Skip to content

Commit

Permalink
aoe: prevent cache aliases
Browse files Browse the repository at this point in the history
Prevent the AoE block driver from creating cache aliases of page cache
pages on machines with virtually indexed caches.

Building kernels on an AT91SAM9G20 board without this patch fails with
segmentation faults after a couple of passes.

Signed-off-by: Peter Horton <zero@colonel-panic.org>
Cc: "Ed L. Cashin" <ecashin@coraid.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
phorton-bb authored and torvalds committed Dec 2, 2009
1 parent ca02970 commit 0a1f127
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions drivers/block/aoe/aoecmd.c
Expand Up @@ -735,6 +735,21 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector
part_stat_unlock();
}

/*
* Ensure we don't create aliases in VI caches
*/
static inline void
killalias(struct bio *bio)
{
struct bio_vec *bv;
int i;

if (bio_data_dir(bio) == READ)
__bio_for_each_segment(bv, bio, i, 0) {
flush_dcache_page(bv->bv_page);
}
}

void
aoecmd_ata_rsp(struct sk_buff *skb)
{
Expand Down Expand Up @@ -853,8 +868,12 @@ aoecmd_ata_rsp(struct sk_buff *skb)

if (buf && --buf->nframesout == 0 && buf->resid == 0) {
diskstats(d->gd, buf->bio, jiffies - buf->stime, buf->sector);
n = (buf->flags & BUFFL_FAIL) ? -EIO : 0;
bio_endio(buf->bio, n);
if (buf->flags & BUFFL_FAIL)
bio_endio(buf->bio, -EIO);
else {
killalias(buf->bio);
bio_endio(buf->bio, 0);
}
mempool_free(buf, d->bufpool);
}

Expand Down

0 comments on commit 0a1f127

Please sign in to comment.