From: John Garry <john.g.garry@oracle.com>
To: Benjamin Marzinski <bmarzins@redhat.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 12/13] scsi: scsi_dh_alua: Switch to use core support
Date: Mon, 23 Mar 2026 11:59:22 +0000 [thread overview]
Message-ID: <cdb891d6-3f5f-4bcc-8d91-fb46dbd1fe55@oracle.com> (raw)
In-Reply-To: <acCbsAISEJC2VfwO@redhat.com>
On 23/03/2026 01:47, Benjamin Marzinski wrote:
>> static void alua_rtpg_work(struct work_struct *work)
>> {
>> struct alua_dh_data *h =
>> @@ -670,56 +179,41 @@ static void alua_rtpg_work(struct work_struct *work)
>> int err = SCSI_DH_OK;
>> struct alua_queue_data *qdata, *tmp;
>> unsigned long flags;
>> + int ret;
>>
>> spin_lock_irqsave(&h->lock, flags);
>> h->flags |= ALUA_PG_RUNNING;
>> if (h->flags & ALUA_PG_RUN_RTPG) {
>> - int state = h->state;
>>
>> 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(&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);
>> - spin_lock_irqsave(&h->lock, flags);
>> -
>> - if (err == SCSI_DH_RETRY || h->flags & ALUA_PG_RUN_RTPG) {
>> + ret = scsi_alua_rtpg_run(sdev);
>> + if (ret == -EAGAIN) {
> This no longer handles the case where you want to trigger a new rtpg as
> soon as the running one finishes. I think it should be checking
> (ret == -EAGAIN || h->flags & ALUA_PG_RUN_RTPG)
> with a spinlock held.
>
Yeah, this is all tricky to handle, as the code in scsi_dh_alua.c was
handling the error codes with the state machine, and I want to move the
error handling into the core driver.
As for your specific point, I think that ALUA_PG_RUN_RTPG can only now
be set from outside this work handler, and that should also trigger the
work (so the check on ALUA_PG_RUN_RTPG was not really required). But, I
think that I can just have as before (with the h->flags &
ALUA_PG_RUN_RTPG check)
>> + spin_lock_irqsave(&h->lock, flags);
>> h->flags &= ~ALUA_PG_RUNNING;
>> - if (err == SCSI_DH_IMM_RETRY)
>> - h->interval = 0;
>> - else if (!h->interval && !(h->flags & ALUA_PG_RUN_RTPG))
>> - h->interval = ALUA_RTPG_RETRY_DELAY;
>> h->flags |= ALUA_PG_RUN_RTPG;
>> spin_unlock_irqrestore(&h->lock, flags);
>> - goto queue_rtpg;
>> + queue_delayed_work(kaluad_wq, &h->rtpg_work,
>> + sdev->alua->interval * HZ);
>> + return;
>> }
>> - if (err != SCSI_DH_OK)
>> - h->flags &= ~ALUA_PG_RUN_STPG;
>> + if (err != 0)
>> + h->flags &= ~ALUA_PG_RUN_STPG;
>> }
>> + spin_lock_irqsave(&h->lock, flags);
> If h->flags & ALUA_PG_RUN_RTPG is false above, h->lock will already be
> locked.
>
Right, that is a bug
>> if (h->flags & ALUA_PG_RUN_STPG) {
>> h->flags &= ~ALUA_PG_RUN_STPG;
>> spin_unlock_irqrestore(&h->lock, flags);
>> - err = alua_stpg(sdev);
>> - spin_lock_irqsave(&h->lock, flags);
>> - if (err == SCSI_DH_RETRY || h->flags & ALUA_PG_RUN_RTPG) {
>> + ret = scsi_alua_stpg_run(sdev, h->flags & ALUA_OPTIMIZE_STPG);
>> + if (err == -EAGAIN || h->flags & ALUA_PG_RUN_RTPG) {
> To avoid a race with resetting ALUA_PG_RUN_RTPG, this check needs to be
> done with the spinlock held.
Yes,
Thanks,
John
next prev parent reply other threads:[~2026-03-23 11:59 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
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 [this message]
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=cdb891d6-3f5f-4bcc-8d91-fb46dbd1fe55@oracle.com \
--to=john.g.garry@oracle.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=hare@suse.com \
--cc=james.bottomley@hansenpartnership.com \
--cc=jmeneghi@redhat.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
Powered by JetHome