Skip to content

Commit 6675c37

Browse files
author
Kent Overstreet
committed
bcachefs: bch_acct_snapshot
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 72c2778 commit 6675c37

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

fs/bcachefs/buckets.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,16 @@ static int __trigger_extent(struct btree_trans *trans,
778778
return ret;
779779
}
780780

781+
if (acc_replicas_key.replicas.nr_devs && !level && k.k->p.snapshot) {
782+
struct disk_accounting_pos acc_snapshot_key = {
783+
.type = BCH_DISK_ACCOUNTING_snapshot,
784+
.snapshot.id = k.k->p.snapshot,
785+
};
786+
ret = bch2_disk_accounting_mod(trans, &acc_snapshot_key, &replicas_sectors, 1, gc);
787+
if (ret)
788+
return ret;
789+
}
790+
781791
if (acct_compression_key.compression.type) {
782792
if (flags & BTREE_TRIGGER_overwrite)
783793
bch2_u64s_neg(compression_acct, ARRAY_SIZE(compression_acct));

fs/bcachefs/disk_accounting.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ void bch2_accounting_key_to_text(struct printbuf *out, struct disk_accounting_po
146146
case BCH_DISK_ACCOUNTING_compression:
147147
bch2_prt_compression_type(out, k->compression.type);
148148
break;
149+
case BCH_DISK_ACCOUNTING_snapshot:
150+
prt_printf(out, "id=%u", k->snapshot.id);
151+
break;
149152
}
150153
}
151154

fs/bcachefs/disk_accounting_format.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ static inline bool data_type_is_hidden(enum bch_data_type type)
100100
x(persistent_reserved, 1) \
101101
x(replicas, 2) \
102102
x(dev_data_type, 3) \
103-
x(compression, 4)
103+
x(compression, 4) \
104+
x(snapshot, 5)
104105

105106
enum disk_accounting_type {
106107
#define x(f, nr) BCH_DISK_ACCOUNTING_##f = nr,
@@ -129,6 +130,10 @@ struct bch_acct_compression {
129130
__u8 type;
130131
};
131132

133+
struct bch_acct_snapshot {
134+
__u32 id;
135+
};
136+
132137
struct disk_accounting_pos {
133138
union {
134139
struct {
@@ -140,6 +145,7 @@ struct disk_accounting_pos {
140145
struct bch_dev_data_type dev_data_type;
141146
struct bch_dev_stripe_buckets dev_stripe_buckets;
142147
struct bch_acct_compression compression;
148+
struct bch_acct_snapshot snapshot;
143149
};
144150
};
145151
struct bpos _pad;

0 commit comments

Comments
 (0)