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