Whamcloud - gitweb
We touched everything, but it's not as scary as it looks.
authorpschwan <pschwan>
Sun, 10 Mar 2002 19:08:09 +0000 (19:08 +0000)
committerpschwan <pschwan>
Sun, 10 Mar 2002 19:08:09 +0000 (19:08 +0000)
- dramatically reorganized and simplified the headers.  Most of the nasty
  recursive definitions are gone, and obd_class.h no longer drags in the
  entirety of Lustre.
- .cvsignores updated and cleaned
- added another chunk of DLM code and a test, which passes (note that it doesn't
  free the locks yet, so don't expect to cleanup afterwards)
- fixed OBD_ALLOC/OBD_FREE in the same ways as the Portals macros
- removed a lot of dead obd_class code

34 files changed:
lustre/.cvsignore
lustre/include/linux/lustre_dlm.h
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_light.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/include/linux/obd_echo.h
lustre/include/linux/obd_ext2.h
lustre/include/linux/obd_filter.h
lustre/include/linux/obd_osc.h [deleted file]
lustre/include/linux/obd_ost.h
lustre/include/linux/obd_raid1.h
lustre/include/linux/obd_snap.h
lustre/include/linux/obd_support.h
lustre/include/linux/obd_trace.h
lustre/ldlm/.cvsignore [new file with mode: 0644]
lustre/ldlm/Makefile.am
lustre/ldlm/ldlm_lock.c [new file with mode: 0644]
lustre/ldlm/ldlm_test.c [new file with mode: 0644]
lustre/ldlm/resource.c
lustre/lib/mds_pack.c
lustre/lib/mds_updates.c
lustre/llite/file.c
lustre/llite/super.c
lustre/mds/handler.c
lustre/obdclass/class_obd.c
lustre/obdfilter/filter.c
lustre/obdfs/namei.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/tests/common.sh
lustre/tests/llmount.sh
lustre/utils/obdctl.c

index 067f05c..2172c53 100644 (file)
@@ -1,6 +1,8 @@
 .Xrefs
+aclocal.m4
 config.log
 config.status
+config.cache
 configure
 Makefile
 Makefile.in
index ea9ae71..da191eb 100644 (file)
@@ -8,22 +8,33 @@
 #include <linux/kp30.h>
 #include <linux/list.h>
 
+#include <linux/obd_class.h>
+
+#ifdef __KERNEL__
+
 #define OBD_LDLM_DEVICENAME  "ldlm"
 
 typedef  int cluster_host;
 typedef  int cluster_pid;
 
+typedef enum {
+        ELDLM_OK = 0,
+        ELDLM_BLOCK_GRANTED,
+        ELDLM_BLOCK_CONV,
+        ELDLM_BLOCK_WAIT
+} ldlm_error_t;
+
 /* lock types */
-typedef enum  { 
-        LCK_EX,
-       LCK_PW,
-       LCK_PR,
-       LCK_CW,
-       LCK_CR,
-       LCK_NL
+typedef enum {
+        LCK_EX = 1,
+        LCK_PW,
+        LCK_PR,
+        LCK_CW,
+        LCK_CR,
+        LCK_NL
 } ldlm_mode_t;
 
-#define L2B(c) (1<<c)
+#define L2B(c) (1 << c)
 
 /* compatibility matrix */
 #define LCK_COMPAT_EX  L2B(LCK_NL)
@@ -34,24 +45,22 @@ typedef enum  {
 #define LCK_COMPAT_NL  (LCK_COMPAT_CR | L2B(LCK_EX))
 
 static ldlm_mode_t lck_compat_array[] = {
-       LCK_COMPAT_EX,
-       LCK_COMPAT_PW,
-       LCK_COMPAT_PR,
-       LCK_COMPAT_CW,
-       LCK_COMPAT_CR,
-       LCK_COMPAT_NL
+        [LCK_EX] LCK_COMPAT_EX,
+        [LCK_PW] LCK_COMPAT_PW,
+        [LCK_PR] LCK_COMPAT_PR,
+        [LCK_CW] LCK_COMPAT_CW,
+        [LCK_CR] LCK_COMPAT_CR,
+        [LCK_NL] LCK_COMPAT_NL
 };
 
-static inline int lockmode_compat(ldlm_mode_t a, ldlm_mode_t b)
+static inline int lockmode_compat(ldlm_mode_t exist, ldlm_mode_t new)
 {
-       if ( 0 <= a && a <= 5 ) { 
+       if (exist < LCK_EX || exist > LCK_NL)
               BUG();
-       }
-       if( 0 <= b && b <= 5 ) { 
+       if (new < LCK_EX || new > LCK_NL)
               BUG();
-       }
-    
-       return 1 && (lck_compat_array[a] & L2B(b));
+
+       return (lck_compat_array[exist] & L2B(new));
 }
 
 /* 
@@ -70,10 +79,11 @@ static inline int lockmode_compat(ldlm_mode_t a, ldlm_mode_t b)
 */
 
 struct ldlm_namespace {
-       struct list_head      ns_link;      /* in the list of ns's */
-       __u32                 ns_id;        /* identifier of ns */
-       struct list_head     *ns_hash;      /* hash table for ns */
-       struct list_head      ns_root_list; /* all root resources in ns */
+        struct list_head      ns_link;      /* in the list of ns's */
+        __u32                 ns_id;        /* identifier of ns */
+        struct list_head     *ns_hash;      /* hash table for ns */
+        struct list_head      ns_root_list; /* all root resources in ns */
+        struct obd_device    *ns_obddev;
 };
 
 /* 
@@ -82,49 +92,93 @@ struct ldlm_namespace {
  *
  */
 
-#define RES_HASH_BITS 18
+#define RES_HASH_BITS 14
 #define RES_HASH_SIZE (1UL << RES_HASH_BITS)
 #define RES_HASH_MASK (RES_HASH_SIZE - 1)
 
 #define RES_NAME_SIZE 6
 #define RES_VERSION_SIZE 4
 
-struct ldlm_resource {
-       struct list_head      lr_hash;
-       struct list_head      lr_rootlink; /* link all root resources in NS */
-       struct ldlm_resource *lr_parent;   /* 0 for a root resource */
-       struct list_head      lr_children; /* list head for child resources */
-       struct list_head      lr_childof;  /* part of child list of parent */
-
-       struct list_head      lr_granted;
-       struct list_head      lr_converting;
-       struct list_head      lr_waiting;
-       ldlm_mode_t           lr_most_restr;
-       struct ldlm_resource *lr_root;
-       //XXX cluster_host          lr_master;
-       __u32                 lr_name[RES_NAME_SIZE];
-       __u32                 lr_version[RES_VERSION_SIZE];
+struct ldlm_lock {
+        struct ldlm_resource *l_resource;
+        struct ldlm_lock     *l_parent;
+        struct list_head      l_children;
+        struct list_head      l_childof;
+        struct list_head      l_res_link; /*position in one of three res lists*/
+        ldlm_mode_t           l_req_mode;
+        ldlm_mode_t           l_granted_mode;
+        void                 *l_completion_ast;
+        void                 *l_blocking_ast;
+        void                 *l_event;
+        //XXX cluster_host    l_holder;
+        __u32                 l_version[RES_VERSION_SIZE];
 };
 
-struct ldlm_lock {
-       struct ldlm_resource *lb_resource;
-       struct ldlm_lock     *lb_parent;
-       struct list_head      lb_children;
-       struct list_head      lb_childof;
-       unsigned long         lb_id;
-       ldlm_mode_t           lb_req_mode;
-       ldlm_mode_t           lb_granted_mode;
-       void                 *lb_completion_ast;
-       void                 *lb_blocking_ast;
-       void                 *lb_event;
-       //XXX cluster_host    lb_holder;
-       __u32                 lb_version[RES_VERSION_SIZE];
+struct ldlm_resource {
+        struct ldlm_namespace *lr_namespace;
+        struct list_head       lr_hash;
+        struct list_head       lr_rootlink; /* link all root resources in NS */
+        struct ldlm_resource  *lr_parent;   /* 0 for a root resource */
+        struct list_head       lr_children; /* list head for child resources */
+        struct list_head       lr_childof;  /* part of child list of parent */
+
+        struct list_head       lr_granted;
+        struct list_head       lr_converting;
+        struct list_head       lr_waiting;
+        ldlm_mode_t            lr_most_restr;
+        atomic_t               lr_refcount;
+        struct ldlm_resource  *lr_root;
+        //XXX cluster_host          lr_master;
+        __u32                  lr_name[RES_NAME_SIZE];
+        __u32                  lr_version[RES_VERSION_SIZE];
+        spinlock_t             lr_lock;
+
+        void (*lr_blocking)(struct ldlm_lock *lock, struct ldlm_lock *new);
 };
 
-struct ldlm_obd {
-        struct list_head ldlm_namespaces;
+struct ldlm_handle {
+        __u64 addr;
+        __u64 cookie;
 };
 
+static inline void ldlm_lock(struct obd_device *obddev)
+{
+        spin_lock(&obddev->u.ldlm.ldlm_lock);
+}
+
+static inline void ldlm_unlock(struct obd_device *obddev)
+{
+        spin_unlock(&obddev->u.ldlm.ldlm_lock);
+}
+
 extern struct obd_ops ldlm_obd_ops;
 
+/* ldlm_lock.c */
+ldlm_error_t ldlm_local_lock_enqueue(struct obd_device *obbdev, __u32 ns_id,
+                                     struct ldlm_resource *parent_res,
+                                     struct ldlm_lock *parent_lock,
+                                     __u32 *res_id, ldlm_mode_t mode);
+void ldlm_lock_dump(struct ldlm_lock *lock);
+
+/* ldlm_test.c */
+int ldlm_test(struct obd_device *device);
+
+/* resource.c */
+struct ldlm_namespace *ldlm_namespace_find(struct obd_device *obddev, __u32 id);
+struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obddev, __u32 id);
+void ldlm_resource_dump(struct ldlm_resource *res);
+struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
+                                        struct ldlm_resource *parent,
+                                        __u32 *name, int create);
+void ldlm_resource_put(struct ldlm_resource *res);
+
+#endif /* __KERNEL__ */
+
+/* ioctls for trying requests */
+#define IOC_LDLM_TYPE                   'f'
+#define IOC_LDLM_MIN_NR                 40
+
+#define IOC_LDLM_TEST                   _IOWR('f', 40, long)
+#define IOC_LDLM_MAX_NR                 41
+
 #endif
index 9e50ef7..90924b6 100644 (file)
@@ -315,7 +315,8 @@ struct mds_rec_rename {
 
 #ifdef __KERNEL__ 
 
-static inline void ll_ino2fid(struct ll_fid *fid, ino_t ino, __u32 generation, int type)
+static inline void ll_ino2fid(struct ll_fid *fid, ino_t ino, __u32 generation,
+                              int type)
 {
         fid->id = HTON__u64((__u64)ino);
         fid->generation = HTON__u32(generation);
@@ -443,7 +444,8 @@ static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
 }
 
 #ifndef __KERNEL__
-static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max)
+static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
+                                 int max)
 {
        char *ptr;
        struct obd_ioctl_data *overlay;
@@ -572,5 +574,4 @@ union ptl_req {
         struct ost_req *ost;
 };
 
-
 #endif
index b290ae6..4ebe4dc 100644 (file)
 
 #ifndef _LL_H
 #define _LL_H
-#include <linux/obd_class.h>
-#include <linux/obdo.h>
-#include <linux/list.h>
-#include <linux/lustre_net.h>
 
+#include <linux/ext2_fs.h>
+
+#include <linux/lustre_net.h>
+#include <linux/lustre_mds.h>
+#include <linux/obdo.h>
 
 extern kmem_cache_t *ll_file_data_slab;
 struct ll_file_data { 
@@ -88,8 +89,8 @@ extern struct list_head ll_super_list;       /* list of all LL superblocks */
 #define EXT2_NAME_LEN 255
 
 int ll_check_dir_entry (const char * function, struct inode * dir,
-                          struct ext2_dir_entry_2 * de, struct page * page,
-                          unsigned long offset);
+                        struct ext2_dir_entry_2 * de, struct page * page,
+                        unsigned long offset);
 extern struct file_operations ll_dir_operations;
 extern struct inode_operations ll_dir_inode_operations;
 
index a958168..79ae98c 100644 (file)
 #ifndef _LUSTRE_MDS_H
 #define _LUSTRE_MDS_H
 
-
-#include <linux/obd_support.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_idl.h>
+#include <linux/lustre_net.h>
 
 static inline void l_dput(struct dentry *de) 
 {
@@ -38,27 +37,8 @@ static inline void l_dput(struct dentry *de)
         dput(de); 
 }
 
-struct mds_run_ctxt { 
-       struct vfsmount *pwdmnt;
-       struct dentry   *pwd;
-       mm_segment_t     fs;
-};
-
 #define LUSTRE_MDS_NAME "mds"
 
-struct mds_obd {
-        struct ptlrpc_service *mds_service;
-
-       char *mds_fstype;
-        struct super_block * mds_sb;
-       struct vfsmount *mds_vfsmnt;
-       struct mds_run_ctxt  mds_ctxt;
-       struct file_operations *mds_fop; 
-       struct inode_operations *mds_iop;
-       struct address_space_operations *mds_aops;
-
-};
-
 struct mds_update_record { 
         __u32 ur_reclen;
         __u32 ur_opcode;
index 674a19a..17dcb8d 100644 (file)
@@ -7,6 +7,12 @@
  * See the file COPYING in this distribution
  */
 
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/smp_lock.h>
+
+#include <linux/lustre_idl.h>
+
 struct obd_conn_info {
         unsigned int conn_id;     /* handle */
 };
@@ -18,9 +24,183 @@ struct obd_type {
         int  typ_refcnt;
 };
 
-#define OBD_MAGIC       0xffff0000
-#define OBD_MAGIC_MASK  0xffff0000
+struct obd_run_ctxt { 
+       struct vfsmount *pwdmnt;
+       struct dentry   *pwd;
+       mm_segment_t     fs;
+};
+
+struct obd_conn {
+        struct obd_device *oc_dev;
+        uint32_t oc_id;
+};
+
+struct obd_devicename {
+       uint32_t len;
+       char *   name;
+        struct dentry *dentry;   /* file system obd device names */
+        __u8           _uuid[16]; /* uuid obd device names */
+};
+
+
+/* Individual type definitions */
+
+struct ext2_obd {
+        struct super_block * e2_sb;
+       struct vfsmount *e2_vfsmnt;
+};
+
+struct filter_obd {
+       char *fo_fstype;
+        struct super_block * fo_sb;
+       struct vfsmount *fo_vfsmnt;
+       struct obd_run_ctxt fo_ctxt;
+       spinlock_t fo_lock;
+       __u64 fo_lastino;
+       struct file_operations *fo_fop; 
+       struct inode_operations *fo_iop;
+       struct address_space_operations *fo_aops;
+};
 
+struct mds_obd {
+        struct ptlrpc_service *mds_service;
 
+       char *mds_fstype;
+        struct super_block * mds_sb;
+       struct vfsmount *mds_vfsmnt;
+       struct obd_run_ctxt mds_ctxt;
+       struct file_operations *mds_fop; 
+       struct inode_operations *mds_iop;
+       struct address_space_operations *mds_aops;
+};
+
+struct ldlm_obd {
+        struct list_head ldlm_namespaces;
+        spinlock_t       ldlm_lock;
+};
+
+struct echo_obd {
+       char *eo_fstype;
+        struct super_block *eo_sb;
+       struct vfsmount *eo_vfsmnt;
+       struct obd_run_ctxt eo_ctxt;
+       spinlock_t eo_lock;
+       __u64 eo_lastino;
+       struct file_operations *eo_fop; 
+       struct inode_operations *eo_iop;
+       struct address_space_operations *eo_aops;
+};
+
+struct trace_obd {
+        struct obdtrace_opstats *stats;
+};
+
+#if 0
+struct snap_obd {
+       unsigned int snap_index;  /* which snapshot index are we accessing */
+       int snap_tableno;
+};
+
+struct raid1_obd {
+        unsigned int raid1_count; /* how many replicas */
+        /* devices to replicate on */
+        struct obd_device *raid1_devlist[MAX_RAID1];
+        /* connections we make */
+        struct obd_conn_info raid1_connections[MAX_RAID1];
+        struct list_head raid1_clients;  /* clients we have */
+};
+#endif
+
+struct ost_obd {
+        struct ptlrpc_service *ost_service;
+
+       struct obd_device *ost_tgt;
+       struct obd_conn ost_conn;
+};
+
+struct osc_obd {
+       struct obd_device *osc_tgt;
+        struct ptlrpc_client *osc_peer;
+};
+
+/* corresponds to one of the obd's */
+#define MAX_MULTI       16
+struct obd_device {
+        struct obd_type *obd_type;
+        int obd_minor;
+        int obd_flags;
+        int obd_refcnt; 
+        struct obd_devicename obd_fsname; 
+       struct proc_dir_entry *obd_proc_entry;
+        int obd_multi_count;
+        struct obd_conn obd_multi_conn[MAX_MULTI];
+        unsigned int obd_gen_last_id;
+        unsigned long obd_gen_prealloc_quota;
+        struct list_head obd_gen_clients;
+        struct list_head obd_req_list;
+        wait_queue_head_t obd_req_waitq;
+        union {
+                struct ext2_obd ext2;
+                struct filter_obd filter;
+                struct mds_obd mds;
+                struct ost_obd ost;
+                struct osc_obd osc;
+                struct ldlm_obd ldlm;
+                struct echo_obd echo;
+               struct trace_obd trace;
+#if 0
+                struct raid1_obd raid1;
+                struct snap_obd snap;
+#endif
+        } u;
+};
+
+struct obd_ops {
+        int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
+                           void *uarg);
+        int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
+                          obd_count *vallen, void **val);
+        int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
+                          obd_count vallen, void *val);
+        int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
+        int (*o_detach)(struct obd_device *dev);
+        int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
+        int (*o_cleanup)(struct obd_device *dev);
+        int (*o_connect)(struct obd_conn *conn);
+        int (*o_disconnect)(struct obd_conn *conn);
+        int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
+        int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
+        int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
+        int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
+        int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
+        int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
+        int (*o_open)(struct obd_conn *conn, struct obdo *oa);
+        int (*o_close)(struct obd_conn *conn, struct obdo *oa);
+        int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
+                      obd_size *count, obd_off offset);
+        int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
+                       obd_size *count, obd_off offset);
+        int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
+                     struct obdo **oa, obd_count *oa_bufs, struct page **buf,
+                     obd_size *count, obd_off *offset, obd_flag *flags);
+        int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
+                       obd_off offset);
+        int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
+                      obd_off offset);
+        int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
+                         struct obdo *src, obd_size count, obd_off offset);
+        int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
+                      struct obd_conn *srconn, struct obdo *src,
+                      obd_size count, obd_off offset);
+        int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
+                         obd_id *startid, obd_gr group, void *data);
+       int (*o_preprw)(int cmd, struct obd_conn *conn, 
+                       int objcount, struct obd_ioobj *obj, 
+                       int niocount, struct niobuf *nb, 
+                       struct niobuf *res);
+       int (*o_commitrw)(int cmd, struct obd_conn *conn, 
+                         int objcount, struct obd_ioobj *obj, 
+                         int niocount, struct niobuf *res);
+};
 
 #endif
index beed87c..51ad239 100644 (file)
 #include <linux/fs.h>
 #include <linux/time.h>
 
+#include <linux/obd_support.h>
+#include <linux/obd.h>
 #include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
-#include <linux/obd.h>
 #endif
 
 /*
  *  ======== OBD Device Declarations ===========
  */
 #define MAX_OBD_DEVICES 8
-#define MAX_MULTI       16
 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
 #define OBD_ATTACHED 0x1
 #define OBD_SET_UP   0x2
 
-struct obd_conn {
-        struct obd_device *oc_dev;
-        uint32_t oc_id;
-};
-
-#include <linux/lustre_net.h>
-
-typedef struct {
-       uint32_t len;
-       char *   name;
-        struct dentry *dentry;   /* file system obd device names */
-        __u8           _uuid[16]; /* uuid obd device names */
-} obd_devicename;
-
-#include <linux/obd_ext2.h>
-#include <linux/obd_filter.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_dlm.h>
-#include <linux/obd_snap.h>
-#include <linux/obd_trace.h>
-/* #include <linux/obd_fc.h> */
-#include <linux/obd_raid1.h>
-#include <linux/obd_ost.h>
-#include <linux/obd_osc.h>
-
-#ifdef __KERNEL__
-/* corresponds to one of the obd's */
-struct obd_device {
-        struct obd_type *obd_type;
-        int obd_minor;
-        int obd_flags;
-        int obd_refcnt; 
-        obd_devicename obd_fsname; 
-       struct proc_dir_entry *obd_proc_entry;
-        int obd_multi_count;
-        struct obd_conn obd_multi_conn[MAX_MULTI];
-        unsigned int obd_gen_last_id;
-        unsigned long obd_gen_prealloc_quota;
-        struct list_head obd_gen_clients;
-        struct list_head obd_req_list;
-        wait_queue_head_t obd_req_waitq;
-        union {
-                struct ext2_obd ext2;
-                struct filter_obd filter;
-                struct mds_obd mds;
-                struct raid1_obd raid1;
-                struct snap_obd snap;
-               struct trace_obd trace;
-                struct ost_obd ost;
-                struct osc_obd osc;
-                struct ldlm_obd ldlm;
-        } u;
-};
-
-extern struct proc_dir_entry *proc_lustre_register_obd_device(struct obd_device *obd);
+extern struct proc_dir_entry *
+proc_lustre_register_obd_device(struct obd_device *obd);
 extern void proc_lustre_release_obd_device(struct obd_device *obd);
-extern void proc_lustre_remove_obd_entry(const char* name, struct obd_device *obd);
+extern void proc_lustre_remove_obd_entry(const char* name,
+                                         struct obd_device *obd);
 
 /*
  *  ======== OBD Operations Declarations ===========
@@ -118,54 +65,7 @@ extern void proc_lustre_remove_obd_entry(const char* name, struct obd_device *ob
 #define OBD_BRW_RWMASK  OBD_BRW_READ | OBD_BRW_WRITE
 #define OBD_BRW_CREATE  4
 
-struct obd_ops {
-        int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
-                           void *uarg);
-        int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
-                          obd_count *vallen, void **val);
-        int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
-                          obd_count vallen, void *val);
-        int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
-        int (*o_detach)(struct obd_device *dev);
-        int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
-        int (*o_cleanup)(struct obd_device *dev);
-        int (*o_connect)(struct obd_conn *conn);
-        int (*o_disconnect)(struct obd_conn *conn);
-        int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
-        int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
-        int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
-        int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
-        int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
-        int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
-        int (*o_open)(struct obd_conn *conn, struct obdo *oa);
-        int (*o_close)(struct obd_conn *conn, struct obdo *oa);
-        int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
-                      obd_size *count, obd_off offset);
-        int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
-                       obd_size *count, obd_off offset);
-        int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
-                     struct obdo **oa, obd_count *oa_bufs, struct page **buf,
-                     obd_size *count, obd_off *offset, obd_flag *flags);
-        int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
-                       obd_off offset);
-        int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
-                      obd_off offset);
-        int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
-                         struct obdo *src, obd_size count, obd_off offset);
-        int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
-                      struct obd_conn *srconn, struct obdo *src,
-                      obd_size count, obd_off offset);
-        int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
-                         obd_id *startid, obd_gr group, void *data);
-       int (*o_preprw)(int cmd, struct obd_conn *conn, 
-                       int objcount, struct obd_ioobj *obj, 
-                       int niocount, struct niobuf *nb, 
-                       struct niobuf *res);
-       int (*o_commitrw)(int cmd, struct obd_conn *conn, 
-                         int objcount, struct obd_ioobj *obj, 
-                         int niocount, struct niobuf *res);
-};
-
+#ifdef __KERNEL__
 struct obd_request {
        struct obdo *oa;
        struct obd_conn *conn;
@@ -187,7 +87,7 @@ static inline int obd_check_conn(struct obd_conn *conn)
        }
 
        if (!obd->obd_flags & OBD_ATTACHED ) {
-               printk("obd_check_conn: obd %d not attached\n", obd->obd_minor); 
+               printk("obd_check_conn: obd %d not attached\n", obd->obd_minor);
                return -ENODEV;
        }
 
@@ -202,7 +102,8 @@ static inline int obd_check_conn(struct obd_conn *conn)
        }
 
        if (!obd->obd_type->typ_ops) {
-               printk("obd_check_conn: obd %d no operations\n", obd->obd_minor);
+               printk("obd_check_conn: obd %d no operations\n",
+                       obd->obd_minor);
                return -EOPNOTSUPP;
        }
        return 0;
@@ -211,22 +112,23 @@ static inline int obd_check_conn(struct obd_conn *conn)
 #define OBT(dev)        dev->obd_type
 #define OBP(dev,op)     dev->obd_type->typ_ops->o_ ## op
 
-#define OBD_CHECK_SETUP(conn)                                                   \
-do {                                                                            \
-        if (!(conn)) {                                                            \
-                CERROR("NULL connection\n");                                    \
-                return -EINVAL;                                                 \
-        }                                                                       \
-                                                                                \
-        if (!((conn)->oc_dev)) {                                                    \
-                CERROR("NULL device\n");                                        \
-                return -EINVAL;                                                 \
-        }                                                                       \
-                                                                                \
-        if ( !((conn)->oc_dev->obd_flags & OBD_SET_UP) ) {                        \
-                CERROR("Device %d not setup\n", (conn)->oc_dev->obd_minor);       \
-                return -EINVAL;                                                 \
-        }                                                                       \
+#define OBD_CHECK_SETUP(conn)                                   \
+do {                                                            \
+        if (!(conn)) {                                          \
+                CERROR("NULL connection\n");                    \
+                return -EINVAL;                                 \
+        }                                                       \
+                                                                \
+        if (!((conn)->oc_dev)) {                                \
+                CERROR("NULL device\n");                        \
+                return -EINVAL;                                 \
+        }                                                       \
+                                                                \
+        if ( !((conn)->oc_dev->obd_flags & OBD_SET_UP) ) {      \
+                CERROR("Device %d not setup\n",                 \
+                       (conn)->oc_dev->obd_minor);              \
+                return -EINVAL;                                 \
+        }                                                       \
 } while (0)
 
 #define OBD_CHECK_OP(conn,op)                                   \
@@ -243,8 +145,8 @@ do {                                                            \
        }                                                       \
 } while (0)
 
-static inline int obd_get_info(struct obd_conn *conn, obd_count keylen, void *key,
-                          obd_count *vallen, void **val)
+static inline int obd_get_info(struct obd_conn *conn, obd_count keylen,
+                               void *key, obd_count *vallen, void **val)
 {
        int rc;
         OBD_CHECK_SETUP(conn);
@@ -255,8 +157,8 @@ static inline int obd_get_info(struct obd_conn *conn, obd_count keylen, void *ke
        return rc;
 }
 
-static inline int obd_set_info(struct obd_conn *conn, obd_count keylen, void *key,
-                          obd_count vallen, void *val)
+static inline int obd_set_info(struct obd_conn *conn, obd_count keylen,
+                               void *key, obd_count vallen, void *val)
 {
        int rc;
         OBD_CHECK_SETUP(conn);
@@ -392,7 +294,8 @@ static inline int obd_statfs(struct obd_conn *conn, struct statfs *buf)
        return rc;
 }
 
-static inline int obd_punch(struct obd_conn *conn, struct obdo *tgt, obd_size count, obd_off offset)
+static inline int obd_punch(struct obd_conn *conn, struct obdo *tgt,
+                            obd_size count, obd_off offset)
 {
        int rc;
         OBD_CHECK_SETUP(conn);
@@ -404,8 +307,9 @@ static inline int obd_punch(struct obd_conn *conn, struct obdo *tgt, obd_size co
 }
 
 static inline int obd_brw(int rw, struct obd_conn *conn, obd_count num_oa,
-                     struct obdo **oa, obd_count *oa_bufs, struct page **buf,
-                     obd_size *count, obd_off *offset, obd_flag *flags)
+                          struct obdo **oa, obd_count *oa_bufs,
+                          struct page **buf, obd_size *count, obd_off *offset,
+                          obd_flag *flags)
 {
        int rc;
         OBD_CHECK_SETUP(conn);
@@ -426,7 +330,8 @@ static inline int obd_preprw(int cmd, struct obd_conn *conn,
         OBD_CHECK_SETUP(conn);
        OBD_CHECK_OP(conn, preprw);
        
-       rc = OBP(conn->oc_dev, preprw)(cmd, conn, objcount, obj, niocount, nb, res);
+       rc = OBP(conn->oc_dev, preprw)(cmd, conn, objcount, obj, niocount, nb,
+                                       res);
        EXIT;
        return rc;
 }
@@ -439,11 +344,23 @@ static inline int obd_commitrw(int cmd, struct obd_conn *conn,
         OBD_CHECK_SETUP(conn);
        OBD_CHECK_OP(conn, commitrw);
        
-       rc = OBP(conn->oc_dev, commitrw)(cmd, conn, objcount, obj, niocount, res);
+       rc = OBP(conn->oc_dev, commitrw)(cmd, conn, objcount, obj, niocount,
+                                         res);
        EXIT;
        return rc;
 }
 
+static inline int obd_iocontrol(int cmd, struct obd_conn *conn, 
+                                int len, void *karg, void *uarg)
+{
+       int rc;
+        OBD_CHECK_SETUP(conn);
+       OBD_CHECK_OP(conn, iocontrol);
+       
+       rc = OBP(conn->oc_dev, iocontrol)(cmd, conn, len, karg, uarg);
+       EXIT;
+       return rc;
+}
 
 #endif 
 
index c5a98c3..67ccf6a 100644 (file)
 #define OBD_ECHO_DEVICENAME "obdecho"
 #endif
 
-struct echo_obd {
-       char *eo_fstype;
-        struct super_block *eo_sb;
-       struct vfsmount *eo_vfsmnt;
-       struct run_ctxt  eo_ctxt;
-       spinlock_t eo_lock;
-       __u64 eo_lastino;
-       struct file_operations *eo_fop; 
-       struct inode_operations *eo_iop;
-       struct address_space_operations *eo_aops;
-};
-
-
 extern struct obd_ops echo_obd_ops;
 
 #endif
index 1f15d0f..84e015e 100644 (file)
 #define OBD_EXT2_DEVICENAME "obdext2"
 #endif
 
-struct ext2_obd {
-        struct super_block * e2_sb;
-       struct vfsmount *e2_vfsmnt;
-};
-
-
 /* development definitions */
 extern struct obdfs_sb_info *obd_sbi;
 extern struct file_operations *obd_fso;
index 0530fc6..b87c50e 100644 (file)
@@ -7,30 +7,12 @@
  * See the file COPYING in this distribution
  */
 
+#include <linux/obd_class.h>
 
 #ifndef OBD_FILTER_DEVICENAME
 #define OBD_FILTER_DEVICENAME "obdfilter"
 #endif
 
-struct run_ctxt { 
-       struct vfsmount *pwdmnt;
-       struct dentry   *pwd;
-       mm_segment_t     fs;
-};
-
-struct filter_obd {
-       char *fo_fstype;
-        struct super_block * fo_sb;
-       struct vfsmount *fo_vfsmnt;
-       struct run_ctxt  fo_ctxt;
-       spinlock_t fo_lock;
-       __u64 fo_lastino;
-       struct file_operations *fo_fop; 
-       struct inode_operations *fo_iop;
-       struct address_space_operations *fo_aops;
-};
-
-
 extern struct obd_ops filter_obd_ops;
 
 #endif
diff --git a/lustre/include/linux/obd_osc.h b/lustre/include/linux/obd_osc.h
deleted file mode 100644 (file)
index cb3e7f8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- *   This file is part of Lustre, http://www.lustre.org.
- *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Data structures for object storage targets and client: OST & OSC's
- * 
- * See also lustre_idl.h for wire formats of requests.
- *
- */
-
-#ifndef _LUSTRE_OSC_H
-#define _LUSTRE_OSC_H
-
-#include <linux/obd_support.h>
-#include <linux/lustre_net.h>
-
-struct osc_obd {
-       struct obd_device *osc_tgt;
-        struct ptlrpc_client osc_peer;
-};
-
-#define OST_EXIT 1
-#define LUSTRE_OST_NAME "ost"
-
-#endif
index 69dcc60..ddfc4b7 100644 (file)
 #ifndef _LUSTRE_OST_H
 #define _LUSTRE_OST_H
 
-#include <linux/obd_support.h>
+#include <linux/obd_class.h>
 
 #define LUSTRE_OST_NAME "ost"
 #define LUSTRE_OSC_NAME "osc"
 
-struct ost_obd {
-        struct ptlrpc_service *ost_service;
-
-       struct obd_device *ost_tgt;
-       struct obd_conn ost_conn;
-};
-
 /* ost/ost_pack.c */
 int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2, struct ptlreq_hdr **hdr, union ptl_req *req, int *len, char **buf);
 int ost_unpack_req(char *buf, int len, struct ptlreq_hdr **hdr, union ptl_req *req);
@@ -57,8 +50,4 @@ void *ost_req_buf1(struct ost_req *req);
 void *ost_rep_buf2(struct ost_rep *rep);
 void *ost_rep_buf1(struct ost_rep *rep);
 
-
-
 #endif
-
-
index b99161e..97aa870 100644 (file)
 #define OBD_RAID1_DEVICENAME "obdraid1"
 #endif
 
-struct raid1_obd {
-        unsigned int raid1_count; /* how many replicas */
-        /* devices to replicate on */
-        struct obd_device *raid1_devlist[MAX_RAID1];
-        /* connections we make */
-        struct obd_conn_info raid1_connections[MAX_RAID1];
-        struct list_head raid1_clients;  /* clients we have */
-};
-
-
 /* development definitions */
 extern struct obdfs_sb_info *obd_sbi;
 extern struct file_operations *obd_fso;
index 4b40801..b7641d4 100644 (file)
@@ -7,6 +7,8 @@
  * See the file COPYING in this distribution
  */
 
+#include <linux/obd_class.h>
+
 #define OBD_SNAP_MAGIC 0xfffffff3   /* an unlikely block number */
 
 #ifndef OBD_SNAP_DEVICENAME
 #define OBD_SNAP_DELETE        _IOWR('f', 42, long)
 #define OBD_SNAP_RESTORE       _IOWR('f', 43, long)
 
-/* this is the obd device descriptor: 
- * - current snapshot ends up in first slot of this array
- */
-struct snap_obd {
-       unsigned int snap_index;  /* which snapshot index are we accessing */
-       int snap_tableno;
-};
-
 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) ;
index 17d84a0..652e372 100644 (file)
@@ -18,24 +18,26 @@ extern unsigned long obd_memory;
 
 #define OBD_ALLOC(ptr, size)                                    \
 do {                                                            \
-        (ptr) = kmalloc((unsigned long)(size), GFP_KERNEL);     \
+        long s = (size);                                        \
+        (ptr) = kmalloc(s, GFP_KERNEL);                         \
         if ((ptr) == NULL) {                                    \
-                CERROR("kernel malloc failed at %s:%d\n",       \
-                       __FILE__, __LINE__);                     \
+                CERROR("kernel malloc of %ld bytes failed at "  \
+                       "%s:%d\n", s, __FILE__, __LINE__);       \
         } else {                                                \
-                memset((ptr), 0, (size));                       \
-                obd_memory += (size);                           \
+                memset((ptr), 0, s);                            \
+                obd_memory += s;                                \
         }                                                       \
         CDEBUG(D_MALLOC, "kmalloced: %ld at %x (tot %ld).\n",   \
-               (long)(size), (int)(ptr), obd_memory);           \
+               s, (int)(ptr), obd_memory);                      \
 } while (0)
 
-#define OBD_FREE(ptr, size)                                  \
-do {                                                         \
-        kfree((ptr));                                        \
-        CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n",    \
-               (int)(size), (int)(ptr), obd_memory);         \
-        obd_memory -= (size);                                \
+#define OBD_FREE(ptr, size)                                     \
+do {                                                            \
+        int s = (size);                                         \
+        kfree((ptr));                                           \
+        CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n",       \
+               s, (int)(ptr), obd_memory);                      \
+        obd_memory -= s;                                        \
 } while (0)
 
 #endif
index 00e16bb..524889d 100644 (file)
 #ifndef __OBD_TRACE_H
 #define __OBD_TRACE_H
 
-struct obd_device;
-struct obdtrace_opstats;
-
-struct trace_obd {
-  struct obdtrace_opstats *stats;
-};
+#include <class/obd_class.h>
 
 #endif
diff --git a/lustre/ldlm/.cvsignore b/lustre/ldlm/.cvsignore
new file mode 100644 (file)
index 0000000..e995588
--- /dev/null
@@ -0,0 +1,3 @@
+.deps
+Makefile
+Makefile.in
index a1a2074..a8ab93d 100644 (file)
@@ -4,11 +4,11 @@
 # See the file COPYING in this distribution
 
 DEFS:= 
-MODULE = llockd
-modulefs_DATA = llockd.o
-EXTRA_PROGRAMS = llockd
+MODULE = ldlm
+modulefs_DATA = ldlm.o
+EXTRA_PROGRAMS = ldlm
 
-llockd_SOURCES = resource.c
+ldlm_SOURCES = ldlm_lock.c resource.c ldlm_test.c
 
 include $(top_srcdir)/Rules
 
diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c
new file mode 100644 (file)
index 0000000..285e16b
--- /dev/null
@@ -0,0 +1,145 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This code is issued under the GNU General Public License.
+ * See the file COPYING in this distribution
+ *
+ * by Cluster File Systems, Inc.
+ */
+
+#define EXPORT_SYMTAB
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <asm/unistd.h>
+
+#define DEBUG_SUBSYSTEM S_LDLM
+
+#include <linux/obd_support.h>
+#include <linux/obd_class.h>
+
+#include <linux/lustre_dlm.h>
+
+extern kmem_cache_t *ldlm_lock_slab;
+
+static struct ldlm_lock *ldlm_lock_new(struct ldlm_lock *parent,
+                                       struct ldlm_resource *resource,
+                                       ldlm_mode_t mode)
+{
+        struct ldlm_lock *lock;
+
+        lock = kmem_cache_alloc(ldlm_lock_slab, SLAB_KERNEL);
+        if (lock == NULL)
+                BUG();
+
+        memset(lock, 0, sizeof(*lock));
+        lock->l_resource = resource;
+        lock->l_req_mode = mode;
+        INIT_LIST_HEAD(&lock->l_children);
+
+        if (parent != NULL) {
+                lock->l_parent = parent;
+                list_add(&lock->l_childof, &parent->l_children);
+        }
+
+        return lock;
+}
+
+static int ldlm_notify_incompatible(struct list_head *list,
+                                    struct ldlm_lock *new)
+{
+        struct list_head *tmp;
+        int rc = 0;
+
+        list_for_each(tmp, list) {
+                struct ldlm_lock *lock = list_entry(tmp, struct ldlm_lock,
+                                                    l_res_link);
+                if (lockmode_compat(lock->l_req_mode, new->l_req_mode))
+                        continue;
+
+                rc = 1;
+
+                if (lock->l_resource->lr_blocking != NULL)
+                        lock->l_resource->lr_blocking(lock, new);
+        }
+
+        return rc;
+}
+
+ldlm_error_t ldlm_local_lock_enqueue(struct obd_device *obddev, __u32 ns_id,
+                                     struct ldlm_resource *parent_res,
+                                     struct ldlm_lock *parent_lock,
+                                     __u32 *res_id, ldlm_mode_t mode)
+{
+        struct ldlm_namespace *ns;
+        struct ldlm_resource *res;
+        struct ldlm_lock *lock;
+        int incompat, rc;
+
+        ENTRY;
+
+       ns = ldlm_namespace_find(obddev, ns_id);
+       if (ns == NULL || ns->ns_hash == NULL)
+               BUG();
+
+        res = ldlm_resource_get(ns, parent_res, res_id, 1);
+        if (res == NULL)
+                BUG();
+
+        lock = ldlm_lock_new(parent_lock, res, mode);
+        if (lock == NULL)
+                BUG();
+
+        spin_lock(&res->lr_lock);
+
+        /* FIXME: We may want to optimize by checking lr_most_restr */
+
+        if (!list_empty(&res->lr_converting)) {
+                list_add(&lock->l_res_link, res->lr_waiting.prev);
+                rc = ELDLM_BLOCK_CONV;
+                GOTO(out, rc);
+        }
+        if (!list_empty(&res->lr_waiting)) {
+                list_add(&lock->l_res_link, res->lr_waiting.prev);
+                rc = ELDLM_BLOCK_WAIT;
+                GOTO(out, rc);
+        }
+        incompat = ldlm_notify_incompatible(&res->lr_granted, lock);
+        if (incompat) {
+                list_add(&lock->l_res_link, res->lr_waiting.prev);
+                rc = ELDLM_BLOCK_GRANTED;
+                GOTO(out, rc);
+        }
+
+        list_add(&lock->l_res_link, &res->lr_granted);
+        lock->l_granted_mode = mode;
+        if (mode < res->lr_most_restr)
+                res->lr_most_restr = mode;
+
+        rc = ELDLM_OK;
+        GOTO(out, rc);
+
+ out:
+        spin_unlock(&res->lr_lock);
+        return rc;
+}
+
+void ldlm_lock_dump(struct ldlm_lock *lock)
+{
+        char ver[128];
+
+        if (RES_VERSION_SIZE != 4)
+                BUG();
+
+        snprintf(ver, sizeof(ver), "%x %x %x %x",
+                 lock->l_version[0], lock->l_version[1],
+                 lock->l_version[2], lock->l_version[3]);
+
+        CDEBUG(D_OTHER, "  -- Lock dump: %p (%s)\n", lock, ver);
+        CDEBUG(D_OTHER, "  Parent: %p\n", lock->l_parent);
+        CDEBUG(D_OTHER, "  Requested mode: %d, granted mode: %d\n",
+               (int)lock->l_req_mode, (int)lock->l_granted_mode);
+}
diff --git a/lustre/ldlm/ldlm_test.c b/lustre/ldlm/ldlm_test.c
new file mode 100644 (file)
index 0000000..8b54915
--- /dev/null
@@ -0,0 +1,60 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This code is issued under the GNU General Public License.
+ * See the file COPYING in this distribution
+ *
+ * by Cluster File Systems, Inc.
+ */
+
+#define EXPORT_SYMTAB
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <asm/unistd.h>
+
+#define DEBUG_SUBSYSTEM S_LDLM
+
+#include <linux/obd_support.h>
+#include <linux/obd_class.h>
+
+#include <linux/lustre_dlm.h>
+
+static void ldlm_test_callback(struct ldlm_lock *lock, struct ldlm_lock *new)
+{
+        printk("ldlm_test_callback: lock=%p, new=%p\n", lock, new);
+}
+
+int ldlm_test(struct obd_device *obddev)
+{
+        struct ldlm_namespace *ns;
+        struct ldlm_resource *res;
+        __u32 res_id[RES_NAME_SIZE] = {1, 2, 3, 4, 5, 6};
+        ldlm_error_t err;
+
+        ns = ldlm_namespace_new(obddev, 1);
+        if (ns == NULL)
+                BUG();
+
+        res = ldlm_resource_get(ns, NULL, res_id, 1);
+        if (res == NULL)
+                BUG();
+
+        res->lr_blocking = ldlm_test_callback;
+
+        /* Get a couple of read locks */
+        err = ldlm_local_lock_enqueue(obddev, 1, NULL, NULL, res_id, LCK_CR);
+        if (err != ELDLM_OK)
+                BUG();
+
+        err = ldlm_local_lock_enqueue(obddev, 1, NULL, NULL, res_id, LCK_CR);
+        if (err != ELDLM_OK)
+                BUG();
+
+        ldlm_resource_dump(res);
+
+        return 0;
+}
index 078116a..94af251 100644 (file)
@@ -1,9 +1,7 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * obd/ldlm/resource.c
- *
- * Copyright (C) 2002  Cluster File Systems, Inc.
+ * Copyright (C) 2002 Cluster File Systems, Inc.
  *
  * This code is issued under the GNU General Public License.
  * See the file COPYING in this distribution
 #include <linux/lustre_dlm.h>
 
 static kmem_cache_t *ldlm_resource_slab;
-static kmem_cache_t *ldlm_lock_slab;
+kmem_cache_t *ldlm_lock_slab;
 
 struct ldlm_namespace *ldlm_namespace_find(struct obd_device *obddev, __u32 id)
 {
        struct list_head *tmp;
        struct ldlm_namespace *res;
 
+        ldlm_lock(obddev);
+
        res = NULL;
        list_for_each(tmp, &obddev->u.ldlm.ldlm_namespaces) { 
                struct ldlm_namespace *chk;
@@ -43,14 +43,21 @@ struct ldlm_namespace *ldlm_namespace_find(struct obd_device *obddev, __u32 id)
                        break;
                }
        }
+
+        ldlm_unlock(obddev);
+
        return res;
 }
 
-static void res_hash_init(struct ldlm_namespace *name_space)
+/* this must be called with ldlm_lock(obddev) held */
+static void res_hash_init(struct ldlm_namespace *ns)
 {
        struct list_head *res_hash;
        struct list_head *bucket;
 
+        if (ns->ns_hash != NULL)
+                return;
+
        OBD_ALLOC(res_hash, sizeof(struct list_head) * RES_HASH_SIZE);
        if (!res_hash)
                BUG();
@@ -60,13 +67,15 @@ static void res_hash_init(struct ldlm_namespace *name_space)
                INIT_LIST_HEAD(bucket);
        }
 
-       name_space->ns_hash = res_hash;
+       ns->ns_hash = res_hash;
 }
 
 struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obddev, __u32 id)
 {
        struct ldlm_namespace *ns;
 
+        ldlm_lock(obddev);
+
        if (ldlm_namespace_find(obddev, id))
                BUG();
 
@@ -76,13 +85,17 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obddev, __u32 id)
 
        ns->ns_id = id;
        INIT_LIST_HEAD(&ns->ns_root_list);
+
        list_add(&ns->ns_link, &obddev->u.ldlm.ldlm_namespaces);
 
        res_hash_init(ns); 
+
+        ldlm_unlock(obddev);
+
        return ns;
 }
 
-__u32 ldlm_hash_fn(struct ldlm_resource *parent, __u32 *name)
+static __u32 ldlm_hash_fn(struct ldlm_resource *parent, __u32 *name)
 {
        __u32 hash = 0;
        int i;
@@ -96,33 +109,7 @@ __u32 ldlm_hash_fn(struct ldlm_resource *parent, __u32 *name)
        return (hash & RES_HASH_MASK);
 }
 
-struct ldlm_resource *ldlm_resource_find(struct ldlm_namespace *ns,
-                                        struct ldlm_resource *parent,
-                                        __u32 *name)
-{
-       struct list_head *bucket;
-       struct list_head *tmp = bucket;
-       struct ldlm_resource *res;
-
-       if (ns->ns_hash == NULL)
-               BUG();
-       bucket = ns->ns_hash + ldlm_hash_fn(parent, name);
-
-       res = NULL;
-       list_for_each(tmp, bucket) {
-               struct ldlm_resource *chk;
-               chk = list_entry(tmp, struct ldlm_resource, lr_hash);
-
-               if (memcmp(chk->lr_name, name, RES_NAME_SIZE * sizeof(__u32))){
-                       res = chk;
-                       break;
-               }
-       }
-                       
-       return res;
-}
-
-struct ldlm_resource *ldlm_resource_new(void)
+static struct ldlm_resource *ldlm_resource_new(void)
 {
        struct ldlm_resource *res;
 
@@ -136,31 +123,29 @@ struct ldlm_resource *ldlm_resource_new(void)
        INIT_LIST_HEAD(&res->lr_converting);
        INIT_LIST_HEAD(&res->lr_waiting);
 
+        res->lr_lock = SPIN_LOCK_UNLOCKED;
+
+        atomic_set(&res->lr_refcount, 1);
+
        return res;
 }
 
-struct ldlm_resource *ldlm_resource_add(struct obd_device *obddev, __u32 id,
-                                       struct ldlm_resource *parent,
-                                       __u32 *name)
+/* ldlm_lock(obddev) must be taken before calling resource_add */
+static struct ldlm_resource *ldlm_resource_add(struct ldlm_namespace *ns,
+                                               struct ldlm_resource *parent,
+                                               __u32 *name)
 {
-       struct ldlm_namespace *ns;
        struct list_head *bucket;
        struct ldlm_resource *res;
 
-       ns = ldlm_namespace_find(obddev, id);
-       if (ns == NULL || ns->ns_hash == NULL)
-               BUG();
-
        bucket = ns->ns_hash + ldlm_hash_fn(parent, name);
 
-       if (ldlm_resource_find(ns, parent, name) != NULL)
-               BUG();
-
        res = ldlm_resource_new();
        if (!res)
                BUG();
 
        memcpy(res->lr_name, name, RES_NAME_SIZE * sizeof(__u32));
+        res->lr_namespace = ns;
        list_add(&res->lr_hash, bucket);
        if (parent == NULL) {
                res->lr_parent = res;
@@ -173,17 +158,156 @@ struct ldlm_resource *ldlm_resource_add(struct obd_device *obddev, __u32 id,
        return res;
 }
 
+struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
+                                        struct ldlm_resource *parent,
+                                        __u32 *name, int create)
+{
+       struct list_head *bucket;
+       struct list_head *tmp = bucket;
+       struct ldlm_resource *res;
+
+       if (ns->ns_hash == NULL)
+               BUG();
+       bucket = ns->ns_hash + ldlm_hash_fn(parent, name);
+
+        ldlm_lock(ns->ns_obddev);
+
+       res = NULL;
+       list_for_each(tmp, bucket) {
+               struct ldlm_resource *chk;
+               chk = list_entry(tmp, struct ldlm_resource, lr_hash);
+
+               if (memcmp(chk->lr_name, name,
+                           RES_NAME_SIZE * sizeof(__u32)) == 0) {
+                       res = chk;
+                        atomic_inc(&res->lr_refcount);
+                       break;
+               }
+       }
+
+        if (res == NULL && create)
+                res = ldlm_resource_add(ns, parent, name);
+
+        ldlm_unlock(ns->ns_obddev);
+
+       return res;
+}
+
+void ldlm_resource_put(struct ldlm_resource *res)
+{
+        ldlm_lock(res->lr_namespace->ns_obddev);
+
+        if (atomic_dec_and_test(&res->lr_refcount)) {
+                if (!list_empty(&res->lr_granted))
+                        BUG();
+
+                if (!list_empty(&res->lr_converting))
+                        BUG();
+
+                if (!list_empty(&res->lr_waiting))
+                        BUG();
+
+                list_del(&res->lr_hash);
+                list_del(&res->lr_rootlink);
+                list_del(&res->lr_childof);
+
+                kmem_cache_free(ldlm_resource_slab, res);
+        }
+
+        ldlm_unlock(res->lr_namespace->ns_obddev);
+}
+
+int ldlm_get_resource_handle(struct ldlm_resource *res, struct ldlm_handle *h)
+{
+        BUG();
+        return 0;
+}
+
+void ldlm_resource_dump(struct ldlm_resource *res)
+{
+        struct list_head *tmp;
+        char name[256];
+
+        if (RES_NAME_SIZE != 6)
+                BUG();
+
+        snprintf(name, sizeof(name), "%x %x %x %x %x %x",
+                 res->lr_name[0], res->lr_name[1], res->lr_name[2],
+                 res->lr_name[3], res->lr_name[4], res->lr_name[5]);
+
+        CDEBUG(D_OTHER, "--- Resource: %p (%s)\n", res, name);
+        CDEBUG(D_OTHER, "Namespace: %p (%u)\n", res->lr_namespace,
+               res->lr_namespace->ns_id);
+        CDEBUG(D_OTHER, "Parent: %p, root: %p\n", res->lr_parent, res->lr_root);
+
+        CDEBUG(D_OTHER, "Granted locks:\n");
+        list_for_each(tmp, &res->lr_granted) {
+                struct ldlm_lock *lock;
+                lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+                ldlm_lock_dump(lock);
+        }
+
+        CDEBUG(D_OTHER, "Converting locks:\n");
+        list_for_each(tmp, &res->lr_converting) {
+                struct ldlm_lock *lock;
+                lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+                ldlm_lock_dump(lock);
+        }
+
+        CDEBUG(D_OTHER, "Waiting locks:\n");
+        list_for_each(tmp, &res->lr_waiting) {
+                struct ldlm_lock *lock;
+                lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+                ldlm_lock_dump(lock);
+        }
+}
+
 static int ldlm_obd_setup(struct obd_device *obddev, obd_count len, void *data)
 {
        INIT_LIST_HEAD(&obddev->u.ldlm.ldlm_namespaces);
+        obddev->u.ldlm.ldlm_lock = SPIN_LOCK_UNLOCKED;
 
        return 0;
 }
 
+static int ldlm_iocontrol(int cmd, struct obd_conn *conn, int len, void *karg,
+                          void *uarg)
+{
+        struct obd_device *obddev = conn->oc_dev;
+       int err;
+
+       ENTRY;
+
+       if ( _IOC_TYPE(cmd) != IOC_LDLM_TYPE ||
+             _IOC_NR(cmd) < IOC_LDLM_MIN_NR  ||
+             _IOC_NR(cmd) > IOC_LDLM_MAX_NR ) {
+                CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
+                                _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
+                EXIT;
+                return -EINVAL;
+        }
+
+       switch (cmd) {
+       case IOC_LDLM_TEST: {
+               err = ldlm_test(obddev);
+               CERROR("-- done err %d\n", err);
+                EXIT;
+               break;
+       }
+        default:
+                err = -EINVAL;
+                EXIT;
+                break;
+        }
+
+        return err;
+}
+
 struct obd_ops ldlm_obd_ops = {
+        o_iocontrol:   ldlm_iocontrol,
        o_setup:       ldlm_obd_setup,
         o_connect:     gen_connect,
-        o_disconnect:  gen_disconnect,
+        o_disconnect:  gen_disconnect
 };
 
 static int __init ldlm_init(void)
index a92fd37..54962f8 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_MDS
 
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
+#include <linux/lustre_lib.h>
 
 int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, 
                 struct ptlreq_hdr **hdr, union ptl_req *r,
index 0444417..645679c 100644 (file)
@@ -31,8 +31,7 @@
 
 #include <linux/obd_support.h>
 #include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_light.h>
+#include <linux/lustre_mds.h>
 
 /* packing of MDS records */
 void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, const char *name, int namelen, __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time, const char *tgt, int tgtlen)
@@ -124,7 +123,8 @@ void mds_rename_pack(struct mds_rec_rename *rec, struct inode *srcdir, struct in
 
 /* unpacking */
 
-static int mds_update_hdr_unpack(char *buf, int len, struct mds_update_record *r)
+static int mds_update_hdr_unpack(char *buf, int len,
+                                 struct mds_update_record *r)
 {
        struct mds_update_record_hdr *hdr = (struct mds_update_record_hdr *)buf;
        
index da2b218..0d5bb4f 100644 (file)
@@ -91,7 +91,7 @@ static int ll_file_open(struct inode *inode, struct file *file)
 
 static int ll_file_release(struct inode *inode, struct file *file)
 {
-       int rc; 
+       int rc;
        struct ptlrpc_request *req;
        struct ll_file_data *fd;
        struct obdo oa; 
@@ -101,6 +101,7 @@ static int ll_file_release(struct inode *inode, struct file *file)
        fd = (struct ll_file_data *)file->private_data;
        if (!fd) { 
                BUG();
+                rc = -EINVAL;
                goto out;
        }
 
index eb52c7d..063af18 100644 (file)
@@ -32,8 +32,6 @@
 
 #define DEBUG_SUBSYSTEM S_LLIGHT
 
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
 #include <linux/lustre_light.h>
 
 kmem_cache_t *ll_file_data_slab;
@@ -113,7 +111,7 @@ static struct super_block * ll_read_super(struct super_block *sb,
                return NULL;
        }
         memset(sbi, 0, sizeof(*sbi));
-       sb->u.generic_sbp = (struct ll_sb_info *) sbi;
+       sb->u.generic_sbp = sbi;
 
         ll_options(data, &device, &version);
 
@@ -398,7 +396,7 @@ struct super_operations ll_super_operations =
 };
 
 struct file_system_type lustre_light_fs_type = {
-   "lustre_light", 0, ll_read_super, NULL
+        "lustre_light", 0, ll_read_super, NULL
 };
 
 static int __init init_lustre_light(void)
index 5c60347..5e5a46a 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_MDS
 
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
-#include <linux/lustre_net.h>
-#include <linux/obd_class.h>
+#include <linux/lustre_lib.h>
 
 int mds_sendpage(struct ptlrpc_request *req, struct file *file, 
                  __u64 offset, struct niobuf *dst)
index 88246c1..e976133 100644 (file)
@@ -459,319 +459,20 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                 kfree(bufs);
                 return err;
         }
-#if 0
-        case OBD_IOC_SYNC: {
-                struct oic_range_s *range = tmp_buf;
-
-                if (!obd->obd_type)
-                        return -ENODEV;
-
-                err = copy_from_user(range, (const void *)arg,  sizeof(*range));
-
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-                        
-                if ( !OBT(obd) || !OBP(obd, sync) ) {
-                        err = -EOPNOTSUPP;
-                        EXIT;
-                        return err;
-                }
-
-                /* XXX sync needs to be tested/verified */
-                err = OBP(obd, sync)(&conn, &range->obdo, range->count,
-                                        range->offset);
-
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-                        
-                return put_user(err, (int *) arg);
-        }
-
-        case OBD_IOC_READ: {
-                int err;
-                struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
-
-                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-
-                conn.oc_id = rw_s->conn_id;
-
-                if ( !OBT(obd) || !OBP(obd, read) ) {
-                        err = -EOPNOTSUPP;
-                        EXIT;
-                        return err;
-                }
-
-
-                err = OBP(obd, read)(&conn, &rw_s->obdo, rw_s->buf, 
-                                        &rw_s->count, rw_s->offset);
-                
-                CDEBUG(D_INFO, "READ: conn %d, count %Ld, offset %Ld, '%s'\n",
-                       rw_s->conn_id, rw_s->count, rw_s->offset, rw_s->buf);
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-                        
-                err = copy_to_user((int*)arg, &rw_s->count, sizeof(rw_s->count));
-                EXIT;
-                return err;
-        }
-
-        case OBD_IOC_WRITE: {
-                struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
-
-                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-
-                conn.oc_id = rw_s->conn_id;
-
-                if ( !OBT(obd) || !OBP(obd, write) ) {
-                        err = -EOPNOTSUPP;
-                        return err;
-                }
-
-                CDEBUG(D_INFO, "WRITE: conn %d, count %Ld, offset %Ld, '%s'\n",
-                       rw_s->conn_id, rw_s->count, rw_s->offset, rw_s->buf);
-
-                err = OBP(obd, write)(&conn, &rw_s->obdo, rw_s->buf, 
-                                         &rw_s->count, rw_s->offset);
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-
-                err = copy_to_user((int *)arg, &rw_s->count,
-                                   sizeof(rw_s->count));
-                EXIT;
-                return err;
-        }
-        case OBD_IOC_PREALLOCATE: {
-                struct oic_prealloc_s *prealloc = tmp_buf;
-
-                /* has this minor been registered? */
-                if (!obd->obd_type)
-                        return -ENODEV;
-
-                err = copy_from_user(prealloc, (int *)arg, sizeof(*prealloc));
-                if (err) 
-                        return -EFAULT;
-
-                if ( !(obd->obd_flags & OBD_ATTACHED) ||
-                     !(obd->obd_flags & OBD_SET_UP)) {
-                        CDEBUG(D_IOCTL, "Device not attached or set up\n");
-                        return -ENODEV;
-                }
-
-                if ( !OBT(obd) || !OBP(obd, preallocate) )
-                        return -EOPNOTSUPP;
-
-                conn.oc_id = prealloc->conn_id;
-                err = OBP(obd, preallocate)(&conn, &prealloc->alloc,
-                                               prealloc->ids);
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-
-                err =copy_to_user((int *)arg, prealloc, sizeof(*prealloc));
-                EXIT;
-                return err;
-        }
-        case OBD_IOC_STATFS: {
-                struct statfs *tmp;
-                unsigned int conn_id;
-                struct statfs buf;
-
-                /* has this minor been registered? */
-                if (!obd->obd_type)
-                        return -ENODEV;
-
-                tmp = (void *)arg + sizeof(unsigned int);
-                get_user(conn_id, (int *) arg);
-
-                if ( !OBT(obd) || !OBP(obd, statfs) )
-                        return -EOPNOTSUPP;
-
-                conn.oc_id = conn_id;
-                err = OBP(obd, statfs)(&conn, &buf);
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-                err = copy_to_user(tmp, &buf, sizeof(buf));
-                EXIT;
-                return err;
-                
-        }
-        case OBD_IOC_COPY: {
-                struct ioc_mv_s *mvdata = tmp_buf;
-
-                if ( (!(obd->obd_flags & OBD_SET_UP)) ||
-                     (!(obd->obd_flags & OBD_ATTACHED))) {
-                        CDEBUG(D_IOCTL, "Device not attached or set up\n");
-                        return -ENODEV;
-                }
-
-                /* get main structure */
-                err = copy_from_user(mvdata, (void *) arg, sizeof(*mvdata));
-                if (err) {
-                        EXIT;
-                        return err;
-                }
-
-                if ( !OBT(obd) || !OBP(obd, copy) )
-                        return -EOPNOTSUPP;
-
-                /* do the partition */
-                CDEBUG(D_INFO, "Copy %d, type %s dst %Ld src %Ld\n", dev, 
-                       obd->obd_type->typ_name, mvdata->dst.o_id, 
-                       mvdata->src.o_id);
-
-                conn.oc_id = mvdata->src_conn_id;
-
-                err = OBP(obd, copy)(&conn, &mvdata->dst, 
-                                        &conn, &mvdata->src, 
-                                        mvdata->src.o_size, 0);
-                return err;
-        }
-
-        case OBD_IOC_MIGR: {
-                struct ioc_mv_s *mvdata = tmp_buf;
-
-                if ( (!(obd->obd_flags & OBD_SET_UP)) ||
-                     (!(obd->obd_flags & OBD_ATTACHED))) {
-                        CDEBUG(D_IOCTL, "Device not attached or set up\n");
-                        return -ENODEV;
-                }
-
-                err = copy_from_user(mvdata, (void *) arg, sizeof(*mvdata));
-                if (err) {
-                        EXIT;
-                        return err;
-                }
-
-                CDEBUG(D_INFO, "Migrate copying %d bytes\n", sizeof(*mvdata));
-
-                if ( !OBT(obd) || !OBP(obd, migrate) )
-                        return -EOPNOTSUPP;
-
-                /* do the partition */
-                CDEBUG(D_INFO, "Migrate %d, type %s conn %d src %Ld dst %Ld\n",
-                       dev, obd->obd_type->typ_name, mvdata->src_conn_id,
-                       mvdata->src.o_id, mvdata->dst.o_id);
-
-                conn.oc_id = mvdata->src_conn_id;
-                err = OBP(obd, migrate)(&conn, &mvdata->dst, &mvdata->src, 
-                                           mvdata->src.o_size, 0);
-
-                return err;
-        }
-        case OBD_IOC_PUNCH: {
-                struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
-
-                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-
-                conn.oc_id = rw_s->conn_id;
-
-                if ( !OBT(obd) || !OBP(obd, punch) ) {
-                        err = -EOPNOTSUPP;
-                        return err;
-                }
-
-                CDEBUG(D_INFO, "PUNCH: conn %d, count %Ld, offset %Ld\n",
-                       rw_s->conn_id, rw_s->count, rw_s->offset);
-                err = OBP(obd, punch)(&conn, &rw_s->obdo, rw_s->count,
-                                         rw_s->offset);
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-                EXIT;
-                return err;
-        }
-
         default: {
-                struct obd_type *type;
-                struct oic_generic input;
-                char *nm;
-                void *karg;
-
-                /* get data structures */
-                err = copy_from_user(&input, (void *)arg, sizeof(input));
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
-
-                err = getdata(input.att_typelen + 1, &input.att_type);
-                if ( err ) {
-                        EXIT;
-                        return err;
-                }
+                conn.oc_id = data->ioc_conn1;
+               conn.oc_dev = obd;
 
-                /* find the type */
-                nm = input.att_type;
-                type = obd_nm_to_type(nm);
-#ifdef CONFIG_KMOD
-                if ( !type ) {
-                        if ( !request_module(nm) ) {
-                                CDEBUG(D_INFO, "Loaded module '%s'\n", nm);
-                                type = obd_nm_to_type(nm);
-                        } else {
-                                CDEBUG(D_INFO, "Can't load module '%s'\n", nm);
-                        }
-                }
-#endif
-                OBD_FREE(input.att_type, input.att_typelen + 1);
-                if ( !type ) {
-                        CERROR("unknown obd type dev %d\n", dev);
-                        EXIT;
-                        return -EINVAL;
-                }
-                
-                if ( !type->typ_ops || !type->typ_ops->o_iocontrol ) {
-                        EXIT;
-                        return -EOPNOTSUPP;
-                }
-                conn.oc_id = input.att_connid;
-                
-                CDEBUG(D_INFO, "Calling ioctl %x for type %s, len %d\n",
-                       cmd, type->typ_name, input.att_datalen);
-
-                /* get the generic data */
-                karg = input.att_data;
-                err = getdata(input.att_datalen, &karg);
-                if ( err ) {
+                err = obd_iocontrol(cmd, &conn, sizeof(*data), data, NULL);
+                if (err) {
                         EXIT;
                         return err;
                 }
 
-                err = type->typ_ops->o_iocontrol(cmd, &conn, input.att_datalen, 
-                                                 karg, input.att_data);
-                OBD_FREE(karg, input.att_datalen);
-
+                err = copy_to_user((int *)arg, data, sizeof(*data));
                 EXIT;
                 return err;
         }
-#endif 
-       default:
-               return -EINVAL;
-
         }
 } /* obd_class_ioctl */
 
index bc0570e..230a4ad 100644 (file)
@@ -22,9 +22,9 @@
 
 #define DEBUG_SUBSYSTEM S_FILTER
 
-#include <linux/obd_support.h>
 #include <linux/obd_class.h>
 #include <linux/obd_ext2.h>
+#include <linux/obd_filter.h>
 
 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 long filter_memory;
@@ -60,7 +60,7 @@ static struct file *filter_parent(obd_id id, obd_mode mode)
        return file;
 }
 
-void push_ctxt(struct run_ctxt *save, struct run_ctxt *new)
+void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new)
 { 
        save->fs = get_fs();
        save->pwd = dget(current->fs->pwd);
@@ -70,7 +70,7 @@ void push_ctxt(struct run_ctxt *save, struct run_ctxt *new)
        set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
 }
 
-void pop_ctxt(struct run_ctxt *saved)
+void pop_ctxt(struct obd_run_ctxt *saved)
 {
        set_fs(saved->fs);
        set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
@@ -131,7 +131,7 @@ static int simple_unlink(struct dentry *dir, char *name)
 
 static void filter_prep(struct obd_device *obddev)
 {
-       struct run_ctxt saved;
+       struct obd_run_ctxt saved;
        struct file *file;
        struct inode *inode;
        loff_t off;
@@ -202,7 +202,7 @@ static void filter_prep(struct obd_device *obddev)
 
 static void filter_post(struct obd_device *obddev)
 {
-       struct run_ctxt saved;
+       struct obd_run_ctxt saved;
        long rc;
        struct file *file;
        loff_t off = 0; 
@@ -328,7 +328,7 @@ static struct file *filter_obj_open(struct obd_device *obddev,
        struct file *file;
        int error = 0;
        char id[24];
-       struct run_ctxt saved;
+       struct obd_run_ctxt saved;
        struct super_block *sb;
 
        sb = obddev->u.filter.fo_sb;
@@ -480,7 +480,7 @@ static int filter_setattr(struct obd_conn *conn, struct obdo *oa)
 static int filter_create (struct obd_conn* conn, struct obdo *oa)
 {
        char name[64];
-       struct run_ctxt saved;
+       struct obd_run_ctxt saved;
        struct file *file;
        int mode;
        struct obd_device *obddev = conn->oc_dev;
@@ -527,7 +527,7 @@ static int filter_destroy(struct obd_conn *conn, struct obdo *oa)
         struct inode * inode;
        struct file *dir;
        int rc;
-       struct run_ctxt saved;
+       struct obd_run_ctxt saved;
        char id[128];
 
         if (!(cli = gen_client(conn))) {
index b8e3387..b575b2f 100644 (file)
@@ -33,8 +33,8 @@
 
 #define DEBUG_SUBSYSTEM S_OBDFS
 
-#include <linux/obd_support.h>
 #include <linux/obdfs.h>
+#include <linux/lustre_light.h>
 extern struct address_space_operations obdfs_aops;
 
 /* from super.c */
index 307bf76..16d0558 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_OSC
 
-#include <linux/obd_support.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
+#include <linux/lustre_net.h>
+#include <linux/obd_ost.h>
 
 struct ptlrpc_client *osc_con2cl(struct obd_conn *conn)
 {
        struct osc_obd *osc = &conn->oc_dev->u.osc;
-       return &osc->osc_peer;
-
+       return osc->osc_peer;
 }
 
 static int osc_connect(struct obd_conn *conn)
@@ -578,12 +577,16 @@ static int osc_setup(struct obd_device *obddev, obd_count len,
        int dev = data->ioc_dev;
         ENTRY;
 
-       rc = ptlrpc_connect_client(dev, "ost", 
-                                  OST_REQUEST_PORTAL, 
-                                  OSC_REPLY_PORTAL,    
-                                  ost_pack_req, 
-                                  ost_unpack_rep,
-                                  &osc->osc_peer); 
+        OBD_ALLOC(osc->osc_peer, sizeof(*osc->osc_peer));
+        if (osc->osc_peer == NULL)
+                return -ENOMEM;
+
+        rc = ptlrpc_connect_client(dev, "ost",
+                                   OST_REQUEST_PORTAL,
+                                   OSC_REPLY_PORTAL,  
+                                   ost_pack_req,
+                                   ost_unpack_rep,
+                                   osc->osc_peer);
 
         MOD_INC_USE_COUNT;
         EXIT;
@@ -592,6 +595,11 @@ static int osc_setup(struct obd_device *obddev, obd_count len,
 
 static int osc_cleanup(struct obd_device * obddev)
 {
+       struct osc_obd *osc = &obddev->u.osc;
+
+        if (osc->osc_peer != NULL)
+                OBD_FREE(osc->osc_peer, sizeof(*osc->osc_peer));
+
         MOD_DEC_USE_COUNT;
         return 0;
 }
index b81caf1..9ff8002 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_OST
 
-#include <linux/obd_support.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_mds.h>
-#include <linux/obd_class.h>
-
-
+#include <linux/obd_ost.h>
+#include <linux/lustre_net.h>
 
 static int ost_destroy(struct ost_obd *ost, struct ptlrpc_request *req)
 {
index 65effbf..9adf4a2 100644 (file)
@@ -35,3 +35,16 @@ setup() {
     echo "The GDB module script is in /tmp/ogdb.  Press enter to continue"
     read
 }
+
+setup_ldlm() {
+    mknod /dev/portals c 10 240
+
+    insmod $R/usr/src/portals/linux/oslib/portals.o || exit -1
+
+    insmod $R/usr/src/obd/class/obdclass.o || exit -1
+    insmod $R/usr/src/obd/ldlm/ldlm.o || exit -1
+
+    $R/usr/src/portals/linux/utils/debugctl modules > $R/tmp/ogdb
+    echo "The GDB module script is in /tmp/ogdb.  Press enter to continue"
+    read
+}
\ No newline at end of file
index cd7abf1..0fcaa83 100755 (executable)
@@ -25,7 +25,6 @@ losetup ${LOOP}1 /tmp/mds || exit -1
 
 mknod /dev/obd c 10 241
 echo 8191 > /proc/sys/portals/debug
-echo 8191 > /proc/sys/portals/trace
 
 $R/usr/src/obd/utils/obdctl <<EOF
 device 0
index e0f28c7..cf83287 100644 (file)
 #include <stdio.h>
 #include <signal.h>
 #define printk printf
+
 #include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
+#include <linux/lustre_dlm.h>
+
 #include <unistd.h>
 #include <sys/un.h>
 #include <time.h>
@@ -40,7 +43,6 @@
 #include <netinet/in.h>
 #include <errno.h>
 #include <string.h>
-#include <linux/module.h>
 
 #define __KERNEL__
 #include <linux/list.h>
@@ -440,7 +442,7 @@ static int jt_getattr(int argc, char **argv)
                 data.ioc_obdo1.o_valid = 0xffffffff;
                 printf("getting attr for %Ld\n", data.ioc_obdo1.o_id);
         } else {
-                printf("usage: %s id\n", argv[0]);
+                fprintf(stderr, "usage: %s id\n", argv[0]);
                 return 0;
         }
 
@@ -474,7 +476,7 @@ static int jt_test_getattr(int argc, char **argv)
                 printf("getting %d attrs (testing only): %s", count,
                        ctime(&start.tv_sec));
         } else {
-                printf("usage: %s count [silent]\n", argv[0]);
+                fprintf(stderr, "usage: %s count [silent]\n", argv[0]);
                 return 0;
         }
 
@@ -526,8 +528,9 @@ static int jt_test_brw(int argc, char **argv)
 
                 bulk = malloc(2 * len);
                 if (!bulk) {
-                        printf("%s: out of memory allocating 2x%d pages\n",
-                               argv[0], pages);
+                        fprintf(stderr,
+                                "%s: out of memory allocating 2x%d pages\n",
+                                argv[0], pages);
                         return 0;
                 }
                 IOCINIT(data);
@@ -576,6 +579,23 @@ static int jt_test_brw(int argc, char **argv)
         return 0;
 }
 
+static int jt_test_ldlm(int argc, char **argv)
+{
+        struct obd_ioctl_data data;
+        int rc;
+
+        IOCINIT(data);
+        if (argc != 1) {
+                fprintf(stderr, "usage: %s\n", argv[0]);
+                return 0;
+        }
+
+        rc = ioctl(fd, IOC_LDLM_TEST, &data);
+        if (rc)
+                fprintf(stderr, "LDLM test failed: %s\n", strerror(errno));
+        return rc;
+}
+
 command_t list[] = {
         {"device", jt_device, 0, "set current device (args device no)"},
         {"attach", jt_attach, 0, "name the typed of device (args: type data"},
@@ -591,6 +611,7 @@ command_t list[] = {
                 "disconnect - break connection to device"},
         {"test_getattr", jt_test_getattr, 0, "test_getattr count [silent]"},
         {"test_brw", jt_test_brw, 0, "test_brw count [write [silent]]"},
+        {"test_ldlm", jt_test_ldlm, 0, "test lock manager (no args)"},
         {"help", Parser_help, 0, "help"},
         {"exit", Parser_quit, 0, "quit"},
         {"quit", Parser_quit, 0, "quit"},