Skip to content

Commit

Permalink
[SCSI] return ENOSPC on thin provisioning failure
Browse files Browse the repository at this point in the history
When the thin provisioning hard threshold is reached we
should return ENOSPC to inform upper layers about this fact.

Signed-off-by: Hannes Reinecke <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
hreinecke authored and James Bottomley committed Aug 23, 2013
1 parent 87f14e6 commit a9d6ceb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 6 additions & 1 deletion drivers/scsi/scsi_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/scsi/scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/*
Expand Down

0 comments on commit a9d6ceb

Please sign in to comment.