Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.103 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794170896; b=T0ekefQ8gZ7WtwDZnyEGS+n0X9JaPDL/N9g7mr8xFQv4satW1ugR/LhHk/1Kx2BczZmx PrdoaLHq54A0yXjkTPw1eDg6FJDbWdZdg7VE9lD+Q4FmBkfs4ONZ+5Bk9MtKS76B/j6yu +YxAaLQXqYrNsKCb70jD+u4hwp3qTxya9uyMDCCuU7W5D57HSEJCX/KBIankhTluLbvmD ba5Im2+ARgSdSUwsRGVGfjZOthru6vAWWtnsMMDo6f/nRgOg68Uqk3ReNpiAlIstOAGRU CX9aCb6lihxciD7zelzlHAQvVrHlznKYh/gga8bsO1rtOsurQFJHCqWCHNYrl+zqRmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794170896; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=wUNj3zcErgaPzyJWqZg0hX16vWl0qpJJmvLNO3XQBUs=; b=Yq0eO+hKR/7XIBTyCotMZkke3gfRLfLE44ffo/W7uYwTAEAtsgnroERyEcQOQF9yaUE5 X24LZzWzbj6kq2XnQYTiLsQrTcbd6U4RMq92j/sV0DCjI/zXjNtsnHkxET2r5p3fcYQJE lXTCS6t/sju+8XnCT8dnQwinrJ/Nfy/2S1M7bWTN8Je7GigUlJLg3gTLQAvktI17RLKwL eL6egIwCeZ/eZXlWLpowkLUciIo4PsMTqKN1clWui50aJkq1JCLtvyBOvFTrDCVHugBCM wP7T3IQf+okV8oF8Ufdg9qzjOpnwVJU9D8U1njsAj6zL2PaSmIBYPEuDPnNk6T/baNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=JoCP8mSk; arc=none smtp.remote-ip=95.215.58.103 Received: from mta1.migadu.com (out-103.mta1.migadu.com [95.215.58.103]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2DB7606D807 for ; Sun, 8 Nov 2026 20:48:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A2DB7606D807 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=JoCP8mSk X-Envelope-To: dm-devel@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=pn2Yu/uIIBg3kKaM6bVH+66C04F3rhaZVDPZfB5P3mM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794170893; v=1; x=1794775693; b=JoCP8mSkZajjXQrlA+PQu8uVatkwBDgTURkfM5QEdlXUt66/zi9cx9goYvmCloHvEFGEegpH mCi9ag8zub8hANZd+jMaZG4AmkE1yIRRAi714xkQVxrhYh5zhEvLrdPaFwlx670npjtvxAtXLZe HuSBhzAdU3uWGXo+nZLqHXDU= X-Envelope-To: dm-devel@lists.linux.dev Received: by mta10.migadu.com with ESMTPS id c491654f1496b39a; Sun, 08 Nov 2026 20:48:13 +0000 X-Mizu-Trace-ID: c491654f1496b39a X-Migadu-Flow: FLOW_OUT From: John Garry To: james.bottomley@hansenpartnership.com, mkp@kernel.org Cc: hare@suse.com, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, snitzer@kernel.org, jmeneghi@redhat.com, bmarzins@redhat.com, dm-devel@lists.linux.dev, hch@lst.de, michael.christie@oracle.com, John Garry Subject: [PATCH v9 16/29] scsi-multipath: clone each bio Date: Sun, 8 Nov 2026 20:47:20 +0000 Message-ID: <20261108204733.557995-17-john.garry@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261108204733.557995-1-john.garry@linux.dev> References: <20261108204733.557995-1-john.garry@linux.dev> X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit For failover handling, we will take the approach to resubmit each bio. However, unlike NVMe, for SCSI there is no guarantee that any bio submitted is either all or none completed. As such, for SCSI, for failover handling we will take the approach to just re-submit the original bio. For this, clone and submit each bio. Signed-off-by: John Garry --- drivers/scsi/scsi_multipath.c | 33 +++++++++++++++++++++++++++++++++ include/scsi/scsi_multipath.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c index baf4ca73f8c9..8e229357e62c 100644 --- a/drivers/scsi/scsi_multipath.c +++ b/drivers/scsi/scsi_multipath.c @@ -101,6 +101,7 @@ static void scsi_mpath_head_release(struct device *dev) container_of(dev, struct scsi_mpath_head, dev); struct mpath_head *mpath_head = &scsi_mpath_head->mpath_head; + bioset_exit(&scsi_mpath_head->bio_pool); ida_free(&scsi_multipath_dev_ida, scsi_mpath_head->index); ida_destroy(&scsi_mpath_head->ida); mpath_head_uninit(mpath_head); @@ -239,7 +240,34 @@ static int scsi_multipath_sdev_init(struct scsi_device *sdev) return 0; } +static void scsi_mpath_clone_end_io(struct bio *clone) +{ + struct bio *master_bio = clone->bi_private; + + master_bio->bi_status = clone->bi_status; + bio_put(clone); + bio_endio(master_bio); +} + +static struct bio *scsi_mpath_clone_bio(struct bio *bio) +{ + struct mpath_head *mpath_head = bio->bi_bdev->bd_disk->private_data; + struct scsi_mpath_head *scsi_mpath_head = to_scsi_mpath_head(mpath_head); + struct bio *clone; + + clone = bio_alloc_clone(bio->bi_bdev, bio, GFP_NOIO, + &scsi_mpath_head->bio_pool); + if (!clone) + return NULL; + + clone->bi_end_io = scsi_mpath_clone_end_io; + clone->bi_private = bio; + + return clone; +} + static struct mpath_head_template smpdt = { + .clone_bio = scsi_mpath_clone_bio, }; static struct scsi_mpath_head *scsi_mpath_alloc_head(char *vpd_id) @@ -265,6 +293,9 @@ static struct scsi_mpath_head *scsi_mpath_alloc_head(char *vpd_id) scsi_mpath_head->index = ida_alloc(&scsi_multipath_dev_ida, GFP_KERNEL); if (scsi_mpath_head->index < 0) goto out_uninit_head; + if (bioset_init(&scsi_mpath_head->bio_pool, BIO_POOL_SIZE, + 0, BIOSET_PERCPU_CACHE)) + goto out_ida_free; kref_init(&scsi_mpath_head->ref); device_initialize(&scsi_mpath_head->dev); @@ -284,6 +315,8 @@ static struct scsi_mpath_head *scsi_mpath_alloc_head(char *vpd_id) return scsi_mpath_head; +out_ida_free: + ida_free(&scsi_multipath_dev_ida, scsi_mpath_head->index); out_uninit_head: mpath_head_uninit(&scsi_mpath_head->mpath_head); out_free: diff --git a/include/scsi/scsi_multipath.h b/include/scsi/scsi_multipath.h index d6f290b84f7f..d2ef94ebd29a 100644 --- a/include/scsi/scsi_multipath.h +++ b/include/scsi/scsi_multipath.h @@ -26,6 +26,7 @@ struct scsi_mpath_head { struct ida ida; struct kref ref; enum mpath_iopolicy_e iopolicy; + struct bio_set bio_pool; struct device dev; int index; }; -- 2.43.0