From owner-svn-src-stable@FreeBSD.ORG Sat Sep 14 09:42:02 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A9DE9991; Sat, 14 Sep 2013 09:42:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 87EB02C63; Sat, 14 Sep 2013 09:42:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8E9g2WQ014390; Sat, 14 Sep 2013 09:42:02 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8E9g2Sb014388; Sat, 14 Sep 2013 09:42:02 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201309140942.r8E9g2Sb014388@svn.freebsd.org> From: Alexander Motin Date: Sat, 14 Sep 2013 09:42:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r255555 - in stable/9/sys/cam: ata scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2013 09:42:02 -0000 Author: mav Date: Sat Sep 14 09:42:01 2013 New Revision: 255555 URL: http://svnweb.freebsd.org/changeset/base/255555 Log: MFC r253752: Fix returning incorrect bio_resid value with failed BIO_DELETE requests. Neither residual length reported for ATA/SCSI command nor one from another BIO_DELETE request are in any way related to the value to be returned. Modified: stable/9/sys/cam/ata/ata_da.c stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Sat Sep 14 09:40:24 2013 (r255554) +++ stable/9/sys/cam/ata/ata_da.c Sat Sep 14 09:42:01 2013 (r255555) @@ -1696,37 +1696,27 @@ adadone(struct cam_periph *periph, union struct ada_softc *softc; struct ccb_ataio *ataio; struct ccb_getdev *cgd; + int state; softc = (struct ada_softc *)periph->softc; ataio = &done_ccb->ataio; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("adadone\n")); - switch (ataio->ccb_h.ccb_state & ADA_CCB_TYPE_MASK) { + state = ataio->ccb_h.ccb_state & ADA_CCB_TYPE_MASK; + switch (state) { case ADA_CCB_BUFFER_IO: case ADA_CCB_TRIM: { struct bio *bp; + int error; - bp = (struct bio *)done_ccb->ccb_h.ccb_bp; if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - int error; - error = adaerror(done_ccb, 0, 0); if (error == ERESTART) { /* A retry was scheduled, so just return. */ return; } - if (error != 0) { - bp->bio_error = error; - bp->bio_resid = bp->bio_bcount; - bp->bio_flags |= BIO_ERROR; - } else { - bp->bio_resid = ataio->resid; - bp->bio_error = 0; - if (bp->bio_resid != 0) - bp->bio_flags |= BIO_ERROR; - } if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) cam_release_devq(done_ccb->ccb_h.path, /*relsim_flags*/0, @@ -1736,26 +1726,38 @@ adadone(struct cam_periph *periph, union } else { if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) panic("REQ_CMP with QFRZN"); - bp->bio_resid = ataio->resid; - if (ataio->resid > 0) + error = 0; + } + bp = (struct bio *)done_ccb->ccb_h.ccb_bp; + bp->bio_error = error; + if (error != 0) { + bp->bio_resid = bp->bio_bcount; + bp->bio_flags |= BIO_ERROR; + } else { + if (state == ADA_CCB_TRIM) + bp->bio_resid = 0; + else + bp->bio_resid = ataio->resid; + if (bp->bio_resid > 0) bp->bio_flags |= BIO_ERROR; } softc->outstanding_cmds--; if (softc->outstanding_cmds == 0) softc->flags |= ADA_FLAG_WENT_IDLE; - if ((ataio->ccb_h.ccb_state & ADA_CCB_TYPE_MASK) == - ADA_CCB_TRIM) { + if (state == ADA_CCB_TRIM) { struct trim_request *req = (struct trim_request *)ataio->data_ptr; int i; for (i = 1; i < TRIM_MAX_BIOS && req->bps[i]; i++) { struct bio *bp1 = req->bps[i]; - - bp1->bio_resid = bp->bio_resid; + bp1->bio_error = bp->bio_error; - if (bp->bio_flags & BIO_ERROR) + if (bp->bio_flags & BIO_ERROR) { bp1->bio_flags |= BIO_ERROR; + bp1->bio_resid = bp1->bio_bcount; + } else + bp1->bio_resid = 0; biodone(bp1); } softc->trim_running = 0; Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Sat Sep 14 09:40:24 2013 (r255554) +++ stable/9/sys/cam/scsi/scsi_da.c Sat Sep 14 09:42:01 2013 (r255555) @@ -2929,7 +2929,10 @@ dadone(struct cam_periph *periph, union bp->bio_flags |= BIO_ERROR; } } else if (bp != NULL) { - bp->bio_resid = csio->resid; + if (state == DA_CCB_DELETE) + bp->bio_resid = 0; + else + bp->bio_resid = csio->resid; bp->bio_error = 0; if (bp->bio_resid != 0) bp->bio_flags |= BIO_ERROR; @@ -2943,7 +2946,10 @@ dadone(struct cam_periph *periph, union } else if (bp != NULL) { if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) panic("REQ_CMP with QFRZN"); - bp->bio_resid = csio->resid; + if (state == DA_CCB_DELETE) + bp->bio_resid = 0; + else + bp->bio_resid = csio->resid; if (csio->resid > 0) bp->bio_flags |= BIO_ERROR; if (softc->error_inject != 0) { @@ -2952,7 +2958,6 @@ dadone(struct cam_periph *periph, union bp->bio_flags |= BIO_ERROR; softc->error_inject = 0; } - } /* @@ -2967,10 +2972,12 @@ dadone(struct cam_periph *periph, union if (state == DA_CCB_DELETE) { while ((bp1 = bioq_takefirst(&softc->delete_run_queue)) != NULL) { - bp1->bio_resid = bp->bio_resid; bp1->bio_error = bp->bio_error; - if (bp->bio_flags & BIO_ERROR) + if (bp->bio_flags & BIO_ERROR) { bp1->bio_flags |= BIO_ERROR; + bp1->bio_resid = bp1->bio_bcount; + } else + bp1->bio_resid = 0; biodone(bp1); } softc->delete_running = 0;