Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fstrim: ignore automount #1463

Closed
huww98 opened this issue Oct 3, 2021 · 2 comments
Closed

fstrim: ignore automount #1463

huww98 opened this issue Oct 3, 2021 · 2 comments

Comments

@huww98
Copy link

huww98 commented Oct 3, 2021

In /etc/fstab, we can use x-systemd.automount option to set up a automount. In our case, we set up a lot of read-only automount for our datasets. Once these automounts are triggered, they will in turn trigger the network block device mapping (Ceph RBD). However, fstrim --fstab will trigger all these mappings, and return errors like fstrim: /mnt/rbd/datasets/ImageNet: the discard operation is not supported, which is not desired.

The automount is triggered at https://github.com/karelzak/util-linux/blob/e549619122b62b587b5aeb1b2ba3ca565010dc6d/sys-utils/fstrim.c#L101

Before automount is triggered, fstrim fails to detect this is a read-only mount. access returns 0
https://github.com/karelzak/util-linux/blob/e549619122b62b587b5aeb1b2ba3ca565010dc6d/sys-utils/fstrim.c#L340
and before automount is triggered, the block device does not exists, so has_discard check also fails.
https://github.com/karelzak/util-linux/blob/d4319b91c9d7d69e7b954fc66819214f81501312/sys-utils/fstrim.c#L157-L159

I propose the following possible improvement on this:

  • Read mount options in /etc/fstab, and ignore mounts with ro, _netdev or x-systemd.automount specified
  • Call statfs then ignore those having f_type == AUTOFS_SUPER_MAGIC
@karelzak
Copy link
Collaborator

karelzak commented Oct 4, 2021

Ah, very good catch. That's strange that someone else did not report it yet. I guess it has to be a pretty common problem. The committed change:

  • ignore read-only entries
  • ignore autofs entries
  • ignore autofs mountpoints (by fstatfs() in O_PATH file-descriptor)

Thanks!

karelzak added a commit that referenced this issue Oct 4, 2021
Addresses: #1463
Signed-off-by: Karel Zak <kzak@redhat.com>
@huww98
Copy link
Author

huww98 commented Oct 4, 2021

Thanks for the fix!

I think it may not be a very common problem because:

  • automount is usually used with network filesystem, and they should already be excluded by mnt_fs_is_netfs(fs)
  • We set up additional systemd units to map network block devices that are required by the device unit (systemd.device(5)). So the block device is only created when automount is triggered. I have not heard of anyone else doing the same.

karelzak added a commit to redhat-plumbers/util-linux-rhel that referenced this issue Jan 31, 2023
- ignore read-only entries
- ignore autofs entries (for example from /proc/self/mountinfo)
- ignore autofs mountpoints where automounter has not been triggered yet

Fixes: util-linux/util-linux#1463
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
karelzak added a commit to redhat-plumbers/util-linux-rhel that referenced this issue Jan 31, 2023
Addresses: util-linux/util-linux#1463
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
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

No branches or pull requests

2 participants