Commit 328676f8 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/ptlrpc: Add infrastructure for sysfs migration

Added necessary plumbing for ptlrpc sysfs integration for registered
services, sysfs directory registration.
Signed-off-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4361a048
...@@ -2016,6 +2016,10 @@ struct ptlrpc_service { ...@@ -2016,6 +2016,10 @@ struct ptlrpc_service {
int srv_cpt_bits; int srv_cpt_bits;
/** CPT table this service is running over */ /** CPT table this service is running over */
struct cfs_cpt_table *srv_cptable; struct cfs_cpt_table *srv_cptable;
/* sysfs object */
struct kobject srv_kobj;
struct completion srv_kobj_unregister;
/** /**
* partition data for ptlrpc service * partition data for ptlrpc service
*/ */
...@@ -2525,6 +2529,7 @@ void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs); ...@@ -2525,6 +2529,7 @@ void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs);
int ptlrpc_hpreq_handler(struct ptlrpc_request *req); int ptlrpc_hpreq_handler(struct ptlrpc_request *req);
struct ptlrpc_service *ptlrpc_register_service( struct ptlrpc_service *ptlrpc_register_service(
struct ptlrpc_service_conf *conf, struct ptlrpc_service_conf *conf,
struct kset *parent,
struct proc_dir_entry *proc_entry); struct proc_dir_entry *proc_entry);
void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
......
...@@ -1112,7 +1112,8 @@ static int ldlm_setup(void) ...@@ -1112,7 +1112,8 @@ static int ldlm_setup(void)
}, },
}; };
ldlm_state->ldlm_cb_service = ldlm_state->ldlm_cb_service =
ptlrpc_register_service(&conf, ldlm_svc_proc_dir); ptlrpc_register_service(&conf, ldlm_svc_kset,
ldlm_svc_proc_dir);
if (IS_ERR(ldlm_state->ldlm_cb_service)) { if (IS_ERR(ldlm_state->ldlm_cb_service)) {
CERROR("failed to start service\n"); CERROR("failed to start service\n");
rc = PTR_ERR(ldlm_state->ldlm_cb_service); rc = PTR_ERR(ldlm_state->ldlm_cb_service);
......
...@@ -1049,6 +1049,46 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, ...@@ -1049,6 +1049,46 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
} }
LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio); LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio);
static struct attribute *ptlrpc_svc_attrs[] = {
NULL,
};
static void ptlrpc_sysfs_svc_release(struct kobject *kobj)
{
struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
srv_kobj);
complete(&svc->srv_kobj_unregister);
}
static struct kobj_type ptlrpc_svc_ktype = {
.default_attrs = ptlrpc_svc_attrs,
.sysfs_ops = &lustre_sysfs_ops,
.release = ptlrpc_sysfs_svc_release,
};
void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc)
{
/* Let's see if we had a chance at initialization first */
if (svc->srv_kobj.kset) {
kobject_put(&svc->srv_kobj);
wait_for_completion(&svc->srv_kobj_unregister);
}
}
int ptlrpc_sysfs_register_service(struct kset *parent,
struct ptlrpc_service *svc)
{
int rc;
svc->srv_kobj.kset = parent;
init_completion(&svc->srv_kobj_unregister);
rc = kobject_init_and_add(&svc->srv_kobj, &ptlrpc_svc_ktype, NULL,
"%s", svc->srv_name);
return rc;
}
void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
struct ptlrpc_service *svc) struct ptlrpc_service *svc)
{ {
......
...@@ -76,6 +76,10 @@ void ptlrpc_initiate_recovery(struct obd_import *imp); ...@@ -76,6 +76,10 @@ void ptlrpc_initiate_recovery(struct obd_import *imp);
int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset); int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset);
int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset); int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
int ptlrpc_sysfs_register_service(struct kset *parent,
struct ptlrpc_service *svc);
void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc);
#if defined(CONFIG_PROC_FS) #if defined(CONFIG_PROC_FS)
void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry, void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
struct ptlrpc_service *svc); struct ptlrpc_service *svc);
......
...@@ -680,6 +680,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, ...@@ -680,6 +680,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
*/ */
struct ptlrpc_service * struct ptlrpc_service *
ptlrpc_register_service(struct ptlrpc_service_conf *conf, ptlrpc_register_service(struct ptlrpc_service_conf *conf,
struct kset *parent,
struct proc_dir_entry *proc_entry) struct proc_dir_entry *proc_entry)
{ {
struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt;
...@@ -798,6 +799,12 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, ...@@ -798,6 +799,12 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
list_add(&service->srv_list, &ptlrpc_all_services); list_add(&service->srv_list, &ptlrpc_all_services);
mutex_unlock(&ptlrpc_all_services_mutex); mutex_unlock(&ptlrpc_all_services_mutex);
if (parent) {
rc = ptlrpc_sysfs_register_service(parent, service);
if (rc)
goto failed;
}
if (proc_entry != NULL) if (proc_entry != NULL)
ptlrpc_lprocfs_register_service(proc_entry, service); ptlrpc_lprocfs_register_service(proc_entry, service);
...@@ -3033,6 +3040,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service) ...@@ -3033,6 +3040,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service)
ptlrpc_service_nrs_cleanup(service); ptlrpc_service_nrs_cleanup(service);
ptlrpc_lprocfs_unregister_service(service); ptlrpc_lprocfs_unregister_service(service);
ptlrpc_sysfs_unregister_service(service);
ptlrpc_service_free(service); ptlrpc_service_free(service);
......
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