]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Quota update [2/3]
authorJan Kara <jack@suse.cz>
Wed, 29 May 2002 02:45:00 +0000 (19:45 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Wed, 29 May 2002 02:45:00 +0000 (19:45 -0700)
This changes the sysctl interface to use reasonable names in
/proc/sys/fs/quota/

fs/dquot.c
fs/quota.c
fs/quota_v1.c
fs/quota_v2.c
include/linux/quota.h
include/linux/sysctl.h

index 0304056b4c2eb8f67a6f15085ebead50b1270966..244b82b3d135e7d58fa75af7ec783395cc58d39a 100644 (file)
@@ -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,
  * 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
- * 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.
  *
  * Dquots with a specific identity (device, type and id) are placed on
@@ -148,7 +148,7 @@ static LIST_HEAD(inuse_list);
 static LIST_HEAD(free_dquots);
 static struct list_head dquot_hash[NR_DQHASH];
 
-__u32 dqstats_array[DQSTATS_SIZE];
+struct dqstats dqstats;
 
 static void dqput(struct dquot *);
 static struct dquot *dqduplicate(struct dquot *);
@@ -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)
 {
        list_add(&dquot->dq_free, &free_dquots);
-       ++dqstats_array[DQSTATS_FREE];
+       dqstats.free_dquots++;
 }
 
 /* Add a dquot to the tail of the free list */
 static inline void put_dquot_last(struct dquot *dquot)
 {
        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) */
@@ -230,7 +230,7 @@ static inline void remove_free_dquot(struct dquot *dquot)
                return;
        list_del(&dquot->dq_free);
        INIT_LIST_HEAD(&dquot->dq_free);
-       --dqstats_array[DQSTATS_FREE];
+       dqstats.free_dquots--;
 }
 
 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
         * when traversing this list and we block */
        list_add(&dquot->dq_inuse, inuse_list.prev);
-       ++dqstats_array[DQSTATS_ALLOCATED];
+       dqstats.allocated_dquots++;
 }
 
 static inline void remove_inuse(struct dquot *dquot)
 {
-       --dqstats_array[DQSTATS_ALLOCATED];
+       dqstats.allocated_dquots--;
        list_del(&dquot->dq_inuse);
 }
 
@@ -403,7 +403,7 @@ restart:
        for (cnt = 0; cnt < MAXQUOTAS; 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);
-       ++dqstats_array[DQSTATS_SYNCS];
+       dqstats.syncs++;
 
        return 0;
 }
@@ -491,7 +491,7 @@ int shrink_dqcache_memory(int priority, unsigned int gfp_mask)
        int count = 0;
 
        lock_kernel();
-       count = dqstats_array[DQSTATS_FREE] / priority;
+       count = dqstats.free_dquots / priority;
        prune_dqcache(count);
        unlock_kernel();
        kmem_cache_shrink(dquot_cachep);
@@ -517,7 +517,7 @@ static void dqput(struct dquot *dquot)
        }
 #endif
 
-       ++dqstats_array[DQSTATS_DROPS];
+       dqstats.drops++;
 we_slept:
        if (dquot->dq_dup_ref && dquot->dq_count - dquot->dq_dup_ref <= 1) {    /* Last unduplicated reference? */
                __wait_dup_drop(dquot);
@@ -597,7 +597,7 @@ we_slept:
                if (!dquot->dq_count)
                        remove_free_dquot(dquot);
                get_dquot_ref(dquot);
-               ++dqstats_array[DQSTATS_CACHE_HITS];
+               dqstats.cache_hits++;
                wait_on_dquot(dquot);
                if (empty)
                        dqput(empty);
@@ -609,7 +609,7 @@ we_slept:
                return NODQUOT;
        }
        ++dquot->dq_referenced;
-       ++dqstats_array[DQSTATS_LOOKUPS];
+       dqstats.lookups++;
 
        return dquot;
 }
@@ -629,7 +629,7 @@ static struct dquot *dqduplicate(struct dquot *dquot)
                printk(KERN_ERR "VFS: dqduplicate(): Locked quota to be duplicated!\n");
        get_dquot_dup_ref(dquot);
        dquot->dq_referenced++;
-       ++dqstats_array[DQSTATS_LOOKUPS];
+       dqstats.lookups++;
 
        return dquot;
 }
@@ -645,7 +645,7 @@ static void dqputduplicate(struct dquot *dquot)
        if (!dquot->dq_dup_ref)
                wake_up(&dquot->dq_wait_free);
        put_dquot_ref(dquot);
-       ++dqstats_array[DQSTATS_DROPS];
+       dqstats.drops++;
 }
 
 static int dqinit_needed(struct inode *inode, int type)
@@ -1473,12 +1473,24 @@ struct quotactl_ops vfs_quotactl_ops = {
        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[] = {
-       {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},
        {},
 };
@@ -1487,7 +1499,7 @@ static int __init dquot_init(void)
 {
        int i;
 
-       register_sysctl_table(dquot_table, 0);
+       register_sysctl_table(sys_table, 0);
        for (i = 0; i < NR_DQHASH; i++)
                INIT_LIST_HEAD(dquot_hash + i);
        printk(KERN_NOTICE "VFS: Disk quotas v%s\n", __DQUOT_VERSION__);
@@ -1498,4 +1510,4 @@ __initcall(dquot_init);
 
 EXPORT_SYMBOL(register_quota_format);
 EXPORT_SYMBOL(unregister_quota_format);
-EXPORT_SYMBOL(dqstats_array);
+EXPORT_SYMBOL(dqstats);
index 422e4cf7ce1279dbd02072a15a5101cc472d87b3..ec2a5098fee0c95db9c5c809f999f239317dc9e5 100644 (file)
@@ -11,7 +11,6 @@
 #include <asm/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/smp_lock.h>
-#include <linux/namei.h>
 #ifdef CONFIG_QIFACE_COMPAT
 #include <linux/quotacompat.h>
 #endif
@@ -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)
 {
-       memcpy(dst, &dqstats_array, sizeof(dqstats_array));
+       memcpy(dst, &dqstats, sizeof(dqstats));
 }
 #endif
 
@@ -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)
 {
-       memcpy(dst, &dqstats_array, sizeof(dqstats_array));
+       memcpy(dst, &dqstats, sizeof(dqstats));
        dst->version = __DQUOT_NUM_VERSION__;
 }
 #endif
index 5c1880ae075eb886b0f70ff1e310fc987c37c58f..1ddcb0e8794490a08d42c76daa98e66f13da3c18 100644 (file)
@@ -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 &&
            dquot->dq_dqb.dqb_ihardlimit == 0 && dquot->dq_dqb.dqb_isoftlimit == 0)
                dquot->dq_flags |= DQ_FAKE;
-       ++dqstats_array[DQSTATS_READS];
+       dqstats.reads++;
 
        return 0;
 }
@@ -101,7 +101,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
 
 out:
        set_fs(fs);
-       ++dqstats_array[DQSTATS_WRITES];
+       dqstats.writes++;
 
        return ret;
 }
@@ -234,6 +234,8 @@ static void __exit exit_v1_quota_format(void)
         unregister_quota_format(&v1_quota_format);
 }
 
+EXPORT_NO_SYMBOLS;
+
 module_init(init_v1_quota_format);
 module_exit(exit_v1_quota_format);
 
index 8c727cdac609dc8f9aa327f64bc4bb51d7062fce..d617121f051176d299563505eff33d83a215139d 100644 (file)
@@ -430,7 +430,7 @@ static int v2_write_dquot(struct dquot *dquot)
        }
        else
                ret = 0;
-       ++dqstats_array[DQSTATS_WRITES];
+       dqstats.writes++;
 
        return ret;
 }
@@ -645,7 +645,7 @@ static int v2_read_dquot(struct dquot *dquot)
                set_fs(fs);
                disk2memdqb(&dquot->dq_dqb, &ddquot);
        }
-       ++dqstats_array[DQSTATS_READS];
+       dqstats.reads++;
 
        return ret;
 }
@@ -686,5 +686,7 @@ static void __exit exit_v2_quota_format(void)
        unregister_quota_format(&v2_quota_format);
 }
 
+EXPORT_NO_SYMBOLS;
+
 module_init(init_v2_quota_format);
 module_exit(exit_v2_quota_format);
index 1a9d178c57bcc317bdc58a94650e673f5a3a1bed..bdaca4b905921528eb24013768ab9a2d74a6afaf 100644 (file)
@@ -184,22 +184,18 @@ extern inline void mark_info_dirty(struct mem_dqinfo *info)
 
 #define sb_dqopt(sb) (&(sb)->s_dquot)
 
-/*
- * Statistics about disc quota.
- */
-enum {
-       DQSTATS_LOOKUPS,
-       DQSTATS_DROPS,
-       DQSTATS_READS,
-       DQSTATS_WRITES,
-       DQSTATS_CACHE_HITS,
-       DQSTATS_ALLOCATED,
-       DQSTATS_FREE,
-       DQSTATS_SYNCS,
-       DQSTATS_SIZE
+struct dqstats {
+       int lookups;
+       int drops;
+       int reads;
+       int writes;
+       int cache_hits;
+       int allocated_dquots;
+       int free_dquots;
+       int syncs;
 };
 
-extern __u32 dqstats_array[DQSTATS_SIZE];
+extern struct dqstats dqstats;
 
 #define NR_DQHASH 43            /* Just an arbitrary number */
 
index 373d20b4c4a745ae4428187bfc795f53524d95d7..a5a6684f9a5024d3bb7269ae9f705a494956a07b 100644 (file)
@@ -544,7 +544,19 @@ enum
        FS_LEASES=13,   /* int: leases enabled */
        FS_DIR_NOTIFY=14,       /* int: directory notification enabled */
        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: */