]> git.neil.brown.name Git - LaFS.git/commitdiff
Fix beyond-eof check when cleaning
authorNeilBrown <neilb@suse.de>
Wed, 2 Sep 2009 00:55:20 +0000 (10:55 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 2 Sep 2009 00:55:20 +0000 (10:55 +1000)
special files don't maintain i_size, so we must not compare against
that when cleaning them.

clean.c

diff --git a/clean.c b/clean.c
index 799b949189b5be44694eeb15678b07fe9feb55c9..0f325f9251d18f81cae26792edaa04f76aa3aea2 100644 (file)
--- a/clean.c
+++ b/clean.c
@@ -261,7 +261,7 @@ static int try_clean(struct fs *fs, struct toclean *tc)
        int again = 0;
        u32 bnum;
        int bcnt;
-       int inum, fsnum;
+       u32 inum, fsnum;
        struct inode *ino = NULL;
        struct datablock *b, *tmp;
 
@@ -391,12 +391,10 @@ static int try_clean(struct fs *fs, struct toclean *tc)
                        break;
                } else {
                        dprintk("got the inode\n");
-                       if (bnum > (i_size_read(ino) >> ino->i_blkbits))
+                       /* Minor optimisation for files that have shrunk */
+                       if (LAFSI(ino)->type >= TypeBase &&
+                           (bnum << ino->i_blkbits) >= i_size_read(ino))
                                goto skip;
-                       /* FIXME that test isn't really right, and maybe
-                        * we should include some locking?? But how important
-                        * is it to avoid blocked beyond EOF anyway??
-                        */
                        b = lafs_get_block(ino, bnum, NULL, GFP_NOFS,
                                           MKREF(cleaning));
                        if (b == NULL)