]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/buffer: invalidate crc on zero, copy_in 738/head
authorSage Weil <sage@inktank.com>
Thu, 17 Oct 2013 23:47:29 +0000 (16:47 -0700)
committerSage Weil <sage@inktank.com>
Thu, 17 Oct 2013 23:47:29 +0000 (16:47 -0700)
This does not capture users who

 - calc a crc
 - use c_str() to modify the buffer content
 - (re)calc a crc

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/buffer.cc

index 221a9977109dcefe894c77159cc6c957a78eb6b8..493070557159e1dbc9d37d2abd16c407911f20f9 100644 (file)
@@ -121,6 +121,10 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE
       Spinlock::Locker l(crc_lock);
       crc_map[fromto] = crc;
     }
+    void invalidate_crc() {
+      Spinlock::Locker l(crc_lock);
+      crc_map.clear();
+    }
   };
 
   class buffer::raw_malloc : public buffer::raw {
@@ -451,17 +455,20 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE
     assert(_raw);
     assert(o <= _len);
     assert(o+l <= _len);
+    _raw->invalidate_crc();
     memcpy(c_str()+o, src, l);
   }
 
   void buffer::ptr::zero()
   {
+    _raw->invalidate_crc();
     memset(c_str(), 0, _len);
   }
 
   void buffer::ptr::zero(unsigned o, unsigned l)
   {
     assert(o+l <= _len);
+    _raw->invalidate_crc();
     memset(c_str()+o, 0, l);
   }