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

📄 mds_lov.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 3 页
字号:
        int valsize = sizeof(ost_uuid);        rc = obd_get_info(lov, sizeof(KEY_LOV_IDX), KEY_LOV_IDX,                          &valsize, ost_uuid);        LASSERT(rc >= 0);        RETURN(rc);}/* Update the lov desc for a new size lov. */static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov){        struct mds_obd *mds = &obd->u.mds;        struct lov_desc *ld;        __u32 stripes, valsize = sizeof(mds->mds_lov_desc);        int rc = 0;        ENTRY;        OBD_ALLOC(ld, sizeof(*ld));        if (!ld)                RETURN(-ENOMEM);        rc = obd_get_info(lov, sizeof(KEY_LOVDESC), KEY_LOVDESC,                          &valsize, ld);        if (rc)                GOTO(out, rc);        /* Don't change the mds_lov_desc until the objids size matches the           count (paranoia) */        mds->mds_lov_desc = *ld;        CDEBUG(D_CONFIG, "updated lov_desc, tgt_count: %d\n",               mds->mds_lov_desc.ld_tgt_count);        stripes = min_t(__u32, LOV_MAX_STRIPE_COUNT,                        mds->mds_lov_desc.ld_tgt_count);        mds->mds_max_mdsize = lov_mds_md_size(stripes);        mds->mds_max_cookiesize = stripes * sizeof(struct llog_cookie);        CDEBUG(D_CONFIG, "updated max_mdsize/max_cookiesize for %d stripes: "               "%d/%d\n", mds->mds_max_mdsize, mds->mds_max_cookiesize,               stripes);        /* If we added a target we have to reconnect the llogs */        /* We only _need_ to do this at first add (idx), or the first time           after recovery.  However, it should now be safe to call anytime. */        rc = llog_cat_initialize(obd, mds->mds_lov_desc.ld_tgt_count, NULL);out:        OBD_FREE(ld, sizeof(*ld));        RETURN(rc);}/* Inform MDS about new/updated target */static int mds_lov_update_mds(struct obd_device *obd,                              struct obd_device *watched,                              __u32 idx){        struct mds_obd *mds = &obd->u.mds;        __u32 old_count;        int rc = 0;        int page;        int off;        obd_id *data;        ENTRY;        /* Don't let anyone else mess with mds_lov_objids now */        mutex_down(&obd->obd_dev_sem);        old_count = mds->mds_lov_desc.ld_tgt_count;        rc = mds_lov_update_desc(obd, mds->mds_osc_exp);        if (rc)                GOTO(out, rc);        CDEBUG(D_CONFIG, "idx=%d, recov=%d/%d, cnt=%d/%d\n",               idx, obd->obd_recovering, obd->obd_async_recov, old_count,               mds->mds_lov_desc.ld_tgt_count);        /* idx is set as data from lov_notify. */        if (obd->obd_recovering)                GOTO(out, rc);        if (idx >= mds->mds_lov_desc.ld_tgt_count) {                CERROR("index %d > count %d!\n", idx,                       mds->mds_lov_desc.ld_tgt_count);                GOTO(out, rc = -EINVAL);        }        rc = mds_lov_get_objid(obd, idx);        if (rc) {                CERROR("Failed to get objid - %d\n", rc);                GOTO(out, rc);        }        page = idx / OBJID_PER_PAGE();        off = idx % OBJID_PER_PAGE();        data = mds->mds_lov_page_array[page];        /* We have read this lastid from disk; tell the osc.           Don't call this during recovery. */        rc = mds_lov_set_one_nextid(obd, idx, &data[off]);        if (rc) {                CERROR("Failed to set next id, idx=%d rc=%d\n", idx,rc);                /* Don't abort the rest of the sync */                rc = 0;        }        CDEBUG(D_CONFIG, "last object "LPU64" from OST %d rc=%d\n",               data[off], idx, rc);out:        mutex_up(&obd->obd_dev_sem);        RETURN(rc);}/* update the LOV-OSC knowledge of the last used object id's */int mds_lov_connect(struct obd_device *obd, char * lov_name){        struct mds_obd *mds = &obd->u.mds;        struct lustre_handle conn = {0,};        struct obd_connect_data *data;        int rc;        ENTRY;        if (IS_ERR(mds->mds_osc_obd))                RETURN(PTR_ERR(mds->mds_osc_obd));        if (mds->mds_osc_obd)                RETURN(0);        mds->mds_osc_obd = class_name2obd(lov_name);        if (!mds->mds_osc_obd) {                CERROR("MDS cannot locate LOV %s\n", lov_name);                mds->mds_osc_obd = ERR_PTR(-ENOTCONN);                RETURN(-ENOTCONN);        }        OBD_ALLOC(data, sizeof(*data));        if (data == NULL)                RETURN(-ENOMEM);        data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_INDEX |                OBD_CONNECT_REQPORTAL | OBD_CONNECT_QUOTA64 | OBD_CONNECT_AT |                OBD_CONNECT_CHANGE_QS;#ifdef HAVE_LRU_RESIZE_SUPPORT        data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;#endif        data->ocd_version = LUSTRE_VERSION_CODE;        /* NB: lov_connect() needs to fill in .ocd_index for each OST */        rc = obd_connect(&conn, mds->mds_osc_obd, &obd->obd_uuid, data, NULL);        OBD_FREE(data, sizeof(*data));        if (rc) {                CERROR("MDS cannot connect to LOV %s (%d)\n", lov_name, rc);                mds->mds_osc_obd = ERR_PTR(rc);                RETURN(rc);        }        mds->mds_osc_exp = class_conn2export(&conn);        rc = obd_register_observer(mds->mds_osc_obd, obd);        if (rc) {                CERROR("MDS cannot register as observer of LOV %s (%d)\n",                       lov_name, rc);                GOTO(err_discon, rc);        }        /* Deny new client connections until we are sure we have some OSTs */        obd->obd_no_conn = 1;        mutex_down(&obd->obd_dev_sem);        rc = mds_lov_read_objids(obd);        if (rc) {                CERROR("cannot read %s: rc = %d\n", "lov_objids", rc);                GOTO(err_reg, rc);        }        rc = mds_lov_update_desc(obd, mds->mds_osc_exp);        if (rc)                GOTO(err_reg, rc);        /* If we're mounting this code for the first time on an existing FS,         * we need to populate the objids array from the real OST values */        if (mds->mds_lov_desc.ld_tgt_count > mds->mds_lov_objid_count) {                __u32 i = mds->mds_lov_objid_count;                for(; i <= mds->mds_lov_desc.ld_tgt_count; i++) {                        rc = mds_lov_get_objid(obd, i);                        if (rc != 0)                                break;                }                if (rc == 0)                        rc = mds_lov_write_objids(obd);                if (rc)                        CERROR("got last objids from OSTs, but error "                                "in update objids file: %d\n", rc);        }        mutex_up(&obd->obd_dev_sem);        /* I want to see a callback happen when the OBD moves to a         * "For General Use" state, and that's when we'll call         * set_nextid().  The class driver can help us here, because         * it can use the obd_recovering flag to determine when the         * the OBD is full available. */        if (!obd->obd_recovering)                rc = mds_postrecov(obd);        RETURN(rc);err_reg:        mutex_up(&obd->obd_dev_sem);        obd_register_observer(mds->mds_osc_obd, NULL);err_discon:        obd_disconnect(mds->mds_osc_exp);        mds->mds_osc_exp = NULL;        mds->mds_osc_obd = ERR_PTR(rc);        RETURN(rc);}int mds_lov_disconnect(struct obd_device *obd){        struct mds_obd *mds = &obd->u.mds;        int rc = 0;        ENTRY;        if (!IS_ERR(mds->mds_osc_obd) && mds->mds_osc_exp != NULL) {                obd_register_observer(mds->mds_osc_obd, NULL);                /* The actual disconnect of the mds_lov will be called from                 * class_disconnect_exports from mds_lov_clean. So we have to                 * ensure that class_cleanup doesn't fail due to the extra ref                 * we're holding now. The mechanism to do that already exists -                 * the obd_force flag. We'll drop the final ref to the                 * mds_osc_exp in mds_cleanup. */                mds->mds_osc_obd->obd_force = 1;        }        RETURN(rc);}int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len,                  void *karg, void *uarg){        static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" };        struct obd_device *obd = exp->exp_obd;        struct mds_obd *mds = &obd->u.mds;        struct obd_ioctl_data *data = karg;        struct lvfs_run_ctxt saved;        int rc = 0;        ENTRY;        CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd);        switch (cmd) {        case OBD_IOC_RECORD: {                char *name = data->ioc_inlbuf1;                struct llog_ctxt *ctxt;                if (mds->mds_cfg_llh)                        RETURN(-EBUSY);                ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                rc = llog_create(ctxt, &mds->mds_cfg_llh, NULL, name);                llog_ctxt_put(ctxt);                if (rc == 0)                        llog_init_handle(mds->mds_cfg_llh, LLOG_F_IS_PLAIN,                                         &cfg_uuid);                else                        mds->mds_cfg_llh = NULL;                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                RETURN(rc);        }        case OBD_IOC_ENDRECORD: {                if (!mds->mds_cfg_llh)                        RETURN(-EBADF);                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                rc = llog_close(mds->mds_cfg_llh);                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                mds->mds_cfg_llh = NULL;                RETURN(rc);        }        case OBD_IOC_CLEAR_LOG: {                char *name = data->ioc_inlbuf1;                struct llog_ctxt *ctxt;                if (mds->mds_cfg_llh)                        RETURN(-EBUSY);                ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                rc = llog_create(ctxt, &mds->mds_cfg_llh, NULL, name);                llog_ctxt_put(ctxt);                if (rc == 0) {                        llog_init_handle(mds->mds_cfg_llh, LLOG_F_IS_PLAIN,                                         NULL);                        rc = llog_destroy(mds->mds_cfg_llh);                        llog_free_handle(mds->mds_cfg_llh);                }                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                mds->mds_cfg_llh = NULL;                RETURN(rc);        }        case OBD_IOC_DORECORD: {                char *cfg_buf;                struct llog_rec_hdr rec;                if (!mds->mds_cfg_llh)                        RETURN(-EBADF);                rec.lrh_len = llog_data_len(data->ioc_plen1);                if (data->ioc_type == LUSTRE_CFG_TYPE) {                        rec.lrh_type = OBD_CFG_REC;                } else {                        CERROR("unknown cfg record type:%d \n", data->ioc_type);                        RETURN(-EINVAL);                }                OBD_ALLOC(cfg_buf, data->ioc_plen1);                if (cfg_buf == NULL)                        RETURN(-EINVAL);                rc = copy_from_user(cfg_buf, data->ioc_pbuf1, data->ioc_plen1);                if (rc) {                        OBD_FREE(cfg_buf, data->ioc_plen1);                        RETURN(rc);                }                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                rc = llog_write_rec(mds->mds_cfg_llh, &rec, NULL, 0,                                    cfg_buf, -1);                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                OBD_FREE(cfg_buf, data->ioc_plen1);                RETURN(rc);        }        case OBD_IOC_PARSE: {                struct llog_ctxt *ctxt =                        llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL);                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                llog_ctxt_put(ctxt);                if (rc)                        RETURN(rc);                RETURN(rc);        }        case OBD_IOC_DUMP_LOG: {                struct llog_ctxt *ctxt =                        llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                rc = class_config_dump_llog(ctxt, data->ioc_inlbuf1, NULL);                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);                llog_ctxt_put(ctxt);                if (rc)                        RETURN(rc);                RETURN(rc);        }        case OBD_IOC_SYNC: {                CDEBUG(D_INFO, "syncing mds %s\n", obd->obd_name);                rc = fsfilt_sync(obd, obd->u.obt.obt_sb);                RETURN(rc);

⌨️ 快捷键说明

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