From: Paul Cuzner Date: Mon, 29 Aug 2022 23:54:00 +0000 (+1200) Subject: cephadm: Fix disk size calculation X-Git-Tag: v17.2.6~513^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47945%2Fhead;p=ceph.git cephadm: Fix disk size calculation With native 4k sectors, the logical blocksize is set to 4096, which yields a disk size 8x the size of the actual device. According to kernel source, device size only uses 512 byte sectors, so the use of logical blocksize is unnecessary. Fixes: https://tracker.ceph.com/issues/57335 Signed-off-by: Paul Cuzner (cherry picked from commit a6f10ebd572cbf95c94614a94f981ca3550fca25) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 2e551377cfc5..4e1cf7c3fb78 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -8217,12 +8217,15 @@ class HostFacts(): def _get_capacity(self, dev): # type: (str) -> int - """Determine the size of a given device""" + """Determine the size of a given device + + The kernel always bases device size calculations based on a 512 byte + sector. For more information see + https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/types.h?h=v5.15.63#n120 + """ size_path = os.path.join('/sys/block', dev, 'size') size_blocks = int(read_file([size_path])) - blk_path = os.path.join('/sys/block', dev, 'queue', 'logical_block_size') - blk_count = int(read_file([blk_path])) - return size_blocks * blk_count + return size_blocks * 512 def _get_capacity_by_type(self, rota='0'): # type: (str) -> int