Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Aug 2013 23:02:20 +0000 (UTC)
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r254979 - in stable/9/sys: dev/nvme geom kern sys
Message-ID:  <201308272302.r7RN2KbT026513@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ken
Date: Tue Aug 27 23:02:20 2013
New Revision: 254979
URL: http://svnweb.freebsd.org/changeset/base/254979

Log:
  MFC change 254389:
  
  There are some slight differences from the version in FreeBSD/head.
  __FreeBSD_version has been bumped to 902503 for the availability
  of the SI_UNMAPPED cdev flag, and the D_UNMAPPED_IO cdevsw flag
  remains in place.  D_UNMAPPED_IO no longer does anything.  Drivers that
  use that flag will just wind up having mapped I/O by default.  The
  impact will only be on performance, not functionality.
  
    Change the way that unmapped I/O capability is advertised.
  
    The previous method was to set the D_UNMAPPED_IO flag in the cdevsw
    for the driver.  The problem with this is that in many cases (e.g.
    sa(4)) there may be some instances of the driver that can handle
    unmapped I/O and some that can't.  The isp(4) driver can handle
    unmapped I/O, but the esp(4) driver currently cannot.  The cdevsw
    is shared among all driver instances.
  
    So instead of setting a flag on the cdevsw, set a flag on the cdev.
    This allows drivers to indicate support for unmapped I/O on a
    per-instance basis.
  
    sys/conf.h:	Remove the D_UNMAPPED_IO cdevsw flag and replace it
    		with an SI_UNMAPPED cdev flag.
  
    kern_physio.c:	Look at the cdev SI_UNMAPPED flag to determine
    		whether or not a particular driver can handle
    		unmapped I/O.
  
    geom_dev.c:	Set the SI_UNMAPPED flag for all GEOM cdevs.
    		Since GEOM will create a temporary mapping when
    		needed, setting SI_UNMAPPED unconditionally will
    		work.
  
    		Remove the D_UNMAPPED_IO flag.
  
    nvme_ns.c:	Set the SI_UNMAPPED flag on cdevs created here
    		if NVME_UNMAPPED_BIO_SUPPORT is enabled.
  
    vfs_aio.c:	In aio_qphysio(), check the SI_UNMAPPED flag on a
    		cdev instead of the D_UNMAPPED_IO flag on the cdevsw.
  
    sys/param.h:	Bump __FreeBSD_version to 1000045 for the switch from
    		setting the D_UNMAPPED_IO flag in the cdevsw to setting
    		SI_UNMAPPED in the cdev.
  
    Reviewed by:	kib, jimharris
    Sponsored by:	Spectra Logic

Modified:
  stable/9/sys/dev/nvme/nvme_ns.c
  stable/9/sys/geom/geom_dev.c
  stable/9/sys/kern/kern_physio.c
  stable/9/sys/kern/vfs_aio.c
  stable/9/sys/sys/conf.h
  stable/9/sys/sys/param.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/dev/nvme/nvme_ns.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ns.c	Tue Aug 27 22:37:29 2013	(r254978)
+++ stable/9/sys/dev/nvme/nvme_ns.c	Tue Aug 27 23:02:20 2013	(r254979)
@@ -133,11 +133,7 @@ nvme_ns_strategy(struct bio *bp)
 
 static struct cdevsw nvme_ns_cdevsw = {
 	.d_version =	D_VERSION,
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
-	.d_flags =	D_DISK | D_UNMAPPED_IO,
-#else
 	.d_flags =	D_DISK,
-#endif
 	.d_read =	physread,
 	.d_write =	physwrite,
 	.d_open =	nvme_ns_open,
@@ -348,6 +344,9 @@ nvme_ns_construct(struct nvme_namespace 
 	    NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d",
 	    device_get_unit(ctrlr->dev), ns->id);
 #endif
+#ifdef NVME_UNMAPPED_BIO_SUPPORT
+	ns->cdev->si_flags |= SI_UNMAPPED;
+#endif
 
 	if (ns->cdev != NULL)
 		ns->cdev->si_drv1 = ns;

Modified: stable/9/sys/geom/geom_dev.c
==============================================================================
--- stable/9/sys/geom/geom_dev.c	Tue Aug 27 22:37:29 2013	(r254978)
+++ stable/9/sys/geom/geom_dev.c	Tue Aug 27 23:02:20 2013	(r254979)
@@ -79,7 +79,7 @@ static struct cdevsw g_dev_cdevsw = {
 	.d_ioctl =	g_dev_ioctl,
 	.d_strategy =	g_dev_strategy,
 	.d_name =	"g_dev",
-	.d_flags =	D_DISK | D_TRACKCLOSE | D_UNMAPPED_IO,
+	.d_flags =	D_DISK | D_TRACKCLOSE,
 };
 
 static g_taste_t g_dev_taste;
@@ -237,6 +237,7 @@ g_dev_taste(struct g_class *mp, struct g
 		g_free(sc);
 		return (NULL);
 	}
+	dev->si_flags |= SI_UNMAPPED;
 	sc->sc_dev = dev;
 
 	/* Search for device alias name and create it if found. */
@@ -251,6 +252,7 @@ g_dev_taste(struct g_class *mp, struct g
 			freeenv(val);
 			make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK,
 			    &adev, dev, "%s", buf);
+			adev->si_flags |= SI_UNMAPPED;
 			break;
 		}
 	}

Modified: stable/9/sys/kern/kern_physio.c
==============================================================================
--- stable/9/sys/kern/kern_physio.c	Tue Aug 27 22:37:29 2013	(r254978)
+++ stable/9/sys/kern/kern_physio.c	Tue Aug 27 23:02:20 2013	(r254979)
@@ -93,8 +93,7 @@ physio(struct cdev *dev, struct uio *uio
 
 			csw = dev->si_devsw;
 			if (uio->uio_segflg == UIO_USERSPACE) {
-				if (csw != NULL &&
-                                    (csw->d_flags & D_UNMAPPED_IO) != 0)
+				if (dev->si_flags & SI_UNMAPPED)
 					mapped = 0;
 				else
 					mapped = 1;

Modified: stable/9/sys/kern/vfs_aio.c
==============================================================================
--- stable/9/sys/kern/vfs_aio.c	Tue Aug 27 22:37:29 2013	(r254978)
+++ stable/9/sys/kern/vfs_aio.c	Tue Aug 27 23:02:20 2013	(r254979)
@@ -1333,7 +1333,7 @@ aio_qphysio(struct proc *p, struct aiocb
 	/*
 	 * Bring buffer into kernel space.
 	 */
-	if (vmapbuf(bp, 1) < 0) {
+	if (vmapbuf(bp, (dev->si_flags & SI_UNMAPPED) == 0) < 0) {
 		error = EFAULT;
 		goto doerror;
 	}

Modified: stable/9/sys/sys/conf.h
==============================================================================
--- stable/9/sys/sys/conf.h	Tue Aug 27 22:37:29 2013	(r254978)
+++ stable/9/sys/sys/conf.h	Tue Aug 27 23:02:20 2013	(r254979)
@@ -64,6 +64,7 @@ struct cdev {
 #define SI_DUMPDEV	0x0080	/* is kernel dumpdev */
 #define SI_CANDELETE	0x0100	/* can do BIO_DELETE */
 #define SI_CLONELIST	0x0200	/* on a clone list */
+#define	SI_UNMAPPED	0x0400	/* can handle unmapped I/O */
 	struct timespec	si_atime;
 	struct timespec	si_ctime;
 	struct timespec	si_mtime;

Modified: stable/9/sys/sys/param.h
==============================================================================
--- stable/9/sys/sys/param.h	Tue Aug 27 22:37:29 2013	(r254978)
+++ stable/9/sys/sys/param.h	Tue Aug 27 23:02:20 2013	(r254979)
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 902502	/* Master, propagated to newvers */
+#define __FreeBSD_version 902503	/* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308272302.r7RN2KbT026513>