Subject: afs/fs/cachefs interface.c,1.7,1.8 index.c,1.19,1.20 cachetest-main.c,1.9,1.10 cachefs-int.h,1.34,1.35

From: [email-masked]
Date: Tue, 03 Jun 2003 18:45:30 +0100

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

Modified Files:
	interface.c index.c cachetest-main.c cachefs-int.h 
Log Message:
make data retrieval work

Index: interface.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/interface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- interface.c	23 May 2003 14:07:31 -0000	1.7
+++ interface.c	3 Jun 2003 17:45:27 -0000	1.8
@@ -362,7 +362,7 @@
 	kdebug("found_parent_entry");
 
 	/* search the parent index for a reference compatible with this object */
-	ret = cachefs_index_search(ipinode,cookie,&srch->ino);
+	ret = cachefs_index_search(ipinode,cookie,NULL,&srch->ino);
 	switch (ret) {
 	default:
 		goto error;
@@ -381,6 +381,11 @@
 		list_add_tail(&srch->link,&cookie->search_results);
 		list_add_tail(&inode->cookie_link,&cookie->backing_inodes);
 		atomic_inc(&cookie->usage);
+
+		spin_lock(&super->ino_list_lock);
+		list_add_tail(&inode->super_link,&super->ino_list);
+		spin_unlock(&super->ino_list_lock);
+
 		up(&inode->vfs_inode.i_sem);
 		break;
 
@@ -711,7 +716,8 @@
 	const struct cachefs_ondisc_fsdef *fsdef = entry;
 	struct cachefs_netfs *netfs = target;
 
-	kenter("{%s.%u},{%s.%u}",
+	kenter("%p,%p",target,entry);
+	kdebug("{%s.%u},{%s.%u}",
 	       netfs->name,netfs->version,
 	       fsdef->name,fsdef->version);
 
@@ -783,7 +789,7 @@
 /*
  * handle a page having been read
  */
-static int cachefs_page_read(struct bio *bio, unsigned int bytes_done, int error)
+static int cachefs_page_read_endio(struct bio *bio, unsigned int bytes_done, int error)
 {
 	struct cachefs_io_end *end_io = bio->bi_private;
 	struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
@@ -806,7 +812,7 @@
 	bio_put(bio);
 	_leave(" = 0");
 	return 0;
-} /* end cachefs_page_read() */
+} /* end cachefs_page_read_endio() */
 
 /*****************************************************************************/
 /*
@@ -945,7 +951,7 @@
 
 	bio->bi_bdev	= block->super->sb->s_bdev;
 	bio->bi_private	= end_io;
-	bio->bi_end_io	= cachefs_page_read;
+	bio->bi_end_io	= cachefs_page_read_endio;
 	bio->bi_sector	= block->bix;
 	bio->bi_sector	<<= PAGE_SHIFT - block->super->sb->s_blocksize_bits;
 
@@ -1003,7 +1009,8 @@
 	for (; bvec>=bio->bi_io_vec; bvec--)
 		end_io->func(end_io->cookie_data,bvec->bv_page,end_io->data);
 
-	cachefs_vj_write_complete(end_io->block);
+	if (end_io->block->vjentry)
+		cachefs_vj_write_complete(end_io->block);
 
 	clear_bit(CACHEFS_BLOCK_NETFSBUSY,&end_io->block->flags);
 	wake_up(&end_io->block->writewq);

Index: index.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/index.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- index.c	2 Jun 2003 09:17:42 -0000	1.19
+++ index.c	3 Jun 2003 17:45:27 -0000	1.20
@@ -33,7 +33,8 @@
 	struct cachefs_cookie		*target;
 	struct cachefs_inode		*iinode;
 	unsigned			entsize;
-	int				entry;
+	unsigned			ino;
+	unsigned			entry;
 };
 
 /*****************************************************************************/
@@ -82,8 +83,9 @@
 		    xent->state==CACHEFS_ONDISC_INDEX_RECYCLE)
 			continue;
 
-		if (rec->index->idef->match(rec->index,xent->data)) {
+		if (rec->index->idef->match(rec->target->netfs_data,xent->data)) {
 			rec->entry = offset/tmp + page->index*(PAGE_SIZE/tmp);
+			rec->ino   = xent->ino;
 			desc->count = 0;
 			ret = 0;
 			break;
@@ -104,11 +106,13 @@
 /*
  * search for the specified target object in an index in one cache
  * - returns -ENOENT if not found
- * - returns 0 if found, and stores the entry number in *_entry
+ * - returns 0 if found, and stores the entry number in *_entry and the inode
+ *   number of the backing file in *_ino
  */
 int cachefs_index_search(struct cachefs_inode *index,
 			 struct cachefs_cookie *target,
-			 unsigned *_entry)
+			 unsigned *_entry,
+			 unsigned *_ino)
 {
 	struct cachefs_index_search_record rec;
 	struct file_ra_state ra;
@@ -118,13 +122,17 @@
 
 	kenter("{%s,%lu}",index->cookie->idef->name,index->vfs_inode.i_ino);
 
-	*_entry = 0;
+	if (_entry)
+		*_entry = UINT_MAX;
+	if (_ino)
+		*_ino = 0;
 
 	rec.iinode	= index;
 	rec.index	= index->cookie;
 	rec.target	= target;
-	rec.entry	= UINT_MAX;
 	rec.entsize	= rec.iinode->index_esize;
+	rec.entry	= UINT_MAX;
+	rec.ino		= 0;
 
 	/* scan the file through the pagecache */
 	file_ra_state_init(&ra,rec.iinode->vfs_inode.i_mapping);
@@ -147,11 +155,14 @@
 		ret = -ENOENT;
 	}
 	else {
-		*_entry = rec.entry;
+		if (_entry)
+			*_entry = rec.entry;
+		if (_ino)
+			*_ino = rec.ino;
 		ret = 0;
 	}
 
-	kleave(" = %d [ent %u]",ret,*_entry);
+	kleave(" = %d [ent=%d ino=%u]",ret,rec.entry,rec.ino);
 	return ret;
 } /* end cachefs_index_search() */

Index: cachetest-main.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/cachetest-main.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- cachetest-main.c	23 May 2003 12:59:22 -0000	1.9
+++ cachetest-main.c	3 Jun 2003 17:45:27 -0000	1.10
@@ -247,7 +247,7 @@
  */
 static cachefs_match_val_t cell_match(void *target, const void *entry)
 {
-	struct afs_cell *cell = container_of(target,struct afs_cell,cache);
+	struct afs_cell *cell = target;
 
 	kenter("");
 
@@ -263,7 +263,7 @@
  */
 static void cell_update(void *source, void *entry)
 {
-	struct afs_cell *cell = container_of(source,struct afs_cell,cache);
+	struct afs_cell *cell = source;
 
 	kenter("%p,%p",source,entry);
 
@@ -277,7 +277,7 @@
  */
 static cachefs_match_val_t vldb_match(void *target, const void *entry)
 {
-	struct afs_volume *volume = container_of(target,struct afs_volume,cache);
+	struct afs_volume *volume = target;
 
 	kenter("");
 
@@ -293,7 +293,7 @@
  */
 static void vldb_update(void *source, void *entry)
 {
-	struct afs_volume *volume = container_of(source,struct afs_volume,cache);
+	struct afs_volume *volume = source;
 
 	kenter("%p,%p",source,entry);
 
@@ -307,7 +307,7 @@
  */
 static cachefs_match_val_t file_match(void *target, const void *entry)
 {
-	struct afs_inode *inode = container_of(target,struct afs_inode,cache);
+	struct afs_inode *inode = target;
 	u_int32_t fid = htonl(inode->fid);
 
 	kenter("");
@@ -324,7 +324,7 @@
  */
 static void file_update(void *source, void *entry)
 {
-	struct afs_inode *inode = container_of(source,struct afs_inode,cache);
+	struct afs_inode *inode = source;
 	u_int32_t fid = htonl(inode->fid);
 
 	kenter("%p,%p",source,entry);

Index: cachefs-int.h
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/cachefs-int.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- cachefs-int.h	2 Jun 2003 09:17:42 -0000	1.34
+++ cachefs-int.h	3 Jun 2003 17:45:27 -0000	1.35
@@ -295,7 +295,6 @@
 {
 	if (block) {
 		int usage = atomic_read(&block->usage);
-		/*kenter(",{bix=%u u=%d",block->bix,atomic_read(&block->usage));*/
 
 		if ((usage&0xffffff00)==0x6b6b6b00) {
 			printk("\ncachefs_block_put(%p{u=%d})\n",block,usage);
@@ -442,7 +441,8 @@
 
 extern int cachefs_index_search(struct cachefs_inode *index,
 				struct cachefs_cookie *target,
-				unsigned *_entry);
+				unsigned *_entry,
+				unsigned *_ino);
 
 extern int cachefs_index_add(struct cachefs_inode *index,
 			     struct cachefs_cookie *cookie,