[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCHv4 12/14] xen-blkback: safely unmap grants in case they are still in use
El 26/01/15 a les 18.01, David Vrabel ha escrit: > From: Jennifer Herbert <jennifer.herbert@xxxxxxxxxx> > > Use gnttab_unmap_refs_async() to wait until the mapped pages are no > longer in use before unmapping them. > > This allows blkback to use network storage which may retain refs to > pages in queued skbs after the block I/O has completed. > > Signed-off-by: Jennifer Herbert <jennifer.herbert@xxxxxxxxxx> > Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> This looks fine, only one comment below. [...] > +/* > + * Unmap the grant references, and also remove the M2P over-rides > + * used in the 'pending_req'. > + */ > +static void xen_blkbk_unmap(struct xen_blkif *blkif, > + struct grant_page *pages[], > + int num) > +{ > + struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST]; > + struct page *unmap_pages[BLKIF_MAX_SEGMENTS_PER_REQUEST]; > + unsigned int invcount = 0; > + int ret; > + > + while (num) { > + unsigned int batch = min(num, BLKIF_MAX_SEGMENTS_PER_REQUEST); > + > + invcount = xen_blkbk_unmap_prepare(blkif, pages, batch, > + unmap, unmap_pages); > + if (invcount) { > + ret = gnttab_unmap_refs(unmap, NULL, unmap_pages, > invcount); > BUG_ON(ret); > put_free_pages(blkif, unmap_pages, invcount); > - invcount = 0; > } > - } > - if (invcount) { > - ret = gnttab_unmap_refs(unmap, NULL, unmap_pages, invcount); > - BUG_ON(ret); > - put_free_pages(blkif, unmap_pages, invcount); > + pages += batch; > + num -= batch; Could you add a comment explaining that the loop is not optimal if the pages array contains both persistent and non-persistent grants? Roger. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |