diff options
author | Peng Tao <bergwolf@gmail.com> | 2012-01-12 10:18:48 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-01-12 16:39:05 -0500 |
commit | 74a6eeb44ca6174d9cc93b9b8b4d58211c57bc80 (patch) | |
tree | 7aa0fc19c383f31123232103121756e48fbb84ed | |
parent | 93a3844ee0f843b05a1df4b52e1a19ff26b98d24 (diff) |
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: Peng Tao <peng_tao@emc.com>
Signed-off-by: Benny Halevy <bhalevy@tonian.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/blocklayout/blocklayout.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index 6d39e9ab1e6..baf0bf2acbd 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c | |||
@@ -146,14 +146,19 @@ static struct bio *bl_alloc_init_bio(int npg, sector_t isect, | |||
146 | { | 146 | { |
147 | struct bio *bio; | 147 | struct bio *bio; |
148 | 148 | ||
149 | npg = min(npg, BIO_MAX_PAGES); | ||
149 | bio = bio_alloc(GFP_NOIO, npg); | 150 | bio = bio_alloc(GFP_NOIO, npg); |
150 | if (!bio) | 151 | if (!bio && (current->flags & PF_MEMALLOC)) { |
151 | return NULL; | 152 | while (!bio && (npg /= 2)) |
153 | bio = bio_alloc(GFP_NOIO, npg); | ||
154 | } | ||
152 | 155 | ||
153 | bio->bi_sector = isect - be->be_f_offset + be->be_v_offset; | 156 | if (bio) { |
154 | bio->bi_bdev = be->be_mdev; | 157 | bio->bi_sector = isect - be->be_f_offset + be->be_v_offset; |
155 | bio->bi_end_io = end_io; | 158 | bio->bi_bdev = be->be_mdev; |
156 | bio->bi_private = par; | 159 | bio->bi_end_io = end_io; |
160 | bio->bi_private = par; | ||
161 | } | ||
157 | return bio; | 162 | return bio; |
158 | } | 163 | } |
159 | 164 | ||