Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH v3] fiemap: add a nosync option
@ 2026-07-14 20:32 Pankaj Raghav
  2026-07-14 20:35 ` Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pankaj Raghav @ 2026-07-14 20:32 UTC (permalink / raw)
  To: aalbersh
  Cc: pankaj.raghav, hch, Zhang Yi, gost.dev, linux-xfs, djwong,
	Pankaj Raghav

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>
---
Changes since v2:
- Add this option to the man page (Darrick)
- Add more information about this flag in the help.
Changes since v1:
- Change '-s' to '-e' to match xfs_bmap (Christoph).

 io/fiemap.c       | 9 +++++++--
 man/man8/xfs_io.8 | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/io/fiemap.c b/io/fiemap.c
index b41f71bf..cf3a1b3e 100644
--- a/io/fiemap.c
+++ b/io/fiemap.c
@@ -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;
 
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 61defcc3..a3ddab02 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -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)

base-commit: e80b048d87fdc5735e0d03ae29b497b402ea8bbe
-- 
2.51.2


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

* Re: [PATCH v3] fiemap: add a nosync option
  2026-07-14 20:32 [PATCH v3] fiemap: add a nosync option Pankaj Raghav
@ 2026-07-14 20:35 ` Darrick J. Wong
  2026-07-15  1:12 ` Zhang Yi
  2026-07-15  4:39 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2026-07-14 20:35 UTC (permalink / raw)
  To: Pankaj Raghav; +Cc: aalbersh, pankaj.raghav, hch, Zhang Yi, gost.dev, linux-xfs

On Tue, Jul 14, 2026 at 10:32:06PM +0200, Pankaj Raghav wrote:
> 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>
> ---
> Changes since v2:
> - Add this option to the man page (Darrick)
> - Add more information about this flag in the help.
> Changes since v1:
> - Change '-s' to '-e' to match xfs_bmap (Christoph).
> 
>  io/fiemap.c       | 9 +++++++--
>  man/man8/xfs_io.8 | 2 +-
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/io/fiemap.c b/io/fiemap.c
> index b41f71bf..cf3a1b3e 100644
> --- a/io/fiemap.c
> +++ b/io/fiemap.c
> @@ -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;
>  
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index 61defcc3..a3ddab02 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -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 " ]]"

Thanks!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

>  Prints the block mapping for the current open file using the fiemap
>  ioctl.  Options behave as described in the
>  .BR xfs_bmap (8)
> 
> base-commit: e80b048d87fdc5735e0d03ae29b497b402ea8bbe
> -- 
> 2.51.2
> 

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

* Re: [PATCH v3] fiemap: add a nosync option
  2026-07-14 20:32 [PATCH v3] fiemap: add a nosync option Pankaj Raghav
  2026-07-14 20:35 ` Darrick J. Wong
@ 2026-07-15  1:12 ` Zhang Yi
  2026-07-15  4:39 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang Yi @ 2026-07-15  1:12 UTC (permalink / raw)
  To: Pankaj Raghav, aalbersh; +Cc: pankaj.raghav, hch, gost.dev, linux-xfs, djwong

On 7/15/2026 4:32 AM, Pankaj Raghav wrote:
> 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>

Thanks for the patch, this looks good to me!

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
> Changes since v2:
> - Add this option to the man page (Darrick)
> - Add more information about this flag in the help.
> Changes since v1:
> - Change '-s' to '-e' to match xfs_bmap (Christoph).
> 
>  io/fiemap.c       | 9 +++++++--
>  man/man8/xfs_io.8 | 2 +-
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/io/fiemap.c b/io/fiemap.c
> index b41f71bf..cf3a1b3e 100644
> --- a/io/fiemap.c
> +++ b/io/fiemap.c
> @@ -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;
>  
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index 61defcc3..a3ddab02 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -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)
> 
> base-commit: e80b048d87fdc5735e0d03ae29b497b402ea8bbe


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

* Re: [PATCH v3] fiemap: add a nosync option
  2026-07-14 20:32 [PATCH v3] fiemap: add a nosync option Pankaj Raghav
  2026-07-14 20:35 ` Darrick J. Wong
  2026-07-15  1:12 ` Zhang Yi
@ 2026-07-15  4:39 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-07-15  4:39 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: aalbersh, pankaj.raghav, hch, Zhang Yi, gost.dev, linux-xfs,
	djwong

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

end of thread, other threads:[~2026-07-15  4:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 20:32 [PATCH v3] fiemap: add a nosync option Pankaj Raghav
2026-07-14 20:35 ` Darrick J. Wong
2026-07-15  1:12 ` Zhang Yi
2026-07-15  4:39 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox