aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-raid1.c
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2007-07-12 12:28:25 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-12 18:01:08 -0400
commit943317efdbc295e8a28df3f5cbd549d066ee8b4a (patch)
tree63eea4f14c4b3913b6755d802afb7631007a9e0e /drivers/md/dm-raid1.c
parent0764147b111b8ca886e4f2e9c9e019106b09b657 (diff)
dm raid1: clear region outside spinlock
A clear_region function is permitted to block (in practice, rare) but gets called in rh_update_states() with a spinlock held. The bits being marked and cleared by the above functions are used to update the on-disk log, but are never read directly. We can perform these operations outside the spinlock since the bits are only changed within one thread viz. - mark_region in rh_inc() - clear_region in rh_update_states(). So, we grab the clean_regions list items via list_splice() within the spinlock and defer clear_region() until we iterate over the list for deletion - similar to how the recovered_regions list is already handled. We then move the flush() call down to ensure it encapsulates the changes which are done by the later calls to clear_region(). Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/dm-raid1.c')
-rw-r--r--drivers/md/dm-raid1.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index b3bba98af772..04dce7a66494 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -378,10 +378,8 @@ static void rh_update_states(struct region_hash *rh)
378 list_splice(&rh->clean_regions, &clean); 378 list_splice(&rh->clean_regions, &clean);
379 INIT_LIST_HEAD(&rh->clean_regions); 379 INIT_LIST_HEAD(&rh->clean_regions);
380 380
381 list_for_each_entry (reg, &clean, list) { 381 list_for_each_entry(reg, &clean, list)
382 rh->log->type->clear_region(rh->log, reg->key);
383 list_del(&reg->hash_list); 382 list_del(&reg->hash_list);
384 }
385 } 383 }
386 384
387 if (!list_empty(&rh->recovered_regions)) { 385 if (!list_empty(&rh->recovered_regions)) {
@@ -405,10 +403,12 @@ static void rh_update_states(struct region_hash *rh)
405 mempool_free(reg, rh->region_pool); 403 mempool_free(reg, rh->region_pool);
406 } 404 }
407 405
408 rh->log->type->flush(rh->log); 406 list_for_each_entry_safe(reg, next, &clean, list) {
409 407 rh->log->type->clear_region(rh->log, reg->key);
410 list_for_each_entry_safe (reg, next, &clean, list)
411 mempool_free(reg, rh->region_pool); 408 mempool_free(reg, rh->region_pool);
409 }
410
411 rh->log->type->flush(rh->log);
412} 412}
413 413
414static void rh_inc(struct region_hash *rh, region_t region) 414static void rh_inc(struct region_hash *rh, region_t region)