From ca26363a216e5df3f861d48c70882b7e36a75321 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 14 Aug 2010 16:38:14 +1000 Subject: [PATCH] Release stray B_Async blocks if we find them. There could still be some stray index blocks... maybe fix that later. Signed-off-by: NeilBrown --- block.c | 4 ++++ checkpoint.c | 11 ++++++++--- super.c | 8 ++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 60fe1a4..ea64fcc 100644 --- a/block.c +++ b/block.c @@ -200,6 +200,10 @@ void lafs_invalidate_page(struct page *page, unsigned long offset) * wait for any pending IO to complete (so page can be freed) */ for (i = 0; i < (1<= offset && + test_and_clear_bit(B_Async, &b[i].b.flags)) + putdref(&b[i], MKREF(Async)); + if (LAFSI(ino)->type >= TypeBase && start >= size) /* Remove block from mapping and file */ lafs_erase_dblock(&b[i]); diff --git a/checkpoint.c b/checkpoint.c index d3ba9fe..8bf84c5 100644 --- a/checkpoint.c +++ b/checkpoint.c @@ -379,9 +379,14 @@ again: while ((b = lafs_get_flushable(fs, oldphase)) != NULL) { int unlock = 1; dprintk("Checkpoint Block %s\n", strblk(b)); - /* FIXME I should check for Async children and - * de-async them. - */ + + if (test_and_clear_bit(B_Async, &b->flags)) { + /* this shouldn't normally happen, but + * it is possible, so check anyway + */ + putref(b, MKREF(async)); + lafs_wake_thread(fs); + } if (!!test_bit(B_Phase1, &b->flags) != oldphase) /* lafs_pin_dblock flipped phase for us */; diff --git a/super.c b/super.c index 9bd0ccd..36e539b 100644 --- a/super.c +++ b/super.c @@ -1246,6 +1246,14 @@ void lafs_destroy_inode(struct inode *inode) set_bit(I_Destroyed, &LAFSI(inode)->iflags); putdref(db, MKREF(destroy)); } else { + spin_lock(&inode->i_data.private_lock); + if (LAFSI(inode)->iblock) + LAFS_BUG(atomic_read(&LAFSI(inode)->iblock->b.refcnt), + &LAFSI(inode)->iblock->b); + /* FIXME could there be Async blocks keeps a refcount? + * we should free them + */ + spin_unlock(&inode->i_data.private_lock); lafs_release_index(&LAFSI(inode)->free_index); call_rcu(&LAFSI(inode)->md.rcu, kfree_inode); -- 2.39.5