Re: [PATCH 2/4] ocfs2: remove empty extent list check in ocfs2_dx_dir_lookup_rec()
Heming Zhao <[email protected]>
| Newsgroups | dev.linux.lists.ocfs2-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <4x7tuyncmpm36ebkp7hccw47fxwhdqgtxwu2lulvcy7cjyt25r@knp63pjqsg6n> |
On Fri, Apr 03, 2026 at 05:08:01PM +0800, Joseph Qi wrote: > The full extent list check is introduced by commit 44acc46d182f, 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. > > Signed-off-by: Joseph Qi <[email protected]> LGTM Reviewed-by: Heming Zhao <[email protected]> > --- > fs/ocfs2/dir.c | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c > index 82e720c8ba32..d94595a49923 100644 > --- a/fs/ocfs2/dir.c > +++ b/fs/ocfs2/dir.c > @@ -835,14 +835,6 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode, > } > } > > - if (le16_to_cpu(el->l_next_free_rec) == 0) { > - ret = ocfs2_error(inode->i_sb, > - "Inode %lu has empty extent list at depth %u\n", > - inode->i_ino, > - le16_to_cpu(el->l_tree_depth)); > - goto out; > - } > - > found = 0; > for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) { > rec = &el->l_recs[i]; > @@ -855,10 +847,9 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode, > > if (!found) { > ret = ocfs2_error(inode->i_sb, > - "Inode %lu has bad extent record (%u, %u, 0) in btree\n", > - inode->i_ino, > - le32_to_cpu(rec->e_cpos), > - ocfs2_rec_clusters(el, rec)); > + "Inode %lu has no extent record for hash %u in btree (next_free_rec %u)\n", > + inode->i_ino, major_hash, > + le16_to_cpu(el->l_next_free_rec)); > goto out; > } > > -- > 2.39.3 >