summaryrefslogtreecommitdiff
path: root/block/partitions
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2021-01-28 09:36:19 +0300
committerJens Axboe <axboe@kernel.dk>2021-01-28 17:31:50 +0300
commit0fe37724f8e70fa4cb72948f60fca553702df768 (patch)
tree3094f7e80c8206dd1842188de08e9c25b459a1dc /block/partitions
parent6c635caef410aa757befbd8857c1eadde5cc22ed (diff)
downloadlinux-0fe37724f8e70fa4cb72948f60fca553702df768.tar.xz
block: fix bd_size_lock use
Some block device drivers, e.g. the skd driver, call set_capacity() with IRQ disabled. This results in lockdep ito complain about inconsistent lock states ("inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage") because set_capacity takes a block device bd_size_lock using the functions spin_lock() and spin_unlock(). Ensure a consistent locking state by replacing these calls with spin_lock_irqsave() and spin_lock_irqrestore(). The same applies to bdev_set_nr_sectors(). With this fix, all lockdep complaints are resolved. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/partitions')
-rw-r--r--block/partitions/core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 23460cee9de5..4601a845cd79 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -88,9 +88,11 @@ static int (*check_part[])(struct parsed_partitions *) = {
static void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors)
{
- spin_lock(&bdev->bd_size_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&bdev->bd_size_lock, flags);
i_size_write(bdev->bd_inode, (loff_t)sectors << SECTOR_SHIFT);
- spin_unlock(&bdev->bd_size_lock);
+ spin_unlock_irqrestore(&bdev->bd_size_lock, flags);
}
static struct parsed_partitions *allocate_partitions(struct gendisk *hd)