/* Ensure that all unmapped FMRs are fully invalidated.  */
int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
/* Ensure that all unmapped FMRs are fully invalidated.  */
int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
{
	int serial;
	struct ib_pool_fmr *fmr, *next;
	spin_lock_irq(&pool->pool_lock);
	list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
		if (fmr->remap_count > 0)
			list_move(&fmr->list, &pool->dirty_list);
	}
	spin_unlock_irq(&pool->pool_lock);
	serial = atomic_inc_return(&pool->req_ser);
	wake_up_process(pool->thread);
	if (wait_event_interruptible(pool->force_wait,
				     atomic_read(&pool->flush_ser) - serial >= 0))
		return -EINTR;
	return 0;
}