aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorKai Makisara <Kai.Makisara@kolumbus.fi>2008-12-18 00:49:51 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-01-02 13:06:52 -0500
commit8f78fc5eb798426891f99390a61f752aaef9fc39 (patch)
tree4b1f614ed4af572024b3906855ab15f3b7f19ec8 /drivers/scsi
parent02ae2c0e844e2864a877d1da8a92fe5e63778a18 (diff)
[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: Kai Makisara <Kai.Makisara@kolumbus.fi> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/st.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index ddf2630b3479..c6f19ee8f2cb 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3695,6 +3695,8 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg)
3695 3695
3696 3696
3697/* Try to allocate enough space in the tape buffer */ 3697/* Try to allocate enough space in the tape buffer */
3698#define ST_MAX_ORDER 6
3699
3698static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) 3700static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
3699{ 3701{
3700 int segs, nbr, max_segs, b_size, order, got; 3702 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 b_size = PAGE_SIZE << order; 3725 b_size = PAGE_SIZE << order;
3724 } else { 3726 } else {
3725 for (b_size = PAGE_SIZE, order = 0; 3727 for (b_size = PAGE_SIZE, order = 0;
3726 order <= 6 && b_size < new_size; order++, b_size *= 2) 3728 order < ST_MAX_ORDER && b_size < new_size;
3729 order++, b_size *= 2)
3727 ; /* empty */ 3730 ; /* empty */
3728 } 3731 }
3732 if (max_segs * (PAGE_SIZE << order) < new_size) {
3733 if (order == ST_MAX_ORDER)
3734 return 0;
3735 normalize_buffer(STbuffer);
3736 return enlarge_buffer(STbuffer, new_size, need_dma);
3737 }
3729 3738
3730 for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; 3739 for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size;
3731 segs < max_segs && got < new_size;) { 3740 segs < max_segs && got < new_size;) {