Skip to content

Commit a9d6ceb

Browse files
hreineckeJames Bottomley
authored andcommitted
[SCSI] return ENOSPC on thin provisioning failure
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>
1 parent 87f14e6 commit a9d6ceb

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎block/blk-core.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,6 +2318,9 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
23182318
case -ETIMEDOUT:
23192319
error_type = "timeout";
23202320
break;
2321+
case -ENOSPC:
2322+
error_type = "critical space allocation";
2323+
break;
23212324
case -EIO:
23222325
default:
23232326
error_type = "I/O";

‎drivers/scsi/scsi_error.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,16 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
354354
return SUCCESS;
355355

356356
/* these are not supported */
357+
case DATA_PROTECT:
358+
if (sshdr.asc == 0x27 && sshdr.ascq == 0x07) {
359+
/* Thin provisioning hard threshold reached */
360+
set_host_byte(scmd, DID_ALLOC_FAILURE);
361+
return SUCCESS;
362+
}
357363
case COPY_ABORTED:
358364
case VOLUME_OVERFLOW:
359365
case MISCOMPARE:
360366
case BLANK_CHECK:
361-
case DATA_PROTECT:
362367
set_host_byte(scmd, DID_TARGET_FAILURE);
363368
return SUCCESS;
364369

‎drivers/scsi/scsi_lib.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
726726
* -ENOLINK temporary transport failure
727727
* -EREMOTEIO permanent target failure, do not retry
728728
* -EBADE permanent nexus failure, retry on other path
729+
* -ENOSPC No write space available
729730
* -EIO unspecified I/O error
730731
*/
731732
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)
744745
set_host_byte(cmd, DID_OK);
745746
error = -EBADE;
746747
break;
748+
case DID_ALLOC_FAILURE:
749+
set_host_byte(cmd, DID_OK);
750+
error = -ENOSPC;
751+
break;
747752
default:
748753
error = -EIO;
749754
break;

‎include/scsi/scsi.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ static inline int scsi_is_wlun(unsigned int lun)
457457
* other paths */
458458
#define DID_NEXUS_FAILURE 0x11 /* Permanent nexus failure, retry on other
459459
* paths might yield different results */
460+
#define DID_ALLOC_FAILURE 0x12 /* Space allocation on the device failed */
460461
#define DRIVER_OK 0x00 /* Driver status */
461462

462463
/*

0 commit comments

Comments
 (0)