From: Coly Li <colyli@suse.de>
To: axboe@kernel.dk
Cc: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org,
hare@suse.de, mhocko@suse.com, mkoutny@suse.com,
Coly Li <colyli@suse.de>
Subject: [PATCH 1/2] bcache: ignore pending signals in bcache_device_init()
Date: Mon, 2 Mar 2020 17:34:49 +0800 [thread overview]
Message-ID: <20200302093450.48016-2-colyli@suse.de> (raw)
In-Reply-To: <20200302093450.48016-1-colyli@suse.de>
When cache device and cached device are registered simuteneously and
register_cache() firstly acquires bch_register_lock. register_bdev()
has to wait before register_cache() finished, it might be a very long
time.
If the registration is from udev rules in system boot up time, and
registration is not completed before udev timeout (default 180s), the
registration process will be killed by udevd. Then the following calls
to kthread_run() or kthread_create() will fail due to the pending
signal (they are implemented this way at this moment).
For boot time, this is not good, because it means a cache device with
huge cached data will always fail in boot time, just because it
spends too much time to check its internal meta data (btree and dirty
sectors).
The failure for cache device registration is solved by previous
patches, but failure due to timeout also exists in cached device
registration. As the above text explains, cached device registration
may also be timeout if it is blocked by a timeout cache device
registration process. Then in the following code path,
bioset_init() <= bcache_device_init() <= cached_dev_init() <=
register_bdev() <= register_bcache()
bioset_init() will fail because internally kthread_create() will fail
for pending signal in the following code path,
bioset_init() => alloc_workqueue() => init_rescuer() =>
kthread_create()
Maybe fix kthread_create() and kthread_run() is better method, but at
this moment a fast workaroudn is to flush pending signals before
calling bioset_init() in bcache_device_init().
This patch calls flush_signals() in bcache_device_init() if there is
pending signal for current process. It avoids bcache registration
failure in system boot up time due to bcache udev rule timeout.
Signed-off-by: Coly Li <colyli@suse.de>
---
drivers/md/bcache/super.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 0c3c5419c52b..e8bbd4f171ca 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -850,6 +850,18 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
if (idx < 0)
return idx;
+ /*
+ * There is a timeout in udevd, if the bcache device is registering
+ * by udev rules, and not completed in time, the udevd may kill the
+ * registration process. In this condition, there will be pending
+ * signal here and cause bioset_init() failed for internally creating
+ * its kthread. Here the registration should ignore the timeout and
+ * continue, it is safe to ignore the pending signal and avoid to
+ * fail bcache registration in boot up time.
+ */
+ if (signal_pending(current))
+ flush_signals(current);
+
if (bioset_init(&d->bio_split, 4, offsetof(struct bbio, bio),
BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER))
goto err;
--
2.16.4
next prev parent reply other threads:[~2020-03-02 9:35 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 9:34 [PATCH 0/2] bcache patches for Linux v5.6-rc5 Coly Li
2020-03-02 9:34 ` Coly Li [this message]
2020-03-02 12:27 ` [PATCH 1/2] bcache: ignore pending signals in bcache_device_init() Michal Hocko
2020-03-02 13:29 ` Coly Li
2020-03-02 13:40 ` Michal Hocko
2020-03-02 17:06 ` Coly Li
2020-03-02 17:28 ` Michal Hocko
2020-03-02 17:47 ` Coly Li
2020-03-03 1:22 ` Guoqing Jiang
2020-03-03 1:30 ` Coly Li
2020-03-03 6:58 ` Сорокин Артем Сергеевич
2020-04-13 8:17 ` Coly Li
2020-03-02 13:49 ` Oleg Nesterov
2020-03-02 17:16 ` Coly Li
2020-03-02 17:19 ` Jens Axboe
2020-03-02 17:32 ` Coly Li
2020-03-02 20:33 ` Jens Axboe
2020-03-03 1:08 ` Coly Li
2020-03-03 7:22 ` Hannes Reinecke
2020-03-03 8:05 ` Michal Hocko
2020-03-03 12:19 ` Oleg Nesterov
2020-03-03 16:03 ` Michal Hocko
2020-03-04 11:36 ` Oleg Nesterov
2020-03-04 11:53 ` Oleg Nesterov
2020-03-04 18:42 ` Jens Axboe
2020-03-04 11:57 ` Michal Hocko
2020-03-04 12:13 ` Oleg Nesterov
2020-03-04 12:22 ` Michal Hocko
2020-03-04 12:33 ` Oleg Nesterov
2020-03-04 12:41 ` Michal Hocko
2020-03-04 13:02 ` Oleg Nesterov
2020-03-04 13:21 ` Michal Hocko
2020-03-02 15:01 ` Jens Axboe
2020-03-02 9:34 ` [PATCH 2/2] bcache: fix code comments for ignore pending signals Coly Li
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=20200302093450.48016-2-colyli@suse.de \
--to=colyli@suse.de \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=mkoutny@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