Remove pininodes
[openafs.git] / src / afsd / afsd.c
index ec1879a..f8e3466 100644 (file)
   *    -confdir    The configuration directory .
   *    -nosettime  Don't keep checking the time to avoid drift (default).
   *     -settime    Keep checking the time to avoid drift.
+  *    -rxmaxmtu   Set the max mtu to help with VPN issues.
   *    -verbose     Be chatty.
+  *    -disable-dynamic-vcaches     Disable the use of -stat value as the starting size of
+  *                          the size of the vcache/stat cache pool, 
+  *                          but increase that pool dynamically as needed.
   *    -debug     Print out additional debugging info.
   *    -kerndev    [OBSOLETE] The kernel device for AFS.
   *    -dontfork   [OBSOLETE] Don't fork off as a new process.
   *     -dcache    The number of data cache entries.
   *     -biods     Number of bkg I/O daemons (AIX3.1 only)
   *    -prealloc  Number of preallocated "small" memory blocks
-  *     -pininodes Number of inodes which can be spared from inode[] for 
-  *                pointing at Vfiles.  If this is set too high, you may have
-  *                system problems, which can only be ameliorated by changing
-  *                NINODE (or equivalent) and rebuilding the kernel.
-  *               This option is now disabled.
   *    -logfile   [OBSOLETE] Place where to put the logfile (default in
   *                <cache>/etc/AFSLog.
   *    -waitclose make close calls always synchronous (slows em down, tho)
@@ -57,8 +56,9 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
+#ifdef IGNORE_SOME_GCC_WARNINGS
+# pragma GCC diagnostic warning "-Wdeprecated-declarations"
+#endif
 
 #define VFS 1
 
@@ -136,6 +136,7 @@ RCSID
 #include <ctype.h>
 #include <afs/afssyscalls.h>
 #include <afs/afsutil.h>
+#include <afs/sys_prototypes.h>
 
 #ifdef AFS_SGI61_ENV
 #include <unistd.h>
@@ -159,12 +160,13 @@ void set_staticaddrs(void);
 #include <sys/ioctl.h>
 #endif
 #include <mach/mach.h>
+#ifndef AFS_DARWIN100_ENV
 /* Symbols from the DiskArbitration framework */
 kern_return_t DiskArbStart(mach_port_t *);
 kern_return_t DiskArbDiskAppearedWithMountpointPing_auto(char *, unsigned int,
                                                         char *);
 #define DISK_ARB_NETWORK_DISK_FLAG 8
-
+#endif
 #include <mach/mach_port.h>
 #include <mach/mach_interface.h>
 #include <mach/mach_init.h>
@@ -317,12 +319,11 @@ static int enable_fakestat = 0;   /* enable fakestat support */
 static int enable_backuptree = 0;      /* enable backup tree support */
 static int enable_nomount = 0; /* do not mount */
 static int enable_splitcache = 0;
-#ifdef notdef
-static int inodes = 60;                /* VERY conservative, but has to be */
-#endif
+int afsd_dynamic_vcaches = 0;  /* Enable dynamic-vcache support */
 int afsd_verbose = 0;          /*Are we being chatty? */
 int afsd_debug = 0;            /*Are we printing debugging info? */
 int afsd_CloseSynch = 0;       /*Are closes synchronous or not? */
+int rxmaxmtu = 0;       /* Are we forcing a limit on the mtu? */
 
 #ifdef AFS_SGI62_ENV
 #define AFSD_INO_T ino64_t
@@ -614,7 +615,8 @@ ParseCacheInfoFile(void)
 int
 PartSizeOverflow(char *path, int cs)
 {
-    int bsize = -1, totalblks, mint;
+  int bsize = -1;
+  afs_int64 totalblks, mint;
 #if AFS_HAVE_STATVFS
     struct statvfs statbuf;
 
@@ -649,7 +651,7 @@ PartSizeOverflow(char *path, int cs)
     bsize = statbuf.f_bsize;
 #endif
     if (bsize == -1)
-       return 0;               /* sucess */
+       return 0;               /* success */
 
     /* now free and totalblks are in fragment units, but we want them in 1K units */
     if (bsize >= 1024) {
@@ -661,7 +663,7 @@ PartSizeOverflow(char *path, int cs)
     mint = totalblks / 100 * 95;
     if (cs > mint) {
        printf
-           ("Cache size (%d) must be less than 95%% of partition size (which is %d). Lower cache size\n",
+           ("Cache size (%d) must be less than 95%% of partition size (which is %lld). Lower cache size\n",
             cs, mint);
        return 1;
     }
@@ -979,6 +981,8 @@ doSweepAFSCache(int *vFilesFound,
 #ifdef AFS_SGI62_ENV
            printf("\tinode=%" AFS_INT64_FMT ", reclen=%d, name='%s'\n", currp->d_ino,
                   currp->d_reclen, currp->d_name);
+#elif defined(AFS_DFBSD_ENV)
+           printf("\tinode=%d, name='%s'\n", currp->d_ino, currp->d_name);
 #else
            printf("\tinode=%d, reclen=%d, name='%s'\n", currp->d_ino,
                   currp->d_reclen, currp->d_name);
@@ -1515,7 +1519,9 @@ mainproc(struct cmd_syndesc *as, void *arock)
     static char rn[] = "afsd"; /*Name of this routine */
     afs_int32 code;            /*Result of fork() */
     int i;
+#ifndef AFS_CACHE_VNODE_PATH
     int currVFile;             /*Current AFS cache file number passed in */
+#endif
     int mountFlags;            /*Flags passed to mount() */
     int lookupResult;          /*Result of GetLocalCellName() */
     int cacheIteration;                /*How many times through cache verification */
@@ -1626,12 +1632,6 @@ mainproc(struct cmd_syndesc *as, void *arock)
        /* -prealloc */
        preallocs = atoi(as->parms[16].items->data);
     }
-#ifdef notdef
-    if (as->parms[17].items) {
-       /* -pininodes */
-       inodes = atoi(as->parms[17].items->data);
-    }
-#endif
     strcpy(confDir, AFSDIR_CLIENT_ETC_DIRPATH);
     if (as->parms[17].items) {
        /* -confdir */
@@ -1747,6 +1747,31 @@ mainproc(struct cmd_syndesc *as, void *arock)
            }
        }
     }
+    if (as->parms[35].items) {
+#ifdef AFS_MAXVCOUNT_ENV
+       /* -disable-dynamic-vcaches */
+       afsd_dynamic_vcaches = FALSE;
+#else
+       printf("afsd: Error toggling flag, dynamically allocated vcaches not supported on your platform\n");
+       exit(1);
+#endif
+    }
+#ifdef AFS_MAXVCOUNT_ENV
+    else {
+       /* -dynamic-vcaches */
+       afsd_dynamic_vcaches = TRUE;
+    }
+
+    if (afsd_verbose)
+    printf("afsd: %s dynamically allocated vcaches\n", ( afsd_dynamic_vcaches ? "enabling" : "disabling" ));
+#endif
+
+    /* set -rxmaxmtu */
+    if (as->parms[35].items) {
+        /* -rxmaxmtu */
+        rxmaxmtu = atoi(as->parms[35].items->data);
+    }
+
     /*
      * Pull out all the configuration info for the workstation's AFS cache and
      * the cellular community we're willing to let our users see.
@@ -1935,7 +1960,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
     }
     memset(inode_for_V, '\0', (cacheFiles * sizeof(AFSD_INO_T)));
     if (afsd_debug)
-       printf("%s: %d inode_for_V entries at 0x%x, %d bytes\n", rn,
+       printf("%s: %d inode_for_V entries at 0x%x, %lu bytes\n", rn,
               cacheFiles, inode_for_V, (cacheFiles * sizeof(AFSD_INO_T)));
 #endif
 
@@ -2085,9 +2110,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
     cparams.chunkSize = chunkSize;
     cparams.setTimeFlag = cacheSetTime;
     cparams.memCacheFlag = cacheFlags;
-#ifdef notdef
-    cparams.inodes = inodes;
-#endif
+    cparams.dynamic_vcaches = afsd_dynamic_vcaches;
     call_syscall(AFSOP_CACHEINIT, &cparams);
 
     /* do it before we init the cache inodes */
@@ -2166,6 +2189,14 @@ mainproc(struct cmd_syndesc *as, void *arock)
               fullpn_CellInfoFile);
     call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile);
 
+    if (rxmaxmtu) {
+    if (afsd_verbose)
+        printf("%s: Setting rxmaxmtu in kernel = %d\n", rn, rxmaxmtu);
+    code = call_syscall(AFSOP_SET_RXMAXMTU, rxmaxmtu);
+    if (code)
+        printf("%s: Error seting rxmaxmtu\n", rn);
+    }
+
     if (enable_dynroot) {
        if (afsd_verbose)
            printf("%s: Enabling dynroot support in kernel.\n", rn);
@@ -2431,10 +2462,6 @@ main(int argc, char **argv)
 
     cmd_AddParm(ts, "-prealloc", CMD_SINGLE, CMD_OPTIONAL,
                "number of 'small' preallocated blocks");
-#ifdef notdef
-    cmd_AddParm(ts, "-pininodes", CMD_SINGLE, CMD_OPTIONAL,
-               "number of inodes to hog");
-#endif
     cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
                "configuration directory");
     cmd_AddParm(ts, "-logfile", CMD_SINGLE, CMD_OPTIONAL,
@@ -2473,7 +2500,10 @@ main(int argc, char **argv)
                "set rx_extraPackets to this value");
     cmd_AddParm(ts, "-splitcache", CMD_SINGLE, CMD_OPTIONAL,
                "Percentage RW versus RO in cache (specify as 60/40)");
-
+    cmd_AddParm(ts, "-disable-dynamic-vcaches", CMD_FLAG, CMD_OPTIONAL, 
+               "disable stat/vcache cache growing as needed");
+    cmd_AddParm(ts, "-rxmaxmtu", CMD_SINGLE, CMD_OPTIONAL, "set rx max MTU to use");
+    
     return (cmd_Dispatch(argc, argv));
 }
 
@@ -2551,6 +2581,7 @@ HandleMTab(void)
 #endif /* AFS_SUN5_ENV */
 #endif /* unreasonable systems */
 #ifdef AFS_DARWIN_ENV
+#ifndef AFS_DARWIN100_ENV
     mach_port_t diskarb_port;
     kern_return_t status;
 
@@ -2563,15 +2594,15 @@ HandleMTab(void)
     }
 
     return status;
+#endif
 #endif /* AFS_DARWIN_ENV */
     return 0;
 }
 
 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
-
 int
 call_syscall(long param1, long param2, long param3, long param4, long param5, 
-            long param6, long  param7)
+            long param6, long param7)
 {
     int error;
 #ifdef AFS_LINUX20_ENV
@@ -2599,22 +2630,51 @@ call_syscall(long param1, long param2, long param3, long param4, long param5,
 #endif
 #ifdef AFS_DARWIN80_ENV
     struct afssysargs syscall_data;
+    void *ioctldata;
     int fd = open(SYSCALL_DEV_FNAME,O_RDWR);
-    syscall_data.syscall = AFSCALL_CALL;
-    syscall_data.param1 = param1;
-    syscall_data.param2 = param2;
-    syscall_data.param3 = param3;
-    syscall_data.param4 = param4;
-    syscall_data.param5 = param5;
-    syscall_data.param6 = param6;
+    int syscallnum;
+#ifdef AFS_DARWIN100_ENV
+    int is64 = 0;
+    struct afssysargs64 syscall64_data;
+    if (sizeof(param1) == 8) {
+       syscallnum = VIOC_SYSCALL64;
+       is64 = 1;
+       ioctldata = &syscall64_data;
+       syscall64_data.syscall = (int)AFSCALL_CALL;
+       syscall64_data.param1 = param1;
+       syscall64_data.param2 = param2;
+       syscall64_data.param3 = param3;
+       syscall64_data.param4 = param4;
+       syscall64_data.param5 = param5;
+       syscall64_data.param6 = param6;
+    } else {
+#endif
+       syscallnum = VIOC_SYSCALL;
+       ioctldata = &syscall_data;
+       syscall_data.syscall = AFSCALL_CALL;
+       syscall_data.param1 = param1;
+       syscall_data.param2 = param2;
+       syscall_data.param3 = param3;
+       syscall_data.param4 = param4;
+       syscall_data.param5 = param5;
+       syscall_data.param6 = param6;
+#ifdef AFS_DARWIN100_ENV
+    }
+#endif
     if(fd >= 0) {
-       error = ioctl(fd, VIOC_SYSCALL, &syscall_data);
-       close(fd);
+       error = ioctl(fd, syscallnum, ioctldata);
+       close(fd);
     } else {
-       error = -1;
+       error = -1;
+    }
+    if (!error) {
+#ifdef AFS_DARWIN100_ENV
+       if (is64)
+           error=syscall64_data.retval;
+       else
+#endif
+           error=syscall_data.retval;
     }
-    if (!error)
-      error=syscall_data.retval;
 #else
     error =
        syscall(AFS_SYSCALL, AFSCALL_CALL, param1, param2, param3, param4,