PNY SDHC card, 16GB - pretty generic. In this case fstrim did work (pfft yeah whatever it
didn't the last time I tried it), and so did mkfs.btrfs but they work differently
according to strace.
fstrim issues:
ioctl(3, FITRIM, 0x7fffbf6b87e0) = 0
The result is
write(1, "/mnt/: 13.9 MiB (14598144 bytes)"…, 41/mnt/: 13.9 MiB (14598144 bytes)
trimmed
And this is roughly the amount of data deleted during the current mount. It's a 13GB
partition, so fstrim is definitely not going to assure you of erasing previously unerased
blocks. Just what the fs is aware of having been recently deleted. LBA's with known
data in them still had data in them after fstrim, even though they were long ago deleted
files from a completely different fs volume.
mkfs.btrfs issues:
write(2, "Performing full device TRIM (13."..., 43Performing full device TRIM
(13.72GiB) ...
) = 43
ioctl(3, BLKDISCARD, {0, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {40000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {80000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {c0000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {100000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {140000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {180000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {1c0000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {200000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {240000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {280000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {2c0000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {300000000, 7fff920ee4a0}) = 0
ioctl(3, BLKDISCARD, {340000000, 7fff920ee4a0}) = 0
And this obliterated everything on that partition. A dd read came up with 99.99% zeros,
the rest of it was just the btrfs superblocks.
I wasn't successful using scsi kernel tracing to find out what commands are actually
sent to the sdcard for either of these. The trace_pipe file only showed the ssd events,
not for /dev/mmcblk0 and I'm not sure how to trace it.
But based on available info I'm pretty sure it's not actually getting issued TRIM
in the ATA sense, but it's probably getting the SD Card equivalent which seems to be
the ERASE_* set of commands.
Chris Murphy