variables fixes in compression.c
cover variables fixes in compression.c
Patch (btrfs: reduce compressed_bio member's types) reduced the size to unsigned int as in [1]. Fix its cascading effects here. And one stale comment in the patch 4/4.
[1]
- unsigned long len;
+ unsigned int len;
- int compress_type;
+ u8 compress_type;
- unsigned long nr_pages;
+ unsigned int nr_pages;
- unsigned long compressed_len;
+ unsigned int compressed_len;
- int errors;
+ u8 errors;
As shown in [2], we set the max compressable block size to 128K. So struct async_extent can reduce some of its members to unsigned int as well.
[2]
static noinline int compress_file_range(struct async_chunk *async_chunk) ::
617 total_compressed = min_t(unsigned long, total_compressed,
618 BTRFS_MAX_UNCOMPRESSED);
But changes touches too many places, and my first attempt to fix is unsatisfactory to me, so I am just sending the changes limited to the file compression.c.
Anand Jain (4):
btrfs: optimize users of members of the struct compressed_bio
btrfs: optimize variables size in btrfs_submit_compressed_read
btrfs: optimize variables size in btrfs_submit_compressed_write
btrfs: fix comment about max_out in btrfs_compress_pages
fs/btrfs/compression.c | 21 +++++++++------------ fs/btrfs/compression.h | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/4 btrfs: reduce the variable size to fit nr_pages
Patch (btrfs: reduce compressed_bio member's types) reduced the @nr_pages size to unsigned int, its cascading effects are fixed here.
--- fs/btrfs/compression.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/compression.c +3 -3
@@ -149,7 +149,7 @@ static int check_compressed_csum(struct btrfs_inode *inode, struct bio *bio,const u32 csum_size = fs_info->csum_size;const u32 sectorsize = fs_info->sectorsize;struct page *page; -unsigned long i; +unsigned int i;char *kaddr;u8 csum[BTRFS_CSUM_SIZE ];struct compressed_bio *cb = bio->bi_private;
@@ -208,7 +208,7 @@ static void end_compressed_bio_read(struct bio *bio)struct compressed_bio *cb = bio->bi_private;struct inode *inode;struct page *page; -unsigned long index; +unsigned int index;unsigned int mirror =btrfs_io_bio (bio)->mirror_num;int ret =0 ;
@@ -334,7 +334,7 @@ static void end_compressed_bio_write(struct bio *bio)struct compressed_bio *cb = bio->bi_private;struct inode *inode;struct page *page; -unsigned long index; +unsigned int index;if (bio->bi_status) cb->errors =1 ;
Signature · 1 line
2.30.2
PATCH 2/4 btrfs: optimize variables size in btrfs_submit_compressed_read
In reply to Anand JainPatch (btrfs: reduce compressed_bio member's types) reduced some member's size. Declare the variables @compressed_len, @nr_pages and @pg_index size as an unsigned int in the function btrfs_submit_compressed_read.
--- fs/btrfs/compression.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/compression.c +3 -3
@@ -667,9 +667,9 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct extent_map_tree *em_tree;struct compressed_bio *cb; -unsigned long compressed_len; -unsigned long nr_pages; -unsigned long pg_index; +unsigned int compressed_len; +unsigned int nr_pages; +unsigned int pg_index;struct page *page;struct bio *comp_bio;u64 cur_disk_byte = bio->bi_iter.bi_sector <<9 ;
Signature · 1 line
2.30.2
PATCH 3/4 btrfs: optimize variables size in btrfs_submit_compressed_write
In reply to Anand JainPatch (btrfs: reduce compressed_bio member's types) reduced some member's size. Function arguments @len, @compressed_len and @nr_pages can be declared as unsigned int.
--- fs/btrfs/compression.c | 6 +++--- fs/btrfs/compression.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/btrfs/compression.c +3 -3
@@ -385,10 +385,10 @@ static void end_compressed_bio_write(struct bio *bio)* the end io hooks. */ blk_status_t btrfs_submit_compressed_write (struct btrfs_inode *inode,u64 start, -unsigned long len,u64 disk_start, -unsigned long compressed_len, +unsigned int len,u64 disk_start, +unsigned int compressed_len,struct page **compressed_pages, -unsigned long nr_pages, +unsigned int nr_pages,unsigned int write_flags,struct cgroup_subsys_state *blkcg_css) {
fs/btrfs/compression.h +3 -3
@@ -91,10 +91,10 @@ int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start, struct bio *bio);blk_status_t btrfs_submit_compressed_write (struct btrfs_inode *inode,u64 start, -unsigned long len,u64 disk_start, -unsigned long compressed_len, +unsigned int len,u64 disk_start, +unsigned int compressed_len,struct page **compressed_pages, -unsigned long nr_pages, +unsigned int nr_pages,unsigned int write_flags,struct cgroup_subsys_state *blkcg_css); blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
Signature · 1 line
2.30.2
PATCH 4/4 btrfs: fix comment about max_out in btrfs_compress_pages
In reply to Anand JainCommit e5d74902362f (btrfs: derive maximum output size in the compression implementation) removed @max_out argument in btrfs_compress_pages() but its comment remained, remove it.
--- fs/btrfs/compression.c | 3 --- 1 file changed, 3 deletions(-)
fs/btrfs/compression.c +0 -3
@@ -1192,9 +1192,6 @@ static unsigned int btrfs_compress_set_level(int type, unsigned level)* * @total_out is an in/out parameter, must be set to the input length and will * be also used to return the total number of compressed bytes -* -* @max_out tells us the max number of bytes that we're allowed to -* stuff into pages */ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping, u64 start, struct page **pages,
Signature · 1 line
2.30.2
Quoted 30 lines · Anand Jain
Patch (btrfs: reduce
compressed_biomember's types) reduced the size to unsigned int as in [1]. Fix its cascading effects here. And one stale comment in the patch 4/4.[1]
(quoted diff) +5
-5- unsigned long len; + unsigned int len; - int compress_type; + u8 compress_type; - unsigned long nr_pages; + unsigned int nr_pages; - unsigned long compressed_len; + unsigned int compressed_len; - int errors; + u8 errors;As shown in [2], we set the max compressable block size to 128K. So struct
async_extentcan reduce some of its members to unsigned int as well.[2]
static noinline intcompress_file_range(struct async_chunk *async_chunk)::
617total_compressed= min_t(unsigned long,total_compressed,
618BTRFS_MAX_UNCOMPRESSED);
Quoted 3 lines
But changes touches too many places, and my first attempt to fix is unsatisfactory to me, so I am just sending the changes limited to the file
compression.c.
That's fin. As long as a patch does one change (possibly cascading to more places) it should be doable step by step.
Quoted 5 lines
Anand Jain (4):
btrfs: optimize users of members of the structcompressed_bio
btrfs: optimize variables size inbtrfs_submit_compressed_read
btrfs: optimize variables size inbtrfs_submit_compressed_write
btrfs: fix comment aboutmax_outinbtrfs_compress_pages
Added to misc-next, thanks.