]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
fiemap: add a nosync option
authorPankaj Raghav <p.raghav@samsung.com>
Tue, 14 Jul 2026 20:32:06 +0000 (22:32 +0200)
committerAndrey Albershteyn <aalbersh@kernel.org>
Wed, 15 Jul 2026 07:40:56 +0000 (09:40 +0200)
io/fiemap adds FIEMAP_FLAG_SYNC by default. There are some test cases
where adding this flag might have an undesired side effect on the
results [1].

Add an option that does not pass FIEMAP_FLAG_SYNC flag.

[1] https://lore.kernel.org/linux-xfs/ca21b3c4-e1df-4ba7-8e9c-5d221337c86b@huaweicloud.com/

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
io/fiemap.c
man/man8/xfs_io.8

index b41f71bfd027bbb14e470d892e1f0685a2e0bd86..cf3a1b3e8d0fee75a8b06098612bea687585f1c2 100644 (file)
@@ -36,6 +36,7 @@ fiemap_help(void)
 " -a -- prints the attribute fork map instead of the data fork.\n"
 " -l -- also displays the length of each extent in 512-byte blocks.\n"
 " -n -- query n extents.\n"
+" -e -- obtains also delayed allocation extents by not using FIEMAP_FLAG_SYNC.\n"
 " -v -- Verbose information\n"
 " offset is the starting offset to map, and is optional.  If offset is\n"
 " specified, mapping length may (optionally) be specified as well."
@@ -242,7 +243,7 @@ fiemap_f(
 
        init_cvtnum(&fsblocksize, &fssectsize);
 
-       while ((c = getopt(argc, argv, "aln:v")) != EOF) {
+       while ((c = getopt(argc, argv, "aln:ev")) != EOF) {
                switch (c) {
                case 'a':
                        fiemap_flags |= FIEMAP_FLAG_XATTR;
@@ -253,6 +254,10 @@ fiemap_f(
                case 'n':
                        max_extents = atoi(optarg);
                        break;
+               case 'e':
+                       /* nosync */
+                       fiemap_flags &= ~(FIEMAP_FLAG_SYNC);
+                       break;
                case 'v':
                        vflag++;
                        break;
@@ -393,7 +398,7 @@ fiemap_init(void)
        fiemap_cmd.argmin = 0;
        fiemap_cmd.argmax = -1;
        fiemap_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
-       fiemap_cmd.args = _("[-alv] [-n nx] [offset [len]]");
+       fiemap_cmd.args = _("[-alev] [-n nx] [offset [len]]");
        fiemap_cmd.oneline = _("print block mapping for a file");
        fiemap_cmd.help = fiemap_help;
 
index 61defcc377163adb5fc7e39bdc074c9bf98e42c4..a3ddab0293e9499b905e0d8f387e56b52c9d16b0 100644 (file)
@@ -353,7 +353,7 @@ Prints the block mapping for the current open file. Refer to the
 .BR xfs_bmap (8)
 manual page for complete documentation.
 .TP
-.BI "fiemap [ \-alv ] [ \-n " nx " ] [ " offset " [ " len " ]]"
+.BI "fiemap [ \-alev ] [ \-n " nx " ] [ " offset " [ " len " ]]"
 Prints the block mapping for the current open file using the fiemap
 ioctl.  Options behave as described in the
 .BR xfs_bmap (8)