From e1e008338639d6cc0d836ff8079e6fb42021ab9e Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 6 Jul 2011 15:22:38 -0500 Subject: [PATCH] afs: Use 64-bit inode numbers When we have a 64-bit ino_t, use the full 64 bits, instead of always limiting ourselves to 32 bits. Change-Id: I8f9f552b230e1723c8b77bfe92213ca43816240c Reviewed-on: http://gerrit.openafs.org/4921 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/IRIX/osi_idbg.c | 2 +- src/afs/VNOPS/afs_vnop_attrs.c | 1 - src/afs/afs_prototypes.h | 3 +-- src/afs/afs_util.c | 21 ++++++++++++++------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/afs/IRIX/osi_idbg.c b/src/afs/IRIX/osi_idbg.c index 369405327..173be4bb6 100644 --- a/src/afs/IRIX/osi_idbg.c +++ b/src/afs/IRIX/osi_idbg.c @@ -106,7 +106,7 @@ idbg_afsvfslist() struct vcache *tvc; struct afs_q *tq; struct afs_q *uq; - afs_int32 nodeid; /* what ls prints as 'inode' */ + ino_t nodeid; /* what ls prints as 'inode' */ AFS_GLOCK(); for (tq = VLRU.prev; tq != &VLRU; tq = uq) { diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index ef3f774c1..4278cd84e 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -117,7 +117,6 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) afs_calc_inum(avc->f.fid.Cell, avc->f.fid.Fid.Volume, avc->f.fid.Fid.Vnode); - attrs->va_nodeid &= 0x7fffffff; /* Saber C hates negative inode #s! */ attrs->va_nlink = fakedir ? 100 : avc->f.m.LinkCount; attrs->va_size = fakedir ? 4096 : avc->f.m.Length; #if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 535ffc227..2483eacbe 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1010,8 +1010,7 @@ extern void afs_MarkUserExpired(afs_int32 pag); /* afs_util.c */ extern afs_int32 afs_strtoi_r(const char *str, char **endptr, afs_uint32 *ret); -extern afs_int32 afs_calc_inum(afs_int32 cell, afs_int32 volume, - afs_int32 vnode); +extern ino_t afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode); #ifndef afs_cv2string extern char *afs_cv2string(char *ttp, afs_uint32 aval); #endif diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c index 6b4cf1904..c9c627fc0 100644 --- a/src/afs/afs_util.c +++ b/src/afs/afs_util.c @@ -368,10 +368,11 @@ afs_data_pointer_to_int32(const void *p) } #ifdef AFS_LINUX20_ENV -static_inline afs_int32 +static_inline ino_t afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode) { - afs_int32 ino = 0, vno = vnode; + ino_t ino = 0; + afs_int32 vno = vnode; char digest[16]; struct md5 ct; @@ -394,7 +395,9 @@ afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode) memcpy(&ino, &digest[offset], sizeof(ino)); ino ^= (ino ^ vno) & 1; - ino &= 0x7fffffff; /* Assumes 32 bit ino_t ..... */ + + /* Clear MSB to ensure a positive inode number */ + ino &= ~(1ULL << (sizeof(ino) * 8 - 1)); } } return ino; @@ -403,16 +406,20 @@ afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode) # define afs_calc_inum_md5(cell, volume, vnode) 0 #endif -afs_int32 +ino_t afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode) { - afs_int32 ino; + ino_t ino; ino = afs_calc_inum_md5(cell, volume, vnode); if (ino == 0 || ino == 1) { - ino = (volume << 16) + vnode; + /* If we have 32-bit inodes, just shift the volume id 16 bits; but + * if we have 64-bit inodes, we can dedicate 32 bits for the volid, + * and 32 bits for the vnode. */ + ino = ((ino_t)volume << (sizeof(ino)*4)) + vnode; } - ino &= 0x7fffffff; /* Assumes 32 bit ino_t ..... */ + /* Clear MSB to ensure a positive inode number */ + ino &= ~(1ULL << (sizeof(ino) * 8 - 1)); return ino; } -- 2.39.5