示例#1
0
int mdt_init_idmap(struct tgt_session_info *tsi)
{
	struct ptlrpc_request	*req = tgt_ses_req(tsi);
	struct mdt_export_data *med = mdt_req2med(req);
	struct obd_export *exp = req->rq_export;
	char *client = libcfs_nid2str(req->rq_peer.nid);
	int rc = 0;
	ENTRY;

	if (exp_connect_rmtclient(exp)) {
		mutex_lock(&med->med_idmap_mutex);
		if (!med->med_idmap)
			med->med_idmap = lustre_idmap_init();
		mutex_unlock(&med->med_idmap_mutex);

		if (IS_ERR(med->med_idmap)) {
			long err = PTR_ERR(med->med_idmap);

			med->med_idmap = NULL;
			CERROR("%s: client %s -> target %s "
			       "failed to init idmap [%ld]!\n",
			       tgt_name(tsi->tsi_tgt), client,
			       tgt_name(tsi->tsi_tgt), err);
			RETURN(err);
		} else if (!med->med_idmap) {
			CERROR("%s: client %s -> target %s "
			       "failed to init(2) idmap!\n",
			       tgt_name(tsi->tsi_tgt), client,
			       tgt_name(tsi->tsi_tgt));
			RETURN(-ENOMEM);
		}

		CDEBUG(D_SEC, "%s: client %s -> target %s is remote.\n",
			tgt_name(tsi->tsi_tgt), client,
			tgt_name(tsi->tsi_tgt));
		/* NB, MDS_CONNECT establish root idmap too! */
		rc = mdt_handle_idmap(tsi);
	}
	RETURN(rc);
}
示例#2
0
文件: mdt_idmap.c 项目: DCteam/lustre
int mdt_init_idmap(struct mdt_thread_info *info)
{
        struct ptlrpc_request *req = mdt_info_req(info);
        struct mdt_export_data *med = mdt_req2med(req);
        struct obd_export *exp = req->rq_export;
        char *client = libcfs_nid2str(req->rq_peer.nid);
        struct obd_device *obd = exp->exp_obd;
        int rc = 0;
        ENTRY;

        if (exp_connect_rmtclient(exp)) {
                cfs_down(&med->med_idmap_sem);
                if (!med->med_idmap)
                        med->med_idmap = lustre_idmap_init();
                cfs_up(&med->med_idmap_sem);

                if (IS_ERR(med->med_idmap)) {
                        long err = PTR_ERR(med->med_idmap);

                        med->med_idmap = NULL;
                        CERROR("client %s -> target %s "
                               "failed to init idmap [%ld]!\n",
                               client, obd->obd_name, err);
                        RETURN(err);
                } else if (!med->med_idmap) {
                        CERROR("client %s -> target %s "
                               "failed to init(2) idmap!\n",
                               client, obd->obd_name);
                        RETURN(-ENOMEM);
                }

                CDEBUG(D_SEC, "client %s -> target %s is remote.\n",
                       client, obd->obd_name);
                /* NB, MDS_CONNECT establish root idmap too! */
                rc = mdt_handle_idmap(info);
        }
        RETURN(rc);
}