2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
17 #include "afs/sysincludes.h" /* Standard vendor system headers */
18 #include "afsincludes.h" /* Afs-based standard headers */
19 #include "afs/afs_stats.h"
25 afs_int32 afs_FirstCSize = AFS_DEFAULTCSIZE;
26 afs_int32 afs_OtherCSize = AFS_DEFAULTCSIZE;
27 afs_int32 afs_LogChunk = AFS_DEFAULTLSIZE;
31 afs_ChunkOffset(offset)
35 AFS_STATCNT(afs_ChunkOffset);
36 if (offset < afs_FirstCSize)
39 return ((offset - afs_FirstCSize) & (afs_OtherCSize - 1));
47 AFS_STATCNT(afs_Chunk);
48 if (offset < afs_FirstCSize)
51 return (((offset - afs_FirstCSize) >> afs_LogChunk) + 1);
59 AFS_STATCNT(afs_ChunkBase);
60 if (offset < afs_FirstCSize)
63 return (((offset - afs_FirstCSize) & ~(afs_OtherCSize - 1)) +
72 AFS_STATCNT(afs_ChunkSize);
73 if (offset < afs_FirstCSize)
74 return afs_FirstCSize;
76 return afs_OtherCSize;
81 afs_ChunkToBase(chunk)
84 AFS_STATCNT(afs_ChunkToBase);
88 return (afs_FirstCSize + ((chunk - 1) << afs_LogChunk));
93 afs_ChunkToSize(chunk)
96 AFS_STATCNT(afs_ChunkToSize);
98 return afs_FirstCSize;
100 return afs_OtherCSize;
103 /* sizes are a power of two */
105 afs_SetChunkSize(chunk)
108 AFS_STATCNT(afs_SetChunkSize);
109 afs_LogChunk = chunk;
110 afs_FirstCSize = afs_OtherCSize = (1 << chunk);