1 diff -NurpP --minimal linux-2.6.32.56/Documentation/scheduler/sched-cfs-hard-limits.txt linux-2.6.32.56-vs2.3.0.36.29.9/Documentation/scheduler/sched-cfs-hard-limits.txt
2 --- linux-2.6.32.56/Documentation/scheduler/sched-cfs-hard-limits.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.32.56-vs2.3.0.36.29.9/Documentation/scheduler/sched-cfs-hard-limits.txt 2011-06-10 13:03:02.000000000 +0200
5 +CPU HARD LIMITS FOR CFS GROUPS
6 +==============================
15 +CFS is a proportional share scheduler which tries to divide the CPU time
16 +proportionately between tasks or groups of tasks (task group/cgroup) depending
17 +on the priority/weight of the task or shares assigned to groups of tasks.
18 +In CFS, a task/task group can get more than its share of CPU if there are
19 +enough idle CPU cycles available in the system, due to the work conserving
20 +nature of the scheduler. However in certain scenarios (like pay-per-use),
21 +it is desirable not to provide extra time to a group even in the presence
22 +of idle CPU cycles. This is where hard limiting can be of use.
24 +Hard limits for task groups can be set by specifying how much CPU runtime a
25 +group can consume within a given period. If the group consumes more CPU time
26 +than the runtime in a given period, it gets throttled. None of the tasks of
27 +the throttled group gets to run until the runtime of the group gets refreshed
28 +at the beginning of the next period.
33 +Hard limit feature adds 2 cgroup files for CFS group scheduler:
35 +cfs_runtime_us: Hard limit for the group in microseconds.
37 +cfs_period_us: Time period in microseconds within which hard limits is
40 +A group gets created with default values for runtime (infinite runtime which
41 +means hard limits disabled) and period (0.5s). Each group can set its own
42 +values for runtime and period independent of other groups in the system.
47 +# mount -t cgroup -ocpu none /cgroups/
51 +# echo 250000 > cfs_runtime_us /* set a 250ms runtime or limit */
52 +# echo 500000 > cfs_period_us /* set a 500ms period */
53 diff -NurpP --minimal linux-2.6.32.56/Documentation/vserver/debug.txt linux-2.6.32.56-vs2.3.0.36.29.9/Documentation/vserver/debug.txt
54 --- linux-2.6.32.56/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
55 +++ linux-2.6.32.56-vs2.3.0.36.29.9/Documentation/vserver/debug.txt 2011-06-10 13:03:02.000000000 +0200
60 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
61 + "vx_rmap_tgid: %p/%llx: %d -> %d"
65 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
66 + "FREE (%p,#%d)%c inode"
67 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
68 + "FREE (%p,#%d)%c %lld bytes"
69 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
70 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
71 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
72 + "rcu_free_dl_info(%p)"
73 + 4 10 "alloc_dl_info(%p,%d) = %p"
74 + "dealloc_dl_info(%p)"
75 + "get_dl_info(%p[#%d.%d])"
76 + "put_dl_info(%p[#%d.%d])"
77 + 5 20 "alloc_dl_info(%p,%d)*"
78 + 6 40 "__hash_dl_info: %p[#%d]"
79 + "__unhash_dl_info: %p[#%d]"
80 + 7 80 "locate_dl_info(%p,#%d) = %p"
84 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
85 + "new_dqhash: %p [#0x%08x]"
86 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
87 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
88 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
89 + "vroot_get_real_bdev not set"
90 + 1 2 "cow_break_link(»%s«)"
92 + 2 4 "dentry_open(new): %p"
93 + "dentry_open(old): %p"
94 + "lookup_create(new): %p"
96 + "path_lookup(old): %d"
97 + "vfs_create(new): %d"
100 + 3 8 "fput(new_file=%p[#%d])"
101 + "fput(old_file=%p[#%d])"
102 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
103 + "vx_info_kill(%p[#%d],%d,%d)*"
104 + 5 20 "vs_reboot(%p[#%d],%d)"
105 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
109 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
110 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
111 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
112 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
113 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
114 + 6 40 "sk,egf: %p [#%d] (from %d)"
115 + "sk,egn: %p [#%d] (from %d)"
116 + "sk,req: %p [#%d] (from %d)"
117 + "sk: %p [#%d] (from %d)"
118 + "tw: %p [#%d] (from %d)"
119 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
120 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
124 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
125 + "alloc_nx_info(%d) = %p"
126 + "create_nx_info(%d) (dynamic rejected)"
127 + "create_nx_info(%d) = %p (already there)"
128 + "create_nx_info(%d) = %p (new)"
129 + "dealloc_nx_info(%p)"
130 + 1 2 "alloc_nx_info(%d)*"
131 + "create_nx_info(%d)*"
132 + 2 4 "get_nx_info(%p[#%d.%d])"
133 + "put_nx_info(%p[#%d.%d])"
134 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
135 + "clr_nx_info(%p[#%d.%d])"
136 + "init_nx_info(%p[#%d.%d])"
137 + "release_nx_info(%p[#%d.%d.%d]) %p"
138 + "set_nx_info(%p[#%d.%d])"
139 + 4 10 "__hash_nx_info: %p[#%d]"
140 + "__nx_dynamic_id: [#%d]"
141 + "__unhash_nx_info: %p[#%d.%d.%d]"
142 + 5 20 "moved task %p into nxi:%p[#%d]"
143 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
144 + "task_get_nx_info(%p)"
145 + 6 40 "nx_clear_persistent(%p[#%d])"
149 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
150 + 1 2 "quota_sync_dqh(%p,%d)"
151 + "sync_dquots(%p,%d)"
152 + "sync_dquots_dqh(%p,%d)"
153 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
157 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
158 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
159 + 4 10 "%s: (%s %s) returned %s with %d"
163 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
164 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
168 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
169 + "alloc_vx_info(%d) = %p"
170 + "alloc_vx_info(%d)*"
171 + "create_vx_info(%d) (dynamic rejected)"
172 + "create_vx_info(%d) = %p (already there)"
173 + "create_vx_info(%d) = %p (new)"
174 + "dealloc_vx_info(%p)"
175 + "loc_vx_info(%d) = %p (found)"
176 + "loc_vx_info(%d) = %p (new)"
177 + "loc_vx_info(%d) = %p (not available)"
178 + 1 2 "create_vx_info(%d)*"
180 + 2 4 "get_vx_info(%p[#%d.%d])"
181 + "put_vx_info(%p[#%d.%d])"
182 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
183 + "clr_vx_info(%p[#%d.%d])"
184 + "init_vx_info(%p[#%d.%d])"
185 + "release_vx_info(%p[#%d.%d.%d]) %p"
186 + "set_vx_info(%p[#%d.%d])"
187 + 4 10 "__hash_vx_info: %p[#%d]"
188 + "__unhash_vx_info: %p[#%d.%d.%d]"
189 + "__vx_dynamic_id: [#%d]"
190 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
191 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
192 + "moved task %p into vxi:%p[#%d]"
193 + "task_get_vx_info(%p)"
194 + "vx_migrate_task(%p,%p[#%d.%d])"
195 + 6 40 "vx_clear_persistent(%p[#%d])"
196 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
197 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
198 + "vx_set_persistent(%p[#%d])"
199 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
200 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
205 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
206 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
208 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
209 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
210 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
211 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/Kconfig
212 --- linux-2.6.32.56/arch/alpha/Kconfig 2009-12-03 20:01:49.000000000 +0100
213 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/Kconfig 2011-06-10 13:03:02.000000000 +0200
214 @@ -674,6 +674,8 @@ config DUMMY_CONSOLE
218 +source "kernel/vserver/Kconfig"
220 source "security/Kconfig"
222 source "crypto/Kconfig"
223 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/kernel/entry.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/entry.S
224 --- linux-2.6.32.56/arch/alpha/kernel/entry.S 2009-06-11 17:11:46.000000000 +0200
225 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/entry.S 2011-06-10 13:03:02.000000000 +0200
226 @@ -874,24 +874,15 @@ sys_getxgid:
233 - ldq $2, TI_TASK($8)
235 - /* See linux/kernel/timer.c sys_getppid for discussion
236 - about this loop. */
237 - ldq $3, TASK_GROUP_LEADER($2)
238 - ldq $4, TASK_REAL_PARENT($3)
239 - ldl $0, TASK_TGID($2)
240 -1: ldl $1, TASK_TGID($4)
244 - ldq $3, TASK_GROUP_LEADER($2)
245 - ldq $4, TASK_REAL_PARENT($3)
251 + jsr $26, do_getxpid
258 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/kernel/osf_sys.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/osf_sys.c
259 --- linux-2.6.32.56/arch/alpha/kernel/osf_sys.c 2012-02-09 10:22:13.000000000 +0100
260 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/osf_sys.c 2011-11-17 12:18:26.000000000 +0100
261 @@ -865,7 +865,7 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct
265 - do_gettimeofday(&ktv);
266 + vx_gettimeofday(&ktv);
267 if (put_tv32(tv, &ktv))
270 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/kernel/ptrace.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/ptrace.c
271 --- linux-2.6.32.56/arch/alpha/kernel/ptrace.c 2009-09-10 15:25:14.000000000 +0200
272 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/ptrace.c 2011-06-10 13:03:02.000000000 +0200
274 #include <linux/slab.h>
275 #include <linux/security.h>
276 #include <linux/signal.h>
277 +#include <linux/vs_base.h>
279 #include <asm/uaccess.h>
280 #include <asm/pgtable.h>
281 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/kernel/systbls.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/systbls.S
282 --- linux-2.6.32.56/arch/alpha/kernel/systbls.S 2009-03-24 14:18:08.000000000 +0100
283 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/systbls.S 2011-06-10 13:03:02.000000000 +0200
284 @@ -446,7 +446,7 @@ sys_call_table:
285 .quad sys_stat64 /* 425 */
288 - .quad sys_ni_syscall /* sys_vserver */
289 + .quad sys_vserver /* sys_vserver */
290 .quad sys_ni_syscall /* sys_mbind */
291 .quad sys_ni_syscall /* sys_get_mempolicy */
292 .quad sys_ni_syscall /* sys_set_mempolicy */
293 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/traps.c
294 --- linux-2.6.32.56/arch/alpha/kernel/traps.c 2009-06-11 17:11:46.000000000 +0200
295 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
296 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
298 printk("CPU %d ", hard_smp_processor_id());
300 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
301 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
302 + task_pid_nr(current), current->xid, str, err);
303 dik_show_regs(regs, r9_15);
304 add_taint(TAINT_DIE);
305 dik_show_trace((unsigned long *)(regs+1));
306 diff -NurpP --minimal linux-2.6.32.56/arch/alpha/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/mm/fault.c
307 --- linux-2.6.32.56/arch/alpha/mm/fault.c 2009-09-10 15:25:14.000000000 +0200
308 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/alpha/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
309 @@ -193,8 +193,8 @@ do_page_fault(unsigned long address, uns
310 down_read(&mm->mmap_sem);
313 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
314 - current->comm, task_pid_nr(current));
315 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
316 + current->comm, task_pid_nr(current), current->xid);
317 if (!user_mode(regs))
319 do_group_exit(SIGKILL);
320 diff -NurpP --minimal linux-2.6.32.56/arch/arm/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/Kconfig
321 --- linux-2.6.32.56/arch/arm/Kconfig 2012-02-09 10:22:13.000000000 +0100
322 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/Kconfig 2012-01-10 09:18:12.000000000 +0100
323 @@ -1536,6 +1536,8 @@ source "fs/Kconfig"
325 source "arch/arm/Kconfig.debug"
327 +source "kernel/vserver/Kconfig"
329 source "security/Kconfig"
331 source "crypto/Kconfig"
332 diff -NurpP --minimal linux-2.6.32.56/arch/arm/include/asm/tlb.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/include/asm/tlb.h
333 --- linux-2.6.32.56/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
334 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/include/asm/tlb.h 2011-06-10 13:03:02.000000000 +0200
337 #else /* !CONFIG_MMU */
339 +#include <linux/vs_memory.h>
340 #include <asm/pgalloc.h>
343 diff -NurpP --minimal linux-2.6.32.56/arch/arm/kernel/calls.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/kernel/calls.S
344 --- linux-2.6.32.56/arch/arm/kernel/calls.S 2012-02-09 10:22:13.000000000 +0100
345 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/kernel/calls.S 2011-06-10 13:03:02.000000000 +0200
347 /* 310 */ CALL(sys_request_key)
349 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
350 -/* vserver */ CALL(sys_ni_syscall)
353 /* 315 */ CALL(sys_ioprio_get)
354 CALL(sys_inotify_init)
355 diff -NurpP --minimal linux-2.6.32.56/arch/arm/kernel/process.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/kernel/process.c
356 --- linux-2.6.32.56/arch/arm/kernel/process.c 2012-02-09 10:22:13.000000000 +0100
357 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/kernel/process.c 2012-01-10 09:18:12.000000000 +0100
358 @@ -272,7 +272,8 @@ void __show_regs(struct pt_regs *regs)
359 void show_regs(struct pt_regs * regs)
362 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
363 + printk("Pid: %d[#%u], comm: %20s\n",
364 + task_pid_nr(current), current->xid, current->comm);
368 diff -NurpP --minimal linux-2.6.32.56/arch/arm/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/kernel/traps.c
369 --- linux-2.6.32.56/arch/arm/kernel/traps.c 2009-12-03 20:01:50.000000000 +0100
370 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/arm/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
371 @@ -234,8 +234,8 @@ static void __die(const char *str, int e
372 sysfs_printk_last_file();
375 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
376 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
377 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
378 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
380 if (!user_mode(regs) || in_interrupt()) {
381 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
382 diff -NurpP --minimal linux-2.6.32.56/arch/avr32/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/avr32/mm/fault.c
383 --- linux-2.6.32.56/arch/avr32/mm/fault.c 2009-09-10 15:25:20.000000000 +0200
384 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/avr32/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
385 @@ -216,7 +216,8 @@ out_of_memory:
386 down_read(&mm->mmap_sem);
389 - printk("VM: Killing process %s\n", tsk->comm);
390 + printk("VM: Killing process %s(%d:#%u)\n",
391 + tsk->comm, task_pid_nr(tsk), tsk->xid);
393 do_group_exit(SIGKILL);
395 diff -NurpP --minimal linux-2.6.32.56/arch/cris/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/cris/Kconfig
396 --- linux-2.6.32.56/arch/cris/Kconfig 2009-06-11 17:11:56.000000000 +0200
397 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/cris/Kconfig 2011-06-10 13:03:02.000000000 +0200
398 @@ -685,6 +685,8 @@ source "drivers/staging/Kconfig"
400 source "arch/cris/Kconfig.debug"
402 +source "kernel/vserver/Kconfig"
404 source "security/Kconfig"
406 source "crypto/Kconfig"
407 diff -NurpP --minimal linux-2.6.32.56/arch/cris/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/cris/mm/fault.c
408 --- linux-2.6.32.56/arch/cris/mm/fault.c 2009-12-03 20:01:56.000000000 +0100
409 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/cris/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
410 @@ -245,7 +245,8 @@ do_page_fault(unsigned long address, str
413 up_read(&mm->mmap_sem);
414 - printk("VM: killing process %s\n", tsk->comm);
415 + printk("VM: killing process %s(%d:#%u)\n",
416 + tsk->comm, task_pid_nr(tsk), tsk->xid);
420 diff -NurpP --minimal linux-2.6.32.56/arch/frv/kernel/kernel_thread.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/frv/kernel/kernel_thread.S
421 --- linux-2.6.32.56/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
422 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/frv/kernel/kernel_thread.S 2011-06-10 13:03:02.000000000 +0200
423 @@ -37,7 +37,7 @@ kernel_thread:
425 # start by forking the current process, but with shared VM
426 setlos.p #__NR_clone,gr7 ; syscall number
427 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
428 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
429 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
431 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
432 diff -NurpP --minimal linux-2.6.32.56/arch/frv/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/frv/mm/fault.c
433 --- linux-2.6.32.56/arch/frv/mm/fault.c 2009-09-10 15:25:22.000000000 +0200
434 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/frv/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
435 @@ -257,7 +257,8 @@ asmlinkage void do_page_fault(int datamm
438 up_read(&mm->mmap_sem);
439 - printk("VM: killing process %s\n", current->comm);
440 + printk("VM: killing process %s(%d:#%u)\n",
441 + current->comm, task_pid_nr(current), current->xid);
442 if (user_mode(__frame))
443 do_group_exit(SIGKILL);
445 diff -NurpP --minimal linux-2.6.32.56/arch/h8300/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/h8300/Kconfig
446 --- linux-2.6.32.56/arch/h8300/Kconfig 2009-03-24 14:18:24.000000000 +0100
447 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/h8300/Kconfig 2011-06-10 13:03:02.000000000 +0200
448 @@ -226,6 +226,8 @@ source "fs/Kconfig"
450 source "arch/h8300/Kconfig.debug"
452 +source "kernel/vserver/Kconfig"
454 source "security/Kconfig"
456 source "crypto/Kconfig"
457 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/Kconfig
458 --- linux-2.6.32.56/arch/ia64/Kconfig 2009-12-03 20:01:56.000000000 +0100
459 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/Kconfig 2011-06-10 13:03:02.000000000 +0200
460 @@ -685,6 +685,8 @@ source "fs/Kconfig"
462 source "arch/ia64/Kconfig.debug"
464 +source "kernel/vserver/Kconfig"
466 source "security/Kconfig"
468 source "crypto/Kconfig"
469 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/ia32/ia32_entry.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/ia32/ia32_entry.S
470 --- linux-2.6.32.56/arch/ia64/ia32/ia32_entry.S 2009-06-11 17:11:57.000000000 +0200
471 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/ia32/ia32_entry.S 2011-06-10 13:03:02.000000000 +0200
472 @@ -451,7 +451,7 @@ ia32_syscall_table:
473 data8 sys_tgkill /* 270 */
474 data8 compat_sys_utimes
475 data8 sys32_fadvise64_64
476 - data8 sys_ni_syscall
477 + data8 sys32_vserver
479 data8 sys_ni_syscall /* 275 */
481 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/include/asm/tlb.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/include/asm/tlb.h
482 --- linux-2.6.32.56/arch/ia64/include/asm/tlb.h 2009-09-10 15:25:22.000000000 +0200
483 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/include/asm/tlb.h 2011-06-10 13:03:02.000000000 +0200
485 #include <linux/mm.h>
486 #include <linux/pagemap.h>
487 #include <linux/swap.h>
488 +#include <linux/vs_memory.h>
490 #include <asm/pgalloc.h>
491 #include <asm/processor.h>
492 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/kernel/entry.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/entry.S
493 --- linux-2.6.32.56/arch/ia64/kernel/entry.S 2009-09-10 15:25:22.000000000 +0200
494 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/entry.S 2011-06-10 13:03:02.000000000 +0200
495 @@ -1753,7 +1753,7 @@ sys_call_table:
497 data8 sys_mq_getsetattr
499 - data8 sys_ni_syscall // reserved for vserver
501 data8 sys_waitid // 1270
503 data8 sys_request_key
504 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/kernel/perfmon.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/perfmon.c
505 --- linux-2.6.32.56/arch/ia64/kernel/perfmon.c 2009-09-10 15:25:22.000000000 +0200
506 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/perfmon.c 2011-06-10 13:03:02.000000000 +0200
508 #include <linux/rcupdate.h>
509 #include <linux/completion.h>
510 #include <linux/tracehook.h>
511 +#include <linux/vs_memory.h>
513 #include <asm/errno.h>
514 #include <asm/intrinsics.h>
515 @@ -2372,7 +2373,7 @@ pfm_smpl_buffer_alloc(struct task_struct
517 insert_vm_struct(mm, vma);
519 - mm->total_vm += size >> PAGE_SHIFT;
520 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
521 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
523 up_write(&task->mm->mmap_sem);
524 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/kernel/process.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/process.c
525 --- linux-2.6.32.56/arch/ia64/kernel/process.c 2009-12-03 20:01:56.000000000 +0100
526 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/process.c 2011-06-10 13:03:02.000000000 +0200
527 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
528 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
531 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
532 - smp_processor_id(), current->comm);
533 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
534 + current->xid, smp_processor_id(), current->comm);
535 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
536 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
537 init_utsname()->release);
538 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/kernel/ptrace.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/ptrace.c
539 --- linux-2.6.32.56/arch/ia64/kernel/ptrace.c 2009-09-10 15:25:22.000000000 +0200
540 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/ptrace.c 2011-06-10 13:03:02.000000000 +0200
542 #include <linux/regset.h>
543 #include <linux/elf.h>
544 #include <linux/tracehook.h>
545 +#include <linux/vs_base.h>
547 #include <asm/pgtable.h>
548 #include <asm/processor.h>
549 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/traps.c
550 --- linux-2.6.32.56/arch/ia64/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
551 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
552 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
555 if (++die.lock_owner_depth < 3) {
556 - printk("%s[%d]: %s %ld [%d]\n",
557 - current->comm, task_pid_nr(current), str, err, ++die_counter);
558 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
559 + current->comm, task_pid_nr(current), current->xid,
560 + str, err, ++die_counter);
561 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
564 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
565 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
566 last.time = current_jiffies + 5 * HZ;
568 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
569 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
570 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
571 + current->comm, task_pid_nr(current), current->xid,
572 + regs->cr_iip + ia64_psr(regs)->ri, isr);
576 diff -NurpP --minimal linux-2.6.32.56/arch/ia64/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/mm/fault.c
577 --- linux-2.6.32.56/arch/ia64/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
578 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/ia64/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
580 #include <linux/interrupt.h>
581 #include <linux/kprobes.h>
582 #include <linux/kdebug.h>
583 +#include <linux/vs_memory.h>
585 #include <asm/pgtable.h>
586 #include <asm/processor.h>
587 @@ -281,7 +282,8 @@ ia64_do_page_fault (unsigned long addres
588 down_read(&mm->mmap_sem);
591 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
592 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
593 + current->comm, task_pid_nr(current), current->xid);
595 do_group_exit(SIGKILL);
597 diff -NurpP --minimal linux-2.6.32.56/arch/m32r/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/m32r/kernel/traps.c
598 --- linux-2.6.32.56/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
599 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m32r/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
600 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
602 printk("SPI: %08lx\n", sp);
604 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
605 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
606 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
607 + current->comm, task_pid_nr(current), current->xid,
608 + 0xffff & i, 4096+(unsigned long)current);
611 * When in-kernel, we also print out the stack and code at the
612 diff -NurpP --minimal linux-2.6.32.56/arch/m32r/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/m32r/mm/fault.c
613 --- linux-2.6.32.56/arch/m32r/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
614 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m32r/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
615 @@ -276,7 +276,8 @@ out_of_memory:
616 down_read(&mm->mmap_sem);
619 - printk("VM: killing process %s\n", tsk->comm);
620 + printk("VM: killing process %s(%d:#%u)\n",
621 + tsk->comm, task_pid_nr(tsk), tsk->xid);
622 if (error_code & ACE_USERMODE)
623 do_group_exit(SIGKILL);
625 diff -NurpP --minimal linux-2.6.32.56/arch/m68k/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/Kconfig
626 --- linux-2.6.32.56/arch/m68k/Kconfig 2009-12-03 20:01:57.000000000 +0100
627 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/Kconfig 2011-06-10 13:03:02.000000000 +0200
628 @@ -622,6 +622,8 @@ source "fs/Kconfig"
630 source "arch/m68k/Kconfig.debug"
632 +source "kernel/vserver/Kconfig"
634 source "security/Kconfig"
636 source "crypto/Kconfig"
637 diff -NurpP --minimal linux-2.6.32.56/arch/m68k/kernel/ptrace.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/kernel/ptrace.c
638 --- linux-2.6.32.56/arch/m68k/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
639 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/kernel/ptrace.c 2011-06-10 13:03:02.000000000 +0200
641 #include <linux/ptrace.h>
642 #include <linux/user.h>
643 #include <linux/signal.h>
644 +#include <linux/vs_base.h>
646 #include <asm/uaccess.h>
647 #include <asm/page.h>
648 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
649 ret = ptrace_request(child, request, addr, data);
652 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
657 diff -NurpP --minimal linux-2.6.32.56/arch/m68k/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/kernel/traps.c
658 --- linux-2.6.32.56/arch/m68k/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
659 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
660 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
661 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
662 regs->d4, regs->d5, regs->a0, regs->a1);
664 - printk("Process %s (pid: %d, task=%p)\n",
665 - current->comm, task_pid_nr(current), current);
666 + printk("Process %s (pid: %d[#%u], task=%p)\n",
667 + current->comm, task_pid_nr(current), current->xid, current);
668 addr = (unsigned long)&fp->un;
669 printk("Frame format=%X ", regs->format);
670 switch (regs->format) {
671 diff -NurpP --minimal linux-2.6.32.56/arch/m68k/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/mm/fault.c
672 --- linux-2.6.32.56/arch/m68k/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
673 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68k/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
674 @@ -186,7 +186,8 @@ out_of_memory:
678 - printk("VM: killing process %s\n", current->comm);
679 + printk("VM: killing process %s(%d:#%u)\n",
680 + current->comm, task_pid_nr(current), current->xid);
682 do_group_exit(SIGKILL);
684 diff -NurpP --minimal linux-2.6.32.56/arch/m68knommu/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68knommu/Kconfig
685 --- linux-2.6.32.56/arch/m68knommu/Kconfig 2009-12-03 20:01:57.000000000 +0100
686 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68knommu/Kconfig 2011-06-10 13:03:02.000000000 +0200
687 @@ -727,6 +727,8 @@ source "fs/Kconfig"
689 source "arch/m68knommu/Kconfig.debug"
691 +source "kernel/vserver/Kconfig"
693 source "security/Kconfig"
695 source "crypto/Kconfig"
696 diff -NurpP --minimal linux-2.6.32.56/arch/m68knommu/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68knommu/kernel/traps.c
697 --- linux-2.6.32.56/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
698 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/m68knommu/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
699 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
700 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
701 fp->d4, fp->d5, fp->a0, fp->a1);
703 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
704 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
705 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
706 + current->comm, task_pid_nr(current), current->xid,
707 + PAGE_SIZE+(unsigned long)current);
708 show_stack(NULL, (unsigned long *)(fp + 1));
709 add_taint(TAINT_DIE);
711 diff -NurpP --minimal linux-2.6.32.56/arch/microblaze/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/microblaze/mm/fault.c
712 --- linux-2.6.32.56/arch/microblaze/mm/fault.c 2009-09-10 15:25:24.000000000 +0200
713 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/microblaze/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
714 @@ -279,7 +279,8 @@ out_of_memory:
717 up_read(&mm->mmap_sem);
718 - printk(KERN_WARNING "VM: killing process %s\n", current->comm);
719 + printk(KERN_WARNING "VM: killing process %s(%d:#%u)\n",
720 + current->comm, task_pid_nr(current), current->xid);
723 bad_page_fault(regs, address, SIGKILL);
724 diff -NurpP --minimal linux-2.6.32.56/arch/mips/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/Kconfig
725 --- linux-2.6.32.56/arch/mips/Kconfig 2009-12-03 20:01:58.000000000 +0100
726 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/Kconfig 2011-06-10 13:03:02.000000000 +0200
727 @@ -2188,6 +2188,8 @@ source "fs/Kconfig"
729 source "arch/mips/Kconfig.debug"
731 +source "kernel/vserver/Kconfig"
733 source "security/Kconfig"
735 source "crypto/Kconfig"
736 diff -NurpP --minimal linux-2.6.32.56/arch/mips/kernel/ptrace.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/ptrace.c
737 --- linux-2.6.32.56/arch/mips/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
738 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/ptrace.c 2011-06-10 13:03:02.000000000 +0200
740 #include <linux/security.h>
741 #include <linux/audit.h>
742 #include <linux/seccomp.h>
743 +#include <linux/vs_base.h>
745 #include <asm/byteorder.h>
747 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
751 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
755 /* when I and D space are separate, these will need to be fixed. */
756 case PTRACE_PEEKTEXT: /* read word at location addr. */
757 diff -NurpP --minimal linux-2.6.32.56/arch/mips/kernel/scall32-o32.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall32-o32.S
758 --- linux-2.6.32.56/arch/mips/kernel/scall32-o32.S 2009-12-03 20:01:59.000000000 +0100
759 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall32-o32.S 2011-06-10 13:03:02.000000000 +0200
760 @@ -525,7 +525,7 @@ einval: li v0, -ENOSYS
761 sys sys_mq_timedreceive 5
762 sys sys_mq_notify 2 /* 4275 */
763 sys sys_mq_getsetattr 3
764 - sys sys_ni_syscall 0 /* sys_vserver */
767 sys sys_ni_syscall 0 /* available, was setaltroot */
768 sys sys_add_key 5 /* 4280 */
769 diff -NurpP --minimal linux-2.6.32.56/arch/mips/kernel/scall64-64.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall64-64.S
770 --- linux-2.6.32.56/arch/mips/kernel/scall64-64.S 2009-12-03 20:01:59.000000000 +0100
771 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall64-64.S 2011-06-10 13:03:02.000000000 +0200
772 @@ -362,7 +362,7 @@ sys_call_table:
773 PTR sys_mq_timedreceive
775 PTR sys_mq_getsetattr /* 5235 */
776 - PTR sys_ni_syscall /* sys_vserver */
779 PTR sys_ni_syscall /* available, was setaltroot */
781 diff -NurpP --minimal linux-2.6.32.56/arch/mips/kernel/scall64-n32.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall64-n32.S
782 --- linux-2.6.32.56/arch/mips/kernel/scall64-n32.S 2009-12-03 20:01:59.000000000 +0100
783 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall64-n32.S 2011-06-10 13:03:02.000000000 +0200
784 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
785 PTR compat_sys_mq_timedreceive
786 PTR compat_sys_mq_notify
787 PTR compat_sys_mq_getsetattr
788 - PTR sys_ni_syscall /* 6240, sys_vserver */
789 + PTR sys32_vserver /* 6240 */
790 PTR compat_sys_waitid
791 PTR sys_ni_syscall /* available, was setaltroot */
793 diff -NurpP --minimal linux-2.6.32.56/arch/mips/kernel/scall64-o32.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall64-o32.S
794 --- linux-2.6.32.56/arch/mips/kernel/scall64-o32.S 2009-12-03 20:01:59.000000000 +0100
795 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/scall64-o32.S 2011-06-10 13:03:02.000000000 +0200
796 @@ -480,7 +480,7 @@ sys_call_table:
797 PTR compat_sys_mq_timedreceive
798 PTR compat_sys_mq_notify /* 4275 */
799 PTR compat_sys_mq_getsetattr
800 - PTR sys_ni_syscall /* sys_vserver */
803 PTR sys_ni_syscall /* available, was setaltroot */
804 PTR sys_add_key /* 4280 */
805 diff -NurpP --minimal linux-2.6.32.56/arch/mips/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/traps.c
806 --- linux-2.6.32.56/arch/mips/kernel/traps.c 2009-12-03 20:01:59.000000000 +0100
807 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mips/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
808 @@ -335,9 +335,10 @@ void show_registers(const struct pt_regs
812 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
813 - current->comm, current->pid, current_thread_info(), current,
814 - field, current_thread_info()->tp_value);
815 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
816 + current->comm, task_pid_nr(current), current->xid,
817 + current_thread_info(), current,
818 + field, current_thread_info()->tp_value);
819 if (cpu_has_userlocal) {
822 diff -NurpP --minimal linux-2.6.32.56/arch/mn10300/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/mn10300/mm/fault.c
823 --- linux-2.6.32.56/arch/mn10300/mm/fault.c 2009-09-10 15:25:39.000000000 +0200
824 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/mn10300/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
825 @@ -339,7 +339,8 @@ no_context:
827 up_read(&mm->mmap_sem);
828 monitor_signal(regs);
829 - printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
830 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
831 + tsk->comm, task_pid_nr(tsk), tsk->xid);
832 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
835 diff -NurpP --minimal linux-2.6.32.56/arch/parisc/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/Kconfig
836 --- linux-2.6.32.56/arch/parisc/Kconfig 2009-12-03 20:02:00.000000000 +0100
837 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/Kconfig 2011-06-10 13:03:02.000000000 +0200
838 @@ -294,6 +294,8 @@ source "fs/Kconfig"
840 source "arch/parisc/Kconfig.debug"
842 +source "kernel/vserver/Kconfig"
844 source "security/Kconfig"
846 source "crypto/Kconfig"
847 diff -NurpP --minimal linux-2.6.32.56/arch/parisc/kernel/syscall_table.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/kernel/syscall_table.S
848 --- linux-2.6.32.56/arch/parisc/kernel/syscall_table.S 2009-12-03 20:02:00.000000000 +0100
849 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/kernel/syscall_table.S 2011-06-10 13:03:02.000000000 +0200
851 ENTRY_COMP(mbind) /* 260 */
852 ENTRY_COMP(get_mempolicy)
853 ENTRY_COMP(set_mempolicy)
854 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
855 + ENTRY_DIFF(vserver)
857 ENTRY_SAME(request_key) /* 265 */
859 diff -NurpP --minimal linux-2.6.32.56/arch/parisc/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/kernel/traps.c
860 --- linux-2.6.32.56/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
861 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
862 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
866 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
867 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
868 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
869 + current->comm, task_pid_nr(current), current->xid,
870 + str, err, regs->iaoq[0]);
871 #ifdef PRINT_USER_FAULTS
872 /* XXX for debugging only */
874 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
875 pdc_console_restart();
878 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
879 - current->comm, task_pid_nr(current), str, err);
880 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
881 + current->comm, task_pid_nr(current), current->xid, str, err);
883 /* Wot's wrong wif bein' racy? */
884 if (current->thread.flags & PARISC_KERNEL_DEATH) {
885 diff -NurpP --minimal linux-2.6.32.56/arch/parisc/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/mm/fault.c
886 --- linux-2.6.32.56/arch/parisc/mm/fault.c 2009-09-10 15:25:40.000000000 +0200
887 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/parisc/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
888 @@ -237,8 +237,9 @@ bad_area:
890 #ifdef PRINT_USER_FAULTS
891 printk(KERN_DEBUG "\n");
892 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
893 - task_pid_nr(tsk), tsk->comm, code, address);
894 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
895 + "command='%s' type=%lu address=0x%08lx\n",
896 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
898 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
899 vma->vm_start, vma->vm_end);
900 @@ -264,7 +265,8 @@ no_context:
903 up_read(&mm->mmap_sem);
904 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
905 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
906 + current->comm, current->pid, current->xid);
908 do_group_exit(SIGKILL);
910 diff -NurpP --minimal linux-2.6.32.56/arch/powerpc/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/Kconfig
911 --- linux-2.6.32.56/arch/powerpc/Kconfig 2009-12-03 20:02:00.000000000 +0100
912 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/Kconfig 2011-06-10 13:03:02.000000000 +0200
913 @@ -943,6 +943,8 @@ source "lib/Kconfig"
915 source "arch/powerpc/Kconfig.debug"
917 +source "kernel/vserver/Kconfig"
919 source "security/Kconfig"
922 diff -NurpP --minimal linux-2.6.32.56/arch/powerpc/include/asm/unistd.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/include/asm/unistd.h
923 --- linux-2.6.32.56/arch/powerpc/include/asm/unistd.h 2009-12-03 20:02:01.000000000 +0100
924 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/include/asm/unistd.h 2011-06-10 13:03:02.000000000 +0200
927 #define __NR_rtas 255
928 #define __NR_sys_debug_setcontext 256
929 -/* Number 257 is reserved for vserver */
930 +#define __NR_vserver 257
931 #define __NR_migrate_pages 258
932 #define __NR_mbind 259
933 #define __NR_get_mempolicy 260
934 diff -NurpP --minimal linux-2.6.32.56/arch/powerpc/kernel/process.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/kernel/process.c
935 --- linux-2.6.32.56/arch/powerpc/kernel/process.c 2012-02-09 10:22:15.000000000 +0100
936 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/kernel/process.c 2011-06-10 13:03:02.000000000 +0200
937 @@ -519,8 +519,9 @@ void show_regs(struct pt_regs * regs)
939 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
941 - printk("TASK = %p[%d] '%s' THREAD: %p",
942 - current, task_pid_nr(current), current->comm, task_thread_info(current));
943 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
944 + current, task_pid_nr(current), current->xid,
945 + current->comm, task_thread_info(current));
948 printk(" CPU: %d", raw_smp_processor_id());
949 diff -NurpP --minimal linux-2.6.32.56/arch/powerpc/kernel/traps.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/kernel/traps.c
950 --- linux-2.6.32.56/arch/powerpc/kernel/traps.c 2009-09-10 15:25:41.000000000 +0200
951 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/kernel/traps.c 2011-06-10 13:03:02.000000000 +0200
952 @@ -931,8 +931,9 @@ void nonrecoverable_exception(struct pt_
954 void trace_syscall(struct pt_regs *regs)
956 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
957 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
958 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
959 + current, task_pid_nr(current), current->xid,
960 + regs->nip, regs->link, regs->gpr[0],
961 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
964 diff -NurpP --minimal linux-2.6.32.56/arch/powerpc/kernel/vdso.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/kernel/vdso.c
965 --- linux-2.6.32.56/arch/powerpc/kernel/vdso.c 2009-12-03 20:02:02.000000000 +0100
966 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/kernel/vdso.c 2011-06-10 13:03:02.000000000 +0200
968 #include <linux/security.h>
969 #include <linux/bootmem.h>
970 #include <linux/lmb.h>
971 +#include <linux/vs_memory.h>
973 #include <asm/pgtable.h>
974 #include <asm/system.h>
975 diff -NurpP --minimal linux-2.6.32.56/arch/powerpc/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/mm/fault.c
976 --- linux-2.6.32.56/arch/powerpc/mm/fault.c 2009-12-03 20:02:02.000000000 +0100
977 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/powerpc/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
978 @@ -358,7 +358,8 @@ out_of_memory:
979 down_read(&mm->mmap_sem);
982 - printk("VM: killing process %s\n", current->comm);
983 + printk("VM: killing process %s(%d:#%u)\n",
984 + current->comm, current->pid, current->xid);
986 do_group_exit(SIGKILL);
988 diff -NurpP --minimal linux-2.6.32.56/arch/s390/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/Kconfig
989 --- linux-2.6.32.56/arch/s390/Kconfig 2009-12-03 20:02:03.000000000 +0100
990 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/Kconfig 2011-06-10 13:03:02.000000000 +0200
991 @@ -616,6 +616,8 @@ source "fs/Kconfig"
993 source "arch/s390/Kconfig.debug"
995 +source "kernel/vserver/Kconfig"
997 source "security/Kconfig"
999 source "crypto/Kconfig"
1000 diff -NurpP --minimal linux-2.6.32.56/arch/s390/include/asm/tlb.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/include/asm/tlb.h
1001 --- linux-2.6.32.56/arch/s390/include/asm/tlb.h 2009-09-10 15:25:43.000000000 +0200
1002 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/include/asm/tlb.h 2011-06-10 13:03:02.000000000 +0200
1005 #include <linux/mm.h>
1006 #include <linux/swap.h>
1007 +#include <linux/vs_memory.h>
1009 #include <asm/processor.h>
1010 #include <asm/pgalloc.h>
1011 #include <asm/smp.h>
1012 diff -NurpP --minimal linux-2.6.32.56/arch/s390/include/asm/unistd.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/include/asm/unistd.h
1013 --- linux-2.6.32.56/arch/s390/include/asm/unistd.h 2009-12-03 20:02:03.000000000 +0100
1014 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/include/asm/unistd.h 2011-06-10 13:03:02.000000000 +0200
1016 #define __NR_clock_gettime (__NR_timer_create+6)
1017 #define __NR_clock_getres (__NR_timer_create+7)
1018 #define __NR_clock_nanosleep (__NR_timer_create+8)
1019 -/* Number 263 is reserved for vserver */
1020 +#define __NR_vserver 263
1021 #define __NR_statfs64 265
1022 #define __NR_fstatfs64 266
1023 #define __NR_remap_file_pages 267
1024 diff -NurpP --minimal linux-2.6.32.56/arch/s390/kernel/ptrace.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/kernel/ptrace.c
1025 --- linux-2.6.32.56/arch/s390/kernel/ptrace.c 2012-02-09 10:22:15.000000000 +0100
1026 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/kernel/ptrace.c 2011-06-10 13:03:02.000000000 +0200
1028 #include <linux/regset.h>
1029 #include <linux/tracehook.h>
1030 #include <linux/seccomp.h>
1031 +#include <linux/vs_base.h>
1032 #include <linux/compat.h>
1033 #include <trace/syscall.h>
1034 #include <asm/segment.h>
1035 diff -NurpP --minimal linux-2.6.32.56/arch/s390/kernel/syscalls.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/kernel/syscalls.S
1036 --- linux-2.6.32.56/arch/s390/kernel/syscalls.S 2009-12-03 20:02:03.000000000 +0100
1037 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/kernel/syscalls.S 2011-06-10 13:03:02.000000000 +0200
1038 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
1039 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
1040 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
1041 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
1042 -NI_SYSCALL /* reserved for vserver */
1043 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
1044 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
1045 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
1046 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
1047 diff -NurpP --minimal linux-2.6.32.56/arch/s390/lib/uaccess_pt.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/lib/uaccess_pt.c
1048 --- linux-2.6.32.56/arch/s390/lib/uaccess_pt.c 2009-09-10 15:25:43.000000000 +0200
1049 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/s390/lib/uaccess_pt.c 2011-06-10 13:03:02.000000000 +0200
1050 @@ -90,7 +90,8 @@ out_of_memory:
1051 down_read(&mm->mmap_sem);
1054 - printk("VM: killing process %s\n", current->comm);
1055 + printk("VM: killing process %s(%d:#%u)\n",
1056 + current->comm, task_pid_nr(current), current->xid);
1060 diff -NurpP --minimal linux-2.6.32.56/arch/sh/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/Kconfig
1061 --- linux-2.6.32.56/arch/sh/Kconfig 2009-12-03 20:02:03.000000000 +0100
1062 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/Kconfig 2011-06-10 13:03:02.000000000 +0200
1063 @@ -853,6 +853,8 @@ source "fs/Kconfig"
1065 source "arch/sh/Kconfig.debug"
1067 +source "kernel/vserver/Kconfig"
1069 source "security/Kconfig"
1071 source "crypto/Kconfig"
1072 diff -NurpP --minimal linux-2.6.32.56/arch/sh/kernel/irq.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/kernel/irq.c
1073 --- linux-2.6.32.56/arch/sh/kernel/irq.c 2009-12-03 20:02:10.000000000 +0100
1074 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/kernel/irq.c 2011-06-10 13:03:02.000000000 +0200
1076 #include <linux/kernel_stat.h>
1077 #include <linux/seq_file.h>
1078 #include <linux/ftrace.h>
1079 +// #include <linux/vs_context.h>
1080 #include <asm/processor.h>
1081 #include <asm/machvec.h>
1082 #include <asm/uaccess.h>
1083 diff -NurpP --minimal linux-2.6.32.56/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/kernel/vsyscall/vsyscall.c
1084 --- linux-2.6.32.56/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:18:42.000000000 +0100
1085 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/kernel/vsyscall/vsyscall.c 2011-06-10 13:03:02.000000000 +0200
1087 #include <linux/elf.h>
1088 #include <linux/sched.h>
1089 #include <linux/err.h>
1090 +#include <linux/vs_memory.h>
1093 * Should the kernel map a VDSO page into processes and pass its
1094 diff -NurpP --minimal linux-2.6.32.56/arch/sh/mm/fault_32.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/mm/fault_32.c
1095 --- linux-2.6.32.56/arch/sh/mm/fault_32.c 2009-12-03 20:02:14.000000000 +0100
1096 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/mm/fault_32.c 2011-06-10 13:03:02.000000000 +0200
1097 @@ -292,7 +292,8 @@ out_of_memory:
1098 down_read(&mm->mmap_sem);
1101 - printk("VM: killing process %s\n", tsk->comm);
1102 + printk("VM: killing process %s(%d:#%u)\n",
1103 + tsk->comm, task_pid_nr(tsk), tsk->xid);
1104 if (user_mode(regs))
1105 do_group_exit(SIGKILL);
1107 diff -NurpP --minimal linux-2.6.32.56/arch/sh/mm/tlbflush_64.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/mm/tlbflush_64.c
1108 --- linux-2.6.32.56/arch/sh/mm/tlbflush_64.c 2009-12-03 20:02:14.000000000 +0100
1109 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sh/mm/tlbflush_64.c 2011-06-10 13:03:02.000000000 +0200
1110 @@ -306,7 +306,8 @@ out_of_memory:
1111 down_read(&mm->mmap_sem);
1114 - printk("VM: killing process %s\n", tsk->comm);
1115 + printk("VM: killing process %s(%d:#%u)\n",
1116 + tsk->comm, task_pid_nr(tsk), tsk->xid);
1117 if (user_mode(regs))
1118 do_group_exit(SIGKILL);
1120 diff -NurpP --minimal linux-2.6.32.56/arch/sparc/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/Kconfig
1121 --- linux-2.6.32.56/arch/sparc/Kconfig 2009-12-03 20:02:14.000000000 +0100
1122 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/Kconfig 2011-06-10 13:03:02.000000000 +0200
1123 @@ -550,6 +550,8 @@ source "fs/Kconfig"
1125 source "arch/sparc/Kconfig.debug"
1127 +source "kernel/vserver/Kconfig"
1129 source "security/Kconfig"
1131 source "crypto/Kconfig"
1132 diff -NurpP --minimal linux-2.6.32.56/arch/sparc/include/asm/tlb_64.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/include/asm/tlb_64.h
1133 --- linux-2.6.32.56/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
1134 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/include/asm/tlb_64.h 2011-06-10 13:03:02.000000000 +0200
1137 #include <linux/swap.h>
1138 #include <linux/pagemap.h>
1139 +#include <linux/vs_memory.h>
1140 #include <asm/pgalloc.h>
1141 #include <asm/tlbflush.h>
1142 #include <asm/mmu_context.h>
1143 diff -NurpP --minimal linux-2.6.32.56/arch/sparc/include/asm/unistd.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/include/asm/unistd.h
1144 --- linux-2.6.32.56/arch/sparc/include/asm/unistd.h 2009-12-03 20:02:15.000000000 +0100
1145 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/include/asm/unistd.h 2011-06-10 13:03:02.000000000 +0200
1147 #define __NR_timer_getoverrun 264
1148 #define __NR_timer_delete 265
1149 #define __NR_timer_create 266
1150 -/* #define __NR_vserver 267 Reserved for VSERVER */
1151 +#define __NR_vserver 267
1152 #define __NR_io_setup 268
1153 #define __NR_io_destroy 269
1154 #define __NR_io_submit 270
1155 diff -NurpP --minimal linux-2.6.32.56/arch/sparc/kernel/systbls_32.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/kernel/systbls_32.S
1156 --- linux-2.6.32.56/arch/sparc/kernel/systbls_32.S 2012-02-09 10:22:16.000000000 +0100
1157 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/kernel/systbls_32.S 2011-06-10 13:03:02.000000000 +0200
1158 @@ -70,7 +70,7 @@ sys_call_table:
1159 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1160 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1161 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1162 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1163 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1164 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1165 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1166 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1167 diff -NurpP --minimal linux-2.6.32.56/arch/sparc/kernel/systbls_64.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/kernel/systbls_64.S
1168 --- linux-2.6.32.56/arch/sparc/kernel/systbls_64.S 2012-02-09 10:22:16.000000000 +0100
1169 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/sparc/kernel/systbls_64.S 2011-06-10 13:03:02.000000000 +0200
1170 @@ -71,7 +71,7 @@ sys_call_table32:
1171 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
1172 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
1173 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
1174 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
1175 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
1176 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
1177 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
1178 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
1179 @@ -146,7 +146,7 @@ sys_call_table:
1180 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1181 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1182 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1183 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
1184 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1185 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1186 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1187 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1188 diff -NurpP --minimal linux-2.6.32.56/arch/um/Kconfig.rest linux-2.6.32.56-vs2.3.0.36.29.9/arch/um/Kconfig.rest
1189 --- linux-2.6.32.56/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
1190 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/um/Kconfig.rest 2011-06-10 13:03:02.000000000 +0200
1191 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
1195 +source "kernel/vserver/Kconfig"
1197 source "security/Kconfig"
1199 source "crypto/Kconfig"
1200 diff -NurpP --minimal linux-2.6.32.56/arch/um/include/asm/tlb.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/um/include/asm/tlb.h
1201 --- linux-2.6.32.56/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
1202 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/um/include/asm/tlb.h 2011-06-10 13:03:02.000000000 +0200
1205 #include <linux/pagemap.h>
1206 #include <linux/swap.h>
1207 +#include <linux/vs_memory.h>
1208 #include <asm/percpu.h>
1209 #include <asm/pgalloc.h>
1210 #include <asm/tlbflush.h>
1211 diff -NurpP --minimal linux-2.6.32.56/arch/x86/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/Kconfig
1212 --- linux-2.6.32.56/arch/x86/Kconfig 2012-02-09 10:22:16.000000000 +0100
1213 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/Kconfig 2011-06-10 13:03:02.000000000 +0200
1214 @@ -2100,6 +2100,8 @@ source "fs/Kconfig"
1216 source "arch/x86/Kconfig.debug"
1218 +source "kernel/vserver/Kconfig"
1220 source "security/Kconfig"
1222 source "crypto/Kconfig"
1223 diff -NurpP --minimal linux-2.6.32.56/arch/x86/ia32/ia32entry.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/ia32/ia32entry.S
1224 --- linux-2.6.32.56/arch/x86/ia32/ia32entry.S 2012-02-09 10:22:16.000000000 +0100
1225 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/ia32/ia32entry.S 2011-06-10 13:03:02.000000000 +0200
1226 @@ -783,7 +783,7 @@ ia32_sys_call_table:
1227 .quad sys_tgkill /* 270 */
1228 .quad compat_sys_utimes
1229 .quad sys32_fadvise64_64
1230 - .quad quiet_ni_syscall /* sys_vserver */
1231 + .quad sys32_vserver
1233 .quad compat_sys_get_mempolicy /* 275 */
1234 .quad sys_set_mempolicy
1235 diff -NurpP --minimal linux-2.6.32.56/arch/x86/include/asm/unistd_64.h linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/include/asm/unistd_64.h
1236 --- linux-2.6.32.56/arch/x86/include/asm/unistd_64.h 2009-12-03 20:02:16.000000000 +0100
1237 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/include/asm/unistd_64.h 2011-06-10 13:03:02.000000000 +0200
1238 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
1239 #define __NR_utimes 235
1240 __SYSCALL(__NR_utimes, sys_utimes)
1241 #define __NR_vserver 236
1242 -__SYSCALL(__NR_vserver, sys_ni_syscall)
1243 +__SYSCALL(__NR_vserver, sys_vserver)
1244 #define __NR_mbind 237
1245 __SYSCALL(__NR_mbind, sys_mbind)
1246 #define __NR_set_mempolicy 238
1247 diff -NurpP --minimal linux-2.6.32.56/arch/x86/kernel/syscall_table_32.S linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/kernel/syscall_table_32.S
1248 --- linux-2.6.32.56/arch/x86/kernel/syscall_table_32.S 2012-02-09 10:22:18.000000000 +0100
1249 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/x86/kernel/syscall_table_32.S 2011-06-10 13:03:02.000000000 +0200
1250 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1251 .long sys_tgkill /* 270 */
1253 .long sys_fadvise64_64
1254 - .long sys_ni_syscall /* sys_vserver */
1257 .long sys_get_mempolicy
1258 .long sys_set_mempolicy
1259 diff -NurpP --minimal linux-2.6.32.56/arch/xtensa/mm/fault.c linux-2.6.32.56-vs2.3.0.36.29.9/arch/xtensa/mm/fault.c
1260 --- linux-2.6.32.56/arch/xtensa/mm/fault.c 2009-09-10 15:25:48.000000000 +0200
1261 +++ linux-2.6.32.56-vs2.3.0.36.29.9/arch/xtensa/mm/fault.c 2011-06-10 13:03:02.000000000 +0200
1262 @@ -151,7 +151,8 @@ out_of_memory:
1263 down_read(&mm->mmap_sem);
1266 - printk("VM: killing process %s\n", current->comm);
1267 + printk("VM: killing process %s(%d:#%u)\n",
1268 + current->comm, task_pid_nr(current), current->xid);
1269 if (user_mode(regs))
1270 do_group_exit(SIGKILL);
1271 bad_page_fault(regs, address, SIGKILL);
1272 diff -NurpP --minimal linux-2.6.32.56/drivers/block/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/Kconfig
1273 --- linux-2.6.32.56/drivers/block/Kconfig 2009-09-10 15:25:49.000000000 +0200
1274 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/Kconfig 2011-06-10 13:03:02.000000000 +0200
1275 @@ -271,6 +271,13 @@ config BLK_DEV_CRYPTOLOOP
1276 instead, which can be configured to be on-disk compatible with the
1279 +config BLK_DEV_VROOT
1280 + tristate "Virtual Root device support"
1281 + depends on QUOTACTL
1283 + Saying Y here will allow you to use quota/fs ioctls on a shared
1284 + partition within a virtual server without compromising security.
1287 tristate "Network block device support"
1289 diff -NurpP --minimal linux-2.6.32.56/drivers/block/Makefile linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/Makefile
1290 --- linux-2.6.32.56/drivers/block/Makefile 2009-09-10 15:25:49.000000000 +0200
1291 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/Makefile 2011-06-10 13:03:02.000000000 +0200
1292 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1293 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1294 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1295 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1296 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1298 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1300 diff -NurpP --minimal linux-2.6.32.56/drivers/block/loop.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/loop.c
1301 --- linux-2.6.32.56/drivers/block/loop.c 2012-02-09 10:22:19.000000000 +0100
1302 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/loop.c 2011-08-08 22:40:36.000000000 +0200
1304 #include <linux/gfp.h>
1305 #include <linux/kthread.h>
1306 #include <linux/splice.h>
1307 +#include <linux/vs_context.h>
1309 #include <asm/uaccess.h>
1311 @@ -814,6 +815,7 @@ static int loop_set_fd(struct loop_devic
1312 lo->lo_blocksize = lo_blocksize;
1313 lo->lo_device = bdev;
1314 lo->lo_flags = lo_flags;
1315 + lo->lo_xid = vx_current_xid();
1316 lo->lo_backing_file = file;
1317 lo->transfer = transfer_none;
1319 @@ -939,6 +941,7 @@ static int loop_clr_fd(struct loop_devic
1320 lo->lo_encrypt_key_size = 0;
1322 lo->lo_thread = NULL;
1324 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1325 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1326 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1327 @@ -973,7 +976,7 @@ loop_set_status(struct loop_device *lo,
1329 if (lo->lo_encrypt_key_size &&
1330 lo->lo_key_owner != uid &&
1331 - !capable(CAP_SYS_ADMIN))
1332 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1334 if (lo->lo_state != Lo_bound)
1336 @@ -1057,7 +1060,8 @@ loop_get_status(struct loop_device *lo,
1337 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1338 info->lo_encrypt_type =
1339 lo->lo_encryption ? lo->lo_encryption->number : 0;
1340 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1341 + if (lo->lo_encrypt_key_size &&
1342 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1343 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1344 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1345 lo->lo_encrypt_key_size);
1346 @@ -1401,6 +1405,9 @@ static int lo_open(struct block_device *
1348 struct loop_device *lo = bdev->bd_disk->private_data;
1350 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1353 mutex_lock(&lo->lo_ctl_mutex);
1355 mutex_unlock(&lo->lo_ctl_mutex);
1356 diff -NurpP --minimal linux-2.6.32.56/drivers/block/vroot.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/vroot.c
1357 --- linux-2.6.32.56/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1358 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/block/vroot.c 2011-06-10 13:03:02.000000000 +0200
1361 + * linux/drivers/block/vroot.c
1363 + * written by Herbert Pötzl, 9/11/2002
1364 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1366 + * based on the loop.c code by Theodore Ts'o.
1368 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1369 + * Redistribution of this file is permitted under the
1370 + * GNU General Public License.
1374 +#include <linux/module.h>
1375 +#include <linux/moduleparam.h>
1376 +#include <linux/file.h>
1377 +#include <linux/major.h>
1378 +#include <linux/blkdev.h>
1380 +#include <linux/vroot.h>
1381 +#include <linux/vs_context.h>
1384 +static int max_vroot = 8;
1386 +static struct vroot_device *vroot_dev;
1387 +static struct gendisk **disks;
1390 +static int vroot_set_dev(
1391 + struct vroot_device *vr,
1392 + struct block_device *bdev,
1395 + struct block_device *real_bdev;
1396 + struct file *file;
1397 + struct inode *inode;
1401 + if (vr->vr_state != Vr_unbound)
1410 + inode = file->f_dentry->d_inode;
1413 + if (S_ISBLK(inode->i_mode)) {
1414 + real_bdev = inode->i_bdev;
1415 + vr->vr_device = real_bdev;
1416 + __iget(real_bdev->bd_inode);
1420 + vxdprintk(VXD_CBIT(misc, 0),
1421 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1422 + vr->vr_number, VXD_DEV(real_bdev));
1424 + vr->vr_state = Vr_bound;
1433 +static int vroot_clr_dev(
1434 + struct vroot_device *vr,
1435 + struct block_device *bdev)
1437 + struct block_device *real_bdev;
1439 + if (vr->vr_state != Vr_bound)
1441 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1444 + real_bdev = vr->vr_device;
1446 + vxdprintk(VXD_CBIT(misc, 0),
1447 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1448 + vr->vr_number, VXD_DEV(real_bdev));
1451 + vr->vr_state = Vr_unbound;
1452 + vr->vr_device = NULL;
1457 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1458 + unsigned int cmd, unsigned long arg)
1460 + struct vroot_device *vr = bdev->bd_disk->private_data;
1463 + down(&vr->vr_ctl_mutex);
1465 + case VROOT_SET_DEV:
1466 + err = vroot_set_dev(vr, bdev, arg);
1468 + case VROOT_CLR_DEV:
1469 + err = vroot_clr_dev(vr, bdev);
1475 + up(&vr->vr_ctl_mutex);
1479 +static int vr_open(struct block_device *bdev, fmode_t mode)
1481 + struct vroot_device *vr = bdev->bd_disk->private_data;
1483 + down(&vr->vr_ctl_mutex);
1485 + up(&vr->vr_ctl_mutex);
1489 +static int vr_release(struct gendisk *disk, fmode_t mode)
1491 + struct vroot_device *vr = disk->private_data;
1493 + down(&vr->vr_ctl_mutex);
1495 + up(&vr->vr_ctl_mutex);
1499 +static struct block_device_operations vr_fops = {
1500 + .owner = THIS_MODULE,
1502 + .release = vr_release,
1503 + .ioctl = vr_ioctl,
1506 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1508 + struct inode *inode = bdev->bd_inode;
1509 + struct vroot_device *vr;
1510 + struct block_device *real_bdev;
1511 + int minor = iminor(inode);
1513 + vr = &vroot_dev[minor];
1514 + real_bdev = vr->vr_device;
1516 + vxdprintk(VXD_CBIT(misc, 0),
1517 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1518 + vr->vr_number, VXD_DEV(real_bdev));
1520 + if (vr->vr_state != Vr_bound)
1521 + return ERR_PTR(-ENXIO);
1523 + __iget(real_bdev->bd_inode);
1528 + * And now the modules code and kernel interface.
1531 +module_param(max_vroot, int, 0);
1533 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1534 +MODULE_LICENSE("GPL");
1535 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1537 +MODULE_AUTHOR ("Herbert Pötzl");
1538 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1541 +int __init vroot_init(void)
1545 + if (max_vroot < 1 || max_vroot > 256) {
1546 + max_vroot = MAX_VROOT_DEFAULT;
1547 + printk(KERN_WARNING "vroot: invalid max_vroot "
1548 + "(must be between 1 and 256), "
1549 + "using default (%d)\n", max_vroot);
1552 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1556 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1559 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1561 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1565 + for (i = 0; i < max_vroot; i++) {
1566 + disks[i] = alloc_disk(1);
1569 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1570 + if (!disks[i]->queue)
1574 + for (i = 0; i < max_vroot; i++) {
1575 + struct vroot_device *vr = &vroot_dev[i];
1576 + struct gendisk *disk = disks[i];
1578 + memset(vr, 0, sizeof(*vr));
1579 + init_MUTEX(&vr->vr_ctl_mutex);
1580 + vr->vr_number = i;
1581 + disk->major = VROOT_MAJOR;
1582 + disk->first_minor = i;
1583 + disk->fops = &vr_fops;
1584 + sprintf(disk->disk_name, "vroot%d", i);
1585 + disk->private_data = vr;
1588 + err = register_vroot_grb(&__vroot_get_real_bdev);
1592 + for (i = 0; i < max_vroot; i++)
1593 + add_disk(disks[i]);
1594 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1599 + put_disk(disks[i]);
1604 + unregister_blkdev(VROOT_MAJOR, "vroot");
1605 + printk(KERN_ERR "vroot: ran out of memory\n");
1609 +void vroot_exit(void)
1613 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1614 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1616 + for (i = 0; i < max_vroot; i++) {
1617 + del_gendisk(disks[i]);
1618 + put_disk(disks[i]);
1620 + unregister_blkdev(VROOT_MAJOR, "vroot");
1626 +module_init(vroot_init);
1627 +module_exit(vroot_exit);
1631 +static int __init max_vroot_setup(char *str)
1633 + max_vroot = simple_strtol(str, NULL, 0);
1637 +__setup("max_vroot=", max_vroot_setup);
1641 diff -NurpP --minimal linux-2.6.32.56/drivers/char/sysrq.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/char/sysrq.c
1642 --- linux-2.6.32.56/drivers/char/sysrq.c 2009-12-03 20:02:20.000000000 +0100
1643 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/char/sysrq.c 2011-06-10 13:03:02.000000000 +0200
1645 #include <linux/workqueue.h>
1646 #include <linux/hrtimer.h>
1647 #include <linux/oom.h>
1648 +#include <linux/vserver/debug.h>
1650 #include <asm/ptrace.h>
1651 #include <asm/irq_regs.h>
1652 @@ -391,6 +392,21 @@ static struct sysrq_key_op sysrq_unrt_op
1653 .enable_mask = SYSRQ_ENABLE_RTNICE,
1657 +#ifdef CONFIG_VSERVER_DEBUG
1658 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1660 + dump_vx_info_inactive((key == 'x')?0:1);
1663 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1664 + .handler = sysrq_handle_vxinfo,
1665 + .help_msg = "conteXt",
1666 + .action_msg = "Show Context Info",
1667 + .enable_mask = SYSRQ_ENABLE_DUMP,
1671 /* Key Operations table and lock */
1672 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1674 @@ -445,7 +461,11 @@ static struct sysrq_key_op *sysrq_key_ta
1676 &sysrq_showstate_blocked_op, /* w */
1677 /* x: May be registered on ppc/powerpc for xmon */
1678 +#ifdef CONFIG_VSERVER_DEBUG
1679 + &sysrq_showvxinfo_op, /* x */
1683 /* y: May be registered on sparc64 for global register dump */
1685 &sysrq_ftrace_dump_op, /* z */
1686 @@ -460,6 +480,8 @@ static int sysrq_key_table_key2index(int
1688 else if ((key >= 'a') && (key <= 'z'))
1689 retval = key + 10 - 'a';
1690 + else if ((key >= 'A') && (key <= 'Z'))
1691 + retval = key + 10 - 'A';
1695 diff -NurpP --minimal linux-2.6.32.56/drivers/char/tty_io.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/char/tty_io.c
1696 --- linux-2.6.32.56/drivers/char/tty_io.c 2012-02-09 10:22:19.000000000 +0100
1697 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/char/tty_io.c 2012-01-10 09:18:12.000000000 +0100
1700 #include <linux/kmod.h>
1701 #include <linux/nsproxy.h>
1702 +#include <linux/vs_pid.h>
1704 #undef TTY_DEBUG_HANGUP
1706 @@ -1971,7 +1972,8 @@ static int tiocsti(struct tty_struct *tt
1708 struct tty_ldisc *ld;
1710 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1711 + if (((current->signal->tty != tty) &&
1712 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1714 if (get_user(ch, p))
1716 @@ -2259,6 +2261,7 @@ static int tiocspgrp(struct tty_struct *
1718 if (get_user(pgrp_nr, p))
1720 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1724 diff -NurpP --minimal linux-2.6.32.56/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/infiniband/hw/ipath/ipath_user_pages.c
1725 --- linux-2.6.32.56/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-03 20:02:23.000000000 +0100
1726 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-06-10 13:03:02.000000000 +0200
1728 #include <linux/mm.h>
1729 #include <linux/device.h>
1730 #include <linux/sched.h>
1731 +#include <linux/vs_memory.h>
1733 #include "ipath_kernel.h"
1735 @@ -62,7 +63,8 @@ static int __get_user_pages(unsigned lon
1736 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1739 - if (num_pages > lock_limit) {
1740 + if (num_pages > lock_limit ||
1741 + !vx_vmlocked_avail(current->mm, num_pages)) {
1745 @@ -79,7 +81,7 @@ static int __get_user_pages(unsigned lon
1749 - current->mm->locked_vm += num_pages;
1750 + vx_vmlocked_add(current->mm, num_pages);
1754 @@ -178,7 +180,7 @@ void ipath_release_user_pages(struct pag
1756 __ipath_release_user_pages(p, num_pages, 1);
1758 - current->mm->locked_vm -= num_pages;
1759 + vx_vmlocked_sub(current->mm, num_pages);
1761 up_write(¤t->mm->mmap_sem);
1763 @@ -195,7 +197,7 @@ static void user_pages_account(struct wo
1764 container_of(_work, struct ipath_user_pages_work, work);
1766 down_write(&work->mm->mmap_sem);
1767 - work->mm->locked_vm -= work->num_pages;
1768 + vx_vmlocked_sub(work->mm, work->num_pages);
1769 up_write(&work->mm->mmap_sem);
1772 diff -NurpP --minimal linux-2.6.32.56/drivers/md/dm-ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/md/dm-ioctl.c
1773 --- linux-2.6.32.56/drivers/md/dm-ioctl.c 2012-02-09 10:22:20.000000000 +0100
1774 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/md/dm-ioctl.c 2011-06-10 13:03:02.000000000 +0200
1776 #include <linux/dm-ioctl.h>
1777 #include <linux/hdreg.h>
1778 #include <linux/compat.h>
1779 +#include <linux/vs_context.h>
1781 #include <asm/uaccess.h>
1783 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1784 unsigned int h = hash_str(str);
1786 list_for_each_entry (hc, _name_buckets + h, name_list)
1787 - if (!strcmp(hc->name, str)) {
1788 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1789 + !strcmp(hc->name, str)) {
1793 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1794 unsigned int h = hash_str(str);
1796 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1797 - if (!strcmp(hc->uuid, str)) {
1798 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1799 + !strcmp(hc->uuid, str)) {
1803 @@ -369,6 +372,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1805 static int remove_all(struct dm_ioctl *param, size_t param_size)
1807 + if (!vx_check(0, VS_ADMIN))
1810 dm_hash_remove_all(1);
1811 param->data_size = 0;
1813 @@ -416,6 +422,8 @@ static int list_devices(struct dm_ioctl
1815 for (i = 0; i < NUM_BUCKETS; i++) {
1816 list_for_each_entry (hc, _name_buckets + i, name_list) {
1817 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1819 needed += sizeof(struct dm_name_list);
1820 needed += strlen(hc->name) + 1;
1821 needed += ALIGN_MASK;
1822 @@ -439,6 +447,8 @@ static int list_devices(struct dm_ioctl
1824 for (i = 0; i < NUM_BUCKETS; i++) {
1825 list_for_each_entry (hc, _name_buckets + i, name_list) {
1826 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1829 old_nl->next = (uint32_t) ((void *) nl -
1831 @@ -629,10 +639,11 @@ static struct hash_cell *__find_device_h
1835 - mdptr = dm_get_mdptr(md);
1836 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1837 + mdptr = dm_get_mdptr(md);
1845 @@ -1462,8 +1473,8 @@ static int ctl_ioctl(uint command, struc
1849 - /* only root can play with this */
1850 - if (!capable(CAP_SYS_ADMIN))
1851 + /* only root and certain contexts can play with this */
1852 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1855 if (_IOC_TYPE(command) != DM_IOCTL)
1856 diff -NurpP --minimal linux-2.6.32.56/drivers/md/dm.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/md/dm.c
1857 --- linux-2.6.32.56/drivers/md/dm.c 2012-02-09 10:22:20.000000000 +0100
1858 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/md/dm.c 2011-11-17 12:18:26.000000000 +0100
1860 #include <linux/slab.h>
1861 #include <linux/idr.h>
1862 #include <linux/hdreg.h>
1863 +#include <linux/vs_base.h>
1865 #include <trace/events/block.h>
1867 @@ -121,6 +122,7 @@ struct mapped_device {
1870 atomic_t open_count;
1873 unsigned long flags;
1875 @@ -331,6 +333,7 @@ static void __exit dm_exit(void)
1876 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1878 struct mapped_device *md;
1881 spin_lock(&_minor_lock);
1883 @@ -339,18 +342,19 @@ static int dm_blk_open(struct block_devi
1886 if (test_bit(DMF_FREEING, &md->flags) ||
1887 - test_bit(DMF_DELETING, &md->flags)) {
1889 + test_bit(DMF_DELETING, &md->flags))
1893 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1898 atomic_inc(&md->open_count);
1902 spin_unlock(&_minor_lock);
1904 - return md ? 0 : -ENXIO;
1908 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1909 @@ -561,6 +565,14 @@ int dm_set_geometry(struct mapped_device
1914 + * Get the xid associated with a dm device
1916 +xid_t dm_get_xid(struct mapped_device *md)
1921 /*-----------------------------------------------------------------
1923 * A more elegant soln is in the works that uses the queue
1924 @@ -1781,6 +1793,7 @@ static struct mapped_device *alloc_dev(i
1925 INIT_LIST_HEAD(&md->uevent_list);
1926 spin_lock_init(&md->uevent_lock);
1928 + md->xid = vx_current_xid();
1929 md->queue = blk_init_queue(dm_request_fn, NULL);
1932 diff -NurpP --minimal linux-2.6.32.56/drivers/md/dm.h linux-2.6.32.56-vs2.3.0.36.29.9/drivers/md/dm.h
1933 --- linux-2.6.32.56/drivers/md/dm.h 2009-09-10 15:25:55.000000000 +0200
1934 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/md/dm.h 2011-06-10 13:03:02.000000000 +0200
1935 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1937 struct dm_md_mempools;
1939 +xid_t dm_get_xid(struct mapped_device *md);
1941 /*-----------------------------------------------------------------
1942 * Internal table functions.
1943 *---------------------------------------------------------------*/
1944 diff -NurpP --minimal linux-2.6.32.56/drivers/net/tun.c linux-2.6.32.56-vs2.3.0.36.29.9/drivers/net/tun.c
1945 --- linux-2.6.32.56/drivers/net/tun.c 2012-02-09 10:22:25.000000000 +0100
1946 +++ linux-2.6.32.56-vs2.3.0.36.29.9/drivers/net/tun.c 2011-06-10 13:03:02.000000000 +0200
1948 #include <linux/crc32.h>
1949 #include <linux/nsproxy.h>
1950 #include <linux/virtio_net.h>
1951 +#include <linux/vs_network.h>
1952 #include <net/net_namespace.h>
1953 #include <net/netns/generic.h>
1954 #include <net/rtnetlink.h>
1955 @@ -102,6 +103,7 @@ struct tun_struct {
1961 struct net_device *dev;
1962 struct fasync_struct *fasync;
1963 @@ -816,6 +818,7 @@ static void tun_setup(struct net_device
1967 + tun->nid = current->nid;
1969 dev->ethtool_ops = &tun_ethtool_ops;
1970 dev->destructor = tun_free_netdev;
1971 @@ -932,7 +935,7 @@ static int tun_set_iff(struct net *net,
1973 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1974 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1975 - !capable(CAP_NET_ADMIN))
1976 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1978 err = security_tun_dev_attach(tun->socket.sk);
1980 @@ -946,7 +949,7 @@ static int tun_set_iff(struct net *net,
1982 unsigned long flags = 0;
1984 - if (!capable(CAP_NET_ADMIN))
1985 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1987 err = security_tun_dev_create();
1989 @@ -1014,6 +1017,9 @@ static int tun_set_iff(struct net *net,
1991 sk->sk_destruct = tun_sock_destruct;
1993 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1996 err = tun_attach(tun, file);
1999 @@ -1203,6 +1209,16 @@ static long tun_chr_ioctl(struct file *f
2000 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2004 + if (!capable(CAP_CONTEXT))
2007 + /* Set nid owner of the device */
2008 + tun->nid = (nid_t) arg;
2010 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2014 /* Only allow setting the type when the interface is down */
2015 if (tun->dev->flags & IFF_UP) {
2016 diff -NurpP --minimal linux-2.6.32.56/fs/attr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/attr.c
2017 --- linux-2.6.32.56/fs/attr.c 2009-12-03 20:02:51.000000000 +0100
2018 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/attr.c 2011-06-10 13:03:02.000000000 +0200
2020 #include <linux/fcntl.h>
2021 #include <linux/quotaops.h>
2022 #include <linux/security.h>
2023 +#include <linux/proc_fs.h>
2024 +#include <linux/devpts_fs.h>
2025 +#include <linux/vs_tag.h>
2027 /* Taken over from the old code... */
2029 @@ -55,6 +58,10 @@ int inode_change_ok(const struct inode *
2030 if (!is_owner_or_cap(inode))
2034 + if (dx_permission(inode, MAY_WRITE))
2040 @@ -120,6 +127,8 @@ int inode_setattr(struct inode * inode,
2041 inode->i_uid = attr->ia_uid;
2042 if (ia_valid & ATTR_GID)
2043 inode->i_gid = attr->ia_gid;
2044 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2045 + inode->i_tag = attr->ia_tag;
2046 if (ia_valid & ATTR_ATIME)
2047 inode->i_atime = timespec_trunc(attr->ia_atime,
2048 inode->i_sb->s_time_gran);
2049 @@ -214,7 +223,8 @@ int notify_change(struct dentry * dentry
2050 error = inode_change_ok(inode, attr);
2052 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2053 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2054 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2055 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2056 error = vfs_dq_transfer(inode, attr) ?
2059 diff -NurpP --minimal linux-2.6.32.56/fs/binfmt_aout.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_aout.c
2060 --- linux-2.6.32.56/fs/binfmt_aout.c 2012-02-09 10:22:29.000000000 +0100
2061 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_aout.c 2011-06-10 13:03:02.000000000 +0200
2063 #include <linux/binfmts.h>
2064 #include <linux/personality.h>
2065 #include <linux/init.h>
2066 +#include <linux/vs_memory.h>
2068 #include <asm/system.h>
2069 #include <asm/uaccess.h>
2070 diff -NurpP --minimal linux-2.6.32.56/fs/binfmt_elf.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_elf.c
2071 --- linux-2.6.32.56/fs/binfmt_elf.c 2012-02-09 10:22:29.000000000 +0100
2072 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_elf.c 2011-06-10 13:03:02.000000000 +0200
2074 #include <linux/random.h>
2075 #include <linux/elf.h>
2076 #include <linux/utsname.h>
2077 +#include <linux/vs_memory.h>
2078 #include <asm/uaccess.h>
2079 #include <asm/param.h>
2080 #include <asm/page.h>
2081 diff -NurpP --minimal linux-2.6.32.56/fs/binfmt_flat.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_flat.c
2082 --- linux-2.6.32.56/fs/binfmt_flat.c 2012-02-09 10:22:29.000000000 +0100
2083 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_flat.c 2011-06-10 13:03:02.000000000 +0200
2085 #include <linux/init.h>
2086 #include <linux/flat.h>
2087 #include <linux/syscalls.h>
2088 +#include <linux/vs_memory.h>
2090 #include <asm/byteorder.h>
2091 #include <asm/system.h>
2092 diff -NurpP --minimal linux-2.6.32.56/fs/binfmt_som.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_som.c
2093 --- linux-2.6.32.56/fs/binfmt_som.c 2012-02-09 10:22:29.000000000 +0100
2094 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/binfmt_som.c 2011-06-10 13:03:02.000000000 +0200
2096 #include <linux/shm.h>
2097 #include <linux/personality.h>
2098 #include <linux/init.h>
2099 +#include <linux/vs_memory.h>
2101 #include <asm/uaccess.h>
2102 #include <asm/pgtable.h>
2103 diff -NurpP --minimal linux-2.6.32.56/fs/block_dev.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/block_dev.c
2104 --- linux-2.6.32.56/fs/block_dev.c 2012-02-09 10:22:29.000000000 +0100
2105 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/block_dev.c 2011-11-17 12:18:26.000000000 +0100
2107 #include <linux/namei.h>
2108 #include <linux/log2.h>
2109 #include <linux/kmemleak.h>
2110 +#include <linux/vs_device.h>
2111 #include <asm/uaccess.h>
2112 #include "internal.h"
2114 @@ -557,6 +558,7 @@ struct block_device *bdget(dev_t dev)
2115 bdev->bd_invalidated = 0;
2116 inode->i_mode = S_IFBLK;
2117 inode->i_rdev = dev;
2118 + inode->i_mdev = dev;
2119 inode->i_bdev = bdev;
2120 inode->i_data.a_ops = &def_blk_aops;
2121 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2122 @@ -603,6 +605,11 @@ EXPORT_SYMBOL(bdput);
2123 static struct block_device *bd_acquire(struct inode *inode)
2125 struct block_device *bdev;
2128 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2130 + inode->i_mdev = mdev;
2132 spin_lock(&bdev_lock);
2133 bdev = inode->i_bdev;
2134 @@ -613,7 +620,7 @@ static struct block_device *bd_acquire(s
2136 spin_unlock(&bdev_lock);
2138 - bdev = bdget(inode->i_rdev);
2139 + bdev = bdget(mdev);
2141 spin_lock(&bdev_lock);
2142 if (!inode->i_bdev) {
2143 diff -NurpP --minimal linux-2.6.32.56/fs/btrfs/ctree.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/ctree.h
2144 --- linux-2.6.32.56/fs/btrfs/ctree.h 2012-02-09 10:22:29.000000000 +0100
2145 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/ctree.h 2011-06-10 13:03:02.000000000 +0200
2146 @@ -547,11 +547,14 @@ struct btrfs_inode_item {
2147 /* modification sequence number for NFS */
2152 * a little future expansion, for more than this we can
2153 * just grow the inode item and version it
2155 - __le64 reserved[4];
2156 + __le16 reserved16;
2157 + __le32 reserved32;
2158 + __le64 reserved[3];
2159 struct btrfs_timespec atime;
2160 struct btrfs_timespec ctime;
2161 struct btrfs_timespec mtime;
2162 @@ -1162,6 +1165,8 @@ struct btrfs_root {
2163 #define BTRFS_MOUNT_NOSSD (1 << 9)
2164 #define BTRFS_MOUNT_DISCARD (1 << 10)
2166 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2168 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2169 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2170 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2171 @@ -1181,6 +1186,10 @@ struct btrfs_root {
2172 #define BTRFS_INODE_NOATIME (1 << 9)
2173 #define BTRFS_INODE_DIRSYNC (1 << 10)
2175 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2176 +#define BTRFS_INODE_BARRIER (1 << 25)
2177 +#define BTRFS_INODE_COW (1 << 26)
2180 #define BTRFS_INODE_ROOT_ITEM_INIT (1 << 31)
2182 @@ -1385,6 +1394,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2183 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2184 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2185 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2186 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2187 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2188 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2189 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2190 @@ -2360,6 +2370,7 @@ extern const struct dentry_operations bt
2191 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2192 void btrfs_update_iflags(struct inode *inode);
2193 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2194 +int btrfs_sync_flags(struct inode *inode, int, int);
2197 int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
2198 diff -NurpP --minimal linux-2.6.32.56/fs/btrfs/disk-io.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/disk-io.c
2199 --- linux-2.6.32.56/fs/btrfs/disk-io.c 2012-02-09 10:22:29.000000000 +0100
2200 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/disk-io.c 2011-06-10 13:03:02.000000000 +0200
2201 @@ -1728,6 +1728,9 @@ struct btrfs_root *open_ctree(struct sup
2205 + if (btrfs_test_opt(tree_root, TAGGED))
2206 + sb->s_flags |= MS_TAGGED;
2208 features = btrfs_super_incompat_flags(disk_super) &
2209 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2211 diff -NurpP --minimal linux-2.6.32.56/fs/btrfs/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/inode.c
2212 --- linux-2.6.32.56/fs/btrfs/inode.c 2012-02-09 10:22:29.000000000 +0100
2213 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/inode.c 2011-06-10 13:03:02.000000000 +0200
2215 #include <linux/xattr.h>
2216 #include <linux/posix_acl.h>
2217 #include <linux/falloc.h>
2218 +#include <linux/vs_tag.h>
2222 #include "disk-io.h"
2223 @@ -2263,6 +2265,8 @@ static void btrfs_read_locked_inode(stru
2225 u64 alloc_group_block;
2231 path = btrfs_alloc_path();
2232 @@ -2279,8 +2283,13 @@ static void btrfs_read_locked_inode(stru
2234 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2235 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2236 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2237 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2239 + uid = btrfs_inode_uid(leaf, inode_item);
2240 + gid = btrfs_inode_gid(leaf, inode_item);
2241 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2242 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2243 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2244 + btrfs_inode_tag(leaf, inode_item));
2245 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2247 tspec = btrfs_inode_atime(inode_item);
2248 @@ -2362,8 +2371,15 @@ static void fill_inode_item(struct btrfs
2249 struct btrfs_inode_item *item,
2250 struct inode *inode)
2252 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2253 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2254 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2255 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2257 + btrfs_set_inode_uid(leaf, item, uid);
2258 + btrfs_set_inode_gid(leaf, item, gid);
2259 +#ifdef CONFIG_TAGGING_INTERN
2260 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2263 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2264 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2265 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2266 @@ -4153,6 +4169,7 @@ static struct inode *btrfs_new_inode(str
2268 inode->i_gid = current_fsgid();
2270 + inode->i_tag = dx_current_fstag(root->fs_info->sb);
2271 inode->i_mode = mode;
2272 inode->i_ino = objectid;
2273 inode_set_bytes(inode, 0);
2274 @@ -5954,6 +5971,7 @@ static const struct inode_operations btr
2275 .listxattr = btrfs_listxattr,
2276 .removexattr = btrfs_removexattr,
2277 .permission = btrfs_permission,
2278 + .sync_flags = btrfs_sync_flags,
2280 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2281 .lookup = btrfs_lookup,
2282 @@ -6029,6 +6047,7 @@ static const struct inode_operations btr
2283 .permission = btrfs_permission,
2284 .fallocate = btrfs_fallocate,
2285 .fiemap = btrfs_fiemap,
2286 + .sync_flags = btrfs_sync_flags,
2288 static const struct inode_operations btrfs_special_inode_operations = {
2289 .getattr = btrfs_getattr,
2290 diff -NurpP --minimal linux-2.6.32.56/fs/btrfs/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/ioctl.c
2291 --- linux-2.6.32.56/fs/btrfs/ioctl.c 2012-02-09 10:22:29.000000000 +0100
2292 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/ioctl.c 2011-06-10 13:03:02.000000000 +0200
2293 @@ -67,10 +67,13 @@ static unsigned int btrfs_flags_to_ioctl
2295 unsigned int iflags = 0;
2297 - if (flags & BTRFS_INODE_SYNC)
2298 - iflags |= FS_SYNC_FL;
2299 if (flags & BTRFS_INODE_IMMUTABLE)
2300 iflags |= FS_IMMUTABLE_FL;
2301 + if (flags & BTRFS_INODE_IXUNLINK)
2302 + iflags |= FS_IXUNLINK_FL;
2304 + if (flags & BTRFS_INODE_SYNC)
2305 + iflags |= FS_SYNC_FL;
2306 if (flags & BTRFS_INODE_APPEND)
2307 iflags |= FS_APPEND_FL;
2308 if (flags & BTRFS_INODE_NODUMP)
2309 @@ -80,28 +83,78 @@ static unsigned int btrfs_flags_to_ioctl
2310 if (flags & BTRFS_INODE_DIRSYNC)
2311 iflags |= FS_DIRSYNC_FL;
2313 + if (flags & BTRFS_INODE_BARRIER)
2314 + iflags |= FS_BARRIER_FL;
2315 + if (flags & BTRFS_INODE_COW)
2316 + iflags |= FS_COW_FL;
2321 - * Update inode->i_flags based on the btrfs internal flags.
2322 + * Update inode->i_(v)flags based on the btrfs internal flags.
2324 void btrfs_update_iflags(struct inode *inode)
2326 struct btrfs_inode *ip = BTRFS_I(inode);
2328 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2329 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2330 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2332 - if (ip->flags & BTRFS_INODE_SYNC)
2333 - inode->i_flags |= S_SYNC;
2334 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2335 inode->i_flags |= S_IMMUTABLE;
2336 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2337 + inode->i_flags |= S_IXUNLINK;
2339 + if (ip->flags & BTRFS_INODE_SYNC)
2340 + inode->i_flags |= S_SYNC;
2341 if (ip->flags & BTRFS_INODE_APPEND)
2342 inode->i_flags |= S_APPEND;
2343 if (ip->flags & BTRFS_INODE_NOATIME)
2344 inode->i_flags |= S_NOATIME;
2345 if (ip->flags & BTRFS_INODE_DIRSYNC)
2346 inode->i_flags |= S_DIRSYNC;
2348 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2350 + if (ip->flags & BTRFS_INODE_BARRIER)
2351 + inode->i_vflags |= V_BARRIER;
2352 + if (ip->flags & BTRFS_INODE_COW)
2353 + inode->i_vflags |= V_COW;
2357 + * Update btrfs internal flags from inode->i_(v)flags.
2359 +void btrfs_update_flags(struct inode *inode)
2361 + struct btrfs_inode *ip = BTRFS_I(inode);
2363 + unsigned int flags = inode->i_flags;
2364 + unsigned int vflags = inode->i_vflags;
2366 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2367 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2368 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2369 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2371 + if (flags & S_IMMUTABLE)
2372 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2373 + if (flags & S_IXUNLINK)
2374 + ip->flags |= BTRFS_INODE_IXUNLINK;
2376 + if (flags & S_SYNC)
2377 + ip->flags |= BTRFS_INODE_SYNC;
2378 + if (flags & S_APPEND)
2379 + ip->flags |= BTRFS_INODE_APPEND;
2380 + if (flags & S_NOATIME)
2381 + ip->flags |= BTRFS_INODE_NOATIME;
2382 + if (flags & S_DIRSYNC)
2383 + ip->flags |= BTRFS_INODE_DIRSYNC;
2385 + if (vflags & V_BARRIER)
2386 + ip->flags |= BTRFS_INODE_BARRIER;
2387 + if (vflags & V_COW)
2388 + ip->flags |= BTRFS_INODE_COW;
2392 @@ -119,7 +172,7 @@ void btrfs_inherit_iflags(struct inode *
2393 flags = BTRFS_I(dir)->flags;
2395 if (S_ISREG(inode->i_mode))
2396 - flags &= ~BTRFS_INODE_DIRSYNC;
2397 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2398 else if (!S_ISDIR(inode->i_mode))
2399 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2401 @@ -127,6 +180,30 @@ void btrfs_inherit_iflags(struct inode *
2402 btrfs_update_iflags(inode);
2405 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2407 + struct btrfs_inode *ip = BTRFS_I(inode);
2408 + struct btrfs_root *root = ip->root;
2409 + struct btrfs_trans_handle *trans;
2412 + trans = btrfs_join_transaction(root, 1);
2415 + inode->i_flags = flags;
2416 + inode->i_vflags = vflags;
2417 + btrfs_update_flags(inode);
2419 + ret = btrfs_update_inode(trans, root, inode);
2422 + btrfs_update_iflags(inode);
2423 + inode->i_ctime = CURRENT_TIME;
2424 + btrfs_end_transaction(trans, root);
2429 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2431 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2432 @@ -149,6 +226,7 @@ static int btrfs_ioctl_setflags(struct f
2433 if (copy_from_user(&flags, arg, sizeof(flags)))
2436 + /* maybe add FS_IXUNLINK_FL ? */
2437 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2438 FS_NOATIME_FL | FS_NODUMP_FL | \
2439 FS_SYNC_FL | FS_DIRSYNC_FL))
2440 @@ -161,7 +239,8 @@ static int btrfs_ioctl_setflags(struct f
2442 flags = btrfs_mask_flags(inode->i_mode, flags);
2443 oldflags = btrfs_flags_to_ioctl(ip->flags);
2444 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2445 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2446 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2447 if (!capable(CAP_LINUX_IMMUTABLE)) {
2450 @@ -172,14 +251,19 @@ static int btrfs_ioctl_setflags(struct f
2454 - if (flags & FS_SYNC_FL)
2455 - ip->flags |= BTRFS_INODE_SYNC;
2457 - ip->flags &= ~BTRFS_INODE_SYNC;
2458 if (flags & FS_IMMUTABLE_FL)
2459 ip->flags |= BTRFS_INODE_IMMUTABLE;
2461 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2462 + if (flags & FS_IXUNLINK_FL)
2463 + ip->flags |= BTRFS_INODE_IXUNLINK;
2465 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2467 + if (flags & FS_SYNC_FL)
2468 + ip->flags |= BTRFS_INODE_SYNC;
2470 + ip->flags &= ~BTRFS_INODE_SYNC;
2471 if (flags & FS_APPEND_FL)
2472 ip->flags |= BTRFS_INODE_APPEND;
2474 diff -NurpP --minimal linux-2.6.32.56/fs/btrfs/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/super.c
2475 --- linux-2.6.32.56/fs/btrfs/super.c 2012-02-09 10:22:29.000000000 +0100
2476 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/btrfs/super.c 2011-06-10 13:03:02.000000000 +0200
2477 @@ -67,7 +67,7 @@ enum {
2478 Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier,
2479 Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
2480 Opt_compress, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
2481 - Opt_discard, Opt_err,
2482 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2485 static match_table_t tokens = {
2486 @@ -90,6 +90,9 @@ static match_table_t tokens = {
2487 {Opt_flushoncommit, "flushoncommit"},
2488 {Opt_ratio, "metadata_ratio=%d"},
2489 {Opt_discard, "discard"},
2491 + {Opt_notag, "notag"},
2492 + {Opt_tagid, "tagid=%u"},
2496 @@ -264,6 +267,22 @@ int btrfs_parse_options(struct btrfs_roo
2498 btrfs_set_opt(info->mount_opt, DISCARD);
2500 +#ifndef CONFIG_TAGGING_NONE
2502 + printk(KERN_INFO "btrfs: use tagging\n");
2503 + btrfs_set_opt(info->mount_opt, TAGGED);
2506 + printk(KERN_INFO "btrfs: disabled tagging\n");
2507 + btrfs_clear_opt(info->mount_opt, TAGGED);
2510 +#ifdef CONFIG_PROPAGATE
2513 + btrfs_set_opt(info->mount_opt, TAGGED);
2517 printk(KERN_INFO "btrfs: unrecognized mount option "
2519 @@ -585,6 +604,12 @@ static int btrfs_remount(struct super_bl
2523 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2524 + printk("btrfs: %s: tagging not permitted on remount.\n",
2529 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2532 diff -NurpP --minimal linux-2.6.32.56/fs/char_dev.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/char_dev.c
2533 --- linux-2.6.32.56/fs/char_dev.c 2012-02-09 10:22:29.000000000 +0100
2534 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/char_dev.c 2011-06-10 13:03:02.000000000 +0200
2536 #include <linux/cdev.h>
2537 #include <linux/mutex.h>
2538 #include <linux/backing-dev.h>
2539 +#include <linux/vs_context.h>
2540 +#include <linux/vs_device.h>
2542 #include "internal.h"
2544 @@ -370,14 +372,21 @@ static int chrdev_open(struct inode *ino
2546 struct cdev *new = NULL;
2550 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2552 + inode->i_mdev = mdev;
2554 spin_lock(&cdev_lock);
2557 struct kobject *kobj;
2560 spin_unlock(&cdev_lock);
2561 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2563 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2566 new = container_of(kobj, struct cdev, kobj);
2567 diff -NurpP --minimal linux-2.6.32.56/fs/dcache.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/dcache.c
2568 --- linux-2.6.32.56/fs/dcache.c 2012-02-09 10:22:30.000000000 +0100
2569 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/dcache.c 2011-06-10 13:03:02.000000000 +0200
2571 #include <linux/bootmem.h>
2572 #include <linux/fs_struct.h>
2573 #include <linux/hardirq.h>
2574 +#include <linux/vs_limit.h>
2575 #include "internal.h"
2577 int sysctl_vfs_cache_pressure __read_mostly = 100;
2578 @@ -230,6 +231,8 @@ repeat:
2582 + vx_dentry_dec(dentry);
2585 * AV: ->d_delete() is _NOT_ allowed to block now.
2587 @@ -321,6 +324,7 @@ static inline struct dentry * __dget_loc
2589 atomic_inc(&dentry->d_count);
2590 dentry_lru_del_init(dentry);
2591 + vx_dentry_inc(dentry);
2595 @@ -919,6 +923,9 @@ struct dentry *d_alloc(struct dentry * p
2596 struct dentry *dentry;
2599 + if (!vx_dentry_avail(1))
2602 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2605 @@ -964,6 +971,7 @@ struct dentry *d_alloc(struct dentry * p
2607 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2608 dentry_stat.nr_dentry++;
2609 + vx_dentry_inc(dentry);
2610 spin_unlock(&dcache_lock);
2613 @@ -1410,6 +1418,7 @@ struct dentry * __d_lookup(struct dentry
2616 atomic_inc(&dentry->d_count);
2617 + vx_dentry_inc(dentry);
2619 spin_unlock(&dentry->d_lock);
2621 diff -NurpP --minimal linux-2.6.32.56/fs/devpts/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/devpts/inode.c
2622 --- linux-2.6.32.56/fs/devpts/inode.c 2012-02-09 10:22:30.000000000 +0100
2623 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/devpts/inode.c 2011-06-10 13:03:02.000000000 +0200
2625 #include <linux/parser.h>
2626 #include <linux/fsnotify.h>
2627 #include <linux/seq_file.h>
2628 +#include <linux/vs_base.h>
2630 #define DEVPTS_DEFAULT_MODE 0600
2633 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2634 #define PTMX_MINOR 2
2636 +static int devpts_permission(struct inode *inode, int mask)
2638 + int ret = -EACCES;
2640 + /* devpts is xid tagged */
2641 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2642 + ret = generic_permission(inode, mask, NULL);
2646 +static struct inode_operations devpts_file_inode_operations = {
2647 + .permission = devpts_permission,
2650 extern int pty_limit; /* Config limit on Unix98 ptys */
2651 static DEFINE_MUTEX(allocated_ptys_lock);
2653 @@ -262,6 +277,25 @@ static int devpts_show_options(struct se
2657 +static int devpts_filter(struct dentry *de)
2659 + /* devpts is xid tagged */
2660 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2663 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2665 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2668 +static struct file_operations devpts_dir_operations = {
2669 + .open = dcache_dir_open,
2670 + .release = dcache_dir_close,
2671 + .llseek = dcache_dir_lseek,
2672 + .read = generic_read_dir,
2673 + .readdir = devpts_readdir,
2676 static const struct super_operations devpts_sops = {
2677 .statfs = simple_statfs,
2678 .remount_fs = devpts_remount,
2679 @@ -301,12 +335,15 @@ devpts_fill_super(struct super_block *s,
2680 inode = new_inode(s);
2685 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2686 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2687 inode->i_op = &simple_dir_inode_operations;
2688 - inode->i_fop = &simple_dir_operations;
2689 + inode->i_fop = &devpts_dir_operations;
2691 + /* devpts is xid tagged */
2692 + inode->i_tag = (tag_t)vx_current_xid();
2694 s->s_root = d_alloc_root(inode);
2696 @@ -497,6 +534,9 @@ int devpts_pty_new(struct inode *ptmx_in
2697 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2698 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2699 init_special_inode(inode, S_IFCHR|opts->mode, device);
2700 + /* devpts is xid tagged */
2701 + inode->i_tag = (tag_t)vx_current_xid();
2702 + inode->i_op = &devpts_file_inode_operations;
2703 inode->i_private = tty;
2704 tty->driver_data = inode;
2706 diff -NurpP --minimal linux-2.6.32.56/fs/exec.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/exec.c
2707 --- linux-2.6.32.56/fs/exec.c 2012-02-09 10:22:30.000000000 +0100
2708 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/exec.c 2011-08-08 22:40:36.000000000 +0200
2709 @@ -273,7 +273,9 @@ static int __bprm_mm_init(struct linux_b
2713 - mm->stack_vm = mm->total_vm = 1;
2715 + vx_vmpages_inc(mm);
2717 up_write(&mm->mmap_sem);
2718 bprm->p = vma->vm_end - sizeof(void *);
2720 @@ -1534,7 +1536,7 @@ static int format_corename(char *corenam
2721 /* UNIX time of coredump */
2724 - do_gettimeofday(&tv);
2725 + vx_gettimeofday(&tv);
2726 rc = snprintf(out_ptr, out_end - out_ptr,
2728 if (rc > out_end - out_ptr)
2729 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/balloc.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/balloc.c
2730 --- linux-2.6.32.56/fs/ext2/balloc.c 2009-06-11 17:13:03.000000000 +0200
2731 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/balloc.c 2011-06-10 13:03:02.000000000 +0200
2732 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2734 end = EXT2_BLOCKS_PER_GROUP(sb);
2737 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2740 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/ext2.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/ext2.h
2741 --- linux-2.6.32.56/fs/ext2/ext2.h 2009-09-10 15:26:21.000000000 +0200
2742 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/ext2.h 2011-06-10 13:03:02.000000000 +0200
2743 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
2744 int __ext2_write_begin(struct file *file, struct address_space *mapping,
2745 loff_t pos, unsigned len, unsigned flags,
2746 struct page **pagep, void **fsdata);
2747 +extern int ext2_sync_flags(struct inode *, int, int);
2750 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2751 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/file.c
2752 --- linux-2.6.32.56/fs/ext2/file.c 2009-12-03 20:02:51.000000000 +0100
2753 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/file.c 2011-06-10 13:03:02.000000000 +0200
2754 @@ -87,4 +87,5 @@ const struct inode_operations ext2_file_
2755 .setattr = ext2_setattr,
2756 .check_acl = ext2_check_acl,
2757 .fiemap = ext2_fiemap,
2758 + .sync_flags = ext2_sync_flags,
2760 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/ialloc.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/ialloc.c
2761 --- linux-2.6.32.56/fs/ext2/ialloc.c 2009-06-11 17:13:03.000000000 +0200
2762 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/ialloc.c 2011-06-10 13:03:02.000000000 +0200
2764 #include <linux/backing-dev.h>
2765 #include <linux/buffer_head.h>
2766 #include <linux/random.h>
2767 +#include <linux/vs_tag.h>
2771 @@ -560,6 +561,7 @@ got:
2773 inode->i_gid = current_fsgid();
2774 inode->i_mode = mode;
2775 + inode->i_tag = dx_current_fstag(sb);
2778 inode->i_blocks = 0;
2779 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/inode.c
2780 --- linux-2.6.32.56/fs/ext2/inode.c 2009-12-03 20:02:51.000000000 +0100
2781 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/inode.c 2011-06-10 18:47:35.000000000 +0200
2783 #include <linux/mpage.h>
2784 #include <linux/fiemap.h>
2785 #include <linux/namei.h>
2786 +#include <linux/vs_tag.h>
2790 @@ -1040,7 +1041,7 @@ void ext2_truncate(struct inode *inode)
2792 if (ext2_inode_is_fast_symlink(inode))
2794 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2795 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2798 blocksize = inode->i_sb->s_blocksize;
2799 @@ -1178,36 +1179,61 @@ void ext2_set_inode_flags(struct inode *
2801 unsigned int flags = EXT2_I(inode)->i_flags;
2803 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2804 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2805 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2808 + if (flags & EXT2_IMMUTABLE_FL)
2809 + inode->i_flags |= S_IMMUTABLE;
2810 + if (flags & EXT2_IXUNLINK_FL)
2811 + inode->i_flags |= S_IXUNLINK;
2813 if (flags & EXT2_SYNC_FL)
2814 inode->i_flags |= S_SYNC;
2815 if (flags & EXT2_APPEND_FL)
2816 inode->i_flags |= S_APPEND;
2817 - if (flags & EXT2_IMMUTABLE_FL)
2818 - inode->i_flags |= S_IMMUTABLE;
2819 if (flags & EXT2_NOATIME_FL)
2820 inode->i_flags |= S_NOATIME;
2821 if (flags & EXT2_DIRSYNC_FL)
2822 inode->i_flags |= S_DIRSYNC;
2824 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2826 + if (flags & EXT2_BARRIER_FL)
2827 + inode->i_vflags |= V_BARRIER;
2828 + if (flags & EXT2_COW_FL)
2829 + inode->i_vflags |= V_COW;
2832 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2833 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2835 unsigned int flags = ei->vfs_inode.i_flags;
2836 + unsigned int vflags = ei->vfs_inode.i_vflags;
2838 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2839 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2840 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2841 + EXT2_BARRIER_FL | EXT2_COW_FL);
2843 + if (flags & S_IMMUTABLE)
2844 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2845 + if (flags & S_IXUNLINK)
2846 + ei->i_flags |= EXT2_IXUNLINK_FL;
2848 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2849 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2851 ei->i_flags |= EXT2_SYNC_FL;
2852 if (flags & S_APPEND)
2853 ei->i_flags |= EXT2_APPEND_FL;
2854 - if (flags & S_IMMUTABLE)
2855 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2856 if (flags & S_NOATIME)
2857 ei->i_flags |= EXT2_NOATIME_FL;
2858 if (flags & S_DIRSYNC)
2859 ei->i_flags |= EXT2_DIRSYNC_FL;
2861 + if (vflags & V_BARRIER)
2862 + ei->i_flags |= EXT2_BARRIER_FL;
2863 + if (vflags & V_COW)
2864 + ei->i_flags |= EXT2_COW_FL;
2867 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2868 @@ -1217,6 +1243,8 @@ struct inode *ext2_iget (struct super_bl
2869 struct ext2_inode *raw_inode;
2870 struct inode *inode;
2876 inode = iget_locked(sb, ino);
2877 @@ -1235,12 +1263,17 @@ struct inode *ext2_iget (struct super_bl
2880 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2881 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2882 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2883 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2884 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2885 if (!(test_opt (inode->i_sb, NO_UID32))) {
2886 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2887 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2888 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2889 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2891 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2892 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2893 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2894 + le16_to_cpu(raw_inode->i_raw_tag));
2896 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2897 inode->i_size = le32_to_cpu(raw_inode->i_size);
2898 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2899 @@ -1338,8 +1371,8 @@ int ext2_write_inode(struct inode *inode
2900 struct ext2_inode_info *ei = EXT2_I(inode);
2901 struct super_block *sb = inode->i_sb;
2902 ino_t ino = inode->i_ino;
2903 - uid_t uid = inode->i_uid;
2904 - gid_t gid = inode->i_gid;
2905 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2906 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2907 struct buffer_head * bh;
2908 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2910 @@ -1375,6 +1408,9 @@ int ext2_write_inode(struct inode *inode
2911 raw_inode->i_uid_high = 0;
2912 raw_inode->i_gid_high = 0;
2914 +#ifdef CONFIG_TAGGING_INTERN
2915 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2917 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2918 raw_inode->i_size = cpu_to_le32(inode->i_size);
2919 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2920 @@ -1456,7 +1492,8 @@ int ext2_setattr(struct dentry *dentry,
2923 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2924 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2925 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2926 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2927 error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
2930 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/ioctl.c
2931 --- linux-2.6.32.56/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2932 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/ioctl.c 2011-06-10 18:47:17.000000000 +0200
2934 #include <asm/uaccess.h>
2937 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2939 + inode->i_flags = flags;
2940 + inode->i_vflags = vflags;
2941 + ext2_get_inode_flags(EXT2_I(inode));
2942 + inode->i_ctime = CURRENT_TIME_SEC;
2943 + mark_inode_dirty(inode);
2947 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2949 struct inode *inode = filp->f_dentry->d_inode;
2950 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2952 flags = ext2_mask_flags(inode->i_mode, flags);
2954 + if (IS_BARRIER(inode)) {
2955 + vxwprintk_task(1, "messing with the barrier.");
2959 mutex_lock(&inode->i_mutex);
2960 /* Is it quota file? Do not allow user to mess with it */
2961 if (IS_NOQUOTA(inode)) {
2962 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2964 * This test looks nicer. Thanks to Pauline Middelink
2966 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2967 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2968 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2969 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2970 if (!capable(CAP_LINUX_IMMUTABLE)) {
2971 mutex_unlock(&inode->i_mutex);
2973 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2977 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2978 + flags &= EXT2_FL_USER_MODIFIABLE;
2979 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2980 ei->i_flags = flags;
2981 mutex_unlock(&inode->i_mutex);
2982 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/namei.c
2983 --- linux-2.6.32.56/fs/ext2/namei.c 2012-02-09 10:22:30.000000000 +0100
2984 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/namei.c 2011-06-10 13:03:02.000000000 +0200
2988 #include <linux/pagemap.h>
2989 +#include <linux/vs_tag.h>
2993 @@ -74,6 +75,7 @@ static struct dentry *ext2_lookup(struct
2994 return ERR_PTR(-EIO);
2996 return ERR_CAST(inode);
2997 + dx_propagate_tag(nd, inode);
3001 @@ -396,6 +398,7 @@ const struct inode_operations ext2_dir_i
3003 .setattr = ext2_setattr,
3004 .check_acl = ext2_check_acl,
3005 + .sync_flags = ext2_sync_flags,
3008 const struct inode_operations ext2_special_inode_operations = {
3009 diff -NurpP --minimal linux-2.6.32.56/fs/ext2/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/super.c
3010 --- linux-2.6.32.56/fs/ext2/super.c 2009-09-10 15:26:21.000000000 +0200
3011 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext2/super.c 2011-06-10 13:03:02.000000000 +0200
3012 @@ -382,7 +382,8 @@ enum {
3013 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3014 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3015 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3016 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3017 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3018 + Opt_tag, Opt_notag, Opt_tagid
3021 static const match_table_t tokens = {
3022 @@ -410,6 +411,9 @@ static const match_table_t tokens = {
3024 {Opt_noacl, "noacl"},
3027 + {Opt_notag, "notag"},
3028 + {Opt_tagid, "tagid=%u"},
3029 {Opt_grpquota, "grpquota"},
3030 {Opt_ignore, "noquota"},
3031 {Opt_quota, "quota"},
3032 @@ -480,6 +484,20 @@ static int parse_options (char * options
3034 set_opt (sbi->s_mount_opt, NO_UID32);
3036 +#ifndef CONFIG_TAGGING_NONE
3038 + set_opt (sbi->s_mount_opt, TAGGED);
3041 + clear_opt (sbi->s_mount_opt, TAGGED);
3044 +#ifdef CONFIG_PROPAGATE
3047 + set_opt (sbi->s_mount_opt, TAGGED);
3051 clear_opt (sbi->s_mount_opt, CHECK);
3053 @@ -829,6 +847,8 @@ static int ext2_fill_super(struct super_
3054 if (!parse_options ((char *) data, sbi))
3057 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3058 + sb->s_flags |= MS_TAGGED;
3059 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3060 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3062 @@ -1175,6 +1195,14 @@ static int ext2_remount (struct super_bl
3066 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3067 + !(sb->s_flags & MS_TAGGED)) {
3068 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3071 + goto restore_opts;
3074 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3075 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3077 diff -NurpP --minimal linux-2.6.32.56/fs/ext3/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/file.c
3078 --- linux-2.6.32.56/fs/ext3/file.c 2009-12-03 20:02:51.000000000 +0100
3079 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/file.c 2011-06-10 13:03:02.000000000 +0200
3080 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
3082 .check_acl = ext3_check_acl,
3083 .fiemap = ext3_fiemap,
3084 + .sync_flags = ext3_sync_flags,
3087 diff -NurpP --minimal linux-2.6.32.56/fs/ext3/ialloc.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/ialloc.c
3088 --- linux-2.6.32.56/fs/ext3/ialloc.c 2009-09-10 15:26:21.000000000 +0200
3089 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/ialloc.c 2011-06-10 13:03:02.000000000 +0200
3091 #include <linux/buffer_head.h>
3092 #include <linux/random.h>
3093 #include <linux/bitops.h>
3094 +#include <linux/vs_tag.h>
3096 #include <asm/byteorder.h>
3098 @@ -548,6 +549,7 @@ got:
3100 inode->i_gid = current_fsgid();
3101 inode->i_mode = mode;
3102 + inode->i_tag = dx_current_fstag(sb);
3105 /* This is the optimal IO size (for stat), not the fs block size */
3106 diff -NurpP --minimal linux-2.6.32.56/fs/ext3/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/inode.c
3107 --- linux-2.6.32.56/fs/ext3/inode.c 2012-02-09 10:22:30.000000000 +0100
3108 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/inode.c 2011-06-10 13:03:02.000000000 +0200
3110 #include <linux/bio.h>
3111 #include <linux/fiemap.h>
3112 #include <linux/namei.h>
3113 +#include <linux/vs_tag.h>
3117 @@ -2343,7 +2344,7 @@ static void ext3_free_branches(handle_t
3119 int ext3_can_truncate(struct inode *inode)
3121 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3122 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3124 if (S_ISREG(inode->i_mode))
3126 @@ -2728,36 +2729,60 @@ void ext3_set_inode_flags(struct inode *
3128 unsigned int flags = EXT3_I(inode)->i_flags;
3130 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3131 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3132 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3134 + if (flags & EXT3_IMMUTABLE_FL)
3135 + inode->i_flags |= S_IMMUTABLE;
3136 + if (flags & EXT3_IXUNLINK_FL)
3137 + inode->i_flags |= S_IXUNLINK;
3139 if (flags & EXT3_SYNC_FL)
3140 inode->i_flags |= S_SYNC;
3141 if (flags & EXT3_APPEND_FL)
3142 inode->i_flags |= S_APPEND;
3143 - if (flags & EXT3_IMMUTABLE_FL)
3144 - inode->i_flags |= S_IMMUTABLE;
3145 if (flags & EXT3_NOATIME_FL)
3146 inode->i_flags |= S_NOATIME;
3147 if (flags & EXT3_DIRSYNC_FL)
3148 inode->i_flags |= S_DIRSYNC;
3150 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3152 + if (flags & EXT3_BARRIER_FL)
3153 + inode->i_vflags |= V_BARRIER;
3154 + if (flags & EXT3_COW_FL)
3155 + inode->i_vflags |= V_COW;
3158 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3159 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3161 unsigned int flags = ei->vfs_inode.i_flags;
3162 + unsigned int vflags = ei->vfs_inode.i_vflags;
3164 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3165 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3166 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3167 + EXT3_BARRIER_FL | EXT3_COW_FL);
3169 + if (flags & S_IMMUTABLE)
3170 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3171 + if (flags & S_IXUNLINK)
3172 + ei->i_flags |= EXT3_IXUNLINK_FL;
3174 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3175 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3177 ei->i_flags |= EXT3_SYNC_FL;
3178 if (flags & S_APPEND)
3179 ei->i_flags |= EXT3_APPEND_FL;
3180 - if (flags & S_IMMUTABLE)
3181 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3182 if (flags & S_NOATIME)
3183 ei->i_flags |= EXT3_NOATIME_FL;
3184 if (flags & S_DIRSYNC)
3185 ei->i_flags |= EXT3_DIRSYNC_FL;
3187 + if (vflags & V_BARRIER)
3188 + ei->i_flags |= EXT3_BARRIER_FL;
3189 + if (vflags & V_COW)
3190 + ei->i_flags |= EXT3_COW_FL;
3193 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3194 @@ -2771,6 +2796,8 @@ struct inode *ext3_iget(struct super_blo
3195 transaction_t *transaction;
3201 inode = iget_locked(sb, ino);
3203 @@ -2787,12 +2814,17 @@ struct inode *ext3_iget(struct super_blo
3205 raw_inode = ext3_raw_inode(&iloc);
3206 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3207 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3208 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3209 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3210 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3211 if(!(test_opt (inode->i_sb, NO_UID32))) {
3212 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3213 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3214 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3215 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3217 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3218 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3219 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3220 + le16_to_cpu(raw_inode->i_raw_tag));
3222 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3223 inode->i_size = le32_to_cpu(raw_inode->i_size);
3224 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3225 @@ -2947,6 +2979,8 @@ static int ext3_do_update_inode(handle_t
3226 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3227 struct ext3_inode_info *ei = EXT3_I(inode);
3228 struct buffer_head *bh = iloc->bh;
3229 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3230 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3231 int err = 0, rc, block;
3234 @@ -2961,29 +2995,32 @@ again:
3235 ext3_get_inode_flags(ei);
3236 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3237 if(!(test_opt(inode->i_sb, NO_UID32))) {
3238 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3239 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3240 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3241 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3243 * Fix up interoperability with old kernels. Otherwise, old inodes get
3244 * re-used with the upper 16 bits of the uid/gid intact
3247 raw_inode->i_uid_high =
3248 - cpu_to_le16(high_16_bits(inode->i_uid));
3249 + cpu_to_le16(high_16_bits(uid));
3250 raw_inode->i_gid_high =
3251 - cpu_to_le16(high_16_bits(inode->i_gid));
3252 + cpu_to_le16(high_16_bits(gid));
3254 raw_inode->i_uid_high = 0;
3255 raw_inode->i_gid_high = 0;
3258 raw_inode->i_uid_low =
3259 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3260 + cpu_to_le16(fs_high2lowuid(uid));
3261 raw_inode->i_gid_low =
3262 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3263 + cpu_to_le16(fs_high2lowgid(gid));
3264 raw_inode->i_uid_high = 0;
3265 raw_inode->i_gid_high = 0;
3267 +#ifdef CONFIG_TAGGING_INTERN
3268 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3270 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3271 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3272 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3273 @@ -3141,7 +3178,8 @@ int ext3_setattr(struct dentry *dentry,
3276 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3277 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3278 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3279 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3282 /* (user+group)*(old+new) structure, inode write (sb,
3283 @@ -3163,6 +3201,8 @@ int ext3_setattr(struct dentry *dentry,
3284 inode->i_uid = attr->ia_uid;
3285 if (attr->ia_valid & ATTR_GID)
3286 inode->i_gid = attr->ia_gid;
3287 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3288 + inode->i_tag = attr->ia_tag;
3289 error = ext3_mark_inode_dirty(handle, inode);
3290 ext3_journal_stop(handle);
3292 diff -NurpP --minimal linux-2.6.32.56/fs/ext3/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/ioctl.c
3293 --- linux-2.6.32.56/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3294 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/ioctl.c 2011-06-10 13:03:02.000000000 +0200
3298 #include <linux/fs.h>
3299 +#include <linux/mount.h>
3300 #include <linux/jbd.h>
3301 #include <linux/capability.h>
3302 #include <linux/ext3_fs.h>
3304 #include <linux/compat.h>
3305 #include <asm/uaccess.h>
3308 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3310 + handle_t *handle = NULL;
3311 + struct ext3_iloc iloc;
3314 + handle = ext3_journal_start(inode, 1);
3315 + if (IS_ERR(handle))
3316 + return PTR_ERR(handle);
3318 + if (IS_SYNC(inode))
3319 + handle->h_sync = 1;
3320 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3324 + inode->i_flags = flags;
3325 + inode->i_vflags = vflags;
3326 + ext3_get_inode_flags(EXT3_I(inode));
3327 + inode->i_ctime = CURRENT_TIME_SEC;
3329 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3331 + ext3_journal_stop(handle);
3335 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3337 struct inode *inode = filp->f_dentry->d_inode;
3338 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3340 flags = ext3_mask_flags(inode->i_mode, flags);
3342 + if (IS_BARRIER(inode)) {
3343 + vxwprintk_task(1, "messing with the barrier.");
3347 mutex_lock(&inode->i_mutex);
3349 /* Is it quota file? Do not allow user to mess with it */
3350 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3352 * This test looks nicer. Thanks to Pauline Middelink
3354 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3355 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3356 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3357 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3358 if (!capable(CAP_LINUX_IMMUTABLE))
3361 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3365 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3366 + flags &= EXT3_FL_USER_MODIFIABLE;
3367 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3368 ei->i_flags = flags;
3370 diff -NurpP --minimal linux-2.6.32.56/fs/ext3/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/namei.c
3371 --- linux-2.6.32.56/fs/ext3/namei.c 2012-02-09 10:22:30.000000000 +0100
3372 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/namei.c 2011-08-08 22:40:36.000000000 +0200
3374 #include <linux/quotaops.h>
3375 #include <linux/buffer_head.h>
3376 #include <linux/bio.h>
3377 +#include <linux/vs_tag.h>
3381 @@ -912,6 +913,7 @@ restart:
3383 ll_rw_block(READ_META, 1, &bh);
3385 + dx_propagate_tag(nd, inode);
3387 if ((bh = bh_use[ra_ptr++]) == NULL)
3389 @@ -2455,6 +2457,7 @@ const struct inode_operations ext3_dir_i
3390 .removexattr = generic_removexattr,
3392 .check_acl = ext3_check_acl,
3393 + .sync_flags = ext3_sync_flags,
3396 const struct inode_operations ext3_special_inode_operations = {
3397 diff -NurpP --minimal linux-2.6.32.56/fs/ext3/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/super.c
3398 --- linux-2.6.32.56/fs/ext3/super.c 2012-02-09 10:22:30.000000000 +0100
3399 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext3/super.c 2011-06-10 13:03:02.000000000 +0200
3400 @@ -789,7 +789,7 @@ enum {
3401 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3402 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
3403 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3405 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3408 static const match_table_t tokens = {
3409 @@ -842,6 +842,9 @@ static const match_table_t tokens = {
3410 {Opt_usrquota, "usrquota"},
3411 {Opt_barrier, "barrier=%u"},
3412 {Opt_resize, "resize"},
3414 + {Opt_notag, "notag"},
3415 + {Opt_tagid, "tagid=%u"},
3419 @@ -934,6 +937,20 @@ static int parse_options (char *options,
3421 set_opt (sbi->s_mount_opt, NO_UID32);
3423 +#ifndef CONFIG_TAGGING_NONE
3425 + set_opt (sbi->s_mount_opt, TAGGED);
3428 + clear_opt (sbi->s_mount_opt, TAGGED);
3431 +#ifdef CONFIG_PROPAGATE
3434 + set_opt (sbi->s_mount_opt, TAGGED);
3438 clear_opt (sbi->s_mount_opt, CHECK);
3440 @@ -1665,6 +1682,9 @@ static int ext3_fill_super (struct super
3444 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3445 + sb->s_flags |= MS_TAGGED;
3447 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3448 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3450 @@ -2534,6 +2554,14 @@ static int ext3_remount (struct super_bl
3451 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3452 ext3_abort(sb, __func__, "Abort forced by user");
3454 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3455 + !(sb->s_flags & MS_TAGGED)) {
3456 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3459 + goto restore_opts;
3462 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3463 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3465 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/ext4.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/ext4.h
3466 --- linux-2.6.32.56/fs/ext4/ext4.h 2012-02-09 10:22:30.000000000 +0100
3467 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/ext4.h 2011-11-17 12:18:26.000000000 +0100
3468 @@ -289,8 +289,12 @@ struct flex_groups {
3469 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3470 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3471 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3472 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3473 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3475 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3476 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3478 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3479 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3481 @@ -551,7 +555,8 @@ struct ext4_inode {
3482 __le16 l_i_file_acl_high;
3483 __le16 l_i_uid_high; /* these 2 fields */
3484 __le16 l_i_gid_high; /* were reserved2[0] */
3485 - __u32 l_i_reserved2;
3486 + __le16 l_i_tag; /* Context Tag */
3487 + __u16 l_i_reserved2;
3490 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3491 @@ -665,6 +670,7 @@ do { \
3492 #define i_gid_low i_gid
3493 #define i_uid_high osd2.linux2.l_i_uid_high
3494 #define i_gid_high osd2.linux2.l_i_gid_high
3495 +#define i_raw_tag osd2.linux2.l_i_tag
3496 #define i_reserved2 osd2.linux2.l_i_reserved2
3498 #elif defined(__GNU__)
3499 @@ -839,6 +845,7 @@ struct ext4_inode_info {
3500 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3501 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3502 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3503 +#define EXT4_MOUNT_TAGGED 0x400000 /* Enable Context Tags */
3504 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3505 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3506 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3507 @@ -1864,6 +1871,7 @@ extern int ext4_get_blocks(handle_t *han
3508 struct buffer_head *bh, int flags);
3509 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3510 __u64 start, __u64 len);
3511 +extern int ext4_sync_flags(struct inode *, int, int);
3513 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3514 __u64 start_orig, __u64 start_donor,
3515 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/file.c
3516 --- linux-2.6.32.56/fs/ext4/file.c 2012-02-09 10:22:30.000000000 +0100
3517 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/file.c 2011-06-10 13:03:02.000000000 +0200
3518 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
3519 .check_acl = ext4_check_acl,
3520 .fallocate = ext4_fallocate,
3521 .fiemap = ext4_fiemap,
3522 + .sync_flags = ext4_sync_flags,
3525 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/ialloc.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/ialloc.c
3526 --- linux-2.6.32.56/fs/ext4/ialloc.c 2012-02-09 10:22:30.000000000 +0100
3527 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/ialloc.c 2011-06-10 13:03:02.000000000 +0200
3529 #include <linux/random.h>
3530 #include <linux/bitops.h>
3531 #include <linux/blkdev.h>
3532 +#include <linux/vs_tag.h>
3533 #include <asm/byteorder.h>
3536 @@ -988,6 +989,7 @@ got:
3538 inode->i_gid = current_fsgid();
3539 inode->i_mode = mode;
3540 + inode->i_tag = dx_current_fstag(sb);
3542 inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
3543 /* This is the optimal IO size (for stat), not the fs block size */
3544 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/inode.c
3545 --- linux-2.6.32.56/fs/ext4/inode.c 2012-02-09 10:22:30.000000000 +0100
3546 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/inode.c 2012-01-10 09:18:12.000000000 +0100
3548 #include <linux/uio.h>
3549 #include <linux/bio.h>
3550 #include <linux/workqueue.h>
3551 +#include <linux/vs_tag.h>
3553 #include "ext4_jbd2.h"
3555 @@ -4446,7 +4447,7 @@ static void ext4_free_branches(handle_t
3557 int ext4_can_truncate(struct inode *inode)
3559 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3560 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3562 if (S_ISREG(inode->i_mode))
3564 @@ -4799,41 +4800,64 @@ void ext4_set_inode_flags(struct inode *
3566 unsigned int flags = EXT4_I(inode)->i_flags;
3568 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3569 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3570 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3572 + if (flags & EXT4_IMMUTABLE_FL)
3573 + inode->i_flags |= S_IMMUTABLE;
3574 + if (flags & EXT4_IXUNLINK_FL)
3575 + inode->i_flags |= S_IXUNLINK;
3577 if (flags & EXT4_SYNC_FL)
3578 inode->i_flags |= S_SYNC;
3579 if (flags & EXT4_APPEND_FL)
3580 inode->i_flags |= S_APPEND;
3581 - if (flags & EXT4_IMMUTABLE_FL)
3582 - inode->i_flags |= S_IMMUTABLE;
3583 if (flags & EXT4_NOATIME_FL)
3584 inode->i_flags |= S_NOATIME;
3585 if (flags & EXT4_DIRSYNC_FL)
3586 inode->i_flags |= S_DIRSYNC;
3588 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3590 + if (flags & EXT4_BARRIER_FL)
3591 + inode->i_vflags |= V_BARRIER;
3592 + if (flags & EXT4_COW_FL)
3593 + inode->i_vflags |= V_COW;
3596 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3597 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3599 - unsigned int vfs_fl;
3600 + unsigned int vfs_fl, vflags;
3601 unsigned long old_fl, new_fl;
3604 vfs_fl = ei->vfs_inode.i_flags;
3605 + vflags = ei->vfs_inode.i_vflags;
3606 old_fl = ei->i_flags;
3607 - new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3608 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3610 + new_fl = old_fl & ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3611 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3612 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3613 + EXT4_BARRIER_FL | EXT4_COW_FL);
3615 + if (vfs_fl & S_IMMUTABLE)
3616 + new_fl |= EXT4_IMMUTABLE_FL;
3617 + if (vfs_fl & S_IXUNLINK)
3618 + new_fl |= EXT4_IXUNLINK_FL;
3620 if (vfs_fl & S_SYNC)
3621 new_fl |= EXT4_SYNC_FL;
3622 if (vfs_fl & S_APPEND)
3623 new_fl |= EXT4_APPEND_FL;
3624 - if (vfs_fl & S_IMMUTABLE)
3625 - new_fl |= EXT4_IMMUTABLE_FL;
3626 if (vfs_fl & S_NOATIME)
3627 new_fl |= EXT4_NOATIME_FL;
3628 if (vfs_fl & S_DIRSYNC)
3629 new_fl |= EXT4_DIRSYNC_FL;
3631 + if (vflags & V_BARRIER)
3632 + new_fl |= EXT4_BARRIER_FL;
3633 + if (vflags & V_COW)
3634 + new_fl |= EXT4_COW_FL;
3635 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3638 @@ -4869,6 +4893,8 @@ struct inode *ext4_iget(struct super_blo
3639 journal_t *journal = EXT4_SB(sb)->s_journal;
3645 inode = iget_locked(sb, ino);
3647 @@ -4884,12 +4910,16 @@ struct inode *ext4_iget(struct super_blo
3649 raw_inode = ext4_raw_inode(&iloc);
3650 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3651 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3652 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3653 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3654 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3655 if (!(test_opt(inode->i_sb, NO_UID32))) {
3656 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3657 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3658 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3659 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3661 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3662 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3663 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3664 + le16_to_cpu(raw_inode->i_raw_tag));
3665 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3667 ei->i_state_flags = 0;
3668 @@ -5111,6 +5141,8 @@ static int ext4_do_update_inode(handle_t
3669 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3670 struct ext4_inode_info *ei = EXT4_I(inode);
3671 struct buffer_head *bh = iloc->bh;
3672 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3673 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3674 int err = 0, rc, block;
3676 /* For fields not not tracking in the in-memory inode,
3677 @@ -5121,29 +5153,32 @@ static int ext4_do_update_inode(handle_t
3678 ext4_get_inode_flags(ei);
3679 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3680 if (!(test_opt(inode->i_sb, NO_UID32))) {
3681 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3682 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3683 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3684 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3686 * Fix up interoperability with old kernels. Otherwise, old inodes get
3687 * re-used with the upper 16 bits of the uid/gid intact
3690 raw_inode->i_uid_high =
3691 - cpu_to_le16(high_16_bits(inode->i_uid));
3692 + cpu_to_le16(high_16_bits(uid));
3693 raw_inode->i_gid_high =
3694 - cpu_to_le16(high_16_bits(inode->i_gid));
3695 + cpu_to_le16(high_16_bits(gid));
3697 raw_inode->i_uid_high = 0;
3698 raw_inode->i_gid_high = 0;
3701 raw_inode->i_uid_low =
3702 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3703 + cpu_to_le16(fs_high2lowuid(uid));
3704 raw_inode->i_gid_low =
3705 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3706 + cpu_to_le16(fs_high2lowgid(gid));
3707 raw_inode->i_uid_high = 0;
3708 raw_inode->i_gid_high = 0;
3710 +#ifdef CONFIG_TAGGING_INTERN
3711 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3713 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3715 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3716 @@ -5329,7 +5364,8 @@ int ext4_setattr(struct dentry *dentry,
3719 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3720 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3721 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3722 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3725 /* (user+group)*(old+new) structure, inode write (sb,
3726 @@ -5351,6 +5387,8 @@ int ext4_setattr(struct dentry *dentry,
3727 inode->i_uid = attr->ia_uid;
3728 if (attr->ia_valid & ATTR_GID)
3729 inode->i_gid = attr->ia_gid;
3730 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3731 + inode->i_tag = attr->ia_tag;
3732 error = ext4_mark_inode_dirty(handle, inode);
3733 ext4_journal_stop(handle);
3735 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/ioctl.c
3736 --- linux-2.6.32.56/fs/ext4/ioctl.c 2012-02-09 10:22:30.000000000 +0100
3737 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/ioctl.c 2011-06-10 13:03:02.000000000 +0200
3739 #include <linux/compat.h>
3740 #include <linux/mount.h>
3741 #include <linux/file.h>
3742 +#include <linux/vs_tag.h>
3743 #include <asm/uaccess.h>
3744 #include "ext4_jbd2.h"
3748 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3750 + handle_t *handle = NULL;
3751 + struct ext4_iloc iloc;
3754 + handle = ext4_journal_start(inode, 1);
3755 + if (IS_ERR(handle))
3756 + return PTR_ERR(handle);
3758 + if (IS_SYNC(inode))
3759 + ext4_handle_sync(handle);
3760 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3764 + inode->i_flags = flags;
3765 + inode->i_vflags = vflags;
3766 + ext4_get_inode_flags(EXT4_I(inode));
3767 + inode->i_ctime = ext4_current_time(inode);
3769 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3771 + ext4_journal_stop(handle);
3775 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3777 struct inode *inode = filp->f_dentry->d_inode;
3778 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3780 flags = ext4_mask_flags(inode->i_mode, flags);
3782 + if (IS_BARRIER(inode)) {
3783 + vxwprintk_task(1, "messing with the barrier.");
3788 mutex_lock(&inode->i_mutex);
3789 /* Is it quota file? Do not allow user to mess with it */
3790 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3792 * This test looks nicer. Thanks to Pauline Middelink
3794 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3795 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3796 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3797 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3798 if (!capable(CAP_LINUX_IMMUTABLE))
3801 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/namei.c
3802 --- linux-2.6.32.56/fs/ext4/namei.c 2012-02-09 10:22:30.000000000 +0100
3803 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/namei.c 2011-06-10 13:03:02.000000000 +0200
3805 #include <linux/quotaops.h>
3806 #include <linux/buffer_head.h>
3807 #include <linux/bio.h>
3808 +#include <linux/vs_tag.h>
3810 #include "ext4_jbd2.h"
3812 @@ -941,6 +942,7 @@ restart:
3814 ll_rw_block(READ_META, 1, &bh);
3816 + dx_propagate_tag(nd, inode);
3818 if ((bh = bh_use[ra_ptr++]) == NULL)
3820 @@ -2543,6 +2545,7 @@ const struct inode_operations ext4_dir_i
3822 .check_acl = ext4_check_acl,
3823 .fiemap = ext4_fiemap,
3824 + .sync_flags = ext4_sync_flags,
3827 const struct inode_operations ext4_special_inode_operations = {
3828 diff -NurpP --minimal linux-2.6.32.56/fs/ext4/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/super.c
3829 --- linux-2.6.32.56/fs/ext4/super.c 2012-02-09 10:22:30.000000000 +0100
3830 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ext4/super.c 2012-02-09 10:33:19.000000000 +0100
3831 @@ -1100,6 +1100,7 @@ enum {
3832 Opt_block_validity, Opt_noblock_validity,
3833 Opt_inode_readahead_blks, Opt_journal_ioprio,
3834 Opt_discard, Opt_nodiscard,
3835 + Opt_tag, Opt_notag, Opt_tagid
3838 static const match_table_t tokens = {
3839 @@ -1167,6 +1168,9 @@ static const match_table_t tokens = {
3840 {Opt_noauto_da_alloc, "noauto_da_alloc"},
3841 {Opt_discard, "discard"},
3842 {Opt_nodiscard, "nodiscard"},
3844 + {Opt_notag, "notag"},
3845 + {Opt_tagid, "tagid=%u"},
3849 @@ -1269,6 +1273,20 @@ static int parse_options(char *options,
3851 set_opt(sbi->s_mount_opt, NO_UID32);
3853 +#ifndef CONFIG_TAGGING_NONE
3855 + set_opt (sbi->s_mount_opt, TAGGED);
3858 + clear_opt (sbi->s_mount_opt, TAGGED);
3861 +#ifdef CONFIG_PROPAGATE
3864 + set_opt (sbi->s_mount_opt, TAGGED);
3868 set_opt(sbi->s_mount_opt, DEBUG);
3870 @@ -2470,6 +2488,9 @@ static int ext4_fill_super(struct super_
3871 &journal_ioprio, NULL, 0))
3874 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3875 + sb->s_flags |= MS_TAGGED;
3877 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3878 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3880 @@ -3521,6 +3542,14 @@ static int ext4_remount(struct super_blo
3881 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3882 ext4_abort(sb, __func__, "Abort forced by user");
3884 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3885 + !(sb->s_flags & MS_TAGGED)) {
3886 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3889 + goto restore_opts;
3892 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3893 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3895 diff -NurpP --minimal linux-2.6.32.56/fs/fcntl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/fcntl.c
3896 --- linux-2.6.32.56/fs/fcntl.c 2012-02-09 10:22:30.000000000 +0100
3897 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/fcntl.c 2011-06-10 13:03:02.000000000 +0200
3899 #include <linux/signal.h>
3900 #include <linux/rcupdate.h>
3901 #include <linux/pid_namespace.h>
3902 +#include <linux/vs_limit.h>
3904 #include <asm/poll.h>
3905 #include <asm/siginfo.h>
3906 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3909 filp_close(tofree, files);
3911 + vx_openfd_inc(newfd); /* fd was unused */
3915 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3919 + if (!vx_files_avail(1))
3922 err = security_file_fcntl(filp, cmd, arg);
3924 diff -NurpP --minimal linux-2.6.32.56/fs/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/file.c
3925 --- linux-2.6.32.56/fs/file.c 2009-12-03 20:02:51.000000000 +0100
3926 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/file.c 2011-06-10 13:03:02.000000000 +0200
3928 #include <linux/spinlock.h>
3929 #include <linux/rcupdate.h>
3930 #include <linux/workqueue.h>
3931 +#include <linux/vs_limit.h>
3933 struct fdtable_defer {
3935 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
3936 struct file *f = *old_fds++;
3939 + /* TODO: sum it first for check and performance */
3940 + vx_openfd_inc(open_files - i);
3943 * The fd may be claimed in the fd bitmap but not yet
3944 @@ -476,6 +479,7 @@ repeat:
3946 FD_CLR(fd, fdt->close_on_exec);
3948 + vx_openfd_inc(fd);
3951 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3952 diff -NurpP --minimal linux-2.6.32.56/fs/file_table.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/file_table.c
3953 --- linux-2.6.32.56/fs/file_table.c 2012-02-09 10:22:30.000000000 +0100
3954 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/file_table.c 2011-06-10 13:03:02.000000000 +0200
3956 #include <linux/fsnotify.h>
3957 #include <linux/sysctl.h>
3958 #include <linux/percpu_counter.h>
3959 +#include <linux/vs_limit.h>
3960 +#include <linux/vs_context.h>
3962 #include <asm/atomic.h>
3964 @@ -131,6 +133,8 @@ struct file *get_empty_filp(void)
3965 spin_lock_init(&f->f_lock);
3966 eventpoll_init_file(f);
3967 /* f->f_version: 0 */
3968 + f->f_xid = vx_current_xid();
3973 @@ -285,6 +289,8 @@ void __fput(struct file *file)
3974 cdev_put(inode->i_cdev);
3975 fops_put(file->f_op);
3976 put_pid(file->f_owner.pid);
3977 + vx_files_dec(file);
3980 if (file->f_mode & FMODE_WRITE)
3981 drop_file_write_access(file);
3982 @@ -352,6 +358,8 @@ void put_filp(struct file *file)
3984 if (atomic_long_dec_and_test(&file->f_count)) {
3985 security_file_free(file);
3986 + vx_files_dec(file);
3991 diff -NurpP --minimal linux-2.6.32.56/fs/fs_struct.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/fs_struct.c
3992 --- linux-2.6.32.56/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
3993 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/fs_struct.c 2011-06-10 13:03:02.000000000 +0200
3995 #include <linux/path.h>
3996 #include <linux/slab.h>
3997 #include <linux/fs_struct.h>
3998 +#include <linux/vserver/global.h>
4001 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4002 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4004 path_put(&fs->root);
4006 + atomic_dec(&vs_global_fs);
4007 kmem_cache_free(fs_cachep, fs);
4010 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
4012 path_get(&old->pwd);
4013 read_unlock(&old->lock);
4014 + atomic_inc(&vs_global_fs);
4018 diff -NurpP --minimal linux-2.6.32.56/fs/gfs2/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/gfs2/file.c
4019 --- linux-2.6.32.56/fs/gfs2/file.c 2012-02-09 10:22:30.000000000 +0100
4020 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/gfs2/file.c 2011-06-10 13:03:02.000000000 +0200
4021 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4022 [7] = GFS2_DIF_NOATIME,
4023 [12] = GFS2_DIF_EXHASH,
4024 [14] = GFS2_DIF_INHERIT_JDATA,
4025 + [27] = GFS2_DIF_IXUNLINK,
4026 + [26] = GFS2_DIF_BARRIER,
4027 + [29] = GFS2_DIF_COW,
4030 static const u32 gfs2_to_fsflags[32] = {
4031 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4032 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4033 [gfs2fl_ExHash] = FS_INDEX_FL,
4034 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4035 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4036 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4037 + [gfs2fl_Cow] = FS_COW_FL,
4040 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4041 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4043 struct gfs2_inode *ip = GFS2_I(inode);
4044 unsigned int flags = inode->i_flags;
4045 + unsigned int vflags = inode->i_vflags;
4047 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4048 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4050 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4051 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4052 flags |= S_IMMUTABLE;
4053 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4054 + flags |= S_IXUNLINK;
4056 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4058 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4059 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4060 if (ip->i_diskflags & GFS2_DIF_SYNC)
4062 inode->i_flags = flags;
4064 + vflags &= ~(V_BARRIER | V_COW);
4066 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4067 + vflags |= V_BARRIER;
4068 + if (ip->i_diskflags & GFS2_DIF_COW)
4070 + inode->i_vflags = vflags;
4073 +void gfs2_get_inode_flags(struct inode *inode)
4075 + struct gfs2_inode *ip = GFS2_I(inode);
4076 + unsigned int flags = inode->i_flags;
4077 + unsigned int vflags = inode->i_vflags;
4079 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4080 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4081 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4082 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4084 + if (flags & S_IMMUTABLE)
4085 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4086 + if (flags & S_IXUNLINK)
4087 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4089 + if (flags & S_APPEND)
4090 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4091 + if (flags & S_NOATIME)
4092 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4093 + if (flags & S_SYNC)
4094 + ip->i_diskflags |= GFS2_DIF_SYNC;
4096 + if (vflags & V_BARRIER)
4097 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4098 + if (vflags & V_COW)
4099 + ip->i_diskflags |= GFS2_DIF_COW;
4102 /* Flags that can be set by user space */
4103 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
4104 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4107 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4109 + struct gfs2_inode *ip = GFS2_I(inode);
4110 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4111 + struct buffer_head *bh;
4112 + struct gfs2_holder gh;
4115 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4118 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4121 + error = gfs2_meta_inode_buffer(ip, &bh);
4123 + goto out_trans_end;
4124 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4125 + inode->i_flags = flags;
4126 + inode->i_vflags = vflags;
4127 + gfs2_get_inode_flags(inode);
4128 + gfs2_dinode_out(ip, bh->b_data);
4130 + gfs2_set_aops(inode);
4132 + gfs2_trans_end(sdp);
4134 + gfs2_glock_dq_uninit(&gh);
4138 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4141 diff -NurpP --minimal linux-2.6.32.56/fs/gfs2/inode.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/gfs2/inode.h
4142 --- linux-2.6.32.56/fs/gfs2/inode.h 2009-09-10 15:26:22.000000000 +0200
4143 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/gfs2/inode.h 2011-06-10 13:03:02.000000000 +0200
4144 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4145 extern const struct file_operations gfs2_dir_fops_nolock;
4147 extern void gfs2_set_inode_flags(struct inode *inode);
4148 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4150 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4151 extern const struct file_operations gfs2_file_fops;
4152 diff -NurpP --minimal linux-2.6.32.56/fs/gfs2/ops_inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/gfs2/ops_inode.c
4153 --- linux-2.6.32.56/fs/gfs2/ops_inode.c 2009-12-03 20:02:52.000000000 +0100
4154 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/gfs2/ops_inode.c 2011-06-10 13:03:02.000000000 +0200
4155 @@ -1400,6 +1400,7 @@ const struct inode_operations gfs2_file_
4156 .listxattr = gfs2_listxattr,
4157 .removexattr = gfs2_removexattr,
4158 .fiemap = gfs2_fiemap,
4159 + .sync_flags = gfs2_sync_flags,
4162 const struct inode_operations gfs2_dir_iops = {
4163 @@ -1420,6 +1421,7 @@ const struct inode_operations gfs2_dir_i
4164 .listxattr = gfs2_listxattr,
4165 .removexattr = gfs2_removexattr,
4166 .fiemap = gfs2_fiemap,
4167 + .sync_flags = gfs2_sync_flags,
4170 const struct inode_operations gfs2_symlink_iops = {
4171 diff -NurpP --minimal linux-2.6.32.56/fs/hfsplus/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/hfsplus/ioctl.c
4172 --- linux-2.6.32.56/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4173 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/hfsplus/ioctl.c 2011-06-10 13:03:02.000000000 +0200
4175 #include <linux/mount.h>
4176 #include <linux/sched.h>
4177 #include <linux/xattr.h>
4178 +#include <linux/mount.h>
4179 #include <asm/uaccess.h>
4180 #include "hfsplus_fs.h"
4182 diff -NurpP --minimal linux-2.6.32.56/fs/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/inode.c
4183 --- linux-2.6.32.56/fs/inode.c 2012-02-09 10:22:30.000000000 +0100
4184 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/inode.c 2011-08-08 22:40:36.000000000 +0200
4185 @@ -133,6 +133,9 @@ int inode_init_always(struct super_block
4186 struct address_space *const mapping = &inode->i_data;
4190 + /* essential because of inode slab reuse */
4192 inode->i_blkbits = sb->s_blocksize_bits;
4194 atomic_set(&inode->i_count, 1);
4195 @@ -153,6 +156,7 @@ int inode_init_always(struct super_block
4196 inode->i_bdev = NULL;
4197 inode->i_cdev = NULL;
4199 + inode->i_mdev = 0;
4200 inode->dirtied_when = 0;
4202 if (security_inode_alloc(inode))
4203 @@ -315,6 +319,8 @@ void __iget(struct inode *inode)
4204 inodes_stat.nr_unused--;
4207 +EXPORT_SYMBOL_GPL(__iget);
4210 * clear_inode - clear an inode
4211 * @inode: inode to clear
4212 @@ -1619,9 +1625,11 @@ void init_special_inode(struct inode *in
4213 if (S_ISCHR(mode)) {
4214 inode->i_fop = &def_chr_fops;
4215 inode->i_rdev = rdev;
4216 + inode->i_mdev = rdev;
4217 } else if (S_ISBLK(mode)) {
4218 inode->i_fop = &def_blk_fops;
4219 inode->i_rdev = rdev;
4220 + inode->i_mdev = rdev;
4221 } else if (S_ISFIFO(mode))
4222 inode->i_fop = &def_fifo_fops;
4223 else if (S_ISSOCK(mode))
4224 diff -NurpP --minimal linux-2.6.32.56/fs/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ioctl.c
4225 --- linux-2.6.32.56/fs/ioctl.c 2009-12-03 20:02:52.000000000 +0100
4226 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ioctl.c 2011-06-10 13:03:02.000000000 +0200
4228 #include <linux/writeback.h>
4229 #include <linux/buffer_head.h>
4230 #include <linux/falloc.h>
4231 +#include <linux/proc_fs.h>
4232 +#include <linux/vserver/inode.h>
4233 +#include <linux/vs_tag.h>
4235 #include <asm/ioctls.h>
4237 diff -NurpP --minimal linux-2.6.32.56/fs/ioprio.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ioprio.c
4238 --- linux-2.6.32.56/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
4239 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ioprio.c 2011-06-10 13:03:02.000000000 +0200
4241 #include <linux/syscalls.h>
4242 #include <linux/security.h>
4243 #include <linux/pid_namespace.h>
4244 +#include <linux/vs_base.h>
4246 int set_task_ioprio(struct task_struct *task, int ioprio)
4248 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4250 pgrp = find_vpid(who);
4251 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4252 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4254 ret = set_task_ioprio(p, ioprio);
4257 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4259 pgrp = find_vpid(who);
4260 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4261 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4263 tmpio = get_task_ioprio(p);
4266 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/acl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/acl.c
4267 --- linux-2.6.32.56/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
4268 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/acl.c 2011-06-10 13:03:02.000000000 +0200
4269 @@ -216,7 +216,8 @@ int jfs_setattr(struct dentry *dentry, s
4272 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4273 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4274 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4275 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4276 if (vfs_dq_transfer(inode, iattr))
4279 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/file.c
4280 --- linux-2.6.32.56/fs/jfs/file.c 2009-12-03 20:02:52.000000000 +0100
4281 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/file.c 2011-06-10 13:03:02.000000000 +0200
4282 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4283 .setattr = jfs_setattr,
4284 .check_acl = jfs_check_acl,
4286 + .sync_flags = jfs_sync_flags,
4289 const struct file_operations jfs_file_operations = {
4290 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/ioctl.c
4291 --- linux-2.6.32.56/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4292 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/ioctl.c 2011-06-10 13:03:02.000000000 +0200
4294 #include <linux/mount.h>
4295 #include <linux/time.h>
4296 #include <linux/sched.h>
4297 +#include <linux/mount.h>
4298 #include <asm/current.h>
4299 #include <asm/uaccess.h>
4301 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4305 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4307 + inode->i_flags = flags;
4308 + inode->i_vflags = vflags;
4309 + jfs_get_inode_flags(JFS_IP(inode));
4310 + inode->i_ctime = CURRENT_TIME_SEC;
4311 + mark_inode_dirty(inode);
4315 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4317 struct inode *inode = filp->f_dentry->d_inode;
4318 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4319 if (!S_ISDIR(inode->i_mode))
4320 flags &= ~JFS_DIRSYNC_FL;
4322 + if (IS_BARRIER(inode)) {
4323 + vxwprintk_task(1, "messing with the barrier.");
4327 /* Is it quota file? Do not allow user to mess with it */
4328 if (IS_NOQUOTA(inode)) {
4330 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4331 * the relevant capability.
4333 if ((oldflags & JFS_IMMUTABLE_FL) ||
4334 - ((flags ^ oldflags) &
4335 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4336 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4337 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4338 if (!capable(CAP_LINUX_IMMUTABLE)) {
4339 mutex_unlock(&inode->i_mutex);
4341 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4345 - flags = flags & JFS_FL_USER_MODIFIABLE;
4346 + flags &= JFS_FL_USER_MODIFIABLE;
4347 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4348 jfs_inode->mode2 = flags;
4350 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/jfs_dinode.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_dinode.h
4351 --- linux-2.6.32.56/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4352 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_dinode.h 2011-06-10 13:03:02.000000000 +0200
4353 @@ -161,9 +161,13 @@ struct dinode {
4355 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4356 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4357 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4359 -#define JFS_FL_USER_VISIBLE 0x03F80000
4360 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4361 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4362 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4364 +#define JFS_FL_USER_VISIBLE 0x07F80000
4365 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4366 #define JFS_FL_INHERIT 0x03C80000
4368 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4369 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/jfs_filsys.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_filsys.h
4370 --- linux-2.6.32.56/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4371 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_filsys.h 2011-06-10 13:03:02.000000000 +0200
4373 #define JFS_NAME_MAX 255
4374 #define JFS_PATH_MAX BPSIZE
4376 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4379 * file system state (superblock state)
4380 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/jfs_imap.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_imap.c
4381 --- linux-2.6.32.56/fs/jfs/jfs_imap.c 2009-09-10 15:26:22.000000000 +0200
4382 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_imap.c 2011-06-10 13:03:02.000000000 +0200
4384 #include <linux/buffer_head.h>
4385 #include <linux/pagemap.h>
4386 #include <linux/quotaops.h>
4387 +#include <linux/vs_tag.h>
4389 #include "jfs_incore.h"
4390 #include "jfs_inode.h"
4391 @@ -3059,6 +3060,8 @@ static int copy_from_dinode(struct dinod
4393 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4394 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4398 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4399 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4400 @@ -3079,14 +3082,18 @@ static int copy_from_dinode(struct dinod
4402 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4404 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4405 + uid = le32_to_cpu(dip->di_uid);
4406 + gid = le32_to_cpu(dip->di_gid);
4407 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4409 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4411 ip->i_uid = jfs_ip->saved_uid;
4413 ip->i_uid = sbi->uid;
4416 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4417 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4419 ip->i_gid = jfs_ip->saved_gid;
4421 @@ -3151,14 +3158,12 @@ static void copy_to_dinode(struct dinode
4422 dip->di_size = cpu_to_le64(ip->i_size);
4423 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4424 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4425 - if (sbi->uid == -1)
4426 - dip->di_uid = cpu_to_le32(ip->i_uid);
4428 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4429 - if (sbi->gid == -1)
4430 - dip->di_gid = cpu_to_le32(ip->i_gid);
4432 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4434 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4435 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4436 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4437 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4439 jfs_get_inode_flags(jfs_ip);
4441 * mode2 is only needed for storing the higher order bits.
4442 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/jfs_inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_inode.c
4443 --- linux-2.6.32.56/fs/jfs/jfs_inode.c 2009-06-11 17:13:05.000000000 +0200
4444 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_inode.c 2011-06-10 13:03:02.000000000 +0200
4447 #include <linux/fs.h>
4448 #include <linux/quotaops.h>
4449 +#include <linux/vs_tag.h>
4450 #include "jfs_incore.h"
4451 #include "jfs_inode.h"
4452 #include "jfs_filsys.h"
4453 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4455 unsigned int flags = JFS_IP(inode)->mode2;
4457 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4458 - S_NOATIME | S_DIRSYNC | S_SYNC);
4459 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4460 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4462 if (flags & JFS_IMMUTABLE_FL)
4463 inode->i_flags |= S_IMMUTABLE;
4464 + if (flags & JFS_IXUNLINK_FL)
4465 + inode->i_flags |= S_IXUNLINK;
4467 + if (flags & JFS_SYNC_FL)
4468 + inode->i_flags |= S_SYNC;
4469 if (flags & JFS_APPEND_FL)
4470 inode->i_flags |= S_APPEND;
4471 if (flags & JFS_NOATIME_FL)
4472 inode->i_flags |= S_NOATIME;
4473 if (flags & JFS_DIRSYNC_FL)
4474 inode->i_flags |= S_DIRSYNC;
4475 - if (flags & JFS_SYNC_FL)
4476 - inode->i_flags |= S_SYNC;
4478 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4480 + if (flags & JFS_BARRIER_FL)
4481 + inode->i_vflags |= V_BARRIER;
4482 + if (flags & JFS_COW_FL)
4483 + inode->i_vflags |= V_COW;
4486 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4488 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4489 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4491 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4492 + JFS_APPEND_FL | JFS_NOATIME_FL |
4493 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4494 + JFS_BARRIER_FL | JFS_COW_FL);
4496 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4497 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4498 if (flags & S_IMMUTABLE)
4499 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4500 + if (flags & S_IXUNLINK)
4501 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4503 if (flags & S_APPEND)
4504 jfs_ip->mode2 |= JFS_APPEND_FL;
4505 if (flags & S_NOATIME)
4506 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4507 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4509 jfs_ip->mode2 |= JFS_SYNC_FL;
4511 + if (vflags & V_BARRIER)
4512 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4513 + if (vflags & V_COW)
4514 + jfs_ip->mode2 |= JFS_COW_FL;
4518 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
4521 inode->i_gid = current_fsgid();
4522 + inode->i_tag = dx_current_fstag(sb);
4525 * New inodes need to save sane values on disk when
4526 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/jfs_inode.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_inode.h
4527 --- linux-2.6.32.56/fs/jfs/jfs_inode.h 2009-06-11 17:13:05.000000000 +0200
4528 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/jfs_inode.h 2011-06-10 13:03:02.000000000 +0200
4529 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4530 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4531 int fh_len, int fh_type);
4532 extern void jfs_set_inode_flags(struct inode *);
4533 +extern int jfs_sync_flags(struct inode *, int, int);
4534 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4536 extern const struct address_space_operations jfs_aops;
4537 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/namei.c
4538 --- linux-2.6.32.56/fs/jfs/namei.c 2009-12-03 20:02:52.000000000 +0100
4539 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/namei.c 2011-06-10 13:03:02.000000000 +0200
4541 #include <linux/ctype.h>
4542 #include <linux/quotaops.h>
4543 #include <linux/exportfs.h>
4544 +#include <linux/vs_tag.h>
4545 #include "jfs_incore.h"
4546 #include "jfs_superblock.h"
4547 #include "jfs_inode.h"
4548 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4549 return ERR_CAST(ip);
4552 + dx_propagate_tag(nd, ip);
4553 dentry = d_splice_alias(ip, dentry);
4555 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4556 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4557 .setattr = jfs_setattr,
4558 .check_acl = jfs_check_acl,
4560 + .sync_flags = jfs_sync_flags,
4563 const struct file_operations jfs_dir_operations = {
4564 diff -NurpP --minimal linux-2.6.32.56/fs/jfs/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/super.c
4565 --- linux-2.6.32.56/fs/jfs/super.c 2009-12-03 20:02:52.000000000 +0100
4566 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/jfs/super.c 2011-06-10 13:03:02.000000000 +0200
4567 @@ -192,7 +192,8 @@ static void jfs_put_super(struct super_b
4569 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4570 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4571 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4572 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4573 + Opt_tag, Opt_notag, Opt_tagid
4576 static const match_table_t tokens = {
4577 @@ -202,6 +203,10 @@ static const match_table_t tokens = {
4578 {Opt_resize, "resize=%u"},
4579 {Opt_resize_nosize, "resize"},
4580 {Opt_errors, "errors=%s"},
4582 + {Opt_notag, "notag"},
4583 + {Opt_tagid, "tagid=%u"},
4584 + {Opt_tag, "tagxid"},
4585 {Opt_ignore, "noquota"},
4586 {Opt_ignore, "quota"},
4587 {Opt_usrquota, "usrquota"},
4588 @@ -336,6 +341,20 @@ static int parse_options(char *options,
4592 +#ifndef CONFIG_TAGGING_NONE
4594 + *flag |= JFS_TAGGED;
4597 + *flag &= JFS_TAGGED;
4600 +#ifdef CONFIG_PROPAGATE
4603 + *flag |= JFS_TAGGED;
4607 printk("jfs: Unrecognized mount option \"%s\" "
4608 " or missing value\n", p);
4609 @@ -366,6 +385,12 @@ static int jfs_remount(struct super_bloc
4610 if (!parse_options(data, sb, &newLVSize, &flag)) {
4613 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4614 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4621 if (sb->s_flags & MS_RDONLY) {
4622 @@ -449,6 +474,9 @@ static int jfs_fill_super(struct super_b
4623 #ifdef CONFIG_JFS_POSIX_ACL
4624 sb->s_flags |= MS_POSIXACL;
4626 + /* map mount option tagxid */
4627 + if (sbi->flag & JFS_TAGGED)
4628 + sb->s_flags |= MS_TAGGED;
4631 printk(KERN_ERR "resize option for remount only\n");
4632 diff -NurpP --minimal linux-2.6.32.56/fs/libfs.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/libfs.c
4633 --- linux-2.6.32.56/fs/libfs.c 2012-02-09 10:22:30.000000000 +0100
4634 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/libfs.c 2011-06-10 13:03:02.000000000 +0200
4635 @@ -127,7 +127,8 @@ static inline unsigned char dt_type(stru
4636 * both impossible due to the lock on directory.
4639 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4640 +static inline int do_dcache_readdir_filter(struct file *filp,
4641 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4643 struct dentry *dentry = filp->f_path.dentry;
4644 struct dentry *cursor = filp->private_data;
4645 @@ -160,6 +161,8 @@ int dcache_readdir(struct file * filp, v
4646 next = list_entry(p, struct dentry, d_u.d_child);
4647 if (d_unhashed(next) || !next->d_inode)
4649 + if (filter && !filter(next))
4652 spin_unlock(&dcache_lock);
4653 if (filldir(dirent, next->d_name.name,
4654 @@ -178,6 +181,18 @@ int dcache_readdir(struct file * filp, v
4658 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4660 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4663 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4664 + int (*filter)(struct dentry *))
4666 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4670 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4673 @@ -842,6 +857,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4674 EXPORT_SYMBOL(dcache_dir_lseek);
4675 EXPORT_SYMBOL(dcache_dir_open);
4676 EXPORT_SYMBOL(dcache_readdir);
4677 +EXPORT_SYMBOL(dcache_readdir_filter);
4678 EXPORT_SYMBOL(generic_read_dir);
4679 EXPORT_SYMBOL(get_sb_pseudo);
4680 EXPORT_SYMBOL(simple_write_begin);
4681 diff -NurpP --minimal linux-2.6.32.56/fs/locks.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/locks.c
4682 --- linux-2.6.32.56/fs/locks.c 2009-12-03 20:02:52.000000000 +0100
4683 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/locks.c 2011-06-10 13:03:02.000000000 +0200
4685 #include <linux/time.h>
4686 #include <linux/rcupdate.h>
4687 #include <linux/pid_namespace.h>
4688 +#include <linux/vs_base.h>
4689 +#include <linux/vs_limit.h>
4691 #include <asm/uaccess.h>
4693 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4694 /* Allocate an empty lock structure. */
4695 static struct file_lock *locks_alloc_lock(void)
4697 + if (!vx_locks_avail(1))
4699 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4702 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4703 BUG_ON(!list_empty(&fl->fl_block));
4704 BUG_ON(!list_empty(&fl->fl_link));
4707 locks_release_private(fl);
4708 kmem_cache_free(filelock_cache, fl);
4710 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
4711 fl->fl_start = fl->fl_end = 0;
4713 fl->fl_lmops = NULL;
4717 EXPORT_SYMBOL(locks_init_lock);
4718 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
4719 new->fl_file = fl->fl_file;
4720 new->fl_ops = fl->fl_ops;
4721 new->fl_lmops = fl->fl_lmops;
4722 + new->fl_xid = fl->fl_xid;
4724 locks_copy_private(new, fl);
4726 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
4727 fl->fl_flags = FL_FLOCK;
4729 fl->fl_end = OFFSET_MAX;
4731 + vxd_assert(filp->f_xid == vx_current_xid(),
4732 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4733 + fl->fl_xid = filp->f_xid;
4738 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
4740 fl->fl_owner = current->files;
4741 fl->fl_pid = current->tgid;
4742 + fl->fl_xid = vx_current_xid();
4745 fl->fl_flags = FL_LEASE;
4746 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
4748 return ERR_PTR(error);
4750 + fl->fl_xid = vx_current_xid();
4752 + vxd_assert(filp->f_xid == fl->fl_xid,
4753 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4755 error = lease_init(filp, type, fl);
4757 locks_free_lock(fl);
4758 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
4762 + new_fl->fl_xid = -1;
4764 for_each_lock(inode, before) {
4765 struct file_lock *fl = *before;
4766 @@ -790,6 +809,7 @@ find_conflict:
4768 locks_copy_lock(new_fl, request);
4769 locks_insert_lock(before, new_fl);
4770 + vx_locks_inc(new_fl);
4774 @@ -800,7 +820,8 @@ out:
4778 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4779 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4780 + struct file_lock *conflock, xid_t xid)
4782 struct file_lock *fl;
4783 struct file_lock *new_fl = NULL;
4784 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
4785 struct file_lock **before;
4786 int error, added = 0;
4788 + vxd_assert(xid == vx_current_xid(),
4789 + "xid(%d) == current(%d)", xid, vx_current_xid());
4791 * We may need two file_lock structures for this operation,
4792 * so we get them in advance to avoid races.
4793 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
4794 (request->fl_type != F_UNLCK ||
4795 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4796 new_fl = locks_alloc_lock();
4797 + new_fl->fl_xid = xid;
4798 + vx_locks_inc(new_fl);
4799 new_fl2 = locks_alloc_lock();
4800 + new_fl2->fl_xid = xid;
4801 + vx_locks_inc(new_fl2);
4805 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
4806 int posix_lock_file(struct file *filp, struct file_lock *fl,
4807 struct file_lock *conflock)
4809 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4810 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4811 + fl, conflock, filp->f_xid);
4813 EXPORT_SYMBOL(posix_lock_file);
4815 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
4816 fl.fl_end = offset + count - 1;
4819 - error = __posix_lock_file(inode, &fl, NULL);
4820 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4821 if (error != FILE_LOCK_DEFERRED)
4823 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4824 @@ -1424,6 +1452,7 @@ int generic_setlease(struct file *filp,
4826 locks_copy_lock(new_fl, lease);
4827 locks_insert_lock(before, new_fl);
4828 + vx_locks_inc(new_fl);
4832 @@ -1779,6 +1808,11 @@ int fcntl_setlk(unsigned int fd, struct
4833 if (file_lock == NULL)
4836 + vxd_assert(filp->f_xid == vx_current_xid(),
4837 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4838 + file_lock->fl_xid = filp->f_xid;
4839 + vx_locks_inc(file_lock);
4842 * This might block, so we do it before checking the inode.
4844 @@ -1897,6 +1931,11 @@ int fcntl_setlk64(unsigned int fd, struc
4845 if (file_lock == NULL)
4848 + vxd_assert(filp->f_xid == vx_current_xid(),
4849 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4850 + file_lock->fl_xid = filp->f_xid;
4851 + vx_locks_inc(file_lock);
4854 * This might block, so we do it before checking the inode.
4856 @@ -2162,8 +2201,11 @@ static int locks_show(struct seq_file *f
4858 lock_get_status(f, fl, (long)f->private, "");
4860 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4861 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4862 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4864 lock_get_status(f, bfl, (long)f->private, " ->");
4869 diff -NurpP --minimal linux-2.6.32.56/fs/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/namei.c
4870 --- linux-2.6.32.56/fs/namei.c 2012-02-09 10:22:30.000000000 +0100
4871 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/namei.c 2011-06-10 18:44:08.000000000 +0200
4873 #include <linux/fcntl.h>
4874 #include <linux/device_cgroup.h>
4875 #include <linux/fs_struct.h>
4876 +#include <linux/proc_fs.h>
4877 +#include <linux/vserver/inode.h>
4878 +#include <linux/vs_base.h>
4879 +#include <linux/vs_tag.h>
4880 +#include <linux/vs_cowbl.h>
4881 +#include <linux/vs_device.h>
4882 +#include <linux/vs_context.h>
4883 +#include <linux/pid_namespace.h>
4884 #include <asm/uaccess.h>
4886 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
4887 @@ -169,6 +177,77 @@ void putname(const char *name)
4888 EXPORT_SYMBOL(putname);
4891 +static inline int dx_barrier(const struct inode *inode)
4893 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4894 + vxwprintk_task(1, "did hit the barrier.");
4900 +static int __dx_permission(const struct inode *inode, int mask)
4902 + if (dx_barrier(inode))
4905 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4906 + /* devpts is xid tagged */
4907 + if (S_ISDIR(inode->i_mode) ||
4908 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4911 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4912 + struct proc_dir_entry *de = PDE(inode);
4914 + if (de && !vx_hide_check(0, de->vx_flags))
4917 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4919 + struct task_struct *tsk;
4921 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4922 + vx_flags(VXF_STATE_SETUP, 0))
4925 + pid = PROC_I(inode)->pid;
4929 + tsk = pid_task(pid, PIDTYPE_PID);
4930 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4931 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4932 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4936 + /* FIXME: Should we block some entries here? */
4941 + if (dx_notagcheck(inode->i_sb) ||
4942 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4951 +int dx_permission(const struct inode *inode, int mask)
4953 + int ret = __dx_permission(inode, mask);
4954 + if (unlikely(ret)) {
4955 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
4956 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4963 * This does basic POSIX ACL permission checking
4965 @@ -269,10 +348,14 @@ int inode_permission(struct inode *inode
4967 * Nobody gets write access to an immutable file.
4969 - if (IS_IMMUTABLE(inode))
4970 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4974 + retval = dx_permission(inode, mask);
4978 if (inode->i_op->permission)
4979 retval = inode->i_op->permission(inode, mask);
4981 @@ -448,6 +531,9 @@ static int exec_permission_lite(struct i
4985 + if (dx_barrier(inode))
4988 if (inode->i_op->permission) {
4989 ret = inode->i_op->permission(inode, MAY_EXEC);
4991 @@ -763,7 +849,8 @@ static __always_inline void follow_dotdo
4993 if (nd->path.dentry == nd->root.dentry &&
4994 nd->path.mnt == nd->root.mnt) {
4996 + /* for sane '/' avoid follow_mount() */
4999 spin_lock(&dcache_lock);
5000 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5001 @@ -799,16 +886,30 @@ static int do_lookup(struct nameidata *n
5003 struct vfsmount *mnt = nd->path.mnt;
5004 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5005 + struct inode *inode;
5009 if (dentry->d_op && dentry->d_op->d_revalidate)
5010 goto need_revalidate;
5011 + inode = dentry->d_inode;
5015 + if (__dx_permission(inode, MAY_ACCESS))
5020 path->dentry = dentry;
5021 __follow_mount(path);
5024 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
5025 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5026 + vxd_path(&nd->path), name->len, name->name);
5031 dentry = real_lookup(nd->path.dentry, name, nd);
5032 @@ -1400,7 +1501,7 @@ static int may_delete(struct inode *dir,
5035 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5036 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5037 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5040 if (!S_ISDIR(victim->d_inode->i_mode))
5041 @@ -1540,6 +1641,14 @@ int may_open(struct path *path, int acc_
5045 +#ifdef CONFIG_VSERVER_COWBL
5046 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5047 + if (IS_COW_LINK(inode))
5049 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
5050 + mark_inode_dirty(inode);
5053 error = inode_permission(inode, acc_mode);
5056 @@ -1688,7 +1797,11 @@ struct file *do_filp_open(int dfd, const
5059 int flag = open_to_namei_flags(open_flag);
5061 +#ifdef CONFIG_VSERVER_COWBL
5067 acc_mode = MAY_OPEN | ACC_MODE(flag);
5069 @@ -1836,6 +1949,25 @@ ok:
5072 error = may_open(&nd.path, acc_mode, flag);
5073 +#ifdef CONFIG_VSERVER_COWBL
5074 + if (error == -EMLINK) {
5075 + struct dentry *dentry;
5076 + dentry = cow_break_link(pathname);
5077 + if (IS_ERR(dentry)) {
5078 + error = PTR_ERR(dentry);
5083 + mnt_drop_write(nd.path.mnt);
5084 + release_open_intent(&nd);
5085 + path_put(&nd.path);
5094 mnt_drop_write(nd.path.mnt);
5095 @@ -1998,9 +2130,17 @@ int vfs_mknod(struct inode *dir, struct
5099 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5100 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5103 + if (!capable(CAP_MKNOD))
5106 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5108 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5111 if (!dir->i_op->mknod)
5114 @@ -2467,7 +2607,7 @@ int vfs_link(struct dentry *old_dentry,
5116 * A link to an append-only or immutable file cannot be created.
5118 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5119 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5121 if (!dir->i_op->link)
5123 @@ -2840,6 +2980,219 @@ int vfs_follow_link(struct nameidata *nd
5124 return __vfs_follow_link(nd, link);
5128 +#ifdef CONFIG_VSERVER_COWBL
5130 +#include <linux/file.h>
5133 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5137 + return do_splice_direct(in, &ppos, out, len, 0);
5140 +struct dentry *cow_break_link(const char *pathname)
5142 + int ret, mode, pathlen, redo = 0;
5143 + struct nameidata old_nd, dir_nd;
5144 + struct path old_path, new_path;
5145 + struct dentry *dir, *res = NULL;
5146 + struct file *old_file;
5147 + struct file *new_file;
5148 + char *to, *path, pad='\251';
5151 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5152 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5157 + /* old_nd will have refs to dentry and mnt */
5158 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5159 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5161 + goto out_free_path;
5163 + old_path = old_nd.path;
5164 + mode = old_path.dentry->d_inode->i_mode;
5166 + to = d_path(&old_path, path, PATH_MAX-2);
5167 + pathlen = strlen(to);
5168 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5169 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5170 + old_path.dentry->d_name.len);
5172 + to[pathlen + 1] = 0;
5174 + to[pathlen] = pad--;
5176 + if (pad <= '\240')
5179 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5180 + /* dir_nd will have refs to dentry and mnt */
5181 + ret = path_lookup(to,
5182 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5183 + vxdprintk(VXD_CBIT(misc, 2),
5184 + "path_lookup(new): %d", ret);
5188 + /* this puppy downs the inode mutex */
5189 + new_path.dentry = lookup_create(&dir_nd, 0);
5190 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5191 + vxdprintk(VXD_CBIT(misc, 2),
5192 + "lookup_create(new): %p", new_path.dentry);
5193 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5194 + path_put(&dir_nd.path);
5197 + vxdprintk(VXD_CBIT(misc, 2),
5198 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5199 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5200 + new_path.dentry->d_name.len);
5201 + dir = dir_nd.path.dentry;
5203 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5204 + vxdprintk(VXD_CBIT(misc, 2),
5205 + "vfs_create(new): %d", ret);
5206 + if (ret == -EEXIST) {
5207 + mutex_unlock(&dir->d_inode->i_mutex);
5208 + dput(new_path.dentry);
5209 + path_put(&dir_nd.path);
5213 + goto out_unlock_new;
5215 + /* drop out early, ret passes ENOENT */
5217 + if ((redo = d_unhashed(old_path.dentry)))
5218 + goto out_unlock_new;
5220 + new_path.mnt = dir_nd.path.mnt;
5221 + dget(old_path.dentry);
5222 + mntget(old_path.mnt);
5223 + /* this one cleans up the dentry/mnt in case of failure */
5224 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5225 + O_RDONLY, current_cred());
5226 + vxdprintk(VXD_CBIT(misc, 2),
5227 + "dentry_open(old): %p", old_file);
5228 + if (!old_file || IS_ERR(old_file)) {
5229 + res = IS_ERR(old_file) ? (void *) old_file : res;
5230 + goto out_unlock_new;
5233 + dget(new_path.dentry);
5234 + mntget(new_path.mnt);
5235 + /* this one cleans up the dentry/mnt in case of failure */
5236 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5237 + O_WRONLY, current_cred());
5238 + vxdprintk(VXD_CBIT(misc, 2),
5239 + "dentry_open(new): %p", new_file);
5241 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5242 + if (!new_file || IS_ERR(new_file))
5243 + goto out_fput_old;
5245 + size = i_size_read(old_file->f_dentry->d_inode);
5246 + ret = do_cow_splice(old_file, new_file, size);
5247 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5249 + goto out_fput_both;
5250 + } else if (ret < size) {
5252 + goto out_fput_both;
5254 + struct inode *old_inode = old_path.dentry->d_inode;
5255 + struct inode *new_inode = new_path.dentry->d_inode;
5256 + struct iattr attr = {
5257 + .ia_uid = old_inode->i_uid,
5258 + .ia_gid = old_inode->i_gid,
5259 + .ia_valid = ATTR_UID | ATTR_GID
5262 + ret = inode_setattr(new_inode, &attr);
5264 + goto out_fput_both;
5267 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5269 + /* drop out late */
5271 + if ((redo = d_unhashed(old_path.dentry)))
5274 + vxdprintk(VXD_CBIT(misc, 2),
5275 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5276 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5277 + new_path.dentry->d_name.len,
5278 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5279 + old_path.dentry->d_name.len);
5280 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5281 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5282 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5283 + res = new_path.dentry;
5286 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5289 + vxdprintk(VXD_CBIT(misc, 3),
5290 + "fput(new_file=%p[#%ld])", new_file,
5291 + atomic_long_read(&new_file->f_count));
5295 + vxdprintk(VXD_CBIT(misc, 3),
5296 + "fput(old_file=%p[#%ld])", old_file,
5297 + atomic_long_read(&old_file->f_count));
5301 + mutex_unlock(&dir->d_inode->i_mutex);
5305 + /* error path cleanup */
5306 + vfs_unlink(dir->d_inode, new_path.dentry);
5307 + dput(new_path.dentry);
5311 + goto out_rel_both;
5312 + /* lookup dentry once again */
5313 + path_put(&old_nd.path);
5314 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5316 + goto out_rel_both;
5318 + new_path.dentry = old_nd.path.dentry;
5319 + vxdprintk(VXD_CBIT(misc, 2),
5320 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5321 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5322 + new_path.dentry->d_name.len);
5323 + dget(new_path.dentry);
5324 + res = new_path.dentry;
5327 + path_put(&dir_nd.path);
5329 + path_put(&old_nd.path);
5334 + res = ERR_PTR(ret);
5340 /* get the link contents into pagecache */
5341 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5343 diff -NurpP --minimal linux-2.6.32.56/fs/namespace.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/namespace.c
5344 --- linux-2.6.32.56/fs/namespace.c 2012-02-09 10:22:30.000000000 +0100
5345 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/namespace.c 2011-06-10 13:03:02.000000000 +0200
5347 #include <linux/log2.h>
5348 #include <linux/idr.h>
5349 #include <linux/fs_struct.h>
5350 +#include <linux/vs_base.h>
5351 +#include <linux/vs_context.h>
5352 +#include <linux/vs_tag.h>
5353 +#include <linux/vserver/space.h>
5354 +#include <linux/vserver/global.h>
5355 #include <asm/uaccess.h>
5356 #include <asm/unistd.h>
5358 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
5359 mnt->mnt_root = dget(root);
5360 mnt->mnt_mountpoint = mnt->mnt_root;
5361 mnt->mnt_parent = mnt;
5362 + mnt->mnt_tag = old->mnt_tag;
5364 if (flag & CL_SLAVE) {
5365 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5366 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
5367 seq_escape(m, s, " \t\n\\");
5370 +static int mnt_is_reachable(struct vfsmount *mnt)
5373 + struct dentry *point;
5376 + if (mnt == mnt->mnt_ns->root)
5379 + spin_lock(&vfsmount_lock);
5380 + root = current->fs->root;
5381 + point = root.dentry;
5383 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5384 + point = mnt->mnt_mountpoint;
5385 + mnt = mnt->mnt_parent;
5388 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5390 + spin_unlock(&vfsmount_lock);
5396 * Simple .show_options callback for filesystems which don't want to
5397 * implement more complex mount option showing.
5398 @@ -748,6 +779,8 @@ static int show_sb_opts(struct seq_file
5399 { MS_SYNCHRONOUS, ",sync" },
5400 { MS_DIRSYNC, ",dirsync" },
5401 { MS_MANDLOCK, ",mand" },
5402 + { MS_TAGGED, ",tag" },
5403 + { MS_NOTAGCHECK, ",notagcheck" },
5406 const struct proc_fs_info *fs_infop;
5407 @@ -795,10 +828,20 @@ static int show_vfsmnt(struct seq_file *
5409 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5411 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5413 - seq_path(m, &mnt_path, " \t\n\\");
5415 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5417 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5420 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5421 + mnt == current->fs->root.mnt) {
5422 + seq_puts(m, "/dev/root / ");
5424 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5426 + seq_path(m, &mnt_path, " \t\n\\");
5429 show_type(m, mnt->mnt_sb);
5430 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5431 err = show_sb_opts(m, mnt->mnt_sb);
5432 @@ -828,6 +871,11 @@ static int show_mountinfo(struct seq_fil
5433 struct path root = p->root;
5436 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5438 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5441 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5442 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5443 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5444 @@ -886,17 +934,27 @@ static int show_vfsstat(struct seq_file
5445 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5449 - if (mnt->mnt_devname) {
5450 - seq_puts(m, "device ");
5451 - mangle(m, mnt->mnt_devname);
5453 - seq_puts(m, "no device");
5454 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5456 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5460 - seq_puts(m, " mounted on ");
5461 - seq_path(m, &mnt_path, " \t\n\\");
5463 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5464 + mnt == current->fs->root.mnt) {
5465 + seq_puts(m, "device /dev/root mounted on / ");
5468 + if (mnt->mnt_devname) {
5469 + seq_puts(m, "device ");
5470 + mangle(m, mnt->mnt_devname);
5472 + seq_puts(m, "no device");
5475 + seq_puts(m, " mounted on ");
5476 + seq_path(m, &mnt_path, " \t\n\\");
5480 /* file system type */
5481 seq_puts(m, "with fstype ");
5482 @@ -1137,7 +1195,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5486 - if (!capable(CAP_SYS_ADMIN))
5487 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5490 retval = do_umount(path.mnt, flags);
5491 @@ -1163,7 +1221,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5493 static int mount_is_safe(struct path *path)
5495 - if (capable(CAP_SYS_ADMIN))
5496 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5500 @@ -1427,7 +1485,7 @@ static int do_change_type(struct path *p
5501 int type = flag & ~MS_REC;
5504 - if (!capable(CAP_SYS_ADMIN))
5505 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5508 if (path->dentry != path->mnt->mnt_root)
5509 @@ -1454,11 +1512,13 @@ static int do_change_type(struct path *p
5510 * do loopback mount.
5512 static int do_loopback(struct path *path, char *old_name,
5514 + tag_t tag, unsigned long flags, int mnt_flags)
5516 struct path old_path;
5517 struct vfsmount *mnt = NULL;
5518 int err = mount_is_safe(path);
5519 + int recurse = flags & MS_REC;
5523 if (!old_name || !*old_name)
5524 @@ -1492,6 +1552,7 @@ static int do_loopback(struct path *path
5525 spin_unlock(&vfsmount_lock);
5526 release_mounts(&umount_list);
5528 + mnt->mnt_flags = mnt_flags;
5531 up_write(&namespace_sem);
5532 @@ -1522,12 +1583,12 @@ static int change_mount_flags(struct vfs
5533 * on it - tough luck.
5535 static int do_remount(struct path *path, int flags, int mnt_flags,
5537 + void *data, xid_t xid)
5540 struct super_block *sb = path->mnt->mnt_sb;
5542 - if (!capable(CAP_SYS_ADMIN))
5543 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5546 if (!check_mnt(path->mnt))
5547 @@ -1569,7 +1630,7 @@ static int do_move_mount(struct path *pa
5548 struct path old_path, parent_path;
5551 - if (!capable(CAP_SYS_ADMIN))
5552 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5554 if (!old_name || !*old_name)
5556 @@ -1651,7 +1712,7 @@ static int do_new_mount(struct path *pat
5559 /* we need capabilities... */
5560 - if (!capable(CAP_SYS_ADMIN))
5561 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5565 @@ -1915,6 +1976,7 @@ long do_mount(char *dev_name, char *dir_
5572 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5573 @@ -1932,6 +1994,12 @@ long do_mount(char *dev_name, char *dir_
5574 if (!(flags & MS_NOATIME))
5575 mnt_flags |= MNT_RELATIME;
5577 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5578 + /* FIXME: bind and re-mounts get the tag flag? */
5579 + if (flags & (MS_BIND|MS_REMOUNT))
5580 + flags |= MS_TAGID;
5583 /* Separate the per-mountpoint flags */
5584 if (flags & MS_NOSUID)
5585 mnt_flags |= MNT_NOSUID;
5586 @@ -1948,6 +2016,8 @@ long do_mount(char *dev_name, char *dir_
5587 if (flags & MS_RDONLY)
5588 mnt_flags |= MNT_READONLY;
5590 + if (!capable(CAP_SYS_ADMIN))
5591 + mnt_flags |= MNT_NODEV;
5592 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5593 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5595 @@ -1964,9 +2034,9 @@ long do_mount(char *dev_name, char *dir_
5597 if (flags & MS_REMOUNT)
5598 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5601 else if (flags & MS_BIND)
5602 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5603 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5604 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5605 retval = do_change_type(&path, flags);
5606 else if (flags & MS_MOVE)
5607 @@ -2045,6 +2115,7 @@ static struct mnt_namespace *dup_mnt_ns(
5608 q = next_mnt(q, new_ns->root);
5610 up_write(&namespace_sem);
5611 + atomic_inc(&vs_global_mnt_ns);
5615 @@ -2189,9 +2260,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5616 down_write(&namespace_sem);
5617 mutex_lock(&old.dentry->d_inode->i_mutex);
5619 - if (IS_MNT_SHARED(old.mnt) ||
5620 + if ((IS_MNT_SHARED(old.mnt) ||
5621 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5622 - IS_MNT_SHARED(root.mnt->mnt_parent))
5623 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5624 + !vx_flags(VXF_STATE_SETUP, 0))
5626 if (!check_mnt(root.mnt))
5628 @@ -2327,6 +2399,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5629 spin_unlock(&vfsmount_lock);
5630 up_write(&namespace_sem);
5631 release_mounts(&umount_list);
5632 + atomic_dec(&vs_global_mnt_ns);
5635 EXPORT_SYMBOL(put_mnt_ns);
5636 diff -NurpP --minimal linux-2.6.32.56/fs/nfs/client.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/client.c
5637 --- linux-2.6.32.56/fs/nfs/client.c 2012-02-09 10:22:30.000000000 +0100
5638 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/client.c 2011-06-10 13:03:02.000000000 +0200
5639 @@ -738,6 +738,9 @@ static int nfs_init_server_rpcclient(str
5640 if (server->flags & NFS_MOUNT_SOFT)
5641 server->client->cl_softrtry = 1;
5643 + server->client->cl_tag = 0;
5644 + if (server->flags & NFS_MOUNT_TAGGED)
5645 + server->client->cl_tag = 1;
5649 @@ -909,6 +912,10 @@ static void nfs_server_set_fsinfo(struct
5650 server->acdirmin = server->acdirmax = 0;
5653 + /* FIXME: needs fsinfo
5654 + if (server->flags & NFS_MOUNT_TAGGED)
5655 + sb->s_flags |= MS_TAGGED; */
5657 server->maxfilesize = fsinfo->maxfilesize;
5659 /* We're airborne Set socket buffersize */
5660 diff -NurpP --minimal linux-2.6.32.56/fs/nfs/dir.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/dir.c
5661 --- linux-2.6.32.56/fs/nfs/dir.c 2012-02-09 10:22:30.000000000 +0100
5662 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/dir.c 2011-06-10 13:03:02.000000000 +0200
5664 #include <linux/namei.h>
5665 #include <linux/mount.h>
5666 #include <linux/sched.h>
5667 +#include <linux/vs_tag.h>
5669 #include "nfs4_fs.h"
5670 #include "delegation.h"
5671 @@ -951,6 +952,7 @@ static struct dentry *nfs_lookup(struct
5673 goto out_unblock_sillyrename;
5675 + dx_propagate_tag(nd, inode);
5677 res = d_materialise_unique(dentry, inode);
5679 diff -NurpP --minimal linux-2.6.32.56/fs/nfs/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/inode.c
5680 --- linux-2.6.32.56/fs/nfs/inode.c 2012-02-09 10:22:30.000000000 +0100
5681 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/inode.c 2011-09-30 02:12:21.000000000 +0200
5683 #include <linux/vfs.h>
5684 #include <linux/inet.h>
5685 #include <linux/nfs_xdr.h>
5686 +#include <linux/vs_tag.h>
5688 #include <asm/system.h>
5689 #include <asm/uaccess.h>
5690 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5691 if (inode->i_state & I_NEW) {
5692 struct nfs_inode *nfsi = NFS_I(inode);
5693 unsigned long now = jiffies;
5697 /* We set i_ino for the few things that still rely on it,
5698 * such as stat(2) */
5699 @@ -327,8 +330,8 @@ nfs_fhget(struct super_block *sb, struct
5700 nfsi->change_attr = 0;
5703 - inode->i_uid = -2;
5704 - inode->i_gid = -2;
5707 inode->i_blocks = 0;
5708 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5710 @@ -365,17 +368,25 @@ nfs_fhget(struct super_block *sb, struct
5711 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5712 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5713 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5714 - inode->i_uid = fattr->uid;
5715 - else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5716 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5717 - | NFS_INO_INVALID_ACCESS
5718 - | NFS_INO_INVALID_ACL;
5721 + uid = TAGINO_UID(DX_TAG(inode),
5722 + inode->i_uid, inode->i_tag);
5723 + if (nfs_server_capable(inode, NFS_CAP_OWNER))
5724 + nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5725 + | NFS_INO_INVALID_ACCESS
5726 + | NFS_INO_INVALID_ACL;
5728 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5729 - inode->i_gid = fattr->gid;
5730 - else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5731 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5732 - | NFS_INO_INVALID_ACCESS
5733 - | NFS_INO_INVALID_ACL;
5736 + gid = TAGINO_GID(DX_TAG(inode),
5737 + inode->i_gid, inode->i_tag);
5738 + if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5739 + nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5740 + | NFS_INO_INVALID_ACCESS
5741 + | NFS_INO_INVALID_ACL;
5743 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5744 inode->i_blocks = fattr->du.nfs2.blocks;
5745 if (fattr->valid & NFS_ATTR_FATTR_SPACE_USED) {
5746 @@ -384,6 +395,11 @@ nfs_fhget(struct super_block *sb, struct
5748 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5750 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5751 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5752 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5753 + /* maybe fattr->xid someday */
5755 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5756 nfsi->attrtimeo_timestamp = now;
5757 nfsi->access_cache = RB_ROOT;
5758 @@ -393,11 +409,11 @@ nfs_fhget(struct super_block *sb, struct
5759 unlock_new_inode(inode);
5761 nfs_refresh_inode(inode, fattr);
5763 dprintk("NFS: nfs_fhget(%s/%Ld ct=%d)\n",
5765 (long long)NFS_FILEID(inode),
5766 atomic_read(&inode->i_count));
5771 @@ -496,6 +512,8 @@ void nfs_setattr_update_inode(struct ino
5772 inode->i_uid = attr->ia_uid;
5773 if ((attr->ia_valid & ATTR_GID) != 0)
5774 inode->i_gid = attr->ia_gid;
5775 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5776 + inode->i_tag = attr->ia_tag;
5777 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5778 spin_unlock(&inode->i_lock);
5780 @@ -914,6 +932,9 @@ static int nfs_check_inode_attributes(st
5781 struct nfs_inode *nfsi = NFS_I(inode);
5782 loff_t cur_size, new_isize;
5783 unsigned long invalid = 0;
5789 /* Has the inode gone and changed behind our back? */
5790 @@ -937,13 +958,18 @@ static int nfs_check_inode_attributes(st
5791 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5794 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5795 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5796 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5798 /* Have any file permissions changed? */
5799 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5800 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5801 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5802 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5803 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5804 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5805 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5806 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5807 + /* maybe check for tag too? */
5809 /* Has the link count changed? */
5810 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5811 @@ -1158,6 +1184,9 @@ static int nfs_update_inode(struct inode
5812 unsigned long invalid = 0;
5813 unsigned long now = jiffies;
5814 unsigned long save_cache_validity;
5819 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5820 __func__, inode->i_sb->s_id, inode->i_ino,
5821 @@ -1260,6 +1289,9 @@ static int nfs_update_inode(struct inode
5822 | NFS_INO_REVAL_PAGECACHE
5823 | NFS_INO_REVAL_FORCED);
5825 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5826 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5827 + tag = inode->i_tag;
5829 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5830 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5831 @@ -1279,9 +1311,9 @@ static int nfs_update_inode(struct inode
5832 | NFS_INO_REVAL_FORCED);
5834 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5835 - if (inode->i_uid != fattr->uid) {
5836 + if (uid != fattr->uid) {
5837 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5838 - inode->i_uid = fattr->uid;
5841 } else if (server->caps & NFS_CAP_OWNER)
5842 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5843 @@ -1290,9 +1322,9 @@ static int nfs_update_inode(struct inode
5844 | NFS_INO_REVAL_FORCED);
5846 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5847 - if (inode->i_gid != fattr->gid) {
5848 + if (gid != fattr->gid) {
5849 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5850 - inode->i_gid = fattr->gid;
5853 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5854 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5855 @@ -1300,6 +1332,10 @@ static int nfs_update_inode(struct inode
5856 | NFS_INO_INVALID_ACL
5857 | NFS_INO_REVAL_FORCED);
5859 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5860 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5861 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5863 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5864 if (inode->i_nlink != fattr->nlink) {
5865 invalid |= NFS_INO_INVALID_ATTR;
5866 diff -NurpP --minimal linux-2.6.32.56/fs/nfs/nfs3xdr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/nfs3xdr.c
5867 --- linux-2.6.32.56/fs/nfs/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
5868 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/nfs3xdr.c 2011-06-10 13:03:02.000000000 +0200
5870 #include <linux/nfs3.h>
5871 #include <linux/nfs_fs.h>
5872 #include <linux/nfsacl.h>
5873 +#include <linux/vs_tag.h>
5874 #include "internal.h"
5876 #define NFSDBG_FACILITY NFSDBG_XDR
5877 @@ -176,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5880 static inline __be32 *
5881 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5882 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5884 if (attr->ia_valid & ATTR_MODE) {
5886 @@ -184,15 +185,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5890 - if (attr->ia_valid & ATTR_UID) {
5891 + if (attr->ia_valid & ATTR_UID ||
5892 + (tag && (attr->ia_valid & ATTR_TAG))) {
5894 - *p++ = htonl(attr->ia_uid);
5895 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5899 - if (attr->ia_valid & ATTR_GID) {
5900 + if (attr->ia_valid & ATTR_GID ||
5901 + (tag && (attr->ia_valid & ATTR_TAG))) {
5903 - *p++ = htonl(attr->ia_gid);
5904 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5908 @@ -279,7 +282,8 @@ static int
5909 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5911 p = xdr_encode_fhandle(p, args->fh);
5912 - p = xdr_encode_sattr(p, args->sattr);
5913 + p = xdr_encode_sattr(p, args->sattr,
5914 + req->rq_task->tk_client->cl_tag);
5915 *p++ = htonl(args->guard);
5917 p = xdr_encode_time3(p, &args->guardtime);
5918 @@ -384,7 +388,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5919 *p++ = args->verifier[0];
5920 *p++ = args->verifier[1];
5922 - p = xdr_encode_sattr(p, args->sattr);
5923 + p = xdr_encode_sattr(p, args->sattr,
5924 + req->rq_task->tk_client->cl_tag);
5926 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5928 @@ -398,7 +403,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5930 p = xdr_encode_fhandle(p, args->fh);
5931 p = xdr_encode_array(p, args->name, args->len);
5932 - p = xdr_encode_sattr(p, args->sattr);
5933 + p = xdr_encode_sattr(p, args->sattr,
5934 + req->rq_task->tk_client->cl_tag);
5935 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5938 @@ -411,7 +417,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5940 p = xdr_encode_fhandle(p, args->fromfh);
5941 p = xdr_encode_array(p, args->fromname, args->fromlen);
5942 - p = xdr_encode_sattr(p, args->sattr);
5943 + p = xdr_encode_sattr(p, args->sattr,
5944 + req->rq_task->tk_client->cl_tag);
5945 *p++ = htonl(args->pathlen);
5946 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5948 @@ -429,7 +436,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5949 p = xdr_encode_fhandle(p, args->fh);
5950 p = xdr_encode_array(p, args->name, args->len);
5951 *p++ = htonl(args->type);
5952 - p = xdr_encode_sattr(p, args->sattr);
5953 + p = xdr_encode_sattr(p, args->sattr,
5954 + req->rq_task->tk_client->cl_tag);
5955 if (args->type == NF3CHR || args->type == NF3BLK) {
5956 *p++ = htonl(MAJOR(args->rdev));
5957 *p++ = htonl(MINOR(args->rdev));
5958 diff -NurpP --minimal linux-2.6.32.56/fs/nfs/nfsroot.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/nfsroot.c
5959 --- linux-2.6.32.56/fs/nfs/nfsroot.c 2009-09-10 15:26:23.000000000 +0200
5960 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/nfsroot.c 2011-06-10 13:03:02.000000000 +0200
5961 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
5963 /* Options that take integer arguments */
5964 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
5965 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
5966 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
5967 /* Options that take no arguments */
5968 Opt_soft, Opt_hard, Opt_intr,
5969 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
5970 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
5971 - Opt_acl, Opt_noacl,
5972 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
5976 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
5979 {Opt_noacl, "noacl"},
5981 + {Opt_notag, "notag"},
5982 + {Opt_tagid, "tagid=%u"},
5986 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
5988 nfs_data.flags |= NFS_MOUNT_NOACL;
5990 +#ifndef CONFIG_TAGGING_NONE
5992 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5995 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
5998 +#ifdef CONFIG_PROPAGATE
6001 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6005 printk(KERN_WARNING "Root-NFS: unknown "
6007 diff -NurpP --minimal linux-2.6.32.56/fs/nfs/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/super.c
6008 --- linux-2.6.32.56/fs/nfs/super.c 2012-02-09 10:22:30.000000000 +0100
6009 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfs/super.c 2011-06-10 13:03:02.000000000 +0200
6011 #include <linux/nfs_xdr.h>
6012 #include <linux/magic.h>
6013 #include <linux/parser.h>
6014 +#include <linux/vs_tag.h>
6016 #include <asm/system.h>
6017 #include <asm/uaccess.h>
6018 @@ -570,6 +571,7 @@ static void nfs_show_mount_options(struc
6019 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6020 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6021 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6022 + { NFS_MOUNT_TAGGED, ",tag", "" },
6025 const struct proc_nfs_info *nfs_infop;
6026 diff -NurpP --minimal linux-2.6.32.56/fs/nfsd/auth.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/auth.c
6027 --- linux-2.6.32.56/fs/nfsd/auth.c 2009-12-03 20:02:52.000000000 +0100
6028 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/auth.c 2011-06-10 13:03:02.000000000 +0200
6030 #include <linux/sunrpc/svcauth.h>
6031 #include <linux/nfsd/nfsd.h>
6032 #include <linux/nfsd/export.h>
6033 +#include <linux/vs_tag.h>
6036 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6037 @@ -44,6 +45,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6039 new->fsuid = rqstp->rq_cred.cr_uid;
6040 new->fsgid = rqstp->rq_cred.cr_gid;
6041 + /* FIXME: this desperately needs a tag :)
6042 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6045 rqgi = rqstp->rq_cred.cr_group_info;
6047 diff -NurpP --minimal linux-2.6.32.56/fs/nfsd/nfs3xdr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/nfs3xdr.c
6048 --- linux-2.6.32.56/fs/nfsd/nfs3xdr.c 2012-02-09 10:22:30.000000000 +0100
6049 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/nfs3xdr.c 2011-06-10 13:03:02.000000000 +0200
6051 #include <linux/sunrpc/svc.h>
6052 #include <linux/nfsd/nfsd.h>
6053 #include <linux/nfsd/xdr3.h>
6054 +#include <linux/vs_tag.h>
6057 #define NFSDDBG_FACILITY NFSDDBG_XDR
6058 @@ -108,6 +109,8 @@ static __be32 *
6059 decode_sattr3(__be32 *p, struct iattr *iap)
6067 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6070 iap->ia_valid |= ATTR_UID;
6071 - iap->ia_uid = ntohl(*p++);
6072 + uid = ntohl(*p++);
6075 iap->ia_valid |= ATTR_GID;
6076 - iap->ia_gid = ntohl(*p++);
6077 + gid = ntohl(*p++);
6079 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6080 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6081 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6085 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6086 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6087 *p++ = htonl((u32) stat->mode);
6088 *p++ = htonl((u32) stat->nlink);
6089 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6090 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6091 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6092 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6093 + stat->uid, stat->tag)));
6094 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6095 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6096 + stat->gid, stat->tag)));
6097 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6098 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6100 diff -NurpP --minimal linux-2.6.32.56/fs/nfsd/nfs4xdr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/nfs4xdr.c
6101 --- linux-2.6.32.56/fs/nfsd/nfs4xdr.c 2012-02-09 10:22:30.000000000 +0100
6102 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/nfs4xdr.c 2011-06-10 13:03:02.000000000 +0200
6104 #include <linux/nfs4_acl.h>
6105 #include <linux/sunrpc/gss_api.h>
6106 #include <linux/sunrpc/svcauth_gss.h>
6107 +#include <linux/vs_tag.h>
6109 #define NFSDDBG_FACILITY NFSDDBG_XDR
6111 @@ -2047,14 +2048,18 @@ out_acl:
6112 WRITE32(stat.nlink);
6114 if (bmval1 & FATTR4_WORD1_OWNER) {
6115 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6116 + status = nfsd4_encode_user(rqstp,
6117 + TAGINO_UID(DX_TAG(dentry->d_inode),
6118 + stat.uid, stat.tag), &p, &buflen);
6119 if (status == nfserr_resource)
6124 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6125 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6126 + status = nfsd4_encode_group(rqstp,
6127 + TAGINO_GID(DX_TAG(dentry->d_inode),
6128 + stat.gid, stat.tag), &p, &buflen);
6129 if (status == nfserr_resource)
6132 diff -NurpP --minimal linux-2.6.32.56/fs/nfsd/nfsxdr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/nfsxdr.c
6133 --- linux-2.6.32.56/fs/nfsd/nfsxdr.c 2008-12-25 00:26:37.000000000 +0100
6134 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/nfsd/nfsxdr.c 2011-06-10 13:03:02.000000000 +0200
6136 #include <linux/nfsd/nfsd.h>
6137 #include <linux/nfsd/xdr.h>
6138 #include <linux/mm.h>
6139 +#include <linux/vs_tag.h>
6142 #define NFSDDBG_FACILITY NFSDDBG_XDR
6143 @@ -98,6 +99,8 @@ static __be32 *
6144 decode_sattr(__be32 *p, struct iattr *iap)
6152 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6154 if ((tmp = ntohl(*p++)) != (u32)-1) {
6155 iap->ia_valid |= ATTR_UID;
6156 - iap->ia_uid = tmp;
6159 if ((tmp = ntohl(*p++)) != (u32)-1) {
6160 iap->ia_valid |= ATTR_GID;
6161 - iap->ia_gid = tmp;
6164 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6165 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6166 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6167 if ((tmp = ntohl(*p++)) != (u32)-1) {
6168 iap->ia_valid |= ATTR_SIZE;
6170 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6171 *p++ = htonl(nfs_ftypes[type >> 12]);
6172 *p++ = htonl((u32) stat->mode);
6173 *p++ = htonl((u32) stat->nlink);
6174 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6175 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6176 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6177 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6178 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6179 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6181 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6182 *p++ = htonl(NFS_MAXPATHLEN);
6183 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/dlm/dlmfs.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/dlm/dlmfs.c
6184 --- linux-2.6.32.56/fs/ocfs2/dlm/dlmfs.c 2012-02-09 10:22:30.000000000 +0100
6185 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/dlm/dlmfs.c 2011-06-10 13:03:02.000000000 +0200
6187 #include <linux/init.h>
6188 #include <linux/string.h>
6189 #include <linux/backing-dev.h>
6190 +#include <linux/vs_tag.h>
6192 #include <asm/uaccess.h>
6194 @@ -342,6 +343,7 @@ static struct inode *dlmfs_get_root_inod
6195 inode->i_mode = mode;
6196 inode->i_uid = current_fsuid();
6197 inode->i_gid = current_fsgid();
6198 + inode->i_tag = dx_current_fstag(sb);
6199 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6200 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6202 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6203 inode->i_mode = mode;
6204 inode->i_uid = current_fsuid();
6205 inode->i_gid = current_fsgid();
6206 + inode->i_tag = dx_current_fstag(sb);
6207 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6208 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6210 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/dlmglue.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/dlmglue.c
6211 --- linux-2.6.32.56/fs/ocfs2/dlmglue.c 2009-12-03 20:02:53.000000000 +0100
6212 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/dlmglue.c 2011-06-10 13:03:02.000000000 +0200
6213 @@ -1991,6 +1991,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6214 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6215 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6216 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6217 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6218 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6219 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6220 lvb->lvb_iatime_packed =
6221 @@ -2045,6 +2046,7 @@ static void ocfs2_refresh_inode_from_lvb
6223 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6224 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6225 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6226 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6227 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6228 ocfs2_unpack_timespec(&inode->i_atime,
6229 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/dlmglue.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/dlmglue.h
6230 --- linux-2.6.32.56/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
6231 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/dlmglue.h 2011-06-10 13:03:02.000000000 +0200
6232 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6235 __be32 lvb_igeneration;
6236 - __be32 lvb_reserved2;
6238 + __be16 lvb_reserved2;
6241 #define OCFS2_QINFO_LVB_VERSION 1
6242 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/file.c
6243 --- linux-2.6.32.56/fs/ocfs2/file.c 2009-12-03 20:02:53.000000000 +0100
6244 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/file.c 2011-06-10 13:03:02.000000000 +0200
6245 @@ -960,13 +960,15 @@ int ocfs2_setattr(struct dentry *dentry,
6246 mlog(0, "uid change: %d\n", attr->ia_uid);
6247 if (attr->ia_valid & ATTR_GID)
6248 mlog(0, "gid change: %d\n", attr->ia_gid);
6249 + if (attr->ia_valid & ATTR_TAG)
6250 + mlog(0, "tag change: %d\n", attr->ia_tag);
6251 if (attr->ia_valid & ATTR_SIZE)
6252 mlog(0, "size change...\n");
6253 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6254 mlog(0, "time change...\n");
6256 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6257 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6258 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6259 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6260 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6262 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/inode.c
6263 --- linux-2.6.32.56/fs/ocfs2/inode.c 2012-02-09 10:22:30.000000000 +0100
6264 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/inode.c 2011-06-10 13:03:02.000000000 +0200
6266 #include <linux/highmem.h>
6267 #include <linux/pagemap.h>
6268 #include <linux/quotaops.h>
6269 +#include <linux/vs_tag.h>
6271 #include <asm/byteorder.h>
6273 @@ -79,11 +80,13 @@ void ocfs2_set_inode_flags(struct inode
6275 unsigned int flags = OCFS2_I(inode)->ip_attr;
6277 - inode->i_flags &= ~(S_IMMUTABLE |
6278 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6279 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6281 if (flags & OCFS2_IMMUTABLE_FL)
6282 inode->i_flags |= S_IMMUTABLE;
6283 + if (flags & OCFS2_IXUNLINK_FL)
6284 + inode->i_flags |= S_IXUNLINK;
6286 if (flags & OCFS2_SYNC_FL)
6287 inode->i_flags |= S_SYNC;
6288 @@ -93,25 +96,44 @@ void ocfs2_set_inode_flags(struct inode
6289 inode->i_flags |= S_NOATIME;
6290 if (flags & OCFS2_DIRSYNC_FL)
6291 inode->i_flags |= S_DIRSYNC;
6293 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6295 + if (flags & OCFS2_BARRIER_FL)
6296 + inode->i_vflags |= V_BARRIER;
6297 + if (flags & OCFS2_COW_FL)
6298 + inode->i_vflags |= V_COW;
6301 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6302 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6304 unsigned int flags = oi->vfs_inode.i_flags;
6305 + unsigned int vflags = oi->vfs_inode.i_vflags;
6307 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6308 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6309 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6310 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6312 + if (flags & S_IMMUTABLE)
6313 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6314 + if (flags & S_IXUNLINK)
6315 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6317 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6318 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6320 oi->ip_attr |= OCFS2_SYNC_FL;
6321 if (flags & S_APPEND)
6322 oi->ip_attr |= OCFS2_APPEND_FL;
6323 - if (flags & S_IMMUTABLE)
6324 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6325 if (flags & S_NOATIME)
6326 oi->ip_attr |= OCFS2_NOATIME_FL;
6327 if (flags & S_DIRSYNC)
6328 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6330 + if (vflags & V_BARRIER)
6331 + oi->ip_attr |= OCFS2_BARRIER_FL;
6332 + if (vflags & V_COW)
6333 + oi->ip_attr |= OCFS2_COW_FL;
6336 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6337 @@ -246,6 +268,8 @@ void ocfs2_populate_inode(struct inode *
6338 struct super_block *sb;
6339 struct ocfs2_super *osb;
6344 mlog_entry("(0x%p, size:%llu)\n", inode,
6345 (unsigned long long)le64_to_cpu(fe->i_size));
6346 @@ -277,8 +301,12 @@ void ocfs2_populate_inode(struct inode *
6347 inode->i_generation = le32_to_cpu(fe->i_generation);
6348 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6349 inode->i_mode = le16_to_cpu(fe->i_mode);
6350 - inode->i_uid = le32_to_cpu(fe->i_uid);
6351 - inode->i_gid = le32_to_cpu(fe->i_gid);
6352 + uid = le32_to_cpu(fe->i_uid);
6353 + gid = le32_to_cpu(fe->i_gid);
6354 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6355 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6356 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6357 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6359 /* Fast symlinks will have i_size but no allocated clusters. */
6360 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6361 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/inode.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/inode.h
6362 --- linux-2.6.32.56/fs/ocfs2/inode.h 2009-12-03 20:02:53.000000000 +0100
6363 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/inode.h 2011-06-10 13:03:02.000000000 +0200
6364 @@ -150,6 +150,7 @@ struct buffer_head *ocfs2_bread(struct i
6366 void ocfs2_set_inode_flags(struct inode *inode);
6367 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6368 +int ocfs2_sync_flags(struct inode *inode, int, int);
6370 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6372 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/ioctl.c
6373 --- linux-2.6.32.56/fs/ocfs2/ioctl.c 2009-12-03 20:02:53.000000000 +0100
6374 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/ioctl.c 2011-06-10 13:03:02.000000000 +0200
6375 @@ -42,7 +42,41 @@ static int ocfs2_get_inode_attr(struct i
6379 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6380 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6382 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6383 + struct buffer_head *bh = NULL;
6384 + handle_t *handle = NULL;
6387 + status = ocfs2_inode_lock(inode, &bh, 1);
6389 + mlog_errno(status);
6392 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6393 + if (IS_ERR(handle)) {
6394 + status = PTR_ERR(handle);
6395 + mlog_errno(status);
6399 + inode->i_flags = flags;
6400 + inode->i_vflags = vflags;
6401 + ocfs2_get_inode_flags(OCFS2_I(inode));
6403 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6405 + mlog_errno(status);
6407 + ocfs2_commit_trans(osb, handle);
6409 + ocfs2_inode_unlock(inode, 1);
6414 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6417 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6418 @@ -67,6 +101,11 @@ static int ocfs2_set_inode_attr(struct i
6419 if (!S_ISDIR(inode->i_mode))
6420 flags &= ~OCFS2_DIRSYNC_FL;
6422 + if (IS_BARRIER(inode)) {
6423 + vxwprintk_task(1, "messing with the barrier.");
6427 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6428 if (IS_ERR(handle)) {
6429 status = PTR_ERR(handle);
6430 @@ -108,6 +147,7 @@ bail:
6435 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6437 struct inode *inode = filp->f_path.dentry->d_inode;
6438 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/namei.c
6439 --- linux-2.6.32.56/fs/ocfs2/namei.c 2009-12-03 20:02:53.000000000 +0100
6440 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/namei.c 2011-06-10 13:03:02.000000000 +0200
6442 #include <linux/slab.h>
6443 #include <linux/highmem.h>
6444 #include <linux/quotaops.h>
6445 +#include <linux/vs_tag.h>
6447 #define MLOG_MASK_PREFIX ML_NAMEI
6448 #include <cluster/masklog.h>
6449 @@ -481,6 +482,7 @@ static int ocfs2_mknod_locked(struct ocf
6457 @@ -524,8 +526,11 @@ static int ocfs2_mknod_locked(struct ocf
6458 fe->i_blkno = cpu_to_le64(fe_blkno);
6459 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6460 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6461 - fe->i_uid = cpu_to_le32(inode->i_uid);
6462 - fe->i_gid = cpu_to_le32(inode->i_gid);
6464 + tag = dx_current_fstag(osb->sb);
6465 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6466 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6467 + inode->i_tag = tag;
6468 fe->i_mode = cpu_to_le16(inode->i_mode);
6469 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6470 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6471 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/ocfs2.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/ocfs2.h
6472 --- linux-2.6.32.56/fs/ocfs2/ocfs2.h 2009-12-03 20:02:53.000000000 +0100
6473 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/ocfs2.h 2011-06-10 13:03:02.000000000 +0200
6474 @@ -248,6 +248,7 @@ enum ocfs2_mount_options
6475 OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
6476 OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
6477 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
6478 + OCFS2_MOUNT_TAGGED = 1 << 11, /* use tagging */
6481 #define OCFS2_OSB_SOFT_RO 0x0001
6482 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/ocfs2_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/ocfs2_fs.h
6483 --- linux-2.6.32.56/fs/ocfs2/ocfs2_fs.h 2009-12-03 20:02:53.000000000 +0100
6484 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/ocfs2_fs.h 2011-06-10 13:03:02.000000000 +0200
6485 @@ -231,18 +231,23 @@
6486 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
6488 /* Inode attributes, keep in sync with EXT2 */
6489 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6490 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6491 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6492 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6493 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6494 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6495 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6496 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6497 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6498 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6499 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6500 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6501 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6502 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6503 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6504 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6505 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6507 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6508 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6509 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6510 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6512 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6513 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6515 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6516 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6519 * Extent record flags (e_node.leaf.flags)
6520 diff -NurpP --minimal linux-2.6.32.56/fs/ocfs2/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/super.c
6521 --- linux-2.6.32.56/fs/ocfs2/super.c 2012-02-09 10:22:30.000000000 +0100
6522 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/ocfs2/super.c 2011-06-10 13:03:02.000000000 +0200
6523 @@ -173,6 +173,7 @@ enum {
6527 + Opt_tag, Opt_notag, Opt_tagid,
6531 @@ -199,6 +200,9 @@ static const match_table_t tokens = {
6532 {Opt_noacl, "noacl"},
6533 {Opt_usrquota, "usrquota"},
6534 {Opt_grpquota, "grpquota"},
6536 + {Opt_notag, "notag"},
6537 + {Opt_tagid, "tagid=%u"},
6541 @@ -605,6 +609,13 @@ static int ocfs2_remount(struct super_bl
6545 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6546 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6548 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6552 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6553 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6555 @@ -1152,6 +1163,9 @@ static int ocfs2_fill_super(struct super
6557 ocfs2_complete_mount_recovery(osb);
6559 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6560 + sb->s_flags |= MS_TAGGED;
6562 if (ocfs2_mount_local(osb))
6563 snprintf(nodestr, sizeof(nodestr), "local");
6565 @@ -1430,6 +1444,20 @@ static int ocfs2_parse_options(struct su
6566 printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
6569 +#ifndef CONFIG_TAGGING_NONE
6571 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6574 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6577 +#ifdef CONFIG_PROPAGATE
6580 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6585 "Unrecognized mount option \"%s\" "
6586 diff -NurpP --minimal linux-2.6.32.56/fs/open.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/open.c
6587 --- linux-2.6.32.56/fs/open.c 2009-12-03 20:02:53.000000000 +0100
6588 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/open.c 2011-06-10 13:03:02.000000000 +0200
6590 #include <linux/audit.h>
6591 #include <linux/falloc.h>
6592 #include <linux/fs_struct.h>
6593 +#include <linux/vs_base.h>
6594 +#include <linux/vs_limit.h>
6595 +#include <linux/vs_tag.h>
6596 +#include <linux/vs_cowbl.h>
6598 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6600 int retval = -ENODEV;
6603 + struct super_block *sb = dentry->d_sb;
6606 - if (dentry->d_sb->s_op->statfs) {
6607 + if (sb->s_op->statfs) {
6608 memset(buf, 0, sizeof(*buf));
6609 retval = security_sb_statfs(dentry);
6612 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6613 + retval = sb->s_op->statfs(dentry, buf);
6614 if (retval == 0 && buf->f_frsize == 0)
6615 buf->f_frsize = buf->f_bsize;
6617 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6618 + vx_vsi_statfs(sb, buf);
6622 @@ -640,6 +648,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6623 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6627 + error = cow_check_and_break(&path);
6629 + goto dput_and_out;
6630 inode = path.dentry->d_inode;
6632 error = mnt_want_write(path.mnt);
6633 @@ -673,11 +685,11 @@ static int chown_common(struct dentry *
6634 newattrs.ia_valid = ATTR_CTIME;
6635 if (user != (uid_t) -1) {
6636 newattrs.ia_valid |= ATTR_UID;
6637 - newattrs.ia_uid = user;
6638 + newattrs.ia_uid = dx_map_uid(user);
6640 if (group != (gid_t) -1) {
6641 newattrs.ia_valid |= ATTR_GID;
6642 - newattrs.ia_gid = group;
6643 + newattrs.ia_gid = dx_map_gid(group);
6645 if (!S_ISDIR(inode->i_mode))
6646 newattrs.ia_valid |=
6647 @@ -700,7 +712,11 @@ SYSCALL_DEFINE3(chown, const char __user
6648 error = mnt_want_write(path.mnt);
6651 - error = chown_common(path.dentry, user, group);
6652 +#ifdef CONFIG_VSERVER_COWBL
6653 + error = cow_check_and_break(&path);
6656 + error = chown_common(path.dentry, user, group);
6657 mnt_drop_write(path.mnt);
6660 @@ -725,7 +741,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6661 error = mnt_want_write(path.mnt);
6664 - error = chown_common(path.dentry, user, group);
6665 +#ifdef CONFIG_VSERVER_COWBL
6666 + error = cow_check_and_break(&path);
6669 + error = chown_common(path.dentry, user, group);
6670 mnt_drop_write(path.mnt);
6673 @@ -744,7 +764,11 @@ SYSCALL_DEFINE3(lchown, const char __use
6674 error = mnt_want_write(path.mnt);
6677 - error = chown_common(path.dentry, user, group);
6678 +#ifdef CONFIG_VSERVER_COWBL
6679 + error = cow_check_and_break(&path);
6682 + error = chown_common(path.dentry, user, group);
6683 mnt_drop_write(path.mnt);
6686 @@ -990,6 +1014,7 @@ static void __put_unused_fd(struct files
6687 __FD_CLR(fd, fdt->open_fds);
6688 if (fd < files->next_fd)
6689 files->next_fd = fd;
6690 + vx_openfd_dec(fd);
6693 void put_unused_fd(unsigned int fd)
6694 diff -NurpP --minimal linux-2.6.32.56/fs/proc/array.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/array.c
6695 --- linux-2.6.32.56/fs/proc/array.c 2012-02-09 10:22:30.000000000 +0100
6696 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/array.c 2011-06-10 18:44:08.000000000 +0200
6698 #include <linux/pid_namespace.h>
6699 #include <linux/ptrace.h>
6700 #include <linux/tracehook.h>
6701 +#include <linux/vs_context.h>
6702 +#include <linux/vs_network.h>
6704 #include <asm/pgtable.h>
6705 #include <asm/processor.h>
6706 @@ -166,6 +168,9 @@ static inline void task_state(struct seq
6708 ppid = pid_alive(p) ?
6709 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6710 + if (unlikely(vx_current_initpid(p->pid)))
6715 struct task_struct *tracer = tracehook_tracer_task(p);
6716 @@ -281,7 +286,7 @@ static inline void task_sig(struct seq_f
6719 static void render_cap_t(struct seq_file *m, const char *header,
6721 + struct vx_info *vxi, kernel_cap_t *a)
6725 @@ -306,10 +311,11 @@ static inline void task_cap(struct seq_f
6726 cap_bset = cred->cap_bset;
6729 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6730 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6731 - render_cap_t(m, "CapEff:\t", &cap_effective);
6732 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6733 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6734 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6735 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6736 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6737 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6740 static inline void task_context_switch_counts(struct seq_file *m,
6741 @@ -321,6 +327,43 @@ static inline void task_context_switch_c
6746 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6747 + struct pid *pid, struct task_struct *task)
6749 + seq_printf(m, "Proxy:\t%p(%c)\n"
6757 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6758 + atomic_read(&task->nsproxy->count),
6759 + task->nsproxy->uts_ns,
6760 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6761 + task->nsproxy->ipc_ns,
6762 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6763 + task->nsproxy->mnt_ns,
6764 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6765 + task->nsproxy->pid_ns,
6766 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6767 + task->nsproxy->net_ns,
6768 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6772 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6774 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6777 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6778 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6782 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6783 struct pid *pid, struct task_struct *task)
6785 @@ -336,6 +379,7 @@ int proc_pid_status(struct seq_file *m,
6788 cpuset_task_status_allowed(m, task);
6789 + task_vs_id(m, task);
6790 task_context_switch_counts(m, task);
6793 @@ -446,6 +490,17 @@ static int do_task_stat(struct seq_file
6794 /* convert nsec -> ticks */
6795 start_time = nsec_to_clock_t(start_time);
6797 + /* fixup start time for virt uptime */
6798 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6799 + unsigned long long bias =
6800 + current->vx_info->cvirt.bias_clock;
6802 + if (start_time > bias)
6803 + start_time -= bias;
6808 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6809 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6810 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6811 diff -NurpP --minimal linux-2.6.32.56/fs/proc/base.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/base.c
6812 --- linux-2.6.32.56/fs/proc/base.c 2012-02-09 10:22:30.000000000 +0100
6813 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/base.c 2011-11-17 12:18:26.000000000 +0100
6815 #include <linux/elf.h>
6816 #include <linux/pid_namespace.h>
6817 #include <linux/fs_struct.h>
6818 +#include <linux/vs_context.h>
6819 +#include <linux/vs_network.h>
6820 #include "internal.h"
6823 @@ -1075,12 +1077,17 @@ static ssize_t oom_adjust_write(struct f
6827 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6828 + if (oom_adjust < task->signal->oom_adj &&
6829 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6830 unlock_task_sighand(task, &flags);
6831 put_task_struct(task);
6835 + /* prevent guest processes from circumventing the oom killer */
6836 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6837 + oom_adjust = OOM_ADJUST_MIN;
6839 task->signal->oom_adj = oom_adjust;
6841 unlock_task_sighand(task, &flags);
6842 @@ -1120,7 +1127,7 @@ static ssize_t proc_loginuid_write(struc
6846 - if (!capable(CAP_AUDIT_CONTROL))
6847 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6850 if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
6851 @@ -1486,6 +1493,8 @@ static struct inode *proc_pid_make_inode
6852 inode->i_gid = cred->egid;
6855 + /* procfs is xid tagged */
6856 + inode->i_tag = (tag_t)vx_task_xid(task);
6857 security_task_to_inode(task, inode);
6860 @@ -2036,6 +2045,13 @@ static struct dentry *proc_pident_lookup
6864 + /* TODO: maybe we can come up with a generic approach? */
6865 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6866 + (dentry->d_name.len == 5) &&
6867 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6868 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6872 * Yes, it does not scale. And it should not. Don't add
6873 * new entries into /proc/<tgid>/ without very good reasons.
6874 @@ -2441,7 +2457,7 @@ out_iput:
6875 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6877 struct dentry *error;
6878 - struct task_struct *task = get_proc_task(dir);
6879 + struct task_struct *task = get_proc_task_real(dir);
6880 const struct pid_entry *p, *last;
6882 error = ERR_PTR(-ENOENT);
6883 @@ -2538,6 +2554,9 @@ static int proc_pid_personality(struct s
6884 static const struct file_operations proc_task_operations;
6885 static const struct inode_operations proc_task_inode_operations;
6887 +extern int proc_pid_vx_info(struct task_struct *, char *);
6888 +extern int proc_pid_nx_info(struct task_struct *, char *);
6890 static const struct pid_entry tgid_base_stuff[] = {
6891 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6892 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6893 @@ -2596,6 +2615,8 @@ static const struct pid_entry tgid_base_
6894 #ifdef CONFIG_CGROUPS
6895 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6897 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6898 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6899 INF("oom_score", S_IRUGO, proc_oom_score),
6900 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6901 #ifdef CONFIG_AUDITSYSCALL
6902 @@ -2611,6 +2632,7 @@ static const struct pid_entry tgid_base_
6903 #ifdef CONFIG_TASK_IO_ACCOUNTING
6904 INF("io", S_IRUSR, proc_tgid_io_accounting),
6906 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6909 static int proc_tgid_base_readdir(struct file * filp,
6910 @@ -2802,7 +2824,7 @@ retry:
6912 pid = find_ge_pid(iter.tgid, ns);
6914 - iter.tgid = pid_nr_ns(pid, ns);
6915 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6916 iter.task = pid_task(pid, PIDTYPE_PID);
6917 /* What we to know is if the pid we have find is the
6918 * pid of a thread_group_leader. Testing for task
6919 @@ -2832,7 +2854,7 @@ static int proc_pid_fill_cache(struct fi
6920 struct tgid_iter iter)
6922 char name[PROC_NUMBUF];
6923 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6924 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6925 return proc_fill_cache(filp, dirent, filldir, name, len,
6926 proc_pid_instantiate, iter.task, NULL);
6928 @@ -2849,7 +2871,7 @@ int proc_pid_readdir(struct file * filp,
6930 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6932 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6933 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6937 @@ -2866,6 +2888,8 @@ int proc_pid_readdir(struct file * filp,
6939 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6940 filp->f_pos = iter.tgid + TGID_OFFSET;
6941 + if (!vx_proc_task_visible(iter.task))
6943 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6944 put_task_struct(iter.task);
6946 @@ -3012,6 +3036,8 @@ static struct dentry *proc_task_lookup(s
6947 tid = name_to_int(dentry);
6950 + if (vx_current_initpid(tid))
6953 ns = dentry->d_sb->s_fs_info;
6955 diff -NurpP --minimal linux-2.6.32.56/fs/proc/generic.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/generic.c
6956 --- linux-2.6.32.56/fs/proc/generic.c 2009-06-11 17:13:07.000000000 +0200
6957 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/generic.c 2011-06-10 13:03:02.000000000 +0200
6959 #include <linux/bitops.h>
6960 #include <linux/spinlock.h>
6961 #include <linux/completion.h>
6962 +#include <linux/vserver/inode.h>
6963 #include <asm/uaccess.h>
6965 #include "internal.h"
6966 @@ -425,6 +426,8 @@ struct dentry *proc_lookup_de(struct pro
6967 for (de = de->subdir; de ; de = de->next) {
6968 if (de->namelen != dentry->d_name.len)
6970 + if (!vx_hide_check(0, de->vx_flags))
6972 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6975 @@ -433,6 +436,8 @@ struct dentry *proc_lookup_de(struct pro
6976 spin_unlock(&proc_subdir_lock);
6978 inode = proc_get_inode(dir->i_sb, ino, de);
6979 + /* generic proc entries belong to the host */
6984 @@ -510,6 +515,8 @@ int proc_readdir_de(struct proc_dir_entr
6986 /* filldir passes info to user space */
6988 + if (!vx_hide_check(0, de->vx_flags))
6990 spin_unlock(&proc_subdir_lock);
6991 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6992 de->low_ino, de->mode >> 12) < 0) {
6993 @@ -517,6 +524,7 @@ int proc_readdir_de(struct proc_dir_entr
6996 spin_lock(&proc_subdir_lock);
7001 @@ -631,6 +639,7 @@ static struct proc_dir_entry *__proc_cre
7003 atomic_set(&ent->count, 1);
7005 + ent->vx_flags = IATTR_PROC_DEFAULT;
7006 spin_lock_init(&ent->pde_unload_lock);
7007 ent->pde_unload_completion = NULL;
7008 INIT_LIST_HEAD(&ent->pde_openers);
7009 @@ -654,7 +663,8 @@ struct proc_dir_entry *proc_symlink(cons
7015 + ent->vx_flags = IATTR_PROC_SYMLINK;
7019 diff -NurpP --minimal linux-2.6.32.56/fs/proc/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/inode.c
7020 --- linux-2.6.32.56/fs/proc/inode.c 2009-06-11 17:13:07.000000000 +0200
7021 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/inode.c 2011-06-10 13:03:02.000000000 +0200
7022 @@ -459,6 +459,8 @@ struct inode *proc_get_inode(struct supe
7023 inode->i_uid = de->uid;
7024 inode->i_gid = de->gid;
7027 + PROC_I(inode)->vx_flags = de->vx_flags;
7029 inode->i_size = de->size;
7031 diff -NurpP --minimal linux-2.6.32.56/fs/proc/internal.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/internal.h
7032 --- linux-2.6.32.56/fs/proc/internal.h 2009-09-10 15:26:23.000000000 +0200
7033 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/internal.h 2011-06-10 13:03:02.000000000 +0200
7037 #include <linux/proc_fs.h>
7038 +#include <linux/vs_pid.h>
7040 extern struct proc_dir_entry proc_root;
7041 #ifdef CONFIG_PROC_SYSCTL
7042 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7043 struct pid *pid, struct task_struct *task);
7044 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7045 struct pid *pid, struct task_struct *task);
7046 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7047 + struct pid *pid, struct task_struct *task);
7049 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7051 extern const struct file_operations proc_maps_operations;
7052 @@ -70,11 +74,16 @@ static inline struct pid *proc_pid(struc
7053 return PROC_I(inode)->pid;
7056 -static inline struct task_struct *get_proc_task(struct inode *inode)
7057 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7059 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7062 +static inline struct task_struct *get_proc_task(struct inode *inode)
7064 + return vx_get_proc_task(inode, proc_pid(inode));
7067 static inline int proc_fd(struct inode *inode)
7069 return PROC_I(inode)->fd;
7070 diff -NurpP --minimal linux-2.6.32.56/fs/proc/loadavg.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/loadavg.c
7071 --- linux-2.6.32.56/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7072 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/loadavg.c 2011-06-10 13:03:02.000000000 +0200
7075 static int loadavg_proc_show(struct seq_file *m, void *v)
7077 + unsigned long running;
7078 + unsigned int threads;
7079 unsigned long avnrun[3];
7081 get_avenrun(avnrun, FIXED_1/200, 0);
7083 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7084 + struct vx_info *vxi = current_vx_info();
7086 + running = atomic_read(&vxi->cvirt.nr_running);
7087 + threads = atomic_read(&vxi->cvirt.nr_threads);
7089 + running = nr_running();
7090 + threads = nr_threads;
7093 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7094 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7095 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7096 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7097 - nr_running(), nr_threads,
7099 task_active_pid_ns(current)->last_pid);
7102 diff -NurpP --minimal linux-2.6.32.56/fs/proc/meminfo.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/meminfo.c
7103 --- linux-2.6.32.56/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7104 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/meminfo.c 2011-06-10 13:03:02.000000000 +0200
7105 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7106 allowed = ((totalram_pages - hugetlb_total_pages())
7107 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7109 - cached = global_page_state(NR_FILE_PAGES) -
7110 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7111 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7112 total_swapcache_pages - i.bufferram;
7115 diff -NurpP --minimal linux-2.6.32.56/fs/proc/root.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/root.c
7116 --- linux-2.6.32.56/fs/proc/root.c 2009-06-11 17:13:07.000000000 +0200
7117 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/root.c 2011-06-10 13:03:02.000000000 +0200
7119 #include <linux/bitops.h>
7120 #include <linux/mount.h>
7121 #include <linux/pid_namespace.h>
7122 +#include <linux/vserver/inode.h>
7124 #include "internal.h"
7126 +struct proc_dir_entry *proc_virtual;
7128 +extern void proc_vx_init(void);
7130 static int proc_test_super(struct super_block *sb, void *data)
7132 return sb->s_fs_info == data;
7133 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
7135 proc_mkdir("bus", NULL);
7140 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7141 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7142 .proc_iops = &proc_root_inode_operations,
7143 .proc_fops = &proc_root_operations,
7144 .parent = &proc_root,
7145 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7148 int pid_ns_prepare_proc(struct pid_namespace *ns)
7149 diff -NurpP --minimal linux-2.6.32.56/fs/proc/uptime.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/uptime.c
7150 --- linux-2.6.32.56/fs/proc/uptime.c 2012-02-09 10:22:30.000000000 +0100
7151 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/proc/uptime.c 2012-02-09 10:58:46.000000000 +0100
7153 #include <linux/seq_file.h>
7154 #include <linux/time.h>
7155 #include <linux/kernel_stat.h>
7156 +#include <linux/vserver/cvirt.h>
7157 #include <asm/cputime.h>
7159 static int uptime_proc_show(struct seq_file *m, void *v)
7160 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
7161 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
7162 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
7165 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7166 + vx_vsi_uptime(&uptime, &idle);
7168 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7169 (unsigned long) uptime.tv_sec,
7170 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7171 diff -NurpP --minimal linux-2.6.32.56/fs/quota/quota.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/quota/quota.c
7172 --- linux-2.6.32.56/fs/quota/quota.c 2009-09-10 15:26:24.000000000 +0200
7173 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/quota/quota.c 2011-06-10 13:03:02.000000000 +0200
7175 #include <linux/capability.h>
7176 #include <linux/quotaops.h>
7177 #include <linux/types.h>
7178 +#include <linux/vs_context.h>
7180 /* Check validity of generic quotactl commands */
7181 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd,
7182 @@ -83,11 +84,11 @@ static int generic_quotactl_valid(struct
7183 if (cmd == Q_GETQUOTA) {
7184 if (((type == USRQUOTA && current_euid() != id) ||
7185 (type == GRPQUOTA && !in_egroup_p(id))) &&
7186 - !capable(CAP_SYS_ADMIN))
7187 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7190 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7191 - if (!capable(CAP_SYS_ADMIN))
7192 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7196 @@ -135,10 +136,10 @@ static int xqm_quotactl_valid(struct sup
7197 if (cmd == Q_XGETQUOTA) {
7198 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7199 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7200 - !capable(CAP_SYS_ADMIN))
7201 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7203 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7204 - if (!capable(CAP_SYS_ADMIN))
7205 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7209 @@ -351,6 +352,46 @@ static int do_quotactl(struct super_bloc
7213 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7215 +#include <linux/vroot.h>
7216 +#include <linux/major.h>
7217 +#include <linux/module.h>
7218 +#include <linux/kallsyms.h>
7219 +#include <linux/vserver/debug.h>
7221 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7223 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7225 +int register_vroot_grb(vroot_grb_func *func) {
7228 + spin_lock(&vroot_grb_lock);
7229 + if (!vroot_get_real_bdev) {
7230 + vroot_get_real_bdev = func;
7233 + spin_unlock(&vroot_grb_lock);
7236 +EXPORT_SYMBOL(register_vroot_grb);
7238 +int unregister_vroot_grb(vroot_grb_func *func) {
7239 + int ret = -EINVAL;
7241 + spin_lock(&vroot_grb_lock);
7242 + if (vroot_get_real_bdev) {
7243 + vroot_get_real_bdev = NULL;
7246 + spin_unlock(&vroot_grb_lock);
7249 +EXPORT_SYMBOL(unregister_vroot_grb);
7254 * look up a superblock on which quota ops will be performed
7255 * - use the name of a block device to find the superblock thereon
7256 @@ -368,6 +409,22 @@ static struct super_block *quotactl_bloc
7259 return ERR_CAST(bdev);
7260 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7261 + if (bdev && bdev->bd_inode &&
7262 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7263 + struct block_device *bdnew = (void *)-EINVAL;
7265 + if (vroot_get_real_bdev)
7266 + bdnew = vroot_get_real_bdev(bdev);
7268 + vxdprintk(VXD_CBIT(misc, 0),
7269 + "vroot_get_real_bdev not set");
7271 + if (IS_ERR(bdnew))
7272 + return ERR_PTR(PTR_ERR(bdnew));
7276 sb = get_super(bdev);
7279 diff -NurpP --minimal linux-2.6.32.56/fs/reiserfs/file.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/file.c
7280 --- linux-2.6.32.56/fs/reiserfs/file.c 2009-06-11 17:13:08.000000000 +0200
7281 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/file.c 2011-06-10 13:03:02.000000000 +0200
7282 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7283 .listxattr = reiserfs_listxattr,
7284 .removexattr = reiserfs_removexattr,
7285 .permission = reiserfs_permission,
7286 + .sync_flags = reiserfs_sync_flags,
7288 diff -NurpP --minimal linux-2.6.32.56/fs/reiserfs/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/inode.c
7289 --- linux-2.6.32.56/fs/reiserfs/inode.c 2012-02-09 10:22:30.000000000 +0100
7290 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/inode.c 2011-06-10 13:03:02.000000000 +0200
7292 #include <linux/writeback.h>
7293 #include <linux/quotaops.h>
7294 #include <linux/swap.h>
7295 +#include <linux/vs_tag.h>
7297 int reiserfs_commit_write(struct file *f, struct page *page,
7298 unsigned from, unsigned to);
7299 @@ -1117,6 +1118,8 @@ static void init_inode(struct inode *ino
7300 struct buffer_head *bh;
7301 struct item_head *ih;
7305 //int version = ITEM_VERSION_1;
7307 bh = PATH_PLAST_BUFFER(path);
7308 @@ -1138,12 +1141,13 @@ static void init_inode(struct inode *ino
7309 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7310 unsigned long blocks;
7312 + uid = sd_v1_uid(sd);
7313 + gid = sd_v1_gid(sd);
7315 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7316 set_inode_sd_version(inode, STAT_DATA_V1);
7317 inode->i_mode = sd_v1_mode(sd);
7318 inode->i_nlink = sd_v1_nlink(sd);
7319 - inode->i_uid = sd_v1_uid(sd);
7320 - inode->i_gid = sd_v1_gid(sd);
7321 inode->i_size = sd_v1_size(sd);
7322 inode->i_atime.tv_sec = sd_v1_atime(sd);
7323 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7324 @@ -1185,11 +1189,12 @@ static void init_inode(struct inode *ino
7325 // (directories and symlinks)
7326 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7328 + uid = sd_v2_uid(sd);
7329 + gid = sd_v2_gid(sd);
7331 inode->i_mode = sd_v2_mode(sd);
7332 inode->i_nlink = sd_v2_nlink(sd);
7333 - inode->i_uid = sd_v2_uid(sd);
7334 inode->i_size = sd_v2_size(sd);
7335 - inode->i_gid = sd_v2_gid(sd);
7336 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7337 inode->i_atime.tv_sec = sd_v2_atime(sd);
7338 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7339 @@ -1219,6 +1224,10 @@ static void init_inode(struct inode *ino
7340 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7343 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7344 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7345 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7348 if (S_ISREG(inode->i_mode)) {
7349 inode->i_op = &reiserfs_file_inode_operations;
7350 @@ -1241,13 +1250,15 @@ static void init_inode(struct inode *ino
7351 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7353 struct stat_data *sd_v2 = (struct stat_data *)sd;
7354 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7355 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7358 + set_sd_v2_uid(sd_v2, uid);
7359 + set_sd_v2_gid(sd_v2, gid);
7360 set_sd_v2_mode(sd_v2, inode->i_mode);
7361 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7362 - set_sd_v2_uid(sd_v2, inode->i_uid);
7363 set_sd_v2_size(sd_v2, size);
7364 - set_sd_v2_gid(sd_v2, inode->i_gid);
7365 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7366 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7367 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7368 @@ -2839,14 +2850,19 @@ int reiserfs_commit_write(struct file *f
7369 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7371 if (reiserfs_attrs(inode->i_sb)) {
7372 - if (sd_attrs & REISERFS_SYNC_FL)
7373 - inode->i_flags |= S_SYNC;
7375 - inode->i_flags &= ~S_SYNC;
7376 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7377 inode->i_flags |= S_IMMUTABLE;
7379 inode->i_flags &= ~S_IMMUTABLE;
7380 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7381 + inode->i_flags |= S_IXUNLINK;
7383 + inode->i_flags &= ~S_IXUNLINK;
7385 + if (sd_attrs & REISERFS_SYNC_FL)
7386 + inode->i_flags |= S_SYNC;
7388 + inode->i_flags &= ~S_SYNC;
7389 if (sd_attrs & REISERFS_APPEND_FL)
7390 inode->i_flags |= S_APPEND;
7392 @@ -2859,6 +2875,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7393 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7395 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7397 + if (sd_attrs & REISERFS_BARRIER_FL)
7398 + inode->i_vflags |= V_BARRIER;
7400 + inode->i_vflags &= ~V_BARRIER;
7401 + if (sd_attrs & REISERFS_COW_FL)
7402 + inode->i_vflags |= V_COW;
7404 + inode->i_vflags &= ~V_COW;
7408 @@ -2869,6 +2894,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7409 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7411 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7412 + if (inode->i_flags & S_IXUNLINK)
7413 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7415 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7417 if (inode->i_flags & S_SYNC)
7418 *sd_attrs |= REISERFS_SYNC_FL;
7420 @@ -2881,6 +2911,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7421 *sd_attrs |= REISERFS_NOTAIL_FL;
7423 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7425 + if (inode->i_vflags & V_BARRIER)
7426 + *sd_attrs |= REISERFS_BARRIER_FL;
7428 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7429 + if (inode->i_vflags & V_COW)
7430 + *sd_attrs |= REISERFS_COW_FL;
7432 + *sd_attrs &= ~REISERFS_COW_FL;
7436 @@ -3101,9 +3140,11 @@ int reiserfs_setattr(struct dentry *dent
7439 error = inode_change_ok(inode, attr);
7442 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7443 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7444 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7445 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7446 error = reiserfs_chown_xattrs(inode, attr);
7449 @@ -3133,6 +3174,9 @@ int reiserfs_setattr(struct dentry *dent
7450 inode->i_uid = attr->ia_uid;
7451 if (attr->ia_valid & ATTR_GID)
7452 inode->i_gid = attr->ia_gid;
7453 + if ((attr->ia_valid & ATTR_TAG) &&
7455 + inode->i_tag = attr->ia_tag;
7456 mark_inode_dirty(inode);
7458 journal_end(&th, inode->i_sb, jbegin_count);
7459 diff -NurpP --minimal linux-2.6.32.56/fs/reiserfs/ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/ioctl.c
7460 --- linux-2.6.32.56/fs/reiserfs/ioctl.c 2009-06-11 17:13:08.000000000 +0200
7461 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/ioctl.c 2011-06-10 13:03:02.000000000 +0200
7463 #include <linux/mount.h>
7464 #include <linux/reiserfs_fs.h>
7465 #include <linux/time.h>
7466 +#include <linux/mount.h>
7467 #include <asm/uaccess.h>
7468 #include <linux/pagemap.h>
7469 #include <linux/smp_lock.h>
7470 #include <linux/compat.h>
7473 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7475 + __u16 sd_attrs = 0;
7477 + inode->i_flags = flags;
7478 + inode->i_vflags = vflags;
7480 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7481 + REISERFS_I(inode)->i_attrs = sd_attrs;
7482 + inode->i_ctime = CURRENT_TIME_SEC;
7483 + mark_inode_dirty(inode);
7488 ** reiserfs_ioctl - handler for ioctl for inode
7489 ** supported commands:
7491 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7494 - unsigned int flags;
7495 + unsigned int flags, oldflags;
7499 @@ -43,6 +59,7 @@ int reiserfs_ioctl(struct inode *inode,
7501 flags = REISERFS_I(inode)->i_attrs;
7502 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7503 + flags &= REISERFS_FL_USER_VISIBLE;
7504 return put_user(flags, (int __user *)arg);
7505 case REISERFS_IOC_SETFLAGS:{
7506 if (!reiserfs_attrs(inode->i_sb))
7507 @@ -60,6 +77,10 @@ int reiserfs_ioctl(struct inode *inode,
7511 + if (IS_BARRIER(inode)) {
7512 + vxwprintk_task(1, "messing with the barrier.");
7516 * Is it quota file? Do not allow user to mess with it
7518 @@ -84,6 +105,10 @@ int reiserfs_ioctl(struct inode *inode,
7523 + oldflags = REISERFS_I(inode)->i_attrs;
7524 + flags &= REISERFS_FL_USER_MODIFIABLE;
7525 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7526 sd_attrs_to_i_attrs(flags, inode);
7527 REISERFS_I(inode)->i_attrs = flags;
7528 inode->i_ctime = CURRENT_TIME_SEC;
7529 diff -NurpP --minimal linux-2.6.32.56/fs/reiserfs/namei.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/namei.c
7530 --- linux-2.6.32.56/fs/reiserfs/namei.c 2009-06-11 17:13:08.000000000 +0200
7531 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/namei.c 2011-06-10 13:03:02.000000000 +0200
7533 #include <linux/reiserfs_acl.h>
7534 #include <linux/reiserfs_xattr.h>
7535 #include <linux/quotaops.h>
7536 +#include <linux/vs_tag.h>
7538 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
7539 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7540 @@ -354,6 +355,7 @@ static struct dentry *reiserfs_lookup(st
7541 if (retval == IO_ERROR) {
7542 return ERR_PTR(-EIO);
7544 + dx_propagate_tag(nd, inode);
7546 return d_splice_alias(inode, dentry);
7548 @@ -570,6 +572,7 @@ static int new_inode_init(struct inode *
7550 inode->i_gid = current_fsgid();
7552 + inode->i_tag = dx_current_fstag(inode->i_sb);
7556 @@ -1515,6 +1518,7 @@ const struct inode_operations reiserfs_d
7557 .listxattr = reiserfs_listxattr,
7558 .removexattr = reiserfs_removexattr,
7559 .permission = reiserfs_permission,
7560 + .sync_flags = reiserfs_sync_flags,
7564 diff -NurpP --minimal linux-2.6.32.56/fs/reiserfs/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/super.c
7565 --- linux-2.6.32.56/fs/reiserfs/super.c 2012-02-09 10:22:30.000000000 +0100
7566 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/super.c 2012-02-09 10:33:19.000000000 +0100
7567 @@ -888,6 +888,14 @@ static int reiserfs_parse_options(struct
7568 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7569 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7571 +#ifndef CONFIG_TAGGING_NONE
7572 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7573 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7574 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7576 +#ifdef CONFIG_PROPAGATE
7577 + {"tag",.arg_required = 'T',.values = NULL},
7579 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7580 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7581 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7582 @@ -1195,6 +1203,14 @@ static int reiserfs_remount(struct super
7583 handle_quota_files(s, qf_names, &qfmt);
7586 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7587 + !(s->s_flags & MS_TAGGED)) {
7588 + reiserfs_warning(s, "super-vs01",
7589 + "reiserfs: tagging not permitted on remount.");
7596 /* Add options that are safe here */
7597 @@ -1657,6 +1673,10 @@ static int reiserfs_fill_super(struct su
7601 + /* map mount option tagxid */
7602 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7603 + s->s_flags |= MS_TAGGED;
7605 rs = SB_DISK_SUPER_BLOCK(s);
7606 /* Let's do basic sanity check to verify that underlying device is not
7607 smaller than the filesystem. If the check fails then abort and scream,
7608 diff -NurpP --minimal linux-2.6.32.56/fs/reiserfs/xattr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/xattr.c
7609 --- linux-2.6.32.56/fs/reiserfs/xattr.c 2012-02-09 10:22:30.000000000 +0100
7610 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/reiserfs/xattr.c 2011-06-10 13:03:02.000000000 +0200
7612 #include <linux/namei.h>
7613 #include <linux/errno.h>
7614 #include <linux/fs.h>
7615 +#include <linux/mount.h>
7616 #include <linux/file.h>
7617 #include <linux/pagemap.h>
7618 #include <linux/xattr.h>
7619 diff -NurpP --minimal linux-2.6.32.56/fs/stat.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/stat.c
7620 --- linux-2.6.32.56/fs/stat.c 2012-02-09 10:22:30.000000000 +0100
7621 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/stat.c 2011-06-10 13:03:02.000000000 +0200
7622 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7623 stat->nlink = inode->i_nlink;
7624 stat->uid = inode->i_uid;
7625 stat->gid = inode->i_gid;
7626 + stat->tag = inode->i_tag;
7627 stat->rdev = inode->i_rdev;
7628 stat->atime = inode->i_atime;
7629 stat->mtime = inode->i_mtime;
7630 diff -NurpP --minimal linux-2.6.32.56/fs/super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/super.c
7631 --- linux-2.6.32.56/fs/super.c 2012-02-09 10:22:30.000000000 +0100
7632 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/super.c 2011-06-10 13:03:02.000000000 +0200
7634 #include <linux/kobject.h>
7635 #include <linux/mutex.h>
7636 #include <linux/file.h>
7637 +#include <linux/devpts_fs.h>
7638 +#include <linux/proc_fs.h>
7639 +#include <linux/vs_context.h>
7640 #include <asm/uaccess.h>
7641 #include "internal.h"
7643 @@ -914,12 +917,18 @@ struct vfsmount *
7644 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7646 struct vfsmount *mnt;
7647 + struct super_block *sb;
7648 char *secdata = NULL;
7652 return ERR_PTR(-ENODEV);
7655 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7656 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7660 mnt = alloc_vfsmnt(name);
7662 @@ -938,9 +947,17 @@ vfs_kern_mount(struct file_system_type *
7663 error = type->get_sb(type, flags, name, data, mnt);
7665 goto out_free_secdata;
7666 - BUG_ON(!mnt->mnt_sb);
7668 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7673 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7674 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7675 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7678 + error = security_sb_kern_mount(sb, flags, secdata);
7682 diff -NurpP --minimal linux-2.6.32.56/fs/sysfs/mount.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/sysfs/mount.c
7683 --- linux-2.6.32.56/fs/sysfs/mount.c 2009-06-11 17:13:08.000000000 +0200
7684 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/sysfs/mount.c 2011-06-10 13:03:02.000000000 +0200
7685 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7687 sb->s_blocksize = PAGE_CACHE_SIZE;
7688 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7689 - sb->s_magic = SYSFS_MAGIC;
7690 + sb->s_magic = SYSFS_SUPER_MAGIC;
7691 sb->s_op = &sysfs_ops;
7692 sb->s_time_gran = 1;
7694 diff -NurpP --minimal linux-2.6.32.56/fs/utimes.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/utimes.c
7695 --- linux-2.6.32.56/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7696 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/utimes.c 2011-06-10 13:03:02.000000000 +0200
7698 #include <linux/stat.h>
7699 #include <linux/utime.h>
7700 #include <linux/syscalls.h>
7701 +#include <linux/mount.h>
7702 +#include <linux/vs_cowbl.h>
7703 #include <asm/uaccess.h>
7704 #include <asm/unistd.h>
7706 diff -NurpP --minimal linux-2.6.32.56/fs/xattr.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xattr.c
7707 --- linux-2.6.32.56/fs/xattr.c 2009-12-03 20:02:53.000000000 +0100
7708 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xattr.c 2011-06-10 13:03:02.000000000 +0200
7710 #include <linux/module.h>
7711 #include <linux/fsnotify.h>
7712 #include <linux/audit.h>
7713 +#include <linux/mount.h>
7714 #include <asm/uaccess.h>
7717 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7718 * The trusted.* namespace can only be accessed by a privileged user.
7720 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7721 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7722 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7724 /* In user.* namespace, only regular files and directories can have
7725 * extended attributes. For sticky directories, only the owner and
7726 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_ioctl.c
7727 --- linux-2.6.32.56/fs/xfs/linux-2.6/xfs_ioctl.c 2012-02-09 10:22:30.000000000 +0100
7728 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_ioctl.c 2011-06-10 13:03:02.000000000 +0200
7730 #include "xfs_dir2_sf.h"
7731 #include "xfs_dinode.h"
7732 #include "xfs_inode.h"
7733 -#include "xfs_ioctl.h"
7734 #include "xfs_btree.h"
7735 #include "xfs_ialloc.h"
7736 #include "xfs_rtalloc.h"
7737 @@ -746,6 +745,10 @@ xfs_merge_ioc_xflags(
7738 xflags |= XFS_XFLAG_IMMUTABLE;
7740 xflags &= ~XFS_XFLAG_IMMUTABLE;
7741 + if (flags & FS_IXUNLINK_FL)
7742 + xflags |= XFS_XFLAG_IXUNLINK;
7744 + xflags &= ~XFS_XFLAG_IXUNLINK;
7745 if (flags & FS_APPEND_FL)
7746 xflags |= XFS_XFLAG_APPEND;
7748 @@ -774,6 +777,8 @@ xfs_di2lxflags(
7750 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7751 flags |= FS_IMMUTABLE_FL;
7752 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7753 + flags |= FS_IXUNLINK_FL;
7754 if (di_flags & XFS_DIFLAG_APPEND)
7755 flags |= FS_APPEND_FL;
7756 if (di_flags & XFS_DIFLAG_SYNC)
7757 @@ -834,6 +839,8 @@ xfs_set_diflags(
7758 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7759 if (xflags & XFS_XFLAG_IMMUTABLE)
7760 di_flags |= XFS_DIFLAG_IMMUTABLE;
7761 + if (xflags & XFS_XFLAG_IXUNLINK)
7762 + di_flags |= XFS_DIFLAG_IXUNLINK;
7763 if (xflags & XFS_XFLAG_APPEND)
7764 di_flags |= XFS_DIFLAG_APPEND;
7765 if (xflags & XFS_XFLAG_SYNC)
7766 @@ -876,6 +883,10 @@ xfs_diflags_to_linux(
7767 inode->i_flags |= S_IMMUTABLE;
7769 inode->i_flags &= ~S_IMMUTABLE;
7770 + if (xflags & XFS_XFLAG_IXUNLINK)
7771 + inode->i_flags |= S_IXUNLINK;
7773 + inode->i_flags &= ~S_IXUNLINK;
7774 if (xflags & XFS_XFLAG_APPEND)
7775 inode->i_flags |= S_APPEND;
7777 @@ -1352,10 +1363,18 @@ xfs_file_ioctl(
7778 case XFS_IOC_FSGETXATTRA:
7779 return xfs_ioc_fsgetxattr(ip, 1, arg);
7780 case XFS_IOC_FSSETXATTR:
7781 + if (IS_BARRIER(inode)) {
7782 + vxwprintk_task(1, "messing with the barrier.");
7783 + return -XFS_ERROR(EACCES);
7785 return xfs_ioc_fssetxattr(ip, filp, arg);
7786 case XFS_IOC_GETXFLAGS:
7787 return xfs_ioc_getxflags(ip, arg);
7788 case XFS_IOC_SETXFLAGS:
7789 + if (IS_BARRIER(inode)) {
7790 + vxwprintk_task(1, "messing with the barrier.");
7791 + return -XFS_ERROR(EACCES);
7793 return xfs_ioc_setxflags(ip, filp, arg);
7795 case XFS_IOC_FSSETDM: {
7796 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_ioctl.h
7797 --- linux-2.6.32.56/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
7798 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_ioctl.h 2011-06-10 13:03:02.000000000 +0200
7799 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7800 void __user *uhandle,
7805 + struct inode *inode,
7812 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_iops.c
7813 --- linux-2.6.32.56/fs/xfs/linux-2.6/xfs_iops.c 2012-02-09 10:22:30.000000000 +0100
7814 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_iops.c 2011-06-10 13:03:02.000000000 +0200
7816 #include "xfs_attr_sf.h"
7817 #include "xfs_dinode.h"
7818 #include "xfs_inode.h"
7819 +#include "xfs_ioctl.h"
7820 #include "xfs_bmap.h"
7821 #include "xfs_btree.h"
7822 #include "xfs_ialloc.h"
7824 #include <linux/security.h>
7825 #include <linux/falloc.h>
7826 #include <linux/fiemap.h>
7827 +#include <linux/vs_tag.h>
7830 * Bring the timestamps in the XFS inode uptodate.
7831 @@ -495,6 +497,7 @@ xfs_vn_getattr(
7832 stat->nlink = ip->i_d.di_nlink;
7833 stat->uid = ip->i_d.di_uid;
7834 stat->gid = ip->i_d.di_gid;
7835 + stat->tag = ip->i_d.di_tag;
7836 stat->ino = ip->i_ino;
7837 stat->atime = inode->i_atime;
7838 stat->mtime = inode->i_mtime;
7839 @@ -686,6 +689,7 @@ static const struct inode_operations xfs
7840 .listxattr = xfs_vn_listxattr,
7841 .fallocate = xfs_vn_fallocate,
7842 .fiemap = xfs_vn_fiemap,
7843 + .sync_flags = xfs_sync_flags,
7846 static const struct inode_operations xfs_dir_inode_operations = {
7847 @@ -711,6 +715,7 @@ static const struct inode_operations xfs
7848 .getxattr = generic_getxattr,
7849 .removexattr = generic_removexattr,
7850 .listxattr = xfs_vn_listxattr,
7851 + .sync_flags = xfs_sync_flags,
7854 static const struct inode_operations xfs_dir_ci_inode_operations = {
7855 @@ -760,6 +765,10 @@ xfs_diflags_to_iflags(
7856 inode->i_flags |= S_IMMUTABLE;
7858 inode->i_flags &= ~S_IMMUTABLE;
7859 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7860 + inode->i_flags |= S_IXUNLINK;
7862 + inode->i_flags &= ~S_IXUNLINK;
7863 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7864 inode->i_flags |= S_APPEND;
7866 @@ -772,6 +781,15 @@ xfs_diflags_to_iflags(
7867 inode->i_flags |= S_NOATIME;
7869 inode->i_flags &= ~S_NOATIME;
7871 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7872 + inode->i_vflags |= V_BARRIER;
7874 + inode->i_vflags &= ~V_BARRIER;
7875 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7876 + inode->i_vflags |= V_COW;
7878 + inode->i_vflags &= ~V_COW;
7882 @@ -800,6 +818,7 @@ xfs_setup_inode(
7883 inode->i_nlink = ip->i_d.di_nlink;
7884 inode->i_uid = ip->i_d.di_uid;
7885 inode->i_gid = ip->i_d.di_gid;
7886 + inode->i_tag = ip->i_d.di_tag;
7888 switch (inode->i_mode & S_IFMT) {
7890 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_linux.h
7891 --- linux-2.6.32.56/fs/xfs/linux-2.6/xfs_linux.h 2009-09-10 15:26:24.000000000 +0200
7892 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_linux.h 2011-06-10 13:03:02.000000000 +0200
7895 #define current_cpu() (raw_smp_processor_id())
7896 #define current_pid() (current->pid)
7897 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7898 #define current_test_flags(f) (current->flags & (f))
7899 #define current_set_flags_nested(sp, f) \
7900 (*(sp) = current->flags, current->flags |= (f))
7901 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/linux-2.6/xfs_super.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_super.c
7902 --- linux-2.6.32.56/fs/xfs/linux-2.6/xfs_super.c 2012-02-09 10:22:30.000000000 +0100
7903 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/linux-2.6/xfs_super.c 2011-06-10 13:03:02.000000000 +0200
7904 @@ -117,6 +117,9 @@ mempool_t *xfs_ioend_pool;
7905 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
7906 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
7907 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
7908 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7909 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7910 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7913 * Table driven mount option parser.
7914 @@ -125,10 +128,14 @@ mempool_t *xfs_ioend_pool;
7915 * in the future, too.
7918 + Opt_tag, Opt_notag,
7919 Opt_barrier, Opt_nobarrier, Opt_err
7922 static const match_table_t tokens = {
7923 + {Opt_tag, "tagxid"},
7925 + {Opt_notag, "notag"},
7926 {Opt_barrier, "barrier"},
7927 {Opt_nobarrier, "nobarrier"},
7929 @@ -382,6 +389,19 @@ xfs_parseargs(
7930 } else if (!strcmp(this_char, "irixsgid")) {
7932 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7933 +#ifndef CONFIG_TAGGING_NONE
7934 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7935 + mp->m_flags |= XFS_MOUNT_TAGGED;
7936 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7937 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7938 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7939 + mp->m_flags |= XFS_MOUNT_TAGGED;
7941 +#ifdef CONFIG_PROPAGATE
7942 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7944 + mp->m_flags |= XFS_MOUNT_TAGGED;
7948 "XFS: unknown mount option [%s].", this_char);
7949 @@ -1295,6 +1315,16 @@ xfs_fs_remount(
7951 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7954 + if (!(sb->s_flags & MS_TAGGED)) {
7956 + "XFS: %s: tagging not permitted on remount.\n",
7965 * Logically we would return an error here to prevent
7966 @@ -1530,6 +1560,9 @@ xfs_fs_fill_super(
7968 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
7970 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7971 + sb->s_flags |= MS_TAGGED;
7973 sb->s_magic = XFS_SB_MAGIC;
7974 sb->s_blocksize = mp->m_sb.sb_blocksize;
7975 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
7976 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_dinode.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_dinode.h
7977 --- linux-2.6.32.56/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
7978 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_dinode.h 2011-06-10 13:03:02.000000000 +0200
7979 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
7980 __be32 di_gid; /* owner's group id */
7981 __be32 di_nlink; /* number of links to file */
7982 __be16 di_projid; /* owner's project id */
7983 - __u8 di_pad[8]; /* unused, zeroed space */
7984 + __be16 di_tag; /* context tagging */
7985 + __be16 di_vflags; /* vserver specific flags */
7986 + __u8 di_pad[4]; /* unused, zeroed space */
7987 __be16 di_flushiter; /* incremented on flush */
7988 xfs_timestamp_t di_atime; /* time last accessed */
7989 xfs_timestamp_t di_mtime; /* time last modified */
7990 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
7991 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7992 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7993 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7994 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7996 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7997 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7998 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7999 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
8000 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8001 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8002 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8003 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8005 #ifdef CONFIG_XFS_RT
8006 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8007 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
8008 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8009 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8010 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8011 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8012 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8013 + XFS_DIFLAG_IXUNLINK)
8015 +#define XFS_DIVFLAG_BARRIER 0x01
8016 +#define XFS_DIVFLAG_COW 0x02
8018 #endif /* __XFS_DINODE_H__ */
8019 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_fs.h
8020 --- linux-2.6.32.56/fs/xfs/xfs_fs.h 2009-12-03 20:02:53.000000000 +0100
8021 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_fs.h 2011-06-10 13:03:02.000000000 +0200
8022 @@ -67,6 +67,9 @@ struct fsxattr {
8023 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8024 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8025 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8026 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8027 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8028 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8029 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8032 @@ -292,7 +295,8 @@ typedef struct xfs_bstat {
8033 __s32 bs_extents; /* number of extents */
8034 __u32 bs_gen; /* generation count */
8035 __u16 bs_projid; /* project id */
8036 - unsigned char bs_pad[14]; /* pad space, unused */
8037 + __u16 bs_tag; /* context tagging */
8038 + unsigned char bs_pad[12]; /* pad space, unused */
8039 __u32 bs_dmevmask; /* DMIG event mask */
8040 __u16 bs_dmstate; /* DMIG state info */
8041 __u16 bs_aextents; /* attribute number of extents */
8042 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_ialloc.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_ialloc.c
8043 --- linux-2.6.32.56/fs/xfs/xfs_ialloc.c 2012-02-09 10:22:31.000000000 +0100
8044 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_ialloc.c 2011-06-10 13:03:02.000000000 +0200
8046 #include "xfs_error.h"
8047 #include "xfs_bmap.h"
8051 * Allocation group level functions.
8053 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_inode.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_inode.c
8054 --- linux-2.6.32.56/fs/xfs/xfs_inode.c 2012-02-09 10:22:31.000000000 +0100
8055 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_inode.c 2011-06-10 13:03:02.000000000 +0200
8056 @@ -249,6 +249,7 @@ xfs_inotobp(
8060 +#include <linux/vs_tag.h>
8063 * This routine is called to map an inode to the buffer containing
8064 @@ -654,15 +655,25 @@ xfs_iformat_btree(
8066 xfs_dinode_from_disk(
8068 - xfs_dinode_t *from)
8069 + xfs_dinode_t *from,
8072 + uint32_t uid, gid, tag;
8074 to->di_magic = be16_to_cpu(from->di_magic);
8075 to->di_mode = be16_to_cpu(from->di_mode);
8076 to->di_version = from ->di_version;
8077 to->di_format = from->di_format;
8078 to->di_onlink = be16_to_cpu(from->di_onlink);
8079 - to->di_uid = be32_to_cpu(from->di_uid);
8080 - to->di_gid = be32_to_cpu(from->di_gid);
8082 + uid = be32_to_cpu(from->di_uid);
8083 + gid = be32_to_cpu(from->di_gid);
8084 + tag = be16_to_cpu(from->di_tag);
8086 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8087 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8088 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8090 to->di_nlink = be32_to_cpu(from->di_nlink);
8091 to->di_projid = be16_to_cpu(from->di_projid);
8092 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8093 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
8094 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8095 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8096 to->di_flags = be16_to_cpu(from->di_flags);
8097 + to->di_vflags = be16_to_cpu(from->di_vflags);
8098 to->di_gen = be32_to_cpu(from->di_gen);
8104 - xfs_icdinode_t *from)
8105 + xfs_icdinode_t *from,
8108 to->di_magic = cpu_to_be16(from->di_magic);
8109 to->di_mode = cpu_to_be16(from->di_mode);
8110 to->di_version = from ->di_version;
8111 to->di_format = from->di_format;
8112 to->di_onlink = cpu_to_be16(from->di_onlink);
8113 - to->di_uid = cpu_to_be32(from->di_uid);
8114 - to->di_gid = cpu_to_be32(from->di_gid);
8116 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8117 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8118 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8120 to->di_nlink = cpu_to_be32(from->di_nlink);
8121 to->di_projid = cpu_to_be16(from->di_projid);
8122 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8123 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
8124 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8125 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8126 to->di_flags = cpu_to_be16(from->di_flags);
8127 + to->di_vflags = cpu_to_be16(from->di_vflags);
8128 to->di_gen = cpu_to_be32(from->di_gen);
8133 - __uint16_t di_flags)
8134 + __uint16_t di_flags,
8135 + __uint16_t di_vflags)
8139 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
8140 flags |= XFS_XFLAG_PREALLOC;
8141 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8142 flags |= XFS_XFLAG_IMMUTABLE;
8143 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8144 + flags |= XFS_XFLAG_IXUNLINK;
8145 if (di_flags & XFS_DIFLAG_APPEND)
8146 flags |= XFS_XFLAG_APPEND;
8147 if (di_flags & XFS_DIFLAG_SYNC)
8148 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
8149 flags |= XFS_XFLAG_FILESTREAM;
8152 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8153 + flags |= FS_BARRIER_FL;
8154 + if (di_vflags & XFS_DIVFLAG_COW)
8155 + flags |= FS_COW_FL;
8159 @@ -767,7 +791,7 @@ xfs_ip2xflags(
8161 xfs_icdinode_t *dic = &ip->i_d;
8163 - return _xfs_dic2xflags(dic->di_flags) |
8164 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8165 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8168 @@ -775,7 +799,8 @@ uint
8172 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8173 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8174 + be16_to_cpu(dip->di_vflags)) |
8175 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8178 @@ -808,7 +833,6 @@ xfs_iread(
8181 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8184 * If we got something that isn't an inode it means someone
8185 * (nfs or dmi) has a stale handle.
8186 @@ -833,7 +857,8 @@ xfs_iread(
8187 * Otherwise, just get the truly permanent information.
8190 - xfs_dinode_from_disk(&ip->i_d, dip);
8191 + xfs_dinode_from_disk(&ip->i_d, dip,
8192 + mp->m_flags & XFS_MOUNT_TAGGED);
8193 error = xfs_iformat(ip, dip);
8196 @@ -1033,6 +1058,7 @@ xfs_ialloc(
8197 ASSERT(ip->i_d.di_nlink == nlink);
8198 ip->i_d.di_uid = current_fsuid();
8199 ip->i_d.di_gid = current_fsgid();
8200 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8201 ip->i_d.di_projid = prid;
8202 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8204 @@ -1093,6 +1119,7 @@ xfs_ialloc(
8205 ip->i_d.di_dmevmask = 0;
8206 ip->i_d.di_dmstate = 0;
8207 ip->i_d.di_flags = 0;
8208 + ip->i_d.di_vflags = 0;
8209 flags = XFS_ILOG_CORE;
8210 switch (mode & S_IFMT) {
8212 @@ -2169,6 +2196,7 @@ xfs_ifree(
8214 ip->i_d.di_mode = 0; /* mark incore inode as free */
8215 ip->i_d.di_flags = 0;
8216 + ip->i_d.di_vflags = 0;
8217 ip->i_d.di_dmevmask = 0;
8218 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8219 ip->i_df.if_ext_max =
8220 @@ -3149,7 +3177,8 @@ xfs_iflush_int(
8221 * because if the inode is dirty at all the core must
8224 - xfs_dinode_to_disk(dip, &ip->i_d);
8225 + xfs_dinode_to_disk(dip, &ip->i_d,
8226 + mp->m_flags & XFS_MOUNT_TAGGED);
8228 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8229 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8230 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_inode.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_inode.h
8231 --- linux-2.6.32.56/fs/xfs/xfs_inode.h 2012-02-09 10:22:31.000000000 +0100
8232 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_inode.h 2011-06-10 13:03:02.000000000 +0200
8233 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8234 __uint32_t di_gid; /* owner's group id */
8235 __uint32_t di_nlink; /* number of links to file */
8236 __uint16_t di_projid; /* owner's project id */
8237 - __uint8_t di_pad[8]; /* unused, zeroed space */
8238 + __uint16_t di_tag; /* context tagging */
8239 + __uint16_t di_vflags; /* vserver specific flags */
8240 + __uint8_t di_pad[4]; /* unused, zeroed space */
8241 __uint16_t di_flushiter; /* incremented on flush */
8242 xfs_ictimestamp_t di_atime; /* time last accessed */
8243 xfs_ictimestamp_t di_mtime; /* time last modified */
8244 @@ -569,7 +571,7 @@ int xfs_itobp(struct xfs_mount *, struc
8245 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8246 struct xfs_inode *, uint);
8247 void xfs_dinode_to_disk(struct xfs_dinode *,
8248 - struct xfs_icdinode *);
8249 + struct xfs_icdinode *, int);
8250 void xfs_idestroy_fork(struct xfs_inode *, int);
8251 void xfs_idata_realloc(struct xfs_inode *, int, int);
8252 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8253 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_itable.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_itable.c
8254 --- linux-2.6.32.56/fs/xfs/xfs_itable.c 2012-02-09 10:22:31.000000000 +0100
8255 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_itable.c 2011-06-10 13:03:02.000000000 +0200
8256 @@ -100,6 +100,7 @@ xfs_bulkstat_one_int(
8257 buf->bs_mode = dic->di_mode;
8258 buf->bs_uid = dic->di_uid;
8259 buf->bs_gid = dic->di_gid;
8260 + buf->bs_tag = dic->di_tag;
8261 buf->bs_size = dic->di_size;
8264 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_log_recover.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_log_recover.c
8265 --- linux-2.6.32.56/fs/xfs/xfs_log_recover.c 2012-02-09 10:22:31.000000000 +0100
8266 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_log_recover.c 2011-06-10 13:03:02.000000000 +0200
8267 @@ -2467,7 +2467,8 @@ xlog_recover_do_inode_trans(
8270 /* The core is in in-core format */
8271 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8272 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8273 + mp->m_flags & XFS_MOUNT_TAGGED);
8275 /* the rest is in on-disk format */
8276 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8277 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_mount.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_mount.h
8278 --- linux-2.6.32.56/fs/xfs/xfs_mount.h 2012-02-09 10:22:31.000000000 +0100
8279 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_mount.h 2011-06-10 13:03:02.000000000 +0200
8280 @@ -285,6 +285,7 @@ typedef struct xfs_mount {
8282 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8284 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8287 * Default minimum read and write sizes.
8288 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_vnodeops.c linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_vnodeops.c
8289 --- linux-2.6.32.56/fs/xfs/xfs_vnodeops.c 2012-02-09 10:22:31.000000000 +0100
8290 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_vnodeops.c 2011-06-10 13:03:02.000000000 +0200
8292 #include "xfs_filestream.h"
8293 #include "xfs_vnodeops.h"
8297 +xfs_get_inode_flags(
8300 + struct inode *inode = VFS_I(ip);
8301 + unsigned int flags = inode->i_flags;
8302 + unsigned int vflags = inode->i_vflags;
8304 + if (flags & S_IMMUTABLE)
8305 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8307 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8308 + if (flags & S_IXUNLINK)
8309 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8311 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8313 + if (vflags & V_BARRIER)
8314 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8316 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8317 + if (vflags & V_COW)
8318 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8320 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8325 + struct inode *inode,
8329 + struct xfs_inode *ip = XFS_I(inode);
8330 + struct xfs_mount *mp = ip->i_mount;
8331 + struct xfs_trans *tp;
8332 + unsigned int lock_flags = 0;
8335 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8336 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8340 + lock_flags = XFS_ILOCK_EXCL;
8341 + xfs_ilock(ip, lock_flags);
8343 + xfs_trans_ijoin(tp, ip, lock_flags);
8344 + xfs_trans_ihold(tp, ip);
8346 + inode->i_flags = flags;
8347 + inode->i_vflags = vflags;
8348 + xfs_get_inode_flags(ip);
8350 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8351 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8353 + XFS_STATS_INC(xs_ig_attrchg);
8355 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8356 + xfs_trans_set_sync(tp);
8357 + code = xfs_trans_commit(tp, 0);
8358 + xfs_iunlock(ip, lock_flags);
8362 + xfs_trans_cancel(tp, 0);
8364 + xfs_iunlock(ip, lock_flags);
8371 struct xfs_inode *ip,
8372 @@ -69,6 +143,7 @@ xfs_setattr(
8373 uint commit_flags=0;
8374 uid_t uid=0, iuid=0;
8375 gid_t gid=0, igid=0;
8376 + tag_t tag=0, itag=0;
8377 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8378 int need_iolock = 1;
8380 @@ -161,7 +236,7 @@ xfs_setattr(
8382 * Change file ownership. Must be the owner or privileged.
8384 - if (mask & (ATTR_UID|ATTR_GID)) {
8385 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8387 * These IDs could have changed since we last looked at them.
8388 * But, we're assured that if the ownership did change
8389 @@ -170,8 +245,10 @@ xfs_setattr(
8391 iuid = ip->i_d.di_uid;
8392 igid = ip->i_d.di_gid;
8393 + itag = ip->i_d.di_tag;
8394 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8395 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8396 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8399 * Do a quota reservation only if uid/gid is actually
8400 @@ -179,7 +256,8 @@ xfs_setattr(
8402 if (XFS_IS_QUOTA_RUNNING(mp) &&
8403 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8404 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8405 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8406 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8408 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8409 capable(CAP_FOWNER) ?
8410 @@ -340,7 +418,7 @@ xfs_setattr(
8412 * Change file ownership. Must be the owner or privileged.
8414 - if (mask & (ATTR_UID|ATTR_GID)) {
8415 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8417 * CAP_FSETID overrides the following restrictions:
8419 @@ -356,6 +434,10 @@ xfs_setattr(
8420 * Change the ownerships and register quota modifications
8421 * in the transaction.
8423 + if (itag != tag) {
8424 + ip->i_d.di_tag = tag;
8425 + inode->i_tag = tag;
8428 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8429 ASSERT(mask & ATTR_UID);
8430 diff -NurpP --minimal linux-2.6.32.56/fs/xfs/xfs_vnodeops.h linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_vnodeops.h
8431 --- linux-2.6.32.56/fs/xfs/xfs_vnodeops.h 2012-02-09 10:22:31.000000000 +0100
8432 +++ linux-2.6.32.56-vs2.3.0.36.29.9/fs/xfs/xfs_vnodeops.h 2011-06-10 13:03:02.000000000 +0200
8433 @@ -14,6 +14,7 @@ struct xfs_inode;
8437 +int xfs_sync_xflags(struct xfs_inode *ip);
8438 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8439 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8440 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8441 diff -NurpP --minimal linux-2.6.32.56/include/asm-generic/tlb.h linux-2.6.32.56-vs2.3.0.36.29.9/include/asm-generic/tlb.h
8442 --- linux-2.6.32.56/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8443 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/asm-generic/tlb.h 2011-06-10 13:03:02.000000000 +0200
8445 #define _ASM_GENERIC__TLB_H
8447 #include <linux/swap.h>
8448 +#include <linux/vs_memory.h>
8449 #include <asm/pgalloc.h>
8450 #include <asm/tlbflush.h>
8452 diff -NurpP --minimal linux-2.6.32.56/include/linux/Kbuild linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/Kbuild
8453 --- linux-2.6.32.56/include/linux/Kbuild 2009-12-03 20:02:54.000000000 +0100
8454 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/Kbuild 2011-06-10 13:03:02.000000000 +0200
8455 @@ -382,5 +382,8 @@ unifdef-y += xattr.h
8458 objhdr-y += version.h
8460 +header-y += vserver/
8464 diff -NurpP --minimal linux-2.6.32.56/include/linux/capability.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/capability.h
8465 --- linux-2.6.32.56/include/linux/capability.h 2009-12-03 20:02:54.000000000 +0100
8466 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/capability.h 2011-06-10 13:03:02.000000000 +0200
8467 @@ -285,6 +285,7 @@ struct cpu_vfs_cap_data {
8468 arbitrary SCSI commands */
8469 /* Allow setting encryption key on loopback filesystem */
8470 /* Allow setting zone reclaim policy */
8471 +/* Allow the selection of a security context */
8473 #define CAP_SYS_ADMIN 21
8475 @@ -357,7 +358,13 @@ struct cpu_vfs_cap_data {
8477 #define CAP_MAC_ADMIN 33
8479 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8480 +/* Allow context manipulations */
8481 +/* Allow changing context info on files */
8483 +#define CAP_CONTEXT 34
8486 +#define CAP_LAST_CAP CAP_CONTEXT
8488 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8490 diff -NurpP --minimal linux-2.6.32.56/include/linux/devpts_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/devpts_fs.h
8491 --- linux-2.6.32.56/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8492 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/devpts_fs.h 2011-06-10 13:03:02.000000000 +0200
8493 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8498 #endif /* _LINUX_DEVPTS_FS_H */
8499 diff -NurpP --minimal linux-2.6.32.56/include/linux/ext2_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/ext2_fs.h
8500 --- linux-2.6.32.56/include/linux/ext2_fs.h 2012-02-09 10:22:31.000000000 +0100
8501 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/ext2_fs.h 2011-11-17 12:18:26.000000000 +0100
8502 @@ -189,8 +189,12 @@ struct ext2_group_desc
8503 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8504 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8505 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8506 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8507 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8509 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8510 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8512 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8513 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8515 @@ -274,7 +278,8 @@ struct ext2_inode {
8517 __le16 l_i_uid_high; /* these 2 fields */
8518 __le16 l_i_gid_high; /* were reserved2[0] */
8519 - __u32 l_i_reserved2;
8520 + __le16 l_i_tag; /* Context Tag */
8521 + __u16 l_i_reserved2;
8524 __u8 h_i_frag; /* Fragment number */
8525 @@ -303,6 +308,7 @@ struct ext2_inode {
8526 #define i_gid_low i_gid
8527 #define i_uid_high osd2.linux2.l_i_uid_high
8528 #define i_gid_high osd2.linux2.l_i_gid_high
8529 +#define i_raw_tag osd2.linux2.l_i_tag
8530 #define i_reserved2 osd2.linux2.l_i_reserved2
8533 @@ -347,6 +353,7 @@ struct ext2_inode {
8534 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8535 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8536 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8537 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8540 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8541 diff -NurpP --minimal linux-2.6.32.56/include/linux/ext3_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/ext3_fs.h
8542 --- linux-2.6.32.56/include/linux/ext3_fs.h 2012-02-09 10:22:31.000000000 +0100
8543 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/ext3_fs.h 2011-11-17 12:18:26.000000000 +0100
8544 @@ -173,10 +173,14 @@ struct ext3_group_desc
8545 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8546 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8547 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8548 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8549 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8551 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8552 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8553 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8554 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8556 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8557 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8559 /* Flags that should be inherited by new inodes from their parent. */
8560 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8561 @@ -320,7 +324,8 @@ struct ext3_inode {
8563 __le16 l_i_uid_high; /* these 2 fields */
8564 __le16 l_i_gid_high; /* were reserved2[0] */
8565 - __u32 l_i_reserved2;
8566 + __le16 l_i_tag; /* Context Tag */
8567 + __u16 l_i_reserved2;
8570 __u8 h_i_frag; /* Fragment number */
8571 @@ -351,6 +356,7 @@ struct ext3_inode {
8572 #define i_gid_low i_gid
8573 #define i_uid_high osd2.linux2.l_i_uid_high
8574 #define i_gid_high osd2.linux2.l_i_gid_high
8575 +#define i_raw_tag osd2.linux2.l_i_tag
8576 #define i_reserved2 osd2.linux2.l_i_reserved2
8578 #elif defined(__GNU__)
8579 @@ -414,6 +420,7 @@ struct ext3_inode {
8580 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8581 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8582 * error in ordered mode */
8583 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8585 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8586 #ifndef _LINUX_EXT2_FS_H
8587 @@ -892,6 +899,7 @@ extern void ext3_get_inode_flags(struct
8588 extern void ext3_set_aops(struct inode *inode);
8589 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8590 u64 start, u64 len);
8591 +extern int ext3_sync_flags(struct inode *, int, int);
8594 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8595 diff -NurpP --minimal linux-2.6.32.56/include/linux/fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/fs.h
8596 --- linux-2.6.32.56/include/linux/fs.h 2012-02-09 10:22:31.000000000 +0100
8597 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/fs.h 2011-08-08 22:40:36.000000000 +0200
8598 @@ -208,6 +208,9 @@ struct inodes_stat_t {
8599 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8600 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8601 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8602 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8603 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8604 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8605 #define MS_ACTIVE (1<<30)
8606 #define MS_NOUSER (1<<31)
8608 @@ -234,6 +237,14 @@ struct inodes_stat_t {
8609 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8610 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8611 #define S_PRIVATE 512 /* Inode is fs-internal */
8612 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8614 +/* Linux-VServer related Inode flags */
8618 +#define V_BARRIER 4 /* Barrier for chroot() */
8619 +#define V_COW 8 /* Copy on Write */
8622 * Note that nosuid etc flags are inode-specific: setting some file-system
8623 @@ -256,12 +267,15 @@ struct inodes_stat_t {
8624 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8625 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8626 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8627 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8628 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8629 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8630 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8631 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8633 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8634 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8635 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8636 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8637 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8638 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8640 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8641 @@ -269,6 +283,16 @@ struct inodes_stat_t {
8642 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8643 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8645 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8647 +#ifdef CONFIG_VSERVER_COWBL
8648 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8649 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8651 +# define IS_COW(inode) (0)
8652 +# define IS_COW_LINK(inode) (0)
8655 /* the read-only stuff doesn't really belong here, but any other place is
8656 probably as bad and I don't want to create yet another include file. */
8658 @@ -350,11 +374,14 @@ struct inodes_stat_t {
8659 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8660 #define FS_EXTENT_FL 0x00080000 /* Extents */
8661 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8662 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8663 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8665 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8666 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8667 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8668 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8670 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8671 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8673 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8674 #define SYNC_FILE_RANGE_WRITE 2
8675 @@ -436,6 +463,7 @@ typedef void (dio_iodone_t)(struct kiocb
8676 #define ATTR_KILL_PRIV (1 << 14)
8677 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8678 #define ATTR_TIMES_SET (1 << 16)
8679 +#define ATTR_TAG (1 << 17)
8682 * This is the Inode Attributes structure, used for notify_change(). It
8683 @@ -451,6 +479,7 @@ struct iattr {
8689 struct timespec ia_atime;
8690 struct timespec ia_mtime;
8691 @@ -464,6 +493,9 @@ struct iattr {
8692 struct file *ia_file;
8695 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8696 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8699 * Includes for diskquotas.
8701 @@ -730,7 +762,9 @@ struct inode {
8702 unsigned int i_nlink;
8710 #ifdef __NEED_I_SIZE_ORDERED
8711 @@ -777,7 +811,8 @@ struct inode {
8712 unsigned long i_state;
8713 unsigned long dirtied_when; /* jiffies of first dirtying */
8715 - unsigned int i_flags;
8716 + unsigned short i_flags;
8717 + unsigned short i_vflags;
8719 atomic_t i_writecount;
8720 #ifdef CONFIG_SECURITY
8721 @@ -865,12 +900,12 @@ static inline void i_size_write(struct i
8723 static inline unsigned iminor(const struct inode *inode)
8725 - return MINOR(inode->i_rdev);
8726 + return MINOR(inode->i_mdev);
8729 static inline unsigned imajor(const struct inode *inode)
8731 - return MAJOR(inode->i_rdev);
8732 + return MAJOR(inode->i_mdev);
8735 extern struct block_device *I_BDEV(struct inode *inode);
8736 @@ -929,6 +964,7 @@ struct file {
8738 struct fown_struct f_owner;
8739 const struct cred *f_cred;
8741 struct file_ra_state f_ra;
8744 @@ -1070,6 +1106,7 @@ struct file_lock {
8745 struct file *fl_file;
8750 struct fasync_struct * fl_fasync; /* for lease break notifications */
8751 unsigned long fl_break_time; /* for nonblocking lease breaks */
8752 @@ -1537,6 +1574,7 @@ struct inode_operations {
8753 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8754 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8755 int (*removexattr) (struct dentry *, const char *);
8756 + int (*sync_flags) (struct inode *, int, int);
8757 void (*truncate_range)(struct inode *, loff_t, loff_t);
8758 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8760 @@ -1557,6 +1595,7 @@ extern ssize_t vfs_readv(struct file *,
8761 unsigned long, loff_t *);
8762 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8763 unsigned long, loff_t *);
8764 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8766 struct super_operations {
8767 struct inode *(*alloc_inode)(struct super_block *sb);
8768 @@ -2356,6 +2395,7 @@ extern int dcache_dir_open(struct inode
8769 extern int dcache_dir_close(struct inode *, struct file *);
8770 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8771 extern int dcache_readdir(struct file *, void *, filldir_t);
8772 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8773 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8774 extern int simple_statfs(struct dentry *, struct kstatfs *);
8775 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8776 diff -NurpP --minimal linux-2.6.32.56/include/linux/gfs2_ondisk.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/gfs2_ondisk.h
8777 --- linux-2.6.32.56/include/linux/gfs2_ondisk.h 2009-12-03 20:02:55.000000000 +0100
8778 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/gfs2_ondisk.h 2011-06-10 13:03:02.000000000 +0200
8779 @@ -235,6 +235,9 @@ enum {
8783 + gfs2fl_IXUnlink = 16,
8784 + gfs2fl_Barrier = 17,
8786 gfs2fl_TruncInProg = 29,
8787 gfs2fl_InheritDirectio = 30,
8788 gfs2fl_InheritJdata = 31,
8789 @@ -251,6 +254,9 @@ enum {
8790 #define GFS2_DIF_NOATIME 0x00000080
8791 #define GFS2_DIF_SYNC 0x00000100
8792 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8793 +#define GFS2_DIF_IXUNLINK 0x00010000
8794 +#define GFS2_DIF_BARRIER 0x00020000
8795 +#define GFS2_DIF_COW 0x00040000
8796 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8797 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8798 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8799 diff -NurpP --minimal linux-2.6.32.56/include/linux/if_tun.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/if_tun.h
8800 --- linux-2.6.32.56/include/linux/if_tun.h 2009-12-03 20:02:55.000000000 +0100
8801 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/if_tun.h 2011-06-10 13:03:02.000000000 +0200
8803 #define TUNGETIFF _IOR('T', 210, unsigned int)
8804 #define TUNGETSNDBUF _IOR('T', 211, int)
8805 #define TUNSETSNDBUF _IOW('T', 212, int)
8806 +#define TUNSETNID _IOW('T', 215, int)
8808 /* TUNSETIFF ifr flags */
8809 #define IFF_TUN 0x0001
8810 diff -NurpP --minimal linux-2.6.32.56/include/linux/init_task.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/init_task.h
8811 --- linux-2.6.32.56/include/linux/init_task.h 2009-12-03 20:02:55.000000000 +0100
8812 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/init_task.h 2011-06-10 13:03:02.000000000 +0200
8813 @@ -184,6 +184,10 @@ extern struct cred init_cred;
8815 INIT_TRACE_RECURSION \
8816 INIT_TASK_RCU_PREEMPT(tsk) \
8818 + .vx_info = NULL, \
8820 + .nx_info = NULL, \
8824 diff -NurpP --minimal linux-2.6.32.56/include/linux/ipc.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/ipc.h
8825 --- linux-2.6.32.56/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8826 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/ipc.h 2011-06-10 13:03:02.000000000 +0200
8827 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8835 diff -NurpP --minimal linux-2.6.32.56/include/linux/loop.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/loop.h
8836 --- linux-2.6.32.56/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8837 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/loop.h 2011-06-10 13:03:02.000000000 +0200
8838 @@ -45,6 +45,7 @@ struct loop_device {
8839 struct loop_func_table *lo_encryption;
8841 uid_t lo_key_owner; /* Who set the key */
8843 int (*ioctl)(struct loop_device *, int cmd,
8846 diff -NurpP --minimal linux-2.6.32.56/include/linux/magic.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/magic.h
8847 --- linux-2.6.32.56/include/linux/magic.h 2009-12-03 20:02:55.000000000 +0100
8848 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/magic.h 2011-06-10 13:03:02.000000000 +0200
8851 #define ADFS_SUPER_MAGIC 0xadf5
8852 #define AFFS_SUPER_MAGIC 0xadff
8853 -#define AFS_SUPER_MAGIC 0x5346414F
8854 +#define AFS_SUPER_MAGIC 0x5346414F
8855 #define AUTOFS_SUPER_MAGIC 0x0187
8856 #define CODA_SUPER_MAGIC 0x73757245
8857 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8859 #define NFS_SUPER_MAGIC 0x6969
8860 #define OPENPROM_SUPER_MAGIC 0x9fa1
8861 #define PROC_SUPER_MAGIC 0x9fa0
8862 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8863 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8865 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8866 diff -NurpP --minimal linux-2.6.32.56/include/linux/major.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/major.h
8867 --- linux-2.6.32.56/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8868 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/major.h 2011-06-10 13:03:02.000000000 +0200
8870 #define HD_MAJOR IDE0_MAJOR
8871 #define PTY_SLAVE_MAJOR 3
8873 +#define VROOT_MAJOR 4
8874 #define TTYAUX_MAJOR 5
8877 diff -NurpP --minimal linux-2.6.32.56/include/linux/memcontrol.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/memcontrol.h
8878 --- linux-2.6.32.56/include/linux/memcontrol.h 2009-12-03 20:02:55.000000000 +0100
8879 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/memcontrol.h 2011-06-10 13:03:02.000000000 +0200
8880 @@ -70,6 +70,13 @@ int task_in_mem_cgroup(struct task_struc
8882 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8884 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8885 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8887 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8888 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8889 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8892 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8894 diff -NurpP --minimal linux-2.6.32.56/include/linux/mm_types.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/mm_types.h
8895 --- linux-2.6.32.56/include/linux/mm_types.h 2012-02-09 10:22:31.000000000 +0100
8896 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/mm_types.h 2011-06-10 13:03:02.000000000 +0200
8897 @@ -246,6 +246,7 @@ struct mm_struct {
8899 /* Architecture-specific MM context */
8900 mm_context_t context;
8901 + struct vx_info *mm_vx_info;
8903 /* Swap token stuff */
8905 diff -NurpP --minimal linux-2.6.32.56/include/linux/mount.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/mount.h
8906 --- linux-2.6.32.56/include/linux/mount.h 2009-09-10 15:26:25.000000000 +0200
8907 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/mount.h 2011-06-10 13:03:02.000000000 +0200
8908 @@ -36,6 +36,9 @@ struct mnt_namespace;
8909 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8910 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8912 +#define MNT_TAGID 0x10000
8913 +#define MNT_NOTAG 0x20000
8916 struct list_head mnt_hash;
8917 struct vfsmount *mnt_parent; /* fs we are mounted on */
8918 @@ -70,6 +73,7 @@ struct vfsmount {
8922 + tag_t mnt_tag; /* tagging used for vfsmount */
8925 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
8926 diff -NurpP --minimal linux-2.6.32.56/include/linux/net.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/net.h
8927 --- linux-2.6.32.56/include/linux/net.h 2009-12-03 20:02:55.000000000 +0100
8928 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/net.h 2011-06-10 13:03:02.000000000 +0200
8929 @@ -69,6 +69,7 @@ struct net;
8930 #define SOCK_NOSPACE 2
8931 #define SOCK_PASSCRED 3
8932 #define SOCK_PASSSEC 4
8933 +#define SOCK_USER_SOCKET 5
8935 #ifndef ARCH_HAS_SOCKET_TYPES
8937 diff -NurpP --minimal linux-2.6.32.56/include/linux/nfs_mount.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/nfs_mount.h
8938 --- linux-2.6.32.56/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
8939 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/nfs_mount.h 2011-06-10 13:03:02.000000000 +0200
8940 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8941 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8942 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8943 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8944 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8945 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8946 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8948 /* The following are for internal use only */
8949 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8950 diff -NurpP --minimal linux-2.6.32.56/include/linux/nsproxy.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/nsproxy.h
8951 --- linux-2.6.32.56/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
8952 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/nsproxy.h 2011-06-10 13:03:02.000000000 +0200
8955 #include <linux/spinlock.h>
8956 #include <linux/sched.h>
8957 +#include <linux/vserver/debug.h>
8959 struct mnt_namespace;
8960 struct uts_namespace;
8961 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8964 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8965 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8966 void exit_task_namespaces(struct task_struct *tsk);
8967 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8968 void free_nsproxy(struct nsproxy *ns);
8969 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8970 struct fs_struct *);
8972 -static inline void put_nsproxy(struct nsproxy *ns)
8973 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8975 +static inline void __get_nsproxy(struct nsproxy *ns,
8976 + const char *_file, int _line)
8978 - if (atomic_dec_and_test(&ns->count)) {
8981 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8982 + ns, atomic_read(&ns->count), _file, _line);
8983 + atomic_inc(&ns->count);
8986 -static inline void get_nsproxy(struct nsproxy *ns)
8987 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8989 +static inline void __put_nsproxy(struct nsproxy *ns,
8990 + const char *_file, int _line)
8992 - atomic_inc(&ns->count);
8993 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8994 + ns, atomic_read(&ns->count), _file, _line);
8995 + if (atomic_dec_and_test(&ns->count)) {
9000 #ifdef CONFIG_CGROUP_NS
9001 diff -NurpP --minimal linux-2.6.32.56/include/linux/pid.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/pid.h
9002 --- linux-2.6.32.56/include/linux/pid.h 2012-02-09 10:22:31.000000000 +0100
9003 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/pid.h 2011-06-10 13:03:02.000000000 +0200
9004 @@ -8,7 +8,8 @@ enum pid_type
9014 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9017 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9018 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9019 pid_t pid_vnr(struct pid *pid);
9021 #define do_each_pid_task(pid, type, task) \
9022 diff -NurpP --minimal linux-2.6.32.56/include/linux/proc_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/proc_fs.h
9023 --- linux-2.6.32.56/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9024 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/proc_fs.h 2011-06-10 13:03:02.000000000 +0200
9025 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9031 const struct inode_operations *proc_iops;
9033 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9034 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9041 int (*proc_get_link)(struct inode *, struct path *);
9042 int (*proc_read)(struct task_struct *task, char *page);
9043 int (*proc_show)(struct seq_file *m,
9044 struct pid_namespace *ns, struct pid *pid,
9045 struct task_struct *task);
9046 + int (*proc_vs_read)(char *page);
9047 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9048 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9051 struct ctl_table_header;
9052 @@ -263,6 +270,7 @@ struct ctl_table;
9059 struct proc_dir_entry *pde;
9060 diff -NurpP --minimal linux-2.6.32.56/include/linux/quotaops.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/quotaops.h
9061 --- linux-2.6.32.56/include/linux/quotaops.h 2012-02-09 10:22:31.000000000 +0100
9062 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/quotaops.h 2011-06-10 13:03:02.000000000 +0200
9064 #define _LINUX_QUOTAOPS_
9066 #include <linux/fs.h>
9067 +#include <linux/vs_dlimit.h>
9069 static inline struct quota_info *sb_dqopt(struct super_block *sb)
9071 @@ -157,10 +158,14 @@ static inline void vfs_dq_init(struct in
9072 * a transaction (deadlocks possible otherwise) */
9073 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9075 + if (dl_alloc_space(inode, nr))
9077 if (sb_any_quota_active(inode->i_sb)) {
9078 /* Used space is updated in alloc_space() */
9079 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
9080 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) {
9081 + dl_free_space(inode, nr);
9086 inode_add_bytes(inode, nr);
9087 @@ -177,10 +182,14 @@ static inline int vfs_dq_prealloc_space(
9089 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9091 + if (dl_alloc_space(inode, nr))
9093 if (sb_any_quota_active(inode->i_sb)) {
9094 /* Used space is updated in alloc_space() */
9095 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
9096 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) {
9097 + dl_free_space(inode, nr);
9102 inode_add_bytes(inode, nr);
9103 @@ -197,10 +206,14 @@ static inline int vfs_dq_alloc_space(str
9105 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9107 + if (dl_reserve_space(inode, nr))
9109 if (sb_any_quota_active(inode->i_sb)) {
9110 /* Used space is updated in alloc_space() */
9111 - if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
9112 + if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) {
9113 + dl_release_space(inode, nr);
9118 inode_add_rsv_space(inode, nr);
9119 @@ -209,10 +222,14 @@ static inline int vfs_dq_reserve_space(s
9121 static inline int vfs_dq_alloc_inode(struct inode *inode)
9123 + if (dl_alloc_inode(inode))
9125 if (sb_any_quota_active(inode->i_sb)) {
9127 - if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
9128 + if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
9129 + dl_free_inode(inode);
9135 @@ -222,9 +239,13 @@ static inline int vfs_dq_alloc_inode(str
9137 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9139 + if (dl_claim_space(inode, nr))
9141 if (sb_any_quota_active(inode->i_sb)) {
9142 - if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
9143 + if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
9144 + dl_release_space(inode, nr);
9148 inode_claim_rsv_space(inode, nr);
9150 @@ -242,6 +263,7 @@ void vfs_dq_release_reservation_space(st
9151 inode->i_sb->dq_op->release_rsv(inode, nr);
9153 inode_sub_rsv_space(inode, nr);
9154 + dl_release_space(inode, nr);
9157 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9158 @@ -250,6 +272,7 @@ static inline void vfs_dq_free_space_nod
9159 inode->i_sb->dq_op->free_space(inode, nr);
9161 inode_sub_bytes(inode, nr);
9162 + dl_free_space(inode, nr);
9165 static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
9166 @@ -262,6 +285,7 @@ static inline void vfs_dq_free_inode(str
9168 if (sb_any_quota_active(inode->i_sb))
9169 inode->i_sb->dq_op->free_inode(inode, 1);
9170 + dl_free_inode(inode);
9173 /* Cannot be called inside a transaction */
9174 @@ -365,6 +389,8 @@ static inline int vfs_dq_transfer(struct
9176 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9178 + if (dl_alloc_space(inode, nr))
9180 inode_add_bytes(inode, nr);
9183 @@ -378,6 +404,8 @@ static inline int vfs_dq_prealloc_space(
9185 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9187 + if (dl_alloc_space(inode, nr))
9189 inode_add_bytes(inode, nr);
9192 @@ -391,22 +419,28 @@ static inline int vfs_dq_alloc_space(str
9194 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9196 + if (dl_reserve_space(inode, nr))
9201 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9203 + if (dl_claim_space(inode, nr))
9205 return vfs_dq_alloc_space(inode, nr);
9209 int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
9211 + dl_release_space(inode, nr);
9215 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9217 + dl_free_space(inode, nr);
9218 inode_sub_bytes(inode, nr);
9221 diff -NurpP --minimal linux-2.6.32.56/include/linux/reboot.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/reboot.h
9222 --- linux-2.6.32.56/include/linux/reboot.h 2008-12-25 00:26:37.000000000 +0100
9223 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/reboot.h 2011-06-10 13:03:02.000000000 +0200
9225 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9226 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9227 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9228 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9232 diff -NurpP --minimal linux-2.6.32.56/include/linux/reiserfs_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/reiserfs_fs.h
9233 --- linux-2.6.32.56/include/linux/reiserfs_fs.h 2009-09-10 15:26:26.000000000 +0200
9234 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/reiserfs_fs.h 2011-06-10 13:03:02.000000000 +0200
9235 @@ -899,6 +899,11 @@ struct stat_data_v1 {
9236 #define REISERFS_COMPR_FL FS_COMPR_FL
9237 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9239 +/* unfortunately reiserfs sdattr is only 16 bit */
9240 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9241 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9242 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9244 /* persistent flags that file inherits from the parent directory */
9245 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9246 REISERFS_SYNC_FL | \
9247 @@ -908,6 +913,9 @@ struct stat_data_v1 {
9248 REISERFS_COMPR_FL | \
9249 REISERFS_NOTAIL_FL )
9251 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9252 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9254 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9257 @@ -1989,6 +1997,7 @@ static inline void reiserfs_update_sd(st
9258 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9259 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9260 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9261 +int reiserfs_sync_flags(struct inode *inode, int, int);
9264 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9265 diff -NurpP --minimal linux-2.6.32.56/include/linux/reiserfs_fs_sb.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/reiserfs_fs_sb.h
9266 --- linux-2.6.32.56/include/linux/reiserfs_fs_sb.h 2009-09-10 15:26:26.000000000 +0200
9267 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/reiserfs_fs_sb.h 2011-06-10 13:03:02.000000000 +0200
9268 @@ -456,6 +456,7 @@ enum reiserfs_mount_options {
9269 REISERFS_EXPOSE_PRIVROOT,
9270 REISERFS_BARRIER_NONE,
9271 REISERFS_BARRIER_FLUSH,
9274 /* Actions on error */
9275 REISERFS_ERROR_PANIC,
9276 diff -NurpP --minimal linux-2.6.32.56/include/linux/sched.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sched.h
9277 --- linux-2.6.32.56/include/linux/sched.h 2012-02-09 10:22:31.000000000 +0100
9278 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sched.h 2011-06-10 13:03:02.000000000 +0200
9279 @@ -389,25 +389,28 @@ extern void arch_unmap_area_topdown(stru
9280 * The mm counters are not protected by its page_table_lock,
9281 * so must be incremented atomically.
9283 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9284 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9285 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9286 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9287 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9288 +#define __set_mm_counter(mm, member, value) \
9289 + atomic_long_set(&(mm)->_##member, value)
9290 +#define get_mm_counter(mm, member) \
9291 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9293 #else /* !USE_SPLIT_PTLOCKS */
9295 * The mm counters are protected by its page_table_lock,
9296 * so can be incremented directly.
9298 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9299 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9300 #define get_mm_counter(mm, member) ((mm)->_##member)
9301 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9302 -#define inc_mm_counter(mm, member) (mm)->_##member++
9303 -#define dec_mm_counter(mm, member) (mm)->_##member--
9305 #endif /* !USE_SPLIT_PTLOCKS */
9307 +#define set_mm_counter(mm, member, value) \
9308 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9309 +#define add_mm_counter(mm, member, value) \
9310 + vx_ ## member ## pages_add((mm), (value))
9311 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9312 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9314 #define get_mm_rss(mm) \
9315 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9316 #define update_hiwater_rss(mm) do { \
9317 @@ -1185,6 +1188,12 @@ struct sched_entity {
9318 u64 nr_wakeups_affine_attempts;
9319 u64 nr_wakeups_passive;
9320 u64 nr_wakeups_idle;
9321 +#ifdef CONFIG_CFS_HARD_LIMITS
9322 + u64 throttle_start;
9324 + u64 throttle_count;
9329 #ifdef CONFIG_FAIR_GROUP_SCHED
9330 @@ -1395,6 +1404,14 @@ struct task_struct {
9334 +/* vserver context data */
9335 + struct vx_info *vx_info;
9336 + struct nx_info *nx_info;
9342 /* Thread group tracking */
9345 @@ -1619,6 +1636,11 @@ struct pid_namespace;
9346 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9347 struct pid_namespace *ns);
9349 +#include <linux/vserver/base.h>
9350 +#include <linux/vserver/context.h>
9351 +#include <linux/vserver/debug.h>
9352 +#include <linux/vserver/pid.h>
9354 static inline pid_t task_pid_nr(struct task_struct *tsk)
9357 @@ -1632,7 +1654,8 @@ static inline pid_t task_pid_nr_ns(struc
9359 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9361 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9362 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9363 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9367 @@ -1645,7 +1668,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9369 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9371 - return pid_vnr(task_tgid(tsk));
9372 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9376 diff -NurpP --minimal linux-2.6.32.56/include/linux/shmem_fs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/shmem_fs.h
9377 --- linux-2.6.32.56/include/linux/shmem_fs.h 2009-12-03 20:02:56.000000000 +0100
9378 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/shmem_fs.h 2011-06-10 13:03:02.000000000 +0200
9381 #define SHMEM_NR_DIRECT 16
9383 +#define TMPFS_SUPER_MAGIC 0x01021994
9386 struct shmem_inode_info {
9388 unsigned long flags;
9389 diff -NurpP --minimal linux-2.6.32.56/include/linux/stat.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/stat.h
9390 --- linux-2.6.32.56/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9391 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/stat.h 2011-06-10 13:03:02.000000000 +0200
9392 @@ -66,6 +66,7 @@ struct kstat {
9399 struct timespec atime;
9400 diff -NurpP --minimal linux-2.6.32.56/include/linux/sunrpc/auth.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sunrpc/auth.h
9401 --- linux-2.6.32.56/include/linux/sunrpc/auth.h 2009-12-03 20:02:56.000000000 +0100
9402 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sunrpc/auth.h 2011-06-10 13:03:02.000000000 +0200
9408 struct group_info *group_info;
9409 unsigned char machine_cred : 1;
9411 diff -NurpP --minimal linux-2.6.32.56/include/linux/sunrpc/clnt.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sunrpc/clnt.h
9412 --- linux-2.6.32.56/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
9413 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sunrpc/clnt.h 2011-06-10 13:03:02.000000000 +0200
9414 @@ -49,7 +49,8 @@ struct rpc_clnt {
9415 unsigned int cl_softrtry : 1,/* soft timeouts */
9416 cl_discrtry : 1,/* disconnect before retry */
9417 cl_autobind : 1,/* use getport() */
9418 - cl_chatty : 1;/* be verbose */
9419 + cl_chatty : 1,/* be verbose */
9420 + cl_tag : 1;/* context tagging */
9422 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9423 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9424 diff -NurpP --minimal linux-2.6.32.56/include/linux/syscalls.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/syscalls.h
9425 --- linux-2.6.32.56/include/linux/syscalls.h 2012-02-09 10:22:32.000000000 +0100
9426 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/syscalls.h 2011-06-10 13:03:02.000000000 +0200
9427 @@ -548,6 +548,8 @@ asmlinkage long sys_symlink(const char _
9428 asmlinkage long sys_unlink(const char __user *pathname);
9429 asmlinkage long sys_rename(const char __user *oldname,
9430 const char __user *newname);
9431 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9433 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9434 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9436 diff -NurpP --minimal linux-2.6.32.56/include/linux/sysctl.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sysctl.h
9437 --- linux-2.6.32.56/include/linux/sysctl.h 2012-02-09 10:22:32.000000000 +0100
9438 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sysctl.h 2011-06-10 13:03:02.000000000 +0200
9439 @@ -69,6 +69,7 @@ enum
9440 CTL_ABI=9, /* Binary emulation */
9441 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9442 CTL_ARLAN=254, /* arlan wireless driver */
9443 + CTL_VSERVER=4242, /* Linux-VServer debug */
9444 CTL_S390DBF=5677, /* s390 debug */
9445 CTL_SUNRPC=7249, /* sunrpc debug */
9446 CTL_PM=9899, /* frv power management */
9447 @@ -103,6 +104,7 @@ enum
9449 KERN_PANIC=15, /* int: panic timeout */
9450 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9451 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9453 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9454 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9455 diff -NurpP --minimal linux-2.6.32.56/include/linux/sysfs.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sysfs.h
9456 --- linux-2.6.32.56/include/linux/sysfs.h 2008-12-25 00:26:37.000000000 +0100
9457 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/sysfs.h 2011-06-10 13:03:02.000000000 +0200
9459 #include <linux/list.h>
9460 #include <asm/atomic.h>
9462 +#define SYSFS_SUPER_MAGIC 0x62656572
9467 diff -NurpP --minimal linux-2.6.32.56/include/linux/time.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/time.h
9468 --- linux-2.6.32.56/include/linux/time.h 2012-02-09 10:22:32.000000000 +0100
9469 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/time.h 2011-06-10 13:03:02.000000000 +0200
9470 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
9471 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9475 +#include <linux/vs_time.h>
9477 #endif /* __KERNEL__ */
9479 #define NFDBITS __NFDBITS
9480 diff -NurpP --minimal linux-2.6.32.56/include/linux/types.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/types.h
9481 --- linux-2.6.32.56/include/linux/types.h 2009-09-10 15:26:26.000000000 +0200
9482 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/types.h 2011-06-10 13:03:02.000000000 +0200
9483 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
9484 typedef __kernel_gid32_t gid_t;
9485 typedef __kernel_uid16_t uid16_t;
9486 typedef __kernel_gid16_t gid16_t;
9487 +typedef unsigned int xid_t;
9488 +typedef unsigned int nid_t;
9489 +typedef unsigned int tag_t;
9491 typedef unsigned long uintptr_t;
9493 diff -NurpP --minimal linux-2.6.32.56/include/linux/vroot.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vroot.h
9494 --- linux-2.6.32.56/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9495 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vroot.h 2011-06-10 13:03:02.000000000 +0200
9499 + * include/linux/vroot.h
9501 + * written by Herbert Pötzl, 9/11/2002
9502 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9504 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9505 + * Redistribution of this file is permitted under the
9506 + * GNU General Public License.
9509 +#ifndef _LINUX_VROOT_H
9510 +#define _LINUX_VROOT_H
9515 +/* Possible states of device */
9521 +struct vroot_device {
9525 + struct semaphore vr_ctl_mutex;
9526 + struct block_device *vr_device;
9531 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9533 +extern int register_vroot_grb(vroot_grb_func *);
9534 +extern int unregister_vroot_grb(vroot_grb_func *);
9536 +#endif /* __KERNEL__ */
9538 +#define MAX_VROOT_DEFAULT 8
9541 + * IOCTL commands --- we will commandeer 0x56 ('V')
9544 +#define VROOT_SET_DEV 0x5600
9545 +#define VROOT_CLR_DEV 0x5601
9547 +#endif /* _LINUX_VROOT_H */
9548 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_base.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_base.h
9549 --- linux-2.6.32.56/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9550 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_base.h 2011-06-10 13:03:02.000000000 +0200
9555 +#include "vserver/base.h"
9556 +#include "vserver/check.h"
9557 +#include "vserver/debug.h"
9560 +#warning duplicate inclusion
9562 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_context.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_context.h
9563 --- linux-2.6.32.56/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9564 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_context.h 2011-06-10 13:03:02.000000000 +0200
9566 +#ifndef _VS_CONTEXT_H
9567 +#define _VS_CONTEXT_H
9569 +#include "vserver/base.h"
9570 +#include "vserver/check.h"
9571 +#include "vserver/context.h"
9572 +#include "vserver/history.h"
9573 +#include "vserver/debug.h"
9575 +#include <linux/sched.h>
9578 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9580 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9581 + const char *_file, int _line, void *_here)
9586 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9587 + vxi, vxi ? vxi->vx_id : 0,
9588 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9590 + __vxh_get_vx_info(vxi, _here);
9592 + atomic_inc(&vxi->vx_usecnt);
9597 +extern void free_vx_info(struct vx_info *);
9599 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9601 +static inline void __put_vx_info(struct vx_info *vxi,
9602 + const char *_file, int _line, void *_here)
9607 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9608 + vxi, vxi ? vxi->vx_id : 0,
9609 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9611 + __vxh_put_vx_info(vxi, _here);
9613 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9614 + free_vx_info(vxi);
9618 +#define init_vx_info(p, i) \
9619 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9621 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9622 + const char *_file, int _line, void *_here)
9625 + vxlprintk(VXD_CBIT(xid, 3),
9626 + "init_vx_info(%p[#%d.%d])",
9627 + vxi, vxi ? vxi->vx_id : 0,
9628 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9630 + __vxh_init_vx_info(vxi, vxp, _here);
9632 + atomic_inc(&vxi->vx_usecnt);
9638 +#define set_vx_info(p, i) \
9639 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9641 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9642 + const char *_file, int _line, void *_here)
9644 + struct vx_info *vxo;
9649 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9650 + vxi, vxi ? vxi->vx_id : 0,
9651 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9653 + __vxh_set_vx_info(vxi, vxp, _here);
9655 + atomic_inc(&vxi->vx_usecnt);
9656 + vxo = xchg(vxp, vxi);
9661 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9663 +static inline void __clr_vx_info(struct vx_info **vxp,
9664 + const char *_file, int _line, void *_here)
9666 + struct vx_info *vxo;
9668 + vxo = xchg(vxp, NULL);
9672 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9673 + vxo, vxo ? vxo->vx_id : 0,
9674 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9676 + __vxh_clr_vx_info(vxo, vxp, _here);
9678 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9679 + free_vx_info(vxo);
9683 +#define claim_vx_info(v, p) \
9684 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9686 +static inline void __claim_vx_info(struct vx_info *vxi,
9687 + struct task_struct *task,
9688 + const char *_file, int _line, void *_here)
9690 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9691 + vxi, vxi ? vxi->vx_id : 0,
9692 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9693 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9694 + task, _file, _line);
9695 + __vxh_claim_vx_info(vxi, task, _here);
9697 + atomic_inc(&vxi->vx_tasks);
9701 +extern void unhash_vx_info(struct vx_info *);
9703 +#define release_vx_info(v, p) \
9704 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9706 +static inline void __release_vx_info(struct vx_info *vxi,
9707 + struct task_struct *task,
9708 + const char *_file, int _line, void *_here)
9710 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9711 + vxi, vxi ? vxi->vx_id : 0,
9712 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9713 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9714 + task, _file, _line);
9715 + __vxh_release_vx_info(vxi, task, _here);
9719 + if (atomic_dec_and_test(&vxi->vx_tasks))
9720 + unhash_vx_info(vxi);
9724 +#define task_get_vx_info(p) \
9725 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9727 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9728 + const char *_file, int _line, void *_here)
9730 + struct vx_info *vxi;
9733 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9735 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9741 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9743 + if (waitqueue_active(&vxi->vx_wait))
9744 + wake_up_interruptible(&vxi->vx_wait);
9748 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9750 +static inline void __enter_vx_info(struct vx_info *vxi,
9751 + struct vx_info_save *vxis, const char *_file, int _line)
9753 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9754 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9755 + current->xid, current->vx_info, _file, _line);
9756 + vxis->vxi = xchg(¤t->vx_info, vxi);
9757 + vxis->xid = current->xid;
9758 + current->xid = vxi ? vxi->vx_id : 0;
9761 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9763 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9764 + const char *_file, int _line)
9766 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9767 + vxis, vxis->xid, vxis->vxi, current,
9768 + current->xid, current->vx_info, _file, _line);
9769 + (void)xchg(¤t->vx_info, vxis->vxi);
9770 + current->xid = vxis->xid;
9774 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9776 + vxis->vxi = xchg(¤t->vx_info, NULL);
9777 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9780 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9782 + (void)xchg(¤t->xid, vxis->xid);
9783 + (void)xchg(¤t->vx_info, vxis->vxi);
9786 +#define task_is_init(p) \
9787 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9789 +static inline int __task_is_init(struct task_struct *p,
9790 + const char *_file, int _line, void *_here)
9792 + int is_init = is_global_init(p);
9796 + is_init = p->vx_info->vx_initpid == p->pid;
9801 +extern void exit_vx_info(struct task_struct *, int);
9802 +extern void exit_vx_info_early(struct task_struct *, int);
9806 +#warning duplicate inclusion
9808 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_cowbl.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_cowbl.h
9809 --- linux-2.6.32.56/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9810 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_cowbl.h 2011-06-10 13:03:02.000000000 +0200
9812 +#ifndef _VS_COWBL_H
9813 +#define _VS_COWBL_H
9815 +#include <linux/fs.h>
9816 +#include <linux/dcache.h>
9817 +#include <linux/namei.h>
9819 +extern struct dentry *cow_break_link(const char *pathname);
9821 +static inline int cow_check_and_break(struct path *path)
9823 + struct inode *inode = path->dentry->d_inode;
9826 + /* do we need this check? */
9827 + if (IS_RDONLY(inode))
9830 + if (IS_COW(inode)) {
9831 + if (IS_COW_LINK(inode)) {
9832 + struct dentry *new_dentry, *old_dentry = path->dentry;
9835 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9839 + pp = d_path(path, buf, PATH_MAX);
9840 + new_dentry = cow_break_link(pp);
9842 + if (!IS_ERR(new_dentry)) {
9843 + path->dentry = new_dentry;
9846 + error = PTR_ERR(new_dentry);
9848 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9849 + inode->i_ctime = CURRENT_TIME;
9850 + mark_inode_dirty(inode);
9857 +#warning duplicate inclusion
9859 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_cvirt.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_cvirt.h
9860 --- linux-2.6.32.56/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9861 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_cvirt.h 2011-06-10 13:03:02.000000000 +0200
9863 +#ifndef _VS_CVIRT_H
9864 +#define _VS_CVIRT_H
9866 +#include "vserver/cvirt.h"
9867 +#include "vserver/context.h"
9868 +#include "vserver/base.h"
9869 +#include "vserver/check.h"
9870 +#include "vserver/debug.h"
9873 +static inline void vx_activate_task(struct task_struct *p)
9875 + struct vx_info *vxi;
9877 + if ((vxi = p->vx_info)) {
9878 + vx_update_load(vxi);
9879 + atomic_inc(&vxi->cvirt.nr_running);
9883 +static inline void vx_deactivate_task(struct task_struct *p)
9885 + struct vx_info *vxi;
9887 + if ((vxi = p->vx_info)) {
9888 + vx_update_load(vxi);
9889 + atomic_dec(&vxi->cvirt.nr_running);
9893 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9895 + struct vx_info *vxi;
9897 + if ((vxi = p->vx_info))
9898 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9901 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9903 + struct vx_info *vxi;
9905 + if ((vxi = p->vx_info))
9906 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9911 +#warning duplicate inclusion
9913 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_device.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_device.h
9914 --- linux-2.6.32.56/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9915 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_device.h 2011-06-10 13:03:02.000000000 +0200
9917 +#ifndef _VS_DEVICE_H
9918 +#define _VS_DEVICE_H
9920 +#include "vserver/base.h"
9921 +#include "vserver/device.h"
9922 +#include "vserver/debug.h"
9925 +#ifdef CONFIG_VSERVER_DEVICE
9927 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9929 +#define vs_device_perm(v, d, m, p) \
9930 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9935 +int vs_map_device(struct vx_info *vxi,
9936 + dev_t device, dev_t *target, umode_t mode)
9943 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9948 +#define vs_map_chrdev(d, t, p) \
9949 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9950 +#define vs_map_blkdev(d, t, p) \
9951 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9953 +#define vs_chrdev_perm(d, p) \
9954 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9955 +#define vs_blkdev_perm(d, p) \
9956 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9960 +#warning duplicate inclusion
9962 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_dlimit.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_dlimit.h
9963 --- linux-2.6.32.56/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9964 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_dlimit.h 2011-06-10 13:03:02.000000000 +0200
9966 +#ifndef _VS_DLIMIT_H
9967 +#define _VS_DLIMIT_H
9969 +#include <linux/fs.h>
9971 +#include "vserver/dlimit.h"
9972 +#include "vserver/base.h"
9973 +#include "vserver/debug.h"
9976 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9978 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9979 + const char *_file, int _line)
9983 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9984 + dli, dli ? dli->dl_tag : 0,
9985 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9987 + atomic_inc(&dli->dl_usecnt);
9992 +#define free_dl_info(i) \
9993 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9995 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9997 +static inline void __put_dl_info(struct dl_info *dli,
9998 + const char *_file, int _line)
10002 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10003 + dli, dli ? dli->dl_tag : 0,
10004 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10006 + if (atomic_dec_and_test(&dli->dl_usecnt))
10007 + free_dl_info(dli);
10011 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10013 +static inline int __dl_alloc_space(struct super_block *sb,
10014 + tag_t tag, dlsize_t nr, const char *file, int line)
10016 + struct dl_info *dli = NULL;
10021 + dli = locate_dl_info(sb, tag);
10025 + spin_lock(&dli->dl_lock);
10026 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10028 + dli->dl_space_used += nr;
10029 + spin_unlock(&dli->dl_lock);
10030 + put_dl_info(dli);
10032 + vxlprintk(VXD_CBIT(dlim, 1),
10033 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10034 + sb, tag, __dlimit_char(dli), (long long)nr,
10035 + ret, file, line);
10039 +static inline void __dl_free_space(struct super_block *sb,
10040 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10042 + struct dl_info *dli = NULL;
10046 + dli = locate_dl_info(sb, tag);
10050 + spin_lock(&dli->dl_lock);
10051 + if (dli->dl_space_used > nr)
10052 + dli->dl_space_used -= nr;
10054 + dli->dl_space_used = 0;
10055 + spin_unlock(&dli->dl_lock);
10056 + put_dl_info(dli);
10058 + vxlprintk(VXD_CBIT(dlim, 1),
10059 + "FREE (%p,#%d)%c %lld bytes",
10060 + sb, tag, __dlimit_char(dli), (long long)nr,
10064 +static inline int __dl_alloc_inode(struct super_block *sb,
10065 + tag_t tag, const char *_file, int _line)
10067 + struct dl_info *dli;
10070 + dli = locate_dl_info(sb, tag);
10074 + spin_lock(&dli->dl_lock);
10075 + dli->dl_inodes_used++;
10076 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
10077 + spin_unlock(&dli->dl_lock);
10078 + put_dl_info(dli);
10080 + vxlprintk(VXD_CBIT(dlim, 0),
10081 + "ALLOC (%p,#%d)%c inode (%d)",
10082 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10086 +static inline void __dl_free_inode(struct super_block *sb,
10087 + tag_t tag, const char *_file, int _line)
10089 + struct dl_info *dli;
10091 + dli = locate_dl_info(sb, tag);
10095 + spin_lock(&dli->dl_lock);
10096 + if (dli->dl_inodes_used > 1)
10097 + dli->dl_inodes_used--;
10099 + dli->dl_inodes_used = 0;
10100 + spin_unlock(&dli->dl_lock);
10101 + put_dl_info(dli);
10103 + vxlprintk(VXD_CBIT(dlim, 0),
10104 + "FREE (%p,#%d)%c inode",
10105 + sb, tag, __dlimit_char(dli), _file, _line);
10108 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10109 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10110 + const char *_file, int _line)
10112 + struct dl_info *dli;
10113 + uint64_t broot, bfree;
10115 + dli = locate_dl_info(sb, tag);
10119 + spin_lock(&dli->dl_lock);
10120 + broot = (dli->dl_space_total -
10121 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10122 + >> sb->s_blocksize_bits;
10123 + bfree = (dli->dl_space_total - dli->dl_space_used)
10124 + >> sb->s_blocksize_bits;
10125 + spin_unlock(&dli->dl_lock);
10127 + vxlprintk(VXD_CBIT(dlim, 2),
10128 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10129 + (long long)bfree, (long long)broot,
10130 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10132 + if (free_blocks) {
10133 + if (*free_blocks > bfree)
10134 + *free_blocks = bfree;
10136 + if (root_blocks) {
10137 + if (*root_blocks > broot)
10138 + *root_blocks = broot;
10140 + put_dl_info(dli);
10143 +#define dl_prealloc_space(in, bytes) \
10144 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10145 + __FILE__, __LINE__ )
10147 +#define dl_alloc_space(in, bytes) \
10148 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10149 + __FILE__, __LINE__ )
10151 +#define dl_reserve_space(in, bytes) \
10152 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10153 + __FILE__, __LINE__ )
10155 +#define dl_claim_space(in, bytes) (0)
10157 +#define dl_release_space(in, bytes) \
10158 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10159 + __FILE__, __LINE__ )
10161 +#define dl_free_space(in, bytes) \
10162 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10163 + __FILE__, __LINE__ )
10167 +#define dl_alloc_inode(in) \
10168 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10170 +#define dl_free_inode(in) \
10171 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10174 +#define dl_adjust_block(sb, tag, fb, rb) \
10175 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10179 +#warning duplicate inclusion
10181 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_inet.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_inet.h
10182 --- linux-2.6.32.56/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
10183 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_inet.h 2011-06-10 13:03:02.000000000 +0200
10185 +#ifndef _VS_INET_H
10186 +#define _VS_INET_H
10188 +#include "vserver/base.h"
10189 +#include "vserver/network.h"
10190 +#include "vserver/debug.h"
10192 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
10194 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
10195 + NIPQUAD((a)->mask), (a)->type
10196 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
10200 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
10202 + __be32 ip = nxa->ip[0].s_addr;
10203 + __be32 mask = nxa->mask.s_addr;
10204 + __be32 bcast = ip | ~mask;
10207 + switch (nxa->type & tmask) {
10208 + case NXA_TYPE_MASK:
10209 + ret = (ip == (addr & mask));
10211 + case NXA_TYPE_ADDR:
10215 + /* fall through to broadcast */
10216 + case NXA_MOD_BCAST:
10217 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
10219 + case NXA_TYPE_RANGE:
10220 + ret = ((nxa->ip[0].s_addr <= addr) &&
10221 + (nxa->ip[1].s_addr > addr));
10223 + case NXA_TYPE_ANY:
10228 + vxdprintk(VXD_CBIT(net, 0),
10229 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
10230 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
10235 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
10237 + struct nx_addr_v4 *nxa;
10244 + /* allow 127.0.0.1 when remapping lback */
10245 + if ((tmask & NXA_LOOPBACK) &&
10246 + (addr == IPI_LOOPBACK) &&
10247 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10250 + /* check for lback address */
10251 + if ((tmask & NXA_MOD_LBACK) &&
10252 + (nxi->v4_lback.s_addr == addr))
10255 + /* check for broadcast address */
10256 + if ((tmask & NXA_MOD_BCAST) &&
10257 + (nxi->v4_bcast.s_addr == addr))
10260 + /* check for v4 addresses */
10261 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
10262 + if (v4_addr_match(nxa, addr, tmask))
10266 + vxdprintk(VXD_CBIT(net, 0),
10267 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
10268 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
10273 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
10275 + /* FIXME: needs full range checks */
10276 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
10280 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
10282 + struct nx_addr_v4 *ptr;
10284 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
10285 + if (v4_nx_addr_match(ptr, nxa, mask))
10290 +#include <net/inet_sock.h>
10293 + * Check if a given address matches for a socket
10295 + * nxi: the socket's nx_info if any
10296 + * addr: to be verified address
10299 +int v4_sock_addr_match (
10300 + struct nx_info *nxi,
10301 + struct inet_sock *inet,
10304 + __be32 saddr = inet->rcv_saddr;
10305 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
10307 + if (addr && (saddr == addr || bcast == addr))
10310 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
10315 +/* inet related checks and helpers */
10319 +struct net_device;
10322 +#ifdef CONFIG_INET
10324 +#include <linux/netdevice.h>
10325 +#include <linux/inetdevice.h>
10326 +#include <net/inet_sock.h>
10327 +#include <net/inet_timewait_sock.h>
10330 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10331 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
10332 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
10336 + * check if address is covered by socket
10338 + * sk: the socket to check against
10339 + * addr: the address in question (must be != 0)
10343 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
10345 + struct nx_info *nxi = sk->sk_nx_info;
10346 + __be32 saddr = inet_rcv_saddr(sk);
10348 + vxdprintk(VXD_CBIT(net, 5),
10349 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
10350 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
10351 + (sk->sk_socket?sk->sk_socket->flags:0));
10353 + if (saddr) { /* direct address match */
10354 + return v4_addr_match(nxa, saddr, -1);
10355 + } else if (nxi) { /* match against nx_info */
10356 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
10357 + } else { /* unrestricted any socket */
10365 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
10367 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
10368 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
10369 + nxi ? dev_in_nx_info(dev, nxi) : 0);
10371 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10373 + if (dev_in_nx_info(dev, nxi))
10380 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
10386 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
10390 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
10392 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
10393 + nxi, nxi ? nxi->nx_id : 0, ifa,
10394 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
10396 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10398 + if (v4_ifa_in_nx_info(ifa, nxi))
10404 +struct nx_v4_sock_addr {
10405 + __be32 saddr; /* Address used for validation */
10406 + __be32 baddr; /* Address used for socket bind */
10410 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
10411 + struct nx_v4_sock_addr *nsa)
10413 + struct sock *sk = &inet->sk;
10414 + struct nx_info *nxi = sk->sk_nx_info;
10415 + __be32 saddr = addr->sin_addr.s_addr;
10416 + __be32 baddr = saddr;
10418 + vxdprintk(VXD_CBIT(net, 3),
10419 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10420 + sk, sk->sk_nx_info, sk->sk_socket,
10421 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10425 + if (saddr == INADDR_ANY) {
10426 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10427 + baddr = nxi->v4.ip[0].s_addr;
10428 + } else if (saddr == IPI_LOOPBACK) {
10429 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10430 + baddr = nxi->v4_lback.s_addr;
10431 + } else { /* normal address bind */
10432 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10433 + return -EADDRNOTAVAIL;
10437 + vxdprintk(VXD_CBIT(net, 3),
10438 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10439 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10441 + nsa->saddr = saddr;
10442 + nsa->baddr = baddr;
10447 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10449 + inet->saddr = nsa->baddr;
10450 + inet->rcv_saddr = nsa->baddr;
10455 + * helper to simplify inet_lookup_listener
10457 + * nxi: the socket's nx_info if any
10458 + * addr: to be verified address
10459 + * saddr: socket address
10461 +static inline int v4_inet_addr_match (
10462 + struct nx_info *nxi,
10466 + if (addr && (saddr == addr))
10469 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10473 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10475 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10476 + (addr == nxi->v4_lback.s_addr))
10477 + return IPI_LOOPBACK;
10482 +int nx_info_has_v4(struct nx_info *nxi)
10486 + if (NX_IPV4(nxi))
10488 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10493 +#else /* CONFIG_INET */
10496 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10502 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10508 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10514 +int nx_info_has_v4(struct nx_info *nxi)
10519 +#endif /* CONFIG_INET */
10521 +#define current_nx_info_has_v4() \
10522 + nx_info_has_v4(current_nx_info())
10525 +// #warning duplicate inclusion
10527 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_inet6.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_inet6.h
10528 --- linux-2.6.32.56/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10529 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_inet6.h 2011-06-10 13:03:02.000000000 +0200
10531 +#ifndef _VS_INET6_H
10532 +#define _VS_INET6_H
10534 +#include "vserver/base.h"
10535 +#include "vserver/network.h"
10536 +#include "vserver/debug.h"
10538 +#include <net/ipv6.h>
10540 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10541 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10544 +#ifdef CONFIG_IPV6
10547 +int v6_addr_match(struct nx_addr_v6 *nxa,
10548 + const struct in6_addr *addr, uint16_t mask)
10552 + switch (nxa->type & mask) {
10553 + case NXA_TYPE_MASK:
10554 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10556 + case NXA_TYPE_ADDR:
10557 + ret = ipv6_addr_equal(&nxa->ip, addr);
10559 + case NXA_TYPE_ANY:
10563 + vxdprintk(VXD_CBIT(net, 0),
10564 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10565 + nxa, NXAV6(nxa), addr, mask, ret);
10570 +int v6_addr_in_nx_info(struct nx_info *nxi,
10571 + const struct in6_addr *addr, uint16_t mask)
10573 + struct nx_addr_v6 *nxa;
10578 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10579 + if (v6_addr_match(nxa, addr, mask))
10583 + vxdprintk(VXD_CBIT(net, 0),
10584 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10585 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10590 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10592 + /* FIXME: needs full range checks */
10593 + return v6_addr_match(nxa, &addr->ip, mask);
10597 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10599 + struct nx_addr_v6 *ptr;
10601 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10602 + if (v6_nx_addr_match(ptr, nxa, mask))
10609 + * Check if a given address matches for a socket
10611 + * nxi: the socket's nx_info if any
10612 + * addr: to be verified address
10615 +int v6_sock_addr_match (
10616 + struct nx_info *nxi,
10617 + struct inet_sock *inet,
10618 + struct in6_addr *addr)
10620 + struct sock *sk = &inet->sk;
10621 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10623 + if (!ipv6_addr_any(addr) &&
10624 + ipv6_addr_equal(saddr, addr))
10626 + if (ipv6_addr_any(saddr))
10627 + return v6_addr_in_nx_info(nxi, addr, -1);
10632 + * check if address is covered by socket
10634 + * sk: the socket to check against
10635 + * addr: the address in question (must be != 0)
10639 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10641 + struct nx_info *nxi = sk->sk_nx_info;
10642 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10644 + vxdprintk(VXD_CBIT(net, 5),
10645 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10646 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10647 + (sk->sk_socket?sk->sk_socket->flags:0));
10649 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10650 + return v6_addr_match(nxa, saddr, -1);
10651 + } else if (nxi) { /* match against nx_info */
10652 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10653 + } else { /* unrestricted any socket */
10659 +/* inet related checks and helpers */
10663 +struct net_device;
10667 +#include <linux/netdevice.h>
10668 +#include <linux/inetdevice.h>
10669 +#include <net/inet_timewait_sock.h>
10672 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10673 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10674 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10679 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10685 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10689 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10691 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10692 + nxi, nxi ? nxi->nx_id : 0, ifa,
10693 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10695 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10697 + if (v6_ifa_in_nx_info(ifa, nxi))
10703 +struct nx_v6_sock_addr {
10704 + struct in6_addr saddr; /* Address used for validation */
10705 + struct in6_addr baddr; /* Address used for socket bind */
10709 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10710 + struct nx_v6_sock_addr *nsa)
10712 + // struct sock *sk = &inet->sk;
10713 + // struct nx_info *nxi = sk->sk_nx_info;
10714 + struct in6_addr saddr = addr->sin6_addr;
10715 + struct in6_addr baddr = saddr;
10717 + nsa->saddr = saddr;
10718 + nsa->baddr = baddr;
10723 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10725 + // struct sock *sk = &inet->sk;
10726 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10728 + // *saddr = nsa->baddr;
10729 + // inet->saddr = nsa->baddr;
10733 +int nx_info_has_v6(struct nx_info *nxi)
10737 + if (NX_IPV6(nxi))
10742 +#else /* CONFIG_IPV6 */
10745 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10752 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10758 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10764 +int nx_info_has_v6(struct nx_info *nxi)
10769 +#endif /* CONFIG_IPV6 */
10771 +#define current_nx_info_has_v6() \
10772 + nx_info_has_v6(current_nx_info())
10775 +#warning duplicate inclusion
10777 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_limit.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_limit.h
10778 --- linux-2.6.32.56/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10779 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_limit.h 2011-06-10 13:03:02.000000000 +0200
10781 +#ifndef _VS_LIMIT_H
10782 +#define _VS_LIMIT_H
10784 +#include "vserver/limit.h"
10785 +#include "vserver/base.h"
10786 +#include "vserver/context.h"
10787 +#include "vserver/debug.h"
10788 +#include "vserver/context.h"
10789 +#include "vserver/limit_int.h"
10792 +#define vx_acc_cres(v, d, p, r) \
10793 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10795 +#define vx_acc_cres_cond(x, d, p, r) \
10796 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10797 + r, d, p, __FILE__, __LINE__)
10800 +#define vx_add_cres(v, a, p, r) \
10801 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10802 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10804 +#define vx_add_cres_cond(x, a, p, r) \
10805 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10806 + r, a, p, __FILE__, __LINE__)
10807 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10810 +/* process and file limits */
10812 +#define vx_nproc_inc(p) \
10813 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10815 +#define vx_nproc_dec(p) \
10816 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10818 +#define vx_files_inc(f) \
10819 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10821 +#define vx_files_dec(f) \
10822 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10824 +#define vx_locks_inc(l) \
10825 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10827 +#define vx_locks_dec(l) \
10828 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10830 +#define vx_openfd_inc(f) \
10831 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10833 +#define vx_openfd_dec(f) \
10834 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10837 +#define vx_cres_avail(v, n, r) \
10838 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10841 +#define vx_nproc_avail(n) \
10842 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10844 +#define vx_files_avail(n) \
10845 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10847 +#define vx_locks_avail(n) \
10848 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10850 +#define vx_openfd_avail(n) \
10851 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10854 +/* dentry limits */
10856 +#define vx_dentry_inc(d) do { \
10857 + if (atomic_read(&d->d_count) == 1) \
10858 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10861 +#define vx_dentry_dec(d) do { \
10862 + if (atomic_read(&d->d_count) == 0) \
10863 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10866 +#define vx_dentry_avail(n) \
10867 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10870 +/* socket limits */
10872 +#define vx_sock_inc(s) \
10873 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10875 +#define vx_sock_dec(s) \
10876 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10878 +#define vx_sock_avail(n) \
10879 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10882 +/* ipc resource limits */
10884 +#define vx_ipcmsg_add(v, u, a) \
10885 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10887 +#define vx_ipcmsg_sub(v, u, a) \
10888 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10890 +#define vx_ipcmsg_avail(v, a) \
10891 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10894 +#define vx_ipcshm_add(v, k, a) \
10895 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10897 +#define vx_ipcshm_sub(v, k, a) \
10898 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10900 +#define vx_ipcshm_avail(v, a) \
10901 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10904 +#define vx_semary_inc(a) \
10905 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10907 +#define vx_semary_dec(a) \
10908 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10911 +#define vx_nsems_add(a,n) \
10912 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10914 +#define vx_nsems_sub(a,n) \
10915 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10919 +#warning duplicate inclusion
10921 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_memory.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_memory.h
10922 --- linux-2.6.32.56/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10923 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_memory.h 2011-06-10 13:03:02.000000000 +0200
10925 +#ifndef _VS_MEMORY_H
10926 +#define _VS_MEMORY_H
10928 +#include "vserver/limit.h"
10929 +#include "vserver/base.h"
10930 +#include "vserver/context.h"
10931 +#include "vserver/debug.h"
10932 +#include "vserver/context.h"
10933 +#include "vserver/limit_int.h"
10936 +#define __acc_add_long(a, v) (*(v) += (a))
10937 +#define __acc_inc_long(v) (++*(v))
10938 +#define __acc_dec_long(v) (--*(v))
10940 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
10941 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
10942 +#define __acc_inc_atomic(v) atomic_long_inc(v)
10943 +#define __acc_dec_atomic(v) atomic_long_dec(v)
10944 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
10945 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
10946 +#define __acc_inc_atomic(v) __acc_inc_long(v)
10947 +#define __acc_dec_atomic(v) __acc_dec_long(v)
10948 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
10951 +#define vx_acc_page(m, d, v, r) do { \
10953 + __acc_inc_long(&(m)->v); \
10955 + __acc_dec_long(&(m)->v); \
10956 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
10959 +#define vx_acc_page_atomic(m, d, v, r) do { \
10961 + __acc_inc_atomic(&(m)->v); \
10963 + __acc_dec_atomic(&(m)->v); \
10964 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
10968 +#define vx_acc_pages(m, p, v, r) do { \
10969 + unsigned long __p = (p); \
10970 + __acc_add_long(__p, &(m)->v); \
10971 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
10974 +#define vx_acc_pages_atomic(m, p, v, r) do { \
10975 + unsigned long __p = (p); \
10976 + __acc_add_atomic(__p, &(m)->v); \
10977 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
10982 +#define vx_acc_vmpage(m, d) \
10983 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
10984 +#define vx_acc_vmlpage(m, d) \
10985 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
10986 +#define vx_acc_file_rsspage(m, d) \
10987 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
10988 +#define vx_acc_anon_rsspage(m, d) \
10989 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
10991 +#define vx_acc_vmpages(m, p) \
10992 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
10993 +#define vx_acc_vmlpages(m, p) \
10994 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
10995 +#define vx_acc_file_rsspages(m, p) \
10996 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
10997 +#define vx_acc_anon_rsspages(m, p) \
10998 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
11000 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
11001 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
11003 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
11004 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
11005 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
11006 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
11008 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
11009 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
11010 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
11011 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
11013 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
11014 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
11015 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
11016 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
11018 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
11019 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
11020 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
11021 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
11024 +#define vx_pages_avail(m, p, r) \
11025 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
11027 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
11028 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
11029 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
11030 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
11032 +#define vx_rss_avail(m, p) \
11033 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
11037 + VXPT_UNKNOWN = 0,
11046 +#define vx_page_fault(mm, vma, type, ret)
11050 +void __vx_page_fault(struct mm_struct *mm,
11051 + struct vm_area_struct *vma, int type, int ret)
11053 + struct vx_info *vxi = mm->mm_vx_info;
11056 + static char *page_type[6] =
11057 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
11058 + static char *page_what[4] =
11059 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
11065 + what = (ret & 0x3);
11067 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
11068 + type, what, ret, page_type[type], page_what[what]);
11070 + if (ret & VM_FAULT_WRITE)
11072 + atomic_inc(&vxi->cacct.page[type][what]);
11075 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
11079 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
11082 +#warning duplicate inclusion
11084 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_network.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_network.h
11085 --- linux-2.6.32.56/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
11086 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_network.h 2011-06-10 13:03:02.000000000 +0200
11088 +#ifndef _NX_VS_NETWORK_H
11089 +#define _NX_VS_NETWORK_H
11091 +#include "vserver/context.h"
11092 +#include "vserver/network.h"
11093 +#include "vserver/base.h"
11094 +#include "vserver/check.h"
11095 +#include "vserver/debug.h"
11097 +#include <linux/sched.h>
11100 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
11102 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
11103 + const char *_file, int _line)
11108 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
11109 + nxi, nxi ? nxi->nx_id : 0,
11110 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11113 + atomic_inc(&nxi->nx_usecnt);
11118 +extern void free_nx_info(struct nx_info *);
11120 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
11122 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
11127 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
11128 + nxi, nxi ? nxi->nx_id : 0,
11129 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11132 + if (atomic_dec_and_test(&nxi->nx_usecnt))
11133 + free_nx_info(nxi);
11137 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
11139 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11140 + const char *_file, int _line)
11143 + vxlprintk(VXD_CBIT(nid, 3),
11144 + "init_nx_info(%p[#%d.%d])",
11145 + nxi, nxi ? nxi->nx_id : 0,
11146 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11149 + atomic_inc(&nxi->nx_usecnt);
11155 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
11157 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11158 + const char *_file, int _line)
11160 + struct nx_info *nxo;
11165 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
11166 + nxi, nxi ? nxi->nx_id : 0,
11167 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11170 + atomic_inc(&nxi->nx_usecnt);
11171 + nxo = xchg(nxp, nxi);
11175 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
11177 +static inline void __clr_nx_info(struct nx_info **nxp,
11178 + const char *_file, int _line)
11180 + struct nx_info *nxo;
11182 + nxo = xchg(nxp, NULL);
11186 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
11187 + nxo, nxo ? nxo->nx_id : 0,
11188 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
11191 + if (atomic_dec_and_test(&nxo->nx_usecnt))
11192 + free_nx_info(nxo);
11196 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
11198 +static inline void __claim_nx_info(struct nx_info *nxi,
11199 + struct task_struct *task, const char *_file, int _line)
11201 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
11202 + nxi, nxi ? nxi->nx_id : 0,
11203 + nxi?atomic_read(&nxi->nx_usecnt):0,
11204 + nxi?atomic_read(&nxi->nx_tasks):0,
11205 + task, _file, _line);
11207 + atomic_inc(&nxi->nx_tasks);
11211 +extern void unhash_nx_info(struct nx_info *);
11213 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
11215 +static inline void __release_nx_info(struct nx_info *nxi,
11216 + struct task_struct *task, const char *_file, int _line)
11218 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
11219 + nxi, nxi ? nxi->nx_id : 0,
11220 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11221 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
11222 + task, _file, _line);
11226 + if (atomic_dec_and_test(&nxi->nx_tasks))
11227 + unhash_nx_info(nxi);
11231 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
11233 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
11234 + const char *_file, int _line)
11236 + struct nx_info *nxi;
11239 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
11240 + p, _file, _line);
11241 + nxi = __get_nx_info(p->nx_info, _file, _line);
11247 +static inline void exit_nx_info(struct task_struct *p)
11250 + release_nx_info(p->nx_info, p);
11255 +#warning duplicate inclusion
11257 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_pid.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_pid.h
11258 --- linux-2.6.32.56/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
11259 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_pid.h 2011-06-10 14:04:27.000000000 +0200
11264 +#include "vserver/base.h"
11265 +#include "vserver/check.h"
11266 +#include "vserver/context.h"
11267 +#include "vserver/debug.h"
11268 +#include "vserver/pid.h"
11269 +#include <linux/pid_namespace.h>
11272 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
11275 +int vx_proc_task_visible(struct task_struct *task)
11277 + if ((task->pid == 1) &&
11278 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
11279 + /* show a blend through init */
11281 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
11288 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
11292 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
11294 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
11296 + if (task && !vx_proc_task_visible(task)) {
11297 + vxdprintk(VXD_CBIT(misc, 6),
11298 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
11299 + task, task->xid, task->pid,
11300 + current, current->xid, current->pid);
11301 + put_task_struct(task);
11309 +#warning duplicate inclusion
11311 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_sched.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_sched.h
11312 --- linux-2.6.32.56/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
11313 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_sched.h 2011-06-10 13:03:02.000000000 +0200
11315 +#ifndef _VS_SCHED_H
11316 +#define _VS_SCHED_H
11318 +#include "vserver/base.h"
11319 +#include "vserver/context.h"
11320 +#include "vserver/sched.h"
11323 +#define VAVAVOOM_RATIO 50
11325 +#define MAX_PRIO_BIAS 20
11326 +#define MIN_PRIO_BIAS -20
11329 +#ifdef CONFIG_VSERVER_HARDCPU
11332 + * effective_prio - return the priority that is based on the static
11333 + * priority but is modified by bonuses/penalties.
11335 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
11336 + * into a -4 ... 0 ... +4 bonus/penalty range.
11338 + * Additionally, we scale another amount based on the number of
11339 + * CPU tokens currently held by the context, if the process is
11340 + * part of a context (and the appropriate SCHED flag is set).
11341 + * This ranges from -5 ... 0 ... +15, quadratically.
11343 + * So, the total bonus is -9 .. 0 .. +19
11344 + * We use ~50% of the full 0...39 priority range so that:
11346 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
11347 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
11348 + * unless that context is far exceeding its CPU allocation.
11350 + * Both properties are important to certain workloads.
11353 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
11355 + int vavavoom, max;
11357 + /* lots of tokens = lots of vavavoom
11358 + * no tokens = no vavavoom */
11359 + if ((vavavoom = sched_pc->tokens) >= 0) {
11360 + max = sched_pc->tokens_max;
11361 + vavavoom = max - vavavoom;
11363 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
11364 + * (vavavoom*vavavoom - (max >> 2)) / max;
11372 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11374 + struct vx_info *vxi = p->vx_info;
11375 + struct _vx_sched_pc *sched_pc;
11380 + sched_pc = &vx_cpu(vxi, sched_pc);
11381 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
11382 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
11384 + sched_pc->vavavoom = vavavoom;
11385 + prio += vavavoom;
11387 + prio += sched_pc->prio_bias;
11391 +#else /* !CONFIG_VSERVER_HARDCPU */
11394 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11396 + struct vx_info *vxi = p->vx_info;
11399 + prio += vx_cpu(vxi, sched_pc).prio_bias;
11403 +#endif /* CONFIG_VSERVER_HARDCPU */
11406 +static inline void vx_account_user(struct vx_info *vxi,
11407 + cputime_t cputime, int nice)
11411 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
11414 +static inline void vx_account_system(struct vx_info *vxi,
11415 + cputime_t cputime, int idle)
11419 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
11423 +#warning duplicate inclusion
11425 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_socket.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_socket.h
11426 --- linux-2.6.32.56/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
11427 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_socket.h 2011-06-10 13:03:02.000000000 +0200
11429 +#ifndef _VS_SOCKET_H
11430 +#define _VS_SOCKET_H
11432 +#include "vserver/debug.h"
11433 +#include "vserver/base.h"
11434 +#include "vserver/cacct.h"
11435 +#include "vserver/context.h"
11436 +#include "vserver/tag.h"
11439 +/* socket accounting */
11441 +#include <linux/socket.h>
11443 +static inline int vx_sock_type(int family)
11445 + switch (family) {
11447 + return VXA_SOCK_UNSPEC;
11449 + return VXA_SOCK_UNIX;
11451 + return VXA_SOCK_INET;
11453 + return VXA_SOCK_INET6;
11455 + return VXA_SOCK_PACKET;
11457 + return VXA_SOCK_OTHER;
11461 +#define vx_acc_sock(v, f, p, s) \
11462 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
11464 +static inline void __vx_acc_sock(struct vx_info *vxi,
11465 + int family, int pos, int size, char *file, int line)
11468 + int type = vx_sock_type(family);
11470 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
11471 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
11475 +#define vx_sock_recv(sk, s) \
11476 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
11477 +#define vx_sock_send(sk, s) \
11478 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
11479 +#define vx_sock_fail(sk, s) \
11480 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
11483 +#define sock_vx_init(s) do { \
11484 + (s)->sk_xid = 0; \
11485 + (s)->sk_vx_info = NULL; \
11488 +#define sock_nx_init(s) do { \
11489 + (s)->sk_nid = 0; \
11490 + (s)->sk_nx_info = NULL; \
11494 +#warning duplicate inclusion
11496 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_tag.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_tag.h
11497 --- linux-2.6.32.56/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
11498 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_tag.h 2011-06-10 13:03:02.000000000 +0200
11503 +#include <linux/vserver/tag.h>
11505 +/* check conditions */
11507 +#define DX_ADMIN 0x0001
11508 +#define DX_WATCH 0x0002
11509 +#define DX_HOSTID 0x0008
11511 +#define DX_IDENT 0x0010
11513 +#define DX_ARG_MASK 0x0010
11516 +#define dx_task_tag(t) ((t)->tag)
11518 +#define dx_current_tag() dx_task_tag(current)
11520 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
11522 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
11526 + * check current context for ADMIN/WATCH and
11527 + * optionally against supplied argument
11529 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
11531 + if (mode & DX_ARG_MASK) {
11532 + if ((mode & DX_IDENT) && (id == cid))
11535 + return (((mode & DX_ADMIN) && (cid == 0)) ||
11536 + ((mode & DX_WATCH) && (cid == 1)) ||
11537 + ((mode & DX_HOSTID) && (id == 0)));
11541 +int dx_permission(const struct inode *inode, int mask);
11545 +#warning duplicate inclusion
11547 diff -NurpP --minimal linux-2.6.32.56/include/linux/vs_time.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_time.h
11548 --- linux-2.6.32.56/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
11549 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vs_time.h 2011-06-10 13:03:02.000000000 +0200
11551 +#ifndef _VS_TIME_H
11552 +#define _VS_TIME_H
11555 +/* time faking stuff */
11557 +#ifdef CONFIG_VSERVER_VTIME
11559 +extern void vx_gettimeofday(struct timeval *tv);
11560 +extern int vx_settimeofday(struct timespec *ts);
11563 +#define vx_gettimeofday(t) do_gettimeofday(t)
11564 +#define vx_settimeofday(t) do_settimeofday(t)
11568 +#warning duplicate inclusion
11570 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/Kbuild linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/Kbuild
11571 --- linux-2.6.32.56/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11572 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/Kbuild 2011-06-10 13:03:02.000000000 +0200
11575 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11576 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11577 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11578 + debug_cmd.h device_cmd.h
11580 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11582 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/base.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/base.h
11583 --- linux-2.6.32.56/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11584 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/base.h 2011-06-10 13:03:02.000000000 +0200
11586 +#ifndef _VX_BASE_H
11587 +#define _VX_BASE_H
11590 +/* context state changes */
11602 +#define vx_task_xid(t) ((t)->xid)
11604 +#define vx_current_xid() vx_task_xid(current)
11606 +#define current_vx_info() (current->vx_info)
11609 +#define nx_task_nid(t) ((t)->nid)
11611 +#define nx_current_nid() nx_task_nid(current)
11613 +#define current_nx_info() (current->nx_info)
11616 +/* generic flag merging */
11618 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11620 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11622 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11624 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11627 +/* context flags */
11629 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11631 +#define vx_current_flags() __vx_flags(current_vx_info())
11633 +#define vx_info_flags(v, m, f) \
11634 + vs_check_flags(__vx_flags(v), m, f)
11636 +#define task_vx_flags(t, m, f) \
11637 + ((t) && vx_info_flags((t)->vx_info, m, f))
11639 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11642 +/* context caps */
11644 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11646 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11648 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11650 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11654 +/* network flags */
11656 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11658 +#define nx_current_flags() __nx_flags(current_nx_info())
11660 +#define nx_info_flags(n, m, f) \
11661 + vs_check_flags(__nx_flags(n), m, f)
11663 +#define task_nx_flags(t, m, f) \
11664 + ((t) && nx_info_flags((t)->nx_info, m, f))
11666 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11669 +/* network caps */
11671 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11673 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11675 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11677 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11680 +/* context mask capabilities */
11682 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11684 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11686 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11689 +/* context bcap mask */
11691 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11693 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11696 +/* mask given bcaps */
11698 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11700 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11703 +/* masked cap_bset */
11705 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11707 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11710 +#define vx_info_mbcap(v, b) \
11711 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11712 + vx_info_bcaps(v, b) : (b))
11714 +#define task_vx_mbcap(t, b) \
11715 + vx_info_mbcap((t)->vx_info, (t)->b)
11717 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11720 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11722 +#define vx_capable(b, c) (capable(b) || \
11723 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11725 +#define nx_capable(b, c) (capable(b) || \
11726 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11728 +#define vx_task_initpid(t, n) \
11729 + ((t)->vx_info && \
11730 + ((t)->vx_info->vx_initpid == (n)))
11732 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11735 +/* context unshare mask */
11737 +#define __vx_umask(v) ((v)->vx_umask)
11739 +#define vx_current_umask() __vx_umask(current_vx_info())
11741 +#define vx_can_unshare(b, f) (capable(b) || \
11742 + (cap_raised(current_cap(), b) && \
11743 + !((f) & ~vx_current_umask())))
11746 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11748 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11751 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11753 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11756 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cacct.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct.h
11757 --- linux-2.6.32.56/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11758 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct.h 2011-06-10 13:03:02.000000000 +0200
11760 +#ifndef _VX_CACCT_H
11761 +#define _VX_CACCT_H
11764 +enum sock_acc_field {
11765 + VXA_SOCK_UNSPEC = 0,
11771 + VXA_SOCK_SIZE /* array size */
11774 +#endif /* _VX_CACCT_H */
11775 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cacct_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct_cmd.h
11776 --- linux-2.6.32.56/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11777 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct_cmd.h 2011-06-10 13:03:02.000000000 +0200
11779 +#ifndef _VX_CACCT_CMD_H
11780 +#define _VX_CACCT_CMD_H
11783 +/* virtual host info name commands */
11785 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11787 +struct vcmd_sock_stat_v0 {
11789 + uint32_t count[3];
11790 + uint64_t total[3];
11796 +#include <linux/compiler.h>
11798 +extern int vc_sock_stat(struct vx_info *, void __user *);
11800 +#endif /* __KERNEL__ */
11801 +#endif /* _VX_CACCT_CMD_H */
11802 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cacct_def.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct_def.h
11803 --- linux-2.6.32.56/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11804 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct_def.h 2011-06-10 13:03:02.000000000 +0200
11806 +#ifndef _VX_CACCT_DEF_H
11807 +#define _VX_CACCT_DEF_H
11809 +#include <asm/atomic.h>
11810 +#include <linux/vserver/cacct.h>
11813 +struct _vx_sock_acc {
11814 + atomic_long_t count;
11815 + atomic_long_t total;
11818 +/* context sub struct */
11820 +struct _vx_cacct {
11821 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11822 + atomic_t slab[8];
11823 + atomic_t page[6][8];
11826 +#ifdef CONFIG_VSERVER_DEBUG
11828 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11832 + printk("\t_vx_cacct:");
11833 + for (i = 0; i < 6; i++) {
11834 + struct _vx_sock_acc *ptr = cacct->sock[i];
11836 + printk("\t [%d] =", i);
11837 + for (j = 0; j < 3; j++) {
11838 + printk(" [%d] = %8lu, %8lu", j,
11839 + atomic_long_read(&ptr[j].count),
11840 + atomic_long_read(&ptr[j].total));
11848 +#endif /* _VX_CACCT_DEF_H */
11849 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cacct_int.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct_int.h
11850 --- linux-2.6.32.56/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11851 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cacct_int.h 2011-06-10 13:03:02.000000000 +0200
11853 +#ifndef _VX_CACCT_INT_H
11854 +#define _VX_CACCT_INT_H
11860 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11862 + return atomic_long_read(&cacct->sock[type][pos].count);
11867 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11869 + return atomic_long_read(&cacct->sock[type][pos].total);
11872 +#endif /* __KERNEL__ */
11873 +#endif /* _VX_CACCT_INT_H */
11874 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/check.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/check.h
11875 --- linux-2.6.32.56/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11876 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/check.h 2011-06-10 13:03:02.000000000 +0200
11878 +#ifndef _VS_CHECK_H
11879 +#define _VS_CHECK_H
11882 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11884 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11885 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11887 +#define MIN_D_CONTEXT 65536
11890 +/* check conditions */
11892 +#define VS_ADMIN 0x0001
11893 +#define VS_WATCH 0x0002
11894 +#define VS_HIDE 0x0004
11895 +#define VS_HOSTID 0x0008
11897 +#define VS_IDENT 0x0010
11898 +#define VS_EQUIV 0x0020
11899 +#define VS_PARENT 0x0040
11900 +#define VS_CHILD 0x0080
11902 +#define VS_ARG_MASK 0x00F0
11904 +#define VS_DYNAMIC 0x0100
11905 +#define VS_STATIC 0x0200
11907 +#define VS_ATR_MASK 0x0F00
11909 +#ifdef CONFIG_VSERVER_PRIVACY
11910 +#define VS_ADMIN_P (0)
11911 +#define VS_WATCH_P (0)
11913 +#define VS_ADMIN_P VS_ADMIN
11914 +#define VS_WATCH_P VS_WATCH
11917 +#define VS_HARDIRQ 0x1000
11918 +#define VS_SOFTIRQ 0x2000
11919 +#define VS_IRQ 0x4000
11921 +#define VS_IRQ_MASK 0xF000
11923 +#include <linux/hardirq.h>
11926 + * check current context for ADMIN/WATCH and
11927 + * optionally against supplied argument
11929 +static inline int __vs_check(int cid, int id, unsigned int mode)
11931 + if (mode & VS_ARG_MASK) {
11932 + if ((mode & VS_IDENT) && (id == cid))
11935 + if (mode & VS_ATR_MASK) {
11936 + if ((mode & VS_DYNAMIC) &&
11937 + (id >= MIN_D_CONTEXT) &&
11938 + (id <= MAX_S_CONTEXT))
11940 + if ((mode & VS_STATIC) &&
11941 + (id > 1) && (id < MIN_D_CONTEXT))
11944 + if (mode & VS_IRQ_MASK) {
11945 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11947 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11949 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11952 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11953 + ((mode & VS_WATCH) && (cid == 1)) ||
11954 + ((mode & VS_HOSTID) && (id == 0)));
11957 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11959 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11962 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11964 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11967 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/context.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/context.h
11968 --- linux-2.6.32.56/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11969 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/context.h 2011-06-10 13:03:02.000000000 +0200
11971 +#ifndef _VX_CONTEXT_H
11972 +#define _VX_CONTEXT_H
11974 +#include <linux/types.h>
11975 +#include <linux/capability.h>
11978 +/* context flags */
11980 +#define VXF_INFO_SCHED 0x00000002
11981 +#define VXF_INFO_NPROC 0x00000004
11982 +#define VXF_INFO_PRIVATE 0x00000008
11984 +#define VXF_INFO_INIT 0x00000010
11985 +#define VXF_INFO_HIDE 0x00000020
11986 +#define VXF_INFO_ULIMIT 0x00000040
11987 +#define VXF_INFO_NSPACE 0x00000080
11989 +#define VXF_SCHED_HARD 0x00000100
11990 +#define VXF_SCHED_PRIO 0x00000200
11991 +#define VXF_SCHED_PAUSE 0x00000400
11993 +#define VXF_VIRT_MEM 0x00010000
11994 +#define VXF_VIRT_UPTIME 0x00020000
11995 +#define VXF_VIRT_CPU 0x00040000
11996 +#define VXF_VIRT_LOAD 0x00080000
11997 +#define VXF_VIRT_TIME 0x00100000
11999 +#define VXF_HIDE_MOUNT 0x01000000
12000 +/* was VXF_HIDE_NETIF 0x02000000 */
12001 +#define VXF_HIDE_VINFO 0x04000000
12003 +#define VXF_STATE_SETUP (1ULL << 32)
12004 +#define VXF_STATE_INIT (1ULL << 33)
12005 +#define VXF_STATE_ADMIN (1ULL << 34)
12007 +#define VXF_SC_HELPER (1ULL << 36)
12008 +#define VXF_REBOOT_KILL (1ULL << 37)
12009 +#define VXF_PERSISTENT (1ULL << 38)
12011 +#define VXF_FORK_RSS (1ULL << 48)
12012 +#define VXF_PROLIFIC (1ULL << 49)
12014 +#define VXF_IGNEG_NICE (1ULL << 52)
12016 +#define VXF_ONE_TIME (0x0007ULL << 32)
12018 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12021 +/* context migration */
12023 +#define VXM_SET_INIT 0x00000001
12024 +#define VXM_SET_REAPER 0x00000002
12026 +/* context caps */
12028 +#define VXC_CAP_MASK 0x00000000
12030 +#define VXC_SET_UTSNAME 0x00000001
12031 +#define VXC_SET_RLIMIT 0x00000002
12032 +#define VXC_FS_SECURITY 0x00000004
12033 +#define VXC_FS_TRUSTED 0x00000008
12034 +#define VXC_TIOCSTI 0x00000010
12036 +/* was VXC_RAW_ICMP 0x00000100 */
12037 +#define VXC_SYSLOG 0x00001000
12038 +#define VXC_OOM_ADJUST 0x00002000
12039 +#define VXC_AUDIT_CONTROL 0x00004000
12041 +#define VXC_SECURE_MOUNT 0x00010000
12042 +#define VXC_SECURE_REMOUNT 0x00020000
12043 +#define VXC_BINARY_MOUNT 0x00040000
12045 +#define VXC_QUOTA_CTL 0x00100000
12046 +#define VXC_ADMIN_MAPPER 0x00200000
12047 +#define VXC_ADMIN_CLOOP 0x00400000
12049 +#define VXC_KTHREAD 0x01000000
12050 +#define VXC_NAMESPACE 0x02000000
12055 +#include <linux/list.h>
12056 +#include <linux/spinlock.h>
12057 +#include <linux/rcupdate.h>
12059 +#include "limit_def.h"
12060 +#include "sched_def.h"
12061 +#include "cvirt_def.h"
12062 +#include "cacct_def.h"
12063 +#include "device_def.h"
12065 +#define VX_SPACES 2
12067 +struct _vx_info_pc {
12068 + struct _vx_sched_pc sched_pc;
12069 + struct _vx_cvirt_pc cvirt_pc;
12073 + struct hlist_node vx_hlist; /* linked list of contexts */
12074 + xid_t vx_id; /* context id */
12075 + atomic_t vx_usecnt; /* usage count */
12076 + atomic_t vx_tasks; /* tasks count */
12077 + struct vx_info *vx_parent; /* parent context */
12078 + int vx_state; /* context state */
12080 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
12081 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
12082 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
12084 + uint64_t vx_flags; /* context flags */
12085 + uint64_t vx_ccaps; /* context caps (vserver) */
12086 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
12087 + unsigned long vx_umask; /* unshare mask (guest) */
12089 + struct task_struct *vx_reaper; /* guest reaper process */
12090 + pid_t vx_initpid; /* PID of guest init */
12091 + int64_t vx_badness_bias; /* OOM points bias */
12093 + struct _vx_limit limit; /* vserver limits */
12094 + struct _vx_sched sched; /* vserver scheduler */
12095 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
12096 + struct _vx_cacct cacct; /* context accounting */
12098 + struct _vx_device dmap; /* default device map targets */
12100 +#ifndef CONFIG_SMP
12101 + struct _vx_info_pc info_pc; /* per cpu data */
12103 + struct _vx_info_pc *ptr_pc; /* per cpu array */
12106 + wait_queue_head_t vx_wait; /* context exit waitqueue */
12107 + int reboot_cmd; /* last sys_reboot() cmd */
12108 + int exit_code; /* last process exit code */
12110 + char vx_name[65]; /* vserver name */
12113 +#ifndef CONFIG_SMP
12114 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
12115 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
12117 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
12118 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12121 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
12124 +struct vx_info_save {
12125 + struct vx_info *vxi;
12130 +/* status flags */
12132 +#define VXS_HASHED 0x0001
12133 +#define VXS_PAUSED 0x0010
12134 +#define VXS_SHUTDOWN 0x0100
12135 +#define VXS_HELPER 0x1000
12136 +#define VXS_RELEASED 0x8000
12139 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12140 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12142 +extern struct vx_info *lookup_vx_info(int);
12143 +extern struct vx_info *lookup_or_create_vx_info(int);
12145 +extern int get_xid_list(int, unsigned int *, int);
12146 +extern int xid_is_hashed(xid_t);
12148 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12150 +extern long vs_state_change(struct vx_info *, unsigned int);
12153 +#endif /* __KERNEL__ */
12154 +#endif /* _VX_CONTEXT_H */
12155 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/context_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/context_cmd.h
12156 --- linux-2.6.32.56/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
12157 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/context_cmd.h 2011-06-10 13:03:02.000000000 +0200
12159 +#ifndef _VX_CONTEXT_CMD_H
12160 +#define _VX_CONTEXT_CMD_H
12163 +/* vinfo commands */
12165 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12168 +extern int vc_task_xid(uint32_t);
12170 +#endif /* __KERNEL__ */
12172 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12174 +struct vcmd_vx_info_v0 {
12176 + uint32_t initpid;
12177 + /* more to come */
12181 +extern int vc_vx_info(struct vx_info *, void __user *);
12183 +#endif /* __KERNEL__ */
12185 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12187 +struct vcmd_ctx_stat_v0 {
12190 + /* more to come */
12194 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12196 +#endif /* __KERNEL__ */
12198 +/* context commands */
12200 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12201 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12203 +struct vcmd_ctx_create {
12204 + uint64_t flagword;
12207 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12208 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12210 +struct vcmd_ctx_migrate {
12211 + uint64_t flagword;
12215 +extern int vc_ctx_create(uint32_t, void __user *);
12216 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12218 +#endif /* __KERNEL__ */
12221 +/* flag commands */
12223 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12224 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12226 +struct vcmd_ctx_flags_v0 {
12227 + uint64_t flagword;
12232 +extern int vc_get_cflags(struct vx_info *, void __user *);
12233 +extern int vc_set_cflags(struct vx_info *, void __user *);
12235 +#endif /* __KERNEL__ */
12238 +/* context caps commands */
12240 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12241 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12243 +struct vcmd_ctx_caps_v1 {
12249 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12250 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12252 +#endif /* __KERNEL__ */
12255 +/* bcaps commands */
12257 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12258 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12260 +struct vcmd_bcaps {
12266 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12267 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12269 +#endif /* __KERNEL__ */
12272 +/* umask commands */
12274 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12275 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12277 +struct vcmd_umask {
12283 +extern int vc_get_umask(struct vx_info *, void __user *);
12284 +extern int vc_set_umask(struct vx_info *, void __user *);
12286 +#endif /* __KERNEL__ */
12291 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12292 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12294 +struct vcmd_badness_v0 {
12299 +extern int vc_get_badness(struct vx_info *, void __user *);
12300 +extern int vc_set_badness(struct vx_info *, void __user *);
12302 +#endif /* __KERNEL__ */
12303 +#endif /* _VX_CONTEXT_CMD_H */
12304 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cvirt.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cvirt.h
12305 --- linux-2.6.32.56/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
12306 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cvirt.h 2011-06-10 13:03:02.000000000 +0200
12308 +#ifndef _VX_CVIRT_H
12309 +#define _VX_CVIRT_H
12316 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12321 +void vx_update_load(struct vx_info *);
12324 +int vx_do_syslog(int, char __user *, int);
12326 +#endif /* __KERNEL__ */
12327 +#endif /* _VX_CVIRT_H */
12328 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cvirt_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cvirt_cmd.h
12329 --- linux-2.6.32.56/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
12330 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cvirt_cmd.h 2011-06-10 13:03:02.000000000 +0200
12332 +#ifndef _VX_CVIRT_CMD_H
12333 +#define _VX_CVIRT_CMD_H
12336 +/* virtual host info name commands */
12338 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12339 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12341 +struct vcmd_vhi_name_v0 {
12347 +enum vhi_name_field {
12348 + VHIN_CONTEXT = 0,
12360 +#include <linux/compiler.h>
12362 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12363 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12365 +#endif /* __KERNEL__ */
12367 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12369 +struct vcmd_virt_stat_v0 {
12372 + uint32_t nr_threads;
12373 + uint32_t nr_running;
12374 + uint32_t nr_uninterruptible;
12375 + uint32_t nr_onhold;
12376 + uint32_t nr_forks;
12377 + uint32_t load[3];
12381 +extern int vc_virt_stat(struct vx_info *, void __user *);
12383 +#endif /* __KERNEL__ */
12384 +#endif /* _VX_CVIRT_CMD_H */
12385 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/cvirt_def.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cvirt_def.h
12386 --- linux-2.6.32.56/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
12387 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/cvirt_def.h 2011-06-10 13:03:02.000000000 +0200
12389 +#ifndef _VX_CVIRT_DEF_H
12390 +#define _VX_CVIRT_DEF_H
12392 +#include <linux/jiffies.h>
12393 +#include <linux/spinlock.h>
12394 +#include <linux/wait.h>
12395 +#include <linux/time.h>
12396 +#include <asm/atomic.h>
12399 +struct _vx_usage_stat {
12403 + uint64_t softirq;
12409 +struct _vx_syslog {
12410 + wait_queue_head_t log_wait;
12411 + spinlock_t logbuf_lock; /* lock for the log buffer */
12413 + unsigned long log_start; /* next char to be read by syslog() */
12414 + unsigned long con_start; /* next char to be sent to consoles */
12415 + unsigned long log_end; /* most-recently-written-char + 1 */
12416 + unsigned long logged_chars; /* #chars since last read+clear operation */
12418 + char log_buf[1024];
12422 +/* context sub struct */
12424 +struct _vx_cvirt {
12425 + atomic_t nr_threads; /* number of current threads */
12426 + atomic_t nr_running; /* number of running threads */
12427 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12429 + atomic_t nr_onhold; /* processes on hold */
12430 + uint32_t onhold_last; /* jiffies when put on hold */
12432 + struct timeval bias_tv; /* time offset to the host */
12433 + struct timespec bias_idle;
12434 + struct timespec bias_uptime; /* context creation point */
12435 + uint64_t bias_clock; /* offset in clock_t */
12437 + spinlock_t load_lock; /* lock for the load averages */
12438 + atomic_t load_updates; /* nr of load updates done so far */
12439 + uint32_t load_last; /* last time load was calculated */
12440 + uint32_t load[3]; /* load averages 1,5,15 */
12442 + atomic_t total_forks; /* number of forks so far */
12444 + struct _vx_syslog syslog;
12447 +struct _vx_cvirt_pc {
12448 + struct _vx_usage_stat cpustat;
12452 +#ifdef CONFIG_VSERVER_DEBUG
12454 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12456 + printk("\t_vx_cvirt:\n");
12457 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12458 + atomic_read(&cvirt->nr_threads),
12459 + atomic_read(&cvirt->nr_running),
12460 + atomic_read(&cvirt->nr_uninterruptible),
12461 + atomic_read(&cvirt->nr_onhold));
12462 + /* add rest here */
12463 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12468 +#endif /* _VX_CVIRT_DEF_H */
12469 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/debug.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/debug.h
12470 --- linux-2.6.32.56/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
12471 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/debug.h 2011-06-10 13:03:02.000000000 +0200
12473 +#ifndef _VX_DEBUG_H
12474 +#define _VX_DEBUG_H
12477 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12478 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12479 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12481 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12482 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12483 +#define VXF_DEV "%p[%lu,%d:%d]"
12486 +#define vxd_path(p) \
12487 + ({ static char _buffer[PATH_MAX]; \
12488 + d_path(p, _buffer, sizeof(_buffer)); })
12490 +#define vxd_cond_path(n) \
12491 + ((n) ? vxd_path(&(n)->path) : "<null>" )
12494 +#ifdef CONFIG_VSERVER_DEBUG
12496 +extern unsigned int vx_debug_switch;
12497 +extern unsigned int vx_debug_xid;
12498 +extern unsigned int vx_debug_nid;
12499 +extern unsigned int vx_debug_tag;
12500 +extern unsigned int vx_debug_net;
12501 +extern unsigned int vx_debug_limit;
12502 +extern unsigned int vx_debug_cres;
12503 +extern unsigned int vx_debug_dlim;
12504 +extern unsigned int vx_debug_quota;
12505 +extern unsigned int vx_debug_cvirt;
12506 +extern unsigned int vx_debug_space;
12507 +extern unsigned int vx_debug_misc;
12510 +#define VX_LOGLEVEL "vxD: "
12511 +#define VX_PROC_FMT "%p: "
12512 +#define VX_PROCESS current
12514 +#define vxdprintk(c, f, x...) \
12517 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12518 + VX_PROCESS , ##x); \
12521 +#define vxlprintk(c, f, x...) \
12524 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12527 +#define vxfprintk(c, f, x...) \
12530 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12536 +void dump_vx_info(struct vx_info *, int);
12537 +void dump_vx_info_inactive(int);
12539 +#else /* CONFIG_VSERVER_DEBUG */
12541 +#define vx_debug_switch 0
12542 +#define vx_debug_xid 0
12543 +#define vx_debug_nid 0
12544 +#define vx_debug_tag 0
12545 +#define vx_debug_net 0
12546 +#define vx_debug_limit 0
12547 +#define vx_debug_cres 0
12548 +#define vx_debug_dlim 0
12549 +#define vx_debug_cvirt 0
12551 +#define vxdprintk(x...) do { } while (0)
12552 +#define vxlprintk(x...) do { } while (0)
12553 +#define vxfprintk(x...) do { } while (0)
12555 +#endif /* CONFIG_VSERVER_DEBUG */
12558 +#ifdef CONFIG_VSERVER_WARN
12560 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12561 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
12562 +#define VX_WARN_XID "[xid #%u] "
12563 +#define VX_WARN_NID "[nid #%u] "
12564 +#define VX_WARN_TAG "[tag #%u] "
12566 +#define vxwprintk(c, f, x...) \
12569 + printk(VX_WARNLEVEL f "\n", ##x); \
12572 +#else /* CONFIG_VSERVER_WARN */
12574 +#define vxwprintk(x...) do { } while (0)
12576 +#endif /* CONFIG_VSERVER_WARN */
12578 +#define vxwprintk_task(c, f, x...) \
12579 + vxwprintk(c, VX_WARN_TASK f, \
12580 + current->comm, current->pid, \
12581 + current->xid, current->nid, current->tag, ##x)
12582 +#define vxwprintk_xid(c, f, x...) \
12583 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12584 +#define vxwprintk_nid(c, f, x...) \
12585 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12586 +#define vxwprintk_tag(c, f, x...) \
12587 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12589 +#ifdef CONFIG_VSERVER_DEBUG
12590 +#define vxd_assert_lock(l) assert_spin_locked(l)
12591 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12592 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12594 +#define vxd_assert_lock(l) do { } while (0)
12595 +#define vxd_assert(c, f, x...) do { } while (0)
12599 +#endif /* _VX_DEBUG_H */
12600 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/debug_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/debug_cmd.h
12601 --- linux-2.6.32.56/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12602 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/debug_cmd.h 2011-06-10 13:03:02.000000000 +0200
12604 +#ifndef _VX_DEBUG_CMD_H
12605 +#define _VX_DEBUG_CMD_H
12608 +/* debug commands */
12610 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12612 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12613 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12615 +struct vcmd_read_history_v0 {
12618 + char __user *data;
12621 +struct vcmd_read_monitor_v0 {
12624 + char __user *data;
12630 +#ifdef CONFIG_COMPAT
12632 +#include <asm/compat.h>
12634 +struct vcmd_read_history_v0_x32 {
12637 + compat_uptr_t data_ptr;
12640 +struct vcmd_read_monitor_v0_x32 {
12643 + compat_uptr_t data_ptr;
12646 +#endif /* CONFIG_COMPAT */
12648 +extern int vc_dump_history(uint32_t);
12650 +extern int vc_read_history(uint32_t, void __user *);
12651 +extern int vc_read_monitor(uint32_t, void __user *);
12653 +#ifdef CONFIG_COMPAT
12655 +extern int vc_read_history_x32(uint32_t, void __user *);
12656 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12658 +#endif /* CONFIG_COMPAT */
12660 +#endif /* __KERNEL__ */
12661 +#endif /* _VX_DEBUG_CMD_H */
12662 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/device.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/device.h
12663 --- linux-2.6.32.56/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12664 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/device.h 2011-06-10 13:03:02.000000000 +0200
12666 +#ifndef _VX_DEVICE_H
12667 +#define _VX_DEVICE_H
12670 +#define DATTR_CREATE 0x00000001
12671 +#define DATTR_OPEN 0x00000002
12673 +#define DATTR_REMAP 0x00000010
12675 +#define DATTR_MASK 0x00000013
12678 +#else /* _VX_DEVICE_H */
12679 +#warning duplicate inclusion
12680 +#endif /* _VX_DEVICE_H */
12681 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/device_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/device_cmd.h
12682 --- linux-2.6.32.56/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12683 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/device_cmd.h 2011-06-10 13:03:02.000000000 +0200
12685 +#ifndef _VX_DEVICE_CMD_H
12686 +#define _VX_DEVICE_CMD_H
12689 +/* device vserver commands */
12691 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12692 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12694 +struct vcmd_set_mapping_v0 {
12695 + const char __user *device;
12696 + const char __user *target;
12703 +#ifdef CONFIG_COMPAT
12705 +#include <asm/compat.h>
12707 +struct vcmd_set_mapping_v0_x32 {
12708 + compat_uptr_t device_ptr;
12709 + compat_uptr_t target_ptr;
12713 +#endif /* CONFIG_COMPAT */
12715 +#include <linux/compiler.h>
12717 +extern int vc_set_mapping(struct vx_info *, void __user *);
12718 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12720 +#ifdef CONFIG_COMPAT
12722 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12723 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12725 +#endif /* CONFIG_COMPAT */
12727 +#endif /* __KERNEL__ */
12728 +#endif /* _VX_DEVICE_CMD_H */
12729 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/device_def.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/device_def.h
12730 --- linux-2.6.32.56/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12731 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/device_def.h 2011-06-10 13:03:02.000000000 +0200
12733 +#ifndef _VX_DEVICE_DEF_H
12734 +#define _VX_DEVICE_DEF_H
12736 +#include <linux/types.h>
12738 +struct vx_dmap_target {
12743 +struct _vx_device {
12744 +#ifdef CONFIG_VSERVER_DEVICE
12745 + struct vx_dmap_target targets[2];
12749 +#endif /* _VX_DEVICE_DEF_H */
12750 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/dlimit.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/dlimit.h
12751 --- linux-2.6.32.56/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12752 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/dlimit.h 2011-06-10 13:03:02.000000000 +0200
12754 +#ifndef _VX_DLIMIT_H
12755 +#define _VX_DLIMIT_H
12757 +#include "switch.h"
12762 +/* keep in sync with CDLIM_INFINITY */
12764 +#define DLIM_INFINITY (~0ULL)
12766 +#include <linux/spinlock.h>
12767 +#include <linux/rcupdate.h>
12769 +struct super_block;
12772 + struct hlist_node dl_hlist; /* linked list of contexts */
12773 + struct rcu_head dl_rcu; /* the rcu head */
12774 + tag_t dl_tag; /* context tag */
12775 + atomic_t dl_usecnt; /* usage count */
12776 + atomic_t dl_refcnt; /* reference count */
12778 + struct super_block *dl_sb; /* associated superblock */
12780 + spinlock_t dl_lock; /* protect the values */
12782 + unsigned long long dl_space_used; /* used space in bytes */
12783 + unsigned long long dl_space_total; /* maximum space in bytes */
12784 + unsigned long dl_inodes_used; /* used inodes */
12785 + unsigned long dl_inodes_total; /* maximum inodes */
12787 + unsigned int dl_nrlmult; /* non root limit mult */
12792 +extern void rcu_free_dl_info(struct rcu_head *);
12793 +extern void unhash_dl_info(struct dl_info *);
12795 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12800 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12802 +typedef uint64_t dlsize_t;
12804 +#endif /* __KERNEL__ */
12805 +#else /* _VX_DLIMIT_H */
12806 +#warning duplicate inclusion
12807 +#endif /* _VX_DLIMIT_H */
12808 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/dlimit_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/dlimit_cmd.h
12809 --- linux-2.6.32.56/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12810 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/dlimit_cmd.h 2011-06-10 13:03:02.000000000 +0200
12812 +#ifndef _VX_DLIMIT_CMD_H
12813 +#define _VX_DLIMIT_CMD_H
12816 +/* dlimit vserver commands */
12818 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12819 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12821 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12822 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12824 +struct vcmd_ctx_dlimit_base_v0 {
12825 + const char __user *name;
12829 +struct vcmd_ctx_dlimit_v0 {
12830 + const char __user *name;
12831 + uint32_t space_used; /* used space in kbytes */
12832 + uint32_t space_total; /* maximum space in kbytes */
12833 + uint32_t inodes_used; /* used inodes */
12834 + uint32_t inodes_total; /* maximum inodes */
12835 + uint32_t reserved; /* reserved for root in % */
12839 +#define CDLIM_UNSET ((uint32_t)0UL)
12840 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12841 +#define CDLIM_KEEP ((uint32_t)~1UL)
12843 +#define DLIME_UNIT 0
12844 +#define DLIME_KILO 1
12845 +#define DLIME_MEGA 2
12846 +#define DLIME_GIGA 3
12848 +#define DLIMF_SHIFT 0x10
12850 +#define DLIMS_USED 0
12851 +#define DLIMS_TOTAL 2
12854 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12856 + int exp = (flags & DLIMF_SHIFT) ?
12857 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12858 + return ((uint64_t)val) << (10 * exp);
12862 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12866 + if (*flags & DLIMF_SHIFT) {
12867 + while (val > (1LL << 32) && (exp < 3)) {
12871 + *flags &= ~(DLIME_GIGA << shift);
12872 + *flags |= exp << shift;
12880 +#ifdef CONFIG_COMPAT
12882 +#include <asm/compat.h>
12884 +struct vcmd_ctx_dlimit_base_v0_x32 {
12885 + compat_uptr_t name_ptr;
12889 +struct vcmd_ctx_dlimit_v0_x32 {
12890 + compat_uptr_t name_ptr;
12891 + uint32_t space_used; /* used space in kbytes */
12892 + uint32_t space_total; /* maximum space in kbytes */
12893 + uint32_t inodes_used; /* used inodes */
12894 + uint32_t inodes_total; /* maximum inodes */
12895 + uint32_t reserved; /* reserved for root in % */
12899 +#endif /* CONFIG_COMPAT */
12901 +#include <linux/compiler.h>
12903 +extern int vc_add_dlimit(uint32_t, void __user *);
12904 +extern int vc_rem_dlimit(uint32_t, void __user *);
12906 +extern int vc_set_dlimit(uint32_t, void __user *);
12907 +extern int vc_get_dlimit(uint32_t, void __user *);
12909 +#ifdef CONFIG_COMPAT
12911 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12912 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12914 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12915 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12917 +#endif /* CONFIG_COMPAT */
12919 +#endif /* __KERNEL__ */
12920 +#endif /* _VX_DLIMIT_CMD_H */
12921 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/global.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/global.h
12922 --- linux-2.6.32.56/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12923 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/global.h 2011-06-10 13:03:02.000000000 +0200
12925 +#ifndef _VX_GLOBAL_H
12926 +#define _VX_GLOBAL_H
12929 +extern atomic_t vx_global_ctotal;
12930 +extern atomic_t vx_global_cactive;
12932 +extern atomic_t nx_global_ctotal;
12933 +extern atomic_t nx_global_cactive;
12935 +extern atomic_t vs_global_nsproxy;
12936 +extern atomic_t vs_global_fs;
12937 +extern atomic_t vs_global_mnt_ns;
12938 +extern atomic_t vs_global_uts_ns;
12939 +extern atomic_t vs_global_user_ns;
12940 +extern atomic_t vs_global_pid_ns;
12943 +#endif /* _VX_GLOBAL_H */
12944 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/history.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/history.h
12945 --- linux-2.6.32.56/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12946 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/history.h 2011-06-10 13:03:02.000000000 +0200
12948 +#ifndef _VX_HISTORY_H
12949 +#define _VX_HISTORY_H
12954 + VXH_THROW_OOPS = 1,
12958 + VXH_INIT_VX_INFO,
12961 + VXH_CLAIM_VX_INFO,
12962 + VXH_RELEASE_VX_INFO,
12963 + VXH_ALLOC_VX_INFO,
12964 + VXH_DEALLOC_VX_INFO,
12965 + VXH_HASH_VX_INFO,
12966 + VXH_UNHASH_VX_INFO,
12968 + VXH_LOOKUP_VX_INFO,
12969 + VXH_CREATE_VX_INFO,
12972 +struct _vxhe_vxi {
12973 + struct vx_info *ptr;
12979 +struct _vxhe_set_clr {
12983 +struct _vxhe_loc_lookup {
12987 +struct _vx_hist_entry {
12989 + unsigned short seq;
12990 + unsigned short type;
12991 + struct _vxhe_vxi vxi;
12993 + struct _vxhe_set_clr sc;
12994 + struct _vxhe_loc_lookup ll;
12998 +#ifdef CONFIG_VSERVER_HISTORY
13000 +extern unsigned volatile int vxh_active;
13002 +struct _vx_hist_entry *vxh_advance(void *loc);
13006 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13008 + entry->vxi.ptr = vxi;
13010 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13011 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13012 + entry->vxi.xid = vxi->vx_id;
13017 +#define __HERE__ current_text_addr()
13019 +#define __VXH_BODY(__type, __data, __here) \
13020 + struct _vx_hist_entry *entry; \
13022 + preempt_disable(); \
13023 + entry = vxh_advance(__here); \
13025 + entry->type = __type; \
13026 + preempt_enable();
13029 + /* pass vxi only */
13031 +#define __VXH_SMPL \
13032 + __vxh_copy_vxi(entry, vxi)
13035 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13037 + __VXH_BODY(__type, __VXH_SMPL, __here)
13040 + /* pass vxi and data (void *) */
13042 +#define __VXH_DATA \
13043 + __vxh_copy_vxi(entry, vxi); \
13044 + entry->sc.data = data
13047 +void __vxh_data(struct vx_info *vxi, void *data,
13048 + int __type, void *__here)
13050 + __VXH_BODY(__type, __VXH_DATA, __here)
13053 + /* pass vxi and arg (long) */
13055 +#define __VXH_LONG \
13056 + __vxh_copy_vxi(entry, vxi); \
13057 + entry->ll.arg = arg
13060 +void __vxh_long(struct vx_info *vxi, long arg,
13061 + int __type, void *__here)
13063 + __VXH_BODY(__type, __VXH_LONG, __here)
13068 +void __vxh_throw_oops(void *__here)
13070 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13071 + /* prevent further acquisition */
13076 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
13078 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
13079 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13081 +#define __vxh_init_vx_info(v, d, h) \
13082 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13083 +#define __vxh_set_vx_info(v, d, h) \
13084 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
13085 +#define __vxh_clr_vx_info(v, d, h) \
13086 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13088 +#define __vxh_claim_vx_info(v, d, h) \
13089 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13090 +#define __vxh_release_vx_info(v, d, h) \
13091 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13093 +#define vxh_alloc_vx_info(v) \
13094 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13095 +#define vxh_dealloc_vx_info(v) \
13096 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13098 +#define vxh_hash_vx_info(v) \
13099 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13100 +#define vxh_unhash_vx_info(v) \
13101 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13103 +#define vxh_loc_vx_info(v, l) \
13104 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13105 +#define vxh_lookup_vx_info(v, l) \
13106 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13107 +#define vxh_create_vx_info(v, l) \
13108 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13110 +extern void vxh_dump_history(void);
13113 +#else /* CONFIG_VSERVER_HISTORY */
13115 +#define __HERE__ 0
13117 +#define vxh_throw_oops() do { } while (0)
13119 +#define __vxh_get_vx_info(v, h) do { } while (0)
13120 +#define __vxh_put_vx_info(v, h) do { } while (0)
13122 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
13123 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
13124 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
13126 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
13127 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13129 +#define vxh_alloc_vx_info(v) do { } while (0)
13130 +#define vxh_dealloc_vx_info(v) do { } while (0)
13132 +#define vxh_hash_vx_info(v) do { } while (0)
13133 +#define vxh_unhash_vx_info(v) do { } while (0)
13135 +#define vxh_loc_vx_info(v, l) do { } while (0)
13136 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13137 +#define vxh_create_vx_info(v, l) do { } while (0)
13139 +#define vxh_dump_history() do { } while (0)
13142 +#endif /* CONFIG_VSERVER_HISTORY */
13144 +#endif /* _VX_HISTORY_H */
13145 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/inode.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/inode.h
13146 --- linux-2.6.32.56/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
13147 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/inode.h 2011-06-10 13:03:02.000000000 +0200
13149 +#ifndef _VX_INODE_H
13150 +#define _VX_INODE_H
13153 +#define IATTR_TAG 0x01000000
13155 +#define IATTR_ADMIN 0x00000001
13156 +#define IATTR_WATCH 0x00000002
13157 +#define IATTR_HIDE 0x00000004
13158 +#define IATTR_FLAGS 0x00000007
13160 +#define IATTR_BARRIER 0x00010000
13161 +#define IATTR_IXUNLINK 0x00020000
13162 +#define IATTR_IMMUTABLE 0x00040000
13163 +#define IATTR_COW 0x00080000
13168 +#ifdef CONFIG_VSERVER_PROC_SECURE
13169 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
13170 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13172 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
13173 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13176 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13178 +#endif /* __KERNEL__ */
13180 +/* inode ioctls */
13182 +#define FIOC_GETXFLG _IOR('x', 5, long)
13183 +#define FIOC_SETXFLG _IOW('x', 6, long)
13185 +#else /* _VX_INODE_H */
13186 +#warning duplicate inclusion
13187 +#endif /* _VX_INODE_H */
13188 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/inode_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/inode_cmd.h
13189 --- linux-2.6.32.56/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
13190 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/inode_cmd.h 2011-06-10 13:03:02.000000000 +0200
13192 +#ifndef _VX_INODE_CMD_H
13193 +#define _VX_INODE_CMD_H
13196 +/* inode vserver commands */
13198 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13199 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13201 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13202 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13204 +struct vcmd_ctx_iattr_v1 {
13205 + const char __user *name;
13211 +struct vcmd_ctx_fiattr_v0 {
13221 +#ifdef CONFIG_COMPAT
13223 +#include <asm/compat.h>
13225 +struct vcmd_ctx_iattr_v1_x32 {
13226 + compat_uptr_t name_ptr;
13232 +#endif /* CONFIG_COMPAT */
13234 +#include <linux/compiler.h>
13236 +extern int vc_get_iattr(void __user *);
13237 +extern int vc_set_iattr(void __user *);
13239 +extern int vc_fget_iattr(uint32_t, void __user *);
13240 +extern int vc_fset_iattr(uint32_t, void __user *);
13242 +#ifdef CONFIG_COMPAT
13244 +extern int vc_get_iattr_x32(void __user *);
13245 +extern int vc_set_iattr_x32(void __user *);
13247 +#endif /* CONFIG_COMPAT */
13249 +#endif /* __KERNEL__ */
13250 +#endif /* _VX_INODE_CMD_H */
13251 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/limit.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit.h
13252 --- linux-2.6.32.56/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
13253 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit.h 2011-06-10 13:03:02.000000000 +0200
13255 +#ifndef _VX_LIMIT_H
13256 +#define _VX_LIMIT_H
13258 +#define VLIMIT_NSOCK 16
13259 +#define VLIMIT_OPENFD 17
13260 +#define VLIMIT_ANON 18
13261 +#define VLIMIT_SHMEM 19
13262 +#define VLIMIT_SEMARY 20
13263 +#define VLIMIT_NSEMS 21
13264 +#define VLIMIT_DENTRY 22
13265 +#define VLIMIT_MAPPED 23
13270 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13272 +/* keep in sync with CRLIM_INFINITY */
13274 +#define VLIM_INFINITY (~0ULL)
13276 +#include <asm/atomic.h>
13277 +#include <asm/resource.h>
13279 +#ifndef RLIM_INFINITY
13280 +#warning RLIM_INFINITY is undefined
13283 +#define __rlim_val(l, r, v) ((l)->res[r].v)
13285 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
13286 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
13288 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
13289 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
13290 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
13292 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
13293 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
13295 +typedef atomic_long_t rlim_atomic_t;
13296 +typedef unsigned long rlim_t;
13298 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
13299 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
13300 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
13301 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
13302 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
13303 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13306 +#if (RLIM_INFINITY == VLIM_INFINITY)
13307 +#define VX_VLIM(r) ((long long)(long)(r))
13308 +#define VX_RLIM(v) ((rlim_t)(v))
13310 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13311 + ? VLIM_INFINITY : (long long)(r))
13312 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13313 + ? RLIM_INFINITY : (rlim_t)(v))
13318 +void vx_vsi_meminfo(struct sysinfo *);
13319 +void vx_vsi_swapinfo(struct sysinfo *);
13320 +long vx_vsi_cached(struct sysinfo *);
13322 +#define NUM_LIMITS 24
13324 +#endif /* __KERNEL__ */
13325 +#endif /* _VX_LIMIT_H */
13326 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/limit_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit_cmd.h
13327 --- linux-2.6.32.56/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13328 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit_cmd.h 2011-06-10 13:03:02.000000000 +0200
13330 +#ifndef _VX_LIMIT_CMD_H
13331 +#define _VX_LIMIT_CMD_H
13334 +/* rlimit vserver commands */
13336 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13337 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13338 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13339 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13340 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13342 +struct vcmd_ctx_rlimit_v0 {
13344 + uint64_t minimum;
13345 + uint64_t softlimit;
13346 + uint64_t maximum;
13349 +struct vcmd_ctx_rlimit_mask_v0 {
13350 + uint32_t minimum;
13351 + uint32_t softlimit;
13352 + uint32_t maximum;
13355 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13357 +struct vcmd_rlimit_stat_v0 {
13361 + uint64_t minimum;
13362 + uint64_t maximum;
13365 +#define CRLIM_UNSET (0ULL)
13366 +#define CRLIM_INFINITY (~0ULL)
13367 +#define CRLIM_KEEP (~1ULL)
13371 +#ifdef CONFIG_IA32_EMULATION
13373 +struct vcmd_ctx_rlimit_v0_x32 {
13375 + uint64_t minimum;
13376 + uint64_t softlimit;
13377 + uint64_t maximum;
13378 +} __attribute__ ((packed));
13380 +#endif /* CONFIG_IA32_EMULATION */
13382 +#include <linux/compiler.h>
13384 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13385 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13386 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13387 +extern int vc_reset_hits(struct vx_info *, void __user *);
13388 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13390 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13392 +#ifdef CONFIG_IA32_EMULATION
13394 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13395 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13397 +#endif /* CONFIG_IA32_EMULATION */
13399 +#endif /* __KERNEL__ */
13400 +#endif /* _VX_LIMIT_CMD_H */
13401 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/limit_def.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit_def.h
13402 --- linux-2.6.32.56/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
13403 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit_def.h 2011-06-10 13:03:02.000000000 +0200
13405 +#ifndef _VX_LIMIT_DEF_H
13406 +#define _VX_LIMIT_DEF_H
13408 +#include <asm/atomic.h>
13409 +#include <asm/resource.h>
13411 +#include "limit.h"
13414 +struct _vx_res_limit {
13415 + rlim_t soft; /* Context soft limit */
13416 + rlim_t hard; /* Context hard limit */
13418 + rlim_atomic_t rcur; /* Current value */
13419 + rlim_t rmin; /* Context minimum */
13420 + rlim_t rmax; /* Context maximum */
13422 + atomic_t lhit; /* Limit hits */
13425 +/* context sub struct */
13427 +struct _vx_limit {
13428 + struct _vx_res_limit res[NUM_LIMITS];
13431 +#ifdef CONFIG_VSERVER_DEBUG
13433 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13437 + printk("\t_vx_limit:");
13438 + for (i = 0; i < NUM_LIMITS; i++) {
13439 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13440 + i, (unsigned long)__rlim_get(limit, i),
13441 + (unsigned long)__rlim_rmin(limit, i),
13442 + (unsigned long)__rlim_rmax(limit, i),
13443 + (long)__rlim_soft(limit, i),
13444 + (long)__rlim_hard(limit, i),
13445 + atomic_read(&__rlim_lhit(limit, i)));
13451 +#endif /* _VX_LIMIT_DEF_H */
13452 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/limit_int.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit_int.h
13453 --- linux-2.6.32.56/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
13454 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/limit_int.h 2011-06-10 13:03:02.000000000 +0200
13456 +#ifndef _VX_LIMIT_INT_H
13457 +#define _VX_LIMIT_INT_H
13459 +#include "context.h"
13463 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13464 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13466 +extern const char *vlimit_name[NUM_LIMITS];
13468 +static inline void __vx_acc_cres(struct vx_info *vxi,
13469 + int res, int dir, void *_data, char *_file, int _line)
13471 + if (VXD_RCRES_COND(res))
13472 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13473 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13474 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13475 + (dir > 0) ? "++" : "--", _data, _file, _line);
13480 + __rlim_inc(&vxi->limit, res);
13482 + __rlim_dec(&vxi->limit, res);
13485 +static inline void __vx_add_cres(struct vx_info *vxi,
13486 + int res, int amount, void *_data, char *_file, int _line)
13488 + if (VXD_RCRES_COND(res))
13489 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13490 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13491 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13492 + amount, _data, _file, _line);
13497 + __rlim_add(&vxi->limit, res, amount);
13501 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13503 + int cond = (value > __rlim_rmax(limit, res));
13506 + __rlim_rmax(limit, res) = value;
13511 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13513 + int cond = (value < __rlim_rmin(limit, res));
13516 + __rlim_rmin(limit, res) = value;
13521 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13523 + if (!__vx_cres_adjust_max(limit, res, value))
13524 + __vx_cres_adjust_min(limit, res, value);
13529 + +1 ... no limit hit
13530 + -1 ... over soft limit
13531 + 0 ... over hard limit */
13533 +static inline int __vx_cres_avail(struct vx_info *vxi,
13534 + int res, int num, char *_file, int _line)
13536 + struct _vx_limit *limit;
13539 + if (VXD_RLIMIT_COND(res))
13540 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13541 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13542 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13543 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13544 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13545 + num, _file, _line);
13549 + limit = &vxi->limit;
13550 + value = __rlim_get(limit, res);
13552 + if (!__vx_cres_adjust_max(limit, res, value))
13553 + __vx_cres_adjust_min(limit, res, value);
13558 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13560 + if (value + num <= __rlim_soft(limit, res))
13563 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13565 + if (value + num <= __rlim_hard(limit, res))
13568 + __rlim_hit(limit, res);
13573 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13576 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13578 + rlim_t value, sum = 0;
13581 + while ((res = *array++)) {
13582 + value = __rlim_get(limit, res);
13583 + __vx_cres_fixup(limit, res, value);
13590 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13592 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13593 + int res = *array;
13595 + if (value == __rlim_get(limit, res))
13598 + __rlim_set(limit, res, value);
13599 + /* now adjust min/max */
13600 + if (!__vx_cres_adjust_max(limit, res, value))
13601 + __vx_cres_adjust_min(limit, res, value);
13606 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13607 + const int *array, int num, char *_file, int _line)
13609 + struct _vx_limit *limit;
13610 + rlim_t value = 0;
13618 + limit = &vxi->limit;
13620 + value = __vx_cres_array_sum(limit, array + 1);
13622 + __rlim_set(limit, res, value);
13623 + __vx_cres_fixup(limit, res, value);
13625 + return __vx_cres_avail(vxi, res, num, _file, _line);
13629 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13634 + /* complex resources first */
13635 + if ((id < 0) || (id == RLIMIT_RSS))
13636 + __vx_cres_array_fixup(limit, VLA_RSS);
13638 + for (res = 0; res < NUM_LIMITS; res++) {
13639 + if ((id > 0) && (res != id))
13642 + value = __rlim_get(limit, res);
13643 + __vx_cres_fixup(limit, res, value);
13645 + /* not supposed to happen, maybe warn? */
13646 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13647 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13652 +#endif /* __KERNEL__ */
13653 +#endif /* _VX_LIMIT_INT_H */
13654 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/monitor.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/monitor.h
13655 --- linux-2.6.32.56/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13656 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/monitor.h 2011-06-10 13:03:02.000000000 +0200
13658 +#ifndef _VX_MONITOR_H
13659 +#define _VX_MONITOR_H
13661 +#include <linux/types.h>
13668 + VXM_UPDATE = 0x20,
13672 + VXM_RQINFO_1 = 0x24,
13675 + VXM_ACTIVATE = 0x40,
13682 + VXM_MIGRATE = 0x48,
13685 + /* all other bits are flags */
13686 + VXM_SCHED = 0x80,
13689 +struct _vxm_update_1 {
13690 + uint32_t tokens_max;
13691 + uint32_t fill_rate;
13692 + uint32_t interval;
13695 +struct _vxm_update_2 {
13696 + uint32_t tokens_min;
13697 + uint32_t fill_rate;
13698 + uint32_t interval;
13701 +struct _vxm_rqinfo_1 {
13702 + uint16_t running;
13706 + uint32_t idle_tokens;
13709 +struct _vxm_rqinfo_2 {
13710 + uint32_t norm_time;
13711 + uint32_t idle_time;
13712 + uint32_t idle_skip;
13715 +struct _vxm_sched {
13717 + uint32_t norm_time;
13718 + uint32_t idle_time;
13721 +struct _vxm_task {
13726 +struct _vxm_event {
13735 + struct _vxm_task tsk;
13739 +struct _vx_mon_entry {
13743 + struct _vxm_event ev;
13744 + struct _vxm_sched sd;
13745 + struct _vxm_update_1 u1;
13746 + struct _vxm_update_2 u2;
13747 + struct _vxm_rqinfo_1 q1;
13748 + struct _vxm_rqinfo_2 q2;
13753 +#endif /* _VX_MONITOR_H */
13754 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/network.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/network.h
13755 --- linux-2.6.32.56/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13756 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/network.h 2011-06-10 13:03:02.000000000 +0200
13758 +#ifndef _VX_NETWORK_H
13759 +#define _VX_NETWORK_H
13761 +#include <linux/types.h>
13764 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13767 +/* network flags */
13769 +#define NXF_INFO_PRIVATE 0x00000008
13771 +#define NXF_SINGLE_IP 0x00000100
13772 +#define NXF_LBACK_REMAP 0x00000200
13773 +#define NXF_LBACK_ALLOW 0x00000400
13775 +#define NXF_HIDE_NETIF 0x02000000
13776 +#define NXF_HIDE_LBACK 0x04000000
13778 +#define NXF_STATE_SETUP (1ULL << 32)
13779 +#define NXF_STATE_ADMIN (1ULL << 34)
13781 +#define NXF_SC_HELPER (1ULL << 36)
13782 +#define NXF_PERSISTENT (1ULL << 38)
13784 +#define NXF_ONE_TIME (0x0005ULL << 32)
13787 +#define NXF_INIT_SET (__nxf_init_set())
13789 +static inline uint64_t __nxf_init_set(void) {
13790 + return NXF_STATE_ADMIN
13791 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13792 + | NXF_LBACK_REMAP
13795 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13798 + | NXF_HIDE_NETIF;
13802 +/* network caps */
13804 +#define NXC_TUN_CREATE 0x00000001
13806 +#define NXC_RAW_ICMP 0x00000100
13809 +/* address types */
13811 +#define NXA_TYPE_IPV4 0x0001
13812 +#define NXA_TYPE_IPV6 0x0002
13814 +#define NXA_TYPE_NONE 0x0000
13815 +#define NXA_TYPE_ANY 0x00FF
13817 +#define NXA_TYPE_ADDR 0x0010
13818 +#define NXA_TYPE_MASK 0x0020
13819 +#define NXA_TYPE_RANGE 0x0040
13821 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13823 +#define NXA_MOD_BCAST 0x0100
13824 +#define NXA_MOD_LBACK 0x0200
13826 +#define NXA_LOOPBACK 0x1000
13828 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13829 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13833 +#include <linux/list.h>
13834 +#include <linux/spinlock.h>
13835 +#include <linux/rcupdate.h>
13836 +#include <linux/in.h>
13837 +#include <linux/in6.h>
13838 +#include <asm/atomic.h>
13840 +struct nx_addr_v4 {
13841 + struct nx_addr_v4 *next;
13842 + struct in_addr ip[2];
13843 + struct in_addr mask;
13848 +struct nx_addr_v6 {
13849 + struct nx_addr_v6 *next;
13850 + struct in6_addr ip;
13851 + struct in6_addr mask;
13858 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13859 + nid_t nx_id; /* vnet id */
13860 + atomic_t nx_usecnt; /* usage count */
13861 + atomic_t nx_tasks; /* tasks count */
13862 + int nx_state; /* context state */
13864 + uint64_t nx_flags; /* network flag word */
13865 + uint64_t nx_ncaps; /* network capabilities */
13867 + struct in_addr v4_lback; /* Loopback address */
13868 + struct in_addr v4_bcast; /* Broadcast address */
13869 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13870 +#ifdef CONFIG_IPV6
13871 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13873 + char nx_name[65]; /* network context name */
13877 +/* status flags */
13879 +#define NXS_HASHED 0x0001
13880 +#define NXS_SHUTDOWN 0x0100
13881 +#define NXS_RELEASED 0x8000
13883 +extern struct nx_info *lookup_nx_info(int);
13885 +extern int get_nid_list(int, unsigned int *, int);
13886 +extern int nid_is_hashed(nid_t);
13888 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13890 +extern long vs_net_change(struct nx_info *, unsigned int);
13895 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13896 +#ifdef CONFIG_IPV6
13897 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13899 +#define NX_IPV6(n) (0)
13902 +#endif /* __KERNEL__ */
13903 +#endif /* _VX_NETWORK_H */
13904 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/network_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/network_cmd.h
13905 --- linux-2.6.32.56/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13906 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/network_cmd.h 2011-06-10 13:03:02.000000000 +0200
13908 +#ifndef _VX_NETWORK_CMD_H
13909 +#define _VX_NETWORK_CMD_H
13912 +/* vinfo commands */
13914 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13917 +extern int vc_task_nid(uint32_t);
13919 +#endif /* __KERNEL__ */
13921 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13923 +struct vcmd_nx_info_v0 {
13925 + /* more to come */
13929 +extern int vc_nx_info(struct nx_info *, void __user *);
13931 +#endif /* __KERNEL__ */
13933 +#include <linux/in.h>
13934 +#include <linux/in6.h>
13936 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13937 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13939 +struct vcmd_net_create {
13940 + uint64_t flagword;
13943 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13945 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13946 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13948 +struct vcmd_net_addr_v0 {
13951 + struct in_addr ip[4];
13952 + struct in_addr mask[4];
13955 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
13956 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
13958 +struct vcmd_net_addr_ipv4_v1 {
13961 + struct in_addr ip;
13962 + struct in_addr mask;
13965 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13966 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13968 +struct vcmd_net_addr_ipv6_v1 {
13972 + struct in6_addr ip;
13973 + struct in6_addr mask;
13976 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13977 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13979 +struct vcmd_match_ipv4_v0 {
13984 + struct in_addr ip;
13985 + struct in_addr ip2;
13986 + struct in_addr mask;
13989 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13990 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13992 +struct vcmd_match_ipv6_v0 {
13997 + struct in6_addr ip;
13998 + struct in6_addr ip2;
13999 + struct in6_addr mask;
14004 +extern int vc_net_create(uint32_t, void __user *);
14005 +extern int vc_net_migrate(struct nx_info *, void __user *);
14007 +extern int vc_net_add(struct nx_info *, void __user *);
14008 +extern int vc_net_remove(struct nx_info *, void __user *);
14010 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
14011 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
14013 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
14014 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
14016 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
14017 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
14019 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
14020 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
14022 +#endif /* __KERNEL__ */
14025 +/* flag commands */
14027 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
14028 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
14030 +struct vcmd_net_flags_v0 {
14031 + uint64_t flagword;
14036 +extern int vc_get_nflags(struct nx_info *, void __user *);
14037 +extern int vc_set_nflags(struct nx_info *, void __user *);
14039 +#endif /* __KERNEL__ */
14042 +/* network caps commands */
14044 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
14045 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
14047 +struct vcmd_net_caps_v0 {
14053 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14054 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14056 +#endif /* __KERNEL__ */
14057 +#endif /* _VX_CONTEXT_CMD_H */
14058 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/percpu.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/percpu.h
14059 --- linux-2.6.32.56/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
14060 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/percpu.h 2011-06-10 13:03:02.000000000 +0200
14062 +#ifndef _VX_PERCPU_H
14063 +#define _VX_PERCPU_H
14065 +#include "cvirt_def.h"
14066 +#include "sched_def.h"
14068 +struct _vx_percpu {
14069 + struct _vx_cvirt_pc cvirt;
14070 + struct _vx_sched_pc sched;
14073 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
14075 +#endif /* _VX_PERCPU_H */
14076 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/pid.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/pid.h
14077 --- linux-2.6.32.56/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
14078 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/pid.h 2011-06-10 13:03:02.000000000 +0200
14080 +#ifndef _VSERVER_PID_H
14081 +#define _VSERVER_PID_H
14083 +/* pid faking stuff */
14085 +#define vx_info_map_pid(v, p) \
14086 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14087 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
14088 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14089 +#define vx_map_tgid(p) vx_map_pid(p)
14091 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14092 + const char *func, const char *file, int line)
14094 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14095 + vxfprintk(VXD_CBIT(cvirt, 2),
14096 + "vx_map_tgid: %p/%llx: %d -> %d",
14097 + vxi, (long long)vxi->vx_flags, pid,
14098 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
14099 + func, file, line);
14102 + if (pid == vxi->vx_initpid)
14108 +#define vx_info_rmap_pid(v, p) \
14109 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14110 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14111 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14113 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14114 + const char *func, const char *file, int line)
14116 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14117 + vxfprintk(VXD_CBIT(cvirt, 2),
14118 + "vx_rmap_tgid: %p/%llx: %d -> %d",
14119 + vxi, (long long)vxi->vx_flags, pid,
14120 + (pid == 1) ? vxi->vx_initpid : pid,
14121 + func, file, line);
14122 + if ((pid == 1) && vxi->vx_initpid)
14123 + return vxi->vx_initpid;
14124 + if (pid == vxi->vx_initpid)
14131 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/sched.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/sched.h
14132 --- linux-2.6.32.56/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
14133 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/sched.h 2011-06-10 13:03:02.000000000 +0200
14135 +#ifndef _VX_SCHED_H
14136 +#define _VX_SCHED_H
14143 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14148 +void vx_update_load(struct vx_info *);
14151 +int vx_tokens_recalc(struct _vx_sched_pc *,
14152 + unsigned long *, unsigned long *, int [2]);
14154 +void vx_update_sched_param(struct _vx_sched *sched,
14155 + struct _vx_sched_pc *sched_pc);
14157 +#endif /* __KERNEL__ */
14158 +#else /* _VX_SCHED_H */
14159 +#warning duplicate inclusion
14160 +#endif /* _VX_SCHED_H */
14161 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/sched_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/sched_cmd.h
14162 --- linux-2.6.32.56/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
14163 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/sched_cmd.h 2011-06-10 13:03:02.000000000 +0200
14165 +#ifndef _VX_SCHED_CMD_H
14166 +#define _VX_SCHED_CMD_H
14169 +/* sched vserver commands */
14171 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
14172 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
14173 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
14175 +struct vcmd_set_sched_v2 {
14176 + int32_t fill_rate;
14177 + int32_t interval;
14179 + int32_t tokens_min;
14180 + int32_t tokens_max;
14181 + uint64_t cpu_mask;
14184 +struct vcmd_set_sched_v3 {
14185 + uint32_t set_mask;
14186 + int32_t fill_rate;
14187 + int32_t interval;
14189 + int32_t tokens_min;
14190 + int32_t tokens_max;
14191 + int32_t priority_bias;
14194 +struct vcmd_set_sched_v4 {
14195 + uint32_t set_mask;
14196 + int32_t fill_rate;
14197 + int32_t interval;
14199 + int32_t tokens_min;
14200 + int32_t tokens_max;
14201 + int32_t prio_bias;
14203 + int32_t bucket_id;
14206 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
14207 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
14209 +struct vcmd_sched_v5 {
14212 + int32_t bucket_id;
14213 + int32_t fill_rate[2];
14214 + int32_t interval[2];
14216 + int32_t tokens_min;
14217 + int32_t tokens_max;
14218 + int32_t prio_bias;
14221 +#define VXSM_FILL_RATE 0x0001
14222 +#define VXSM_INTERVAL 0x0002
14223 +#define VXSM_FILL_RATE2 0x0004
14224 +#define VXSM_INTERVAL2 0x0008
14225 +#define VXSM_TOKENS 0x0010
14226 +#define VXSM_TOKENS_MIN 0x0020
14227 +#define VXSM_TOKENS_MAX 0x0040
14228 +#define VXSM_PRIO_BIAS 0x0100
14230 +#define VXSM_IDLE_TIME 0x0200
14231 +#define VXSM_FORCE 0x0400
14233 +#define VXSM_V3_MASK 0x0173
14234 +#define VXSM_SET_MASK 0x01FF
14236 +#define VXSM_CPU_ID 0x1000
14237 +#define VXSM_BUCKET_ID 0x2000
14239 +#define VXSM_MSEC 0x4000
14241 +#define SCHED_KEEP (-2) /* only for v2 */
14245 +#include <linux/compiler.h>
14247 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14248 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14249 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14250 +extern int vc_set_sched(struct vx_info *, void __user *);
14251 +extern int vc_get_sched(struct vx_info *, void __user *);
14253 +#endif /* __KERNEL__ */
14255 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
14257 +struct vcmd_sched_info {
14259 + int32_t bucket_id;
14260 + uint64_t user_msec;
14261 + uint64_t sys_msec;
14262 + uint64_t hold_msec;
14263 + uint32_t token_usec;
14264 + int32_t vavavoom;
14269 +extern int vc_sched_info(struct vx_info *, void __user *);
14271 +#endif /* __KERNEL__ */
14272 +#endif /* _VX_SCHED_CMD_H */
14273 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/sched_def.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/sched_def.h
14274 --- linux-2.6.32.56/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
14275 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/sched_def.h 2011-06-10 13:03:02.000000000 +0200
14277 +#ifndef _VX_SCHED_DEF_H
14278 +#define _VX_SCHED_DEF_H
14280 +#include <linux/spinlock.h>
14281 +#include <linux/jiffies.h>
14282 +#include <linux/cpumask.h>
14283 +#include <asm/atomic.h>
14284 +#include <asm/param.h>
14287 +/* context sub struct */
14289 +struct _vx_sched {
14290 + spinlock_t tokens_lock; /* lock for token bucket */
14292 + int tokens; /* number of CPU tokens */
14293 + int fill_rate[2]; /* Fill rate: add X tokens... */
14294 + int interval[2]; /* Divisor: per Y jiffies */
14295 + int tokens_min; /* Limit: minimum for unhold */
14296 + int tokens_max; /* Limit: no more than N tokens */
14298 + int prio_bias; /* bias offset for priority */
14300 + unsigned update_mask; /* which features should be updated */
14301 + cpumask_t update; /* CPUs which should update */
14304 +struct _vx_sched_pc {
14305 + int tokens; /* number of CPU tokens */
14306 + int flags; /* bucket flags */
14308 + int fill_rate[2]; /* Fill rate: add X tokens... */
14309 + int interval[2]; /* Divisor: per Y jiffies */
14310 + int tokens_min; /* Limit: minimum for unhold */
14311 + int tokens_max; /* Limit: no more than N tokens */
14313 + int prio_bias; /* bias offset for priority */
14314 + int vavavoom; /* last calculated vavavoom */
14316 + unsigned long norm_time; /* last time accounted */
14317 + unsigned long idle_time; /* non linear time for fair sched */
14318 + unsigned long token_time; /* token time for accounting */
14319 + unsigned long onhold; /* jiffies when put on hold */
14321 + uint64_t user_ticks; /* token tick events */
14322 + uint64_t sys_ticks; /* token tick events */
14323 + uint64_t hold_ticks; /* token ticks paused */
14327 +#define VXSF_ONHOLD 0x0001
14328 +#define VXSF_IDLE_TIME 0x0100
14330 +#ifdef CONFIG_VSERVER_DEBUG
14332 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14334 + printk("\t_vx_sched:\n");
14335 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14336 + sched->fill_rate[0], sched->interval[0],
14337 + sched->fill_rate[1], sched->interval[1],
14338 + sched->tokens_min, sched->tokens_max);
14339 + printk("\t priority = %4d\n", sched->prio_bias);
14344 +#endif /* _VX_SCHED_DEF_H */
14345 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/signal.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/signal.h
14346 --- linux-2.6.32.56/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14347 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/signal.h 2011-06-10 13:03:02.000000000 +0200
14349 +#ifndef _VX_SIGNAL_H
14350 +#define _VX_SIGNAL_H
14357 +int vx_info_kill(struct vx_info *, int, int);
14359 +#endif /* __KERNEL__ */
14360 +#else /* _VX_SIGNAL_H */
14361 +#warning duplicate inclusion
14362 +#endif /* _VX_SIGNAL_H */
14363 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/signal_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/signal_cmd.h
14364 --- linux-2.6.32.56/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
14365 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/signal_cmd.h 2011-06-10 13:03:02.000000000 +0200
14367 +#ifndef _VX_SIGNAL_CMD_H
14368 +#define _VX_SIGNAL_CMD_H
14371 +/* signalling vserver commands */
14373 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
14374 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
14376 +struct vcmd_ctx_kill_v0 {
14381 +struct vcmd_wait_exit_v0 {
14382 + int32_t reboot_cmd;
14383 + int32_t exit_code;
14388 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14389 +extern int vc_wait_exit(struct vx_info *, void __user *);
14391 +#endif /* __KERNEL__ */
14393 +/* process alteration commands */
14395 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
14396 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
14398 +struct vcmd_pflags_v0 {
14399 + uint32_t flagword;
14405 +extern int vc_get_pflags(uint32_t pid, void __user *);
14406 +extern int vc_set_pflags(uint32_t pid, void __user *);
14408 +#endif /* __KERNEL__ */
14409 +#endif /* _VX_SIGNAL_CMD_H */
14410 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/space.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/space.h
14411 --- linux-2.6.32.56/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
14412 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/space.h 2011-06-10 13:03:02.000000000 +0200
14414 +#ifndef _VX_SPACE_H
14415 +#define _VX_SPACE_H
14417 +#include <linux/types.h>
14421 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14423 +#else /* _VX_SPACE_H */
14424 +#warning duplicate inclusion
14425 +#endif /* _VX_SPACE_H */
14426 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/space_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/space_cmd.h
14427 --- linux-2.6.32.56/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
14428 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/space_cmd.h 2011-06-10 13:03:02.000000000 +0200
14430 +#ifndef _VX_SPACE_CMD_H
14431 +#define _VX_SPACE_CMD_H
14434 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14435 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
14436 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
14438 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14439 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
14440 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
14442 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14444 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
14445 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14448 +struct vcmd_space_mask_v1 {
14452 +struct vcmd_space_mask_v2 {
14460 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14461 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14462 +extern int vc_enter_space(struct vx_info *, void __user *);
14463 +extern int vc_set_space(struct vx_info *, void __user *);
14464 +extern int vc_get_space_mask(void __user *, int);
14466 +#endif /* __KERNEL__ */
14467 +#endif /* _VX_SPACE_CMD_H */
14468 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/switch.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/switch.h
14469 --- linux-2.6.32.56/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14470 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/switch.h 2011-06-10 13:03:02.000000000 +0200
14472 +#ifndef _VX_SWITCH_H
14473 +#define _VX_SWITCH_H
14475 +#include <linux/types.h>
14478 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14479 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14480 +#define VC_VERSION(c) ((c) & 0xFFF)
14482 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14483 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14487 + Syscall Matrix V2.8
14489 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14490 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14491 + |INFO |SETUP | |MOVE | | | | | |
14492 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14493 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
14494 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14495 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14496 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14497 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14498 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14499 + MEMORY | | | | |MEMCTRL| | |SWAP | |
14500 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14501 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14502 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14503 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14504 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14505 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
14506 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14507 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14508 + OTHER |VSTAT | | | | | | |VINFO | |
14509 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14510 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14511 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
14512 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14513 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14514 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14515 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14516 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14520 +#define VC_CAT_VERSION 0
14522 +#define VC_CAT_VSETUP 1
14523 +#define VC_CAT_VHOST 2
14525 +#define VC_CAT_DEVICE 6
14527 +#define VC_CAT_VPROC 9
14528 +#define VC_CAT_PROCALT 10
14529 +#define VC_CAT_PROCMIG 11
14530 +#define VC_CAT_PROCTRL 12
14532 +#define VC_CAT_SCHED 14
14533 +#define VC_CAT_MEMCTRL 20
14535 +#define VC_CAT_VNET 25
14536 +#define VC_CAT_NETALT 26
14537 +#define VC_CAT_NETMIG 27
14538 +#define VC_CAT_NETCTRL 28
14540 +#define VC_CAT_TAGMIG 35
14541 +#define VC_CAT_DLIMIT 36
14542 +#define VC_CAT_INODE 38
14544 +#define VC_CAT_VSTAT 40
14545 +#define VC_CAT_VINFO 46
14546 +#define VC_CAT_EVENT 48
14548 +#define VC_CAT_FLAGS 52
14549 +#define VC_CAT_VSPACE 54
14550 +#define VC_CAT_DEBUG 56
14551 +#define VC_CAT_RLIMIT 60
14553 +#define VC_CAT_SYSTEST 61
14554 +#define VC_CAT_COMPAT 63
14556 +/* query version */
14558 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14559 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14564 +#include <linux/errno.h>
14566 +#endif /* __KERNEL__ */
14568 +#endif /* _VX_SWITCH_H */
14570 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/tag.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/tag.h
14571 --- linux-2.6.32.56/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
14572 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/tag.h 2011-06-10 13:03:02.000000000 +0200
14577 +#include <linux/types.h>
14580 +#define DX_TAG(in) (IS_TAGGED(in))
14583 +#ifdef CONFIG_TAG_NFSD
14584 +#define DX_TAG_NFSD 1
14586 +#define DX_TAG_NFSD 0
14590 +#ifdef CONFIG_TAGGING_NONE
14592 +#define MAX_UID 0xFFFFFFFF
14593 +#define MAX_GID 0xFFFFFFFF
14595 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14597 +#define TAGINO_UID(cond, uid, tag) (uid)
14598 +#define TAGINO_GID(cond, gid, tag) (gid)
14603 +#ifdef CONFIG_TAGGING_GID16
14605 +#define MAX_UID 0xFFFFFFFF
14606 +#define MAX_GID 0x0000FFFF
14608 +#define INOTAG_TAG(cond, uid, gid, tag) \
14609 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14611 +#define TAGINO_UID(cond, uid, tag) (uid)
14612 +#define TAGINO_GID(cond, gid, tag) \
14613 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14618 +#ifdef CONFIG_TAGGING_ID24
14620 +#define MAX_UID 0x00FFFFFF
14621 +#define MAX_GID 0x00FFFFFF
14623 +#define INOTAG_TAG(cond, uid, gid, tag) \
14624 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14626 +#define TAGINO_UID(cond, uid, tag) \
14627 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14628 +#define TAGINO_GID(cond, gid, tag) \
14629 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14634 +#ifdef CONFIG_TAGGING_UID16
14636 +#define MAX_UID 0x0000FFFF
14637 +#define MAX_GID 0xFFFFFFFF
14639 +#define INOTAG_TAG(cond, uid, gid, tag) \
14640 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14642 +#define TAGINO_UID(cond, uid, tag) \
14643 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14644 +#define TAGINO_GID(cond, gid, tag) (gid)
14649 +#ifdef CONFIG_TAGGING_INTERN
14651 +#define MAX_UID 0xFFFFFFFF
14652 +#define MAX_GID 0xFFFFFFFF
14654 +#define INOTAG_TAG(cond, uid, gid, tag) \
14655 + ((cond) ? (tag) : 0)
14657 +#define TAGINO_UID(cond, uid, tag) (uid)
14658 +#define TAGINO_GID(cond, gid, tag) (gid)
14663 +#ifndef CONFIG_TAGGING_NONE
14664 +#define dx_current_fstag(sb) \
14665 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14667 +#define dx_current_fstag(sb) (0)
14670 +#ifndef CONFIG_TAGGING_INTERN
14671 +#define TAGINO_TAG(cond, tag) (0)
14673 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14676 +#define INOTAG_UID(cond, uid, gid) \
14677 + ((cond) ? ((uid) & MAX_UID) : (uid))
14678 +#define INOTAG_GID(cond, uid, gid) \
14679 + ((cond) ? ((gid) & MAX_GID) : (gid))
14682 +static inline uid_t dx_map_uid(uid_t uid)
14684 + if ((uid > MAX_UID) && (uid != -1))
14686 + return (uid & MAX_UID);
14689 +static inline gid_t dx_map_gid(gid_t gid)
14691 + if ((gid > MAX_GID) && (gid != -1))
14693 + return (gid & MAX_GID);
14701 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14703 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14704 + unsigned long *flags);
14706 +#ifdef CONFIG_PROPAGATE
14708 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14710 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14713 +#define dx_propagate_tag(n, i) do { } while (0)
14716 +#endif /* _DX_TAG_H */
14717 diff -NurpP --minimal linux-2.6.32.56/include/linux/vserver/tag_cmd.h linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/tag_cmd.h
14718 --- linux-2.6.32.56/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14719 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/linux/vserver/tag_cmd.h 2011-06-10 13:03:02.000000000 +0200
14721 +#ifndef _VX_TAG_CMD_H
14722 +#define _VX_TAG_CMD_H
14725 +/* vinfo commands */
14727 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14730 +extern int vc_task_tag(uint32_t);
14732 +#endif /* __KERNEL__ */
14734 +/* context commands */
14736 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14739 +extern int vc_tag_migrate(uint32_t);
14741 +#endif /* __KERNEL__ */
14742 +#endif /* _VX_TAG_CMD_H */
14743 diff -NurpP --minimal linux-2.6.32.56/include/net/addrconf.h linux-2.6.32.56-vs2.3.0.36.29.9/include/net/addrconf.h
14744 --- linux-2.6.32.56/include/net/addrconf.h 2009-12-03 20:02:57.000000000 +0100
14745 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/net/addrconf.h 2011-06-10 13:03:02.000000000 +0200
14746 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14747 struct net_device *dev,
14748 const struct in6_addr *daddr,
14749 unsigned int srcprefs,
14750 - struct in6_addr *saddr);
14751 + struct in6_addr *saddr,
14752 + struct nx_info *nxi);
14753 extern int ipv6_get_lladdr(struct net_device *dev,
14754 struct in6_addr *addr,
14755 unsigned char banned_flags);
14756 diff -NurpP --minimal linux-2.6.32.56/include/net/af_unix.h linux-2.6.32.56-vs2.3.0.36.29.9/include/net/af_unix.h
14757 --- linux-2.6.32.56/include/net/af_unix.h 2012-02-09 10:22:32.000000000 +0100
14758 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/net/af_unix.h 2011-06-10 13:03:02.000000000 +0200
14760 #include <linux/socket.h>
14761 #include <linux/un.h>
14762 #include <linux/mutex.h>
14763 +#include <linux/vs_base.h>
14764 #include <net/sock.h>
14766 extern void unix_inflight(struct file *fp);
14767 diff -NurpP --minimal linux-2.6.32.56/include/net/inet_timewait_sock.h linux-2.6.32.56-vs2.3.0.36.29.9/include/net/inet_timewait_sock.h
14768 --- linux-2.6.32.56/include/net/inet_timewait_sock.h 2009-12-03 20:02:57.000000000 +0100
14769 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/net/inet_timewait_sock.h 2011-06-10 13:03:02.000000000 +0200
14770 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14771 #define tw_hash __tw_common.skc_hash
14772 #define tw_prot __tw_common.skc_prot
14773 #define tw_net __tw_common.skc_net
14774 +#define tw_xid __tw_common.skc_xid
14775 +#define tw_vx_info __tw_common.skc_vx_info
14776 +#define tw_nid __tw_common.skc_nid
14777 +#define tw_nx_info __tw_common.skc_nx_info
14779 volatile unsigned char tw_substate;
14780 /* 3 bits hole, try to pack */
14781 diff -NurpP --minimal linux-2.6.32.56/include/net/route.h linux-2.6.32.56-vs2.3.0.36.29.9/include/net/route.h
14782 --- linux-2.6.32.56/include/net/route.h 2009-09-10 15:26:27.000000000 +0200
14783 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/net/route.h 2011-06-10 13:03:02.000000000 +0200
14784 @@ -135,6 +135,9 @@ static inline void ip_rt_put(struct rtab
14785 dst_release(&rt->u.dst);
14788 +#include <linux/vs_base.h>
14789 +#include <linux/vs_inet.h>
14791 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14793 extern const __u8 ip_tos2prio[16];
14794 @@ -144,6 +147,9 @@ static inline char rt_tos2priority(u8 to
14795 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14798 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14799 + struct rtable **, struct flowi *);
14801 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14802 __be32 src, u32 tos, int oif, u8 protocol,
14803 __be16 sport, __be16 dport, struct sock *sk,
14804 @@ -161,11 +167,24 @@ static inline int ip_route_connect(struc
14807 struct net *net = sock_net(sk);
14808 + struct nx_info *nx_info = current_nx_info();
14810 if (inet_sk(sk)->transparent)
14811 fl.flags |= FLOWI_FLAG_ANYSRC;
14813 - if (!dst || !src) {
14815 + nx_info = sk->sk_nx_info;
14817 + vxdprintk(VXD_CBIT(net, 4),
14818 + "ip_route_connect(%p) %p,%p;%lx",
14819 + sk, nx_info, sk->sk_socket,
14820 + (sk->sk_socket?sk->sk_socket->flags:0));
14822 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14826 + if (!fl.fl4_dst || !fl.fl4_src) {
14827 err = __ip_route_output_key(net, rp, &fl);
14830 diff -NurpP --minimal linux-2.6.32.56/include/net/sock.h linux-2.6.32.56-vs2.3.0.36.29.9/include/net/sock.h
14831 --- linux-2.6.32.56/include/net/sock.h 2009-12-03 20:02:57.000000000 +0100
14832 +++ linux-2.6.32.56-vs2.3.0.36.29.9/include/net/sock.h 2011-06-10 13:03:02.000000000 +0200
14833 @@ -139,6 +139,10 @@ struct sock_common {
14834 #ifdef CONFIG_NET_NS
14835 struct net *skc_net;
14838 + struct vx_info *skc_vx_info;
14840 + struct nx_info *skc_nx_info;
14844 @@ -225,6 +229,10 @@ struct sock {
14845 #define sk_bind_node __sk_common.skc_bind_node
14846 #define sk_prot __sk_common.skc_prot
14847 #define sk_net __sk_common.skc_net
14848 +#define sk_xid __sk_common.skc_xid
14849 +#define sk_vx_info __sk_common.skc_vx_info
14850 +#define sk_nid __sk_common.skc_nid
14851 +#define sk_nx_info __sk_common.skc_nx_info
14852 kmemcheck_bitfield_begin(flags);
14853 unsigned int sk_shutdown : 2,
14855 diff -NurpP --minimal linux-2.6.32.56/init/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/init/Kconfig
14856 --- linux-2.6.32.56/init/Kconfig 2012-02-09 10:22:35.000000000 +0100
14857 +++ linux-2.6.32.56-vs2.3.0.36.29.9/init/Kconfig 2011-06-10 13:03:02.000000000 +0200
14858 @@ -426,6 +426,19 @@ config LOG_BUF_SHIFT
14859 config HAVE_UNSTABLE_SCHED_CLOCK
14862 +config CFS_HARD_LIMITS
14863 + bool "Hard Limits for CFS Group Scheduler"
14864 + depends on EXPERIMENTAL
14865 + depends on FAIR_GROUP_SCHED && CGROUP_SCHED
14868 + This option enables hard limiting of CPU time obtained by
14869 + a fair task group. Use this if you want to throttle a group of tasks
14870 + based on its CPU usage. For more details refer to
14871 + Documentation/scheduler/sched-cfs-hard-limits.txt
14876 boolean "Control Group support"
14878 diff -NurpP --minimal linux-2.6.32.56/init/main.c linux-2.6.32.56-vs2.3.0.36.29.9/init/main.c
14879 --- linux-2.6.32.56/init/main.c 2012-02-09 10:22:35.000000000 +0100
14880 +++ linux-2.6.32.56-vs2.3.0.36.29.9/init/main.c 2011-06-10 13:03:02.000000000 +0200
14882 #include <linux/sfi.h>
14883 #include <linux/shmem_fs.h>
14884 #include <trace/boot.h>
14885 +#include <linux/vserver/percpu.h>
14887 #include <asm/io.h>
14888 #include <asm/bugs.h>
14889 diff -NurpP --minimal linux-2.6.32.56/ipc/mqueue.c linux-2.6.32.56-vs2.3.0.36.29.9/ipc/mqueue.c
14890 --- linux-2.6.32.56/ipc/mqueue.c 2012-02-09 10:22:35.000000000 +0100
14891 +++ linux-2.6.32.56-vs2.3.0.36.29.9/ipc/mqueue.c 2011-06-10 13:03:02.000000000 +0200
14893 #include <linux/pid.h>
14894 #include <linux/ipc_namespace.h>
14895 #include <linux/ima.h>
14896 +#include <linux/vs_context.h>
14897 +#include <linux/vs_limit.h>
14899 #include <net/sock.h>
14901 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14902 struct sigevent notify;
14903 struct pid* notify_owner;
14904 struct user_struct *user; /* user who created, for accounting */
14905 + struct vx_info *vxi;
14906 struct sock *notify_sock;
14907 struct sk_buff *notify_cookie;
14909 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
14910 if (S_ISREG(mode)) {
14911 struct mqueue_inode_info *info;
14912 struct task_struct *p = current;
14913 + struct vx_info *vxi = p->vx_info;
14914 unsigned long mq_bytes, mq_msg_tblsz;
14916 inode->i_fop = &mqueue_file_operations;
14917 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14918 info->notify_owner = NULL;
14920 info->user = NULL; /* set when all is ok */
14921 + info->vxi = NULL;
14922 memset(&info->attr, 0, sizeof(info->attr));
14923 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14924 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14925 @@ -153,22 +158,26 @@ static struct inode *mqueue_get_inode(st
14926 spin_lock(&mq_lock);
14927 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14928 u->mq_bytes + mq_bytes >
14929 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14930 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14931 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14932 spin_unlock(&mq_lock);
14935 u->mq_bytes += mq_bytes;
14936 + vx_ipcmsg_add(vxi, u, mq_bytes);
14937 spin_unlock(&mq_lock);
14939 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14940 if (!info->messages) {
14941 spin_lock(&mq_lock);
14942 u->mq_bytes -= mq_bytes;
14943 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14944 spin_unlock(&mq_lock);
14948 info->user = get_uid(u);
14949 + info->vxi = get_vx_info(vxi);
14950 } else if (S_ISDIR(mode)) {
14952 /* Some things misbehave if size == 0 on a directory */
14953 @@ -269,8 +278,11 @@ static void mqueue_delete_inode(struct i
14954 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14957 + struct vx_info *vxi = info->vxi;
14959 spin_lock(&mq_lock);
14960 user->mq_bytes -= mq_bytes;
14961 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14963 * get_ns_from_inode() ensures that the
14964 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14965 @@ -280,6 +292,7 @@ static void mqueue_delete_inode(struct i
14967 ipc_ns->mq_queues_count--;
14968 spin_unlock(&mq_lock);
14969 + put_vx_info(vxi);
14973 diff -NurpP --minimal linux-2.6.32.56/ipc/msg.c linux-2.6.32.56-vs2.3.0.36.29.9/ipc/msg.c
14974 --- linux-2.6.32.56/ipc/msg.c 2012-02-09 10:22:35.000000000 +0100
14975 +++ linux-2.6.32.56-vs2.3.0.36.29.9/ipc/msg.c 2011-06-10 13:03:02.000000000 +0200
14977 #include <linux/rwsem.h>
14978 #include <linux/nsproxy.h>
14979 #include <linux/ipc_namespace.h>
14980 +#include <linux/vs_base.h>
14982 #include <asm/current.h>
14983 #include <asm/uaccess.h>
14984 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
14986 msq->q_perm.mode = msgflg & S_IRWXUGO;
14987 msq->q_perm.key = key;
14988 + msq->q_perm.xid = vx_current_xid();
14990 msq->q_perm.security = NULL;
14991 retval = security_msg_queue_alloc(msq);
14992 diff -NurpP --minimal linux-2.6.32.56/ipc/namespace.c linux-2.6.32.56-vs2.3.0.36.29.9/ipc/namespace.c
14993 --- linux-2.6.32.56/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14994 +++ linux-2.6.32.56-vs2.3.0.36.29.9/ipc/namespace.c 2011-06-10 13:03:02.000000000 +0200
14996 #include <linux/slab.h>
14997 #include <linux/fs.h>
14998 #include <linux/mount.h>
14999 +#include <linux/vs_base.h>
15000 +#include <linux/vserver/global.h>
15004 diff -NurpP --minimal linux-2.6.32.56/ipc/sem.c linux-2.6.32.56-vs2.3.0.36.29.9/ipc/sem.c
15005 --- linux-2.6.32.56/ipc/sem.c 2012-02-09 10:22:35.000000000 +0100
15006 +++ linux-2.6.32.56-vs2.3.0.36.29.9/ipc/sem.c 2011-06-10 13:03:02.000000000 +0200
15008 #include <linux/rwsem.h>
15009 #include <linux/nsproxy.h>
15010 #include <linux/ipc_namespace.h>
15011 +#include <linux/vs_base.h>
15012 +#include <linux/vs_limit.h>
15014 #include <asm/uaccess.h>
15016 @@ -256,6 +258,7 @@ static int newary(struct ipc_namespace *
15018 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15019 sma->sem_perm.key = key;
15020 + sma->sem_perm.xid = vx_current_xid();
15022 sma->sem_perm.security = NULL;
15023 retval = security_sem_alloc(sma);
15024 @@ -271,6 +274,9 @@ static int newary(struct ipc_namespace *
15027 ns->used_sems += nsems;
15028 + /* FIXME: obsoleted? */
15029 + vx_semary_inc(sma);
15030 + vx_nsems_add(sma, nsems);
15032 sma->sem_base = (struct sem *) &sma[1];
15033 INIT_LIST_HEAD(&sma->sem_pending);
15034 @@ -547,6 +553,9 @@ static void freeary(struct ipc_namespace
15037 ns->used_sems -= sma->sem_nsems;
15038 + /* FIXME: obsoleted? */
15039 + vx_nsems_sub(sma, sma->sem_nsems);
15040 + vx_semary_dec(sma);
15041 security_sem_free(sma);
15042 ipc_rcu_putref(sma);
15044 diff -NurpP --minimal linux-2.6.32.56/ipc/shm.c linux-2.6.32.56-vs2.3.0.36.29.9/ipc/shm.c
15045 --- linux-2.6.32.56/ipc/shm.c 2012-02-09 10:22:35.000000000 +0100
15046 +++ linux-2.6.32.56-vs2.3.0.36.29.9/ipc/shm.c 2011-06-10 13:03:02.000000000 +0200
15048 #include <linux/mount.h>
15049 #include <linux/ipc_namespace.h>
15050 #include <linux/ima.h>
15051 +#include <linux/vs_context.h>
15052 +#include <linux/vs_limit.h>
15054 #include <asm/uaccess.h>
15056 @@ -170,7 +172,12 @@ static void shm_open(struct vm_area_stru
15058 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15060 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15061 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15062 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15064 + vx_ipcshm_sub(vxi, shp, numpages);
15065 + ns->shm_tot -= numpages;
15069 if (!is_file_hugepages(shp->shm_file))
15070 @@ -180,6 +187,7 @@ static void shm_destroy(struct ipc_names
15072 fput (shp->shm_file);
15073 security_shm_free(shp);
15074 + put_vx_info(vxi);
15075 ipc_rcu_putref(shp);
15078 @@ -350,11 +358,15 @@ static int newseg(struct ipc_namespace *
15079 if (ns->shm_tot + numpages > ns->shm_ctlall)
15082 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
15085 shp = ipc_rcu_alloc(sizeof(*shp));
15089 shp->shm_perm.key = key;
15090 + shp->shm_perm.xid = vx_current_xid();
15091 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15092 shp->mlock_user = NULL;
15094 @@ -408,6 +420,7 @@ static int newseg(struct ipc_namespace *
15095 ns->shm_tot += numpages;
15096 error = shp->shm_perm.id;
15098 + vx_ipcshm_add(current_vx_info(), key, numpages);
15102 diff -NurpP --minimal linux-2.6.32.56/kernel/Makefile linux-2.6.32.56-vs2.3.0.36.29.9/kernel/Makefile
15103 --- linux-2.6.32.56/kernel/Makefile 2009-12-03 20:02:57.000000000 +0100
15104 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/Makefile 2011-06-10 13:03:02.000000000 +0200
15105 @@ -23,6 +23,7 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
15106 CFLAGS_REMOVE_sched_clock.o = -pg
15110 obj-$(CONFIG_FREEZER) += freezer.o
15111 obj-$(CONFIG_PROFILING) += profile.o
15112 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15113 diff -NurpP --minimal linux-2.6.32.56/kernel/capability.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/capability.c
15114 --- linux-2.6.32.56/kernel/capability.c 2012-02-09 10:22:35.000000000 +0100
15115 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/capability.c 2011-06-10 13:03:02.000000000 +0200
15117 #include <linux/security.h>
15118 #include <linux/syscalls.h>
15119 #include <linux/pid_namespace.h>
15120 +#include <linux/vs_context.h>
15121 #include <asm/uaccess.h>
15124 @@ -121,6 +122,7 @@ static int cap_validate_magic(cap_user_h
15130 * The only thing that can change the capabilities of the current
15131 * process is the current process. As such, we can't be in this code
15132 @@ -288,6 +290,8 @@ error:
15136 +#include <linux/vserver/base.h>
15139 * capable - Determine if the current task has a superior capability in effect
15140 * @cap: The capability to be tested for
15141 @@ -300,6 +304,9 @@ error:
15143 int capable(int cap)
15145 + /* here for now so we don't require task locking */
15146 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15148 if (unlikely(!cap_valid(cap))) {
15149 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15151 diff -NurpP --minimal linux-2.6.32.56/kernel/compat.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/compat.c
15152 --- linux-2.6.32.56/kernel/compat.c 2012-02-09 10:22:36.000000000 +0100
15153 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/compat.c 2011-06-10 13:03:02.000000000 +0200
15154 @@ -900,7 +900,7 @@ asmlinkage long compat_sys_time(compat_t
15158 - do_gettimeofday(&tv);
15159 + vx_gettimeofday(&tv);
15163 @@ -925,7 +925,7 @@ asmlinkage long compat_sys_stime(compat_
15167 - do_settimeofday(&tv);
15168 + vx_settimeofday(&tv);
15172 diff -NurpP --minimal linux-2.6.32.56/kernel/exit.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/exit.c
15173 --- linux-2.6.32.56/kernel/exit.c 2012-02-09 10:22:36.000000000 +0100
15174 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/exit.c 2011-06-10 13:03:02.000000000 +0200
15176 #include <linux/fs_struct.h>
15177 #include <linux/init_task.h>
15178 #include <linux/perf_event.h>
15179 +#include <linux/vs_limit.h>
15180 +#include <linux/vs_context.h>
15181 +#include <linux/vs_network.h>
15182 +#include <linux/vs_pid.h>
15183 #include <trace/events/sched.h>
15185 #include <asm/uaccess.h>
15186 @@ -495,9 +499,11 @@ static void close_files(struct files_str
15187 filp_close(file, files);
15190 + vx_openfd_dec(i);
15198 @@ -1027,11 +1033,16 @@ NORET_TYPE void do_exit(long code)
15200 validate_creds_for_do_exit(tsk);
15202 + /* needs to stay after exit_notify() */
15203 + exit_vx_info(tsk, code);
15204 + exit_nx_info(tsk);
15208 /* causes final put_task_struct in finish_task_switch(). */
15209 tsk->state = TASK_DEAD;
15211 + printk("bad task: %p [%lx]\n", current, current->state);
15213 /* Avoid "noreturn function does return". */
15215 diff -NurpP --minimal linux-2.6.32.56/kernel/fork.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/fork.c
15216 --- linux-2.6.32.56/kernel/fork.c 2012-02-09 10:22:36.000000000 +0100
15217 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/fork.c 2011-06-10 13:03:02.000000000 +0200
15219 #include <linux/magic.h>
15220 #include <linux/perf_event.h>
15221 #include <linux/posix-timers.h>
15222 +#include <linux/vs_context.h>
15223 +#include <linux/vs_network.h>
15224 +#include <linux/vs_limit.h>
15225 +#include <linux/vs_memory.h>
15227 #include <asm/pgtable.h>
15228 #include <asm/pgalloc.h>
15229 @@ -151,6 +155,8 @@ void free_task(struct task_struct *tsk)
15230 account_kernel_stack(tsk->stack, -1);
15231 free_thread_info(tsk->stack);
15232 rt_mutex_debug_task_free(tsk);
15233 + clr_vx_info(&tsk->vx_info);
15234 + clr_nx_info(&tsk->nx_info);
15235 ftrace_graph_exit_task(tsk);
15236 free_task_struct(tsk);
15238 @@ -296,6 +302,8 @@ static int dup_mmap(struct mm_struct *mm
15239 mm->free_area_cache = oldmm->mmap_base;
15240 mm->cached_hole_size = ~0UL;
15242 + __set_mm_counter(mm, file_rss, 0);
15243 + __set_mm_counter(mm, anon_rss, 0);
15244 cpumask_clear(mm_cpumask(mm));
15245 mm->mm_rb = RB_ROOT;
15246 rb_link = &mm->mm_rb.rb_node;
15247 @@ -311,7 +319,7 @@ static int dup_mmap(struct mm_struct *mm
15249 if (mpnt->vm_flags & VM_DONTCOPY) {
15250 long pages = vma_pages(mpnt);
15251 - mm->total_vm -= pages;
15252 + vx_vmpages_sub(mm, pages);
15253 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15256 @@ -455,8 +463,8 @@ static struct mm_struct * mm_init(struct
15257 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
15258 mm->core_state = NULL;
15260 - set_mm_counter(mm, file_rss, 0);
15261 - set_mm_counter(mm, anon_rss, 0);
15262 + __set_mm_counter(mm, file_rss, 0);
15263 + __set_mm_counter(mm, anon_rss, 0);
15264 spin_lock_init(&mm->page_table_lock);
15265 mm->free_area_cache = TASK_UNMAPPED_BASE;
15266 mm->cached_hole_size = ~0UL;
15267 @@ -466,6 +474,7 @@ static struct mm_struct * mm_init(struct
15268 if (likely(!mm_alloc_pgd(mm))) {
15270 mmu_notifier_mm_init(mm);
15271 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15275 @@ -499,6 +508,7 @@ void __mmdrop(struct mm_struct *mm)
15277 destroy_context(mm);
15278 mmu_notifier_mm_destroy(mm);
15279 + clr_vx_info(&mm->mm_vx_info);
15282 EXPORT_SYMBOL_GPL(__mmdrop);
15283 @@ -634,6 +644,7 @@ struct mm_struct *dup_mm(struct task_str
15286 memcpy(mm, oldmm, sizeof(*mm));
15287 + mm->mm_vx_info = NULL;
15289 /* Initializing for Swap token stuff */
15290 mm->token_priority = 0;
15291 @@ -672,6 +683,7 @@ fail_nocontext:
15292 * If init_new_context() failed, we cannot use mmput() to free the mm
15293 * because it calls destroy_context()
15295 + clr_vx_info(&mm->mm_vx_info);
15299 @@ -986,6 +998,8 @@ static struct task_struct *copy_process(
15301 struct task_struct *p;
15302 int cgroup_callbacks_done = 0;
15303 + struct vx_info *vxi;
15304 + struct nx_info *nxi;
15306 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15307 return ERR_PTR(-EINVAL);
15308 @@ -1032,12 +1046,28 @@ static struct task_struct *copy_process(
15309 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15310 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15312 + init_vx_info(&p->vx_info, current_vx_info());
15313 + init_nx_info(&p->nx_info, current_nx_info());
15315 + /* check vserver memory */
15316 + if (p->mm && !(clone_flags & CLONE_VM)) {
15317 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15318 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15320 + goto bad_fork_free;
15322 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15323 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15324 + goto bad_fork_cleanup_vm;
15327 + if (!vx_nproc_avail(1))
15328 + goto bad_fork_cleanup_vm;
15329 if (atomic_read(&p->real_cred->user->processes) >=
15330 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15331 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15332 p->real_cred->user != INIT_USER)
15333 - goto bad_fork_free;
15334 + goto bad_fork_cleanup_vm;
15337 retval = copy_creds(p, clone_flags);
15338 @@ -1289,6 +1319,18 @@ static struct task_struct *copy_process(
15341 spin_unlock(¤t->sighand->siglock);
15343 + /* p is copy of current */
15344 + vxi = p->vx_info;
15346 + claim_vx_info(vxi, p);
15347 + atomic_inc(&vxi->cvirt.nr_threads);
15348 + atomic_inc(&vxi->cvirt.total_forks);
15351 + nxi = p->nx_info;
15353 + claim_nx_info(nxi, p);
15354 write_unlock_irq(&tasklist_lock);
15355 proc_fork_connector(p);
15356 cgroup_post_fork(p);
15357 @@ -1330,6 +1372,9 @@ bad_fork_cleanup_cgroup:
15358 bad_fork_cleanup_count:
15359 atomic_dec(&p->cred->user->processes);
15361 +bad_fork_cleanup_vm:
15362 + if (p->mm && !(clone_flags & CLONE_VM))
15363 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15367 diff -NurpP --minimal linux-2.6.32.56/kernel/kthread.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/kthread.c
15368 --- linux-2.6.32.56/kernel/kthread.c 2012-02-09 10:22:36.000000000 +0100
15369 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/kthread.c 2011-06-10 13:03:02.000000000 +0200
15371 #include <linux/file.h>
15372 #include <linux/module.h>
15373 #include <linux/mutex.h>
15374 +#include <linux/vs_pid.h>
15375 #include <trace/events/sched.h>
15377 static DEFINE_SPINLOCK(kthread_create_lock);
15378 diff -NurpP --minimal linux-2.6.32.56/kernel/nsproxy.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/nsproxy.c
15379 --- linux-2.6.32.56/kernel/nsproxy.c 2009-09-10 15:26:28.000000000 +0200
15380 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/nsproxy.c 2011-06-10 13:03:02.000000000 +0200
15382 #include <linux/mnt_namespace.h>
15383 #include <linux/utsname.h>
15384 #include <linux/pid_namespace.h>
15385 +#include <linux/vserver/global.h>
15386 +#include <linux/vserver/debug.h>
15387 #include <net/net_namespace.h>
15388 #include <linux/ipc_namespace.h>
15390 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
15391 struct nsproxy *nsproxy;
15393 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15396 atomic_set(&nsproxy->count, 1);
15397 + atomic_inc(&vs_global_nsproxy);
15399 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15403 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
15404 * Return the newly created nsproxy. Do not attach this to the task,
15405 * leave it to the caller to do proper locking and attach it to task.
15407 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15408 - struct task_struct *tsk, struct fs_struct *new_fs)
15409 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15410 + struct nsproxy *orig, struct fs_struct *new_fs)
15412 struct nsproxy *new_nsp;
15415 + vxdprintk(VXD_CBIT(space, 4),
15416 + "unshare_namespaces(0x%08lx,%p,%p)",
15417 + flags, orig, new_fs);
15419 new_nsp = create_nsproxy();
15421 return ERR_PTR(-ENOMEM);
15423 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15424 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15425 if (IS_ERR(new_nsp->mnt_ns)) {
15426 err = PTR_ERR(new_nsp->mnt_ns);
15430 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15431 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15432 if (IS_ERR(new_nsp->uts_ns)) {
15433 err = PTR_ERR(new_nsp->uts_ns);
15437 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15438 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15439 if (IS_ERR(new_nsp->ipc_ns)) {
15440 err = PTR_ERR(new_nsp->ipc_ns);
15444 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15445 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15446 if (IS_ERR(new_nsp->pid_ns)) {
15447 err = PTR_ERR(new_nsp->pid_ns);
15451 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15453 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15454 + if (IS_ERR(new_nsp->user_ns)) {
15455 + err = PTR_ERR(new_nsp->user_ns);
15459 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15460 if (IS_ERR(new_nsp->net_ns)) {
15461 err = PTR_ERR(new_nsp->net_ns);
15463 @@ -100,6 +116,38 @@ out_ns:
15464 return ERR_PTR(err);
15467 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15468 + struct fs_struct *new_fs)
15470 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15474 + * copies the nsproxy, setting refcount to 1, and grabbing a
15475 + * reference to all contained namespaces.
15477 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15479 + struct nsproxy *ns = create_nsproxy();
15482 + memcpy(ns, orig, sizeof(struct nsproxy));
15483 + atomic_set(&ns->count, 1);
15486 + get_mnt_ns(ns->mnt_ns);
15488 + get_uts_ns(ns->uts_ns);
15490 + get_ipc_ns(ns->ipc_ns);
15492 + get_pid_ns(ns->pid_ns);
15494 + get_net(ns->net_ns);
15500 * called from clone. This now handles copy for nsproxy and all
15501 * namespaces therein.
15502 @@ -107,9 +155,12 @@ out_ns:
15503 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15505 struct nsproxy *old_ns = tsk->nsproxy;
15506 - struct nsproxy *new_ns;
15507 + struct nsproxy *new_ns = NULL;
15510 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15511 + flags, tsk, old_ns);
15516 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
15517 CLONE_NEWPID | CLONE_NEWNET)))
15520 - if (!capable(CAP_SYS_ADMIN)) {
15521 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15525 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
15528 put_nsproxy(old_ns);
15529 + vxdprintk(VXD_CBIT(space, 3),
15530 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15531 + flags, tsk, old_ns, err, new_ns);
15535 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
15536 put_ipc_ns(ns->ipc_ns);
15538 put_pid_ns(ns->pid_ns);
15539 - put_net(ns->net_ns);
15541 + put_net(ns->net_ns);
15542 + atomic_dec(&vs_global_nsproxy);
15543 kmem_cache_free(nsproxy_cachep, ns);
15546 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned
15550 + vxdprintk(VXD_CBIT(space, 4),
15551 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15552 + unshare_flags, current->nsproxy);
15554 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15558 - if (!capable(CAP_SYS_ADMIN))
15559 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15562 *new_nsp = create_new_namespaces(unshare_flags, current,
15563 diff -NurpP --minimal linux-2.6.32.56/kernel/pid.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/pid.c
15564 --- linux-2.6.32.56/kernel/pid.c 2012-02-09 10:22:36.000000000 +0100
15565 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/pid.c 2011-06-10 13:03:02.000000000 +0200
15567 #include <linux/pid_namespace.h>
15568 #include <linux/init_task.h>
15569 #include <linux/syscalls.h>
15570 +#include <linux/vs_pid.h>
15572 #define pid_hashfn(nr, ns) \
15573 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15574 @@ -308,7 +309,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15576 struct pid *find_vpid(int nr)
15578 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15579 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15581 EXPORT_SYMBOL_GPL(find_vpid);
15583 @@ -368,6 +369,9 @@ void transfer_pid(struct task_struct *ol
15584 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15586 struct task_struct *result = NULL;
15588 + if (type == PIDTYPE_REALPID)
15589 + type = PIDTYPE_PID;
15591 struct hlist_node *first;
15592 first = rcu_dereference(pid->tasks[type].first);
15593 @@ -383,7 +387,7 @@ EXPORT_SYMBOL(pid_task);
15595 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15597 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15598 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15601 struct task_struct *find_task_by_vpid(pid_t vnr)
15602 @@ -425,7 +429,7 @@ struct pid *find_get_pid(pid_t nr)
15604 EXPORT_SYMBOL_GPL(find_get_pid);
15606 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15607 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15611 @@ -438,6 +442,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15615 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15617 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15620 pid_t pid_vnr(struct pid *pid)
15622 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15623 diff -NurpP --minimal linux-2.6.32.56/kernel/pid_namespace.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/pid_namespace.c
15624 --- linux-2.6.32.56/kernel/pid_namespace.c 2009-12-03 20:02:58.000000000 +0100
15625 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/pid_namespace.c 2011-06-10 13:03:02.000000000 +0200
15627 #include <linux/syscalls.h>
15628 #include <linux/err.h>
15629 #include <linux/acct.h>
15630 +#include <linux/vserver/global.h>
15632 #define BITS_PER_PAGE (PAGE_SIZE*8)
15634 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
15637 kref_init(&ns->kref);
15638 + atomic_inc(&vs_global_pid_ns);
15640 ns->parent = get_pid_ns(parent_pid_ns);
15642 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
15644 for (i = 0; i < PIDMAP_ENTRIES; i++)
15645 kfree(ns->pidmap[i].page);
15646 + atomic_dec(&vs_global_pid_ns);
15647 kmem_cache_free(pid_ns_cachep, ns);
15650 diff -NurpP --minimal linux-2.6.32.56/kernel/posix-timers.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/posix-timers.c
15651 --- linux-2.6.32.56/kernel/posix-timers.c 2012-02-09 10:22:36.000000000 +0100
15652 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/posix-timers.c 2011-06-10 13:03:02.000000000 +0200
15654 #include <linux/wait.h>
15655 #include <linux/workqueue.h>
15656 #include <linux/module.h>
15657 +#include <linux/vs_context.h>
15660 * Management arrays for POSIX timers. Timers are kept in slab memory
15661 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15663 struct task_struct *task;
15664 int shared, ret = -1;
15667 * FIXME: if ->sigq is queued we can race with
15668 * dequeue_signal()->do_schedule_next_timer().
15669 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15671 task = pid_task(timr->it_pid, PIDTYPE_PID);
15673 + struct vx_info_save vxis;
15674 + struct vx_info *vxi;
15676 + vxi = get_vx_info(task->vx_info);
15677 + enter_vx_info(vxi, &vxis);
15678 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15679 ret = send_sigqueue(timr->sigq, task, shared);
15680 + leave_vx_info(&vxis);
15681 + put_vx_info(vxi);
15685 /* If we failed to send the signal the timer stops. */
15688 diff -NurpP --minimal linux-2.6.32.56/kernel/printk.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/printk.c
15689 --- linux-2.6.32.56/kernel/printk.c 2012-02-09 10:22:36.000000000 +0100
15690 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/printk.c 2011-06-10 13:03:02.000000000 +0200
15692 #include <linux/bootmem.h>
15693 #include <linux/syscalls.h>
15694 #include <linux/kexec.h>
15695 +#include <linux/vs_cvirt.h>
15697 #include <asm/uaccess.h>
15699 @@ -276,18 +277,13 @@ int do_syslog(int type, char __user *buf
15700 unsigned i, j, limit, count;
15706 error = security_syslog(type);
15711 - case 0: /* Close log */
15713 - case 1: /* Open log */
15715 - case 2: /* Read from log */
15716 + if ((type >= 2) && (type <= 4)) {
15718 if (!buf || len < 0)
15720 @@ -298,6 +294,16 @@ int do_syslog(int type, char __user *buf
15725 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15726 + return vx_do_syslog(type, buf, len);
15729 + case 0: /* Close log */
15731 + case 1: /* Open log */
15733 + case 2: /* Read from log */
15734 error = wait_event_interruptible(log_wait,
15735 (log_start - log_end));
15737 @@ -322,16 +328,6 @@ int do_syslog(int type, char __user *buf
15740 case 3: /* Read last kernel messages */
15742 - if (!buf || len < 0)
15747 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15752 if (count > log_buf_len)
15753 count = log_buf_len;
15754 diff -NurpP --minimal linux-2.6.32.56/kernel/ptrace.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/ptrace.c
15755 --- linux-2.6.32.56/kernel/ptrace.c 2012-02-09 10:22:36.000000000 +0100
15756 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/ptrace.c 2011-06-10 14:03:28.000000000 +0200
15758 #include <linux/pid_namespace.h>
15759 #include <linux/syscalls.h>
15760 #include <linux/uaccess.h>
15761 +#include <linux/vs_context.h>
15765 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
15766 dumpable = get_dumpable(task->mm);
15767 if (!dumpable && !capable(CAP_SYS_PTRACE))
15769 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15771 + if (!vx_check(task->xid, VS_IDENT) &&
15772 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15775 return security_ptrace_access_check(task, mode);
15777 diff -NurpP --minimal linux-2.6.32.56/kernel/sched.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched.c
15778 --- linux-2.6.32.56/kernel/sched.c 2012-02-09 10:22:36.000000000 +0100
15779 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched.c 2011-06-10 13:15:21.000000000 +0200
15781 #include <linux/debugfs.h>
15782 #include <linux/ctype.h>
15783 #include <linux/ftrace.h>
15784 +#include <linux/vs_sched.h>
15785 +#include <linux/vs_cvirt.h>
15787 #include <asm/tlb.h>
15788 #include <asm/irq_regs.h>
15789 @@ -237,6 +239,15 @@ static DEFINE_MUTEX(sched_domains_mutex)
15791 #include <linux/cgroup.h>
15793 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
15794 +struct cfs_bandwidth {
15795 + spinlock_t cfs_runtime_lock;
15796 + ktime_t cfs_period;
15798 + struct hrtimer cfs_period_timer;
15804 static LIST_HEAD(task_groups);
15805 @@ -251,6 +262,9 @@ struct task_group {
15806 /* runqueue "owned" by this group on each cpu */
15807 struct cfs_rq **cfs_rq;
15808 unsigned long shares;
15809 +#ifdef CONFIG_CFS_HARD_LIMITS
15810 + struct cfs_bandwidth cfs_bandwidth;
15814 #ifdef CONFIG_RT_GROUP_SCHED
15815 @@ -404,6 +418,19 @@ struct cfs_rq {
15816 unsigned long rq_weight;
15819 +#ifdef CONFIG_CFS_HARD_LIMITS
15820 + /* set when the group is throttled on this cpu */
15821 + int cfs_throttled;
15823 + /* runtime currently consumed by the group on this rq */
15826 + /* runtime available to the group on this rq */
15829 + /* Protects the cfs runtime related fields of this cfs_rq */
15830 + spinlock_t cfs_runtime_lock;
15834 /* Real-Time classes' related field in a runqueue: */
15835 @@ -1586,6 +1613,7 @@ static void update_group_shares_cpu(stru
15839 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq);
15841 * Re-compute the task group their per cpu shares over the given domain.
15842 * This needs to be done in a bottom-up fashion because the rq weight of a
15843 @@ -1614,8 +1642,10 @@ static int tg_shares_up(struct task_grou
15844 * If there are currently no tasks on the cpu pretend there
15845 * is one of average load so that when a new task gets to
15846 * run here it will not get delayed by group starvation.
15847 + * Also if the group is throttled on this cpu, pretend that
15848 + * it has no tasks.
15851 + if (!weight || cfs_rq_throttled(tg->cfs_rq[i]))
15852 weight = NICE_0_LOAD;
15854 sum_weight += weight;
15855 @@ -1792,6 +1822,175 @@ static void cfs_rq_set_shares(struct cfs
15856 static void calc_load_account_active(struct rq *this_rq);
15857 static void update_sysctl(void);
15860 +#if defined(CONFIG_RT_GROUP_SCHED) || defined(CONFIG_FAIR_GROUP_SCHED)
15863 +static inline const struct cpumask *sched_bw_period_mask(void)
15865 + return cpu_rq(smp_processor_id())->rd->span;
15867 +#else /* !CONFIG_SMP */
15868 +static inline const struct cpumask *sched_bw_period_mask(void)
15870 + return cpu_online_mask;
15872 +#endif /* CONFIG_SMP */
15875 +static inline const struct cpumask *sched_bw_period_mask(void)
15877 + return cpu_online_mask;
15882 +#ifdef CONFIG_FAIR_GROUP_SCHED
15883 +#ifdef CONFIG_CFS_HARD_LIMITS
15886 + * Runtime allowed for a cfs group before it is hard limited.
15887 + * default: Infinite which means no hard limiting.
15889 +u64 sched_cfs_runtime = RUNTIME_INF;
15892 + * period over which we hard limit the cfs group's bandwidth.
15895 +u64 sched_cfs_period = 500000;
15897 +static inline u64 global_cfs_period(void)
15899 + return sched_cfs_period * NSEC_PER_USEC;
15902 +static inline u64 global_cfs_runtime(void)
15904 + return RUNTIME_INF;
15907 +void do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b);
15909 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
15911 + spin_lock(&cfs_rq->cfs_runtime_lock);
15914 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
15916 + spin_unlock(&cfs_rq->cfs_runtime_lock);
15920 + * Refresh the runtimes of the throttled groups.
15921 + * But nothing much to do now, will populate this in later patches.
15923 +static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)
15925 + struct cfs_bandwidth *cfs_b =
15926 + container_of(timer, struct cfs_bandwidth, cfs_period_timer);
15928 + do_sched_cfs_period_timer(cfs_b);
15929 + hrtimer_add_expires_ns(timer, ktime_to_ns(cfs_b->cfs_period));
15930 + return HRTIMER_RESTART;
15934 + * TODO: Check if this kind of timer setup is sufficient for cfs or
15935 + * should we do what rt is doing.
15937 +static void start_cfs_bandwidth(struct task_group *tg)
15939 + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
15942 + * Timer isn't setup for groups with infinite runtime
15944 + if (cfs_b->cfs_runtime == RUNTIME_INF)
15947 + if (hrtimer_active(&cfs_b->cfs_period_timer))
15950 + hrtimer_start_range_ns(&cfs_b->cfs_period_timer, cfs_b->cfs_period,
15951 + 0, HRTIMER_MODE_REL);
15954 +static void init_cfs_bandwidth(struct task_group *tg)
15956 + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
15958 + cfs_b->cfs_period = ns_to_ktime(global_cfs_period());
15959 + cfs_b->cfs_runtime = global_cfs_runtime();
15961 + spin_lock_init(&cfs_b->cfs_runtime_lock);
15963 + hrtimer_init(&cfs_b->cfs_period_timer,
15964 + CLOCK_MONOTONIC, HRTIMER_MODE_REL);
15965 + cfs_b->cfs_period_timer.function = &sched_cfs_period_timer;
15968 +static inline void destroy_cfs_bandwidth(struct task_group *tg)
15970 + hrtimer_cancel(&tg->cfs_bandwidth.cfs_period_timer);
15973 +static void init_cfs_hard_limits(struct cfs_rq *cfs_rq, struct task_group *tg)
15975 + cfs_rq->cfs_time = 0;
15976 + cfs_rq->cfs_throttled = 0;
15977 + cfs_rq->cfs_runtime = tg->cfs_bandwidth.cfs_runtime;
15978 + spin_lock_init(&cfs_rq->cfs_runtime_lock);
15981 +#else /* !CONFIG_CFS_HARD_LIMITS */
15983 +static void init_cfs_bandwidth(struct task_group *tg)
15988 +static inline void destroy_cfs_bandwidth(struct task_group *tg)
15993 +static void init_cfs_hard_limits(struct cfs_rq *cfs_rq, struct task_group *tg)
15998 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
16003 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
16008 +#endif /* CONFIG_CFS_HARD_LIMITS */
16009 +#else /* !CONFIG_FAIR_GROUP_SCHED */
16011 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
16016 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
16021 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16026 +#endif /* CONFIG_FAIR_GROUP_SCHED */
16028 static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
16030 set_task_rq(p, cpu);
16031 @@ -3129,9 +3328,17 @@ EXPORT_SYMBOL(avenrun);
16033 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
16035 - loads[0] = (avenrun[0] + offset) << shift;
16036 - loads[1] = (avenrun[1] + offset) << shift;
16037 - loads[2] = (avenrun[2] + offset) << shift;
16038 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
16039 + struct vx_info *vxi = current_vx_info();
16041 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
16042 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
16043 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
16045 + loads[0] = (avenrun[0] + offset) << shift;
16046 + loads[1] = (avenrun[1] + offset) << shift;
16047 + loads[2] = (avenrun[2] + offset) << shift;
16051 static unsigned long
16052 @@ -5245,16 +5452,19 @@ void account_user_time(struct task_struc
16053 cputime_t cputime_scaled)
16055 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16056 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16058 + int nice = (TASK_NICE(p) > 0);
16060 /* Add user time to process. */
16061 p->utime = cputime_add(p->utime, cputime);
16062 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
16063 + vx_account_user(vxi, cputime, nice);
16064 account_group_user_time(p, cputime);
16066 /* Add user time to cpustat. */
16067 tmp = cputime_to_cputime64(cputime);
16068 - if (TASK_NICE(p) > 0)
16070 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16072 cpustat->user = cputime64_add(cpustat->user, tmp);
16073 @@ -5300,6 +5510,7 @@ void account_system_time(struct task_str
16074 cputime_t cputime, cputime_t cputime_scaled)
16076 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16077 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16080 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
16081 @@ -5310,6 +5521,7 @@ void account_system_time(struct task_str
16082 /* Add system time to process. */
16083 p->stime = cputime_add(p->stime, cputime);
16084 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
16085 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
16086 account_group_system_time(p, cputime);
16088 /* Add system time to cpustat. */
16089 @@ -6393,7 +6605,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16092 if (increment < 0 && !can_nice(current, nice))
16094 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16096 retval = security_task_setnice(current, nice);
16098 @@ -9470,6 +9682,32 @@ static int update_sched_domains(struct n
16103 +static void disable_runtime(struct rq *rq)
16105 + unsigned long flags;
16107 + spin_lock_irqsave(&rq->lock, flags);
16108 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16109 + disable_runtime_cfs(rq);
16111 + disable_runtime_rt(rq);
16112 + spin_unlock_irqrestore(&rq->lock, flags);
16115 +static void enable_runtime(struct rq *rq)
16117 + unsigned long flags;
16119 + spin_lock_irqsave(&rq->lock, flags);
16120 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16121 + enable_runtime_cfs(rq);
16123 + enable_runtime_rt(rq);
16124 + spin_unlock_irqrestore(&rq->lock, flags);
16128 static int update_runtime(struct notifier_block *nfb,
16129 unsigned long action, void *hcpu)
16131 @@ -9602,6 +9840,7 @@ static void init_tg_cfs_entry(struct tas
16132 struct rq *rq = cpu_rq(cpu);
16133 tg->cfs_rq[cpu] = cfs_rq;
16134 init_cfs_rq(cfs_rq, rq);
16135 + init_cfs_hard_limits(cfs_rq, tg);
16138 list_add(&cfs_rq->leaf_cfs_rq_list, &rq->leaf_cfs_rq_list);
16139 @@ -9710,6 +9949,10 @@ void __init sched_init(void)
16140 global_rt_period(), global_rt_runtime());
16141 #endif /* CONFIG_RT_GROUP_SCHED */
16143 +#ifdef CONFIG_FAIR_GROUP_SCHED
16144 + init_cfs_bandwidth(&init_task_group);
16147 #ifdef CONFIG_CGROUP_SCHED
16148 list_add(&init_task_group.list, &task_groups);
16149 INIT_LIST_HEAD(&init_task_group.children);
16150 @@ -9731,6 +9974,7 @@ void __init sched_init(void)
16151 init_cfs_rq(&rq->cfs, rq);
16152 init_rt_rq(&rq->rt, rq);
16153 #ifdef CONFIG_FAIR_GROUP_SCHED
16154 + init_cfs_hard_limits(&rq->cfs, &init_task_group);
16155 init_task_group.shares = init_task_group_load;
16156 INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
16157 #ifdef CONFIG_CGROUP_SCHED
16158 @@ -9992,6 +10236,7 @@ static void free_fair_sched_group(struct
16162 + destroy_cfs_bandwidth(tg);
16163 for_each_possible_cpu(i) {
16165 kfree(tg->cfs_rq[i]);
16166 @@ -10018,6 +10263,7 @@ int alloc_fair_sched_group(struct task_g
16170 + init_cfs_bandwidth(tg);
16171 tg->shares = NICE_0_LOAD;
16173 for_each_possible_cpu(i) {
16174 @@ -10734,6 +10980,100 @@ static u64 cpu_shares_read_u64(struct cg
16176 return (u64) tg->shares;
16179 +#ifdef CONFIG_CFS_HARD_LIMITS
16181 +static int tg_set_cfs_bandwidth(struct task_group *tg,
16182 + u64 cfs_period, u64 cfs_runtime)
16186 + spin_lock_irq(&tg->cfs_bandwidth.cfs_runtime_lock);
16187 + tg->cfs_bandwidth.cfs_period = ns_to_ktime(cfs_period);
16188 + tg->cfs_bandwidth.cfs_runtime = cfs_runtime;
16190 + for_each_possible_cpu(i) {
16191 + struct cfs_rq *cfs_rq = tg->cfs_rq[i];
16193 + cfs_rq_runtime_lock(cfs_rq);
16194 + cfs_rq->cfs_runtime = cfs_runtime;
16195 + cfs_rq_runtime_unlock(cfs_rq);
16198 + start_cfs_bandwidth(tg);
16199 + spin_unlock_irq(&tg->cfs_bandwidth.cfs_runtime_lock);
16203 +int tg_set_cfs_runtime(struct task_group *tg, long cfs_runtime_us)
16205 + u64 cfs_runtime, cfs_period;
16207 + cfs_period = ktime_to_ns(tg->cfs_bandwidth.cfs_period);
16208 + cfs_runtime = (u64)cfs_runtime_us * NSEC_PER_USEC;
16209 + if (cfs_runtime_us < 0)
16210 + cfs_runtime = RUNTIME_INF;
16212 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16215 +long tg_get_cfs_runtime(struct task_group *tg)
16217 + u64 cfs_runtime_us;
16219 + if (tg->cfs_bandwidth.cfs_runtime == RUNTIME_INF)
16222 + cfs_runtime_us = tg->cfs_bandwidth.cfs_runtime;
16223 + do_div(cfs_runtime_us, NSEC_PER_USEC);
16224 + return cfs_runtime_us;
16227 +int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
16229 + u64 cfs_runtime, cfs_period;
16231 + cfs_period = (u64)cfs_period_us * NSEC_PER_USEC;
16232 + cfs_runtime = tg->cfs_bandwidth.cfs_runtime;
16234 + if (cfs_period == 0)
16237 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16240 +long tg_get_cfs_period(struct task_group *tg)
16242 + u64 cfs_period_us;
16244 + cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.cfs_period);
16245 + do_div(cfs_period_us, NSEC_PER_USEC);
16246 + return cfs_period_us;
16249 +static s64 cpu_cfs_runtime_read_s64(struct cgroup *cgrp, struct cftype *cft)
16251 + return tg_get_cfs_runtime(cgroup_tg(cgrp));
16254 +static int cpu_cfs_runtime_write_s64(struct cgroup *cgrp, struct cftype *cftype,
16255 + s64 cfs_runtime_us)
16257 + return tg_set_cfs_runtime(cgroup_tg(cgrp), cfs_runtime_us);
16260 +static u64 cpu_cfs_period_read_u64(struct cgroup *cgrp, struct cftype *cft)
16262 + return tg_get_cfs_period(cgroup_tg(cgrp));
16265 +static int cpu_cfs_period_write_u64(struct cgroup *cgrp, struct cftype *cftype,
16266 + u64 cfs_period_us)
16268 + return tg_set_cfs_period(cgroup_tg(cgrp), cfs_period_us);
16271 +#endif /* CONFIG_CFS_HARD_LIMITS */
16272 #endif /* CONFIG_FAIR_GROUP_SCHED */
16274 #ifdef CONFIG_RT_GROUP_SCHED
16275 @@ -10767,6 +11107,18 @@ static struct cftype cpu_files[] = {
16276 .read_u64 = cpu_shares_read_u64,
16277 .write_u64 = cpu_shares_write_u64,
16279 +#ifdef CONFIG_CFS_HARD_LIMITS
16281 + .name = "cfs_runtime_us",
16282 + .read_s64 = cpu_cfs_runtime_read_s64,
16283 + .write_s64 = cpu_cfs_runtime_write_s64,
16286 + .name = "cfs_period_us",
16287 + .read_u64 = cpu_cfs_period_read_u64,
16288 + .write_u64 = cpu_cfs_period_write_u64,
16290 +#endif /* CONFIG_CFS_HARD_LIMITS */
16292 #ifdef CONFIG_RT_GROUP_SCHED
16294 diff -NurpP --minimal linux-2.6.32.56/kernel/sched_debug.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched_debug.c
16295 --- linux-2.6.32.56/kernel/sched_debug.c 2012-02-09 10:22:36.000000000 +0100
16296 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched_debug.c 2011-06-10 13:03:02.000000000 +0200
16297 @@ -80,6 +80,11 @@ static void print_cfs_group_stats(struct
16301 +#ifdef CONFIG_CFS_HARD_LIMITS
16302 + PN(se->throttle_max);
16303 + PN(se->throttle_sum);
16304 + P(se->throttle_count);
16307 P(se->load.weight);
16309 @@ -209,6 +214,16 @@ void print_cfs_rq(struct seq_file *m, in
16311 SEQ_printf(m, " .%-30s: %lu\n", "shares", cfs_rq->shares);
16313 +#ifdef CONFIG_CFS_HARD_LIMITS
16314 + spin_lock_irqsave(&rq->lock, flags);
16315 + SEQ_printf(m, " .%-30s: %d\n", "cfs_throttled",
16316 + cfs_rq->cfs_throttled);
16317 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_time",
16318 + SPLIT_NS(cfs_rq->cfs_time));
16319 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_runtime",
16320 + SPLIT_NS(cfs_rq->cfs_runtime));
16321 + spin_unlock_irqrestore(&rq->lock, flags);
16322 +#endif /* CONFIG_CFS_HARD_LIMITS */
16323 print_cfs_group_stats(m, cpu, cfs_rq->tg);
16326 @@ -309,7 +324,7 @@ static int sched_debug_show(struct seq_f
16327 u64 now = ktime_to_ns(ktime_get());
16330 - SEQ_printf(m, "Sched Debug Version: v0.09, %s %.*s\n",
16331 + SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n",
16332 init_utsname()->release,
16333 (int)strcspn(init_utsname()->version, " "),
16334 init_utsname()->version);
16335 diff -NurpP --minimal linux-2.6.32.56/kernel/sched_fair.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched_fair.c
16336 --- linux-2.6.32.56/kernel/sched_fair.c 2012-02-09 10:22:36.000000000 +0100
16337 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched_fair.c 2011-06-10 13:08:20.000000000 +0200
16338 @@ -192,7 +192,308 @@ find_matching_se(struct sched_entity **s
16342 -#else /* !CONFIG_FAIR_GROUP_SCHED */
16343 +#ifdef CONFIG_CFS_HARD_LIMITS
16345 +static inline void update_stats_throttle_start(struct cfs_rq *cfs_rq,
16346 + struct sched_entity *se)
16348 + schedstat_set(se->throttle_start, rq_of(cfs_rq)->clock);
16351 +static inline void update_stats_throttle_end(struct cfs_rq *cfs_rq,
16352 + struct sched_entity *se)
16354 + schedstat_set(se->throttle_max, max(se->throttle_max,
16355 + rq_of(cfs_rq)->clock - se->throttle_start));
16356 + schedstat_set(se->throttle_count, se->throttle_count + 1);
16357 + schedstat_set(se->throttle_sum, se->throttle_sum +
16358 + rq_of(cfs_rq)->clock - se->throttle_start);
16359 + schedstat_set(se->throttle_start, 0);
16363 +struct cfs_rq *sched_cfs_period_cfs_rq(struct cfs_bandwidth *cfs_b, int cpu)
16365 + return container_of(cfs_b, struct task_group,
16366 + cfs_bandwidth)->cfs_rq[cpu];
16369 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16371 + return cfs_rq->cfs_throttled;
16376 + * Ensure this RQ takes back all the runtime it lend to its neighbours.
16378 +static void disable_runtime_cfs(struct rq *rq)
16380 + struct root_domain *rd = rq->rd;
16381 + struct cfs_rq *cfs_rq;
16383 + if (unlikely(!scheduler_running))
16386 + for_each_leaf_cfs_rq(rq, cfs_rq) {
16387 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16391 + spin_lock(&cfs_b->cfs_runtime_lock);
16392 + spin_lock(&cfs_rq->cfs_runtime_lock);
16395 + * Either we're all are infinity and nobody needs to borrow,
16396 + * or we're already disabled and this have nothing to do, or
16397 + * we have exactly the right amount of runtime to take out.
16399 + if (cfs_rq->cfs_runtime == RUNTIME_INF ||
16400 + cfs_rq->cfs_runtime == cfs_b->cfs_runtime)
16402 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16405 + * Calculate the difference between what we started out with
16406 + * and what we current have, that's the amount of runtime
16407 + * we lend and now have to reclaim.
16409 + want = cfs_b->cfs_runtime - cfs_rq->cfs_runtime;
16412 + * Greedy reclaim, take back as much as possible.
16414 + for_each_cpu(i, rd->span) {
16415 + struct cfs_rq *iter = sched_cfs_period_cfs_rq(cfs_b, i);
16419 + * Can't reclaim from ourselves or disabled runqueues.
16421 + if (iter == cfs_rq || iter->cfs_runtime == RUNTIME_INF)
16424 + spin_lock(&iter->cfs_runtime_lock);
16426 + diff = min_t(s64, iter->cfs_runtime, want);
16427 + iter->cfs_runtime -= diff;
16430 + iter->cfs_runtime -= want;
16434 + spin_unlock(&iter->cfs_runtime_lock);
16439 + spin_lock(&cfs_rq->cfs_runtime_lock);
16441 + * We cannot be left wanting - that would mean some
16442 + * runtime leaked out of the system.
16447 + * Disable all the borrow logic by pretending we have infinite
16448 + * runtime - in which case borrowing doesn't make sense.
16450 + cfs_rq->cfs_runtime = RUNTIME_INF;
16451 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16452 + spin_unlock(&cfs_b->cfs_runtime_lock);
16456 +static void enable_runtime_cfs(struct rq *rq)
16458 + struct cfs_rq *cfs_rq;
16460 + if (unlikely(!scheduler_running))
16464 + * Reset each runqueue's bandwidth settings
16466 + for_each_leaf_cfs_rq(rq, cfs_rq) {
16467 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16469 + spin_lock(&cfs_b->cfs_runtime_lock);
16470 + spin_lock(&cfs_rq->cfs_runtime_lock);
16471 + cfs_rq->cfs_runtime = cfs_b->cfs_runtime;
16472 + cfs_rq->cfs_time = 0;
16473 + cfs_rq->cfs_throttled = 0;
16474 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16475 + spin_unlock(&cfs_b->cfs_runtime_lock);
16480 + * Ran out of runtime, check if we can borrow some from others
16481 + * instead of getting throttled right away.
16483 +static void do_cfs_balance_runtime(struct cfs_rq *cfs_rq)
16485 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16486 + const struct cpumask *span = sched_bw_period_mask();
16490 + weight = cpumask_weight(span);
16491 + spin_lock(&cfs_b->cfs_runtime_lock);
16492 + cfs_period = ktime_to_ns(cfs_b->cfs_period);
16494 + for_each_cpu(i, span) {
16495 + struct cfs_rq *borrow_cfs_rq =
16496 + sched_cfs_period_cfs_rq(cfs_b, i);
16499 + if (borrow_cfs_rq == cfs_rq)
16502 + cfs_rq_runtime_lock(borrow_cfs_rq);
16503 + if (borrow_cfs_rq->cfs_runtime == RUNTIME_INF) {
16504 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16508 + diff = borrow_cfs_rq->cfs_runtime - borrow_cfs_rq->cfs_time;
16510 + diff = div_u64((u64)diff, weight);
16511 + if (cfs_rq->cfs_runtime + diff > cfs_period)
16512 + diff = cfs_period - cfs_rq->cfs_runtime;
16513 + borrow_cfs_rq->cfs_runtime -= diff;
16514 + cfs_rq->cfs_runtime += diff;
16515 + if (cfs_rq->cfs_runtime == cfs_period) {
16516 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16520 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16522 + spin_unlock(&cfs_b->cfs_runtime_lock);
16526 + * Called with rq->runtime_lock held.
16528 +static void cfs_balance_runtime(struct cfs_rq *cfs_rq)
16530 + cfs_rq_runtime_unlock(cfs_rq);
16531 + do_cfs_balance_runtime(cfs_rq);
16532 + cfs_rq_runtime_lock(cfs_rq);
16535 +#else /* !CONFIG_SMP */
16537 +static void cfs_balance_runtime(struct cfs_rq *cfs_rq)
16541 +#endif /* CONFIG_SMP */
16544 + * Check if group entity exceeded its runtime. If so, mark the cfs_rq as
16545 + * throttled mark the current task for reschedling.
16547 +static void sched_cfs_runtime_exceeded(struct sched_entity *se,
16548 + struct task_struct *tsk_curr, unsigned long delta_exec)
16550 + struct cfs_rq *cfs_rq;
16552 + cfs_rq = group_cfs_rq(se);
16554 + if (cfs_rq->cfs_runtime == RUNTIME_INF)
16557 + cfs_rq->cfs_time += delta_exec;
16559 + if (cfs_rq_throttled(cfs_rq))
16562 + if (cfs_rq->cfs_time > cfs_rq->cfs_runtime)
16563 + cfs_balance_runtime(cfs_rq);
16565 + if (cfs_rq->cfs_time > cfs_rq->cfs_runtime) {
16566 + cfs_rq->cfs_throttled = 1;
16567 + update_stats_throttle_start(cfs_rq, se);
16568 + resched_task(tsk_curr);
16572 +static inline void update_curr_group(struct sched_entity *curr,
16573 + unsigned long delta_exec, struct task_struct *tsk_curr)
16575 + sched_cfs_runtime_exceeded(curr, tsk_curr, delta_exec);
16578 +static void enqueue_entity_locked(struct cfs_rq *cfs_rq,
16579 + struct sched_entity *se, int flags);
16581 +static void enqueue_throttled_entity(struct rq *rq, struct sched_entity *se)
16583 + for_each_sched_entity(se) {
16584 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16586 + if (se->on_rq || cfs_rq_throttled(gcfs_rq) ||
16587 + !gcfs_rq->nr_running)
16589 + enqueue_entity_locked(cfs_rq_of(se), se, 0);
16594 + * Refresh runtimes of all cfs_rqs in this group, i,e.,
16595 + * refresh runtimes of the representative cfs_rq of this
16596 + * tg on all cpus. Enqueue any throttled entity back.
16598 +void do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b)
16601 + const struct cpumask *span = sched_bw_period_mask();
16602 + unsigned long flags;
16604 + for_each_cpu(i, span) {
16605 + struct rq *rq = cpu_rq(i);
16606 + struct cfs_rq *cfs_rq = sched_cfs_period_cfs_rq(cfs_b, i);
16607 + struct sched_entity *se = cfs_rq->tg->se[i];
16609 + spin_lock_irqsave(&rq->lock, flags);
16610 + cfs_rq_runtime_lock(cfs_rq);
16611 + cfs_rq->cfs_time = 0;
16612 + if (cfs_rq_throttled(cfs_rq)) {
16613 + update_rq_clock(rq);
16614 + update_stats_throttle_end(cfs_rq, se);
16615 + cfs_rq->cfs_throttled = 0;
16616 + enqueue_throttled_entity(rq, se);
16618 + cfs_rq_runtime_unlock(cfs_rq);
16619 + spin_unlock_irqrestore(&rq->lock, flags);
16625 +static inline void update_curr_group(struct sched_entity *curr,
16626 + unsigned long delta_exec, struct task_struct *tsk_curr)
16631 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16636 +#endif /* CONFIG_CFS_HARD_LIMITS */
16638 +#else /* CONFIG_FAIR_GROUP_SCHED */
16640 +static inline void update_curr_group(struct sched_entity *curr,
16641 + unsigned long delta_exec, struct task_struct *tsk_curr)
16646 static inline struct task_struct *task_of(struct sched_entity *se)
16648 @@ -254,7 +555,6 @@ find_matching_se(struct sched_entity **s
16650 #endif /* CONFIG_FAIR_GROUP_SCHED */
16653 /**************************************************************
16654 * Scheduling class tree data structure manipulation methods:
16656 @@ -493,14 +793,25 @@ __update_curr(struct cfs_rq *cfs_rq, str
16657 update_min_vruntime(cfs_rq);
16660 -static void update_curr(struct cfs_rq *cfs_rq)
16661 +static void update_curr_task(struct sched_entity *curr,
16662 + unsigned long delta_exec)
16664 + struct task_struct *curtask = task_of(curr);
16666 + trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
16667 + cpuacct_charge(curtask, delta_exec);
16668 + account_group_exec_runtime(curtask, delta_exec);
16671 +static int update_curr_common(struct cfs_rq *cfs_rq, unsigned long *delta)
16673 struct sched_entity *curr = cfs_rq->curr;
16674 - u64 now = rq_of(cfs_rq)->clock_task;
16675 + struct rq *rq = rq_of(cfs_rq);
16676 + u64 now = rq->clock_task;
16677 unsigned long delta_exec;
16679 if (unlikely(!curr))
16684 * Get the amount of time the current task was running
16685 @@ -509,17 +820,29 @@ static void update_curr(struct cfs_rq *c
16687 delta_exec = (unsigned long)(now - curr->exec_start);
16692 __update_curr(cfs_rq, curr, delta_exec);
16693 curr->exec_start = now;
16694 + *delta = delta_exec;
16698 - if (entity_is_task(curr)) {
16699 - struct task_struct *curtask = task_of(curr);
16700 +static void update_curr(struct cfs_rq *cfs_rq)
16702 + struct sched_entity *curr = cfs_rq->curr;
16703 + struct rq *rq = rq_of(cfs_rq);
16704 + unsigned long delta_exec;
16706 - trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
16707 - cpuacct_charge(curtask, delta_exec);
16708 - account_group_exec_runtime(curtask, delta_exec);
16709 + if (update_curr_common(cfs_rq, &delta_exec))
16712 + if (entity_is_task(curr))
16713 + update_curr_task(curr, delta_exec);
16715 + cfs_rq_runtime_lock(group_cfs_rq(curr));
16716 + update_curr_group(curr, delta_exec, rq->curr);
16717 + cfs_rq_runtime_unlock(group_cfs_rq(curr));
16721 @@ -748,6 +1071,25 @@ place_entity(struct cfs_rq *cfs_rq, stru
16722 #define ENQUEUE_MIGRATE 2
16725 +enqueue_entity_common(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
16727 + account_entity_enqueue(cfs_rq, se);
16729 + if (flags & ENQUEUE_WAKEUP) {
16730 + place_entity(cfs_rq, se, 0);
16731 + enqueue_sleeper(cfs_rq, se);
16734 + update_stats_enqueue(cfs_rq, se);
16735 + check_spread(cfs_rq, se);
16736 + if (se != cfs_rq->curr)
16737 + __enqueue_entity(cfs_rq, se);
16739 + if (entity_is_task(se))
16740 + vx_activate_task(task_of(se));
16744 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
16747 @@ -761,17 +1103,17 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16748 * Update run-time statistics of the 'current'.
16750 update_curr(cfs_rq);
16751 - account_entity_enqueue(cfs_rq, se);
16753 - if (flags & ENQUEUE_WAKEUP) {
16754 - place_entity(cfs_rq, se, 0);
16755 - enqueue_sleeper(cfs_rq, se);
16757 + enqueue_entity_common(cfs_rq, se, flags);
16760 - update_stats_enqueue(cfs_rq, se);
16761 - check_spread(cfs_rq, se);
16762 - if (se != cfs_rq->curr)
16763 - __enqueue_entity(cfs_rq, se);
16764 +static void enqueue_entity_locked(struct cfs_rq *cfs_rq,
16765 + struct sched_entity *se, int flags)
16768 + * Update run-time statistics of the 'current'.
16770 + // update_curr_locked(cfs_rq);
16771 + enqueue_entity_common(cfs_rq, se, flags);
16774 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
16775 @@ -815,6 +1157,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16777 if (se != cfs_rq->curr)
16778 __dequeue_entity(cfs_rq, se);
16779 + if (entity_is_task(se))
16780 + vx_deactivate_task(task_of(se));
16781 account_entity_dequeue(cfs_rq, se);
16782 update_min_vruntime(cfs_rq);
16784 @@ -919,6 +1263,32 @@ static struct sched_entity *pick_next_en
16789 + * Called from put_prev_entity()
16790 + * If a group entity (@se) is found to be throttled, it will not be put back
16791 + * on @cfs_rq, which is equivalent to dequeing it.
16793 +static int dequeue_throttled_entity(struct cfs_rq *cfs_rq,
16794 + struct sched_entity *se)
16796 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16798 + if (entity_is_task(se))
16801 + cfs_rq_runtime_lock(gcfs_rq);
16802 + if (!cfs_rq_throttled(gcfs_rq) && gcfs_rq->nr_running) {
16803 + cfs_rq_runtime_unlock(gcfs_rq);
16807 + __clear_buddies(cfs_rq, se);
16808 + account_entity_dequeue(cfs_rq, se);
16809 + cfs_rq->curr = NULL;
16810 + cfs_rq_runtime_unlock(gcfs_rq);
16814 static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
16817 @@ -930,6 +1300,8 @@ static void put_prev_entity(struct cfs_r
16819 check_spread(cfs_rq, prev);
16821 + if (dequeue_throttled_entity(cfs_rq, prev))
16823 update_stats_wait_start(cfs_rq, prev);
16824 /* Put 'current' back into the tree. */
16825 __enqueue_entity(cfs_rq, prev);
16826 @@ -1026,10 +1398,28 @@ static inline void hrtick_update(struct
16830 +static int enqueue_group_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
16833 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16836 + cfs_rq_runtime_lock(gcfs_rq);
16837 + if (cfs_rq_throttled(gcfs_rq)) {
16841 + enqueue_entity_locked(cfs_rq, se, flags);
16843 + cfs_rq_runtime_unlock(gcfs_rq);
16848 * The enqueue_task method is called before nr_running is
16849 * increased. Here we update the fair scheduling stats and
16850 * then put the task into the rbtree:
16851 + * Don't enqueue a throttled entity further into the hierarchy.
16854 enqueue_task_fair(struct rq *rq, struct task_struct *p, int wakeup, bool head)
16855 @@ -1046,11 +1436,15 @@ enqueue_task_fair(struct rq *rq, struct
16856 for_each_sched_entity(se) {
16860 cfs_rq = cfs_rq_of(se);
16861 - enqueue_entity(cfs_rq, se, flags);
16862 + if (entity_is_task(se))
16863 + enqueue_entity(cfs_rq, se, flags);
16865 + if (enqueue_group_entity(cfs_rq, se, flags))
16867 flags = ENQUEUE_WAKEUP;
16873 @@ -1070,6 +1464,17 @@ static void dequeue_task_fair(struct rq
16874 /* Don't dequeue parent if it has other entities besides us */
16875 if (cfs_rq->load.weight)
16879 + * If this cfs_rq is throttled, then it is already
16882 + cfs_rq_runtime_lock(cfs_rq);
16883 + if (cfs_rq_throttled(cfs_rq)) {
16884 + cfs_rq_runtime_unlock(cfs_rq);
16887 + cfs_rq_runtime_unlock(cfs_rq);
16891 @@ -1896,9 +2301,10 @@ load_balance_fair(struct rq *this_rq, in
16892 u64 rem_load, moved_load;
16896 + * empty group or throttled group
16898 - if (!busiest_cfs_rq->task_weight)
16899 + if (!busiest_cfs_rq->task_weight ||
16900 + cfs_rq_throttled(busiest_cfs_rq))
16903 rem_load = (u64)rem_load_move * busiest_weight;
16904 @@ -1947,6 +2353,12 @@ move_one_task_fair(struct rq *this_rq, i
16906 for_each_leaf_cfs_rq(busiest, busy_cfs_rq) {
16908 + * Don't move task from a throttled cfs_rq
16910 + if (cfs_rq_throttled(busy_cfs_rq))
16914 * pass busy_cfs_rq argument into
16915 * load_balance_[start|next]_fair iterators
16917 diff -NurpP --minimal linux-2.6.32.56/kernel/sched_rt.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched_rt.c
16918 --- linux-2.6.32.56/kernel/sched_rt.c 2012-02-09 10:22:36.000000000 +0100
16919 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sched_rt.c 2011-06-10 13:03:02.000000000 +0200
16920 @@ -235,18 +235,6 @@ static int rt_se_boosted(struct sched_rt
16921 return p->prio != p->normal_prio;
16925 -static inline const struct cpumask *sched_rt_period_mask(void)
16927 - return cpu_rq(smp_processor_id())->rd->span;
16930 -static inline const struct cpumask *sched_rt_period_mask(void)
16932 - return cpu_online_mask;
16937 struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
16939 @@ -296,11 +284,6 @@ static inline int rt_rq_throttled(struct
16940 return rt_rq->rt_throttled;
16943 -static inline const struct cpumask *sched_rt_period_mask(void)
16945 - return cpu_online_mask;
16949 struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
16951 @@ -373,7 +356,7 @@ next:
16953 * Ensure this RQ takes back all the runtime it lend to its neighbours.
16955 -static void __disable_runtime(struct rq *rq)
16956 +static void disable_runtime_rt(struct rq *rq)
16958 struct root_domain *rd = rq->rd;
16959 struct rt_rq *rt_rq;
16960 @@ -450,16 +433,7 @@ balanced:
16964 -static void disable_runtime(struct rq *rq)
16966 - unsigned long flags;
16968 - spin_lock_irqsave(&rq->lock, flags);
16969 - __disable_runtime(rq);
16970 - spin_unlock_irqrestore(&rq->lock, flags);
16973 -static void __enable_runtime(struct rq *rq)
16974 +static void enable_runtime_rt(struct rq *rq)
16976 struct rt_rq *rt_rq;
16978 @@ -482,15 +456,6 @@ static void __enable_runtime(struct rq *
16982 -static void enable_runtime(struct rq *rq)
16984 - unsigned long flags;
16986 - spin_lock_irqsave(&rq->lock, flags);
16987 - __enable_runtime(rq);
16988 - spin_unlock_irqrestore(&rq->lock, flags);
16991 static int balance_runtime(struct rt_rq *rt_rq)
16994 @@ -518,7 +483,7 @@ static int do_sched_rt_period_timer(stru
16995 if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
16998 - span = sched_rt_period_mask();
16999 + span = sched_bw_period_mask();
17000 for_each_cpu(i, span) {
17002 struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
17003 @@ -1571,7 +1536,7 @@ static void rq_online_rt(struct rq *rq)
17004 if (rq->rt.overloaded)
17005 rt_set_overload(rq);
17007 - __enable_runtime(rq);
17008 + enable_runtime_rt(rq);
17010 cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio.curr);
17012 @@ -1582,7 +1547,7 @@ static void rq_offline_rt(struct rq *rq)
17013 if (rq->rt.overloaded)
17014 rt_clear_overload(rq);
17016 - __disable_runtime(rq);
17017 + disable_runtime_rt(rq);
17019 cpupri_set(&rq->rd->cpupri, rq->cpu, CPUPRI_INVALID);
17021 diff -NurpP --minimal linux-2.6.32.56/kernel/signal.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/signal.c
17022 --- linux-2.6.32.56/kernel/signal.c 2012-02-09 10:22:36.000000000 +0100
17023 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/signal.c 2011-06-10 13:03:02.000000000 +0200
17025 #include <linux/freezer.h>
17026 #include <linux/pid_namespace.h>
17027 #include <linux/nsproxy.h>
17028 +#include <linux/vs_context.h>
17029 +#include <linux/vs_pid.h>
17030 #include <trace/events/sched.h>
17032 #include <asm/param.h>
17033 @@ -598,6 +600,14 @@ static int check_kill_permission(int sig
17034 if (!valid_signal(sig))
17037 + if ((info != SEND_SIG_NOINFO) &&
17038 + (is_si_special(info) || !SI_FROMUSER(info)))
17041 + vxdprintk(VXD_CBIT(misc, 7),
17042 + "check_kill_permission(%d,%p,%p[#%u,%u])",
17043 + sig, info, t, vx_task_xid(t), t->pid);
17045 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
17048 @@ -627,6 +637,20 @@ static int check_kill_permission(int sig
17053 + if (t->pid == 1 && current->xid)
17057 + /* FIXME: we shouldn't return ESRCH ever, to avoid
17058 + loops, maybe ENOENT or EACCES? */
17059 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17060 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
17061 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17062 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
17066 return security_task_kill(t, info, sig, 0);
17069 @@ -1115,7 +1139,7 @@ int kill_pid_info(int sig, struct siginf
17072 p = pid_task(pid, PIDTYPE_PID);
17074 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17075 error = group_send_sig_info(sig, info, p);
17076 if (unlikely(error == -ESRCH))
17078 @@ -1154,7 +1178,7 @@ int kill_pid_info_as_uid(int sig, struct
17080 read_lock(&tasklist_lock);
17081 p = pid_task(pid, PIDTYPE_PID);
17083 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17087 @@ -1208,8 +1232,10 @@ static int kill_something_info(int sig,
17088 struct task_struct * p;
17090 for_each_process(p) {
17091 - if (task_pid_vnr(p) > 1 &&
17092 - !same_thread_group(p, current)) {
17093 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17094 + task_pid_vnr(p) > 1 &&
17095 + !same_thread_group(p, current) &&
17096 + !vx_current_initpid(p->pid)) {
17097 int err = group_send_sig_info(sig, info, p);
17100 @@ -1874,6 +1900,11 @@ relock:
17101 !sig_kernel_only(signr))
17104 + /* virtual init is protected against user signals */
17105 + if ((info->si_code == SI_USER) &&
17106 + vx_current_initpid(current->pid))
17109 if (sig_kernel_stop(signr)) {
17111 * The default action is to stop all threads in
17112 diff -NurpP --minimal linux-2.6.32.56/kernel/softirq.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/softirq.c
17113 --- linux-2.6.32.56/kernel/softirq.c 2012-02-09 10:22:36.000000000 +0100
17114 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/softirq.c 2011-06-10 13:03:02.000000000 +0200
17116 #include <linux/ftrace.h>
17117 #include <linux/smp.h>
17118 #include <linux/tick.h>
17119 +#include <linux/vs_context.h>
17121 #define CREATE_TRACE_POINTS
17122 #include <trace/events/irq.h>
17123 diff -NurpP --minimal linux-2.6.32.56/kernel/sys.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sys.c
17124 --- linux-2.6.32.56/kernel/sys.c 2012-02-09 10:22:36.000000000 +0100
17125 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sys.c 2011-06-10 13:03:02.000000000 +0200
17127 #include <linux/syscalls.h>
17128 #include <linux/kprobes.h>
17129 #include <linux/user_namespace.h>
17130 +#include <linux/vs_pid.h>
17132 #include <asm/uaccess.h>
17133 #include <asm/io.h>
17134 @@ -130,7 +131,10 @@ static int set_one_prio(struct task_stru
17137 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17139 + if (vx_flags(VXF_IGNEG_NICE, 0))
17145 no_nice = security_task_setnice(p, niceval);
17146 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17148 pgrp = task_pgrp(current);
17149 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17150 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17152 error = set_one_prio(p, niceval, error);
17153 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17155 @@ -240,6 +246,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17157 pgrp = task_pgrp(current);
17158 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17159 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17161 niceval = 20 - task_nice(p);
17162 if (niceval > retval)
17164 @@ -349,6 +357,9 @@ void kernel_power_off(void)
17165 machine_power_off();
17167 EXPORT_SYMBOL_GPL(kernel_power_off);
17169 +long vs_reboot(unsigned int, void __user *);
17172 * Reboot system call: for obvious reasons only root may call it,
17173 * and even root needs to set up some magic numbers in the registers
17174 @@ -381,6 +392,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17175 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17176 cmd = LINUX_REBOOT_CMD_HALT;
17178 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17179 + return vs_reboot(cmd, arg);
17183 case LINUX_REBOOT_CMD_RESTART:
17184 @@ -1129,7 +1143,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17186 char tmp[__NEW_UTS_LEN];
17188 - if (!capable(CAP_SYS_ADMIN))
17189 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17191 if (len < 0 || len > __NEW_UTS_LEN)
17193 @@ -1178,7 +1192,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17195 char tmp[__NEW_UTS_LEN];
17197 - if (!capable(CAP_SYS_ADMIN))
17198 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17200 if (len < 0 || len > __NEW_UTS_LEN)
17202 @@ -1247,7 +1261,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17204 old_rlim = current->signal->rlim + resource;
17205 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17206 - !capable(CAP_SYS_RESOURCE))
17207 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17209 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17211 diff -NurpP --minimal linux-2.6.32.56/kernel/sysctl.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sysctl.c
17212 --- linux-2.6.32.56/kernel/sysctl.c 2012-02-09 10:22:36.000000000 +0100
17213 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sysctl.c 2011-06-10 13:03:02.000000000 +0200
17214 @@ -124,6 +124,7 @@ static int ngroups_max = NGROUPS_MAX;
17215 extern char modprobe_path[];
17216 extern int modules_disabled;
17218 +extern char vshelper_path[];
17219 #ifdef CONFIG_CHR_DEV_SG
17220 extern int sg_big_buff;
17222 @@ -593,6 +594,15 @@ static struct ctl_table kern_table[] = {
17223 .strategy = &sysctl_string,
17227 + .ctl_name = KERN_VSHELPER,
17228 + .procname = "vshelper",
17229 + .data = &vshelper_path,
17232 + .proc_handler = &proc_dostring,
17233 + .strategy = &sysctl_string,
17235 #ifdef CONFIG_CHR_DEV_SG
17237 .ctl_name = KERN_SG_BIG_BUFF,
17238 diff -NurpP --minimal linux-2.6.32.56/kernel/sysctl_check.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sysctl_check.c
17239 --- linux-2.6.32.56/kernel/sysctl_check.c 2012-02-09 10:22:36.000000000 +0100
17240 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/sysctl_check.c 2011-06-10 13:03:02.000000000 +0200
17241 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
17243 { KERN_PANIC, "panic" },
17244 { KERN_REALROOTDEV, "real-root-dev" },
17245 + { KERN_VSHELPER, "vshelper", },
17247 { KERN_SPARC_REBOOT, "reboot-cmd" },
17248 { KERN_CTLALTDEL, "ctrl-alt-del" },
17249 @@ -1218,6 +1219,22 @@ static const struct trans_ctl_table tran
17253 +static struct trans_ctl_table trans_vserver_table[] = {
17254 + { 1, "debug_switch" },
17255 + { 2, "debug_xid" },
17256 + { 3, "debug_nid" },
17257 + { 4, "debug_tag" },
17258 + { 5, "debug_net" },
17259 + { 6, "debug_limit" },
17260 + { 7, "debug_cres" },
17261 + { 8, "debug_dlim" },
17262 + { 9, "debug_quota" },
17263 + { 10, "debug_cvirt" },
17264 + { 11, "debug_space" },
17265 + { 12, "debug_misc" },
17269 static const struct trans_ctl_table trans_root_table[] = {
17270 { CTL_KERN, "kernel", trans_kern_table },
17271 { CTL_VM, "vm", trans_vm_table },
17272 @@ -1234,6 +1251,7 @@ static const struct trans_ctl_table tran
17273 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
17274 { CTL_PM, "pm", trans_pm_table },
17275 { CTL_FRV, "frv", trans_frv_table },
17276 + { CTL_VSERVER, "vserver", trans_vserver_table },
17280 diff -NurpP --minimal linux-2.6.32.56/kernel/time.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/time.c
17281 --- linux-2.6.32.56/kernel/time.c 2012-02-09 10:22:36.000000000 +0100
17282 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/time.c 2011-11-17 12:18:26.000000000 +0100
17283 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
17284 SYSCALL_DEFINE1(time, time_t __user *, tloc)
17286 time_t i = get_seconds();
17287 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17290 if (put_user(i,tloc))
17291 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17295 - do_settimeofday(&tv);
17296 + vx_settimeofday(&tv);
17300 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17302 if (likely(tv != NULL)) {
17303 struct timeval ktv;
17304 - do_gettimeofday(&ktv);
17305 + vx_gettimeofday(&ktv);
17306 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17309 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
17310 /* SMP safe, again the code in arch/foo/time.c should
17311 * globally block out interrupts when it runs.
17313 - return do_settimeofday(tv);
17314 + return vx_settimeofday(tv);
17318 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
17322 - do_gettimeofday(&x);
17323 + vx_gettimeofday(&x);
17324 tv->tv_sec = x.tv_sec;
17325 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17327 diff -NurpP --minimal linux-2.6.32.56/kernel/timer.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/timer.c
17328 --- linux-2.6.32.56/kernel/timer.c 2012-02-09 10:22:36.000000000 +0100
17329 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/timer.c 2011-06-10 13:03:02.000000000 +0200
17331 #include <linux/kallsyms.h>
17332 #include <linux/perf_event.h>
17333 #include <linux/sched.h>
17334 +#include <linux/vs_base.h>
17335 +#include <linux/vs_cvirt.h>
17336 +#include <linux/vs_pid.h>
17337 +#include <linux/vserver/sched.h>
17339 #include <asm/uaccess.h>
17340 #include <asm/unistd.h>
17341 @@ -1261,12 +1265,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17348 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17349 - * should be moved into arch/i386 instead?
17353 * sys_getpid - return the thread group id of the current process
17354 @@ -1295,10 +1293,23 @@ SYSCALL_DEFINE0(getppid)
17356 pid = task_tgid_vnr(current->real_parent);
17358 + return vx_map_pid(pid);
17365 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17368 +asmlinkage long do_getxpid(long *ppid)
17370 + *ppid = sys_getppid();
17371 + return sys_getpid();
17374 +#else /* _alpha_ */
17376 SYSCALL_DEFINE0(getuid)
17378 /* Only we change this so SMP safe */
17379 diff -NurpP --minimal linux-2.6.32.56/kernel/user_namespace.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/user_namespace.c
17380 --- linux-2.6.32.56/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
17381 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/user_namespace.c 2011-06-10 13:03:02.000000000 +0200
17383 #include <linux/slab.h>
17384 #include <linux/user_namespace.h>
17385 #include <linux/cred.h>
17386 +#include <linux/vserver/global.h>
17389 * Create a new user namespace, deriving the creator from the user in the
17390 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17393 kref_init(&ns->kref);
17394 + atomic_inc(&vs_global_user_ns);
17396 for (n = 0; n < UIDHASH_SZ; ++n)
17397 INIT_HLIST_HEAD(ns->uidhash_table + n);
17398 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17399 struct user_namespace *ns =
17400 container_of(kref, struct user_namespace, kref);
17402 + /* FIXME: maybe move into destroyer? */
17403 + atomic_dec(&vs_global_user_ns);
17404 INIT_WORK(&ns->destroyer, free_user_ns_work);
17405 schedule_work(&ns->destroyer);
17407 diff -NurpP --minimal linux-2.6.32.56/kernel/utsname.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/utsname.c
17408 --- linux-2.6.32.56/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
17409 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/utsname.c 2011-06-10 13:03:02.000000000 +0200
17410 @@ -14,14 +14,17 @@
17411 #include <linux/utsname.h>
17412 #include <linux/err.h>
17413 #include <linux/slab.h>
17414 +#include <linux/vserver/global.h>
17416 static struct uts_namespace *create_uts_ns(void)
17418 struct uts_namespace *uts_ns;
17420 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17423 kref_init(&uts_ns->kref);
17424 + atomic_inc(&vs_global_uts_ns);
17429 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17430 struct uts_namespace *ns;
17432 ns = container_of(kref, struct uts_namespace, kref);
17433 + atomic_dec(&vs_global_uts_ns);
17436 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/Kconfig
17437 --- linux-2.6.32.56/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
17438 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/Kconfig 2011-06-10 13:03:02.000000000 +0200
17441 +# Linux VServer configuration
17444 +menu "Linux VServer"
17446 +config VSERVER_AUTO_LBACK
17447 + bool "Automatically Assign Loopback IP"
17450 + Automatically assign a guest specific loopback
17451 + IP and add it to the kernel network stack on
17454 +config VSERVER_AUTO_SINGLE
17455 + bool "Automatic Single IP Special Casing"
17456 + depends on EXPERIMENTAL
17459 + This allows network contexts with a single IP to
17460 + automatically remap 0.0.0.0 bindings to that IP,
17461 + avoiding further network checks and improving
17464 + (note: such guests do not allow to change the ip
17465 + on the fly and do not show loopback addresses)
17467 +config VSERVER_COWBL
17468 + bool "Enable COW Immutable Link Breaking"
17471 + This enables the COW (Copy-On-Write) link break code.
17472 + It allows you to treat unified files like normal files
17473 + when writing to them (which will implicitely break the
17474 + link and create a copy of the unified file)
17476 +config VSERVER_VTIME
17477 + bool "Enable Virtualized Guest Time"
17478 + depends on EXPERIMENTAL
17481 + This enables per guest time offsets to allow for
17482 + adjusting the system clock individually per guest.
17483 + this adds some overhead to the time functions and
17484 + therefore should not be enabled without good reason.
17486 +config VSERVER_DEVICE
17487 + bool "Enable Guest Device Mapping"
17488 + depends on EXPERIMENTAL
17491 + This enables generic device remapping.
17493 +config VSERVER_PROC_SECURE
17494 + bool "Enable Proc Security"
17495 + depends on PROC_FS
17498 + This configures ProcFS security to initially hide
17499 + non-process entries for all contexts except the main and
17500 + spectator context (i.e. for all guests), which is a secure
17503 + (note: on 1.2x the entries were visible by default)
17505 +config VSERVER_HARDCPU
17506 + bool "Enable Hard CPU Limits"
17509 + Activate the Hard CPU Limits
17511 + This will compile in code that allows the Token Bucket
17512 + Scheduler to put processes on hold when a context's
17513 + tokens are depleted (provided that its per-context
17514 + sched_hard flag is set).
17516 + Processes belonging to that context will not be able
17517 + to consume CPU resources again until a per-context
17518 + configured minimum of tokens has been reached.
17520 +config VSERVER_IDLETIME
17521 + bool "Avoid idle CPUs by skipping Time"
17522 + depends on VSERVER_HARDCPU
17525 + This option allows the scheduler to artificially
17526 + advance time (per cpu) when otherwise the idle
17527 + task would be scheduled, thus keeping the cpu
17528 + busy and sharing the available resources among
17529 + certain contexts.
17531 +config VSERVER_IDLELIMIT
17532 + bool "Limit the IDLE task"
17533 + depends on VSERVER_HARDCPU
17536 + Limit the idle slices, so the the next context
17537 + will be scheduled as soon as possible.
17539 + This might improve interactivity and latency, but
17540 + will also marginally increase scheduling overhead.
17543 + prompt "Persistent Inode Tagging"
17544 + default TAGGING_ID24
17546 + This adds persistent context information to filesystems
17547 + mounted with the tagxid option. Tagging is a requirement
17548 + for per-context disk limits and per-context quota.
17551 +config TAGGING_NONE
17554 + do not store per-context information in inodes.
17556 +config TAGGING_UID16
17557 + bool "UID16/GID32"
17559 + reduces UID to 16 bit, but leaves GID at 32 bit.
17561 +config TAGGING_GID16
17562 + bool "UID32/GID16"
17564 + reduces GID to 16 bit, but leaves UID at 32 bit.
17566 +config TAGGING_ID24
17567 + bool "UID24/GID24"
17569 + uses the upper 8bit from UID and GID for XID tagging
17570 + which leaves 24bit for UID/GID each, which should be
17571 + more than sufficient for normal use.
17573 +config TAGGING_INTERN
17574 + bool "UID32/GID32"
17576 + this uses otherwise reserved inode fields in the on
17577 + disk representation, which limits the use to a few
17578 + filesystems (currently ext2 and ext3)
17583 + bool "Tag NFSD User Auth and Files"
17586 + Enable this if you do want the in-kernel NFS
17587 + Server to use the tagging specified above.
17588 + (will require patched clients too)
17590 +config VSERVER_PRIVACY
17591 + bool "Honor Privacy Aspects of Guests"
17594 + When enabled, most context checks will disallow
17595 + access to structures assigned to a specific context,
17596 + like ptys or loop devices.
17598 +config VSERVER_CONTEXTS
17599 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
17601 + default "768" if 64BIT
17604 + This setting will optimize certain data structures
17605 + and memory allocations according to the expected
17608 + note: this is not a strict upper limit.
17610 +config VSERVER_WARN
17611 + bool "VServer Warnings"
17614 + This enables various runtime warnings, which will
17615 + notify about potential manipulation attempts or
17616 + resource shortage. It is generally considered to
17617 + be a good idea to have that enabled.
17619 +config VSERVER_DEBUG
17620 + bool "VServer Debugging Code"
17623 + Set this to yes if you want to be able to activate
17624 + debugging output at runtime. It adds a very small
17625 + overhead to all vserver related functions and
17626 + increases the kernel size by about 20k.
17628 +config VSERVER_HISTORY
17629 + bool "VServer History Tracing"
17630 + depends on VSERVER_DEBUG
17633 + Set this to yes if you want to record the history of
17634 + linux-vserver activities, so they can be replayed in
17635 + the event of a kernel panic or oops.
17637 +config VSERVER_HISTORY_SIZE
17638 + int "Per-CPU History Size (32-65536)"
17639 + depends on VSERVER_HISTORY
17643 + This allows you to specify the number of entries in
17644 + the per-CPU history buffer.
17646 +config VSERVER_MONITOR
17647 + bool "VServer Scheduling Monitor"
17648 + depends on VSERVER_DISABLED
17651 + Set this to yes if you want to record the scheduling
17652 + decisions, so that they can be relayed to userspace
17653 + for detailed analysis.
17655 +config VSERVER_MONITOR_SIZE
17656 + int "Per-CPU Monitor Queue Size (32-65536)"
17657 + depends on VSERVER_MONITOR
17661 + This allows you to specify the number of entries in
17662 + the per-CPU scheduling monitor buffer.
17664 +config VSERVER_MONITOR_SYNC
17665 + int "Per-CPU Monitor Sync Interval (0-65536)"
17666 + depends on VSERVER_MONITOR
17670 + This allows you to specify the interval in ticks
17671 + when a time sync entry is inserted.
17679 + select NAMESPACES
17685 +config VSERVER_SECURITY
17687 + depends on SECURITY
17689 + select SECURITY_CAPABILITIES
17691 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/Makefile linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/Makefile
17692 --- linux-2.6.32.56/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
17693 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/Makefile 2011-06-10 13:03:02.000000000 +0200
17696 +# Makefile for the Linux vserver routines.
17700 +obj-y += vserver.o
17702 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
17703 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
17706 +vserver-$(CONFIG_INET) += inet.o
17707 +vserver-$(CONFIG_PROC_FS) += proc.o
17708 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
17709 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
17710 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
17711 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
17713 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/cacct.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cacct.c
17714 --- linux-2.6.32.56/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17715 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cacct.c 2011-06-10 13:03:02.000000000 +0200
17718 + * linux/kernel/vserver/cacct.c
17720 + * Virtual Server: Context Accounting
17722 + * Copyright (C) 2006-2007 Herbert Pötzl
17724 + * V0.01 added accounting stats
17728 +#include <linux/types.h>
17729 +#include <linux/vs_context.h>
17730 +#include <linux/vserver/cacct_cmd.h>
17731 +#include <linux/vserver/cacct_int.h>
17733 +#include <asm/errno.h>
17734 +#include <asm/uaccess.h>
17737 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17739 + struct vcmd_sock_stat_v0 vc_data;
17742 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17745 + field = vc_data.field;
17746 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17749 + for (j = 0; j < 3; j++) {
17750 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17751 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17754 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17759 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/cacct_init.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cacct_init.h
17760 --- linux-2.6.32.56/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17761 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cacct_init.h 2011-06-10 13:03:02.000000000 +0200
17765 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17770 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17771 + for (j = 0; j < 3; j++) {
17772 + atomic_long_set(&cacct->sock[i][j].count, 0);
17773 + atomic_long_set(&cacct->sock[i][j].total, 0);
17776 + for (i = 0; i < 8; i++)
17777 + atomic_set(&cacct->slab[i], 0);
17778 + for (i = 0; i < 5; i++)
17779 + for (j = 0; j < 4; j++)
17780 + atomic_set(&cacct->page[i][j], 0);
17783 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17788 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/cacct_proc.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cacct_proc.h
17789 --- linux-2.6.32.56/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17790 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cacct_proc.h 2011-06-10 13:03:02.000000000 +0200
17792 +#ifndef _VX_CACCT_PROC_H
17793 +#define _VX_CACCT_PROC_H
17795 +#include <linux/vserver/cacct_int.h>
17798 +#define VX_SOCKA_TOP \
17799 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17801 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17803 + int i, j, length = 0;
17804 + static char *type[VXA_SOCK_SIZE] = {
17805 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17808 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17809 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17810 + length += sprintf(buffer + length, "%s:", type[i]);
17811 + for (j = 0; j < 3; j++) {
17812 + length += sprintf(buffer + length,
17813 + "\t%10lu/%-10lu",
17814 + vx_sock_count(cacct, i, j),
17815 + vx_sock_total(cacct, i, j));
17817 + buffer[length++] = '\n';
17820 + length += sprintf(buffer + length, "\n");
17821 + length += sprintf(buffer + length,
17822 + "slab:\t %8u %8u %8u %8u\n",
17823 + atomic_read(&cacct->slab[1]),
17824 + atomic_read(&cacct->slab[4]),
17825 + atomic_read(&cacct->slab[0]),
17826 + atomic_read(&cacct->slab[2]));
17828 + length += sprintf(buffer + length, "\n");
17829 + for (i = 0; i < 5; i++) {
17830 + length += sprintf(buffer + length,
17831 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17832 + atomic_read(&cacct->page[i][0]),
17833 + atomic_read(&cacct->page[i][1]),
17834 + atomic_read(&cacct->page[i][2]),
17835 + atomic_read(&cacct->page[i][3]),
17836 + atomic_read(&cacct->page[i][4]),
17837 + atomic_read(&cacct->page[i][5]),
17838 + atomic_read(&cacct->page[i][6]),
17839 + atomic_read(&cacct->page[i][7]));
17844 +#endif /* _VX_CACCT_PROC_H */
17845 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/context.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/context.c
17846 --- linux-2.6.32.56/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17847 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/context.c 2011-06-10 14:02:35.000000000 +0200
17850 + * linux/kernel/vserver/context.c
17852 + * Virtual Server: Context Support
17854 + * Copyright (C) 2003-2007 Herbert Pötzl
17856 + * V0.01 context helper
17857 + * V0.02 vx_ctx_kill syscall command
17858 + * V0.03 replaced context_info calls
17859 + * V0.04 redesign of struct (de)alloc
17860 + * V0.05 rlimit basic implementation
17861 + * V0.06 task_xid and info commands
17862 + * V0.07 context flags and caps
17863 + * V0.08 switch to RCU based hash
17864 + * V0.09 revert to non RCU for now
17865 + * V0.10 and back to working RCU hash
17866 + * V0.11 and back to locking again
17867 + * V0.12 referenced context store
17868 + * V0.13 separate per cpu data
17869 + * V0.14 changed vcmds to vxi arg
17870 + * V0.15 added context stat
17871 + * V0.16 have __create claim() the vxi
17872 + * V0.17 removed older and legacy stuff
17876 +#include <linux/slab.h>
17877 +#include <linux/types.h>
17878 +#include <linux/security.h>
17879 +#include <linux/pid_namespace.h>
17881 +#include <linux/vserver/context.h>
17882 +#include <linux/vserver/network.h>
17883 +#include <linux/vserver/debug.h>
17884 +#include <linux/vserver/limit.h>
17885 +#include <linux/vserver/limit_int.h>
17886 +#include <linux/vserver/space.h>
17887 +#include <linux/init_task.h>
17888 +#include <linux/fs_struct.h>
17890 +#include <linux/vs_context.h>
17891 +#include <linux/vs_limit.h>
17892 +#include <linux/vs_pid.h>
17893 +#include <linux/vserver/context_cmd.h>
17895 +#include "cvirt_init.h"
17896 +#include "cacct_init.h"
17897 +#include "limit_init.h"
17898 +#include "sched_init.h"
17901 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17902 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17905 +/* now inactive context structures */
17907 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17909 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17912 +/* __alloc_vx_info()
17914 + * allocate an initialized vx_info struct
17915 + * doesn't make it visible (hash) */
17917 +static struct vx_info *__alloc_vx_info(xid_t xid)
17919 + struct vx_info *new = NULL;
17922 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17924 + /* would this benefit from a slab cache? */
17925 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17929 + memset(new, 0, sizeof(struct vx_info));
17931 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17932 + if (!new->ptr_pc)
17935 + new->vx_id = xid;
17936 + INIT_HLIST_NODE(&new->vx_hlist);
17937 + atomic_set(&new->vx_usecnt, 0);
17938 + atomic_set(&new->vx_tasks, 0);
17939 + new->vx_parent = NULL;
17940 + new->vx_state = 0;
17941 + init_waitqueue_head(&new->vx_wait);
17943 + /* prepare reaper */
17944 + get_task_struct(init_pid_ns.child_reaper);
17945 + new->vx_reaper = init_pid_ns.child_reaper;
17946 + new->vx_badness_bias = 0;
17948 + /* rest of init goes here */
17949 + vx_info_init_limit(&new->limit);
17950 + vx_info_init_sched(&new->sched);
17951 + vx_info_init_cvirt(&new->cvirt);
17952 + vx_info_init_cacct(&new->cacct);
17954 + /* per cpu data structures */
17955 + for_each_possible_cpu(cpu) {
17956 + vx_info_init_sched_pc(
17957 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17958 + vx_info_init_cvirt_pc(
17959 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17962 + new->vx_flags = VXF_INIT_SET;
17963 + cap_set_init_eff(new->vx_bcaps);
17964 + new->vx_ccaps = 0;
17965 + new->vx_umask = 0;
17967 + new->reboot_cmd = 0;
17968 + new->exit_code = 0;
17970 + // preconfig fs entries
17971 + for (index = 0; index < VX_SPACES; index++) {
17972 + write_lock(&init_fs.lock);
17974 + write_unlock(&init_fs.lock);
17975 + new->vx_fs[index] = &init_fs;
17978 + vxdprintk(VXD_CBIT(xid, 0),
17979 + "alloc_vx_info(%d) = %p", xid, new);
17980 + vxh_alloc_vx_info(new);
17981 + atomic_inc(&vx_global_ctotal);
17990 +/* __dealloc_vx_info()
17992 + * final disposal of vx_info */
17994 +static void __dealloc_vx_info(struct vx_info *vxi)
17996 +#ifdef CONFIG_VSERVER_WARN
17997 + struct vx_info_save vxis;
18000 + vxdprintk(VXD_CBIT(xid, 0),
18001 + "dealloc_vx_info(%p)", vxi);
18002 + vxh_dealloc_vx_info(vxi);
18004 +#ifdef CONFIG_VSERVER_WARN
18005 + enter_vx_info(vxi, &vxis);
18006 + vx_info_exit_limit(&vxi->limit);
18007 + vx_info_exit_sched(&vxi->sched);
18008 + vx_info_exit_cvirt(&vxi->cvirt);
18009 + vx_info_exit_cacct(&vxi->cacct);
18011 + for_each_possible_cpu(cpu) {
18012 + vx_info_exit_sched_pc(
18013 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18014 + vx_info_exit_cvirt_pc(
18015 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18017 + leave_vx_info(&vxis);
18021 + vxi->vx_state |= VXS_RELEASED;
18024 + free_percpu(vxi->ptr_pc);
18027 + atomic_dec(&vx_global_ctotal);
18030 +static void __shutdown_vx_info(struct vx_info *vxi)
18032 + struct nsproxy *nsproxy;
18033 + struct fs_struct *fs;
18038 + vxi->vx_state |= VXS_SHUTDOWN;
18039 + vs_state_change(vxi, VSC_SHUTDOWN);
18041 + for (index = 0; index < VX_SPACES; index++) {
18042 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
18044 + put_nsproxy(nsproxy);
18046 + fs = xchg(&vxi->vx_fs[index], NULL);
18047 + write_lock(&fs->lock);
18048 + kill = !--fs->users;
18049 + write_unlock(&fs->lock);
18051 + free_fs_struct(fs);
18055 +/* exported stuff */
18057 +void free_vx_info(struct vx_info *vxi)
18059 + unsigned long flags;
18062 + /* check for reference counts first */
18063 + BUG_ON(atomic_read(&vxi->vx_usecnt));
18064 + BUG_ON(atomic_read(&vxi->vx_tasks));
18066 + /* context must not be hashed */
18067 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18069 + /* context shutdown is mandatory */
18070 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18072 + /* nsproxy and fs check */
18073 + for (index = 0; index < VX_SPACES; index++) {
18074 + BUG_ON(vxi->vx_nsproxy[index]);
18075 + BUG_ON(vxi->vx_fs[index]);
18078 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18079 + hlist_del(&vxi->vx_hlist);
18080 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18082 + __dealloc_vx_info(vxi);
18086 +/* hash table for vx_info hash */
18088 +#define VX_HASH_SIZE 13
18090 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18091 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18093 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
18096 +static inline unsigned int __hashval(xid_t xid)
18098 + return (xid % VX_HASH_SIZE);
18103 +/* __hash_vx_info()
18105 + * add the vxi to the global hash table
18106 + * requires the hash_lock to be held */
18108 +static inline void __hash_vx_info(struct vx_info *vxi)
18110 + struct hlist_head *head;
18112 + vxd_assert_lock(&vx_info_hash_lock);
18113 + vxdprintk(VXD_CBIT(xid, 4),
18114 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18115 + vxh_hash_vx_info(vxi);
18117 + /* context must not be hashed */
18118 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18120 + vxi->vx_state |= VXS_HASHED;
18121 + head = &vx_info_hash[__hashval(vxi->vx_id)];
18122 + hlist_add_head(&vxi->vx_hlist, head);
18123 + atomic_inc(&vx_global_cactive);
18126 +/* __unhash_vx_info()
18128 + * remove the vxi from the global hash table
18129 + * requires the hash_lock to be held */
18131 +static inline void __unhash_vx_info(struct vx_info *vxi)
18133 + unsigned long flags;
18135 + vxd_assert_lock(&vx_info_hash_lock);
18136 + vxdprintk(VXD_CBIT(xid, 4),
18137 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18138 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18139 + vxh_unhash_vx_info(vxi);
18141 + /* context must be hashed */
18142 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18143 + /* but without tasks */
18144 + BUG_ON(atomic_read(&vxi->vx_tasks));
18146 + vxi->vx_state &= ~VXS_HASHED;
18147 + hlist_del_init(&vxi->vx_hlist);
18148 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18149 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18150 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18151 + atomic_dec(&vx_global_cactive);
18155 +/* __lookup_vx_info()
18157 + * requires the hash_lock to be held
18158 + * doesn't increment the vx_refcnt */
18160 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18162 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18163 + struct hlist_node *pos;
18164 + struct vx_info *vxi;
18166 + vxd_assert_lock(&vx_info_hash_lock);
18167 + hlist_for_each(pos, head) {
18168 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18170 + if (vxi->vx_id == xid)
18175 + vxdprintk(VXD_CBIT(xid, 0),
18176 + "__lookup_vx_info(#%u): %p[#%u]",
18177 + xid, vxi, vxi ? vxi->vx_id : 0);
18178 + vxh_lookup_vx_info(vxi, xid);
18183 +/* __create_vx_info()
18185 + * create the requested context
18186 + * get(), claim() and hash it */
18188 +static struct vx_info *__create_vx_info(int id)
18190 + struct vx_info *new, *vxi = NULL;
18192 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18194 + if (!(new = __alloc_vx_info(id)))
18195 + return ERR_PTR(-ENOMEM);
18197 + /* required to make dynamic xids unique */
18198 + spin_lock(&vx_info_hash_lock);
18200 + /* static context requested */
18201 + if ((vxi = __lookup_vx_info(id))) {
18202 + vxdprintk(VXD_CBIT(xid, 0),
18203 + "create_vx_info(%d) = %p (already there)", id, vxi);
18204 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18205 + vxi = ERR_PTR(-EBUSY);
18207 + vxi = ERR_PTR(-EEXIST);
18210 + /* new context */
18211 + vxdprintk(VXD_CBIT(xid, 0),
18212 + "create_vx_info(%d) = %p (new)", id, new);
18213 + claim_vx_info(new, NULL);
18214 + __hash_vx_info(get_vx_info(new));
18215 + vxi = new, new = NULL;
18218 + spin_unlock(&vx_info_hash_lock);
18219 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18221 + __dealloc_vx_info(new);
18226 +/* exported stuff */
18229 +void unhash_vx_info(struct vx_info *vxi)
18231 + spin_lock(&vx_info_hash_lock);
18232 + __unhash_vx_info(vxi);
18233 + spin_unlock(&vx_info_hash_lock);
18234 + __shutdown_vx_info(vxi);
18235 + __wakeup_vx_info(vxi);
18239 +/* lookup_vx_info()
18241 + * search for a vx_info and get() it
18242 + * negative id means current */
18244 +struct vx_info *lookup_vx_info(int id)
18246 + struct vx_info *vxi = NULL;
18249 + vxi = get_vx_info(current_vx_info());
18250 + } else if (id > 1) {
18251 + spin_lock(&vx_info_hash_lock);
18252 + vxi = get_vx_info(__lookup_vx_info(id));
18253 + spin_unlock(&vx_info_hash_lock);
18258 +/* xid_is_hashed()
18260 + * verify that xid is still hashed */
18262 +int xid_is_hashed(xid_t xid)
18266 + spin_lock(&vx_info_hash_lock);
18267 + hashed = (__lookup_vx_info(xid) != NULL);
18268 + spin_unlock(&vx_info_hash_lock);
18272 +#ifdef CONFIG_PROC_FS
18276 + * get a subset of hashed xids for proc
18277 + * assumes size is at least one */
18279 +int get_xid_list(int index, unsigned int *xids, int size)
18281 + int hindex, nr_xids = 0;
18283 + /* only show current and children */
18284 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18287 + xids[nr_xids] = vx_current_xid();
18291 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18292 + struct hlist_head *head = &vx_info_hash[hindex];
18293 + struct hlist_node *pos;
18295 + spin_lock(&vx_info_hash_lock);
18296 + hlist_for_each(pos, head) {
18297 + struct vx_info *vxi;
18302 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18303 + xids[nr_xids] = vxi->vx_id;
18304 + if (++nr_xids >= size) {
18305 + spin_unlock(&vx_info_hash_lock);
18309 + /* keep the lock time short */
18310 + spin_unlock(&vx_info_hash_lock);
18317 +#ifdef CONFIG_VSERVER_DEBUG
18319 +void dump_vx_info_inactive(int level)
18321 + struct hlist_node *entry, *next;
18323 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18324 + struct vx_info *vxi =
18325 + list_entry(entry, struct vx_info, vx_hlist);
18327 + dump_vx_info(vxi, level);
18334 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18336 + struct user_struct *new_user, *old_user;
18341 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18344 + new_user = alloc_uid(vxi->vx_id, p->uid);
18348 + old_user = p->user;
18349 + if (new_user != old_user) {
18350 + atomic_inc(&new_user->processes);
18351 + atomic_dec(&old_user->processes);
18352 + p->user = new_user;
18354 + free_uid(old_user);
18360 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18362 + // p->cap_effective &= vxi->vx_cap_bset;
18363 + p->cap_effective =
18364 + cap_intersect(p->cap_effective, vxi->cap_bset);
18365 + // p->cap_inheritable &= vxi->vx_cap_bset;
18366 + p->cap_inheritable =
18367 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18368 + // p->cap_permitted &= vxi->vx_cap_bset;
18369 + p->cap_permitted =
18370 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18375 +#include <linux/file.h>
18376 +#include <linux/fdtable.h>
18378 +static int vx_openfd_task(struct task_struct *tsk)
18380 + struct files_struct *files = tsk->files;
18381 + struct fdtable *fdt;
18382 + const unsigned long *bptr;
18383 + int count, total;
18385 + /* no rcu_read_lock() because of spin_lock() */
18386 + spin_lock(&files->file_lock);
18387 + fdt = files_fdtable(files);
18388 + bptr = fdt->open_fds->fds_bits;
18389 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18390 + for (total = 0; count > 0; count--) {
18392 + total += hweight_long(*bptr);
18395 + spin_unlock(&files->file_lock);
18400 +/* for *space compatibility */
18402 +asmlinkage long sys_unshare(unsigned long);
18405 + * migrate task to new context
18406 + * gets vxi, puts old_vxi on change
18407 + * optionally unshares namespaces (hack)
18410 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18412 + struct vx_info *old_vxi;
18418 + vxdprintk(VXD_CBIT(xid, 5),
18419 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18420 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18422 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18423 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18426 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18429 + old_vxi = task_get_vx_info(p);
18430 + if (old_vxi == vxi)
18433 +// if (!(ret = vx_migrate_user(p, vxi))) {
18438 + openfd = vx_openfd_task(p);
18441 + atomic_dec(&old_vxi->cvirt.nr_threads);
18442 + atomic_dec(&old_vxi->cvirt.nr_running);
18443 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18444 + /* FIXME: what about the struct files here? */
18445 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18446 + /* account for the executable */
18447 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18449 + atomic_inc(&vxi->cvirt.nr_threads);
18450 + atomic_inc(&vxi->cvirt.nr_running);
18451 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18452 + /* FIXME: what about the struct files here? */
18453 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18454 + /* account for the executable */
18455 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18458 + release_vx_info(old_vxi, p);
18459 + clr_vx_info(&p->vx_info);
18461 + claim_vx_info(vxi, p);
18462 + set_vx_info(&p->vx_info, vxi);
18463 + p->xid = vxi->vx_id;
18465 + vxdprintk(VXD_CBIT(xid, 5),
18466 + "moved task %p into vxi:%p[#%d]",
18467 + p, vxi, vxi->vx_id);
18469 + // vx_mask_cap_bset(vxi, p);
18472 + /* hack for *spaces to provide compatibility */
18474 + struct nsproxy *old_nsp, *new_nsp;
18476 + ret = unshare_nsproxy_namespaces(
18477 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18482 + old_nsp = xchg(&p->nsproxy, new_nsp);
18483 + vx_set_space(vxi,
18484 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18485 + put_nsproxy(old_nsp);
18489 + put_vx_info(old_vxi);
18493 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18495 + struct task_struct *old_reaper;
18500 + vxdprintk(VXD_CBIT(xid, 6),
18501 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18502 + vxi, vxi->vx_id, p, p->xid, p->pid);
18504 + old_reaper = vxi->vx_reaper;
18505 + if (old_reaper == p)
18508 + /* set new child reaper */
18509 + get_task_struct(p);
18510 + vxi->vx_reaper = p;
18511 + put_task_struct(old_reaper);
18515 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18520 + vxdprintk(VXD_CBIT(xid, 6),
18521 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18522 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18524 + vxi->vx_flags &= ~VXF_STATE_INIT;
18525 + // vxi->vx_initpid = p->tgid;
18526 + vxi->vx_initpid = p->pid;
18530 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18532 + vxdprintk(VXD_CBIT(xid, 6),
18533 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18534 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18536 + vxi->exit_code = code;
18537 + vxi->vx_initpid = 0;
18541 +void vx_set_persistent(struct vx_info *vxi)
18543 + vxdprintk(VXD_CBIT(xid, 6),
18544 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18546 + get_vx_info(vxi);
18547 + claim_vx_info(vxi, NULL);
18550 +void vx_clear_persistent(struct vx_info *vxi)
18552 + vxdprintk(VXD_CBIT(xid, 6),
18553 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18555 + release_vx_info(vxi, NULL);
18556 + put_vx_info(vxi);
18559 +void vx_update_persistent(struct vx_info *vxi)
18561 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18562 + vx_set_persistent(vxi);
18564 + vx_clear_persistent(vxi);
18568 +/* task must be current or locked */
18570 +void exit_vx_info(struct task_struct *p, int code)
18572 + struct vx_info *vxi = p->vx_info;
18575 + atomic_dec(&vxi->cvirt.nr_threads);
18578 + vxi->exit_code = code;
18579 + release_vx_info(vxi, p);
18583 +void exit_vx_info_early(struct task_struct *p, int code)
18585 + struct vx_info *vxi = p->vx_info;
18588 + if (vxi->vx_initpid == p->pid)
18589 + vx_exit_init(vxi, p, code);
18590 + if (vxi->vx_reaper == p)
18591 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18596 +/* vserver syscall commands below here */
18598 +/* taks xid and vx_info functions */
18600 +#include <asm/uaccess.h>
18603 +int vc_task_xid(uint32_t id)
18608 + struct task_struct *tsk;
18610 + read_lock(&tasklist_lock);
18611 + tsk = find_task_by_real_pid(id);
18612 + xid = (tsk) ? tsk->xid : -ESRCH;
18613 + read_unlock(&tasklist_lock);
18615 + xid = vx_current_xid();
18620 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18622 + struct vcmd_vx_info_v0 vc_data;
18624 + vc_data.xid = vxi->vx_id;
18625 + vc_data.initpid = vxi->vx_initpid;
18627 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18633 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18635 + struct vcmd_ctx_stat_v0 vc_data;
18637 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18638 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18640 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18646 +/* context functions */
18648 +int vc_ctx_create(uint32_t xid, void __user *data)
18650 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18651 + struct vx_info *new_vxi;
18654 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18657 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18660 + new_vxi = __create_vx_info(xid);
18661 + if (IS_ERR(new_vxi))
18662 + return PTR_ERR(new_vxi);
18664 + /* initial flags */
18665 + new_vxi->vx_flags = vc_data.flagword;
18668 + if (vs_state_change(new_vxi, VSC_STARTUP))
18671 + ret = vx_migrate_task(current, new_vxi, (!data));
18675 + /* return context id on success */
18676 + ret = new_vxi->vx_id;
18678 + /* get a reference for persistent contexts */
18679 + if ((vc_data.flagword & VXF_PERSISTENT))
18680 + vx_set_persistent(new_vxi);
18682 + release_vx_info(new_vxi, NULL);
18683 + put_vx_info(new_vxi);
18688 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18690 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18693 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18696 + ret = vx_migrate_task(current, vxi, 0);
18699 + if (vc_data.flagword & VXM_SET_INIT)
18700 + ret = vx_set_init(vxi, current);
18703 + if (vc_data.flagword & VXM_SET_REAPER)
18704 + ret = vx_set_reaper(vxi, current);
18709 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18711 + struct vcmd_ctx_flags_v0 vc_data;
18713 + vc_data.flagword = vxi->vx_flags;
18715 + /* special STATE flag handling */
18716 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18718 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18723 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18725 + struct vcmd_ctx_flags_v0 vc_data;
18726 + uint64_t mask, trigger;
18728 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18731 + /* special STATE flag handling */
18732 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18733 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18735 + if (vxi == current_vx_info()) {
18736 + /* if (trigger & VXF_STATE_SETUP)
18737 + vx_mask_cap_bset(vxi, current); */
18738 + if (trigger & VXF_STATE_INIT) {
18741 + ret = vx_set_init(vxi, current);
18744 + ret = vx_set_reaper(vxi, current);
18750 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18751 + vc_data.flagword, mask);
18752 + if (trigger & VXF_PERSISTENT)
18753 + vx_update_persistent(vxi);
18759 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18761 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18763 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18767 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18769 + kernel_cap_t c = __cap_empty_set;
18771 + c.cap[0] = v & 0xFFFFFFFF;
18772 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18774 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18779 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18782 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18784 + *ccaps = vxi->vx_ccaps;
18789 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18791 + struct vcmd_ctx_caps_v1 vc_data;
18794 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18797 + vc_data.cmask = ~0ULL;
18799 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18804 +static int do_set_caps(struct vx_info *vxi,
18805 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18807 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18810 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18811 + bcaps, bmask, ccaps, cmask);
18813 + vxi->vx_bcaps = cap_t_from_caps(
18814 + vs_mask_flags(bcold, bcaps, bmask));
18815 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18820 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18822 + struct vcmd_ctx_caps_v1 vc_data;
18824 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18827 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18830 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18832 + struct vcmd_bcaps vc_data;
18835 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18838 + vc_data.bmask = ~0ULL;
18840 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18845 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18847 + struct vcmd_bcaps vc_data;
18849 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18852 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18856 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18858 + struct vcmd_umask vc_data;
18860 + vc_data.umask = vxi->vx_umask;
18861 + vc_data.mask = ~0ULL;
18863 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18868 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18870 + struct vcmd_umask vc_data;
18872 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18875 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18876 + vc_data.umask, vc_data.mask);
18881 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18883 + struct vcmd_badness_v0 vc_data;
18885 + vc_data.bias = vxi->vx_badness_bias;
18887 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18892 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18894 + struct vcmd_badness_v0 vc_data;
18896 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18899 + vxi->vx_badness_bias = vc_data.bias;
18903 +#include <linux/module.h>
18905 +EXPORT_SYMBOL_GPL(free_vx_info);
18907 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/cvirt.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cvirt.c
18908 --- linux-2.6.32.56/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18909 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cvirt.c 2011-06-10 13:03:02.000000000 +0200
18912 + * linux/kernel/vserver/cvirt.c
18914 + * Virtual Server: Context Virtualization
18916 + * Copyright (C) 2004-2007 Herbert Pötzl
18918 + * V0.01 broken out from limit.c
18919 + * V0.02 added utsname stuff
18920 + * V0.03 changed vcmds to vxi arg
18924 +#include <linux/types.h>
18925 +#include <linux/utsname.h>
18926 +#include <linux/vs_cvirt.h>
18927 +#include <linux/vserver/switch.h>
18928 +#include <linux/vserver/cvirt_cmd.h>
18930 +#include <asm/uaccess.h>
18933 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18935 + struct vx_info *vxi = current_vx_info();
18937 + set_normalized_timespec(uptime,
18938 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18939 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18942 + set_normalized_timespec(idle,
18943 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18944 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18948 +uint64_t vx_idle_jiffies(void)
18950 + return init_task.utime + init_task.stime;
18955 +static inline uint32_t __update_loadavg(uint32_t load,
18956 + int wsize, int delta, int n)
18958 + unsigned long long calc, prev;
18960 + /* just set it to n */
18961 + if (unlikely(delta >= wsize))
18962 + return (n << FSHIFT);
18964 + calc = delta * n;
18966 + prev = (wsize - delta);
18969 + do_div(calc, wsize);
18974 +void vx_update_load(struct vx_info *vxi)
18976 + uint32_t now, last, delta;
18977 + unsigned int nr_running, nr_uninterruptible;
18978 + unsigned int total;
18979 + unsigned long flags;
18981 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18984 + last = vxi->cvirt.load_last;
18985 + delta = now - last;
18987 + if (delta < 5*HZ)
18990 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18991 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18992 + total = nr_running + nr_uninterruptible;
18994 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18995 + 60*HZ, delta, total);
18996 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18997 + 5*60*HZ, delta, total);
18998 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18999 + 15*60*HZ, delta, total);
19001 + vxi->cvirt.load_last = now;
19003 + atomic_inc(&vxi->cvirt.load_updates);
19004 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19009 + * Commands to do_syslog:
19011 + * 0 -- Close the log. Currently a NOP.
19012 + * 1 -- Open the log. Currently a NOP.
19013 + * 2 -- Read from the log.
19014 + * 3 -- Read all messages remaining in the ring buffer.
19015 + * 4 -- Read and clear all messages remaining in the ring buffer
19016 + * 5 -- Clear ring buffer.
19017 + * 6 -- Disable printk's to console
19018 + * 7 -- Enable printk's to console
19019 + * 8 -- Set level of messages printed to console
19020 + * 9 -- Return number of unread characters in the log buffer
19021 + * 10 -- Return size of the log buffer
19023 +int vx_do_syslog(int type, char __user *buf, int len)
19026 + int do_clear = 0;
19027 + struct vx_info *vxi = current_vx_info();
19028 + struct _vx_syslog *log;
19032 + log = &vxi->cvirt.syslog;
19035 + case 0: /* Close log */
19036 + case 1: /* Open log */
19038 + case 2: /* Read from log */
19039 + error = wait_event_interruptible(log->log_wait,
19040 + (log->log_start - log->log_end));
19043 + spin_lock_irq(&log->logbuf_lock);
19044 + spin_unlock_irq(&log->logbuf_lock);
19046 + case 4: /* Read/clear last kernel messages */
19048 + /* fall through */
19049 + case 3: /* Read last kernel messages */
19052 + case 5: /* Clear ring buffer */
19055 + case 6: /* Disable logging to console */
19056 + case 7: /* Enable logging to console */
19057 + case 8: /* Set level of messages printed to console */
19060 + case 9: /* Number of chars in the log buffer */
19062 + case 10: /* Size of the log buffer */
19072 +/* virtual host info names */
19074 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19076 + struct nsproxy *nsproxy;
19077 + struct uts_namespace *uts;
19079 + if (id == VHIN_CONTEXT)
19080 + return vxi->vx_name;
19082 + nsproxy = vxi->vx_nsproxy[0];
19086 + uts = nsproxy->uts_ns;
19091 + case VHIN_SYSNAME:
19092 + return uts->name.sysname;
19093 + case VHIN_NODENAME:
19094 + return uts->name.nodename;
19095 + case VHIN_RELEASE:
19096 + return uts->name.release;
19097 + case VHIN_VERSION:
19098 + return uts->name.version;
19099 + case VHIN_MACHINE:
19100 + return uts->name.machine;
19101 + case VHIN_DOMAINNAME:
19102 + return uts->name.domainname;
19109 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19111 + struct vcmd_vhi_name_v0 vc_data;
19114 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19117 + name = vx_vhi_name(vxi, vc_data.field);
19121 + memcpy(name, vc_data.name, 65);
19125 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19127 + struct vcmd_vhi_name_v0 vc_data;
19130 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19133 + name = vx_vhi_name(vxi, vc_data.field);
19137 + memcpy(vc_data.name, name, 65);
19138 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19144 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19146 + struct vcmd_virt_stat_v0 vc_data;
19147 + struct _vx_cvirt *cvirt = &vxi->cvirt;
19148 + struct timespec uptime;
19150 + do_posix_clock_monotonic_gettime(&uptime);
19151 + set_normalized_timespec(&uptime,
19152 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19153 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19155 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
19156 + vc_data.uptime = timespec_to_ns(&uptime);
19157 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19158 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
19159 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19160 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19161 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19162 + vc_data.load[0] = cvirt->load[0];
19163 + vc_data.load[1] = cvirt->load[1];
19164 + vc_data.load[2] = cvirt->load[2];
19166 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19172 +#ifdef CONFIG_VSERVER_VTIME
19174 +/* virtualized time base */
19176 +void vx_gettimeofday(struct timeval *tv)
19178 + struct vx_info *vxi;
19180 + do_gettimeofday(tv);
19181 + if (!vx_flags(VXF_VIRT_TIME, 0))
19184 + vxi = current_vx_info();
19185 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
19186 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
19188 + if (tv->tv_usec >= USEC_PER_SEC) {
19190 + tv->tv_usec -= USEC_PER_SEC;
19191 + } else if (tv->tv_usec < 0) {
19193 + tv->tv_usec += USEC_PER_SEC;
19197 +int vx_settimeofday(struct timespec *ts)
19199 + struct timeval tv;
19200 + struct vx_info *vxi;
19202 + if (!vx_flags(VXF_VIRT_TIME, 0))
19203 + return do_settimeofday(ts);
19205 + do_gettimeofday(&tv);
19206 + vxi = current_vx_info();
19207 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19208 + vxi->cvirt.bias_tv.tv_usec =
19209 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19215 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/cvirt_init.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cvirt_init.h
19216 --- linux-2.6.32.56/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
19217 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cvirt_init.h 2011-06-10 13:03:02.000000000 +0200
19221 +extern uint64_t vx_idle_jiffies(void);
19223 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19225 + uint64_t idle_jiffies = vx_idle_jiffies();
19226 + uint64_t nsuptime;
19228 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19229 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19230 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19231 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19232 + cvirt->bias_tv.tv_sec = 0;
19233 + cvirt->bias_tv.tv_usec = 0;
19235 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19236 + atomic_set(&cvirt->nr_threads, 0);
19237 + atomic_set(&cvirt->nr_running, 0);
19238 + atomic_set(&cvirt->nr_uninterruptible, 0);
19239 + atomic_set(&cvirt->nr_onhold, 0);
19241 + spin_lock_init(&cvirt->load_lock);
19242 + cvirt->load_last = jiffies;
19243 + atomic_set(&cvirt->load_updates, 0);
19244 + cvirt->load[0] = 0;
19245 + cvirt->load[1] = 0;
19246 + cvirt->load[2] = 0;
19247 + atomic_set(&cvirt->total_forks, 0);
19249 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19250 + init_waitqueue_head(&cvirt->syslog.log_wait);
19251 + cvirt->syslog.log_start = 0;
19252 + cvirt->syslog.log_end = 0;
19253 + cvirt->syslog.con_start = 0;
19254 + cvirt->syslog.logged_chars = 0;
19258 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19260 + // cvirt_pc->cpustat = { 0 };
19263 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19267 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19268 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19270 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19271 + "!!! cvirt: %p[nr_running] = %d on exit.",
19273 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19274 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19276 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19277 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19283 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19288 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/cvirt_proc.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cvirt_proc.h
19289 --- linux-2.6.32.56/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
19290 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/cvirt_proc.h 2011-06-10 13:03:02.000000000 +0200
19292 +#ifndef _VX_CVIRT_PROC_H
19293 +#define _VX_CVIRT_PROC_H
19295 +#include <linux/nsproxy.h>
19296 +#include <linux/mnt_namespace.h>
19297 +#include <linux/ipc_namespace.h>
19298 +#include <linux/utsname.h>
19299 +#include <linux/ipc.h>
19303 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19305 + struct mnt_namespace *ns;
19306 + struct uts_namespace *uts;
19307 + struct ipc_namespace *ipc;
19308 + struct path path;
19309 + char *pstr, *root;
19315 + length += sprintf(buffer + length,
19316 + "NSProxy:\t%p [%p,%p,%p]\n",
19317 + nsproxy, nsproxy->mnt_ns,
19318 + nsproxy->uts_ns, nsproxy->ipc_ns);
19320 + ns = nsproxy->mnt_ns;
19324 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19328 + path.mnt = ns->root;
19329 + path.dentry = ns->root->mnt_root;
19330 + root = d_path(&path, pstr, PATH_MAX - 2);
19331 + length += sprintf(buffer + length,
19332 + "Namespace:\t%p [#%u]\n"
19333 + "RootPath:\t%s\n",
19334 + ns, atomic_read(&ns->count),
19339 + uts = nsproxy->uts_ns;
19343 + length += sprintf(buffer + length,
19344 + "SysName:\t%.*s\n"
19345 + "NodeName:\t%.*s\n"
19346 + "Release:\t%.*s\n"
19347 + "Version:\t%.*s\n"
19348 + "Machine:\t%.*s\n"
19349 + "DomainName:\t%.*s\n",
19350 + __NEW_UTS_LEN, uts->name.sysname,
19351 + __NEW_UTS_LEN, uts->name.nodename,
19352 + __NEW_UTS_LEN, uts->name.release,
19353 + __NEW_UTS_LEN, uts->name.version,
19354 + __NEW_UTS_LEN, uts->name.machine,
19355 + __NEW_UTS_LEN, uts->name.domainname);
19358 + ipc = nsproxy->ipc_ns;
19362 + length += sprintf(buffer + length,
19363 + "SEMS:\t\t%d %d %d %d %d\n"
19364 + "MSG:\t\t%d %d %d\n"
19365 + "SHM:\t\t%lu %lu %d %d\n",
19366 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19367 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19369 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19370 + (unsigned long)ipc->shm_ctlmax,
19371 + (unsigned long)ipc->shm_ctlall,
19372 + ipc->shm_ctlmni, ipc->shm_tot);
19379 +#include <linux/sched.h>
19381 +#define LOAD_INT(x) ((x) >> FSHIFT)
19382 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19385 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19390 + length += sprintf(buffer + length,
19391 + "BiasUptime:\t%lu.%02lu\n",
19392 + (unsigned long)cvirt->bias_uptime.tv_sec,
19393 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19395 + a = cvirt->load[0] + (FIXED_1 / 200);
19396 + b = cvirt->load[1] + (FIXED_1 / 200);
19397 + c = cvirt->load[2] + (FIXED_1 / 200);
19398 + length += sprintf(buffer + length,
19399 + "nr_threads:\t%d\n"
19400 + "nr_running:\t%d\n"
19401 + "nr_unintr:\t%d\n"
19402 + "nr_onhold:\t%d\n"
19403 + "load_updates:\t%d\n"
19404 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19405 + "total_forks:\t%d\n",
19406 + atomic_read(&cvirt->nr_threads),
19407 + atomic_read(&cvirt->nr_running),
19408 + atomic_read(&cvirt->nr_uninterruptible),
19409 + atomic_read(&cvirt->nr_onhold),
19410 + atomic_read(&cvirt->load_updates),
19411 + LOAD_INT(a), LOAD_FRAC(a),
19412 + LOAD_INT(b), LOAD_FRAC(b),
19413 + LOAD_INT(c), LOAD_FRAC(c),
19414 + atomic_read(&cvirt->total_forks));
19419 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19420 + char *buffer, int cpu)
19426 +#endif /* _VX_CVIRT_PROC_H */
19427 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/debug.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/debug.c
19428 --- linux-2.6.32.56/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19429 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/debug.c 2011-06-10 13:03:02.000000000 +0200
19432 + * kernel/vserver/debug.c
19434 + * Copyright (C) 2005-2007 Herbert Pötzl
19436 + * V0.01 vx_info dump support
19440 +#include <linux/module.h>
19442 +#include <linux/vserver/context.h>
19445 +void dump_vx_info(struct vx_info *vxi, int level)
19447 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19448 + atomic_read(&vxi->vx_usecnt),
19449 + atomic_read(&vxi->vx_tasks),
19452 + __dump_vx_limit(&vxi->limit);
19453 + __dump_vx_sched(&vxi->sched);
19454 + __dump_vx_cvirt(&vxi->cvirt);
19455 + __dump_vx_cacct(&vxi->cacct);
19461 +EXPORT_SYMBOL_GPL(dump_vx_info);
19463 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/device.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/device.c
19464 --- linux-2.6.32.56/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19465 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/device.c 2011-06-10 13:03:02.000000000 +0200
19468 + * linux/kernel/vserver/device.c
19470 + * Linux-VServer: Device Support
19472 + * Copyright (C) 2006 Herbert Pötzl
19473 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19475 + * V0.01 device mapping basics
19476 + * V0.02 added defaults
19480 +#include <linux/slab.h>
19481 +#include <linux/rcupdate.h>
19482 +#include <linux/fs.h>
19483 +#include <linux/namei.h>
19484 +#include <linux/hash.h>
19486 +#include <asm/errno.h>
19487 +#include <asm/uaccess.h>
19488 +#include <linux/vserver/base.h>
19489 +#include <linux/vserver/debug.h>
19490 +#include <linux/vserver/context.h>
19491 +#include <linux/vserver/device.h>
19492 +#include <linux/vserver/device_cmd.h>
19495 +#define DMAP_HASH_BITS 4
19498 +struct vs_mapping {
19500 + struct hlist_node hlist;
19501 + struct list_head list;
19503 +#define dm_hlist u.hlist
19504 +#define dm_list u.list
19507 + struct vx_dmap_target target;
19511 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19513 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19515 +static struct vx_dmap_target dmap_defaults[2] = {
19516 + { .flags = DATTR_OPEN },
19517 + { .flags = DATTR_OPEN },
19521 +struct kmem_cache *dmap_cachep __read_mostly;
19523 +int __init dmap_cache_init(void)
19525 + dmap_cachep = kmem_cache_create("dmap_cache",
19526 + sizeof(struct vs_mapping), 0,
19527 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19531 +__initcall(dmap_cache_init);
19534 +static inline unsigned int __hashval(dev_t dev, int bits)
19536 + return hash_long((unsigned long)dev, bits);
19540 +/* __hash_mapping()
19541 + * add the mapping to the hash table
19543 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19545 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19546 + struct hlist_head *head, *hash = dmap_main_hash;
19547 + int device = vdm->device;
19549 + spin_lock(hash_lock);
19550 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19551 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19553 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19554 + hlist_add_head(&vdm->dm_hlist, head);
19555 + spin_unlock(hash_lock);
19559 +static inline int __mode_to_default(umode_t mode)
19572 +/* __set_default()
19575 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19576 + struct vx_dmap_target *vdmt)
19578 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19579 + spin_lock(hash_lock);
19582 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19584 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19587 + spin_unlock(hash_lock);
19589 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19590 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19594 +/* __remove_default()
19595 + * remove a default
19597 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19599 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19600 + spin_lock(hash_lock);
19603 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19604 + else /* remove == reset */
19605 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19607 + spin_unlock(hash_lock);
19612 +/* __find_mapping()
19613 + * find a mapping in the hash table
19615 + * caller must hold hash_lock
19617 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19618 + struct vs_mapping **local, struct vs_mapping **global)
19620 + struct hlist_head *hash = dmap_main_hash;
19621 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19622 + struct hlist_node *pos;
19623 + struct vs_mapping *vdm;
19629 + hlist_for_each(pos, head) {
19630 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19632 + if ((vdm->device == device) &&
19633 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19634 + if (vdm->xid == xid) {
19637 + } else if (global && vdm->xid == 0)
19642 + if (global && *global)
19649 +/* __lookup_mapping()
19650 + * find a mapping and store the result in target and flags
19652 +static inline int __lookup_mapping(struct vx_info *vxi,
19653 + dev_t device, dev_t *target, int *flags, umode_t mode)
19655 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19656 + struct vs_mapping *vdm, *global;
19657 + struct vx_dmap_target *vdmt;
19659 + xid_t xid = vxi->vx_id;
19662 + spin_lock(hash_lock);
19663 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19665 + vdmt = &vdm->target;
19669 + index = __mode_to_default(mode);
19670 + if (vxi && vxi->dmap.targets[index].flags) {
19672 + vdmt = &vxi->dmap.targets[index];
19673 + } else if (global) {
19675 + vdmt = &global->target;
19679 + vdmt = &dmap_defaults[index];
19683 + if (target && (vdmt->flags & DATTR_REMAP))
19684 + *target = vdmt->target;
19686 + *target = device;
19688 + *flags = vdmt->flags;
19690 + spin_unlock(hash_lock);
19696 +/* __remove_mapping()
19697 + * remove a mapping from the hash table
19699 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19702 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19703 + struct vs_mapping *vdm = NULL;
19706 + spin_lock(hash_lock);
19708 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19710 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19711 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19714 + hlist_del(&vdm->dm_hlist);
19717 + spin_unlock(hash_lock);
19719 + kmem_cache_free(dmap_cachep, vdm);
19725 +int vs_map_device(struct vx_info *vxi,
19726 + dev_t device, dev_t *target, umode_t mode)
19728 + int ret, flags = DATTR_MASK;
19732 + *target = device;
19735 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19736 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19737 + device, target ? *target : 0, flags, mode, ret);
19739 + return (flags & DATTR_MASK);
19744 +static int do_set_mapping(struct vx_info *vxi,
19745 + dev_t device, dev_t target, int flags, umode_t mode)
19748 + struct vs_mapping *new;
19750 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19754 + INIT_HLIST_NODE(&new->dm_hlist);
19755 + new->device = device;
19756 + new->target.target = target;
19757 + new->target.flags = flags | mode;
19758 + new->xid = (vxi ? vxi->vx_id : 0);
19760 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19761 + __hash_mapping(vxi, new);
19763 + struct vx_dmap_target new = {
19764 + .target = target,
19765 + .flags = flags | mode,
19767 + __set_default(vxi, mode, &new);
19773 +static int do_unset_mapping(struct vx_info *vxi,
19774 + dev_t device, dev_t target, int flags, umode_t mode)
19776 + int ret = -EINVAL;
19779 + ret = __remove_mapping(vxi, device, mode);
19783 + ret = __remove_default(vxi, mode);
19793 +static inline int __user_device(const char __user *name, dev_t *dev,
19796 + struct nameidata nd;
19803 + ret = user_lpath(name, &nd.path);
19806 + if (nd.path.dentry->d_inode) {
19807 + *dev = nd.path.dentry->d_inode->i_rdev;
19808 + *mode = nd.path.dentry->d_inode->i_mode;
19810 + path_put(&nd.path);
19814 +static inline int __mapping_mode(dev_t device, dev_t target,
19815 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19818 + *mode = device_mode & S_IFMT;
19820 + *mode = target_mode & S_IFMT;
19824 + /* if both given, device and target mode have to match */
19825 + if (device && target &&
19826 + ((device_mode ^ target_mode) & S_IFMT))
19832 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19833 + const char __user *target_path, int flags, int set)
19835 + dev_t device = ~0, target = ~0;
19836 + umode_t device_mode = 0, target_mode = 0, mode;
19839 + ret = __user_device(device_path, &device, &device_mode);
19842 + ret = __user_device(target_path, &target, &target_mode);
19846 + ret = __mapping_mode(device, target,
19847 + device_mode, target_mode, &mode);
19852 + return do_set_mapping(vxi, device, target,
19855 + return do_unset_mapping(vxi, device, target,
19860 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19862 + struct vcmd_set_mapping_v0 vc_data;
19864 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19867 + return do_mapping(vxi, vc_data.device, vc_data.target,
19868 + vc_data.flags, 1);
19871 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19873 + struct vcmd_set_mapping_v0 vc_data;
19875 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19878 + return do_mapping(vxi, vc_data.device, vc_data.target,
19879 + vc_data.flags, 0);
19883 +#ifdef CONFIG_COMPAT
19885 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19887 + struct vcmd_set_mapping_v0_x32 vc_data;
19889 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19892 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19893 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19896 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19898 + struct vcmd_set_mapping_v0_x32 vc_data;
19900 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19903 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19904 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19907 +#endif /* CONFIG_COMPAT */
19910 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/dlimit.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/dlimit.c
19911 --- linux-2.6.32.56/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19912 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/dlimit.c 2011-06-10 13:03:02.000000000 +0200
19915 + * linux/kernel/vserver/dlimit.c
19917 + * Virtual Server: Context Disk Limits
19919 + * Copyright (C) 2004-2009 Herbert Pötzl
19921 + * V0.01 initial version
19922 + * V0.02 compat32 splitup
19923 + * V0.03 extended interface
19927 +#include <linux/statfs.h>
19928 +#include <linux/sched.h>
19929 +#include <linux/namei.h>
19930 +#include <linux/vs_tag.h>
19931 +#include <linux/vs_dlimit.h>
19932 +#include <linux/vserver/dlimit_cmd.h>
19934 +#include <asm/uaccess.h>
19936 +/* __alloc_dl_info()
19938 + * allocate an initialized dl_info struct
19939 + * doesn't make it visible (hash) */
19941 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19943 + struct dl_info *new = NULL;
19945 + vxdprintk(VXD_CBIT(dlim, 5),
19946 + "alloc_dl_info(%p,%d)*", sb, tag);
19948 + /* would this benefit from a slab cache? */
19949 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19953 + memset(new, 0, sizeof(struct dl_info));
19954 + new->dl_tag = tag;
19956 + INIT_RCU_HEAD(&new->dl_rcu);
19957 + INIT_HLIST_NODE(&new->dl_hlist);
19958 + spin_lock_init(&new->dl_lock);
19959 + atomic_set(&new->dl_refcnt, 0);
19960 + atomic_set(&new->dl_usecnt, 0);
19962 + /* rest of init goes here */
19964 + vxdprintk(VXD_CBIT(dlim, 4),
19965 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19969 +/* __dealloc_dl_info()
19971 + * final disposal of dl_info */
19973 +static void __dealloc_dl_info(struct dl_info *dli)
19975 + vxdprintk(VXD_CBIT(dlim, 4),
19976 + "dealloc_dl_info(%p)", dli);
19978 + dli->dl_hlist.next = LIST_POISON1;
19979 + dli->dl_tag = -1;
19982 + BUG_ON(atomic_read(&dli->dl_usecnt));
19983 + BUG_ON(atomic_read(&dli->dl_refcnt));
19989 +/* hash table for dl_info hash */
19991 +#define DL_HASH_SIZE 13
19993 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19995 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19998 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20000 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20005 +/* __hash_dl_info()
20007 + * add the dli to the global hash table
20008 + * requires the hash_lock to be held */
20010 +static inline void __hash_dl_info(struct dl_info *dli)
20012 + struct hlist_head *head;
20014 + vxdprintk(VXD_CBIT(dlim, 6),
20015 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20016 + get_dl_info(dli);
20017 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20018 + hlist_add_head_rcu(&dli->dl_hlist, head);
20021 +/* __unhash_dl_info()
20023 + * remove the dli from the global hash table
20024 + * requires the hash_lock to be held */
20026 +static inline void __unhash_dl_info(struct dl_info *dli)
20028 + vxdprintk(VXD_CBIT(dlim, 6),
20029 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20030 + hlist_del_rcu(&dli->dl_hlist);
20031 + put_dl_info(dli);
20035 +/* __lookup_dl_info()
20037 + * requires the rcu_read_lock()
20038 + * doesn't increment the dl_refcnt */
20040 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20042 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20043 + struct hlist_node *pos;
20044 + struct dl_info *dli;
20046 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20048 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
20056 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20058 + struct dl_info *dli;
20061 + dli = get_dl_info(__lookup_dl_info(sb, tag));
20062 + vxdprintk(VXD_CBIT(dlim, 7),
20063 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20064 + rcu_read_unlock();
20068 +void rcu_free_dl_info(struct rcu_head *head)
20070 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20071 + int usecnt, refcnt;
20073 + BUG_ON(!dli || !head);
20075 + usecnt = atomic_read(&dli->dl_usecnt);
20076 + BUG_ON(usecnt < 0);
20078 + refcnt = atomic_read(&dli->dl_refcnt);
20079 + BUG_ON(refcnt < 0);
20081 + vxdprintk(VXD_CBIT(dlim, 3),
20082 + "rcu_free_dl_info(%p)", dli);
20084 + __dealloc_dl_info(dli);
20086 + printk("!!! rcu didn't free\n");
20092 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20093 + uint32_t flags, int add)
20095 + struct path path;
20098 + ret = user_lpath(name, &path);
20100 + struct super_block *sb;
20101 + struct dl_info *dli;
20104 + if (!path.dentry->d_inode)
20105 + goto out_release;
20106 + if (!(sb = path.dentry->d_inode->i_sb))
20107 + goto out_release;
20110 + dli = __alloc_dl_info(sb, id);
20111 + spin_lock(&dl_info_hash_lock);
20114 + if (__lookup_dl_info(sb, id))
20116 + __hash_dl_info(dli);
20119 + spin_lock(&dl_info_hash_lock);
20120 + dli = __lookup_dl_info(sb, id);
20125 + __unhash_dl_info(dli);
20129 + spin_unlock(&dl_info_hash_lock);
20131 + __dealloc_dl_info(dli);
20138 +int vc_add_dlimit(uint32_t id, void __user *data)
20140 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20142 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20145 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20148 +int vc_rem_dlimit(uint32_t id, void __user *data)
20150 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20152 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20155 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20158 +#ifdef CONFIG_COMPAT
20160 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20162 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20164 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20167 + return do_addrem_dlimit(id,
20168 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20171 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20173 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20175 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20178 + return do_addrem_dlimit(id,
20179 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20182 +#endif /* CONFIG_COMPAT */
20186 +int do_set_dlimit(uint32_t id, const char __user *name,
20187 + uint32_t space_used, uint32_t space_total,
20188 + uint32_t inodes_used, uint32_t inodes_total,
20189 + uint32_t reserved, uint32_t flags)
20191 + struct path path;
20194 + ret = user_lpath(name, &path);
20196 + struct super_block *sb;
20197 + struct dl_info *dli;
20200 + if (!path.dentry->d_inode)
20201 + goto out_release;
20202 + if (!(sb = path.dentry->d_inode->i_sb))
20203 + goto out_release;
20205 + /* sanity checks */
20206 + if ((reserved != CDLIM_KEEP &&
20207 + reserved > 100) ||
20208 + (inodes_used != CDLIM_KEEP &&
20209 + inodes_used > inodes_total) ||
20210 + (space_used != CDLIM_KEEP &&
20211 + space_used > space_total))
20212 + goto out_release;
20215 + dli = locate_dl_info(sb, id);
20217 + goto out_release;
20219 + spin_lock(&dli->dl_lock);
20221 + if (inodes_used != CDLIM_KEEP)
20222 + dli->dl_inodes_used = inodes_used;
20223 + if (inodes_total != CDLIM_KEEP)
20224 + dli->dl_inodes_total = inodes_total;
20225 + if (space_used != CDLIM_KEEP)
20226 + dli->dl_space_used = dlimit_space_32to64(
20227 + space_used, flags, DLIMS_USED);
20229 + if (space_total == CDLIM_INFINITY)
20230 + dli->dl_space_total = DLIM_INFINITY;
20231 + else if (space_total != CDLIM_KEEP)
20232 + dli->dl_space_total = dlimit_space_32to64(
20233 + space_total, flags, DLIMS_TOTAL);
20235 + if (reserved != CDLIM_KEEP)
20236 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20238 + spin_unlock(&dli->dl_lock);
20240 + put_dl_info(dli);
20249 +int vc_set_dlimit(uint32_t id, void __user *data)
20251 + struct vcmd_ctx_dlimit_v0 vc_data;
20253 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20256 + return do_set_dlimit(id, vc_data.name,
20257 + vc_data.space_used, vc_data.space_total,
20258 + vc_data.inodes_used, vc_data.inodes_total,
20259 + vc_data.reserved, vc_data.flags);
20262 +#ifdef CONFIG_COMPAT
20264 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20266 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20268 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20271 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20272 + vc_data.space_used, vc_data.space_total,
20273 + vc_data.inodes_used, vc_data.inodes_total,
20274 + vc_data.reserved, vc_data.flags);
20277 +#endif /* CONFIG_COMPAT */
20281 +int do_get_dlimit(uint32_t id, const char __user *name,
20282 + uint32_t *space_used, uint32_t *space_total,
20283 + uint32_t *inodes_used, uint32_t *inodes_total,
20284 + uint32_t *reserved, uint32_t *flags)
20286 + struct path path;
20289 + ret = user_lpath(name, &path);
20291 + struct super_block *sb;
20292 + struct dl_info *dli;
20295 + if (!path.dentry->d_inode)
20296 + goto out_release;
20297 + if (!(sb = path.dentry->d_inode->i_sb))
20298 + goto out_release;
20301 + dli = locate_dl_info(sb, id);
20303 + goto out_release;
20305 + spin_lock(&dli->dl_lock);
20306 + *inodes_used = dli->dl_inodes_used;
20307 + *inodes_total = dli->dl_inodes_total;
20309 + *space_used = dlimit_space_64to32(
20310 + dli->dl_space_used, flags, DLIMS_USED);
20312 + if (dli->dl_space_total == DLIM_INFINITY)
20313 + *space_total = CDLIM_INFINITY;
20315 + *space_total = dlimit_space_64to32(
20316 + dli->dl_space_total, flags, DLIMS_TOTAL);
20318 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20319 + spin_unlock(&dli->dl_lock);
20321 + put_dl_info(dli);
20332 +int vc_get_dlimit(uint32_t id, void __user *data)
20334 + struct vcmd_ctx_dlimit_v0 vc_data;
20337 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20340 + ret = do_get_dlimit(id, vc_data.name,
20341 + &vc_data.space_used, &vc_data.space_total,
20342 + &vc_data.inodes_used, &vc_data.inodes_total,
20343 + &vc_data.reserved, &vc_data.flags);
20347 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20352 +#ifdef CONFIG_COMPAT
20354 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20356 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20359 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20362 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20363 + &vc_data.space_used, &vc_data.space_total,
20364 + &vc_data.inodes_used, &vc_data.inodes_total,
20365 + &vc_data.reserved, &vc_data.flags);
20369 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20374 +#endif /* CONFIG_COMPAT */
20377 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20379 + struct dl_info *dli;
20380 + __u64 blimit, bfree, bavail;
20383 + dli = locate_dl_info(sb, dx_current_tag());
20387 + spin_lock(&dli->dl_lock);
20388 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20391 + /* reduce max inodes available to limit */
20392 + if (buf->f_files > dli->dl_inodes_total)
20393 + buf->f_files = dli->dl_inodes_total;
20395 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20396 + /* reduce free inodes to min */
20397 + if (ifree < buf->f_ffree)
20398 + buf->f_ffree = ifree;
20401 + if (dli->dl_space_total == DLIM_INFINITY)
20404 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20406 + if (dli->dl_space_total < dli->dl_space_used)
20409 + bfree = (dli->dl_space_total - dli->dl_space_used)
20410 + >> sb->s_blocksize_bits;
20412 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20413 + if (bavail < dli->dl_space_used)
20416 + bavail = (bavail - dli->dl_space_used)
20417 + >> sb->s_blocksize_bits;
20419 + /* reduce max space available to limit */
20420 + if (buf->f_blocks > blimit)
20421 + buf->f_blocks = blimit;
20423 + /* reduce free space to min */
20424 + if (bfree < buf->f_bfree)
20425 + buf->f_bfree = bfree;
20427 + /* reduce avail space to min */
20428 + if (bavail < buf->f_bavail)
20429 + buf->f_bavail = bavail;
20432 + spin_unlock(&dli->dl_lock);
20433 + put_dl_info(dli);
20438 +#include <linux/module.h>
20440 +EXPORT_SYMBOL_GPL(locate_dl_info);
20441 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20443 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/helper.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/helper.c
20444 --- linux-2.6.32.56/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20445 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/helper.c 2011-06-10 13:03:02.000000000 +0200
20448 + * linux/kernel/vserver/helper.c
20450 + * Virtual Context Support
20452 + * Copyright (C) 2004-2007 Herbert Pötzl
20454 + * V0.01 basic helper
20458 +#include <linux/kmod.h>
20459 +#include <linux/reboot.h>
20460 +#include <linux/vs_context.h>
20461 +#include <linux/vs_network.h>
20462 +#include <linux/vserver/signal.h>
20465 +char vshelper_path[255] = "/sbin/vshelper";
20468 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20472 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20473 + printk( KERN_WARNING
20474 + "%s: (%s %s) returned %s with %d\n",
20475 + name, argv[1], argv[2],
20476 + sync ? "sync" : "async", ret);
20478 + vxdprintk(VXD_CBIT(switch, 4),
20479 + "%s: (%s %s) returned %s with %d",
20480 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20485 + * vshelper path is set via /proc/sys
20486 + * invoked by vserver sys_reboot(), with
20487 + * the following arguments
20489 + * argv [0] = vshelper_path;
20490 + * argv [1] = action: "restart", "halt", "poweroff", ...
20491 + * argv [2] = context identifier
20493 + * envp [*] = type-specific parameters
20496 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20498 + char id_buf[8], cmd_buf[16];
20499 + char uid_buf[16], pid_buf[16];
20502 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20503 + char *envp[] = {"HOME=/", "TERM=linux",
20504 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20505 + uid_buf, pid_buf, cmd_buf, 0};
20507 + if (vx_info_state(vxi, VXS_HELPER))
20509 + vxi->vx_state |= VXS_HELPER;
20511 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20513 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20514 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20515 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20518 + case LINUX_REBOOT_CMD_RESTART:
20519 + argv[1] = "restart";
20522 + case LINUX_REBOOT_CMD_HALT:
20523 + argv[1] = "halt";
20526 + case LINUX_REBOOT_CMD_POWER_OFF:
20527 + argv[1] = "poweroff";
20530 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20531 + argv[1] = "swsusp";
20534 + case LINUX_REBOOT_CMD_OOM:
20539 + vxi->vx_state &= ~VXS_HELPER;
20543 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20544 + vxi->vx_state &= ~VXS_HELPER;
20545 + __wakeup_vx_info(vxi);
20546 + return (ret) ? -EPERM : 0;
20550 +long vs_reboot(unsigned int cmd, void __user *arg)
20552 + struct vx_info *vxi = current_vx_info();
20555 + vxdprintk(VXD_CBIT(misc, 5),
20556 + "vs_reboot(%p[#%d],%u)",
20557 + vxi, vxi ? vxi->vx_id : 0, cmd);
20559 + ret = vs_reboot_helper(vxi, cmd, arg);
20563 + vxi->reboot_cmd = cmd;
20564 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20566 + case LINUX_REBOOT_CMD_RESTART:
20567 + case LINUX_REBOOT_CMD_HALT:
20568 + case LINUX_REBOOT_CMD_POWER_OFF:
20569 + vx_info_kill(vxi, 0, SIGKILL);
20570 + vx_info_kill(vxi, 1, SIGKILL);
20578 +long vs_oom_action(unsigned int cmd)
20580 + struct vx_info *vxi = current_vx_info();
20583 + vxdprintk(VXD_CBIT(misc, 5),
20584 + "vs_oom_action(%p[#%d],%u)",
20585 + vxi, vxi ? vxi->vx_id : 0, cmd);
20587 + ret = vs_reboot_helper(vxi, cmd, NULL);
20591 + vxi->reboot_cmd = cmd;
20592 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20593 + vx_info_kill(vxi, 0, SIGKILL);
20594 + vx_info_kill(vxi, 1, SIGKILL);
20600 + * argv [0] = vshelper_path;
20601 + * argv [1] = action: "startup", "shutdown"
20602 + * argv [2] = context identifier
20604 + * envp [*] = type-specific parameters
20607 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20609 + char id_buf[8], cmd_buf[16];
20610 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20611 + char *envp[] = {"HOME=/", "TERM=linux",
20612 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20614 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20617 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20618 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20621 + case VSC_STARTUP:
20622 + argv[1] = "startup";
20624 + case VSC_SHUTDOWN:
20625 + argv[1] = "shutdown";
20631 + return do_vshelper(vshelper_path, argv, envp, 1);
20636 + * argv [0] = vshelper_path;
20637 + * argv [1] = action: "netup", "netdown"
20638 + * argv [2] = context identifier
20640 + * envp [*] = type-specific parameters
20643 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20645 + char id_buf[8], cmd_buf[16];
20646 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20647 + char *envp[] = {"HOME=/", "TERM=linux",
20648 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20650 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20653 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20654 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20658 + argv[1] = "netup";
20660 + case VSC_NETDOWN:
20661 + argv[1] = "netdown";
20667 + return do_vshelper(vshelper_path, argv, envp, 1);
20670 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/history.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/history.c
20671 --- linux-2.6.32.56/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20672 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/history.c 2011-06-10 13:03:02.000000000 +0200
20675 + * kernel/vserver/history.c
20677 + * Virtual Context History Backtrace
20679 + * Copyright (C) 2004-2007 Herbert Pötzl
20681 + * V0.01 basic structure
20682 + * V0.02 hash/unhash and trace
20683 + * V0.03 preemption fixes
20687 +#include <linux/module.h>
20688 +#include <asm/uaccess.h>
20690 +#include <linux/vserver/context.h>
20691 +#include <linux/vserver/debug.h>
20692 +#include <linux/vserver/debug_cmd.h>
20693 +#include <linux/vserver/history.h>
20696 +#ifdef CONFIG_VSERVER_HISTORY
20697 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20699 +#define VXH_SIZE 64
20702 +struct _vx_history {
20703 + unsigned int counter;
20705 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20709 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20711 +unsigned volatile int vxh_active = 1;
20713 +static atomic_t sequence = ATOMIC_INIT(0);
20718 + * requires disabled preemption */
20720 +struct _vx_hist_entry *vxh_advance(void *loc)
20722 + unsigned int cpu = smp_processor_id();
20723 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20724 + struct _vx_hist_entry *entry;
20725 + unsigned int index;
20727 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20728 + entry = &hist->entry[index];
20730 + entry->seq = atomic_inc_return(&sequence);
20731 + entry->loc = loc;
20735 +EXPORT_SYMBOL_GPL(vxh_advance);
20738 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20740 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20743 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20745 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20746 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20747 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20748 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20750 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20752 + switch (e->type) {
20753 + case VXH_THROW_OOPS:
20754 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20757 + case VXH_GET_VX_INFO:
20758 + case VXH_PUT_VX_INFO:
20759 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20761 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20762 + VXH_VXI_ARGS(e));
20765 + case VXH_INIT_VX_INFO:
20766 + case VXH_SET_VX_INFO:
20767 + case VXH_CLR_VX_INFO:
20768 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20770 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20771 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20772 + VXH_VXI_ARGS(e), e->sc.data);
20775 + case VXH_CLAIM_VX_INFO:
20776 + case VXH_RELEASE_VX_INFO:
20777 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20779 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20780 + VXH_VXI_ARGS(e), e->sc.data);
20783 + case VXH_ALLOC_VX_INFO:
20784 + case VXH_DEALLOC_VX_INFO:
20785 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20787 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20788 + VXH_VXI_ARGS(e));
20791 + case VXH_HASH_VX_INFO:
20792 + case VXH_UNHASH_VX_INFO:
20793 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20795 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20796 + VXH_VXI_ARGS(e));
20799 + case VXH_LOC_VX_INFO:
20800 + case VXH_LOOKUP_VX_INFO:
20801 + case VXH_CREATE_VX_INFO:
20802 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20804 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20805 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20806 + e->ll.arg, VXH_VXI_ARGS(e));
20811 +static void __vxh_dump_history(void)
20813 + unsigned int i, cpu;
20815 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20816 + atomic_read(&sequence), NR_CPUS);
20818 + for (i = 0; i < VXH_SIZE; i++) {
20819 + for_each_online_cpu(cpu) {
20820 + struct _vx_history *hist =
20821 + &per_cpu(vx_history_buffer, cpu);
20822 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20823 + struct _vx_hist_entry *entry = &hist->entry[index];
20825 + vxh_dump_entry(entry, cpu);
20830 +void vxh_dump_history(void)
20834 + local_irq_enable();
20836 + local_irq_disable();
20838 + __vxh_dump_history();
20842 +/* vserver syscall commands below here */
20845 +int vc_dump_history(uint32_t id)
20848 + __vxh_dump_history();
20855 +int do_read_history(struct __user _vx_hist_entry *data,
20856 + int cpu, uint32_t *index, uint32_t *count)
20858 + int pos, ret = 0;
20859 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20860 + int end = hist->counter;
20861 + int start = end - VXH_SIZE + 2;
20862 + int idx = *index;
20864 + /* special case: get current pos */
20870 + /* have we lost some data? */
20874 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20875 + struct _vx_hist_entry *entry =
20876 + &hist->entry[idx % VXH_SIZE];
20878 + /* send entry to userspace */
20879 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20883 + /* save new index and count */
20886 + return ret ? ret : (*index < end);
20889 +int vc_read_history(uint32_t id, void __user *data)
20891 + struct vcmd_read_history_v0 vc_data;
20894 + if (id >= NR_CPUS)
20897 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20900 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20901 + id, &vc_data.index, &vc_data.count);
20903 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20908 +#ifdef CONFIG_COMPAT
20910 +int vc_read_history_x32(uint32_t id, void __user *data)
20912 + struct vcmd_read_history_v0_x32 vc_data;
20915 + if (id >= NR_CPUS)
20918 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20921 + ret = do_read_history((struct __user _vx_hist_entry *)
20922 + compat_ptr(vc_data.data_ptr),
20923 + id, &vc_data.index, &vc_data.count);
20925 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20930 +#endif /* CONFIG_COMPAT */
20932 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/inet.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/inet.c
20933 --- linux-2.6.32.56/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20934 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/inet.c 2011-06-10 13:03:02.000000000 +0200
20937 +#include <linux/in.h>
20938 +#include <linux/inetdevice.h>
20939 +#include <linux/vs_inet.h>
20940 +#include <linux/vs_inet6.h>
20941 +#include <linux/vserver/debug.h>
20942 +#include <net/route.h>
20943 +#include <net/addrconf.h>
20946 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20950 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20953 + struct nx_addr_v4 *ptr;
20955 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20956 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20963 + vxdprintk(VXD_CBIT(net, 2),
20964 + "nx_v4_addr_conflict(%p,%p): %d",
20965 + nxi1, nxi2, ret);
20971 +#ifdef CONFIG_IPV6
20973 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20977 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20980 + struct nx_addr_v6 *ptr;
20982 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20983 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20990 + vxdprintk(VXD_CBIT(net, 2),
20991 + "nx_v6_addr_conflict(%p,%p): %d",
20992 + nxi1, nxi2, ret);
20999 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21001 + struct in_device *in_dev;
21002 + struct in_ifaddr **ifap;
21003 + struct in_ifaddr *ifa;
21008 + in_dev = in_dev_get(dev);
21012 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
21013 + ifap = &ifa->ifa_next) {
21014 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
21019 + in_dev_put(in_dev);
21025 +#ifdef CONFIG_IPV6
21027 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21029 + struct inet6_dev *in_dev;
21030 + struct inet6_ifaddr **ifap;
21031 + struct inet6_ifaddr *ifa;
21036 + in_dev = in6_dev_get(dev);
21040 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
21041 + ifap = &ifa->if_next) {
21042 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
21047 + in6_dev_put(in_dev);
21054 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21060 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
21062 +#ifdef CONFIG_IPV6
21064 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
21069 + vxdprintk(VXD_CBIT(net, 3),
21070 + "dev_in_nx_info(%p,%p[#%d]) = %d",
21071 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
21075 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
21076 + struct rtable **rp, struct flowi *fl)
21081 + /* FIXME: handle lback only case */
21082 + if (!NX_IPV4(nxi))
21085 + vxdprintk(VXD_CBIT(net, 4),
21086 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
21087 + nxi, nxi ? nxi->nx_id : 0,
21088 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
21090 + /* single IP is unconditional */
21091 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21092 + (fl->fl4_src == INADDR_ANY))
21093 + fl->fl4_src = nxi->v4.ip[0].s_addr;
21095 + if (fl->fl4_src == INADDR_ANY) {
21096 + struct nx_addr_v4 *ptr;
21097 + __be32 found = 0;
21100 + err = __ip_route_output_key(net, rp, fl);
21102 + found = (*rp)->rt_src;
21104 + vxdprintk(VXD_CBIT(net, 4),
21105 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21106 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
21107 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21111 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21112 + __be32 primary = ptr->ip[0].s_addr;
21113 + __be32 mask = ptr->mask.s_addr;
21114 + __be32 neta = primary & mask;
21116 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21117 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21118 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21119 + NIPQUAD(mask), NIPQUAD(neta));
21120 + if ((found & mask) != neta)
21123 + fl->fl4_src = primary;
21124 + err = __ip_route_output_key(net, rp, fl);
21125 + vxdprintk(VXD_CBIT(net, 4),
21126 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21127 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
21129 + found = (*rp)->rt_src;
21131 + if (found == primary)
21135 + /* still no source ip? */
21136 + found = ipv4_is_loopback(fl->fl4_dst)
21137 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21139 + /* assign src ip to flow */
21140 + fl->fl4_src = found;
21143 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
21147 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21148 + if (ipv4_is_loopback(fl->fl4_dst))
21149 + fl->fl4_dst = nxi->v4_lback.s_addr;
21150 + if (ipv4_is_loopback(fl->fl4_src))
21151 + fl->fl4_src = nxi->v4_lback.s_addr;
21152 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
21153 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21159 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21161 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/init.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/init.c
21162 --- linux-2.6.32.56/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
21163 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/init.c 2011-06-10 13:03:02.000000000 +0200
21166 + * linux/kernel/init.c
21168 + * Virtual Server Init
21170 + * Copyright (C) 2004-2007 Herbert Pötzl
21172 + * V0.01 basic structure
21176 +#include <linux/init.h>
21178 +int vserver_register_sysctl(void);
21179 +void vserver_unregister_sysctl(void);
21182 +static int __init init_vserver(void)
21186 +#ifdef CONFIG_VSERVER_DEBUG
21187 + vserver_register_sysctl();
21193 +static void __exit exit_vserver(void)
21196 +#ifdef CONFIG_VSERVER_DEBUG
21197 + vserver_unregister_sysctl();
21202 +/* FIXME: GFP_ZONETYPES gone
21203 +long vx_slab[GFP_ZONETYPES]; */
21207 +module_init(init_vserver);
21208 +module_exit(exit_vserver);
21210 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/inode.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/inode.c
21211 --- linux-2.6.32.56/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21212 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/inode.c 2011-06-10 18:58:46.000000000 +0200
21215 + * linux/kernel/vserver/inode.c
21217 + * Virtual Server: File System Support
21219 + * Copyright (C) 2004-2007 Herbert Pötzl
21221 + * V0.01 separated from vcontext V0.05
21222 + * V0.02 moved to tag (instead of xid)
21226 +#include <linux/tty.h>
21227 +#include <linux/proc_fs.h>
21228 +#include <linux/devpts_fs.h>
21229 +#include <linux/fs.h>
21230 +#include <linux/file.h>
21231 +#include <linux/mount.h>
21232 +#include <linux/parser.h>
21233 +#include <linux/namei.h>
21234 +#include <linux/vserver/inode.h>
21235 +#include <linux/vserver/inode_cmd.h>
21236 +#include <linux/vs_base.h>
21237 +#include <linux/vs_tag.h>
21239 +#include <asm/uaccess.h>
21242 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21244 + struct proc_dir_entry *entry;
21246 + if (!in || !in->i_sb)
21249 + *flags = IATTR_TAG
21250 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21251 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21252 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21253 + | (IS_COW(in) ? IATTR_COW : 0);
21254 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21256 + if (S_ISDIR(in->i_mode))
21257 + *mask |= IATTR_BARRIER;
21259 + if (IS_TAGGED(in)) {
21260 + *tag = in->i_tag;
21261 + *mask |= IATTR_TAG;
21264 + switch (in->i_sb->s_magic) {
21265 + case PROC_SUPER_MAGIC:
21266 + entry = PROC_I(in)->pde;
21268 + /* check for specific inodes? */
21270 + *mask |= IATTR_FLAGS;
21272 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21274 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21277 + case DEVPTS_SUPER_MAGIC:
21278 + *tag = in->i_tag;
21279 + *mask |= IATTR_TAG;
21288 +int vc_get_iattr(void __user *data)
21290 + struct path path;
21291 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21294 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21297 + ret = user_lpath(vc_data.name, &path);
21299 + ret = __vc_get_iattr(path.dentry->d_inode,
21300 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21306 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21311 +#ifdef CONFIG_COMPAT
21313 +int vc_get_iattr_x32(void __user *data)
21315 + struct path path;
21316 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21319 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21322 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21324 + ret = __vc_get_iattr(path.dentry->d_inode,
21325 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21331 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21336 +#endif /* CONFIG_COMPAT */
21339 +int vc_fget_iattr(uint32_t fd, void __user *data)
21341 + struct file *filp;
21342 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21345 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21349 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21352 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21353 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21357 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21363 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21365 + struct inode *in = de->d_inode;
21366 + int error = 0, is_proc = 0, has_tag = 0;
21367 + struct iattr attr = { 0 };
21369 + if (!in || !in->i_sb)
21372 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21373 + if ((*mask & IATTR_FLAGS) && !is_proc)
21376 + has_tag = IS_TAGGED(in) ||
21377 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21378 + if ((*mask & IATTR_TAG) && !has_tag)
21381 + mutex_lock(&in->i_mutex);
21382 + if (*mask & IATTR_TAG) {
21383 + attr.ia_tag = *tag;
21384 + attr.ia_valid |= ATTR_TAG;
21387 + if (*mask & IATTR_FLAGS) {
21388 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21389 + unsigned int iflags = PROC_I(in)->vx_flags;
21391 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21392 + | (*flags & IATTR_FLAGS);
21393 + PROC_I(in)->vx_flags = iflags;
21395 + entry->vx_flags = iflags;
21398 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21399 + IATTR_BARRIER | IATTR_COW)) {
21400 + int iflags = in->i_flags;
21401 + int vflags = in->i_vflags;
21403 + if (*mask & IATTR_IMMUTABLE) {
21404 + if (*flags & IATTR_IMMUTABLE)
21405 + iflags |= S_IMMUTABLE;
21407 + iflags &= ~S_IMMUTABLE;
21409 + if (*mask & IATTR_IXUNLINK) {
21410 + if (*flags & IATTR_IXUNLINK)
21411 + iflags |= S_IXUNLINK;
21413 + iflags &= ~S_IXUNLINK;
21415 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21416 + if (*flags & IATTR_BARRIER)
21417 + vflags |= V_BARRIER;
21419 + vflags &= ~V_BARRIER;
21421 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21422 + if (*flags & IATTR_COW)
21425 + vflags &= ~V_COW;
21427 + if (in->i_op && in->i_op->sync_flags) {
21428 + error = in->i_op->sync_flags(in, iflags, vflags);
21434 + if (attr.ia_valid) {
21435 + if (in->i_op && in->i_op->setattr)
21436 + error = in->i_op->setattr(de, &attr);
21438 + error = inode_change_ok(in, &attr);
21440 + error = inode_setattr(in, &attr);
21445 + mutex_unlock(&in->i_mutex);
21449 +int vc_set_iattr(void __user *data)
21451 + struct path path;
21452 + struct vcmd_ctx_iattr_v1 vc_data;
21455 + if (!capable(CAP_LINUX_IMMUTABLE))
21457 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21460 + ret = user_lpath(vc_data.name, &path);
21462 + ret = __vc_set_iattr(path.dentry,
21463 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21467 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21472 +#ifdef CONFIG_COMPAT
21474 +int vc_set_iattr_x32(void __user *data)
21476 + struct path path;
21477 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21480 + if (!capable(CAP_LINUX_IMMUTABLE))
21482 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21485 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21487 + ret = __vc_set_iattr(path.dentry,
21488 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21492 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21497 +#endif /* CONFIG_COMPAT */
21499 +int vc_fset_iattr(uint32_t fd, void __user *data)
21501 + struct file *filp;
21502 + struct vcmd_ctx_fiattr_v0 vc_data;
21505 + if (!capable(CAP_LINUX_IMMUTABLE))
21507 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21511 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21514 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21515 + &vc_data.flags, &vc_data.mask);
21519 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21525 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21527 +static match_table_t tokens = {
21528 + {Opt_notagcheck, "notagcheck"},
21529 +#ifdef CONFIG_PROPAGATE
21530 + {Opt_notag, "notag"},
21531 + {Opt_tag, "tag"},
21532 + {Opt_tagid, "tagid=%u"},
21538 +static void __dx_parse_remove(char *string, char *opt)
21540 + char *p = strstr(string, opt);
21544 + while (*q != '\0' && *q != ',')
21553 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21554 + unsigned long *flags)
21557 + substring_t args[MAX_OPT_ARGS];
21558 + int token, option = 0;
21559 + char *s, *p, *opts;
21563 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21568 + while ((p = strsep(&opts, ",")) != NULL) {
21569 + token = match_token(p, tokens, args);
21571 + vxdprintk(VXD_CBIT(tag, 7),
21572 + "dx_parse_tag(»%s«): %d:#%d",
21573 + p, token, option);
21576 +#ifdef CONFIG_PROPAGATE
21581 + __dx_parse_remove(s, "tag");
21582 + *mnt_flags |= MNT_TAGID;
21583 + set |= MNT_TAGID;
21587 + __dx_parse_remove(s, "notag");
21588 + *mnt_flags |= MNT_NOTAG;
21589 + set |= MNT_NOTAG;
21592 + if (tag && !match_int(args, &option))
21595 + __dx_parse_remove(s, "tagid");
21596 + *mnt_flags |= MNT_TAGID;
21597 + set |= MNT_TAGID;
21600 + case Opt_notagcheck:
21602 + __dx_parse_remove(s, "notagcheck");
21603 + *flags |= MS_NOTAGCHECK;
21604 + set |= MS_NOTAGCHECK;
21609 + strcpy(string, s);
21614 +#ifdef CONFIG_PROPAGATE
21616 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21618 + tag_t new_tag = 0;
21619 + struct vfsmount *mnt;
21624 + mnt = nd->path.mnt;
21628 + propagate = (mnt->mnt_flags & MNT_TAGID);
21630 + new_tag = mnt->mnt_tag;
21632 + vxdprintk(VXD_CBIT(tag, 7),
21633 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21634 + inode, inode->i_ino, inode->i_tag,
21635 + new_tag, (propagate) ? 1 : 0);
21638 + inode->i_tag = new_tag;
21641 +#include <linux/module.h>
21643 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21645 +#endif /* CONFIG_PROPAGATE */
21647 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/limit.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/limit.c
21648 --- linux-2.6.32.56/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21649 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/limit.c 2011-06-10 13:03:02.000000000 +0200
21652 + * linux/kernel/vserver/limit.c
21654 + * Virtual Server: Context Limits
21656 + * Copyright (C) 2004-2010 Herbert Pötzl
21658 + * V0.01 broken out from vcontext V0.05
21659 + * V0.02 changed vcmds to vxi arg
21660 + * V0.03 added memory cgroup support
21664 +#include <linux/sched.h>
21665 +#include <linux/module.h>
21666 +#include <linux/memcontrol.h>
21667 +#include <linux/res_counter.h>
21668 +#include <linux/vs_limit.h>
21669 +#include <linux/vserver/limit.h>
21670 +#include <linux/vserver/limit_cmd.h>
21672 +#include <asm/uaccess.h>
21675 +const char *vlimit_name[NUM_LIMITS] = {
21676 + [RLIMIT_CPU] = "CPU",
21677 + [RLIMIT_RSS] = "RSS",
21678 + [RLIMIT_NPROC] = "NPROC",
21679 + [RLIMIT_NOFILE] = "NOFILE",
21680 + [RLIMIT_MEMLOCK] = "VML",
21681 + [RLIMIT_AS] = "VM",
21682 + [RLIMIT_LOCKS] = "LOCKS",
21683 + [RLIMIT_SIGPENDING] = "SIGP",
21684 + [RLIMIT_MSGQUEUE] = "MSGQ",
21686 + [VLIMIT_NSOCK] = "NSOCK",
21687 + [VLIMIT_OPENFD] = "OPENFD",
21688 + [VLIMIT_ANON] = "ANON",
21689 + [VLIMIT_SHMEM] = "SHMEM",
21690 + [VLIMIT_DENTRY] = "DENTRY",
21693 +EXPORT_SYMBOL_GPL(vlimit_name);
21695 +#define MASK_ENTRY(x) (1 << (x))
21697 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21700 + , /* softlimit */
21701 + MASK_ENTRY( RLIMIT_RSS ) |
21702 + MASK_ENTRY( VLIMIT_ANON ) |
21705 + MASK_ENTRY( RLIMIT_RSS ) |
21706 + MASK_ENTRY( RLIMIT_NPROC ) |
21707 + MASK_ENTRY( RLIMIT_NOFILE ) |
21708 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21709 + MASK_ENTRY( RLIMIT_AS ) |
21710 + MASK_ENTRY( RLIMIT_LOCKS ) |
21711 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21713 + MASK_ENTRY( VLIMIT_NSOCK ) |
21714 + MASK_ENTRY( VLIMIT_OPENFD ) |
21715 + MASK_ENTRY( VLIMIT_ANON ) |
21716 + MASK_ENTRY( VLIMIT_SHMEM ) |
21717 + MASK_ENTRY( VLIMIT_DENTRY ) |
21720 + /* accounting only */
21721 +uint32_t account_mask =
21722 + MASK_ENTRY( VLIMIT_SEMARY ) |
21723 + MASK_ENTRY( VLIMIT_NSEMS ) |
21724 + MASK_ENTRY( VLIMIT_MAPPED ) |
21728 +static int is_valid_vlimit(int id)
21730 + uint32_t mask = vlimit_mask.minimum |
21731 + vlimit_mask.softlimit | vlimit_mask.maximum;
21732 + return mask & (1 << id);
21735 +static int is_accounted_vlimit(int id)
21737 + if (is_valid_vlimit(id))
21739 + return account_mask & (1 << id);
21743 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21745 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21746 + return VX_VLIM(limit);
21749 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21751 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21752 + return VX_VLIM(limit);
21755 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21756 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21758 + if (!is_valid_vlimit(id))
21762 + *minimum = CRLIM_UNSET;
21764 + *softlimit = vc_get_soft(vxi, id);
21766 + *maximum = vc_get_hard(vxi, id);
21770 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21772 + struct vcmd_ctx_rlimit_v0 vc_data;
21775 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21778 + ret = do_get_rlimit(vxi, vc_data.id,
21779 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21783 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21788 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21789 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21791 + if (!is_valid_vlimit(id))
21794 + if (maximum != CRLIM_KEEP)
21795 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21796 + if (softlimit != CRLIM_KEEP)
21797 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21799 + /* clamp soft limit */
21800 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21801 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21806 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21808 + struct vcmd_ctx_rlimit_v0 vc_data;
21810 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21813 + return do_set_rlimit(vxi, vc_data.id,
21814 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21817 +#ifdef CONFIG_IA32_EMULATION
21819 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21821 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21823 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21826 + return do_set_rlimit(vxi, vc_data.id,
21827 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21830 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21832 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21835 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21838 + ret = do_get_rlimit(vxi, vc_data.id,
21839 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21843 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21848 +#endif /* CONFIG_IA32_EMULATION */
21851 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21853 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21859 +static inline void vx_reset_hits(struct _vx_limit *limit)
21863 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21864 + atomic_set(&__rlim_lhit(limit, lim), 0);
21868 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21870 + vx_reset_hits(&vxi->limit);
21874 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21879 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21880 + value = __rlim_get(limit, lim);
21881 + __rlim_rmax(limit, lim) = value;
21882 + __rlim_rmin(limit, lim) = value;
21886 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21888 + vx_reset_minmax(&vxi->limit);
21893 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21895 + struct vcmd_rlimit_stat_v0 vc_data;
21896 + struct _vx_limit *limit = &vxi->limit;
21899 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21903 + if (!is_accounted_vlimit(id))
21906 + vx_limit_fixup(limit, id);
21907 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21908 + vc_data.value = __rlim_get(limit, id);
21909 + vc_data.minimum = __rlim_rmin(limit, id);
21910 + vc_data.maximum = __rlim_rmax(limit, id);
21912 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21918 +void vx_vsi_meminfo(struct sysinfo *val)
21920 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21921 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21922 + u64 res_limit, res_usage;
21927 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21928 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21930 + if (res_limit != RESOURCE_MAX)
21931 + val->totalram = (res_limit >> PAGE_SHIFT);
21932 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21933 + val->bufferram = 0;
21934 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR */
21935 + struct vx_info *vxi = current_vx_info();
21936 + unsigned long totalram, freeram;
21939 + /* we blindly accept the max */
21940 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21941 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21943 + /* total minus used equals free */
21944 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21945 + freeram = (v < totalram) ? totalram - v : 0;
21947 + val->totalram = totalram;
21948 + val->freeram = freeram;
21949 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
21950 + val->totalhigh = 0;
21951 + val->freehigh = 0;
21955 +void vx_vsi_swapinfo(struct sysinfo *val)
21957 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21958 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
21959 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21960 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
21961 + s64 swap_limit, swap_usage;
21966 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21967 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21968 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
21969 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
21971 + if (res_limit == RESOURCE_MAX)
21974 + swap_limit = memsw_limit - res_limit;
21975 + if (memsw_limit != RESOURCE_MAX)
21976 + val->totalswap = swap_limit >> PAGE_SHIFT;
21978 + swap_usage = memsw_usage - res_usage;
21979 + val->freeswap = (swap_usage < swap_limit) ?
21980 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
21981 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
21982 + val->totalswap = 0;
21983 + val->freeswap = 0;
21984 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
21985 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR */
21986 + struct vx_info *vxi = current_vx_info();
21987 + unsigned long totalswap, freeswap;
21990 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21991 + if (v == RLIM_INFINITY) {
21992 + val->freeswap = val->totalswap;
21996 + /* we blindly accept the max */
21997 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21998 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22000 + /* currently 'used' swap */
22001 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22002 + w -= (w > v) ? v : w;
22004 + /* total minus used equals free */
22005 + freeswap = (w < totalswap) ? totalswap - w : 0;
22007 + val->totalswap = totalswap;
22008 + val->freeswap = freeswap;
22009 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22013 +long vx_vsi_cached(struct sysinfo *val)
22015 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22016 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22018 + return mem_cgroup_stat_read_cache(mcg);
22025 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22027 + struct vx_info *vxi = mm->mm_vx_info;
22028 + unsigned long points;
22034 + points = vxi->vx_badness_bias;
22036 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22037 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22038 + points += (v > w) ? (v - w) : 0;
22043 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/limit_init.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/limit_init.h
22044 --- linux-2.6.32.56/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
22045 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/limit_init.h 2011-06-10 13:03:02.000000000 +0200
22049 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22053 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22054 + __rlim_soft(limit, lim) = RLIM_INFINITY;
22055 + __rlim_hard(limit, lim) = RLIM_INFINITY;
22056 + __rlim_set(limit, lim, 0);
22057 + atomic_set(&__rlim_lhit(limit, lim), 0);
22058 + __rlim_rmin(limit, lim) = 0;
22059 + __rlim_rmax(limit, lim) = 0;
22063 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22068 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22069 + if ((1 << lim) & VLIM_NOCHECK)
22071 + value = __rlim_get(limit, lim);
22072 + vxwprintk_xid(value,
22073 + "!!! limit: %p[%s,%d] = %ld on exit.",
22074 + limit, vlimit_name[lim], lim, (long)value);
22078 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/limit_proc.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/limit_proc.h
22079 --- linux-2.6.32.56/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
22080 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/limit_proc.h 2011-06-10 13:03:02.000000000 +0200
22082 +#ifndef _VX_LIMIT_PROC_H
22083 +#define _VX_LIMIT_PROC_H
22085 +#include <linux/vserver/limit_int.h>
22088 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22089 +#define VX_LIMIT_TOP \
22090 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
22092 +#define VX_LIMIT_ARG(r) \
22093 + (unsigned long)__rlim_get(limit, r), \
22094 + (unsigned long)__rlim_rmin(limit, r), \
22095 + (unsigned long)__rlim_rmax(limit, r), \
22096 + VX_VLIM(__rlim_soft(limit, r)), \
22097 + VX_VLIM(__rlim_hard(limit, r)), \
22098 + atomic_read(&__rlim_lhit(limit, r))
22100 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22102 + vx_limit_fixup(limit, -1);
22103 + return sprintf(buffer, VX_LIMIT_TOP
22104 + "PROC" VX_LIMIT_FMT
22105 + "VM" VX_LIMIT_FMT
22106 + "VML" VX_LIMIT_FMT
22107 + "RSS" VX_LIMIT_FMT
22108 + "ANON" VX_LIMIT_FMT
22109 + "RMAP" VX_LIMIT_FMT
22110 + "FILES" VX_LIMIT_FMT
22111 + "OFD" VX_LIMIT_FMT
22112 + "LOCKS" VX_LIMIT_FMT
22113 + "SOCK" VX_LIMIT_FMT
22114 + "MSGQ" VX_LIMIT_FMT
22115 + "SHM" VX_LIMIT_FMT
22116 + "SEMA" VX_LIMIT_FMT
22117 + "SEMS" VX_LIMIT_FMT
22118 + "DENT" VX_LIMIT_FMT,
22119 + VX_LIMIT_ARG(RLIMIT_NPROC),
22120 + VX_LIMIT_ARG(RLIMIT_AS),
22121 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22122 + VX_LIMIT_ARG(RLIMIT_RSS),
22123 + VX_LIMIT_ARG(VLIMIT_ANON),
22124 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22125 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22126 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22127 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22128 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22129 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22130 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22131 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22132 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22133 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22136 +#endif /* _VX_LIMIT_PROC_H */
22139 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/monitor.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/monitor.c
22140 --- linux-2.6.32.56/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
22141 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/monitor.c 2011-06-10 13:03:02.000000000 +0200
22144 + * kernel/vserver/monitor.c
22146 + * Virtual Context Scheduler Monitor
22148 + * Copyright (C) 2006-2007 Herbert Pötzl
22150 + * V0.01 basic design
22154 +#include <linux/module.h>
22155 +#include <linux/jiffies.h>
22156 +#include <asm/uaccess.h>
22157 +#include <asm/atomic.h>
22159 +#include <linux/vserver/monitor.h>
22160 +#include <linux/vserver/debug_cmd.h>
22163 +#ifdef CONFIG_VSERVER_MONITOR
22164 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
22166 +#define VXM_SIZE 64
22169 +struct _vx_monitor {
22170 + unsigned int counter;
22172 + struct _vx_mon_entry entry[VXM_SIZE+1];
22176 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22178 +unsigned volatile int vxm_active = 1;
22180 +static atomic_t sequence = ATOMIC_INIT(0);
22185 + * requires disabled preemption */
22187 +struct _vx_mon_entry *vxm_advance(int cpu)
22189 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22190 + struct _vx_mon_entry *entry;
22191 + unsigned int index;
22193 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22194 + entry = &mon->entry[index];
22196 + entry->ev.seq = atomic_inc_return(&sequence);
22197 + entry->ev.jif = jiffies;
22201 +EXPORT_SYMBOL_GPL(vxm_advance);
22204 +int do_read_monitor(struct __user _vx_mon_entry *data,
22205 + int cpu, uint32_t *index, uint32_t *count)
22207 + int pos, ret = 0;
22208 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22209 + int end = mon->counter;
22210 + int start = end - VXM_SIZE + 2;
22211 + int idx = *index;
22213 + /* special case: get current pos */
22219 + /* have we lost some data? */
22223 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22224 + struct _vx_mon_entry *entry =
22225 + &mon->entry[idx % VXM_SIZE];
22227 + /* send entry to userspace */
22228 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22232 + /* save new index and count */
22235 + return ret ? ret : (*index < end);
22238 +int vc_read_monitor(uint32_t id, void __user *data)
22240 + struct vcmd_read_monitor_v0 vc_data;
22243 + if (id >= NR_CPUS)
22246 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22249 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22250 + id, &vc_data.index, &vc_data.count);
22252 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22257 +#ifdef CONFIG_COMPAT
22259 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22261 + struct vcmd_read_monitor_v0_x32 vc_data;
22264 + if (id >= NR_CPUS)
22267 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22270 + ret = do_read_monitor((struct __user _vx_mon_entry *)
22271 + compat_ptr(vc_data.data_ptr),
22272 + id, &vc_data.index, &vc_data.count);
22274 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22279 +#endif /* CONFIG_COMPAT */
22281 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/network.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/network.c
22282 --- linux-2.6.32.56/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22283 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/network.c 2011-06-10 13:03:02.000000000 +0200
22286 + * linux/kernel/vserver/network.c
22288 + * Virtual Server: Network Support
22290 + * Copyright (C) 2003-2007 Herbert Pötzl
22292 + * V0.01 broken out from vcontext V0.05
22293 + * V0.02 cleaned up implementation
22294 + * V0.03 added equiv nx commands
22295 + * V0.04 switch to RCU based hash
22296 + * V0.05 and back to locking again
22297 + * V0.06 changed vcmds to nxi arg
22298 + * V0.07 have __create claim() the nxi
22302 +#include <linux/err.h>
22303 +#include <linux/slab.h>
22304 +#include <linux/rcupdate.h>
22306 +#include <linux/vs_network.h>
22307 +#include <linux/vs_pid.h>
22308 +#include <linux/vserver/network_cmd.h>
22311 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22312 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22314 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22315 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22318 +static int __init init_network(void)
22320 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22321 + sizeof(struct nx_addr_v4), 0,
22322 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22323 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22324 + sizeof(struct nx_addr_v6), 0,
22325 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22330 +/* __alloc_nx_addr_v4() */
22332 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22334 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22335 + nx_addr_v4_cachep, GFP_KERNEL);
22337 + if (!IS_ERR(nxa))
22338 + memset(nxa, 0, sizeof(*nxa));
22342 +/* __dealloc_nx_addr_v4() */
22344 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22346 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22349 +/* __dealloc_nx_addr_v4_all() */
22351 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22354 + struct nx_addr_v4 *next = nxa->next;
22356 + __dealloc_nx_addr_v4(nxa);
22362 +#ifdef CONFIG_IPV6
22364 +/* __alloc_nx_addr_v6() */
22366 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22368 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22369 + nx_addr_v6_cachep, GFP_KERNEL);
22371 + if (!IS_ERR(nxa))
22372 + memset(nxa, 0, sizeof(*nxa));
22376 +/* __dealloc_nx_addr_v6() */
22378 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22380 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22383 +/* __dealloc_nx_addr_v6_all() */
22385 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22388 + struct nx_addr_v6 *next = nxa->next;
22390 + __dealloc_nx_addr_v6(nxa);
22395 +#endif /* CONFIG_IPV6 */
22397 +/* __alloc_nx_info()
22399 + * allocate an initialized nx_info struct
22400 + * doesn't make it visible (hash) */
22402 +static struct nx_info *__alloc_nx_info(nid_t nid)
22404 + struct nx_info *new = NULL;
22406 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22408 + /* would this benefit from a slab cache? */
22409 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22413 + memset(new, 0, sizeof(struct nx_info));
22414 + new->nx_id = nid;
22415 + INIT_HLIST_NODE(&new->nx_hlist);
22416 + atomic_set(&new->nx_usecnt, 0);
22417 + atomic_set(&new->nx_tasks, 0);
22418 + new->nx_state = 0;
22420 + new->nx_flags = NXF_INIT_SET;
22422 + /* rest of init goes here */
22424 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22425 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22427 + vxdprintk(VXD_CBIT(nid, 0),
22428 + "alloc_nx_info(%d) = %p", nid, new);
22429 + atomic_inc(&nx_global_ctotal);
22433 +/* __dealloc_nx_info()
22435 + * final disposal of nx_info */
22437 +static void __dealloc_nx_info(struct nx_info *nxi)
22439 + vxdprintk(VXD_CBIT(nid, 0),
22440 + "dealloc_nx_info(%p)", nxi);
22442 + nxi->nx_hlist.next = LIST_POISON1;
22445 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22446 + BUG_ON(atomic_read(&nxi->nx_tasks));
22448 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22450 + nxi->nx_state |= NXS_RELEASED;
22452 + atomic_dec(&nx_global_ctotal);
22455 +static void __shutdown_nx_info(struct nx_info *nxi)
22457 + nxi->nx_state |= NXS_SHUTDOWN;
22458 + vs_net_change(nxi, VSC_NETDOWN);
22461 +/* exported stuff */
22463 +void free_nx_info(struct nx_info *nxi)
22465 + /* context shutdown is mandatory */
22466 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22468 + /* context must not be hashed */
22469 + BUG_ON(nxi->nx_state & NXS_HASHED);
22471 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22472 + BUG_ON(atomic_read(&nxi->nx_tasks));
22474 + __dealloc_nx_info(nxi);
22478 +void __nx_set_lback(struct nx_info *nxi)
22480 + int nid = nxi->nx_id;
22481 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22483 + nxi->v4_lback.s_addr = lback;
22486 +extern int __nx_inet_add_lback(__be32 addr);
22487 +extern int __nx_inet_del_lback(__be32 addr);
22490 +/* hash table for nx_info hash */
22492 +#define NX_HASH_SIZE 13
22494 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22496 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22499 +static inline unsigned int __hashval(nid_t nid)
22501 + return (nid % NX_HASH_SIZE);
22506 +/* __hash_nx_info()
22508 + * add the nxi to the global hash table
22509 + * requires the hash_lock to be held */
22511 +static inline void __hash_nx_info(struct nx_info *nxi)
22513 + struct hlist_head *head;
22515 + vxd_assert_lock(&nx_info_hash_lock);
22516 + vxdprintk(VXD_CBIT(nid, 4),
22517 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22519 + /* context must not be hashed */
22520 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22522 + nxi->nx_state |= NXS_HASHED;
22523 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22524 + hlist_add_head(&nxi->nx_hlist, head);
22525 + atomic_inc(&nx_global_cactive);
22528 +/* __unhash_nx_info()
22530 + * remove the nxi from the global hash table
22531 + * requires the hash_lock to be held */
22533 +static inline void __unhash_nx_info(struct nx_info *nxi)
22535 + vxd_assert_lock(&nx_info_hash_lock);
22536 + vxdprintk(VXD_CBIT(nid, 4),
22537 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22538 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22540 + /* context must be hashed */
22541 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22542 + /* but without tasks */
22543 + BUG_ON(atomic_read(&nxi->nx_tasks));
22545 + nxi->nx_state &= ~NXS_HASHED;
22546 + hlist_del(&nxi->nx_hlist);
22547 + atomic_dec(&nx_global_cactive);
22551 +/* __lookup_nx_info()
22553 + * requires the hash_lock to be held
22554 + * doesn't increment the nx_refcnt */
22556 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22558 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22559 + struct hlist_node *pos;
22560 + struct nx_info *nxi;
22562 + vxd_assert_lock(&nx_info_hash_lock);
22563 + hlist_for_each(pos, head) {
22564 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22566 + if (nxi->nx_id == nid)
22571 + vxdprintk(VXD_CBIT(nid, 0),
22572 + "__lookup_nx_info(#%u): %p[#%u]",
22573 + nid, nxi, nxi ? nxi->nx_id : 0);
22578 +/* __create_nx_info()
22580 + * create the requested context
22581 + * get(), claim() and hash it */
22583 +static struct nx_info *__create_nx_info(int id)
22585 + struct nx_info *new, *nxi = NULL;
22587 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22589 + if (!(new = __alloc_nx_info(id)))
22590 + return ERR_PTR(-ENOMEM);
22592 + /* required to make dynamic xids unique */
22593 + spin_lock(&nx_info_hash_lock);
22595 + /* static context requested */
22596 + if ((nxi = __lookup_nx_info(id))) {
22597 + vxdprintk(VXD_CBIT(nid, 0),
22598 + "create_nx_info(%d) = %p (already there)", id, nxi);
22599 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22600 + nxi = ERR_PTR(-EBUSY);
22602 + nxi = ERR_PTR(-EEXIST);
22605 + /* new context */
22606 + vxdprintk(VXD_CBIT(nid, 0),
22607 + "create_nx_info(%d) = %p (new)", id, new);
22608 + claim_nx_info(new, NULL);
22609 + __nx_set_lback(new);
22610 + __hash_nx_info(get_nx_info(new));
22611 + nxi = new, new = NULL;
22614 + spin_unlock(&nx_info_hash_lock);
22616 + __dealloc_nx_info(new);
22622 +/* exported stuff */
22625 +void unhash_nx_info(struct nx_info *nxi)
22627 + __shutdown_nx_info(nxi);
22628 + spin_lock(&nx_info_hash_lock);
22629 + __unhash_nx_info(nxi);
22630 + spin_unlock(&nx_info_hash_lock);
22633 +/* lookup_nx_info()
22635 + * search for a nx_info and get() it
22636 + * negative id means current */
22638 +struct nx_info *lookup_nx_info(int id)
22640 + struct nx_info *nxi = NULL;
22643 + nxi = get_nx_info(current_nx_info());
22644 + } else if (id > 1) {
22645 + spin_lock(&nx_info_hash_lock);
22646 + nxi = get_nx_info(__lookup_nx_info(id));
22647 + spin_unlock(&nx_info_hash_lock);
22652 +/* nid_is_hashed()
22654 + * verify that nid is still hashed */
22656 +int nid_is_hashed(nid_t nid)
22660 + spin_lock(&nx_info_hash_lock);
22661 + hashed = (__lookup_nx_info(nid) != NULL);
22662 + spin_unlock(&nx_info_hash_lock);
22667 +#ifdef CONFIG_PROC_FS
22671 + * get a subset of hashed nids for proc
22672 + * assumes size is at least one */
22674 +int get_nid_list(int index, unsigned int *nids, int size)
22676 + int hindex, nr_nids = 0;
22678 + /* only show current and children */
22679 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22682 + nids[nr_nids] = nx_current_nid();
22686 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22687 + struct hlist_head *head = &nx_info_hash[hindex];
22688 + struct hlist_node *pos;
22690 + spin_lock(&nx_info_hash_lock);
22691 + hlist_for_each(pos, head) {
22692 + struct nx_info *nxi;
22697 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22698 + nids[nr_nids] = nxi->nx_id;
22699 + if (++nr_nids >= size) {
22700 + spin_unlock(&nx_info_hash_lock);
22704 + /* keep the lock time short */
22705 + spin_unlock(&nx_info_hash_lock);
22714 + * migrate task to new network
22715 + * gets nxi, puts old_nxi on change
22718 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22720 + struct nx_info *old_nxi;
22726 + vxdprintk(VXD_CBIT(nid, 5),
22727 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22728 + p, nxi, nxi->nx_id,
22729 + atomic_read(&nxi->nx_usecnt),
22730 + atomic_read(&nxi->nx_tasks));
22732 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22733 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22736 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22739 + /* maybe disallow this completely? */
22740 + old_nxi = task_get_nx_info(p);
22741 + if (old_nxi == nxi)
22746 + clr_nx_info(&p->nx_info);
22747 + claim_nx_info(nxi, p);
22748 + set_nx_info(&p->nx_info, nxi);
22749 + p->nid = nxi->nx_id;
22752 + vxdprintk(VXD_CBIT(nid, 5),
22753 + "moved task %p into nxi:%p[#%d]",
22754 + p, nxi, nxi->nx_id);
22757 + release_nx_info(old_nxi, p);
22760 + put_nx_info(old_nxi);
22765 +void nx_set_persistent(struct nx_info *nxi)
22767 + vxdprintk(VXD_CBIT(nid, 6),
22768 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22770 + get_nx_info(nxi);
22771 + claim_nx_info(nxi, NULL);
22774 +void nx_clear_persistent(struct nx_info *nxi)
22776 + vxdprintk(VXD_CBIT(nid, 6),
22777 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22779 + release_nx_info(nxi, NULL);
22780 + put_nx_info(nxi);
22783 +void nx_update_persistent(struct nx_info *nxi)
22785 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22786 + nx_set_persistent(nxi);
22788 + nx_clear_persistent(nxi);
22791 +/* vserver syscall commands below here */
22793 +/* taks nid and nx_info functions */
22795 +#include <asm/uaccess.h>
22798 +int vc_task_nid(uint32_t id)
22803 + struct task_struct *tsk;
22805 + read_lock(&tasklist_lock);
22806 + tsk = find_task_by_real_pid(id);
22807 + nid = (tsk) ? tsk->nid : -ESRCH;
22808 + read_unlock(&tasklist_lock);
22810 + nid = nx_current_nid();
22815 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22817 + struct vcmd_nx_info_v0 vc_data;
22819 + vc_data.nid = nxi->nx_id;
22821 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22827 +/* network functions */
22829 +int vc_net_create(uint32_t nid, void __user *data)
22831 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22832 + struct nx_info *new_nxi;
22835 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22838 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22841 + new_nxi = __create_nx_info(nid);
22842 + if (IS_ERR(new_nxi))
22843 + return PTR_ERR(new_nxi);
22845 + /* initial flags */
22846 + new_nxi->nx_flags = vc_data.flagword;
22849 + if (vs_net_change(new_nxi, VSC_NETUP))
22852 + ret = nx_migrate_task(current, new_nxi);
22856 + /* return context id on success */
22857 + ret = new_nxi->nx_id;
22859 + /* get a reference for persistent contexts */
22860 + if ((vc_data.flagword & NXF_PERSISTENT))
22861 + nx_set_persistent(new_nxi);
22863 + release_nx_info(new_nxi, NULL);
22864 + put_nx_info(new_nxi);
22869 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22871 + return nx_migrate_task(current, nxi);
22876 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22877 + uint16_t type, uint16_t flags)
22879 + struct nx_addr_v4 *nxa = &nxi->v4;
22881 + if (NX_IPV4(nxi)) {
22882 + /* locate last entry */
22883 + for (; nxa->next; nxa = nxa->next);
22884 + nxa->next = __alloc_nx_addr_v4();
22888 + return PTR_ERR(nxa);
22891 + if (nxi->v4.next)
22892 + /* remove single ip for ip list */
22893 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22895 + nxa->ip[0].s_addr = ip;
22896 + nxa->ip[1].s_addr = ip2;
22897 + nxa->mask.s_addr = mask;
22898 + nxa->type = type;
22899 + nxa->flags = flags;
22904 +int vc_net_add(struct nx_info *nxi, void __user *data)
22906 + struct vcmd_net_addr_v0 vc_data;
22907 + int index, ret = 0;
22909 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22912 + switch (vc_data.type) {
22913 + case NXA_TYPE_IPV4:
22914 + if ((vc_data.count < 1) || (vc_data.count > 4))
22918 + while (index < vc_data.count) {
22919 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22920 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22928 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22929 + nxi->v4_bcast = vc_data.ip[0];
22933 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22934 + nxi->v4_lback = vc_data.ip[0];
22945 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22947 + struct vcmd_net_addr_v0 vc_data;
22949 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22952 + switch (vc_data.type) {
22953 + case NXA_TYPE_ANY:
22954 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22955 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22965 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22967 + struct vcmd_net_addr_ipv4_v1 vc_data;
22969 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22972 + switch (vc_data.type) {
22973 + case NXA_TYPE_ADDR:
22974 + case NXA_TYPE_RANGE:
22975 + case NXA_TYPE_MASK:
22976 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22977 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22979 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22980 + nxi->v4_bcast = vc_data.ip;
22983 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22984 + nxi->v4_lback = vc_data.ip;
22993 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
22995 + struct vcmd_net_addr_ipv4_v1 vc_data;
22997 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23000 + switch (vc_data.type) {
23001 +/* case NXA_TYPE_ADDR:
23004 + case NXA_TYPE_ANY:
23005 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23006 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23016 +#ifdef CONFIG_IPV6
23018 +int do_add_v6_addr(struct nx_info *nxi,
23019 + struct in6_addr *ip, struct in6_addr *mask,
23020 + uint32_t prefix, uint16_t type, uint16_t flags)
23022 + struct nx_addr_v6 *nxa = &nxi->v6;
23024 + if (NX_IPV6(nxi)) {
23025 + /* locate last entry */
23026 + for (; nxa->next; nxa = nxa->next);
23027 + nxa->next = __alloc_nx_addr_v6();
23031 + return PTR_ERR(nxa);
23035 + nxa->mask = *mask;
23036 + nxa->prefix = prefix;
23037 + nxa->type = type;
23038 + nxa->flags = flags;
23043 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23045 + struct vcmd_net_addr_ipv6_v1 vc_data;
23047 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23050 + switch (vc_data.type) {
23051 + case NXA_TYPE_ADDR:
23052 + case NXA_TYPE_MASK:
23053 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23054 + vc_data.prefix, vc_data.type, vc_data.flags);
23061 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23063 + struct vcmd_net_addr_ipv6_v1 vc_data;
23065 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23068 + switch (vc_data.type) {
23069 + case NXA_TYPE_ANY:
23070 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23071 + memset(&nxi->v6, 0, sizeof(nxi->v6));
23080 +#endif /* CONFIG_IPV6 */
23083 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23085 + struct vcmd_net_flags_v0 vc_data;
23087 + vc_data.flagword = nxi->nx_flags;
23089 + /* special STATE flag handling */
23090 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23092 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23097 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23099 + struct vcmd_net_flags_v0 vc_data;
23100 + uint64_t mask, trigger;
23102 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23105 + /* special STATE flag handling */
23106 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23107 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23109 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23110 + vc_data.flagword, mask);
23111 + if (trigger & NXF_PERSISTENT)
23112 + nx_update_persistent(nxi);
23117 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23119 + struct vcmd_net_caps_v0 vc_data;
23121 + vc_data.ncaps = nxi->nx_ncaps;
23122 + vc_data.cmask = ~0ULL;
23124 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23129 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23131 + struct vcmd_net_caps_v0 vc_data;
23133 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23136 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23137 + vc_data.ncaps, vc_data.cmask);
23142 +#include <linux/module.h>
23144 +module_init(init_network);
23146 +EXPORT_SYMBOL_GPL(free_nx_info);
23147 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23149 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/proc.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/proc.c
23150 --- linux-2.6.32.56/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
23151 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/proc.c 2011-06-10 13:03:02.000000000 +0200
23154 + * linux/kernel/vserver/proc.c
23156 + * Virtual Context Support
23158 + * Copyright (C) 2003-2007 Herbert Pötzl
23160 + * V0.01 basic structure
23161 + * V0.02 adaptation vs1.3.0
23162 + * V0.03 proc permissions
23163 + * V0.04 locking/generic
23164 + * V0.05 next generation procfs
23165 + * V0.06 inode validation
23166 + * V0.07 generic rewrite vid
23167 + * V0.08 remove inode type
23171 +#include <linux/proc_fs.h>
23172 +#include <linux/fs_struct.h>
23173 +#include <linux/mount.h>
23174 +#include <asm/unistd.h>
23176 +#include <linux/vs_context.h>
23177 +#include <linux/vs_network.h>
23178 +#include <linux/vs_cvirt.h>
23180 +#include <linux/in.h>
23181 +#include <linux/inetdevice.h>
23182 +#include <linux/vs_inet.h>
23183 +#include <linux/vs_inet6.h>
23185 +#include <linux/vserver/global.h>
23187 +#include "cvirt_proc.h"
23188 +#include "cacct_proc.h"
23189 +#include "limit_proc.h"
23190 +#include "sched_proc.h"
23191 +#include "vci_config.h"
23194 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23198 + CAP_FOR_EACH_U32(__capi) {
23199 + buffer += sprintf(buffer, "%08x",
23200 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23206 +static struct proc_dir_entry *proc_virtual;
23208 +static struct proc_dir_entry *proc_virtnet;
23211 +/* first the actual feeds */
23214 +static int proc_vci(char *buffer)
23216 + return sprintf(buffer,
23217 + "VCIVersion:\t%04x:%04x\n"
23218 + "VCISyscall:\t%d\n"
23219 + "VCIKernel:\t%08x\n",
23220 + VCI_VERSION >> 16,
23221 + VCI_VERSION & 0xFFFF,
23223 + vci_kernel_config());
23226 +static int proc_virtual_info(char *buffer)
23228 + return proc_vci(buffer);
23231 +static int proc_virtual_status(char *buffer)
23233 + return sprintf(buffer,
23235 + "#CActive:\t%d\n"
23236 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23237 + "#InitTask:\t%d\t%d %d\n",
23238 + atomic_read(&vx_global_ctotal),
23239 + atomic_read(&vx_global_cactive),
23240 + atomic_read(&vs_global_nsproxy),
23241 + atomic_read(&vs_global_fs),
23242 + atomic_read(&vs_global_mnt_ns),
23243 + atomic_read(&vs_global_uts_ns),
23244 + atomic_read(&nr_ipc_ns),
23245 + atomic_read(&vs_global_user_ns),
23246 + atomic_read(&vs_global_pid_ns),
23247 + atomic_read(&init_task.usage),
23248 + atomic_read(&init_task.nsproxy->count),
23249 + init_task.fs->users);
23253 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23257 + length = sprintf(buffer,
23265 + vxi->vx_badness_bias);
23269 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23271 + char *orig = buffer;
23273 + buffer += sprintf(buffer,
23276 + "Flags:\t%016llx\n",
23277 + atomic_read(&vxi->vx_usecnt),
23278 + atomic_read(&vxi->vx_tasks),
23279 + (unsigned long long)vxi->vx_flags);
23281 + buffer += sprintf(buffer, "BCaps:\t");
23282 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23283 + buffer += sprintf(buffer, "\n");
23285 + buffer += sprintf(buffer,
23286 + "CCaps:\t%016llx\n"
23287 + "Spaces:\t%08lx %08lx\n",
23288 + (unsigned long long)vxi->vx_ccaps,
23289 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23290 + return buffer - orig;
23293 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23295 + return vx_info_proc_limit(&vxi->limit, buffer);
23298 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23302 + length = vx_info_proc_sched(&vxi->sched, buffer);
23303 + for_each_online_cpu(cpu) {
23304 + length += vx_info_proc_sched_pc(
23305 + &vx_per_cpu(vxi, sched_pc, cpu),
23306 + buffer + length, cpu);
23311 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23313 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23316 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23318 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23321 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23325 + vx_update_load(vxi);
23326 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23327 + for_each_online_cpu(cpu) {
23328 + length += vx_info_proc_cvirt_pc(
23329 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23330 + buffer + length, cpu);
23335 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23337 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23341 +static int proc_virtnet_info(char *buffer)
23343 + return proc_vci(buffer);
23346 +static int proc_virtnet_status(char *buffer)
23348 + return sprintf(buffer,
23350 + "#CActive:\t%d\n",
23351 + atomic_read(&nx_global_ctotal),
23352 + atomic_read(&nx_global_cactive));
23355 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23357 + struct nx_addr_v4 *v4a;
23358 +#ifdef CONFIG_IPV6
23359 + struct nx_addr_v6 *v6a;
23363 + length = sprintf(buffer,
23366 + "Bcast:\t" NIPQUAD_FMT "\n"
23367 + "Lback:\t" NIPQUAD_FMT "\n",
23370 + NIPQUAD(nxi->v4_bcast.s_addr),
23371 + NIPQUAD(nxi->v4_lback.s_addr));
23373 + if (!NX_IPV4(nxi))
23375 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23376 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23379 +#ifdef CONFIG_IPV6
23380 + if (!NX_IPV6(nxi))
23382 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23383 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23390 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23394 + length = sprintf(buffer,
23397 + "Flags:\t%016llx\n"
23398 + "NCaps:\t%016llx\n",
23399 + atomic_read(&nxi->nx_usecnt),
23400 + atomic_read(&nxi->nx_tasks),
23401 + (unsigned long long)nxi->nx_flags,
23402 + (unsigned long long)nxi->nx_ncaps);
23408 +/* here the inode helpers */
23414 + struct inode_operations *iop;
23415 + struct file_operations *fop;
23416 + union proc_op op;
23419 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23421 + struct inode *inode = new_inode(sb);
23426 + inode->i_mode = p->mode;
23428 + inode->i_op = p->iop;
23430 + inode->i_fop = p->fop;
23432 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23433 + inode->i_flags |= S_IMMUTABLE;
23435 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23437 + inode->i_uid = 0;
23438 + inode->i_gid = 0;
23439 + inode->i_tag = 0;
23444 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23445 + struct dentry *dentry, int id, void *ptr)
23447 + struct vs_entry *p = ptr;
23448 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23449 + struct dentry *error = ERR_PTR(-EINVAL);
23454 + PROC_I(inode)->op = p->op;
23455 + PROC_I(inode)->fd = id;
23456 + d_add(dentry, inode);
23464 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23467 + * Fill a directory entry.
23469 + * If possible create the dcache entry and derive our inode number and
23470 + * file type from dcache entry.
23472 + * Since all of the proc inode numbers are dynamically generated, the inode
23473 + * numbers do not exist until the inode is cache. This means creating the
23474 + * the dcache entry in readdir is necessary to keep the inode numbers
23475 + * reported by readdir in sync with the inode numbers reported
23478 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23479 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23481 + struct dentry *child, *dir = filp->f_dentry;
23482 + struct inode *inode;
23483 + struct qstr qname;
23485 + unsigned type = DT_UNKNOWN;
23487 + qname.name = name;
23489 + qname.hash = full_name_hash(name, len);
23491 + child = d_lookup(dir, &qname);
23493 + struct dentry *new;
23494 + new = d_alloc(dir, &qname);
23496 + child = instantiate(dir->d_inode, new, id, ptr);
23503 + if (!child || IS_ERR(child) || !child->d_inode)
23504 + goto end_instantiate;
23505 + inode = child->d_inode;
23507 + ino = inode->i_ino;
23508 + type = inode->i_mode >> 12;
23513 + ino = find_inode_number(dir, &qname);
23516 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23521 +/* get and revalidate vx_info/xid */
23524 +struct vx_info *get_proc_vx_info(struct inode *inode)
23526 + return lookup_vx_info(PROC_I(inode)->fd);
23529 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23531 + struct inode *inode = dentry->d_inode;
23532 + xid_t xid = PROC_I(inode)->fd;
23534 + if (!xid || xid_is_hashed(xid))
23541 +/* get and revalidate nx_info/nid */
23543 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23545 + struct inode *inode = dentry->d_inode;
23546 + nid_t nid = PROC_I(inode)->fd;
23548 + if (!nid || nid_is_hashed(nid))
23556 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23558 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23559 + size_t count, loff_t *ppos)
23561 + struct inode *inode = file->f_dentry->d_inode;
23562 + unsigned long page;
23563 + ssize_t length = 0;
23565 + if (count > PROC_BLOCK_SIZE)
23566 + count = PROC_BLOCK_SIZE;
23568 + /* fade that out as soon as stable */
23569 + WARN_ON(PROC_I(inode)->fd);
23571 + if (!(page = __get_free_page(GFP_KERNEL)))
23574 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23575 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23578 + length = simple_read_from_buffer(buf, count, ppos,
23579 + (char *)page, length);
23585 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23586 + size_t count, loff_t *ppos)
23588 + struct inode *inode = file->f_dentry->d_inode;
23589 + struct vx_info *vxi = NULL;
23590 + xid_t xid = PROC_I(inode)->fd;
23591 + unsigned long page;
23592 + ssize_t length = 0;
23594 + if (count > PROC_BLOCK_SIZE)
23595 + count = PROC_BLOCK_SIZE;
23597 + /* fade that out as soon as stable */
23599 + vxi = lookup_vx_info(xid);
23603 + length = -ENOMEM;
23604 + if (!(page = __get_free_page(GFP_KERNEL)))
23607 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23608 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23611 + length = simple_read_from_buffer(buf, count, ppos,
23612 + (char *)page, length);
23616 + put_vx_info(vxi);
23621 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23622 + size_t count, loff_t *ppos)
23624 + struct inode *inode = file->f_dentry->d_inode;
23625 + struct nx_info *nxi = NULL;
23626 + nid_t nid = PROC_I(inode)->fd;
23627 + unsigned long page;
23628 + ssize_t length = 0;
23630 + if (count > PROC_BLOCK_SIZE)
23631 + count = PROC_BLOCK_SIZE;
23633 + /* fade that out as soon as stable */
23635 + nxi = lookup_nx_info(nid);
23639 + length = -ENOMEM;
23640 + if (!(page = __get_free_page(GFP_KERNEL)))
23643 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23644 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23647 + length = simple_read_from_buffer(buf, count, ppos,
23648 + (char *)page, length);
23652 + put_nx_info(nxi);
23659 +/* here comes the lower level */
23662 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23663 + .len = sizeof(NAME) - 1, \
23664 + .name = (NAME), \
23672 +#define DIR(NAME, MODE, OTYPE) \
23673 + NOD(NAME, (S_IFDIR | (MODE)), \
23674 + &proc_ ## OTYPE ## _inode_operations, \
23675 + &proc_ ## OTYPE ## _file_operations, { } )
23677 +#define INF(NAME, MODE, OTYPE) \
23678 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23679 + &proc_vs_info_file_operations, \
23680 + { .proc_vs_read = &proc_##OTYPE } )
23682 +#define VINF(NAME, MODE, OTYPE) \
23683 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23684 + &proc_vx_info_file_operations, \
23685 + { .proc_vxi_read = &proc_##OTYPE } )
23687 +#define NINF(NAME, MODE, OTYPE) \
23688 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23689 + &proc_nx_info_file_operations, \
23690 + { .proc_nxi_read = &proc_##OTYPE } )
23693 +static struct file_operations proc_vs_info_file_operations = {
23694 + .read = proc_vs_info_read,
23697 +static struct file_operations proc_vx_info_file_operations = {
23698 + .read = proc_vx_info_read,
23701 +static struct dentry_operations proc_xid_dentry_operations = {
23702 + .d_revalidate = proc_xid_revalidate,
23705 +static struct vs_entry vx_base_stuff[] = {
23706 + VINF("info", S_IRUGO, vxi_info),
23707 + VINF("status", S_IRUGO, vxi_status),
23708 + VINF("limit", S_IRUGO, vxi_limit),
23709 + VINF("sched", S_IRUGO, vxi_sched),
23710 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23711 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23712 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23713 + VINF("cacct", S_IRUGO, vxi_cacct),
23720 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23721 + struct dentry *dentry, int id, void *ptr)
23723 + dentry->d_op = &proc_xid_dentry_operations;
23724 + return vs_proc_instantiate(dir, dentry, id, ptr);
23727 +static struct dentry *proc_xid_lookup(struct inode *dir,
23728 + struct dentry *dentry, struct nameidata *nd)
23730 + struct vs_entry *p = vx_base_stuff;
23731 + struct dentry *error = ERR_PTR(-ENOENT);
23733 + for (; p->name; p++) {
23734 + if (p->len != dentry->d_name.len)
23736 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23742 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23747 +static int proc_xid_readdir(struct file *filp,
23748 + void *dirent, filldir_t filldir)
23750 + struct dentry *dentry = filp->f_dentry;
23751 + struct inode *inode = dentry->d_inode;
23752 + struct vs_entry *p = vx_base_stuff;
23753 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23757 + pos = filp->f_pos;
23760 + ino = inode->i_ino;
23761 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23764 + /* fall through */
23766 + ino = parent_ino(dentry);
23767 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23770 + /* fall through */
23773 + if (index >= size)
23775 + for (p += index; p->name; p++) {
23776 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23777 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23783 + filp->f_pos = pos;
23789 +static struct file_operations proc_nx_info_file_operations = {
23790 + .read = proc_nx_info_read,
23793 +static struct dentry_operations proc_nid_dentry_operations = {
23794 + .d_revalidate = proc_nid_revalidate,
23797 +static struct vs_entry nx_base_stuff[] = {
23798 + NINF("info", S_IRUGO, nxi_info),
23799 + NINF("status", S_IRUGO, nxi_status),
23804 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23805 + struct dentry *dentry, int id, void *ptr)
23807 + dentry->d_op = &proc_nid_dentry_operations;
23808 + return vs_proc_instantiate(dir, dentry, id, ptr);
23811 +static struct dentry *proc_nid_lookup(struct inode *dir,
23812 + struct dentry *dentry, struct nameidata *nd)
23814 + struct vs_entry *p = nx_base_stuff;
23815 + struct dentry *error = ERR_PTR(-ENOENT);
23817 + for (; p->name; p++) {
23818 + if (p->len != dentry->d_name.len)
23820 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23826 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23831 +static int proc_nid_readdir(struct file *filp,
23832 + void *dirent, filldir_t filldir)
23834 + struct dentry *dentry = filp->f_dentry;
23835 + struct inode *inode = dentry->d_inode;
23836 + struct vs_entry *p = nx_base_stuff;
23837 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23841 + pos = filp->f_pos;
23844 + ino = inode->i_ino;
23845 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23848 + /* fall through */
23850 + ino = parent_ino(dentry);
23851 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23854 + /* fall through */
23857 + if (index >= size)
23859 + for (p += index; p->name; p++) {
23860 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23861 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23867 + filp->f_pos = pos;
23872 +#define MAX_MULBY10 ((~0U - 9) / 10)
23874 +static inline int atovid(const char *str, int len)
23879 + while (len-- > 0) {
23884 + if (vid >= MAX_MULBY10)
23894 +/* now the upper level (virtual) */
23897 +static struct file_operations proc_xid_file_operations = {
23898 + .read = generic_read_dir,
23899 + .readdir = proc_xid_readdir,
23902 +static struct inode_operations proc_xid_inode_operations = {
23903 + .lookup = proc_xid_lookup,
23906 +static struct vs_entry vx_virtual_stuff[] = {
23907 + INF("info", S_IRUGO, virtual_info),
23908 + INF("status", S_IRUGO, virtual_status),
23909 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23913 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23914 + struct dentry *dentry, struct nameidata *nd)
23916 + struct vs_entry *p = vx_virtual_stuff;
23917 + struct dentry *error = ERR_PTR(-ENOENT);
23920 + for (; p->name; p++) {
23921 + if (p->len != dentry->d_name.len)
23923 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23927 + goto instantiate;
23929 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23930 + if ((id < 0) || !xid_is_hashed(id))
23934 + error = proc_xid_instantiate(dir, dentry, id, p);
23939 +static struct file_operations proc_nid_file_operations = {
23940 + .read = generic_read_dir,
23941 + .readdir = proc_nid_readdir,
23944 +static struct inode_operations proc_nid_inode_operations = {
23945 + .lookup = proc_nid_lookup,
23948 +static struct vs_entry nx_virtnet_stuff[] = {
23949 + INF("info", S_IRUGO, virtnet_info),
23950 + INF("status", S_IRUGO, virtnet_status),
23951 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23955 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23956 + struct dentry *dentry, struct nameidata *nd)
23958 + struct vs_entry *p = nx_virtnet_stuff;
23959 + struct dentry *error = ERR_PTR(-ENOENT);
23962 + for (; p->name; p++) {
23963 + if (p->len != dentry->d_name.len)
23965 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23969 + goto instantiate;
23971 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23972 + if ((id < 0) || !nid_is_hashed(id))
23976 + error = proc_nid_instantiate(dir, dentry, id, p);
23982 +#define PROC_MAXVIDS 32
23984 +int proc_virtual_readdir(struct file *filp,
23985 + void *dirent, filldir_t filldir)
23987 + struct dentry *dentry = filp->f_dentry;
23988 + struct inode *inode = dentry->d_inode;
23989 + struct vs_entry *p = vx_virtual_stuff;
23990 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23992 + unsigned int xid_array[PROC_MAXVIDS];
23993 + char buf[PROC_NUMBUF];
23994 + unsigned int nr_xids, i;
23997 + pos = filp->f_pos;
24000 + ino = inode->i_ino;
24001 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24004 + /* fall through */
24006 + ino = parent_ino(dentry);
24007 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24010 + /* fall through */
24013 + if (index >= size)
24015 + for (p += index; p->name; p++) {
24016 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24017 + vs_proc_instantiate, 0, p))
24022 + index = pos - size;
24023 + p = &vx_virtual_stuff[size - 1];
24024 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24025 + for (i = 0; i < nr_xids; i++) {
24026 + int n, xid = xid_array[i];
24027 + unsigned int j = PROC_NUMBUF;
24031 + buf[--j] = '0' + (n % 10);
24034 + if (proc_fill_cache(filp, dirent, filldir,
24035 + buf + j, PROC_NUMBUF - j,
24036 + vs_proc_instantiate, xid, p))
24042 + filp->f_pos = pos;
24046 +static int proc_virtual_getattr(struct vfsmount *mnt,
24047 + struct dentry *dentry, struct kstat *stat)
24049 + struct inode *inode = dentry->d_inode;
24051 + generic_fillattr(inode, stat);
24052 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
24056 +static struct file_operations proc_virtual_dir_operations = {
24057 + .read = generic_read_dir,
24058 + .readdir = proc_virtual_readdir,
24061 +static struct inode_operations proc_virtual_dir_inode_operations = {
24062 + .getattr = proc_virtual_getattr,
24063 + .lookup = proc_virtual_lookup,
24070 +int proc_virtnet_readdir(struct file *filp,
24071 + void *dirent, filldir_t filldir)
24073 + struct dentry *dentry = filp->f_dentry;
24074 + struct inode *inode = dentry->d_inode;
24075 + struct vs_entry *p = nx_virtnet_stuff;
24076 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24078 + unsigned int nid_array[PROC_MAXVIDS];
24079 + char buf[PROC_NUMBUF];
24080 + unsigned int nr_nids, i;
24083 + pos = filp->f_pos;
24086 + ino = inode->i_ino;
24087 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24090 + /* fall through */
24092 + ino = parent_ino(dentry);
24093 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24096 + /* fall through */
24099 + if (index >= size)
24101 + for (p += index; p->name; p++) {
24102 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24103 + vs_proc_instantiate, 0, p))
24108 + index = pos - size;
24109 + p = &nx_virtnet_stuff[size - 1];
24110 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24111 + for (i = 0; i < nr_nids; i++) {
24112 + int n, nid = nid_array[i];
24113 + unsigned int j = PROC_NUMBUF;
24117 + buf[--j] = '0' + (n % 10);
24120 + if (proc_fill_cache(filp, dirent, filldir,
24121 + buf + j, PROC_NUMBUF - j,
24122 + vs_proc_instantiate, nid, p))
24128 + filp->f_pos = pos;
24132 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24133 + struct dentry *dentry, struct kstat *stat)
24135 + struct inode *inode = dentry->d_inode;
24137 + generic_fillattr(inode, stat);
24138 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
24142 +static struct file_operations proc_virtnet_dir_operations = {
24143 + .read = generic_read_dir,
24144 + .readdir = proc_virtnet_readdir,
24147 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24148 + .getattr = proc_virtnet_getattr,
24149 + .lookup = proc_virtnet_lookup,
24154 +void proc_vx_init(void)
24156 + struct proc_dir_entry *ent;
24158 + ent = proc_mkdir("virtual", 0);
24160 + ent->proc_fops = &proc_virtual_dir_operations;
24161 + ent->proc_iops = &proc_virtual_dir_inode_operations;
24163 + proc_virtual = ent;
24165 + ent = proc_mkdir("virtnet", 0);
24167 + ent->proc_fops = &proc_virtnet_dir_operations;
24168 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
24170 + proc_virtnet = ent;
24176 +/* per pid info */
24179 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24181 + struct vx_info *vxi;
24182 + char *orig = buffer;
24184 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24186 + vxi = task_get_vx_info(p);
24190 + buffer += sprintf(buffer, "BCaps:\t");
24191 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24192 + buffer += sprintf(buffer, "\n");
24193 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24194 + (unsigned long long)vxi->vx_ccaps);
24195 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24196 + (unsigned long long)vxi->vx_flags);
24197 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24199 + put_vx_info(vxi);
24201 + return buffer - orig;
24205 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24207 + struct nx_info *nxi;
24208 + struct nx_addr_v4 *v4a;
24209 +#ifdef CONFIG_IPV6
24210 + struct nx_addr_v6 *v6a;
24212 + char *orig = buffer;
24215 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24217 + nxi = task_get_nx_info(p);
24221 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24222 + (unsigned long long)nxi->nx_ncaps);
24223 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24224 + (unsigned long long)nxi->nx_flags);
24226 + buffer += sprintf(buffer,
24227 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24228 + NIPQUAD(nxi->v4_bcast.s_addr));
24229 + buffer += sprintf (buffer,
24230 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24231 + NIPQUAD(nxi->v4_lback.s_addr));
24232 + if (!NX_IPV4(nxi))
24234 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24235 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24238 +#ifdef CONFIG_IPV6
24239 + if (!NX_IPV6(nxi))
24241 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24242 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24246 + put_nx_info(nxi);
24248 + return buffer - orig;
24251 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/sched.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sched.c
24252 --- linux-2.6.32.56/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24253 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sched.c 2011-06-10 13:03:02.000000000 +0200
24256 + * linux/kernel/vserver/sched.c
24258 + * Virtual Server: Scheduler Support
24260 + * Copyright (C) 2004-2007 Herbert Pötzl
24262 + * V0.01 adapted Sam Vilains version to 2.6.3
24263 + * V0.02 removed legacy interface
24264 + * V0.03 changed vcmds to vxi arg
24265 + * V0.04 removed older and legacy interfaces
24269 +#include <linux/vs_context.h>
24270 +#include <linux/vs_sched.h>
24271 +#include <linux/vserver/sched_cmd.h>
24273 +#include <asm/uaccess.h>
24276 +#define vxd_check_range(val, min, max) do { \
24277 + vxlprintk((val < min) || (val > max), \
24278 + "check_range(%ld,%ld,%ld)", \
24279 + (long)val, (long)min, (long)max, \
24280 + __FILE__, __LINE__); \
24284 +void vx_update_sched_param(struct _vx_sched *sched,
24285 + struct _vx_sched_pc *sched_pc)
24287 + unsigned int set_mask = sched->update_mask;
24289 + if (set_mask & VXSM_FILL_RATE)
24290 + sched_pc->fill_rate[0] = sched->fill_rate[0];
24291 + if (set_mask & VXSM_INTERVAL)
24292 + sched_pc->interval[0] = sched->interval[0];
24293 + if (set_mask & VXSM_FILL_RATE2)
24294 + sched_pc->fill_rate[1] = sched->fill_rate[1];
24295 + if (set_mask & VXSM_INTERVAL2)
24296 + sched_pc->interval[1] = sched->interval[1];
24297 + if (set_mask & VXSM_TOKENS)
24298 + sched_pc->tokens = sched->tokens;
24299 + if (set_mask & VXSM_TOKENS_MIN)
24300 + sched_pc->tokens_min = sched->tokens_min;
24301 + if (set_mask & VXSM_TOKENS_MAX)
24302 + sched_pc->tokens_max = sched->tokens_max;
24303 + if (set_mask & VXSM_PRIO_BIAS)
24304 + sched_pc->prio_bias = sched->prio_bias;
24306 + if (set_mask & VXSM_IDLE_TIME)
24307 + sched_pc->flags |= VXSF_IDLE_TIME;
24309 + sched_pc->flags &= ~VXSF_IDLE_TIME;
24312 + sched_pc->norm_time = jiffies;
24317 + * recalculate the context's scheduling tokens
24319 + * ret > 0 : number of tokens available
24320 + * ret < 0 : on hold, check delta_min[]
24321 + * -1 only jiffies
24322 + * -2 also idle time
24325 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24326 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24330 + int flags = sched_pc->flags;
24332 + /* how much time did pass? */
24333 + delta = *norm_time - sched_pc->norm_time;
24334 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24335 + vxd_check_range(delta, 0, INT_MAX);
24337 + if (delta >= sched_pc->interval[0]) {
24338 + long tokens, integral;
24340 + /* calc integral token part */
24341 + tokens = delta / sched_pc->interval[0];
24342 + integral = tokens * sched_pc->interval[0];
24343 + tokens *= sched_pc->fill_rate[0];
24344 +#ifdef CONFIG_VSERVER_HARDCPU
24345 + delta_min[0] = delta - integral;
24346 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24348 + /* advance time */
24349 + sched_pc->norm_time += delta;
24352 + sched_pc->tokens += tokens;
24353 + sched_pc->token_time += tokens;
24355 + delta_min[0] = delta;
24357 +#ifdef CONFIG_VSERVER_IDLETIME
24358 + if (!(flags & VXSF_IDLE_TIME))
24361 + /* how much was the idle skip? */
24362 + delta = *idle_time - sched_pc->idle_time;
24363 + vxd_check_range(delta, 0, INT_MAX);
24365 + if (delta >= sched_pc->interval[1]) {
24366 + long tokens, integral;
24368 + /* calc fair share token part */
24369 + tokens = delta / sched_pc->interval[1];
24370 + integral = tokens * sched_pc->interval[1];
24371 + tokens *= sched_pc->fill_rate[1];
24372 + delta_min[1] = delta - integral;
24373 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24375 + /* advance idle time */
24376 + sched_pc->idle_time += integral;
24379 + sched_pc->tokens += tokens;
24380 + sched_pc->token_time += tokens;
24382 + delta_min[1] = delta;
24386 + /* clip at maximum */
24387 + if (sched_pc->tokens > sched_pc->tokens_max)
24388 + sched_pc->tokens = sched_pc->tokens_max;
24389 + tokens = sched_pc->tokens;
24391 + if ((flags & VXSF_ONHOLD)) {
24392 + /* can we unhold? */
24393 + if (tokens >= sched_pc->tokens_min) {
24394 + flags &= ~VXSF_ONHOLD;
24395 + sched_pc->hold_ticks +=
24396 + *norm_time - sched_pc->onhold;
24400 + /* put on hold? */
24401 + if (tokens <= 0) {
24402 + flags |= VXSF_ONHOLD;
24403 + sched_pc->onhold = *norm_time;
24407 + sched_pc->flags = flags;
24411 + tokens = sched_pc->tokens_min - tokens;
24412 + sched_pc->flags = flags;
24413 + // BUG_ON(tokens < 0); probably doesn't hold anymore
24415 +#ifdef CONFIG_VSERVER_HARDCPU
24416 + /* next interval? */
24417 + if (!sched_pc->fill_rate[0])
24418 + delta_min[0] = HZ;
24419 + else if (tokens > sched_pc->fill_rate[0])
24420 + delta_min[0] += sched_pc->interval[0] *
24421 + tokens / sched_pc->fill_rate[0];
24423 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24424 + vxd_check_range(delta_min[0], 0, INT_MAX);
24426 +#ifdef CONFIG_VSERVER_IDLETIME
24427 + if (!(flags & VXSF_IDLE_TIME))
24430 + /* next interval? */
24431 + if (!sched_pc->fill_rate[1])
24432 + delta_min[1] = HZ;
24433 + else if (tokens > sched_pc->fill_rate[1])
24434 + delta_min[1] += sched_pc->interval[1] *
24435 + tokens / sched_pc->fill_rate[1];
24437 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24438 + vxd_check_range(delta_min[1], 0, INT_MAX);
24443 +#endif /* CONFIG_VSERVER_IDLETIME */
24446 +#endif /* CONFIG_VSERVER_HARDCPU */
24449 +static inline unsigned long msec_to_ticks(unsigned long msec)
24451 + return msecs_to_jiffies(msec);
24454 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24456 + return jiffies_to_msecs(ticks);
24459 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24461 + return jiffies_to_usecs(ticks);
24465 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24467 + unsigned int set_mask = data->mask;
24468 + unsigned int update_mask;
24471 + /* Sanity check data values */
24472 + if (data->tokens_max <= 0)
24473 + data->tokens_max = HZ;
24474 + if (data->tokens_min < 0)
24475 + data->tokens_min = HZ / 3;
24476 + if (data->tokens_min >= data->tokens_max)
24477 + data->tokens_min = data->tokens_max;
24479 + if (data->prio_bias > MAX_PRIO_BIAS)
24480 + data->prio_bias = MAX_PRIO_BIAS;
24481 + if (data->prio_bias < MIN_PRIO_BIAS)
24482 + data->prio_bias = MIN_PRIO_BIAS;
24484 + spin_lock(&vxi->sched.tokens_lock);
24486 + /* sync up on delayed updates */
24487 + for_each_cpu_mask(cpu, vxi->sched.update)
24488 + vx_update_sched_param(&vxi->sched,
24489 + &vx_per_cpu(vxi, sched_pc, cpu));
24491 + if (set_mask & VXSM_FILL_RATE)
24492 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24493 + if (set_mask & VXSM_FILL_RATE2)
24494 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24495 + if (set_mask & VXSM_INTERVAL)
24496 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24497 + msec_to_ticks(data->interval[0]) : data->interval[0];
24498 + if (set_mask & VXSM_INTERVAL2)
24499 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24500 + msec_to_ticks(data->interval[1]) : data->interval[1];
24501 + if (set_mask & VXSM_TOKENS)
24502 + vxi->sched.tokens = data->tokens;
24503 + if (set_mask & VXSM_TOKENS_MIN)
24504 + vxi->sched.tokens_min = data->tokens_min;
24505 + if (set_mask & VXSM_TOKENS_MAX)
24506 + vxi->sched.tokens_max = data->tokens_max;
24507 + if (set_mask & VXSM_PRIO_BIAS)
24508 + vxi->sched.prio_bias = data->prio_bias;
24510 + /* Sanity check rate/interval */
24511 + for (i = 0; i < 2; i++) {
24512 + if (data->fill_rate[i] < 0)
24513 + data->fill_rate[i] = 0;
24514 + if (data->interval[i] <= 0)
24515 + data->interval[i] = HZ;
24518 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24519 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24520 + vxi->sched.update_mask = update_mask;
24524 + if (set_mask & VXSM_CPU_ID) {
24525 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24526 + cpus_and(vxi->sched.update, cpu_online_map,
24527 + vxi->sched.update);
24529 + vxi->sched.update = cpu_online_map;
24531 + /* forced reload? */
24532 + if (set_mask & VXSM_FORCE) {
24533 + for_each_cpu_mask(cpu, vxi->sched.update)
24534 + vx_update_sched_param(&vxi->sched,
24535 + &vx_per_cpu(vxi, sched_pc, cpu));
24536 + vxi->sched.update = CPU_MASK_NONE;
24539 + /* on UP we update immediately */
24540 + vx_update_sched_param(&vxi->sched,
24541 + &vx_per_cpu(vxi, sched_pc, 0));
24544 + spin_unlock(&vxi->sched.tokens_lock);
24549 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24550 +#define COPY_PRI(C) C(prio_bias)
24551 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24552 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24553 + C(fill_rate[1]); C(interval[1]);
24555 +#define COPY_VALUE(name) vc_data.name = data->name
24557 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24559 + struct vcmd_sched_v5 vc_data;
24561 + vc_data.mask = data->set_mask;
24562 + COPY_IDS(COPY_VALUE);
24563 + COPY_PRI(COPY_VALUE);
24564 + COPY_TOK(COPY_VALUE);
24565 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24566 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24567 + return do_set_sched(vxi, &vc_data);
24570 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24572 + struct vcmd_set_sched_v4 vc_data;
24574 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24577 + return do_set_sched_v4(vxi, &vc_data);
24580 + /* latest interface is v5 */
24582 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24584 + struct vcmd_sched_v5 vc_data;
24586 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24589 + return do_set_sched(vxi, &vc_data);
24593 +#define COPY_PRI(C) C(prio_bias)
24594 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24595 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24596 + C(fill_rate[1]); C(interval[1]);
24598 +#define COPY_VALUE(name) vc_data.name = data->name
24601 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24603 + struct vcmd_sched_v5 vc_data;
24605 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24608 + if (vc_data.mask & VXSM_CPU_ID) {
24609 + int cpu = vc_data.cpu_id;
24610 + struct _vx_sched_pc *data;
24612 + if (!cpu_possible(cpu))
24615 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24616 + COPY_TOK(COPY_VALUE);
24617 + COPY_PRI(COPY_VALUE);
24618 + COPY_FRI(COPY_VALUE);
24620 + if (data->flags & VXSF_IDLE_TIME)
24621 + vc_data.mask |= VXSM_IDLE_TIME;
24623 + struct _vx_sched *data = &vxi->sched;
24625 + COPY_TOK(COPY_VALUE);
24626 + COPY_PRI(COPY_VALUE);
24627 + COPY_FRI(COPY_VALUE);
24630 + if (vc_data.mask & VXSM_MSEC) {
24631 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24632 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24635 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24641 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24643 + struct vcmd_sched_info vc_data;
24646 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24649 + cpu = vc_data.cpu_id;
24650 + if (!cpu_possible(cpu))
24654 + struct _vx_sched_pc *sched_pc =
24655 + &vx_per_cpu(vxi, sched_pc, cpu);
24657 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24658 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24659 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24660 + vc_data.vavavoom = sched_pc->vavavoom;
24662 + vc_data.token_usec = ticks_to_usec(1);
24664 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24669 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/sched_init.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sched_init.h
24670 --- linux-2.6.32.56/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24671 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sched_init.h 2011-06-10 13:03:02.000000000 +0200
24674 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24676 + static struct lock_class_key tokens_lock_key;
24678 + /* scheduling; hard code starting values as constants */
24679 + sched->fill_rate[0] = 1;
24680 + sched->interval[0] = 4;
24681 + sched->fill_rate[1] = 1;
24682 + sched->interval[1] = 8;
24683 + sched->tokens = HZ >> 2;
24684 + sched->tokens_min = HZ >> 4;
24685 + sched->tokens_max = HZ >> 1;
24686 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24687 + sched->prio_bias = 0;
24689 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24693 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24695 + sched_pc->fill_rate[0] = 1;
24696 + sched_pc->interval[0] = 4;
24697 + sched_pc->fill_rate[1] = 1;
24698 + sched_pc->interval[1] = 8;
24699 + sched_pc->tokens = HZ >> 2;
24700 + sched_pc->tokens_min = HZ >> 4;
24701 + sched_pc->tokens_max = HZ >> 1;
24702 + sched_pc->prio_bias = 0;
24703 + sched_pc->vavavoom = 0;
24704 + sched_pc->token_time = 0;
24705 + sched_pc->idle_time = 0;
24706 + sched_pc->norm_time = jiffies;
24708 + sched_pc->user_ticks = 0;
24709 + sched_pc->sys_ticks = 0;
24710 + sched_pc->hold_ticks = 0;
24713 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24719 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24723 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/sched_proc.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sched_proc.h
24724 --- linux-2.6.32.56/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24725 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sched_proc.h 2011-06-10 13:03:02.000000000 +0200
24727 +#ifndef _VX_SCHED_PROC_H
24728 +#define _VX_SCHED_PROC_H
24732 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24736 + length += sprintf(buffer,
24737 + "FillRate:\t%8d,%d\n"
24738 + "Interval:\t%8d,%d\n"
24739 + "TokensMin:\t%8d\n"
24740 + "TokensMax:\t%8d\n"
24741 + "PrioBias:\t%8d\n",
24742 + sched->fill_rate[0],
24743 + sched->fill_rate[1],
24744 + sched->interval[0],
24745 + sched->interval[1],
24746 + sched->tokens_min,
24747 + sched->tokens_max,
24748 + sched->prio_bias);
24753 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24754 + char *buffer, int cpu)
24758 + length += sprintf(buffer + length,
24759 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24760 + (unsigned long long)sched_pc->user_ticks,
24761 + (unsigned long long)sched_pc->sys_ticks,
24762 + (unsigned long long)sched_pc->hold_ticks,
24763 + sched_pc->token_time,
24764 + sched_pc->idle_time);
24765 + length += sprintf(buffer + length,
24766 + " %c%c %d %d %d %d/%d %d/%d",
24767 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24768 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24769 + sched_pc->tokens,
24770 + sched_pc->tokens_min,
24771 + sched_pc->tokens_max,
24772 + sched_pc->fill_rate[0],
24773 + sched_pc->interval[0],
24774 + sched_pc->fill_rate[1],
24775 + sched_pc->interval[1]);
24776 + length += sprintf(buffer + length,
24778 + sched_pc->prio_bias,
24779 + sched_pc->vavavoom);
24783 +#endif /* _VX_SCHED_PROC_H */
24784 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/signal.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/signal.c
24785 --- linux-2.6.32.56/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24786 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/signal.c 2011-06-10 13:03:02.000000000 +0200
24789 + * linux/kernel/vserver/signal.c
24791 + * Virtual Server: Signal Support
24793 + * Copyright (C) 2003-2007 Herbert Pötzl
24795 + * V0.01 broken out from vcontext V0.05
24796 + * V0.02 changed vcmds to vxi arg
24797 + * V0.03 adjusted siginfo for kill
24801 +#include <asm/uaccess.h>
24803 +#include <linux/vs_context.h>
24804 +#include <linux/vs_pid.h>
24805 +#include <linux/vserver/signal_cmd.h>
24808 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24810 + int retval, count = 0;
24811 + struct task_struct *p;
24812 + struct siginfo *sip = SEND_SIG_PRIV;
24815 + vxdprintk(VXD_CBIT(misc, 4),
24816 + "vx_info_kill(%p[#%d],%d,%d)*",
24817 + vxi, vxi->vx_id, pid, sig);
24818 + read_lock(&tasklist_lock);
24822 + for_each_process(p) {
24825 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24826 + (pid && vxi->vx_initpid == p->pid))
24829 + err = group_send_sig_info(sig, sip, p);
24831 + if (err != -EPERM)
24837 + if (vxi->vx_initpid) {
24838 + pid = vxi->vx_initpid;
24839 + /* for now, only SIGINT to private init ... */
24840 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24841 + /* ... as long as there are tasks left */
24842 + (atomic_read(&vxi->vx_tasks) > 1))
24845 + /* fallthrough */
24847 + p = find_task_by_real_pid(pid);
24849 + if (vx_task_xid(p) == vxi->vx_id)
24850 + retval = group_send_sig_info(sig, sip, p);
24854 + read_unlock(&tasklist_lock);
24855 + vxdprintk(VXD_CBIT(misc, 4),
24856 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24857 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24861 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24863 + struct vcmd_ctx_kill_v0 vc_data;
24865 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24868 + /* special check to allow guest shutdown */
24869 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24870 + /* forbid killall pid=0 when init is present */
24871 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24872 + (vc_data.pid > 1)))
24875 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24879 +static int __wait_exit(struct vx_info *vxi)
24881 + DECLARE_WAITQUEUE(wait, current);
24884 + add_wait_queue(&vxi->vx_wait, &wait);
24885 + set_current_state(TASK_INTERRUPTIBLE);
24888 + if (vx_info_state(vxi,
24889 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24891 + if (signal_pending(current)) {
24892 + ret = -ERESTARTSYS;
24899 + set_current_state(TASK_RUNNING);
24900 + remove_wait_queue(&vxi->vx_wait, &wait);
24906 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24908 + struct vcmd_wait_exit_v0 vc_data;
24911 + ret = __wait_exit(vxi);
24912 + vc_data.reboot_cmd = vxi->reboot_cmd;
24913 + vc_data.exit_code = vxi->exit_code;
24915 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24920 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/space.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/space.c
24921 --- linux-2.6.32.56/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24922 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/space.c 2011-06-10 13:03:02.000000000 +0200
24925 + * linux/kernel/vserver/space.c
24927 + * Virtual Server: Context Space Support
24929 + * Copyright (C) 2003-2007 Herbert Pötzl
24931 + * V0.01 broken out from context.c 0.07
24932 + * V0.02 added task locking for namespace
24933 + * V0.03 broken out vx_enter_namespace
24934 + * V0.04 added *space support and commands
24938 +#include <linux/utsname.h>
24939 +#include <linux/nsproxy.h>
24940 +#include <linux/err.h>
24941 +#include <linux/fs_struct.h>
24942 +#include <asm/uaccess.h>
24944 +#include <linux/vs_context.h>
24945 +#include <linux/vserver/space.h>
24946 +#include <linux/vserver/space_cmd.h>
24948 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24949 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24950 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24951 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24952 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24953 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24956 +/* namespace functions */
24958 +#include <linux/mnt_namespace.h>
24959 +#include <linux/user_namespace.h>
24960 +#include <linux/pid_namespace.h>
24961 +#include <linux/ipc_namespace.h>
24962 +#include <net/net_namespace.h>
24965 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24966 + .mask = CLONE_FS |
24974 +static const struct vcmd_space_mask_v1 space_mask = {
24975 + .mask = CLONE_FS |
24980 +#ifdef CONFIG_PID_NS
24983 +#ifdef CONFIG_NET_NS
24989 +static const struct vcmd_space_mask_v1 default_space_mask = {
24990 + .mask = CLONE_FS |
24995 +#ifdef CONFIG_PID_NS
25002 + * build a new nsproxy mix
25003 + * assumes that both proxies are 'const'
25004 + * does not touch nsproxy refcounts
25005 + * will hold a reference on the result.
25008 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25009 + struct nsproxy *new_nsproxy, unsigned long mask)
25011 + struct mnt_namespace *old_ns;
25012 + struct uts_namespace *old_uts;
25013 + struct ipc_namespace *old_ipc;
25014 +#ifdef CONFIG_PID_NS
25015 + struct pid_namespace *old_pid;
25017 +#ifdef CONFIG_NET_NS
25018 + struct net *old_net;
25020 + struct nsproxy *nsproxy;
25022 + nsproxy = copy_nsproxy(old_nsproxy);
25026 + if (mask & CLONE_NEWNS) {
25027 + old_ns = nsproxy->mnt_ns;
25028 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25029 + if (nsproxy->mnt_ns)
25030 + get_mnt_ns(nsproxy->mnt_ns);
25034 + if (mask & CLONE_NEWUTS) {
25035 + old_uts = nsproxy->uts_ns;
25036 + nsproxy->uts_ns = new_nsproxy->uts_ns;
25037 + if (nsproxy->uts_ns)
25038 + get_uts_ns(nsproxy->uts_ns);
25042 + if (mask & CLONE_NEWIPC) {
25043 + old_ipc = nsproxy->ipc_ns;
25044 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25045 + if (nsproxy->ipc_ns)
25046 + get_ipc_ns(nsproxy->ipc_ns);
25050 +#ifdef CONFIG_PID_NS
25051 + if (mask & CLONE_NEWPID) {
25052 + old_pid = nsproxy->pid_ns;
25053 + nsproxy->pid_ns = new_nsproxy->pid_ns;
25054 + if (nsproxy->pid_ns)
25055 + get_pid_ns(nsproxy->pid_ns);
25059 +#ifdef CONFIG_NET_NS
25060 + if (mask & CLONE_NEWNET) {
25061 + old_net = nsproxy->net_ns;
25062 + nsproxy->net_ns = new_nsproxy->net_ns;
25063 + if (nsproxy->net_ns)
25064 + get_net(nsproxy->net_ns);
25069 + put_mnt_ns(old_ns);
25071 + put_uts_ns(old_uts);
25073 + put_ipc_ns(old_ipc);
25074 +#ifdef CONFIG_PID_NS
25076 + put_pid_ns(old_pid);
25078 +#ifdef CONFIG_NET_NS
25080 + put_net(old_net);
25088 + * merge two nsproxy structs into a new one.
25089 + * will hold a reference on the result.
25093 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25094 + struct nsproxy *proxy, unsigned long mask)
25096 + struct nsproxy null_proxy = { .mnt_ns = NULL };
25102 + /* vs_mix_nsproxy returns with reference */
25103 + return vs_mix_nsproxy(old ? old : &null_proxy,
25106 + get_nsproxy(proxy);
25111 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25113 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
25114 + struct fs_struct *fs_cur, *fs = NULL;
25115 + int ret, kill = 0;
25117 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25118 + vxi, vxi->vx_id, mask, index);
25120 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25124 + mask = vxi->vx_nsmask[index];
25126 + if ((mask & vxi->vx_nsmask[index]) != mask)
25129 + if (mask & CLONE_FS) {
25130 + fs = copy_fs_struct(vxi->vx_fs[index]);
25134 + proxy = vxi->vx_nsproxy[index];
25136 + vxdprintk(VXD_CBIT(space, 9),
25137 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25138 + vxi, vxi->vx_id, mask, index, proxy, fs);
25140 + task_lock(current);
25141 + fs_cur = current->fs;
25143 + if (mask & CLONE_FS) {
25144 + write_lock(&fs_cur->lock);
25145 + current->fs = fs;
25146 + kill = !--fs_cur->users;
25147 + write_unlock(&fs_cur->lock);
25150 + proxy_cur = current->nsproxy;
25151 + get_nsproxy(proxy_cur);
25152 + task_unlock(current);
25155 + free_fs_struct(fs_cur);
25157 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25158 + if (IS_ERR(proxy_new)) {
25159 + ret = PTR_ERR(proxy_new);
25163 + proxy_new = xchg(¤t->nsproxy, proxy_new);
25167 + put_nsproxy(proxy_new);
25170 + put_nsproxy(proxy_cur);
25175 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25177 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25178 + struct fs_struct *fs_vxi, *fs;
25179 + int ret, kill = 0;
25181 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25182 + vxi, vxi->vx_id, mask, index);
25185 + mask = default_space_mask.mask;
25187 + if ((mask & space_mask.mask) != mask)
25190 + proxy_vxi = vxi->vx_nsproxy[index];
25191 + fs_vxi = vxi->vx_fs[index];
25193 + if (mask & CLONE_FS) {
25194 + fs = copy_fs_struct(current->fs);
25199 + task_lock(current);
25201 + if (mask & CLONE_FS) {
25202 + write_lock(&fs_vxi->lock);
25203 + vxi->vx_fs[index] = fs;
25204 + kill = !--fs_vxi->users;
25205 + write_unlock(&fs_vxi->lock);
25208 + proxy_cur = current->nsproxy;
25209 + get_nsproxy(proxy_cur);
25210 + task_unlock(current);
25213 + free_fs_struct(fs_vxi);
25215 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25216 + if (IS_ERR(proxy_new)) {
25217 + ret = PTR_ERR(proxy_new);
25221 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25222 + vxi->vx_nsmask[index] |= mask;
25226 + put_nsproxy(proxy_new);
25229 + put_nsproxy(proxy_cur);
25234 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25236 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25238 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25241 + return vx_enter_space(vxi, vc_data.mask, 0);
25244 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25246 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25248 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25251 + if (vc_data.index >= VX_SPACES)
25254 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25257 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25259 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25261 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25264 + return vx_set_space(vxi, vc_data.mask, 0);
25267 +int vc_set_space(struct vx_info *vxi, void __user *data)
25269 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25271 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25274 + if (vc_data.index >= VX_SPACES)
25277 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
25280 +int vc_get_space_mask(void __user *data, int type)
25282 + const struct vcmd_space_mask_v1 *mask;
25285 + mask = &space_mask_v0;
25286 + else if (type == 1)
25287 + mask = &space_mask;
25289 + mask = &default_space_mask;
25291 + vxdprintk(VXD_CBIT(space, 10),
25292 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25294 + if (copy_to_user(data, mask, sizeof(*mask)))
25299 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/switch.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/switch.c
25300 --- linux-2.6.32.56/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25301 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/switch.c 2011-06-10 13:03:02.000000000 +0200
25304 + * linux/kernel/vserver/switch.c
25306 + * Virtual Server: Syscall Switch
25308 + * Copyright (C) 2003-2007 Herbert Pötzl
25310 + * V0.01 syscall switch
25311 + * V0.02 added signal to context
25312 + * V0.03 added rlimit functions
25313 + * V0.04 added iattr, task/xid functions
25314 + * V0.05 added debug/history stuff
25315 + * V0.06 added compat32 layer
25316 + * V0.07 vcmd args and perms
25317 + * V0.08 added status commands
25318 + * V0.09 added tag commands
25319 + * V0.10 added oom bias
25320 + * V0.11 added device commands
25324 +#include <linux/vs_context.h>
25325 +#include <linux/vs_network.h>
25326 +#include <linux/vserver/switch.h>
25328 +#include "vci_config.h"
25332 +int vc_get_version(uint32_t id)
25334 + return VCI_VERSION;
25338 +int vc_get_vci(uint32_t id)
25340 + return vci_kernel_config();
25343 +#include <linux/vserver/context_cmd.h>
25344 +#include <linux/vserver/cvirt_cmd.h>
25345 +#include <linux/vserver/cacct_cmd.h>
25346 +#include <linux/vserver/limit_cmd.h>
25347 +#include <linux/vserver/network_cmd.h>
25348 +#include <linux/vserver/sched_cmd.h>
25349 +#include <linux/vserver/debug_cmd.h>
25350 +#include <linux/vserver/inode_cmd.h>
25351 +#include <linux/vserver/dlimit_cmd.h>
25352 +#include <linux/vserver/signal_cmd.h>
25353 +#include <linux/vserver/space_cmd.h>
25354 +#include <linux/vserver/tag_cmd.h>
25355 +#include <linux/vserver/device_cmd.h>
25357 +#include <linux/vserver/inode.h>
25358 +#include <linux/vserver/dlimit.h>
25361 +#ifdef CONFIG_COMPAT
25362 +#define __COMPAT(name, id, data, compat) \
25363 + (compat) ? name ## _x32(id, data) : name(id, data)
25364 +#define __COMPAT_NO_ID(name, data, compat) \
25365 + (compat) ? name ## _x32(data) : name(data)
25367 +#define __COMPAT(name, id, data, compat) \
25369 +#define __COMPAT_NO_ID(name, data, compat) \
25375 +long do_vcmd(uint32_t cmd, uint32_t id,
25376 + struct vx_info *vxi, struct nx_info *nxi,
25377 + void __user *data, int compat)
25381 + case VCMD_get_version:
25382 + return vc_get_version(id);
25383 + case VCMD_get_vci:
25384 + return vc_get_vci(id);
25386 + case VCMD_task_xid:
25387 + return vc_task_xid(id);
25388 + case VCMD_vx_info:
25389 + return vc_vx_info(vxi, data);
25391 + case VCMD_task_nid:
25392 + return vc_task_nid(id);
25393 + case VCMD_nx_info:
25394 + return vc_nx_info(nxi, data);
25396 + case VCMD_task_tag:
25397 + return vc_task_tag(id);
25399 + case VCMD_set_space_v1:
25400 + return vc_set_space_v1(vxi, data);
25401 + /* this is version 2 */
25402 + case VCMD_set_space:
25403 + return vc_set_space(vxi, data);
25405 + case VCMD_get_space_mask_v0:
25406 + return vc_get_space_mask(data, 0);
25407 + /* this is version 1 */
25408 + case VCMD_get_space_mask:
25409 + return vc_get_space_mask(data, 1);
25411 + case VCMD_get_space_default:
25412 + return vc_get_space_mask(data, -1);
25414 +#ifdef CONFIG_IA32_EMULATION
25415 + case VCMD_get_rlimit:
25416 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25417 + case VCMD_set_rlimit:
25418 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25420 + case VCMD_get_rlimit:
25421 + return vc_get_rlimit(vxi, data);
25422 + case VCMD_set_rlimit:
25423 + return vc_set_rlimit(vxi, data);
25425 + case VCMD_get_rlimit_mask:
25426 + return vc_get_rlimit_mask(id, data);
25427 + case VCMD_reset_hits:
25428 + return vc_reset_hits(vxi, data);
25429 + case VCMD_reset_minmax:
25430 + return vc_reset_minmax(vxi, data);
25432 + case VCMD_get_vhi_name:
25433 + return vc_get_vhi_name(vxi, data);
25434 + case VCMD_set_vhi_name:
25435 + return vc_set_vhi_name(vxi, data);
25437 + case VCMD_ctx_stat:
25438 + return vc_ctx_stat(vxi, data);
25439 + case VCMD_virt_stat:
25440 + return vc_virt_stat(vxi, data);
25441 + case VCMD_sock_stat:
25442 + return vc_sock_stat(vxi, data);
25443 + case VCMD_rlimit_stat:
25444 + return vc_rlimit_stat(vxi, data);
25446 + case VCMD_set_cflags:
25447 + return vc_set_cflags(vxi, data);
25448 + case VCMD_get_cflags:
25449 + return vc_get_cflags(vxi, data);
25451 + /* this is version 1 */
25452 + case VCMD_set_ccaps:
25453 + return vc_set_ccaps(vxi, data);
25454 + /* this is version 1 */
25455 + case VCMD_get_ccaps:
25456 + return vc_get_ccaps(vxi, data);
25457 + case VCMD_set_bcaps:
25458 + return vc_set_bcaps(vxi, data);
25459 + case VCMD_get_bcaps:
25460 + return vc_get_bcaps(vxi, data);
25462 + case VCMD_set_badness:
25463 + return vc_set_badness(vxi, data);
25464 + case VCMD_get_badness:
25465 + return vc_get_badness(vxi, data);
25467 + case VCMD_set_nflags:
25468 + return vc_set_nflags(nxi, data);
25469 + case VCMD_get_nflags:
25470 + return vc_get_nflags(nxi, data);
25472 + case VCMD_set_ncaps:
25473 + return vc_set_ncaps(nxi, data);
25474 + case VCMD_get_ncaps:
25475 + return vc_get_ncaps(nxi, data);
25477 + case VCMD_set_sched_v4:
25478 + return vc_set_sched_v4(vxi, data);
25479 + /* this is version 5 */
25480 + case VCMD_set_sched:
25481 + return vc_set_sched(vxi, data);
25482 + case VCMD_get_sched:
25483 + return vc_get_sched(vxi, data);
25484 + case VCMD_sched_info:
25485 + return vc_sched_info(vxi, data);
25487 + case VCMD_add_dlimit:
25488 + return __COMPAT(vc_add_dlimit, id, data, compat);
25489 + case VCMD_rem_dlimit:
25490 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25491 + case VCMD_set_dlimit:
25492 + return __COMPAT(vc_set_dlimit, id, data, compat);
25493 + case VCMD_get_dlimit:
25494 + return __COMPAT(vc_get_dlimit, id, data, compat);
25496 + case VCMD_ctx_kill:
25497 + return vc_ctx_kill(vxi, data);
25499 + case VCMD_wait_exit:
25500 + return vc_wait_exit(vxi, data);
25502 + case VCMD_get_iattr:
25503 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25504 + case VCMD_set_iattr:
25505 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25507 + case VCMD_fget_iattr:
25508 + return vc_fget_iattr(id, data);
25509 + case VCMD_fset_iattr:
25510 + return vc_fset_iattr(id, data);
25512 + case VCMD_enter_space_v0:
25513 + return vc_enter_space_v1(vxi, NULL);
25514 + case VCMD_enter_space_v1:
25515 + return vc_enter_space_v1(vxi, data);
25516 + /* this is version 2 */
25517 + case VCMD_enter_space:
25518 + return vc_enter_space(vxi, data);
25520 + case VCMD_ctx_create_v0:
25521 + return vc_ctx_create(id, NULL);
25522 + case VCMD_ctx_create:
25523 + return vc_ctx_create(id, data);
25524 + case VCMD_ctx_migrate_v0:
25525 + return vc_ctx_migrate(vxi, NULL);
25526 + case VCMD_ctx_migrate:
25527 + return vc_ctx_migrate(vxi, data);
25529 + case VCMD_net_create_v0:
25530 + return vc_net_create(id, NULL);
25531 + case VCMD_net_create:
25532 + return vc_net_create(id, data);
25533 + case VCMD_net_migrate:
25534 + return vc_net_migrate(nxi, data);
25536 + case VCMD_tag_migrate:
25537 + return vc_tag_migrate(id);
25539 + case VCMD_net_add:
25540 + return vc_net_add(nxi, data);
25541 + case VCMD_net_remove:
25542 + return vc_net_remove(nxi, data);
25544 + case VCMD_net_add_ipv4:
25545 + return vc_net_add_ipv4(nxi, data);
25546 + case VCMD_net_remove_ipv4:
25547 + return vc_net_remove_ipv4(nxi, data);
25548 +#ifdef CONFIG_IPV6
25549 + case VCMD_net_add_ipv6:
25550 + return vc_net_add_ipv6(nxi, data);
25551 + case VCMD_net_remove_ipv6:
25552 + return vc_net_remove_ipv6(nxi, data);
25554 +/* case VCMD_add_match_ipv4:
25555 + return vc_add_match_ipv4(nxi, data);
25556 + case VCMD_get_match_ipv4:
25557 + return vc_get_match_ipv4(nxi, data);
25558 +#ifdef CONFIG_IPV6
25559 + case VCMD_add_match_ipv6:
25560 + return vc_add_match_ipv6(nxi, data);
25561 + case VCMD_get_match_ipv6:
25562 + return vc_get_match_ipv6(nxi, data);
25565 +#ifdef CONFIG_VSERVER_DEVICE
25566 + case VCMD_set_mapping:
25567 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25568 + case VCMD_unset_mapping:
25569 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25571 +#ifdef CONFIG_VSERVER_HISTORY
25572 + case VCMD_dump_history:
25573 + return vc_dump_history(id);
25574 + case VCMD_read_history:
25575 + return __COMPAT(vc_read_history, id, data, compat);
25577 +#ifdef CONFIG_VSERVER_MONITOR
25578 + case VCMD_read_monitor:
25579 + return __COMPAT(vc_read_monitor, id, data, compat);
25582 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25583 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25589 +#define __VCMD(vcmd, _perm, _args, _flags) \
25590 + case VCMD_ ## vcmd: perm = _perm; \
25591 + args = _args; flags = _flags; break
25594 +#define VCA_NONE 0x00
25595 +#define VCA_VXI 0x01
25596 +#define VCA_NXI 0x02
25598 +#define VCF_NONE 0x00
25599 +#define VCF_INFO 0x01
25600 +#define VCF_ADMIN 0x02
25601 +#define VCF_ARES 0x06 /* includes admin */
25602 +#define VCF_SETUP 0x08
25604 +#define VCF_ZIDOK 0x10 /* zero id okay */
25608 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25611 + int permit = -1, state = 0;
25612 + int perm = -1, args = 0, flags = 0;
25613 + struct vx_info *vxi = NULL;
25614 + struct nx_info *nxi = NULL;
25617 + /* unpriviledged commands */
25618 + __VCMD(get_version, 0, VCA_NONE, 0);
25619 + __VCMD(get_vci, 0, VCA_NONE, 0);
25620 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25621 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25622 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25623 + __VCMD(get_space_default,0, VCA_NONE, 0);
25625 + /* info commands */
25626 + __VCMD(task_xid, 2, VCA_NONE, 0);
25627 + __VCMD(reset_hits, 2, VCA_VXI, 0);
25628 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25629 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25630 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25631 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25632 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25633 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25634 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25635 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25637 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25638 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25639 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25640 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25642 + __VCMD(task_nid, 2, VCA_NONE, 0);
25643 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25644 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25645 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25647 + __VCMD(task_tag, 2, VCA_NONE, 0);
25649 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25650 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25651 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25652 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25653 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25655 + /* lower admin commands */
25656 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25657 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25658 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25659 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25660 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25661 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25662 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25663 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25665 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25666 + __VCMD(net_create, 5, VCA_NONE, 0);
25667 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25669 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25671 + /* higher admin commands */
25672 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25673 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25674 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25676 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25677 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25678 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25679 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25681 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25682 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25683 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25684 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25686 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25687 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25688 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25689 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25690 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25691 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25692 +#ifdef CONFIG_IPV6
25693 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25694 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25696 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25697 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25698 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25699 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25700 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25702 +#ifdef CONFIG_VSERVER_DEVICE
25703 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25704 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25706 + /* debug level admin commands */
25707 +#ifdef CONFIG_VSERVER_HISTORY
25708 + __VCMD(dump_history, 9, VCA_NONE, 0);
25709 + __VCMD(read_history, 9, VCA_NONE, 0);
25711 +#ifdef CONFIG_VSERVER_MONITOR
25712 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25719 + vxdprintk(VXD_CBIT(switch, 0),
25720 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25721 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25722 + VC_VERSION(cmd), id, data, compat,
25723 + perm, args, flags);
25730 + if (!capable(CAP_CONTEXT))
25734 + /* moved here from the individual commands */
25736 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25740 + /* vcmd involves resource management */
25742 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25746 + /* various legacy exceptions */
25748 + /* will go away when spectator is a cap */
25749 + case VCMD_ctx_migrate_v0:
25750 + case VCMD_ctx_migrate:
25752 + current->xid = 1;
25758 + /* will go away when spectator is a cap */
25759 + case VCMD_net_migrate:
25761 + current->nid = 1;
25768 + /* vcmds are fine by default */
25771 + /* admin type vcmds require admin ... */
25772 + if (flags & VCF_ADMIN)
25773 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25775 + /* ... but setup type vcmds override that */
25776 + if (!permit && (flags & VCF_SETUP))
25777 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25785 + if (!id && (flags & VCF_ZIDOK))
25789 + if (args & VCA_VXI) {
25790 + vxi = lookup_vx_info(id);
25794 + if ((flags & VCF_ADMIN) &&
25795 + /* special case kill for shutdown */
25796 + (cmd != VCMD_ctx_kill) &&
25797 + /* can context be administrated? */
25798 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25804 + if (args & VCA_NXI) {
25805 + nxi = lookup_nx_info(id);
25809 + if ((flags & VCF_ADMIN) &&
25810 + /* can context be administrated? */
25811 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25818 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25821 + if ((args & VCA_NXI) && nxi)
25822 + put_nx_info(nxi);
25824 + if ((args & VCA_VXI) && vxi)
25825 + put_vx_info(vxi);
25827 + vxdprintk(VXD_CBIT(switch, 1),
25828 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25829 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25830 + VC_VERSION(cmd), ret, ret, state, permit);
25835 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25837 + return do_vserver(cmd, id, data, 0);
25840 +#ifdef CONFIG_COMPAT
25843 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25845 + return do_vserver(cmd, id, data, 1);
25848 +#endif /* CONFIG_COMPAT */
25849 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/sysctl.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sysctl.c
25850 --- linux-2.6.32.56/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25851 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/sysctl.c 2011-06-10 13:03:02.000000000 +0200
25854 + * kernel/vserver/sysctl.c
25856 + * Virtual Context Support
25858 + * Copyright (C) 2004-2007 Herbert Pötzl
25860 + * V0.01 basic structure
25864 +#include <linux/module.h>
25865 +#include <linux/ctype.h>
25866 +#include <linux/sysctl.h>
25867 +#include <linux/parser.h>
25868 +#include <asm/uaccess.h>
25872 + CTL_DEBUG_ERROR = 0,
25873 + CTL_DEBUG_SWITCH = 1,
25888 +unsigned int vx_debug_switch = 0;
25889 +unsigned int vx_debug_xid = 0;
25890 +unsigned int vx_debug_nid = 0;
25891 +unsigned int vx_debug_tag = 0;
25892 +unsigned int vx_debug_net = 0;
25893 +unsigned int vx_debug_limit = 0;
25894 +unsigned int vx_debug_cres = 0;
25895 +unsigned int vx_debug_dlim = 0;
25896 +unsigned int vx_debug_quota = 0;
25897 +unsigned int vx_debug_cvirt = 0;
25898 +unsigned int vx_debug_space = 0;
25899 +unsigned int vx_debug_misc = 0;
25902 +static struct ctl_table_header *vserver_table_header;
25903 +static ctl_table vserver_root_table[];
25906 +void vserver_register_sysctl(void)
25908 + if (!vserver_table_header) {
25909 + vserver_table_header = register_sysctl_table(vserver_root_table);
25914 +void vserver_unregister_sysctl(void)
25916 + if (vserver_table_header) {
25917 + unregister_sysctl_table(vserver_table_header);
25918 + vserver_table_header = NULL;
25923 +static int proc_dodebug(ctl_table *table, int write,
25924 + void __user *buffer, size_t *lenp, loff_t *ppos)
25926 + char tmpbuf[20], *p, c;
25927 + unsigned int value;
25928 + size_t left, len;
25930 + if ((*ppos && !write) || !*lenp) {
25938 + if (!access_ok(VERIFY_READ, buffer, left))
25940 + p = (char *)buffer;
25941 + while (left && __get_user(c, p) >= 0 && isspace(c))
25946 + if (left > sizeof(tmpbuf) - 1)
25948 + if (copy_from_user(tmpbuf, p, left))
25950 + tmpbuf[left] = '\0';
25952 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25953 + value = 10 * value + (*p - '0');
25954 + if (*p && !isspace(*p))
25956 + while (left && isspace(*p))
25958 + *(unsigned int *)table->data = value;
25960 + if (!access_ok(VERIFY_WRITE, buffer, left))
25962 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25965 + if (__copy_to_user(buffer, tmpbuf, len))
25967 + if ((left -= len) > 0) {
25968 + if (put_user('\n', (char *)buffer + len))
25982 +#define CTL_ENTRY(ctl, name) \
25984 + .ctl_name = ctl, \
25985 + .procname = #name, \
25986 + .data = &vx_ ## name, \
25987 + .maxlen = sizeof(int), \
25989 + .proc_handler = &proc_dodebug, \
25990 + .strategy = &sysctl_intvec, \
25991 + .extra1 = &zero, \
25992 + .extra2 = &zero, \
25995 +static ctl_table vserver_debug_table[] = {
25996 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25997 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25998 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25999 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
26000 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
26001 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
26002 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
26003 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
26004 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
26005 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
26006 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
26007 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
26008 + { .ctl_name = 0 }
26011 +static ctl_table vserver_root_table[] = {
26013 + .ctl_name = CTL_VSERVER,
26014 + .procname = "vserver",
26016 + .child = vserver_debug_table
26018 + { .ctl_name = 0 }
26022 +static match_table_t tokens = {
26023 + { CTL_DEBUG_SWITCH, "switch=%x" },
26024 + { CTL_DEBUG_XID, "xid=%x" },
26025 + { CTL_DEBUG_NID, "nid=%x" },
26026 + { CTL_DEBUG_TAG, "tag=%x" },
26027 + { CTL_DEBUG_NET, "net=%x" },
26028 + { CTL_DEBUG_LIMIT, "limit=%x" },
26029 + { CTL_DEBUG_CRES, "cres=%x" },
26030 + { CTL_DEBUG_DLIM, "dlim=%x" },
26031 + { CTL_DEBUG_QUOTA, "quota=%x" },
26032 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
26033 + { CTL_DEBUG_SPACE, "space=%x" },
26034 + { CTL_DEBUG_MISC, "misc=%x" },
26035 + { CTL_DEBUG_ERROR, NULL }
26038 +#define HANDLE_CASE(id, name, val) \
26039 + case CTL_DEBUG_ ## id: \
26040 + vx_debug_ ## name = val; \
26041 + printk("vs_debug_" #name "=0x%x\n", val); \
26045 +static int __init vs_debug_setup(char *str)
26050 + printk("vs_debug_setup(%s)\n", str);
26051 + while ((p = strsep(&str, ",")) != NULL) {
26052 + substring_t args[MAX_OPT_ARGS];
26053 + unsigned int value;
26058 + token = match_token(p, tokens, args);
26059 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26062 + HANDLE_CASE(SWITCH, switch, value);
26063 + HANDLE_CASE(XID, xid, value);
26064 + HANDLE_CASE(NID, nid, value);
26065 + HANDLE_CASE(TAG, tag, value);
26066 + HANDLE_CASE(NET, net, value);
26067 + HANDLE_CASE(LIMIT, limit, value);
26068 + HANDLE_CASE(CRES, cres, value);
26069 + HANDLE_CASE(DLIM, dlim, value);
26070 + HANDLE_CASE(QUOTA, quota, value);
26071 + HANDLE_CASE(CVIRT, cvirt, value);
26072 + HANDLE_CASE(SPACE, space, value);
26073 + HANDLE_CASE(MISC, misc, value);
26082 +__setup("vsdebug=", vs_debug_setup);
26086 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26087 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26088 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26089 +EXPORT_SYMBOL_GPL(vx_debug_net);
26090 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26091 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26092 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26093 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26094 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26095 +EXPORT_SYMBOL_GPL(vx_debug_space);
26096 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26098 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/tag.c linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/tag.c
26099 --- linux-2.6.32.56/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26100 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/tag.c 2011-06-10 13:03:02.000000000 +0200
26103 + * linux/kernel/vserver/tag.c
26105 + * Virtual Server: Shallow Tag Space
26107 + * Copyright (C) 2007 Herbert Pötzl
26109 + * V0.01 basic implementation
26113 +#include <linux/sched.h>
26114 +#include <linux/vserver/debug.h>
26115 +#include <linux/vs_pid.h>
26116 +#include <linux/vs_tag.h>
26118 +#include <linux/vserver/tag_cmd.h>
26121 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26126 + vxdprintk(VXD_CBIT(tag, 5),
26127 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26133 + vxdprintk(VXD_CBIT(tag, 5),
26134 + "moved task %p into [#%d]", p, tag);
26138 +/* vserver syscall commands below here */
26140 +/* taks xid and vx_info functions */
26143 +int vc_task_tag(uint32_t id)
26148 + struct task_struct *tsk;
26149 + read_lock(&tasklist_lock);
26150 + tsk = find_task_by_real_pid(id);
26151 + tag = (tsk) ? tsk->tag : -ESRCH;
26152 + read_unlock(&tasklist_lock);
26154 + tag = dx_current_tag();
26159 +int vc_tag_migrate(uint32_t tag)
26161 + return dx_migrate_task(current, tag & 0xFFFF);
26165 diff -NurpP --minimal linux-2.6.32.56/kernel/vserver/vci_config.h linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/vci_config.h
26166 --- linux-2.6.32.56/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
26167 +++ linux-2.6.32.56-vs2.3.0.36.29.9/kernel/vserver/vci_config.h 2011-06-10 13:03:02.000000000 +0200
26170 +/* interface version */
26172 +#define VCI_VERSION 0x00020305
26176 + VCI_KCBIT_NO_DYNAMIC = 0,
26178 + VCI_KCBIT_PROC_SECURE = 4,
26179 + VCI_KCBIT_HARDCPU = 5,
26180 + VCI_KCBIT_IDLELIMIT = 6,
26181 + VCI_KCBIT_IDLETIME = 7,
26183 + VCI_KCBIT_COWBL = 8,
26184 + VCI_KCBIT_FULLCOWBL = 9,
26185 + VCI_KCBIT_SPACES = 10,
26186 + VCI_KCBIT_NETV2 = 11,
26188 + VCI_KCBIT_DEBUG = 16,
26189 + VCI_KCBIT_HISTORY = 20,
26190 + VCI_KCBIT_TAGGED = 24,
26191 + VCI_KCBIT_PPTAG = 28,
26193 + VCI_KCBIT_MORE = 31,
26197 +static inline uint32_t vci_kernel_config(void)
26200 + (1 << VCI_KCBIT_NO_DYNAMIC) |
26202 + /* configured features */
26203 +#ifdef CONFIG_VSERVER_PROC_SECURE
26204 + (1 << VCI_KCBIT_PROC_SECURE) |
26206 +#ifdef CONFIG_VSERVER_HARDCPU
26207 + (1 << VCI_KCBIT_HARDCPU) |
26209 +#ifdef CONFIG_VSERVER_IDLELIMIT
26210 + (1 << VCI_KCBIT_IDLELIMIT) |
26212 +#ifdef CONFIG_VSERVER_IDLETIME
26213 + (1 << VCI_KCBIT_IDLETIME) |
26215 +#ifdef CONFIG_VSERVER_COWBL
26216 + (1 << VCI_KCBIT_COWBL) |
26217 + (1 << VCI_KCBIT_FULLCOWBL) |
26219 + (1 << VCI_KCBIT_SPACES) |
26220 + (1 << VCI_KCBIT_NETV2) |
26222 + /* debug options */
26223 +#ifdef CONFIG_VSERVER_DEBUG
26224 + (1 << VCI_KCBIT_DEBUG) |
26226 +#ifdef CONFIG_VSERVER_HISTORY
26227 + (1 << VCI_KCBIT_HISTORY) |
26230 + /* inode context tagging */
26231 +#if defined(CONFIG_TAGGING_NONE)
26232 + (0 << VCI_KCBIT_TAGGED) |
26233 +#elif defined(CONFIG_TAGGING_UID16)
26234 + (1 << VCI_KCBIT_TAGGED) |
26235 +#elif defined(CONFIG_TAGGING_GID16)
26236 + (2 << VCI_KCBIT_TAGGED) |
26237 +#elif defined(CONFIG_TAGGING_ID24)
26238 + (3 << VCI_KCBIT_TAGGED) |
26239 +#elif defined(CONFIG_TAGGING_INTERN)
26240 + (4 << VCI_KCBIT_TAGGED) |
26241 +#elif defined(CONFIG_TAGGING_RUNTIME)
26242 + (5 << VCI_KCBIT_TAGGED) |
26244 + (7 << VCI_KCBIT_TAGGED) |
26246 + (1 << VCI_KCBIT_PPTAG) |
26250 diff -NurpP --minimal linux-2.6.32.56/mm/allocpercpu.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/allocpercpu.c
26251 --- linux-2.6.32.56/mm/allocpercpu.c 2009-12-03 20:02:58.000000000 +0100
26252 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/allocpercpu.c 2011-06-10 13:03:02.000000000 +0200
26253 @@ -160,12 +160,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
26255 void __init setup_per_cpu_areas(void)
26257 - unsigned long size, i;
26258 + unsigned long size, vspc, i;
26260 unsigned long nr_possible_cpus = num_possible_cpus();
26262 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
26264 /* Copy section for each CPU (we discard the original) */
26265 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
26266 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
26267 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
26269 for_each_possible_cpu(i) {
26270 diff -NurpP --minimal linux-2.6.32.56/mm/filemap_xip.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/filemap_xip.c
26271 --- linux-2.6.32.56/mm/filemap_xip.c 2009-12-03 20:02:58.000000000 +0100
26272 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/filemap_xip.c 2011-06-10 13:03:02.000000000 +0200
26274 #include <linux/sched.h>
26275 #include <linux/seqlock.h>
26276 #include <linux/mutex.h>
26277 +#include <linux/vs_memory.h>
26278 #include <asm/tlbflush.h>
26279 #include <asm/io.h>
26281 diff -NurpP --minimal linux-2.6.32.56/mm/fremap.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/fremap.c
26282 --- linux-2.6.32.56/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
26283 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/fremap.c 2011-06-10 13:03:02.000000000 +0200
26285 #include <linux/module.h>
26286 #include <linux/syscalls.h>
26287 #include <linux/mmu_notifier.h>
26288 +#include <linux/vs_memory.h>
26290 #include <asm/mmu_context.h>
26291 #include <asm/cacheflush.h>
26292 diff -NurpP --minimal linux-2.6.32.56/mm/hugetlb.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/hugetlb.c
26293 --- linux-2.6.32.56/mm/hugetlb.c 2012-02-09 10:22:36.000000000 +0100
26294 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/hugetlb.c 2011-08-08 22:40:36.000000000 +0200
26296 #include <asm/io.h>
26298 #include <linux/hugetlb.h>
26299 +#include <linux/vs_memory.h>
26300 #include "internal.h"
26302 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26303 diff -NurpP --minimal linux-2.6.32.56/mm/memcontrol.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/memcontrol.c
26304 --- linux-2.6.32.56/mm/memcontrol.c 2012-02-09 10:22:36.000000000 +0100
26305 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/memcontrol.c 2011-06-10 13:03:02.000000000 +0200
26306 @@ -549,6 +549,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26307 struct mem_cgroup, css);
26310 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26312 + return res_counter_read_u64(&mem->res, member);
26315 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26317 + return res_counter_read_u64(&mem->memsw, member);
26320 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26322 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
26325 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26327 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
26330 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26332 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_MAPPED_FILE);
26335 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26337 struct mem_cgroup *mem = NULL;
26338 diff -NurpP --minimal linux-2.6.32.56/mm/memory.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/memory.c
26339 --- linux-2.6.32.56/mm/memory.c 2012-02-09 10:22:36.000000000 +0100
26340 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/memory.c 2011-08-08 22:40:36.000000000 +0200
26342 #include <linux/kallsyms.h>
26343 #include <linux/swapops.h>
26344 #include <linux/elf.h>
26345 +// #include <linux/vs_memory.h>
26347 #include <asm/io.h>
26348 #include <asm/pgalloc.h>
26349 @@ -647,6 +648,9 @@ static int copy_pte_range(struct mm_stru
26353 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26357 rss[1] = rss[0] = 0;
26358 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26359 @@ -2680,6 +2684,9 @@ static int do_anonymous_page(struct mm_s
26361 pte_unmap(page_table);
26363 + if (!vx_rss_avail(mm, 1))
26366 /* Check if we need to add a guard page to the stack */
26367 if (check_stack_guard_page(vma, address) < 0)
26368 return VM_FAULT_SIGBUS;
26369 @@ -2986,6 +2993,7 @@ static inline int handle_pte_fault(struc
26373 + int ret = 0, type = VXPT_UNKNOWN;
26376 if (!pte_present(entry)) {
26377 @@ -3010,9 +3018,12 @@ static inline int handle_pte_fault(struc
26378 if (unlikely(!pte_same(*pte, entry)))
26380 if (flags & FAULT_FLAG_WRITE) {
26381 - if (!pte_write(entry))
26382 - return do_wp_page(mm, vma, address,
26383 + if (!pte_write(entry)) {
26384 + ret = do_wp_page(mm, vma, address,
26385 pte, pmd, ptl, entry);
26386 + type = VXPT_WRITE;
26389 entry = pte_mkdirty(entry);
26391 entry = pte_mkyoung(entry);
26392 @@ -3030,7 +3041,10 @@ static inline int handle_pte_fault(struc
26395 pte_unmap_unlock(pte, ptl);
26399 + vx_page_fault(mm, vma, type, ret);
26404 diff -NurpP --minimal linux-2.6.32.56/mm/mlock.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/mlock.c
26405 --- linux-2.6.32.56/mm/mlock.c 2012-02-09 10:22:36.000000000 +0100
26406 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/mlock.c 2011-06-10 13:03:02.000000000 +0200
26408 #include <linux/rmap.h>
26409 #include <linux/mmzone.h>
26410 #include <linux/hugetlb.h>
26411 +#include <linux/vs_memory.h>
26413 #include "internal.h"
26415 @@ -414,7 +415,7 @@ success:
26416 nr_pages = (end - start) >> PAGE_SHIFT;
26418 nr_pages = -nr_pages;
26419 - mm->locked_vm += nr_pages;
26420 + vx_vmlocked_add(mm, nr_pages);
26423 * vm_flags is protected by the mmap_sem held in write mode.
26424 @@ -487,7 +488,7 @@ static int do_mlock(unsigned long start,
26426 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26428 - unsigned long locked;
26429 + unsigned long locked, grow;
26430 unsigned long lock_limit;
26431 int error = -ENOMEM;
26433 @@ -500,8 +501,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26434 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26435 start &= PAGE_MASK;
26437 - locked = len >> PAGE_SHIFT;
26438 - locked += current->mm->locked_vm;
26439 + grow = len >> PAGE_SHIFT;
26440 + if (!vx_vmlocked_avail(current->mm, grow))
26442 + locked = current->mm->locked_vm + grow;
26444 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26445 lock_limit >>= PAGE_SHIFT;
26446 @@ -509,6 +512,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26447 /* check against resource limits */
26448 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26449 error = do_mlock(start, len, 1);
26451 up_write(¤t->mm->mmap_sem);
26454 @@ -570,6 +574,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
26455 lock_limit >>= PAGE_SHIFT;
26458 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26460 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26461 capable(CAP_IPC_LOCK))
26462 ret = do_mlockall(flags);
26463 @@ -644,8 +650,10 @@ int account_locked_memory(struct mm_stru
26467 - mm->total_vm += pgsz;
26468 - mm->locked_vm += pgsz;
26469 + // mm->total_vm += pgsz;
26470 + vx_vmpages_add(mm, pgsz);
26471 + // mm->locked_vm += pgsz;
26472 + vx_vmlocked_add(mm, pgsz);
26476 @@ -659,8 +667,10 @@ void refund_locked_memory(struct mm_stru
26478 down_write(&mm->mmap_sem);
26480 - mm->total_vm -= pgsz;
26481 - mm->locked_vm -= pgsz;
26482 + // mm->total_vm -= pgsz;
26483 + vx_vmpages_sub(mm, pgsz);
26484 + // mm->locked_vm -= pgsz;
26485 + vx_vmlocked_sub(mm, pgsz);
26487 up_write(&mm->mmap_sem);
26489 diff -NurpP --minimal linux-2.6.32.56/mm/mmap.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/mmap.c
26490 --- linux-2.6.32.56/mm/mmap.c 2012-02-09 10:22:36.000000000 +0100
26491 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/mmap.c 2011-11-17 12:18:26.000000000 +0100
26492 @@ -1224,7 +1224,8 @@ munmap_back:
26494 perf_event_mmap(vma);
26496 - mm->total_vm += len >> PAGE_SHIFT;
26497 + // mm->total_vm += len >> PAGE_SHIFT;
26498 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26499 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26500 if (vm_flags & VM_LOCKED) {
26502 @@ -1233,7 +1234,8 @@ out:
26503 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
26505 return nr_pages; /* vma gone! */
26506 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
26507 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
26508 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
26509 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
26510 make_pages_present(addr, addr + len);
26512 @@ -1588,9 +1590,9 @@ static int acct_stack_growth(struct vm_a
26515 /* Ok, everything looks good - let it rip */
26516 - mm->total_vm += grow;
26517 + vx_vmpages_add(mm, grow);
26518 if (vma->vm_flags & VM_LOCKED)
26519 - mm->locked_vm += grow;
26520 + vx_vmlocked_add(mm, grow);
26521 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26524 @@ -1768,7 +1770,8 @@ static void remove_vma_list(struct mm_st
26526 long nrpages = vma_pages(vma);
26528 - mm->total_vm -= nrpages;
26529 + // mm->total_vm -= nrpages;
26530 + vx_vmpages_sub(mm, nrpages);
26531 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26532 vma = remove_vma(vma);
26534 @@ -1943,7 +1946,8 @@ int do_munmap(struct mm_struct *mm, unsi
26535 struct vm_area_struct *tmp = vma;
26536 while (tmp && tmp->vm_start < end) {
26537 if (tmp->vm_flags & VM_LOCKED) {
26538 - mm->locked_vm -= vma_pages(tmp);
26539 + // mm->locked_vm -= vma_pages(tmp);
26540 + vx_vmlocked_sub(mm, vma_pages(tmp));
26541 munlock_vma_pages_all(tmp);
26543 tmp = tmp->vm_next;
26544 @@ -2026,6 +2030,8 @@ unsigned long do_brk(unsigned long addr,
26545 lock_limit >>= PAGE_SHIFT;
26546 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26548 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26553 @@ -2052,7 +2058,8 @@ unsigned long do_brk(unsigned long addr,
26554 if (mm->map_count > sysctl_max_map_count)
26557 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26558 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26559 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26562 /* Can we just expand an old private anonymous mapping? */
26563 @@ -2078,10 +2085,13 @@ unsigned long do_brk(unsigned long addr,
26564 vma->vm_page_prot = vm_get_page_prot(flags);
26565 vma_link(mm, vma, prev, rb_link, rb_parent);
26567 - mm->total_vm += len >> PAGE_SHIFT;
26568 + // mm->total_vm += len >> PAGE_SHIFT;
26569 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26571 if (flags & VM_LOCKED) {
26572 if (!mlock_vma_pages_range(vma, addr, addr + len))
26573 - mm->locked_vm += (len >> PAGE_SHIFT);
26574 + // mm->locked_vm += (len >> PAGE_SHIFT);
26575 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26579 @@ -2125,6 +2135,11 @@ void exit_mmap(struct mm_struct *mm)
26580 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
26581 tlb_finish_mmu(tlb, 0, end);
26583 + set_mm_counter(mm, file_rss, 0);
26584 + set_mm_counter(mm, anon_rss, 0);
26585 + vx_vmpages_sub(mm, mm->total_vm);
26586 + vx_vmlocked_sub(mm, mm->locked_vm);
26589 * Walk the list again, actually closing and freeing it,
26590 * with preemption enabled, without holding any MM locks.
26591 @@ -2164,7 +2179,8 @@ int insert_vm_struct(struct mm_struct *
26592 if (__vma && __vma->vm_start < vma->vm_end)
26594 if ((vma->vm_flags & VM_ACCOUNT) &&
26595 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
26596 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
26597 + !vx_vmpages_avail(mm, vma_pages(vma))))
26599 vma_link(mm, vma, prev, rb_link, rb_parent);
26601 @@ -2240,6 +2256,8 @@ int may_expand_vm(struct mm_struct *mm,
26603 if (cur + npages > lim)
26605 + if (!vx_vmpages_avail(mm, npages))
26610 @@ -2321,7 +2339,7 @@ int install_special_mapping(struct mm_st
26614 - mm->total_vm += len >> PAGE_SHIFT;
26615 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26617 perf_event_mmap(vma);
26619 diff -NurpP --minimal linux-2.6.32.56/mm/mremap.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/mremap.c
26620 --- linux-2.6.32.56/mm/mremap.c 2012-02-09 10:22:36.000000000 +0100
26621 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/mremap.c 2011-06-10 13:03:02.000000000 +0200
26623 #include <linux/security.h>
26624 #include <linux/syscalls.h>
26625 #include <linux/mmu_notifier.h>
26626 +#include <linux/vs_memory.h>
26628 #include <asm/uaccess.h>
26629 #include <asm/cacheflush.h>
26630 @@ -232,7 +233,7 @@ static unsigned long move_vma(struct vm_
26631 * If this were a serious issue, we'd add a flag to do_munmap().
26633 hiwater_vm = mm->hiwater_vm;
26634 - mm->total_vm += new_len >> PAGE_SHIFT;
26635 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26636 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26638 if (do_munmap(mm, old_addr, old_len) < 0) {
26639 @@ -250,7 +251,7 @@ static unsigned long move_vma(struct vm_
26642 if (vm_flags & VM_LOCKED) {
26643 - mm->locked_vm += new_len >> PAGE_SHIFT;
26644 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26645 if (new_len > old_len)
26646 mlock_vma_pages_range(new_vma, new_addr + old_len,
26647 new_addr + new_len);
26648 @@ -468,10 +469,12 @@ unsigned long do_mremap(unsigned long ad
26649 vma_adjust(vma, vma->vm_start,
26650 addr + new_len, vma->vm_pgoff, NULL);
26652 - mm->total_vm += pages;
26653 + // mm->total_vm += pages;
26654 + vx_vmpages_add(mm, pages);
26655 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26656 if (vma->vm_flags & VM_LOCKED) {
26657 - mm->locked_vm += pages;
26658 + // mm->locked_vm += pages;
26659 + vx_vmlocked_add(mm, pages);
26660 mlock_vma_pages_range(vma, addr + old_len,
26663 diff -NurpP --minimal linux-2.6.32.56/mm/nommu.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/nommu.c
26664 --- linux-2.6.32.56/mm/nommu.c 2012-02-09 10:22:36.000000000 +0100
26665 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/nommu.c 2011-06-10 13:03:02.000000000 +0200
26666 @@ -1349,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file
26667 /* okay... we have a mapping; now we have to register it */
26668 result = vma->vm_start;
26670 - current->mm->total_vm += len >> PAGE_SHIFT;
26671 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26674 add_vma_to_mm(current->mm, vma);
26675 @@ -1609,7 +1609,7 @@ void exit_mmap(struct mm_struct *mm)
26679 - mm->total_vm = 0;
26680 + vx_vmpages_sub(mm, mm->total_vm);
26682 while ((vma = mm->mmap)) {
26683 mm->mmap = vma->vm_next;
26684 diff -NurpP --minimal linux-2.6.32.56/mm/oom_kill.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/oom_kill.c
26685 --- linux-2.6.32.56/mm/oom_kill.c 2012-02-09 10:22:36.000000000 +0100
26686 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/oom_kill.c 2011-06-10 13:03:02.000000000 +0200
26688 #include <linux/notifier.h>
26689 #include <linux/memcontrol.h>
26690 #include <linux/security.h>
26691 +#include <linux/reboot.h>
26692 +#include <linux/vs_memory.h>
26693 +#include <linux/vs_context.h>
26695 int sysctl_panic_on_oom;
26696 int sysctl_oom_kill_allocating_task;
26697 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
26698 points >>= -(oom_adj);
26702 + * add points for context badness and
26703 + * reduce badness for processes belonging to
26704 + * a different context
26707 + points += vx_badness(p, mm);
26709 + if ((vx_current_xid() > 1) &&
26710 + vx_current_xid() != vx_task_xid(p))
26714 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26715 - p->pid, p->comm, points);
26716 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26717 + task_pid_nr(p), p->xid, p->comm, points);
26721 @@ -230,6 +245,7 @@ static struct task_struct *select_bad_pr
26722 struct task_struct *p;
26723 struct task_struct *chosen = NULL;
26724 struct timespec uptime;
26725 + unsigned xid = vx_current_xid();
26728 do_posix_clock_monotonic_gettime(&uptime);
26729 @@ -242,11 +258,14 @@ static struct task_struct *select_bad_pr
26733 - /* skip the init task */
26734 - if (is_global_init(p))
26735 + /* skip the init task, global and per guest */
26736 + if (task_is_init(p))
26738 if (mem && !task_in_mem_cgroup(p, mem))
26740 + /* skip other guest and host processes if oom in guest */
26741 + if (xid && vx_task_xid(p) != xid)
26745 * This task already has access to memory reserves and is
26746 @@ -357,8 +376,8 @@ static void __oom_kill_task(struct task_
26750 - printk(KERN_ERR "Killed process %d (%s)\n",
26751 - task_pid_nr(p), p->comm);
26752 + printk(KERN_ERR "Killed process %s(%d:#%u)\n",
26753 + p->comm, task_pid_nr(p), p->xid);
26756 * We give our sacrificial lamb high priority and access to
26757 @@ -419,8 +438,8 @@ static int oom_kill_process(struct task_
26761 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26762 - message, task_pid_nr(p), p->comm, points);
26763 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26764 + message, p->comm, task_pid_nr(p), p->xid, points);
26766 /* Try to kill a child first */
26767 list_for_each_entry(c, &p->children, sibling) {
26768 @@ -521,6 +540,8 @@ void clear_zonelist_oom(struct zonelist
26769 spin_unlock(&zone_scan_lock);
26772 +long vs_oom_action(unsigned int);
26775 * Must be called with tasklist_lock held for read.
26777 @@ -546,7 +567,11 @@ retry:
26778 /* Found nothing?!?! Either we hang forever, or we panic. */
26780 read_unlock(&tasklist_lock);
26781 - panic("Out of memory and no killable processes...\n");
26782 + /* avoid panic for guest OOM */
26783 + if (current->xid)
26784 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
26786 + panic("Out of memory and no killable processes...\n");
26789 if (oom_kill_process(p, gfp_mask, order, points, NULL,
26790 diff -NurpP --minimal linux-2.6.32.56/mm/page_alloc.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/page_alloc.c
26791 --- linux-2.6.32.56/mm/page_alloc.c 2012-02-09 10:22:36.000000000 +0100
26792 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/page_alloc.c 2011-08-08 22:40:36.000000000 +0200
26794 #include <linux/page_cgroup.h>
26795 #include <linux/debugobjects.h>
26796 #include <linux/kmemleak.h>
26797 +#include <linux/vs_base.h>
26798 +#include <linux/vs_limit.h>
26799 #include <trace/events/kmem.h>
26801 #include <asm/tlbflush.h>
26802 @@ -2144,6 +2146,9 @@ void si_meminfo(struct sysinfo *val)
26803 val->totalhigh = totalhigh_pages;
26804 val->freehigh = nr_free_highpages();
26805 val->mem_unit = PAGE_SIZE;
26807 + if (vx_flags(VXF_VIRT_MEM, 0))
26808 + vx_vsi_meminfo(val);
26811 EXPORT_SYMBOL(si_meminfo);
26812 @@ -2164,6 +2169,9 @@ void si_meminfo_node(struct sysinfo *val
26815 val->mem_unit = PAGE_SIZE;
26817 + if (vx_flags(VXF_VIRT_MEM, 0))
26818 + vx_vsi_meminfo(val);
26822 diff -NurpP --minimal linux-2.6.32.56/mm/rmap.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/rmap.c
26823 --- linux-2.6.32.56/mm/rmap.c 2009-12-03 20:02:58.000000000 +0100
26824 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/rmap.c 2011-06-10 13:03:02.000000000 +0200
26826 #include <linux/memcontrol.h>
26827 #include <linux/mmu_notifier.h>
26828 #include <linux/migrate.h>
26829 +#include <linux/vs_memory.h>
26831 #include <asm/tlbflush.h>
26833 diff -NurpP --minimal linux-2.6.32.56/mm/shmem.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/shmem.c
26834 --- linux-2.6.32.56/mm/shmem.c 2012-02-09 10:22:36.000000000 +0100
26835 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/shmem.c 2011-06-10 13:03:02.000000000 +0200
26836 @@ -1781,7 +1781,7 @@ static int shmem_statfs(struct dentry *d
26838 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26840 - buf->f_type = TMPFS_MAGIC;
26841 + buf->f_type = TMPFS_SUPER_MAGIC;
26842 buf->f_bsize = PAGE_CACHE_SIZE;
26843 buf->f_namelen = NAME_MAX;
26844 spin_lock(&sbinfo->stat_lock);
26845 @@ -2346,7 +2346,7 @@ int shmem_fill_super(struct super_block
26846 sb->s_maxbytes = SHMEM_MAX_BYTES;
26847 sb->s_blocksize = PAGE_CACHE_SIZE;
26848 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26849 - sb->s_magic = TMPFS_MAGIC;
26850 + sb->s_magic = TMPFS_SUPER_MAGIC;
26851 sb->s_op = &shmem_ops;
26852 sb->s_time_gran = 1;
26853 #ifdef CONFIG_TMPFS_POSIX_ACL
26854 diff -NurpP --minimal linux-2.6.32.56/mm/slab.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/slab.c
26855 --- linux-2.6.32.56/mm/slab.c 2012-02-09 10:22:36.000000000 +0100
26856 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/slab.c 2011-06-10 13:03:02.000000000 +0200
26857 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
26858 #define STATS_INC_FREEMISS(x) do { } while (0)
26861 +#include "slab_vs.h"
26866 @@ -3251,6 +3253,7 @@ retry:
26868 obj = slab_get_obj(cachep, slabp, nodeid);
26869 check_slabp(cachep, slabp);
26870 + vx_slab_alloc(cachep, flags);
26871 l3->free_objects--;
26872 /* move slabp to correct slabp list: */
26873 list_del(&slabp->list);
26874 @@ -3327,6 +3330,7 @@ __cache_alloc_node(struct kmem_cache *ca
26875 /* ___cache_alloc_node can fall back to other nodes */
26876 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26878 + vx_slab_alloc(cachep, flags);
26879 local_irq_restore(save_flags);
26880 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26881 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26882 @@ -3513,6 +3517,7 @@ static inline void __cache_free(struct k
26884 kmemleak_free_recursive(objp, cachep->flags);
26885 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26886 + vx_slab_free(cachep);
26888 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26890 diff -NurpP --minimal linux-2.6.32.56/mm/slab_vs.h linux-2.6.32.56-vs2.3.0.36.29.9/mm/slab_vs.h
26891 --- linux-2.6.32.56/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26892 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/slab_vs.h 2011-06-10 13:03:02.000000000 +0200
26895 +#include <linux/vserver/context.h>
26897 +#include <linux/vs_context.h>
26900 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26902 + int what = gfp_zone(cachep->gfpflags);
26903 + struct vx_info *vxi = current_vx_info();
26908 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26912 +void vx_slab_free(struct kmem_cache *cachep)
26914 + int what = gfp_zone(cachep->gfpflags);
26915 + struct vx_info *vxi = current_vx_info();
26920 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26923 diff -NurpP --minimal linux-2.6.32.56/mm/swapfile.c linux-2.6.32.56-vs2.3.0.36.29.9/mm/swapfile.c
26924 --- linux-2.6.32.56/mm/swapfile.c 2012-02-09 10:22:36.000000000 +0100
26925 +++ linux-2.6.32.56-vs2.3.0.36.29.9/mm/swapfile.c 2011-06-10 13:03:02.000000000 +0200
26927 #include <asm/tlbflush.h>
26928 #include <linux/swapops.h>
26929 #include <linux/page_cgroup.h>
26930 +#include <linux/vs_base.h>
26931 +#include <linux/vs_memory.h>
26933 static DEFINE_SPINLOCK(swap_lock);
26934 static unsigned int nr_swapfiles;
26935 @@ -1682,6 +1684,8 @@ static void *swap_next(struct seq_file *
26936 if (v == SEQ_START_TOKEN)
26939 + if (vx_flags(VXF_VIRT_MEM, 0))
26944 @@ -1709,6 +1713,16 @@ static int swap_show(struct seq_file *sw
26946 if (ptr == SEQ_START_TOKEN) {
26947 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26948 + if (vx_flags(VXF_VIRT_MEM, 0)) {
26949 + struct sysinfo si;
26951 + vx_vsi_swapinfo(&si);
26952 + if (si.totalswap < (1 << 10))
26954 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26955 + "hdv0", "partition", si.totalswap >> 10,
26956 + (si.totalswap - si.freeswap) >> 10, -1);
26961 @@ -2066,6 +2080,8 @@ void si_swapinfo(struct sysinfo *val)
26962 val->freeswap = nr_swap_pages + nr_to_be_unused;
26963 val->totalswap = total_swap_pages + nr_to_be_unused;
26964 spin_unlock(&swap_lock);
26965 + if (vx_flags(VXF_VIRT_MEM, 0))
26966 + vx_vsi_swapinfo(val);
26970 diff -NurpP --minimal linux-2.6.32.56/net/core/dev.c linux-2.6.32.56-vs2.3.0.36.29.9/net/core/dev.c
26971 --- linux-2.6.32.56/net/core/dev.c 2012-02-09 10:22:37.000000000 +0100
26972 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/core/dev.c 2012-01-10 09:18:12.000000000 +0100
26973 @@ -126,6 +126,7 @@
26974 #include <linux/in.h>
26975 #include <linux/jhash.h>
26976 #include <linux/random.h>
26977 +#include <linux/vs_inet.h>
26978 #include <trace/events/napi.h>
26980 #include "net-sysfs.h"
26981 @@ -591,7 +592,8 @@ struct net_device *__dev_get_by_name(str
26982 hlist_for_each(p, dev_name_hash(net, name)) {
26983 struct net_device *dev
26984 = hlist_entry(p, struct net_device, name_hlist);
26985 - if (!strncmp(dev->name, name, IFNAMSIZ))
26986 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26987 + nx_dev_visible(current_nx_info(), dev))
26991 @@ -642,7 +644,8 @@ struct net_device *__dev_get_by_index(st
26992 hlist_for_each(p, dev_index_hash(net, ifindex)) {
26993 struct net_device *dev
26994 = hlist_entry(p, struct net_device, index_hlist);
26995 - if (dev->ifindex == ifindex)
26996 + if ((dev->ifindex == ifindex) &&
26997 + nx_dev_visible(current_nx_info(), dev))
27001 @@ -695,10 +698,12 @@ struct net_device *dev_getbyhwaddr(struc
27005 - for_each_netdev(net, dev)
27006 + for_each_netdev(net, dev) {
27007 if (dev->type == type &&
27008 - !memcmp(dev->dev_addr, ha, dev->addr_len))
27009 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
27010 + nx_dev_visible(current_nx_info(), dev))
27016 @@ -709,9 +714,11 @@ struct net_device *__dev_getfirstbyhwtyp
27017 struct net_device *dev;
27020 - for_each_netdev(net, dev)
27021 - if (dev->type == type)
27022 + for_each_netdev(net, dev) {
27023 + if ((dev->type == type) &&
27024 + nx_dev_visible(current_nx_info(), dev))
27030 @@ -830,6 +837,8 @@ static int __dev_alloc_name(struct net *
27032 if (i < 0 || i >= max_netdevices)
27034 + if (!nx_dev_visible(current_nx_info(), d))
27037 /* avoid cases where sscanf is not exact inverse of printf */
27038 snprintf(buf, IFNAMSIZ, name, i);
27039 @@ -3003,6 +3012,8 @@ static int dev_ifconf(struct net *net, c
27042 for_each_netdev(net, dev) {
27043 + if (!nx_dev_visible(current_nx_info(), dev))
27045 for (i = 0; i < NPROTO; i++) {
27046 if (gifconf_list[i]) {
27048 @@ -3071,6 +3082,9 @@ static void dev_seq_printf_stats(struct
27050 const struct net_device_stats *stats = dev_get_stats(dev);
27052 + if (!nx_dev_visible(current_nx_info(), dev))
27055 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
27056 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
27057 dev->name, stats->rx_bytes, stats->rx_packets,
27058 @@ -5336,7 +5350,6 @@ int dev_change_net_namespace(struct net_
27059 if (dev->dev.parent)
27063 /* Ensure the device has been registrered */
27065 if (dev->reg_state != NETREG_REGISTERED)
27066 diff -NurpP --minimal linux-2.6.32.56/net/core/rtnetlink.c linux-2.6.32.56-vs2.3.0.36.29.9/net/core/rtnetlink.c
27067 --- linux-2.6.32.56/net/core/rtnetlink.c 2012-02-09 10:22:37.000000000 +0100
27068 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/core/rtnetlink.c 2011-06-10 13:03:02.000000000 +0200
27069 @@ -688,6 +688,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
27072 for_each_netdev(net, dev) {
27073 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
27077 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
27078 @@ -1222,6 +1224,9 @@ void rtmsg_ifinfo(int type, struct net_d
27079 struct sk_buff *skb;
27080 int err = -ENOBUFS;
27082 + if (!nx_dev_visible(current_nx_info(), dev))
27085 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
27088 diff -NurpP --minimal linux-2.6.32.56/net/core/sock.c linux-2.6.32.56-vs2.3.0.36.29.9/net/core/sock.c
27089 --- linux-2.6.32.56/net/core/sock.c 2012-02-09 10:22:37.000000000 +0100
27090 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/core/sock.c 2011-06-10 13:03:02.000000000 +0200
27091 @@ -125,6 +125,10 @@
27092 #include <linux/ipsec.h>
27094 #include <linux/filter.h>
27095 +#include <linux/vs_socket.h>
27096 +#include <linux/vs_limit.h>
27097 +#include <linux/vs_context.h>
27098 +#include <linux/vs_network.h>
27101 #include <net/tcp.h>
27102 @@ -984,6 +988,8 @@ static struct sock *sk_prot_alloc(struct
27103 if (!try_module_get(prot->owner))
27106 + sock_vx_init(sk);
27107 + sock_nx_init(sk);
27111 @@ -1063,6 +1069,11 @@ static void __sk_free(struct sock *sk)
27112 __func__, atomic_read(&sk->sk_omem_alloc));
27114 put_net(sock_net(sk));
27116 + clr_vx_info(&sk->sk_vx_info);
27118 + clr_nx_info(&sk->sk_nx_info);
27120 sk_prot_free(sk->sk_prot_creator, sk);
27123 @@ -1110,6 +1121,8 @@ struct sock *sk_clone(const struct sock
27126 get_net(sock_net(newsk));
27127 + sock_vx_init(newsk);
27128 + sock_nx_init(newsk);
27129 sk_node_init(&newsk->sk_node);
27130 sock_lock_init(newsk);
27131 bh_lock_sock(newsk);
27132 @@ -1164,6 +1177,12 @@ struct sock *sk_clone(const struct sock
27134 atomic_set(&newsk->sk_refcnt, 2);
27136 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
27137 + newsk->sk_xid = sk->sk_xid;
27138 + vx_sock_inc(newsk);
27139 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
27140 + newsk->sk_nid = sk->sk_nid;
27143 * Increment the counter in the same struct proto as the master
27144 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
27145 @@ -1886,6 +1905,12 @@ void sock_init_data(struct socket *sock,
27147 sk->sk_stamp = ktime_set(-1L, 0);
27149 + set_vx_info(&sk->sk_vx_info, current_vx_info());
27150 + sk->sk_xid = vx_current_xid();
27152 + set_nx_info(&sk->sk_nx_info, current_nx_info());
27153 + sk->sk_nid = nx_current_nid();
27156 * Before updating sk_refcnt, we must commit prior changes to memory
27157 * (Documentation/RCU/rculist_nulls.txt for details)
27158 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/af_inet.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/af_inet.c
27159 --- linux-2.6.32.56/net/ipv4/af_inet.c 2012-02-09 10:22:37.000000000 +0100
27160 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/af_inet.c 2011-08-08 22:42:21.000000000 +0200
27161 @@ -115,6 +115,7 @@
27162 #ifdef CONFIG_IP_MROUTE
27163 #include <linux/mroute.h>
27165 +#include <linux/vs_limit.h>
27168 /* The inetsw table contains everything that inet_create needs to
27169 @@ -325,9 +326,12 @@ lookup_protocol:
27173 + if ((protocol == IPPROTO_ICMP) &&
27174 + nx_capable(answer->capability, NXC_RAW_ICMP))
27176 if (answer->capability > 0 && !capable(answer->capability))
27177 goto out_rcu_unlock;
27180 err = -EAFNOSUPPORT;
27181 if (!inet_netns_ok(net, protocol))
27182 goto out_rcu_unlock;
27183 @@ -447,6 +451,7 @@ int inet_bind(struct socket *sock, struc
27184 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
27185 struct sock *sk = sock->sk;
27186 struct inet_sock *inet = inet_sk(sk);
27187 + struct nx_v4_sock_addr nsa;
27188 unsigned short snum;
27191 @@ -463,7 +468,11 @@ int inet_bind(struct socket *sock, struc
27192 if (addr->sin_family != AF_INET)
27195 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27196 + err = v4_map_sock_addr(inet, addr, &nsa);
27200 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27202 /* Not specified by any standard per-se, however it breaks too
27203 * many applications when removed. It is unfortunate since
27204 @@ -475,7 +484,7 @@ int inet_bind(struct socket *sock, struc
27205 err = -EADDRNOTAVAIL;
27206 if (!sysctl_ip_nonlocal_bind &&
27207 !(inet->freebind || inet->transparent) &&
27208 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
27209 + nsa.saddr != htonl(INADDR_ANY) &&
27210 chk_addr_ret != RTN_LOCAL &&
27211 chk_addr_ret != RTN_MULTICAST &&
27212 chk_addr_ret != RTN_BROADCAST)
27213 @@ -500,7 +509,7 @@ int inet_bind(struct socket *sock, struc
27214 if (sk->sk_state != TCP_CLOSE || inet->num)
27215 goto out_release_sock;
27217 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27218 + v4_set_sock_addr(inet, &nsa);
27219 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27220 inet->saddr = 0; /* Use device */
27222 @@ -697,11 +706,13 @@ int inet_getname(struct socket *sock, st
27225 sin->sin_port = inet->dport;
27226 - sin->sin_addr.s_addr = inet->daddr;
27227 + sin->sin_addr.s_addr =
27228 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27230 __be32 addr = inet->rcv_saddr;
27232 addr = inet->saddr;
27233 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
27234 sin->sin_port = inet->sport;
27235 sin->sin_addr.s_addr = addr;
27237 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/devinet.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/devinet.c
27238 --- linux-2.6.32.56/net/ipv4/devinet.c 2012-02-09 10:22:37.000000000 +0100
27239 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/devinet.c 2011-06-10 13:03:02.000000000 +0200
27240 @@ -413,6 +413,7 @@ struct in_device *inetdev_by_index(struc
27245 /* Called only from RTNL semaphored context. No locks. */
27247 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
27248 @@ -653,6 +654,8 @@ int devinet_ioctl(struct net *net, unsig
27251 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
27252 + struct nx_info *nxi = current_nx_info();
27254 if (tryaddrmatch) {
27255 /* Matthias Andree */
27256 /* compare label and address (4.4BSD style) */
27257 @@ -661,6 +664,8 @@ int devinet_ioctl(struct net *net, unsig
27258 This is checked above. */
27259 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27260 ifap = &ifa->ifa_next) {
27261 + if (!nx_v4_ifa_visible(nxi, ifa))
27263 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
27264 sin_orig.sin_addr.s_addr ==
27265 ifa->ifa_address) {
27266 @@ -673,9 +678,12 @@ int devinet_ioctl(struct net *net, unsig
27267 comparing just the label */
27269 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27270 - ifap = &ifa->ifa_next)
27271 + ifap = &ifa->ifa_next) {
27272 + if (!nx_v4_ifa_visible(nxi, ifa))
27274 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27280 @@ -826,6 +834,8 @@ static int inet_gifconf(struct net_devic
27283 for (; ifa; ifa = ifa->ifa_next) {
27284 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27287 done += sizeof(ifr);
27289 @@ -1185,6 +1195,7 @@ static int inet_dump_ifaddr(struct sk_bu
27290 struct net_device *dev;
27291 struct in_device *in_dev;
27292 struct in_ifaddr *ifa;
27293 + struct sock *sk = skb->sk;
27294 int s_ip_idx, s_idx = cb->args[0];
27296 s_ip_idx = ip_idx = cb->args[1];
27297 @@ -1199,6 +1210,8 @@ static int inet_dump_ifaddr(struct sk_bu
27299 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27300 ifa = ifa->ifa_next, ip_idx++) {
27301 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27303 if (ip_idx < s_ip_idx)
27305 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
27306 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/fib_hash.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/fib_hash.c
27307 --- linux-2.6.32.56/net/ipv4/fib_hash.c 2009-09-10 15:26:29.000000000 +0200
27308 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/fib_hash.c 2011-06-10 13:03:02.000000000 +0200
27309 @@ -1021,7 +1021,7 @@ static int fib_seq_show(struct seq_file
27310 prefix = f->fn_key;
27311 mask = FZ_MASK(iter->zone);
27312 flags = fib_flag_trans(fa->fa_type, mask, fi);
27314 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27316 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27317 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27318 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/inet_connection_sock.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/inet_connection_sock.c
27319 --- linux-2.6.32.56/net/ipv4/inet_connection_sock.c 2009-12-03 20:02:59.000000000 +0100
27320 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/inet_connection_sock.c 2011-06-10 13:03:02.000000000 +0200
27321 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
27323 EXPORT_SYMBOL(inet_get_local_port_range);
27325 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27327 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
27328 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
27330 + if (inet_v6_ipv6only(sk2))
27333 + if (sk1_rcv_saddr &&
27335 + sk1_rcv_saddr == sk2_rcv_saddr)
27338 + if (sk1_rcv_saddr &&
27339 + !sk2_rcv_saddr &&
27340 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27343 + if (sk2_rcv_saddr &&
27344 + !sk1_rcv_saddr &&
27345 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27348 + if (!sk1_rcv_saddr &&
27349 + !sk2_rcv_saddr &&
27350 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27356 int inet_csk_bind_conflict(const struct sock *sk,
27357 const struct inet_bind_bucket *tb)
27359 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27361 struct hlist_node *node;
27362 int reuse = sk->sk_reuse;
27363 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
27364 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27365 if (!reuse || !sk2->sk_reuse ||
27366 sk2->sk_state == TCP_LISTEN) {
27367 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27368 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27369 - sk2_rcv_saddr == sk_rcv_saddr)
27370 + if (ipv4_rcv_saddr_equal(sk, sk2))
27374 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/inet_diag.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/inet_diag.c
27375 --- linux-2.6.32.56/net/ipv4/inet_diag.c 2012-02-09 10:22:37.000000000 +0100
27376 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/inet_diag.c 2011-08-08 22:40:36.000000000 +0200
27378 #include <linux/stddef.h>
27380 #include <linux/inet_diag.h>
27381 +#include <linux/vs_network.h>
27382 +#include <linux/vs_inet.h>
27384 static const struct inet_diag_handler **inet_diag_table;
27386 @@ -118,8 +120,8 @@ static int inet_csk_diag_fill(struct soc
27388 r->id.idiag_sport = inet->sport;
27389 r->id.idiag_dport = inet->dport;
27390 - r->id.idiag_src[0] = inet->rcv_saddr;
27391 - r->id.idiag_dst[0] = inet->daddr;
27392 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
27393 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27395 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27396 if (r->idiag_family == AF_INET6) {
27397 @@ -204,8 +206,8 @@ static int inet_twsk_diag_fill(struct in
27398 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27399 r->id.idiag_sport = tw->tw_sport;
27400 r->id.idiag_dport = tw->tw_dport;
27401 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
27402 - r->id.idiag_dst[0] = tw->tw_daddr;
27403 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27404 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27405 r->idiag_state = tw->tw_substate;
27406 r->idiag_timer = 3;
27407 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
27408 @@ -262,6 +264,7 @@ static int inet_diag_get_exact(struct sk
27411 if (req->idiag_family == AF_INET) {
27412 + /* TODO: lback */
27413 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27414 req->id.idiag_dport, req->id.idiag_src[0],
27415 req->id.idiag_sport, req->id.idiag_if);
27416 @@ -504,6 +507,7 @@ static int inet_csk_diag_dump(struct soc
27420 + /* TODO: lback */
27421 entry.saddr = &inet->rcv_saddr;
27422 entry.daddr = &inet->daddr;
27424 @@ -542,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
27428 + /* TODO: lback */
27429 entry.saddr = &tw->tw_rcv_saddr;
27430 entry.daddr = &tw->tw_daddr;
27432 @@ -588,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
27434 r->id.idiag_sport = inet->sport;
27435 r->id.idiag_dport = ireq->rmt_port;
27436 - r->id.idiag_src[0] = ireq->loc_addr;
27437 - r->id.idiag_dst[0] = ireq->rmt_addr;
27438 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27439 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27440 r->idiag_expires = jiffies_to_msecs(tmo);
27441 r->idiag_rqueue = 0;
27442 r->idiag_wqueue = 0;
27443 @@ -660,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
27447 + /* TODO: lback */
27449 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27450 (entry.family == AF_INET6) ?
27451 @@ -730,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
27452 sk_nulls_for_each(sk, node, &ilb->head) {
27453 struct inet_sock *inet = inet_sk(sk);
27455 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27460 @@ -796,6 +804,8 @@ skip_listen_ht:
27461 sk_nulls_for_each(sk, node, &head->chain) {
27462 struct inet_sock *inet = inet_sk(sk);
27464 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27468 if (!(r->idiag_states & (1 << sk->sk_state)))
27469 @@ -820,6 +830,8 @@ next_normal:
27470 inet_twsk_for_each(tw, node,
27473 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27477 if (r->id.idiag_sport != tw->tw_sport &&
27478 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/inet_hashtables.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/inet_hashtables.c
27479 --- linux-2.6.32.56/net/ipv4/inet_hashtables.c 2012-02-09 10:22:37.000000000 +0100
27480 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/inet_hashtables.c 2011-11-17 12:19:00.000000000 +0100
27482 #include <net/inet_connection_sock.h>
27483 #include <net/inet_hashtables.h>
27484 #include <net/secure_seq.h>
27485 +#include <net/route.h>
27486 #include <net/ip.h>
27489 @@ -135,6 +136,11 @@ static inline int compute_score(struct s
27490 if (rcv_saddr != daddr)
27494 + /* block non nx_info ips */
27495 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27496 + daddr, NXA_MASK_BIND))
27499 if (sk->sk_bound_dev_if) {
27500 if (sk->sk_bound_dev_if != dif)
27501 @@ -152,7 +158,6 @@ static inline int compute_score(struct s
27502 * wildcarded during the search since they can never be otherwise.
27506 struct sock *__inet_lookup_listener(struct net *net,
27507 struct inet_hashinfo *hashinfo,
27508 const __be32 daddr, const unsigned short hnum,
27509 @@ -175,6 +180,7 @@ begin:
27515 * if the nulls value we got at the end of this lookup is
27516 * not the expected one, we must restart lookup.
27517 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/netfilter/nf_nat_helper.c
27518 --- linux-2.6.32.56/net/ipv4/netfilter/nf_nat_helper.c 2009-12-03 20:02:59.000000000 +0100
27519 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/netfilter/nf_nat_helper.c 2011-06-10 13:03:02.000000000 +0200
27521 #include <net/route.h>
27523 #include <linux/netfilter_ipv4.h>
27524 +#include <net/route.h>
27525 #include <net/netfilter/nf_conntrack.h>
27526 #include <net/netfilter/nf_conntrack_helper.h>
27527 #include <net/netfilter/nf_conntrack_ecache.h>
27528 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/netfilter.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/netfilter.c
27529 --- linux-2.6.32.56/net/ipv4/netfilter.c 2009-09-10 15:26:29.000000000 +0200
27530 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/netfilter.c 2011-06-10 13:03:02.000000000 +0200
27532 #include <linux/netfilter_ipv4.h>
27533 #include <linux/ip.h>
27534 #include <linux/skbuff.h>
27535 -#include <net/route.h>
27536 +// #include <net/route.h>
27537 #include <net/xfrm.h>
27538 #include <net/ip.h>
27539 #include <net/netfilter/nf_queue.h>
27540 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/raw.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/raw.c
27541 --- linux-2.6.32.56/net/ipv4/raw.c 2009-12-03 20:02:59.000000000 +0100
27542 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/raw.c 2011-06-10 13:03:02.000000000 +0200
27543 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27545 if (net_eq(sock_net(sk), net) && inet->num == num &&
27546 !(inet->daddr && inet->daddr != raddr) &&
27547 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27548 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27549 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27550 goto found; /* gotcha */
27552 @@ -383,6 +383,12 @@ static int raw_send_hdrinc(struct sock *
27553 icmp_out_count(net, ((struct icmphdr *)
27554 skb_transport_header(skb))->type);
27557 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27558 + sk->sk_nx_info &&
27559 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27562 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27565 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
27568 security_sk_classify_flow(sk, &fl);
27569 + if (sk->sk_nx_info) {
27570 + err = ip_v4_find_src(sock_net(sk),
27571 + sk->sk_nx_info, &rt, &fl);
27576 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27579 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
27581 struct inet_sock *inet = inet_sk(sk);
27582 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27583 + struct nx_v4_sock_addr nsa = { 0 };
27587 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27589 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27590 + v4_map_sock_addr(inet, addr, &nsa);
27591 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27592 ret = -EADDRNOTAVAIL;
27593 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27594 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27595 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27597 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27598 + v4_set_sock_addr(inet, &nsa);
27599 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27600 inet->saddr = 0; /* Use device */
27602 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
27603 /* Copy the address. */
27605 sin->sin_family = AF_INET;
27606 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27607 + sin->sin_addr.s_addr =
27608 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27610 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27612 @@ -875,7 +891,8 @@ static struct sock *raw_get_first(struct
27613 struct hlist_node *node;
27615 sk_for_each(sk, node, &state->h->ht[state->bucket])
27616 - if (sock_net(sk) == seq_file_net(seq))
27617 + if ((sock_net(sk) == seq_file_net(seq)) &&
27618 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27622 @@ -891,7 +908,8 @@ static struct sock *raw_get_next(struct
27626 - } while (sk && sock_net(sk) != seq_file_net(seq));
27627 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27628 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27630 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27631 sk = sk_head(&state->h->ht[state->bucket]);
27632 @@ -950,7 +968,10 @@ static void raw_sock_seq_show(struct seq
27634 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27635 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27636 - i, src, srcp, dest, destp, sp->sk_state,
27638 + nx_map_sock_lback(current_nx_info(), src), srcp,
27639 + nx_map_sock_lback(current_nx_info(), dest), destp,
27641 sk_wmem_alloc_get(sp),
27642 sk_rmem_alloc_get(sp),
27643 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27644 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/tcp.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/tcp.c
27645 --- linux-2.6.32.56/net/ipv4/tcp.c 2012-02-09 10:22:37.000000000 +0100
27646 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/tcp.c 2011-06-10 13:03:02.000000000 +0200
27647 @@ -264,6 +264,7 @@
27648 #include <linux/cache.h>
27649 #include <linux/err.h>
27650 #include <linux/crypto.h>
27651 +#include <linux/in.h>
27653 #include <net/icmp.h>
27654 #include <net/tcp.h>
27655 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/tcp_ipv4.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/tcp_ipv4.c
27656 --- linux-2.6.32.56/net/ipv4/tcp_ipv4.c 2012-02-09 10:22:37.000000000 +0100
27657 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/tcp_ipv4.c 2011-11-17 12:18:26.000000000 +0100
27658 @@ -1926,6 +1926,12 @@ static void *listening_get_next(struct s
27659 req = req->dl_next;
27662 + vxdprintk(VXD_CBIT(net, 6),
27663 + "sk,req: %p [#%d] (from %d)", req->sk,
27664 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27666 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27668 if (req->rsk_ops->family == st->family) {
27671 @@ -1950,6 +1956,10 @@ get_req:
27674 sk_nulls_for_each_from(sk, node) {
27675 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27676 + sk, sk->sk_nid, nx_current_nid());
27677 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27679 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27682 @@ -2013,6 +2023,11 @@ static void *established_get_first(struc
27684 spin_lock_bh(lock);
27685 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27686 + vxdprintk(VXD_CBIT(net, 6),
27687 + "sk,egf: %p [#%d] (from %d)",
27688 + sk, sk->sk_nid, nx_current_nid());
27689 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27691 if (sk->sk_family != st->family ||
27692 !net_eq(sock_net(sk), net)) {
27694 @@ -2023,6 +2038,11 @@ static void *established_get_first(struc
27695 st->state = TCP_SEQ_STATE_TIME_WAIT;
27696 inet_twsk_for_each(tw, node,
27697 &tcp_hashinfo.ehash[st->bucket].twchain) {
27698 + vxdprintk(VXD_CBIT(net, 6),
27699 + "tw: %p [#%d] (from %d)",
27700 + tw, tw->tw_nid, nx_current_nid());
27701 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27703 if (tw->tw_family != st->family ||
27704 !net_eq(twsk_net(tw), net)) {
27706 @@ -2051,7 +2071,9 @@ static void *established_get_next(struct
27710 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27711 + while (tw && (tw->tw_family != st->family ||
27712 + !net_eq(twsk_net(tw), net) ||
27713 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27717 @@ -2074,6 +2096,11 @@ get_tw:
27718 sk = sk_nulls_next(sk);
27720 sk_nulls_for_each_from(sk, node) {
27721 + vxdprintk(VXD_CBIT(net, 6),
27722 + "sk,egn: %p [#%d] (from %d)",
27723 + sk, sk->sk_nid, nx_current_nid());
27724 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27726 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27729 @@ -2225,9 +2252,9 @@ static void get_openreq4(struct sock *sk
27730 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27731 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27734 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27735 ntohs(inet_sk(sk)->sport),
27737 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27738 ntohs(ireq->rmt_port),
27740 0, 0, /* could print option size, but that is af dependent. */
27741 @@ -2270,7 +2297,10 @@ static void get_tcp4_sock(struct sock *s
27743 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27744 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27745 - i, src, srcp, dest, destp, sk->sk_state,
27747 + nx_map_sock_lback(current_nx_info(), src), srcp,
27748 + nx_map_sock_lback(current_nx_info(), dest), destp,
27750 tp->write_seq - tp->snd_una,
27751 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
27752 (tp->rcv_nxt - tp->copied_seq),
27753 @@ -2306,7 +2336,10 @@ static void get_timewait4_sock(struct in
27755 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27756 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27757 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27759 + nx_map_sock_lback(current_nx_info(), src), srcp,
27760 + nx_map_sock_lback(current_nx_info(), dest), destp,
27761 + tw->tw_substate, 0, 0,
27762 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27763 atomic_read(&tw->tw_refcnt), tw, len);
27765 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/tcp_minisocks.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/tcp_minisocks.c
27766 --- linux-2.6.32.56/net/ipv4/tcp_minisocks.c 2009-12-03 20:03:00.000000000 +0100
27767 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/tcp_minisocks.c 2011-06-10 13:03:02.000000000 +0200
27769 #include <net/inet_common.h>
27770 #include <net/xfrm.h>
27772 +#include <linux/vs_limit.h>
27773 +#include <linux/vs_socket.h>
27774 +#include <linux/vs_context.h>
27776 #ifdef CONFIG_SYSCTL
27777 #define SYNC_INIT 0 /* let the user enable it */
27779 @@ -294,6 +298,11 @@ void tcp_time_wait(struct sock *sk, int
27780 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27781 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27783 + tw->tw_xid = sk->sk_xid;
27784 + tw->tw_vx_info = NULL;
27785 + tw->tw_nid = sk->sk_nid;
27786 + tw->tw_nx_info = NULL;
27788 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27789 if (tw->tw_family == PF_INET6) {
27790 struct ipv6_pinfo *np = inet6_sk(sk);
27791 diff -NurpP --minimal linux-2.6.32.56/net/ipv4/udp.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/udp.c
27792 --- linux-2.6.32.56/net/ipv4/udp.c 2012-02-09 10:22:37.000000000 +0100
27793 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv4/udp.c 2011-08-08 22:40:36.000000000 +0200
27794 @@ -224,14 +224,7 @@ fail:
27796 EXPORT_SYMBOL(udp_lib_get_port);
27798 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27800 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27802 - return (!ipv6_only_sock(sk2) &&
27803 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27804 - inet1->rcv_saddr == inet2->rcv_saddr));
27806 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27808 int udp_v4_get_port(struct sock *sk, unsigned short snum)
27810 @@ -253,6 +246,11 @@ static inline int compute_score(struct s
27811 if (inet->rcv_saddr != daddr)
27815 + /* block non nx_info ips */
27816 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27817 + daddr, NXA_MASK_BIND))
27821 if (inet->daddr != saddr)
27822 @@ -273,6 +271,7 @@ static inline int compute_score(struct s
27827 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27828 * harder than this. -DaveM
27830 @@ -294,6 +293,11 @@ begin:
27831 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27832 score = compute_score(sk, net, saddr, hnum, sport,
27833 daddr, dport, dif);
27834 + /* FIXME: disabled?
27835 + if (score == 9) {
27839 if (score > badness) {
27842 @@ -307,6 +311,7 @@ begin:
27843 if (get_nulls_value(node) != hash)
27848 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27850 @@ -316,6 +321,7 @@ begin:
27858 @@ -358,7 +364,7 @@ static inline struct sock *udp_v4_mcast_
27859 s->sk_hash != hnum ||
27860 (inet->daddr && inet->daddr != rmt_addr) ||
27861 (inet->dport != rmt_port && inet->dport) ||
27862 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27863 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27864 ipv6_only_sock(s) ||
27865 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27867 @@ -707,8 +713,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27868 { .sport = inet->sport,
27869 .dport = dport } } };
27870 struct net *net = sock_net(sk);
27871 + struct nx_info *nxi = sk->sk_nx_info;
27873 security_sk_classify_flow(sk, &fl);
27874 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27878 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27880 if (err == -ENETUNREACH)
27881 @@ -988,7 +999,8 @@ try_again:
27883 sin->sin_family = AF_INET;
27884 sin->sin_port = udp_hdr(skb)->source;
27885 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27886 + sin->sin_addr.s_addr = nx_map_sock_lback(
27887 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27888 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27890 if (inet->cmsg_flags)
27891 @@ -1630,6 +1642,8 @@ static struct sock *udp_get_first(struct
27892 sk_nulls_for_each(sk, node, &hslot->head) {
27893 if (!net_eq(sock_net(sk), net))
27895 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27897 if (sk->sk_family == state->family)
27900 @@ -1647,7 +1661,9 @@ static struct sock *udp_get_next(struct
27903 sk = sk_nulls_next(sk);
27904 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27905 + } while (sk && (!net_eq(sock_net(sk), net) ||
27906 + sk->sk_family != state->family ||
27907 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27910 if (state->bucket < UDP_HTABLE_SIZE)
27911 @@ -1754,7 +1770,10 @@ static void udp4_format_sock(struct sock
27913 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27914 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27915 - bucket, src, srcp, dest, destp, sp->sk_state,
27917 + nx_map_sock_lback(current_nx_info(), src), srcp,
27918 + nx_map_sock_lback(current_nx_info(), dest), destp,
27920 sk_wmem_alloc_get(sp),
27921 sk_rmem_alloc_get(sp),
27922 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27923 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/Kconfig linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/Kconfig
27924 --- linux-2.6.32.56/net/ipv6/Kconfig 2009-09-10 15:26:30.000000000 +0200
27925 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/Kconfig 2011-06-10 13:03:02.000000000 +0200
27928 # IPv6 as module will cause a CRASH if you try to unload it
27930 - tristate "The IPv6 protocol"
27932 + bool "The IPv6 protocol"
27935 This is complemental support for the IP version 6.
27936 You will still be able to do traditional IPv4 networking as well.
27937 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/addrconf.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/addrconf.c
27938 --- linux-2.6.32.56/net/ipv6/addrconf.c 2012-02-09 10:22:37.000000000 +0100
27939 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/addrconf.c 2011-06-10 13:03:02.000000000 +0200
27942 #include <linux/proc_fs.h>
27943 #include <linux/seq_file.h>
27944 +#include <linux/vs_network.h>
27945 +#include <linux/vs_inet6.h>
27947 /* Set to 3 to get tracing... */
27948 #define ACONF_DEBUG 2
27949 @@ -1119,7 +1121,7 @@ out:
27951 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27952 const struct in6_addr *daddr, unsigned int prefs,
27953 - struct in6_addr *saddr)
27954 + struct in6_addr *saddr, struct nx_info *nxi)
27956 struct ipv6_saddr_score scores[2],
27957 *score = &scores[0], *hiscore = &scores[1];
27958 @@ -1192,6 +1194,8 @@ int ipv6_dev_get_saddr(struct net *net,
27962 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27966 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27967 @@ -3000,7 +3004,10 @@ static void if6_seq_stop(struct seq_file
27968 static int if6_seq_show(struct seq_file *seq, void *v)
27970 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27971 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27973 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27974 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27975 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27977 ifp->idev->dev->ifindex,
27979 @@ -3497,6 +3504,12 @@ static int inet6_dump_addr(struct sk_buf
27980 struct ifmcaddr6 *ifmca;
27981 struct ifacaddr6 *ifaca;
27982 struct net *net = sock_net(skb->sk);
27983 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27985 + /* disable ipv6 on non v6 guests */
27986 + if (nxi && !nx_info_has_v6(nxi))
27990 s_idx = cb->args[0];
27991 s_ip_idx = ip_idx = cb->args[1];
27992 @@ -3518,6 +3531,8 @@ static int inet6_dump_addr(struct sk_buf
27993 ifa = ifa->if_next, ip_idx++) {
27994 if (ip_idx < s_ip_idx)
27996 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27998 err = inet6_fill_ifaddr(skb, ifa,
27999 NETLINK_CB(cb->skb).pid,
28000 cb->nlh->nlmsg_seq,
28001 @@ -3531,6 +3546,8 @@ static int inet6_dump_addr(struct sk_buf
28002 ifmca = ifmca->next, ip_idx++) {
28003 if (ip_idx < s_ip_idx)
28005 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
28007 err = inet6_fill_ifmcaddr(skb, ifmca,
28008 NETLINK_CB(cb->skb).pid,
28009 cb->nlh->nlmsg_seq,
28010 @@ -3544,6 +3561,8 @@ static int inet6_dump_addr(struct sk_buf
28011 ifaca = ifaca->aca_next, ip_idx++) {
28012 if (ip_idx < s_ip_idx)
28014 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
28016 err = inet6_fill_ifacaddr(skb, ifaca,
28017 NETLINK_CB(cb->skb).pid,
28018 cb->nlh->nlmsg_seq,
28019 @@ -3830,12 +3849,19 @@ static int inet6_dump_ifinfo(struct sk_b
28020 int s_idx = cb->args[0];
28021 struct net_device *dev;
28022 struct inet6_dev *idev;
28023 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28025 + /* FIXME: maybe disable ipv6 on non v6 guests?
28026 + if (skb->sk && skb->sk->sk_vx_info)
28027 + return skb->len; */
28029 read_lock(&dev_base_lock);
28031 for_each_netdev(net, dev) {
28034 + if (!v6_dev_in_nx_info(dev, nxi))
28036 if ((idev = in6_dev_get(dev)) == NULL)
28038 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
28039 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/af_inet6.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/af_inet6.c
28040 --- linux-2.6.32.56/net/ipv6/af_inet6.c 2009-12-03 20:03:00.000000000 +0100
28041 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/af_inet6.c 2011-06-10 13:03:02.000000000 +0200
28043 #include <linux/netdevice.h>
28044 #include <linux/icmpv6.h>
28045 #include <linux/netfilter_ipv6.h>
28046 +#include <linux/vs_inet.h>
28047 +#include <linux/vs_inet6.h>
28049 #include <net/ip.h>
28050 #include <net/ipv6.h>
28051 @@ -158,9 +160,12 @@ lookup_protocol:
28055 + if ((protocol == IPPROTO_ICMPV6) &&
28056 + nx_capable(answer->capability, NXC_RAW_ICMP))
28058 if (answer->capability > 0 && !capable(answer->capability))
28059 goto out_rcu_unlock;
28062 sock->ops = answer->ops;
28063 answer_prot = answer->prot;
28064 answer_no_check = answer->no_check;
28065 @@ -259,6 +264,7 @@ int inet6_bind(struct socket *sock, stru
28066 struct inet_sock *inet = inet_sk(sk);
28067 struct ipv6_pinfo *np = inet6_sk(sk);
28068 struct net *net = sock_net(sk);
28069 + struct nx_v6_sock_addr nsa;
28071 unsigned short snum;
28073 @@ -270,6 +276,11 @@ int inet6_bind(struct socket *sock, stru
28075 if (addr_len < SIN6_LEN_RFC2133)
28078 + err = v6_map_sock_addr(inet, addr, &nsa);
28082 addr_type = ipv6_addr_type(&addr->sin6_addr);
28083 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
28085 @@ -301,6 +312,7 @@ int inet6_bind(struct socket *sock, stru
28086 /* Reproduce AF_INET checks to make the bindings consitant */
28087 v4addr = addr->sin6_addr.s6_addr32[3];
28088 chk_addr_ret = inet_addr_type(net, v4addr);
28090 if (!sysctl_ip_nonlocal_bind &&
28091 !(inet->freebind || inet->transparent) &&
28092 v4addr != htonl(INADDR_ANY) &&
28093 @@ -310,6 +322,10 @@ int inet6_bind(struct socket *sock, stru
28094 err = -EADDRNOTAVAIL;
28097 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
28098 + err = -EADDRNOTAVAIL;
28102 if (addr_type != IPV6_ADDR_ANY) {
28103 struct net_device *dev = NULL;
28104 @@ -335,6 +351,11 @@ int inet6_bind(struct socket *sock, stru
28108 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28109 + err = -EADDRNOTAVAIL;
28113 /* ipv4 addr of the socket is invalid. Only the
28114 * unspecified and mapped address have a v4 equivalent.
28116 @@ -353,6 +374,8 @@ int inet6_bind(struct socket *sock, stru
28120 + v6_set_sock_addr(inet, &nsa);
28122 inet->rcv_saddr = v4addr;
28123 inet->saddr = v4addr;
28125 @@ -448,9 +471,11 @@ int inet6_getname(struct socket *sock, s
28127 sin->sin6_port = inet->dport;
28128 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
28129 + /* FIXME: remap lback? */
28131 sin->sin6_flowinfo = np->flow_label;
28133 + /* FIXME: remap lback? */
28134 if (ipv6_addr_any(&np->rcv_saddr))
28135 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
28137 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/fib6_rules.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/fib6_rules.c
28138 --- linux-2.6.32.56/net/ipv6/fib6_rules.c 2009-09-10 15:26:30.000000000 +0200
28139 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/fib6_rules.c 2011-06-10 13:03:02.000000000 +0200
28140 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
28141 if (ipv6_dev_get_saddr(net,
28142 ip6_dst_idev(&rt->u.dst)->dev,
28143 &flp->fl6_dst, srcprefs,
28147 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
28149 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/inet6_hashtables.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/inet6_hashtables.c
28150 --- linux-2.6.32.56/net/ipv6/inet6_hashtables.c 2012-02-09 10:22:37.000000000 +0100
28151 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/inet6_hashtables.c 2011-11-17 12:18:26.000000000 +0100
28154 #include <linux/module.h>
28155 #include <linux/random.h>
28156 +#include <linux/vs_inet6.h>
28158 #include <net/inet_connection_sock.h>
28159 #include <net/inet_hashtables.h>
28160 @@ -77,7 +78,6 @@ struct sock *__inet6_lookup_established(
28161 unsigned int slot = hash & (hashinfo->ehash_size - 1);
28162 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
28167 sk_nulls_for_each_rcu(sk, node, &head->chain) {
28168 @@ -89,7 +89,7 @@ begin:
28176 if (get_nulls_value(node) != slot)
28177 @@ -135,6 +135,9 @@ static int inline compute_score(struct s
28178 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28182 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28185 if (sk->sk_bound_dev_if) {
28186 if (sk->sk_bound_dev_if != dif)
28187 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/ip6_output.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/ip6_output.c
28188 --- linux-2.6.32.56/net/ipv6/ip6_output.c 2012-02-09 10:22:37.000000000 +0100
28189 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/ip6_output.c 2011-11-17 12:18:26.000000000 +0100
28190 @@ -942,7 +942,7 @@ static int ip6_dst_lookup_tail(struct so
28191 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
28193 sk ? inet6_sk(sk)->srcprefs : 0,
28195 + &fl->fl6_src, sk->sk_nx_info);
28197 goto out_err_release;
28199 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/ndisc.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/ndisc.c
28200 --- linux-2.6.32.56/net/ipv6/ndisc.c 2009-12-03 20:03:00.000000000 +0100
28201 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/ndisc.c 2011-06-10 13:03:02.000000000 +0200
28202 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
28204 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
28205 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
28207 + &tmpaddr, NULL /* FIXME: ? */ ))
28209 src_addr = &tmpaddr;
28211 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/raw.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/raw.c
28212 --- linux-2.6.32.56/net/ipv6/raw.c 2009-12-03 20:03:00.000000000 +0100
28213 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/raw.c 2011-06-10 13:03:02.000000000 +0200
28215 #include <linux/icmpv6.h>
28216 #include <linux/netfilter.h>
28217 #include <linux/netfilter_ipv6.h>
28218 +#include <linux/vs_inet6.h>
28219 #include <linux/skbuff.h>
28220 #include <asm/uaccess.h>
28221 #include <asm/ioctls.h>
28222 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
28226 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28227 + err = -EADDRNOTAVAIL;
28233 /* ipv4 addr of the socket is invalid. Only the
28234 * unspecified and mapped address have a v4 equivalent.
28236 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/route.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/route.c
28237 --- linux-2.6.32.56/net/ipv6/route.c 2012-02-09 10:22:37.000000000 +0100
28238 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/route.c 2011-06-10 13:03:02.000000000 +0200
28239 @@ -2277,7 +2277,8 @@ static int rt6_fill_node(struct net *net
28240 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
28241 struct in6_addr saddr_buf;
28242 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
28243 - dst, 0, &saddr_buf) == 0)
28244 + dst, 0, &saddr_buf,
28245 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
28246 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
28249 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/tcp_ipv6.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/tcp_ipv6.c
28250 --- linux-2.6.32.56/net/ipv6/tcp_ipv6.c 2012-02-09 10:22:37.000000000 +0100
28251 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/tcp_ipv6.c 2011-11-17 12:18:26.000000000 +0100
28254 #include <linux/crypto.h>
28255 #include <linux/scatterlist.h>
28256 +#include <linux/vs_inet6.h>
28258 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
28259 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
28260 @@ -157,8 +158,15 @@ static int tcp_v6_connect(struct sock *s
28261 * connect() to INADDR_ANY means loopback (BSD'ism).
28264 - if(ipv6_addr_any(&usin->sin6_addr))
28265 - usin->sin6_addr.s6_addr[15] = 0x1;
28266 + if(ipv6_addr_any(&usin->sin6_addr)) {
28267 + struct nx_info *nxi = sk->sk_nx_info;
28269 + if (nxi && nx_info_has_v6(nxi))
28270 + /* FIXME: remap lback? */
28271 + usin->sin6_addr = nxi->v6.ip;
28273 + usin->sin6_addr.s6_addr[15] = 0x1;
28276 addr_type = ipv6_addr_type(&usin->sin6_addr);
28278 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/udp.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/udp.c
28279 --- linux-2.6.32.56/net/ipv6/udp.c 2012-02-09 10:22:38.000000000 +0100
28280 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/udp.c 2012-01-10 09:18:12.000000000 +0100
28283 #include <linux/proc_fs.h>
28284 #include <linux/seq_file.h>
28285 +#include <linux/vs_inet6.h>
28286 #include "udp_impl.h"
28288 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28289 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
28290 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28292 /* if both are mapped, treat as IPv4 */
28293 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28294 - return (!sk2_ipv6only &&
28295 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28296 + if (!sk2_ipv6only &&
28297 (!sk_rcv_saddr || !sk2_rcv_saddr ||
28298 - sk_rcv_saddr == sk2_rcv_saddr));
28299 + sk_rcv_saddr == sk2_rcv_saddr))
28305 if (addr_type2 == IPV6_ADDR_ANY &&
28306 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28310 if (addr_type == IPV6_ADDR_ANY &&
28311 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28315 if (sk2_rcv_saddr6 &&
28316 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28323 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
28324 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28325 + if (!sk2_rcv_saddr)
28326 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28327 + if (!sk_rcv_saddr)
28328 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28331 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28332 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28333 + else if (addr_type2 == IPV6_ADDR_ANY)
28334 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28335 + else if (addr_type == IPV6_ADDR_ANY) {
28336 + if (addr_type2 == IPV6_ADDR_MAPPED)
28337 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28339 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28344 int udp_v6_get_port(struct sock *sk, unsigned short snum)
28345 @@ -109,6 +135,10 @@ static inline int compute_score(struct s
28346 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28350 + /* block non nx_info ips */
28351 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28354 if (!ipv6_addr_any(&np->daddr)) {
28355 if (!ipv6_addr_equal(&np->daddr, saddr))
28356 diff -NurpP --minimal linux-2.6.32.56/net/ipv6/xfrm6_policy.c linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/xfrm6_policy.c
28357 --- linux-2.6.32.56/net/ipv6/xfrm6_policy.c 2009-12-03 20:03:00.000000000 +0100
28358 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/ipv6/xfrm6_policy.c 2011-06-10 13:03:02.000000000 +0200
28359 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
28360 dev = ip6_dst_idev(dst)->dev;
28361 ipv6_dev_get_saddr(dev_net(dev), dev,
28362 (struct in6_addr *)&daddr->a6, 0,
28363 - (struct in6_addr *)&saddr->a6);
28364 + (struct in6_addr *)&saddr->a6, NULL);
28368 diff -NurpP --minimal linux-2.6.32.56/net/netlink/af_netlink.c linux-2.6.32.56-vs2.3.0.36.29.9/net/netlink/af_netlink.c
28369 --- linux-2.6.32.56/net/netlink/af_netlink.c 2012-02-09 10:22:38.000000000 +0100
28370 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/netlink/af_netlink.c 2011-06-10 13:03:02.000000000 +0200
28372 #include <linux/types.h>
28373 #include <linux/audit.h>
28374 #include <linux/mutex.h>
28375 +#include <linux/vs_context.h>
28376 +#include <linux/vs_network.h>
28377 +#include <linux/vs_limit.h>
28379 #include <net/net_namespace.h>
28380 #include <net/sock.h>
28381 @@ -1885,6 +1888,8 @@ static struct sock *netlink_seq_socket_i
28382 sk_for_each(s, node, &hash->table[j]) {
28383 if (sock_net(s) != seq_file_net(seq))
28385 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28389 iter->hash_idx = j;
28390 @@ -1919,7 +1924,8 @@ static void *netlink_seq_next(struct seq
28394 - } while (s && sock_net(s) != seq_file_net(seq));
28395 + } while (s && (sock_net(s) != seq_file_net(seq) ||
28396 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28400 @@ -1931,7 +1937,8 @@ static void *netlink_seq_next(struct seq
28402 for (; j <= hash->mask; j++) {
28403 s = sk_head(&hash->table[j]);
28404 - while (s && sock_net(s) != seq_file_net(seq))
28405 + while (s && (sock_net(s) != seq_file_net(seq) ||
28406 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28410 diff -NurpP --minimal linux-2.6.32.56/net/sctp/ipv6.c linux-2.6.32.56-vs2.3.0.36.29.9/net/sctp/ipv6.c
28411 --- linux-2.6.32.56/net/sctp/ipv6.c 2009-12-03 20:03:01.000000000 +0100
28412 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/sctp/ipv6.c 2011-06-10 13:03:02.000000000 +0200
28413 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
28414 dst ? ip6_dst_idev(dst)->dev : NULL,
28415 &daddr->v6.sin6_addr,
28416 inet6_sk(&sk->inet.sk)->srcprefs,
28417 - &saddr->v6.sin6_addr);
28418 + &saddr->v6.sin6_addr,
28419 + asoc->base.sk->sk_nx_info);
28420 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28421 &saddr->v6.sin6_addr);
28423 diff -NurpP --minimal linux-2.6.32.56/net/socket.c linux-2.6.32.56-vs2.3.0.36.29.9/net/socket.c
28424 --- linux-2.6.32.56/net/socket.c 2012-02-09 10:22:38.000000000 +0100
28425 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/socket.c 2011-06-10 13:03:02.000000000 +0200
28428 #include <net/sock.h>
28429 #include <linux/netfilter.h>
28430 +#include <linux/vs_base.h>
28431 +#include <linux/vs_socket.h>
28432 +#include <linux/vs_inet.h>
28433 +#include <linux/vs_inet6.h>
28435 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
28436 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
28437 @@ -559,7 +563,7 @@ static inline int __sock_sendmsg(struct
28438 struct msghdr *msg, size_t size)
28440 struct sock_iocb *si = kiocb_to_siocb(iocb);
28446 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct
28450 - return sock->ops->sendmsg(iocb, sock, msg, size);
28451 + len = sock->ops->sendmsg(iocb, sock, msg, size);
28454 + vx_sock_send(sock->sk, size);
28456 + vx_sock_fail(sock->sk, size);
28458 + vxdprintk(VXD_CBIT(net, 7),
28459 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28461 + (sock->sk)?sock->sk->sk_nx_info:0,
28462 + (sock->sk)?sock->sk->sk_vx_info:0,
28463 + (sock->sk)?sock->sk->sk_xid:0,
28464 + (sock->sk)?sock->sk->sk_nid:0,
28465 + (unsigned int)size, len);
28469 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28470 @@ -671,7 +690,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
28471 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28472 struct msghdr *msg, size_t size, int flags)
28476 struct sock_iocb *si = kiocb_to_siocb(iocb);
28479 @@ -684,7 +703,18 @@ static inline int __sock_recvmsg(struct
28483 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28484 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28485 + if ((len >= 0) && sock->sk)
28486 + vx_sock_recv(sock->sk, len);
28487 + vxdprintk(VXD_CBIT(net, 7),
28488 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28490 + (sock->sk)?sock->sk->sk_nx_info:0,
28491 + (sock->sk)?sock->sk->sk_vx_info:0,
28492 + (sock->sk)?sock->sk->sk_xid:0,
28493 + (sock->sk)?sock->sk->sk_nid:0,
28494 + (unsigned int)size, len);
28498 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
28499 @@ -1155,6 +1185,13 @@ static int __sock_create(struct net *net
28500 if (type < 0 || type >= SOCK_MAX)
28503 + if (!nx_check(0, VS_ADMIN)) {
28504 + if (family == PF_INET && !current_nx_info_has_v4())
28505 + return -EAFNOSUPPORT;
28506 + if (family == PF_INET6 && !current_nx_info_has_v6())
28507 + return -EAFNOSUPPORT;
28512 This uglymoron is moved from INET layer to here to avoid
28513 @@ -1287,6 +1324,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28517 + set_bit(SOCK_USER_SOCKET, &sock->flags);
28518 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28521 @@ -1328,10 +1366,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28522 err = sock_create(family, type, protocol, &sock1);
28525 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
28527 err = sock_create(family, type, protocol, &sock2);
28529 goto out_release_1;
28530 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
28532 err = sock1->ops->socketpair(sock1, sock2);
28534 diff -NurpP --minimal linux-2.6.32.56/net/sunrpc/auth.c linux-2.6.32.56-vs2.3.0.36.29.9/net/sunrpc/auth.c
28535 --- linux-2.6.32.56/net/sunrpc/auth.c 2009-12-03 20:03:01.000000000 +0100
28536 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/sunrpc/auth.c 2011-06-10 13:03:02.000000000 +0200
28538 #include <linux/hash.h>
28539 #include <linux/sunrpc/clnt.h>
28540 #include <linux/spinlock.h>
28541 +#include <linux/vs_tag.h>
28544 # define RPCDBG_FACILITY RPCDBG_AUTH
28545 @@ -360,6 +361,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28546 memset(&acred, 0, sizeof(acred));
28547 acred.uid = cred->fsuid;
28548 acred.gid = cred->fsgid;
28549 + acred.tag = dx_current_tag();
28550 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28552 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28553 @@ -400,6 +402,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28554 struct auth_cred acred = {
28557 + .tag = dx_current_tag(),
28559 struct rpc_cred *ret;
28561 diff -NurpP --minimal linux-2.6.32.56/net/sunrpc/auth_unix.c linux-2.6.32.56-vs2.3.0.36.29.9/net/sunrpc/auth_unix.c
28562 --- linux-2.6.32.56/net/sunrpc/auth_unix.c 2012-02-09 10:22:38.000000000 +0100
28563 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/sunrpc/auth_unix.c 2012-01-10 09:18:12.000000000 +0100
28564 @@ -11,12 +11,14 @@
28565 #include <linux/module.h>
28566 #include <linux/sunrpc/clnt.h>
28567 #include <linux/sunrpc/auth.h>
28568 +#include <linux/vs_tag.h>
28570 #define NFS_NGROUPS 16
28573 struct rpc_cred uc_base;
28576 gid_t uc_gids[NFS_NGROUPS];
28578 #define uc_uid uc_base.cr_uid
28579 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28580 groups = NFS_NGROUPS;
28582 cred->uc_gid = acred->gid;
28583 + cred->uc_tag = acred->tag;
28584 for (i = 0; i < groups; i++)
28585 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28586 if (i < NFS_NGROUPS)
28587 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28591 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28592 + if (cred->uc_uid != acred->uid ||
28593 + cred->uc_gid != acred->gid ||
28594 + cred->uc_tag != acred->tag)
28597 if (acred->group_info != NULL)
28598 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
28599 struct rpc_clnt *clnt = task->tk_client;
28600 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28601 __be32 *base, *hold;
28605 *p++ = htonl(RPC_AUTH_UNIX);
28607 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
28608 * Copy the UTS nodename captured when the client was created.
28610 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28611 + tag = task->tk_client->cl_tag;
28613 - *p++ = htonl((u32) cred->uc_uid);
28614 - *p++ = htonl((u32) cred->uc_gid);
28615 + *p++ = htonl((u32) TAGINO_UID(tag,
28616 + cred->uc_uid, cred->uc_tag));
28617 + *p++ = htonl((u32) TAGINO_GID(tag,
28618 + cred->uc_gid, cred->uc_tag));
28620 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28621 *p++ = htonl((u32) cred->uc_gids[i]);
28622 diff -NurpP --minimal linux-2.6.32.56/net/sunrpc/clnt.c linux-2.6.32.56-vs2.3.0.36.29.9/net/sunrpc/clnt.c
28623 --- linux-2.6.32.56/net/sunrpc/clnt.c 2012-02-09 10:22:38.000000000 +0100
28624 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/sunrpc/clnt.c 2011-11-17 12:18:26.000000000 +0100
28626 #include <linux/utsname.h>
28627 #include <linux/workqueue.h>
28628 #include <linux/in6.h>
28629 +#include <linux/vs_cvirt.h>
28631 #include <linux/sunrpc/clnt.h>
28632 #include <linux/sunrpc/rpc_pipe_fs.h>
28633 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28634 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28635 clnt->cl_chatty = 1;
28637 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28638 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28639 + clnt->cl_tag = 1; */
28642 EXPORT_SYMBOL_GPL(rpc_create);
28643 diff -NurpP --minimal linux-2.6.32.56/net/unix/af_unix.c linux-2.6.32.56-vs2.3.0.36.29.9/net/unix/af_unix.c
28644 --- linux-2.6.32.56/net/unix/af_unix.c 2012-02-09 10:22:38.000000000 +0100
28645 +++ linux-2.6.32.56-vs2.3.0.36.29.9/net/unix/af_unix.c 2011-06-10 13:03:02.000000000 +0200
28646 @@ -114,6 +114,8 @@
28647 #include <linux/mount.h>
28648 #include <net/checksum.h>
28649 #include <linux/security.h>
28650 +#include <linux/vs_context.h>
28651 +#include <linux/vs_limit.h>
28653 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28654 static DEFINE_SPINLOCK(unix_table_lock);
28655 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28656 if (!net_eq(sock_net(s), net))
28659 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28661 if (u->addr->len == len &&
28662 !memcmp(u->addr->name, sunname, len))
28664 @@ -2164,6 +2168,8 @@ static struct sock *unix_seq_idx(struct
28665 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28666 if (sock_net(s) != seq_file_net(seq))
28668 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28673 @@ -2188,7 +2194,8 @@ static void *unix_seq_next(struct seq_fi
28674 sk = first_unix_socket(&iter->i);
28676 sk = next_unix_socket(&iter->i, sk);
28677 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28678 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28679 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28680 sk = next_unix_socket(&iter->i, sk);
28683 diff -NurpP --minimal linux-2.6.32.56/scripts/checksyscalls.sh linux-2.6.32.56-vs2.3.0.36.29.9/scripts/checksyscalls.sh
28684 --- linux-2.6.32.56/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
28685 +++ linux-2.6.32.56-vs2.3.0.36.29.9/scripts/checksyscalls.sh 2011-06-10 13:03:02.000000000 +0200
28686 @@ -194,7 +194,6 @@ cat << EOF
28687 #define __IGNORE_afs_syscall
28688 #define __IGNORE_getpmsg
28689 #define __IGNORE_putpmsg
28690 -#define __IGNORE_vserver
28694 diff -NurpP --minimal linux-2.6.32.56/security/commoncap.c linux-2.6.32.56-vs2.3.0.36.29.9/security/commoncap.c
28695 --- linux-2.6.32.56/security/commoncap.c 2009-12-03 20:03:02.000000000 +0100
28696 +++ linux-2.6.32.56-vs2.3.0.36.29.9/security/commoncap.c 2011-06-10 13:03:02.000000000 +0200
28698 #include <linux/sched.h>
28699 #include <linux/prctl.h>
28700 #include <linux/securebits.h>
28701 +#include <linux/vs_context.h>
28704 * If a non-root user executes a setuid-root binary in
28705 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
28707 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28709 - NETLINK_CB(skb).eff_cap = current_cap();
28710 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28714 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
28719 EXPORT_SYMBOL(cap_netlink_recv);
28722 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28723 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28726 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28727 + struct vx_info *vxi = tsk->vx_info;
28730 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28731 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28732 + cap_raised(tsk->cap_effective, cap),
28733 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28736 + /* special case SETUP */
28737 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28738 + /* FIXME: maybe use cred instead? */
28739 + cap_raised(tsk->cred->cap_effective, cap))
28742 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28746 @@ -618,7 +635,7 @@ int cap_inode_setxattr(struct dentry *de
28748 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28749 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28750 - !capable(CAP_SYS_ADMIN))
28751 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28755 @@ -644,7 +661,7 @@ int cap_inode_removexattr(struct dentry
28757 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28758 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28759 - !capable(CAP_SYS_ADMIN))
28760 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28764 @@ -962,7 +979,8 @@ error:
28766 int cap_syslog(int type)
28768 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
28769 + if ((type != 3 && type != 10) &&
28770 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28774 diff -NurpP --minimal linux-2.6.32.56/security/selinux/hooks.c linux-2.6.32.56-vs2.3.0.36.29.9/security/selinux/hooks.c
28775 --- linux-2.6.32.56/security/selinux/hooks.c 2012-02-09 10:22:38.000000000 +0100
28776 +++ linux-2.6.32.56-vs2.3.0.36.29.9/security/selinux/hooks.c 2011-06-10 13:03:02.000000000 +0200
28778 #include <linux/dccp.h>
28779 #include <linux/quota.h>
28780 #include <linux/un.h> /* for Unix socket types */
28781 -#include <net/af_unix.h> /* for Unix socket types */
28782 #include <linux/parser.h>
28783 #include <linux/nfs_mount.h>
28784 #include <net/ipv6.h>
28785 diff -NurpP --minimal linux-2.6.32.56/security/selinux/include/av_perm_to_string.h linux-2.6.32.56-vs2.3.0.36.29.9/security/selinux/include/av_perm_to_string.h
28786 --- linux-2.6.32.56/security/selinux/include/av_perm_to_string.h 2009-12-03 20:03:02.000000000 +0100
28787 +++ linux-2.6.32.56-vs2.3.0.36.29.9/security/selinux/include/av_perm_to_string.h 2011-06-10 13:03:02.000000000 +0200
28788 @@ -142,6 +142,7 @@
28789 S_(SECCLASS_CAPABILITY, CAPABILITY__SETFCAP, "setfcap")
28790 S_(SECCLASS_CAPABILITY2, CAPABILITY2__MAC_OVERRIDE, "mac_override")
28791 S_(SECCLASS_CAPABILITY2, CAPABILITY2__MAC_ADMIN, "mac_admin")
28792 + S_(SECCLASS_CAPABILITY2, CAPABILITY2__CONTEXT, "context")
28793 S_(SECCLASS_NETLINK_ROUTE_SOCKET, NETLINK_ROUTE_SOCKET__NLMSG_READ, "nlmsg_read")
28794 S_(SECCLASS_NETLINK_ROUTE_SOCKET, NETLINK_ROUTE_SOCKET__NLMSG_WRITE, "nlmsg_write")
28795 S_(SECCLASS_NETLINK_FIREWALL_SOCKET, NETLINK_FIREWALL_SOCKET__NLMSG_READ, "nlmsg_read")
28796 diff -NurpP --minimal linux-2.6.32.56/security/selinux/include/av_permissions.h linux-2.6.32.56-vs2.3.0.36.29.9/security/selinux/include/av_permissions.h
28797 --- linux-2.6.32.56/security/selinux/include/av_permissions.h 2009-12-03 20:03:02.000000000 +0100
28798 +++ linux-2.6.32.56-vs2.3.0.36.29.9/security/selinux/include/av_permissions.h 2011-06-10 13:03:02.000000000 +0200
28799 @@ -565,6 +565,7 @@
28800 #define CAPABILITY__SETFCAP 0x80000000UL
28801 #define CAPABILITY2__MAC_OVERRIDE 0x00000001UL
28802 #define CAPABILITY2__MAC_ADMIN 0x00000002UL
28803 +#define CAPABILITY2__CONTEXT 0x00000004UL
28804 #define NETLINK_ROUTE_SOCKET__IOCTL 0x00000001UL
28805 #define NETLINK_ROUTE_SOCKET__READ 0x00000002UL
28806 #define NETLINK_ROUTE_SOCKET__WRITE 0x00000004UL