Skip to contentSkip to conversation

gfs2-utils: Fix hang on withdraw

PATCH New Abhijith Das 2 participants 2 messages Aug 4, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 gfs2-utils: Fix hang on withdraw

Issuing a withdraw on a gfs2 filesystem causes a hang. When gfs_controld was removed, the userspace functionality that completes a withdraw operation went away. This causes gfs2 kernel to hang waiting for a withdraw completion ack from userspace.

This patchset introduces a uevent-based shell script to do the job that gfs_controld used to do on withdraw. An 'offline' uevent triggers the execution of this script. This script suspends the device associated with the filesystem and signals a completed withdraw to the kernel.

Resolves: rhbz#1225634

---
 README.build                        |  9 +++++++++
 gfs2/scripts/82-gfs2-withdraw.rules |  2 ++
 gfs2/scripts/Makefile.am            |  5 +++++
 gfs2/scripts/gfs2_wd_udev.sh        | 30 ++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+)
 create mode 100644 gfs2/scripts/82-gfs2-withdraw.rules
 create mode 100755 gfs2/scripts/gfs2_wd_udev.sh
README.build +9 -0
index f4ebe53..6487bae 100644
@@ -29,5 +29,14 @@ To install gfs2-utils, run:
 
     make install
 
+The following scripts (located in gfs2/scripts) are used to complete
+the userland portion of the gfs2 withdraw feature using uevents. They
+are not installed by 'make install' and need to be installed manually
+or during rpm installation to the corresponding locations.
+
+	82-gfs2-withdraw.rules in /etc/udev/rules.d/
+	gfs2_wd_udev.sh        in /usr/sbin/
+
 See also doc/README.contributing for details on submitting patches and
 doc/README.tests for more details regarding the test suite.
+
gfs2/scripts/82-gfs2-withdraw.rules new file +2 -0
new file mode 100644
index 0000000..2228615
@@ -0,0 +1,2 @@
+SUBSYSTEM=="gfs2", ACTION=="offline", RUN+="/bin/sh /usr/sbin/gfs2_wd_udev.sh"
+
gfs2/scripts/Makefile.am +5 -0
index 62fb2fe..dde906f 100644
@@ -3,3 +3,8 @@ MAINTAINERCLEANFILES = Makefile.in
 dist_sbin_SCRIPTS = \
 	gfs2_lockcapture \
 	gfs2_trace
+
+noinst_SCRIPTS = \
+	82-gfs2-withdraw.rules \
+	gfs2_wd_udev.sh
+
gfs2/scripts/gfs2_wd_udev.sh new file +30 -0
new file mode 100755
index 0000000..ac3ce35
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Do not run this script manually. This script is called by udev on a gfs2
+# withdraw uevent and is used to complete the withdraw action and notify the
+# kernel.
+#
+
+# Sanity checks
+if [ "$SUBSYSTEM" != "gfs2" ] || [ "$LOCKPROTO" != "lock_dlm" ] ||
+       [ -z "$DEVPATH" ] || [ "$ACTION" != "offline" ]
+then
+    exit 1 # Nothing to do here
+fi
+
+# Try and suspend the device
+SYSFS_TOPDIR="/sys"$DEVPATH
+DM_NAME=$(cat "$SYSFS_TOPDIR/device/dm/name")
+DM_DEV="/dev/mapper/"$DM_NAME
+
+if [ -z "$DM_DEV" ]
+then
+    /usr/bin/dmsetup suspend $DM_DEV
+fi
+
+# Signal completion of withdraw
+WD_ACK="$SYSFS_TOPDIR/lock_module/withdraw"
+if [ -f "$WD_ACK" ]
+then
+    echo "1" > $WD_ACK
+fi
Signature · 1 line
2.4.3
#2 lore raw

PATCH v2 1/1 gfs2-utils: Fix hang on withdraw

Hi Abhi,

Thanks for adding the docs, this looks good to me.

Cheers,
Andy

Quoted 100 lines · Abhijith Das

Issuing a withdraw on a gfs2 filesystem causes a hang. When gfs_controld was removed, the userspace functionality that completes a withdraw operation went away. This causes gfs2 kernel to hang waiting for a withdraw completion ack from userspace.

This patchset introduces a uevent-based shell script to do the job that gfs_controld used to do on withdraw. An 'offline' uevent triggers the execution of this script. This script suspends the device associated with the filesystem and signals a completed withdraw to the kernel.

Resolves: rhbz#1225634

---
  README.build                        |  9 +++++++++
  gfs2/scripts/82-gfs2-withdraw.rules |  2 ++
  gfs2/scripts/Makefile.am            |  5 +++++
  gfs2/scripts/gfs2_wd_udev.sh        | 30 ++++++++++++++++++++++++++++++
  4 files changed, 46 insertions(+)

create mode 100644 gfs2/scripts/82-gfs2-withdraw.rules create mode 100755 gfs2/scripts/gfs2_wd_udev.sh

README.build +9 -0
index f4ebe53..6487bae 100644
@@ -29,5 +29,14 @@ To install gfs2-utils, run:
 
      make install
 
+The following scripts (located in gfs2/scripts) are used to complete
+the userland portion of the gfs2 withdraw feature using uevents. They
+are not installed by 'make install' and need to be installed manually
+or during rpm installation to the corresponding locations.
+
+	82-gfs2-withdraw.rules in /etc/udev/rules.d/
+	gfs2_wd_udev.sh        in /usr/sbin/
+
  See also doc/README.contributing for details on submitting patches and
  doc/README.tests for more details regarding the test suite.
+
gfs2/scripts/82-gfs2-withdraw.rules new file +2 -0
new file mode 100644
index 0000000..2228615
@@ -0,0 +1,2 @@
+SUBSYSTEM=="gfs2", ACTION=="offline", RUN+="/bin/sh /usr/sbin/gfs2_wd_udev.sh"
+
gfs2/scripts/Makefile.am +5 -0
index 62fb2fe..dde906f 100644
@@ -3,3 +3,8 @@ MAINTAINERCLEANFILES = Makefile.in
  dist_sbin_SCRIPTS = \
  	gfs2_lockcapture \
  	gfs2_trace
+
+noinst_SCRIPTS = \
+	82-gfs2-withdraw.rules \
+	gfs2_wd_udev.sh
+
gfs2/scripts/gfs2_wd_udev.sh new file +30 -0
new file mode 100755
index 0000000..ac3ce35
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Do not run this script manually. This script is called by udev on a gfs2
+# withdraw uevent and is used to complete the withdraw action and notify the
+# kernel.
+#
+
+# Sanity checks
+if [ "$SUBSYSTEM" != "gfs2" ] || [ "$LOCKPROTO" != "lock_dlm" ] ||
+       [ -z "$DEVPATH" ] || [ "$ACTION" != "offline" ]
+then
+    exit 1 # Nothing to do here
+fi
+
+# Try and suspend the device
+SYSFS_TOPDIR="/sys"$DEVPATH
+DM_NAME=$(cat "$SYSFS_TOPDIR/device/dm/name")
+DM_DEV="/dev/mapper/"$DM_NAME
+
+if [ -z "$DM_DEV" ]
+then
+    /usr/bin/dmsetup suspend $DM_DEV
+fi
+
+# Signal completion of withdraw
+WD_ACK="$SYSFS_TOPDIR/lock_module/withdraw"
+if [ -f "$WD_ACK" ]
+then
+    echo "1" > $WD_ACK
+fi