diff options
author | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:10 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:10 -0400 |
commit | 1ec885cdd01a9ad867dbb9fd32a1bfcc0875c486 (patch) | |
tree | 232eaa1e1b7820ca8e97782666f7742f78bef175 /drivers/md/bitmap.c | |
parent | d189122d4bca2647441fdc170dc6d4cc5c8bb2fa (diff) |
md/bitmap: move some fields of 'struct bitmap' into a 'storage' substruct.
This new 'struct bitmap_storage' reflects the external storage of the
bitmap.
Having this clearly defined will make it easier to change the storage
used while the array is active.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 180 |
1 files changed, 94 insertions, 86 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 511f0ed5a5db..c98f2fee1bd0 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -195,6 +195,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) | |||
195 | struct md_rdev *rdev = NULL; | 195 | struct md_rdev *rdev = NULL; |
196 | struct block_device *bdev; | 196 | struct block_device *bdev; |
197 | struct mddev *mddev = bitmap->mddev; | 197 | struct mddev *mddev = bitmap->mddev; |
198 | struct bitmap_storage *store = &bitmap->storage; | ||
198 | 199 | ||
199 | while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { | 200 | while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { |
200 | int size = PAGE_SIZE; | 201 | int size = PAGE_SIZE; |
@@ -202,8 +203,8 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) | |||
202 | 203 | ||
203 | bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; | 204 | bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; |
204 | 205 | ||
205 | if (page->index == bitmap->file_pages-1) | 206 | if (page->index == store->file_pages-1) |
206 | size = roundup(bitmap->last_page_size, | 207 | size = roundup(store->last_page_size, |
207 | bdev_logical_block_size(bdev)); | 208 | bdev_logical_block_size(bdev)); |
208 | /* Just make sure we aren't corrupting data or | 209 | /* Just make sure we aren't corrupting data or |
209 | * metadata | 210 | * metadata |
@@ -263,7 +264,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait) | |||
263 | { | 264 | { |
264 | struct buffer_head *bh; | 265 | struct buffer_head *bh; |
265 | 266 | ||
266 | if (bitmap->file == NULL) { | 267 | if (bitmap->storage.file == NULL) { |
267 | switch (write_sb_page(bitmap, page, wait)) { | 268 | switch (write_sb_page(bitmap, page, wait)) { |
268 | case -EINVAL: | 269 | case -EINVAL: |
269 | bitmap->flags |= BITMAP_WRITE_ERROR; | 270 | bitmap->flags |= BITMAP_WRITE_ERROR; |
@@ -408,9 +409,9 @@ void bitmap_update_sb(struct bitmap *bitmap) | |||
408 | return; | 409 | return; |
409 | if (bitmap->mddev->bitmap_info.external) | 410 | if (bitmap->mddev->bitmap_info.external) |
410 | return; | 411 | return; |
411 | if (!bitmap->sb_page) /* no superblock */ | 412 | if (!bitmap->storage.sb_page) /* no superblock */ |
412 | return; | 413 | return; |
413 | sb = kmap_atomic(bitmap->sb_page); | 414 | sb = kmap_atomic(bitmap->storage.sb_page); |
414 | sb->events = cpu_to_le64(bitmap->mddev->events); | 415 | sb->events = cpu_to_le64(bitmap->mddev->events); |
415 | if (bitmap->mddev->events < bitmap->events_cleared) | 416 | if (bitmap->mddev->events < bitmap->events_cleared) |
416 | /* rocking back to read-only */ | 417 | /* rocking back to read-only */ |
@@ -421,7 +422,7 @@ void bitmap_update_sb(struct bitmap *bitmap) | |||
421 | sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ); | 422 | sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ); |
422 | sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind); | 423 | sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind); |
423 | kunmap_atomic(sb); | 424 | kunmap_atomic(sb); |
424 | write_page(bitmap, bitmap->sb_page, 1); | 425 | write_page(bitmap, bitmap->storage.sb_page, 1); |
425 | } | 426 | } |
426 | 427 | ||
427 | /* print out the bitmap file superblock */ | 428 | /* print out the bitmap file superblock */ |
@@ -429,9 +430,9 @@ void bitmap_print_sb(struct bitmap *bitmap) | |||
429 | { | 430 | { |
430 | bitmap_super_t *sb; | 431 | bitmap_super_t *sb; |
431 | 432 | ||
432 | if (!bitmap || !bitmap->sb_page) | 433 | if (!bitmap || !bitmap->storage.sb_page) |
433 | return; | 434 | return; |
434 | sb = kmap_atomic(bitmap->sb_page); | 435 | sb = kmap_atomic(bitmap->storage.sb_page); |
435 | printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); | 436 | printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); |
436 | printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); | 437 | printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); |
437 | printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); | 438 | printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); |
@@ -470,15 +471,15 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap) | |||
470 | unsigned long chunksize, daemon_sleep, write_behind; | 471 | unsigned long chunksize, daemon_sleep, write_behind; |
471 | int err = -EINVAL; | 472 | int err = -EINVAL; |
472 | 473 | ||
473 | bitmap->sb_page = alloc_page(GFP_KERNEL); | 474 | bitmap->storage.sb_page = alloc_page(GFP_KERNEL); |
474 | if (IS_ERR(bitmap->sb_page)) { | 475 | if (IS_ERR(bitmap->storage.sb_page)) { |
475 | err = PTR_ERR(bitmap->sb_page); | 476 | err = PTR_ERR(bitmap->storage.sb_page); |
476 | bitmap->sb_page = NULL; | 477 | bitmap->storage.sb_page = NULL; |
477 | return err; | 478 | return err; |
478 | } | 479 | } |
479 | bitmap->sb_page->index = 0; | 480 | bitmap->storage.sb_page->index = 0; |
480 | 481 | ||
481 | sb = kmap_atomic(bitmap->sb_page); | 482 | sb = kmap_atomic(bitmap->storage.sb_page); |
482 | 483 | ||
483 | sb->magic = cpu_to_le32(BITMAP_MAGIC); | 484 | sb->magic = cpu_to_le32(BITMAP_MAGIC); |
484 | sb->version = cpu_to_le32(BITMAP_MAJOR_HI); | 485 | sb->version = cpu_to_le32(BITMAP_MAJOR_HI); |
@@ -536,7 +537,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
536 | int err = -EINVAL; | 537 | int err = -EINVAL; |
537 | struct page *sb_page; | 538 | struct page *sb_page; |
538 | 539 | ||
539 | if (!bitmap->file && !bitmap->mddev->bitmap_info.offset) { | 540 | if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { |
540 | chunksize = 128 * 1024 * 1024; | 541 | chunksize = 128 * 1024 * 1024; |
541 | daemon_sleep = 5 * HZ; | 542 | daemon_sleep = 5 * HZ; |
542 | write_behind = 0; | 543 | write_behind = 0; |
@@ -548,13 +549,13 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
548 | sb_page = alloc_page(GFP_KERNEL); | 549 | sb_page = alloc_page(GFP_KERNEL); |
549 | if (!sb_page) | 550 | if (!sb_page) |
550 | return -ENOMEM; | 551 | return -ENOMEM; |
551 | bitmap->sb_page = sb_page; | 552 | bitmap->storage.sb_page = sb_page; |
552 | 553 | ||
553 | if (bitmap->file) { | 554 | if (bitmap->storage.file) { |
554 | loff_t isize = i_size_read(bitmap->file->f_mapping->host); | 555 | loff_t isize = i_size_read(bitmap->storage.file->f_mapping->host); |
555 | int bytes = isize > PAGE_SIZE ? PAGE_SIZE : isize; | 556 | int bytes = isize > PAGE_SIZE ? PAGE_SIZE : isize; |
556 | 557 | ||
557 | err = read_page(bitmap->file, 0, | 558 | err = read_page(bitmap->storage.file, 0, |
558 | bitmap, bytes, sb_page); | 559 | bitmap, bytes, sb_page); |
559 | } else { | 560 | } else { |
560 | err = read_sb_page(bitmap->mddev, | 561 | err = read_sb_page(bitmap->mddev, |
@@ -647,9 +648,9 @@ static int bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, | |||
647 | bitmap_super_t *sb; | 648 | bitmap_super_t *sb; |
648 | int old; | 649 | int old; |
649 | 650 | ||
650 | if (!bitmap->sb_page) /* can't set the state */ | 651 | if (!bitmap->storage.sb_page) /* can't set the state */ |
651 | return 0; | 652 | return 0; |
652 | sb = kmap_atomic(bitmap->sb_page); | 653 | sb = kmap_atomic(bitmap->storage.sb_page); |
653 | old = le32_to_cpu(sb->state) & bits; | 654 | old = le32_to_cpu(sb->state) & bits; |
654 | switch (op) { | 655 | switch (op) { |
655 | case MASK_SET: | 656 | case MASK_SET: |
@@ -678,17 +679,19 @@ static int bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, | |||
678 | * file a page at a time. There's a superblock at the start of the file. | 679 | * file a page at a time. There's a superblock at the start of the file. |
679 | */ | 680 | */ |
680 | /* calculate the index of the page that contains this bit */ | 681 | /* calculate the index of the page that contains this bit */ |
681 | static inline unsigned long file_page_index(struct bitmap *bitmap, unsigned long chunk) | 682 | static inline unsigned long file_page_index(struct bitmap_storage *store, |
683 | unsigned long chunk) | ||
682 | { | 684 | { |
683 | if (!bitmap->mddev->bitmap_info.external) | 685 | if (store->sb_page) |
684 | chunk += sizeof(bitmap_super_t) << 3; | 686 | chunk += sizeof(bitmap_super_t) << 3; |
685 | return chunk >> PAGE_BIT_SHIFT; | 687 | return chunk >> PAGE_BIT_SHIFT; |
686 | } | 688 | } |
687 | 689 | ||
688 | /* calculate the (bit) offset of this bit within a page */ | 690 | /* calculate the (bit) offset of this bit within a page */ |
689 | static inline unsigned long file_page_offset(struct bitmap *bitmap, unsigned long chunk) | 691 | static inline unsigned long file_page_offset(struct bitmap_storage *store, |
692 | unsigned long chunk) | ||
690 | { | 693 | { |
691 | if (!bitmap->mddev->bitmap_info.external) | 694 | if (store->sb_page) |
692 | chunk += sizeof(bitmap_super_t) << 3; | 695 | chunk += sizeof(bitmap_super_t) << 3; |
693 | return chunk & (PAGE_BITS - 1); | 696 | return chunk & (PAGE_BITS - 1); |
694 | } | 697 | } |
@@ -700,13 +703,13 @@ static inline unsigned long file_page_offset(struct bitmap *bitmap, unsigned lon | |||
700 | * 1 page (e.g., x86) or less than 1 page -- so the bitmap might start on page | 703 | * 1 page (e.g., x86) or less than 1 page -- so the bitmap might start on page |
701 | * 0 or page 1 | 704 | * 0 or page 1 |
702 | */ | 705 | */ |
703 | static inline struct page *filemap_get_page(struct bitmap *bitmap, | 706 | static inline struct page *filemap_get_page(struct bitmap_storage *store, |
704 | unsigned long chunk) | 707 | unsigned long chunk) |
705 | { | 708 | { |
706 | if (file_page_index(bitmap, chunk) >= bitmap->file_pages) | 709 | if (file_page_index(store, chunk) >= store->file_pages) |
707 | return NULL; | 710 | return NULL; |
708 | return bitmap->filemap[file_page_index(bitmap, chunk) | 711 | return store->filemap[file_page_index(store, chunk) |
709 | - file_page_index(bitmap, 0)]; | 712 | - file_page_index(store, 0)]; |
710 | } | 713 | } |
711 | 714 | ||
712 | static void bitmap_file_unmap(struct bitmap *bitmap) | 715 | static void bitmap_file_unmap(struct bitmap *bitmap) |
@@ -715,16 +718,17 @@ static void bitmap_file_unmap(struct bitmap *bitmap) | |||
715 | unsigned long *attr; | 718 | unsigned long *attr; |
716 | int pages; | 719 | int pages; |
717 | unsigned long flags; | 720 | unsigned long flags; |
721 | struct bitmap_storage *store = &bitmap->storage; | ||
718 | 722 | ||
719 | spin_lock_irqsave(&bitmap->lock, flags); | 723 | spin_lock_irqsave(&bitmap->lock, flags); |
720 | map = bitmap->filemap; | 724 | map = store->filemap; |
721 | bitmap->filemap = NULL; | 725 | store->filemap = NULL; |
722 | attr = bitmap->filemap_attr; | 726 | attr = store->filemap_attr; |
723 | bitmap->filemap_attr = NULL; | 727 | store->filemap_attr = NULL; |
724 | pages = bitmap->file_pages; | 728 | pages = store->file_pages; |
725 | bitmap->file_pages = 0; | 729 | store->file_pages = 0; |
726 | sb_page = bitmap->sb_page; | 730 | sb_page = store->sb_page; |
727 | bitmap->sb_page = NULL; | 731 | store->sb_page = NULL; |
728 | spin_unlock_irqrestore(&bitmap->lock, flags); | 732 | spin_unlock_irqrestore(&bitmap->lock, flags); |
729 | 733 | ||
730 | while (pages--) | 734 | while (pages--) |
@@ -743,8 +747,8 @@ static void bitmap_file_put(struct bitmap *bitmap) | |||
743 | unsigned long flags; | 747 | unsigned long flags; |
744 | 748 | ||
745 | spin_lock_irqsave(&bitmap->lock, flags); | 749 | spin_lock_irqsave(&bitmap->lock, flags); |
746 | file = bitmap->file; | 750 | file = bitmap->storage.file; |
747 | bitmap->file = NULL; | 751 | bitmap->storage.file = NULL; |
748 | spin_unlock_irqrestore(&bitmap->lock, flags); | 752 | spin_unlock_irqrestore(&bitmap->lock, flags); |
749 | 753 | ||
750 | if (file) | 754 | if (file) |
@@ -771,11 +775,11 @@ static void bitmap_file_kick(struct bitmap *bitmap) | |||
771 | if (bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET) == 0) { | 775 | if (bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET) == 0) { |
772 | bitmap_update_sb(bitmap); | 776 | bitmap_update_sb(bitmap); |
773 | 777 | ||
774 | if (bitmap->file) { | 778 | if (bitmap->storage.file) { |
775 | path = kmalloc(PAGE_SIZE, GFP_KERNEL); | 779 | path = kmalloc(PAGE_SIZE, GFP_KERNEL); |
776 | if (path) | 780 | if (path) |
777 | ptr = d_path(&bitmap->file->f_path, path, | 781 | ptr = d_path(&bitmap->storage.file->f_path, |
778 | PAGE_SIZE); | 782 | path, PAGE_SIZE); |
779 | 783 | ||
780 | printk(KERN_ALERT | 784 | printk(KERN_ALERT |
781 | "%s: kicking failed bitmap file %s from array!\n", | 785 | "%s: kicking failed bitmap file %s from array!\n", |
@@ -803,19 +807,19 @@ enum bitmap_page_attr { | |||
803 | static inline void set_page_attr(struct bitmap *bitmap, int pnum, | 807 | static inline void set_page_attr(struct bitmap *bitmap, int pnum, |
804 | enum bitmap_page_attr attr) | 808 | enum bitmap_page_attr attr) |
805 | { | 809 | { |
806 | __set_bit((pnum<<2) + attr, bitmap->filemap_attr); | 810 | __set_bit((pnum<<2) + attr, bitmap->storage.filemap_attr); |
807 | } | 811 | } |
808 | 812 | ||
809 | static inline void clear_page_attr(struct bitmap *bitmap, int pnum, | 813 | static inline void clear_page_attr(struct bitmap *bitmap, int pnum, |
810 | enum bitmap_page_attr attr) | 814 | enum bitmap_page_attr attr) |
811 | { | 815 | { |
812 | __clear_bit((pnum<<2) + attr, bitmap->filemap_attr); | 816 | __clear_bit((pnum<<2) + attr, bitmap->storage.filemap_attr); |
813 | } | 817 | } |
814 | 818 | ||
815 | static inline unsigned long test_page_attr(struct bitmap *bitmap, int pnum, | 819 | static inline unsigned long test_page_attr(struct bitmap *bitmap, int pnum, |
816 | enum bitmap_page_attr attr) | 820 | enum bitmap_page_attr attr) |
817 | { | 821 | { |
818 | return test_bit((pnum<<2) + attr, bitmap->filemap_attr); | 822 | return test_bit((pnum<<2) + attr, bitmap->storage.filemap_attr); |
819 | } | 823 | } |
820 | 824 | ||
821 | /* | 825 | /* |
@@ -832,10 +836,10 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) | |||
832 | void *kaddr; | 836 | void *kaddr; |
833 | unsigned long chunk = block >> bitmap->chunkshift; | 837 | unsigned long chunk = block >> bitmap->chunkshift; |
834 | 838 | ||
835 | page = filemap_get_page(bitmap, chunk); | 839 | page = filemap_get_page(&bitmap->storage, chunk); |
836 | if (!page) | 840 | if (!page) |
837 | return; | 841 | return; |
838 | bit = file_page_offset(bitmap, chunk); | 842 | bit = file_page_offset(&bitmap->storage, chunk); |
839 | 843 | ||
840 | /* set the bit */ | 844 | /* set the bit */ |
841 | kaddr = kmap_atomic(page); | 845 | kaddr = kmap_atomic(page); |
@@ -856,10 +860,10 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) | |||
856 | void *paddr; | 860 | void *paddr; |
857 | unsigned long chunk = block >> bitmap->chunkshift; | 861 | unsigned long chunk = block >> bitmap->chunkshift; |
858 | 862 | ||
859 | page = filemap_get_page(bitmap, chunk); | 863 | page = filemap_get_page(&bitmap->storage, chunk); |
860 | if (!page) | 864 | if (!page) |
861 | return; | 865 | return; |
862 | bit = file_page_offset(bitmap, chunk); | 866 | bit = file_page_offset(&bitmap->storage, chunk); |
863 | paddr = kmap_atomic(page); | 867 | paddr = kmap_atomic(page); |
864 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 868 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
865 | clear_bit(bit, paddr); | 869 | clear_bit(bit, paddr); |
@@ -881,14 +885,14 @@ void bitmap_unplug(struct bitmap *bitmap) | |||
881 | int dirty, need_write; | 885 | int dirty, need_write; |
882 | int wait = 0; | 886 | int wait = 0; |
883 | 887 | ||
884 | if (!bitmap || !bitmap->filemap) | 888 | if (!bitmap || !bitmap->storage.filemap) |
885 | return; | 889 | return; |
886 | 890 | ||
887 | /* look at each page to see if there are any set bits that need to be | 891 | /* look at each page to see if there are any set bits that need to be |
888 | * flushed out to disk */ | 892 | * flushed out to disk */ |
889 | for (i = 0; i < bitmap->file_pages; i++) { | 893 | for (i = 0; i < bitmap->storage.file_pages; i++) { |
890 | spin_lock_irqsave(&bitmap->lock, flags); | 894 | spin_lock_irqsave(&bitmap->lock, flags); |
891 | if (!bitmap->filemap) { | 895 | if (!bitmap->storage.filemap) { |
892 | spin_unlock_irqrestore(&bitmap->lock, flags); | 896 | spin_unlock_irqrestore(&bitmap->lock, flags); |
893 | return; | 897 | return; |
894 | } | 898 | } |
@@ -903,10 +907,10 @@ void bitmap_unplug(struct bitmap *bitmap) | |||
903 | spin_unlock_irqrestore(&bitmap->lock, flags); | 907 | spin_unlock_irqrestore(&bitmap->lock, flags); |
904 | 908 | ||
905 | if (dirty || need_write) | 909 | if (dirty || need_write) |
906 | write_page(bitmap, bitmap->filemap[i], 0); | 910 | write_page(bitmap, bitmap->storage.filemap[i], 0); |
907 | } | 911 | } |
908 | if (wait) { /* if any writes were performed, we need to wait on them */ | 912 | if (wait) { /* if any writes were performed, we need to wait on them */ |
909 | if (bitmap->file) | 913 | if (bitmap->storage.file) |
910 | wait_event(bitmap->write_wait, | 914 | wait_event(bitmap->write_wait, |
911 | atomic_read(&bitmap->pending_writes)==0); | 915 | atomic_read(&bitmap->pending_writes)==0); |
912 | else | 916 | else |
@@ -940,14 +944,15 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
940 | int outofdate; | 944 | int outofdate; |
941 | int ret = -ENOSPC; | 945 | int ret = -ENOSPC; |
942 | void *paddr; | 946 | void *paddr; |
947 | struct bitmap_storage *store = &bitmap->storage; | ||
943 | 948 | ||
944 | chunks = bitmap->chunks; | 949 | chunks = bitmap->chunks; |
945 | file = bitmap->file; | 950 | file = store->file; |
946 | 951 | ||
947 | if (!file && !bitmap->mddev->bitmap_info.offset) { | 952 | if (!file && !bitmap->mddev->bitmap_info.offset) { |
948 | /* No permanent bitmap - fill with '1s'. */ | 953 | /* No permanent bitmap - fill with '1s'. */ |
949 | bitmap->filemap = NULL; | 954 | store->filemap = NULL; |
950 | bitmap->file_pages = 0; | 955 | store->file_pages = 0; |
951 | for (i = 0; i < chunks ; i++) { | 956 | for (i = 0; i < chunks ; i++) { |
952 | /* if the disk bit is set, set the memory bit */ | 957 | /* if the disk bit is set, set the memory bit */ |
953 | int needed = ((sector_t)(i+1) << (bitmap->chunkshift) | 958 | int needed = ((sector_t)(i+1) << (bitmap->chunkshift) |
@@ -980,39 +985,40 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
980 | 985 | ||
981 | ret = -ENOMEM; | 986 | ret = -ENOMEM; |
982 | 987 | ||
983 | bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL); | 988 | store->filemap = kmalloc(sizeof(struct page *) |
984 | if (!bitmap->filemap) | 989 | * num_pages, GFP_KERNEL); |
990 | if (!store->filemap) | ||
985 | goto err; | 991 | goto err; |
986 | 992 | ||
987 | pnum = 0; | 993 | pnum = 0; |
988 | offset = 0; | 994 | offset = 0; |
989 | if (bitmap->sb_page) { | 995 | if (store->sb_page) { |
990 | bitmap->filemap[0] = bitmap->sb_page; | 996 | store->filemap[0] = store->sb_page; |
991 | pnum = 1; | 997 | pnum = 1; |
992 | offset = sizeof(bitmap_super_t); | 998 | offset = sizeof(bitmap_super_t); |
993 | } | 999 | } |
994 | for ( ; pnum < num_pages; pnum++) { | 1000 | for ( ; pnum < num_pages; pnum++) { |
995 | bitmap->filemap[pnum] = alloc_page(GFP_KERNEL); | 1001 | store->filemap[pnum] = alloc_page(GFP_KERNEL); |
996 | if (!bitmap->filemap[pnum]) { | 1002 | if (!store->filemap[pnum]) { |
997 | bitmap->file_pages = pnum; | 1003 | store->file_pages = pnum; |
998 | goto err; | 1004 | goto err; |
999 | } | 1005 | } |
1000 | } | 1006 | } |
1001 | bitmap->file_pages = pnum; | 1007 | store->file_pages = pnum; |
1002 | 1008 | ||
1003 | /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ | 1009 | /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ |
1004 | bitmap->filemap_attr = kzalloc( | 1010 | store->filemap_attr = kzalloc( |
1005 | roundup(DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)), | 1011 | roundup(DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)), |
1006 | GFP_KERNEL); | 1012 | GFP_KERNEL); |
1007 | if (!bitmap->filemap_attr) | 1013 | if (!store->filemap_attr) |
1008 | goto err; | 1014 | goto err; |
1009 | 1015 | ||
1010 | oldindex = ~0L; | 1016 | oldindex = ~0L; |
1011 | 1017 | ||
1012 | for (i = 0; i < chunks; i++) { | 1018 | for (i = 0; i < chunks; i++) { |
1013 | int b; | 1019 | int b; |
1014 | index = file_page_index(bitmap, i); | 1020 | index = file_page_index(&bitmap->storage, i); |
1015 | bit = file_page_offset(bitmap, i); | 1021 | bit = file_page_offset(&bitmap->storage, i); |
1016 | if (index != oldindex) { /* this is a new page, read it in */ | 1022 | if (index != oldindex) { /* this is a new page, read it in */ |
1017 | int count; | 1023 | int count; |
1018 | /* unmap the old page, we're done with it */ | 1024 | /* unmap the old page, we're done with it */ |
@@ -1020,7 +1026,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
1020 | count = bytes - index * PAGE_SIZE; | 1026 | count = bytes - index * PAGE_SIZE; |
1021 | else | 1027 | else |
1022 | count = PAGE_SIZE; | 1028 | count = PAGE_SIZE; |
1023 | page = bitmap->filemap[index]; | 1029 | page = store->filemap[index]; |
1024 | if (file) | 1030 | if (file) |
1025 | ret = read_page(file, index, bitmap, | 1031 | ret = read_page(file, index, bitmap, |
1026 | count, page); | 1032 | count, page); |
@@ -1036,7 +1042,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
1036 | 1042 | ||
1037 | oldindex = index; | 1043 | oldindex = index; |
1038 | 1044 | ||
1039 | bitmap->last_page_size = count; | 1045 | store->last_page_size = count; |
1040 | 1046 | ||
1041 | if (outofdate) { | 1047 | if (outofdate) { |
1042 | /* | 1048 | /* |
@@ -1074,7 +1080,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
1074 | 1080 | ||
1075 | printk(KERN_INFO "%s: bitmap initialized from disk: " | 1081 | printk(KERN_INFO "%s: bitmap initialized from disk: " |
1076 | "read %lu/%lu pages, set %lu of %lu bits\n", | 1082 | "read %lu/%lu pages, set %lu of %lu bits\n", |
1077 | bmname(bitmap), bitmap->file_pages, num_pages, bit_cnt, chunks); | 1083 | bmname(bitmap), store->file_pages, |
1084 | num_pages, bit_cnt, chunks); | ||
1078 | 1085 | ||
1079 | return 0; | 1086 | return 0; |
1080 | 1087 | ||
@@ -1091,14 +1098,14 @@ void bitmap_write_all(struct bitmap *bitmap) | |||
1091 | */ | 1098 | */ |
1092 | int i; | 1099 | int i; |
1093 | 1100 | ||
1094 | if (!bitmap || !bitmap->filemap) | 1101 | if (!bitmap || !bitmap->storage.filemap) |
1095 | return; | 1102 | return; |
1096 | if (bitmap->file) | 1103 | if (bitmap->storage.file) |
1097 | /* Only one copy, so nothing needed */ | 1104 | /* Only one copy, so nothing needed */ |
1098 | return; | 1105 | return; |
1099 | 1106 | ||
1100 | spin_lock_irq(&bitmap->lock); | 1107 | spin_lock_irq(&bitmap->lock); |
1101 | for (i = 0; i < bitmap->file_pages; i++) | 1108 | for (i = 0; i < bitmap->storage.file_pages; i++) |
1102 | set_page_attr(bitmap, i, | 1109 | set_page_attr(bitmap, i, |
1103 | BITMAP_PAGE_NEEDWRITE); | 1110 | BITMAP_PAGE_NEEDWRITE); |
1104 | bitmap->allclean = 0; | 1111 | bitmap->allclean = 0; |
@@ -1165,7 +1172,7 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1165 | * we will write it. | 1172 | * we will write it. |
1166 | */ | 1173 | */ |
1167 | spin_lock_irqsave(&bitmap->lock, flags); | 1174 | spin_lock_irqsave(&bitmap->lock, flags); |
1168 | for (j = 0; j < bitmap->file_pages; j++) | 1175 | for (j = 0; j < bitmap->storage.file_pages; j++) |
1169 | if (test_page_attr(bitmap, j, | 1176 | if (test_page_attr(bitmap, j, |
1170 | BITMAP_PAGE_PENDING)) { | 1177 | BITMAP_PAGE_PENDING)) { |
1171 | set_page_attr(bitmap, j, | 1178 | set_page_attr(bitmap, j, |
@@ -1180,8 +1187,8 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1180 | * other changes */ | 1187 | * other changes */ |
1181 | bitmap_super_t *sb; | 1188 | bitmap_super_t *sb; |
1182 | bitmap->need_sync = 0; | 1189 | bitmap->need_sync = 0; |
1183 | if (bitmap->filemap) { | 1190 | if (bitmap->storage.filemap) { |
1184 | sb = kmap_atomic(bitmap->sb_page); | 1191 | sb = kmap_atomic(bitmap->storage.sb_page); |
1185 | sb->events_cleared = | 1192 | sb->events_cleared = |
1186 | cpu_to_le64(bitmap->events_cleared); | 1193 | cpu_to_le64(bitmap->events_cleared); |
1187 | kunmap_atomic(sb); | 1194 | kunmap_atomic(sb); |
@@ -1233,7 +1240,7 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1233 | * the first blocking holds the superblock and it has been updated. | 1240 | * the first blocking holds the superblock and it has been updated. |
1234 | * We mustn't write any other blocks before the superblock. | 1241 | * We mustn't write any other blocks before the superblock. |
1235 | */ | 1242 | */ |
1236 | for (j = 0; j < bitmap->file_pages; j++) { | 1243 | for (j = 0; j < bitmap->storage.file_pages; j++) { |
1237 | 1244 | ||
1238 | if (test_page_attr(bitmap, j, | 1245 | if (test_page_attr(bitmap, j, |
1239 | BITMAP_PAGE_DIRTY)) | 1246 | BITMAP_PAGE_DIRTY)) |
@@ -1244,9 +1251,9 @@ void bitmap_daemon_work(struct mddev *mddev) | |||
1244 | clear_page_attr(bitmap, j, | 1251 | clear_page_attr(bitmap, j, |
1245 | BITMAP_PAGE_NEEDWRITE); | 1252 | BITMAP_PAGE_NEEDWRITE); |
1246 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1253 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1247 | write_page(bitmap, bitmap->filemap[j], 0); | 1254 | write_page(bitmap, bitmap->storage.filemap[j], 0); |
1248 | spin_lock_irqsave(&bitmap->lock, flags); | 1255 | spin_lock_irqsave(&bitmap->lock, flags); |
1249 | if (!bitmap->filemap) | 1256 | if (!bitmap->storage.filemap) |
1250 | break; | 1257 | break; |
1251 | } | 1258 | } |
1252 | } | 1259 | } |
@@ -1700,7 +1707,7 @@ int bitmap_create(struct mddev *mddev) | |||
1700 | } else | 1707 | } else |
1701 | bitmap->sysfs_can_clear = NULL; | 1708 | bitmap->sysfs_can_clear = NULL; |
1702 | 1709 | ||
1703 | bitmap->file = file; | 1710 | bitmap->storage.file = file; |
1704 | if (file) { | 1711 | if (file) { |
1705 | get_file(file); | 1712 | get_file(file); |
1706 | /* As future accesses to this file will use bmap, | 1713 | /* As future accesses to this file will use bmap, |
@@ -1832,9 +1839,9 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) | |||
1832 | << (PAGE_SHIFT - 10), | 1839 | << (PAGE_SHIFT - 10), |
1833 | chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize, | 1840 | chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize, |
1834 | chunk_kb ? "KB" : "B"); | 1841 | chunk_kb ? "KB" : "B"); |
1835 | if (bitmap->file) { | 1842 | if (bitmap->storage.file) { |
1836 | seq_printf(seq, ", file: "); | 1843 | seq_printf(seq, ", file: "); |
1837 | seq_path(seq, &bitmap->file->f_path, " \t\n"); | 1844 | seq_path(seq, &bitmap->storage.file->f_path, " \t\n"); |
1838 | } | 1845 | } |
1839 | 1846 | ||
1840 | seq_printf(seq, "\n"); | 1847 | seq_printf(seq, "\n"); |
@@ -1958,8 +1965,9 @@ space_store(struct mddev *mddev, const char *buf, size_t len) | |||
1958 | return -EINVAL; | 1965 | return -EINVAL; |
1959 | 1966 | ||
1960 | if (mddev->bitmap && | 1967 | if (mddev->bitmap && |
1961 | sectors < ((mddev->bitmap->file_pages - 1) * PAGE_SIZE | 1968 | sectors < ((mddev->bitmap->storage.file_pages - 1) |
1962 | + mddev->bitmap->last_page_size + 511) >> 9) | 1969 | * PAGE_SIZE |
1970 | + mddev->bitmap->storage.last_page_size + 511) >> 9) | ||
1963 | return -EFBIG; /* Bitmap is too big for this small space */ | 1971 | return -EFBIG; /* Bitmap is too big for this small space */ |
1964 | 1972 | ||
1965 | /* could make sure it isn't too big, but that isn't really | 1973 | /* could make sure it isn't too big, but that isn't really |