⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdc_request.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 4 页
字号:
        ENTRY;        if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)                RETURN(0);        req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,                              MDS_CLOSE, 2, size, NULL);        if (req == NULL)                RETURN(-ENOMEM);        body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));        memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));        body->flags = flag;        ptlrpc_req_set_repsize(req, 1, NULL);        mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);        rc = ptlrpc_queue_wait(req);        mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);        if (rc != 0)                CERROR("unpin failed: %d\n", rc);        ptlrpc_req_finished(req);        ptlrpc_req_finished(handle->och_mod->mod_open_req);        OBD_FREE(handle->och_mod, sizeof(*handle->och_mod));        RETURN(rc);}int mdc_sync(struct obd_export *exp, struct ll_fid *fid,             struct ptlrpc_request **request){        struct ptlrpc_request *req;        int size[2] = { sizeof(struct ptlrpc_body), sizeof(struct mds_body) };        int rc;        ENTRY;        req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,                              MDS_SYNC, 2, size, NULL);        if (!req)                RETURN(rc = -ENOMEM);        mdc_pack_req_body(req, REQ_REC_OFF, 0, fid, 0, 0);        ptlrpc_req_set_repsize(req, 2, size);        rc = ptlrpc_queue_wait(req);        if (rc || request == NULL)                ptlrpc_req_finished(req);        else                *request = req;        RETURN(rc);}static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,                            enum obd_import_event event){        int rc = 0;        LASSERT(imp->imp_obd == obd);        switch (event) {        case IMP_EVENT_DISCON: {                ptlrpc_import_setasync(imp, -obd->obd_namespace->ns_max_unused);                break;        }        case IMP_EVENT_INACTIVE: {                rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE, NULL);                break;        }        case IMP_EVENT_INVALIDATE: {                struct ldlm_namespace *ns = obd->obd_namespace;                ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);                break;        }        case IMP_EVENT_ACTIVE: {                rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL);                break;        }        case IMP_EVENT_OCD:                ptlrpc_import_setasync(imp, obd->obd_namespace->ns_max_unused);                break;        default:                CERROR("Unknown import event %x\n", event);                LBUG();        }        RETURN(rc);}static int mdc_setup(struct obd_device *obd, obd_count len, void *buf){        struct client_obd *cli = &obd->u.cli;        struct lprocfs_static_vars lvars = { 0 };        int rc;        ENTRY;        OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));        if (!cli->cl_rpc_lock)                RETURN(-ENOMEM);        mdc_init_rpc_lock(cli->cl_rpc_lock);        ptlrpcd_addref();        OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));        if (!cli->cl_setattr_lock)                GOTO(err_rpc_lock, rc = -ENOMEM);        mdc_init_rpc_lock(cli->cl_setattr_lock);        OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));        if (!cli->cl_close_lock)                GOTO(err_setattr_lock, rc = -ENOMEM);        mdc_init_rpc_lock(cli->cl_close_lock);        rc = client_obd_setup(obd, len, buf);        if (rc)                GOTO(err_close_lock, rc);        lprocfs_mdc_init_vars(&lvars);        if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0)                ptlrpc_lprocfs_register_obd(obd);        rc = obd_llog_init(obd, obd, 0, NULL, NULL);        if (rc) {                mdc_cleanup(obd);                CERROR("failed to setup llogging subsystems\n");        }        RETURN(rc);err_close_lock:        OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));err_setattr_lock:        OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));err_rpc_lock:        OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));        ptlrpcd_decref();        RETURN(rc);}/* Initialize the default and maximum LOV EA and cookie sizes.  This allows * us to make MDS RPCs with large enough reply buffers to hold the * maximum-sized (= maximum striped) EA and cookie without having to * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp){        struct obd_device *obd = mdc_exp->exp_obd;        struct client_obd *cli = &obd->u.cli;        struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC };        struct lov_desc desc;        __u32 valsize = sizeof(desc);        __u32 stripes;        int rc, size;        ENTRY;        rc = obd_get_info(lov_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC,                          &valsize, &desc);        if (rc)                RETURN(rc);        stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT);        lsm.lsm_stripe_count = stripes;        size = obd_size_diskmd(lov_exp, &lsm);                if (cli->cl_max_mds_easize < size)                cli->cl_max_mds_easize = size;        lsm.lsm_stripe_count = desc.ld_default_stripe_count;        size = obd_size_diskmd(lov_exp, &lsm);        if (cli->cl_default_mds_easize < size)                cli->cl_default_mds_easize = size;        size = stripes * sizeof(struct llog_cookie);        if (cli->cl_max_mds_cookiesize < size)                cli->cl_max_mds_cookiesize = size;        CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n",               cli->cl_max_mds_easize, cli->cl_max_mds_cookiesize);                RETURN(0);}static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage){        int rc = 0;        ENTRY;        switch (stage) {        case OBD_CLEANUP_EARLY:         case OBD_CLEANUP_EXPORTS:                /* If we set up but never connected, the                   client import will not have been cleaned. */                if (obd->u.cli.cl_import) {                        struct obd_import *imp;                        imp = obd->u.cli.cl_import;                        CERROR("client import never connected\n");                        ptlrpc_invalidate_import(imp);                        ptlrpc_free_rq_pool(imp->imp_rq_pool);                        class_destroy_import(imp);                        obd->u.cli.cl_import = NULL;                }                break;        case OBD_CLEANUP_SELF_EXP:                rc = obd_llog_finish(obd, 0);                if (rc != 0)                        CERROR("failed to cleanup llogging subsystems\n");        case OBD_CLEANUP_OBD:                break;        }        RETURN(rc);}static int mdc_cleanup(struct obd_device *obd){        struct client_obd *cli = &obd->u.cli;        OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));        OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));        OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));        ptlrpc_lprocfs_unregister_obd(obd);        lprocfs_obd_cleanup(obd);        ptlrpcd_decref();        return client_obd_cleanup(obd);}static int mdc_llog_init(struct obd_device *obd, struct obd_device *tgt,                         int count, struct llog_catid *logid,                          struct obd_uuid *uuid){        struct llog_ctxt *ctxt;        int rc;        ENTRY;        rc = llog_setup(obd, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,                        &llog_client_ops);        if (rc == 0) {                ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);                ctxt->loc_imp = obd->u.cli.cl_import;                llog_ctxt_put(ctxt);        }        rc = llog_setup(obd, LLOG_LOVEA_REPL_CTXT, tgt, 0, NULL,                       &llog_client_ops);        if (rc == 0) {                ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);                ctxt->loc_imp = obd->u.cli.cl_import;                llog_ctxt_put(ctxt);        }        RETURN(rc);}static int mdc_llog_finish(struct obd_device *obd, int count){        int rc;        ENTRY;        rc = llog_cleanup(llog_get_context(obd, LLOG_LOVEA_REPL_CTXT));        if (rc) {                CERROR("can not cleanup LLOG_CONFIG_REPL_CTXT rc %d\n", rc);        }        rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT));        RETURN(rc);}static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf){        struct lustre_cfg *lcfg = buf;        struct lprocfs_static_vars lvars = { 0 };        int rc = 0;        lprocfs_mdc_init_vars(&lvars);                rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars, lcfg, obd);        return(rc);}struct obd_ops mdc_obd_ops = {        .o_owner        = THIS_MODULE,        .o_setup        = mdc_setup,        .o_precleanup   = mdc_precleanup,        .o_cleanup      = mdc_cleanup,        .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_iocontrol    = mdc_iocontrol,        .o_set_info_async = mdc_set_info_async,        .o_get_info     = mdc_get_info,        .o_statfs       = mdc_statfs,        .o_pin          = mdc_pin,        .o_unpin        = mdc_unpin,        .o_import_event = mdc_import_event,        .o_llog_init    = mdc_llog_init,        .o_llog_finish  = mdc_llog_finish,        .o_process_config = mdc_process_config,};int __init mdc_init(void){        int rc;        struct lprocfs_static_vars lvars = { 0 };        lprocfs_mdc_init_vars(&lvars);        request_module("lquota");        quota_interface = PORTAL_SYMBOL_GET(mdc_quota_interface);        init_obd_quota_ops(quota_interface, &mdc_obd_ops);        rc = class_register_type(&mdc_obd_ops, lvars.module_vars,                                 LUSTRE_MDC_NAME);        if (rc && quota_interface)                PORTAL_SYMBOL_PUT(mdc_quota_interface);        RETURN(rc);}#ifdef __KERNEL__static void /*__exit*/ mdc_exit(void){        if (quota_interface)                PORTAL_SYMBOL_PUT(mdc_quota_interface);        class_unregister_type(LUSTRE_MDC_NAME);}MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");MODULE_DESCRIPTION("Lustre Metadata Client");MODULE_LICENSE("GPL");EXPORT_SYMBOL(mdc_req2lustre_md);EXPORT_SYMBOL(mdc_free_lustre_md);EXPORT_SYMBOL(mdc_change_cbdata);EXPORT_SYMBOL(mdc_getstatus);EXPORT_SYMBOL(mdc_getattr);EXPORT_SYMBOL(mdc_getattr_name);EXPORT_SYMBOL(mdc_create);EXPORT_SYMBOL(mdc_unlink);EXPORT_SYMBOL(mdc_rename);EXPORT_SYMBOL(mdc_link);EXPORT_SYMBOL(mdc_readpage);EXPORT_SYMBOL(mdc_setattr);EXPORT_SYMBOL(mdc_close);EXPORT_SYMBOL(mdc_done_writing);EXPORT_SYMBOL(mdc_sync);EXPORT_SYMBOL(mdc_set_open_replay_data);EXPORT_SYMBOL(mdc_clear_open_replay_data);EXPORT_SYMBOL(mdc_store_inode_generation);EXPORT_SYMBOL(mdc_init_ea_size);EXPORT_SYMBOL(mdc_getxattr);EXPORT_SYMBOL(mdc_setxattr);module_init(mdc_init);module_exit(mdc_exit);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -