]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: add osdc data to sysfs
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 10 Mar 2009 00:01:31 +0000 (17:01 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 10 Mar 2009 00:01:31 +0000 (17:01 -0700)
src/kernel/osd_client.c
src/kernel/osd_client.h
src/kernel/super.h
src/kernel/sysfs.c

index 1b15e2ea1d362efbcdd67b37511a5c0ee1402297..832632b77cb5a473ccd39ce07cf7467f3ae5c9d1 100644 (file)
@@ -194,6 +194,7 @@ static int register_request(struct ceph_osd_client *osdc,
                      round_jiffies_relative(req->r_timeout_stamp - jiffies));
        }
 
+       ceph_sysfs_osd_req_init(osdc, req);
 out:
        mutex_unlock(&osdc->request_mutex);
        return rc;
@@ -296,6 +297,8 @@ static void __unregister_request(struct ceph_osd_client *osdc,
                                                     jiffies));
                }
        }
+
+       ceph_sysfs_osd_req_cleanup(req);
 }
 
 /*
index 687ec787fa6e319156c945effba528d3874d65e8..0f60a9bdadb5a3f32daa0964cce5e291bfa551bd 100644 (file)
@@ -32,9 +32,21 @@ struct ceph_osd_request;
  */
 typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *);
 
+struct ceph_osd_request_attr {
+       struct attribute attr;
+       ssize_t (*show)(struct ceph_osd_request *, struct ceph_osd_request_attr *,
+                       char *);
+       ssize_t (*store)(struct ceph_osd_request *, struct ceph_osd_request_attr *,
+                       const char *, size_t);
+};
+
 /* an in-flight request */
 struct ceph_osd_request {
        u64             r_tid;              /* unique for this client */
+
+       struct kobject    kobj;
+       struct ceph_osd_request_attr k_osd, k_op;
+
        struct ceph_msg  *r_request;
        struct ceph_msg  *r_reply;
        int               r_result;
@@ -71,6 +83,7 @@ struct ceph_osd_client {
        struct radix_tree_root request_tree;  /* pending requests, by tid */
        int                    num_requests;
        struct delayed_work    timeout_work;
+       struct kobject         kobj;
 };
 
 extern void ceph_osdc_init(struct ceph_osd_client *osdc,
index 96389c631a372b7db145d63e6c678e0f2fff90c5..f6b0b8d109a7265d37e5a9d43c3fff2e6151e023 100644 (file)
@@ -801,6 +801,8 @@ extern int ceph_sysfs_init(void);
 extern void ceph_sysfs_cleanup(void);
 extern int ceph_sysfs_mds_req_init(struct ceph_mds_client *mdsc, struct ceph_mds_request *req);
 extern void ceph_sysfs_mds_req_cleanup(struct ceph_mds_request *req);
+extern int ceph_sysfs_osd_req_init(struct ceph_osd_client *osdc, struct ceph_osd_request *req);
+extern void ceph_sysfs_osd_req_cleanup(struct ceph_osd_request *req);
 
 static inline struct inode *get_dentry_parent_inode(struct dentry *dentry)
 {
index 37dda51a8aff965915962f853ee45b5d8bf69343..d1325e08ea2962ac31966655ac5e578edf52db2e 100644 (file)
@@ -55,7 +55,8 @@ static struct kobj_type name##_ops = {                                                \
 
 
 DEF_ATTR_OP(ceph_client)
-
+DEF_ATTR_OP(ceph_mds_request)
+DEF_ATTR_OP(ceph_osd_request)
 
 /*
  * per-client attributes
@@ -175,6 +176,11 @@ int ceph_sysfs_client_init(struct ceph_client *client)
        if (ret)
                goto out;
 
+       ret = kobject_init_and_add(&client->osdc.kobj, &entity_ops,
+                                  &client->kobj, "osdc");
+       if (ret)
+               goto out;
+
        ADD_ENTITY_ATTR(client, k_fsid, "fsid", 0400, fsid_show, NULL);
        ADD_ENTITY_ATTR(client, k_monmap, "monmap", 0400, monmap_show, NULL);
        ADD_ENTITY_ATTR(client, k_mdsmap, "mdsmap", 0400, mdsmap_show, NULL);
@@ -189,13 +195,12 @@ out:
 void ceph_sysfs_client_cleanup(struct ceph_client *client)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+       kobject_del(&client->osdc.kobj);
        kobject_del(&client->mdsc.kobj);
        kobject_del(&client->kobj);
 #endif 
 }
 
-DEF_ATTR_OP(ceph_mds_request)
-
 static ssize_t req_mds_show(struct ceph_mds_request *req,
                           struct ceph_mds_request_attr *attr, char *buf)
 {
@@ -204,7 +209,7 @@ static ssize_t req_mds_show(struct ceph_mds_request *req,
                        ENTITY_NAME(req->r_request->hdr.dst.name));
 }
 
-static ssize_t req_op_show(struct ceph_mds_request *req,
+static ssize_t req_mds_op_show(struct ceph_mds_request *req,
                           struct ceph_mds_request_attr *attr, char *buf)
 {
        int pos = 0, pathlen;
@@ -251,10 +256,9 @@ int ceph_sysfs_mds_req_init(struct ceph_mds_client *mdsc, struct ceph_mds_reques
                goto out;
 
        ADD_ENTITY_ATTR(req, k_mds, "mds", 0400, req_mds_show, NULL);
-       ADD_ENTITY_ATTR(req, k_op, "op", 0400, req_op_show, NULL);
+       ADD_ENTITY_ATTR(req, k_op, "op", 0400, req_mds_op_show, NULL);
 
        return 0;
-
 out:
 #endif
        return ret;
@@ -267,6 +271,69 @@ void ceph_sysfs_mds_req_cleanup(struct ceph_mds_request *req)
 #endif
 }
 
+static ssize_t req_osd_show(struct ceph_osd_request *req,
+                          struct ceph_osd_request_attr *attr, char *buf)
+{
+       return sprintf(buf, "%u.%u.%u.%u:%u (%s%d)\n",
+                       IPQUADPORT(req->r_request->hdr.dst.addr.ipaddr),
+                       ENTITY_NAME(req->r_request->hdr.dst.name));
+}
+
+static ssize_t req_osd_op_show(struct ceph_osd_request *req,
+                          struct ceph_osd_request_attr *attr, char *buf)
+{
+       struct ceph_osd_request_head *head = req->r_request->front.iov_base;
+       struct ceph_osd_op *op;
+       int num_ops;
+       int pos = 0;
+       int opcode;
+       int i;
+
+       op = (void *)(head + 1);
+
+       pos += sprintf(buf, "oid=%llx.%08x (snap=%lld)\n",
+            le64_to_cpu(head->oid.ino),
+            le32_to_cpu(head->oid.bno),
+            le64_to_cpu(head->oid.snap));
+
+       num_ops = le16_to_cpu(head->num_ops);
+
+       for (i=0; i<num_ops; i++) {
+               opcode = le16_to_cpu(op->op);
+
+               pos += sprintf(buf + pos, "%s\n", ceph_osd_op_name(opcode));
+               op++;
+       }
+
+       return pos;
+}
+
+int ceph_sysfs_osd_req_init(struct ceph_osd_client *osdc, struct ceph_osd_request *req)
+{
+       int ret = 0;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+       ret = kobject_init_and_add(&req->kobj, &ceph_osd_request_ops,
+                                  &osdc->kobj, "%d", req->r_tid);
+       if (ret)
+               goto out;
+
+       ADD_ENTITY_ATTR(req, k_osd, "osd", 0400, req_osd_show, NULL);
+       ADD_ENTITY_ATTR(req, k_op, "op", 0400, req_osd_op_show, NULL);
+
+       return 0;
+out:
+#endif
+       return ret;
+}
+
+void ceph_sysfs_osd_req_cleanup(struct ceph_osd_request *req)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+       kobject_del(&req->kobj);
+#endif
+}
+
 /*
  * ceph attrs
  */