diff options
author | Mike Snitzer <snitzer@redhat.com> | 2014-02-06 06:08:56 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2014-02-17 11:00:05 -0500 |
commit | 4d1662a30dde6e545086fe0e8fd7e474c4e0b639 (patch) | |
tree | 0845a7da235aceef3400a6ad7c6ab49b9c4c7ed9 | |
parent | 80ae49aaed32af72630251eb06161b15cde15ac8 (diff) |
dm thin: avoid metadata commit if a pool's thin devices haven't changed
Commit 905e51b ("dm thin: commit outstanding data every second")
introduced a periodic commit. This commit occurs regardless of whether
any thin devices have made changes.
Fix the periodic commit to check if any of a pool's thin devices have
changed using dm_pool_changed_this_transaction().
Reported-by: Alexander Larsson <alexl@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Cc: stable@vger.kernel.org
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 17 | ||||
-rw-r--r-- | drivers/md/dm-thin-metadata.h | 2 | ||||
-rw-r--r-- | drivers/md/dm-thin.c | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 7da347665552..3bb4506582a9 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
@@ -1489,6 +1489,23 @@ bool dm_thin_changed_this_transaction(struct dm_thin_device *td) | |||
1489 | return r; | 1489 | return r; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | bool dm_pool_changed_this_transaction(struct dm_pool_metadata *pmd) | ||
1493 | { | ||
1494 | bool r = false; | ||
1495 | struct dm_thin_device *td, *tmp; | ||
1496 | |||
1497 | down_read(&pmd->root_lock); | ||
1498 | list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) { | ||
1499 | if (td->changed) { | ||
1500 | r = td->changed; | ||
1501 | break; | ||
1502 | } | ||
1503 | } | ||
1504 | up_read(&pmd->root_lock); | ||
1505 | |||
1506 | return r; | ||
1507 | } | ||
1508 | |||
1492 | bool dm_thin_aborted_changes(struct dm_thin_device *td) | 1509 | bool dm_thin_aborted_changes(struct dm_thin_device *td) |
1493 | { | 1510 | { |
1494 | bool r; | 1511 | bool r; |
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h index 9a368567632f..dd6088a17a65 100644 --- a/drivers/md/dm-thin-metadata.h +++ b/drivers/md/dm-thin-metadata.h | |||
@@ -161,6 +161,8 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block); | |||
161 | */ | 161 | */ |
162 | bool dm_thin_changed_this_transaction(struct dm_thin_device *td); | 162 | bool dm_thin_changed_this_transaction(struct dm_thin_device *td); |
163 | 163 | ||
164 | bool dm_pool_changed_this_transaction(struct dm_pool_metadata *pmd); | ||
165 | |||
164 | bool dm_thin_aborted_changes(struct dm_thin_device *td); | 166 | bool dm_thin_aborted_changes(struct dm_thin_device *td); |
165 | 167 | ||
166 | int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, | 168 | int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, |
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index faaf944597ab..d501e436a7d9 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
@@ -1357,7 +1357,8 @@ static void process_deferred_bios(struct pool *pool) | |||
1357 | bio_list_init(&pool->deferred_flush_bios); | 1357 | bio_list_init(&pool->deferred_flush_bios); |
1358 | spin_unlock_irqrestore(&pool->lock, flags); | 1358 | spin_unlock_irqrestore(&pool->lock, flags); |
1359 | 1359 | ||
1360 | if (bio_list_empty(&bios) && !need_commit_due_to_time(pool)) | 1360 | if (bio_list_empty(&bios) && |
1361 | !(dm_pool_changed_this_transaction(pool->pmd) && need_commit_due_to_time(pool))) | ||
1361 | return; | 1362 | return; |
1362 | 1363 | ||
1363 | if (commit(pool)) { | 1364 | if (commit(pool)) { |