summaryrefslogtreecommitdiff
path: root/libbcachefs/alloc_background.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-11-30 12:38:54 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2018-11-30 12:51:13 -0500
commit0c7db4eca3e6519043c10288cb41f8a0ee634a0b (patch)
treefd788cd46ea5b14e287b48677a94384a5abcce27 /libbcachefs/alloc_background.c
parentbca8b084ad754afc54e628d9db7721b90d9480b7 (diff)
Update bcachefs sources to 62de7539dc bcachefs: Make bkey types globally unique
Diffstat (limited to 'libbcachefs/alloc_background.c')
-rw-r--r--libbcachefs/alloc_background.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/libbcachefs/alloc_background.c b/libbcachefs/alloc_background.c
index 89929163..2e2fb99e 100644
--- a/libbcachefs/alloc_background.c
+++ b/libbcachefs/alloc_background.c
@@ -75,22 +75,15 @@ static unsigned bch_alloc_val_u64s(const struct bch_alloc *a)
const char *bch2_alloc_invalid(const struct bch_fs *c, struct bkey_s_c k)
{
+ struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
+
if (k.k->p.inode >= c->sb.nr_devices ||
!c->devs[k.k->p.inode])
return "invalid device";
- switch (k.k->type) {
- case BCH_ALLOC: {
- struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
-
- /* allow for unknown fields */
- if (bkey_val_u64s(a.k) < bch_alloc_val_u64s(a.v))
- return "incorrect value size";
- break;
- }
- default:
- return "invalid type";
- }
+ /* allow for unknown fields */
+ if (bkey_val_u64s(a.k) < bch_alloc_val_u64s(a.v))
+ return "incorrect value size";
return NULL;
}
@@ -98,14 +91,9 @@ const char *bch2_alloc_invalid(const struct bch_fs *c, struct bkey_s_c k)
void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c,
struct bkey_s_c k)
{
- switch (k.k->type) {
- case BCH_ALLOC: {
- struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
+ struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
- pr_buf(out, "gen %u", a.v->gen);
- break;
- }
- }
+ pr_buf(out, "gen %u", a.v->gen);
}
static inline unsigned get_alloc_field(const u8 **p, unsigned bytes)
@@ -157,7 +145,7 @@ static void bch2_alloc_read_key(struct bch_fs *c, struct bkey_s_c k)
struct bucket *g;
const u8 *d;
- if (k.k->type != BCH_ALLOC)
+ if (k.k->type != KEY_TYPE_alloc)
return;
a = bkey_s_c_to_alloc(k);