sane-project-website/old-archive/2000-11/0254.html

190 wiersze
7.0 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: reaction to a smaller buffer size</TITLE>
<META NAME="Author" CONTENT="abel deuring (a.deuring@satzbau-gmbh.de)">
<META NAME="Subject" CONTENT="Re: reaction to a smaller buffer size">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Re: reaction to a smaller buffer size</H1>
<!-- received="Sun Nov 19 09:40:22 2000" -->
<!-- isoreceived="20001119174022" -->
<!-- sent="Sun, 19 Nov 2000 20:03:13 +0100" -->
<!-- isosent="20001119190313" -->
<!-- name="abel deuring" -->
<!-- email="a.deuring@satzbau-gmbh.de" -->
<!-- subject="Re: reaction to a smaller buffer size" -->
<!-- id="3A1823F1.3D50C56F@satzbau-gmbh.de" -->
<!-- inreplyto="20001118224652.A4375@vortex.swb.de" -->
<STRONG>From:</STRONG> abel deuring (<A HREF="mailto:a.deuring@satzbau-gmbh.de?Subject=Re:%20reaction%20to%20a%20smaller%20buffer%20size&In-Reply-To=&lt;3A1823F1.3D50C56F@satzbau-gmbh.de&gt;"><EM>a.deuring@satzbau-gmbh.de</EM></A>)<BR>
<STRONG>Date:</STRONG> Sun Nov 19 2000 - 11:03:13 PST
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0255.html">Oliver Neukum: "Re: reaction to a smaller buffer size"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0253.html">Peter Kirchgessner: "Re: scanimage-files in frontend package"</A>
<LI><STRONG>In reply to:</STRONG> <A HREF="0241.html">Henning Meier-Geinitz: "Re: reaction to a smaller buffer size"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0255.html">Oliver Neukum: "Re: reaction to a smaller buffer size"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0255.html">Oliver Neukum: "Re: reaction to a smaller buffer size"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#254">[ date ]</A>
<A HREF="index.html#254">[ thread ]</A>
<A HREF="subject.html#254">[ subject ]</A>
<A HREF="author.html#254">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
Henning Meier-Geinitz wrote:
<BR>
<EM>&gt;
</EM><BR>
<EM>&gt; Hi,
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; On Sat, Nov 18, 2000 at 10:11:21PM +0100, Oliver Neukum wrote:
</EM><BR>
<EM>&gt; &gt; Hi,
</EM><BR>
<EM>&gt; &gt;
</EM><BR>
<EM>&gt; &gt; I'd like to ask whether that check
</EM><BR>
<EM>&gt; &gt;
</EM><BR>
<EM>&gt; &gt; if (real_buffersize != wanted_buffersize)
</EM><BR>
<EM>&gt; &gt; {
</EM><BR>
<EM>&gt; &gt; DBG(1, &quot;sanei_scsi_open: could not allocate SG buffer memory &quot;
</EM><BR>
<EM>&gt; &gt; &quot;wanted: %i got: %i\n&quot;, wanted_buffersize, real_buffersize);
</EM><BR>
<EM>&gt; &gt; sanei_scsi_close(*fdp);
</EM><BR>
<EM>&gt; &gt; return SANE_STATUS_NO_MEM;
</EM><BR>
<EM>&gt; &gt; }
</EM><BR>
<EM>&gt; &gt;
</EM><BR>
<EM>&gt; &gt; in sanei_scsi.c might be removed. It makes using SANE with scsi drivers
</EM><BR>
<EM>&gt; &gt; which don't do scatter/gather very hard.
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; I don't understand this fully. With sanei_scsi_open there is no way to
</EM><BR>
<EM>&gt; tell the backend that the buffersize is smaller than expected. What
</EM><BR>
<EM>&gt; happens if the backend sends a bigger buffer than allowed? Is it just
</EM><BR>
<EM>&gt; slowed down or does the SCSI call return with an error?
</EM><BR>
<EM>&gt; sanei_scsi_open already reduces the buffer size if
</EM><BR>
<EM>&gt; proc/sys/kernel/sg-big-buff has a lower value but the backend can't
</EM><BR>
<EM>&gt; find out about it if I understood correctly.
</EM><BR>
<P>The problem is that a backend may consider sanei_scsi_max_request_size
<BR>
as a constant. This was true for the old Linux SG driver; but with the
<BR>
new SG driver it is at least in theory possible that you get different
<BR>
buffer sizes each time a SG device file is opened. (Not very likely, but
<BR>
it is possible)
<BR>
<P>This can have at least two nasty consequences:
<BR>
<P>1. A large buffer for the first open call, a small buffer for the second
<BR>
open call: Assume that a backend sets up the read buffer size after the
<BR>
first open call (eg, during sane_init), and that it stores the size of
<BR>
this buffer in an internal variable. Then, the device file is closed and
<BR>
opened again for a scan. This time, we get a smaller SG buffer size. If
<BR>
the backend now tries to read more data then the changed value of
<BR>
sanei_scsi_max_request_size allow, it is likely that the SG write/read
<BR>
cycle will fail: If the SG driver was not able to allocate enough memory
<BR>
during the open(2) call, it will probably not be able to allocate this
<BR>
amount of memory a few seconds later.
<BR>
<P>2. A small buffer for the first open call, a large buffer for the second
<BR>
open call: If the backend allocates a buffer of size
<BR>
sanei_scsi_max_request_size after the first open, and tries to use
<BR>
sanei_scsi_max_request_size in this buffer after the second open, it
<BR>
will bail out with a segfault.
<BR>
<P>Both situations might have caused unnecessary work and headaches for
<BR>
backend developers, who don't need or don't want to switch to
<BR>
sanei_scsi_open_extended, and therefore I decided to use this &quot;paranoid&quot;
<BR>
looking &quot;if (real_buffersize != wanted_buffersize)&quot;, when I introduced
<BR>
sane_scsi_open_extended and related stuff.
<BR>
<P><P><EM>&gt; Why don't you use sanei_scsi_open_extended if it is available for your
</EM><BR>
<EM>&gt; paltform? In this case the backend can try to get a big buffer and
</EM><BR>
<EM>&gt; knows the actual size it is allowed to use.
</EM><BR>
<P>Exactly.
<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:%20reaction%20to%20a%20smaller%20buffer%20size&In-Reply-To=&lt;3A1823F1.3D50C56F@satzbau-gmbh.de&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0255.html">Oliver Neukum: "Re: reaction to a smaller buffer size"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0253.html">Peter Kirchgessner: "Re: scanimage-files in frontend package"</A>
<LI><STRONG>In reply to:</STRONG> <A HREF="0241.html">Henning Meier-Geinitz: "Re: reaction to a smaller buffer size"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0255.html">Oliver Neukum: "Re: reaction to a smaller buffer size"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0255.html">Oliver Neukum: "Re: reaction to a smaller buffer size"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#254">[ date ]</A>
<A HREF="index.html#254">[ thread ]</A>
<A HREF="subject.html#254">[ subject ]</A>
<A HREF="author.html#254">[ 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>Sun Nov 19 2000 - 09:40:59 PST</EM>
</EM>
</SMALL>
</BODY>
</HTML>