diff options
author | Heinz Mauelshagen <heinzm@redhat.com> | 2013-10-14 17:24:43 +0200 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2013-11-09 18:20:24 -0500 |
commit | ffcbcb6720ab6a4bb6e0a51b3711e8c60872d281 (patch) | |
tree | 68cad35eb1e891e819979babe5b00775ed186ba0 /drivers/md/dm-cache-target.c | |
parent | 40c57f475f416ab241124e1e6a593b2f982eaae3 (diff) | |
download | lwn-ffcbcb6720ab6a4bb6e0a51b3711e8c60872d281.tar.gz lwn-ffcbcb6720ab6a4bb6e0a51b3711e8c60872d281.zip |
dm cache: optimize commit_if_needed
Check commit_requested flag _before_ calling
dm_cache_changed_this_transaction() superfluously.
Also, be sure to set last_commit_jiffies _after_ dm_cache_commit()
completes.
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-cache-target.c')
-rw-r--r-- | drivers/md/dm-cache-target.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 05a10c02043f..4b564069e08f 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -1234,15 +1234,17 @@ static int need_commit_due_to_time(struct cache *cache) static int commit_if_needed(struct cache *cache) { - if (dm_cache_changed_this_transaction(cache->cmd) && - (cache->commit_requested || need_commit_due_to_time(cache))) { + int r = 0; + + if ((cache->commit_requested || need_commit_due_to_time(cache)) && + dm_cache_changed_this_transaction(cache->cmd)) { atomic_inc(&cache->stats.commit_count); - cache->last_commit_jiffies = jiffies; cache->commit_requested = false; - return dm_cache_commit(cache->cmd, false); + r = dm_cache_commit(cache->cmd, false); + cache->last_commit_jiffies = jiffies; } - return 0; + return r; } static void process_deferred_bios(struct cache *cache) |