linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] btrfs/ioctl.c: Prefer inode with lowest offset as source for clone
@ 2015-10-20 13:29 Timofey Titovets
  2015-10-20 14:56 ` Filipe Manana
  2015-10-23  0:14 ` Zygo Blaxell
  0 siblings, 2 replies; 5+ messages in thread
From: Timofey Titovets @ 2015-10-20 13:29 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

For performance reason, leave data at the start of disk, is preferable
while deduping
It's might sense for the reasons:
1. Spinning rust - start of the disk is much faster
2. Btrfs can deallocate empty data chunk from the end of fs - ie it's compact fs

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
---
 fs/btrfs/ioctl.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3e3e613..3eb77c0 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3074,8 +3074,13 @@ static int btrfs_extent_same(struct inode *src,
u64 loff, u64 olen,

  /* pass original length for comparison so we stay within i_size */
  ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen, &cmp);
- if (ret == 0)
-     ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
+ if (ret == 0) {
+     /* prefer inode with lowest offset as source for clone*/
+     if (loff > dest_loff)
+         ret = btrfs_clone(dst, src, dst_loff, olen, len, loff, 1);
+     else
+         ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
+ }

  if (same_inode)
  unlock_extent(&BTRFS_I(src)->io_tree, same_lock_start,
-- 
2.6.1

[-- Attachment #2: 0001-btrfs-ioctl.c-Prefer-inode-with-lowest-offset-as-sou.patch --]
[-- Type: text/x-patch, Size: 1215 bytes --]

From 5ed3822bc308c726d91a837fbd97ebacaa51e58d Mon Sep 17 00:00:00 2001
From: Timofey Titovets <nefelim4ag@gmail.com>
Date: Tue, 20 Oct 2015 15:53:20 +0300
Subject: [RFC PATCH] btrfs/ioctl.c: Prefer inode with lowest offset as source for
 clone

For performance reason, leave data at the start of disk, is preferable

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
---
 fs/btrfs/ioctl.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3e3e613..3eb77c0 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3074,8 +3074,13 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
 
 	/* pass original length for comparison so we stay within i_size */
 	ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen, &cmp);
-	if (ret == 0)
-		ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
+	if (ret == 0) {
+		/* prefer inode with lowest offset as source for clone*/
+		if (loff > dest_loff)
+			ret = btrfs_clone(dst, src, dst_loff, olen, len, loff, 1);
+		else
+			ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
+	}
 
 	if (same_inode)
 		unlock_extent(&BTRFS_I(src)->io_tree, same_lock_start,
-- 
2.6.1


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

end of thread, other threads:[~2015-10-23 11:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-20 13:29 [RFC PATCH] btrfs/ioctl.c: Prefer inode with lowest offset as source for clone Timofey Titovets
2015-10-20 14:56 ` Filipe Manana
2015-10-20 16:19   ` Timofey Titovets
2015-10-23  0:14 ` Zygo Blaxell
2015-10-23 11:51   ` Timofey Titovets

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).