int rc;
ENTRY;
+ down_write(&cli->cl_seq_rwsem);
OBD_ALLOC_PTR(cli->cl_seq);
- if (cli->cl_seq == NULL)
- RETURN(-ENOMEM);
+ if (!cli->cl_seq)
+ GOTO(out, rc = -ENOMEM);
OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
- if (prefix == NULL)
- GOTO(out_free_seq, rc = -ENOMEM);
+ if (!prefix)
+ GOTO(out, rc = -ENOMEM);
snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name);
/* Init client side sequence-manager */
rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL);
OBD_FREE(prefix, MAX_OBD_NAME + 5);
- if (rc)
- GOTO(out_free_seq, rc);
- RETURN(rc);
-out_free_seq:
- OBD_FREE_PTR(cli->cl_seq);
- cli->cl_seq = NULL;
+ GOTO(out, rc);
+
+out:
+ if (rc && cli->cl_seq) {
+ OBD_FREE_PTR(cli->cl_seq);
+ cli->cl_seq = NULL;
+ }
+ up_write(&cli->cl_seq_rwsem);
+
return rc;
}
EXPORT_SYMBOL(client_fid_init);
struct client_obd *cli = &obd->u.cli;
ENTRY;
- if (cli->cl_seq != NULL) {
+ down_write(&cli->cl_seq_rwsem);
+ if (cli->cl_seq) {
seq_client_fini(cli->cl_seq);
OBD_FREE_PTR(cli->cl_seq);
cli->cl_seq = NULL;
}
+ up_write(&cli->cl_seq_rwsem);
RETURN(0);
}
/* sequence manager */
struct lu_client_seq *cl_seq;
+ struct rw_semaphore cl_seq_rwsem;
atomic_t cl_resends; /* resend count */
init_rwsem(&cli->cl_sem);
mutex_init(&cli->cl_mgc_mutex);
- cli->cl_conn_count = 0;
- memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
- min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
- sizeof(server_uuid)));
+ cli->cl_seq = NULL;
+ init_rwsem(&cli->cl_seq_rwsem);
+ cli->cl_conn_count = 0;
+ memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
+ min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
+ sizeof(server_uuid)));
cli->cl_dirty_pages = 0;
cli->cl_avail_grant = 0;
* Flush current sequence to make client obtain new one
* from server in case of disconnect/reconnect.
*/
- if (cli->cl_seq != NULL)
+ down_read(&cli->cl_seq_rwsem);
+ if (cli->cl_seq)
seq_client_flush(cli->cl_seq);
+ up_read(&cli->cl_seq_rwsem);
rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE);
break;
struct lu_fid *fid, struct md_op_data *op_data)
{
struct client_obd *cli = &exp->exp_obd->u.cli;
- struct lu_client_seq *seq = cli->cl_seq;
+ int rc = -EIO;
+
ENTRY;
- RETURN(seq_client_alloc_fid(env, seq, fid));
+
+ down_read(&cli->cl_seq_rwsem);
+ if (cli->cl_seq)
+ rc = seq_client_alloc_fid(env, cli->cl_seq, fid);
+ up_read(&cli->cl_seq_rwsem);
+
+ RETURN(rc);
}
static struct obd_uuid *mdc_get_uuid(struct obd_export *exp)