aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorAlexander Motin <[email protected]>2023-11-22 13:15:32 -0500
committerBrian Behlendorf <[email protected]>2023-11-27 09:56:30 -0800
commita490875103659bfb58cae1778c0f326c2111dd66 (patch)
tree32a03ad8b8727af2f36b83a1b9e52668cca51680 /module
parent27d8c23c582056a23509a7b80844a1b6435750b0 (diff)
ZIL: Refactor TX_WRITE encryption similar to TX_CLONE_RANGE
It should be purely textual change to make the code more readable. Should cause no functional difference. Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Tom Caputi <[email protected]> Reviewed-by: Sean Eric Fagan <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Edmund Nadolski <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15543 Closes #15513
Diffstat (limited to 'module')
-rw-r--r--module/os/freebsd/zfs/zio_crypt.c18
-rw-r--r--module/os/linux/zfs/zio_crypt.c12
2 files changed, 10 insertions, 20 deletions
diff --git a/module/os/freebsd/zfs/zio_crypt.c b/module/os/freebsd/zfs/zio_crypt.c
index 024a931d7..74755eb6d 100644
--- a/module/os/freebsd/zfs/zio_crypt.c
+++ b/module/os/freebsd/zfs/zio_crypt.c
@@ -1338,19 +1338,14 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
* authenticate it.
*/
if (txtype == TX_WRITE) {
- crypt_len = sizeof (lr_write_t) -
- sizeof (lr_t) - sizeof (blkptr_t);
- dst_iovecs[vec].iov_base = (char *)dlrp +
- sizeof (lr_t);
+ const size_t o = offsetof(lr_write_t, lr_blkptr);
+ crypt_len = o - sizeof (lr_t);
+ dst_iovecs[vec].iov_base = (char *)dlrp + sizeof (lr_t);
dst_iovecs[vec].iov_len = crypt_len;
/* copy the bp now since it will not be encrypted */
- memcpy(dlrp + sizeof (lr_write_t) - sizeof (blkptr_t),
- slrp + sizeof (lr_write_t) - sizeof (blkptr_t),
- sizeof (blkptr_t));
- memcpy(aadp,
- slrp + sizeof (lr_write_t) - sizeof (blkptr_t),
- sizeof (blkptr_t));
+ memcpy(dlrp + o, slrp + o, sizeof (blkptr_t));
+ memcpy(aadp, slrp + o, sizeof (blkptr_t));
aadp += sizeof (blkptr_t);
aad_len += sizeof (blkptr_t);
vec++;
@@ -1379,8 +1374,7 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
total_len += crypt_len;
} else {
crypt_len = lr_len - sizeof (lr_t);
- dst_iovecs[vec].iov_base = (char *)dlrp +
- sizeof (lr_t);
+ dst_iovecs[vec].iov_base = (char *)dlrp + sizeof (lr_t);
dst_iovecs[vec].iov_len = crypt_len;
vec++;
total_len += crypt_len;
diff --git a/module/os/linux/zfs/zio_crypt.c b/module/os/linux/zfs/zio_crypt.c
index 775ab8efb..55f807ccf 100644
--- a/module/os/linux/zfs/zio_crypt.c
+++ b/module/os/linux/zfs/zio_crypt.c
@@ -1513,20 +1513,16 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
* authenticate it.
*/
if (txtype == TX_WRITE) {
- crypt_len = sizeof (lr_write_t) -
- sizeof (lr_t) - sizeof (blkptr_t);
+ const size_t o = offsetof(lr_write_t, lr_blkptr);
+ crypt_len = o - sizeof (lr_t);
src_iovecs[nr_iovecs].iov_base = slrp + sizeof (lr_t);
src_iovecs[nr_iovecs].iov_len = crypt_len;
dst_iovecs[nr_iovecs].iov_base = dlrp + sizeof (lr_t);
dst_iovecs[nr_iovecs].iov_len = crypt_len;
/* copy the bp now since it will not be encrypted */
- memcpy(dlrp + sizeof (lr_write_t) - sizeof (blkptr_t),
- slrp + sizeof (lr_write_t) - sizeof (blkptr_t),
- sizeof (blkptr_t));
- memcpy(aadp,
- slrp + sizeof (lr_write_t) - sizeof (blkptr_t),
- sizeof (blkptr_t));
+ memcpy(dlrp + o, slrp + o, sizeof (blkptr_t));
+ memcpy(aadp, slrp + o, sizeof (blkptr_t));
aadp += sizeof (blkptr_t);
aad_len += sizeof (blkptr_t);
nr_iovecs++;