Skip to content

Commit 1dbece9

Browse files
OjaswinMgregkh
authored andcommitted
ext4: protect ext4_release_dquot against freezing
[ Upstream commit 530fea2 ] 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 <jack@suse.cz> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Reviewed-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20241121123855.645335-3-ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1263713 commit 1dbece9

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

fs/ext4/super.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6933,12 +6933,25 @@ static int ext4_release_dquot(struct dquot *dquot)
69336933
{
69346934
int ret, err;
69356935
handle_t *handle;
6936+
bool freeze_protected = false;
6937+
6938+
/*
6939+
* Trying to sb_start_intwrite() in a running transaction
6940+
* can result in a deadlock. Further, running transactions
6941+
* are already protected from freezing.
6942+
*/
6943+
if (!ext4_journal_current_handle()) {
6944+
sb_start_intwrite(dquot->dq_sb);
6945+
freeze_protected = true;
6946+
}
69366947

69376948
handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
69386949
EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
69396950
if (IS_ERR(handle)) {
69406951
/* Release dquot anyway to avoid endless cycle in dqput() */
69416952
dquot_release(dquot);
6953+
if (freeze_protected)
6954+
sb_end_intwrite(dquot->dq_sb);
69426955
return PTR_ERR(handle);
69436956
}
69446957
ret = dquot_release(dquot);
@@ -6949,6 +6962,10 @@ static int ext4_release_dquot(struct dquot *dquot)
69496962
err = ext4_journal_stop(handle);
69506963
if (!ret)
69516964
ret = err;
6965+
6966+
if (freeze_protected)
6967+
sb_end_intwrite(dquot->dq_sb);
6968+
69526969
return ret;
69536970
}
69546971

0 commit comments

Comments
 (0)