From: Hans de Goede <hdegoede@redhat.com>
To: Greg KH <greg@kroah.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
USB list <linux-usb@vger.kernel.org>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: RFC: Add USBDEVFS_TRY_DISCONNECT ioctl
Date: Wed, 24 Aug 2011 23:04:03 +0200 [thread overview]
Message-ID: <4E556743.4000106@redhat.com> (raw)
In-Reply-To: <20110824204533.GA19618@kroah.com>
Hi,
First of all: A big thanks to Alan for working on this. From my POV
the code looks good, but I'm only familiar with the usb parts
and not with the scsi parts.
One generic concern is the use of scsi_lock(host) in the
scsi_device_open / close callbacks. We need to be sure non
of the callers of these can already be holding the lock.
On 08/24/2011 10:45 PM, Greg KH wrote:
> On Wed, Aug 24, 2011 at 04:32:31PM -0400, Alan Stern wrote:
>> Okay, here's a sample patch. Actually it's three patches, listed one
>> after another, but people can apply it like a single patch.
>>
>> 1. Introduce the USBDEVFS_TRY_DISCONNECT ioctl and the check_busy
>> callback it uses. Implement the callback in the usbfs driver;
>> this gives a way for programs to unbind kernel drivers without
>> unbinding other userspace drivers.
>>
>> 2. Implement device-file reference tracking in the SCSI layer,
>> and the device_open and device_close callbacks it uses.
>
> Does this handle if the filesystem is being created or fscked, as it's
> not mounted at that time.
>
>> @@ -1647,9 +1653,16 @@ static int proc_ioctl(struct dev_state *
>> else switch (ctl->ioctl_code) {
>>
>> /* disconnect kernel driver from interface */
>> + case USBDEVFS_TRY_DISCONNECT:
>> case USBDEVFS_DISCONNECT:
>> if (intf->dev.driver) {
>> driver = to_usb_driver(intf->dev.driver);
>> + if (ctl->ioctl_code == USBDEVFS_TRY_DISCONNECT&&
>> + driver->check_busy) {
>> + retval = driver->check_busy(intf);
>> + if (retval)
>> + break;
>> + }
>
> I don't like the fact that if a driver doesn't contain check_busy() then
> it will automatically fall back to looking like it was a DISCONNECT
> call, which could give userspace a false sense of "everything was fine"
> when trying this out.
I've to agree with Greg here, what to do in case of a driver not
implementing check_busy and thus not really offering USBDEVFS_TRY_DISCONNECT
is policy and thus should be left to userspace. I suggest we just return
-ENOTTY in case of USBDEVFS_TRY_DISCONNECT and the bound driver does not
have checkbusy, then userspace can decide wether to fallback to a regular
disconnect, or to give up.
Regards,
Hans
next prev parent reply other threads:[~2011-08-24 21:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20110821164108.GC6229@kroah.com>
2011-08-24 20:32 ` RFC: Add USBDEVFS_TRY_DISCONNECT ioctl Alan Stern
2011-08-24 20:45 ` Greg KH
2011-08-24 21:04 ` Hans de Goede [this message]
2011-08-24 21:23 ` Alan Stern
2011-08-24 21:18 ` Alan Stern
2011-08-24 21:34 ` Greg KH
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=4E556743.4000106@redhat.com \
--to=hdegoede@redhat.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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