static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
 {
        int                 ret;
-       struct ib_pool_fmr *fmr;
+       struct ib_pool_fmr *fmr, *next;
        LIST_HEAD(unmap_list);
        LIST_HEAD(fmr_list);
 
 #endif
        }
 
+       /*
+        * The free_list may hold FMRs that have been put there
+        * because they haven't reached the max_remap count.
+        * Invalidate their mapping as well.
+        */
+       list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
+               if (fmr->remap_count == 0)
+                       continue;
+               hlist_del_init(&fmr->cache_node);
+               fmr->remap_count = 0;
+               list_add_tail(&fmr->fmr->list, &fmr_list);
+               list_move(&fmr->list, &unmap_list);
+       }
+
        list_splice(&pool->dirty_list, &unmap_list);
        INIT_LIST_HEAD(&pool->dirty_list);
        pool->dirty_len = 0;
 
        i = 0;
        list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) {
-               if (fmr->remap_count) {
-                       INIT_LIST_HEAD(&fmr_list);
-                       list_add_tail(&fmr->fmr->list, &fmr_list);
-                       ib_unmap_fmr(&fmr_list);
-               }
                ib_dealloc_fmr(fmr->fmr);
                list_del(&fmr->list);
                kfree(fmr);