コード例 #1
0
ファイル: entry.c プロジェクト: cbreak-black/zfs
nvlist_t *
dm_get_stats(char *slice, int stat_type, int *errp)
{
	nvlist_t	*stats = NULL;

	/* BGH - removed everything except ability to check a slice */
  
	if (stat_type == DM_SLICE_STAT_USE) {
		/*
		 * If NOINUSE_CHECK is set, we do not perform
		 * the in use checking if the user has set stat_type
		 * DM_SLICE_STAT_USE
		 */
		if (NOINUSE_SET) {
			stats = NULL;
			return (stats);
		}
	}
	stats = slice_get_stats(slice, stat_type, errp);

	return (stats);
}
コード例 #2
0
ファイル: entry.c プロジェクト: apprisi/illumos-gate
nvlist_t *
dm_get_stats(dm_descriptor_t desc, int stat_type, int *errp)
{
	descriptor_t  *dp;
	nvlist_t	*stats = NULL;


	dp = (descriptor_t *)(uintptr_t)desc;

	cache_rlock();

	if (!cache_is_valid_desc(dp)) {
		cache_unlock();
		*errp = EBADF;
		return (NULL);
	}

	/* verify that the descriptor is still valid */
	if (dp->p.generic == NULL) {
		cache_unlock();
		*errp = ENODEV;
		return (NULL);
	}

	switch (dp->type) {
	case DM_DRIVE:
		stats = drive_get_stats(dp, stat_type, errp);
		break;
	case DM_BUS:
		stats = bus_get_stats(dp, stat_type, errp);
		break;
	case DM_CONTROLLER:
		stats = controller_get_stats(dp, stat_type, errp);
		break;
	case DM_MEDIA:
		stats = media_get_stats(dp, stat_type, errp);
		break;
	case DM_SLICE:
		if (stat_type == DM_SLICE_STAT_USE) {
			/*
			 * If NOINUSE_CHECK is set, we do not perform
			 * the in use checking if the user has set stat_type
			 * DM_SLICE_STAT_USE
			 */
			if (NOINUSE_SET) {
				stats = NULL;
				break;
			}
		}
		stats = slice_get_stats(dp, stat_type, errp);
		break;
	case DM_PARTITION:
		stats = partition_get_stats(dp, stat_type, errp);
		break;
	case DM_PATH:
		stats = path_get_stats(dp, stat_type, errp);
		break;
	case DM_ALIAS:
		stats = alias_get_stats(dp, stat_type, errp);
		break;
	default:
		*errp = EINVAL;
		break;
	}

	cache_unlock();

	return (stats);
}