All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fstrim: Add fstab option x-fstrim.notrim
@ 2022-01-31  0:21 Stanislav Brabec
  2022-01-31  9:55 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Brabec @ 2022-01-31  0:21 UTC (permalink / raw)
  To: util-linux

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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
---
  sys-utils/fstrim.8.adoc | 4 +++-
  sys-utils/fstrim.c      | 2 ++
  2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys-utils/fstrim.8.adoc b/sys-utils/fstrim.8.adoc
index b2c1fce22..66387ba35 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.
@@ -47,6 +47,8 @@ The number of bytes (after the starting point) to 
search for free blocks to disc
  Specifies a colon-separated list of files in fstab or kernel mountinfo 
format. All missing or empty files are silently ignored. The evaluation 
of the _list_ stops after first non-empty file. For example:
  +
  *--listed-in /etc/fstab:/proc/self/mountinfo*.
++
+Filesystems with "x-fstrim.notrim" mount option are skipped.

  *-m, --minimum* _minimum-size_::
  Minimum contiguous free range to discard, in bytes. (This value is 
internally rounded up to a multiple of the filesystem block size.) Free 
ranges smaller than this will be ignored and *fstrim* will adjust the 
minimum if it's smaller than the device's minimum, and report that 
(fstrim_range.minlen) back to userspace. By increasing this value, the 
*fstrim* operation will complete more quickly for filesystems with badly 
fragmented freespace, although not all blocks will be discarded. The 
default value is zero, discarding every free block.
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index 88397f0ec..cbe1c76d0 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)
-- 
2.31.1
-- 

Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa)                    tel: +420 284 084 060
186 00 Praha 8-Karlín                          fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fstrim: Add fstab option x-fstrim.notrim
  2022-01-31  0:21 [PATCH] fstrim: Add fstab option x-fstrim.notrim Stanislav Brabec
@ 2022-01-31  9:55 ` Karel Zak
  2022-01-31 22:35   ` Stanislav Brabec
  0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2022-01-31  9:55 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: util-linux

On Mon, Jan 31, 2022 at 01:21:30AM +0100, Stanislav Brabec wrote:
> 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.

Good idea, but I've merged it with small change.

We need "X-fstrim.notrim", because x-* options are stored by libmount
in utab to be accessible for umount (etc.). This is expensive and
unnecessary for fstrim.

Thanks!

 Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fstrim: Add fstab option x-fstrim.notrim
  2022-01-31  9:55 ` Karel Zak
@ 2022-01-31 22:35   ` Stanislav Brabec
  2022-02-01  8:51     ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Brabec @ 2022-01-31 22:35 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

My original patch contains 2 adoc chunks: one for -A, second for 
--listed-in. X-fstrim.notrim works for both. Was the omitting of the 
chunk for --listed-in intentional?

(Maybe it could be mentioned in a better way, so only one mention will 
be enough.)

Karel Zak wrote:
> On Mon, Jan 31, 2022 at 01:21:30AM +0100, Stanislav Brabec wrote:
>> 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.
> Good idea, but I've merged it with small change.
>

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa)                    tel: +420 284 084 060
186 00 Praha 8-Karlín                          fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fstrim: Add fstab option x-fstrim.notrim
  2022-01-31 22:35   ` Stanislav Brabec
@ 2022-02-01  8:51     ` Karel Zak
  0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2022-02-01  8:51 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: util-linux

On Mon, Jan 31, 2022 at 11:35:19PM +0100, Stanislav Brabec wrote:
> My original patch contains 2 adoc chunks: one for -A, second for
> --listed-in. X-fstrim.notrim works for both. Was the omitting of the chunk
> for --listed-in intentional?

Ah, no. I have applied the patch manually as git-am had a problem with
your email. Fixed now.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-01  8:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31  0:21 [PATCH] fstrim: Add fstab option x-fstrim.notrim Stanislav Brabec
2022-01-31  9:55 ` Karel Zak
2022-01-31 22:35   ` Stanislav Brabec
2022-02-01  8:51     ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.