1 |
From 23dd561ad9eae02b4d51bb502fe4e1a0666e9567 Mon Sep 17 00:00:00 2001 |
2 |
From: Yi Li <yili@winhong.com> |
3 |
Date: Wed, 30 Dec 2020 11:38:27 +0800 |
4 |
Subject: [PATCH] ext4: use IS_ERR instead of IS_ERR_OR_NULL and set inode null |
5 |
when IS_ERR |
6 |
|
7 |
1: ext4_iget/ext4_find_extent never returns NULL, use IS_ERR |
8 |
instead of IS_ERR_OR_NULL to fix this. |
9 |
|
10 |
2: ext4_fc_replay_inode should set the inode to NULL when IS_ERR. |
11 |
and go to call iput properly. |
12 |
|
13 |
Fixes: 8016e29f4362 ("ext4: fast commit recovery path") |
14 |
Signed-off-by: Yi Li <yili@winhong.com> |
15 |
Reviewed-by: Jan Kara <jack@suse.cz> |
16 |
Link: https://lore.kernel.org/r/20201230033827.3996064-1-yili@winhong.com |
17 |
Signed-off-by: Theodore Ts'o <tytso@mit.edu> |
18 |
Cc: stable@kernel.org |
19 |
--- |
20 |
fs/ext4/fast_commit.c | 23 ++++++++++++----------- |
21 |
1 file changed, 12 insertions(+), 11 deletions(-) |
22 |
|
23 |
diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c |
24 |
index 4fcc21c25e79..6b5489273c85 100644 |
25 |
--- a/fs/ext4/fast_commit.c |
26 |
+++ b/fs/ext4/fast_commit.c |
27 |
@@ -1318,14 +1318,14 @@ static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl) |
28 |
entry.len = darg.dname_len; |
29 |
inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL); |
30 |
|
31 |
- if (IS_ERR_OR_NULL(inode)) { |
32 |
+ if (IS_ERR(inode)) { |
33 |
jbd_debug(1, "Inode %d not found", darg.ino); |
34 |
return 0; |
35 |
} |
36 |
|
37 |
old_parent = ext4_iget(sb, darg.parent_ino, |
38 |
EXT4_IGET_NORMAL); |
39 |
- if (IS_ERR_OR_NULL(old_parent)) { |
40 |
+ if (IS_ERR(old_parent)) { |
41 |
jbd_debug(1, "Dir with inode %d not found", darg.parent_ino); |
42 |
iput(inode); |
43 |
return 0; |
44 |
@@ -1410,7 +1410,7 @@ static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl) |
45 |
darg.parent_ino, darg.dname_len); |
46 |
|
47 |
inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL); |
48 |
- if (IS_ERR_OR_NULL(inode)) { |
49 |
+ if (IS_ERR(inode)) { |
50 |
jbd_debug(1, "Inode not found."); |
51 |
return 0; |
52 |
} |
53 |
@@ -1466,10 +1466,11 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) |
54 |
trace_ext4_fc_replay(sb, tag, ino, 0, 0); |
55 |
|
56 |
inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL); |
57 |
- if (!IS_ERR_OR_NULL(inode)) { |
58 |
+ if (!IS_ERR(inode)) { |
59 |
ext4_ext_clear_bb(inode); |
60 |
iput(inode); |
61 |
} |
62 |
+ inode = NULL; |
63 |
|
64 |
ext4_fc_record_modified_inode(sb, ino); |
65 |
|
66 |
@@ -1512,7 +1513,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) |
67 |
|
68 |
/* Given that we just wrote the inode on disk, this SHOULD succeed. */ |
69 |
inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL); |
70 |
- if (IS_ERR_OR_NULL(inode)) { |
71 |
+ if (IS_ERR(inode)) { |
72 |
jbd_debug(1, "Inode not found."); |
73 |
return -EFSCORRUPTED; |
74 |
} |
75 |
@@ -1564,7 +1565,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl) |
76 |
goto out; |
77 |
|
78 |
inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL); |
79 |
- if (IS_ERR_OR_NULL(inode)) { |
80 |
+ if (IS_ERR(inode)) { |
81 |
jbd_debug(1, "inode %d not found.", darg.ino); |
82 |
inode = NULL; |
83 |
ret = -EINVAL; |
84 |
@@ -1577,7 +1578,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl) |
85 |
* dot and dot dot dirents are setup properly. |
86 |
*/ |
87 |
dir = ext4_iget(sb, darg.parent_ino, EXT4_IGET_NORMAL); |
88 |
- if (IS_ERR_OR_NULL(dir)) { |
89 |
+ if (IS_ERR(dir)) { |
90 |
jbd_debug(1, "Dir %d not found.", darg.ino); |
91 |
goto out; |
92 |
} |
93 |
@@ -1653,7 +1654,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb, |
94 |
|
95 |
inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino), |
96 |
EXT4_IGET_NORMAL); |
97 |
- if (IS_ERR_OR_NULL(inode)) { |
98 |
+ if (IS_ERR(inode)) { |
99 |
jbd_debug(1, "Inode not found."); |
100 |
return 0; |
101 |
} |
102 |
@@ -1777,7 +1778,7 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl) |
103 |
le32_to_cpu(lrange->fc_ino), cur, remaining); |
104 |
|
105 |
inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL); |
106 |
- if (IS_ERR_OR_NULL(inode)) { |
107 |
+ if (IS_ERR(inode)) { |
108 |
jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino)); |
109 |
return 0; |
110 |
} |
111 |
@@ -1832,7 +1833,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb) |
112 |
for (i = 0; i < state->fc_modified_inodes_used; i++) { |
113 |
inode = ext4_iget(sb, state->fc_modified_inodes[i], |
114 |
EXT4_IGET_NORMAL); |
115 |
- if (IS_ERR_OR_NULL(inode)) { |
116 |
+ if (IS_ERR(inode)) { |
117 |
jbd_debug(1, "Inode %d not found.", |
118 |
state->fc_modified_inodes[i]); |
119 |
continue; |
120 |
@@ -1849,7 +1850,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb) |
121 |
|
122 |
if (ret > 0) { |
123 |
path = ext4_find_extent(inode, map.m_lblk, NULL, 0); |
124 |
- if (!IS_ERR_OR_NULL(path)) { |
125 |
+ if (!IS_ERR(path)) { |
126 |
for (j = 0; j < path->p_depth; j++) |
127 |
ext4_mb_mark_bb(inode->i_sb, |
128 |
path[j].p_block, 1, 1); |
129 |
-- |
130 |
2.30.0 |
131 |
|