Skip to content

Commit 76d21a1

Browse files
author
Ryan Moeller
committed
Add zpool properties for allocation class space
The existing zpool properties accounting pool space (size, allocated, fragmentation, expandsize, free, capacity) are based on the normal metaslab class or are cumulative properties of several classes combined. Add properties reporting the space accounting metrics for each metaslab class individually. Also introduce pool-wide USABLE and USED properties reporting values corresponding to SIZE and ALLOC deflated for raidz. Update ZTS to recognize the new properties and validate reported values. Sponsored-by: Klara, Inc. Signed-off-by: Ryan Moeller <ryan.moeller@klarasystems.com>
1 parent bc6e027 commit 76d21a1

File tree

13 files changed

+950
-33
lines changed

13 files changed

+950
-33
lines changed

cmd/zpool/zpool_main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6954,7 +6954,19 @@ collect_vdev_prop(zpool_prop_t prop, uint64_t value, const char *str,
69546954

69556955
switch (prop) {
69566956
case ZPOOL_PROP_SIZE:
6957+
case ZPOOL_PROP_NORMAL_SIZE:
6958+
case ZPOOL_PROP_SPECIAL_SIZE:
6959+
case ZPOOL_PROP_DEDUP_SIZE:
6960+
case ZPOOL_PROP_LOG_SIZE:
6961+
case ZPOOL_PROP_ELOG_SIZE:
6962+
case ZPOOL_PROP_SELOG_SIZE:
69576963
case ZPOOL_PROP_EXPANDSZ:
6964+
case ZPOOL_PROP_NORMAL_EXPANDSZ:
6965+
case ZPOOL_PROP_SPECIAL_EXPANDSZ:
6966+
case ZPOOL_PROP_DEDUP_EXPANDSZ:
6967+
case ZPOOL_PROP_LOG_EXPANDSZ:
6968+
case ZPOOL_PROP_ELOG_EXPANDSZ:
6969+
case ZPOOL_PROP_SELOG_EXPANDSZ:
69586970
case ZPOOL_PROP_CHECKPOINT:
69596971
case ZPOOL_PROP_DEDUPRATIO:
69606972
case ZPOOL_PROP_DEDUPCACHED:
@@ -6965,6 +6977,12 @@ collect_vdev_prop(zpool_prop_t prop, uint64_t value, const char *str,
69656977
format);
69666978
break;
69676979
case ZPOOL_PROP_FRAGMENTATION:
6980+
case ZPOOL_PROP_NORMAL_FRAGMENTATION:
6981+
case ZPOOL_PROP_SPECIAL_FRAGMENTATION:
6982+
case ZPOOL_PROP_DEDUP_FRAGMENTATION:
6983+
case ZPOOL_PROP_LOG_FRAGMENTATION:
6984+
case ZPOOL_PROP_ELOG_FRAGMENTATION:
6985+
case ZPOOL_PROP_SELOG_FRAGMENTATION:
69686986
if (value == ZFS_FRAG_INVALID) {
69696987
(void) strlcpy(propval, "-", sizeof (propval));
69706988
} else if (format == ZFS_NICENUM_RAW) {
@@ -6976,6 +6994,12 @@ collect_vdev_prop(zpool_prop_t prop, uint64_t value, const char *str,
69766994
}
69776995
break;
69786996
case ZPOOL_PROP_CAPACITY:
6997+
case ZPOOL_PROP_NORMAL_CAPACITY:
6998+
case ZPOOL_PROP_SPECIAL_CAPACITY:
6999+
case ZPOOL_PROP_DEDUP_CAPACITY:
7000+
case ZPOOL_PROP_LOG_CAPACITY:
7001+
case ZPOOL_PROP_ELOG_CAPACITY:
7002+
case ZPOOL_PROP_SELOG_CAPACITY:
69797003
/* capacity value is in parts-per-10,000 (aka permyriad) */
69807004
if (format == ZFS_NICENUM_RAW)
69817005
(void) snprintf(propval, sizeof (propval), "%llu",

include/sys/fs/zfs.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,89 @@ typedef enum {
273273
ZPOOL_PROP_DEDUP_TABLE_QUOTA,
274274
ZPOOL_PROP_DEDUPCACHED,
275275
ZPOOL_PROP_LAST_SCRUBBED_TXG,
276+
ZPOOL_PROP_USABLE,
277+
ZPOOL_PROP_USED,
278+
ZPOOL_PROP_NORMAL_SIZE,
279+
ZPOOL_PROP_NORMAL_CAPACITY,
280+
ZPOOL_PROP_NORMAL_FREE,
281+
ZPOOL_PROP_NORMAL_ALLOCATED,
282+
ZPOOL_PROP_NORMAL_AVAILABLE,
283+
ZPOOL_PROP_NORMAL_USABLE,
284+
ZPOOL_PROP_NORMAL_USED,
285+
ZPOOL_PROP_NORMAL_EXPANDSZ,
286+
ZPOOL_PROP_NORMAL_FRAGMENTATION,
287+
ZPOOL_PROP_SPECIAL_SIZE,
288+
ZPOOL_PROP_SPECIAL_CAPACITY,
289+
ZPOOL_PROP_SPECIAL_FREE,
290+
ZPOOL_PROP_SPECIAL_ALLOCATED,
291+
ZPOOL_PROP_SPECIAL_AVAILABLE,
292+
ZPOOL_PROP_SPECIAL_USABLE,
293+
ZPOOL_PROP_SPECIAL_USED,
294+
ZPOOL_PROP_SPECIAL_EXPANDSZ,
295+
ZPOOL_PROP_SPECIAL_FRAGMENTATION,
296+
ZPOOL_PROP_DEDUP_SIZE,
297+
ZPOOL_PROP_DEDUP_CAPACITY,
298+
ZPOOL_PROP_DEDUP_FREE,
299+
ZPOOL_PROP_DEDUP_ALLOCATED,
300+
ZPOOL_PROP_DEDUP_AVAILABLE,
301+
ZPOOL_PROP_DEDUP_USABLE,
302+
ZPOOL_PROP_DEDUP_USED,
303+
ZPOOL_PROP_DEDUP_EXPANDSZ,
304+
ZPOOL_PROP_DEDUP_FRAGMENTATION,
305+
ZPOOL_PROP_LOG_SIZE,
306+
ZPOOL_PROP_LOG_CAPACITY,
307+
ZPOOL_PROP_LOG_FREE,
308+
ZPOOL_PROP_LOG_ALLOCATED,
309+
ZPOOL_PROP_LOG_AVAILABLE,
310+
ZPOOL_PROP_LOG_USABLE,
311+
ZPOOL_PROP_LOG_USED,
312+
ZPOOL_PROP_LOG_EXPANDSZ,
313+
ZPOOL_PROP_LOG_FRAGMENTATION,
314+
ZPOOL_PROP_ELOG_SIZE,
315+
ZPOOL_PROP_ELOG_CAPACITY,
316+
ZPOOL_PROP_ELOG_FREE,
317+
ZPOOL_PROP_ELOG_ALLOCATED,
318+
ZPOOL_PROP_ELOG_AVAILABLE,
319+
ZPOOL_PROP_ELOG_USABLE,
320+
ZPOOL_PROP_ELOG_USED,
321+
ZPOOL_PROP_ELOG_EXPANDSZ,
322+
ZPOOL_PROP_ELOG_FRAGMENTATION,
323+
ZPOOL_PROP_SELOG_SIZE,
324+
ZPOOL_PROP_SELOG_CAPACITY,
325+
ZPOOL_PROP_SELOG_FREE,
326+
ZPOOL_PROP_SELOG_ALLOCATED,
327+
ZPOOL_PROP_SELOG_AVAILABLE,
328+
ZPOOL_PROP_SELOG_USABLE,
329+
ZPOOL_PROP_SELOG_USED,
330+
ZPOOL_PROP_SELOG_EXPANDSZ,
331+
ZPOOL_PROP_SELOG_FRAGMENTATION,
276332
ZPOOL_NUM_PROPS
277333
} zpool_prop_t;
278334

335+
/* Offsets for metaslab class properties. */
336+
typedef enum {
337+
ZPOOL_MC_PROP_SIZE,
338+
ZPOOL_MC_PROP_CAPACITY,
339+
ZPOOL_MC_PROP_FREE,
340+
ZPOOL_MC_PROP_ALLOCATED,
341+
ZPOOL_MC_PROP_AVAILABLE,
342+
ZPOOL_MC_PROP_USABLE,
343+
ZPOOL_MC_PROP_USED,
344+
ZPOOL_MC_PROP_EXPANDSZ,
345+
ZPOOL_MC_PROP_FRAGMENTATION,
346+
ZPOOL_NUM_MC_PROPS
347+
} zpool_mc_prop_t;
348+
349+
/* Offsets for metaslab class property groups. */
350+
typedef enum {
351+
ZPOOL_MC_PROPS_NORMAL = ZPOOL_PROP_NORMAL_SIZE,
352+
ZPOOL_MC_PROPS_SPECIAL = ZPOOL_PROP_SPECIAL_SIZE,
353+
ZPOOL_MC_PROPS_DEDUP = ZPOOL_PROP_DEDUP_SIZE,
354+
ZPOOL_MC_PROPS_LOG = ZPOOL_PROP_LOG_SIZE,
355+
ZPOOL_MC_PROPS_ELOG = ZPOOL_PROP_ELOG_SIZE,
356+
ZPOOL_MC_PROPS_SELOG = ZPOOL_PROP_SELOG_SIZE,
357+
} zpool_mc_props_t;
358+
279359
/* Small enough to not hog a whole line of printout in zpool(8). */
280360
#define ZPROP_MAX_COMMENT 32
281361
#define ZPROP_BOOLEAN_NA 2

lib/libzfs/libzfs_pool.c

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,46 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
370370
zfs_fallthrough;
371371

372372
case ZPOOL_PROP_SIZE:
373+
case ZPOOL_PROP_NORMAL_SIZE:
374+
case ZPOOL_PROP_SPECIAL_SIZE:
375+
case ZPOOL_PROP_DEDUP_SIZE:
376+
case ZPOOL_PROP_LOG_SIZE:
377+
case ZPOOL_PROP_ELOG_SIZE:
378+
case ZPOOL_PROP_SELOG_SIZE:
373379
case ZPOOL_PROP_ALLOCATED:
380+
case ZPOOL_PROP_NORMAL_ALLOCATED:
381+
case ZPOOL_PROP_SPECIAL_ALLOCATED:
382+
case ZPOOL_PROP_DEDUP_ALLOCATED:
383+
case ZPOOL_PROP_LOG_ALLOCATED:
384+
case ZPOOL_PROP_ELOG_ALLOCATED:
385+
case ZPOOL_PROP_SELOG_ALLOCATED:
386+
case ZPOOL_PROP_NORMAL_AVAILABLE:
387+
case ZPOOL_PROP_SPECIAL_AVAILABLE:
388+
case ZPOOL_PROP_DEDUP_AVAILABLE:
389+
case ZPOOL_PROP_LOG_AVAILABLE:
390+
case ZPOOL_PROP_ELOG_AVAILABLE:
391+
case ZPOOL_PROP_SELOG_AVAILABLE:
374392
case ZPOOL_PROP_FREE:
393+
case ZPOOL_PROP_NORMAL_FREE:
394+
case ZPOOL_PROP_SPECIAL_FREE:
395+
case ZPOOL_PROP_DEDUP_FREE:
396+
case ZPOOL_PROP_LOG_FREE:
397+
case ZPOOL_PROP_ELOG_FREE:
398+
case ZPOOL_PROP_SELOG_FREE:
399+
case ZPOOL_PROP_USABLE:
400+
case ZPOOL_PROP_NORMAL_USABLE:
401+
case ZPOOL_PROP_SPECIAL_USABLE:
402+
case ZPOOL_PROP_DEDUP_USABLE:
403+
case ZPOOL_PROP_LOG_USABLE:
404+
case ZPOOL_PROP_ELOG_USABLE:
405+
case ZPOOL_PROP_SELOG_USABLE:
406+
case ZPOOL_PROP_USED:
407+
case ZPOOL_PROP_NORMAL_USED:
408+
case ZPOOL_PROP_SPECIAL_USED:
409+
case ZPOOL_PROP_DEDUP_USED:
410+
case ZPOOL_PROP_LOG_USED:
411+
case ZPOOL_PROP_ELOG_USED:
412+
case ZPOOL_PROP_SELOG_USED:
375413
case ZPOOL_PROP_FREEING:
376414
case ZPOOL_PROP_LEAKED:
377415
case ZPOOL_PROP_ASHIFT:
@@ -389,6 +427,12 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
389427
break;
390428

391429
case ZPOOL_PROP_EXPANDSZ:
430+
case ZPOOL_PROP_NORMAL_EXPANDSZ:
431+
case ZPOOL_PROP_SPECIAL_EXPANDSZ:
432+
case ZPOOL_PROP_DEDUP_EXPANDSZ:
433+
case ZPOOL_PROP_LOG_EXPANDSZ:
434+
case ZPOOL_PROP_ELOG_EXPANDSZ:
435+
case ZPOOL_PROP_SELOG_EXPANDSZ:
392436
case ZPOOL_PROP_CHECKPOINT:
393437
if (intval == 0) {
394438
(void) strlcpy(buf, "-", len);
@@ -401,6 +445,12 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
401445
break;
402446

403447
case ZPOOL_PROP_CAPACITY:
448+
case ZPOOL_PROP_NORMAL_CAPACITY:
449+
case ZPOOL_PROP_SPECIAL_CAPACITY:
450+
case ZPOOL_PROP_DEDUP_CAPACITY:
451+
case ZPOOL_PROP_LOG_CAPACITY:
452+
case ZPOOL_PROP_ELOG_CAPACITY:
453+
case ZPOOL_PROP_SELOG_CAPACITY:
404454
if (literal) {
405455
(void) snprintf(buf, len, "%llu",
406456
(u_longlong_t)intval);
@@ -411,7 +461,13 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
411461
break;
412462

413463
case ZPOOL_PROP_FRAGMENTATION:
414-
if (intval == UINT64_MAX) {
464+
case ZPOOL_PROP_NORMAL_FRAGMENTATION:
465+
case ZPOOL_PROP_SPECIAL_FRAGMENTATION:
466+
case ZPOOL_PROP_DEDUP_FRAGMENTATION:
467+
case ZPOOL_PROP_LOG_FRAGMENTATION:
468+
case ZPOOL_PROP_ELOG_FRAGMENTATION:
469+
case ZPOOL_PROP_SELOG_FRAGMENTATION:
470+
if (intval == ZFS_FRAG_INVALID) {
415471
(void) strlcpy(buf, "-", len);
416472
} else if (literal) {
417473
(void) snprintf(buf, len, "%llu",

man/man7/zpoolprops.7

Lines changed: 130 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
.\" Copyright 2017 Nexenta Systems, Inc.
2828
.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
2929
.\" Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
30-
.\" Copyright (c) 2023, Klara Inc.
30+
.\" Copyright (c) 2023, 2026, Klara Inc.
3131
.\"
32-
.Dd December 4, 2024
32+
.Dd February 20, 2026
3333
.Dt ZPOOLPROPS 7
3434
.Os
3535
.
@@ -49,7 +49,7 @@ For more information about user properties, see the
4949
section.
5050
.Pp
5151
The following are read-only properties:
52-
.Bl -tag -width "unsupported@guid"
52+
.Bl -tag -width "last_scrubbed_txg"
5353
.It Sy allocated
5454
Amount of storage used within the pool.
5555
See
@@ -169,6 +169,21 @@ Information about unsupported features that are enabled on the pool.
169169
See
170170
.Xr zpool-features 7
171171
for details.
172+
.It Sy usable
173+
Estimate of total storage pool size, adjusted for raidz parity overhead.
174+
The adjustment assumes a fixed 128KiB record size to compute a data-to-parity
175+
ratio.
176+
.Sy usable
177+
is a heuristic for allocation and should not be interpreted as an exact measure
178+
of usable space.
179+
.It Sy used
180+
Estimate of storage used within the storage pool, adjusted for raidz parity
181+
overhead.
182+
The adjustment assumes a fixed 128KiB record size to compute a data-to-parity
183+
ratio.
184+
.Sy used
185+
is a heuristic for allocation and should not be interpreted as an exact measure
186+
of used space.
172187
.El
173188
.Pp
174189
The space usage properties report actual physical space available to the
@@ -186,6 +201,118 @@ For non-full pools of a reasonable size, these effects should be invisible.
186201
For small pools, or pools that are close to being completely full, these
187202
discrepancies may become more noticeable.
188203
.Pp
204+
The following properties are read-only metrics for allocation classes:
205+
.Bl -ohang
206+
.It Xo Sy dedup_allocated , dedup_available , dedup_capacity ,
207+
.Sy dedup_expandsize , dedup_fragmentation , dedup_free , dedup_size ,
208+
.Sy dedup_usable , dedup_used
209+
.Xc
210+
.Bd -ragged -offset Ds -compact
211+
Space usage properties of the pool's
212+
.Sy dedup
213+
metaslab allocator class.
214+
.Ed
215+
.It Xo Sy embedded_log_allocated , embedded_log_available ,
216+
.Sy embedded_log_capacity , embedded_log_expandsize ,
217+
.Sy embedded_log_fragmentation , embedded_log_free , embedded_log_size ,
218+
.Sy embedded_log_usable , embedded_log_used
219+
.Xc
220+
.Bd -ragged -offset Ds -compact
221+
Space usage properties of the pool's
222+
.Sy embedded_log
223+
metaslab allocator class.
224+
.Ed
225+
.It Xo Sy log_allocated , log_available , log_capacity , log_expandsize ,
226+
.Sy log_fragmentation , log_free , log_size , log_usable , log_used
227+
.Xc
228+
.Bd -ragged -offset Ds -compact
229+
Space usage properties of the pool's
230+
.Sy log
231+
metaslab allocator class.
232+
.Ed
233+
.It Xo Sy normal_allocated , normal_available , normal_capacity ,
234+
.Sy normal_expandsize , normal_fragmentation , normal_free , normal_size ,
235+
.Sy normal_usable , normal_used
236+
.Xc
237+
.Bd -ragged -offset Ds -compact
238+
Space usage properties of the pool's
239+
.Sy normal
240+
metaslab allocator class.
241+
.Ed
242+
.It Xo Sy special_allocated , special_available , special_capacity ,
243+
.Sy special_expandsize , special_fragmentation , special_free , special_size ,
244+
.Sy special_usable , special_used
245+
.Xc
246+
.Bd -ragged -offset Ds -compact
247+
Space usage properties of the pool's
248+
.Sy special
249+
metaslab allocator class.
250+
.Ed
251+
.It Xo Sy special_embedded_log_allocated , special_embedded_log_available ,
252+
.Sy special_embedded_log_capacity , special_embedded_log_expandsize ,
253+
.Sy special_embedded_log_fragmentation , special_embedded_log_free ,
254+
.Sy special_embedded_size , special_embedded_usable , special_embedded_used
255+
.Xc
256+
.Bd -ragged -offset Ds -compact
257+
Space usage properties of the pool's
258+
.Sy special_embedded_log
259+
metaslab allocator class.
260+
.Ed
261+
.El
262+
.Pp
263+
Each allocation class is described by these values:
264+
.Bl -tag -width "fragmentation"
265+
.It Sy allocated
266+
Amount of storage used within the allocation class.
267+
.It Sy available
268+
Estimate of free space available in the allocation class, adjusted for raidz
269+
parity overhead.
270+
The adjustment assumes a fixed 128KiB record size to compute a data-to-parity
271+
ratio.
272+
.Sy available
273+
is a heuristic for allocation and should not be interpreted as an exact measure
274+
of usable space.
275+
Actual usable space depends on a variety of factors such as dataset record size
276+
and compression.
277+
.It Sy capacity
278+
Percentage of allocation class space used.
279+
.It Sy expandsize
280+
Amount of uninitialized space within the allocation class that can be used to
281+
increase the capacity of the allocator.
282+
See the pool-wide
283+
.Sy expandsize
284+
property.
285+
.It Sy fragmentation
286+
The amount of free space fragmentation in the allocation class.
287+
See the pool-wide
288+
.Sy fragmentation
289+
property.
290+
.It Sy free
291+
The amount of free space available in the allocation class.
292+
This value is not adjusted for factors such as dataset record size, compression,
293+
or raidz parity overhead.
294+
See the pool-wide
295+
.Sy free
296+
property.
297+
.It Sy size
298+
Total size of the allocation class.
299+
.It Sy usable
300+
Estimate of total allocation class size, adjusted for raidz parity overhead.
301+
The adjustment assumes a fixed 128KiB record size to compute a data-to-parity
302+
ratio.
303+
.Sy usable
304+
is a heuristic for allocation and should not be interpreted as an exact measure
305+
of usable space.
306+
.It Sy used
307+
Estimate of storage used within the allocation class, adjusted for raidz parity
308+
overhead.
309+
The adjustment assumes a fixed 128KiB record size to compute a data-to-parity
310+
ratio.
311+
.Sy used
312+
is a heuristic for allocation and should not be interpreted as an exact measure
313+
of used space.
314+
.El
315+
.Pp
189316
The following property can be set at creation time and import time:
190317
.Bl -tag -width Ds
191318
.It Sy altroot

0 commit comments

Comments
 (0)