public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "Elliott, Robert (Server Storage)" <Elliott@hp.com>,
	"James Bottomley (jbottomley@parallels.com)"
	<jbottomley@parallels.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"Don Brace (PMC)" <Don.Brace@pmcs.com>,
	"Scales, Webb" <webb.scales@hp.com>
Subject: Re: Concurrent SG_SCSI_RESET ioctls
Date: Fri, 24 Oct 2014 18:29:33 +0200	[thread overview]
Message-ID: <544A7E6D.5070908@interlog.com> (raw)
In-Reply-To: <20141024145131.GA2940@infradead.org>

On 14-10-24 04:51 PM, Christoph Hellwig wrote:
> On Tue, Oct 14, 2014 at 12:42:26PM -0400, Douglas Gilbert wrote:
>> I don't mind if you change it. However I plan to release
>> sg3_utils-1.40 in the next 2 or 3 weeks, so that would
>> be the earliest a revised sg_reset would be available for
>> distros. Improving error reports is something I always
>> like to do (so ENODEV for the "in progress" case seems a
>> bit strident).
>
> Doug, are you fine with changing the error code to EAGAIN
> similar to what we get elsewhere when a O_NONBLOCK open
> would have to block?  If that's something you can prepare
> sg3_utils for I'd like to send a patch for it for the 3.19 merge
> window.

Yes, that's fine.

Just expanded the sg_reset ioctl erorr processing to this:

     switch (errno) {
     case EBUSY:
         fprintf(stderr, ME "BUSY, may be resetting now\n");
         break;
     case ENODEV:
         fprintf(stderr, ME "'no device' error, may be temporary while "
                 "device is resetting\n");
         break;
     case EAGAIN:
         fprintf(stderr, ME "try again later, may be resetting now\n");
         break;
     case EIO:
         fprintf(stderr, ME "reset (for value=0x%x) may not be "
                 "available\n", k);
         break;
     case EPERM:
     case EACCES:
         fprintf(stderr, ME "reset requires CAP_SYS_ADMIN (root) "
                 "permission\n");
         break;
     case EINVAL:
         fprintf(stderr, ME "SG_SCSI_RESET not supported (for "
                 "value=0x%x)\n", k);
     default:
         perror(ME "SG_SCSI_RESET failed");
         break;
     }

The ENODEV, EAGAIN and EPERM entries are new. In the sg_reset
implementation currently in the field they will drop down to
the default case and do a perror().

With the ioctl(SG_IO), it is sufficient to give a user permissions
on the device node (e.g. 'chmod 666 /dev/sg2; sg_turs /dev/sg2')
to pass through a command. However with ioctl(SG_SCSI_RESET),
another check is done by the ioctl and if it fails then it yields
EACCES .


Doug Gilbert



  reply	other threads:[~2014-10-24 16:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 23:32 Concurrent SG_SCSI_RESET ioctls Elliott, Robert (Server Storage)
2014-10-11 11:05 ` Christoph Hellwig
2014-10-11 16:11 ` Christoph Hellwig
2014-10-11 22:06   ` Elliott, Robert (Server Storage)
2014-10-14 11:13     ` Christoph Hellwig
2014-10-14 16:42       ` Douglas Gilbert
2014-10-15 13:25         ` Christoph Hellwig
2014-10-15 14:34           ` Elliott, Robert (Server Storage)
2014-10-24 14:51         ` Christoph Hellwig
2014-10-24 16:29           ` Douglas Gilbert [this message]
2014-10-11 23:04   ` Elliott, Robert (Server Storage)
2014-10-13  9:15   ` Bart Van Assche
2014-10-13 10:23     ` Christoph Hellwig

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=544A7E6D.5070908@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=Don.Brace@pmcs.com \
    --cc=Elliott@hp.com \
    --cc=hch@infradead.org \
    --cc=jbottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=webb.scales@hp.com \
    /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