Skip to content

Commit 4ae9cca

Browse files
josephhzakpm00
authored andcommitted
ocfs2: remove empty extent list check in ocfs2_dx_dir_lookup_rec()
The full extent list check is introduced by commit 44acc46, which is to avoid NULL pointer dereference if a dirent is not found. Reworking the error message to not reference rec. Instead, report major_hash being looked up and l_next_free_rec, which naturally covers both failure cases (empty extent list and no matching record) without needing a separate l_next_free_rec == 0 guard. Link: https://lkml.kernel.org/r/20260403090803.3860971-3-joseph.qi@linux.alibaba.com Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com> Reviewed-by: Heming Zhao <heming.zhao@suse.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Joel Becker <jlbec@evilplan.org> Cc: Jun Piao <piaojun@huawei.com> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Mark Fasheh <mark@fasheh.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 775c173 commit 4ae9cca

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

fs/ocfs2/dir.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -835,14 +835,6 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
835835
}
836836
}
837837

838-
if (le16_to_cpu(el->l_next_free_rec) == 0) {
839-
ret = ocfs2_error(inode->i_sb,
840-
"Inode %lu has empty extent list at depth %u\n",
841-
inode->i_ino,
842-
le16_to_cpu(el->l_tree_depth));
843-
goto out;
844-
}
845-
846838
found = 0;
847839
for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
848840
rec = &el->l_recs[i];
@@ -855,10 +847,9 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
855847

856848
if (!found) {
857849
ret = ocfs2_error(inode->i_sb,
858-
"Inode %lu has bad extent record (%u, %u, 0) in btree\n",
859-
inode->i_ino,
860-
le32_to_cpu(rec->e_cpos),
861-
ocfs2_rec_clusters(el, rec));
850+
"Inode %lu has no extent record for hash %u in btree (next_free_rec %u)\n",
851+
inode->i_ino, major_hash,
852+
le16_to_cpu(el->l_next_free_rec));
862853
goto out;
863854
}
864855

0 commit comments

Comments
 (0)