]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix race condition of global csum setting 11195/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 22 Sep 2016 11:59:05 +0000 (19:59 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 22 Sep 2016 14:46:50 +0000 (22:46 +0800)
The global csum_type option can be changed dynamically and
can be fixed by upgrading into std::atomic.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 0ec048f6f29d3afe10ed77d8f34ad61992558641..43eb9d7d45c80c735cc178d632ea8bcab09bb7c3 100644 (file)
@@ -4728,8 +4728,7 @@ int BlueStore::_do_read(
     } else {
       for (auto reg : b2r_it->second) {
        // determine how much of the blob to read
-       uint64_t chunk_size = bptr->get_blob().get_chunk_size(
-         csum_type != bluestore_blob_t::CSUM_NONE, block_size);
+       uint64_t chunk_size = bptr->get_blob().get_chunk_size(true, block_size);
        uint64_t r_off = reg.blob_xoffset;
        uint64_t r_len = reg.length;
        unsigned front = r_off % chunk_size;
@@ -7337,8 +7336,9 @@ int BlueStore::_do_alloc_write(
             << dendl;
 
     // checksum
-    if (csum_type) {
-      b->dirty_blob().init_csum(csum_type, csum_order, csum_length);
+    int csum = csum_type.load();
+    if (csum) {
+      b->dirty_blob().init_csum(csum, csum_order, csum_length);
       b->dirty_blob().calc_csum(b_off, *l);
     }
     if (wi.mark_unused) {
index 5e5253d5cc9c07695c7524173fdee9572da3b0eb..b206bb087b14c5cf42a076b93b75c74578c0beaf 100644 (file)
@@ -1336,7 +1336,7 @@ private:
   set<ghobject_t, ghobject_t::BitwiseComparator> debug_data_error_objects;
   set<ghobject_t, ghobject_t::BitwiseComparator> debug_mdata_error_objects;
 
-  int csum_type;
+  std::atomic<int> csum_type;
 
   uint64_t block_size;     ///< block size of block device (power of 2)
   uint64_t block_mask;     ///< mask to get just the block offset