From owner-svn-src-head@FreeBSD.ORG Sun Jun 15 20:14:12 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 79A80A99; Sun, 15 Jun 2014 20:14:12 +0000 (UTC) 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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6680B2DB4; Sun, 15 Jun 2014 20:14:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5FKEC0A033029; Sun, 15 Jun 2014 20:14:12 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5FKEC3j033027; Sun, 15 Jun 2014 20:14:12 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201406152014.s5FKEC3j033027@svn.freebsd.org> From: Alexander Motin Date: Sun, 15 Jun 2014 20:14:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267519 - 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.18 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: Sun, 15 Jun 2014 20:14:12 -0000 Author: mav Date: Sun Jun 15 20:14:11 2014 New Revision: 267519 URL: http://svnweb.freebsd.org/changeset/base/267519 Log: Make backends track completion by processed number of sectors instead of total transfer size. Commands such as VERIFY or COMPARE AND WRITE may have transfer size not matching directly to number of sectors. Modified: head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_backend_ramdisk.c Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Sun Jun 15 18:39:10 2014 (r267518) +++ head/sys/cam/ctl/ctl_backend_block.c Sun Jun 15 20:14:11 2014 (r267519) @@ -103,6 +103,9 @@ __FBSDID("$FreeBSD$"); #define DPRINTF(fmt, args...) do {} while(0) #endif +#define PRIV(io) \ + ((struct ctl_ptr_len_flags *)&(io)->io_hdr.ctl_private[CTL_PRIV_BACKEND]) + SDT_PROVIDER_DEFINE(cbb); typedef enum { @@ -356,9 +359,7 @@ ctl_be_block_move_done(union ctl_io *io) struct bintime cur_bt; #endif - beio = (struct ctl_be_block_io *) - io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr; - + beio = (struct ctl_be_block_io *)PRIV(io)->ptr; be_lun = beio->lun; DPRINTF("entered\n"); @@ -932,7 +933,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b DPRINTF("entered\n"); - beio = io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr; + beio = (struct ctl_be_block_io *)PRIV(io)->ptr; softc = be_lun->softc; lbalen = (struct ctl_lba_len_flags *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; @@ -1039,7 +1040,7 @@ ctl_be_block_cw_dispatch_unmap(struct ct DPRINTF("entered\n"); - beio = io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr; + beio = (struct ctl_be_block_io *)PRIV(io)->ptr; softc = be_lun->softc; ptrlen = (struct ctl_ptr_len_flags *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; @@ -1114,7 +1115,7 @@ ctl_be_block_cw_dispatch(struct ctl_be_b beio->io = io; beio->lun = be_lun; beio->beio_cont = ctl_be_block_cw_done; - io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr = beio; + PRIV(io)->ptr = (void *)beio; switch (io->scsiio.cdb[0]) { case SYNCHRONIZE_CACHE: @@ -1181,7 +1182,8 @@ ctl_be_block_dispatch(struct ctl_be_bloc struct ctl_be_block_io *beio; struct ctl_be_block_softc *softc; struct ctl_lba_len *lbalen; - uint64_t len_left, lbaoff; + struct ctl_ptr_len_flags *bptrlen; + uint64_t len_left, lbas; int i; softc = be_lun->softc; @@ -1197,7 +1199,8 @@ ctl_be_block_dispatch(struct ctl_be_bloc beio = ctl_alloc_beio(softc); beio->io = io; beio->lun = be_lun; - io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr = beio; + bptrlen = PRIV(io); + bptrlen->ptr = (void *)beio; /* * If the I/O came down with an ordered or head of queue tag, set @@ -1243,12 +1246,12 @@ ctl_be_block_dispatch(struct ctl_be_bloc lbalen = (struct ctl_lba_len *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; DPRINTF("%s at LBA %jx len %u @%ju\n", (beio->bio_cmd == BIO_READ) ? "READ" : "WRITE", - (uintmax_t)lbalen->lba, lbalen->len, lbaoff); - lbaoff = io->scsiio.kern_rel_offset / be_lun->blocksize; - beio->io_offset = (lbalen->lba + lbaoff) * be_lun->blocksize; - beio->io_len = MIN((lbalen->len - lbaoff) * be_lun->blocksize, - CTLBLK_MAX_IO_SIZE); - beio->io_len -= beio->io_len % be_lun->blocksize; + (uintmax_t)lbalen->lba, lbalen->len, bptrlen->len); + lbas = MIN(lbalen->len - bptrlen->len, + CTLBLK_MAX_IO_SIZE / be_lun->blocksize); + beio->io_offset = (lbalen->lba + bptrlen->len) * be_lun->blocksize; + beio->io_len = lbas * be_lun->blocksize; + bptrlen->len += lbas; for (i = 0, len_left = beio->io_len; len_left > 0; i++) { KASSERT(i < CTLBLK_MAX_SEGS, ("Too many segs (%d >= %d)", @@ -1266,8 +1269,7 @@ ctl_be_block_dispatch(struct ctl_be_bloc beio->num_segs++; len_left -= beio->sg_segs[i].len; } - if (io->scsiio.kern_rel_offset + beio->io_len < - io->scsiio.kern_total_len) + if (bptrlen->len < lbalen->len) beio->beio_cont = ctl_be_block_next; io->scsiio.be_move_done = ctl_be_block_move_done; io->scsiio.kern_data_ptr = (uint8_t *)beio->sg_segs; @@ -1318,8 +1320,7 @@ ctl_be_block_worker(void *context, int p mtx_unlock(&be_lun->lock); - beio = (struct ctl_be_block_io *) - io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr; + beio = (struct ctl_be_block_io *)PRIV(io)->ptr; be_lun->dispatch(be_lun, beio); @@ -1391,6 +1392,8 @@ ctl_be_block_submit(union ctl_io *io) KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, ("Non-SCSI I/O (type " "%#x) encountered", io->io_hdr.io_type)); + PRIV(io)->len = 0; + mtx_lock(&be_lun->lock); /* * XXX KDM make sure that links is okay to use at this point. Modified: head/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_ramdisk.c Sun Jun 15 18:39:10 2014 (r267518) +++ head/sys/cam/ctl/ctl_backend_ramdisk.c Sun Jun 15 20:14:11 2014 (r267519) @@ -241,7 +241,7 @@ ctl_backend_ramdisk_move_done(union ctl_ if ((io->io_hdr.port_status == 0) && ((io->io_hdr.flags & CTL_FLAG_ABORT) == 0) && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) { - if (io->scsiio.kern_rel_offset < io->scsiio.kern_total_len) { + if (io->io_hdr.ctl_private[CTL_PRIV_BACKEND].integer > 0) { mtx_lock(&be_lun->lock); STAILQ_INSERT_TAIL(&be_lun->cont_queue, &io->io_hdr, links); @@ -274,7 +274,14 @@ ctl_backend_ramdisk_move_done(union ctl_ static int ctl_backend_ramdisk_submit(union ctl_io *io) { + struct ctl_be_lun *ctl_be_lun; + struct ctl_lba_len *lbalen; + ctl_be_lun = (struct ctl_be_lun *)io->io_hdr.ctl_private[ + CTL_PRIV_BACKEND_LUN].ptr; + lbalen = (struct ctl_lba_len *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; + io->io_hdr.ctl_private[CTL_PRIV_BACKEND].integer = + lbalen->len * ctl_be_lun->blocksize; ctl_backend_ramdisk_continue(io); return (CTL_RETVAL_COMPLETE); } @@ -290,7 +297,7 @@ ctl_backend_ramdisk_continue(union ctl_i #endif softc = &rd_softc; - len = io->scsiio.kern_total_len - io->scsiio.kern_rel_offset; + len = io->io_hdr.ctl_private[CTL_PRIV_BACKEND].integer; #ifdef CTL_RAMDISK_PAGES sg_filled = min(btoc(len), softc->num_pages); if (sg_filled > 1) { @@ -321,6 +328,7 @@ ctl_backend_ramdisk_continue(union ctl_i io->scsiio.kern_data_len = len_filled; io->scsiio.kern_sg_entries = sg_filled; io->io_hdr.flags |= CTL_FLAG_ALLOCATED; + io->io_hdr.ctl_private[CTL_PRIV_BACKEND].integer -= len_filled; #ifdef CTL_TIME_IO getbintime(&io->io_hdr.dma_start_bt); #endif