]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fstrim: de-duplicate btrfs sub-volumes
authorStanislav Brabec <sbrabec@suse.cz>
Wed, 25 Jan 2017 17:30:26 +0000 (18:30 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 21 Feb 2017 12:13:25 +0000 (13:13 +0100)
There was a comparison of roots in uniq_fs_source_cmp(). As we care only on
device names, comparing roots makes only a little sense, and it breaks on btrfs.
As a result, FITRIM ioctl() is called for each subvolume. But by design, only
one TRIM is needed for the whole btrfs volume.

Remove it to be able to de-duplicate btrfs subvolumes.

Fixes opensuse #1020077.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
sys-utils/fstrim.c

index b764b0b330751fd3b59c68795823a7f35bd0f53a..09c6b496082293b62a23fda6a2b2297c02de3ef6 100644 (file)
@@ -158,23 +158,11 @@ static int uniq_fs_source_cmp(
                struct libmnt_fs *a,
                struct libmnt_fs *b)
 {
-       int eq;
-
        if (mnt_fs_is_pseudofs(a) || mnt_fs_is_netfs(a) ||
            mnt_fs_is_pseudofs(b) || mnt_fs_is_netfs(b))
                return 1;
 
-       eq = mnt_fs_streq_srcpath(a, mnt_fs_get_srcpath(b));
-       if (eq) {
-               const char *aroot = mnt_fs_get_root(a),
-                          *broot = mnt_fs_get_root(b);
-               if (!aroot || !broot)
-                       eq = 0;
-               else if (strcmp(aroot, broot) != 0)
-                       eq = 0;
-       }
-
-       return !eq;
+       return !mnt_fs_streq_srcpath(a, mnt_fs_get_srcpath(b));
 }
 
 /*