Print this page
NEX-19394 backport 9337 zfs get all is slow due to uncached metadata
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Thomas Caputi <tcaputi@datto.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
 Conflicts:
  usr/src/uts/common/fs/zfs/dbuf.c
  usr/src/uts/common/fs/zfs/dmu.c
  usr/src/uts/common/fs/zfs/sys/dmu_objset.h
NEX-3562 filename normalization doesn't work for removes (sync with upstream)
NEX-9752 backport illumos 6950 ARC should cache compressed data
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
6950 ARC should cache compressed data
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Don Brady <don.brady@intel.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
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>
NEX-5318 Cleanup specialclass property (obsolete, not used) and fix related meta-to-special case
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
NEX-5058 WBC: Race between the purging of window and opening new one
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
NEX-2830 ZFS smart compression
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-4934 Add capability to remove special vdev
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
6495 Fix mutex leak in dmu_objset_find_dp
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Albert Lee <trisk@omniti.com>
6267 dn_bonus evicted too early
Reviewed by: Richard Yao <ryao@gentoo.org>
Reviewed by: Xin LI <delphij@freebsd.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
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>
5981 Deadlock in dmu_objset_find_dp
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Robert Mustacchi <rm@joyent.com>
5269 zpool import slow
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Dan McDonald <danmcd@omniti.com>
5610 zfs clone from different source and target pools produces coredump
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
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-4028 use lz4 by default
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
NEX-3558 KRRP Integration
SUP-507 Delete or truncate of large files delayed on datasets with small recordsize
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Ilya Usvyatsky <ilya.usvyatsky@nexenta.com>
Reviewed by: Tony Nguyen <tony.nguyen@nexenta.com>
OS-80 support for vdev and CoS properties for the new I/O scheduler
OS-95 lint warning introduced by OS-61
Issues #7: Reconsile L2ARC and "special" use by datasets
Support for secondarycache=data option
Align mutex tables in arc.c and dbuf.c to 64 bytes (cache line), place each kmutex_t on cache line by itself to avoid false sharing
re #12619 rb4429 More dp->dp_config_rwlock holds

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dmu_objset.c
          +++ new/usr/src/uts/common/fs/zfs/dmu_objset.c
↓ open down ↓ 45 lines elided ↑ open up ↑
  46   46  #include <sys/zvol.h>
  47   47  #include <sys/dmu_tx.h>
  48   48  #include <sys/zap.h>
  49   49  #include <sys/zil.h>
  50   50  #include <sys/dmu_impl.h>
  51   51  #include <sys/zfs_ioctl.h>
  52   52  #include <sys/sa.h>
  53   53  #include <sys/zfs_onexit.h>
  54   54  #include <sys/dsl_destroy.h>
  55   55  #include <sys/vdev.h>
  56      -#include <sys/zfeature.h>
       56 +#include <sys/wbc.h>
  57   57  
  58   58  /*
  59   59   * Needed to close a window in dnode_move() that allows the objset to be freed
  60   60   * before it can be safely accessed.
  61   61   */
  62   62  krwlock_t os_lock;
  63   63  
       64 +extern kmem_cache_t *zfs_ds_collector_cache;
       65 +
  64   66  /*
  65   67   * Tunable to overwrite the maximum number of threads for the parallization
  66   68   * of dmu_objset_find_dp, needed to speed up the import of pools with many
  67   69   * datasets.
  68   70   * Default is 4 times the number of leaf vdevs.
  69   71   */
  70   72  int dmu_find_threads = 0;
  71   73  
  72   74  /*
  73   75   * Backfill lower metadnode objects after this many have been freed.
  74   76   * Backfilling negatively impacts object creation rates, so only do it
  75   77   * if there are enough holes to fill.
  76   78   */
  77   79  int dmu_rescan_dnode_threshold = 131072;
  78   80  
  79   81  static void dmu_objset_find_dp_cb(void *arg);
  80   82  
       83 +/* ARGSUSED */
       84 +static int
       85 +zfs_ds_collector_constructor(void *ds_el, void *unused, int flags)
       86 +{
       87 +        bzero(ds_el, sizeof (zfs_ds_collector_entry_t));
       88 +        return (0);
       89 +}
       90 +
  81   91  void
  82   92  dmu_objset_init(void)
  83   93  {
       94 +        zfs_ds_collector_cache = kmem_cache_create("zfs_ds_collector_cache",
       95 +            sizeof (zfs_ds_collector_entry_t),
       96 +            8, zfs_ds_collector_constructor,
       97 +            NULL, NULL, NULL, NULL, 0);
  84   98          rw_init(&os_lock, NULL, RW_DEFAULT, NULL);
  85   99  }
  86  100  
  87  101  void
  88  102  dmu_objset_fini(void)
  89  103  {
  90  104          rw_destroy(&os_lock);
      105 +        kmem_cache_destroy(zfs_ds_collector_cache);
  91  106  }
  92  107  
  93  108  spa_t *
  94  109  dmu_objset_spa(objset_t *os)
  95  110  {
  96  111          return (os->os_spa);
  97  112  }
  98  113  
  99  114  zilog_t *
 100  115  dmu_objset_zil(objset_t *os)
↓ open down ↓ 71 lines elided ↑ open up ↑
 172  187          /*
 173  188           * Inheritance and range checking should have been done by now.
 174  189           */
 175  190          ASSERT(newval != ZIO_COMPRESS_INHERIT);
 176  191  
 177  192          os->os_compress = zio_compress_select(os->os_spa, newval,
 178  193              ZIO_COMPRESS_ON);
 179  194  }
 180  195  
 181  196  static void
      197 +smartcomp_changed_cb(void *arg, uint64_t newval)
      198 +{
      199 +        objset_t *os = arg;
      200 +
      201 +        os->os_smartcomp_enabled = newval ? B_TRUE : B_FALSE;
      202 +}
      203 +
      204 +static void
 182  205  copies_changed_cb(void *arg, uint64_t newval)
 183  206  {
 184  207          objset_t *os = arg;
 185  208  
 186  209          /*
 187  210           * Inheritance and range checking should have been done by now.
 188  211           */
 189  212          ASSERT(newval > 0);
 190  213          ASSERT(newval <= spa_max_replication(os->os_spa));
 191  214  
↓ open down ↓ 34 lines elided ↑ open up ↑
 226  249  
 227  250  static void
 228  251  secondary_cache_changed_cb(void *arg, uint64_t newval)
 229  252  {
 230  253          objset_t *os = arg;
 231  254  
 232  255          /*
 233  256           * Inheritance and range checking should have been done by now.
 234  257           */
 235  258          ASSERT(newval == ZFS_CACHE_ALL || newval == ZFS_CACHE_NONE ||
 236      -            newval == ZFS_CACHE_METADATA);
      259 +            newval == ZFS_CACHE_METADATA || newval == ZFS_CACHE_DATA);
 237  260  
 238  261          os->os_secondary_cache = newval;
 239  262  }
 240  263  
 241  264  static void
      265 +zpl_meta_placement_changed_cb(void *arg, uint64_t newval)
      266 +{
      267 +        objset_t *os = arg;
      268 +
      269 +        os->os_zpl_meta_to_special = newval;
      270 +}
      271 +
      272 +static void
 242  273  sync_changed_cb(void *arg, uint64_t newval)
 243  274  {
 244  275          objset_t *os = arg;
 245  276  
 246  277          /*
 247  278           * Inheritance and range checking should have been done by now.
 248  279           */
 249  280          ASSERT(newval == ZFS_SYNC_STANDARD || newval == ZFS_SYNC_ALWAYS ||
 250  281              newval == ZFS_SYNC_DISABLED);
 251  282  
↓ open down ↓ 90 lines elided ↑ open up ↑
 342  373   */
 343  374  int
 344  375  dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
 345  376      objset_t **osp)
 346  377  {
 347  378          objset_t *os;
 348  379          int i, err;
 349  380  
 350  381          ASSERT(ds == NULL || MUTEX_HELD(&ds->ds_opening_lock));
 351  382  
 352      -        /*
 353      -         * The $ORIGIN dataset (if it exists) doesn't have an associated
 354      -         * objset, so there's no reason to open it. The $ORIGIN dataset
 355      -         * will not exist on pools older than SPA_VERSION_ORIGIN.
 356      -         */
 357      -        if (ds != NULL && spa_get_dsl(spa) != NULL &&
 358      -            spa_get_dsl(spa)->dp_origin_snap != NULL) {
 359      -                ASSERT3P(ds->ds_dir, !=,
 360      -                    spa_get_dsl(spa)->dp_origin_snap->ds_dir);
 361      -        }
 362      -
 363  383          os = kmem_zalloc(sizeof (objset_t), KM_SLEEP);
 364  384          os->os_dsl_dataset = ds;
 365  385          os->os_spa = spa;
 366  386          os->os_rootbp = bp;
 367  387          if (!BP_IS_HOLE(os->os_rootbp)) {
 368  388                  arc_flags_t aflags = ARC_FLAG_WAIT;
 369  389                  zbookmark_phys_t zb;
 370  390                  SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET,
 371  391                      ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
 372  392  
↓ open down ↓ 54 lines elided ↑ open up ↑
 427  447                          dsl_pool_config_enter(dmu_objset_pool(os), FTAG);
 428  448                  }
 429  449                  err = dsl_prop_register(ds,
 430  450                      zfs_prop_to_name(ZFS_PROP_PRIMARYCACHE),
 431  451                      primary_cache_changed_cb, os);
 432  452                  if (err == 0) {
 433  453                          err = dsl_prop_register(ds,
 434  454                              zfs_prop_to_name(ZFS_PROP_SECONDARYCACHE),
 435  455                              secondary_cache_changed_cb, os);
 436  456                  }
      457 +                if (err == 0) {
      458 +                        err = dsl_prop_register(ds,
      459 +                            zfs_prop_to_name(ZFS_PROP_ZPL_META_TO_METADEV),
      460 +                            zpl_meta_placement_changed_cb, os);
      461 +                }
 437  462                  if (!ds->ds_is_snapshot) {
 438  463                          if (err == 0) {
 439  464                                  err = dsl_prop_register(ds,
 440  465                                      zfs_prop_to_name(ZFS_PROP_CHECKSUM),
 441  466                                      checksum_changed_cb, os);
 442  467                          }
 443  468                          if (err == 0) {
 444  469                                  err = dsl_prop_register(ds,
 445  470                                      zfs_prop_to_name(ZFS_PROP_COMPRESSION),
 446  471                                      compression_changed_cb, os);
 447  472                          }
 448  473                          if (err == 0) {
 449  474                                  err = dsl_prop_register(ds,
      475 +                                    zfs_prop_to_name(ZFS_PROP_SMARTCOMPRESSION),
      476 +                                    smartcomp_changed_cb, os);
      477 +                        }
      478 +                        if (err == 0) {
      479 +                                err = dsl_prop_register(ds,
 450  480                                      zfs_prop_to_name(ZFS_PROP_COPIES),
 451  481                                      copies_changed_cb, os);
 452  482                          }
 453  483                          if (err == 0) {
 454  484                                  err = dsl_prop_register(ds,
 455  485                                      zfs_prop_to_name(ZFS_PROP_DEDUP),
 456  486                                      dedup_changed_cb, os);
 457  487                          }
 458  488                          if (err == 0) {
 459  489                                  err = dsl_prop_register(ds,
↓ open down ↓ 9 lines elided ↑ open up ↑
 469  499                                  err = dsl_prop_register(ds,
 470  500                                      zfs_prop_to_name(
 471  501                                      ZFS_PROP_REDUNDANT_METADATA),
 472  502                                      redundant_metadata_changed_cb, os);
 473  503                          }
 474  504                          if (err == 0) {
 475  505                                  err = dsl_prop_register(ds,
 476  506                                      zfs_prop_to_name(ZFS_PROP_RECORDSIZE),
 477  507                                      recordsize_changed_cb, os);
 478  508                          }
      509 +                        if (err == 0) {
      510 +                                err = dsl_prop_register(ds,
      511 +                                    zfs_prop_to_name(ZFS_PROP_WBC_MODE),
      512 +                                    wbc_mode_changed, os);
      513 +                        }
 479  514                  }
 480  515                  if (needlock)
 481  516                          dsl_pool_config_exit(dmu_objset_pool(os), FTAG);
 482  517                  if (err != 0) {
 483  518                          arc_buf_destroy(os->os_phys_buf, &os->os_phys_buf);
 484  519                          kmem_free(os, sizeof (objset_t));
 485  520                          return (err);
 486  521                  }
 487  522          } else {
 488  523                  /* It's the meta-objset. */
 489  524                  os->os_checksum = ZIO_CHECKSUM_FLETCHER_4;
 490  525                  os->os_compress = ZIO_COMPRESS_ON;
 491  526                  os->os_copies = spa_max_replication(spa);
 492  527                  os->os_dedup_checksum = ZIO_CHECKSUM_OFF;
 493  528                  os->os_dedup_verify = B_FALSE;
 494  529                  os->os_logbias = ZFS_LOGBIAS_LATENCY;
 495  530                  os->os_sync = ZFS_SYNC_STANDARD;
 496  531                  os->os_primary_cache = ZFS_CACHE_ALL;
 497  532                  os->os_secondary_cache = ZFS_CACHE_ALL;
      533 +                os->os_zpl_meta_to_special = 0;
 498  534          }
      535 +        /*
      536 +         * These properties will be filled in by the logic in zfs_get_zplprop()
      537 +         * when they are queried for the first time.
      538 +         */
      539 +        os->os_version = OBJSET_PROP_UNINITIALIZED;
      540 +        os->os_normalization = OBJSET_PROP_UNINITIALIZED;
      541 +        os->os_utf8only = OBJSET_PROP_UNINITIALIZED;
      542 +        os->os_casesensitivity = OBJSET_PROP_UNINITIALIZED;
 499  543  
 500  544          if (ds == NULL || !ds->ds_is_snapshot)
 501  545                  os->os_zil_header = os->os_phys->os_zil_header;
 502  546          os->os_zil = zil_alloc(os, &os->os_zil_header);
 503  547  
 504  548          for (i = 0; i < TXG_SIZE; i++) {
 505  549                  os->os_dirty_dnodes[i] = multilist_create(sizeof (dnode_t),
 506  550                      offsetof(dnode_t, dn_dirty_link[i]),
 507  551                      dnode_multilist_index_func);
 508  552          }
↓ open down ↓ 198 lines elided ↑ open up ↑
 707  751          while (dn != NULL) {
 708  752                  /*
 709  753                   * Skip dnodes without holds.  We have to do this dance
 710  754                   * because dnode_add_ref() only works if there is already a
 711  755                   * hold.  If the dnode has no holds, then it has no dbufs.
 712  756                   */
 713  757                  if (dnode_add_ref(dn, FTAG)) {
 714  758                          list_insert_after(&os->os_dnodes, dn, &dn_marker);
 715  759                          mutex_exit(&os->os_lock);
 716  760  
 717      -                        dnode_evict_dbufs(dn);
      761 +                        dnode_evict_dbufs(dn, DBUF_EVICT_ALL);
 718  762                          dnode_rele(dn, FTAG);
 719  763  
 720  764                          mutex_enter(&os->os_lock);
 721  765                          dn = list_next(&os->os_dnodes, &dn_marker);
 722  766                          list_remove(&os->os_dnodes, &dn_marker);
 723  767                  } else {
 724  768                          dn = list_next(&os->os_dnodes, dn);
 725  769                  }
 726  770          }
 727  771          mutex_exit(&os->os_lock);
 728  772  
 729  773          if (DMU_USERUSED_DNODE(os) != NULL) {
 730      -                dnode_evict_dbufs(DMU_GROUPUSED_DNODE(os));
 731      -                dnode_evict_dbufs(DMU_USERUSED_DNODE(os));
      774 +                dnode_evict_dbufs(DMU_GROUPUSED_DNODE(os), DBUF_EVICT_ALL);
      775 +                dnode_evict_dbufs(DMU_USERUSED_DNODE(os), DBUF_EVICT_ALL);
 732  776          }
 733      -        dnode_evict_dbufs(DMU_META_DNODE(os));
      777 +        dnode_evict_dbufs(DMU_META_DNODE(os), DBUF_EVICT_ALL);
 734  778  }
 735  779  
 736  780  /*
 737  781   * Objset eviction processing is split into into two pieces.
 738  782   * The first marks the objset as evicting, evicts any dbufs that
 739  783   * have a refcount of zero, and then queues up the objset for the
 740  784   * second phase of eviction.  Once os->os_dnodes has been cleared by
 741  785   * dnode_buf_pageout()->dnode_destroy(), the second phase is executed.
 742  786   * The second phase closes the special dnodes, dequeues the objset from
 743  787   * the list of those undergoing eviction, and finally frees the objset.
↓ open down ↓ 313 lines elided ↑ open up ↑
1057 1101  
1058 1102          doca.doca_clone = clone;
1059 1103          doca.doca_origin = origin;
1060 1104          doca.doca_cred = CRED();
1061 1105  
1062 1106          return (dsl_sync_task(clone,
1063 1107              dmu_objset_clone_check, dmu_objset_clone_sync, &doca,
1064 1108              5, ZFS_SPACE_CHECK_NORMAL));
1065 1109  }
1066 1110  
1067      -static int
1068      -dmu_objset_remap_indirects_impl(objset_t *os, uint64_t last_removed_txg)
1069      -{
1070      -        int error = 0;
1071      -        uint64_t object = 0;
1072      -        while ((error = dmu_object_next(os, &object, B_FALSE, 0)) == 0) {
1073      -                error = dmu_object_remap_indirects(os, object,
1074      -                    last_removed_txg);
1075      -                /*
1076      -                 * If the ZPL removed the object before we managed to dnode_hold
1077      -                 * it, we would get an ENOENT. If the ZPL declares its intent
1078      -                 * to remove the object (dnode_free) before we manage to
1079      -                 * dnode_hold it, we would get an EEXIST. In either case, we
1080      -                 * want to continue remapping the other objects in the objset;
1081      -                 * in all other cases, we want to break early.
1082      -                 */
1083      -                if (error != 0 && error != ENOENT && error != EEXIST) {
1084      -                        break;
1085      -                }
1086      -        }
1087      -        if (error == ESRCH) {
1088      -                error = 0;
1089      -        }
1090      -        return (error);
1091      -}
1092      -
1093 1111  int
1094      -dmu_objset_remap_indirects(const char *fsname)
1095      -{
1096      -        int error = 0;
1097      -        objset_t *os = NULL;
1098      -        uint64_t last_removed_txg;
1099      -        uint64_t remap_start_txg;
1100      -        dsl_dir_t *dd;
1101      -
1102      -        error = dmu_objset_hold(fsname, FTAG, &os);
1103      -        if (error != 0) {
1104      -                return (error);
1105      -        }
1106      -        dd = dmu_objset_ds(os)->ds_dir;
1107      -
1108      -        if (!spa_feature_is_enabled(dmu_objset_spa(os),
1109      -            SPA_FEATURE_OBSOLETE_COUNTS)) {
1110      -                dmu_objset_rele(os, FTAG);
1111      -                return (SET_ERROR(ENOTSUP));
1112      -        }
1113      -
1114      -        if (dsl_dataset_is_snapshot(dmu_objset_ds(os))) {
1115      -                dmu_objset_rele(os, FTAG);
1116      -                return (SET_ERROR(EINVAL));
1117      -        }
1118      -
1119      -        /*
1120      -         * If there has not been a removal, we're done.
1121      -         */
1122      -        last_removed_txg = spa_get_last_removal_txg(dmu_objset_spa(os));
1123      -        if (last_removed_txg == -1ULL) {
1124      -                dmu_objset_rele(os, FTAG);
1125      -                return (0);
1126      -        }
1127      -
1128      -        /*
1129      -         * If we have remapped since the last removal, we're done.
1130      -         */
1131      -        if (dsl_dir_is_zapified(dd)) {
1132      -                uint64_t last_remap_txg;
1133      -                if (zap_lookup(spa_meta_objset(dmu_objset_spa(os)),
1134      -                    dd->dd_object, DD_FIELD_LAST_REMAP_TXG,
1135      -                    sizeof (last_remap_txg), 1, &last_remap_txg) == 0 &&
1136      -                    last_remap_txg > last_removed_txg) {
1137      -                        dmu_objset_rele(os, FTAG);
1138      -                        return (0);
1139      -                }
1140      -        }
1141      -
1142      -        dsl_dataset_long_hold(dmu_objset_ds(os), FTAG);
1143      -        dsl_pool_rele(dmu_objset_pool(os), FTAG);
1144      -
1145      -        remap_start_txg = spa_last_synced_txg(dmu_objset_spa(os));
1146      -        error = dmu_objset_remap_indirects_impl(os, last_removed_txg);
1147      -        if (error == 0) {
1148      -                /*
1149      -                 * We update the last_remap_txg to be the start txg so that
1150      -                 * we can guarantee that every block older than last_remap_txg
1151      -                 * that can be remapped has been remapped.
1152      -                 */
1153      -                error = dsl_dir_update_last_remap_txg(dd, remap_start_txg);
1154      -        }
1155      -
1156      -        dsl_dataset_long_rele(dmu_objset_ds(os), FTAG);
1157      -        dsl_dataset_rele(dmu_objset_ds(os), FTAG);
1158      -
1159      -        return (error);
1160      -}
1161      -
1162      -int
1163 1112  dmu_objset_snapshot_one(const char *fsname, const char *snapname)
1164 1113  {
1165 1114          int err;
1166 1115          char *longsnap = kmem_asprintf("%s@%s", fsname, snapname);
1167 1116          nvlist_t *snaps = fnvlist_alloc();
1168 1117  
1169 1118          fnvlist_add_boolean(snaps, longsnap);
1170 1119          strfree(longsnap);
1171 1120          err = dsl_dataset_snapshot(snaps, NULL, NULL);
1172 1121          fnvlist_free(snaps);
↓ open down ↓ 133 lines elided ↑ open up ↑
1306 1255          SET_BOOKMARK(&zb, os->os_dsl_dataset ?
1307 1256              os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
1308 1257              ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
1309 1258          arc_release(os->os_phys_buf, &os->os_phys_buf);
1310 1259  
1311 1260          dmu_write_policy(os, NULL, 0, 0, &zp);
1312 1261  
1313 1262          zio = arc_write(pio, os->os_spa, tx->tx_txg,
1314 1263              blkptr_copy, os->os_phys_buf, DMU_OS_IS_L2CACHEABLE(os),
1315 1264              &zp, dmu_objset_write_ready, NULL, NULL, dmu_objset_write_done,
1316      -            os, ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
     1265 +            os, ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb, NULL);
1317 1266  
1318 1267          /*
1319 1268           * Sync special dnodes - the parent IO for the sync is the root block
1320 1269           */
1321 1270          DMU_META_DNODE(os)->dn_zio = zio;
1322 1271          dnode_sync(DMU_META_DNODE(os), tx);
1323 1272  
1324 1273          os->os_phys->os_flags = os->os_flags;
1325 1274  
1326 1275          if (DMU_USERUSED_DNODE(os) &&
↓ open down ↓ 519 lines elided ↑ open up ↑
1846 1795          uint64_t ignored;
1847 1796  
1848 1797          if (dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0)
1849 1798                  return (SET_ERROR(ENOENT));
1850 1799  
1851 1800          return (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset,
1852 1801              dsl_dataset_phys(ds)->ds_snapnames_zapobj, name, 8, 1, &ignored,
1853 1802              MT_NORMALIZE, real, maxlen, conflict));
1854 1803  }
1855 1804  
     1805 +int
     1806 +dmu_clone_list_next(objset_t *os, int len, char *name,
     1807 +    uint64_t *idp, uint64_t *offp)
     1808 +{
     1809 +        dsl_dataset_t *ds = os->os_dsl_dataset, *clone;
     1810 +        zap_cursor_t cursor;
     1811 +        zap_attribute_t attr;
     1812 +        char buf[MAXNAMELEN];
     1813 +
     1814 +        ASSERT(dsl_pool_config_held(dmu_objset_pool(os)));
     1815 +
     1816 +        if (dsl_dataset_phys(ds)->ds_next_clones_obj == 0)
     1817 +                return (SET_ERROR(ENOENT));
     1818 +
     1819 +        zap_cursor_init_serialized(&cursor,
     1820 +            ds->ds_dir->dd_pool->dp_meta_objset,
     1821 +            dsl_dataset_phys(ds)->ds_next_clones_obj, *offp);
     1822 +
     1823 +        if (zap_cursor_retrieve(&cursor, &attr) != 0) {
     1824 +                zap_cursor_fini(&cursor);
     1825 +                return (SET_ERROR(ENOENT));
     1826 +        }
     1827 +
     1828 +        VERIFY0(dsl_dataset_hold_obj(ds->ds_dir->dd_pool,
     1829 +            attr.za_first_integer, FTAG, &clone));
     1830 +
     1831 +        dsl_dir_name(clone->ds_dir, buf);
     1832 +
     1833 +        dsl_dataset_rele(clone, FTAG);
     1834 +
     1835 +        if (strlen(buf) >= len) {
     1836 +                zap_cursor_fini(&cursor);
     1837 +                return (SET_ERROR(ENAMETOOLONG));
     1838 +        }
     1839 +
     1840 +        (void) strcpy(name, buf);
     1841 +        if (idp != NULL)
     1842 +                *idp = attr.za_first_integer;
     1843 +
     1844 +        zap_cursor_advance(&cursor);
     1845 +        *offp = zap_cursor_serialize(&cursor);
     1846 +        zap_cursor_fini(&cursor);
     1847 +
     1848 +        return (0);
     1849 +}
     1850 +
1856 1851  int
1857 1852  dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
1858 1853      uint64_t *idp, uint64_t *offp, boolean_t *case_conflict)
1859 1854  {
1860 1855          dsl_dataset_t *ds = os->os_dsl_dataset;
1861 1856          zap_cursor_t cursor;
1862 1857          zap_attribute_t attr;
1863 1858  
1864 1859          ASSERT(dsl_pool_config_held(dmu_objset_pool(os)));
1865 1860  
↓ open down ↓ 484 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX