Whamcloud - gitweb
53f89868c82a35f0e524283e87c37a8f0c04996d
[fs/lustre-release.git] / lustre / include / linux / obd_snap.h
1 #ifndef _OBD_SNAP
2 #define _OBD_SNAP
3
4 #define OBD_SNAP_MAGIC 0x47224722
5
6
7 /* maximum number of snapshot tables we maintain in the kernel */
8 #define SNAP_MAX_TABLES 8
9
10
11 /* maximum number of snapshots per device 
12    must fit in "u" area of struct inode */
13 #define SNAP_MAX  8 
14
15
16 /* ioctls for manipulating snapshots 40 - 60 */
17 #define OBD_SNAP_SETTABLE       _IOWR('f', 40, long)
18 #define OBD_SNAP_PRINTTABLE     _IOWR('f', 41, long)
19 #define OBD_SNAP_RUNIT          _IOWR('f', 42, long)
20
21
22
23 /* if time is 0 this designates the "current" snapshot, i.e.
24    the head of the tree 
25 */
26 struct snap {
27         time_t time;
28         int index;
29 };
30
31 /* snap ioctl data for attach: current always in first slot of this array */
32 struct snap_obd_data {
33         int          snap_dev;  /* which device contains the data */
34         unsigned int snap_index;/* which snapshot is ours */
35         unsigned int snap_table;/* which table do we use */
36 };
37
38
39 /* snap ioctl data for table fiddling */
40 struct snap_table_data {
41         int             tblcmd_no;      /* which table */
42         unsigned int    tblcmd_count;   /* how many snaps */
43         struct snap     tblcmd_snaps[SNAP_MAX]; /* sorted times! */
44 };
45
46
47 struct snap_table {
48         spinlock_t          tbl_lock;
49         unsigned int tbl_count; /* how many snapshots exist in this table*/
50         int tbl_used;  /* bitmap of snaps in use by a device */
51         time_t tbl_times[SNAP_MAX];
52         int tbl_index[SNAP_MAX];
53 };
54
55
56 /* this is the obd device descriptor: 
57    - current snapshot ends up in first slot of this array
58  */
59 struct snap_obd {
60         unsigned int snap_index;  /* which snapshot index are we accessing */
61         int snap_tableno;
62 };
63
64
65 /* stored as inline data in the objects */
66 struct snap_object_data {
67         int od_magic;
68         /* id of snaps of object; slot 0 has the current data */
69         unsigned long od_ids[SNAP_MAX + 1]; 
70 };
71
72 #define this_snapidx(obd) (obd->u.snap.snap_index)
73
74 void snap_use(int table_no, int snap_index) ;
75 void snap_unuse(int table_no, int snap_index) ;
76 int snap_is_used(int table_no, int snap_index) ;
77 int snap_table_attach(int tableno, int snap_index);
78
79 #endif