Skip to content

Commit 945b407

Browse files
authored
quota: disable quota check for ZVOL
The quota for ZVOLs is set to the size of the volume. When the quota reaches the maximum, there isn't an excellent way to check if the new writers are overwriting the data or if they are inserting a new one. Because of that, when we reach the maximum quota, we wait till txg is flushed. This is causing a significant fluctuation in bandwidth. In the case of ZVOL, the quota is enforced by the volsize, so we can omit it. This commit adds a sysctl thats allow to control if the quota mechanism should be enforced or not. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> Sponsored-by: Zededa Inc. Sponsored-by: Klara Inc. Closes #13838
1 parent e197bb2 commit 945b407

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

man/man4/zfs.4

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
.\" own identifying information:
1616
.\" Portions Copyright [yyyy] [name of copyright owner]
1717
.\"
18-
.Dd June 1, 2021
18+
.Dd November 7, 2022
1919
.Dt ZFS 4
2020
.Os
2121
.
@@ -2386,6 +2386,10 @@ Defines zvol block devices behaviour when
23862386
.It Sy 3
23872387
.No equivalent to Sy none
23882388
.El
2389+
.
2390+
.It Sy zvol_enforce_quotas Ns = Ns Sy 0 Ns | Ns 1 Pq uint
2391+
Enable strict ZVOL quota enforcement.
2392+
The strict quota enforcement may have a performance impact.
23892393
.El
23902394
.
23912395
.Sh ZFS I/O SCHEDULER

module/zfs/dsl_dir.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
#include "zfs_namecheck.h"
5454
#include "zfs_prop.h"
5555

56+
/*
57+
* This controls if we verify the ZVOL quota or not.
58+
* Currently, quotas are not implemented for ZVOLs.
59+
* The quota size is the size of the ZVOL.
60+
* The size of the volume already implies the ZVOL size quota.
61+
* The quota mechanism can introduce a significant performance drop.
62+
*/
63+
static int zvol_enforce_quotas = B_TRUE;
64+
5665
/*
5766
* Filesystem and Snapshot Limits
5867
* ------------------------------
@@ -1311,7 +1320,9 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
13111320
* If this transaction will result in a net free of space,
13121321
* we want to let it through.
13131322
*/
1314-
if (ignorequota || netfree || dsl_dir_phys(dd)->dd_quota == 0)
1323+
if (ignorequota || netfree || dsl_dir_phys(dd)->dd_quota == 0 ||
1324+
(dmu_objset_type(tx->tx_objset) == DMU_OST_ZVOL &&
1325+
zvol_enforce_quotas == B_FALSE))
13151326
quota = UINT64_MAX;
13161327
else
13171328
quota = dsl_dir_phys(dd)->dd_quota;
@@ -1399,10 +1410,9 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
13991410
ignorequota = (dsl_dir_phys(dd)->dd_head_dataset_obj == 0);
14001411
first = B_FALSE;
14011412
goto top_of_function;
1402-
1403-
} else {
1404-
return (0);
14051413
}
1414+
1415+
return (0);
14061416
}
14071417

14081418
/*
@@ -2483,3 +2493,7 @@ dsl_dir_cancel_waiters(dsl_dir_t *dd)
24832493
EXPORT_SYMBOL(dsl_dir_set_quota);
24842494
EXPORT_SYMBOL(dsl_dir_set_reservation);
24852495
#endif
2496+
2497+
/* CSTYLED */
2498+
ZFS_MODULE_PARAM(zfs, , zvol_enforce_quotas, INT, ZMOD_RW,
2499+
"Enable strict ZVOL quota enforcment");

0 commit comments

Comments
 (0)