Re: [PATCH] loop: make autoclear operation asynchronous
From: Christoph Hellwig <hch@infradead.org>
Date: 2021-12-03 06:51:03
From: Christoph Hellwig <hch@infradead.org>
Date: 2021-12-03 06:51:03
On Thu, Dec 02, 2021 at 07:05:00PM +0100, Jan Kara wrote:
So the advantage of using task work instead of just dropping open_mutex before calling __loop_clr_fd() is that if something in block/bdev.c ever changes and starts relying on open_mutex being held throughout blkdev_put() then loop device handling will not suddently become broken. Generally it is a bad practice to drop locks (even temporarily) upper layers have acquired. Sometimes it is inevitable in in this case we can avoid that... So I'd prefer if we used task work instead of dropping open_mutex inside loop driver. Not sure what's Christoph's opinion though, I don't feel *that* strongly about it.
Dropping the lock is a complete no go a it doesn't allow proper reasoning about the locking scheme in the block layer. task_work_add sounds nice, but it is currently not exported which might be for a reason (I don't really have any experience with it).