public inbox for linux-btrfs@vger.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 01/20] btrfs: change nr to u64 in btrfs_start_delalloc_roots
Date: Thu, 30 Jan 2020 14:06:04 +0200	[thread overview]
Message-ID: <21932aac-2499-6112-2f47-e85b7963c037@suse.com> (raw)
In-Reply-To: <20200129235024.24774-2-josef@toxicpanda.com>



On 30.01.20 г. 1:50 ч., Josef Bacik wrote:
> We have btrfs_wait_ordered_roots() which takes a u64 for nr, but
> btrfs_start_delalloc_roots() that takes an int for nr, which makes using
> them in conjunction, especially for something like (u64)-1, annoying and
> inconsistent.  Fix btrfs_start_delalloc_roots() to take a u64 for nr and
> adjust start_delalloc_inodes() and it's callers appropriately.

nit: You could include one more sentence to be explicit about the fact
that now 'nr' management is delegated to start_delalloc_inodes i.e you
pass it as a pointer to that function which in turn will control when
btrfs_Start_delalloc_roots breaks out of its own loop.

> 
> Part of adjusting the callers to this means changing
> btrfs_writeback_inodes_sb_nr() to take a u64 for items.  This may be
> confusing because it seems unrelated, but the caller of
> btrfs_writeback_inodes_sb_nr() already passes in a u64, it's just the
> function variable that needs to be changed.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/ctree.h       |  2 +-
>  fs/btrfs/dev-replace.c |  2 +-
>  fs/btrfs/inode.c       | 27 +++++++++++----------------
>  fs/btrfs/ioctl.c       |  2 +-
>  fs/btrfs/space-info.c  |  2 +-
>  5 files changed, 15 insertions(+), 20 deletions(-)
> 

<snip>

> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -9619,7 +9619,8 @@ static struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode
>   * some fairly slow code that needs optimization. This walks the list
>   * of all the inodes with pending delalloc and forces them to disk.
>   */
> -static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot)
> +static int start_delalloc_inodes(struct btrfs_root *root, u64 *nr,
> +				 bool snapshot)
>  {
>  	struct btrfs_inode *binode;
>  	struct inode *inode;
> @@ -9659,9 +9660,11 @@ static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot)
>  		list_add_tail(&work->list, &works);
>  		btrfs_queue_work(root->fs_info->flush_workers,
>  				 &work->work);
> -		ret++;
> -		if (nr != -1 && ret >= nr)
> -			goto out;
> +		if (*nr != U64_MAX) {
> +			(*nr)--;
> +			if (*nr == 0)
> +				goto out;
> +		}
>  		cond_resched();
>  		spin_lock(&root->delalloc_lock);
>  	}
> @@ -9686,18 +9689,15 @@ static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot)
>  int btrfs_start_delalloc_snapshot(struct btrfs_root *root)
>  {
>  	struct btrfs_fs_info *fs_info = root->fs_info;
> -	int ret;
> +	u64 nr = U64_MAX;

This var is never used past start_delalloc_snapshot so you can remove it
and simply pass U64_MAX to start_delalloc_inodes.

>  
>  	if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state))
>  		return -EROFS;
>  
> -	ret = start_delalloc_inodes(root, -1, true);
> -	if (ret > 0)
> -		ret = 0;
> -	return ret;
> +	return start_delalloc_inodes(root, &nr, true);
>  }
>  
> -int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr)
> +int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, u64 nr)
>  {
>  	struct btrfs_root *root;
>  	struct list_head splice;
> @@ -9720,15 +9720,10 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr)
>  			       &fs_info->delalloc_roots);
>  		spin_unlock(&fs_info->delalloc_root_lock);
>  
> -		ret = start_delalloc_inodes(root, nr, false);
> +		ret = start_delalloc_inodes(root, &nr, false);
>  		btrfs_put_root(root);
>  		if (ret < 0)
>  			goto out;
> -
> -		if (nr != -1) {
> -			nr -= ret;
> -			WARN_ON(nr < 0);
> -		}
>  		spin_lock(&fs_info->delalloc_root_lock);
>  	}
>  	spin_unlock(&fs_info->delalloc_root_lock);

<snip>

  reply	other threads:[~2020-01-30 12:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 23:50 [PATCH 00/20][RFC] Convert data reservations to the ticketing infrastructure Josef Bacik
2020-01-29 23:50 ` [PATCH 01/20] btrfs: change nr to u64 in btrfs_start_delalloc_roots Josef Bacik
2020-01-30 12:06   ` Nikolay Borisov [this message]
2020-01-31 15:07     ` Josef Bacik
2020-01-31 15:13       ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 02/20] btrfs: remove orig from shrink_delalloc Josef Bacik
2020-01-30 11:44   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 03/20] btrfs: handle U64_MAX for shrink_delalloc Josef Bacik
2020-01-30 11:46   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 04/20] btrfs: make shrink_delalloc take space_info as an arg Josef Bacik
2020-01-30 12:15   ` Nikolay Borisov
2020-01-30 12:35   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 05/20] btrfs: make ALLOC_CHUNK use the space info flags Josef Bacik
2020-01-30 13:19   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 06/20] btrfs: call btrfs_try_granting_tickets when freeing reserved bytes Josef Bacik
2020-01-31 11:16   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 07/20] btrfs: call btrfs_try_granting_tickets when unpinning anything Josef Bacik
2020-01-31 11:25   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 08/20] btrfs: call btrfs_try_granting_tickets when reserving space Josef Bacik
2020-01-31 11:37   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 09/20] btrfs: use the btrfs_space_info_free_bytes_may_use helper for delalloc Josef Bacik
2020-01-31 11:56   ` Nikolay Borisov
2020-01-29 23:50 ` [PATCH 10/20] btrfs: add flushing states for handling data reservations Josef Bacik
2020-01-29 23:50 ` [PATCH 11/20] btrfs: add btrfs_reserve_data_bytes and use it Josef Bacik
2020-01-29 23:50 ` [PATCH 12/20] btrfs: use ticketing for data space reservations Josef Bacik
2020-01-29 23:50 ` [PATCH 13/20] btrfs: run delayed iputs before committing the transaction for data Josef Bacik
2020-01-29 23:50 ` [PATCH 14/20] btrfs: flush delayed refs when trying to reserve data space Josef Bacik
2020-01-29 23:50 ` [PATCH 15/20] btrfs: serialize data reservations if we are flushing Josef Bacik
2020-01-29 23:50 ` [PATCH 16/20] btrfs: rework chunk allocate for data reservations Josef Bacik
2020-01-29 23:50 ` [PATCH 17/20] btrfs: drop the commit_cycles stuff " Josef Bacik
2020-01-29 23:50 ` [PATCH 18/20] btrfs: use the same helper for data and metadata reservations Josef Bacik
2020-01-29 23:50 ` [PATCH 19/20] btrfs: do async reclaim for data reservations Josef Bacik
2020-01-29 23:50 ` [PATCH 20/20] btrfs: kill the priority_reclaim_space helper 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=21932aac-2499-6112-2f47-e85b7963c037@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox