diff options
author | Jan Blunck <jblunck@suse.de> | 2008-02-14 22:38:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-15 00:17:08 -0500 |
commit | 448678a0f3cdd0157f00e98bd337e32030273637 (patch) | |
tree | 12b4fb7875dd500b1923d3eec316db4c1e1a3692 | |
parent | 3dcd25f37cfe2943beca93f41f50994108248a60 (diff) |
d_path: Make get_dcookie() use a struct path argument
get_dcookie() is always called with a dentry and a vfsmount from a struct
path. Make get_dcookie() take it directly as an argument.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Jan Blunck <jblunck@suse.de>
Acked-by: Christoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/powerpc/oprofile/cell/spu_task_sync.c | 15 | ||||
-rw-r--r-- | drivers/oprofile/buffer_sync.c | 21 | ||||
-rw-r--r-- | fs/dcookies.c | 34 | ||||
-rw-r--r-- | include/linux/dcookies.h | 15 |
4 files changed, 37 insertions, 48 deletions
diff --git a/arch/powerpc/oprofile/cell/spu_task_sync.c b/arch/powerpc/oprofile/cell/spu_task_sync.c index 4a890cb42b98..257b13cb18af 100644 --- a/arch/powerpc/oprofile/cell/spu_task_sync.c +++ b/arch/powerpc/oprofile/cell/spu_task_sync.c | |||
@@ -198,14 +198,13 @@ out: | |||
198 | * dcookie user still being registered (namely, the reader | 198 | * dcookie user still being registered (namely, the reader |
199 | * of the event buffer). | 199 | * of the event buffer). |
200 | */ | 200 | */ |
201 | static inline unsigned long fast_get_dcookie(struct dentry *dentry, | 201 | static inline unsigned long fast_get_dcookie(struct path *path) |
202 | struct vfsmount *vfsmnt) | ||
203 | { | 202 | { |
204 | unsigned long cookie; | 203 | unsigned long cookie; |
205 | 204 | ||
206 | if (dentry->d_cookie) | 205 | if (path->dentry->d_cookie) |
207 | return (unsigned long)dentry; | 206 | return (unsigned long)path->dentry; |
208 | get_dcookie(dentry, vfsmnt, &cookie); | 207 | get_dcookie(path, &cookie); |
209 | return cookie; | 208 | return cookie; |
210 | } | 209 | } |
211 | 210 | ||
@@ -240,8 +239,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp, | |||
240 | continue; | 239 | continue; |
241 | if (!(vma->vm_flags & VM_EXECUTABLE)) | 240 | if (!(vma->vm_flags & VM_EXECUTABLE)) |
242 | continue; | 241 | continue; |
243 | app_cookie = fast_get_dcookie(vma->vm_file->f_dentry, | 242 | app_cookie = fast_get_dcookie(&vma->vm_file->f_path); |
244 | vma->vm_file->f_vfsmnt); | ||
245 | pr_debug("got dcookie for %s\n", | 243 | pr_debug("got dcookie for %s\n", |
246 | vma->vm_file->f_dentry->d_name.name); | 244 | vma->vm_file->f_dentry->d_name.name); |
247 | app = vma->vm_file; | 245 | app = vma->vm_file; |
@@ -262,8 +260,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp, | |||
262 | break; | 260 | break; |
263 | } | 261 | } |
264 | 262 | ||
265 | *spu_bin_dcookie = fast_get_dcookie(vma->vm_file->f_dentry, | 263 | *spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path); |
266 | vma->vm_file->f_vfsmnt); | ||
267 | pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name); | 264 | pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name); |
268 | 265 | ||
269 | up_read(&mm->mmap_sem); | 266 | up_read(&mm->mmap_sem); |
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index 8134c7e198a5..b07ba2a14119 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c | |||
@@ -187,23 +187,22 @@ void sync_stop(void) | |||
187 | end_sync(); | 187 | end_sync(); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | /* Optimisation. We can manage without taking the dcookie sem | 191 | /* Optimisation. We can manage without taking the dcookie sem |
192 | * because we cannot reach this code without at least one | 192 | * because we cannot reach this code without at least one |
193 | * dcookie user still being registered (namely, the reader | 193 | * dcookie user still being registered (namely, the reader |
194 | * of the event buffer). */ | 194 | * of the event buffer). */ |
195 | static inline unsigned long fast_get_dcookie(struct dentry * dentry, | 195 | static inline unsigned long fast_get_dcookie(struct path *path) |
196 | struct vfsmount * vfsmnt) | ||
197 | { | 196 | { |
198 | unsigned long cookie; | 197 | unsigned long cookie; |
199 | 198 | ||
200 | if (dentry->d_cookie) | 199 | if (path->dentry->d_cookie) |
201 | return (unsigned long)dentry; | 200 | return (unsigned long)path->dentry; |
202 | get_dcookie(dentry, vfsmnt, &cookie); | 201 | get_dcookie(path, &cookie); |
203 | return cookie; | 202 | return cookie; |
204 | } | 203 | } |
205 | 204 | ||
206 | 205 | ||
207 | /* Look up the dcookie for the task's first VM_EXECUTABLE mapping, | 206 | /* Look up the dcookie for the task's first VM_EXECUTABLE mapping, |
208 | * which corresponds loosely to "application name". This is | 207 | * which corresponds loosely to "application name". This is |
209 | * not strictly necessary but allows oprofile to associate | 208 | * not strictly necessary but allows oprofile to associate |
@@ -222,8 +221,7 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm) | |||
222 | continue; | 221 | continue; |
223 | if (!(vma->vm_flags & VM_EXECUTABLE)) | 222 | if (!(vma->vm_flags & VM_EXECUTABLE)) |
224 | continue; | 223 | continue; |
225 | cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, | 224 | cookie = fast_get_dcookie(&vma->vm_file->f_path); |
226 | vma->vm_file->f_path.mnt); | ||
227 | break; | 225 | break; |
228 | } | 226 | } |
229 | 227 | ||
@@ -248,8 +246,7 @@ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, o | |||
248 | continue; | 246 | continue; |
249 | 247 | ||
250 | if (vma->vm_file) { | 248 | if (vma->vm_file) { |
251 | cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, | 249 | cookie = fast_get_dcookie(&vma->vm_file->f_path); |
252 | vma->vm_file->f_path.mnt); | ||
253 | *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - | 250 | *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - |
254 | vma->vm_start; | 251 | vma->vm_start; |
255 | } else { | 252 | } else { |
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 | */ |
33 | struct dcookie_struct { | 34 | struct 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 */ |
52 | static inline unsigned long dcookie_value(struct dcookie_struct * dcs) | 52 | static 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 | ||
92 | static struct dcookie_struct * alloc_dcookie(struct dentry * dentry, | 92 | static 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 | */ |
112 | int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, | 110 | int 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 | ||
255 | static void free_dcookie(struct dcookie_struct * dcs) | 252 | static 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 | ||
diff --git a/include/linux/dcookies.h b/include/linux/dcookies.h index 98c69ab80c84..24c806f12a6c 100644 --- a/include/linux/dcookies.h +++ b/include/linux/dcookies.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #ifdef CONFIG_PROFILING | 13 | #ifdef CONFIG_PROFILING |
14 | 14 | ||
15 | #include <linux/dcache.h> | 15 | #include <linux/dcache.h> |
16 | #include <linux/path.h> | ||
16 | #include <linux/types.h> | 17 | #include <linux/types.h> |
17 | 18 | ||
18 | struct dcookie_user; | 19 | struct dcookie_user; |
@@ -43,8 +44,7 @@ void dcookie_unregister(struct dcookie_user * user); | |||
43 | * | 44 | * |
44 | * Returns 0 on success, with *cookie filled in | 45 | * Returns 0 on success, with *cookie filled in |
45 | */ | 46 | */ |
46 | int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, | 47 | int get_dcookie(struct path *path, unsigned long *cookie); |
47 | unsigned long * cookie); | ||
48 | 48 | ||
49 | #else | 49 | #else |
50 | 50 | ||
@@ -57,13 +57,12 @@ static inline void dcookie_unregister(struct dcookie_user * user) | |||
57 | { | 57 | { |
58 | return; | 58 | return; |
59 | } | 59 | } |
60 | 60 | ||
61 | static inline int get_dcookie(struct dentry * dentry, | 61 | static inline int get_dcookie(struct path *path, unsigned long *cookie) |
62 | struct vfsmount * vfsmnt, unsigned long * cookie) | ||
63 | { | 62 | { |
64 | return -ENOSYS; | 63 | return -ENOSYS; |
65 | } | 64 | } |
66 | 65 | ||
67 | #endif /* CONFIG_PROFILING */ | 66 | #endif /* CONFIG_PROFILING */ |
68 | 67 | ||
69 | #endif /* DCOOKIES_H */ | 68 | #endif /* DCOOKIES_H */ |