#define OBD_SNAP_MAGIC 0x47224722
-#define SNAP_MAX 8 /* must fit in "u" area of struct inode */
+
+/* maximum number of snapshot tables we maintain in the kernel */
+#define SNAP_MAX_TABLES 8
+
+
+/* maximum number of snapshots per device
+ must fit in "u" area of struct inode */
+#define SNAP_MAX 8
+
+
+/* ioctls for manipulating snapshots 40 - 60 */
+#define OBD_SNAP_SETTABLE _IOWR('f', 40, long)
+#define OBD_SNAP_PRINTTABLE _IOWR('f', 41, long)
+#define OBD_SNAP_RUNIT _IOWR('f', 42, long)
+
+
/* if time is 0 this designates the "current" snapshot, i.e.
the head of the tree
*/
-
struct snap {
time_t time;
int index;
};
-/* snap ioctl data for attach */
+/* snap ioctl data for attach: current always in first slot of this array */
struct snap_obd_data {
- int snap_dev; /* which device contains the data */
- unsigned int snap_no; /* which snapshot are we accessing */
- unsigned int snap_count; /* how many snapshots exist */
- struct snap snap_snaps[SNAP_MAX]; /* times must be incr or attach will fail */
+ int snap_dev; /* which device contains the data */
+ unsigned int snap_index;/* which snapshot is ours */
+ unsigned int snap_table;/* which table do we use */
+};
+
+
+/* snap ioctl data for table fiddling */
+struct snap_table_data {
+ int tblcmd_no; /* which table */
+ unsigned int tblcmd_count; /* how many snaps */
+ struct snap tblcmd_snaps[SNAP_MAX]; /* sorted times! */
+};
+
+
+struct snap_table {
+ spinlock_t tbl_lock;
+ unsigned int tbl_count; /* how many snapshots exist in this table*/
+ int tbl_used; /* bitmap of snaps in use by a device */
+ time_t tbl_times[SNAP_MAX];
+ int tbl_index[SNAP_MAX];
};
-/* this is the obd device descriptor */
+/* this is the obd device descriptor:
+ - current snapshot ends up in first slot of this array
+ */
struct snap_obd {
- unsigned int snap_no; /* which snapshot index are we accessing */
- unsigned int snap_current;
- unsigned int snap_count; /* how many snapshots exist */
- time_t snap_times[SNAP_MAX];
- int snap_index[SNAP_MAX];
+ unsigned int snap_index; /* which snapshot index are we accessing */
+ int snap_tableno;
};
unsigned long od_ids[SNAP_MAX + 1];
};
+#define this_snapidx(obd) (obd->u.snap.snap_index)
+void snap_use(int table_no, int snap_index) ;
+void snap_unuse(int table_no, int snap_index) ;
+int snap_is_used(int table_no, int snap_index) ;
+int snap_table_attach(int tableno, int snap_index);
#endif