diff options
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 7aeceedcf7d4..c14dacdacfac 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -1045,8 +1045,14 @@ void bitmap_daemon_work(struct bitmap *bitmap) | |||
1045 | if (bitmap == NULL) | 1045 | if (bitmap == NULL) |
1046 | return; | 1046 | return; |
1047 | if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ)) | 1047 | if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ)) |
1048 | return; | 1048 | goto done; |
1049 | |||
1049 | bitmap->daemon_lastrun = jiffies; | 1050 | bitmap->daemon_lastrun = jiffies; |
1051 | if (bitmap->allclean) { | ||
1052 | bitmap->mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; | ||
1053 | return; | ||
1054 | } | ||
1055 | bitmap->allclean = 1; | ||
1050 | 1056 | ||
1051 | for (j = 0; j < bitmap->chunks; j++) { | 1057 | for (j = 0; j < bitmap->chunks; j++) { |
1052 | bitmap_counter_t *bmc; | 1058 | bitmap_counter_t *bmc; |
@@ -1068,8 +1074,10 @@ void bitmap_daemon_work(struct bitmap *bitmap) | |||
1068 | clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); | 1074 | clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); |
1069 | 1075 | ||
1070 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1076 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1071 | if (need_write) | 1077 | if (need_write) { |
1072 | write_page(bitmap, page, 0); | 1078 | write_page(bitmap, page, 0); |
1079 | bitmap->allclean = 0; | ||
1080 | } | ||
1073 | continue; | 1081 | continue; |
1074 | } | 1082 | } |
1075 | 1083 | ||
@@ -1098,6 +1106,9 @@ void bitmap_daemon_work(struct bitmap *bitmap) | |||
1098 | /* | 1106 | /* |
1099 | if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc); | 1107 | if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc); |
1100 | */ | 1108 | */ |
1109 | if (*bmc) | ||
1110 | bitmap->allclean = 0; | ||
1111 | |||
1101 | if (*bmc == 2) { | 1112 | if (*bmc == 2) { |
1102 | *bmc=1; /* maybe clear the bit next time */ | 1113 | *bmc=1; /* maybe clear the bit next time */ |
1103 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); | 1114 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); |
@@ -1132,6 +1143,9 @@ void bitmap_daemon_work(struct bitmap *bitmap) | |||
1132 | } | 1143 | } |
1133 | } | 1144 | } |
1134 | 1145 | ||
1146 | done: | ||
1147 | if (bitmap->allclean == 0) | ||
1148 | bitmap->mddev->thread->timeout = bitmap->daemon_sleep * HZ; | ||
1135 | } | 1149 | } |
1136 | 1150 | ||
1137 | static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, | 1151 | static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, |
@@ -1226,6 +1240,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect | |||
1226 | sectors -= blocks; | 1240 | sectors -= blocks; |
1227 | else sectors = 0; | 1241 | else sectors = 0; |
1228 | } | 1242 | } |
1243 | bitmap->allclean = 0; | ||
1229 | return 0; | 1244 | return 0; |
1230 | } | 1245 | } |
1231 | 1246 | ||
@@ -1296,6 +1311,7 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, | |||
1296 | } | 1311 | } |
1297 | } | 1312 | } |
1298 | spin_unlock_irq(&bitmap->lock); | 1313 | spin_unlock_irq(&bitmap->lock); |
1314 | bitmap->allclean = 0; | ||
1299 | return rv; | 1315 | return rv; |
1300 | } | 1316 | } |
1301 | 1317 | ||
@@ -1332,6 +1348,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int ab | |||
1332 | } | 1348 | } |
1333 | unlock: | 1349 | unlock: |
1334 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1350 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1351 | bitmap->allclean = 0; | ||
1335 | } | 1352 | } |
1336 | 1353 | ||
1337 | void bitmap_close_sync(struct bitmap *bitmap) | 1354 | void bitmap_close_sync(struct bitmap *bitmap) |
@@ -1399,7 +1416,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n | |||
1399 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); | 1416 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); |
1400 | } | 1417 | } |
1401 | spin_unlock_irq(&bitmap->lock); | 1418 | spin_unlock_irq(&bitmap->lock); |
1402 | 1419 | bitmap->allclean = 0; | |
1403 | } | 1420 | } |
1404 | 1421 | ||
1405 | /* dirty the memory and file bits for bitmap chunks "s" to "e" */ | 1422 | /* dirty the memory and file bits for bitmap chunks "s" to "e" */ |