* [PATCH 1/4] btrfs: reduce the variable size to fit nr_pages
2021-05-29 9:48 [PATCH 0/4] variables fixes in compression.c Anand Jain
@ 2021-05-29 9:48 ` Anand Jain
2021-05-29 9:48 ` [PATCH 2/4] btrfs: optimize variables size in btrfs_submit_compressed_read Anand Jain
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2021-05-29 9:48 UTC (permalink / raw)
To: linux-btrfs; +Cc: Anand Jain
Patch (btrfs: reduce compressed_bio member's types) reduced the
@nr_pages size to unsigned int, its cascading effects are fixed here.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/compression.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7bd7cae51dbf..e10041af8476 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] btrfs: optimize variables size in btrfs_submit_compressed_read
2021-05-29 9:48 [PATCH 0/4] variables fixes in compression.c Anand Jain
2021-05-29 9:48 ` [PATCH 1/4] btrfs: reduce the variable size to fit nr_pages Anand Jain
@ 2021-05-29 9:48 ` Anand Jain
2021-05-29 9:48 ` [PATCH 3/4] btrfs: optimize variables size in btrfs_submit_compressed_write Anand Jain
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2021-05-29 9:48 UTC (permalink / raw)
To: linux-btrfs; +Cc: Anand Jain
Patch (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.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/compression.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index e10041af8476..c1432a58f378 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] btrfs: optimize variables size in btrfs_submit_compressed_write
2021-05-29 9:48 [PATCH 0/4] variables fixes in compression.c Anand Jain
2021-05-29 9:48 ` [PATCH 1/4] btrfs: reduce the variable size to fit nr_pages Anand Jain
2021-05-29 9:48 ` [PATCH 2/4] btrfs: optimize variables size in btrfs_submit_compressed_read Anand Jain
@ 2021-05-29 9:48 ` Anand Jain
2021-05-29 9:48 ` [PATCH 4/4] btrfs: fix comment about max_out in btrfs_compress_pages Anand Jain
2021-05-31 18:37 ` [PATCH 0/4] variables fixes in compression.c David Sterba
4 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2021-05-29 9:48 UTC (permalink / raw)
To: linux-btrfs; +Cc: Anand Jain
Patch (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.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/compression.c | 6 +++---
fs/btrfs/compression.h | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index c1432a58f378..c523f384bd1a 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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)
{
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 00d8439048c9..c359f20920d0 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -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,
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] btrfs: fix comment about max_out in btrfs_compress_pages
2021-05-29 9:48 [PATCH 0/4] variables fixes in compression.c Anand Jain
` (2 preceding siblings ...)
2021-05-29 9:48 ` [PATCH 3/4] btrfs: optimize variables size in btrfs_submit_compressed_write Anand Jain
@ 2021-05-29 9:48 ` Anand Jain
2021-05-31 18:37 ` [PATCH 0/4] variables fixes in compression.c David Sterba
4 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2021-05-29 9:48 UTC (permalink / raw)
To: linux-btrfs; +Cc: Anand Jain
Commit e5d74902362f (btrfs: derive maximum output size in the compression
implementation) removed @max_out argument in btrfs_compress_pages() but
its comment remained, remove it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/compression.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index c523f384bd1a..35ca49893803 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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,
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/4] variables fixes in compression.c
2021-05-29 9:48 [PATCH 0/4] variables fixes in compression.c Anand Jain
` (3 preceding siblings ...)
2021-05-29 9:48 ` [PATCH 4/4] btrfs: fix comment about max_out in btrfs_compress_pages Anand Jain
@ 2021-05-31 18:37 ` David Sterba
4 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2021-05-31 18:37 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Sat, May 29, 2021 at 05:48:32PM +0800, Anand Jain wrote:
> 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.
That's fin. As long as a patch does one change (possibly cascading to
more places) it should be doable step by step.
> 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
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread