Whamcloud - gitweb
Lproc-snmp code drop
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 3e26333..5700797 100644 (file)
 #include <linux/obd_support.h> /* for OBD_FAIL_CHECK */
 #include <linux/lustre_lite.h> /* for ll_i2info */
 #include <portals/lib-types.h> /* for PTL_MD_MAX_IOV */
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
 
 static int osc_getattr(struct lustre_handle *conn, struct obdo *oa,
                        struct lov_stripe_md *md)
@@ -244,11 +248,10 @@ static int osc_punch(struct lustre_handle *conn, struct obdo *oa,
 #warning FIXME: pack only valid fields instead of memcpy, endianness, valid
         memcpy(&body->oa, oa, sizeof(*oa));
 
-        /* overload the blocks and size fields in the oa with start/end */
-#warning FIXME: endianness, size=start, blocks=end?
-        body->oa.o_blocks = start;
-        body->oa.o_size = end;
-        body->oa.o_valid |= OBD_MD_FLBLOCKS | OBD_MD_FLSIZE;
+        /* overload the size and blocks fields in the oa with start/end */
+        body->oa.o_size = HTON__u64(start);
+        body->oa.o_blocks = HTON__u64(end);
+        body->oa.o_valid |= HTON__u32(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
 
         request->rq_replen = lustre_msg_size(1, &size);
 
@@ -392,6 +395,7 @@ static int osc_brw_read(struct lustre_handle *conn, struct lov_stripe_md *lsm,
 
         cb_data->callback = callback;
         cb_data->cb_data = data;
+        CDEBUG(D_PAGE, "data(%p)->desc = %p\n", data, desc);
         data->desc = desc;
         desc->bd_cb_data = cb_data;
 
@@ -510,6 +514,7 @@ static int osc_brw_write(struct lustre_handle *conn, struct lov_stripe_md *md,
 
         cb_data->callback = callback;
         cb_data->cb_data = data;
+        CDEBUG(D_PAGE, "data(%p)->desc = %p\n", data, desc);
         data->desc = desc;
         desc->bd_cb_data = cb_data;
 
@@ -661,7 +666,8 @@ static int osc_enqueue(struct lustre_handle *connh, struct lov_stripe_md *lsm,
         rc = ldlm_lock_match(obddev->obd_namespace, res_id, type, extent,
                              sizeof(extent), mode, lockh);
         if (rc == 1)
-                RETURN(0); /* We already have a lock, and it's referenced */
+                /* We already have a lock, and it's referenced */
+                RETURN(ELDLM_OK);
 
         /* If we're trying to read, we also search for an existing PW lock.  The
          * VFS and page cache already protect us locally, so lots of readers/
@@ -685,7 +691,7 @@ static int osc_enqueue(struct lustre_handle *connh, struct lov_stripe_md *lsm,
                         ldlm_lock_addref(lockh, LCK_PR);
                         ldlm_lock_decref(lockh, LCK_PW);
 
-                        RETURN(0);
+                        RETURN(ELDLM_OK);
                 }
         }
 
@@ -707,12 +713,12 @@ static int osc_cancel(struct lustre_handle *oconn, struct lov_stripe_md *md,
 }
 
 static int osc_cancel_unused(struct lustre_handle *connh,
-                             struct lov_stripe_md *lsm, int local)
+                             struct lov_stripe_md *lsm, int flags)
 {
         struct obd_device *obddev = class_conn2obd(connh);
         __u64 res_id[RES_NAME_SIZE] = { lsm->lsm_object_id };
 
-        return ldlm_cli_cancel_unused(obddev->obd_namespace, res_id, local);
+        return ldlm_cli_cancel_unused(obddev->obd_namespace, res_id, flags);
 }
 
 static int osc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
@@ -813,7 +819,24 @@ out:
         return err;
 }
 
+int osc_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 osc_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+
+}
 struct obd_ops osc_obd_ops = {
+        o_attach:       osc_attach,
+        o_detach:       osc_detach,
         o_setup:        client_obd_setup,
         o_cleanup:      client_obd_cleanup,
         o_statfs:       osc_statfs,
@@ -835,7 +858,15 @@ struct obd_ops osc_obd_ops = {
 
 static int __init osc_init(void)
 {
-        return class_register_type(&osc_obd_ops, LUSTRE_OSC_NAME);
+        int rc;
+        
+        rc = class_register_type(&osc_obd_ops,
+                                 (lprocfs_vars_t*)status_class_var, 
+                                 LUSTRE_OSC_NAME);
+        if (rc)
+                RETURN(rc);
+        return 0;
+       
 }
 
 static void __exit osc_exit(void)