Skip to content

Commit

Permalink
aoe: fix crash in page count manipulation
Browse files Browse the repository at this point in the history
aoeblk contains some mysterious code, that wants to elevate the bio
vec page counts while it's under IO. That is not needed, it's
fragile, and it's causing kernel oopses for some.

Reported-by: Tested-by: Don Koch <kochd@us.ibm.com>
Tested-by: Tested-by: Don Koch <kochd@us.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
axboe committed Nov 12, 2016
1 parent 409ae5a commit 0cbc72a
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,53 +853,13 @@ rqbiocnt(struct request *r)
return n;
}

/* This can be removed if we are certain that no users of the block
* layer will ever use zero-count pages in bios. Otherwise we have to
* protect against the put_page sometimes done by the network layer.
*
* See http://oss.sgi.com/archives/xfs/2007-01/msg00594.html for
* discussion.
*
* We cannot use get_page in the workaround, because it insists on a
* positive page count as a precondition. So we use _refcount directly.
*/
static void
bio_pageinc(struct bio *bio)
{
struct bio_vec bv;
struct page *page;
struct bvec_iter iter;

bio_for_each_segment(bv, bio, iter) {
/* Non-zero page count for non-head members of
* compound pages is no longer allowed by the kernel.
*/
page = compound_head(bv.bv_page);
page_ref_inc(page);
}
}

static void
bio_pagedec(struct bio *bio)
{
struct page *page;
struct bio_vec bv;
struct bvec_iter iter;

bio_for_each_segment(bv, bio, iter) {
page = compound_head(bv.bv_page);
page_ref_dec(page);
}
}

static void
bufinit(struct buf *buf, struct request *rq, struct bio *bio)
{
memset(buf, 0, sizeof(*buf));
buf->rq = rq;
buf->bio = bio;
buf->iter = bio->bi_iter;
bio_pageinc(bio);
}

static struct buf *
Expand Down Expand Up @@ -1127,7 +1087,6 @@ aoe_end_buf(struct aoedev *d, struct buf *buf)
if (buf == d->ip.buf)
d->ip.buf = NULL;
rq = buf->rq;
bio_pagedec(buf->bio);
mempool_free(buf, d->bufpool);
n = (unsigned long) rq->special;
rq->special = (void *) --n;
Expand Down

0 comments on commit 0cbc72a

Please sign in to comment.