linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use IS_ERR instead of IS_ERR_OR_NULL and set inode null when IS_ERR.
@ 2020-12-30  3:38 Yi Li
  2021-01-06 13:02 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Yi Li @ 2020-12-30  3:38 UTC (permalink / raw)
  To: tytso; +Cc: yilikernel, adilger.kernel, linux-ext4, linux-kernel, Yi Li

1: ext4_iget/ext4_find_extent never returns NULL, use IS_ERR
instead of IS_ERR_OR_NULL to fix this.

2: ext4_fc_replay_inode should set the inode to NULL when IS_ERR.
and go to call iput properly.

Signed-off-by: Yi Li <yili@winhong.com>
---
 fs/ext4/fast_commit.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index 4fcc21c25e79..6b5489273c85 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -1318,14 +1318,14 @@ static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl)
 	entry.len = darg.dname_len;
 	inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
 
-	if (IS_ERR_OR_NULL(inode)) {
+	if (IS_ERR(inode)) {
 		jbd_debug(1, "Inode %d not found", darg.ino);
 		return 0;
 	}
 
 	old_parent = ext4_iget(sb, darg.parent_ino,
 				EXT4_IGET_NORMAL);
-	if (IS_ERR_OR_NULL(old_parent)) {
+	if (IS_ERR(old_parent)) {
 		jbd_debug(1, "Dir with inode  %d not found", darg.parent_ino);
 		iput(inode);
 		return 0;
@@ -1410,7 +1410,7 @@ static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl)
 			darg.parent_ino, darg.dname_len);
 
 	inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
-	if (IS_ERR_OR_NULL(inode)) {
+	if (IS_ERR(inode)) {
 		jbd_debug(1, "Inode not found.");
 		return 0;
 	}
@@ -1466,10 +1466,11 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
 	trace_ext4_fc_replay(sb, tag, ino, 0, 0);
 
 	inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
-	if (!IS_ERR_OR_NULL(inode)) {
+	if (!IS_ERR(inode)) {
 		ext4_ext_clear_bb(inode);
 		iput(inode);
 	}
+	inode = NULL;
 
 	ext4_fc_record_modified_inode(sb, ino);
 
@@ -1512,7 +1513,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
 
 	/* Given that we just wrote the inode on disk, this SHOULD succeed. */
 	inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
-	if (IS_ERR_OR_NULL(inode)) {
+	if (IS_ERR(inode)) {
 		jbd_debug(1, "Inode not found.");
 		return -EFSCORRUPTED;
 	}
@@ -1564,7 +1565,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl)
 		goto out;
 
 	inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
-	if (IS_ERR_OR_NULL(inode)) {
+	if (IS_ERR(inode)) {
 		jbd_debug(1, "inode %d not found.", darg.ino);
 		inode = NULL;
 		ret = -EINVAL;
@@ -1577,7 +1578,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl)
 		 * dot and dot dot dirents are setup properly.
 		 */
 		dir = ext4_iget(sb, darg.parent_ino, EXT4_IGET_NORMAL);
-		if (IS_ERR_OR_NULL(dir)) {
+		if (IS_ERR(dir)) {
 			jbd_debug(1, "Dir %d not found.", darg.ino);
 			goto out;
 		}
@@ -1653,7 +1654,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
 
 	inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino),
 				EXT4_IGET_NORMAL);
-	if (IS_ERR_OR_NULL(inode)) {
+	if (IS_ERR(inode)) {
 		jbd_debug(1, "Inode not found.");
 		return 0;
 	}
@@ -1777,7 +1778,7 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl)
 		le32_to_cpu(lrange->fc_ino), cur, remaining);
 
 	inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL);
-	if (IS_ERR_OR_NULL(inode)) {
+	if (IS_ERR(inode)) {
 		jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino));
 		return 0;
 	}
@@ -1832,7 +1833,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
 	for (i = 0; i < state->fc_modified_inodes_used; i++) {
 		inode = ext4_iget(sb, state->fc_modified_inodes[i],
 			EXT4_IGET_NORMAL);
-		if (IS_ERR_OR_NULL(inode)) {
+		if (IS_ERR(inode)) {
 			jbd_debug(1, "Inode %d not found.",
 				state->fc_modified_inodes[i]);
 			continue;
@@ -1849,7 +1850,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
 
 			if (ret > 0) {
 				path = ext4_find_extent(inode, map.m_lblk, NULL, 0);
-				if (!IS_ERR_OR_NULL(path)) {
+				if (!IS_ERR(path)) {
 					for (j = 0; j < path->p_depth; j++)
 						ext4_mb_mark_bb(inode->i_sb,
 							path[j].p_block, 1, 1);
-- 
2.25.3




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

* Re: [PATCH] Use IS_ERR instead of IS_ERR_OR_NULL and set inode null when IS_ERR.
  2020-12-30  3:38 [PATCH] Use IS_ERR instead of IS_ERR_OR_NULL and set inode null when IS_ERR Yi Li
@ 2021-01-06 13:02 ` Jan Kara
  2021-01-14  3:32   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2021-01-06 13:02 UTC (permalink / raw)
  To: Yi Li; +Cc: tytso, yilikernel, adilger.kernel, linux-ext4, linux-kernel

On Wed 30-12-20 11:38:27, Yi Li wrote:
> 1: ext4_iget/ext4_find_extent never returns NULL, use IS_ERR
> instead of IS_ERR_OR_NULL to fix this.
> 
> 2: ext4_fc_replay_inode should set the inode to NULL when IS_ERR.
> and go to call iput properly.
> 
> Signed-off-by: Yi Li <yili@winhong.com>

Thanks for the patch! It looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/fast_commit.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 4fcc21c25e79..6b5489273c85 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -1318,14 +1318,14 @@ static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl)
>  	entry.len = darg.dname_len;
>  	inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
>  
> -	if (IS_ERR_OR_NULL(inode)) {
> +	if (IS_ERR(inode)) {
>  		jbd_debug(1, "Inode %d not found", darg.ino);
>  		return 0;
>  	}
>  
>  	old_parent = ext4_iget(sb, darg.parent_ino,
>  				EXT4_IGET_NORMAL);
> -	if (IS_ERR_OR_NULL(old_parent)) {
> +	if (IS_ERR(old_parent)) {
>  		jbd_debug(1, "Dir with inode  %d not found", darg.parent_ino);
>  		iput(inode);
>  		return 0;
> @@ -1410,7 +1410,7 @@ static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl)
>  			darg.parent_ino, darg.dname_len);
>  
>  	inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
> -	if (IS_ERR_OR_NULL(inode)) {
> +	if (IS_ERR(inode)) {
>  		jbd_debug(1, "Inode not found.");
>  		return 0;
>  	}
> @@ -1466,10 +1466,11 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
>  	trace_ext4_fc_replay(sb, tag, ino, 0, 0);
>  
>  	inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
> -	if (!IS_ERR_OR_NULL(inode)) {
> +	if (!IS_ERR(inode)) {
>  		ext4_ext_clear_bb(inode);
>  		iput(inode);
>  	}
> +	inode = NULL;
>  
>  	ext4_fc_record_modified_inode(sb, ino);
>  
> @@ -1512,7 +1513,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
>  
>  	/* Given that we just wrote the inode on disk, this SHOULD succeed. */
>  	inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
> -	if (IS_ERR_OR_NULL(inode)) {
> +	if (IS_ERR(inode)) {
>  		jbd_debug(1, "Inode not found.");
>  		return -EFSCORRUPTED;
>  	}
> @@ -1564,7 +1565,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl)
>  		goto out;
>  
>  	inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
> -	if (IS_ERR_OR_NULL(inode)) {
> +	if (IS_ERR(inode)) {
>  		jbd_debug(1, "inode %d not found.", darg.ino);
>  		inode = NULL;
>  		ret = -EINVAL;
> @@ -1577,7 +1578,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl)
>  		 * dot and dot dot dirents are setup properly.
>  		 */
>  		dir = ext4_iget(sb, darg.parent_ino, EXT4_IGET_NORMAL);
> -		if (IS_ERR_OR_NULL(dir)) {
> +		if (IS_ERR(dir)) {
>  			jbd_debug(1, "Dir %d not found.", darg.ino);
>  			goto out;
>  		}
> @@ -1653,7 +1654,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
>  
>  	inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino),
>  				EXT4_IGET_NORMAL);
> -	if (IS_ERR_OR_NULL(inode)) {
> +	if (IS_ERR(inode)) {
>  		jbd_debug(1, "Inode not found.");
>  		return 0;
>  	}
> @@ -1777,7 +1778,7 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl)
>  		le32_to_cpu(lrange->fc_ino), cur, remaining);
>  
>  	inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL);
> -	if (IS_ERR_OR_NULL(inode)) {
> +	if (IS_ERR(inode)) {
>  		jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino));
>  		return 0;
>  	}
> @@ -1832,7 +1833,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
>  	for (i = 0; i < state->fc_modified_inodes_used; i++) {
>  		inode = ext4_iget(sb, state->fc_modified_inodes[i],
>  			EXT4_IGET_NORMAL);
> -		if (IS_ERR_OR_NULL(inode)) {
> +		if (IS_ERR(inode)) {
>  			jbd_debug(1, "Inode %d not found.",
>  				state->fc_modified_inodes[i]);
>  			continue;
> @@ -1849,7 +1850,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
>  
>  			if (ret > 0) {
>  				path = ext4_find_extent(inode, map.m_lblk, NULL, 0);
> -				if (!IS_ERR_OR_NULL(path)) {
> +				if (!IS_ERR(path)) {
>  					for (j = 0; j < path->p_depth; j++)
>  						ext4_mb_mark_bb(inode->i_sb,
>  							path[j].p_block, 1, 1);
> -- 
> 2.25.3
> 
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] Use IS_ERR instead of IS_ERR_OR_NULL and set inode null when IS_ERR.
  2021-01-06 13:02 ` Jan Kara
@ 2021-01-14  3:32   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2021-01-14  3:32 UTC (permalink / raw)
  To: Jan Kara; +Cc: Yi Li, yilikernel, adilger.kernel, linux-ext4, linux-kernel

On Wed, Jan 06, 2021 at 02:02:11PM +0100, Jan Kara wrote:
> On Wed 30-12-20 11:38:27, Yi Li wrote:
> > 1: ext4_iget/ext4_find_extent never returns NULL, use IS_ERR
> > instead of IS_ERR_OR_NULL to fix this.
> > 
> > 2: ext4_fc_replay_inode should set the inode to NULL when IS_ERR.
> > and go to call iput properly.
> > 
> > Signed-off-by: Yi Li <yili@winhong.com>
> 
> Thanks for the patch! It looks good to me. You can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2021-01-14  3:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  3:38 [PATCH] Use IS_ERR instead of IS_ERR_OR_NULL and set inode null when IS_ERR Yi Li
2021-01-06 13:02 ` Jan Kara
2021-01-14  3:32   ` Theodore Ts'o

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