chiark / gitweb /
rsync-backup.in: Retry unmounting snapshot filesystems a few times.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 29 Jun 2015 09:45:53 +0000 (10:45 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 30 Jun 2015 08:35:35 +0000 (09:35 +0100)
Not quite sure what's making this fail, but it's happening annoyingly
frequently.

rsync-backup.in

index b0c4086ed18d8ec6d48292a6148bb4a17044d67e..a48d58ac368825959ade894986c3e9c2da889964 100644 (file)
@@ -308,9 +308,21 @@ unsnap_lvm () {
   vg=$1 lv=$2
 
   ## Remove the snapshot.  Sometimes LVM doesn't notice that the snapshot is
-  ## no longer in open immdiately, so try several times.
+  ## no longer in open immdiately, so try several times.  Sometimes, more
+  ## mysteriously, something is keeping the filesystem from being unmounted,
+  ## so try that several times and report on things keeping the filesystem
+  ## open.
   hostrun "unsnap-lvm $vg/$lv" "
-       umount $SNAPDIR/$lv
+       for i in 1 2 3 4; do
+         echo \";;; BEGIN fuser -mv $SNAPDIR/$lv\"
+         fuser -mv $SNAPDIR/$lv | sed 's/^/;;; /'
+         echo \";;; END fuser -mv $SNAPDIR/$lv\"
+         echo \";;; BEGIN lsof $SNAPDIR/$lv\"
+         lsof $SNAPDIR/$lv | sed 's/^/;;; /'
+         echo \";;; END lsof $SNAPDIR/$lv\"
+         if umount $SNAPDIR/$lv; then break; fi
+         sleep 2
+       done
        rc=1
        for i in 1 2 3 4; do
          if lvremove -f $vg/$lv.bkp; then rc=0; break; fi