static kmem_cache_t *dentry_cache;
+/*
+ * The allocation size for each dentry. It is a multiple of 16 bytes. We
+ * leave the final 32-47 bytes for the inline name.
+ */
+#define DENTRY_STORAGE (((sizeof(struct dentry)+32) + 15) & ~15)
+#define DNAME_INLINE_LEN (DENTRY_STORAGE - sizeof(struct dentry))
+
/*
* This is the single most critical data structure when it comes
* to the dcache: the hashtable for lookups. Somebody should try
return dentry_stat.nr_unused;
}
-#define NAME_ALLOC_LEN(len) ((len+16) & ~15)
-
/**
* d_alloc - allocate a dcache entry
* @parent: parent of entry to allocate
return NULL;
if (name->len > DNAME_INLINE_LEN-1) {
- qstr = kmalloc(sizeof(*qstr) + NAME_ALLOC_LEN(name->len),
- GFP_KERNEL);
+ qstr = kmalloc(sizeof(*qstr) + name->len + 1, GFP_KERNEL);
if (!qstr) {
kmem_cache_free(dentry_cache, dentry);
return NULL;
* of the dcache.
*/
dentry_cache = kmem_cache_create("dentry_cache",
- sizeof(struct dentry),
+ DENTRY_STORAGE,
0,
SLAB_RECLAIM_ACCOUNT,
NULL, NULL);
return end_name_hash(hash);
}
-#define DNAME_INLINE_LEN_MIN 24
-
struct dcookie_struct;
struct dentry {
struct qstr d_name;
struct hlist_node d_hash; /* lookup hash list */
struct hlist_head * d_bucket; /* lookup hash bucket */
- unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
+ unsigned char d_iname[0]; /* small names */
};
-#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname))
-
struct dentry_operations {
int (*d_revalidate)(struct dentry *, struct nameidata *);
int (*d_hash) (struct dentry *, struct qstr *);