From 26cf591e6dfc0d07495b7bcf20a557b316811f00 Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Sat, 18 Oct 2014 22:11:21 +0200 Subject: scsi: add SG_SCSI_RESET_NO_ESCALATE flag to SG_SCSI_RESET ioctl Further to a January 2013 thread titled: "[PATCH] SG_SCSI_RESET ioctl should only perform requested operation" by Jeremy Linton a patch (v3) is presented that expands the existing ioctl to include "no_escalate" versions to the existing resets. This requires no changes to SCSI low level drivers (LLDs); it adds several more finely tuned reset options to the user space. For example: /* This call remains the same, with the same escalating semantics * if the device (LU) reset fail. That is: on failure to try a * target reset and if that fails, try a bus reset, and if that fails * try a host (i.e. LLD) reset. */ val = SG_SCSI_RESET_DEVICE; res = ioctl(, SG_SCSI_RESET, &val); /* What follows is a new option introduced by this patch series. Only * a device reset is attempted. If that fails then an appropriate * error code is provided. N.B. There is no reset escalation. */ val = SG_SCSI_RESET_DEVICE | SG_SCSI_RESET_NO_ESCALATE; res = ioctl(, SG_SCSI_RESET, &val); Signed-off-by: Douglas Gilbert Reviewed-by: Jeremy Linton Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_error.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/scsi/scsi_error.c') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index bc5ff6ff9c79..0ed666112b4f 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2366,8 +2366,18 @@ scsi_reset_provider(struct scsi_device *dev, int flag) break; /* FALLTHROUGH */ case SCSI_TRY_RESET_HOST: + case SCSI_TRY_RESET_HOST | SCSI_TRY_RESET_NO_ESCALATE: rtn = scsi_try_host_reset(scmd); break; + case SCSI_TRY_RESET_DEVICE | SCSI_TRY_RESET_NO_ESCALATE: + rtn = scsi_try_bus_device_reset(scmd); + break; + case SCSI_TRY_RESET_TARGET | SCSI_TRY_RESET_NO_ESCALATE: + rtn = scsi_try_target_reset(scmd); + break; + case SCSI_TRY_RESET_BUS | SCSI_TRY_RESET_NO_ESCALATE: + rtn = scsi_try_bus_reset(scmd); + break; default: rtn = FAILED; } -- cgit v1.2.3-70-g09d2