From: Bodo Stroesser <bostroesser@gmail.com>
To: Guixin Liu <kanie@linux.alibaba.com>, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH] scsi: target: tcmu: check cmd aborted earlier
Date: Mon, 11 Jul 2022 12:33:09 +0200 [thread overview]
Message-ID: <bc4d910a-216a-76ea-4141-3d7562db7d8c@gmail.com> (raw)
In-Reply-To: <1657251175-116098-1-git-send-email-kanie@linux.alibaba.com>
Hi Liu,
to be honest I don't like this change.
Why do we check CMD_T_ABORTED here? It's just because a concurrently
incoming TMR might already have aborted the cmd, and we don't want to
queue up aborted cmds in tcmu.
But that means, we better check CMD_T_ABORTED after taking cmdr_lock,
because we might sleep a while waiting for the lock, which opens a
possibly long time frame for new TMRs.
So, I'd prefer to have the overhead of alloc/free over not catching
aborted cmds, which causes even more overhead.
Bodo
On 08.07.22 05:32, Guixin Liu wrote:
> Lift the check of cmd aborted to the head of tcmu_queue_cmd(), which
> avoids pointless tcmu_cmd allocation if the cmd is already aborted.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
> drivers/target/target_core_user.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 3deaeec..c1c1d2f 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1204,16 +1204,18 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
> struct se_device *se_dev = se_cmd->se_dev;
> struct tcmu_dev *udev = TCMU_DEV(se_dev);
> struct tcmu_cmd *tcmu_cmd;
> - sense_reason_t scsi_ret = TCM_CHECK_CONDITION_ABORT_CMD;
> - int ret = -1;
> + sense_reason_t scsi_ret;
> + int ret;
> +
> + if (se_cmd->transport_state & CMD_T_ABORTED)
> + return TCM_CHECK_CONDITION_ABORT_CMD;
>
> tcmu_cmd = tcmu_alloc_cmd(se_cmd);
> if (!tcmu_cmd)
> return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
>
> mutex_lock(&udev->cmdr_lock);
> - if (!(se_cmd->transport_state & CMD_T_ABORTED))
> - ret = queue_cmd_ring(tcmu_cmd, &scsi_ret);
> + ret = queue_cmd_ring(tcmu_cmd, &scsi_ret);
> if (ret < 0)
> tcmu_free_cmd(tcmu_cmd);
> else
prev parent reply other threads:[~2022-07-11 11:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 3:32 [PATCH] scsi: target: tcmu: check cmd aborted earlier Guixin Liu
2022-07-11 10:33 ` Bodo Stroesser [this message]
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=bc4d910a-216a-76ea-4141-3d7562db7d8c@gmail.com \
--to=bostroesser@gmail.com \
--cc=kanie@linux.alibaba.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.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