]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: add sysfs directory per mds request
authorYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 9 Mar 2009 17:08:29 +0000 (10:08 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 9 Mar 2009 17:08:29 +0000 (10:08 -0700)
src/kernel/mds_client.c
src/kernel/mds_client.h
src/kernel/super.h
src/kernel/sysfs.c

index 559ecbd26175b240f952f1a7c0a5a4a0a3a7eb83..239b4b9f6688dd571732964682495e338bf9e1bc 100644 (file)
@@ -446,6 +446,8 @@ static void __register_request(struct ceph_mds_client *mdsc,
                list_add_tail(&req->r_listener_item, &ci->i_listener_list);
                spin_unlock(&ci->i_listener_lock);
        }
+
+       ceph_sysfs_mds_req_init(mdsc, req);
 }
 
 static void __unregister_request(struct ceph_mds_client *mdsc,
@@ -462,6 +464,8 @@ static void __unregister_request(struct ceph_mds_client *mdsc,
                list_del_init(&req->r_listener_item);
                spin_unlock(&ci->i_listener_lock);
        }
+
+       ceph_sysfs_mds_req_cleanup(req);
 }
 
 static bool __have_session(struct ceph_mds_client *mdsc, int mds)
index 8c3f8fbef0b048da9ecb2d40f13f97d3436e696d..0d2dc9d57ab76b2102aa3837d04dd431920157cc 100644 (file)
@@ -192,6 +192,8 @@ struct ceph_mds_request {
        ceph_mds_request_callback_t r_callback;
        struct list_head  r_unsafe_item;  /* per-session unsafe list item */
        bool              r_got_unsafe, r_got_safe;
+
+       struct kobject    kobj;
 };
 
 /*
@@ -229,6 +231,8 @@ struct ceph_mds_client {
        spinlock_t       cap_delay_lock;   /* protects cap_delay_list */
        struct list_head snap_flush_list;  /* cap_snaps ready to flush */
        spinlock_t       snap_flush_lock;
+
+       struct kobject          kobj;
 };
 
 extern const char *ceph_mds_op_name(int op);
index ca87899df15d10aad908767d1d336f7ab4f5c601..96389c631a372b7db145d63e6c678e0f2fff90c5 100644 (file)
@@ -799,6 +799,8 @@ extern int ceph_sysfs_client_init(struct ceph_client *client);
 extern void ceph_sysfs_client_cleanup(struct ceph_client *client);
 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);
 
 static inline struct inode *get_dentry_parent_inode(struct dentry *dentry)
 {
index debc5d023908379b0103223b1d54f7e28b6108b2..655587b52c4fbb69090d1c84aed059f258ad2539 100644 (file)
@@ -141,6 +141,11 @@ static ssize_t osdmap_show(struct ceph_client *client,
        return pos;
 }
 
+static struct kobj_type entity_type = {
+       .sysfs_ops = &generic_sysfs_ops,
+};
+
+
 #define ADD_CLIENT_ATTR(a, n, m, sh, st) \
        client->a.attr.name = n; \
        client->a.attr.mode = m; \
@@ -158,6 +163,11 @@ int ceph_sysfs_client_init(struct ceph_client *client)
        if (ret)
                goto out;
 
+       ret = kobject_init_and_add(&client->mdsc.kobj, &entity_type,
+                                  &client->kobj, "mdsc");
+       if (ret)
+               goto out;
+
        ADD_CLIENT_ATTR(k_fsid, "fsid", 0400, fsid_show, NULL);
        ADD_CLIENT_ATTR(k_monmap, "monmap", 0400, monmap_show, NULL);
        ADD_CLIENT_ATTR(k_mdsmap, "mdsmap", 0400, mdsmap_show, NULL);
@@ -172,10 +182,35 @@ out:
 void ceph_sysfs_client_cleanup(struct ceph_client *client)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+       kobject_del(&client->mdsc.kobj);
        kobject_del(&client->kobj);
 #endif 
 }
 
+int ceph_sysfs_mds_req_init(struct ceph_mds_client *mdsc, struct ceph_mds_request *req)
+{
+       int ret = 0;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+       ret = kobject_init_and_add(&req->kobj, &client_type,
+                                  &mdsc->kobj, "%d", req->r_tid);
+       if (ret)
+               goto out;
+
+       return 0;
+
+out:
+#endif
+       return ret;
+}
+
+void ceph_sysfs_mds_req_cleanup(struct ceph_mds_request *req)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+       kobject_del(&req->kobj);
+#endif
+}
+
 /*
  * ceph attrs
  */