diff options
author | NeilBrown <neilb@suse.de> | 2006-01-06 03:20:34 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 11:34:06 -0500 |
commit | ea03aff93b4117c2ddfb91b34b44a44e19df24cd (patch) | |
tree | c3ecdc4b9ba311456c38133e3edb3acc8868682a | |
parent | fccddba060f2b4916a30aa27acc3d03b01bb981e (diff) |
[PATCH] md: convert various kmap calls to kmap_atomic
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/md/bitmap.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index c3faa6a43de1..519b1bf7a09a 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -406,11 +406,11 @@ int bitmap_update_sb(struct bitmap *bitmap) | |||
406 | return 0; | 406 | return 0; |
407 | } | 407 | } |
408 | spin_unlock_irqrestore(&bitmap->lock, flags); | 408 | spin_unlock_irqrestore(&bitmap->lock, flags); |
409 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 409 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
410 | sb->events = cpu_to_le64(bitmap->mddev->events); | 410 | sb->events = cpu_to_le64(bitmap->mddev->events); |
411 | if (!bitmap->mddev->degraded) | 411 | if (!bitmap->mddev->degraded) |
412 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); | 412 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); |
413 | kunmap(bitmap->sb_page); | 413 | kunmap_atomic(sb, KM_USER0); |
414 | return write_page(bitmap, bitmap->sb_page, 1); | 414 | return write_page(bitmap, bitmap->sb_page, 1); |
415 | } | 415 | } |
416 | 416 | ||
@@ -421,7 +421,7 @@ void bitmap_print_sb(struct bitmap *bitmap) | |||
421 | 421 | ||
422 | if (!bitmap || !bitmap->sb_page) | 422 | if (!bitmap || !bitmap->sb_page) |
423 | return; | 423 | return; |
424 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 424 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
425 | printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); | 425 | printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); |
426 | printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); | 426 | printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); |
427 | printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); | 427 | printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); |
@@ -440,7 +440,7 @@ void bitmap_print_sb(struct bitmap *bitmap) | |||
440 | printk(KERN_DEBUG " sync size: %llu KB\n", | 440 | printk(KERN_DEBUG " sync size: %llu KB\n", |
441 | (unsigned long long)le64_to_cpu(sb->sync_size)/2); | 441 | (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)); | 442 | printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); |
443 | kunmap(bitmap->sb_page); | 443 | kunmap_atomic(sb, KM_USER0); |
444 | } | 444 | } |
445 | 445 | ||
446 | /* read the superblock from the bitmap file and initialize some bitmap fields */ | 446 | /* read the superblock from the bitmap file and initialize some bitmap fields */ |
@@ -466,7 +466,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
466 | return err; | 466 | return err; |
467 | } | 467 | } |
468 | 468 | ||
469 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 469 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
470 | 470 | ||
471 | if (bytes_read < sizeof(*sb)) { /* short read */ | 471 | if (bytes_read < sizeof(*sb)) { /* short read */ |
472 | printk(KERN_INFO "%s: bitmap file superblock truncated\n", | 472 | printk(KERN_INFO "%s: bitmap file superblock truncated\n", |
@@ -535,7 +535,7 @@ success: | |||
535 | bitmap->events_cleared = bitmap->mddev->events; | 535 | bitmap->events_cleared = bitmap->mddev->events; |
536 | err = 0; | 536 | err = 0; |
537 | out: | 537 | out: |
538 | kunmap(bitmap->sb_page); | 538 | kunmap_atomic(sb, KM_USER0); |
539 | if (err) | 539 | if (err) |
540 | bitmap_print_sb(bitmap); | 540 | bitmap_print_sb(bitmap); |
541 | return err; | 541 | return err; |
@@ -560,7 +560,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, | |||
560 | } | 560 | } |
561 | get_page(bitmap->sb_page); | 561 | get_page(bitmap->sb_page); |
562 | spin_unlock_irqrestore(&bitmap->lock, flags); | 562 | spin_unlock_irqrestore(&bitmap->lock, flags); |
563 | sb = (bitmap_super_t *)kmap(bitmap->sb_page); | 563 | sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); |
564 | switch (op) { | 564 | switch (op) { |
565 | case MASK_SET: sb->state |= bits; | 565 | case MASK_SET: sb->state |= bits; |
566 | break; | 566 | break; |
@@ -568,7 +568,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, | |||
568 | break; | 568 | break; |
569 | default: BUG(); | 569 | default: BUG(); |
570 | } | 570 | } |
571 | kunmap(bitmap->sb_page); | 571 | kunmap_atomic(sb, KM_USER0); |
572 | put_page(bitmap->sb_page); | 572 | put_page(bitmap->sb_page); |
573 | } | 573 | } |
574 | 574 | ||
@@ -854,6 +854,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
854 | unsigned long bytes, offset, dummy; | 854 | unsigned long bytes, offset, dummy; |
855 | int outofdate; | 855 | int outofdate; |
856 | int ret = -ENOSPC; | 856 | int ret = -ENOSPC; |
857 | void *paddr; | ||
857 | 858 | ||
858 | chunks = bitmap->chunks; | 859 | chunks = bitmap->chunks; |
859 | file = bitmap->file; | 860 | file = bitmap->file; |
@@ -899,8 +900,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
899 | bit = file_page_offset(i); | 900 | bit = file_page_offset(i); |
900 | if (index != oldindex) { /* this is a new page, read it in */ | 901 | if (index != oldindex) { /* this is a new page, read it in */ |
901 | /* unmap the old page, we're done with it */ | 902 | /* unmap the old page, we're done with it */ |
902 | if (oldpage != NULL) | ||
903 | kunmap(oldpage); | ||
904 | if (index == 0) { | 903 | if (index == 0) { |
905 | /* | 904 | /* |
906 | * if we're here then the superblock page | 905 | * if we're here then the superblock page |
@@ -923,18 +922,18 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
923 | 922 | ||
924 | oldindex = index; | 923 | oldindex = index; |
925 | oldpage = page; | 924 | oldpage = page; |
926 | kmap(page); | ||
927 | 925 | ||
928 | if (outofdate) { | 926 | if (outofdate) { |
929 | /* | 927 | /* |
930 | * if bitmap is out of date, dirty the | 928 | * if bitmap is out of date, dirty the |
931 | * whole page and write it out | 929 | * whole page and write it out |
932 | */ | 930 | */ |
933 | memset(page_address(page) + offset, 0xff, | 931 | paddr = kmap_atomic(page, KM_USER0); |
932 | memset(paddr + offset, 0xff, | ||
934 | PAGE_SIZE - offset); | 933 | PAGE_SIZE - offset); |
934 | kunmap_atomic(paddr, KM_USER0); | ||
935 | ret = write_page(bitmap, page, 1); | 935 | ret = write_page(bitmap, page, 1); |
936 | if (ret) { | 936 | if (ret) { |
937 | kunmap(page); | ||
938 | /* release, page not in filemap yet */ | 937 | /* release, page not in filemap yet */ |
939 | put_page(page); | 938 | put_page(page); |
940 | goto out; | 939 | goto out; |
@@ -943,10 +942,12 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
943 | 942 | ||
944 | bitmap->filemap[bitmap->file_pages++] = page; | 943 | bitmap->filemap[bitmap->file_pages++] = page; |
945 | } | 944 | } |
945 | paddr = kmap_atomic(page, KM_USER0); | ||
946 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 946 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
947 | b = test_bit(bit, page_address(page)); | 947 | b = test_bit(bit, paddr); |
948 | else | 948 | else |
949 | b = ext2_test_bit(bit, page_address(page)); | 949 | b = ext2_test_bit(bit, paddr); |
950 | kunmap_atomic(paddr, KM_USER0); | ||
950 | if (b) { | 951 | if (b) { |
951 | /* if the disk bit is set, set the memory bit */ | 952 | /* if the disk bit is set, set the memory bit */ |
952 | bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), | 953 | bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), |
@@ -961,9 +962,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
961 | ret = 0; | 962 | ret = 0; |
962 | bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); | 963 | bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); |
963 | 964 | ||
964 | if (page) /* unmap the last page */ | ||
965 | kunmap(page); | ||
966 | |||
967 | if (bit_cnt) { /* Kick recovery if any bits were set */ | 965 | if (bit_cnt) { /* Kick recovery if any bits were set */ |
968 | set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); | 966 | set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); |
969 | md_wakeup_thread(bitmap->mddev->thread); | 967 | md_wakeup_thread(bitmap->mddev->thread); |
@@ -1019,6 +1017,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1019 | int err = 0; | 1017 | int err = 0; |
1020 | int blocks; | 1018 | int blocks; |
1021 | int attr; | 1019 | int attr; |
1020 | void *paddr; | ||
1022 | 1021 | ||
1023 | if (bitmap == NULL) | 1022 | if (bitmap == NULL) |
1024 | return 0; | 1023 | return 0; |
@@ -1075,14 +1074,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1075 | set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1074 | set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |
1076 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1075 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1077 | } | 1076 | } |
1078 | kunmap(lastpage); | ||
1079 | put_page(lastpage); | 1077 | put_page(lastpage); |
1080 | if (err) | 1078 | if (err) |
1081 | bitmap_file_kick(bitmap); | 1079 | bitmap_file_kick(bitmap); |
1082 | } else | 1080 | } else |
1083 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1081 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1084 | lastpage = page; | 1082 | lastpage = page; |
1085 | kmap(page); | ||
1086 | /* | 1083 | /* |
1087 | printk("bitmap clean at page %lu\n", j); | 1084 | printk("bitmap clean at page %lu\n", j); |
1088 | */ | 1085 | */ |
@@ -1105,10 +1102,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1105 | -1); | 1102 | -1); |
1106 | 1103 | ||
1107 | /* clear the bit */ | 1104 | /* clear the bit */ |
1105 | paddr = kmap_atomic(page, KM_USER0); | ||
1108 | if (bitmap->flags & BITMAP_HOSTENDIAN) | 1106 | if (bitmap->flags & BITMAP_HOSTENDIAN) |
1109 | clear_bit(file_page_offset(j), page_address(page)); | 1107 | clear_bit(file_page_offset(j), paddr); |
1110 | else | 1108 | else |
1111 | ext2_clear_bit(file_page_offset(j), page_address(page)); | 1109 | ext2_clear_bit(file_page_offset(j), paddr); |
1110 | kunmap_atomic(paddr, KM_USER0); | ||
1112 | } | 1111 | } |
1113 | } | 1112 | } |
1114 | spin_unlock_irqrestore(&bitmap->lock, flags); | 1113 | spin_unlock_irqrestore(&bitmap->lock, flags); |
@@ -1116,7 +1115,6 @@ int bitmap_daemon_work(struct bitmap *bitmap) | |||
1116 | 1115 | ||
1117 | /* now sync the final page */ | 1116 | /* now sync the final page */ |
1118 | if (lastpage != NULL) { | 1117 | if (lastpage != NULL) { |
1119 | kunmap(lastpage); | ||
1120 | spin_lock_irqsave(&bitmap->lock, flags); | 1118 | spin_lock_irqsave(&bitmap->lock, flags); |
1121 | if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { | 1119 | if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { |
1122 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); | 1120 | clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); |