summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2015-07-16 21:26:10 -0400
committerMike Snitzer <snitzer@redhat.com>2015-07-16 22:32:07 -0400
commite782eff591bca2d96bac30ab5d1cfa4ccd3b0f86 (patch)
tree5e21539eba3903ddfee00729e38d5a006f2f2005 /drivers/md
parent386cb7cdeeef97e0bf082a8d6bbfc07a2ccce07b (diff)
downloadlinux-e782eff591bca2d96bac30ab5d1cfa4ccd3b0f86.tar.bz2
dm cache: avoid preallocation if no work in writeback_some_dirty_blocks()
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>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-cache-target.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index c8a160b37412..408dd276d6c9 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -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;
@@ -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;
}