Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libbe/common/be_snapshot.c
          +++ new/usr/src/lib/libbe/common/be_snapshot.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  /*
  27      - * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
       27 + * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  28   28   */
  29   29  
  30   30  /*
  31   31   * System includes
  32   32   */
  33   33  #include <assert.h>
  34   34  #include <libintl.h>
  35   35  #include <libnvpair.h>
  36   36  #include <libzfs.h>
  37   37  #include <stdio.h>
↓ open down ↓ 278 lines elided ↑ open up ↑
 316  316                              libzfs_error_description(g_zfs));
 317  317                          return (zfs_err_to_be_err(g_zfs));
 318  318                  }
 319  319          }
 320  320  
 321  321          /* Generate string for BE's root dataset */
 322  322          be_make_root_ds(bt.obe_zpool, bt.obe_name, obe_root_ds,
 323  323              sizeof (obe_root_ds));
 324  324          bt.obe_root_ds = obe_root_ds;
 325  325  
      326 +        if (getzoneid() != GLOBAL_ZONEID) {
      327 +                if (!be_zone_compare_uuids(bt.obe_root_ds)) {
      328 +                        be_print_err(gettext("be_rollback: rolling back zone "
      329 +                            "root dataset from non-active global BE is not "
      330 +                            "supported\n"));
      331 +                        return (BE_ERR_NOTSUP);
      332 +                }
      333 +        }
      334 +
 326  335          /* Get handle to BE's root dataset */
 327  336          if ((zhp = zfs_open(g_zfs, bt.obe_root_ds, ZFS_TYPE_DATASET)) == NULL) {
 328  337                  be_print_err(gettext("be_rollback: "
 329  338                      "failed to open BE root dataset (%s): %s\n"),
 330  339                      bt.obe_root_ds, libzfs_error_description(g_zfs));
 331  340                  return (zfs_err_to_be_err(g_zfs));
 332  341          }
 333  342  
 334  343          /*
 335  344           * Check that snapshot name exists for this BE and all of its
↓ open down ↓ 86 lines elided ↑ open up ↑
 422  431                  be_print_err(gettext("be_create_snapshot: "
 423  432                      "zpool_iter failed: %s\n"),
 424  433                      libzfs_error_description(g_zfs));
 425  434                  return (zfs_err_to_be_err(g_zfs));
 426  435          }
 427  436  
 428  437          be_make_root_ds(bt.obe_zpool, bt.obe_name, root_ds,
 429  438              sizeof (root_ds));
 430  439          bt.obe_root_ds = root_ds;
 431  440  
      441 +        if (getzoneid() != GLOBAL_ZONEID) {
      442 +                if (!be_zone_compare_uuids(bt.obe_root_ds)) {
      443 +                        be_print_err(gettext("be_create_snapshot: creating "
      444 +                            "snapshot for the zone root dataset from "
      445 +                            "non-active global BE is not "
      446 +                            "supported\n"));
      447 +                        return (BE_ERR_NOTSUP);
      448 +                }
      449 +        }
      450 +
 432  451          /* If BE policy not specified, use the default policy */
 433  452          if (bt.policy == NULL) {
 434  453                  bt.policy = be_default_policy();
 435  454          } else {
 436  455                  /* Validate policy type */
 437  456                  if (!valid_be_policy(bt.policy)) {
 438  457                          be_print_err(gettext("be_create_snapshot: "
 439  458                              "invalid BE policy type (%s)\n"), bt.policy);
 440  459                          return (BE_ERR_INVAL);
 441  460                  }
↓ open down ↓ 33 lines elided ↑ open up ↑
 475  494                  be_print_err(gettext("be_create_snapshot: failed to "
 476  495                      "get ZFS pool version for %s: %s\n"), zfs_get_name(zhp),
 477  496                      libzfs_error_description(g_zfs));
 478  497          }
 479  498  
 480  499          /*
 481  500           * If ZFS pool version supports snapshot user properties, store
 482  501           * cleanup policy there.  Otherwise don't set one - this snapshot
 483  502           * will always inherit the cleanup policy from its parent.
 484  503           */
 485      -        if (pool_version >= SPA_VERSION_SNAP_PROPS) {
 486      -                if (nvlist_alloc(&ss_props, NV_UNIQUE_NAME, 0) != 0) {
 487      -                        be_print_err(gettext("be_create_snapshot: internal "
 488      -                            "error: out of memory\n"));
 489      -                        return (BE_ERR_NOMEM);
      504 +        if (getzoneid() == GLOBAL_ZONEID) {
      505 +                if (pool_version >= SPA_VERSION_SNAP_PROPS) {
      506 +                        if (nvlist_alloc(&ss_props, NV_UNIQUE_NAME, 0) != 0) {
      507 +                                be_print_err(gettext("be_create_snapshot: "
      508 +                                    "internal error: out of memory\n"));
      509 +                                return (BE_ERR_NOMEM);
      510 +                        }
      511 +                        if (nvlist_add_string(ss_props, BE_POLICY_PROPERTY,
      512 +                            bt.policy) != 0) {
      513 +                                be_print_err(gettext("be_create_snapshot: "
      514 +                                    "internal error: out of memory\n"));
      515 +                                nvlist_free(ss_props);
      516 +                                return (BE_ERR_NOMEM);
      517 +                        }
      518 +                } else if (policy != NULL) {
      519 +                        /*
      520 +                         * If an explicit cleanup policy was requested
      521 +                         * by the caller and we don't support it, error out.
      522 +                         */
      523 +                        be_print_err(gettext("be_create_snapshot: cannot set "
      524 +                            "cleanup policy: ZFS pool version is %d\n"),
      525 +                            pool_version);
      526 +                        return (BE_ERR_NOTSUP);
 490  527                  }
 491      -                if (nvlist_add_string(ss_props, BE_POLICY_PROPERTY, bt.policy)
 492      -                    != 0) {
 493      -                        be_print_err(gettext("be_create_snapshot: internal "
 494      -                            "error: out of memory\n"));
 495      -                        nvlist_free(ss_props);
 496      -                        return (BE_ERR_NOMEM);
 497      -                }
 498      -        } else if (policy != NULL) {
 499      -                /*
 500      -                 * If an explicit cleanup policy was requested
 501      -                 * by the caller and we don't support it, error out.
 502      -                 */
 503      -                be_print_err(gettext("be_create_snapshot: cannot set "
 504      -                    "cleanup policy: ZFS pool version is %d\n"), pool_version);
 505      -                return (BE_ERR_NOTSUP);
 506  528          }
 507  529  
 508  530          /* Create the snapshots recursively */
 509  531          if (zfs_snapshot(g_zfs, ss, B_TRUE, ss_props) != 0) {
 510  532                  if (!autoname || libzfs_errno(g_zfs) != EZFS_EXISTS) {
 511  533                          be_print_err(gettext("be_create_snapshot: "
 512  534                              "recursive snapshot of %s failed: %s\n"),
 513  535                              ss, libzfs_error_description(g_zfs));
 514  536  
 515  537                          if (libzfs_errno(g_zfs) == EZFS_EXISTS)
↓ open down ↓ 275 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX