From f48acc23db77f14f59e8337ad6e015d9fe8d47b2 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Sun, 19 May 2002 19:34:05 -0700 Subject: [PATCH] [PATCH] [4/13] quota-4-getstats This patch moves reporting of quota statistics from Q_GETSTATS call to /proc/fs/quota. Also reporting of registered quota formats is added. --- fs/dquot.c | 103 +++++++++++++++++++++++++----------------- include/linux/quota.h | 3 ++ 2 files changed, 65 insertions(+), 41 deletions(-) diff --git a/fs/dquot.c b/fs/dquot.c index f4d8fbe1c165..b824ce109c57 100644 --- a/fs/dquot.c +++ b/fs/dquot.c @@ -62,11 +62,10 @@ #include #include #include +#include #include -#define __DQUOT_VERSION__ "dquot_6.4.0" - int nr_dquots, nr_free_dquots; static char *quotatypes[] = INITQFNAMES; @@ -879,21 +878,6 @@ static int check_bdq(struct dquot *dquot, ulong blocks, char prealloc, char *war return QUOTA_OK; } -static int get_stats(caddr_t addr) -{ - int error = -EFAULT; - struct dqstats stats; - - dqstats.allocated_dquots = nr_dquots; - dqstats.free_dquots = nr_free_dquots; - - /* make a copy, in case we page-fault in user space */ - memcpy(&stats, &dqstats, sizeof(struct dqstats)); - if (!copy_to_user(addr, &stats, sizeof(struct dqstats))) - error = 0; - return error; -} - /* * Externally referenced functions through dquot_operations in inode. * @@ -1172,30 +1156,6 @@ warn_put_all: return ret; } -static ctl_table fs_table[] = { - {FS_NRDQUOT, "dquot-nr", &nr_dquots, 2*sizeof(int), - 0444, NULL, &proc_dointvec}, - {}, -}; - -static ctl_table dquot_table[] = { - {CTL_FS, "fs", NULL, 0, 0555, fs_table}, - {}, -}; - -static int __init dquot_init(void) -{ - int i; - - register_sysctl_table(dquot_table, 0); - - for (i = 0; i < NR_DQHASH; i++) - INIT_LIST_HEAD(dquot_hash + i); - printk(KERN_NOTICE "VFS: Diskquotas version %s initialized\n", __DQUOT_VERSION__); - return 0; -} -__initcall(dquot_init); - /* * Definitions of diskquota operations. */ @@ -1439,3 +1399,64 @@ out: unlock_kernel(); return ret; } + +#ifdef CONFIG_PROC_FS +static int read_stats(char *buffer, char **start, off_t offset, int count, int *eof, void *data) +{ + int len; + struct quota_format_type *actqf; + + dqstats.allocated_dquots = nr_dquots; + dqstats.free_dquots = nr_free_dquots; + + len = sprintf(buffer, "Version %u\n", __DQUOT_NUM_VERSION__); + len += sprintf(buffer + len, "Formats"); + lock_kernel(); + for (actqf = quota_formats; actqf; actqf = actqf->qf_next) + len += sprintf(buffer + len, " %u", actqf->qf_id); + unlock_kernel(); + len += sprintf(buffer + len, "\n%u %u %u %u %u %u %u %u\n", + dqstats.lookups, dqstats.drops, + dqstats.reads, dqstats.writes, + dqstats.cache_hits, dqstats.allocated_dquots, + dqstats.free_dquots, dqstats.syncs); + + if (offset >= len) { + *start = buffer; + *eof = 1; + return 0; + } + *start = buffer + offset; + if ((len -= offset) > count) + return count; + *eof = 1; + + return len; +} +#endif + +static ctl_table fs_table[] = { + {FS_NRDQUOT, "dquot-nr", &nr_dquots, 2*sizeof(int), + 0444, NULL, &proc_dointvec}, + {}, +}; + +static ctl_table dquot_table[] = { + {CTL_FS, "fs", NULL, 0, 0555, fs_table}, + {}, +}; + +static int __init dquot_init(void) +{ + int i; + + register_sysctl_table(dquot_table, 0); + for (i = 0; i < NR_DQHASH; i++) + INIT_LIST_HEAD(dquot_hash + i); + printk(KERN_NOTICE "VFS: Diskquotas version %s initialized\n", __DQUOT_VERSION__); +#ifdef CONFIG_PROC_FS + create_proc_read_entry("fs/quota", 0, 0, read_stats, NULL); +#endif + return 0; +} +__initcall(dquot_init); diff --git a/include/linux/quota.h b/include/linux/quota.h index c6f1eacb9bc2..b17397cb51ba 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h @@ -42,6 +42,9 @@ #include #include +#define __DQUOT_VERSION__ "dquot_6.5.1" +#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1 + typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */ /* -- 2.39.5