Skip to content

Commit

Permalink
dm cache: optimize commit_if_needed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heinz Mauelshagen authored and Mike Snitzer committed Nov 9, 2013
1 parent 40c57f4 commit ffcbcb6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ffcbcb6

Please sign in to comment.