On Fri, 14 Apr 2000, Eric Lee Green wrote:

> Jim Hammack wrote:
> > How can I read > 32 Kbytes from a generic scsi device?  I am running
> > kernel 2.2.13 and using a Sony SDT-9000 DAT drive.  I have data tapes
> > with a 40960 byte block size.  I can read these tapes okay on an SGI
> > under IRIX 6.5, but under Linux I only get 32K bytes.
> 
> That is correct. Linux currently by default only allows a maximum of 32K bytes
> in fixed-block mode. This has been identified as a problem. 
> 
> You may try 
> 
> mt -f /dev/st1 setblk 0
> 
> and see if that will work, this puts the driver (and, presumably, tape drive)
> into variable block mode. But I don't think it'll work even then. But it's
> worth a try, because in the unlikely event that it does work, your problem is
> solved :-). 
> 
It should work. The tape driver tries to enlarge the buffer in variable
block mode is the requested size exceeds the buffer size (this behaviour
has existed for a very long time). This may fail if the memory is
fragmented but chances of success increase with the kernel version number.
With kernel 2.2 the buffer does not have to be contiguous and this
increases the chances of success.

> But I think you'll need to edit linux/drivers/scsi/st_options.h and increase
> ST_BUFFER_BLOCKS to a bigger number (64 will definitely do you!). Re-compile
> your kernel, install the kernel with the bigger ST_BUFFER_BLOCKS, then you'll
> be able to do the following and have it work:
> 
You don't have to recompile the kernel. The default buffer size can be set
either as a kernel parameter (driver in kernel) or module parameters. The
syntax is documented in the file linux/drivers/scsi/README.st.

> The driver knows what block size it's trying to read, this is part of the tape
> status info. The driver needs to re-size its buffer to be bigger than
> ST_BUFFER_BLOCKS bytes when necessary upon READ's but currently doesn't.  I
> don't know if this is fixed in the latest 2.3 drivers for the 'st' device. I
> may take a look at it this weekend and see whether it has been fixed, or
> whether I need to hack at it (but this is NOT an easy problem to solve, we're
> talking about DMA buffers and possibly scatter-gather if we can't get enough
> adjacent memory ... ).  
> 
In fixed block mode the buffer size is not changed. This has not been
implemented basically because no one has told me that it is a problem: the
default is enough for most practical purposes and it can be changed easily if
necessary.

Looking at the source of the 2.3.99-pre5 source, it should be easy to fix
this problem. The following patch compiles but I have not tested it at
all:

---------------------------------8<----------------------------------------
--- /source/linux-2.3/drivers/scsi/st.c Fri Mar 24 21:44:32 2000
+++ linux-2.3/drivers/scsi/st.c Sat Apr 15 10:31:41 2000
@@ -2853,6 +2853,11 @@
                    mtc.mt_op != MTSETDENSITY && mtc.mt_op != MTWSM &&
                    mtc.mt_op != MTSETDRVBUFFER && mtc.mt_op != MTSETPART)
                        STps->rw = ST_IDLE;     /* Prevent automatic WEOF and fsf */
+
+               if (mtc.mt_op == MTSETBLK && STp->buffer != NULL &&
+                   mtc.mt_count > (STp->buffer)->buffer_size &&
+                   !enlarge_buffer(STp->buffer, mtc.mt_count, STp->restr_dma))
+                       return (-EIO);  /* Buffer resizing for fixed block mode failed 
+*/
 
                if (mtc.mt_op == MTOFFL && STp->door_locked != ST_UNLOCKED)
                        st_int_ioctl(STp, MTUNLOCK, 0); /* Ignore result! */
---------------------------------8<----------------------------------------

Modulo line numbers and indentation, the same patch should apply to the
2.2 driver.

        Kai



-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]

Reply via email to