Skip to content

Commit 2df15be

Browse files
OjaswinMjfvogel
authored andcommitted
ext4: protect ext4_release_dquot against freezing
[ Upstream commit 530fea29ef82e169cd7fe048c2b7baaeb85a0028 ] Protect ext4_release_dquot against freezing so that we don't try to start a transaction when FS is frozen, leading to warnings. Further, avoid taking the freeze protection if a transaction is already running so that we don't need end up in a deadlock as described in 46e294e ext4: fix deadlock with fs freezing and EA inodes Suggested-by: Jan Kara <[email protected]> Signed-off-by: Ojaswin Mujoo <[email protected]> Reviewed-by: Baokun Li <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 5f815757e6debbe0b7ecd2c99e32a46de196a797) Signed-off-by: Jack Vogel <[email protected]>
1 parent 7900816 commit 2df15be

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fs/ext4/super.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6906,12 +6906,25 @@ static int ext4_release_dquot(struct dquot *dquot)
69066906
{
69076907
int ret, err;
69086908
handle_t *handle;
6909+
bool freeze_protected = false;
6910+
6911+
/*
6912+
* Trying to sb_start_intwrite() in a running transaction
6913+
* can result in a deadlock. Further, running transactions
6914+
* are already protected from freezing.
6915+
*/
6916+
if (!ext4_journal_current_handle()) {
6917+
sb_start_intwrite(dquot->dq_sb);
6918+
freeze_protected = true;
6919+
}
69096920

69106921
handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
69116922
EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
69126923
if (IS_ERR(handle)) {
69136924
/* Release dquot anyway to avoid endless cycle in dqput() */
69146925
dquot_release(dquot);
6926+
if (freeze_protected)
6927+
sb_end_intwrite(dquot->dq_sb);
69156928
return PTR_ERR(handle);
69166929
}
69176930
ret = dquot_release(dquot);
@@ -6922,6 +6935,10 @@ static int ext4_release_dquot(struct dquot *dquot)
69226935
err = ext4_journal_stop(handle);
69236936
if (!ret)
69246937
ret = err;
6938+
6939+
if (freeze_protected)
6940+
sb_end_intwrite(dquot->dq_sb);
6941+
69256942
return ret;
69266943
}
69276944

0 commit comments

Comments
 (0)