* -splitcache RW/RO ratio for cache.
* -rxmaxfrags Max number of UDP fragments per rx packet.
* -inumcalc inode number calculation method; 0=compat, 1=MD5 digest
+ * -volume-ttl vldb cache timeout in seconds
*---------------------------------------------------------------------------*/
#include <afsconfig.h>
static int afsd_CloseSynch = 0; /*Are closes synchronous or not? */
static int rxmaxmtu = 0; /* Are we forcing a limit on the mtu? */
static int rxmaxfrags = 0; /* Are we forcing a limit on frags? */
+static int volume_ttl = 0; /* enable vldb cache timeout support */
#ifdef AFS_SGI62_ENV
#define AFSD_INO_T ino64_t
OPT_dynrootsparse,
OPT_rxmaxfrags,
OPT_inumcalc,
+ OPT_volume_ttl,
};
#ifdef MACOS_EVENT_HANDLING
(NULL, kSCDynamicStoreDomainState,
kSCCompAnyRegex, kSCEntNetIPv4));
-#if 0
- /* This should tell us when the hostname(s) change. do we care? */
- keys[N] = SCDynamicStoreKeyCreateHostNames (NULL);
-#endif
-
if (keys[0] != NULL) {
CFArrayRef pattern_array;
SetNoBackupAttr(fullpn_CellInfoFile);
} else if ((strcmp(currp->d_name, ".") == 0)
|| (strcmp(currp->d_name, "..") == 0) ||
-#ifdef AFS_DECOSF_ENV
- /* these are magic AdvFS files */
- (strcmp(currp->d_name, ".tags") == 0)
- || (strcmp(currp->d_name, "quota.user") == 0)
- || (strcmp(currp->d_name, "quota.group") == 0) ||
-#endif
#ifdef AFS_LINUX22_ENV
/* this is the ext3 journal file */
(strcmp(currp->d_name, ".journal") == 0) ||
uspc->ts = -1;
while (1) {
- pid_t child = 0;
- int status;
- char srcpath[BUFSIZ];
- char dstpath[BUFSIZ];
-
/* pushing in a buffer this large */
uspc->bufSz = 256;
code = afsd_syscall(AFSOP_BKG_HANDLER, uspc, srcName, dstName);
if (code) { /* Something is wrong? */
- if (code == -2) /* shutting down */
- break;
+ if (code == -2) {
+ /*
+ * Before AFS_USPC_SHUTDOWN existed, the kernel module used to
+ * indicate it was shutting down by returning -2. Treat this
+ * like a AFS_USPC_SHUTDOWN, in case we're running with an
+ * older kernel module.
+ */
+ return;
+ }
sleep(1);
uspc->retval = -1;
}
switch (uspc->reqtype) {
- case AFS_USPC_UMV:
- snprintf(srcpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
- uspc->req.umv.sCell, uspc->req.umv.sVolume,
- uspc->req.umv.sVnode, uspc->req.umv.sUnique, srcName);
- snprintf(dstpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
- uspc->req.umv.dCell, uspc->req.umv.dVolume,
- uspc->req.umv.dVnode, uspc->req.umv.dUnique, dstName);
- if ((child = fork()) == 0) {
- /* first child does cp; second, rm. mv would re-enter. */
-
- switch (uspc->req.umv.idtype) {
- case IDTYPE_UID:
- if (setuid(uspc->req.umv.id) != 0) {
- exit(-1);
- }
- break;
- default:
- exit(-1);
- break; /* notreached */
- }
- execl("/bin/cp", "(afsd EXDEV helper)", "-PRp", "--", srcpath,
- dstpath, (char *) NULL);
- }
- if (child == (pid_t) -1) {
- uspc->retval = -1;
- continue;
- }
+ case AFS_USPC_SHUTDOWN:
+ /* Client is shutting down */
+ return;
- if (waitpid(child, &status, 0) == -1)
- uspc->retval = EIO;
- else if (WIFEXITED(status) != 0 && WEXITSTATUS(status) == 0) {
- if ((child = fork()) == 0) {
- switch (uspc->req.umv.idtype) {
- case IDTYPE_UID:
- if (setuid(uspc->req.umv.id) != 0) {
- exit(-1);
- }
- break;
- default:
- exit(-1);
- break; /* notreached */
- }
- execl("/bin/rm", "(afsd EXDEV helper)", "-rf", "--",
- srcpath, (char *) NULL);
- }
- if (child == (pid_t) -1) {
- uspc->retval = -1;
- continue;
- }
- if (waitpid(child, &status, 0) == -1)
- uspc->retval = EIO;
- else if (WIFEXITED(status) != 0) {
- /* rm exit status */
- uspc->retval = WEXITSTATUS(status);
- } else {
- /* rm signal status */
- uspc->retval = -(WTERMSIG(status));
- }
- } else {
- /* error from cp: exit or signal status */
- uspc->retval = (WIFEXITED(status) != 0) ?
- WEXITSTATUS(status) : -(WTERMSIG(status));
- }
+ case AFS_USPC_NOOP:
+ /* noop */
memset(srcName, 0, sizeof(srcName));
memset(dstName, 0, sizeof(dstName));
break;
+# ifdef AFS_DARWIN_ENV
+ case AFS_USPC_UMV:
+ {
+ pid_t child = 0;
+ int status;
+ char srcpath[BUFSIZ];
+ char dstpath[BUFSIZ];
+ snprintf(srcpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
+ uspc->req.umv.sCell, uspc->req.umv.sVolume,
+ uspc->req.umv.sVnode, uspc->req.umv.sUnique, srcName);
+ snprintf(dstpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
+ uspc->req.umv.dCell, uspc->req.umv.dVolume,
+ uspc->req.umv.dVnode, uspc->req.umv.dUnique, dstName);
+ if ((child = fork()) == 0) {
+ /* first child does cp; second, rm. mv would re-enter. */
+
+ switch (uspc->req.umv.idtype) {
+ case IDTYPE_UID:
+ if (setuid(uspc->req.umv.id) != 0) {
+ exit(-1);
+ }
+ break;
+ default:
+ exit(-1);
+ break; /* notreached */
+ }
+ execl("/bin/cp", "(afsd EXDEV helper)", "-PRp", "--", srcpath,
+ dstpath, (char *) NULL);
+ }
+ if (child == (pid_t) -1) {
+ uspc->retval = -1;
+ continue;
+ }
+
+ if (waitpid(child, &status, 0) == -1)
+ uspc->retval = EIO;
+ else if (WIFEXITED(status) != 0 && WEXITSTATUS(status) == 0) {
+ if ((child = fork()) == 0) {
+ switch (uspc->req.umv.idtype) {
+ case IDTYPE_UID:
+ if (setuid(uspc->req.umv.id) != 0) {
+ exit(-1);
+ }
+ break;
+ default:
+ exit(-1);
+ break; /* notreached */
+ }
+ execl("/bin/rm", "(afsd EXDEV helper)", "-rf", "--",
+ srcpath, (char *) NULL);
+ }
+ if (child == (pid_t) -1) {
+ uspc->retval = -1;
+ continue;
+ }
+ if (waitpid(child, &status, 0) == -1)
+ uspc->retval = EIO;
+ else if (WIFEXITED(status) != 0) {
+ /* rm exit status */
+ uspc->retval = WEXITSTATUS(status);
+ } else {
+ /* rm signal status */
+ uspc->retval = -(WTERMSIG(status));
+ }
+ } else {
+ /* error from cp: exit or signal status */
+ uspc->retval = (WIFEXITED(status) != 0) ?
+ WEXITSTATUS(status) : -(WTERMSIG(status));
+ }
+ }
+ memset(srcName, 0, sizeof(srcName));
+ memset(dstName, 0, sizeof(dstName));
+ break;
+# endif /* AFS_DARWIN_ENV */
+
default:
/* unknown req type */
uspc->retval = -1;
if (cmd_OptionPresent(as, OPT_inumcalc)) {
cmd_OptionAsString(as, OPT_inumcalc, &inumcalc);
}
+ cmd_OptionAsInt(as, OPT_volume_ttl, &volume_ttl);
/* parse cacheinfo file if this is a diskcache */
if (ParseCacheInfoFile()) {
if (afsd_verbose)
printf("%s: cacheFiles autotuned to %d\n", rn, cacheFiles);
}
-#if 0
- /* This actually needs to
- 1) use powers of 2
- 2) not second-guess when a chunksize comes from the command line
- 3) be less, um, small. 2^2??
- */
- /* Sanity check chunkSize */
- i = max(cacheBlocks / 1000, cacheBlocks / cacheFiles);
- chunkSize = min(chunkSize, i);
- chunkSize = max(chunkSize, 2);
- if (afsd_verbose)
- printf("%s: chunkSize autotuned to %d\n", rn, chunkSize);
-#endif
-
if (!sawDCacheSize) {
dCacheSize = cacheFiles / 2;
if (dCacheSize > 10000) {
if (code > 0) {
if (enable_rxbind)
code = code | 0x80000000;
- afsd_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
+ afsd_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
} else
printf("ADVISEADDR: Error in specifying interface addresses:%s\n",
reason);
cparams.setTimeFlag = 0;
cparams.memCacheFlag = cacheFlags;
cparams.dynamic_vcaches = afsd_dynamic_vcaches;
- afsd_syscall(AFSOP_CACHEINIT, &cparams);
+ code = afsd_syscall(AFSOP_CACHEINIT, &cparams);
+ if (code) {
+ printf("%s: Error %d during cache init.\n", rn, code);
+ exit(1);
+ }
/* do it before we init the cache inodes */
if (enable_splitcache) {
afsd_syscall(AFSOP_ROOTVOLUME, rootVolume);
}
+ if (volume_ttl != 0) {
+ if (afsd_verbose)
+ printf("%s: Calling AFSOP_SET_VOLUME_TTL with '%d'\n", rn, volume_ttl);
+ code = afsd_syscall(AFSOP_SET_VOLUME_TTL, volume_ttl);
+ if (code == EFAULT) {
+ if (volume_ttl < AFS_MIN_VOLUME_TTL)
+ printf("%s: Failed to set volume ttl to %d seconds; "
+ "value is too low.\n", rn, volume_ttl);
+ else if (volume_ttl > AFS_MAX_VOLUME_TTL)
+ printf("%s: Failed to set volume ttl to %d seconds; "
+ "value is too high.\n", rn, volume_ttl);
+ else
+ printf("%s: Failed to set volume ttl to %d seconds; "
+ "value is out of range.\n", rn, volume_ttl);
+ } else if (code != 0) {
+ printf("%s: Failed to set volume ttl to %d seconds; "
+ "code=%d.\n", rn, volume_ttl, code);
+ }
+ }
+
/*
* Pass the kernel the name of the workstation cache file holding the
* volume information.
if (afsd_debug)
printf("%s: Calling AFSOP_GO with cacheSetTime = %d\n", rn,
0);
- afsd_syscall(AFSOP_GO, 0);
+ afsd_syscall(AFSOP_GO, 0);
/*
* At this point, we have finished passing the kernel all the info
"send/receive per Rx packet");
cmd_AddParmAtOffset(ts, OPT_inumcalc, "-inumcalc", CMD_SINGLE, CMD_OPTIONAL,
"Set inode number calculation method");
+ cmd_AddParmAtOffset(ts, OPT_volume_ttl, "-volume-ttl", CMD_SINGLE,
+ CMD_OPTIONAL,
+ "Set the vldb cache timeout value in seconds.");
}
/**
case AFSOP_GO:
case AFSOP_SET_RMTSYS_FLAG:
case AFSOP_SET_INUMCALC:
+ case AFSOP_SET_VOLUME_TTL:
params[0] = CAST_SYSCALL_PARAM((va_arg(ap, int)));
break;
case AFSOP_SET_THISCELL: