From: Stanislav Brabec Date: Mon, 31 Jan 2022 09:53:20 +0000 (+0100) Subject: fstrim: Add fstab option X-fstrim.notrim X-Git-Tag: v2.38-rc1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=582eb71d737b6c23dd5ec19db0e9aa1d4d7abee9;p=thirdparty%2Futil-linux.git fstrim: Add fstab option X-fstrim.notrim Sometimes it makes sense to skip fstrim for selected file mounts, but still be able to use fstrim.service. Add a possibility to specify "X-fstrim.notrim" in fstab. Do not use "notrim", as it collides with the kernel rbd driver. [kzak@redhat.com: - rename x-fstrim to X-fstrim] Signed-off-by: Stanislav Brabec Signed-off-by: Karel Zak --- diff --git a/sys-utils/fstrim.8.adoc b/sys-utils/fstrim.8.adoc index b2c1fce227..004eb0bdaa 100644 --- a/sys-utils/fstrim.8.adoc +++ b/sys-utils/fstrim.8.adoc @@ -29,7 +29,7 @@ Running *fstrim* frequently, or even using *mount -o discard*, might negatively The _offset_, _length_, and _minimum-size_ arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. *-A, --fstab*:: -Trim all mounted filesystems mentioned in _/etc/fstab_ on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored. +Trim all mounted filesystems mentioned in _/etc/fstab_ on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored. Filesystems with "X-fstrim.notrim" mount option are skipped. *-a, --all*:: Trim all mounted filesystems on devices that support the discard operation. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored. diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c index 88397f0ec3..0d6cabeb96 100644 --- a/sys-utils/fstrim.c +++ b/sys-utils/fstrim.c @@ -224,6 +224,8 @@ static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt) return 1; if (mnt_fs_match_options(fs, "ro")) return 1; + if (mnt_fs_match_options(fs, "+X-fstrim.notrim")) + return 1; fd = open(tgt, O_PATH); if (fd < 0)