[one-users] Ceph snapshot

Fabian Zimmermann dev.faz at gmail.com
Fri Jan 16 06:10:11 PST 2015


Hi,

answering myself:

Am 16.01.15 um 13:59 schrieb Fabian Zimmermann:
> Hi,
>
> Am 22.10.14 um 10:42 schrieb Ruben S. Montero:
>> They should be supported for RBD 2 images, you may want to take a look to
>> the actual cloning process in tm/ceph/clone
> looks like /var/lib/one/remotes/tm/ceph/cpds is used in case of a hot
> hdd-snapshot.
yes, because ceph would block the deletion of the source-image until the
new image is flatten and all snapshots are removed.
> Should one use this script to create a hot snapshot?
>
> If yes, is it a good idea to reuse the
>
> if RBD_FORMAT=2
> then
>    clone
> else
>   copy
>
> system of tm/ceph/clone in tm/ceph/cpds or may this lead to other problems?
Already asked at ceph-mailinglist if "rbd cp" is doing an internal
snapshot to protect consistency of data. If not a "snap, protect,
flatten, unprotect, rm" would be done with the following patch:

--
--- cpds.orig    2015-01-16 14:09:10.116016425 +0100
+++ cpds    2015-01-16 15:00:26.666220420 +0100
@@ -1,5 +1,7 @@
 #!/bin/bash

+echo $* > /tmp/$$
+
 #
-------------------------------------------------------------------------- #
 # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G
Labs        #
 #                                                                           
#
@@ -80,8 +82,27 @@
     RBD="$RBD --id ${CEPH_USER}"
 fi

+RBD_SNAP="cpds-${VM_ID}-${DISK_ID}-$( date +%s )"
+
+CP_CMD=$(
+cat <<EOF
+set -e
+
+RBD_FORMAT=\$($RBD info $RBD_DST | sed -n 's/.*format: // p')
+if [ "\$RBD_FORMAT" = "2" ]; then
+    $RBD snap create "$RBD_DST@$RBD_SNAP"
+    $RBD snap protect "$RBD_DST@$RBD_SNAP"
+    $RBD clone "$RBD_DST@$RBD_SNAP" $DST
+    $RBD flatten $DST
+    $RBD snap unprotect "$RBD_DST@$RBD_SNAP"
+    $RBD snap rm "$RBD_DST@$RBD_SNAP"
+else
+    $RBD copy $RBD_DST $DST
+fi
+EOF
+)

-ssh_exec_and_log "$SRC_HOST" "$RBD copy $RBD_DST $DST" \
+ssh_exec_and_log "$SRC_HOST" "$CP_CMD" \
                  "Error cloning $RBD_DST to $DST in $SRC_HOST"

 exit 0
--

I will create a feature-request if "rbd cp" isn't using an internal
snapshot.

Fabian



More information about the Users mailing list