Esempio n. 1
0
int
slc_fcmh_ctor(struct fidc_membh *f, __unusedx int flags)
{
	struct fcmh_cli_info *fci;
	struct sl_resource *res;
	struct sl_site *s;
	sl_siteid_t siteid;
	int i;

	fci = fcmh_get_pri(f);
	slc_fcmh_refresh_age(f);
	INIT_PSC_LISTENTRY(&fci->fci_lentry);
	siteid = FID_GET_SITEID(fcmh_2_fid(f));

	psc_assert(f->fcmh_flags & FCMH_INITING);

	if (fcmh_2_fid(f) != SLFID_ROOT &&
	    siteid != msl_rmc_resm->resm_siteid) {
		s = libsl_siteid2site(siteid);
		if (s == NULL) {
			psclog_errorx("fid "SLPRI_FID" has "
			    "invalid site ID %d",
			    fcmh_2_fid(f), siteid);
			return (ESTALE);
		}
		SITE_FOREACH_RES(s, res, i)
			if (res->res_type == SLREST_MDS) {
				fci->fci_resm = psc_dynarray_getpos(
				    &res->res_members, 0);
				return (0);
			}
		psclog_errorx("fid "SLPRI_FID" has invalid site ID %d",
		    fcmh_2_fid(f), siteid);
		return (ESTALE);
	}
Esempio n. 2
0
/*
 * Handle a request for MDS from another MDS.
 */
int
slm_rmm_handler(struct pscrpc_request *rq)
{
	int rc;

	rq->rq_status = SL_EXP_REGISTER_RESM(rq->rq_export,
	    slm_getmcsvcx(_resm, rq->rq_export));
	if (rq->rq_status)
		return (pscrpc_error(rq));

	switch (rq->rq_reqmsg->opc) {
	case SRMT_CONNECT:
		rc = slrpc_handle_connect(rq, SRMM_MAGIC, SRMM_VERSION,
		    SLCONNT_MDS);
		break;
	case SRMT_BATCH_RP:
		rc = sl_handle_batchrp(rq);
		break;
	case SRMT_NAMESPACE_UPDATE:
		rc = slm_rmm_handle_namespace_update(rq);
		break;
	case SRMT_NAMESPACE_FORWARD:
		rc = slm_rmm_handle_namespace_forward(rq);
		break;
	default:
		psclog_errorx("unexpected opcode %d",
		    rq->rq_reqmsg->opc);
		rq->rq_status = -PFLERR_NOSYS;
		return (pscrpc_error(rq));
	}
	slrpc_rep_out(rq);
	pscrpc_target_send_reply_msg(rq, rc, 0);
	return (rc);
}
Esempio n. 3
0
int
sli_rmi_setmds(const char *name)
{
	struct slashrpc_cservice *csvc;
	struct sl_resource *res;
//	struct sl_resm *old;
	lnet_nid_t nid;

	/* XXX kill any old MDS and purge any bmap updates being held */
//	slconnthr_unwatch(rmi_resm->resm_csvc);
//	old = rmi_resm;
//	sl_csvc_disable(old->resm_csvc);

	nid = libcfs_str2nid(name);
	if (nid == LNET_NID_ANY) {
		res = libsl_str2res(name);
		if (res == NULL)
			return (SLERR_RES_UNKNOWN);
		rmi_resm = psc_dynarray_getpos(&res->res_members, 0);
	} else
		rmi_resm = libsl_nid2resm(nid);

	if (sli_rmi_getcsvc(&csvc))
		psclog_errorx("error connecting to MDS");
	else {
		slconnthr_watch(sliconnthr, csvc, CSVCF_PING, NULL,
		    NULL);
		sl_csvc_decref(csvc);
	}
	return (0);
}
Esempio n. 4
0
void
pjournal_dump_entry(uint32_t slot, struct psc_journal_enthdr *pje)
{
	union {
		struct slmds_jent_assign_rep *logentry;
		struct slmds_jent_bmap_assign *sjba;
		struct slmds_jent_bmap_repls *sjbr;
		struct slmds_jent_ino_repls *sjir;
		struct slmds_jent_namespace *sjnm;
		struct slmds_jent_bmap_crc *sjbc;
		struct slmds_jent_bmapseq *sjsq;
		void *p;
	} u;
	int type, nlen, n2len;
	const char *n, *n2;

	u.p = PJE_DATA(pje);

	type = pje->pje_type & ~(_PJE_FLSHFT - 1);
	printf("%6d: %3x %4"PRIx64" %4"PRIx64" ",
	    slot, type, pje->pje_xid, pje->pje_txg);
	switch (type) {
	case MDS_LOG_BMAP_REPLS:
		printf("fid=%016"PRIx64" bmap_repls", u.sjbr->sjbr_fid);
		break;
	case MDS_LOG_BMAP_CRC:
		printf("fid=%016"PRIx64" bmap_crc", u.sjbc->sjbc_fid);
		break;
	case MDS_LOG_BMAP_SEQ:
		printf("lwm=%"PRIx64" hwm=%"PRIx64,
		    u.sjsq->sjbsq_low_wm,
		    u.sjsq->sjbsq_high_wm);
		break;
	case MDS_LOG_INO_REPLS:
		printf("fid=%016"PRIx64" ino_repls", u.sjir->sjir_fid);
		break;
	case MDS_LOG_BMAP_ASSIGN:
		if (u.logentry->sjar_flags & SLJ_ASSIGN_REP_FREE)
			printf("bia item=%d", u.logentry->sjar_elem);
		else {
			printf("fid=%016"PRIx64" bia flags=%x",
			    u.logentry->sjar_bmap.sjba_fid,
			    u.logentry->sjar_flags);
		}
		break;
	case MDS_LOG_NAMESPACE:
		printf("fid=%016"PRIx64" ", u.sjnm->sjnm_target_fid);

		n = u.sjnm->sjnm_name;
		nlen = u.sjnm->sjnm_namelen;
		n2len = u.sjnm->sjnm_namelen2;
		n2 = n + nlen;

		switch (u.sjnm->sjnm_op) {
		case NS_OP_RECLAIM:
			printf("op=reclaim");
			break;
		case NS_OP_CREATE:
			printf("op=create name=%.*s", nlen, n);
			break;
		case NS_OP_MKDIR:
			printf("op=mkdir name=%.*s", nlen, n);
			break;
		case NS_OP_LINK:
			printf("op=link name=%.*s", nlen, n);
			break;
		case NS_OP_SYMLINK:
			printf("op=symlink name=%.*s", nlen, n);
			break;
		case NS_OP_RENAME:
			printf("op=rename oldname=%.*s newname=%.*s",
			    nlen, n, n2len, n2);
			break;
		case NS_OP_UNLINK:
			printf("op=unlink name=%.*s", nlen, n);
			break;
		case NS_OP_RMDIR:
			printf("op=rmdir name=%.*s", nlen, n);
			break;
		case NS_OP_SETSIZE:
			printf("op=setsize");
			break;
		case NS_OP_SETATTR:
			printf("op=setattr mask=%#x",
			    u.sjnm->sjnm_mask);
			break;
		default:
			psclog_errorx("op=INVALID (%d)",
			    u.sjnm->sjnm_op);
		}
		break;
	default:
		psclog_errorx("invalid type");
		break;
	}
	printf("\n");
}
Esempio n. 5
0
int
sli_rmi_issue_repl_schedwk(struct sli_repl_workrq *w)
{
	struct slashrpc_cservice *csvc = NULL;
	struct pscrpc_request *rq = NULL;
	int rc;

	if (w->srw_op == SLI_REPLWKOP_REPL) {
		w->srw_pp->rc = w->srw_status;
		if (psc_atomic32_inc_getnew(&w->srw_bchrp->ndone) <
		    w->srw_bchrp->total)
			return (0);
	}

	rc = sli_rmi_getcsvc(&csvc);
	if (rc)
		goto out;

	if (w->srw_op == SLI_REPLWKOP_PTRUNC) {
		struct srm_bmap_ptrunc_req *mq;
		struct srm_bmap_ptrunc_rep *mp;

		rc = SL_RSX_NEWREQ(csvc, SRMT_BMAP_PTRUNC, rq, mq,
		    mp);
		if (rc)
			goto out;
		mq->bmapno = w->srw_bmapno;
		mq->bgen = w->srw_bgen;
		mq->rc = w->srw_status;
		mq->fg = w->srw_fg;
		rc = SL_RSX_WAITREP(csvc, rq, mp);
		if (rc == 0)
			rc = mp->rc;
	} else {
		struct srm_batch_req *mq;
		struct srm_batch_rep *mp;
		struct iovec iov;

		rc = SL_RSX_NEWREQ(csvc, SRMT_BATCH_RP, rq, mq, mp);
		if (rc)
			goto out;
		mq->opc = SRMT_REPL_SCHEDWK;
		mq->len = w->srw_bchrp->total * sizeof(*w->srw_pp);
		mq->bid = w->srw_bchrp->id;

		iov.iov_base = w->srw_bchrp->buf;
		iov.iov_len = mq->len;
		rc = slrpc_bulkclient(rq, BULK_GET_SOURCE, SRMI_BULK_PORTAL,
		    &iov, 1);
		if (rc == 0)
			rc = SL_RSX_WAITREP(csvc, rq, mp);
		if (rc == 0)
			rc = mp->rc;
	}
	if (w->srw_status)
		psclog_errorx("sent error rc=%d", w->srw_status);

 out:
	if (rq)
		pscrpc_req_finished(rq);
	if (csvc)
		sl_csvc_decref(csvc);
	return (rc);
}
Esempio n. 6
0
/*
 * For the given bmap, change the status of all its replicas marked
 * "valid" to "invalid" except for the replica specified.
 *
 * This is a high-level convenience call provided to easily update
 * status after an ION has received some new I/O, which would make all
 * other existing copies of the bmap on any other replicas old.
 * @b: the bmap.
 * @iosidx: the index of the only ION resource in the inode replica
 *	table that should be marked "valid".
 *
 * Note: All callers must journal log these bmap replica changes
 *	themselves.  In addition, they must log any changes to the inode
 *	_before_ the bmap changes.  Otherwise, we could end up actually
 *	having bmap replicas that are not recognized by the information
 *	stored in the inode during log replay.
 */
int
mds_repl_inv_except(struct bmap *b, int iosidx)
{
	int rc, logit = 0, tract[NBREPLST], retifset[NBREPLST];
	uint32_t policy;

	/* Ensure replica on active IOS is marked valid. */
	brepls_init(tract, -1);
	tract[BREPLST_INVALID] = BREPLST_VALID;
	tract[BREPLST_GARBAGE_SCHED] = BREPLST_VALID;
	tract[BREPLST_GARBAGE_QUEUED] = BREPLST_VALID;

	/*
	 * The old state for this bmap on the given IOS is
	 * either valid or invalid.
	 */
	brepls_init_idx(retifset);
	retifset[BREPLST_INVALID] = 0;
	retifset[BREPLST_VALID] = 0;

	/*
	 * XXX on full truncate, the metafile will exist, which means
	 * the bmap states will exist, which means a new IOS will be
	 * selected which will probably be GARBAGE after truncate
	 * happens a few times.
	 */
	rc = mds_repl_bmap_walk(b, tract, retifset, 0, &iosidx, 1);
	if (rc) {
		psclog_errorx("bcs_repls has active IOS marked in a "
		    "weird state while invalidating other replicas; "
		    "fid="SLPRI_FID" bmap=%d iosidx=%d state=%d",
		    fcmh_2_fid(b->bcm_fcmh), b->bcm_bmapno, iosidx, rc);
	}

	policy = bmap_2_replpol(b);

	/*
	 * Invalidate all other replicas.
	 * Note: if the status is SCHED here, don't do anything; once
	 * the replication status update comes from the ION, we will
	 * know he copied an old bmap and mark it OLD then.
	 */
	brepls_init(tract, -1);
	tract[BREPLST_VALID] = policy == BRPOL_PERSIST ?
	    BREPLST_REPL_QUEUED : BREPLST_GARBAGE_QUEUED;
	tract[BREPLST_REPL_SCHED] = BREPLST_REPL_QUEUED;

	brepls_init(retifset, 0);
	retifset[BREPLST_VALID] = 1;
	retifset[BREPLST_REPL_SCHED] = 1;

	if (_mds_repl_bmap_walk(b, tract, retifset, REPL_WALKF_MODOTH,
	    &iosidx, 1, NULL, NULL)) {
		logit = 1;
		BHGEN_INCREMENT(b);
	}
	if (logit)
		rc = mds_bmap_write_logrepls(b);
	else
		rc = mds_bmap_write(b, NULL, NULL);

	/*
	 * If this bmap is marked for persistent replication, the repl
	 * request must exist and should be marked such that the
	 * replication monitors do not release it in the midst of
	 * processing it as this activity now means they have more to
	 * do.
	 */
	if (policy == BRPOL_PERSIST)
		upsch_enqueue(&bmap_2_bmi(b)->bmi_upd);
	return (rc);
}