MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zfs_ioc_pool_initialize

Function zfs_ioc_pool_initialize

freebsd/contrib/openzfs/module/zfs/zfs_ioctl.c:3946–3992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3944};
3945
3946static int
3947zfs_ioc_pool_initialize(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
3948{
3949 uint64_t cmd_type;
3950 if (nvlist_lookup_uint64(innvl, ZPOOL_INITIALIZE_COMMAND,
3951 &cmd_type) != 0) {
3952 return (SET_ERROR(EINVAL));
3953 }
3954
3955 if (!(cmd_type == POOL_INITIALIZE_CANCEL ||
3956 cmd_type == POOL_INITIALIZE_START ||
3957 cmd_type == POOL_INITIALIZE_SUSPEND)) {
3958 return (SET_ERROR(EINVAL));
3959 }
3960
3961 nvlist_t *vdev_guids;
3962 if (nvlist_lookup_nvlist(innvl, ZPOOL_INITIALIZE_VDEVS,
3963 &vdev_guids) != 0) {
3964 return (SET_ERROR(EINVAL));
3965 }
3966
3967 for (nvpair_t *pair = nvlist_next_nvpair(vdev_guids, NULL);
3968 pair != NULL; pair = nvlist_next_nvpair(vdev_guids, pair)) {
3969 uint64_t vdev_guid;
3970 if (nvpair_value_uint64(pair, &vdev_guid) != 0) {
3971 return (SET_ERROR(EINVAL));
3972 }
3973 }
3974
3975 spa_t *spa;
3976 int error = spa_open(poolname, &spa, FTAG);
3977 if (error != 0)
3978 return (error);
3979
3980 nvlist_t *vdev_errlist = fnvlist_alloc();
3981 int total_errors = spa_vdev_initialize(spa, vdev_guids, cmd_type,
3982 vdev_errlist);
3983
3984 if (fnvlist_size(vdev_errlist) > 0) {
3985 fnvlist_add_nvlist(outnvl, ZPOOL_INITIALIZE_VDEVS,
3986 vdev_errlist);
3987 }
3988 fnvlist_free(vdev_errlist);
3989
3990 spa_close(spa, FTAG);
3991 return (total_errors > 0 ? EINVAL : 0);
3992}
3993
3994/*
3995 * innvl: {

Callers

nothing calls this directly

Calls 11

nvlist_lookup_uint64Function · 0.85
nvlist_lookup_nvlistFunction · 0.85
nvpair_value_uint64Function · 0.85
spa_openFunction · 0.85
fnvlist_allocFunction · 0.85
spa_vdev_initializeFunction · 0.85
fnvlist_sizeFunction · 0.85
fnvlist_add_nvlistFunction · 0.85
fnvlist_freeFunction · 0.85
spa_closeFunction · 0.85
nvlist_next_nvpairFunction · 0.50

Tested by

no test coverage detected