Lines Matching refs:bb
60 struct backed_block *backed_block_iter_next(struct backed_block *bb) in backed_block_iter_next() argument
62 return bb->next; in backed_block_iter_next()
65 unsigned int backed_block_len(struct backed_block *bb) in backed_block_len() argument
67 return bb->len; in backed_block_len()
70 unsigned int backed_block_block(struct backed_block *bb) in backed_block_block() argument
72 return bb->block; in backed_block_block()
75 void *backed_block_data(struct backed_block *bb) in backed_block_data() argument
77 assert(bb->type == BACKED_BLOCK_DATA); in backed_block_data()
78 return bb->data.data; in backed_block_data()
81 const char *backed_block_filename(struct backed_block *bb) in backed_block_filename() argument
83 assert(bb->type == BACKED_BLOCK_FILE); in backed_block_filename()
84 return bb->file.filename; in backed_block_filename()
87 int backed_block_fd(struct backed_block *bb) in backed_block_fd() argument
89 assert(bb->type == BACKED_BLOCK_FD); in backed_block_fd()
90 return bb->fd.fd; in backed_block_fd()
93 int64_t backed_block_file_offset(struct backed_block *bb) in backed_block_file_offset() argument
95 assert(bb->type == BACKED_BLOCK_FILE || bb->type == BACKED_BLOCK_FD); in backed_block_file_offset()
96 if (bb->type == BACKED_BLOCK_FILE) { in backed_block_file_offset()
97 return bb->file.offset; in backed_block_file_offset()
99 return bb->fd.offset; in backed_block_file_offset()
103 uint32_t backed_block_fill_val(struct backed_block *bb) in backed_block_fill_val() argument
105 assert(bb->type == BACKED_BLOCK_FILL); in backed_block_fill_val()
106 return bb->fill.val; in backed_block_fill_val()
109 enum backed_block_type backed_block_type(struct backed_block *bb) in backed_block_type() argument
111 return bb->type; in backed_block_type()
114 void backed_block_destroy(struct backed_block *bb) in backed_block_destroy() argument
116 if (bb->type == BACKED_BLOCK_FILE) { in backed_block_destroy()
117 free(bb->file.filename); in backed_block_destroy()
120 free(bb); in backed_block_destroy()
133 struct backed_block *bb = bbl->data_blocks; in backed_block_list_destroy() local
134 while (bb) { in backed_block_list_destroy()
135 struct backed_block *next = bb->next; in backed_block_list_destroy()
136 backed_block_destroy(bb); in backed_block_list_destroy()
137 bb = next; in backed_block_list_destroy()
148 struct backed_block *bb; in backed_block_list_move() local
168 for (bb = from->data_blocks; bb; bb = bb->next) { in backed_block_list_move()
169 if (bb->next == start) { in backed_block_list_move()
170 bb->next = end->next; in backed_block_list_move()
180 for (bb = to->data_blocks; bb; bb = bb->next) { in backed_block_list_move()
181 if (!bb->next || bb->next->block > start->block) { in backed_block_list_move()
182 end->next = bb->next; in backed_block_list_move()
183 bb->next = start; in backed_block_list_move()
250 struct backed_block *bb; in queue_bb() local
267 bb = bbl->last_used; in queue_bb()
269 bb = bbl->data_blocks; in queue_bb()
272 for (; bb->next && bb->next->block < new_bb->block; bb = bb->next) in queue_bb()
275 if (bb->next == NULL) { in queue_bb()
276 bb->next = new_bb; in queue_bb()
278 new_bb->next = bb->next; in queue_bb()
279 bb->next = new_bb; in queue_bb()
283 if (!merge_bb(bbl, bb, new_bb)) { in queue_bb()
285 bbl->last_used = bb; in queue_bb()
295 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_fill() local
296 if (bb == NULL) { in backed_block_add_fill()
300 bb->block = block; in backed_block_add_fill()
301 bb->len = len; in backed_block_add_fill()
302 bb->type = BACKED_BLOCK_FILL; in backed_block_add_fill()
303 bb->fill.val = fill_val; in backed_block_add_fill()
304 bb->next = NULL; in backed_block_add_fill()
306 return queue_bb(bbl, bb); in backed_block_add_fill()
313 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_data() local
314 if (bb == NULL) { in backed_block_add_data()
318 bb->block = block; in backed_block_add_data()
319 bb->len = len; in backed_block_add_data()
320 bb->type = BACKED_BLOCK_DATA; in backed_block_add_data()
321 bb->data.data = data; in backed_block_add_data()
322 bb->next = NULL; in backed_block_add_data()
324 return queue_bb(bbl, bb); in backed_block_add_data()
331 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_file() local
332 if (bb == NULL) { in backed_block_add_file()
336 bb->block = block; in backed_block_add_file()
337 bb->len = len; in backed_block_add_file()
338 bb->type = BACKED_BLOCK_FILE; in backed_block_add_file()
339 bb->file.filename = strdup(filename); in backed_block_add_file()
340 bb->file.offset = offset; in backed_block_add_file()
341 bb->next = NULL; in backed_block_add_file()
343 return queue_bb(bbl, bb); in backed_block_add_file()
350 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_fd() local
351 if (bb == NULL) { in backed_block_add_fd()
355 bb->block = block; in backed_block_add_fd()
356 bb->len = len; in backed_block_add_fd()
357 bb->type = BACKED_BLOCK_FD; in backed_block_add_fd()
358 bb->fd.fd = fd; in backed_block_add_fd()
359 bb->fd.offset = offset; in backed_block_add_fd()
360 bb->next = NULL; in backed_block_add_fd()
362 return queue_bb(bbl, bb); in backed_block_add_fd()
365 int backed_block_split(struct backed_block_list *bbl, struct backed_block *bb, in backed_block_split() argument
372 if (bb->len <= max_len) { in backed_block_split()
381 *new_bb = *bb; in backed_block_split()
383 new_bb->len = bb->len - max_len; in backed_block_split()
384 new_bb->block = bb->block + max_len / bbl->block_size; in backed_block_split()
385 new_bb->next = bb->next; in backed_block_split()
386 bb->next = new_bb; in backed_block_split()
387 bb->len = max_len; in backed_block_split()
389 switch (bb->type) { in backed_block_split()
391 new_bb->data.data = (char *)bb->data.data + max_len; in backed_block_split()