From 0f0dd62fddcbd0f6830ed8ef3d3426ccc46b9250 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:41 -0400 Subject: quota: kill the vfs_dq_off and vfs_dq_quota_on_remount wrappers Instead of having wrappers in the VFS namespace export the dquot_suspend and dquot_resume helpers directly. Also rename vfs_quota_disable to dquot_disable while we're at it. [Jan Kara: Moved dquot_suspend to quotaops.h and made it inline] Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- include/linux/quotaops.h | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 370abb1e99c..811529241e3 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -50,6 +50,14 @@ int dquot_alloc_inode(const struct inode *inode); int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); void dquot_free_inode(const struct inode *inode); +int dquot_disable(struct super_block *sb, int type, unsigned int flags); +/* Suspend quotas on remount RO */ +static inline int dquot_suspend(struct super_block *sb, int type) +{ + return dquot_disable(sb, type, DQUOT_SUSPENDED); +} +int dquot_resume(struct super_block *sb, int type); + int dquot_commit(struct dquot *dquot); int dquot_acquire(struct dquot *dquot); int dquot_release(struct dquot *dquot); @@ -67,7 +75,6 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id, int vfs_quota_on_mount(struct super_block *sb, char *qf_name, int format_id, int type); int vfs_quota_off(struct super_block *sb, int type, int remount); -int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); int vfs_quota_sync(struct super_block *sb, int type, int wait); int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); @@ -78,7 +85,6 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); int dquot_transfer(struct inode *inode, struct iattr *iattr); -int vfs_dq_quota_on_remount(struct super_block *sb); static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) { @@ -231,11 +237,6 @@ static inline int vfs_dq_off(struct super_block *sb, int remount) return 0; } -static inline int vfs_dq_quota_on_remount(struct super_block *sb) -{ - return 0; -} - static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) { return 0; @@ -262,6 +263,22 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) return 0; } +static inline int dquot_disable(struct super_block *sb, int type, + unsigned int flags) +{ + return 0; +} + +static inline int dquot_suspend(struct super_block *sb, int type) +{ + return 0; +} + +static inline int dquot_resume(struct super_block *sb, int type) +{ + return 0; +} + #define dquot_file_open generic_file_open #endif /* CONFIG_QUOTA */ -- cgit v1.2.3 From e0ccfd959cd8907bcb66cc2042e0f4fd7fcbff2b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:42 -0400 Subject: quota: move unmount handling into the filesystem Currently the VFS calls into the quotactl interface for unmounting filesystems. This means filesystems with their own quota handling can't easily distinguish between user-space originating quotaoff and an unount. Instead move the responsibily of the unmount handling into the filesystem to be consistent with all other dquot handling. Note that we do call dquot_disable a lot later now, e.g. after a sync_filesystem. But this is fine as the quota code does all its writes via blockdev's mapping and that is synced even later. Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- include/linux/quotaops.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'include') diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 811529241e3..cfa2abb1b6d 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -156,16 +156,6 @@ extern const struct quotactl_ops vfs_quotactl_ops; #define sb_dquot_ops (&dquot_operations) #define sb_quotactl_ops (&vfs_quotactl_ops) -/* Cannot be called inside a transaction */ -static inline int vfs_dq_off(struct super_block *sb, int remount) -{ - int ret = -ENOSYS; - - if (sb->s_qcop && sb->s_qcop->quota_off) - ret = sb->s_qcop->quota_off(sb, -1, remount); - return ret; -} - #else static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) @@ -232,11 +222,6 @@ static inline void dquot_free_inode(const struct inode *inode) { } -static inline int vfs_dq_off(struct super_block *sb, int remount) -{ - return 0; -} - static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) { return 0; -- cgit v1.2.3 From 307ae18a56e5b706056a2050d52e8cc01b5171c0 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:43 -0400 Subject: quota: drop remount argument to ->quota_on and ->quota_off Remount handling has fully moved into the filesystem, so all this is superflous now. Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- include/linux/quota.h | 4 ++-- include/linux/quotaops.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/quota.h b/include/linux/quota.h index 7126a15467f..2789d07c37b 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h @@ -332,8 +332,8 @@ struct dquot_operations { /* Operations handling requests from userspace */ struct quotactl_ops { - int (*quota_on)(struct super_block *, int, int, char *, int); - int (*quota_off)(struct super_block *, int, int); + int (*quota_on)(struct super_block *, int, int, char *); + int (*quota_off)(struct super_block *, int); int (*quota_sync)(struct super_block *, int, int); int (*get_info)(struct super_block *, int, struct if_dqinfo *); int (*set_info)(struct super_block *, int, struct if_dqinfo *); diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index cfa2abb1b6d..a6592ddc349 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -67,14 +67,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot); int dquot_file_open(struct inode *inode, struct file *file); int vfs_quota_on(struct super_block *sb, int type, int format_id, - char *path, int remount); + char *path); int vfs_quota_enable(struct inode *inode, int type, int format_id, unsigned int flags); int vfs_quota_on_path(struct super_block *sb, int type, int format_id, struct path *path); int vfs_quota_on_mount(struct super_block *sb, char *qf_name, int format_id, int type); -int vfs_quota_off(struct super_block *sb, int type, int remount); +int vfs_quota_off(struct super_block *sb, int type); int vfs_quota_sync(struct super_block *sb, int type, int wait); int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); -- cgit v1.2.3 From 123e9caf1e85008ab7eb5f6cd58c44f9a5d73b2b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:44 -0400 Subject: quota: explicitly set ->dq_op and ->s_qcop Only set the quota operation vectors if the filesystem actually supports quota instead of doing it for all filesystems in alloc_super(). [Jan Kara: Export dquot_operations and vfs_quotactl_ops] Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- include/linux/quotaops.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include') diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index a6592ddc349..84b8dbf59c0 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -153,9 +153,6 @@ static inline unsigned sb_any_quota_active(struct super_block *sb) extern const struct dquot_operations dquot_operations; extern const struct quotactl_ops vfs_quotactl_ops; -#define sb_dquot_ops (&dquot_operations) -#define sb_quotactl_ops (&vfs_quotactl_ops) - #else static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) @@ -199,12 +196,6 @@ static inline int sb_any_quota_active(struct super_block *sb) return 0; } -/* - * NO-OP when quota not configured. - */ -#define sb_dquot_ops (NULL) -#define sb_quotactl_ops (NULL) - static inline void dquot_initialize(struct inode *inode) { } -- cgit v1.2.3 From 287a80958cf63fc5c68d5bf6e89a3669dd66234a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:45 -0400 Subject: quota: rename default quotactl methods to dquot_ Follow the dquot_* style used elsewhere in dquot.c. [Jan Kara: Fixed up missing conversion of ext2] Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- include/linux/quotaops.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 84b8dbf59c0..0c77cd8d282 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -66,21 +66,21 @@ int dquot_mark_dquot_dirty(struct dquot *dquot); int dquot_file_open(struct inode *inode, struct file *file); -int vfs_quota_on(struct super_block *sb, int type, int format_id, +int dquot_quota_on(struct super_block *sb, int type, int format_id, char *path); -int vfs_quota_enable(struct inode *inode, int type, int format_id, +int dquot_enable(struct inode *inode, int type, int format_id, unsigned int flags); -int vfs_quota_on_path(struct super_block *sb, int type, int format_id, +int dquot_quota_on_path(struct super_block *sb, int type, int format_id, struct path *path); -int vfs_quota_on_mount(struct super_block *sb, char *qf_name, +int dquot_quota_on_mount(struct super_block *sb, char *qf_name, int format_id, int type); -int vfs_quota_off(struct super_block *sb, int type); -int vfs_quota_sync(struct super_block *sb, int type, int wait); -int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); -int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); -int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, +int dquot_quota_off(struct super_block *sb, int type); +int dquot_quota_sync(struct super_block *sb, int type, int wait); +int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); +int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); +int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, struct fs_disk_quota *di); -int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, +int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, struct fs_disk_quota *di); int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); @@ -151,7 +151,7 @@ static inline unsigned sb_any_quota_active(struct super_block *sb) * Operations supported for diskquotas. */ extern const struct dquot_operations dquot_operations; -extern const struct quotactl_ops vfs_quotactl_ops; +extern const struct quotactl_ops dquot_quotactl_ops; #else -- cgit v1.2.3 From f32764bd2bbb6ea003c158b1d276b4dc9f900348 Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Wed, 26 May 2010 23:21:58 +0200 Subject: quota: Convert quota statistics to generic percpu_counter Generic per-cpu counter has some memory overhead but it is negligible for modern systems and embedded systems compile without quota support. And code reuse is a good thing. This patch should fix complain from preemptive kernels which was introduced by dde9588853b1bde. [Jan Kara: Fixed patch to work on 32-bit archs as well] Reported-by: Rafael J. Wysocki Signed-off-by: Dmitry Monakhov Signed-off-by: Jan Kara --- include/linux/quota.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/linux/quota.h b/include/linux/quota.h index 2789d07c37b..94c1f03b50e 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h @@ -174,8 +174,7 @@ enum { #include #include #include -#include -#include +#include #include #include @@ -254,6 +253,7 @@ enum { struct dqstats { int stat[_DQST_DQSTAT_LAST]; + struct percpu_counter counter[_DQST_DQSTAT_LAST]; }; extern struct dqstats *dqstats_pcpu; @@ -261,20 +261,12 @@ extern struct dqstats dqstats; static inline void dqstats_inc(unsigned int type) { -#ifdef CONFIG_SMP - per_cpu_ptr(dqstats_pcpu, smp_processor_id())->stat[type]++; -#else - dqstats.stat[type]++; -#endif + percpu_counter_inc(&dqstats.counter[type]); } static inline void dqstats_dec(unsigned int type) { -#ifdef CONFIG_SMP - per_cpu_ptr(dqstats_pcpu, smp_processor_id())->stat[type]--; -#else - dqstats.stat[type]--; -#endif + percpu_counter_dec(&dqstats.counter[type]); } #define DQ_MOD_B 0 /* dquot modified since read */ -- cgit v1.2.3