Bug 124901 - [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
Summary: [patch] sysutils/fusefs-kmod dataloss on write shortly before shutdown
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Stefan Walter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-23 07:30 UTC by kamikaze
Modified: 2008-12-12 15:20 UTC (History)
0 users

See Also:


Attachments
file.diff (757 bytes, patch)
2008-06-23 07:30 UTC, kamikaze
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kamikaze 2008-06-23 07:30:01 UTC
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.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-06-23 07:30:05 UTC
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
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2008-06-23 07:30:07 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Stefan Walter freebsd_committer freebsd_triage 2008-10-10 14:38:25 UTC
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
Comment 4 Stefan Walter freebsd_committer freebsd_triage 2008-10-10 14:39:36 UTC
Responsible Changed
From-To: freebsd-ports-bugs->stefan

Take.
Comment 5 amistry 2008-10-11 23:25:05 UTC
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=ports/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.


-- 
Anish Mistry
Comment 6 Stefan Walter freebsd_committer freebsd_triage 2008-10-14 13:22:50 UTC
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=ports/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
Comment 7 amistry 2008-10-19 11:20:30 UTC
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=ports/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=ports/124901

-- 
Anish Mistry
Comment 8 Stefan Walter freebsd_committer freebsd_triage 2008-12-10 10:48:17 UTC
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
Comment 9 kamikaze 2008-12-12 11:22:24 UTC
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"
Comment 10 dfilter service freebsd_committer freebsd_triage 2008-12-12 15:11:00 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"
Comment 11 Stefan Walter freebsd_committer freebsd_triage 2008-12-12 15:12:32 UTC
State Changed
From-To: feedback->closed

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.