Skip to content

Commit

Permalink
[SCSI] st: make all the fragment buffers the same size
Browse files Browse the repository at this point in the history
This patch simiplifies the fragment buffer management a bit, all the
buffers in the fragment list become the same size. This is necessary
to use the block layer API (sg driver was modified in the same way)
since the block layer API takes the same size page frames instead of
scatter gatter.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Kai Makisara <Kai.Makisara@kolumbus.fi>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Jan 2, 2009
1 parent 97ae77a commit 9c90596
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/scsi/st.c
Original file line number Diff line number Diff line change
Expand Up @@ -3747,20 +3747,20 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
priority = GFP_KERNEL | __GFP_NOWARN;
if (need_dma)
priority |= GFP_DMA;
for (b_size = PAGE_SIZE, order=0; order <= 6 &&
b_size < new_size - STbuffer->buffer_size;
order++, b_size *= 2)
; /* empty */

if (STbuffer->frp_segs) {
b_size = STbuffer->frp[0].length;
order = get_order(b_size);
} else {
for (b_size = PAGE_SIZE, order = 0;
order <= 6 && b_size < new_size; order++, b_size *= 2)
; /* empty */
}

for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size;
segs < max_segs && got < new_size;) {
STbuffer->frp[segs].page = alloc_pages(priority, order);
if (STbuffer->frp[segs].page == NULL) {
if (new_size - got <= (max_segs - segs) * b_size / 2) {
b_size /= 2; /* Large enough for the rest of the buffers */
order--;
continue;
}
DEB(STbuffer->buffer_size = got);
normalize_buffer(STbuffer);
return 0;
Expand Down

0 comments on commit 9c90596

Please sign in to comment.