Thread (5 messages) 5 messages, 3 authors, 2021-01-14

Re: [PATCH] btrfs-progs: align btrfs receive buffer to enable fast CRC

From: Wang Yugui <hidden>
Date: 2021-01-03 02:54:37

Hi, Sheng
quoted hunk ↗ jump to hunk
From: Sheng Mao <redacted>

To use optimized CRC implemention, the input buffer must be
unsigned long aligned. btrfs receive calculates checksum based on
read_buf, including btrfs_cmd_header (with zero-ed CRC field)
and command content. GCC attribute is added to both struct
btrfs_send_stream and read_buf to make sure read_buf is allocated
with proper alignment.

Issue: #324
Signed-off-by: Sheng Mao <redacted>
---
 common/send-stream.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/send-stream.c b/common/send-stream.c
index 69d75168..b13aa16e 100644
--- a/common/send-stream.c
+++ b/common/send-stream.c
@@ -26,7 +26,8 @@
 
 struct btrfs_send_stream {
 	int fd;
-	char read_buf[BTRFS_SEND_BUF_SIZE];
+	char read_buf[BTRFS_SEND_BUF_SIZE]
+		__attribute__((aligned(sizeof(unsigned long))));
 
 	int cmd;
Can we move 'int cmd' to before 'char read_buf' too?

There is a hole between 'int fd' and 'char read_buf' after the
addiatioin of '__attribute__((aligned(sizeof(unsigned long))))'
in x86_64.

Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2021/01/03
quoted hunk ↗ jump to hunk
 	struct btrfs_cmd_header *cmd_hdr;
@@ -41,7 +42,7 @@ struct btrfs_send_stream {
 
 	struct btrfs_send_ops *ops;
 	void *user;
-};
+} __attribute__((aligned(sizeof(unsigned long))));
 
 /*
  * Read len bytes to buf.
-- 
2.29.2
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help