2 * Definitions for diskquota-operations. When diskquota is configured these
3 * macros expand to the right source-code.
5 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
10 #ifndef _LINUX_QUOTAOPS_
11 #define _LINUX_QUOTAOPS_
13 #include <linux/config.h>
14 #include <linux/smp_lock.h>
18 #if defined(CONFIG_QUOTA)
21 * declaration of quota_function calls in kernel.
23 extern void sync_dquots(struct super_block
*sb
, int type
);
25 extern void dquot_initialize(struct inode
*inode
, int type
);
26 extern void dquot_drop(struct inode
*inode
);
28 extern int dquot_alloc_space(struct inode
*inode
, qsize_t number
, int prealloc
);
29 extern int dquot_alloc_inode(const struct inode
*inode
, unsigned long number
);
31 extern void dquot_free_space(struct inode
*inode
, qsize_t number
);
32 extern void dquot_free_inode(const struct inode
*inode
, unsigned long number
);
34 extern int dquot_transfer(struct inode
*inode
, struct iattr
*iattr
);
37 * Operations supported for diskquotas.
39 extern struct dquot_operations dquot_operations
;
40 extern struct quotactl_ops vfs_quotactl_ops
;
42 #define sb_dquot_ops (&dquot_operations)
43 #define sb_quotactl_ops (&vfs_quotactl_ops)
45 static __inline__
void DQUOT_INIT(struct inode
*inode
)
49 if (sb_any_quota_enabled(inode
->i_sb
) && !IS_NOQUOTA(inode
))
50 inode
->i_sb
->dq_op
->initialize(inode
, -1);
53 static __inline__
void DQUOT_DROP(struct inode
*inode
)
55 if (IS_QUOTAINIT(inode
)) {
58 inode
->i_sb
->dq_op
->drop(inode
); /* Ops must be set when there's any quota... */
62 static __inline__
int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode
*inode
, qsize_t nr
)
64 if (sb_any_quota_enabled(inode
->i_sb
)) {
65 /* Used space is updated in alloc_space() */
66 if (inode
->i_sb
->dq_op
->alloc_space(inode
, nr
, 1) == NO_QUOTA
)
70 spin_lock(&dq_data_lock
);
71 inode_add_bytes(inode
, nr
);
72 spin_unlock(&dq_data_lock
);
77 static __inline__
int DQUOT_PREALLOC_SPACE(struct inode
*inode
, qsize_t nr
)
80 if (!(ret
= DQUOT_PREALLOC_SPACE_NODIRTY(inode
, nr
)))
81 mark_inode_dirty(inode
);
85 static __inline__
int DQUOT_ALLOC_SPACE_NODIRTY(struct inode
*inode
, qsize_t nr
)
87 if (sb_any_quota_enabled(inode
->i_sb
)) {
88 /* Used space is updated in alloc_space() */
89 if (inode
->i_sb
->dq_op
->alloc_space(inode
, nr
, 0) == NO_QUOTA
)
93 spin_lock(&dq_data_lock
);
94 inode_add_bytes(inode
, nr
);
95 spin_unlock(&dq_data_lock
);
100 static __inline__
int DQUOT_ALLOC_SPACE(struct inode
*inode
, qsize_t nr
)
103 if (!(ret
= DQUOT_ALLOC_SPACE_NODIRTY(inode
, nr
)))
104 mark_inode_dirty(inode
);
108 static __inline__
int DQUOT_ALLOC_INODE(struct inode
*inode
)
110 if (sb_any_quota_enabled(inode
->i_sb
)) {
112 if (inode
->i_sb
->dq_op
->alloc_inode(inode
, 1) == NO_QUOTA
)
118 static __inline__
void DQUOT_FREE_SPACE_NODIRTY(struct inode
*inode
, qsize_t nr
)
120 if (sb_any_quota_enabled(inode
->i_sb
))
121 inode
->i_sb
->dq_op
->free_space(inode
, nr
);
123 spin_lock(&dq_data_lock
);
124 inode_sub_bytes(inode
, nr
);
125 spin_unlock(&dq_data_lock
);
129 static __inline__
void DQUOT_FREE_SPACE(struct inode
*inode
, qsize_t nr
)
131 DQUOT_FREE_SPACE_NODIRTY(inode
, nr
);
132 mark_inode_dirty(inode
);
135 static __inline__
void DQUOT_FREE_INODE(struct inode
*inode
)
137 if (sb_any_quota_enabled(inode
->i_sb
))
138 inode
->i_sb
->dq_op
->free_inode(inode
, 1);
141 static __inline__
int DQUOT_TRANSFER(struct inode
*inode
, struct iattr
*iattr
)
143 if (sb_any_quota_enabled(inode
->i_sb
) && !IS_NOQUOTA(inode
)) {
145 if (inode
->i_sb
->dq_op
->transfer(inode
, iattr
) == NO_QUOTA
)
151 #define DQUOT_SYNC(sb) sync_dquots(sb, -1)
153 static __inline__
int DQUOT_OFF(struct super_block
*sb
)
157 if (sb
->s_qcop
&& sb
->s_qcop
->quota_off
)
158 ret
= sb
->s_qcop
->quota_off(sb
, -1);
165 * NO-OP when quota not configured.
167 #define sb_dquot_ops (NULL)
168 #define sb_quotactl_ops (NULL)
169 #define sync_dquots_dev(dev,type) (NULL)
170 #define DQUOT_INIT(inode) do { } while(0)
171 #define DQUOT_DROP(inode) do { } while(0)
172 #define DQUOT_ALLOC_INODE(inode) (0)
173 #define DQUOT_FREE_INODE(inode) do { } while(0)
174 #define DQUOT_SYNC(sb) do { } while(0)
175 #define DQUOT_OFF(sb) do { } while(0)
176 #define DQUOT_TRANSFER(inode, iattr) (0)
177 extern __inline__
int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode
*inode
, qsize_t nr
)
179 inode_add_bytes(inode
, nr
);
183 extern __inline__
int DQUOT_PREALLOC_SPACE(struct inode
*inode
, qsize_t nr
)
185 DQUOT_PREALLOC_SPACE_NODIRTY(inode
, nr
);
186 mark_inode_dirty(inode
);
190 extern __inline__
int DQUOT_ALLOC_SPACE_NODIRTY(struct inode
*inode
, qsize_t nr
)
192 inode_add_bytes(inode
, nr
);
196 extern __inline__
int DQUOT_ALLOC_SPACE(struct inode
*inode
, qsize_t nr
)
198 DQUOT_ALLOC_SPACE_NODIRTY(inode
, nr
);
199 mark_inode_dirty(inode
);
203 extern __inline__
void DQUOT_FREE_SPACE_NODIRTY(struct inode
*inode
, qsize_t nr
)
205 inode_sub_bytes(inode
, nr
);
208 extern __inline__
void DQUOT_FREE_SPACE(struct inode
*inode
, qsize_t nr
)
210 DQUOT_FREE_SPACE_NODIRTY(inode
, nr
);
211 mark_inode_dirty(inode
);
214 #endif /* CONFIG_QUOTA */
216 #define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_PREALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
217 #define DQUOT_PREALLOC_BLOCK(inode, nr) DQUOT_PREALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
218 #define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_ALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
219 #define DQUOT_ALLOC_BLOCK(inode, nr) DQUOT_ALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
220 #define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) DQUOT_FREE_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
221 #define DQUOT_FREE_BLOCK(inode, nr) DQUOT_FREE_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
223 #endif /* _LINUX_QUOTAOPS_ */