From owner-svn-src-head@freebsd.org Thu Sep 17 12:52:20 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7257A9CF8A2; Thu, 17 Sep 2015 12:52:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62C451847; Thu, 17 Sep 2015 12:52:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8HCqKvt088004; Thu, 17 Sep 2015 12:52:20 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8HCqJkn088000; Thu, 17 Sep 2015 12:52:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201509171252.t8HCqJkn088000@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 17 Sep 2015 12:52:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287912 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 12:52:20 -0000 Author: mav Date: Thu Sep 17 12:52:18 2015 New Revision: 287912 URL: https://svnweb.freebsd.org/changeset/base/287912 Log: Report proper medium error code for VERIFY commands. Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_error.c head/sys/cam/ctl/ctl_error.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Thu Sep 17 12:04:41 2015 (r287911) +++ head/sys/cam/ctl/ctl.c Thu Sep 17 12:52:18 2015 (r287912) @@ -12046,7 +12046,9 @@ ctl_inject_error(struct ctl_lun *lun, un ctl_set_aborted(&io->scsiio); break; case CTL_LUN_INJ_MEDIUM_ERR: - ctl_set_medium_error(&io->scsiio); + ctl_set_medium_error(&io->scsiio, + (io->io_hdr.flags & CTL_FLAG_DATA_MASK) != + CTL_FLAG_DATA_OUT); break; case CTL_LUN_INJ_UA: /* 29h/00h POWER ON, RESET, OR BUS DEVICE RESET Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Thu Sep 17 12:04:41 2015 (r287911) +++ head/sys/cam/ctl/ctl_backend_block.c Thu Sep 17 12:52:18 2015 (r287912) @@ -542,8 +542,10 @@ ctl_be_block_biodone(struct bio *bio) ctl_set_internal_failure(&io->scsiio, /*sks_valid*/ 1, /*retry_count*/ 0xbad2); - } else - ctl_set_medium_error(&io->scsiio); + } else { + ctl_set_medium_error(&io->scsiio, + beio->bio_cmd == BIO_READ); + } ctl_complete_beio(beio); return; } @@ -758,17 +760,14 @@ ctl_be_block_dispatch_file(struct ctl_be * return the I/O to the user. */ if (error != 0) { - char path_str[32]; - - ctl_scsi_path_string(io, path_str, sizeof(path_str)); - printf("%s%s command returned errno %d\n", path_str, - (beio->bio_cmd == BIO_READ) ? "READ" : "WRITE", error); if (error == ENOSPC || error == EDQUOT) { ctl_set_space_alloc_fail(&io->scsiio); } else if (error == EROFS || error == EACCES) { ctl_set_hw_write_protected(&io->scsiio); - } else - ctl_set_medium_error(&io->scsiio); + } else { + ctl_set_medium_error(&io->scsiio, + beio->bio_cmd == BIO_READ); + } ctl_complete_beio(beio); return; } @@ -934,8 +933,10 @@ ctl_be_block_dispatch_zvol(struct ctl_be ctl_set_space_alloc_fail(&io->scsiio); } else if (error == EROFS || error == EACCES) { ctl_set_hw_write_protected(&io->scsiio); - } else - ctl_set_medium_error(&io->scsiio); + } else { + ctl_set_medium_error(&io->scsiio, + beio->bio_cmd == BIO_READ); + } ctl_complete_beio(beio); return; } Modified: head/sys/cam/ctl/ctl_error.c ============================================================================== --- head/sys/cam/ctl/ctl_error.c Thu Sep 17 12:04:41 2015 (r287911) +++ head/sys/cam/ctl/ctl_error.c Thu Sep 17 12:52:18 2015 (r287912) @@ -686,9 +686,9 @@ ctl_set_internal_failure(struct ctl_scsi } void -ctl_set_medium_error(struct ctl_scsiio *ctsio) +ctl_set_medium_error(struct ctl_scsiio *ctsio, int read) { - if ((ctsio->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) { + if (read) { /* "Unrecovered read error" */ ctl_set_sense(ctsio, /*current_error*/ 1, Modified: head/sys/cam/ctl/ctl_error.h ============================================================================== --- head/sys/cam/ctl/ctl_error.h Thu Sep 17 12:04:41 2015 (r287911) +++ head/sys/cam/ctl/ctl_error.h Thu Sep 17 12:52:18 2015 (r287912) @@ -73,7 +73,7 @@ void ctl_set_lun_standby(struct ctl_scsi void ctl_set_lun_unavail(struct ctl_scsiio *ctsio); void ctl_set_internal_failure(struct ctl_scsiio *ctsio, int sks_valid, uint16_t retry_count); -void ctl_set_medium_error(struct ctl_scsiio *ctsio); +void ctl_set_medium_error(struct ctl_scsiio *ctsio, int read); void ctl_set_aborted(struct ctl_scsiio *ctsio); void ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio); void ctl_set_lun_stopped(struct ctl_scsiio *ctsio);