[SCSI] st: fix enlarge_buffer
authorBodo Stroesser <bstroesser@ts.fujitsu.com>
Mon, 2 Dec 2013 17:52:10 +0000 (18:52 +0100)
committerJames Bottomley <JBottomley@Parallels.com>
Fri, 20 Dec 2013 04:56:28 +0000 (20:56 -0800)
This patch removes a bug in enlarge_buffer() that can make a
read or write fail under special conditions.

After changing TRY_DIRECT_IO to 0 and ST_MAX_SG to 32 in
st_options.h, a program that writes a first block of 128k and
than a second bigger block (e.g. 256k) fails. The second write
returns errno EOVERFLOW, as enlarge_buffer() checks the sg list
and detects that it already is full.
As enlarge_buffer uses different page allocation orders
depending on the size of the buffer needed, the check does not
make sense.

Signed-off-by: Bodo Stroesser <bstroesser@ts.fujitsu.com>
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/st.c

index ff44b3c2cff2b72662c7cda8e829ba433a108afa..a1d6986261a3c5ffbb5053473f0f4e018fe9c877 100644 (file)
@@ -3719,7 +3719,7 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg)
 
 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, max_segs, b_size, order, got;
        gfp_t priority;
 
        if (new_size <= STbuffer->buffer_size)
@@ -3729,9 +3729,6 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
                normalize_buffer(STbuffer);  /* Avoid extra segment */
 
        max_segs = STbuffer->use_sg;
-       nbr = max_segs - STbuffer->frp_segs;
-       if (nbr <= 0)
-               return 0;
 
        priority = GFP_KERNEL | __GFP_NOWARN;
        if (need_dma)
This page took 0.034111 seconds and 5 git commands to generate.