All of lore.kernel.org
 help / color / mirror / Atom feed
* Why is SECTOR_SIZE = 512 inside kernel ?
@ 2015-08-17 12:53 Navin P
  2015-08-17 13:54 ` Theodore Ts'o
  0 siblings, 1 reply; 6+ messages in thread
From: Navin P @ 2015-08-17 12:53 UTC (permalink / raw)
  To: linux-kernel

Hi,

 Why is SECTOR_SIZE 512 ?

http://lxr.free-electrons.com/source/include/linux/ide.h#L118

http://lxr.free-electrons.com/source/include/linux/device-mapper.h#L548

548 #define SECTOR_SHIFT 9

I was looking at disks with hw_sector_size . Most of them i looked at
had 512 bytes except for one which had 4096 (virtual disk). The one
with AF format ie has logical sector size as 512 and hw_sector_size as
512 . So it is fine for my calculation from /proc/diskstats.

But the one with 4096 logical and 4096 physical i multiply
hw_sector_size with the sectors read and written but that is wrong
since the kernel always defines sectors in terms of 512.


Is it going to change or is it  cast in stone ?


Here is an example. Again this is a VM virtual disk. vdc is the
subject in interest.


[root@hphuge-049 ~]# fdisk -l /dev/vdb /dev/vdc

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/vdc: 17.2 GB, 17179869184 bytes, 4194304 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

[root@hphuge-049 ~]#


[root@hphuge-049 ~]# cat /sys/block/vdc/queue/hw_sector_size && cat
/sys/block/vdc/queue/logical_block_size  && cat
/sys/block/vdc/queue/physical_block_size
4096
4096
4096
[root@hphuge-049 ~]# cat /sys/block/vdb/queue/hw_sector_size && cat
/sys/block/vdb/queue/logical_block_size  && cat
/sys/block/vdb/queue/physical_block_size
512
512
4096
[root@hphuge-049 ~]#



Regards,
Navin

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Why is SECTOR_SIZE = 512 inside kernel ?
@ 2015-08-17 11:05 Navin P
       [not found] ` <14960.1439831792@turing-police.cc.vt.edu>
  0 siblings, 1 reply; 6+ messages in thread
From: Navin P @ 2015-08-17 11:05 UTC (permalink / raw)
  To: kernelnewbies

Hi,
 Why is SECTOR_SIZE 512 ?

http://lxr.free-electrons.com/source/include/linux/ide.h#L118

http://lxr.free-electrons.com/source/include/linux/device-mapper.h#L548

548 #define SECTOR_SHIFT 9

I was looking at disks with hw_sector_size . Most of them i looked at
had 512 bytes except for one which had 4096 (virtual disk). The one
with AF format ie has logical sector size as 512 and hw_sector_size as
512 . So it is fine for my calculation from /proc/diskstats.

But the one with 4096 logical and 4096 physical i multiply
hw_sector_size with the sectors read and written but that is wrong
since the kernel always defines sectors in terms of 512.


Is it going to change or is it  cast in stone ?


Here is an example. Again this is a VM virtual disk. vdc is the
subject in interest.


[root at hphuge-049 ~]# fdisk -l /dev/vdb /dev/vdc

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/vdc: 17.2 GB, 17179869184 bytes, 4194304 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

[root at hphuge-049 ~]#


[root at hphuge-049 ~]# cat /sys/block/vdc/queue/hw_sector_size && cat
/sys/block/vdc/queue/logical_block_size  && cat
/sys/block/vdc/queue/physical_block_size
4096
4096
4096
[root at hphuge-049 ~]# cat /sys/block/vdb/queue/hw_sector_size && cat
/sys/block/vdb/queue/logical_block_size  && cat
/sys/block/vdb/queue/physical_block_size
512
512
4096
[root at hphuge-049 ~]#



Regards,
Navin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-18 21:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 12:53 Why is SECTOR_SIZE = 512 inside kernel ? Navin P
2015-08-17 13:54 ` Theodore Ts'o
2015-08-18 21:06   ` Brice Goglin
2015-08-18 21:38     ` tytso
  -- strict thread matches above, loose matches on Subject: below --
2015-08-17 11:05 Navin P
     [not found] ` <14960.1439831792@turing-police.cc.vt.edu>
2015-08-17 18:03   ` Navin P

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.