Linux block layer
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
	Jan Kara <jack@suse.cz>,
	linux-block <linux-block@vger.kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Brian Foster <bfoster@redhat.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Hillf Danton <hdanton@sina.com>,
	Markus Elfring <Markus.Elfring@web.de>,
	Ming Lei <tom.leiming@gmail.com>, Qu Wenruo <wqu@suse.com>,
	Tao Cui <cui.tao@linux.dev>, kernel test robot <lkp@intel.com>,
	rust-for-linux@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Nilay Shroff <nilay@linux.ibm.com>
Subject: Re: [PATCH v4 1/2] block: Add run_todo() operation
Date: Mon, 21 Sep 2026 10:27:43 -0700	[thread overview]
Message-ID: <afbf50a0-d409-45a3-8e95-99c04ca0e302@acm.org> (raw)
In-Reply-To: <e615fb71-f386-4029-8ceb-22e375ad9e94@I-love.SAKURA.ne.jp>

On 9/19/26 3:50 AM, Tetsuo Handa wrote:
> Add run_todo() block device operation which provides a hook for performing
> synchronous cleanup without disk->open_mutex held, which is needed by the
> loop devices.

I like the "post_release()" name much better. I think it is more clear
and more descriptive than "run_todo()".

> diff --git a/block/bdev.c b/block/bdev.c
> index cd8323083740..8f09aafbae11 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -974,6 +974,8 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
>   	bool unblock_events = true;
>   	struct gendisk *disk = bdev->bd_disk;
>   	int ret;
> +	struct module *fops_owner = NULL;
> +	void (*run_todo)(struct gendisk *disk) = NULL;
>   
>   	if (holder) {
>   		mode |= BLK_OPEN_EXCL;
> @@ -996,6 +998,7 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
>   	ret = -EBUSY;
>   	if (!bdev_may_open(bdev, mode))
>   		goto put_module;
> +	run_todo = disk->fops->run_todo;
>   	if (bdev_is_partition(bdev))
>   		ret = blkdev_get_part(bdev, mode);
>   	else
> @@ -1037,12 +1040,15 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
>   
>   	return 0;
>   put_module:
> -	module_put(disk->fops->owner);
> +	fops_owner = disk->fops->owner;
>   abort_claiming:
>   	if (holder)
>   		bd_abort_claiming(bdev, holder);
>   	mutex_unlock(&disk->open_mutex);
>   	disk_unblock_events(disk);
> +	if (run_todo)
> +		run_todo(disk);
> +	module_put(fops_owner);
>   	return ret;
>   }
The above changes introduce a bug: these changes cause module_put()
to be called if try_module_get() fails. I think that's wrong.

Thanks,

Bart.

  parent reply	other threads:[~2026-09-21 17:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 10:50 [PATCH v4 1/2] block: Add run_todo() operation Tetsuo Handa
2026-09-19 10:51 ` [PATCH v4 2/2] loop: Perform __loop_clr_fd() from run_todo callback Tetsuo Handa
2026-09-21 17:30   ` Bart Van Assche
2026-09-21 17:27 ` Bart Van Assche [this message]
2026-09-22  5:08   ` [PATCH v4 1/2] block: Add run_todo() operation Tetsuo Handa
2026-09-22 18:09     ` Bart Van Assche
2026-09-23  5:26       ` Tetsuo Handa
2026-09-23 17:05         ` Bart Van Assche

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=afbf50a0-d409-45a3-8e95-99c04ca0e302@acm.org \
    --to=bvanassche@acm.org \
    --cc=Markus.Elfring@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bfoster@redhat.com \
    --cc=cui.tao@linux.dev \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=hdanton@sina.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=nilay@linux.ibm.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tom.leiming@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox