2005-05-25 15:52:21

by Miklos Szeredi

[permalink] [raw]
Subject: [PATCH] dcookies.c: use proper refcounting functions

Dcookies shouldn't play with the internals of dentry and vfsmnt
refcounting. It defeats grepping, and is prone to break if
implementation details change.

In addition the function doesn't even seem to be performance critical:
it calls kmem_cache_alloc().

Signed-off-by: Miklos Szeredi <[email protected]>

Index: linux/fs/dcookies.c
===================================================================
--- linux.orig/fs/dcookies.c 2004-12-24 22:33:48.000000000 +0100
+++ linux/fs/dcookies.c 2005-05-25 17:14:08.000000000 +0200
@@ -94,12 +94,10 @@ static struct dcookie_struct * alloc_dco
if (!dcs)
return NULL;

- atomic_inc(&dentry->d_count);
- atomic_inc(&vfsmnt->mnt_count);
dentry->d_cookie = dcs;

- dcs->dentry = dentry;
- dcs->vfsmnt = vfsmnt;
+ dcs->dentry = dget(dentry);
+ dcs->vfsmnt = mntget(vfsmnt);
hash_dcookie(dcs);

return dcs;