From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 02/10] btrfs: replace div_u64 by shift in free_space_bitmap_size
Date: Mon, 2 Nov 2020 22:07:16 +0800 [thread overview]
Message-ID: <d25cb311-83f0-4f74-4c73-5f5a58290048@gmx.com> (raw)
In-Reply-To: <8eeec6dd99180d96b96168d24fc4205c0ed48f36.1603981453.git.dsterba@suse.com>
[-- Attachment #1.1: Type: text/plain, Size: 2781 bytes --]
On 2020/10/29 下午10:27, David Sterba wrote:
> Change free_space_bitmap_size to take btrfs_fs_info so we can get the
> sectorsize_bits to do calculations.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/free-space-tree.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
> index f09f62e245a0..0f6a2ee6f235 100644
> --- a/fs/btrfs/free-space-tree.c
> +++ b/fs/btrfs/free-space-tree.c
> @@ -136,9 +136,10 @@ static int btrfs_search_prev_slot(struct btrfs_trans_handle *trans,
> return 0;
> }
>
> -static inline u32 free_space_bitmap_size(u64 size, u32 sectorsize)
> +static inline u32 free_space_bitmap_size(const struct btrfs_fs_info *fs_info,
> + u64 size)
> {
> - return DIV_ROUND_UP((u32)div_u64(size, sectorsize), BITS_PER_BYTE);
> + return DIV_ROUND_UP(size >> fs_info->sectorsize_bits, BITS_PER_BYTE);
> }
>
> static unsigned long *alloc_bitmap(u32 bitmap_size)
> @@ -200,8 +201,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
> int done = 0, nr;
> int ret;
>
> - bitmap_size = free_space_bitmap_size(block_group->length,
> - fs_info->sectorsize);
> + bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
> bitmap = alloc_bitmap(bitmap_size);
> if (!bitmap) {
> ret = -ENOMEM;
> @@ -290,8 +290,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
> u32 data_size;
>
> extent_size = min(end - i, bitmap_range);
> - data_size = free_space_bitmap_size(extent_size,
> - fs_info->sectorsize);
> + data_size = free_space_bitmap_size(fs_info, extent_size);
>
> key.objectid = i;
> key.type = BTRFS_FREE_SPACE_BITMAP_KEY;
> @@ -339,8 +338,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
> int done = 0, nr;
> int ret;
>
> - bitmap_size = free_space_bitmap_size(block_group->length,
> - fs_info->sectorsize);
> + bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
> bitmap = alloc_bitmap(bitmap_size);
> if (!bitmap) {
> ret = -ENOMEM;
> @@ -383,8 +381,8 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
> fs_info->sectorsize *
> BITS_PER_BYTE);
> bitmap_cursor = ((char *)bitmap) + bitmap_pos;
> - data_size = free_space_bitmap_size(found_key.offset,
> - fs_info->sectorsize);
> + data_size = free_space_bitmap_size(fs_info,
> + found_key.offset);
>
> ptr = btrfs_item_ptr_offset(leaf, path->slots[0] - 1);
> read_extent_buffer(leaf, bitmap_cursor, ptr,
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-11-02 14:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 14:27 [PATCH 00/10] Sectorsize, csum_size lifted to fs_info David Sterba
2020-10-29 14:27 ` [PATCH 01/10] btrfs: use precalculated sectorsize_bits from fs_info David Sterba
2020-11-02 14:05 ` Qu Wenruo
2020-11-02 14:18 ` Qu Wenruo
2020-11-02 14:31 ` Johannes Thumshirn
2020-11-02 15:08 ` David Sterba
2020-11-02 15:12 ` Johannes Thumshirn
2020-11-02 15:15 ` David Sterba
2020-11-03 9:31 ` David Sterba
2020-10-29 14:27 ` [PATCH 02/10] btrfs: replace div_u64 by shift in free_space_bitmap_size David Sterba
2020-11-02 14:07 ` Qu Wenruo [this message]
2020-10-29 14:27 ` [PATCH 03/10] btrfs: replace s_blocksize_bits with fs_info::sectorsize_bits David Sterba
2020-11-02 14:23 ` Qu Wenruo
2020-11-02 15:18 ` David Sterba
2020-10-29 14:27 ` [PATCH 04/10] btrfs: store precalculated csum_size in fs_info David Sterba
2020-10-29 14:27 ` [PATCH 05/10] btrfs: precalculate checksums per leaf once David Sterba
2020-11-02 14:27 ` Qu Wenruo
2020-11-02 15:24 ` David Sterba
2020-11-02 16:00 ` David Sterba
2020-10-29 14:27 ` [PATCH 06/10] btrfs: use cached value of fs_info::csum_size everywhere David Sterba
2020-11-02 14:28 ` Qu Wenruo
2020-10-29 14:27 ` [PATCH 07/10] btrfs: switch cached fs_info::csum_size from u16 to u32 David Sterba
2020-10-29 14:27 ` [PATCH 08/10] btrfs: remove unnecessary local variables for checksum size David Sterba
2020-10-29 14:43 ` Johannes Thumshirn
2020-10-29 14:27 ` [PATCH 09/10] btrfs: check integrity: remove local copy of csum_size David Sterba
2020-10-29 14:44 ` Johannes Thumshirn
2020-10-29 14:27 ` [PATCH 10/10] btrfs: scrub: remove local copy of csum_size from context David Sterba
2020-10-29 14:45 ` Johannes Thumshirn
2020-10-29 14:54 ` David Sterba
2020-10-29 15:01 ` Johannes Thumshirn
2020-10-29 14:50 ` [PATCH 00/10] Sectorsize, csum_size lifted to fs_info Johannes Thumshirn
2020-10-29 16:25 ` 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=d25cb311-83f0-4f74-4c73-5f5a58290048@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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