From: Andrew Deason Date: Wed, 22 Jun 2011 19:39:39 +0000 (-0500) Subject: afs: Use cell for md5 inode numbers X-Git-Tag: openafs-devel-1_7_1~330 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=42943aead4db2bdf9b8ec01c3917eb1c9ac9eb76 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. Change-Id: I4b939042dd993419f785a78e87e68cf346b56e26 Reviewed-on: http://gerrit.openafs.org/4902 Reviewed-by: Derrick Brashear Tested-by: BuildBot --- diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index eb1f8e7..3ddc7d9 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -345,7 +345,8 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) break; de = (struct DirEntry *)entry.data; - 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/LINUX24/osi_vnodeops.c b/src/afs/LINUX24/osi_vnodeops.c index f86b0d2..8744691 100644 --- a/src/afs/LINUX24/osi_vnodeops.c +++ b/src/afs/LINUX24/osi_vnodeops.c @@ -305,7 +305,8 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) break; de = (struct DirEntry *)entry.data; - 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 13708d1..ef3f774 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 ee7018d..535ffc2 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -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 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 783ebc1..426346d 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; MD5_Init(&ct); + MD5_Update(&ct, &cell, 4); MD5_Update(&ct, &volume, 4); MD5_Update(&ct, &vnode, 4); 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; }