Openembedded Devel Discussions
 help / color / mirror / Atom feed
From: Koen Kooi <k.kooi@student.utwente.nl>
To: openembedded-devel@lists.openembedded.org
Subject: Re: [PATCH] udev/mount.sh: try to kill active processes before umount
Date: Tue, 22 Jun 2010 13:02:30 +0200	[thread overview]
Message-ID: <hvq586$1jc$1@dough.gmane.org> (raw)
In-Reply-To: <1277201329-1339-1-git-send-email-sledz@dresearch.de>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wouldn't a umount -l be a lot better in this case?

On 22-06-10 12:08, Steffen Sledz wrote:
> * umount will fail if there are processes accessing files at the
>   device. Therefor try to kill these processes using fuser if
>   available.
> 
> Signed-off-by: Steffen Sledz <sledz@dresearch.de>
> ---
>  recipes/udev/files/mount.sh        |   21 ++++++++++++++++++++-
>  recipes/udev/files/slugos/mount.sh |   21 ++++++++++++++++++++-
>  2 files changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/recipes/udev/files/mount.sh b/recipes/udev/files/mount.sh
> index be8b3df..79c6891 100644
> --- a/recipes/udev/files/mount.sh
> +++ b/recipes/udev/files/mount.sh
> @@ -8,6 +8,7 @@
>  MOUNT="/bin/mount"
>  PMOUNT="/usr/bin/pmount"
>  UMOUNT="/bin/umount"
> +FUSER="/usr/bin/fuser"
>  name="`basename "$DEVNAME"`"
>  
>  for line in `cat /etc/udev/mount.blacklist | grep -v ^#`
> @@ -64,7 +65,25 @@ fi
>  if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
>  	for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
>  	do
> -		$UMOUNT $mnt
> +		if [ -x "$FUSER" ]; then
> +			$FUSER -k -KILL -m $mnt
> +			for try in `seq 10`
> +			do
> +				$FUSER -m $mnt || break
> +				sleep 1
> +				logger "mount.sh/automount" "$try secs waited for processes active at $mnt to finish on SIGKILL"
> +			done
> +
> +			if $FUSER -m $mnt 
> +			then
> +				logger "mount.sh/automount" "Could not kill all processes using files at $mnt, try forced umount"
> +				$UMOUNT -f $mnt
> +			else
> +				$UMOUNT $mnt
> +			fi
> +		else
> +			$UMOUNT $mnt
> +		fi
>  	done
>  	
>  	# Remove empty directories from auto-mounter
> diff --git a/recipes/udev/files/slugos/mount.sh b/recipes/udev/files/slugos/mount.sh
> index 0990a7e..f67c3ff 100644
> --- a/recipes/udev/files/slugos/mount.sh
> +++ b/recipes/udev/files/slugos/mount.sh
> @@ -8,6 +8,7 @@
>  MOUNT="/bin/mount"
>  PMOUNT="/usr/bin/pmount"
>  UMOUNT="/bin/umount"
> +FUSER="/usr/bin/fuser"
>  name="`basename "$DEVNAME"`"
>  
>  if ( blkid "$DEVNAME" | grep -q 'TYPE="mdraid"' )
> @@ -75,7 +76,25 @@ fi
>  if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
>  	for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
>  	do
> -		$UMOUNT $mnt
> +		if [ -x "$FUSER" ]; then
> +			$FUSER -k -KILL -m $mnt
> +			for try in `seq 10`
> +			do
> +				$FUSER -m $mnt || break
> +				sleep 1
> +				logger "mount.sh/automount" "$try secs waited for processes active at $mnt to finish on SIGKILL"
> +			done
> +
> +			if $FUSER -m $mnt 
> +			then
> +				logger "mount.sh/automount" "Could not kill all processes using files at $mnt, try forced umount"
> +				$UMOUNT -f $mnt
> +			else
> +				$UMOUNT $mnt
> +			fi
> +		else
> +			$UMOUNT $mnt
> +		fi
>  	done
>  	
>  	# Remove empty directories from auto-mounter

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFMIJhGMkyGM64RGpERAo+WAJsEfFfYOKZzeSChA8FBf6SmLSlEbgCdHP2z
d2kNPcFp4RiRHac8Zqh8Hb4=
=HT9O
-----END PGP SIGNATURE-----




  reply	other threads:[~2010-06-22 11:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-22 10:08 [PATCH] udev/mount.sh: try to kill active processes before umount Steffen Sledz
2010-06-22 11:02 ` Koen Kooi [this message]
2010-06-22 12:01   ` Steffen Sledz
2010-06-22 14:29     ` Koen Kooi
2010-06-22 19:11       ` John Willis
2010-06-23  6:13         ` Steffen Sledz
2010-06-22 20:54     ` Phil Blundell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='hvq586$1jc$1@dough.gmane.org' \
    --to=k.kooi@student.utwente.nl \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox