Author: rmacklem
Date: Thu Mar  8 02:27:29 2012
New Revision: 232682
URL: http://svn.freebsd.org/changeset/base/232682

Log:
  MFC: r232327
  Fix the NFS clients so that they use copyin() instead of bcopy(),
  when doing direct I/O. This direct I/O code is not enabled by default.

Modified:
  stable/9/sys/fs/nfsclient/nfs_clbio.c
  stable/9/sys/nfsclient/nfs_bio.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)

Modified: stable/9/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clbio.c       Thu Mar  8 02:00:52 2012        
(r232681)
+++ stable/9/sys/fs/nfsclient/nfs_clbio.c       Thu Mar  8 02:27:29 2012        
(r232682)
@@ -820,7 +820,21 @@ do_sync:
                        t_uio->uio_segflg = UIO_SYSSPACE;
                        t_uio->uio_rw = UIO_WRITE;
                        t_uio->uio_td = td;
-                       bcopy(uiop->uio_iov->iov_base, t_iov->iov_base, size);
+                       KASSERT(uiop->uio_segflg == UIO_USERSPACE ||
+                           uiop->uio_segflg == UIO_SYSSPACE,
+                           ("nfs_directio_write: Bad uio_segflg"));
+                       if (uiop->uio_segflg == UIO_USERSPACE) {
+                               error = copyin(uiop->uio_iov->iov_base,
+                                   t_iov->iov_base, size);
+                               if (error != 0)
+                                       goto err_free;
+                       } else
+                               /*
+                                * UIO_SYSSPACE may never happen, but handle
+                                * it just in case it does.
+                                */
+                               bcopy(uiop->uio_iov->iov_base, t_iov->iov_base,
+                                   size);
                        bp->b_flags |= B_DIRECT;
                        bp->b_iocmd = BIO_WRITE;
                        if (cred != NOCRED) {
@@ -831,6 +845,7 @@ do_sync:
                        bp->b_caller1 = (void *)t_uio;
                        bp->b_vp = vp;
                        error = ncl_asyncio(nmp, bp, NOCRED, td);
+err_free:
                        if (error) {
                                free(t_iov->iov_base, M_NFSDIRECTIO);
                                free(t_iov, M_NFSDIRECTIO);

Modified: stable/9/sys/nfsclient/nfs_bio.c
==============================================================================
--- stable/9/sys/nfsclient/nfs_bio.c    Thu Mar  8 02:00:52 2012        
(r232681)
+++ stable/9/sys/nfsclient/nfs_bio.c    Thu Mar  8 02:27:29 2012        
(r232682)
@@ -814,7 +814,21 @@ do_sync:
                        t_uio->uio_segflg = UIO_SYSSPACE;
                        t_uio->uio_rw = UIO_WRITE;
                        t_uio->uio_td = td;
-                       bcopy(uiop->uio_iov->iov_base, t_iov->iov_base, size);
+                       KASSERT(uiop->uio_segflg == UIO_USERSPACE ||
+                           uiop->uio_segflg == UIO_SYSSPACE,
+                           ("nfs_directio_write: Bad uio_segflg"));
+                       if (uiop->uio_segflg == UIO_USERSPACE) {
+                               error = copyin(uiop->uio_iov->iov_base,
+                                   t_iov->iov_base, size);
+                               if (error != 0)
+                                       goto err_free;
+                       } else
+                               /*
+                                * UIO_SYSSPACE may never happen, but handle
+                                * it just in case it does.
+                                */
+                               bcopy(uiop->uio_iov->iov_base, t_iov->iov_base,
+                                   size);
                        bp->b_flags |= B_DIRECT;
                        bp->b_iocmd = BIO_WRITE;
                        if (cred != NOCRED) {
@@ -825,6 +839,7 @@ do_sync:
                        bp->b_caller1 = (void *)t_uio;
                        bp->b_vp = vp;
                        error = nfs_asyncio(nmp, bp, NOCRED, td);
+err_free:
                        if (error) {
                                free(t_iov->iov_base, M_NFSDIRECTIO);
                                free(t_iov, M_NFSDIRECTIO);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to