All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 4/4] btrfs: fix bytes_may_use underflow in prealloc error condtition
Date: Thu, 13 Feb 2020 12:17:24 +0200	[thread overview]
Message-ID: <55467ec8-f966-d4f9-d882-8c5881328f77@suse.com> (raw)
In-Reply-To: <20200211214042.4645-5-josef@toxicpanda.com>



On 11.02.20 г. 23:40 ч., Josef Bacik wrote:
> I hit the following warning while running my error injection stress testing
> 
> ------------[ cut here ]------------
> WARNING: CPU: 3 PID: 1453 at fs/btrfs/space-info.h:108 btrfs_free_reserved_data_space_noquota+0xfd/0x160 [btrfs]
> RIP: 0010:btrfs_free_reserved_data_space_noquota+0xfd/0x160 [btrfs]
> Call Trace:
> btrfs_free_reserved_data_space+0x4f/0x70 [btrfs]
> __btrfs_prealloc_file_range+0x378/0x470 [btrfs]
> elfcorehdr_read+0x40/0x40
> ? elfcorehdr_read+0x40/0x40
> ? btrfs_commit_transaction+0xca/0xa50 [btrfs]
> ? dput+0xb4/0x2a0
> ? btrfs_log_dentry_safe+0x55/0x70 [btrfs]
> ? btrfs_sync_file+0x30e/0x420 [btrfs]
> ? do_fsync+0x38/0x70
> ? __x64_sys_fdatasync+0x13/0x20
> ? do_syscall_64+0x5b/0x1b0
> ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
> ---[ end trace 70ccb5d0fe51151c ]---
> 
> This happens if we fail to insert our reserved file extent.  At this
> point we've already converted our reservation from ->bytes_may_use to
> ->bytes_reserved.  However once we break we will attempt to free
> everything from [cur_offset, end] from ->bytes_may_use, but our extent
> reservation will overlap part of this.
> 
> Fix this problem by adding ins.offset (our extent allocation size) to
> cur_offset so we remove the actual remaining part from ->bytes_may_use.
This contradicts the code, you are adding ins.objectid which is the
offset and not the size. This means either the code is buggy.
<snip>

>  		if (ret) {
> +			/*
> +			 * We've reserved this space, and thus converted it from
> +			 * ->bytes_may_use to ->bytes_reserved, which we cleanup
> +			 * here.  We need to adjust cur_offset so that we only
> +			 * drop the ->bytes_may_use for the area we still have
> +			 * remaining in ->>bytes_may_use.
> +			 */
> +			cur_offset += ins.objectid;
>  			btrfs_free_reserved_extent(fs_info, ins.objectid,
>  						   ins.offset, 0);
>  			btrfs_abort_transaction(trans, ret);
> 

  parent reply	other threads:[~2020-02-13 10:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 21:40 [PATCH 0/4] Error condition failure fixes Josef Bacik
2020-02-11 21:40 ` [PATCH 1/4] btrfs: set fs_root = NULL on error Josef Bacik
2020-02-12  0:55   ` Qu Wenruo
2020-02-13 10:05   ` Johannes Thumshirn
2020-02-13 10:48   ` Nikolay Borisov
2020-02-13 15:31     ` Josef Bacik
2020-02-13 15:32       ` Nikolay Borisov
2020-02-11 21:40 ` [PATCH 2/4] btrfs: do not check delayed items are empty for single trans cleanup Josef Bacik
2020-02-12  0:57   ` Qu Wenruo
2020-02-13 10:28   ` Nikolay Borisov
2020-02-13 11:15   ` Johannes Thumshirn
2020-02-11 21:40 ` [PATCH 3/4] btrfs: handle logged extent failure properly Josef Bacik
2020-02-12  0:58   ` Qu Wenruo
2020-02-13 10:26   ` Nikolay Borisov
2020-02-13 11:16   ` Johannes Thumshirn
2020-02-11 21:40 ` [PATCH 4/4] btrfs: fix bytes_may_use underflow in prealloc error condtition Josef Bacik
2020-02-12  1:00   ` Qu Wenruo
2020-02-13 10:17   ` Nikolay Borisov [this message]
2020-02-13 15:29     ` Josef Bacik
2020-02-13 15:47 [PATCH 0/4][v2] Error condition failure fixes Josef Bacik
2020-02-13 15:47 ` [PATCH 4/4] btrfs: fix bytes_may_use underflow in prealloc error condtition Josef Bacik

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=55467ec8-f966-d4f9-d882-8c5881328f77@suse.com \
    --to=nborisov@suse.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.