linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 09/16] btrfs: IS_ERR(p) && PTR_ERR(p) == n is a weird way to spell p == ERR_PTR(n)
       [not found]   ` <20180729220453.13431-9-viro@ZenIV.linux.org.uk>
@ 2018-07-30  8:06     ` Nikolay Borisov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2018-07-30  8:06 UTC (permalink / raw)
  To: Al Viro, linux-fsdevel
  Cc: Linus Torvalds, linux-kernel, Miklos Szeredi, Chris Mason,
	David Sterba, linux-btrfs


[ADDED David Sterba and Linux-btrfs mailing list]

On 30.07.2018 01:04, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> Cc: Chris Mason <clm@fb.com>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

David, yout might want to pull this immediately, it's a nice cleanup.

> ---
>  fs/btrfs/transaction.c | 2 +-
>  fs/btrfs/tree-log.c    | 5 ++---
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index ff5f6c719976..feb0348dbcbf 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -680,7 +680,7 @@ btrfs_attach_transaction_barrier(struct btrfs_root *root)
>  
>  	trans = start_transaction(root, 0, TRANS_ATTACH,
>  				  BTRFS_RESERVE_NO_FLUSH, true);
> -	if (IS_ERR(trans) && PTR_ERR(trans) == -ENOENT)
> +	if (trans == ERR_PTR(-ENOENT))
>  		btrfs_wait_for_commit(root->fs_info, 0);
>  
>  	return trans;
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index fcfbe1d8584a..2c13e8155ff1 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -2116,7 +2116,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
>  						     dir_key->offset,
>  						     name, name_len, 0);
>  		}
> -		if (!log_di || (IS_ERR(log_di) && PTR_ERR(log_di) == -ENOENT)) {
> +		if (!log_di || log_di ==  ERR_PTR(-ENOENT)) {
>  			btrfs_dir_item_key_to_cpu(eb, di, &location);
>  			btrfs_release_path(path);
>  			btrfs_release_path(log_path);
> @@ -5090,8 +5090,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
>  				 * we don't need to do more work nor fallback to
>  				 * a transaction commit.
>  				 */
> -				if (IS_ERR(other_inode) &&
> -				    PTR_ERR(other_inode) == -ENOENT) {
> +				if (other_inode == ERR_PTR(-ENOENT)) {
>  					goto next_key;
>  				} else if (IS_ERR(other_inode)) {
>  					err = PTR_ERR(other_inode);
> 

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

* Re: [PATCH 08/16] btrfs: btrfs_iget() never returns an is_bad_inode() inode.
       [not found]   ` <20180729220453.13431-8-viro@ZenIV.linux.org.uk>
@ 2018-07-30  8:13     ` Nikolay Borisov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2018-07-30  8:13 UTC (permalink / raw)
  To: Al Viro, linux-fsdevel
  Cc: Linus Torvalds, linux-kernel, Miklos Szeredi, Chris Mason,
	David Sterba, linux-btrfs


[ADDED David Sterba and Linux-btrf ml]
On 30.07.2018 01:04, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> just get rid of pointless checks
> 
> Cc: Chris Mason <clm@fb.com>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

It seems even if we return is_bad_inode from btrfs_read_locked_inode we
always override it in the else branch in btrfs_iget. So :

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/free-space-cache.c | 4 ----
>  fs/btrfs/relocation.c       | 7 ++-----
>  fs/btrfs/tree-log.c         | 6 +-----
>  3 files changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index d5f80cb300be..79f03b3bbbd4 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -71,10 +71,6 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
>  	inode = btrfs_iget(fs_info->sb, &location, root, NULL);
>  	if (IS_ERR(inode))
>  		return inode;
> -	if (is_bad_inode(inode)) {
> -		iput(inode);
> -		return ERR_PTR(-ENOENT);
> -	}
>  
>  	mapping_set_gfp_mask(inode->i_mapping,
>  			mapping_gfp_constraint(inode->i_mapping,
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 879b76fa881a..f6e8dc134e44 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3563,11 +3563,8 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info,
>  	key.offset = 0;
>  
>  	inode = btrfs_iget(fs_info->sb, &key, root, NULL);
> -	if (IS_ERR(inode) || is_bad_inode(inode)) {
> -		if (!IS_ERR(inode))
> -			iput(inode);
> +	if (IS_ERR(inode))
>  		return -ENOENT;
> -	}
>  
>  truncate:
>  	ret = btrfs_check_trunc_cache_free_space(fs_info,
> @@ -4284,7 +4281,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
>  	key.type = BTRFS_INODE_ITEM_KEY;
>  	key.offset = 0;
>  	inode = btrfs_iget(fs_info->sb, &key, root, NULL);
> -	BUG_ON(IS_ERR(inode) || is_bad_inode(inode));
> +	BUG_ON(IS_ERR(inode));
>  	BTRFS_I(inode)->index_cnt = group->key.objectid;
>  
>  	err = btrfs_orphan_add(trans, BTRFS_I(inode));
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index f8220ec02036..fcfbe1d8584a 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -545,12 +545,8 @@ static noinline struct inode *read_one_inode(struct btrfs_root *root,
>  	key.type = BTRFS_INODE_ITEM_KEY;
>  	key.offset = 0;
>  	inode = btrfs_iget(root->fs_info->sb, &key, root, NULL);
> -	if (IS_ERR(inode)) {
> +	if (IS_ERR(inode))
>  		inode = NULL;
> -	} else if (is_bad_inode(inode)) {
> -		iput(inode);
> -		inode = NULL;
> -	}
>  	return inode;
>  }
>  
> 

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

* Re: [PATCH 13/16] btrfs: lift make_bad_inode() into btrfs_iget()
       [not found]   ` <20180729220453.13431-13-viro@ZenIV.linux.org.uk>
@ 2018-07-30  8:15     ` Nikolay Borisov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2018-07-30  8:15 UTC (permalink / raw)
  To: Al Viro, linux-fsdevel
  Cc: Linus Torvalds, linux-kernel, Miklos Szeredi, David Sterba,
	linux-btrfs



On 30.07.2018 01:04, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> we don't need to check is_bad_inode() after the call of
> btrfs_read_locked_inode() - it's exactly the same as checking
> return value for being non-zero.
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 9382e0881900..8f0b2592feb0 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3777,7 +3777,6 @@ static int btrfs_read_locked_inode(struct inode *inode)
>  
>  make_bad:
>  	btrfs_free_path(path);
> -	make_bad_inode(inode);
>  	return ret;
>  }
>  
> @@ -5708,12 +5707,13 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
>  		int ret;
>  
>  		ret = btrfs_read_locked_inode(inode);
> -		if (!is_bad_inode(inode)) {
> +		if (!ret) {
>  			inode_tree_add(inode);
>  			unlock_new_inode(inode);
>  			if (new)
>  				*new = 1;
>  		} else {
> +			make_bad_inode(inode);
>  			unlock_new_inode(inode);
>  			iput(inode);
>  			ASSERT(ret < 0);
> 

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

* Re: [PATCH 14/16] btrfs: simplify btrfs_iget()
       [not found]   ` <20180729220453.13431-14-viro@ZenIV.linux.org.uk>
@ 2018-07-30  8:17     ` Nikolay Borisov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2018-07-30  8:17 UTC (permalink / raw)
  To: Al Viro, linux-fsdevel
  Cc: Linus Torvalds, linux-kernel, Miklos Szeredi, David Sterba,
	linux-btrfs

[ADDED David Sterba and Linux-btrfs ml to cc. ]

On 30.07.2018 01:04, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> don't open-code iget_failed(), don't bother with btrfs_free_path(NULL),
> move handling of positive return values of btrfs_lookup_inode() from
> btrfs_read_locked_inode() to btrfs_iget() and kill now obviously pointless
> ASSERT() in there.
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/inode.c | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 8f0b2592feb0..388b2dba68a0 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3610,18 +3610,15 @@ static int btrfs_read_locked_inode(struct inode *inode)
>  		filled = true;
>  
>  	path = btrfs_alloc_path();
> -	if (!path) {
> -		ret = -ENOMEM;
> -		goto make_bad;
> -	}
> +	if (!path)
> +		return -ENOMEM;
>  
>  	memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
>  
>  	ret = btrfs_lookup_inode(NULL, root, path, &location, 0);
>  	if (ret) {
> -		if (ret > 0)
> -			ret = -ENOENT;
> -		goto make_bad;
> +		btrfs_free_path(path);
> +		return ret;
>  	}
>  
>  	leaf = path->nodes[0];
> @@ -3774,10 +3771,6 @@ static int btrfs_read_locked_inode(struct inode *inode)
>  
>  	btrfs_sync_inode_flags_to_i_flags(inode);
>  	return 0;
> -
> -make_bad:
> -	btrfs_free_path(path);
> -	return ret;
>  }
>  
>  /*
> @@ -5713,11 +5706,10 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
>  			if (new)
>  				*new = 1;
>  		} else {
> -			make_bad_inode(inode);
> -			unlock_new_inode(inode);
> -			iput(inode);
> -			ASSERT(ret < 0);
> -			inode = ERR_PTR(ret < 0 ? ret : -ESTALE);
> +			iget_failed(inode);
> +			if (ret > 0)
> +				ret = -ENOENT;
> +			inode = ERR_PTR(ret);
>  		}
>  	}
>  
> 

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

end of thread, other threads:[~2018-07-30  9:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180729220317.GB30522@ZenIV.linux.org.uk>
     [not found] ` <20180729220453.13431-1-viro@ZenIV.linux.org.uk>
     [not found]   ` <20180729220453.13431-9-viro@ZenIV.linux.org.uk>
2018-07-30  8:06     ` [PATCH 09/16] btrfs: IS_ERR(p) && PTR_ERR(p) == n is a weird way to spell p == ERR_PTR(n) Nikolay Borisov
     [not found]   ` <20180729220453.13431-8-viro@ZenIV.linux.org.uk>
2018-07-30  8:13     ` [PATCH 08/16] btrfs: btrfs_iget() never returns an is_bad_inode() inode Nikolay Borisov
     [not found]   ` <20180729220453.13431-13-viro@ZenIV.linux.org.uk>
2018-07-30  8:15     ` [PATCH 13/16] btrfs: lift make_bad_inode() into btrfs_iget() Nikolay Borisov
     [not found]   ` <20180729220453.13431-14-viro@ZenIV.linux.org.uk>
2018-07-30  8:17     ` [PATCH 14/16] btrfs: simplify btrfs_iget() Nikolay Borisov

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).