diff mbox

rbd: flush dcache after zeroing page data

Message ID 519E0781.4000603@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder May 23, 2013, 12:11 p.m. UTC
Neither zero_bio_chain() nor zero_pages() contains a call to flush
caches after zeroing a portion of a page.  This can cause problems
on architectures that have caches that allow virtual address
aliasing.

This resolves:
    http://tracker.ceph.com/issues/4777

Signed-off-by: Alex Elder <elder@inktank.com>
---
 drivers/block/rbd.c |    2 ++
 1 file changed, 2 insertions(+)

 			pos += bv->bv_len;
@@ -1156,6 +1157,7 @@ static void zero_pages(struct page **pages, u64
offset, u64 end)
 		local_irq_save(flags);
 		kaddr = kmap_atomic(*page);
 		memset(kaddr + page_offset, 0, length);
+		flush_dcache_page(*page);
 		kunmap_atomic(kaddr);
 		local_irq_restore(flags);

Comments

Alex Elder May 23, 2013, 12:13 p.m. UTC | #1
On 05/23/2013 07:11 AM, Alex Elder wrote:
> Neither zero_bio_chain() nor zero_pages() contains a call to flush
> caches after zeroing a portion of a page.  This can cause problems
> on architectures that have caches that allow virtual address
> aliasing.
> 
> This resolves:
>     http://tracker.ceph.com/issues/4777
> 
> Signed-off-by: Alex Elder <elder@inktank.com>

This patch and the other two I just posted are available in the
"review/wip-rbd" branch of the ceph-client git repository.

					-Alex
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Josh Durgin May 23, 2013, 6:54 p.m. UTC | #2
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 05/23/2013 05:11 AM, Alex Elder wrote:
> Neither zero_bio_chain() nor zero_pages() contains a call to flush
> caches after zeroing a portion of a page.  This can cause problems
> on architectures that have caches that allow virtual address
> aliasing.
>
> This resolves:
>      http://tracker.ceph.com/issues/4777
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |    2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 6e377a0..f860dd6 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -1124,6 +1124,7 @@ static void zero_bio_chain(struct bio *chain, int
> start_ofs)
>   				buf = bvec_kmap_irq(bv, &flags);
>   				memset(buf + remainder, 0,
>   				       bv->bv_len - remainder);
> +				flush_dcache_page(bv->bv_page);
>   				bvec_kunmap_irq(buf, &flags);
>   			}
>   			pos += bv->bv_len;
> @@ -1156,6 +1157,7 @@ static void zero_pages(struct page **pages, u64
> offset, u64 end)
>   		local_irq_save(flags);
>   		kaddr = kmap_atomic(*page);
>   		memset(kaddr + page_offset, 0, length);
> +		flush_dcache_page(*page);
>   		kunmap_atomic(kaddr);
>   		local_irq_restore(flags);
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 6e377a0..f860dd6 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1124,6 +1124,7 @@  static void zero_bio_chain(struct bio *chain, int
start_ofs)
 				buf = bvec_kmap_irq(bv, &flags);
 				memset(buf + remainder, 0,
 				       bv->bv_len - remainder);
+				flush_dcache_page(bv->bv_page);
 				bvec_kunmap_irq(buf, &flags);
 			}