linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: fix erofs_get_meta_page locking by a cleanup
@ 2019-09-21  7:30 Gao Xiang
  2019-09-21 18:43 ` [PATCH v2] " Gao Xiang
  2019-09-22  8:32 ` [PATCH] " kbuild test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Gao Xiang @ 2019-09-21  7:30 UTC (permalink / raw)
  To: Chao Yu, linux-erofs; +Cc: Miao Xie, LKML

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/20190904020912.63925-26-gaoxiang25@huawei.com
Fixes: 618f40ea026b ("erofs: use read_cache_page_gfp for erofs_get_meta_page")
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] erofs: fix erofs_get_meta_page locking by a cleanup
  2019-09-21  7:30 [PATCH] erofs: fix erofs_get_meta_page locking by a cleanup Gao Xiang
@ 2019-09-21 18:43 ` Gao Xiang
  2019-09-23 12:16   ` Chao Yu
  2019-09-22  8:32 ` [PATCH] " kbuild test robot
  1 sibling, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2019-09-21 18:43 UTC (permalink / raw)
  To: Chao Yu, linux-erofs; +Cc: Miao Xie, LKML

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/20190904020912.63925-26-gaoxiang25@huawei.com
Fixes: 618f40ea026b ("erofs: use read_cache_page_gfp for erofs_get_meta_page")
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] erofs: fix erofs_get_meta_page locking by a cleanup
  2019-09-21  7:30 [PATCH] erofs: fix erofs_get_meta_page locking by a cleanup Gao Xiang
  2019-09-21 18:43 ` [PATCH v2] " Gao Xiang
@ 2019-09-22  8:32 ` kbuild test robot
  2019-09-22  8:41   ` Gao Xiang
  1 sibling, 1 reply; 5+ messages in thread
From: kbuild test robot @ 2019-09-22  8:32 UTC (permalink / raw)
  To: Gao Xiang; +Cc: linux-erofs, LKML, kbuild-all, Miao Xie

[-- Attachment #1: Type: text/plain, Size: 3191 bytes --]

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 <lkp@intel.com>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56194 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] erofs: fix erofs_get_meta_page locking by a cleanup
  2019-09-22  8:32 ` [PATCH] " kbuild test robot
@ 2019-09-22  8:41   ` Gao Xiang
  0 siblings, 0 replies; 5+ messages in thread
From: Gao Xiang @ 2019-09-22  8:41 UTC (permalink / raw)
  To: kbuild test robot; +Cc: linux-erofs, LKML, kbuild-all, Miao Xie

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] erofs: fix erofs_get_meta_page locking by a cleanup
  2019-09-21 18:43 ` [PATCH v2] " Gao Xiang
@ 2019-09-23 12:16   ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2019-09-23 12:16 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: Miao Xie, LKML

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/20190904020912.63925-26-gaoxiang25@huawei.com
> Fixes: 618f40ea026b ("erofs: use read_cache_page_gfp for erofs_get_meta_page")
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-23 12:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-21  7:30 [PATCH] erofs: fix erofs_get_meta_page locking by a cleanup Gao Xiang
2019-09-21 18:43 ` [PATCH v2] " Gao Xiang
2019-09-23 12:16   ` Chao Yu
2019-09-22  8:32 ` [PATCH] " kbuild test robot
2019-09-22  8:41   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).