Whamcloud - gitweb
* Added a file handling snapshot tables
[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 - 50 */
17 #define OBD_SNAP_SETTABLE           _IOWR('f', 40, long)
18 #define OBD_SNAP_PRINTTABLE           _IOWR('f', 41, long)
19
20
21
22 /* if time is 0 this designates the "current" snapshot, i.e.
23    the head of the tree 
24 */
25 struct snap {
26         time_t time;
27         int index;
28 };
29
30 /* snap ioctl data for attach: current always in first slot of this array */
31 struct snap_obd_data {
32         int          snap_dev;  /* which device contains the data */
33         unsigned int snap_index;/* which snapshot is ours */
34         unsigned int snap_table;/* which table do we use */
35 };
36
37
38 /* snap ioctl data for table fiddling */
39 struct snap_table_data {
40         int             tblcmd_no;      /* which table */
41         unsigned int    tblcmd_count;   /* how many snaps */
42         struct snap     tblcmd_snaps[SNAP_MAX]; /* sorted times! */
43 };
44
45
46 struct snap_table {
47         spinlock_t          tbl_lock;
48         unsigned int tbl_count; /* how many snapshots exist in this table*/
49         int tbl_used;  /* bitmap of snaps in use by a device */
50         time_t tbl_times[SNAP_MAX];
51         int tbl_index[SNAP_MAX];
52 };
53
54
55 /* this is the obd device descriptor: 
56    - current snapshot ends up in first slot of this array
57  */
58 struct snap_obd {
59         unsigned int snap_index;  /* which snapshot index are we accessing */
60         int snap_tableno;
61 };
62
63
64 /* stored as inline data in the objects */
65 struct snap_object_data {
66         int od_magic;
67         /* id of snaps of object; slot 0 has the current data */
68         unsigned long od_ids[SNAP_MAX + 1]; 
69 };
70
71 #define this_snapidx(obd) (obd->u.snap.snap_index)
72
73 extern int snap_iocontrol(int cmd, int len, void *karg, void *uarg);
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