]> git.neil.brown.name Git - LaFS.git/commitdiff
Fix pruning of orphan file.
authorNeilBrown <neilb@suse.de>
Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)
The test for "now beyond EOF" was all wrong.

orphan.c

index 5f96003bf7b8995b1242565a689ee475e4792fba..fce204394e83fb114c168f054f3d8195234f2549 100644 (file)
--- a/orphan.c
+++ b/orphan.c
@@ -212,11 +212,14 @@ static void orphan_abort(struct fs *fs)
        putdref(b, MKREF(orphanx));
 
        /* If this was the last block in the file,
-        * we need to punch a hole
+        * we need to punch a hole.
+        * i.e. if the first unneeded slot is at or before
+        * the first slot in this block, we don't want
+        * this block.
         */
-       if (((om->nextfree + om->reserved + 1) >>
-            (fs->prime_sb->s_blocksize_bits-4))
-           != bnum)
+       if ((om->nextfree + om->reserved) <=
+           (bnum << (fs->prime_sb->s_blocksize_bits-4))
+               )
                lafs_erase_dblock(b);
 
        putdref(b, MKREF(orphan_reserve));