diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-09-29 21:39:59 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-11-10 08:48:44 -0500 |
commit | e145b35bb97eaf86205b99feef524254c581895c (patch) | |
tree | f9f5eafaa71aff788ae494277d66c1cf8b24579e /fs/ext4 | |
parent | 24219d21c75f188d9e25053b0da22f2d698ca688 (diff) |
ext4: take handling of EXT4_IOC_GROUP_ADD into a helper, get rid of set_fs()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ioctl.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index afb66d4ab5cf..aafba6287a73 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -583,6 +583,44 @@ static int ext4_ioc_getfsmap(struct super_block *sb, | |||
583 | return 0; | 583 | return 0; |
584 | } | 584 | } |
585 | 585 | ||
586 | static long ext4_ioctl_group_add(struct file *file, | ||
587 | struct ext4_new_group_data *input) | ||
588 | { | ||
589 | struct super_block *sb = file_inode(file)->i_sb; | ||
590 | int err, err2=0; | ||
591 | |||
592 | err = ext4_resize_begin(sb); | ||
593 | if (err) | ||
594 | return err; | ||
595 | |||
596 | if (ext4_has_feature_bigalloc(sb)) { | ||
597 | ext4_msg(sb, KERN_ERR, | ||
598 | "Online resizing not supported with bigalloc"); | ||
599 | err = -EOPNOTSUPP; | ||
600 | goto group_add_out; | ||
601 | } | ||
602 | |||
603 | err = mnt_want_write_file(file); | ||
604 | if (err) | ||
605 | goto group_add_out; | ||
606 | |||
607 | err = ext4_group_add(sb, input); | ||
608 | if (EXT4_SB(sb)->s_journal) { | ||
609 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | ||
610 | err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | ||
611 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | ||
612 | } | ||
613 | if (err == 0) | ||
614 | err = err2; | ||
615 | mnt_drop_write_file(file); | ||
616 | if (!err && ext4_has_group_desc_csum(sb) && | ||
617 | test_opt(sb, INIT_INODE_TABLE)) | ||
618 | err = ext4_register_li_request(sb, input->group); | ||
619 | group_add_out: | ||
620 | ext4_resize_end(sb); | ||
621 | return err; | ||
622 | } | ||
623 | |||
586 | long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 624 | long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
587 | { | 625 | { |
588 | struct inode *inode = file_inode(filp); | 626 | struct inode *inode = file_inode(filp); |
@@ -767,44 +805,12 @@ mext_out: | |||
767 | 805 | ||
768 | case EXT4_IOC_GROUP_ADD: { | 806 | case EXT4_IOC_GROUP_ADD: { |
769 | struct ext4_new_group_data input; | 807 | struct ext4_new_group_data input; |
770 | int err, err2=0; | ||
771 | |||
772 | err = ext4_resize_begin(sb); | ||
773 | if (err) | ||
774 | return err; | ||
775 | 808 | ||
776 | if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, | 809 | if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, |
777 | sizeof(input))) { | 810 | sizeof(input))) |
778 | err = -EFAULT; | 811 | return -EFAULT; |
779 | goto group_add_out; | ||
780 | } | ||
781 | |||
782 | if (ext4_has_feature_bigalloc(sb)) { | ||
783 | ext4_msg(sb, KERN_ERR, | ||
784 | "Online resizing not supported with bigalloc"); | ||
785 | err = -EOPNOTSUPP; | ||
786 | goto group_add_out; | ||
787 | } | ||
788 | |||
789 | err = mnt_want_write_file(filp); | ||
790 | if (err) | ||
791 | goto group_add_out; | ||
792 | 812 | ||
793 | err = ext4_group_add(sb, &input); | 813 | return ext4_ioctl_group_add(filp, &input); |
794 | if (EXT4_SB(sb)->s_journal) { | ||
795 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | ||
796 | err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | ||
797 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | ||
798 | } | ||
799 | if (err == 0) | ||
800 | err = err2; | ||
801 | mnt_drop_write_file(filp); | ||
802 | if (!err && ext4_has_group_desc_csum(sb) && | ||
803 | test_opt(sb, INIT_INODE_TABLE)) | ||
804 | err = ext4_register_li_request(sb, input.group); | ||
805 | group_add_out: | ||
806 | ext4_resize_end(sb); | ||
807 | return err; | ||
808 | } | 814 | } |
809 | 815 | ||
810 | case EXT4_IOC_MIGRATE: | 816 | case EXT4_IOC_MIGRATE: |
@@ -1075,8 +1081,7 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1075 | break; | 1081 | break; |
1076 | case EXT4_IOC32_GROUP_ADD: { | 1082 | case EXT4_IOC32_GROUP_ADD: { |
1077 | struct compat_ext4_new_group_input __user *uinput; | 1083 | struct compat_ext4_new_group_input __user *uinput; |
1078 | struct ext4_new_group_input input; | 1084 | struct ext4_new_group_data input; |
1079 | mm_segment_t old_fs; | ||
1080 | int err; | 1085 | int err; |
1081 | 1086 | ||
1082 | uinput = compat_ptr(arg); | 1087 | uinput = compat_ptr(arg); |
@@ -1089,12 +1094,7 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1089 | &uinput->reserved_blocks); | 1094 | &uinput->reserved_blocks); |
1090 | if (err) | 1095 | if (err) |
1091 | return -EFAULT; | 1096 | return -EFAULT; |
1092 | old_fs = get_fs(); | 1097 | return ext4_ioctl_group_add(file, &input); |
1093 | set_fs(KERNEL_DS); | ||
1094 | err = ext4_ioctl(file, EXT4_IOC_GROUP_ADD, | ||
1095 | (unsigned long) &input); | ||
1096 | set_fs(old_fs); | ||
1097 | return err; | ||
1098 | } | 1098 | } |
1099 | case EXT4_IOC_MOVE_EXT: | 1099 | case EXT4_IOC_MOVE_EXT: |
1100 | case EXT4_IOC_RESIZE_FS: | 1100 | case EXT4_IOC_RESIZE_FS: |