• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/md/

Lines Matching refs:bitmap

2  * bitmap.c two-level bitmap (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003
4 * bitmap_create - sets up the bitmap structure
5 * bitmap_destroy - destroys the bitmap structure
8 * - added disk storage for bitmap
9 * - changes to allow various bitmap chunk sizes
30 #include <linux/raid/bitmap.h>
41 #define INJECT_FAULTS_2 0 /* cause bitmap file to be kicked when first bit set*/
42 #define INJECT_FAULTS_3 0 /* treat bitmap file as kicked at init time */
64 static inline char * bmname(struct bitmap *bitmap)
66 return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
71 * just a placeholder - calls kmalloc for bitmap pages
73 static unsigned char *bitmap_alloc_page(struct bitmap *bitmap)
83 printk("%s: bitmap_alloc_page FAILED\n", bmname(bitmap));
86 bmname(bitmap), page);
91 * for now just a placeholder -- just calls kfree for bitmap pages
93 static void bitmap_free_page(struct bitmap *bitmap, unsigned char *page)
95 PRINTK("%s: bitmap_free_page: free page %p\n", bmname(bitmap), page);
109 static int bitmap_checkpage(struct bitmap *bitmap, unsigned long page, int create)
113 if (page >= bitmap->pages) {
115 "%s: invalid bitmap page request: %lu (> %lu)\n",
116 bmname(bitmap), page, bitmap->pages-1);
121 if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */
124 if (bitmap->bp[page].map) /* page is already allocated, just return */
130 spin_unlock_irq(&bitmap->lock);
134 if ((mappage = bitmap_alloc_page(bitmap)) == NULL) {
135 PRINTK("%s: bitmap map page allocation failed, hijacking\n",
136 bmname(bitmap));
139 spin_lock_irq(&bitmap->lock);
140 if (!bitmap->bp[page].map)
141 bitmap->bp[page].hijacked = 1;
147 spin_lock_irq(&bitmap->lock);
151 if (bitmap->bp[page].map || bitmap->bp[page].hijacked) {
153 bitmap_free_page(bitmap, mappage);
160 bitmap->bp[page].map = mappage;
161 bitmap->missing_pages--;
170 static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
174 if (bitmap->bp[page].count) /* page is still busy */
179 if (bitmap->bp[page].hijacked) { /* page was hijacked, undo this now */
180 bitmap->bp[page].hijacked = 0;
181 bitmap->bp[page].map = NULL;
187 ptr = bitmap->bp[page].map;
188 bitmap->bp[page].map = NULL;
189 bitmap->missing_pages++;
190 bitmap_free_page(bitmap, ptr);
196 * bitmap file handling - read and write the bitmap file and its superblock
220 /* IO operations when bitmap is stored near all superblocks */
251 static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
255 mddev_t *mddev = bitmap->mddev;
261 if (page->index == bitmap->file_pages-1)
262 size = roundup(bitmap->last_page_size,
265 (rdev->sb_offset<<1) + bitmap->offset
279 static int write_page(struct bitmap *bitmap, struct page *page, int wait)
283 if (bitmap->file == NULL)
284 return write_sb_page(bitmap, page, wait);
289 atomic_inc(&bitmap->pending_writes);
297 wait_event(bitmap->write_wait,
298 atomic_read(&bitmap->pending_writes)==0);
299 return (bitmap->flags & BITMAP_WRITE_ERROR) ? -EIO : 0;
306 struct bitmap *bitmap = bh->b_private;
310 spin_lock_irqsave(&bitmap->lock, flags);
311 bitmap->flags |= BITMAP_WRITE_ERROR;
312 spin_unlock_irqrestore(&bitmap->lock, flags);
314 if (atomic_dec_and_test(&bitmap->pending_writes))
315 wake_up(&bitmap->write_wait);
347 struct bitmap *bitmap,
355 PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_SIZE,
390 bh->b_private = bitmap;
391 atomic_inc(&bitmap->pending_writes);
401 wait_event(bitmap->write_wait,
402 atomic_read(&bitmap->pending_writes)==0);
403 if (bitmap->flags & BITMAP_WRITE_ERROR) {
409 printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n",
417 * bitmap file superblock operations
421 int bitmap_update_sb(struct bitmap *bitmap)
426 if (!bitmap || !bitmap->mddev) /* no bitmap for this array */
428 spin_lock_irqsave(&bitmap->lock, flags);
429 if (!bitmap->sb_page) { /* no superblock */
430 spin_unlock_irqrestore(&bitmap->lock, flags);
433 spin_unlock_irqrestore(&bitmap->lock, flags);
434 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
435 sb->events = cpu_to_le64(bitmap->mddev->events);
436 if (!bitmap->mddev->degraded)
437 sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
439 return write_page(bitmap, bitmap->sb_page, 1);
442 /* print out the bitmap file superblock */
443 void bitmap_print_sb(struct bitmap *bitmap)
447 if (!bitmap || !bitmap->sb_page)
449 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
450 printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap));
471 /* read the superblock from the bitmap file and initialize some bitmap fields */
472 static int bitmap_read_sb(struct bitmap *bitmap)
481 if (bitmap->file) {
482 loff_t isize = i_size_read(bitmap->file->f_mapping->host);
485 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes);
487 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, 0);
489 if (IS_ERR(bitmap->sb_page)) {
490 err = PTR_ERR(bitmap->sb_page);
491 bitmap->sb_page = NULL;
495 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
501 /* verify that the bitmap-specific fields are valid */
508 reason = "bitmap chunksize too small";
510 reason = "bitmap chunksize not a power of 2";
516 printk(KERN_INFO "%s: invalid bitmap file superblock: %s\n",
517 bmname(bitmap), reason);
521 /* keep the array size field of the bitmap superblock up to date */
522 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors);
524 if (!bitmap->mddev->persistent)
529 * bitmap's UUID and event counter to the mddev's
531 if (memcmp(sb->uuid, bitmap->mddev->uuid, 16)) {
532 printk(KERN_INFO "%s: bitmap superblock UUID mismatch\n",
533 bmname(bitmap));
537 if (events < bitmap->mddev->events) {
538 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
539 "-- forcing full recovery\n", bmname(bitmap), events,
540 (unsigned long long) bitmap->mddev->events);
545 bitmap->chunksize = chunksize;
546 bitmap->daemon_sleep = daemon_sleep;
547 bitmap->daemon_lastrun = jiffies;
548 bitmap->max_write_behind = write_behind;
549 bitmap->flags |= le32_to_cpu(sb->state);
551 bitmap->flags |= BITMAP_HOSTENDIAN;
552 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
554 bitmap->events_cleared = bitmap->mddev->events;
559 bitmap_print_sb(bitmap);
568 /* record the state of the bitmap in the superblock */
569 static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
575 spin_lock_irqsave(&bitmap->lock, flags);
576 if (!bitmap->sb_page) { /* can't set the state */
577 spin_unlock_irqrestore(&bitmap->lock, flags);
580 spin_unlock_irqrestore(&bitmap->lock, flags);
581 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
593 * general bitmap file operations
611 * this lookup is complicated by the fact that the bitmap sb might be exactly
612 * 1 page (e.g., x86) or less than 1 page -- so the bitmap might start on page
615 static inline struct page *filemap_get_page(struct bitmap *bitmap,
618 if (file_page_index(chunk) >= bitmap->file_pages) return NULL;
619 return bitmap->filemap[file_page_index(chunk) - file_page_index(0)];
623 static void bitmap_file_unmap(struct bitmap *bitmap)
630 spin_lock_irqsave(&bitmap->lock, flags);
631 map = bitmap->filemap;
632 bitmap->filemap = NULL;
633 attr = bitmap->filemap_attr;
634 bitmap->filemap_attr = NULL;
635 pages = bitmap->file_pages;
636 bitmap->file_pages = 0;
637 sb_page = bitmap->sb_page;
638 bitmap->sb_page = NULL;
639 spin_unlock_irqrestore(&bitmap->lock, flags);
651 static void bitmap_file_put(struct bitmap *bitmap)
656 spin_lock_irqsave(&bitmap->lock, flags);
657 file = bitmap->file;
658 bitmap->file = NULL;
659 spin_unlock_irqrestore(&bitmap->lock, flags);
662 wait_event(bitmap->write_wait,
663 atomic_read(&bitmap->pending_writes)==0);
664 bitmap_file_unmap(bitmap);
675 * bitmap_file_kick - if an error occurs while manipulating the bitmap file
679 static void bitmap_file_kick(struct bitmap *bitmap)
683 bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET);
684 bitmap_update_sb(bitmap);
686 if (bitmap->file) {
689 ptr = file_path(bitmap->file, path, PAGE_SIZE);
691 printk(KERN_ALERT "%s: kicking failed bitmap file %s from array!\n",
692 bmname(bitmap), ptr ? ptr : "");
697 bitmap_file_put(bitmap);
708 static inline void set_page_attr(struct bitmap *bitmap, struct page *page,
711 __set_bit((page->index<<2) + attr, bitmap->filemap_attr);
714 static inline void clear_page_attr(struct bitmap *bitmap, struct page *page,
717 __clear_bit((page->index<<2) + attr, bitmap->filemap_attr);
720 static inline unsigned long test_page_attr(struct bitmap *bitmap, struct page *page,
723 return test_bit((page->index<<2) + attr, bitmap->filemap_attr);
728 * to set (and eventually sync) a particular bit in the bitmap file
733 static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
738 unsigned long chunk = block >> CHUNK_BLOCK_SHIFT(bitmap);
740 if (!bitmap->filemap) {
744 page = filemap_get_page(bitmap, chunk);
750 if (bitmap->flags & BITMAP_HOSTENDIAN)
758 set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
764 * sync the dirty pages of the bitmap file to disk */
765 int bitmap_unplug(struct bitmap *bitmap)
773 if (!bitmap)
778 for (i = 0; i < bitmap->file_pages; i++) {
779 spin_lock_irqsave(&bitmap->lock, flags);
780 if (!bitmap->filemap) {
781 spin_unlock_irqrestore(&bitmap->lock, flags);
784 page = bitmap->filemap[i];
785 dirty = test_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
786 need_write = test_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
787 clear_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
788 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
791 spin_unlock_irqrestore(&bitmap->lock, flags);
794 err = write_page(bitmap, page, 0);
797 if (bitmap->file)
798 wait_event(bitmap->write_wait,
799 atomic_read(&bitmap->pending_writes)==0);
801 md_super_wait(bitmap->mddev);
803 if (bitmap->flags & BITMAP_WRITE_ERROR)
804 bitmap_file_kick(bitmap);
808 static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed);
810 * the in-memory bitmap from the on-disk bitmap -- also, sets up the
811 * memory mapping of the bitmap file
813 * if there's no bitmap file, or if the bitmap file had been
818 * This is used when reading an out-of-date bitmap...
820 static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
831 chunks = bitmap->chunks;
832 file = bitmap->file;
834 BUG_ON(!file && !bitmap->offset);
839 outofdate = bitmap->flags & BITMAP_STALE;
842 printk(KERN_INFO "%s: bitmap file is out of date, doing full "
843 "recovery\n", bmname(bitmap));
850 printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n",
851 bmname(bitmap),
859 bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
860 if (!bitmap->filemap)
864 bitmap->filemap_attr = kzalloc(
867 if (!bitmap->filemap_attr)
890 page = bitmap->sb_page;
893 page = read_page(file, index, bitmap, count);
896 page = read_sb_page(bitmap->mddev, bitmap->offset, index);
909 * if bitmap is out of date, dirty the
916 ret = write_page(bitmap, page, 1);
924 bitmap->filemap[bitmap->file_pages++] = page;
925 bitmap->last_page_size = count;
928 if (bitmap->flags & BITMAP_HOSTENDIAN)
935 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap),
936 ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start)
939 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
945 bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);
948 set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);
949 md_wakeup_thread(bitmap->mddev->thread);
953 printk(KERN_INFO "%s: bitmap initialized from disk: "
955 bmname(bitmap), bitmap->file_pages, num_pages, bit_cnt, ret);
960 void bitmap_write_all(struct bitmap *bitmap)
962 /* We don't actually write all bitmap blocks here,
967 for (i=0; i < bitmap->file_pages; i++)
968 set_page_attr(bitmap, bitmap->filemap[i],
973 static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc)
975 sector_t chunk = offset >> CHUNK_BLOCK_SHIFT(bitmap);
977 bitmap->bp[page].count += inc;
980 (unsigned long long)offset, inc, bitmap->bp[page].count);
982 bitmap_checkfree(bitmap, page);
984 static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
989 * bitmap daemon -- periodically wakes up to clean bits and flush pages
993 int bitmap_daemon_work(struct bitmap *bitmap)
1002 if (bitmap == NULL)
1004 if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ))
1006 bitmap->daemon_lastrun = jiffies;
1008 for (j = 0; j < bitmap->chunks; j++) {
1010 spin_lock_irqsave(&bitmap->lock, flags);
1011 if (!bitmap->filemap) {
1013 spin_unlock_irqrestore(&bitmap->lock, flags);
1017 page = filemap_get_page(bitmap, j);
1021 if (!test_page_attr(bitmap, page, BITMAP_PAGE_CLEAN)) {
1022 int need_write = test_page_attr(bitmap, page,
1025 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
1027 spin_unlock_irqrestore(&bitmap->lock, flags);
1029 switch (write_page(bitmap, page, 0)) {
1033 bitmap_file_kick(bitmap);
1041 if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) {
1042 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1043 spin_unlock_irqrestore(&bitmap->lock, flags);
1044 err = write_page(bitmap, lastpage, 0);
1046 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1047 spin_unlock_irqrestore(&bitmap->lock, flags);
1050 bitmap_file_kick(bitmap);
1052 spin_unlock_irqrestore(&bitmap->lock, flags);
1055 printk("bitmap clean at page %lu\n", j);
1057 spin_lock_irqsave(&bitmap->lock, flags);
1058 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1060 bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),
1064 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);
1068 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1072 bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),
1077 if (bitmap->flags & BITMAP_HOSTENDIAN)
1084 spin_unlock_irqrestore(&bitmap->lock, flags);
1089 spin_lock_irqsave(&bitmap->lock, flags);
1090 if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) {
1091 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1092 spin_unlock_irqrestore(&bitmap->lock, flags);
1093 err = write_page(bitmap, lastpage, 0);
1095 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1096 spin_unlock_irqrestore(&bitmap->lock, flags);
1103 static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
1111 sector_t chunk = offset >> CHUNK_BLOCK_SHIFT(bitmap);
1116 if (bitmap_checkpage(bitmap, page, create) < 0) {
1117 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap));
1123 if (bitmap->bp[page].hijacked) { /* hijacked pointer */
1127 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap) +
1131 &bitmap->bp[page].map)[hi];
1133 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap));
1136 &(bitmap->bp[page].map[pageoff]);
1140 int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int behind)
1142 if (!bitmap) return 0;
1145 atomic_inc(&bitmap->behind_writes);
1147 atomic_read(&bitmap->behind_writes), bitmap->max_write_behind);
1154 spin_lock_irq(&bitmap->lock);
1155 bmc = bitmap_get_counter(bitmap, offset, &blocks, 1);
1157 spin_unlock_irq(&bitmap->lock);
1167 prepare_to_wait(&bitmap->overflow_wait, &__wait,
1169 spin_unlock_irq(&bitmap->lock);
1170 bitmap->mddev->queue
1171 ->unplug_fn(bitmap->mddev->queue);
1173 finish_wait(&bitmap->overflow_wait, &__wait);
1179 bitmap_file_set_bit(bitmap, offset);
1180 bitmap_count_page(bitmap,offset, 1);
1181 blk_plug_device(bitmap->mddev->queue);
1189 spin_unlock_irq(&bitmap->lock);
1199 void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
1202 if (!bitmap) return;
1204 atomic_dec(&bitmap->behind_writes);
1206 atomic_read(&bitmap->behind_writes), bitmap->max_write_behind);
1214 spin_lock_irqsave(&bitmap->lock, flags);
1215 bmc = bitmap_get_counter(bitmap, offset, &blocks, 0);
1217 spin_unlock_irqrestore(&bitmap->lock, flags);
1225 wake_up(&bitmap->overflow_wait);
1229 set_page_attr(bitmap,
1230 filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)),
1233 spin_unlock_irqrestore(&bitmap->lock, flags);
1241 int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
1246 if (bitmap == NULL) {
1248 return 1; /* always resync if no bitmap */
1250 spin_lock_irq(&bitmap->lock);
1251 bmc = bitmap_get_counter(bitmap, offset, blocks, 0);
1265 spin_unlock_irq(&bitmap->lock);
1269 void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted)
1275 */ if (bitmap == NULL) {
1279 spin_lock_irqsave(&bitmap->lock, flags);
1280 bmc = bitmap_get_counter(bitmap, offset, blocks, 0);
1294 set_page_attr(bitmap,
1295 filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)),
1301 spin_unlock_irqrestore(&bitmap->lock, flags);
1304 void bitmap_close_sync(struct bitmap *bitmap)
1306 /* Sync has finished, and any bitmap chunks that weren't synced
1312 if (!bitmap) return;
1313 while (sector < bitmap->mddev->resync_max_sectors) {
1314 bitmap_end_sync(bitmap, sector, &blocks, 0);
1322 static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed)
1331 spin_lock_irq(&bitmap->lock);
1332 bmc = bitmap_get_counter(bitmap, offset, &secs, 1);
1334 spin_unlock_irq(&bitmap->lock);
1340 bitmap_count_page(bitmap, offset, 1);
1341 page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap));
1342 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1344 spin_unlock_irq(&bitmap->lock);
1348 /* dirty the memory and file bits for bitmap chunks "s" to "e" */
1349 void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1354 sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap);
1355 bitmap_set_memory_bits(bitmap, sec, 1);
1356 bitmap_file_set_bit(bitmap, sec);
1365 struct bitmap *bitmap = mddev->bitmap;
1368 if (!bitmap) /* there was no bitmap */
1374 sleep = bitmap->daemon_sleep;
1375 bitmap->daemon_sleep = 0;
1376 bitmap_daemon_work(bitmap);
1377 bitmap_daemon_work(bitmap);
1378 bitmap_daemon_work(bitmap);
1379 bitmap->daemon_sleep = sleep;
1380 bitmap_update_sb(bitmap);
1386 static void bitmap_free(struct bitmap *bitmap)
1391 if (!bitmap) /* there was no bitmap */
1394 /* release the bitmap file and kill the daemon */
1395 bitmap_file_put(bitmap);
1397 bp = bitmap->bp;
1398 pages = bitmap->pages;
1407 kfree(bitmap);
1411 struct bitmap *bitmap = mddev->bitmap;
1413 if (!bitmap) /* there was no bitmap */
1416 mddev->bitmap = NULL; /* disconnect from the md device */
1420 bitmap_free(bitmap);
1424 * initialize the bitmap structure
1429 struct bitmap *bitmap;
1439 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */
1444 bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
1445 if (!bitmap)
1448 spin_lock_init(&bitmap->lock);
1449 atomic_set(&bitmap->pending_writes, 0);
1450 init_waitqueue_head(&bitmap->write_wait);
1451 init_waitqueue_head(&bitmap->overflow_wait);
1453 bitmap->mddev = mddev;
1455 bitmap->file = file;
1456 bitmap->offset = mddev->bitmap_offset;
1464 /* read superblock from bitmap file (this sets bitmap->chunksize) */
1465 err = bitmap_read_sb(bitmap);
1469 bitmap->chunkshift = ffz(~bitmap->chunksize);
1472 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) /
1473 CHUNK_BLOCK_RATIO(bitmap);
1478 bitmap->chunks = chunks;
1479 bitmap->pages = pages;
1480 bitmap->missing_pages = pages;
1481 bitmap->counter_bits = COUNTER_BITS;
1483 bitmap->syncchunk = ~0UL;
1486 bitmap->bp = NULL;
1488 bitmap->bp = kzalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL);
1491 if (!bitmap->bp)
1495 * bitmap from the on-disk bitmap */
1498 || bitmap->events_cleared == mddev->events)
1501 err = bitmap_init_from_disk(bitmap, start);
1506 printk(KERN_INFO "created bitmap (%lu pages) for device %s\n",
1507 pages, bmname(bitmap));
1509 mddev->bitmap = bitmap;
1511 mddev->thread->timeout = bitmap->daemon_sleep * HZ;
1513 return bitmap_update_sb(bitmap);
1516 bitmap_free(bitmap);
1520 /* the bitmap API -- for raid personalities */