1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_FSSNAP_IF_H 28 #define _SYS_FSSNAP_IF_H 29 30 #include <sys/types.h> 31 #include <sys/fssnap.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* 38 * ioctl's for communicating between the user and the fssnapctl device. 39 * Also used to communicate between fssnapctl and the file system. 40 * Pack fiosnapcreate for amd64 to make struct size same as x86. 41 */ 42 43 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 44 #pragma pack(4) 45 #endif 46 47 struct fiosnapcreate { 48 int rootfiledesc; /* IN fd for root of fs to be snapshotted */ 49 int backfiledesc; /* IN backing store file for snapshot data */ 50 uint_t snapshotnumber; /* OUT snapshot number created */ 51 uint_t chunksize; /* IN chunk size, 0 == fs defined */ 52 u_offset_t maxsize; /* IN maximum size of backing file */ 53 char backfilename[MAXPATHLEN]; /* IN for bookkeeping */ 54 int error; /* OUT error code */ 55 }; 56 57 struct fiosnapcreate_multi { 58 int rootfiledesc; /* IN fd for root of fs to be snapshotted */ 59 uint_t snapshotnumber; /* OUT snapshot number created */ 60 uint_t chunksize; /* IN chunk size, 0 == fs defined */ 61 u_offset_t maxsize; /* IN max size of entire backing store */ 62 char backfilename[MAXPATHLEN]; /* IN for bookkeeping */ 63 int error; /* OUT error code */ 64 int backfilecount; /* IN number of backing store files */ 65 u_offset_t backfilesize; /* IN maximum size of each backfile */ 66 int backfiledesc[1]; /* IN backing store files for snapshot data */ 67 }; 68 69 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 70 #pragma pack() 71 #endif 72 73 struct fiosnapdelete { 74 int rootfiledesc; /* IN fd for root of fs to be unsnapshotted */ 75 uint_t snapshotnumber; /* OUT snapshot number deleted */ 76 int error; /* OUT error code */ 77 }; 78 79 /* ioctl error returns */ 80 #define FIOCOW_EREADONLY (1) /* read only file system */ 81 #define FIOCOW_EBUSY (2) /* snapshot already enabled */ 82 #define FIOCOW_EULOCK (3) /* file system is locked */ 83 #define FIOCOW_EWLOCK (4) /* file system could not be write locked */ 84 #define FIOCOW_EFLUSH (5) /* file system could not be flushed */ 85 #define FIOCOW_ECLEAN (6) /* file system may not be stable */ 86 #define FIOCOW_ENOULOCK (7) /* file system could not be unlocked */ 87 #define FIOCOW_ECHUNKSZ (8) /* chunksize is less than fs fragment size */ 88 #define FIOCOW_ECREATE (9) /* could not allocate/create snapshot */ 89 #define FIOCOW_EBITMAP (10) /* error scanning file system bitmaps */ 90 #define FIOCOW_EBACKFILE (11) /* bad backing file path passed in */ 91 92 /* 93 * make the control device minor number high so minor numbers match 94 * snapshot numbers. 95 */ 96 #define SNAP_CTL_MINOR (L_MAXMIN32) 97 #define SNAP_NAME "fssnap" 98 #define SNAP_CTL_NODE "ctl" 99 #define SNAP_CTL_NAME SNAP_NAME SNAP_CTL_NODE 100 #define SNAP_BLOCK_NAME SNAP_NAME 101 #define SNAP_CHAR_NAME "r" SNAP_NAME 102 103 /* kstat names */ 104 #define FSSNAP_KSTAT_HIGHWATER "highwater" 105 #define FSSNAP_KSTAT_MNTPT "mountpoint" 106 #define FSSNAP_KSTAT_BFNAME "bfname" 107 #define FSSNAP_KSTAT_NUM "numericstats" 108 109 /* numericstats kstat names */ 110 #define FSSNAP_KSTAT_NUM_STATE "state" 111 #define FSSNAP_KSTAT_NUM_BFSIZE "bfsize" 112 #define FSSNAP_KSTAT_NUM_MAXSIZE "maxsize" 113 #define FSSNAP_KSTAT_NUM_CHUNKSIZE "chunksize" 114 #define FSSNAP_KSTAT_NUM_CREATETIME "createtime" 115 116 #if defined(_KERNEL) 117 /* 118 * snapshot operations implemented by the loadable snapshot subsystem 119 */ 120 struct fssnap_operations { 121 void *(*fssnap_create)(chunknumber_t, uint_t, u_offset_t, 122 struct vnode *, int, struct vnode **, char *, u_offset_t); 123 void (*fssnap_set_candidate)(void *, chunknumber_t); 124 int (*fssnap_is_candidate)(void *, u_offset_t); 125 int (*fssnap_create_done)(void *); 126 int (*fssnap_delete)(void *); 127 void (*fssnap_strategy)(void *, struct buf *); 128 }; 129 130 131 /* global variables to manage interface operations */ 132 extern struct fssnap_operations snapops; 133 134 /* External functions called by file systems that use snapshots */ 135 extern int fssnap_init(void); 136 extern int fssnap_fini(void); 137 extern void *fssnap_create(chunknumber_t, uint_t, u_offset_t, struct vnode *, 138 int, struct vnode **, char *, u_offset_t); 139 extern void fssnap_set_candidate(void *, chunknumber_t); 140 extern int fssnap_is_candidate(void *, u_offset_t); 141 extern int fssnap_create_done(void *); 142 extern int fssnap_delete(void *); 143 extern void fssnap_strategy(void *, struct buf *); 144 145 #endif /* _KERNEL */ 146 147 #ifdef __cplusplus 148 } 149 #endif 150 151 #endif /* _SYS_FSSNAP_IF_H */ 152