From owner-svn-src-stable-10@freebsd.org Thu Jan 5 11:38:23 2017 Return-Path: Delivered-To: svn-src-stable-10@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 93963CA045F; Thu, 5 Jan 2017 11:38:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 62EE619D2; Thu, 5 Jan 2017 11:38:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v05BcMQs054091; Thu, 5 Jan 2017 11:38:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v05BcMm2054090; Thu, 5 Jan 2017 11:38:22 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201701051138.v05BcMm2054090@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 5 Jan 2017 11:38:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r311419 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2017 11:38:23 -0000 Author: mav Date: Thu Jan 5 11:38:22 2017 New Revision: 311419 URL: https://svnweb.freebsd.org/changeset/base/311419 Log: MFC r310298: Improve error handling when I/O split between several BIOs. If we get several error codes, handle one with lowest offset. Modified: stable/10/sys/cam/ctl/ctl_backend_block.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Thu Jan 5 11:37:46 2017 (r311418) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Thu Jan 5 11:38:22 2017 (r311419) @@ -203,7 +203,8 @@ struct ctl_be_block_io { int num_bios_sent; int num_bios_done; int send_complete; - int num_errors; + int first_error; + uint64_t first_error_offset; struct bintime ds_t0; devstat_tag_type ds_tag_type; devstat_trans_flags ds_trans_type; @@ -489,8 +490,12 @@ ctl_be_block_biodone(struct bio *bio) error = bio->bio_error; mtx_lock(&be_lun->io_lock); - if (error != 0) - beio->num_errors++; + if (error != 0 && + (beio->first_error == 0 || + bio->bio_offset < beio->first_error_offset)) { + beio->first_error = error; + beio->first_error_offset = bio->bio_offset; + } beio->num_bios_done++; @@ -523,7 +528,8 @@ ctl_be_block_biodone(struct bio *bio) * If there are any errors from the backing device, we fail the * entire I/O with a medium error. */ - if (beio->num_errors > 0) { + error = beio->first_error; + if (error != 0) { if (error == EOPNOTSUPP) { ctl_set_invalid_opcode(&io->scsiio); } else if (error == ENOSPC || error == EDQUOT) {