linux-warning-reduction-20090318
[openafs.git] / src / afs / afs_init.c
index b2503ae..fd79310 100644 (file)
@@ -39,11 +39,16 @@ char *afs_sysname = 0;              /* So that superuser may change the
                                 * local value of @sys */
 char *afs_sysnamelist[MAXNUMSYSNAMES]; /* For support of a list of sysname */
 int afs_sysnamecount = 0;
+int afs_sysnamegen = 0;
 struct volume *Initialafs_freeVolList;
 int afs_memvolumes = 0;
 #if defined(AFS_XBSD_ENV)
 static struct vnode *volumeVnode;
 #endif
+#if defined(AFS_DISCON_ENV)
+afs_rwlock_t afs_discon_lock;
+extern afs_rwlock_t afs_disconDirtyLock;
+#endif
 
 /*
  * Initialization order is important.  Must first call afs_CacheInit,
@@ -108,7 +113,13 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
     usedihint = 0;
 
     LOCK_INIT(&afs_ftf, "afs_ftf");
-    RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
+    AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
+#ifdef AFS_DISCON_ENV
+    AFS_RWLOCK_INIT(&afs_discon_lock, "afs_discon_lock");
+    AFS_RWLOCK_INIT(&afs_disconDirtyLock, "afs_disconDirtyLock");
+    QInit(&afs_disconDirty);
+    QInit(&afs_disconShadow);
+#endif
     osi_dnlc_init();
 
     /* 
@@ -116,8 +127,8 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
      */
     if (aVolumes < 50)
        aVolumes = 50;
-    else if (aVolumes > 3000)
-       aVolumes = 3000;
+    else if (aVolumes > 32767)
+       aVolumes = 32767;
 
     tv = (struct volume *)afs_osi_Alloc(aVolumes * sizeof(struct volume));
     for (i = 0; i < aVolumes - 1; i++)
@@ -241,11 +252,25 @@ LookupInodeByPath(char *filename, ino_t * inode, struct vnode **fvpp)
 int
 afs_InitCellInfo(char *afile)
 {
-    ino_t inode;
+    ino_t inode = 0;
     int code;
+#if defined(LINUX_USE_FH)
+    struct fid fh;
+    int fh_type;
+    int max_len = sizeof(struct fid);
+    struct dentry *dp;
+#endif
 
+#ifdef AFS_CACHE_VNODE_PATH
+    return afs_cellname_init(AFS_CACHE_CELLS_INODE, code);
+#elif defined(LINUX_USE_FH)
+    code = gop_lookupname(afile, AFS_UIOSYS, 0, &dp);
+    fh_type = osi_get_fh(dp, &fh, &max_len);
+    return afs_cellname_init(&fh, fh_type, code);
+#else
     code = LookupInodeByPath(afile, &inode, NULL);
     return afs_cellname_init(inode, code);
+#endif
 }
 
 /*
@@ -269,6 +294,10 @@ afs_InitVolumeInfo(char *afile)
 {
     int code;
     struct osi_file *tfile;
+#if defined(LINUX_USE_FH)
+    int max_len = sizeof(struct fid);
+    struct dentry *dp;
+#endif
 
     AFS_STATCNT(afs_InitVolumeInfo);
 #if defined(AFS_XBSD_ENV)
@@ -286,12 +315,21 @@ afs_InitVolumeInfo(char *afile)
      * it in the cache...
      */
     code = LookupInodeByPath(afile, &volumeInode, &volumeVnode);
+#elif defined(AFS_CACHE_VNODE_PATH)
+    volumeInode = AFS_CACHE_VOLUME_INODE;
+#elif defined(LINUX_USE_FH)
+    code = gop_lookupname(afile, AFS_UIOSYS, 0, &dp);
+    volumeinfo_fh_type = osi_get_fh(dp, &volumeinfo_fh, &max_len);
 #else
     code = LookupInodeByPath(afile, &volumeInode, NULL);
 #endif
     if (code)
        return code;
+#if defined(LINUX_USE_FH)
+    tfile = osi_UFSOpen_fh(&volumeinfo_fh, volumeinfo_fh_type);
+#else
     tfile = afs_CFileOpen(volumeInode);
+#endif
     afs_CFileTruncate(tfile, 0);
     afs_CFileClose(tfile);
     return 0;
@@ -416,15 +454,23 @@ afs_InitCacheInfo(register char *afile)
 #if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
     afs_InitDualFSCacheOps(filevp);
 #endif
-    cacheInode = afs_vnodeToInumber(filevp);
-    cacheDev.dev = afs_vnodeToDev(filevp);
+#ifndef AFS_CACHE_VNODE_PATH
 #ifndef AFS_DARWIN80_ENV
     afs_cacheVfsp = filevp->v_vfsp;
 #endif
+    cacheInode = afs_vnodeToInumber(filevp);
+#else
+    cacheInode = AFS_CACHE_ITEMS_INODE;
+#endif
+    cacheDev.dev = afs_vnodeToDev(filevp);
 #endif /* AFS_LINUX20_ENV */
     AFS_RELE(filevp);
 #endif /* AFS_LINUX22_ENV */
+#if defined(LINUX_USE_FH)
+    tfile = osi_UFSOpen_fh(&cacheitems_fh, cacheitems_fh_type);
+#else
     tfile = osi_UFSOpen(cacheInode);
+#endif
     afs_osi_Stat(tfile, &tstat);
     cacheInfoModTime = tstat.mtime;
     code = afs_osi_Read(tfile, -1, &theader, sizeof(theader));
@@ -467,18 +513,18 @@ afs_ResourceInit(int preallocs)
     static struct rx_securityClass *secobj;
 
     AFS_STATCNT(afs_ResourceInit);
-    RWLOCK_INIT(&afs_xuser, "afs_xuser");
-    RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
-    RWLOCK_INIT(&afs_xserver, "afs_xserver");
-    RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr");
-    RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
-    RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
+    AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
+    AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
+    AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
+    AFS_RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr");
+    AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
+    AFS_RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
     LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
 #ifndef AFS_FBSD_ENV
     LOCK_INIT(&osi_fsplock, "osi_fsplock");
     LOCK_INIT(&osi_flplock, "osi_flplock");
 #endif
-    RWLOCK_INIT(&afs_xconn, "afs_xconn");
+    AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
 
     afs_CellInit();
     afs_InitCBQueue(1);                /* initialize callback queues */
@@ -492,6 +538,7 @@ afs_ResourceInit(int preallocs)
        afs_sysname = afs_sysnamelist[0];
        strcpy(afs_sysname, SYS_NAME);
        afs_sysnamecount = 1;
+       afs_sysnamegen++;
     }
 
     secobj = rxnull_NewServerSecurityObject();
@@ -648,8 +695,9 @@ shutdown_cache(void)
            cacheDev.held_vnode = NULL;
        }
 #endif
+#if !defined(LINUX_USE_FH)
        cacheInode = volumeInode = (ino_t) 0;
-
+#endif
        cacheInfoModTime = 0;
 
        afs_fsfragsize = 1023;
@@ -747,7 +795,7 @@ shutdown_AFS(void)
         */
        {
            struct server *ts, *nts;
-           struct conn *tc, *ntc;
+           struct afs_conn *tc, *ntc;
            register struct afs_cbr *tcbrp, *tbrp;
 
            for (i = 0; i < NSERVERS; i++) {
@@ -764,7 +812,7 @@ shutdown_AFS(void)
                                AFS_GUNLOCK();
                                rx_DestroyConnection(tc->id);
                                AFS_GLOCK();
-                               afs_osi_Free(tc, sizeof(struct conn));
+                               afs_osi_Free(tc, sizeof(struct afs_conn));
                                tc = ntc;
                            }
                        }
@@ -794,11 +842,11 @@ shutdown_AFS(void)
        afs_waitForever = afs_waitForeverCount = 0;
        afs_FVIndex = -1;
        afs_server = (struct rx_service *)0;
-       RWLOCK_INIT(&afs_xconn, "afs_xconn");
+       AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
        memset((char *)&afs_rootFid, 0, sizeof(struct VenusFid));
-       RWLOCK_INIT(&afs_xuser, "afs_xuser");
-       RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
-       RWLOCK_INIT(&afs_xserver, "afs_xserver");
+       AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
+       AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
+       AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
        LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
 
        shutdown_cell();