Re: Why is SECTOR_SIZE = 512 inside kernel ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 17, 2015 at 10:46 PM,  <Valdis.Kletnieks@xxxxxx> wrote:
> On Mon, 17 Aug 2015 16:35:59 +0530, Navin P said:
>> Hi,
>>  Why is SECTOR_SIZE 512 ?
>
> Because most fixed-block devices presented a logical interface in terms
> of 512 byte sectors.  (IBM's count-key-data format is an example of a non-fixed
> block device).
>
>> Is it going to change or is it  cast in stone ?
>
> As you have probably figured out, high-capacity devices have often moved
> to 4K physical blocks to avoid wasting so much room between blocks (the hardware
> format includes a preamble to each block and a postamble, and dead space in
> between, it uses more space than you think).
>
> However, as long as there are still devices out there that have 512 byte
> blocks, it's not changing.  And it still won't change unless there's a
> good reason to change it (hint - how many places in the kernel have hidden
> assumptions about the size of SECTOR_SIZE being 9 bits worth?)

I posted this to
http://www.mail-archive.com/linux-kernel@xxxxxxxxxxxxxxx/msg956881.html
avoided cross posting.

Looks like this is cast in stone at kernel . I was thinking of doing
sectors written  * hw_sector_size. But the sectors counters in
/proc/diskstats are actually 512 byte sections even for 4kN disks.
That way userspace programs are immune to underlying sector. Wish that
page_size was also same :)

There are lot of places like 9 bits .

http://lxr.free-electrons.com/source/block/blk-lib.c

 bio->bi_iter.bi_size = req_sects << 9;

http://lxr.free-electrons.com/source/include/linux/blkdev.h

sprinkled with 9 . I'm assuming the magic number 9 here is SECTOR_SIZE. :)

The hw_sector_size must be cosmetic in that sense or just to you tell
you that "your drive really is 4kn" or "512e".

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux