summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-10-08 18:45:29 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:29 -0400
commit37954a275fce612f60406bc79f5bc0b07b4b6558 (patch)
tree14acd88d70f6424860f91195622a167ef4eb1374 /fs/bcachefs/buckets.c
parent9ef6068c4dce124235b335847570ae8f2bf2911d (diff)
downloadlwn-37954a275fce612f60406bc79f5bc0b07b4b6558.tar.gz
lwn-37954a275fce612f60406bc79f5bc0b07b4b6558.zip
bcachefs: Limit pointers to being in only one stripe
This make the disk accounting code saner, and it's not clear why we'd ever want the same data to be in multiple stripes simultaneously. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.c')
-rw-r--r--fs/bcachefs/buckets.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 9beb4d4cf85d..dc184de053ee 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -1027,7 +1027,6 @@ static int bch2_mark_extent(struct bch_fs *c, struct bkey_s_c k,
struct extent_ptr_decoded p;
struct bch_replicas_padded r;
s64 dirty_sectors = 0;
- unsigned i;
int ret;
r.e.data_type = data_type;
@@ -1047,17 +1046,15 @@ static int bch2_mark_extent(struct bch_fs *c, struct bkey_s_c k,
if (!stale)
update_cached_sectors(c, fs_usage, p.ptr.dev,
disk_sectors);
- } else if (!p.ec_nr) {
+ } else if (!p.has_ec) {
dirty_sectors += disk_sectors;
r.e.devs[r.e.nr_devs++] = p.ptr.dev;
} else {
- for (i = 0; i < p.ec_nr; i++) {
- ret = bch2_mark_stripe_ptr(c, p.ec[i],
- data_type, fs_usage,
- disk_sectors, flags);
- if (ret)
- return ret;
- }
+ ret = bch2_mark_stripe_ptr(c, p.ec,
+ data_type, fs_usage,
+ disk_sectors, flags);
+ if (ret)
+ return ret;
r.e.nr_required = 0;
}
@@ -1564,7 +1561,6 @@ static int bch2_trans_mark_extent(struct btree_trans *trans,
struct bch_replicas_padded r;
s64 dirty_sectors = 0;
bool stale;
- unsigned i;
int ret;
r.e.data_type = data_type;
@@ -1589,16 +1585,14 @@ static int bch2_trans_mark_extent(struct btree_trans *trans,
if (!stale)
update_cached_sectors_list(trans, p.ptr.dev,
disk_sectors);
- } else if (!p.ec_nr) {
+ } else if (!p.has_ec) {
dirty_sectors += disk_sectors;
r.e.devs[r.e.nr_devs++] = p.ptr.dev;
} else {
- for (i = 0; i < p.ec_nr; i++) {
- ret = bch2_trans_mark_stripe_ptr(trans, p.ec[i],
- disk_sectors, data_type);
- if (ret)
- return ret;
- }
+ ret = bch2_trans_mark_stripe_ptr(trans, p.ec,
+ disk_sectors, data_type);
+ if (ret)
+ return ret;
r.e.nr_required = 0;
}