Print this page
8520 lzc_rollback_to should support rolling back to origin
7198 libzfs should gracefully handle EINVAL from lzc_rollback
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
NEX-9673 Add capability to replicate cloned datasets relative to origin
Reviewed by: Alex Deiter <alex.deiter@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-13340 Continuous replication service may fail if a user removes nested datasets
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-3562 filename normalization doesn't work for removes (sync with upstream)
NEX-9406 Add a property to show that a dataset has been modified since a snapshot
Reviewed by: Alexey Komarov <alexey.komarov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Revert "NEX-7251 Resume_token is not cleared right after finishing receive"
This reverts commit 9e97a45e8cf6ca59307a39e2d3c11c6e845e4187.
NEX-7251 Resume_token is not cleared right after finishing receive
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Alexey Komarov <alexey.komarov@nexenta.com>
NEX-6815 KRRP: 'sess-send-stop' hangs forever if the sources pool does not have free space
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
NEX-5366 Race between unique_insert() and unique_remove() causes ZFS fsid change
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Dan Vatca <dan.vatca@gmail.com>
NEX-5795 Rename 'wrc' as 'wbc' in the source and in the tech docs
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
NEX-5272 KRRP: replicate snapshot properties
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Alexey Komarov <alexey.komarov@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
6328 Fix cstyle errors in zfs codebase (fix studio)
6328 Fix cstyle errors in zfs codebase
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Jorgen Lundman <lundman@lundman.net>
Approved by: Robert Mustacchi <rm@joyent.com>
2605 want to resume interrupted zfs send
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Xin Li <delphij@freebsd.org>
Reviewed by: Arne Jansen <sensille@gmx.net>
Approved by: Dan McDonald <danmcd@omniti.com>
6160 /usr/lib/fs/zfs/bootinstall should use bootadm
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Adam Števko <adam.stevko@gmail.com>
Reviewed by: Josef Sipek <jeffpc@josefsipek.net>
Approved by: Richard Lowe <richlowe@richlowe.net>
4185 add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R (NULL is not an int)
6171 dsl_prop_unregister() slows down dataset eviction.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
4185 add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R (fix studio build)
4185 add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Garrett D'Amore <garrett@damore.org>
6047 SPARC boot should support feature@embedded_data
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>
5959 clean up per-dataset feature count code
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Alex Reece <alex@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
NEX-4582 update wrc test cases for allow to use write back cache per tree of datasets
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
5960 zfs recv should prefetch indirect blocks
5925 zfs receive -o origin=
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
5909 ensure that shared snap names don't become too long after promotion
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
5393 spurious failures from dsl_dataset_hold_obj()
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Will Andrews <willa@spectralogic.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Steven Hartland <killing@multiplay.co.uk>
Approved by: Dan McDonald <danmcd@omniti.com>
NEX-4476 WRC: Allow to use write back cache per tree of datasets
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
Revert "NEX-4476 WRC: Allow to use write back cache per tree of datasets"
This reverts commit fe97b74444278a6f36fec93179133641296312da.
NEX-4476 WRC: Allow to use write back cache per tree of datasets
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
NEX-3964 It should not be allowed to rename a snapshot that its new name is matched to the prefix of in-kernel autosnapshots
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
NEX-3669 Faults for fans that don't exist
Reviewed by: Jeffry Molanus <jeffry.molanus@nexenta.com>
NEX-3891 Hide the snapshots that belong to in-kernel autosnap-service
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Alek Pinchuk <alek@nexenta.com>
NEX-3329 libnsl: set_up_connection() over TCP does not adhere the specified timeout
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-3521 CLONE - Port NEX-3209 normalization=formD and casesensitivity=mixed behaves improperly, squashing case
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-3558 KRRP Integration
4370 avoid transmitting holes during zfs send
4371 DMU code clean up
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Garrett D'Amore <garrett@damore.org>
re #13318 rb4428 kernel panic during failover with autosync running on the active node
re #12619 rb4429 More dp->dp_config_rwlock holds
re #8279 rb3915 need a mechanism to notify NMS about ZFS config changes (fix lint -courtesy of Yuri Pankov)
re #12584 rb4049 zfsxx latest code merge (fix lint - courtesy of Yuri Pankov)
re #12585 rb4049 ZFS++ work port - refactoring to improve separation of open/closed code, bug fixes, performance improvements - open code
re 12063 rb 3793 Panic on zpool destroy
Bug 11205: add missing libzfs_closed_stubs.c to fix opensource-only build.
ZFS plus work: special vdevs, cos, cos/vdev properties

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dsl_dataset.c
          +++ new/usr/src/uts/common/fs/zfs/dsl_dataset.c
↓ open down ↓ 38 lines elided ↑ open up ↑
  39   39  #include <sys/dmu_impl.h>
  40   40  #include <sys/dmu_tx.h>
  41   41  #include <sys/arc.h>
  42   42  #include <sys/zio.h>
  43   43  #include <sys/zap.h>
  44   44  #include <sys/zfeature.h>
  45   45  #include <sys/unique.h>
  46   46  #include <sys/zfs_context.h>
  47   47  #include <sys/zfs_ioctl.h>
  48   48  #include <sys/spa.h>
  49      -#include <sys/vdev.h>
       49 +#include <sys/spa_impl.h>
  50   50  #include <sys/zfs_znode.h>
  51   51  #include <sys/zfs_onexit.h>
  52   52  #include <sys/zvol.h>
  53   53  #include <sys/dsl_scan.h>
  54   54  #include <sys/dsl_deadlist.h>
  55   55  #include <sys/dsl_destroy.h>
  56   56  #include <sys/dsl_userhold.h>
  57   57  #include <sys/dsl_bookmark.h>
       58 +#include <sys/autosnap.h>
  58   59  #include <sys/dmu_send.h>
  59   60  #include <sys/zio_checksum.h>
  60   61  #include <sys/zio_compress.h>
  61   62  #include <zfs_fletcher.h>
  62   63  
  63   64  /*
  64   65   * The SPA supports block sizes up to 16MB.  However, very large blocks
  65   66   * can have an impact on i/o latency (e.g. tying up a spinning disk for
  66   67   * ~300ms), and also potentially on the memory allocator.  Therefore,
  67   68   * we do not allow the recordsize to be set larger than zfs_max_recordsize
↓ open down ↓ 7 lines elided ↑ open up ↑
  75   76          { \
  76   77                  uint64_t __tmp = (x); \
  77   78                  (x) = (y); \
  78   79                  (y) = __tmp; \
  79   80          }
  80   81  
  81   82  #define DS_REF_MAX      (1ULL << 62)
  82   83  
  83   84  extern inline dsl_dataset_phys_t *dsl_dataset_phys(dsl_dataset_t *ds);
  84   85  
  85      -static void dsl_dataset_set_remap_deadlist_object(dsl_dataset_t *ds,
  86      -    uint64_t obj, dmu_tx_t *tx);
  87      -static void dsl_dataset_unset_remap_deadlist_object(dsl_dataset_t *ds,
  88      -    dmu_tx_t *tx);
  89      -
  90   86  extern int spa_asize_inflation;
  91   87  
  92   88  static zil_header_t zero_zil;
  93   89  
       90 +kmem_cache_t *zfs_ds_collector_cache = NULL;
       91 +
       92 +zfs_ds_collector_entry_t *
       93 +dsl_dataset_collector_cache_alloc()
       94 +{
       95 +        return (kmem_cache_alloc(zfs_ds_collector_cache, KM_SLEEP));
       96 +}
       97 +
       98 +void
       99 +dsl_dataset_collector_cache_free(zfs_ds_collector_entry_t *entry)
      100 +{
      101 +        kmem_cache_free(zfs_ds_collector_cache, entry);
      102 +}
      103 +
  94  104  /*
  95  105   * Figure out how much of this delta should be propogated to the dsl_dir
  96  106   * layer.  If there's a refreservation, that space has already been
  97  107   * partially accounted for in our ancestors.
  98  108   */
  99  109  static int64_t
 100  110  parent_delta(dsl_dataset_t *ds, int64_t delta)
 101  111  {
 102  112          dsl_dataset_phys_t *ds_phys;
 103  113          uint64_t old_bytes, new_bytes;
↓ open down ↓ 49 lines elided ↑ open up ↑
 153  163          if (f != SPA_FEATURE_NONE)
 154  164                  ds->ds_feature_activation_needed[f] = B_TRUE;
 155  165  
 156  166          mutex_exit(&ds->ds_lock);
 157  167          dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD, delta,
 158  168              compressed, uncompressed, tx);
 159  169          dsl_dir_transfer_space(ds->ds_dir, used - delta,
 160  170              DD_USED_REFRSRV, DD_USED_HEAD, tx);
 161  171  }
 162  172  
 163      -/*
 164      - * Called when the specified segment has been remapped, and is thus no
 165      - * longer referenced in the head dataset.  The vdev must be indirect.
 166      - *
 167      - * If the segment is referenced by a snapshot, put it on the remap deadlist.
 168      - * Otherwise, add this segment to the obsolete spacemap.
 169      - */
 170      -void
 171      -dsl_dataset_block_remapped(dsl_dataset_t *ds, uint64_t vdev, uint64_t offset,
 172      -    uint64_t size, uint64_t birth, dmu_tx_t *tx)
 173      -{
 174      -        spa_t *spa = ds->ds_dir->dd_pool->dp_spa;
 175      -
 176      -        ASSERT(dmu_tx_is_syncing(tx));
 177      -        ASSERT(birth <= tx->tx_txg);
 178      -        ASSERT(!ds->ds_is_snapshot);
 179      -
 180      -        if (birth > dsl_dataset_phys(ds)->ds_prev_snap_txg) {
 181      -                spa_vdev_indirect_mark_obsolete(spa, vdev, offset, size, tx);
 182      -        } else {
 183      -                blkptr_t fakebp;
 184      -                dva_t *dva = &fakebp.blk_dva[0];
 185      -
 186      -                ASSERT(ds != NULL);
 187      -
 188      -                mutex_enter(&ds->ds_remap_deadlist_lock);
 189      -                if (!dsl_dataset_remap_deadlist_exists(ds)) {
 190      -                        dsl_dataset_create_remap_deadlist(ds, tx);
 191      -                }
 192      -                mutex_exit(&ds->ds_remap_deadlist_lock);
 193      -
 194      -                BP_ZERO(&fakebp);
 195      -                fakebp.blk_birth = birth;
 196      -                DVA_SET_VDEV(dva, vdev);
 197      -                DVA_SET_OFFSET(dva, offset);
 198      -                DVA_SET_ASIZE(dva, size);
 199      -
 200      -                dsl_deadlist_insert(&ds->ds_remap_deadlist, &fakebp, tx);
 201      -        }
 202      -}
 203      -
 204  173  int
 205  174  dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
 206  175      boolean_t async)
 207  176  {
 208  177          int used = bp_get_dsize_sync(tx->tx_pool->dp_spa, bp);
 209  178          int compressed = BP_GET_PSIZE(bp);
 210  179          int uncompressed = BP_GET_UCSIZE(bp);
      180 +        wbc_data_t *wbc_data = spa_get_wbc_data(tx->tx_pool->dp_spa);
 211  181  
 212  182          if (BP_IS_HOLE(bp))
 213  183                  return (0);
 214  184  
 215  185          ASSERT(dmu_tx_is_syncing(tx));
 216  186          ASSERT(bp->blk_birth <= tx->tx_txg);
 217  187  
 218  188          if (ds == NULL) {
 219  189                  dsl_free(tx->tx_pool, tx->tx_txg, bp);
 220  190                  dsl_pool_mos_diduse_space(tx->tx_pool,
↓ open down ↓ 4 lines elided ↑ open up ↑
 225  195  
 226  196          ASSERT(!ds->ds_is_snapshot);
 227  197          dmu_buf_will_dirty(ds->ds_dbuf, tx);
 228  198  
 229  199          if (bp->blk_birth > dsl_dataset_phys(ds)->ds_prev_snap_txg) {
 230  200                  int64_t delta;
 231  201  
 232  202                  dprintf_bp(bp, "freeing ds=%llu", ds->ds_object);
 233  203                  dsl_free(tx->tx_pool, tx->tx_txg, bp);
 234  204  
      205 +                /* update amount of data which is changed in the window */
      206 +                mutex_enter(&wbc_data->wbc_lock);
      207 +                if (wbc_data->wbc_isvalid &&
      208 +                    bp->blk_birth && wbc_data->wbc_finish_txg &&
      209 +                    bp->blk_birth <= wbc_data->wbc_finish_txg &&
      210 +                    bp->blk_birth >= wbc_data->wbc_start_txg &&
      211 +                    !wbc_data->wbc_purge) {
      212 +
      213 +                        wbc_data->wbc_altered_bytes += used;
      214 +                        if (wbc_data->wbc_altered_limit &&
      215 +                            wbc_data->wbc_altered_bytes >
      216 +                            wbc_data->wbc_altered_limit) {
      217 +                                wbc_purge_window(tx->tx_pool->dp_spa, tx);
      218 +                        }
      219 +                }
      220 +                mutex_exit(&wbc_data->wbc_lock);
      221 +
 235  222                  mutex_enter(&ds->ds_lock);
 236  223                  ASSERT(dsl_dataset_phys(ds)->ds_unique_bytes >= used ||
 237  224                      !DS_UNIQUE_IS_ACCURATE(ds));
 238  225                  delta = parent_delta(ds, -used);
 239  226                  dsl_dataset_phys(ds)->ds_unique_bytes -= used;
 240  227                  mutex_exit(&ds->ds_lock);
 241  228                  dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD,
 242  229                      delta, -compressed, -uncompressed, tx);
 243  230                  dsl_dir_transfer_space(ds->ds_dir, -used - delta,
 244  231                      DD_USED_REFRSRV, DD_USED_HEAD, tx);
↓ open down ↓ 67 lines elided ↑ open up ↑
 312  299  
 313  300          if (ds->ds_objset != NULL)
 314  301                  dmu_objset_evict(ds->ds_objset);
 315  302  
 316  303          if (ds->ds_prev) {
 317  304                  dsl_dataset_rele(ds->ds_prev, ds);
 318  305                  ds->ds_prev = NULL;
 319  306          }
 320  307  
 321  308          bplist_destroy(&ds->ds_pending_deadlist);
 322      -        if (dsl_deadlist_is_open(&ds->ds_deadlist))
      309 +        if (ds->ds_deadlist.dl_os != NULL)
 323  310                  dsl_deadlist_close(&ds->ds_deadlist);
 324      -        if (dsl_deadlist_is_open(&ds->ds_remap_deadlist))
 325      -                dsl_deadlist_close(&ds->ds_remap_deadlist);
 326  311          if (ds->ds_dir)
 327  312                  dsl_dir_async_rele(ds->ds_dir, ds);
 328  313  
 329  314          ASSERT(!list_link_active(&ds->ds_synced_link));
 330  315  
 331  316          list_destroy(&ds->ds_prop_cbs);
 332  317          mutex_destroy(&ds->ds_lock);
 333  318          mutex_destroy(&ds->ds_opening_lock);
 334  319          mutex_destroy(&ds->ds_sendstream_lock);
 335      -        mutex_destroy(&ds->ds_remap_deadlist_lock);
 336  320          refcount_destroy(&ds->ds_longholds);
 337  321          rrw_destroy(&ds->ds_bp_rwlock);
 338  322  
 339  323          kmem_free(ds, sizeof (dsl_dataset_t));
 340  324  }
 341  325  
 342  326  int
 343  327  dsl_dataset_get_snapname(dsl_dataset_t *ds)
 344  328  {
 345  329          dsl_dataset_phys_t *headphys;
↓ open down ↓ 104 lines elided ↑ open up ↑
 450  434  
 451  435          ds = dmu_buf_get_user(dbuf);
 452  436          if (ds == NULL) {
 453  437                  dsl_dataset_t *winner = NULL;
 454  438  
 455  439                  ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP);
 456  440                  ds->ds_dbuf = dbuf;
 457  441                  ds->ds_object = dsobj;
 458  442                  ds->ds_is_snapshot = dsl_dataset_phys(ds)->ds_num_children != 0;
 459  443  
 460      -                err = dsl_dir_hold_obj(dp, dsl_dataset_phys(ds)->ds_dir_obj,
 461      -                    NULL, ds, &ds->ds_dir);
 462      -                if (err != 0) {
 463      -                        kmem_free(ds, sizeof (dsl_dataset_t));
 464      -                        dmu_buf_rele(dbuf, tag);
 465      -                        return (err);
 466      -                }
 467      -
 468  444                  mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL);
 469  445                  mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL);
 470  446                  mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL);
 471      -                mutex_init(&ds->ds_remap_deadlist_lock,
 472      -                    NULL, MUTEX_DEFAULT, NULL);
 473  447                  rrw_init(&ds->ds_bp_rwlock, B_FALSE);
 474  448                  refcount_create(&ds->ds_longholds);
 475  449  
 476  450                  bplist_create(&ds->ds_pending_deadlist);
      451 +                dsl_deadlist_open(&ds->ds_deadlist,
      452 +                    mos, dsl_dataset_phys(ds)->ds_deadlist_obj);
 477  453  
 478  454                  list_create(&ds->ds_sendstreams, sizeof (dmu_sendarg_t),
 479  455                      offsetof(dmu_sendarg_t, dsa_link));
 480  456  
 481  457                  list_create(&ds->ds_prop_cbs, sizeof (dsl_prop_cb_record_t),
 482  458                      offsetof(dsl_prop_cb_record_t, cbr_ds_node));
 483  459  
 484  460                  if (doi.doi_type == DMU_OTN_ZAP_METADATA) {
 485  461                          for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
 486  462                                  if (!(spa_feature_table[f].fi_flags &
↓ open down ↓ 3 lines elided ↑ open up ↑
 490  466                                      spa_feature_table[f].fi_guid);
 491  467                                  if (err == 0) {
 492  468                                          ds->ds_feature_inuse[f] = B_TRUE;
 493  469                                  } else {
 494  470                                          ASSERT3U(err, ==, ENOENT);
 495  471                                          err = 0;
 496  472                                  }
 497  473                          }
 498  474                  }
 499  475  
      476 +                err = dsl_dir_hold_obj(dp,
      477 +                    dsl_dataset_phys(ds)->ds_dir_obj, NULL, ds, &ds->ds_dir);
      478 +                if (err != 0) {
      479 +                        mutex_destroy(&ds->ds_lock);
      480 +                        mutex_destroy(&ds->ds_opening_lock);
      481 +                        mutex_destroy(&ds->ds_sendstream_lock);
      482 +                        refcount_destroy(&ds->ds_longholds);
      483 +                        bplist_destroy(&ds->ds_pending_deadlist);
      484 +                        dsl_deadlist_close(&ds->ds_deadlist);
      485 +                        kmem_free(ds, sizeof (dsl_dataset_t));
      486 +                        dmu_buf_rele(dbuf, tag);
      487 +                        return (err);
      488 +                }
      489 +
 500  490                  if (!ds->ds_is_snapshot) {
 501  491                          ds->ds_snapname[0] = '\0';
 502  492                          if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
 503  493                                  err = dsl_dataset_hold_obj(dp,
 504  494                                      dsl_dataset_phys(ds)->ds_prev_snap_obj,
 505  495                                      ds, &ds->ds_prev);
 506  496                          }
 507  497                          if (doi.doi_type == DMU_OTN_ZAP_METADATA) {
 508  498                                  int zaperr = zap_lookup(mos, ds->ds_object,
 509  499                                      DS_FIELD_BOOKMARK_NAMES,
↓ open down ↓ 20 lines elided ↑ open up ↑
 530  520                              &ds->ds_reserved);
 531  521                          if (err == 0) {
 532  522                                  err = dsl_prop_get_int_ds(ds,
 533  523                                      zfs_prop_to_name(ZFS_PROP_REFQUOTA),
 534  524                                      &ds->ds_quota);
 535  525                          }
 536  526                  } else {
 537  527                          ds->ds_reserved = ds->ds_quota = 0;
 538  528                  }
 539  529  
 540      -                dsl_deadlist_open(&ds->ds_deadlist,
 541      -                    mos, dsl_dataset_phys(ds)->ds_deadlist_obj);
 542      -                uint64_t remap_deadlist_obj =
 543      -                    dsl_dataset_get_remap_deadlist_object(ds);
 544      -                if (remap_deadlist_obj != 0) {
 545      -                        dsl_deadlist_open(&ds->ds_remap_deadlist, mos,
 546      -                            remap_deadlist_obj);
 547      -                }
 548      -
 549  530                  dmu_buf_init_user(&ds->ds_dbu, dsl_dataset_evict_sync,
 550  531                      dsl_dataset_evict_async, &ds->ds_dbuf);
 551  532                  if (err == 0)
 552  533                          winner = dmu_buf_set_user_ie(dbuf, &ds->ds_dbu);
 553  534  
 554  535                  if (err != 0 || winner != NULL) {
 555  536                          bplist_destroy(&ds->ds_pending_deadlist);
 556  537                          dsl_deadlist_close(&ds->ds_deadlist);
 557      -                        if (dsl_deadlist_is_open(&ds->ds_remap_deadlist))
 558      -                                dsl_deadlist_close(&ds->ds_remap_deadlist);
 559  538                          if (ds->ds_prev)
 560  539                                  dsl_dataset_rele(ds->ds_prev, ds);
 561  540                          dsl_dir_rele(ds->ds_dir, ds);
 562  541                          mutex_destroy(&ds->ds_lock);
 563  542                          mutex_destroy(&ds->ds_opening_lock);
 564  543                          mutex_destroy(&ds->ds_sendstream_lock);
 565  544                          refcount_destroy(&ds->ds_longholds);
 566  545                          kmem_free(ds, sizeof (dsl_dataset_t));
 567  546                          if (err != 0) {
 568  547                                  dmu_buf_rele(dbuf, tag);
↓ open down ↓ 627 lines elided ↑ open up ↑
1196 1175  }
1197 1176  
1198 1177  int
1199 1178  dsl_dataset_snapshot_check(void *arg, dmu_tx_t *tx)
1200 1179  {
1201 1180          dsl_dataset_snapshot_arg_t *ddsa = arg;
1202 1181          dsl_pool_t *dp = dmu_tx_pool(tx);
1203 1182          nvpair_t *pair;
1204 1183          int rv = 0;
1205 1184  
     1185 +        if (ddsa->ddsa_autosnap && dmu_tx_is_syncing(tx))
     1186 +                autosnap_invalidate_list(dp, ddsa->ddsa_snaps);
     1187 +
1206 1188          /*
1207 1189           * Pre-compute how many total new snapshots will be created for each
1208 1190           * level in the tree and below. This is needed for validating the
1209 1191           * snapshot limit when either taking a recursive snapshot or when
1210 1192           * taking multiple snapshots.
1211 1193           *
1212 1194           * The problem is that the counts are not actually adjusted when
1213 1195           * we are checking, only when we finally sync. For a single snapshot,
1214 1196           * this is easy, the count will increase by 1 at each node up the tree,
1215 1197           * but its more complicated for the recursive/multiple snapshot case.
↓ open down ↓ 120 lines elided ↑ open up ↑
1336 1318  
1337 1319  void
1338 1320  dsl_dataset_snapshot_sync_impl(dsl_dataset_t *ds, const char *snapname,
1339 1321      dmu_tx_t *tx)
1340 1322  {
1341 1323          dsl_pool_t *dp = ds->ds_dir->dd_pool;
1342 1324          dmu_buf_t *dbuf;
1343 1325          dsl_dataset_phys_t *dsphys;
1344 1326          uint64_t dsobj, crtxg;
1345 1327          objset_t *mos = dp->dp_meta_objset;
1346      -        objset_t *os;
     1328 +        objset_t *os = NULL;
     1329 +        uint64_t unique_bytes = 0;
1347 1330  
1348 1331          ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock));
1349 1332  
1350 1333          /*
1351 1334           * If we are on an old pool, the zil must not be active, in which
1352 1335           * case it will be zeroed.  Usually zil_suspend() accomplishes this.
1353 1336           */
1354 1337          ASSERT(spa_version(dmu_tx_pool(tx)->dp_spa) >= SPA_VERSION_FAST_SNAP ||
1355 1338              dmu_objset_from_ds(ds, &os) != 0 ||
1356 1339              bcmp(&os->os_phys->os_zil_header, &zero_zil,
↓ open down ↓ 84 lines elided ↑ open up ↑
1441 1424          dmu_buf_will_dirty(ds->ds_dbuf, tx);
1442 1425          dsl_dataset_phys(ds)->ds_deadlist_obj =
1443 1426              dsl_deadlist_clone(&ds->ds_deadlist, UINT64_MAX,
1444 1427              dsl_dataset_phys(ds)->ds_prev_snap_obj, tx);
1445 1428          dsl_deadlist_close(&ds->ds_deadlist);
1446 1429          dsl_deadlist_open(&ds->ds_deadlist, mos,
1447 1430              dsl_dataset_phys(ds)->ds_deadlist_obj);
1448 1431          dsl_deadlist_add_key(&ds->ds_deadlist,
1449 1432              dsl_dataset_phys(ds)->ds_prev_snap_txg, tx);
1450 1433  
1451      -        if (dsl_dataset_remap_deadlist_exists(ds)) {
1452      -                uint64_t remap_deadlist_obj =
1453      -                    dsl_dataset_get_remap_deadlist_object(ds);
1454      -                /*
1455      -                 * Move the remap_deadlist to the snapshot.  The head
1456      -                 * will create a new remap deadlist on demand, from
1457      -                 * dsl_dataset_block_remapped().
1458      -                 */
1459      -                dsl_dataset_unset_remap_deadlist_object(ds, tx);
1460      -                dsl_deadlist_close(&ds->ds_remap_deadlist);
1461      -
1462      -                dmu_object_zapify(mos, dsobj, DMU_OT_DSL_DATASET, tx);
1463      -                VERIFY0(zap_add(mos, dsobj, DS_FIELD_REMAP_DEADLIST,
1464      -                    sizeof (remap_deadlist_obj), 1, &remap_deadlist_obj, tx));
1465      -        }
1466      -
1467 1434          ASSERT3U(dsl_dataset_phys(ds)->ds_prev_snap_txg, <, tx->tx_txg);
1468 1435          dsl_dataset_phys(ds)->ds_prev_snap_obj = dsobj;
1469 1436          dsl_dataset_phys(ds)->ds_prev_snap_txg = crtxg;
     1437 +        unique_bytes = dsl_dataset_phys(ds)->ds_unique_bytes;
1470 1438          dsl_dataset_phys(ds)->ds_unique_bytes = 0;
1471      -
1472 1439          if (spa_version(dp->dp_spa) >= SPA_VERSION_UNIQUE_ACCURATE)
1473 1440                  dsl_dataset_phys(ds)->ds_flags |= DS_FLAG_UNIQUE_ACCURATE;
1474 1441  
1475 1442          VERIFY0(zap_add(mos, dsl_dataset_phys(ds)->ds_snapnames_zapobj,
1476 1443              snapname, 8, 1, &dsobj, tx));
1477 1444  
1478 1445          if (ds->ds_prev)
1479 1446                  dsl_dataset_rele(ds->ds_prev, ds);
1480 1447          VERIFY0(dsl_dataset_hold_obj(dp,
1481 1448              dsl_dataset_phys(ds)->ds_prev_snap_obj, ds, &ds->ds_prev));
1482 1449  
1483 1450          dsl_scan_ds_snapshotted(ds, tx);
1484 1451  
1485 1452          dsl_dir_snap_cmtime_update(ds->ds_dir);
1486 1453  
1487 1454          spa_history_log_internal_ds(ds->ds_prev, "snapshot", tx, "");
     1455 +
     1456 +        if (autosnap_check_name(snapname)) {
     1457 +                autosnap_create_cb(spa_get_autosnap(dp->dp_spa),
     1458 +                    ds, snapname, tx->tx_txg);
     1459 +        }
     1460 +
     1461 +        if (os == NULL)
     1462 +                VERIFY0(dmu_objset_from_ds(ds, &os));
     1463 +
     1464 +        if (os->os_wbc_mode != ZFS_WBC_MODE_OFF)
     1465 +                wbc_add_bytes(dp->dp_spa, tx->tx_txg, unique_bytes);
1488 1466  }
1489 1467  
1490 1468  void
1491 1469  dsl_dataset_snapshot_sync(void *arg, dmu_tx_t *tx)
1492 1470  {
1493 1471          dsl_dataset_snapshot_arg_t *ddsa = arg;
1494 1472          dsl_pool_t *dp = dmu_tx_pool(tx);
1495 1473          nvpair_t *pair;
1496 1474  
1497 1475          for (pair = nvlist_next_nvpair(ddsa->ddsa_snaps, NULL);
1498 1476              pair != NULL; pair = nvlist_next_nvpair(ddsa->ddsa_snaps, pair)) {
1499 1477                  dsl_dataset_t *ds;
1500 1478                  char *name, *atp;
1501 1479                  char dsname[ZFS_MAX_DATASET_NAME_LEN];
1502 1480  
1503 1481                  name = nvpair_name(pair);
     1482 +
1504 1483                  atp = strchr(name, '@');
1505 1484                  (void) strlcpy(dsname, name, atp - name + 1);
1506 1485                  VERIFY0(dsl_dataset_hold(dp, dsname, FTAG, &ds));
1507 1486  
1508 1487                  dsl_dataset_snapshot_sync_impl(ds, atp + 1, tx);
1509 1488                  if (ddsa->ddsa_props != NULL) {
1510 1489                          dsl_props_set_sync_impl(ds->ds_prev,
1511 1490                              ZPROP_SRC_LOCAL, ddsa->ddsa_props, tx);
1512 1491                  }
1513 1492                  dsl_dataset_rele(ds, FTAG);
↓ open down ↓ 47 lines elided ↑ open up ↑
1561 1540                                  break;
1562 1541                          fnvlist_add_uint64(suspended, fsname,
1563 1542                              (uintptr_t)cookie);
1564 1543                  }
1565 1544          }
1566 1545  
1567 1546          ddsa.ddsa_snaps = snaps;
1568 1547          ddsa.ddsa_props = props;
1569 1548          ddsa.ddsa_errors = errors;
1570 1549          ddsa.ddsa_cr = CRED();
     1550 +        ddsa.ddsa_autosnap = B_FALSE;
1571 1551  
1572 1552          if (error == 0) {
1573 1553                  error = dsl_sync_task(firstname, dsl_dataset_snapshot_check,
1574 1554                      dsl_dataset_snapshot_sync, &ddsa,
1575 1555                      fnvlist_num_pairs(snaps) * 3, ZFS_SPACE_CHECK_NORMAL);
1576 1556          }
1577 1557  
1578 1558          if (suspended != NULL) {
1579 1559                  for (pair = nvlist_next_nvpair(suspended, NULL); pair != NULL;
1580 1560                      pair = nvlist_next_nvpair(suspended, pair)) {
↓ open down ↓ 614 lines elided ↑ open up ↑
2195 2175          dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO,
2196 2176              dsl_get_refratio(ds));
2197 2177          dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_LOGICALREFERENCED,
2198 2178              dsl_get_logicalreferenced(ds));
2199 2179          dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO,
2200 2180              dsl_get_compressratio(ds));
2201 2181          dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
2202 2182              dsl_get_used(ds));
2203 2183  
2204 2184          if (ds->ds_is_snapshot) {
     2185 +                dsl_dataset_t *hds = NULL;
     2186 +                boolean_t modified = B_FALSE;
     2187 +
     2188 +                if (dsl_dataset_hold_obj(dp,
     2189 +                    dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj,
     2190 +                    FTAG, &hds) == 0) {
     2191 +                        modified = dsl_dataset_modified_since_snap(hds, ds);
     2192 +                        dsl_dataset_rele(hds, FTAG);
     2193 +                }
     2194 +
     2195 +                dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_MODIFIED,
     2196 +                    modified ? 1 : 0);
     2197 +
2205 2198                  get_clones_stat(ds, nv);
2206 2199          } else {
2207 2200                  char buf[ZFS_MAX_DATASET_NAME_LEN];
2208 2201                  if (dsl_get_prev_snap(ds, buf) == 0)
2209 2202                          dsl_prop_nvlist_add_string(nv, ZFS_PROP_PREV_SNAP,
2210 2203                              buf);
2211 2204                  dsl_dir_stats(ds->ds_dir, nv);
2212 2205          }
2213 2206  
2214 2207          dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_AVAILABLE,
↓ open down ↓ 57 lines elided ↑ open up ↑
2272 2265  void
2273 2266  dsl_dataset_fast_stat(dsl_dataset_t *ds, dmu_objset_stats_t *stat)
2274 2267  {
2275 2268          dsl_pool_t *dp = ds->ds_dir->dd_pool;
2276 2269          ASSERT(dsl_pool_config_held(dp));
2277 2270  
2278 2271          stat->dds_creation_txg = dsl_get_creationtxg(ds);
2279 2272          stat->dds_inconsistent = dsl_get_inconsistent(ds);
2280 2273          stat->dds_guid = dsl_get_guid(ds);
2281 2274          stat->dds_origin[0] = '\0';
     2275 +        stat->dds_is_snapshot = B_FALSE;
     2276 +        stat->dds_is_autosnapshot = B_FALSE;
2282 2277          if (ds->ds_is_snapshot) {
2283      -                stat->dds_is_snapshot = B_TRUE;
     2278 +                if (autosnap_is_autosnap(ds))
     2279 +                        stat->dds_is_autosnapshot = B_TRUE;
     2280 +                else
     2281 +                        stat->dds_is_snapshot = B_TRUE;
     2282 +
2284 2283                  stat->dds_num_clones = dsl_get_numclones(ds);
2285 2284          } else {
2286      -                stat->dds_is_snapshot = B_FALSE;
2287 2285                  stat->dds_num_clones = 0;
2288 2286  
2289 2287                  if (dsl_dir_is_clone(ds->ds_dir)) {
2290 2288                          dsl_dir_get_origin(ds->ds_dir, stat->dds_origin);
2291 2289                  }
2292 2290          }
2293 2291  }
2294 2292  
2295 2293  uint64_t
2296 2294  dsl_dataset_fsid_guid(dsl_dataset_t *ds)
↓ open down ↓ 96 lines elided ↑ open up ↑
2393 2391  }
2394 2392  
2395 2393  static int
2396 2394  dsl_dataset_rename_snapshot_check(void *arg, dmu_tx_t *tx)
2397 2395  {
2398 2396          dsl_dataset_rename_snapshot_arg_t *ddrsa = arg;
2399 2397          dsl_pool_t *dp = dmu_tx_pool(tx);
2400 2398          dsl_dataset_t *hds;
2401 2399          int error;
2402 2400  
     2401 +        /* You cannot rename an autosnapshot */
     2402 +        if (autosnap_check_name(ddrsa->ddrsa_oldsnapname))
     2403 +                return (SET_ERROR(EPERM));
     2404 +
     2405 +        /* New name cannot match the AUTOSNAP prefix */
     2406 +        if (autosnap_check_name(ddrsa->ddrsa_newsnapname))
     2407 +                return (SET_ERROR(EPERM));
     2408 +
2403 2409          error = dsl_dataset_hold(dp, ddrsa->ddrsa_fsname, FTAG, &hds);
2404 2410          if (error != 0)
2405 2411                  return (error);
2406 2412  
2407 2413          if (ddrsa->ddrsa_recursive) {
2408 2414                  error = dmu_objset_find_dp(dp, hds->ds_dir->dd_object,
2409 2415                      dsl_dataset_rename_snapshot_check_impl, ddrsa,
2410 2416                      DS_FIND_CHILDREN);
2411 2417          } else {
2412 2418                  error = dsl_dataset_rename_snapshot_check_impl(dp, hds, ddrsa);
↓ open down ↓ 922 lines elided ↑ open up ↑
3335 3341           * So that overage is the refquota_slack we use below.
3336 3342           */
3337 3343          if (origin_head->ds_quota != 0 &&
3338 3344              dsl_dataset_phys(clone)->ds_referenced_bytes >
3339 3345              origin_head->ds_quota + refquota_slack)
3340 3346                  return (SET_ERROR(EDQUOT));
3341 3347  
3342 3348          return (0);
3343 3349  }
3344 3350  
3345      -static void
3346      -dsl_dataset_swap_remap_deadlists(dsl_dataset_t *clone,
3347      -    dsl_dataset_t *origin, dmu_tx_t *tx)
3348      -{
3349      -        uint64_t clone_remap_dl_obj, origin_remap_dl_obj;
3350      -        dsl_pool_t *dp = dmu_tx_pool(tx);
3351      -
3352      -        ASSERT(dsl_pool_sync_context(dp));
3353      -
3354      -        clone_remap_dl_obj = dsl_dataset_get_remap_deadlist_object(clone);
3355      -        origin_remap_dl_obj = dsl_dataset_get_remap_deadlist_object(origin);
3356      -
3357      -        if (clone_remap_dl_obj != 0) {
3358      -                dsl_deadlist_close(&clone->ds_remap_deadlist);
3359      -                dsl_dataset_unset_remap_deadlist_object(clone, tx);
3360      -        }
3361      -        if (origin_remap_dl_obj != 0) {
3362      -                dsl_deadlist_close(&origin->ds_remap_deadlist);
3363      -                dsl_dataset_unset_remap_deadlist_object(origin, tx);
3364      -        }
3365      -
3366      -        if (clone_remap_dl_obj != 0) {
3367      -                dsl_dataset_set_remap_deadlist_object(origin,
3368      -                    clone_remap_dl_obj, tx);
3369      -                dsl_deadlist_open(&origin->ds_remap_deadlist,
3370      -                    dp->dp_meta_objset, clone_remap_dl_obj);
3371      -        }
3372      -        if (origin_remap_dl_obj != 0) {
3373      -                dsl_dataset_set_remap_deadlist_object(clone,
3374      -                    origin_remap_dl_obj, tx);
3375      -                dsl_deadlist_open(&clone->ds_remap_deadlist,
3376      -                    dp->dp_meta_objset, origin_remap_dl_obj);
3377      -        }
3378      -}
3379      -
3380 3351  void
3381 3352  dsl_dataset_clone_swap_sync_impl(dsl_dataset_t *clone,
3382 3353      dsl_dataset_t *origin_head, dmu_tx_t *tx)
3383 3354  {
3384 3355          dsl_pool_t *dp = dmu_tx_pool(tx);
3385 3356          int64_t unused_refres_delta;
3386 3357  
3387 3358          ASSERT(clone->ds_reserved == 0);
3388 3359          /*
3389 3360           * NOTE: On DEBUG kernels there could be a race between this and
↓ open down ↓ 149 lines elided ↑ open up ↑
3539 3510           * Swap deadlists.
3540 3511           */
3541 3512          dsl_deadlist_close(&clone->ds_deadlist);
3542 3513          dsl_deadlist_close(&origin_head->ds_deadlist);
3543 3514          SWITCH64(dsl_dataset_phys(origin_head)->ds_deadlist_obj,
3544 3515              dsl_dataset_phys(clone)->ds_deadlist_obj);
3545 3516          dsl_deadlist_open(&clone->ds_deadlist, dp->dp_meta_objset,
3546 3517              dsl_dataset_phys(clone)->ds_deadlist_obj);
3547 3518          dsl_deadlist_open(&origin_head->ds_deadlist, dp->dp_meta_objset,
3548 3519              dsl_dataset_phys(origin_head)->ds_deadlist_obj);
3549      -        dsl_dataset_swap_remap_deadlists(clone, origin_head, tx);
3550 3520  
3551 3521          dsl_scan_ds_clone_swapped(origin_head, clone, tx);
3552 3522  
3553 3523          spa_history_log_internal_ds(clone, "clone swap", tx,
3554 3524              "parent=%s", origin_head->ds_dir->dd_myname);
3555 3525  }
3556 3526  
3557 3527  /*
3558 3528   * Given a pool name and a dataset object number in that pool,
3559 3529   * return the name of that dataset.
↓ open down ↓ 472 lines elided ↑ open up ↑
4032 4002  }
4033 4003  
4034 4004  void
4035 4005  dsl_dataset_zapify(dsl_dataset_t *ds, dmu_tx_t *tx)
4036 4006  {
4037 4007          objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset;
4038 4008          dmu_object_zapify(mos, ds->ds_object, DMU_OT_DSL_DATASET, tx);
4039 4009  }
4040 4010  
4041 4011  boolean_t
4042      -dsl_dataset_is_zapified(dsl_dataset_t *ds)
     4012 +dataset_name_hidden(const char *name)
4043 4013  {
4044      -        dmu_object_info_t doi;
4045      -
4046      -        dmu_object_info_from_db(ds->ds_dbuf, &doi);
4047      -        return (doi.doi_type == DMU_OTN_ZAP_METADATA);
     4014 +        if (strchr(name, '$') != NULL)
     4015 +                return (B_TRUE);
     4016 +        if (strchr(name, '%') != NULL)
     4017 +                return (B_TRUE);
     4018 +        if (!INGLOBALZONE(curproc) && !zone_dataset_visible(name, NULL))
     4019 +                return (B_TRUE);
     4020 +        return (B_FALSE);
4048 4021  }
4049 4022  
4050      -boolean_t
4051      -dsl_dataset_has_resume_receive_state(dsl_dataset_t *ds)
4052      -{
4053      -        return (dsl_dataset_is_zapified(ds) &&
4054      -            zap_contains(ds->ds_dir->dd_pool->dp_meta_objset,
4055      -            ds->ds_object, DS_FIELD_RESUME_TOGUID) == 0);
4056      -}
4057      -
4058 4023  uint64_t
4059      -dsl_dataset_get_remap_deadlist_object(dsl_dataset_t *ds)
     4024 +dsl_dataset_creation_txg(const char *name)
4060 4025  {
4061      -        uint64_t remap_deadlist_obj;
     4026 +        dsl_pool_t *dp;
     4027 +        dsl_dataset_t *ds;
4062 4028          int err;
     4029 +        uint64_t ret = UINT64_MAX;
4063 4030  
4064      -        if (!dsl_dataset_is_zapified(ds))
4065      -                return (0);
     4031 +        err = dsl_pool_hold(name, FTAG, &dp);
4066 4032  
4067      -        err = zap_lookup(ds->ds_dir->dd_pool->dp_meta_objset, ds->ds_object,
4068      -            DS_FIELD_REMAP_DEADLIST, sizeof (remap_deadlist_obj), 1,
4069      -            &remap_deadlist_obj);
     4033 +        if (err)
     4034 +                return (ret);
4070 4035  
4071      -        if (err != 0) {
4072      -                VERIFY3S(err, ==, ENOENT);
4073      -                return (0);
     4036 +        err = dsl_dataset_hold(dp, name, FTAG, &ds);
     4037 +
     4038 +        if (!err) {
     4039 +                ret = dsl_dataset_phys(ds)->ds_creation_txg;
     4040 +                dsl_dataset_rele(ds, FTAG);
4074 4041          }
4075 4042  
4076      -        ASSERT(remap_deadlist_obj != 0);
4077      -        return (remap_deadlist_obj);
     4043 +        dsl_pool_rele(dp, FTAG);
     4044 +
     4045 +        return (ret);
4078 4046  }
4079 4047  
4080 4048  boolean_t
4081      -dsl_dataset_remap_deadlist_exists(dsl_dataset_t *ds)
     4049 +dsl_dataset_is_zapified(dsl_dataset_t *ds)
4082 4050  {
4083      -        EQUIV(dsl_deadlist_is_open(&ds->ds_remap_deadlist),
4084      -            dsl_dataset_get_remap_deadlist_object(ds) != 0);
4085      -        return (dsl_deadlist_is_open(&ds->ds_remap_deadlist));
4086      -}
     4051 +        dmu_object_info_t doi;
4087 4052  
4088      -static void
4089      -dsl_dataset_set_remap_deadlist_object(dsl_dataset_t *ds, uint64_t obj,
4090      -    dmu_tx_t *tx)
4091      -{
4092      -        ASSERT(obj != 0);
4093      -        dsl_dataset_zapify(ds, tx);
4094      -        VERIFY0(zap_add(ds->ds_dir->dd_pool->dp_meta_objset, ds->ds_object,
4095      -            DS_FIELD_REMAP_DEADLIST, sizeof (obj), 1, &obj, tx));
     4053 +        dmu_object_info_from_db(ds->ds_dbuf, &doi);
     4054 +        return (doi.doi_type == DMU_OTN_ZAP_METADATA);
4096 4055  }
4097 4056  
4098      -static void
4099      -dsl_dataset_unset_remap_deadlist_object(dsl_dataset_t *ds, dmu_tx_t *tx)
     4057 +boolean_t
     4058 +dsl_dataset_has_resume_receive_state(dsl_dataset_t *ds)
4100 4059  {
4101      -        VERIFY0(zap_remove(ds->ds_dir->dd_pool->dp_meta_objset,
4102      -            ds->ds_object, DS_FIELD_REMAP_DEADLIST, tx));
4103      -}
4104      -
4105      -void
4106      -dsl_dataset_destroy_remap_deadlist(dsl_dataset_t *ds, dmu_tx_t *tx)
4107      -{
4108      -        uint64_t remap_deadlist_object;
4109      -        spa_t *spa = ds->ds_dir->dd_pool->dp_spa;
4110      -
4111      -        ASSERT(dmu_tx_is_syncing(tx));
4112      -        ASSERT(dsl_dataset_remap_deadlist_exists(ds));
4113      -
4114      -        remap_deadlist_object = ds->ds_remap_deadlist.dl_object;
4115      -        dsl_deadlist_close(&ds->ds_remap_deadlist);
4116      -        dsl_deadlist_free(spa_meta_objset(spa), remap_deadlist_object, tx);
4117      -        dsl_dataset_unset_remap_deadlist_object(ds, tx);
4118      -        spa_feature_decr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx);
4119      -}
4120      -
4121      -void
4122      -dsl_dataset_create_remap_deadlist(dsl_dataset_t *ds, dmu_tx_t *tx)
4123      -{
4124      -        uint64_t remap_deadlist_obj;
4125      -        spa_t *spa = ds->ds_dir->dd_pool->dp_spa;
4126      -
4127      -        ASSERT(dmu_tx_is_syncing(tx));
4128      -        ASSERT(MUTEX_HELD(&ds->ds_remap_deadlist_lock));
4129      -        /*
4130      -         * Currently we only create remap deadlists when there are indirect
4131      -         * vdevs with referenced mappings.
4132      -         */
4133      -        ASSERT(spa_feature_is_active(spa, SPA_FEATURE_DEVICE_REMOVAL));
4134      -
4135      -        remap_deadlist_obj = dsl_deadlist_clone(
4136      -            &ds->ds_deadlist, UINT64_MAX,
4137      -            dsl_dataset_phys(ds)->ds_prev_snap_obj, tx);
4138      -        dsl_dataset_set_remap_deadlist_object(ds,
4139      -            remap_deadlist_obj, tx);
4140      -        dsl_deadlist_open(&ds->ds_remap_deadlist, spa_meta_objset(spa),
4141      -            remap_deadlist_obj);
4142      -        spa_feature_incr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx);
     4060 +        return (dsl_dataset_is_zapified(ds) &&
     4061 +            zap_contains(ds->ds_dir->dd_pool->dp_meta_objset,
     4062 +            ds->ds_object, DS_FIELD_RESUME_TOGUID) == 0);
4143 4063  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX