linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] clone ioctl fixes
@ 2010-10-19 22:22 Sage Weil
  2010-10-19 22:22 ` [PATCH 1/3] Btrfs: fix delalloc checks in clone ioctl Sage Weil
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sage Weil @ 2010-10-19 22:22 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Sage Weil

Hi Chris,

These are a few critical bug fixes for the clone ioctl.  We've been 
hitting these on a number of different systems, so getting these into 
2.6.37 would be much appreciated.

Thanks!
sage

--

Sage Weil (1):
  Btrfs: fix lockdep warning on clone ioctl

Yehuda Sadeh (2):
  Btrfs: fix delalloc checks in clone ioctl
  Btrfs: fix clone ioctl where range is adjacent to extent

 fs/btrfs/ioctl.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)


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

* [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 2/3] Btrfs: fix clone ioctl where range is adjacent to extent
  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 ` 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>

We had an edge case issue where the requested range was just
following an existing extent. Instead of skipping to the next
extent, we used the previous one which lead to having zero
sized extents.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
---
 fs/btrfs/ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3471b22..f4a3dde 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1607,7 +1607,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
 			}
 			btrfs_release_path(root, path);
 
-			if (key.offset + datal < off ||
+			if (key.offset + datal <= off ||
 			    key.offset >= off+len)
 				goto next;
 
-- 
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

end of thread, other threads:[~2010-10-19 22:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/3] Btrfs: fix lockdep warning on clone ioctl Sage Weil

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