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: "SCSI development list" <linux-scsi@vger.kernel.org>,
	"Dan Horák" <dhorak@redhat.com>
Subject: Re: SYNCHRONIZE CACHE command from sd on close
Date: Fri, 19 Feb 2010 01:20:25 +0100	[thread overview]
Message-ID: <4B7DD949.3010907@interlog.com> (raw)
In-Reply-To: <20100215224847.GA2490@infradead.org>

Christoph Hellwig wrote:
> On Mon, Feb 15, 2010 at 02:51:22PM +0100, Douglas Gilbert wrote:
>> What about O_NONBLOCK (which stops a hang on open)?
>> The open code common to my utilities in Linux is
>> below.
> 
> No, O_NONBLOCK should have nothing to do with it and your code
> snipplet looks fine.  We'll need to figure out what's really going
> on here.

Forget SYNCHRONIZE CACHE, the pass-through interface via
sd looks completely stupid when opened RW.

   'modprobe scsi_debug opts=1'
shows all SCSI commands sent to a device (dev/sdb in this
case).

   # sg_start --stop --readonly /dev/sdb
does the expected:
     scsi_debug: cmd 1b 00 00 00 00 00


but remove that '--readonly' and /dev/sdb is opened RW
with this command:
   # sg_start --stop /dev/sdb
then scsi_debug reports this load (of crap):
     scsi_debug: cmd 1b 00 00 00 00 00
     scsi_debug: cmd 12 00 00 00 fe 00
     scsi_debug: cmd 12 01 00 00 fe 00
     scsi_debug: cmd 12 01 83 00 fe 00
     scsi_debug: cmd 28 00 00 00 00 00 00 01 00 00
     scsi_debug: cmd 28 00 00 00 00 00 00 00 08 00
     scsi_debug: cmd 28 00 00 00 00 00 00 00 20 00
     scsi_debug: cmd 28 00 00 00 00 00 00 00 08 00
     scsi_debug: cmd 28 00 00 00 00 00 00 00 08 00

So send a START_STOP_UNIT(stop) through the SG_IO
ioctl on a sd device opened RW and as a bonus get
three INQUIRYs (one standard, two VPD pages) and 5 READ
commands!

If the device is SCSI (as the scsi_debug driver is
simulating) then those READs fail because the drive
is stopped. However if that is an ATA disk behind a
SAT layer, then the disk will be spun up. That defeats
the purpose of the pass-though, especially when it
is being used to spin down the disk.

My guess, reviewing the bug reports flowing into me is
that this nonsense started around lk 2.6.29 .

Please fix.

Doug Gilbert

  reply	other threads:[~2010-02-19  0:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-15 13:03 SYNCHRONIZE CACHE command from sd on close Douglas Gilbert
2010-02-15 13:25 ` Christoph Hellwig
2010-02-15 13:51   ` Douglas Gilbert
2010-02-15 22:48     ` Christoph Hellwig
2010-02-19  0:20       ` Douglas Gilbert [this message]
2010-02-19  8:04         ` Christoph Hellwig
2010-02-19 11:56           ` Douglas Gilbert

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=4B7DD949.3010907@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=dhorak@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-scsi@vger.kernel.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