mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
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>
This commit is contained in:
parent
3dcd25f37c
commit
448678a0f3
4 changed files with 37 additions and 48 deletions
|
@ -198,14 +198,13 @@ out:
|
||||||
* dcookie user still being registered (namely, the reader
|
* dcookie user still being registered (namely, the reader
|
||||||
* of the event buffer).
|
* of the event buffer).
|
||||||
*/
|
*/
|
||||||
static inline unsigned long fast_get_dcookie(struct dentry *dentry,
|
static inline unsigned long fast_get_dcookie(struct path *path)
|
||||||
struct vfsmount *vfsmnt)
|
|
||||||
{
|
{
|
||||||
unsigned long cookie;
|
unsigned long cookie;
|
||||||
|
|
||||||
if (dentry->d_cookie)
|
if (path->dentry->d_cookie)
|
||||||
return (unsigned long)dentry;
|
return (unsigned long)path->dentry;
|
||||||
get_dcookie(dentry, vfsmnt, &cookie);
|
get_dcookie(path, &cookie);
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,8 +239,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
|
||||||
continue;
|
continue;
|
||||||
if (!(vma->vm_flags & VM_EXECUTABLE))
|
if (!(vma->vm_flags & VM_EXECUTABLE))
|
||||||
continue;
|
continue;
|
||||||
app_cookie = fast_get_dcookie(vma->vm_file->f_dentry,
|
app_cookie = fast_get_dcookie(&vma->vm_file->f_path);
|
||||||
vma->vm_file->f_vfsmnt);
|
|
||||||
pr_debug("got dcookie for %s\n",
|
pr_debug("got dcookie for %s\n",
|
||||||
vma->vm_file->f_dentry->d_name.name);
|
vma->vm_file->f_dentry->d_name.name);
|
||||||
app = vma->vm_file;
|
app = vma->vm_file;
|
||||||
|
@ -262,8 +260,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*spu_bin_dcookie = fast_get_dcookie(vma->vm_file->f_dentry,
|
*spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path);
|
||||||
vma->vm_file->f_vfsmnt);
|
|
||||||
pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name);
|
pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name);
|
||||||
|
|
||||||
up_read(&mm->mmap_sem);
|
up_read(&mm->mmap_sem);
|
||||||
|
|
|
@ -187,23 +187,22 @@ void sync_stop(void)
|
||||||
end_sync();
|
end_sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Optimisation. We can manage without taking the dcookie sem
|
/* Optimisation. We can manage without taking the dcookie sem
|
||||||
* because we cannot reach this code without at least one
|
* because we cannot reach this code without at least one
|
||||||
* dcookie user still being registered (namely, the reader
|
* dcookie user still being registered (namely, the reader
|
||||||
* of the event buffer). */
|
* of the event buffer). */
|
||||||
static inline unsigned long fast_get_dcookie(struct dentry * dentry,
|
static inline unsigned long fast_get_dcookie(struct path *path)
|
||||||
struct vfsmount * vfsmnt)
|
|
||||||
{
|
{
|
||||||
unsigned long cookie;
|
unsigned long cookie;
|
||||||
|
|
||||||
if (dentry->d_cookie)
|
if (path->dentry->d_cookie)
|
||||||
return (unsigned long)dentry;
|
return (unsigned long)path->dentry;
|
||||||
get_dcookie(dentry, vfsmnt, &cookie);
|
get_dcookie(path, &cookie);
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Look up the dcookie for the task's first VM_EXECUTABLE mapping,
|
/* Look up the dcookie for the task's first VM_EXECUTABLE mapping,
|
||||||
* which corresponds loosely to "application name". This is
|
* which corresponds loosely to "application name". This is
|
||||||
* not strictly necessary but allows oprofile to associate
|
* not strictly necessary but allows oprofile to associate
|
||||||
|
@ -222,8 +221,7 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm)
|
||||||
continue;
|
continue;
|
||||||
if (!(vma->vm_flags & VM_EXECUTABLE))
|
if (!(vma->vm_flags & VM_EXECUTABLE))
|
||||||
continue;
|
continue;
|
||||||
cookie = fast_get_dcookie(vma->vm_file->f_path.dentry,
|
cookie = fast_get_dcookie(&vma->vm_file->f_path);
|
||||||
vma->vm_file->f_path.mnt);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,8 +246,7 @@ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, o
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (vma->vm_file) {
|
if (vma->vm_file) {
|
||||||
cookie = fast_get_dcookie(vma->vm_file->f_path.dentry,
|
cookie = fast_get_dcookie(&vma->vm_file->f_path);
|
||||||
vma->vm_file->f_path.mnt);
|
|
||||||
*offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
|
*offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
|
||||||
vma->vm_start;
|
vma->vm_start;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/dcookies.h>
|
#include <linux/dcookies.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/path.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
|
|
||||||
/* The dcookies are allocated from a kmem_cache and
|
/* The dcookies are allocated from a kmem_cache and
|
||||||
|
@ -31,8 +32,7 @@
|
||||||
* code here is particularly performance critical
|
* code here is particularly performance critical
|
||||||
*/
|
*/
|
||||||
struct dcookie_struct {
|
struct dcookie_struct {
|
||||||
struct dentry * dentry;
|
struct path path;
|
||||||
struct vfsmount * vfsmnt;
|
|
||||||
struct list_head hash_list;
|
struct list_head hash_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ static inline int is_live(void)
|
||||||
/* The dentry is locked, its address will do for the cookie */
|
/* The dentry is locked, its address will do for the cookie */
|
||||||
static inline unsigned long dcookie_value(struct dcookie_struct * dcs)
|
static inline unsigned long dcookie_value(struct dcookie_struct * dcs)
|
||||||
{
|
{
|
||||||
return (unsigned long)dcs->dentry;
|
return (unsigned long)dcs->path.dentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,19 +89,17 @@ static void hash_dcookie(struct dcookie_struct * dcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct dcookie_struct * alloc_dcookie(struct dentry * dentry,
|
static struct dcookie_struct *alloc_dcookie(struct path *path)
|
||||||
struct vfsmount * vfsmnt)
|
|
||||||
{
|
{
|
||||||
struct dcookie_struct * dcs = kmem_cache_alloc(dcookie_cache, GFP_KERNEL);
|
struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache,
|
||||||
|
GFP_KERNEL);
|
||||||
if (!dcs)
|
if (!dcs)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dentry->d_cookie = dcs;
|
path->dentry->d_cookie = dcs;
|
||||||
|
dcs->path = *path;
|
||||||
dcs->dentry = dget(dentry);
|
path_get(path);
|
||||||
dcs->vfsmnt = mntget(vfsmnt);
|
|
||||||
hash_dcookie(dcs);
|
hash_dcookie(dcs);
|
||||||
|
|
||||||
return dcs;
|
return dcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +107,7 @@ static struct dcookie_struct * alloc_dcookie(struct dentry * dentry,
|
||||||
/* This is the main kernel-side routine that retrieves the cookie
|
/* This is the main kernel-side routine that retrieves the cookie
|
||||||
* value for a dentry/vfsmnt pair.
|
* value for a dentry/vfsmnt pair.
|
||||||
*/
|
*/
|
||||||
int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
|
int get_dcookie(struct path *path, unsigned long *cookie)
|
||||||
unsigned long * cookie)
|
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
struct dcookie_struct * dcs;
|
struct dcookie_struct * dcs;
|
||||||
|
@ -122,10 +119,10 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcs = dentry->d_cookie;
|
dcs = path->dentry->d_cookie;
|
||||||
|
|
||||||
if (!dcs)
|
if (!dcs)
|
||||||
dcs = alloc_dcookie(dentry, vfsmnt);
|
dcs = alloc_dcookie(path);
|
||||||
|
|
||||||
if (!dcs) {
|
if (!dcs) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
@ -174,7 +171,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* FIXME: (deleted) ? */
|
/* FIXME: (deleted) ? */
|
||||||
path = d_path(dcs->dentry, dcs->vfsmnt, kbuf, PAGE_SIZE);
|
path = d_path(dcs->path.dentry, dcs->path.mnt, kbuf, PAGE_SIZE);
|
||||||
|
|
||||||
if (IS_ERR(path)) {
|
if (IS_ERR(path)) {
|
||||||
err = PTR_ERR(path);
|
err = PTR_ERR(path);
|
||||||
|
@ -254,9 +251,8 @@ out_kmem:
|
||||||
|
|
||||||
static void free_dcookie(struct dcookie_struct * dcs)
|
static void free_dcookie(struct dcookie_struct * dcs)
|
||||||
{
|
{
|
||||||
dcs->dentry->d_cookie = NULL;
|
dcs->path.dentry->d_cookie = NULL;
|
||||||
dput(dcs->dentry);
|
path_put(&dcs->path);
|
||||||
mntput(dcs->vfsmnt);
|
|
||||||
kmem_cache_free(dcookie_cache, dcs);
|
kmem_cache_free(dcookie_cache, dcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#ifdef CONFIG_PROFILING
|
#ifdef CONFIG_PROFILING
|
||||||
|
|
||||||
#include <linux/dcache.h>
|
#include <linux/dcache.h>
|
||||||
|
#include <linux/path.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
struct dcookie_user;
|
struct dcookie_user;
|
||||||
|
@ -43,8 +44,7 @@ void dcookie_unregister(struct dcookie_user * user);
|
||||||
*
|
*
|
||||||
* Returns 0 on success, with *cookie filled in
|
* Returns 0 on success, with *cookie filled in
|
||||||
*/
|
*/
|
||||||
int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
|
int get_dcookie(struct path *path, unsigned long *cookie);
|
||||||
unsigned long * cookie);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -57,13 +57,12 @@ static inline void dcookie_unregister(struct dcookie_user * user)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_dcookie(struct dentry * dentry,
|
static inline int get_dcookie(struct path *path, unsigned long *cookie)
|
||||||
struct vfsmount * vfsmnt, unsigned long * cookie)
|
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PROFILING */
|
#endif /* CONFIG_PROFILING */
|
||||||
|
|
||||||
#endif /* DCOOKIES_H */
|
#endif /* DCOOKIES_H */
|
||||||
|
|
Loading…
Reference in a new issue