public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: John Garry <john.g.garry@oracle.com>
Cc: martin.petersen@oracle.com,
	james.bottomley@hansenpartnership.com, hare@suse.com,
	jmeneghi@redhat.com, linux-scsi@vger.kernel.org,
	michael.christie@oracle.com, snitzer@kernel.org,
	dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/13] scsi: scsi_dh_alua: Delete alua_port_group
Date: Mon, 23 Mar 2026 12:15:10 -0400	[thread overview]
Message-ID: <acFnDlO6b4SzFq90@redhat.com> (raw)
In-Reply-To: <470edb84-1621-41e4-b172-91f9388a813b@oracle.com>

On Mon, Mar 23, 2026 at 10:33:12AM +0000, John Garry wrote:
> On 23/03/2026 00:08, Benjamin Marzinski wrote:
> > >       k += off, desc += off) {
> > > -		u16 group_id = get_unaligned_be16(&desc[2]);
> > > -
> > > -		spin_lock_irqsave(&port_group_lock, flags);
> > > -		tmp_pg = alua_find_get_pg(pg->device_id_str, pg->device_id_len,
> > > -					  group_id);
> > > -		spin_unlock_irqrestore(&port_group_lock, flags);
> > > -		if (tmp_pg) {
> > > -			if (spin_trylock_irqsave(&tmp_pg->lock, flags)) {
> > > -				if ((tmp_pg == pg) ||
> > > -				    !(tmp_pg->flags & ALUA_PG_RUNNING)) {
> > > -					struct alua_dh_data *h;
> > > -
> > > -					tmp_pg->state = desc[0] & 0x0f;
> > > -					tmp_pg->pref = desc[0] >> 7;
> > > -					rcu_read_lock();
> > > -					list_for_each_entry_rcu(h,
> > > -						&tmp_pg->dh_list, node) {
> > > -						if (!h->sdev)
> > > -							continue;
> > > -						h->sdev->access_state = desc[0];
> > > -					}
> > > -					rcu_read_unlock();
> > > -				}
> > > -				if (tmp_pg == pg)
> > > -					tmp_pg->valid_states = desc[1];
> > > -				spin_unlock_irqrestore(&tmp_pg->lock, flags);
> > > -			}
> > > -			kref_put(&tmp_pg->kref, release_port_group);
> > > +		u16 group_id_desc = get_unaligned_be16(&desc[2]);
> > > +
> > > +		spin_lock_irqsave(&h->lock, flags);
> > > +		if (group_id_desc == group_id) {
> > > +			h->group_id = group_id;
> > > +			WRITE_ONCE(h->state, desc[0] & 0x0f);
> > > +			h->pref = desc[0] >> 7;
> > > +			WRITE_ONCE(sdev->access_state, desc[0]);
> > > +			h->valid_states = desc[1];
> > instead of alua_rtpg() updating the access_state all of the devices in
> > all the port groups, and the state and pref of all the port groups. It
> > now just sets these for one device. It seems like it's wasting a lot of
> > information that it used to use. For instance, now when a scsi command
> > returns a unit attention that the ALUA state has changed, it won't get
> > updated on all the devices, just the one that got the unit attention.
> 
> The fabric should then trigger this PG info update be re-scanned
> per-path/sdev (and not just a single sdev in the PG). From testing with a
> linux target, this is what happens - a UA is triggered per path when I
> changed the PG access state.
> 
> > 
> > >   		}
> > > +		spin_unlock_irqrestore(&h->lock, flags);
> > >   		off = 8 + (desc[7] * 4);
> > >   	}
> > >    skip_rtpg:
> > > -	spin_lock_irqsave(&pg->lock, flags);
> > > +	spin_lock_irqsave(&h->lock, flags);
> > >   	if (transitioning_sense)
> > > -		pg->state = SCSI_ACCESS_STATE_TRANSITIONING;
> > > +		h->state = SCSI_ACCESS_STATE_TRANSITIONING;
> 
> ...
> 
> > > -
> > >   static void alua_rtpg_work(struct work_struct *work)
> > >   {
> > > -	struct alua_port_group *pg =
> > > -		container_of(work, struct alua_port_group, rtpg_work.work);
> > > -	struct scsi_device *sdev, *prev_sdev = NULL;
> > > +	struct alua_dh_data *h =
> > > +		container_of(work, struct alua_dh_data, rtpg_work.work);
> > > +	struct scsi_device *sdev = h->sdev;
> > >   	LIST_HEAD(qdata_list);
> > >   	int err = SCSI_DH_OK;
> > >   	struct alua_queue_data *qdata, *tmp;
> > > -	struct alua_dh_data *h;
> > >   	unsigned long flags;
> > > -	spin_lock_irqsave(&pg->lock, flags);
> > > -	sdev = pg->rtpg_sdev;
> > > -	if (!sdev) {
> > > -		WARN_ON(pg->flags & ALUA_PG_RUN_RTPG);
> > > -		WARN_ON(pg->flags & ALUA_PG_RUN_STPG);
> > > -		spin_unlock_irqrestore(&pg->lock, flags);
> > > -		kref_put(&pg->kref, release_port_group);
> > > -		return;
> > > -	}
> > > -	pg->flags |= ALUA_PG_RUNNING;
> > > -	if (pg->flags & ALUA_PG_RUN_RTPG) {
> > > -		int state = pg->state;
> > > +	spin_lock_irqsave(&h->lock, flags);
> > > +	h->flags |= ALUA_PG_RUNNING;
> > > +	if (h->flags & ALUA_PG_RUN_RTPG) {
> > > +		int state = h->state;
> > > -		pg->flags &= ~ALUA_PG_RUN_RTPG;
> > > -		spin_unlock_irqrestore(&pg->lock, flags);
> > > +		h->flags &= ~ALUA_PG_RUN_RTPG;
> > > +		spin_unlock_irqrestore(&h->lock, flags);
> > >   		if (state == SCSI_ACCESS_STATE_TRANSITIONING) {
> > >   			if (alua_tur(sdev) == SCSI_DH_RETRY) {
> > > -				spin_lock_irqsave(&pg->lock, flags);
> > > -				pg->flags &= ~ALUA_PG_RUNNING;
> > > -				pg->flags |= ALUA_PG_RUN_RTPG;
> > > -				if (!pg->interval)
> > > -					pg->interval = ALUA_RTPG_RETRY_DELAY;
> > > -				spin_unlock_irqrestore(&pg->lock, flags);
> > > -				queue_delayed_work(kaluad_wq, &pg->rtpg_work,
> > > -						   pg->interval * HZ);
> > > +				spin_lock_irqsave(&h->lock, flags);
> > > +				h->flags &= ~ALUA_PG_RUNNING;
> > > +				h->flags |= ALUA_PG_RUN_RTPG;
> > > +				if (!h->interval)
> > > +					h->interval = ALUA_RTPG_RETRY_DELAY;
> > > +				spin_unlock_irqrestore(&h->lock, flags);
> > > +				queue_delayed_work(kaluad_wq, &h->rtpg_work,
> > > +						   h->interval * HZ);
> > >   				return;
> > >   			}
> > >   			/* Send RTPG on failure or if TUR indicates SUCCESS */
> > >   		}
> > > -		err = alua_rtpg(sdev, pg);
> > > -		spin_lock_irqsave(&pg->lock, flags);
> > > +		err = alua_rtpg(sdev);
> > > +		spin_lock_irqsave(&h->lock, flags);
> > > -		/* If RTPG failed on the current device, try using another */
> > > -		if (err == SCSI_DH_RES_TEMP_UNAVAIL &&
> > > -		    (prev_sdev = alua_rtpg_select_sdev(pg)))
> > > -			err = SCSI_DH_IMM_RETRY;
> > Previously, if the rtpg failed on a device, another device would be
> > tried, and the unusable device's alua state would get updated, along
> > with all the other device's states.
> 
> Where specifically are you referring to here please?

The removed code above here calls alua_rtpg_select_sdev() to select a
new device to retry the rtpg on, and returns with SCSI_DH_IMM_RETRY, to
retrigger the rtpg on that device. If the rtpg completed on any device,
it would update the state on all the devices. But if we are depending
each device issuing its own rtp to update its state, what happens to
the devices that can't complete the rtpg? I assume the correct answer is
to give them some failed state.
 
-Ben

> > Now I don't see how a failed device
> > gets its state updated.
> 
> AFAICS, I am only not omitted how we iterate through the devices per-PG, as
> now we just do this work for all paths/scsi devices.
> 
> Thanks,
> John


  reply	other threads:[~2026-03-23 16:15 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 12:06 [PATCH 00/13] scsi: Core ALUA driver John Garry
2026-03-17 12:06 ` [PATCH 01/13] scsi: scsi_dh_alua: Delete alua_port_group John Garry
2026-03-18  7:44   ` Hannes Reinecke
2026-03-18  8:53     ` John Garry
2026-03-23  0:08   ` Benjamin Marzinski
2026-03-23 10:33     ` John Garry
2026-03-23 16:15       ` Benjamin Marzinski [this message]
2026-03-23 18:07         ` John Garry
2026-03-17 12:06 ` [PATCH 02/13] scsi: alua: Create a core ALUA driver John Garry
2026-03-18  7:47   ` Hannes Reinecke
2026-03-23 12:56     ` John Garry
2026-03-18 17:17   ` kernel test robot
2026-03-18 22:54   ` kernel test robot
2026-03-17 12:06 ` [PATCH 03/13] scsi: alua: Add scsi_alua_rtpg() John Garry
2026-03-18  7:50   ` Hannes Reinecke
2026-03-23 12:58     ` John Garry
2026-03-17 12:06 ` [PATCH 04/13] scsi: alua: Add scsi_alua_stpg() John Garry
2026-03-18  7:53   ` Hannes Reinecke
2026-03-17 12:06 ` [PATCH 05/13] scsi: alua: Add scsi_alua_tur() John Garry
2026-03-18  7:54   ` Hannes Reinecke
2026-03-23 13:42     ` John Garry
2026-03-24 10:49       ` John Garry
2026-03-17 12:06 ` [PATCH 06/13] scsi: alua: Add scsi_alua_rtpg_run() John Garry
2026-03-17 12:06 ` [PATCH 07/13] scsi: alua: Add scsi_alua_stpg_run() John Garry
2026-03-18  7:57   ` Hannes Reinecke
2026-03-18  8:59     ` John Garry
2026-03-18  9:24       ` Hannes Reinecke
2026-03-23 13:58         ` John Garry
2026-03-17 12:06 ` [PATCH 08/13] scsi: alua: Add scsi_alua_check_tpgs() John Garry
2026-03-18  7:57   ` Hannes Reinecke
2026-03-17 12:06 ` [PATCH 09/13] scsi: alua: Add scsi_alua_handle_state_transition() John Garry
2026-03-18  7:58   ` Hannes Reinecke
2026-03-23 13:43     ` John Garry
2026-03-17 12:07 ` [PATCH 10/13] scsi: alua: Add scsi_alua_prep_fn() John Garry
2026-03-18  8:01   ` Hannes Reinecke
2026-03-23 13:49     ` John Garry
2026-03-17 12:07 ` [PATCH 11/13] scsi: alua: Add scsi_device_alua_implicit() John Garry
2026-03-18  8:02   ` Hannes Reinecke
2026-03-23 13:50     ` John Garry
2026-03-17 12:07 ` [PATCH 12/13] scsi: scsi_dh_alua: Switch to use core support John Garry
2026-03-23  1:47   ` Benjamin Marzinski
2026-03-23 11:59     ` John Garry
2026-03-17 12:07 ` [PATCH 13/13] scsi: core: Add implicit ALUA support John Garry
2026-03-18  8:08   ` Hannes Reinecke
2026-03-18 23:08   ` kernel test robot
2026-03-23  1:58   ` Benjamin Marzinski
2026-03-23 12:52     ` John Garry
2026-03-23 17:29       ` Benjamin Marzinski
2026-03-23 18:13         ` John Garry
2026-03-22 17:37 ` [PATCH 00/13] scsi: Core ALUA driver Benjamin Marzinski
2026-03-23  9:57   ` John Garry
2026-03-23 16:25     ` Benjamin Marzinski
2026-03-23 18:04       ` John Garry
2026-03-23 19:45         ` Benjamin Marzinski
2026-03-24 10:57           ` John Garry
2026-03-24 13:58             ` Benjamin Marzinski
2026-03-24 15:12               ` John Garry
2026-03-24 15:48                 ` Benjamin Marzinski
2026-03-24 16:25                   ` John Garry
2026-03-26 10:19                 ` Hannes Reinecke
2026-03-26 12:16                   ` John Garry
2026-03-27  7:02                     ` Hannes Reinecke
2026-03-26 10:17               ` Hannes Reinecke

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=acFnDlO6b4SzFq90@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.com \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=jmeneghi@redhat.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=snitzer@kernel.org \
    /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