public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v3 2/7] btrfs: check for priority ticket granting before flushing
Date: Thu, 11 Nov 2021 09:13:37 -0500	[thread overview]
Message-ID: <YY0lETfvTPmkvhA9@localhost.localdomain> (raw)
In-Reply-To: <f0f97d68-cf01-515b-f787-3ccb924ff9ad@suse.com>

On Thu, Nov 11, 2021 at 03:14:20PM +0200, Nikolay Borisov wrote:
> 
> 
> On 9.11.21 г. 17:12, Josef Bacik wrote:
> > Since we're dropping locks before we enter the priority flushing loops
> > we could have had our ticket granted before we got the space_info->lock.
> > So add this check to avoid doing some extra flushing in the priority
> > flushing cases.
> > 
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> 
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> 
> > --->  fs/btrfs/space-info.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> > index 9d6048f54097..9a362f3a6df4 100644
> > --- a/fs/btrfs/space-info.c
> > +++ b/fs/btrfs/space-info.c
> > @@ -1264,7 +1264,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
> >  
> >  	spin_lock(&space_info->lock);
> >  	to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info);
> > -	if (!to_reclaim) {
> > +	if (!to_reclaim || ticket->bytes == 0) {
> 
> nit: This is purely an optimization, handling the case where a prio
> ticket N is being added to the list, but at the same time we might have
> had ticket N-1 just satisfied (or failed) and having called
> try_granting_ticket might have satisfied concurrently added ticket N,
> right? And this is a completely independent change of the other cleanups
> being done here?
> 

It's definitely just an optimization, but it can be less specific than this.
Think we came in to reserve, we didn't have the space, we added our ticket to
the list.  But at the same time somebody was waiting on the space_info lock to
add space and do btrfs_try_granting_ticket(), so we drop the lock, get
satisfied, come in to do our loop, and we have been satisified.

This is the priority reclaim path, so to_reclaim could be !0 still because we
may have only satisified the priority tickets and still left non priority
tickets on the list.  We would then have to_reclaim but ->bytes == 0.

Clearly not a huge deal, I just noticied it when I was redoing the locking for
the cleanups and it annoyed me.  Thanks,

Josef

  reply	other threads:[~2021-11-11 14:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 15:12 [PATCH v3 0/7] Use global rsv stealing for evict and clean things up Josef Bacik
2021-11-09 15:12 ` [PATCH v3 1/7] btrfs: handle priority ticket failures in their respective helpers Josef Bacik
2021-11-11 13:10   ` Nikolay Borisov
2021-11-09 15:12 ` [PATCH v3 2/7] btrfs: check for priority ticket granting before flushing Josef Bacik
2021-11-11 13:14   ` Nikolay Borisov
2021-11-11 14:13     ` Josef Bacik [this message]
2021-11-11 14:50       ` Nikolay Borisov
2021-11-11 15:17         ` David Sterba
2021-11-17 17:04   ` Nikolay Borisov
2021-11-18  8:54     ` David Sterba
2021-11-09 15:12 ` [PATCH v3 3/7] btrfs: check ticket->steal in steal_from_global_block_rsv Josef Bacik
2021-11-11 13:28   ` Nikolay Borisov
2021-11-09 15:12 ` [PATCH v3 4/7] btrfs: make BTRFS_RESERVE_FLUSH_EVICT use the global rsv stealing code Josef Bacik
2021-11-11 14:46   ` Nikolay Borisov
2021-11-09 15:12 ` [PATCH v3 5/7] btrfs: remove global rsv stealing logic for orphan cleanup Josef Bacik
2021-11-09 15:12 ` [PATCH v3 6/7] btrfs: get rid of root->orphan_cleanup_state Josef Bacik
2021-11-09 15:12 ` [PATCH v3 7/7] btrfs: change root to fs_info for btrfs_reserve_metadata_bytes Josef Bacik
2021-11-16 16:38 ` [PATCH v3 0/7] Use global rsv stealing for evict and clean things up 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=YY0lETfvTPmkvhA9@localhost.localdomain \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --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