From db22d8a1f38fea318943a8ee8f836702c60ecc94 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 3 Sep 2009 15:28:20 +1000 Subject: [PATCH] Fix pruning of orphan file. The test for "now beyond EOF" was all wrong. --- orphan.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/orphan.c b/orphan.c index 5f96003..fce2043 100644 --- 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)); -- 2.39.5