Skip to contentSkip to conversation

btrfs: send: update command for protocol version check

PATCH In review David Sterba 2 participants 2 messages Oct 7, 2022 – Oct 9, 2022 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH 1/1 btrfs: send: update command for protocol version check

For a protocol and command compatibility we have a helper that hasn't been updated for v3 yet. We use it for verity so update where necessary.

Fixes 38622010a6de ("btrfs: send: add support for fs-verity")
---
 fs/btrfs/send.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/btrfs/send.c +4 -1
index 178347666235..ec6e1752af2c 100644
@@ -348,6 +348,7 @@ static bool proto_cmd_ok(const struct send_ctx *sctx, int cmd)
 	switch (sctx->proto) {
 	case 1:	 return cmd <= BTRFS_SEND_C_MAX_V1;
 	case 2:	 return cmd <= BTRFS_SEND_C_MAX_V2;
+	case 3:	 return cmd <= BTRFS_SEND_C_MAX_V3;
 	default: return false;
 	}
 }
@@ -6469,7 +6470,9 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end)
 		if (ret < 0)
 			goto out;
 	}
-	if (sctx->proto >= 3 && sctx->cur_inode_needs_verity) {
+
+	if (proto_cmd_ok(sctx, BTRFS_SEND_C_ENABLE_VERITY)
+	    && sctx->cur_inode_needs_verity) {
 		ret = process_verity(sctx);
 		if (ret < 0)
 			goto out;
Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · David Sterba

For a protocol and command compatibility we have a helper that hasn't been updated for v3 yet. We use it for verity so update where necessary.

Fixes 38622010a6de ("btrfs: send: add support for fs-verity")
Quoted 27 lines
---
  fs/btrfs/send.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
fs/btrfs/send.c +4 -1
index 178347666235..ec6e1752af2c 100644
@@ -348,6 +348,7 @@ static bool proto_cmd_ok(const struct send_ctx *sctx, int cmd)
  	switch (sctx->proto) {
  	case 1:	 return cmd <= BTRFS_SEND_C_MAX_V1;
  	case 2:	 return cmd <= BTRFS_SEND_C_MAX_V2;
+	case 3:	 return cmd <= BTRFS_SEND_C_MAX_V3;
  	default: return false;
  	}
  }
@@ -6469,7 +6470,9 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end)
  		if (ret < 0)
  			goto out;
  	}
-	if (sctx->proto >= 3 && sctx->cur_inode_needs_verity) {
+
+	if (proto_cmd_ok(sctx, BTRFS_SEND_C_ENABLE_VERITY)
+	    && sctx->cur_inode_needs_verity) {
  		ret = process_verity(sctx);
  		if (ret < 0)
  			goto out;