From: Joe Thornber <[email-masked]>

Commit metadata just before providing pool status information to make the free
block counts more accurate.

Signed-off-by: Joe Thornber <[email-masked]>
Signed-off-by: Mike Snitzer <[email-masked]>

(1) Is this too slow?
(2) Commit failure should *not* cause fn failure - we still need
to get the status!  Requires readonly-on-error code first?
- agk

---
drivers/md/dm-thin.c |    9 +++++++++
 drivers/md/dm-thin.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-3.4-rc5/drivers/md/dm-thin.c
===================================================================
--- linux-3.4-rc5.orig/drivers/md/dm-thin.c
+++ linux-3.4-rc5/drivers/md/dm-thin.c
@@ -2339,6 +2339,15 @@ static int pool_status(struct dm_target 
 		if (r)
 			return r;
 
+		/*
+		 * If we're in the middle of a transaction the free block
+		 * counts can be quite out of date, so we do a quick
+		 * commit.
+		 */
+		r = dm_pool_commit_metadata(pool->pmd);
+		if (r)
+			return r;
+
 		r = dm_pool_get_free_metadata_block_count(pool->pmd,
 							  &nr_free_blocks_metadata);
 		if (r)