diff options
author | Joe Thornber <ejt@redhat.com> | 2013-10-30 13:29:30 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2013-11-09 18:19:59 -0500 |
commit | 238f8363b6661fd9dd9aae854917ab9c661f3652 (patch) | |
tree | c1ea27daf3c5b2b0ff37f2ee2037bd74458f1d23 /drivers/md/dm-cache-target.c | |
parent | 66cb1910df17b38334153462ec8166e48058035f (diff) |
dm cache: improve efficiency of quiescing flag management
Make the quiescing flag an atomic_t and stop protecting it with a spin
lock.
Signed-off-by: Joe Thornber <ejt@redhat.com>
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 | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 25d3253e72d0..50afdf72285b 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c | |||
@@ -149,6 +149,7 @@ struct cache { | |||
149 | atomic_t nr_migrations; | 149 | atomic_t nr_migrations; |
150 | 150 | ||
151 | wait_queue_head_t quiescing_wait; | 151 | wait_queue_head_t quiescing_wait; |
152 | atomic_t quiescing; | ||
152 | atomic_t quiescing_ack; | 153 | atomic_t quiescing_ack; |
153 | 154 | ||
154 | /* | 155 | /* |
@@ -189,7 +190,6 @@ struct cache { | |||
189 | 190 | ||
190 | bool need_tick_bio:1; | 191 | bool need_tick_bio:1; |
191 | bool sized:1; | 192 | bool sized:1; |
192 | bool quiescing:1; | ||
193 | bool commit_requested:1; | 193 | bool commit_requested:1; |
194 | bool loaded_mappings:1; | 194 | bool loaded_mappings:1; |
195 | bool loaded_discards:1; | 195 | bool loaded_discards:1; |
@@ -1353,14 +1353,7 @@ static void writeback_some_dirty_blocks(struct cache *cache) | |||
1353 | *--------------------------------------------------------------*/ | 1353 | *--------------------------------------------------------------*/ |
1354 | static bool is_quiescing(struct cache *cache) | 1354 | static bool is_quiescing(struct cache *cache) |
1355 | { | 1355 | { |
1356 | int r; | 1356 | return atomic_read(&cache->quiescing); |
1357 | unsigned long flags; | ||
1358 | |||
1359 | spin_lock_irqsave(&cache->lock, flags); | ||
1360 | r = cache->quiescing; | ||
1361 | spin_unlock_irqrestore(&cache->lock, flags); | ||
1362 | |||
1363 | return r; | ||
1364 | } | 1357 | } |
1365 | 1358 | ||
1366 | static void ack_quiescing(struct cache *cache) | 1359 | static void ack_quiescing(struct cache *cache) |
@@ -1378,23 +1371,13 @@ static void wait_for_quiescing_ack(struct cache *cache) | |||
1378 | 1371 | ||
1379 | static void start_quiescing(struct cache *cache) | 1372 | static void start_quiescing(struct cache *cache) |
1380 | { | 1373 | { |
1381 | unsigned long flags; | 1374 | atomic_inc(&cache->quiescing); |
1382 | |||
1383 | spin_lock_irqsave(&cache->lock, flags); | ||
1384 | cache->quiescing = true; | ||
1385 | spin_unlock_irqrestore(&cache->lock, flags); | ||
1386 | |||
1387 | wait_for_quiescing_ack(cache); | 1375 | wait_for_quiescing_ack(cache); |
1388 | } | 1376 | } |
1389 | 1377 | ||
1390 | static void stop_quiescing(struct cache *cache) | 1378 | static void stop_quiescing(struct cache *cache) |
1391 | { | 1379 | { |
1392 | unsigned long flags; | 1380 | atomic_set(&cache->quiescing, 0); |
1393 | |||
1394 | spin_lock_irqsave(&cache->lock, flags); | ||
1395 | cache->quiescing = false; | ||
1396 | spin_unlock_irqrestore(&cache->lock, flags); | ||
1397 | |||
1398 | atomic_set(&cache->quiescing_ack, 0); | 1381 | atomic_set(&cache->quiescing_ack, 0); |
1399 | } | 1382 | } |
1400 | 1383 | ||
@@ -2030,6 +2013,7 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
2030 | init_waitqueue_head(&cache->migration_wait); | 2013 | init_waitqueue_head(&cache->migration_wait); |
2031 | 2014 | ||
2032 | init_waitqueue_head(&cache->quiescing_wait); | 2015 | init_waitqueue_head(&cache->quiescing_wait); |
2016 | atomic_set(&cache->quiescing, 0); | ||
2033 | atomic_set(&cache->quiescing_ack, 0); | 2017 | atomic_set(&cache->quiescing_ack, 0); |
2034 | 2018 | ||
2035 | r = -ENOMEM; | 2019 | r = -ENOMEM; |
@@ -2091,7 +2075,6 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
2091 | 2075 | ||
2092 | cache->need_tick_bio = true; | 2076 | cache->need_tick_bio = true; |
2093 | cache->sized = false; | 2077 | cache->sized = false; |
2094 | cache->quiescing = false; | ||
2095 | cache->commit_requested = false; | 2078 | cache->commit_requested = false; |
2096 | cache->loaded_mappings = false; | 2079 | cache->loaded_mappings = false; |
2097 | cache->loaded_discards = false; | 2080 | cache->loaded_discards = false; |