From: MingXin Liu Date: Mon, 5 Jan 2015 09:30:32 +0000 (+0800) Subject: rbd: write a diff description into the merged diff file X-Git-Tag: v0.93~268^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7cc6af7057ebbab9ee37a1672f5f5fc47950b07;p=ceph.git rbd: write a diff description into the merged diff file Signed-off-by: MingXin Liu Signed-off-by: Yunchuan Wen Reviewed-by: Li Wang --- diff --git a/src/rbd.cc b/src/rbd.cc index 4e28e6491e8..c47658aff31 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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) {