From: Josef Bacik <jbacik@fb.com>
To: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>,
<linux-btrfs@vger.kernel.org>
Cc: <dsterba@suse.cz>, <holger@applied-asynchrony.com>
Subject: Re: [PATCH 1/4] btrfs: use correct offset for reloc_inode in prealloc_file_extent_cluster()
Date: Thu, 21 Jul 2016 09:05:01 -0400 [thread overview]
Message-ID: <cf46653d-13f6-84a5-0d46-16a308d9a01e@fb.com> (raw)
In-Reply-To: <57902A11.9070201@cn.fujitsu.com>
On 07/20/2016 09:49 PM, Wang Xiaoguang wrote:
> hello,
>
> On 07/20/2016 09:18 PM, Josef Bacik wrote:
>> On 07/20/2016 01:56 AM, Wang Xiaoguang wrote:
>>> In prealloc_file_extent_cluster(), btrfs_check_data_free_space() uses
>>> wrong file offset for reloc_inode, it uses cluster->start and cluster->end,
>>> which indeed are extent's bytenr. The correct value should be
>>> cluster->[start|end] minus block group's start bytenr.
>>>
>>> start bytenr cluster->start
>>> | | extent | extent | ...| extent |
>>> |----------------------------------------------------------------|
>>> | block group reloc_inode |
>>>
>>> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
>>> ---
>>> fs/btrfs/relocation.c | 10 ++++++----
>>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
>>> index 0477dca..a0de885 100644
>>> --- a/fs/btrfs/relocation.c
>>> +++ b/fs/btrfs/relocation.c
>>> @@ -3030,12 +3030,14 @@ int prealloc_file_extent_cluster(struct inode *inode,
>>> u64 num_bytes;
>>> int nr = 0;
>>> int ret = 0;
>>> + u64 prealloc_start = cluster->start - offset;
>>> + u64 prealloc_end = cluster->end - offset;
>>>
>>> BUG_ON(cluster->start != cluster->boundary[0]);
>>> inode_lock(inode);
>>>
>>> - ret = btrfs_check_data_free_space(inode, cluster->start,
>>> - cluster->end + 1 - cluster->start);
>>> + ret = btrfs_check_data_free_space(inode, prealloc_start,
>>> + prealloc_end + 1 - prealloc_start);
>>> if (ret)
>>> goto out;
>>>
>>> @@ -3056,8 +3058,8 @@ int prealloc_file_extent_cluster(struct inode *inode,
>>> break;
>>> nr++;
>>> }
>>> - btrfs_free_reserved_data_space(inode, cluster->start,
>>> - cluster->end + 1 - cluster->start);
>>> + btrfs_free_reserved_data_space(inode, prealloc_start,
>>> + prealloc_end + 1 - prealloc_start);
>>> out:
>>> inode_unlock(inode);
>>> return ret;
>>>
>>
>> This ends up being the same amount. Consider this scenario
>>
>> bg bytenr = 4096
>> cluster->start = 8192
>> cluster->end = 12287
>>
>> cluster->end + 1 - cluster->start = 4096
>>
>> prealloc_start = cluster->start - offset = 0
>> prealloc_end = cluster->end - offset = 8191
>>
>> prealloc_end + 1 - prealloc_start = 4096
>>
>> You shift both by the same amount, which gives you the same answer. Thanks,
> Thanks for reviewing.
> Yes, I know the amount of preallocated data space is the same, this patch
> does not fix any bugs :)
>
> For every block group to be balanced, we create a corresponding inode.
> For this inode, the initial offset should be 0. In your above example,
> before this patch, it's btrfs_free_reserved_data_space(inode, 8192, 4096);
> with this patch, it's btrfs_free_reserved_data_space(inode, 4096, 4096).
>
> I just want to make btrfs_free_reserved_data_space()'s 'start' argument
> be offset inside block group, not offset inside whole fs byternr space. I'm not
> a English native, hope that I have expressed what I want to :)
>
> But yes, I'm also OK with removing this patch.
>
Oh I see, ok that's fine if we're just trying to make it look sane then go for it.
Signed-off-by: Josef Bacik <jbacik@fb.com>
Thanks,
Josef
next prev parent reply other threads:[~2016-07-21 13:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-20 5:56 [PATCH 0/4] update bytes_may_use timely to avoid false ENOSPC issue Wang Xiaoguang
2016-07-20 5:56 ` [PATCH 1/4] btrfs: use correct offset for reloc_inode in prealloc_file_extent_cluster() Wang Xiaoguang
2016-07-20 13:18 ` Josef Bacik
2016-07-21 1:49 ` Wang Xiaoguang
2016-07-21 13:05 ` Josef Bacik [this message]
2016-07-20 5:56 ` [PATCH 2/4] btrfs: divide btrfs_update_reserved_bytes() into two functions Wang Xiaoguang
2016-07-20 13:21 ` Josef Bacik
2016-07-20 5:56 ` [PATCH 3/4] btrfs: introduce new EXTENT_CLEAR_DATA_RESV flag Wang Xiaoguang
2016-07-20 13:22 ` Josef Bacik
2016-07-21 1:15 ` Wang Xiaoguang
2016-07-20 5:56 ` [PATCH 4/4] btrfs: update btrfs_space_info's bytes_may_use timely Wang Xiaoguang
2016-07-20 13:35 ` Josef Bacik
2016-07-21 1:18 ` Wang Xiaoguang
2016-07-20 8:46 ` [PATCH 0/4] update bytes_may_use timely to avoid false ENOSPC issue Holger Hoffstätte
2016-07-21 1:51 ` Wang Xiaoguang
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=cf46653d-13f6-84a5-0d46-16a308d9a01e@fb.com \
--to=jbacik@fb.com \
--cc=dsterba@suse.cz \
--cc=holger@applied-asynchrony.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangxg.fnst@cn.fujitsu.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).