[Pkg-ceph-commits] [ceph] 02/04: rbdmap patches

Dmitry Smirnov onlyjob at moszumanska.debian.org
Thu Jul 17 20:37:18 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 d56eed2
Author: Dmitry Smirnov <onlyjob at member.fsf.org>
Date:   Thu Jul 17 16:16:05 2014

    rbdmap patches
---
 .../{rbdmap-mount.patch => rbdmap1-mount.patch}    |   8 +-
 debian/patches/rbdmap2-hooks.patch                 | 103 +++++++++++++++++++++
 debian/patches/rbdmap3-lazyumount.patch            |  56 +++++++++++
 debian/patches/series                              |   4 +-
 4 files changed, 166 insertions(+), 5 deletions(-)

diff --git a/debian/patches/rbdmap-mount.patch b/debian/patches/rbdmap1-mount.patch
similarity index 94%
rename from debian/patches/rbdmap-mount.patch
rename to debian/patches/rbdmap1-mount.patch
index d189cc5..38d2216 100644
--- a/debian/patches/rbdmap-mount.patch
+++ b/debian/patches/rbdmap1-mount.patch
@@ -1,7 +1,7 @@
-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)
+Forwarded: yes
+Applied-Upstream: yes
+Author: Dmitry Smirnov <onlyjob at member.fsf.org>
+Description: 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
diff --git a/debian/patches/rbdmap2-hooks.patch b/debian/patches/rbdmap2-hooks.patch
new file mode 100644
index 0000000..4f94bd8
--- /dev/null
+++ b/debian/patches/rbdmap2-hooks.patch
@@ -0,0 +1,103 @@
+Forwarded: yes
+Applied-Upstream: yes
+From: Dmitry Smirnov <onlyjob at member.fsf.org>
+Description: rbdmap: per-device post-map/pre-unmap hooks
+
+There are cases when automatic (un-)mounting of file system on RBD is not
+enough. Some services may need to be started when RBD device becomes
+available (mapped) as well as it may be desirable to stop services in order
+to release file system before unmapping RBD device.
+
+File system(s) on RBD is not the only use case scenario. RBD devices may be
+used as block devices in which case `/etc/fstab` is not sufficient to
+perform action upon mapping RBD device. A handler script (hook) can be
+useful to properly release RBD device before unmapping, etc.
+
+Pre-unmap hooks can be important for clean shut down and for re-exporting
+RBD device(s) as (iSCSI,AoE,DRBD) etc.
+
+This commit introduces support for per-device hooks to perform per-device
+post-map/pre-unmap actions. If hook named like "poolname/imagename" (same
+as in `/etc/ceph/rbdmap` file) is found in
+
+    /etc/ceph/rbd.d/poolname/imagename
+
+it is executed as
+
+    /etc/ceph/rbd.d/poolname/imagename map poolname/imagename
+
+following after attempt to mount file system (if relevant `fstab` entry
+exist) following mapping of corresponding RBD device.
+
+Before un-mounting file system and un-mapping RBD device hook is called as
+follows:
+
+    /etc/ceph/rbd.d/poolname/imagename unmap poolname/imagename
+
+Second argument is intentional to allow multiple RBD devices to share the
+same hook (symlinked under different names).
+
+Sample hook to use RBD device as "mdadm" hot spare may look like this:
+
+~~~~
+DEV="$2"
+case "$1" in
+    "map")
+        mdadm /dev/md2 --add --write-mostly "${DEV}"
+    ;;
+    "unmap")
+        mdadm /dev/md2 --fail "${DEV}"
+        sleep 2
+        mdadm /dev/md2 --remove "${DEV}"
+    ;;
+esac
+~~~~
+
+Signed-off-by: Dmitry Smirnov <onlyjob at member.fsf.org>
+---
+ src/init-rbdmap | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+--- a/src/init-rbdmap
++++ b/src/init-rbdmap
+@@ -63,13 +63,19 @@
+ 		fi
+ 		log_action_end_msg ${RET_OP} "${MAP_RV}"
+ 
+ 		if [ "$newrbd" ]; then
+-                        ## Mount new rbd
++			## 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}"
++
++			## post-mapping
++			if [ -x "/etc/ceph/rbd.d/${DEV}" ]; then
++			    log_action_msg "RBD Running post-map hook '/etc/ceph/rbd.d/${DEV}'"
++			    /etc/ceph/rbd.d/${DEV} map "/dev/rbd/${DEV}"
++			fi
+ 		fi
+ 	done < $RBDMAPFILE
+ 	exit ${RET}
+ 
+@@ -79,8 +85,19 @@
+ 	RET=0
+ 	## 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
++			## pre-unmapping
++			for L in $(find /dev/rbd -type l); do
++			    LL="${L##/dev/rbd/}"
++			    if [ "$(readlink -f $L)" = "${DEV}" ] \
++			    && [ -x "/etc/ceph/rbd.d/${LL}" ]; then
++			        log_action_msg "RBD pre-unmap:  '${DEV}' hook '/etc/ceph/rbd.d/${LL}'"
++			        /etc/ceph/rbd.d/${LL} unmap "$L"
++			        break
++			    fi
++			done
++
+ 			log_action_begin_msg "RBD un-mapping: '${DEV}'"
+ 			UMNT_RV=""
+ 			UMAP_RV=""
+ 			RET_OP=0
diff --git a/debian/patches/rbdmap3-lazyumount.patch b/debian/patches/rbdmap3-lazyumount.patch
new file mode 100644
index 0000000..7ad4ed9
--- /dev/null
+++ b/debian/patches/rbdmap3-lazyumount.patch
@@ -0,0 +1,56 @@
+Forwarded: yes
+Author: Dmitry Smirnov <onlyjob at member.fsf.org>
+Description: rbdmap: lazy umount on shutdown and reboot (runlevel 0 and 6)
+
+Do lazy unmount in runlevel 0 and 6. This is necessary to avoid unclean
+shutdown due to "umount" hangs on reboot.
+
+"rbdmap" fail to umount and unmap RBD device when some applications are
+still using file system on RBD. If RBD device not released on
+shutdown/reboot system deconfigures network interfaces, terminates
+remaining processes then tries to umount remaining file systems where it
+hangs forever in endless libceph attempt to reach MONs. This scenario was
+observed when /home is located on RBD device (users start processes in
+screen/tmux etc.). Even worse, `umount` stuck on RBD mount point so
+remaining local file systems are never un-mounted making unclean shutdown
+almost inevitable.
+
+Lazy umount is effective because it allows to release RBD device and
+unmount file system when applications are terminated.
+
+Also before umount (if `fuser` utility is available) TERM signal will be
+sent to all processes still using mount point so applications that haven't
+been asked to terminate yet will have some time to finish before final cut.
+
+Signed-off-by: Dmitry Smirnov <onlyjob at member.fsf.org>
+---
+ src/init-rbdmap | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/src/init-rbdmap b/src/init-rbdmap
+index a4e9863..70f0be8 100755
+--- a/src/init-rbdmap
++++ b/src/init-rbdmap
+@@ -104,7 +104,18 @@ do_unmap() {
+ 			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)
++			    local ULAZY=""
++			    local RUNLEVEL=$(runlevel | awk '{print $2}')
++			    if [ $? -eq 0 ]; then
++			        if [ "${RUNLEVEL}" -eq 0 ] \
++			        || [ "${RUNLEVEL}" -eq 6 ] ; then
++			            ULAZY="-l"
++			            if [ -x "$(which fuser)" ]; then
++			                fuser -M -m "${MNT}" --kill -TERM
++			            fi
++			        fi
++			    fi
++			    UMNT_RV=$(umount ${ULAZY} "${MNT}" 2>&1)
+ 			fi
+ 			if mountpoint -q "${MNT}"; then
+ 			    ## Un-mounting failed.
+-- 
+2.0.0
+
diff --git a/debian/patches/series b/debian/patches/series
index 2685588..e504701 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,9 +10,11 @@ sleep-recover.patch
 backfill-prio.patch
 bash-completion.patch
 ceph-ao-require-cas.patch
-rbdmap-mount.patch
+rbdmap1-mount.patch
+rbdmap2-hooks.patch
 
 ## Debian
+rbdmap3-lazyumount.patch
 arch.patch
 modules.patch
 sample.ceph.conf.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