Whamcloud - gitweb
- ext2_obd.c --- fix the bugs in read/write for Linux 2.4.3
[fs/lustre-release.git] / lustre / include / linux / obd_snap_support.h
1 #ifndef __OBD_SNAP_SUPP_H
2 #define __OBD_SNAP_SUPP_H
3 /*
4  * Copyright (C) 2001  Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 /* What we use to point to IDs in the obdmd data for snapshots.  If we use
11  * obd_id (8 bytes) instead of ino_t (4 bytes), we halve the number of
12  * available snapshot slots (14 in 56 bytes vs. 7 in 56 bytes until we
13  * increase the size of OBD_OBDMDSZ).
14  */
15 typedef ino_t   snap_id;
16
17 /* maximum number of snapshot tables we maintain in the kernel */
18 #define SNAP_MAX_TABLES 8
19
20 /* maximum number of snapshots per device 
21    must fit in "o_obdmd" area of struct obdo */
22 #define SNAP_MAX ((OBD_OBDMDSZ - sizeof(uint32_t))/sizeof(snap_id))
23
24 struct snap_md {
25         uint32_t m_magic;
26         snap_id  m_ids[SNAP_MAX];       /* id of snaps; slot 0 has current id */
27 };
28
29
30 /* if time is 0 this designates the "current" snapshot, i.e.
31    the head of the tree 
32 */
33 struct snap {
34         time_t time;
35         int index;
36 };
37
38 /* snap ioctl data for attach: current always in first slot of this array */
39 struct snap_obd_data {
40         int          snap_dev;  /* which device contains the data */
41         unsigned int snap_index;/* which snapshot is ours */
42         unsigned int snap_table;/* which table do we use */
43 };
44
45
46 /* snap ioctl data for table fiddling */
47 struct snap_table_data {
48         int             tblcmd_no;      /* which table */
49         unsigned int    tblcmd_count;   /* how many snaps */
50         struct snap     tblcmd_snaps[SNAP_MAX]; /* sorted times! */
51 };
52
53
54 struct snap_table {
55         spinlock_t          tbl_lock;
56         unsigned int tbl_count; /* how many snapshots exist in this table*/
57         int tbl_used;  /* bitmap of snaps in use by a device */
58         time_t tbl_times[SNAP_MAX];
59         int tbl_index[SNAP_MAX];
60 };
61
62 struct snap_iterdata {
63         struct obd_conn *conn;
64         struct obd_conn *ch_conn;
65         int index;
66         int previndex;
67         int currentindex;
68         int prevslot;
69         time_t prevtime;
70 };
71
72 inline struct obd_conn *child_conn(struct obd_conn *conn);
73 int snap_deleteobj(obd_id id, obd_gr group, void *data);
74 int snap_restoreobj(obd_id id, obd_gr group, void *data);
75 int snap_printobj(obd_id id, obd_gr group, void *data);
76 int snap_iocontrol(int cmd, struct obd_conn *conn, int len, void *karg, void *uarg);
77
78 /* In the future, this function may have to deal with offsets into the obdmd.
79  * Currently, we assume we have the whole obdmd struct.
80  */
81 static __inline__ struct snap_md *snap_obdmd(struct obdo *oa)
82 {
83         return ((struct snap_md *)(&oa->o_obdmd));
84 }
85 #endif