Subject: afs/fs/cachefs vjournal.c,1.3,1.4 super.c,1.35,1.36 status.c,1.6,1.7 rootdir.c,1.11,1.12 recycling.c,1.22,1.23 main.c,1.15,1.16 kcachefsd.c,1.12,1.13 kcachefs_jnld.c,1.5,1.6 journal.c,1.36,1.37 io.c,1.14,1.15 interface.c,1.13,1.14 inode.c,1.20,1.21 index.c,1.23,1.24 dump-journal.c,1.10,1.11 cachetest-main.c,1.11,1.12 cachefs-layout.h,1.25,1.26 cachefs-int.h,1.36,1.37 block.c,1.7,1.8 aops.c,1.38,1.39

From: [email-masked]
Date: Fri, 04 Jul 2003 10:04:46 +0100

Update of /home/cvs/afs/fs/cachefs
In directory phoenix.infradead.org:/tmp/cvs-serv9327/fs/cachefs

Modified Files:
	vjournal.c super.c status.c rootdir.c recycling.c main.c 
	kcachefsd.c kcachefs_jnld.c journal.c io.c interface.c inode.c 
	index.c dump-journal.c cachetest-main.c cachefs-layout.h 
	cachefs-int.h block.c aops.c 
Log Message:
manoeuvered the source towards hch-compliance (CodingStyle)
fixed a couple of bugs

Index: vjournal.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/vjournal.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vjournal.c	5 Jun 2003 08:27:39 -0000	1.3
+++ vjournal.c	4 Jul 2003 09:04:43 -0000	1.4
@@ -22,24 +22,24 @@
  */
 int cachefs_vj_alloc(struct cachefs_transaction *trans, struct cachefs_inode *inode)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct cachefs_vj_entry *vjentry;
 	struct cachefs_super *super;
 	cachefs_blockix_t bix;
 	int slot, ret;
 
+	DECLARE_WAITQUEUE(myself,current);
+
 	_enter("");
 
 	super = trans->super;
 
-	vjentry = kmalloc(sizeof(*vjentry),GFP_KERNEL);
+	vjentry = kmalloc(sizeof(*vjentry), GFP_KERNEL);
 	if (!vjentry) {
 		_leave(" = -ENOMEM");
 		return -ENOMEM;
 	}
 
-	memset(vjentry,0,sizeof(vjentry));
+	memset(vjentry, 0, sizeof(vjentry));
 	INIT_LIST_HEAD(&vjentry->link);
 
 	vjentry->ino = inode->vfs_inode.i_ino;
@@ -47,11 +47,11 @@
 	/* now allocate a slot when one becomes available */
 	spin_lock(&super->vjnl_lock);
 
-	if (super->vjnl_count==0) {
+	if (super->vjnl_count == 0) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&super->vjnl_alloc_wq,&myself);
+		add_wait_queue(&super->vjnl_alloc_wq, &myself);
 
-		while (super->vjnl_count!=0 && !signal_pending(current)) {
+		while (super->vjnl_count == 0 && !signal_pending(current)) {
 			spin_unlock(&super->vjnl_lock);
 			schedule();
 			spin_lock(&super->vjnl_lock);
@@ -59,24 +59,27 @@
 		}
 
 		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&super->vjnl_alloc_wq,&myself);
+		remove_wait_queue(&super->vjnl_alloc_wq, &myself);
 
 		ret = -EINTR;
 		if (signal_pending(current))
 			goto error_free;
 	}
 
-	slot = find_first_zero_bit(super->vjnl_map,CACHEFS_ONDISC_VJNL_ENTS);
-	if (slot<0 || slot>=CACHEFS_ONDISC_VJNL_ENTS)
+	slot = find_first_zero_bit(super->vjnl_map, CACHEFS_ONDISC_VJNL_ENTS);
+	if (slot < 0 || slot >= CACHEFS_ONDISC_VJNL_ENTS) {
+		printk("CacheFS: vjnl_count=%u slot=%d\n",
+		       super->vjnl_count, slot);
 		BUG();
+	}
 
-	set_bit(slot,super->vjnl_map);
+	set_bit(slot, super->vjnl_map);
 	super->vjnl_count--;
 
 	spin_unlock(&super->vjnl_lock);
 
 	/* got a slot - now find the block and page holding it */
-	_debug("VJ slot %d",slot);
+	_debug("VJ slot %d", slot);
 
 	vjentry->vslot	= slot;
 	vjentry->ventry	= slot % CACHEFS_ONDISC_VJNL_ENTPERPAGE;
@@ -84,13 +87,14 @@
 	bix = slot / CACHEFS_ONDISC_VJNL_ENTPERPAGE;
 	bix += super->layout->bix_vjournal;
 
-	ret = cachefs_block_read(super,NULL,bix,0,&vjentry->vblock,&vjentry->vpage);
-	if (ret<0)
+	ret = cachefs_block_read(super, NULL, bix, 0,
+				 &vjentry->vblock, &vjentry->vpage);
+	if (ret < 0)
 		goto error_clearbit;
 
 	trans->vjentry = vjentry;
 
-	cachefs_trans_affects_block(trans,vjentry->vblock,vjentry->ventry,
+	cachefs_trans_affects_block(trans, vjentry->vblock, vjentry->ventry,
 				    sizeof(struct cachefs_ondisc_validity_journal));
 
 	_leave(" = 0");
@@ -98,13 +102,14 @@
 
  error_clearbit:
 	spin_lock(&super->vjnl_lock);
-	clear_bit(slot,super->vjnl_map);
+	clear_bit(slot, super->vjnl_map);
 	super->vjnl_count++;
+	wake_up(&super->vjnl_alloc_wq);
 
  error_free:
 	spin_unlock(&super->vjnl_lock);
 	kfree(vjentry);
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end cachefs_vj_alloc() */
@@ -119,7 +124,7 @@
 	_enter("");
 
 	spin_lock(&super->vjnl_lock);
-	clear_bit(vjentry->vslot,super->vjnl_map);
+	clear_bit(vjentry->vslot, super->vjnl_map);
 	super->vjnl_count++;
 	spin_unlock(&super->vjnl_lock);
 
@@ -142,13 +147,14 @@
 	struct cachefs_super *super;
 
 	_enter("{vs=%u pg={%u}+%u up={%u}+%u",
-	       vjentry->vslot,vjentry->ino,vjentry->pgnum,vjentry->upblock,vjentry->upentry);
+	       vjentry->vslot, vjentry->ino, vjentry->pgnum,
+	       vjentry->upblock, vjentry->upentry);
 
 	block->vjentry = NULL;
 	super = block->super;
 
 	spin_lock(&super->vjnl_lock);
-	list_move_tail(&vjentry->link,&super->vjnl_writtenq);
+	list_move_tail(&vjentry->link, &super->vjnl_writtenq);
 	spin_unlock(&super->vjnl_lock);
 
 	wake_up(&super->dmn_sleepq);
@@ -165,12 +171,13 @@
 	struct cachefs_super *super;
 
 	_enter("{vs=%u pg={%u}+%u up={%u}+%u",
-	       vjentry->vslot,vjentry->ino,vjentry->pgnum,vjentry->upblock,vjentry->upentry);
+	       vjentry->vslot, vjentry->ino, vjentry->pgnum,
+	       vjentry->upblock, vjentry->upentry);
 
 	super = vjentry->vblock->super;
 
 	spin_lock(&super->vjnl_lock);
-	list_move_tail(&vjentry->link,&super->vjnl_unallocq);
+	list_move_tail(&vjentry->link, &super->vjnl_unallocq);
 	spin_unlock(&super->vjnl_lock);
 
 	wake_up(&super->dmn_sleepq);
@@ -195,10 +202,12 @@
 
 	/* we can access the next pointer without a lock because we know we're
 	 * the only ones going to change it now */
-	vjentry = list_entry(super->vjnl_writtenq.next,struct cachefs_vj_entry,link);
+	vjentry = list_entry(super->vjnl_writtenq.next,
+			     struct cachefs_vj_entry,
+			     link);
 
 	ret = -ENOMEM;
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans)
 		goto error;
 
@@ -207,15 +216,16 @@
 	trans->jentry->auxmark	= vjentry->vslot;
 	trans->jentry->block	= vjentry->bix;
 
-	cachefs_trans_affects_block(trans,vjentry->vblock,vjentry->ventry,
-				    sizeof(struct cachefs_ondisc_validity_journal));
+	cachefs_trans_affects_block(
+		trans, vjentry->vblock, vjentry->ventry,
+		sizeof(struct cachefs_ondisc_validity_journal));
 
 	/* mark the journal and then make modifications */
 	ret = cachefs_trans_mark(trans);
-	if (ret<0)
+	if (ret < 0)
 		goto error_free;
 
-	cachefs_block_modify(super,vjentry->vblock,&vjentry->vpage);
+	cachefs_block_modify(super, vjentry->vblock, &vjentry->vpage);
 	memset(kmap(vjentry->vpage) + vjentry->ventry, 0,
 	       sizeof(struct cachefs_ondisc_validity_journal));
 	kunmap(vjentry->vpage);
@@ -226,13 +236,13 @@
 	list_del_init(&vjentry->link);
 	spin_unlock(&super->vjnl_lock);
 
-	cachefs_vj_release(super,vjentry);
+	cachefs_vj_release(super, vjentry);
 	_leave("");
 	return;
 
  error_free:
 	cachefs_trans_put(trans);
  error:
-	_leave(" [error %d]",ret);
+	_leave(" [error %d]", ret);
 
 } /* end cachefs_vj_note_write_completion() */

Index: super.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/super.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- super.c	1 Jul 2003 17:45:22 -0000	1.35
+++ super.c	4 Jul 2003 09:04:43 -0000	1.36
@@ -23,10 +23,12 @@
 
 #define CACHEFS_FS_MAGIC 0x43414653 /* 'CAFS' */
 
-static void cachefs_i_init_once(void *foo, kmem_cache_t *cachep, unsigned long flags);
+static void cachefs_i_init_once(void *foo, kmem_cache_t *cachep,
+				unsigned long flags);
 
 static struct super_block *cachefs_get_sb(struct file_system_type *fs_type,
-					  int flags, const char *dev_name, void *data);
+					  int flags, const char *dev_name,
+					  void *data);
 
 static struct inode *cachefs_alloc_inode(struct super_block *sb);
 static void cachefs_destroy_inode(struct inode *inode);
@@ -76,8 +78,9 @@
 						 cachefs_i_init_once,
 						 NULL);
 	if (!cachefs_inode_cachep) {
-		printk(KERN_NOTICE "CacheFS: Failed to allocate inode cache\n");
-		kleave(" = %d",ret);
+		printk(KERN_NOTICE
+		       "CacheFS: Failed to allocate inode cache\n");
+		kleave(" = %d", ret);
 		return ret;
 	}
 
@@ -85,7 +88,7 @@
 	ret = register_filesystem(&cachefs_fs_type);
 	if (ret<0) {
 		kmem_cache_destroy(cachefs_inode_cachep);
-		kleave(" = %d",ret);
+		kleave(" = %d", ret);
 		return ret;
 	}
 
@@ -120,12 +123,13 @@
 {
 	struct super_block *sb;
 
-	_enter(",,%s,%p",dev_name,options);
+	_enter(",,%s,%p", dev_name, options);
 
 	/* allocate a device superblock */
-	sb = get_sb_bdev(fs_type,flags,dev_name,options,cachefs_fill_super);
+	sb = get_sb_bdev(fs_type, flags, dev_name, options,
+			 cachefs_fill_super);
 
-	_leave(" = %p",sb);
+	_leave(" = %p", sb);
 	return sb;
 } /* end cachefs_get_sb() */
 
@@ -133,22 +137,23 @@
 /*
  * BIO operation completed
  */
-static int cachefs_bio_completion(struct bio *bio, unsigned int bytes_done, int error)
+static int cachefs_bio_completion(struct bio *bio, unsigned int bytes_done,
+				  int error)
 {
 	unsigned short loop;
 
-	_enter("%p{%u},%u,%d",bio,bio->bi_size,bytes_done,error);
+	_enter("%p{%u},%u,%d", bio, bio->bi_size, bytes_done, error);
 
-	if (bio->bi_size>0) {
+	if (bio->bi_size > 0) {
 		_leave(" = 1");
 		return 1;
 	}
 
-	for (loop=0; loop<bio->bi_vcnt; loop++) {
+	for (loop = 0; loop < bio->bi_vcnt; loop++) {
 		struct page *page = bio->bi_io_vec[loop].bv_page;
 
 		if (PageLocked(page)) {
-			if (test_bit(BIO_UPTODATE,&bio->bi_flags))
+			if (test_bit(BIO_UPTODATE, &bio->bi_flags))
 				SetPageUptodate(page);
 			else
 				SetPageError(page);
@@ -171,14 +176,14 @@
 	struct bio *bio;
 	int loop;
 
-	if (*count>BIO_MAX_PAGES)
+	if (*count > BIO_MAX_PAGES)
 		*count = BIO_MAX_PAGES;
 
-	bio = bio_alloc(GFP_NOFS,*count);
+	bio = bio_alloc(GFP_NOFS, *count);
 	if (!bio)
 		return -ENOMEM;
 
-	_enter("{bdev=%p},%p,%u,%u,%d",sb->s_bdev,page,bix,*count,rw);
+	_enter("{bdev=%p},%p,%u,%u,%d", sb->s_bdev, page, bix, *count, rw);
 
 	SetPageLocked(page);
 
@@ -188,11 +193,11 @@
 	bio->bi_private	= NULL;
 
 	for (loop=0; loop<*count; loop++)
-		if (!bio_add_page(bio,page,PAGE_SIZE,0))
+		if (!bio_add_page(bio, page, PAGE_SIZE, 0))
 			break;
 	*count = loop;
 
-	submit_bio(rw,bio);
+	submit_bio(rw, bio);
 
 	_leave(" = 0");
 	return 0;
@@ -223,24 +228,27 @@
 		return -EROFS;
 	}
 
-	/* we want the block size to be at least as big as the size of a journal entry */
-	if (!sb_min_blocksize(sb,sizeof(struct cachefs_ondisc_update_journal))) {
+	/* we want the block size to be at least as big as the size of a
+	 * journal entry */
+	if (!sb_min_blocksize(sb,
+			      sizeof(struct cachefs_ondisc_update_journal))) {
 		printk("CacheFS: unable to set blocksize\n");
 		return -EIO;
 	}
 
-	kdebug("blockdev %u,%u",MAJOR(sb->s_dev),MINOR(sb->s_dev));
-	kdebug("blockdev size %LuMb",sb->s_bdev->bd_inode->i_size/1024/1024);
+	kdebug("blockdev %u,%u", MAJOR(sb->s_dev), MINOR(sb->s_dev));
+	kdebug("blockdev size %LuMb",
+	       sb->s_bdev->bd_inode->i_size / 1024 / 1024);
 
 	/* allocate a superblock info record */
 	ret = -ENOMEM;
-	super = kmalloc(sizeof(*super),GFP_KERNEL);
+	super = kmalloc(sizeof(*super), GFP_KERNEL);
 	if (!super)
 		goto error;
 
-	memset(super,0,sizeof(*super));
+	memset(super, 0, sizeof(*super));
 
-	super->rcm_imm_buf = (unsigned*) get_zeroed_page(GFP_KERNEL);
+	super->rcm_imm_buf = (unsigned *) get_zeroed_page(GFP_KERNEL);
 	if (!super->rcm_imm_buf)
 		goto error;
 
@@ -254,7 +262,7 @@
 
 	super->vjnl_count = CACHEFS_ONDISC_VJNL_ENTS;
 
-	srch = kmalloc(sizeof(*srch),GFP_KERNEL);
+	srch = kmalloc(sizeof(*srch), GFP_KERNEL);
 	if (!srch)
 		goto error;
 
@@ -313,17 +321,17 @@
 	init_waitqueue_head(&super->dmn_sleepq);
 
 	/* create the linear-mapping inode */
-	ret = cachefs_iget(super,CACHEFS_INO_MISC,&inode2);
-	if (ret<0)
+	ret = cachefs_iget(super, CACHEFS_INO_MISC, &inode2);
+	if (ret < 0)
 		goto error;
 	super->imisc = &inode2->vfs_inode;
 
 	/* read the superblock from disc */
-	ret = cachefs_block_read(super,NULL,0,0,NULL,&page);
-	if (ret<0)
+	ret = cachefs_block_read(super, NULL, 0, 0, NULL, &page);
+	if (ret < 0)
 		goto error;
 
-	set_bit(CACHEFS_BLOCK_NOCOW,&__cachefs_get_page_block(page)->flags);
+	set_bit(CACHEFS_BLOCK_NOCOW, &__cachefs_get_page_block(page)->flags);
 	super->layout = page_address(page);
 
 	/* examine the on-disc superblock record */
@@ -362,7 +370,7 @@
 		 ) {
 		printk("CacheFS: Found uninitialised cache\n");
 		ret = cachefs_initialise_blockdev(super);
-		if (ret<0)
+		if (ret < 0)
 			goto error;
 	}
 	else {
@@ -375,27 +383,27 @@
 	super->ujnl_jsof <<= (PAGE_SHIFT - super->sb->s_blocksize_bits);
 
 	/* get and retain various meta-data inodes */
-	ret = cachefs_iget(super,CACHEFS_INO_METADATA,&super->imetadata);
-	if (ret<0)
+	ret = cachefs_iget(super, CACHEFS_INO_METADATA, &super->imetadata);
+	if (ret < 0)
 		goto error;
 
 	if (jnlreplay) {
 		ret = cachefs_ujnl_replay(super);
-		if (ret<0)
+		if (ret < 0)
 			goto error;
 	}
 
 	kcachefs_jnld_add_super(super);
 
 	/* start the manager daemon */
-	ret = kernel_thread(kcachefsd,super,0);
+	ret = kernel_thread(kcachefsd, super, 0);
 	if (ret<0)
 		goto error;
 	wait_for_completion(&super->dmn_alive);
 
 	/* allocate the root inode and dentry */
-	ret = cachefs_iget(super,CACHEFS_INO_ROOTDIR,&inode);
-	if (ret<0)
+	ret = cachefs_iget(super, CACHEFS_INO_ROOTDIR, &inode);
+	if (ret < 0)
 		goto error;
 
 	ret = -ENOMEM;
@@ -405,9 +413,9 @@
 
 	sb->s_root = root;
 
-	cachefs_add_cache((struct cachefs_super *)sb->s_fs_info,srch);
+	cachefs_add_cache((struct cachefs_super *) sb->s_fs_info,srch);
 
-	kleave(" = 0 [super=%p]",super);
+	kleave(" = 0 [super=%p]", super);
 	return 0;
 
  error:
@@ -423,9 +431,9 @@
 
 		cachefs_put_page(super->alloc_next);
 		cachefs_put_page(super->recycle_node);
-		if (super->rcm_atm_list)	free_page((unsigned long)super->rcm_atm_list);
-		if (super->rcm_imm_buf)		free_page((unsigned long)super->rcm_imm_buf);
-		if (super->vjnl_map)		free_page((unsigned long)super->vjnl_map);
+		free_page((unsigned long) super->rcm_atm_list);
+		free_page((unsigned long) super->rcm_imm_buf);
+		free_page((unsigned long) super->vjnl_map);
 
 		kcachefs_jnld_remove_super(super);
 	}
@@ -435,22 +443,21 @@
 		dbgfree(page_address(page));
 		cachefs_put_page(page);
 	}
-	if (root)
-		dput(root);
 
+	dput(root);
 	cachefs_iput(inode);
 
 	if (super) {
 		cachefs_iput(super->imetadata);
-		if (super->imisc)
-			iput(super->imisc);
+		iput(super->imisc);
 		dbgfree(super);
 		kfree(super);
 	}
+
 	sb->s_root = NULL;
 	sb->s_fs_info = NULL;
 
-	kleave(" = %d",ret);
+	kleave(" = %d", ret);
 	return ret;
 } /* end cachefs_fill_super() */
 
@@ -468,7 +475,7 @@
 	int ret;
 
 	kenter("");
-	set_bit(CACHEFS_SUPER_INIT_BLKDEV,&super->flags);
+	set_bit(CACHEFS_SUPER_INIT_BLKDEV, &super->flags);
 
 	page = alloc_page(GFP_KERNEL);
 	if (!page)
@@ -477,18 +484,20 @@
 
 	/* work out how big the cache is (we use 32-bit block index numbers) */
 	nblocks = super->sb->s_bdev->bd_inode->i_size;
-	do_div(nblocks,PAGE_SIZE);
-	if (nblocks>UINT_MAX)
+	do_div(nblocks, PAGE_SIZE);
+	if (nblocks > UINT_MAX)
 		nblocks = UINT_MAX;
-	if (nblocks<256) {
+	if (nblocks < 256) {
 		printk("CacheFS: cache must be at least 256 blocks in size\n");
 		__free_page(page);
 		return -ENOSPC;
 	}
 
 	/* determine the layout */
-	memset(super->layout,0,PAGE_SIZE);
-	memcpy(super->layout->magic,CACHEFS_SUPER_MAGIC,sizeof(super->layout->magic));
+	memset(super->layout, 0, PAGE_SIZE);
+	memcpy(super->layout->magic,
+	       CACHEFS_SUPER_MAGIC,
+	       sizeof(super->layout->magic));
 
 	super->layout->endian		= CACHEFS_SUPER_ENDIAN;
 	super->layout->version		= CACHEFS_SUPER_VERSION;
@@ -496,30 +505,44 @@
 	super->layout->metadata_size	= super->sb->s_blocksize;
 	super->layout->metadata_bits	= super->sb->s_blocksize_bits;
 	super->layout->ujnl_rsize	= super->sb->s_blocksize;
-	super->layout->ujnl_recperblk	= super->layout->bsize / super->layout->ujnl_rsize;
+	super->layout->ujnl_recperblk	=
+		super->layout->bsize / super->layout->ujnl_rsize;
 
 	ndirect = 1;
-	qty = super->layout->ujnl_rsize * CACHEFS_ONDISC_UJNL_NUMENTS / super->layout->bsize;
+	qty = super->layout->ujnl_rsize * CACHEFS_ONDISC_UJNL_NUMENTS;
+	qty /= super->layout->bsize;
 
 	super->layout->bix_ujournal	= 1 + ndirect;
-	super->layout->bix_vjournal	= super->layout->bix_ujournal  + qty;
-	super->layout->bix_wbjournal	= super->layout->bix_vjournal  + CACHEFS_ONDISC_VJNL_SIZE;
-	super->layout->bix_cache	= super->layout->bix_wbjournal + CACHEFS_ONDISC_WBJNL_SIZE;
-	super->layout->bix_unready	= super->layout->bix_cache;
-	super->layout->bix_end		= nblocks;
+	super->layout->bix_vjournal =
+		super->layout->bix_ujournal  + qty;
+	super->layout->bix_wbjournal =
+		super->layout->bix_vjournal  + CACHEFS_ONDISC_VJNL_SIZE;
+	super->layout->bix_cache =
+		super->layout->bix_wbjournal + CACHEFS_ONDISC_WBJNL_SIZE;
+	super->layout->bix_unready =
+		super->layout->bix_cache;
+	super->layout->bix_end
+		= nblocks;
 
 	printk("CacheFS: 00000000 super block\n");
-	printk("CacheFS: 00000001 initial vnodes (%u blocks)\n",ndirect);
+	printk("CacheFS: 00000001 initial vnodes (%u blocks)\n", ndirect);
 
 	printk("CacheFS: %08x update journal (%u recs of %u/%ub)\n",
-	       super->layout->bix_ujournal,qty,
+	       super->layout->bix_ujournal,
+	       qty,
 	       sizeof(struct cachefs_ondisc_update_journal),
 	       super->layout->ujnl_rsize);
 
-	printk("CacheFS: %08x validity journal\n",	super->layout->bix_vjournal);
-	printk("CacheFS: %08x writeback journal\n",	super->layout->bix_wbjournal);
-	printk("CacheFS: %08x data cache\n",		super->layout->bix_cache);
-	printk("CacheFS: %08x end\n",			super->layout->bix_end);
+	printk("CacheFS: %08x validity journal\n",
+	       super->layout->bix_vjournal);
+	printk("CacheFS: %08x writeback journal (%u recs of %ub)\n",
+	       super->layout->bix_wbjournal,
+	       super->vjnl_count,
+	       sizeof(struct cachefs_ondisc_validity_journal));
+	printk("CacheFS: %08x data cache\n",
+	       super->layout->bix_cache);
+	printk("CacheFS: %08x end\n",
+	       super->layout->bix_end);
 
 	/* initialise the metadata entry for the metadata file itself */
 	memset(data,0,PAGE_SIZE);
@@ -532,7 +555,8 @@
 
 	metadata =
 		(struct cachefs_ondisc_metadata *)
-		(data + (CACHEFS_INO_METADATA << super->layout->metadata_bits));
+		(data + (CACHEFS_INO_METADATA <<
+			 super->layout->metadata_bits));
 
 	metadata->header.state	= CACHEFS_ONDISC_INDEX_ACTIVE;
 	metadata->size		= PAGE_SIZE;
@@ -544,15 +568,16 @@
 	metadata->index_dsize	-= sizeof(struct cachefs_ondisc_index_entry);
 	metadata->index_esize	= super->layout->metadata_size;
 
-	strncpy(metadata->index_type,".METADAT",9);
+	strncpy(metadata->index_type, ".METADAT", 9);
 
-	for (tmp=0; tmp<ndirect; tmp++)
-		metadata->direct[tmp] = tmp+1; /* point to itself */
+	for (tmp = 0; tmp < ndirect; tmp++)
+		metadata->direct[tmp] = tmp + 1; /* point to itself */
 
 	/* initialise the metadata entry for the FSDEF catalogue */
 	metadata =
 		(struct cachefs_ondisc_metadata *)
-		(data + (CACHEFS_INO_FSDEF_CATALOGUE << super->layout->metadata_bits));
+		(data + (CACHEFS_INO_FSDEF_CATALOGUE <<
+			 super->layout->metadata_bits));
 
 	metadata->header.state	= CACHEFS_ONDISC_INDEX_ACTIVE;
 	metadata->size		= 0;
@@ -565,21 +590,11 @@
 	metadata->index_esize	+= metadata->index_dsize;
 	metadata->index_keys[0]	= CACHEFS_ONDISC_INDEXKEY_ASCIIZ | 24;
 
-	strncpy(metadata->index_type,".FSDEF",8);
-
-#if 1 /* TODO: remove */
-	metadata =
-		(struct cachefs_ondisc_metadata *)
-		(data + (CACHEFS_INO_WIBBLE << super->layout->metadata_bits));
-
-	metadata->header.state	= CACHEFS_ONDISC_INDEX_ACTIVE;
-	metadata->freelink	= UINT_MAX;
-	metadata->mtime		= CURRENT_TIME.tv_sec;
-#endif
+	strncpy(metadata->index_type, ".FSDEF", 8);
 
 	tmp = 1;
-	ret = cachefs_bio_submit(super->sb,page,1,&tmp,WRITE);
-	if (ret<0) {
+	ret = cachefs_bio_submit(super->sb, page, 1, &tmp, WRITE);
+	if (ret < 0) {
 		__free_page(page);
 		return ret;
 	}
@@ -592,24 +607,25 @@
 	}
 
 	/* clear the journals and other metafiles */
-	memset(data,0,PAGE_SIZE);
+	memset(data, 0, PAGE_SIZE);
 
 	bix = 2;
-	while (bix<super->layout->bix_cache) {
+	while (bix < super->layout->bix_cache) {
 		qty = super->layout->bix_cache - bix;
 
-		kdebug("clearing blocks %u-%u",bix,bix+qty-1);
+		kdebug("clearing blocks %u-%u", bix, bix + qty - 1);
 
 		tmp = qty;
-		ret = cachefs_bio_submit(super->sb,page,bix,&tmp,WRITE);
-		if (ret<0) {
+		ret = cachefs_bio_submit(super->sb, page, bix, &tmp, WRITE);
+		if (ret < 0) {
 			__free_page(page);
 			return ret;
 		}
 
 		wait_on_page_locked(page);
 		if (PageError(page)) {
-			printk("CacheFS: failed to write blocks %u-%u\n",bix,bix+qty-1);
+			printk("CacheFS: failed to write blocks %u-%u\n",
+			       bix, bix + qty - 1);
 			__free_page(page);
 			return -EIO;
 		}
@@ -622,12 +638,13 @@
 	/* write the superblock last */
 	kdebug("writing superblock");
 	tmp = 1;
-	ret = cachefs_bio_submit(super->sb,virt_to_page(super->layout),0,&tmp,WRITE);
-	if (ret<0)
+	ret = cachefs_bio_submit(super->sb, virt_to_page(super->layout), 0,
+				 &tmp, WRITE);
+	if (ret < 0)
 		return ret;
 	wait_on_page_locked(page);
 
-	clear_bit(CACHEFS_SUPER_INIT_BLKDEV,&super->flags);
+	clear_bit(CACHEFS_SUPER_INIT_BLKDEV, &super->flags);
 	kleave(" = 0");
 	return 0;
 } /* end cachefs_initialise_blockdev() */
@@ -656,7 +673,8 @@
 	buf->f_ffree	= tmp;
 	buf->f_namelen	= NAME_MAX;
 
-	if (super->recycle_room>0) buf->f_bfree++;
+	if (super->recycle_room > 0)
+		buf->f_bfree++;
 
 	return 0;
 } /* end cachefs_statfs() */
@@ -677,19 +695,21 @@
 
 	page = alloc_page(GFP_KERNEL);
 	if (!page) {
-		printk("CacheFS: unable to write superblock to disc (ENOMEM)\n");
+		printk("CacheFS:"
+		       " unable to write superblock to disc (ENOMEM)\n");
 		return;
 	}
 
 	data = kmap(page);
-	memset(data,0,PAGE_SIZE);
-	memcpy(data,&super->layout,sizeof(super->layout));
+	memset(data, 0, PAGE_SIZE);
+	memcpy(data, &super->layout, sizeof(super->layout));
 	kunmap(page);
 
 	tmp = 1;
-	ret = cachefs_bio_submit(super->sb,page,0,&tmp,WRITE);
-	if (ret<0) {
-		printk("CacheFS: unable to write superblock to disc (%d)\n",ret);
+	ret = cachefs_bio_submit(super->sb,page, 0, &tmp, WRITE);
+	if (ret < 0) {
+		printk("CacheFS: unable to write superblock to disc (%d)\n",
+		       ret);
 		return;
 	}
 	wait_on_page_locked(page);
@@ -706,12 +726,12 @@
 {
 	struct cachefs_super *super = sb->s_fs_info;
 
-	DECLARE_WAITQUEUE(myself,current);
+	DECLARE_WAITQUEUE(myself, current);
 
 	printk("\n\n");
-	kenter("{%p}",super);
+	kenter("{%p}", super);
 
-	if (!super) BUG();
+	BUG_ON(!super);
 
 	cachefs_withdraw_cache(super);
 
@@ -719,7 +739,7 @@
 	    !list_empty(&super->vjnl_writtenq)
 	    ) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		add_wait_queue(&super->vjnl_alloc_wq,&myself);
+		add_wait_queue(&super->vjnl_alloc_wq, &myself);
 
 		while (!list_empty(&super->vjnl_unallocq) ||
 		       !list_empty(&super->vjnl_writtenq)) {
@@ -732,7 +752,7 @@
 	}
 
 	super->dmn_die = 1;
-	cachefs_trans_sync(super,CACHEFS_TRANS_SYNC_WAIT_FOR_ACK);
+	cachefs_trans_sync(super, CACHEFS_TRANS_SYNC_WAIT_FOR_ACK);
 
 	super->dmn_die = 2;
 	wake_up(&super->dmn_sleepq);
@@ -752,9 +772,9 @@
 	cachefs_put_page(super->recycle_node);
 	cachefs_block_put(super->recycle_block);
 
-	free_page((unsigned long)super->rcm_atm_list);
-	free_page((unsigned long)super->rcm_imm_buf);
-	free_page((unsigned long)super->vjnl_map);
+	free_page((unsigned long) super->rcm_atm_list);
+	free_page((unsigned long) super->rcm_imm_buf);
+	free_page((unsigned long) super->vjnl_map);
 
 	kcachefs_jnld_remove_super(super);
 
@@ -762,15 +782,17 @@
 	cachefs_iput(super->imetadata);
 	iput(super->imisc);
 
-	if (atomic_read(&super->cnt_blk_tree)!=0) {
+	if (atomic_read(&super->cnt_blk_tree) != 0) {
 		struct rb_node *_n;
 
 		printk("#### ERROR: %d block tree nodes left at unmount:\n",
 		       atomic_read(&super->cnt_blk_tree));
 
-		for (_n=rb_first(&super->blk_tree); _n; _n=rb_next(_n)) {
+		for (_n = rb_first(&super->blk_tree); _n; _n = rb_next(_n)) {
 			struct cachefs_block *block =
-				rb_entry(_n,struct cachefs_block,lookup_node);
+				rb_entry(_n,
+					 struct cachefs_block,
+					 lookup_node);
 
 			printk("- block %05d u=%d fl=%08lx pg=%p wb=%p\n",
 			       block->bix,
@@ -797,8 +819,9 @@
 {
 	struct cachefs_inode *inode = _inode;
 
-	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) {
-		memset(inode,0,sizeof(*inode));
+	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+	    SLAB_CTOR_CONSTRUCTOR) {
+		memset(inode, 0, sizeof(*inode));
 		inode_init_once(&inode->vfs_inode);
 		init_rwsem(&inode->metadata_sem);
 
@@ -816,7 +839,8 @@
 {
 	struct cachefs_inode *inode;
 
-	inode = (struct cachefs_inode *) kmem_cache_alloc(cachefs_inode_cachep,SLAB_KERNEL);
+	inode = (struct cachefs_inode *)
+		kmem_cache_alloc(cachefs_inode_cachep, SLAB_KERNEL);
 	if (!inode)
 		return NULL;
 
@@ -829,6 +853,6 @@
  */
 static void cachefs_destroy_inode(struct inode *inode)
 {
-	_enter("{%lu}",inode->i_ino);
-	kmem_cache_free(cachefs_inode_cachep,CACHEFS_FS_I(inode));
+	_enter("{%lu}", inode->i_ino);
+	kmem_cache_free(cachefs_inode_cachep, CACHEFS_FS_I(inode));
 } /* end cachefs_destroy_inode() */

Index: status.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/status.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- status.c	9 Jun 2003 13:38:21 -0000	1.6
+++ status.c	4 Jul 2003 09:04:43 -0000	1.7
@@ -21,7 +21,8 @@
 #include "cachefs-int.h"
 
 static int cachefs_status_open(struct inode *inode, struct file *file);
-static ssize_t cachefs_status_write(struct file *, const char __user *, size_t, loff_t *);
+static ssize_t cachefs_status_write(struct file *, const char __user *,
+				    size_t, loff_t *);
 static void *cachefs_status_start(struct seq_file *p, loff_t *pos);
 static void *cachefs_status_next(struct seq_file *p, void *v, loff_t *pos);
 static void cachefs_status_stop(struct seq_file *p, void *v);
@@ -54,7 +55,7 @@
 	struct seq_file *m;
 	int ret;
 
-	ret = seq_open(file,&cachefs_status_ops);
+	ret = seq_open(file, &cachefs_status_ops);
 	if (ret<0)
 		return ret;
 
@@ -62,7 +63,6 @@
 	m->private = inode->i_sb->s_fs_info;
 
 	return 0;
-
 } /* end cachefs_status_open() */
 
 /*****************************************************************************/
@@ -71,7 +71,8 @@
  */
 static void *cachefs_status_start(struct seq_file *p, loff_t *pos)
 {
-	return (*pos) ? NULL : (void*)1;
+	return *pos ? NULL : (void *) 1;
+
 } /* end cachefs_status_start() */
 
 /*****************************************************************************/
@@ -81,8 +82,8 @@
 static void *cachefs_status_next(struct seq_file *p, void *v, loff_t *pos)
 {
 	(*pos)++;
-	return NULL;
 
+	return NULL;
 } /* end cachefs_status_next() */
 
 /*****************************************************************************/
@@ -101,50 +102,56 @@
 {
 	struct cachefs_super *super = m->private;
 
-	seq_puts(m,"CacheFS (c) Red Hat, Inc. 2002\n");
-	seq_puts(m,"\n");
+	seq_puts(m, "CacheFS (c) Red Hat, Inc. 2002\n");
+	seq_puts(m, "\n");
 
-	seq_printf(m,"u-journal : %u-%u (%u byte slots, %u per page)\n",
+	seq_printf(m, "u-journal : %u-%u (%u byte slots, %u per page)\n",
 		   super->layout->bix_ujournal,
 		   super->layout->bix_wbjournal,
 		   super->layout->ujnl_rsize,
-		   super->layout->ujnl_recperblk
-		   );
+		   super->layout->ujnl_recperblk);
 
-	seq_printf(m,"wb-journal: %u-%u\n",
+	seq_printf(m, "wb-journal: %u-%u\n",
 		   super->layout->bix_wbjournal,
-		   super->layout->bix_cache
-		   );
+		   super->layout->bix_cache);
 
-	seq_printf(m,"cache     : %u-%u [%u-%u unready]\n",
+	seq_printf(m, "cache     : %u-%u [%u-%u unready]\n",
 		   super->layout->bix_cache,
 		   super->layout->bix_end,
 		   super->layout->bix_unready,
-		   super->layout->bix_end
-		   );
-
-	seq_puts(m,"\n");
-
-	seq_printf(m,"Alloc Stk : TOS={%u}+%u NUM=%u\n",
-		   super->alloc_cur,super->alloc_leaf,super->alloc_cur_n);
+		   super->layout->bix_end);
 
-	seq_printf(m,"Recyc Stk : TOS={%u} #%u NUM=%u\n",
-		   super->recycle_cur,super->recycle_room,super->recycle_cur_n);
+	seq_puts(m, "\n");
 
-	seq_printf(m,"Reclaimer : ino=%u indir=%u blk=%u:%hu-%hu\n",
-		   super->rcm_ino,super->rcm_indirect,super->rcm_block,
-		   super->rcm_ptrnext,super->rcm_ptrstop);
+	seq_printf(m, "Alloc Stk : TOS={%u}+%u NUM=%u\n",
+		   super->alloc_cur,
+		   super->alloc_leaf,
+		   super->alloc_cur_n);
+
+	seq_printf(m, "Recyc Stk : TOS={%u} #%u NUM=%u\n",
+		   super->recycle_cur,
+		   super->recycle_room,
+		   super->recycle_cur_n);
+
+	seq_printf(m, "Reclaimer : ino=%u indir=%u blk=%u:%hu-%hu\n",
+		   super->rcm_ino,
+		   super->rcm_indirect,
+		   super->rcm_block,
+		   super->rcm_ptrnext,
+		   super->rcm_ptrstop);
+
+	seq_printf(m, "uj disc   : NEXT=%u ACK=%u\n",
+		   super->ujnl_head,
+		   super->ujnl_tail);
 
-	seq_printf(m,"uj disc   : NEXT=%u ACK=%u\n",super->ujnl_head,super->ujnl_tail);
-
-	seq_printf(m,"ujournal  : BATCH=%hd SERIAL=%hu\n",
+	seq_printf(m, "ujournal  : BATCH=%hd SERIAL=%hu\n",
 		   super->ujnl_batch,
-		   super->ujnl_serial
-		   );
+		   super->ujnl_serial);
 
-	seq_puts(m,"\n");
+	seq_puts(m, "\n");
 
-	seq_printf(m,"uj marks  : REQUESTED=%u GRANTED=%u WRITTEN=%u FREED=%u\n",
+	seq_printf(m,
+		   "uj marks  : REQUESTED=%u GRANTED=%u WRITTEN=%u FREED=%u\n",
 		   atomic_read(&super->cnt_ujnl_mkrq),
 		   atomic_read(&super->cnt_ujnl_mkgr),
 		   atomic_read(&super->cnt_ujnl_mkwr),
@@ -161,10 +168,10 @@
 
 /*****************************************************************************/
 /*
- * 
+ *
  */
-static ssize_t cachefs_status_write(struct file *file, const char __user *data, size_t size,
-				    loff_t *pos)
+static ssize_t cachefs_status_write(struct file *file, const char __user *data,
+				    size_t size, loff_t *pos)
 {
 	struct cachefs_super *super;
 	struct cachefs_block *block, *xblock;
@@ -176,16 +183,16 @@
 	super = inode->i_sb->s_fs_info;
 
 	xblock = NULL;
-	read_lock_irqsave(&super->blk_tree_lock,flags);
+	read_lock_irqsave(&super->blk_tree_lock, flags);
 
 	_rb = rb_first(&super->blk_tree);
 	while (_rb) {
-		block = rb_entry(_rb,struct cachefs_block,lookup_node);
+		block = rb_entry(_rb, struct cachefs_block, lookup_node);
 
 		if (block->page) {
 			cachefs_block_get(block);
 
-			read_unlock_irqrestore(&super->blk_tree_lock,flags);
+			read_unlock_irqrestore(&super->blk_tree_lock, flags);
 			cachefs_block_put(xblock);
 
 			printk("- block %05d u=%d fl=%08lx pg=%p wb=%p r=%p\n",
@@ -196,13 +203,13 @@
 			       block->writeback,
 			       block->ref);
 
-			read_lock_irqsave(&super->blk_tree_lock,flags);
+			read_lock_irqsave(&super->blk_tree_lock, flags);
 			xblock = block;
 		}
 		_rb = rb_next(_rb);
 	}
 
-	read_unlock_irqrestore(&super->blk_tree_lock,flags);
+	read_unlock_irqrestore(&super->blk_tree_lock, flags);
 	cachefs_block_put(xblock);
 
 	return size;

Index: rootdir.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/rootdir.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- rootdir.c	3 Jun 2003 17:43:15 -0000	1.11
+++ rootdir.c	4 Jul 2003 09:04:43 -0000	1.12
@@ -22,9 +22,12 @@
 #include <asm/uaccess.h>
 #include "cachefs-int.h"
 
-static struct dentry *cachefs_root_lookup(struct inode *dir, struct dentry *dentry);
-static int cachefs_root_readdir(struct file *file, void *dirent, filldir_t filldir);
-static int cachefs_root_rmdir_unlink(struct inode *dir, struct dentry *dentry);
+static struct dentry *cachefs_root_lookup(struct inode *dir,
+					  struct dentry *dentry);
+static int cachefs_root_readdir(struct file *file, void *dirent,
+				filldir_t filldir);
+static int cachefs_root_rmdir_unlink(struct inode *dir,
+				     struct dentry *dentry);
 
 struct file_operations cachefs_root_file_operations = {
 	.readdir	= cachefs_root_readdir,
@@ -58,6 +61,71 @@
 
 /*****************************************************************************/
 /*
+ * construct a name from an index entry and definition
+ */
+static
+int cachefs_readdir_actor_cons_name(struct cachefs_readdir_record *rec,
+				    struct cachefs_ondisc_index_entry *xent)
+{
+	unsigned char *ptr;
+	unsigned long tmp;
+	char *name;
+	int ksize, loop;
+
+	/* construct a name */
+	name = rec->scratch;
+	ptr = xent->data;
+
+	for (loop = 0; loop < 4; loop++) {
+
+		_debug("- key %04hx", rec->keys[loop]);
+
+		ksize = rec->keys[loop] & CACHEFS_ONDISC_INDEXKEY_KLEN;
+
+		if (loop > 0)
+			*name++ = ',';
+
+		switch (rec->keys[loop] & CACHEFS_ONDISC_INDEXKEY_TYPE) {
+		case CACHEFS_ONDISC_INDEXKEY_BIN:
+			for (tmp = 0; tmp < ksize; tmp++) {
+				sprintf(name, "%02x", ptr[tmp]);
+				name += 2;
+			}
+			break;
+
+		case CACHEFS_ONDISC_INDEXKEY_ASCIIZ:
+			tmp = strnlen(ptr, ksize);
+			memcpy(name, ptr, tmp);
+			name += tmp;
+			break;
+
+		case CACHEFS_ONDISC_INDEXKEY_IPV4:
+			tmp = sprintf(name, "%u.%u.%u.%u",
+				      ptr[0], ptr[1], ptr[2], ptr[3]);
+			name += tmp;
+			break;
+
+		case CACHEFS_ONDISC_INDEXKEY_IPV6:
+			tmp = sprintf(name, "%u:%u:%u:%u:%u:%u:%u:%u",
+				      ptr[0], ptr[1], ptr[2], ptr[3],
+				      ptr[4], ptr[5], ptr[6], ptr[7]);
+			name += tmp;
+			break;
+		default:
+			if (loop > 0)
+				name--;
+			break;
+		}
+
+		ptr += ksize;
+	}
+
+	*name = 0;
+	return name - rec->scratch;
+} /* end cachefs_readdir_actor_cons_name() */
+
+/*****************************************************************************/
+/*
  * root directory read actor
  * - return size to continue, 0 to stop (search also stops when desc->count==0)
  */
@@ -68,12 +136,10 @@
 {
 	struct cachefs_readdir_record *rec;
 	unsigned long stop, tmp;
-	unsigned char *ptr;
 	void *content;
-	char *name;
-	int loop, ret, type;
+	int ret, type, nlen;
 
-	_enter(",{%lu},%lu,%lu",page->index,offset,size);
+	_enter(",{%lu},%lu,%lu", page->index, offset, size);
 
 	rec = (struct cachefs_readdir_record *) desc->buf;
 
@@ -94,76 +160,32 @@
 	size		-= tmp;
 	ret		= tmp;
 
-	/* limit the search of this page to the amount specified in desc->count */
+	/* limit the search of this page to the amount specified in
+	 * desc->count */
 	stop = desc->count;
-	if (size<stop)
+	if (size < stop)
 		stop = size;
 
 	/* read the entries on the page (ignoring slack at end) */
 	content = kmap(page);
 
-	for (; offset+rec->esize<=stop; offset+=rec->esize) {
+	for (; offset + rec->esize <= stop; offset += rec->esize) {
 		struct cachefs_ondisc_index_entry *xent = content + offset;
 
-		if (xent->state==CACHEFS_ONDISC_INDEX_FREE ||
-		    xent->state==CACHEFS_ONDISC_INDEX_RECYCLE) {
+		if (xent->state == CACHEFS_ONDISC_INDEX_FREE ||
+		    xent->state == CACHEFS_ONDISC_INDEX_RECYCLE) {
 			desc->count	-= rec->esize;
 			desc->written	+= rec->esize;
 			ret		+= rec->esize;
 			continue;
 		}
 
-		/* construct a name */
-		name = rec->scratch;
-		ptr = xent->data;
-
-		for (loop=0; loop<4; loop++) {
-			int ksize = rec->keys[loop] & CACHEFS_ONDISC_INDEXKEY_KLEN;
-
-			_debug("- key %04hx",rec->keys[loop]);
-
-			if (loop>0) *name++ = ',';
-
-			switch (rec->keys[loop] & CACHEFS_ONDISC_INDEXKEY_TYPE) {
-			case CACHEFS_ONDISC_INDEXKEY_BIN:
-				for (tmp=0; tmp<ksize; tmp++) {
-					sprintf(name,"%02x",ptr[tmp]);
-					name += 2;
-				}
-				break;
-
-			case CACHEFS_ONDISC_INDEXKEY_ASCIIZ:
-				tmp = strnlen(ptr,ksize);
-				memcpy(name,ptr,tmp);
-				name += tmp;
-				break;
-
-			case CACHEFS_ONDISC_INDEXKEY_IPV4:
-				tmp = sprintf(name,"%u.%u.%u.%u",ptr[0],ptr[1],ptr[2],ptr[3]);
-				name += tmp;
-				break;
-
-			case CACHEFS_ONDISC_INDEXKEY_IPV6:
-				tmp = sprintf(name,"%u:%u:%u:%u:%u:%u:%u:%u",
-					      ptr[0],ptr[1],ptr[2],ptr[3],
-					      ptr[4],ptr[5],ptr[6],ptr[7]);
-				name += tmp;
-				break;
-			default:
-				if (loop>0) name--;
-				break;
-			}
-
-			ptr += ksize;
-		}
-
-		*name = 0;
-
-		tmp = rec->dpos_off + (page->index * rec->epp) + offset/rec->esize;
+		nlen = cachefs_readdir_actor_cons_name(rec, xent);
 
-		_debug("dirent: %d '%s' ino=%u",name-rec->scratch,rec->scratch,xent->ino);
+		_debug("dirent: %d '%s' ino=%u",
+		       nlen, rec->scratch, xent->ino);
 
-		if (name == rec->scratch) {
+		if (nlen) {
 			desc->count	-= rec->esize;
 			desc->written	+= rec->esize;
 			ret		+= rec->esize;
@@ -171,15 +193,18 @@
 		}
 
 		type = DT_REG;
-		if (xent->type==CACHEFS_ONDISC_INDEX_INDEXFILE)
+		if (xent->type == CACHEFS_ONDISC_INDEX_INDEXFILE)
 			type = DT_DIR;
 
+		tmp = rec->dpos_off + (page->index * rec->epp) +
+			offset / rec->esize;
+
 		if (rec->filldir(rec->cookie,
 				 rec->scratch,
-				 name - rec->scratch,
+				 nlen,
 				 tmp,
 				 xent->ino,
-				 type)<0
+				 type) < 0
 		    ) {
 			desc->count = 0;
 			goto done;
@@ -198,7 +223,7 @@
 	kunmap(page);
 
  done_already:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_readdir_actor() */
 
@@ -206,7 +231,9 @@
 /*
  * read the cache's root directory
  */
-static int cachefs_root_readdir(struct file *file, void *cookie, filldir_t filldir)
+static int cachefs_root_readdir(struct file *file,
+				void *cookie,
+				filldir_t filldir)
 {
 	struct cachefs_ondisc_metadata *metadata;
 	struct cachefs_readdir_record rec;
@@ -218,9 +245,9 @@
 
 	inode = CACHEFS_FS_I(file->f_dentry->d_inode);
 
-	_enter("{%Ld,{%lu}}",file->f_pos,inode->vfs_inode.i_ino);
+	_enter("{%Ld,{%lu}}", file->f_pos, inode->vfs_inode.i_ino);
 
-	rec.scratch = (char*) get_zeroed_page(GFP_KERNEL);
+	rec.scratch = (char *) get_zeroed_page(GFP_KERNEL);
 	dbgpgalloc(rec.scratch);
 	if (!rec.scratch)
 		return -ENOMEM;
@@ -233,18 +260,20 @@
 	rec.epp		= inode->index_esize;
 
 	metadata = cachefs_metadata_preread(inode);
-	memcpy(rec.keys,metadata->index_keys,sizeof(rec.keys));
+	memcpy(rec.keys, metadata->index_keys, sizeof(rec.keys));
 	cachefs_metadata_postread(inode);
 
 	switch (file->f_pos) {
 	case 0:
-		ret = filldir(cookie,".",1,file->f_pos,inode->vfs_inode.i_ino,DT_DIR);
-		if (ret<0)
+		ret = filldir(cookie, ".", 1, file->f_pos,
+			      inode->vfs_inode.i_ino, DT_DIR);
+		if (ret < 0)
 			goto done;
 		file->f_pos++;
 	case 1:
-		ret = filldir(cookie,"..",2,file->f_pos,parent_ino(file->f_dentry),DT_DIR);
-		if (ret<0)
+		ret = filldir(cookie, "..", 2, file->f_pos,
+			      parent_ino(file->f_dentry), DT_DIR);
+		if (ret < 0)
 			goto done;
 		file->f_pos++;
 	default:
@@ -252,57 +281,55 @@
 	}
 
 	/* deal with root directory only entries */
-	if (inode->vfs_inode.i_ino==CACHEFS_INO_ROOTDIR) {
+	if (inode->vfs_inode.i_ino == CACHEFS_INO_ROOTDIR) {
 		rec.dpos_off = 5;
 		switch (file->f_pos) {
 		case 2:
-			ret = filldir(cookie,"metadata_catalogue",18,
-				      file->f_pos,CACHEFS_INO_METADATA,DT_REG);
-			if (ret<0)
+			ret = filldir(cookie, "metadata_catalogue", 18,
+				      file->f_pos, CACHEFS_INO_METADATA,
+				      DT_REG);
+			if (ret < 0)
 				goto done;
 			file->f_pos++;
 		case 3:
-			ret = filldir(cookie,"status",6,file->f_pos,CACHEFS_INO_STATUS,DT_REG);
-			if (ret<0)
-				goto done;
-			file->f_pos++;
-#if 1 /* TODO: remove */
-		case 4:
-			ret = filldir(cookie,"wibble",6,
-				      file->f_pos,CACHEFS_INO_WIBBLE,DT_REG);
-			if (ret<0)
+			ret = filldir(cookie, "status", 6,
+				      file->f_pos, CACHEFS_INO_STATUS,
+				      DT_REG);
+			if (ret < 0)
 				goto done;
 			file->f_pos++;
-#endif
 		default:
 			break;
 		}
 	}
 
 	/* iterate through the index entries stored on disc */
-	if (inode->vfs_inode.i_size>0) {
+	if (inode->vfs_inode.i_size > 0) {
 		entry = file->f_pos - rec.dpos_off;
-		pos = (entry/rec.epp) << PAGE_SHIFT;
-		pos += (entry%rec.epp) * rec.esize;
+		pos = (entry / rec.epp) << PAGE_SHIFT;
+		pos += (entry % rec.epp) * rec.esize;
 
 		desc.written	= 0;
 		desc.count	= inode->vfs_inode.i_size - pos;
-		desc.buf	= (char*) &rec;
+		desc.buf	= (char *) &rec;
 		desc.error	= 0;
 
 		_debug("do read: isz=%llu pos=%llu count=%u",
-		       inode->vfs_inode.i_size,pos,desc.count);
+		       inode->vfs_inode.i_size, pos, desc.count);
 
-		do_generic_file_read(file,&pos,&desc,cachefs_readdir_actor);
+		do_generic_file_read(file, &pos, &desc, cachefs_readdir_actor);
 
 		file->f_pos = (pos >> PAGE_SHIFT) * rec.epp;
-		file->f_pos += ((unsigned)(pos & ~PAGE_MASK) + rec.esize - 1) / rec.esize;
+		file->f_pos +=
+			((unsigned) (pos & ~PAGE_MASK) + rec.esize - 1) /
+			rec.esize;
 		file->f_pos += rec.dpos_off;
 
-		_debug("done read: err=%d pos=%llu fpos=%llu",desc.error,pos,file->f_pos);
+		_debug("done read: err=%d pos=%llu fpos=%llu",
+		       desc.error, pos, file->f_pos);
 
 		ret = desc.error;
-		if (ret<0)
+		if (ret < 0)
 			goto error;
 	}
 
@@ -312,7 +339,7 @@
  error:
 	dbgpgfree(rec.scratch);
 	free_page((unsigned long) rec.scratch);
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_root_readdir() */
 
@@ -331,7 +358,7 @@
 	void *content;
 	int ret;
 
-	_enter(",{%lu},%lu,%lu",page->index,offset,size);
+	_enter(",{%lu},%lu,%lu", page->index, offset, size);
 
 	rec = (struct cachefs_lookup_record *) desc->buf;
 	ret = size;
@@ -340,14 +367,15 @@
 	tmp = offset;
 	offset += rec->esize - 1;
 	offset -= offset % rec->esize;
-	if (offset-tmp > size)
+	if (offset - tmp > size)
 		goto done;
 
 	size -= offset - tmp;
 
-	/* limit the search of this page to the amount specified in desc->count */
+	/* limit the search of this page to the amount specified in
+	 * desc->count */
 	stop = desc->count;
-	if (size<stop)
+	if (size < stop)
 		stop = size;
 
 	tmp = rec->esize;
@@ -355,14 +383,14 @@
 	/* search the elements on the page (ignoring slack at end) */
 	content = kmap(page);
 
-	for (; offset+tmp<=stop; offset+=tmp) {
+	for (; offset + tmp <= stop; offset += tmp) {
 		struct cachefs_ondisc_index_entry *xent = content + offset;
 
-		if (xent->state==CACHEFS_ONDISC_INDEX_FREE ||
-		    xent->state==CACHEFS_ONDISC_INDEX_RECYCLE)
+		if (xent->state == CACHEFS_ONDISC_INDEX_FREE ||
+		    xent->state == CACHEFS_ONDISC_INDEX_RECYCLE)
 			continue;
 
-		if (memcmp(xent->data,rec->key,rec->ksize)==0) {
+		if (memcmp(xent->data, rec->key, rec->ksize) == 0) {
 			rec->ino = xent->ino;
 			desc->count = 0;
 			ret = 0;
@@ -376,7 +404,7 @@
 	desc->count -= ret;
 	desc->written += ret;
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_lookup_actor() */
 
@@ -401,7 +429,7 @@
 	dir = CACHEFS_FS_I(_dir);
 	name = dentry->d_name.name;
 
-	_enter("{%lu},{%s}",dir->vfs_inode.i_ino,name);
+	_enter("{%lu},{%s}", dir->vfs_inode.i_ino, name);
 
 	rec.key		= NULL;
 	rec.esize	= dir->index_esize;
@@ -411,34 +439,27 @@
 	/* consider the virtual files we want to expose */
 	switch (dentry->d_name.len) {
 	case 1:
-		if (memcmp(name,".",1)==0) {
+		if (memcmp(name, ".", 1) == 0) {
 			target = cachefs_igrab(dir);
 			goto instantiate;
 		}
 		break;
 	case 2:
-		if (memcmp(name,"..",2)==0) {
+		if (memcmp(name, "..", 2)==0) {
 			target = cachefs_igrab(dir);
 			goto instantiate;
 		}
 		break;
 	case 6:
-		if (dir->vfs_inode.i_ino==CACHEFS_INO_ROOTDIR &&
-		    memcmp(name,"status",6)==0) {
+		if (dir->vfs_inode.i_ino == CACHEFS_INO_ROOTDIR &&
+		    memcmp(name, "status", 6) == 0) {
 			ino = CACHEFS_INO_STATUS;
 			goto get;
 		}
-#if 1 /* TODO: remove */
-		if (dir->vfs_inode.i_ino==CACHEFS_INO_ROOTDIR &&
-		    memcmp(name,"wibble",6)==0) {
-			ino = CACHEFS_INO_WIBBLE;
-			goto get;
-		}
-#endif
 		break;
 	case 18:
-		if (dir->vfs_inode.i_ino==CACHEFS_INO_ROOTDIR &&
-		    memcmp(name,"metadata_catalogue",18)==0) {
+		if (dir->vfs_inode.i_ino == CACHEFS_INO_ROOTDIR &&
+		    memcmp(name, "metadata_catalogue", 18) == 0) {
 			ino = CACHEFS_INO_METADATA;
 			goto get;
 		}
@@ -449,20 +470,21 @@
 
 	/* construct a key to search the FSDEF index with */
 	metadata = cachefs_metadata_preread(dir);
-	memcpy(rec.keys,metadata->index_keys,sizeof(rec.keys));
+	memcpy(rec.keys, metadata->index_keys, sizeof(rec.keys));
 	cachefs_metadata_postread(dir);
 
-	for (loop=0; loop<4; loop++)
+	for (loop = 0; loop < 4; loop++)
 		rec.ksize += rec.keys[loop] & CACHEFS_ONDISC_INDEXKEY_KLEN;
 
 	if (rec.ksize>dir->index_dsize) {
-		printk("CacheFS: key def longer than data %u>%u\n",rec.ksize,dir->index_dsize);
+		printk("CacheFS: key def longer than data %u>%u\n",
+		       rec.ksize, dir->index_dsize);
 		ret = -EIO;
 		goto error;
 	}
 
 	ret = -ENOMEM;
-	rec.key = (char*) get_zeroed_page(GFP_KERNEL);
+	rec.key = (char *) get_zeroed_page(GFP_KERNEL);
 	if (!rec.key)
 		goto error;
 
@@ -470,47 +492,57 @@
 
 	stop = name;
 	ptr = rec.key;
-	for (loop=0; loop<4; loop++) {
+	for (loop = 0; loop < 4; loop++) {
 		char x;
 		int ksize = rec.keys[loop] & CACHEFS_ONDISC_INDEXKEY_KLEN;
 
-		if (ksize==0)
+		if (ksize == 0)
 			continue;
 
-		stop = memchr(name,',',nend-name) ?: nend;
+		stop = memchr(name, ',', nend - name) ?: nend;
 
-		_debug("- key %04hx [%*.*s]",rec.keys[loop],nend-name,nend-name,name);
+		_debug("- key %04hx [%*.*s]",
+		       rec.keys[loop], nend - name, nend - name, name);
 
 		switch (rec.keys[loop] & CACHEFS_ONDISC_INDEXKEY_TYPE) {
 		case CACHEFS_ONDISC_INDEXKEY_BIN:
-			if (stop-name!=ksize*2 || ksize==0)
+			if (stop - name != ksize * 2 || ksize == 0)
 				goto not_found;
 
 			do {
+				char c;
+
 				if (!isxdigit(*name))
 					goto not_found;
-				x = isdigit(*name) ? *name-'0' : toupper(*name)-'A'+10;
+				c = *name - '0';
+				if (!isdigit(*name))
+					c = toupper(*name) - 'A' + 10;
 				name++;
-				x <<= 4;
+				x = c << 4;
 
 				if (!isxdigit(*name))
 					goto not_found;
-				x |= isdigit(*name) ? *name-'0' : toupper(*name)-'A'+10;
+				c = *name - '0';
+				if (!isdigit(*name))
+					c = toupper(*name) - 'A' + 10;
 				name++;
+				x |= c;
+
 				*ptr++ = x;
-			} while (name<stop);
+			} while (name < stop);
 
 			break;
 
 		case CACHEFS_ONDISC_INDEXKEY_ASCIIZ:
-			if (nend-name>ksize || ksize==0)
+			if (nend - name > ksize || ksize == 0)
 				goto not_found;
-			memcpy(ptr,name,stop-name);
+			memcpy(ptr, name, stop - name);
 			ptr += ksize;
 			break;
 
 		case CACHEFS_ONDISC_INDEXKEY_IPV4:
-			if (sscanf(ptr,"%hu.%hu.%hu.%hu",&ip[0],&ip[1],&ip[2],&ip[3])!=4)
+			if (sscanf(ptr, "%hu.%hu.%hu.%hu",
+				   &ip[0], &ip[1], &ip[2], &ip[3]) != 4)
 				goto not_found;
 			*ptr++ = ip[0];
 			*ptr++ = ip[1];
@@ -519,8 +551,9 @@
 			break;
 
 		case CACHEFS_ONDISC_INDEXKEY_IPV6:
-			if (sscanf(ptr,"%hu:%hu:%hu:%hu:%hu:%hu:%hu:%hu",
-				   &ip[0],&ip[1],&ip[2],&ip[3],&ip[4],&ip[5],&ip[6],&ip[7])!=8)
+			if (sscanf(ptr, "%hu:%hu:%hu:%hu:%hu:%hu:%hu:%hu",
+				   &ip[0], &ip[1], &ip[2], &ip[3],
+				   &ip[4], &ip[5], &ip[6], &ip[7]) != 8)
 				goto not_found;
 			*ptr++ = ip[0];
 			*ptr++ = ip[1];
@@ -536,14 +569,15 @@
 		name = stop + 1;
 	}
 
-	if (rec.ksize != ptr-rec.key) {
-		printk("CacheFS: Built key incorrectly %u!=%u\n",rec.ksize,ptr-rec.key);
+	if (rec.ksize != ptr - rec.key) {
+		printk("CacheFS: Built key incorrectly %u!=%u\n",
+		       rec.ksize, ptr - rec.key);
 		ret = -EIO;
 		goto error;
 	}
 
 	if (stop != nend) {
-		printk("CacheFS: Overran name %p!=%p\n",stop,nend);
+		printk("CacheFS: Overran name %p!=%p\n", stop, nend);
 		ret = -EIO;
 		goto error;
 	}
@@ -551,27 +585,27 @@
 #if 0
 	{ /* dump the key */
 		int loop;
-		for (loop=0; loop<rec.ksize; loop++)
-			printk("%02x",rec.key[loop]);
+		for (loop = 0; loop < rec.ksize; loop++)
+			printk("%02x", rec.key[loop]);
 		printk("\n");
 	}
 #endif
 
 	/* search the FSDEF index */
-	file_ra_state_init(&ra,dir->vfs_inode.i_mapping);
+	file_ra_state_init(&ra, dir->vfs_inode.i_mapping);
 
 	pos = 0;
 
 	desc.written	= 0;
 	desc.count	= dir->vfs_inode.i_size;
-	desc.buf	= (char*) &rec;
+	desc.buf	= (char *) &rec;
 	desc.error	= 0;
 
-	do_generic_mapping_read(dir->vfs_inode.i_mapping,&ra,NULL,
-				&pos,&desc,cachefs_lookup_actor);
+	do_generic_mapping_read(dir->vfs_inode.i_mapping, &ra, NULL, &pos,
+				&desc, cachefs_lookup_actor);
 
 	ret = desc.error;
-	if (ret<0)
+	if (ret < 0)
 		goto error;
 	ino = rec.ino;
 	if (ino)
@@ -579,23 +613,24 @@
  not_found:
 	ret = -ENOENT;
  error:
-	if (rec.key) free_page((unsigned long) rec.key);
-	_leave(" = %d",ret);
+	if (rec.key)
+		free_page((unsigned long) rec.key);
+	_leave(" = %d", ret);
 	return ERR_PTR(ret);
 
 	/* get the inode */
  get_free:
 	free_page((unsigned long) rec.key);
  get:
-	ret = cachefs_iget(dir->vfs_inode.i_sb->s_fs_info,ino,&target);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = cachefs_iget(dir->vfs_inode.i_sb->s_fs_info, ino, &target);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ERR_PTR(ret);
 	}
 
 	/* instantiate the dentry */
  instantiate:
-	d_add(dentry,&target->vfs_inode);
+	d_add(dentry, &target->vfs_inode);
 	_leave(" = NULL");
 	return NULL;
 } /* end cachefs_root_lookup() */
@@ -613,7 +648,7 @@
 	unsigned long flags;
 	int ret;
 
-	_enter("{%lx},{%s,%p}",dir->i_ino,dentry->d_name.name,dentry->d_inode);
+	_enter("{%lx},{%s,%p}", dir->i_ino, dentry->d_name.name, dentry->d_inode);
 
 	if (!dentry->d_inode) {
 		printk("&&& no inode &&&\n");
@@ -624,7 +659,7 @@
 	inode = CACHEFS_FS_I(dentry->d_inode);
 
 	/* mark for reclamation under journalling */
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans) {
 		_leave(" = -ENOMEM");
 		return -ENOMEM;
@@ -633,12 +668,12 @@
 	trans->jentry->mark	= CACHEFS_ONDISC_UJNL_INODE_MARK_RECLAIM;
 	trans->jentry->ino	= inode->vfs_inode.i_ino;
 
-	cachefs_trans_affects_inode(trans,inode);
+	cachefs_trans_affects_inode(trans, inode);
 
 	ret = cachefs_trans_mark(trans);
-	if (ret<0) {
+	if (ret < 0) {
 		cachefs_trans_put(trans);
-		_leave(" = %d",ret);
+		_leave(" = %d", ret);
 		return ret;
 	}
 
@@ -650,19 +685,24 @@
 	cachefs_trans_commit(trans);
 
 	/* add to the immediate-reclaim table if possible */
-	spin_lock_irqsave(&super->rcm_lock,flags);
+	spin_lock_irqsave(&super->rcm_lock, flags);
 
-	if (CIRC_SPACE(super->rcm_imm_head,super->rcm_imm_tail,CACHEFS_RCM_IMM_BUFSIZE)>0) {
-		super->rcm_imm_buf[super->rcm_imm_head] = inode->vfs_inode.i_ino;
-		super->rcm_imm_head = (super->rcm_imm_head+1) & (CACHEFS_RCM_IMM_BUFSIZE-1);
+	if (CIRC_SPACE(super->rcm_imm_head,
+		       super->rcm_imm_tail,
+		       CACHEFS_RCM_IMM_BUFSIZE) > 0) {
+		super->rcm_imm_buf[super->rcm_imm_head] =
+			inode->vfs_inode.i_ino;
+		super->rcm_imm_head =
+			(super->rcm_imm_head + 1) &
+			(CACHEFS_RCM_IMM_BUFSIZE - 1);
 	}
 	else {
-		set_bit(CACHEFS_SUPER_RCM_IMM_SCAN,&super->flags);
+		set_bit(CACHEFS_SUPER_RCM_IMM_SCAN, &super->flags);
 	}
 
-	spin_unlock_irqrestore(&super->rcm_lock,flags);
+	spin_unlock_irqrestore(&super->rcm_lock, flags);
 
-	set_bit(CACHEFS_SUPER_DO_RECLAIM,&super->flags);
+	set_bit(CACHEFS_SUPER_DO_RECLAIM, &super->flags);
 	wake_up(&super->dmn_sleepq);
 
 	_leave(" = 0");

Index: recycling.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/recycling.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- recycling.c	11 Jun 2003 11:59:52 -0000	1.22
+++ recycling.c	4 Jul 2003 09:04:43 -0000	1.23
@@ -42,7 +42,7 @@
 	char used_unready_node = 0;
 	int ret;
 
-	_enter(",%u,%u,%u",bix,upblock,upentry);
+	_enter(",%u,%u,%u", bix, upblock, upentry);
 
 	/* select the block */
 	if (!bix) {
@@ -53,53 +53,56 @@
 		used_unready_node = 1;
 	}
 
-	_debug("begin new recycling on block %x",bix);
+	_debug("begin new recycling on block %x", bix);
 
 	/* mirror the block in memory */
-	ret = cachefs_block_read(super,NULL,bix,1,&block,&page);
-	if (ret<0) {
-		printk("kcachefsd: Failed to get page: %d\n",ret);
-		_leave(" = %d",ret);
-		return ret;
+	ret = cachefs_block_read(super, NULL, bix, 1, &block, &page);
+	if (ret < 0) {
+		printk("kcachefsd: Failed to get page: %d\n", ret);
+		_leave(" = %d", ret);
+		return  ret;
 	}
 
 	/* journal what we're going to do */
 	ret = -ENOMEM;
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans)
 		goto error_rel_block;
 
-	cachefs_trans_affects_block(trans,block,0,PAGE_SIZE);
+	cachefs_trans_affects_block(trans, block, 0, PAGE_SIZE);
 
 	if (used_unready_node) {
-		/* need to update the superblock too if we've consumed an unready block */
+		/* need to update the superblock too if we've consumed an
+		 * unready block */
 		cachefs_trans_affects_super(trans);
 	}
 
 	trans->jentry->mark	= CACHEFS_ONDISC_UJNL_RECYC_BEGIN_NEW;
 	trans->jentry->block	= bix;
 	trans->jentry->auxblock	= super->recycle_cur;
-	trans->jentry->pgnum	= super->layout->bix_unready + used_unready_node;
 	trans->jentry->upblock	= upblock;
 	trans->jentry->upentry	= upentry;
 
+	trans->jentry->pgnum =
+		super->layout->bix_unready + used_unready_node;
+
 	/* mark the beginning of the operation */
 	ret = cachefs_trans_mark(trans);
 	if (ret<0)
 		goto error_rel_trans;
 
 	/* initialise the page */
-	cachefs_block_modify(super,block,&page);
+	cachefs_block_modify(super, block, &page);
 
-	node = (struct cachefs_ondisc_free_node*) kmap(page);
+	node = (struct cachefs_ondisc_free_node *) kmap(page);
 	node->next = super->recycle_cur;
 	node->count = super->recycle_cur_n;
 	kunmap(page);
 
 	super->recycle_cur	= bix;
 	super->recycle_room	= CACHEFS_ONDISC_LEAVES_PER_FREE_NODE;
-	page	= xchg(&super->recycle_node,page);
-	block	= xchg(&super->recycle_block,block);
+	page	= xchg(&super->recycle_node, page);
+	block	= xchg(&super->recycle_block, block);
 
 	if (used_unready_node)
 		super->layout->bix_unready++;
@@ -107,11 +110,8 @@
 	/* go do it */
 	cachefs_trans_commit(trans);
 
-	if (block) cachefs_block_put(block);
-	if (page) {
-		dbgpgfree(page);
-		page_cache_release(page);
-	}
+	cachefs_block_put(block);
+	cachefs_put_page(page);
 
 	_leave(" = 0");
 	return 0;
@@ -120,7 +120,7 @@
 	cachefs_trans_put(trans);
  error_rel_block:
 	cachefs_block_put(block);
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_recycle_begin_new_node() */
 
@@ -138,29 +138,29 @@
 
 	_enter("");
 
-	/* if there's no room in the current front node of recycling, then consume the next unready
-	 * block to set up a new one
+	/* if there's no room in the current front node of recycling, then
+	 * consume the next unready block to set up a new one
 	 */
-	if (super->recycle_room==0)
-		cachefs_recycle_begin_new_node(super,0,0,0);
+	if (super->recycle_room == 0)
+		cachefs_recycle_begin_new_node(super, 0, 0, 0);
 
 	qty = super->layout->bix_end - super->layout->bix_unready;
-	if (qty==0) {
+	if (qty == 0) {
 		_leave("");
 		return;
 	}
 
-	if (qty>super->recycle_room)
+	if (qty > super->recycle_room)
 		qty = super->recycle_room;
 
 	/* journal what we're going to do */
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans) {
 		_leave(" [ENOMEM]");
 		return;
 	}
 
-	cachefs_trans_affects_block(trans,super->recycle_block,0,PAGE_SIZE);
+	cachefs_trans_affects_block(trans, super->recycle_block, 0, PAGE_SIZE);
 	cachefs_trans_affects_super(trans);
 
 	trans->jentry->mark	= CACHEFS_ONDISC_UJNL_RECYC_MAKEREADY;
@@ -170,24 +170,26 @@
 	trans->jentry->count	= qty;
 
 	ret = cachefs_trans_mark(trans);
-	if (ret<0) {
+	if (ret < 0) {
 		cachefs_trans_put(trans);
 		_leave(" [ENOMEM]");
 		return;
 	}
 
-	cachefs_block_modify(super,super->recycle_block,&super->recycle_node);
+	cachefs_block_modify(super, super->recycle_block,
+			     &super->recycle_node);
 
 	super->recycle_cur_n += qty;
 
 	/* transfer a number of nodes to the recycling block */
-	node = (struct cachefs_ondisc_free_node*) kmap(super->recycle_node);
+	node = (struct cachefs_ondisc_free_node *) kmap(super->recycle_node);
 	pbix = node->leaves;
 
-	for (loop=0; loop<qty; loop++) {
-		while (*pbix) pbix++;
+	for (loop = 0; loop < qty; loop++) {
+		while (*pbix)
+			pbix++;
 
-		if (!((unsigned)pbix & (~PAGE_MASK & ~3))) BUG();
+		BUG_ON(!((unsigned) pbix & (~PAGE_MASK & ~3)));
 
 		*pbix = super->layout->bix_unready + loop;
 	}
@@ -198,7 +200,7 @@
 	super->layout->bix_unready += qty;
 	super->recycle_room -= qty;
 
-	if (super->recycle_room==0)
+	if (super->recycle_room == 0)
 		super->recycle_cur_n++;
 
 	cachefs_trans_commit(trans);
@@ -227,8 +229,9 @@
 		return;
 	}
 
-	/* if the front recycling node is saturated, then transfer the entire stack */
-	if (super->recycle_room==0) {
+	/* if the front recycling node is saturated, then transfer the entire
+	 * stack */
+	if (super->recycle_room == 0) {
 		kdebug("transfer entire stack");
 		allocTOS = super->recycle_cur;
 		cur_n	= super->recycle_cur_n;
@@ -236,7 +239,7 @@
 		page	= super->recycle_node;
 
 		/* mark the journal to begin the transfer */
-		trans = cachefs_trans_alloc(super,GFP_KERNEL);
+		trans = cachefs_trans_alloc(super, GFP_KERNEL);
 		if (!trans) {
 			_leave(" [ENOMEM]");
 			return;
@@ -246,9 +249,9 @@
 		trans->jentry->block	= allocTOS;
 
 		ret = cachefs_trans_mark(trans);
-		if (ret<0) {
-			printk("CacheFS: failed to mark ujnl: %d\n",ret);
-			_leave(" [error %d]",ret);
+		if (ret < 0) {
+			printk("CacheFS: failed to mark ujnl: %d\n", ret);
+			_leave(" [error %d]", ret);
 			return;
 		}
 
@@ -260,26 +263,28 @@
 	/* otherwise transfer from the second-in-line if there is one */
 	else {
 		kdebug("transfer 2OS+ of stack");
-		node = (struct cachefs_ondisc_free_node *) kmap(super->recycle_node);
+		node = (struct cachefs_ondisc_free_node *)
+			kmap(super->recycle_node);
 		allocTOS = node->next;
 		kunmap(super->recycle_node);
 
 		cur_n = super->recycle_cur_n - super->recycle_room;
 
-		if (allocTOS==0) {
+		if (allocTOS == 0) {
 			_leave(" [recyc stack almost empty]");
 			return;
 		}
 
-		ret = cachefs_block_read(super,NULL,allocTOS,0,&block,&page);
-		if (ret<0) {
-			printk("CacheFS: failed to read page: %d\n",ret);
-			_leave(" [error %d]",ret);
+		ret = cachefs_block_read(super, NULL, allocTOS, 0,
+					 &block, &page);
+		if (ret < 0) {
+			printk("CacheFS: failed to read page: %d\n", ret);
+			_leave(" [error %d]", ret);
 			return;
 		}
 
 		/* mark the journal to begin the transfer */
-		trans = cachefs_trans_alloc(super,GFP_KERNEL);
+		trans = cachefs_trans_alloc(super, GFP_KERNEL);
 		if (!trans) {
 			cachefs_block_put(block);
 			page_cache_release(page);
@@ -287,33 +292,35 @@
 			return;
 		}
 
-		cachefs_trans_affects_block(trans,super->recycle_block,0,PAGE_SIZE);
+		cachefs_trans_affects_block(trans, super->recycle_block, 0,
+					    PAGE_SIZE);
 
 		trans->jentry->mark	= CACHEFS_ONDISC_UJNL_RECYC_TRANSFER;
 		trans->jentry->block	= allocTOS;
 		trans->jentry->upblock	= super->recycle_cur;
 
 		ret = cachefs_trans_mark(trans);
-		if (ret<0) {
-			printk("CacheFS: failed to mark ujnl: %d\n",ret);
+		if (ret < 0) {
+			printk("CacheFS: failed to mark ujnl: %d\n", ret);
 			dbgpgfree(page);
 			page_cache_release(page);
 			cachefs_block_put(block);
 			cachefs_trans_put(trans);
-			_leave(" [error %d]",ret);
+			_leave(" [error %d]", ret);
 			return;
 		}
 
 		/* break the pointer from the recycling stack TOS to the 2OS */
-		node = (struct cachefs_ondisc_free_node *) kmap(super->recycle_node);
+		node = (struct cachefs_ondisc_free_node *)
+			kmap(super->recycle_node);
 		node->next	= 0;
 		node->count	= 0;
 		kunmap(super->recycle_node);
 
-		super->recycle_cur_n	= super->recycle_room;
+		super->recycle_cur_n = super->recycle_room;
 	}
 
-	set_bit(CACHEFS_BLOCK_CRITICAL,&block->flags);
+	set_bit(CACHEFS_BLOCK_CRITICAL, &block->flags);
 
 	super->alloc_cur	= allocTOS;
 	super->alloc_cur_n	= cur_n;
@@ -324,8 +331,7 @@
 	cachefs_trans_commit(trans);
 
 	/* force a batch to be written */
-	set_bit(CACHEFS_SUPER_BATCH_TIMER,&super->flags);
-
+	set_bit(CACHEFS_SUPER_BATCH_TIMER, &super->flags);
 	wake_up(&super->alloc_wq);
 
 	_leave("");
@@ -333,8 +339,8 @@
 
 /*****************************************************************************/
 /*
- * recycle the dependents of the block currently in the recycling bin and then recycle the block
- * itself
+ * recycle the dependents of the block currently in the recycling bin and then
+ * recycle the block itself
  */
 static void cachefs_recycle_pointer_array(struct cachefs_super *super)
 {
@@ -347,15 +353,20 @@
 	int ret;
 
 	kenter("{room=%u block=%u:%hu-%hu},",
-	       super->recycle_room,super->rcm_block,super->rcm_ptrnext,super->rcm_ptrstop);
+	       super->recycle_room,
+	       super->rcm_block,
+	       super->rcm_ptrnext,
+	       super->rcm_ptrstop);
 
-	max = super->sb->s_blocksize - sizeof(struct cachefs_ondisc_update_journal);
+	max = super->sb->s_blocksize;
+	max -= sizeof(struct cachefs_ondisc_update_journal);
 	max /= sizeof(cachefs_blockix_t);
 
 	/* load the pointer block page */
-	ret = cachefs_block_read(super,NULL,super->rcm_block,0,NULL,&page);
-	if (ret<0) {
-		kleave(" [error %d]",ret);
+	ret = cachefs_block_read(super, NULL, super->rcm_block, 0,
+				 NULL, &page);
+	if (ret < 0) {
+		kleave(" [error %d]", ret);
 		return;
 	}
 
@@ -364,7 +375,7 @@
 	indirect = (cachefs_blockix_t*) kmap(page);
 
 	/* find an occupied pointer */
-	for (src=super->rcm_ptrnext; src<super->rcm_ptrstop; src++)
+	for (src = super->rcm_ptrnext; src < super->rcm_ptrstop; src++)
 		if (indirect[src])
 			goto found;
 
@@ -373,21 +384,22 @@
 
  found:
 	/* make sure there's a recycling block with space available */
-	if (super->recycle_room==0) {
-		/* recycle the first dependent page as the new recycling node */
+	if (super->recycle_room == 0) {
+		/* recycle the first dependent page as the new recycling
+		 * node */
 		super->rcm_ptrnext = src;
-		ret = cachefs_recycle_begin_new_node(super,indirect[src],super->rcm_block,src);
+		ret = cachefs_recycle_begin_new_node(super, indirect[src],
+						     super->rcm_block, src);
 		goto out;
 	}
 
-	/* journal what we're going to do */
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans)
 		goto out;
 
-	cachefs_trans_affects_block(trans,super->recycle_block,0,PAGE_SIZE);
+	cachefs_trans_affects_block(trans, super->recycle_block, 0, PAGE_SIZE);
 
-	limit = min(super->recycle_room,max);
+	limit = min(super->recycle_room, max);
 	dst = CACHEFS_ONDISC_LEAVES_PER_FREE_NODE - super->recycle_room;
 
 	trans->jentry->mark	= CACHEFS_ONDISC_UJNL_RECYC_SCAVENGE;
@@ -399,13 +411,15 @@
 	/* transfer the pointers into the journal entry first */
 	jeptr = trans->jentry->rcyptrs;
 	count = 0;
-	while (count<limit && src<super->rcm_ptrstop) {
+	while (count < limit && src < super->rcm_ptrstop) {
 		if (indirect[src]) {
 			jeptr[count] = indirect[src];
 			count++;
 
-			if (cachefs_block_find(super,jeptr[count],&block) == 0) {
-				clear_bit(CACHEFS_BLOCK_NETFSDATA,&block->flags);
+			if (cachefs_block_find(super, jeptr[count],
+					       &block) == 0) {
+				clear_bit(CACHEFS_BLOCK_NETFSDATA,
+					  &block->flags);
 				cachefs_block_put(block);
 			}
 		}
@@ -416,23 +430,26 @@
 	trans->jentry->count = count;
 
 	ret = cachefs_trans_mark(trans);
-	if (ret<0) {
-		printk("kcachefsd: Failed to mark journal: %d\n",ret);
+	if (ret < 0) {
+		printk("kcachefsd: Failed to mark journal: %d\n", ret);
 		cachefs_trans_put(trans);
 		goto out;
 	}
 
 	super->recycle_room -= count;
 	super->recycle_cur_n += count;
-	if (super->recycle_room==0)
+	if (super->recycle_room == 0)
 		super->recycle_cur_n++;
 
 	/* transfer from the jentry to the recycling block */
-	cachefs_block_modify(super,super->recycle_block,&super->recycle_node);
+	cachefs_block_modify(super, super->recycle_block,
+			     &super->recycle_node);
 
-	node = (struct cachefs_ondisc_free_node*) kmap(super->recycle_node);
+	node = (struct cachefs_ondisc_free_node *) kmap(super->recycle_node);
 
-	memcpy(&node->leaves[dst],trans->jentry->rcyptrs,count*sizeof(cachefs_blockix_t));
+	memcpy(&node->leaves[dst],
+	       trans->jentry->rcyptrs,
+	       count * sizeof(cachefs_blockix_t));
 
 	kunmap(super->recycle_node);
 
@@ -446,7 +463,7 @@
 	dbgpgfree(page);
 	page_cache_release(page);
 
-	kleave(" [error %d]",ret);
+	kleave(" [error %d]", ret);
 } /* end cachefs_recycle_pointer_array() */
 
 /*****************************************************************************/
@@ -468,7 +485,7 @@
 	unsigned iino, ixentry, offset;
 	int ret;
 
-	kenter("{%u}",super->rcm_ino);
+	kenter("{%u}", super->rcm_ino);
 
 	/* find the parent index entry */
 	metadata = cachefs_metadata_preread(super->rcm_inode);
@@ -477,12 +494,13 @@
 	cachefs_metadata_postread(super->rcm_inode);
 
 	if (iino) {
-		ret = cachefs_iget(super,iino,&iinode);
+		ret = cachefs_iget(super, iino, &iinode);
 		if (ret<0)
 			goto error;
 
-		ret = cachefs_get_page(iinode,ixentry/iinode->index_epp,&ixpage);
-		if (ret<0)
+		ret = cachefs_get_page(iinode, ixentry / iinode->index_epp,
+				       &ixpage);
+		if (ret < 0)
 			goto error;
 
 		offset = (ixentry % iinode->index_epp) * iinode->index_esize;
@@ -494,7 +512,7 @@
 
 	/* do the release under journalling */
 	ret = -ENOMEM;
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans)
 		goto error;
 
@@ -502,43 +520,49 @@
 	trans->jentry->index	= iino;
 	trans->jentry->ixentry	= ixentry;
 	trans->jentry->ino	= super->rcm_ino;
-	trans->jentry->size	= iinode ? iinode->vfs_inode.i_size : 0;
-	trans->jentry->pgnum	= ixpage ? ixpage->index : 0;
-	trans->jentry->block	= ixpage ? __cachefs_get_page_block(ixpage)->bix : 0;
 	trans->jentry->entry	= offset;
-	trans->jentry->count	= iinode ? iinode->index_esize : 0;
 
-	metadata = cachefs_metadata_preread(super->imetadata);
-	trans->jentry->auxblock	= metadata->freelink;
-	cachefs_metadata_postread(super->imetadata);
+	if (ixpage) {
+		trans->jentry->pgnum = ixpage->index;
+		trans->jentry->block = __cachefs_get_page_block(ixpage)->bix;
+	}
 
 	if (iinode) {
+		trans->jentry->size  = iinode->vfs_inode.i_size;
+		trans->jentry->count = iinode->index_esize;
+
 		metadata = cachefs_metadata_preread(iinode);
-		trans->jentry->upblock	= metadata->freelink;
+		trans->jentry->upblock = metadata->freelink;
 		cachefs_metadata_postread(iinode);
 
-		cachefs_trans_affects_page(trans,__cachefs_page_get_private(ixpage),offset,
+		cachefs_trans_affects_page(trans,
+					   __cachefs_page_get_private(ixpage),
+					   offset,
 					   iinode->index_esize);
-		cachefs_trans_affects_inode(trans,iinode);
+
+		cachefs_trans_affects_inode(trans, iinode);
 	}
 
-	cachefs_trans_affects_inode(trans,super->rcm_inode);
-	cachefs_trans_affects_inode(trans,super->imetadata);
+	metadata = cachefs_metadata_preread(super->imetadata);
+	trans->jentry->auxblock	= metadata->freelink;
+	cachefs_metadata_postread(super->imetadata);
+
+	cachefs_trans_affects_inode(trans, super->rcm_inode);
+	cachefs_trans_affects_inode(trans, super->imetadata);
 
 	ret = cachefs_trans_mark(trans);
-	if (ret<0)
+	if (ret < 0)
 		goto error;
 
-	if (iinode)
-		cachefs_page_modify(super,&ixpage);
-
 	/* free up the parent index entry */
 	if (iinode) {
+		cachefs_page_modify(super, &ixpage);
+
 		xent = kmap(ixpage) + offset;
 		xent->state		= CACHEFS_ONDISC_INDEX_FREE;
 		xent->ino		= 0;
 		xent->freelink[0]	= trans->jentry->upblock;
-		memset(xent->data,0,iinode->index_dsize);
+		memset(xent->data, 0, iinode->index_dsize);
 		kunmap(ixpage);
 
 		/* modify the index inode metadata entry */
@@ -549,7 +573,7 @@
 
 	/* clear the inode definition */
 	metadata = cachefs_metadata_prewrite(super->rcm_inode);
-	memset(metadata,0,sizeof(super->imetadata->index_esize));
+	memset(metadata, 0, sizeof(super->imetadata->index_esize));
 
 	metadata->header.state	= CACHEFS_ONDISC_INDEX_FREE;
 	metadata->freelink	= trans->jentry->auxblock;
@@ -571,7 +595,7 @@
 	cachefs_put_page(ixpage);
 	cachefs_iput(iinode);
 
-	kleave(" = %d",ret);
+	kleave(" = %d", ret);
 	return ret;
 } /* end cachefs_recycle_reclaim_inode_metadata() */
 
@@ -607,12 +631,12 @@
 	const unsigned N = PAGE_SIZE / sizeof(cachefs_blockix_t);
 
 	kenter("{%u,%u,%u:%hu-%hu}",
-	       super->rcm_ino,super->rcm_indirect,super->rcm_block,
-	       super->rcm_ptrnext,super->rcm_ptrstop);
+	       super->rcm_ino, super->rcm_indirect, super->rcm_block,
+	       super->rcm_ptrnext, super->rcm_ptrstop);
 
 	BUG_ON(!super->rcm_ino);
 
-	if (super->rcm_ptrnext==super->rcm_ptrstop && super->rcm_curpage) {
+	if (super->rcm_ptrnext == super->rcm_ptrstop && super->rcm_curpage) {
 		put_page(super->rcm_curpage);
 		super->rcm_curpage = NULL;
 	}
@@ -629,10 +653,10 @@
 
 	/* clear out then entries in an index */
 	if (indirect == 1) {
-		if (super->rcm_inode->index_dsize==0)
+		if (super->rcm_inode->index_dsize == 0)
 			goto again;
 
-		if (cachefs_index_zap(super)<0)
+		if (cachefs_index_zap(super) < 0)
 			goto error2;
 		goto again;
 	}
@@ -649,27 +673,27 @@
 	}
 
 	/* deal with double indirection */
-	if (indirect <= 3+N) {
+	if (indirect <= 3 + N) {
 		metadata = cachefs_metadata_preread(super->rcm_inode);
 		bix = metadata->double_indirect;
 		cachefs_metadata_postread(super->rcm_inode);
 
 		if (!bix) {
-			indirect = 3+N;
+			indirect = 3 + N;
 			goto again;
 		}
 
-		ret = cachefs_block_read(super,NULL,bix,0,NULL,&dpage);
-		if (ret<0)
+		ret = cachefs_block_read(super, NULL, bix, 0, NULL, &dpage);
+		if (ret < 0)
 			goto error;
 
 		/* start processing a double indirect subblock */
-		if (indirect <= 3+N-1) {
+		if (indirect <= 3 + N - 1) {
 			wait_on_page_locked(dpage);
 
 			bix = 0;
 			pbix = kmap(dpage);
-			for (loop=indirect-2; loop<N; loop++) {
+			for (loop = indirect - 2; loop < N; loop++) {
 				bix = pbix[loop];
 				if (bix)
 					break;
@@ -690,13 +714,15 @@
 	}
 
 	/* reclaim all the block pointers in the inode metadata record */
-	if (indirect == 3+N+1) {
+	if (indirect == 3 + N + 1) {
 		bix	= super->rcm_inode->metadata->bix;
 		next	= super->rcm_inode->metadata_offset;
-		next	+= offsetof(struct cachefs_ondisc_metadata,triple_indirect);
+		next	+= offsetof(struct cachefs_ondisc_metadata,
+				    triple_indirect);
 		next	/= sizeof(cachefs_blockix_t);
 
-		stop	= super->rcm_inode->metadata_offset + super->layout->metadata_size;
+		stop	= super->rcm_inode->metadata_offset;
+		stop	+= super->layout->metadata_size;
 		stop	/= sizeof(cachefs_blockix_t);
 
 		down_read(&super->rcm_inode->metadata_sem);
@@ -707,7 +733,7 @@
 	}
 
 	/* reclaim the inode itself */
-	if (cachefs_recycle_reclaim_inode_metadata(super)<0) {
+	if (cachefs_recycle_reclaim_inode_metadata(super) < 0) {
 		indirect--;
 		bix	= 0;
 		next	= 0;
@@ -728,8 +754,8 @@
 	return;
 
  pointer_array:
-	ret = cachefs_block_read(super,NULL,bix,0,NULL,&page);
-	if (ret<0)
+	ret = cachefs_block_read(super, NULL, bix, 0, NULL, &page);
+	if (ret < 0)
 		goto error;
 
  pointer_array2:
@@ -745,13 +771,13 @@
 	return;
 
  error:
-	if (ret==-EIO) {
+	if (ret == -EIO) {
 		/* just sweep any buggy block under the rug */
-		printk("CacheFS: discarding block %u due to I/O error\n",bix);
+		printk("CacheFS: discarding block %u due to I/O error\n", bix);
 		goto again;
 	}
  error2:
-	kleave(" [error %d]",ret);
+	kleave(" [error %d]", ret);
 	goto set;
 } /* end cachefs_recycle_reclaim_inode() */
 
@@ -765,16 +791,17 @@
 	int ret;
 
 	kenter("{%u,%u,%u:%hu-%hu}",
-	       super->rcm_ino,super->rcm_indirect,super->rcm_block,
-	       super->rcm_ptrnext,super->rcm_ptrstop);
+	       super->rcm_ino, super->rcm_indirect, super->rcm_block,
+	       super->rcm_ptrnext, super->rcm_ptrstop);
 
 	/* recycle the next chunk of an inode we're busy reclaiming */
 	if (super->rcm_ino) {
 		kdebug("do reclaim");
 		if (!super->rcm_inode) {
-			ret = cachefs_iget(super,super->rcm_ino,&super->rcm_inode);
-			if (ret<0) {
-				kleave(" [error %d]",ret);
+			ret = cachefs_iget(super, super->rcm_ino,
+					   &super->rcm_inode);
+			if (ret < 0) {
+				kleave(" [error %d]", ret);
 				return;
 			}
 		}
@@ -786,19 +813,20 @@
 
 	/* see if there's an inode we can start reclaiming */
 	if (super->rcm_imm_head != super->rcm_imm_tail) {
-		kdebug("begin reclaim {%u-%u}",super->rcm_imm_tail,super->rcm_imm_head);
-		trans = cachefs_trans_alloc(super,GFP_KERNEL);
+		kdebug("begin reclaim {%u-%u}",
+		       super->rcm_imm_tail, super->rcm_imm_head);
+		trans = cachefs_trans_alloc(super, GFP_KERNEL);
 		if (!trans) {
 			kdebug("[ENOMEM]");
 			goto done;
 		}
 
-		trans->jentry->ino	= super->rcm_imm_buf[super->rcm_imm_tail];
-		trans->jentry->mark   	= CACHEFS_ONDISC_UJNL_INODE_RECLAIMING;
+		trans->jentry->ino  = super->rcm_imm_buf[super->rcm_imm_tail];
+		trans->jentry->mark = CACHEFS_ONDISC_UJNL_INODE_RECLAIMING;
 
 		ret = cachefs_trans_mark(trans);
 		if (ret<0) {
-			kdebug("[error %d]",ret);
+			kdebug("[error %d]", ret);
 			cachefs_trans_put(trans);
 			goto done;
 		}
@@ -811,7 +839,8 @@
 
 		cachefs_trans_commit(trans);
 
-		super->rcm_imm_tail = (super->rcm_imm_tail+1) & (CACHEFS_RCM_IMM_BUFSIZE-1);
+		super->rcm_imm_tail =
+			(super->rcm_imm_tail+1) & (CACHEFS_RCM_IMM_BUFSIZE-1);
 		goto done;
 	}
 
@@ -820,7 +849,7 @@
 	if (super->rcm_ino ||
 	    super->rcm_imm_head != super->rcm_imm_tail
 	    )
-		set_bit(CACHEFS_SUPER_DO_RECLAIM,&super->flags);
+		set_bit(CACHEFS_SUPER_DO_RECLAIM, &super->flags);
 	kleave("");
 	return;
 } /* end cachefs_recycle_reclaim() */
@@ -845,7 +874,9 @@
 
 	/* we can access the next pointer without a lock because we know we're
 	 * the only ones going to change it now */
-	vjentry = list_entry(super->vjnl_unallocq.next,struct cachefs_vj_entry,link);
+	vjentry = list_entry(super->vjnl_unallocq.next,
+			     struct cachefs_vj_entry,
+			     link);
 
 	ret = -ENOMEM;
 	trans = cachefs_trans_alloc(super,GFP_KERNEL);
@@ -861,51 +892,57 @@
 	trans->jentry->auxblock	= super->recycle_cur;
 	trans->jentry->auxentry	= ~0;
 
-	ret = cachefs_block_read(super,NULL,vjentry->upblock,1,&upblock,&uppage);
-	if (ret<0)
+	ret = cachefs_block_read(super, NULL, vjentry->upblock, 1,
+				 &upblock, &uppage);
+	if (ret < 0)
 		goto error_free;
 
-	cachefs_trans_affects_block(trans,upblock,vjentry->upentry,sizeof(cachefs_blockix_t));
+	cachefs_trans_affects_block(trans, upblock, vjentry->upentry,
+				    sizeof(cachefs_blockix_t));
 
-	cachefs_trans_affects_block(trans,vjentry->vblock,vjentry->ventry,
-				    sizeof(struct cachefs_ondisc_validity_journal));
+	cachefs_trans_affects_block(
+		trans, vjentry->vblock, vjentry->ventry,
+		sizeof(struct cachefs_ondisc_validity_journal));
 
-	if (cachefs_block_find(super,vjentry->bix,&block) == 0) {
-		clear_bit(CACHEFS_BLOCK_NETFSDATA,&block->flags);
+	if (cachefs_block_find(super, vjentry->bix, &block) == 0) {
+		clear_bit(CACHEFS_BLOCK_NETFSDATA, &block->flags);
 		cachefs_block_put(block);
 	}
 
-	if (super->recycle_room==0) {
+	if (super->recycle_room == 0) {
 		/* we have to generate a new recycling node */
-		ret = cachefs_block_read(super,NULL,vjentry->bix,1,&rcyblock,&rcypage);
-		if (ret<0)
+		ret = cachefs_block_read(super, NULL, vjentry->bix, 1,
+					 &rcyblock, &rcypage);
+		if (ret < 0)
 			goto error_free;
 
-		cachefs_trans_affects_block(trans,rcyblock,0,PAGE_SIZE);
+		cachefs_trans_affects_block(trans, rcyblock, 0, PAGE_SIZE);
 	}
 	else {
 		/* we can add into an existing recycling node */
-		cachefs_trans_affects_block(trans,super->recycle_block,0,PAGE_SIZE);
+		cachefs_trans_affects_block(trans, super->recycle_block, 0,
+					    PAGE_SIZE);
 
 		trans->jentry->auxentry	=
-			CACHEFS_ONDISC_LEAVES_PER_FREE_NODE - super->recycle_room;
+			CACHEFS_ONDISC_LEAVES_PER_FREE_NODE -
+			super->recycle_room;
 	}
 
 	/* mark the journal and then make modifications */
 	ret = cachefs_trans_mark(trans);
-	if (ret<0)
+	if (ret < 0)
 		goto error_free;
 
-	cachefs_block_modify(super,vjentry->vblock,&vjentry->vpage);
+	cachefs_block_modify(super, vjentry->vblock, &vjentry->vpage);
 	memset(kmap(vjentry->vpage) + vjentry->ventry, 0,
 	       sizeof(struct cachefs_ondisc_validity_journal));
 	kunmap(vjentry->vpage);
 
-	cachefs_block_modify(super,upblock,&uppage);
+	cachefs_block_modify(super, upblock, &uppage);
 	memset(kmap(uppage) + vjentry->upentry, 0, sizeof(cachefs_blockix_t));
 	kunmap(uppage);
 
-	if (trans->jentry->auxentry==UINT_MAX) {
+	if (trans->jentry->auxentry == UINT_MAX) {
 		/* new recycling node */
 		node = kmap(rcypage);
 		node->next  = super->recycle_cur;
@@ -914,12 +951,13 @@
 
 		super->recycle_cur	= vjentry->bix;
 		super->recycle_room	= CACHEFS_ONDISC_LEAVES_PER_FREE_NODE;
-		rcypage	 = xchg(&super->recycle_node,rcypage);
-		rcyblock = xchg(&super->recycle_block,rcyblock);
+		rcypage	 = xchg(&super->recycle_node, rcypage);
+		rcyblock = xchg(&super->recycle_block, rcyblock);
 	}
 	else {
 		/* add to existing recycling node */
-		cachefs_block_modify(super,super->recycle_block,&super->recycle_node);
+		cachefs_block_modify(super, super->recycle_block,
+				     &super->recycle_node);
 
 		node = kmap(super->recycle_node);
 		node->leaves[trans->jentry->auxentry] = vjentry->bix;
@@ -927,7 +965,7 @@
 
 		super->recycle_room--;
 		super->recycle_cur_n++;
-		if (super->recycle_room==0)
+		if (super->recycle_room == 0)
 			super->recycle_cur_n++;
 	}
 
@@ -937,7 +975,7 @@
 	list_del_init(&vjentry->link);
 	spin_unlock(&super->vjnl_lock);
 
-	cachefs_vj_release(super,vjentry);
+	cachefs_vj_release(super, vjentry);
 	cachefs_put_page(uppage);
 	cachefs_put_page(rcypage);
 	cachefs_block_put(upblock);
@@ -952,13 +990,13 @@
 	cachefs_block_put(rcyblock);
 	cachefs_trans_put(trans);
  error:
-	kleave(" [error %d]",ret);
+	kleave(" [error %d]", ret);
 
 } /* end cachefs_recycle_unallocate_data_block() */
 
 /*****************************************************************************/
 /*
- * 
+ *
  */
 int cachefs_replay_ujnl_recyc_empty_node(struct cachefs_super *super,
 					 struct cachefs_ondisc_update_journal *jentry)
@@ -968,7 +1006,7 @@
 
 /*****************************************************************************/
 /*
- * 
+ *
  */
 int cachefs_replay_ujnl_recyc_begin_new(struct cachefs_super *super,
 					struct cachefs_ondisc_update_journal *jentry)
@@ -978,7 +1016,7 @@
 
 /*****************************************************************************/
 /*
- * 
+ *
  */
 int cachefs_replay_ujnl_recyc_transfer(struct cachefs_super *super,
 				       struct cachefs_ondisc_update_journal *jentry)
@@ -988,7 +1026,7 @@
 
 /*****************************************************************************/
 /*
- * 
+ *
  */
 int cachefs_replay_ujnl_recyc_scavenge(struct cachefs_super *super,
 				       struct cachefs_ondisc_update_journal *jentry)
@@ -998,7 +1036,7 @@
 
 /*****************************************************************************/
 /*
- * 
+ *
  */
 int cachefs_replay_ujnl_recyc_makeready(struct cachefs_super *super,
 					struct cachefs_ondisc_update_journal *jentry)

Index: main.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/main.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- main.c	23 May 2003 12:59:21 -0000	1.15
+++ main.c	4 Jul 2003 09:04:44 -0000	1.16
@@ -39,35 +39,39 @@
 	printk(KERN_INFO "cachefs: general fs caching v0.1 registering.\n");
 
 	ret = kcachefs_jnld_start();
-	if (ret<0)
+	if (ret < 0)
 		goto error;
 
 	/* create ourselves a cookie jar and a block har */
 	ret = -ENOMEM;
-	cachefs_cookie_jar = kmem_cache_create("cachefs_cookie_jar",
-					       sizeof(struct cachefs_cookie),
-					       0,
-					       SLAB_HWCACHE_ALIGN,
-					       cachefs_cookie_init_once,
-					       NULL);
+	cachefs_cookie_jar =
+		kmem_cache_create("cachefs_cookie_jar",
+				  sizeof(struct cachefs_cookie),
+				  0,
+				  SLAB_HWCACHE_ALIGN,
+				  cachefs_cookie_init_once,
+				  NULL);
 	if (!cachefs_cookie_jar) {
-		printk(KERN_NOTICE "CacheFS: Failed to allocate a cookie jar\n");
+		printk(KERN_NOTICE
+		       "CacheFS: Failed to allocate a cookie jar\n");
 		goto error_jnld;
 	}
 
-	cachefs_block_jar = kmem_cache_create("cachefs_block_jar",
-					      sizeof(struct cachefs_block),
-					      0,
-					      SLAB_HWCACHE_ALIGN,
-					      cachefs_block_init_once,
-					      NULL);
+	cachefs_block_jar =
+		kmem_cache_create("cachefs_block_jar",
+				  sizeof(struct cachefs_block),
+				  0,
+				  SLAB_HWCACHE_ALIGN,
+				  cachefs_block_init_once,
+				  NULL);
 	if (!cachefs_block_jar) {
-		printk(KERN_NOTICE "CacheFS: Failed to allocate a block jar\n");
+		printk(KERN_NOTICE
+		       "CacheFS: Failed to allocate a block jar\n");
 		goto error_cookie_jar;
 	}
 
 	ret = cachefs_fs_init();
-	if (ret<0)
+	if (ret < 0)
 		goto error_block_jar;
 
 	return ret;
@@ -79,7 +83,7 @@
  error_jnld:
 	kcachefs_jnld_stop();	
  error:
-	printk(KERN_ERR "cachefs: failed to register: %d\n",ret);
+	printk(KERN_ERR "cachefs: failed to register: %d\n", ret);
 	return ret;
 } /* end cachefs_init() */

Index: kcachefsd.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/kcachefsd.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- kcachefsd.c	10 Jun 2003 17:49:49 -0000	1.12
+++ kcachefsd.c	4 Jul 2003 09:04:44 -0000	1.13
@@ -39,16 +39,111 @@
 
 /*****************************************************************************/
 /*
+ * sleep waiting for work
+ */
+static void kcachefsd_sleep(struct cachefs_super *super)
+{
+	DECLARE_WAITQUEUE(myself, current);
+	DECLARE_WAITQUEUE(myself2, current);
+
+	set_current_state(TASK_INTERRUPTIBLE);
+	add_wait_queue(&super->dmn_sleepq, &myself);
+	add_wait_queue(&super->batch_timer_wq, &myself2);
+
+	for (;;) {
+		/* discard pending signals */
+		discard_my_signals();
+
+		/* see if there's work to be done */
+		if (super->dmn_die == 0 &&
+		    (!super->alloc_node ||
+		     super->layout->bix_unready < super->layout->bix_end ||
+		     test_bit(CACHEFS_SUPER_DO_RECLAIM, &super->flags)
+		     ))
+			break;
+
+		if (test_bit(CACHEFS_SUPER_BATCH_TIMER, &super->flags) ||
+		    !list_empty(&super->vjnl_unallocq) ||
+		    !list_empty(&super->vjnl_writtenq)
+		    )
+			break;
+
+		/* deal with the server being asked to die */
+		if (super->dmn_die > 1) {
+			remove_wait_queue(&super->batch_timer_wq, &myself2);
+			remove_wait_queue(&super->dmn_sleepq, &myself);
+			_leave(" [dead]");
+			complete_and_exit(&super->dmn_dead, 0);
+		}
+
+		schedule();
+
+		set_current_state(TASK_INTERRUPTIBLE);
+	}
+
+	remove_wait_queue(&super->batch_timer_wq, &myself2);
+	remove_wait_queue(&super->dmn_sleepq, &myself);
+	set_current_state(TASK_RUNNING);
+} /* end kcachefsd_sleep() */
+
+/*****************************************************************************/
+/*
+ * actually do the work
+ */
+static void kcachefsd_work(struct cachefs_super *super)
+{
+	_debug("@@@ Begin Cache Management");
+
+	if (super->dmn_die)
+		goto dying;
+
+	/* decant the recycling queue */
+	if (test_and_clear_bit(CACHEFS_SUPER_DO_RECLAIM, &super->flags))
+		cachefs_recycle_reclaim(super);
+
+	/* transfer blocks from the unready data if possible */
+	if (super->layout->bix_unready < super->layout->bix_end) {
+		cachefs_recycle_unready_blocks(super);
+
+		if (super->layout->bix_unready == super->layout->bix_end) {
+			printk("CacheFS:"
+			       " all blocks now added to recycling stack\n");
+			cachefs_debug = 1;
+		}
+		else {
+			yield();
+		}
+	}
+
+	/* if there's no next node, then get one */
+	if (!super->alloc_node)
+		cachefs_recycle_transfer_stack(super);
+
+ dying:
+	/* deal with validity journal changes */
+	if (!list_empty(&super->vjnl_unallocq))
+		cachefs_recycle_unallocate_data_block(super);
+
+	if (!list_empty(&super->vjnl_writtenq))
+		cachefs_vj_note_write_completion(super);
+
+	/* write a batch of metadata if it's time to do so */
+	if (test_bit(CACHEFS_SUPER_BATCH_TIMER, &super->flags))
+		cachefs_trans_batch_write(super);
+
+	_debug("@@@ End Cache Management");
+
+} /* end kcachefsd_work() */
+
+/*****************************************************************************/
+/*
  * cache recycling daemon
  */
 int kcachefsd(void *_super)
 {
-	DECLARE_WAITQUEUE(myself,current);
-	DECLARE_WAITQUEUE(myself2,current);
-
 	struct cachefs_super *super = _super;
 
-	printk("CacheFS: Started kcachefsd %d\n",current->pid);
+	printk("CacheFS: Started kcachefsd %d\n", current->pid);
 	super->dmn_task = current;
 
 	daemonize("kcachefsd %02x%02x",
@@ -59,93 +154,17 @@
 
 	/* no signals are of interest */
 	spin_lock_irq(&current->sighand->siglock);
-	siginitsetinv(&current->blocked,0);
+	siginitsetinv(&current->blocked, 0);
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
 	/* loop around looking for things to attend to */
 	for (;;) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&super->dmn_sleepq,&myself);
-		add_wait_queue(&super->batch_timer_wq,&myself2);
-
-		for (;;) {
-			/* discard pending signals */
-			discard_my_signals();
-
-			/* see if there's work to be done */
-			if (super->dmn_die == 0) {
-				if (!super->alloc_node ||
-				    super->layout->bix_unready < super->layout->bix_end ||
-				    test_bit(CACHEFS_SUPER_DO_RECLAIM,&super->flags)
-				    )
-				break;
-			}
-
-			if (test_bit(CACHEFS_SUPER_BATCH_TIMER,&super->flags) ||
-			    !list_empty(&super->vjnl_unallocq) ||
-			    !list_empty(&super->vjnl_writtenq)
-			    )
-				break;
-
-			/* deal with the server being asked to die */
-			if (super->dmn_die > 1) {
-				remove_wait_queue(&super->dmn_sleepq,&myself);
-				_leave("");
-				complete_and_exit(&super->dmn_dead,0);
-			}
-
-			schedule();
-
-			set_current_state(TASK_INTERRUPTIBLE);
-		}
-
-		remove_wait_queue(&super->batch_timer_wq,&myself2);
-		remove_wait_queue(&super->dmn_sleepq,&myself);
-		set_current_state(TASK_RUNNING);
-
-		/* actually do some work */
-		_debug("@@@ Begin Cache Management");
-
-		if (super->dmn_die == 0) {
-			/* decant the recycling queue */
-			if (test_and_clear_bit(CACHEFS_SUPER_DO_RECLAIM,&super->flags))
-				cachefs_recycle_reclaim(super);
-
-			/* transfer blocks from the unready data if possible */
-			if (super->layout->bix_unready<super->layout->bix_end) {
-				cachefs_recycle_unready_blocks(super);
-				if (super->layout->bix_unready==super->layout->bix_end) {
-					printk("CacheFS:"
-					       " all blocks now added to recycling stack\n");
-					cachefs_debug = 1;
-				}
-				else {
-					yield();
-				}
-			}
-
-			/* if there's no next node, then get one */
-			if (!super->alloc_node)
-				cachefs_recycle_transfer_stack(super);
-		}
-
-		/* deal with validity journal changes */
-		if (!list_empty(&super->vjnl_unallocq))
-			cachefs_recycle_unallocate_data_block(super);
-
-		if (!list_empty(&super->vjnl_writtenq))
-			cachefs_vj_note_write_completion(super);
-
-		/* write a batch of metadata if it's time to do so */
-		if (test_bit(CACHEFS_SUPER_BATCH_TIMER,&super->flags))
-			cachefs_trans_batch_write(super);
-
-//		super->dmn_die = 2;
-
-		_debug("@@@ End Cache Management");
-
+		kcachefsd_sleep(super);
+		kcachefsd_work(super);
 		cond_resched();
+
+		// super->dmn_die = 2;
 	}
 
 } /* end kcachefsd() */

Index: kcachefs_jnld.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/kcachefs_jnld.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- kcachefs_jnld.c	21 Mar 2003 14:01:00 -0000	1.5
+++ kcachefs_jnld.c	4 Jul 2003 09:04:44 -0000	1.6
@@ -46,8 +46,8 @@
 {
 	int ret;
 
-	ret = kernel_thread(kcachefs_jnld,NULL,0);
-	if (ret<0)
+	ret = kernel_thread(kcachefs_jnld, NULL, 0);
+	if (ret < 0)
 		return ret;
 
 	wait_for_completion(&kcachefs_jnld_alive);
@@ -74,13 +74,11 @@
  */
 static int kcachefs_jnld(void *arg)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
-//	struct cachefs_super *super;
-//	struct list_head *_p;
 	signed long timo = MAX_SCHEDULE_TIMEOUT;
 
-	printk("CacheFS: Started kcachefs_jnld %d\n",current->pid);
+	DECLARE_WAITQUEUE(myself, current);
+
+	printk("CacheFS: Started kcachefs_jnld %d\n", current->pid);
 
 	daemonize("kujnld");
 
@@ -88,14 +86,14 @@
 
 	/* no signals are of interest */
 	spin_lock_irq(&current->sighand->siglock);
-	siginitsetinv(&current->blocked,0);
+	siginitsetinv(&current->blocked, 0);
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
 	/* loop around looking for things to attend to */
 	do {
 		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&kcachefs_jnld_sleepq,&myself);
+		add_wait_queue(&kcachefs_jnld_sleepq, &myself);
 
 		while (timo) {
 			if (kcachefs_jnld_do_acks ||
@@ -107,7 +105,7 @@
 			set_current_state(TASK_INTERRUPTIBLE);
 		}
 
-		remove_wait_queue(&kcachefs_jnld_sleepq,&myself);
+		remove_wait_queue(&kcachefs_jnld_sleepq, &myself);
 		set_current_state(TASK_RUNNING);
 
 		/* discard pending signals */
@@ -117,13 +115,16 @@
 		timo = MAX_SCHEDULE_TIMEOUT;
 
 		/* poll the superblocks looking for ACKs to process
-		 * - use a semaphore to prevent the list from changing whilst we walk it
+		 * - use a semaphore to prevent the list from changing whilst
+		 *   we walk it
 		 */
 		down(&kcachefs_jnld_list_sem);
 
 #if 0
-		list_for_each(_p,&kcachefs_jnld_list) {
-			super = list_entry(_p,struct cachefs_super,jnld_link);
+		list_for_each(_p, &kcachefs_jnld_list) {
+			super = list_entry(_p,
+					   struct cachefs_super,
+					   jnld_link);
 
 			cachefs_trans_write_batch(super);
 
@@ -131,18 +132,22 @@
 				cachefs_ujnl_process_acks(super);
 
 			if (super->ujnl_ack_pend - super->ujnl_ack_disc &&
-			    time_before(super->ujnl_ack_last + CACHEFS_UJNL_ACKMARK_DELAY,jiffies))
-					cachefs_ujnl_generate_ackmark(super);
+			    time_before(super->ujnl_ack_last +
+					CACHEFS_UJNL_ACKMARK_DELAY,
+					jiffies))
+				cachefs_ujnl_generate_ackmark(super);
 			
-			/* determine how long to wait before we might need to write an ACK mark */
+			/* determine how long to wait before we might need to
+			 * write an ACK mark */
 			if (super->ujnl_ack_pend > super->ujnl_ack_disc) {
 				signed long _timo;
 
-				_timo = super->ujnl_ack_last + CACHEFS_UJNL_ACKMARK_DELAY;
+				_timo = super->ujnl_ack_last;
+				_timo += CACHEFS_UJNL_ACKMARK_DELAY;
 				_timo -= jiffies;
-				if (_timo<0)
+				if (_timo < 0)
 					timo = 0;
-				else if (timo==MAX_SCHEDULE_TIMEOUT || _timo<timo)
+				else if (timo == MAX_SCHEDULE_TIMEOUT || _timo < timo)
 					timo = _timo;
 			}
 		}
@@ -154,7 +159,7 @@
 
 	/* and that's all */
 	kleave("");
-	complete_and_exit(&kcachefs_jnld_dead,0);
+	complete_and_exit(&kcachefs_jnld_dead, 0);
 
 } /* end kcachefs_jnld() */
 
@@ -168,7 +173,7 @@
 
 	down(&kcachefs_jnld_list_sem);
 
-	list_add_tail(&super->jnld_link,&kcachefs_jnld_list);
+	list_add_tail(&super->jnld_link, &kcachefs_jnld_list);
 
 	up(&kcachefs_jnld_list_sem);

Index: journal.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/journal.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- journal.c	11 Jun 2003 11:59:52 -0000	1.36
+++ journal.c	4 Jul 2003 09:04:44 -0000	1.37
@@ -17,6 +17,8 @@
 #include <linux/bio.h>
 #include "cachefs-int.h"
 
+#define UJNL_WRAP(X) ((X) & (CACHEFS_ONDISC_UJNL_NUMENTS - 1))
+
 struct cachefs_replay_find_batch_desc {
 	read_descriptor_t	desc;
 	unsigned short		batch_first;	/* sector holding first entry in batch */
@@ -35,28 +37,37 @@
 	"RcycXfer ",
 	"RcycScvng",
[...1618 lines suppressed...]
 
 		if (ret<0) {
-			printk("CacheFS: failed to reload recycling stack: %d\n",ret);
+			printk("CacheFS: failed to reload recycling stack: %d\n",
+			       ret);
 			return ret;
 		}
 
@@ -1707,9 +1809,10 @@
 
 		node = kmap(super->recycle_node);
 
-		for (loop=0; loop<CACHEFS_ONDISC_LEAVES_PER_FREE_NODE; loop++)
+		for (loop = 0; loop < CACHEFS_ONDISC_LEAVES_PER_FREE_NODE; loop++)
 			if (!node->leaves[loop])
 				break;
+
 		super->recycle_room = CACHEFS_ONDISC_LEAVES_PER_FREE_NODE - loop;
 		super->recycle_cur_n = node->count + super->recycle_room;

Index: io.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/io.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- io.c	1 Jul 2003 17:44:50 -0000	1.14
+++ io.c	4 Jul 2003 09:04:44 -0000	1.15
@@ -22,14 +22,18 @@
 #include "cachefs-int.h"
 
 static int cachefs_vio_readpage(struct file *file, struct page *page);
-static int cachefs_vio_readpages(struct file *file, struct address_space *mapping,
-				 struct list_head *pages, unsigned nr_pages);
-static int cachefs_vio_writepage(struct page *page, struct writeback_control *wbc);
-static int cachefs_vio_writepages(struct address_space *mapping, struct writeback_control *wbc);
-static int cachefs_vio_prepare_write(struct file *file, struct page *page, unsigned from,
-				     unsigned to);
-static int cachefs_vio_commit_write(struct file *file, struct page *page, unsigned from,
-				    unsigned to);
+static int cachefs_vio_readpages(struct file *file,
+				 struct address_space *mapping,
+				 struct list_head *pages,
+				 unsigned nr_pages);
+static int cachefs_vio_writepage(struct page *page,
+				 struct writeback_control *wbc);
+static int cachefs_vio_writepages(struct address_space *mapping,
+				  struct writeback_control *wbc);
+static int cachefs_vio_prepare_write(struct file *file, struct page *page,
+				     unsigned from, unsigned to);
+static int cachefs_vio_commit_write(struct file *file, struct page *page,
+				    unsigned from, unsigned to);
 static int cachefs_vio_invalidatepage(struct page *page, unsigned long offset);
 static int cachefs_vio_releasepage(struct page *page, int gfp_flags);
 static int cachefs_vio_set_page_dirty(struct page *page);
@@ -59,12 +63,14 @@
  * status of that page is hard.  See end_buffer_async_read() for the details.
  * There is no point in duplicating all that complexity.
  */
-static int cachefs_vio_io_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
+static int cachefs_vio_io_end_io_read(struct bio *bio, unsigned int bytes_done,
+				      int err)
 {
 	const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
 	struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
 
-	_enter("{sz=%u rw=%lu},%u,%d",bio->bi_size,bio->bi_rw,bytes_done,err);
+	_enter("{sz=%u rw=%lu},%u,%d",
+	       bio->bi_size, bio->bi_rw, bytes_done, err);
 
 	if (bio->bi_size)
 		return 1;
@@ -92,26 +98,30 @@
 	struct bio *bio;
 
 	bio = *_bio;
-	if (!bio) return;
+	if (!bio)
+		return;
 	*_bio = NULL;
 
-	_enter("{sz=%u}",bio->bi_size);
+	_enter("{sz=%u}", bio->bi_size);
 
 	bio->bi_end_io = cachefs_vio_io_end_io_read;
-	submit_bio(READ,bio);
+	submit_bio(READ, bio);
 }
 
 static int cachefs_vio_io_alloc(struct super_block *sb,
-				sector_t first_sector, int nr_vecs, int gfp_flags,
+				sector_t first_sector,
+				int nr_vecs,
+				int gfp_flags,
 				struct bio **_bio)
 {
 	struct bio *bio;
 
 	*_bio = NULL;
 
-	_enter("{bits=%u},%llu,%d,%x,",sb->s_blocksize_bits,first_sector,nr_vecs,gfp_flags);
+	_enter("{bits=%u},%llu,%d,%x,",
+	       sb->s_blocksize_bits, first_sector, nr_vecs, gfp_flags);
 
-	bio = bio_alloc(gfp_flags,nr_vecs);
+	bio = bio_alloc(gfp_flags, nr_vecs);
 
 	if (!bio && (current->flags & PF_MEMALLOC)) {
 		while (!bio && (nr_vecs /= 2))
@@ -126,15 +136,18 @@
 	return 0;
 }
 
-static int cachefs_vio_writepages(struct address_space *mapping, struct writeback_control *wbc)
+static int cachefs_vio_writepages(struct address_space *mapping,
+				  struct writeback_control *wbc)
 {
 	struct page *page;
 
 	spin_lock(&mapping->page_lock);
 
-	list_splice_init(&mapping->dirty_pages,&mapping->io_pages);
+	list_splice_init(&mapping->dirty_pages,
+			 &mapping->io_pages);
 
-	if (list_empty(&mapping->dirty_pages) && list_empty(&mapping->io_pages)) {
+	if (list_empty(&mapping->dirty_pages) &&
+	    list_empty(&mapping->io_pages)) {
 		spin_unlock(&mapping->page_lock);
 		return 0;
 	}
@@ -142,10 +155,10 @@
 	/* shouldn't ever get this far */
 	printk("CacheFS: meta-data writepages not supported\n");
 
-	printk("- inode %lx\n",mapping->host->i_ino);
+	printk("- inode %lx\n", mapping->host->i_ino);
 
-	list_for_each_entry(page,&mapping->io_pages,list) {
-		printk("  - pg %lu\n",page->index);
+	list_for_each_entry(page, &mapping->io_pages, list) {
+		printk("  - pg %lu\n", page->index);
 	}
 
 	spin_unlock(&mapping->page_lock);
@@ -154,7 +167,8 @@
 	return -EIO;
 }
 
-static int cachefs_vio_writepage(struct page *page, struct writeback_control *wbc)
+static int cachefs_vio_writepage(struct page *page,
+				 struct writeback_control *wbc)
 {
 	printk("CacheFS: meta-data writepage not supported\n");
 	BUG();
@@ -181,7 +195,9 @@
 /*
  *
  */
-static int cachefs_vio_do_readpage(struct bio **_bio, struct page *page, unsigned nr_pages,
+static int cachefs_vio_do_readpage(struct bio **_bio,
+				   struct page *page,
+				   unsigned nr_pages,
 				   cachefs_blockix_t *last_block_in_bio)
 {
 	struct cachefs_page *pageio;
@@ -190,26 +206,32 @@
 
 	_enter("");
 
-	ret = cachefs_page_get_private(page,&pageio,GFP_KERNEL);
-	if (ret<0)
+	ret = cachefs_page_get_private(page, &pageio, GFP_KERNEL);
+	if (ret < 0)
 		goto error;
 
-	ret = cachefs_block_insert(inode->i_sb->s_fs_info,page->index,&pageio->mapped_block);
-	if (ret<0)
+	ret = cachefs_block_insert(inode->i_sb->s_fs_info,
+				   page->index,
+				   &pageio->mapped_block);
+	if (ret < 0)
 		goto error;
 
 	/* dispatch the outstanding BIO if the pages are not adjacent */
-	if (*_bio && *last_block_in_bio != page->index-1)
+	if (*_bio && *last_block_in_bio != page->index - 1)
 		cachefs_vio_io_bio_submit(_bio);
 
  alloc_new:
 	if (!*_bio) {
-		ret = cachefs_vio_io_alloc(inode->i_sb,page->index,nr_pages,GFP_KERNEL,_bio);
-		if (ret<0)
+		ret = cachefs_vio_io_alloc(inode->i_sb,
+					   page->index,
+					   nr_pages,
+					   GFP_KERNEL,
+					   _bio);
+		if (ret < 0)
 			goto error;
 	}
 
-	if (!bio_add_page(*_bio,page,PAGE_SIZE,0)) {
+	if (!bio_add_page(*_bio, page, PAGE_SIZE, 0)) {
 		cachefs_vio_io_bio_submit(_bio);
 		goto alloc_new;
 	}
@@ -220,8 +242,9 @@
 	return 0;
 
  error:
-	if (*_bio) cachefs_vio_io_bio_submit(_bio);
-	_leave("= %d",ret);
+	if (*_bio)
+		cachefs_vio_io_bio_submit(_bio);
+	_leave("= %d", ret);
 	return ret;
 } /* end cachefs_vio_do_readpage() */
 
@@ -238,19 +261,22 @@
 	unsigned page_idx;
 	int ret;
 
-	_enter(",,%u",nr_pages);
+	_enter(",,%u", nr_pages);
 
 	ret = 0;
-	pagevec_init(&lru_pvec,0);
-	for (page_idx=0; page_idx<nr_pages; page_idx++) {
-		struct page *page = list_entry(pages->prev,struct page,list);
+	pagevec_init(&lru_pvec, 0);
+	for (page_idx = 0; page_idx < nr_pages; page_idx++) {
+		struct page *page = list_entry(pages->prev, struct page, list);
 
 		prefetchw(&page->flags);
 		list_del(&page->list);
-		if (!add_to_page_cache(page,mapping,page->index,GFP_KERNEL)) {
-			ret = cachefs_vio_do_readpage(&bio,page,nr_pages-page_idx,
+		if (!add_to_page_cache(page, mapping, page->index,
+				       GFP_KERNEL)) {
+			ret = cachefs_vio_do_readpage(&bio,
+						      page,
+						      nr_pages - page_idx,
 						      &last_block_in_bio);
-			if (ret<0)
+			if (ret < 0)
 				break;
 			if (!pagevec_add(&lru_pvec, page))
 				__pagevec_lru_add(&lru_pvec);
@@ -261,9 +287,10 @@
 	pagevec_lru_add(&lru_pvec);
 	BUG_ON(!list_empty(pages));
 
-	if (bio) cachefs_vio_io_bio_submit(&bio);
+	if (bio)
+		cachefs_vio_io_bio_submit(&bio);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_vio_readpages() */
 
@@ -278,23 +305,26 @@
 	struct bio *bio;
 	int ret;
 
-	_enter(",{%lu}",page->index);
+	_enter(",{%lu}", page->index);
 
-	ret = cachefs_page_get_private(page,&pageio,GFP_KERNEL);
-	if (ret<0)
+	ret = cachefs_page_get_private(page, &pageio, GFP_KERNEL);
+	if (ret < 0)
 		return ret;
 
-	ret = cachefs_block_insert(inode->i_sb->s_fs_info,page->index,&pageio->mapped_block);
-	if (ret<0)
+	ret = cachefs_block_insert(inode->i_sb->s_fs_info, page->index,
+				   &pageio->mapped_block);
+	if (ret < 0)
 		return ret;
 
-	ret = cachefs_vio_io_alloc(inode->i_sb,page->index,1,GFP_KERNEL,&bio);
-	if (ret==0) {
-		if (!bio_add_page(bio,page,PAGE_SIZE,0)) BUG();
+	ret = cachefs_vio_io_alloc(inode->i_sb, page->index, 1, GFP_KERNEL,
+				   &bio);
+	if (ret == 0) {
+		if (!bio_add_page(bio, page, PAGE_SIZE, 0))
+			BUG();
 		cachefs_vio_io_bio_submit(&bio);
 	}
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_vio_readpage() */
 
@@ -308,32 +338,31 @@
 	struct cachefs_page *pageio;
 	int ret = 1;
 
-	_enter("{%lu},%lu",page->index,offset);
+	_enter("{%lu},%lu", page->index, offset);
 
 	BUG_ON(!PageLocked(page));
 	if (!PagePrivate(page))
 		goto out;
 
-	pageio = (struct cachefs_page*) page->private;
-	block = xchg(&pageio->mapped_block,NULL);
+	pageio = (struct cachefs_page *) page->private;
+	block = xchg(&pageio->mapped_block, NULL);
 	pageio->flags = 0;
 
 	if (block) {
 		int usage = atomic_read(&block->usage);
 
-		if ((usage&0xffffff00)==0x6b6b6b00) {
-			printk("\nBLOCK PUT ERROR pg=%p{ix=%lu} blk=%p{u=%x}\n",
-			       page,page->index,block,usage);
+		if ((usage & 0xffffff00) == 0x6b6b6b00) {
+			printk("BLOCK PUT ERROR pg=%p{ix=%lu} blk=%p{u=%x}\n",
+			       page, page->index, block, usage);
 			BUG();
 		}
 
 		cachefs_block_put(block);
 	}
 
-	/*
-	 * We release buffers only if the entire page is being invalidated.
-	 * The get_block cached value has been unconditionally invalidated,
-	 * so real IO is not possible anymore.
+	/* We release buffers only if the entire page is being invalidated.
+	 * The get_block cached value has been unconditionally invalidated, so
+	 * real IO is not possible anymore.
 	 */
 	if (offset == 0) {
 		BUG_ON(!PageLocked(page));
@@ -354,20 +383,17 @@
  */
 static int cachefs_vio_releasepage(struct page *page, int gfp_flags)
 {
-	struct cachefs_block *block;
 	struct cachefs_page *pageio;
 
-	_enter("{%lu},%x",page->index,gfp_flags);
+	_enter("{%lu},%x", page->index, gfp_flags);
 
 	if (PagePrivate(page)) {
-		pageio = (struct cachefs_page*) page->private;
+		pageio = (struct cachefs_page *) page->private;
 		page->private = 0;
 		ClearPagePrivate(page);
 
 		if (pageio) {
-			block = xchg(&pageio->mapped_block,NULL);
-			if (block)
-				cachefs_block_put(block);
+			cachefs_block_put(xchg(&pageio->mapped_block, NULL));
 			dbgfree(pageio);
 			kfree(pageio);
 		}
@@ -383,7 +409,7 @@
  */
 static int cachefs_vio_set_page_dirty(struct page *page)
 {
-	kenter("{%lu}",page->index);
+	kenter("{%lu}", page->index);
 
 	BUG();
 
@@ -418,14 +444,15 @@
 		       bio->bi_io_vec[loop].bv_page,
 		       bio->bi_io_vec[loop].bv_page->index,
 		       bio->bi_io_vec[loop].bv_offset,
-		       bio->bi_io_vec[loop].bv_offset + bio->bi_io_vec[loop].bv_len - 1
+		       bio->bi_io_vec[loop].bv_offset +
+		       bio->bi_io_vec[loop].bv_len - 1
 		       );
 
 		stuff = page_address(bio->bi_io_vec[loop].bv_page);
 		stuff += bio->bi_io_vec[loop].bv_offset;
 
-		for (loop2=0; loop2<20; loop2++)
-			printk("%02x",stuff[loop2]);
+		for (loop2 = 0; loop2 < 20; loop2++)
+			printk("%02x", stuff[loop2]);
 
 		printk(" }\n");
 	}

Index: interface.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/interface.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- interface.c	10 Jun 2003 17:49:49 -0000	1.13
+++ interface.c	4 Jul 2003 09:04:44 -0000	1.14
@@ -25,7 +25,8 @@
 
 kmem_cache_t *cachefs_cookie_jar;
 
-static cachefs_match_val_t cachefs_fsdef_index_match(void *target, const void *entry);
+static cachefs_match_val_t cachefs_fsdef_index_match(void *target,
+						     const void *entry);
 
 static void cachefs_fsdef_index_update(void *source, void *entry);
 
@@ -47,10 +48,10 @@
 static void __cachefs_cookie_put(struct cachefs_cookie *cookie);
[...1022 lines suppressed...]
 	struct cachefs_page *pageio;
 	int ret;
 
-	_enter(",{%lu}",page->index);
+	_enter(",{%lu}", page->index);
 
 	if (!cookie) {
 		_leave(" [no cookie]");
@@ -1167,9 +1212,9 @@
 
 	BUG_ON(cookie->idef); /* not supposed to use this for indexes */
 
-	ret = cookie->netfs->ops->get_page_cookie(page,&pageio);
+	ret = cookie->netfs->ops->get_page_cookie(page, &pageio);
 	if (ret<0) {
-		_leave(" [get_page_cookie() =:%d]",ret);
+		_leave(" [get_page_cookie() = %d]", ret);
 		return;
 	}

Index: inode.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/inode.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- inode.c	10 Jun 2003 17:49:49 -0000	1.20
+++ inode.c	4 Jul 2003 09:04:44 -0000	1.21
@@ -22,7 +22,8 @@
 #include <asm/div64.h>
 #include "cachefs-int.h"
 
-static int cachefs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
+static int cachefs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
+				 struct kstat *stat);
 
 static struct inode_operations cachefs_inode_operations = {
 	.getattr	= cachefs_inode_getattr,
@@ -61,13 +62,14 @@
 /*
  * set up a linear file inode
  */
-static void cachefs_iget_linear_file(struct cachefs_inode *inode, unsigned blocks)
+static void cachefs_iget_linear_file(struct cachefs_inode *inode,
+				     unsigned blocks)
 {
 	inode->vfs_inode.i_mode		= S_IFREG | S_IRUGO;
 	inode->vfs_inode.i_uid		= 0;
 	inode->vfs_inode.i_gid		= 0;
 	inode->vfs_inode.i_nlink	= 1;
-	inode->vfs_inode.i_size		= (unsigned long)blocks << PAGE_SHIFT;
+	inode->vfs_inode.i_size		= (unsigned long) blocks << PAGE_SHIFT;
 	inode->vfs_inode.i_atime	= CURRENT_TIME;
 	inode->vfs_inode.i_mtime	= CURRENT_TIME;
 	inode->vfs_inode.i_ctime	= CURRENT_TIME;
@@ -84,7 +86,8 @@
 
 /*****************************************************************************/
 /*
- * retrieve the inode for the meta-data file, the first block of which we know to reside in block 1
+ * retrieve the inode for the meta-data file, the first block of which we know
+ * to reside in block 1
  */
 static int cachefs_iget_file0(struct cachefs_inode *inode)
 {
@@ -95,9 +98,11 @@
 
 	super = inode->vfs_inode.i_sb->s_fs_info;
 
-	_enter("{sb=%p ino=%lu}",inode->vfs_inode.i_sb,inode->vfs_inode.i_ino);
+	_enter("{sb=%p ino=%lu}",
+	       inode->vfs_inode.i_sb, inode->vfs_inode.i_ino);
 
-	/* stick in some initial values so that we can read the first page into the page cache */
+	/* stick in some initial values so that we can read the first page into
+	 * the page cache */
 	inode->vfs_inode.i_mode		= S_IFREG | S_IRUGO | S_IWUSR;
 	inode->vfs_inode.i_uid		= 0;
 	inode->vfs_inode.i_gid		= 0;
@@ -116,14 +121,15 @@
 	inode->index_esize	= inode->index_dsize;
 	inode->index_epp	= PAGE_SIZE / inode->index_esize;
 
-	__set_bit(CACHEFS_ACTIVE_INODE_ISINDEX,&inode->flags);
+	__set_bit(CACHEFS_ACTIVE_INODE_ISINDEX, &inode->flags);
 
 	/* read the page containing this inode's meta-data */
 	pos = inode->vfs_inode.i_ino << super->layout->metadata_bits;
-	ret = cachefs_get_page(inode,pos/PAGE_SIZE,&inode->metadata_page);
+	ret = cachefs_get_page(inode, pos / PAGE_SIZE, &inode->metadata_page);
 	if (ret<0) {
-		printk("kAFS: Failed to read meta-data page %lu: %d\n",pos/PAGE_SIZE,ret);
-		_leave(" = %d",ret);
+		printk("kAFS: Failed to read meta-data page %lu: %d\n",
+		       pos / PAGE_SIZE, ret);
+		_leave(" = %d", ret);
 		return ret;
 	}
 	inode->metadata = __cachefs_get_page_block(inode->metadata_page);
@@ -131,7 +137,7 @@
 	metadata = cachefs_metadata_preread(inode);
 
 	_debug("read page %lu (pos %04x-%04x)",
-	       inode->metadata_page->index,pos,pos+inode->index_esize-1);
+	       inode->metadata_page->index, pos, pos + inode->index_esize - 1);
 
 	inode->vfs_inode.i_size		= metadata->size;
 	inode->vfs_inode.i_blocks	= metadata->size + inode->vfs_inode.i_blksize - 1;
@@ -153,12 +159,12 @@
 
 	_leave(" = 0");
 	return 0;
-
 } /* end cachefs_iget_file0() */
 
 /*****************************************************************************/
 /*
- * retrieve the inode for the Nth file, for which we have to look it up in the meta-data file
+ * retrieve the inode for the Nth file, for which we have to look it up in the
+ * meta-data file
  */
 static int cachefs_iget_fileN(struct cachefs_inode *inode)
 {
@@ -170,7 +176,7 @@
 
 	super = inode->vfs_inode.i_sb->s_fs_info;
 
-	_enter("{s=%p ino=%lu}",super,inode->vfs_inode.i_ino);
+	_enter("{s=%p ino=%lu}", super, inode->vfs_inode.i_ino);
 
 	/* get the meta-file inode */
 	imetadata = cachefs_igrab(super->imetadata);
@@ -181,25 +187,23 @@
 
 	/* read the page containing this inode's meta-data */
 	pos = inode->vfs_inode.i_ino * imetadata->index_esize;
-	ret = cachefs_get_page(imetadata,pos/PAGE_SIZE,&inode->metadata_page);
+	ret = cachefs_get_page(imetadata, pos / PAGE_SIZE,
+			       &inode->metadata_page);
 	cachefs_iput(imetadata);
-	if (ret<0) {
-		printk("CacheFS: Failed to read meta-data page %lu: %d\n",pos/PAGE_SIZE,ret);
-		_leave(" = %d",ret);
+	if (ret < 0) {
+		printk("CacheFS: Failed to read meta-data page %lu: %d\n",
+		       pos / PAGE_SIZE, ret);
+		_leave(" = %d", ret);
 		return ret;
 	}
 	inode->metadata = __cachefs_get_page_block(inode->metadata_page);
 
 	_debug("Reading inode %lu metadata record {%lu,{%u}}+%04x",
-	       inode->vfs_inode.i_ino,inode->metadata_page->index,
-	       inode->metadata->bix,pos);
+	       inode->vfs_inode.i_ino,
+	       inode->metadata_page->index,
+	       inode->metadata->bix,
+	       pos);
 
-#if 0
-	if (inode->metadata.mtime==0) {
-		inode->metadata.mtime = CURRENT_TIME;
-		mark_inode_dirty(&inode->vfs_inode);
-	}
-#endif
 	inode->vfs_inode.i_atime.tv_nsec = 0;
 	inode->vfs_inode.i_mtime.tv_nsec = 0;
 	inode->vfs_inode.i_ctime.tv_nsec = 0;
@@ -216,7 +220,8 @@
 	inode->vfs_inode.i_ctime.tv_sec	= metadata->mtime;
 	inode->vfs_inode.i_blksize	= PAGE_SIZE;
 	inode->vfs_inode.i_blkbits	= PAGE_SHIFT;
-	inode->vfs_inode.i_blocks	= metadata->size + inode->vfs_inode.i_blksize-1;
+	inode->vfs_inode.i_blocks	= metadata->size;
+	inode->vfs_inode.i_blocks	+= inode->vfs_inode.i_blksize - 1;
 	inode->vfs_inode.i_blocks	>>= PAGE_SHIFT;
 	inode->vfs_inode.i_version	= metadata->version;
 	inode->vfs_inode.i_flags	|= S_NOATIME;
@@ -224,32 +229,33 @@
 	inode->vfs_inode.i_fop		= &cachefs_file_operations;
 	inode->vfs_inode.i_mapping->a_ops = &cachefs_addrspace_operations;
 
-	inode->index_dsize	= metadata->index_dsize;
-	inode->index_esize	= metadata->index_esize;
+	inode->index_dsize = metadata->index_dsize;
+	inode->index_esize = metadata->index_esize;
 
 	cachefs_metadata_postread(inode);
 
 	inode->index_epp = 0;
-	if (inode->index_esize || inode->vfs_inode.i_ino==CACHEFS_INO_ROOTDIR) {
+	if (inode->index_esize ||
+	    inode->vfs_inode.i_ino == CACHEFS_INO_ROOTDIR) {
 		inode->index_epp = PAGE_SIZE / metadata->index_esize;
-		inode->vfs_inode.i_mode		= S_IFDIR | S_IRUGO | S_IXUGO;
-		inode->vfs_inode.i_nlink	= 2;
-		inode->vfs_inode.i_op		= &cachefs_root_inode_operations;
-		inode->vfs_inode.i_fop		= &cachefs_root_file_operations;
+		inode->vfs_inode.i_mode	= S_IFDIR | S_IRUGO | S_IXUGO;
+		inode->vfs_inode.i_nlink = 2;
+		inode->vfs_inode.i_op	= &cachefs_root_inode_operations;
+		inode->vfs_inode.i_fop	= &cachefs_root_file_operations;
 
-		__set_bit(CACHEFS_ACTIVE_INODE_ISINDEX,&inode->flags);
+		__set_bit(CACHEFS_ACTIVE_INODE_ISINDEX, &inode->flags);
 	}
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
-
 } /* end cachefs_iget_fileN() */
 
 /*****************************************************************************/
 /*
  * attempt to retrieve the inode for a cached file
  */
-int cachefs_iget(struct cachefs_super *super, ino_t ino, struct cachefs_inode **_inode)
+int cachefs_iget(struct cachefs_super *super, ino_t ino,
+		 struct cachefs_inode **_inode)
 {
 	struct cachefs_inode *inode;
 	struct inode *vfs_inode;
@@ -257,12 +263,14 @@
 	loff_t nblocks;
 	int ret;
 
-	_enter(",%lu,",ino);
+	_enter(",%lu,", ino);
 
 	*_inode = NULL;
 
+	BUG_ON(ino == 0);
+
 	/* it does reside in this cache - create an inode for it */
-	vfs_inode = iget_locked(super->sb,ino);
+	vfs_inode = iget_locked(super->sb, ino);
 	if (!vfs_inode) {
 		_leave(" = -ENOMEM");
 		return -ENOMEM;
@@ -282,16 +290,16 @@
 		/* miscellaneous data block linear inode */
 	case CACHEFS_INO_MISC:
 		nblocks = super->sb->s_bdev->bd_inode->i_size;
-		do_div(nblocks,PAGE_SIZE);
-		if (nblocks>UINT_MAX)
+		do_div(nblocks, PAGE_SIZE);
+		if (nblocks > UINT_MAX)
 			nblocks = UINT_MAX;
-		cachefs_iget_linear_file(inode,nblocks);
+		cachefs_iget_linear_file(inode, nblocks);
 		break;
 
 		/* writeback journal linear inode */
 	case CACHEFS_INO_WBJOURNAL:
 		tmp = super->layout->bix_cache - super->layout->bix_wbjournal;
-		cachefs_iget_linear_file(inode,tmp);
+		cachefs_iget_linear_file(inode, tmp);
 		break;
 
 		/* status file */
@@ -301,17 +309,19 @@
 
 		/* metadata meta-data inode */
 	case CACHEFS_INO_METADATA:
-		inode->metadata_offset = (ino << super->layout->metadata_bits) & ~PAGE_MASK;
+		inode->metadata_offset =
+			(ino << super->layout->metadata_bits) & ~PAGE_MASK;
 		ret = cachefs_iget_file0(inode);
-		if (ret<0)
+		if (ret < 0)
 			goto bad_inode;
 		break;
 
 		/* index and data-cache inodes */
 	default:
-		inode->metadata_offset = (ino << super->layout->metadata_bits) & ~PAGE_MASK;
+		inode->metadata_offset =
+			(ino << super->layout->metadata_bits) & ~PAGE_MASK;
 		ret = cachefs_iget_fileN(inode);
-		if (ret<0)
+		if (ret < 0)
 			goto bad_inode;
 		break;
 	}
@@ -320,7 +330,7 @@
 	unlock_new_inode(&inode->vfs_inode);
 
 	*_inode = inode;
-	_leave(" = 0 [%p]",inode);
+	_leave(" = 0 [%p]", inode);
 	return 0;
 
 	/* failure */
@@ -329,122 +339,20 @@
 	unlock_new_inode(&inode->vfs_inode);
 	iput(&inode->vfs_inode);
 
-	_leave(" = %d [bad]",ret);
+	_leave(" = %d [bad]", ret);
 	return ret;
-
 } /* end cachefs_iget() */
 
-#if 0
-/*****************************************************************************/
-/*
- *
- */
-static int cachefs_end_write_inode(struct bio *bio, unsigned int bytes_done, int err)
-{
-	const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
-	struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
-
-	_enter("{sz=%u rw=%lu},%u,%d",bio->bi_size,bio->bi_rw,bytes_done,err);
-
-	if (bio->bi_size)
-		return 1;
-
-	do {
-		struct page *page = bvec->bv_page;
-
-		if (--bvec >= bio->bi_io_vec)
-			prefetchw(&bvec->bv_page->flags);
-
-		if (!uptodate)
-			SetPageError(page);
-		end_page_writeback(page);
-	} while (bvec >= bio->bi_io_vec);
-	bio_put(bio);
-	return 0;
-} /* end cachefs_end_write_inode() */
-#endif
-
 /*****************************************************************************/
 /*
  * write a cache inode back to disc
- * - don't use generic_file_write() to write out the meta-data file's meta-data as it updates the
- *   mtime & ctime and marks the inode dirty again
+ * - don't use generic_file_write() to write out the meta-data file's meta-data
+ *   as it updates the mtime & ctime and marks the inode dirty again
  */
 void cachefs_write_inode(struct inode *vfs_inode, int sync)
 {
-#if 0
-	struct cachefs_ondisc_metadata *metadata;
-	struct cachefs_super *super;
-	struct cachefs_inode *inode;
-	struct bio *bio;
-#endif
-	unsigned ino;
-
-	ino = vfs_inode->i_ino;
-
-	_enter("{sb=%p ino=%u},%d",vfs_inode->i_sb,ino,sync);
-
-#if 0
-	inode = CACHEFS_FS_I(vfs_inode);
-	super = vfs_inode->i_sb->s_fs_info;
-
-	bio = bio_alloc(GFP_KERNEL,1);
-	if (!bio) {
-		printk("CacheFS: Can't allocate BIO to write inode: -ENOMEM\n");
-		return;
-	}
-
-	tmp = (ino << super->sb->s_blocksize_bits) & (PAGE_SIZE-1);
-
-	_debug("Writing inode %u metadata record {{%u}}+%04x",
-	       ino,cachefs_pageio(inode->metadata)->mapped_block,tmp);
-
-	bio->bi_sector	= __cachefs_get_page_block(inode->metadata)->bix;
-	bio->bi_sector	<<= (PAGE_SHIFT - super->sb->s_blocksize_bits);
-	bio->bi_sector	+= tmp >> super->sb->s_blocksize_bits;
-	bio->bi_bdev	= super->sb->s_bdev;
-	bio->bi_end_io	= cachefs_end_write_inode;
-
-	if (!bio_add_page(bio,inode->metadata,super->sb->s_blocksize,tmp))
-		BUG();
-
-	/* make the change */
-	lock_page(inode->metadata);
-
-	metadata =
-		kmap(inode->metadata) +
-		(ino % CACHEFS_METADATA_PER_PAGE) * CACHEFS_ONDISC_METADATA_RECSIZE;
-
-	metadata->size		= inode->vfs_inode.i_size;
-	metadata->version	= inode->vfs_inode.i_version;
-	metadata->mtime		= inode->vfs_inode.i_mtime.tv_sec;
-
-	kunmap(inode->metadata);
-	flush_dcache_page(inode->metadata);
-
-	SetPageWriteback(inode->metadata);
-	unlock_page(inode->metadata);
-
-	submit_bio(WRITE,bio);
-	if (sync)
-		wait_on_page_writeback(inode->metadata);
-#endif
-
-#if 0
-	/* update the modification time of the meta-data inode */
-	if (inode!=imetadata) {
-		time_t time_now = CURRENT_TIME;
-		if (imetadata->vfs_inode.i_ctime != time_now ||
-		    imetadata->vfs_inode.i_mtime != time_now
-		    ) {
-			imetadata->vfs_inode.i_ctime = time_now;
-			imetadata->vfs_inode.i_mtime = time_now;
-			mark_inode_dirty_sync(&imetadata->vfs_inode);
-		}
-	}
-#endif
+	_enter("{sb=%p ino=%lu},%d", vfs_inode->i_sb, vfs_inode->i_ino, sync);
 
-	_leave("");
 } /* end cachefs_write_inode() */
 
 /*****************************************************************************/
@@ -453,25 +361,20 @@
  */
 void cachefs_clear_inode(struct inode *vfs_inode)
 {
-	struct cachefs_inode *inode;
-
-	inode = CACHEFS_FS_I(vfs_inode);
-
-	_enter("{ino=%lu nl=%u}",inode->vfs_inode.i_ino,inode->vfs_inode.i_nlink);
+	_enter("{ino=%lu nl=%u}", vfs_inode->i_ino, vfs_inode->i_nlink);
 
-	_leave("");
 } /* end cachefs_clear_inode() */
 
 /*****************************************************************************/
 /*
  * read the attributes of an inode
  */
-int cachefs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+int cachefs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
+			  struct kstat *stat)
 {
-	_enter("{ ino=%lu }",dentry->d_inode->i_ino);
+	_enter("{ ino=%lu }", dentry->d_inode->i_ino);
 
-	/* transfer attributes from the inode structure to the stat structure */
-	generic_fillattr(dentry->d_inode,stat);
+	generic_fillattr(dentry->d_inode, stat);
 
 	_leave(" = 0");
 	return 0;

Index: index.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/index.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- index.c	11 Jun 2003 11:59:52 -0000	1.23
+++ index.c	4 Jul 2003 09:04:44 -0000	1.24
@@ -52,7 +52,7 @@
 	void *content;
 	int ret;
 
-	_enter(",{%lu},%lu,%lu",page->index,offset,size);
+	_enter(",{%lu},%lu,%lu", page->index, offset, size);
 
 	rec = (struct cachefs_index_search_record *) desc->buf;
 	ret = size;
@@ -61,14 +61,15 @@
 	tmp = offset;
 	offset += rec->entsize - 1;
 	offset -= offset % rec->entsize;
-	if (offset-tmp > size)
+	if (offset - tmp > size)
 		goto done;
 
 	size -= offset - tmp;
 
-	/* limit the search of this page to the amount specified in desc->count */
+	/* limit the search of this page to the amount specified in
+	 * desc->count */
 	stop = desc->count;
-	if (size<stop)
+	if (size < stop)
 		stop = size;
 
 	tmp = rec->entsize;
@@ -76,16 +77,30 @@
 	/* search the elements on the page (ignoring slack at end) */
 	content = kmap(page);
 
-	for (; offset+tmp<=stop; offset+=tmp) {
+	for (; offset + tmp <= stop; offset += tmp) {
 		struct cachefs_ondisc_index_entry *xent = content + offset;
 
-		if (xent->state==CACHEFS_ONDISC_INDEX_FREE ||
-		    xent->state==CACHEFS_ONDISC_INDEX_RECYCLE)
+		if (xent->state == CACHEFS_ONDISC_INDEX_FREE ||
+		    xent->state == CACHEFS_ONDISC_INDEX_RECYCLE)
 			continue;
 
-		if (rec->index->idef->match(rec->target->netfs_data,xent->data)) {
-			rec->entry = offset/tmp + page->index*(PAGE_SIZE/tmp);
+		if (rec->index->idef->match(rec->target->netfs_data,
+					    xent->data)) {
+			rec->entry = offset / tmp;
+			rec->entry += page->index * (PAGE_SIZE / tmp);
 			rec->ino   = xent->ino;
+
+			if (rec->ino == 0) {
+				printk("CacheFS: Unexpected 0 inode number in"
+				       " index %lu ent %u {%lu [%u] +%lu}\n",
+				       rec->iinode->vfs_inode.i_ino,
+				       rec->entry,
+				       page->index,
+				       __cachefs_get_page_block(page)->bix,
+				       offset / tmp);
+				BUG();
+			}
+
 			desc->count = 0;
 			ret = 0;
 			break;
@@ -98,7 +113,7 @@
 	desc->count -= ret;
 	desc->written += ret;
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_index_search_actor() */
 
@@ -120,7 +135,7 @@
 	loff_t pos;
 	int ret;
 
-	_enter("{%s,%lu}",index->cookie->idef->name,index->vfs_inode.i_ino);
+	_enter("{%s,%lu}", index->cookie->idef->name, index->vfs_inode.i_ino);
 
 	if (_entry)
 		*_entry = UINT_MAX;
@@ -135,26 +150,27 @@
 	rec.ino		= 0;
 
 	/* scan the file through the pagecache */
-	file_ra_state_init(&ra,rec.iinode->vfs_inode.i_mapping);
+	file_ra_state_init(&ra, rec.iinode->vfs_inode.i_mapping);
 
 	desc.written	= 0;
 	desc.count	= rec.iinode->vfs_inode.i_size;
-	desc.buf	= (char*) &rec;
+	desc.buf	= (char *) &rec;
 	desc.error	= 0;
 
 	pos = 0;
 
-	do_generic_mapping_read(rec.iinode->vfs_inode.i_mapping,&ra,NULL,
-				&pos,&desc,cachefs_index_search_actor);
+	do_generic_mapping_read(rec.iinode->vfs_inode.i_mapping, &ra, NULL,
+				&pos, &desc, cachefs_index_search_actor);
 
 	if (desc.error) {
 		ret = desc.error;
-		
 	}
-	else if (rec.entry==UINT_MAX) {
+	else if (rec.entry == UINT_MAX) {
 		ret = -ENOENT;
 	}
 	else {
+		BUG_ON(rec.ino == 0);
+
 		if (_entry)
 			*_entry = rec.entry;
 		if (_ino)
@@ -162,7 +178,7 @@
 		ret = 0;
 	}
 
-	_leave(" = %d [ent=%d ino=%u]",ret,rec.entry,rec.ino);
+	_leave(" = %d [ent=%d ino=%u]", ret, rec.entry, rec.ino);
 	return ret;
 } /* end cachefs_index_search() */
 
@@ -181,11 +197,11 @@
 	int loop, ret;
 
 	iinode = data;
-	_enter("{%lu},%p{%lu}",iinode->vfs_inode.i_ino,page,page->index);
+	_enter("{%lu},%p{%lu}", iinode->vfs_inode.i_ino, page, page->index);
 
-	ret = cachefs_page_get_private(page,&pageio,GFP_KERNEL);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = cachefs_page_get_private(page, &pageio, GFP_KERNEL);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ret;
 	}
 
@@ -198,7 +214,7 @@
 	content = kmap(page);
 	clear_page(content);
 
-	for (loop=iinode->index_epp-1; loop>=0; loop--) {
+	for (loop = iinode->index_epp - 1; loop >= 0; loop--) {
 		xent = content + loop * iinode->index_esize;
 		xent->state		= CACHEFS_ONDISC_INDEX_FREE;
 		xent->freelink[0]	= next;
@@ -207,7 +223,7 @@
 
 	kunmap(content);
 
-	_debug("new freelink: %u",next);
+	_debug("new freelink: %u", next);
 
 	metadata = cachefs_metadata_prewrite(iinode);
 	metadata->freelink = next;
@@ -235,7 +251,7 @@
 	unsigned newentry, pgnum, offset;
 	int ret;
 
-	_enter("{%lu},",iinode->vfs_inode.i_ino);
+	_enter("{%lu},", iinode->vfs_inode.i_ino);
 
 	*_page		= NULL;
 	*_newentry	= 0;
@@ -245,15 +261,17 @@
 	newentry = metadata->freelink;
 	cachefs_metadata_postread(iinode);
 
-	_debug("free entry: %u [size %Lu]",newentry,iinode->vfs_inode.i_size);
+	_debug("free entry: %u [size %Lu]",
+	       newentry, iinode->vfs_inode.i_size);
 
 	/* we may need to extend the index file */
-	if (newentry==UINT_MAX) {
+	if (newentry == UINT_MAX) {
 		pgnum = iinode->vfs_inode.i_size >> PAGE_SHIFT;
 
-		/* we need to get the new contents for this block ready in advance */
-		page = read_cache_page(iinode->vfs_inode.i_mapping,pgnum,
-				       cachefs_index_preinit_page,iinode);
+		/* we need to get the new contents for this block ready in
+		 * advance */
+		page = read_cache_page(iinode->vfs_inode.i_mapping, pgnum,
+				       cachefs_index_preinit_page, iinode);
 		dbgpgalloc(page);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
@@ -263,9 +281,9 @@
 		iinode->vfs_inode.i_size += PAGE_SIZE;
 
 		/* make the extension */
-		ret = cachefs_get_block(&iinode->vfs_inode,page,
-					__cachefs_page_get_private(page),1);
-		if (ret<0) {
+		ret = cachefs_get_block(&iinode->vfs_inode, page,
+					__cachefs_page_get_private(page), 1);
+		if (ret < 0) {
 			iinode->vfs_inode.i_size -= PAGE_SIZE;
 			goto error2;
 		}
@@ -274,19 +292,31 @@
 		newentry = metadata->freelink;
 		cachefs_metadata_postread(iinode);
 
-		BUG_ON(newentry==UINT_MAX);
-
-//		_debug("syncing");
-//		cachefs_trans_sync(iinode->vfs_inode.i_sb->s_fs_info,
-//				   CACHEFS_TRANS_SYNC_WAIT_FOR_ACK);
+		BUG_ON(newentry == UINT_MAX);
 		_debug("done");
 	}
 	/* get the page holding the next free entry */
 	else {
+		filler_t *filler = 
+			(filler_t *)
+			iinode->vfs_inode.i_mapping->a_ops->readpage;
+
+		if (!iinode->index_epp) {
+			printk("CacheFS:"
+			       " Index %lu {meta %u+%u} has zero-sized entries"
+			       " (%hu/%hu/%hu)\n",
+			       iinode->vfs_inode.i_ino,
+			       iinode->metadata->bix,
+			       iinode->metadata_offset,
+			       iinode->index_dsize,
+			       iinode->index_esize,
+			       iinode->index_epp);
+			BUG();
+		}
+
 		pgnum = newentry / iinode->index_epp;
-		page = read_cache_page(iinode->vfs_inode.i_mapping,pgnum,
-				       (filler_t*) iinode->vfs_inode.i_mapping->a_ops->readpage,
-				       NULL);
+		page = read_cache_page(iinode->vfs_inode.i_mapping, pgnum,
+				       filler, NULL);
 		dbgpgalloc(page);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
@@ -305,13 +335,13 @@
 	*_next = xent->freelink[0];
 	kunmap(page);
 
-	_leave(" = 0 [{%lu},%u,%u]",page->index,newentry,*_next);
+	_leave(" = 0 [{%lu},%u,%u]", page->index, newentry, *_next);
 	return 0;
 
  error2:
 	cachefs_put_page(page);
  error:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end cachefs_index_select_free_entry() */
@@ -319,8 +349,10 @@
 /*****************************************************************************/
 /*
  * allocate an entry in the specified index file and associate an inode with it
- * - target->cookie->def determines whether the new inode will be a file or an index
- * - if an inode is successfully allocated, *_newino will be set with the inode number
+ * - target->cookie->def determines whether the new inode will be a file or an
+ *   index
+ * - if an inode is successfully allocated *_newino will be set with the inode
+ *   number
  */
 int cachefs_index_add(struct cachefs_inode *index,
 		      struct cachefs_cookie *cookie,
@@ -335,7 +367,8 @@
 	unsigned ino, ixentry, offset, inonext, ixnext, ino_offset;
 	int ret, loop;
 
-	_enter("{%lu},{%s},",index->vfs_inode.i_ino,index->cookie->idef->name);
+	_enter("{%lu},{%s},",
+	       index->vfs_inode.i_ino, index->cookie->idef->name);
 
 	*_newino = 0;
 
@@ -345,27 +378,29 @@
 	trans	= NULL;
 
 	/* we need an index entry and a inode */
-	ret = cachefs_index_select_free_entry(index,&ixpage,&ixentry,&ixnext);
-	if (ret<0)
+	ret = cachefs_index_select_free_entry(index,
+					      &ixpage, &ixentry, &ixnext);
+	if (ret < 0)
 		goto error;
 
-	ret = cachefs_index_select_free_entry(super->imetadata,&inopage,&ino,&inonext);
-	if (ret<0)
+	ret = cachefs_index_select_free_entry(super->imetadata,
+					      &inopage, &ino, &inonext);
+	if (ret < 0)
 		goto error;
 
-	_debug("entry %u ino %u",ixentry,ino);
+	_debug("entry %u ino %u", ixentry, ino);
 
 	/* do the allocation under journalling */
 	ret = -ENOMEM;
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans)
 		goto error;
 
 	offset = (ixentry % index->index_epp) * index->index_esize;
 
-	trans->jentry->mark = CACHEFS_ONDISC_UJNL_INDEX_ALLOCING;
+	trans->jentry->mark = CACHEFS_ONDISC_UJNL_INDEX_CREATING;
 	if (!cookie->idef)
-		trans->jentry->mark = CACHEFS_ONDISC_UJNL_INODE_ALLOCING;
+		trans->jentry->mark = CACHEFS_ONDISC_UJNL_INODE_CREATING;
 
 	trans->jentry->index	= index->vfs_inode.i_ino;
 	trans->jentry->ixentry	= ixentry;
@@ -381,20 +416,20 @@
 	ino_offset = ino % super->imetadata->index_epp;
 	ino_offset <<= super->layout->metadata_bits;
 
-	cachefs_trans_affects_page(trans,__cachefs_page_get_private(ixpage),offset,
-				   index->index_esize);
-	cachefs_trans_affects_page(trans,__cachefs_page_get_private(inopage),ino_offset,
-				   super->layout->metadata_size);
+	cachefs_trans_affects_page(trans, __cachefs_page_get_private(ixpage),
+				   offset, index->index_esize);
+	cachefs_trans_affects_page(trans, __cachefs_page_get_private(inopage),
+				   ino_offset, super->layout->metadata_size);
 
-	cachefs_trans_affects_inode(trans,index);
-	cachefs_trans_affects_inode(trans,super->imetadata);
+	cachefs_trans_affects_inode(trans, index);
+	cachefs_trans_affects_inode(trans, super->imetadata);
 
 	ret = cachefs_trans_mark(trans);
-	if (ret<0)
+	if (ret < 0)
 		goto error;
 
-	cachefs_page_modify(super,&ixpage);
-	cachefs_page_modify(super,&inopage);
+	cachefs_page_modify(super, &ixpage);
+	cachefs_page_modify(super, &inopage);
 
 	/* fill the index entry */
 	xent = kmap(ixpage) + offset;
@@ -405,7 +440,7 @@
 	if (cookie->idef)
 		xent->type = CACHEFS_ONDISC_INDEX_INDEXFILE;
 
-	index->cookie->idef->update(cookie->netfs_data,xent->data);
+	index->cookie->idef->update(cookie->netfs_data, xent->data);
 
 	kunmap(ixpage);
 
@@ -417,7 +452,7 @@
 
 	/* fill the inode definition */
 	metadata = kmap(inopage) + ino_offset;
-	memset(metadata,0,sizeof(super->imetadata->index_esize));
+	memset(metadata, 0, sizeof(super->imetadata->index_esize));
 
 	metadata->header.state	= CACHEFS_ONDISC_INDEX_ACTIVE;
 	metadata->header.ino	= 0xfefefe;
@@ -431,17 +466,26 @@
 	if (cookie->idef) {
 		struct cachefs_index_def *definition = cookie->idef;
 
-		metadata->index_dsize	= definition->data_size;
-		metadata->index_esize	= metadata->index_dsize;
-		metadata->index_esize	+= sizeof(struct cachefs_ondisc_index_entry);
-
-		for (loop=0; loop<4; loop++) {
-			metadata->index_keys[loop] = definition->keys[loop].len;
-			metadata->index_keys[loop] &= CACHEFS_ONDISC_INDEXKEY_KLEN;
-			metadata->index_keys[loop] |= definition->keys[loop].type << 12;
+		metadata->index_dsize = definition->data_size;
+		metadata->index_esize = metadata->index_dsize;
+		metadata->index_esize +=
+			sizeof(struct cachefs_ondisc_index_entry);
+
+		if (metadata->index_esize < CACHEFS_ONDISC_INDEX_ENTRY_MINSIZE)
+			metadata->index_esize =
+				CACHEFS_ONDISC_INDEX_ENTRY_MINSIZE;
+
+		for (loop = 0; loop < 4; loop++) {
+			metadata->index_keys[loop] =
+				definition->keys[loop].len &
+				CACHEFS_ONDISC_INDEXKEY_KLEN;
+			metadata->index_keys[loop] |=
+				definition->keys[loop].type << 12;
 		}
 
-		strncpy(metadata->index_type,definition->name,sizeof(metadata->index_type));
+		strncpy(metadata->index_type,
+			definition->name,
+			sizeof(metadata->index_type));
 	}
 
 	kunmap(inopage);
@@ -457,8 +501,8 @@
 	trans = NULL;
 
 	/* note that it is now present */
-	list_for_each_entry(srch,&cookie->search_results,link) {
-		if (srch->super==super) {
+	list_for_each_entry(srch, &cookie->search_results, link) {
+		if (srch->super == super) {
 			srch->ino = ino;
 			break;
 		}
@@ -471,13 +515,14 @@
 	cachefs_put_page(inopage);
 	cachefs_put_page(ixpage);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_index_add() */
 
 /*****************************************************************************/
 /*
- * mark the next inode pinned by an entry in the index currently being reclaimed as being obsolete
+ * mark the next inode pinned by an entry in the index currently being
+ * reclaimed as being obsolete
  */
 int cachefs_index_zap(struct cachefs_super *super)
 {
@@ -490,7 +535,7 @@
 	unsigned pgnum, offset, ino;
 	int ret;
 
-	_enter("{%u,%u}",super->rcm_ino,super->rcm_block);
+	_enter("{%u,%u}", super->rcm_ino, super->rcm_block);
 
 	pgnum	= super->rcm_block / super->rcm_inode->index_epp;
 	offset	= super->rcm_block % super->rcm_inode->index_epp;
@@ -500,13 +545,15 @@
 		return 0; /* done them all */
 	}
 
-	/* get the page holding the next index entry and extract the inode number from it */
-	ret = cachefs_get_page(super->rcm_inode,pgnum,&page);
-	if (ret<0) {
-		if (ret==-EIO) {
-			super->rcm_block = (pgnum+1) * super->rcm_inode->index_epp;
+	/* get the page holding the next index entry and extract the inode
+	 * number from it */
+	ret = cachefs_get_page(super->rcm_inode, pgnum, &page);
+	if (ret < 0) {
+		if (ret == -EIO) {
+			super->rcm_block =
+				(pgnum + 1) * super->rcm_inode->index_epp;
 		}
-		_leave(" = %d",ret);
+		_leave(" = %d", ret);
 		return ret;
 	}
 
@@ -515,13 +562,12 @@
 	ino = xent->ino;
 	kunmap(page);
 
-	/* open the inode */
-	ret = cachefs_iget(super,ino,&inode);
-	if (ret<0)
+	ret = cachefs_iget(super, ino, &inode);
+	if (ret < 0)
 		goto error_skip;
 
 	/* journal what we're going to do */
-	trans = cachefs_trans_alloc(super,GFP_KERNEL);
+	trans = cachefs_trans_alloc(super, GFP_KERNEL);
 	if (!trans) {
 		_leave(" = -ENOMEM");
 		return -ENOMEM;
@@ -549,17 +595,22 @@
 	trans = NULL;
 
 	/* add to the immediate-reclaim table if possible */
-	spin_lock_irqsave(&super->rcm_lock,flags);
+	spin_lock_irqsave(&super->rcm_lock, flags);
 
-	if (CIRC_SPACE(super->rcm_imm_head,super->rcm_imm_tail,CACHEFS_RCM_IMM_BUFSIZE)>0) {
-		super->rcm_imm_buf[super->rcm_imm_head] = inode->vfs_inode.i_ino;
-		super->rcm_imm_head = (super->rcm_imm_head+1) & (CACHEFS_RCM_IMM_BUFSIZE-1);
+	if (CIRC_SPACE(super->rcm_imm_head,
+		       super->rcm_imm_tail,
+		       CACHEFS_RCM_IMM_BUFSIZE) > 0) {
+		super->rcm_imm_buf[super->rcm_imm_head] =
+			inode->vfs_inode.i_ino;
+		super->rcm_imm_head =
+			(super->rcm_imm_head + 1) &
+			(CACHEFS_RCM_IMM_BUFSIZE - 1);
 	}
 	else {
-		set_bit(CACHEFS_SUPER_RCM_IMM_SCAN,&super->flags);
+		set_bit(CACHEFS_SUPER_RCM_IMM_SCAN, &super->flags);
 	}
 
-	spin_unlock_irqrestore(&super->rcm_lock,flags);
+	spin_unlock_irqrestore(&super->rcm_lock, flags);
 
 	super->rcm_block++;
 	ret = -EAGAIN;
@@ -568,10 +619,10 @@
 	cachefs_iput(inode);
 	cachefs_trans_put(trans);
 	cachefs_put_page(page);
-	if (ret==-EIO)
+	if (ret == -EIO)
 		super->rcm_block++;
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_index_zap() */
 
@@ -581,11 +632,11 @@
  * - since we don't know what index data was associated with it, all we can do
  *   is mark it for reclamation
  */
-int cachefs_replay_ujnl_inode_allocing(struct cachefs_super *super,
+int cachefs_replay_ujnl_inode_creating(struct cachefs_super *super,
 				       struct cachefs_ondisc_update_journal *jentry)
 {
 	return -ENOANO;
-} /* end cachefs_replay_ujnl_inode_allocing() */
+} /* end cachefs_replay_ujnl_inode_creating() */
 
 /*****************************************************************************/
 /*
@@ -645,11 +696,11 @@
 /*
  * 
  */
-int cachefs_replay_ujnl_index_allocing(struct cachefs_super *super,
+int cachefs_replay_ujnl_index_creating(struct cachefs_super *super,
 				       struct cachefs_ondisc_update_journal *jentry)
 {
 	return -ENOANO;
-} /* end cachefs_replay_ujnl_index_allocing() */
+} /* end cachefs_replay_ujnl_index_creating() */
 
 /*****************************************************************************/
 /*
@@ -665,8 +716,8 @@
 /*
  * 
  */
-int cachefs_replay_ujnl_index_freeing(struct cachefs_super *super,
-				      struct cachefs_ondisc_update_journal *jentry)
+int cachefs_replay_ujnl_index_deleting(struct cachefs_super *super,
+				       struct cachefs_ondisc_update_journal *jentry)
 {
 	return -ENOANO;
-} /* end cachefs_replay_ujnl_index_freeing() */
+} /* end cachefs_replay_ujnl_index_deleting() */

Index: dump-journal.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/dump-journal.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- dump-journal.c	28 May 2003 10:32:54 -0000	1.10
+++ dump-journal.c	4 Jul 2003 09:04:44 -0000	1.11
@@ -31,7 +31,8 @@
 
 #define BP_RED	"\e[41;1m"
 
-#define OSERROR(X,Y) do { if ((int)(Y)<0) { perror((X)); exit(1); } } while(0)
+#define OSERROR(X,Y) \
+	do { if ((int)(Y) < 0) { perror((X)); exit(1); } } while(0)
 
 struct sector {
 	union {
@@ -49,9 +50,9 @@
 	BRIGHT	"RcycXfer "	NORMAL,
 	BRIGHT	"RcycScvng"	NORMAL,
 	BRIGHT	"RcycMkRdy"	NORMAL,
-	BRIGHT	"InoAlloc "	NORMAL,
-	BRIGHT	"InoUpdate"	NORMAL,
-	BRIGHT	"InoDelete"	NORMAL,
+	BRIGHT	"CrtData  "	NORMAL,
+	BRIGHT	"UpdData  "	NORMAL,
+	BRIGHT	"DelData  "	NORMAL,
 	BRIGHT	"InoMkRcm "	NORMAL,
 	BRIGHT	"InoRcming"	NORMAL,
 	BRIGHT	"DataAlloc"	NORMAL,
@@ -59,10 +60,10 @@
 	BRIGHT	"DataUnalc"	NORMAL,
 	BRIGHT	"IndrAlloc"	NORMAL,
 	BRIGHT	"IndrFree "	NORMAL,
-	BRIGHT	"IndexExtn"	NORMAL,
-	BRIGHT	"IndexAllc"	NORMAL,
-	BRIGHT	"IndexModf"	NORMAL,
-	BRIGHT	"IndexFree"	NORMAL,
+	BRIGHT	"ExtnIndex"	NORMAL,
+	BRIGHT	"CrtIndex "	NORMAL,
+	BRIGHT	"ModIndex "	NORMAL,
+	BRIGHT	"DelIndex "	NORMAL,
 	BP_RED	"?????????"	NORMAL
 };
 
@@ -76,33 +77,33 @@
 	int devfd, loop, delta;
 
 	delta = 1;
-	if (argc==3 && strcmp(argv[1],"-r")==0) {
+	if (argc == 3 && strcmp(argv[1], "-r") == 0) {
 		delta = -1;
 		argc--;
 		argv++;
 	}
 
-	if (argc!=2) abort();
+	if (argc != 2) abort();
 
-	devfd = open(argv[1],O_RDONLY);
-	OSERROR("open",devfd);
+	devfd = open(argv[1], O_RDONLY);
+	OSERROR("open", devfd);
 
-	OSERROR("stat",fstat(devfd,&st));
+	OSERROR("stat", fstat(devfd, &st));
 	if (!S_ISBLK(st.st_mode)) {
-		fprintf(stderr,"not a blockdev\n");
+		fprintf(stderr, "not a blockdev\n");
 		exit(1);
 	}
 
-	super = mmap(NULL,4096,PROT_READ,MAP_PRIVATE,devfd,0);
-	OSERROR("mmap",super);
+	super = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, devfd, 0);
+	OSERROR("mmap", super);
 
 	if (memcmp(super->magic,
 		   CACHEFS_SUPER_MAGIC,
-		   CACHEFS_SUPER_MAGIC_SIZE)!=0
+		   CACHEFS_SUPER_MAGIC_SIZE) != 0
 	    ) {
 		if (memcmp(super->magic,
 			   CACHEFS_SUPER_MAGIC_NEEDS_INIT,
-			   CACHEFS_SUPER_MAGIC_SIZE)!=0
+			   CACHEFS_SUPER_MAGIC_SIZE) != 0
 		    ) {
 			fprintf(stderr,"not a CacheFS filesystem");
 			exit(1);
@@ -110,8 +111,10 @@
 
 		printf("uninitialised CacheFS filesystem");
 
-		if (super->bix_ujournal!=2) exit(0);
-		if (super->bix_vjournal > super->bix_ujournal+65536/512) exit(0);
+		if (super->bix_ujournal != 2)
+			exit(0);
+		if (super->bix_vjournal > super->bix_ujournal + 65536 / 512)
+			exit(0);
 	}
 
 	numujnl = super->bix_vjournal - super->bix_ujournal;
@@ -119,14 +122,19 @@
 
 	jsof = super->bix_ujournal * (4096 / super->ujnl_rsize);
 
-	ujournal = mmap(NULL,numujnl,PROT_READ,MAP_PRIVATE,devfd,super->bix_ujournal*4096);
-	OSERROR("mmap",super);
+	ujournal = mmap(NULL,
+			numujnl,
+			PROT_READ,
+			MAP_PRIVATE,
+			devfd,
+			super->bix_ujournal * 4096);
+	OSERROR("mmap", super);
 
 	numujnl /= sizeof(struct sector);
 
 	printf("SECT"
 	       "    BATCH   "
-	       "   MARK    AUX"
+	       "   MARK    AUX "
 	       "  INODE    PGNUM  "
 	       "    INDEX:ENT "
 	       "    BLOCK+ENT "
@@ -139,7 +147,7 @@
 
 	printf("===="
 	       " ==========="
-	       " ========= ==="
+	       " ========= ===="
 	       " ======== ========"
 	       " ============="
 	       " ============="
@@ -150,23 +158,23 @@
 	       " ========"
 	       " ==================\n");
 
-	for (loop = delta>0 ? 0 : numujnl - 1;
-	     delta>0 ? loop<numujnl : loop >= 0;
+	for (loop = delta > 0 ? 0 : numujnl - 1;
+	     delta > 0 ? loop < numujnl : loop >= 0;
 	     loop += delta
 	     ) {
 		jentry = &ujournal[loop].jentry;
 
-		if (jentry->mark==CACHEFS_ONDISC_UJNL_NULL)
+		if (jentry->mark == CACHEFS_ONDISC_UJNL_NULL)
 			continue;
 
 		printf("%s%4u" NORMAL
 		       " " CYAN		"%5u"	GREY	"."	NORMAL	"%-5u"	NORMAL
-		       " "		"%s"		" %3d"
+		       " "		"%s"		" %4d"
 		       " " YELLOW	"%8x"	NORMAL	" %8u"
 		       " " YELLOW	"%8u"	GREY	":"	NORMAL	"%-4hu"
-		       " " YELLOW	"%8u"	GREY	"+"	NORMAL	"%-4hu"
-		       " " YELLOW	"%8u"	GREY	"+"	NORMAL	"%-4hu"
-		       " " YELLOW	"%8u"	GREY	"+"	NORMAL	"%-4hu"
+		       " " YELLOW	"%8d"	GREY	"+"	NORMAL	"%-4hu"
+		       " " YELLOW	"%8d"	GREY	"+"	NORMAL	"%-4hu"
+		       " " YELLOW	"%8d"	GREY	"+"	NORMAL	"%-4hu"
 		       " " YELLOW	"%4hu"	NORMAL	""
 		       " " GREEN	"%8u"	NORMAL	"[%-4hu]"
 		       " " CYAN		"%8u"	NORMAL	""
@@ -185,7 +193,8 @@
 		       jentry->count,
 		       jentry->alloc_cur,	jentry->alloc_leaf,
 		       jentry->recycle_cur,
-		       jentry->rcm_block,	jentry->rcm_ptrnext,	jentry->rcm_ptrstop
+		       jentry->rcm_block,	jentry->rcm_ptrnext,
+		       jentry->rcm_ptrstop
 		       );
 	}

Index: cachetest-main.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/cachetest-main.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- cachetest-main.c	10 Jun 2003 17:49:49 -0000	1.11
+++ cachetest-main.c	4 Jul 2003 09:04:44 -0000	1.12
@@ -16,9 +16,9 @@
 #include <linux/in.h>
 #include <linux/cachefs.h>
 
-#define kenter(FMT,...)	printk("==> %s("FMT")\n",__FUNCTION__,##__VA_ARGS__)
-#define kleave(FMT,...)	printk("<== %s()"FMT"\n",__FUNCTION__,##__VA_ARGS__)
-#define kdebug(FMT,...)	printk(FMT"\n",##__VA_ARGS__)
+#define kenter(FMT,...)	printk("==> %s("FMT")\n", __FUNCTION__ ,##__VA_ARGS__)
+#define kleave(FMT,...)	printk("<== %s()"FMT"\n", __FUNCTION__ ,##__VA_ARGS__)
+#define kdebug(FMT,...)	printk(FMT"\n" ,##__VA_ARGS__)
 
 static int cachefstest_init(void);
 static void cachefstest_exit(void);
@@ -63,7 +63,8 @@
 	.update			= cell_update,
 };
 
-static int afs_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie);
+static int afs_get_page_cookie(struct page *page,
+			       struct cachefs_page **_page_cookie);
 
 static struct cachefs_netfs_operations cachetest_ops = {
 	.get_page_cookie	= afs_get_page_cookie,
@@ -77,7 +78,8 @@
 
 /* AFS cell
  * - this is an index containing volume location database references
- * - objects of this type will be typically embedded in the AFS fs's cell record structures
+ * - objects of this type will be typically embedded in the AFS fs's cell
+ *   record structures
  */
 static cachefs_match_val_t vldb_match(void *target, const void *entry);
 static void vldb_update(void *source, void *entry);
@@ -96,7 +98,8 @@
 
 /* AFS root volume
  * - this is an index containing file references
- * - objects of this type will be typically embedded in the AFS fs's volume record structures
+ * - objects of this type will be typically embedded in the AFS fs's volume
+ *   record structures
  */
 static cachefs_match_val_t file_match(void *target, const void *entry);
 static void file_update(void *source, void *entry);
@@ -115,7 +118,8 @@
 
 /* AFS root dir
  * - this is a file (hence .idef is NULL)
- * - objects of this type will be typically embedded in the AFS fs's inode structures
+ * - objects of this type will be typically embedded in the AFS fs's inode
+ *   structures
  */
 static struct afs_inode afs_root_dir = {
 	.fid		= 0x1234abcd,
@@ -133,11 +137,11 @@
 	.lock		= RW_LOCK_UNLOCKED,
 };
 
-static void afs_page_cache_write_complete(void *cookie_data, struct page *page, void *data,
-					  int error);
+static void afs_page_cache_write_complete(void *cookie_data, struct page *page,
+					  void *data, int error);
 
-static void afs_page_cache_read_complete(void *cookie_data, struct page *page, void *data,
-					 int error);
+static void afs_page_cache_read_complete(void *cookie_data, struct page *page,
+					 void *data, int error);
 
 /*****************************************************************************/
 /*
@@ -147,10 +151,11 @@
 {
 	int ret;
 
-	printk(KERN_INFO "cachefstest: general fs caching v0.1 tester registering\n");
+	printk(KERN_INFO
+	       "cachefstest: general fs caching v0.1 tester registering\n");
 
 	ret = -ENOMEM;
-	afs_data_page = alloc_pages(GFP_KERNEL,1);
+	afs_data_page = alloc_pages(GFP_KERNEL, 1);
 	if (!afs_data_page)
 		goto error;
 
@@ -158,10 +163,10 @@
 	afs_data_page->index  = 0;
 	afs_data_page2->index = 1;
 
-	memset(page_address(afs_data_page ),0xde,PAGE_SIZE);
-	memset(page_address(afs_data_page2),0xdf,PAGE_SIZE);
+	memset(page_address(afs_data_page ), 0xde, PAGE_SIZE);
+	memset(page_address(afs_data_page2), 0xdf, PAGE_SIZE);
 
-	ret = cachefs_register_netfs(&cachetest,&cachetest_cell_index_def);
+	ret = cachefs_register_netfs(&cachetest, &cachetest_cell_index_def);
 	if (ret<0)
 		goto error2;
 
@@ -187,40 +192,40 @@
 	ret = cachefs_read_or_alloc_page(afs_root_dir.cache,
 					 afs_data_page,
 					 afs_page_cache_read_complete,
-					 (void*)7,
+					 (void *) 7,
 					 GFP_KERNEL);
 
 	printk("\n### Read page 2\n");
 	ret = cachefs_read_or_alloc_page(afs_root_dir.cache,
 					 afs_data_page2,
 					 afs_page_cache_read_complete,
-					 (void*)9,
+					 (void *) 9,
 					 GFP_KERNEL);
 
 	printk("\n### Write page\n");
 	ret = cachefs_write_page(afs_root_dir.cache,
 				 afs_data_page,
 				 afs_page_cache_write_complete,
-				 (void*)3,
+				 (void *) 3,
 				 GFP_KERNEL);
 
-	printk("\nresult = %d\n",ret);
+	printk("\nresult = %d\n", ret);
 
 	printk("\n### Write page2\n");
 	ret = cachefs_write_page(afs_root_dir.cache,
 				 afs_data_page2,
 				 afs_page_cache_write_complete,
-				 (void*)23,
+				 (void *) 23,
 				 GFP_KERNEL);
 
-	printk("\nresult = %d\n",ret);
+	printk("\nresult = %d\n", ret);
 
 	return 0;
 
  error2:
-	__free_pages(afs_data_page,1);
+	__free_pages(afs_data_page, 1);
  error:
-	printk(KERN_ERR "cachefstest: failed to register: %d\n",ret);
+	printk(KERN_ERR "cachefstest: failed to register: %d\n", ret);
 	return ret;
 } /* end cachefstest_init() */
 
@@ -230,16 +235,17 @@
  */
 static void cachefstest_exit(void)
 {
-	printk(KERN_INFO "cachefstest: general fs caching v0.1 tester unregistering.\n");
+	printk(KERN_INFO
+	       "cachefstest: general fs caching v0.1 tester unregistering.\n");
 
-	cachefs_uncache_page(afs_root_dir.cache,afs_data_page);
-	cachefs_uncache_page(afs_root_dir.cache,afs_data_page2);
+	cachefs_uncache_page(afs_root_dir.cache, afs_data_page);
+	cachefs_uncache_page(afs_root_dir.cache, afs_data_page2);
 
-	__free_pages(afs_data_page,1);
+	__free_pages(afs_data_page, 1);
 
-	cachefs_relinquish_cookie(afs_root_dir.cache,0);
-	cachefs_relinquish_cookie(afs_root_volume.cache,0);
-	cachefs_relinquish_cookie(afs_mycell.cache,0);
+	cachefs_relinquish_cookie(afs_root_dir.cache, 0);
+	cachefs_relinquish_cookie(afs_root_volume.cache, 0);
+	cachefs_relinquish_cookie(afs_mycell.cache, 0);
 	cachefs_unregister_netfs(&cachetest);
 
 } /* end cachefstest_exit() */
@@ -254,7 +260,7 @@
 
 	kenter("");
 
-	if (strncmp(entry,cell->name,sizeof(cell->name))==0)
+	if (strncmp(entry, cell->name, sizeof(cell->name)) == 0)
 		return CACHEFS_MATCH_SUCCESS;
 
 	return CACHEFS_MATCH_FAILED;
@@ -268,9 +274,9 @@
 {
 	struct afs_cell *cell = source;
 
-	kenter("%p,%p",source,entry);
+	kenter("%p,%p", source, entry);
 
-	strncpy(entry,cell->name,sizeof(cell->name));
+	strncpy(entry, cell->name, sizeof(cell->name));
 
 } /* end cell_update() */
 
@@ -284,7 +290,7 @@
 
 	kenter("");
 
-	if (strncmp(entry,volume->name,sizeof(volume->name))==0)
+	if (strncmp(entry, volume->name, sizeof(volume->name)) == 0)
 		return CACHEFS_MATCH_SUCCESS;
 
 	return CACHEFS_MATCH_FAILED;
@@ -298,9 +304,9 @@
 {
 	struct afs_volume *volume = source;
 
-	kenter("%p,%p",source,entry);
+	kenter("%p,%p", source, entry);
 
-	strncpy(entry,volume->name,sizeof(volume->name));
+	strncpy(entry, volume->name, sizeof(volume->name));
 
 } /* end vldb_update() */
 
@@ -315,7 +321,7 @@
 
 	kenter("");
 
-	if (memcmp(entry,&fid,sizeof(fid))==0)
+	if (memcmp(entry, &fid, sizeof(fid)) == 0)
 		return CACHEFS_MATCH_SUCCESS;
 
 	return CACHEFS_MATCH_FAILED;
@@ -330,9 +336,9 @@
 	struct afs_inode *inode = source;
 	u_int32_t fid = htonl(inode->fid);
 
-	kenter("%p,%p",source,entry);
+	kenter("%p,%p", source, entry);
 
-	memcpy(entry,&fid,sizeof(fid));
+	memcpy(entry, &fid, sizeof(fid));
 
 } /* end file_update() */
 
@@ -340,10 +346,10 @@
 /*
  * 
  */
-static void afs_page_cache_write_complete(void *cookie_data, struct page *page, void *data,
-					  int error)
+static void afs_page_cache_write_complete(void *cookie_data, struct page *page,
+					  void *data, int error)
 {
-	kenter("%p,%p,%p,%d",cookie_data,page,data,error);
+	kenter("%p,%p,%p,%d", cookie_data, page, data, error);
 
 } /* end afs_page_cache_write_complete() */
 
@@ -351,10 +357,10 @@
 /*
  * 
  */
-static void afs_page_cache_read_complete(void *cookie_data, struct page *page, void *data,
-					 int error)
+static void afs_page_cache_read_complete(void *cookie_data, struct page *page,
+					 void *data, int error)
 {
-	kenter("%p,%p,%p,%d",cookie_data,page,data,error);
+	kenter("%p,%p,%p,%d", cookie_data, page, data, error);
 
 } /* end afs_page_cache_write_complete() */
 
@@ -362,18 +368,19 @@
 /*
  * get a page cookie for the specified page
  */
-static int afs_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie)
+static int afs_get_page_cookie(struct page *page,
+			       struct cachefs_page **_page_cookie)
 {
-	kenter("%p,",page);
+	kenter("%p,", page);
 
 	if (page == afs_data_page) {
 		*_page_cookie = &afs_data_page_cookie;
-		kleave(" = 0 [%p]",*_page_cookie);
+		kleave(" = 0 [%p]", *_page_cookie);
 		return 0;
 	}
 	else if (page == afs_data_page2) {
 		*_page_cookie = &afs_data_page2_cookie;
-		kleave(" = 0 [%p]",*_page_cookie);
+		kleave(" = 0 [%p]", *_page_cookie);
 		return 0;
 	}

Index: cachefs-layout.h
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/cachefs-layout.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- cachefs-layout.h	2 Jun 2003 09:17:42 -0000	1.25
+++ cachefs-layout.h	4 Jul 2003 09:04:44 -0000	1.26
@@ -19,7 +19,6 @@
 	CACHEFS_INO_METADATA		= 0x00000001,
 	CACHEFS_INO_FSDEF_CATALOGUE,
 	CACHEFS_INO_ROOTDIR		= CACHEFS_INO_FSDEF_CATALOGUE,
-	CACHEFS_INO_WIBBLE,		/* TODO: remove */
 	CACHEFS_INO__FIRST_FILE,
 
 	/* virtual files all have the top bit set */
@@ -33,7 +32,8 @@
 /*****************************************************************************/
 /*
  * cache superblock block layout
- * - the blockdev is prepared for initialisation by 'echo "cachefs___" >/dev/hdaXX' before mounting
+ * - the blockdev is prepared for initialisation by
+ *   'echo "cachefs___" >/dev/hdaXX' before mounting
  * - when initialised, the magic number is changed to "cachefsrdy"
  */
 struct cachefs_ondisc_superblock
@@ -85,14 +85,17 @@
 	};
 };
 
+#define CACHEFS_ONDISC_INDEX_ENTRY_MINSIZE \
+	(sizeof(struct cachefs_ondisc_index_entry) + sizeof(u_int32_t))
+
 /*****************************************************************************/
 /*
  * on-disc metadata record
  * - padded out to sector size and stored several to a block
  * - only the data version is necessary
  *   - disconnected operation is not supported
- *   - afs_iget() contacts the server to get the meta-data _anyway_ when an inode is first brought
- *     into memory
+ *   - afs_iget() contacts the server to get the meta-data _anyway_ when an
+ *     inode is first brought into memory
  * - at least 64 direct block pointers will be available
  * - any block pointer which is 0 indicates an uncached page
  */
@@ -133,26 +136,6 @@
 	cachefs_blockix_t		direct[0];	/* direct block ptrs */
 };
 
-//#define CACHEFS_ONDISC_STORAGE_DIRECT
-//	((CACHEFS_ONDISC_STORAGE_RECSIZE-sizeof(struct cachefs_ondisc_storage)) /
-//	sizeof(cachefs_blockix_t))
-
-//#define CACHEFS_STORAGE_PER_PAGE	(PAGE_SIZE / CACHEFS_ONDISC_STORAGE_RECSIZE)
-
-//#define CACHEFS_POINTERS_PER_PAGE	(PAGE_SIZE / sizeof(cachefs_blockix_t))
-
-/* #define CACHEFS_ONDISC_STORAGE_TRIPLE_INDR_OFFS \ */
-/* 	offsetof(struct cachefs_ondisc_storage,triple_indirect) */
-
-/* #define CACHEFS_ONDISC_STORAGE_DOUBLE_INDR_OFFS \ */
-/* 	offsetof(struct cachefs_ondisc_storage,double_indirect) */
-
-/* #define CACHEFS_ONDISC_STORAGE_SINGLE_INDR_OFFS \ */
-/* 	offsetof(struct cachefs_ondisc_storage,single_indirect) */
-
-/* #define CACHEFS_ONDISC_STORAGE_DIRECT_OFFS \ */
-/* 	offsetof(struct cachefs_ondisc_storage,direct) */
-
 /*****************************************************************************/
 /*
  * on-disc cached network filesystem definition record
@@ -166,7 +149,8 @@
 
 /*****************************************************************************/
 /*
- * Free blocks are kept in pair of a very one sided trees (more horsetail plants than trees)
+ * Free blocks are kept in pair of a very one sided trees (more horsetail
+ * plants than trees)
  *
  *        +---------+    +---------+    +---------+    +---------+
  * stk--->|         |--->|         |--->|         |--->|         |---> NULL
@@ -179,18 +163,14 @@
  * - each free block is on one of two trees, both pointed to by the ujournal:
  *   - the "recycling stack" - all newly freed blocks end up on here
  *   - the "alloc stack" - all allocations are popped off here
- *   - when the alloc stack is empty, the recycling stack is transferred into it
- * - the front node on the alloc stack is the current source of block allocations
- *   - when all a node's leaves have been allocated, then the node itself will be allocated
- *   - leaves are consumed in a rotating sector pattern to avoid waiting for BIO completion as much
- *     as possible
- * - the front node on the recycling stack is the current sink of recycled blocks
- *   - leaves are inserted in a rotating sector pattern to avoid waiting for BIO completion as much
- *     as possible
- */
-
-/*
- * on-disc free-block tree node format
+ *   - when the alloc stack is empty, the recycling stack is transferred into
+ *     it
+ * - the front node on the alloc stack is the current source of block
+ *   allocations
+ *   - when all a node's leaves have been allocated, then the node itself will
+ *     be allocated
+ * - the front node on the recycling stack is the current sink of recycled
+ *   blocks
  */
 struct cachefs_ondisc_free_node
 {
@@ -200,7 +180,7 @@
 };
 
 #define CACHEFS_ONDISC_LEAVES_PER_FREE_NODE \
-	((PAGE_SIZE-sizeof(struct cachefs_ondisc_free_node)) / sizeof(cachefs_blockix_t))
+	((PAGE_SIZE - sizeof(struct cachefs_ondisc_free_node)) / sizeof(cachefs_blockix_t))
 
 /*****************************************************************************/
 /*
@@ -210,10 +190,10 @@
  *   - ACKs specify everything between "index" & "block" as being complete
  *   - serial numbers can wrap, but can't go into window of un-ACK'd marks
  * - journal slots are the size of a sector (blockdev block size)
- *   - this means that two adjacent marks are made on separate sectors, and so the second doesn't
- *     have to wait for the first to be written to disc
- * - the current slot allocation point is not permitted to lap the currently un-ACK'd slots - the
- *   requestor must wait
+ *   - this means that two adjacent marks are made on separate sectors, and so
+ *     the second doesn't have to wait for the first to be written to disc
+ * - the current slot allocation point is not permitted to lap the currently
+ *   un-ACK'd slots - the requestor must wait
  */
 enum cachefs_ondisc_ujnl_mark {
 	/* NULL mark */
@@ -261,13 +241,13 @@
 	 */
 	CACHEFS_ONDISC_UJNL_RECYC_MAKEREADY,
 
-	/* inode record being allocated */
-	CACHEFS_ONDISC_UJNL_INODE_ALLOCING,
+	/* data file being created */
+	CACHEFS_ONDISC_UJNL_INODE_CREATING,
 
-	/* inode record being updated */
+	/* data file being updated */
 	CACHEFS_ONDISC_UJNL_INODE_UPDATING,
 
-	/* inode being deleted */
+	/* data file being deleted */
 	CACHEFS_ONDISC_UJNL_INODE_DELETING,
 
 	/* inode being marked for reclamation
@@ -341,9 +321,9 @@
 	/* index file being extended (as for data block allocation) */
 	CACHEFS_ONDISC_UJNL_INDEX_EXTENDING,
 
-	/* index entry being allocated
-	 * - index	= index being allocated from
-	 * - ixentry	= index entry being allocated
+	/* index file being created
+	 * - index	= parent index being attached to
+	 * - ixentry	= entry in parent index
 	 * - pgnum	= page in file holding index entry being allocated
 	 * - block	= block holding index entry being allocated
 	 * - entry	= offset of entry in block
@@ -351,13 +331,13 @@
 	 * - upblock	= next free index file entry
 	 * - count	= size of entry in block
 	 */
-	CACHEFS_ONDISC_UJNL_INDEX_ALLOCING,
+	CACHEFS_ONDISC_UJNL_INDEX_CREATING,
 
 	/* index entry being modified */
 	CACHEFS_ONDISC_UJNL_INDEX_MODIFYING,
 
-	/* index entry being freed */
-	CACHEFS_ONDISC_UJNL_INDEX_FREEING,
+	/* index file being deleted */
+	CACHEFS_ONDISC_UJNL_INDEX_DELETING,
 
 	CACHEFS_ONDISC_UJNL__LAST
 } __attribute__((packed));
@@ -407,7 +387,8 @@
 /*****************************************************************************/
 /*
  * on-disc block validity journal
- * - blocks noted here don't yet have valid data downloaded from the remote server
+ * - blocks noted here don't yet have valid data downloaded from the remote
+ *   server
  * - unused entries have ino==0
  * - changed under the influence of the u-journal
  */
@@ -418,7 +399,7 @@
 };
 
 #define CACHEFS_ONDISC_VJNL_ENTPERPAGE	\
-	(PAGE_SIZE / sizeof(struct cachefs_ondisc_writeback_journal))
+	(PAGE_SIZE / sizeof(struct cachefs_ondisc_validity_journal))
 
 #define CACHEFS_ONDISC_VJNL_SIZE	16 /* blocks */
 
@@ -429,9 +410,6 @@
 /*
  * on-disc writeback journal
  * - records pages that are pending being written back to the server
- * - journal slots are allocated in a round-robin fashion, going through slot 0 in every sector,
- *   then slot 1 in every sector, then slot 2... this means that two adjacent marks are made on
- *   separate sectors, and so the second doesn't have to wait for the first to be written to disc
  */
 struct cachefs_ondisc_writeback_journal
 {

Index: cachefs-int.h
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/cachefs-int.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- cachefs-int.h	11 Jun 2003 11:59:52 -0000	1.36
+++ cachefs-int.h	4 Jul 2003 09:04:44 -0000	1.37
@@ -51,8 +51,8 @@
 
 extern int cachefs_io_dummy_filler(void *data, struct page *page);
 
-extern int cachefs_get_block(struct inode *inode, struct page *page, struct cachefs_page *pageio,
-			     int create);
+extern int cachefs_get_block(struct inode *inode, struct page *page,
+			     struct cachefs_page *pageio, int create);
 
 struct cachefs_reclaimable {
 	unsigned	ino;
@@ -193,7 +193,8 @@
 	struct cachefs_ondisc_superblock *layout;
 };
 
-extern void cachefs_add_cache(struct cachefs_super *super, struct cachefs_search_result *srch);
+extern void cachefs_add_cache(struct cachefs_super *super,
+			      struct cachefs_search_result *srch);
 extern void cachefs_withdraw_cache(struct cachefs_super *super);
 
 extern void cachefs_recycle_unready_blocks(struct cachefs_super *super);
@@ -251,7 +252,8 @@
 
 extern kmem_cache_t *cachefs_block_jar;
 
-extern void cachefs_block_init_once(void *_block, kmem_cache_t *cachep, unsigned long flags);
+extern void cachefs_block_init_once(void *_block, kmem_cache_t *cachep,
+				    unsigned long flags);
 
 extern int cachefs_block_insert(struct cachefs_super *super,
 				cachefs_blockix_t bix,
@@ -283,9 +285,11 @@
 				 struct cachefs_block *block,
 				 struct page **_page);
 
-extern int cachefs_block_cow(struct cachefs_super *super, struct cachefs_block *block);
+extern int cachefs_block_cow(struct cachefs_super *super,
+			     struct cachefs_block *block);
 
-static inline struct cachefs_block *cachefs_block_get(struct cachefs_block *block)
+static inline
+struct cachefs_block *cachefs_block_get(struct cachefs_block *block)
 {
 	atomic_inc(&block->usage);
 	return block;
@@ -298,12 +302,13 @@
 	if (block) {
 		int usage = atomic_read(&block->usage);
 
-		if ((usage&0xffffff00)==0x6b6b6b00) {
-			printk("\ncachefs_block_put(%p{u=%d})\n",block,usage);
+		if ((usage & 0xffffff00) == 0x6b6b6b00) {
+			printk("\ncachefs_block_put(%p{u=%d})\n",
+			       block, usage);
 			BUG();
 		}
 
-		BUG_ON(usage<=0);
+		BUG_ON(usage <= 0);
 		if (atomic_dec_and_test(&block->usage))
 			__cachefs_block_put(block);
 	}
@@ -315,9 +320,10 @@
 	return ((struct cachefs_page *) page->private)->mapped_block;
 }
 
-static inline void cachefs_page_modify(struct cachefs_super *super, struct page **page)
+static inline void cachefs_page_modify(struct cachefs_super *super,
+				       struct page **page)
 {
-	cachefs_block_modify(super,__cachefs_get_page_block(*page),page);
+	cachefs_block_modify(super, __cachefs_get_page_block(*page), page);
 }
 
 extern void cachefs_block_withdraw(struct cachefs_super *super);
@@ -326,8 +332,8 @@
 /*
  * data file or index object cookie
  * - a file will only appear in one cache
- * - a request to cache a file may or may not be honoured, subject to constraints such as disc
- *   space
+ * - a request to cache a file may or may not be honoured, subject to
+ *   constraints such as disc space
  * - indexes files are created on disc just-in-time
  */
 struct cachefs_cookie
@@ -384,9 +390,11 @@
 extern struct inode_operations cachefs_status_inode_operations;
 extern struct file_operations cachefs_status_file_operations;
 
-#define CACHEFS_FS_I(inode) container_of((inode),struct cachefs_inode,vfs_inode)
+#define CACHEFS_FS_I(inode) \
+	container_of((inode), struct cachefs_inode, vfs_inode)
 
-extern int cachefs_iget(struct cachefs_super *super, ino_t ino, struct cachefs_inode **_inode);
+extern int cachefs_iget(struct cachefs_super *super, ino_t ino,
+			struct cachefs_inode **_inode);
 extern void cachefs_write_inode(struct inode *_inode, int sync);
 extern void cachefs_clear_inode(struct inode *vfs_inode);
 
@@ -402,7 +410,8 @@
 		iput(&inode->vfs_inode);
 }
 
-extern int cachefs_get_page(struct cachefs_inode *inode, unsigned index, struct page **_page);
+extern int cachefs_get_page(struct cachefs_inode *inode, unsigned index,
+			    struct page **_page);
 
 static inline void cachefs_put_page(struct page *page)
 {
@@ -428,7 +437,8 @@
 struct cachefs_ondisc_metadata *cachefs_metadata_prewrite(struct cachefs_inode *inode)
 {
 	down_write(&inode->metadata_sem);
-	cachefs_block_modify(inode->metadata->super,inode->metadata,&inode->metadata_page);
+	cachefs_block_modify(inode->metadata->super, inode->metadata,
+			     &inode->metadata_page);
 	return kmap(inode->metadata_page) + inode->metadata_offset;
 }
 
@@ -452,7 +462,7 @@
 
 extern int cachefs_index_zap(struct cachefs_super *super);
 
-extern int cachefs_replay_ujnl_inode_allocing(struct cachefs_super *super,
+extern int cachefs_replay_ujnl_inode_creating(struct cachefs_super *super,
 					      struct cachefs_ondisc_update_journal *jentry);
 extern int cachefs_replay_ujnl_inode_updating(struct cachefs_super *super,
 					      struct cachefs_ondisc_update_journal *jentry);
@@ -464,12 +474,12 @@
 						struct cachefs_ondisc_update_journal *jentry);
 extern int cachefs_replay_ujnl_index_extending(struct cachefs_super *super,
 					       struct cachefs_ondisc_update_journal *jentry);
-extern int cachefs_replay_ujnl_index_allocing(struct cachefs_super *super,
+extern int cachefs_replay_ujnl_index_creating(struct cachefs_super *super,
 					      struct cachefs_ondisc_update_journal *jentry);
 extern int cachefs_replay_ujnl_index_modifying(struct cachefs_super *super,
 					       struct cachefs_ondisc_update_journal *jentry);
-extern int cachefs_replay_ujnl_index_freeing(struct cachefs_super *super,
-					     struct cachefs_ondisc_update_journal *jentry);
+extern int cachefs_replay_ujnl_index_deleting(struct cachefs_super *super,
+					      struct cachefs_ondisc_update_journal *jentry);
 
 extern int cachefs_replay_ujnl_data_allocing(struct cachefs_super *super,
 					     struct cachefs_ondisc_update_journal *jentry);
@@ -500,8 +510,10 @@
 	unsigned		upentry;	/* offset in upblock at which pointer stored */
 };
 
-extern int cachefs_vj_alloc(struct cachefs_transaction *trans, struct cachefs_inode *inode);
-extern void cachefs_vj_release(struct cachefs_super *super, struct cachefs_vj_entry *vjentry);
+extern int cachefs_vj_alloc(struct cachefs_transaction *trans,
+			    struct cachefs_inode *inode);
+extern void cachefs_vj_release(struct cachefs_super *super,
+			       struct cachefs_vj_entry *vjentry);
 extern void cachefs_vj_cancel(struct cachefs_vj_entry *vjentry);
 extern void cachefs_vj_write_complete(struct cachefs_block *block);
 extern void cachefs_vj_note_write_completion(struct cachefs_super *super);
@@ -551,8 +563,9 @@
 	struct cachefs_trans_effect	effects[CACHEFS_EFFECTS_PER_TRANS];
 };
 
-extern struct cachefs_transaction *cachefs_trans_alloc(struct cachefs_super *super,
-						       unsigned long gfp);
+extern
+struct cachefs_transaction *cachefs_trans_alloc(struct cachefs_super *super,
+						unsigned long gfp);
 
 extern void __cachefs_trans_put(struct cachefs_transaction *trans);
 static inline void cachefs_trans_put(struct cachefs_transaction *trans)
@@ -566,16 +579,18 @@
 					unsigned offset,
 					unsigned size);
 
-static inline void cachefs_trans_affects_page(struct cachefs_transaction *trans,
-					      struct cachefs_page *pageio,
-					      unsigned offset,
-					      unsigned size)
+static inline
+void cachefs_trans_affects_page(struct cachefs_transaction *trans,
+				struct cachefs_page *pageio,
+				unsigned offset,
+				unsigned size)
 {
-	cachefs_trans_affects_block(trans,pageio->mapped_block,offset,size);
+	cachefs_trans_affects_block(trans, pageio->mapped_block, offset, size);
 }
 
-static inline void cachefs_trans_affects_inode(struct cachefs_transaction *trans,
-					       struct cachefs_inode *inode)
+static inline
+void cachefs_trans_affects_inode(struct cachefs_transaction *trans,
+				 struct cachefs_inode *inode)
 {
 	struct cachefs_super *super = inode->vfs_inode.i_sb->s_fs_info;
 
@@ -588,8 +603,11 @@
 static inline void cachefs_trans_affects_super(struct cachefs_transaction *trans)
 {
 	struct cachefs_super *super = trans->super;
-	cachefs_trans_affects_page(trans,__cachefs_page_get_private(virt_to_page(super->layout)),
-				   0,super->sb->s_blocksize);
+	cachefs_trans_affects_page(trans,
+				   __cachefs_page_get_private(
+					   virt_to_page(super->layout)),
+				   0,
+				   super->sb->s_blocksize);
 }
 
 extern int  cachefs_trans_mark(struct cachefs_transaction *trans);
@@ -604,7 +622,8 @@
 	CACHEFS_TRANS_SYNC_WAIT_FOR_ACK,	/* wait until ujnl ACK mark is written */
 } cachefs_trans_syncwt_t;
 
-extern void cachefs_trans_sync(struct cachefs_super *super, cachefs_trans_syncwt_t wait);
+extern void cachefs_trans_sync(struct cachefs_super *super,
+			       cachefs_trans_syncwt_t wait);
 
 extern int  cachefs_ujnl_replay(struct cachefs_super *super);
 
@@ -612,7 +631,8 @@
 /*
  * debug tracing
  */
-#define dbgprintk(FMT,...) printk("[%-6.6s] "FMT"\n",current->comm ,##__VA_ARGS__)
+#define dbgprintk(FMT,...) \
+	printk("[%-6.6s] "FMT"\n",current->comm ,##__VA_ARGS__)
 #define _dbprintk(FMT,...) do { } while(0)
 
 #define kenter(FMT,...)	dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__)
@@ -631,13 +651,15 @@
 		  );							\
 } while(0)
 
-#define dbgpgfree(PAGE)								\
-do {										\
-	if ((PAGE))								\
-		_dbprintk("PGFREE %s:%d: %p {%lx,%lu}\n",			\
-			  __FILE__,__LINE__,					\
-			  (PAGE),(PAGE)->mapping->host->i_ino,(PAGE)->index	\
-			  );							\
+#define dbgpgfree(PAGE)						\
+do {								\
+	if ((PAGE))						\
+		_dbprintk("PGFREE %s:%d: %p {%lx,%lu}\n",	\
+			  __FILE__,__LINE__,			\
+			  (PAGE),				\
+			  (PAGE)->mapping->host->i_ino,		\
+			  (PAGE)->index				\
+			  );					\
 } while(0)
 
 #ifdef __KDEBUG

Index: block.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/block.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- block.c	10 Jun 2003 17:49:49 -0000	1.7
+++ block.c	4 Jul 2003 09:04:44 -0000	1.8
@@ -23,8 +23,9 @@
 {
 	struct cachefs_block *block = _block;
 
-	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) {
-		memset(block,0,sizeof(*block));
+	if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
+	    SLAB_CTOR_CONSTRUCTOR) {
+		memset(block, 0, sizeof(*block));
 
 		rwlock_init(&block->ref_lock);
 		init_waitqueue_head(&block->writewq);
@@ -37,22 +38,21 @@
 	struct cachefs_page *pageio;
 	int ret;
 
-	_enter("%p,{%lu}",data,page->index);
+	_enter("%p,{%lu}", data, page->index);
 
 	/* we need somewhere to note journal ACKs that need to be made */
-	ret = cachefs_page_get_private(page,&pageio,GFP_KERNEL);
-	if (ret<0)
+	ret = cachefs_page_get_private(page, &pageio, GFP_KERNEL);
+	if (ret < 0)
 		return ret;
 
 	pageio->mapped_block = data;
 	cachefs_block_get(pageio->mapped_block);
 
-	memset(kmap(page),0,PAGE_SIZE);
+	memset(kmap(page), 0, PAGE_SIZE);
 	kunmap(page);
 	flush_dcache_page(page);
 
 	SetPageUptodate(page);
-
 	unlock_page(page);
 	return 0;
 }
@@ -70,13 +70,13 @@
 
 	struct cachefs_block *block2;
 
-	_enter(",%u,",block->bix);
+	_enter(",%u,", block->bix);
 
 	/* don't do anything if already associated as we want */
 	block2 = pageio->mapped_block;
 	if (block2) {
-		if (block2==block) {
-			if (block->page==page) {
+		if (block2 == block) {
+			if (block->page == page) {
 				_leave(" = 0 [assoc preset]");
 				return 0;
 			}
@@ -90,11 +90,11 @@
 	}
 
 	/* get the page alloc lock for this block */
-	if (test_and_set_bit(CACHEFS_BLOCK_ALLOC,&block->flags)) {
+	if (test_and_set_bit(CACHEFS_BLOCK_ALLOC, &block->flags)) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&block->writewq,&myself);
+		add_wait_queue(&block->writewq, &myself);
 
-		while (test_and_set_bit(CACHEFS_BLOCK_ALLOC,&block->flags)) {
+		while (test_and_set_bit(CACHEFS_BLOCK_ALLOC, &block->flags)) {
 			if (signal_pending(current))
 				break;
 
@@ -103,7 +103,7 @@
 		}
 
 		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&block->writewq,&myself);
+		remove_wait_queue(&block->writewq, &myself);
 
 		if (signal_pending(current))
 			goto intr;
@@ -141,15 +141,16 @@
 
 	_enter(",%u,,",bix);
 
-	if (_block) *_block = NULL;
+	if (_block)
+		*_block = NULL;
 
 	/* get the block definition */
-	ret = cachefs_block_insert(super,bix,&block);
-	if (ret<0)
+	ret = cachefs_block_insert(super, bix, &block);
+	if (ret < 0)
 		goto error;
 
-	ret = cachefs_block_set(super,block,page,pageio);
-	if (ret<0)
+	ret = cachefs_block_set(super, block, page, pageio);
+	if (ret < 0)
 		goto error2;
 
 	if (_block) {
@@ -160,7 +161,7 @@
  error2:
 	cachefs_block_put(block);
  error:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end cachefs_block_set2() */
 
@@ -175,32 +176,35 @@
 		       struct cachefs_block **_block,
 		       struct page **_page)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct address_space *mapping;
 	struct cachefs_block *block;
 	struct page *page;
 	filler_t *filler;
 	int ret;
 
-	_enter(",%lx,%u,%d,,",inode?inode->vfs_inode.i_ino:CACHEFS_INO_MISC,bix,wipe);
+	DECLARE_WAITQUEUE(myself, current);
+
+	_enter(",%lx,%u,%d,,",
+	       inode ? inode->vfs_inode.i_ino : CACHEFS_INO_MISC, bix, wipe);
 
-	if (_block)	*_block  = NULL;
-	if (_page)	*_page   = NULL;
+	if (_block)
+		*_block = NULL;
+	if (_page)
+		*_page = NULL;
 
 	/* get the block definition */
-	ret = cachefs_block_insert(super,bix,&block);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = cachefs_block_insert(super, bix, &block);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ret;
 	}
 
 	/* get the page alloc lock for this block */
-	if (test_and_set_bit(CACHEFS_BLOCK_ALLOC,&block->flags)) {
+	if (test_and_set_bit(CACHEFS_BLOCK_ALLOC, &block->flags)) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&block->writewq,&myself);
+		add_wait_queue(&block->writewq, &myself);
 
-		while (test_and_set_bit(CACHEFS_BLOCK_ALLOC,&block->flags)) {
+		while (test_and_set_bit(CACHEFS_BLOCK_ALLOC, &block->flags)) {
 			if (signal_pending(current))
 				break;
 
@@ -209,7 +213,7 @@
 		}
 
 		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&block->writewq,&myself);
+		remove_wait_queue(&block->writewq, &myself);
 
 		if (signal_pending(current))
 			goto intr;
@@ -217,13 +221,15 @@
 
 	/* get a page for it if it doesn't already exist */
 	if (!block->page) {
-		/* if the block is marked as currently undergoing writeback then there was an
-		 * ENOMEM encountered whilst trying to COW the block */
+		/* if the block is marked as currently undergoing writeback
+		 * then there was an ENOMEM encountered whilst trying to COW
+		 * the block */
 		if (test_bit(CACHEFS_BLOCK_WRITEBACK,&block->flags)) {
 			set_current_state(TASK_INTERRUPTIBLE);
 			add_wait_queue(&block->writewq,&myself);
 
-			while (test_bit(CACHEFS_BLOCK_WRITEBACK,&block->flags)) {
+			while (test_bit(CACHEFS_BLOCK_WRITEBACK,
+					&block->flags)) {
 				if (signal_pending(current))
 					break;
 
@@ -232,24 +238,27 @@
 			}
 
 			set_current_state(TASK_RUNNING);
-			remove_wait_queue(&block->writewq,&myself);
+			remove_wait_queue(&block->writewq, &myself);
 
 			if (signal_pending(current))
 				goto intr2;
 		}
 
 		/* load the page into the page cache */
-		mapping = (inode ? &inode->vfs_inode : super->imisc)->i_mapping;
+		if (inode)
+			mapping = inode->vfs_inode.i_mapping;
+		else
+			mapping = super->imisc->i_mapping;
 
-		filler = (filler_t*) mapping->a_ops->readpage;
+		filler = (filler_t *) mapping->a_ops->readpage;
 		if (wipe)
 			filler = cachefs_block_dummy_filler;
 
-		page = read_cache_page(mapping,bix,filler,block);
+		page = read_cache_page(mapping, bix, filler, block);
 
 		if (IS_ERR(page)) {
 			cachefs_block_put(block);
-			_leave(" = %ld",PTR_ERR(page));
+			_leave(" = %ld", PTR_ERR(page));
 			return PTR_ERR(page);
 		}
 
@@ -260,7 +269,7 @@
 		get_page(page);
 	}
 
-	clear_bit(CACHEFS_BLOCK_ALLOC,&block->flags);
+	clear_bit(CACHEFS_BLOCK_ALLOC, &block->flags);
 	wake_up_all(&block->writewq);
 
 	if (_block) {
@@ -283,7 +292,7 @@
 	return 0;
 
  intr2:
-	clear_bit(CACHEFS_BLOCK_ALLOC,&block->flags);
+	clear_bit(CACHEFS_BLOCK_ALLOC, &block->flags);
 	wake_up_all(&block->writewq);
  intr:
 	cachefs_block_put(block);
@@ -297,31 +306,31 @@
  */
 int cachefs_block_cow(struct cachefs_super *super, struct cachefs_block *block)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 //	struct address_space *mapping;
 	struct page *page; //, *newpage;
 	filler_t filler;
 //	int ret;
 
-	_enter(",%u",block->bix);
+	DECLARE_WAITQUEUE(myself, current);
+
+	_enter(",%u", block->bix);
 
 	/* get the page alloc lock for this block */
-	if (test_and_set_bit(CACHEFS_BLOCK_ALLOC,&block->flags)) {
+	if (test_and_set_bit(CACHEFS_BLOCK_ALLOC, &block->flags)) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		add_wait_queue(&block->writewq,&myself);
+		add_wait_queue(&block->writewq, &myself);
 
-		while (test_and_set_bit(CACHEFS_BLOCK_ALLOC,&block->flags)) {
+		while (test_and_set_bit(CACHEFS_BLOCK_ALLOC, &block->flags)) {
 			schedule();
 			set_current_state(TASK_UNINTERRUPTIBLE);
 		}
 
 		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&block->writewq,&myself);
+		remove_wait_queue(&block->writewq, &myself);
 	}
 
 	/* duplicate the page if it's flagged copy-on-write */
-	if (test_bit(CACHEFS_BLOCK_COW,&block->flags)) {
+	if (test_bit(CACHEFS_BLOCK_COW, &block->flags)) {
 		BUG();
 #if 0
 		struct cachefs_page *newpageio;
@@ -332,27 +341,30 @@
 		if (!newpage)
 			goto nomem;
 
-		if (cachefs_get_page_private(newpage,&newpageio,mapping->gfp_mask)<0)
+		if (cachefs_get_page_private(newpage, &newpageio,
+					     mapping->gfp_mask) < 0)
 			goto nomem_page;
 
 		newpageio->mapped_block =
-			cachefs_block_get(__cachefs_get_page_block(block->page));
+			cachefs_block_get(
+				__cachefs_get_page_block(block->page));
 
-		copy_page(kmap(newpage),kmap(block->page));
+		copy_page(kmap(newpage), kmap(block->page));
 		kunmap(newpage);
 		kunmap(block->page);
 
 		/* exchange the old page for the new page */
-		page = xchg(&block->page,NULL);
+		page = xchg(&block->page, NULL);
 
-		mapping->a_ops->releasepage(page,GFP_NOFS);
+		mapping->a_ops->releasepage(page, GFP_NOFS);
 		remove_from_page_cache(page);
 		page_cache_release(page);
 		page = NULL;
 
-		ret = add_to_page_cache_lru(newpage,mapping,block->bix,GFP_KERNEL);
+		ret = add_to_page_cache_lru(newpage, mapping, block->bix,
+					    GFP_KERNEL);
 		if (ret<0) {
-			BUG_ON(ret==-EEXIST);
+			BUG_ON(ret == -EEXIST);
 			page_cache_release(newpage);
 			return ret;
 		}
@@ -365,7 +377,7 @@
 		get_page(page);
 	}
 
-	clear_bit(CACHEFS_BLOCK_ALLOC,&block->flags);
+	clear_bit(CACHEFS_BLOCK_ALLOC, &block->flags);
 	wake_up_all(&block->writewq);
 
 	_leave(" = 0");
@@ -375,7 +387,7 @@
  nomem_page:
 	page_cache_release(newpage);
  nomem:
-	clear_bit(CACHEFS_BLOCK_ALLOC,&block->flags);
+	clear_bit(CACHEFS_BLOCK_ALLOC, &block->flags);
 	wake_up_all(&block->writewq);
 
 	_leave(" = -ENOMEM");
@@ -386,7 +398,8 @@
 /*****************************************************************************/
 /*
  * indicate that we're going to modify a block
- * - the page pointed to by *_page may be COW'd and replaced with a different page
+ * - the page pointed to by *_page may be COW'd and replaced with a different
+ *   page
  */
 void cachefs_block_modify(struct cachefs_super *super,
 			  struct cachefs_block *block,
@@ -394,13 +407,12 @@
 {
 	struct page *page;
 
-	_enter(",%u,",block->bix);
+	_enter(",%u,", block->bix);
 
-	if (*_page!=block->page) {
+	if (*_page != block->page) {
 		page = block->page;
 		get_page(page);
-		page = xchg(_page,page);
-		if (page) put_page(page);
+		cachefs_put_page(xchg(_page, page));
 	}
 
 	_leave("");
@@ -408,7 +420,8 @@
 
 /*****************************************************************************/
 /*
- * insert a block into the superblock's lookup tree (if it doesn't already exist)
+ * insert a block into the superblock's lookup tree (if it doesn't already
+ * exist)
  */
 int cachefs_block_insert(struct cachefs_super *super,
 			 cachefs_blockix_t bix,
@@ -423,7 +436,7 @@
 	*_block = NULL;
 
 	/* allocate a block record just in case */
-	newblock = kmem_cache_alloc(cachefs_block_jar,SLAB_KERNEL);
+	newblock = kmem_cache_alloc(cachefs_block_jar, SLAB_KERNEL);
 	if (!newblock)
 		return -ENOMEM;
 
@@ -438,12 +451,12 @@
 	parent = NULL;
 	block = NULL;
 
-	write_lock_irqsave(&super->blk_tree_lock,flags);
+	write_lock_irqsave(&super->blk_tree_lock, flags);
 	p = &super->blk_tree.rb_node;
 
 	while (*p) {
 		parent = *p;
-		block = rb_entry(parent,struct cachefs_block,lookup_node);
+		block = rb_entry(parent, struct cachefs_block, lookup_node);
 
 		if (bix < block->bix)
 			p = &(*p)->rb_left;
@@ -454,24 +467,24 @@
 	}
 
 	/* no block record yet - use the new one we allocated earlier */
-	rb_link_node(&newblock->lookup_node,parent,p);
-	rb_insert_color(&newblock->lookup_node,&super->blk_tree);
-	write_unlock_irqrestore(&super->blk_tree_lock,flags);
+	rb_link_node(&newblock->lookup_node, parent, p);
+	rb_insert_color(&newblock->lookup_node, &super->blk_tree);
+	write_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 	atomic_inc(&super->cnt_blk_tree);
 	*_block = newblock;
-	_leave(" = 0 [new %p{u=%d}]",newblock,atomic_read(&newblock->usage));
+	_leave(" = 0 [new %p{u=%d}]", newblock, atomic_read(&newblock->usage));
 	return 0;
 
  found:
 	cachefs_block_get(block);
-	write_unlock_irqrestore(&super->blk_tree_lock,flags);
+	write_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 	dbgfree(newblock);
-	kmem_cache_free(cachefs_block_jar,newblock);
+	kmem_cache_free(cachefs_block_jar, newblock);
 
 	*_block = block;
-	_leave(" = 0 [found %p{u=%d}]",block,atomic_read(&block->usage));
+	_leave(" = 0 [found %p{u=%d}]", block, atomic_read(&block->usage));
 	return 0;
 } /* end cachefs_block_insert() */
 
@@ -487,15 +500,15 @@
 	struct rb_node *node;
 	unsigned long flags;
 
-	_enter(",%d,",bix);
+	_enter(",%d,", bix);
 
 	*_block = NULL;
 
-	read_lock_irqsave(&super->blk_tree_lock,flags);
+	read_lock_irqsave(&super->blk_tree_lock, flags);
 	node = super->blk_tree.rb_node;
 
 	while (node) {
-		block = rb_entry(node,struct cachefs_block,lookup_node);
+		block = rb_entry(node, struct cachefs_block, lookup_node);
 
 		if (bix < block->bix)
 			node = node->rb_left;
@@ -504,17 +517,17 @@
 		else
 			goto found;
 	}
-	read_unlock_irqrestore(&super->blk_tree_lock,flags);
+	read_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 	_leave(" = -ENOENT");
 	return -ENOENT;
 
  found:
 	cachefs_block_get(block);
-	read_unlock_irqrestore(&super->blk_tree_lock,flags);
+	read_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 	*_block = block;
-	_leave(" = 0 [%p{u=%d}]",block,atomic_read(&block->usage));
+	_leave(" = 0 [%p{u=%d}]", block, atomic_read(&block->usage));
 	return 0;
 } /* end cachefs_block_find() */
 
@@ -527,21 +540,21 @@
 	struct cachefs_super *super = block->super;
 	unsigned long flags;
 
-	_enter(",{u=%d bix=%d}",atomic_read(&block->usage),block->bix);
+	_enter(",{u=%d bix=%d}", atomic_read(&block->usage), block->bix);
 
-	write_lock_irqsave(&super->blk_tree_lock,flags);
+	write_lock_irqsave(&super->blk_tree_lock, flags);
 
-	if (atomic_read(&block->usage)==0)
-		rb_erase(&block->lookup_node,&super->blk_tree);
+	if (atomic_read(&block->usage) == 0)
+		rb_erase(&block->lookup_node, &super->blk_tree);
 	else
 		block = NULL;
 
-	write_unlock_irqrestore(&super->blk_tree_lock,flags);
+	write_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 	if (block) {
 		atomic_dec(&super->cnt_blk_tree);
 		dbgfree(block);
-		kmem_cache_free(cachefs_block_jar,block);
+		kmem_cache_free(cachefs_block_jar, block);
 	}
 
 	_leave("");
@@ -558,41 +571,44 @@
 	struct rb_node *node;
 	unsigned long flags;
 
-	DECLARE_WAITQUEUE(myself,current);
+	DECLARE_WAITQUEUE(myself, current);
 
 	_enter("");
 
 	/* first thing to do is mark all blocks withdrawn
 	 * - this prevents the netfs from getting underfoot
 	 */
-	read_lock_irqsave(&super->blk_tree_lock,flags);
+	read_lock_irqsave(&super->blk_tree_lock, flags);
 
-	for (node=rb_first(&super->blk_tree); node; node=rb_next(node)) {
-		block = rb_entry(node,struct cachefs_block,lookup_node);
-		set_bit(CACHEFS_BLOCK_WITHDRAWN,&block->flags);
+	for (node = rb_first(&super->blk_tree); node; node = rb_next(node)) {
+		block = rb_entry(node, struct cachefs_block, lookup_node);
+		set_bit(CACHEFS_BLOCK_WITHDRAWN, &block->flags);
 	}
 
-	read_unlock_irqrestore(&super->blk_tree_lock,flags);
+	read_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 	/* now withdraw each block that's already in use by a netfs */
 	for (;;) {
 		block = NULL;
-		write_lock_irqsave(&super->blk_tree_lock,flags);
+		write_lock_irqsave(&super->blk_tree_lock, flags);
 
-		for (node=rb_first(&super->blk_tree); node; node=rb_next(node)) {
-			block = rb_entry(node,struct cachefs_block,lookup_node);
+		for (node = rb_first(&super->blk_tree);
+		     node;
+		     node = rb_next(node)) {
+			block = rb_entry(node, struct cachefs_block,
+					 lookup_node);
 			if (block->ref) {
 				cachefs_block_get(block);
 				break;
 			}
 		}
 
-		write_unlock_irqrestore(&super->blk_tree_lock,flags);
+		write_unlock_irqrestore(&super->blk_tree_lock, flags);
 
 		if (!node)
 			break;
 
-		_debug("withdraw block %u",block->bix);
+		_debug("withdraw block %u", block->bix);
 
 		/* disconnect block from netfs page cookie */
 		xblock = NULL;
@@ -609,21 +625,21 @@
 		}
 		write_unlock(&pageio->lock);
 
-		if (xblock)
-			cachefs_block_put(xblock);
+		cachefs_block_put(xblock);
 
 		/* wait for the netfs to finish with the block */
-		if (test_bit(CACHEFS_BLOCK_NETFSBUSY,&block->flags)) {
+		if (test_bit(CACHEFS_BLOCK_NETFSBUSY, &block->flags)) {
 			set_current_state(TASK_UNINTERRUPTIBLE);
-			add_wait_queue(&block->writewq,&myself);
+			add_wait_queue(&block->writewq, &myself);
 
-			while (test_bit(CACHEFS_BLOCK_NETFSBUSY,&block->flags)) {
+			while (test_bit(CACHEFS_BLOCK_NETFSBUSY,
+					&block->flags)) {
 				schedule();
 				set_current_state(TASK_UNINTERRUPTIBLE);
 			}
 
 			set_current_state(TASK_RUNNING);
-			remove_wait_queue(&block->writewq,&myself);
+			remove_wait_queue(&block->writewq, &myself);
 		}
 
 		/* a block that's not yet valid must be cancelled */

Index: aops.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/aops.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- aops.c	1 Jul 2003 17:44:50 -0000	1.38
+++ aops.c	4 Jul 2003 09:04:44 -0000	1.39
@@ -51,9 +51,12 @@
 static int cachefs_readpages(struct file *file, struct address_space *mapping,
 			     struct list_head *pages, unsigned nr_pages);
 static int cachefs_writepage(struct page *page, struct writeback_control *wbc);
-static int cachefs_writepages(struct address_space *mapping, struct writeback_control *wbc);
-static int cachefs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to);
-static int cachefs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to);
+static int cachefs_writepages(struct address_space *mapping,
+			      struct writeback_control *wbc);
+static int cachefs_prepare_write(struct file *file, struct page *page,
+				 unsigned from, unsigned to);
+static int cachefs_commit_write(struct file *file, struct page *page,
[...1214 lines suppressed...]
 	ret = -ENOMEM;
-	bio = bio_alloc(GFP_KERNEL,1);
+	bio = bio_alloc(GFP_KERNEL, 1);
 	if (!bio)
 		goto error;
 
@@ -1455,11 +1517,11 @@
 	bio->bi_sector	= block->bix << (PAGE_SHIFT - sb->s_blocksize_bits);
 	bio->bi_end_io	= cachefs_io_end_io_read;
 	//dump_bio(bio,1);
-	submit_bio(READ,bio);
+	submit_bio(READ, bio);
 	ret = 0;
 
  error:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end cachefs_file_readpage() */