On 5/1/20 7:43 PM, Christoph Hellwig wrote:
On Thu, Apr 30, 2020 at 03:18:26PM +0200, Hannes Reinecke wrote:
Add function to check if a SCSI command originates from the reserved
tag pool and update scsi_put_reserved_cmd() to only free commands if
they originate from the reserved tag pool.
The SCSI bits should go into the previous patch. The block layer
bits should be a separate prep patch before that.
Okay.
+/**
+ * blk_mq_rq_is_reserved - Check for reserved request
+ *
+ * @rq: Request to check
No empty line before the parameter description, please.
Okay
*/
void scsi_put_reserved_cmd(struct scsi_cmnd *scmd)
{
+ struct request *rq;
+ if (scmd && scsi_cmd_is_reserved(scmd)) {
+ rq = blk_mq_rq_from_pdu(scmd);
+ blk_mq_free_request(rq);
+ }
The check looks weird. Passing a NULL cmnd here seems like an API
abuse to start with, and !scsi_cmd_is_reserved should at best be
a WARN_ON_ONCE.
So I think this should just be something like:
void scsi_put_reserved_cmd(struct scsi_cmnd *scmd)
{
WARN_ON_ONCE(!scsi_cmd_is_reserved(scmd));
blk_mq_free_request(blk_mq_rq_from_pdu(scmd));
}
Will do.
+/**
+ * scsi_cmd_is_reserved - check for reserved scsi command
+ * @scmd: command to check
+ *
+ * Returns true if @scmd originates from the reserved tag pool.
+ */
+static inline bool scsi_cmd_is_reserved(struct scsi_cmnd *scmd)
+{
+ struct request *rq = blk_mq_rq_from_pdu(scmd);
+
+ return blk_mq_rq_is_reserved(rq);
Can be shortened to:
return blk_mq_rq_is_reserved(blk_mq_rq_from_pdu(scmd));
Same here.
Will be updating the patch.
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@xxxxxxx +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer