diff options
author | Jonathan Brassow <jbrassow@redhat.com> | 2011-07-26 21:00:37 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-07-26 21:00:37 -0400 |
commit | 3520fa4db7fc4ae1b0373dcecdaf720f620dab2d (patch) | |
tree | 62c675a29c65f89ec15f4a52203e5e0f731c2aa5 /drivers/md | |
parent | 654e8b5abc0a793f0c029128db6e4804691a383e (diff) |
MD bitmap: Revert DM dirty log hooks
Revert most of commit e384e58549a2e9a83071ad80280c1a9053cfd84c
md/bitmap: prepare for storing write-intent-bitmap via dm-dirty-log.
MD should not need to use DM's dirty log - we decided to use md's
bitmaps instead.
Keeping the DIV_ROUND_UP clean-ups that were part of commit
e384e58549a2e9a83071ad80280c1a9053cfd84c, however.
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bitmap.c | 133 | ||||
-rw-r--r-- | drivers/md/bitmap.h | 5 | ||||
-rw-r--r-- | drivers/md/md.h | 5 |
3 files changed, 43 insertions, 100 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 39ff0ef8b76e..0dc6546b77a8 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "md.h" | 29 | #include "md.h" |
30 | #include "bitmap.h" | 30 | #include "bitmap.h" |
31 | 31 | ||
32 | #include <linux/dm-dirty-log.h> | ||
33 | /* debug macros */ | 32 | /* debug macros */ |
34 | 33 | ||
35 | #define DEBUG 0 | 34 | #define DEBUG 0 |
@@ -775,10 +774,8 @@ static inline unsigned long file_page_offset(struct bitmap *bitmap, unsigned lon | |||
775 | * 0 or page 1 | 774 | * 0 or page 1 |
776 | */ | 775 | */ |
777 | static inline struct page *filemap_get_page(struct bitmap *bitmap, | 776 | static inline struct page *filemap_get_page(struct bitmap *bitmap, |
778 | unsigned long chunk) | 777 | unsigned long chunk) |
779 | { | 778 | { |
780 | if (bitmap->filemap == NULL) | ||
781 | return NULL; | ||
782 | if (file_page_index(bitmap, chunk) >= bitmap->file_pages) | 779 | if (file_page_index(bitmap, chunk) >= bitmap->file_pages) |
783 | return NULL; | 780 | return NULL; |
784 | return bitmap->filemap[file_page_index(bitmap, chunk) | 781 | return bitmap->filemap[file_page_index(bitmap, chunk) |
@@ -878,28 +875,19 @@ enum bitmap_page_attr { | |||
878 | static inline void set_page_attr(struct bitmap *bitmap, struct page *page, | 875 | static inline void set_page_attr(struct bitmap *bitmap, struct page *page, |
879 | enum bitmap_page_attr attr) | 876 | enum bitmap_page_attr attr) |
880 | { | 877 | { |
881 | if (page) | 878 | __set_bit((page->index<<2) + attr, bitmap->filemap_attr); |
882 | __set_bit((page->index<<2) + attr, bitmap->filemap_attr); | ||
883 | else | ||
884 | __set_bit(attr, &bitmap->logattrs); | ||
885 | } | 879 | } |
886 | 880 | ||
887 | static inline void clear_page_attr(struct bitmap *bitmap, struct page *page, | 881 | static inline void clear_page_attr(struct bitmap *bitmap, struct page *page, |
888 | enum bitmap_page_attr attr) | 882 | enum bitmap_page_attr attr) |
889 | { | 883 | { |
890 | if (page) | 884 | __clear_bit((page->index<<2) + attr, bitmap->filemap_attr); |
891 | __clear_bit((page->index<<2) + attr, bitmap->filemap_attr); | ||
892 | else | ||
893 | __clear_bit(attr, &bitmap->logattrs); | ||
894 | } | 885 | } |
895 | 886 | ||
896 | static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page, | 887 | static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page, |
897 | enum bitmap_page_attr attr) | 888 | enum bitmap_page_attr attr) |
898 | { | 889 | { |
899 | if (page) | 890 | return test_bit((page->index<<2) + attr, bitmap->filemap_attr); |
900 | return test_bit((page->index<<2) + attr, bitmap->filemap_attr); | ||
901 | else | ||
902 | return test_bit(attr, &bitmap->logattrs); | ||
903 | } | 891 | } |
904 | 892 | ||
905 | /* | 893 | /* |
@@ -912,30 +900,26 @@ static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *p | |||
912 | static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) | 900 | static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) |
913 | { | 901 | { |
914 | unsigned long bit; | 902 | unsigned long bit; |
915 | struct page *page = NULL; | 903 | struct page *page; |
916 | void *kaddr; | 904 | void *kaddr; |
917 | unsigned long chunk = block >> CHUNK_BLOCK_SHIFT(bitmap); | 905 | unsigned long chunk = block >> CHUNK_BLOCK_SHIFT(bitmap); |
918 | 906 | ||
919 | if (!bitmap->filemap) { | 907 | if (!bitmap->filemap) |
920 | struct dm_dirty_log *log = bitmap->mddev->bitmap_info.log; | 908 | return; |
921 | if (log) | ||
922 | log->type->mark_region(log, chunk); | ||
923 | } else { | ||
924 | 909 | ||
925 | page = filemap_get_page(bitmap, chunk); | 910 | page = filemap_get_page(bitmap, chunk); |
926 | if (!page) | 911 | if (!page) |
927 | return; | 912 | return; |
928 | bit = file_page_offset(bitmap, chunk); | 913 | bit = file_page_offset(bitmap, chunk); |
929 | 914 | ||
930 | /* set the bit */ | 915 | /* set the bit */ |
931 | kaddr = kmap_atomic(page, KM_USER0); | 916 | kaddr = kmap_atomic(page, KM_USER0); |
932 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 917 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
933 | set_bit(bit, kaddr); | 918 | set_bit(bit, kaddr); |
934 | else | 919 | else |
935 | __set_bit_le(bit, kaddr); | 920 | __set_bit_le(bit, kaddr); |
936 | kunmap_atomic(kaddr, KM_USER0); | 921 | kunmap_atomic(kaddr, KM_USER0); |
937 | PRINTK("set file bit %lu page %lu\n", bit, page->index); | 922 | PRINTK("set file bit %lu page %lu\n", bit, page->index); |
938 | } | ||
939 | /* record page number so it gets flushed to disk when unplug occurs */ | 923 | /* record page number so it gets flushed to disk when unplug occurs */ |
940 | set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); | 924 | set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); |
941 | } | 925 | } |
@@ -952,16 +936,6 @@ void bitmap_unplug(struct bitmap *bitmap) | |||
952 | 936 | ||
953 | if (!bitmap) | 937 | if (!bitmap) |
954 | return; | 938 | return; |
955 | if (!bitmap->filemap) { | ||
956 | /* Must be using a dirty_log */ | ||
957 | struct dm_dirty_log *log = bitmap->mddev->bitmap_info.log; | ||
958 | dirty = test_and_clear_bit(BITMAP_PAGE_DIRTY, &bitmap->logattrs); | ||
959 | need_write = test_and_clear_bit(BITMAP_PAGE_NEEDWRITE, &bitmap->logattrs); | ||
960 | if (dirty || need_write) | ||
961 | if (log->type->flush(log)) | ||
962 | bitmap->flags |= BITMAP_WRITE_ERROR; | ||
963 | goto out; | ||
964 | } | ||
965 | 939 | ||
966 | /* look at each page to see if there are any set bits that need to be | 940 | /* look at each page to see if there are any set bits that need to be |
967 | * flushed out to disk */ | 941 | * flushed out to disk */ |
@@ -990,7 +964,6 @@ void bitmap_unplug(struct bitmap *bitmap) | |||
990 | else | 964 | else |
991 | md_super_wait(bitmap->mddev); | 965 | md_super_wait(bitmap->mddev); |
992 | } | 966 | } |
993 | out: | ||
994 | if (bitmap->flags & BITMAP_WRITE_ERROR) | 967 | if (bitmap->flags & BITMAP_WRITE_ERROR) |
995 | bitmap_file_kick(bitmap); | 968 | bitmap_file_kick(bitmap); |
996 | } | 969 | } |
@@ -1199,7 +1172,6 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1199 | struct page *page = NULL, *lastpage = NULL; | 1172 | struct page *page = NULL, *lastpage = NULL; |
1200 | sector_t blocks; | 1173 | sector_t blocks; |
1201 | void *paddr; | 1174 | void *paddr; |
1202 | struct dm_dirty_log *log = mddev->bitmap_info.log; | ||
1203 | 1175 | ||
1204 | /* Use a mutex to guard daemon_work against | 1176 | /* Use a mutex to guard daemon_work against |
1205 | * bitmap_destroy. | 1177 | * bitmap_destroy. |
@@ -1224,12 +1196,11 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1224 | spin_lock_irqsave(&bitmap->lock, flags); | 1196 | spin_lock_irqsave(&bitmap->lock, flags); |
1225 | for (j = 0; j < bitmap->chunks; j++) { | 1197 | for (j = 0; j < bitmap->chunks; j++) { |
1226 | bitmap_counter_t *bmc; | 1198 | bitmap_counter_t *bmc; |
1227 | if (!bitmap->filemap) { | 1199 | if (!bitmap->filemap) |
1228 | if (!log) | 1200 | /* error or shutdown */ |
1229 | /* error or shutdown */ | 1201 | break; |
1230 | break; | 1202 | |
1231 | } else | 1203 | page = filemap_get_page(bitmap, j); |
1232 | page = filemap_get_page(bitmap, j); | ||
1233 | 1204 | ||
1234 | if (page != lastpage) { | 1205 | if (page != lastpage) { |
1235 | /* skip this page unless it's marked as needing cleaning */ | 1206 | /* skip this page unless it's marked as needing cleaning */ |
@@ -1298,19 +1269,16 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1298 | -1); | 1269 | -1); |
1299 | 1270 | ||
1300 | /* clear the bit */ | 1271 | /* clear the bit */ |
1301 | if (page) { | 1272 | paddr = kmap_atomic(page, KM_USER0); |
1302 | paddr = kmap_atomic(page, KM_USER0); | 1273 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
1303 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 1274 | clear_bit(file_page_offset(bitmap, j), |
1304 | clear_bit(file_page_offset(bitmap, j), | 1275 | paddr); |
1305 | paddr); | 1276 | else |
1306 | else | 1277 | __clear_bit_le( |
1307 | __clear_bit_le( | ||
1308 | file_page_offset(bitmap, | 1278 | file_page_offset(bitmap, |
1309 | j), | 1279 | j), |
1310 | paddr); | 1280 | paddr); |
1311 | kunmap_atomic(paddr, KM_USER0); | 1281 | kunmap_atomic(paddr, KM_USER0); |
1312 | } else | ||
1313 | log->type->clear_region(log, j); | ||
1314 | } | 1282 | } |
1315 | } else | 1283 | } else |
1316 | j |= PAGE_COUNTER_MASK; | 1284 | j |= PAGE_COUNTER_MASK; |
@@ -1318,16 +1286,12 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1318 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1286 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1319 | 1287 | ||
1320 | /* now sync the final page */ | 1288 | /* now sync the final page */ |
1321 | if (lastpage != NULL || log != NULL) { | 1289 | if (lastpage != NULL) { |
1322 | spin_lock_irqsave(&bitmap->lock, flags); | 1290 | spin_lock_irqsave(&bitmap->lock, flags); |
1323 | if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) { | 1291 | if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) { |
1324 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1292 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |
1325 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1293 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1326 | if (lastpage) | 1294 | write_page(bitmap, lastpage, 0); |
1327 | write_page(bitmap, lastpage, 0); | ||
1328 | else | ||
1329 | if (log->type->flush(log)) | ||
1330 | bitmap->flags |= BITMAP_WRITE_ERROR; | ||
1331 | } else { | 1295 | } else { |
1332 | set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1296 | set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |
1333 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1297 | spin_unlock_irqrestore(&bitmap->lock, flags); |
@@ -1769,12 +1733,10 @@ int bitmap_create(mddev_t *mddev) | |||
1769 | BUILD_BUG_ON(sizeof(bitmap_super_t) != 256); | 1733 | BUILD_BUG_ON(sizeof(bitmap_super_t) != 256); |
1770 | 1734 | ||
1771 | if (!file | 1735 | if (!file |
1772 | && !mddev->bitmap_info.offset | 1736 | && !mddev->bitmap_info.offset) /* bitmap disabled, nothing to do */ |
1773 | && !mddev->bitmap_info.log) /* bitmap disabled, nothing to do */ | ||
1774 | return 0; | 1737 | return 0; |
1775 | 1738 | ||
1776 | BUG_ON(file && mddev->bitmap_info.offset); | 1739 | BUG_ON(file && mddev->bitmap_info.offset); |
1777 | BUG_ON(mddev->bitmap_info.offset && mddev->bitmap_info.log); | ||
1778 | 1740 | ||
1779 | bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL); | 1741 | bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL); |
1780 | if (!bitmap) | 1742 | if (!bitmap) |
@@ -1865,6 +1827,7 @@ int bitmap_create(mddev_t *mddev) | |||
1865 | int bitmap_load(mddev_t *mddev) | 1827 | int bitmap_load(mddev_t *mddev) |
1866 | { | 1828 | { |
1867 | int err = 0; | 1829 | int err = 0; |
1830 | sector_t start = 0; | ||
1868 | sector_t sector = 0; | 1831 | sector_t sector = 0; |
1869 | struct bitmap *bitmap = mddev->bitmap; | 1832 | struct bitmap *bitmap = mddev->bitmap; |
1870 | 1833 | ||
@@ -1883,24 +1846,14 @@ int bitmap_load(mddev_t *mddev) | |||
1883 | } | 1846 | } |
1884 | bitmap_close_sync(bitmap); | 1847 | bitmap_close_sync(bitmap); |
1885 | 1848 | ||
1886 | if (mddev->bitmap_info.log) { | 1849 | if (mddev->degraded == 0 |
1887 | unsigned long i; | 1850 | || bitmap->events_cleared == mddev->events) |
1888 | struct dm_dirty_log *log = mddev->bitmap_info.log; | 1851 | /* no need to keep dirty bits to optimise a |
1889 | for (i = 0; i < bitmap->chunks; i++) | 1852 | * re-add of a missing device */ |
1890 | if (!log->type->in_sync(log, i, 1)) | 1853 | start = mddev->recovery_cp; |
1891 | bitmap_set_memory_bits(bitmap, | 1854 | |
1892 | (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap), | 1855 | err = bitmap_init_from_disk(bitmap, start); |
1893 | 1); | 1856 | |
1894 | } else { | ||
1895 | sector_t start = 0; | ||
1896 | if (mddev->degraded == 0 | ||
1897 | || bitmap->events_cleared == mddev->events) | ||
1898 | /* no need to keep dirty bits to optimise a | ||
1899 | * re-add of a missing device */ | ||
1900 | start = mddev->recovery_cp; | ||
1901 | |||
1902 | err = bitmap_init_from_disk(bitmap, start); | ||
1903 | } | ||
1904 | if (err) | 1857 | if (err) |
1905 | goto out; | 1858 | goto out; |
1906 | 1859 | ||
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h index b2a127e891ac..a28f2e5588c6 100644 --- a/drivers/md/bitmap.h +++ b/drivers/md/bitmap.h | |||
@@ -212,10 +212,6 @@ struct bitmap { | |||
212 | unsigned long file_pages; /* number of pages in the file */ | 212 | unsigned long file_pages; /* number of pages in the file */ |
213 | int last_page_size; /* bytes in the last page */ | 213 | int last_page_size; /* bytes in the last page */ |
214 | 214 | ||
215 | unsigned long logattrs; /* used when filemap_attr doesn't exist | ||
216 | * because we are working with a dirty_log | ||
217 | */ | ||
218 | |||
219 | unsigned long flags; | 215 | unsigned long flags; |
220 | 216 | ||
221 | int allclean; | 217 | int allclean; |
@@ -237,7 +233,6 @@ struct bitmap { | |||
237 | wait_queue_head_t behind_wait; | 233 | wait_queue_head_t behind_wait; |
238 | 234 | ||
239 | struct sysfs_dirent *sysfs_can_clear; | 235 | struct sysfs_dirent *sysfs_can_clear; |
240 | |||
241 | }; | 236 | }; |
242 | 237 | ||
243 | /* the bitmap API */ | 238 | /* the bitmap API */ |
diff --git a/drivers/md/md.h b/drivers/md/md.h index de5455d30d41..7d906a96477a 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -307,11 +307,6 @@ struct mddev_s | |||
307 | * hot-adding a bitmap. It should | 307 | * hot-adding a bitmap. It should |
308 | * eventually be settable by sysfs. | 308 | * eventually be settable by sysfs. |
309 | */ | 309 | */ |
310 | /* When md is serving under dm, it might use a | ||
311 | * dirty_log to store the bits. | ||
312 | */ | ||
313 | struct dm_dirty_log *log; | ||
314 | |||
315 | struct mutex mutex; | 310 | struct mutex mutex; |
316 | unsigned long chunksize; | 311 | unsigned long chunksize; |
317 | unsigned long daemon_sleep; /* how many jiffies between updates? */ | 312 | unsigned long daemon_sleep; /* how many jiffies between updates? */ |