Skip to content

Commit eee9362

Browse files
authored
Activate filesystem features only in syncing context
When activating filesystem features after receiving a snapshot, do so only in syncing context. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: George Amanakis <[email protected]> Closes #14304 Closes #14252
1 parent 6320b9e commit eee9362

File tree

6 files changed

+109
-17
lines changed

6 files changed

+109
-17
lines changed

module/zfs/dmu_objset.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,13 +2408,6 @@ dmu_objset_id_quota_upgrade_cb(objset_t *os)
24082408
dmu_objset_userobjspace_present(os))
24092409
return (SET_ERROR(ENOTSUP));
24102410

2411-
if (dmu_objset_userobjused_enabled(os))
2412-
dmu_objset_ds(os)->ds_feature_activation[
2413-
SPA_FEATURE_USEROBJ_ACCOUNTING] = (void *)B_TRUE;
2414-
if (dmu_objset_projectquota_enabled(os))
2415-
dmu_objset_ds(os)->ds_feature_activation[
2416-
SPA_FEATURE_PROJECT_QUOTA] = (void *)B_TRUE;
2417-
24182411
err = dmu_objset_space_upgrade(os);
24192412
if (err)
24202413
return (err);

module/zfs/dsl_dataset.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,16 +1761,20 @@ dsl_dataset_snapshot_sync_impl(dsl_dataset_t *ds, const char *snapname,
17611761

17621762
/*
17631763
* We are not allowed to dirty a filesystem when done receiving
1764-
* a snapshot. In this case the flag SPA_FEATURE_LARGE_BLOCKS will
1765-
* not be set and a subsequent encrypted raw send will fail. Hence
1766-
* activate this feature if needed here.
1764+
* a snapshot. In this case some flags such as SPA_FEATURE_LARGE_BLOCKS
1765+
* will not be set and a subsequent encrypted raw send will fail. Hence
1766+
* activate this feature if needed here. This needs to happen only in
1767+
* syncing context.
17671768
*/
1768-
for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
1769-
if (zfeature_active(f, ds->ds_feature_activation[f]) &&
1770-
!(zfeature_active(f, ds->ds_feature[f]))) {
1771-
dsl_dataset_activate_feature(dsobj, f,
1772-
ds->ds_feature_activation[f], tx);
1773-
ds->ds_feature[f] = ds->ds_feature_activation[f];
1769+
if (dmu_tx_is_syncing(tx)) {
1770+
for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
1771+
if (zfeature_active(f, ds->ds_feature_activation[f]) &&
1772+
!(zfeature_active(f, ds->ds_feature[f]))) {
1773+
dsl_dataset_activate_feature(dsobj, f,
1774+
ds->ds_feature_activation[f], tx);
1775+
ds->ds_feature[f] =
1776+
ds->ds_feature_activation[f];
1777+
}
17741778
}
17751779
}
17761780

tests/runfiles/common.run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ tests = ['recv_dedup', 'recv_dedup_encrypted_zvol', 'rsend_001_pos',
842842
'send-c_recv_lz4_disabled', 'send-c_mixed_compression',
843843
'send-c_stream_size_estimate', 'send-c_embedded_blocks', 'send-c_resume',
844844
'send-cpL_varied_recsize', 'send-c_recv_dedup', 'send-L_toggle',
845+
'send_encrypted_incremental.ksh',
845846
'send_encrypted_hierarchy', 'send_encrypted_props',
846847
'send_encrypted_truncated_files', 'send_freeobjects', 'send_realloc_files',
847848
'send_realloc_encrypted_files', 'send_spill_block', 'send_holds',

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
18061806
functional/rsend/send-c_zstreamdump.ksh \
18071807
functional/rsend/send-cpL_varied_recsize.ksh \
18081808
functional/rsend/send_doall.ksh \
1809+
functional/rsend/send_encrypted_incremental.ksh \
18091810
functional/rsend/send_encrypted_files.ksh \
18101811
functional/rsend/send_encrypted_hierarchy.ksh \
18111812
functional/rsend/send_encrypted_props.ksh \
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/ksh -p
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License (the "License").
7+
# You may not use this file except in compliance with the License.
8+
#
9+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10+
# or https://opensource.org/licenses/CDDL-1.0.
11+
# See the License for the specific language governing permissions
12+
# and limitations under the License.
13+
#
14+
# When distributing Covered Code, include this CDDL HEADER in each
15+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16+
# If applicable, add the following below this CDDL HEADER, with the
17+
# fields enclosed by brackets "[]" replaced with your own identifying
18+
# information: Portions Copyright [yyyy] [name of copyright owner]
19+
#
20+
# CDDL HEADER END
21+
#
22+
23+
. $STF_SUITE/include/libtest.shlib
24+
. $STF_SUITE/tests/functional/rsend/rsend.kshlib
25+
26+
#
27+
# Description:
28+
# Incrementally receiving a snapshot to an encrypted filesystem succeeds.
29+
#
30+
# Strategy:
31+
# 1) Create a pool and an encrypted fs
32+
# 2) Create some files and snapshots
33+
# 3) Send the first snapshot to a second encrypted as well as an
34+
# unencrypted fs.
35+
# 4) Incrementally send the second snapshot to the unencrypted fs.
36+
# 5) Rollback the second encrypted fs to the first snapshot.
37+
# 6) Incrementally send the second snapshot from the unencrypted to the
38+
# second encrypted fs.
39+
# 7) Incrementally send the third snapshot from the first encrypted to the
40+
# unencrypted fs.
41+
# 8) Incrementally send the third snapshot from the unencrypted to the second
42+
# encrypted fs.
43+
#
44+
45+
verify_runnable "both"
46+
47+
log_assert "Incrementally receiving a snapshot to an encrypted filesystem succeeds"
48+
49+
function cleanup
50+
{
51+
destroy_pool pool_lb
52+
log_must rm -f $TESTDIR/vdev_a
53+
}
54+
55+
log_onexit cleanup
56+
57+
typeset passphrase="password"
58+
typeset passphrase2="password2"
59+
60+
typeset file="/pool_lb/encryptme/$TESTFILE0"
61+
typeset file1="/pool_lb/encryptme/$TESTFILE1"
62+
typeset file2="/pool_lb/encryptme/$TESTFILE2"
63+
64+
# Create pool
65+
truncate -s $MINVDEVSIZE $TESTDIR/vdev_a
66+
log_must zpool create -f pool_lb $TESTDIR/vdev_a
67+
log_must eval "echo $passphrase > /pool_lb/pwd"
68+
log_must eval "echo $passphrase2 > /pool_lb/pwd2"
69+
70+
log_must zfs create -o encryption=on -o keyformat=passphrase \
71+
-o keylocation=file:///pool_lb/pwd pool_lb/encryptme
72+
log_must dd if=/dev/urandom of=$file bs=1024 count=1024
73+
log_must zfs snapshot pool_lb/encryptme@snap1
74+
log_must dd if=/dev/urandom of=$file1 bs=1024 count=1024
75+
log_must zfs snapshot pool_lb/encryptme@snap2
76+
log_must dd if=/dev/urandom of=$file2 bs=1024 count=1024
77+
log_must zfs snapshot pool_lb/encryptme@snap3
78+
log_must eval "zfs send -Lc pool_lb/encryptme@snap1 | zfs recv \
79+
-o encryption=on -o keyformat=passphrase -o keylocation=file:///pool_lb/pwd2 \
80+
pool_lb/encrypttwo"
81+
log_must eval "zfs send -Lc pool_lb/encryptme@snap1 | zfs recv \
82+
pool_lb/unencryptme"
83+
log_must eval "zfs send -Lc -i pool_lb/encryptme@{snap1,snap2} | zfs recv \
84+
pool_lb/unencryptme"
85+
log_must zfs rollback pool_lb/encrypttwo@snap1
86+
log_must eval "zfs send -Lc -i pool_lb/unencryptme@{snap1,snap2} | zfs recv \
87+
pool_lb/encrypttwo"
88+
log_must eval "zfs send -Lc -i pool_lb/encryptme@{snap2,snap3} | zfs recv \
89+
pool_lb/unencryptme"
90+
log_must eval "zfs send -Lc -i pool_lb/unencryptme@{snap2,snap3} | zfs recv \
91+
-F pool_lb/encrypttwo"
92+
93+
log_pass "Incrementally receiving a snapshot to an encrypted filesystem succeeds"

tests/zfs-tests/tests/functional/rsend/send_raw_large_blocks.ksh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ raw_backup=$TEST_BASE_DIR/raw_backup
4949
function cleanup
5050
{
5151
log_must rm -f $backup $raw_backup $ibackup $unc_backup
52-
destroy_pool pool_lb/fs
52+
destroy_pool pool_lb
5353
log_must rm -f $TESTDIR/vdev_a
5454
}
5555

0 commit comments

Comments
 (0)