diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-09-01 14:51:45 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-09-21 11:39:48 -0400 |
commit | 1b11c4d3654877f4deb6f9bec12f6ec487d62030 (patch) | |
tree | 705411f2e3eeceb1058ad299bdb3b3ecc011d1c1 /fs | |
parent | 54a12984a9a29d6b7a363e8860506f0c77f334d7 (diff) | |
download | lwn-1b11c4d3654877f4deb6f9bec12f6ec487d62030.tar.gz lwn-1b11c4d3654877f4deb6f9bec12f6ec487d62030.zip |
bcachefs: stripe_to_mem()
factor out a common helper
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/ec.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 0812d2c76384..9efffc43406d 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -352,6 +352,18 @@ static int mark_stripe_buckets(struct btree_trans *trans, return 0; } +static inline void stripe_to_mem(struct stripe *m, const struct bch_stripe *s) +{ + m->sectors = le16_to_cpu(s->sectors); + m->algorithm = s->algorithm; + m->nr_blocks = s->nr_blocks; + m->nr_redundant = s->nr_redundant; + m->blocks_nonempty = 0; + + for (unsigned i = 0; i < s->nr_blocks; i++) + m->blocks_nonempty += !!stripe_blockcount_get(s, i); +} + int bch2_trigger_stripe(struct btree_trans *trans, enum btree_id btree, unsigned level, struct bkey_s_c old, struct bkey_s _new, @@ -468,14 +480,7 @@ int bch2_trigger_stripe(struct btree_trans *trans, memset(m, 0, sizeof(*m)); } else { - m->sectors = le16_to_cpu(new_s->sectors); - m->algorithm = new_s->algorithm; - m->nr_blocks = new_s->nr_blocks; - m->nr_redundant = new_s->nr_redundant; - m->blocks_nonempty = 0; - - for (unsigned i = 0; i < new_s->nr_blocks; i++) - m->blocks_nonempty += !!stripe_blockcount_get(new_s, i); + stripe_to_mem(m, new_s); if (!old_s) bch2_stripes_heap_insert(c, m, idx); @@ -2198,17 +2203,9 @@ int bch2_stripes_read(struct bch_fs *c) if (ret) break; - const struct bch_stripe *s = bkey_s_c_to_stripe(k).v; - struct stripe *m = genradix_ptr(&c->stripes, k.k->p.offset); - m->sectors = le16_to_cpu(s->sectors); - m->algorithm = s->algorithm; - m->nr_blocks = s->nr_blocks; - m->nr_redundant = s->nr_redundant; - m->blocks_nonempty = 0; - - for (unsigned i = 0; i < s->nr_blocks; i++) - m->blocks_nonempty += !!stripe_blockcount_get(s, i); + + stripe_to_mem(m, bkey_s_c_to_stripe(k).v); bch2_stripes_heap_insert(c, m, k.k->p.offset); 0; |