Re: include/linux/compiler_types.h:631:38: error: call to '__compiletime_assert_431' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)

From: Finn Thain

Date: Tue Mar 03 2026 - 17:15:42 EST



On Tue, 3 Mar 2026, Arnd Bergmann wrote:

>
> As far as I can tell, the assertion is always true on all architectures
> other than m68k because "struct rsp_que *rsp" is word-aligned and
> "struct atio_from_isp atio" is either 64 bytes long. The intention of
> the assertion is to ensure that nothing got added after atio, though the
> way it is written does not take misaligned atio into account.
>

Hardly an m68k issue. The same thing could happen on any 32-bit
architecture under slightly different circumstances. (Nevermind
Linux/CRIS, would would be affected in the same way as m68k is.)

No, the real problem is the assertion itself, which is a failed attempt to
state that no struct element follows 'atio'. It isn't about alignment or
padding and yet the assertion is written in terms of sizeof(). Go figure.

It is about the non-existance of an non-entity. That is, something with no
name. I don't know how to express that in C. It may require the help of a
fancy compiler.

> > I suppose the assertion could be motivated by some code elsewhere but
> > I haven't yet found it. So perhaps the assertion can simply be
> > removed. An alternative solution could be to increase the 1 byte hole
> > to 3 bytes, and prevent tail padding that way.
>
> The simplest way would be to force atio itself to be aligned regardless
> of the architecture, either by removing the __packed attribute on the
> struct nack_from_isp definition, or by adding alignment on the variable:
>
> --- a/drivers/scsi/qla2xxx/qla_target.h
> +++ b/drivers/scsi/qla2xxx/qla_target.h
> @@ -844,7 +844,7 @@ struct qla_tgt_sess_op {
> bool aborted;
> struct rsp_que *rsp;
>
> - struct atio_from_isp atio;
> + struct atio_from_isp atio __aligned(8);
> /* DO NOT ADD ANYTHING ELSE HERE - atio must be last member */
> };
>

I'm fine with that, but I'd add a comment like the one I pointed to in my
previous message, which explains some gratuitous struct padding added to
satisfy a BUILD_BUG_ON assertion.

> In general, the use of __packed attributes in this file seems a bit
> inconsistent, with outer structures being packed but containing aligned
> inner structures like atio_from_isp and nack_to_isp. It may be best to
> review all of them and remove as much as possible, but that's not
> necessary as a bug fix here.
>

I'm fine with that suggestion too. Thanks for your assistance, Arnd.

Nilesh, let me know if you'd prefer a patch to change the struct padding
or packing, or something else.