Skip to content

Commit efcf089

Browse files
committed
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>
1 parent 4d08367 commit efcf089

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

fs/btrfs/zlib.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static bool need_special_buffer(struct btrfs_fs_info *fs_info)
7171

7272
struct list_head *zlib_alloc_workspace(struct btrfs_fs_info *fs_info, unsigned int level)
7373
{
74-
const u32 blocksize = fs_info->sectorsize;
7574
struct workspace *workspace;
7675
int workspacesize;
7776

@@ -91,8 +90,8 @@ struct list_head *zlib_alloc_workspace(struct btrfs_fs_info *fs_info, unsigned i
9190
workspace->buf_size = ZLIB_DFLTCC_BUF_SIZE;
9291
}
9392
if (!workspace->buf) {
94-
workspace->buf = kmalloc(blocksize, GFP_KERNEL);
95-
workspace->buf_size = blocksize;
93+
workspace->buf = kmalloc(fs_info->sectorsize, GFP_KERNEL);
94+
workspace->buf_size = fs_info->sectorsize;
9695
}
9796
if (!workspace->strm.workspace || !workspace->buf)
9897
goto fail;
@@ -159,7 +158,6 @@ int zlib_compress_bio(struct list_head *ws, struct compressed_bio *cb)
159158
char *data_in = NULL;
160159
struct folio *in_folio = NULL;
161160
struct folio *out_folio = NULL;
162-
const u32 blocksize = fs_info->sectorsize;
163161
const u64 orig_end = start + len;
164162

165163
ret = zlib_deflateInit(&workspace->strm, workspace->level);
@@ -240,7 +238,7 @@ int zlib_compress_bio(struct list_head *ws, struct compressed_bio *cb)
240238
}
241239

242240
/* We're making it bigger, give up. */
243-
if (workspace->strm.total_in > blocksize * 2 &&
241+
if (workspace->strm.total_in > fs_info->sectorsize * 2 &&
244242
workspace->strm.total_in < workspace->strm.total_out) {
245243
ret = -E2BIG;
246244
goto out;

0 commit comments

Comments
 (0)