From: Qu Wenruo <wqu@suse.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: Re: [PATCH] btrfs: extent-tree: Use round up to replace align macro
Date: Tue, 21 Nov 2017 16:06:54 +0800 [thread overview]
Message-ID: <c864ff00-ec2a-603b-cc2c-b942d2373f7c@suse.com> (raw)
In-Reply-To: <78abe4d1-b83c-980a-4594-e1f25b52b81a@suse.com>
[-- Attachment #1.1: Type: text/plain, Size: 2873 bytes --]
On 2017年11月21日 15:33, Nikolay Borisov wrote:
>
>
> On 21.11.2017 07:54, Qu Wenruo wrote:
>> To save reader seconds before checking if it's rounding up or down.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>> fs/btrfs/extent-tree.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index 309a109069f1..8ab18e25cb91 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -2054,7 +2054,7 @@ static int btrfs_issue_discard(struct block_device *bdev, u64 start, u64 len,
>> {
>> int j, ret = 0;
>> u64 bytes_left, end;
>> - u64 aligned_start = ALIGN(start, 1 << 9);
>> + u64 aligned_start = round_up(start, 1 << 9);
>
> nit: 1 << 9 == SZ_512 or essentially sector size however looking at the
> defines there is SECTOR_SIZE defined in ide.h which we do not include.
> Or just use 512 no need to obscure it behind a shift.
I also noticed that while I don't have any good idea which macro should
be used.
That SECTOR_SIZE defined in ide.h doesn't sound good to me.
And all other filesystems are using their own definition, without some
definition in fs/bio level.
Thanks,
Qu
>
>>
>> if (WARN_ON(start != aligned_start)) {
>> len -= aligned_start - start;
>> @@ -4266,7 +4266,7 @@ int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
>> int have_pinned_space;
>>
>> /* make sure bytes are sectorsize aligned */
>> - bytes = ALIGN(bytes, fs_info->sectorsize);
>> + bytes = round_up(bytes, fs_info->sectorsize);
>>
>> if (btrfs_is_free_space_inode(inode)) {
>> need_commit = 0;
>> @@ -6080,7 +6080,7 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
>> if (delalloc_lock)
>> mutex_lock(&inode->delalloc_mutex);
>>
>> - num_bytes = ALIGN(num_bytes, fs_info->sectorsize);
>> + num_bytes = round_up(num_bytes, fs_info->sectorsize);
>>
>> /* Add our new extents and calculate the new rsv size. */
>> spin_lock(&inode->lock);
>> @@ -6135,7 +6135,7 @@ void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes)
>> {
>> struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
>>
>> - num_bytes = ALIGN(num_bytes, fs_info->sectorsize);
>> + num_bytes = round_up(num_bytes, fs_info->sectorsize);
>> spin_lock(&inode->lock);
>> inode->csum_bytes -= num_bytes;
>> btrfs_calculate_inode_block_rsv_size(fs_info, inode);
>> @@ -7818,7 +7818,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
>> goto loop;
>> }
>> checks:
>> - search_start = ALIGN(offset, fs_info->stripesize);
>> + search_start = round_up(offset, fs_info->stripesize);
>>
>> /* move on to the next group */
>> if (search_start + num_bytes >
>>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 504 bytes --]
next prev parent reply other threads:[~2017-11-21 8:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 5:54 [PATCH] btrfs: extent-tree: Use round up to replace align macro Qu Wenruo
2017-11-21 7:33 ` Nikolay Borisov
2017-11-21 8:06 ` Qu Wenruo [this message]
2017-11-21 13:47 ` David Sterba
2017-11-21 13:36 ` David Sterba
2017-11-21 14:36 ` Qu Wenruo
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=c864ff00-ec2a-603b-cc2c-b942d2373f7c@suse.com \
--to=wqu@suse.com \
--cc=dsterba@suse.cz \
--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).