diff options
author | Mike Snitzer <snitzer@redhat.com> | 2015-07-16 21:26:10 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2015-07-16 22:32:07 -0400 |
commit | e782eff591bca2d96bac30ab5d1cfa4ccd3b0f86 (patch) | |
tree | 5e21539eba3903ddfee00729e38d5a006f2f2005 /drivers/md/dm-cache-target.c | |
parent | 386cb7cdeeef97e0bf082a8d6bbfc07a2ccce07b (diff) |
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/dm-cache-target.c')
-rw-r--r-- | drivers/md/dm-cache-target.c | 13 |
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) | |||
2061 | 2061 | ||
2062 | static void writeback_some_dirty_blocks(struct cache *cache) | 2062 | static void writeback_some_dirty_blocks(struct cache *cache) |
2063 | { | 2063 | { |
2064 | int r = 0; | ||
2065 | dm_oblock_t oblock; | 2064 | dm_oblock_t oblock; |
2066 | dm_cblock_t cblock; | 2065 | dm_cblock_t cblock; |
2067 | struct prealloc structs; | 2066 | struct prealloc structs; |
@@ -2071,15 +2070,11 @@ static void writeback_some_dirty_blocks(struct cache *cache) | |||
2071 | memset(&structs, 0, sizeof(structs)); | 2070 | memset(&structs, 0, sizeof(structs)); |
2072 | 2071 | ||
2073 | while (spare_migration_bandwidth(cache)) { | 2072 | while (spare_migration_bandwidth(cache)) { |
2074 | if (prealloc_data_structs(cache, &structs)) | 2073 | if (policy_writeback_work(cache->policy, &oblock, &cblock, busy)) |
2075 | break; | 2074 | break; /* no work to do */ |
2076 | |||
2077 | r = policy_writeback_work(cache->policy, &oblock, &cblock, busy); | ||
2078 | if (r) | ||
2079 | break; | ||
2080 | 2075 | ||
2081 | r = get_cell(cache, oblock, &structs, &old_ocell); | 2076 | if (prealloc_data_structs(cache, &structs) || |
2082 | if (r) { | 2077 | get_cell(cache, oblock, &structs, &old_ocell)) { |
2083 | policy_set_dirty(cache->policy, oblock); | 2078 | policy_set_dirty(cache->policy, oblock); |
2084 | break; | 2079 | break; |
2085 | } | 2080 | } |