diff options
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 0f1732570770..2e257d5998bc 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -700,27 +700,27 @@ static void bitmap_file_kick(struct bitmap *bitmap) | |||
700 | } | 700 | } |
701 | 701 | ||
702 | enum bitmap_page_attr { | 702 | enum bitmap_page_attr { |
703 | BITMAP_PAGE_DIRTY = 1, // there are set bits that need to be synced | 703 | BITMAP_PAGE_DIRTY = 0, // there are set bits that need to be synced |
704 | BITMAP_PAGE_CLEAN = 2, // there are bits that might need to be cleared | 704 | BITMAP_PAGE_CLEAN = 1, // there are bits that might need to be cleared |
705 | BITMAP_PAGE_NEEDWRITE=4, // there are cleared bits that need to be synced | 705 | BITMAP_PAGE_NEEDWRITE=2, // there are cleared bits that need to be synced |
706 | }; | 706 | }; |
707 | 707 | ||
708 | static inline void set_page_attr(struct bitmap *bitmap, struct page *page, | 708 | static inline void set_page_attr(struct bitmap *bitmap, struct page *page, |
709 | enum bitmap_page_attr attr) | 709 | enum bitmap_page_attr attr) |
710 | { | 710 | { |
711 | bitmap->filemap_attr[page->index] |= attr; | 711 | __set_bit((page->index<<2) + attr, bitmap->filemap_attr); |
712 | } | 712 | } |
713 | 713 | ||
714 | static inline void clear_page_attr(struct bitmap *bitmap, struct page *page, | 714 | static inline void clear_page_attr(struct bitmap *bitmap, struct page *page, |
715 | enum bitmap_page_attr attr) | 715 | enum bitmap_page_attr attr) |
716 | { | 716 | { |
717 | bitmap->filemap_attr[page->index] &= ~attr; | 717 | __clear_bit((page->index<<2) + attr, bitmap->filemap_attr); |
718 | } | 718 | } |
719 | 719 | ||
720 | static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page, | 720 | static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page, |
721 | enum bitmap_page_attr attr) | 721 | enum bitmap_page_attr attr) |
722 | { | 722 | { |
723 | return bitmap->filemap_attr[page->index] & attr; | 723 | return test_bit((page->index<<2) + attr, bitmap->filemap_attr); |
724 | } | 724 | } |
725 | 725 | ||
726 | /* | 726 | /* |
@@ -872,7 +872,12 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
872 | if (!bitmap->filemap) | 872 | if (!bitmap->filemap) |
873 | goto out; | 873 | goto out; |
874 | 874 | ||
875 | bitmap->filemap_attr = kzalloc(sizeof(long) * num_pages, GFP_KERNEL); | 875 | /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ |
876 | bitmap->filemap_attr = kzalloc( | ||
877 | (((num_pages*4/8)+sizeof(unsigned long)-1) | ||
878 | /sizeof(unsigned long)) | ||
879 | *sizeof(unsigned long), | ||
880 | GFP_KERNEL); | ||
876 | if (!bitmap->filemap_attr) | 881 | if (!bitmap->filemap_attr) |
877 | goto out; | 882 | goto out; |
878 | 883 | ||