Discussion:
[linux-lvm] Sector size is assumed 512
Tomasz Lasko
2017-05-11 10:39:23 UTC
Permalink
Hi,

I'm not a part of the list or the project, just a random guy dropping by
to say I found one suspicious thing:

after looking for what 's' size stands for, I found that your
lvmcmdline.c source code
<https://github.com/Jajcus/lvm2/blob/master/tools/lvmcmdline.c#L320>
probably assumes that sector size is 512, but there are various sector
sizes out in world (both for the hardware sector size and logical disk
interfaces like SCSI) especially more and more popular 4096 byte sector
size.

I wonder if apart of lvmcmdline.c above, also other parts of your
software assume that sector size will always be 512. If yes, then I
suggest rethinking if 4k sectors might break some operations in LVM.

By the way, I understand that when specifying command line parameter
sector size, then it is the same for small 's' as capital 'S', right?
And the same goes for bytes ('b' is the same as 'B'), right?

Best regards,
Tomasz Lasko
Alasdair G Kergon
2017-05-12 11:31:47 UTC
Permalink
It's been a linux kernel coding standard to treat the sector size as
always 512 bytes which we have adopted - regardless of the actual
hardware underneath.

S and s, and B and b mean the same.

Both userspace and kernel code automatically respects alignment
constraints imposed by the devices underneath, such as larger sector sizes.

Alasdair
Zdenek Kabelac
2017-05-12 11:34:56 UTC
Permalink
Hi,
I'm not a part of the list or the project, just a random guy dropping by to
after looking for what 's' size stands for, I found that your lvmcmdline.c
source code
<https://github.com/Jajcus/lvm2/blob/master/tools/lvmcmdline.c#L320> probably
assumes that sector size is 512, but there are various sector sizes out in
world (both for the hardware sector size and logical disk interfaces like
SCSI) especially more and more popular 4096 byte sector size.
I wonder if apart of lvmcmdline.c above, also other parts of your software
assume that sector size will always be 512. If yes, then I suggest rethinking
if 4k sectors might break some operations in LVM.
By the way, I understand that when specifying command line parameter sector
size, then it is the same for small 's' as capital 'S', right? And the same
goes for bytes ('b' is the same as 'B'), right?
Hi

Sector size is 'fixed' for dm devices for 512b.

If you work with 4K sector disks you need to use/specify size multiplied by 8.

It would get really messy if you would have multiple different PVs in a VG
with different sector size and you would want to print i.e. size of LV in
sectors.

So nope - we can't change this fixed 'base' value.

Normally users do work size in MiB or GiB eventually TiB.

lvm2 never advises users to go to sector level precision for numerous reason.

If you care about single sector - lvm2 is likely not a tool to be considered
for usage.


Also note - default alignment is 4MiB - so unless you would override this
extent-size below 4K, you can't actually hit issues with wrong alignment
(and likely >99% users never change this setting)

And BTW it's explicitly mentioned that 'sector is 512b' it has not attachment
to physical device sector size...

Regards


Zdenek

Loading...