Skip to content

Commit a52d81e

Browse files
author
Paul Dagnelie
committed
Add support for anyraid in vdev properties
Signed-off-by: Paul Dagnelie <[email protected]> Sponsored-by: Eshtek, creators of HexOS Sponsored-by: Klara, Inc.
1 parent 6ac085b commit a52d81e

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

include/sys/fs/zfs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ typedef enum {
385385
VDEV_PROP_TRIM_SUPPORT,
386386
VDEV_PROP_TRIM_ERRORS,
387387
VDEV_PROP_SLOW_IOS,
388+
VDEV_PROP_ANYRAID_CAP_TILES,
389+
VDEV_PROP_ANYRAID_NUM_TILES,
390+
VDEV_PROP_ANYRAID_TILE_SIZE,
388391
VDEV_NUM_PROPS
389392
} vdev_prop_t;
390393

lib/libzfs/libzfs_pool.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5477,6 +5477,10 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name,
54775477
if (nvlist_lookup_nvlist(nvprop, prop_name, &nv) == 0) {
54785478
src = fnvlist_lookup_uint64(nv, ZPROP_SOURCE);
54795479
intval = fnvlist_lookup_uint64(nv, ZPROP_VALUE);
5480+
} else if (prop == VDEV_PROP_ANYRAID_CAP_TILES ||
5481+
prop == VDEV_PROP_ANYRAID_NUM_TILES ||
5482+
prop == VDEV_PROP_ANYRAID_TILE_SIZE) {
5483+
return (ENOENT);
54805484
} else {
54815485
src = ZPROP_SRC_DEFAULT;
54825486
intval = vdev_prop_default_numeric(prop);
@@ -5507,6 +5511,7 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name,
55075511
case VDEV_PROP_BYTES_FREE:
55085512
case VDEV_PROP_BYTES_CLAIM:
55095513
case VDEV_PROP_BYTES_TRIM:
5514+
case VDEV_PROP_ANYRAID_TILE_SIZE:
55105515
if (literal) {
55115516
(void) snprintf(buf, len, "%llu",
55125517
(u_longlong_t)intval);

module/zcommon/zpool_prop.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,15 @@ vdev_prop_init(void)
436436
zprop_register_number(VDEV_PROP_BYTES_TRIM, "trim_bytes", 0,
437437
PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "TRIMBYTE", B_FALSE,
438438
sfeatures);
439+
zprop_register_number(VDEV_PROP_ANYRAID_CAP_TILES,
440+
"anyraid_region_capacity", 0, PROP_READONLY, ZFS_TYPE_VDEV,
441+
"<regions>", "TILECAP", B_FALSE, sfeatures);
442+
zprop_register_number(VDEV_PROP_ANYRAID_NUM_TILES,
443+
"anyraid_region_count", 0, PROP_READONLY, ZFS_TYPE_VDEV,
444+
"<regions>", "NUMTILES", B_FALSE, sfeatures);
445+
zprop_register_number(VDEV_PROP_ANYRAID_TILE_SIZE,
446+
"anyraid_region_size", 0, PROP_READONLY, ZFS_TYPE_VDEV,
447+
"<bytes>", "TILESIZE", B_FALSE, sfeatures);
439448

440449
/* default numeric properties */
441450
zprop_register_number(VDEV_PROP_CHECKSUM_N, "checksum_n", UINT64_MAX,

module/zfs/vdev.c

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
#include <sys/arc.h>
5656
#include <sys/zil.h>
5757
#include <sys/dsl_scan.h>
58-
#include <sys/vdev_raidz.h>
5958
#include <sys/abd.h>
6059
#include <sys/vdev_initialize.h>
6160
#include <sys/vdev_trim.h>
6261
#include <sys/vdev_raidz.h>
62+
#include <sys/vdev_anyraid.h>
6363
#include <sys/zvol.h>
6464
#include <sys/zfs_ratelimit.h>
6565
#include "zfs_prop.h"
@@ -6571,6 +6571,68 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
65716571
break;
65726572
}
65736573
break;
6574+
case VDEV_PROP_ANYRAID_CAP_TILES:
6575+
{
6576+
vdev_t *pvd = vd->vdev_parent;
6577+
uint64_t total = 0;
6578+
if (vd->vdev_ops == &vdev_anyraid_ops) {
6579+
vdev_anyraid_t *var = vd->vdev_tsd;
6580+
for (int i = 0; i < vd->vdev_children;
6581+
i++) {
6582+
total += var->vd_children[i]
6583+
->van_capacity;
6584+
}
6585+
} else if (pvd && pvd->vdev_ops ==
6586+
&vdev_anyraid_ops) {
6587+
vdev_anyraid_t *var = pvd->vdev_tsd;
6588+
total = var->vd_children[vd->vdev_id]
6589+
->van_capacity;
6590+
} else {
6591+
continue;
6592+
}
6593+
vdev_prop_add_list(outnvl, propname,
6594+
NULL, total, ZPROP_SRC_NONE);
6595+
continue;
6596+
}
6597+
case VDEV_PROP_ANYRAID_NUM_TILES:
6598+
{
6599+
vdev_t *pvd = vd->vdev_parent;
6600+
uint64_t total = 0;
6601+
if (vd->vdev_ops == &vdev_anyraid_ops) {
6602+
vdev_anyraid_t *var = vd->vdev_tsd;
6603+
for (int i = 0; i < vd->vdev_children;
6604+
i++) {
6605+
total += var->vd_children[i]
6606+
->van_next_offset;
6607+
}
6608+
} else if (pvd && pvd->vdev_ops ==
6609+
&vdev_anyraid_ops) {
6610+
vdev_anyraid_t *var = pvd->vdev_tsd;
6611+
total = var->vd_children[vd->vdev_id]
6612+
->van_next_offset;
6613+
} else {
6614+
continue;
6615+
}
6616+
vdev_prop_add_list(outnvl, propname,
6617+
NULL, total, ZPROP_SRC_NONE);
6618+
continue;
6619+
}
6620+
case VDEV_PROP_ANYRAID_TILE_SIZE:
6621+
{
6622+
vdev_t *pvd = vd->vdev_parent;
6623+
vdev_anyraid_t *var = NULL;
6624+
if (vd->vdev_ops == &vdev_anyraid_ops) {
6625+
var = vd->vdev_tsd;
6626+
} else if (pvd && pvd->vdev_ops ==
6627+
&vdev_anyraid_ops) {
6628+
var = pvd->vdev_tsd;
6629+
} else {
6630+
continue;
6631+
}
6632+
vdev_prop_add_list(outnvl, propname,
6633+
NULL, var->vd_tile_size, ZPROP_SRC_NONE);
6634+
continue;
6635+
}
65746636
default:
65756637
err = ENOENT;
65766638
break;

0 commit comments

Comments
 (0)