lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <49D2C342.9040603@garzik.org>
Date:	Tue, 31 Mar 2009 21:28:34 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	James Bottomley <James.Bottomley@...senPartnership.com>
CC:	Ric Wheeler <rwheeler@...hat.com>,
	Jens Axboe <jens.axboe@...cle.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Theodore Tso <tytso@....edu>, Ingo Molnar <mingo@...e.hu>,
	Alan Cox <alan@...rguk.ukuu.org.uk>,
	Arjan van de Ven <arjan@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Nick Piggin <npiggin@...e.de>, David Rees <drees76@...il.com>,
	Jesper Krogh <jesper@...gh.cc>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: range-based cache flushing (was Re: Linux 2.6.29)

James Bottomley wrote:
> On Mon, 2009-03-30 at 15:05 -0400, Jeff Garzik wrote:
>> James Bottomley wrote:
>>> On Wed, 2009-03-25 at 16:25 -0400, Ric Wheeler wrote:
>>>> Jeff Garzik wrote:
>>>>> Ric Wheeler wrote:> And, as I am sure that you do know, to add insult 
>>>>> to injury, FLUSH_CACHE
>>>>>> is per device (not file system).
>>>>>> When you issue an fsync() on a disk with multiple partitions, you 
>>>>>> will flush the data for all of its partitions from the write cache....
>>>>> SCSI'S SYNCHRONIZE CACHE command already accepts an (LBA, length) 
>>>>> pair.  We could make use of that.
>>>>> And I bet we could convince T13 to add FLUSH CACHE RANGE, if we could 
>>>>> demonstrate clear benefit.
>>>> How well supported is this in SCSI?  Can we try it out with a commodity 
>>>> SAS drive?
>>> What do you mean by well supported?  The way the SCSI standard is
>>> written, a device can do a complete cache flush when a range flush is
>>> requested and still be fully standards compliant.  There's no easy way
>>> to tell if it does a complete cache flush every time other than by
>>> taking the firmware apart (or asking the manufacturer).
>> Quite true, though wondering aloud...
>>
>> How difficult would it be to pass the "lower-bound" LBA to SYNCHRONIZE 
>> CACHE, where "lower bound" is defined as the lowest sector in the range 
>> of sectors to be flushed?
> 
> Actually, the implementation is designed to allow this.  The standard
> says if the number of blocks is zero that means flush from the specified
> LBA to the end of the device.  The sync cache we currently use has LBA 0
> and number of blocks zero (which means flush everything).

Yeah, that feature of the spec was what got me thinking.

"difficult" was referring more to the kernel side of things...  if 
calculating the lowest LBA of a write barrier is difficult and/or 
CPU-consuming, the effort may not be worth it.

But if we could stick a

	if (LBA < barrier-lower-bound)
		barrier-lower-bound = LBA

somewhere, then pass that to SYNCHRONIZE CACHE, it could be a cheap way 
to increase sync-cache speed.

It seems extremely unlikely that sync-cache speed would _decrease_:  for 
flush-everything firmwares, the sync-cache speed would remain unchanged.


>> That seems like a reasonable optimization -- it gives the drive an easy 
>> way to skip sync'ing sectors lower than the lower-bound LBA, if it is 
>> capable.  Otherwise, a standards-compliant firmware will behave as you 
>> describe, and do what our code currently expects today -- a full cache 
>> flush.
>>
>> This seems like a good way to speed up cache flush [on SCSI], while also 
>> perhaps experimenting with a more fine-grained way to pass down write 
>> barriers to the device.
>>
>> Not a high priority thing overall, but OTOH, consider the case of 
>> placing your journal at the end of the disk.  You could then issue a 
>> cache flush with a non-zero starting offset:
>>
>> 	SYNCHRONIZE CACHE (max sectors - JOURNAL_SIZE, ~0)
>>
>> That should be trivial even for dumb disk firmwares to optimize.
> 
> We could try it ... I'm still not sure how we'd tell the device is
> actually implementing it and not flushing the entire device.

Is that knowledge necessary?

Assuming the lower-bound is super-cheap to calculate, then the two most 
likely outcomes are:  sync-cache speed remains the same, or sync-cache 
speed increases.

If the calculation of lower-bound is costly, I could see the need for 
that knowledge -- but if the cost is too high, the entire effort it 
likely to be scuttled, rather than worrying about detecting 
flush-everything firmwares.

	Jeff




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ