[dm-devel] [PATCH 15/18] scsi: allocate scsi_cmnd structures as part of struct request

Bart Van Assche Bart.VanAssche at sandisk.com
Fri Jan 27 18:39:46 UTC 2017


On Wed, 2017-01-25 at 18:25 +0100, Christoph Hellwig wrote:
> -unsigned char *scsi_alloc_sense_buffer(struct Scsi_Host *shost, gfp_t gfp_mask,
> -               int numa_node)
> +static unsigned char *scsi_alloc_sense_buffer(struct Scsi_Host *shost,
> +       gfp_t gfp_mask, int numa_node)
>  {
>         return kmem_cache_alloc_node(scsi_select_sense_cache(shost), gfp_mask,
>                         numa_node);
> @@ -697,14 +696,13 @@ static bool scsi_end_request(struct request *req, int error,
>  
>                 if (bidi_bytes)
>                         scsi_release_bidi_buffers(cmd);
> +               scsi_release_buffers(cmd);
> +               scsi_put_command(cmd);
>  
>                 spin_lock_irqsave(q->queue_lock, flags);
>                 blk_finish_request(req, error);
>                 spin_unlock_irqrestore(q->queue_lock, flags);
>  
> -               scsi_release_buffers(cmd);
> -
> -               scsi_put_command(cmd);
>                 scsi_run_queue(q);
>         }

Hello Christoph,

Why have the scsi_release_buffers() and scsi_put_command(cmd) calls been
moved up? I haven't found an explanation for this change in the patch
description.

Please also consider to remove the cmd->request->special = NULL assignments
via this patch. Since this patch makes the lifetime of struct scsi_cmnd and
struct request identical these assignments are no longer needed.

This patch introduces the function scsi_exit_rq(). Having two functions
for the single-queue path that release resources (scsi_release_buffers()
and scsi_exit_rq()) is confusing. Since every scsi_release_buffers() call
is followed by a blk_unprep_request() call, have you considered to move
the scsi_release_buffers() call into scsi_unprep_fn() via an additional
patch?

Thanks,

Bart.




More information about the dm-devel mailing list