Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

jbd2: use a per-journal lock_class_key for jbd2_trans_commit_key

syzbot is reporting possibility of deadlock due to sharing lock_class_key
for jbd2_handle across ext4 and ocfs2. But this is a false positive, for
one disk partition can't have two filesystems at the same time.

Reported-by: syzbot+6e493c165d26d6fcbf72@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6e493c165d26d6fcbf72
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: syzbot+6e493c165d26d6fcbf72@syzkaller.appspotmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Message-ID: <987110fc-5470-457a-a218-d286a09dd82f@I-love.SAKURA.ne.jp>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org

authored by

Tetsuo Handa and committed by
Theodore Ts'o
524c3853 b97cb7d6

+10 -2
+4 -2
fs/jbd2/journal.c
··· 1521 1521 struct block_device *fs_dev, 1522 1522 unsigned long long start, int len, int blocksize) 1523 1523 { 1524 - static struct lock_class_key jbd2_trans_commit_key; 1525 1524 journal_t *journal; 1526 1525 int err; 1527 1526 int n; ··· 1529 1530 if (!journal) 1530 1531 return ERR_PTR(-ENOMEM); 1531 1532 1533 + lockdep_register_key(&journal->jbd2_trans_commit_key); 1532 1534 journal->j_blocksize = blocksize; 1533 1535 journal->j_dev = bdev; 1534 1536 journal->j_fs_dev = fs_dev; ··· 1560 1560 journal->j_max_batch_time = 15000; /* 15ms */ 1561 1561 atomic_set(&journal->j_reserved_credits, 0); 1562 1562 lockdep_init_map(&journal->j_trans_commit_map, "jbd2_handle", 1563 - &jbd2_trans_commit_key, 0); 1563 + &journal->jbd2_trans_commit_key, 0); 1564 1564 1565 1565 /* The journal is marked for error until we succeed with recovery! */ 1566 1566 journal->j_flags = JBD2_ABORT; ··· 1611 1611 kfree(journal->j_wbuf); 1612 1612 jbd2_journal_destroy_revoke(journal); 1613 1613 journal_fail_superblock(journal); 1614 + lockdep_unregister_key(&journal->jbd2_trans_commit_key); 1614 1615 kfree(journal); 1615 1616 return ERR_PTR(err); 1616 1617 } ··· 2188 2187 jbd2_journal_destroy_revoke(journal); 2189 2188 kfree(journal->j_fc_wbuf); 2190 2189 kfree(journal->j_wbuf); 2190 + lockdep_unregister_key(&journal->jbd2_trans_commit_key); 2191 2191 kfree(journal); 2192 2192 2193 2193 return err;
+6
include/linux/jbd2.h
··· 1253 1253 */ 1254 1254 struct lockdep_map j_trans_commit_map; 1255 1255 #endif 1256 + /** 1257 + * @jbd2_trans_commit_key: 1258 + * 1259 + * "struct lock_class_key" for @j_trans_commit_map 1260 + */ 1261 + struct lock_class_key jbd2_trans_commit_key; 1256 1262 1257 1263 /** 1258 1264 * @j_fc_cleanup_callback: