diff options
Diffstat (limited to 'include/linux/quotaops.h')
| -rw-r--r-- | include/linux/quotaops.h | 397 |
1 files changed, 149 insertions, 248 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 3ebb23153640..d1a9193960f1 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
| @@ -9,25 +9,40 @@ | |||
| 9 | 9 | ||
| 10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
| 11 | 11 | ||
| 12 | #define DQUOT_SPACE_WARN 0x1 | ||
| 13 | #define DQUOT_SPACE_RESERVE 0x2 | ||
| 14 | #define DQUOT_SPACE_NOFAIL 0x4 | ||
| 15 | |||
| 12 | static inline struct quota_info *sb_dqopt(struct super_block *sb) | 16 | static inline struct quota_info *sb_dqopt(struct super_block *sb) |
| 13 | { | 17 | { |
| 14 | return &sb->s_dquot; | 18 | return &sb->s_dquot; |
| 15 | } | 19 | } |
| 16 | 20 | ||
| 21 | /* i_mutex must being held */ | ||
| 22 | static inline bool is_quota_modification(struct inode *inode, struct iattr *ia) | ||
| 23 | { | ||
| 24 | return (ia->ia_valid & ATTR_SIZE && ia->ia_size != inode->i_size) || | ||
| 25 | (ia->ia_valid & ATTR_UID && ia->ia_uid != inode->i_uid) || | ||
| 26 | (ia->ia_valid & ATTR_GID && ia->ia_gid != inode->i_gid); | ||
| 27 | } | ||
| 28 | |||
| 17 | #if defined(CONFIG_QUOTA) | 29 | #if defined(CONFIG_QUOTA) |
| 18 | 30 | ||
| 31 | #define quota_error(sb, fmt, args...) \ | ||
| 32 | __quota_error((sb), __func__, fmt , ## args) | ||
| 33 | |||
| 34 | extern void __quota_error(struct super_block *sb, const char *func, | ||
| 35 | const char *fmt, ...); | ||
| 36 | |||
| 19 | /* | 37 | /* |
| 20 | * declaration of quota_function calls in kernel. | 38 | * declaration of quota_function calls in kernel. |
| 21 | */ | 39 | */ |
| 22 | void sync_quota_sb(struct super_block *sb, int type); | 40 | void inode_add_rsv_space(struct inode *inode, qsize_t number); |
| 23 | static inline void writeout_quota_sb(struct super_block *sb, int type) | 41 | void inode_claim_rsv_space(struct inode *inode, qsize_t number); |
| 24 | { | 42 | void inode_sub_rsv_space(struct inode *inode, qsize_t number); |
| 25 | if (sb->s_qcop->quota_sync) | ||
| 26 | sb->s_qcop->quota_sync(sb, type); | ||
| 27 | } | ||
| 28 | 43 | ||
| 29 | int dquot_initialize(struct inode *inode, int type); | 44 | void dquot_initialize(struct inode *inode); |
| 30 | int dquot_drop(struct inode *inode); | 45 | void dquot_drop(struct inode *inode); |
| 31 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type); | 46 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type); |
| 32 | void dqput(struct dquot *dquot); | 47 | void dqput(struct dquot *dquot); |
| 33 | int dquot_scan_active(struct super_block *sb, | 48 | int dquot_scan_active(struct super_block *sb, |
| @@ -36,43 +51,49 @@ int dquot_scan_active(struct super_block *sb, | |||
| 36 | struct dquot *dquot_alloc(struct super_block *sb, int type); | 51 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
| 37 | void dquot_destroy(struct dquot *dquot); | 52 | void dquot_destroy(struct dquot *dquot); |
| 38 | 53 | ||
| 39 | int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); | 54 | int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags); |
| 40 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); | 55 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags); |
| 41 | 56 | ||
| 42 | int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); | 57 | int dquot_alloc_inode(const struct inode *inode); |
| 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 | 58 | ||
| 47 | int dquot_free_space(struct inode *inode, qsize_t number); | 59 | int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); |
| 48 | int dquot_free_inode(const struct inode *inode, qsize_t number); | 60 | void dquot_free_inode(const struct inode *inode); |
| 61 | |||
| 62 | int dquot_disable(struct super_block *sb, int type, unsigned int flags); | ||
| 63 | /* Suspend quotas on remount RO */ | ||
| 64 | static inline int dquot_suspend(struct super_block *sb, int type) | ||
| 65 | { | ||
| 66 | return dquot_disable(sb, type, DQUOT_SUSPENDED); | ||
| 67 | } | ||
| 68 | int dquot_resume(struct super_block *sb, int type); | ||
| 49 | 69 | ||
| 50 | int dquot_transfer(struct inode *inode, struct iattr *iattr); | ||
| 51 | int dquot_commit(struct dquot *dquot); | 70 | int dquot_commit(struct dquot *dquot); |
| 52 | int dquot_acquire(struct dquot *dquot); | 71 | int dquot_acquire(struct dquot *dquot); |
| 53 | int dquot_release(struct dquot *dquot); | 72 | int dquot_release(struct dquot *dquot); |
| 54 | int dquot_commit_info(struct super_block *sb, int type); | 73 | int dquot_commit_info(struct super_block *sb, int type); |
| 55 | int dquot_mark_dquot_dirty(struct dquot *dquot); | 74 | int dquot_mark_dquot_dirty(struct dquot *dquot); |
| 56 | 75 | ||
| 57 | int vfs_quota_on(struct super_block *sb, int type, int format_id, | 76 | int dquot_file_open(struct inode *inode, struct file *file); |
| 58 | char *path, int remount); | 77 | |
| 59 | int vfs_quota_enable(struct inode *inode, int type, int format_id, | 78 | int dquot_quota_on(struct super_block *sb, int type, int format_id, |
| 79 | char *path); | ||
| 80 | int dquot_enable(struct inode *inode, int type, int format_id, | ||
| 60 | unsigned int flags); | 81 | unsigned int flags); |
| 61 | int vfs_quota_on_path(struct super_block *sb, int type, int format_id, | 82 | int dquot_quota_on_path(struct super_block *sb, int type, int format_id, |
| 62 | struct path *path); | 83 | struct path *path); |
| 63 | int vfs_quota_on_mount(struct super_block *sb, char *qf_name, | 84 | int dquot_quota_on_mount(struct super_block *sb, char *qf_name, |
| 64 | int format_id, int type); | 85 | int format_id, int type); |
| 65 | int vfs_quota_off(struct super_block *sb, int type, int remount); | 86 | int dquot_quota_off(struct super_block *sb, int type); |
| 66 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); | 87 | int dquot_quota_sync(struct super_block *sb, int type, int wait); |
| 67 | int vfs_quota_sync(struct super_block *sb, int type); | 88 | int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
| 68 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 89 | int dquot_set_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); | 90 | int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, |
| 70 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 91 | struct fs_disk_quota *di); |
| 71 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 92 | int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, |
| 72 | 93 | struct fs_disk_quota *di); | |
| 73 | void vfs_dq_drop(struct inode *inode); | 94 | |
| 74 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr); | 95 | int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); |
| 75 | int vfs_dq_quota_on_remount(struct super_block *sb); | 96 | int dquot_transfer(struct inode *inode, struct iattr *iattr); |
| 76 | 97 | ||
| 77 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) | 98 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) |
| 78 | { | 99 | { |
| @@ -83,189 +104,58 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) | |||
| 83 | * Functions for checking status of quota | 104 | * Functions for checking status of quota |
| 84 | */ | 105 | */ |
| 85 | 106 | ||
| 86 | static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) | 107 | static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type) |
| 87 | { | 108 | { |
| 88 | return sb_dqopt(sb)->flags & | 109 | return sb_dqopt(sb)->flags & |
| 89 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); | 110 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); |
| 90 | } | 111 | } |
| 91 | 112 | ||
| 92 | static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) | 113 | static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type) |
| 93 | { | 114 | { |
| 94 | return sb_dqopt(sb)->flags & | 115 | return sb_dqopt(sb)->flags & |
| 95 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); | 116 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); |
| 96 | } | 117 | } |
| 97 | 118 | ||
| 98 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) | 119 | static inline bool sb_has_quota_suspended(struct super_block *sb, int type) |
| 99 | { | 120 | { |
| 100 | return sb_dqopt(sb)->flags & | 121 | return sb_dqopt(sb)->flags & |
| 101 | dquot_state_flag(DQUOT_SUSPENDED, type); | 122 | dquot_state_flag(DQUOT_SUSPENDED, type); |
| 102 | } | 123 | } |
| 103 | 124 | ||
| 104 | static inline int sb_any_quota_suspended(struct super_block *sb) | 125 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) |
| 105 | { | 126 | { |
| 106 | return sb_has_quota_suspended(sb, USRQUOTA) || | 127 | unsigned type, tmsk = 0; |
| 107 | sb_has_quota_suspended(sb, GRPQUOTA); | 128 | for (type = 0; type < MAXQUOTAS; type++) |
| 129 | tmsk |= sb_has_quota_suspended(sb, type) << type; | ||
| 130 | return tmsk; | ||
| 108 | } | 131 | } |
| 109 | 132 | ||
| 110 | /* Does kernel know about any quota information for given sb + type? */ | 133 | /* 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) | 134 | static inline bool sb_has_quota_loaded(struct super_block *sb, int type) |
| 112 | { | 135 | { |
| 113 | /* Currently if anything is on, then quota usage is on as well */ | 136 | /* Currently if anything is on, then quota usage is on as well */ |
| 114 | return sb_has_quota_usage_enabled(sb, type); | 137 | return sb_has_quota_usage_enabled(sb, type); |
| 115 | } | 138 | } |
| 116 | 139 | ||
| 117 | static inline int sb_any_quota_loaded(struct super_block *sb) | 140 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) |
| 118 | { | 141 | { |
| 119 | return sb_has_quota_loaded(sb, USRQUOTA) || | 142 | unsigned type, tmsk = 0; |
| 120 | sb_has_quota_loaded(sb, GRPQUOTA); | 143 | for (type = 0; type < MAXQUOTAS; type++) |
| 144 | tmsk |= sb_has_quota_loaded(sb, type) << type; | ||
| 145 | return tmsk; | ||
| 121 | } | 146 | } |
| 122 | 147 | ||
| 123 | static inline int sb_has_quota_active(struct super_block *sb, int type) | 148 | static inline bool sb_has_quota_active(struct super_block *sb, int type) |
| 124 | { | 149 | { |
| 125 | return sb_has_quota_loaded(sb, type) && | 150 | return sb_has_quota_loaded(sb, type) && |
| 126 | !sb_has_quota_suspended(sb, type); | 151 | !sb_has_quota_suspended(sb, type); |
| 127 | } | 152 | } |
| 128 | 153 | ||
| 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 | |||
| 135 | /* | 154 | /* |
| 136 | * Operations supported for diskquotas. | 155 | * Operations supported for diskquotas. |
| 137 | */ | 156 | */ |
| 138 | extern const struct dquot_operations dquot_operations; | 157 | extern const struct dquot_operations dquot_operations; |
| 139 | extern const struct quotactl_ops vfs_quotactl_ops; | 158 | extern const struct quotactl_ops dquot_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. */ | ||
| 146 | static inline void vfs_dq_init(struct inode *inode) | ||
| 147 | { | ||
| 148 | BUG_ON(!inode->i_sb); | ||
| 149 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) | ||
| 150 | inode->i_sb->dq_op->initialize(inode, -1); | ||
| 151 | } | ||
| 152 | |||
| 153 | /* The following allocation/freeing/transfer functions *must* be called inside | ||
| 154 | * a transaction (deadlocks possible otherwise) */ | ||
| 155 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
| 156 | { | ||
| 157 | if (sb_any_quota_active(inode->i_sb)) { | ||
| 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 | |||
| 167 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) | ||
| 168 | { | ||
| 169 | int ret; | ||
| 170 | if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr))) | ||
| 171 | mark_inode_dirty(inode); | ||
| 172 | return ret; | ||
| 173 | } | ||
| 174 | |||
| 175 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
| 176 | { | ||
| 177 | if (sb_any_quota_active(inode->i_sb)) { | ||
| 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 | |||
| 187 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | ||
| 188 | { | ||
| 189 | int ret; | ||
| 190 | if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr))) | ||
| 191 | mark_inode_dirty(inode); | ||
| 192 | return ret; | ||
| 193 | } | ||
| 194 | |||
| 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 | |||
| 205 | static inline int vfs_dq_alloc_inode(struct inode *inode) | ||
| 206 | { | ||
| 207 | if (sb_any_quota_active(inode->i_sb)) { | ||
| 208 | vfs_dq_init(inode); | ||
| 209 | if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) | ||
| 210 | return 1; | ||
| 211 | } | ||
| 212 | return 0; | ||
| 213 | } | ||
| 214 | |||
| 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 | |||
| 240 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | ||
| 241 | { | ||
| 242 | if (sb_any_quota_active(inode->i_sb)) | ||
| 243 | inode->i_sb->dq_op->free_space(inode, nr); | ||
| 244 | else | ||
| 245 | inode_sub_bytes(inode, nr); | ||
| 246 | } | ||
| 247 | |||
| 248 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | ||
| 249 | { | ||
| 250 | vfs_dq_free_space_nodirty(inode, nr); | ||
| 251 | mark_inode_dirty(inode); | ||
| 252 | } | ||
| 253 | |||
| 254 | static inline void vfs_dq_free_inode(struct inode *inode) | ||
| 255 | { | ||
| 256 | if (sb_any_quota_active(inode->i_sb)) | ||
| 257 | inode->i_sb->dq_op->free_inode(inode, 1); | ||
| 258 | } | ||
| 259 | |||
| 260 | /* Cannot be called inside a transaction */ | ||
| 261 | static inline int vfs_dq_off(struct super_block *sb, int remount) | ||
| 262 | { | ||
| 263 | int ret = -ENOSYS; | ||
| 264 | |||
| 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 | 159 | ||
| 270 | #else | 160 | #else |
| 271 | 161 | ||
| @@ -305,156 +195,167 @@ static inline int sb_has_quota_active(struct super_block *sb, int type) | |||
| 305 | return 0; | 195 | return 0; |
| 306 | } | 196 | } |
| 307 | 197 | ||
| 308 | static inline int sb_any_quota_active(struct super_block *sb) | 198 | static inline void dquot_initialize(struct inode *inode) |
| 309 | { | 199 | { |
| 310 | return 0; | ||
| 311 | } | 200 | } |
| 312 | 201 | ||
| 313 | /* | 202 | static inline void dquot_drop(struct inode *inode) |
| 314 | * NO-OP when quota not configured. | ||
| 315 | */ | ||
| 316 | #define sb_dquot_ops (NULL) | ||
| 317 | #define sb_quotactl_ops (NULL) | ||
| 318 | |||
| 319 | static inline void vfs_dq_init(struct inode *inode) | ||
| 320 | { | 203 | { |
| 321 | } | 204 | } |
| 322 | 205 | ||
| 323 | static inline void vfs_dq_drop(struct inode *inode) | 206 | static inline int dquot_alloc_inode(const struct inode *inode) |
| 324 | { | 207 | { |
| 208 | return 0; | ||
| 325 | } | 209 | } |
| 326 | 210 | ||
| 327 | static inline int vfs_dq_alloc_inode(struct inode *inode) | 211 | static inline void dquot_free_inode(const struct inode *inode) |
| 328 | { | 212 | { |
| 329 | return 0; | ||
| 330 | } | 213 | } |
| 331 | 214 | ||
| 332 | static inline void vfs_dq_free_inode(struct inode *inode) | 215 | static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) |
| 333 | { | 216 | { |
| 217 | return 0; | ||
| 334 | } | 218 | } |
| 335 | 219 | ||
| 336 | static inline void sync_quota_sb(struct super_block *sb, int type) | 220 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, |
| 221 | int flags) | ||
| 337 | { | 222 | { |
| 223 | if (!(flags & DQUOT_SPACE_RESERVE)) | ||
| 224 | inode_add_bytes(inode, number); | ||
| 225 | return 0; | ||
| 338 | } | 226 | } |
| 339 | 227 | ||
| 340 | static inline void writeout_quota_sb(struct super_block *sb, int type) | 228 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, |
| 229 | int flags) | ||
| 341 | { | 230 | { |
| 231 | if (!(flags & DQUOT_SPACE_RESERVE)) | ||
| 232 | inode_sub_bytes(inode, number); | ||
| 342 | } | 233 | } |
| 343 | 234 | ||
| 344 | static inline int vfs_dq_off(struct super_block *sb, int remount) | 235 | static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) |
| 345 | { | 236 | { |
| 237 | inode_add_bytes(inode, number); | ||
| 346 | return 0; | 238 | return 0; |
| 347 | } | 239 | } |
| 348 | 240 | ||
| 349 | static inline int vfs_dq_quota_on_remount(struct super_block *sb) | 241 | static inline int dquot_disable(struct super_block *sb, int type, |
| 242 | unsigned int flags) | ||
| 350 | { | 243 | { |
| 351 | return 0; | 244 | return 0; |
| 352 | } | 245 | } |
| 353 | 246 | ||
| 354 | static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) | 247 | static inline int dquot_suspend(struct super_block *sb, int type) |
| 355 | { | 248 | { |
| 356 | return 0; | 249 | return 0; |
| 357 | } | 250 | } |
| 358 | 251 | ||
| 359 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) | 252 | static inline int dquot_resume(struct super_block *sb, int type) |
| 360 | { | 253 | { |
| 361 | inode_add_bytes(inode, nr); | ||
| 362 | return 0; | 254 | return 0; |
| 363 | } | 255 | } |
| 364 | 256 | ||
| 365 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) | 257 | #define dquot_file_open generic_file_open |
| 258 | |||
| 259 | #endif /* CONFIG_QUOTA */ | ||
| 260 | |||
| 261 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
| 366 | { | 262 | { |
| 367 | vfs_dq_prealloc_space_nodirty(inode, nr); | 263 | return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN); |
| 368 | mark_inode_dirty(inode); | ||
| 369 | return 0; | ||
| 370 | } | 264 | } |
| 371 | 265 | ||
| 372 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) | 266 | static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr) |
| 373 | { | 267 | { |
| 374 | inode_add_bytes(inode, nr); | 268 | __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL); |
| 375 | return 0; | 269 | mark_inode_dirty_sync(inode); |
| 376 | } | 270 | } |
| 377 | 271 | ||
| 378 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | 272 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) |
| 379 | { | 273 | { |
| 380 | vfs_dq_alloc_space_nodirty(inode, nr); | 274 | int ret; |
| 381 | mark_inode_dirty(inode); | 275 | |
| 382 | return 0; | 276 | ret = dquot_alloc_space_nodirty(inode, nr); |
| 277 | if (!ret) { | ||
| 278 | /* | ||
| 279 | * Mark inode fully dirty. Since we are allocating blocks, inode | ||
| 280 | * would become fully dirty soon anyway and it reportedly | ||
| 281 | * reduces inode_lock contention. | ||
| 282 | */ | ||
| 283 | mark_inode_dirty(inode); | ||
| 284 | } | ||
| 285 | return ret; | ||
| 383 | } | 286 | } |
| 384 | 287 | ||
| 385 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | 288 | static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr) |
| 386 | { | 289 | { |
| 387 | return 0; | 290 | return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
| 388 | } | 291 | } |
| 389 | 292 | ||
| 390 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | 293 | static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr) |
| 391 | { | 294 | { |
| 392 | return vfs_dq_alloc_space(inode, nr); | 295 | dquot_alloc_space_nofail(inode, nr << inode->i_blkbits); |
| 393 | } | 296 | } |
| 394 | 297 | ||
| 395 | static inline | 298 | static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) |
| 396 | int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
| 397 | { | 299 | { |
| 398 | return 0; | 300 | return dquot_alloc_space(inode, nr << inode->i_blkbits); |
| 399 | } | 301 | } |
| 400 | 302 | ||
| 401 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | 303 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
| 402 | { | 304 | { |
| 403 | inode_sub_bytes(inode, nr); | 305 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0); |
| 404 | } | 306 | } |
| 405 | 307 | ||
| 406 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | 308 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) |
| 407 | { | 309 | { |
| 408 | vfs_dq_free_space_nodirty(inode, nr); | 310 | int ret; |
| 409 | mark_inode_dirty(inode); | ||
| 410 | } | ||
| 411 | |||
| 412 | #endif /* CONFIG_QUOTA */ | ||
| 413 | 311 | ||
| 414 | static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 312 | ret = dquot_prealloc_block_nodirty(inode, nr); |
| 415 | { | 313 | if (!ret) |
| 416 | return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); | 314 | mark_inode_dirty_sync(inode); |
| 315 | return ret; | ||
| 417 | } | 316 | } |
| 418 | 317 | ||
| 419 | static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) | 318 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) |
| 420 | { | 319 | { |
| 421 | return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); | 320 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, |
| 321 | DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE); | ||
| 422 | } | 322 | } |
| 423 | 323 | ||
| 424 | static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) | 324 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) |
| 425 | { | 325 | { |
| 426 | return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); | 326 | int ret; |
| 427 | } | ||
| 428 | 327 | ||
| 429 | static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) | 328 | ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits); |
| 430 | { | 329 | if (!ret) |
| 431 | return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); | 330 | mark_inode_dirty_sync(inode); |
| 331 | return ret; | ||
| 432 | } | 332 | } |
| 433 | 333 | ||
| 434 | static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) | 334 | static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr) |
| 435 | { | 335 | { |
| 436 | return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); | 336 | __dquot_free_space(inode, nr, 0); |
| 437 | } | 337 | } |
| 438 | 338 | ||
| 439 | static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) | 339 | static inline void dquot_free_space(struct inode *inode, qsize_t nr) |
| 440 | { | 340 | { |
| 441 | return vfs_dq_claim_space(inode, nr << inode->i_blkbits); | 341 | dquot_free_space_nodirty(inode, nr); |
| 342 | mark_inode_dirty_sync(inode); | ||
| 442 | } | 343 | } |
| 443 | 344 | ||
| 444 | static inline | 345 | static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr) |
| 445 | void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr) | ||
| 446 | { | 346 | { |
| 447 | vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); | 347 | dquot_free_space_nodirty(inode, nr << inode->i_blkbits); |
| 448 | } | 348 | } |
| 449 | 349 | ||
| 450 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) | 350 | static inline void dquot_free_block(struct inode *inode, qsize_t nr) |
| 451 | { | 351 | { |
| 452 | vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); | 352 | dquot_free_space(inode, nr << inode->i_blkbits); |
| 453 | } | 353 | } |
| 454 | 354 | ||
| 455 | static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) | 355 | static inline void dquot_release_reservation_block(struct inode *inode, |
| 356 | qsize_t nr) | ||
| 456 | { | 357 | { |
| 457 | vfs_dq_free_space(inode, nr << inode->i_blkbits); | 358 | __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE); |
| 458 | } | 359 | } |
| 459 | 360 | ||
| 460 | #endif /* _LINUX_QUOTAOPS_ */ | 361 | #endif /* _LINUX_QUOTAOPS_ */ |
