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