summaryrefslogtreecommitdiffstats
path: root/src/kernel/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/sysfs.c')
-rw-r--r--src/kernel/sysfs.c143
1 files changed, 136 insertions, 7 deletions
diff --git a/src/kernel/sysfs.c b/src/kernel/sysfs.c
index fc107fd167b..af6ee8c3213 100644
--- a/src/kernel/sysfs.c
+++ b/src/kernel/sysfs.c
@@ -55,7 +55,9 @@ static struct kobj_type name##_ops = { \
DEF_ATTR_OP(ceph_client)
-
+DEF_ATTR_OP(ceph_mds_request)
+DEF_ATTR_OP(ceph_osd_request)
+DEF_ATTR_OP(ceph_mon_statfs_request)
/*
* per-client attributes
@@ -114,7 +116,7 @@ static ssize_t mdsmap_show(struct ceph_client *client,
pos += sprintf(buf+pos, "\tmds%d\t%u.%u.%u.%u:%u\t(%s)\n",
i,
IPQUADPORT(addr->ipaddr),
- ceph_mdsmap_state_str(state));
+ ceph_mds_state_name(state));
}
return pos;
}
@@ -155,6 +157,18 @@ static ssize_t osdmap_show(struct ceph_client *client,
return pos;
}
+static ssize_t req_mon_want_osdmap_show(struct ceph_mon_client *monc,
+ struct ceph_mon_client_attr *attr, char *buf)
+{
+ return sprintf(buf, "%u\n", monc->want_osdmap);
+}
+
+static ssize_t req_mon_want_mdsmap_show(struct ceph_mon_client *monc,
+ struct ceph_mon_client_attr *attr, char *buf)
+{
+ return sprintf(buf, "%u\n", monc->want_mdsmap);
+}
+
static struct kobj_type entity_ops = {
.sysfs_ops = &ceph_client_sysfs_ops,
};
@@ -175,10 +189,22 @@ 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;
+
+ ret = kobject_init_and_add(&client->monc.kobj, &entity_ops,
+ &client->kobj, "monc");
+ 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);
ADD_ENTITY_ATTR(client, k_osdmap, "osdmap", 0400, osdmap_show, NULL);
+ ADD_ENTITY_ATTR((&client->monc), k_want_osdmap, "want_osdmap", 0400, req_mon_want_osdmap_show, NULL);
+ ADD_ENTITY_ATTR((&client->monc), k_want_mdsmap, "want_mdsmap", 0400, req_mon_want_mdsmap_show, NULL);
return 0;
out:
@@ -189,13 +215,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 +229,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 +276,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 +291,111 @@ 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
+}
+
+static ssize_t req_mon_show(struct ceph_mon_statfs_request *req,
+ struct ceph_mon_statfs_request_attr *attr, char *buf)
+{
+ return sprintf(buf, "%u.%u.%u.%u:%u (%s%d)\n",
+ IPQUADPORT(attr->dst.addr.ipaddr),
+ ENTITY_NAME(attr->dst.name));
+}
+
+static ssize_t req_mon_op_show(struct ceph_mon_statfs_request *req,
+ struct ceph_mon_statfs_request_attr *attr, char *buf)
+{
+ return sprintf(buf, "statfs\n");
+}
+
+int ceph_sysfs_mon_statfs_req_init(struct ceph_mon_client *monc, struct ceph_mon_statfs_request *req,
+ struct ceph_msg *msg)
+{
+ int ret = 0;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+ ret = kobject_init_and_add(&req->kobj, &ceph_mon_statfs_request_ops,
+ &monc->kobj, "%d", req->tid);
+ if (ret)
+ goto out;
+
+ req->k_mon.dst = msg->hdr.dst;
+ ADD_ENTITY_ATTR(req, k_mon, "mon", 0400, req_mon_show, NULL);
+ ADD_ENTITY_ATTR(req, k_op, "op", 0400, req_mon_op_show, NULL);
+
+ return 0;
+out:
+#endif
+ return ret;
+}
+
+void ceph_sysfs_mon_statfs_req_cleanup(struct ceph_mon_statfs_request *req)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+ kobject_del(&req->kobj);
+#endif
+}
+
/*
* ceph attrs
*/