return -ENOSPC;
 }
 
+int sm_ll_find_common_free_block(struct ll_disk *old_ll, struct ll_disk *new_ll,
+                                dm_block_t begin, dm_block_t end, dm_block_t *b)
+{
+       int r;
+       uint32_t count;
+
+       do {
+               r = sm_ll_find_free_block(new_ll, begin, new_ll->nr_blocks, b);
+               if (r)
+                       break;
+
+               /* double check this block wasn't used in the old transaction */
+               if (*b >= old_ll->nr_blocks)
+                       count = 0;
+               else {
+                       r = sm_ll_lookup(old_ll, *b, &count);
+                       if (r)
+                               break;
+
+                       if (count)
+                               begin = *b + 1;
+               }
+       } while (count);
+
+       return r;
+}
+
 static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b,
                        int (*mutator)(void *context, uint32_t old, uint32_t *new),
                        void *context, enum allocation_event *ev)
 
 int sm_ll_lookup(struct ll_disk *ll, dm_block_t b, uint32_t *result);
 int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
                          dm_block_t end, dm_block_t *result);
+int sm_ll_find_common_free_block(struct ll_disk *old_ll, struct ll_disk *new_ll,
+                                dm_block_t begin, dm_block_t end, dm_block_t *result);
 int sm_ll_insert(struct ll_disk *ll, dm_block_t b, uint32_t ref_count, enum allocation_event *ev);
 int sm_ll_inc(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev);
 int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev);
 
        enum allocation_event ev;
        struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
 
-       /* FIXME: we should loop round a couple of times */
-       r = sm_ll_find_free_block(&smd->old_ll, smd->begin, smd->old_ll.nr_blocks, b);
+       /*
+        * Any block we allocate has to be free in both the old and current ll.
+        */
+       r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b);
        if (r)
                return r;
 
 
        enum allocation_event ev;
        struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
 
-       r = sm_ll_find_free_block(&smm->old_ll, smm->begin, smm->old_ll.nr_blocks, b);
+       /*
+        * Any block we allocate has to be free in both the old and current ll.
+        */
+       r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b);
        if (r)
                return r;