From: Jason Dillaman Date: Fri, 8 May 2015 19:15:29 +0000 (-0400) Subject: librbd: add new copyup helper method X-Git-Tag: v9.0.2~13^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=da5b565f9f1c83891c3523aba87120fa0915312d;p=ceph.git librbd: add new copyup helper method ImageCtx::get_copyup_snap_id returns the oldest snapshot to be used when calculating parent image overlaps. Signed-off-by: Jason Dillaman Conflicts: src/librbd/AioRequest.cc --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 298eeed12ffc..c5e253ebd0a3 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -586,6 +586,17 @@ public: return -ENOENT; } + uint64_t ImageCtx::get_copyup_snap_id() const + { + assert(snap_lock.is_locked()); + // copyup requires the largest possible parent overlap, + // which is always the oldest snapshot (if any). + if (!snaps.empty()) { + return snaps.back(); + } + return CEPH_NOSNAP; + } + void ImageCtx::aio_read_from_cache(object_t o, uint64_t object_no, bufferlist *bl, size_t len, uint64_t off, Context *onfinish, diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 11028705f593..e0b5cb477ab7 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -210,6 +210,7 @@ namespace librbd { uint64_t get_parent_snap_id(librados::snap_t in_snap_id) const; int get_parent_overlap(librados::snap_t in_snap_id, uint64_t *overlap) const; + uint64_t get_copyup_snap_id() const; void aio_read_from_cache(object_t o, uint64_t object_no, bufferlist *bl, size_t len, uint64_t off, Context *onfinish, int fadvise_flags);