On 2020/11/19 上午12:29, David Sterba wrote: > On Fri, Nov 13, 2020 at 08:51:47PM +0800, Qu Wenruo wrote: >> @@ -1781,8 +1781,9 @@ static int scrub_checksum_data(struct scrub_block *sblock) >> struct scrub_ctx *sctx = sblock->sctx; >> struct btrfs_fs_info *fs_info = sctx->fs_info; >> SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); >> - u8 csum[BTRFS_CSUM_SIZE]; >> struct scrub_page *spage; >> + u32 sectorsize = fs_info->sectorsize; >> + u8 csum[BTRFS_CSUM_SIZE]; >> char *kaddr; >> >> BUG_ON(sblock->page_count < 1); >> @@ -1794,11 +1795,15 @@ static int scrub_checksum_data(struct scrub_block *sblock) >> >> shash->tfm = fs_info->csum_shash; >> crypto_shash_init(shash); >> - crypto_shash_digest(shash, kaddr, PAGE_SIZE, csum); >> + >> + /* >> + * In scrub_pages() and scrub_pages_for_parity() we ensure >> + * each spage only contains just one sector of data. >> + */ >> + crypto_shash_digest(shash, kaddr, sectorsize, csum); > > Temporary variable is not needed for single use (sectorsize). > Personally speaking, whether such temporary variable is needed should be determined at compile time. For reader, I didn't see anything wrong using such variable, especially it can save some "fs_info->" typing and saves some new line. Thanks, Qu