コード例 #1
0
ファイル: replica.c プロジェクト: wojtuss/nvml
/*
 * check_shutdown_state -- (internal) check if replica has
 *			   healthy shutdown_state
 */
static int
check_shutdown_state(struct pool_set *set,
	struct poolset_health_status *set_hs)
{
	LOG(3, "set %p, set_hs %p", set, set_hs);
	for (unsigned r = 0; r < set->nreplicas; ++r) {\
		struct pool_replica *rep = set->replica[r];
		struct replica_health_status *rep_hs = set_hs->replica[r];
		struct pool_hdr *hdrp = HDR(rep, 0);

		if (rep->remote)
			continue;

		if (hdrp == NULL) {
			/* cannot verify shutdown state */
			rep_hs->flags |= IS_BROKEN;
			continue;
		}

		struct shutdown_state curr_sds;
		shutdown_state_init(&curr_sds, NULL);
		for (unsigned p = 0; p < rep->nparts; ++p) {
			shutdown_state_add_part(&curr_sds, PART(rep, p).path,
				NULL);
		}
		/* make a copy of sds as we shouldn't modify a pool */
		struct shutdown_state pool_sds = hdrp->sds;

		if (shutdown_state_check(&curr_sds, &pool_sds, NULL))
				rep_hs->flags |= IS_BROKEN;

	}
	return 0;
}
コード例 #2
0
ファイル: check_sds.c プロジェクト: krzycz/nvml
/*
 * sds_check_replica -- (internal) check if replica is healthy
 */
static int
sds_check_replica(location *loc)
{
	LOG(3, NULL);

	struct pool_replica *rep = REP(loc->set, loc->replica);

	if (rep->remote)
		return 0;

	/* make a copy of sds as we shouldn't modify a pool */
	struct shutdown_state old_sds = loc->hdr.sds;
	struct shutdown_state curr_sds;

	if (IGNORE_SDS(&loc->hdr))
		return util_is_zeroed(&old_sds, sizeof(old_sds)) ? 0 : -1;

	shutdown_state_init(&curr_sds, NULL);

	/* get current shutdown state */
	for (unsigned p = 0; p < rep->nparts; ++p) {
		if (shutdown_state_add_part(&curr_sds,
				PART(rep, p)->path, NULL))
			return -1;
	}

	/* compare current and old shutdown state */
	return shutdown_state_check(&curr_sds, &old_sds, NULL);
}