Skip to contentSkip to conversation

fsmap: fix documentation of FMR_OF_LAST

PATCH In review Darrick J. Wong 3 participants 5 messages Aug 31, 2017 – Sep 3, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsmap: fix documentation of FMR_OF_LAST

The FMR_OF_LAST flag is set on the last fsmap record being returned for the dataset requested, contrary to what the header file says. Fix the docs to reflect the behavior of all fsmap implementations.

---
 include/uapi/linux/fsmap.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/fsmap.h +1 -1
index 7e8e5f0b..e5213c3 100644
@@ -96,7 +96,7 @@ fsmap_advance(
 #define FMR_OF_EXTENT_MAP	0x4	/* segment = extent map */
 #define FMR_OF_SHARED		0x8	/* segment = shared with another file */
 #define FMR_OF_SPECIAL_OWNER	0x10	/* owner is a special value */
-#define FMR_OF_LAST		0x20	/* segment is the last in the FS */
+#define FMR_OF_LAST		0x20	/* segment is the last in the dataset */
 
 /* Each FS gets to define its own special owner codes. */
 #define FMR_OWNER(type, code)	(((__u64)type << 32) | \
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Darrick J. Wong

The FMR_OF_LAST flag is set on the last fsmap record being returned for the dataset requested, contrary to what the header file says. Fix the docs to reflect the behavior of all fsmap implementations.

---
 include/uapi/linux/fsmap.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/fsmap.h +0 -0
index 7e8e5f0b..e5213c3 100644

include/uapi/linux/fsmap.h fsmap_advance( · line 102

Quoted 8 lines
include/uapi/linux/fsmap.h +1 -1
@@ -96,7 +96,7 @@ fsmap_advance(
 #define FMR_OF_EXTENT_MAP	0x4	/* segment = extent map */
 #define FMR_OF_SHARED		0x8	/* segment = shared with another file */
 #define FMR_OF_SPECIAL_OWNER	0x10	/* owner is a special value */
-#define FMR_OF_LAST		0x20	/* segment is the last in the FS */
+#define FMR_OF_LAST		0x20	/* segment is the last in the dataset */
 
 /* Each FS gets to define its own special owner codes. */
 #define FMR_OWNER(type, code)	(((__u64)type << 32) | \

Looks fine.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
In reply to Darrick J. Wong
Quoted 3 lines · Darrick J. Wong

The FMR_OF_LAST flag is set on the last fsmap record being returned for the dataset requested, contrary to what the header file says. Fix the docs to reflect the behavior of all fsmap implementations.

Hmm. What's the point of the flag then given that you can trivially deduce the last entry from fmh_entries?

#3 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

The FMR_OF_LAST flag is set on the last fsmap record being returned for the dataset requested, contrary to what the header file says. Fix the docs to reflect the behavior of all fsmap implementations.

Hmm. What's the point of the flag then given that you can trivially deduce the last entry from fmh_entries?

fmh_entries is the number of records returned, not the number of records in the dataset. If, for example, you allocate space for 100 records and perform a query for a block that has been reflinked 1000 times, the dataset size is 1000 but fmh_entries is set to 100. The lack of a LAST flag on the 100th record tells you that there's more records to return.

If however you allocate space for 100 records and the block is reflinked exactly 100 times, there's no way (without the flag) for userspace to know that record 100 is the end of the dataset, so the only thing it can do is to fsmap_advance() and try the query again, only to receive zero results. Granted I don't think fsmap queries are all /that/ expensive, but it's trivial for the kernel to set the flag.

--D

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by
#4 lore raw
Quoted 6 lines · Darrick J. Wong

fmh_entries is the number of records returned, not the number of records in the dataset. If, for example, you allocate space for 100 records and perform a query for a block that has been reflinked 1000 times, the dataset size is 1000 but fmh_entries is set to 100. The lack of a LAST flag on the 100th record tells you that there's more records to return.

Quoted 6 lines

If however you allocate space for 100 records and the block is reflinked exactly 100 times, there's no way (without the flag) for userspace to know that record 100 is the end of the dataset, so the only thing it can do is to fsmap_advance() and try the query again, only to receive zero results. Granted I don't think fsmap queries are all /that/ expensive, but it's trivial for the kernel to set the flag.

Oh, ok - it had to look up this defintion of dataset first. With that the explanation makes total sense: