* [PATCH] Btrfs: calc file extent num_bytes correctly in file clone
@ 2011-08-24 6:13 Li Zefan
2011-09-07 12:23 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Li Zefan @ 2011-08-24 6:13 UTC (permalink / raw)
To: linux-btrfs@vger.kernel.org; +Cc: Sage Weil
# touch /mnt/dst
# clone_range -s 8192 -l 4096 /mnt/src /mnt/dst
# ls -l /mnt/dst
-rw-r--r-- 1 root root 4096 dst
# umount /mnt
# btrfs-debug-tree /dev/sda7
...
item 11 key (258 EXTENT_DATA 0) itemoff 3230 itemsize 53
extent data disk byte 12582912 nr 49152
extent data offset 8192 nr 12288 ram 49152
extent compression 0
num_bytes should be 4096 not 12288.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/ioctl.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 660a6c8..3351b1b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2331,14 +2331,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
if (type == BTRFS_FILE_EXTENT_REG ||
type == BTRFS_FILE_EXTENT_PREALLOC) {
+ /*
+ * a | --- range to clone ---| b
+ * | ------------- extent ------------- |
+ */
+
+ /* substract range b */
+ if (key.offset + datal > off + len)
+ datal = off + len - key.offset;
+
+ /* substract range a */
if (off > key.offset) {
datao += off - key.offset;
datal -= off - key.offset;
}
- if (key.offset + datal > off + len)
- datal = off + len - key.offset;
-
ret = btrfs_drop_extents(trans, inode,
new_key.offset,
new_key.offset + datal,
--
1.7.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: calc file extent num_bytes correctly in file clone
2011-08-24 6:13 [PATCH] Btrfs: calc file extent num_bytes correctly in file clone Li Zefan
@ 2011-09-07 12:23 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2011-09-07 12:23 UTC (permalink / raw)
To: Li Zefan; +Cc: linux-btrfs@vger.kernel.org, Sage Weil
minor, typos in comments s/substract/subtract/
On Wed, Aug 24, 2011 at 02:13:16PM +0800, Li Zefan wrote:
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 660a6c8..3351b1b 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2331,14 +2331,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
>
> if (type == BTRFS_FILE_EXTENT_REG ||
> type == BTRFS_FILE_EXTENT_PREALLOC) {
> + /*
> + * a | --- range to clone ---| b
> + * | ------------- extent ------------- |
> + */
> +
> + /* substract range b */
...
> + if (key.offset + datal > off + len)
> + datal = off + len - key.offset;
> +
> + /* substract range a */
...
> if (off > key.offset) {
> datao += off - key.offset;
> datal -= off - key.offset;
> }
>
> - if (key.offset + datal > off + len)
> - datal = off + len - key.offset;
> -
> ret = btrfs_drop_extents(trans, inode,
> new_key.offset,
> new_key.offset + datal,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-07 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-24 6:13 [PATCH] Btrfs: calc file extent num_bytes correctly in file clone Li Zefan
2011-09-07 12:23 ` David Sterba
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.