]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: write a diff description into the merged diff file
authorMingXin Liu <mingxinliu@ubuntukylin.com>
Mon, 5 Jan 2015 09:30:32 +0000 (17:30 +0800)
committerLi Wang <liwang@ubuntukylin.com>
Mon, 5 Jan 2015 09:51:02 +0000 (17:51 +0800)
Signed-off-by: MingXin Liu <mingxinliu@ubuntukylin.com>
Signed-off-by: Yunchuan Wen <yunchuanwen@ubuntukylin.com>
Reviewed-by: Li Wang <liwang@ubuntukylin.com>
src/rbd.cc

index 4e28e6491e85e6dbd87fd754aa8203123c9b1135..c47658aff3171df44c3c79c9878afe36e400f938 100644 (file)
@@ -1712,6 +1712,39 @@ static int do_import_diff(librbd::Image &image, const char *path)
   return r;
 }
 
+/*
+ * fd: the diff file to read from
+ * pd: the diff file to be written into
+ */
+static int accept_diff_body(int fd, int pd, __u8 tag, uint64_t offset, uint64_t length)
+{
+  if (tag == 'e')
+    return 0;
+
+  bufferlist bl;
+  ::encode(tag, bl);
+  ::encode(offset, bl);
+  ::encode(length, bl);
+  int r;
+  r = bl.write_fd(pd);
+  if (r < 0)
+    return r;
+
+  if (tag == 'w') {
+    bufferptr bp = buffer::create(length);
+    r = safe_read_exact(fd, bp.c_str(), length);
+    if (r < 0)
+      return r;
+    bufferlist data;
+    data.append(bp);
+    r = data.write_fd(pd);
+    if (r < 0)
+      return r;
+  }
+
+  return 0;
+}
+
 static int do_copy(librbd::Image &src, librados::IoCtx& dest_pp,
                   const char *destname)
 {