linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3]ext4: Initialize moved_len before calling ext4_move_extents()
@ 2009-11-18  7:26 Akira Fujita
  2009-11-24 15:31 ` tytso
  0 siblings, 1 reply; 2+ messages in thread
From: Akira Fujita @ 2009-11-18  7:26 UTC (permalink / raw)
  To: Theodore Tso; +Cc: ext4 development, Akira Fujita

# This is a RESENT patch
http://marc.info/?l=linux-ext4&m=125498954712519&w=4

ext4: initialize moved_len before calling ext4_move_extents()

From: Kazuya Mio <k-mio@sx.jp.nec.com>

moved_len of struct move_extent is used to notify
exchanged blocks count to the user space.
So at the beginning of the EXT4_IOC_MOVE_EXT,
moved_len should be always zero.
Without this patch, if wrong moved_len is passed from the user space,
EXT4_IOC_MOVE_EXT will return wrong blocks count.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
---
 ioctl.c       |    1 +
 move_extent.c |   12 ++----------
 2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index d1fe495..dbf9a8b 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -251,6 +251,7 @@ setversion_out:
 			}
 		}

+		me.moved_len = 0;
 		err = ext4_move_extents(filp, donor_filp, me.orig_start,
 					me.donor_start, me.len, &me.moved_len);
 		fput(donor_filp);
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 25b6b14..e2e99fd 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -962,7 +962,6 @@ out2:
  * @orig_start:		logical start offset in block for orig
  * @donor_start:	logical start offset in block for donor
  * @len:		the number of blocks to be moved
- * @moved_len:		moved block length
  *
  * Check the arguments of ext4_move_extents() whether the files can be
  * exchanged with each other.
@@ -971,7 +970,7 @@ out2:
 static int
 mext_check_arguments(struct inode *orig_inode,
 			  struct inode *donor_inode, __u64 orig_start,
-			  __u64 donor_start, __u64 *len, __u64 moved_len)
+			  __u64 donor_start, __u64 *len)
 {
 	ext4_lblk_t orig_blocks, donor_blocks;
 	unsigned int blkbits = orig_inode->i_blkbits;
@@ -1025,13 +1024,6 @@ mext_check_arguments(struct inode *orig_inode,
 		return -EINVAL;
 	}

-	if (moved_len) {
-		ext4_debug("ext4 move extent: moved_len should be 0 "
-			"[ino:orig %lu, donor %lu]\n", orig_inode->i_ino,
-			donor_inode->i_ino);
-		return -EINVAL;
-	}

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

* Re: [PATCH 2/3]ext4: Initialize moved_len before calling ext4_move_extents()
  2009-11-18  7:26 [PATCH 2/3]ext4: Initialize moved_len before calling ext4_move_extents() Akira Fujita
@ 2009-11-24 15:31 ` tytso
  0 siblings, 0 replies; 2+ messages in thread
From: tytso @ 2009-11-24 15:31 UTC (permalink / raw)
  To: Akira Fujita; +Cc: ext4 development

On Wed, Nov 18, 2009 at 04:26:10PM +0900, Akira Fujita wrote:
> ext4: initialize moved_len before calling ext4_move_extents()
> 
> From: Kazuya Mio <k-mio@sx.jp.nec.com>
> 
> moved_len of struct move_extent is used to notify
> exchanged blocks count to the user space.
> So at the beginning of the EXT4_IOC_MOVE_EXT,
> moved_len should be always zero.
> Without this patch, if wrong moved_len is passed from the user space,
> EXT4_IOC_MOVE_EXT will return wrong blocks count.

Applied with the following rewording of the patch description:

ext4: initialize moved_len before calling ext4_move_extents()

From: Kazuya Mio <k-mio@sx.jp.nec.com>

The move_extent.moved_len is used to pass back the number of exchanged
blocks count to user space.  Currently the caller must clear this
field; but we spend more code space checking for this requirement than
simply zeroing the field ourselves, so let's just make life easier for
everyone all around.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

						- Ted

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

end of thread, other threads:[~2009-11-24 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18  7:26 [PATCH 2/3]ext4: Initialize moved_len before calling ext4_move_extents() Akira Fujita
2009-11-24 15:31 ` tytso

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