Print this page
5610 zfs clone from different source and target pools produces coredump


   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) 2012, 2014 by Delphix. All rights reserved.
  24  * Copyright (c) 2013 Martin Matuska. All rights reserved.
  25  * Copyright (c) 2014 Joyent, Inc. All rights reserved.
  26  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.

  27  */
  28 
  29 #include <sys/dmu.h>
  30 #include <sys/dmu_objset.h>
  31 #include <sys/dmu_tx.h>
  32 #include <sys/dsl_dataset.h>
  33 #include <sys/dsl_dir.h>
  34 #include <sys/dsl_prop.h>
  35 #include <sys/dsl_synctask.h>
  36 #include <sys/dsl_deleg.h>
  37 #include <sys/dmu_impl.h>
  38 #include <sys/spa.h>
  39 #include <sys/metaslab.h>
  40 #include <sys/zap.h>
  41 #include <sys/zio.h>
  42 #include <sys/arc.h>
  43 #include <sys/sunddi.h>
  44 #include <sys/zfeature.h>
  45 #include <sys/policy.h>
  46 #include <sys/zfs_znode.h>


 404  * path is bogus, or if tail==NULL and we couldn't parse the whole name.
 405  * (*tail)[0] == '@' means that the last component is a snapshot.
 406  */
 407 int
 408 dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
 409     dsl_dir_t **ddp, const char **tailp)
 410 {
 411         char buf[MAXNAMELEN];
 412         const char *spaname, *next, *nextnext = NULL;
 413         int err;
 414         dsl_dir_t *dd;
 415         uint64_t ddobj;
 416 
 417         err = getcomponent(name, buf, &next);
 418         if (err != 0)
 419                 return (err);
 420 
 421         /* Make sure the name is in the specified pool. */
 422         spaname = spa_name(dp->dp_spa);
 423         if (strcmp(buf, spaname) != 0)
 424                 return (SET_ERROR(EINVAL));
 425 
 426         ASSERT(dsl_pool_config_held(dp));
 427 
 428         err = dsl_dir_hold_obj(dp, dp->dp_root_dir_obj, NULL, tag, &dd);
 429         if (err != 0) {
 430                 return (err);
 431         }
 432 
 433         while (next != NULL) {
 434                 dsl_dir_t *child_dd;
 435                 err = getcomponent(next, buf, &nextnext);
 436                 if (err != 0)
 437                         break;
 438                 ASSERT(next[0] != '\0');
 439                 if (next[0] == '@')
 440                         break;
 441                 dprintf("looking up %s in obj%lld\n",
 442                     buf, dsl_dir_phys(dd)->dd_child_dir_zapobj);
 443 
 444                 err = zap_lookup(dp->dp_meta_objset,




   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) 2012, 2014 by Delphix. All rights reserved.
  24  * Copyright (c) 2013 Martin Matuska. All rights reserved.
  25  * Copyright (c) 2014 Joyent, Inc. All rights reserved.
  26  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  27  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  28  */
  29 
  30 #include <sys/dmu.h>
  31 #include <sys/dmu_objset.h>
  32 #include <sys/dmu_tx.h>
  33 #include <sys/dsl_dataset.h>
  34 #include <sys/dsl_dir.h>
  35 #include <sys/dsl_prop.h>
  36 #include <sys/dsl_synctask.h>
  37 #include <sys/dsl_deleg.h>
  38 #include <sys/dmu_impl.h>
  39 #include <sys/spa.h>
  40 #include <sys/metaslab.h>
  41 #include <sys/zap.h>
  42 #include <sys/zio.h>
  43 #include <sys/arc.h>
  44 #include <sys/sunddi.h>
  45 #include <sys/zfeature.h>
  46 #include <sys/policy.h>
  47 #include <sys/zfs_znode.h>


 405  * path is bogus, or if tail==NULL and we couldn't parse the whole name.
 406  * (*tail)[0] == '@' means that the last component is a snapshot.
 407  */
 408 int
 409 dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
 410     dsl_dir_t **ddp, const char **tailp)
 411 {
 412         char buf[MAXNAMELEN];
 413         const char *spaname, *next, *nextnext = NULL;
 414         int err;
 415         dsl_dir_t *dd;
 416         uint64_t ddobj;
 417 
 418         err = getcomponent(name, buf, &next);
 419         if (err != 0)
 420                 return (err);
 421 
 422         /* Make sure the name is in the specified pool. */
 423         spaname = spa_name(dp->dp_spa);
 424         if (strcmp(buf, spaname) != 0)
 425                 return (SET_ERROR(EXDEV));
 426 
 427         ASSERT(dsl_pool_config_held(dp));
 428 
 429         err = dsl_dir_hold_obj(dp, dp->dp_root_dir_obj, NULL, tag, &dd);
 430         if (err != 0) {
 431                 return (err);
 432         }
 433 
 434         while (next != NULL) {
 435                 dsl_dir_t *child_dd;
 436                 err = getcomponent(next, buf, &nextnext);
 437                 if (err != 0)
 438                         break;
 439                 ASSERT(next[0] != '\0');
 440                 if (next[0] == '@')
 441                         break;
 442                 dprintf("looking up %s in obj%lld\n",
 443                     buf, dsl_dir_phys(dd)->dd_child_dir_zapobj);
 444 
 445                 err = zap_lookup(dp->dp_meta_objset,