0

This question applies to all unices, but I'm interested mainly in the Linux kernel -- unless there are unices that don't have this restriction.

It seems like allowing non-power-of-two block sizes would greatly simplify things. However this is not allowed.

Question: is there something preventing a policy change to allow non-power-of-two block sizes for block devices? If not, what was the justification for the policy?

  • Motivation: a lot of "block layer wrappers" involve adding some small amount of extra metadata to each block. For example: dm-integrity adds a hash, dm-raid adds a generation number in RAID5 mode to close the RAID5 write hole, etc. – user4718 Sep 6 '18 at 8:10
  • Unfortunately this small amount of extra metadata cannot be stored in the same block of the underlying device, so most drivers (including mdraid raid5, dm-integrity, LVM, bcache and similar) are forced to resort to keeping the data in an external journal, which is a much more complicated solution. – user4718 Sep 6 '18 at 8:10
  • 1
    Doing this correctly in a way that is robust against power failures is almost as complicated as designing a proper filesystem, which is one reason why features like this have been pushed up into monolithic filesystems (like btrfs) instead of maintained as cleanly separated, small, and interchangeable elements in a layered design. – user4718 Sep 6 '18 at 8:11
  • One of the most useful wrappers would be one which adds a checksum on every write and returns an I/O error on read if the checksum is invalid. For an underlying disk with 4k blocks and a 128-bit checksum this would mean a block size of 3968 exposed to the upper layers of the stack. For magnetic media no seeking back and forth between a block and the journal is required, since the checksum is stored in the same underlying device block as the data it covers. – user4718 Sep 6 '18 at 8:11
  • Upper layers of the stack which choose a no-overwrite policy (i.e. COW or journal-like usage) could then safely assume that writes are all-or-nothing and even after a power failure no partially-written blocks will ever read back (of course write re-ordering is still a concern). – user4718 Sep 6 '18 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.