diff options
author | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:09 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:09 -0400 |
commit | d189122d4bca2647441fdc170dc6d4cc5c8bb2fa (patch) | |
tree | d5907014aaef1be959b93d0fb4a327e11673f855 /drivers/md/bitmap.c | |
parent | 27581e5ae01f77b5472dc5c2368b41063fed7f37 (diff) |
md/bitmap: change *_page_attr() to take a page number, not a page.
Most often we have the page number, not the page. And that is what
the *_page_attr() functions really want. So change the arguments to
take that number.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 324a198e8be7..511f0ed5a5db 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -800,22 +800,22 @@ enum bitmap_page_attr { | |||
800 | BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */ | 800 | BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */ |
801 | }; | 801 | }; |
802 | 802 | ||
803 | static inline void set_page_attr(struct bitmap *bitmap, struct page *page, | 803 | static inline void set_page_attr(struct bitmap *bitmap, int pnum, |
804 | enum bitmap_page_attr attr) | 804 | enum bitmap_page_attr attr) |
805 | { | 805 | { |
806 | __set_bit((page->index<<2) + attr, bitmap->filemap_attr); | 806 | __set_bit((pnum<<2) + attr, bitmap->filemap_attr); |
807 | } | 807 | } |
808 | 808 | ||
809 | static inline void clear_page_attr(struct bitmap *bitmap, struct page *page, | 809 | static inline void clear_page_attr(struct bitmap *bitmap, int pnum, |
810 | enum bitmap_page_attr attr) | 810 | enum bitmap_page_attr attr) |
811 | { | 811 | { |
812 | __clear_bit((page->index<<2) + attr, bitmap->filemap_attr); | 812 | __clear_bit((pnum<<2) + attr, bitmap->filemap_attr); |
813 | } | 813 | } |
814 | 814 | ||
815 | static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page, | 815 | static inline unsigned long test_page_attr(struct bitmap *bitmap, int pnum, |
816 | enum bitmap_page_attr attr) | 816 | enum bitmap_page_attr attr) |
817 | { | 817 | { |
818 | return test_bit((page->index<<2) + attr, bitmap->filemap_attr); | 818 | return test_bit((pnum<<2) + attr, bitmap->filemap_attr); |
819 | } | 819 | } |
820 | 820 | ||
821 | /* | 821 | /* |
@@ -846,7 +846,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) | |||
846 | kunmap_atomic(kaddr); | 846 | kunmap_atomic(kaddr); |
847 | pr_debug("set file bit %lu page %lu\n", bit, page->index); | 847 | pr_debug("set file bit %lu page %lu\n", bit, page->index); |
848 | /* record page number so it gets flushed to disk when unplug occurs */ | 848 | /* record page number so it gets flushed to disk when unplug occurs */ |
849 | set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); | 849 | set_page_attr(bitmap, page->index, BITMAP_PAGE_DIRTY); |
850 | } | 850 | } |
851 | 851 | ||
852 | static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) | 852 | static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) |
@@ -866,8 +866,8 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) | |||
866 | else | 866 | else |
867 | __clear_bit_le(bit, paddr); | 867 | __clear_bit_le(bit, paddr); |
868 | kunmap_atomic(paddr); | 868 | kunmap_atomic(paddr); |
869 | if (!test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE)) { | 869 | if (!test_page_attr(bitmap, page->index, BITMAP_PAGE_NEEDWRITE)) { |
870 | set_page_attr(bitmap, page, BITMAP_PAGE_PENDING); | 870 | set_page_attr(bitmap, page->index, BITMAP_PAGE_PENDING); |
871 | bitmap->allclean = 0; | 871 | bitmap->allclean = 0; |
872 | } | 872 | } |
873 | } | 873 | } |
@@ -879,7 +879,6 @@ void bitmap_unplug(struct bitmap *bitmap) | |||
879 | { | 879 | { |
880 | unsigned long i, flags; | 880 | unsigned long i, flags; |
881 | int dirty, need_write; | 881 | int dirty, need_write; |
882 | struct page *page; | ||
883 | int wait = 0; | 882 | int wait = 0; |
884 | 883 | ||
885 | if (!bitmap || !bitmap->filemap) | 884 | if (!bitmap || !bitmap->filemap) |
@@ -893,19 +892,18 @@ void bitmap_unplug(struct bitmap *bitmap) | |||
893 | spin_unlock_irqrestore(&bitmap->lock, flags); | 892 | spin_unlock_irqrestore(&bitmap->lock, flags); |
894 | return; | 893 | return; |
895 | } | 894 | } |
896 | page = bitmap->filemap[i]; | 895 | dirty = test_page_attr(bitmap, i, BITMAP_PAGE_DIRTY); |
897 | dirty = test_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); | 896 | need_write = test_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE); |
898 | need_write = test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); | 897 | clear_page_attr(bitmap, i, BITMAP_PAGE_DIRTY); |
899 | clear_page_attr(bitmap, page, BITMAP_PAGE_DIRTY); | 898 | clear_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE); |
900 | clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); | ||
901 | if (dirty || need_write) | 899 | if (dirty || need_write) |
902 | clear_page_attr(bitmap, page, BITMAP_PAGE_PENDING); | 900 | clear_page_attr(bitmap, i, BITMAP_PAGE_PENDING); |
903 | if (dirty) | 901 | if (dirty) |
904 | wait = 1; | 902 | wait = 1; |
905 | spin_unlock_irqrestore(&bitmap->lock, flags); | 903 | spin_unlock_irqrestore(&bitmap->lock, flags); |
906 | 904 | ||
907 | if (dirty || need_write) | 905 | if (dirty || need_write) |
908 | write_page(bitmap, page, 0); | 906 | write_page(bitmap, bitmap->filemap[i], 0); |
909 | } | 907 | } |
910 | if (wait) { /* if any writes were performed, we need to wait on them */ | 908 | if (wait) { /* if any writes were performed, we need to wait on them */ |
911 | if (bitmap->file) | 909 | if (bitmap->file) |
@@ -1101,7 +1099,7 @@ void bitmap_write_all(struct bitmap *bitmap) | |||
1101 | 1099 | ||
1102 | spin_lock_irq(&bitmap->lock); | 1100 | spin_lock_irq(&bitmap->lock); |
1103 | for (i = 0; i < bitmap->file_pages; i++) | 1101 | for (i = 0; i < bitmap->file_pages; i++) |
1104 | set_page_attr(bitmap, bitmap->filemap[i], | 1102 | set_page_attr(bitmap, i, |
1105 | BITMAP_PAGE_NEEDWRITE); | 1103 | BITMAP_PAGE_NEEDWRITE); |
1106 | bitmap->allclean = 0; | 1104 | bitmap->allclean = 0; |
1107 | spin_unlock_irq(&bitmap->lock); | 1105 | spin_unlock_irq(&bitmap->lock); |
@@ -1168,11 +1166,11 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1168 | */ | 1166 | */ |
1169 | spin_lock_irqsave(&bitmap->lock, flags); | 1167 | spin_lock_irqsave(&bitmap->lock, flags); |
1170 | for (j = 0; j < bitmap->file_pages; j++) | 1168 | for (j = 0; j < bitmap->file_pages; j++) |
1171 | if (test_page_attr(bitmap, bitmap->filemap[j], | 1169 | if (test_page_attr(bitmap, j, |
1172 | BITMAP_PAGE_PENDING)) { | 1170 | BITMAP_PAGE_PENDING)) { |
1173 | set_page_attr(bitmap, bitmap->filemap[j], | 1171 | set_page_attr(bitmap, j, |
1174 | BITMAP_PAGE_NEEDWRITE); | 1172 | BITMAP_PAGE_NEEDWRITE); |
1175 | clear_page_attr(bitmap, bitmap->filemap[j], | 1173 | clear_page_attr(bitmap, j, |
1176 | BITMAP_PAGE_PENDING); | 1174 | BITMAP_PAGE_PENDING); |
1177 | } | 1175 | } |
1178 | 1176 | ||
@@ -1187,7 +1185,7 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1187 | sb->events_cleared = | 1185 | sb->events_cleared = |
1188 | cpu_to_le64(bitmap->events_cleared); | 1186 | cpu_to_le64(bitmap->events_cleared); |
1189 | kunmap_atomic(sb); | 1187 | kunmap_atomic(sb); |
1190 | set_page_attr(bitmap, bitmap->sb_page, | 1188 | set_page_attr(bitmap, 0, |
1191 | BITMAP_PAGE_NEEDWRITE); | 1189 | BITMAP_PAGE_NEEDWRITE); |
1192 | } | 1190 | } |
1193 | } | 1191 | } |
@@ -1236,18 +1234,17 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1236 | * We mustn't write any other blocks before the superblock. | 1234 | * We mustn't write any other blocks before the superblock. |
1237 | */ | 1235 | */ |
1238 | for (j = 0; j < bitmap->file_pages; j++) { | 1236 | for (j = 0; j < bitmap->file_pages; j++) { |
1239 | struct page *page = bitmap->filemap[j]; | ||
1240 | 1237 | ||
1241 | if (test_page_attr(bitmap, page, | 1238 | if (test_page_attr(bitmap, j, |
1242 | BITMAP_PAGE_DIRTY)) | 1239 | BITMAP_PAGE_DIRTY)) |
1243 | /* bitmap_unplug will handle the rest */ | 1240 | /* bitmap_unplug will handle the rest */ |
1244 | break; | 1241 | break; |
1245 | if (test_page_attr(bitmap, page, | 1242 | if (test_page_attr(bitmap, j, |
1246 | BITMAP_PAGE_NEEDWRITE)) { | 1243 | BITMAP_PAGE_NEEDWRITE)) { |
1247 | clear_page_attr(bitmap, page, | 1244 | clear_page_attr(bitmap, j, |
1248 | BITMAP_PAGE_NEEDWRITE); | 1245 | BITMAP_PAGE_NEEDWRITE); |
1249 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1246 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1250 | write_page(bitmap, page, 0); | 1247 | write_page(bitmap, bitmap->filemap[j], 0); |
1251 | spin_lock_irqsave(&bitmap->lock, flags); | 1248 | spin_lock_irqsave(&bitmap->lock, flags); |
1252 | if (!bitmap->filemap) | 1249 | if (!bitmap->filemap) |
1253 | break; | 1250 | break; |