From nobody@FreeBSD.org  Mon Jun 23 06:23:39 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 24E161065687
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 06:23:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 147D48FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 06:23:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m5N6NcHm091420
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 06:23:38 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m5N6NcZC091413;
	Mon, 23 Jun 2008 06:23:38 GMT
	(envelope-from nobody)
Message-Id: <200806230623.m5N6NcZC091413@www.freebsd.org>
Date: Mon, 23 Jun 2008 06:23:38 GMT
From: Dominic Fandrey <kamikaze@bsdforen.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: amistry@am-productions.biz

>Number:         124901
>Category:       ports
>Synopsis:       [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    stefan
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 23 06:30:01 UTC 2008
>Closed-Date:    Fri Dec 12 15:14:08 UTC 2008
>Last-Modified:  Fri Dec 12 15:20:02 UTC 2008
>Originator:     Dominic Fandrey
>Release:        RELENG_7
>Organization:
private
>Environment:
FreeBSD mobileKamikaze.norad 7.0-STABLE FreeBSD 7.0-STABLE #1: Sat Jun  7 14:00:26 CEST 2008     root@mobileKamikaze.norad:/usr/obj/HP6510b/amd64/usr/src/sys/HP6510b  amd64
>Description:
As described in ports/122907 fusefs keeps a lot of things in memory and only writes them back when a filsystem is unmounted. During shutdown the time to write things back is often not sufficient, hence the shutdown script contains code that is meant to stall shutdown until the writing back is finished (this is detected by trying to unload the fusefs kernel module).

Unfortunately the script is often shot down by the shutdown watchdog (see rc.shutdown).
>How-To-Repeat:
Do some heavy writing on a fusefs file system, like ntfs-3g and shutdown immediately afterwards. You'll see the watchdog kill the shutdown process and some of the files will definitely not be there any more upon the next boot. The file system will be in requirement of a file system check.
>Fix:
diff -Pur ports/sysutils/fusefs-kmod.orig/files/fusefs.in ports/sysutils/fusefs-kmod/files/fusefs.in
--- ports/sysutils/fusefs-kmod.orig/files/fusefs.in	2008-06-22 21:35:27.000000000 +0200
+++ ports/sysutils/fusefs-kmod/files/fusefs.in	2008-06-22 21:44:34.000000000 +0200
@@ -50,9 +50,18 @@
 			;;
 		esac
 	done
+
+	# This is an evil yet necessary hack to give fuse the time to
+	# write all data to the media before the system is shut down.
+	if [ -n "$rcshutdown_timeout" -a -n "$_rcshutdown_watchdog" ]; then
+		/bin/kill -STOP "$_rcshutdown_watchdog"
+	fi
 	until kldunload $kmod; do
 		/bin/sleep 0.25
 	done
+	if [ -n "$rcshutdown_timeout" -a -n "$_rcshutdown_watchdog" ]; then
+		/bin/kill -CONT "$_rcshutdown_watchdog"
+	fi
 }
 load_rc_config $name
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Mon Jun 23 06:30:07 UTC 2008 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124901 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: amistry@am-productions.biz
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
Date: Mon, 23 Jun 2008 06:30:05 UT

 Maintainer of sysutils/fusefs-kmod,
 
 Please note that PR ports/124901 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/124901
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org
Responsible-Changed-From-To: freebsd-ports-bugs->stefan 
Responsible-Changed-By: stefan 
Responsible-Changed-When: Fri Oct 10 13:39:36 UTC 2008 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124901 

From: Stefan Walter <stefan@freebsd.org>
To: amistry@am-productions.biz
Cc: Dominic Fandrey <kamikaze@bsdforen.de>,
	GNATS <FreeBSD-gnats-submit@FreeBSD.org>
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write
	shortly before shutdown
Date: Fri, 10 Oct 2008 15:38:25 +0200

 --oJ71EGRlYNjSvfq7
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi,
 
 how long does the shutdown procedure take? Wouldn't it be feasible/a
 better solution to set rcshutdown_timeout in /etc/rc.conf? If not: Anish,
 is it OK to commit this patch [1]?
 
 Best regards,
 Stefan
 
 [1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/124901
 
 --oJ71EGRlYNjSvfq7
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iQGVAwUBSO9a0VaRERsSueCzAQKodwwAnnYHQOcIFfIZQtsouPuw+Wwk/q4Fuae+
 m+hoXSemtGXoA904NUfX525TOk1XNS0jpXm2L3bUgNYYLxwWZ3LUK40F16ZEReoc
 YdvbJlhOE87MXXMfLL9P1EvsUoA+Zkzu0pnSV2kGACIRki4mOt2F//c4VvyHIeZJ
 ZF+hQobuR2Ro1lRN03Jusqp7tQPDfrS+pXmwsDXlANAv33+99hZCaFvGqKw5J6ms
 kwoSh/9hk3lYrPb58+1QiRtnAXxa9HgYWNv7ekTzIeobJ7SIbUMiU6x0LQX/1oBW
 X8OMNFr3Tam5SJy8BjX+bIaEk0yZaJewJ1aOSjdeswKbM/kykSZRZKo3CSfImbh3
 nHwyFADRjofuFsJrlh0U7sTBp7FsehOf28cSPW40iOok1yytUJBAD4YJRjMwjSUl
 EmqyGOhDtaK4uf0+MworKQFs1PVUyOE2fLT+nqHZQD5QKu7wZrV7KhsIg3BgkEYK
 W0OgnD2SYiWbcD4xOb6qzamGda1e092e
 =Fe8M
 -----END PGP SIGNATURE-----
 
 --oJ71EGRlYNjSvfq7--

From: Anish Mistry <amistry@am-productions.biz>
To: Stefan Walter <stefan@freebsd.org>
Cc: Dominic Fandrey <kamikaze@bsdforen.de>,
        GNATS <FreeBSD-gnats-submit@freebsd.org>
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
Date: Sat, 11 Oct 2008 18:25:05 -0400

 --nextPart3318672.rGoqPBbNTl
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 On Friday 10 October 2008, Stefan Walter wrote:
 > Hi,
 >
 > how long does the shutdown procedure take? Wouldn't it be feasible/a
 > better solution to set rcshutdown_timeout in /etc/rc.conf? If not: Anish,
 > is it OK to commit this patch [1]?
 >
 > Best regards,
 > Stefan
 >
 > [1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/124901
 I still don't think this is the right way to do it.  It really needs to be=
 =20
 fixed in the module, but if it works for some people then make it a=20
 configurable knob that they can enable for them.
 
 
 =2D-=20
 Anish Mistry
 
 --nextPart3318672.rGoqPBbNTl
 Content-Type: application/pgp-signature; name=signature.asc 
 Content-Description: This is a digitally signed message part.
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.9 (FreeBSD)
 
 iEYEABECAAYFAkjxJ8EACgkQxqA5ziudZT2QAwCfeM3mUZaF/8K/JaZrJLA+WGnP
 cfIAn30IXS5pncajP5iglIuj56bEZarU
 =0NJM
 -----END PGP SIGNATURE-----
 
 --nextPart3318672.rGoqPBbNTl--

From: Stefan Walter <stefan@freebsd.org>
To: Anish Mistry <amistry@am-productions.biz>
Cc: Dominic Fandrey <kamikaze@bsdforen.de>,
	GNATS <FreeBSD-gnats-submit@freebsd.org>
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write
	shortly before shutdown
Date: Tue, 14 Oct 2008 14:22:50 +0200

 --NMuMz9nt05w80d4+
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Anish Mistry, 12.10.08, 00:25h CEST:
 
 > On Friday 10 October 2008, Stefan Walter wrote:
 > > Hi,
 > >
 > > how long does the shutdown procedure take? Wouldn't it be feasible/a
 > > better solution to set rcshutdown_timeout in /etc/rc.conf? If not: Anis=
 h,
 > > is it OK to commit this patch [1]?
 > >
 > > Best regards,
 > > Stefan
 > >
 > > [1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/124901
 > I still don't think this is the right way to do it.  It really needs to b=
 e=20
 > fixed in the module, but if it works for some people then make it a=20
 > configurable knob that they can enable for them.
 
 I agree that this issue looks like it should be fixed upstream. Does the
 author know about it? (A quick glance over the project's mailing list
 revealed nothing to me.)
 
 Best regards,
 Stefan
 
 --NMuMz9nt05w80d4+
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iQGVAwUBSPSPGlaRERsSueCzAQKg9Av9FfYhAI2CbVgpbdsjXVh7RhX/GenOwL9T
 hAf8NHhb5mGQgXZid8ZkLTiuV3kVO+6GydGjRpZB+jjJkUdd4qiw1GNUmZWWRGtY
 97J1tGaHmq5yhRSh1MmBucw70NCaPFvJM75xI9q03cA2LIBE/QUc8Vmw6k6z/xOE
 /NszOET+dLksBzFzElRVcUmy45aCrATEbo+hB8xHadSg9wrp3ubh42cAJQg1prVP
 J23f+bFoep8ZDCEhQqCzxK1xWvoO0tOYTCgu678IaGwkTBxiqn1jcZWXFjpJkiuK
 acULrRft9EcJBBE7d6uWuuHe7xiiy/hm9HPuiSaAww9LOUvLGZVGe5tHbDPB6n+c
 tkvunWNLBUd0sRPItuKnlt+6vniQt0df/FPNRyzwKBo/FooLxJBMf3j5u8XX+ffD
 pTx7DPNsNI+8yVBcg/WaikSy58wyuekoTuZx8RIXsZ35bBnXDgs+Z0gDWeAn4Rl9
 v6uy8CKACBIc2WuWYmwlOS9IS5QZBP0+
 =NZpI
 -----END PGP SIGNATURE-----
 
 --NMuMz9nt05w80d4+--

From: Anish Mistry <amistry@am-productions.biz>
To: Stefan Walter <stefan@freebsd.org>
Cc: Dominic Fandrey <kamikaze@bsdforen.de>,
        GNATS <FreeBSD-gnats-submit@freebsd.org>, csaba.henk@creo.hu
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
Date: Sun, 19 Oct 2008 06:20:30 -0400

 --nextPart1797099.Hi4HoJjzOJ
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 On Tuesday 14 October 2008, Stefan Walter wrote:
 > Anish Mistry, 12.10.08, 00:25h CEST:
 > > On Friday 10 October 2008, Stefan Walter wrote:
 > > > Hi,
 > > >
 > > > how long does the shutdown procedure take? Wouldn't it be feasible/a
 > > > better solution to set rcshutdown_timeout in /etc/rc.conf? If not:
 > > > Anish, is it OK to commit this patch [1]?
 > > >
 > > > Best regards,
 > > > Stefan
 > > >
 > > > [1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/124901
 > >
 > > I still don't think this is the right way to do it.  It really needs to
 > > be fixed in the module, but if it works for some people then make it a
 > > configurable knob that they can enable for them.
 >
 > I agree that this issue looks like it should be fixed upstream. Does the
 > author know about it? (A quick glance over the project's mailing list
 > revealed nothing to me.)
 >
 > Best regards,
 > Stefan
 Csaba,
 	Have you take a look at this:
 http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/124901
 
 =2D-=20
 Anish Mistry
 
 --nextPart1797099.Hi4HoJjzOJ
 Content-Type: application/pgp-signature; name=signature.asc 
 Content-Description: This is a digitally signed message part.
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.9 (FreeBSD)
 
 iEYEABECAAYFAkj7Ce4ACgkQxqA5ziudZT0CaACdHIgFghA7l6rUNOXLqvPAQG9Q
 8vwAn3vrjkqnXbfFyCdC6XPVtwXmN+kK
 =cdM1
 -----END PGP SIGNATURE-----
 
 --nextPart1797099.Hi4HoJjzOJ--

From: Stefan Walter <stefan@FreeBSD.org>
To: Dominic Fandrey <kamikaze@bsdforen.de>
Cc: Anish Mistry <amistry@am-productions.biz>,
	GNATS <FreeBSD-gnats-submit@FreeBSD.org>
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write
	shortly before shutdown
Date: Wed, 10 Dec 2008 11:48:17 +0100

 Hi Dominic,
 
 sorry for the delay, I've been abroad for a couple of weeks and then busy
 with lots of non-FreeBSD stuff recently.
 
 Since there hasn't been any response by the author, yet, and Anish seems
 to think it's OK to use your solution until the issue is fixed in the code
 itself, could you provide a new patch that adds a knob to switch it
 on/off? (Default should be off as Anish stated.) I'll commit it, then.
 
 Regards,
 Stefan

From: Dominic Fandrey <kamikaze@bsdforen.de>
To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de
Cc:  
Subject: Re: ports/124901: [patch] sysutils/fusefs-kmod dataloss on write
 shortly before shutdown
Date: Fri, 12 Dec 2008 12:22:24 +0100

 Here is my evil patch. I hope this will satisfy everyone.
 I had to switch to a force unmount or the stop process was likely
 to never terminate, with the watchdog paused and eternally trying
 to unload the module.
 
 diff -Pur ports/sysutils/fusefs-kmod.orig/files/fusefs.in ports/sysutils/fusefs-kmod/files/fusefs.in
 --- ports/sysutils/fusefs-kmod.orig/files/fusefs.in	2008-12-12 11:36:44.000000000 +0100
 +++ ports/sysutils/fusefs-kmod/files/fusefs.in	2008-12-12 12:15:20.000000000 +0100
 @@ -13,6 +13,14 @@
  # fusefs_enable (bool):		Set to NO by default.
  #				Set it to YES to enable fusefs.
  #
 +# fusefs_safe (bool):		Set to NO by default.
 +#				Set it to YES to wait for all write operations
 +#				to finish before terminating.
 +#
 +# fusefs_safe_evil (bool):	Set to NO by default.
 +#				Set it to YES to pause the watchdog timer
 +#				while waiting for write operations.
 +#
  
  . %%RC_SUBR%%
  
 @@ -46,14 +54,36 @@
  		case "$dev" in
  		/dev/fuse[0-9]*)
  			echo "fusefs: unmounting ${mountpoint}."
 -			umount $mountpoint
 +			umount -f $mountpoint
  			;;
  		esac
  	done
 -	kldunload $kmod
 +	if checkyesno "${name}_safe_evil"; then
 +		if [ -n "$_rcshutdown_watchdog" ]; then
 +			echo "fusefs: pausing watchdog timer."
 +			kill -STOP "$_rcshutdown_watchdog"
 +		fi
 +	fi
 +	if checkyesno "${name}_safe"; then
 +		printf "fusefs: unloading $kmod... "
 +		while ! kldunload $kmod 2> /dev/null; do
 +			sleep 0.25
 +		done
 +		echo "done."
 +	else
 +		kldunload $kmod
 +	fi
 +	if checkyesno "${name}_safe_evil"; then
 +		if [ -n "$_rcshutdown_watchdog" ]; then
 +			echo "fusefs: continuing watchdog timer."
 +			kill -CONT "$_rcshutdown_watchdog"
 +		fi
 +	fi
  }
  load_rc_config $name
  
  : ${fusefs_enable="NO"}
 +: ${fusefs_safe="NO"}
 +: ${fusefs_safe_evil="NO"}
  
  run_rc_command "$1"
State-Changed-From-To: feedback->closed 
State-Changed-By: stefan 
State-Changed-When: Fri Dec 12 15:12:32 UTC 2008 
State-Changed-Why:  
Patch committed, thanks! It would probably be a good idea to discuss this 
problem with the software's author, though, so it can eventually be fixed 
upstream. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124901 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/124901: commit references a PR
Date: Fri, 12 Dec 2008 15:11:00 +0000 (UTC)

 stefan      2008-12-12 15:10:52 UTC
 
   FreeBSD ports repository
 
   Modified files:
     sysutils/fusefs-kmod Makefile 
     sysutils/fusefs-kmod/files fusefs.in 
   Log:
   Add knobs to the rc.d script to safely wait until all data has been written on
   shutdown. (As this implies pausing rc.shutdown's shutdown watchdog, the knobs
   are off by default.)
   
   PR:             124901
   Submitted by:   Dominic Fandrey <kamikaze@bsdforen.de>
   Approved by:    maintainer
   
   Revision  Changes    Path
   1.25      +1 -1      ports/sysutils/fusefs-kmod/Makefile
   1.7       +33 -3     ports/sysutils/fusefs-kmod/files/fusefs.in
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
