From: Josef Bacik <josef@toxicpanda.com>
We keep track of this information in the ordered extent for writes, but
we need it for reads as well. Add fscrypt_extent_info and orig_start to
the dio_data so we can populate this on reads. This will be used later
when we attach the fscrypt context to the bios.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Daniel Vacek <neelx@suse.com>
---
v5: https://lore.kernel.org/linux-btrfs/acf3d79bcd72a4447b2993e78d9742fa5a05397f.1706116485.git.josef@toxicpanda.com/
* Open-code orig_start to start - offset.
---
fs/btrfs/direct-io.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c
index c95b4e768043..d3789109ca85 100644
--- a/fs/btrfs/direct-io.c
+++ b/fs/btrfs/direct-io.c
@@ -17,6 +17,8 @@ struct btrfs_dio_data {
ssize_t submitted;
struct extent_changeset *data_reserved;
struct btrfs_ordered_extent *ordered;
+ struct fscrypt_extent_info *fscrypt_info;
+ u64 orig_start;
bool data_space_reserved;
bool nocow_done;
};
@@ -550,6 +552,9 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
release_offset,
release_len);
}
+ } else {
+ dio_data->fscrypt_info = fscrypt_get_extent_info(em->fscrypt_info);
+ dio_data->orig_start = em->start - em->offset;
}
/*
@@ -640,6 +645,11 @@ static int btrfs_dio_iomap_end(struct inode *inode, loff_t pos, loff_t length,
dio_data->ordered = NULL;
}
+ if (dio_data->fscrypt_info) {
+ fscrypt_put_extent_info(dio_data->fscrypt_info);
+ dio_data->fscrypt_info = NULL;
+ }
+
if (write)
extent_changeset_free(dio_data->data_reserved);
return ret;
--
2.51.0