Re: [PATCH 2/2] sd_zbc: Write unlock zones from sd_uninit_cmnd()

2017-08-05 Thread Christoph Hellwig
Looks fine,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 2/2] sd_zbc: Write unlock zones from sd_uninit_cmnd()

2017-08-04 Thread Bart Van Assche
On Fri, 2017-08-04 at 16:52 +0900, Damien Le Moal wrote:
> Releasing the write lock of a zone when the write commnand that
> acquired the lock completes can cause deadlocks with scsi-mq due to
> potential queue reordering if the lock owning request is requeued and
> not executed.
> 
> Since sd_uninit_cmnd() is always called when a request is requeued,
> call sd_zbc_write_unlock_zone() from that function for write requests
> that acquired a zone lock. Acquisition of a zone lock by a write command
> is indicated using the new command flag SCMD_ZONE_WRITE_LOCK.
> 
> Signed-off-by: Damien Le Moal 

Hello Damien,

Should "Cc: " be added to this patch?

> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 96855df9f49d..6423ae70477e 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -294,6 +294,9 @@ int sd_zbc_write_lock_zone(struct scsi_cmnd *cmd)
>   test_and_set_bit(zno, sdkp->zones_wlock))
>   return BLKPREP_DEFER;
>  
> + WARN_ON(cmd->flags & SCMD_ZONE_WRITE_LOCK);
> + cmd->flags |= SCMD_ZONE_WRITE_LOCK;
> +
>   return BLKPREP_OK;
>  }

Did you perhaps intend WARN_ON_ONCE() instead of WARN_ON()?

Thanks,

Bart.