Skip to content

Commit d75297d

Browse files
committed
Add option none to zfs redundant_metadata property
Currently, additional/extra copies are created for metadata in addition to the redundancy provided by the pool(mirror/raidz/draid), due to this 2 times more space is utilized per inode and this decreases the total number of inodes that can be created in the filesystem. By setting redundant_metadata to none, no additional copies of metadata are created, hence can reduce the space consumed by the additional metadata copies and increase the total number of inodes that can be created in the filesystem. Reviewed-by: Dipak Ghosh <dipak.ghosh@hpe.com> Signed-off-by: Akash B <akash-b@hpe.com>
1 parent f371cc1 commit d75297d

File tree

6 files changed

+26
-5
lines changed

6 files changed

+26
-5
lines changed

include/sys/dsl_prop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void dsl_prop_unregister_all(struct dsl_dataset *ds, void *cbarg);
7878
void dsl_prop_notify_all(struct dsl_dir *dd);
7979
boolean_t dsl_prop_hascb(struct dsl_dataset *ds);
8080

81+
void dsl_prop_validate(zfs_prop_t prop, uint64_t *val);
8182
int dsl_prop_get(const char *ddname, const char *propname,
8283
int intsz, int numints, void *buf, char *setpoint);
8384
int dsl_prop_get_integer(const char *ddname, const char *propname,

include/sys/fs/zfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ typedef enum {
500500

501501
typedef enum {
502502
ZFS_REDUNDANT_METADATA_ALL,
503-
ZFS_REDUNDANT_METADATA_MOST
503+
ZFS_REDUNDANT_METADATA_MOST,
504+
ZFS_REDUNDANT_METADATA_NONE
504505
} zfs_redundant_metadata_type_t;
505506

506507
typedef enum {

man/man7/zfsprops.7

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
.\" Copyright 2019 Joyent, Inc.
3838
.\" Copyright (c) 2019, Kjeld Schouten-Lebbing
3939
.\"
40-
.Dd May 24, 2021
40+
.Dd July 21, 2022
4141
.Dt ZFSPROPS 7
4242
.Os
4343
.
@@ -1444,7 +1444,7 @@ affects only files created afterward; existing files are unaffected.
14441444
.Pp
14451445
This property can also be referred to by its shortened column name,
14461446
.Sy recsize .
1447-
.It Sy redundant_metadata Ns = Ns Sy all Ns | Ns Sy most
1447+
.It Sy redundant_metadata Ns = Ns Sy all Ns | Ns Sy most Ns | Ns Sy none
14481448
Controls what types of metadata are stored redundantly.
14491449
ZFS stores an extra copy of metadata, so that if a single block is corrupted,
14501450
the amount of user data lost is limited.
@@ -1485,6 +1485,10 @@ of user data can be lost if a single on-disk block is corrupt.
14851485
The exact behavior of which metadata blocks are stored redundantly may change in
14861486
future releases.
14871487
.Pp
1488+
When set to
1489+
.Sy none ,
1490+
ZFS does not store any copies of metadata redundantly through this property.
1491+
.Pp
14881492
The default value is
14891493
.Sy all .
14901494
.It Sy refquota Ns = Ns Ar size Ns | Ns Sy none

module/zcommon/zfs_prop.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ zfs_prop_init(void)
369369
static const zprop_index_t redundant_metadata_table[] = {
370370
{ "all", ZFS_REDUNDANT_METADATA_ALL },
371371
{ "most", ZFS_REDUNDANT_METADATA_MOST },
372+
{ "none", ZFS_REDUNDANT_METADATA_NONE },
372373
{ NULL }
373374
};
374375

@@ -388,7 +389,7 @@ zfs_prop_init(void)
388389
zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
389390
ZFS_REDUNDANT_METADATA_ALL,
390391
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
391-
"all | most", "REDUND_MD",
392+
"all | most | none", "REDUND_MD",
392393
redundant_metadata_table, sfeatures);
393394
zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
394395
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,

module/zfs/dmu_objset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ redundant_metadata_changed_cb(void *arg, uint64_t newval)
287287
* Inheritance and range checking should have been done by now.
288288
*/
289289
ASSERT(newval == ZFS_REDUNDANT_METADATA_ALL ||
290-
newval == ZFS_REDUNDANT_METADATA_MOST);
290+
newval == ZFS_REDUNDANT_METADATA_MOST ||
291+
newval == ZFS_REDUNDANT_METADATA_NONE);
291292

292293
os->os_redundant_metadata = newval;
293294
}

module/zfs/dsl_prop.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ dsl_prop_get_ds(dsl_dataset_t *ds, const char *propname,
219219
intsz, numints, buf, setpoint, ds->ds_is_snapshot));
220220
}
221221

222+
void
223+
dsl_prop_validate(zfs_prop_t prop, uint64_t *val)
224+
{
225+
const char *str;
226+
int err;
227+
if (zfs_prop_get_type(prop) == PROP_TYPE_INDEX) {
228+
err = zfs_prop_index_to_string(prop, *val, &str);
229+
if (err != 0 )
230+
*val = zfs_prop_default_numeric(prop);
231+
}
232+
}
233+
222234
static dsl_prop_record_t *
223235
dsl_prop_record_find(dsl_dir_t *dd, const char *propname)
224236
{
@@ -292,6 +304,7 @@ dsl_prop_register(dsl_dataset_t *ds, const char *propname,
292304
ASSERT(dsl_pool_config_held(dp));
293305

294306
err = dsl_prop_get_int_ds(ds, propname, &value);
307+
(void) dsl_prop_validate(zfs_name_to_prop(propname), &value);
295308
if (err != 0)
296309
return (err);
297310

0 commit comments

Comments
 (0)