afs: Slight adjustments in afs_GetDCache

maxGoodSize is only used in one block, so move the decl to that block.
Adjust some of the comments to more accurately reflect what's going
on.

Reviewed-on: http://gerrit.openafs.org/6936
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit d5c13a0f3ce7d9f0a01820ff9c12dfb1cbc12047)

Change-Id: I2ba6574b88856d2f506663eafb984a9f3bea4cf8
Reviewed-on: http://gerrit.openafs.org/7995
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Andrew Deason 2012-03-22 10:52:47 -05:00 committed by Derrick Brashear
parent f899af247c
commit 8f0eed22c3

View File

@ -1633,7 +1633,6 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
afs_int32 index;
afs_int32 us;
afs_int32 chunk;
afs_size_t maxGoodLength; /* amount of good data at server */
afs_size_t Position = 0;
afs_int32 size, tlen; /* size of segment to transfer */
struct afs_FetchOutput *tsmall = 0;
@ -2087,10 +2086,6 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
goto RetryGetDCache;
}
/* Do not fetch data beyond truncPos. */
maxGoodLength = avc->f.m.Length;
if (avc->f.truncPos < maxGoodLength)
maxGoodLength = avc->f.truncPos;
Position = AFS_CHUNKBASE(abyte);
if (vType(avc) == VDIR) {
size = avc->f.m.Length;
@ -2100,16 +2095,23 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
}
size = 999999999; /* max size for transfer */
} else {
afs_size_t maxGoodLength;
/* estimate how much data we're expecting back from the server,
* and reserve space in the dcache entry for it */
maxGoodLength = avc->f.m.Length;
if (avc->f.truncPos < maxGoodLength)
maxGoodLength = avc->f.truncPos;
size = AFS_CHUNKSIZE(abyte); /* expected max size */
/* don't read past end of good data on server */
if (Position + size > maxGoodLength)
size = maxGoodLength - Position;
if (size < 0)
size = 0; /* Handle random races */
if (size > tdc->f.chunkBytes) {
/* pre-reserve space for file */
/* pre-reserve estimated space for file */
afs_AdjustSize(tdc, size); /* changes chunkBytes */
/* max size for transfer still in size */
}
if (size) {