kclient: proc subdir for each ceph client

This commit is contained in:
Yehuda Sadeh 2009-02-10 16:08:02 -08:00
parent 3b2cffdd61
commit 9ddbf9dbb8
3 changed files with 34 additions and 3 deletions

View 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);
}

View 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)

View 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)
{