Skip to content

Commit

Permalink
dm cache: avoid preallocation if no work in writeback_some_dirty_bloc…
Browse files Browse the repository at this point in the history
…ks()

Refactor writeback_some_dirty_blocks() to avoid prealloc_data_structs()
if the policy doesn't have any dirty blocks ready for writeback.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Mike Snitzer committed Jul 17, 2015
1 parent 386cb7c commit e782eff
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,6 @@ static void process_deferred_writethrough_bios(struct cache *cache)

static void writeback_some_dirty_blocks(struct cache *cache)
{
int r = 0;
dm_oblock_t oblock;
dm_cblock_t cblock;
struct prealloc structs;
Expand All @@ -2071,15 +2070,11 @@ static void writeback_some_dirty_blocks(struct cache *cache)
memset(&structs, 0, sizeof(structs));

while (spare_migration_bandwidth(cache)) {
if (prealloc_data_structs(cache, &structs))
break;

r = policy_writeback_work(cache->policy, &oblock, &cblock, busy);
if (r)
break;
if (policy_writeback_work(cache->policy, &oblock, &cblock, busy))
break; /* no work to do */

r = get_cell(cache, oblock, &structs, &old_ocell);
if (r) {
if (prealloc_data_structs(cache, &structs) ||
get_cell(cache, oblock, &structs, &old_ocell)) {
policy_set_dirty(cache->policy, oblock);
break;
}
Expand Down

0 comments on commit e782eff

Please sign in to comment.