patch-2.1.44 linux/include/linux/dalloc.h

Next file: linux/include/linux/ext2_fs.h
Previous file: linux/include/linux/console_struct.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.43/linux/include/linux/dalloc.h linux/include/linux/dalloc.h
@@ -9,16 +9,19 @@
  * <schoebel@informatik.uni-stuttgart.de>.
  */
 
-#define D_MAXLEN   1024
+#define D_MAXLEN 1024
 
 /* public flags for d_add() */
-#define D_NORMAL     0
-#define D_BASKET     1 /* put into basket (deleted/unref'd files) */
-#define D_DUPLICATE  2 /* allow duplicate entries */
-#define D_NOCHECKDUP 4 /* no not check for duplicates */
-
-/* public flags for d_flag */
-#define D_PRELOADED 8
+#define D_NORMAL	  0
+#define D_BASKET	  1 /* put into basket (deleted/unref'd files) */
+#define D_DUPLICATE	  2 /* allow duplicate entries */
+#define D_NOCHECKDUP	  4 /* no not check for duplicates */
+#define D_NEGATIVE	  8 /* negative entry */
+#define D_PRELOADED	 16
+#define D_DIR		 32 /* directory entry - look out for allocation issues */
+#define D_HASHED	 64
+#define D_ZOMBIE	128
+#define D_INC_DDIR	512
 
 /* public flags for d_del() */
 #define D_REMOVE         0
@@ -26,53 +29,78 @@
 
 #define IS_ROOT(x) ((x) == (x)->d_parent)
 
+/* "quick string" -- I introduced this to shorten the parameter list
+ * of many routines. Think of it as a (str,stlen,hash) pair.
+ * Storing the len instead of doing strlen() very often is performance
+ * critical.
+ */
+struct qstr {
+	const unsigned char * name;
+	int len, hash;
+};
+
+/* Name hashing routines. Initial hash value */
+#define init_name_hash()		0
+
+/* partial hash update function. Assume roughly 4 bits per character */
+static inline unsigned long partial_name_hash(unsigned char c, unsigned long prevhash)
+{
+	prevhash = (prevhash << 4) | (prevhash >> (8*sizeof(unsigned long)-4));
+	return prevhash ^ c;
+}
+
+/* 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)
+{
+	if (sizeof(hash) > sizeof(unsigned int))
+		hash += hash >> 4*sizeof(hash);
+	return (unsigned int) hash;
+}
+
 struct dentry {
-	union {
-		struct inode  * d_inode;  /* Where the name belongs to */
-		unsigned long d_ino;      /* for preliminary entries */
-	} u;
-	struct dentry * d_parent; /* parent directory */
-	struct dentry * d_next;   /* hardlink aliasname / empty list */
-	struct dentry * d_prev;   /* hardlink aliasname */
+	unsigned int d_flag;
+	unsigned int d_count;
+	struct inode  * d_inode;	/* Where the name belongs to */
+	struct dentry * d_parent;	/* parent directory */
+	struct dentry * d_mounts;	/* mount information */
+	struct dentry * d_covers;
+	struct dentry * d_next;		/* hardlink aliasname / empty list */
+	struct dentry * d_prev;		/* hardlink aliasname */
 	struct dentry * d_hash_next;
 	struct dentry * d_hash_prev;
 	struct dentry * d_basket_next;
 	struct dentry * d_basket_prev;
-	short d_len;              /* set by dalloc() */
-	short d_flag;
-	char d_name[D_MAXLEN];
+	struct qstr d_name;
 };
 
-/* "quick string" -- I introduced this to shorten the parameter list
- * of many routines. Think of it as a (str,stlen) pair.
- * Storing the len instead of doing strlen() very often is performance
- * critical.
+extern struct dentry * the_root;
+
+/*
+ * These are the low-level FS interfaces to the dcache..
  */
-struct qstr {
-	const char * name;
-	int len;
-};
+extern void d_instantiate(struct dentry *, struct inode *, int);
+extern void d_delete(struct dentry *);
 
-extern struct dentry * the_root;
 
 /* Note that all these routines must be called with vfs_lock() held */
 
 /* get inode, if necessary retrieve it with iget() */
 extern blocking struct inode * d_inode(struct dentry ** changing_entry);
 
-/* allocate proper space for the len */
-extern struct dentry * d_alloc(struct dentry * parent, int len, int isdir);
+/* allocate/de-allocate */
+extern void d_free(struct dentry *);
+extern struct dentry * d_alloc(struct dentry * parent, struct qstr *name, int isdir);
 
-/* only used once at mount_root() */
+/* only used at mount-time */
 extern blocking
-struct dentry * d_alloc_root(struct inode * root_inode);
+struct dentry * d_alloc_root(struct inode * root_inode, struct dentry * old_root);
 
-/* d_inode is connected with inode, and d_name is copied from ininame.
- * either of them may be NULL, but when ininame is NULL, dname must be
- * set by the caller prior to calling this. */
+/*
+ * This adds the entry to the hash queues and initializes "d_inode".
+ * The entry was actually filled in earlier during "d_alloc()"
+ */
 extern blocking
-void d_add(struct dentry * entry, struct inode * inode,
-	   struct qstr * ininame, int flags);
+void d_add(struct dentry * entry, struct inode * inode, int flags);
 
 /* combination of d_alloc() and d_add(), less lookup overhead */
 extern blocking 
@@ -86,17 +114,32 @@
 
 /* used for rename() and baskets */
 extern blocking 
-void d_move(struct dentry * entry, struct inode * newdir,
-	    struct qstr * newname, struct qstr * newapp);
+void d_move(struct dentry * entry, struct dentry * newparent, struct qstr * newname);
 
 /* appendix may either be NULL or be used for transname suffixes */
-extern struct dentry * d_lookup(struct inode * dir, struct qstr * name,
-				struct qstr * appendix);
+extern struct dentry * d_lookup(struct dentry * dir, struct qstr * name);
 
 /* write full pathname into buffer and return length */
-extern int d_path(struct dentry * entry, struct inode * chroot, char * buf);
+extern int d_path(struct dentry * entry, struct dentry * chroot, char * buf);
 
 extern struct dentry * d_basket(struct dentry * dir_entry);
 
 extern int d_isbasket(struct dentry * entry);
+
+/*
+ * Whee..
+ */
+static inline void dput(struct dentry *dentry)
+{
+	if (dentry)
+		dentry->d_count--;
+}
+
+static inline struct dentry * dget(struct dentry *dentry)
+{
+	if (dentry)
+		dentry->d_count++;
+	return dentry;
+}
+
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov