Skip to contentSkip to conversation

"Enhanced" MD code avaible for review

DISCUSSION Andi Kleen 3 participants 3 messages Mar 18, 2004 – Mar 20, 2004 2 messages not in the archive MD RAID

lore
Share & tools
lore

Andi Kleen

author
#2 lore raw
In reply to a message not in the archive
Quoted 6 lines · Jeff Garzik

ioctl's are a pain for 32->64-bit translation layers. Using a read/write interface allows one to create an interface that requires no translation layer -- a big deal for AMD64 and IA32e processors moving forward -- and it also gives one a lot more control over the interface.

Sorry, Jeff, but that's just not true. While ioctls need an additional entry in the conversion table, they can at least easily get an translation handler if needed. When they are correctly designed you just need a single line to enable pass through the emulation. If you don't want to add that line to the generic compat_ioctl.h file you can also do it in your driver.

read/write has the big disadvantage that if someone gets the emulation wrong (and that happens regularly) it is near impossible to add an emulation handler then, because there is no good way to hook into the read/write paths.

There may be valid reasons to go for read/write, but 32bit emulation is not one of them. In fact from the emulation perspective read/write should be avoided.

-Andi

#3 lore raw
Quoted 7 lines · Andi Kleen

Sorry, Jeff, but that's just not true. While ioctls need an additional entry in the conversion table, they can at least easily get an translation handler if needed. When they are correctly designed you just need a single line to enable pass through the emulation. If you don't want to add that line to the generic compat_ioctl.h file you can also do it in your driver.

Quoted 7 lines

read/write has the big disadvantage that if someone gets the emulation
wrong (and that happens regularly) it is near impossible to add an emulation handler then, because there is no good way to hook into the read/write paths.

There may be valid reasons to go for read/write, but 32bit emulation is not one of them. In fact from the emulation perspective read/write should be avoided.

I'll probably have to illustrate with code, but basically, read/write can be completely ignorant of 32/64-bit architecture, endianness, it can even be network-transparent. ioctls just can't do that.

Jeff

#4 lore raw
Quoted 3 lines · Jeff Garzik

I'll probably have to illustrate with code, but basically, read/write can be completely ignorant of 32/64-bit architecture, endianness, it can even be network-transparent. ioctls just can't do that.

Apart from the network transparency, yes they can.

Ioctl is no different from read/write/read-modify-write except the additional command argument.

You can write architecture-specific ioctls which take and return structs -- and you can do the same with read/write. This is what Andi is thinking of as dangerous: the read/write case is then much harder to emulate.

Or, you can write architecture-independent read/write, which use fixed formats, which you seem to have in mind. That works fine with ioctls too.

It isn't commonly done, because people prefer the convenience of a struct. But it does work. It's slightly easier in the driver to implement commands this way using an ioctl, because you don't have to check the read/write length. It's about the same to use from
userspace: both read/write and ioctl methods using an architecture-independent data format require the program to lay out the command bytes and then issue one system call.

-- Jamie