Bug 105799 - Pulseaudio prevents /home from unmounting
Summary: Pulseaudio prevents /home from unmounting
Status: RESOLVED INVALID
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: daemon (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) All
: medium critical
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-29 06:37 UTC by Manco
Modified: 2018-04-04 07:58 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Manco 2018-03-29 06:37:21 UTC
Hi,

I run Fedora 27/28 with Gnome 3.26/3.28 but without gdm (so booting to multi-user.target and starting Gnome with startx). Everything works fine. However whenever I play audio and after that log out to the console again, I see with lsof /home that there are a small number of open files. The only interesting things are the files related to Pulseaudio in my ~/.config/pulse. Pulseaudio is running according to htop. 

So I figure it has something to do with Pulseaudio in my case. When I quit from X11 and do pulseaudio -k and then reboot or shutdown, than no error concerning failed unmounting occurs.

The bug also occurs when playing sound from the console (without X) and quiting that and rebooting after that. Pulseaudio is preventing /home from cleanly unmounting. I am afraid for data corruption if this is not resolved. 

My /home is a simple ext4 (with no encryption) on a different partition on SDA1.

I have spend many hours trying to debug this problem. I have the issue on both of my laptops and my desktop (1 running Fedora 28 and 2 running Fedora 27).

On Fedora 27 the version of Pulseaudio is 11.1-15.fc27. I originally assumed the bug was related to systemd, see this bug where everything is explained in detail (https://github.com/systemd/systemd/issues/6956).
Comment 1 Tanu Kaskinen 2018-03-30 04:38:08 UTC
Try setting "exit-idle-time = 0" in /etc/pulse/daemon.conf. By default there's a 20 second delay after logging out before pulseaudio will exit. There's a fix for this already (won't be released before PulseAudio 13.0, though).
Comment 2 Manco 2018-03-30 08:11:15 UTC
Thank you Tanu

Is it possible that the fix can be backported to 11.1? Pulseaudio 13 seems like a long time :)

For the past two days I have tried solving this issue and it seems impossible. I have tried setting exit-idle-time=0, it doesn't help unforunatly.

Right now I have narrowed down the issue to the following;

If I boot into multi-user.targer and start Pulseaudio either manually or with systemctl --user enable pulseaudio.socket and pulseaudio.service, audio plays fine in the console. Everything is good.

The problem starts when I try to reboot or shutdown after having played some audio. When the audio stops and I reboot/shutdown, I get the error message of failed unmounting /home. This is without first logging out. 

When I do pulseaudio -k or systemctl --user stop pulseaudio.socket and pulseaudio.service BEFORE logging out and then reboot/shutdown, there is no error message.

Rebooting or shutting down when logged out (by pressing the power button or ctrl-alt-delete) sometimes /home fails and sometimes it doesn't.

So bottom line is, playing sound from the console and rebooting does not unmount /home cleanly. I suppose this can lead to data corruption, so this is not good.
Comment 3 Manco 2018-03-30 08:17:01 UTC
BTW another way to see that the problem is Pulseaudio is to start Pulseaudio from multi-user.target and then go to emergency.target.

All user processes will be stopped EXCEPT Pulseaudio, so Pulseaudio stays open somehow and you have to kill it manually.
Comment 4 Felipe Sateler 2018-03-30 12:43:11 UTC
What happens if you add ordering for /home to the user manager?

  systemctl edit user@.service
 
Add the following content to the editor:

  [Unit]
  RequiresMountsFor=/home


I think what happens is that systemd is unmounting /home before trying to shutdown the user manager (and thus pulseaudio).

If this fixes the problem then it needs to get fixed in systemd.
Comment 5 Manco 2018-03-30 15:24:22 UTC
Thank you Felipe!

There is partial succes!

In multi-user.target (so without starting X), the system unmounts /home cleanly. So after playing audio I can reboot/shutdown cleanly.

But when rebooting or shutting down from Gnome, I still get failed unmounting /home. So Gnome must doing something. 

Mind you, I start Gnome from the console (I have set-default multi-user.target) because I don't always need a GUI. In this case I don't use a display manager like GDM, so GDM does not run on my system. 

I have the following in pulseaudio.service (as a user service):

[Unit]
Description=Sound Service
#RequiresMountsFor=/home
StopWhenUnneeded=true

# We require pulseaudio.socket to be active before starting the daemon, because
# while it is possible to use the service without the socket, it is not clear
# why it would be desirable.
#
# A user installing pulseaudio and doing `systemctl --user start pulseaudio`
# will not get the socket started, which might be confusing and problematic if
# the server is to be restarted later on, as the client autospawn feature
# might kick in. Also, a start of the socket unit will fail, adding to the
# confusion.
#
# After=pulseaudio.socket is not needed, as it is already implicit in the
# socket-service relationship, see systemd.socket(5).
Requires=pulseaudio.socket

[Service]
# Note that notify will only work if --daemonize=no
Type=notify
ExecStart=/usr/bin/pulseaudio --daemonize=no --exit-idle-time=0
Restart=on-failure

[Install]
Also=pulseaudio.socket
WantedBy=default.target

And the following in pulseaudio.socket:

[Unit]
Description=Sound System

[Socket]
Priority=6
Backlog=5
ListenStream=%t/pulse/native

[Install]
WantedBy=sockets.target
Comment 6 Manco 2018-03-30 15:52:57 UTC
BTW I just tried removing /etc/xdg/autostart/pulseaudio.desktop and /usr/bin/start-pulseaudio-x11 and see if Gnome autostarting Pulseaudio is a problem when shutting down.

It didn't help. Pulseaudio was loaded via the systemd user service, but still when rebooting or shutting from Gnome causes failed unmounting /home

So at this point, I have run out of options :)
Comment 7 Manco 2018-04-04 07:01:27 UTC
I'm so stupid....I just found out what was causing this bug.

I had noauto,x-systemd.automount as one of the mount option for /home in my fstab. I added this line to all my systems to improve (at least I thought it would improve) boot times. It didn't improve boot times, but I also forgot to remove it.

Somehow between Fedora 25 and Fedora 26 this bug came up. It seems that Pulseaudio does not like the mount option noauto,x-systemd.automount. I just removed the mount option on all my systems and the bug (seems) gone!

So in the end, this bug can be closed. @Tanu and @Felipe, I am sorry I wasted your time.
Comment 8 Tanu Kaskinen 2018-04-04 07:58:22 UTC
(In reply to Manco from comment #7)
> So in the end, this bug can be closed.

OK, I'll close this. I don't understand why PulseAudio is preventing /home from unmounting if x-systemd.automount is used, but I'm not keen on finding out myself. If someone finds out that it's a fault of PulseAudio, feel free to reopen.

> @Tanu and @Felipe, I am sorry I wasted your time.

It happens, no problem.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.