Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2013 14:46:42 +0000 (UTC)
From:      Scott Long <scottl@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: r251942 - in stable/9/sys: geom kern sys
Message-ID:  <201306181446.r5IEkg9Q089958@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Tue Jun 18 14:46:42 2013
New Revision: 251942
URL: http://svnweb.freebsd.org/changeset/base/251942

Log:
  MFC r248712:
  
  Do not pass unmapped buffers to drivers that cannot handle them
  
  Submitted by:	kan, mav
  Obtained from:	Netflix

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

Modified: stable/9/sys/geom/geom_dev.c
==============================================================================
--- stable/9/sys/geom/geom_dev.c	Tue Jun 18 14:40:21 2013	(r251941)
+++ stable/9/sys/geom/geom_dev.c	Tue Jun 18 14:46:42 2013	(r251942)
@@ -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_flags =	D_DISK | D_TRACKCLOSE | D_UNMAPPED_IO,
 };
 
 static g_taste_t g_dev_taste;

Modified: stable/9/sys/kern/kern_physio.c
==============================================================================
--- stable/9/sys/kern/kern_physio.c	Tue Jun 18 14:40:21 2013	(r251941)
+++ stable/9/sys/kern/kern_physio.c	Tue Jun 18 14:46:42 2013	(r251942)
@@ -92,11 +92,19 @@ physio(struct cdev *dev, struct uio *uio
 			bp->b_blkno = btodb(bp->b_offset);
 			csw = dev->si_devsw;
 			if (uio->uio_segflg == UIO_USERSPACE) {
-				if (vmapbuf(bp, 0) < 0) {
+				int mapped;
+
+				if (csw != NULL &&
+                                    (csw->d_flags & D_UNMAPPED_IO) != 0)
+					mapped = 0;
+				else
+					mapped = 1;
+				if (vmapbuf(bp, mapped) < 0) {
 					error = EFAULT;
 					goto doerror;
 				}
 			}
+
 			dev_strategy_csw(dev, csw, bp);
 			if (uio->uio_rw == UIO_READ)
 				bwait(bp, PRIBIO, "physrd");

Modified: stable/9/sys/sys/conf.h
==============================================================================
--- stable/9/sys/sys/conf.h	Tue Jun 18 14:40:21 2013	(r251941)
+++ stable/9/sys/sys/conf.h	Tue Jun 18 14:46:42 2013	(r251942)
@@ -171,6 +171,7 @@ typedef int dumper_t(
 #define D_PSEUDO	0x00200000	/* make_dev() can return NULL */
 #define D_NEEDGIANT	0x00400000	/* driver want Giant */
 #define	D_NEEDMINOR	0x00800000	/* driver uses clone_create() */
+#define	D_UNMAPPED_IO   0x01000000	/* d_strategy can accept unmapped IO */
 
 /*
  * Version numbers.



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