]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/6.8.6/ext4-forbid-commit-inconsistent-quota-data-when-erro.patch
Linux 6.8.6
[thirdparty/kernel/stable-queue.git] / releases / 6.8.6 / ext4-forbid-commit-inconsistent-quota-data-when-erro.patch
1 From 671376cc826fe7d12bc92e1d7d96671c0dbbf985 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Fri, 19 Jan 2024 14:29:08 +0800
4 Subject: ext4: forbid commit inconsistent quota data when errors=remount-ro
5
6 From: Ye Bin <yebin10@huawei.com>
7
8 [ Upstream commit d8b945fa475f13d787df00c26a6dc45a3e2e1d1d ]
9
10 There's issue as follows When do IO fault injection test:
11 Quota error (device dm-3): find_block_dqentry: Quota for id 101 referenced but not present
12 Quota error (device dm-3): qtree_read_dquot: Can't read quota structure for id 101
13 Quota error (device dm-3): do_check_range: Getting block 2021161007 out of range 1-186
14 Quota error (device dm-3): qtree_read_dquot: Can't read quota structure for id 661
15
16 Now, ext4_write_dquot()/ext4_acquire_dquot()/ext4_release_dquot() may commit
17 inconsistent quota data even if process failed. This may lead to filesystem
18 corruption.
19 To ensure filesystem consistent when errors=remount-ro there is need to call
20 ext4_handle_error() to abort journal.
21
22 Signed-off-by: Ye Bin <yebin10@huawei.com>
23 Reviewed-by: Jan Kara <jack@suse.cz>
24 Link: https://lore.kernel.org/r/20240119062908.3598806-1-yebin10@huawei.com
25 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 ---
28 fs/ext4/super.c | 12 ++++++++++++
29 1 file changed, 12 insertions(+)
30
31 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
32 index 32bd83adf0bb8..4866657c6d41f 100644
33 --- a/fs/ext4/super.c
34 +++ b/fs/ext4/super.c
35 @@ -6864,6 +6864,10 @@ static int ext4_write_dquot(struct dquot *dquot)
36 if (IS_ERR(handle))
37 return PTR_ERR(handle);
38 ret = dquot_commit(dquot);
39 + if (ret < 0)
40 + ext4_error_err(dquot->dq_sb, -ret,
41 + "Failed to commit dquot type %d",
42 + dquot->dq_id.type);
43 err = ext4_journal_stop(handle);
44 if (!ret)
45 ret = err;
46 @@ -6880,6 +6884,10 @@ static int ext4_acquire_dquot(struct dquot *dquot)
47 if (IS_ERR(handle))
48 return PTR_ERR(handle);
49 ret = dquot_acquire(dquot);
50 + if (ret < 0)
51 + ext4_error_err(dquot->dq_sb, -ret,
52 + "Failed to acquire dquot type %d",
53 + dquot->dq_id.type);
54 err = ext4_journal_stop(handle);
55 if (!ret)
56 ret = err;
57 @@ -6899,6 +6907,10 @@ static int ext4_release_dquot(struct dquot *dquot)
58 return PTR_ERR(handle);
59 }
60 ret = dquot_release(dquot);
61 + if (ret < 0)
62 + ext4_error_err(dquot->dq_sb, -ret,
63 + "Failed to release dquot type %d",
64 + dquot->dq_id.type);
65 err = ext4_journal_stop(handle);
66 if (!ret)
67 ret = err;
68 --
69 2.43.0
70