From owner-svn-src-head@freebsd.org Tue Jun 26 00:39:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 949A31027034; Tue, 26 Jun 2018 00:39:39 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 35063748BD; Tue, 26 Jun 2018 00:39:39 +0000 (UTC) (envelope-from imp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 075CD4D16; Tue, 26 Jun 2018 00:39:39 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5Q0dcSk030984; Tue, 26 Jun 2018 00:39:38 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5Q0dcnh030983; Tue, 26 Jun 2018 00:39:38 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201806260039.w5Q0dcnh030983@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 26 Jun 2018 00:39:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335650 - head/sys/ufs/ffs X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/ufs/ffs X-SVN-Commit-Revision: 335650 X-SVN-Commit-Repository: base 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.26 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: Tue, 26 Jun 2018 00:39:39 -0000 Author: imp Date: Tue Jun 26 00:39:38 2018 New Revision: 335650 URL: https://svnweb.freebsd.org/changeset/base/335650 Log: Use buf + strategy rather than bypassing geom_vfs layer The reference counting that's done in the geom_vfs layer to prevent delivery of requests to defunct devices only works if all requests go through that layer. UFS was bypassing that layer for BIO_DELETE requests, sending them to the geom_consumer directly with g_io_request. Allocate a buf, fill it in, and call strategy on it instead. Submitted by: Chuck Silvers Reviewed by: scottl, imp, kirk Sponsored by: Netflix Differential: https://reviews.freebsd.org/D15456 Modified: head/sys/ufs/ffs/ffs_alloc.c Modified: head/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_alloc.c Mon Jun 25 22:36:25 2018 (r335649) +++ head/sys/ufs/ffs/ffs_alloc.c Tue Jun 26 00:39:38 2018 (r335650) @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -109,7 +110,7 @@ static ufs2_daddr_t static void ffs_blkfree_cg(struct ufsmount *, struct fs *, struct vnode *, ufs2_daddr_t, long, ino_t, struct workhead *); -static void ffs_blkfree_trim_completed(struct bio *); +static void ffs_blkfree_trim_completed(struct buf *); static void ffs_blkfree_trim_task(void *ctx, int pending __unused); #ifdef INVARIANTS static int ffs_checkblk(struct inode *, ufs2_daddr_t, long); @@ -2280,13 +2281,13 @@ ffs_blkfree_trim_task(ctx, pending) } static void -ffs_blkfree_trim_completed(bip) - struct bio *bip; +ffs_blkfree_trim_completed(bp) + struct buf *bp; { struct ffs_blkfree_trim_params *tp; - tp = bip->bio_caller2; - g_destroy_bio(bip); + tp = bp->b_fsprivate1; + free(bp, M_TEMP); TASK_INIT(&tp->task, 0, ffs_blkfree_trim_task, tp); taskqueue_enqueue(tp->ump->um_trim_tq, &tp->task); } @@ -2303,7 +2304,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, inum, vtype, de struct workhead *dephd; { struct mount *mp; - struct bio *bip; + struct buf *bp; struct ffs_blkfree_trim_params *tp; /* @@ -2346,16 +2347,16 @@ ffs_blkfree(ump, fs, devvp, bno, size, inum, vtype, de } else tp->pdephd = NULL; - bip = g_alloc_bio(); - bip->bio_cmd = BIO_DELETE; - bip->bio_offset = dbtob(fsbtodb(fs, bno)); - bip->bio_done = ffs_blkfree_trim_completed; - bip->bio_length = size; - bip->bio_caller2 = tp; + bp = malloc(sizeof(*bp), M_TEMP, M_WAITOK | M_ZERO); + bp->b_iocmd = BIO_DELETE; + bp->b_iooffset = dbtob(fsbtodb(fs, bno)); + bp->b_iodone = ffs_blkfree_trim_completed; + bp->b_bcount = size; + bp->b_fsprivate1 = tp; mp = UFSTOVFS(ump); vn_start_secondary_write(NULL, &mp, 0); - g_io_request(bip, (struct g_consumer *)devvp->v_bufobj.bo_private); + g_vfs_strategy(ump->um_bo, bp); } #ifdef INVARIANTS