Program logic for the read cache patch

Dave Collier-Brown davec-b at rogers.com
Fri May 30 00:36:54 GMT 2003


  This patch provides a cache in write_cache format,
suitable for use when doing a sequential series of reads
from a device, such as a RAID array, that like large
reads of specific sizes.

  In loadparm.c, it is declared and the option read
as size in bytes, where a size of 0 is the default
and means "don't create a read cache".

  In fileio.c, it is created by read_file if there is
no preexisting read or write cache. If it exists
and is empty, it is filled following the creation check.
  If it is empty after trying to read from it, read_file
attempts to read the write cache, and if that is empty,
tries to read the file directly, via a new function, 
really_read_file.

The cache code is structured like a simple storage
object, with 
	static BOOL setup_read_cache(files_struct *);
	static int copy_from_cache(write_cache *, char *, size_t);
	static int read_from_read_cache(files_struct *,
		char *,SMB_OFF_T,size_t);
	void delete_read_cache(files_struct *fsp)
	static void delete_cache(write_cache *cp);
	int reload_read_cache(files_struct *fsp);
functions.  These do the bookeeping for the buffer pointers, so
that like knuthput or stdio, a read which empties the cache will
refill it via a read of the desired size, and return the amount
asked for until EOF is reached.

The data structure is adapted from the write_cache one, so
that in principle the two can be combined.

The code does not know what to do if there is a seek or a write.
It should either discard the read cache, invalidate it,
or, if read and write caches are combined, simply reset its 
position pointers.  I'm initially inclined to discared it,
and later combine the read and write caches. The former
(ie, discard) would be done on any write or seek where the
 read cache is found to exist.

--dave




-- 
David Collier-Brown,  | Always do right. This will gratify
Americas Customer Eng | some people and astonish the rest.
at Sun Canada         |                      -- Mark Twain
(905) 415-2849        | davecb at spamcop.net



More information about the samba-technical mailing list