Fix configfs leak
[safe/jmp/linux-2.6] / fs / afs / volume.c
index 15e1367..a353e69 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
+#include <linux/sched.h>
 #include "internal.h"
 
 static const char *afs_voltypes[] = { "R/W", "R/O", "BAK" };
@@ -123,13 +124,11 @@ struct afs_volume *afs_volume_lookup(struct afs_mount_params *params)
        }
 
        /* attach the cache and volume location */
-#ifdef AFS_CACHING_SUPPORT
-       cachefs_acquire_cookie(vlocation->cache,
-                              &afs_vnode_cache_index_def,
-                              volume,
-                              &volume->cache);
+#ifdef CONFIG_AFS_FSCACHE
+       volume->cache = fscache_acquire_cookie(vlocation->cache,
+                                              &afs_volume_cache_index_def,
+                                              volume);
 #endif
-
        afs_get_vlocation(vlocation);
        volume->vlocation = vlocation;
 
@@ -193,8 +192,8 @@ void afs_put_volume(struct afs_volume *volume)
        up_write(&vlocation->cell->vl_sem);
 
        /* finish cleaning up the volume */
-#ifdef AFS_CACHING_SUPPORT
-       cachefs_relinquish_cookie(volume->cache, 0);
+#ifdef CONFIG_AFS_FSCACHE
+       fscache_relinquish_cookie(volume->cache, 0);
 #endif
        afs_put_vlocation(vlocation);
 
@@ -295,6 +294,7 @@ struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *vnode)
  * - releases the ref on the server struct that was acquired by picking
  * - records result of using a particular server to access a volume
  * - return 0 to try again, 1 if okay or to issue error
+ * - the caller must release the server struct if result was 0
  */
 int afs_volume_release_fileserver(struct afs_vnode *vnode,
                                  struct afs_server *server,
@@ -312,7 +312,8 @@ int afs_volume_release_fileserver(struct afs_vnode *vnode,
        case 0:
                server->fs_act_jif = jiffies;
                server->fs_state = 0;
-               break;
+               _leave("");
+               return 1;
 
                /* the fileserver denied all knowledge of the volume */
        case -ENOMEDIUM:
@@ -377,14 +378,12 @@ int afs_volume_release_fileserver(struct afs_vnode *vnode,
                server->fs_act_jif = jiffies;
        case -ENOMEM:
        case -ENONET:
-               break;
+               /* tell the caller to accept the result */
+               afs_put_server(server);
+               _leave(" [local failure]");
+               return 1;
        }
 
-       /* tell the caller to accept the result */
-       afs_put_server(server);
-       _leave("");
-       return 1;
-
        /* tell the caller to loop around and try the next server */
 try_next_server_upw:
        up_write(&volume->server_sem);