On 3/18/19 5:29 PM, Bart Van Assche wrote:
cmd->rcu is initialized by scsi_initialize_rq(). For passthrough
requests, blk_get_request() calls scsi_initialize_rq(). For filesystem
requests, scsi_init_command() calls scsi_initialize_rq(). Make sure
that destroy_rcu_head() is called for passthrough requests.

Cc: Christoph Hellwig <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Cc: Ewan D. Milne <[email protected]>
Cc: Johannes Thumshirn <[email protected]>
Reported-by: Ewan D. Milne <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
---
  drivers/scsi/scsi_lib.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 33e1a72d47fa..ed4314f8542e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -585,9 +585,16 @@ static bool scsi_end_request(struct request *req, 
blk_status_t error,
        if (!blk_rq_is_scsi(req)) {
                WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED));
                cmd->flags &= ~SCMD_INITIALIZED;
-               destroy_rcu_head(&cmd->rcu);
        }
+ /*
+        * Calling rcu_barrier() is not necessary here because the
+        * SCSI error handler guarantees that the function called by
+        * call_rcu() has been called before scsi_end_request() is
+        * called.
+        */
+       destroy_rcu_head(&cmd->rcu);
+
        /*
         * In the MQ case the command gets freed by __blk_mq_end_request,
         * so we have to do all cleanup that depends on it earlier.

Reviewed-by: Hannes Reinecke <[email protected]>

Cheers,

Hannes
--
Dr. Hannes Reinecke                            zSeries & Storage
[email protected]                                  +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

Reply via email to