On Tue, Jul 07, 2020 at 04:45:51PM +0800, Ming Lei wrote: > loop_reread_partitions() has been there for rereading partitions, so > replace the open code in __loop_clr_fd() with loop_reread_partitions() > by passing 'locked' parameter. > > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > --- > drivers/block/loop.c | 29 ++++++++++++----------------- > 1 file changed, 12 insertions(+), 17 deletions(-) > > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index a943207705dd..0e08468b9ce0 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -650,13 +650,17 @@ static inline void loop_update_dio(struct loop_device *lo) > } > > static void loop_reread_partitions(struct loop_device *lo, > - struct block_device *bdev) > + struct block_device *bdev, bool locked) > { > int rc; > > - mutex_lock(&bdev->bd_mutex); > - rc = bdev_disk_changed(bdev, false); > - mutex_unlock(&bdev->bd_mutex); > + if (locked) { > + rc = bdev_disk_changed(bdev, false); > + } else { > + mutex_lock(&bdev->bd_mutex); > + rc = bdev_disk_changed(bdev, false); > + mutex_unlock(&bdev->bd_mutex); > + } functions with an argument based locking context are a really bad idea. And there is absolutely no reason to add them just for a shared printk.