summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-30 00:24:20 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-16 16:48:40 -0500
commit2c8e020dd3ca3f385485786d1a82c3aa5e9a6be3 (patch)
tree09dc4db1073d89b821981428b572bbc927e3b7ca
parent7d008520c1cdd3d26e9f7f8195812606b2e9bf6f (diff)
bcachefs: extent_block_checksums
todo: - nonces? - alignment - extent merging - need a better bch2_checksum_merge() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/Makefile171
-rw-r--r--fs/bcachefs/alloc_foreground.c5
-rw-r--r--fs/bcachefs/alloc_foreground.h12
-rw-r--r--fs/bcachefs/bcachefs_format.h80
-rw-r--r--fs/bcachefs/bkey_methods.c1
-rw-r--r--fs/bcachefs/extent_block_checksums.c65
-rw-r--r--fs/bcachefs/extent_block_checksums.h49
-rw-r--r--fs/bcachefs/extents.c37
-rw-r--r--fs/bcachefs/extents.h8
-rw-r--r--fs/bcachefs/io_write.c55
-rw-r--r--fs/bcachefs/sb-errors_types.h7
11 files changed, 348 insertions, 142 deletions
diff --git a/fs/bcachefs/Makefile b/fs/bcachefs/Makefile
index 7423a3557c68..ab11cb3e3dba 100644
--- a/fs/bcachefs/Makefile
+++ b/fs/bcachefs/Makefile
@@ -1,92 +1,93 @@
obj-$(CONFIG_BCACHEFS_FS) += bcachefs.o
-bcachefs-y := \
- acl.o \
- alloc_background.o \
- alloc_foreground.o \
- backpointers.o \
- bkey.o \
- bkey_methods.o \
- bkey_sort.o \
- bset.o \
- btree_cache.o \
- btree_gc.o \
- btree_io.o \
- btree_iter.o \
- btree_journal_iter.o \
- btree_key_cache.o \
- btree_locking.o \
- btree_trans_commit.o \
- btree_update.o \
- btree_update_interior.o \
- btree_write_buffer.o \
- buckets.o \
+bcachefs-y := \
+ acl.o \
+ alloc_background.o \
+ alloc_foreground.o \
+ backpointers.o \
+ bkey.o \
+ bkey_methods.o \
+ bkey_sort.o \
+ bset.o \
+ btree_cache.o \
+ btree_gc.o \
+ btree_io.o \
+ btree_iter.o \
+ btree_journal_iter.o \
+ btree_key_cache.o \
+ btree_locking.o \
+ btree_trans_commit.o \
+ btree_update.o \
+ btree_update_interior.o \
+ btree_write_buffer.o \
+ buckets.o \
buckets_waiting_for_journal.o \
- chardev.o \
- checksum.o \
- clock.o \
- compress.o \
- counters.o \
- darray.o \
- debug.o \
- dirent.o \
- disk_groups.o \
- data_update.o \
- ec.o \
- errcode.o \
- error.o \
- extents.o \
- extent_update.o \
- fs.o \
- fs-common.o \
- fs-ioctl.o \
- fs-io.o \
- fs-io-buffered.o \
- fs-io-direct.o \
- fs-io-pagecache.o \
- fsck.o \
- inode.o \
- io_read.o \
- io_misc.o \
- io_write.o \
- journal.o \
- journal_io.o \
- journal_reclaim.o \
- journal_sb.o \
- journal_seq_blacklist.o \
- keylist.o \
- logged_ops.o \
- lru.o \
- mean_and_variance.o \
- migrate.o \
- move.o \
- movinggc.o \
- nocow_locking.o \
- opts.o \
- printbuf.o \
- quota.o \
- rebalance.o \
- recovery.o \
- reflink.o \
- replicas.o \
- sb-clean.o \
- sb-downgrade.o \
- sb-errors.o \
- sb-members.o \
- siphash.o \
- six.o \
- snapshot.o \
- subvolume.o \
- super.o \
- super-io.o \
- sysfs.o \
- tests.o \
- thread_with_file.o \
- trace.o \
- two_state_shared_lock.o \
- util.o \
- varint.o \
+ chardev.o \
+ checksum.o \
+ clock.o \
+ compress.o \
+ counters.o \
+ darray.o \
+ debug.o \
+ dirent.o \
+ disk_groups.o \
+ data_update.o \
+ ec.o \
+ errcode.o \
+ error.o \
+ extent_block_checksums.o \
+ extents.o \
+ extent_update.o \
+ fs.o \
+ fs-common.o \
+ fs-ioctl.o \
+ fs-io.o \
+ fs-io-buffered.o \
+ fs-io-direct.o \
+ fs-io-pagecache.o \
+ fsck.o \
+ inode.o \
+ io_read.o \
+ io_misc.o \
+ io_write.o \
+ journal.o \
+ journal_io.o \
+ journal_reclaim.o \
+ journal_sb.o \
+ journal_seq_blacklist.o \
+ keylist.o \
+ logged_ops.o \
+ lru.o \
+ mean_and_variance.o \
+ migrate.o \
+ move.o \
+ movinggc.o \
+ nocow_locking.o \
+ opts.o \
+ printbuf.o \
+ quota.o \
+ rebalance.o \
+ recovery.o \
+ reflink.o \
+ replicas.o \
+ sb-clean.o \
+ sb-downgrade.o \
+ sb-errors.o \
+ sb-members.o \
+ siphash.o \
+ six.o \
+ snapshot.o \
+ subvolume.o \
+ super.o \
+ super-io.o \
+ sysfs.o \
+ tests.o \
+ thread_with_file.o \
+ trace.o \
+ two_state_shared_lock.o \
+ util.o \
+ varint.o \
xattr.o
obj-$(CONFIG_MEAN_AND_VARIANCE_UNIT_TEST) += mean_and_variance_test.o
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 633d3223b353..0005965a940f 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -1461,7 +1461,10 @@ void bch2_alloc_sectors_append_ptrs(struct bch_fs *c, struct write_point *wp,
struct bkey_i *k, unsigned sectors,
bool cached)
{
- bch2_alloc_sectors_append_ptrs_inlined(c, wp, k, sectors, cached);
+ struct bch_extent_ptr *ptrs = bkey_val_end(bkey_i_to_s(k));
+
+ k->k.u64s += wp->ptrs.nr;
+ bch2_alloc_sectors_append_ptrs_inlined(c, wp, sectors, cached, ptrs);
}
/*
diff --git a/fs/bcachefs/alloc_foreground.h b/fs/bcachefs/alloc_foreground.h
index 7aaeec44c746..3b5e51b53e74 100644
--- a/fs/bcachefs/alloc_foreground.h
+++ b/fs/bcachefs/alloc_foreground.h
@@ -173,8 +173,8 @@ struct bch_extent_ptr bch2_ob_ptr(struct bch_fs *, struct open_bucket *);
*/
static inline void
bch2_alloc_sectors_append_ptrs_inlined(struct bch_fs *c, struct write_point *wp,
- struct bkey_i *k, unsigned sectors,
- bool cached)
+ unsigned sectors, bool cached,
+ struct bch_extent_ptr *ptrs)
{
struct open_bucket *ob;
unsigned i;
@@ -185,13 +185,13 @@ bch2_alloc_sectors_append_ptrs_inlined(struct bch_fs *c, struct write_point *wp,
open_bucket_for_each(c, &wp->ptrs, ob, i) {
struct bch_dev *ca = bch_dev_bkey_exists(c, ob->dev);
- struct bch_extent_ptr ptr = bch2_ob_ptr(c, ob);
- ptr.cached = cached ||
+ *ptrs = bch2_ob_ptr(c, ob);
+ ptrs->type = 1 << BCH_EXTENT_ENTRY_ptr;
+ ptrs->cached = cached ||
(!ca->mi.durability &&
wp->data_type == BCH_DATA_user);
-
- bch2_bkey_append_ptr(k, ptr);
+ ptrs++;
BUG_ON(sectors > ob->sectors_free);
ob->sectors_free -= sectors;
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index f3598cfe446c..96e5e785a144 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -350,40 +350,41 @@ static inline void bkey_init(struct bkey *k)
* - WHITEOUT: for hash table btrees
*/
#define BCH_BKEY_TYPES() \
- x(deleted, 0) \
- x(whiteout, 1) \
- x(error, 2) \
- x(cookie, 3) \
- x(hash_whiteout, 4) \
- x(btree_ptr, 5) \
- x(extent, 6) \
- x(reservation, 7) \
- x(inode, 8) \
- x(inode_generation, 9) \
- x(dirent, 10) \
- x(xattr, 11) \
- x(alloc, 12) \
- x(quota, 13) \
- x(stripe, 14) \
- x(reflink_p, 15) \
- x(reflink_v, 16) \
- x(inline_data, 17) \
- x(btree_ptr_v2, 18) \
- x(indirect_inline_data, 19) \
- x(alloc_v2, 20) \
- x(subvolume, 21) \
- x(snapshot, 22) \
- x(inode_v2, 23) \
- x(alloc_v3, 24) \
- x(set, 25) \
- x(lru, 26) \
- x(alloc_v4, 27) \
- x(backpointer, 28) \
- x(inode_v3, 29) \
- x(bucket_gens, 30) \
- x(snapshot_tree, 31) \
- x(logged_op_truncate, 32) \
- x(logged_op_finsert, 33)
+ x(deleted, 0) \
+ x(whiteout, 1) \
+ x(error, 2) \
+ x(cookie, 3) \
+ x(hash_whiteout, 4) \
+ x(btree_ptr, 5) \
+ x(extent, 6) \
+ x(reservation, 7) \
+ x(inode, 8) \
+ x(inode_generation, 9) \
+ x(dirent, 10) \
+ x(xattr, 11) \
+ x(alloc, 12) \
+ x(quota, 13) \
+ x(stripe, 14) \
+ x(reflink_p, 15) \
+ x(reflink_v, 16) \
+ x(inline_data, 17) \
+ x(btree_ptr_v2, 18) \
+ x(indirect_inline_data, 19) \
+ x(alloc_v2, 20) \
+ x(subvolume, 21) \
+ x(snapshot, 22) \
+ x(inode_v2, 23) \
+ x(alloc_v3, 24) \
+ x(set, 25) \
+ x(lru, 26) \
+ x(alloc_v4, 27) \
+ x(backpointer, 28) \
+ x(inode_v3, 29) \
+ x(bucket_gens, 30) \
+ x(snapshot_tree, 31) \
+ x(logged_op_truncate, 32) \
+ x(logged_op_finsert, 33) \
+ x(extent_block_checksums, 34)
enum bch_bkey_type {
#define x(name, nr) KEY_TYPE_##name = nr,
@@ -683,6 +684,17 @@ struct bch_extent {
union bch_extent_entry start[];
} __packed __aligned(8);
+struct bch_extent_block_checksums {
+ struct bch_val v;
+ __u8 csum_type;
+ __u8 csum_blocksize_bits;
+ __u8 front_pad;
+ __u8 back_pad;
+ __u8 nr_ptrs;
+ __u8 pad[3];
+ struct bch_extent_ptr ptrs[];
+} __packed __aligned(8);
+
struct bch_reservation {
struct bch_val v;
diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c
index 5e52684764eb..5a955d0723a3 100644
--- a/fs/bcachefs/bkey_methods.c
+++ b/fs/bcachefs/bkey_methods.c
@@ -9,6 +9,7 @@
#include "dirent.h"
#include "ec.h"
#include "error.h"
+#include "extent_block_checksums.h"
#include "extents.h"
#include "inode.h"
#include "io_misc.h"
diff --git a/fs/bcachefs/extent_block_checksums.c b/fs/bcachefs/extent_block_checksums.c
new file mode 100644
index 000000000000..233e38db4de7
--- /dev/null
+++ b/fs/bcachefs/extent_block_checksums.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include "bcachefs.h"
+#include "checksum.h"
+#include "error.h"
+#include "extent_block_checksums.h"
+
+int bch2_extent_block_checksums_invalid(struct bch_fs *c, struct bkey_s_c k,
+ enum bkey_invalid_flags flags, struct printbuf *err)
+{
+ struct bkey_s_c_extent_block_checksums e = bkey_s_c_to_extent_block_checksums(k);
+ unsigned csum_blocksize = 1U << e.v->csum_blocksize_bits;
+ int ret = 0;
+
+ bkey_fsck_err_on(!e.v->csum_type ||
+ !bch2_checksum_type_valid(c, e.v->csum_type), c, err,
+ extent_block_checksums_csum_type_unknown,
+ "invalid checksum type %u", e.v->csum_type);
+
+ bkey_fsck_err_on(e.v->front_pad >= csum_blocksize, c, err,
+ extent_block_checksums_front_pad_bad,
+ "front_pad %u > csum_blocksize %u",
+ e.v->front_pad, csum_blocksize);
+
+ bkey_fsck_err_on(e.v->back_pad >= csum_blocksize, c, err,
+ extent_block_checksums_back_pad_bad,
+ "back_pad %u > csum_blocksize %u",
+ e.v->back_pad, csum_blocksize);
+
+ bkey_fsck_err_on((e.v->front_pad + e.k->size + e.v->back_pad) & (csum_blocksize - 1), c, err,
+ extent_block_checksums_misaligned,
+ "misaligned");
+
+ bkey_fsck_err_on(bkey_val_u64s(e.k) != extent_block_checksums_val_u64s(e), c, err,
+ extent_block_checksums_val_size_bad,
+ "incorrect value size (%zu != %u)",
+ bkey_val_u64s(k.k), extent_block_checksums_val_u64s(e));
+
+ ret = bch2_bkey_ptrs_invalid(c, k, flags, err);
+fsck_err:
+ return ret;
+}
+
+bool bch2_extent_block_checksums_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r)
+{
+ /* this is going to need a much bigger key, look at how it's allocated
+ * */
+#if 0
+ struct bkey_s_xtent_block_checksums le = bkey_s_o_extent_block_checksums(l);
+ struct bkey_s_c_extent_block_checksums re = bkey_s_c_to_extent_block_checksums(r);
+
+#endif
+ return false;
+}
+
+void bch2_extent_block_checksums_to_text(struct printbuf *out, struct bch_fs *c,
+ struct bkey_s_c k)
+{
+ struct bkey_s_c_extent_block_checksums e = bkey_s_c_to_extent_block_checksums(k);
+
+ prt_printf(out, "csum type %s ", bch2_csum_types[e.v->csum_type]);
+ prt_printf(out, "csum blocksize %u ", 1U << e.v->csum_blocksize_bits);
+
+ bch2_bkey_ptrs_to_text(out, c, k);
+}
diff --git a/fs/bcachefs/extent_block_checksums.h b/fs/bcachefs/extent_block_checksums.h
new file mode 100644
index 000000000000..4cd3f0a40c2f
--- /dev/null
+++ b/fs/bcachefs/extent_block_checksums.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BCACHEFS_EXTENT_BLOCK_CHECKSUS_H
+#define _BCACHEFS_EXTENT_BLOCK_CHECKSUS_H
+
+#include "bkey.h"
+
+static inline unsigned extent_block_checksums_nr_crcs(struct bkey_s_c_extent_block_checksums e)
+{
+ return (e.k->size + e.v->front_pad + e.v->back_pad) >> e.v->csum_blocksize_bits;
+}
+
+static inline unsigned extent_block_checksums_crc_bytes(struct bkey_s_c_extent_block_checksums e)
+{
+ return round_up(extent_block_checksums_nr_crcs(e) * bch_crc_bytes[e.v->csum_type], sizeof(u64));
+}
+
+static inline unsigned extent_block_checksums_crc_u64s(struct bkey_s_c_extent_block_checksums e)
+{
+ return extent_block_checksums_crc_bytes(e) / sizeof(u64);
+}
+
+static inline unsigned extent_block_checksums_val_bytes(struct bkey_s_c_extent_block_checksums e)
+{
+ return sizeof(*e.v) + sizeof(e.v->ptrs[0]) * e.v->nr_ptrs + extent_block_checksums_crc_bytes(e);
+}
+
+static inline unsigned extent_block_checksums_val_u64s(struct bkey_s_c_extent_block_checksums e)
+{
+ return extent_block_checksums_val_bytes(e) / sizeof(u64);
+}
+
+int bch2_extent_block_checksums_invalid(struct bch_fs *, struct bkey_s_c,
+ enum bkey_invalid_flags, struct printbuf *);
+bool bch2_extent_block_checksums_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
+void bch2_extent_block_checksums_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
+
+#define bch2_bkey_ops_extent_block_checksums ((struct bkey_ops) { \
+ .key_invalid = bch2_bkey_ptrs_invalid, \
+ .val_to_text = bch2_extent_block_checksums_to_text, \
+ .swab = bch2_ptr_swab, \
+ .key_normalize = bch2_extent_normalize, \
+ .key_merge = bch2_extent_block_checksums_merge, \
+ .trans_trigger = bch2_trans_mark_extent, \
+ .atomic_trigger = bch2_mark_extent, \
+ .min_val_size = 8, \
+})
+
+#endif /* _BCACHEFS_EXTENT_BLOCK_CHECKSUS_H */
+
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c
index 61395b113df9..3d53f85d99a6 100644
--- a/fs/bcachefs/extents.c
+++ b/fs/bcachefs/extents.c
@@ -18,6 +18,7 @@
#include "debug.h"
#include "disk_groups.h"
#include "error.h"
+#include "extent_block_checksums.h"
#include "extents.h"
#include "inode.h"
#include "journal.h"
@@ -1462,6 +1463,25 @@ int bch2_cut_front_s(struct bpos where, struct bkey_s k)
new_val_u64s -= sub >> 3;
break;
}
+ case KEY_TYPE_extent_block_checksums: {
+ struct bkey_s_extent_block_checksums e = bkey_s_to_extent_block_checksums(k);
+ unsigned csum_blocksize_mask = ((1U << e.v->csum_blocksize_bits) - 1);
+ unsigned front_pad = e.v->front_pad + sub;
+ unsigned crcs_to_remove = front_pad >> e.v->csum_blocksize_bits;
+ unsigned crc_bytes_to_remove = crcs_to_remove * bch_crc_bytes[e.v->csum_type];
+
+ for (unsigned i = 0; i < e.v->nr_ptrs; i++)
+ e.v->ptrs[i].offset += front_pad & ~csum_blocksize_mask;
+ e.v->front_pad = front_pad & csum_blocksize_mask;
+
+ void *crc_start = &e.v->ptrs[e.v->nr_ptrs];
+
+ memmove(crc_start,
+ crc_start + crc_bytes_to_remove,
+ extent_block_checksums_crc_bytes(e.c) - crc_bytes_to_remove);
+
+ new_val_u64s = extent_block_checksums_val_u64s(e.c);
+ }
}
val_u64s_delta = bkey_val_u64s(k.k) - new_val_u64s;
@@ -1476,19 +1496,20 @@ int bch2_cut_back_s(struct bpos where, struct bkey_s k)
{
unsigned new_val_u64s = bkey_val_u64s(k.k);
int val_u64s_delta;
- u64 len = 0;
if (bkey_ge(where, k.k->p))
return 0;
EBUG_ON(bkey_lt(where, bkey_start_pos(k.k)));
- len = where.offset - bkey_start_offset(k.k);
+ unsigned new_size = where.offset - bkey_start_offset(k.k);
+
+ unsigned sub = k.k->size - new_size;
k.k->p.offset = where.offset;
- k.k->size = len;
+ k.k->size = new_size;
- if (!len) {
+ if (!k.k->size) {
k.k->type = KEY_TYPE_deleted;
new_val_u64s = 0;
}
@@ -1499,6 +1520,14 @@ int bch2_cut_back_s(struct bpos where, struct bkey_s k)
new_val_u64s = (bkey_inline_data_offset(k.k) +
min(bkey_inline_data_bytes(k.k), k.k->size << 9)) >> 3;
break;
+ case KEY_TYPE_extent_block_checksums: {
+ struct bkey_s_extent_block_checksums e = bkey_s_to_extent_block_checksums(k);
+ unsigned csum_blocksize_mask = ((1U << e.v->csum_blocksize_bits) - 1);
+
+ e.v->back_pad = (e.v->back_pad + sub) & csum_blocksize_mask;
+
+ new_val_u64s = extent_block_checksums_val_u64s(e.c);
+ }
}
val_u64s_delta = bkey_val_u64s(k.k) - new_val_u64s;
diff --git a/fs/bcachefs/extents.h b/fs/bcachefs/extents.h
index 6bf839d69e84..87ec7c481a0b 100644
--- a/fs/bcachefs/extents.h
+++ b/fs/bcachefs/extents.h
@@ -262,6 +262,14 @@ static inline struct bkey_ptrs_c bch2_bkey_ptrs_c(struct bkey_s_c k)
to_entry(extent_entry_last(e))
};
}
+ case KEY_TYPE_extent_block_checksums: {
+ struct bkey_s_c_extent_block_checksums e = bkey_s_c_to_extent_block_checksums(k);
+
+ return (struct bkey_ptrs_c) {
+ to_entry(&e.v->ptrs[0]),
+ to_entry(&e.v->ptrs[e.v->nr_ptrs]),
+ };
+ }
default:
return (struct bkey_ptrs_c) { NULL, NULL };
}
diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c
index ef3a53f9045a..e5a5ac6de7fe 100644
--- a/fs/bcachefs/io_write.c
+++ b/fs/bcachefs/io_write.c
@@ -16,6 +16,7 @@
#include "debug.h"
#include "ec.h"
#include "error.h"
+#include "extent_block_checksums.h"
#include "extent_update.h"
#include "inode.h"
#include "io_write.h"
@@ -672,27 +673,59 @@ static void bch2_write_endio(struct bio *bio)
closure_put(cl);
}
+static inline bool use_block_checksums(struct bch_write_op *op,
+ struct bch_extent_crc_unpacked crc)
+{
+ if (!crc.csum_type &&
+ crc.compression_type ||
+ !op->opts.checksum_blocksize)
+ return false;
+
+ unsigned blocksize_mask = (op->opts.checksum_blocksize >> 9) - 1;
+ if ((op->pos.offset & blocksize_mask) ||
+ (crc.uncompressed_size & blocksize_mask))
+ return false;
+
+ return true;
+}
+
static void init_append_extent(struct bch_write_op *op,
struct write_point *wp,
struct bversion version,
struct bch_extent_crc_unpacked crc)
{
- struct bkey_i_extent *e;
+ struct bch_extent_ptr *ptrs;
op->pos.offset += crc.uncompressed_size;
- e = bkey_extent_init(op->insert_keys.top);
- e->k.p = op->pos;
- e->k.size = crc.uncompressed_size;
- e->k.version = version;
+ if (likely(!use_block_checksums(op, crc))) {
+ struct bkey_i_extent *e = bkey_extent_init(op->insert_keys.top);
- if (crc.csum_type ||
- crc.compression_type ||
- crc.nonce)
- bch2_extent_crc_append(&e->k_i, crc);
+ e->k.p = op->pos;
+ e->k.size = crc.uncompressed_size;
+ e->k.version = version;
+
+ if (crc.csum_type ||
+ crc.compression_type ||
+ crc.nonce)
+ bch2_extent_crc_append(&e->k_i, crc);
+
+ ptrs = bkey_val_end(bkey_i_to_s(&e->k_i));
+ e->k.u64s += wp->ptrs.nr;
+ } else {
+ struct bkey_i_extent_block_checksums *e =
+ bkey_extent_block_checksums_init(op->insert_keys.top);
+
+ e->v.csum_type = crc.csum_type;
+ e->v.csum_blocksize_bits = ilog2(op->opts.checksum_blocksize >> 9);
+ e->v.nr_ptrs = wp->ptrs.nr;
+
+ ptrs = e->v.ptrs;
+ set_bkey_val_u64s(&e->k, extent_block_checksums_val_u64s(extent_block_checksums_i_to_s_c(e)));
+ }
- bch2_alloc_sectors_append_ptrs_inlined(op->c, wp, &e->k_i, crc.compressed_size,
- op->flags & BCH_WRITE_CACHED);
+ bch2_alloc_sectors_append_ptrs_inlined(op->c, wp, crc.compressed_size,
+ op->flags & BCH_WRITE_CACHED, ptrs);
bch2_keylist_push(&op->insert_keys);
}
diff --git a/fs/bcachefs/sb-errors_types.h b/fs/bcachefs/sb-errors_types.h
index 24ec6f81d862..2ce1e17c922a 100644
--- a/fs/bcachefs/sb-errors_types.h
+++ b/fs/bcachefs/sb-errors_types.h
@@ -251,7 +251,12 @@
x(hash_table_key_wrong_offset, 243) \
x(unlinked_inode_not_on_deleted_list, 244) \
x(reflink_p_front_pad_bad, 245) \
- x(alloc_key_stripe_sectors_wrong, 246)
+ x(alloc_key_stripe_sectors_wrong, 246) \
+ x(extent_block_checksums_csum_type_unknown, 247) \
+ x(extent_block_checksums_front_pad_bad, 248) \
+ x(extent_block_checksums_back_pad_bad, 249) \
+ x(extent_block_checksums_misaligned, 250) \
+ x(extent_block_checksums_val_size_bad, 251)
enum bch_sb_error_id {
#define x(t, n) BCH_FSCK_ERR_##t = n,