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