Skip to content

Commit

Permalink
Merge pull request openzfs#19 from bgly/refcountoff
Browse files Browse the repository at this point in the history
ddt_unique_max
  • Loading branch information
Bryant G. Ly authored Dec 11, 2019
2 parents b42d33b + 74b98e8 commit 3df1baf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions man/man5/zfs-module-parameters.5
Original file line number Diff line number Diff line change
Expand Up @@ -2860,11 +2860,13 @@ Default value: \fB5\fR.
\fBzfs_unique_ddt_max\fR (ulong)
.ad
.RS 12n
Max unique refcount=1 entries in bytes. Default value is 128MB.
Max unique refcount=1 entries in bytes. Default value is 0, which is off.
The value needs to be 1024 bytes or higher, otherwise value will get
rejected and defaulted back to off.
.sp
This value can be changed dynamically.
.sp
Default value: \fB134217728\fR.
Default value: \fB0\fR.
.RE

.sp
Expand Down
8 changes: 4 additions & 4 deletions module/zfs/ddt.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int zfs_dedup_prefetch = 0;
* If more entries are added, old (randomly selected) entries will be evicted.
* Assuming each entry is 320bytes, 128MB/320 = 134217728/320 = 419430 entries
*/
#define DDT_UNIQUE_MAX_SIZE 134217728
#define DDT_UNIQUE_MAX_SIZE 0
unsigned long zfs_unique_ddt_max = DDT_UNIQUE_MAX_SIZE;

static const ddt_ops_t *ddt_ops[DDT_TYPES] = {
Expand Down Expand Up @@ -1210,9 +1210,9 @@ ddt_unique_max_size(void)
* altered them.
*/
size = zfs_unique_ddt_max;
if (size == 0) {
if (size < 1024) {
cmn_err(CE_NOTE, "Bad value for zfs_unique_ddt_max, value must "
"be greater than zero, resetting it to the default (%d)",
"be greater than 1024 bytes, resetting it to the default (%d)",
DDT_UNIQUE_MAX_SIZE);
size = zfs_unique_ddt_max = DDT_UNIQUE_MAX_SIZE;
}
Expand Down Expand Up @@ -1265,7 +1265,7 @@ ddt_sync_table(ddt_t *ddt, dmu_tx_t *tx, uint64_t txg)
* unique entries they want for their own data, depending on what kind
* of writes they are doing.
*/
if (ddt_object_exists(ddt, DDT_TYPE_CURRENT, DDT_CLASS_UNIQUE)) {
if (ddt_object_exists(ddt, DDT_TYPE_CURRENT, DDT_CLASS_UNIQUE) && (ddt_unique_max != 0)) {
uint64_t count = 0;
VERIFY(ddt_object_count(ddt, DDT_TYPE_CURRENT, DDT_CLASS_UNIQUE, &count) == 0);
for (int64_t i = 0; i < (int64_t)(count - ddt_unique_max); i++) {
Expand Down

0 comments on commit 3df1baf

Please sign in to comment.