summaryrefslogtreecommitdiff
path: root/fs/bcachefs/io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-09-27 21:08:39 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:10 -0400
commit71c9e0ba427ae0572693c133e33dad30efaf3aba (patch)
tree0fab58d78d2842a83b6d733bedf68927c84c3688 /fs/bcachefs/io.c
parenta2753581f6c5c05ea93978f8217a29115450ac58 (diff)
downloadlwn-71c9e0ba427ae0572693c133e33dad30efaf3aba.tar.gz
lwn-71c9e0ba427ae0572693c133e33dad30efaf3aba.zip
bcachefs: bch2_extent_ptr_decoded_append()
This new helper for the move path avoids creating a new CRC entry when we already have one that matches the pointer being added. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io.c')
-rw-r--r--fs/bcachefs/io.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index d17128f50f98..549a179b85e6 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -431,12 +431,16 @@ static void init_append_extent(struct bch_write_op *op,
struct bkey_i_extent *e = bkey_extent_init(op->insert_keys.top);
op->pos.offset += crc.uncompressed_size;
- e->k.p = op->pos;
- e->k.size = crc.uncompressed_size;
- e->k.version = version;
+ e->k.p = op->pos;
+ e->k.size = crc.uncompressed_size;
+ e->k.version = version;
bkey_extent_set_cached(&e->k, op->flags & BCH_WRITE_CACHED);
- bch2_extent_crc_append(e, crc);
+ if (crc.csum_type ||
+ crc.compression_type ||
+ crc.nonce)
+ bch2_extent_crc_append(e, crc);
+
bch2_alloc_sectors_append_ptrs(op->c, wp, e, crc.compressed_size);
bch2_keylist_push(&op->insert_keys);