El 26/01/15 a les 18.01, David Vrabel ha escrit: > From: Jennifer Herbert <jennifer.herb...@citrix.com> > > 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.herb...@citrix.com> > Signed-off-by: David Vrabel <david.vra...@citrix.com>
Acked-by: Roger Pau Monné <roger....@citrix.com> 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@lists.xen.org http://lists.xen.org/xen-devel