Commit 6d7160c7 authored by Martin Wilck's avatar Martin Wilck Committed by Martin K. Petersen

scsi: core: Improve warning message in scsi_device_block()

If __scsi_internal_device_block() returns an error, it is always -EINVAL
because of an invalid state transition. For debugging purposes, it makes
more sense to print the device state.
Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
Link: https://lore.kernel.org/r/20230614103616.31857-8-mwilck@suse.comReviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 31950192
...@@ -2784,9 +2784,11 @@ EXPORT_SYMBOL_GPL(scsi_internal_device_block_nowait); ...@@ -2784,9 +2784,11 @@ EXPORT_SYMBOL_GPL(scsi_internal_device_block_nowait);
static void scsi_device_block(struct scsi_device *sdev, void *data) static void scsi_device_block(struct scsi_device *sdev, void *data)
{ {
int err; int err;
enum scsi_device_state state;
mutex_lock(&sdev->state_mutex); mutex_lock(&sdev->state_mutex);
err = __scsi_internal_device_block_nowait(sdev); err = __scsi_internal_device_block_nowait(sdev);
state = sdev->sdev_state;
if (err == 0) if (err == 0)
/* /*
* scsi_stop_queue() must be called with the state_mutex * scsi_stop_queue() must be called with the state_mutex
...@@ -2797,8 +2799,8 @@ static void scsi_device_block(struct scsi_device *sdev, void *data) ...@@ -2797,8 +2799,8 @@ static void scsi_device_block(struct scsi_device *sdev, void *data)
mutex_unlock(&sdev->state_mutex); mutex_unlock(&sdev->state_mutex);
WARN_ONCE(err, "__scsi_internal_device_block_nowait(%s) failed: err = %d\n", WARN_ONCE(err, "%s: failed to block %s in state %d\n",
dev_name(&sdev->sdev_gendev), err); __func__, dev_name(&sdev->sdev_gendev), state);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment