diff options
author | Mike Snitzer <snitzer@redhat.com> | 2012-05-18 20:01:01 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-05-18 20:01:01 -0400 |
commit | f402693d06f32e746c6153e459c5fb064fa02741 (patch) | |
tree | c4cfcf2702b3e5a1e94e3c3b923b52c413e4325a /drivers | |
parent | 36be50515fe2aef61533b516fa2576a2c7fe7664 (diff) |
dm thin: fix table output when pool target disables discard passdown internally
When the thin pool target clears the discard_passdown parameter
internally, it incorrectly changes the table line reported to userspace.
This breaks dumb string comparisons on these table lines in generic
userspace device-mapper library code and leads to tables being reloaded
repeatedly when nothing is actually meant to be changing.
This patch corrects this by no longer changing the table line when
discard passdown was disabled.
We can still tell when discard passdown is overridden by looking for the
message "Discard unsupported by data device (sdX): Disabling discard passdown."
This automatic detection is also moved from the 'load' to the 'resume'
so that it is re-evaluated should the properties of underlying devices
change.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-thin.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 2fd87b544a93..eb3d138ff55a 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
@@ -1632,6 +1632,21 @@ static int bind_control_target(struct pool *pool, struct dm_target *ti) | |||
1632 | pool->low_water_blocks = pt->low_water_blocks; | 1632 | pool->low_water_blocks = pt->low_water_blocks; |
1633 | pool->pf = pt->pf; | 1633 | pool->pf = pt->pf; |
1634 | 1634 | ||
1635 | /* | ||
1636 | * If discard_passdown was enabled verify that the data device | ||
1637 | * supports discards. Disable discard_passdown if not; otherwise | ||
1638 | * -EOPNOTSUPP will be returned. | ||
1639 | */ | ||
1640 | if (pt->pf.discard_passdown) { | ||
1641 | struct request_queue *q = bdev_get_queue(pt->data_dev->bdev); | ||
1642 | if (!q || !blk_queue_discard(q)) { | ||
1643 | char buf[BDEVNAME_SIZE]; | ||
1644 | DMWARN("Discard unsupported by data device (%s): Disabling discard passdown.", | ||
1645 | bdevname(pt->data_dev->bdev, buf)); | ||
1646 | pool->pf.discard_passdown = 0; | ||
1647 | } | ||
1648 | } | ||
1649 | |||
1635 | return 0; | 1650 | return 0; |
1636 | } | 1651 | } |
1637 | 1652 | ||
@@ -1988,19 +2003,6 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
1988 | goto out_flags_changed; | 2003 | goto out_flags_changed; |
1989 | } | 2004 | } |
1990 | 2005 | ||
1991 | /* | ||
1992 | * If discard_passdown was enabled verify that the data device | ||
1993 | * supports discards. Disable discard_passdown if not; otherwise | ||
1994 | * -EOPNOTSUPP will be returned. | ||
1995 | */ | ||
1996 | if (pf.discard_passdown) { | ||
1997 | struct request_queue *q = bdev_get_queue(data_dev->bdev); | ||
1998 | if (!q || !blk_queue_discard(q)) { | ||
1999 | DMWARN("Discard unsupported by data device: Disabling discard passdown."); | ||
2000 | pf.discard_passdown = 0; | ||
2001 | } | ||
2002 | } | ||
2003 | |||
2004 | pt->pool = pool; | 2006 | pt->pool = pool; |
2005 | pt->ti = ti; | 2007 | pt->ti = ti; |
2006 | pt->metadata_dev = metadata_dev; | 2008 | pt->metadata_dev = metadata_dev; |
@@ -2385,7 +2387,7 @@ static int pool_status(struct dm_target *ti, status_type_t type, | |||
2385 | (unsigned long long)pt->low_water_blocks); | 2387 | (unsigned long long)pt->low_water_blocks); |
2386 | 2388 | ||
2387 | count = !pool->pf.zero_new_blocks + !pool->pf.discard_enabled + | 2389 | count = !pool->pf.zero_new_blocks + !pool->pf.discard_enabled + |
2388 | !pool->pf.discard_passdown; | 2390 | !pt->pf.discard_passdown; |
2389 | DMEMIT("%u ", count); | 2391 | DMEMIT("%u ", count); |
2390 | 2392 | ||
2391 | if (!pool->pf.zero_new_blocks) | 2393 | if (!pool->pf.zero_new_blocks) |
@@ -2394,7 +2396,7 @@ static int pool_status(struct dm_target *ti, status_type_t type, | |||
2394 | if (!pool->pf.discard_enabled) | 2396 | if (!pool->pf.discard_enabled) |
2395 | DMEMIT("ignore_discard "); | 2397 | DMEMIT("ignore_discard "); |
2396 | 2398 | ||
2397 | if (!pool->pf.discard_passdown) | 2399 | if (!pt->pf.discard_passdown) |
2398 | DMEMIT("no_discard_passdown "); | 2400 | DMEMIT("no_discard_passdown "); |
2399 | 2401 | ||
2400 | break; | 2402 | break; |