diff options
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 114 |
1 files changed, 56 insertions, 58 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 252d55df9642..76a189ceb529 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -315,6 +315,8 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait) | |||
315 | if (bitmap->file == NULL) | 315 | if (bitmap->file == NULL) |
316 | return write_sb_page(bitmap->mddev, bitmap->offset, page, wait); | 316 | return write_sb_page(bitmap->mddev, bitmap->offset, page, wait); |
317 | 317 | ||
318 | flush_dcache_page(page); /* make sure visible to anyone reading the file */ | ||
319 | |||
318 | if (wait) | 320 | if (wait) |
319 | lock_page(page); | 321 | lock_page(page); |
320 | else { | 322 | else { |
@@ -341,7 +343,7 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait) | |||
341 | /* add to list to be waited for by daemon */ | 343 | /* add to list to be waited for by daemon */ |
342 | struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO); | 344 | struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO); |
343 | item->page = page; | 345 | item->page = page; |
344 | page_cache_get(page); | 346 | get_page(page); |
345 | spin_lock(&bitmap->write_lock); | 347 | spin_lock(&bitmap->write_lock); |
346 | list_add(&item->list, &bitmap->complete_pages); | 348 | list_add(&item->list, &bitmap->complete_pages); |
347 | spin_unlock(&bitmap->write_lock); | 349 | spin_unlock(&bitmap->write_lock); |
@@ -357,10 +359,10 @@ static struct page *read_page(struct file *file, unsigned long index, | |||
357 | struct inode *inode = file->f_mapping->host; | 359 | struct inode *inode = file->f_mapping->host; |
358 | struct page *page = NULL; | 360 | struct page *page = NULL; |
359 | loff_t isize = i_size_read(inode); | 361 | loff_t isize = i_size_read(inode); |
360 | unsigned long end_index = isize >> PAGE_CACHE_SHIFT; | 362 | unsigned long end_index = isize >> PAGE_SHIFT; |
361 | 363 | ||
362 | PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_CACHE_SIZE, | 364 | PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_SIZE, |
363 | (unsigned long long)index << PAGE_CACHE_SHIFT); | 365 | (unsigned long long)index << PAGE_SHIFT); |
364 | 366 | ||
365 | page = read_cache_page(inode->i_mapping, index, | 367 | page = read_cache_page(inode->i_mapping, index, |
366 | (filler_t *)inode->i_mapping->a_ops->readpage, file); | 368 | (filler_t *)inode->i_mapping->a_ops->readpage, file); |
@@ -368,7 +370,7 @@ static struct page *read_page(struct file *file, unsigned long index, | |||
368 | goto out; | 370 | goto out; |
369 | wait_on_page_locked(page); | 371 | wait_on_page_locked(page); |
370 | if (!PageUptodate(page) || PageError(page)) { | 372 | if (!PageUptodate(page) || PageError(page)) { |
371 | page_cache_release(page); | 373 | put_page(page); |
372 | page = ERR_PTR(-EIO); | 374 | page = ERR_PTR(-EIO); |
373 | goto out; | 375 | goto out; |
374 | } | 376 | } |
@@ -376,14 +378,14 @@ static struct page *read_page(struct file *file, unsigned long index, | |||
376 | if (index > end_index) /* we have read beyond EOF */ | 378 | if (index > end_index) /* we have read beyond EOF */ |
377 | *bytes_read = 0; | 379 | *bytes_read = 0; |
378 | else if (index == end_index) /* possible short read */ | 380 | else if (index == end_index) /* possible short read */ |
379 | *bytes_read = isize & ~PAGE_CACHE_MASK; | 381 | *bytes_read = isize & ~PAGE_MASK; |
380 | else | 382 | else |
381 | *bytes_read = PAGE_CACHE_SIZE; /* got a full page */ | 383 | *bytes_read = PAGE_SIZE; /* got a full page */ |
382 | out: | 384 | out: |
383 | if (IS_ERR(page)) | 385 | if (IS_ERR(page)) |
384 | printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n", | 386 | printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n", |
385 | (int)PAGE_CACHE_SIZE, | 387 | (int)PAGE_SIZE, |
386 | (unsigned long long)index << PAGE_CACHE_SHIFT, | 388 | (unsigned long long)index << PAGE_SHIFT, |
387 | PTR_ERR(page)); | 389 | PTR_ERR(page)); |
388 | return page; | 390 | return page; |
389 | } | 391 | } |
@@ -406,11 +408,11 @@ int bitmap_update_sb(struct bitmap *bitmap) | |||
406 | return 0; | 408 | return 0; |
407 | } | 409 | } |
408 | spin_unlock_irqrestore(&bitmap->lock, flags); | 410 | spin_unlock_irqrestore(&bitmap->lock, flags); |
409 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 411 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
410 | sb->events = cpu_to_le64(bitmap->mddev->events); | 412 | sb->events = cpu_to_le64(bitmap->mddev->events); |
411 | if (!bitmap->mddev->degraded) | 413 | if (!bitmap->mddev->degraded) |
412 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); | 414 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); |
413 | kunmap(bitmap->sb_page); | 415 | kunmap_atomic(sb, KM_USER0); |
414 | return write_page(bitmap, bitmap->sb_page, 1); | 416 | return write_page(bitmap, bitmap->sb_page, 1); |
415 | } | 417 | } |
416 | 418 | ||
@@ -421,7 +423,7 @@ void bitmap_print_sb(struct bitmap *bitmap) | |||
421 | 423 | ||
422 | if (!bitmap || !bitmap->sb_page) | 424 | if (!bitmap || !bitmap->sb_page) |
423 | return; | 425 | return; |
424 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 426 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
425 | printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); | 427 | printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); |
426 | printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); | 428 | printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); |
427 | printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); | 429 | printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); |
@@ -440,7 +442,7 @@ void bitmap_print_sb(struct bitmap *bitmap) | |||
440 | printk(KERN_DEBUG " sync size: %llu KB\n", | 442 | printk(KERN_DEBUG " sync size: %llu KB\n", |
441 | (unsigned long long)le64_to_cpu(sb->sync_size)/2); | 443 | (unsigned long long)le64_to_cpu(sb->sync_size)/2); |
442 | printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); | 444 | printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); |
443 | kunmap(bitmap->sb_page); | 445 | kunmap_atomic(sb, KM_USER0); |
444 | } | 446 | } |
445 | 447 | ||
446 | /* read the superblock from the bitmap file and initialize some bitmap fields */ | 448 | /* read the superblock from the bitmap file and initialize some bitmap fields */ |
@@ -466,7 +468,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
466 | return err; | 468 | return err; |
467 | } | 469 | } |
468 | 470 | ||
469 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 471 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
470 | 472 | ||
471 | if (bytes_read < sizeof(*sb)) { /* short read */ | 473 | if (bytes_read < sizeof(*sb)) { /* short read */ |
472 | printk(KERN_INFO "%s: bitmap file superblock truncated\n", | 474 | printk(KERN_INFO "%s: bitmap file superblock truncated\n", |
@@ -485,12 +487,12 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
485 | else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO || | 487 | else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO || |
486 | le32_to_cpu(sb->version) > BITMAP_MAJOR_HI) | 488 | le32_to_cpu(sb->version) > BITMAP_MAJOR_HI) |
487 | reason = "unrecognized superblock version"; | 489 | reason = "unrecognized superblock version"; |
488 | else if (chunksize < 512 || chunksize > (1024 * 1024 * 4)) | 490 | else if (chunksize < PAGE_SIZE) |
489 | reason = "bitmap chunksize out of range (512B - 4MB)"; | 491 | reason = "bitmap chunksize too small"; |
490 | else if ((1 << ffz(~chunksize)) != chunksize) | 492 | else if ((1 << ffz(~chunksize)) != chunksize) |
491 | reason = "bitmap chunksize not a power of 2"; | 493 | reason = "bitmap chunksize not a power of 2"; |
492 | else if (daemon_sleep < 1 || daemon_sleep > 15) | 494 | else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT / HZ) |
493 | reason = "daemon sleep period out of range (1-15s)"; | 495 | reason = "daemon sleep period out of range"; |
494 | else if (write_behind > COUNTER_MAX) | 496 | else if (write_behind > COUNTER_MAX) |
495 | reason = "write-behind limit out of range (0 - 16383)"; | 497 | reason = "write-behind limit out of range (0 - 16383)"; |
496 | if (reason) { | 498 | if (reason) { |
@@ -535,7 +537,7 @@ success: | |||
535 | bitmap->events_cleared = bitmap->mddev->events; | 537 | bitmap->events_cleared = bitmap->mddev->events; |
536 | err = 0; | 538 | err = 0; |
537 | out: | 539 | out: |
538 | kunmap(bitmap->sb_page); | 540 | kunmap_atomic(sb, KM_USER0); |
539 | if (err) | 541 | if (err) |
540 | bitmap_print_sb(bitmap); | 542 | bitmap_print_sb(bitmap); |
541 | return err; | 543 | return err; |
@@ -558,9 +560,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, | |||
558 | spin_unlock_irqrestore(&bitmap->lock, flags); | 560 | spin_unlock_irqrestore(&bitmap->lock, flags); |
559 | return; | 561 | return; |
560 | } | 562 | } |
561 | page_cache_get(bitmap->sb_page); | 563 | get_page(bitmap->sb_page); |
562 | spin_unlock_irqrestore(&bitmap->lock, flags); | 564 | spin_unlock_irqrestore(&bitmap->lock, flags); |
563 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 565 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
564 | switch (op) { | 566 | switch (op) { |
565 | case MASK_SET: sb->state |= bits; | 567 | case MASK_SET: sb->state |= bits; |
566 | break; | 568 | break; |
@@ -568,8 +570,8 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, | |||
568 | break; | 570 | break; |
569 | default: BUG(); | 571 | default: BUG(); |
570 | } | 572 | } |
571 | kunmap(bitmap->sb_page); | 573 | kunmap_atomic(sb, KM_USER0); |
572 | page_cache_release(bitmap->sb_page); | 574 | put_page(bitmap->sb_page); |
573 | } | 575 | } |
574 | 576 | ||
575 | /* | 577 | /* |
@@ -622,12 +624,11 @@ static void bitmap_file_unmap(struct bitmap *bitmap) | |||
622 | 624 | ||
623 | while (pages--) | 625 | while (pages--) |
624 | if (map[pages]->index != 0) /* 0 is sb_page, release it below */ | 626 | if (map[pages]->index != 0) /* 0 is sb_page, release it below */ |
625 | page_cache_release(map[pages]); | 627 | put_page(map[pages]); |
626 | kfree(map); | 628 | kfree(map); |
627 | kfree(attr); | 629 | kfree(attr); |
628 | 630 | ||
629 | if (sb_page) | 631 | safe_put_page(sb_page); |
630 | page_cache_release(sb_page); | ||
631 | } | 632 | } |
632 | 633 | ||
633 | static void bitmap_stop_daemon(struct bitmap *bitmap); | 634 | static void bitmap_stop_daemon(struct bitmap *bitmap); |
@@ -654,7 +655,7 @@ static void drain_write_queues(struct bitmap *bitmap) | |||
654 | 655 | ||
655 | while ((item = dequeue_page(bitmap))) { | 656 | while ((item = dequeue_page(bitmap))) { |
656 | /* don't bother to wait */ | 657 | /* don't bother to wait */ |
657 | page_cache_release(item->page); | 658 | put_page(item->page); |
658 | mempool_free(item, bitmap->write_pool); | 659 | mempool_free(item, bitmap->write_pool); |
659 | } | 660 | } |
660 | 661 | ||
@@ -763,7 +764,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) | |||
763 | 764 | ||
764 | /* make sure the page stays cached until it gets written out */ | 765 | /* make sure the page stays cached until it gets written out */ |
765 | if (! (get_page_attr(bitmap, page) & BITMAP_PAGE_DIRTY)) | 766 | if (! (get_page_attr(bitmap, page) & BITMAP_PAGE_DIRTY)) |
766 | page_cache_get(page); | 767 | get_page(page); |
767 | 768 | ||
768 | /* set the bit */ | 769 | /* set the bit */ |
769 | kaddr = kmap_atomic(page, KM_USER0); | 770 | kaddr = kmap_atomic(page, KM_USER0); |
@@ -854,6 +855,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
854 | unsigned long bytes, offset, dummy; | 855 | unsigned long bytes, offset, dummy; |
855 | int outofdate; | 856 | int outofdate; |
856 | int ret = -ENOSPC; | 857 | int ret = -ENOSPC; |
858 | void *paddr; | ||
857 | 859 | ||
858 | chunks = bitmap->chunks; | 860 | chunks = bitmap->chunks; |
859 | file = bitmap->file; | 861 | file = bitmap->file; |
@@ -887,12 +889,10 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
887 | if (!bitmap->filemap) | 889 | if (!bitmap->filemap) |
888 | goto out; | 890 | goto out; |
889 | 891 | ||
890 | bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); | 892 | bitmap->filemap_attr = kzalloc(sizeof(long) * num_pages, GFP_KERNEL); |
891 | if (!bitmap->filemap_attr) | 893 | if (!bitmap->filemap_attr) |
892 | goto out; | 894 | goto out; |
893 | 895 | ||
894 | memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages); | ||
895 | |||
896 | oldindex = ~0L; | 896 | oldindex = ~0L; |
897 | 897 | ||
898 | for (i = 0; i < chunks; i++) { | 898 | for (i = 0; i < chunks; i++) { |
@@ -901,8 +901,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
901 | bit = file_page_offset(i); | 901 | bit = file_page_offset(i); |
902 | if (index != oldindex) { /* this is a new page, read it in */ | 902 | if (index != oldindex) { /* this is a new page, read it in */ |
903 | /* unmap the old page, we're done with it */ | 903 | /* unmap the old page, we're done with it */ |
904 | if (oldpage != NULL) | ||
905 | kunmap(oldpage); | ||
906 | if (index == 0) { | 904 | if (index == 0) { |
907 | /* | 905 | /* |
908 | * if we're here then the superblock page | 906 | * if we're here then the superblock page |
@@ -925,30 +923,32 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
925 | 923 | ||
926 | oldindex = index; | 924 | oldindex = index; |
927 | oldpage = page; | 925 | oldpage = page; |
928 | kmap(page); | ||
929 | 926 | ||
930 | if (outofdate) { | 927 | if (outofdate) { |
931 | /* | 928 | /* |
932 | * if bitmap is out of date, dirty the | 929 | * if bitmap is out of date, dirty the |
933 | * whole page and write it out | 930 | * whole page and write it out |
934 | */ | 931 | */ |
935 | memset(page_address(page) + offset, 0xff, | 932 | paddr = kmap_atomic(page, KM_USER0); |
933 | memset(paddr + offset, 0xff, | ||
936 | PAGE_SIZE - offset); | 934 | PAGE_SIZE - offset); |
935 | kunmap_atomic(paddr, KM_USER0); | ||
937 | ret = write_page(bitmap, page, 1); | 936 | ret = write_page(bitmap, page, 1); |
938 | if (ret) { | 937 | if (ret) { |
939 | kunmap(page); | ||
940 | /* release, page not in filemap yet */ | 938 | /* release, page not in filemap yet */ |
941 | page_cache_release(page); | 939 | put_page(page); |
942 | goto out; | 940 | goto out; |
943 | } | 941 | } |
944 | } | 942 | } |
945 | 943 | ||
946 | bitmap->filemap[bitmap->file_pages++] = page; | 944 | bitmap->filemap[bitmap->file_pages++] = page; |
947 | } | 945 | } |
946 | paddr = kmap_atomic(page, KM_USER0); | ||
948 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 947 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
949 | b = test_bit(bit, page_address(page)); | 948 | b = test_bit(bit, paddr); |
950 | else | 949 | else |
951 | b = ext2_test_bit(bit, page_address(page)); | 950 | b = ext2_test_bit(bit, paddr); |
951 | kunmap_atomic(paddr, KM_USER0); | ||
952 | if (b) { | 952 | if (b) { |
953 | /* if the disk bit is set, set the memory bit */ | 953 | /* if the disk bit is set, set the memory bit */ |
954 | bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), | 954 | bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), |
@@ -963,9 +963,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
963 | ret = 0; | 963 | ret = 0; |
964 | bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); | 964 | bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); |
965 | 965 | ||
966 | if (page) /* unmap the last page */ | ||
967 | kunmap(page); | ||
968 | |||
969 | if (bit_cnt) { /* Kick recovery if any bits were set */ | 966 | if (bit_cnt) { /* Kick recovery if any bits were set */ |
970 | set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); | 967 | set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); |
971 | md_wakeup_thread(bitmap->mddev->thread); | 968 | md_wakeup_thread(bitmap->mddev->thread); |
@@ -1021,6 +1018,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1021 | int err = 0; | 1018 | int err = 0; |
1022 | int blocks; | 1019 | int blocks; |
1023 | int attr; | 1020 | int attr; |
1021 | void *paddr; | ||
1024 | 1022 | ||
1025 | if (bitmap == NULL) | 1023 | if (bitmap == NULL) |
1026 | return 0; | 1024 | return 0; |
@@ -1043,7 +1041,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1043 | /* skip this page unless it's marked as needing cleaning */ | 1041 | /* skip this page unless it's marked as needing cleaning */ |
1044 | if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) { | 1042 | if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) { |
1045 | if (attr & BITMAP_PAGE_NEEDWRITE) { | 1043 | if (attr & BITMAP_PAGE_NEEDWRITE) { |
1046 | page_cache_get(page); | 1044 | get_page(page); |
1047 | clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); | 1045 | clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); |
1048 | } | 1046 | } |
1049 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1047 | spin_unlock_irqrestore(&bitmap->lock, flags); |
@@ -1057,13 +1055,13 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1057 | default: | 1055 | default: |
1058 | bitmap_file_kick(bitmap); | 1056 | bitmap_file_kick(bitmap); |
1059 | } | 1057 | } |
1060 | page_cache_release(page); | 1058 | put_page(page); |
1061 | } | 1059 | } |
1062 | continue; | 1060 | continue; |
1063 | } | 1061 | } |
1064 | 1062 | ||
1065 | /* grab the new page, sync and release the old */ | 1063 | /* grab the new page, sync and release the old */ |
1066 | page_cache_get(page); | 1064 | get_page(page); |
1067 | if (lastpage != NULL) { | 1065 | if (lastpage != NULL) { |
1068 | if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) { | 1066 | if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) { |
1069 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1067 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |
@@ -1077,14 +1075,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1077 | set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1075 | set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |
1078 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1076 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1079 | } | 1077 | } |
1080 | kunmap(lastpage); | 1078 | put_page(lastpage); |
1081 | page_cache_release(lastpage); | ||
1082 | if (err) | 1079 | if (err) |
1083 | bitmap_file_kick(bitmap); | 1080 | bitmap_file_kick(bitmap); |
1084 | } else | 1081 | } else |
1085 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1082 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1086 | lastpage = page; | 1083 | lastpage = page; |
1087 | kmap(page); | ||
1088 | /* | 1084 | /* |
1089 | printk("bitmap clean at page %lu\n", j); | 1085 | printk("bitmap clean at page %lu\n", j); |
1090 | */ | 1086 | */ |
@@ -1107,10 +1103,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1107 | -1); | 1103 | -1); |
1108 | 1104 | ||
1109 | /* clear the bit */ | 1105 | /* clear the bit */ |
1106 | paddr = kmap_atomic(page, KM_USER0); | ||
1110 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 1107 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
1111 | clear_bit(file_page_offset(j), page_address(page)); | 1108 | clear_bit(file_page_offset(j), paddr); |
1112 | else | 1109 | else |
1113 | ext2_clear_bit(file_page_offset(j), page_address(page)); | 1110 | ext2_clear_bit(file_page_offset(j), paddr); |
1111 | kunmap_atomic(paddr, KM_USER0); | ||
1114 | } | 1112 | } |
1115 | } | 1113 | } |
1116 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1114 | spin_unlock_irqrestore(&bitmap->lock, flags); |
@@ -1118,7 +1116,6 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1118 | 1116 | ||
1119 | /* now sync the final page */ | 1117 | /* now sync the final page */ |
1120 | if (lastpage != NULL) { | 1118 | if (lastpage != NULL) { |
1121 | kunmap(lastpage); | ||
1122 | spin_lock_irqsave(&bitmap->lock, flags); | 1119 | spin_lock_irqsave(&bitmap->lock, flags); |
1123 | if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { | 1120 | if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { |
1124 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1121 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |
@@ -1133,7 +1130,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1133 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1130 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1134 | } | 1131 | } |
1135 | 1132 | ||
1136 | page_cache_release(lastpage); | 1133 | put_page(lastpage); |
1137 | } | 1134 | } |
1138 | 1135 | ||
1139 | return err; | 1136 | return err; |
@@ -1184,7 +1181,7 @@ static void bitmap_writeback_daemon(mddev_t *mddev) | |||
1184 | PRINTK("finished page writeback: %p\n", page); | 1181 | PRINTK("finished page writeback: %p\n", page); |
1185 | 1182 | ||
1186 | err = PageError(page); | 1183 | err = PageError(page); |
1187 | page_cache_release(page); | 1184 | put_page(page); |
1188 | if (err) { | 1185 | if (err) { |
1189 | printk(KERN_WARNING "%s: bitmap file writeback " | 1186 | printk(KERN_WARNING "%s: bitmap file writeback " |
1190 | "failed (page %lu): %d\n", | 1187 | "failed (page %lu): %d\n", |
@@ -1530,6 +1527,8 @@ void bitmap_destroy(mddev_t *mddev) | |||
1530 | return; | 1527 | return; |
1531 | 1528 | ||
1532 | mddev->bitmap = NULL; /* disconnect from the md device */ | 1529 | mddev->bitmap = NULL; /* disconnect from the md device */ |
1530 | if (mddev->thread) | ||
1531 | mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; | ||
1533 | 1532 | ||
1534 | bitmap_free(bitmap); | 1533 | bitmap_free(bitmap); |
1535 | } | 1534 | } |
@@ -1555,12 +1554,10 @@ int bitmap_create(mddev_t *mddev) | |||
1555 | 1554 | ||
1556 | BUG_ON(file && mddev->bitmap_offset); | 1555 | BUG_ON(file && mddev->bitmap_offset); |
1557 | 1556 | ||
1558 | bitmap = kmalloc(sizeof(*bitmap), GFP_KERNEL); | 1557 | bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL); |
1559 | if (!bitmap) | 1558 | if (!bitmap) |
1560 | return -ENOMEM; | 1559 | return -ENOMEM; |
1561 | 1560 | ||
1562 | memset(bitmap, 0, sizeof(*bitmap)); | ||
1563 | |||
1564 | spin_lock_init(&bitmap->lock); | 1561 | spin_lock_init(&bitmap->lock); |
1565 | bitmap->mddev = mddev; | 1562 | bitmap->mddev = mddev; |
1566 | 1563 | ||
@@ -1601,12 +1598,11 @@ int bitmap_create(mddev_t *mddev) | |||
1601 | #ifdef INJECT_FATAL_FAULT_1 | 1598 | #ifdef INJECT_FATAL_FAULT_1 |
1602 | bitmap->bp = NULL; | 1599 | bitmap->bp = NULL; |
1603 | #else | 1600 | #else |
1604 | bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); | 1601 | bitmap->bp = kzalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); |
1605 | #endif | 1602 | #endif |
1606 | err = -ENOMEM; | 1603 | err = -ENOMEM; |
1607 | if (!bitmap->bp) | 1604 | if (!bitmap->bp) |
1608 | goto error; | 1605 | goto error; |
1609 | memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp)); | ||
1610 | 1606 | ||
1611 | bitmap->flags |= BITMAP_ACTIVE; | 1607 | bitmap->flags |= BITMAP_ACTIVE; |
1612 | 1608 | ||
@@ -1636,6 +1632,8 @@ int bitmap_create(mddev_t *mddev) | |||
1636 | 1632 | ||
1637 | if (IS_ERR(bitmap->writeback_daemon)) | 1633 | if (IS_ERR(bitmap->writeback_daemon)) |
1638 | return PTR_ERR(bitmap->writeback_daemon); | 1634 | return PTR_ERR(bitmap->writeback_daemon); |
1635 | mddev->thread->timeout = bitmap->daemon_sleep * HZ; | ||
1636 | |||
1639 | return bitmap_update_sb(bitmap); | 1637 | return bitmap_update_sb(bitmap); |
1640 | 1638 | ||
1641 | error: | 1639 | error: |