Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: zstd: don't cache sectorsize in a local variable

The sectorsize is used once or at most twice in the callbacks, no need
to cache it on stack. Minor effect on zstd_compress_folios() where it
saves 8 bytes of stack.

Signed-off-by: David Sterba <dsterba@suse.com>

+4 -8
+4 -8
fs/btrfs/zstd.c
··· 370 370 371 371 struct list_head *zstd_alloc_workspace(struct btrfs_fs_info *fs_info, int level) 372 372 { 373 - const u32 blocksize = fs_info->sectorsize; 374 373 struct workspace *workspace; 375 374 376 375 workspace = kzalloc_obj(*workspace); ··· 382 383 workspace->req_level = level; 383 384 workspace->last_used = jiffies; 384 385 workspace->mem = kvmalloc(workspace->size, GFP_KERNEL | __GFP_NOWARN); 385 - workspace->buf = kmalloc(blocksize, GFP_KERNEL); 386 + workspace->buf = kmalloc(fs_info->sectorsize, GFP_KERNEL); 386 387 if (!workspace->mem || !workspace->buf) 387 388 goto fail; 388 389 ··· 413 414 const u64 start = cb->start; 414 415 const u32 len = cb->len; 415 416 const u64 end = start + len; 416 - const u32 blocksize = fs_info->sectorsize; 417 417 const u32 min_folio_size = btrfs_min_folio_size(fs_info); 418 418 419 419 workspace->params = zstd_get_btrfs_parameters(workspace->req_level, len); ··· 461 463 } 462 464 463 465 /* Check to see if we are making it bigger. */ 464 - if (tot_in + workspace->in_buf.pos > blocksize * 2 && 466 + if (tot_in + workspace->in_buf.pos > fs_info->sectorsize * 2 && 465 467 tot_in + workspace->in_buf.pos < tot_out + workspace->out_buf.pos) { 466 468 ret = -E2BIG; 467 469 goto out; ··· 588 590 size_t srclen = bio_get_size(&cb->bbio.bio); 589 591 zstd_dstream *stream; 590 592 int ret = 0; 591 - const u32 blocksize = fs_info->sectorsize; 592 593 const unsigned int min_folio_size = btrfs_min_folio_size(fs_info); 593 594 unsigned long folio_in_index = 0; 594 595 unsigned long total_folios_in = DIV_ROUND_UP(srclen, min_folio_size); ··· 617 620 618 621 workspace->out_buf.dst = workspace->buf; 619 622 workspace->out_buf.pos = 0; 620 - workspace->out_buf.size = blocksize; 623 + workspace->out_buf.size = fs_info->sectorsize; 621 624 622 625 while (1) { 623 626 size_t ret2; ··· 679 682 { 680 683 struct workspace *workspace = list_entry(ws, struct workspace, list); 681 684 struct btrfs_fs_info *fs_info = btrfs_sb(folio_inode(dest_folio)->i_sb); 682 - const u32 sectorsize = fs_info->sectorsize; 683 685 zstd_dstream *stream; 684 686 int ret = 0; 685 687 unsigned long to_copy = 0; ··· 702 706 703 707 workspace->out_buf.dst = workspace->buf; 704 708 workspace->out_buf.pos = 0; 705 - workspace->out_buf.size = sectorsize; 709 + workspace->out_buf.size = fs_info->sectorsize; 706 710 707 711 /* 708 712 * Since both input and output buffers should not exceed one sector,