Re: [PATCH 6/6] ext4: calculate rec_len of ".." with correct name length 2

From: Kemeng Shi
Date: Tue Dec 24 2024 - 07:16:18 EST




on 12/21/2024 4:38 AM, Andreas Dilger wrote:
> On Dec 20, 2024, at 6:52 AM, Markus Elfring <Markus.Elfring@xxxxxx> wrote:
>>
>>> The rec_len of directory ".." should be ext4_dir_rec_len(2, NULL) instead
>>> of ext4_dir_rec_len(1, NULL). Although ext4_dir_rec_len return the same
>>> number either with name_len 1 or name_len 2, it's better use the right
>>> name_len to make code more intuitive.
>>
>> Do you try to point a correctness issue out here?
>>
>> How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.13-rc3#n145
>
> The patch is a no-op in terms of functionality. Dirent lengths are rounded up to a multiple of 4 bytes, so "1" and "2" give the same value.
>
> I was looking back at the changes to this code, and it has existed
> since at least when ext4 was cloned from ext3. In older versions
> of the code this calculation was done *before* the
>
> I also realized that the original code with "1" is actually correct.
> This code is calculating the dirent length of the ".." entry, but
> this is actually "the rest of the block minus the the '.' dirent size",
> so passing "1" is correct in this case.
>
> So this patch should not be applied.
Ahh, right... Thanks for point this out. Will drop this in next version.

Thanks,
Kemeng
>
>
> Cheers, Andreas
>
>
>
>
>