afs/fs/cachefs interface.c,1.2,1.3 cachefs-int.h,1.27,1.28

dwh at infradead.org dwh at infradead.org
Thu Apr 24 16:42:28 BST 2003


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

Modified Files:
	interface.c cachefs-int.h 
Log Message:
fixed netfs & cache removing problems


Index: interface.c
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/interface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- interface.c	24 Apr 2003 12:02:34 -0000	1.2
+++ interface.c	24 Apr 2003 14:42:24 -0000	1.3
@@ -141,6 +141,10 @@
 	kenter("");
 
 	/* prepare an active-inode record for the FSDEF index of this cache */
+	printk("###\n");
+	printk("### PREALLOC ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
+
 	memset(active,0,sizeof(*active));
 
 	atomic_set(&active->usage,2);
@@ -168,6 +172,11 @@
 
 	down_write(&cachefs_fsdef_index.sem);
 	list_add_tail(&active->link,&cachefs_fsdef_index.active_inodes);
+
+	printk("###\n");
+	printk("### LISTADD ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
+
 	atomic_inc(&cachefs_fsdef_index.usage);
 	up_write(&cachefs_fsdef_index.sem);
 
@@ -261,6 +270,10 @@
 		return -ENOMEM;
 	}
 
+	printk("###\n");
+	printk("### ALLOC ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
+
 	memset(active,0,sizeof(*active));
 
 	active->super	= super;
@@ -292,6 +305,10 @@
 			/* set a negative entry */
 			if (list_empty(&active->link)) {
 				list_add_tail(&active->link,&cookie->active_inodes);
+
+	printk("###\n");
+	printk("### LISTADD ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
 				atomic_inc(&cookie->usage);
 			}
 		}
@@ -323,6 +340,10 @@
 	case 0:
 		if (list_empty(&active->link)) {
 			list_add_tail(&active->link,&cookie->active_inodes);
+
+	printk("###\n");
+	printk("### LISTADD ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
 			atomic_inc(&cookie->usage);
 		}
 		goto add_to_active_tree;
@@ -331,6 +352,10 @@
 		/* we can at least set a valid negative entry */
 		if (list_empty(&active->link)) {
 			list_add_tail(&active->link,&cookie->active_inodes);
+
+	printk("###\n");
+	printk("### LISTADD ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
 			atomic_inc(&cookie->usage);
 		}
 
@@ -514,9 +539,15 @@
 		 */
 		list_for_each_safe(_p,_n,&cookie->active_inodes) {
 			active = list_entry(_p,struct cachefs_active_inode,link);
-			if (active->super==super || active->ino==0) {
+			if (active->super!=super || active->ino==0) {
 				list_del(&active->link);
-				kfree(active);
+
+				down_write(&active->sem);
+				active->cookie = NULL;
+				up_write(&active->sem);
+
+				cachefs_cookie_put(cookie);
+				cachefs_put_active_inode(active);
 			}
 		}
 
@@ -581,7 +612,12 @@
 
 	/* break links with all the active inodes */
 	while (!list_empty(&cookie->active_inodes)) {
-		active = list_entry(&cookie->active_inodes, struct cachefs_active_inode,link);
+		active = list_entry(cookie->active_inodes.next, struct cachefs_active_inode,link);
+
+
+		printk("###\n");
+		printk("### RELINQ ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+		printk("###\n");
 
 		/* detach the cache inode from the cached object cookie */
 		set_bit(CACHEFS_ACTIVE_INODE_RELEASING,&active->flags);
@@ -600,6 +636,9 @@
 
 	up_write(&cookie->sem);
 
+	if (cookie->iparent)
+		atomic_dec(&cookie->iparent->children);
+
 	cachefs_cookie_put(cookie);
 
 	kleave("");
@@ -628,21 +667,15 @@
 	/* first of all we have to break the links between the active inode and the cookie
 	 * - we have to hold both writelocks BUT we have to get the cookie lock FIRST
 	 */
-		kdebug("%d",__LINE__);
 	down_write(&active->sem);
 
 	cookie = active->cookie;
-	kdebug("cookie: %p",cookie);
-
 	if (cookie) {
 		atomic_inc(&cookie->usage); /* pin the cookie */
 
 		up_write(&active->sem); /* re-order the locks to avoid deadlock */
-		kdebug("%d",__LINE__);
 		down_write(&cookie->sem);
-		kdebug("%d",__LINE__);
 		down_write(&active->sem);
-		kdebug("%d",__LINE__);
 
 		list_del_init(&active->link);
 
@@ -654,7 +687,8 @@
 
 	up_write(&active->sem);
 
-	cachefs_cookie_put(cookie);
+	if (cookie)
+		cachefs_cookie_put(cookie);
 
 	if (xcookie) {
 		cachefs_cookie_put(xcookie);
@@ -716,6 +750,9 @@
 {
 	kenter("");
 
+	if (cookie->iparent)
+		cachefs_cookie_put(cookie->iparent);
+
 	kfree(cookie);
 
 	kleave("");
@@ -732,10 +769,14 @@
 
 	kenter("");
 
+	printk("###\n");
+	printk("### PUT ACTIVE %p{%x}\n",active,atomic_read(&active->usage));
+	printk("###\n");
+
 	/* remove from the cache's inode tree */
 	super = active->super;
 
-	if (!test_bit(CACHEFS_ACTIVE_INODE_WITHDRAWN,&active->flags))
+	if (active->ino && !test_bit(CACHEFS_ACTIVE_INODE_WITHDRAWN,&active->flags))
 		rb_erase(&active->node,&super->ino_tree);
 
 	spin_unlock(&super->ino_tree_lock);

Index: cachefs-int.h
===================================================================
RCS file: /home/cvs/afs/fs/cachefs/cachefs-int.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- cachefs-int.h	24 Apr 2003 12:02:34 -0000	1.27
+++ cachefs-int.h	24 Apr 2003 14:42:24 -0000	1.28
@@ -478,7 +478,7 @@
 /*
  * debug tracing
  */
-#define dbgprintk(FMT,...) printk("[%-5.5hu] "FMT"\n",(u16)jiffies ,##__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__)




More information about the linux-afs-cvs mailing list