Jeffrey Walton <noloa...@gmail.com> writes:

> The file system cache is still holding the writes. If I remove the
> SDcard and try to use it, the image is corrupt. When I say "remove", I
> mean pop the card out of the card reader since the write has
> supposedly finished.

All right. So in fact, block devices either have write back write
caching or they don't and apparently the device driver decides
that. hdparm may be able to control caching but I don't know it works
for USB devices.

It'd be interesting to know if you have caching related kernel messages
about your SD cards when plugged in? I did have from my USB SD reader.

I remember I have a USB-SSD case which demonstrated this situation,
super fast writes to a block device. I may dig that up for some testing.

In my little experiments with media on hand I found only uncached writes
this weekend. Test devices were one old 1 GB SD card, one newish 64 GB
SDXC card, one old 4 GB USB stick, two SD card readers, one USB and one
PCI-connected built in to a laptop.

Interestingly with the old memory stick there's a kernel message which
says outright write caching is write through which seems to indicate
synchronous writes.

[3675744.043264] sd 6:0:0:0: [sdc] No Caching mode page found
[3675744.048781] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[3675744.113885]  sdc: sdc1
[3675744.139820] sd 6:0:0:0: [sdc] Attached SCSI removable disk

Writes to that stick were about 6 MB/s as reported by dd.

With my USB SD card reader there was a similar message:
[17740.817424] sd 5:0:0:0: [sdb] Write cache: disabled, read cache: enabled, 
doesn't support DPO or FUA

Laptop's built in PCI-connected SD card reader didn't say anything about
cache.

Write speeds reported from dd were pretty much as expected, from a few
MB/s to a few dozen with the SDXC card.

Reply via email to