]> git.neil.brown.name Git - LaFS.git/commitdiff
cleaner_parse: use truncate number to avoid looking at old inodes.
authorNeilBrown <neilb@suse.de>
Sat, 14 Aug 2010 10:55:23 +0000 (20:55 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 14 Aug 2010 10:55:23 +0000 (20:55 +1000)
That is why we have the truncnumber in the cluster head after all.

Signed-off-by: NeilBrown <neilb@suse.de>
clean.c

diff --git a/clean.c b/clean.c
index f5f48bdbe35674fd2de39b592bd7b4722a261e1e..ac59aed7159ead38337a08223370f053a962adb8 100644 (file)
--- a/clean.c
+++ b/clean.c
@@ -183,6 +183,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc)
        u32 bnum;
        int bcnt;
        u32 inum, fsnum;
+       u16 trunc;
        struct inode *ino = NULL;
        int again = 0;
 
@@ -257,6 +258,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc)
                }
                inum = le32_to_cpu(tc->gh->inum);
                fsnum = le32_to_cpu(tc->gh->fsnum);
+               trunc = le16_to_cpu(tc->gh->truncatenum_and_flag) & 0x7fff;
 
                if (inum == 0xFFFFFFFF &&
                    fsnum == 0xFFFFFFFF) {
@@ -278,6 +280,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc)
                        ino = lafs_iget_fs(fs, fsnum, inum, ASYNC);
                }
                if (!IS_ERR(ino)) {
+                       int itrunc;
                        struct datablock *b;
                        dprintk("got the inode\n");
                        /* Minor optimisation for files that have shrunk */
@@ -289,6 +292,14 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc)
                            (LAFSI(ino)->type >= TypeBase &&
                             ((loff_t)bnum << ino->i_blkbits) >= i_size_read(ino)))
                                goto skip;
+                       itrunc = ((ino->i_generation<<8) |
+                                 (LAFSI(ino)->trunc_gen & 0xff)) & 0x7fff;
+                       if (itrunc != trunc) {
+                               /* file has been truncated or replaced since
+                                * this cluster
+                                */
+                               goto skip_inode;
+                       }
                        b = lafs_get_block(ino, bnum, NULL, GFP_NOFS,
                                           MKREF(cleaning));
                        if (b == NULL)
@@ -338,6 +349,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc)
                        /* inode not found, make sure we never
                         * look for it again
                         */
+               skip_inode:
                        tc->gh->inum = 0xFFFFFFFF;
                        tc->gh->fsnum = 0xFFFFFFFF;
                        tc->desc++;