Linux-ext4 Archive on lore.kernel.org
 help / color / Atom feed
* [bug report] ext4, project: expand inode extra size if possible
@ 2019-12-02  9:41 Dan Carpenter
  2019-12-13 11:32 ` Jan Kara
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-12-02  9:41 UTC (permalink / raw)
  To: miaoxie; +Cc: linux-ext4

Hello Miao Xie,

The patch c03b45b853f5: "ext4, project: expand inode extra size if
possible" from Aug 6, 2017, leads to the following static checker
warning:

    fs/ext4/inode.c:5708 ext4_expand_extra_isize()
    warn: inconsistent returns 'EXT4_I(inode)->xattr_sem'.
      Locked on  : 5708
      Unlocked on: 5708

fs/ext4/inode.c
  5681          handle = ext4_journal_start(inode, EXT4_HT_INODE,
  5682                                      EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
  5683          if (IS_ERR(handle)) {
  5684                  error = PTR_ERR(handle);
  5685                  brelse(iloc->bh);
  5686                  return error;
  5687          }
  5688  
  5689          ext4_write_lock_xattr(inode, &no_expand);
  5690  
  5691          BUFFER_TRACE(iloc->bh, "get_write_access");
  5692          error = ext4_journal_get_write_access(handle, iloc->bh);
  5693          if (error) {
  5694                  brelse(iloc->bh);
  5695                  goto out_stop;

Shouldn't this goto the ext4_write_unlock_xattr()?

  5696          }
  5697  
  5698          error = __ext4_expand_extra_isize(inode, new_extra_isize, iloc,
  5699                                            handle, &no_expand);
  5700  
  5701          rc = ext4_mark_iloc_dirty(handle, inode, iloc);
  5702          if (!error)
  5703                  error = rc;
  5704  
  5705          ext4_write_unlock_xattr(inode, &no_expand);
  5706  out_stop:
  5707          ext4_journal_stop(handle);
  5708          return error;
  5709  }


regards,
dan carpenter

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

* Re: [bug report] ext4, project: expand inode extra size if possible
  2019-12-02  9:41 [bug report] ext4, project: expand inode extra size if possible Dan Carpenter
@ 2019-12-13 11:32 ` Jan Kara
  2019-12-13 18:50   ` [PATCH] ext4: unlock on error in ext4_expand_extra_isize() Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2019-12-13 11:32 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: miaoxie, linux-ext4

On Mon 02-12-19 12:41:04, Dan Carpenter wrote:
> Hello Miao Xie,
> 
> The patch c03b45b853f5: "ext4, project: expand inode extra size if
> possible" from Aug 6, 2017, leads to the following static checker
> warning:
> 
>     fs/ext4/inode.c:5708 ext4_expand_extra_isize()
>     warn: inconsistent returns 'EXT4_I(inode)->xattr_sem'.
>       Locked on  : 5708
>       Unlocked on: 5708
> 
> fs/ext4/inode.c
>   5681          handle = ext4_journal_start(inode, EXT4_HT_INODE,
>   5682                                      EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
>   5683          if (IS_ERR(handle)) {
>   5684                  error = PTR_ERR(handle);
>   5685                  brelse(iloc->bh);
>   5686                  return error;
>   5687          }
>   5688  
>   5689          ext4_write_lock_xattr(inode, &no_expand);
>   5690  
>   5691          BUFFER_TRACE(iloc->bh, "get_write_access");
>   5692          error = ext4_journal_get_write_access(handle, iloc->bh);
>   5693          if (error) {
>   5694                  brelse(iloc->bh);
>   5695                  goto out_stop;
> 
> Shouldn't this goto the ext4_write_unlock_xattr()?

Yes, it should AFAICT. Thanks for spotting this. Care to send a patch?

								Honza

> 
>   5696          }
>   5697  
>   5698          error = __ext4_expand_extra_isize(inode, new_extra_isize, iloc,
>   5699                                            handle, &no_expand);
>   5700  
>   5701          rc = ext4_mark_iloc_dirty(handle, inode, iloc);
>   5702          if (!error)
>   5703                  error = rc;
>   5704  
>   5705          ext4_write_unlock_xattr(inode, &no_expand);
>   5706  out_stop:
>   5707          ext4_journal_stop(handle);
>   5708          return error;
>   5709  }
> 
> 
> regards,
> dan carpenter
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* [PATCH] ext4: unlock on error in ext4_expand_extra_isize()
  2019-12-13 11:32 ` Jan Kara
@ 2019-12-13 18:50   ` Dan Carpenter
  2019-12-14 22:32     ` Theodore Y. Ts'o
  2019-12-16  9:22     ` Miao Xie
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-12-13 18:50 UTC (permalink / raw)
  To: Theodore Ts'o, Miao Xie; +Cc: Andreas Dilger, linux-ext4, kernel-janitors

We need to unlock the xattr before returning on this error path.

Fixes: c03b45b853f5 ("ext4, project: expand inode extra size if possible")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/ext4/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 28f28de0c1b6..629a25d999f0 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5692,7 +5692,7 @@ int ext4_expand_extra_isize(struct inode *inode,
 	error = ext4_journal_get_write_access(handle, iloc->bh);
 	if (error) {
 		brelse(iloc->bh);
-		goto out_stop;
+		goto out_unlock;
 	}
 
 	error = __ext4_expand_extra_isize(inode, new_extra_isize, iloc,
@@ -5702,8 +5702,8 @@ int ext4_expand_extra_isize(struct inode *inode,
 	if (!error)
 		error = rc;
 
+out_unlock:
 	ext4_write_unlock_xattr(inode, &no_expand);
-out_stop:
 	ext4_journal_stop(handle);
 	return error;
 }
-- 
2.11.0


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

* Re: [PATCH] ext4: unlock on error in ext4_expand_extra_isize()
  2019-12-13 18:50   ` [PATCH] ext4: unlock on error in ext4_expand_extra_isize() Dan Carpenter
@ 2019-12-14 22:32     ` Theodore Y. Ts'o
  2019-12-16  9:22     ` Miao Xie
  1 sibling, 0 replies; 5+ messages in thread
From: Theodore Y. Ts'o @ 2019-12-14 22:32 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Miao Xie, Andreas Dilger, linux-ext4, kernel-janitors

On Fri, Dec 13, 2019 at 09:50:11PM +0300, Dan Carpenter wrote:
> We need to unlock the xattr before returning on this error path.
> 
> Fixes: c03b45b853f5 ("ext4, project: expand inode extra size if possible")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied.

					- Ted

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

* Re: [PATCH] ext4: unlock on error in ext4_expand_extra_isize()
  2019-12-13 18:50   ` [PATCH] ext4: unlock on error in ext4_expand_extra_isize() Dan Carpenter
  2019-12-14 22:32     ` Theodore Y. Ts'o
@ 2019-12-16  9:22     ` Miao Xie
  1 sibling, 0 replies; 5+ messages in thread
From: Miao Xie @ 2019-12-16  9:22 UTC (permalink / raw)
  To: Dan Carpenter, Theodore Ts'o
  Cc: Andreas Dilger, linux-ext4, kernel-janitors

Hi, Dan Carpenter

I forgot to reply your mail because I'm busy recently. Sorry.
Thanks for your fix.

Regards
Miao

on 2019/12/14 at 2:50, Dan Carpenter wrote:
> We need to unlock the xattr before returning on this error path.
> 
> Fixes: c03b45b853f5 ("ext4, project: expand inode extra size if possible")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/ext4/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 28f28de0c1b6..629a25d999f0 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5692,7 +5692,7 @@ int ext4_expand_extra_isize(struct inode *inode,
>  	error = ext4_journal_get_write_access(handle, iloc->bh);
>  	if (error) {
>  		brelse(iloc->bh);
> -		goto out_stop;
> +		goto out_unlock;
>  	}
>  
>  	error = __ext4_expand_extra_isize(inode, new_extra_isize, iloc,
> @@ -5702,8 +5702,8 @@ int ext4_expand_extra_isize(struct inode *inode,
>  	if (!error)
>  		error = rc;
>  
> +out_unlock:
>  	ext4_write_unlock_xattr(inode, &no_expand);
> -out_stop:
>  	ext4_journal_stop(handle);
>  	return error;
>  }
> 

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02  9:41 [bug report] ext4, project: expand inode extra size if possible Dan Carpenter
2019-12-13 11:32 ` Jan Kara
2019-12-13 18:50   ` [PATCH] ext4: unlock on error in ext4_expand_extra_isize() Dan Carpenter
2019-12-14 22:32     ` Theodore Y. Ts'o
2019-12-16  9:22     ` Miao Xie

Linux-ext4 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ext4/0 linux-ext4/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ext4 linux-ext4/ https://lore.kernel.org/linux-ext4 \
		linux-ext4@vger.kernel.org
	public-inbox-index linux-ext4

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ext4


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git