26 /*
27 * This file is intended for functions that ought to be common between user
28 * land (libzfs) and the kernel. When many common routines need to be shared
29 * then a separate file should to be created.
30 */
31
32 #if defined(_KERNEL)
33 #include <sys/systm.h>
34 #else
35 #include <string.h>
36 #endif
37
38 #include <sys/types.h>
39 #include <sys/fs/zfs.h>
40 #include <sys/int_limits.h>
41 #include <sys/nvpair.h>
42 #include "zfs_comutil.h"
43
44 /*
45 * Are there allocatable vdevs?
46 */
47 boolean_t
48 zfs_allocatable_devs(nvlist_t *nv)
49 {
50 uint64_t is_log;
51 uint_t c;
52 nvlist_t **child;
53 uint_t children;
54
55 if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
56 &child, &children) != 0) {
57 return (B_FALSE);
58 }
59 for (c = 0; c < children; c++) {
60 is_log = 0;
61 (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
62 &is_log);
63 if (!is_log)
64 return (B_TRUE);
65 }
66 return (B_FALSE);
67 }
68
69 void
70 zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
71 {
72 nvlist_t *policy;
73 nvpair_t *elem;
74 char *nm;
75
76 /* Defaults */
77 zrpp->zrp_request = ZPOOL_NO_REWIND;
78 zrpp->zrp_maxmeta = 0;
79 zrpp->zrp_maxdata = UINT64_MAX;
80 zrpp->zrp_txg = UINT64_MAX;
81
82 if (nvl == NULL)
83 return;
|
26 /*
27 * This file is intended for functions that ought to be common between user
28 * land (libzfs) and the kernel. When many common routines need to be shared
29 * then a separate file should to be created.
30 */
31
32 #if defined(_KERNEL)
33 #include <sys/systm.h>
34 #else
35 #include <string.h>
36 #endif
37
38 #include <sys/types.h>
39 #include <sys/fs/zfs.h>
40 #include <sys/int_limits.h>
41 #include <sys/nvpair.h>
42 #include "zfs_comutil.h"
43
44 /*
45 * Are there allocatable vdevs?
46 * Any pool must have at least one normal (metaslab) class vdev, which means:
47 * at least one that is simultaneously non-slog and non-special
48 */
49 boolean_t
50 zfs_allocatable_devs(nvlist_t *nv)
51 {
52 uint64_t is_log, is_special;
53 uint_t c;
54 nvlist_t **child;
55 uint_t children;
56
57 if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
58 &child, &children) != 0) {
59 return (B_FALSE);
60 }
61 for (c = 0; c < children; c++) {
62 is_log = is_special = 0;
63 (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
64 &is_log);
65 (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_SPECIAL,
66 &is_special);
67 if (!is_log && !is_special)
68 return (B_TRUE);
69 }
70 return (B_FALSE);
71 }
72
73 void
74 zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
75 {
76 nvlist_t *policy;
77 nvpair_t *elem;
78 char *nm;
79
80 /* Defaults */
81 zrpp->zrp_request = ZPOOL_NO_REWIND;
82 zrpp->zrp_maxmeta = 0;
83 zrpp->zrp_maxdata = UINT64_MAX;
84 zrpp->zrp_txg = UINT64_MAX;
85
86 if (nvl == NULL)
87 return;
|