Skip to contentSkip to conversation

xfs_io: allow combination of sync_file_range() flags

PATCH In review Brian Foster 2 participants 2 messages Mar 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_io: allow combination of sync_file_range() flags

The sync_file_range() functionality supports a flags argument that allows the caller to specify any combination of initiating writeback or waiting for write completion before and/or after the write. The xfs_io handler supports the ability to specify combinations of flags on the command line, but fails to OR the flags together and thus only performs one action per invocation.

This is inconsistent with the syscall and command interpretation. Update the sync_file_range() handler to populate the flags mask as specified by the user.

---
 io/sync_file_range.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
io/sync_file_range.c +3 -3
index 30bbc93d..8b5345c5 100644
@@ -37,13 +37,13 @@ sync_range_f(
 	while ((c = getopt(argc, argv, "abw")) != EOF) {
 		switch (c) {
 		case 'a':
-			sync_mode = SYNC_FILE_RANGE_WAIT_AFTER;
+			sync_mode |= SYNC_FILE_RANGE_WAIT_AFTER;
 			break;
 		case 'b':
-			sync_mode = SYNC_FILE_RANGE_WAIT_BEFORE;
+			sync_mode |= SYNC_FILE_RANGE_WAIT_BEFORE;
 			break;
 		case 'w':
-			sync_mode = SYNC_FILE_RANGE_WRITE;
+			sync_mode |= SYNC_FILE_RANGE_WRITE;
 			break;
 		default:
 			return command_usage(&sync_range_cmd);
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Brian Foster

The sync_file_range() functionality supports a flags argument that allows the caller to specify any combination of initiating writeback or waiting for write completion before and/or after the write. The xfs_io handler supports the ability to specify combinations of flags on the command line, but fails to OR the flags together and thus only performs one action per invocation.

Quoted 5 lines

This is inconsistent with the syscall and command interpretation. Update the sync_file_range() handler to populate the flags mask as specified by the user.

Makes sens... oh wait, this is sync_file_range, what a trash fire! :(

The arg processing changes look ok though.

--D

Quoted 28 lines
---
 io/sync_file_range.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
io/sync_file_range.c +3 -3
index 30bbc93d..8b5345c5 100644
@@ -37,13 +37,13 @@ sync_range_f(
 	while ((c = getopt(argc, argv, "abw")) != EOF) {
 		switch (c) {
 		case 'a':
-			sync_mode = SYNC_FILE_RANGE_WAIT_AFTER;
+			sync_mode |= SYNC_FILE_RANGE_WAIT_AFTER;
 			break;
 		case 'b':
-			sync_mode = SYNC_FILE_RANGE_WAIT_BEFORE;
+			sync_mode |= SYNC_FILE_RANGE_WAIT_BEFORE;
 			break;
 		case 'w':
-			sync_mode = SYNC_FILE_RANGE_WRITE;
+			sync_mode |= SYNC_FILE_RANGE_WRITE;
 			break;
 		default:
 			return command_usage(&sync_range_cmd);
Signature · 1 line
2.17.2