[Nottingham] Optimising btrfs for an SSD

Martin martin at ml1.co.uk
Mon Oct 3 12:05:36 UTC 2011


Folks,

OK... So I have an SSD that has:

Erase block size: 2MByte
Physical to logical translation unit size: 2 pages (16kByte)
Page size: 8kBytes

So...

My reading so far suggests to ensure that partitions are on 2MByte boundaries.

For formatting, mkfs.btrfs offers the parameters:

       -l, --leafsize size
              Specify the leaf size, the least data item in which
btrfs stores data. The default value is the page size.

       -n, --nodesize size
              Specify the nodesize. By default the value is set to the pagesize.

       -s, --sectorsize size
              Specify the sectorsize, the minimum block allocation.



Note that the pagesize for x86 Linux systems (PCs) is 4kBytes.

For SSDs, the pagesize is the smallest unit writeable to the
underlying storage. Anything smaller, or anything misaligned away from
a page boundary, will require a read-modify-write operation to write a
complete page. Pages can be erased for new data only for an entire
erase block at a time (2MBytes). To write new/modified data, a new
page that is already erased must be allocated, the new data written
there, and the physical-to-logical map updated to 'slot' the newly
used page back into the 'right place'.

A complication is that for this SSD, the physical to logical mapping
only works down to chunks of two pages at a time, 16kBytes.

Also, what does btrfs do with the "sectorsize" parameter exactly?


So...

Should I use:

mkfs.btrfs -L my_new_ssd -l 8192 -n 8192 -s 8192 /dev/sdX

to force btrfs to align with the SSD pagesize?

Or:

mkfs.btrfs -L my_new_ssd -l 16384 -n 16384 -s 16384 /dev/sdX

to align with the physical-to-logical mapping unit size?

Or something else?


Opinions and reasons on an email to the list please!

Cheers,
Martin



More information about the Nottingham mailing list