mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] erofs: fix .fadvise() for page cache sharing
@ 2026-03-24 14:08 Gao Xiang
  0 siblings, 0 replies; only message in thread
From: Gao Xiang @ 2026-03-24 14:08 UTC (permalink / raw)
  To: linux-erofs; +Cc: LKML, Gao Xiang, Hongbo Li

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")
Cc: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 fs/erofs/ishare.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c
index 829d50d5c717..57b51d77263d 100644
--- a/fs/erofs/ishare.c
+++ b/fs/erofs/ishare.c
@@ -201,7 +201,10 @@ struct inode *erofs_real_inode(struct inode *inode, bool *need_iput)
 int __init erofs_init_ishare(void)
 {
 	erofs_ishare_mnt = kern_mount(&erofs_anon_fs_type);
-	return PTR_ERR_OR_ZERO(erofs_ishare_mnt);
+	if (IS_ERR_OR_NULL(erofs_ishare_mnt))
+		return PTR_ERR_OR_ZERO(erofs_ishare_mnt);
+	/* generic_fadvise() doesn't work if s_bdi == &noop_backing_dev_info */
+	return super_setup_bdi(erofs_ishare_mnt->mnt_sb);
 }
 
 void erofs_exit_ishare(void)
-- 
2.43.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-24 14:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-24 14:08 [PATCH] erofs: fix .fadvise() for page cache sharing Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®