Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: core: Make the budget map optional

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>

authored by

Bart Van Assche and committed by
Martin K. Petersen
a47c7bef 21008cab

+15 -2
+5
drivers/scsi/scsi.c
··· 216 216 */ 217 217 int scsi_change_queue_depth(struct scsi_device *sdev, int depth) 218 218 { 219 + if (!sdev->budget_map.map) 220 + return -EINVAL; 221 + 219 222 depth = min_t(int, depth, scsi_device_max_queue_depth(sdev)); 220 223 221 224 if (depth > 0) { ··· 258 255 */ 259 256 int scsi_track_queue_full(struct scsi_device *sdev, int depth) 260 257 { 258 + if (!sdev->budget_map.map) 259 + return 0; 261 260 262 261 /* 263 262 * Don't let QUEUE_FULLs on the same
+3
drivers/scsi/scsi_error.c
··· 749 749 const struct scsi_host_template *sht = sdev->host->hostt; 750 750 struct scsi_device *tmp_sdev; 751 751 752 + if (!sdev->budget_map.map) 753 + return; 754 + 752 755 if (!sht->track_queue_depth || 753 756 sdev->queue_depth >= sdev->max_queue_depth) 754 757 return;
+7 -2
drivers/scsi/scsi_lib.c
··· 396 396 if (starget->can_queue > 0) 397 397 atomic_dec(&starget->target_busy); 398 398 399 - sbitmap_put(&sdev->budget_map, cmd->budget_token); 399 + if (sdev->budget_map.map) 400 + sbitmap_put(&sdev->budget_map, cmd->budget_token); 400 401 cmd->budget_token = -1; 401 402 } 402 403 ··· 1361 1360 { 1362 1361 int token; 1363 1362 1363 + if (!sdev->budget_map.map) 1364 + return INT_MAX; 1365 + 1364 1366 token = sbitmap_get(&sdev->budget_map); 1365 1367 if (token < 0) 1366 1368 return -1; ··· 1753 1749 { 1754 1750 struct scsi_device *sdev = q->queuedata; 1755 1751 1756 - sbitmap_put(&sdev->budget_map, budget_token); 1752 + if (sdev->budget_map.map) 1753 + sbitmap_put(&sdev->budget_map, budget_token); 1757 1754 } 1758 1755 1759 1756 /*