Skip to content

Commit 6b1d9e1

Browse files
jthornbergregkh
authored andcommitted
dm persistent data: packed struct should have an aligned() attribute too
commit a88b2358f1da2c9f9fcc432f2e0a79617fea397c upstream. Otherwise most non-x86 architectures (e.g. riscv, arm) will resort to byte-by-byte access. Cc: [email protected] Signed-off-by: Joe Thornber <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 82d706f commit 6b1d9e1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/md/persistent-data/dm-btree-internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ struct node_header {
3434
__le32 max_entries;
3535
__le32 value_size;
3636
__le32 padding;
37-
} __packed;
37+
} __attribute__((packed, aligned(8)));
3838

3939
struct btree_node {
4040
struct node_header header;
4141
__le64 keys[0];
42-
} __packed;
42+
} __attribute__((packed, aligned(8)));
4343

4444

4545
/*

drivers/md/persistent-data/dm-space-map-common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct disk_index_entry {
3333
__le64 blocknr;
3434
__le32 nr_free;
3535
__le32 none_free_before;
36-
} __packed;
36+
} __attribute__ ((packed, aligned(8)));
3737

3838

3939
#define MAX_METADATA_BITMAPS 255
@@ -43,7 +43,7 @@ struct disk_metadata_index {
4343
__le64 blocknr;
4444

4545
struct disk_index_entry index[MAX_METADATA_BITMAPS];
46-
} __packed;
46+
} __attribute__ ((packed, aligned(8)));
4747

4848
struct ll_disk;
4949

@@ -86,15 +86,15 @@ struct disk_sm_root {
8686
__le64 nr_allocated;
8787
__le64 bitmap_root;
8888
__le64 ref_count_root;
89-
} __packed;
89+
} __attribute__ ((packed, aligned(8)));
9090

9191
#define ENTRIES_PER_BYTE 4
9292

9393
struct disk_bitmap_header {
9494
__le32 csum;
9595
__le32 not_used;
9696
__le64 blocknr;
97-
} __packed;
97+
} __attribute__ ((packed, aligned(8)));
9898

9999
enum allocation_event {
100100
SM_NONE,

0 commit comments

Comments
 (0)