xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Valentin Priescu <vali.priescu@gmail.com>, xen-devel@lists.xensource.com
Cc: Matt Wilson <msw@amazon.com>, Valentin Priescu <priescuv@amazon.com>
Subject: Re: [PATCH] xen-blkback: defer freeing blkif to avoid blocking xenwatch
Date: Mon, 12 May 2014 10:39:33 +0100	[thread overview]
Message-ID: <537096D5.4090809@citrix.com> (raw)
In-Reply-To: <1399678479-14758-1-git-send-email-vali.priescu@gmail.com>

On 10/05/14 00:34, Valentin Priescu wrote:
> From: Valentin Priescu <priescuv@amazon.com>
> 
> Currently xenwatch blocks in VBD disconnect, waiting for all pending I/O
> requests to finish. If the VBD is attached to a hot-swappable disk, then
> xenwatch can hang for a long period of time, stalling other watches.
>
[...]
> 
> With this patch, when there is still pending I/O, the actual disconnect
> is done by the last reference holder (last pending I/O request). In this
> case, xenwatch doesn't block indefinitely.

[...]

> @@ -239,19 +253,26 @@ static void xen_blkif_disconnect(struct xen_blkif *blkif)
>  		blkif->xenblkd = NULL;
>  	}
>  
> -	atomic_dec(&blkif->refcnt);
> -	wait_event(blkif->waiting_to_free, atomic_read(&blkif->refcnt) == 0);
> -	atomic_inc(&blkif->refcnt);
> +	/* The above kthread_stop() guarantees that at this point we
> +	 * don't have any discard_io or other_io requests. So, checking
> +	 * for inflight IO is enough.
> +	 */
> +	if (!atomic_read(&blkif->inflight)) {

if (atomic_read(&blkif->inflight > 0)
    return -EBUSY;

> +		if (blkif->irq) {
> +			unbind_from_irqhandler(blkif->irq, blkif);
> +			blkif->irq = 0;
> +		}
>  
> -	if (blkif->irq) {
> -		unbind_from_irqhandler(blkif->irq, blkif);
> -		blkif->irq = 0;
> -	}
> +		if (blkif->blk_rings.common.sring) {
> +			xenbus_unmap_ring_vfree(blkif->be->dev,
> +				blkif->blk_ring);
> +			blkif->blk_rings.common.sring = NULL;
> +		}
>  
> -	if (blkif->blk_rings.common.sring) {
> -		xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
> -		blkif->blk_rings.common.sring = NULL;
> +		return 0;
>  	}
> +
> +	return -EBUSY;
>  }
[...]
> @@ -700,7 +720,9 @@ static void frontend_changed(struct xenbus_device *dev,
>  		 * Enforce precondition before potential leak point.
>  		 * xen_blkif_disconnect() is idempotent.
>  		 */
> -		xen_blkif_disconnect(be->blkif);
> +		err = xen_blkif_disconnect(be->blkif);
> +		if (err)
> +			break;
>  
>  		err = connect_ring(be);
>  		if (err)

If xen_blkif_disconnect() returns -EBUSY, nothing will trigger the
reconnect.

David

  parent reply	other threads:[~2014-05-12  9:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09 23:34 [PATCH] xen-blkback: defer freeing blkif to avoid blocking xenwatch Valentin Priescu
2014-05-09 23:56 ` Matt Wilson
2014-05-12  6:42   ` Vasiliy Tolstov
2014-05-12  8:59     ` Valentin Priescu
2014-05-12  9:12       ` Alexey
2014-05-12 10:50         ` Valentin Priescu
2014-05-12  9:39 ` David Vrabel [this message]
2014-05-12 10:41   ` Valentin Priescu
2014-05-12 10:43     ` David Vrabel
2014-05-12 10:47       ` Valentin Priescu
2014-05-12 16:40 ` Boris Ostrovsky
2014-05-12 17:04   ` Valentin Priescu
2014-05-12 17:50     ` Boris Ostrovsky
2014-05-12 19:25 ` [PATCH v2] " Valentin Priescu
2014-05-13  9:32   ` David Vrabel
2014-05-13 17:00     ` Vasiliy Tolstov
2014-05-13 17:32       ` Valentin Priescu
2014-05-13 17:39         ` Vasiliy Tolstov
2014-05-16  8:37     ` Valentin Priescu
2014-06-02 16:20     ` Matt Wilson
2014-05-20 20:28   ` [PATCH v3] " Valentin Priescu
2014-05-22  9:11     ` Vasiliy Tolstov
2014-05-22 10:16       ` Valentin Priescu
2014-06-03  8:07         ` Vasiliy Tolstov
2014-06-03  9:59           ` Valentin Priescu
2014-06-02 16:13     ` Valentin Priescu
2014-06-02 16:56       ` Konrad Rzeszutek Wilk

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=537096D5.4090809@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=msw@amazon.com \
    --cc=priescuv@amazon.com \
    --cc=vali.priescu@gmail.com \
    --cc=xen-devel@lists.xensource.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).