* [PATCH 1/3] Btrfs: fix delalloc checks in clone ioctl
2010-10-19 22:22 [PATCH 0/3] clone ioctl fixes Sage Weil
@ 2010-10-19 22:22 ` Sage Weil
2010-10-19 22:22 ` [PATCH 2/3] Btrfs: fix clone ioctl where range is adjacent to extent Sage Weil
2010-10-19 22:22 ` [PATCH 3/3] Btrfs: fix lockdep warning on clone ioctl Sage Weil
2 siblings, 0 replies; 4+ messages in thread
From: Sage Weil @ 2010-10-19 22:22 UTC (permalink / raw)
To: linux-btrfs; +Cc: Yehuda Sadeh
From: Yehuda Sadeh <yehuda@hq.newdream.net>
The lookup_first_ordered_extent() was done on the wrong inode, and the
->delalloc_bytes test was wrong, as the following
btrfs_wait_ordered_range() would only invoke a range write and wouldn't
write the entire file data range. Also, a bad parameter was passed to
btrfs_wait_ordered_range().
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
---
fs/btrfs/ioctl.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9254b3d..3471b22 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1530,13 +1530,15 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
while (1) {
struct btrfs_ordered_extent *ordered;
lock_extent(&BTRFS_I(src)->io_tree, off, off+len, GFP_NOFS);
- ordered = btrfs_lookup_first_ordered_extent(inode, off+len);
- if (BTRFS_I(src)->delalloc_bytes == 0 && !ordered)
+ ordered = btrfs_lookup_first_ordered_extent(src, off+len);
+ if (!ordered &&
+ !test_range_bit(&BTRFS_I(src)->io_tree, off, off+len,
+ EXTENT_DELALLOC, 0, NULL))
break;
unlock_extent(&BTRFS_I(src)->io_tree, off, off+len, GFP_NOFS);
if (ordered)
btrfs_put_ordered_extent(ordered);
- btrfs_wait_ordered_range(src, off, off+len);
+ btrfs_wait_ordered_range(src, off, len);
}
/* clone data */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] Btrfs: fix lockdep warning on clone ioctl
2010-10-19 22:22 [PATCH 0/3] clone ioctl fixes Sage Weil
2010-10-19 22:22 ` [PATCH 1/3] Btrfs: fix delalloc checks in clone ioctl Sage Weil
2010-10-19 22:22 ` [PATCH 2/3] Btrfs: fix clone ioctl where range is adjacent to extent Sage Weil
@ 2010-10-19 22:22 ` Sage Weil
2 siblings, 0 replies; 4+ messages in thread
From: Sage Weil @ 2010-10-19 22:22 UTC (permalink / raw)
To: linux-btrfs; +Cc: Sage Weil
I'm no lockdep expert, but this appears to make the lockdep warning go
away for the i_mutex locking in the clone ioctl.
Signed-off-by: Sage Weil <sage@newdream.net>
---
fs/btrfs/ioctl.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f4a3dde..3f27529 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1502,11 +1502,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
path->reada = 2;
if (inode < src) {
- mutex_lock(&inode->i_mutex);
- mutex_lock(&src->i_mutex);
+ mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
+ mutex_lock_nested(&src->i_mutex, I_MUTEX_CHILD);
} else {
- mutex_lock(&src->i_mutex);
- mutex_lock(&inode->i_mutex);
+ mutex_lock_nested(&src->i_mutex, I_MUTEX_PARENT);
+ mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD);
}
/* determine range to clone */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread