From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 583EAAD48 for ; Wed, 4 Jan 2023 16:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9B8DC433D2; Wed, 4 Jan 2023 16:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672849626; bh=4aVomUC427AMNaaw43UgXdo47FNOPAhP+Zw1KAFJmDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lxm07J5c0SzCR4zFVuYfUvpcy55hO8bl6jVnlONENu9c5P8o9Pr5E6PYwSOkz1r3O PnaOe73kfrPdDNr09xn2LC+QSSM8C52B3UrBcKZ7JauALHeVcThsjvQ1vAwdga992o PkkjHSAom5k7vc7yPqhBNGreMphz1XvE3ChQeqEk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , stable@kernel.org, Theodore Tso Subject: [PATCH 6.0 165/177] ext4: initialize quota before expanding inode in setproject ioctl Date: Wed, 4 Jan 2023 17:07:36 +0100 Message-Id: <20230104160512.680160992@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104160507.635888536@linuxfoundation.org> References: <20230104160507.635888536@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jan Kara commit 1485f726c6dec1a1f85438f2962feaa3d585526f 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 Cc: stable@kernel.org Link: https://lore.kernel.org/r/20221207115937.26601-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/ioctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -732,6 +732,10 @@ static int ext4_ioctl_setproject(struct 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; @@ -747,10 +751,6 @@ static int ext4_ioctl_setproject(struct 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);