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