Subject: Re: Explicit enabling of disk caches
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: Matthew Jacob <mjacob@feral.com>
List: tech-kern
Date: 09/02/2001 11:25:44
This is interesting- in particular dkctl. I'd suggest that you could also add
functions going the *Other* way and add 'write check' functionality as well.
On Sun, 2 Sep 2001, Jason R Thorpe wrote:
> Folks...
>
> I've been thinking of ways we can improve I/O performance, and one
> obvious way is to provide a mechanism to explicitly manipulate the
> read and write caches on disks.
>
> The first step in this is to provide an abstract mechanism to query,
> enable/disable, and flush the caches on disks. I.e. you don't want
> to litter knowledge of SCSI throughout the tree, and e.g. RAID controllers
> which have caches are likely to have different mechanisms for cache
> manipulation.
>
> So, what I'm proposing are 3 new ioctls:
>
> DIOCGCACHE get cache enable bits
> DIOCSCACHE set cache enable bits
> DIOCSYNCCCACHE synchronize the cache
>
> DIOC{G,S}CACHE use an `int' argument that has the following bits:
>
> DKCACHE_READ read cache enabled
> DKCACHE_WRITE write(-back) cache enabled
>
> DIOCCACHESYNC uses an `int' argument, treated as a boolean, indicating
> whether or not to force the cache flush. This allows e.g. battery-backed
> RAID caches to skip the cache flush unless you tell it to REALLY REALLY
> flush it (e.g. you're going to swap out the disk).
>
> I've written a cheezy little dkctl(8) program that uses these ioctls
> to do the obvious thing. This program will need a little work before
> it goes into the tree.
>
> But the eventual goal is for the file system to be able to explicitly
> use the cache flush operation as a barrier, which would let disks
> run with the write-back cache enabled in a safe fashion. Something like
> this:
>
> write out data -> sync cache -> write out metadata -> sync cache
>
> Side note -- I'm considering a bit in `struct buf', maybe B_WRITETHROUGH,
> which would make it look more like this:
>
> write out data -> sync cache -> write-through out metadata
>
> ..saving a SCSI command (SCSI has a bit in the CDB that can force
> write-through on a per-write basis).
>
> Attached are diffs that implement the above ioctls in the SCSI disk
> driver. If we decide these are a good idea, then I'll add stubs in
> the other disk drivers as well (at least for the SYNCCACHE ioctl).
>
> --
> -- Jason R. Thorpe <thorpej@wasabisystems.com>
>