diff options
author | NeilBrown <neilb@suse.de> | 2006-06-26 03:27:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-26 12:58:38 -0400 |
commit | e16b68b6e456a61b895a198baf5aa473cf2a32bf (patch) | |
tree | 0d592ee3c7245f4958dcd337cc506e650cefac2c /drivers/md/bitmap.c | |
parent | ec7a3197f4777eff5039251d0e08a031b3372d6c (diff) |
[PATCH] md/bitmap: use set_bit etc for bitmap page attributes
In particular, this means that we use 4 bits per page instead of a whole
unsigned long.
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
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 | ||