From: Yehuda Sadeh Date: Mon, 9 Mar 2009 17:08:29 +0000 (-0700) Subject: kclient: add sysfs directory per mds request X-Git-Tag: v0.7~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=927926e903fcfc9d26699a51231f4664fae08820;p=ceph.git kclient: add sysfs directory per mds request --- diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index 559ecbd2617..239b4b9f668 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -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) diff --git a/src/kernel/mds_client.h b/src/kernel/mds_client.h index 8c3f8fbef0b..0d2dc9d57ab 100644 --- a/src/kernel/mds_client.h +++ b/src/kernel/mds_client.h @@ -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); diff --git a/src/kernel/super.h b/src/kernel/super.h index ca87899df15..96389c631a3 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -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) { diff --git a/src/kernel/sysfs.c b/src/kernel/sysfs.c index debc5d02390..655587b52c4 100644 --- a/src/kernel/sysfs.c +++ b/src/kernel/sysfs.c @@ -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 */