aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-thin.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2012-07-27 10:08:16 -0400
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 10:08:16 -0400
commit1f4e0ff07980820977f45d6a5dbc81d3bb9ce4d3 (patch)
tree5b5a159add010d09ea58ca12fd079b16f05333b8 /drivers/md/dm-thin.c
parente49e582965b3694f07a106adc83ddb44aa4f0890 (diff)
dm thin: commit before gathering status
Commit outstanding metadata before returning the status for a dm thin pool so that the numbers reported are as up-to-date as possible. The commit is not performed if the device is suspended or if the DM_NOFLUSH_FLAG is supplied by userspace and passed to the target through a new 'status_flags' parameter in the target's dm_status_fn. The userspace dmsetup tool will support the --noflush flag with the 'dmsetup status' and 'dmsetup wait' commands from version 1.02.76 onwards. Tested-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-thin.c')
-rw-r--r--drivers/md/dm-thin.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 087e9b34d290..af1fc3b2c2ad 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include "dm-thin-metadata.h" 7#include "dm-thin-metadata.h"
8#include "dm.h"
8 9
9#include <linux/device-mapper.h> 10#include <linux/device-mapper.h>
10#include <linux/dm-io.h> 11#include <linux/dm-io.h>
@@ -2619,7 +2620,7 @@ static void emit_flags(struct pool_features *pf, char *result,
2619 * <used data sectors>/<total data sectors> <held metadata root> 2620 * <used data sectors>/<total data sectors> <held metadata root>
2620 */ 2621 */
2621static int pool_status(struct dm_target *ti, status_type_t type, 2622static int pool_status(struct dm_target *ti, status_type_t type,
2622 char *result, unsigned maxlen) 2623 unsigned status_flags, char *result, unsigned maxlen)
2623{ 2624{
2624 int r; 2625 int r;
2625 unsigned sz = 0; 2626 unsigned sz = 0;
@@ -2641,6 +2642,10 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2641 break; 2642 break;
2642 } 2643 }
2643 2644
2645 /* Commit to ensure statistics aren't out-of-date */
2646 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti))
2647 (void) commit_or_fallback(pool);
2648
2644 r = dm_pool_get_metadata_transaction_id(pool->pmd, 2649 r = dm_pool_get_metadata_transaction_id(pool->pmd,
2645 &transaction_id); 2650 &transaction_id);
2646 if (r) 2651 if (r)
@@ -2968,7 +2973,7 @@ static void thin_postsuspend(struct dm_target *ti)
2968 * <nr mapped sectors> <highest mapped sector> 2973 * <nr mapped sectors> <highest mapped sector>
2969 */ 2974 */
2970static int thin_status(struct dm_target *ti, status_type_t type, 2975static int thin_status(struct dm_target *ti, status_type_t type,
2971 char *result, unsigned maxlen) 2976 unsigned status_flags, char *result, unsigned maxlen)
2972{ 2977{
2973 int r; 2978 int r;
2974 ssize_t sz = 0; 2979 ssize_t sz = 0;