Skip to contentSkip to conversation

dcache.{c,h} cleanup

PATCH In review Dan Aloni 2 participants 3 messages May 31, 2002 – Jun 3, 2002 VFS

lore
Share & tools
lore

Dan Aloni

author
#0 lore raw

PATCH 1/1 dcache.{c,h} cleanup

include/linux/dcache.h:
+ change __inline__ to inline
+ use list_del_init() instead of list_del() + INIT_LIST_HEAD()
+ remove #define for obsolete shrink_dcache()
+ remove obsolete forward declaration of struct zone_struct.

fs/dcache.c:
+ use d_unhashed() instead of list_empty(&dentry->d_hash)
+ document d_free().
+ renamed dentry_iput() to d_iput(), for naming and prefix consistency.
+ added d_release() in order to refactor dput() and prune_one_dentry().
+ modified dput() to use d_release().
+ modified prune_one_dentry() to use d_release().

include/linux/dcache.h +10 -13
@@ -44,19 +44,19 @@
 #define init_name_hash()		0
 
 /* partial hash update function. Assume roughly 4 bits per character */
-static __inline__ unsigned long partial_name_hash(unsigned long c, unsigned long prevhash)
+static inline unsigned long partial_name_hash(unsigned long c, unsigned long prevhash)
 {
 	return (prevhash + (c << 4) + (c >> 4)) * 11;
 }
 
 /* Finally: cut down the number of bits to a int value (and try to avoid losing bits) */
-static __inline__ unsigned long end_name_hash(unsigned long hash)
+static inline unsigned long end_name_hash(unsigned long hash)
 {
 	return (unsigned int) hash;
 }
 
 /* Compute the hash for a name string. */
-static __inline__ unsigned int full_name_hash(const unsigned char * name, unsigned int len)
+static inline unsigned int full_name_hash(const unsigned char * name, unsigned int len)
 {
 	unsigned long hash = init_name_hash();
 	while (len--)
@@ -153,15 +153,14 @@
  * timeouts or autofs deletes).
  */
 
-static __inline__ void d_drop(struct dentry * dentry)
+static inline void d_drop(struct dentry * dentry)
 {
 	spin_lock(&dcache_lock);
-	list_del(&dentry->d_hash);
-	INIT_LIST_HEAD(&dentry->d_hash);
+	list_del_init(&dentry->d_hash);
 	spin_unlock(&dcache_lock);
 }
 
-static __inline__ int dname_external(struct dentry *d)
+static inline int dname_external(struct dentry *d)
 {
 	return d->d_name.name != d->d_iname; 
 }
@@ -181,8 +180,6 @@
 extern void shrink_dcache_anon(struct list_head *);
 extern int d_invalidate(struct dentry *);
 
-#define shrink_dcache() prune_dcache(0)
-struct zone_struct;
 /* dcache memory management */
 extern int shrink_dcache_memory(int, unsigned int);
 extern void prune_dcache(int);
@@ -220,7 +217,7 @@
  * The entry was actually filled in earlier during d_alloc().
  */
  
-static __inline__ void d_add(struct dentry * entry, struct inode * inode)
+static inline void d_add(struct dentry * entry, struct inode * inode)
 {
 	d_instantiate(entry, inode);
 	d_rehash(entry);
@@ -254,7 +251,7 @@
  *	and call dget_locked() instead of dget().
  */
  
-static __inline__ struct dentry * dget(struct dentry *dentry)
+static inline struct dentry * dget(struct dentry *dentry)
 {
 	if (dentry) {
 		if (!atomic_read(&dentry->d_count))
@@ -273,14 +270,14 @@
  *	Returns true if the dentry passed is not currently hashed.
  */
  
-static __inline__ int d_unhashed(struct dentry *dentry)
+static inline int d_unhashed(struct dentry *dentry)
 {
 	return list_empty(&dentry->d_hash);
 }
 
 extern void dput(struct dentry *);
 
-static __inline__ int d_mountpoint(struct dentry *dentry)
+static inline int d_mountpoint(struct dentry *dentry)
 {
 	return dentry->d_mounted;
 }
fs/dcache.c +53 -31

172 lines not on this page · raw message

Signature · 2 lines
Dan Aloni
[email protected]
author
#1 lore raw
Quoted 9 lines · Maneesh Soni
Quoted 1 line · Dan Aloni

+ use d_unhashed() instead of list_empty(&dentry->d_hash)

There are few more list_empty(...->d_hash)s left

fs/intermezzo/journal.c presto_path

fs/libfs.c              dcache_dir_lseek  
fs/libfs.c              dcache_readdir    
kernel/exit.c           __unhash_process  

I'll send a patch to rusty.

Quoted 10 lines

fs/dcache.c line 171

Quoted 9 lines
fs/dcache.c +2 -2
 	if (dentry->d_op && dentry->d_op->d_delete) {
 		if (dentry->d_op->d_delete(dentry))
-			goto unhash_it;
+			goto kill_it;
 	}
 	/* Unreachable? Get rid of it */
-	if (list_empty(&dentry->d_hash))
+	if (d_unhashed(dentry))
 		goto kill_it;
		^^^^^^^^^^^^^
Quoted 2 lines

This will do list_del_init on a already unhashed dentry.

I am awake of this. From what I've seen, a second list_del_init is a no-op, and this one-liner doesn't yell 'refactor me'.

Quoted 5 lines
Quoted 5 lines
fs/dcache.c +3 -2
-unhash_it:
-	list_del_init(&dentry->d_hash);
+kill_it:
+	parent = d_release(dentry);
+	if (dentry == parent)
Signature · 2 lines
Dan Aloni
[email protected]
#2 lore raw
In reply to Dan Aloni
Quoted 1 line · On Fri, 31 May 2002 11:28:06 +0300 Dan Aloni <[email protected]> wrote:

include/linux/dcache.h:

You should break these down to one per file, and send them to the VFS maintainer.

Rusty.

Signature · 2 lines
   there are those who do and those who hang on and you don't see too
   many doers quoting their contemporaries.  -- Larry McVoy