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()
249 struct backed_block *bb; in queue_bb() local
266 bb = bbl->last_used; in queue_bb()
268 bb = bbl->data_blocks; in queue_bb()
271 for (; bb->next && bb->next->block < new_bb->block; bb = bb->next) in queue_bb()
274 if (bb->next == NULL) { in queue_bb()
275 bb->next = new_bb; in queue_bb()
277 new_bb->next = bb->next; in queue_bb()
278 bb->next = new_bb; in queue_bb()
282 merge_bb(bbl, bb, new_bb); in queue_bb()
291 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_fill() local
292 if (bb == NULL) { in backed_block_add_fill()
296 bb->block = block; in backed_block_add_fill()
297 bb->len = len; in backed_block_add_fill()
298 bb->type = BACKED_BLOCK_FILL; in backed_block_add_fill()
299 bb->fill.val = fill_val; in backed_block_add_fill()
300 bb->next = NULL; in backed_block_add_fill()
302 return queue_bb(bbl, bb); in backed_block_add_fill()
309 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_data() local
310 if (bb == NULL) { in backed_block_add_data()
314 bb->block = block; in backed_block_add_data()
315 bb->len = len; in backed_block_add_data()
316 bb->type = BACKED_BLOCK_DATA; in backed_block_add_data()
317 bb->data.data = data; in backed_block_add_data()
318 bb->next = NULL; in backed_block_add_data()
320 return queue_bb(bbl, bb); in backed_block_add_data()
327 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_file() local
328 if (bb == NULL) { in backed_block_add_file()
332 bb->block = block; in backed_block_add_file()
333 bb->len = len; in backed_block_add_file()
334 bb->type = BACKED_BLOCK_FILE; in backed_block_add_file()
335 bb->file.filename = strdup(filename); in backed_block_add_file()
336 bb->file.offset = offset; in backed_block_add_file()
337 bb->next = NULL; in backed_block_add_file()
339 return queue_bb(bbl, bb); in backed_block_add_file()
346 struct backed_block *bb = calloc(1, sizeof(struct backed_block)); in backed_block_add_fd() local
347 if (bb == NULL) { in backed_block_add_fd()
351 bb->block = block; in backed_block_add_fd()
352 bb->len = len; in backed_block_add_fd()
353 bb->type = BACKED_BLOCK_FD; in backed_block_add_fd()
354 bb->fd.fd = fd; in backed_block_add_fd()
355 bb->fd.offset = offset; in backed_block_add_fd()
356 bb->next = NULL; in backed_block_add_fd()
358 return queue_bb(bbl, bb); in backed_block_add_fd()
361 int backed_block_split(struct backed_block_list *bbl, struct backed_block *bb, in backed_block_split() argument
368 if (bb->len <= max_len) { in backed_block_split()
377 *new_bb = *bb; in backed_block_split()
379 new_bb->len = bb->len - max_len; in backed_block_split()
380 new_bb->block = bb->block + max_len / bbl->block_size; in backed_block_split()
381 new_bb->next = bb->next; in backed_block_split()
382 bb->next = new_bb; in backed_block_split()
383 bb->len = max_len; in backed_block_split()
385 switch (bb->type) { in backed_block_split()
387 new_bb->data.data = (char *)bb->data.data + max_len; in backed_block_split()