/* nilfs_btnode_delete() invalidates the specified buffer and delete the page including the buffer if the page gets unbusy.  */
void nilfs_btnode_delete(struct buffer_head *bh)
/* nilfs_btnode_delete() invalidates the specified buffer and delete the page including the buffer if the page gets unbusy.  */
void nilfs_btnode_delete(struct buffer_head *bh)
{
	struct address_space *mapping;
	struct page *page = bh->b_page;
	pgoff_t index = page_index(page);
	int still_dirty;
	page_cache_get(page);
	lock_page(page);
	wait_on_page_writeback(page);
	nilfs_forget_buffer(bh);
	still_dirty = PageDirty(page);
	mapping = page->mapping;
	unlock_page(page);
	page_cache_release(page);
	if (!still_dirty && mapping)
		invalidate_inode_pages2_range(mapping, index, index);
}