summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2026-01-06 17:20:31 +0100
committerDavid Sterba <dsterba@suse.com>2026-04-07 18:56:08 +0200
commitefcf0898a6d01724fc8ea15e55fc39bfb1ecf347 (patch)
treea98916b2cee56c9dc2f12ed1c8b2297d7eca2b21
parent4d083672b49294c31a683fd0e50d468e555768ca (diff)
downloadlinux-efcf0898a6d01724fc8ea15e55fc39bfb1ecf347.tar.gz
linux-efcf0898a6d01724fc8ea15e55fc39bfb1ecf347.zip
btrfs: zlib: 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. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/zlib.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 0640ab4da2b1..9ebc90267e26 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -71,7 +71,6 @@ static bool need_special_buffer(struct btrfs_fs_info *fs_info)
struct list_head *zlib_alloc_workspace(struct btrfs_fs_info *fs_info, unsigned int level)
{
- const u32 blocksize = fs_info->sectorsize;
struct workspace *workspace;
int workspacesize;
@@ -91,8 +90,8 @@ struct list_head *zlib_alloc_workspace(struct btrfs_fs_info *fs_info, unsigned i
workspace->buf_size = ZLIB_DFLTCC_BUF_SIZE;
}
if (!workspace->buf) {
- workspace->buf = kmalloc(blocksize, GFP_KERNEL);
- workspace->buf_size = blocksize;
+ workspace->buf = kmalloc(fs_info->sectorsize, GFP_KERNEL);
+ workspace->buf_size = fs_info->sectorsize;
}
if (!workspace->strm.workspace || !workspace->buf)
goto fail;
@@ -159,7 +158,6 @@ int zlib_compress_bio(struct list_head *ws, struct compressed_bio *cb)
char *data_in = NULL;
struct folio *in_folio = NULL;
struct folio *out_folio = NULL;
- const u32 blocksize = fs_info->sectorsize;
const u64 orig_end = start + len;
ret = zlib_deflateInit(&workspace->strm, workspace->level);
@@ -240,7 +238,7 @@ int zlib_compress_bio(struct list_head *ws, struct compressed_bio *cb)
}
/* We're making it bigger, give up. */
- if (workspace->strm.total_in > blocksize * 2 &&
+ if (workspace->strm.total_in > fs_info->sectorsize * 2 &&
workspace->strm.total_in < workspace->strm.total_out) {
ret = -E2BIG;
goto out;