mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
os/bluestore/KernelDevice: handle non-block-aligned backing file
Fixes: http://tracker.ceph.com/issues/16644 Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
a81863e7b8
commit
8c32e69c66
@ -108,6 +108,18 @@ int KernelDevice::open(const string& p)
|
||||
derr << __func__ << " fstat got " << cpp_strerror(r) << dendl;
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
// Operate as though the block size is 4 KB. The backing file
|
||||
// blksize doesn't strictly matter except that some file systems may
|
||||
// require a read/modify/write if we write something smaller than
|
||||
// it.
|
||||
block_size = cct->_conf->bdev_block_size;
|
||||
if (block_size != (unsigned)st.st_blksize) {
|
||||
dout(1) << __func__ << " backing device/file reports st_blksize "
|
||||
<< st.st_blksize << ", using bdev_block_size "
|
||||
<< block_size << " anyway" << dendl;
|
||||
}
|
||||
|
||||
if (S_ISBLK(st.st_mode)) {
|
||||
int64_t s;
|
||||
r = get_block_device_size(fd_direct, &s);
|
||||
@ -118,6 +130,7 @@ int KernelDevice::open(const string& p)
|
||||
} else {
|
||||
size = st.st_size;
|
||||
}
|
||||
size &= ~(block_size);
|
||||
|
||||
{
|
||||
char partition[PATH_MAX], devname[PATH_MAX];
|
||||
@ -132,17 +145,6 @@ int KernelDevice::open(const string& p)
|
||||
}
|
||||
}
|
||||
|
||||
// Operate as though the block size is 4 KB. The backing file
|
||||
// blksize doesn't strictly matter except that some file systems may
|
||||
// require a read/modify/write if we write something smaller than
|
||||
// it.
|
||||
block_size = cct->_conf->bdev_block_size;
|
||||
if (block_size != (unsigned)st.st_blksize) {
|
||||
dout(1) << __func__ << " backing device/file reports st_blksize "
|
||||
<< st.st_blksize << ", using bdev_block_size "
|
||||
<< block_size << " anyway" << dendl;
|
||||
}
|
||||
|
||||
fs = FS::create_by_fd(fd_direct);
|
||||
assert(fs);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user