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

Configure Feed

Select the types of activity you want to include in your feed.

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