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 C07666FA0 for ; Mon, 16 Jan 2023 16:55:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 431F0C433D2; Mon, 16 Jan 2023 16:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673888139; bh=BPQ0BIBfVbEWfBpt6wLK/JFnO3XNUZh1qg2beyPzEQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B20lwc+fLOjxa8N7t9QgvGcmEU08w7gfRTdCWqeMn+FPkMnfCNxmezBgS6dOzq6fb qMQYNPvVSJ+1RimwzKoOGvVNtjLtu0ugYmVvfCdrl8F8Kt6R3XVmqcAugnLaaoOAbw bg1bOoCIQo4fZ5JKKe4zyhRDbEUnHxFkHxD+LYJI= 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 4.19 415/521] ext4: initialize quota before expanding inode in setproject ioctl Date: Mon, 16 Jan 2023 16:51:17 +0100 Message-Id: <20230116154905.675537386@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154847.246743274@linuxfoundation.org> References: <20230116154847.246743274@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 @@ -449,6 +449,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; @@ -464,10 +468,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);