summaryrefslogtreecommitdiff
path: root/fs/ext4/ioctl.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-09-13 12:52:26 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-09-13 12:52:26 -0400
commit2a43a878001cc5cb7c3c7be2e8dad0a1aeb939b0 (patch)
treea0653e45baefbbe3d4de74087525d1b86292a101 /fs/ext4/ioctl.c
parent7ee1ec4ca30c6df8e989615cdaacb75f2af4fa6b (diff)
downloadlwn-2a43a878001cc5cb7c3c7be2e8dad0a1aeb939b0.tar.gz
lwn-2a43a878001cc5cb7c3c7be2e8dad0a1aeb939b0.zip
ext4: elevate write count for migrate ioctl
The migrate ioctl writes to the filsystem, so we need to elevate the write count. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ioctl.c')
-rw-r--r--fs/ext4/ioctl.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index ca09dd1039ec..9f3044ac6994 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -267,7 +267,26 @@ setversion_out:
}
case EXT4_IOC_MIGRATE:
- return ext4_ext_migrate(inode, filp, cmd, arg);
+ {
+ int err;
+ if (!is_owner_or_cap(inode))
+ return -EACCES;
+
+ err = mnt_want_write(filp->f_path.mnt);
+ if (err)
+ return err;
+ /*
+ * inode_mutex prevent write and truncate on the file.
+ * Read still goes through. We take i_data_sem in
+ * ext4_ext_swap_inode_data before we switch the
+ * inode format to prevent read.
+ */
+ mutex_lock(&(inode->i_mutex));
+ err = ext4_ext_migrate(inode);
+ mutex_unlock(&(inode->i_mutex));
+ mnt_drop_write(filp->f_path.mnt);
+ return err;
+ }
default:
return -ENOTTY;