After doing more drop_caches stress test on
our products, I found the mistake introduced by
a very recent cleanup [1].
The current rule is that "erofs_get_meta_page"
should be returned with page locked (although
it's mostly unnecessary for read-only fs after
pages are PG_Uptodate), but a fix should be
done for this.
[1] https://lore.kernel.org/r/[email protected]
Fixes: 618f40ea026b ("erofs: use read_cache_page_gfp for erofs_get_meta_page")
Signed-off-by: Gao Xiang <[email protected]>
---
fs/erofs/data.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 8a9fcbd0e8ac..e0207dba31cb 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -34,11 +34,17 @@ static void erofs_readendio(struct bio *bio)
struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
{
- struct inode *const bd_inode = sb->s_bdev->bd_inode;
- struct address_space *const mapping = bd_inode->i_mapping;
+ struct address_space *const mapping = sb->s_bdev->bd_inode->i_mapping;
+ struct page *page;
- return read_cache_page_gfp(mapping, blkaddr,
+ page = read_cache_page_gfp(mapping, blkaddr,
mapping_gfp_constraint(mapping, ~__GFP_FS));
+ if (IS_ERR(page))
+ return PTR_ERR(page);
+
+ /* should already be PageUptodate */
+ lock_page(page);
+ return page;
}
static int erofs_map_blocks_flatmode(struct inode *inode,
--
2.17.1
After doing more drop_caches stress test on
our products, I found the mistake introduced by
a very recent cleanup [1].
The current rule is that "erofs_get_meta_page"
should be returned with page locked (although
it's mostly unnecessary for read-only fs after
pages are PG_uptodate), but a fix should be
done for this.
[1] https://lore.kernel.org/r/[email protected]
Fixes: 618f40ea026b ("erofs: use read_cache_page_gfp for erofs_get_meta_page")
Signed-off-by: Gao Xiang <[email protected]>
---
changelog from v1:
- type of return value should be struct page *.
fs/erofs/data.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 8a9fcbd0e8ac..fc3a8d8064f8 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -34,11 +34,15 @@ static void erofs_readendio(struct bio *bio)
struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
{
- struct inode *const bd_inode = sb->s_bdev->bd_inode;
- struct address_space *const mapping = bd_inode->i_mapping;
+ struct address_space *const mapping = sb->s_bdev->bd_inode->i_mapping;
+ struct page *page;
- return read_cache_page_gfp(mapping, blkaddr,
+ page = read_cache_page_gfp(mapping, blkaddr,
mapping_gfp_constraint(mapping, ~__GFP_FS));
+ /* should already be PageUptodate */
+ if (!IS_ERR(page))
+ lock_page(page);
+ return page;
}
static int erofs_map_blocks_flatmode(struct inode *inode,
--
2.17.1
Hi Gao,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.3 next-20190920]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Gao-Xiang/erofs-fix-erofs_get_meta_page-locking-by-a-cleanup/20190921-173503
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390
:::::: branch date: 57 minutes ago
:::::: commit date: 57 minutes ago
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>
All warnings (new ones prefixed by >>):
fs//erofs/data.c: In function 'erofs_get_meta_page':
>> fs//erofs/data.c:43:10: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PTR_ERR(page);
^~~~~~~~~~~~~
# https://github.com/0day-ci/linux/commit/e21cd9836355e16fdb49ff36d5492ed35b2abe5c
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout e21cd9836355e16fdb49ff36d5492ed35b2abe5c
vim +43 fs//erofs/data.c
81781b02f9845b drivers/staging/erofs/data.c Gao Xiang 2018-07-26 34
e655b5b3a29c5a fs/erofs/data.c Gao Xiang 2019-09-04 35 struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
81781b02f9845b drivers/staging/erofs/data.c Gao Xiang 2018-07-26 36 {
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 37 struct address_space *const mapping = sb->s_bdev->bd_inode->i_mapping;
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 38 struct page *page;
81781b02f9845b drivers/staging/erofs/data.c Gao Xiang 2018-07-26 39
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 40 page = read_cache_page_gfp(mapping, blkaddr,
618f40ea026bda fs/erofs/data.c Gao Xiang 2019-09-04 41 mapping_gfp_constraint(mapping, ~__GFP_FS));
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 42 if (IS_ERR(page))
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 @43 return PTR_ERR(page);
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 44
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 45 /* should already be PageUptodate */
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 46 lock_page(page);
e21cd9836355e1 fs/erofs/data.c Gao Xiang 2019-09-21 47 return page;
81781b02f9845b drivers/staging/erofs/data.c Gao Xiang 2018-07-26 48 }
81781b02f9845b drivers/staging/erofs/data.c Gao Xiang 2018-07-26 49
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi,
On Sun, Sep 22, 2019 at 04:32:05PM +0800, kbuild test robot wrote:
>
> All warnings (new ones prefixed by >>):
>
> fs//erofs/data.c: In function 'erofs_get_meta_page':
> >> fs//erofs/data.c:43:10: warning: return makes pointer from integer without a cast [-Wint-conversion]
> return PTR_ERR(page);
It was already fixed in v2.
Thanks,
Gao Xiang
On 2019/9/22 2:43, Gao Xiang wrote:
> After doing more drop_caches stress test on
> our products, I found the mistake introduced by
> a very recent cleanup [1].
>
> The current rule is that "erofs_get_meta_page"
> should be returned with page locked (although
> it's mostly unnecessary for read-only fs after
> pages are PG_uptodate), but a fix should be
> done for this.
>
> [1] https://lore.kernel.org/r/[email protected]
> Fixes: 618f40ea026b ("erofs: use read_cache_page_gfp for erofs_get_meta_page")
> Signed-off-by: Gao Xiang <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Thanks,