X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Fmd%2Fbitmap.c;h=8e67634e79a0d1f16d033e9e7ecdf3bcdd416f56;hb=5df0a29d9c2239c28b5864037b51ac3d747439a9;hp=ebbd2d856256f148d9352a396e2c537d59564925;hpb=936813a8807c5684c6a97f1081b31027403d4a93;p=powerpc.git diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index ebbd2d8562..8e67634e79 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -614,6 +613,7 @@ static inline unsigned long file_page_offset(unsigned long chunk) static inline struct page *filemap_get_page(struct bitmap *bitmap, unsigned long chunk) { + if (file_page_index(chunk) >= bitmap->file_pages) return NULL; return bitmap->filemap[file_page_index(chunk) - file_page_index(0)]; } @@ -740,6 +740,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) } page = filemap_get_page(bitmap, chunk); + if (!page) return; bit = file_page_offset(chunk); /* set the bit */ @@ -1323,6 +1324,18 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n } +/* dirty the memory and file bits for bitmap chunks "s" to "e" */ +void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e) +{ + unsigned long chunk; + + for (chunk = s; chunk <= e; chunk++) { + sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap); + bitmap_set_memory_bits(bitmap, sec, 1); + bitmap_file_set_bit(bitmap, sec); + } +} + /* * flush out any pending updates */ @@ -1431,8 +1444,7 @@ int bitmap_create(mddev_t *mddev) if (err) goto error; - bitmap->chunkshift = find_first_bit(&bitmap->chunksize, - sizeof(bitmap->chunksize)); + bitmap->chunkshift = ffz(~bitmap->chunksize); /* now that chunksize and chunkshift are set, we can use these macros */ chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) /