Lines Matching refs:persistent_gnt

135 static inline bool persistent_gnt_timeout(struct persistent_gnt *persistent_gnt)  in persistent_gnt_timeout()  argument
137 return pgrant_timeout && (jiffies - persistent_gnt->last_used >= in persistent_gnt_timeout()
169 struct persistent_gnt *persistent_gnt) in add_persistent_gnt() argument
172 struct persistent_gnt *this; in add_persistent_gnt()
183 this = container_of(*new, struct persistent_gnt, node); in add_persistent_gnt()
186 if (persistent_gnt->gnt < this->gnt) in add_persistent_gnt()
188 else if (persistent_gnt->gnt > this->gnt) in add_persistent_gnt()
196 persistent_gnt->active = true; in add_persistent_gnt()
198 rb_link_node(&(persistent_gnt->node), parent, new); in add_persistent_gnt()
199 rb_insert_color(&(persistent_gnt->node), &ring->persistent_gnts); in add_persistent_gnt()
205 static struct persistent_gnt *get_persistent_gnt(struct xen_blkif_ring *ring, in get_persistent_gnt()
208 struct persistent_gnt *data; in get_persistent_gnt()
213 data = container_of(node, struct persistent_gnt, node); in get_persistent_gnt()
233 struct persistent_gnt *persistent_gnt) in put_persistent_gnt() argument
235 if (!persistent_gnt->active) in put_persistent_gnt()
237 persistent_gnt->last_used = jiffies; in put_persistent_gnt()
238 persistent_gnt->active = false; in put_persistent_gnt()
247 struct persistent_gnt *persistent_gnt; in free_persistent_gnts() local
259 foreach_grant_safe(persistent_gnt, n, root, node) { in free_persistent_gnts()
260 BUG_ON(persistent_gnt->handle == in free_persistent_gnts()
264 persistent_gnt->page)), in free_persistent_gnts()
266 persistent_gnt->handle); in free_persistent_gnts()
268 pages[segs_to_unmap] = persistent_gnt->page; in free_persistent_gnts()
271 !rb_next(&persistent_gnt->node)) { in free_persistent_gnts()
281 rb_erase(&persistent_gnt->node, root); in free_persistent_gnts()
282 kfree(persistent_gnt); in free_persistent_gnts()
294 struct persistent_gnt *persistent_gnt; in xen_blkbk_unmap_purged_grants() local
304 persistent_gnt = list_first_entry(&ring->persistent_purge_list, in xen_blkbk_unmap_purged_grants()
305 struct persistent_gnt, in xen_blkbk_unmap_purged_grants()
307 list_del(&persistent_gnt->remove_node); in xen_blkbk_unmap_purged_grants()
310 vaddr(persistent_gnt->page), in xen_blkbk_unmap_purged_grants()
312 persistent_gnt->handle); in xen_blkbk_unmap_purged_grants()
314 pages[segs_to_unmap] = persistent_gnt->page; in xen_blkbk_unmap_purged_grants()
323 kfree(persistent_gnt); in xen_blkbk_unmap_purged_grants()
334 struct persistent_gnt *persistent_gnt; in purge_persistent_gnt() local
371 foreach_grant_safe(persistent_gnt, n, root, node) { in purge_persistent_gnt()
372 BUG_ON(persistent_gnt->handle == in purge_persistent_gnt()
375 if (persistent_gnt->active) in purge_persistent_gnt()
377 if (!scan_used && !persistent_gnt_timeout(persistent_gnt)) in purge_persistent_gnt()
382 rb_erase(&persistent_gnt->node, root); in purge_persistent_gnt()
383 list_add(&persistent_gnt->remove_node, in purge_persistent_gnt()
655 if (pages[i]->persistent_gnt != NULL) { in xen_blkbk_unmap_prepare()
656 put_persistent_gnt(ring, pages[i]->persistent_gnt); in xen_blkbk_unmap_prepare()
762 struct persistent_gnt *persistent_gnt = NULL; in xen_blkbk_map() local
783 persistent_gnt = get_persistent_gnt( in xen_blkbk_map()
788 if (persistent_gnt) { in xen_blkbk_map()
793 pages[i]->page = persistent_gnt->page; in xen_blkbk_map()
794 pages[i]->persistent_gnt = persistent_gnt; in xen_blkbk_map()
806 pages[i]->persistent_gnt = NULL; in xen_blkbk_map()
828 if (!pages[seg_idx]->persistent_gnt) { in xen_blkbk_map()
849 persistent_gnt = kmalloc(sizeof(struct persistent_gnt), in xen_blkbk_map()
851 if (!persistent_gnt) { in xen_blkbk_map()
859 persistent_gnt->gnt = map[new_map_idx].ref; in xen_blkbk_map()
860 persistent_gnt->handle = map[new_map_idx].handle; in xen_blkbk_map()
861 persistent_gnt->page = pages[seg_idx]->page; in xen_blkbk_map()
863 persistent_gnt)) { in xen_blkbk_map()
864 kfree(persistent_gnt); in xen_blkbk_map()
865 persistent_gnt = NULL; in xen_blkbk_map()
868 pages[seg_idx]->persistent_gnt = persistent_gnt; in xen_blkbk_map()
870 persistent_gnt->gnt, ring->persistent_gnt_c, in xen_blkbk_map()
895 pages[i]->persistent_gnt = NULL; in xen_blkbk_map()