All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Btrfs: don't compress for a small write
@ 2014-03-24  9:58 Wang Shilong
  2014-03-24  9:58 ` [PATCH 2/2] Btrfs: scrub raid56 stripes in the right way Wang Shilong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wang Shilong @ 2014-03-24  9:58 UTC (permalink / raw)
  To: linux-btrfs

To compress a small write(<=blocksize) dosen't save us
disk space at all, skip it can save us some compression time.

This patch can also fix wrong setting nocompression flag for
inode, say a case when @total_in is 4096, and then we get
@total_compressed 52,because we do aligment to page cache size
firstly, and then we get into conclusion @total_in=@total_compressed
thus we will clear this inode's compression flag.

An exception comes from inserting inline extent failure but we
still have @total_compressed < @total_in,so we will still reset
inode's flag, this is ok, because we don't have good compression
effect.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
 fs/btrfs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0ec8766..d3eccd6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -394,6 +394,15 @@ static noinline int compress_file_range(struct inode *inode,
 	    (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
 		btrfs_add_inode_defrag(NULL, inode);
 
+	/*
+	 * if this is a small write(<=blocksize), we don't save
+	 * disk space at all, don't compress which can save us some
+	 * compression time.
+	 */
+	if ((end - start + 1) <= blocksize &&
+	    (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
+		goto cleanup_and_bail_uncompressed;
+
 	actual_end = min_t(u64, isize, end + 1);
 again:
 	will_compress = 0;
-- 
1.9.0


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

end of thread, other threads:[~2014-03-31 12:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-24  9:58 [PATCH 1/2] Btrfs: don't compress for a small write Wang Shilong
2014-03-24  9:58 ` [PATCH 2/2] Btrfs: scrub raid56 stripes in the right way Wang Shilong
2014-03-28 12:00   ` Wang Shilong
2014-03-26 18:10 ` [PATCH 1/2] Btrfs: don't compress for a small write David Sterba
2014-03-27  3:06   ` Wang Shilong
2014-03-31 12:31 ` Chris Mason
2014-03-31 12:53   ` Shilong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.