Subject: afs/fs/cachefs aops.c,1.40,1.41

From: [email-masked]
Date: Tue, 15 Jul 2003 17:41:32 +0100

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

Modified Files:
	aops.c 
Log Message:
note advance of alloc stack tracking in allocation records, not following
records

Index: aops.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/aops.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- aops.c	9 Jul 2003 10:39:50 -0000	1.40
+++ aops.c	15 Jul 2003 16:41:30 -0000	1.41
@@ -923,8 +923,8 @@
 	struct cachefs_ondisc_metadata *metadata;
 	struct cachefs_super *super = sb->s_fs_info;
 	struct cachefs_block *block;
-	cachefs_blockix_t alloc2os = 0;
-	unsigned next_count = 0;
+	cachefs_blockix_t alloc2os = 0, old_alloc_cur;
+	u_int32_t next_count = 0, old_alloc_leaf;
 	int ret;
 	u8 *data;
 
@@ -954,7 +954,8 @@
 		if (!(step[1].flags & CACHEFS_BLOCK_IS_INODE))
 			cachefs_trans_affects_inode(step->transaction, inode);
 
-		jentry->count = inode->index_epp;
+		jentry->count = inode->index_esize;
+		jentry->ixentry = step->page->index * inode->index_epp;
 	}
 
 	/* freshly allocated data blocks must be recorded in the v-journal */
@@ -999,6 +1000,9 @@
 	BUG_ON(super->alloc_leaf > CACHEFS_ONDISC_LEAVES_PER_FREE_NODE);
 
 	/* choose either a dependent block or the now empty node */
+	old_alloc_cur  = super->alloc_cur;
+	old_alloc_leaf = super->alloc_leaf;
+
 	if (super->alloc_leaf == CACHEFS_ONDISC_LEAVES_PER_FREE_NODE) {
 		/* no dependent blocks left - take the alloc node itself */
 		block = super->alloc_block;
@@ -1008,12 +1012,12 @@
 		BUG_ON(!jentry->block);
 
 		node = kmap(super->alloc_node);
-		alloc2os	= node->next;
-		next_count	= node->count;
+		super->alloc_cur	= node->next;
+		super->alloc_leaf	= 0;
+		next_count		= node->count;
 		kunmap(node);
 
-		jentry->auxblock = alloc2os;
-		jentry->auxentry = 1;
+		alloc2os = super->alloc_cur;
 
 		if (step->page)
 			cachefs_block_set(super,
@@ -1024,14 +1028,11 @@
 	else {
 		/* take the next dependent page */
 		node = kmap(super->alloc_node);
-		jentry->block	= node->leaves[super->alloc_leaf];
+		jentry->block	= node->leaves[super->alloc_leaf++];
 		alloc2os	= node->next;
 		kunmap(node);
 		BUG_ON(!jentry->block);
 
-		jentry->auxblock = 0;
-		jentry->auxentry = 0;
-
 		if (!step->page) {
 			ret = cachefs_block_read(super, NULL, jentry->block, 1,
 						 &block, &step->page);
@@ -1070,17 +1071,20 @@
 		ret = cachefs_block_read(super, NULL, alloc2os, 0,
 					 &super->alloc_nxblock,
 					 &super->alloc_next);
-		if (ret==0)
+		if (ret == 0)
 			set_bit(CACHEFS_BLOCK_CRITICAL,
 				&super->alloc_nxblock->flags);
 		else
-			printk("CacheFS: can't read 2OS of alloc stack:"
-			       " %d\n", ret);
+			printk("CacheFS: can't read 2OS of alloc stack: %d\n",
+			       ret);
 	}
 
 	/* make sure the journal is marked on disc before doing anything else */
-	if (cachefs_trans_mark(step->transaction) < 0)
+	if (cachefs_trans_mark(step->transaction) < 0) {
+		super->alloc_cur  = old_alloc_cur;
+		super->alloc_leaf = old_alloc_leaf;
 		goto error_block;
+	}
 
 	if (step->flags & CACHEFS_BLOCK_INIT_NETFSDATA) {
 		set_bit(CACHEFS_BLOCK_NETFSDATA, &block->flags);
@@ -1096,16 +1100,14 @@
 		kunmap(step->page);
 	}
 
-	/* now we can mess about with the alloc tracking */
-	if (super->alloc_leaf == CACHEFS_ONDISC_LEAVES_PER_FREE_NODE) {
+	/* clean up the alloc stack tracking */
+	if (old_alloc_leaf == CACHEFS_ONDISC_LEAVES_PER_FREE_NODE) {
 		struct page *dead;
 
 		/* move the allocation stack to the 2OS */
-		super->alloc_cur	= jentry->auxblock;
-		super->alloc_cur_n	= next_count;
-		super->alloc_leaf	= 0;
-
 		dead = super->alloc_node;
+
+		super->alloc_cur_n	= next_count;
 		super->alloc_node	= super->alloc_next;
 		super->alloc_block	= super->alloc_nxblock;
 		super->alloc_next	= NULL;
@@ -1113,9 +1115,6 @@
 		dbgpgfree(dead);
 		page_cache_release(dead);
 	}
-	else {
-		super->alloc_leaf++;
-	}
 
 	super->alloc_cur_n--;
 
@@ -1136,6 +1135,10 @@
 	metadata->size	= inode->vfs_inode.i_size;
 	metadata->mtime	= CURRENT_TIME.tv_sec;
 
+	if (step->flags & CACHEFS_BLOCK_INIT_INDEX) {
+		metadata->freelink = step->page->index * inode->index_epp;
+	}
+
 	if (step[1].flags & CACHEFS_BLOCK_IS_INODE) {
 		unsigned long pageaddr = (unsigned long) metadata & PAGE_MASK;
 		*(cachefs_blockix_t *)(pageaddr + step->offset) = step->bix;
@@ -1350,7 +1353,8 @@
 			jentry->auxmark	= step->auxmark;
 			jentry->upblock	=
 				__cachefs_get_page_block(step[1].page)->bix;
-			jentry->upentry	= step->offset / sizeof(cachefs_blockix_t);
+			jentry->upentry	=
+				step->offset / sizeof(cachefs_blockix_t);
 
 			ret = cachefs_get_block_alloc(inode->vfs_inode.i_sb,
 						      inode, step);