PERFORCE change 180436 for review

Efstratios Karatzas gpf at FreeBSD.org
Sat Jul 3 14:52:52 UTC 2010


http://p4web.freebsd.org/@@180436?ac=10

Change 180436 by gpf at gpf_desktop on 2010/07/03 14:52:47

	- make putroofh & putpubfh actually replace the current fh
	- provide a cleaner/better implementation of getfh
	- remove an __unused marker
	- relocate AUDIT_NFS_EXIT() so that we auditing the final error code

Affected files ...

.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nfsserver/nfs_nfsdserv.c#8 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nfsserver/nfs_nfsdsocket.c#11 edit

Differences ...

==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nfsserver/nfs_nfsdserv.c#8 (text+ko) ====

@@ -2455,7 +2455,7 @@
  */
 APPLESTATIC int
 nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram,
-    vnode_t dp, vnode_t *vpp, __unused fhandle_t *fhp, NFSPROC_T *p,
+    vnode_t dp, vnode_t *vpp, fhandle_t *fhp, NFSPROC_T *p,
     struct nfsexstuff *exp)
 {
 	u_int32_t *tl;

==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nfsserver/nfs_nfsdsocket.c#11 (text+ko) ====

@@ -539,7 +539,6 @@
 	struct ucred *credanon;
 	struct nfsexstuff nes, vpnes, savevpnes;
 	static u_int64_t compref = 0;
-	int rootfhflag = 0, pubfhflag = 0;
 
 	NFSVNO_EXINIT(&vpnes);
 	NFSVNO_EXINIT(&savevpnes);
@@ -771,7 +770,6 @@
 			}
 			break;
 		case NFSV4OP_PUTPUBFH:
-			pubfhflag = 1;
 			if (nfs_pubfhset) {
 			    nes.nes_vfslocked = vpnes.nes_vfslocked;
 			    nfsd_fhtovp(nd, &nfs_pubfh, &nvp,
@@ -790,12 +788,11 @@
 						(fhandle_t *)nfs_pubfh.nfsrvfh_data, 1);
 				vrele(vp);
 				vpnes = nes;
+				NFSBCOPY(&nfs_pubfh, &fh, sizeof(fh));
 			}
 			break;
 		case NFSV4OP_PUTROOTFH:
-			rootfhflag = 1;
 			if (nfs_rootfhset) {
-				printf("mpkha sto prwto\n");
 				nes.nes_vfslocked = vpnes.nes_vfslocked;
 				nfsd_fhtovp(nd, &nfs_rootfh, &nvp,
 				    &nes, &mp, 0, p);
@@ -810,9 +807,9 @@
 						(fhandle_t *)nfs_rootfh.nfsrvfh_data, 1);
 					vrele(vp);
 					vpnes = nes;
+					NFSBCOPY(&nfs_rootfh, &fh, sizeof(fh));
 				}
 			} else if (nfsv4root_vp && nfsv4root_set) {
-				printf("mpkha sto deytero\n");
 				if (vp) {
 					if (vpnes.nes_vfslocked)
 						nfsvno_unlockvfs(mp);
@@ -823,6 +820,7 @@
 				NFSVNO_SETEXRDONLY(&vpnes);
 				vpnes.nes_vfslocked = 0;
 				mp = vnode_mount(vp);
+				NFSBCOPY(&nfs_rootfh, &fh, sizeof(fh));
 			} else {
 				nd->nd_repstat = NFSERR_NOFILEHANDLE;
 			}
@@ -887,6 +885,21 @@
 				nd->nd_repstat = NFSERR_RESTOREFH;
 			}
 			break;
+		/* 
+		 * XXXgpf: 
+		 * NFSV4OP_GETFH hack so that current filehandle, with the hint stored inside,
+		 * is returned instead of recomputing the filehandle and losing the hint.
+		 * All NFS v4 OPs that are supposed to replace the current filehandle, now do so:
+		 * putroofh, putpubfh, open, mknod, lookup, lookupp, putfh
+		 */	
+		case NFSV4OP_GETFH: 
+			if (vp == NULL)
+				error = nd->nd_repstat = NFSERR_NOFILEHANDLE;
+			else {
+				(void) nfsm_fhtom(nd, (u_int8_t *)fh.nfsrvfh_data, 0, 0);
+				error = nd->nd_repstat = 0;
+			}
+			break;
 		default:
 		    /*
 		     * Allow a Lookup, Getattr, GetFH, Secinfo on an
@@ -1023,27 +1036,8 @@
 					}
 					break;
 				}
-				/* 
-				 * XXXgpf: 
-				 * NFSV4OP_GETFH hack so that current filehandle, with the hint stored inside,
-				 * is returned instead of recomputing the filehandle and losing the hint.
-				 */
-				if (op == NFSV4OP_GETFH) {
-					fhandle_t * fhp;
-
-					vput(vp);
-					if (rootfhflag)
-						fhp = (fhandle_t *)nfs_rootfh.nfsrvfh_data;
-					else if (pubfhflag)
-						fhp = (fhandle_t *)nfs_pubfh.nfsrvfh_data;
-					else 
-						fhp = (fhandle_t *)fh.nfsrvfh_data;
-					(void) nfsm_fhtom(nd, (u_int8_t *)fhp, 0, 0);
-					error = 0;
-				}
-				else
-					error = (*(nfsrv4_ops0[op]))(nd, isdgram, vp,
-						p, &vpnes);
+				error = (*(nfsrv4_ops0[op]))(nd, isdgram, vp,
+					p, &vpnes);
 				if (nfsv4_opflag[op].modifyfs)
 					NFS_ENDWRITE(mp);
 			} else {
@@ -1051,8 +1045,7 @@
 				    NULL, p, &vpnes);
 			}
 		    }
-		};
-		AUDIT_NFS_EXIT(nd->nd_repstat, curthread);
+		};		
 		if (error) {
 			if (error == EBADRPC || error == NFSERR_BADXDR) {
 				nd->nd_repstat = NFSERR_BADXDR;
@@ -1062,6 +1055,7 @@
 			}
 			error = 0;
 		}
+		AUDIT_NFS_EXIT(nd->nd_repstat, curthread);
 		retops++;
 		if (nd->nd_repstat) {
 			*repp = nfsd_errmap(nd);


More information about the p4-projects mailing list