Skip to content

Commit 00234aa

Browse files
author
Paul Dagnelie
committed
Tony's feedback
Signed-off-by: Paul Dagnelie <[email protected]>
1 parent 6c76de0 commit 00234aa

File tree

69 files changed

+411
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+411
-202
lines changed

cmd/zdb/zdb.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9394,7 +9394,7 @@ zdb_print_anyraid_tile_layout(vdev_t *vd)
93949394
// Create and populate table with all the values we need to print.
93959395
char ***table = malloc(sizeof (*table) * cols);
93969396
for (int i = 0; i < cols; i++) {
9397-
table[i] = calloc(var->vd_children[i]->van_capacity,
9397+
table[i] = calloc(var->vd_children[i]->van_capacity + 1,
93989398
sizeof (**table));
93999399
}
94009400

@@ -9440,7 +9440,7 @@ zdb_print_anyraid_tile_layout(vdev_t *vd)
94409440
for (int v = 0; v < cols; v++) {
94419441
if (final[v]) {
94429442
ASSERT3U(i, >=,
9443-
var->vd_children[v]->van_capacity);
9443+
var->vd_children[v]->van_capacity + 1);
94449444
int extra_width = 0;
94459445
if (v == 0 || !printed[v - 1])
94469446
extra_width++;
@@ -9449,7 +9449,7 @@ zdb_print_anyraid_tile_layout(vdev_t *vd)
94499449
printed[v] = B_FALSE;
94509450
continue;
94519451
}
9452-
if (i + 1 == var->vd_children[v]->van_capacity)
9452+
if (i + 1 == var->vd_children[v]->van_capacity + 1)
94539453
final[v] = B_TRUE;
94549454
if (v - 1 != last_printed)
94559455
(void) printf("│");
@@ -9466,7 +9466,7 @@ zdb_print_anyraid_tile_layout(vdev_t *vd)
94669466
}
94679467
(void) printf("\n");
94689468
for (int i = 0; i < cols; i++) {
9469-
for (int j = 0; j < var->vd_children[i]->van_capacity; j++)
9469+
for (int j = 0; j < var->vd_children[i]->van_capacity + 1; j++)
94709470
if (table[i][j])
94719471
free(table[i][j]);
94729472
free(table[i]);
@@ -9539,7 +9539,7 @@ print_anyraid_mapping(vdev_t *vd, int child, int mapping,
95399539
&disk_id) != 0)
95409540
(void) printf("No valid disk ID\n");
95419541

9542-
(void) printf("version: %6d\ttile size: %8lx\ttxg: %lu\n",
9542+
(void) printf("version: %6d\ttile size: %#8lx\ttxg: %lu\n",
95439543
version, tile_size, written_txg);
95449544
(void) printf("map length: %6u\tdisk id: %3u\n", map_length, disk_id);
95459545

@@ -9722,12 +9722,18 @@ zdb_dump_anyraid_map_vdev(vdev_t *vd, int verbosity)
97229722
ASSERT3P(vd->vdev_ops, ==, &vdev_anyraid_ops);
97239723
vdev_anyraid_t *var = vd->vdev_tsd;
97249724

9725-
(void) printf("\t%-5s%11llu %s %16llx\n",
9725+
(void) printf("\t%-5s%11llu %s %#16llx\n",
97269726
"vdev", (u_longlong_t)vd->vdev_id,
97279727
"tile_size", (u_longlong_t)var->vd_tile_size);
9728-
(void) printf("\t%-8s%8llu %-12s %10u\n", "tiles",
9729-
(u_longlong_t)avl_numnodes(&var->vd_tile_map),
9730-
"checkpoint tile", var->vd_checkpoint_tile);
9728+
(void) printf("\t%-8s%8llu", "tiles",
9729+
(u_longlong_t)avl_numnodes(&var->vd_tile_map));
9730+
if (var->vd_checkpoint_tile != UINT32_MAX) {
9731+
(void) printf(". %-12s %10u\n", "checkpoint tile",
9732+
var->vd_checkpoint_tile);
9733+
} else {
9734+
(void) printf("\n");
9735+
}
9736+
97319737
(void) printf("\t%16s %12s %13s\n", "----------------",
97329738
"------------", "-------------");
97339739

@@ -9759,23 +9765,26 @@ zdb_dump_anyraid_map(char *vdev_str, spa_t *spa, int verbosity)
97599765
{
97609766
vdev_t *rvd, *vd;
97619767

9762-
(void) printf("\nAnyRAID tiles:\n");
9763-
97649768
/* A specific vdev. */
97659769
if (vdev_str != NULL) {
97669770
vd = zdb_vdev_lookup(spa->spa_root_vdev, vdev_str);
97679771
if (vd == NULL) {
97689772
(void) printf("Invalid vdev: %s\n", vdev_str);
97699773
return (EINVAL);
97709774
}
9771-
if (vd->vdev_ops != &vdev_anyraid_ops) {
9775+
if (vd->vdev_ops != &vdev_anyraid_ops &&
9776+
(vd->vdev_parent == NULL ||
9777+
(vd = vd->vdev_parent)->vdev_ops != &vdev_anyraid_ops)) {
97729778
(void) printf("Not an anyraid vdev: %s\n", vdev_str);
97739779
return (EINVAL);
97749780
}
9781+
9782+
(void) printf("\nAnyRAID tiles:\n");
97759783
zdb_dump_anyraid_map_vdev(vd, verbosity);
97769784
return (0);
97779785
}
97789786

9787+
(void) printf("\nAnyRAID tiles:\n");
97799788
/* All anyraid vdevs. */
97809789
rvd = spa->spa_root_vdev;
97819790
for (uint64_t c = 0; c < rvd->vdev_children; c++) {

cmd/zpool/zpool_vdev.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ is_raidz_mirror(replication_level_t *a, replication_level_t *b,
459459
if ((strcmp(a->zprl_type, "raidz") == 0 ||
460460
strcmp(a->zprl_type, "draid") == 0) &&
461461
(strcmp(b->zprl_type, "mirror") == 0 ||
462-
strcmp(b->zprl_type, "anyraid") == 0)) {
462+
strcmp(b->zprl_type, "anymirror") == 0)) {
463463
*raidz = a;
464464
*mirror = b;
465465
return (B_TRUE);
@@ -555,11 +555,11 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
555555
rep.zprl_children = 0;
556556

557557
if (strcmp(type, VDEV_TYPE_RAIDZ) == 0 ||
558-
strcmp(type, VDEV_TYPE_DRAID) == 0) {
558+
strcmp(type, VDEV_TYPE_DRAID) == 0 ||
559+
strcmp(type, VDEV_TYPE_ANYRAID) == 0) {
559560
verify(nvlist_lookup_uint64(nv,
560561
ZPOOL_CONFIG_NPARITY,
561562
&rep.zprl_parity) == 0);
562-
assert(rep.zprl_parity != 0);
563563
} else {
564564
rep.zprl_parity = 0;
565565
}
@@ -771,7 +771,9 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
771771
rep.zprl_type);
772772
else
773773
return (NULL);
774-
} else if (lastrep.zprl_children != rep.zprl_children) {
774+
} else if (lastrep.zprl_children !=
775+
rep.zprl_children && strcmp(rep.zprl_type,
776+
VDEV_TYPE_ANYRAID) != 0) {
775777
if (ret)
776778
free(ret);
777779
ret = NULL;
@@ -1258,7 +1260,7 @@ get_parity(const char *type)
12581260
parity = strtol(p, &end, 10);
12591261
if (errno != 0 || *end != '\0' ||
12601262
parity < 0 || parity > VDEV_ANYRAID_MAXPARITY) {
1261-
return (0);
1263+
return (-1);
12621264
}
12631265
}
12641266
} else if (strncmp(type, VDEV_TYPE_DRAID,
@@ -1320,6 +1322,8 @@ is_grouping(const char *type, int *mindev, int *maxdev)
13201322

13211323
if (strncmp(type, VDEV_TYPE_ANYRAID, strlen(VDEV_TYPE_ANYRAID)) == 0) {
13221324
nparity = get_parity(type);
1325+
if (nparity < 0)
1326+
return (NULL);
13231327
if (mindev != NULL)
13241328
*mindev = nparity + 1;
13251329
if (maxdev != NULL)

cmd/ztest.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ typedef struct ztest_shared_opts {
189189
int zo_raid_do_expand;
190190
int zo_raid_children;
191191
int zo_raid_parity;
192-
char zo_raid_type[8];
192+
char zo_raid_type[16];
193193
int zo_draid_data;
194194
int zo_draid_spares;
195195
int zo_datasets;
@@ -773,7 +773,7 @@ static ztest_option_t option_table[] = {
773773
DEFAULT_RAID_CHILDREN, NULL},
774774
{ 'R', "raid-parity", "INTEGER", "Raid parity",
775775
DEFAULT_RAID_PARITY, NULL},
776-
{ 'K', "raid-kind", "raidz|eraidz|draid|anyraid|random", "Raid kind",
776+
{ 'K', "raid-kind", "raidz|eraidz|draid|anymirror|random", "Raid kind",
777777
NO_DEFAULT, "random"},
778778
{ 'D', "draid-data", "INTEGER", "Number of draid data drives",
779779
DEFAULT_DRAID_DATA, NULL},
@@ -1134,7 +1134,7 @@ process_options(int argc, char **argv)
11341134
raid_kind = "draid";
11351135
break;
11361136
case 3:
1137-
raid_kind = "anyraid";
1137+
raid_kind = "anymirror";
11381138
break;
11391139
}
11401140

@@ -1190,7 +1190,7 @@ process_options(int argc, char **argv)
11901190
} else if (strcmp(raid_kind, "raidz") == 0) {
11911191
zo->zo_raid_parity = MIN(zo->zo_raid_parity,
11921192
zo->zo_raid_children - 1);
1193-
} else if (strcmp(raid_kind, "anyraid") == 0) {
1193+
} else if (strcmp(raid_kind, "anymirror") == 0) {
11941194
uint64_t min_devsize;
11951195

11961196
/* With fewer disks use 1G, otherwise 512M is OK */
@@ -3814,7 +3814,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
38143814
if (ztest_opts.zo_raid_children > 1) {
38153815
if (strcmp(oldvd->vdev_ops->vdev_op_type, "raidz") == 0)
38163816
ASSERT3P(oldvd->vdev_ops, ==, &vdev_raidz_ops);
3817-
else if (strcmp(oldvd->vdev_ops->vdev_op_type, "anyraid") == 0)
3817+
else if (strcmp(oldvd->vdev_ops->vdev_op_type, "anymirror") ==
3818+
0)
38183819
ASSERT3P(oldvd->vdev_ops, ==, &vdev_anyraid_ops);
38193820
else
38203821
ASSERT3P(oldvd->vdev_ops, ==, &vdev_draid_ops);
@@ -3838,11 +3839,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
38383839
}
38393840

38403841
oldguid = oldvd->vdev_guid;
3841-
if (oldvd->vdev_ops != &vdev_anyraid_ops)
3842-
oldsize = vdev_get_min_asize(oldvd);
3843-
else
3844-
oldsize = oldvd->vdev_child[
3845-
ztest_random(oldvd->vdev_children)]->vdev_asize;
3842+
oldsize = vdev_get_min_attach_size(oldvd);
38463843
oldvd_is_log = oldvd->vdev_top->vdev_islog;
38473844
oldvd_is_special =
38483845
oldvd->vdev_top->vdev_alloc_bias == VDEV_BIAS_SPECIAL ||

include/sys/fs/zfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ typedef struct zpool_load_policy {
916916
#define VDEV_TYPE_MIRROR "mirror"
917917
#define VDEV_TYPE_REPLACING "replacing"
918918
#define VDEV_TYPE_RAIDZ "raidz"
919-
#define VDEV_TYPE_ANYRAID "anyraid"
919+
#define VDEV_TYPE_ANYRAID "anymirror"
920920
#define VDEV_TYPE_DRAID "draid"
921921
#define VDEV_TYPE_DRAID_SPARE "dspare"
922922
#define VDEV_TYPE_DISK "disk"

include/sys/vdev_anyraid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ typedef struct vdev_anyraid_node {
4444
avl_node_t van_node;
4545
uint8_t van_id;
4646
uint16_t van_next_offset;
47+
// Note: store capacity - 1 for rollover reasons
4748
uint16_t van_capacity;
4849
} vdev_anyraid_node_t;
4950

@@ -275,7 +276,6 @@ _Static_assert(VDEV_ANYRAID_MAP_SIZE % SPA_MAXBLOCKSIZE == 0, "");
275276
void vdev_anyraid_write_map_sync(vdev_t *vd, zio_t *pio, uint64_t txg,
276277
uint64_t *good_writes, int flags, vdev_config_sync_status_t status);
277278

278-
uint64_t vdev_anyraid_min_newsize(vdev_t *vd, uint64_t ashift);
279279
void vdev_anyraid_expand(vdev_t *tvd, vdev_t *newvd);
280280
boolean_t vdev_anyraid_mapped(vdev_t *vd, uint64_t offset);
281281

include/sys/vdev_impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size,
7171
typedef void vdev_close_func_t(vdev_t *vd);
7272
typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize, uint64_t txg);
7373
typedef uint64_t vdev_min_asize_func_t(vdev_t *pvd, vdev_t *cvd);
74+
typedef uint64_t vdev_min_attach_size_func_t(vdev_t *vd);
7475
typedef uint64_t vdev_min_alloc_func_t(vdev_t *vd);
7576
typedef void vdev_io_start_func_t(zio_t *zio);
7677
typedef void vdev_io_done_func_t(zio_t *zio);
@@ -107,6 +108,7 @@ typedef const struct vdev_ops {
107108
vdev_asize_func_t *vdev_op_psize_to_asize;
108109
vdev_asize_func_t *vdev_op_asize_to_psize;
109110
vdev_min_asize_func_t *vdev_op_min_asize;
111+
vdev_min_attach_size_func_t *vdev_op_min_attach_size;
110112
vdev_min_alloc_func_t *vdev_op_min_alloc;
111113
vdev_io_start_func_t *vdev_op_io_start;
112114
vdev_io_done_func_t *vdev_op_io_done;
@@ -630,7 +632,9 @@ extern void vdev_default_xlate(vdev_t *vd, const zfs_range_seg64_t *logical_rs,
630632
extern uint64_t vdev_default_psize(vdev_t *vd, uint64_t asize, uint64_t txg);
631633
extern uint64_t vdev_default_asize(vdev_t *vd, uint64_t psize, uint64_t txg);
632634
extern uint64_t vdev_default_min_asize(vdev_t *pvd, vdev_t *cvd);
635+
extern uint64_t vdev_default_min_attach_size(vdev_t *vd);
633636
extern uint64_t vdev_get_min_asize(vdev_t *vd);
637+
extern uint64_t vdev_get_min_attach_size(vdev_t *vd);
634638
extern void vdev_set_min_asize(vdev_t *vd);
635639
extern uint64_t vdev_get_nparity(vdev_t *vd);
636640
extern uint64_t vdev_get_ndisks(vdev_t *vd);

lib/libzfs/libzfs_pool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,8 @@ zpool_name_valid(libzfs_handle_t *hdl, boolean_t isopen, const char *pool)
12231223
strncmp(pool, "raidz", 5) == 0 ||
12241224
strncmp(pool, "draid", 5) == 0 ||
12251225
strncmp(pool, "spare", 5) == 0 ||
1226-
strcmp(pool, "log") == 0)) {
1226+
strcmp(pool, "log") == 0 ||
1227+
strncmp(pool, "anymirror", 9) == 0)) {
12271228
if (hdl != NULL)
12281229
zfs_error_aux(hdl,
12291230
dgettext(TEXT_DOMAIN, "name is reserved"));

man/man4/zfs.4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,15 @@ Logical ashift for file-based devices.
655655
.It Sy vdev_file_physical_ashift Ns = Ns Sy 9 Po 512 B Pc Pq u64
656656
Physical ashift for file-based devices.
657657
.
658+
.It Sy zfs_anyraid_min_tile_size Ns = Ns Sy 16 GiB Pq u64
659+
Minimum size of the tiles that anyraid will use to do its mapping.
660+
Smaller tile sizes let data be spread more evenly across devices, and makes
661+
smaller devices use more of their capacity.
662+
Larger tile sizes allow for larger disks to be used in the future, since a given
663+
device can only store 16384 tiles.
664+
The minimum valid tile size is 16MiB, since a metaslab always needs to be able
665+
to fit in a single tile.
666+
.
658667
.It Sy zap_iterate_prefetch Ns = Ns Sy 1 Ns | Ns 0 Pq int
659668
If set, when we start iterating over a ZAP object,
660669
prefetch the entire object (all leaf blocks).

man/man7/vdevprops.7

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,21 @@ If this device should perform new allocations, used to disable a device
188188
when it is scheduled for later removal.
189189
See
190190
.Xr zpool-remove 8 .
191+
.It anyraid_tile_capacity
192+
Only valid for
193+
.Sy AnyRAID
194+
vdevs and their leaf vdevs.
195+
The number of physical tiles that the vdev can hold.
196+
.It anyraid_tile_count
197+
Only valid for
198+
.Sy AnyRAID
199+
vdevs and their leaf vdevs.
200+
The number of physical tiles that are currently allocated on the vdev.
201+
.It anyraid_tile_size
202+
Only valid for
203+
.Sy AnyRAID
204+
vdevs and their leaf vdevs.
205+
The size of the tiles in use on this vdev.
191206
.El
192207
.Ss User Properties
193208
In addition to the standard native properties, ZFS supports arbitrary user

man/man7/zpoolconcepts.7

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ An error is returned when the provided number of children differs.
165165
The number of distributed hot spares.
166166
Defaults to zero.
167167
.El
168-
.It Sy anyraid , anyraid0 , anyraid1 , anyraid2
168+
.It Sy anymirror , anymirror0 , anymirror1 , anymirror2
169169
A new device type that allows for mirror-parity redundancy while using devices
170170
of different sizes.
171171
An AnyRAID vdev works by dividing each of the underlying disks that make it up
@@ -177,13 +177,17 @@ disks, while enabling maximum space usage by allocating more tiles from the
177177
disks with the most free space.
178178
In addition, the device can be expanded by attaching new disks, and new tiles
179179
will be allocated from those disks.
180-
.Sy anyraid
180+
The vdev class as a whole is referred to as AnyRAID; anymirror vdevs
181+
specifically use mirror-style parity.
182+
Future work will also add anyraidz, which will use the same basic tile
183+
architecture, but use raidz-style parity.
184+
.Sy anymirror
181185
is a synonym for
182-
.Sy anyraid1
186+
.Sy anymirror1
183187
, which is the 2-way mirror parity version (1 parity tile).
184-
.Sy anyraid2
188+
.Sy anymirror2
185189
is a 3-way mirror (2 parity tiles), while
186-
.Sy anyraid0
190+
.Sy anymirror0
187191
is striped (no parity tiles), and is primarily intended for testing.
188192
.It Sy spare
189193
A pseudo-vdev which keeps track of available hot spares for a pool.

0 commit comments

Comments
 (0)