]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: ensure block device size is a multiple of the block size
authorSage Weil <sage@redhat.com>
Wed, 24 Aug 2016 17:02:07 +0000 (13:02 -0400)
committerSage Weil <sage@redhat.com>
Wed, 24 Aug 2016 17:02:31 +0000 (13:02 -0400)
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 <sage@redhat.com>
src/os/bluestore/KernelDevice.cc
src/os/bluestore/NVMEDevice.cc

index 52fca98ab2b4050f9c46a43dc194e66bbca7a0bd..2f3811ed58fff69eb4c9ae15d554f1c0bc68f2e6 100644 (file)
@@ -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);
 
index c5ba1e48086448718a05661c8c7e3bcc4c42be3c..32a3a04316ced6ae23ffae1dca7677eb5b9f65b6 100644 (file)
@@ -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;