]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/KernelDevice: handle non-block-aligned backing file
authorSage Weil <sage@redhat.com>
Wed, 12 Apr 2017 22:49:20 +0000 (18:49 -0400)
committerSage Weil <sage@redhat.com>
Wed, 26 Apr 2017 20:03:34 +0000 (16:03 -0400)
Fixes: http://tracker.ceph.com/issues/16644
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/KernelDevice.cc

index d8b19a1e19522d0811d8a935afea897c0a8e3f22..0793be729161d1e167530dbe367d5d995f60bff1 100644 (file)
@@ -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);