2015-07-06 16:13:19

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH] tcm_qla2xxx: pass timeout as HZ independent value

API compliance scanning with coccinelle flagged:
./drivers/scsi/qla2xxx/tcm_qla2xxx.c:407:2-29:
WARNING: timeout is HZ dependent

This was introduced in 'commit 75f8c1f693ee ("[SCSI] tcm_qla2xxx: Add >=
24xx series fabric module for target-core")'. wait_for_completion_timeout()
expects a timeout in jiffies so the numeric constant makes the effective
timeout HZ dependent. Resolved by converting it to CONST * HZ.

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

As the intended timeout is not documented I'm guessing that it should be
3000 milliseconds but someone that knows the driver needs to check if that
is a reasonable guess.

Further its not clear why the timeout event if it were to occure does not
produce some debug message and/or pass it up through the return value.

Patch was compile tested with x86_64_defconfig + CONFIG_SCSI_LOWLEVEL=y,
CONFIG_SCSI_FC_ATTRS=y, CONFIG_TARGET_CORE=m, CONFIG_LIBFC=m,
CONFIG_SCSI_QLA_FC=m, CONFIG_TCM_QLA2XXX=m

Patch is against 4.2-rc1 (localversion-next is -next-20150706)

drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index d9a8c60..33364b6 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -405,7 +405,7 @@ static int tcm_qla2xxx_write_pending_status(struct se_cmd *se_cmd)
se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP) {
spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
wait_for_completion_timeout(&se_cmd->t_transport_stop_comp,
- 3000);
+ 3 * HZ);
return 0;
}
spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
--
1.7.10.4


2015-07-07 01:08:15

by Nicholas A. Bellinger

[permalink] [raw]
Subject: Re: [PATCH] tcm_qla2xxx: pass timeout as HZ independent value

Hi Nicholas,

On Mon, 2015-07-06 at 18:04 +0200, Nicholas Mc Guire wrote:
> API compliance scanning with coccinelle flagged:
> ./drivers/scsi/qla2xxx/tcm_qla2xxx.c:407:2-29:
> WARNING: timeout is HZ dependent
>
> This was introduced in 'commit 75f8c1f693ee ("[SCSI] tcm_qla2xxx: Add >=
> 24xx series fabric module for target-core")'. wait_for_completion_timeout()
> expects a timeout in jiffies so the numeric constant makes the effective
> timeout HZ dependent. Resolved by converting it to CONST * HZ.
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>
> ---
>
> As the intended timeout is not documented I'm guessing that it should be
> 3000 milliseconds but someone that knows the driver needs to check if that
> is a reasonable guess.
>
> Further its not clear why the timeout event if it were to occure does not
> produce some debug message and/or pass it up through the return value.
>
> Patch was compile tested with x86_64_defconfig + CONFIG_SCSI_LOWLEVEL=y,
> CONFIG_SCSI_FC_ATTRS=y, CONFIG_TARGET_CORE=m, CONFIG_LIBFC=m,
> CONFIG_SCSI_QLA_FC=m, CONFIG_TCM_QLA2XXX=m
>
> Patch is against 4.2-rc1 (localversion-next is -next-20150706)
>
> drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index d9a8c60..33364b6 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -405,7 +405,7 @@ static int tcm_qla2xxx_write_pending_status(struct se_cmd *se_cmd)
> se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP) {
> spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
> wait_for_completion_timeout(&se_cmd->t_transport_stop_comp,
> - 3000);
> + 3 * HZ);
> return 0;
> }
> spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);

Applied to target-pending/master, and will include in the next v4.2-rc
fixes PULL request.

Thanks!

--nab