]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Introduce dm_thin_changed_this_transaction to dm-thin-metadata to publish a
authorJoe Thornber <ejt@redhat.com>
Tue, 24 Jul 2012 23:25:31 +0000 (09:25 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 24 Jul 2012 23:25:31 +0000 (09:25 +1000)
useful bit of information we're already tracking.  This will help dm thin
decide when to commit.

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/dm-thin-metadata.c
drivers/md/dm-thin-metadata.h

index 5ae31185e47caad41e3b67e8fb7fb17a27154a10..4f5b11c195f407349e8c2150460cadec27647051 100644 (file)
@@ -1375,10 +1375,9 @@ static int __insert(struct dm_thin_device *td, dm_block_t block,
        if (r)
                return r;
 
-       if (inserted) {
+       td->changed = 1;
+       if (inserted)
                td->mapped_blocks++;
-               td->changed = 1;
-       }
 
        return 0;
 }
@@ -1422,6 +1421,17 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block)
        return r;
 }
 
+bool dm_thin_changed_this_transaction(struct dm_thin_device *td)
+{
+       int r;
+
+       down_read(&td->pmd->root_lock);
+       r = td->changed;
+       up_read(&td->pmd->root_lock);
+
+       return r;
+}
+
 int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result)
 {
        int r;
index 7e6656c49bd5707eb5f34d48c0101b2d69582079..1632fec1660d0ac32f97fe41832c207ab6a8c7ed 100644 (file)
@@ -148,6 +148,8 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block);
 /*
  * Queries.
  */
+bool dm_thin_changed_this_transaction(struct dm_thin_device *td);
+
 int dm_thin_get_highest_mapped_block(struct dm_thin_device *td,
                                     dm_block_t *highest_mapped);