]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: core: Make the budget map optional
authorBart Van Assche <bvanassche@acm.org>
Fri, 31 Oct 2025 20:39:11 +0000 (13:39 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 12 Nov 2025 22:02:31 +0000 (17:02 -0500)
Prepare for not allocating a budget map for pseudo SCSI devices by
checking whether a budget map has been allocated before using it.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251031204029.2883185-4-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c

index 9a0f467264b35f8e97edca8644723ae19cf400b7..589ae28b2c8b3fbf9c0ba1f731a7cd8672277b5c 100644 (file)
@@ -216,6 +216,9 @@ int scsi_device_max_queue_depth(struct scsi_device *sdev)
  */
 int scsi_change_queue_depth(struct scsi_device *sdev, int depth)
 {
+       if (!sdev->budget_map.map)
+               return -EINVAL;
+
        depth = min_t(int, depth, scsi_device_max_queue_depth(sdev));
 
        if (depth > 0) {
@@ -255,6 +258,8 @@ EXPORT_SYMBOL(scsi_change_queue_depth);
  */
 int scsi_track_queue_full(struct scsi_device *sdev, int depth)
 {
+       if (!sdev->budget_map.map)
+               return 0;
 
        /*
         * Don't let QUEUE_FULLs on the same
index 746ff6a1f309a33bc50e44cc8cea198f7b734fea..87636068cd37c8b1e72ace26808d58cb08af7bcd 100644 (file)
@@ -749,6 +749,9 @@ static void scsi_handle_queue_ramp_up(struct scsi_device *sdev)
        const struct scsi_host_template *sht = sdev->host->hostt;
        struct scsi_device *tmp_sdev;
 
+       if (!sdev->budget_map.map)
+               return;
+
        if (!sht->track_queue_depth ||
            sdev->queue_depth >= sdev->max_queue_depth)
                return;
index d52bbbe5a357b7a49eaafab99bf675a2cee9e0ac..53ff348b3a4c0afcfc58af520c9f40c8fb162b72 100644 (file)
@@ -396,7 +396,8 @@ void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd)
        if (starget->can_queue > 0)
                atomic_dec(&starget->target_busy);
 
-       sbitmap_put(&sdev->budget_map, cmd->budget_token);
+       if (sdev->budget_map.map)
+               sbitmap_put(&sdev->budget_map, cmd->budget_token);
        cmd->budget_token = -1;
 }
 
@@ -1360,6 +1361,9 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
 {
        int token;
 
+       if (!sdev->budget_map.map)
+               return INT_MAX;
+
        token = sbitmap_get(&sdev->budget_map);
        if (token < 0)
                return -1;
@@ -1749,7 +1753,8 @@ static void scsi_mq_put_budget(struct request_queue *q, int budget_token)
 {
        struct scsi_device *sdev = q->queuedata;
 
-       sbitmap_put(&sdev->budget_map, budget_token);
+       if (sdev->budget_map.map)
+               sbitmap_put(&sdev->budget_map, budget_token);
 }
 
 /*