Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Definitions for diskquota-operations. When diskquota is configured these |
| 3 | * macros expand to the right source-code. |
| 4 | * |
| 5 | * Author: Marco van Wieringen <mvw@planets.elm.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #ifndef _LINUX_QUOTAOPS_ |
| 8 | #define _LINUX_QUOTAOPS_ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/smp_lock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/fs.h> |
| 12 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 13 | static inline struct quota_info *sb_dqopt(struct super_block *sb) |
| 14 | { |
| 15 | return &sb->s_dquot; |
| 16 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #if defined(CONFIG_QUOTA) |
| 19 | |
| 20 | /* |
| 21 | * declaration of quota_function calls in kernel. |
| 22 | */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 23 | void sync_dquots(struct super_block *sb, int type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 25 | int dquot_initialize(struct inode *inode, int type); |
| 26 | int dquot_drop(struct inode *inode); |
Jan Kara | 3d9ea25 | 2008-10-10 16:12:23 +0200 | [diff] [blame] | 27 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type); |
| 28 | void dqput(struct dquot *dquot); |
Jan Kara | 12c7752 | 2008-10-20 17:05:00 +0200 | [diff] [blame] | 29 | int dquot_scan_active(struct super_block *sb, |
| 30 | int (*fn)(struct dquot *dquot, unsigned long priv), |
| 31 | unsigned long priv); |
Jan Kara | 7d9056b | 2008-11-25 15:31:32 +0100 | [diff] [blame] | 32 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
| 33 | void dquot_destroy(struct dquot *dquot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 35 | int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); |
Jan Kara | 1209546 | 2008-08-20 14:45:12 +0200 | [diff] [blame] | 36 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Mingming Cao | 740d9dc | 2009-01-13 16:43:14 +0100 | [diff] [blame] | 38 | int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); |
| 39 | int dquot_claim_space(struct inode *inode, qsize_t number); |
| 40 | void dquot_release_reserved_space(struct inode *inode, qsize_t number); |
| 41 | qsize_t dquot_get_reserved_space(struct inode *inode); |
| 42 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 43 | int dquot_free_space(struct inode *inode, qsize_t number); |
Jan Kara | 1209546 | 2008-08-20 14:45:12 +0200 | [diff] [blame] | 44 | int dquot_free_inode(const struct inode *inode, qsize_t number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 46 | int dquot_transfer(struct inode *inode, struct iattr *iattr); |
| 47 | int dquot_commit(struct dquot *dquot); |
| 48 | int dquot_acquire(struct dquot *dquot); |
| 49 | int dquot_release(struct dquot *dquot); |
| 50 | int dquot_commit_info(struct super_block *sb, int type); |
| 51 | int dquot_mark_dquot_dirty(struct dquot *dquot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 53 | int vfs_quota_on(struct super_block *sb, int type, int format_id, |
| 54 | char *path, int remount); |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 55 | int vfs_quota_enable(struct inode *inode, int type, int format_id, |
| 56 | unsigned int flags); |
Al Viro | 77e69da | 2008-08-01 04:29:18 -0400 | [diff] [blame] | 57 | int vfs_quota_on_path(struct super_block *sb, int type, int format_id, |
| 58 | struct path *path); |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 59 | int vfs_quota_on_mount(struct super_block *sb, char *qf_name, |
| 60 | int format_id, int type); |
| 61 | int vfs_quota_off(struct super_block *sb, int type, int remount); |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 62 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 63 | int vfs_quota_sync(struct super_block *sb, int type); |
| 64 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
| 65 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
| 66 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); |
| 67 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); |
| 68 | |
| 69 | void vfs_dq_drop(struct inode *inode); |
| 70 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr); |
| 71 | int vfs_dq_quota_on_remount(struct super_block *sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 73 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) |
| 74 | { |
| 75 | return sb_dqopt(sb)->info + type; |
| 76 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * Functions for checking status of quota |
| 80 | */ |
| 81 | |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 82 | static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 83 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 84 | return sb_dqopt(sb)->flags & |
| 85 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 86 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 87 | |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 88 | static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 89 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 90 | return sb_dqopt(sb)->flags & |
| 91 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 92 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 93 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 94 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) |
| 95 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 96 | return sb_dqopt(sb)->flags & |
| 97 | dquot_state_flag(DQUOT_SUSPENDED, type); |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 98 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 99 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 100 | static inline int sb_any_quota_suspended(struct super_block *sb) |
| 101 | { |
| 102 | return sb_has_quota_suspended(sb, USRQUOTA) || |
| 103 | sb_has_quota_suspended(sb, GRPQUOTA); |
| 104 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 105 | |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 106 | /* Does kernel know about any quota information for given sb + type? */ |
| 107 | static inline int sb_has_quota_loaded(struct super_block *sb, int type) |
| 108 | { |
| 109 | /* Currently if anything is on, then quota usage is on as well */ |
| 110 | return sb_has_quota_usage_enabled(sb, type); |
| 111 | } |
| 112 | |
| 113 | static inline int sb_any_quota_loaded(struct super_block *sb) |
| 114 | { |
| 115 | return sb_has_quota_loaded(sb, USRQUOTA) || |
| 116 | sb_has_quota_loaded(sb, GRPQUOTA); |
| 117 | } |
| 118 | |
| 119 | static inline int sb_has_quota_active(struct super_block *sb, int type) |
| 120 | { |
| 121 | return sb_has_quota_loaded(sb, type) && |
| 122 | !sb_has_quota_suspended(sb, type); |
| 123 | } |
| 124 | |
| 125 | static inline int sb_any_quota_active(struct super_block *sb) |
| 126 | { |
| 127 | return sb_has_quota_active(sb, USRQUOTA) || |
| 128 | sb_has_quota_active(sb, GRPQUOTA); |
| 129 | } |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | /* |
| 132 | * Operations supported for diskquotas. |
| 133 | */ |
| 134 | extern struct dquot_operations dquot_operations; |
| 135 | extern struct quotactl_ops vfs_quotactl_ops; |
| 136 | |
| 137 | #define sb_dquot_ops (&dquot_operations) |
| 138 | #define sb_quotactl_ops (&vfs_quotactl_ops) |
| 139 | |
| 140 | /* It is better to call this function outside of any transaction as it might |
| 141 | * need a lot of space in journal for dquot structure allocation. */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 142 | static inline void vfs_dq_init(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | { |
| 144 | BUG_ON(!inode->i_sb); |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 145 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | inode->i_sb->dq_op->initialize(inode, -1); |
| 147 | } |
| 148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | /* The following allocation/freeing/transfer functions *must* be called inside |
| 150 | * a transaction (deadlocks possible otherwise) */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 151 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 153 | if (sb_any_quota_active(inode->i_sb)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | /* Used space is updated in alloc_space() */ |
| 155 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) |
| 156 | return 1; |
| 157 | } |
| 158 | else |
| 159 | inode_add_bytes(inode, nr); |
| 160 | return 0; |
| 161 | } |
| 162 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 163 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | { |
| 165 | int ret; |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 166 | if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | mark_inode_dirty(inode); |
| 168 | return ret; |
| 169 | } |
| 170 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 171 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 173 | if (sb_any_quota_active(inode->i_sb)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | /* Used space is updated in alloc_space() */ |
| 175 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) |
| 176 | return 1; |
| 177 | } |
| 178 | else |
| 179 | inode_add_bytes(inode, nr); |
| 180 | return 0; |
| 181 | } |
| 182 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 183 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | int ret; |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 186 | if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | mark_inode_dirty(inode); |
| 188 | return ret; |
| 189 | } |
| 190 | |
Mingming Cao | f18df22 | 2009-01-13 16:43:09 +0100 | [diff] [blame] | 191 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) |
| 192 | { |
| 193 | if (sb_any_quota_active(inode->i_sb)) { |
| 194 | /* Used space is updated in alloc_space() */ |
| 195 | if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) |
| 196 | return 1; |
| 197 | } |
| 198 | return 0; |
| 199 | } |
| 200 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 201 | static inline int vfs_dq_alloc_inode(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 203 | if (sb_any_quota_active(inode->i_sb)) { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 204 | vfs_dq_init(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) |
| 206 | return 1; |
| 207 | } |
| 208 | return 0; |
| 209 | } |
| 210 | |
Mingming Cao | 740d9dc | 2009-01-13 16:43:14 +0100 | [diff] [blame] | 211 | /* |
| 212 | * Convert in-memory reserved quotas to real consumed quotas |
| 213 | */ |
| 214 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) |
| 215 | { |
| 216 | if (sb_any_quota_active(inode->i_sb)) { |
| 217 | if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) |
| 218 | return 1; |
| 219 | } else |
| 220 | inode_add_bytes(inode, nr); |
| 221 | |
| 222 | mark_inode_dirty(inode); |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | /* |
| 227 | * Release reserved (in-memory) quotas |
| 228 | */ |
| 229 | static inline |
| 230 | void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) |
| 231 | { |
| 232 | if (sb_any_quota_active(inode->i_sb)) |
| 233 | inode->i_sb->dq_op->release_rsv(inode, nr); |
| 234 | } |
| 235 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 236 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 238 | if (sb_any_quota_active(inode->i_sb)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | inode->i_sb->dq_op->free_space(inode, nr); |
| 240 | else |
| 241 | inode_sub_bytes(inode, nr); |
| 242 | } |
| 243 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 244 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 246 | vfs_dq_free_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | mark_inode_dirty(inode); |
| 248 | } |
| 249 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 250 | static inline void vfs_dq_free_inode(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | { |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 252 | if (sb_any_quota_active(inode->i_sb)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | inode->i_sb->dq_op->free_inode(inode, 1); |
| 254 | } |
| 255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | /* The following two functions cannot be called inside a transaction */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 257 | static inline void vfs_dq_sync(struct super_block *sb) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 258 | { |
| 259 | sync_dquots(sb, -1); |
| 260 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 262 | static inline int vfs_dq_off(struct super_block *sb, int remount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | { |
| 264 | int ret = -ENOSYS; |
| 265 | |
Jan Kara | 0ff5af8 | 2008-04-28 02:14:33 -0700 | [diff] [blame] | 266 | if (sb->s_qcop && sb->s_qcop->quota_off) |
| 267 | ret = sb->s_qcop->quota_off(sb, -1, remount); |
| 268 | return ret; |
| 269 | } |
| 270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | #else |
| 272 | |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 273 | static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 274 | { |
| 275 | return 0; |
| 276 | } |
| 277 | |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 278 | static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 279 | { |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) |
| 284 | { |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | static inline int sb_any_quota_suspended(struct super_block *sb) |
| 289 | { |
| 290 | return 0; |
| 291 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 292 | |
Jan Kara | f55abc0 | 2008-08-20 17:50:32 +0200 | [diff] [blame] | 293 | /* Does kernel know about any quota information for given sb + type? */ |
| 294 | static inline int sb_has_quota_loaded(struct super_block *sb, int type) |
| 295 | { |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | static inline int sb_any_quota_loaded(struct super_block *sb) |
| 300 | { |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | static inline int sb_has_quota_active(struct super_block *sb, int type) |
| 305 | { |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | static inline int sb_any_quota_active(struct super_block *sb) |
| 310 | { |
| 311 | return 0; |
| 312 | } |
| 313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | /* |
| 315 | * NO-OP when quota not configured. |
| 316 | */ |
| 317 | #define sb_dquot_ops (NULL) |
| 318 | #define sb_quotactl_ops (NULL) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 319 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 320 | static inline void vfs_dq_init(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 321 | { |
| 322 | } |
| 323 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 324 | static inline void vfs_dq_drop(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 325 | { |
| 326 | } |
| 327 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 328 | static inline int vfs_dq_alloc_inode(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 329 | { |
| 330 | return 0; |
| 331 | } |
| 332 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 333 | static inline void vfs_dq_free_inode(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 334 | { |
| 335 | } |
| 336 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 337 | static inline void vfs_dq_sync(struct super_block *sb) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 338 | { |
| 339 | } |
| 340 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 341 | static inline int vfs_dq_off(struct super_block *sb, int remount) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 342 | { |
| 343 | return 0; |
| 344 | } |
| 345 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 346 | static inline int vfs_dq_quota_on_remount(struct super_block *sb) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 347 | { |
| 348 | return 0; |
| 349 | } |
| 350 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 351 | static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 352 | { |
| 353 | return 0; |
| 354 | } |
| 355 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 356 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | { |
| 358 | inode_add_bytes(inode, nr); |
| 359 | return 0; |
| 360 | } |
| 361 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 362 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 364 | vfs_dq_prealloc_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | mark_inode_dirty(inode); |
| 366 | return 0; |
| 367 | } |
| 368 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 369 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | { |
| 371 | inode_add_bytes(inode, nr); |
| 372 | return 0; |
| 373 | } |
| 374 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 375 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 377 | vfs_dq_alloc_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | mark_inode_dirty(inode); |
| 379 | return 0; |
| 380 | } |
| 381 | |
Mingming Cao | f18df22 | 2009-01-13 16:43:09 +0100 | [diff] [blame] | 382 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) |
| 383 | { |
| 384 | return 0; |
| 385 | } |
| 386 | |
Mingming Cao | 740d9dc | 2009-01-13 16:43:14 +0100 | [diff] [blame] | 387 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) |
| 388 | { |
| 389 | return vfs_dq_alloc_space(inode, nr); |
| 390 | } |
| 391 | |
| 392 | static inline |
| 393 | int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) |
| 394 | { |
| 395 | return 0; |
| 396 | } |
| 397 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 398 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | { |
| 400 | inode_sub_bytes(inode, nr); |
| 401 | } |
| 402 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 403 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 405 | vfs_dq_free_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | mark_inode_dirty(inode); |
| 407 | } |
| 408 | |
| 409 | #endif /* CONFIG_QUOTA */ |
| 410 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 411 | static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 412 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 413 | return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 416 | static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 417 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 418 | return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 421 | static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 422 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 423 | return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 424 | } |
| 425 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 426 | static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 427 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 428 | return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Mingming Cao | f18df22 | 2009-01-13 16:43:09 +0100 | [diff] [blame] | 431 | static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) |
| 432 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 433 | return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); |
Mingming Cao | f18df22 | 2009-01-13 16:43:09 +0100 | [diff] [blame] | 434 | } |
| 435 | |
Mingming Cao | 740d9dc | 2009-01-13 16:43:14 +0100 | [diff] [blame] | 436 | static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) |
| 437 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 438 | return vfs_dq_claim_space(inode, nr << inode->i_blkbits); |
Mingming Cao | 740d9dc | 2009-01-13 16:43:14 +0100 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | static inline |
| 442 | void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr) |
| 443 | { |
| 444 | vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); |
| 445 | } |
| 446 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 447 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 448 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 449 | vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 452 | static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 453 | { |
Mingming Cao | 9900ba3 | 2009-01-14 16:18:57 +0100 | [diff] [blame] | 454 | vfs_dq_free_space(inode, nr << inode->i_blkbits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 455 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | #endif /* _LINUX_QUOTAOPS_ */ |