HomeFreeBSD

Stack overflow when destroying deeply nested clones

Description

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

...

  1. 13576 72 dsl_dataset_remove_clones_key.isra.4+0x124/0x1e0 [zfs]
  2. 13504 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs]
  3. 13432 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs]

...

  1. 2128 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs]
  2. 2056 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs]
  3. 1984 72 dsl_dataset_remove_clones_key.isra.4+0x18a/0x1e0 [zfs]
  4. 1912 136 dsl_destroy_snapshot_sync_impl+0x4e0/0x1090 [zfs]
  5. 1776 16 dsl_destroy_snapshot_check+0x0/0x90 [zfs]

...

  1. 304 128 kthread+0xdf/0x100
  2. 176 48 ret_from_fork+0x22/0x40
  3. 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

Details

Provenance
LOLi <loli10K@users.noreply.github.com>Authored on Aug 22 2018, 6:03 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Aug 22 2018, 6:03 PM
Parents
rGe8a8208eef3f: Added metadata/dnode cache info to arc_summary
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rGc434d8806cfd: Stack overflow when destroying deeply nested clones (authored by LOLi <loli10K@users.noreply.github.com>).Aug 22 2018, 6:03 PM