Commit d5eade93 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: move: convert to bbpos

parent 63316903
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -2,22 +2,10 @@
#ifndef _BCACHEFS_BBPOS_H
#define _BCACHEFS_BBPOS_H

#include "bbpos_types.h"
#include "bkey_methods.h"
#include "btree_cache.h"

struct bbpos {
	enum btree_id		btree;
	struct bpos		pos;
};

static inline struct bbpos BBPOS(enum btree_id btree, struct bpos pos)
{
	return (struct bbpos) { btree, pos };
}

#define BBPOS_MIN	BBPOS(0, POS_MIN)
#define BBPOS_MAX	BBPOS(BTREE_ID_NR - 1, POS_MAX)

static inline int bbpos_cmp(struct bbpos l, struct bbpos r)
{
	return cmp_int(l.btree, r.btree) ?: bpos_cmp(l.pos, r.pos);
+18 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _BCACHEFS_BBPOS_TYPES_H
#define _BCACHEFS_BBPOS_TYPES_H

struct bbpos {
	enum btree_id		btree;
	struct bpos		pos;
};

static inline struct bbpos BBPOS(enum btree_id btree, struct bpos pos)
{
	return (struct bbpos) { btree, pos };
}

#define BBPOS_MIN	BBPOS(0, POS_MIN)
#define BBPOS_MAX	BBPOS(BTREE_ID_NR - 1, POS_MAX)

#endif /* _BCACHEFS_BBPOS_TYPES_H */
+2 −2
Original line number Diff line number Diff line
@@ -332,8 +332,8 @@ static ssize_t bch2_data_job_read(struct file *file, char __user *buf,
	struct bch_ioctl_data_event e = {
		.type			= BCH_DATA_EVENT_PROGRESS,
		.p.data_type		= ctx->stats.data_type,
		.p.btree_id		= ctx->stats.btree_id,
		.p.pos			= ctx->stats.pos,
		.p.btree_id		= ctx->stats.pos.btree,
		.p.pos			= ctx->stats.pos.pos,
		.p.sectors_done		= atomic64_read(&ctx->stats.sectors_seen),
		.p.sectors_total	= bch2_fs_usage_read_short(c).used,
	};
+5 −3
Original line number Diff line number Diff line
@@ -281,11 +281,11 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
		}
		continue;
nowork:
		if (m->ctxt && m->ctxt->stats) {
		if (m->stats && m->stats) {
			BUG_ON(k.k->p.offset <= iter.pos.offset);
			atomic64_inc(&m->ctxt->stats->keys_raced);
			atomic64_inc(&m->stats->keys_raced);
			atomic64_add(k.k->p.offset - iter.pos.offset,
				     &m->ctxt->stats->sectors_raced);
				     &m->stats->sectors_raced);
		}

		this_cpu_inc(c->counters[BCH_COUNTER_move_extent_fail]);
@@ -439,6 +439,8 @@ int bch2_data_update_init(struct btree_trans *trans,
	bch2_bkey_buf_reassemble(&m->k, c, k);
	m->btree_id	= btree_id;
	m->data_opts	= data_opts;
	m->ctxt		= ctxt;
	m->stats	= ctxt->stats;

	bch2_write_op_init(&m->op, c, io_opts);
	m->op.pos	= bkey_start_pos(k.k);
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ struct data_update {
	struct bkey_buf		k;
	struct data_update_opts	data_opts;
	struct moving_context	*ctxt;
	struct bch_move_stats	*stats;
	struct bch_write_op	op;
};

Loading