linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>, kernel-team@fb.com
Subject: Re: [PATCH 3/8] btrfs: explicitly protect ->last_byte_to_unpin in unpin_extent_range
Date: Wed, 4 Nov 2020 15:36:52 +0000	[thread overview]
Message-ID: <CAL3q7H6q35g5cYigKuyO46L+fAZJdf_rmsOKzwQ60ATHeXKjwA@mail.gmail.com> (raw)
In-Reply-To: <129622d0259e8e3209d4c9f9fe9a44e58a011b93.1603460665.git.josef@toxicpanda.com>

On Fri, Oct 23, 2020 at 5:12 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> Currently unpin_extent_range happens in the transaction commit context,
> so we are protected from ->last_byte_to_unpin changing while we're
> unpinning, because any new transactions would have to wait for us to
> complete before modifying ->last_byte_to_unpin.
>
> However in the future we may want to change how this works, for instance
> with async unpinning or other such TODO items.  To prepare for that
> future explicitly protect ->last_byte_to_unpin with the commit_root_sem
> so we are sure it won't change while we're doing our work.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Ok, looks good, thanks.

> ---
>  fs/btrfs/extent-tree.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index ee7bceace8b3..5d3564b077bf 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2791,11 +2791,13 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
>                 len = cache->start + cache->length - start;
>                 len = min(len, end + 1 - start);
>
> +               down_read(&fs_info->commit_root_sem);
>                 if (start < cache->last_byte_to_unpin && return_free_space) {
>                         u64 add_len = min(len,
>                                           cache->last_byte_to_unpin - start);
>                         btrfs_add_free_space(cache, start, add_len);
>                 }
> +               up_read(&fs_info->commit_root_sem);
>
>                 start += len;
>                 total_unpinned += len;
> --
> 2.26.2
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

  reply	other threads:[~2020-11-04 15:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 13:58 [PATCH 0/8] Block group caching fixes Josef Bacik
2020-10-23 13:58 ` [PATCH 1/8] btrfs: do not shorten unpin len for caching block groups Josef Bacik
2020-11-04 13:38   ` Filipe Manana
2020-10-23 13:58 ` [PATCH 2/8] btrfs: update last_byte_to_unpin in switch_commit_roots Josef Bacik
2020-11-04 15:15   ` Filipe Manana
2020-10-23 13:58 ` [PATCH 3/8] btrfs: explicitly protect ->last_byte_to_unpin in unpin_extent_range Josef Bacik
2020-11-04 15:36   ` Filipe Manana [this message]
2020-10-23 13:58 ` [PATCH 4/8] btrfs: cleanup btrfs_discard_update_discardable usage Josef Bacik
2020-11-04 15:54   ` Filipe Manana
2020-11-04 17:36     ` Amy Parker
2020-11-04 18:21     ` Josef Bacik
2020-11-04 18:28       ` Filipe Manana
2020-11-05 13:22         ` David Sterba
2020-10-23 13:58 ` [PATCH 5/8] btrfs: load free space cache into a temporary ctl Josef Bacik
2020-11-04 16:20   ` Filipe Manana
2020-10-23 13:58 ` [PATCH 6/8] btrfs: load the free space cache inode extents from commit root Josef Bacik
2020-11-04 16:27   ` Filipe Manana
2020-10-23 13:58 ` [PATCH 7/8] btrfs: async load free space cache Josef Bacik
2020-11-04 18:02   ` Filipe Manana
2020-10-23 13:58 ` [PATCH 8/8] btrfs: protect the fs_info->caching_block_groups differently Josef Bacik
2020-11-04 18:27   ` Filipe Manana
2020-11-05 14:27 ` [PATCH 0/8] Block group caching fixes 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=CAL3q7H6q35g5cYigKuyO46L+fAZJdf_rmsOKzwQ60ATHeXKjwA@mail.gmail.com \
    --to=fdmanana@gmail.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 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).