From owner-svn-src-all@FreeBSD.ORG Thu Jun 6 08:48:03 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9B5399C; Thu, 6 Jun 2013 08:48:03 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7303B10A1; Thu, 6 Jun 2013 08:48:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r568m3sQ064852; Thu, 6 Jun 2013 08:48:03 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r568m30c064850; Thu, 6 Jun 2013 08:48:03 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306060848.r568m30c064850@svn.freebsd.org> From: Steven Hartland Date: Thu, 6 Jun 2013 08:48:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r251453 - stable/8/sys/dev/md X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2013 08:48:03 -0000 Author: smh Date: Thu Jun 6 08:48:02 2013 New Revision: 251453 URL: http://svnweb.freebsd.org/changeset/base/251453 Log: MFC r221229: Implement BIO_DELETE for vnode devices Modified: stable/8/sys/dev/md/md.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/md/ (props changed) Modified: stable/8/sys/dev/md/md.c ============================================================================== --- stable/8/sys/dev/md/md.c Thu Jun 6 06:17:20 2013 (r251452) +++ stable/8/sys/dev/md/md.c Thu Jun 6 08:48:02 2013 (r251453) @@ -205,6 +205,9 @@ struct md_s { vm_object_t object; }; +/* Used for BIO_DELETE on MD_VNODE */ +static u_char zero[PAGE_SIZE]; + static struct indir * new_indir(u_int shift) { @@ -514,10 +517,12 @@ mdstart_vnode(struct md_s *sc, struct bi struct mount *mp; struct vnode *vp; struct thread *td; + off_t end, zerosize; switch (bp->bio_cmd) { case BIO_READ: case BIO_WRITE: + case BIO_DELETE: case BIO_FLUSH: break; default: @@ -548,6 +553,43 @@ mdstart_vnode(struct md_s *sc, struct bi bzero(&auio, sizeof(auio)); + /* + * Special case for BIO_DELETE. On the surface, this is very + * similar to BIO_WRITE, except that we write from our own + * fixed-length buffer, so we have to loop. The net result is + * that the two cases end up having very little in common. + */ + if (bp->bio_cmd == BIO_DELETE) { + zerosize = sizeof(zero) - (sizeof(zero) % sc->sectorsize); + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_offset = (vm_ooffset_t)bp->bio_offset; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_td = td; + end = bp->bio_offset + bp->bio_length; + vfslocked = VFS_LOCK_GIANT(vp->v_mount); + (void) vn_start_write(vp, &mp, V_WAIT); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + error = 0; + while (auio.uio_offset < end) { + aiov.iov_base = zero; + aiov.iov_len = end - auio.uio_offset; + if (aiov.iov_len > zerosize) + aiov.iov_len = zerosize; + auio.uio_resid = aiov.iov_len; + error = VOP_WRITE(vp, &auio, + sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred); + if (error != 0) + break; + } + VOP_UNLOCK(vp, 0); + vn_finished_write(mp); + bp->bio_resid = end - auio.uio_offset; + VFS_UNLOCK_GIANT(vfslocked); + return (error); + } + aiov.iov_base = bp->bio_data; aiov.iov_len = bp->bio_length; auio.uio_iov = &aiov;