]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: snap revert header manipulation fixes
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 27 May 2010 00:13:17 +0000 (17:13 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 10 Jun 2010 21:45:39 +0000 (14:45 -0700)
src/cls_rbd.cc

index b667dabb2908f925588ccfbcc31aa617d1deab24..a921276d3f300317666b101ed689f87062010a43 100644 (file)
@@ -205,7 +205,7 @@ int snapshot_revert(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
       found = true;
       break;
     }
-    snap_names += strlen(snap_names);
+    snap_names += strlen(snap_names) + 1;
   }
   if (!found)
     return -ENOENT;
@@ -213,14 +213,17 @@ int snapshot_revert(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   header->image_size = snap.image_size;
   header->snap_seq = header->snap_seq + 1;
 
-  snap_names += strlen(snap_names);
+  snap_names += strlen(snap_names) + 1;
   i++;
 
   header->snap_count = header->snap_count - i;
+  CLS_LOG("snap_count=%d\n", header->snap_count);
   bufferptr new_names_bp(end - snap_names);
   bufferptr new_snaps_bp(sizeof(header->snaps[0]) * header->snap_count);
 
   memcpy(header_bp.c_str(), header, sizeof(*header));
+  newbl.push_back(header_bp);
+
   if (header->snap_count) {
     char *new_snap_names;
     memcpy(new_snaps_bp.c_str(), header->snaps + i, sizeof(header->snaps[0]) * header->snap_count);
@@ -229,7 +232,7 @@ int snapshot_revert(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
     newbl.push_back(new_names_bp);
   }
 
-  rc = cls_cxx_write(hctx, 0, len, &newbl);
+  rc = cls_cxx_write(hctx, 0, newbl.length(), &newbl);
   if (rc < 0)
     return rc;