Re: Why is SECTOR_SIZE = 512 inside kernel ?
From: tytso
Date: Tue Aug 18 2015 - 17:38:18 EST
On Tue, Aug 18, 2015 at 11:06:47PM +0200, Brice Goglin wrote:
> Le 17/08/2015 15:54, Theodore Ts'o a écrit :
> >
> > It's cast in stone. There are too many places all over the kernel,
> > especially in a huge number of file systems, which assume that the
> > sector size is 512 bytes. So above the block layer, the sector size
> > is always going to be 512.
>
> Could this be a problem when using pmem/nvdimm devices with
> byte-granularity (no BTT layer)? (hw_sector_size reports
> 512 in this case while we could expect 1 instead).
> Or it just doesn't matter because BTT is the only way to use
> these devices for filesystems like other block devices?
Right now there are very few applications that understand how to use
pmem/nvdimm devices as memory. And even where they do, they will need
some kind of file system to provide resource isolation in case more
than one application or more than one user wants to use the
pmem/nvdimm. In that case, they will probably mmap a file and then
access the nvdimm directly. In that case, the applications won't be
using the block device layer at all, so they won't care about the
advertised hw_sector_Size.
The challenge with pmem-aware applications is that they need to be
able to correctly update their in-memory data structures in such a way
that they can correctly recover after an arbitrary power failure.
That means they have to use atomic updates and/or copy-on-write update
schemes, and I suspect most application writes just aren't going to be
able to get this right.
So for many legacy applications, they will still read in the file
"foo", make changes in local memory, and then write the new contents
to the file "foo.new", and then rename "foo.new" on top of "foo".
These applications will effectively use nvdimm as super fast flash,
and so they will use file systems as file systems. And since file
systems today all use block sizes which are multiples of the
traditional 512 byte sector size, again, changing something as
fundamental as the kernel's internal sector size doesn't have any real
value, at least not as far as pmem/nvdimm support is concerned.
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/