diff options
author | Theodore Ts'o <tytso@mit.edu> | 2012-01-10 11:54:07 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-01-10 11:54:07 -0500 |
commit | ff9cb1c4eead5e4c292e75cd3170a82d66944101 (patch) | |
tree | cdb132a39e550a9b7b28ea67544cb86cd6ebdb6e /fs/ext4/ioctl.c | |
parent | e4e11180dfa545233e5145919b75b7fac88638df (diff) | |
parent | d50f2ab6f050311dbf7b8f5501b25f0bf64a439b (diff) |
Merge branch 'for_linus' into for_linus_merged
Conflicts:
fs/ext4/ioctl.c
Diffstat (limited to 'fs/ext4/ioctl.c')
-rw-r--r-- | fs/ext4/ioctl.c | 86 |
1 files changed, 74 insertions, 12 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index e87a932b073b..6eee25591b81 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include "ext4_jbd2.h" | 18 | #include "ext4_jbd2.h" |
19 | #include "ext4.h" | 19 | #include "ext4.h" |
20 | 20 | ||
21 | #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1) | ||
22 | |||
21 | long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 23 | long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
22 | { | 24 | { |
23 | struct inode *inode = filp->f_dentry->d_inode; | 25 | struct inode *inode = filp->f_dentry->d_inode; |
@@ -186,19 +188,22 @@ setversion_out: | |||
186 | if (err) | 188 | if (err) |
187 | return err; | 189 | return err; |
188 | 190 | ||
189 | if (get_user(n_blocks_count, (__u32 __user *)arg)) | 191 | if (get_user(n_blocks_count, (__u32 __user *)arg)) { |
190 | return -EFAULT; | 192 | err = -EFAULT; |
193 | goto group_extend_out; | ||
194 | } | ||
191 | 195 | ||
192 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, | 196 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, |
193 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | 197 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { |
194 | ext4_msg(sb, KERN_ERR, | 198 | ext4_msg(sb, KERN_ERR, |
195 | "Online resizing not supported with bigalloc"); | 199 | "Online resizing not supported with bigalloc"); |
196 | return -EOPNOTSUPP; | 200 | err = -EOPNOTSUPP; |
201 | goto group_extend_out; | ||
197 | } | 202 | } |
198 | 203 | ||
199 | err = mnt_want_write_file(filp); | 204 | err = mnt_want_write_file(filp); |
200 | if (err) | 205 | if (err) |
201 | return err; | 206 | goto group_extend_out; |
202 | 207 | ||
203 | err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count); | 208 | err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count); |
204 | if (EXT4_SB(sb)->s_journal) { | 209 | if (EXT4_SB(sb)->s_journal) { |
@@ -209,8 +214,8 @@ setversion_out: | |||
209 | if (err == 0) | 214 | if (err == 0) |
210 | err = err2; | 215 | err = err2; |
211 | mnt_drop_write_file(filp); | 216 | mnt_drop_write_file(filp); |
217 | group_extend_out: | ||
212 | ext4_resize_end(sb); | 218 | ext4_resize_end(sb); |
213 | |||
214 | return err; | 219 | return err; |
215 | } | 220 | } |
216 | 221 | ||
@@ -251,8 +256,7 @@ setversion_out: | |||
251 | err = ext4_move_extents(filp, donor_filp, me.orig_start, | 256 | err = ext4_move_extents(filp, donor_filp, me.orig_start, |
252 | me.donor_start, me.len, &me.moved_len); | 257 | me.donor_start, me.len, &me.moved_len); |
253 | mnt_drop_write_file(filp); | 258 | mnt_drop_write_file(filp); |
254 | if (me.moved_len > 0) | 259 | mnt_drop_write(filp->f_path.mnt); |
255 | file_remove_suid(donor_filp); | ||
256 | 260 | ||
257 | if (copy_to_user((struct move_extent __user *)arg, | 261 | if (copy_to_user((struct move_extent __user *)arg, |
258 | &me, sizeof(me))) | 262 | &me, sizeof(me))) |
@@ -271,19 +275,22 @@ mext_out: | |||
271 | return err; | 275 | return err; |
272 | 276 | ||
273 | if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, | 277 | if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, |
274 | sizeof(input))) | 278 | sizeof(input))) { |
275 | return -EFAULT; | 279 | err = -EFAULT; |
280 | goto group_add_out; | ||
281 | } | ||
276 | 282 | ||
277 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, | 283 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, |
278 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | 284 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { |
279 | ext4_msg(sb, KERN_ERR, | 285 | ext4_msg(sb, KERN_ERR, |
280 | "Online resizing not supported with bigalloc"); | 286 | "Online resizing not supported with bigalloc"); |
281 | return -EOPNOTSUPP; | 287 | err = -EOPNOTSUPP; |
288 | goto group_add_out; | ||
282 | } | 289 | } |
283 | 290 | ||
284 | err = mnt_want_write_file(filp); | 291 | err = mnt_want_write_file(filp); |
285 | if (err) | 292 | if (err) |
286 | return err; | 293 | goto group_add_out; |
287 | 294 | ||
288 | err = ext4_group_add(sb, &input); | 295 | err = ext4_group_add(sb, &input); |
289 | if (EXT4_SB(sb)->s_journal) { | 296 | if (EXT4_SB(sb)->s_journal) { |
@@ -294,8 +301,8 @@ mext_out: | |||
294 | if (err == 0) | 301 | if (err == 0) |
295 | err = err2; | 302 | err = err2; |
296 | mnt_drop_write_file(filp); | 303 | mnt_drop_write_file(filp); |
304 | group_add_out: | ||
297 | ext4_resize_end(sb); | 305 | ext4_resize_end(sb); |
298 | |||
299 | return err; | 306 | return err; |
300 | } | 307 | } |
301 | 308 | ||
@@ -335,6 +342,60 @@ mext_out: | |||
335 | return err; | 342 | return err; |
336 | } | 343 | } |
337 | 344 | ||
345 | case EXT4_IOC_RESIZE_FS: { | ||
346 | ext4_fsblk_t n_blocks_count; | ||
347 | struct super_block *sb = inode->i_sb; | ||
348 | int err = 0, err2 = 0; | ||
349 | |||
350 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, | ||
351 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | ||
352 | ext4_msg(sb, KERN_ERR, | ||
353 | "Online resizing not (yet) supported with bigalloc"); | ||
354 | return -EOPNOTSUPP; | ||
355 | } | ||
356 | |||
357 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, | ||
358 | EXT4_FEATURE_INCOMPAT_META_BG)) { | ||
359 | ext4_msg(sb, KERN_ERR, | ||
360 | "Online resizing not (yet) supported with meta_bg"); | ||
361 | return -EOPNOTSUPP; | ||
362 | } | ||
363 | |||
364 | if (copy_from_user(&n_blocks_count, (__u64 __user *)arg, | ||
365 | sizeof(__u64))) { | ||
366 | return -EFAULT; | ||
367 | } | ||
368 | |||
369 | if (n_blocks_count > MAX_32_NUM && | ||
370 | !EXT4_HAS_INCOMPAT_FEATURE(sb, | ||
371 | EXT4_FEATURE_INCOMPAT_64BIT)) { | ||
372 | ext4_msg(sb, KERN_ERR, | ||
373 | "File system only supports 32-bit block numbers"); | ||
374 | return -EOPNOTSUPP; | ||
375 | } | ||
376 | |||
377 | err = ext4_resize_begin(sb); | ||
378 | if (err) | ||
379 | return err; | ||
380 | |||
381 | err = mnt_want_write(filp->f_path.mnt); | ||
382 | if (err) | ||
383 | goto resizefs_out; | ||
384 | |||
385 | err = ext4_resize_fs(sb, n_blocks_count); | ||
386 | if (EXT4_SB(sb)->s_journal) { | ||
387 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | ||
388 | err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | ||
389 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | ||
390 | } | ||
391 | if (err == 0) | ||
392 | err = err2; | ||
393 | mnt_drop_write(filp->f_path.mnt); | ||
394 | resizefs_out: | ||
395 | ext4_resize_end(sb); | ||
396 | return err; | ||
397 | } | ||
398 | |||
338 | case FITRIM: | 399 | case FITRIM: |
339 | { | 400 | { |
340 | struct request_queue *q = bdev_get_queue(sb->s_bdev); | 401 | struct request_queue *q = bdev_get_queue(sb->s_bdev); |
@@ -433,6 +494,7 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
433 | } | 494 | } |
434 | case EXT4_IOC_MOVE_EXT: | 495 | case EXT4_IOC_MOVE_EXT: |
435 | case FITRIM: | 496 | case FITRIM: |
497 | case EXT4_IOC_RESIZE_FS: | ||
436 | break; | 498 | break; |
437 | default: | 499 | default: |
438 | return -ENOIOCTLCMD; | 500 | return -ENOIOCTLCMD; |