d->opd_statfs_fresh_till);
}
+/*
+ * OSP tries to maintain pool of available objects so that calls to create
+ * objects don't block most of time
+ *
+ * each time OSP gets connected to OST, we should start from precreation cleanup
+ */
+static inline bool osp_precreate_running(struct osp_device *d)
+{
+ return !!(d->opd_pre_thread.t_flags & SVC_RUNNING);
+}
+
+static inline bool osp_precreate_stopped(struct osp_device *d)
+{
+ return !!(d->opd_pre_thread.t_flags & SVC_STOPPED);
+}
+
static void osp_statfs_timer_cb(unsigned long _d)
{
struct osp_device *d = (struct osp_device *) _d;
LASSERT(d);
- wake_up(&d->opd_pre_waitq);
+ if (d->opd_pre != NULL && osp_precreate_running(d))
+ wake_up(&d->opd_pre_waitq);
}
static int osp_statfs_interpret(const struct lu_env *env,
RETURN(0);
out:
/* couldn't update statfs, try again as soon as possible */
- wake_up(&d->opd_pre_waitq);
+ if (d->opd_pre != NULL && osp_precreate_running(d))
+ wake_up(&d->opd_pre_waitq);
+
if (req->rq_import_generation == imp->imp_generation)
CDEBUG(D_CACHE, "%s: couldn't update statfs: rc = %d\n",
d->opd_obd->obd_name, rc);
}
}
-
-/*
- * OSP tries to maintain pool of available objects so that calls to create
- * objects don't block most of time
- *
- * each time OSP gets connected to OST, we should start from precreation cleanup
- */
-static inline int osp_precreate_running(struct osp_device *d)
-{
- return !!(d->opd_pre_thread.t_flags & SVC_RUNNING);
-}
-
-static inline int osp_precreate_stopped(struct osp_device *d)
-{
- return !!(d->opd_pre_thread.t_flags & SVC_STOPPED);
-}
-
static inline int osp_objs_precreated(const struct lu_env *env,
struct osp_device *osp)
{
if (req == NULL)
RETURN(-ENOMEM);
- req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT,
+ req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY, RCL_CLIENT,
sizeof(KEY_LAST_FID));
- req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL, RCL_CLIENT,
- sizeof(struct lu_fid));
-
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO);
if (rc) {
ptlrpc_request_free(req);
RETURN(rc);
}
- tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
+ tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY);
memcpy(tmp, KEY_LAST_FID, sizeof(KEY_LAST_FID));
req->rq_no_delay = req->rq_no_resend = 1;
- tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
- fid_cpu_to_le((struct lu_fid *)tmp, &d->opd_last_used_fid);
+ last_fid = req_capsule_client_get(&req->rq_pill, &RMF_FID);
+ fid_cpu_to_le(last_fid, &d->opd_last_used_fid);
+
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
wake_up(&d->opd_pre_user_waitq);
}
-static int osp_init_pre_fid(struct osp_device *osp)
+int osp_init_pre_fid(struct osp_device *osp)
{
struct lu_env env;
struct osp_thread_info *osi;
int rc;
ENTRY;
+ LASSERT(osp->opd_pre != NULL);
+
/* Return if last_used fid has been initialized */
if (!fid_is_zero(&osp->opd_last_used_fid))
RETURN(0);
break;
LASSERT(d->opd_obd->u.cli.cl_seq != NULL);
- if (d->opd_obd->u.cli.cl_seq->lcs_exp == NULL) {
- /* Get new sequence for client first */
- LASSERT(d->opd_exp != NULL);
- d->opd_obd->u.cli.cl_seq->lcs_exp =
- class_export_get(d->opd_exp);
- rc = osp_init_pre_fid(d);
- if (rc != 0) {
- class_export_put(d->opd_exp);
- d->opd_obd->u.cli.cl_seq->lcs_exp = NULL;
- CERROR("%s: init pre fid error: rc = %d\n",
- d->opd_obd->obd_name, rc);
- continue;
- }
+ /* Sigh, fid client is not ready yet */
+ if (d->opd_obd->u.cli.cl_seq->lcs_exp == NULL)
+ continue;
+
+ /* Init fid for osp_precreate if necessary */
+ rc = osp_init_pre_fid(d);
+ if (rc != 0) {
+ class_export_put(d->opd_exp);
+ d->opd_obd->u.cli.cl_seq->lcs_exp = NULL;
+ CERROR("%s: init pre fid error: rc = %d\n",
+ d->opd_obd->obd_name, rc);
+ continue;
}
osp_statfs_update(d);
return 1;
/* Bail out I/O fails to OST */
- if (d->opd_pre_status == -EIO)
+ if (d->opd_pre_status != 0 &&
+ d->opd_pre_status != -EAGAIN &&
+ d->opd_pre_status != -ENODEV &&
+ d->opd_pre_status != -ENOSPC) {
+ /* DEBUG LU-3230 */
+ if (d->opd_pre_status != -EIO)
+ CERROR("%s: precreate failed opd_pre_status %d\n",
+ d->opd_obd->obd_name, d->opd_pre_status);
return 1;
+ }
return 0;
}
* - OST can allocate fid sequence.
*/
while ((rc = d->opd_pre_status) == 0 || rc == -ENOSPC ||
- rc == -ENODEV || rc == -EAGAIN) {
+ rc == -ENODEV || rc == -EAGAIN || rc == -ENOTCONN) {
/*
* increase number of precreations
ENTRY;
+ OBD_ALLOC_PTR(d->opd_pre);
+ if (d->opd_pre == NULL)
+ RETURN(-ENOMEM);
+
/* initially precreation isn't ready */
d->opd_pre_status = -EAGAIN;
fid_zero(&d->opd_pre_used_fid);
void osp_precreate_fini(struct osp_device *d)
{
- struct ptlrpc_thread *thread = &d->opd_pre_thread;
+ struct ptlrpc_thread *thread;
ENTRY;
cfs_timer_disarm(&d->opd_statfs_timer);
+ if (d->opd_pre == NULL)
+ RETURN_EXIT;
+
+ thread = &d->opd_pre_thread;
+
thread->t_flags = SVC_STOPPING;
wake_up(&d->opd_pre_waitq);
wait_event(thread->t_ctl_waitq, thread->t_flags & SVC_STOPPED);
+ OBD_FREE_PTR(d->opd_pre);
+ d->opd_pre = NULL;
+
EXIT;
}