From: NeilBrown Date: Wed, 4 May 2011 03:47:01 +0000 (+1000) Subject: FORMAT CHANGE add timestamp to group head in write cluster X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=f6faab308e1171d30a6b5623b3123a32bf74d5c9;p=LaFS.git FORMAT CHANGE add timestamp to group head in write cluster This allows accurate preservation of timestamps during roll forward. Signed-off-by: NeilBrown --- diff --git a/cluster.c b/cluster.c index 6233fb8..57fa6a6 100644 --- a/cluster.c +++ b/cluster.c @@ -801,7 +801,7 @@ int lafs_cluster_allocate(struct block *b, int cnum) int avail; /* see how much room is in cluster. * The interesting values are: - * none, one descriptor, one grouphead and one descriptor + * none, one descriptor, one group_head and one descriptor * These are assigned values 0, 1, 2. */ if (wc->cluster_space >= (sizeof(struct group_head) + @@ -871,11 +871,20 @@ static void cluster_addhead(struct wc *wc, struct inode *ino, struct group_head *gh = (struct group_head *)((char *)wc->chead + wc->chead_size); u16 tnf; + u64 tstamp; dprintk("CLUSTER addhead %d\n", wc->chead_size); *headstart = gh; gh->inum = cpu_to_le32(ino->i_ino); gh->fsnum = cpu_to_le32(LAFSI(ino)->filesys->i_ino); + if (LAFSI(ino)->type >= TypeBase) { + tstamp = encode_time(&ino->i_mtime); + if (tstamp != encode_time(&ino->i_ctime)) + tstamp = 0; + } else + tstamp = 0; + gh->timestamp = cpu_to_le64(tstamp); + tnf = ((ino->i_generation<<8) | (LAFSI(ino)->trunc_gen & 0xff)) & 0x7fff; if (wc->cnum) diff --git a/layout.h b/layout.h index afa81ed..0095097 100644 --- a/layout.h +++ b/layout.h @@ -81,6 +81,9 @@ struct miniblock { struct group_head { u32 inum; u32 fsnum; + u64 timestamp; /* If non-zero, the ctime and mtime + * of the file should be set to this. + */ u16 truncatenum_and_flag; u16 group_size_words; /* 4byte words */ union { diff --git a/roll.c b/roll.c index e8ebbba..7b82acd 100644 --- a/roll.c +++ b/roll.c @@ -394,7 +394,7 @@ roll_mini(struct fs *fs, int fsnum, int inum, int trunc, static int __must_check roll_block(struct fs *fs, int fsnum, int inum, int trunc, - u32 bnum, u64 baddr, int bytes, struct page *p) + u32 bnum, u64 baddr, int bytes, u64 tstamp, struct page *p) { struct inode *inode; struct datablock *blk = NULL; @@ -492,6 +492,11 @@ roll_block(struct fs *fs, int fsnum, int inum, int trunc, inode->i_size = ((loff_t)bnum << inode->i_blkbits) + bytes; set_bit(I_Dirty, &LAFSI(inode)->iflags); } + if (tstamp) { + decode_time(&inode->i_mtime, tstamp); + decode_time(&inode->i_ctime, tstamp); + set_bit(I_Dirty, &LAFSI(inode)->iflags); + } /* FIXME: we pretend this is a dirty, pinned block * so the lower-level code doesn't get confused. @@ -600,6 +605,7 @@ roll_one(struct fs *fs, u64 *addrp, struct page *p, struct page *pg, int fsnum = le32_to_cpu(gh->fsnum); int trunc = le16_to_cpu(gh->truncatenum_and_flag) & 0x7fff; int flg = le16_to_cpu(gh->truncatenum_and_flag) & 0x8000; + u64 tstamp = le64_to_cpu(gh->timestamp); desc = gh->u.desc; while (((char *)desc - (char *)gh) < @@ -634,6 +640,7 @@ roll_one(struct fs *fs, u64 *addrp, struct page *p, struct page *pg, cnt == 0 || bytes == DescHole ? bytes : blocksize, + tstamp, pg); bnum++; }