Skip to contentSkip to conversation

fiemap: add a nosync option

PATCH Superseded Pankaj Raghav 2 participants 2 messages Jul 14

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fiemap: add a nosync option

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/[email protected]/

---
Changes since v1:
- Change '-s' to '-e' to match xfs_bmap (Christoph).

 io/fiemap.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
io/fiemap.c +7 -2
index b41f71bf..b2e89b95 100644
@@ -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 -- do not use 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;
 

base-commit: e80b048d87fdc5735e0d03ae29b497b402ea8bbe

Signature · 1 line
2.51.2
#1 lore raw
Quoted 21 lines · 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/[email protected]/

---
Changes since v1:
- Change '-s' to '-e' to match xfs_bmap (Christoph).

 io/fiemap.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
io/fiemap.c +0 -0
index b41f71bf..b2e89b95 100644

io/fiemap.c fiemap_help(void) · line 39

Quoted 4 lines
io/fiemap.c +1 -0
@@ -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 -- do not use FIEMAP_FLAG_SYNC.\n"

Needs an xfs_io(8) manpage update, but otherwise this looks good to me.

--D

Quoted 38 lines
io/fiemap.c +6 -2
 " -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;
 

base-commit: e80b048d87fdc5735e0d03ae29b497b402ea8bbe

Signature · 1 line
2.51.2