-#ifdef HAVE_VFS_READDIR_U64_INO
-static int l_filldir(void *__buf, const char *name, int namlen, loff_t offset,
- u64 ino, unsigned int d_type)
-#else
-static int l_filldir(void *__buf, const char *name, int namlen, loff_t offset,
- ino_t ino, unsigned int d_type)
-#endif
-{
- struct l_linux_dirent *dirent;
- struct l_readdir_callback *buf = (struct l_readdir_callback *)__buf;
-
- dirent = buf->lrc_dirent;
- if (dirent)
- dirent->lld_off = offset;
-
- OBD_ALLOC(dirent, sizeof(*dirent));
-
- if (!dirent)
- return -ENOMEM;
-
- list_add_tail(&dirent->lld_list, buf->lrc_list);
-
- buf->lrc_dirent = dirent;
- dirent->lld_ino = ino;
- LASSERT(sizeof(dirent->lld_name) >= namlen + 1);
- memcpy(dirent->lld_name, name, namlen);
-
- return 0;
-}
-
-long l_readdir(struct file *file, struct list_head *dentry_list)
-{
- struct l_linux_dirent *lastdirent;
- struct l_readdir_callback buf;
- int error;
-
- buf.lrc_dirent = NULL;
- buf.lrc_list = dentry_list;
-
- error = vfs_readdir(file, l_filldir, &buf);
- if (error < 0)
- return error;
-
- lastdirent = buf.lrc_dirent;
- if (lastdirent)
- lastdirent->lld_off = file->f_pos;
-
- return 0;
-}
-EXPORT_SYMBOL(l_readdir);
-EXPORT_SYMBOL(obd_memory);
-EXPORT_SYMBOL(obd_memmax);
-
-#if defined (CONFIG_DEBUG_MEMORY) && defined(__KERNEL__)
-static spinlock_t obd_memlist_lock = SPIN_LOCK_UNLOCKED;
-static struct hlist_head *obd_memtable = NULL;
-static unsigned long obd_memtable_size = 0;
-
-static int lvfs_memdbg_init(int size)
-{
- struct hlist_head *head;
- int i;
-
- LASSERT(size > sizeof(sizeof(struct hlist_head)));
- obd_memtable_size = size / sizeof(struct hlist_head);
-
- CWARN("Allocating %lu memdbg entries.\n",
- (unsigned long)obd_memtable_size);
-
- LASSERT(obd_memtable == NULL);
- obd_memtable = kmalloc(size, GFP_KERNEL);
- if (!obd_memtable)
- return -ENOMEM;
-
- i = obd_memtable_size;
- head = obd_memtable;
- do {
- INIT_HLIST_HEAD(head);
- head++;
- i--;
- } while(i);
-
- return 0;
-}
-
-static int lvfs_memdbg_cleanup(void)
-{
- struct hlist_node *node = NULL, *tmp = NULL;
- struct hlist_head *head;
- struct obd_mem_track *mt;
- int i;
-
- spin_lock(&obd_memlist_lock);
- for (i = 0, head = obd_memtable; i < obd_memtable_size; i++, head++) {
- hlist_for_each_safe(node, tmp, head) {
- mt = hlist_entry(node, struct obd_mem_track, mt_hash);
- hlist_del_init(&mt->mt_hash);
- kfree(mt);
- }
- }
- spin_unlock(&obd_memlist_lock);
- kfree(obd_memtable);
- return 0;
-}
-
-static inline unsigned long const hashfn(void *ptr)
-{
- return (unsigned long)ptr &
- (obd_memtable_size - 1);
-}
-
-static void __lvfs_memdbg_insert(struct obd_mem_track *mt)
-{
- struct hlist_head *head = obd_memtable +
- hashfn(mt->mt_ptr);
- hlist_add_head(&mt->mt_hash, head);
-}
-
-void lvfs_memdbg_insert(struct obd_mem_track *mt)
-{
- spin_lock(&obd_memlist_lock);
- __lvfs_memdbg_insert(mt);
- spin_unlock(&obd_memlist_lock);
-}
-EXPORT_SYMBOL(lvfs_memdbg_insert);
-
-static void __lvfs_memdbg_remove(struct obd_mem_track *mt)
-{
- hlist_del_init(&mt->mt_hash);
-}
-
-void lvfs_memdbg_remove(struct obd_mem_track *mt)
-{
- spin_lock(&obd_memlist_lock);
- __lvfs_memdbg_remove(mt);
- spin_unlock(&obd_memlist_lock);
-}
-EXPORT_SYMBOL(lvfs_memdbg_remove);
-
-static struct obd_mem_track *__lvfs_memdbg_find(void *ptr)