Skip to content

Commit 48d1788

Browse files
jeffmahoneyjankara
authored andcommitted
reiserfs: fix deadlocks with quotas
The BKL push-down for reiserfs made lock recursion a special case that needs to be handled explicitly. One of the cases that was unhandled is dropping the quota during inode eviction. Both reiserfs_evict_inode and reiserfs_write_dquot take the write lock, but when the journal lock is taken it only drops one the references. The locking rules are that the journal lock be acquired before the write lock so leaving the reference open leads to a ABBA deadlock. This patch pushes the unlock up before clear_inode and avoids the recursive locking. Another ABBA situation can occur when the write lock is dropped while reading the bitmap buffer while in the quota code. When the lock is reacquired, it will deadlock against dquot->dq_lock and dqopt->dqio_mutex in the dquot_acquire path. It's safe to retain the lock across the read and should be cached under write load. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 6ea2eea commit 48d1788

2 files changed

Lines changed: 1 addition & 3 deletions

File tree

‎fs/reiserfs/bitmap.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,9 +1334,7 @@ struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb,
13341334
else if (bitmap == 0)
13351335
block = (REISERFS_DISK_OFFSET_IN_BYTES >> sb->s_blocksize_bits) + 1;
13361336

1337-
reiserfs_write_unlock(sb);
13381337
bh = sb_bread(sb, block);
1339-
reiserfs_write_lock(sb);
13401338
if (bh == NULL)
13411339
reiserfs_warning(sb, "sh-2029: %s: bitmap block (#%u) "
13421340
"reading failed", __func__, block);

‎fs/reiserfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ void reiserfs_evict_inode(struct inode *inode)
7676
;
7777
}
7878
out:
79+
reiserfs_write_unlock_once(inode->i_sb, depth);
7980
clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */
8081
dquot_drop(inode);
8182
inode->i_blocks = 0;
82-
reiserfs_write_unlock_once(inode->i_sb, depth);
8383
return;
8484

8585
no_delete:

0 commit comments

Comments
 (0)