Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Feb 2012 03:32:29 +0000 (UTC)
From:      Rick Macklem <rmacklem@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: r231330 - in stable/9/sys: fs/nfsclient nfsclient
Message-ID:  <201202100332.q1A3WTom051545@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Fri Feb 10 03:32:29 2012
New Revision: 231330
URL: http://svn.freebsd.org/changeset/base/231330

Log:
  MFC: r230605
  A problem with respect to data read through the buffer cache for both
  NFS clients was reported to freebsd-fs@ under the subject "NFS
  corruption in recent HEAD" on Nov. 26, 2011. This problem occurred when
  a TCP mounted root fs was changed to using UDP. I believe that this
  problem was caused by the change in mnt_stat.f_iosize that occurred
  because rsize was decreased to the maximum supported by UDP. This
  patch fixes the problem by using v_bufobj.bo_bsize instead of f_iosize,
  since the latter is set to f_iosize when the vnode is allocated, but
  does not change for a given vnode when f_iosize changes.

Modified:
  stable/9/sys/fs/nfsclient/nfs_clbio.c
  stable/9/sys/fs/nfsclient/nfs_clnode.c
  stable/9/sys/fs/nfsclient/nfs_clport.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)

Modified: stable/9/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clbio.c	Fri Feb 10 03:30:57 2012	(r231329)
+++ stable/9/sys/fs/nfsclient/nfs_clbio.c	Fri Feb 10 03:32:29 2012	(r231330)
@@ -480,7 +480,7 @@ ncl_bioread(struct vnode *vp, struct uio
 		/* No caching/ no readaheads. Just read data into the user buffer */
 		return ncl_readrpc(vp, uio, cred);
 
-	biosize = vp->v_mount->mnt_stat.f_iosize;
+	biosize = vp->v_bufobj.bo_bsize;
 	seqcount = (int)((off_t)(ioflag >> IO_SEQSHIFT) * biosize / BKVASIZE);
 	
 	error = nfs_bioread_check_cons(vp, td, cred);
@@ -960,7 +960,7 @@ flush_and_restart:
 	if (vn_rlimit_fsize(vp, uio, td))
 		return (EFBIG);
 
-	biosize = vp->v_mount->mnt_stat.f_iosize;
+	biosize = vp->v_bufobj.bo_bsize;
 	/*
 	 * Find all of this file's B_NEEDCOMMIT buffers.  If our writes
 	 * would exceed the local maximum per-file write commit size when
@@ -1264,12 +1264,8 @@ nfs_getcacheblk(struct vnode *vp, daddr_
 		bp = getblk(vp, bn, size, 0, 0, 0);
 	}
 
-	if (vp->v_type == VREG) {
-		int biosize;
-
-		biosize = mp->mnt_stat.f_iosize;
-		bp->b_blkno = bn * (biosize / DEV_BSIZE);
-	}
+	if (vp->v_type == VREG)
+		bp->b_blkno = bn * (vp->v_bufobj.bo_bsize / DEV_BSIZE);
 	return (bp);
 }
 
@@ -1785,7 +1781,7 @@ ncl_meta_setsize(struct vnode *vp, struc
 {
 	struct nfsnode *np = VTONFS(vp);
 	u_quad_t tsize;
-	int biosize = vp->v_mount->mnt_stat.f_iosize;
+	int biosize = vp->v_bufobj.bo_bsize;
 	int error = 0;
 
 	mtx_lock(&np->n_mtx);

Modified: stable/9/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clnode.c	Fri Feb 10 03:30:57 2012	(r231329)
+++ stable/9/sys/fs/nfsclient/nfs_clnode.c	Fri Feb 10 03:32:29 2012	(r231330)
@@ -136,6 +136,7 @@ ncl_nget(struct mount *mntp, u_int8_t *f
 		return (error);
 	}
 	vp = nvp;
+	KASSERT(vp->v_bufobj.bo_bsize != 0, ("ncl_nget: bo_bsize == 0"));
 	vp->v_bufobj.bo_ops = &buf_ops_newnfs;
 	vp->v_data = np;
 	np->n_vnode = vp;

Modified: stable/9/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clport.c	Fri Feb 10 03:30:57 2012	(r231329)
+++ stable/9/sys/fs/nfsclient/nfs_clport.c	Fri Feb 10 03:32:29 2012	(r231330)
@@ -212,6 +212,7 @@ nfscl_nget(struct mount *mntp, struct vn
 		return (error);
 	}
 	vp = nvp;
+	KASSERT(vp->v_bufobj.bo_bsize != 0, ("nfscl_nget: bo_bsize == 0"));
 	vp->v_bufobj.bo_ops = &buf_ops_newnfs;
 	vp->v_data = np;
 	np->n_vnode = vp;

Modified: stable/9/sys/nfsclient/nfs_bio.c
==============================================================================
--- stable/9/sys/nfsclient/nfs_bio.c	Fri Feb 10 03:30:57 2012	(r231329)
+++ stable/9/sys/nfsclient/nfs_bio.c	Fri Feb 10 03:32:29 2012	(r231330)
@@ -474,7 +474,7 @@ nfs_bioread(struct vnode *vp, struct uio
 		/* No caching/ no readaheads. Just read data into the user buffer */
 		return nfs_readrpc(vp, uio, cred);
 
-	biosize = vp->v_mount->mnt_stat.f_iosize;
+	biosize = vp->v_bufobj.bo_bsize;
 	seqcount = (int)((off_t)(ioflag >> IO_SEQSHIFT) * biosize / BKVASIZE);
 	
 	error = nfs_bioread_check_cons(vp, td, cred);
@@ -951,7 +951,7 @@ flush_and_restart:
 	if (vn_rlimit_fsize(vp, uio, td))
 		return (EFBIG);
 
-	biosize = vp->v_mount->mnt_stat.f_iosize;
+	biosize = vp->v_bufobj.bo_bsize;
 	/*
 	 * Find all of this file's B_NEEDCOMMIT buffers.  If our writes
 	 * would exceed the local maximum per-file write commit size when
@@ -1255,12 +1255,8 @@ nfs_getcacheblk(struct vnode *vp, daddr_
 		bp = getblk(vp, bn, size, 0, 0, 0);
 	}
 
-	if (vp->v_type == VREG) {
-		int biosize;
-
-		biosize = mp->mnt_stat.f_iosize;
-		bp->b_blkno = bn * (biosize / DEV_BSIZE);
-	}
+	if (vp->v_type == VREG)
+		bp->b_blkno = bn * (vp->v_bufobj.bo_bsize / DEV_BSIZE);
 	return (bp);
 }
 
@@ -1767,7 +1763,7 @@ nfs_meta_setsize(struct vnode *vp, struc
 {
 	struct nfsnode *np = VTONFS(vp);
 	u_quad_t tsize;
-	int biosize = vp->v_mount->mnt_stat.f_iosize;
+	int biosize = vp->v_bufobj.bo_bsize;
 	int error = 0;
 
 	mtx_lock(&np->n_mtx);



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