--- drivers/md/dm-exception-store.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) Index: linux-2.6.28-rc2-devel/drivers/md/dm-exception-store.c =================================================================== --- linux-2.6.28-rc2-devel.orig/drivers/md/dm-exception-store.c 2008-10-27 20:31:20.000000000 +0100 +++ linux-2.6.28-rc2-devel/drivers/md/dm-exception-store.c 2008-10-27 20:31:25.000000000 +0100 @@ -94,6 +94,7 @@ struct pstore { struct dm_snapshot *snap; /* up pointer to my snapshot */ int version; int valid; + int merging; /* 1 if there is mering going on */ uint32_t exceptions_per_area; /* @@ -482,11 +483,15 @@ static struct pstore *get_info(struct ex static void persistent_fraction_full(struct exception_store *store, sector_t *numerator, sector_t *denominator) { + struct pstore *ps = get_info(store); /* * Compensate for the first two chunks that are always allocated. * Make sure that we return 0 when there are no exceptions. */ - *numerator = (get_info(store)->next_free - 2) * store->snap->chunk_size; + if (!ps->merging) + *numerator = (ps->next_free - 2) * store->snap->chunk_size; + else + *numerator = (area_location(ps, ps->current_area) - 1 + ps->current_committed) * store->snap->chunk_size; *denominator = get_dev_size(store->snap->cow->bdev) - 2 * store->snap->chunk_size; } @@ -577,6 +582,8 @@ static int persistent_prepare(struct exc chunk_t next_free; sector_t size = get_dev_size(store->snap->cow->bdev); + ps->merging = 0; + /* Is there enough room ? */ if (size < ((ps->next_free + 1) * store->snap->chunk_size)) return -ENOSPC; @@ -664,6 +671,8 @@ static int persistent_prepare_merge(stru struct pstore *ps = get_info(store); struct disk_exception de; + ps->merging = 1; + if (!ps->current_committed) { if (!ps->current_area) return 0; @@ -741,6 +750,7 @@ int dm_create_persistent(struct exceptio ps->snap = store->snap; ps->valid = 1; + ps->merging = 0; ps->version = SNAPSHOT_DISK_VERSION; ps->area = NULL; ps->next_free = 2; /* skipping the header and first area */