dmu_zfetch.c revision 404ba9d7d495f1806ee789b2a2aa1518284a6192
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/zfs_context.h>
#include <sys/dmu_objset.h>
#include <sys/dmu_zfetch.h>
/*
* I'm against tune-ables, but these should probably exist as tweakable globals
* until we can get this working the way we want it to.
*/
/* max # of streams per zfetch */
/* min time before stream reclaim */
/* max number of blocks to fetch at a time */
/* number of bytes in a array_read at which we stop prefetching (1Mb) */
/* forward decls for static routines */
/*
* Given a zfetch structure and a zstream structure, determine whether the
* blocks to be read are part of a co-linear to a pair of existing prefetch
* streams. If a set is found, coalesce the streams, removing one, and
* configure the prefetch so it looks for a strided access pattern.
*
* If no co-linear streams are found, return NULL.
*/
static int
{
return (0);
return (0);
}
continue;
}
z_walk->zst_stride =
return (1);
}
z_walk->zst_stride =
return (1);
}
}
}
return (0);
}
/*
* Given a zstream_t, determine the bounds of the prefetch. Then call the
* routine that actually prefetches the individual blocks.
*/
static void
{
/*
* XXX: use a faster division method?
*/
while (prefetch_tail < prefetch_limit) {
/*
* Don't prefetch beyond the end of the file, if working
* backwards.
*/
(prefetch_ofst > prefetch_tail)) {
prefetch_ofst = 0;
}
/* don't prefetch more than we're supposed to */
break;
/* stop if we've run out of stuff to prefetch */
break;
}
}
/*
* This takes a pointer to a zfetch structure and a dnode. It performs the
* necessary setup for the zfetch structure, grokking data from the
* associated dnode.
*/
void
{
return;
}
zf->zf_stream_cnt = 0;
zf->zf_alloc_fail = 0;
}
/*
* This function computes the actual size, in blocks, that can be prefetched,
* and fetches it.
*/
static uint64_t
{
uint64_t i;
for (i = 0; i < fetchsz; i++) {
}
return (fetchsz);
}
/*
* this function returns the number of blocks that would be prefetched, based
* upon the supplied dnode, blockid, and nblks. This is used so that we can
* update streams in place, and then prefetch with their old value after the
* fact. This way, we can delay the prefetch, but subsequent accesses to the
* stream won't result in the same data being prefetched multiple times.
*/
static uint64_t
{
return (0);
}
/* compute fetch size */
} else {
}
return (fetchsz);
}
/*
* given a zfetch and a zsearch structure, see if there is an associated zstream
* for this block read. If so, it starts a prefetch for the stream it
* located and returns true, otherwise it returns false
*/
static int
{
int rc = 0;
return (0);
/*
* XXX: This locking strategy is a bit coarse; however, it's impact has
* yet to be tested. If this turns out to be an issue, it can be
* modified in a number of different ways.
*/
top:
/* bogus stream */
continue;
}
/* already fetched */
return (1);
}
/* forward sequential access */
goto top;
}
if (diff > 0) {
}
break;
/* backwards sequential access */
goto top;
}
if (diff > 0) {
}
break;
/* strided forward access */
goto top;
}
break;
/* strided reverse access */
goto top;
}
break;
}
}
if (zs) {
rc = 1;
}
return (rc);
}
/*
* Clean-up state associated with a zfetch structure. This frees allocated
* structure members, empties the zf_stream tree, and generally makes things
* nice. This doesn't free the zfetch_t itself, that's left to the caller.
*/
void
{
}
}
/*
* Given a zfetch and zstream structure, insert the zstream structure into the
* AVL tree contained within the zfetch structure. Peform the appropriate
* book-keeping. It is possible that another thread has inserted a stream which
* matches one that we are about to insert, so we must be sure to check for this
* case. If one is found, return failure, and let the caller cleanup the
* duplicates.
*/
static int
{
return (0);
}
}
zf->zf_stream_cnt++;
return (1);
}
/*
* Walk the list of zstreams in the given zfetch, find an old one (by time), and
* reclaim it for use by the caller.
*/
static zstream_t *
{
return (0);
break;
}
if (zs) {
} else {
zf->zf_alloc_fail++;
}
return (zs);
}
/*
* Given a zfetch and zstream structure, remove the zstream structure from its
* container in the zfetch structure. Perform the appropriate book-keeping.
*/
static void
{
zf->zf_stream_cnt--;
}
static int
{
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
return (1);
}
/*
* This is the prefetch entry point. It calls all of the other dmu_zfetch
* routines to create, delete, find, or operate upon prefetch streams.
*/
void
{
int fetched;
int inserted;
unsigned int blkshft;
/* files that aren't ln2 blocksz are only one block -- nothing to do */
return;
}
/* convert offset and size, into blockid and nblocks */
if (!fetched) {
}
if (!fetched) {
/*
* we still couldn't find a stream, drop the lock, and allocate
* one if possible. Otherwise, give up and go home.
*/
(maxblocks / zfetch_block_cap));
if (max_streams == 0) {
max_streams++;
}
if (cur_streams >= max_streams) {
return;
}
}
if (!inserted) {
}
}
}