Print this page
2883 changing "canmount" property to "on" should not always remount dataset

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_dataset.c
          +++ new/usr/src/lib/libzfs/common/libzfs_dataset.c
↓ open down ↓ 1440 lines elided ↑ open up ↑
1441 1441          if (prop == ZFS_PROP_MOUNTPOINT && changelist_haszonedchild(cl)) {
1442 1442                  zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1443 1443                      "child dataset with inherited mountpoint is used "
1444 1444                      "in a non-global zone"));
1445 1445                  ret = zfs_error(hdl, EZFS_ZONED, errbuf);
1446 1446                  goto error;
1447 1447          }
1448 1448  
1449 1449          /*
1450 1450           * If the dataset's canmount property is being set to noauto,
     1451 +         * or being set to on and the dataset is already mounted,
1451 1452           * then we want to prevent unmounting & remounting it.
1452 1453           */
1453 1454          do_prefix = !((prop == ZFS_PROP_CANMOUNT) &&
1454 1455              (zprop_string_to_index(prop, propval, &idx,
1455      -            ZFS_TYPE_DATASET) == 0) && (idx == ZFS_CANMOUNT_NOAUTO));
     1456 +            ZFS_TYPE_DATASET) == 0) && (idx == ZFS_CANMOUNT_NOAUTO ||
     1457 +            (idx == ZFS_CANMOUNT_ON && zfs_is_mounted(zhp, NULL))));
1456 1458  
1457 1459          if (do_prefix && (ret = changelist_prefix(cl)) != 0)
1458 1460                  goto error;
1459 1461  
1460 1462          /*
1461 1463           * Execute the corresponding ioctl() to set this property.
1462 1464           */
1463 1465          (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
1464 1466  
1465 1467          if (zcmd_write_src_nvlist(hdl, &zc, nvl) != 0)
↓ open down ↓ 2894 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX