From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: Martin Wilck <mwilck@suse.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH 7/8] libmultipath: handle TUR threads that can't be cancelled
Date: Fri, 12 Oct 2018 17:11:38 -0500 [thread overview]
Message-ID: <20181012221138.GJ29125@octiron.msp.redhat.com> (raw)
In-Reply-To: <20181010200506.15796-8-mwilck@suse.com>
On Wed, Oct 10, 2018 at 10:05:05PM +0200, Martin Wilck wrote:
> When the tur checker code determines that a hanging TUR thread
> couldn't be cancelled, rather than simply returning, reallocate
> the checker context and start a new thread. This will leak some
> memory if the hanging thread never wakes up again, but well, in
> that highly unlikely case we're leaking threads anyway.
>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
> libmultipath/checkers/tur.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
> index a986a244..9ecca5bd 100644
> --- a/libmultipath/checkers/tur.c
> +++ b/libmultipath/checkers/tur.c
> @@ -349,11 +349,29 @@ int libcheck_check(struct checker * c)
> }
> } else {
> if (uatomic_read(&ct->holders) > 1) {
> - /* The thread has been cancelled but hasn't
> - * quit. exit with timeout. */
> + int holders;
> +
> + /*
> + * The thread has been cancelled but hasn't quit.
> + * We have to prevent it from interfering with the new
> + * thread. We create a new context and leave the old
> + * one with the stale thread, hoping it will clean up
> + * eventually.
> + */
> condlog(3, "%d:%d : tur thread not responding",
> major(ct->devt), minor(ct->devt));
> - return PATH_TIMEOUT;
> +
> + /* libcheck_init will replace c->context */
> + libcheck_init(c);
> +
> + holders = uatomic_sub_return(&ct->holders, 1);
> + if (!holders)
> + /* It did terminate, eventually */
> + cleanup_context(ct);
> +
> + ct = c->context;
> + if (ct == NULL)
> + return PATH_UNCHECKED;
libcheck_init can fail to allocate the checker_context, and return 1.
If it does so, it won't reset c->context. In this case, you will unhold
the context but keep using it. Instead we should fail right after the
call to libcheck_init if it returns 1.
Also, returning PATH_UNCHECKED triggers code in check_path that assumes
there is a problem with the path. It recalls pathinfo(), and does not do
all the work that would happen on PATH_DOWN. PATH_TIMEOUT works like
PATH_DOWN and PATH_SHAKY, which seems like the right thing to do here.
-Ben
> }
> /* Start new TUR checker */
> pthread_mutex_lock(&ct->lock);
> --
> 2.19.0
next prev parent reply other threads:[~2018-10-12 22:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 20:04 [PATCH 0/8] various multipath-tools patches Martin Wilck
2018-10-10 20:04 ` [PATCH 1/8] test-kpartx: add test for invocation on image file Martin Wilck
2018-10-12 21:45 ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 2/8] libmultipath: scsi_ioctl_pathinfo doesn't fail Martin Wilck
2018-10-12 21:46 ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 3/8] libmultipath: cciss_ioctl_pathinfo " Martin Wilck
2018-10-12 21:47 ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 4/8] multipath.rules: add comment about DM_MULTIPATH_DEVICE_PATH=2 Martin Wilck
2018-10-12 21:49 ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 5/8] multipath.8: man page update Martin Wilck
2018-10-12 21:51 ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 6/8] libmultipath: test code for "zombie" TUR threads Martin Wilck
2018-10-12 21:51 ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 7/8] libmultipath: handle TUR threads that can't be cancelled Martin Wilck
2018-10-12 22:11 ` Benjamin Marzinski [this message]
2018-10-23 10:58 ` Martin Wilck
2018-10-10 20:05 ` [PATCH 8/8] multipathd: handle repeated udev retrigger failure Martin Wilck
2018-10-12 22:30 ` Benjamin Marzinski
2018-10-13 8:48 ` [PATCH 0/8] various multipath-tools patches Christophe Varoqui
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=20181012221138.GJ29125@octiron.msp.redhat.com \
--to=bmarzins@redhat.com \
--cc=dm-devel@redhat.com \
--cc=mwilck@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