static int out(struct sm_metadata *smm)
{
	int r = 0;

	/*
	 * If we're not recursing then very bad things are happening.
	 */
	if (!smm->recursion_count) {
		DMERR("lost track of recursion depth");
		return -ENOMEM;
	}

	if (smm->recursion_count == 1) {
		while (!brb_empty(&smm->uncommitted)) {
			struct block_op bop;

			r = brb_pop(&smm->uncommitted, &bop);
			if (r) {
				DMERR("bug in bop ring buffer");
				break;
			}

			r = commit_bop(smm, &bop);
			if (r)
				break;
		}
	}

	smm->recursion_count--;

	return r;
}
Ejemplo n.º 2
0
static int brb_pop(struct bop_ring_buffer *brb)
{
	if (brb_empty(brb))
		return -ENODATA;

	brb->begin = brb_next(brb, brb->begin);

	return 0;
}
Ejemplo n.º 3
0
static int brb_peek(struct bop_ring_buffer *brb, struct block_op *result)
{
	struct block_op *bop;

	if (brb_empty(brb))
		return -ENODATA;

	bop = brb->bops + brb->begin;
	result->type = bop->type;
	result->block = bop->block;

	return 0;
}
Ejemplo n.º 4
0
static int apply_bops(struct sm_metadata *smm)
{
	int r = 0;

	while (!brb_empty(&smm->uncommitted)) {
		struct block_op bop;

		r = brb_pop(&smm->uncommitted, &bop);
		if (r) {
			DMERR("bug in bop ring buffer");
			break;
		}

		r = commit_bop(smm, &bop);
		if (r)
			break;
	}

	return r;
}