The patch titled Subject: ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2 has been added to the -mm tree. Its filename is ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Wengang Wang <wen.gang.wang@xxxxxxxxxx> Subject: ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2 remove the "had_alloc_lock" as suggested Link: https://lkml.kernel.org/r/20210402171344.1605-1-wen.gang.wang@xxxxxxxxxx Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Wengang Wang <wen.gang.wang@xxxxxxxxxx> Cc: Mark Fasheh <mark@xxxxxxxxxx> Cc: Joel Becker <jlbec@xxxxxxxxxxxx> Cc: Junxiao Bi <junxiao.bi@xxxxxxxxxx> Cc: Joseph Qi <jiangqi903@xxxxxxxxx> Cc: Changwei Ge <gechangwei@xxxxxxx> Cc: Gang He <ghe@xxxxxxxx> Cc: Jun Piao <piaojun@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/ocfs2/file.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) --- a/fs/ocfs2/file.c~ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2 +++ a/fs/ocfs2/file.c @@ -1124,7 +1124,7 @@ int ocfs2_setattr(struct user_namespace handle_t *handle = NULL; struct dquot *transfer_to[MAXQUOTAS] = { }; int qtype; - int had_lock, had_alloc_lock = 0; + int had_lock; struct ocfs2_lock_holder oh; trace_ocfs2_setattr(inode, dentry, @@ -1246,27 +1246,23 @@ int ocfs2_setattr(struct user_namespace } } down_write(&OCFS2_I(inode)->ip_alloc_sem); - had_alloc_lock = 1; - handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS + 2 * ocfs2_quota_trans_credits(sb)); if (IS_ERR(handle)) { status = PTR_ERR(handle); mlog_errno(status); - goto bail_unlock; + goto bail_unlock_alloc; } status = __dquot_transfer(inode, transfer_to); if (status < 0) goto bail_commit; } else { down_write(&OCFS2_I(inode)->ip_alloc_sem); - had_alloc_lock = 1; - handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); if (IS_ERR(handle)) { status = PTR_ERR(handle); mlog_errno(status); - goto bail_unlock; + goto bail_unlock_alloc; } } @@ -1279,10 +1275,9 @@ int ocfs2_setattr(struct user_namespace bail_commit: ocfs2_commit_trans(osb, handle); +bail_unlock_alloc: + up_write(&OCFS2_I(inode)->ip_alloc_sem); bail_unlock: - if (had_alloc_lock) - up_write(&OCFS2_I(inode)->ip_alloc_sem); - if (status && inode_locked) { ocfs2_inode_unlock_tracker(inode, 1, &oh, had_lock); inode_locked = 0; _ Patches currently in -mm which might be from wen.gang.wang@xxxxxxxxxx are ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write.patch ocfs2-fix-deadlock-between-setattr-and-dio_end_io_write-v2.patch