#include <uapi/linux/lustre/lustre_param.h>
#include <lustre_swab.h>
#include <obd_class.h>
+#include <lustre_osc.h>
#include "mdc_internal.h"
keylen, key, vallen, val, set);
RETURN(rc);
}
- if (KEY_IS(KEY_SPTLRPC_CONF)) {
- sptlrpc_conf_client_adapt(exp->exp_obd);
- RETURN(0);
- }
- if (KEY_IS(KEY_FLUSH_CTX)) {
- sptlrpc_import_flush_my_ctx(imp);
- RETURN(0);
- }
if (KEY_IS(KEY_CHANGELOG_CLEAR)) {
rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
keylen, key, vallen, val, set);
RETURN(0);
}
- CERROR("Unknown key %s\n", (char *)key);
- RETURN(-EINVAL);
+ rc = osc_set_info_async(env, exp, keylen, key, vallen, val, set);
+ RETURN(rc);
}
static int mdc_get_info(const struct lu_env *env, struct obd_export *exp,
static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
enum obd_import_event event)
{
+ struct client_obd *cli = &obd->u.cli;
int rc = 0;
LASSERT(imp->imp_obd == obd);
switch (event) {
-
- case IMP_EVENT_INACTIVE: {
- struct client_obd *cli = &obd->u.cli;
+ case IMP_EVENT_DISCON:
+ spin_lock(&cli->cl_loi_list_lock);
+ cli->cl_avail_grant = 0;
+ cli->cl_lost_grant = 0;
+ spin_unlock(&cli->cl_loi_list_lock);
+ break;
+ case IMP_EVENT_INACTIVE:
/*
* Flush current sequence to make client obtain new one
* from server in case of disconnect/reconnect.
rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE);
break;
- }
case IMP_EVENT_INVALIDATE: {
struct ldlm_namespace *ns = obd->obd_namespace;
+ struct lu_env *env;
+ __u16 refcheck;
ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
+ env = cl_env_get(&refcheck);
+ if (!IS_ERR(env)) {
+ /* Reset grants. All pages go to failing rpcs due to
+ * the invalid import.
+ */
+ osc_io_unplug(env, cli, NULL);
+
+ cfs_hash_for_each_nolock(ns->ns_rs_hash,
+ osc_ldlm_resource_invalidate,
+ env, 0);
+ cl_env_put(env, &refcheck);
+ ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
+ } else {
+ rc = PTR_ERR(env);
+ }
break;
}
case IMP_EVENT_ACTIVE:
if (rc == 0)
rc = mdc_kuc_reregister(imp);
break;
- case IMP_EVENT_OCD:
+ case IMP_EVENT_OCD: {
+ struct obd_connect_data *ocd = &imp->imp_connect_data;
+
+ if (OCD_HAS_FLAG(ocd, GRANT))
+ osc_init_grant(cli, ocd);
+
rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD);
break;
- case IMP_EVENT_DISCON:
+ }
case IMP_EVENT_DEACTIVATE:
case IMP_EVENT_ACTIVATE:
break;
EXIT;
}
-static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
+int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
{
- int rc;
+ int rc;
+
ENTRY;
- rc = ptlrpcd_addref();
+ rc = osc_setup_common(obd, cfg);
if (rc < 0)
RETURN(rc);
- rc = client_obd_setup(obd, cfg);
- if (rc)
- GOTO(err_ptlrpcd_decref, rc);
#ifdef CONFIG_PROC_FS
obd->obd_vars = lprocfs_mdc_obd_vars;
lprocfs_obd_setup(obd, false);
lprocfs_alloc_md_stats(obd, 0);
#endif
+
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);
if (rc) {
CERROR("%s: failed to setup llogging subsystems: rc = %d\n",
obd->obd_name, rc);
- GOTO(err_mdc_cleanup, rc);
+ GOTO(err_llog_cleanup, rc);
}
rc = mdc_changelog_cdev_init(obd);
if (rc) {
CERROR("%s: failed to setup changelog char device: rc = %d\n",
obd->obd_name, rc);
- GOTO(err_mdc_cleanup, rc);
+ GOTO(err_changelog_cleanup, rc);
}
- EXIT;
-err_mdc_cleanup:
- if (rc)
- client_obd_cleanup(obd);
+ RETURN(rc);
-err_ptlrpcd_decref:
- if (rc)
- ptlrpcd_decref();
+err_changelog_cleanup:
+ mdc_llog_finish(obd);
+err_llog_cleanup:
+ ptlrpc_lprocfs_unregister_obd(obd);
+ lprocfs_obd_cleanup(obd);
+ lprocfs_free_md_stats(obd);
- return rc;
+ osc_cleanup_common(obd);
+ return rc;
}
/* Initialize the default and maximum LOV EA sizes. This allows
{
ENTRY;
+ osc_precleanup_common(obd);
+
/* Failsafe, ok if racy */
if (obd->obd_type->typ_refcnt <= 1)
libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
static int mdc_cleanup(struct obd_device *obd)
{
- ptlrpcd_decref();
-
- return client_obd_cleanup(obd);
+ return osc_cleanup_common(obd);
}
-static int mdc_process_config(struct obd_device *obd, size_t len, void *buf)
+int mdc_process_config(struct obd_device *obd, size_t len, void *buf)
{
- struct lustre_cfg *lcfg = buf;
- int rc = class_process_proc_param(PARAM_MDC, obd->obd_vars, lcfg, obd);
+ struct lustre_cfg *lcfg = buf;
+ int rc;
+
+ rc = class_process_proc_param(PARAM_MDC, obd->obd_vars, lcfg, obd);
return (rc > 0 ? 0: rc);
}
.o_add_conn = client_import_add_conn,
.o_del_conn = client_import_del_conn,
.o_connect = client_connect_import,
- .o_disconnect = client_disconnect_export,
+ .o_reconnect = osc_reconnect,
+ .o_disconnect = osc_disconnect,
.o_iocontrol = mdc_iocontrol,
.o_set_info_async = mdc_set_info_async,
.o_statfs = mdc_statfs,
static int __init mdc_init(void)
{
return class_register_type(&mdc_obd_ops, &mdc_md_ops, true, NULL,
- LUSTRE_MDC_NAME, NULL);
+ LUSTRE_MDC_NAME, &mdc_device_type);
}
static void __exit mdc_exit(void)