Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: shngmao@gmail.com
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: align btrfs receive buffer to enable fast CRC
Date: Sun, 03 Jan 2021 10:53:02 +0800	[thread overview]
Message-ID: <20210103105301.523C.409509F4@e16-tech.com> (raw)
In-Reply-To: <20201226214606.49241-1-shngmao@gmail.com>

Hi, Sheng

> From: Sheng Mao <shngmao@gmail.com>
> 
> 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 <shngmao@gmail.com>
> ---
>  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

>  	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



  reply	other threads:[~2021-01-03  2:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-26 21:46 [PATCH] btrfs-progs: align btrfs receive buffer to enable fast CRC shngmao
2021-01-03  2:53 ` Wang Yugui [this message]
2021-01-06 12:16 ` David Sterba
2021-01-08  1:58   ` Sheng Mao
2021-01-14 18:37 ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210103105301.523C.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=shngmao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox