Skip to content

Commit 2f0407e

Browse files
committed
erofs: fix .fadvise() for page cache sharing
Currently, .fadvise() doesn't work well if page cache sharing is on since shared inodes belong to a pseudo fs generated with init_pseudo(), and sb->s_bdi is the default one &noop_backing_dev_info. Then, generic_fadvise() will just behave as a no-op if sb->s_bdi is &noop_backing_dev_info, but as the bdev fs (the bdev fs changes inode_to_bdi() instead), it's actually NOT a pure memfs. Let's generate a real bdi for erofs_ishare_mnt instead. Fixes: d86d781 ("erofs: implement .fadvise for page cache share") Reviewed-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 938c418 commit 2f0407e

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

fs/erofs/ishare.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,19 @@ struct inode *erofs_real_inode(struct inode *inode, bool *need_iput)
200200

201201
int __init erofs_init_ishare(void)
202202
{
203-
erofs_ishare_mnt = kern_mount(&erofs_anon_fs_type);
204-
return PTR_ERR_OR_ZERO(erofs_ishare_mnt);
203+
struct vfsmount *mnt;
204+
int ret;
205+
206+
mnt = kern_mount(&erofs_anon_fs_type);
207+
if (IS_ERR(mnt))
208+
return PTR_ERR(mnt);
209+
/* generic_fadvise() doesn't work if s_bdi == &noop_backing_dev_info */
210+
ret = super_setup_bdi(mnt->mnt_sb);
211+
if (ret)
212+
kern_unmount(mnt);
213+
else
214+
erofs_ishare_mnt = mnt;
215+
return ret;
205216
}
206217

207218
void erofs_exit_ishare(void)

0 commit comments

Comments
 (0)