linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com, wqu@suse.com
Subject: Re: [PATCH 1/4] btrfs: don't pass system_chunk into can_overcommit
Date: Tue, 26 Nov 2019 10:32:06 +0800	[thread overview]
Message-ID: <5cdd2708-2902-8c4b-98ed-7b6432542dd7@gmx.com> (raw)
In-Reply-To: <20191125144011.146722-2-josef@toxicpanda.com>


[-- Attachment #1.1: Type: text/plain, Size: 6792 bytes --]



On 2019/11/25 下午10:40, Josef Bacik wrote:
> We have the space_info, we can just check its flags to see if it's the
> system chunk space info.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  fs/btrfs/space-info.c | 41 +++++++++++++++--------------------------
>  1 file changed, 15 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index f09aa6ee9113..df5fb68df798 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -161,8 +161,7 @@ static inline u64 calc_global_rsv_need_space(struct btrfs_block_rsv *global)
>  
>  static int can_overcommit(struct btrfs_fs_info *fs_info,
>  			  struct btrfs_space_info *space_info, u64 bytes,
> -			  enum btrfs_reserve_flush_enum flush,
> -			  bool system_chunk)
> +			  enum btrfs_reserve_flush_enum flush)
>  {
>  	u64 profile;
>  	u64 avail;
> @@ -173,7 +172,7 @@ static int can_overcommit(struct btrfs_fs_info *fs_info,
>  	if (space_info->flags & BTRFS_BLOCK_GROUP_DATA)
>  		return 0;
>  
> -	if (system_chunk)
> +	if (space_info->flags & BTRFS_BLOCK_GROUP_SYSTEM)
>  		profile = btrfs_system_alloc_profile(fs_info);
>  	else
>  		profile = btrfs_metadata_alloc_profile(fs_info);
> @@ -227,8 +226,7 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info,
>  
>  		/* Check and see if our ticket can be satisified now. */
>  		if ((used + ticket->bytes <= space_info->total_bytes) ||
> -		    can_overcommit(fs_info, space_info, ticket->bytes, flush,
> -				   false)) {
> +		    can_overcommit(fs_info, space_info, ticket->bytes, flush)) {
>  			btrfs_space_info_update_bytes_may_use(fs_info,
>  							      space_info,
>  							      ticket->bytes);
> @@ -626,8 +624,7 @@ static void flush_space(struct btrfs_fs_info *fs_info,
>  
>  static inline u64
>  btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
> -				 struct btrfs_space_info *space_info,
> -				 bool system_chunk)
> +				 struct btrfs_space_info *space_info)
>  {
>  	struct reserve_ticket *ticket;
>  	u64 used;
> @@ -643,13 +640,13 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
>  
>  	to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M);
>  	if (can_overcommit(fs_info, space_info, to_reclaim,
> -			   BTRFS_RESERVE_FLUSH_ALL, system_chunk))
> +			   BTRFS_RESERVE_FLUSH_ALL))
>  		return 0;
>  
>  	used = btrfs_space_info_used(space_info, true);
>  
>  	if (can_overcommit(fs_info, space_info, SZ_1M,
> -			   BTRFS_RESERVE_FLUSH_ALL, system_chunk))
> +			   BTRFS_RESERVE_FLUSH_ALL))
>  		expected = div_factor_fine(space_info->total_bytes, 95);
>  	else
>  		expected = div_factor_fine(space_info->total_bytes, 90);
> @@ -665,7 +662,7 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
>  
>  static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info,
>  					struct btrfs_space_info *space_info,
> -					u64 used, bool system_chunk)
> +					u64 used)
>  {
>  	u64 thresh = div_factor_fine(space_info->total_bytes, 98);
>  
> @@ -673,8 +670,7 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info,
>  	if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh)
>  		return 0;
>  
> -	if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info,
> -					      system_chunk))
> +	if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info))
>  		return 0;
>  
>  	return (used >= thresh && !btrfs_fs_closing(fs_info) &&
> @@ -765,8 +761,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
>  	space_info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
>  
>  	spin_lock(&space_info->lock);
> -	to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info,
> -						      false);
> +	to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info);
>  	if (!to_reclaim) {
>  		space_info->flush = 0;
>  		spin_unlock(&space_info->lock);
> @@ -785,8 +780,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
>  			return;
>  		}
>  		to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info,
> -							      space_info,
> -							      false);
> +							      space_info);
>  		if (last_tickets_id == space_info->tickets_id) {
>  			flush_state++;
>  		} else {
> @@ -858,8 +852,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
>  	int flush_state;
>  
>  	spin_lock(&space_info->lock);
> -	to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info,
> -						      false);
> +	to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info);
>  	if (!to_reclaim) {
>  		spin_unlock(&space_info->lock);
>  		return;
> @@ -990,8 +983,7 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info,
>  static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
>  				    struct btrfs_space_info *space_info,
>  				    u64 orig_bytes,
> -				    enum btrfs_reserve_flush_enum flush,
> -				    bool system_chunk)
> +				    enum btrfs_reserve_flush_enum flush)
>  {
>  	struct reserve_ticket ticket;
>  	u64 used;
> @@ -1013,8 +1005,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
>  	 */
>  	if (!pending_tickets &&
>  	    ((used + orig_bytes <= space_info->total_bytes) ||
> -	     can_overcommit(fs_info, space_info, orig_bytes, flush,
> -			   system_chunk))) {
> +	     can_overcommit(fs_info, space_info, orig_bytes, flush))) {
>  		btrfs_space_info_update_bytes_may_use(fs_info, space_info,
>  						      orig_bytes);
>  		ret = 0;
> @@ -1054,8 +1045,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
>  		 * the async reclaim as we will panic.
>  		 */
>  		if (!test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags) &&
> -		    need_do_async_reclaim(fs_info, space_info,
> -					  used, system_chunk) &&
> +		    need_do_async_reclaim(fs_info, space_info, used) &&
>  		    !work_busy(&fs_info->async_reclaim_work)) {
>  			trace_btrfs_trigger_flush(fs_info, space_info->flags,
>  						  orig_bytes, flush, "preempt");
> @@ -1092,10 +1082,9 @@ int btrfs_reserve_metadata_bytes(struct btrfs_root *root,
>  	struct btrfs_fs_info *fs_info = root->fs_info;
>  	struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv;
>  	int ret;
> -	bool system_chunk = (root == fs_info->chunk_root);
>  
>  	ret = __reserve_metadata_bytes(fs_info, block_rsv->space_info,
> -				       orig_bytes, flush, system_chunk);
> +				       orig_bytes, flush);
>  	if (ret == -ENOSPC &&
>  	    unlikely(root->orphan_cleanup_state == ORPHAN_CLEANUP_STARTED)) {
>  		if (block_rsv != global_rsv &&
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2019-11-26  2:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 14:40 [PATCH 0/4][RFC] clean up how we mark block groups read only Josef Bacik
2019-11-25 14:40 ` [PATCH 1/4] btrfs: don't pass system_chunk into can_overcommit Josef Bacik
2019-11-25 15:36   ` Johannes Thumshirn
2019-11-26  2:32   ` Qu Wenruo [this message]
2019-11-26  8:42   ` Nikolay Borisov
2019-11-25 14:40 ` [PATCH 2/4] btrfs: kill min_allocable_bytes in inc_block_group_ro Josef Bacik
2019-11-26  2:35   ` Qu Wenruo
2019-11-25 14:40 ` [PATCH 3/4] btrfs: fix force usage " Josef Bacik
2019-11-26  2:43   ` Qu Wenruo
2019-11-26  4:59     ` Qu Wenruo
2019-11-26 10:09   ` Nikolay Borisov
2019-11-25 14:40 ` [PATCH 4/4] btrfs: use btrfs_can_overcommit " Josef Bacik
2019-11-26  3:00   ` Qu Wenruo
2019-11-26 16:28     ` Josef Bacik
2019-11-26 10:18   ` Nikolay Borisov
2019-11-26 16:25 [PATCH 0/4][v2] clean up how we mark block groups read only Josef Bacik
2019-11-26 16:25 ` [PATCH 1/4] btrfs: don't pass system_chunk into can_overcommit 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=5cdd2708-2902-8c4b-98ed-7b6432542dd7@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@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;
as well as URLs for NNTP newsgroup(s).