Commit 8f78fc5e authored by Kai Makisara's avatar Kai Makisara Committed by James Bottomley

[SCSI] st: retry enlarge_buffer allocation

Make enlarge_buffer() retry allocation if the previously chosen page
order was too small. Really limit the page order to 6. Return error if
the maximum order is not large enough for the request.
Signed-off-by: default avatarKai Makisara <Kai.Makisara@kolumbus.fi>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 02ae2c0e
...@@ -3695,6 +3695,8 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg) ...@@ -3695,6 +3695,8 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg)
/* Try to allocate enough space in the tape buffer */ /* Try to allocate enough space in the tape buffer */
#define ST_MAX_ORDER 6
static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
{ {
int segs, nbr, max_segs, b_size, order, got; int segs, nbr, max_segs, b_size, order, got;
...@@ -3723,9 +3725,16 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm ...@@ -3723,9 +3725,16 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
b_size = PAGE_SIZE << order; b_size = PAGE_SIZE << order;
} else { } else {
for (b_size = PAGE_SIZE, order = 0; for (b_size = PAGE_SIZE, order = 0;
order <= 6 && b_size < new_size; order++, b_size *= 2) order < ST_MAX_ORDER && b_size < new_size;
order++, b_size *= 2)
; /* empty */ ; /* empty */
} }
if (max_segs * (PAGE_SIZE << order) < new_size) {
if (order == ST_MAX_ORDER)
return 0;
normalize_buffer(STbuffer);
return enlarge_buffer(STbuffer, new_size, need_dma);
}
for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size;
segs < max_segs && got < new_size;) { segs < max_segs && got < new_size;) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment