Skip to content

Commit 8c62a0d

Browse files
Dan McDonaldbehlendorf
authored andcommitted
OpenZFS 6562 - Refquota on receive doesn't account for overage
Authored by: Dan McDonald <danmcd@omniti.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Gordon Ross <gwr@nexenta.com> Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/6562 OpenZFS-commit: openzfs/openzfs@5f7a8e6
1 parent 671c935 commit 8c62a0d

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

module/zfs/dsl_dataset.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Copyright (c) 2014 RackTop Systems.
2626
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
2727
* Copyright (c) 2016 Actifio, Inc. All rights reserved.
28+
* Copyright 2016, OmniTI Computer Consulting, Inc. All rights reserved.
2829
*/
2930

3031
#include <sys/dmu_objset.h>
@@ -78,6 +79,8 @@ int zfs_max_recordsize = 1 * 1024 * 1024;
7879

7980
extern inline dsl_dataset_phys_t *dsl_dataset_phys(dsl_dataset_t *ds);
8081

82+
extern int spa_asize_inflation;
83+
8184
/*
8285
* Figure out how much of this delta should be propogated to the dsl_dir
8386
* layer. If there's a refreservation, that space has already been
@@ -2810,6 +2813,11 @@ int
28102813
dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
28112814
dsl_dataset_t *origin_head, boolean_t force, void *owner, dmu_tx_t *tx)
28122815
{
2816+
/*
2817+
* "slack" factor for received datasets with refquota set on them.
2818+
* See the bottom of this function for details on its use.
2819+
*/
2820+
uint64_t refquota_slack = DMU_MAX_ACCESS * spa_asize_inflation;
28132821
int64_t unused_refres_delta;
28142822

28152823
/* they should both be heads */
@@ -2852,10 +2860,22 @@ dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
28522860
dsl_dir_space_available(origin_head->ds_dir, NULL, 0, TRUE))
28532861
return (SET_ERROR(ENOSPC));
28542862

2855-
/* clone can't be over the head's refquota */
2863+
/*
2864+
* The clone can't be too much over the head's refquota.
2865+
*
2866+
* To ensure that the entire refquota can be used, we allow one
2867+
* transaction to exceed the the refquota. Therefore, this check
2868+
* needs to also allow for the space referenced to be more than the
2869+
* refquota. The maximum amount of space that one transaction can use
2870+
* on disk is DMU_MAX_ACCESS * spa_asize_inflation. Allowing this
2871+
* overage ensures that we are able to receive a filesystem that
2872+
* exceeds the refquota on the source system.
2873+
*
2874+
* So that overage is the refquota_slack we use below.
2875+
*/
28562876
if (origin_head->ds_quota != 0 &&
28572877
dsl_dataset_phys(clone)->ds_referenced_bytes >
2858-
origin_head->ds_quota)
2878+
origin_head->ds_quota + refquota_slack)
28592879
return (SET_ERROR(EDQUOT));
28602880

28612881
return (0);
@@ -2870,8 +2890,13 @@ dsl_dataset_clone_swap_sync_impl(dsl_dataset_t *clone,
28702890
int64_t unused_refres_delta;
28712891

28722892
ASSERT(clone->ds_reserved == 0);
2893+
/*
2894+
* NOTE: On DEBUG kernels there could be a race between this and
2895+
* the check function if spa_asize_inflation is adjusted...
2896+
*/
28732897
ASSERT(origin_head->ds_quota == 0 ||
2874-
dsl_dataset_phys(clone)->ds_unique_bytes <= origin_head->ds_quota);
2898+
dsl_dataset_phys(clone)->ds_unique_bytes <= origin_head->ds_quota +
2899+
DMU_MAX_ACCESS * spa_asize_inflation);
28752900
ASSERT3P(clone->ds_prev, ==, origin_head->ds_prev);
28762901

28772902
/*

tests/runfiles/linux.run

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,11 @@ tests = []
148148
# DISABLED:
149149
# zfs_receive_004_neg - Fails for OpenZFS on illumos
150150
# zfs_receive_011_pos - Requires port of OpenZFS 6562
151-
# zfs_receive_012_pos - Requires port of OpenZFS 6562
152151
[tests/functional/cli_root/zfs_receive]
153152
tests = ['zfs_receive_001_pos', 'zfs_receive_002_pos', 'zfs_receive_003_pos',
154153
'zfs_receive_005_neg', 'zfs_receive_006_pos',
155154
'zfs_receive_007_neg', 'zfs_receive_008_pos', 'zfs_receive_009_neg',
156-
'zfs_receive_010_pos']
155+
'zfs_receive_010_pos', 'zfs_receive_012_pos']
157156

158157
# DISABLED:
159158
# zfs_rename_002_pos - needs investigation

0 commit comments

Comments
 (0)