Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755274AbbHQMxH (ORCPT ); Mon, 17 Aug 2015 08:53:07 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:36706 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156AbbHQMxF (ORCPT ); Mon, 17 Aug 2015 08:53:05 -0400 MIME-Version: 1.0 Date: Mon, 17 Aug 2015 18:23:04 +0530 Message-ID: Subject: Why is SECTOR_SIZE = 512 inside kernel ? From: Navin P To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1904 Lines: 66 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/