Whamcloud - gitweb
snap/snap.c: snap_do_cow() fixed case with existing indirect object
[fs/lustre-release.git] / lustre / include / linux / obd_snap.h
index ddb2d8c..53f8986 100644 (file)
@@ -3,26 +3,77 @@
 
 #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: 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 */
-       time_t snap_times[SNAP_MAX];
+       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: 
+   - current snapshot ends up in first slot of this array
+ */
 struct snap_obd {
-       unsigned int snap_no;    /* which snapshot are we accessing */
-       unsigned int snap_count; /* how many snapshots exist */
-       time_t snap_times[SNAP_MAX];
+       unsigned int snap_index;  /* which snapshot index are we accessing */
+       int snap_tableno;
 };
 
+
+/* stored as inline data in the objects */
 struct snap_object_data {
        int od_magic;
        /* id of snaps of object; slot 0 has the current data */
        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