]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Fix disk size calculation 47945/head
authorPaul Cuzner <pcuzner@redhat.com>
Mon, 29 Aug 2022 23:54:00 +0000 (11:54 +1200)
committerAdam King <adking@redhat.com>
Sat, 3 Sep 2022 17:05:13 +0000 (13:05 -0400)
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 <pcuzner@redhat.com>
(cherry picked from commit a6f10ebd572cbf95c94614a94f981ca3550fca25)

src/cephadm/cephadm

index 2e551377cfc5863e15dc8e5b3f708e23ec753f33..4e1cf7c3fb78af664b95ccf4fdabec704358fa76 100755 (executable)
@@ -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