Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>


  35 
  36 #ifdef  __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 /*
  41  * Types and constants shared between userland and the kernel.
  42  */
  43 
  44 /*
  45  * Each dataset can be one of the following types.  These constants can be
  46  * combined into masks that can be passed to various functions.
  47  */
  48 typedef enum {
  49         ZFS_TYPE_FILESYSTEM     = 0x1,
  50         ZFS_TYPE_SNAPSHOT       = 0x2,
  51         ZFS_TYPE_VOLUME         = 0x4,
  52         ZFS_TYPE_POOL           = 0x8
  53 } zfs_type_t;
  54 










  55 #define ZFS_TYPE_DATASET        \
  56         (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
  57 
  58 #define ZAP_MAXNAMELEN 256
  59 #define ZAP_MAXVALUELEN (1024 * 8)
  60 #define ZAP_OLDMAXVALUELEN 1024
  61 
  62 /*
  63  * Dataset properties are identified by these constants and must be added to
  64  * the end of this list to ensure that external consumers are not affected
  65  * by the change. If you make any changes to this list, be sure to update
  66  * the property table in usr/src/common/zfs/zfs_prop.c.
  67  */
  68 typedef enum {
  69         ZFS_PROP_TYPE,
  70         ZFS_PROP_CREATION,
  71         ZFS_PROP_USED,
  72         ZFS_PROP_AVAILABLE,
  73         ZFS_PROP_REFERENCED,
  74         ZFS_PROP_COMPRESSRATIO,


 727 } ddt_histogram_t;
 728 
 729 #define ZVOL_DRIVER     "zvol"
 730 #define ZFS_DRIVER      "zfs"
 731 #define ZFS_DEV         "/dev/zfs"
 732 
 733 /* general zvol path */
 734 #define ZVOL_DIR                "/dev/zvol"
 735 /* expansion */
 736 #define ZVOL_PSEUDO_DEV         "/devices/pseudo/zfs@0:"
 737 /* for dump and swap */
 738 #define ZVOL_FULL_DEV_DIR       ZVOL_DIR "/dsk/"
 739 #define ZVOL_FULL_RDEV_DIR      ZVOL_DIR "/rdsk/"
 740 
 741 #define ZVOL_PROP_NAME          "name"
 742 #define ZVOL_DEFAULT_BLOCKSIZE  8192
 743 
 744 /*
 745  * /dev/zfs ioctl numbers.
 746  */
 747 #define ZFS_IOC         ('Z' << 8)
 748 
 749 typedef enum zfs_ioc {
 750         ZFS_IOC_POOL_CREATE = ZFS_IOC,


 751         ZFS_IOC_POOL_DESTROY,
 752         ZFS_IOC_POOL_IMPORT,
 753         ZFS_IOC_POOL_EXPORT,
 754         ZFS_IOC_POOL_CONFIGS,
 755         ZFS_IOC_POOL_STATS,
 756         ZFS_IOC_POOL_TRYIMPORT,
 757         ZFS_IOC_POOL_SCAN,
 758         ZFS_IOC_POOL_FREEZE,
 759         ZFS_IOC_POOL_UPGRADE,
 760         ZFS_IOC_POOL_GET_HISTORY,
 761         ZFS_IOC_VDEV_ADD,
 762         ZFS_IOC_VDEV_REMOVE,
 763         ZFS_IOC_VDEV_SET_STATE,
 764         ZFS_IOC_VDEV_ATTACH,
 765         ZFS_IOC_VDEV_DETACH,
 766         ZFS_IOC_VDEV_SETPATH,
 767         ZFS_IOC_VDEV_SETFRU,
 768         ZFS_IOC_OBJSET_STATS,
 769         ZFS_IOC_OBJSET_ZPLPROPS,
 770         ZFS_IOC_DATASET_LIST_NEXT,


 789         ZFS_IOC_POOL_GET_PROPS,
 790         ZFS_IOC_SET_FSACL,
 791         ZFS_IOC_GET_FSACL,
 792         ZFS_IOC_SHARE,
 793         ZFS_IOC_INHERIT_PROP,
 794         ZFS_IOC_SMB_ACL,
 795         ZFS_IOC_USERSPACE_ONE,
 796         ZFS_IOC_USERSPACE_MANY,
 797         ZFS_IOC_USERSPACE_UPGRADE,
 798         ZFS_IOC_HOLD,
 799         ZFS_IOC_RELEASE,
 800         ZFS_IOC_GET_HOLDS,
 801         ZFS_IOC_OBJSET_RECVD_PROPS,
 802         ZFS_IOC_VDEV_SPLIT,
 803         ZFS_IOC_NEXT_OBJ,
 804         ZFS_IOC_DIFF,
 805         ZFS_IOC_TMP_SNAPSHOT,
 806         ZFS_IOC_OBJ_TO_STATS,
 807         ZFS_IOC_SPACE_WRITTEN,
 808         ZFS_IOC_SPACE_SNAPS,
 809         ZFS_IOC_DESTROY_SNAPS_NVL,
 810         ZFS_IOC_POOL_REGUID,
 811         ZFS_IOC_POOL_REOPEN,
 812         ZFS_IOC_SEND_PROGRESS





 813 } zfs_ioc_t;
 814 
 815 /*
 816  * Internal SPA load state.  Used by FMA diagnosis engine.
 817  */
 818 typedef enum {
 819         SPA_LOAD_NONE,          /* no load in progress  */
 820         SPA_LOAD_OPEN,          /* normal open          */
 821         SPA_LOAD_IMPORT,        /* import in progress   */
 822         SPA_LOAD_TRYIMPORT,     /* tryimport in progress */
 823         SPA_LOAD_RECOVER,       /* recovery requested   */
 824         SPA_LOAD_ERROR          /* load failed          */
 825 } spa_load_state_t;
 826 
 827 /*
 828  * Bookmark name values.
 829  */
 830 #define ZPOOL_ERR_LIST          "error list"
 831 #define ZPOOL_ERR_DATASET       "dataset"
 832 #define ZPOOL_ERR_OBJECT        "object"
 833 
 834 #define HIS_MAX_RECORD_LEN      (MAXPATHLEN + MAXPATHLEN + 1)
 835 
 836 /*
 837  * The following are names used in the nvlist describing
 838  * the pool's history log.
 839  */
 840 #define ZPOOL_HIST_RECORD       "history record"
 841 #define ZPOOL_HIST_TIME         "history time"
 842 #define ZPOOL_HIST_CMD          "history command"
 843 #define ZPOOL_HIST_WHO          "history who"
 844 #define ZPOOL_HIST_ZONE         "history zone"
 845 #define ZPOOL_HIST_HOST         "history hostname"
 846 #define ZPOOL_HIST_TXG          "history txg"
 847 #define ZPOOL_HIST_INT_EVENT    "history internal event"
 848 #define ZPOOL_HIST_INT_STR      "history internal str"






 849 
 850 /*
 851  * Flags for ZFS_IOC_VDEV_SET_STATE
 852  */
 853 #define ZFS_ONLINE_CHECKREMOVE  0x1
 854 #define ZFS_ONLINE_UNSPARE      0x2
 855 #define ZFS_ONLINE_FORCEFAULT   0x4
 856 #define ZFS_ONLINE_EXPAND       0x8
 857 #define ZFS_OFFLINE_TEMPORARY   0x1
 858 
 859 /*
 860  * Flags for ZFS_IOC_POOL_IMPORT
 861  */
 862 #define ZFS_IMPORT_NORMAL       0x0
 863 #define ZFS_IMPORT_VERBATIM     0x1
 864 #define ZFS_IMPORT_ANY_HOST     0x2
 865 #define ZFS_IMPORT_MISSING_LOG  0x4
 866 #define ZFS_IMPORT_ONLY         0x8
 867 
 868 /*


 874  *      ESC_ZFS_POOL_DESTROY
 875  *      ESC_ZFS_POOL_REGUID
 876  *
 877  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
 878  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
 879  *
 880  *      ESC_ZFS_VDEV_REMOVE
 881  *      ESC_ZFS_VDEV_CLEAR
 882  *      ESC_ZFS_VDEV_CHECK
 883  *
 884  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
 885  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
 886  *              ZFS_EV_VDEV_PATH        DATA_TYPE_STRING        (optional)
 887  *              ZFS_EV_VDEV_GUID        DATA_TYPE_UINT64
 888  */
 889 #define ZFS_EV_POOL_NAME        "pool_name"
 890 #define ZFS_EV_POOL_GUID        "pool_guid"
 891 #define ZFS_EV_VDEV_PATH        "vdev_path"
 892 #define ZFS_EV_VDEV_GUID        "vdev_guid"
 893 
 894 /*
 895  * Note: This is encoded on-disk, so new events must be added to the
 896  * end, and unused events can not be removed.  Be sure to edit
 897  * libzfs_pool.c: hist_event_table[].
 898  */
 899 typedef enum history_internal_events {
 900         LOG_NO_EVENT = 0,
 901         LOG_POOL_CREATE,
 902         LOG_POOL_VDEV_ADD,
 903         LOG_POOL_REMOVE,
 904         LOG_POOL_DESTROY,
 905         LOG_POOL_EXPORT,
 906         LOG_POOL_IMPORT,
 907         LOG_POOL_VDEV_ATTACH,
 908         LOG_POOL_VDEV_REPLACE,
 909         LOG_POOL_VDEV_DETACH,
 910         LOG_POOL_VDEV_ONLINE,
 911         LOG_POOL_VDEV_OFFLINE,
 912         LOG_POOL_UPGRADE,
 913         LOG_POOL_CLEAR,
 914         LOG_POOL_SCAN,
 915         LOG_POOL_PROPSET,
 916         LOG_DS_CREATE,
 917         LOG_DS_CLONE,
 918         LOG_DS_DESTROY,
 919         LOG_DS_DESTROY_BEGIN,
 920         LOG_DS_INHERIT,
 921         LOG_DS_PROPSET,
 922         LOG_DS_QUOTA,
 923         LOG_DS_PERM_UPDATE,
 924         LOG_DS_PERM_REMOVE,
 925         LOG_DS_PERM_WHO_REMOVE,
 926         LOG_DS_PROMOTE,
 927         LOG_DS_RECEIVE,
 928         LOG_DS_RENAME,
 929         LOG_DS_RESERVATION,
 930         LOG_DS_REPLAY_INC_SYNC,
 931         LOG_DS_REPLAY_FULL_SYNC,
 932         LOG_DS_ROLLBACK,
 933         LOG_DS_SNAPSHOT,
 934         LOG_DS_UPGRADE,
 935         LOG_DS_REFQUOTA,
 936         LOG_DS_REFRESERV,
 937         LOG_POOL_SCAN_DONE,
 938         LOG_DS_USER_HOLD,
 939         LOG_DS_USER_RELEASE,
 940         LOG_POOL_SPLIT,
 941         LOG_END
 942 } history_internal_events_t;
 943 
 944 #ifdef  __cplusplus
 945 }
 946 #endif
 947 
 948 #endif  /* _SYS_FS_ZFS_H */


  35 
  36 #ifdef  __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 /*
  41  * Types and constants shared between userland and the kernel.
  42  */
  43 
  44 /*
  45  * Each dataset can be one of the following types.  These constants can be
  46  * combined into masks that can be passed to various functions.
  47  */
  48 typedef enum {
  49         ZFS_TYPE_FILESYSTEM     = 0x1,
  50         ZFS_TYPE_SNAPSHOT       = 0x2,
  51         ZFS_TYPE_VOLUME         = 0x4,
  52         ZFS_TYPE_POOL           = 0x8
  53 } zfs_type_t;
  54 
  55 typedef enum dmu_objset_type {
  56         DMU_OST_NONE,
  57         DMU_OST_META,
  58         DMU_OST_ZFS,
  59         DMU_OST_ZVOL,
  60         DMU_OST_OTHER,                  /* For testing only! */
  61         DMU_OST_ANY,                    /* Be careful! */
  62         DMU_OST_NUMTYPES
  63 } dmu_objset_type_t;
  64 
  65 #define ZFS_TYPE_DATASET        \
  66         (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
  67 
  68 #define ZAP_MAXNAMELEN 256
  69 #define ZAP_MAXVALUELEN (1024 * 8)
  70 #define ZAP_OLDMAXVALUELEN 1024
  71 
  72 /*
  73  * Dataset properties are identified by these constants and must be added to
  74  * the end of this list to ensure that external consumers are not affected
  75  * by the change. If you make any changes to this list, be sure to update
  76  * the property table in usr/src/common/zfs/zfs_prop.c.
  77  */
  78 typedef enum {
  79         ZFS_PROP_TYPE,
  80         ZFS_PROP_CREATION,
  81         ZFS_PROP_USED,
  82         ZFS_PROP_AVAILABLE,
  83         ZFS_PROP_REFERENCED,
  84         ZFS_PROP_COMPRESSRATIO,


 737 } ddt_histogram_t;
 738 
 739 #define ZVOL_DRIVER     "zvol"
 740 #define ZFS_DRIVER      "zfs"
 741 #define ZFS_DEV         "/dev/zfs"
 742 
 743 /* general zvol path */
 744 #define ZVOL_DIR                "/dev/zvol"
 745 /* expansion */
 746 #define ZVOL_PSEUDO_DEV         "/devices/pseudo/zfs@0:"
 747 /* for dump and swap */
 748 #define ZVOL_FULL_DEV_DIR       ZVOL_DIR "/dsk/"
 749 #define ZVOL_FULL_RDEV_DIR      ZVOL_DIR "/rdsk/"
 750 
 751 #define ZVOL_PROP_NAME          "name"
 752 #define ZVOL_DEFAULT_BLOCKSIZE  8192
 753 
 754 /*
 755  * /dev/zfs ioctl numbers.
 756  */


 757 typedef enum zfs_ioc {
 758         ZFS_IOC_FIRST = ('Z' << 8),
 759         ZFS_IOC = ZFS_IOC_FIRST,
 760         ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
 761         ZFS_IOC_POOL_DESTROY,
 762         ZFS_IOC_POOL_IMPORT,
 763         ZFS_IOC_POOL_EXPORT,
 764         ZFS_IOC_POOL_CONFIGS,
 765         ZFS_IOC_POOL_STATS,
 766         ZFS_IOC_POOL_TRYIMPORT,
 767         ZFS_IOC_POOL_SCAN,
 768         ZFS_IOC_POOL_FREEZE,
 769         ZFS_IOC_POOL_UPGRADE,
 770         ZFS_IOC_POOL_GET_HISTORY,
 771         ZFS_IOC_VDEV_ADD,
 772         ZFS_IOC_VDEV_REMOVE,
 773         ZFS_IOC_VDEV_SET_STATE,
 774         ZFS_IOC_VDEV_ATTACH,
 775         ZFS_IOC_VDEV_DETACH,
 776         ZFS_IOC_VDEV_SETPATH,
 777         ZFS_IOC_VDEV_SETFRU,
 778         ZFS_IOC_OBJSET_STATS,
 779         ZFS_IOC_OBJSET_ZPLPROPS,
 780         ZFS_IOC_DATASET_LIST_NEXT,


 799         ZFS_IOC_POOL_GET_PROPS,
 800         ZFS_IOC_SET_FSACL,
 801         ZFS_IOC_GET_FSACL,
 802         ZFS_IOC_SHARE,
 803         ZFS_IOC_INHERIT_PROP,
 804         ZFS_IOC_SMB_ACL,
 805         ZFS_IOC_USERSPACE_ONE,
 806         ZFS_IOC_USERSPACE_MANY,
 807         ZFS_IOC_USERSPACE_UPGRADE,
 808         ZFS_IOC_HOLD,
 809         ZFS_IOC_RELEASE,
 810         ZFS_IOC_GET_HOLDS,
 811         ZFS_IOC_OBJSET_RECVD_PROPS,
 812         ZFS_IOC_VDEV_SPLIT,
 813         ZFS_IOC_NEXT_OBJ,
 814         ZFS_IOC_DIFF,
 815         ZFS_IOC_TMP_SNAPSHOT,
 816         ZFS_IOC_OBJ_TO_STATS,
 817         ZFS_IOC_SPACE_WRITTEN,
 818         ZFS_IOC_SPACE_SNAPS,
 819         ZFS_IOC_DESTROY_SNAPS,
 820         ZFS_IOC_POOL_REGUID,
 821         ZFS_IOC_POOL_REOPEN,
 822         ZFS_IOC_SEND_PROGRESS,
 823         ZFS_IOC_LOG_HISTORY,
 824         ZFS_IOC_SEND_NEW,
 825         ZFS_IOC_SEND_SPACE,
 826         ZFS_IOC_CLONE,
 827         ZFS_IOC_LAST
 828 } zfs_ioc_t;
 829 
 830 /*
 831  * Internal SPA load state.  Used by FMA diagnosis engine.
 832  */
 833 typedef enum {
 834         SPA_LOAD_NONE,          /* no load in progress  */
 835         SPA_LOAD_OPEN,          /* normal open          */
 836         SPA_LOAD_IMPORT,        /* import in progress   */
 837         SPA_LOAD_TRYIMPORT,     /* tryimport in progress */
 838         SPA_LOAD_RECOVER,       /* recovery requested   */
 839         SPA_LOAD_ERROR          /* load failed          */
 840 } spa_load_state_t;
 841 
 842 /*
 843  * Bookmark name values.
 844  */
 845 #define ZPOOL_ERR_LIST          "error list"
 846 #define ZPOOL_ERR_DATASET       "dataset"
 847 #define ZPOOL_ERR_OBJECT        "object"
 848 
 849 #define HIS_MAX_RECORD_LEN      (MAXPATHLEN + MAXPATHLEN + 1)
 850 
 851 /*
 852  * The following are names used in the nvlist describing
 853  * the pool's history log.
 854  */
 855 #define ZPOOL_HIST_RECORD       "history record"
 856 #define ZPOOL_HIST_TIME         "history time"
 857 #define ZPOOL_HIST_CMD          "history command"
 858 #define ZPOOL_HIST_WHO          "history who"
 859 #define ZPOOL_HIST_ZONE         "history zone"
 860 #define ZPOOL_HIST_HOST         "history hostname"
 861 #define ZPOOL_HIST_TXG          "history txg"
 862 #define ZPOOL_HIST_INT_EVENT    "history internal event"
 863 #define ZPOOL_HIST_INT_STR      "history internal str"
 864 #define ZPOOL_HIST_INT_NAME     "internal_name"
 865 #define ZPOOL_HIST_IOCTL        "ioctl"
 866 #define ZPOOL_HIST_INPUT_NVL    "in_nvl"
 867 #define ZPOOL_HIST_OUTPUT_NVL   "out_nvl"
 868 #define ZPOOL_HIST_DSNAME       "dsname"
 869 #define ZPOOL_HIST_DSID         "dsid"
 870 
 871 /*
 872  * Flags for ZFS_IOC_VDEV_SET_STATE
 873  */
 874 #define ZFS_ONLINE_CHECKREMOVE  0x1
 875 #define ZFS_ONLINE_UNSPARE      0x2
 876 #define ZFS_ONLINE_FORCEFAULT   0x4
 877 #define ZFS_ONLINE_EXPAND       0x8
 878 #define ZFS_OFFLINE_TEMPORARY   0x1
 879 
 880 /*
 881  * Flags for ZFS_IOC_POOL_IMPORT
 882  */
 883 #define ZFS_IMPORT_NORMAL       0x0
 884 #define ZFS_IMPORT_VERBATIM     0x1
 885 #define ZFS_IMPORT_ANY_HOST     0x2
 886 #define ZFS_IMPORT_MISSING_LOG  0x4
 887 #define ZFS_IMPORT_ONLY         0x8
 888 
 889 /*


 895  *      ESC_ZFS_POOL_DESTROY
 896  *      ESC_ZFS_POOL_REGUID
 897  *
 898  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
 899  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
 900  *
 901  *      ESC_ZFS_VDEV_REMOVE
 902  *      ESC_ZFS_VDEV_CLEAR
 903  *      ESC_ZFS_VDEV_CHECK
 904  *
 905  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
 906  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
 907  *              ZFS_EV_VDEV_PATH        DATA_TYPE_STRING        (optional)
 908  *              ZFS_EV_VDEV_GUID        DATA_TYPE_UINT64
 909  */
 910 #define ZFS_EV_POOL_NAME        "pool_name"
 911 #define ZFS_EV_POOL_GUID        "pool_guid"
 912 #define ZFS_EV_VDEV_PATH        "vdev_path"
 913 #define ZFS_EV_VDEV_GUID        "vdev_guid"
 914 


















































 915 #ifdef  __cplusplus
 916 }
 917 #endif
 918 
 919 #endif  /* _SYS_FS_ZFS_H */