Print this page
Use the LZ4 algorithm to compress metadata when the corresponding feature is enabled


  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 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Portions Copyright 2011 Martin Matuska
  25  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  27  * Copyright (c) 2013 by Delphix. All rights reserved.
  28  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  29  * Copyright (c) 2013 Steven Hartland. All rights reserved.

  30  */
  31 
  32 /*
  33  * ZFS ioctls.
  34  *
  35  * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  36  * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  37  *
  38  * There are two ways that we handle ioctls: the legacy way where almost
  39  * all of the logic is in the ioctl callback, and the new way where most
  40  * of the marshalling is handled in the common entry point, zfsdev_ioctl().
  41  *
  42  * Non-legacy ioctls should be registered by calling
  43  * zfs_ioctl_register() from zfs_ioctl_init().  The ioctl is invoked
  44  * from userland by lzc_ioctl().
  45  *
  46  * The registration arguments are as follows:
  47  *
  48  * const char *name
  49  *   The name of the ioctl.  This is used for history logging.  If the


2436         case ZFS_PROP_VERSION:
2437         {
2438                 zfsvfs_t *zfsvfs;
2439 
2440                 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
2441                         break;
2442 
2443                 err = zfs_set_version(zfsvfs, intval);
2444                 zfsvfs_rele(zfsvfs, FTAG);
2445 
2446                 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) {
2447                         zfs_cmd_t *zc;
2448 
2449                         zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
2450                         (void) strcpy(zc->zc_name, dsname);
2451                         (void) zfs_ioc_userspace_upgrade(zc);
2452                         kmem_free(zc, sizeof (zfs_cmd_t));
2453                 }
2454                 break;
2455         }
2456         case ZFS_PROP_COMPRESSION:
2457         {
2458                 if (intval == ZIO_COMPRESS_LZ4) {
2459                         spa_t *spa;
2460 
2461                         if ((err = spa_open(dsname, &spa, FTAG)) != 0)
2462                                 return (err);
2463 
2464                         /*
2465                          * Setting the LZ4 compression algorithm activates
2466                          * the feature.
2467                          */
2468                         if (!spa_feature_is_active(spa,
2469                             SPA_FEATURE_LZ4_COMPRESS)) {
2470                                 if ((err = zfs_prop_activate_feature(spa,
2471                                     SPA_FEATURE_LZ4_COMPRESS)) != 0) {
2472                                         spa_close(spa, FTAG);
2473                                         return (err);
2474                                 }
2475                         }
2476 
2477                         spa_close(spa, FTAG);
2478                 }
2479                 /*
2480                  * We still want the default set action to be performed in the
2481                  * caller, we only performed zfeature settings here.
2482                  */
2483                 err = -1;
2484                 break;
2485         }
2486 
2487         default:
2488                 err = -1;
2489         }
2490 
2491         return (err);
2492 }
2493 
2494 /*
2495  * This function is best effort. If it fails to set any of the given properties,
2496  * it continues to set as many as it can and returns the last error
2497  * encountered. If the caller provides a non-NULL errlist, it will be filled in
2498  * with the list of names of all the properties that failed along with the
2499  * corresponding error numbers.
2500  *
2501  * If every property is set successfully, zero is returned and errlist is not
2502  * modified.
2503  */
2504 int
2505 zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
2506     nvlist_t *errlist)




  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 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Portions Copyright 2011 Martin Matuska
  25  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  27  * Copyright (c) 2013 by Delphix. All rights reserved.
  28  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  29  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  30  * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
  31  */
  32 
  33 /*
  34  * ZFS ioctls.
  35  *
  36  * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  37  * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  38  *
  39  * There are two ways that we handle ioctls: the legacy way where almost
  40  * all of the logic is in the ioctl callback, and the new way where most
  41  * of the marshalling is handled in the common entry point, zfsdev_ioctl().
  42  *
  43  * Non-legacy ioctls should be registered by calling
  44  * zfs_ioctl_register() from zfs_ioctl_init().  The ioctl is invoked
  45  * from userland by lzc_ioctl().
  46  *
  47  * The registration arguments are as follows:
  48  *
  49  * const char *name
  50  *   The name of the ioctl.  This is used for history logging.  If the


2437         case ZFS_PROP_VERSION:
2438         {
2439                 zfsvfs_t *zfsvfs;
2440 
2441                 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
2442                         break;
2443 
2444                 err = zfs_set_version(zfsvfs, intval);
2445                 zfsvfs_rele(zfsvfs, FTAG);
2446 
2447                 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) {
2448                         zfs_cmd_t *zc;
2449 
2450                         zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
2451                         (void) strcpy(zc->zc_name, dsname);
2452                         (void) zfs_ioc_userspace_upgrade(zc);
2453                         kmem_free(zc, sizeof (zfs_cmd_t));
2454                 }
2455                 break;
2456         }































2457         default:
2458                 err = -1;
2459         }
2460 
2461         return (err);
2462 }
2463 
2464 /*
2465  * This function is best effort. If it fails to set any of the given properties,
2466  * it continues to set as many as it can and returns the last error
2467  * encountered. If the caller provides a non-NULL errlist, it will be filled in
2468  * with the list of names of all the properties that failed along with the
2469  * corresponding error numbers.
2470  *
2471  * If every property is set successfully, zero is returned and errlist is not
2472  * modified.
2473  */
2474 int
2475 zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
2476     nvlist_t *errlist)