2007-08-10 14:44:20

by Andreas Gruenbacher

[permalink] [raw]
Subject: [patch 3/4] Introduce pathget

This is the symmetric operation to pathput.

Signed-off-by: Jan Blunck <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>

---
fs/namei.c | 9 +++------
include/linux/namei.h | 8 --------
2 files changed, 3 insertions(+), 14 deletions(-)

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1003,14 +1003,12 @@ static int fastcall link_path_walk(const
int result;

/* make sure the stuff we saved doesn't go away */
- dget(save.lookup.path.dentry);
- mntget(save.lookup.path.mnt);
+ pathget(&save.lookup.path);

result = __link_path_walk(name, nd);
if (result == -ESTALE) {
*nd = save;
- dget(nd->lookup.path.dentry);
- mntget(nd->lookup.path.mnt);
+ pathget(&nd->lookup.path);
nd->lookup.flags |= LOOKUP_REVAL;
result = __link_path_walk(name, nd);
}
@@ -1140,8 +1138,7 @@ static int fastcall do_path_lookup(int d
if (retval)
goto fput_fail;

- mntget(nd->lookup.path.mnt);
- dget(nd->lookup.path.dentry);
+ pathget(&nd->lookup.path);

fput_light(file, fput_needed);
}
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -102,6 +102,14 @@ static inline char *nd_get_link(struct n
return nd->saved_names[nd->depth];
}

+static inline struct path *pathget(struct path *path)
+{
+ mntget(path->mnt);
+ dget(path->dentry);
+
+ return path;
+}
+
static inline void pathput(struct path *path)
{
dput(path->dentry);


2007-08-29 19:09:38

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [patch 3/4] Introduce pathget

On Fri, Aug 10, 2007 at 04:22:11PM +0200, Andreas Gruenbacher wrote:
> This is the symmetric operation to pathput.

The primitive looks fine to me, but it needs a kerneldoc comment describing
it. Also I think both this and pathput should not actually be inline.