LDLM_LOCK_PUT(lock);
rc = 0;
} else {
+ struct md_attr *ma = &info->mti_attr;
relock:
mdt_lock_handle_init(lhc);
mdt_lock_reg_init(lhc, LCK_PR);
&child->mot_obj.mo_lu,
"Object doesn't exist!\n");
}
+
+ ma->ma_valid = 0;
+ ma->ma_need = MA_INODE;
+ rc = mo_attr_get(info->mti_env, next, ma);
+ if (unlikely(rc != 0))
+ GOTO(out_child, rc);
+
+ /* If the file has not been changed for some time, we return
+ * not only a LOOKUP lock, but also an UPDATE lock and this
+ * might save us RPC on later STAT. For directories, it also
+ * let negative dentry starts working for this dir. */
+ if (ma->ma_valid & MA_INODE &&
+ ma->ma_attr.la_valid & LA_CTIME &&
+ info->mti_mdt->mdt_namespace->ns_ctime_age_limit +
+ ma->ma_attr.la_ctime < cfs_time_current_sec())
+ child_bits |= MDS_INODELOCK_UPDATE;
+
rc = mdt_object_lock(info, child, lhc, child_bits,
MDT_CROSS_LOCK);
GOTO(free_desc, rc);
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE))
- GOTO(abort_bulk, rc);
+ GOTO(abort_bulk, rc = 0);
*lwi = LWI_TIMEOUT(obd_timeout * HZ / 4, NULL, NULL);
rc = l_wait_event(desc->bd_waitq, !ptlrpc_bulk_active(desc), lwi);
ma->ma_attr.la_valid = LA_MODE;
ma->ma_valid = MA_INODE;
- kmap(page);
+ cfs_kmap(page);
dp = page_address(page);
offset = (int)((__u32)lu_dirent_start(dp) - (__u32)dp);
}
EXIT;
out:
- kunmap(page);
+ cfs_kunmap(page);
return rc;
}
cleanup_lwi:
OBD_FREE_PTR(lwi);
cleanup_page:
- __cfs_free_page(page);
+ cfs_free_page(page);
desc_cleanup:
ptlrpc_free_bulk(desc);
RETURN(rc);
for (i = 0; i < rdpg->rp_npages; i++)
if (rdpg->rp_pages[i] != NULL)
- __cfs_free_page(rdpg->rp_pages[i]);
+ cfs_free_page(rdpg->rp_pages[i]);
OBD_FREE(rdpg->rp_pages, rdpg->rp_npages * sizeof rdpg->rp_pages[0]);
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE))
ENTRY;
- if (OBD_FAIL_CHECK_RESET(OBD_FAIL_MDS_REINT_NET,
- OBD_FAIL_MDS_REINT_NET)) {
- info->mti_fail_id = OBD_FAIL_MDS_REINT_NET;
- RETURN(0);
- }
-
opc = mdt_reint_opcode(info, reint_fmts);
if (opc >= 0) {
/*
*/
LASSERT(info->mti_dlm_req != NULL);
- if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_ENQUEUE)) {
- info->mti_fail_id = OBD_FAIL_LDLM_ENQUEUE;
- return 0;
- }
-
req = mdt_info_req(info);
/*
LASSERT(current->journal_info == NULL);
/*
- * Mask out OBD_FAIL_ONCE, because that will stop
- * correct handling of failed req later in ldlm due to doing
- * obd_fail_loc |= OBD_FAIL_ONCE without actually
- * correct actions like it is done in target_send_reply_msg().
+ * Checking for various OBD_FAIL_$PREF_$OPC_NET codes. _Do_ not try
+ * to put same checks into handlers like mdt_close(), mdt_reint(),
+ * etc., without talking to mdt authors first. Checking same thing
+ * there again is useless and returning 0 error wihtout packing reply
+ * is buggy! Handlers either pack reply or return error.
+ *
+ * We return 0 here and do not send any reply in order to emulate
+ * network failure. Do not send any reply in case any of NET related
+ * fail_id has occured.
*/
- if (h->mh_fail_id != 0) {
- /*
- * Set to info->mti_fail_id to handler fail_id, it will be used
- * later, and better than use default fail_id.
- */
- if (OBD_FAIL_CHECK_RESET(h->mh_fail_id && OBD_FAIL_MASK_LOC,
- h->mh_fail_id & ~OBD_FAILED)) {
- info->mti_fail_id = h->mh_fail_id;
- RETURN(0);
- }
- }
+ if (OBD_FAIL_CHECK_ORSET(h->mh_fail_id, OBD_FAIL_ONCE))
+ RETURN(0);
rc = 0;
flags = h->mh_flags;
* only
*/
rc = h->mh_act(info);
+ if (rc == 0 &&
+ !req->rq_no_reply && req->rq_reply_state == NULL) {
+ DEBUG_REQ(D_ERROR, req, "MDT \"handler\" %s did not "
+ "pack reply and returned 0 error\n",
+ h->mh_name);
+ LBUG();
+ }
serious = is_serious(rc);
rc = clear_serious(rc);
} else
LBUG();
}
- RETURN(rc);
+ target_send_reply(req, rc, info->mti_fail_id);
+ RETURN(0);
}
void mdt_lock_handle_init(struct mdt_lock_handle *lh)
info->mti_env = NULL;
}
-/* mds/handler.c */
-extern int mds_filter_recovery_request(struct ptlrpc_request *req,
- struct obd_device *obd, int *process);
+static int mdt_filter_recovery_request(struct ptlrpc_request *req,
+ struct obd_device *obd, int *process)
+{
+ switch (lustre_msg_get_opc(req->rq_reqmsg)) {
+ case MDS_CONNECT: /* This will never get here, but for completeness. */
+ case OST_CONNECT: /* This will never get here, but for completeness. */
+ case MDS_DISCONNECT:
+ case OST_DISCONNECT:
+ *process = 1;
+ RETURN(0);
+
+ case MDS_CLOSE:
+ case MDS_DONE_WRITING:
+ case MDS_SYNC: /* used in unmounting */
+ case OBD_PING:
+ case MDS_REINT:
+ case SEQ_QUERY:
+ case FLD_QUERY:
+ case LDLM_ENQUEUE:
+ *process = target_queue_recovery_request(req, obd);
+ RETURN(0);
+
+ default:
+ DEBUG_REQ(D_ERROR, req, "not permitted during recovery");
+ *process = -EAGAIN;
+ RETURN(0);
+ }
+}
+
/*
* Handle recovery. Return:
* +1: continue request processing;
int rc;
int should_process;
DEBUG_REQ(D_INFO, req, "Got new replay");
- rc = mds_filter_recovery_request(req, obd, &should_process);
+ rc = mdt_filter_recovery_request(req, obd, &should_process);
if (rc != 0 || !should_process)
RETURN(rc);
else if (should_process < 0) {
RETURN(+1);
}
-static int mdt_reply(struct ptlrpc_request *req, int rc,
- struct mdt_thread_info *info)
+static int mdt_msg_check_version(struct lustre_msg *msg)
{
- ENTRY;
+ int rc;
-#if 0
- if (req->rq_reply_state == NULL && rc == 0) {
- req->rq_status = rc;
- lustre_pack_reply(req, 1, NULL, NULL);
+ switch (lustre_msg_get_opc(msg)) {
+ case MDS_CONNECT:
+ case MDS_DISCONNECT:
+ case OBD_PING:
+ case SEC_CTX_INIT:
+ case SEC_CTX_INIT_CONT:
+ case SEC_CTX_FINI:
+ rc = lustre_msg_check_version(msg, LUSTRE_OBD_VERSION);
+ if (rc)
+ CERROR("bad opc %u version %08x, expecting %08x\n",
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_OBD_VERSION);
+ break;
+ case MDS_GETSTATUS:
+ case MDS_GETATTR:
+ case MDS_GETATTR_NAME:
+ case MDS_STATFS:
+ case MDS_READPAGE:
+ case MDS_WRITEPAGE:
+ case MDS_IS_SUBDIR:
+ case MDS_REINT:
+ case MDS_CLOSE:
+ case MDS_DONE_WRITING:
+ case MDS_PIN:
+ case MDS_SYNC:
+ case MDS_GETXATTR:
+ case MDS_SETXATTR:
+ case MDS_SET_INFO:
+ case MDS_QUOTACHECK:
+ case MDS_QUOTACTL:
+ case QUOTA_DQACQ:
+ case QUOTA_DQREL:
+ case SEQ_QUERY:
+ case FLD_QUERY:
+ rc = lustre_msg_check_version(msg, LUSTRE_MDS_VERSION);
+ if (rc)
+ CERROR("bad opc %u version %08x, expecting %08x\n",
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_MDS_VERSION);
+ break;
+ case LDLM_ENQUEUE:
+ case LDLM_CONVERT:
+ case LDLM_BL_CALLBACK:
+ case LDLM_CP_CALLBACK:
+ rc = lustre_msg_check_version(msg, LUSTRE_DLM_VERSION);
+ if (rc)
+ CERROR("bad opc %u version %08x, expecting %08x\n",
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_DLM_VERSION);
+ break;
+ case OBD_LOG_CANCEL:
+ case LLOG_ORIGIN_HANDLE_CREATE:
+ case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
+ case LLOG_ORIGIN_HANDLE_READ_HEADER:
+ case LLOG_ORIGIN_HANDLE_CLOSE:
+ case LLOG_ORIGIN_HANDLE_DESTROY:
+ case LLOG_ORIGIN_HANDLE_PREV_BLOCK:
+ case LLOG_CATINFO:
+ rc = lustre_msg_check_version(msg, LUSTRE_LOG_VERSION);
+ if (rc)
+ CERROR("bad opc %u version %08x, expecting %08x\n",
+ lustre_msg_get_opc(msg),
+ lustre_msg_get_version(msg),
+ LUSTRE_LOG_VERSION);
+ break;
+ default:
+ CERROR("MDS unknown opcode %d\n", lustre_msg_get_opc(msg));
+ rc = -ENOTSUPP;
}
-#endif
- target_send_reply(req, rc, info->mti_fail_id);
- RETURN(0);
+ return rc;
}
-/* mds/handler.c */
-extern int mds_msg_check_version(struct lustre_msg *msg);
-
static int mdt_handle0(struct ptlrpc_request *req,
struct mdt_thread_info *info,
struct mdt_opc_slice *supported)
LASSERT(current->journal_info == NULL);
msg = req->rq_reqmsg;
- rc = mds_msg_check_version(msg);
+ rc = mdt_msg_check_version(msg);
if (likely(rc == 0)) {
rc = mdt_recovery(info);
if (likely(rc == +1)) {
supported);
if (likely(h != NULL)) {
rc = mdt_req_handle(info, h, req);
- rc = mdt_reply(req, rc, info);
} else {
CERROR("The unsupported opc: 0x%x\n", lustre_msg_get_opc(msg) );
req->rq_status = -ENOTSUPP;
static void mdt_stack_fini(const struct lu_env *env,
struct mdt_device *m, struct lu_device *top)
{
- struct lu_device *d = top, *n;
struct obd_device *obd = m->mdt_md_dev.md_lu_dev.ld_obd;
struct lustre_cfg_bufs *bufs;
struct lustre_cfg *lcfg;
top->ld_ops->ldo_process_config(env, top, lcfg);
lustre_cfg_free(lcfg);
- lu_site_purge(env, top->ld_site, ~0);
- while (d != NULL) {
- struct lu_device_type *ldt = d->ld_type;
-
- /* each fini() returns next device in stack of layers
- * so we can avoid the recursion */
- n = ldt->ldt_ops->ldto_device_fini(env, d);
- lu_device_put(d);
-
- /* switch to the next device in the layer */
- d = n;
- }
-
- /* purge again. */
- lu_site_purge(env, top->ld_site, ~0);
-
- if (!list_empty(&top->ld_site->ls_lru) || top->ld_site->ls_total != 0) {
- /*
- * Uh-oh, objects still exist.
- */
- static DECLARE_LU_CDEBUG_PRINT_INFO(cookie, D_ERROR);
-
- lu_site_print(env, top->ld_site, &cookie, lu_cdebug_printer);
- }
-
- d = top;
- while (d != NULL) {
- struct obd_type *type;
- struct lu_device_type *ldt = d->ld_type;
-
- /* each free() returns next device in stack of layers
- * so we can avoid the recursion */
- n = ldt->ldt_ops->ldto_device_free(env, d);
- type = ldt->ldt_obd_type;
- type->typ_refcnt--;
- class_put_type(type);
-
- /* switch to the next device in the layer */
- d = n;
- }
+ lu_stack_fini(env, top);
m->mdt_child = NULL;
m->mdt_bottom = NULL;
}
m->mdt_identity_cache = NULL;
if (m->mdt_namespace != NULL) {
- ldlm_namespace_free(m->mdt_namespace, d->ld_obd->obd_force);
+ ldlm_namespace_free(m->mdt_namespace, NULL, d->ld_obd->obd_force);
d->ld_obd->obd_namespace = m->mdt_namespace = NULL;
}
sptlrpc_rule_set_free(&m->mdt_sptlrpc_rset);
next->md_ops->mdo_init_capa_ctxt(env, next, 0, 0, 0, NULL);
- del_timer(&m->mdt_ck_timer);
+ cfs_timer_disarm(&m->mdt_ck_timer);
mdt_ck_thread_stop(m);
/* finish the stack */
snprintf(info->mti_u.ns_name, sizeof info->mti_u.ns_name,
LUSTRE_MDT_NAME"-%p", m);
- m->mdt_namespace = ldlm_namespace_new(info->mti_u.ns_name,
+ m->mdt_namespace = ldlm_namespace_new(obd, info->mti_u.ns_name,
LDLM_NAMESPACE_SERVER,
LDLM_NAMESPACE_GREEDY);
if (m->mdt_namespace == NULL)
GOTO(err_free_ns, rc);
}
- m->mdt_ck_timer.function = mdt_ck_timer_callback;
- m->mdt_ck_timer.data = (unsigned long)m;
- init_timer(&m->mdt_ck_timer);
+ cfs_timer_init(&m->mdt_ck_timer, mdt_ck_timer_callback, m);
+
rc = mdt_ck_thread_start(m);
if (rc)
GOTO(err_free_ns, rc);
target_recovery_fini(obd);
mdt_fs_cleanup(env, m);
err_capa:
- del_timer(&m->mdt_ck_timer);
+ cfs_timer_disarm(&m->mdt_ck_timer);
mdt_ck_thread_stop(m);
err_free_ns:
upcall_cache_cleanup(m->mdt_identity_cache);
m->mdt_identity_cache = NULL;
- ldlm_namespace_free(m->mdt_namespace, 0);
+ ldlm_namespace_free(m->mdt_namespace, NULL, 0);
obd->obd_namespace = m->mdt_namespace = NULL;
err_fini_seq:
mdt_seq_fini(env, m);
static int mdt_obd_connect(const struct lu_env *env,
struct lustre_handle *conn, struct obd_device *obd,
struct obd_uuid *cluuid,
- struct obd_connect_data *data)
+ struct obd_connect_data *data,
+ void *localdata)
{
struct mdt_thread_info *info;
struct mdt_client_data *mcd;
struct mdt_export_data *med = &exp->exp_mdt_data;
ENTRY;
- INIT_LIST_HEAD(&med->med_open_head);
+ CFS_INIT_LIST_HEAD(&med->med_open_head);
spin_lock_init(&med->med_open_lock);
sema_init(&med->med_idmap_sem, 1);
med->med_idmap = NULL;