From 7290f34101c46ff02cf8606ad534467be09486d0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 24 Aug 2016 13:02:07 -0400 Subject: [PATCH] os/bluestore: ensure block device size is a multiple of the block size We might have a backing device that is an odd number of 512-byte sectors but have the block_size configured to 4096. Ensure the reported size rounds down to avoid confusing other layers of the stack. Signed-off-by: Sage Weil --- src/os/bluestore/KernelDevice.cc | 3 +++ src/os/bluestore/NVMEDevice.cc | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 52fca98ab2b..2f3811ed58f 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -140,6 +140,9 @@ int KernelDevice::open(string p) fs = FS::create_by_fd(fd_direct); assert(fs); + // round size down to an even block + size &= ~(block_size - 1); + r = _aio_start(); assert(r == 0); diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index c5ba1e48086..32a3a04316c 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -813,6 +813,9 @@ int NVMEDevice::open(string p) //nvme is non-rotational device. rotational = false; + // round size down to an even block + size &= ~(block_size - 1); + dout(1) << __func__ << " size " << size << " (" << pretty_si_t(size) << "B)" << " block_size " << block_size << " (" << pretty_si_t(block_size) << "B)" << dendl; -- 2.39.5