Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 04/13] libmultipath: Add bio handling
Date: Fri, 3 Jul 2026 15:48:53 +0100	[thread overview]
Message-ID: <7857df14-e143-4798-ae6a-3a1ec4cbd2e4@oracle.com> (raw)
In-Reply-To: <20260703104915.5EBEA1F000E9@smtp.kernel.org>

On 03/07/2026 11:49, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] TOCTOU race in `mpath_remove_disk` can strand a bio on `requeue_list`, causing `del_gendisk` to deadlock.
> - [Medium] The `trace_block_bio_remap` tracepoint is called with the wrong device argument for `old_dev`, causing the trace event to emit identical devices for source and destination.
> --
> 
> commit 1f99dbf217347b66f1710f734eac617209a4e8c6
> Author: John Garry <john.g.garry@oracle.com>
> 
> libmultipath: Add bio handling
> 
> This commit adds per-path bio submission support and failover requeuing
> logic for libmultipath. It introduces mechanisms similar to NVMe multipath
> to clone bios and submit them with the REQ_MPATH flag.
> 
>> diff --git a/lib/multipath.c b/lib/multipath.c
>> index 21f7ffdb22d60..81e737c1ce469 100644
>> --- a/lib/multipath.c
>> +++ b/lib/multipath.c
> 
> [ ... ]
> 
>> @@ -243,6 +242,81 @@ static struct mpath_device *mpath_find_path(struct mpath_head *mpath_head)
>> +static void mpath_bdev_submit_bio(struct bio *bio)
>> +{
> 
> [ ... ]
> 
>> +		bio_set_dev(bio, mpath_device->disk->part0);
>> +		/*
>> +		 * Use BIO_REMAPPED to skip bio_check_eod() when this bio
>> +		 * enters submit_bio_noacct() for the per-path device. The EOD
>> +		 * check already passed on the multipath head.
>> +		 */
>> +		bio_set_flag(bio, BIO_REMAPPED);
>> +		bio->bi_opf |= REQ_MPATH;
>> +		trace_block_bio_remap(bio, disk_devt(mpath_device->disk),
>> +				      bio->bi_iter.bi_sector);
> 
> [Severity: Medium]
> Does this tracepoint call incorrectly use the target path device instead of
> the original head device?
> 
> By passing disk_devt(mpath_device->disk), it seems the trace event will log
> the new path device as both the source and destination, which might break
> trace analysis. Should this be disk_devt(mpath_head->disk)?

But with bio_set_dev(), the new device is from mpath_device->disk->part0 
and old is the mpath_head disk in mpath_head->disk

> 
>> +		submit_bio_noacct(bio);
>> +	} else if (mpath_available_path(mpath_head)) {
>> +		dev_warn_ratelimited(dev, "no usable path - requeuing I/O\n");
>> +
>> +		spin_lock_irq(&mpath_head->requeue_lock);
>> +		bio_list_add(&mpath_head->requeue_list, bio);
>> +		spin_unlock_irq(&mpath_head->requeue_lock);
>> +		atomic_long_inc(&mpath_head->requeue_no_usable_path_cnt);
>> +	} else {
> 
> [ ... ]
> 
>> @@ -314,11 +389,34 @@ static void multipath_partition_scan_work(struct work_struct *work)
>>   void mpath_remove_disk(struct mpath_head *mpath_head)
>>   {
>>   	if (test_and_clear_bit(MPATH_HEAD_DISK_LIVE, &mpath_head->flags)) {
>>   		struct gendisk *disk = mpath_head->disk;
>>   
>> +		/*
>> +		 * requeue I/O after MPATH_HEAD_DISK_LIVE has been cleared
>> +		 * to allow multipath to fail all I/O.
>> +		 */
>> +		mpath_schedule_requeue_work(mpath_head);
>> +
>>   		mpath_synchronize(mpath_head);
> 
> [Severity: High]
> Could scheduling the requeue work before synchronizing SRCU cause a deadlock
> during device removal?
> 
> If mpath_bdev_submit_bio() checks mpath_available_path() and sees the disk
> is live, but then gets preempted before taking the requeue_lock,
> mpath_remove_disk() might clear MPATH_HEAD_DISK_LIVE and schedule the
> requeue worker.
> 
> The worker would run and find the requeue_list empty. When the submitter
> wakes up and adds the bio, it will be stranded on the requeue_list.
> 
> Because the bio holds a q_usage_counter reference, will del_gendisk()
> hang forever waiting for the queue to freeze?

Yeah, maybe we should do that. This is same as mainline NVMe multipath 
code today.

> 
>>   		del_gendisk(disk);
>>   	}
> 


  reply	other threads:[~2026-07-03 14:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 10:29 [PATCH v3 00/13] libmultipath: a generic multipath lib for block drivers John Garry
2026-07-03 10:29 ` [PATCH v3 01/13] libmultipath: Add initial framework John Garry
2026-07-03 10:43   ` sashiko-bot
2026-07-03 14:06     ` John Garry
2026-07-03 10:29 ` [PATCH v3 02/13] libmultipath: Add basic gendisk support John Garry
2026-07-03 10:51   ` sashiko-bot
2026-07-03 14:19     ` John Garry
2026-07-03 10:29 ` [PATCH v3 03/13] libmultipath: Add path selection support John Garry
2026-07-03 10:45   ` sashiko-bot
2026-07-03 14:37     ` John Garry
2026-07-03 10:29 ` [PATCH v3 04/13] libmultipath: Add bio handling John Garry
2026-07-03 10:49   ` sashiko-bot
2026-07-03 14:48     ` John Garry [this message]
2026-07-03 10:29 ` [PATCH v3 05/13] libmultipath: Add support for mpath_device management John Garry
2026-07-03 10:29 ` [PATCH v3 06/13] libmultipath: Add delayed removal support John Garry
2026-07-03 10:45   ` sashiko-bot
2026-07-03 15:18     ` John Garry
2026-07-03 10:29 ` [PATCH v3 07/13] libmultipath: Add cdev support John Garry
2026-07-03 10:48   ` sashiko-bot
2026-07-06 10:26     ` John Garry
2026-07-03 10:29 ` [PATCH v3 08/13] libmultipath: Add sysfs helpers John Garry
2026-07-03 10:44   ` sashiko-bot
2026-07-06 13:57     ` John Garry
2026-07-03 10:29 ` [PATCH v3 09/13] libmultipath: Add PR support John Garry
2026-07-03 10:48   ` sashiko-bot
2026-07-06 14:12     ` John Garry
2026-07-03 10:29 ` [PATCH v3 10/13] libmultipath: Add mpath_bdev_report_zones() John Garry
2026-07-03 10:29 ` [PATCH v3 11/13] libmultipath: Add support for block device IOCTL John Garry
2026-07-03 10:56   ` sashiko-bot
2026-07-06 14:16     ` John Garry
2026-07-03 10:29 ` [PATCH v3 12/13] libmultipath: Add mpath_bdev_getgeo() John Garry
2026-07-03 10:54   ` sashiko-bot
2026-07-03 10:29 ` [PATCH v3 13/13] libmultipath: Add mpath_bdev_get_unique_id() John Garry

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=7857df14-e143-4798-ae6a-3a1ec4cbd2e4@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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