Skip to content

Commit 10ef07e

Browse files
djbwsashalevin
authored andcommitted
block: fix ext_dev_lock lockdep report
[ Upstream commit 4d66e5e ] ================================= [ INFO: inconsistent lock state ] 4.1.0-rc7+ torvalds#217 Tainted: G O --------------------------------- inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. swapper/6/0 [HC0[0]:SC1[1]:HE1:SE0] takes: (ext_devt_lock){+.?...}, at: [<ffffffff8143a60c>] blk_free_devt+0x3c/0x70 {SOFTIRQ-ON-W} state was registered at: [<ffffffff810bf6b1>] __lock_acquire+0x461/0x1e70 [<ffffffff810c1947>] lock_acquire+0xb7/0x290 [<ffffffff818ac3a8>] _raw_spin_lock+0x38/0x50 [<ffffffff8143a07d>] blk_alloc_devt+0x6d/0xd0 <-- take the lock in process context [..] [<ffffffff810bf64e>] __lock_acquire+0x3fe/0x1e70 [<ffffffff810c00ad>] ? __lock_acquire+0xe5d/0x1e70 [<ffffffff810c1947>] lock_acquire+0xb7/0x290 [<ffffffff8143a60c>] ? blk_free_devt+0x3c/0x70 [<ffffffff818ac3a8>] _raw_spin_lock+0x38/0x50 [<ffffffff8143a60c>] ? blk_free_devt+0x3c/0x70 [<ffffffff8143a60c>] blk_free_devt+0x3c/0x70 <-- take the lock in softirq [<ffffffff8143bfec>] part_release+0x1c/0x50 [<ffffffff8158edf6>] device_release+0x36/0xb0 [<ffffffff8145ac2b>] kobject_cleanup+0x7b/0x1a0 [<ffffffff8145aad0>] kobject_put+0x30/0x70 [<ffffffff8158f147>] put_device+0x17/0x20 [<ffffffff8143c29c>] delete_partition_rcu_cb+0x16c/0x180 [<ffffffff8143c130>] ? read_dev_sector+0xa0/0xa0 [<ffffffff810e0e0f>] rcu_process_callbacks+0x2ff/0xa90 [<ffffffff810e0dcf>] ? rcu_process_callbacks+0x2bf/0xa90 [<ffffffff81067e2e>] __do_softirq+0xde/0x600 Neil sees this in his tests and it also triggers on pmem driver unbind for the libnvdimm tests. This fix is on top of an initial fix by Keith for incorrect usage of mutex_lock() in this path: 2da7809 "block: Fix dev_t minor allocation lifetime". Both this and 2da7809 are candidates for -stable. Fixes: 2da7809 ("block: Fix dev_t minor allocation lifetime") Cc: <stable@vger.kernel.org> Cc: Keith Busch <keith.busch@intel.com> Reported-by: NeilBrown <neilb@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent ec5e9c9 commit 10ef07e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

block/genhd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ int blk_alloc_devt(struct hd_struct *part, dev_t *devt)
422422
/* allocate ext devt */
423423
idr_preload(GFP_KERNEL);
424424

425-
spin_lock(&ext_devt_lock);
425+
spin_lock_bh(&ext_devt_lock);
426426
idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_NOWAIT);
427-
spin_unlock(&ext_devt_lock);
427+
spin_unlock_bh(&ext_devt_lock);
428428

429429
idr_preload_end();
430430
if (idx < 0)
@@ -449,9 +449,9 @@ void blk_free_devt(dev_t devt)
449449
return;
450450

451451
if (MAJOR(devt) == BLOCK_EXT_MAJOR) {
452-
spin_lock(&ext_devt_lock);
452+
spin_lock_bh(&ext_devt_lock);
453453
idr_remove(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
454-
spin_unlock(&ext_devt_lock);
454+
spin_unlock_bh(&ext_devt_lock);
455455
}
456456
}
457457

@@ -691,13 +691,13 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
691691
} else {
692692
struct hd_struct *part;
693693

694-
spin_lock(&ext_devt_lock);
694+
spin_lock_bh(&ext_devt_lock);
695695
part = idr_find(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
696696
if (part && get_disk(part_to_disk(part))) {
697697
*partno = part->partno;
698698
disk = part_to_disk(part);
699699
}
700-
spin_unlock(&ext_devt_lock);
700+
spin_unlock_bh(&ext_devt_lock);
701701
}
702702

703703
return disk;

0 commit comments

Comments
 (0)