Bug 567865

Summary: Shutdown hangs on stopping smbfs after NetworkManager was killed
Product: [openSUSE] openSUSE 11.2 Reporter: Diederik van der Boor <vdboor-fora>
Component: BasesystemAssignee: E-mail List <bnc-team-screening>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: chris, forgotten_--EoyBps8f, mt, rainer.klier, samba-maintainers
Version: Final   
Target Milestone: ---   
Hardware: i686   
OS: openSUSE 11.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Diederik van der Boor 2010-01-01 18:21:34 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; nl; rv:1.9.1.6) Gecko/20091201 SUSE/3.5.6-1.1.1 Firefox/3.5.6

The shutdown of openSUSE 11.2 is delayed by a few minutes when SMB shares are mounted.

Reproducible: Always

Steps to Reproduce:
- Have a wifi connection with NetworkManager.
- Have shares in /etc/samba/smbfstab.
- /etc/init.d/smbfs start
- /etc/init.d/network stop
Actual Results:  
NetworkManager is killed first (so the wlan connection is lost), and next it tries to unmount the shares of /etc/samba/smbfstab with the script from /etc/sysconfig/network/if-down.d/21-smbfs script. This hangs for a few minutes.

Expected Results:  
- The smbfs script to run first for normal situations.
- The smbfs script to quickly unmount when the network is unreachable.
Comment 1 Lars Müller 2010-01-04 09:58:57 UTC
The INIT INFO part of the smbfs (cifs for post 11.2 systems) ensures the network get started before and stopped after the smbfs or cifs service.

Please check the order of the symbolic links named /etc/init.d/rc*.d/K*

On a 11.2 system I see for example:

gab:~ # ls -l /etc/init.d/rc5.d/K*{smbfs,network}
lrwxrwxrwx 1 root root  8  4. Jan 10:44 /etc/init.d/rc5.d/K05smbfs -> ../smbfs
lrwxrwxrwx 1 root root 10 11. Nov 20:09 /etc/init.d/rc5.d/K08network -> ../network

or on Factory it's:

giles:~ # ls -l /etc/init.d/rc5.d/K*{cifs,network}
lrwxrwxrwx 1 root root  7  4. Jan 10:52 /etc/init.d/rc5.d/K01cifs -> ../cifs
lrwxrwxrwx 1 root root 10  2. Nov 16:56 /etc/init.d/rc5.d/K08network -> ../network

In both cases the order of the symbolic links is correct.

Please keep in mind that the actual values following the K might be different on your system as they are calculated dynamically.

I fear that we here face an issue of NetworkManager (NM).  NM might get stopped by the X11 session (KDE or Gnome for example) as the user decided to log off.

@Diederik: Please check the values of the symbolic links.  If they fit to the explanation offered here we have to consult the NM maintainer next.
Comment 2 Christian Wittmer 2010-01-12 23:01:01 UTC
Hi,

smbfs is failing on shutdown because:
- Networkmanager ist stopped before smbfs
- network-remotefs is stoped before smbfs

lape:/etc/init.d/rc3.d # ls -1
K01auditd
K01bluez-coldplug
K01courier-authdaemon
K01cron
K01fam
K01irq_balancer
K01nscd
K01random
K01smartd
K01splash
K01splash_early
K01sshd
K01stoppreload
K01SuSEfirewall2_setup
K01xinetd
K02acpid
K02alsasound
K02avahi-daemon
K02courier-imap
K02cups
K02fbset
K02kbd
K02postfix
K03network-remotefs
K04haldaemon
K04nfs
K04smbfs
K05rpcbind
K06syslog
K07earlysyslog
K07network

I think network-remotefs and NetworkManager should be stopped after smbfs.
Chris
Comment 3 Christian Wittmer 2010-01-12 23:36:19 UTC
Solution that works:

lape:/etc/init.d # diff -ruN ~/network-remotefs network-remotefs 
--- /root/network-remotefs      2009-12-18 01:47:48.000000000 +0100
+++ network-remotefs    2010-01-13 00:20:56.000000000 +0100
@@ -26,9 +26,9 @@
 #
 ### BEGIN INIT INFO
 # Provides:            network-remotefs
-# Required-Start:      $network $remote_fs haldaemon
+# Required-Start:      $network haldaemon
 # Should-Start:
-# Required-Stop:       $network $remote_fs haldaemon
+# Required-Stop:       $network haldaemon
 # Should-Stop:
 # Default-Start:       2 3 5
 # Default-Stop:

and

lape:/etc/init.d # diff -ruN ~/smbfs smbfs
--- /root/smbfs 2009-10-27 09:16:52.000000000 +0100
+++ smbfs       2010-01-13 00:21:17.000000000 +0100
@@ -25,9 +25,9 @@
 #
 ### BEGIN INIT INFO
 # Provides:       smbfs
-# Required-Start: $network $syslog
+# Required-Start: $network $syslog network-remotefs
 # Should-Start:   nmb
-# Required-Stop:  $network $syslog
+# Required-Stop:  $network $syslog network-remotefs
 # Should-Stop:    nmb
 # Default-Start:  3 5
 # Default-Stop:   0 1 2 6

then smbfs is umounted without problem when shutdown.
Chris
Comment 4 Lars Müller 2010-01-13 10:22:49 UTC
Tanks Chris for the input on this.

But wouldn't it fir better to add network-remotefs to Should-Start and Should-Stop?  Only then it#s possible to disable the network-remotefs if it's not needed or the user likes to disable it.
Comment 5 Marius Tomaschewski 2010-01-13 11:23:26 UTC
See also
https://bugzilla.novell.com/show_bug.cgi?id=487190#c7
that seems to provide a workaround setup here for fs != /usr (insserv
-r smbfs, it will get restarted via NM dispatcher).

We have /usr on nfs requirement and the above changes are wrong.

The use of the nfs/smbfs via /etc/init.d/{smbfs,nfs} are not supported
on wlan interfaces (in ifup mode), because the scripts provide /usr
and all wlan utils as well as the NetworkManager itself are installed
in /usr.

The network-remotefs requires $remote_fs, because it is using tools
from /usr, so removing $remote_fs from network-remotefs or adding
network-remotefs to smbfs adding is wrong.
Also adding network-remotefs to Should-Start/Stop in smbfs is wrong.

The /etc/sysconfig/network/if-{down,up}.d/* scripts are called with
the "-o nm" option that can be used e.g. to disable them in NM mode.

I can also disable the execution of the if-{up,down} scripts in NM
mode completely (remove /etc/NetworkManager/dispatcher.d/netcontrol*)
in stable -- I think this makes sense.

Any smbfs or nfs mounts in NetworkManager mode have to be done using
NM mechanisms. See also bug 487190#c7, bug 557836#c3 and bug 557836#c5.
Comment 6 Marius Tomaschewski 2010-01-13 12:12:15 UTC
BTW: See also "man 5 ifservices" - this mechanism is the way in ifup mode.
Comment 7 Rainer Klier 2010-01-13 16:41:08 UTC
yes, Marius is completely right with comment #5.

my workaround for this bug (see bug 487190 comment 9) ONLY works for situations, with the following conditions:
1. /usr is on local disc.
2. NetworkManger is used
3. CIFS shares are used/needed

but in this scenario it works perfectly and solves the problem this bug is all about.

i also tried before to solve the problem with changing dependencies/requirements of the init-scripts, but that did not work properly and is really wrong.
Comment 8 Diederik van der Boor 2010-01-14 20:24:58 UTC
@Lars:
My links are:

$ ls -l /etc/init.d/rc5.d/K*{smbfs,network}
lrwxrwxrwx 1 root root  8 jul 29 12:57 /etc/init.d/rc5.d/K04smbfs -> ../smbfs
lrwxrwxrwx 1 root root 10 jul 29 12:57 /etc/init.d/rc5.d/K07network -> ../network


Actually my network is already closed when I logout of KDE. Plasma gets killed, and so does the KDE network manager applet.
Comment 9 Lars Müller 2010-03-09 12:30:18 UTC
*** Bug 584095 has been marked as a duplicate of this bug. ***
Comment 10 Lars Müller 2010-03-09 12:33:53 UTC
Passing this issue to Suresh, the kernel cifs maintainer.  The mounts.cifs helper applications soon will also get separated from the Samba packages anyhow.
Comment 11 Forgotten User b5BnQSUi71 2010-03-25 12:47:00 UTC
Does the suggestion provided in Comment #5 help?
Comment 12 Forgotten User b5BnQSUi71 2010-03-31 09:36:43 UTC
Ping!
Comment 13 Diederik van der Boor 2010-04-08 08:58:27 UTC
(In reply to comment #12)
> Ping!

Sorry, been away for a while. I don't really get the solution of comment #5, and reading it does not make it sound related to my situation, which is:

- When I boot:
  * once the network is up, /mnt/nas/SomeShare is mounted using /etc/init.d/smbfs
- When I shutdown:
  * KDE exits, the NM applet is killed.
  * Connection is lost, /etc/init.d/smbfs stop does not run yet however.
  * At shutdown, the init scripts try to tear down the smbfs connections.
  * The shutdown procedure waits 2 minutes for a timeout..
Comment 14 Rainer Klier 2010-04-08 09:41:22 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > Ping!
> 
> Sorry, been away for a while. I don't really get the solution of comment #5,
> and reading it does not make it sound related to my situation, which is:
> 
> - When I boot:
>   * once the network is up, /mnt/nas/SomeShare is mounted using
> /etc/init.d/smbfs
> - When I shutdown:
>   * KDE exits, the NM applet is killed.
>   * Connection is lost, /etc/init.d/smbfs stop does not run yet however.
>   * At shutdown, the init scripts try to tear down the smbfs connections.
>   * The shutdown procedure waits 2 minutes for a timeout..

the solution from comment #5 is described in bug 487190#c7.
you should NOT use /etc/init.d/smbfs!
disable it using: insserv -r smbfs

and instead use networkmanager dispatcher script /etc/NetworkManager/dispatcher.d/smbfs.
this script can be made by copying /etc/NetworkManager/dispatcher.d/nfs and changing it.
here it is ready-to-use as attachment from bug 487190:
https://bugzilla.novell.com/attachment.cgi?id=336364

but this only works when:
1. /usr is on local disc.
2. NetworkManger is used

but i assume this is the case for you, Diederik, right?
Comment 15 Diederik van der Boor 2010-04-08 20:20:17 UTC
(In reply to comment #14)
> the solution from comment #5 is described in bug 487190#c7.
> you should NOT use /etc/init.d/smbfs!
> disable it using: insserv -r smbfs
> 
> and instead use networkmanager dispatcher script
> /etc/NetworkManager/dispatcher.d/smbfs.
> this script can be made by copying /etc/NetworkManager/dispatcher.d/nfs and
> changing it.
> here it is ready-to-use as attachment from bug 487190:
> https://bugzilla.novell.com/attachment.cgi?id=336364

I've tried this solution, it merely moves the problem.

Mounting works properly after being connected. Unmounting happens too late.

Unmounting happens when the connection is already closed. For example
 * When selecting a different network to connect to
 * When closing/killing the network manager applet.

So there is a umount.cifs being stale for each of my connected shares. After ~1 minute it's timed out, and the mount is removed. Then it continues with the next mounted share, up till all 5 I have..


> but this only works when:
> 1. /usr is on local disc.
> 2. NetworkManger is used
> 
> but i assume this is the case for you, Diederik, right?

Yes, I'm using a pretty standard openSUSE install on a laptop. Hence the NetworkManager stuff, because I'm mostly connected with WiFi, even at home. Here, I auto-mount my NAS network shares via smbfs/cifs.
Comment 16 Rainer Klier 2010-04-09 06:22:27 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > here it is ready-to-use as attachment from bug 487190:
> > https://bugzilla.novell.com/attachment.cgi?id=336364
> 
> I've tried this solution, it merely moves the problem.
> 
> Mounting works properly after being connected. Unmounting happens too late.
> 
> Unmounting happens when the connection is already closed. For example
>  * When selecting a different network to connect to
>  * When closing/killing the network manager applet.

yes, but these situations are not happening as often as a shutdown.
so it is better to have the timeouts happen in these situations than in a shutdown.

i never noticed the timeouts or too late unmountings since i use the networkmanager-dispatcher-script.

but i usually also don't kill networkmanager during work, nor do i switch networks.

but, of course, the umounts should be done correctly, even if network is switched or networkmanager applet gets killed.

> NetworkManager stuff, because I'm mostly connected with WiFi, even at home.
> Here, I auto-mount my NAS network shares via smbfs/cifs.

and you switch networks at home also?
Comment 17 Forgotten User b5BnQSUi71 2010-04-14 06:24:12 UTC
It appears to me that here cifs cannot do much (without side-effects) and the problem is pretty much the same with other network filesystems. Either Network Manager should handle it, if not we should explain what is possible and close this.
Comment 19 Diederik van der Boor 2010-04-21 14:29:05 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > Unmounting happens when the connection is already closed. For example
> >  * When selecting a different network to connect to
> >  * When closing/killing the network manager applet.
> 
> yes, but these situations are not happening as often as a shutdown.
> so it is better to have the timeouts happen in these situations than in a
> shutdown.

When a shutdown is initiated, the network manager applet is closed once KDE (or GNOME) exists. So for every shutdown, the connection is closed before any init.d script runs.

> > NetworkManager stuff, because I'm mostly connected with WiFi, even at home.
> > Here, I auto-mount my NAS network shares via smbfs/cifs.
> 
> and you switch networks at home also?

Only plugging in an ethernet cable every now and then. I was mainly listing all possible scenario's where the connection is dropped before any unmount script runs.
Comment 20 Rainer Klier 2010-04-21 14:55:48 UTC
(In reply to comment #19)
> (In reply to comment #16)
> > (In reply to comment #15)
> > > Unmounting happens when the connection is already closed. For example
> > >  * When selecting a different network to connect to
> > >  * When closing/killing the network manager applet.
> > 
> > yes, but these situations are not happening as often as a shutdown.
> > so it is better to have the timeouts happen in these situations than in a
> > shutdown.
> 
> When a shutdown is initiated, the network manager applet is closed once KDE (or
> GNOME) exists. So for every shutdown, the connection is closed before any
> init.d script runs.

yes. but that is not a problem any more.
there is no init.d script anymore dealing with smbfs.
because i disabled /etc/init.d/smbfs in rc5.d.
so the only umounting of all the smb/cifs-shares happens, when networkmanager is quit.
and at this time the shares are there and can be umounted.
so no hang or timeout anymore and shares become umounted without any problems.
Comment 21 Xin Li Niu 2010-11-29 08:09:15 UTC
Seems this bug can be closed?
Comment 22 Rainer Klier 2010-11-29 08:47:29 UTC
whould be ok for me.
Comment 23 Andreas Jaeger 2010-12-19 19:00:16 UTC
See comments 21/22 - closing as fixed as suggested