Skip to content

Commit 787f1b2

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm-verity, dm-crypt: align "struct bvec_iter" correctly
"struct bvec_iter" is defined with the __packed attribute, so it is aligned on a single byte. On X86 (and on other architectures that support unaligned addresses in hardware), "struct bvec_iter" is accessed using the 8-byte and 4-byte memory instructions, however these instructions are less efficient if they operate on unaligned addresses. (on RISC machines that don't have unaligned access in hardware, GCC generates byte-by-byte accesses that are very inefficient - see [1]) This commit reorders the entries in "struct dm_verity_io" and "struct convert_context", so that "struct bvec_iter" is aligned on 8 bytes. [1] https://lore.kernel.org/all/ZcLuWUNRZadJr0tQ@fedora/T/ Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 42e15d1 commit 787f1b2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/md/dm-crypt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
struct convert_context {
5454
struct completion restart;
5555
struct bio *bio_in;
56-
struct bio *bio_out;
5756
struct bvec_iter iter_in;
57+
struct bio *bio_out;
5858
struct bvec_iter iter_out;
59-
u64 cc_sector;
6059
atomic_t cc_pending;
60+
u64 cc_sector;
6161
union {
6262
struct skcipher_request *req;
6363
struct aead_request *req_aead;

drivers/md/dm-verity.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ struct dm_verity_io {
8080
/* original value of bio->bi_end_io */
8181
bio_end_io_t *orig_bi_end_io;
8282

83+
struct bvec_iter iter;
84+
8385
sector_t block;
8486
unsigned int n_blocks;
8587
bool in_tasklet;
8688

87-
struct bvec_iter iter;
88-
8989
struct work_struct work;
9090

9191
char *recheck_buffer;

0 commit comments

Comments
 (0)