changeset 13928:2e1fa548c4ab

nfs4x: Introduce new functions rfs4x_compound_state_[alloc/free]. The functions are going to be used as a universal function for allocation/releasing of compound state structure for both NFS4.0 and NFS4.1
author Dan Kruchinin <dan.kruchinin@nexenta.com>
date Thu, 25 Aug 2011 17:42:09 +0300
parents 510d3c00268f
children ed4988bf8ee1
files usr/src/uts/common/fs/nfs/nfs4x_srv_common.c usr/src/uts/common/nfs/nfs4.h
diffstat 2 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/nfs/nfs4x_srv_common.c	Thu Aug 25 17:42:09 2011 +0300
+++ b/usr/src/uts/common/fs/nfs/nfs4x_srv_common.c	Thu Aug 25 17:42:09 2011 +0300
@@ -20,6 +20,64 @@
 	    NULL, NULL, 0);
 }
 
+compound_state_t *
+rfs4x_compound_state_alloc(nfs_server_instance_t *instp, int minorvers)
+{
+	compound_state_t *cs;
+
+	cs = kmem_cache_alloc(rfs4x_compound_state_cache, KM_SLEEP);
+	cs->instp = instp;
+	cs->cont = TRUE;
+	cs->fh.nfs_fh4_val = cs->fhbuf;
+	cs->access = CS_ACCESS_DENIED;
+
+	switch (minorvers) {
+	case NFS4_MINOR_v0:
+	case NFS4_MINOR_v1:
+		break;
+	default:
+		VERIFY(0);
+	}
+
+	cs->minorversion = minorvers;
+	return (cs);
+}
+
+void
+rfs4x_compound_state_free(compound_state_t *cs)
+{
+	if (cs->vp) {
+		VN_RELE(cs->vp);
+		cs->vp = NULL;
+	}
+	if (cs->saved_vp) {
+		VN_RELE(cs->saved_vp);
+		cs->saved_vp = NULL;
+	}
+	if (cs->cr) {
+		crfree(cs->cr);
+		cs->cr = NULL;
+	}
+	if (cs->saved_fh.nfs_fh4_val) {
+		kmem_free(cs->saved_fh.nfs_fh4_val, NFS4_FHSIZE);
+		cs->saved_fh.nfs_fh4_val = NULL;
+	}
+	if (cs->basecr) {
+		crfree(cs->basecr);
+		cs->basecr = NULL;
+	}
+	if (cs->sp) {
+		rfs41_session_rele(cs->sp);
+		if (cs->cp)
+			rfs4_client_rele(cs->cp);
+
+		cs->sp = NULL;
+		cs->cp = NULL;
+	}
+
+	kmem_cache_free(rfs4x_compound_state_cache, cs);
+}
+
 /*ARGSUSED*/
 static int
 rfs4x_compound_state_construct(void *buf, void *cdrarg, int kmflags)
--- a/usr/src/uts/common/nfs/nfs4.h	Thu Aug 25 17:42:09 2011 +0300
+++ b/usr/src/uts/common/nfs/nfs4.h	Thu Aug 25 17:42:09 2011 +0300
@@ -1452,6 +1452,9 @@
 extern void rfs4_cs_invalidate_fh(compound_state_t *cs);
 extern void rfs4_cs_invalidate_savedfh(compound_state_t *cs);
 extern	compound_state_t *
+    rfs4x_compound_state_alloc(nfs_server_instance_t *, int);
+void rfs4x_compound_state_free(compound_state_t *);
+extern	compound_state_t *
     rfs41_compound_state_alloc(nfs_server_instance_t *);
 extern	void rfs41_compound_state_free(compound_state_t *);
 extern	rfs4_state_t	*rfs4_findstate_by_owner_file(