]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ext4: initialize quota before expanding inode in setproject ioctl
authorJan Kara <jack@suse.cz>
Wed, 7 Dec 2022 11:59:27 +0000 (12:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:52 +0000 (11:41 +0100)
commit 4b4add9154bc4de78caf83bc70292dab16bab2e7 upstream.

Make sure we initialize quotas before possibly expanding inode space
(and thus maybe needing to allocate external xattr block) in
ext4_ioctl_setproject(). This prevents not accounting the necessary
block allocation.

Signed-off-by: Jan Kara <jack@suse.cz>
Cc: stable@kernel.org
Link: https://lore.kernel.org/r/20221207115937.26601-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ioctl.c

index de7a7f8229b3cae080e6bb19f045119dc63a6442..645186927c1f83c76df82445b6684f9c2abcf386 100644 (file)
@@ -461,6 +461,10 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
        if (ext4_is_quota_file(inode))
                return err;
 
+       err = dquot_initialize(inode);
+       if (err)
+               return err;
+
        err = ext4_get_inode_loc(inode, &iloc);
        if (err)
                return err;
@@ -476,10 +480,6 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
                brelse(iloc.bh);
        }
 
-       err = dquot_initialize(inode);
-       if (err)
-               return err;
-
        handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
                EXT4_QUOTA_INIT_BLOCKS(sb) +
                EXT4_QUOTA_DEL_BLOCKS(sb) + 3);