[lvc-project] [PATCH] ocfs2: add extent record check in ocfs2_commit_truncate()
Matthew Wilcox
willy at infradead.org
Sun Dec 29 13:49:45 MSK 2024
On Sun, Dec 29, 2024 at 10:05:17AM +0800, Glass Su wrote:
> > +++ b/fs/ocfs2/alloc.c
> > @@ -7219,12 +7219,20 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
> > struct ocfs2_extent_rec *rec;
> > struct ocfs2_path *path = NULL;
> > struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
> > + u16 tree_depth = le16_to_cpu(di->id2.i_list.l_tree_depth);
>
> No need of tree_depth. Just call
> If (unlikely(le16_to_cpu(di->id2.i_list.l_tree_depth) >= OCFS2_MAX_PATH_DEPTH)) {
That seems more complicated to me. I find the original easier to read.
> > + if (unlikely(tree_depth >= OCFS2_MAX_PATH_DEPTH)) {
> > + ocfs2_error(inode->i_sb,
> > + "dinode %llu has invalid extent record depth %u\n",
> > + (u64)di_bh->b_blocknr, tree_depth);
> > + return -EINVAL;
>
> -EIO is better.
-EFSCORRUPTED is surely the right errno here?
More information about the lvc-project
mailing list