From f8f10315d9ebecf32b5537a82aedde4c24b28d62 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 9 Aug 2017 20:06:05 -0500 Subject: [PATCH] SOLARIS: Switch non-embedded vnodes for Solaris 11 Newer updates to Solaris 11 have been including several changes to the vnode struct. Since we embed a vnode in our struct vcache, our kernel module must be recompiled for any such change in order for the openafs client to work at all. To avoid the need for this, switch Solaris to using a non-embedded vnode in our struct vcache. Follow a similar technique as is used in DARWIN and XBSD, where we allocate a vnode in osi_AttachVnode, and free it in afs_FlushVCache. Reviewed-on: https://gerrit.openafs.org/12696 Reviewed-by: Mark Vitale Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie Reviewed-by: Marcio Brito Barbosa Tested-by: Mark Vitale Reviewed-by: Benjamin Kaduk (cherry picked from commit 2aafe7df403e6a848185d15495139c07bced2758) Change-Id: I2f5b3e2b2b908ea9815fd7735a1abed511cec9cb Reviewed-on: https://gerrit.openafs.org/13528 Reviewed-by: Michael Meffie Reviewed-by: Andrew Deason Reviewed-by: Mark Vitale Reviewed-by: Cheyenne Wills Reviewed-by: Marcio Brito Barbosa Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/afs/SOLARIS/osi_vcache.c | 17 ++++++++++++++++- src/afs/VNOPS/afs_vnop_attrs.c | 2 +- src/afs/afs.h | 6 ++++-- src/afs/afs_osi.h | 6 +++--- src/afs/afs_osi_vm.c | 2 +- src/afs/afs_vcache.c | 8 +++++++- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/afs/SOLARIS/osi_vcache.c b/src/afs/SOLARIS/osi_vcache.c index 4c40a7417..78a1e2067 100644 --- a/src/afs/SOLARIS/osi_vcache.c +++ b/src/afs/SOLARIS/osi_vcache.c @@ -45,6 +45,7 @@ osi_PrePopulateVCache(struct vcache *avc) { rw_init(&avc->rwlock, "vcache rwlock", RW_DEFAULT, NULL); +#ifndef AFS_SUN511_ENV /* This is required if the kaio (kernel aynchronous io) ** module is installed. Inside the kernel, the function ** check_vp( common/os/aio.c) checks to see if the kernel has @@ -57,10 +58,24 @@ osi_PrePopulateVCache(struct vcache *avc) { ** for the time being, we fill up the v_data field with the ** vnode pointer itself. */ avc->v.v_data = (char *)avc; +#endif /* !AFS_SUN511_ENV */ } void -osi_AttachVnode(struct vcache *avc, int seq) { } +osi_AttachVnode(struct vcache *avc, int seq) +{ +#ifdef AFS_SUN511_ENV + struct vnode *vp; + + osi_Assert(AFSTOV(avc) == NULL); + + vp = vn_alloc(KM_SLEEP); + osi_Assert(vp != NULL); + + vp->v_data = avc; + AFSTOV(avc) = vp; +#endif +} void osi_PostPopulateVCache(struct vcache *avc) { diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index 26062d1b9..05a38ce96 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -93,7 +93,7 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) attrs->va_uid = fakedir ? 0 : avc->f.m.Owner; attrs->va_gid = fakedir ? 0 : avc->f.m.Group; /* yeah! */ #if defined(AFS_SUN5_ENV) - attrs->va_fsid = avc->v.v_vfsp->vfs_fsid.val[0]; + attrs->va_fsid = AFSTOV(avc)->v_vfsp->vfs_fsid.val[0]; #elif defined(AFS_DARWIN80_ENV) VATTR_RETURN(attrs, va_fsid, vfs_statfs(vnode_mount(AFSTOV(avc)))->f_fsid.val[0]); #elif defined(AFS_DARWIN_ENV) diff --git a/src/afs/afs.h b/src/afs/afs.h index bf2273dc9..e242e89be 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -716,6 +716,8 @@ struct SimpleLocks { #define CPSIZE 2 #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) #define vrefCount v->v_usecount +#elif defined(AFS_SUN511_ENV) +# define vrefCount v->v_count #else #define vrefCount v.v_count #endif /* AFS_XBSD_ENV */ @@ -763,7 +765,7 @@ struct nbvdata { }; #define VTOAFS(v) ((((struct nbvdata *)((v)->v_data)))->afsvc) #define AFSTOV(vc) ((vc)->v) -#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)) +#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_SUN511_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)) #define VTOAFS(v) ((struct vcache *)(v)->v_data) #define AFSTOV(vc) ((vc)->v) #else @@ -837,7 +839,7 @@ struct multiPage_range { * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree) */ struct vcache { -#if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)) +#if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_SUN511_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)) struct vnode *v; #else struct vnode v; /* Has reference count in v.v_count */ diff --git a/src/afs/afs_osi.h b/src/afs/afs_osi.h index af1c426be..5e21cfdd2 100644 --- a/src/afs/afs_osi.h +++ b/src/afs/afs_osi.h @@ -134,9 +134,9 @@ struct afs_osi_WaitHandle { * Darwin, all of the BSDs, and Linux have their own */ #if !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_LINUX20_ENV) -# define vType(vc) (vc)->v.v_type -# define vSetType(vc,type) (vc)->v.v_type = (type) -# define vSetVfsp(vc,vfsp) (vc)->v.v_vfsp = (vfsp) +# define vType(vc) AFSTOV(vc)->v_type +# define vSetType(vc,type) AFSTOV(vc)->v_type = (type) +# define vSetVfsp(vc,vfsp) AFSTOV(vc)->v_vfsp = (vfsp) extern struct vnodeops *afs_ops; # define IsAfsVnode(v) ((v)->v_op == afs_ops) # define SetAfsVnode(v) (v)->v_op = afs_ops diff --git a/src/afs/afs_osi_vm.c b/src/afs/afs_osi_vm.c index fa278cb40..1688c58ac 100644 --- a/src/afs/afs_osi_vm.c +++ b/src/afs/afs_osi_vm.c @@ -231,7 +231,7 @@ osi_VMDirty_p(struct vcache *avc) #if defined (AFS_SUN5_ENV) if (avc->f.states & CMAPPED) { struct page *pg; - for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) { + for (pg = AFSTOV(avc)->v_s.v_Pages; pg; pg = pg->p_vpnext) { if (pg->p_mod) { return 1; } diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index c34f2e194..a89c33084 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -243,7 +243,13 @@ afs_FlushVCache(struct vcache *avc, int *slept) AFSTOV(avc) = NULL; /* also drop the ptr to vnode */ } #endif -#ifdef AFS_SUN510_ENV + +#ifdef AFS_SUN511_ENV + if (avc->v) { + vn_free(avc->v); + avc->v = NULL; + } +#elif defined(AFS_SUN510_ENV) /* As we use private vnodes, cleanup is up to us */ vn_reinit(AFSTOV(avc)); #endif -- 2.39.5