summaryrefslogtreecommitdiff
path: root/libbcachefs/disk_accounting.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-10-17 22:30:32 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-10-20 19:07:51 -0400
commit553d6f107a3e90d451fcac8a88c07746dcb340cf (patch)
tree9cb62d5dcdd1ef09815cea97ccacefe348703394 /libbcachefs/disk_accounting.c
parent4f9293b045cf32dfc629ce300180d311aba8f53a (diff)
Update bcachefs sources to 1dbc147a6eb0 bcachefs: Add version check for bch_btree_ptr_v2.sectors_written validate
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/disk_accounting.c')
-rw-r--r--libbcachefs/disk_accounting.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libbcachefs/disk_accounting.c b/libbcachefs/disk_accounting.c
index 6875f3dd..55a00018 100644
--- a/libbcachefs/disk_accounting.c
+++ b/libbcachefs/disk_accounting.c
@@ -244,10 +244,10 @@ void bch2_accounting_swab(struct bkey_s k)
}
static inline void __accounting_to_replicas(struct bch_replicas_entry_v1 *r,
- struct disk_accounting_pos acc)
+ struct disk_accounting_pos *acc)
{
- unsafe_memcpy(r, &acc.replicas,
- replicas_entry_bytes(&acc.replicas),
+ unsafe_memcpy(r, &acc->replicas,
+ replicas_entry_bytes(&acc->replicas),
"variable length struct");
}
@@ -258,7 +258,7 @@ static inline bool accounting_to_replicas(struct bch_replicas_entry_v1 *r, struc
switch (acc_k.type) {
case BCH_DISK_ACCOUNTING_replicas:
- __accounting_to_replicas(r, acc_k);
+ __accounting_to_replicas(r, &acc_k);
return true;
default:
return false;
@@ -626,7 +626,7 @@ static int bch2_disk_accounting_validate_late(struct btree_trans *trans,
switch (acc.type) {
case BCH_DISK_ACCOUNTING_replicas: {
struct bch_replicas_padded r;
- __accounting_to_replicas(&r.e, acc);
+ __accounting_to_replicas(&r.e, &acc);
for (unsigned i = 0; i < r.e.nr_devs; i++)
if (r.e.devs[i] != BCH_SB_MEMBER_INVALID &&
@@ -857,8 +857,10 @@ int bch2_dev_usage_init(struct bch_dev *ca, bool gc)
};
u64 v[3] = { ca->mi.nbuckets - ca->mi.first_bucket, 0, 0 };
- int ret = bch2_trans_do(c, NULL, NULL, 0,
- bch2_disk_accounting_mod(trans, &acc, v, ARRAY_SIZE(v), gc));
+ int ret = bch2_trans_do(c, ({
+ bch2_disk_accounting_mod(trans, &acc, v, ARRAY_SIZE(v), gc) ?:
+ (!gc ? bch2_trans_commit(trans, NULL, NULL, 0) : 0);
+ }));
bch_err_fn(c, ret);
return ret;
}