public inbox for linux-bcache@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Vazharov <freakpv@gmail.com>
To: mlyle@lyle.org, kent.overstreet@gmail.com
Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pavel Vazharov <freakpv@gmail.com>
Subject: [PATCH] bcache: btree.c: Fix GC thread exit in case of cache device failure and unregister
Date: Fri, 12 Jan 2018 17:24:50 +0200	[thread overview]
Message-ID: <1515770690-18562-1-git-send-email-freakpv@gmail.com> (raw)

There was a possibility for infinite do-while loop inside the GC thread
function in case of total failure of the caching device. I was able to
reproduce it 3 times simulating disappearing of the caching device via
'echo 1 > /sys/block/<dev>/device/delete'. In that case the btree_root
starts to return non zero and non -EAGAIN result, 'gc failed' message
start to fill the kernel log and the do-while becomes infinite loop
occupying single CPU core at 100%.
There is already a logic which unregisters the cache_set (or panics) in
case of io errors and thus we exit the loop here if the unregistering
procedure has already started.

Signed-off-by: Pavel Vazharov <freakpv@gmail.com>
---
 drivers/md/bcache/btree.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 81e8dc3..a672081 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1748,8 +1748,12 @@ static void bch_btree_gc(struct cache_set *c)
 		closure_sync(&writes);
 		cond_resched();
 
-		if (ret && ret != -EAGAIN)
-			pr_warn("gc failed!");
+		if (ret && ret != -EAGAIN) {
+			if (test_bit(CACHE_SET_UNREGISTERING, &c->flags))
+				break;
+			else
+				pr_warn("gc failed!");
+		}
 	} while (ret);
 
 	bch_btree_gc_finish(c);
-- 
2.7.4

             reply	other threads:[~2018-01-12 15:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 15:24 Pavel Vazharov [this message]
2018-01-13  4:06 ` [PATCH] bcache: btree.c: Fix GC thread exit in case of cache device failure and unregister Coly Li
2018-01-13  4:43   ` Pavel Vazharov

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=1515770690-18562-1-git-send-email-freakpv@gmail.com \
    --to=freakpv@gmail.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlyle@lyle.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