[PATCH v2 5/5] erofs: use meta buffers for zmap operations

Gao Xiang hsiangkao at linux.alibaba.com
Tue Jan 4 20:02:00 AEDT 2022


Hi Chao,

On Tue, Jan 04, 2022 at 04:15:05PM +0800, Chao Yu wrote:
> On 2022/1/2 12:00, Gao Xiang wrote:

...

> > --- a/fs/erofs/zdata.c
> > +++ b/fs/erofs/zdata.c
> > @@ -698,20 +698,18 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
> >   		goto err_out;
> >   	if (z_erofs_is_inline_pcluster(clt->pcl)) {
> > -		struct page *mpage;
> > +		void *mp;
> > -		mpage = erofs_get_meta_page(inode->i_sb,
> > -					    erofs_blknr(map->m_pa));
> > -		if (IS_ERR(mpage)) {
> > -			err = PTR_ERR(mpage);
> > +		mp = erofs_read_metabuf(&fe->map.buf, inode->i_sb,
> > +					erofs_blknr(map->m_pa), EROFS_NO_KMAP);
> > +		if (IS_ERR(mp)) {
> > +			err = PTR_ERR(mp);
> >   			erofs_err(inode->i_sb,
> >   				  "failed to get inline page, err %d", err);
> >   			goto err_out;
> >   		}
> > -		/* TODO: new subpage feature will get rid of it */
> > -		unlock_page(mpage);
> > -
> > -		WRITE_ONCE(clt->pcl->compressed_pages[0], mpage);
> > +		get_page(fe->map.buf.page);
> 
> Comparing to previous implementation, it adds an extra reference on the page, why?

Thanks for the question. Previously, erofs_get_meta_page was called
independently without reusing zmap mpage, so the page refcount had no
relationship with zmap mpage.

However, now we reuse zmap metabuf instead(fe->map.buf), so an extra
page refcount is needed since zmap metabuf will be released at the end
of readpage or readahead...

Thanks,
Gao Xiang


More information about the Linux-erofs mailing list