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 <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-08-24 13:02:07 -04:00
parent 108ee77b54
commit 7290f34101
2 changed files with 6 additions and 0 deletions

View 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);

View 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;