Lines Matching refs:zone
78 static bool is_zone_chapter_sparse(const struct index_zone *zone, u64 virtual_chapter) in is_zone_chapter_sparse() argument
80 return uds_is_chapter_sparse(zone->index->volume->geometry, in is_zone_chapter_sparse()
81 zone->oldest_virtual_chapter, in is_zone_chapter_sparse()
82 zone->newest_virtual_chapter, virtual_chapter); in is_zone_chapter_sparse()
85 static int launch_zone_message(struct uds_zone_message message, unsigned int zone, in launch_zone_message() argument
97 request->zone_number = zone; in launch_zone_message()
110 unsigned int zone; in enqueue_barrier_messages() local
112 for (zone = 0; zone < index->zone_count; zone++) { in enqueue_barrier_messages()
113 int result = launch_zone_message(message, zone, index); in enqueue_barrier_messages()
127 struct index_zone *zone; in triage_index_request() local
134 zone = index->zones[request->zone_number]; in triage_index_request()
135 if (!is_zone_chapter_sparse(zone, virtual_chapter)) in triage_index_request()
151 static int simulate_index_zone_barrier_message(struct index_zone *zone, in simulate_index_zone_barrier_message() argument
156 if ((zone->index->zone_count > 1) || in simulate_index_zone_barrier_message()
157 !uds_is_sparse_index_geometry(zone->index->volume->geometry)) in simulate_index_zone_barrier_message()
160 sparse_virtual_chapter = triage_index_request(zone->index, request); in simulate_index_zone_barrier_message()
164 return uds_update_sparse_cache(zone, sparse_virtual_chapter); in simulate_index_zone_barrier_message()
197 static int swap_open_chapter(struct index_zone *zone) in swap_open_chapter() argument
201 result = finish_previous_chapter(zone->index, zone->newest_virtual_chapter); in swap_open_chapter()
205 swap(zone->open_chapter, zone->writing_chapter); in swap_open_chapter()
229 static int announce_chapter_closed(struct index_zone *zone, u64 closed_chapter) in announce_chapter_closed() argument
238 for (i = 0; i < zone->index->zone_count; i++) { in announce_chapter_closed()
239 if (zone->id == i) in announce_chapter_closed()
242 result = launch_zone_message(zone_message, i, zone->index); in announce_chapter_closed()
250 static int open_next_chapter(struct index_zone *zone) in open_next_chapter() argument
259 (unsigned long long) zone->newest_virtual_chapter, zone->id, in open_next_chapter()
260 zone->open_chapter->size, in open_next_chapter()
261 zone->open_chapter->capacity - zone->open_chapter->size); in open_next_chapter()
263 result = swap_open_chapter(zone); in open_next_chapter()
267 closed_chapter = zone->newest_virtual_chapter++; in open_next_chapter()
268 uds_set_volume_index_zone_open_chapter(zone->index->volume_index, zone->id, in open_next_chapter()
269 zone->newest_virtual_chapter); in open_next_chapter()
270 uds_reset_open_chapter(zone->open_chapter); in open_next_chapter()
272 finished_zones = start_closing_chapter(zone->index, zone->id, in open_next_chapter()
273 zone->writing_chapter); in open_next_chapter()
274 if ((finished_zones == 1) && (zone->index->zone_count > 1)) { in open_next_chapter()
275 result = announce_chapter_closed(zone, closed_chapter); in open_next_chapter()
280 expiring = zone->oldest_virtual_chapter; in open_next_chapter()
281 expire_chapters = uds_chapters_to_expire(zone->index->volume->geometry, in open_next_chapter()
282 zone->newest_virtual_chapter); in open_next_chapter()
283 zone->oldest_virtual_chapter += expire_chapters; in open_next_chapter()
285 if (finished_zones < zone->index->zone_count) in open_next_chapter()
289 uds_forget_chapter(zone->index->volume, expiring++); in open_next_chapter()
294 static int handle_chapter_closed(struct index_zone *zone, u64 virtual_chapter) in handle_chapter_closed() argument
296 if (zone->newest_virtual_chapter == virtual_chapter) in handle_chapter_closed()
297 return open_next_chapter(zone); in handle_chapter_closed()
305 struct index_zone *zone = request->index->zones[request->zone_number]; in dispatch_index_zone_control_request() local
309 return uds_update_sparse_cache(zone, message->virtual_chapter); in dispatch_index_zone_control_request()
312 return handle_chapter_closed(zone, message->virtual_chapter); in dispatch_index_zone_control_request()
330 const struct index_zone *zone, u64 virtual_chapter) in set_chapter_location() argument
333 if (virtual_chapter == zone->newest_virtual_chapter) in set_chapter_location()
335 else if (is_zone_chapter_sparse(zone, virtual_chapter)) in set_chapter_location()
341 static int search_sparse_cache_in_zone(struct index_zone *zone, struct uds_request *request, in search_sparse_cache_in_zone() argument
349 result = uds_search_sparse_cache(zone, &request->record_name, &virtual_chapter, in search_sparse_cache_in_zone()
355 volume = zone->index->volume; in search_sparse_cache_in_zone()
361 static int get_record_from_zone(struct index_zone *zone, struct uds_request *request, in get_record_from_zone() argument
374 if (request->virtual_chapter == zone->newest_virtual_chapter) { in get_record_from_zone()
375 uds_search_open_chapter(zone->open_chapter, &request->record_name, in get_record_from_zone()
380 if ((zone->newest_virtual_chapter > 0) && in get_record_from_zone()
381 (request->virtual_chapter == (zone->newest_virtual_chapter - 1)) && in get_record_from_zone()
382 (zone->writing_chapter->size > 0)) { in get_record_from_zone()
383 uds_search_open_chapter(zone->writing_chapter, &request->record_name, in get_record_from_zone()
388 volume = zone->index->volume; in get_record_from_zone()
389 if (is_zone_chapter_sparse(zone, request->virtual_chapter) && in get_record_from_zone()
392 return search_sparse_cache_in_zone(zone, request, in get_record_from_zone()
398 static int put_record_in_zone(struct index_zone *zone, struct uds_request *request, in put_record_in_zone() argument
403 remaining = uds_put_open_chapter(zone->open_chapter, &request->record_name, in put_record_in_zone()
406 return open_next_chapter(zone); in put_record_in_zone()
411 static int search_index_zone(struct index_zone *zone, struct uds_request *request) in search_index_zone() argument
419 result = uds_get_volume_index_record(zone->index->volume_index, in search_index_zone()
429 result = get_record_from_zone(zone, request, &found); in search_index_zone()
435 set_chapter_location(request, zone, record.virtual_chapter); in search_index_zone()
444 chapter = zone->newest_virtual_chapter; in search_index_zone()
473 } else if (uds_is_sparse_index_geometry(zone->index->volume->geometry) && in search_index_zone()
474 !uds_is_volume_index_sample(zone->index->volume_index, in search_index_zone()
476 result = search_sparse_cache_in_zone(zone, request, NO_CHAPTER, in search_index_zone()
517 return put_record_in_zone(zone, request, metadata); in search_index_zone()
520 static int remove_from_index_zone(struct index_zone *zone, struct uds_request *request) in remove_from_index_zone() argument
525 result = uds_get_volume_index_record(zone->index->volume_index, in remove_from_index_zone()
536 set_chapter_location(request, zone, record.virtual_chapter); in remove_from_index_zone()
545 result = get_record_from_zone(zone, request, &found); in remove_from_index_zone()
555 set_chapter_location(request, zone, record.virtual_chapter); in remove_from_index_zone()
571 uds_remove_from_open_chapter(zone->open_chapter, &request->record_name); in remove_from_index_zone()
579 struct index_zone *zone = index->zones[request->zone_number]; in dispatch_index_request() local
582 result = simulate_index_zone_barrier_message(zone, request); in dispatch_index_request()
592 result = search_index_zone(zone, request); in dispatch_index_request()
596 result = remove_from_index_zone(zone, request); in dispatch_index_request()
1111 static void free_index_zone(struct index_zone *zone) in free_index_zone() argument
1113 if (zone == NULL) in free_index_zone()
1116 uds_free_open_chapter(zone->open_chapter); in free_index_zone()
1117 uds_free_open_chapter(zone->writing_chapter); in free_index_zone()
1118 vdo_free(zone); in free_index_zone()
1124 struct index_zone *zone; in make_index_zone() local
1126 result = vdo_allocate(1, struct index_zone, "index zone", &zone); in make_index_zone()
1131 &zone->open_chapter); in make_index_zone()
1133 free_index_zone(zone); in make_index_zone()
1138 &zone->writing_chapter); in make_index_zone()
1140 free_index_zone(zone); in make_index_zone()
1144 zone->index = index; in make_index_zone()
1145 zone->id = zone_number; in make_index_zone()
1146 index->zones[zone_number] = zone; in make_index_zone()
1159 struct index_zone *zone; in uds_make_index() local
1250 zone = index->zones[z]; in uds_make_index()
1251 zone->oldest_virtual_chapter = index->oldest_virtual_chapter; in uds_make_index()
1252 zone->newest_virtual_chapter = index->newest_virtual_chapter; in uds_make_index()