linux-stable/drivers/s390/block
Gerald Schaefer 789dd8cb1e s390/dcssblk: fix lockdep warning
dcssblk_remove_store() holds the dcssblk_devices_sem semaphore while
calling del_gendisk(dev_info->gd), which in turn tries to acquire
disk->open_mutex. Then there is dcssblk_release(), which is called
with disk->open_mutex held, and tries to acquire dcssblk_devices_sem.

Lockdep reports this as possible circular locking dependency (CPU0 =
dcssblk_remove_store, CPU1 = dcssblk_release):

[   44.948865]  Possible unsafe locking scenario:

[   44.948866]        CPU0                    CPU1
[   44.948867]        ----                    ----
[   44.948868]   lock(&dcssblk_devices_sem);
[   44.948870]                                lock(&disk->open_mutex);
[   44.948872]                                lock(&dcssblk_devices_sem);
[   44.948874]   lock(&disk->open_mutex);
[   44.948876]
                *** DEADLOCK ***

In practice, this deadlock should not happen, since dcssblk_remove_store()
checks for dev_info->use_count != 0 after acquiring dcssblk_devices_sem,
and breaks out before calling del_gendisk(). dev_info->use_count will be
decremented in dcssblk_release(), protected by dcssblk_devices_sem.

Still there is no need for dcssblk_remove_store() to hold the
dcssblk_devices_sem until after calling del_gendisk(), as this only
protects dcssblk internal data. So fix the lockdep warning by releasing
dcssblk_devices_sem earlier. Also move the segment_unload() loop up,
similar to dcssblk_shared_store() error path, no need to do that after
calling del_gendisk().

Also change dcssblk_shared_store() error path, where dcssblk_devices_sem
was also released only after calling del_gendisk(), and a similar lockdep
warning could be triggered (but also deadlock prevented by check for
dev_info->use_count).

Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2023-08-30 11:03:27 +02:00
..
dasd.c v6.6-vfs.super 2023-08-28 11:04:18 -07:00
dasd_3990_erp.c s390/dasd: print copy pair message only for the correct error 2023-07-24 13:05:29 -06:00
dasd_alias.c s390/dasd: sort out physical vs virtual pointers usage 2023-02-09 17:05:43 -07:00
dasd_devmap.c s390/dasd: add aq_timeouts autoquiesce trigger 2023-04-11 19:53:08 -06:00
dasd_diag.c s390: include linux/io.h instead of asm/io.h 2023-07-03 11:19:40 +02:00
dasd_diag.h
dasd_eckd.c s390: include linux/io.h instead of asm/io.h 2023-07-03 11:19:40 +02:00
dasd_eckd.h s390/dasd: add device ping attribute 2022-09-21 08:32:51 -06:00
dasd_eer.c s390/dasd: add autoquiesce feature 2023-04-11 19:53:08 -06:00
dasd_erp.c
dasd_fba.c s390: include linux/io.h instead of asm/io.h 2023-07-03 11:19:40 +02:00
dasd_fba.h
dasd_genhd.c block: replace fmode_t with a block-specific type for block open flags 2023-06-12 08:04:05 -06:00
dasd_int.h block: replace fmode_t with a block-specific type for block open flags 2023-06-12 08:04:05 -06:00
dasd_ioctl.c s390/dasd: fix hanging device after quiesce/resume 2023-07-24 13:05:29 -06:00
dasd_proc.c
dcssblk.c s390/dcssblk: fix lockdep warning 2023-08-30 11:03:27 +02:00
Kconfig
Makefile
scm_blk.c s390/mm: make virt_to_pfn() a static inline 2023-08-16 15:13:03 +02:00
scm_blk.h block: remove genhd.h 2022-02-02 07:49:59 -07:00
scm_drv.c