274 /*
275 * The following correspond to faults as defined in the (fault.fs.zfs.*)
276 * event namespace. Each is associated with a corresponding message ID.
277 */
278 ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */
279 ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */
280 ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */
281 ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */
282 ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */
283 ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */
284 ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */
285 ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */
286 ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */
287 ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */
288 ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */
289 ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */
290 ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
291 ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */
292
293 /*
294 * These faults have no corresponding message ID. At the time we are
295 * checking the status, the original reason for the FMA fault (I/O or
296 * checksum errors) has been lost.
297 */
298 ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */
299 ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */
300
301 /*
302 * The following are not faults per se, but still an error possibly
303 * requiring administrative attention. There is no corresponding
304 * message ID.
305 */
306 ZPOOL_STATUS_VERSION_OLDER, /* older on-disk version */
307 ZPOOL_STATUS_RESILVERING, /* device being resilvered */
308 ZPOOL_STATUS_OFFLINE_DEV, /* device online */
309 ZPOOL_STATUS_REMOVED_DEV, /* removed device */
310
311 /*
312 * Finally, the following indicates a healthy pool.
313 */
314 ZPOOL_STATUS_OK
315 } zpool_status_t;
316
317 extern zpool_status_t zpool_get_status(zpool_handle_t *, char **);
318 extern zpool_status_t zpool_import_status(nvlist_t *, char **);
319 extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh);
320
321 /*
322 * Statistics and configuration functions.
323 */
324 extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
325 extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
326 extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
327
328 /*
329 * Import and export functions
330 */
331 extern int zpool_export(zpool_handle_t *, boolean_t);
332 extern int zpool_export_force(zpool_handle_t *);
333 extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
334 char *altroot);
335 extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
336 nvlist_t *, int);
337
338 /*
339 * Search for pools to import
340 */
341
342 typedef struct importargs {
343 char **path; /* a list of paths to search */
344 int paths; /* number of paths to search */
345 char *poolname; /* name of a pool to find */
346 uint64_t guid; /* guid of a pool to find */
347 char *cachefile; /* cachefile to use for import */
348 int can_be_active : 1; /* can the pool be active? */
349 int unique : 1; /* does 'poolname' already exist? */
350 int exists : 1; /* set on return if pool already exists */
351 } importargs_t;
352
353 extern nvlist_t *zpool_search_import(libzfs_handle_t *, importargs_t *);
354
355 /* legacy pool search routines */
356 extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **);
406
407 extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t,
408 nvlist_t *, uint64_t, zfs_handle_t *, const char *);
409
410 extern const char *zfs_prop_to_name(zfs_prop_t);
411 extern int zfs_prop_set(zfs_handle_t *, const char *, const char *);
412 extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t,
413 zprop_source_t *, char *, size_t, boolean_t);
414 extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t,
415 boolean_t);
416 extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *,
417 zprop_source_t *, char *, size_t);
418 extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname,
419 uint64_t *propvalue);
420 extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
421 char *propbuf, int proplen, boolean_t literal);
422 extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
423 uint64_t *propvalue);
424 extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
425 char *propbuf, int proplen, boolean_t literal);
426 extern int zfs_get_snapused_int(zfs_handle_t *firstsnap, zfs_handle_t *lastsnap,
427 uint64_t *usedp);
428 extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
429 extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
430 extern const char *zfs_prop_values(zfs_prop_t);
431 extern int zfs_prop_is_string(zfs_prop_t prop);
432 extern nvlist_t *zfs_get_user_props(zfs_handle_t *);
433 extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *);
434 extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *);
435
436
437 typedef struct zprop_list {
438 int pl_prop;
439 char *pl_user_prop;
440 struct zprop_list *pl_next;
441 boolean_t pl_all;
442 size_t pl_width;
443 size_t pl_recvd_width;
444 boolean_t pl_fixed;
445 } zprop_list_t;
446
447 extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t);
448 extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
449
450 #define ZFS_MOUNTPOINT_NONE "none"
451 #define ZFS_MOUNTPOINT_LEGACY "legacy"
452
453 /*
454 * zpool property management
455 */
456 extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
457 extern const char *zpool_prop_default_string(zpool_prop_t);
458 extern uint64_t zpool_prop_default_numeric(zpool_prop_t);
459 extern const char *zpool_prop_column_name(zpool_prop_t);
460 extern boolean_t zpool_prop_align_right(zpool_prop_t);
461
462 /*
463 * Functions shared by zfs and zpool property management.
464 */
465 extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all,
466 boolean_t ordered, zfs_type_t type);
467 extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **,
468 zfs_type_t);
469 extern void zprop_free_list(zprop_list_t *);
470
471 #define ZFS_GET_NCOLS 5
472
473 typedef enum {
474 GET_COL_NONE,
475 GET_COL_NAME,
476 GET_COL_PROPERTY,
|
274 /*
275 * The following correspond to faults as defined in the (fault.fs.zfs.*)
276 * event namespace. Each is associated with a corresponding message ID.
277 */
278 ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */
279 ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */
280 ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */
281 ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */
282 ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */
283 ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */
284 ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */
285 ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */
286 ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */
287 ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */
288 ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */
289 ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */
290 ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
291 ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */
292
293 /*
294 * If the pool has unsupported features but can still be opened in
295 * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
296 * pool has unsupported features but cannot be opened at all, its
297 * status is ZPOOL_STATUS_UNSUP_FEAT_READ.
298 */
299 ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */
300 ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */
301
302 /*
303 * These faults have no corresponding message ID. At the time we are
304 * checking the status, the original reason for the FMA fault (I/O or
305 * checksum errors) has been lost.
306 */
307 ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */
308 ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */
309
310 /*
311 * The following are not faults per se, but still an error possibly
312 * requiring administrative attention. There is no corresponding
313 * message ID.
314 */
315 ZPOOL_STATUS_VERSION_OLDER, /* older on-disk version */
316 ZPOOL_STATUS_RESILVERING, /* device being resilvered */
317 ZPOOL_STATUS_OFFLINE_DEV, /* device online */
318 ZPOOL_STATUS_REMOVED_DEV, /* removed device */
319
320 /*
321 * Finally, the following indicates a healthy pool.
322 */
323 ZPOOL_STATUS_OK
324 } zpool_status_t;
325
326 extern zpool_status_t zpool_get_status(zpool_handle_t *, char **);
327 extern zpool_status_t zpool_import_status(nvlist_t *, char **);
328 extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh);
329
330 /*
331 * Statistics and configuration functions.
332 */
333 extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
334 extern nvlist_t *zpool_get_features(zpool_handle_t *);
335 extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
336 extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
337
338 /*
339 * Import and export functions
340 */
341 extern int zpool_export(zpool_handle_t *, boolean_t);
342 extern int zpool_export_force(zpool_handle_t *);
343 extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
344 char *altroot);
345 extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
346 nvlist_t *, int);
347 extern void zpool_print_unsup_feat(nvlist_t *config);
348
349 /*
350 * Search for pools to import
351 */
352
353 typedef struct importargs {
354 char **path; /* a list of paths to search */
355 int paths; /* number of paths to search */
356 char *poolname; /* name of a pool to find */
357 uint64_t guid; /* guid of a pool to find */
358 char *cachefile; /* cachefile to use for import */
359 int can_be_active : 1; /* can the pool be active? */
360 int unique : 1; /* does 'poolname' already exist? */
361 int exists : 1; /* set on return if pool already exists */
362 } importargs_t;
363
364 extern nvlist_t *zpool_search_import(libzfs_handle_t *, importargs_t *);
365
366 /* legacy pool search routines */
367 extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **);
417
418 extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t,
419 nvlist_t *, uint64_t, zfs_handle_t *, const char *);
420
421 extern const char *zfs_prop_to_name(zfs_prop_t);
422 extern int zfs_prop_set(zfs_handle_t *, const char *, const char *);
423 extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t,
424 zprop_source_t *, char *, size_t, boolean_t);
425 extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t,
426 boolean_t);
427 extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *,
428 zprop_source_t *, char *, size_t);
429 extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname,
430 uint64_t *propvalue);
431 extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
432 char *propbuf, int proplen, boolean_t literal);
433 extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
434 uint64_t *propvalue);
435 extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
436 char *propbuf, int proplen, boolean_t literal);
437 extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname,
438 char *buf, size_t len);
439 extern int zfs_get_snapused_int(zfs_handle_t *firstsnap, zfs_handle_t *lastsnap,
440 uint64_t *usedp);
441 extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
442 extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
443 extern const char *zfs_prop_values(zfs_prop_t);
444 extern int zfs_prop_is_string(zfs_prop_t prop);
445 extern nvlist_t *zfs_get_user_props(zfs_handle_t *);
446 extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *);
447 extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *);
448
449
450 typedef struct zprop_list {
451 int pl_prop;
452 char *pl_user_prop;
453 struct zprop_list *pl_next;
454 boolean_t pl_all;
455 size_t pl_width;
456 size_t pl_recvd_width;
457 boolean_t pl_fixed;
458 } zprop_list_t;
459
460 extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t);
461 extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
462
463 #define ZFS_MOUNTPOINT_NONE "none"
464 #define ZFS_MOUNTPOINT_LEGACY "legacy"
465
466 #define ZFS_FEATURE_DISABLED "disabled"
467 #define ZFS_FEATURE_ENABLED "enabled"
468 #define ZFS_FEATURE_ACTIVE "active"
469
470 #define ZFS_UNSUPPORTED_INACTIVE "inactive"
471 #define ZFS_UNSUPPORTED_READONLY "readonly"
472
473 /*
474 * zpool property management
475 */
476 extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
477 extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
478 size_t);
479 extern const char *zpool_prop_default_string(zpool_prop_t);
480 extern uint64_t zpool_prop_default_numeric(zpool_prop_t);
481 extern const char *zpool_prop_column_name(zpool_prop_t);
482 extern boolean_t zpool_prop_align_right(zpool_prop_t);
483
484 /*
485 * Functions shared by zfs and zpool property management.
486 */
487 extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all,
488 boolean_t ordered, zfs_type_t type);
489 extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **,
490 zfs_type_t);
491 extern void zprop_free_list(zprop_list_t *);
492
493 #define ZFS_GET_NCOLS 5
494
495 typedef enum {
496 GET_COL_NONE,
497 GET_COL_NAME,
498 GET_COL_PROPERTY,
|