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