make DESTDIR=$RPM_BUILD_ROOT install
find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
find $RPM_BUILD_ROOT -type f -name "*.a" -exec rm -f {} ';'
-install -D src/rbdmap $RPM_BUILD_ROOT%{_sysconfdir}/ceph/rbdmap
+install -D src/etc-rbdmap $RPM_BUILD_ROOT%{_sysconfdir}/ceph/rbdmap
install -D src/init-rbdmap $RPM_BUILD_ROOT%{_initrddir}/rbdmap
%if 0%{?fedora} || 0%{?rhel}
install -m 0644 -D etc/sysconfig/ceph $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ceph
%{_bindir}/rbd
%{_bindir}/rbd-replay
%{_bindir}/rbd-replay-many
+%{_bindir}/rbdmap
%if 0%{?_with_lttng}
%{_bindir}/rbd-replay-prep
%endif
usr/bin/ceph-crush-location
usr/bin/rados
usr/bin/rbd
+usr/bin/rbdmap
usr/bin/rbd-replay*
usr/bin/ceph-post-file
usr/bin/ceph-brag
install -D -m 644 udev/50-rbd.rules $(DESTDIR)/lib/udev/rules.d/50-rbd.rules
install -D -m 644 udev/60-ceph-partuuid-workaround.rules $(DESTDIR)/lib/udev/rules.d/60-ceph-partuuid-workaround.rules
install -D -m 644 udev/95-ceph-osd.rules $(DESTDIR)/lib/udev/rules.d/95-ceph-osd.rules
- install -D -m 644 src/rbdmap $(DESTDIR)/etc/ceph/rbdmap
+ install -D -m 644 src/etc-rbdmap $(DESTDIR)/etc/ceph/rbdmap
install -D -m 755 src/init-rbdmap $(DESTDIR)/etc/init.d/rbdmap
# Add here commands to install the package into debian/testpack.
${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${TCMALLOC_LIBS})
install(TARGETS rbd DESTINATION bin)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/src/ceph-rbdnamer DESTINATION bin)
+ install(PROGRAMS ${CMAKE_SOURCE_DIR}/src/rbdmap DESTINATION bin)
set(librbd_replay_types_srcs
rbd_replay/ActionTypes.cc)
bin_SCRIPTS += \
ceph-rbdnamer \
- rbd-replay-many
+ rbd-replay-many \
+ rbdmap
python_PYTHON += pybind/rbd.py
mount.fuse.ceph \
rbd-replay-many \
rbdmap \
+ etc-rbdmap \
yasm-wrapper
EXTRA_DIST += \
--- /dev/null
+# RbdDevice Parameters
+#poolname/imagename id=client,keyring=/etc/ceph/ceph.client.keyring
. /lib/lsb/init-functions
fi
-do_map() {
- if [ ! -f "$RBDMAPFILE" ]; then
- logger -p "daemon.warning" -t init-rbdmap "No $RBDMAPFILE found."
- exit 0
- fi
-
- # Read /etc/rbdtab to create non-existant mapping
- RET=0
- while read DEV PARAMS; do
- case "$DEV" in
- ""|\#*)
- continue
- ;;
- */*)
- ;;
- *)
- DEV=rbd/$DEV
- ;;
- esac
- logger -p "daemon.debug" -t init-rbdmap "Mapping '${DEV}'"
- newrbd=""
- MAP_RV=""
- OIFS=$IFS
- IFS=','
- CMDPARAMS=""
- for PARAM in ${PARAMS[@]}; do
- CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')"
- done
- IFS=$OIFS
- if [ -b /dev/rbd/$DEV ]; then
- MAP_RV="$(readlink -f /dev/rbd/$DEV)"
- else
- MAP_RV="$(rbd map $DEV $CMDPARAMS 2>&1)"
- if [ $? -eq 0 ]; then
- newrbd="yes"
- else
- RET=$((${RET}+$?))
- logger -p "daemon.warning" -t init-rbdmap "Failed to map '${DEV}"
- continue
- fi
- fi
- logger -p "daemon.debug" -t init-rbdmap "Mapped '${DEV}' to '${MAP_RV}'"
-
- if [ "$newrbd" ]; then
- ## Mount new rbd
- MNT_RV=""
- mount --fake /dev/rbd/$DEV >>/dev/null 2>&1 \
- && MNT_RV=$(mount -vn /dev/rbd/$DEV 2>&1)
- [ -n "${MNT_RV}" ] && logger -p "daemon.debug" -t init-rbdmap "Mounted '${MAP_RV}' to '${MNT_RV}'"
-
- ## post-mapping
- if [ -x "/etc/ceph/rbd.d/${DEV}" ]; then
- logger -p "daemon.debug" -t init-rbdmap "Running post-map hook '/etc/ceph/rbd.d/${DEV}'"
- /etc/ceph/rbd.d/${DEV} map "/dev/rbd/${DEV}"
- fi
- fi
- done < $RBDMAPFILE
- exit ${RET}
-
-}
-
-do_unmap() {
- 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
- logger -p "daemon.debug" -t init-rbdmap "Running pre-unmap hook for '${DEV}': '/etc/ceph/rbd.d/${LL}'"
- /etc/ceph/rbd.d/${LL} unmap "$L"
- break
- fi
- done
-
- logger -p "daemon.debug" -t init-rbdmap "Unmapping '${DEV}'"
- MNT=$(findmnt --mtab --source ${DEV} --noheadings | awk '{print $1'})
- if [ -n "${MNT}" ]; then
- logger -p "daemon.debug" -t init-rbdmap "Unmounting '${MNT}'"
- umount "${MNT}" >>/dev/null 2>&1
- fi
- if mountpoint -q "${MNT}"; then
- ## Un-mounting failed.
- logger -p "daemon.warning" -t init-rbdmap "Failed to unmount '${MNT}'"
- RET=$((${RET}+1))
- continue
- fi
- ## Un-mapping.
- rbd unmap $DEV >>/dev/null 2>&1
- if [ $? -ne 0 ]; then
- logger -p "daemon.warning" -t init-rbdmap "Failed to unmap '${MNT}'"
- RET=$((${RET}+$?))
- continue
- fi
- logger -p "daemon.debug" -t init-rbdmap "Unmapped '${DEV}'"
- done
- fi
- exit ${RET}
-}
-
-
case "$1" in
start)
- do_map
+ rbdmap map
;;
stop)
- do_unmap
+ rbdmap unmap
;;
restart|force-reload)
;;
reload)
- do_map
+ rbdmap map
;;
status)
-# RbdDevice Parameters
-#poolname/imagename id=client,keyring=/etc/ceph/ceph.client.keyring
+#!/bin/sh
+
+do_map() {
+ if [ ! -f "$RBDMAPFILE" ]; then
+ logger -p "daemon.warning" -t init-rbdmap "No $RBDMAPFILE found."
+ exit 0
+ fi
+
+ # Read /etc/rbdtab to create non-existant mapping
+ RET=0
+ while read DEV PARAMS; do
+ case "$DEV" in
+ ""|\#*)
+ continue
+ ;;
+ */*)
+ ;;
+ *)
+ DEV=rbd/$DEV
+ ;;
+ esac
+ logger -p "daemon.debug" -t init-rbdmap "Mapping '${DEV}'"
+ newrbd=""
+ MAP_RV=""
+ OIFS=$IFS
+ IFS=','
+ CMDPARAMS=""
+ for PARAM in ${PARAMS[@]}; do
+ CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')"
+ done
+ IFS=$OIFS
+ if [ -b /dev/rbd/$DEV ]; then
+ MAP_RV="$(readlink -f /dev/rbd/$DEV)"
+ else
+ MAP_RV="$(rbd map $DEV $CMDPARAMS 2>&1)"
+ if [ $? -eq 0 ]; then
+ newrbd="yes"
+ else
+ RET=$((${RET}+$?))
+ logger -p "daemon.warning" -t init-rbdmap "Failed to map '${DEV}"
+ continue
+ fi
+ fi
+ logger -p "daemon.debug" -t init-rbdmap "Mapped '${DEV}' to '${MAP_RV}'"
+
+ if [ "$newrbd" ]; then
+ ## Mount new rbd
+ MNT_RV=""
+ mount --fake /dev/rbd/$DEV >>/dev/null 2>&1 \
+ && MNT_RV=$(mount -vn /dev/rbd/$DEV 2>&1)
+ [ -n "${MNT_RV}" ] && logger -p "daemon.debug" -t init-rbdmap "Mounted '${MAP_RV}' to '${MNT_RV}'"
+
+ ## post-mapping
+ if [ -x "/etc/ceph/rbd.d/${DEV}" ]; then
+ logger -p "daemon.debug" -t init-rbdmap "Running post-map hook '/etc/ceph/rbd.d/${DEV}'"
+ /etc/ceph/rbd.d/${DEV} map "/dev/rbd/${DEV}"
+ fi
+ fi
+ done < $RBDMAPFILE
+ exit ${RET}
+
+}
+
+do_unmap() {
+ 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
+ logger -p "daemon.debug" -t init-rbdmap "Running pre-unmap hook for '${DEV}': '/etc/ceph/rbd.d/${LL}'"
+ /etc/ceph/rbd.d/${LL} unmap "$L"
+ break
+ fi
+ done
+
+ logger -p "daemon.debug" -t init-rbdmap "Unmapping '${DEV}'"
+ MNT=$(findmnt --mtab --source ${DEV} --noheadings | awk '{print $1'})
+ if [ -n "${MNT}" ]; then
+ logger -p "daemon.debug" -t init-rbdmap "Unmounting '${MNT}'"
+ umount "${MNT}" >>/dev/null 2>&1
+ fi
+ if mountpoint -q "${MNT}"; then
+ ## Un-mounting failed.
+ logger -p "daemon.warning" -t init-rbdmap "Failed to unmount '${MNT}'"
+ RET=$((${RET}+1))
+ continue
+ fi
+ ## Un-mapping.
+ rbd unmap $DEV >>/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ logger -p "daemon.warning" -t init-rbdmap "Failed to unmap '${MNT}'"
+ RET=$((${RET}+$?))
+ continue
+ fi
+ logger -p "daemon.debug" -t init-rbdmap "Unmapped '${DEV}'"
+ done
+ fi
+ exit ${RET}
+}
+
+case "$1" in
+ map)
+ do_map
+ ;;
+
+ unmap)
+ do_unmap
+ ;;
+ *)
+ echo "Usage: rbdmap map | unmap"
+esac