From 8f0eed22c3eb03e5f376d2152112ae354481ab2c Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 22 Mar 2012 10:52:47 -0500 Subject: [PATCH] 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 Reviewed-by: Alistair Ferguson Reviewed-by: Derrick Brashear (cherry picked from commit d5c13a0f3ce7d9f0a01820ff9c12dfb1cbc12047) Change-Id: I2ba6574b88856d2f506663eafb984a9f3bea4cf8 Reviewed-on: http://gerrit.openafs.org/7995 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/afs_dcache.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 6bb875fd0..ff5ee5c6f 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -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) { -- 2.39.5