]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Introduce bitmap_index_changed to track whether or not the index changed
authorJoe Thornber <ejt@redhat.com>
Tue, 24 Jul 2012 23:25:20 +0000 (09:25 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 24 Jul 2012 23:25:20 +0000 (09:25 +1000)
then only commit a space map if it did.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/persistent-data/dm-space-map-common.c
drivers/md/persistent-data/dm-space-map-common.h

index ff3beed6ad2d93769e475539ecd60d29ffdfaf22..d77602d63c83f8b98e341dd07c1dd50c397986e4 100644 (file)
@@ -224,6 +224,7 @@ static int sm_ll_init(struct ll_disk *ll, struct dm_transaction_manager *tm)
        ll->nr_blocks = 0;
        ll->bitmap_root = 0;
        ll->ref_count_root = 0;
+       ll->bitmap_index_changed = false;
 
        return 0;
 }
@@ -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)
 {
-       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,
 static int metadata_ll_save_ie(struct ll_disk *ll, dm_block_t index,
                               struct disk_index_entry *ie)
 {
+       ll->bitmap_index_changed = true;
        memcpy(ll->mi_le.index + index, ie, sizeof(*ie));
        return 0;
 }
index 8f220821a9a9a336a175c1f748f20399abf7a14b..b3078d5eda0c335c2986b84128d3e5bde01e8b8e 100644 (file)
@@ -78,6 +78,7 @@ struct ll_disk {
        open_index_fn open_index;
        max_index_entries_fn max_entries;
        commit_fn commit;
+       bool bitmap_index_changed:1;
 };
 
 struct disk_sm_root {