From: Andrew Deason Date: Wed, 22 Jun 2011 19:39:39 +0000 (-0500) Subject: afs: Use cell for md5 inode numbers X-Git-Tag: upstream/1.6.2_pre2^2~191 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=b9c03fa6f8e696c64c90949cce34bb075aa2ae6f;p=packages%2Fo%2Fopenafs.git afs: Use cell for md5 inode numbers When calculating the inode number for a file with md5 inodes, include the cell number in the calculation, in order to reduce collisions between cells. Reviewed-on: http://gerrit.openafs.org/4902 Reviewed-by: Derrick Brashear Tested-by: BuildBot (cherry picked from commit 42943aead4db2bdf9b8ec01c3917eb1c9ac9eb76) Change-Id: I5cf88ecd30a5813697dbf3b86964d53bb1f3915a Reviewed-on: http://gerrit.openafs.org/7277 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index e8fc96a9b..f1d43bb7d 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -272,7 +272,8 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) goto out; } - ino = afs_calc_inum (avc->f.fid.Fid.Volume, ntohl(de->fid.vnode)); + ino = afs_calc_inum(avc->f.fid.Cell, avc->f.fid.Fid.Volume, + ntohl(de->fid.vnode)); len = strlen(de->name); /* filldir returns -EINVAL when the buffer is full. */ diff --git a/src/afs/LINUX24/osi_vnodeops.c b/src/afs/LINUX24/osi_vnodeops.c index 841f453a5..372bc806b 100644 --- a/src/afs/LINUX24/osi_vnodeops.c +++ b/src/afs/LINUX24/osi_vnodeops.c @@ -303,7 +303,8 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) if (!de) break; - ino = afs_calc_inum (avc->f.fid.Fid.Volume, ntohl(de->fid.vnode)); + ino = afs_calc_inum(avc->f.fid.Cell, avc->f.fid.Fid.Volume, + ntohl(de->fid.vnode)); if (de->name) len = strlen(de->name); diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index b3931e546..d01aff2f2 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -104,8 +104,9 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) /* The mount point's vnode. */ if (tvp) { attrs->va_nodeid = - afs_calc_inum (tvp->mtpoint.Fid.Volume, - tvp->mtpoint.Fid.Vnode); + afs_calc_inum(tvp->mtpoint.Cell, + tvp->mtpoint.Fid.Volume, + tvp->mtpoint.Fid.Vnode); if (FidCmp(&afs_rootFid, &avc->f.fid) && !attrs->va_nodeid) attrs->va_nodeid = 2; afs_PutVolume(tvp, READ_LOCK); @@ -113,8 +114,9 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) attrs->va_nodeid = 2; } else attrs->va_nodeid = - afs_calc_inum (avc->f.fid.Fid.Volume, - avc->f.fid.Fid.Vnode); + 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; diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 6e8a87bfd..11a6a8c9d 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -968,7 +968,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 afs_int32 afs_calc_inum (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 diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c index daf86ff4c..f50bbf1f7 100644 --- a/src/afs/afs_util.c +++ b/src/afs/afs_util.c @@ -370,7 +370,7 @@ afs_data_pointer_to_int32(const void *p) #ifdef AFS_LINUX20_ENV afs_int32 -afs_calc_inum(afs_int32 volume, afs_int32 vnode) +afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode) { afs_int32 ino = 0, vno = vnode; char digest[16]; @@ -379,6 +379,7 @@ afs_calc_inum(afs_int32 volume, afs_int32 vnode) if (afs_new_inum) { int offset; AFS_MD5_Init(&ct); + AFS_MD5_Update(&ct, &cell, 4); AFS_MD5_Update(&ct, &volume, 4); AFS_MD5_Update(&ct, &vnode, 4); AFS_MD5_Final(digest, &ct); @@ -407,7 +408,7 @@ afs_calc_inum(afs_int32 volume, afs_int32 vnode) #else afs_int32 -afs_calc_inum (afs_int32 volume, afs_int32 vnode) +afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode) { return (volume << 16) + vnode; }