From: Douglas Gilbert <dgilbert@interlog.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: SYNCHRONIZE CACHE command from sd on close
Date: Mon, 15 Feb 2010 14:51:22 +0100 [thread overview]
Message-ID: <4B79515A.6020507@interlog.com> (raw)
In-Reply-To: <20100215132502.GA15360@infradead.org>
Christoph Hellwig wrote:
> On Mon, Feb 15, 2010 at 02:03:06PM +0100, Douglas Gilbert wrote:
>> Recently, judging from error reports reaching me
>> from smartmontools, sdparm and sg_start, something
>> changed in the sd driver associated with the
>> SYNCHRONIZE CACHE command it issues when a device
>> is closed.
>>
>> That only seems to happen when the device is opened
>> RW and it exposes a nasty difference between the
>> semantics of spinning up and down ATA disks compared
>> to SCSI disks.
>
> The sd driver itself never sends a SYNCHRONIZE CACHE in
> response to access through the block device node, it is only
> sent for barrier requests, when hot-unplugging a scsi device,
> or when shutting down the system.
>
> Now that has change recently is that we now send down a cache
> flush from the block layer when fsync is called on the block
> device node. The kernel should never call that by itself when
> closing the device, but can you double check that the tools
> don't call fsync/fdatasync/msync or open the block device node
> using O_SYNC/O_DYSNC?
What about O_NONBLOCK (which stops a hang on open)?
The open code common to my utilities in Linux is
below.
Doug Gilbert
int
scsi_pt_open_device(const char * device_name, int read_only, int verbose)
{
int oflags = O_NONBLOCK;
oflags |= (read_only ? O_RDONLY : O_RDWR);
return scsi_pt_open_flags(device_name, oflags, verbose);
}
int
scsi_pt_open_flags(const char * device_name, int flags, int verbose)
{
int fd;
if (verbose > 1) {
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
fprintf(sg_warnings_strm, "open %s with flags=0x%x\n", device_name,
flags);
}
fd = open(device_name, flags);
if (fd < 0)
fd = -errno;
return fd;
}
next prev parent reply other threads:[~2010-02-15 13:51 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 [this message]
2010-02-15 22:48 ` Christoph Hellwig
2010-02-19 0:20 ` Douglas Gilbert
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=4B79515A.6020507@interlog.com \
--to=dgilbert@interlog.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.