@@ -1927,6 +1927,36 @@ void scsi_mq_destroy_tags(struct Scsi_Host *shost)
blk_mq_free_tag_set(&shost->tag_set);
}
+struct scsi_cmnd *scsi_get_reserved_cmd(struct Scsi_Host *shost)
+{
+ struct scsi_cmnd *scmd;
+ struct request *rq;
+
+ if (WARN_ON(!shost->reserved_cmd_q))
+ return NULL;
+
+ rq = blk_mq_alloc_request(shost->reserved_cmd_q,
+ REQ_OP_DRV_OUT | REQ_NOWAIT,
+ BLK_MQ_REQ_RESERVED);
+ if (IS_ERR(rq))
+ return NULL;
+ WARN_ON(rq->tag == -1);
+ scmd = blk_mq_rq_to_pdu(rq);
+ scmd->request = rq;
+
+ return scmd;
+}
+EXPORT_SYMBOL_GPL(scsi_get_reserved_cmd);
+
+void scsi_put_reserved_cmd(struct scsi_cmnd *scmd)
+{
+ struct request *rq = blk_mq_rq_from_pdu(scmd);
+
+ if (blk_mq_rq_is_reserved(rq))
+ blk_mq_free_request(rq);
+}
+EXPORT_SYMBOL_GPL(scsi_put_reserved_cmd);
+
/**
* scsi_device_from_queue - return sdev associated with a request_queue
* @q: The request queue to return the sdev from
@@ -159,6 +159,9 @@ static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
}
+struct scsi_cmnd *scsi_get_reserved_cmd(struct Scsi_Host *shost);
+void scsi_put_reserved_cmd(struct scsi_cmnd *);
+
extern void scsi_put_command(struct scsi_cmnd *);
extern void scsi_finish_command(struct scsi_cmnd *cmd);