diff options
author | Joe Thornber | 2012-07-27 15:08:08 +0100 |
---|---|---|
committer | Alasdair G Kergon | 2012-07-27 15:08:08 +0100 |
commit | eb04cf634fc2d5e3bc8fe88fbf434eda4921d875 (patch) | |
tree | 92948b71b13387b85ec3da1b6471074df3cd6c07 | |
parent | 51a0f659c03ccc8ec407c7a9f9701d1b4618d515 (diff) |
dm thin metadata: stop tracking need for commit
Remove an optimisation that tracks whether or not a thin metadata commit
is needed.
If dm_pool_commit_metadata() is called and no changes have been made
to the metadata then this optimisation avoided writing to disk.
Removing because we're going to do something better later.
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>
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index afd84cacca4b..c8f36227fd7b 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -178,7 +178,6 @@ struct dm_pool_metadata { struct rw_semaphore root_lock; uint32_t time; - int need_commit; dm_block_t root; dm_block_t details_root; struct list_head thin_devices; @@ -479,7 +478,6 @@ static int init_pmd(struct dm_pool_metadata *pmd, init_rwsem(&pmd->root_lock); pmd->time = 0; - pmd->need_commit = 0; pmd->details_root = 0; pmd->trans_id = 0; pmd->flags = 0; @@ -504,11 +502,6 @@ static int __begin_transaction(struct dm_pool_metadata *pmd) struct dm_block *sblock; /* - * __maybe_commit_transaction() resets these - */ - WARN_ON(pmd->need_commit); - - /* * We re-read the superblock every time. Shouldn't need to do this * really. */ @@ -583,8 +576,6 @@ static int __write_changed_details(struct dm_pool_metadata *pmd) list_del(&td->list); kfree(td); } - - pmd->need_commit = 1; } return 0; @@ -609,9 +600,6 @@ static int __commit_transaction(struct dm_pool_metadata *pmd) if (r < 0) return r; - if (!pmd->need_commit) - return r; - r = dm_sm_commit(pmd->data_sm); if (r < 0) return r; @@ -650,11 +638,7 @@ static int __commit_transaction(struct dm_pool_metadata *pmd) if (r < 0) goto out_locked; - r = dm_tm_commit(pmd->tm, sblock); - if (!r) - pmd->need_commit = 0; - - return r; + return dm_tm_commit(pmd->tm, sblock); out_locked: dm_bm_unlock(sblock); @@ -744,7 +728,6 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, } pmd->flags = 0; - pmd->need_commit = 1; r = dm_pool_commit_metadata(pmd); if (r < 0) { DMERR("%s: dm_pool_commit_metadata() failed, error = %d", @@ -1042,8 +1025,6 @@ static int __delete_device(struct dm_pool_metadata *pmd, dm_thin_id dev) if (r) return r; - pmd->need_commit = 1; - return 0; } @@ -1071,7 +1052,6 @@ int dm_pool_set_metadata_transaction_id(struct dm_pool_metadata *pmd, } pmd->trans_id = new_id; - pmd->need_commit = 1; up_write(&pmd->root_lock); return 0; @@ -1113,8 +1093,6 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd) dm_tm_dec(pmd->tm, held_root); dm_tm_unlock(pmd->tm, copy); - pmd->need_commit = 1; - return -EBUSY; } @@ -1140,16 +1118,12 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd) &sb_validator, &sblock); if (r) { dm_tm_dec(pmd->tm, held_root); - pmd->need_commit = 1; return r; } disk_super = dm_block_data(sblock); disk_super->held_root = cpu_to_le64(held_root); dm_bm_unlock(sblock); - - pmd->need_commit = 1; - return 0; } @@ -1179,7 +1153,6 @@ static int __release_metadata_snap(struct dm_pool_metadata *pmd) disk_super = dm_block_data(sblock); held_root = le64_to_cpu(disk_super->held_root); disk_super->held_root = cpu_to_le64(0); - pmd->need_commit = 1; dm_bm_unlock(sblock); @@ -1317,7 +1290,6 @@ static int __insert(struct dm_thin_device *td, dm_block_t block, struct dm_pool_metadata *pmd = td->pmd; dm_block_t keys[2] = { td->id, block }; - pmd->need_commit = 1; value = cpu_to_le64(pack_block_time(data_block, pmd->time)); __dm_bless_for_disk(&value); @@ -1358,7 +1330,6 @@ static int __remove(struct dm_thin_device *td, dm_block_t block) td->mapped_blocks--; td->changed = 1; - pmd->need_commit = 1; return 0; } @@ -1379,10 +1350,7 @@ int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result) int r; down_write(&pmd->root_lock); - r = dm_sm_new_block(pmd->data_sm, result); - pmd->need_commit = 1; - up_write(&pmd->root_lock); return r; @@ -1519,11 +1487,7 @@ static int __resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count) return -EINVAL; } - r = dm_sm_extend(pmd->data_sm, new_count - old_count); - if (!r) - pmd->need_commit = 1; - - return r; + return dm_sm_extend(pmd->data_sm, new_count - old_count); } int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count) |