libafs: Flush vcaches in afs_shutdown
[openafs.git] / src / afs / SOLARIS / osi_vfsops.c
index d090111..dbc76ab 100644 (file)
@@ -71,6 +71,18 @@ afs_mount(struct vfs *afsp, struct vnode *amvp, struct mounta *uap,
     return 0;
 }
 
+static void
+afs_freevfs(void)
+{
+    int i;
+    struct vcache *vc, *nvc;
+    extern struct vcache *afs_vhashT[VCSIZE];
+
+    afs_globalVFS = 0;
+
+    afs_shutdown();
+}
+
 #if defined(AFS_SUN58_ENV)
 int
 afs_unmount(struct vfs *afsp, int flag, afs_ucred_t *credp)
@@ -123,9 +135,8 @@ afs_unmount(struct vfs *afsp, afs_ucred_t *credp)
     AFS_RELE(rootvp);
 
 #ifndef AFS_SUN58_ENV
-    /* shutdown now, since afs_freevfs() will not be called */
-    afs_globalVFS = 0;
-    afs_shutdown();
+    /* shutdown now, since gafs_freevfs() will not be called */
+    afs_freevfs();
 #endif /* !AFS_SUN58_ENV */
 
     AFS_GUNLOCK();
@@ -134,12 +145,11 @@ afs_unmount(struct vfs *afsp, afs_ucred_t *credp)
 
 #ifdef AFS_SUN58_ENV
 void
-afs_freevfs(struct vfs *afsp)
+gafs_freevfs(struct vfs *afsp)
 {
     AFS_GLOCK();
 
-    afs_globalVFS = 0;
-    afs_shutdown();
+    afs_freevfs();
 
     AFS_GUNLOCK();
 }
@@ -148,9 +158,9 @@ afs_freevfs(struct vfs *afsp)
 int
 afs_root(struct vfs *afsp, struct vnode **avpp)
 {
-    register afs_int32 code = 0;
+    afs_int32 code = 0;
     struct vrequest treq;
-    register struct vcache *tvp = 0;
+    struct vcache *tvp = 0;
     struct vcache *gvp;
     struct proc *proc = ttoproc(curthread);
     struct vnode *vp = afsp->vfs_vnodecovered;
@@ -200,7 +210,7 @@ again:
        }
     }
     if (tvp) {
-       VN_HOLD(AFSTOV(tvp));
+       AFS_FAST_HOLD(tvp);
        mutex_enter(&AFSTOV(tvp)->v_lock);
        AFSTOV(tvp)->v_flag |= VROOT;
        mutex_exit(&AFSTOV(tvp)->v_lock);
@@ -315,7 +325,7 @@ static const fs_operation_def_t afs_vfsops_template[] = {
     VFSNAME_SYNC,              { .vfs_sync = afs_sync },
     VFSNAME_VGET,              { .vfs_vget = afs_vget },
     VFSNAME_MOUNTROOT,         { .vfs_mountroot = afs_mountroot },
-    VFSNAME_FREEVFS,           { .vfs_freevfs = afs_freevfs },
+    VFSNAME_FREEVFS,           { .vfs_freevfs = gafs_freevfs },
     NULL,                      NULL
 };
 struct vfsops *afs_vfsopsp;
@@ -329,7 +339,7 @@ const fs_operation_def_t afs_vfsops_template[] = {
     VFSNAME_SYNC,              afs_sync,
     VFSNAME_VGET,              afs_vget,
     VFSNAME_MOUNTROOT,         afs_mountroot,
-    VFSNAME_FREEVFS,           afs_freevfs,
+    VFSNAME_FREEVFS,           gafs_freevfs,
     NULL,                      NULL
 };
 struct vfsops *afs_vfsopsp;
@@ -344,7 +354,7 @@ struct vfsops Afs_vfsops = {
     afs_mountroot,
     afs_swapvp,
 #if defined(AFS_SUN58_ENV)
-    afs_freevfs,
+    gafs_freevfs,
 #endif
 };
 #endif
@@ -490,11 +500,13 @@ static struct vfssw afs_vfw = {
 };
 #endif
 
+#ifndef AFS_SUN511_ENV
 static struct sysent afssysent = {
     6,
     0,
     Afs_syscall
 };
+#endif /* AFS_SUN511_ENV */
 
 /* inter-module dependencies */
 char _depends_on[] = "drv/ip drv/udp strmod/rpcmod";
@@ -503,7 +515,6 @@ char _depends_on[] = "drv/ip drv/udp strmod/rpcmod";
  * Info/Structs to link the afs module into the kernel
  */
 extern struct mod_ops mod_fsops;
-extern struct mod_ops mod_syscallops;
 
 static struct modlfs afsmodlfs = {
     &mod_fsops,
@@ -515,6 +526,13 @@ static struct modlfs afsmodlfs = {
 #endif
 };
 
+#ifdef AFS_SUN511_ENV
+
+extern struct modldrv afs_modldrv;
+
+#else /* AFS_SUN511_ENV */
+
+extern struct mod_ops mod_syscallops;
 static struct modlsys afsmodlsys = {
     &mod_syscallops,
     "afs syscall interface",
@@ -530,7 +548,7 @@ static struct modlsys afsmodlsys = {
   * land here from sysent or sysent32
   */
 
-#if defined(AFS_SUN57_64BIT_ENV)
+# if defined(AFS_SUN57_64BIT_ENV)
 extern struct mod_ops mod_syscallops32;
 
 static struct modlsys afsmodlsys32 = {
@@ -538,16 +556,21 @@ static struct modlsys afsmodlsys32 = {
     "afs syscall interface(32 bit)",
     &afssysent
 };
-#endif
+# endif
+#endif /* !AFS_SUN511_ENV */
 
 
 static struct modlinkage afs_modlinkage = {
     MODREV_1,
+    (void *)&afsmodlfs,
+#ifdef AFS_SUN511_ENV
+    (void *)&afs_modldrv,
+#else
     (void *)&afsmodlsys,
-#ifdef AFS_SUN57_64BIT_ENV
+# ifdef AFS_SUN57_64BIT_ENV
     (void *)&afsmodlsys32,
-#endif
-    (void *)&afsmodlfs,
+# endif
+#endif /* !AFS_SUN511_ENV */
     NULL
 };
 
@@ -581,7 +604,8 @@ _init()
 #if     defined(AFS_SUN55_ENV)
     if ((!(mp = mod_find_by_filename("misc", "nfssrv"))
         && !(mp = mod_find_by_filename(NULL, NFSSRV))
-        && !(mp = mod_find_by_filename(NULL, NFSSRV_V9))) || (mp
+        && !(mp = mod_find_by_filename(NULL, NFSSRV_V9))
+        && !(mp = mod_find_by_filename(NULL, NFSSRV_AMD64))) || (mp
                                                               && !mp->
                                                               mod_installed))
     {
@@ -604,7 +628,11 @@ _init()
 #endif /* AFS_SUN52_ENV */
 #endif /* AFS_SUN55_ENV */
 #endif /* !AFS_NONFSTRANS */
-#if !defined(AFS_SUN58_ENV)
+
+#ifndef AFS_SUN511_ENV
+    /* syscall initialization stff */
+
+# if !defined(AFS_SUN58_ENV)
     /* 
      * Re-read the /etc/name_to_sysnum file to make sure afs isn't added after
      * reboot.  Ideally we would like to call modctl_read_sysbinding_file() but
@@ -614,14 +642,14 @@ _init()
      * proper slot entry and we also actually have to properly initialize the
      * global sysent[AFS_SYSCALL] entry!
      */
-#ifdef AFS_SUN53_ENV
-#ifndef        SYSBINDFILE
-#define        SYSBINDFILE     "/etc/name_to_sysnum"
-#endif /* SYSBINDFILE */
+#  ifdef       AFS_SUN53_ENV
+#   ifndef     SYSBINDFILE
+#    define    SYSBINDFILE     "/etc/name_to_sysnum"
+#   endif /* SYSBINDFILE */
     read_binding_file(SYSBINDFILE, sb_hashtab);
-#else /* !AFS_SUN53_ENV */
+#  else /* !AFS_SUN53_ENV */
     read_binding_file(sysbind, sb_hashtab);
-#endif /* AFS_SUN53_ENV */
+#  endif /* AFS_SUN53_ENV */
     make_syscallname("afs", AFS_SYSCALL);
 
     if (sysent[AFS_SYSCALL].sy_call == nosys) {
@@ -629,14 +657,15 @@ _init()
            sysent[AFS_SYSCALL].sy_lock =
                (krwlock_t *) kobj_zalloc(sizeof(krwlock_t), KM_SLEEP);
            rw_init(sysent[AFS_SYSCALL].sy_lock, "afs_syscall",
-#ifdef AFS_SUN57_ENV
+#  ifdef AFS_SUN57_ENV
                    RW_DEFAULT, NULL);
-#else /* !AFS_SUN57_ENV */
+#  else /* !AFS_SUN57_ENV */
                    RW_DEFAULT, DEFAULT_WT);
-#endif /* AFS_SUN57_ENV */
+#  endif /* AFS_SUN57_ENV */
        }
     }
-#endif /* !AFS_SUN58_ENV */
+# endif /* !AFS_SUN58_ENV */
+#endif /* !AFS_SUN511_ENV */
 
     osi_Init();                        /* initialize global lock, etc */