Create simple function init_va_filerev() for initializing a va_filerev

field.

Replace three instances of longhaired initialization va_filerev fields.

Added XXX comment wondering why we don't use random bits instead of
uptime of the system for this purpose.
This commit is contained in:
Poul-Henning Kamp 2004-09-07 09:17:05 +00:00
parent 35f134080f
commit 1affa3adc8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134899
6 changed files with 19 additions and 93 deletions

View File

@ -76,23 +76,6 @@ static u_long dehash; /* size of hash table - 1 */
static struct mtx dehash_mtx;
static int dehash_init;
union _qcvt {
quad_t qcvt;
long val[2];
};
#define SETHIGH(q, h) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_HIGHWORD] = (h); \
(q) = tmp.qcvt; \
}
#define SETLOW(q, l) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_LOWWORD] = (l); \
(q) = tmp.qcvt; \
}
static struct denode *
msdosfs_hashget(struct cdev *dev, u_long dirclust, u_long diroff);
static void msdosfs_hashins(struct denode *dep);
@ -222,7 +205,6 @@ deget(pmp, dirclust, diroffset, depp)
struct vnode *nvp;
struct buf *bp;
struct thread *td = curthread; /* XXX */
struct timeval tv;
#ifdef MSDOSFS_DEBUG
printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n",
@ -389,9 +371,8 @@ deget(pmp, dirclust, diroffset, depp)
}
} else
nvp->v_type = VREG;
getmicrouptime(&tv);
SETHIGH(ldep->de_modrev, tv.tv_sec);
SETLOW(ldep->de_modrev, tv.tv_usec * 4294);
ldep->de_modrev = init_va_filerev();
ldep->de_devvp = pmp->pm_devvp;
VREF(ldep->de_devvp);
*depp = ldep;

View File

@ -201,23 +201,6 @@ static struct vnodeopv_desc ext2fs_fifoop_opv_desc =
#include <gnu/ext2fs/ext2_readwrite.c>
union _qcvt {
int64_t qcvt;
int32_t val[2];
};
#define SETHIGH(q, h) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_HIGHWORD] = (h); \
(q) = tmp.qcvt; \
}
#define SETLOW(q, l) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_LOWWORD] = (l); \
(q) = tmp.qcvt; \
}
/*
* A virgin directory (no blushing please).
* Note that the type and namlen fields are reversed relative to ext2.
@ -1741,7 +1724,6 @@ ext2_vinit(mntp, specops, fifoops, vpp)
{
struct inode *ip;
struct vnode *vp;
struct timeval tv;
vp = *vpp;
ip = VTOI(vp);
@ -1763,12 +1745,7 @@ ext2_vinit(mntp, specops, fifoops, vpp)
}
if (ip->i_number == ROOTINO)
vp->v_vflag |= VV_ROOT;
/*
* Initialize modrev times
*/
getmicrouptime(&tv);
SETHIGH(ip->i_modrev, tv.tv_sec);
SETLOW(ip->i_modrev, tv.tv_usec * 4294);
ip->i_modrev = init_va_filerev();
*vpp = vp;
return (0);
}

View File

@ -201,23 +201,6 @@ static struct vnodeopv_desc ext2fs_fifoop_opv_desc =
#include <gnu/ext2fs/ext2_readwrite.c>
union _qcvt {
int64_t qcvt;
int32_t val[2];
};
#define SETHIGH(q, h) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_HIGHWORD] = (h); \
(q) = tmp.qcvt; \
}
#define SETLOW(q, l) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_LOWWORD] = (l); \
(q) = tmp.qcvt; \
}
/*
* A virgin directory (no blushing please).
* Note that the type and namlen fields are reversed relative to ext2.
@ -1741,7 +1724,6 @@ ext2_vinit(mntp, specops, fifoops, vpp)
{
struct inode *ip;
struct vnode *vp;
struct timeval tv;
vp = *vpp;
ip = VTOI(vp);
@ -1763,12 +1745,7 @@ ext2_vinit(mntp, specops, fifoops, vpp)
}
if (ip->i_number == ROOTINO)
vp->v_vflag |= VV_ROOT;
/*
* Initialize modrev times
*/
getmicrouptime(&tv);
SETHIGH(ip->i_modrev, tv.tv_sec);
SETLOW(ip->i_modrev, tv.tv_usec * 4294);
ip->i_modrev = init_va_filerev();
*vpp = vp;
return (0);
}

View File

@ -4062,3 +4062,16 @@ sysctl_vfs_ctl(SYSCTL_HANDLER_ARGS)
SYSCTL_PROC(_vfs, OID_AUTO, ctl, CTLFLAG_WR,
NULL, 0, sysctl_vfs_ctl, "", "Sysctl by fsid");
/*
* Function to initialize a va_filerev field sensibly.
* XXX: Wouldn't a random number make a lot more sense ??
*/
u_quad_t
init_va_filerev(void)
{
struct bintime bt;
getbinuptime(&bt);
return (((u_quad_t)bt.sec << 32LL) | (bt.frac >> 32LL));
}

View File

@ -613,6 +613,7 @@ void cvtstat(struct stat *st, struct ostat *ost);
void cvtnstat(struct stat *sb, struct nstat *nsb);
int getnewvnode(const char *tag, struct mount *mp, vop_t **vops,
struct vnode **vpp);
u_quad_t init_va_filerev(void);
int lease_check(struct vop_lease_args *ap);
int spec_vnoperate(struct vop_generic_args *);
int speedup_syncer(void);

View File

@ -117,23 +117,6 @@ static int filt_ufsvnode(struct knote *kn, long hint);
static void filt_ufsdetach(struct knote *kn);
static int ufs_kqfilter(struct vop_kqfilter_args *ap);
union _qcvt {
int64_t qcvt;
int32_t val[2];
};
#define SETHIGH(q, h) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_HIGHWORD] = (h); \
(q) = tmp.qcvt; \
}
#define SETLOW(q, l) { \
union _qcvt tmp; \
tmp.qcvt = (q); \
tmp.val[_QUAD_LOWWORD] = (l); \
(q) = tmp.qcvt; \
}
/*
* A virgin directory (no blushing please).
*/
@ -2321,7 +2304,6 @@ ufs_vinit(mntp, specops, fifoops, vpp)
{
struct inode *ip;
struct vnode *vp;
struct timeval tv;
vp = *vpp;
ip = VTOI(vp);
@ -2342,12 +2324,7 @@ ufs_vinit(mntp, specops, fifoops, vpp)
ASSERT_VOP_LOCKED(vp, "ufs_vinit");
if (ip->i_number == ROOTINO)
vp->v_vflag |= VV_ROOT;
/*
* Initialize modrev times
*/
getmicrouptime(&tv);
SETHIGH(ip->i_modrev, tv.tv_sec);
SETLOW(ip->i_modrev, tv.tv_usec * 4294);
ip->i_modrev = init_va_filerev();
*vpp = vp;
return (0);
}