[lvc-project] [PATCH] ocfs2: add extent record check in ocfs2_commit_truncate()
Glass Su
glass.su at suse.com
Mon Dec 30 05:05:14 MSK 2024
> On Dec 29, 2024, at 18:49, Matthew Wilcox <willy at infradead.org> wrote:
>
> 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?
Indeed. -EIO is an old school errno. -EFSCORRUPTED is more accurate.
—
Su
More information about the lvc-project
mailing list