Print this page
6536 zfs send: want a way to disable setting of DRR_FLAG_FREERECORDS
Reviewed by: Anil Vijarnia <avijarnia@racktopsystems.com>
Reviewed by: Kim Shrier <kshrier@racktopsystems.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>


   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 2011 Nexenta Systems, Inc. All rights reserved.
  24  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  25  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  26  * Copyright 2014 HybridCluster. All rights reserved.

  27  */
  28 
  29 #include <sys/dmu.h>
  30 #include <sys/dmu_impl.h>
  31 #include <sys/dmu_tx.h>
  32 #include <sys/dbuf.h>
  33 #include <sys/dnode.h>
  34 #include <sys/zfs_context.h>
  35 #include <sys/dmu_objset.h>
  36 #include <sys/dmu_traverse.h>
  37 #include <sys/dsl_dataset.h>
  38 #include <sys/dsl_dir.h>
  39 #include <sys/dsl_prop.h>
  40 #include <sys/dsl_pool.h>
  41 #include <sys/dsl_synctask.h>
  42 #include <sys/zfs_ioctl.h>
  43 #include <sys/zap.h>
  44 #include <sys/zio_checksum.h>
  45 #include <sys/zfs_znode.h>
  46 #include <zfs_fletcher.h>
  47 #include <sys/avl.h>
  48 #include <sys/ddt.h>
  49 #include <sys/zfs_onexit.h>
  50 #include <sys/dmu_send.h>
  51 #include <sys/dsl_destroy.h>
  52 #include <sys/blkptr.h>
  53 #include <sys/dsl_bookmark.h>
  54 #include <sys/zfeature.h>
  55 #include <sys/bqueue.h>
  56 
  57 /* Set this tunable to TRUE to replace corrupt data with 0x2f5baddb10c */
  58 int zfs_send_corrupt_data = B_FALSE;
  59 int zfs_send_queue_length = 16 * 1024 * 1024;
  60 int zfs_recv_queue_length = 16 * 1024 * 1024;


  61 
  62 static char *dmu_recv_tag = "dmu_recv_tag";
  63 const char *recv_clone_name = "%recv";
  64 
  65 #define BP_SPAN(datablkszsec, indblkshift, level) \
  66         (((uint64_t)datablkszsec) << (SPA_MINBLOCKSHIFT + \
  67         (level) * (indblkshift - SPA_BLKPTRSHIFT)))
  68 
  69 static void byteswap_record(dmu_replay_record_t *drr);
  70 
  71 struct send_thread_arg {
  72         bqueue_t        q;
  73         dsl_dataset_t   *ds;            /* Dataset to traverse */
  74         uint64_t        fromtxg;        /* Traverse from this txg */
  75         int             flags;          /* flags to pass to traverse_dataset */
  76         int             error_code;
  77         boolean_t       cancel;
  78         zbookmark_phys_t resume;
  79 };
  80 


 728                 featureflags |= DMU_BACKUP_FEATURE_EMBED_DATA;
 729                 if (spa_feature_is_active(dp->dp_spa, SPA_FEATURE_LZ4_COMPRESS))
 730                         featureflags |= DMU_BACKUP_FEATURE_EMBED_DATA_LZ4;
 731         }
 732 
 733         if (resumeobj != 0 || resumeoff != 0) {
 734                 featureflags |= DMU_BACKUP_FEATURE_RESUMING;
 735         }
 736 
 737         DMU_SET_FEATUREFLAGS(drr->drr_u.drr_begin.drr_versioninfo,
 738             featureflags);
 739 
 740         drr->drr_u.drr_begin.drr_creation_time =
 741             dsl_dataset_phys(to_ds)->ds_creation_time;
 742         drr->drr_u.drr_begin.drr_type = dmu_objset_type(os);
 743         if (is_clone)
 744                 drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE;
 745         drr->drr_u.drr_begin.drr_toguid = dsl_dataset_phys(to_ds)->ds_guid;
 746         if (dsl_dataset_phys(to_ds)->ds_flags & DS_FLAG_CI_DATASET)
 747                 drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA;

 748         drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_FREERECORDS;
 749 
 750         if (ancestor_zb != NULL) {
 751                 drr->drr_u.drr_begin.drr_fromguid =
 752                     ancestor_zb->zbm_guid;
 753                 fromtxg = ancestor_zb->zbm_creation_txg;
 754         }
 755         dsl_dataset_name(to_ds, drr->drr_u.drr_begin.drr_toname);
 756         if (!to_ds->ds_is_snapshot) {
 757                 (void) strlcat(drr->drr_u.drr_begin.drr_toname, "@--head--",
 758                     sizeof (drr->drr_u.drr_begin.drr_toname));
 759         }
 760 
 761         dsp = kmem_zalloc(sizeof (dmu_sendarg_t), KM_SLEEP);
 762 
 763         dsp->dsa_drr = drr;
 764         dsp->dsa_vp = vp;
 765         dsp->dsa_outfd = outfd;
 766         dsp->dsa_proc = curproc;
 767         dsp->dsa_os = os;




   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 2011 Nexenta Systems, Inc. All rights reserved.
  24  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  25  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  26  * Copyright 2014 HybridCluster. All rights reserved.
  27  * Copyright 2016 RackTop Systems.
  28  */
  29 
  30 #include <sys/dmu.h>
  31 #include <sys/dmu_impl.h>
  32 #include <sys/dmu_tx.h>
  33 #include <sys/dbuf.h>
  34 #include <sys/dnode.h>
  35 #include <sys/zfs_context.h>
  36 #include <sys/dmu_objset.h>
  37 #include <sys/dmu_traverse.h>
  38 #include <sys/dsl_dataset.h>
  39 #include <sys/dsl_dir.h>
  40 #include <sys/dsl_prop.h>
  41 #include <sys/dsl_pool.h>
  42 #include <sys/dsl_synctask.h>
  43 #include <sys/zfs_ioctl.h>
  44 #include <sys/zap.h>
  45 #include <sys/zio_checksum.h>
  46 #include <sys/zfs_znode.h>
  47 #include <zfs_fletcher.h>
  48 #include <sys/avl.h>
  49 #include <sys/ddt.h>
  50 #include <sys/zfs_onexit.h>
  51 #include <sys/dmu_send.h>
  52 #include <sys/dsl_destroy.h>
  53 #include <sys/blkptr.h>
  54 #include <sys/dsl_bookmark.h>
  55 #include <sys/zfeature.h>
  56 #include <sys/bqueue.h>
  57 
  58 /* Set this tunable to TRUE to replace corrupt data with 0x2f5baddb10c */
  59 int zfs_send_corrupt_data = B_FALSE;
  60 int zfs_send_queue_length = 16 * 1024 * 1024;
  61 int zfs_recv_queue_length = 16 * 1024 * 1024;
  62 /* Set this tunable to FALSE to disable setting of DRR_FLAG_FREERECORDS */
  63 int zfs_send_set_freerecords_bit = B_TRUE;
  64 
  65 static char *dmu_recv_tag = "dmu_recv_tag";
  66 const char *recv_clone_name = "%recv";
  67 
  68 #define BP_SPAN(datablkszsec, indblkshift, level) \
  69         (((uint64_t)datablkszsec) << (SPA_MINBLOCKSHIFT + \
  70         (level) * (indblkshift - SPA_BLKPTRSHIFT)))
  71 
  72 static void byteswap_record(dmu_replay_record_t *drr);
  73 
  74 struct send_thread_arg {
  75         bqueue_t        q;
  76         dsl_dataset_t   *ds;            /* Dataset to traverse */
  77         uint64_t        fromtxg;        /* Traverse from this txg */
  78         int             flags;          /* flags to pass to traverse_dataset */
  79         int             error_code;
  80         boolean_t       cancel;
  81         zbookmark_phys_t resume;
  82 };
  83 


 731                 featureflags |= DMU_BACKUP_FEATURE_EMBED_DATA;
 732                 if (spa_feature_is_active(dp->dp_spa, SPA_FEATURE_LZ4_COMPRESS))
 733                         featureflags |= DMU_BACKUP_FEATURE_EMBED_DATA_LZ4;
 734         }
 735 
 736         if (resumeobj != 0 || resumeoff != 0) {
 737                 featureflags |= DMU_BACKUP_FEATURE_RESUMING;
 738         }
 739 
 740         DMU_SET_FEATUREFLAGS(drr->drr_u.drr_begin.drr_versioninfo,
 741             featureflags);
 742 
 743         drr->drr_u.drr_begin.drr_creation_time =
 744             dsl_dataset_phys(to_ds)->ds_creation_time;
 745         drr->drr_u.drr_begin.drr_type = dmu_objset_type(os);
 746         if (is_clone)
 747                 drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE;
 748         drr->drr_u.drr_begin.drr_toguid = dsl_dataset_phys(to_ds)->ds_guid;
 749         if (dsl_dataset_phys(to_ds)->ds_flags & DS_FLAG_CI_DATASET)
 750                 drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA;
 751         if (zfs_send_set_freerecords_bit)
 752                 drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_FREERECORDS;
 753 
 754         if (ancestor_zb != NULL) {
 755                 drr->drr_u.drr_begin.drr_fromguid =
 756                     ancestor_zb->zbm_guid;
 757                 fromtxg = ancestor_zb->zbm_creation_txg;
 758         }
 759         dsl_dataset_name(to_ds, drr->drr_u.drr_begin.drr_toname);
 760         if (!to_ds->ds_is_snapshot) {
 761                 (void) strlcat(drr->drr_u.drr_begin.drr_toname, "@--head--",
 762                     sizeof (drr->drr_u.drr_begin.drr_toname));
 763         }
 764 
 765         dsp = kmem_zalloc(sizeof (dmu_sendarg_t), KM_SLEEP);
 766 
 767         dsp->dsa_drr = drr;
 768         dsp->dsa_vp = vp;
 769         dsp->dsa_outfd = outfd;
 770         dsp->dsa_proc = curproc;
 771         dsp->dsa_os = os;