1 quota: sb_quota state flags clean
3 - convert int to bool for appropriate functions
4 - remove hardcoded USRQUOTA/GRPQUOTA flags
5 I dont expect any performance regressions here.
6 STATUS: this is amazing, but i've missed some flags :(
8 move DQUOT_QUOTA_SYS_FILE and rest to the end of the quotas flags
9 reorganize perquota flags near to each other in order to make
10 any_XXX_func() more quick.
11 diff --git a/include/linux/quota.h b/include/linux/quota.h
12 index f279c51..dc65aa6 100644
13 --- a/include/linux/quota.h
14 +++ b/include/linux/quota.h
15 @@ -355,26 +355,25 @@ enum {
16 #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \
18 /* Other quota flags */
19 -#define DQUOT_QUOTA_SYS_FILE (1 << 6) /* Quota file is a special
20 +#define DQUOT_STALE_LAST (_DQUOT_STATE_FLAGS * MAXQUOTAS)
21 +#define DQUOT_QUOTA_SYS_FILE (1 << DQUOT_STALE_LAST)
22 + /* Quota file is a special
23 * system file and user cannot
24 * touch it. Filesystem is
25 * responsible for setting
26 * S_NOQUOTA, S_NOATIME flags
28 -#define DQUOT_NEGATIVE_USAGE (1 << 7) /* Allow negative quota usage */
29 +#define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STALE_LAST +1))
30 + /* Allow negative quota usage */
32 static inline unsigned int dquot_state_flag(unsigned int flags, int type)
34 - if (type == USRQUOTA)
36 - return flags << _DQUOT_STATE_FLAGS;
37 + return flags << _DQUOT_STATE_FLAGS * type;
40 static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
42 - if (type == USRQUOTA)
44 - return flags >> _DQUOT_STATE_FLAGS;
45 + return flags >> _DQUOT_STATE_FLAGS * type;
49 diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
50 index b194878..a4f248e 100644
51 --- a/include/linux/quotaops.h
52 +++ b/include/linux/quotaops.h
53 @@ -84,53 +84,58 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
54 * Functions for checking status of quota
57 -static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type)
58 +static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
60 return sb_dqopt(sb)->flags &
61 dquot_state_flag(DQUOT_USAGE_ENABLED, type);
64 -static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type)
65 +static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type)
67 return sb_dqopt(sb)->flags &
68 dquot_state_flag(DQUOT_LIMITS_ENABLED, type);
71 -static inline int sb_has_quota_suspended(struct super_block *sb, int type)
72 +static inline bool sb_has_quota_suspended(struct super_block *sb, int type)
74 return sb_dqopt(sb)->flags &
75 dquot_state_flag(DQUOT_SUSPENDED, type);
78 -static inline int sb_any_quota_suspended(struct super_block *sb)
79 +static inline unsigned sb_any_quota_suspended(struct super_block *sb)
81 - return sb_has_quota_suspended(sb, USRQUOTA) ||
82 - sb_has_quota_suspended(sb, GRPQUOTA);
85 + for (type = 0; type < MAXQUOTAS; type++)
86 + tmsk |= sb_has_quota_suspended(sb, type) << type;
90 /* Does kernel know about any quota information for given sb + type? */
91 -static inline int sb_has_quota_loaded(struct super_block *sb, int type)
92 +static inline bool sb_has_quota_loaded(struct super_block *sb, int type)
94 /* Currently if anything is on, then quota usage is on as well */
95 return sb_has_quota_usage_enabled(sb, type);
98 -static inline int sb_any_quota_loaded(struct super_block *sb)
99 +static inline unsigned sb_any_quota_loaded(struct super_block *sb)
101 - return sb_has_quota_loaded(sb, USRQUOTA) ||
102 - sb_has_quota_loaded(sb, GRPQUOTA);
105 + for (type = 0; type < MAXQUOTAS; type++)
106 + tmsk |= sb_has_quota_loaded(sb, type) << type;
110 -static inline int sb_has_quota_active(struct super_block *sb, int type)
111 +static inline bool sb_has_quota_active(struct super_block *sb, int type)
113 return sb_has_quota_loaded(sb, type) &&
114 !sb_has_quota_suspended(sb, type);
117 -static inline int sb_any_quota_active(struct super_block *sb)
118 +static inline unsigned sb_any_quota_active(struct super_block *sb)
120 - return sb_has_quota_active(sb, USRQUOTA) ||
121 - sb_has_quota_active(sb, GRPQUOTA);
122 + return sb_any_quota_loaded(sb);
126 @@ -146,8 +151,11 @@ extern const struct quotactl_ops vfs_quotactl_ops;
127 * need a lot of space in journal for dquot structure allocation. */
128 static inline void vfs_dq_init(struct inode *inode)
131 BUG_ON(!inode->i_sb);
132 - if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode))
133 + tmsk = sb_any_quota_active(inode->i_sb);
134 + if (tmsk && !IS_NOQUOTA(inode))
135 + ////FIXME: pass tmsk to ->initialize(inode, tmsk)
136 inode->i_sb->dq_op->initialize(inode, -1);