Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <gkernel.adm@hostme.bitkeeper.com>2002-02-09 07:11:54 -0800
committerJeff Garzik <gkernel.adm@hostme.bitkeeper.com>2002-02-09 07:11:54 -0800
commit52b5e869852bc17061c86ad85be7d0143da583b2 (patch)
tree28df680c65158ae496178e9e9714b7dc2f6cc9a1
parent339c84ae2a9412a0f2befc459ad433f82c5ca9e0 (diff)
parent0431923fb7a1f25051ff4435810679a337d25076 (diff)
Merge http://gkernel.bkbits.net/linus-2.5
into hostme.bitkeeper.com:/ua/repos/g/gkernel/net-drivers-2.5
-rw-r--r--drivers/pcmcia/cardbus.c4
-rw-r--r--fs/affs/super.c10
-rw-r--r--fs/dquot.c6
-rw-r--r--fs/ext2/balloc.c2
-rw-r--r--fs/lockd/svclock.c20
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--fs/nfsd/export.c6
-rw-r--r--fs/nfsd/nfsfh.c3
-rw-r--r--fs/nfsd/vfs.c4
-rw-r--r--fs/proc/proc_misc.c40
-rw-r--r--include/linux/slab.h5
-rw-r--r--kernel/module.c129
-rw-r--r--mm/slab.c257
13 files changed, 229 insertions, 259 deletions
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 7001c37d167c..580c9d93b64b 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -279,13 +279,13 @@ int cb_alloc(socket_info_t * s)
pci_readw(dev, PCI_DEVICE_ID, &dev->device);
dev->hdr_type = hdr & 0x7f;
+ pci_setup_device(dev);
+
dev->dev.parent = bus->dev;
strcpy(dev->dev.name, dev->name);
strcpy(dev->dev.bus_id, dev->slot_name);
device_register(&dev->dev);
- pci_setup_device(dev);
-
/* FIXME: Do we need to enable the expansion ROM? */
for (r = 0; r < 7; r++) {
struct resource *res = dev->resource + r;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 3d0b3824db45..f526b3fe5c75 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -270,9 +270,8 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
struct buffer_head *root_bh = NULL;
struct buffer_head *boot_bh;
struct inode *root_inode = NULL;
- kdev_t dev = sb->s_dev;
s32 root_block;
- int blocks, size, blocksize;
+ int size, blocksize;
u32 chksum;
int num_bm;
int i, j;
@@ -308,12 +307,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
* blocks, we will have to change it.
*/
- blocks = blk_size[major(dev)] ? blk_size[major(dev)][minor(dev)] : 0;
- if (!blocks) {
- printk(KERN_ERR "AFFS: Could not determine device size\n");
- goto out_error;
- }
- size = (BLOCK_SIZE / 512) * blocks;
+ size = sb->s_bdev->bd_inode->i_size >> 9;
pr_debug("AFFS: initial blksize=%d, blocks=%d\n", 512, blocks);
affs_set_blocksize(sb, PAGE_SIZE);
diff --git a/fs/dquot.c b/fs/dquot.c
index 2e4d5922f319..ff2326ae046e 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -289,7 +289,7 @@ static void write_dquot(struct dquot *dquot)
sizeof(struct dqblk), &offset);
if (ret != sizeof(struct dqblk))
printk(KERN_WARNING "VFS: dquota write failed on dev %s\n",
- kdevname(dquot->dq_sb->s_dev));
+ dquot->dq_sb->s_id);
set_fs(fs);
up(sem);
@@ -440,7 +440,7 @@ static void dqput(struct dquot *dquot)
if (!dquot->dq_count) {
printk("VFS: dqput: trying to free free dquot\n");
printk("VFS: device %s, dquot of %s %d\n",
- kdevname(dquot->dq_sb->s_dev),
+ dquot->dq_sb->s_id,
quotatypes[dquot->dq_type],
dquot->dq_id);
return;
@@ -715,7 +715,7 @@ static void print_warning(struct dquot *dquot, const char warntype)
if (!need_print_warning(dquot, flag))
return;
dquot->dq_flags |= flag;
- tty_write_message(current->tty, (char *)bdevname(dquot->dq_sb->s_dev));
+ tty_write_message(current->tty, dquot->dq_sb->s_id);
if (warntype == ISOFTWARN || warntype == BSOFTWARN)
tty_write_message(current->tty, ": warning, ");
else
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 92e672ac8b26..cc6c6217e758 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -404,7 +404,7 @@ int ext2_new_block (struct inode * inode, unsigned long goal,
if (DQUOT_ALLOC_BLOCK(inode, 1))
goto out;
- while (prealloc_goal && !DQUOT_PREALLOC_BLOCK(inode, prealloc_goal))
+ while (prealloc_goal && DQUOT_PREALLOC_BLOCK(inode, prealloc_goal))
prealloc_goal--;
dq_alloc = prealloc_goal + 1;
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index db4be6f1012f..67c4743d2006 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -306,9 +306,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
struct nlm_block *block;
int error;
- dprintk("lockd: nlmsvc_lock(%02x:%02x/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
- major(file->f_file.f_dentry->d_inode->i_dev),
- minor(file->f_file.f_dentry->d_inode->i_dev),
+ dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
+ file->f_file.f_dentry->d_inode->i_sb->s_id,
file->f_file.f_dentry->d_inode->i_ino,
lock->fl.fl_type, lock->fl.fl_pid,
(long long)lock->fl.fl_start,
@@ -386,9 +385,8 @@ nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
{
struct file_lock *fl;
- dprintk("lockd: nlmsvc_testlock(%02x:%02x/%ld, ty=%d, %Ld-%Ld)\n",
- major(file->f_file.f_dentry->d_inode->i_dev),
- minor(file->f_file.f_dentry->d_inode->i_dev),
+ dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
+ file->f_file.f_dentry->d_inode->i_sb->s_id,
file->f_file.f_dentry->d_inode->i_ino,
lock->fl.fl_type,
(long long)lock->fl.fl_start,
@@ -419,9 +417,8 @@ nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock)
{
int error;
- dprintk("lockd: nlmsvc_unlock(%02x:%02x/%ld, pi=%d, %Ld-%Ld)\n",
- major(file->f_file.f_dentry->d_inode->i_dev),
- minor(file->f_file.f_dentry->d_inode->i_dev),
+ dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n",
+ file->f_file.f_dentry->d_inode->i_sb->s_id,
file->f_file.f_dentry->d_inode->i_ino,
lock->fl.fl_pid,
(long long)lock->fl.fl_start,
@@ -448,9 +445,8 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
{
struct nlm_block *block;
- dprintk("lockd: nlmsvc_cancel(%02x:%02x/%ld, pi=%d, %Ld-%Ld)\n",
- major(file->f_file.f_dentry->d_inode->i_dev),
- minor(file->f_file.f_dentry->d_inode->i_dev),
+ dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n",
+ file->f_file.f_dentry->d_inode->i_sb->s_id,
file->f_file.f_dentry->d_inode->i_ino,
lock->fl.fl_pid,
(long long)lock->fl.fl_start,
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 59ed7ae53cd4..6c07d3af87f8 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -128,7 +128,7 @@ nlm_delete_file(struct nlm_file *file)
struct nlm_file **fp, *f;
dprintk("lockd: closing file %s/%ld\n",
- kdevname(inode->i_dev), inode->i_ino);
+ inode->i_sb->s_id, inode->i_ino);
fp = nlm_files + file->f_hash;
while ((f = *fp) != NULL) {
if (f == file) {
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 03c7735c7cb4..6f725d3562cd 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -375,7 +375,6 @@ exp_rootfh(struct svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
struct nameidata nd;
struct inode *inode;
struct svc_fh fh;
- kdev_t dev;
int err;
err = -EPERM;
@@ -386,11 +385,10 @@ exp_rootfh(struct svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
return err;
}
inode = nd.dentry->d_inode;
- dev = inode->i_dev;
- dprintk("nfsd: exp_rootfh(%s [%p] %s:%02x:%02x/%ld)\n",
+ dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
path, nd.dentry, clp->cl_ident,
- major(dev), minor(dev), (long) inode->i_ino);
+ inode->i_sb->s_id, inode->i_ino);
exp = exp_parent(clp, inode->i_sb, nd.dentry);
if (!exp) {
dprintk("nfsd: exp_rootfh export not found.\n");
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 952e012591a2..82152dc031d9 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -424,8 +424,7 @@ find_fh_dentry(struct super_block *sb, __u32 *datap, int len, int fhtype, int ne
/* It's a directory, or we are required to confirm the file's
* location in the tree.
*/
- dprintk("nfs_fh: need to look harder for %02x:%02x/%d\n",
- major(sb->s_dev), minor(sb->s_dev), datap[0]);
+ dprintk("nfs_fh: need to look harder for %s/%d\n", sb->s_id, datap[0]);
if (!S_ISDIR(result->d_inode->i_mode)) {
nfsdstats.fh_nocache_nondir++;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index f72b8a01a99c..55a29adf3e0e 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1410,8 +1410,8 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
oldlen = cd.buflen;
/*
- dprintk("nfsd: f_op->readdir(%x/%ld @ %d) buflen = %d (%d)\n",
- file.f_inode->i_dev, file.f_inode->i_ino,
+ dprintk("nfsd: f_op->readdir(%s/%ld @ %d) buflen = %d (%d)\n",
+ file.f_inode->i_sb->s_id, file.f_inode->i_ino,
(int) file.f_pos, (int) oldlen, (int) cd.buflen);
*/
err = file.f_op->readdir(&file, &cd, (filldir_t) func);
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index e542e57a28c6..b176467ff765 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -50,9 +50,6 @@
* have a way to deal with that gracefully. Right now I used straightforward
* wrappers, but this needs further analysis wrt potential overflows.
*/
-#ifdef CONFIG_MODULES
-extern int get_module_list(char *);
-#endif
extern int get_device_list(char *);
extern int get_partition_list(char *, char **, off_t, int);
extern int get_filesystem_list(char *);
@@ -203,13 +200,17 @@ static struct file_operations proc_cpuinfo_operations = {
};
#ifdef CONFIG_MODULES
-static int modules_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
+extern struct seq_operations modules_op;
+static int modules_open(struct inode *inode, struct file *file)
{
- int len = get_module_list(page);
- return proc_calc_metrics(page, start, off, count, eof, len);
+ return seq_open(file, &modules_op);
}
-
+static struct file_operations proc_modules_operations = {
+ open: modules_open,
+ read: seq_read,
+ llseek: seq_lseek,
+ release: seq_release,
+};
extern struct seq_operations ksyms_op;
static int ksyms_open(struct inode *inode, struct file *file)
{
@@ -223,6 +224,20 @@ static struct file_operations proc_ksyms_operations = {
};
#endif
+extern struct seq_operations slabinfo_op;
+extern ssize_t slabinfo_write(struct file *, const char *, size_t, loff_t *);
+static int slabinfo_open(struct inode *inode, struct file *file)
+{
+ return seq_open(file, &slabinfo_op);
+}
+static struct file_operations proc_slabinfo_operations = {
+ open: slabinfo_open,
+ read: seq_read,
+ write: slabinfo_write,
+ llseek: seq_lseek,
+ release: seq_release,
+};
+
static int kstat_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
@@ -521,9 +536,6 @@ void __init proc_misc_init(void)
{"uptime", uptime_read_proc},
{"meminfo", meminfo_read_proc},
{"version", version_read_proc},
-#ifdef CONFIG_MODULES
- {"modules", modules_read_proc},
-#endif
{"stat", kstat_read_proc},
{"devices", devices_read_proc},
{"partitions", partitions_read_proc},
@@ -551,7 +563,9 @@ void __init proc_misc_init(void)
entry->proc_fops = &proc_kmsg_operations;
create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
create_seq_entry("interrupts", 0, &proc_interrupts_operations);
+ create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
#ifdef CONFIG_MODULES
+ create_seq_entry("modules", 0, &proc_modules_operations);
create_seq_entry("ksyms", 0, &proc_ksyms_operations);
#endif
proc_root_kcore = create_proc_entry("kcore", S_IRUSR, NULL);
@@ -575,8 +589,4 @@ void __init proc_misc_init(void)
entry->proc_fops = &ppc_htab_operations;
}
#endif
- entry = create_proc_read_entry("slabinfo", S_IWUSR | S_IRUGO, NULL,
- slabinfo_read_proc, NULL);
- if (entry)
- entry->write_proc = slabinfo_write_proc;
}
diff --git a/include/linux/slab.h b/include/linux/slab.h
index ceff3509f29e..50cefbbc92a8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -62,11 +62,6 @@ extern void *kmalloc(size_t, int);
extern void kfree(const void *);
extern int FASTCALL(kmem_cache_reap(int));
-extern int slabinfo_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-struct file;
-extern int slabinfo_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data);
/* System wide caches */
extern kmem_cache_t *vm_area_cachep;
diff --git a/kernel/module.c b/kernel/module.c
index 9d310463bfdb..d0ed467083f9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1075,84 +1075,67 @@ free_module(struct module *mod, int tag_freed)
/*
* Called by the /proc file system to return a current list of modules.
*/
-
-int get_module_list(char *p)
+static void *m_start(struct seq_file *m, loff_t *pos)
{
- size_t left = PAGE_SIZE;
- struct module *mod;
- char tmpstr[64];
- struct module_ref *ref;
-
- for (mod = module_list; mod != &kernel_module; mod = mod->next) {
- long len;
- const char *q;
-
-#define safe_copy_str(str, len) \
- do { \
- if (left < len) \
- goto fini; \
- memcpy(p, str, len); p += len, left -= len; \
- } while (0)
-#define safe_copy_cstr(str) safe_copy_str(str, sizeof(str)-1)
-
- len = strlen(mod->name);
- safe_copy_str(mod->name, len);
-
- if ((len = 20 - len) > 0) {
- if (left < len)
- goto fini;
- memset(p, ' ', len);
- p += len;
- left -= len;
- }
-
- len = sprintf(tmpstr, "%8lu", mod->size);
- safe_copy_str(tmpstr, len);
-
- if (mod->flags & MOD_RUNNING) {
- len = sprintf(tmpstr, "%4ld",
- (mod_member_present(mod, can_unload)
- && mod->can_unload
- ? -1L : (long)atomic_read(&mod->uc.usecount)));
- safe_copy_str(tmpstr, len);
- }
+ struct module *v;
+ loff_t n = *pos;
+ lock_kernel();
+ for (v = module_list; v && n--; v = v->next)
+ ;
+ return v;
+}
+static void *m_next(struct seq_file *m, void *p, loff_t *pos)
+{
+ struct module *v = p;
+ (*pos)++;
+ return v->next;
+}
+static void m_stop(struct seq_file *m, void *p)
+{
+ unlock_kernel();
+}
+static int m_show(struct seq_file *m, void *p)
+{
+ struct module *mod = p;
+ struct module_ref *ref = mod->refs;
- if (mod->flags & MOD_DELETED)
- safe_copy_cstr(" (deleted)");
- else if (mod->flags & MOD_RUNNING) {
- if (mod->flags & MOD_AUTOCLEAN)
- safe_copy_cstr(" (autoclean)");
- if (!(mod->flags & MOD_USED_ONCE))
- safe_copy_cstr(" (unused)");
- }
- else if (mod->flags & MOD_INITIALIZING)
- safe_copy_cstr(" (initializing)");
- else
- safe_copy_cstr(" (uninitialized)");
-
- if ((ref = mod->refs) != NULL) {
- safe_copy_cstr(" [");
- while (1) {
- q = ref->ref->name;
- len = strlen(q);
- safe_copy_str(q, len);
-
- if ((ref = ref->next_ref) != NULL)
- safe_copy_cstr(" ");
- else
- break;
- }
- safe_copy_cstr("]");
- }
- safe_copy_cstr("\n");
+ if (mod == &kernel_module)
+ return 0;
-#undef safe_copy_str
-#undef safe_copy_cstr
+ seq_printf(m, "%-20s%8lu", mod->name, mod->size);
+ if (mod->flags & MOD_RUNNING)
+ seq_printf(m, "%4ld",
+ (mod_member_present(mod, can_unload)
+ && mod->can_unload
+ ? -1L : (long)atomic_read(&mod->uc.usecount)));
+
+ if (mod->flags & MOD_DELETED)
+ seq_puts(m, " (deleted)");
+ else if (mod->flags & MOD_RUNNING) {
+ if (mod->flags & MOD_AUTOCLEAN)
+ seq_puts(m, " (autoclean)");
+ if (!(mod->flags & MOD_USED_ONCE))
+ seq_puts(m, " (unused)");
+ } else if (mod->flags & MOD_INITIALIZING)
+ seq_puts(m, " (initializing)");
+ else
+ seq_puts(m, " (uninitialized)");
+ if (ref) {
+ char c;
+ seq_putc(m, ' ');
+ for (c = '[' ; ref; c = ' ', ref = ref->next_ref)
+ seq_printf(m, "%c%s", c, ref->ref->name);
+ seq_putc(m, ']');
}
-
-fini:
- return PAGE_SIZE - left;
+ seq_putc(m, '\n');
+ return 0;
}
+struct seq_operations modules_op = {
+ start: m_start,
+ next: m_next,
+ stop: m_stop,
+ show: m_show
+};
/*
* Called by the /proc file system to return a current list of ksyms.
diff --git a/mm/slab.c b/mm/slab.c
index 9835c232b066..26c7eb5aac01 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -75,6 +75,7 @@
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/compiler.h>
+#include <linux/seq_file.h>
#include <asm/uaccess.h>
/*
@@ -1869,31 +1870,56 @@ out:
}
#ifdef CONFIG_PROC_FS
-/* /proc/slabinfo
- * cache-name num-active-objs total-objs
- * obj-size num-active-slabs total-slabs
- * num-pages-per-slab
- */
-#define FIXUP(t) \
- do { \
- if (len <= off) { \
- off -= len; \
- len = 0; \
- } else { \
- if (len-off > count) \
- goto t; \
- } \
- } while (0)
-static int proc_getdata (char*page, char**start, off_t off, int count)
+static void *s_start(struct seq_file *m, loff_t *pos)
{
+ loff_t n = *pos;
struct list_head *p;
- int len = 0;
- /* Output format version, so at least we can change it without _too_
- * many complaints.
- */
- len += sprintf(page+len, "slabinfo - version: 1.1"
+ down(&cache_chain_sem);
+ if (!n)
+ return (void *)1;
+ p = &cache_cache.next;
+ while (--n) {
+ p = p->next;
+ if (p == &cache_cache.next)
+ return NULL;
+ }
+ return list_entry(p, kmem_cache_t, next);
+}
+
+static void *s_next(struct seq_file *m, void *p, loff_t *pos)
+{
+ kmem_cache_t *cachep = p;
+ ++*pos;
+ if (p == (void *)1)
+ return &cache_cache;
+ cachep = list_entry(cachep->next.next, kmem_cache_t, next);
+ return cachep == &cache_cache ? NULL : cachep;
+}
+
+static void s_stop(struct seq_file *m, void *p)
+{
+ up(&cache_chain_sem);
+}
+
+static int s_show(struct seq_file *m, void *p)
+{
+ kmem_cache_t *cachep = p;
+ struct list_head *q;
+ slab_t *slabp;
+ unsigned long active_objs;
+ unsigned long num_objs;
+ unsigned long active_slabs = 0;
+ unsigned long num_slabs;
+ const char *name;
+
+ if (p == (void*)1) {
+ /*
+ * Output format version, so at least we can change it
+ * without _too_ many complaints.
+ */
+ seq_puts(m, "slabinfo - version: 1.1"
#if STATS
" (statistics)"
#endif
@@ -1901,116 +1927,89 @@ static int proc_getdata (char*page, char**start, off_t off, int count)
" (SMP)"
#endif
"\n");
- FIXUP(got_data);
-
- down(&cache_chain_sem);
- p = &cache_cache.next;
- do {
- kmem_cache_t *cachep;
- struct list_head *q;
- slab_t *slabp;
- unsigned long active_objs;
- unsigned long num_objs;
- unsigned long active_slabs = 0;
- unsigned long num_slabs;
- const char *name;
- cachep = list_entry(p, kmem_cache_t, next);
+ return 0;
+ }
- spin_lock_irq(&cachep->spinlock);
- active_objs = 0;
- num_slabs = 0;
- list_for_each(q,&cachep->slabs_full) {
- slabp = list_entry(q, slab_t, list);
- if (slabp->inuse != cachep->num)
- BUG();
- active_objs += cachep->num;
- active_slabs++;
- }
- list_for_each(q,&cachep->slabs_partial) {
- slabp = list_entry(q, slab_t, list);
- if (slabp->inuse == cachep->num || !slabp->inuse)
- BUG();
- active_objs += slabp->inuse;
- active_slabs++;
- }
- list_for_each(q,&cachep->slabs_free) {
- slabp = list_entry(q, slab_t, list);
- if (slabp->inuse)
- BUG();
- num_slabs++;
- }
- num_slabs+=active_slabs;
- num_objs = num_slabs*cachep->num;
+ spin_lock_irq(&cachep->spinlock);
+ active_objs = 0;
+ num_slabs = 0;
+ list_for_each(q,&cachep->slabs_full) {
+ slabp = list_entry(q, slab_t, list);
+ if (slabp->inuse != cachep->num)
+ BUG();
+ active_objs += cachep->num;
+ active_slabs++;
+ }
+ list_for_each(q,&cachep->slabs_partial) {
+ slabp = list_entry(q, slab_t, list);
+ if (slabp->inuse == cachep->num || !slabp->inuse)
+ BUG();
+ active_objs += slabp->inuse;
+ active_slabs++;
+ }
+ list_for_each(q,&cachep->slabs_free) {
+ slabp = list_entry(q, slab_t, list);
+ if (slabp->inuse)
+ BUG();
+ num_slabs++;
+ }
+ num_slabs+=active_slabs;
+ num_objs = num_slabs*cachep->num;
- name = cachep->name;
- {
- char tmp;
- if (__get_user(tmp, name))
- name = "broken";
- }
+ name = cachep->name;
+ {
+ char tmp;
+ if (__get_user(tmp, name))
+ name = "broken";
+ }
- len += sprintf(page+len, "%-17s %6lu %6lu %6u %4lu %4lu %4u",
- name, active_objs, num_objs, cachep->objsize,
- active_slabs, num_slabs, (1<<cachep->gfporder));
+ seq_printf(m, "%-17s %6lu %6lu %6u %4lu %4lu %4u",
+ name, active_objs, num_objs, cachep->objsize,
+ active_slabs, num_slabs, (1<<cachep->gfporder));
#if STATS
- {
- unsigned long errors = cachep->errors;
- unsigned long high = cachep->high_mark;
- unsigned long grown = cachep->grown;
- unsigned long reaped = cachep->reaped;
- unsigned long allocs = cachep->num_allocations;
-
- len += sprintf(page+len, " : %6lu %7lu %5lu %4lu %4lu",
- high, allocs, grown, reaped, errors);
- }
+ {
+ unsigned long errors = cachep->errors;
+ unsigned long high = cachep->high_mark;
+ unsigned long grown = cachep->grown;
+ unsigned long reaped = cachep->reaped;
+ unsigned long allocs = cachep->num_allocations;
+
+ seq_printf(m, " : %6lu %7lu %5lu %4lu %4lu",
+ high, allocs, grown, reaped, errors);
+ }
#endif
#ifdef CONFIG_SMP
- {
- unsigned int batchcount = cachep->batchcount;
- unsigned int limit;
-
- if (cc_data(cachep))
- limit = cc_data(cachep)->limit;
- else
- limit = 0;
- len += sprintf(page+len, " : %4u %4u",
- limit, batchcount);
- }
+ {
+ unsigned int batchcount = cachep->batchcount;
+ unsigned int limit;
+
+ if (cc_data(cachep))
+ limit = cc_data(cachep)->limit;
+ else
+ limit = 0;
+ seq_printf(m, " : %4u %4u", limit, batchcount);
+ }
#endif
#if STATS && defined(CONFIG_SMP)
- {
- unsigned long allochit = atomic_read(&cachep->allochit);
- unsigned long allocmiss = atomic_read(&cachep->allocmiss);
- unsigned long freehit = atomic_read(&cachep->freehit);
- unsigned long freemiss = atomic_read(&cachep->freemiss);
- len += sprintf(page+len, " : %6lu %6lu %6lu %6lu",
- allochit, allocmiss, freehit, freemiss);
- }
+ {
+ unsigned long allochit = atomic_read(&cachep->allochit);
+ unsigned long allocmiss = atomic_read(&cachep->allocmiss);
+ unsigned long freehit = atomic_read(&cachep->freehit);
+ unsigned long freemiss = atomic_read(&cachep->freemiss);
+ seq_printf(m, " : %6lu %6lu %6lu %6lu",
+ allochit, allocmiss, freehit, freemiss);
+ }
#endif
- len += sprintf(page+len,"\n");
- spin_unlock_irq(&cachep->spinlock);
- FIXUP(got_data_up);
- p = cachep->next.next;
- } while (p != &cache_cache.next);
-got_data_up:
- up(&cache_chain_sem);
-
-got_data:
- *start = page+off;
- return len;
+ spin_unlock_irq(&cachep->spinlock);
+ seq_putc(m, '\n');
+ return 0;
}
/**
- * slabinfo_read_proc - generates /proc/slabinfo
- * @page: scratch area, one page long
- * @start: pointer to the pointer to the output buffer
- * @off: offset within /proc/slabinfo the caller is interested in
- * @count: requested len in bytes
- * @eof: eof marker
- * @data: unused
+ * slabinfo_op - iterator that generates /proc/slabinfo
*
- * The contents of the buffer are
+ * Output layout:
* cache-name
* num-active-objs
* total-objs
@@ -2020,28 +2019,24 @@ got_data:
* num-pages-per-slab
* + further values on SMP and with statistics enabled
*/
-int slabinfo_read_proc (char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len = proc_getdata(page, start, off, count);
- len -= (*start-page);
- if (len <= count)
- *eof = 1;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
+
+struct seq_operations slabinfo_op = {
+ start: s_start,
+ next: s_next,
+ stop: s_stop,
+ show: s_show
+};
#define MAX_SLABINFO_WRITE 128
/**
- * slabinfo_write_proc - SMP tuning for the slab allocator
+ * slabinfo_write - SMP tuning for the slab allocator
* @file: unused
* @buffer: user buffer
* @count: data len
* @data: unused
*/
-int slabinfo_write_proc (struct file *file, const char *buffer,
- unsigned long count, void *data)
+ssize_t slabinfo_write(struct file *file, const char *buffer,
+ size_t count, loff_t *ppos)
{
#ifdef CONFIG_SMP
char kbuf[MAX_SLABINFO_WRITE+1], *tmp;