Skip to content

Commit a418f65

Browse files
OjaswinMvijay-suman
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 1648029cd30223740cbe1fbee7165f8202b361cf) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent ca149ad commit a418f65

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
@@ -6212,12 +6212,25 @@ static int ext4_release_dquot(struct dquot *dquot)
62126212
{
62136213
int ret, err;
62146214
handle_t *handle;
6215+
bool freeze_protected = false;
6216+
6217+
/*
6218+
* Trying to sb_start_intwrite() in a running transaction
6219+
* can result in a deadlock. Further, running transactions
6220+
* are already protected from freezing.
6221+
*/
6222+
if (!ext4_journal_current_handle()) {
6223+
sb_start_intwrite(dquot->dq_sb);
6224+
freeze_protected = true;
6225+
}
62156226

62166227
handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
62176228
EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
62186229
if (IS_ERR(handle)) {
62196230
/* Release dquot anyway to avoid endless cycle in dqput() */
62206231
dquot_release(dquot);
6232+
if (freeze_protected)
6233+
sb_end_intwrite(dquot->dq_sb);
62216234
return PTR_ERR(handle);
62226235
}
62236236
ret = dquot_release(dquot);
@@ -6228,6 +6241,10 @@ static int ext4_release_dquot(struct dquot *dquot)
62286241
err = ext4_journal_stop(handle);
62296242
if (!ret)
62306243
ret = err;
6244+
6245+
if (freeze_protected)
6246+
sb_end_intwrite(dquot->dq_sb);
6247+
62316248
return ret;
62326249
}
62336250

0 commit comments

Comments
 (0)