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