From: NeilBrown Date: Sat, 14 Aug 2010 10:55:23 +0000 (+1000) Subject: cleaner_parse: use truncate number to avoid looking at old inodes. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=eb36b5d4c6336c105f16cf99d713cf4fd49e2fcc;p=LaFS.git cleaner_parse: use truncate number to avoid looking at old inodes. That is why we have the truncnumber in the cluster head after all. Signed-off-by: NeilBrown --- diff --git a/clean.c b/clean.c index f5f48bd..ac59aed 100644 --- 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++;