]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
fiemap: Eliminate num_extents
authorNikolay Borisov <nborisov@suse.com>
Thu, 24 Aug 2017 21:43:40 +0000 (16:43 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 24 Aug 2017 21:43:40 +0000 (16:43 -0500)
Fiemap has this rather convoluted logic to calculate the number of extents to
query. This introduces needless complexity with no real benefit. Remove
num_extents and instead hardcode the number of extents we query for in a single
go to 32. No functional changes

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
io/fiemap.c

index d284248e4fe1112406214304dc4ff0dc5669394c..a31db790c86d7493769c6fbaa43755168867e1cf 100644 (file)
@@ -23,6 +23,8 @@
 #include "init.h"
 #include "io.h"
 
+#define EXTENT_BATCH 32
+
 static cmdinfo_t fiemap_cmd;
 static int max_extents = 0;
 
@@ -195,7 +197,6 @@ fiemap_f(
        char            **argv)
 {
        struct fiemap   *fiemap;
-       int             num_extents = 32;
        int             last = 0;
        int             lflag = 0;
        int             vflag = 0;
@@ -231,10 +232,8 @@ fiemap_f(
                }
        }
 
-       if (max_extents)
-               num_extents = min(num_extents, max_extents);
        map_size = sizeof(struct fiemap) +
-               (num_extents * sizeof(struct fiemap_extent));
+               (EXTENT_BATCH * sizeof(struct fiemap_extent));
        fiemap = malloc(map_size);
        if (!fiemap) {
                fprintf(stderr, _("%s: malloc of %d bytes failed.\n"),
@@ -246,15 +245,12 @@ fiemap_f(
        printf("%s:\n", file->name);
 
        while (!last && ((cur_extent + 1) != max_extents)) {
-               if (max_extents)
-                       num_extents = min(num_extents,
-                                         max_extents - (cur_extent + 1));
 
                memset(fiemap, 0, map_size);
                fiemap->fm_flags = fiemap_flags;
                fiemap->fm_start = last_logical;
                fiemap->fm_length = -1LL;
-               fiemap->fm_extent_count = num_extents;
+               fiemap->fm_extent_count = EXTENT_BATCH;
 
                ret = ioctl(file->fd, FS_IOC_FIEMAP, (unsigned long)fiemap);
                if (ret < 0) {