Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cleaning/cleaning.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct ocf_request;

struct cleaning_policy_config {
uint8_t data[CLEANING_POLICY_CONFIG_BYTES];
};
} __attribute__((aligned(4)));

struct cleaning_policy {
union {
Expand Down
2 changes: 1 addition & 1 deletion src/prefetch/ocf_prefetch_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

struct prefetch_policy_config {
uint8_t data[PREFETCH_POLICY_CONFIG_BYTES];
};
} __attribute__((aligned(4)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it complain about other config structures (cleaning/promotion)? They are constructed and embedded into superblock exactly the same way, so their potential alignment is at best coincidental.

@rafalste rafalste Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem of misalignment stems from the size of prefetch_mask which prepends prefetch[] field in the struct ocf_superblock_config.
Before the config structures for cleaning and promotion, there are cleaning/promotion_policy_type fields, which are enums and thus have a size of 4 bytes, so the next config struct is properly aligned to 4 bytes as well.
But before the prefetch config structure, there is a prefetch_mask field, which is uint8_t and 1 byte in size and the next struct is placed right after it.
That matches with the UBSan output, which shows exactly one byte shift.

Nevertheless, I've added proper alignment to cleaning and promotion config structs as well to make it more robust in case of any future changes to the field placements.


#define OCF_PF_ID_VALID(pf_id) ((pf_id) != ocf_pf_none && (pf_id) < ocf_pf_num)
#define OCF_PF_ID_ENABLED(pf_id, enabled_mask) ((1 << ((pf_id))) & enabled_mask)
Expand Down
2 changes: 1 addition & 1 deletion src/promotion/promotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

struct promotion_policy_config {
uint8_t data[PROMOTION_POLICY_CONFIG_BYTES];
};
} __attribute__((aligned(4)));

typedef struct ocf_promotion_policy *ocf_promotion_policy_t;

Expand Down
Loading