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