Lines Matching refs:actor
24 static void *cache_first_page(struct squashfs_page_actor *actor) in cache_first_page() argument
26 actor->next_page = 1; in cache_first_page()
27 return actor->buffer[0]; in cache_first_page()
30 static void *cache_next_page(struct squashfs_page_actor *actor) in cache_next_page() argument
32 if (actor->next_page == actor->pages) in cache_next_page()
35 return actor->buffer[actor->next_page++]; in cache_next_page()
38 static void cache_finish_page(struct squashfs_page_actor *actor) in cache_finish_page() argument
46 struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL); in squashfs_page_actor_init() local
48 if (actor == NULL) in squashfs_page_actor_init()
51 actor->length = length ? : pages * PAGE_SIZE; in squashfs_page_actor_init()
52 actor->buffer = buffer; in squashfs_page_actor_init()
53 actor->pages = pages; in squashfs_page_actor_init()
54 actor->next_page = 0; in squashfs_page_actor_init()
55 actor->tmp_buffer = NULL; in squashfs_page_actor_init()
56 actor->squashfs_first_page = cache_first_page; in squashfs_page_actor_init()
57 actor->squashfs_next_page = cache_next_page; in squashfs_page_actor_init()
58 actor->squashfs_finish_page = cache_finish_page; in squashfs_page_actor_init()
59 return actor; in squashfs_page_actor_init()
63 static loff_t page_next_index(struct squashfs_page_actor *actor) in page_next_index() argument
65 return page_folio(actor->page[actor->next_page])->index; in page_next_index()
68 static void *handle_next_page(struct squashfs_page_actor *actor) in handle_next_page() argument
70 int max_pages = (actor->length + PAGE_SIZE - 1) >> PAGE_SHIFT; in handle_next_page()
72 if (actor->returned_pages == max_pages) in handle_next_page()
75 if ((actor->next_page == actor->pages) || in handle_next_page()
76 (actor->next_index != page_next_index(actor))) { in handle_next_page()
77 actor->next_index++; in handle_next_page()
78 actor->returned_pages++; in handle_next_page()
79 actor->last_page = NULL; in handle_next_page()
80 return actor->alloc_buffer ? actor->tmp_buffer : ERR_PTR(-ENOMEM); in handle_next_page()
83 actor->next_index++; in handle_next_page()
84 actor->returned_pages++; in handle_next_page()
85 actor->last_page = actor->page[actor->next_page]; in handle_next_page()
86 return actor->pageaddr = kmap_local_page(actor->page[actor->next_page++]); in handle_next_page()
89 static void *direct_first_page(struct squashfs_page_actor *actor) in direct_first_page() argument
91 return handle_next_page(actor); in direct_first_page()
94 static void *direct_next_page(struct squashfs_page_actor *actor) in direct_next_page() argument
96 if (actor->pageaddr) { in direct_next_page()
97 kunmap_local(actor->pageaddr); in direct_next_page()
98 actor->pageaddr = NULL; in direct_next_page()
101 return handle_next_page(actor); in direct_next_page()
104 static void direct_finish_page(struct squashfs_page_actor *actor) in direct_finish_page() argument
106 if (actor->pageaddr) in direct_finish_page()
107 kunmap_local(actor->pageaddr); in direct_finish_page()
113 struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL); in squashfs_page_actor_init_special() local
115 if (actor == NULL) in squashfs_page_actor_init_special()
119 actor->tmp_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); in squashfs_page_actor_init_special()
121 if (actor->tmp_buffer == NULL) { in squashfs_page_actor_init_special()
122 kfree(actor); in squashfs_page_actor_init_special()
126 actor->tmp_buffer = NULL; in squashfs_page_actor_init_special()
128 actor->length = length ? : pages * PAGE_SIZE; in squashfs_page_actor_init_special()
129 actor->page = page; in squashfs_page_actor_init_special()
130 actor->pages = pages; in squashfs_page_actor_init_special()
131 actor->next_page = 0; in squashfs_page_actor_init_special()
132 actor->returned_pages = 0; in squashfs_page_actor_init_special()
133 actor->next_index = start_index >> PAGE_SHIFT; in squashfs_page_actor_init_special()
134 actor->pageaddr = NULL; in squashfs_page_actor_init_special()
135 actor->last_page = NULL; in squashfs_page_actor_init_special()
136 actor->alloc_buffer = msblk->decompressor->alloc_buffer; in squashfs_page_actor_init_special()
137 actor->squashfs_first_page = direct_first_page; in squashfs_page_actor_init_special()
138 actor->squashfs_next_page = direct_next_page; in squashfs_page_actor_init_special()
139 actor->squashfs_finish_page = direct_finish_page; in squashfs_page_actor_init_special()
140 return actor; in squashfs_page_actor_init_special()