|
|
Subscribe / Log in / New account

Why partition alignment?

Why partition alignment?

Posted Mar 11, 2010 8:43 UTC (Thu) by PO8 (guest, #41661)
Parent article: 4K-sector drives and Linux

I don't understand why the kernel can't just read and write with the appropriate disk alignment, rather than relying on the partition being aligned. Surely it can just look at the partition table for the device and remember the correct alignment for each partition, the same as the article above does? The off-by-one thing is still a problem, but other than that it all seems straightforward. What am I missing?


to post comments

Why partition alignment?

Posted Mar 11, 2010 15:50 UTC (Thu) by BenHutchings (subscriber, #37955) [Link] (3 responses)

So you want the filesystem to start at some offset from the start of the partition? How would an old kernel know about that offset? How would a new kernel know that an old filesystem did not have that offset? The rule is that the partition table specifies the start.

Why partition alignment?

Posted Mar 11, 2010 17:15 UTC (Thu) by etienne_lorrain@yahoo.fr (guest, #38022) [Link]

I am not sure that is the solution neither, but if it is needed for ext2/3/4fs, it could be implemented in two steps:
1. The EXTxFS superblock is no more located at 1 Kbyte from the beginning of the partition but at the 3rd sector i.e. LBA=2.
It then only make unreadable the EXTxFS located on DVD-RAM or the EXTxFS images written to CDROM/DVDs.
Also, it seems strange to search for a signature in the middle of a sector when the device has 4096 bytes/sector.
2. The EXTxFS superblock is located at the 3rd *physical* sector of the partition.
Then to mount the FS the software has to scan few sectors to see if it find an EXT* superblock, and old mount command can probably handle the "-o offset=1" parameter.

Why partition alignment?

Posted Mar 11, 2010 18:39 UTC (Thu) by PO8 (guest, #41661) [Link] (1 responses)

No, I just want the kernel to issue reads and writes aligned with the disk blocks. I don't see why anything has to move on-disk at all? Reads presumably aren't much of an issue anyhow, and writes are only going to be a problem at the beginning and end. I don't see why just doing the reads and writes properly aligned wouldn't be almost as good as shifting the data on disk?

Why partition alignment?

Posted Mar 11, 2010 19:33 UTC (Thu) by cmccabe (guest, #60281) [Link]

What you're talking about is actually done by a lot of SSDs that are sold today. It's called write coalescing. SSDs don't really have sectors, they have "erase blocks" which are often 16k or so in size.

So when they get a request for a 512-byte write, rather than doing the read-modify-write of a 16k block, they wait to see if the user wants to do any more I/O to that erase block.

The disadvantages of write coalescing are kind of obvious-- it's complex, requires temporary storage (for the un-coalesced 512-byte chunks). More buffering also means there's a longer window when power failures can result in data loss.

Overall, it's not something you want to do unless you absolutely have to. Performance and stability would be a lot better if the kernel knew about the real situation on the hardware.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds