[Pkg-ceph-commits] [ceph] 01/02: rbdmap-mount.patch

Dmitry Smirnov onlyjob at moszumanska.debian.org
Mon Jul 14 18:13:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

onlyjob pushed a commit to branch master
in repository ceph.

commit 31e3ba5
Author: Dmitry Smirnov <onlyjob at member.fsf.org>
Date:   Sat Jul 12 07:45:00 2014

    rbdmap-mount.patch
---
 debian/patches/rbdmap-mount.patch | 154 ++++++++++++++++++++++++++++++++++++++
 debian/patches/series             |   1 +
 2 files changed, 155 insertions(+)

diff --git a/debian/patches/rbdmap-mount.patch b/debian/patches/rbdmap-mount.patch
new file mode 100644
index 0000000..d189cc5
--- /dev/null
+++ b/debian/patches/rbdmap-mount.patch
@@ -0,0 +1,154 @@
+From b844ec93c50453fa5dc70d367224f2286440d7dd Mon Sep 17 00:00:00 2001
+From: Dmitry Smirnov <onlyjob at member.fsf.org>
+Date: Fri, 11 Jul 2014 19:50:24 +1000
+Subject: [PATCH] rbdmap: per-device mount (Closes: #8538)
+
+`/etc/init.d/rbdmap start` was doing `mount -a`. Although (arguably)
+`mount -a -O _netdev` could be less disruptive, it's not RBD mapping job to
+mount unrelated devices and potentially do it at the wrong time.
+
+Solution is to call `mount {device}` which works as expected and mounts
+device even if it given in form `mount /dev/rbd/pool/imagename` while
+`/etc/fstab` uses UUID or LABEL notation.
+
+Furthermore this commit
+
+ * fixes global exit code (it was always 0): now it is 0 only when
+   all devices were (un)mounted successfully; otherwise non-zero.
+ * replaces `mount -a` with per-device post-mapping `mount {dev}`
+ * show mapping progress using LSB functions per device instead of for
+   {start|stop} invocation.
+ * capture output of `(u)mount` (if any) and report it as "info".
+
+Signed-off-by: Dmitry Smirnov <onlyjob at member.fsf.org>
+---
+ src/init-rbdmap | 74 ++++++++++++++++++++++++++++++++++++---------------------
+ 1 file changed, 47 insertions(+), 27 deletions(-)
+
+--- a/src/init-rbdmap
++++ b/src/init-rbdmap
+@@ -17,9 +17,9 @@
+ # Short-Description: Ceph RBD Mapping
+ # Description:       Ceph RBD Mapping
+ ### END INIT INFO
+ 
+-DESC="RBD Mapping"
++DESC="RBD Mapping:"
+ RBDMAPFILE="/etc/ceph/rbdmap"
+ 
+ . /lib/lsb/init-functions
+ 
+@@ -28,11 +28,9 @@
+ 		log_warning_msg "$DESC : No $RBDMAPFILE found."
+ 		exit 0
+ 	fi
+ 
+-	log_daemon_msg "Starting $DESC"
+ 	# Read /etc/rbdtab to create non-existant mapping
+-	newrbd=
+ 	RET=0
+ 	while read DEV PARAMS; do
+ 		case "$DEV" in
+ 		  ""|\#*)
+@@ -43,48 +41,72 @@
+ 		  *)
+ 			DEV=rbd/$DEV
+ 			;;
+ 		esac
++		log_action_begin_msg "${DESC} '${DEV}'"
++		newrbd=""
++		MAP_RV=""
++		RET_OP=0
+ 		OIFS=$IFS
+ 		IFS=','
+ 		for PARAM in ${PARAMS[@]}; do
+ 			CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')"
+ 		done
+ 		IFS=$OIFS
+ 		if [ ! -b /dev/rbd/$DEV ]; then
+-			log_progress_msg $DEV
+-			rbd map $DEV $CMDPARAMS
+-			[ $? -ne "0" ] && RET=1
+-			newrbd="yes"
++			MAP_RV=$(rbd map $DEV $CMDPARAMS 2>&1)
++			if [ $? -eq 0 ]; then
++			    newrbd="yes"
++			else
++			    RET=$((${RET}+$?))
++			    RET_OP=1
++			fi
++		fi
++		log_action_end_msg ${RET_OP} "${MAP_RV}"
++
++		if [ "$newrbd" ]; then
++                        ## Mount new rbd
++			MNT_RV=""
++			mount --fake /dev/rbd/$DEV >>/dev/null 2>&1 \
++			&& MNT_RV=$(mount -v /dev/rbd/$DEV 2>&1)
++			[ -n "${MNT_RV}" ] && log_action_msg "mount: ${MNT_RV}"
+ 		fi
+ 	done < $RBDMAPFILE
+-	log_end_msg $RET
++	exit ${RET}
+ 
+-	# Mount new rbd
+-	if [ "$newrbd" ]; then
+-                log_action_begin_msg "Mounting all filesystems"
+-		mount -a
+-		log_action_end_msg $?
+-	fi
+ }
+ 
+ do_unmap() {
+-	log_daemon_msg "Stopping $DESC"
+ 	RET=0
+-	# Recursive umount that depends /dev/rbd*
+-	MNTDEP=$(findmnt --mtab | awk '$2 ~ /^\/dev\/rbd[0-9]*$/ {print $1}' | sort -r)
+-	for MNT in $MNTDEP; do
+-		umount $MNT
+-	done 
+-	# Unmap all rbd device
++	## Unmount and unmap all rbd devices
+ 	if ls /dev/rbd[0-9]* >/dev/null 2>&1; then
+ 		for DEV in /dev/rbd[0-9]*; do
+-			log_progress_msg $DEV
+-			rbd unmap $DEV
+-			[ $? -ne "0" ] && RET=1
++			log_action_begin_msg "RBD un-mapping: '${DEV}'"
++			UMNT_RV=""
++			UMAP_RV=""
++			RET_OP=0
++			MNT=$(findmnt --mtab --source ${DEV} --noheadings | awk '{print $1'})
++			if [ -n "${MNT}" ]; then
++			    log_action_cont_msg "un-mounting '${MNT}'"
++			    UMNT_RV=$(umount "${MNT}" 2>&1)
++			fi
++			if mountpoint -q "${MNT}"; then
++			    ## Un-mounting failed.
++			    RET_OP=1
++			    RET=$((${RET}+1))
++			else
++			    ## Un-mapping.
++			    UMAP_RV=$(rbd unmap $DEV 2>&1)
++			    if [ $? -ne 0 ]; then
++			        RET=$((${RET}+$?))
++			        RET_OP=1
++			    fi
++			fi
++			log_action_end_msg ${RET_OP} "${UMAP_RV}"
++			[ -n "${UMNT_RV}" ] && log_action_msg "${UMNT_RV}"
+ 		done
+ 	fi
+-	log_end_msg $RET
++	exit ${RET}
+ }
+ 
+ 
+ case "$1" in
+@@ -113,6 +135,4 @@
+ 	log_success_msg "Usage: rbdmap {start|stop|restart|force-reload|reload|status}"
+ 	exit 1
+ 	;;
+ esac
+-
+-exit 0
diff --git a/debian/patches/series b/debian/patches/series
index 4cfd604..2685588 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,6 +10,7 @@ sleep-recover.patch
 backfill-prio.patch
 bash-completion.patch
 ceph-ao-require-cas.patch
+rbdmap-mount.patch
 
 ## Debian
 arch.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ceph/ceph.git



More information about the Pkg-ceph-commits mailing list