linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6] Btrfs: compression must free at least one sector size
@ 2017-06-06 11:41 Timofey Titovets
  2017-06-13 13:45 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Timofey Titovets @ 2017-06-06 11:41 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Timofey Titovets, David Sterba

Btrfs already skip store of data where compression didn't
free at least one byte. Let's make logic better and make check
that compression free at least one sector size
because in another case it useless to store this data compressed

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Cc: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 17cbe930..7646f46b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -609,11 +609,10 @@ static noinline void compress_file_range(struct inode *inode,
 		/*
 		 * one last check to make sure the compression is really a
 		 * win, compare the page count read with the blocks on disk
+		 * compression must free at least one sector size
 		 */
 		total_in = ALIGN(total_in, PAGE_SIZE);
-		if (total_compressed >= total_in) {
-			will_compress = 0;
-		} else {
+		if (total_compressed + blocksize <= total_in) {
 			num_bytes = total_in;
 			*num_added += 1;

--
2.13.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v6] Btrfs: compression must free at least one sector size
  2017-06-06 11:41 [PATCH v6] Btrfs: compression must free at least one sector size Timofey Titovets
@ 2017-06-13 13:45 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-06-13 13:45 UTC (permalink / raw)
  To: Timofey Titovets; +Cc: linux-btrfs, David Sterba

On Tue, Jun 06, 2017 at 02:41:15PM +0300, Timofey Titovets wrote:
> Btrfs already skip store of data where compression didn't
> free at least one byte. Let's make logic better and make check
> that compression free at least one sector size
> because in another case it useless to store this data compressed
> 
> Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>

Reviewed-by: David Sterba <dsterba@suse.com>

I've updated the changelog a bit.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-13 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-06 11:41 [PATCH v6] Btrfs: compression must free at least one sector size Timofey Titovets
2017-06-13 13:45 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).