Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.
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
Nick
Philipp Reisner wrote:
> [...]
>
>> I see you have removed the (short*) cast.... I am not sure if it is
>> necessary, but I though it might be helpful on big-endian platforms,
>> where hopefully the compiler would take the pointer to the
>> least-significant word???
>>
>
> You are right. But you missed that I have changed the type of
> the variable where it is declared, so no more cast necessary.
>
>
>> As mentioned in my previous mail, all seems to be work fine. I have run
>> the tests you asked, and it seems everything is not quite perfect, but
>> perhaps good enough for me at the moment. I would be happy to test any
>> further fixes, however.
>>
> [...]
>
>> device minor 0;
>> disk "/dev/sda7";
>> meta-disk internal;
>> }
>> # (5376) unknown tag = (integer) 8402432 [len: 384]
>> # Found unknown tags, you should update your
>> # userland tools
>>
>>
>
> Right. I realised myself that I missed the "show" part of drbdsetup
> some when on the weekend.
>
> Attached is a second patch, that should also fix the "show" command
> and its relatives.
>
> BTW, Into which embedded product are you integrating DRBD ?
>
> cheers,
> Phil
>