[IRDA]: Avoid a label defined but not used warning in irda_init()
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / jfs / jfs_metapage.c
blob62e96be02acfcdfa87c15e9ce63a8ff1643ad18e
1 /*
2 * Copyright (C) International Business Machines Corp., 2000-2005
3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/fs.h>
21 #include <linux/mm.h>
22 #include <linux/bio.h>
23 #include <linux/init.h>
24 #include <linux/buffer_head.h>
25 #include <linux/mempool.h>
26 #include "jfs_incore.h"
27 #include "jfs_superblock.h"
28 #include "jfs_filsys.h"
29 #include "jfs_metapage.h"
30 #include "jfs_txnmgr.h"
31 #include "jfs_debug.h"
33 #ifdef CONFIG_JFS_STATISTICS
34 static struct {
35 uint pagealloc; /* # of page allocations */
36 uint pagefree; /* # of page frees */
37 uint lockwait; /* # of sleeping lock_metapage() calls */
38 } mpStat;
39 #endif
41 #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)
42 #define trylock_metapage(mp) test_and_set_bit(META_locked, &(mp)->flag)
44 static inline void unlock_metapage(struct metapage *mp)
46 clear_bit(META_locked, &mp->flag);
47 wake_up(&mp->wait);
50 static inline void __lock_metapage(struct metapage *mp)
52 DECLARE_WAITQUEUE(wait, current);
53 INCREMENT(mpStat.lockwait);
54 add_wait_queue_exclusive(&mp->wait, &wait);
55 do {
56 set_current_state(TASK_UNINTERRUPTIBLE);
57 if (metapage_locked(mp)) {
58 unlock_page(mp->page);
59 io_schedule();
60 lock_page(mp->page);
62 } while (trylock_metapage(mp));
63 __set_current_state(TASK_RUNNING);
64 remove_wait_queue(&mp->wait, &wait);
68 * Must have mp->page locked
70 static inline void lock_metapage(struct metapage *mp)
72 if (trylock_metapage(mp))
73 __lock_metapage(mp);
76 #define METAPOOL_MIN_PAGES 32
77 static struct kmem_cache *metapage_cache;
78 static mempool_t *metapage_mempool;
80 #define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE)
82 #if MPS_PER_PAGE > 1
84 struct meta_anchor {
85 int mp_count;
86 atomic_t io_count;
87 struct metapage *mp[MPS_PER_PAGE];
89 #define mp_anchor(page) ((struct meta_anchor *)page_private(page))
91 static inline struct metapage *page_to_mp(struct page *page, uint offset)
93 if (!PagePrivate(page))
94 return NULL;
95 return mp_anchor(page)->mp[offset >> L2PSIZE];
98 static inline int insert_metapage(struct page *page, struct metapage *mp)
100 struct meta_anchor *a;
101 int index;
102 int l2mp_blocks; /* log2 blocks per metapage */
104 if (PagePrivate(page))
105 a = mp_anchor(page);
106 else {
107 a = kzalloc(sizeof(struct meta_anchor), GFP_NOFS);
108 if (!a)
109 return -ENOMEM;
110 set_page_private(page, (unsigned long)a);
111 SetPagePrivate(page);
112 kmap(page);
115 if (mp) {
116 l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
117 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
118 a->mp_count++;
119 a->mp[index] = mp;
122 return 0;
125 static inline void remove_metapage(struct page *page, struct metapage *mp)
127 struct meta_anchor *a = mp_anchor(page);
128 int l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
129 int index;
131 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
133 BUG_ON(a->mp[index] != mp);
135 a->mp[index] = NULL;
136 if (--a->mp_count == 0) {
137 kfree(a);
138 set_page_private(page, 0);
139 ClearPagePrivate(page);
140 kunmap(page);
144 static inline void inc_io(struct page *page)
146 atomic_inc(&mp_anchor(page)->io_count);
149 static inline void dec_io(struct page *page, void (*handler) (struct page *))
151 if (atomic_dec_and_test(&mp_anchor(page)->io_count))
152 handler(page);
155 #else
156 static inline struct metapage *page_to_mp(struct page *page, uint offset)
158 return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL;
161 static inline int insert_metapage(struct page *page, struct metapage *mp)
163 if (mp) {
164 set_page_private(page, (unsigned long)mp);
165 SetPagePrivate(page);
166 kmap(page);
168 return 0;
171 static inline void remove_metapage(struct page *page, struct metapage *mp)
173 set_page_private(page, 0);
174 ClearPagePrivate(page);
175 kunmap(page);
178 #define inc_io(page) do {} while(0)
179 #define dec_io(page, handler) handler(page)
181 #endif
183 static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
185 struct metapage *mp = (struct metapage *)foo;
187 mp->lid = 0;
188 mp->lsn = 0;
189 mp->flag = 0;
190 mp->data = NULL;
191 mp->clsn = 0;
192 mp->log = NULL;
193 set_bit(META_free, &mp->flag);
194 init_waitqueue_head(&mp->wait);
197 static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
199 return mempool_alloc(metapage_mempool, gfp_mask);
202 static inline void free_metapage(struct metapage *mp)
204 mp->flag = 0;
205 set_bit(META_free, &mp->flag);
207 mempool_free(mp, metapage_mempool);
210 int __init metapage_init(void)
213 * Allocate the metapage structures
215 metapage_cache = kmem_cache_create("jfs_mp", sizeof(struct metapage),
216 0, 0, init_once);
217 if (metapage_cache == NULL)
218 return -ENOMEM;
220 metapage_mempool = mempool_create_slab_pool(METAPOOL_MIN_PAGES,
221 metapage_cache);
223 if (metapage_mempool == NULL) {
224 kmem_cache_destroy(metapage_cache);
225 return -ENOMEM;
228 return 0;
231 void metapage_exit(void)
233 mempool_destroy(metapage_mempool);
234 kmem_cache_destroy(metapage_cache);
237 static inline void drop_metapage(struct page *page, struct metapage *mp)
239 if (mp->count || mp->nohomeok || test_bit(META_dirty, &mp->flag) ||
240 test_bit(META_io, &mp->flag))
241 return;
242 remove_metapage(page, mp);
243 INCREMENT(mpStat.pagefree);
244 free_metapage(mp);
248 * Metapage address space operations
251 static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
252 unsigned int *len)
254 int rc = 0;
255 int xflag;
256 s64 xaddr;
257 sector_t file_blocks = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
258 inode->i_blkbits;
260 if (lblock >= file_blocks)
261 return 0;
262 if (lblock + *len > file_blocks)
263 *len = file_blocks - lblock;
265 if (inode->i_ino) {
266 rc = xtLookup(inode, (s64)lblock, *len, &xflag, &xaddr, len, 0);
267 if ((rc == 0) && *len)
268 lblock = (sector_t)xaddr;
269 else
270 lblock = 0;
271 } /* else no mapping */
273 return lblock;
276 static void last_read_complete(struct page *page)
278 if (!PageError(page))
279 SetPageUptodate(page);
280 unlock_page(page);
283 static int metapage_read_end_io(struct bio *bio, unsigned int bytes_done,
284 int err)
286 struct page *page = bio->bi_private;
288 if (bio->bi_size)
289 return 1;
291 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
292 printk(KERN_ERR "metapage_read_end_io: I/O error\n");
293 SetPageError(page);
296 dec_io(page, last_read_complete);
297 bio_put(bio);
299 return 0;
302 static void remove_from_logsync(struct metapage *mp)
304 struct jfs_log *log = mp->log;
305 unsigned long flags;
307 * This can race. Recheck that log hasn't been set to null, and after
308 * acquiring logsync lock, recheck lsn
310 if (!log)
311 return;
313 LOGSYNC_LOCK(log, flags);
314 if (mp->lsn) {
315 mp->log = NULL;
316 mp->lsn = 0;
317 mp->clsn = 0;
318 log->count--;
319 list_del(&mp->synclist);
321 LOGSYNC_UNLOCK(log, flags);
324 static void last_write_complete(struct page *page)
326 struct metapage *mp;
327 unsigned int offset;
329 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
330 mp = page_to_mp(page, offset);
331 if (mp && test_bit(META_io, &mp->flag)) {
332 if (mp->lsn)
333 remove_from_logsync(mp);
334 clear_bit(META_io, &mp->flag);
337 * I'd like to call drop_metapage here, but I don't think it's
338 * safe unless I have the page locked
341 end_page_writeback(page);
344 static int metapage_write_end_io(struct bio *bio, unsigned int bytes_done,
345 int err)
347 struct page *page = bio->bi_private;
349 BUG_ON(!PagePrivate(page));
351 if (bio->bi_size)
352 return 1;
354 if (! test_bit(BIO_UPTODATE, &bio->bi_flags)) {
355 printk(KERN_ERR "metapage_write_end_io: I/O error\n");
356 SetPageError(page);
358 dec_io(page, last_write_complete);
359 bio_put(bio);
360 return 0;
363 static int metapage_writepage(struct page *page, struct writeback_control *wbc)
365 struct bio *bio = NULL;
366 unsigned int block_offset; /* block offset of mp within page */
367 struct inode *inode = page->mapping->host;
368 unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
369 unsigned int len;
370 unsigned int xlen;
371 struct metapage *mp;
372 int redirty = 0;
373 sector_t lblock;
374 sector_t pblock;
375 sector_t next_block = 0;
376 sector_t page_start;
377 unsigned long bio_bytes = 0;
378 unsigned long bio_offset = 0;
379 unsigned int offset;
381 page_start = (sector_t)page->index <<
382 (PAGE_CACHE_SHIFT - inode->i_blkbits);
383 BUG_ON(!PageLocked(page));
384 BUG_ON(PageWriteback(page));
386 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
387 mp = page_to_mp(page, offset);
389 if (!mp || !test_bit(META_dirty, &mp->flag))
390 continue;
392 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) {
393 redirty = 1;
395 * Make sure this page isn't blocked indefinitely.
396 * If the journal isn't undergoing I/O, push it
398 if (mp->log && !(mp->log->cflag & logGC_PAGEOUT))
399 jfs_flush_journal(mp->log, 0);
400 continue;
403 clear_bit(META_dirty, &mp->flag);
404 block_offset = offset >> inode->i_blkbits;
405 lblock = page_start + block_offset;
406 if (bio) {
407 if (xlen && lblock == next_block) {
408 /* Contiguous, in memory & on disk */
409 len = min(xlen, blocks_per_mp);
410 xlen -= len;
411 bio_bytes += len << inode->i_blkbits;
412 set_bit(META_io, &mp->flag);
413 continue;
415 /* Not contiguous */
416 if (bio_add_page(bio, page, bio_bytes, bio_offset) <
417 bio_bytes)
418 goto add_failed;
420 * Increment counter before submitting i/o to keep
421 * count from hitting zero before we're through
423 inc_io(page);
424 if (!bio->bi_size)
425 goto dump_bio;
426 submit_bio(WRITE, bio);
427 bio = NULL;
428 } else {
429 set_page_writeback(page);
430 inc_io(page);
432 xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits;
433 pblock = metapage_get_blocks(inode, lblock, &xlen);
434 if (!pblock) {
435 /* Need better error handling */
436 printk(KERN_ERR "JFS: metapage_get_blocks failed\n");
437 dec_io(page, last_write_complete);
438 continue;
440 set_bit(META_io, &mp->flag);
441 len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage);
443 bio = bio_alloc(GFP_NOFS, 1);
444 bio->bi_bdev = inode->i_sb->s_bdev;
445 bio->bi_sector = pblock << (inode->i_blkbits - 9);
446 bio->bi_end_io = metapage_write_end_io;
447 bio->bi_private = page;
449 /* Don't call bio_add_page yet, we may add to this vec */
450 bio_offset = offset;
451 bio_bytes = len << inode->i_blkbits;
453 xlen -= len;
454 next_block = lblock + len;
456 if (bio) {
457 if (bio_add_page(bio, page, bio_bytes, bio_offset) < bio_bytes)
458 goto add_failed;
459 if (!bio->bi_size)
460 goto dump_bio;
462 submit_bio(WRITE, bio);
464 if (redirty)
465 redirty_page_for_writepage(wbc, page);
467 unlock_page(page);
469 return 0;
470 add_failed:
471 /* We should never reach here, since we're only adding one vec */
472 printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
473 goto skip;
474 dump_bio:
475 print_hex_dump(KERN_ERR, "JFS: dump of bio: ", DUMP_PREFIX_ADDRESS, 16,
476 4, bio, sizeof(*bio), 0);
477 skip:
478 bio_put(bio);
479 unlock_page(page);
480 dec_io(page, last_write_complete);
482 return -EIO;
485 static int metapage_readpage(struct file *fp, struct page *page)
487 struct inode *inode = page->mapping->host;
488 struct bio *bio = NULL;
489 unsigned int block_offset;
490 unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
491 sector_t page_start; /* address of page in fs blocks */
492 sector_t pblock;
493 unsigned int xlen;
494 unsigned int len;
495 unsigned int offset;
497 BUG_ON(!PageLocked(page));
498 page_start = (sector_t)page->index <<
499 (PAGE_CACHE_SHIFT - inode->i_blkbits);
501 block_offset = 0;
502 while (block_offset < blocks_per_page) {
503 xlen = blocks_per_page - block_offset;
504 pblock = metapage_get_blocks(inode, page_start + block_offset,
505 &xlen);
506 if (pblock) {
507 if (!PagePrivate(page))
508 insert_metapage(page, NULL);
509 inc_io(page);
510 if (bio)
511 submit_bio(READ, bio);
513 bio = bio_alloc(GFP_NOFS, 1);
514 bio->bi_bdev = inode->i_sb->s_bdev;
515 bio->bi_sector = pblock << (inode->i_blkbits - 9);
516 bio->bi_end_io = metapage_read_end_io;
517 bio->bi_private = page;
518 len = xlen << inode->i_blkbits;
519 offset = block_offset << inode->i_blkbits;
520 if (bio_add_page(bio, page, len, offset) < len)
521 goto add_failed;
522 block_offset += xlen;
523 } else
524 block_offset++;
526 if (bio)
527 submit_bio(READ, bio);
528 else
529 unlock_page(page);
531 return 0;
533 add_failed:
534 printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
535 bio_put(bio);
536 dec_io(page, last_read_complete);
537 return -EIO;
540 static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
542 struct metapage *mp;
543 int ret = 1;
544 unsigned int offset;
546 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
547 mp = page_to_mp(page, offset);
549 if (!mp)
550 continue;
552 jfs_info("metapage_releasepage: mp = 0x%p", mp);
553 if (mp->count || mp->nohomeok ||
554 test_bit(META_dirty, &mp->flag)) {
555 jfs_info("count = %ld, nohomeok = %d", mp->count,
556 mp->nohomeok);
557 ret = 0;
558 continue;
560 if (mp->lsn)
561 remove_from_logsync(mp);
562 remove_metapage(page, mp);
563 INCREMENT(mpStat.pagefree);
564 free_metapage(mp);
566 return ret;
569 static void metapage_invalidatepage(struct page *page, unsigned long offset)
571 BUG_ON(offset);
573 BUG_ON(PageWriteback(page));
575 metapage_releasepage(page, 0);
578 const struct address_space_operations jfs_metapage_aops = {
579 .readpage = metapage_readpage,
580 .writepage = metapage_writepage,
581 .sync_page = block_sync_page,
582 .releasepage = metapage_releasepage,
583 .invalidatepage = metapage_invalidatepage,
584 .set_page_dirty = __set_page_dirty_nobuffers,
587 struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
588 unsigned int size, int absolute,
589 unsigned long new)
591 int l2BlocksPerPage;
592 int l2bsize;
593 struct address_space *mapping;
594 struct metapage *mp = NULL;
595 struct page *page;
596 unsigned long page_index;
597 unsigned long page_offset;
599 jfs_info("__get_metapage: ino = %ld, lblock = 0x%lx, abs=%d",
600 inode->i_ino, lblock, absolute);
602 l2bsize = inode->i_blkbits;
603 l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
604 page_index = lblock >> l2BlocksPerPage;
605 page_offset = (lblock - (page_index << l2BlocksPerPage)) << l2bsize;
606 if ((page_offset + size) > PAGE_CACHE_SIZE) {
607 jfs_err("MetaData crosses page boundary!!");
608 jfs_err("lblock = %lx, size = %d", lblock, size);
609 dump_stack();
610 return NULL;
612 if (absolute)
613 mapping = JFS_SBI(inode->i_sb)->direct_inode->i_mapping;
614 else {
616 * If an nfs client tries to read an inode that is larger
617 * than any existing inodes, we may try to read past the
618 * end of the inode map
620 if ((lblock << inode->i_blkbits) >= inode->i_size)
621 return NULL;
622 mapping = inode->i_mapping;
625 if (new && (PSIZE == PAGE_CACHE_SIZE)) {
626 page = grab_cache_page(mapping, page_index);
627 if (!page) {
628 jfs_err("grab_cache_page failed!");
629 return NULL;
631 SetPageUptodate(page);
632 } else {
633 page = read_mapping_page(mapping, page_index, NULL);
634 if (IS_ERR(page) || !PageUptodate(page)) {
635 jfs_err("read_mapping_page failed!");
636 return NULL;
638 lock_page(page);
641 mp = page_to_mp(page, page_offset);
642 if (mp) {
643 if (mp->logical_size != size) {
644 jfs_error(inode->i_sb,
645 "__get_metapage: mp->logical_size != size");
646 jfs_err("logical_size = %d, size = %d",
647 mp->logical_size, size);
648 dump_stack();
649 goto unlock;
651 mp->count++;
652 lock_metapage(mp);
653 if (test_bit(META_discard, &mp->flag)) {
654 if (!new) {
655 jfs_error(inode->i_sb,
656 "__get_metapage: using a "
657 "discarded metapage");
658 discard_metapage(mp);
659 goto unlock;
661 clear_bit(META_discard, &mp->flag);
663 } else {
664 INCREMENT(mpStat.pagealloc);
665 mp = alloc_metapage(GFP_NOFS);
666 mp->page = page;
667 mp->flag = 0;
668 mp->xflag = COMMIT_PAGE;
669 mp->count = 1;
670 mp->nohomeok = 0;
671 mp->logical_size = size;
672 mp->data = page_address(page) + page_offset;
673 mp->index = lblock;
674 if (unlikely(insert_metapage(page, mp))) {
675 free_metapage(mp);
676 goto unlock;
678 lock_metapage(mp);
681 if (new) {
682 jfs_info("zeroing mp = 0x%p", mp);
683 memset(mp->data, 0, PSIZE);
686 unlock_page(page);
687 jfs_info("__get_metapage: returning = 0x%p data = 0x%p", mp, mp->data);
688 return mp;
690 unlock:
691 unlock_page(page);
692 return NULL;
695 void grab_metapage(struct metapage * mp)
697 jfs_info("grab_metapage: mp = 0x%p", mp);
698 page_cache_get(mp->page);
699 lock_page(mp->page);
700 mp->count++;
701 lock_metapage(mp);
702 unlock_page(mp->page);
705 void force_metapage(struct metapage *mp)
707 struct page *page = mp->page;
708 jfs_info("force_metapage: mp = 0x%p", mp);
709 set_bit(META_forcewrite, &mp->flag);
710 clear_bit(META_sync, &mp->flag);
711 page_cache_get(page);
712 lock_page(page);
713 set_page_dirty(page);
714 write_one_page(page, 1);
715 clear_bit(META_forcewrite, &mp->flag);
716 page_cache_release(page);
719 void hold_metapage(struct metapage *mp)
721 lock_page(mp->page);
724 void put_metapage(struct metapage *mp)
726 if (mp->count || mp->nohomeok) {
727 /* Someone else will release this */
728 unlock_page(mp->page);
729 return;
731 page_cache_get(mp->page);
732 mp->count++;
733 lock_metapage(mp);
734 unlock_page(mp->page);
735 release_metapage(mp);
738 void release_metapage(struct metapage * mp)
740 struct page *page = mp->page;
741 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag);
743 BUG_ON(!page);
745 lock_page(page);
746 unlock_metapage(mp);
748 assert(mp->count);
749 if (--mp->count || mp->nohomeok) {
750 unlock_page(page);
751 page_cache_release(page);
752 return;
755 if (test_bit(META_dirty, &mp->flag)) {
756 set_page_dirty(page);
757 if (test_bit(META_sync, &mp->flag)) {
758 clear_bit(META_sync, &mp->flag);
759 write_one_page(page, 1);
760 lock_page(page); /* write_one_page unlocks the page */
762 } else if (mp->lsn) /* discard_metapage doesn't remove it */
763 remove_from_logsync(mp);
765 /* Try to keep metapages from using up too much memory */
766 drop_metapage(page, mp);
768 unlock_page(page);
769 page_cache_release(page);
772 void __invalidate_metapages(struct inode *ip, s64 addr, int len)
774 sector_t lblock;
775 int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits;
776 int BlocksPerPage = 1 << l2BlocksPerPage;
777 /* All callers are interested in block device's mapping */
778 struct address_space *mapping =
779 JFS_SBI(ip->i_sb)->direct_inode->i_mapping;
780 struct metapage *mp;
781 struct page *page;
782 unsigned int offset;
785 * Mark metapages to discard. They will eventually be
786 * released, but should not be written.
788 for (lblock = addr & ~(BlocksPerPage - 1); lblock < addr + len;
789 lblock += BlocksPerPage) {
790 page = find_lock_page(mapping, lblock >> l2BlocksPerPage);
791 if (!page)
792 continue;
793 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
794 mp = page_to_mp(page, offset);
795 if (!mp)
796 continue;
797 if (mp->index < addr)
798 continue;
799 if (mp->index >= addr + len)
800 break;
802 clear_bit(META_dirty, &mp->flag);
803 set_bit(META_discard, &mp->flag);
804 if (mp->lsn)
805 remove_from_logsync(mp);
807 unlock_page(page);
808 page_cache_release(page);
812 #ifdef CONFIG_JFS_STATISTICS
813 int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length,
814 int *eof, void *data)
816 int len = 0;
817 off_t begin;
819 len += sprintf(buffer,
820 "JFS Metapage statistics\n"
821 "=======================\n"
822 "page allocations = %d\n"
823 "page frees = %d\n"
824 "lock waits = %d\n",
825 mpStat.pagealloc,
826 mpStat.pagefree,
827 mpStat.lockwait);
829 begin = offset;
830 *start = buffer + begin;
831 len -= begin;
833 if (len > length)
834 len = length;
835 else
836 *eof = 1;
838 if (len < 0)
839 len = 0;
841 return len;
843 #endif