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