Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74a6eeb4 authored by Peng Tao's avatar Peng Tao Committed by Trond Myklebust
Browse files

pnfsblock: limit bio page count



One bio can have at most BIO_MAX_PAGES pages. We should limit it bec otherwise
bio_alloc will fail when there are many pages in one read/write_pagelist.

Cc: <stable@vger.kernel.org> #3.1+
Signed-off-by: default avatarPeng Tao <peng_tao@emc.com>
Signed-off-by: default avatarBenny Halevy <bhalevy@tonian.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 93a3844e
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -146,14 +146,19 @@ static struct bio *bl_alloc_init_bio(int npg, sector_t isect,
{
{
	struct bio *bio;
	struct bio *bio;


	npg = min(npg, BIO_MAX_PAGES);
	bio = bio_alloc(GFP_NOIO, npg);
	bio = bio_alloc(GFP_NOIO, npg);
	if (!bio)
	if (!bio && (current->flags & PF_MEMALLOC)) {
		return NULL;
		while (!bio && (npg /= 2))
			bio = bio_alloc(GFP_NOIO, npg);
	}


	if (bio) {
		bio->bi_sector = isect - be->be_f_offset + be->be_v_offset;
		bio->bi_sector = isect - be->be_f_offset + be->be_v_offset;
		bio->bi_bdev = be->be_mdev;
		bio->bi_bdev = be->be_mdev;
		bio->bi_end_io = end_io;
		bio->bi_end_io = end_io;
		bio->bi_private = par;
		bio->bi_private = par;
	}
	return bio;
	return bio;
}
}