Patch "scsi: core: Introduce the scsi_cmd_to_rq() function" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: core: Introduce the scsi_cmd_to_rq() function

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-core-introduce-the-scsi_cmd_to_rq-function.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d0f346c9e21dbd4dc404d9a10e313ed95318386a
Author: Bart Van Assche <bvanassche@xxxxxxx>
Date:   Mon Aug 9 16:03:04 2021 -0700

    scsi: core: Introduce the scsi_cmd_to_rq() function
    
    [ Upstream commit 51f3a478892873337c54068d1185bcd797000a52 ]
    
    The 'request' member of struct scsi_cmnd is superfluous. The struct request
    and struct scsi_cmnd data structures are adjacent and hence the request
    pointer can be derived easily from a scsi_cmnd pointer. Introduce a helper
    function that performs that conversion in a type-safe way. This patch is
    the first step towards removing the request member from struct
    scsi_cmnd. Making that change has the following advantages:
    
     - This is a performance optimization since adding an offset to a pointer
       takes less time than dereferencing a pointer.
    
     - struct scsi_cmnd becomes smaller.
    
    Link: https://lore.kernel.org/r/20210809230355.8186-2-bvanassche@xxxxxxx
    Cc: Christoph Hellwig <hch@xxxxxx>
    Cc: Hannes Reinecke <hare@xxxxxxx>
    Cc: Ming Lei <ming.lei@xxxxxxxxxx>
    Reviewed-by: Hannes Reinecke <hare@xxxxxxx>
    Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Stable-dep-of: 19597cad64d6 ("scsi: qla2xxx: Fix system crash due to bad pointer access")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 7738a055d9535..dafde3d764d03 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -143,6 +143,12 @@ struct scsi_cmnd {
 	unsigned char tag;	/* SCSI-II queued command tag */
 };
 
+/* Variant of blk_mq_rq_from_pdu() that verifies the type of its argument. */
+static inline struct request *scsi_cmd_to_rq(struct scsi_cmnd *scmd)
+{
+	return blk_mq_rq_from_pdu(scmd);
+}
+
 /*
  * Return the driver private allocation behind the command.
  * Only works if cmd_size is set in the host template.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux