From de143794d1837ba33362f60f98a770d6a4dd514a Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 12 Oct 2009 23:26:13 +0000 Subject: [PATCH] b=20766 i=adilger i=thomas.leibovici@cea.fr changelog records using epoch time instead of CURRENT_SECONDS --- lustre/mdd/mdd_device.c | 9 ++++++++- lustre/tests/sanity.sh | 4 ++-- lustre/utils/lfs.c | 14 +++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 3ce0d5d..48da062 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -290,6 +290,13 @@ int mdd_changelog_on(struct mdd_device *mdd, int on) return rc; } +static __u64 cl_time(void) { + cfs_fs_time_t time; + + cfs_fs_time_current(&time); + return (((__u64)time.tv_sec) << 30) + time.tv_nsec; +} + /** Add a changelog entry \a rec to the changelog llog * \param mdd * \param rec @@ -311,7 +318,7 @@ int mdd_changelog_llog_write(struct mdd_device *mdd, rec->cr_hdr.lrh_len = llog_data_len(sizeof(*rec) + rec->cr.cr_namelen); /* llog_lvfs_write_rec sets the llog tail len */ rec->cr_hdr.lrh_type = CHANGELOG_REC; - rec->cr.cr_time = cfs_time_current_64(); + rec->cr.cr_time = cl_time(); spin_lock(&mdd->mdd_cl.mc_lock); /* NB: I suppose it's possible llog_add adds out of order wrt cr_index, but as long as the MDD transactions are ordered correctly for e.g. diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index fe2d7f3..8e8ec18 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6466,13 +6466,13 @@ test_160() { # verify contents echo "verifying target fid" fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \ - tail -1 | awk '{print $5}') + tail -1 | awk '{print $6}') fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp) [ "$fidc" == "t=$fidf" ] || \ err17935 "fid in changelog $fidc != file fid $fidf" echo "verifying parent fid" fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \ - tail -1 | awk '{print $6}') + tail -1 | awk '{print $7}') fidf=$($LFS path2fid $DIR/$tdir/pics/zach) [ "$fidc" == "p=$fidf" ] || \ err17935 "pfid in changelog $fidc != dir fid $fidf" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 0e582ed..d950da6 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -2357,14 +2357,22 @@ static int lfs_changelog(int argc, char **argv) } while ((rc = llapi_changelog_recv(changelog_priv, &rec)) == 0) { + time_t secs; + struct tm ts; + if (endrec && rec->cr_index > endrec) break; if (rec->cr_index < startrec) continue; - printf(LPU64" %02d%-5s "LPU64" 0x%x t="DFID, - rec->cr_index, rec->cr_type, - changelog_type2str(rec->cr_type), rec->cr_time, + secs = rec->cr_time >> 30; + gmtime_r(&secs, &ts); + printf(LPU64" %02d%-5s %02d:%02d:%02d.%06d %04d.%02d.%02d " + "0x%x t="DFID, rec->cr_index, rec->cr_type, + changelog_type2str(rec->cr_type), + ts.tm_hour, ts.tm_min, ts.tm_sec, + (int)(rec->cr_time & ((1<<30) - 1)), + ts.tm_year+1900, ts.tm_mon+1, ts.tm_mday, rec->cr_flags & CLF_FLAGMASK, PFID(&rec->cr_tfid)); if (rec->cr_namelen) /* namespace rec includes parent and filename */ -- 1.8.3.1