All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: David Vrabel <david.vrabel@citrix.com>, xen-devel@lists.xenproject.org
Cc: Jenny Herbert <jennifer.herbert@citrix.com>
Subject: Re: [PATCH 12/14] xen-blkback: safely unmap grants in case they are still in use
Date: Wed, 14 Jan 2015 10:47:26 -0500	[thread overview]
Message-ID: <54B68F8E.60805@oracle.com> (raw)
In-Reply-To: <1421077417-7162-13-git-send-email-david.vrabel@citrix.com>


>   
> +static void xen_blkbk_unmap_and_respond_callback(int result, struct gntab_unmap_queue_data *data)
> +{
> +	struct pending_req* pending_req = (struct pending_req*) (data->data);
> +	struct xen_blkif *blkif = pending_req->blkif;
> +
> +	/* BUG_ON used to reproduce existing behaviour,
> +	   but is this the best way to deal with this? */
> +	BUG_ON(result);
> +	/* free page after unmap */
> +	put_free_pages(blkif, data->pages, data->count);
> +
> +	/* respond */
> +	make_response(blkif, pending_req->id,
> +		      pending_req->operation, pending_req->status);
> +	free_req(blkif, pending_req);
> +	/*
> +	 * Make sure the request is freed before releasing blkif,
> +	 * or there could be a race between free_req and the
> +	 * cleanup done in xen_blkif_free during shutdown.
> +	 *
> +	 * NB: The fact that we might try to wake up pending_free_wq
> +	 * before drain_complete (in case there's a drain going on)
> +	 * it's not a problem with our current implementation
> +	 * because we can assure there's no thread waiting on
> +	 * pending_free_wq if there's a drain going on, but it has
> +	 * to be taken into account if the current model is changed.
> +	 */
> +	if (atomic_dec_and_test(&blkif->inflight) && atomic_read(&blkif->drain)) {
> +		complete(&blkif->drain_complete);
> +	}
> +	xen_blkif_put(blkif);
> +}
> +
> +static void xen_blkbk_unmap_populate(struct pending_req *req)
> +{
> +
> +       struct gntab_unmap_queue_data* work = &req->gnttab_unmap_data;
> +       struct xen_blkif *blkif = req->blkif;
> +       struct grant_page **pages = req->segments;
> +       unsigned int i, invcount = 0;
> +
> +       for (i = 0; i < req->nr_pages; i++) {
> +		if (pages[i]->persistent_gnt != NULL) {
> +			put_persistent_gnt(blkif, pages[i]->persistent_gnt);
> +			continue;
> +		}
> +		if (pages[i]->handle == BLKBACK_INVALID_HANDLE)
> +			continue;
> +
> +		req->unmap_pages[invcount] = pages[i]->page;
> +		gnttab_set_unmap_op(&req->unmap[invcount], vaddr(pages[invcount]->page),
> +				    GNTMAP_host_map, pages[i]->handle);
> +		pages[i]->handle = BLKBACK_INVALID_HANDLE;
> +		invcount++;
> +       }
> +
> +       work->data = req;
> +       work->done = &xen_blkbk_unmap_and_respond_callback;
> +       work->unmap_ops = req->unmap;
> +       work->kunmap_ops = NULL;
> +       work->pages = req->unmap_pages;
> +       work->count = invcount;
> +
> +}
> +
> +static void xen_blkbk_unmap_and_respond(struct pending_req *req)
> +{
> +       xen_blkbk_unmap_populate(req);
> +       gnttab_unmap_refs_async(&req->gnttab_unmap_data);
> +}

(One more for this patch)

If you are using async unmap here, I thought new interface requires you 
to wait for completion (which should be called from 
xen_blkbk_unmap_and_respond_callback()).

-boris

>   /*
>    * Unmap the grant references, and also remove the M2P over-rides
>    * used in the 'pending_req'.
> @@ -982,6 +1075,9 @@ static void __end_block_io_op(struct pending_req *pending_req, int error)
>   	 * the grant references associated with 'request' and provide
>   	 * the proper response on the ring.
>   	 */
> +	if (atomic_dec_and_test(&pending_req->pendcnt))
> +		xen_blkbk_unmap_and_respond(pending_req);
> +
>   	if (atomic_dec_and_test(&pending_req->pendcnt)) {
>   		struct xen_blkif *blkif = pending_req->blkif;
>   

  parent reply	other threads:[~2015-01-14 15:47 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 15:43 [PATCHv2 00/14] xen: fix many long-standing grant mapping bugs David Vrabel
2015-01-12 15:43 ` [PATCH 01/14] mm: provide a find_page vma operation David Vrabel
2015-01-12 15:43 ` [PATCH 02/14] mm: add 'foreign' alias for the 'pinned' page flag David Vrabel
2015-01-12 15:43 ` [PATCH 03/14] xen/grant-table: pre-populate kernel unmap ops for xen_gnttab_unmap_refs() David Vrabel
2015-01-12 15:43 ` [PATCH 04/14] xen: remove scratch frames for ballooned pages and m2p override David Vrabel
2015-01-12 15:43 ` [PATCH 05/14] x86/xen: require ballooned pages for grant maps David Vrabel
2015-01-12 15:43 ` [PATCH 06/14] xen/grant-table: add helpers for allocating pages David Vrabel
2015-01-12 15:43 ` [PATCH 07/14] xen: mark grant mapped pages as foreign David Vrabel
2015-01-12 16:54   ` Ian Campbell
2015-01-12 16:56     ` David Vrabel
2015-01-13 22:46   ` Boris Ostrovsky
2015-01-12 15:43 ` [PATCH 08/14] xen-netback: use foreign page information from the pages themselves David Vrabel
2015-01-12 16:56   ` Ian Campbell
2015-01-12 17:16     ` David Vrabel
2015-01-12 17:20       ` Ian Campbell
2015-01-13 14:43   ` [Xen-devel] " David Vrabel
2015-01-13 21:57     ` David Miller
2015-01-13 21:57     ` David Miller
2015-01-13 14:43   ` David Vrabel
2015-01-12 15:43 ` [PATCH 09/14] xen/grant-table: add a mechanism to safely unmap pages that are in use David Vrabel
2015-01-13 23:31   ` Boris Ostrovsky
2015-01-19 15:27     ` David Vrabel
2015-01-12 15:43 ` [PATCH 10/14] xen/gntdev: convert priv->lock to a mutex David Vrabel
2015-01-12 15:43 ` [PATCH 11/14] xen/gntdev: safely unmap grants in case they are still in use David Vrabel
2015-01-12 15:43 ` [PATCH 12/14] xen-blkback: " David Vrabel
2015-01-14 15:17   ` Boris Ostrovsky
2015-01-14 15:47   ` Boris Ostrovsky [this message]
2015-01-14 16:00     ` David Vrabel
2015-01-14 16:22       ` Boris Ostrovsky
2015-01-14 16:33         ` David Vrabel
2015-01-12 15:43 ` [PATCH 13/14] xen/gntdev: mark userspace PTEs as special on x86 PV guests David Vrabel
2015-01-12 15:43 ` [PATCH 14/14] xen/gntdev: provide find_page VMA operation David Vrabel
  -- strict thread matches above, loose matches on Subject: below --
2015-01-19 15:51 [PATCHv3 00/14] xen: fix many long-standing grant mapping bugs David Vrabel
2015-01-19 15:51 ` [PATCH 12/14] xen-blkback: safely unmap grants in case they are still in use David Vrabel
2015-01-23 12:02   ` David Vrabel
2015-01-23 14:41     ` Roger Pau Monné
2015-01-23 14:31   ` Roger Pau Monné
2015-01-23 14:54     ` David Vrabel
2015-01-23 15:47       ` Roger Pau Monné
2015-01-23 16:00         ` David Vrabel
2015-01-26 15:00           ` David Vrabel
2015-01-24  8:57         ` Roger Pau Monné
2015-01-26 15:02   ` David Vrabel
2015-01-26 17:34     ` Jens Axboe

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=54B68F8E.60805@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=jennifer.herbert@citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.