* [Drbd-dev] Re: DRBD IOCTLs nicht 64bit clean...
[not found] ` <NPUp4T3Ya1hNzMAxjFRXf0M=lge@web.de>
@ 2004-10-20 10:39 ` Philipp Reisner
2004-10-20 14:22 ` Lars Ellenberg
0 siblings, 1 reply; 3+ messages in thread
From: Philipp Reisner @ 2004-10-20 10:39 UTC (permalink / raw)
To: Lars Ellenberg; +Cc: drbd-dev
On Monday 18 October 2004 19:19, you wrote:
> / 2004-10-18 18:41:00 +0200
>
> \ Lars Ellenberg:
> > na dann, ran...
> > es ind ja nicht mehr viele.
> > gnaugenommen nur eben dieser.
> > alle anderen benutzen doch sowieso structs, und die sind doch sowieso
> > all u32/u64, oder täusch ich mich da jetzt?
>
> hm.
> eigentlich ist doch ein "int" immer 32 bit gross,
> auch auf einer 64 bit box. interessant sind also nur pointer und longs.
>
> und enums, wenn da der basistyp nicht klar ist.
[...]
You are 100% right:
phil@mescal:~/src/drbd07/testing$ file ./ioctl_structs_sizes
./ioctl_structs_sizes: ELF 32-bit LSB executable, Intel 80386, version 1
(SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not
stripped
phil@mescal:~/src/drbd07/testing$ ./ioctl_structs_sizes
sizeof(struct disk_config) = 24
sizeof(struct net_config) = 300
sizeof(struct syncer_config) = 20
sizeof(struct ioctl_disk_config) = 28
sizeof(struct ioctl_net_config) = 304
sizeof(struct ioctl_syncer_config) = 24
sizeof(struct ioctl_wait) = 12
sizeof(struct ioctl_get_config) = 428
sum = 1140 DRBD_07_SUM = 1140
OKAY
[root@ra2:/usr/src/drbd-0.7.5/testing]# file ./ioctl_structs_sizes
./ioctl_structs_sizes: ELF 64-bit LSB executable, AMD x86-64, version 1
(SYSV), dynamically linked (uses shared libs), not stripped
[root@ra2:/usr/src/drbd-0.7.5/testing]# ./ioctl_structs_sizes
sizeof(struct disk_config) = 32
sizeof(struct net_config) = 300
sizeof(struct syncer_config) = 20
sizeof(struct ioctl_disk_config) = 40
sizeof(struct ioctl_net_config) = 304
sizeof(struct ioctl_syncer_config) = 24
sizeof(struct ioctl_wait) = 12
sizeof(struct ioctl_get_config) = 432
sum = 1164 DRBD_07_SUM = 1140
FAILED
Dann alle Structs mit __attribute__((packed)) versehen:
[root@ra2:/usr/src/drbd-0.7.5/testing]# file ./ioctl_structs_sizes
./ioctl_structs_sizes: ELF 64-bit LSB executable, AMD x86-64, version 1
(SYSV), dynamically linked (uses shared libs), not stripped
[root@ra2:/usr/src/drbd-0.7.5/testing]# ./ioctl_structs_sizes
sizeof(struct disk_config) = 24
sizeof(struct net_config) = 300
sizeof(struct syncer_config) = 20
sizeof(struct ioctl_disk_config) = 28
sizeof(struct ioctl_net_config) = 304
sizeof(struct ioctl_syncer_config) = 24
sizeof(struct ioctl_wait) = 12
sizeof(struct ioctl_get_config) = 428
sum = 1140 DRBD_07_SUM = 1140
OKAY
I have not yet decided if I will do the reordering of the
members as well and increase the API version,
OR,
leave the members in this order and no change to the API
version number .... This would be more conventient for our
i386 users, but plain frong for the users of 64bit archs...
-Philipp
--
: Dipl-Ing Philipp Reisner Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austria http://www.linbit.com :
^ permalink raw reply [flat|nested] 3+ messages in thread* [Drbd-dev] Re: DRBD IOCTLs nicht 64bit clean...
2004-10-20 10:39 ` [Drbd-dev] Re: DRBD IOCTLs nicht 64bit clean Philipp Reisner
@ 2004-10-20 14:22 ` Lars Ellenberg
0 siblings, 0 replies; 3+ messages in thread
From: Lars Ellenberg @ 2004-10-20 14:22 UTC (permalink / raw)
To: drbd-dev
/ 2004-10-20 12:39:55 +0200
\ Philipp Reisner:
> I have not yet decided if I will do the reordering of the
> members as well and increase the API version,
>
> OR,
>
> leave the members in this order and no change to the API
> version number .... This would be more conventient for our
> i386 users, but plain frong for the users of 64bit archs...
please rather do it right, than have __u64 odd-aligned.
an while we are at it, use a unified prefix ioctl struct,
which includes the api version, device id and result fields,
and only then the specific data. halfes our ioctls, since the api
version now can be verified with each ioctl, and has other advantages
as well...
lge
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Drbd-dev] Re: DRBD IOCTLs nicht 64bit clean...
[not found] ` <n/0nVbG2W2wQDG4jMwN41Pc=lge@web.de>
[not found] ` <NPUp4T3Ya1hNzMAxjFRXf0M=lge@web.de>
@ 2004-10-20 23:26 ` Lars Ellenberg
1 sibling, 0 replies; 3+ messages in thread
From: Lars Ellenberg @ 2004-10-20 23:26 UTC (permalink / raw)
To: drbd-dev
resent to the list just so this is in the archives, too.
lge
/ 2004-10-18 18:41:00 +0200
\ Lars Ellenberg:
> na dann, ran...
> es ind ja nicht mehr viele.
> gnaugenommen nur eben dieser.
> alle anderen benutzen doch sowieso structs, und die sind doch sowieso
> all u32/u64, oder täusch ich mich da jetzt?
hm.
eigentlich ist doch ein "int" immer 32 bit gross,
auch auf einer 64 bit box. interessant sind also nur pointer und longs.
und enums, wenn da der basistyp nicht klar ist.
#define DRBD_IOCTL_GET_VERSION _IOR( DRBD_IOCTL_LETTER, 0x00, int )
hat bisher immer funktioniert.
wenn kernel_int == userspace_int == 32bit, sollte das auch immer so sein.
#define DRBD_IOCTL_SET_STATE _IOW( DRBD_IOCTL_LETTER, 0x02, Drbd_State )
enum, allerdings nur kleine werte.
falls basistyp "long" ist, und long einmal 64, einmal 32 hat,
könnte das obere "wort" ignoriert werden... muss man mal nachlesen.
#define DRBD_IOCTL_SET_DISK_CONFIG _IOW( DRBD_IOCTL_LETTER, 0x06, struct ioctl_disk_config )
struct disk_config {
IN int lower_device;
IN __u64 disk_size;
IN enum io_error_handler on_io_error;
IN int meta_device;
IN int meta_index;
};
likely alignment problems...
ich neheme jetzt mal an, dass enums basistyp int sind, und dass ints
immer 32bit sind. dann sollte entweder __packed__ dabei stehen,
oder besser:
struct disk_config {
IN __u64 disk_size;
IN enum io_error_handler on_io_error;
IN int lower_device;
IN int meta_device;
IN int meta_index;
};
#define DRBD_IOCTL_SET_NET_CONFIG _IOW( DRBD_IOCTL_LETTER, 0x07, struct ioctl_net_config )
struct net_config {
#define MAX_SOCK_ADDR 128 /* 108 for Unix domain -
16 for IP, 16 for IPX,
24 for IPv6,
about 80 for AX.25
must be at least one bigger than
the AF_UNIX size (see net/unix/af_unix.c
:unix_mkname()).
*/
IN char my_addr[MAX_SOCK_ADDR];
IN int my_addr_len;
==> alignment problem <<==
IN char other_addr[MAX_SOCK_ADDR];
IN int other_addr_len;
IN int timeout; // deci seconds
IN int wire_protocol;
IN int try_connect_int; /* seconds */
IN int ping_int; /* seconds */
IN int max_epoch_size;
IN int max_buffers;
IN int sndbuf_size; /* socket send buffer size */
IN unsigned int ko_count;
IN enum disconnect_handler on_disconnect;
};
#define DRBD_IOCTL_UNCONFIG_NET _IO ( DRBD_IOCTL_LETTER, 0x08 )
egal
#define DRBD_IOCTL_GET_CONFIG _IOW( DRBD_IOCTL_LETTER, 0x0A, struct ioctl_get_config )
möglicherweise schlecht aligned, bin jetzt zu faul genau zu schauen ...
#define DRBD_IOCTL_INVALIDATE _IO ( DRBD_IOCTL_LETTER, 0x0D )
#define DRBD_IOCTL_INVALIDATE_REM _IO ( DRBD_IOCTL_LETTER, 0x0E )
egal
#define DRBD_IOCTL_SET_SYNC_CONFIG _IOW( DRBD_IOCTL_LETTER, 0x0F, struct ioctl_syncer_config )
struct syncer_config {
int rate; /* KB/sec */
int use_csums; /* use checksum based syncing*/
int skip;
int group;
int al_extents;
};
sollte passen. evtl. alignment problem in zusammen gesetzten
structs wie get_config...
#define DRBD_IOCTL_SET_DISK_SIZE _IOW( DRBD_IOCTL_LETTER, 0x10, unsigned int )
sollte passen, aber lieber explizit __u32
#define DRBD_IOCTL_WAIT_CONNECT _IOR( DRBD_IOCTL_LETTER, 0x11, struct ioctl_wait )
#define DRBD_IOCTL_WAIT_SYNC _IOR( DRBD_IOCTL_LETTER, 0x12, struct ioctl_wait )
struct ioctl_wait {
IN int wfc_timeout;
IN int degr_wfc_timeout;
OUT int ret_code;
};
sollte passen. evtl. alignment problem in zusammen gesetzten
structs wie get_config...
#define DRBD_IOCTL_UNCONFIG_DISK _IO ( DRBD_IOCTL_LETTER, 0x13 )
egal
#define DRBD_IOCTL_SET_STATE_FLAGS _IOW( DRBD_IOCTL_LETTER, 0x14, Drbd_State )
enum. siehe SET_STATE
^ permalink raw reply [flat|nested] 3+ messages in thread