Commit ea03aff9 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md: convert various kmap calls to kmap_atomic

Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fccddba0
...@@ -406,11 +406,11 @@ int bitmap_update_sb(struct bitmap *bitmap) ...@@ -406,11 +406,11 @@ int bitmap_update_sb(struct bitmap *bitmap)
return 0; return 0;
} }
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
sb = (bitmap_super_t *)kmap(bitmap->sb_page); sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
sb->events = cpu_to_le64(bitmap->mddev->events); sb->events = cpu_to_le64(bitmap->mddev->events);
if (!bitmap->mddev->degraded) if (!bitmap->mddev->degraded)
sb->events_cleared = cpu_to_le64(bitmap->mddev->events); sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
kunmap(bitmap->sb_page); kunmap_atomic(sb, KM_USER0);
return write_page(bitmap, bitmap->sb_page, 1); return write_page(bitmap, bitmap->sb_page, 1);
} }
...@@ -421,7 +421,7 @@ void bitmap_print_sb(struct bitmap *bitmap) ...@@ -421,7 +421,7 @@ void bitmap_print_sb(struct bitmap *bitmap)
if (!bitmap || !bitmap->sb_page) if (!bitmap || !bitmap->sb_page)
return; return;
sb = (bitmap_super_t *)kmap(bitmap->sb_page); sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap));
printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic));
printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version));
...@@ -440,7 +440,7 @@ void bitmap_print_sb(struct bitmap *bitmap) ...@@ -440,7 +440,7 @@ void bitmap_print_sb(struct bitmap *bitmap)
printk(KERN_DEBUG " sync size: %llu KB\n", printk(KERN_DEBUG " sync size: %llu KB\n",
(unsigned long long)le64_to_cpu(sb->sync_size)/2); (unsigned long long)le64_to_cpu(sb->sync_size)/2);
printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind));
kunmap(bitmap->sb_page); kunmap_atomic(sb, KM_USER0);
} }
/* read the superblock from the bitmap file and initialize some bitmap fields */ /* 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,7 +466,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
return err; return err;
} }
sb = (bitmap_super_t *)kmap(bitmap->sb_page); sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
if (bytes_read < sizeof(*sb)) { /* short read */ if (bytes_read < sizeof(*sb)) { /* short read */
printk(KERN_INFO "%s: bitmap file superblock truncated\n", printk(KERN_INFO "%s: bitmap file superblock truncated\n",
...@@ -535,7 +535,7 @@ success: ...@@ -535,7 +535,7 @@ success:
bitmap->events_cleared = bitmap->mddev->events; bitmap->events_cleared = bitmap->mddev->events;
err = 0; err = 0;
out: out:
kunmap(bitmap->sb_page); kunmap_atomic(sb, KM_USER0);
if (err) if (err)
bitmap_print_sb(bitmap); bitmap_print_sb(bitmap);
return err; return err;
...@@ -560,7 +560,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, ...@@ -560,7 +560,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
} }
get_page(bitmap->sb_page); get_page(bitmap->sb_page);
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
sb = (bitmap_super_t *)kmap(bitmap->sb_page); sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
switch (op) { switch (op) {
case MASK_SET: sb->state |= bits; case MASK_SET: sb->state |= bits;
break; break;
...@@ -568,7 +568,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, ...@@ -568,7 +568,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
break; break;
default: BUG(); default: BUG();
} }
kunmap(bitmap->sb_page); kunmap_atomic(sb, KM_USER0);
put_page(bitmap->sb_page); put_page(bitmap->sb_page);
} }
...@@ -854,6 +854,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) ...@@ -854,6 +854,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
unsigned long bytes, offset, dummy; unsigned long bytes, offset, dummy;
int outofdate; int outofdate;
int ret = -ENOSPC; int ret = -ENOSPC;
void *paddr;
chunks = bitmap->chunks; chunks = bitmap->chunks;
file = bitmap->file; file = bitmap->file;
...@@ -899,8 +900,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) ...@@ -899,8 +900,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
bit = file_page_offset(i); bit = file_page_offset(i);
if (index != oldindex) { /* this is a new page, read it in */ if (index != oldindex) { /* this is a new page, read it in */
/* unmap the old page, we're done with it */ /* unmap the old page, we're done with it */
if (oldpage != NULL)
kunmap(oldpage);
if (index == 0) { if (index == 0) {
/* /*
* if we're here then the superblock page * 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,18 +922,18 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
oldindex = index; oldindex = index;
oldpage = page; oldpage = page;
kmap(page);
if (outofdate) { if (outofdate) {
/* /*
* if bitmap is out of date, dirty the * if bitmap is out of date, dirty the
* whole page and write it out * whole page and write it out
*/ */
memset(page_address(page) + offset, 0xff, paddr = kmap_atomic(page, KM_USER0);
memset(paddr + offset, 0xff,
PAGE_SIZE - offset); PAGE_SIZE - offset);
kunmap_atomic(paddr, KM_USER0);
ret = write_page(bitmap, page, 1); ret = write_page(bitmap, page, 1);
if (ret) { if (ret) {
kunmap(page);
/* release, page not in filemap yet */ /* release, page not in filemap yet */
put_page(page); put_page(page);
goto out; goto out;
...@@ -943,10 +942,12 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) ...@@ -943,10 +942,12 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
bitmap->filemap[bitmap->file_pages++] = page; bitmap->filemap[bitmap->file_pages++] = page;
} }
paddr = kmap_atomic(page, KM_USER0);
if (bitmap->flags & BITMAP_HOSTENDIAN) if (bitmap->flags & BITMAP_HOSTENDIAN)
b = test_bit(bit, page_address(page)); b = test_bit(bit, paddr);
else else
b = ext2_test_bit(bit, page_address(page)); b = ext2_test_bit(bit, paddr);
kunmap_atomic(paddr, KM_USER0);
if (b) { if (b) {
/* if the disk bit is set, set the memory bit */ /* if the disk bit is set, set the memory bit */
bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), 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,9 +962,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
ret = 0; ret = 0;
bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);
if (page) /* unmap the last page */
kunmap(page);
if (bit_cnt) { /* Kick recovery if any bits were set */ if (bit_cnt) { /* Kick recovery if any bits were set */
set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);
md_wakeup_thread(bitmap->mddev->thread); md_wakeup_thread(bitmap->mddev->thread);
...@@ -1019,6 +1017,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) ...@@ -1019,6 +1017,7 @@ int bitmap_daemon_work(struct bitmap *bitmap)
int err = 0; int err = 0;
int blocks; int blocks;
int attr; int attr;
void *paddr;
if (bitmap == NULL) if (bitmap == NULL)
return 0; return 0;
...@@ -1075,14 +1074,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) ...@@ -1075,14 +1074,12 @@ int bitmap_daemon_work(struct bitmap *bitmap)
set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
} }
kunmap(lastpage);
put_page(lastpage); put_page(lastpage);
if (err) if (err)
bitmap_file_kick(bitmap); bitmap_file_kick(bitmap);
} else } else
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
lastpage = page; lastpage = page;
kmap(page);
/* /*
printk("bitmap clean at page %lu\n", j); printk("bitmap clean at page %lu\n", j);
*/ */
...@@ -1105,10 +1102,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) ...@@ -1105,10 +1102,12 @@ int bitmap_daemon_work(struct bitmap *bitmap)
-1); -1);
/* clear the bit */ /* clear the bit */
paddr = kmap_atomic(page, KM_USER0);
if (bitmap->flags & BITMAP_HOSTENDIAN) if (bitmap->flags & BITMAP_HOSTENDIAN)
clear_bit(file_page_offset(j), page_address(page)); clear_bit(file_page_offset(j), paddr);
else else
ext2_clear_bit(file_page_offset(j), page_address(page)); ext2_clear_bit(file_page_offset(j), paddr);
kunmap_atomic(paddr, KM_USER0);
} }
} }
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
...@@ -1116,7 +1115,6 @@ int bitmap_daemon_work(struct bitmap *bitmap) ...@@ -1116,7 +1115,6 @@ int bitmap_daemon_work(struct bitmap *bitmap)
/* now sync the final page */ /* now sync the final page */
if (lastpage != NULL) { if (lastpage != NULL) {
kunmap(lastpage);
spin_lock_irqsave(&bitmap->lock, flags); spin_lock_irqsave(&bitmap->lock, flags);
if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) {
clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment