2 * Copyright (c) 2020 iXsystems, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/systm.h>
32 #include <sys/kernel.h>
34 #include <sys/malloc.h>
35 #include <sys/mutex.h>
37 #include <sys/errno.h>
43 #include <sys/cmn_err.h>
45 #include <sys/zfs_ioctl.h>
46 #include <sys/zfs_vfsops.h>
47 #include <sys/zfs_znode.h>
50 #include <sys/spa_impl.h>
52 #include <sys/vdev_impl.h>
53 #include <sys/arc_os.h>
55 #include <sys/dsl_dir.h>
56 #include <sys/dsl_dataset.h>
57 #include <sys/dsl_prop.h>
58 #include <sys/dsl_deleg.h>
59 #include <sys/dmu_objset.h>
60 #include <sys/dmu_impl.h>
61 #include <sys/dmu_tx.h>
62 #include <sys/sunddi.h>
63 #include <sys/policy.h>
65 #include <sys/nvpair.h>
66 #include <sys/mount.h>
67 #include <sys/taskqueue.h>
69 #include <sys/fs/zfs.h>
70 #include <sys/zfs_ctldir.h>
71 #include <sys/zfs_dir.h>
72 #include <sys/zfs_onexit.h>
74 #include <sys/dsl_scan.h>
75 #include <sys/dmu_objset.h>
76 #include <sys/dmu_send.h>
77 #include <sys/dsl_destroy.h>
78 #include <sys/dsl_bookmark.h>
79 #include <sys/dsl_userhold.h>
80 #include <sys/zfeature.h>
82 #include <sys/zio_checksum.h>
83 #include <sys/vdev_removal.h>
84 #include <sys/dsl_crypt.h>
86 #include <sys/zfs_ioctl_compat.h>
87 #include <sys/zfs_context.h>
89 #include <sys/arc_impl.h>
90 #include <sys/dsl_pool.h>
92 #include <sys/vmmeter.h>
94 SYSCTL_DECL(_vfs_zfs
);
95 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, arc
, CTLFLAG_RW
, 0,
96 "ZFS adaptive replacement cache");
97 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, brt
, CTLFLAG_RW
, 0,
98 "ZFS Block Reference Table");
99 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, condense
, CTLFLAG_RW
, 0, "ZFS condense");
100 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, dbuf
, CTLFLAG_RW
, 0, "ZFS disk buf cache");
101 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, dbuf_cache
, CTLFLAG_RW
, 0,
102 "ZFS disk buf cache");
103 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, deadman
, CTLFLAG_RW
, 0, "ZFS deadman");
104 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, dedup
, CTLFLAG_RW
, 0, "ZFS dedup");
105 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, l2arc
, CTLFLAG_RW
, 0, "ZFS l2arc");
106 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, livelist
, CTLFLAG_RW
, 0, "ZFS livelist");
107 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, lua
, CTLFLAG_RW
, 0, "ZFS lua");
108 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, metaslab
, CTLFLAG_RW
, 0, "ZFS metaslab");
109 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, mg
, CTLFLAG_RW
, 0, "ZFS metaslab group");
110 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, multihost
, CTLFLAG_RW
, 0,
111 "ZFS multihost protection");
112 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, prefetch
, CTLFLAG_RW
, 0, "ZFS prefetch");
113 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, reconstruct
, CTLFLAG_RW
, 0, "ZFS reconstruct");
114 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, recv
, CTLFLAG_RW
, 0, "ZFS receive");
115 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, send
, CTLFLAG_RW
, 0, "ZFS send");
116 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, spa
, CTLFLAG_RW
, 0, "ZFS space allocation");
117 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, trim
, CTLFLAG_RW
, 0, "ZFS TRIM");
118 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, txg
, CTLFLAG_RW
, 0, "ZFS transaction group");
119 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, vdev
, CTLFLAG_RW
, 0, "ZFS VDEV");
120 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, vnops
, CTLFLAG_RW
, 0, "ZFS VNOPS");
121 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, zevent
, CTLFLAG_RW
, 0, "ZFS event");
122 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, zil
, CTLFLAG_RW
, 0, "ZFS ZIL");
123 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, zio
, CTLFLAG_RW
, 0, "ZFS ZIO");
125 SYSCTL_NODE(_vfs_zfs_livelist
, OID_AUTO
, condense
, CTLFLAG_RW
, 0,
126 "ZFS livelist condense");
127 SYSCTL_NODE(_vfs_zfs_vdev
, OID_AUTO
, file
, CTLFLAG_RW
, 0, "ZFS VDEV file");
128 SYSCTL_NODE(_vfs_zfs_vdev
, OID_AUTO
, mirror
, CTLFLAG_RD
, 0,
131 SYSCTL_DECL(_vfs_zfs_version
);
132 SYSCTL_CONST_STRING(_vfs_zfs_version
, OID_AUTO
, module
, CTLFLAG_RD
,
133 (ZFS_META_VERSION
"-" ZFS_META_RELEASE
), "OpenZFS module version");
138 param_set_arc_u64(SYSCTL_HANDLER_ARGS
)
142 err
= sysctl_handle_64(oidp
, arg1
, 0, req
);
143 if (err
!= 0 || req
->newptr
== NULL
)
146 arc_tuning_update(B_TRUE
);
152 param_set_arc_int(SYSCTL_HANDLER_ARGS
)
156 err
= sysctl_handle_int(oidp
, arg1
, 0, req
);
157 if (err
!= 0 || req
->newptr
== NULL
)
160 arc_tuning_update(B_TRUE
);
166 param_set_arc_max(SYSCTL_HANDLER_ARGS
)
172 err
= sysctl_handle_64(oidp
, &val
, 0, req
);
173 if (err
!= 0 || req
->newptr
== NULL
)
174 return (SET_ERROR(err
));
176 if (val
!= 0 && (val
< MIN_ARC_MAX
|| val
<= arc_c_min
||
177 val
>= arc_all_memory()))
178 return (SET_ERROR(EINVAL
));
181 arc_tuning_update(B_TRUE
);
183 /* Update the sysctl to the tuned value */
185 zfs_arc_max
= arc_c_max
;
191 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, arc_max
,
192 CTLTYPE_ULONG
| CTLFLAG_RWTUN
| CTLFLAG_MPSAFE
,
193 NULL
, 0, param_set_arc_max
, "LU",
194 "Maximum ARC size in bytes (LEGACY)");
198 param_set_arc_min(SYSCTL_HANDLER_ARGS
)
204 err
= sysctl_handle_64(oidp
, &val
, 0, req
);
205 if (err
!= 0 || req
->newptr
== NULL
)
206 return (SET_ERROR(err
));
208 if (val
!= 0 && (val
< 2ULL << SPA_MAXBLOCKSHIFT
|| val
> arc_c_max
))
209 return (SET_ERROR(EINVAL
));
212 arc_tuning_update(B_TRUE
);
214 /* Update the sysctl to the tuned value */
216 zfs_arc_min
= arc_c_min
;
222 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, arc_min
,
223 CTLTYPE_ULONG
| CTLFLAG_RWTUN
| CTLFLAG_MPSAFE
,
224 NULL
, 0, param_set_arc_min
, "LU",
225 "Minimum ARC size in bytes (LEGACY)");
228 extern uint_t zfs_arc_free_target
;
231 param_set_arc_free_target(SYSCTL_HANDLER_ARGS
)
236 val
= zfs_arc_free_target
;
237 err
= sysctl_handle_int(oidp
, &val
, 0, req
);
238 if (err
!= 0 || req
->newptr
== NULL
)
243 if (val
> vm_cnt
.v_page_count
)
246 zfs_arc_free_target
= val
;
252 * NOTE: This sysctl is CTLFLAG_RW not CTLFLAG_RWTUN due to its dependency on
253 * pagedaemon initialization.
256 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, arc_free_target
,
257 CTLTYPE_UINT
| CTLFLAG_RW
| CTLFLAG_MPSAFE
,
258 NULL
, 0, param_set_arc_free_target
, "IU",
259 "Desired number of free pages below which ARC triggers reclaim"
264 param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS
)
268 val
= arc_no_grow_shift
;
269 err
= sysctl_handle_int(oidp
, &val
, 0, req
);
270 if (err
!= 0 || req
->newptr
== NULL
)
273 if (val
< 0 || val
>= arc_shrink_shift
)
276 arc_no_grow_shift
= val
;
282 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, arc_no_grow_shift
,
283 CTLTYPE_INT
| CTLFLAG_RWTUN
| CTLFLAG_MPSAFE
,
284 NULL
, 0, param_set_arc_no_grow_shift
, "I",
285 "log2(fraction of ARC which must be free to allow growing) (LEGACY)");
288 extern uint64_t l2arc_write_max
;
291 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, l2arc_write_max
,
292 CTLFLAG_RWTUN
, &l2arc_write_max
, 0,
293 "Max write bytes per interval (LEGACY)");
296 extern uint64_t l2arc_write_boost
;
299 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, l2arc_write_boost
,
300 CTLFLAG_RWTUN
, &l2arc_write_boost
, 0,
301 "Extra write bytes during device warmup (LEGACY)");
304 extern uint64_t l2arc_headroom
;
307 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, l2arc_headroom
,
308 CTLFLAG_RWTUN
, &l2arc_headroom
, 0,
309 "Number of max device writes to precache (LEGACY)");
312 extern uint64_t l2arc_headroom_boost
;
315 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, l2arc_headroom_boost
,
316 CTLFLAG_RWTUN
, &l2arc_headroom_boost
, 0,
317 "Compressed l2arc_headroom multiplier (LEGACY)");
320 extern uint64_t l2arc_feed_secs
;
323 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, l2arc_feed_secs
,
324 CTLFLAG_RWTUN
, &l2arc_feed_secs
, 0,
325 "Seconds between L2ARC writing (LEGACY)");
328 extern uint64_t l2arc_feed_min_ms
;
331 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, l2arc_feed_min_ms
,
332 CTLFLAG_RWTUN
, &l2arc_feed_min_ms
, 0,
333 "Min feed interval in milliseconds (LEGACY)");
336 extern int l2arc_noprefetch
;
339 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, l2arc_noprefetch
,
340 CTLFLAG_RWTUN
, &l2arc_noprefetch
, 0,
341 "Skip caching prefetched buffers (LEGACY)");
344 extern int l2arc_feed_again
;
347 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, l2arc_feed_again
,
348 CTLFLAG_RWTUN
, &l2arc_feed_again
, 0,
349 "Turbo L2ARC warmup (LEGACY)");
352 extern int l2arc_norw
;
355 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, l2arc_norw
,
356 CTLFLAG_RWTUN
, &l2arc_norw
, 0,
357 "No reads during writes (LEGACY)");
361 param_get_arc_state_size(SYSCTL_HANDLER_ARGS
)
363 arc_state_t
*state
= (arc_state_t
*)arg1
;
366 val
= zfs_refcount_count(&state
->arcs_size
[ARC_BUFC_DATA
]) +
367 zfs_refcount_count(&state
->arcs_size
[ARC_BUFC_METADATA
]);
368 return (sysctl_handle_64(oidp
, &val
, 0, req
));
371 extern arc_state_t ARC_anon
;
374 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, anon_size
,
375 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
376 &ARC_anon
, 0, param_get_arc_state_size
, "Q",
377 "size of anonymous state");
378 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, anon_metadata_esize
, CTLFLAG_RD
,
379 &ARC_anon
.arcs_esize
[ARC_BUFC_METADATA
].rc_count
, 0,
380 "size of evictable metadata in anonymous state");
381 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, anon_data_esize
, CTLFLAG_RD
,
382 &ARC_anon
.arcs_esize
[ARC_BUFC_DATA
].rc_count
, 0,
383 "size of evictable data in anonymous state");
386 extern arc_state_t ARC_mru
;
389 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, mru_size
,
390 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
391 &ARC_mru
, 0, param_get_arc_state_size
, "Q",
392 "size of mru state");
393 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mru_metadata_esize
, CTLFLAG_RD
,
394 &ARC_mru
.arcs_esize
[ARC_BUFC_METADATA
].rc_count
, 0,
395 "size of evictable metadata in mru state");
396 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mru_data_esize
, CTLFLAG_RD
,
397 &ARC_mru
.arcs_esize
[ARC_BUFC_DATA
].rc_count
, 0,
398 "size of evictable data in mru state");
401 extern arc_state_t ARC_mru_ghost
;
404 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, mru_ghost_size
,
405 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
406 &ARC_mru_ghost
, 0, param_get_arc_state_size
, "Q",
407 "size of mru ghost state");
408 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mru_ghost_metadata_esize
, CTLFLAG_RD
,
409 &ARC_mru_ghost
.arcs_esize
[ARC_BUFC_METADATA
].rc_count
, 0,
410 "size of evictable metadata in mru ghost state");
411 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mru_ghost_data_esize
, CTLFLAG_RD
,
412 &ARC_mru_ghost
.arcs_esize
[ARC_BUFC_DATA
].rc_count
, 0,
413 "size of evictable data in mru ghost state");
416 extern arc_state_t ARC_mfu
;
419 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, mfu_size
,
420 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
421 &ARC_mfu
, 0, param_get_arc_state_size
, "Q",
422 "size of mfu state");
423 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mfu_metadata_esize
, CTLFLAG_RD
,
424 &ARC_mfu
.arcs_esize
[ARC_BUFC_METADATA
].rc_count
, 0,
425 "size of evictable metadata in mfu state");
426 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mfu_data_esize
, CTLFLAG_RD
,
427 &ARC_mfu
.arcs_esize
[ARC_BUFC_DATA
].rc_count
, 0,
428 "size of evictable data in mfu state");
431 extern arc_state_t ARC_mfu_ghost
;
434 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, mfu_ghost_size
,
435 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
436 &ARC_mfu_ghost
, 0, param_get_arc_state_size
, "Q",
437 "size of mfu ghost state");
438 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mfu_ghost_metadata_esize
, CTLFLAG_RD
,
439 &ARC_mfu_ghost
.arcs_esize
[ARC_BUFC_METADATA
].rc_count
, 0,
440 "size of evictable metadata in mfu ghost state");
441 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, mfu_ghost_data_esize
, CTLFLAG_RD
,
442 &ARC_mfu_ghost
.arcs_esize
[ARC_BUFC_DATA
].rc_count
, 0,
443 "size of evictable data in mfu ghost state");
446 extern arc_state_t ARC_uncached
;
449 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, uncached_size
,
450 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
451 &ARC_uncached
, 0, param_get_arc_state_size
, "Q",
452 "size of uncached state");
453 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, uncached_metadata_esize
, CTLFLAG_RD
,
454 &ARC_uncached
.arcs_esize
[ARC_BUFC_METADATA
].rc_count
, 0,
455 "size of evictable metadata in uncached state");
456 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, uncached_data_esize
, CTLFLAG_RD
,
457 &ARC_uncached
.arcs_esize
[ARC_BUFC_DATA
].rc_count
, 0,
458 "size of evictable data in uncached state");
461 extern arc_state_t ARC_l2c_only
;
464 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, l2c_only_size
,
465 CTLTYPE_S64
| CTLFLAG_RD
| CTLFLAG_MPSAFE
,
466 &ARC_l2c_only
, 0, param_get_arc_state_size
, "Q",
467 "size of l2c_only state");
476 SYSCTL_NODE(_vfs_zfs
, OID_AUTO
, zfetch
, CTLFLAG_RW
, 0, "ZFS ZFETCH (LEGACY)");
478 extern uint32_t zfetch_max_distance
;
481 SYSCTL_UINT(_vfs_zfs_zfetch
, OID_AUTO
, max_distance
,
482 CTLFLAG_RWTUN
, &zfetch_max_distance
, 0,
483 "Max bytes to prefetch per stream (LEGACY)");
486 extern uint32_t zfetch_max_idistance
;
489 SYSCTL_UINT(_vfs_zfs_zfetch
, OID_AUTO
, max_idistance
,
490 CTLFLAG_RWTUN
, &zfetch_max_idistance
, 0,
491 "Max bytes to prefetch indirects for per stream (LEGACY)");
503 param_set_active_allocator(SYSCTL_HANDLER_ARGS
)
508 if (req
->newptr
== NULL
)
509 strlcpy(buf
, zfs_active_allocator
, sizeof (buf
));
511 rc
= sysctl_handle_string(oidp
, buf
, sizeof (buf
), req
);
512 if (rc
|| req
->newptr
== NULL
)
514 if (strcmp(buf
, zfs_active_allocator
) == 0)
517 return (param_set_active_allocator_common(buf
));
521 * In pools where the log space map feature is not enabled we touch
522 * multiple metaslabs (and their respective space maps) with each
523 * transaction group. Thus, we benefit from having a small space map
524 * block size since it allows us to issue more I/O operations scattered
525 * around the disk. So a sane default for the space map block size
528 extern int zfs_metaslab_sm_blksz_no_log
;
531 SYSCTL_INT(_vfs_zfs_metaslab
, OID_AUTO
, sm_blksz_no_log
,
532 CTLFLAG_RDTUN
, &zfs_metaslab_sm_blksz_no_log
, 0,
533 "Block size for space map in pools with log space map disabled. "
534 "Power of 2 greater than 4096.");
538 * When the log space map feature is enabled, we accumulate a lot of
539 * changes per metaslab that are flushed once in a while so we benefit
540 * from a bigger block size like 128K for the metaslab space maps.
542 extern int zfs_metaslab_sm_blksz_with_log
;
545 SYSCTL_INT(_vfs_zfs_metaslab
, OID_AUTO
, sm_blksz_with_log
,
546 CTLFLAG_RDTUN
, &zfs_metaslab_sm_blksz_with_log
, 0,
547 "Block size for space map in pools with log space map enabled. "
548 "Power of 2 greater than 4096.");
552 * The in-core space map representation is more compact than its on-disk form.
553 * The zfs_condense_pct determines how much more compact the in-core
554 * space map representation must be before we compact it on-disk.
555 * Values should be greater than or equal to 100.
557 extern uint_t zfs_condense_pct
;
560 SYSCTL_UINT(_vfs_zfs
, OID_AUTO
, condense_pct
,
561 CTLFLAG_RWTUN
, &zfs_condense_pct
, 0,
562 "Condense on-disk spacemap when it is more than this many percents"
563 " of in-memory counterpart");
566 extern uint_t zfs_remove_max_segment
;
569 SYSCTL_UINT(_vfs_zfs
, OID_AUTO
, remove_max_segment
,
570 CTLFLAG_RWTUN
, &zfs_remove_max_segment
, 0,
571 "Largest contiguous segment ZFS will attempt to allocate when removing"
575 extern int zfs_removal_suspend_progress
;
578 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, removal_suspend_progress
,
579 CTLFLAG_RWTUN
, &zfs_removal_suspend_progress
, 0,
580 "Ensures certain actions can happen while in the middle of a removal");
584 * Minimum size which forces the dynamic allocator to change
585 * it's allocation strategy. Once the space map cannot satisfy
586 * an allocation of this size then it switches to using more
587 * aggressive strategy (i.e search by size rather than offset).
589 extern uint64_t metaslab_df_alloc_threshold
;
592 SYSCTL_QUAD(_vfs_zfs_metaslab
, OID_AUTO
, df_alloc_threshold
,
593 CTLFLAG_RWTUN
, &metaslab_df_alloc_threshold
, 0,
594 "Minimum size which forces the dynamic allocator to change its"
595 " allocation strategy");
599 * The minimum free space, in percent, which must be available
600 * in a space map to continue allocations in a first-fit fashion.
601 * Once the space map's free space drops below this level we dynamically
602 * switch to using best-fit allocations.
604 extern uint_t metaslab_df_free_pct
;
607 SYSCTL_UINT(_vfs_zfs_metaslab
, OID_AUTO
, df_free_pct
,
608 CTLFLAG_RWTUN
, &metaslab_df_free_pct
, 0,
609 "The minimum free space, in percent, which must be available in a"
610 " space map to continue allocations in a first-fit fashion");
616 param_set_multihost_interval(SYSCTL_HANDLER_ARGS
)
620 err
= sysctl_handle_64(oidp
, &zfs_multihost_interval
, 0, req
);
621 if (err
!= 0 || req
->newptr
== NULL
)
624 if (spa_mode_global
!= SPA_MODE_UNINIT
)
625 mmp_signal_all_threads();
632 extern int zfs_ccw_retry_interval
;
635 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, ccw_retry_interval
,
636 CTLFLAG_RWTUN
, &zfs_ccw_retry_interval
, 0,
637 "Configuration cache file write, retry after failure, interval"
641 extern uint64_t zfs_max_missing_tvds_cachefile
;
644 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, max_missing_tvds_cachefile
,
645 CTLFLAG_RWTUN
, &zfs_max_missing_tvds_cachefile
, 0,
646 "Allow importing pools with missing top-level vdevs in cache file");
649 extern uint64_t zfs_max_missing_tvds_scan
;
652 SYSCTL_UQUAD(_vfs_zfs
, OID_AUTO
, max_missing_tvds_scan
,
653 CTLFLAG_RWTUN
, &zfs_max_missing_tvds_scan
, 0,
654 "Allow importing pools with missing top-level vdevs during scan");
659 extern int zfs_flags
;
662 sysctl_vfs_zfs_debug_flags(SYSCTL_HANDLER_ARGS
)
667 err
= sysctl_handle_int(oidp
, &val
, 0, req
);
668 if (err
!= 0 || req
->newptr
== NULL
)
672 * ZFS_DEBUG_MODIFY must be enabled prior to boot so all
673 * arc buffers in the system have the necessary additional
674 * checksum data. However, it is safe to disable at any
677 if (!(zfs_flags
& ZFS_DEBUG_MODIFY
))
678 val
&= ~ZFS_DEBUG_MODIFY
;
685 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, debugflags
,
686 CTLTYPE_UINT
| CTLFLAG_MPSAFE
| CTLFLAG_RWTUN
, NULL
, 0,
687 sysctl_vfs_zfs_debug_flags
, "IU", "Debug flags for ZFS testing.");
691 param_set_deadman_synctime(SYSCTL_HANDLER_ARGS
)
696 val
= zfs_deadman_synctime_ms
;
697 err
= sysctl_handle_64(oidp
, &val
, 0, req
);
698 if (err
!= 0 || req
->newptr
== NULL
)
700 zfs_deadman_synctime_ms
= val
;
702 spa_set_deadman_synctime(MSEC2NSEC(zfs_deadman_synctime_ms
));
708 param_set_deadman_ziotime(SYSCTL_HANDLER_ARGS
)
713 val
= zfs_deadman_ziotime_ms
;
714 err
= sysctl_handle_64(oidp
, &val
, 0, req
);
715 if (err
!= 0 || req
->newptr
== NULL
)
717 zfs_deadman_ziotime_ms
= val
;
719 spa_set_deadman_ziotime(MSEC2NSEC(zfs_deadman_synctime_ms
));
725 param_set_deadman_failmode(SYSCTL_HANDLER_ARGS
)
730 if (req
->newptr
== NULL
)
731 strlcpy(buf
, zfs_deadman_failmode
, sizeof (buf
));
733 rc
= sysctl_handle_string(oidp
, buf
, sizeof (buf
), req
);
734 if (rc
|| req
->newptr
== NULL
)
736 if (strcmp(buf
, zfs_deadman_failmode
) == 0)
738 if (strcmp(buf
, "wait") == 0)
739 zfs_deadman_failmode
= "wait";
740 if (strcmp(buf
, "continue") == 0)
741 zfs_deadman_failmode
= "continue";
742 if (strcmp(buf
, "panic") == 0)
743 zfs_deadman_failmode
= "panic";
745 return (-param_set_deadman_failmode_common(buf
));
749 param_set_slop_shift(SYSCTL_HANDLER_ARGS
)
754 val
= spa_slop_shift
;
755 err
= sysctl_handle_int(oidp
, &val
, 0, req
);
756 if (err
!= 0 || req
->newptr
== NULL
)
759 if (val
< 1 || val
> 31)
762 spa_slop_shift
= val
;
769 extern int space_map_ibs
;
772 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, space_map_ibs
, CTLFLAG_RWTUN
,
773 &space_map_ibs
, 0, "Space map indirect block shift");
780 param_set_min_auto_ashift(SYSCTL_HANDLER_ARGS
)
785 val
= zfs_vdev_min_auto_ashift
;
786 err
= sysctl_handle_int(oidp
, &val
, 0, req
);
787 if (err
!= 0 || req
->newptr
== NULL
)
788 return (SET_ERROR(err
));
790 if (val
< ASHIFT_MIN
|| val
> zfs_vdev_max_auto_ashift
)
791 return (SET_ERROR(EINVAL
));
793 zfs_vdev_min_auto_ashift
= val
;
799 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, min_auto_ashift
,
800 CTLTYPE_UINT
| CTLFLAG_RWTUN
| CTLFLAG_MPSAFE
,
801 &zfs_vdev_min_auto_ashift
, sizeof (zfs_vdev_min_auto_ashift
),
802 param_set_min_auto_ashift
, "IU",
803 "Min ashift used when creating new top-level vdev. (LEGACY)");
807 param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS
)
812 val
= zfs_vdev_max_auto_ashift
;
813 err
= sysctl_handle_int(oidp
, &val
, 0, req
);
814 if (err
!= 0 || req
->newptr
== NULL
)
815 return (SET_ERROR(err
));
817 if (val
> ASHIFT_MAX
|| val
< zfs_vdev_min_auto_ashift
)
818 return (SET_ERROR(EINVAL
));
820 zfs_vdev_max_auto_ashift
= val
;
826 SYSCTL_PROC(_vfs_zfs
, OID_AUTO
, max_auto_ashift
,
827 CTLTYPE_UINT
| CTLFLAG_RWTUN
| CTLFLAG_MPSAFE
,
828 &zfs_vdev_max_auto_ashift
, sizeof (zfs_vdev_max_auto_ashift
),
829 param_set_max_auto_ashift
, "IU",
830 "Max ashift used when optimizing for logical -> physical sector size on"
831 " new top-level vdevs. (LEGACY)");
835 * Since the DTL space map of a vdev is not expected to have a lot of
836 * entries, we default its block size to 4K.
838 extern int zfs_vdev_dtl_sm_blksz
;
841 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, dtl_sm_blksz
,
842 CTLFLAG_RDTUN
, &zfs_vdev_dtl_sm_blksz
, 0,
843 "Block size for DTL space map. Power of 2 greater than 4096.");
847 * vdev-wide space maps that have lots of entries written to them at
848 * the end of each transaction can benefit from a higher I/O bandwidth
849 * (e.g. vdev_obsolete_sm), thus we default their block size to 128K.
851 extern int zfs_vdev_standard_sm_blksz
;
854 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, standard_sm_blksz
,
855 CTLFLAG_RDTUN
, &zfs_vdev_standard_sm_blksz
, 0,
856 "Block size for standard space map. Power of 2 greater than 4096.");
859 extern int vdev_validate_skip
;
862 SYSCTL_INT(_vfs_zfs
, OID_AUTO
, validate_skip
,
863 CTLFLAG_RDTUN
, &vdev_validate_skip
, 0,
864 "Enable to bypass vdev_validate().");
871 extern uint_t zfs_vdev_max_active
;
874 SYSCTL_UINT(_vfs_zfs
, OID_AUTO
, top_maxinflight
,
875 CTLFLAG_RWTUN
, &zfs_vdev_max_active
, 0,
876 "The maximum number of I/Os of all types active for each device."
883 SYSCTL_INT(_vfs_zfs_zio
, OID_AUTO
, exclude_metadata
,
884 CTLFLAG_RDTUN
, &zio_exclude_metadata
, 0,
885 "Exclude metadata buffers from dumps as well");