Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

quota: rename quota functions from upper case, make bigger ones non-inline

Cleanup quotaops.h: Rename functions from uppercase to lowercase (and
define backward compatibility macros), move larger functions to dquot.c
and make them non-inline.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Kara and committed by
Linus Torvalds
b85f4b87 b48d3805

+165 -124
+53
fs/dquot.c
··· 1153 1153 return 0; 1154 1154 } 1155 1155 1156 + /* Wrapper to remove references to quota structures from inode */ 1157 + void vfs_dq_drop(struct inode *inode) 1158 + { 1159 + /* Here we can get arbitrary inode from clear_inode() so we have 1160 + * to be careful. OTOH we don't need locking as quota operations 1161 + * are allowed to change only at mount time */ 1162 + if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op 1163 + && inode->i_sb->dq_op->drop) { 1164 + int cnt; 1165 + /* Test before calling to rule out calls from proc and such 1166 + * where we are not allowed to block. Note that this is 1167 + * actually reliable test even without the lock - the caller 1168 + * must assure that nobody can come after the DQUOT_DROP and 1169 + * add quota pointers back anyway */ 1170 + for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1171 + if (inode->i_dquot[cnt] != NODQUOT) 1172 + break; 1173 + if (cnt < MAXQUOTAS) 1174 + inode->i_sb->dq_op->drop(inode); 1175 + } 1176 + } 1177 + 1156 1178 /* 1157 1179 * Following four functions update i_blocks+i_bytes fields and 1158 1180 * quota information (together with appropriate checks) ··· 1447 1425 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1448 1426 return ret; 1449 1427 } 1428 + 1429 + /* Wrapper for transferring ownership of an inode */ 1430 + int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) 1431 + { 1432 + if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) { 1433 + vfs_dq_init(inode); 1434 + if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA) 1435 + return 1; 1436 + } 1437 + return 0; 1438 + } 1439 + 1450 1440 1451 1441 /* 1452 1442 * Write info of quota file to disk ··· 1800 1766 return error; 1801 1767 } 1802 1768 1769 + /* Wrapper to turn on quotas when remounting rw */ 1770 + int vfs_dq_quota_on_remount(struct super_block *sb) 1771 + { 1772 + int cnt; 1773 + int ret = 0, err; 1774 + 1775 + if (!sb->s_qcop || !sb->s_qcop->quota_on) 1776 + return -ENOSYS; 1777 + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1778 + err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1); 1779 + if (err < 0 && !ret) 1780 + ret = err; 1781 + } 1782 + return ret; 1783 + } 1784 + 1803 1785 /* Generic routine for getting common part of quota structure */ 1804 1786 static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di) 1805 1787 { ··· 2151 2101 EXPORT_SYMBOL(dquot_mark_dquot_dirty); 2152 2102 EXPORT_SYMBOL(dquot_initialize); 2153 2103 EXPORT_SYMBOL(dquot_drop); 2104 + EXPORT_SYMBOL(vfs_dq_drop); 2154 2105 EXPORT_SYMBOL(dquot_alloc_space); 2155 2106 EXPORT_SYMBOL(dquot_alloc_inode); 2156 2107 EXPORT_SYMBOL(dquot_free_space); 2157 2108 EXPORT_SYMBOL(dquot_free_inode); 2158 2109 EXPORT_SYMBOL(dquot_transfer); 2110 + EXPORT_SYMBOL(vfs_dq_transfer); 2111 + EXPORT_SYMBOL(vfs_dq_quota_on_remount);
+112 -124
include/linux/quotaops.h
··· 19 19 /* 20 20 * declaration of quota_function calls in kernel. 21 21 */ 22 - extern void sync_dquots(struct super_block *sb, int type); 22 + void sync_dquots(struct super_block *sb, int type); 23 23 24 - extern int dquot_initialize(struct inode *inode, int type); 25 - extern int dquot_drop(struct inode *inode); 24 + int dquot_initialize(struct inode *inode, int type); 25 + int dquot_drop(struct inode *inode); 26 26 27 - extern int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 28 - extern int dquot_alloc_inode(const struct inode *inode, unsigned long number); 27 + int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 28 + int dquot_alloc_inode(const struct inode *inode, unsigned long number); 29 29 30 - extern int dquot_free_space(struct inode *inode, qsize_t number); 31 - extern int dquot_free_inode(const struct inode *inode, unsigned long number); 30 + int dquot_free_space(struct inode *inode, qsize_t number); 31 + int dquot_free_inode(const struct inode *inode, unsigned long number); 32 32 33 - extern int dquot_transfer(struct inode *inode, struct iattr *iattr); 34 - extern int dquot_commit(struct dquot *dquot); 35 - extern int dquot_acquire(struct dquot *dquot); 36 - extern int dquot_release(struct dquot *dquot); 37 - extern int dquot_commit_info(struct super_block *sb, int type); 38 - extern int dquot_mark_dquot_dirty(struct dquot *dquot); 33 + int dquot_transfer(struct inode *inode, struct iattr *iattr); 34 + int dquot_commit(struct dquot *dquot); 35 + int dquot_acquire(struct dquot *dquot); 36 + int dquot_release(struct dquot *dquot); 37 + int dquot_commit_info(struct super_block *sb, int type); 38 + int dquot_mark_dquot_dirty(struct dquot *dquot); 39 39 40 - extern int vfs_quota_on(struct super_block *sb, int type, int format_id, 41 - char *path, int remount); 42 - extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 43 - int format_id, int type); 44 - extern int vfs_quota_off(struct super_block *sb, int type, int remount); 45 - extern int vfs_quota_sync(struct super_block *sb, int type); 46 - extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 47 - extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 48 - extern int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 49 - extern int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 40 + int vfs_quota_on(struct super_block *sb, int type, int format_id, 41 + char *path, int remount); 42 + int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 43 + int format_id, int type); 44 + int vfs_quota_off(struct super_block *sb, int type, int remount); 45 + int vfs_quota_sync(struct super_block *sb, int type); 46 + int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 47 + int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 48 + int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 49 + int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 50 + 51 + void vfs_dq_drop(struct inode *inode); 52 + int vfs_dq_transfer(struct inode *inode, struct iattr *iattr); 53 + int vfs_dq_quota_on_remount(struct super_block *sb); 50 54 51 55 /* 52 56 * Operations supported for diskquotas. ··· 63 59 64 60 /* It is better to call this function outside of any transaction as it might 65 61 * need a lot of space in journal for dquot structure allocation. */ 66 - static inline void DQUOT_INIT(struct inode *inode) 62 + static inline void vfs_dq_init(struct inode *inode) 67 63 { 68 64 BUG_ON(!inode->i_sb); 69 65 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) 70 66 inode->i_sb->dq_op->initialize(inode, -1); 71 67 } 72 68 73 - /* The same as with DQUOT_INIT */ 74 - static inline void DQUOT_DROP(struct inode *inode) 75 - { 76 - /* Here we can get arbitrary inode from clear_inode() so we have 77 - * to be careful. OTOH we don't need locking as quota operations 78 - * are allowed to change only at mount time */ 79 - if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op 80 - && inode->i_sb->dq_op->drop) { 81 - int cnt; 82 - /* Test before calling to rule out calls from proc and such 83 - * where we are not allowed to block. Note that this is 84 - * actually reliable test even without the lock - the caller 85 - * must assure that nobody can come after the DQUOT_DROP and 86 - * add quota pointers back anyway */ 87 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 88 - if (inode->i_dquot[cnt] != NODQUOT) 89 - break; 90 - if (cnt < MAXQUOTAS) 91 - inode->i_sb->dq_op->drop(inode); 92 - } 93 - } 94 - 95 69 /* The following allocation/freeing/transfer functions *must* be called inside 96 70 * a transaction (deadlocks possible otherwise) */ 97 - static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 71 + static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) 98 72 { 99 73 if (sb_any_quota_enabled(inode->i_sb)) { 100 74 /* Used space is updated in alloc_space() */ ··· 84 102 return 0; 85 103 } 86 104 87 - static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) 105 + static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) 88 106 { 89 107 int ret; 90 - if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr))) 108 + if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr))) 91 109 mark_inode_dirty(inode); 92 110 return ret; 93 111 } 94 112 95 - static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 113 + static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) 96 114 { 97 115 if (sb_any_quota_enabled(inode->i_sb)) { 98 116 /* Used space is updated in alloc_space() */ ··· 104 122 return 0; 105 123 } 106 124 107 - static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) 125 + static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) 108 126 { 109 127 int ret; 110 - if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr))) 128 + if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr))) 111 129 mark_inode_dirty(inode); 112 130 return ret; 113 131 } 114 132 115 - static inline int DQUOT_ALLOC_INODE(struct inode *inode) 133 + static inline int vfs_dq_alloc_inode(struct inode *inode) 116 134 { 117 135 if (sb_any_quota_enabled(inode->i_sb)) { 118 - DQUOT_INIT(inode); 136 + vfs_dq_init(inode); 119 137 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) 120 138 return 1; 121 139 } 122 140 return 0; 123 141 } 124 142 125 - static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 143 + static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 126 144 { 127 145 if (sb_any_quota_enabled(inode->i_sb)) 128 146 inode->i_sb->dq_op->free_space(inode, nr); ··· 130 148 inode_sub_bytes(inode, nr); 131 149 } 132 150 133 - static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) 151 + static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) 134 152 { 135 - DQUOT_FREE_SPACE_NODIRTY(inode, nr); 153 + vfs_dq_free_space_nodirty(inode, nr); 136 154 mark_inode_dirty(inode); 137 155 } 138 156 139 - static inline void DQUOT_FREE_INODE(struct inode *inode) 157 + static inline void vfs_dq_free_inode(struct inode *inode) 140 158 { 141 159 if (sb_any_quota_enabled(inode->i_sb)) 142 160 inode->i_sb->dq_op->free_inode(inode, 1); 143 161 } 144 162 145 - static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) 146 - { 147 - if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) { 148 - DQUOT_INIT(inode); 149 - if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA) 150 - return 1; 151 - } 152 - return 0; 153 - } 154 - 155 163 /* The following two functions cannot be called inside a transaction */ 156 - static inline void DQUOT_SYNC(struct super_block *sb) 164 + static inline void vfs_dq_sync(struct super_block *sb) 157 165 { 158 166 sync_dquots(sb, -1); 159 167 } 160 168 161 - static inline int DQUOT_OFF(struct super_block *sb, int remount) 169 + static inline int vfs_dq_off(struct super_block *sb, int remount) 162 170 { 163 171 int ret = -ENOSYS; 164 172 165 173 if (sb->s_qcop && sb->s_qcop->quota_off) 166 174 ret = sb->s_qcop->quota_off(sb, -1, remount); 167 - return ret; 168 - } 169 - 170 - static inline int DQUOT_ON_REMOUNT(struct super_block *sb) 171 - { 172 - int cnt; 173 - int ret = 0, err; 174 - 175 - if (!sb->s_qcop || !sb->s_qcop->quota_on) 176 - return -ENOSYS; 177 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 178 - err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1); 179 - if (err < 0 && !ret) 180 - ret = err; 181 - } 182 175 return ret; 183 176 } 184 177 ··· 165 208 #define sb_dquot_ops (NULL) 166 209 #define sb_quotactl_ops (NULL) 167 210 168 - static inline void DQUOT_INIT(struct inode *inode) 211 + static inline void vfs_dq_init(struct inode *inode) 169 212 { 170 213 } 171 214 172 - static inline void DQUOT_DROP(struct inode *inode) 215 + static inline void vfs_dq_drop(struct inode *inode) 173 216 { 174 217 } 175 218 176 - static inline int DQUOT_ALLOC_INODE(struct inode *inode) 177 - { 178 - return 0; 179 - } 180 - 181 - static inline void DQUOT_FREE_INODE(struct inode *inode) 182 - { 183 - } 184 - 185 - static inline void DQUOT_SYNC(struct super_block *sb) 186 - { 187 - } 188 - 189 - static inline int DQUOT_OFF(struct super_block *sb, int remount) 219 + static inline int vfs_dq_alloc_inode(struct inode *inode) 190 220 { 191 221 return 0; 192 222 } 193 223 194 - static inline int DQUOT_ON_REMOUNT(struct super_block *sb) 224 + static inline void vfs_dq_free_inode(struct inode *inode) 225 + { 226 + } 227 + 228 + static inline void vfs_dq_sync(struct super_block *sb) 229 + { 230 + } 231 + 232 + static inline int vfs_dq_off(struct super_block *sb, int remount) 195 233 { 196 234 return 0; 197 235 } 198 236 199 - static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) 237 + static inline int vfs_dq_quota_on_remount(struct super_block *sb) 200 238 { 201 239 return 0; 202 240 } 203 241 204 - static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 242 + static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) 243 + { 244 + return 0; 245 + } 246 + 247 + static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) 205 248 { 206 249 inode_add_bytes(inode, nr); 207 250 return 0; 208 251 } 209 252 210 - static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) 253 + static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) 211 254 { 212 - DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr); 255 + vfs_dq_prealloc_space_nodirty(inode, nr); 213 256 mark_inode_dirty(inode); 214 257 return 0; 215 258 } 216 259 217 - static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 260 + static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) 218 261 { 219 262 inode_add_bytes(inode, nr); 220 263 return 0; 221 264 } 222 265 223 - static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) 266 + static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) 224 267 { 225 - DQUOT_ALLOC_SPACE_NODIRTY(inode, nr); 268 + vfs_dq_alloc_space_nodirty(inode, nr); 226 269 mark_inode_dirty(inode); 227 270 return 0; 228 271 } 229 272 230 - static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 273 + static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 231 274 { 232 275 inode_sub_bytes(inode, nr); 233 276 } 234 277 235 - static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) 278 + static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) 236 279 { 237 - DQUOT_FREE_SPACE_NODIRTY(inode, nr); 280 + vfs_dq_free_space_nodirty(inode, nr); 238 281 mark_inode_dirty(inode); 239 282 } 240 283 241 284 #endif /* CONFIG_QUOTA */ 242 285 243 - static inline int DQUOT_PREALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) 286 + static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) 244 287 { 245 - return DQUOT_PREALLOC_SPACE_NODIRTY(inode, 288 + return vfs_dq_prealloc_space_nodirty(inode, 246 289 nr << inode->i_sb->s_blocksize_bits); 247 290 } 248 291 249 - static inline int DQUOT_PREALLOC_BLOCK(struct inode *inode, qsize_t nr) 292 + static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) 250 293 { 251 - return DQUOT_PREALLOC_SPACE(inode, 294 + return vfs_dq_prealloc_space(inode, 252 295 nr << inode->i_sb->s_blocksize_bits); 253 296 } 254 297 255 - static inline int DQUOT_ALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) 298 + static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) 256 299 { 257 - return DQUOT_ALLOC_SPACE_NODIRTY(inode, 300 + return vfs_dq_alloc_space_nodirty(inode, 258 301 nr << inode->i_sb->s_blocksize_bits); 259 302 } 260 303 261 - static inline int DQUOT_ALLOC_BLOCK(struct inode *inode, qsize_t nr) 304 + static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) 262 305 { 263 - return DQUOT_ALLOC_SPACE(inode, 306 + return vfs_dq_alloc_space(inode, 264 307 nr << inode->i_sb->s_blocksize_bits); 265 308 } 266 309 267 - static inline void DQUOT_FREE_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) 310 + static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) 268 311 { 269 - DQUOT_FREE_SPACE_NODIRTY(inode, nr << inode->i_sb->s_blocksize_bits); 312 + vfs_dq_free_space_nodirty(inode, nr << inode->i_sb->s_blocksize_bits); 270 313 } 271 314 272 - static inline void DQUOT_FREE_BLOCK(struct inode *inode, qsize_t nr) 315 + static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) 273 316 { 274 - DQUOT_FREE_SPACE(inode, nr << inode->i_sb->s_blocksize_bits); 317 + vfs_dq_free_space(inode, nr << inode->i_sb->s_blocksize_bits); 275 318 } 319 + 320 + /* 321 + * Define uppercase equivalents for compatibility with old function names 322 + * Can go away when we think all users have been converted (15/04/2008) 323 + */ 324 + #define DQUOT_INIT(inode) vfs_dq_init(inode) 325 + #define DQUOT_DROP(inode) vfs_dq_drop(inode) 326 + #define DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr) \ 327 + vfs_dq_prealloc_space_nodirty(inode, nr) 328 + #define DQUOT_PREALLOC_SPACE(inode, nr) vfs_dq_prealloc_space(inode, nr) 329 + #define DQUOT_ALLOC_SPACE_NODIRTY(inode, nr) \ 330 + vfs_dq_alloc_space_nodirty(inode, nr) 331 + #define DQUOT_ALLOC_SPACE(inode, nr) vfs_dq_alloc_space(inode, nr) 332 + #define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) \ 333 + vfs_dq_prealloc_block_nodirty(inode, nr) 334 + #define DQUOT_PREALLOC_BLOCK(inode, nr) vfs_dq_prealloc_block(inode, nr) 335 + #define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) \ 336 + vfs_dq_alloc_block_nodirty(inode, nr) 337 + #define DQUOT_ALLOC_BLOCK(inode, nr) vfs_dq_alloc_block(inode, nr) 338 + #define DQUOT_ALLOC_INODE(inode) vfs_dq_alloc_inode(inode) 339 + #define DQUOT_FREE_SPACE_NODIRTY(inode, nr) \ 340 + vfs_dq_free_space_nodirty(inode, nr) 341 + #define DQUOT_FREE_SPACE(inode, nr) vfs_dq_free_space(inode, nr) 342 + #define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) \ 343 + vfs_dq_free_block_nodirty(inode, nr) 344 + #define DQUOT_FREE_BLOCK(inode, nr) vfs_dq_free_block(inode, nr) 345 + #define DQUOT_FREE_INODE(inode) vfs_dq_free_inode(inode) 346 + #define DQUOT_TRANSFER(inode, iattr) vfs_dq_transfer(inode, iattr) 347 + #define DQUOT_SYNC(sb) vfs_dq_sync(sb) 348 + #define DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount) 349 + #define DQUOT_ON_REMOUNT(sb) vfs_dq_quota_on_remount(sb) 276 350 277 351 #endif /* _LINUX_QUOTAOPS_ */