Commit 9d8e6506 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] kmap_atomic fix in bio_copy()

bio_copy is doing

	vfrom = kmap_atomic(bv->bv_page, KM_BIO_IRQ);
	vto = kmap_atomic(bbv->bv_page, KM_BIO_IRQ);

which, if I understand atomic kmaps, is incorrect.  Both source and
dest will get the same pte.

The patch creates a separate atomic kmap member for the destination and
source of this copy.
parent 8504e479
...@@ -284,8 +284,8 @@ struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy) ...@@ -284,8 +284,8 @@ struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy)
vto = kmap(bbv->bv_page); vto = kmap(bbv->bv_page);
} else { } else {
local_irq_save(flags); local_irq_save(flags);
vfrom = kmap_atomic(bv->bv_page, KM_BIO_IRQ); vfrom = kmap_atomic(bv->bv_page, KM_BIO_SRC_IRQ);
vto = kmap_atomic(bbv->bv_page, KM_BIO_IRQ); vto = kmap_atomic(bbv->bv_page, KM_BIO_DST_IRQ);
} }
memcpy(vto + bbv->bv_offset, vfrom + bv->bv_offset, bv->bv_len); memcpy(vto + bbv->bv_offset, vfrom + bv->bv_offset, bv->bv_len);
...@@ -293,8 +293,8 @@ struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy) ...@@ -293,8 +293,8 @@ struct bio *bio_copy(struct bio *bio, int gfp_mask, int copy)
kunmap(bbv->bv_page); kunmap(bbv->bv_page);
kunmap(bv->bv_page); kunmap(bv->bv_page);
} else { } else {
kunmap_atomic(vto, KM_BIO_IRQ); kunmap_atomic(vto, KM_BIO_DST_IRQ);
kunmap_atomic(vfrom, KM_BIO_IRQ); kunmap_atomic(vfrom, KM_BIO_SRC_IRQ);
local_irq_restore(flags); local_irq_restore(flags);
} }
} }
......
...@@ -61,10 +61,10 @@ static void end_buffer_read_file_async(struct buffer_head *bh, int uptodate) ...@@ -61,10 +61,10 @@ static void end_buffer_read_file_async(struct buffer_head *bh, int uptodate)
if (file_ofs < ni->initialized_size) if (file_ofs < ni->initialized_size)
ofs = ni->initialized_size - file_ofs; ofs = ni->initialized_size - file_ofs;
addr = kmap_atomic(page, KM_BIO_IRQ); addr = kmap_atomic(page, KM_BIO_SRC_IRQ);
memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs); memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs);
flush_dcache_page(page); flush_dcache_page(page);
kunmap_atomic(addr, KM_BIO_IRQ); kunmap_atomic(addr, KM_BIO_SRC_IRQ);
} }
} else } else
SetPageError(page); SetPageError(page);
...@@ -363,10 +363,10 @@ static void end_buffer_read_mftbmp_async(struct buffer_head *bh, int uptodate) ...@@ -363,10 +363,10 @@ static void end_buffer_read_mftbmp_async(struct buffer_head *bh, int uptodate)
if (file_ofs < vol->mftbmp_initialized_size) if (file_ofs < vol->mftbmp_initialized_size)
ofs = vol->mftbmp_initialized_size - file_ofs; ofs = vol->mftbmp_initialized_size - file_ofs;
addr = kmap_atomic(page, KM_BIO_IRQ); addr = kmap_atomic(page, KM_BIO_SRC_IRQ);
memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs); memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs);
flush_dcache_page(page); flush_dcache_page(page);
kunmap_atomic(addr, KM_BIO_IRQ); kunmap_atomic(addr, KM_BIO_SRC_IRQ);
} }
} else } else
SetPageError(page); SetPageError(page);
...@@ -559,10 +559,10 @@ static void end_buffer_read_mst_async(struct buffer_head *bh, int uptodate) ...@@ -559,10 +559,10 @@ static void end_buffer_read_mst_async(struct buffer_head *bh, int uptodate)
if (file_ofs < ni->initialized_size) if (file_ofs < ni->initialized_size)
ofs = ni->initialized_size - file_ofs; ofs = ni->initialized_size - file_ofs;
addr = kmap_atomic(page, KM_BIO_IRQ); addr = kmap_atomic(page, KM_BIO_SRC_IRQ);
memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs); memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs);
flush_dcache_page(page); flush_dcache_page(page);
kunmap_atomic(addr, KM_BIO_IRQ); kunmap_atomic(addr, KM_BIO_SRC_IRQ);
} }
} else } else
SetPageError(page); SetPageError(page);
...@@ -593,7 +593,7 @@ static void end_buffer_read_mst_async(struct buffer_head *bh, int uptodate) ...@@ -593,7 +593,7 @@ static void end_buffer_read_mst_async(struct buffer_head *bh, int uptodate)
rec_size = ni->_IDM(index_block_size); rec_size = ni->_IDM(index_block_size);
recs = PAGE_CACHE_SIZE / rec_size; recs = PAGE_CACHE_SIZE / rec_size;
addr = kmap_atomic(page, KM_BIO_IRQ); addr = kmap_atomic(page, KM_BIO_SRC_IRQ);
for (i = 0; i < recs; i++) { for (i = 0; i < recs; i++) {
if (!post_read_mst_fixup((NTFS_RECORD*)(addr + if (!post_read_mst_fixup((NTFS_RECORD*)(addr +
i * rec_size), rec_size)) i * rec_size), rec_size))
...@@ -607,7 +607,7 @@ static void end_buffer_read_mst_async(struct buffer_head *bh, int uptodate) ...@@ -607,7 +607,7 @@ static void end_buffer_read_mst_async(struct buffer_head *bh, int uptodate)
ni->_IDM(index_block_size_bits)) + i)); ni->_IDM(index_block_size_bits)) + i));
} }
flush_dcache_page(page); flush_dcache_page(page);
kunmap_atomic(addr, KM_BIO_IRQ); kunmap_atomic(addr, KM_BIO_SRC_IRQ);
if (likely(!nr_err && recs)) if (likely(!nr_err && recs))
SetPageUptodate(page); SetPageUptodate(page);
else { else {
......
...@@ -15,10 +15,11 @@ D(1) KM_SKB_SUNRPC_DATA, ...@@ -15,10 +15,11 @@ D(1) KM_SKB_SUNRPC_DATA,
D(2) KM_SKB_DATA_SOFTIRQ, D(2) KM_SKB_DATA_SOFTIRQ,
D(3) KM_USER0, D(3) KM_USER0,
D(4) KM_USER1, D(4) KM_USER1,
D(5) KM_BIO_IRQ, D(5) KM_BIO_SRC_IRQ,
D(6) KM_PTE0, D(6) KM_BIO_DST_IRQ,
D(7) KM_PTE1, D(7) KM_PTE0,
D(8) KM_TYPE_NR D(8) KM_PTE1,
D(9) KM_TYPE_NR
}; };
#undef D #undef D
......
...@@ -11,7 +11,8 @@ enum km_type { ...@@ -11,7 +11,8 @@ enum km_type {
KM_SKB_DATA_SOFTIRQ, KM_SKB_DATA_SOFTIRQ,
KM_USER0, KM_USER0,
KM_USER1, KM_USER1,
KM_BIO_IRQ, KM_BIO_SRC_IRQ,
KM_BIO_DST_IRQ,
KM_PTE0, KM_PTE0,
KM_PTE1, KM_PTE1,
KM_TYPE_NR KM_TYPE_NR
......
...@@ -7,7 +7,8 @@ enum km_type { ...@@ -7,7 +7,8 @@ enum km_type {
KM_SKB_DATA_SOFTIRQ, KM_SKB_DATA_SOFTIRQ,
KM_USER0, KM_USER0,
KM_USER1, KM_USER1,
KM_BIO_IRQ, KM_BIO_SRC_IRQ,
KM_BIO_DST_IRQ,
KM_TYPE_NR KM_TYPE_NR
}; };
......
...@@ -7,7 +7,8 @@ enum km_type { ...@@ -7,7 +7,8 @@ enum km_type {
KM_SKB_DATA_SOFTIRQ, KM_SKB_DATA_SOFTIRQ,
KM_USER0, KM_USER0,
KM_USER1, KM_USER1,
KM_BIO_IRQ, KM_BIO_SRC_IRQ,
KM_BIO_DST_IRQ,
KM_TYPE_NR KM_TYPE_NR
}; };
......
...@@ -38,7 +38,7 @@ static inline char *bio_kmap_irq(struct bio *bio, unsigned long *flags) ...@@ -38,7 +38,7 @@ static inline char *bio_kmap_irq(struct bio *bio, unsigned long *flags)
* it's a highmem page * it's a highmem page
*/ */
__cli(); __cli();
addr = (unsigned long) kmap_atomic(bio_page(bio), KM_BIO_IRQ); addr = (unsigned long) kmap_atomic(bio_page(bio), KM_BIO_SRC_IRQ);
if (addr & ~PAGE_MASK) if (addr & ~PAGE_MASK)
BUG(); BUG();
...@@ -50,7 +50,7 @@ static inline void bio_kunmap_irq(char *buffer, unsigned long *flags) ...@@ -50,7 +50,7 @@ static inline void bio_kunmap_irq(char *buffer, unsigned long *flags)
{ {
unsigned long ptr = (unsigned long) buffer & PAGE_MASK; unsigned long ptr = (unsigned long) buffer & PAGE_MASK;
kunmap_atomic((void *) ptr, KM_BIO_IRQ); kunmap_atomic((void *) ptr, KM_BIO_SRC_IRQ);
__restore_flags(*flags); __restore_flags(*flags);
} }
......
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