Now fstrim de-duplicates by target (mountpoint). This patch adds
de-duplication according to mount source (device) to avoid bind mounts
or devices mounted more than once. Note that the patch also check FS
root, the different FS roots of the same multi-root FS (e.g. btrfs)
maybe mounted on different places.
# mount --bind /home/wine /mnt/test
old version:
# fstrim -av
/mnt/test: 0 B (0 bytes) trimmed <---
/home/wine: 0 B (0 bytes) trimmed <---
/boot: 0 B (0 bytes) trimmed
/home: 0 B (0 bytes) trimmed
/: 0 B (0 bytes) trimmed
new version:
# fstrim -av
/mnt/test: 0 B (0 bytes) trimmed <---
/boot: 0 B (0 bytes) trimmed
/home: 171.8 MiB (180113408 bytes) trimmed
/: 0 B (0 bytes) trimmed
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1162213
Signed-off-by: Karel Zak <kzak@redhat.com>
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed. So say so. Also make
two very similar messages equal to this one.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
This adds a concise description of a tool to its usage text.
A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Reading the code this initialization is not necessary, so the change is
mostly about silencing a compiler warning and ensuring the program keeps
on working if there is a future bug that could make uninitialized 'path'
reachable to use.
sys-utils/fstrim.c:247: warning: 'path' may be used uninitialized in this
function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* read /proc/self/mountinfo to get filesystems
* ignore net and pseudo filesystems
* ignore unaccessible filesystems (over mounted by another FS)
* read disk sysfs queue/discard_granularity to detect is discard support
* call FITRIM ioctl
* silently ignore EOPNOTSUPP (for example LUKS without discard) and ENOTTY
(for example vfat) errors
Signed-off-by: Karel Zak <kzak@redhat.com>
Add to fstrim(8) code to support new discard BLKDISCARD and
BLKSECDISCARD ioctls for block devices. The new command is only
symlink to fstrim(8) as the both utils share some code and the basic
ideas.
Based on patch from Lukas Czerner <lczerner@redhat.com>.
Signed-off-by: Karel Zak <kzak@redhat.com>
This should improve a bit the portability as error() is a GNU extension and
util-linux provides fallbacks for err.h functions.
Fix compilation with icc, broken due to a reference to `__builtin_va_arg_pack'
in error.h using the -gcc default option.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Solaris lacks err, errx, warn and warnx. This also means the err.h header
doesn't exist. Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
fstrim is used on a mounted filesystem to discard (or "trim") blocks
which are not in use by the filesystem. This is useful for
solid-state drives (SSDs) and thinly-provisioned storage
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>