nfsd4: lookup up callback cred only once
[safe/jmp/linux-2.6] / fs / 9p / vfs_dentry.c
index 0cf2b84..d743252 100644 (file)
@@ -7,9 +7,8 @@
  *  Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  *
  *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+ *  it under the terms of the GNU General Public License version 2
+ *  as published by the Free Software Foundation.
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include <linux/pagemap.h>
 #include <linux/stat.h>
 #include <linux/string.h>
-#include <linux/smp_lock.h>
 #include <linux/inet.h>
 #include <linux/namei.h>
 #include <linux/idr.h>
+#include <linux/sched.h>
+#include <net/9p/9p.h>
+#include <net/9p/client.h>
 
-#include "debug.h"
 #include "v9fs.h"
-#include "9p.h"
 #include "v9fs_vfs.h"
 #include "fid.h"
 
 
 static int v9fs_dentry_delete(struct dentry *dentry)
 {
-       dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry);
+       P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
+                                                                       dentry);
+
        return 1;
 }
 
 /**
- * v9fs_dentry_release - called when dentry is going to be freed
- * @dentry:  dentry that is being release
+ * v9fs_cached_dentry_delete - called when dentry refcount equals 0
+ * @dentry:  dentry in question
+ *
+ * Only return 1 if our inode is invalid.  Only non-synthetic files
+ * (ones without mtime == 0) should be calling this function.
  *
  */
 
-void v9fs_dentry_release(struct dentry *dentry)
+static int v9fs_cached_dentry_delete(struct dentry *dentry)
 {
-       int err;
+       struct inode *inode = dentry->d_inode;
+       P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
+                                                                       dentry);
 
-       dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry);
+       if(!inode)
+               return 1;
 
-       if (dentry->d_fsdata != NULL) {
-               struct list_head *fid_list = dentry->d_fsdata;
-               struct v9fs_fid *temp = NULL;
-               struct v9fs_fid *current_fid = NULL;
+       return 0;
+}
 
-               list_for_each_entry_safe(current_fid, temp, fid_list, list) {
-                       err = v9fs_t_clunk(current_fid->v9ses, current_fid->fid);
+/**
+ * v9fs_dentry_release - called when dentry is going to be freed
+ * @dentry:  dentry that is being release
+ *
+ */
 
-                       if (err < 0)
-                               dprintk(DEBUG_ERROR, "clunk failed: %d name %s\n",
-                                       err, dentry->d_iname);
+void v9fs_dentry_release(struct dentry *dentry)
+{
+       struct v9fs_dentry *dent;
+       struct p9_fid *temp, *current_fid;
 
-                       v9fs_fid_destroy(current_fid);
+       P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
+                                                                       dentry);
+       dent = dentry->d_fsdata;
+       if (dent) {
+               list_for_each_entry_safe(current_fid, temp, &dent->fidlist,
+                                                                       dlist) {
+                       p9_client_clunk(current_fid);
                }
 
-               kfree(dentry->d_fsdata);        /* free the list_head */
+               kfree(dent);
+               dentry->d_fsdata = NULL;
        }
 }
 
-struct dentry_operations v9fs_dentry_operations = {
+const struct dentry_operations v9fs_cached_dentry_operations = {
+       .d_delete = v9fs_cached_dentry_delete,
+       .d_release = v9fs_dentry_release,
+};
+
+const struct dentry_operations v9fs_dentry_operations = {
        .d_delete = v9fs_dentry_delete,
        .d_release = v9fs_dentry_release,
 };