Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: d86d7817c042 ("erofs: implement .fadvise for page cache share")
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

+13 -2
+13 -2
fs/erofs/ishare.c
··· 200 200 201 201 int __init erofs_init_ishare(void) 202 202 { 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; 205 216 } 206 217 207 218 void erofs_exit_ishare(void)