Whamcloud - gitweb
WARNING: we currently crash on unmount after the last phase of runtests.
[fs/lustre-release.git] / lustre / include / linux / obd.h
index 27aed58..c115d18 100644 (file)
 #include <linux/smp_lock.h>
 #include <linux/proc_fs.h>
 
+#include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
+#include <linux/lustre_mds.h>
+#include <linux/lustre_export.h>
 
 struct obd_type {
         struct list_head typ_chain;
@@ -23,8 +26,6 @@ struct obd_type {
         int  typ_refcnt;
 };
 
-struct io_cb_data;
-typedef int (*brw_callback_t)(struct io_cb_data *, int err, int phase);
 struct brw_page { 
         struct page *pg;
         obd_size count;
@@ -32,6 +33,33 @@ struct brw_page {
         obd_flag flag;
 };
 
+struct lov_oinfo { /* per-child structure */
+        __u64 loi_id;
+        __u64 loi_size;
+};
+
+struct lov_stripe_md {
+        __u32 lmd_magic;
+        __u32 lmd_easize;          /* packed size for MDS of ea */
+        __u64 lmd_object_id;       /* lov object id */
+        __u64 lmd_stripe_offset;   /* offset of the stripe */ 
+        __u64 lmd_stripe_size;     /* size of the stripe */
+        __u32 lmd_stripe_count;    /* how many objects are being striped */
+        __u32 lmd_stripe_pattern;  /* per-lov object stripe pattern */
+        struct lov_oinfo lmd_oinfo[0];
+};
+
+struct lov_stripe_md_one {
+        __u32 lmd_magic;
+        __u32 lmd_easize;          /* packed size for MDS of ea */
+        __u64 lmd_object_id;       /* lov object id */
+        __u64 lmd_stripe_offset;   /* offset of the stripe */ 
+        __u64 lmd_stripe_size;     /* size of the stripe */
+        __u32 lmd_stripe_count;    /* how many objects are being striped */
+        __u32 lmd_stripe_pattern;  /* per-lov object stripe pattern */
+        struct lov_oinfo lmd_oinfo[1];
+};
+
 /* Individual type definitions */
 
 struct ext2_obd {
@@ -50,6 +78,12 @@ struct obd_run_ctxt {
 #endif
 };
 
+#ifdef OBD_CTXT_DEBUG
+#define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
+#else
+#define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
+#endif
+
 struct filter_obd {
         char *fo_fstype;
         struct super_block *fo_sb;
@@ -67,14 +101,11 @@ struct filter_obd {
 struct mds_server_data;
 
 struct client_obd {
-        struct ptlrpc_client *cl_client;
-        struct ptlrpc_client *cl_ldlm_client;
-        struct ptlrpc_connection *cl_conn;
-        struct lustre_handle cl_exporth;
-        struct semaphore cl_sem;
-        int cl_conn_count;
-        __u8 cl_target_uuid[37];
-        int cl_max_mdsize;
+        struct obd_import    cl_import;
+        struct semaphore     cl_sem;
+        int                  cl_conn_count;
+        __u8                 cl_target_uuid[37]; /* XXX -> lustre_name */
+        int                  cl_max_mdsize;
 };
 
 struct mds_obd {
@@ -91,6 +122,7 @@ struct mds_obd {
         struct mds_fs_operations *mds_fsops;
         int mds_max_mdsize;
         struct file *mds_rcvd_filp;
+        spinlock_t mds_last_lock;
         __u64 mds_last_committed;
         __u64 mds_last_rcvd;
         __u64 mds_mount_count;
@@ -117,19 +149,17 @@ struct echo_obd {
 };
 
 struct recovd_obd {
-        time_t                recovd_waketime;
-        time_t                recovd_timeout;
-        struct ptlrpc_service *recovd_service;
-        struct ptlrpc_client  *recovd_client;
-        __u32                  recovd_flags; 
-        __u32                  recovd_wakeup_flag; 
-        spinlock_t             recovd_lock;
-        struct list_head      recovd_clients_lh; /* clients managed  */
-        struct list_head      recovd_troubled_lh; /* clients in trouble */
+        __u32                 recovd_phase;
+        __u32                 recovd_next_phase;
+        __u32                 recovd_flags; 
+        struct recovd_data   *recovd_current_rd;
+        spinlock_t            recovd_lock;
+        struct list_head      recovd_managed_items; /* items managed  */
+        struct list_head      recovd_troubled_items; /* items in trouble */
         wait_queue_head_t     recovd_recovery_waitq;
         wait_queue_head_t     recovd_ctl_waitq;
         wait_queue_head_t     recovd_waitq;
-        struct task_struct    *recovd_thread;
+        struct task_struct   *recovd_thread;
 };
 
 struct trace_obd {
@@ -186,9 +216,12 @@ struct obd_device {
         int obd_minor;
         int obd_flags;
         struct proc_dir_entry *obd_proc_entry;
-        struct list_head obd_exports;
-        struct list_head obd_imports;
+        struct list_head       obd_exports;
+        struct list_head       obd_imports;
         struct ldlm_namespace *obd_namespace;
+        struct ptlrpc_client   obd_ldlm_client; /* XXX OST/MDS only */
+        /* a spinlock is OK for what we do now, may need a semaphore later */
+        spinlock_t obd_dev_lock;
         union {
                 struct ext2_obd ext2;
                 struct filter_obd filter;
@@ -273,4 +306,85 @@ struct obd_ops {
         int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *);
 };
 
+#if BITS_PER_LONG > 32
+#define LPU64 "%lu"
+#define LPD64 "%ld"
+#define LPX64 "%lx"
+#else
+#define LPU64 "%Lu"
+#define LPD64 "%Ld"
+#define LPX64 "%Lx"
+#endif
+
+static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
+                                 int op)
+{
+        return mds->mds_fsops->fs_start(inode, op);
+}
+
+static inline int mds_fs_commit(struct mds_obd *mds, struct inode *inode,
+                                void *handle)
+{
+        return mds->mds_fsops->fs_commit(inode, handle);
+}
+
+static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry,
+                                 void *handle, struct iattr *iattr)
+{
+        int rc;
+        /*
+         * NOTE: we probably don't need to take i_sem here when changing
+         *       ATTR_SIZE because the MDS never needs to truncate a file.
+         *       The ext2/ext3 code never truncates a directory, and files
+         *       stored on the MDS are entirely sparse (no data blocks).
+         *       If we do need to get it, we can do it here.
+         */
+        lock_kernel();
+        rc = mds->mds_fsops->fs_setattr(dentry, handle, iattr);
+        unlock_kernel();
+
+        return rc;
+}
+
+static inline int mds_fs_set_md(struct mds_obd *mds, struct inode *inode,
+                                  void *handle, struct lov_mds_md *md)
+{
+        return mds->mds_fsops->fs_set_md(inode, handle, md);
+}
+
+static inline int mds_fs_get_md(struct mds_obd *mds, struct inode *inode,
+                                  struct lov_mds_md *md)
+{
+        return mds->mds_fsops->fs_get_md(inode, md);
+}
+
+static inline ssize_t mds_fs_readpage(struct mds_obd *mds, struct file *file,
+                                      char *buf, size_t count, loff_t *offset)
+{
+        return mds->mds_fsops->fs_readpage(file, buf, count, offset);
+}
+
+/* Set up callback to update mds->mds_last_committed with the current
+ * value of mds->mds_last_recieved when this transaction is on disk.
+ */
+static inline int mds_fs_set_last_rcvd(struct mds_obd *mds, void *handle)
+{
+        return mds->mds_fsops->fs_set_last_rcvd(mds, handle);
+}
+
+/* Enable data journaling on the given file */
+static inline ssize_t mds_fs_journal_data(struct mds_obd *mds,
+                                          struct file *file)
+{
+        return mds->mds_fsops->fs_journal_data(file);
+}
+
+static inline int mds_fs_statfs(struct mds_obd *mds, struct statfs *sfs)
+{
+        if (mds->mds_fsops->fs_statfs)
+                return mds->mds_fsops->fs_statfs(mds->mds_sb, sfs);
+
+        return vfs_statfs(mds->mds_sb, sfs);
+}
+
 #endif