sane-project-website/old-archive/2000-02/0049.html

158 wiersze
5.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>sane-devel: Re: scsi buffer size handling for backends</TITLE>
<META NAME="Author" CONTENT="abel deuring (a.deuring@satzbau-gmbh.de)">
<META NAME="Subject" CONTENT="Re: scsi buffer size handling for backends">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Re: scsi buffer size handling for backends</H1>
<!-- received="Sat Feb 5 07:52:32 2000" -->
<!-- isoreceived="20000205155232" -->
<!-- sent="Sat, 05 Feb 2000 16:39:18 +0100" -->
<!-- isosent="20000205153918" -->
<!-- name="abel deuring" -->
<!-- email="a.deuring@satzbau-gmbh.de" -->
<!-- subject="Re: scsi buffer size handling for backends" -->
<!-- id="389C4426.9B5559F4@satzbau-gmbh.de" -->
<!-- inreplyto="389BD5C4.43577948@wolfsburg.de" -->
<STRONG>From:</STRONG> abel deuring (<A HREF="mailto:a.deuring@satzbau-gmbh.de?Subject=Re:%20scsi%20buffer%20size%20handling%20for%20backends&In-Reply-To=&lt;389C4426.9B5559F4@satzbau-gmbh.de&gt;"><EM>a.deuring@satzbau-gmbh.de</EM></A>)<BR>
<STRONG>Date:</STRONG> Sat Feb 05 2000 - 07:39:18 PST
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0050.html">Bernd Schroeder: "Re: Failure to recognize Microtek ScanMaker V310"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0048.html">Yuri Dario: "Re: fork or pthread for async I/O?"</A>
<LI><STRONG>In reply to:</STRONG> <A HREF="0046.html">Oliver Rauch: "scsi buffer size handling for backends"</A>
<!-- nextthread="start" -->
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#49">[ date ]</A>
<A HREF="index.html#49">[ thread ]</A>
<A HREF="subject.html#49">[ subject ]</A>
<A HREF="author.html#49">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
Oliver Rauch wrote:
<BR>
<EM>&gt;
</EM><BR>
<EM>&gt; Hi,
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; there has changed a lot in the scsi buffer size handling in the past
</EM><BR>
<EM>&gt; and I watched at it with one eye.
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; Can someone tell me what must be done to implement it in a backend?
</EM><BR>
<EM>&gt; Is it already really stable and will the interface keep the same in the future?
</EM><BR>
<P>The simplest way to change the buffer size for existing backends, is to
<BR>
set the environment variable SANE_SG_BUFFERSIZE. If an SG driver &gt;= 2.0
<BR>
is installed, sanei_scsi_open tries to allocate a buffer of the size
<BR>
specified in that variable. Technically, sanei_scsi_max_request_size is
<BR>
set to this value.
<BR>
<P>A problem with this approach is the following: Most backends open device
<BR>
files in sane_init (or in a fucntion called from sane_init) to detect
<BR>
the scanner model, and to set up the &quot;usual internal stuff&quot;. Here, a
<BR>
backend might allocate buffers, where the buffer size is based on the
<BR>
value of sanei_scsi_max_request_size. Then, the device files are closed.
<BR>
When a scan is started, the device file is opened again. This means,
<BR>
that the SG driver needs again to allocate its internal buffer, and it
<BR>
can happen, that it cannot allocate as much memory as requested.
<BR>
Therefore, sanei_scsi_open will fail, if this happens. Otherwise,
<BR>
sanei_scsi_max_request_size would not be constant during program run
<BR>
time, and I was afraid, that this might crashes with some backends.
<BR>
<P>Practically, one should not choose too larger buffer sizes for the old
<BR>
open call, since for larger buffers there increasing probability that
<BR>
the SG driver cannot allocate the requested amount of memory.
<BR>
<P>Regarding switching to sanei_scsi_open_extended, the main task is to get
<BR>
rid of sanei_scsi_max_request_size in the backend's sources, and to
<BR>
replace it with the value returned in int *buffersize (the last argument
<BR>
of sanei_scsi_open_extended). All mallocs and related stuff should be
<BR>
based on the actual value of that variable. The practical aspects of
<BR>
this work can be a little bit nasty: I was quite surprised when I
<BR>
discovered, at how many occasions the Sharp backend used this variable,
<BR>
and &quot;cleaning&quot; the backend from it took some time.
<BR>
<P>A more formal problem I saw in sanei_scsi.c, is the function
<BR>
sanei_scsi_req_flush_all. This function &quot;eats&quot; _all_ queued SCSI
<BR>
commands, without checking the destination device. Right now, this does
<BR>
not hurt, but it would cause trouble for a frontend which is able to
<BR>
operate more that one scanner simultaneously. (yes, that's a quite
<BR>
theoretical question, but on the other hand, all backends seem to be
<BR>
able to handle more than one scanner.)
<BR>
<P>Abel
<BR>
<P><PRE>
--
Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A>
To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20scsi%20buffer%20size%20handling%20for%20backends&In-Reply-To=&lt;389C4426.9B5559F4@satzbau-gmbh.de&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0050.html">Bernd Schroeder: "Re: Failure to recognize Microtek ScanMaker V310"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0048.html">Yuri Dario: "Re: fork or pthread for async I/O?"</A>
<LI><STRONG>In reply to:</STRONG> <A HREF="0046.html">Oliver Rauch: "scsi buffer size handling for backends"</A>
<!-- nextthread="start" -->
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#49">[ date ]</A>
<A HREF="index.html#49">[ thread ]</A>
<A HREF="subject.html#49">[ subject ]</A>
<A HREF="author.html#49">[ author ]</A>
</UL>
<!-- trailer="footer" -->
<HR NOSHADE>
<P>
<SMALL>
<EM>
This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>
: <EM>Sat Feb 05 2000 - 07:54:11 PST</EM>
</EM>
</SMALL>
</BODY>
</HTML>