Fsys.eide problem with SanDisk flash drive

We’ve encountered a problem with certain SanDisk flash drives (we use
SD25B-128 drives on an ATA bus) under QNX 4.25, and if any of you can shed
light on it, I’d appreciate it greatly.

We have code which uses a fairly simple sequence of fopen(),
fprintf()…fprintf(), fclose() calls to write to a file of approximately
2200 bytes. With certain of the SanDisk units*, the first 1024 bytes are
written, but not the rest of the data, even though the file size is updated
to indicate the correct length. Thus, when the data is read back later,
random, pre-existing data from the drive is returned at the end of the file.
Using a logic analyzer on the ATA bus, we have confirmed that no data beyond
the first 1024 bytes is provided to the drive.

  • The units which fail in this manner appear to be working, but very slowly.
    The “completed successfully” IRQ after the write of the first 1024 bytes
    comes after about 24.5 msecs, whereas with other units not exhibiting this
    problem, the IRQ comes after only about 2.5 msecs. Curiously, the drives
    report themselves as “removeable”…

The system calls do not report any errors. Changing the system calls to
open(), write(), close() makes no difference. Likewise, using setbuf() to
disable buffering does not help. However, if Fsys is started with the ‘-d0’
option, and mount is given the ‘-s’ option, the drive units appear to
function correctly.

While the drives are abnormally slow, they can hardly be considered “faulty”
if they succeed at writing the data they are given, and are never given the
remaining data. The source code itself is beyond question. This appears to
be the fault of the QNX device driver at some low level. Does anyone know of
bugs or issues with the drivers which cause this sort of bad behavior?

Kent Radek <karadek@essvote.com> wrote:

We’ve encountered a problem with certain SanDisk flash drives (we use
SD25B-128 drives on an ATA bus) under QNX 4.25, and if any of you can shed
light on it, I’d appreciate it greatly.

We have code which uses a fairly simple sequence of fopen(),
fprintf()…fprintf(), fclose() calls to write to a file of approximately
2200 bytes. With certain of the SanDisk units*, the first 1024 bytes are
written, but not the rest of the data, even though the file size is updated
to indicate the correct length. Thus, when the data is read back later,
random, pre-existing data from the drive is returned at the end of the file.
Using a logic analyzer on the ATA bus, we have confirmed that no data beyond
the first 1024 bytes is provided to the drive.

  • The units which fail in this manner appear to be working, but very slowly.
    The “completed successfully” IRQ after the write of the first 1024 bytes
    comes after about 24.5 msecs, whereas with other units not exhibiting this
    problem, the IRQ comes after only about 2.5 msecs. Curiously, the drives
    report themselves as “removeable”…

The system calls do not report any errors. Changing the system calls to
open(), write(), close() makes no difference. Likewise, using setbuf() to
disable buffering does not help. However, if Fsys is started with the ‘-d0’
option, and mount is given the ‘-s’ option, the drive units appear to
function correctly.

While the drives are abnormally slow, they can hardly be considered “faulty”
if they succeed at writing the data they are given, and are never given the
remaining data. The source code itself is beyond question. This appears to
be the fault of the QNX device driver at some low level. Does anyone know of
bugs or issues with the drivers which cause this sort of bad behavior?

I don’t know of any known bugs, but I’m not a subject matter expert there.

The extremely long delay to the write complete irq might be being seen
as a hardware fault.

Can you try increasing the trace level to 6, and then checking to
see if Fsys has generated any tracelogs after this happens?

Can you also try doing your test with an
open( … O_DSYNC ) and then checking the result of the write() call
and seeing if it gives a success or failure back?

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:ausec7$co2$1@nntp.qnx.com

I don’t know of any known bugs, but I’m not a subject matter expert there.

The extremely long delay to the write complete irq might be being seen
as a hardware fault.

That’s pretty much what I was guessing…I’m just not sure how to check
whether that’s the case.

Can you try increasing the trace level to 6, and then checking to
see if Fsys has generated any tracelogs after this happens?

I’ve attached a tracelog, but I’m still pretty new to QNX and didn’t know
anything about tracelogs before your message. So if my ignorance shines
through, feel free to enlighten me. I passed “-v 6” to Fsys – hope that was
the trace level you were talking about. For reference when perusing the log,
the file was written at 11:45:38.

Can you also try doing your test with an
open( … O_DSYNC ) and then checking the result of the write() call
and seeing if it gives a success or failure back?

Setting O_DSYNC causes the file to be written successfully…so, of course,
no errors are returned.

Thanks,
Kent


begin 666 Trace.zip
M4$L#!!0(`/59(BX,:ZHRN@0``$4L```%5%)!0T7=6E%OVS80?B_0
M_W![2X"A)271D@KXP<E2;-T0#$O1/1:JK=1"$ZF39!?;KQ\I)39C’2\ZB0.*
M’5!4<#Y^/GYW$K\3_“XK000@Y9M(O0D”"$#HB%1\VUWHD-V%U/Z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V.+R'Q53^+3X11 X/$V9KZJCV;;>H+!! ^/*<"T]70^E *^?(C%R/4A]E*F M#XEF3Q<$@PD>'JLD<[J@\T$J:7G8B8_DV,OAF,RNA)O!! ^?#M^?$'B\$F0^ M2"52+SH>S)VW._/(R+XSK:7<.]/:AZ]S=+:3)QA,\/!8BS&=/)W/L,74;"=/ M,)C@X1$%"#RJ)T/HH 7)Z\LWSOMH:G<OS.9SV"“AT^O.‘B$LQ?SJ@1KC8.
MG:YVS’+”%"O/IEB%7OIJMK4F&$SP%A7,TUG0_2%<<?GE!3E@7S=3JHV::>
M8##!PV/:,TT]G0\BJO+2P^I8&C&Q&+D&A![
=. _!WX>M6L6:,B<>?EYE!
M>7;KJ:
#5?3WX:KX]MP\J&7^DU)GCSZPNB+S#[ (0ZCV>5WOR@:VV3Z’
M:KW>U76^>04WU7T.;9VM<\CW^N!LX
YJVE<O7_P+4$L!A0% ````@]5DB M+@QKJC*Z! ``12P```4``````````0@+:!`````%1204-%4$L%!@`````! -``$,P```-T$````````
`
end

Kent Radek <karadek@essvote.com> wrote:

“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:ausec7$co2$> 1@nntp.qnx.com> …

I don’t know of any known bugs, but I’m not a subject matter expert there.

The extremely long delay to the write complete irq might be being seen
as a hardware fault.

That’s pretty much what I was guessing…I’m just not sure how to check
whether that’s the case.

Can you try increasing the trace level to 6, and then checking to
see if Fsys has generated any tracelogs after this happens?

I’ve attached a tracelog, but I’m still pretty new to QNX and didn’t know
anything about tracelogs before your message. So if my ignorance shines
through, feel free to enlighten me. I passed “-v 6” to Fsys – hope that was
the trace level you were talking about. For reference when perusing the log,
the file was written at 11:45:38.

No – I was talking about the Proc tracelevel, to control what goes into
the tracelog.

tracectrl will set the level
tracelogger will extract the trace information in a compact but not
human readable form
traceinfo will extract the info in a human readable form, or translate the
output generated by tracelogger

tracectrl -s 6

will set the tracelevel to 6. Basically… Proc throws away everything
less important than the level set – doesn’t matter what Fsys generates.

Can you also try doing your test with an
open( … O_DSYNC ) and then checking the result of the write() call
and seeing if it gives a success or failure back?

Setting O_DSYNC causes the file to be written successfully…so, of course,
no errors are returned.

Hm…very odd.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:av24sd$rep$1@nntp.qnx.com

Kent Radek <> karadek@essvote.com> > wrote:

I’ve attached a tracelog, but I’m still pretty new to QNX and didn’t
know
anything about tracelogs before your message. So if my ignorance shines
through, feel free to enlighten me. I passed “-v 6” to Fsys – hope that
was
the trace level you were talking about. For reference when perusing the
log,
the file was written at 11:45:38.

No – I was talking about the Proc tracelevel, to control what goes into
the tracelog.

Slowly, realization dawns… Okay, I’ve attached a new trace with all events
of severity 6 or higher. There doesn’t appear to be anything new in regards
to the /dev/hd0 device, though. The file was written at 16:43:38.

Setting O_DSYNC causes the file to be written successfully…so, of
course,
no errors are returned.

Hm…very odd.

My theory as to why the drive is taking so long to respond is that it’s
accumulating “things” (keep in mind that this is a flash drive) in its
internal cache until it reaches a point where there’s no more cache and it
must actually complete a previous task to respond to the current write. If
all (or most) writes are synchronous, and thus slower (more widely spaced),
the backlog never builds to the point where extremely long delays are seen.
I know, it sounds kind of…odd…but I don’t know much about the internal
workings of flash drives.


begin 666 Trace.zip
M4$L#!!0(`$F (BX,D$Z\B 4``( P```%5%)!0T7=6EUOVS84?2_0
M_W#WE@!;3(GZ+."’).NP=44P+$7W6- 2G0BQ4^BG;:_?E>28SLVR9&1U’T0
M""PXE^<>WD/QDKQ^QP00’[SH34#?^!%$0+ %A,1 X P_SN’F[0<X_GY'-Z7 M=T7&%E,O@#DK%CR'LTWVB4G)LGO(9+6 U8,\?_WJG0;4IRTH#3O0KNU 0_@! M;LJ<@R@E% (_<KYDJPL]GIED. :wink::&"2T1@DXX%)QF.03 8FF8Q!,AV89.I& MTM^"H@(>@OKTD.1/'=*J*C/XM(=;UG=P]O:7FX^7[PV(U&MI!NF69K6ISV%3 MY/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