mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
afs_TruncateAllSegments() make sure correct afs_size_t comparison is
used when selecting dcache entries for truncation Insure that afs_TruncateAllSegments() uses the correct [64-bit] comparison when deciding whether to truncate chunks: alen - AFS_CHUNKTOBASE(tdc->f.chunk) for a file > 2GB would fail to be recognised negative with an "afs_int32 newSize", even with alen = 0 and big tdc->f.chunk. Change-Id: Id77109fb8238234dae725bd876f70ea0fbd403fc Change-Id: If0120e21a52316e536d03241c83e8f0d36614c13 Reviewed-on: http://gerrit.openafs.org/1252 Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
880d35f837
commit
3913aa55ee
@ -644,7 +644,7 @@ afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen,
|
|||||||
register struct dcache *tdc;
|
register struct dcache *tdc;
|
||||||
register afs_int32 code;
|
register afs_int32 code;
|
||||||
register afs_int32 index;
|
register afs_int32 index;
|
||||||
afs_int32 newSize;
|
afs_size_t newSize;
|
||||||
|
|
||||||
int dcCount, dcPos;
|
int dcCount, dcPos;
|
||||||
struct dcache **tdcArray;
|
struct dcache **tdcArray;
|
||||||
@ -748,12 +748,12 @@ afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen,
|
|||||||
if (newSize < 0)
|
if (newSize < 0)
|
||||||
newSize = 0;
|
newSize = 0;
|
||||||
ObtainSharedLock(&tdc->lock, 672);
|
ObtainSharedLock(&tdc->lock, 672);
|
||||||
if (newSize < tdc->f.chunkBytes) {
|
if (newSize < tdc->f.chunkBytes && newSize < MAX_AFS_UINT32) {
|
||||||
UpgradeSToWLock(&tdc->lock, 673);
|
UpgradeSToWLock(&tdc->lock, 673);
|
||||||
tfile = afs_CFileOpen(&tdc->f.inode);
|
tfile = afs_CFileOpen(&tdc->f.inode);
|
||||||
afs_CFileTruncate(tfile, newSize);
|
afs_CFileTruncate(tfile, (afs_int32)newSize);
|
||||||
afs_CFileClose(tfile);
|
afs_CFileClose(tfile);
|
||||||
afs_AdjustSize(tdc, newSize);
|
afs_AdjustSize(tdc, (afs_int32)newSize);
|
||||||
if (alen < tdc->validPos) {
|
if (alen < tdc->validPos) {
|
||||||
if (alen < AFS_CHUNKTOBASE(tdc->f.chunk))
|
if (alen < AFS_CHUNKTOBASE(tdc->f.chunk))
|
||||||
tdc->validPos = 0;
|
tdc->validPos = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user