]> git.neil.brown.name Git - LaFS.git/commitdiff
FORMAT CHANGE add timestamp to group head in write cluster
authorNeilBrown <neilb@suse.de>
Wed, 4 May 2011 03:47:01 +0000 (13:47 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 4 May 2011 03:47:01 +0000 (13:47 +1000)
This allows accurate preservation of timestamps during
roll forward.

Signed-off-by: NeilBrown <neilb@suse.de>
cluster.c
layout.h
roll.c

index 6233fb817e4605c5742b89913fa2113263a849cf..57fa6a6a875ae174d1e3b6af9f056ea539167365 100644 (file)
--- 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)
index afa81ed7a0c0f175b22189012981e7f7aa92c470..0095097b5af67f50a1391eb1ecb794b21443770b 100644 (file)
--- 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 e8ebbbade810b9db38ae685f2b37e52a82d121c6..7b82acdfe3efcebe96aa1e6fba90dff563bb92be 100644 (file)
--- 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++;
                                }