Skip to content

Commit

Permalink
ext4: initialize quota before expanding inode in setproject ioctl
Browse files Browse the repository at this point in the history
commit 1485f72 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>
  • Loading branch information
jankara authored and gregkh committed Jan 7, 2023
1 parent 70e5b46 commit 0f860f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/ext4/ioctl.c
Expand Up @@ -732,6 +732,10 @@ static int ext4_ioctl_setproject(struct inode *inode, __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;
Expand All @@ -747,10 +751,6 @@ static int ext4_ioctl_setproject(struct inode *inode, __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);
Expand Down

0 comments on commit 0f860f7

Please sign in to comment.