Skip to content

Commit 23dd561

Browse files
cybertantytso
authored andcommitted
ext4: use IS_ERR instead of IS_ERR_OR_NULL and set inode null when IS_ERR
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. Fixes: 8016e29 ("ext4: fast commit recovery path") Signed-off-by: Yi Li <yili@winhong.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20201230033827.3996064-1-yili@winhong.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent 5a3b590 commit 23dd561

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

fs/ext4/fast_commit.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,14 +1318,14 @@ static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl)
13181318
entry.len = darg.dname_len;
13191319
inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
13201320

1321-
if (IS_ERR_OR_NULL(inode)) {
1321+
if (IS_ERR(inode)) {
13221322
jbd_debug(1, "Inode %d not found", darg.ino);
13231323
return 0;
13241324
}
13251325

13261326
old_parent = ext4_iget(sb, darg.parent_ino,
13271327
EXT4_IGET_NORMAL);
1328-
if (IS_ERR_OR_NULL(old_parent)) {
1328+
if (IS_ERR(old_parent)) {
13291329
jbd_debug(1, "Dir with inode %d not found", darg.parent_ino);
13301330
iput(inode);
13311331
return 0;
@@ -1410,7 +1410,7 @@ static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl)
14101410
darg.parent_ino, darg.dname_len);
14111411

14121412
inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
1413-
if (IS_ERR_OR_NULL(inode)) {
1413+
if (IS_ERR(inode)) {
14141414
jbd_debug(1, "Inode not found.");
14151415
return 0;
14161416
}
@@ -1466,10 +1466,11 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
14661466
trace_ext4_fc_replay(sb, tag, ino, 0, 0);
14671467

14681468
inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
1469-
if (!IS_ERR_OR_NULL(inode)) {
1469+
if (!IS_ERR(inode)) {
14701470
ext4_ext_clear_bb(inode);
14711471
iput(inode);
14721472
}
1473+
inode = NULL;
14731474

14741475
ext4_fc_record_modified_inode(sb, ino);
14751476

@@ -1512,7 +1513,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
15121513

15131514
/* Given that we just wrote the inode on disk, this SHOULD succeed. */
15141515
inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
1515-
if (IS_ERR_OR_NULL(inode)) {
1516+
if (IS_ERR(inode)) {
15161517
jbd_debug(1, "Inode not found.");
15171518
return -EFSCORRUPTED;
15181519
}
@@ -1564,7 +1565,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl)
15641565
goto out;
15651566

15661567
inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
1567-
if (IS_ERR_OR_NULL(inode)) {
1568+
if (IS_ERR(inode)) {
15681569
jbd_debug(1, "inode %d not found.", darg.ino);
15691570
inode = NULL;
15701571
ret = -EINVAL;
@@ -1577,7 +1578,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl)
15771578
* dot and dot dot dirents are setup properly.
15781579
*/
15791580
dir = ext4_iget(sb, darg.parent_ino, EXT4_IGET_NORMAL);
1580-
if (IS_ERR_OR_NULL(dir)) {
1581+
if (IS_ERR(dir)) {
15811582
jbd_debug(1, "Dir %d not found.", darg.ino);
15821583
goto out;
15831584
}
@@ -1653,7 +1654,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
16531654

16541655
inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino),
16551656
EXT4_IGET_NORMAL);
1656-
if (IS_ERR_OR_NULL(inode)) {
1657+
if (IS_ERR(inode)) {
16571658
jbd_debug(1, "Inode not found.");
16581659
return 0;
16591660
}
@@ -1777,7 +1778,7 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl)
17771778
le32_to_cpu(lrange->fc_ino), cur, remaining);
17781779

17791780
inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL);
1780-
if (IS_ERR_OR_NULL(inode)) {
1781+
if (IS_ERR(inode)) {
17811782
jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino));
17821783
return 0;
17831784
}
@@ -1832,7 +1833,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
18321833
for (i = 0; i < state->fc_modified_inodes_used; i++) {
18331834
inode = ext4_iget(sb, state->fc_modified_inodes[i],
18341835
EXT4_IGET_NORMAL);
1835-
if (IS_ERR_OR_NULL(inode)) {
1836+
if (IS_ERR(inode)) {
18361837
jbd_debug(1, "Inode %d not found.",
18371838
state->fc_modified_inodes[i]);
18381839
continue;
@@ -1849,7 +1850,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
18491850

18501851
if (ret > 0) {
18511852
path = ext4_find_extent(inode, map.m_lblk, NULL, 0);
1852-
if (!IS_ERR_OR_NULL(path)) {
1853+
if (!IS_ERR(path)) {
18531854
for (j = 0; j < path->p_depth; j++)
18541855
ext4_mb_mark_bb(inode->i_sb,
18551856
path[j].p_block, 1, 1);

0 commit comments

Comments
 (0)