*/
static int osp_update_init(struct osp_device *osp)
{
- struct l_wait_info lwi = { 0 };
- struct task_struct *task;
+ struct task_struct *task;
+ int rc;
ENTRY;
if (osp->opd_update == NULL)
RETURN(-ENOMEM);
- init_waitqueue_head(&osp->opd_update_thread.t_ctl_waitq);
init_waitqueue_head(&osp->opd_update->ou_waitq);
spin_lock_init(&osp->opd_update->ou_lock);
INIT_LIST_HEAD(&osp->opd_update->ou_list);
osp->opd_update->ou_version = 1;
osp->opd_update->ou_generation = 0;
+ rc = lu_env_init(&osp->opd_update->ou_env,
+ osp->opd_dt_dev.dd_lu_dev.ld_type->ldt_ctx_tags);
+ if (rc < 0) {
+ CERROR("%s: init env error: rc = %d\n", osp->opd_obd->obd_name,
+ rc);
+ OBD_FREE_PTR(osp->opd_update);
+ osp->opd_update = NULL;
+ RETURN(rc);
+ }
/* start thread handling sending updates to the remote MDT */
- task = kthread_run(osp_send_update_thread, osp,
- "osp_up%u-%u", osp->opd_index, osp->opd_group);
+ task = kthread_create(osp_send_update_thread, osp,
+ "osp_up%u-%u", osp->opd_index, osp->opd_group);
if (IS_ERR(task)) {
int rc = PTR_ERR(task);
+ lu_env_fini(&osp->opd_update->ou_env);
OBD_FREE_PTR(osp->opd_update);
osp->opd_update = NULL;
CERROR("%s: can't start precreate thread: rc = %d\n",
RETURN(rc);
}
- l_wait_event(osp->opd_update_thread.t_ctl_waitq,
- osp_send_update_thread_running(osp) ||
- osp_send_update_thread_stopped(osp), &lwi);
+ osp->opd_update->ou_update_task = task;
+ wake_up_process(task);
RETURN(0);
}
if (ou == NULL)
return;
- osp->opd_update_thread.t_flags = SVC_STOPPING;
- wake_up(&ou->ou_waitq);
-
- wait_event(osp->opd_update_thread.t_ctl_waitq,
- osp->opd_update_thread.t_flags & SVC_STOPPED);
+ kthread_stop(ou->ou_update_task);
+ lu_env_fini(&ou->ou_env);
/* Remove the left osp thandle from the list */
spin_lock(&ou->ou_lock);
RETURN(0);
}
+/**
+ * Implementation of lu_device_operations::ldo_fid_alloc() for OSP
+ *
+ * Allocate FID from remote MDT.
+ *
+ * see include/lu_object.h for the details.
+ */
+static int osp_fid_alloc(const struct lu_env *env, struct lu_device *d,
+ struct lu_fid *fid, struct lu_object *parent,
+ const struct lu_name *name)
+{
+ struct osp_device *osp = lu2osp_dev(d);
+ struct client_obd *cli = &osp->opd_obd->u.cli;
+ struct lu_client_seq *seq = cli->cl_seq;
+ int rc;
+
+ ENTRY;
+
+ /* Sigh, fid client is not ready yet */
+ if (!osp->opd_obd->u.cli.cl_seq)
+ RETURN(-ENOTCONN);
+
+ if (!osp->opd_obd->u.cli.cl_seq->lcs_exp)
+ RETURN(-ENOTCONN);
+
+ rc = seq_client_alloc_fid(env, seq, fid);
+
+ RETURN(rc);
+}
+
const struct lu_device_operations osp_lu_ops = {
.ldo_object_alloc = osp_object_alloc,
.ldo_process_config = osp_process_config,
.ldo_recovery_complete = osp_recovery_complete,
+ .ldo_fid_alloc = osp_fid_alloc,
};
/**
RETURN(0);
CDEBUG(D_OTHER, "%s: %llu blocks, %llu free, %llu avail, "
- "%u reserved mb low, %u reserved mb high,"
+ "%u bsize, %u reserved mb low, %u reserved mb high, "
"%llu files, %llu free files\n", d->opd_obd->obd_name,
- sfs->os_blocks, sfs->os_bfree, sfs->os_bavail,
+ sfs->os_blocks, sfs->os_bfree, sfs->os_bavail, sfs->os_bsize,
d->opd_reserved_mb_low, d->opd_reserved_mb_high,
sfs->os_files, sfs->os_ffree);
RETURN(0);
/*
- * layer above osp (usually lod) can use ffree to estimate
- * how many objects are available for immediate creation
+ * The layer above osp (usually lod) can use f_precreated to
+ * estimate how many objects are available for immediate usage.
*/
spin_lock(&d->opd_pre_lock);
sfs->os_fprecreated = osp_fid_diff(&d->opd_pre_last_created_fid,
RETURN(0);
}
-static int osp_sync_timeout(void *data)
-{
- return 1;
-}
-
/**
* Implementation of dt_device_operations::dt_sync
*
static int osp_sync(const struct lu_env *env, struct dt_device *dev)
{
struct osp_device *d = dt2osp_dev(dev);
- struct l_wait_info lwi = { 0 };
time64_t start = ktime_get_seconds();
int recs, rc = 0;
u64 old;
atomic_read(&d->opd_async_updates_count));
/* make sure the connection is fine */
- lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout), osp_sync_timeout, d);
- rc = l_wait_event(d->opd_sync_barrier_waitq,
- atomic_read(&d->opd_async_updates_count) == 0,
- &lwi);
+ rc = wait_event_idle_timeout(
+ d->opd_sync_barrier_waitq,
+ atomic_read(&d->opd_async_updates_count) == 0,
+ cfs_time_seconds(obd_timeout));
+ if (rc > 0)
+ rc = 0;
+ else if (rc == 0)
+ rc = -ETIMEDOUT;
+
up_write(&d->opd_async_updates_rwsem);
if (rc != 0)
GOTO(out, rc);
while (atomic64_read(&d->opd_sync_processed_recs) < old + recs) {
__u64 last = atomic64_read(&d->opd_sync_processed_recs);
/* make sure the connection is fine */
- lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout),
- osp_sync_timeout, d);
- l_wait_event(d->opd_sync_barrier_waitq,
- atomic64_read(&d->opd_sync_processed_recs)
- >= old + recs, &lwi);
+ wait_event_idle_timeout(
+ d->opd_sync_barrier_waitq,
+ atomic64_read(&d->opd_sync_processed_recs)
+ >= old + recs,
+ cfs_time_seconds(obd_timeout));
if (atomic64_read(&d->opd_sync_processed_recs) >= old + recs)
break;
while (atomic_read(&d->opd_sync_rpcs_in_flight) > 0) {
old = atomic_read(&d->opd_sync_rpcs_in_flight);
- lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout),
- osp_sync_timeout, d);
- l_wait_event(d->opd_sync_barrier_waitq,
- atomic_read(&d->opd_sync_rpcs_in_flight) == 0,
- &lwi);
+ wait_event_idle_timeout(
+ d->opd_sync_barrier_waitq,
+ atomic_read(&d->opd_sync_rpcs_in_flight) == 0,
+ cfs_time_seconds(obd_timeout));
if (atomic_read(&d->opd_sync_rpcs_in_flight) == 0)
break;
{
struct obd_device *obd;
struct obd_import *imp;
- char *src, *tgt, *mdt, *osdname = NULL;
+ char *src, *tgt, *osdname = NULL;
+ const char *mdt;
int rc;
- long idx;
+ u32 idx;
ENTRY;
RETURN(-EINVAL);
}
- idx = simple_strtol(tgt + 4, &mdt, 16);
- if (mdt[0] != '-' || idx > INT_MAX || idx < 0) {
+ rc = target_name2index(tgt + 1, &idx, &mdt);
+ if (rc < 0 || rc & LDD_F_SV_ALL || mdt[0] != '-') {
CERROR("%s: invalid OST index in '%s': rc = %d\n",
osp->opd_obd->obd_name, src, -EINVAL);
RETURN(-EINVAL);
RETURN(-EINVAL);
}
- idx = simple_strtol(tgt + 4, &mdt, 16);
- if (*mdt != '\0' || idx > INT_MAX || idx < 0) {
+ rc = target_name2index(tgt + 1, &idx, &mdt);
+ if (rc < 0 || rc & LDD_F_SV_ALL || *mdt != '\0') {
CERROR("%s: invalid OST index in '%s': rc = %d\n",
osp->opd_obd->obd_name, src, -EINVAL);
RETURN(-EINVAL);
if (strncmp(tgt - 12, "-MDT", 4) == 0)
osp->opd_connect_mdt = 1;
- idx = simple_strtol(tgt - 8, &mdt, 16);
- if (mdt[0] != '-' || idx > INT_MAX || idx < 0) {
+ rc = target_name2index(tgt - 11, &idx, &mdt);
+ if (rc < 0 || rc & LDD_F_SV_ALL || mdt[0] != '-') {
CERROR("%s: invalid OST index in '%s': rc =%d\n",
osp->opd_obd->obd_name, src, -EINVAL);
RETURN(-EINVAL);
{
struct osp_device *osp = lu2osp_dev(lu);
- if (atomic_read(&lu->ld_ref) && lu->ld_site) {
- LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL);
- lu_site_print(env, lu->ld_site, &msgdata, lu_cdebug_printer);
- }
+ lu_site_print(env, lu->ld_site, &lu->ld_ref, D_ERROR,
+ lu_cdebug_printer);
dt_device_fini(&osp->opd_dt_dev);
OBD_FREE_PTR(osp);
break;
default:
CERROR("%s: unrecognized ioctl %#x by %s\n", obd->obd_name,
- cmd, current_comm());
+ cmd, current->comm);
rc = -ENOTTY;
}
module_put(THIS_MODULE);
RETURN(0);
}
-/**
- * Implementation of obd_ops: o_fid_alloc
- *
- * Allocate a FID. There are two cases in which OSP performs
- * FID allocation.
- *
- * 1. FID precreation for data objects, which is done in
- * osp_precreate_fids() instead of this function.
- * 2. FID allocation for each sub-stripe of a striped directory.
- * Similar to other FID clients, OSP requests the sequence
- * from its corresponding remote MDT, which in turn requests
- * sequences from the sequence controller (MDT0).
- *
- * \param[in] env execution environment
- * \param[in] exp export of the OSP
- * \param[out] fid FID being allocated
- * \param[in] unused necessary for the interface but unused.
- *
- * \retval 0 0 FID allocated successfully.
- * \retval 1 1 FID allocated successfully and new sequence
- * requested from seq meta server
- * \retval negative negative errno if FID allocation failed.
- */
-static int osp_fid_alloc(const struct lu_env *env, struct obd_export *exp,
- struct lu_fid *fid, struct md_op_data *unused)
-{
- struct client_obd *cli = &exp->exp_obd->u.cli;
- struct osp_device *osp = lu2osp_dev(exp->exp_obd->obd_lu_dev);
- struct lu_client_seq *seq = cli->cl_seq;
- ENTRY;
-
- LASSERT(osp->opd_obd->u.cli.cl_seq != NULL);
- /* Sigh, fid client is not ready yet */
- LASSERT(osp->opd_obd->u.cli.cl_seq->lcs_exp != NULL);
-
- RETURN(seq_client_alloc_fid(env, seq, fid));
-}
-
/* context key constructor/destructor: mdt_key_init, mdt_key_fini */
LU_KEY_INIT_FINI(osp, struct osp_thread_info);
static void osp_key_exit(const struct lu_context *ctx,
.ldt_ctx_tags = LCT_MD_THREAD | LCT_DT_THREAD,
};
-static struct obd_ops osp_obd_device_ops = {
+static const struct obd_ops osp_obd_device_ops = {
.o_owner = THIS_MODULE,
.o_add_conn = client_import_add_conn,
.o_del_conn = client_import_del_conn,
.o_statfs = osp_obd_statfs,
.o_fid_init = client_fid_init,
.o_fid_fini = client_fid_fini,
- .o_fid_alloc = osp_fid_alloc,
};
/**