Raspi linux bug with USB storage

How to make them do what you want, not to rant on about. Slashdot is better for rants anyway.

Raspi linux bug with USB storage

Postby Doug Coulter » Sun Nov 12, 2017 11:05 am

In working on the LOT and the new "office trailer" stuff, I encountered a snaky bug in linux for raspi (in my case kernel 4.9, raspi b2+). I was using a USB stick mounted over root, as this wants to have plenty of room and live a long time. There is a CGI program that produces plots of the environment data, using gnuplot to create some .png files that are later passed to the browser as urls.

The bug is - and this is only with USB storage AFAICT, is that gnuplot returns thinking it has written the files, but they're not done yet. When the web server passes the links to the browser, it tries to read, and gets all manner of garbage - it's not just that it's seeing the half done files, it's much worse - instead of seeing a png (which it does see some of) it appears that the unwritten data shows up in the STDOUT pipe...so tons of binary garbage also winds up in the browser as though we'd sent it as well as the links to the files.

This was a real head-scratcher, as the same code had run on other pies...just fine. I'd had to change it a tiny bit to account for slightly different filesystem layouts for the web server, but nothing that should have been snaky like this - normally a broken link is just that, and easy to troubleshoot. I realized that in the other places I'd used this code model, I had either a spinning disk or a tmpfs (ramdisk) at that location in the filesystem...

And when I changed it to use a tmpfs (it could be a really small one, the plots aren't that big)...the problem went away.

There is no way that's my bug. The workaround is above. I didn't test with the SD card but I'd bet 25c it has this issue too. Spinning rust and ram don't.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Return to Operating systems

Who is online

Users browsing this forum: No registered users and 3 guests