diff options
author | NeilBrown <neilb@suse.de> | 2011-09-21 01:37:46 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-09-21 01:37:46 -0400 |
commit | 5a537df44d52331a3d2792ca21a296959bd2ac3a (patch) | |
tree | 31907bdb1be692583702cd8be91de2a578a6f0d5 /drivers/md/bitmap.c | |
parent | 01f96c0a9922cd9919baf9d16febdf7016177a12 (diff) |
md/bitmap: rename and tidy up BITMAP_PAGE_CLEAN
The flag 'BITMAP_PAGE_CLEAN' has a confusing name as it doesn't mean
that the page is clean, but rather that there are counters in the page
which allow bits in the bitmap to be cleared - i.e. maybe cleaning can
happen.
So change it to BITMAP_PAGE_PENDING and fix some irregularities:
- Don't set it in bitmap_init_from_disk as bitmap_set_memory_bits
sets it when needed
- in bitmap_daemon_work, if we find a counter that is '1', but
need_sync is set, then set BITMAP_PAGE_PENDING again (it was
recently cleared) to ensure we don't forget about this bit.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 0dc6546b77a8..69a6f256ce35 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -868,7 +868,8 @@ static void bitmap_file_kick(struct bitmap *bitmap) | |||
868 | 868 | ||
869 | enum bitmap_page_attr { | 869 | enum bitmap_page_attr { |
870 | BITMAP_PAGE_DIRTY = 0, /* there are set bits that need to be synced */ | 870 | BITMAP_PAGE_DIRTY = 0, /* there are set bits that need to be synced */ |
871 | BITMAP_PAGE_CLEAN = 1, /* there are bits that might need to be cleared */ | 871 | BITMAP_PAGE_PENDING = 1, /* there are bits that are being cleaned. |
872 | * i.e. counter is 1 or 2. */ | ||
872 | BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */ | 873 | BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */ |
873 | }; | 874 | }; |
874 | 875 | ||
@@ -1111,7 +1112,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
1111 | (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap), | 1112 | (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap), |
1112 | needed); | 1113 | needed); |
1113 | bit_cnt++; | 1114 | bit_cnt++; |
1114 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); | ||
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | 1117 | ||
@@ -1204,7 +1204,7 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1204 | 1204 | ||
1205 | if (page != lastpage) { | 1205 | if (page != lastpage) { |
1206 | /* skip this page unless it's marked as needing cleaning */ | 1206 | /* skip this page unless it's marked as needing cleaning */ |
1207 | if (!test_page_attr(bitmap, page, BITMAP_PAGE_CLEAN)) { | 1207 | if (!test_page_attr(bitmap, page, BITMAP_PAGE_PENDING)) { |
1208 | int need_write = test_page_attr(bitmap, page, | 1208 | int need_write = test_page_attr(bitmap, page, |
1209 | BITMAP_PAGE_NEEDWRITE); | 1209 | BITMAP_PAGE_NEEDWRITE); |
1210 | if (need_write) | 1210 | if (need_write) |
@@ -1249,19 +1249,17 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1249 | } | 1249 | } |
1250 | spin_lock_irqsave(&bitmap->lock, flags); | 1250 | spin_lock_irqsave(&bitmap->lock, flags); |
1251 | if (!bitmap->need_sync) | 1251 | if (!bitmap->need_sync) |
1252 | clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); | 1252 | clear_page_attr(bitmap, page, BITMAP_PAGE_PENDING); |
1253 | } | 1253 | } |
1254 | bmc = bitmap_get_counter(bitmap, | 1254 | bmc = bitmap_get_counter(bitmap, |
1255 | (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), | 1255 | (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), |
1256 | &blocks, 0); | 1256 | &blocks, 0); |
1257 | if (bmc) { | 1257 | if (!bmc) |
1258 | if (*bmc) | 1258 | j |= PAGE_COUNTER_MASK; |
1259 | bitmap->allclean = 0; | 1259 | else if (*bmc) { |
1260 | bitmap->allclean = 0; | ||
1260 | 1261 | ||
1261 | if (*bmc == 2) { | 1262 | if (*bmc == 1 && !bitmap->need_sync) { |
1262 | *bmc = 1; /* maybe clear the bit next time */ | ||
1263 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); | ||
1264 | } else if (*bmc == 1 && !bitmap->need_sync) { | ||
1265 | /* we can clear the bit */ | 1263 | /* we can clear the bit */ |
1266 | *bmc = 0; | 1264 | *bmc = 0; |
1267 | bitmap_count_page(bitmap, | 1265 | bitmap_count_page(bitmap, |
@@ -1275,13 +1273,15 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1275 | paddr); | 1273 | paddr); |
1276 | else | 1274 | else |
1277 | __clear_bit_le( | 1275 | __clear_bit_le( |
1278 | file_page_offset(bitmap, | 1276 | file_page_offset(bitmap, |
1279 | j), | 1277 | j), |
1280 | paddr); | 1278 | paddr); |
1281 | kunmap_atomic(paddr, KM_USER0); | 1279 | kunmap_atomic(paddr, KM_USER0); |
1280 | } else if (*bmc <= 2) { | ||
1281 | *bmc = 1; /* maybe clear the bit next time */ | ||
1282 | set_page_attr(bitmap, page, BITMAP_PAGE_PENDING); | ||
1282 | } | 1283 | } |
1283 | } else | 1284 | } |
1284 | j |= PAGE_COUNTER_MASK; | ||
1285 | } | 1285 | } |
1286 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1286 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1287 | 1287 | ||
@@ -1458,7 +1458,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto | |||
1458 | filemap_get_page( | 1458 | filemap_get_page( |
1459 | bitmap, | 1459 | bitmap, |
1460 | offset >> CHUNK_BLOCK_SHIFT(bitmap)), | 1460 | offset >> CHUNK_BLOCK_SHIFT(bitmap)), |
1461 | BITMAP_PAGE_CLEAN); | 1461 | BITMAP_PAGE_PENDING); |
1462 | 1462 | ||
1463 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1463 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1464 | offset += blocks; | 1464 | offset += blocks; |
@@ -1546,7 +1546,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i | |||
1546 | if (*bmc <= 2) | 1546 | if (*bmc <= 2) |
1547 | set_page_attr(bitmap, | 1547 | set_page_attr(bitmap, |
1548 | filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)), | 1548 | filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)), |
1549 | BITMAP_PAGE_CLEAN); | 1549 | BITMAP_PAGE_PENDING); |
1550 | } | 1550 | } |
1551 | } | 1551 | } |
1552 | unlock: | 1552 | unlock: |
@@ -1622,7 +1622,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n | |||
1622 | *bmc = 1 | (needed ? NEEDED_MASK : 0); | 1622 | *bmc = 1 | (needed ? NEEDED_MASK : 0); |
1623 | bitmap_count_page(bitmap, offset, 1); | 1623 | bitmap_count_page(bitmap, offset, 1); |
1624 | page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)); | 1624 | page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)); |
1625 | set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); | 1625 | set_page_attr(bitmap, page, BITMAP_PAGE_PENDING); |
1626 | } | 1626 | } |
1627 | spin_unlock_irq(&bitmap->lock); | 1627 | spin_unlock_irq(&bitmap->lock); |
1628 | bitmap->allclean = 0; | 1628 | bitmap->allclean = 0; |