From fc3d4d7cfbe647cff07e8da119bdfe754d9056ec Mon Sep 17 00:00:00 2001 From: adilger Date: Mon, 9 Feb 2004 22:03:02 +0000 Subject: [PATCH] Update b_smallfix from HEAD (20040209_1433) (merge of b_recovery) --- lustre/include/linux/lvfs_linux.h | 18 ++++++------ lustre/lvfs/lvfs_linux.c | 60 +++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/lustre/include/linux/lvfs_linux.h b/lustre/include/linux/lvfs_linux.h index b38d6f0..71fc431 100644 --- a/lustre/include/linux/lvfs_linux.h +++ b/lustre/include/linux/lvfs_linux.h @@ -1,3 +1,6 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + */ #ifndef __LVFS_LINUX_H__ #define __LVFS_LINUX_H__ @@ -22,17 +25,14 @@ struct l_file *l_dentry_open(struct obd_run_ctxt *, struct l_dentry *, int flags); struct l_linux_dirent { - ino_t d_ino; - unsigned long d_off; - unsigned short d_reclen; - char d_name[1]; + struct list_head lld_list; + ino_t lld_ino; + unsigned long lld_off; + char lld_name[LL_FID_NAMELEN]; }; - struct l_readdir_callback { - struct l_linux_dirent *current_dir; - struct l_linux_dirent *previous; - int count; - int error; + struct l_linux_dirent *lrc_dirent; + struct list_head *lrc_list; }; #endif diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index 61cd57c..935548e 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -50,6 +50,10 @@ #include #include +atomic_t obd_memory; +int obd_memmax; + + /* Debugging check only needed during development */ #ifdef OBD_CTXT_DEBUG # define ASSERT_CTXT_MAGIC(magic) LASSERT((magic) == OBD_RUN_CTXT_MAGIC) @@ -308,49 +312,45 @@ static int l_filldir(void *__buf, const char *name, int namlen, loff_t offset, { struct l_linux_dirent *dirent; struct l_readdir_callback *buf = (struct l_readdir_callback *)__buf; - int reclen = size_round(offsetof(struct l_linux_dirent, d_name) + namlen + 1); - buf->error = -EINVAL; - if (reclen > buf->count) - return -EINVAL; - dirent = buf->previous; + dirent = buf->lrc_dirent; if (dirent) - dirent->d_off = offset; - dirent = buf->current_dir; - buf->previous = dirent; - dirent->d_ino = ino; - dirent->d_reclen = reclen; - memcpy(dirent->d_name, name, namlen); - ((char *)dirent) += reclen; - buf->current_dir = dirent; - buf->count -= reclen; + dirent->lld_off = offset; + + OBD_ALLOC(dirent, sizeof(*dirent)); + + 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, void * dirent, unsigned int count) +long l_readdir(struct file *file, struct list_head *dentry_list) { - struct l_linux_dirent * lastdirent; + struct l_linux_dirent *lastdirent; struct l_readdir_callback buf; int error; - buf.current_dir = (struct l_linux_dirent *)dirent; - buf.previous = NULL; - buf.count = count; - buf.error = 0; + buf.lrc_dirent = NULL; + buf.lrc_list = dentry_list; error = vfs_readdir(file, l_filldir, &buf); if (error < 0) return error; - error = buf.error; - lastdirent = buf.previous; - if (lastdirent) { - lastdirent->d_off = file->f_pos; - error = count - buf.count; - } - 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 (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) @@ -361,6 +361,12 @@ static int __init lvfs_linux_init(void) static void __exit lvfs_linux_exit(void) { + int leaked; + ENTRY; + + leaked = atomic_read(&obd_memory); + CDEBUG(leaked ? D_ERROR : D_INFO, + "obd mem max: %d leaked: %d\n", obd_memmax, leaked); return; } -- 1.8.3.1