From 5437403abd225b10a49b1c2491eb6806201233e7 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Thu, 17 Apr 2003 05:11:28 -0500 Subject: [PATCH] JFS: Avoid rare deadlock --- fs/jfs/jfs_txnmgr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index 5d013b2d6d256..d7740cc3fb37e 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c @@ -1240,8 +1240,21 @@ int txCommit(tid_t tid, /* transaction identifier */ * Ensure that inode isn't reused before * lazy commit thread finishes processing */ - if (tblk->xflag & (COMMIT_CREATE | COMMIT_DELETE)) + if (tblk->xflag & (COMMIT_CREATE | COMMIT_DELETE)) { atomic_inc(&tblk->ip->i_count); + /* + * Avoid a rare deadlock + * + * If the inode is locked, we may be blocked in + * jfs_commit_inode. If so, we don't want the + * lazy_commit thread doing the last iput() on the inode + * since that may block on the locked inode. Instead, + * commit the transaction synchronously, so the last iput + * will be done by the calling thread (or later) + */ + if (tblk->ip->i_state & I_LOCK) + tblk->xflag &= ~COMMIT_LAZY; + } ASSERT((!(tblk->xflag & COMMIT_DELETE)) || ((tblk->ip->i_nlink == 0) && -- 2.53.0