[SCSI] return ENOSPC on thin provisioning failure
authorHannes Reinecke <hare@suse.de>
Mon, 1 Jul 2013 13:16:25 +0000 (15:16 +0200)
committerJames Bottomley <JBottomley@Parallels.com>
Fri, 23 Aug 2013 16:43:54 +0000 (12:43 -0400)
When the thin provisioning hard threshold is reached we
should return ENOSPC to inform upper layers about this fact.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
block/blk-core.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
include/scsi/scsi.h

index 93a18d1d3da8e43d79b4450e30211ecb59f14b2f..68ce4d53a528850642a05ec71062c1d5014d666d 100644 (file)
@@ -2318,6 +2318,9 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
                case -ETIMEDOUT:
                        error_type = "timeout";
                        break;
+               case -ENOSPC:
+                       error_type = "critical space allocation";
+                       break;
                case -EIO:
                default:
                        error_type = "I/O";
index 7be5229ed3a4025fa359c334d7a8888e54b48708..1b1298ce0e71fe67e5e26877b7ed61c191b02203 100644 (file)
@@ -354,11 +354,16 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
                return SUCCESS;
 
                /* these are not supported */
+       case DATA_PROTECT:
+               if (sshdr.asc == 0x27 && sshdr.ascq == 0x07) {
+                       /* Thin provisioning hard threshold reached */
+                       set_host_byte(scmd, DID_ALLOC_FAILURE);
+                       return SUCCESS;
+               }
        case COPY_ABORTED:
        case VOLUME_OVERFLOW:
        case MISCOMPARE:
        case BLANK_CHECK:
-       case DATA_PROTECT:
                set_host_byte(scmd, DID_TARGET_FAILURE);
                return SUCCESS;
 
index e2af8ae0d0cafd9fbc2abdd68b37cd1ddccb6097..49020d52d685d21c01ffc62fc47488c95dadebea 100644 (file)
@@ -726,6 +726,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
  * -ENOLINK    temporary transport failure
  * -EREMOTEIO  permanent target failure, do not retry
  * -EBADE      permanent nexus failure, retry on other path
+ * -ENOSPC     No write space available
  * -EIO                unspecified I/O error
  */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
@@ -744,6 +745,10 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
                set_host_byte(cmd, DID_OK);
                error = -EBADE;
                break;
+       case DID_ALLOC_FAILURE:
+               set_host_byte(cmd, DID_OK);
+               error = -ENOSPC;
+               break;
        default:
                error = -EIO;
                break;
index e4cd3e97553884180fb934f1230f56886c312f56..d0387d84dd6839f99bc91bf614db60c61902cf6c 100644 (file)
@@ -457,6 +457,7 @@ static inline int scsi_is_wlun(unsigned int lun)
                                 * other paths */
 #define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
                                 * paths might yield different results */
+#define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
 #define DRIVER_OK       0x00   /* Driver status                           */
 
 /*