static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
{
- struct client_obd *cli = &obd->u.cli;
- struct lprocfs_static_vars lvars = { 0 };
- int rc;
- ENTRY;
+ struct client_obd *cli = &obd->u.cli;
+ struct lprocfs_static_vars lvars = { 0 };
+ int rc;
+ ENTRY;
OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
if (!cli->cl_rpc_lock)
RETURN(-ENOMEM);
mdc_init_rpc_lock(cli->cl_rpc_lock);
- ptlrpcd_addref();
+ rc = ptlrpcd_addref();
+ if (rc < 0)
+ GOTO(err_rpc_lock, rc);
OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
if (!cli->cl_close_lock)
- GOTO(err_rpc_lock, rc = -ENOMEM);
+ GOTO(err_ptlrpcd_decref, rc = -ENOMEM);
mdc_init_rpc_lock(cli->cl_close_lock);
rc = client_obd_setup(obd, cfg);
err_close_lock:
OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
+err_ptlrpcd_decref:
+ ptlrpcd_decref();
err_rpc_lock:
OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
- ptlrpcd_decref();
RETURN(rc);
}
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
- struct lprocfs_static_vars lvars;
- int rc;
+ struct lprocfs_static_vars lvars;
+ int rc;
ENTRY;
- ptlrpcd_addref();
+ rc = ptlrpcd_addref();
+ if (rc < 0)
+ RETURN(rc);
rc = client_obd_setup(obd, lcfg);
if (rc)
static int ptlrpcd_init(void)
{
- int nthreads = num_online_cpus();
- char name[16];
- int size, i = -1, j, rc = 0;
+ int nthreads = num_online_cpus();
+ char name[16];
+ int size, i = -1, j, rc = 0;
ENTRY;
#ifdef __KERNEL__
ptlrpcds = NULL;
}
- RETURN(0);
+ RETURN(rc);
}
int ptlrpcd_addref(void)
ENTRY;
mutex_lock(&ptlrpcd_mutex);
- if (++ptlrpcd_users == 1)
- rc = ptlrpcd_init();
+ if (++ptlrpcd_users == 1) {
+ rc = ptlrpcd_init();
+ if (rc < 0)
+ ptlrpcd_users--;
+ }
mutex_unlock(&ptlrpcd_mutex);
RETURN(rc);
}