linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 3/4] btrfs: relocation: Check cancel request after each extent found
Date: Tue,  3 Dec 2019 14:42:53 +0800	[thread overview]
Message-ID: <20191203064254.22683-4-wqu@suse.com> (raw)
In-Reply-To: <20191203064254.22683-1-wqu@suse.com>

When relocating data block groups with tons of small extents, or
large metadata block groups, there can be over 200,000 extents.

We will iterate all extents of such block group in relocate_block_group(),
where iteration itself can be kinda time-consuming.

So when user want to cancel the balance, the extent iteration loop can
be another target.

This patch will add the cancelling check in the extent iteration loop of
relocate_block_group() to make balance cancelling faster.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/relocation.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 533481a1f962..161d66f70190 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4140,6 +4140,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
 				break;
 			}
 		}
+		if (should_cancel_balance(fs_info)) {
+			err = -ECANCELED;
+			break;
+		}
 	}
 	if (trans && progress && err == -ENOSPC) {
 		ret = btrfs_force_chunk_alloc(trans, rc->block_group->flags);
-- 
2.24.0


  parent reply	other threads:[~2019-12-03  6:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03  6:42 [PATCH 0/4] btrfs: Make balance cancelling response faster Qu Wenruo
2019-12-03  6:42 ` [PATCH 1/4] btrfs: relocation: Introduce error injection points for cancelling balance Qu Wenruo
2019-12-03 13:29   ` Johannes Thumshirn
2019-12-03  6:42 ` [PATCH 2/4] btrfs: relocation: Check cancel request after each data page read Qu Wenruo
2019-12-03  6:42 ` Qu Wenruo [this message]
2019-12-03  6:42 ` [PATCH 4/4] btrfs: relocation: Work around dead relocation stage loop Qu Wenruo
2019-12-04 16:39 ` [PATCH 0/4] btrfs: Make balance cancelling response faster David Sterba
2020-02-11  5:21   ` Qu Wenruo
2020-02-11  5:35     ` Qu Wenruo
2019-12-05  2:58 ` Zygo Blaxell
2019-12-05  3:26   ` Qu Wenruo

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=20191203064254.22683-4-wqu@suse.com \
    --to=wqu@suse.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).