Re: [PATCH] block: fix bd_size_lock use
From: Damien Le Moal <hidden>
Date: 2021-01-28 23:01:06
On 2021/01/28 23:43, Christoph Hellwig wrote:
On Thu, Jan 28, 2021 at 07:39:21AM -0700, Jens Axboe wrote:quoted
On 1/28/21 7:37 AM, Christoph Hellwig wrote:quoted
On Thu, Jan 28, 2021 at 03:36:19PM +0900, Damien Le Moal wrote:quoted
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.I'd much rather fix the driver to not call set_capacity with irqs disabled..Agree, but that might be a bit beyond 5.10 at this point..True.
Agree, it was my initial intent to fix the driver itself to fix this problem. However, the entire completion path code, where the set_capacity() call is, is executed under a single spin_lock with IRQ disabled. That is pretty horrible and will need major surgery to fix. I can work on that for 5.12 if required, but I would rather leave it like this and deprecate this driver so that we can remove it in a couple of releases or so. The STEC cards are not sold anymore since many years ago and are not even supported by the vendor anymore. Should I start fixing this driver or go with deprecating it ? -- Damien Le Moal Western Digital Research