4 #include "vserver/limit.h"
5 #include "vserver/base.h"
6 #include "vserver/context.h"
7 #include "vserver/debug.h"
8 #include "vserver/context.h"
9 #include "vserver/limit_int.h"
12 #define vx_acc_cres(v,d,p,r) \
13 __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15 #define vx_acc_cres_cond(x,d,p,r) \
16 __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
17 r, d, p, __FILE__, __LINE__)
20 #define vx_add_cres(v,a,p,r) \
21 __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
22 #define vx_sub_cres(v,a,p,r) vx_add_cres(v,-(a),p,r)
24 #define vx_add_cres_cond(x,a,p,r) \
25 __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
26 r, a, p, __FILE__, __LINE__)
27 #define vx_sub_cres_cond(x,a,p,r) vx_add_cres_cond(x,-(a),p,r)
30 /* process and file limits */
32 #define vx_nproc_inc(p) \
33 vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
35 #define vx_nproc_dec(p) \
36 vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
38 #define vx_files_inc(f) \
39 vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
41 #define vx_files_dec(f) \
42 vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
44 #define vx_locks_inc(l) \
45 vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
47 #define vx_locks_dec(l) \
48 vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
50 #define vx_openfd_inc(f) \
51 vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
53 #define vx_openfd_dec(f) \
54 vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
57 #define vx_cres_avail(v,n,r) \
58 __vx_cres_avail(v, r, n, __FILE__, __LINE__)
61 #define vx_nproc_avail(n) \
62 vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
64 #define vx_files_avail(n) \
65 vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
67 #define vx_locks_avail(n) \
68 vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
70 #define vx_openfd_avail(n) \
71 vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
76 #define vx_dentry_inc(d) do { \
77 if (atomic_read(&d->d_count) == 1) \
78 vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
81 #define vx_dentry_dec(d) do { \
82 if (atomic_read(&d->d_count) == 0) \
83 vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
86 #define vx_dentry_avail(n) \
87 vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
92 #define vx_sock_inc(s) \
93 vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
95 #define vx_sock_dec(s) \
96 vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
98 #define vx_sock_avail(n) \
99 vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
102 /* ipc resource limits */
104 #define vx_ipcmsg_add(v,u,a) \
105 vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
107 #define vx_ipcmsg_sub(v,u,a) \
108 vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
110 #define vx_ipcmsg_avail(v,a) \
111 vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
114 #define vx_ipcshm_add(v,k,a) \
115 vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
117 #define vx_ipcshm_sub(v,k,a) \
118 vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
120 #define vx_ipcshm_avail(v,a) \
121 vx_cres_avail(v, a, VLIMIT_SHMEM)
124 #define vx_semary_inc(a) \
125 vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
127 #define vx_semary_dec(a) \
128 vx_acc_cres(current->vx_info,-1, a, VLIMIT_SEMARY)
131 #define vx_nsems_add(a,n) \
132 vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
134 #define vx_nsems_sub(a,n) \
135 vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
139 #warning duplicate inclusion