Commit 26dc86a2 authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

[PATCH] Quota update [2/3]

This changes the sysctl interface to use reasonable names in
/proc/sys/fs/quota/
parent c5bea884
...@@ -121,7 +121,7 @@ static void put_quota_format(struct quota_format_type *fmt) ...@@ -121,7 +121,7 @@ static void put_quota_format(struct quota_format_type *fmt)
* Unused dquots (dq_count == 0) are added to the free_dquots list when freed, * Unused dquots (dq_count == 0) are added to the free_dquots list when freed,
* and this list is searched whenever we need an available dquot. Dquots are * and this list is searched whenever we need an available dquot. Dquots are
* removed from the list as soon as they are used again, and * removed from the list as soon as they are used again, and
* dqstats_array[DQSTATS_FREE] gives the number of dquots on the list. When * dqstats.free_dquots gives the number of dquots on the list. When
* dquot is invalidated it's completely released from memory. * dquot is invalidated it's completely released from memory.
* *
* Dquots with a specific identity (device, type and id) are placed on * Dquots with a specific identity (device, type and id) are placed on
...@@ -148,7 +148,7 @@ static LIST_HEAD(inuse_list); ...@@ -148,7 +148,7 @@ static LIST_HEAD(inuse_list);
static LIST_HEAD(free_dquots); static LIST_HEAD(free_dquots);
static struct list_head dquot_hash[NR_DQHASH]; static struct list_head dquot_hash[NR_DQHASH];
__u32 dqstats_array[DQSTATS_SIZE]; struct dqstats dqstats;
static void dqput(struct dquot *); static void dqput(struct dquot *);
static struct dquot *dqduplicate(struct dquot *); static struct dquot *dqduplicate(struct dquot *);
...@@ -207,14 +207,14 @@ static inline struct dquot *find_dquot(unsigned int hashent, struct super_block ...@@ -207,14 +207,14 @@ static inline struct dquot *find_dquot(unsigned int hashent, struct super_block
static inline void put_dquot_head(struct dquot *dquot) static inline void put_dquot_head(struct dquot *dquot)
{ {
list_add(&dquot->dq_free, &free_dquots); list_add(&dquot->dq_free, &free_dquots);
++dqstats_array[DQSTATS_FREE]; dqstats.free_dquots++;
} }
/* Add a dquot to the tail of the free list */ /* Add a dquot to the tail of the free list */
static inline void put_dquot_last(struct dquot *dquot) static inline void put_dquot_last(struct dquot *dquot)
{ {
list_add(&dquot->dq_free, free_dquots.prev); list_add(&dquot->dq_free, free_dquots.prev);
++dqstats_array[DQSTATS_FREE]; dqstats.free_dquots++;
} }
/* Move dquot to the head of free list (it must be already on it) */ /* Move dquot to the head of free list (it must be already on it) */
...@@ -230,7 +230,7 @@ static inline void remove_free_dquot(struct dquot *dquot) ...@@ -230,7 +230,7 @@ static inline void remove_free_dquot(struct dquot *dquot)
return; return;
list_del(&dquot->dq_free); list_del(&dquot->dq_free);
INIT_LIST_HEAD(&dquot->dq_free); INIT_LIST_HEAD(&dquot->dq_free);
--dqstats_array[DQSTATS_FREE]; dqstats.free_dquots--;
} }
static inline void put_inuse(struct dquot *dquot) static inline void put_inuse(struct dquot *dquot)
...@@ -238,12 +238,12 @@ static inline void put_inuse(struct dquot *dquot) ...@@ -238,12 +238,12 @@ static inline void put_inuse(struct dquot *dquot)
/* We add to the back of inuse list so we don't have to restart /* We add to the back of inuse list so we don't have to restart
* when traversing this list and we block */ * when traversing this list and we block */
list_add(&dquot->dq_inuse, inuse_list.prev); list_add(&dquot->dq_inuse, inuse_list.prev);
++dqstats_array[DQSTATS_ALLOCATED]; dqstats.allocated_dquots++;
} }
static inline void remove_inuse(struct dquot *dquot) static inline void remove_inuse(struct dquot *dquot)
{ {
--dqstats_array[DQSTATS_ALLOCATED]; dqstats.allocated_dquots--;
list_del(&dquot->dq_inuse); list_del(&dquot->dq_inuse);
} }
...@@ -403,7 +403,7 @@ static int vfs_quota_sync(struct super_block *sb, int type) ...@@ -403,7 +403,7 @@ static int vfs_quota_sync(struct super_block *sb, int type)
for (cnt = 0; cnt < MAXQUOTAS; cnt++) for (cnt = 0; cnt < MAXQUOTAS; cnt++)
if ((cnt == type || type == -1) && sb_has_quota_enabled(sb, cnt) && info_dirty(&dqopt->info[cnt])) if ((cnt == type || type == -1) && sb_has_quota_enabled(sb, cnt) && info_dirty(&dqopt->info[cnt]))
dqopt->ops[cnt]->write_file_info(sb, cnt); dqopt->ops[cnt]->write_file_info(sb, cnt);
++dqstats_array[DQSTATS_SYNCS]; dqstats.syncs++;
return 0; return 0;
} }
...@@ -491,7 +491,7 @@ int shrink_dqcache_memory(int priority, unsigned int gfp_mask) ...@@ -491,7 +491,7 @@ int shrink_dqcache_memory(int priority, unsigned int gfp_mask)
int count = 0; int count = 0;
lock_kernel(); lock_kernel();
count = dqstats_array[DQSTATS_FREE] / priority; count = dqstats.free_dquots / priority;
prune_dqcache(count); prune_dqcache(count);
unlock_kernel(); unlock_kernel();
kmem_cache_shrink(dquot_cachep); kmem_cache_shrink(dquot_cachep);
...@@ -517,7 +517,7 @@ static void dqput(struct dquot *dquot) ...@@ -517,7 +517,7 @@ static void dqput(struct dquot *dquot)
} }
#endif #endif
++dqstats_array[DQSTATS_DROPS]; dqstats.drops++;
we_slept: we_slept:
if (dquot->dq_dup_ref && dquot->dq_count - dquot->dq_dup_ref <= 1) { /* Last unduplicated reference? */ if (dquot->dq_dup_ref && dquot->dq_count - dquot->dq_dup_ref <= 1) { /* Last unduplicated reference? */
__wait_dup_drop(dquot); __wait_dup_drop(dquot);
...@@ -597,7 +597,7 @@ static struct dquot *dqget(struct super_block *sb, unsigned int id, int type) ...@@ -597,7 +597,7 @@ static struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
if (!dquot->dq_count) if (!dquot->dq_count)
remove_free_dquot(dquot); remove_free_dquot(dquot);
get_dquot_ref(dquot); get_dquot_ref(dquot);
++dqstats_array[DQSTATS_CACHE_HITS]; dqstats.cache_hits++;
wait_on_dquot(dquot); wait_on_dquot(dquot);
if (empty) if (empty)
dqput(empty); dqput(empty);
...@@ -609,7 +609,7 @@ static struct dquot *dqget(struct super_block *sb, unsigned int id, int type) ...@@ -609,7 +609,7 @@ static struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
return NODQUOT; return NODQUOT;
} }
++dquot->dq_referenced; ++dquot->dq_referenced;
++dqstats_array[DQSTATS_LOOKUPS]; dqstats.lookups++;
return dquot; return dquot;
} }
...@@ -629,7 +629,7 @@ static struct dquot *dqduplicate(struct dquot *dquot) ...@@ -629,7 +629,7 @@ static struct dquot *dqduplicate(struct dquot *dquot)
printk(KERN_ERR "VFS: dqduplicate(): Locked quota to be duplicated!\n"); printk(KERN_ERR "VFS: dqduplicate(): Locked quota to be duplicated!\n");
get_dquot_dup_ref(dquot); get_dquot_dup_ref(dquot);
dquot->dq_referenced++; dquot->dq_referenced++;
++dqstats_array[DQSTATS_LOOKUPS]; dqstats.lookups++;
return dquot; return dquot;
} }
...@@ -645,7 +645,7 @@ static void dqputduplicate(struct dquot *dquot) ...@@ -645,7 +645,7 @@ static void dqputduplicate(struct dquot *dquot)
if (!dquot->dq_dup_ref) if (!dquot->dq_dup_ref)
wake_up(&dquot->dq_wait_free); wake_up(&dquot->dq_wait_free);
put_dquot_ref(dquot); put_dquot_ref(dquot);
++dqstats_array[DQSTATS_DROPS]; dqstats.drops++;
} }
static int dqinit_needed(struct inode *inode, int type) static int dqinit_needed(struct inode *inode, int type)
...@@ -1473,12 +1473,24 @@ struct quotactl_ops vfs_quotactl_ops = { ...@@ -1473,12 +1473,24 @@ struct quotactl_ops vfs_quotactl_ops = {
set_dqblk: vfs_set_dqblk set_dqblk: vfs_set_dqblk
}; };
static ctl_table fs_dqstats_table[] = {
{FS_DQ_LOOKUPS, "lookups", &dqstats.lookups, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_DROPS, "drops", &dqstats.drops, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_READS, "reads", &dqstats.reads, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_WRITES, "writes", &dqstats.writes, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_CACHE_HITS, "cache_hits", &dqstats.cache_hits, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_ALLOCATED, "allocated_dquots", &dqstats.allocated_dquots, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_FREE, "free_dquots", &dqstats.free_dquots, sizeof(int), 0444, NULL, &proc_dointvec},
{FS_DQ_SYNCS, "syncs", &dqstats.syncs, sizeof(int), 0444, NULL, &proc_dointvec},
{},
};
static ctl_table fs_table[] = { static ctl_table fs_table[] = {
{FS_DQSTATS, "dqstats", dqstats_array, sizeof(dqstats_array), 0444, NULL, &proc_dointvec}, {FS_DQSTATS, "quota", NULL, 0, 0555, fs_dqstats_table},
{}, {},
}; };
static ctl_table dquot_table[] = { static ctl_table sys_table[] = {
{CTL_FS, "fs", NULL, 0, 0555, fs_table}, {CTL_FS, "fs", NULL, 0, 0555, fs_table},
{}, {},
}; };
...@@ -1487,7 +1499,7 @@ static int __init dquot_init(void) ...@@ -1487,7 +1499,7 @@ static int __init dquot_init(void)
{ {
int i; int i;
register_sysctl_table(dquot_table, 0); register_sysctl_table(sys_table, 0);
for (i = 0; i < NR_DQHASH; i++) for (i = 0; i < NR_DQHASH; i++)
INIT_LIST_HEAD(dquot_hash + i); INIT_LIST_HEAD(dquot_hash + i);
printk(KERN_NOTICE "VFS: Disk quotas v%s\n", __DQUOT_VERSION__); printk(KERN_NOTICE "VFS: Disk quotas v%s\n", __DQUOT_VERSION__);
...@@ -1498,4 +1510,4 @@ __initcall(dquot_init); ...@@ -1498,4 +1510,4 @@ __initcall(dquot_init);
EXPORT_SYMBOL(register_quota_format); EXPORT_SYMBOL(register_quota_format);
EXPORT_SYMBOL(unregister_quota_format); EXPORT_SYMBOL(unregister_quota_format);
EXPORT_SYMBOL(dqstats_array); EXPORT_SYMBOL(dqstats);
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/namei.h>
#ifdef CONFIG_QIFACE_COMPAT #ifdef CONFIG_QIFACE_COMPAT
#include <linux/quotacompat.h> #include <linux/quotacompat.h>
#endif #endif
...@@ -410,7 +409,7 @@ static int v1_set_dqblk(struct super_block *sb, int type, int cmd, qid_t id, str ...@@ -410,7 +409,7 @@ static int v1_set_dqblk(struct super_block *sb, int type, int cmd, qid_t id, str
static void v1_get_stats(struct v1c_dqstats *dst) static void v1_get_stats(struct v1c_dqstats *dst)
{ {
memcpy(dst, &dqstats_array, sizeof(dqstats_array)); memcpy(dst, &dqstats, sizeof(dqstats));
} }
#endif #endif
...@@ -489,7 +488,7 @@ static int v2_set_dqblk(struct super_block *sb, int type, int cmd, qid_t id, str ...@@ -489,7 +488,7 @@ static int v2_set_dqblk(struct super_block *sb, int type, int cmd, qid_t id, str
static void v2_get_stats(struct v2c_dqstats *dst) static void v2_get_stats(struct v2c_dqstats *dst)
{ {
memcpy(dst, &dqstats_array, sizeof(dqstats_array)); memcpy(dst, &dqstats, sizeof(dqstats));
dst->version = __DQUOT_NUM_VERSION__; dst->version = __DQUOT_NUM_VERSION__;
} }
#endif #endif
......
...@@ -57,7 +57,7 @@ static int v1_read_dqblk(struct dquot *dquot) ...@@ -57,7 +57,7 @@ static int v1_read_dqblk(struct dquot *dquot)
if (dquot->dq_dqb.dqb_bhardlimit == 0 && dquot->dq_dqb.dqb_bsoftlimit == 0 && if (dquot->dq_dqb.dqb_bhardlimit == 0 && dquot->dq_dqb.dqb_bsoftlimit == 0 &&
dquot->dq_dqb.dqb_ihardlimit == 0 && dquot->dq_dqb.dqb_isoftlimit == 0) dquot->dq_dqb.dqb_ihardlimit == 0 && dquot->dq_dqb.dqb_isoftlimit == 0)
dquot->dq_flags |= DQ_FAKE; dquot->dq_flags |= DQ_FAKE;
++dqstats_array[DQSTATS_READS]; dqstats.reads++;
return 0; return 0;
} }
...@@ -101,7 +101,7 @@ static int v1_commit_dqblk(struct dquot *dquot) ...@@ -101,7 +101,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
out: out:
set_fs(fs); set_fs(fs);
++dqstats_array[DQSTATS_WRITES]; dqstats.writes++;
return ret; return ret;
} }
...@@ -234,6 +234,8 @@ static void __exit exit_v1_quota_format(void) ...@@ -234,6 +234,8 @@ static void __exit exit_v1_quota_format(void)
unregister_quota_format(&v1_quota_format); unregister_quota_format(&v1_quota_format);
} }
EXPORT_NO_SYMBOLS;
module_init(init_v1_quota_format); module_init(init_v1_quota_format);
module_exit(exit_v1_quota_format); module_exit(exit_v1_quota_format);
...@@ -430,7 +430,7 @@ static int v2_write_dquot(struct dquot *dquot) ...@@ -430,7 +430,7 @@ static int v2_write_dquot(struct dquot *dquot)
} }
else else
ret = 0; ret = 0;
++dqstats_array[DQSTATS_WRITES]; dqstats.writes++;
return ret; return ret;
} }
...@@ -645,7 +645,7 @@ static int v2_read_dquot(struct dquot *dquot) ...@@ -645,7 +645,7 @@ static int v2_read_dquot(struct dquot *dquot)
set_fs(fs); set_fs(fs);
disk2memdqb(&dquot->dq_dqb, &ddquot); disk2memdqb(&dquot->dq_dqb, &ddquot);
} }
++dqstats_array[DQSTATS_READS]; dqstats.reads++;
return ret; return ret;
} }
...@@ -686,5 +686,7 @@ static void __exit exit_v2_quota_format(void) ...@@ -686,5 +686,7 @@ static void __exit exit_v2_quota_format(void)
unregister_quota_format(&v2_quota_format); unregister_quota_format(&v2_quota_format);
} }
EXPORT_NO_SYMBOLS;
module_init(init_v2_quota_format); module_init(init_v2_quota_format);
module_exit(exit_v2_quota_format); module_exit(exit_v2_quota_format);
...@@ -184,22 +184,18 @@ extern inline void mark_info_dirty(struct mem_dqinfo *info) ...@@ -184,22 +184,18 @@ extern inline void mark_info_dirty(struct mem_dqinfo *info)
#define sb_dqopt(sb) (&(sb)->s_dquot) #define sb_dqopt(sb) (&(sb)->s_dquot)
/* struct dqstats {
* Statistics about disc quota. int lookups;
*/ int drops;
enum { int reads;
DQSTATS_LOOKUPS, int writes;
DQSTATS_DROPS, int cache_hits;
DQSTATS_READS, int allocated_dquots;
DQSTATS_WRITES, int free_dquots;
DQSTATS_CACHE_HITS, int syncs;
DQSTATS_ALLOCATED,
DQSTATS_FREE,
DQSTATS_SYNCS,
DQSTATS_SIZE
}; };
extern __u32 dqstats_array[DQSTATS_SIZE]; extern struct dqstats dqstats;
#define NR_DQHASH 43 /* Just an arbitrary number */ #define NR_DQHASH 43 /* Just an arbitrary number */
......
...@@ -544,7 +544,19 @@ enum ...@@ -544,7 +544,19 @@ enum
FS_LEASES=13, /* int: leases enabled */ FS_LEASES=13, /* int: leases enabled */
FS_DIR_NOTIFY=14, /* int: directory notification enabled */ FS_DIR_NOTIFY=14, /* int: directory notification enabled */
FS_LEASE_TIME=15, /* int: maximum time to wait for a lease break */ FS_LEASE_TIME=15, /* int: maximum time to wait for a lease break */
FS_DQSTATS=16, /* int: disc quota suage statistics */ FS_DQSTATS=16, /* disc quota usage statistics */
};
/* /proc/sys/fs/quota/ */
enum {
FS_DQ_LOOKUPS = 1,
FS_DQ_DROPS = 2,
FS_DQ_READS = 3,
FS_DQ_WRITES = 4,
FS_DQ_CACHE_HITS = 5,
FS_DQ_ALLOCATED = 6,
FS_DQ_FREE = 7,
FS_DQ_SYNCS = 8,
}; };
/* CTL_DEBUG names: */ /* CTL_DEBUG names: */
......
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