diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-05-17 16:43:30 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:03 -0400 |
commit | c21d5377791d94fca0d990eee82111572412640c (patch) | |
tree | 890012193173892f2234bd83f3522642fe698cb8 /fs/bcachefs/bkey.c | |
parent | 82355e2882339067e1d6deaec68e629f63259c0d (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>
Diffstat (limited to 'fs/bcachefs/bkey.c')
-rw-r--r-- | fs/bcachefs/bkey.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index a0379f980f7e..5de88a93f33f 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -446,8 +446,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; - *w = 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++) + w[i] = 0; if (unlikely(in.snapshot < le64_to_cpu(f->field_offset[BKEY_FIELD_SNAPSHOT]))) { |