Commit f48acc23 authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

[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.
parent 48c39f24
...@@ -62,11 +62,10 @@ ...@@ -62,11 +62,10 @@
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#define __DQUOT_VERSION__ "dquot_6.4.0"
int nr_dquots, nr_free_dquots; int nr_dquots, nr_free_dquots;
static char *quotatypes[] = INITQFNAMES; static char *quotatypes[] = INITQFNAMES;
...@@ -879,21 +878,6 @@ static int check_bdq(struct dquot *dquot, ulong blocks, char prealloc, char *war ...@@ -879,21 +878,6 @@ static int check_bdq(struct dquot *dquot, ulong blocks, char prealloc, char *war
return QUOTA_OK; 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. * Externally referenced functions through dquot_operations in inode.
* *
...@@ -1172,30 +1156,6 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) ...@@ -1172,30 +1156,6 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
return ret; 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. * Definitions of diskquota operations.
*/ */
...@@ -1439,3 +1399,64 @@ asmlinkage long sys_quotactl(int cmd, const char *special, int id, caddr_t addr) ...@@ -1439,3 +1399,64 @@ asmlinkage long sys_quotactl(int cmd, const char *special, int id, caddr_t addr)
unlock_kernel(); unlock_kernel();
return ret; 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);
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/types.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 */ typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment