Btrfs: compression fixes
v3 cover Btrfs: compression fixes
First patch: fix copy paste typo in debug message in lzo.c, lzo is not deflate
Second patch: force btrfs to not store data as compressed, if compression will not
free at least one PAGE_SIZE, because it's useless in term of storage and reading data from disk, as a result productivity suffers
Changes since v1:
- Merge patches for zlib and lzo in one
- Sync check logic for zlib and lzo
- Check profit after all data are compressed (not while compressing)
Changes since v2:
- Fix comparassion logic, it's enough if:
compressed size + PAGE_SIZE not bigger then input data size
Timofey Titovets (2):
Btrfs: lzo.c pr_debug() deflate->lzo
Btrfs: compression must free at least PAGE_SIZE
fs/btrfs/lzo.c | 7 +++++-- fs/btrfs/zlib.c | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-)
--
2.13.0
PATCH v3 1/2 Btrfs: lzo.c pr_debug() deflate->lzo
--- fs/btrfs/lzo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/lzo.c +1 -1
@@ -141,7 +141,7 @@ static int lzo_compress_pages(struct list_head *ws, ret =lzo1x_1_compress (data_in, in_len, workspace->cbuf, &out_len, workspace->mem);if (ret !=LZO_E_OK ) { -pr_debug ("BTRFS: deflate in loop returned %d\n" , +pr_debug ("BTRFS: lzo in loop returned %d\n" , ret); ret = -EIO ; goto out;
--
2.13.0
PATCH v3 2/2 Btrfs: compression must free at least PAGE_SIZE
In reply to Timofey TitovetsBtrfs already skip store of data where compression didn't free at least one byte. So make logic better and make check that compression free at least one PAGE_SIZE, because in another case it useless to store this data compressed
--- fs/btrfs/lzo.c | 5 ++++- fs/btrfs/zlib.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)
fs/btrfs/lzo.c +4 -1
@@ -229,8 +229,11 @@ static int lzo_compress_pages(struct list_head *ws, in_len =min (bytes_left,PAGE_SIZE ); } -if (tot_out > tot_in) +/* Compression must save at least one PAGE_SIZE */ +if (tot_out +PAGE_SIZE > tot_in) { + ret = -E2BIG ; goto out; + }/* store the size of all chunks of compressed data */ cpage_out =kmap (pages[0 ]);
fs/btrfs/zlib.c +2 -1
@@ -191,7 +191,8 @@ static int zlib_compress_pages(struct list_head *ws, goto out; } -if (workspace->strm.total_out >= workspace->strm.total_in) { +/* Compression must save at least one PAGE_SIZE */ +if (workspace->strm.total_out +PAGE_SIZE > workspace->strm.total_in) { ret = -E2BIG ; goto out; }
--
2.13.0
Re: [PATCH v3 2/2] Btrfs: compression must free at least PAGE_SIZE
Quoted 15 lines · IST Timofey Titovets
Btrfs already skip store of data where compression didn't free at least one byte. So make logic better and make check that compression free at least one
PAGE_SIZE, because in another case it useless to store this data compressedSigned-off-by Timofey Titovets <[email protected]>--- fs/btrfs/lzo.c | 5 ++++- fs/btrfs/zlib.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)fs/btrfs/lzo.c +0
-0
fs/btrfs/lzo.c static int lzo_compress_pages(struct list_head *ws, · line 236
Quoted 9 lines
fs/btrfs/lzo.c +4
-1@@ -229,8 +229,11 @@ static int lzo_compress_pages(struct list_head *ws, in_len =min (bytes_left,PAGE_SIZE ); } -if (tot_out > tot_in) +/* Compression must save at least one PAGE_SIZE */ +if (tot_out +PAGE_SIZE > tot_in) { + ret = -E2BIG ; goto out; + }
Apologies for the delayed response.
I am not really sure if compression code must save atleast one sectorsize worth of space. But if other developers agree to it, then the above 'if' condition can be replaced with,
u32 sectorsize = btrfs_inode_sectorsize(mapping->host);
...
...
if (tot_out + sectorsize > tot_in) {
Quoted 25 lines
fs/btrfs/lzo.c +0
-0/* store the size of all chunks of compressed data */ cpage_out =kmap (pages[0 ]);fs/btrfs/zlib.c +2
-2@@ -191,7 +191,8 @@ static int zlib_compress_pages(struct list_head *ws, goto out; } -if (workspace->strm.total_out >= workspace->strm.total_in) { +/* Compression must save at least one PAGE_SIZE */ +if (workspace->strm.total_out +PAGE_SIZE > workspace->strm.total_in) { ret = -E2BIG ; goto out; } --2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
chandan
Re: [PATCH v3 2/2] Btrfs: compression must free at least PAGE_SIZE
2017-05-25 15:51 GMT+03:00 Chandan Rajendra <[email protected]>:
...
Quoted 6 lines
Apologies for the delayed response.
I am not really sure if compression code must save atleast one sectorsize worth of space. But if other developers agree to it, then the above 'if' condition can be replaced with,
Quoted 8 lines
u32 sectorsize =
btrfs_inode_sectorsize(mapping->host);
...
...if (
tot_out+ sectorsize >tot_in) {
--
chandan
Thanks a lot!
This approach much simplier then i imagined, i will update patch set and resend.
Thank you!
Signature · 2 lines
Have a nice day, Timofey.