aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-05-25 19:41:17 -0400
committerNeilBrown <neilb@suse.de>2009-05-25 19:41:17 -0400
commitbe512691036cc989c11d0f418187efbbf14468e6 (patch)
tree557b303a058fc3effdfc15a5cc08867fb0ee6889 /drivers/md/bitmap.c
parent2b69c83924396ad1eda36fdd267c9d2f360f5555 (diff)
md: bitmap: improve bitmap maintenance code.
The code for checking which bits in the bitmap can be cleared has 2 problems: 1/ it repeatedly takes and drops a spinlock, where it would make more sense to just hold on to it most of the time. 2/ it doesn't make use of some opportunities to skip large sections of the bitmap This patch fixes those. It will only affect CPU consumption, not correctness. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 47c68bc75a17..56df1cee8fb3 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1097,14 +1097,12 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1097 } 1097 }
1098 bitmap->allclean = 1; 1098 bitmap->allclean = 1;
1099 1099
1100 spin_lock_irqsave(&bitmap->lock, flags);
1100 for (j = 0; j < bitmap->chunks; j++) { 1101 for (j = 0; j < bitmap->chunks; j++) {
1101 bitmap_counter_t *bmc; 1102 bitmap_counter_t *bmc;
1102 spin_lock_irqsave(&bitmap->lock, flags); 1103 if (!bitmap->filemap)
1103 if (!bitmap->filemap) {
1104 /* error or shutdown */ 1104 /* error or shutdown */
1105 spin_unlock_irqrestore(&bitmap->lock, flags);
1106 break; 1105 break;
1107 }
1108 1106
1109 page = filemap_get_page(bitmap, j); 1107 page = filemap_get_page(bitmap, j);
1110 1108
@@ -1121,6 +1119,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1121 write_page(bitmap, page, 0); 1119 write_page(bitmap, page, 0);
1122 bitmap->allclean = 0; 1120 bitmap->allclean = 0;
1123 } 1121 }
1122 spin_lock_irqsave(&bitmap->lock, flags);
1123 j |= (PAGE_BITS - 1);
1124 continue; 1124 continue;
1125 } 1125 }
1126 1126
@@ -1181,9 +1181,10 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1181 ext2_clear_bit(file_page_offset(j), paddr); 1181 ext2_clear_bit(file_page_offset(j), paddr);
1182 kunmap_atomic(paddr, KM_USER0); 1182 kunmap_atomic(paddr, KM_USER0);
1183 } 1183 }
1184 } 1184 } else
1185 spin_unlock_irqrestore(&bitmap->lock, flags); 1185 j |= PAGE_COUNTER_MASK;
1186 } 1186 }
1187 spin_unlock_irqrestore(&bitmap->lock, flags);
1187 1188
1188 /* now sync the final page */ 1189 /* now sync the final page */
1189 if (lastpage != NULL) { 1190 if (lastpage != NULL) {