Skip to content

Commit d8b945f

Browse files
Ye Bintytso
authored andcommitted
ext4: forbid commit inconsistent quota data when errors=remount-ro
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=remount-ro there is need to call ext4_handle_error() to abort journal. Signed-off-by: Ye Bin <yebin10@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20240119062908.3598806-1-yebin10@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 68ee261 commit d8b945f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

fs/ext4/super.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6864,6 +6864,10 @@ static int ext4_write_dquot(struct dquot *dquot)
68646864
if (IS_ERR(handle))
68656865
return PTR_ERR(handle);
68666866
ret = dquot_commit(dquot);
6867+
if (ret < 0)
6868+
ext4_error_err(dquot->dq_sb, -ret,
6869+
"Failed to commit dquot type %d",
6870+
dquot->dq_id.type);
68676871
err = ext4_journal_stop(handle);
68686872
if (!ret)
68696873
ret = err;
@@ -6880,6 +6884,10 @@ static int ext4_acquire_dquot(struct dquot *dquot)
68806884
if (IS_ERR(handle))
68816885
return PTR_ERR(handle);
68826886
ret = dquot_acquire(dquot);
6887+
if (ret < 0)
6888+
ext4_error_err(dquot->dq_sb, -ret,
6889+
"Failed to acquire dquot type %d",
6890+
dquot->dq_id.type);
68836891
err = ext4_journal_stop(handle);
68846892
if (!ret)
68856893
ret = err;
@@ -6899,6 +6907,10 @@ static int ext4_release_dquot(struct dquot *dquot)
68996907
return PTR_ERR(handle);
69006908
}
69016909
ret = dquot_release(dquot);
6910+
if (ret < 0)
6911+
ext4_error_err(dquot->dq_sb, -ret,
6912+
"Failed to release dquot type %d",
6913+
dquot->dq_id.type);
69026914
err = ext4_journal_stop(handle);
69036915
if (!ret)
69046916
ret = err;

0 commit comments

Comments
 (0)