From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org
Subject: Re: [PATCH 1/2] block: loop: share code of reread partitions
Date: Tue, 7 Jul 2020 19:49:03 +0200 [thread overview]
Message-ID: <20200707174903.GA3730@lst.de> (raw)
In-Reply-To: <20200707084552.3294693-2-ming.lei@redhat.com>
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@redhat.com>
> ---
> 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.
next prev parent reply other threads:[~2020-07-07 17:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 8:45 [PATCH 0/2] block: loop: delete partitions after clearing & changing fd Ming Lei
2020-07-07 8:45 ` [PATCH 1/2] block: loop: share code of reread partitions Ming Lei
2020-07-07 17:49 ` Christoph Hellwig [this message]
2020-07-07 8:45 ` [PATCH 2/2] block: loop: delete partitions after clearing & changing fd Ming Lei
2020-07-07 17:53 ` Christoph Hellwig
2020-07-08 9:13 ` Ming Lei
2020-07-08 9:52 ` Ming Lei
-- strict thread matches above, loose matches on Subject: below --
2025-03-08 16:14 [PATCH 0/5] loop: improve loop aio perf by IOCB_NOWAIT Ming Lei
2025-03-08 16:14 ` [PATCH 1/2] block: loop: share code of reread partitions Ming Lei
2025-03-08 16:17 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200707174903.GA3730@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.