diff options
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r-- | drivers/scsi/st.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 7f3f317ee6ca..3984cd82fe10 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -3747,20 +3747,20 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm | |||
3747 | priority = GFP_KERNEL | __GFP_NOWARN; | 3747 | priority = GFP_KERNEL | __GFP_NOWARN; |
3748 | if (need_dma) | 3748 | if (need_dma) |
3749 | priority |= GFP_DMA; | 3749 | priority |= GFP_DMA; |
3750 | for (b_size = PAGE_SIZE, order=0; order <= 6 && | 3750 | |
3751 | b_size < new_size - STbuffer->buffer_size; | 3751 | if (STbuffer->frp_segs) { |
3752 | order++, b_size *= 2) | 3752 | b_size = STbuffer->frp[0].length; |
3753 | ; /* empty */ | 3753 | order = get_order(b_size); |
3754 | } else { | ||
3755 | for (b_size = PAGE_SIZE, order = 0; | ||
3756 | order <= 6 && b_size < new_size; order++, b_size *= 2) | ||
3757 | ; /* empty */ | ||
3758 | } | ||
3754 | 3759 | ||
3755 | for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; | 3760 | for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; |
3756 | segs < max_segs && got < new_size;) { | 3761 | segs < max_segs && got < new_size;) { |
3757 | STbuffer->frp[segs].page = alloc_pages(priority, order); | 3762 | STbuffer->frp[segs].page = alloc_pages(priority, order); |
3758 | if (STbuffer->frp[segs].page == NULL) { | 3763 | if (STbuffer->frp[segs].page == NULL) { |
3759 | if (new_size - got <= (max_segs - segs) * b_size / 2) { | ||
3760 | b_size /= 2; /* Large enough for the rest of the buffers */ | ||
3761 | order--; | ||
3762 | continue; | ||
3763 | } | ||
3764 | DEB(STbuffer->buffer_size = got); | 3764 | DEB(STbuffer->buffer_size = got); |
3765 | normalize_buffer(STbuffer); | 3765 | normalize_buffer(STbuffer); |
3766 | return 0; | 3766 | return 0; |