Re: [PATCH] btrfs: replace a wrong memset() with memzero_page()

Qu Wenruo
2022-03-26T01:15:38Z

On 2022/3/26 00:38, Christoph Hellwig wrote:
> On Fri, Mar 25, 2022 at 05:37:59PM +0800, Qu Wenruo wrote:
>> - u32 len = fs_info->sectorsize;
>> + const u32 len = fs_info->sectorsize;
>
> Why the spurious and rather pointless const annotation that is unrelated
> to the rest of the patch?

Because we prefer const for constant variables in btrfs code.

As we have experienced some bugs in the past related to reusing some
variables.

>
>> BTRFS_DEV_STAT_CORRUPTION_ERRS);
>> - memset(kaddr + pgoff, 1, len);
>> + memzero_page(page, pgoff, len);
>> flush_dcache_page(page);
>
> memzero_page already takes care of the flush_dcache_page.
>

Oh, indeed.

Thanks,
Qu