drivers/md/dm-vdo/logical-zone.c

Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/logical-zone.c

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-vdo/logical-zone.c
Extension
.c
Size
11386 bytes
Lines
361
Domain
Driver Families
Bucket
drivers/md
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (result != VDO_SUCCESS) {
			vdo_free_logical_zones(zones);
			return result;
		}
	}

	result = vdo_make_action_manager(zones->zone_count, get_thread_id_for_zone,
					 vdo->thread_config.admin_thread, zones, NULL,
					 vdo, &zones->manager);
	if (result != VDO_SUCCESS) {
		vdo_free_logical_zones(zones);
		return result;
	}

	*zones_ptr = zones;
	return VDO_SUCCESS;
}

/**
 * vdo_free_logical_zones() - Free a set of logical zones.
 * @zones: The set of zones to free.
 */
void vdo_free_logical_zones(struct logical_zones *zones)
{
	zone_count_t index;

	if (zones == NULL)
		return;

	vdo_free(vdo_forget(zones->manager));

	for (index = 0; index < zones->zone_count; index++)
		vdo_int_map_free(vdo_forget(zones->zones[index].lbn_operations));

	vdo_free(zones);
}

static inline void assert_on_zone_thread(struct logical_zone *zone, const char *what)
{
	VDO_ASSERT_LOG_ONLY((vdo_get_callback_thread_id() == zone->thread_id),
			    "%s() called on correct thread", what);
}

/**
 * check_for_drain_complete() - Check whether this zone has drained.
 * @zone: The zone to check.
 */
static void check_for_drain_complete(struct logical_zone *zone)
{
	if (!vdo_is_state_draining(&zone->state) || zone->notifying ||
	    !list_empty(&zone->write_vios))
		return;

	vdo_finish_draining(&zone->state);
}

/** Implements vdo_admin_initiator_fn. */
static void initiate_drain(struct admin_state *state)
{
	check_for_drain_complete(container_of(state, struct logical_zone, state));
}

/** Implements vdo_zone_action_fn. */
static void drain_logical_zone(void *context, zone_count_t zone_number,
			       struct vdo_completion *parent)
{
	struct logical_zones *zones = context;

	vdo_start_draining(&zones->zones[zone_number].state,
			   vdo_get_current_manager_operation(zones->manager), parent,
			   initiate_drain);
}

void vdo_drain_logical_zones(struct logical_zones *zones,
			     const struct admin_state_code *operation,
			     struct vdo_completion *parent)
{
	vdo_schedule_operation(zones->manager, operation, NULL, drain_logical_zone, NULL,
			       parent);
}

/** Implements vdo_zone_action_fn. */
static void resume_logical_zone(void *context, zone_count_t zone_number,
				struct vdo_completion *parent)
{
	struct logical_zone *zone = &(((struct logical_zones *) context)->zones[zone_number]);

	vdo_fail_completion(parent, vdo_resume_if_quiescent(&zone->state));
}

Annotation

Implementation Notes