Skip to content

Commit 3dc985b

Browse files
wenchao-haomartinkpetersen
authored andcommitted
scsi: core: Clean up scsi_dev_queue_ready()
This is just a cleanup for scsi_dev_queue_ready() to avoid a redundant goto and if statement. No functional change. Signed-off-by: Wenchao Hao <haowenchao2@huawei.com> Link: https://lore.kernel.org/r/20231018113746.1940197-2-haowenchao2@huawei.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 0b1b4b0 commit 3dc985b

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,28 +1251,26 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
12511251
int token;
12521252

12531253
token = sbitmap_get(&sdev->budget_map);
1254-
if (atomic_read(&sdev->device_blocked)) {
1255-
if (token < 0)
1256-
goto out;
1254+
if (token < 0)
1255+
return -1;
12571256

1258-
if (scsi_device_busy(sdev) > 1)
1259-
goto out_dec;
1257+
if (!atomic_read(&sdev->device_blocked))
1258+
return token;
12601259

1261-
/*
1262-
* unblock after device_blocked iterates to zero
1263-
*/
1264-
if (atomic_dec_return(&sdev->device_blocked) > 0)
1265-
goto out_dec;
1266-
SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev,
1267-
"unblocking device at zero depth\n"));
1260+
/*
1261+
* Only unblock if no other commands are pending and
1262+
* if device_blocked has decreased to zero
1263+
*/
1264+
if (scsi_device_busy(sdev) > 1 ||
1265+
atomic_dec_return(&sdev->device_blocked) > 0) {
1266+
sbitmap_put(&sdev->budget_map, token);
1267+
return -1;
12681268
}
12691269

1270+
SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev,
1271+
"unblocking device at zero depth\n"));
1272+
12701273
return token;
1271-
out_dec:
1272-
if (token >= 0)
1273-
sbitmap_put(&sdev->budget_map, token);
1274-
out:
1275-
return -1;
12761274
}
12771275

12781276
/*

0 commit comments

Comments
 (0)