]> git.hungrycats.org Git - linux/commitdiff
[PATCH] [4/13] quota-4-getstats
authorJan Kara <jack@suse.cz>
Mon, 20 May 2002 02:34:05 +0000 (19:34 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Mon, 20 May 2002 02:34:05 +0000 (19:34 -0700)
  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
include/linux/quota.h

index f4d8fbe1c165f8fb8cd26ae0ad17fe2ba6d5f2d3..b824ce109c572988da7ecb8d0f424e56459a1b08 100644 (file)
 #include <linux/sysctl.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
+#include <linux/proc_fs.h>
 
 #include <asm/uaccess.h>
 
-#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);
index c6f1eacb9bc23cab464e8e32df56912d7b92684b..b17397cb51baf076c16b4be3e7a4d09a3897f489 100644 (file)
@@ -42,6 +42,9 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 
+#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 */
 
 /*