Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Al Viro e145b35b 24219d21

+43 -43
+43 -43
fs/ext4/ioctl.c
··· 583 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 624 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 587 625 { 588 626 struct inode *inode = file_inode(filp); ··· 805 767 806 768 case EXT4_IOC_GROUP_ADD: { 807 769 struct ext4_new_group_data input; 808 - int err, err2=0; 809 - 810 - err = ext4_resize_begin(sb); 811 - if (err) 812 - return err; 813 770 814 771 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, 815 - sizeof(input))) { 816 - err = -EFAULT; 817 - goto group_add_out; 818 - } 772 + sizeof(input))) 773 + return -EFAULT; 819 774 820 - if (ext4_has_feature_bigalloc(sb)) { 821 - ext4_msg(sb, KERN_ERR, 822 - "Online resizing not supported with bigalloc"); 823 - err = -EOPNOTSUPP; 824 - goto group_add_out; 825 - } 826 - 827 - err = mnt_want_write_file(filp); 828 - if (err) 829 - goto group_add_out; 830 - 831 - err = ext4_group_add(sb, &input); 832 - if (EXT4_SB(sb)->s_journal) { 833 - jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); 834 - err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); 835 - jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 836 - } 837 - if (err == 0) 838 - err = err2; 839 - mnt_drop_write_file(filp); 840 - if (!err && ext4_has_group_desc_csum(sb) && 841 - test_opt(sb, INIT_INODE_TABLE)) 842 - err = ext4_register_li_request(sb, input.group); 843 - group_add_out: 844 - ext4_resize_end(sb); 845 - return err; 775 + return ext4_ioctl_group_add(filp, &input); 846 776 } 847 777 848 778 case EXT4_IOC_MIGRATE: ··· 1081 1075 break; 1082 1076 case EXT4_IOC32_GROUP_ADD: { 1083 1077 struct compat_ext4_new_group_input __user *uinput; 1084 - struct ext4_new_group_input input; 1085 - mm_segment_t old_fs; 1078 + struct ext4_new_group_data input; 1086 1079 int err; 1087 1080 1088 1081 uinput = compat_ptr(arg); ··· 1094 1089 &uinput->reserved_blocks); 1095 1090 if (err) 1096 1091 return -EFAULT; 1097 - old_fs = get_fs(); 1098 - set_fs(KERNEL_DS); 1099 - err = ext4_ioctl(file, EXT4_IOC_GROUP_ADD, 1100 - (unsigned long) &input); 1101 - set_fs(old_fs); 1102 - return err; 1092 + return ext4_ioctl_group_add(file, &input); 1103 1093 } 1104 1094 case EXT4_IOC_MOVE_EXT: 1105 1095 case EXT4_IOC_RESIZE_FS: