aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-cache-target.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-cache-target.c')
-rw-r--r--drivers/md/dm-cache-target.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 1b4e1756b169..b680da5d7b93 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -424,7 +424,6 @@ static void free_migration(struct dm_cache_migration *mg)
424 wake_up(&cache->migration_wait); 424 wake_up(&cache->migration_wait);
425 425
426 mempool_free(mg, cache->migration_pool); 426 mempool_free(mg, cache->migration_pool);
427 wake_worker(cache);
428} 427}
429 428
430static int prealloc_data_structs(struct cache *cache, struct prealloc *p) 429static int prealloc_data_structs(struct cache *cache, struct prealloc *p)
@@ -1947,6 +1946,7 @@ static int commit_if_needed(struct cache *cache)
1947 1946
1948static void process_deferred_bios(struct cache *cache) 1947static void process_deferred_bios(struct cache *cache)
1949{ 1948{
1949 bool prealloc_used = false;
1950 unsigned long flags; 1950 unsigned long flags;
1951 struct bio_list bios; 1951 struct bio_list bios;
1952 struct bio *bio; 1952 struct bio *bio;
@@ -1981,13 +1981,16 @@ static void process_deferred_bios(struct cache *cache)
1981 process_discard_bio(cache, &structs, bio); 1981 process_discard_bio(cache, &structs, bio);
1982 else 1982 else
1983 process_bio(cache, &structs, bio); 1983 process_bio(cache, &structs, bio);
1984 prealloc_used = true;
1984 } 1985 }
1985 1986
1986 prealloc_free_structs(cache, &structs); 1987 if (prealloc_used)
1988 prealloc_free_structs(cache, &structs);
1987} 1989}
1988 1990
1989static void process_deferred_cells(struct cache *cache) 1991static void process_deferred_cells(struct cache *cache)
1990{ 1992{
1993 bool prealloc_used = false;
1991 unsigned long flags; 1994 unsigned long flags;
1992 struct dm_bio_prison_cell *cell, *tmp; 1995 struct dm_bio_prison_cell *cell, *tmp;
1993 struct list_head cells; 1996 struct list_head cells;
@@ -2015,9 +2018,11 @@ static void process_deferred_cells(struct cache *cache)
2015 } 2018 }
2016 2019
2017 process_cell(cache, &structs, cell); 2020 process_cell(cache, &structs, cell);
2021 prealloc_used = true;
2018 } 2022 }
2019 2023
2020 prealloc_free_structs(cache, &structs); 2024 if (prealloc_used)
2025 prealloc_free_structs(cache, &structs);
2021} 2026}
2022 2027
2023static void process_deferred_flush_bios(struct cache *cache, bool submit_bios) 2028static void process_deferred_flush_bios(struct cache *cache, bool submit_bios)
@@ -2062,7 +2067,7 @@ static void process_deferred_writethrough_bios(struct cache *cache)
2062 2067
2063static void writeback_some_dirty_blocks(struct cache *cache) 2068static void writeback_some_dirty_blocks(struct cache *cache)
2064{ 2069{
2065 int r = 0; 2070 bool prealloc_used = false;
2066 dm_oblock_t oblock; 2071 dm_oblock_t oblock;
2067 dm_cblock_t cblock; 2072 dm_cblock_t cblock;
2068 struct prealloc structs; 2073 struct prealloc structs;
@@ -2072,23 +2077,21 @@ static void writeback_some_dirty_blocks(struct cache *cache)
2072 memset(&structs, 0, sizeof(structs)); 2077 memset(&structs, 0, sizeof(structs));
2073 2078
2074 while (spare_migration_bandwidth(cache)) { 2079 while (spare_migration_bandwidth(cache)) {
2075 if (prealloc_data_structs(cache, &structs)) 2080 if (policy_writeback_work(cache->policy, &oblock, &cblock, busy))
2076 break; 2081 break; /* no work to do */
2077 2082
2078 r = policy_writeback_work(cache->policy, &oblock, &cblock, busy); 2083 if (prealloc_data_structs(cache, &structs) ||
2079 if (r) 2084 get_cell(cache, oblock, &structs, &old_ocell)) {
2080 break;
2081
2082 r = get_cell(cache, oblock, &structs, &old_ocell);
2083 if (r) {
2084 policy_set_dirty(cache->policy, oblock); 2085 policy_set_dirty(cache->policy, oblock);
2085 break; 2086 break;
2086 } 2087 }
2087 2088
2088 writeback(cache, &structs, oblock, cblock, old_ocell); 2089 writeback(cache, &structs, oblock, cblock, old_ocell);
2090 prealloc_used = true;
2089 } 2091 }
2090 2092
2091 prealloc_free_structs(cache, &structs); 2093 if (prealloc_used)
2094 prealloc_free_structs(cache, &structs);
2092} 2095}
2093 2096
2094/*---------------------------------------------------------------- 2097/*----------------------------------------------------------------
@@ -3496,7 +3499,7 @@ static void cache_resume(struct dm_target *ti)
3496 * <#demotions> <#promotions> <#dirty> 3499 * <#demotions> <#promotions> <#dirty>
3497 * <#features> <features>* 3500 * <#features> <features>*
3498 * <#core args> <core args> 3501 * <#core args> <core args>
3499 * <policy name> <#policy args> <policy args>* <cache metadata mode> 3502 * <policy name> <#policy args> <policy args>* <cache metadata mode> <needs_check>
3500 */ 3503 */
3501static void cache_status(struct dm_target *ti, status_type_t type, 3504static void cache_status(struct dm_target *ti, status_type_t type,
3502 unsigned status_flags, char *result, unsigned maxlen) 3505 unsigned status_flags, char *result, unsigned maxlen)
@@ -3582,6 +3585,11 @@ static void cache_status(struct dm_target *ti, status_type_t type,
3582 else 3585 else
3583 DMEMIT("rw "); 3586 DMEMIT("rw ");
3584 3587
3588 if (dm_cache_metadata_needs_check(cache->cmd))
3589 DMEMIT("needs_check ");
3590 else
3591 DMEMIT("- ");
3592
3585 break; 3593 break;
3586 3594
3587 case STATUSTYPE_TABLE: 3595 case STATUSTYPE_TABLE:
@@ -3820,7 +3828,7 @@ static void cache_io_hints(struct dm_target *ti, struct queue_limits *limits)
3820 3828
3821static struct target_type cache_target = { 3829static struct target_type cache_target = {
3822 .name = "cache", 3830 .name = "cache",
3823 .version = {1, 7, 0}, 3831 .version = {1, 8, 0},
3824 .module = THIS_MODULE, 3832 .module = THIS_MODULE,
3825 .ctr = cache_ctr, 3833 .ctr = cache_ctr,
3826 .dtr = cache_dtr, 3834 .dtr = cache_dtr,