aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ioctl.c
diff options
context:
space:
mode:
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:
267 } 267 }
268 268
269 case EXT4_IOC_MIGRATE: 269 case EXT4_IOC_MIGRATE:
270 return ext4_ext_migrate(inode, filp, cmd, arg); 270 {
271 int err;
272 if (!is_owner_or_cap(inode))
273 return -EACCES;
274
275 err = mnt_want_write(filp->f_path.mnt);
276 if (err)
277 return err;
278 /*
279 * inode_mutex prevent write and truncate on the file.
280 * Read still goes through. We take i_data_sem in
281 * ext4_ext_swap_inode_data before we switch the
282 * inode format to prevent read.
283 */
284 mutex_lock(&(inode->i_mutex));
285 err = ext4_ext_migrate(inode);
286 mutex_unlock(&(inode->i_mutex));
287 mnt_drop_write(filp->f_path.mnt);
288 return err;
289 }
271 290
272 default: 291 default:
273 return -ENOTTY; 292 return -ENOTTY;