From: Su Yue <suy.fnst@cn.fujitsu.com>
To: Nikolay Borisov <nborisov@suse.com>, <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: Don't hardcode the csum size in btrfs_ordered_sum_size
Date: Wed, 7 Feb 2018 17:32:08 +0800 [thread overview]
Message-ID: <e77a1f6b-16e1-c8b5-cfe9-d0275f5c8f25@cn.fujitsu.com> (raw)
In-Reply-To: <1517995150-28081-1-git-send-email-nborisov@suse.com>
On 02/07/2018 05:19 PM, Nikolay Borisov wrote:
> Currently the function uses a hardcoded value for the checksum size of
> a sector. This is fine, given that we currently support only a single
> algorithm, whose checksum is 4 bytes == sizeof(u32). Despite not
> having other algorithms, btrfs' design supports using a different
> algorithm whith different space requirements. To future-proof the code
> query the size of the currently used algorithm from the in-memory copy
> of the super block. No functional changes.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
> fs/btrfs/ordered-data.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
> index 56c4c0ee6381..c53e2cfb72d9 100644
> --- a/fs/btrfs/ordered-data.h
> +++ b/fs/btrfs/ordered-data.h
> @@ -151,7 +151,9 @@ static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info,
> unsigned long bytes)
> {
> int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize);
> - return sizeof(struct btrfs_ordered_sum) + num_sectors * sizeof(u32);
> + int csum_size = btrfs_super_csum_size(fs_info->super_copy);
> +
> + return sizeof(struct btrfs_ordered_sum) + num_sectors * csum_size;
> }
>
> static inline void
>
prev parent reply other threads:[~2018-02-07 9:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 9:19 [PATCH] btrfs: Don't hardcode the csum size in btrfs_ordered_sum_size Nikolay Borisov
2018-02-07 9:23 ` Qu Wenruo
2018-02-07 9:32 ` Su Yue [this message]
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=e77a1f6b-16e1-c8b5-cfe9-d0275f5c8f25@cn.fujitsu.com \
--to=suy.fnst@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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;
as well as URLs for NNTP newsgroup(s).