mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Chao Yu <yuchao0@huawei.com>
Cc: Chao Yu <chao@kernel.org>, <devel@driverdev.osuosl.org>,
	<linux-erofs@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/8] staging: erofs: add error handling for xattr submodule
Date: Mon, 13 Aug 2018 10:36:39 +0800	[thread overview]
Message-ID: <3d6e8cd9-0263-2196-7b45-b60245f0ba7c@huawei.com> (raw)
In-Reply-To: <11a5b8c0-c3fa-0da9-a41b-a6b33ddcc9bb@huawei.com>

Hi Chao,

On 2018/8/13 10:00, Chao Yu wrote:
> On 2018/8/12 22:01, Chao Yu wrote:
>> From: Gao Xiang <gaoxiang25@huawei.com>
>>
>> This patch enhances the missing error handling code for
>> xattr submodule, which improves the stability for the rare cases.
>>
>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
>> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>  drivers/staging/erofs/internal.h |   6 +-
>>  drivers/staging/erofs/xattr.c    | 120 ++++++++++++++++++++-----------
>>  2 files changed, 83 insertions(+), 43 deletions(-)
>>
>> diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
>> index a756abeff7e9..8951e01216e3 100644
>> --- a/drivers/staging/erofs/internal.h
>> +++ b/drivers/staging/erofs/internal.h
>> @@ -485,10 +485,10 @@ struct erofs_map_blocks_iter {
>>  
>>  
>>  static inline struct page *
>> -erofs_get_inline_page_nofail(struct inode *inode,
>> -			     erofs_blk_t blkaddr)
>> +erofs_get_inline_page(struct inode *inode,
>> +		      erofs_blk_t blkaddr)
>>  {
>> -	return erofs_get_meta_page_nofail(inode->i_sb,
>> +	return erofs_get_meta_page(inode->i_sb,
>>  		blkaddr, S_ISDIR(inode->i_mode));
>>  }
>>  
>> diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
>> index 2593c856b079..1b5815fc70db 100644
>> --- a/drivers/staging/erofs/xattr.c
>> +++ b/drivers/staging/erofs/xattr.c
>> @@ -24,16 +24,25 @@ struct xattr_iter {
>>  
>>  static inline void xattr_iter_end(struct xattr_iter *it, bool atomic)
>>  {
>> -	/* only init_inode_xattrs use non-atomic once */
>> +	/* the only user of kunmap() is 'init_inode_xattrs' */
>>  	if (unlikely(!atomic))
>>  		kunmap(it->page);
>>  	else
>>  		kunmap_atomic(it->kaddr);
>> +
>>  	unlock_page(it->page);
>>  	put_page(it->page);
>>  }
>>  
>> -static void init_inode_xattrs(struct inode *inode)
>> +static inline void xattr_iter_end_final(struct xattr_iter *it)
>> +{
>> +	if (unlikely(it->page == NULL))
>> +		return;
>> +
>> +	xattr_iter_end(it, true);
>> +}
>> +
>> +static int init_inode_xattrs(struct inode *inode)
>>  {
>>  	struct xattr_iter it;
>>  	unsigned i;
>> @@ -44,7 +53,7 @@ static void init_inode_xattrs(struct inode *inode)
>>  	bool atomic_map;
>>  
>>  	if (likely(inode_has_inited_xattr(inode)))
>> -		return;
>> +		return 0;
>>  
>>  	vi = EROFS_V(inode);
>>  	BUG_ON(!vi->xattr_isize);
>> @@ -54,8 +63,9 @@ static void init_inode_xattrs(struct inode *inode)
>>  	it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize);
>>  	it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize);
>>  
>> -	it.page = erofs_get_inline_page_nofail(inode, it.blkaddr);
>> -	BUG_ON(IS_ERR(it.page));
>> +	it.page = erofs_get_inline_page(inode, it.blkaddr);
>> +	if (IS_ERR(it.page))
>> +		return PTR_ERR(it.page);
>>  
>>  	/* read in shared xattr array (non-atomic, see kmalloc below) */
>>  	it.kaddr = kmap(it.page);
>> @@ -64,9 +74,12 @@ static void init_inode_xattrs(struct inode *inode)
>>  	ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
>>  
>>  	vi->xattr_shared_count = ih->h_shared_count;
>> -	vi->xattr_shared_xattrs = (unsigned *)kmalloc_array(
>> -		vi->xattr_shared_count, sizeof(unsigned),
>> -		GFP_KERNEL | __GFP_NOFAIL);
>> +	vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
>> +						sizeof(unsigned), GFP_KERNEL);
>> +	if (unlikely(vi->xattr_shared_xattrs == NULL)) {
>> +		xattr_iter_end(&it, atomic_map);
>> +		return -ENOMEM;
>> +	}
>>  
>>  	/* let's skip ibody header */
>>  	it.ofs += sizeof(struct erofs_xattr_ibody_header);
>> @@ -77,9 +90,10 @@ static void init_inode_xattrs(struct inode *inode)
>>  			BUG_ON(it.ofs != EROFS_BLKSIZ);
>>  			xattr_iter_end(&it, atomic_map);
>>  
>> -			it.page = erofs_get_meta_page_nofail(sb,
>> +			it.page = erofs_get_meta_page(sb,
>>  				++it.blkaddr, S_ISDIR(inode->i_mode));
>> -			BUG_ON(IS_ERR(it.page));
>> +			if (IS_ERR(it.page))
>> +				return PTR_ERR(it.page);
>>  
>>  			it.kaddr = kmap_atomic(it.page);
>>  			atomic_map = true;
>> @@ -92,6 +106,7 @@ static void init_inode_xattrs(struct inode *inode)
>>  	xattr_iter_end(&it, atomic_map);
>>  
>>  	inode_set_inited_xattr(inode);
>> +	return 0;
>>  }
>>  
>>  struct xattr_iter_handlers {
>> @@ -101,19 +116,24 @@ struct xattr_iter_handlers {
>>  	void (*value)(struct xattr_iter *, unsigned, char *, unsigned);
>>  };
>>  
>> -static void xattr_iter_fixup(struct xattr_iter *it)
>> +static inline int xattr_iter_fixup(struct xattr_iter *it)
>>  {
>> -	if (unlikely(it->ofs >= EROFS_BLKSIZ)) {
>> -		xattr_iter_end(it, true);
>> +	if (likely(it->ofs < EROFS_BLKSIZ))
>> +		return 0;
>>  
>> -		it->blkaddr += erofs_blknr(it->ofs);
>> -		it->page = erofs_get_meta_page_nofail(it->sb,
>> -			it->blkaddr, false);
>> -		BUG_ON(IS_ERR(it->page));
>> +	xattr_iter_end(it, true);
>>  
>> -		it->kaddr = kmap_atomic(it->page);
>> -		it->ofs = erofs_blkoff(it->ofs);
>> +	it->blkaddr += erofs_blknr(it->ofs);
>> +
>> +	it->page = erofs_get_meta_page(it->sb, it->blkaddr, false);
>> +	if (IS_ERR(it->page)) {
>> +		it->page = NULL;
>> +		return PTR_ERR(it->page);
> As LKP reported, we need to fix this as below:
> 
> err = PTR_ERR(it->page);
> it->page = NULL;
> return err;
> 
> Thanks,
>

I have seen this at
https://lists.01.org/pipermail/kbuild-all/2018-August/051187.html

I will fix it soon. Thanks for report.

Thanks,
Gao Xiang

  reply	other threads:[~2018-08-13  2:41 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-12 14:01 [PATCH 0/8] staging: erofs: fix some issues and clean up codes Chao Yu
2018-08-12 14:01 ` [PATCH 1/8] staging: erofs: introduce erofs_grab_bio Chao Yu
2018-08-12 14:01 ` [PATCH 2/8] staging: erofs: separate erofs_get_meta_page Chao Yu
2018-08-13 11:04   ` Dan Carpenter
2018-08-13 11:23     ` Gao Xiang
2018-08-13 12:34     ` Chao Yu
2018-08-12 14:01 ` [PATCH 3/8] staging: erofs: add error handling for xattr submodule Chao Yu
2018-08-13  2:00   ` Chao Yu
2018-08-13  2:36     ` Gao Xiang [this message]
2018-08-13  2:56       ` [PATCH v2 " Gao Xiang
2018-08-13  8:15       ` [PATCH " Chao Yu
2018-08-13 11:47   ` Dan Carpenter
2018-08-13 12:17     ` Gao Xiang
2018-08-13 12:25       ` Dan Carpenter
2018-08-13 13:40         ` Gao Xiang
2018-08-13 13:50           ` Dan Carpenter
2018-08-13 12:40       ` Dan Carpenter
2018-08-13 12:46         ` Gao Xiang
2018-08-13 12:46       ` Chao Yu
2018-08-12 14:01 ` [PATCH 4/8] staging: erofs: cleanup z_erofs_vle_work_{lookup, register} Chao Yu
2018-08-13 12:00   ` Dan Carpenter
2018-08-13 12:37     ` Gao Xiang
2018-08-13 13:05       ` Dan Carpenter
2018-08-13 13:19         ` Gao Xiang
2018-08-12 14:01 ` [PATCH 5/8] staging: erofs: rearrange vle clustertype definitions Chao Yu
2018-08-12 14:01 ` [PATCH 6/8] staging: erofs: fix vle_decompressed_index_clusterofs Chao Yu
2018-08-13 12:03   ` Dan Carpenter
2018-08-13 13:01     ` Gao Xiang
2018-08-12 14:01 ` [PATCH 7/8] staging: erofs: fix integer overflow on 32-bit platform Chao Yu
2018-08-12 14:01 ` [PATCH 8/8] staging: erofs: fix compression mapping beyond EOF Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d6e8cd9-0263-2196-7b45-b60245f0ba7c@huawei.com \
    --to=gaoxiang25@huawei.com \
    --cc=chao@kernel.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®