From 7f2372c79b258d43c9582b8c348889fa56a91c50 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 21 Jun 2012 12:32:34 +0100 Subject: [PATCH 12/41] dm transaction manager: stop using dm_bm_unlock_move when shadowing blocks Some code, such as the space maps, keep using the old data structures secure in the knowledge they won't be changed until the next transaction. Using dm_bm_unlock_move forces a synchronous read since the old block would no longer be in the cache. Signed-off-by: Joe Thornber Signed-off-by: Mike Snitzer --- .../md/persistent-data/dm-transaction-manager.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c index b4f0583..aa75409 100644 --- a/drivers/md/persistent-data/dm-transaction-manager.c +++ b/drivers/md/persistent-data/dm-transaction-manager.c @@ -219,13 +219,24 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig, if (r < 0) return r; - r = dm_bm_unlock_move(orig_block, new); - if (r < 0) { + /* + * It would be tempting to use dm_bm_unlock_move here. But some + * code, such as the space maps, keep using the old data structures + * - secure in the knowledge they wont be changed until the next + * transaction. Using unlock_move would force a synchronous read + * since the old block would no longer be in the cache. + */ + r = dm_bm_write_lock_zero(tm->bm, new, v, result); + if (r) { dm_bm_unlock(orig_block); return r; } - return dm_bm_write_lock(tm->bm, new, v, result); + memcpy(dm_block_data(*result), dm_block_data(orig_block), + dm_bm_block_size(tm->bm)); + + dm_bm_unlock(orig_block); + return r; } int dm_tm_shadow_block(struct dm_transaction_manager *tm, dm_block_t orig, -- 1.7.1