From owner-svn-src-head@freebsd.org Sun Feb 16 23:11:01 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86E20245F7F; Sun, 16 Feb 2020 23:11:01 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48LNC86dQtz4cJt; Sun, 16 Feb 2020 23:11:00 +0000 (UTC) (envelope-from scottl@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 BDC9E2D764; Sun, 16 Feb 2020 23:11:00 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01GNB06i095543; Sun, 16 Feb 2020 23:11:00 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01GNAxGT095504; Sun, 16 Feb 2020 23:10:59 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <202002162310.01GNAxGT095504@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sun, 16 Feb 2020 23:10:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358009 - in head/sys: cam/ata cam/nvme cam/scsi ufs/ffs ufs/ufs X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in head/sys: cam/ata cam/nvme cam/scsi ufs/ffs ufs/ufs X-SVN-Commit-Revision: 358009 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.29 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, 16 Feb 2020 23:11:01 -0000 Author: scottl Date: Sun Feb 16 23:10:59 2020 New Revision: 358009 URL: https://svnweb.freebsd.org/changeset/base/358009 Log: Add rudamentary support for UFS to probe whether a block device supports the BIO_SPEEDUP command. Add complimentary support to the CAM periphs that support it. This is a redo of r357710. Modified: head/sys/cam/ata/ata_da.c head/sys/cam/nvme/nvme_da.c head/sys/cam/scsi/scsi_da.c head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/ffs_vfsops.c head/sys/ufs/ufs/ufsmount.h Modified: head/sys/cam/ata/ata_da.c ============================================================================== --- head/sys/cam/ata/ata_da.c Sun Feb 16 21:23:23 2020 (r358008) +++ head/sys/cam/ata/ata_da.c Sun Feb 16 23:10:59 2020 (r358009) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #endif /* _KERNEL */ @@ -878,6 +879,7 @@ static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOW static int ada_spindown_suspend = ADA_DEFAULT_SPINDOWN_SUSPEND; static int ada_read_ahead = ADA_DEFAULT_READ_AHEAD; static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; +static int ada_enable_biospeedup = 1; static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); @@ -895,6 +897,8 @@ SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLA &ada_read_ahead, 0, "Enable disk read-ahead"); SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, &ada_write_cache, 0, "Enable disk write cache"); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, + &ada_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); /* * ADA_ORDEREDTAG_INTERVAL determines how often, relative @@ -1565,6 +1569,9 @@ adagetattr(struct bio *bp) { int ret; struct cam_periph *periph; + + if (g_handleattr_int(bp, "GEOM::canspeedup", ada_enable_biospeedup)) + return (EJUSTRETURN); periph = (struct cam_periph *)bp->bio_disk->d_drv1; cam_periph_lock(periph); Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Sun Feb 16 21:23:23 2020 (r358008) +++ head/sys/cam/nvme/nvme_da.c Sun Feb 16 23:10:59 2020 (r358009) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #endif /* _KERNEL */ @@ -174,9 +175,12 @@ static SYSCTL_NODE(_kern_cam, OID_AUTO, nda, CTLFLAG_R static int nda_send_ordered = NDA_DEFAULT_SEND_ORDERED; static int nda_default_timeout = NDA_DEFAULT_TIMEOUT; static int nda_max_trim_entries = NDA_MAX_TRIM_ENTRIES; +static int nda_enable_biospeedup = 1; SYSCTL_INT(_kern_cam_nda, OID_AUTO, max_trim, CTLFLAG_RDTUN, &nda_max_trim_entries, NDA_MAX_TRIM_ENTRIES, "Maximum number of BIO_DELETE to send down as a DSM TRIM."); +SYSCTL_INT(_kern_cam_nda, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, + &nda_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); /* * All NVMe media is non-rotational, so all nvme device instances @@ -699,6 +703,9 @@ ndagetattr(struct bio *bp) { int ret; struct cam_periph *periph; + + if (g_handleattr_int(bp, "GEOM::canspeedup", nda_enable_biospeedup)) + return (EJUSTRETURN); periph = (struct cam_periph *)bp->bio_disk->d_drv1; cam_periph_lock(periph); Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Sun Feb 16 21:23:23 2020 (r358008) +++ head/sys/cam/scsi/scsi_da.c Sun Feb 16 23:10:59 2020 (r358009) @@ -1547,6 +1547,7 @@ static int da_default_timeout = DA_DEFAULT_TIMEOUT; static sbintime_t da_default_softtimeout = DA_DEFAULT_SOFTTIMEOUT; static int da_send_ordered = DA_DEFAULT_SEND_ORDERED; static int da_disable_wp_detection = 0; +static int da_enable_biospeedup = 1; static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); @@ -1561,6 +1562,8 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFL SYSCTL_INT(_kern_cam_da, OID_AUTO, disable_wp_detection, CTLFLAG_RWTUN, &da_disable_wp_detection, 0, "Disable detection of write-protected disks"); +SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, + &da_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout, CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, dasysctlsofttimeout, "I", @@ -1966,6 +1969,9 @@ dagetattr(struct bio *bp) { int ret; struct cam_periph *periph; + + if (g_handleattr_int(bp, "GEOM::canspeedup", da_enable_biospeedup)) + return (EJUSTRETURN); periph = (struct cam_periph *)bp->bio_disk->d_drv1; cam_periph_lock(periph); Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Sun Feb 16 21:23:23 2020 (r358008) +++ head/sys/ufs/ffs/ffs_softdep.c Sun Feb 16 23:10:59 2020 (r358009) @@ -1464,6 +1464,9 @@ softdep_send_speedup(struct ufsmount *ump, size_t shor { struct buf *bp; + if ((ump->um_flags & UM_CANSPEEDUP) == 0) + return; + bp = malloc(sizeof(*bp), M_TRIM, M_WAITOK | M_ZERO); bp->b_iocmd = BIO_SPEEDUP; bp->b_ioflags = flags; Modified: head/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vfsops.c Sun Feb 16 21:23:23 2020 (r358008) +++ head/sys/ufs/ffs/ffs_vfsops.c Sun Feb 16 23:10:59 2020 (r358009) @@ -794,7 +794,7 @@ ffs_mountfs(devvp, mp, td) struct ucred *cred; struct g_consumer *cp; struct mount *nmp; - int candelete; + int candelete, canspeedup; off_t loc; fs = NULL; @@ -1009,6 +1009,12 @@ ffs_mountfs(devvp, mp, td) ump->um_trimhash = hashinit(MAXTRIMIO, M_TRIM, &ump->um_trimlisthashsize); } + } + + len = sizeof(int); + if (g_io_getattr("GEOM::canspeedup", cp, &len, &canspeedup) == 0) { + if (canspeedup) + ump->um_flags |= UM_CANSPEEDUP; } ump->um_mountp = mp; Modified: head/sys/ufs/ufs/ufsmount.h ============================================================================== --- head/sys/ufs/ufs/ufsmount.h Sun Feb 16 21:23:23 2020 (r358008) +++ head/sys/ufs/ufs/ufsmount.h Sun Feb 16 23:10:59 2020 (r358009) @@ -131,6 +131,7 @@ struct ufsmount { */ #define UM_CANDELETE 0x00000001 /* devvp supports TRIM */ #define UM_WRITESUSPENDED 0x00000002 /* suspension in progress */ +#define UM_CANSPEEDUP 0x00000004 /* devvp supports SPEEDUP */ /* * function prototypes