aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcookies.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dcookies.c')
-rw-r--r--fs/dcookies.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/fs/dcookies.c b/fs/dcookies.c
index 792cbf55fa95..13c29f1f711f 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/dcookies.h> 25#include <linux/dcookies.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/path.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28 29
29/* The dcookies are allocated from a kmem_cache and 30/* The dcookies are allocated from a kmem_cache and
@@ -31,8 +32,7 @@
31 * code here is particularly performance critical 32 * code here is particularly performance critical
32 */ 33 */
33struct dcookie_struct { 34struct dcookie_struct {
34 struct dentry * dentry; 35 struct path path;
35 struct vfsmount * vfsmnt;
36 struct list_head hash_list; 36 struct list_head hash_list;
37}; 37};
38 38
@@ -51,7 +51,7 @@ static inline int is_live(void)
51/* The dentry is locked, its address will do for the cookie */ 51/* The dentry is locked, its address will do for the cookie */
52static inline unsigned long dcookie_value(struct dcookie_struct * dcs) 52static inline unsigned long dcookie_value(struct dcookie_struct * dcs)
53{ 53{
54 return (unsigned long)dcs->dentry; 54 return (unsigned long)dcs->path.dentry;
55} 55}
56 56
57 57
@@ -89,19 +89,17 @@ static void hash_dcookie(struct dcookie_struct * dcs)
89} 89}
90 90
91 91
92static struct dcookie_struct * alloc_dcookie(struct dentry * dentry, 92static struct dcookie_struct *alloc_dcookie(struct path *path)
93 struct vfsmount * vfsmnt)
94{ 93{
95 struct dcookie_struct * dcs = kmem_cache_alloc(dcookie_cache, GFP_KERNEL); 94 struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache,
95 GFP_KERNEL);
96 if (!dcs) 96 if (!dcs)
97 return NULL; 97 return NULL;
98 98
99 dentry->d_cookie = dcs; 99 path->dentry->d_cookie = dcs;
100 100 dcs->path = *path;
101 dcs->dentry = dget(dentry); 101 path_get(path);
102 dcs->vfsmnt = mntget(vfsmnt);
103 hash_dcookie(dcs); 102 hash_dcookie(dcs);
104
105 return dcs; 103 return dcs;
106} 104}
107 105
@@ -109,8 +107,7 @@ static struct dcookie_struct * alloc_dcookie(struct dentry * dentry,
109/* This is the main kernel-side routine that retrieves the cookie 107/* This is the main kernel-side routine that retrieves the cookie
110 * value for a dentry/vfsmnt pair. 108 * value for a dentry/vfsmnt pair.
111 */ 109 */
112int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, 110int get_dcookie(struct path *path, unsigned long *cookie)
113 unsigned long * cookie)
114{ 111{
115 int err = 0; 112 int err = 0;
116 struct dcookie_struct * dcs; 113 struct dcookie_struct * dcs;
@@ -122,10 +119,10 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
122 goto out; 119 goto out;
123 } 120 }
124 121
125 dcs = dentry->d_cookie; 122 dcs = path->dentry->d_cookie;
126 123
127 if (!dcs) 124 if (!dcs)
128 dcs = alloc_dcookie(dentry, vfsmnt); 125 dcs = alloc_dcookie(path);
129 126
130 if (!dcs) { 127 if (!dcs) {
131 err = -ENOMEM; 128 err = -ENOMEM;
@@ -174,7 +171,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
174 goto out; 171 goto out;
175 172
176 /* FIXME: (deleted) ? */ 173 /* FIXME: (deleted) ? */
177 path = d_path(dcs->dentry, dcs->vfsmnt, kbuf, PAGE_SIZE); 174 path = d_path(dcs->path.dentry, dcs->path.mnt, kbuf, PAGE_SIZE);
178 175
179 if (IS_ERR(path)) { 176 if (IS_ERR(path)) {
180 err = PTR_ERR(path); 177 err = PTR_ERR(path);
@@ -254,9 +251,8 @@ out_kmem:
254 251
255static void free_dcookie(struct dcookie_struct * dcs) 252static void free_dcookie(struct dcookie_struct * dcs)
256{ 253{
257 dcs->dentry->d_cookie = NULL; 254 dcs->path.dentry->d_cookie = NULL;
258 dput(dcs->dentry); 255 path_put(&dcs->path);
259 mntput(dcs->vfsmnt);
260 kmem_cache_free(dcookie_cache, dcs); 256 kmem_cache_free(dcookie_cache, dcs);
261} 257}
262 258