]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Make RPGTransaction::get_bytes_written return the correct size. 2400/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Sun, 28 Sep 2014 07:01:46 +0000 (15:01 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Sun, 28 Sep 2014 07:01:46 +0000 (15:01 +0800)
It record size larger than clien wrote. It should like
ECTransaction::get_bytes_written only return the size which clien
wrote. It should contain omap data.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/osd/ReplicatedBackend.cc

index 5e079760f72000ba5210095e4fad4243003193b7..6996801e32565eb63130ec4e209bd42c963d6533 100644 (file)
@@ -274,6 +274,7 @@ class RPGTransaction : public PGBackend::PGTransaction {
   set<hobject_t> temp_added;
   set<hobject_t> temp_cleared;
   ObjectStore::Transaction *t;
+  uint64_t written;
   const coll_t &get_coll_ct(const hobject_t &hoid) {
     if (hoid.is_temp()) {
       temp_cleared.erase(hoid);
@@ -296,7 +297,7 @@ class RPGTransaction : public PGBackend::PGTransaction {
   }
 public:
   RPGTransaction(coll_t coll, coll_t temp_coll)
-    : coll(coll), temp_coll(temp_coll), t(new ObjectStore::Transaction)
+    : coll(coll), temp_coll(temp_coll), t(new ObjectStore::Transaction), written(0)
     {}
 
   /// Yields ownership of contained transaction
@@ -318,6 +319,7 @@ public:
     uint64_t len,
     bufferlist &bl
     ) {
+    written += len;
     t->write(get_coll_ct(hoid), hoid, off, len, bl);
   }
   void remove(
@@ -355,6 +357,8 @@ public:
     const hobject_t &hoid,
     map<string, bufferlist> &keys
     ) {
+    for (map<string, bufferlist>::iterator p = keys.begin(); p != keys.end(); p++)
+      written += p->first.length() + p->second.length();
     return t->omap_setkeys(get_coll(hoid), hoid, keys);
   }
   void omap_rmkeys(
@@ -372,6 +376,7 @@ public:
     const hobject_t &hoid,
     bufferlist &header
     ) {
+    written += header.length();
     t->omap_setheader(get_coll(hoid), hoid, header);
   }
   void clone_range(
@@ -436,6 +441,8 @@ public:
     ) {
     RPGTransaction *to_append = dynamic_cast<RPGTransaction*>(_to_append);
     assert(to_append);
+    written += to_append->written;
+    to_append->written = 0;
     t->append(*(to_append->t));
     for (set<hobject_t>::iterator i = to_append->temp_added.begin();
         i != to_append->temp_added.end();
@@ -457,7 +464,7 @@ public:
     return t->empty();
   }
   uint64_t get_bytes_written() const {
-    return t->get_encoded_bytes();
+    return written;
   }
   ~RPGTransaction() { delete t; }
 };