linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: dougg@torque.net
Cc: andrew.patterson@hp.com, Luben Tuikov <luben_tuikov@adaptec.com>,
	Christoph Hellwig <hch@lst.de>,
	"Moore, Eric Dean" <Eric.Moore@lsil.com>,
	jejb@steeleye.com, linux-scsi@vger.kernel.org,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@osdl.org>
Subject: Re: ioctls, etc. (was Re: [PATCH 1/4] sas: add flag for locally attached PHYs)
Date: Fri, 21 Oct 2005 02:19:40 -0400	[thread overview]
Message-ID: <4358887C.6020200@pobox.com> (raw)
In-Reply-To: <43587F74.6080600@torque.net>

Douglas Gilbert wrote:
> ioctls represent the most direct, unimpeded (by OS
> policy) route between the user space and a driver,
> potentially a few levels down a driver stack.

With the inevitable result that most ioctl code is poorly written, and 
causes bugs and special case synchronization problems :)  Driver writers 
love to stuff way too much stuff into ioctls, without thinking about 
overall design.


> I see it as a control issue, in one corner there are
> Microsoft and Linux while in the other there are
> the hardware vendors. OS vendors come out with
> ioctl replacements but can't resist enforcing policy.
> 
> As for type safety in linux, I stopped taking that
> seriously when practicality of having C++ code
> in the kernel was killed by "struct class".

C++ was never ever meant to work with the kernel.


>>>Yes, CSMI should have had more Linux input when it was developed.  The
>>>no-new IOCTL policy certainly came as a surprise to the authors. Still,
>>>there doesn't seem to be any other usable cross-platform interface that
>>>is acceptable to the linux community (or at least to Christoph)'s corner
>>
>>
>>Beyond Linus's rant, ioctls have a practical limitation, too:  because
>>they are untyped, we have to deal with stuff like the 32<->64 compat
>>ioctl thunking.
> 
> 
> Do you know where there are some clear guidelines
> on the use of pointers in a structure passed to an
> ioctl to lessen (or bypass) 32<->64 compat ioctl
> thunking?

Its impossible.  If you pass pointers, you need to thunk.  (Not even 
passing pointers via sysfs can avoid this.)  Consider running a 32-bit 
app (with 32-bit pointers and 32-bit ABI) on a 64-bit kernel.


>>Consider what an ioctl is, overall:  a domain-specific "do this
>>operation" interface.  Which, further, is nothing but a wrapping of a
>>"send message" + "receive response" interface.  There are several ways
>>to do this in Linux:
>>
>>* block driver.  a block driver is nothing but a message queue.  This is
>>why James has suggested implementing SMP as a block driver.  People get
>>stuck into thinking "block driver == block device", which is wrong.  The
>>Linux block layer is nothing but a message queueing interface.
>>
>>* netlink.  You connect to <an object> and send/receive messages.  Not
>>strictly limited to networking, as this is used in some areas of the
>>kernel now for generic event delivery.
>>
>>* char driver.  Poor man's netlink.  Unless its done right, it suffers
>>from the same binary problems as ioctls.  I don't recommend this path.
>>
>>* sysfs.  This has no inherent message/queue properties by itself, and
>>is less structured than blockdrvr or netlink, so dealing with more than
>>one outstanding operation at a time requires some coding.
>>
>>sysfs's attractiveness is in its ease of use.  It works with standard
>>Unix filesystem tools.  You don't need to use a library to read
>>information, cat(1) often suffices.  sysfs, since its normal ASCII
>>(UTF8), also has none of the annoying 32<->64 compatibility issues that
>>ioctls suffer from.
> 
> 
> ... and on the other side for sysfs are the loss of
> layered error reporting,

Only for the most simple interfaces.  sysfs is for exporting kernel data 
structures to userspace, using read(2) and write(2).  You can quite 
literally accomplish anything with that.  sysfs could export an event 
directory entry, and a response directory entry.  The response dirent 
could provide all the error reporting you could ever want.  That's just 
a 2-second off-the-cuff example.


> inability to supply auxiliary
> attributes such as a request timeout and the possibility
> that write()s will either be limited in size or segmented.

This entirely depends on the interface you define.  These problems are 
all surmountable.

Note, I'm _not_ suggesting this is the best route for an SMP interface, 
just stating sysfs generalities.  sysfs is flexible enough that it could 
completely replace SG_IO (though that would not be a wise idea).

	Jeff



  reply	other threads:[~2005-10-21  6:20 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-20 15:25 [PATCH 1/4] sas: add flag for locally attached PHYs Moore, Eric Dean
2005-10-20 15:55 ` Luben Tuikov
2005-10-20 16:01 ` Christoph Hellwig
2005-10-20 16:51   ` Luben Tuikov
2005-10-20 17:03     ` Christoph Hellwig
2005-10-20 17:22       ` Arjan van de Ven
2005-10-20 20:10         ` Luben Tuikov
2005-10-21  8:16           ` Arjan van de Ven
2005-10-20 20:02       ` Luben Tuikov
2005-10-21  0:01         ` Andrew Patterson
2005-10-21  0:46           ` ioctls, etc. (was Re: [PATCH 1/4] sas: add flag for locally attached PHYs) Jeff Garzik
2005-10-21  5:09             ` Mike Christie
2005-10-21  5:41             ` Douglas Gilbert
2005-10-21  6:19               ` Jeff Garzik [this message]
2005-10-21 18:37                 ` Luben Tuikov
2005-10-21 17:48             ` Luben Tuikov
2005-10-21 18:04               ` Christoph Hellwig
2005-10-21 18:12                 ` Luben Tuikov
2005-10-21 18:20                   ` Matthew Wilcox
2005-10-22  2:30                     ` Douglas Gilbert
2005-10-22  2:54                       ` Jeff Garzik
2005-10-22  3:53                         ` Jeff Garzik
2005-10-22 17:14                           ` Luben Tuikov
2005-10-22 17:49                             ` Francois Romieu
2005-10-22 16:51                         ` Luben Tuikov
2005-10-21 18:18               ` Jeff Garzik
2005-10-21 18:50                 ` Luben Tuikov
2005-10-21 18:54                   ` Jeff Garzik
2005-10-21 19:13                     ` Luben Tuikov
2005-10-21 19:23                       ` Jeff Garzik
2005-10-21 22:20                         ` Stefan Richter
2005-10-21 19:22                     ` Luben Tuikov
2005-10-21 19:39                       ` Jeff Garzik
2005-10-21 20:41                         ` Luben Tuikov
2005-10-21 21:12                           ` Jeff Garzik
2005-10-21 21:24                             ` Luben Tuikov
2005-10-21 21:41                               ` Jeff Garzik
2005-10-21 22:14                                 ` Luben Tuikov
2005-10-21 22:43                                   ` Jeff Garzik
2005-10-22  9:26                                     ` Stefan Richter
2005-10-22 17:23                                       ` Luben Tuikov
2005-10-22 10:42                                     ` Stefan Richter
2005-10-22 10:58                                       ` Christoph Hellwig
2005-10-22 15:28                                         ` Sergey Panov
2005-10-22 17:19                                           ` Christoph Hellwig
2005-10-22 17:38                                             ` Sergey Panov
2005-10-24 15:18                                               ` Luben Tuikov
2005-10-22 18:27                                             ` Alan Cox
2005-10-24 13:51                                             ` Luben Tuikov
2005-10-24 15:41                                               ` Alan Cox
2005-10-24 15:14                                                 ` Luben Tuikov
2005-10-24 16:03                                                   ` Regala
2005-10-24 16:13                                                     ` Luben Tuikov
2005-10-24 16:04                                                   ` Regala
2005-10-22 17:30                                         ` Luben Tuikov
2005-10-22 18:19                                           ` Jeff Garzik
2005-10-22 17:49                                         ` Stefan Richter
2005-10-24 22:09                                           ` ioctls, etc. (was Re: [PATCH 1/4] sas: add flag for locally attachedPHYs) David Lang
2005-10-24 23:09                                             ` Stefan Richter
2005-10-22 11:12                                       ` David Lang
2005-10-22 17:39                                         ` Luben Tuikov
2005-10-22 17:41                                         ` Stefan Richter
2005-10-22 17:51                                           ` Christoph Hellwig
2005-10-22 18:21                                             ` Stefan Richter
2005-10-22 18:39                                             ` Sergey Panov
2005-10-22 13:27                                       ` ioctls, etc. (was Re: [PATCH 1/4] sas: add flag for locally attached PHYs) Stefan Richter
2005-10-22 16:09                                     ` Luben Tuikov
2005-10-21 19:41                       ` Matthew Wilcox
2005-10-21 19:48                         ` Luben Tuikov
2005-10-21 19:54                           ` Matthew Wilcox
2005-10-21 20:05                             ` Luben Tuikov
2005-10-21 19:46                       ` Arjan van de Ven
2005-10-21 19:50                         ` Luben Tuikov
2005-10-21  9:06           ` [PATCH 1/4] sas: add flag for locally attached PHYs Arjan van de Ven
2005-10-21 17:05             ` Andrew Patterson
2005-10-21 17:18               ` Arjan van de Ven
2005-10-21 18:57               ` Luben Tuikov
2005-10-21 17:32           ` Luben Tuikov
2005-10-21  1:50 ` Douglas Gilbert
2005-10-21  2:16   ` Jeff Garzik
2005-10-21  3:25     ` Douglas Gilbert
2005-10-21 18:04   ` Luben Tuikov
  -- strict thread matches above, loose matches on Subject: below --
2005-10-21 20:31 ioctls, etc. (was Re: [PATCH 1/4] sas: add flag for locally attached PHYs) Salyzyn, Mark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4358887C.6020200@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=Eric.Moore@lsil.com \
    --cc=andrew.patterson@hp.com \
    --cc=dougg@torque.net \
    --cc=hch@lst.de \
    --cc=jejb@steeleye.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luben_tuikov@adaptec.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).