Skip to content

Conversation

@Victrid
Copy link
Contributor

@Victrid Victrid commented May 24, 2025

What problem are we solving?

Currently, weed does not work well with systemd-based mount, including systemd-fstab-generator and systemd.mount/systemd.automount:
https://github.com/seaweedfs/seaweedfs/wiki/fstab/948a70df5c0d9d2d27561b96de53bde07a29d2db

The previous PR #6809 has fixed the problem quote

No matter what systemd options (nofail, x-systemd.device-timeout, x-systemd.mount-timeout, etc.) you add to /etc/fstab, you won’t be able to make systemd.mount(5) handle the mount properly. You will always get an error when starting mount unit, even though the filesystem ends up being mounted.

and this PR fixes others, making such as _netdev, systemd-fstab-generator, and x-systemd.automount to work again.

How are we solving the problem?

x-systemd.automount don't work because automount will mount a autofs to be a placeholder and triggering the actual mount over the same mountpoint when being accessed.
e.g.

systemd-1 on /home/victrid/packages type autofs (rw,relatime,fd=114,uid=1000,gid=1000,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=66576660)
127.0.0.1:6001:/buckets/packages/ on /home/victrid/packages type fuse.seaweedfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=1048576)

The default behavior throws error when mountpoint is occupied. We added an ignoreMounted field to change the behavior and should be specified in fstab/systemd.mount if used along with systemd automount.

The _netdev is removed from command line, as:

The _netdev results in errors like:

kernel: fuse: Unknown parameter '_netdev'

p.s. Not sure if it’s related. (systemd 255.6)

while _netdev itself is used to make the mount unit belongs to remote-fs.target (otherwise it belongs to local-fs.target) and we can't remove them from mount options. The weed fuse command will remove it as it will have no effect when fuse takes place.

We also changed the signal handling on SIGINT/SIGCHLD and file descriptor inheriting to improve debugging.

How is the PR tested?

We test them on an Archlinux system which uses systemd-based mounting system.

Testing systemd automount

We mount it with the following /etc/fstab entry:

fuse /home/victrid/packages weed rw,noauto,_netdev,x-systemd.mount-timeout=120,x-systemd.automount,x-systemd.idle-timeout=300,filer='127.0.0.1:6001',filer.path=/buckets/packages/,ignoreMounted 0 0

which in turn generates following systemd unit:

# Automatically generated by systemd-fstab-generator

[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
Before=remote-fs.target

[Mount]
What=fuse
Where=/home/victrid/packages
Type=weed
TimeoutSec=2min
Options=rw,noauto,_netdev,x-systemd.mount-timeout=120,x-systemd.automount,x-systemd.idle-timeout=300,filer='127.0.0.1:6001',filer.path=/buckets/packages/,ignoreMounted
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Automount]
Where=/home/victrid/packages
TimeoutIdleSec=5min

This is also tested with static mount/automount unit files:

[Unit]
After=weed-filer.service

[Mount]
What=fuse
Where=/home/victrid/packages
Type=weed
Options=rw,filer='127.0.0.1:6001',filer.path=/buckets/packages/,ignoreMounted
TimeoutSec=30
[Automount]
Where=/home/victrid/packages
TimeoutIdleSec=30
Testing booting with fstab and systemd-fstab-generator

We mount it with the following /etc/fstab entry:

fuse /home/victrid/packages weed rw,_netdev,x-systemd.mount-timeout=120,x-systemd.after=weed-filer.service,filer='127.0.0.1:6001',filer.path=/buckets/packages/,ignoreMounted 0 0

and boots correctly.

Checks

  • I have added unit tests if possible.
  • I will add related wiki document changes and link to this PR after merging.

Including:

- Add option allowing mounting onto existing mount point.
- Strip `_netdev` option if `mount` can't do the job.
- Handle other unhealthy signals in master process management
- Attach our stdin/out to child process for better problem hinting.
@Victrid
Copy link
Contributor Author

Victrid commented May 24, 2025

Tests run fine, but it seems that mount -a will create duplicated mounts 🤔 we need to identify whether we are doing a remount.

@Victrid
Copy link
Contributor Author

Victrid commented May 27, 2025

It seems that when mount -a is called, it will check the mount table to see if it is already mounted, and skip them. Maybe the fuse is not correctly configured to be recognized. Let me check the mount implementation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant