All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org
Cc: Nilay Shroff <nilay@linux.ibm.com>,
	Christoph Hellwig <hch@lst.de>,
	syzbot+9dd7dbb1a4b915dee638@syzkaller.appspotmail.com
Subject: Re: [PATCH] loop: replace freezing queue with quiesce when changing loop specific setting
Date: Thu, 3 Apr 2025 22:04:58 +0200	[thread overview]
Message-ID: <407754b2-1e52-4d20-892d-524be47053c4@linux.dev> (raw)
In-Reply-To: <20250403105414.1334254-1-ming.lei@redhat.com>

在 2025/4/3 12:54, Ming Lei 写道:
> freeze queue should be used for changing block layer generic setting, such
> as logical block size, PI, ..., and it is enough to quiesce queue for
> changing loop specific setting.
> 
> Remove the queue freeze warning in loop_update_dio(), since it is only
> needed in loop_set_block_size(), where queue is froze obviously.
> 
> Fix reported lockdep by syszbot:
> 
> https://lore.kernel.org/linux-block/67ea99e0.050a0220.3c3d88.0042.GAE@google.com/
> 
> Reported-by: syzbot+9dd7dbb1a4b915dee638@syzkaller.appspotmail.com
> Signed-off-by: Ming Lei <ming.lei@redhat.com>

I am fine with this commit.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>

Zhu Yanjun

> ---
>   drivers/block/loop.c | 14 +++++---------
>   1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 674527d770dc..59886556f55c 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -190,8 +190,6 @@ static bool lo_can_use_dio(struct loop_device *lo)
>   static inline void loop_update_dio(struct loop_device *lo)
>   {
>   	lockdep_assert_held(&lo->lo_mutex);
> -	WARN_ON_ONCE(lo->lo_state == Lo_bound &&
> -		     lo->lo_queue->mq_freeze_depth == 0);
>   
>   	if ((lo->lo_flags & LO_FLAGS_DIRECT_IO) && !lo_can_use_dio(lo))
>   		lo->lo_flags &= ~LO_FLAGS_DIRECT_IO;
> @@ -595,7 +593,6 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
>   {
>   	struct file *file = fget(arg);
>   	struct file *old_file;
> -	unsigned int memflags;
>   	int error;
>   	bool partscan;
>   	bool is_loop;
> @@ -640,11 +637,11 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
>   
>   	/* and ... switch */
>   	disk_force_media_change(lo->lo_disk);
> -	memflags = blk_mq_freeze_queue(lo->lo_queue);
> +	blk_mq_quiesce_queue(lo->lo_queue);
>   	mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
>   	loop_assign_backing_file(lo, file);
>   	loop_update_dio(lo);
> -	blk_mq_unfreeze_queue(lo->lo_queue, memflags);
> +	blk_mq_unquiesce_queue(lo->lo_queue);
>   	partscan = lo->lo_flags & LO_FLAGS_PARTSCAN;
>   	loop_global_unlock(lo, is_loop);
>   
> @@ -1270,7 +1267,6 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
>   	int err;
>   	bool partscan = false;
>   	bool size_changed = false;
> -	unsigned int memflags;
>   
>   	err = mutex_lock_killable(&lo->lo_mutex);
>   	if (err)
> @@ -1287,8 +1283,8 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
>   		invalidate_bdev(lo->lo_device);
>   	}
>   
> -	/* I/O needs to be drained before changing lo_offset or lo_sizelimit */
> -	memflags = blk_mq_freeze_queue(lo->lo_queue);
> +	/* queue needs to be quiesced before changing lo_offset or lo_sizelimit */
> +	blk_mq_quiesce_queue(lo->lo_queue);
>   
>   	err = loop_set_status_from_info(lo, info);
>   	if (err)
> @@ -1310,7 +1306,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
>   	loop_update_dio(lo);
>   
>   out_unfreeze:
> -	blk_mq_unfreeze_queue(lo->lo_queue, memflags);
> +	blk_mq_unquiesce_queue(lo->lo_queue);
>   	if (partscan)
>   		clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
>   out_unlock:


  reply	other threads:[~2025-04-03 20:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 10:54 [PATCH] loop: replace freezing queue with quiesce when changing loop specific setting Ming Lei
2025-04-03 20:04 ` Zhu Yanjun [this message]
2025-04-04  9:11 ` Christoph Hellwig
2025-04-04 12:06   ` Ming Lei
2025-04-07  6:48     ` Christoph Hellwig
2025-04-07 14:54       ` Ming Lei
2025-04-08  5:23         ` Christoph Hellwig

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=407754b2-1e52-4d20-892d-524be47053c4@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nilay@linux.ibm.com \
    --cc=syzbot+9dd7dbb1a4b915dee638@syzkaller.appspotmail.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.