Commit 18fd8850 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/ldlm: Preparation to move /proc/fs/lustre/ldlm to sysfs

Add necessary infrastructure, register /sys/fs/lustre/ldlm,
/sys/fs/lustre/ldlm/namespaces and /sys/fs/lustre/ldlm/services
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 070c29ca
......@@ -60,6 +60,9 @@
struct obd_ops;
struct obd_device;
extern struct kset *ldlm_ns_kset;
extern struct kset *ldlm_svc_kset;
#define OBD_LDLM_DEVICENAME "ldlm"
#define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus())
......@@ -501,6 +504,9 @@ struct ldlm_namespace {
* recalculation of LDLM pool statistics should be skipped.
*/
unsigned ns_stopping:1;
struct kobject ns_kobj; /* sysfs object */
struct completion ns_kobj_unregister;
};
/**
......
......@@ -58,6 +58,10 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on");
static struct mutex ldlm_ref_mutex;
static int ldlm_refcount;
struct kobject *ldlm_kobj;
struct kset *ldlm_ns_kset;
struct kset *ldlm_svc_kset;
struct ldlm_cb_async_args {
struct ldlm_cb_set_arg *ca_set_arg;
struct ldlm_lock *ca_lock;
......@@ -1002,6 +1006,15 @@ void ldlm_destroy_export(struct obd_export *exp)
}
EXPORT_SYMBOL(ldlm_destroy_export);
/* These are for root of /sys/fs/lustre/ldlm */
struct attribute *ldlm_attrs[] = {
NULL,
};
static struct attribute_group ldlm_attr_group = {
.attrs = ldlm_attrs,
};
static int ldlm_setup(void)
{
static struct ptlrpc_service_conf conf;
......@@ -1016,6 +1029,28 @@ static int ldlm_setup(void)
if (ldlm_state == NULL)
return -ENOMEM;
ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj);
if (!ldlm_kobj) {
rc = -ENOMEM;
goto out;
}
rc = sysfs_create_group(ldlm_kobj, &ldlm_attr_group);
if (rc)
goto out;
ldlm_ns_kset = kset_create_and_add("namespaces", NULL, ldlm_kobj);
if (!ldlm_ns_kset) {
rc = -ENOMEM;
goto out;
}
ldlm_svc_kset = kset_create_and_add("services", NULL, ldlm_kobj);
if (!ldlm_svc_kset) {
rc = -ENOMEM;
goto out;
}
rc = ldlm_proc_setup();
if (rc != 0)
goto out;
......@@ -1088,7 +1123,6 @@ static int ldlm_setup(void)
goto out;
}
rc = ldlm_pools_init();
if (rc) {
CERROR("Failed to initialize LDLM pools: %d\n", rc);
......@@ -1135,6 +1169,13 @@ static int ldlm_cleanup(void)
if (ldlm_state->ldlm_cb_service != NULL)
ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
if (ldlm_ns_kset)
kset_unregister(ldlm_ns_kset);
if (ldlm_svc_kset)
kset_unregister(ldlm_svc_kset);
if (ldlm_kobj)
kobject_put(ldlm_kobj);
ldlm_proc_cleanup();
......
......@@ -307,6 +307,24 @@ static ssize_t lprocfs_elc_seq_write(struct file *file,
}
LPROC_SEQ_FOPS(lprocfs_elc);
/* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */
static struct attribute *ldlm_ns_attrs[] = {
NULL,
};
static void ldlm_ns_release(struct kobject *kobj)
{
struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
ns_kobj);
complete(&ns->ns_kobj_unregister);
}
static struct kobj_type ldlm_ns_ktype = {
.default_attrs = ldlm_ns_attrs,
.sysfs_ops = &lustre_sysfs_ops,
.release = ldlm_ns_release,
};
void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
{
if (ns->ns_proc_dir_entry == NULL)
......@@ -319,6 +337,12 @@ void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
lprocfs_free_stats(&ns->ns_stats);
}
void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns)
{
kobject_put(&ns->ns_kobj);
wait_for_completion(&ns->ns_kobj_unregister);
}
#define LDLM_NS_ADD_VAR(name, var, ops) \
do { \
snprintf(lock_name, MAX_STRING_SIZE, name); \
......@@ -327,6 +351,19 @@ void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
lprocfs_add_vars(ns_pde, lock_vars, NULL); \
} while (0)
int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns)
{
int err;
ns->ns_kobj.kset = ldlm_ns_kset;
init_completion(&ns->ns_kobj_unregister);
err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL,
"%s", ldlm_ns_name(ns));
return err;
}
int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
{
struct lprocfs_vars lock_vars[2];
......@@ -636,10 +673,17 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
ns->ns_orig_connect_flags = 0;
ns->ns_connect_flags = 0;
ns->ns_stopping = 0;
rc = ldlm_namespace_sysfs_register(ns);
if (rc != 0) {
CERROR("Can't initialize ns sysfs, rc %d\n", rc);
goto out_hash;
}
rc = ldlm_namespace_proc_register(ns);
if (rc != 0) {
CERROR("Can't initialize ns proc, rc %d\n", rc);
goto out_hash;
goto out_sysfs;
}
idx = ldlm_namespace_nr_read(client);
......@@ -653,6 +697,8 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
return ns;
out_proc:
ldlm_namespace_proc_unregister(ns);
out_sysfs:
ldlm_namespace_sysfs_unregister(ns);
ldlm_namespace_cleanup(ns, 0);
out_hash:
cfs_hash_putref(ns->ns_rs_hash);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment