Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jan Blunck and committed by
Linus Torvalds
448678a0 3dcd25f3

+37 -48
+6 -9
arch/powerpc/oprofile/cell/spu_task_sync.c
··· 198 198 * dcookie user still being registered (namely, the reader 199 199 * of the event buffer). 200 200 */ 201 - static inline unsigned long fast_get_dcookie(struct dentry *dentry, 202 - struct vfsmount *vfsmnt) 201 + static inline unsigned long fast_get_dcookie(struct path *path) 203 202 { 204 203 unsigned long cookie; 205 204 206 - if (dentry->d_cookie) 207 - return (unsigned long)dentry; 208 - get_dcookie(dentry, vfsmnt, &cookie); 205 + if (path->dentry->d_cookie) 206 + return (unsigned long)path->dentry; 207 + get_dcookie(path, &cookie); 209 208 return cookie; 210 209 } 211 210 ··· 239 240 continue; 240 241 if (!(vma->vm_flags & VM_EXECUTABLE)) 241 242 continue; 242 - app_cookie = fast_get_dcookie(vma->vm_file->f_dentry, 243 - vma->vm_file->f_vfsmnt); 243 + app_cookie = fast_get_dcookie(&vma->vm_file->f_path); 244 244 pr_debug("got dcookie for %s\n", 245 245 vma->vm_file->f_dentry->d_name.name); 246 246 app = vma->vm_file; ··· 260 262 break; 261 263 } 262 264 263 - *spu_bin_dcookie = fast_get_dcookie(vma->vm_file->f_dentry, 264 - vma->vm_file->f_vfsmnt); 265 + *spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path); 265 266 pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name); 266 267 267 268 up_read(&mm->mmap_sem);
+9 -12
drivers/oprofile/buffer_sync.c
··· 187 187 end_sync(); 188 188 } 189 189 190 - 190 + 191 191 /* Optimisation. We can manage without taking the dcookie sem 192 192 * because we cannot reach this code without at least one 193 193 * dcookie user still being registered (namely, the reader 194 194 * of the event buffer). */ 195 - static inline unsigned long fast_get_dcookie(struct dentry * dentry, 196 - struct vfsmount * vfsmnt) 195 + static inline unsigned long fast_get_dcookie(struct path *path) 197 196 { 198 197 unsigned long cookie; 199 - 200 - if (dentry->d_cookie) 201 - return (unsigned long)dentry; 202 - get_dcookie(dentry, vfsmnt, &cookie); 198 + 199 + if (path->dentry->d_cookie) 200 + return (unsigned long)path->dentry; 201 + get_dcookie(path, &cookie); 203 202 return cookie; 204 203 } 205 204 206 - 205 + 207 206 /* Look up the dcookie for the task's first VM_EXECUTABLE mapping, 208 207 * which corresponds loosely to "application name". This is 209 208 * not strictly necessary but allows oprofile to associate ··· 221 222 continue; 222 223 if (!(vma->vm_flags & VM_EXECUTABLE)) 223 224 continue; 224 - cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, 225 - vma->vm_file->f_path.mnt); 225 + cookie = fast_get_dcookie(&vma->vm_file->f_path); 226 226 break; 227 227 } 228 228 ··· 246 248 continue; 247 249 248 250 if (vma->vm_file) { 249 - cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, 250 - vma->vm_file->f_path.mnt); 251 + cookie = fast_get_dcookie(&vma->vm_file->f_path); 251 252 *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - 252 253 vma->vm_start; 253 254 } else {
+15 -19
fs/dcookies.c
··· 24 24 #include <linux/errno.h> 25 25 #include <linux/dcookies.h> 26 26 #include <linux/mutex.h> 27 + #include <linux/path.h> 27 28 #include <asm/uaccess.h> 28 29 29 30 /* The dcookies are allocated from a kmem_cache and ··· 32 31 * code here is particularly performance critical 33 32 */ 34 33 struct dcookie_struct { 35 - struct dentry * dentry; 36 - struct vfsmount * vfsmnt; 34 + struct path path; 37 35 struct list_head hash_list; 38 36 }; 39 37 ··· 51 51 /* The dentry is locked, its address will do for the cookie */ 52 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 89 } 90 90 91 91 92 - static struct dcookie_struct * alloc_dcookie(struct dentry * dentry, 93 - struct vfsmount * vfsmnt) 92 + static struct dcookie_struct *alloc_dcookie(struct path *path) 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 96 if (!dcs) 97 97 return NULL; 98 98 99 - dentry->d_cookie = dcs; 100 - 101 - dcs->dentry = dget(dentry); 102 - dcs->vfsmnt = mntget(vfsmnt); 99 + path->dentry->d_cookie = dcs; 100 + dcs->path = *path; 101 + path_get(path); 103 102 hash_dcookie(dcs); 104 - 105 103 return dcs; 106 104 } 107 105 ··· 107 109 /* This is the main kernel-side routine that retrieves the cookie 108 110 * value for a dentry/vfsmnt pair. 109 111 */ 110 - int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, 111 - unsigned long * cookie) 112 + int get_dcookie(struct path *path, unsigned long *cookie) 112 113 { 113 114 int err = 0; 114 115 struct dcookie_struct * dcs; ··· 119 122 goto out; 120 123 } 121 124 122 - dcs = dentry->d_cookie; 125 + dcs = path->dentry->d_cookie; 123 126 124 127 if (!dcs) 125 - dcs = alloc_dcookie(dentry, vfsmnt); 128 + dcs = alloc_dcookie(path); 126 129 127 130 if (!dcs) { 128 131 err = -ENOMEM; ··· 171 174 goto out; 172 175 173 176 /* FIXME: (deleted) ? */ 174 - path = d_path(dcs->dentry, dcs->vfsmnt, kbuf, PAGE_SIZE); 177 + path = d_path(dcs->path.dentry, dcs->path.mnt, kbuf, PAGE_SIZE); 175 178 176 179 if (IS_ERR(path)) { 177 180 err = PTR_ERR(path); ··· 251 254 252 255 static void free_dcookie(struct dcookie_struct * dcs) 253 256 { 254 - dcs->dentry->d_cookie = NULL; 255 - dput(dcs->dentry); 256 - mntput(dcs->vfsmnt); 257 + dcs->path.dentry->d_cookie = NULL; 258 + path_put(&dcs->path); 257 259 kmem_cache_free(dcookie_cache, dcs); 258 260 } 259 261
+7 -8
include/linux/dcookies.h
··· 13 13 #ifdef CONFIG_PROFILING 14 14 15 15 #include <linux/dcache.h> 16 + #include <linux/path.h> 16 17 #include <linux/types.h> 17 18 18 19 struct dcookie_user; ··· 44 43 * 45 44 * Returns 0 on success, with *cookie filled in 46 45 */ 47 - int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, 48 - unsigned long * cookie); 46 + int get_dcookie(struct path *path, unsigned long *cookie); 49 47 50 48 #else 51 49 ··· 57 57 { 58 58 return; 59 59 } 60 - 61 - static inline int get_dcookie(struct dentry * dentry, 62 - struct vfsmount * vfsmnt, unsigned long * cookie) 60 + 61 + static inline int get_dcookie(struct path *path, unsigned long *cookie) 63 62 { 64 63 return -ENOSYS; 65 - } 66 - 64 + } 65 + 67 66 #endif /* CONFIG_PROFILING */ 68 - 67 + 69 68 #endif /* DCOOKIES_H */