From nobody Thu Dec 25 08:34:22 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 C92BD1392; Fri, 19 Jan 2024 06:26:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705645622; cv=none; b=h3kZPWZTIYTYkcSwaEVFRi2O2fsl4TiSaOhXwYJla0cEitwuCNUYmz098JC2JQNB27F/6OmheFHd59+JxhnIDnQqUTigyCzvpBSoY8SEUcX0F2L/yzHlTp31YVxWtYSTjj9aJiGiZAx+zVX4xP+HvOJogkx6lJGaKwfiLPSvgvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705645622; c=relaxed/simple; bh=BJBSrPNRreGjzWMMOUvCDXMWWWf3fGjxnuuwDjC+5Uw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=sJHUEfW2htNxz71aTwqLcQDiKsez2C4sxNC2nsTCbDo5a3QqjbqEpHfCARkeTl/hMhbCVL/E3gsF6yQSfzAkSaidnx9Obdug33RXO6TPiXR75nwZxv9U5mdpET9LPxzS97Us/pCcIr3M7hPYF2QvwHSqfovuW1c1WFMz1hI48eU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TGV4J5kQvz1xmS2; Fri, 19 Jan 2024 14:26:08 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id A93B5140558; Fri, 19 Jan 2024 14:26:55 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 19 Jan 2024 14:26:28 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH] ext4: forbid commit inconsistent quota data when errors=remount-ro Date: Fri, 19 Jan 2024 14:29:08 +0800 Message-ID: <20240119062908.3598806-1-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500010.china.huawei.com (7.192.105.118) Content-Type: text/plain; charset="utf-8" There's issue as follows When do IO fault injection test: Quota error (device dm-3): find_block_dqentry: Quota for id 101 referenced = but not present Quota error (device dm-3): qtree_read_dquot: Can't read quota structure for= id 101 Quota error (device dm-3): do_check_range: Getting block 2021161007 out of = range 1-186 Quota error (device dm-3): qtree_read_dquot: Can't read quota structure for= id 661 Now, ext4_write_dquot()/ext4_acquire_dquot()/ext4_release_dquot() may commit inconsistent quota data even if process failed. This may lead to filesystem corruption. To ensure filesystem consistent when errors=3Dremount-ro there is need to c= all ext4_handle_error() to abort journal. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/super.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 0980845c8b8f..ef41b452173e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6873,6 +6873,10 @@ static int ext4_write_dquot(struct dquot *dquot) if (IS_ERR(handle)) return PTR_ERR(handle); ret =3D dquot_commit(dquot); + if (ret < 0) + ext4_error_err(dquot->dq_sb, -ret, + "Failed to commit dquot type %d", + dquot->dq_id.type); err =3D ext4_journal_stop(handle); if (!ret) ret =3D err; @@ -6889,6 +6893,10 @@ static int ext4_acquire_dquot(struct dquot *dquot) if (IS_ERR(handle)) return PTR_ERR(handle); ret =3D dquot_acquire(dquot); + if (ret < 0) + ext4_error_err(dquot->dq_sb, -ret, + "Failed to acquire dquot type %d", + dquot->dq_id.type); err =3D ext4_journal_stop(handle); if (!ret) ret =3D err; @@ -6908,6 +6916,10 @@ static int ext4_release_dquot(struct dquot *dquot) return PTR_ERR(handle); } ret =3D dquot_release(dquot); + if (ret < 0) + ext4_error_err(dquot->dq_sb, -ret, + "Failed to release dquot type %d", + dquot->dq_id.type); err =3D ext4_journal_stop(handle); if (!ret) ret =3D err; --=20 2.31.1