jfs_metapage.c 13.7 KB
Newer Older
Dave Kleikamp's avatar
Dave Kleikamp committed
1
/*
Dave Kleikamp's avatar
Dave Kleikamp committed
2 3
 *   Copyright (C) International Business Machines Corp., 2000-2003
 *   Portions Copyright (C) Christoph Hellwig, 2001-2002
Dave Kleikamp's avatar
Dave Kleikamp committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version.
 * 
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program;  if not, write to the Free Software 
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include <linux/fs.h>
#include <linux/init.h>
22
#include <linux/buffer_head.h>
23
#include <linux/mempool.h>
Dave Kleikamp's avatar
Dave Kleikamp committed
24
#include "jfs_incore.h"
Dave Kleikamp's avatar
Dave Kleikamp committed
25
#include "jfs_superblock.h"
Dave Kleikamp's avatar
Dave Kleikamp committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include "jfs_filsys.h"
#include "jfs_metapage.h"
#include "jfs_txnmgr.h"
#include "jfs_debug.h"

static spinlock_t meta_lock = SPIN_LOCK_UNLOCKED;

#ifdef CONFIG_JFS_STATISTICS
struct {
	uint	pagealloc;	/* # of page allocations */
	uint	pagefree;	/* # of page frees */
	uint	lockwait;	/* # of sleeping lock_metapage() calls */
} mpStat;
#endif


#define HASH_BITS 10		/* This makes hash_table 1 4K page */
#define HASH_SIZE (1 << HASH_BITS)
44
static struct metapage **hash_table = NULL;
Dave Kleikamp's avatar
Dave Kleikamp committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
static unsigned long hash_order;


static inline int metapage_locked(struct metapage *mp)
{
	return test_bit(META_locked, &mp->flag);
}

static inline int trylock_metapage(struct metapage *mp)
{
	return test_and_set_bit(META_locked, &mp->flag);
}

static inline void unlock_metapage(struct metapage *mp)
{
	clear_bit(META_locked, &mp->flag);
	wake_up(&mp->wait);
}

static void __lock_metapage(struct metapage *mp)
{
	DECLARE_WAITQUEUE(wait, current);

	INCREMENT(mpStat.lockwait);

	add_wait_queue_exclusive(&mp->wait, &wait);
	do {
		set_current_state(TASK_UNINTERRUPTIBLE);
		if (metapage_locked(mp)) {
			spin_unlock(&meta_lock);
			schedule();
			spin_lock(&meta_lock);
		}
	} while (trylock_metapage(mp));
	__set_current_state(TASK_RUNNING);
	remove_wait_queue(&mp->wait, &wait);
}

/* needs meta_lock */
static inline void lock_metapage(struct metapage *mp)
{
	if (trylock_metapage(mp))
		__lock_metapage(mp);
}

90 91 92 93 94
#define METAPOOL_MIN_PAGES 32
static kmem_cache_t *metapage_cache;
static mempool_t *metapage_mempool;

static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
Dave Kleikamp's avatar
Dave Kleikamp committed
95
{
96
	struct metapage *mp = (struct metapage *)foo;
97 98 99 100 101 102 103 104 105 106 107 108 109 110

	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
	    SLAB_CTOR_CONSTRUCTOR) {
		mp->lid = 0;
		mp->lsn = 0;
		mp->flag = 0;
		mp->data = NULL;
		mp->clsn = 0;
		mp->log = NULL;
		set_bit(META_free, &mp->flag);
		init_waitqueue_head(&mp->wait);
	}
}

111
static inline struct metapage *alloc_metapage(int no_wait)
112 113 114 115
{
	return mempool_alloc(metapage_mempool, no_wait ? GFP_ATOMIC : GFP_NOFS);
}

116
static inline void free_metapage(struct metapage *mp)
117 118 119 120 121 122
{
	mp->flag = 0;
	set_bit(META_free, &mp->flag);

	mempool_free(mp, metapage_mempool);
}
Dave Kleikamp's avatar
Dave Kleikamp committed
123

124 125
int __init metapage_init(void)
{
Dave Kleikamp's avatar
Dave Kleikamp committed
126 127 128
	/*
	 * Allocate the metapage structures
	 */
129 130
	metapage_cache = kmem_cache_create("jfs_mp", sizeof(struct metapage),
					   0, 0, init_once, NULL);
131 132
	if (metapage_cache == NULL)
		return -ENOMEM;
Dave Kleikamp's avatar
Dave Kleikamp committed
133

134 135
	metapage_mempool = mempool_create(METAPOOL_MIN_PAGES, mempool_alloc_slab,
					  mempool_free_slab, metapage_cache);
Dave Kleikamp's avatar
Dave Kleikamp committed
136

137 138 139
	if (metapage_mempool == NULL) {
		kmem_cache_destroy(metapage_cache);
		return -ENOMEM;
Dave Kleikamp's avatar
Dave Kleikamp committed
140 141 142 143 144 145 146 147
	}
	/*
	 * Now the hash list
	 */
	for (hash_order = 0;
	     ((PAGE_SIZE << hash_order) / sizeof(void *)) < HASH_SIZE;
	     hash_order++);
	hash_table =
148
	    (struct metapage **) __get_free_pages(GFP_KERNEL, hash_order);
Dave Kleikamp's avatar
Dave Kleikamp committed
149 150 151 152 153 154 155 156
	assert(hash_table);
	memset(hash_table, 0, PAGE_SIZE << hash_order);

	return 0;
}

void metapage_exit(void)
{
157 158
	mempool_destroy(metapage_mempool);
	kmem_cache_destroy(metapage_cache);
Dave Kleikamp's avatar
Dave Kleikamp committed
159 160 161 162 163
}

/*
 * Basically same hash as in pagemap.h, but using our hash table
 */
164 165
static struct metapage **meta_hash(struct address_space *mapping,
				   unsigned long index)
Dave Kleikamp's avatar
Dave Kleikamp committed
166 167 168 169 170 171 172 173 174
{
#define i (((unsigned long)mapping)/ \
	   (sizeof(struct inode) & ~(sizeof(struct inode) -1 )))
#define s(x) ((x) + ((x) >> HASH_BITS))
	return hash_table + (s(i + index) & (HASH_SIZE - 1));
#undef i
#undef s
}

175 176
static struct metapage *search_hash(struct metapage ** hash_ptr,
				    struct address_space *mapping,
Dave Kleikamp's avatar
Dave Kleikamp committed
177 178
			       unsigned long index)
{
179
	struct metapage *ptr;
Dave Kleikamp's avatar
Dave Kleikamp committed
180 181 182 183 184 185 186 187 188

	for (ptr = *hash_ptr; ptr; ptr = ptr->hash_next) {
		if ((ptr->mapping == mapping) && (ptr->index == index))
			return ptr;
	}

	return NULL;
}

189
static void add_to_hash(struct metapage * mp, struct metapage ** hash_ptr)
Dave Kleikamp's avatar
Dave Kleikamp committed
190 191 192 193 194 195 196 197 198
{
	if (*hash_ptr)
		(*hash_ptr)->hash_prev = mp;

	mp->hash_prev = NULL;
	mp->hash_next = *hash_ptr;
	*hash_ptr = mp;
}

199
static void remove_from_hash(struct metapage * mp, struct metapage ** hash_ptr)
Dave Kleikamp's avatar
Dave Kleikamp committed
200 201 202 203 204 205 206 207 208 209 210 211
{
	if (mp->hash_prev)
		mp->hash_prev->hash_next = mp->hash_next;
	else {
		assert(*hash_ptr == mp);
		*hash_ptr = mp->hash_next;
	}

	if (mp->hash_next)
		mp->hash_next->hash_prev = mp->hash_prev;
}

212 213 214
struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
				unsigned int size, int absolute,
				unsigned long new)
Dave Kleikamp's avatar
Dave Kleikamp committed
215
{
216
	struct metapage **hash_ptr;
Dave Kleikamp's avatar
Dave Kleikamp committed
217 218 219
	int l2BlocksPerPage;
	int l2bsize;
	struct address_space *mapping;
220
	struct metapage *mp;
Dave Kleikamp's avatar
Dave Kleikamp committed
221 222 223
	unsigned long page_index;
	unsigned long page_offset;

224
	jfs_info("__get_metapage: inode = 0x%p, lblock = 0x%lx", inode, lblock);
Dave Kleikamp's avatar
Dave Kleikamp committed
225 226

	if (absolute)
227
		mapping = inode->i_sb->s_bdev->bd_inode->i_mapping;
Dave Kleikamp's avatar
Dave Kleikamp committed
228 229 230 231
	else
		mapping = inode->i_mapping;

	hash_ptr = meta_hash(mapping, lblock);
232 233
again:
	spin_lock(&meta_lock);
Dave Kleikamp's avatar
Dave Kleikamp committed
234 235 236
	mp = search_hash(hash_ptr, mapping, lblock);
	if (mp) {
	      page_found:
237 238 239 240 241 242 243
		mp->count++;
		lock_metapage(mp);
		spin_unlock(&meta_lock);
		if (test_bit(META_stale, &mp->flag)) {
			release_metapage(mp);
			goto again;
		}
Dave Kleikamp's avatar
Dave Kleikamp committed
244
		if (test_bit(META_discard, &mp->flag)) {
Dave Kleikamp's avatar
Dave Kleikamp committed
245 246 247 248
			if (!new) {
				jfs_error(inode->i_sb,
					  "__get_metapage: using a "
					  "discarded metapage");
249
				release_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
250 251
				return NULL;
			}
Dave Kleikamp's avatar
Dave Kleikamp committed
252 253
			clear_bit(META_discard, &mp->flag);
		}
254
		jfs_info("__get_metapage: found 0x%p, in hash", mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
255 256 257
		if (mp->logical_size != size) {
			jfs_error(inode->i_sb,
				  "__get_metapage: mp->logical_size != size");
258
			release_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
259 260
			return NULL;
		}
Dave Kleikamp's avatar
Dave Kleikamp committed
261
	} else {
262
		l2bsize = inode->i_blkbits;
Dave Kleikamp's avatar
Dave Kleikamp committed
263 264 265 266
		l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
		page_index = lblock >> l2BlocksPerPage;
		page_offset = (lblock - (page_index << l2BlocksPerPage)) <<
		    l2bsize;
267
		if ((page_offset + size) > PAGE_CACHE_SIZE) {
Dave Kleikamp's avatar
Dave Kleikamp committed
268
			spin_unlock(&meta_lock);
269
			jfs_err("MetaData crosses page boundary!!");
Dave Kleikamp's avatar
Dave Kleikamp committed
270 271
			return NULL;
		}
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
		
		/*
		 * Locks held on aggregate inode pages are usually
		 * not held long, and they are taken in critical code
		 * paths (committing dirty inodes, txCommit thread) 
		 * 
		 * Attempt to get metapage without blocking, tapping into
		 * reserves if necessary.
		 */
		mp = NULL;
		if (JFS_IP(inode)->fileset == AGGREGATE_I) {
			mp =  mempool_alloc(metapage_mempool, GFP_ATOMIC);
			if (!mp) {
				/*
				 * mempool is supposed to protect us from
				 * failing here.  We will try a blocking
				 * call, but a deadlock is possible here
				 */
				printk(KERN_WARNING
				       "__get_metapage: atomic call to mempool_alloc failed.\n");
				printk(KERN_WARNING
				       "Will attempt blocking call\n");
			}
		}
		if (!mp) {
297
			struct metapage *mp2;
Dave Kleikamp's avatar
Dave Kleikamp committed
298

299 300 301 302 303 304
			spin_unlock(&meta_lock);
			mp =  mempool_alloc(metapage_mempool, GFP_NOFS);
			spin_lock(&meta_lock);

			/* we dropped the meta_lock, we need to search the
			 * hash again.
Dave Kleikamp's avatar
Dave Kleikamp committed
305 306 307
			 */
			mp2 = search_hash(hash_ptr, mapping, lblock);
			if (mp2) {
308
				free_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
				mp = mp2;
				goto page_found;
			}
		}
		mp->flag = 0;
		lock_metapage(mp);
		if (absolute)
			set_bit(META_absolute, &mp->flag);
		mp->xflag = COMMIT_PAGE;
		mp->count = 1;
		atomic_set(&mp->nohomeok,0);
		mp->mapping = mapping;
		mp->index = lblock;
		mp->page = 0;
		mp->logical_size = size;
		add_to_hash(mp, hash_ptr);
		spin_unlock(&meta_lock);

		if (new) {
328
			jfs_info("__get_metapage: Calling grab_cache_page");
Dave Kleikamp's avatar
Dave Kleikamp committed
329 330
			mp->page = grab_cache_page(mapping, page_index);
			if (!mp->page) {
331
				jfs_err("grab_cache_page failed!");
Dave Kleikamp's avatar
Dave Kleikamp committed
332
				goto freeit;
333
			} else {
Dave Kleikamp's avatar
Dave Kleikamp committed
334
				INCREMENT(mpStat.pagealloc);
335 336
				unlock_page(mp->page);
			}
Dave Kleikamp's avatar
Dave Kleikamp committed
337
		} else {
338
			jfs_info("__get_metapage: Calling read_cache_page");
Dave Kleikamp's avatar
Dave Kleikamp committed
339 340
			mp->page = read_cache_page(mapping, lblock,
				    (filler_t *)mapping->a_ops->readpage, NULL);
Dave Kleikamp's avatar
Dave Kleikamp committed
341
			if (IS_ERR(mp->page)) {
342
				jfs_err("read_cache_page failed!");
Dave Kleikamp's avatar
Dave Kleikamp committed
343
				goto freeit;
Dave Kleikamp's avatar
Dave Kleikamp committed
344 345 346
			} else
				INCREMENT(mpStat.pagealloc);
		}
Dave Kleikamp's avatar
Dave Kleikamp committed
347
		mp->data = kmap(mp->page) + page_offset;
Dave Kleikamp's avatar
Dave Kleikamp committed
348
	}
Dave Kleikamp's avatar
Dave Kleikamp committed
349 350 351 352

	if (new)
		memset(mp->data, 0, PSIZE);

353
	jfs_info("__get_metapage: returning = 0x%p", mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
354
	return mp;
Dave Kleikamp's avatar
Dave Kleikamp committed
355 356 357 358

freeit:
	spin_lock(&meta_lock);
	remove_from_hash(mp, hash_ptr);
359
	free_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
360 361
	spin_unlock(&meta_lock);
	return NULL;
Dave Kleikamp's avatar
Dave Kleikamp committed
362 363
}

364
void hold_metapage(struct metapage * mp, int force)
Dave Kleikamp's avatar
Dave Kleikamp committed
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
{
	spin_lock(&meta_lock);

	mp->count++;

	if (force) {
		ASSERT (!(test_bit(META_forced, &mp->flag)));
		if (trylock_metapage(mp))
			set_bit(META_forced, &mp->flag);
	} else
		lock_metapage(mp);

	spin_unlock(&meta_lock);
}

380
static void __write_metapage(struct metapage * mp)
Dave Kleikamp's avatar
Dave Kleikamp committed
381
{
382 383
	int l2bsize = mp->mapping->host->i_blkbits;
	int l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
Dave Kleikamp's avatar
Dave Kleikamp committed
384 385 386 387
	unsigned long page_index;
	unsigned long page_offset;
	int rc;

388
	jfs_info("__write_metapage: mp = 0x%p", mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
389 390 391 392 393 394 395 396 397 398 399 400 401

	if (test_bit(META_discard, &mp->flag)) {
		/*
		 * This metadata is no longer valid
		 */
		clear_bit(META_dirty, &mp->flag);
		return;
	}

	page_index = mp->page->index;
	page_offset =
	    (mp->index - (page_index << l2BlocksPerPage)) << l2bsize;

402
	lock_page(mp->page);
Dave Kleikamp's avatar
Dave Kleikamp committed
403 404 405 406
	rc = mp->mapping->a_ops->prepare_write(NULL, mp->page, page_offset,
					       page_offset +
					       mp->logical_size);
	if (rc) {
407
		jfs_err("prepare_write return %d!", rc);
Dave Kleikamp's avatar
Dave Kleikamp committed
408
		ClearPageUptodate(mp->page);
409
		unlock_page(mp->page);
Dave Kleikamp's avatar
Dave Kleikamp committed
410 411 412 413 414 415 416
		clear_bit(META_dirty, &mp->flag);
		return;
	}
	rc = mp->mapping->a_ops->commit_write(NULL, mp->page, page_offset,
					      page_offset +
					      mp->logical_size);
	if (rc) {
417
		jfs_err("commit_write returned %d", rc);
Dave Kleikamp's avatar
Dave Kleikamp committed
418 419
	}

420
	unlock_page(mp->page);
Dave Kleikamp's avatar
Dave Kleikamp committed
421 422
	clear_bit(META_dirty, &mp->flag);

423
	jfs_info("__write_metapage done");
Dave Kleikamp's avatar
Dave Kleikamp committed
424 425
}

426
static inline void sync_metapage(struct metapage *mp)
Dave Kleikamp's avatar
Dave Kleikamp committed
427 428 429 430 431 432 433
{
	struct page *page = mp->page;

	page_cache_get(page);
	lock_page(page);

	/* we're done with this page - no need to check for errors */
Andrew Morton's avatar
Andrew Morton committed
434 435 436 437
	if (page_has_buffers(page))
		write_one_page(page, 1);
	else
		unlock_page(page);
Dave Kleikamp's avatar
Dave Kleikamp committed
438 439 440
	page_cache_release(page);
}

441
void release_metapage(struct metapage * mp)
Dave Kleikamp's avatar
Dave Kleikamp committed
442
{
443
	struct jfs_log *log;
Dave Kleikamp's avatar
Dave Kleikamp committed
444

445
	jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag);
Dave Kleikamp's avatar
Dave Kleikamp committed
446 447 448 449 450 451 452 453 454 455 456 457 458

	spin_lock(&meta_lock);
	if (test_bit(META_forced, &mp->flag)) {
		clear_bit(META_forced, &mp->flag);
		mp->count--;
		spin_unlock(&meta_lock);
		return;
	}

	assert(mp->count);
	if (--mp->count || atomic_read(&mp->nohomeok)) {
		unlock_metapage(mp);
		spin_unlock(&meta_lock);
459 460
		return;
	}
Dave Kleikamp's avatar
Dave Kleikamp committed
461

462 463 464 465 466 467 468 469 470 471 472
	if (mp->page) {
		/* Releasing spinlock, we have to check mp->count later */
		set_bit(META_stale, &mp->flag);
		spin_unlock(&meta_lock);
		kunmap(mp->page);
		mp->data = 0;
		if (test_bit(META_dirty, &mp->flag))
			__write_metapage(mp);
		if (test_bit(META_sync, &mp->flag)) {
			sync_metapage(mp);
			clear_bit(META_sync, &mp->flag);
Dave Kleikamp's avatar
Dave Kleikamp committed
473 474
		}

475 476 477 478
		if (test_bit(META_discard, &mp->flag)) {
			lock_page(mp->page);
			block_invalidatepage(mp->page, 0);
			unlock_page(mp->page);
Dave Kleikamp's avatar
Dave Kleikamp committed
479 480
		}

481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
		page_cache_release(mp->page);
		mp->page = NULL;
		INCREMENT(mpStat.pagefree);
		spin_lock(&meta_lock);
	}

	if (mp->lsn) {
		/*
		 * Remove metapage from logsynclist.
		 */
		log = mp->log;
		LOGSYNC_LOCK(log);
		mp->log = 0;
		mp->lsn = 0;
		mp->clsn = 0;
		log->count--;
		list_del(&mp->synclist);
		LOGSYNC_UNLOCK(log);
Dave Kleikamp's avatar
Dave Kleikamp committed
499
	}
500 501 502 503 504 505 506 507 508 509
	if (mp->count) {
		/* Someone else is trying to get this metpage */
		unlock_metapage(mp);
		spin_unlock(&meta_lock);
		return;
	}
	remove_from_hash(mp, meta_hash(mp->mapping, mp->index));
	spin_unlock(&meta_lock);

	free_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
510 511
}

512
void __invalidate_metapages(struct inode *ip, s64 addr, int len)
Dave Kleikamp's avatar
Dave Kleikamp committed
513
{
514
	struct metapage **hash_ptr;
Dave Kleikamp's avatar
Dave Kleikamp committed
515
	unsigned long lblock;
516
	int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits;
517 518
	/* All callers are interested in block device's mapping */
	struct address_space *mapping = ip->i_sb->s_bdev->bd_inode->i_mapping;
519
	struct metapage *mp;
Dave Kleikamp's avatar
Dave Kleikamp committed
520 521 522 523 524 525 526 527 528
	struct page *page;

	/*
	 * First, mark metapages to discard.  They will eventually be
	 * released, but should not be written.
	 */
	for (lblock = addr; lblock < addr + len;
	     lblock += 1 << l2BlocksPerPage) {
		hash_ptr = meta_hash(mapping, lblock);
529
again:
Dave Kleikamp's avatar
Dave Kleikamp committed
530 531 532
		spin_lock(&meta_lock);
		mp = search_hash(hash_ptr, mapping, lblock);
		if (mp) {
533 534 535 536 537 538 539 540 541 542
			if (test_bit(META_stale, &mp->flag)) {
				/* Racing with release_metapage */
				mp->count++;
				lock_metapage(mp);
				spin_unlock(&meta_lock);
				/* racing release_metapage should be done now */
				release_metapage(mp);
				goto again;
			}

Dave Kleikamp's avatar
Dave Kleikamp committed
543 544 545 546
			set_bit(META_discard, &mp->flag);
			spin_unlock(&meta_lock);
		} else {
			spin_unlock(&meta_lock);
547
			page = find_lock_page(mapping, lblock>>l2BlocksPerPage);
Dave Kleikamp's avatar
Dave Kleikamp committed
548
			if (page) {
549
				block_invalidatepage(page, 0);
Andrew Morton's avatar
Andrew Morton committed
550
				unlock_page(page);
Dave Kleikamp's avatar
Dave Kleikamp committed
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
			}
		}
	}
}

#ifdef CONFIG_JFS_STATISTICS
int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length,
		    int *eof, void *data)
{
	int len = 0;
	off_t begin;

	len += sprintf(buffer,
		       "JFS Metapage statistics\n"
		       "=======================\n"
		       "page allocations = %d\n"
		       "page frees = %d\n"
568
		       "lock waits = %d\n",
Dave Kleikamp's avatar
Dave Kleikamp committed
569 570
		       mpStat.pagealloc,
		       mpStat.pagefree,
571
		       mpStat.lockwait);
Dave Kleikamp's avatar
Dave Kleikamp committed
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587

	begin = offset;
	*start = buffer + begin;
	len -= begin;

	if (len > length)
		len = length;
	else
		*eof = 1;

	if (len < 0)
		len = 0;

	return len;
}
#endif