From: Nikolay Borisov <nborisov@suse.com>
To: dsterba@suse.cz, Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 5/7] btrfs: just delete pending bgs if we are aborted
Date: Thu, 17 Jan 2019 17:40:25 +0200 [thread overview]
Message-ID: <a2af90d1-067b-870d-802f-c9cdf2b0e6f5@suse.com> (raw)
In-Reply-To: <20190117145632.GS2900@twin.jikos.cz>
On 17.01.19 г. 16:56 ч., David Sterba wrote:
> On Wed, Jan 16, 2019 at 04:22:55PM +0100, David Sterba wrote:
>> On Wed, Jan 16, 2019 at 03:59:20PM +0100, David Sterba wrote:
>>> On Wed, Nov 21, 2018 at 02:05:43PM -0500, Josef Bacik wrote:
>>>> We still need to do all of the accounting cleanup for pending block
>>>> groups if we abort. So set the ret to trans->aborted so if we aborted
>>>> the cleanup happens and everybody is happy.
>>>>
>>>> Reviewed-by: Omar Sandoval <osandov@fb.com>
>>>> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
>>>> ---
>>>> fs/btrfs/extent-tree.c | 8 +++++++-
>>>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>>>> index b9b829c8825c..90423b6749b7 100644
>>>> --- a/fs/btrfs/extent-tree.c
>>>> +++ b/fs/btrfs/extent-tree.c
>>>> @@ -10500,11 +10500,17 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
>>>> struct btrfs_root *extent_root = fs_info->extent_root;
>>>> struct btrfs_block_group_item item;
>>>> struct btrfs_key key;
>>>> - int ret = 0;
>>>> + int ret;
>>>>
>>>> if (!trans->can_flush_pending_bgs)
>>>> return;
>>>>
>>>> + /*
>>>> + * If we aborted the transaction with pending bg's we need to just
>>>> + * cleanup the list and carry on.
>>>> + */
>>>> + ret = trans->aborted;
>>>
>>> The cleanup is suitable for a separate helper that does only
>>>
>>> while (!list_empty(&trans->new_bgs)) {
>>> list_del_init(&block_group->bg_list);
>>> btrfs_delayed_refs_rsv_release(fs_info, 1);
>>> }
>>>
>>> and does not rely on the transaction->abort in a function with 'create'
>>> in it's name.
>>>
>>> The related part is in a separate patch that ab-uses the fact that
>>> setting ->abort will trigger the cleanup.
>>>
>>> https://patchwork.kernel.org/patch/10693081/ will then simply call the
>>> halper instead of
>>>
>>> + /* This cleans up the pending block groups list properly. */
>>> + if (!trans->aborted)
>>> + trans->aborted = ret;
>>> + btrfs_create_pending_block_groups(trans);
>>>
>>> Setting aborted to an error code anywhere else than
>>> __btrfs_abort_transaction does not sound right as it misses the whole
>>> report.
>>
>> Like this:
>>
>> --- a/fs/btrfs/transaction.c
>> +++ b/fs/btrfs/transaction.c
>> @@ -1901,6 +1901,20 @@ static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info)
>> btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1);
>> }
>>
>> +static void btrfs_cleanup_pending_block_groups(struct btrfs_trans_handle *trans)
>> +{
>> + struct btrfs_fs_info *fs_info = trans->fs_info;
>> + struct btrfs_block_group_cache *block_group;
>> +
>> + while (!list_empty(&trans->new_bgs)) {
>> + block_group = list_first_entry(&trans->new_bgs,
>> + struct btrfs_block_group_cache,
>> + bg_list);
>> + btrfs_delayed_refs_rsv_release(fs_info, 1);
>> + list_del_init(&block_group->bg_list);
>> + }
>> +}
>> +
>> int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
>> {
>> struct btrfs_fs_info *fs_info = trans->fs_info;
>> @@ -2270,6 +2284,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
>> btrfs_scrub_continue(fs_info);
>> cleanup_transaction:
>> btrfs_trans_release_metadata(trans);
>> + btrfs_cleanup_pending_block_groups(trans);
>> btrfs_trans_release_chunk_metadata(trans);
>> trans->block_rsv = NULL;
>> btrfs_warn(fs_info, "Skipping commit of aborted transaction.");
>> ---
>>
>> The call to btrfs_trans_release_chunk_metadata is not duplicated now as it
>> would happen twice in you version (within btrfs_create_pending_block_groups and
>> in transaction commit).
>
> FYI, this passed the 475 test (with accounting warnings that are
> possibly fixed by the other patches) + no blowups in the following
> tests.
For what is worth 475 doesn't always fail for me - without those
patches. So make sure you have given it a good bashing before deeming it
good.
>
next prev parent reply other threads:[~2019-01-17 15:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 19:05 [PATCH 0/7] Abort cleanup fixes Josef Bacik
2018-11-21 19:05 ` [PATCH 1/7] btrfs: make btrfs_destroy_delayed_refs use btrfs_delayed_ref_lock Josef Bacik
2018-11-21 19:05 ` [PATCH 2/7] btrfs: make btrfs_destroy_delayed_refs use btrfs_delete_ref_head Josef Bacik
2018-11-21 19:05 ` [PATCH 3/7] btrfs: handle delayed ref head accounting cleanup in abort Josef Bacik
2018-11-21 19:05 ` [PATCH 4/7] btrfs: call btrfs_create_pending_block_groups unconditionally Josef Bacik
2018-11-21 19:05 ` [PATCH 5/7] btrfs: just delete pending bgs if we are aborted Josef Bacik
2019-01-16 14:59 ` David Sterba
2019-01-16 15:22 ` David Sterba
2019-01-17 14:56 ` David Sterba
2019-01-17 14:58 ` Josef Bacik
2019-01-17 15:40 ` Nikolay Borisov [this message]
2018-11-21 19:05 ` [PATCH 6/7] btrfs: cleanup pending bgs on transaction abort Josef Bacik
2018-11-21 19:05 ` [PATCH 7/7] btrfs: wait on ordered extents on abort cleanup Josef Bacik
2019-01-14 11:55 ` [PATCH 0/7] Abort cleanup fixes David Sterba
2019-01-28 22:06 ` 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=a2af90d1-067b-870d-802f-c9cdf2b0e6f5@suse.com \
--to=nborisov@suse.com \
--cc=dsterba@suse.cz \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.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;
as well as URLs for NNTP newsgroup(s).