From ec3284816d56c363630fd28c5766eb749fd25d90 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 23 Jun 2010 12:23:50 +1000 Subject: [PATCH] Fix inode_orphan_handler issues. 1/ a stray ';' caused a while loop not to work. 2/ If the for loop finds a block with a 'primary' reference, just incorporating it won't help. We need to find the last block so we know it has not primary reference, so it will get unpinned by the lafs_cluster_allocate call, and so will remove the primary reference. Signed-off-by: NeilBrown --- inode.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/inode.c b/inode.c index 29974d5..027f856 100644 --- a/inode.c +++ b/inode.c @@ -641,8 +641,9 @@ void lafs_inode_handle_orphan(struct datablock *b) ino->i_sb->s_blocksize - 1) >> ino->i_sb->s_blocksize_bits; /* Find a Pinned descendent of ib which has no - * Pinned descendents. - * Prefer blocks that are beyond EOF. + * Pinned descendents and no PrimaryRef dependent + * (so take the last). + * Prefer blocks that are beyond EOF (again, take the last). * If there are none, descend the last block that * is not after EOF and look at its children. */ @@ -654,10 +655,6 @@ void lafs_inode_handle_orphan(struct datablock *b) if (!test_bit(B_Index, &tmp->b.flags) || !test_bit(B_Pinned, &tmp->b.flags)) continue; - if (tmp->b.fileaddr >= lastaddr) { - next = tmp; - break; - } if (next == NULL || tmp->b.fileaddr > next->b.fileaddr) next = tmp; @@ -688,11 +685,9 @@ void lafs_inode_handle_orphan(struct datablock *b) do_restart = 0; goto out2; } - while (ib2->uninc_table.pending_cnt || ib2->uninc); + while (ib2->uninc_table.pending_cnt || ib2->uninc) lafs_incorporate(fs, ib2); - /* FIXME should I just cluster_allocate and let - * it figure things out ?? - */ + if (test_bit(B_Dirty, &ib2->b.flags) || test_bit(B_Realloc, &ib2->b.flags)) lafs_cluster_allocate(&ib2->b, 0); -- 2.39.5