Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stack overflow when destroying deeply nested clones
Destroy operations on deeply nested chains of clones can overflow the stack: Depth Size Location (221 entries) ----- ---- -------- 0) 15664 48 mutex_lock+0x5/0x30 1) 15616 8 mutex_lock+0x5/0x30 ... 26) 13576 72 dsl_dataset_remove_clones_key.isra.4+0x124/0x1e0 [zfs] 27) 13504 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs] 28) 13432 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs] ... 185) 2128 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs] 186) 2056 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs] 187) 1984 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs] 188) 1912 136 dsl_destroy_snapshot_sync_impl+0x4e0/0x1090 [zfs] 189) 1776 16 dsl_destroy_snapshot_check+0x0/0x90 [zfs] ... 218) 304 128 kthread+0xdf/0x100 219) 176 48 ret_from_fork+0x22/0x40 220) 128 128 kthread+0x0/0x100 Fix this issue by converting dsl_dataset_remove_clones_key() from recursive to iterative. Reviewed-by: Paul Zuchowski <pzuchowski@datto.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #7279 Closes #7810
- Loading branch information
1 parent
e8a8208
commit c434d88
Showing
4 changed files
with
126 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_deeply_nested.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/ksh -p | ||
# | ||
# CDDL HEADER START | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
# CDDL HEADER END | ||
# | ||
|
||
# | ||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# Deeply nested clones can be created and destroyed successfully | ||
# | ||
# STRATEGY: | ||
# 1. Create a deeply nested chain of clones | ||
# 2. Verify we can promote and destroy datasets in the chain without issues | ||
# NOTE: | ||
# Ported from scripts used to reproduce issue #3959 and #7279 | ||
# | ||
|
||
verify_runnable "both" | ||
|
||
function cleanup | ||
{ | ||
destroy_dataset "$clonesfs" "-rRf" | ||
} | ||
log_onexit cleanup | ||
|
||
log_assert "Deeply nested clones should be created and destroyed without issues" | ||
|
||
snapname='snap' | ||
snaprename='temporary-snap' | ||
clonesfs="$TESTPOOL/$TESTFS1" | ||
|
||
# NOTE: set mountpoint=none to avoid mount/umount calls and speed up the process | ||
log_must zfs create -o mountpoint=none $clonesfs | ||
log_must zfs create $clonesfs/0 | ||
dsname="$clonesfs/0@$snapname" | ||
log_must zfs snapshot $dsname | ||
|
||
# 1. Create a deeply nested chain of clones | ||
for c in {1..250}; do | ||
log_must zfs clone $dsname $clonesfs/$c | ||
dsname="$clonesfs/$c@$snapname" | ||
log_must zfs snapshot $dsname | ||
done | ||
|
||
# 2. Verify we can promote and destroy datasets in the chain without issues | ||
for c in {0..249}; do | ||
log_must zfs rename $clonesfs/$c@$snapname $clonesfs/$c@$snaprename | ||
log_must zfs promote $clonesfs/$((c+1)) | ||
log_must zfs destroy -r $clonesfs/$c | ||
log_must zfs destroy $clonesfs/$((c+1))@$snaprename | ||
done | ||
|
||
log_pass "Deeply nested clones can be created and destroyed successfully" |