static_inline int
afs_pd_alloc(struct afs_pdata *apd, size_t size)
{
-
- if (size > AFS_LRALLOCSIZ)
+ /* Ensure that we give caller at least one trailing guard byte
+ * for the NUL terminator. */
+ if (size >= AFS_LRALLOCSIZ)
apd->ptr = osi_Alloc(size + 1);
else
apd->ptr = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
if (apd->ptr == NULL)
return ENOMEM;
+ /* Clear it all now, including the guard byte. */
+ if (size >= AFS_LRALLOCSIZ)
+ memset(apd->ptr, 0, size + 1);
+ else
+ memset(apd->ptr, 0, AFS_LRALLOCSIZ);
+
+ /* Don't tell the caller about the guard byte. */
apd->remaining = size;
return 0;
if (apd->ptr == NULL)
return;
- if (apd->remaining > AFS_LRALLOCSIZ)
+ if (apd->remaining >= AFS_LRALLOCSIZ)
osi_Free(apd->ptr, apd->remaining + 1);
else
osi_FreeLargeSpace(apd->ptr);
SHARED_LOCK, NULL));
/* now we've forgotten all of the access info */
- ObtainWriteLock(&afs_xcbhash, 455);
- avc->callback = 0;
- afs_DequeueCallback(avc);
- avc->f.states &= ~(CStatd | CUnique);
- ReleaseWriteLock(&afs_xcbhash);
- if (avc->f.fid.Fid.Vnode & 1 || (vType(avc) == VDIR))
- osi_dnlc_purgedp(avc);
+ afs_StaleVCacheFlags(avc, AFS_STALEVC_CLEARCB, CUnique);
/* SXW - Should we flush metadata here? */
+
return code;
}
AFS_STATCNT(PSetVolumeStatus);
if (!avc)
return EINVAL;
+ memset(&storeStat, 0, sizeof(storeStat));
tvp = afs_GetVolume(&avc->f.fid, areq, READ_LOCK);
if (tvp) {
}
tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1);
if (!tdc)
- return ENOENT;
+ return EIO;
Check_AtSys(avc, name, &sysState, areq);
ObtainReadLock(&tdc->lock);
do {
tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
}
if (!tvc) {
- code = ENOENT;
+ code = EIO;
goto out;
}
- if (tvc->mvstat != 1) {
+ if (tvc->mvstat != AFS_MVSTAT_MTPT) {
afs_PutVCache(tvc);
code = EINVAL;
goto out;
afs_int32 results[MAXGCSTATS];
afs_int32 flags;
struct dcache * tdc;
- int i, size;
+ int i;
AFS_STATCNT(PGetCacheSize);
tdc = afs_indexTable[i];
if (tdc){
+ afs_size_t size = tdc->validPos;
+
results[9]++;
- size = tdc->validPos;
- if ( 0 < size && size < (1<<12) ) results[10]++;
+ if ( 0 <= size && size < (1<<12) ) results[10]++;
else if (size < (1<<14) ) results[11]++;
else if (size < (1<<16) ) results[12]++;
else if (size < (1<<18) ) results[13]++;
(tc, rxconn, code, &avc->f.fid, areq,
AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, NULL));
- ObtainWriteLock(&afs_xcbhash, 457);
- afs_DequeueCallback(avc);
- avc->callback = 0;
- avc->f.states &= ~(CStatd | CUnique);
- ReleaseWriteLock(&afs_xcbhash);
- if (avc->f.fid.Fid.Vnode & 1 || (vType(avc) == VDIR))
- osi_dnlc_purgedp(avc);
+ afs_StaleVCacheFlags(avc, AFS_STALEVC_CLEARCB, CUnique);
}
ReleaseWriteLock(&avc->lock);
return 0;
* This whole logic is bogus, because it relies on the newer command
* sending its 12th address as 0.
*/
- if ((afs_pd_remaining(ain) < AFS_MAXCELLHOSTS +3) * sizeof(afs_int32))
+ if (afs_pd_remaining(ain) < (AFS_MAXCELLHOSTS + 3) * sizeof(afs_int32))
return EINVAL;
newcell = afs_pd_where(ain) + (AFS_MAXCELLHOSTS + 3) * sizeof(afs_int32);
tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1); /* test for error below */
if (!tdc)
- return ENOENT;
+ return EIO;
Check_AtSys(avc, name, &sysState, areq);
ObtainReadLock(&tdc->lock);
do {
tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
}
if (!tvc) {
- code = ENOENT;
+ code = EIO;
afs_PutDCache(tdc);
goto out;
}
- if (tvc->mvstat != 1) {
+ if (tvc->mvstat != AFS_MVSTAT_MTPT) {
afs_PutDCache(tdc);
afs_PutVCache(tvc);
code = EINVAL;
return 0;
}
-static void
+static int
FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
{
afs_int32 i;
afs_int32 cell = 0;
afs_int32 volume = 0;
struct afs_q *tq, *uq;
+ int code = 0;
#ifdef AFS_DARWIN80_ENV
vnode_t vp;
#endif
continue; /* never had any data */
tdc = afs_GetValidDSlot(i);
if (!tdc) {
- continue;
+ code = EIO;
+ break;
}
if (tdc->refCount <= 1) { /* too high, in use by running sys call */
ReleaseReadLock(&tdc->tlock);
ReleaseWriteLock(&afs_xdcache);
ObtainReadLock(&afs_xvolume);
- for (i = 0; i < NVOLS; i++) {
+ for (i = all ? 0 : VHash(volume); i < NVOLS; i++) {
for (tv = afs_volumes[i]; tv; tv = tv->next) {
if (all || tv->volume == volume) {
afs_ResetVolumeInfo(tv);
- break;
+ if (!all)
+ goto last;
}
}
}
+ last:
ReleaseReadLock(&afs_xvolume);
/* probably, a user is doing this, probably, because things are screwed up.
* maybe it's the dnlc's fault? */
osi_dnlc_purge();
+ return code;
}
/*!
if (!afs_resourceinit_flag) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
- FlushVolumeData(&avc->f.fid, *acred);
- return 0;
+ return FlushVolumeData(&avc->f.fid, *acred);
}
/*!
if (!afs_resourceinit_flag) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
- FlushVolumeData(NULL, *acred);
- return 0;
+ return FlushVolumeData(NULL, *acred);
}
/*!
newcred->cr_groupset.gs_union.un_groups[0] = g0;
newcred->cr_groupset.gs_union.un_groups[1] = g1;
#elif defined(AFS_LINUX26_ENV)
-# ifdef AFS_LINUX26_ONEGROUP_ENV
+# ifdef AFS_PAG_ONEGROUP_ENV
afs_set_cr_group_info(newcred, groups_alloc(1)); /* nothing sets this */
l = (((g0-0x3f00) & 0x3fff) << 14) | ((g1-0x3f00) & 0x3fff);
h = ((g0-0x3f00) >> 14);
GROUP_AT(afs_cr_group_info(newcred), 1) = g1;
# endif
#elif defined(AFS_SUN510_ENV)
+# ifdef AFS_PAG_ONEGROUP_ENV
+ gids[0] = afs_get_pag_from_groups(g0, g1);
+ crsetgroups(newcred, 1, gids);
+# else
gids[0] = g0;
gids[1] = g1;
crsetgroups(newcred, 2, gids);
+# endif /* !AFS_PAG_ONEGROUP_ENV */
#else
newcred->cr_groups[0] = g0;
newcred->cr_groups[1] = g1;
}
tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1);
if (!tdc)
- return ENOENT;
+ return EIO;
Check_AtSys(avc, mount, &sysState, areq);
ObtainReadLock(&tdc->lock);
do {
tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
}
if (!tvc) {
- code = ENOENT;
+ code = EIO;
goto out;
}
- if (tvc->mvstat != 1) {
+ if (tvc->mvstat != AFS_MVSTAT_MTPT) {
afs_PutVCache(tvc);
code = EINVAL;
goto out;
}
ObtainWriteLock(&tvc->lock, 649);
- ObtainWriteLock(&afs_xcbhash, 650);
- afs_DequeueCallback(tvc);
- tvc->f.states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */
- ReleaseWriteLock(&afs_xcbhash);
+ /* next reference will re-stat cache entry */
+ afs_StaleVCacheFlags(tvc, 0, CDirty);
/* now find the disk cache entries */
afs_TryToSmush(tvc, *acred, 1);
- osi_dnlc_purgedp(tvc);
if (tvc->linkData && !(tvc->f.states & CCore)) {
afs_osi_Free(tvc->linkData, strlen(tvc->linkData) + 1);
tvc->linkData = NULL;
if (tc) {
RX_AFS_GUNLOCK();
code =
- RXAFS_FsCmd(rxconn, Fid, Inputs,
- (struct FsCmdOutputs *)aout);
+ RXAFS_FsCmd(rxconn, Fid, Inputs, Outputs);
RX_AFS_GLOCK();
} else
code = -1;
DECL_PIOCTL(PCallBackAddr)
{
#ifndef UKERNEL
- afs_uint32 addr, code;
+ afs_uint32 code;
int srvAddrCount;
struct server *ts;
struct srvAddr *sa;
struct afs_conn *tc;
- afs_int32 i, j;
+ afs_int32 i, j, addr;
struct unixuser *tu;
struct srvAddr **addrs;
struct rx_connection *rxconn;
}
afs_PutConn(tc, rxconn, SHARED_LOCK); /* done with it now */
} /* Outer loop over addrs */
+ afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs));
#endif /* UKERNEL */
return 0;
}