From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.127 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794170902; b=J1kIzSTJwJIqxoApvePvGVjUt0iGo6a50u9+tjUHS6omLNu39x156EuUL8DRKKW6nG6Y m2YnCtTdvPGEgDXs0EQvAcPdG3MYGsNULL81iCrLdBj86mFqq516gGhLx/c1l8eiHdd8h KcO5uIBm/jy4Ii3gPJdpwv9xwhxIVNKaZ2WkL/2NTpHnKB9uQVjPzqXbZIB5eS2vjyfWq kLyRVHl/fAVzlxnPgiRkoHT0GGO0oTAKVJNU/XLj0zBrQ8Xgm/smJKJP/ljIYJ3M191TU 8gDw1viibn/XNOpGpdq54Hqtt9TEmOn1U5v4AtRdalERHlBPHL/SZvAdTHQROwS/tNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794170902; 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=2nnhEenE0/1GT2EDac2uSW/ypInHmlgcoWTshjS2obA=; b=XGZM0r0+TDyPeLETTrd4+7sOf2DLAPXvlXhwsxlyyqX0VR0ZE8zWlA2+cEwTDZQ3+L5k jqYG2SnsvkLzF3+3nvc/K+GNHieufQYKvezr0X9l2rn8p9ezltoR8PWSIaoptBfOqcUss b8W5RVnNtp8HCkb04ebwZ9FuuLswr61KCHOJ1lwG8+SBxP8qaDbeurGU48INtl7YLVzn5 qTiyWicKbYl0ZWuNSjr+Y1kYvy7w9JjkpzieiKUjMW06I/bl2STLh+aT5/3oJh71yCPmw Nf5N/sxDlKd3vUnAbNBXkI5Sqwm6ZaivFkD22K+EFpo/ZrroSNPkVxp1sW31awV/few== 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=STCqHCKo; arc=none smtp.remote-ip=95.215.58.127 Received: from mta1.migadu.com (out-127.mta1.migadu.com [95.215.58.127]) (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 8D669606A32A for ; Sun, 8 Nov 2026 20:48:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D669606A32A 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=STCqHCKo X-Envelope-To: linux-scsi@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=pPiJo5YvvZwz+FSuNCP5LV5980zfLh166gCKBgUb8TU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794170899; v=1; x=1794775699; b=STCqHCKooXiP/JFm9tRgW3k2K0EZRgZUzYpfsWJ/nZhmOi1NZ+x+eFysdDpxd0X+TvipCHrv /gW4YuE/qvdJCueQetYDDEYzWfKaUaAP3QmXi/e15EnooO37axtULx7Bs0syB5feEUrZaibzjFn +62QjsWOhnbO4EDrHG2uAPaY= X-Envelope-To: linux-scsi@vger.kernel.org Received: by mta10.migadu.com with ESMTPS id 3d3bbd98ebe99174; Sun, 08 Nov 2026 20:48:19 +0000 X-Mizu-Trace-ID: 3d3bbd98ebe99174 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 20/29] scsi-multipath: provide callbacks for path state Date: Sun, 8 Nov 2026 20:47:24 +0000 Message-ID: <20261108204733.557995-21-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: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Provide callbacks for .is_disabled, .is_optimized, and .available_path. These all use scsi_device.sdev_state and scsi_device.access_state. Member scsi_device.access_state will be driven by ALUA. Currently only device handlers support this, and in future we will have core SCSI support for implicit ALUA (not relying on device handlers). Signed-off-by: John Garry --- drivers/scsi/scsi_multipath.c | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c index 4c965650c2bd..2f47c39d8293 100644 --- a/drivers/scsi/scsi_multipath.c +++ b/drivers/scsi/scsi_multipath.c @@ -298,7 +298,56 @@ static struct bio *scsi_mpath_clone_bio(struct bio *bio) return clone; } +static bool scsi_mpath_is_disabled(struct mpath_device *mpath_device) +{ + struct scsi_mpath_device *scsi_mpath_dev = + to_scsi_mpath_device(mpath_device); + struct scsi_device *sdev = scsi_mpath_dev->sdev; + unsigned char access_state = READ_ONCE(sdev->access_state) & + SCSI_ACCESS_STATE_MASK; + + if (READ_ONCE(sdev->sdev_state) != SDEV_RUNNING) + return true; + + if (access_state == SCSI_ACCESS_STATE_OPTIMAL || + access_state == SCSI_ACCESS_STATE_ACTIVE) + return false; + + return true; +} + +static bool scsi_mpath_is_optimized(struct mpath_device *mpath_device) +{ + struct scsi_mpath_device *scsi_mpath_dev = + to_scsi_mpath_device(mpath_device); + struct scsi_device *sdev = scsi_mpath_dev->sdev; + unsigned char access_state = READ_ONCE(sdev->access_state) & + SCSI_ACCESS_STATE_MASK; + + if (READ_ONCE(sdev->sdev_state) != SDEV_RUNNING) + return false; + + return access_state == SCSI_ACCESS_STATE_OPTIMAL; +} + +static bool scsi_mpath_available_path(struct mpath_device *mpath_device) +{ + struct scsi_mpath_device *scsi_mpath_dev = + to_scsi_mpath_device(mpath_device); + struct scsi_device *sdev = scsi_mpath_dev->sdev; + enum scsi_device_state sdev_state = READ_ONCE(sdev->sdev_state); + + if (sdev_state == SDEV_RUNNING || sdev_state == SDEV_QUIESCE || + sdev_state == SDEV_BLOCK || sdev_state == SDEV_CREATED_BLOCK) + return true; + + return false; +} + static struct mpath_head_template smpdt = { + .is_disabled = scsi_mpath_is_disabled, + .is_optimized = scsi_mpath_is_optimized, + .available_path = scsi_mpath_available_path, .clone_bio = scsi_mpath_clone_bio, }; -- 2.43.0