diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2016-05-02 11:50:14 -0400 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2016-05-04 15:39:35 -0400 |
commit | 23cea66a37c76dc6554b862b179a654db24fa83d (patch) | |
tree | 6a97f3225c3a47fbd1fdc30ceff85aa1de25184f /drivers/md/bitmap.c | |
parent | 7f86ffed9b5f3f0b1a29108c5e965942b935ec98 (diff) |
md-cluster/bitmap: fix wrong page num in bitmap_file_clear_bit and bitmap_file_set_bit
The pnum passed to set_page_attr and test_page_attr should from
0 to storage.file_pages - 1, but bitmap_file_set_bit and
bitmap_file_clear_bit call set_page_attr and test_page_attr with
page->index parameter while page->index has already added node_offset
before.
So we need to minus node_offset in both bitmap_file_clear_bit
and bitmap_file_set_bit.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index cf93bb80aff7..de28c8095df8 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -903,6 +903,11 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) | |||
903 | struct page *page; | 903 | struct page *page; |
904 | void *kaddr; | 904 | void *kaddr; |
905 | unsigned long chunk = block >> bitmap->counts.chunkshift; | 905 | unsigned long chunk = block >> bitmap->counts.chunkshift; |
906 | struct bitmap_storage *store = &bitmap->storage; | ||
907 | unsigned long node_offset = 0; | ||
908 | |||
909 | if (mddev_is_clustered(bitmap->mddev)) | ||
910 | node_offset = bitmap->cluster_slot * store->file_pages; | ||
906 | 911 | ||
907 | page = filemap_get_page(&bitmap->storage, chunk); | 912 | page = filemap_get_page(&bitmap->storage, chunk); |
908 | if (!page) | 913 | if (!page) |
@@ -918,7 +923,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) | |||
918 | kunmap_atomic(kaddr); | 923 | kunmap_atomic(kaddr); |
919 | pr_debug("set file bit %lu page %lu\n", bit, page->index); | 924 | pr_debug("set file bit %lu page %lu\n", bit, page->index); |
920 | /* record page number so it gets flushed to disk when unplug occurs */ | 925 | /* record page number so it gets flushed to disk when unplug occurs */ |
921 | set_page_attr(bitmap, page->index, BITMAP_PAGE_DIRTY); | 926 | set_page_attr(bitmap, page->index - node_offset, BITMAP_PAGE_DIRTY); |
922 | } | 927 | } |
923 | 928 | ||
924 | static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) | 929 | static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) |
@@ -927,6 +932,11 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) | |||
927 | struct page *page; | 932 | struct page *page; |
928 | void *paddr; | 933 | void *paddr; |
929 | unsigned long chunk = block >> bitmap->counts.chunkshift; | 934 | unsigned long chunk = block >> bitmap->counts.chunkshift; |
935 | struct bitmap_storage *store = &bitmap->storage; | ||
936 | unsigned long node_offset = 0; | ||
937 | |||
938 | if (mddev_is_clustered(bitmap->mddev)) | ||
939 | node_offset = bitmap->cluster_slot * store->file_pages; | ||
930 | 940 | ||
931 | page = filemap_get_page(&bitmap->storage, chunk); | 941 | page = filemap_get_page(&bitmap->storage, chunk); |
932 | if (!page) | 942 | if (!page) |
@@ -938,8 +948,8 @@ static void bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block) | |||
938 | else | 948 | else |
939 | clear_bit_le(bit, paddr); | 949 | clear_bit_le(bit, paddr); |
940 | kunmap_atomic(paddr); | 950 | kunmap_atomic(paddr); |
941 | if (!test_page_attr(bitmap, page->index, BITMAP_PAGE_NEEDWRITE)) { | 951 | if (!test_page_attr(bitmap, page->index - node_offset, BITMAP_PAGE_NEEDWRITE)) { |
942 | set_page_attr(bitmap, page->index, BITMAP_PAGE_PENDING); | 952 | set_page_attr(bitmap, page->index - node_offset, BITMAP_PAGE_PENDING); |
943 | bitmap->allclean = 0; | 953 | bitmap->allclean = 0; |
944 | } | 954 | } |
945 | } | 955 | } |