On Wed, 15 Aug 2018, Martin Hicks wrote: > On Fri, Aug 03, 2018 at 12:56:37PM -0400, Alan Stern wrote: > > On Fri, 3 Aug 2018, Martin Hicks wrote: > > > > > > > > Hi, > > > > > > I've run into a huge performance gap between running a g_mass_storage > > > gadget with the backing file pointing to a raw partition (/dev/mmcblk1) > > > vs. creating a file on an ext4 filesystem and exporting that. > > > > > > With the partition I see write rates around 5MB/s, and with /proc/sys/vm/block_dump > > > enabled I can see that all writes are 512-byte single-sector writes. > > > > > > Using a file within ext4fs, I get around 20MB and block_dump shows large IOs > > > (mostly 2048 sector). > > > > > > Is there any way to get raw-partition to better use caching and not write back > > > every sector individually? > > > > g_mass_storage does no buffering internally; the benefit you get with > > ext4 comes from buffering within the filesystem. > > > > I have no idea how much or what kind of buffering the block-layer > > drivers do for raw partition accesses. You're better off asking the > > people responsible for the block layer about that. > > The culprit ended up being a badly aligned partition. Make sure your partitions > start on some reasonable boundary (like 1MB). Ah, okay. Well done for finding that answer. Alan Stern