]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: make blob_t unused helpers use logical length
authorSage Weil <sage@redhat.com>
Tue, 6 Sep 2016 20:50:46 +0000 (16:50 -0400)
committerSage Weil <sage@redhat.com>
Wed, 7 Sep 2016 15:26:06 +0000 (11:26 -0400)
These were taking min_alloc_size, but this can change
across mounts; better to use the logical blob length
instead (that's what we want anyway!).

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index a9274cd8b494442664bb44859338fd42fe0e99ea..d1890b5c7fdbace69ab931fd0cdf210e00c5e390 100644 (file)
@@ -6969,7 +6969,7 @@ void BlueStore::_do_write_small(
     uint64_t b_len = length + head_pad + tail_pad;
     if ((b_off % chunk_size == 0 && b_len % chunk_size == 0) &&
        b->get_blob().get_ondisk_length() >= b_off + b_len &&
-       b->get_blob().is_unused(b_off, b_len, min_alloc_size) &&
+       b->get_blob().is_unused(b_off, b_len) &&
        b->get_blob().is_allocated(b_off, b_len)) {
       dout(20) << __func__ << "  write to unused 0x" << std::hex
               << b_off << "~" << b_len
@@ -6989,7 +6989,7 @@ void BlueStore::_do_write_small(
       dout(20) << __func__ << "  lex old " << *ep << dendl;
       Extent *le = o->extent_map.set_lextent(offset, b_off + head_pad, length, b,
                                             &wctx->old_extents);
-      b->dirty_blob().mark_used(le->blob_offset, le->length, min_alloc_size);
+      b->dirty_blob().mark_used(le->blob_offset, le->length);
       txc->statfs_delta.stored() += le->length;
       dout(20) << __func__ << "  lex " << *le << dendl;
       return;
@@ -7061,7 +7061,7 @@ void BlueStore::_do_write_small(
               << " at " << op->extents << dendl;
       Extent *le = o->extent_map.set_lextent(offset, offset - bstart, length, b,
                                             &wctx->old_extents);
-      b->dirty_blob().mark_used(le->blob_offset, le->length, min_alloc_size);
+      b->dirty_blob().mark_used(le->blob_offset, le->length);
       txc->statfs_delta.stored() += le->length;
       dout(20) << __func__ << "  lex " << *le << dendl;
       return;
@@ -7242,12 +7242,13 @@ int BlueStore::_do_alloc_write(
     if (wi.mark_unused) {
       auto b_off = wi.b_off;
       auto b_len = wi.bl.length();
-      if (b_off)
-        b->dirty_blob().add_unused(0, b_off, min_alloc_size);
-      if (b_off + b_len < wi.blob_length)
+      if (b_off) {
+        b->dirty_blob().add_unused(0, b_off);
+      }
+      if (b_off + b_len < wi.blob_length) {
         b->dirty_blob().add_unused(b_off + b_len,
-                                  wi.blob_length - (b_off + b_len),
-                                  min_alloc_size);
+                                  wi.blob_length - (b_off + b_len));
+      }
     }
 
     // queue io
index e38ff30ab03a6ebe3509fbd96b75aa09d5d12747..a484ea20667b0e3ee160ace6d044546aa9910b8f 100644 (file)
@@ -541,8 +541,8 @@ void bluestore_blob_t::generate_test_instances(list<bluestore_blob_t*>& ls)
   ls.push_back(new bluestore_blob_t);
   ls.back()->init_csum(CSUM_XXHASH32, 16, 65536);
   ls.back()->csum_data = buffer::claim_malloc(4, strdup("abcd"));
-  ls.back()->add_unused(0, 3, 4096);
-  ls.back()->add_unused(8, 8, 4096);
+  ls.back()->add_unused(0, 3);
+  ls.back()->add_unused(8, 8);
   ls.back()->extents.emplace_back(bluestore_pextent_t(0x40100000, 0x10000));
   ls.back()->extents.emplace_back(
     bluestore_pextent_t(bluestore_pextent_t::INVALID_OFFSET, 0x1000));
index 52c9eab9e30819f086cdbbfec72113f6392feae1..5da333d17a7844c269bb9b9bfbeee91a97df118f 100644 (file)
@@ -394,13 +394,14 @@ struct bluestore_blob_t {
   }
 
   /// return true if the logical range has never been used
-  bool is_unused(uint64_t offset, uint64_t length, uint64_t min_alloc_size) const {
+  bool is_unused(uint64_t offset, uint64_t length) const {
     if (!has_unused()) {
       return false;
     }
-    assert((min_alloc_size % unused.size()) == 0);
-    assert(offset + length <= min_alloc_size);
-    uint64_t chunk_size = min_alloc_size / unused.size();
+    uint64_t blob_len = get_logical_length();
+    assert((blob_len % unused.size()) == 0);
+    assert(offset + length <= blob_len);
+    uint64_t chunk_size = blob_len / unused.size();
     uint64_t start = offset / chunk_size;
     uint64_t end = ROUND_UP_TO(offset + length, chunk_size) / chunk_size;
     assert(end <= unused.size());
@@ -412,10 +413,11 @@ struct bluestore_blob_t {
   }
 
   /// mark a range that has never been used
-  void add_unused(uint64_t offset, uint64_t length, uint64_t min_alloc_size) {
-    assert((min_alloc_size % unused.size()) == 0);
-    assert(offset + length <= min_alloc_size);
-    uint64_t chunk_size = min_alloc_size / unused.size();
+  void add_unused(uint64_t offset, uint64_t length) {
+    uint64_t blob_len = get_logical_length();
+    assert((blob_len % unused.size()) == 0);
+    assert(offset + length <= blob_len);
+    uint64_t chunk_size = blob_len / unused.size();
     uint64_t start = ROUND_UP_TO(offset, chunk_size) / chunk_size;
     uint64_t end = (offset + length) / chunk_size;
     assert(end <= unused.size());
@@ -428,11 +430,12 @@ struct bluestore_blob_t {
   }
 
   /// indicate that a range has (now) been used.
-  void mark_used(uint64_t offset, uint64_t length, uint64_t min_alloc_size) {
+  void mark_used(uint64_t offset, uint64_t length) {
     if (has_unused()) {
-      assert((min_alloc_size % unused.size()) == 0);
-      assert(offset + length <= min_alloc_size);
-      uint64_t chunk_size = min_alloc_size / unused.size();
+      uint64_t blob_len = get_logical_length();
+      assert((blob_len % unused.size()) == 0);
+      assert(offset + length <= blob_len);
+      uint64_t chunk_size = blob_len / unused.size();
       uint64_t start = offset / chunk_size;
       uint64_t end = ROUND_UP_TO(offset + length, chunk_size) / chunk_size;
       assert(end <= unused.size());