diff options
author | Mike Snitzer <snitzer@redhat.com> | 2015-07-16 21:48:55 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2015-07-16 22:32:08 -0400 |
commit | 665022d72f9b5762f21b5ea02fa0503d04802849 (patch) | |
tree | d7760993f35eac82be5f165d385b3f05fb1f4552 /drivers/md/dm-cache-target.c | |
parent | e782eff591bca2d96bac30ab5d1cfa4ccd3b0f86 (diff) |
dm cache: avoid calls to prealloc_free_structs() if possible
If no work was performed then prealloc_data_structs() wasn't ever called
so there isn't any need to call prealloc_free_structs().
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 | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 408dd276d6c9..b680da5d7b93 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c | |||
@@ -1946,6 +1946,7 @@ static int commit_if_needed(struct cache *cache) | |||
1946 | 1946 | ||
1947 | static void process_deferred_bios(struct cache *cache) | 1947 | static void process_deferred_bios(struct cache *cache) |
1948 | { | 1948 | { |
1949 | bool prealloc_used = false; | ||
1949 | unsigned long flags; | 1950 | unsigned long flags; |
1950 | struct bio_list bios; | 1951 | struct bio_list bios; |
1951 | struct bio *bio; | 1952 | struct bio *bio; |
@@ -1980,13 +1981,16 @@ static void process_deferred_bios(struct cache *cache) | |||
1980 | process_discard_bio(cache, &structs, bio); | 1981 | process_discard_bio(cache, &structs, bio); |
1981 | else | 1982 | else |
1982 | process_bio(cache, &structs, bio); | 1983 | process_bio(cache, &structs, bio); |
1984 | prealloc_used = true; | ||
1983 | } | 1985 | } |
1984 | 1986 | ||
1985 | prealloc_free_structs(cache, &structs); | 1987 | if (prealloc_used) |
1988 | prealloc_free_structs(cache, &structs); | ||
1986 | } | 1989 | } |
1987 | 1990 | ||
1988 | static void process_deferred_cells(struct cache *cache) | 1991 | static void process_deferred_cells(struct cache *cache) |
1989 | { | 1992 | { |
1993 | bool prealloc_used = false; | ||
1990 | unsigned long flags; | 1994 | unsigned long flags; |
1991 | struct dm_bio_prison_cell *cell, *tmp; | 1995 | struct dm_bio_prison_cell *cell, *tmp; |
1992 | struct list_head cells; | 1996 | struct list_head cells; |
@@ -2014,9 +2018,11 @@ static void process_deferred_cells(struct cache *cache) | |||
2014 | } | 2018 | } |
2015 | 2019 | ||
2016 | process_cell(cache, &structs, cell); | 2020 | process_cell(cache, &structs, cell); |
2021 | prealloc_used = true; | ||
2017 | } | 2022 | } |
2018 | 2023 | ||
2019 | prealloc_free_structs(cache, &structs); | 2024 | if (prealloc_used) |
2025 | prealloc_free_structs(cache, &structs); | ||
2020 | } | 2026 | } |
2021 | 2027 | ||
2022 | static void process_deferred_flush_bios(struct cache *cache, bool submit_bios) | 2028 | static void process_deferred_flush_bios(struct cache *cache, bool submit_bios) |
@@ -2061,6 +2067,7 @@ static void process_deferred_writethrough_bios(struct cache *cache) | |||
2061 | 2067 | ||
2062 | static void writeback_some_dirty_blocks(struct cache *cache) | 2068 | static void writeback_some_dirty_blocks(struct cache *cache) |
2063 | { | 2069 | { |
2070 | bool prealloc_used = false; | ||
2064 | dm_oblock_t oblock; | 2071 | dm_oblock_t oblock; |
2065 | dm_cblock_t cblock; | 2072 | dm_cblock_t cblock; |
2066 | struct prealloc structs; | 2073 | struct prealloc structs; |
@@ -2080,9 +2087,11 @@ static void writeback_some_dirty_blocks(struct cache *cache) | |||
2080 | } | 2087 | } |
2081 | 2088 | ||
2082 | writeback(cache, &structs, oblock, cblock, old_ocell); | 2089 | writeback(cache, &structs, oblock, cblock, old_ocell); |
2090 | prealloc_used = true; | ||
2083 | } | 2091 | } |
2084 | 2092 | ||
2085 | prealloc_free_structs(cache, &structs); | 2093 | if (prealloc_used) |
2094 | prealloc_free_structs(cache, &structs); | ||
2086 | } | 2095 | } |
2087 | 2096 | ||
2088 | /*---------------------------------------------------------------- | 2097 | /*---------------------------------------------------------------- |