Commit f4b90369 authored by Joe Thornber's avatar Joe Thornber Committed by Alasdair G Kergon

dm persistent data: only commit space map if index changed

Introduce bitmap_index_changed to track whether or not the index changed
then only commit a space map if it did.
Signed-off-by: default avatarJoe Thornber <ejt@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 8d44c98a
...@@ -224,6 +224,7 @@ static int sm_ll_init(struct ll_disk *ll, struct dm_transaction_manager *tm) ...@@ -224,6 +224,7 @@ static int sm_ll_init(struct ll_disk *ll, struct dm_transaction_manager *tm)
ll->nr_blocks = 0; ll->nr_blocks = 0;
ll->bitmap_root = 0; ll->bitmap_root = 0;
ll->ref_count_root = 0; ll->ref_count_root = 0;
ll->bitmap_index_changed = false;
return 0; return 0;
} }
...@@ -476,7 +477,15 @@ int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev) ...@@ -476,7 +477,15 @@ int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev)
int sm_ll_commit(struct ll_disk *ll) int sm_ll_commit(struct ll_disk *ll)
{ {
return ll->commit(ll); int r = 0;
if (ll->bitmap_index_changed) {
r = ll->commit(ll);
if (!r)
ll->bitmap_index_changed = false;
}
return r;
} }
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
...@@ -491,6 +500,7 @@ static int metadata_ll_load_ie(struct ll_disk *ll, dm_block_t index, ...@@ -491,6 +500,7 @@ static int metadata_ll_load_ie(struct ll_disk *ll, dm_block_t index,
static int metadata_ll_save_ie(struct ll_disk *ll, dm_block_t index, static int metadata_ll_save_ie(struct ll_disk *ll, dm_block_t index,
struct disk_index_entry *ie) struct disk_index_entry *ie)
{ {
ll->bitmap_index_changed = true;
memcpy(ll->mi_le.index + index, ie, sizeof(*ie)); memcpy(ll->mi_le.index + index, ie, sizeof(*ie));
return 0; return 0;
} }
......
...@@ -78,6 +78,7 @@ struct ll_disk { ...@@ -78,6 +78,7 @@ struct ll_disk {
open_index_fn open_index; open_index_fn open_index;
max_index_entries_fn max_entries; max_index_entries_fn max_entries;
commit_fn commit; commit_fn commit;
bool bitmap_index_changed:1;
}; };
struct disk_sm_root { struct disk_sm_root {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment