summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-17 16:43:30 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2021-05-19 15:33:48 -0400
commitac91176cb1f48e218d19026977ebe52078297c32 (patch)
tree972b4bad3c4a118207bbff22eecf7f3e81d14d9a
parent421203a28c3654a71a342a2e3d524e1a31901a77 (diff)
bcachefs: Fix for bch2_bkey_pack_pos() not initializing len/version fields
This bug led to push_whiteout() generating whiteouts that failed bch2_bkey_invalid() due to nonzero length fields - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/bkey.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c
index 3af56062601f..0053f32c0076 100644
--- a/fs/bcachefs/bkey.c
+++ b/fs/bcachefs/bkey.c
@@ -443,8 +443,15 @@ enum bkey_pack_pos_ret bch2_bkey_pack_pos_lossy(struct bkey_packed *out,
struct bpos orig = in;
#endif
bool exact = true;
+ unsigned i;
- out->_data[0] = 0;
+ /*
+ * bch2_bkey_pack_key() will write to all of f->key_u64s, minus the 3
+ * byte header, but pack_pos() won't if the len/version fields are big
+ * enough - we need to make sure to zero them out:
+ */
+ for (i = 0; i < f->key_u64s; i++)
+ out->_data[i] = 0;
if (unlikely(in.snapshot <
le64_to_cpu(f->field_offset[BKEY_FIELD_SNAPSHOT]))) {