From nobody Sun Apr 5 16:28:24 2026 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FAAC362136 for ; Tue, 24 Mar 2026 15:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774367659; cv=none; b=LhQOeruY+iyL8E/24z0ELeXnupQ6CJ7VF+kAn+J6CpNQMr3soh+iJZt3FErxOTYGxWsfFNzO9R7g7fEd6AXYk8YyEh4qmFqbi9N3gmeWxduqrBXOKfTSZeeeIH6HdkZkA9y4Eo3wkDg/OQi7Yj4Y5CO6JzFV/Y0X2tNBi5Hmlss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774367659; c=relaxed/simple; bh=h04A++5eMkMQ8XlvcBHhvTVQR0kRH/gSnae9vDxH2cM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hEERIvITYDDndYZYy0lhmMZIDHheKFjQWKgM/yZsNtp/lOaoVKTEZ+/iHMXbr3E9aepOmB9/WmnwdFZBioB2wNzT2okkzayaLFUb1H5ZUS45Do1UZbuSbaNOPVFTsx+GZtvcDhdYRjDpkz2jBn1P52VDMUpe2cnm8UNQ4OKgM2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=bT4PJjBE; arc=none smtp.client-ip=115.124.30.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="bT4PJjBE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1774367654; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=4hVaJmFmshKdDCM6BozTuwWtZc1MVjyP17xXKKrx3eM=; b=bT4PJjBEgI1fKLYhCq1UASCspqKQLLhe8dxWreBvHa5G3RQZvQ5pXu/GUyUE2dsk2nJtWG6QOvfs1wigyoctQkKdkGbyMch5k6aSA2tmMEYdCAdqMBravUWLZCguukGfNwe3surUDuud9gFjFXuOcJ5EfpRlricJHgoW94sK1l4= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam011083073210;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0X.esRfB_1774367648; Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X.esRfB_1774367648 cluster:ay36) by smtp.aliyun-inc.com; Tue, 24 Mar 2026 23:54:13 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang , Hongbo Li Subject: [PATCH v2] erofs: fix .fadvise() for page cache sharing Date: Tue, 24 Mar 2026 23:54:07 +0800 Message-ID: <20260324155407.371642-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Gao Xiang Reviewed-by: Hongbo Li --- v2: - handle super_setup_bdi() failure properly. fs/erofs/ishare.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index 829d50d5c717..ec433bacc592 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -200,8 +200,19 @@ struct inode *erofs_real_inode(struct inode *inode, bo= ol *need_iput) =20 int __init erofs_init_ishare(void) { - erofs_ishare_mnt =3D kern_mount(&erofs_anon_fs_type); - return PTR_ERR_OR_ZERO(erofs_ishare_mnt); + struct vfsmount *mnt; + int ret; + + mnt =3D kern_mount(&erofs_anon_fs_type); + if (IS_ERR(mnt)) + return PTR_ERR(mnt); + /* generic_fadvise() doesn't work if s_bdi =3D=3D &noop_backing_dev_info = */ + ret =3D super_setup_bdi(mnt->mnt_sb); + if (ret) + kern_unmount(mnt); + else + erofs_ishare_mnt =3D mnt; + return ret; } =20 void erofs_exit_ishare(void) --=20 2.43.5