Print this page
3740 Poor ZFS send / receive performance due to snapshot hold / release processing
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013 by Delphix. All rights reserved.

  24  */
  25 
  26 #include <sys/dsl_pool.h>
  27 #include <sys/dsl_dataset.h>
  28 #include <sys/dsl_prop.h>
  29 #include <sys/dsl_dir.h>
  30 #include <sys/dsl_synctask.h>
  31 #include <sys/dsl_scan.h>
  32 #include <sys/dnode.h>
  33 #include <sys/dmu_tx.h>
  34 #include <sys/dmu_objset.h>
  35 #include <sys/arc.h>
  36 #include <sys/zap.h>
  37 #include <sys/zio.h>
  38 #include <sys/zfs_context.h>
  39 #include <sys/fs/zfs.h>
  40 #include <sys/zfs_znode.h>
  41 #include <sys/spa_impl.h>
  42 #include <sys/dsl_deadlist.h>
  43 #include <sys/bptree.h>


 819         dsl_dataset_rele(ds, FTAG);
 820 }
 821 
 822 taskq_t *
 823 dsl_pool_vnrele_taskq(dsl_pool_t *dp)
 824 {
 825         return (dp->dp_vnrele_taskq);
 826 }
 827 
 828 /*
 829  * Walk through the pool-wide zap object of temporary snapshot user holds
 830  * and release them.
 831  */
 832 void
 833 dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp)
 834 {
 835         zap_attribute_t za;
 836         zap_cursor_t zc;
 837         objset_t *mos = dp->dp_meta_objset;
 838         uint64_t zapobj = dp->dp_tmp_userrefs_obj;

 839 
 840         if (zapobj == 0)
 841                 return;
 842         ASSERT(spa_version(dp->dp_spa) >= SPA_VERSION_USERREFS);
 843 


 844         for (zap_cursor_init(&zc, mos, zapobj);
 845             zap_cursor_retrieve(&zc, &za) == 0;
 846             zap_cursor_advance(&zc)) {
 847                 char *htag;
 848                 uint64_t dsobj;
 849 
 850                 htag = strchr(za.za_name, '-');
 851                 *htag = '\0';
 852                 ++htag;
 853                 dsobj = strtonum(za.za_name, NULL);
 854                 dsl_dataset_user_release_tmp(dp, dsobj, htag);






 855         }


 856         zap_cursor_fini(&zc);
 857 }
 858 
 859 /*
 860  * Create the pool-wide zap object for storing temporary snapshot holds.
 861  */
 862 void
 863 dsl_pool_user_hold_create_obj(dsl_pool_t *dp, dmu_tx_t *tx)
 864 {
 865         objset_t *mos = dp->dp_meta_objset;
 866 
 867         ASSERT(dp->dp_tmp_userrefs_obj == 0);
 868         ASSERT(dmu_tx_is_syncing(tx));
 869 
 870         dp->dp_tmp_userrefs_obj = zap_create_link(mos, DMU_OT_USERREFS,
 871             DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_TMP_USERREFS, tx);
 872 }
 873 
 874 static int
 875 dsl_pool_user_hold_rele_impl(dsl_pool_t *dp, uint64_t dsobj,




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013 by Delphix. All rights reserved.
  24  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  25  */
  26 
  27 #include <sys/dsl_pool.h>
  28 #include <sys/dsl_dataset.h>
  29 #include <sys/dsl_prop.h>
  30 #include <sys/dsl_dir.h>
  31 #include <sys/dsl_synctask.h>
  32 #include <sys/dsl_scan.h>
  33 #include <sys/dnode.h>
  34 #include <sys/dmu_tx.h>
  35 #include <sys/dmu_objset.h>
  36 #include <sys/arc.h>
  37 #include <sys/zap.h>
  38 #include <sys/zio.h>
  39 #include <sys/zfs_context.h>
  40 #include <sys/fs/zfs.h>
  41 #include <sys/zfs_znode.h>
  42 #include <sys/spa_impl.h>
  43 #include <sys/dsl_deadlist.h>
  44 #include <sys/bptree.h>


 820         dsl_dataset_rele(ds, FTAG);
 821 }
 822 
 823 taskq_t *
 824 dsl_pool_vnrele_taskq(dsl_pool_t *dp)
 825 {
 826         return (dp->dp_vnrele_taskq);
 827 }
 828 
 829 /*
 830  * Walk through the pool-wide zap object of temporary snapshot user holds
 831  * and release them.
 832  */
 833 void
 834 dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp)
 835 {
 836         zap_attribute_t za;
 837         zap_cursor_t zc;
 838         objset_t *mos = dp->dp_meta_objset;
 839         uint64_t zapobj = dp->dp_tmp_userrefs_obj;
 840         nvlist_t *holds;
 841 
 842         if (zapobj == 0)
 843                 return;
 844         ASSERT(spa_version(dp->dp_spa) >= SPA_VERSION_USERREFS);
 845 
 846         holds = fnvlist_alloc();
 847 
 848         for (zap_cursor_init(&zc, mos, zapobj);
 849             zap_cursor_retrieve(&zc, &za) == 0;
 850             zap_cursor_advance(&zc)) {
 851                 char *htag;
 852                 nvlist_t *tags;
 853 
 854                 htag = strchr(za.za_name, '-');
 855                 *htag = '\0';
 856                 ++htag;
 857                 if (nvlist_lookup_nvlist(holds, za.za_name, &tags) != 0) {
 858                         tags = fnvlist_alloc();
 859                         fnvlist_add_boolean(tags, htag);
 860                         fnvlist_add_nvlist(holds, za.za_name, tags);
 861                         fnvlist_free(tags);
 862                 } else {
 863                         fnvlist_add_boolean(tags, htag);
 864                 }
 865         }
 866         dsl_dataset_user_release_tmp(dp, holds);
 867         fnvlist_free(holds);
 868         zap_cursor_fini(&zc);
 869 }
 870 
 871 /*
 872  * Create the pool-wide zap object for storing temporary snapshot holds.
 873  */
 874 void
 875 dsl_pool_user_hold_create_obj(dsl_pool_t *dp, dmu_tx_t *tx)
 876 {
 877         objset_t *mos = dp->dp_meta_objset;
 878 
 879         ASSERT(dp->dp_tmp_userrefs_obj == 0);
 880         ASSERT(dmu_tx_is_syncing(tx));
 881 
 882         dp->dp_tmp_userrefs_obj = zap_create_link(mos, DMU_OT_USERREFS,
 883             DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_TMP_USERREFS, tx);
 884 }
 885 
 886 static int
 887 dsl_pool_user_hold_rele_impl(dsl_pool_t *dp, uint64_t dsobj,