-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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
statfsthen ignore those havingf_type == AUTOFS_SUPER_MAGIC