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> |
| 6 | * |
| 7 | * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $ |
| 8 | * |
| 9 | */ |
| 10 | #ifndef _LINUX_QUOTAOPS_ |
| 11 | #define _LINUX_QUOTAOPS_ |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/smp_lock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/fs.h> |
| 15 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 16 | static inline struct quota_info *sb_dqopt(struct super_block *sb) |
| 17 | { |
| 18 | return &sb->s_dquot; |
| 19 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #if defined(CONFIG_QUOTA) |
| 22 | |
| 23 | /* |
| 24 | * declaration of quota_function calls in kernel. |
| 25 | */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 26 | void sync_dquots(struct super_block *sb, int type); |
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_initialize(struct inode *inode, int type); |
| 29 | int dquot_drop(struct inode *inode); |
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_alloc_space(struct inode *inode, qsize_t number, int prealloc); |
| 32 | int dquot_alloc_inode(const struct inode *inode, unsigned long 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_free_space(struct inode *inode, qsize_t number); |
| 35 | int dquot_free_inode(const struct inode *inode, unsigned long number); |
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_transfer(struct inode *inode, struct iattr *iattr); |
| 38 | int dquot_commit(struct dquot *dquot); |
| 39 | int dquot_acquire(struct dquot *dquot); |
| 40 | int dquot_release(struct dquot *dquot); |
| 41 | int dquot_commit_info(struct super_block *sb, int type); |
| 42 | int dquot_mark_dquot_dirty(struct dquot *dquot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 44 | int vfs_quota_on(struct super_block *sb, int type, int format_id, |
| 45 | char *path, int remount); |
Al Viro | 77e69da | 2008-08-01 04:29:18 -0400 | [diff] [blame] | 46 | int vfs_quota_on_path(struct super_block *sb, int type, int format_id, |
| 47 | struct path *path); |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 48 | int vfs_quota_on_mount(struct super_block *sb, char *qf_name, |
| 49 | int format_id, int type); |
| 50 | int vfs_quota_off(struct super_block *sb, int type, int remount); |
| 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 | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 70 | static inline int sb_has_quota_enabled(struct super_block *sb, int type) |
| 71 | { |
| 72 | if (type == USRQUOTA) |
| 73 | return sb_dqopt(sb)->flags & DQUOT_USR_ENABLED; |
| 74 | return sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED; |
| 75 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 76 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 77 | static inline int sb_any_quota_enabled(struct super_block *sb) |
| 78 | { |
| 79 | return sb_has_quota_enabled(sb, USRQUOTA) || |
| 80 | sb_has_quota_enabled(sb, GRPQUOTA); |
| 81 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 82 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 83 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) |
| 84 | { |
| 85 | if (type == USRQUOTA) |
| 86 | return sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED; |
| 87 | return sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED; |
| 88 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 89 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 90 | static inline int sb_any_quota_suspended(struct super_block *sb) |
| 91 | { |
| 92 | return sb_has_quota_suspended(sb, USRQUOTA) || |
| 93 | sb_has_quota_suspended(sb, GRPQUOTA); |
| 94 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 95 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | /* |
| 97 | * Operations supported for diskquotas. |
| 98 | */ |
| 99 | extern struct dquot_operations dquot_operations; |
| 100 | extern struct quotactl_ops vfs_quotactl_ops; |
| 101 | |
| 102 | #define sb_dquot_ops (&dquot_operations) |
| 103 | #define sb_quotactl_ops (&vfs_quotactl_ops) |
| 104 | |
| 105 | /* It is better to call this function outside of any transaction as it might |
| 106 | * need a lot of space in journal for dquot structure allocation. */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 107 | static inline void vfs_dq_init(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { |
| 109 | BUG_ON(!inode->i_sb); |
| 110 | if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) |
| 111 | inode->i_sb->dq_op->initialize(inode, -1); |
| 112 | } |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | /* The following allocation/freeing/transfer functions *must* be called inside |
| 115 | * a transaction (deadlocks possible otherwise) */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 116 | 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] | 117 | { |
| 118 | if (sb_any_quota_enabled(inode->i_sb)) { |
| 119 | /* Used space is updated in alloc_space() */ |
| 120 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) |
| 121 | return 1; |
| 122 | } |
| 123 | else |
| 124 | inode_add_bytes(inode, nr); |
| 125 | return 0; |
| 126 | } |
| 127 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 128 | 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] | 129 | { |
| 130 | int ret; |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 131 | if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | mark_inode_dirty(inode); |
| 133 | return ret; |
| 134 | } |
| 135 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 136 | 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] | 137 | { |
| 138 | if (sb_any_quota_enabled(inode->i_sb)) { |
| 139 | /* Used space is updated in alloc_space() */ |
| 140 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) |
| 141 | return 1; |
| 142 | } |
| 143 | else |
| 144 | inode_add_bytes(inode, nr); |
| 145 | return 0; |
| 146 | } |
| 147 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 148 | 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] | 149 | { |
| 150 | int ret; |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 151 | if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | mark_inode_dirty(inode); |
| 153 | return ret; |
| 154 | } |
| 155 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 156 | static inline int vfs_dq_alloc_inode(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
| 158 | if (sb_any_quota_enabled(inode->i_sb)) { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 159 | vfs_dq_init(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) |
| 161 | return 1; |
| 162 | } |
| 163 | return 0; |
| 164 | } |
| 165 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 166 | 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] | 167 | { |
| 168 | if (sb_any_quota_enabled(inode->i_sb)) |
| 169 | inode->i_sb->dq_op->free_space(inode, nr); |
| 170 | else |
| 171 | inode_sub_bytes(inode, nr); |
| 172 | } |
| 173 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 174 | 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] | 175 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 176 | vfs_dq_free_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | mark_inode_dirty(inode); |
| 178 | } |
| 179 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 180 | static inline void vfs_dq_free_inode(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | { |
| 182 | if (sb_any_quota_enabled(inode->i_sb)) |
| 183 | inode->i_sb->dq_op->free_inode(inode, 1); |
| 184 | } |
| 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | /* The following two functions cannot be called inside a transaction */ |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 187 | static inline void vfs_dq_sync(struct super_block *sb) |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 188 | { |
| 189 | sync_dquots(sb, -1); |
| 190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 192 | static inline int vfs_dq_off(struct super_block *sb, int remount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | { |
| 194 | int ret = -ENOSYS; |
| 195 | |
Jan Kara | 0ff5af8 | 2008-04-28 02:14:33 -0700 | [diff] [blame] | 196 | if (sb->s_qcop && sb->s_qcop->quota_off) |
| 197 | ret = sb->s_qcop->quota_off(sb, -1, remount); |
| 198 | return ret; |
| 199 | } |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | #else |
| 202 | |
Jan Kara | 03b0634 | 2008-07-25 01:46:52 -0700 | [diff] [blame] | 203 | static inline int sb_has_quota_enabled(struct super_block *sb, int type) |
| 204 | { |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static inline int sb_any_quota_enabled(struct super_block *sb) |
| 209 | { |
| 210 | return 0; |
| 211 | } |
| 212 | |
| 213 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) |
| 214 | { |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | static inline int sb_any_quota_suspended(struct super_block *sb) |
| 219 | { |
| 220 | return 0; |
| 221 | } |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 222 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | /* |
| 224 | * NO-OP when quota not configured. |
| 225 | */ |
| 226 | #define sb_dquot_ops (NULL) |
| 227 | #define sb_quotactl_ops (NULL) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 228 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 229 | static inline void vfs_dq_init(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 230 | { |
| 231 | } |
| 232 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 233 | static inline void vfs_dq_drop(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 234 | { |
| 235 | } |
| 236 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 237 | static inline int vfs_dq_alloc_inode(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 238 | { |
| 239 | return 0; |
| 240 | } |
| 241 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 242 | static inline void vfs_dq_free_inode(struct inode *inode) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 243 | { |
| 244 | } |
| 245 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 246 | static inline void vfs_dq_sync(struct super_block *sb) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 247 | { |
| 248 | } |
| 249 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 250 | static inline int vfs_dq_off(struct super_block *sb, int remount) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 251 | { |
| 252 | return 0; |
| 253 | } |
| 254 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 255 | static inline int vfs_dq_quota_on_remount(struct super_block *sb) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 256 | { |
| 257 | return 0; |
| 258 | } |
| 259 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 260 | static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) |
Andrew Morton | 50f8c37 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 261 | { |
| 262 | return 0; |
| 263 | } |
| 264 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 265 | 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] | 266 | { |
| 267 | inode_add_bytes(inode, nr); |
| 268 | return 0; |
| 269 | } |
| 270 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 271 | 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] | 272 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 273 | vfs_dq_prealloc_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | mark_inode_dirty(inode); |
| 275 | return 0; |
| 276 | } |
| 277 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 278 | 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] | 279 | { |
| 280 | inode_add_bytes(inode, nr); |
| 281 | return 0; |
| 282 | } |
| 283 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 284 | 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] | 285 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 286 | vfs_dq_alloc_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | mark_inode_dirty(inode); |
| 288 | return 0; |
| 289 | } |
| 290 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 291 | 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] | 292 | { |
| 293 | inode_sub_bytes(inode, nr); |
| 294 | } |
| 295 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 296 | 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] | 297 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 298 | vfs_dq_free_space_nodirty(inode, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | mark_inode_dirty(inode); |
| 300 | } |
| 301 | |
| 302 | #endif /* CONFIG_QUOTA */ |
| 303 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 304 | 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] | 305 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 306 | return vfs_dq_prealloc_space_nodirty(inode, |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 307 | nr << inode->i_sb->s_blocksize_bits); |
| 308 | } |
| 309 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 310 | 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] | 311 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 312 | return vfs_dq_prealloc_space(inode, |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 313 | nr << inode->i_sb->s_blocksize_bits); |
| 314 | } |
| 315 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 316 | 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] | 317 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 318 | return vfs_dq_alloc_space_nodirty(inode, |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 319 | nr << inode->i_sb->s_blocksize_bits); |
| 320 | } |
| 321 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 322 | 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] | 323 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 324 | return vfs_dq_alloc_space(inode, |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 325 | nr << inode->i_sb->s_blocksize_bits); |
| 326 | } |
| 327 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 328 | 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] | 329 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 330 | 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] | 331 | } |
| 332 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 333 | 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] | 334 | { |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 335 | vfs_dq_free_space(inode, nr << inode->i_sb->s_blocksize_bits); |
Jan Kara | 03f6e92 | 2008-04-28 02:14:32 -0700 | [diff] [blame] | 336 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Jan Kara | b85f4b8 | 2008-07-25 01:46:50 -0700 | [diff] [blame] | 338 | /* |
| 339 | * Define uppercase equivalents for compatibility with old function names |
| 340 | * Can go away when we think all users have been converted (15/04/2008) |
| 341 | */ |
| 342 | #define DQUOT_INIT(inode) vfs_dq_init(inode) |
| 343 | #define DQUOT_DROP(inode) vfs_dq_drop(inode) |
| 344 | #define DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr) \ |
| 345 | vfs_dq_prealloc_space_nodirty(inode, nr) |
| 346 | #define DQUOT_PREALLOC_SPACE(inode, nr) vfs_dq_prealloc_space(inode, nr) |
| 347 | #define DQUOT_ALLOC_SPACE_NODIRTY(inode, nr) \ |
| 348 | vfs_dq_alloc_space_nodirty(inode, nr) |
| 349 | #define DQUOT_ALLOC_SPACE(inode, nr) vfs_dq_alloc_space(inode, nr) |
| 350 | #define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) \ |
| 351 | vfs_dq_prealloc_block_nodirty(inode, nr) |
| 352 | #define DQUOT_PREALLOC_BLOCK(inode, nr) vfs_dq_prealloc_block(inode, nr) |
| 353 | #define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) \ |
| 354 | vfs_dq_alloc_block_nodirty(inode, nr) |
| 355 | #define DQUOT_ALLOC_BLOCK(inode, nr) vfs_dq_alloc_block(inode, nr) |
| 356 | #define DQUOT_ALLOC_INODE(inode) vfs_dq_alloc_inode(inode) |
| 357 | #define DQUOT_FREE_SPACE_NODIRTY(inode, nr) \ |
| 358 | vfs_dq_free_space_nodirty(inode, nr) |
| 359 | #define DQUOT_FREE_SPACE(inode, nr) vfs_dq_free_space(inode, nr) |
| 360 | #define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) \ |
| 361 | vfs_dq_free_block_nodirty(inode, nr) |
| 362 | #define DQUOT_FREE_BLOCK(inode, nr) vfs_dq_free_block(inode, nr) |
| 363 | #define DQUOT_FREE_INODE(inode) vfs_dq_free_inode(inode) |
| 364 | #define DQUOT_TRANSFER(inode, iattr) vfs_dq_transfer(inode, iattr) |
| 365 | #define DQUOT_SYNC(sb) vfs_dq_sync(sb) |
| 366 | #define DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount) |
| 367 | #define DQUOT_ON_REMOUNT(sb) vfs_dq_quota_on_remount(sb) |
| 368 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | #endif /* _LINUX_QUOTAOPS_ */ |