Date: Wed, 29 Oct 2014 03:14:30 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273809 - in head/sys/cam: ctl scsi Message-ID: <201410290314.s9T3EUFT050781@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Wed Oct 29 03:14:29 2014 New Revision: 273809 URL: https://svnweb.freebsd.org/changeset/base/273809 Log: Implement better handling for ENOSPC error for both CTL and CAM. This makes VMWare VAAI Thin Provisioning Stun primitive activate, pausing the virtual machine, when backing storage (ZFS pool) is getting overflowed. MFC after: 1 week Sponsored by: iXsystems, Inc. Modified: head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_error.h head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Wed Oct 29 02:23:50 2014 (r273808) +++ head/sys/cam/ctl/ctl_backend_block.c Wed Oct 29 03:14:29 2014 (r273809) @@ -501,6 +501,8 @@ ctl_be_block_biodone(struct bio *bio) if (beio->num_errors > 0) { if (error == EOPNOTSUPP) { ctl_set_invalid_opcode(&io->scsiio); + } else if (error == ENOSPC) { + ctl_set_space_alloc_fail(&io->scsiio); } else if (beio->bio_cmd == BIO_FLUSH) { /* XXX KDM is there is a better error here? */ ctl_set_internal_failure(&io->scsiio, @@ -711,14 +713,12 @@ ctl_be_block_dispatch_file(struct ctl_be char path_str[32]; ctl_scsi_path_string(io, path_str, sizeof(path_str)); - /* - * XXX KDM ZFS returns ENOSPC when the underlying - * filesystem fills up. What kind of SCSI error should we - * return for that? - */ printf("%s%s command returned errno %d\n", path_str, (beio->bio_cmd == BIO_READ) ? "READ" : "WRITE", error); - ctl_set_medium_error(&io->scsiio); + if (error == ENOSPC) { + ctl_set_space_alloc_fail(&io->scsiio); + } else + ctl_set_medium_error(&io->scsiio); ctl_complete_beio(beio); return; } @@ -804,7 +804,10 @@ ctl_be_block_dispatch_zvol(struct ctl_be * return the I/O to the user. */ if (error != 0) { - ctl_set_medium_error(&io->scsiio); + if (error == ENOSPC) { + ctl_set_space_alloc_fail(&io->scsiio); + } else + ctl_set_medium_error(&io->scsiio); ctl_complete_beio(beio); return; } Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Wed Oct 29 02:23:50 2014 (r273808) +++ head/sys/cam/ctl/ctl_error.c Wed Oct 29 03:14:29 2014 (r273809) @@ -806,6 +806,18 @@ ctl_set_task_aborted(struct ctl_scsiio * } void +ctl_set_space_alloc_fail(struct ctl_scsiio *ctsio) +{ + /* "Space allocation failed write protect" */ + ctl_set_sense(ctsio, + /*current_error*/ 1, + /*sense_key*/ SSD_KEY_DATA_PROTECT, + /*asc*/ 0x27, + /*ascq*/ 0x07, + SSD_ELEM_NONE); +} + +void ctl_set_success(struct ctl_scsiio *ctsio) { struct scsi_sense_data *sense; Modified: head/sys/cam/ctl/ctl_error.h ============================================================================== --- head/sys/cam/ctl/ctl_error.h Wed Oct 29 02:23:50 2014 (r273808) +++ head/sys/cam/ctl/ctl_error.h Wed Oct 29 03:14:29 2014 (r273809) @@ -81,6 +81,7 @@ void ctl_set_reservation_conflict(struct void ctl_set_queue_full(struct ctl_scsiio *ctsio); void ctl_set_busy(struct ctl_scsiio *ctsio); void ctl_set_task_aborted(struct ctl_scsiio *ctsio); +void ctl_set_space_alloc_fail(struct ctl_scsiio *ctsio); void ctl_set_success(struct ctl_scsiio *ctsio); #endif /* _CTL_ERROR_H_ */ Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Wed Oct 29 02:23:50 2014 (r273808) +++ head/sys/cam/scsi/scsi_all.c Wed Oct 29 03:14:29 2014 (r273809) @@ -1733,7 +1733,7 @@ static struct asc_table_entry asc_table[ { SST(0x27, 0x06, SS_RDEF, /* XXX TBD */ "Conditional write protect") }, /* D B */ - { SST(0x27, 0x07, SS_RDEF, /* XXX TBD */ + { SST(0x27, 0x07, SS_FATAL | ENOSPC, "Space allocation failed write protect") }, /* DTLPWROMAEBKVF */ { SST(0x28, 0x00, SS_FATAL | ENXIO,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410290314.s9T3EUFT050781>