Changeset View
Changeset View
Standalone View
Standalone View
sbin/geom/class/multipath/geom_multipath.c
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
static void mp_prefer(struct gctl_req *); | static void mp_prefer(struct gctl_req *); | ||||
struct g_command class_commands[] = { | struct g_command class_commands[] = { | ||||
{ | { | ||||
"create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, | "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, | ||||
{ | { | ||||
{ 'A', "active_active", NULL, G_TYPE_BOOL }, | { 'A', "active_active", NULL, G_TYPE_BOOL }, | ||||
{ 'R', "active_read", NULL, G_TYPE_BOOL }, | { 'R', "active_read", NULL, G_TYPE_BOOL }, | ||||
{ 'L', "logicalblock", 0, G_TYPE_NUMBER }, | |||||
G_OPT_SENTINEL | G_OPT_SENTINEL | ||||
}, | }, | ||||
"[-vAR] name prov ..." | "[-vAR] [-L logicalblock] name prov ..." | ||||
}, | }, | ||||
{ | { | ||||
"label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, | "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, | ||||
{ | { | ||||
{ 'A', "active_active", NULL, G_TYPE_BOOL }, | { 'A', "active_active", NULL, G_TYPE_BOOL }, | ||||
{ 'R', "active_read", NULL, G_TYPE_BOOL }, | { 'R', "active_read", NULL, G_TYPE_BOOL }, | ||||
{ 'L', "logicalblock", 0, G_TYPE_NUMBER }, | |||||
G_OPT_SENTINEL | G_OPT_SENTINEL | ||||
}, | }, | ||||
"[-vAR] name prov ..." | "[-vAR] [-L logicalblock] name prov ..." | ||||
}, | }, | ||||
{ "configure", G_FLAG_VERBOSE, NULL, | |||||
{ | { | ||||
"configure", G_FLAG_VERBOSE, NULL, | |||||
{ | |||||
{ 'A', "active_active", NULL, G_TYPE_BOOL }, | { 'A', "active_active", NULL, G_TYPE_BOOL }, | ||||
{ 'P', "active_passive", NULL, G_TYPE_BOOL }, | { 'P', "active_passive", NULL, G_TYPE_BOOL }, | ||||
{ 'R', "active_read", NULL, G_TYPE_BOOL }, | { 'R', "active_read", NULL, G_TYPE_BOOL }, | ||||
{ 'L', "logicalblock", 0, G_TYPE_NUMBER }, | |||||
G_OPT_SENTINEL | G_OPT_SENTINEL | ||||
}, | }, | ||||
"[-vAPR] name" | "[-vAPR] [-L logicalblock] name" | ||||
}, | }, | ||||
{ | { | ||||
"add", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, | "add", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, | ||||
"[-v] name prov" | "[-v] name prov" | ||||
}, | }, | ||||
{ | { | ||||
"remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, | "remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, | ||||
"[-v] name prov" | "[-v] name prov" | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | mp_main(struct gctl_req *req, unsigned int flags __unused) | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
mp_label(struct gctl_req *req) | mp_label(struct gctl_req *req) | ||||
{ | { | ||||
struct g_multipath_metadata md; | struct g_multipath_metadata md; | ||||
off_t disksize = 0, msize; | off_t disksize = 0, msize; | ||||
uint8_t *sector, *rsector; | uint8_t *sector, *rsector, val; | ||||
char *ptr; | char *ptr; | ||||
uuid_t uuid; | uuid_t uuid; | ||||
ssize_t secsize = 0, ssize; | ssize_t secsize = 0, ssize; | ||||
uint32_t status; | uint32_t status; | ||||
const char *name, *name2, *mpname; | const char *name, *name2, *mpname; | ||||
int error, i, nargs, fd; | int error, i, nargs, fd; | ||||
nargs = gctl_get_int(req, "nargs"); | nargs = gctl_get_int(req, "nargs"); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (status != uuid_s_ok) { | ||||
return; | return; | ||||
} | } | ||||
uuid_to_string(&uuid, &ptr, &status); | uuid_to_string(&uuid, &ptr, &status); | ||||
if (status != uuid_s_ok) { | if (status != uuid_s_ok) { | ||||
gctl_error(req, "cannot stringify a UUID."); | gctl_error(req, "cannot stringify a UUID."); | ||||
return; | return; | ||||
} | } | ||||
strlcpy(md.md_uuid, ptr, sizeof (md.md_uuid)); | strlcpy(md.md_uuid, ptr, sizeof (md.md_uuid)); | ||||
free(ptr); | |||||
md.md_active_active = gctl_get_int(req, "active_active"); | md.md_active_active = gctl_get_int(req, "active_active"); | ||||
if (gctl_get_int(req, "active_read")) | if (gctl_get_int(req, "active_read")) | ||||
md.md_active_active = 2; | md.md_active_active = 2; | ||||
free(ptr); | val = gctl_get_int(req, "logicalblock"); | ||||
if (val == 0 || (val > 8 && val < 32)) | |||||
md.md_logicalblock = val; | |||||
else { | |||||
gctl_error(req, "Invalid logicalblock bitshift value: %u. " | |||||
"Must be a value between 9 and 31, or 0 to disable.", | |||||
val); | |||||
return; | |||||
} | |||||
/* | /* | ||||
* Allocate a sector to write as metadata. | * Allocate a sector to write as metadata. | ||||
*/ | */ | ||||
sector = calloc(1, secsize); | sector = calloc(1, secsize); | ||||
if (sector == NULL) { | if (sector == NULL) { | ||||
gctl_error(req, "unable to allocate metadata buffer"); | gctl_error(req, "unable to allocate metadata buffer"); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |