summaryrefslogtreecommitdiff
path: root/fs/btrfs/bio.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-01-21 09:50:05 +0300
committerDavid Sterba <dsterba@suse.com>2023-02-15 21:38:51 +0300
commit1c2b3ee3b0ec4bc971e23fe18d4c92333a6ad18a (patch)
treed4c86e0cfc3f6243968b8a79760f8c7390cff852 /fs/btrfs/bio.c
parent7276aa7d38255b40e578267c3634ebc05f5d5236 (diff)
downloadlinux-1c2b3ee3b0ec4bc971e23fe18d4c92333a6ad18a.tar.xz
btrfs: pre-load data checksum for reads in btrfs_submit_bio
Instead of calling btrfs_lookup_bio_sums in every caller of btrfs_submit_bio that reads data, do the call once in btrfs_submit_bio. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/bio.c')
-rw-r--r--fs/btrfs/bio.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 8285aa49586a..3e23b97129f8 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -14,6 +14,7 @@
#include "dev-replace.h"
#include "rcu-string.h"
#include "zoned.h"
+#include "file-item.h"
static struct bio_set btrfs_bioset;
@@ -253,9 +254,16 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
BUG();
}
- /* Save the iter for the end_io handler for data reads. */
- if (bio_op(bio) == REQ_OP_READ && !(bio->bi_opf & REQ_META))
+ /*
+ * Save the iter for the end_io handler and preload the checksums for
+ * data reads.
+ */
+ if (bio_op(bio) == REQ_OP_READ && !(bio->bi_opf & REQ_META)) {
bbio->iter = bio->bi_iter;
+ ret = btrfs_lookup_bio_sums(bbio);
+ if (ret)
+ goto fail;
+ }
if (!bioc) {
/* Single mirror read/write fast path */