]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: proc subdir for each ceph client
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 11 Feb 2009 00:08:02 +0000 (16:08 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 11 Feb 2009 00:08:02 +0000 (16:08 -0800)
src/kernel/proc.c
src/kernel/super.c
src/kernel/super.h

index 9838f6a51cc31a102abfe4ae47559b7f9f37b0f3..de9e9bca690c91ab4b2f11bd3231c4d3fd0f354a 100644 (file)
@@ -140,6 +140,7 @@ static int ceph_debug_mask_write(struct file *file, const char __user *buffer,
 }
 
 static struct proc_dir_entry *proc_fs_ceph;
+static struct proc_dir_entry *proc_fs_ceph_clients;
 
 int ceph_proc_init(void)
 {
@@ -172,14 +173,37 @@ int ceph_proc_init(void)
        if (pde)
                pde->write_proc = ceph_debug_mask_write;
 
+       proc_fs_ceph_clients = proc_mkdir("clients", proc_fs_ceph);
+
        return 0;
 }
 
 void ceph_proc_cleanup(void)
 {
+       struct list_head *p;
+       struct ceph_client *client;
+       char str[16];
+
+       spin_lock(&ceph_clients_list_lock);
+       list_for_each(p, &ceph_clients) {
+               client = list_entry(p, struct ceph_client, clients_all);
+               snprintf(str, sizeof(str), "%d", client->whoami);
+               remove_proc_entry(str, proc_fs_ceph_clients);
+       }
+       spin_unlock(&ceph_clients_list_lock);
+       remove_proc_entry("clients", proc_fs_ceph_clients);
+
        remove_proc_entry("debug", proc_fs_ceph);
        remove_proc_entry("debug_msgr", proc_fs_ceph);
        remove_proc_entry("debug_console", proc_fs_ceph);
        remove_proc_entry("debug_mask", proc_fs_ceph);
        remove_proc_entry("fs/ceph", NULL);
 }
+
+void ceph_proc_register_client(struct ceph_client *client)
+{
+       char str[16];
+
+       snprintf(str, sizeof(str), "%d", client->whoami);
+       client->proc_entry = proc_mkdir(str, proc_fs_ceph_clients);
+}
index 23940fcc8201c73ef65fb1acdd44cd6e46b29145..640235dc0d744013156120c5cf1e2186812ecadc 100644 (file)
@@ -28,7 +28,7 @@ int ceph_debug_console;
 int ceph_debug_super = -1;   /* for this file */
 
 struct list_head ceph_clients;
-static spinlock_t _clients_list_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t ceph_clients_list_lock = SPIN_LOCK_UNLOCKED;
 
 #define DOUT_MASK DOUT_MASK_SUPER
 #define DOUT_VAR ceph_debug_super
@@ -251,6 +251,7 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg)
        if (first) {
                char name[10];
                client->whoami = le32_to_cpu(msg->hdr.dst.name.num);
+               ceph_proc_register_client(client);
                client->msgr->inst.name = msg->hdr.dst.name;
                sprintf(name, "client%d", client->whoami);
                dout(1, "i am %s, fsid is %llx.%llx\n", name,
@@ -1028,9 +1029,9 @@ static int ceph_get_sb(struct file_system_type *fs_type,
                dout(20, "get_sb got existing client %p\n", client);
        } else {
                dout(20, "get_sb using new client %p\n", client);
-               spin_lock(&_clients_list_lock);
+               spin_lock(&ceph_clients_list_lock);
                list_add(&client->clients_all, &ceph_clients);
-               spin_unlock(&_clients_list_lock);
+               spin_unlock(&ceph_clients_list_lock);
 
                err = ceph_init_bdi(sb, client);
                if (err < 0)
index 85c3272b40808a315a598fee5e69a422975df83f..48b4f69b23b4df825427cf6aab80430ddb2bfc71 100644 (file)
@@ -79,6 +79,10 @@ enum {
 
 extern struct kobject *ceph_kobj;
 
+extern struct list_head ceph_clients;
+extern spinlock_t ceph_clients_list_lock;
+
+
 /*
  * per-filesystem client state
  *
@@ -111,6 +115,7 @@ struct ceph_client {
 
        struct backing_dev_info backing_dev_info;
        struct list_head clients_all;
+       struct proc_dir_entry *proc_entry;
 };
 
 static inline struct ceph_client *ceph_client(struct super_block *sb)
@@ -785,6 +790,7 @@ extern const struct export_operations ceph_export_ops;
 /* proc.c */
 extern int ceph_proc_init(void);
 extern void ceph_proc_cleanup(void);
+extern void ceph_proc_register_client(struct ceph_client *client);
 
 static inline struct inode *get_dentry_parent_inode(struct dentry *dentry)
 {