Whamcloud - gitweb
Lproc-snmp code drop
[fs/lustre-release.git] / lustre / obdecho / echo.c
index 74aad68..f310687 100644 (file)
  * and Andreas Dilger <adilger@clusterfs.com>
  */
 
-static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.32 2002/09/04 16:30:40 adilger Exp $";
-#define OBDECHO_VERSION "$Revision: 1.32 $"
+static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.42 2002/11/01 17:23:13 thantry Exp $";
+#define OBDECHO_VERSION "$Revision: 1.42 $"
 
 #define EXPORT_SYMTAB
 
 #include <linux/version.h>
 #include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/highmem.h>
 #include <linux/fs.h>
 #include <linux/stat.h>
-#include <linux/locks.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
 #include <linux/ext2_fs.h>
 #include <linux/quotaops.h>
 #include <linux/proc_fs.h>
@@ -35,13 +38,16 @@ static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.32 2002/09/04 16:3
 #include <linux/obd_echo.h>
 #include <linux/lustre_debug.h>
 #include <linux/lustre_dlm.h>
-
-extern struct obd_device obd_dev[MAX_OBD_DEVICES];
+#include <linux/lprocfs_status.h>
 
 static atomic_t echo_page_rws;
 static atomic_t echo_getattrs;
 
 #define ECHO_PROC_STAT "sys/obdecho"
+#define ECHO_INIT_OBJID 0x1000000000000000ULL
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
 
 int echo_proc_read(char *page, char **start, off_t off, int count, int *eof,
                    void *data)
@@ -92,7 +98,8 @@ void echo_proc_fini(void)
 }
 
 static int echo_connect(struct lustre_handle *conn, struct obd_device *obd,
-                        char *cluuid)
+                        obd_uuid_t cluuid, struct recovd_obd *recovd,
+                        ptlrpc_recovery_cb_t recover)
 {
         int rc;
 
@@ -142,7 +149,7 @@ int echo_create(struct lustre_handle *conn, struct obdo *oa,
                 return -ENOENT;
         }
 
-        if (!(oa->o_valid & OBD_MD_FLMODE)) {
+        if (!(oa->o_valid & OBD_MD_FLTYPE)) {
                 CERROR("invalid o_valid %08x\n", oa->o_valid);
                 return -EINVAL;
         }
@@ -169,8 +176,8 @@ int echo_destroy(struct lustre_handle *conn, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
-        if (oa->o_id > obd->u.echo.eo_lastino) {
-                CERROR("bad destroy objid: %Ld\n", (long long)oa->o_id);
+        if (oa->o_id > obd->u.echo.eo_lastino || oa->o_id < ECHO_INIT_OBJID) {
+                CERROR("bad destroy objid: "LPX64"\n", oa->o_id);
                 RETURN(-EINVAL);
         }
 
@@ -179,6 +186,18 @@ int echo_destroy(struct lustre_handle *conn, struct obdo *oa,
         return 0;
 }
 
+static int echo_open(struct lustre_handle *conn, struct obdo *oa,
+                     struct lov_stripe_md *md)
+{
+        return 0;
+}
+
+static int echo_close(struct lustre_handle *conn, struct obdo *oa,
+                      struct lov_stripe_md *md)
+{
+        return 0;
+}
+
 static int echo_getattr(struct lustre_handle *conn, struct obdo *oa,
                         struct lov_stripe_md *md)
 {
@@ -393,6 +412,8 @@ static int echo_setup(struct obd_device *obddev, obd_count len, void *buf)
                 LBUG();
                 RETURN(-ENOMEM);
         }
+        spin_lock_init(&obddev->u.echo.eo_lock);
+        obddev->u.echo.eo_lastino = ECHO_INIT_OBJID;
 
         RETURN(0);
 }
@@ -408,11 +429,32 @@ static int echo_cleanup(struct obd_device *obddev)
         RETURN(0);
 }
 
+int echo_attach(struct obd_device *dev, 
+                   obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int echo_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+
+}
+
+
 struct obd_ops echo_obd_ops = {
+        o_attach:       echo_attach,
+        o_detach:       echo_detach,
         o_connect:      echo_connect,
         o_disconnect:   echo_disconnect,
         o_create:       echo_create,
         o_destroy:      echo_destroy,
+        o_open:         echo_open,
+        o_close:        echo_close,
         o_getattr:      echo_getattr,
         o_setattr:      echo_setattr,
         o_preprw:       echo_preprw,
@@ -423,16 +465,25 @@ struct obd_ops echo_obd_ops = {
 
 static int __init obdecho_init(void)
 {
+        int rc;
+        
+
         printk(KERN_INFO "Echo OBD driver " OBDECHO_VERSION
                " info@clusterfs.com\n");
 
         echo_proc_init();
+        rc = class_register_type(&echo_obd_ops, 
+                                 (lprocfs_vars_t*)status_class_var, 
+                                 OBD_ECHO_DEVICENAME);
+        if (rc) RETURN(rc);
+        
+        return 0;
 
-        return class_register_type(&echo_obd_ops, OBD_ECHO_DEVICENAME);
 }
 
 static void __exit obdecho_exit(void)
 {
+                
         echo_proc_fini();
 
         class_unregister_type(OBD_ECHO_DEVICENAME);