[DRBD-user] DRBD - on ARM (armel)

Philipp Reisner philipp.reisner at linbit.com
Tue Jun 16 10:47:13 CEST 2009

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


On Monday 15 June 2009 23:21:51 you wrote:
> Hi,
>
> With the latest patch, things are not working very well at all!
>
>
> It think the problem may lie here:
>
>
> #define put_unaligned(val, ptr) ({                    \
> +    typeof(val) v;                            \
> +    switch (sizeof(*(ptr))) {                    \
> +    case 1:                                \
> +        *(uint8_t *)(ptr) = (uint8_t)(val);            \
> +        break;                            \
> +    case 2:                                \
> +    case 4:                                \
> +    case 8:                                \
> +        v = val;                        \
> +        memcpy(ptr, &v, sizeof(*(ptr)));            \
> +        break;                            \
> +    default:                            \
> +        __bad_unaligned_access_size();                \
> +        break;                            \
> +    }                                \
> +    (void)0; })
> +
>
>
> When called with
>
> put_unaligned(tag, tl->tag_list_cpos++);
>
> ptr is evaluated in the switch statement, and twice in the memcpy call,
> and hence the post-increment will be done three times ....not what we want!
>
> Maybe an inline function, or taking a copy of ptr if safer here
>

Hi Nick,

No, typeof(), sizeof() do not evaluate the expression at runtime. They
just deliver the type or the size at compile time. But in that macro 
there was an error with the type conversation.

I have again, attached a patch, that should fix the issue. Please verify.

-- 
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_for_unaligned_access3.diff
Type: text/x-patch
Size: 1377 bytes
Desc: not available
URL: <http://lists.linbit.com/pipermail/drbd-user/attachments/20090616/6d468865/attachment.bin>


More information about the drbd-user mailing list