Revert "afs: Use 64-bit inode numbers"
authorAndrew Deason <adeason@sinenomine.net>
Tue, 19 Jul 2011 21:44:21 +0000 (16:44 -0500)
committerDerrick Brashear <shadow@dementia.org>
Wed, 20 Jul 2011 02:39:24 +0000 (19:39 -0700)
This reverts commit e1e008338639d6cc0d836ff8079e6fb42021ab9e. Using
64-bit inode numbers can make AFS largely inaccessible to 32-bit
programs that are not compiled with large file support, since the
inode number we provide is not representable in a 32-bit struct stat.
Using 64-bit inode numbers thus can break quite a few programs, and
has little benefit, so don't do it.

Change-Id: Ia482ac2864601b5c56a4259432529d14981f4a1a
Reviewed-on: http://gerrit.openafs.org/5048
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/IRIX/osi_idbg.c
src/afs/VNOPS/afs_vnop_attrs.c
src/afs/afs_prototypes.h
src/afs/afs_util.c

index 173be4b..3694053 100644 (file)
@@ -106,7 +106,7 @@ idbg_afsvfslist()
     struct vcache *tvc;
     struct afs_q *tq;
     struct afs_q *uq;
-    ino_t nodeid;              /* what ls prints as 'inode' */
+    afs_int32 nodeid;          /* what ls prints as 'inode' */
 
     AFS_GLOCK();
     for (tq = VLRU.prev; tq != &VLRU; tq = uq) {
index 4278cd8..ef3f774 100644 (file)
@@ -117,6 +117,7 @@ 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)
index 2483eac..535ffc2 100644 (file)
@@ -1010,7 +1010,8 @@ 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 ino_t afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode);
+extern afs_int32 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
index c9c627f..6b4cf19 100644 (file)
@@ -368,11 +368,10 @@ afs_data_pointer_to_int32(const void *p)
 }
 
 #ifdef AFS_LINUX20_ENV
-static_inline ino_t
+static_inline afs_int32
 afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode)
 {
-    ino_t ino = 0;
-    afs_int32 vno = vnode;
+    afs_int32 ino = 0, vno = vnode;
     char digest[16];
     struct md5 ct;
 
@@ -395,9 +394,7 @@ afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode)
 
            memcpy(&ino, &digest[offset], sizeof(ino));
            ino ^= (ino ^ vno) & 1;
-
-           /* Clear MSB to ensure a positive inode number */
-           ino &= ~(1ULL << (sizeof(ino) * 8 - 1));
+           ino &= 0x7fffffff;      /* Assumes 32 bit ino_t ..... */
        }
     }
     return ino;
@@ -406,20 +403,16 @@ afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode)
 # define afs_calc_inum_md5(cell, volume, vnode) 0
 #endif
 
-ino_t
+afs_int32
 afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode)
 {
-    ino_t ino;
+    afs_int32 ino;
 
     ino = afs_calc_inum_md5(cell, volume, vnode);
 
     if (ino == 0 || ino == 1) {
-       /* 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 = (volume << 16) + vnode;
     }
-    /* Clear MSB to ensure a positive inode number */
-    ino &= ~(1ULL << (sizeof(ino) * 8 - 1));
+    ino &= 0x7fffffff;      /* Assumes 32 bit ino_t ..... */
     return ino;
 }