1 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/Kconfig
2 --- linux-2.6.32.10/arch/alpha/Kconfig 2009-12-03 20:01:49.000000000 +0100
3 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/Kconfig 2009-12-03 20:04:56.000000000 +0100
4 @@ -674,6 +674,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/kernel/entry.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/entry.S
14 --- linux-2.6.32.10/arch/alpha/kernel/entry.S 2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/entry.S 2009-12-03 20:04:56.000000000 +0100
16 @@ -874,24 +874,15 @@ sys_getxgid:
25 - /* See linux/kernel/timer.c sys_getppid for discussion
27 - ldq $3, TASK_GROUP_LEADER($2)
28 - ldq $4, TASK_REAL_PARENT($3)
29 - ldl $0, TASK_TGID($2)
30 -1: ldl $1, TASK_TGID($4)
34 - ldq $3, TASK_GROUP_LEADER($2)
35 - ldq $4, TASK_REAL_PARENT($3)
48 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/kernel/osf_sys.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.32.10/arch/alpha/kernel/osf_sys.c 2010-03-18 16:17:26.000000000 +0100
50 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/osf_sys.c 2010-01-20 04:21:33.000000000 +0100
51 @@ -865,7 +865,7 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct
55 - do_gettimeofday(&ktv);
56 + vx_gettimeofday(&ktv);
57 if (put_tv32(tv, &ktv))
60 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/kernel/ptrace.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.32.10/arch/alpha/kernel/ptrace.c 2009-09-10 15:25:14.000000000 +0200
62 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
64 #include <linux/slab.h>
65 #include <linux/security.h>
66 #include <linux/signal.h>
67 +#include <linux/vs_base.h>
69 #include <asm/uaccess.h>
70 #include <asm/pgtable.h>
71 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/kernel/systbls.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/systbls.S
72 --- linux-2.6.32.10/arch/alpha/kernel/systbls.S 2009-03-24 14:18:08.000000000 +0100
73 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/systbls.S 2009-12-03 20:04:56.000000000 +0100
74 @@ -446,7 +446,7 @@ sys_call_table:
75 .quad sys_stat64 /* 425 */
78 - .quad sys_ni_syscall /* sys_vserver */
79 + .quad sys_vserver /* sys_vserver */
80 .quad sys_ni_syscall /* sys_mbind */
81 .quad sys_ni_syscall /* sys_get_mempolicy */
82 .quad sys_ni_syscall /* sys_set_mempolicy */
83 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/traps.c
84 --- linux-2.6.32.10/arch/alpha/kernel/traps.c 2009-06-11 17:11:46.000000000 +0200
85 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
86 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
88 printk("CPU %d ", hard_smp_processor_id());
90 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
91 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
92 + task_pid_nr(current), current->xid, str, err);
93 dik_show_regs(regs, r9_15);
95 dik_show_trace((unsigned long *)(regs+1));
96 diff -NurpP --minimal linux-2.6.32.10/arch/alpha/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/mm/fault.c
97 --- linux-2.6.32.10/arch/alpha/mm/fault.c 2009-09-10 15:25:14.000000000 +0200
98 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/alpha/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
99 @@ -193,8 +193,8 @@ do_page_fault(unsigned long address, uns
100 down_read(&mm->mmap_sem);
103 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
104 - current->comm, task_pid_nr(current));
105 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
106 + current->comm, task_pid_nr(current), current->xid);
107 if (!user_mode(regs))
109 do_group_exit(SIGKILL);
110 diff -NurpP --minimal linux-2.6.32.10/arch/arm/include/asm/tlb.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/include/asm/tlb.h
111 --- linux-2.6.32.10/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
112 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/include/asm/tlb.h 2010-02-19 16:17:49.000000000 +0100
115 #else /* !CONFIG_MMU */
117 +#include <linux/vs_memory.h>
118 #include <asm/pgalloc.h>
121 diff -NurpP --minimal linux-2.6.32.10/arch/arm/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/Kconfig
122 --- linux-2.6.32.10/arch/arm/Kconfig 2009-12-03 20:01:49.000000000 +0100
123 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/Kconfig 2009-12-03 20:04:56.000000000 +0100
124 @@ -1512,6 +1512,8 @@ source "fs/Kconfig"
126 source "arch/arm/Kconfig.debug"
128 +source "kernel/vserver/Kconfig"
130 source "security/Kconfig"
132 source "crypto/Kconfig"
133 diff -NurpP --minimal linux-2.6.32.10/arch/arm/kernel/calls.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/kernel/calls.S
134 --- linux-2.6.32.10/arch/arm/kernel/calls.S 2010-03-18 16:17:26.000000000 +0100
135 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/kernel/calls.S 2010-01-20 04:21:33.000000000 +0100
137 /* 310 */ CALL(sys_request_key)
139 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
140 -/* vserver */ CALL(sys_ni_syscall)
143 /* 315 */ CALL(sys_ioprio_get)
144 CALL(sys_inotify_init)
145 diff -NurpP --minimal linux-2.6.32.10/arch/arm/kernel/process.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/kernel/process.c
146 --- linux-2.6.32.10/arch/arm/kernel/process.c 2009-12-03 20:01:50.000000000 +0100
147 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/kernel/process.c 2009-12-03 20:04:56.000000000 +0100
148 @@ -269,7 +269,8 @@ void __show_regs(struct pt_regs *regs)
149 void show_regs(struct pt_regs * regs)
152 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
153 + printk("Pid: %d[#%u], comm: %20s\n",
154 + task_pid_nr(current), current->xid, current->comm);
158 diff -NurpP --minimal linux-2.6.32.10/arch/arm/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/kernel/traps.c
159 --- linux-2.6.32.10/arch/arm/kernel/traps.c 2009-12-03 20:01:50.000000000 +0100
160 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/arm/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
161 @@ -234,8 +234,8 @@ static void __die(const char *str, int e
162 sysfs_printk_last_file();
165 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
166 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
167 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
168 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
170 if (!user_mode(regs) || in_interrupt()) {
171 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
172 diff -NurpP --minimal linux-2.6.32.10/arch/avr32/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/avr32/mm/fault.c
173 --- linux-2.6.32.10/arch/avr32/mm/fault.c 2009-09-10 15:25:20.000000000 +0200
174 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/avr32/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
175 @@ -216,7 +216,8 @@ out_of_memory:
176 down_read(&mm->mmap_sem);
179 - printk("VM: Killing process %s\n", tsk->comm);
180 + printk("VM: Killing process %s(%d:#%u)\n",
181 + tsk->comm, task_pid_nr(tsk), tsk->xid);
183 do_group_exit(SIGKILL);
185 diff -NurpP --minimal linux-2.6.32.10/arch/cris/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/cris/Kconfig
186 --- linux-2.6.32.10/arch/cris/Kconfig 2009-06-11 17:11:56.000000000 +0200
187 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/cris/Kconfig 2009-12-03 20:04:56.000000000 +0100
188 @@ -685,6 +685,8 @@ source "drivers/staging/Kconfig"
190 source "arch/cris/Kconfig.debug"
192 +source "kernel/vserver/Kconfig"
194 source "security/Kconfig"
196 source "crypto/Kconfig"
197 diff -NurpP --minimal linux-2.6.32.10/arch/cris/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/cris/mm/fault.c
198 --- linux-2.6.32.10/arch/cris/mm/fault.c 2009-12-03 20:01:56.000000000 +0100
199 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/cris/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
200 @@ -245,7 +245,8 @@ do_page_fault(unsigned long address, str
203 up_read(&mm->mmap_sem);
204 - printk("VM: killing process %s\n", tsk->comm);
205 + printk("VM: killing process %s(%d:#%u)\n",
206 + tsk->comm, task_pid_nr(tsk), tsk->xid);
210 diff -NurpP --minimal linux-2.6.32.10/arch/frv/kernel/kernel_thread.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/frv/kernel/kernel_thread.S
211 --- linux-2.6.32.10/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
212 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/frv/kernel/kernel_thread.S 2009-12-03 20:04:56.000000000 +0100
213 @@ -37,7 +37,7 @@ kernel_thread:
215 # start by forking the current process, but with shared VM
216 setlos.p #__NR_clone,gr7 ; syscall number
217 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
218 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
219 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
221 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
222 diff -NurpP --minimal linux-2.6.32.10/arch/frv/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/frv/mm/fault.c
223 --- linux-2.6.32.10/arch/frv/mm/fault.c 2009-09-10 15:25:22.000000000 +0200
224 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/frv/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
225 @@ -257,7 +257,8 @@ asmlinkage void do_page_fault(int datamm
228 up_read(&mm->mmap_sem);
229 - printk("VM: killing process %s\n", current->comm);
230 + printk("VM: killing process %s(%d:#%u)\n",
231 + current->comm, task_pid_nr(current), current->xid);
232 if (user_mode(__frame))
233 do_group_exit(SIGKILL);
235 diff -NurpP --minimal linux-2.6.32.10/arch/h8300/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/h8300/Kconfig
236 --- linux-2.6.32.10/arch/h8300/Kconfig 2009-03-24 14:18:24.000000000 +0100
237 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/h8300/Kconfig 2009-12-03 20:04:56.000000000 +0100
238 @@ -226,6 +226,8 @@ source "fs/Kconfig"
240 source "arch/h8300/Kconfig.debug"
242 +source "kernel/vserver/Kconfig"
244 source "security/Kconfig"
246 source "crypto/Kconfig"
247 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/ia32/ia32_entry.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/ia32/ia32_entry.S
248 --- linux-2.6.32.10/arch/ia64/ia32/ia32_entry.S 2009-06-11 17:11:57.000000000 +0200
249 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/ia32/ia32_entry.S 2009-12-03 20:04:56.000000000 +0100
250 @@ -451,7 +451,7 @@ ia32_syscall_table:
251 data8 sys_tgkill /* 270 */
252 data8 compat_sys_utimes
253 data8 sys32_fadvise64_64
254 - data8 sys_ni_syscall
255 + data8 sys32_vserver
257 data8 sys_ni_syscall /* 275 */
259 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/include/asm/tlb.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/include/asm/tlb.h
260 --- linux-2.6.32.10/arch/ia64/include/asm/tlb.h 2009-09-10 15:25:22.000000000 +0200
261 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/include/asm/tlb.h 2009-12-31 14:37:34.000000000 +0100
263 #include <linux/mm.h>
264 #include <linux/pagemap.h>
265 #include <linux/swap.h>
266 +#include <linux/vs_memory.h>
268 #include <asm/pgalloc.h>
269 #include <asm/processor.h>
270 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/Kconfig
271 --- linux-2.6.32.10/arch/ia64/Kconfig 2009-12-03 20:01:56.000000000 +0100
272 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/Kconfig 2009-12-03 20:04:56.000000000 +0100
273 @@ -685,6 +685,8 @@ source "fs/Kconfig"
275 source "arch/ia64/Kconfig.debug"
277 +source "kernel/vserver/Kconfig"
279 source "security/Kconfig"
281 source "crypto/Kconfig"
282 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/kernel/entry.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/entry.S
283 --- linux-2.6.32.10/arch/ia64/kernel/entry.S 2009-09-10 15:25:22.000000000 +0200
284 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/entry.S 2009-12-03 20:04:56.000000000 +0100
285 @@ -1753,7 +1753,7 @@ sys_call_table:
287 data8 sys_mq_getsetattr
289 - data8 sys_ni_syscall // reserved for vserver
291 data8 sys_waitid // 1270
293 data8 sys_request_key
294 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/kernel/perfmon.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/perfmon.c
295 --- linux-2.6.32.10/arch/ia64/kernel/perfmon.c 2009-09-10 15:25:22.000000000 +0200
296 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/perfmon.c 2009-12-03 20:04:56.000000000 +0100
298 #include <linux/rcupdate.h>
299 #include <linux/completion.h>
300 #include <linux/tracehook.h>
301 +#include <linux/vs_memory.h>
303 #include <asm/errno.h>
304 #include <asm/intrinsics.h>
305 @@ -2372,7 +2373,7 @@ pfm_smpl_buffer_alloc(struct task_struct
307 insert_vm_struct(mm, vma);
309 - mm->total_vm += size >> PAGE_SHIFT;
310 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
311 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
313 up_write(&task->mm->mmap_sem);
314 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/kernel/process.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/process.c
315 --- linux-2.6.32.10/arch/ia64/kernel/process.c 2009-12-03 20:01:56.000000000 +0100
316 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/process.c 2009-12-03 20:04:56.000000000 +0100
317 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
318 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
321 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
322 - smp_processor_id(), current->comm);
323 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
324 + current->xid, smp_processor_id(), current->comm);
325 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
326 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
327 init_utsname()->release);
328 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/kernel/ptrace.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/ptrace.c
329 --- linux-2.6.32.10/arch/ia64/kernel/ptrace.c 2009-09-10 15:25:22.000000000 +0200
330 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
332 #include <linux/regset.h>
333 #include <linux/elf.h>
334 #include <linux/tracehook.h>
335 +#include <linux/vs_base.h>
337 #include <asm/pgtable.h>
338 #include <asm/processor.h>
339 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/traps.c
340 --- linux-2.6.32.10/arch/ia64/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
341 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
342 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
345 if (++die.lock_owner_depth < 3) {
346 - printk("%s[%d]: %s %ld [%d]\n",
347 - current->comm, task_pid_nr(current), str, err, ++die_counter);
348 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
349 + current->comm, task_pid_nr(current), current->xid,
350 + str, err, ++die_counter);
351 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
354 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
355 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
356 last.time = current_jiffies + 5 * HZ;
358 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
359 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
360 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
361 + current->comm, task_pid_nr(current), current->xid,
362 + regs->cr_iip + ia64_psr(regs)->ri, isr);
366 diff -NurpP --minimal linux-2.6.32.10/arch/ia64/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/mm/fault.c
367 --- linux-2.6.32.10/arch/ia64/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
368 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/ia64/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
370 #include <linux/interrupt.h>
371 #include <linux/kprobes.h>
372 #include <linux/kdebug.h>
373 +#include <linux/vs_memory.h>
375 #include <asm/pgtable.h>
376 #include <asm/processor.h>
377 @@ -281,7 +282,8 @@ ia64_do_page_fault (unsigned long addres
378 down_read(&mm->mmap_sem);
381 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
382 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
383 + current->comm, task_pid_nr(current), current->xid);
385 do_group_exit(SIGKILL);
387 diff -NurpP --minimal linux-2.6.32.10/arch/m32r/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/m32r/kernel/traps.c
388 --- linux-2.6.32.10/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
389 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m32r/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
390 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
392 printk("SPI: %08lx\n", sp);
394 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
395 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
396 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
397 + current->comm, task_pid_nr(current), current->xid,
398 + 0xffff & i, 4096+(unsigned long)current);
401 * When in-kernel, we also print out the stack and code at the
402 diff -NurpP --minimal linux-2.6.32.10/arch/m32r/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/m32r/mm/fault.c
403 --- linux-2.6.32.10/arch/m32r/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m32r/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
405 @@ -276,7 +276,8 @@ out_of_memory:
406 down_read(&mm->mmap_sem);
409 - printk("VM: killing process %s\n", tsk->comm);
410 + printk("VM: killing process %s(%d:#%u)\n",
411 + tsk->comm, task_pid_nr(tsk), tsk->xid);
412 if (error_code & ACE_USERMODE)
413 do_group_exit(SIGKILL);
415 diff -NurpP --minimal linux-2.6.32.10/arch/m68k/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/Kconfig
416 --- linux-2.6.32.10/arch/m68k/Kconfig 2009-12-03 20:01:57.000000000 +0100
417 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/Kconfig 2009-12-03 20:04:56.000000000 +0100
418 @@ -622,6 +622,8 @@ source "fs/Kconfig"
420 source "arch/m68k/Kconfig.debug"
422 +source "kernel/vserver/Kconfig"
424 source "security/Kconfig"
426 source "crypto/Kconfig"
427 diff -NurpP --minimal linux-2.6.32.10/arch/m68k/kernel/ptrace.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/kernel/ptrace.c
428 --- linux-2.6.32.10/arch/m68k/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
429 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
431 #include <linux/ptrace.h>
432 #include <linux/user.h>
433 #include <linux/signal.h>
434 +#include <linux/vs_base.h>
436 #include <asm/uaccess.h>
437 #include <asm/page.h>
438 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
439 ret = ptrace_request(child, request, addr, data);
442 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
447 diff -NurpP --minimal linux-2.6.32.10/arch/m68k/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/kernel/traps.c
448 --- linux-2.6.32.10/arch/m68k/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
449 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
450 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
451 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
452 regs->d4, regs->d5, regs->a0, regs->a1);
454 - printk("Process %s (pid: %d, task=%p)\n",
455 - current->comm, task_pid_nr(current), current);
456 + printk("Process %s (pid: %d[#%u], task=%p)\n",
457 + current->comm, task_pid_nr(current), current->xid, current);
458 addr = (unsigned long)&fp->un;
459 printk("Frame format=%X ", regs->format);
460 switch (regs->format) {
461 diff -NurpP --minimal linux-2.6.32.10/arch/m68k/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/mm/fault.c
462 --- linux-2.6.32.10/arch/m68k/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
463 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68k/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
464 @@ -186,7 +186,8 @@ out_of_memory:
468 - printk("VM: killing process %s\n", current->comm);
469 + printk("VM: killing process %s(%d:#%u)\n",
470 + current->comm, task_pid_nr(current), current->xid);
472 do_group_exit(SIGKILL);
474 diff -NurpP --minimal linux-2.6.32.10/arch/m68knommu/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68knommu/Kconfig
475 --- linux-2.6.32.10/arch/m68knommu/Kconfig 2009-12-03 20:01:57.000000000 +0100
476 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68knommu/Kconfig 2009-12-03 20:04:56.000000000 +0100
477 @@ -727,6 +727,8 @@ source "fs/Kconfig"
479 source "arch/m68knommu/Kconfig.debug"
481 +source "kernel/vserver/Kconfig"
483 source "security/Kconfig"
485 source "crypto/Kconfig"
486 diff -NurpP --minimal linux-2.6.32.10/arch/m68knommu/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68knommu/kernel/traps.c
487 --- linux-2.6.32.10/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
488 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/m68knommu/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
489 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
490 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
491 fp->d4, fp->d5, fp->a0, fp->a1);
493 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
494 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
495 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
496 + current->comm, task_pid_nr(current), current->xid,
497 + PAGE_SIZE+(unsigned long)current);
498 show_stack(NULL, (unsigned long *)(fp + 1));
499 add_taint(TAINT_DIE);
501 diff -NurpP --minimal linux-2.6.32.10/arch/microblaze/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/microblaze/mm/fault.c
502 --- linux-2.6.32.10/arch/microblaze/mm/fault.c 2009-09-10 15:25:24.000000000 +0200
503 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/microblaze/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
504 @@ -279,7 +279,8 @@ out_of_memory:
507 up_read(&mm->mmap_sem);
508 - printk(KERN_WARNING "VM: killing process %s\n", current->comm);
509 + printk(KERN_WARNING "VM: killing process %s(%d:#%u)\n",
510 + current->comm, task_pid_nr(current), current->xid);
513 bad_page_fault(regs, address, SIGKILL);
514 diff -NurpP --minimal linux-2.6.32.10/arch/mips/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/Kconfig
515 --- linux-2.6.32.10/arch/mips/Kconfig 2009-12-03 20:01:58.000000000 +0100
516 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/Kconfig 2009-12-03 20:04:56.000000000 +0100
517 @@ -2188,6 +2188,8 @@ source "fs/Kconfig"
519 source "arch/mips/Kconfig.debug"
521 +source "kernel/vserver/Kconfig"
523 source "security/Kconfig"
525 source "crypto/Kconfig"
526 diff -NurpP --minimal linux-2.6.32.10/arch/mips/kernel/ptrace.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/ptrace.c
527 --- linux-2.6.32.10/arch/mips/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
528 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
530 #include <linux/security.h>
531 #include <linux/audit.h>
532 #include <linux/seccomp.h>
533 +#include <linux/vs_base.h>
535 #include <asm/byteorder.h>
537 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
541 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
545 /* when I and D space are separate, these will need to be fixed. */
546 case PTRACE_PEEKTEXT: /* read word at location addr. */
547 diff -NurpP --minimal linux-2.6.32.10/arch/mips/kernel/scall32-o32.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall32-o32.S
548 --- linux-2.6.32.10/arch/mips/kernel/scall32-o32.S 2009-12-03 20:01:59.000000000 +0100
549 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall32-o32.S 2009-12-03 20:04:56.000000000 +0100
550 @@ -525,7 +525,7 @@ einval: li v0, -ENOSYS
551 sys sys_mq_timedreceive 5
552 sys sys_mq_notify 2 /* 4275 */
553 sys sys_mq_getsetattr 3
554 - sys sys_ni_syscall 0 /* sys_vserver */
557 sys sys_ni_syscall 0 /* available, was setaltroot */
558 sys sys_add_key 5 /* 4280 */
559 diff -NurpP --minimal linux-2.6.32.10/arch/mips/kernel/scall64-64.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall64-64.S
560 --- linux-2.6.32.10/arch/mips/kernel/scall64-64.S 2009-12-03 20:01:59.000000000 +0100
561 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall64-64.S 2009-12-03 20:04:56.000000000 +0100
562 @@ -362,7 +362,7 @@ sys_call_table:
563 PTR sys_mq_timedreceive
565 PTR sys_mq_getsetattr /* 5235 */
566 - PTR sys_ni_syscall /* sys_vserver */
569 PTR sys_ni_syscall /* available, was setaltroot */
571 diff -NurpP --minimal linux-2.6.32.10/arch/mips/kernel/scall64-n32.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall64-n32.S
572 --- linux-2.6.32.10/arch/mips/kernel/scall64-n32.S 2009-12-03 20:01:59.000000000 +0100
573 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall64-n32.S 2009-12-03 20:04:56.000000000 +0100
574 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
575 PTR compat_sys_mq_timedreceive
576 PTR compat_sys_mq_notify
577 PTR compat_sys_mq_getsetattr
578 - PTR sys_ni_syscall /* 6240, sys_vserver */
579 + PTR sys32_vserver /* 6240 */
580 PTR compat_sys_waitid
581 PTR sys_ni_syscall /* available, was setaltroot */
583 diff -NurpP --minimal linux-2.6.32.10/arch/mips/kernel/scall64-o32.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall64-o32.S
584 --- linux-2.6.32.10/arch/mips/kernel/scall64-o32.S 2009-12-03 20:01:59.000000000 +0100
585 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/scall64-o32.S 2009-12-03 20:04:56.000000000 +0100
586 @@ -480,7 +480,7 @@ sys_call_table:
587 PTR compat_sys_mq_timedreceive
588 PTR compat_sys_mq_notify /* 4275 */
589 PTR compat_sys_mq_getsetattr
590 - PTR sys_ni_syscall /* sys_vserver */
593 PTR sys_ni_syscall /* available, was setaltroot */
594 PTR sys_add_key /* 4280 */
595 diff -NurpP --minimal linux-2.6.32.10/arch/mips/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/traps.c
596 --- linux-2.6.32.10/arch/mips/kernel/traps.c 2009-12-03 20:01:59.000000000 +0100
597 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mips/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
598 @@ -335,9 +335,10 @@ void show_registers(const struct pt_regs
602 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
603 - current->comm, current->pid, current_thread_info(), current,
604 - field, current_thread_info()->tp_value);
605 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
606 + current->comm, task_pid_nr(current), current->xid,
607 + current_thread_info(), current,
608 + field, current_thread_info()->tp_value);
609 if (cpu_has_userlocal) {
612 diff -NurpP --minimal linux-2.6.32.10/arch/mn10300/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/mn10300/mm/fault.c
613 --- linux-2.6.32.10/arch/mn10300/mm/fault.c 2009-09-10 15:25:39.000000000 +0200
614 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/mn10300/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
615 @@ -339,7 +339,8 @@ no_context:
617 up_read(&mm->mmap_sem);
618 monitor_signal(regs);
619 - printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
620 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
621 + tsk->comm, task_pid_nr(tsk), tsk->xid);
622 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
625 diff -NurpP --minimal linux-2.6.32.10/arch/parisc/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/Kconfig
626 --- linux-2.6.32.10/arch/parisc/Kconfig 2009-12-03 20:02:00.000000000 +0100
627 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/Kconfig 2009-12-03 20:04:56.000000000 +0100
628 @@ -294,6 +294,8 @@ source "fs/Kconfig"
630 source "arch/parisc/Kconfig.debug"
632 +source "kernel/vserver/Kconfig"
634 source "security/Kconfig"
636 source "crypto/Kconfig"
637 diff -NurpP --minimal linux-2.6.32.10/arch/parisc/kernel/syscall_table.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/kernel/syscall_table.S
638 --- linux-2.6.32.10/arch/parisc/kernel/syscall_table.S 2009-12-03 20:02:00.000000000 +0100
639 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/kernel/syscall_table.S 2009-12-03 20:04:56.000000000 +0100
641 ENTRY_COMP(mbind) /* 260 */
642 ENTRY_COMP(get_mempolicy)
643 ENTRY_COMP(set_mempolicy)
644 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
645 + ENTRY_DIFF(vserver)
647 ENTRY_SAME(request_key) /* 265 */
649 diff -NurpP --minimal linux-2.6.32.10/arch/parisc/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/kernel/traps.c
650 --- linux-2.6.32.10/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
651 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
652 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
656 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
657 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
658 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
659 + current->comm, task_pid_nr(current), current->xid,
660 + str, err, regs->iaoq[0]);
661 #ifdef PRINT_USER_FAULTS
662 /* XXX for debugging only */
664 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
665 pdc_console_restart();
668 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
669 - current->comm, task_pid_nr(current), str, err);
670 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
671 + current->comm, task_pid_nr(current), current->xid, str, err);
673 /* Wot's wrong wif bein' racy? */
674 if (current->thread.flags & PARISC_KERNEL_DEATH) {
675 diff -NurpP --minimal linux-2.6.32.10/arch/parisc/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/mm/fault.c
676 --- linux-2.6.32.10/arch/parisc/mm/fault.c 2009-09-10 15:25:40.000000000 +0200
677 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/parisc/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
678 @@ -237,8 +237,9 @@ bad_area:
680 #ifdef PRINT_USER_FAULTS
681 printk(KERN_DEBUG "\n");
682 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
683 - task_pid_nr(tsk), tsk->comm, code, address);
684 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
685 + "command='%s' type=%lu address=0x%08lx\n",
686 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
688 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
689 vma->vm_start, vma->vm_end);
690 @@ -264,7 +265,8 @@ no_context:
693 up_read(&mm->mmap_sem);
694 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
695 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
696 + current->comm, current->pid, current->xid);
698 do_group_exit(SIGKILL);
700 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/include/asm/unistd.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/include/asm/unistd.h
701 --- linux-2.6.32.10/arch/powerpc/include/asm/unistd.h 2009-12-03 20:02:01.000000000 +0100
702 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/include/asm/unistd.h 2009-12-03 20:04:56.000000000 +0100
705 #define __NR_rtas 255
706 #define __NR_sys_debug_setcontext 256
707 -/* Number 257 is reserved for vserver */
708 +#define __NR_vserver 257
709 #define __NR_migrate_pages 258
710 #define __NR_mbind 259
711 #define __NR_get_mempolicy 260
712 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/Kconfig
713 --- linux-2.6.32.10/arch/powerpc/Kconfig 2009-12-03 20:02:00.000000000 +0100
714 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/Kconfig 2009-12-03 20:04:56.000000000 +0100
715 @@ -943,6 +943,8 @@ source "lib/Kconfig"
717 source "arch/powerpc/Kconfig.debug"
719 +source "kernel/vserver/Kconfig"
721 source "security/Kconfig"
724 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/kernel/irq.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/irq.c
725 --- linux-2.6.32.10/arch/powerpc/kernel/irq.c 2009-12-03 20:02:01.000000000 +0100
726 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/irq.c 2009-12-03 20:04:56.000000000 +0100
728 #include <linux/pci.h>
729 #include <linux/debugfs.h>
730 #include <linux/perf_event.h>
731 +// #include <linux/vs_context.h>
733 #include <asm/uaccess.h>
734 #include <asm/system.h>
735 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/kernel/process.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/process.c
736 --- linux-2.6.32.10/arch/powerpc/kernel/process.c 2010-03-18 16:17:26.000000000 +0100
737 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/process.c 2010-02-12 10:59:55.000000000 +0100
738 @@ -519,8 +519,9 @@ void show_regs(struct pt_regs * regs)
740 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
742 - printk("TASK = %p[%d] '%s' THREAD: %p",
743 - current, task_pid_nr(current), current->comm, task_thread_info(current));
744 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
745 + current, task_pid_nr(current), current->xid,
746 + current->comm, task_thread_info(current));
749 printk(" CPU: %d", raw_smp_processor_id());
750 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/kernel/traps.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/traps.c
751 --- linux-2.6.32.10/arch/powerpc/kernel/traps.c 2009-09-10 15:25:41.000000000 +0200
752 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/traps.c 2009-12-03 20:04:56.000000000 +0100
753 @@ -931,8 +931,9 @@ void nonrecoverable_exception(struct pt_
755 void trace_syscall(struct pt_regs *regs)
757 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
758 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
759 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
760 + current, task_pid_nr(current), current->xid,
761 + regs->nip, regs->link, regs->gpr[0],
762 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
765 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/kernel/vdso.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/vdso.c
766 --- linux-2.6.32.10/arch/powerpc/kernel/vdso.c 2009-12-03 20:02:02.000000000 +0100
767 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/kernel/vdso.c 2009-12-03 20:04:56.000000000 +0100
769 #include <linux/security.h>
770 #include <linux/bootmem.h>
771 #include <linux/lmb.h>
772 +#include <linux/vs_memory.h>
774 #include <asm/pgtable.h>
775 #include <asm/system.h>
776 diff -NurpP --minimal linux-2.6.32.10/arch/powerpc/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/mm/fault.c
777 --- linux-2.6.32.10/arch/powerpc/mm/fault.c 2009-12-03 20:02:02.000000000 +0100
778 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/powerpc/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
779 @@ -358,7 +358,8 @@ out_of_memory:
780 down_read(&mm->mmap_sem);
783 - printk("VM: killing process %s\n", current->comm);
784 + printk("VM: killing process %s(%d:#%u)\n",
785 + current->comm, current->pid, current->xid);
787 do_group_exit(SIGKILL);
789 diff -NurpP --minimal linux-2.6.32.10/arch/s390/include/asm/tlb.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/include/asm/tlb.h
790 --- linux-2.6.32.10/arch/s390/include/asm/tlb.h 2009-09-10 15:25:43.000000000 +0200
791 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/include/asm/tlb.h 2009-12-31 14:37:21.000000000 +0100
794 #include <linux/mm.h>
795 #include <linux/swap.h>
796 +#include <linux/vs_memory.h>
798 #include <asm/processor.h>
799 #include <asm/pgalloc.h>
801 diff -NurpP --minimal linux-2.6.32.10/arch/s390/include/asm/unistd.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/include/asm/unistd.h
802 --- linux-2.6.32.10/arch/s390/include/asm/unistd.h 2009-12-03 20:02:03.000000000 +0100
803 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/include/asm/unistd.h 2009-12-30 00:58:47.000000000 +0100
805 #define __NR_clock_gettime (__NR_timer_create+6)
806 #define __NR_clock_getres (__NR_timer_create+7)
807 #define __NR_clock_nanosleep (__NR_timer_create+8)
808 -/* Number 263 is reserved for vserver */
809 +#define __NR_vserver 263
810 #define __NR_statfs64 265
811 #define __NR_fstatfs64 266
812 #define __NR_remap_file_pages 267
813 diff -NurpP --minimal linux-2.6.32.10/arch/s390/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/Kconfig
814 --- linux-2.6.32.10/arch/s390/Kconfig 2009-12-03 20:02:03.000000000 +0100
815 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/Kconfig 2009-12-03 20:04:56.000000000 +0100
816 @@ -616,6 +616,8 @@ source "fs/Kconfig"
818 source "arch/s390/Kconfig.debug"
820 +source "kernel/vserver/Kconfig"
822 source "security/Kconfig"
824 source "crypto/Kconfig"
825 diff -NurpP --minimal linux-2.6.32.10/arch/s390/kernel/ptrace.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/kernel/ptrace.c
826 --- linux-2.6.32.10/arch/s390/kernel/ptrace.c 2009-12-03 20:02:03.000000000 +0100
827 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
829 #include <linux/regset.h>
830 #include <linux/tracehook.h>
831 #include <linux/seccomp.h>
832 +#include <linux/vs_base.h>
833 #include <trace/syscall.h>
834 #include <asm/compat.h>
835 #include <asm/segment.h>
836 diff -NurpP --minimal linux-2.6.32.10/arch/s390/kernel/syscalls.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/kernel/syscalls.S
837 --- linux-2.6.32.10/arch/s390/kernel/syscalls.S 2009-12-03 20:02:03.000000000 +0100
838 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/kernel/syscalls.S 2009-12-03 20:04:56.000000000 +0100
839 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
840 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
841 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
842 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
843 -NI_SYSCALL /* reserved for vserver */
844 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
845 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
846 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
847 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
848 diff -NurpP --minimal linux-2.6.32.10/arch/s390/lib/uaccess_pt.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/lib/uaccess_pt.c
849 --- linux-2.6.32.10/arch/s390/lib/uaccess_pt.c 2009-09-10 15:25:43.000000000 +0200
850 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/s390/lib/uaccess_pt.c 2009-12-03 20:04:56.000000000 +0100
851 @@ -90,7 +90,8 @@ out_of_memory:
852 down_read(&mm->mmap_sem);
855 - printk("VM: killing process %s\n", current->comm);
856 + printk("VM: killing process %s(%d:#%u)\n",
857 + current->comm, task_pid_nr(current), current->xid);
861 diff -NurpP --minimal linux-2.6.32.10/arch/sh/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/Kconfig
862 --- linux-2.6.32.10/arch/sh/Kconfig 2009-12-03 20:02:03.000000000 +0100
863 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/Kconfig 2009-12-03 20:04:56.000000000 +0100
864 @@ -853,6 +853,8 @@ source "fs/Kconfig"
866 source "arch/sh/Kconfig.debug"
868 +source "kernel/vserver/Kconfig"
870 source "security/Kconfig"
872 source "crypto/Kconfig"
873 diff -NurpP --minimal linux-2.6.32.10/arch/sh/kernel/irq.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/kernel/irq.c
874 --- linux-2.6.32.10/arch/sh/kernel/irq.c 2009-12-03 20:02:10.000000000 +0100
875 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/kernel/irq.c 2009-12-03 20:04:56.000000000 +0100
877 #include <linux/kernel_stat.h>
878 #include <linux/seq_file.h>
879 #include <linux/ftrace.h>
880 +// #include <linux/vs_context.h>
881 #include <asm/processor.h>
882 #include <asm/machvec.h>
883 #include <asm/uaccess.h>
884 diff -NurpP --minimal linux-2.6.32.10/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/kernel/vsyscall/vsyscall.c
885 --- linux-2.6.32.10/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:18:42.000000000 +0100
886 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/kernel/vsyscall/vsyscall.c 2009-12-03 20:04:56.000000000 +0100
888 #include <linux/elf.h>
889 #include <linux/sched.h>
890 #include <linux/err.h>
891 +#include <linux/vs_memory.h>
894 * Should the kernel map a VDSO page into processes and pass its
895 diff -NurpP --minimal linux-2.6.32.10/arch/sh/mm/fault_32.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/mm/fault_32.c
896 --- linux-2.6.32.10/arch/sh/mm/fault_32.c 2009-12-03 20:02:14.000000000 +0100
897 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/mm/fault_32.c 2009-12-03 20:04:56.000000000 +0100
898 @@ -292,7 +292,8 @@ out_of_memory:
899 down_read(&mm->mmap_sem);
902 - printk("VM: killing process %s\n", tsk->comm);
903 + printk("VM: killing process %s(%d:#%u)\n",
904 + tsk->comm, task_pid_nr(tsk), tsk->xid);
906 do_group_exit(SIGKILL);
908 diff -NurpP --minimal linux-2.6.32.10/arch/sh/mm/tlbflush_64.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/mm/tlbflush_64.c
909 --- linux-2.6.32.10/arch/sh/mm/tlbflush_64.c 2009-12-03 20:02:14.000000000 +0100
910 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sh/mm/tlbflush_64.c 2009-12-03 20:04:56.000000000 +0100
911 @@ -306,7 +306,8 @@ out_of_memory:
912 down_read(&mm->mmap_sem);
915 - printk("VM: killing process %s\n", tsk->comm);
916 + printk("VM: killing process %s(%d:#%u)\n",
917 + tsk->comm, task_pid_nr(tsk), tsk->xid);
919 do_group_exit(SIGKILL);
921 diff -NurpP --minimal linux-2.6.32.10/arch/sparc/include/asm/tlb_64.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/include/asm/tlb_64.h
922 --- linux-2.6.32.10/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
923 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/include/asm/tlb_64.h 2009-12-03 20:04:56.000000000 +0100
926 #include <linux/swap.h>
927 #include <linux/pagemap.h>
928 +#include <linux/vs_memory.h>
929 #include <asm/pgalloc.h>
930 #include <asm/tlbflush.h>
931 #include <asm/mmu_context.h>
932 diff -NurpP --minimal linux-2.6.32.10/arch/sparc/include/asm/unistd.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/include/asm/unistd.h
933 --- linux-2.6.32.10/arch/sparc/include/asm/unistd.h 2009-12-03 20:02:15.000000000 +0100
934 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/include/asm/unistd.h 2009-12-03 20:04:56.000000000 +0100
936 #define __NR_timer_getoverrun 264
937 #define __NR_timer_delete 265
938 #define __NR_timer_create 266
939 -/* #define __NR_vserver 267 Reserved for VSERVER */
940 +#define __NR_vserver 267
941 #define __NR_io_setup 268
942 #define __NR_io_destroy 269
943 #define __NR_io_submit 270
944 diff -NurpP --minimal linux-2.6.32.10/arch/sparc/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/Kconfig
945 --- linux-2.6.32.10/arch/sparc/Kconfig 2009-12-03 20:02:14.000000000 +0100
946 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/Kconfig 2009-12-03 20:04:56.000000000 +0100
947 @@ -550,6 +550,8 @@ source "fs/Kconfig"
949 source "arch/sparc/Kconfig.debug"
951 +source "kernel/vserver/Kconfig"
953 source "security/Kconfig"
955 source "crypto/Kconfig"
956 diff -NurpP --minimal linux-2.6.32.10/arch/sparc/kernel/systbls_32.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/kernel/systbls_32.S
957 --- linux-2.6.32.10/arch/sparc/kernel/systbls_32.S 2010-03-18 16:17:27.000000000 +0100
958 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/kernel/systbls_32.S 2010-01-20 04:21:33.000000000 +0100
959 @@ -70,7 +70,7 @@ sys_call_table:
960 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
961 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
962 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
963 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
964 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
965 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
966 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
967 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
968 diff -NurpP --minimal linux-2.6.32.10/arch/sparc/kernel/systbls_64.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/kernel/systbls_64.S
969 --- linux-2.6.32.10/arch/sparc/kernel/systbls_64.S 2010-03-18 16:17:27.000000000 +0100
970 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/sparc/kernel/systbls_64.S 2010-01-20 04:21:33.000000000 +0100
971 @@ -71,7 +71,7 @@ sys_call_table32:
972 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
973 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
974 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
975 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
976 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
977 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
978 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
979 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
980 @@ -146,7 +146,7 @@ sys_call_table:
981 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
982 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
983 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
984 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
985 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
986 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
987 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
988 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
989 diff -NurpP --minimal linux-2.6.32.10/arch/um/include/asm/tlb.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/um/include/asm/tlb.h
990 --- linux-2.6.32.10/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
991 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/um/include/asm/tlb.h 2010-03-13 21:49:04.000000000 +0100
994 #include <linux/pagemap.h>
995 #include <linux/swap.h>
996 +#include <linux/vs_memory.h>
997 #include <asm/percpu.h>
998 #include <asm/pgalloc.h>
999 #include <asm/tlbflush.h>
1000 diff -NurpP --minimal linux-2.6.32.10/arch/um/Kconfig.rest linux-2.6.32.10-vs2.3.0.36.29.2/arch/um/Kconfig.rest
1001 --- linux-2.6.32.10/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
1002 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/um/Kconfig.rest 2010-03-13 21:49:04.000000000 +0100
1003 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
1007 +source "kernel/vserver/Kconfig"
1009 source "security/Kconfig"
1011 source "crypto/Kconfig"
1012 diff -NurpP --minimal linux-2.6.32.10/arch/x86/ia32/ia32entry.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/ia32/ia32entry.S
1013 --- linux-2.6.32.10/arch/x86/ia32/ia32entry.S 2010-03-18 16:17:27.000000000 +0100
1014 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/ia32/ia32entry.S 2010-01-20 04:21:33.000000000 +0100
1015 @@ -777,7 +777,7 @@ ia32_sys_call_table:
1016 .quad sys_tgkill /* 270 */
1017 .quad compat_sys_utimes
1018 .quad sys32_fadvise64_64
1019 - .quad quiet_ni_syscall /* sys_vserver */
1020 + .quad sys32_vserver
1022 .quad compat_sys_get_mempolicy /* 275 */
1023 .quad sys_set_mempolicy
1024 diff -NurpP --minimal linux-2.6.32.10/arch/x86/include/asm/unistd_64.h linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/include/asm/unistd_64.h
1025 --- linux-2.6.32.10/arch/x86/include/asm/unistd_64.h 2009-12-03 20:02:16.000000000 +0100
1026 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/include/asm/unistd_64.h 2009-12-03 20:04:56.000000000 +0100
1027 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
1028 #define __NR_utimes 235
1029 __SYSCALL(__NR_utimes, sys_utimes)
1030 #define __NR_vserver 236
1031 -__SYSCALL(__NR_vserver, sys_ni_syscall)
1032 +__SYSCALL(__NR_vserver, sys_vserver)
1033 #define __NR_mbind 237
1034 __SYSCALL(__NR_mbind, sys_mbind)
1035 #define __NR_set_mempolicy 238
1036 diff -NurpP --minimal linux-2.6.32.10/arch/x86/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/Kconfig
1037 --- linux-2.6.32.10/arch/x86/Kconfig 2010-03-18 16:17:27.000000000 +0100
1038 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/Kconfig 2010-02-12 10:59:55.000000000 +0100
1039 @@ -2079,6 +2079,8 @@ source "fs/Kconfig"
1041 source "arch/x86/Kconfig.debug"
1043 +source "kernel/vserver/Kconfig"
1045 source "security/Kconfig"
1047 source "crypto/Kconfig"
1048 diff -NurpP --minimal linux-2.6.32.10/arch/x86/kernel/syscall_table_32.S linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/kernel/syscall_table_32.S
1049 --- linux-2.6.32.10/arch/x86/kernel/syscall_table_32.S 2010-03-18 16:17:27.000000000 +0100
1050 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/x86/kernel/syscall_table_32.S 2010-01-20 04:21:33.000000000 +0100
1051 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1052 .long sys_tgkill /* 270 */
1054 .long sys_fadvise64_64
1055 - .long sys_ni_syscall /* sys_vserver */
1058 .long sys_get_mempolicy
1059 .long sys_set_mempolicy
1060 diff -NurpP --minimal linux-2.6.32.10/arch/xtensa/mm/fault.c linux-2.6.32.10-vs2.3.0.36.29.2/arch/xtensa/mm/fault.c
1061 --- linux-2.6.32.10/arch/xtensa/mm/fault.c 2009-09-10 15:25:48.000000000 +0200
1062 +++ linux-2.6.32.10-vs2.3.0.36.29.2/arch/xtensa/mm/fault.c 2009-12-03 20:04:56.000000000 +0100
1063 @@ -151,7 +151,8 @@ out_of_memory:
1064 down_read(&mm->mmap_sem);
1067 - printk("VM: killing process %s\n", current->comm);
1068 + printk("VM: killing process %s(%d:#%u)\n",
1069 + current->comm, task_pid_nr(current), current->xid);
1070 if (user_mode(regs))
1071 do_group_exit(SIGKILL);
1072 bad_page_fault(regs, address, SIGKILL);
1073 diff -NurpP --minimal linux-2.6.32.10/Documentation/scheduler/sched-cfs-hard-limits.txt linux-2.6.32.10-vs2.3.0.36.29.2/Documentation/scheduler/sched-cfs-hard-limits.txt
1074 --- linux-2.6.32.10/Documentation/scheduler/sched-cfs-hard-limits.txt 1970-01-01 01:00:00.000000000 +0100
1075 +++ linux-2.6.32.10-vs2.3.0.36.29.2/Documentation/scheduler/sched-cfs-hard-limits.txt 2009-12-03 20:04:56.000000000 +0100
1077 +CPU HARD LIMITS FOR CFS GROUPS
1078 +==============================
1087 +CFS is a proportional share scheduler which tries to divide the CPU time
1088 +proportionately between tasks or groups of tasks (task group/cgroup) depending
1089 +on the priority/weight of the task or shares assigned to groups of tasks.
1090 +In CFS, a task/task group can get more than its share of CPU if there are
1091 +enough idle CPU cycles available in the system, due to the work conserving
1092 +nature of the scheduler. However in certain scenarios (like pay-per-use),
1093 +it is desirable not to provide extra time to a group even in the presence
1094 +of idle CPU cycles. This is where hard limiting can be of use.
1096 +Hard limits for task groups can be set by specifying how much CPU runtime a
1097 +group can consume within a given period. If the group consumes more CPU time
1098 +than the runtime in a given period, it gets throttled. None of the tasks of
1099 +the throttled group gets to run until the runtime of the group gets refreshed
1100 +at the beginning of the next period.
1105 +Hard limit feature adds 2 cgroup files for CFS group scheduler:
1107 +cfs_runtime_us: Hard limit for the group in microseconds.
1109 +cfs_period_us: Time period in microseconds within which hard limits is
1112 +A group gets created with default values for runtime (infinite runtime which
1113 +means hard limits disabled) and period (0.5s). Each group can set its own
1114 +values for runtime and period independent of other groups in the system.
1119 +# mount -t cgroup -ocpu none /cgroups/
1123 +# echo 250000 > cfs_runtime_us /* set a 250ms runtime or limit */
1124 +# echo 500000 > cfs_period_us /* set a 500ms period */
1125 diff -NurpP --minimal linux-2.6.32.10/Documentation/vserver/debug.txt linux-2.6.32.10-vs2.3.0.36.29.2/Documentation/vserver/debug.txt
1126 --- linux-2.6.32.10/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1127 +++ linux-2.6.32.10-vs2.3.0.36.29.2/Documentation/vserver/debug.txt 2009-12-03 20:04:56.000000000 +0100
1132 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1133 + "vx_rmap_tgid: %p/%llx: %d -> %d"
1137 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
1138 + "FREE (%p,#%d)%c inode"
1139 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1140 + "FREE (%p,#%d)%c %lld bytes"
1141 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1142 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1143 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1144 + "rcu_free_dl_info(%p)"
1145 + 4 10 "alloc_dl_info(%p,%d) = %p"
1146 + "dealloc_dl_info(%p)"
1147 + "get_dl_info(%p[#%d.%d])"
1148 + "put_dl_info(%p[#%d.%d])"
1149 + 5 20 "alloc_dl_info(%p,%d)*"
1150 + 6 40 "__hash_dl_info: %p[#%d]"
1151 + "__unhash_dl_info: %p[#%d]"
1152 + 7 80 "locate_dl_info(%p,#%d) = %p"
1156 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
1157 + "new_dqhash: %p [#0x%08x]"
1158 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1159 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1160 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1161 + "vroot_get_real_bdev not set"
1162 + 1 2 "cow_break_link(»%s«)"
1163 + "temp copy »%s«"
1164 + 2 4 "dentry_open(new): %p"
1165 + "dentry_open(old): %p"
1166 + "lookup_create(new): %p"
1168 + "path_lookup(old): %d"
1169 + "vfs_create(new): %d"
1171 + "vfs_sendfile: %d"
1172 + 3 8 "fput(new_file=%p[#%d])"
1173 + "fput(old_file=%p[#%d])"
1174 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1175 + "vx_info_kill(%p[#%d],%d,%d)*"
1176 + 5 20 "vs_reboot(%p[#%d],%d)"
1177 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1181 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1182 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1183 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
1184 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
1185 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
1186 + 6 40 "sk,egf: %p [#%d] (from %d)"
1187 + "sk,egn: %p [#%d] (from %d)"
1188 + "sk,req: %p [#%d] (from %d)"
1189 + "sk: %p [#%d] (from %d)"
1190 + "tw: %p [#%d] (from %d)"
1191 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
1192 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
1196 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
1197 + "alloc_nx_info(%d) = %p"
1198 + "create_nx_info(%d) (dynamic rejected)"
1199 + "create_nx_info(%d) = %p (already there)"
1200 + "create_nx_info(%d) = %p (new)"
1201 + "dealloc_nx_info(%p)"
1202 + 1 2 "alloc_nx_info(%d)*"
1203 + "create_nx_info(%d)*"
1204 + 2 4 "get_nx_info(%p[#%d.%d])"
1205 + "put_nx_info(%p[#%d.%d])"
1206 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1207 + "clr_nx_info(%p[#%d.%d])"
1208 + "init_nx_info(%p[#%d.%d])"
1209 + "release_nx_info(%p[#%d.%d.%d]) %p"
1210 + "set_nx_info(%p[#%d.%d])"
1211 + 4 10 "__hash_nx_info: %p[#%d]"
1212 + "__nx_dynamic_id: [#%d]"
1213 + "__unhash_nx_info: %p[#%d.%d.%d]"
1214 + 5 20 "moved task %p into nxi:%p[#%d]"
1215 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
1216 + "task_get_nx_info(%p)"
1217 + 6 40 "nx_clear_persistent(%p[#%d])"
1221 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
1222 + 1 2 "quota_sync_dqh(%p,%d)"
1223 + "sync_dquots(%p,%d)"
1224 + "sync_dquots_dqh(%p,%d)"
1225 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1229 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1230 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1231 + 4 10 "%s: (%s %s) returned %s with %d"
1235 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1236 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1240 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1241 + "alloc_vx_info(%d) = %p"
1242 + "alloc_vx_info(%d)*"
1243 + "create_vx_info(%d) (dynamic rejected)"
1244 + "create_vx_info(%d) = %p (already there)"
1245 + "create_vx_info(%d) = %p (new)"
1246 + "dealloc_vx_info(%p)"
1247 + "loc_vx_info(%d) = %p (found)"
1248 + "loc_vx_info(%d) = %p (new)"
1249 + "loc_vx_info(%d) = %p (not available)"
1250 + 1 2 "create_vx_info(%d)*"
1251 + "loc_vx_info(%d)*"
1252 + 2 4 "get_vx_info(%p[#%d.%d])"
1253 + "put_vx_info(%p[#%d.%d])"
1254 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1255 + "clr_vx_info(%p[#%d.%d])"
1256 + "init_vx_info(%p[#%d.%d])"
1257 + "release_vx_info(%p[#%d.%d.%d]) %p"
1258 + "set_vx_info(%p[#%d.%d])"
1259 + 4 10 "__hash_vx_info: %p[#%d]"
1260 + "__unhash_vx_info: %p[#%d.%d.%d]"
1261 + "__vx_dynamic_id: [#%d]"
1262 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1263 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1264 + "moved task %p into vxi:%p[#%d]"
1265 + "task_get_vx_info(%p)"
1266 + "vx_migrate_task(%p,%p[#%d.%d])"
1267 + 6 40 "vx_clear_persistent(%p[#%d])"
1268 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1269 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1270 + "vx_set_persistent(%p[#%d])"
1271 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1272 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1277 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1278 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1280 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1281 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1282 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1283 diff -NurpP --minimal linux-2.6.32.10/drivers/block/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/Kconfig
1284 --- linux-2.6.32.10/drivers/block/Kconfig 2009-09-10 15:25:49.000000000 +0200
1285 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/Kconfig 2009-12-03 20:04:56.000000000 +0100
1286 @@ -271,6 +271,13 @@ config BLK_DEV_CRYPTOLOOP
1287 instead, which can be configured to be on-disk compatible with the
1290 +config BLK_DEV_VROOT
1291 + tristate "Virtual Root device support"
1292 + depends on QUOTACTL
1294 + Saying Y here will allow you to use quota/fs ioctls on a shared
1295 + partition within a virtual server without compromising security.
1298 tristate "Network block device support"
1300 diff -NurpP --minimal linux-2.6.32.10/drivers/block/loop.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/loop.c
1301 --- linux-2.6.32.10/drivers/block/loop.c 2009-12-03 20:02:19.000000000 +0100
1302 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/loop.c 2009-12-03 20:04:56.000000000 +0100
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 @@ -812,6 +813,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 @@ -937,6 +939,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 @@ -971,7 +974,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 @@ -1055,7 +1058,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 @@ -1399,6 +1403,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.10/drivers/block/Makefile linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/Makefile
1357 --- linux-2.6.32.10/drivers/block/Makefile 2009-09-10 15:25:49.000000000 +0200
1358 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/Makefile 2009-12-03 20:04:56.000000000 +0100
1359 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1360 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1361 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1362 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1363 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1365 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1367 diff -NurpP --minimal linux-2.6.32.10/drivers/block/vroot.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/vroot.c
1368 --- linux-2.6.32.10/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1369 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/block/vroot.c 2009-12-03 20:04:56.000000000 +0100
1372 + * linux/drivers/block/vroot.c
1374 + * written by Herbert Pötzl, 9/11/2002
1375 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1377 + * based on the loop.c code by Theodore Ts'o.
1379 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1380 + * Redistribution of this file is permitted under the
1381 + * GNU General Public License.
1385 +#include <linux/module.h>
1386 +#include <linux/moduleparam.h>
1387 +#include <linux/file.h>
1388 +#include <linux/major.h>
1389 +#include <linux/blkdev.h>
1391 +#include <linux/vroot.h>
1392 +#include <linux/vs_context.h>
1395 +static int max_vroot = 8;
1397 +static struct vroot_device *vroot_dev;
1398 +static struct gendisk **disks;
1401 +static int vroot_set_dev(
1402 + struct vroot_device *vr,
1403 + struct block_device *bdev,
1406 + struct block_device *real_bdev;
1407 + struct file *file;
1408 + struct inode *inode;
1412 + if (vr->vr_state != Vr_unbound)
1421 + inode = file->f_dentry->d_inode;
1424 + if (S_ISBLK(inode->i_mode)) {
1425 + real_bdev = inode->i_bdev;
1426 + vr->vr_device = real_bdev;
1427 + __iget(real_bdev->bd_inode);
1431 + vxdprintk(VXD_CBIT(misc, 0),
1432 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1433 + vr->vr_number, VXD_DEV(real_bdev));
1435 + vr->vr_state = Vr_bound;
1444 +static int vroot_clr_dev(
1445 + struct vroot_device *vr,
1446 + struct block_device *bdev)
1448 + struct block_device *real_bdev;
1450 + if (vr->vr_state != Vr_bound)
1452 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1455 + real_bdev = vr->vr_device;
1457 + vxdprintk(VXD_CBIT(misc, 0),
1458 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1459 + vr->vr_number, VXD_DEV(real_bdev));
1462 + vr->vr_state = Vr_unbound;
1463 + vr->vr_device = NULL;
1468 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1469 + unsigned int cmd, unsigned long arg)
1471 + struct vroot_device *vr = bdev->bd_disk->private_data;
1474 + down(&vr->vr_ctl_mutex);
1476 + case VROOT_SET_DEV:
1477 + err = vroot_set_dev(vr, bdev, arg);
1479 + case VROOT_CLR_DEV:
1480 + err = vroot_clr_dev(vr, bdev);
1486 + up(&vr->vr_ctl_mutex);
1490 +static int vr_open(struct block_device *bdev, fmode_t mode)
1492 + struct vroot_device *vr = bdev->bd_disk->private_data;
1494 + down(&vr->vr_ctl_mutex);
1496 + up(&vr->vr_ctl_mutex);
1500 +static int vr_release(struct gendisk *disk, fmode_t mode)
1502 + struct vroot_device *vr = disk->private_data;
1504 + down(&vr->vr_ctl_mutex);
1506 + up(&vr->vr_ctl_mutex);
1510 +static struct block_device_operations vr_fops = {
1511 + .owner = THIS_MODULE,
1513 + .release = vr_release,
1514 + .ioctl = vr_ioctl,
1517 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1519 + struct inode *inode = bdev->bd_inode;
1520 + struct vroot_device *vr;
1521 + struct block_device *real_bdev;
1522 + int minor = iminor(inode);
1524 + vr = &vroot_dev[minor];
1525 + real_bdev = vr->vr_device;
1527 + vxdprintk(VXD_CBIT(misc, 0),
1528 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1529 + vr->vr_number, VXD_DEV(real_bdev));
1531 + if (vr->vr_state != Vr_bound)
1532 + return ERR_PTR(-ENXIO);
1534 + __iget(real_bdev->bd_inode);
1539 + * And now the modules code and kernel interface.
1542 +module_param(max_vroot, int, 0);
1544 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1545 +MODULE_LICENSE("GPL");
1546 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1548 +MODULE_AUTHOR ("Herbert Pötzl");
1549 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1552 +int __init vroot_init(void)
1556 + if (max_vroot < 1 || max_vroot > 256) {
1557 + max_vroot = MAX_VROOT_DEFAULT;
1558 + printk(KERN_WARNING "vroot: invalid max_vroot "
1559 + "(must be between 1 and 256), "
1560 + "using default (%d)\n", max_vroot);
1563 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1567 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1570 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1572 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1576 + for (i = 0; i < max_vroot; i++) {
1577 + disks[i] = alloc_disk(1);
1580 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1581 + if (!disks[i]->queue)
1585 + for (i = 0; i < max_vroot; i++) {
1586 + struct vroot_device *vr = &vroot_dev[i];
1587 + struct gendisk *disk = disks[i];
1589 + memset(vr, 0, sizeof(*vr));
1590 + init_MUTEX(&vr->vr_ctl_mutex);
1591 + vr->vr_number = i;
1592 + disk->major = VROOT_MAJOR;
1593 + disk->first_minor = i;
1594 + disk->fops = &vr_fops;
1595 + sprintf(disk->disk_name, "vroot%d", i);
1596 + disk->private_data = vr;
1599 + err = register_vroot_grb(&__vroot_get_real_bdev);
1603 + for (i = 0; i < max_vroot; i++)
1604 + add_disk(disks[i]);
1605 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1610 + put_disk(disks[i]);
1615 + unregister_blkdev(VROOT_MAJOR, "vroot");
1616 + printk(KERN_ERR "vroot: ran out of memory\n");
1620 +void vroot_exit(void)
1624 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1625 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1627 + for (i = 0; i < max_vroot; i++) {
1628 + del_gendisk(disks[i]);
1629 + put_disk(disks[i]);
1631 + unregister_blkdev(VROOT_MAJOR, "vroot");
1637 +module_init(vroot_init);
1638 +module_exit(vroot_exit);
1642 +static int __init max_vroot_setup(char *str)
1644 + max_vroot = simple_strtol(str, NULL, 0);
1648 +__setup("max_vroot=", max_vroot_setup);
1652 diff -NurpP --minimal linux-2.6.32.10/drivers/char/sysrq.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/char/sysrq.c
1653 --- linux-2.6.32.10/drivers/char/sysrq.c 2009-12-03 20:02:20.000000000 +0100
1654 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/char/sysrq.c 2009-12-03 20:04:56.000000000 +0100
1656 #include <linux/workqueue.h>
1657 #include <linux/hrtimer.h>
1658 #include <linux/oom.h>
1659 +#include <linux/vserver/debug.h>
1661 #include <asm/ptrace.h>
1662 #include <asm/irq_regs.h>
1663 @@ -391,6 +392,21 @@ static struct sysrq_key_op sysrq_unrt_op
1664 .enable_mask = SYSRQ_ENABLE_RTNICE,
1668 +#ifdef CONFIG_VSERVER_DEBUG
1669 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1671 + dump_vx_info_inactive((key == 'x')?0:1);
1674 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1675 + .handler = sysrq_handle_vxinfo,
1676 + .help_msg = "conteXt",
1677 + .action_msg = "Show Context Info",
1678 + .enable_mask = SYSRQ_ENABLE_DUMP,
1682 /* Key Operations table and lock */
1683 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1685 @@ -445,7 +461,11 @@ static struct sysrq_key_op *sysrq_key_ta
1687 &sysrq_showstate_blocked_op, /* w */
1688 /* x: May be registered on ppc/powerpc for xmon */
1689 +#ifdef CONFIG_VSERVER_DEBUG
1690 + &sysrq_showvxinfo_op, /* x */
1694 /* y: May be registered on sparc64 for global register dump */
1696 &sysrq_ftrace_dump_op, /* z */
1697 @@ -460,6 +480,8 @@ static int sysrq_key_table_key2index(int
1699 else if ((key >= 'a') && (key <= 'z'))
1700 retval = key + 10 - 'a';
1701 + else if ((key >= 'A') && (key <= 'Z'))
1702 + retval = key + 10 - 'A';
1706 diff -NurpP --minimal linux-2.6.32.10/drivers/char/tty_io.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/char/tty_io.c
1707 --- linux-2.6.32.10/drivers/char/tty_io.c 2010-03-18 16:17:28.000000000 +0100
1708 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/char/tty_io.c 2010-02-24 12:32:54.000000000 +0100
1711 #include <linux/kmod.h>
1712 #include <linux/nsproxy.h>
1713 +#include <linux/vs_pid.h>
1715 #undef TTY_DEBUG_HANGUP
1717 @@ -1968,7 +1969,8 @@ static int tiocsti(struct tty_struct *tt
1719 struct tty_ldisc *ld;
1721 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1722 + if (((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) ||
1723 + !vx_ccaps(VXC_TIOCSTI))
1725 if (get_user(ch, p))
1727 @@ -2256,6 +2258,7 @@ static int tiocspgrp(struct tty_struct *
1729 if (get_user(pgrp_nr, p))
1731 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1735 diff -NurpP --minimal linux-2.6.32.10/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/infiniband/hw/ipath/ipath_user_pages.c
1736 --- linux-2.6.32.10/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-03 20:02:23.000000000 +0100
1737 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-04 23:31:17.000000000 +0100
1739 #include <linux/mm.h>
1740 #include <linux/device.h>
1741 #include <linux/sched.h>
1742 +#include <linux/vs_memory.h>
1744 #include "ipath_kernel.h"
1746 @@ -62,7 +63,8 @@ static int __get_user_pages(unsigned lon
1747 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1750 - if (num_pages > lock_limit) {
1751 + if (num_pages > lock_limit ||
1752 + !vx_vmlocked_avail(current->mm, num_pages)) {
1756 @@ -79,7 +81,7 @@ static int __get_user_pages(unsigned lon
1760 - current->mm->locked_vm += num_pages;
1761 + vx_vmlocked_add(current->mm, num_pages);
1765 @@ -178,7 +180,7 @@ void ipath_release_user_pages(struct pag
1767 __ipath_release_user_pages(p, num_pages, 1);
1769 - current->mm->locked_vm -= num_pages;
1770 + vx_vmlocked_sub(current->mm, num_pages);
1772 up_write(¤t->mm->mmap_sem);
1774 @@ -195,7 +197,7 @@ static void user_pages_account(struct wo
1775 container_of(_work, struct ipath_user_pages_work, work);
1777 down_write(&work->mm->mmap_sem);
1778 - work->mm->locked_vm -= work->num_pages;
1779 + vx_vmlocked_sub(work->mm, work->num_pages);
1780 up_write(&work->mm->mmap_sem);
1783 diff -NurpP --minimal linux-2.6.32.10/drivers/md/dm.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/md/dm.c
1784 --- linux-2.6.32.10/drivers/md/dm.c 2010-03-18 16:17:29.000000000 +0100
1785 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/md/dm.c 2010-03-18 16:53:05.000000000 +0100
1787 #include <linux/slab.h>
1788 #include <linux/idr.h>
1789 #include <linux/hdreg.h>
1790 +#include <linux/vs_base.h>
1792 #include <trace/events/block.h>
1794 @@ -119,6 +120,7 @@ struct mapped_device {
1797 atomic_t open_count;
1800 unsigned long flags;
1802 @@ -323,6 +325,7 @@ static void __exit dm_exit(void)
1803 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1805 struct mapped_device *md;
1808 spin_lock(&_minor_lock);
1810 @@ -331,18 +334,19 @@ static int dm_blk_open(struct block_devi
1813 if (test_bit(DMF_FREEING, &md->flags) ||
1814 - test_bit(DMF_DELETING, &md->flags)) {
1816 + test_bit(DMF_DELETING, &md->flags))
1820 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1825 atomic_inc(&md->open_count);
1829 spin_unlock(&_minor_lock);
1831 - return md ? 0 : -ENXIO;
1835 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1836 @@ -553,6 +557,14 @@ int dm_set_geometry(struct mapped_device
1841 + * Get the xid associated with a dm device
1843 +xid_t dm_get_xid(struct mapped_device *md)
1848 /*-----------------------------------------------------------------
1850 * A more elegant soln is in the works that uses the queue
1851 @@ -1762,6 +1774,7 @@ static struct mapped_device *alloc_dev(i
1852 INIT_LIST_HEAD(&md->uevent_list);
1853 spin_lock_init(&md->uevent_lock);
1855 + md->xid = vx_current_xid();
1856 md->queue = blk_init_queue(dm_request_fn, NULL);
1859 diff -NurpP --minimal linux-2.6.32.10/drivers/md/dm.h linux-2.6.32.10-vs2.3.0.36.29.2/drivers/md/dm.h
1860 --- linux-2.6.32.10/drivers/md/dm.h 2009-09-10 15:25:55.000000000 +0200
1861 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/md/dm.h 2009-12-03 20:04:56.000000000 +0100
1862 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1864 struct dm_md_mempools;
1866 +xid_t dm_get_xid(struct mapped_device *md);
1868 /*-----------------------------------------------------------------
1869 * Internal table functions.
1870 *---------------------------------------------------------------*/
1871 diff -NurpP --minimal linux-2.6.32.10/drivers/md/dm-ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/md/dm-ioctl.c
1872 --- linux-2.6.32.10/drivers/md/dm-ioctl.c 2010-03-18 16:17:29.000000000 +0100
1873 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/md/dm-ioctl.c 2009-12-29 00:36:25.000000000 +0100
1875 #include <linux/dm-ioctl.h>
1876 #include <linux/hdreg.h>
1877 #include <linux/compat.h>
1878 +#include <linux/vs_context.h>
1880 #include <asm/uaccess.h>
1882 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1883 unsigned int h = hash_str(str);
1885 list_for_each_entry (hc, _name_buckets + h, name_list)
1886 - if (!strcmp(hc->name, str)) {
1887 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1888 + !strcmp(hc->name, str)) {
1892 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1893 unsigned int h = hash_str(str);
1895 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1896 - if (!strcmp(hc->uuid, str)) {
1897 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1898 + !strcmp(hc->uuid, str)) {
1902 @@ -363,6 +366,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1904 static int remove_all(struct dm_ioctl *param, size_t param_size)
1906 + if (!vx_check(0, VS_ADMIN))
1909 dm_hash_remove_all(1);
1910 param->data_size = 0;
1912 @@ -410,6 +416,8 @@ static int list_devices(struct dm_ioctl
1914 for (i = 0; i < NUM_BUCKETS; i++) {
1915 list_for_each_entry (hc, _name_buckets + i, name_list) {
1916 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1918 needed += sizeof(struct dm_name_list);
1919 needed += strlen(hc->name) + 1;
1920 needed += ALIGN_MASK;
1921 @@ -433,6 +441,8 @@ static int list_devices(struct dm_ioctl
1923 for (i = 0; i < NUM_BUCKETS; i++) {
1924 list_for_each_entry (hc, _name_buckets + i, name_list) {
1925 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1928 old_nl->next = (uint32_t) ((void *) nl -
1930 @@ -623,10 +633,11 @@ static struct hash_cell *__find_device_h
1934 - mdptr = dm_get_mdptr(md);
1935 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1936 + mdptr = dm_get_mdptr(md);
1944 @@ -1456,8 +1467,8 @@ static int ctl_ioctl(uint command, struc
1948 - /* only root can play with this */
1949 - if (!capable(CAP_SYS_ADMIN))
1950 + /* only root and certain contexts can play with this */
1951 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1954 if (_IOC_TYPE(command) != DM_IOCTL)
1955 diff -NurpP --minimal linux-2.6.32.10/drivers/net/tun.c linux-2.6.32.10-vs2.3.0.36.29.2/drivers/net/tun.c
1956 --- linux-2.6.32.10/drivers/net/tun.c 2009-12-03 20:02:32.000000000 +0100
1957 +++ linux-2.6.32.10-vs2.3.0.36.29.2/drivers/net/tun.c 2009-12-03 20:04:56.000000000 +0100
1959 #include <linux/crc32.h>
1960 #include <linux/nsproxy.h>
1961 #include <linux/virtio_net.h>
1962 +#include <linux/vs_network.h>
1963 #include <net/net_namespace.h>
1964 #include <net/netns/generic.h>
1965 #include <net/rtnetlink.h>
1966 @@ -102,6 +103,7 @@ struct tun_struct {
1972 struct net_device *dev;
1973 struct fasync_struct *fasync;
1974 @@ -816,6 +818,7 @@ static void tun_setup(struct net_device
1978 + tun->nid = current->nid;
1980 dev->ethtool_ops = &tun_ethtool_ops;
1981 dev->destructor = tun_free_netdev;
1982 @@ -932,7 +935,7 @@ static int tun_set_iff(struct net *net,
1984 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1985 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1986 - !capable(CAP_NET_ADMIN))
1987 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1989 err = security_tun_dev_attach(tun->socket.sk);
1991 @@ -946,7 +949,7 @@ static int tun_set_iff(struct net *net,
1993 unsigned long flags = 0;
1995 - if (!capable(CAP_NET_ADMIN))
1996 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1998 err = security_tun_dev_create();
2000 @@ -1013,6 +1016,9 @@ static int tun_set_iff(struct net *net,
2002 sk->sk_destruct = tun_sock_destruct;
2004 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
2007 err = tun_attach(tun, file);
2010 @@ -1202,6 +1208,16 @@ static long tun_chr_ioctl(struct file *f
2011 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2015 + if (!capable(CAP_CONTEXT))
2018 + /* Set nid owner of the device */
2019 + tun->nid = (nid_t) arg;
2021 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2025 /* Only allow setting the type when the interface is down */
2026 if (tun->dev->flags & IFF_UP) {
2027 diff -NurpP --minimal linux-2.6.32.10/fs/attr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/attr.c
2028 --- linux-2.6.32.10/fs/attr.c 2009-12-03 20:02:51.000000000 +0100
2029 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/attr.c 2009-12-03 20:04:56.000000000 +0100
2031 #include <linux/fcntl.h>
2032 #include <linux/quotaops.h>
2033 #include <linux/security.h>
2034 +#include <linux/proc_fs.h>
2035 +#include <linux/devpts_fs.h>
2036 +#include <linux/vs_tag.h>
2038 /* Taken over from the old code... */
2040 @@ -55,6 +58,10 @@ int inode_change_ok(const struct inode *
2041 if (!is_owner_or_cap(inode))
2045 + if (dx_permission(inode, MAY_WRITE))
2051 @@ -120,6 +127,8 @@ int inode_setattr(struct inode * inode,
2052 inode->i_uid = attr->ia_uid;
2053 if (ia_valid & ATTR_GID)
2054 inode->i_gid = attr->ia_gid;
2055 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2056 + inode->i_tag = attr->ia_tag;
2057 if (ia_valid & ATTR_ATIME)
2058 inode->i_atime = timespec_trunc(attr->ia_atime,
2059 inode->i_sb->s_time_gran);
2060 @@ -214,7 +223,8 @@ int notify_change(struct dentry * dentry
2061 error = inode_change_ok(inode, attr);
2063 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2064 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2065 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2066 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2067 error = vfs_dq_transfer(inode, attr) ?
2070 diff -NurpP --minimal linux-2.6.32.10/fs/binfmt_aout.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_aout.c
2071 --- linux-2.6.32.10/fs/binfmt_aout.c 2010-03-18 16:17:36.000000000 +0100
2072 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_aout.c 2010-02-12 10:59:55.000000000 +0100
2074 #include <linux/binfmts.h>
2075 #include <linux/personality.h>
2076 #include <linux/init.h>
2077 +#include <linux/vs_memory.h>
2079 #include <asm/system.h>
2080 #include <asm/uaccess.h>
2081 diff -NurpP --minimal linux-2.6.32.10/fs/binfmt_elf.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_elf.c
2082 --- linux-2.6.32.10/fs/binfmt_elf.c 2010-03-18 16:17:36.000000000 +0100
2083 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_elf.c 2010-02-12 10:59:55.000000000 +0100
2085 #include <linux/random.h>
2086 #include <linux/elf.h>
2087 #include <linux/utsname.h>
2088 +#include <linux/vs_memory.h>
2089 #include <asm/uaccess.h>
2090 #include <asm/param.h>
2091 #include <asm/page.h>
2092 diff -NurpP --minimal linux-2.6.32.10/fs/binfmt_flat.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_flat.c
2093 --- linux-2.6.32.10/fs/binfmt_flat.c 2010-03-18 16:17:36.000000000 +0100
2094 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_flat.c 2010-02-12 10:59:55.000000000 +0100
2096 #include <linux/init.h>
2097 #include <linux/flat.h>
2098 #include <linux/syscalls.h>
2099 +#include <linux/vs_memory.h>
2101 #include <asm/byteorder.h>
2102 #include <asm/system.h>
2103 diff -NurpP --minimal linux-2.6.32.10/fs/binfmt_som.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_som.c
2104 --- linux-2.6.32.10/fs/binfmt_som.c 2010-03-18 16:17:36.000000000 +0100
2105 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/binfmt_som.c 2010-02-12 10:59:55.000000000 +0100
2107 #include <linux/shm.h>
2108 #include <linux/personality.h>
2109 #include <linux/init.h>
2110 +#include <linux/vs_memory.h>
2112 #include <asm/uaccess.h>
2113 #include <asm/pgtable.h>
2114 diff -NurpP --minimal linux-2.6.32.10/fs/block_dev.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/block_dev.c
2115 --- linux-2.6.32.10/fs/block_dev.c 2010-03-18 16:17:36.000000000 +0100
2116 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/block_dev.c 2010-02-24 12:32:54.000000000 +0100
2118 #include <linux/namei.h>
2119 #include <linux/log2.h>
2120 #include <linux/kmemleak.h>
2121 +#include <linux/vs_device.h>
2122 #include <asm/uaccess.h>
2123 #include "internal.h"
2125 @@ -556,6 +557,7 @@ struct block_device *bdget(dev_t dev)
2126 bdev->bd_invalidated = 0;
2127 inode->i_mode = S_IFBLK;
2128 inode->i_rdev = dev;
2129 + inode->i_mdev = dev;
2130 inode->i_bdev = bdev;
2131 inode->i_data.a_ops = &def_blk_aops;
2132 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2133 @@ -602,6 +604,11 @@ EXPORT_SYMBOL(bdput);
2134 static struct block_device *bd_acquire(struct inode *inode)
2136 struct block_device *bdev;
2139 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2141 + inode->i_mdev = mdev;
2143 spin_lock(&bdev_lock);
2144 bdev = inode->i_bdev;
2145 @@ -612,7 +619,7 @@ static struct block_device *bd_acquire(s
2147 spin_unlock(&bdev_lock);
2149 - bdev = bdget(inode->i_rdev);
2150 + bdev = bdget(mdev);
2152 spin_lock(&bdev_lock);
2153 if (!inode->i_bdev) {
2154 diff -NurpP --minimal linux-2.6.32.10/fs/btrfs/ctree.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/ctree.h
2155 --- linux-2.6.32.10/fs/btrfs/ctree.h 2009-12-03 20:02:51.000000000 +0100
2156 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/ctree.h 2009-12-03 20:04:56.000000000 +0100
2157 @@ -544,11 +544,14 @@ struct btrfs_inode_item {
2158 /* modification sequence number for NFS */
2163 * a little future expansion, for more than this we can
2164 * just grow the inode item and version it
2166 - __le64 reserved[4];
2167 + __le16 reserved16;
2168 + __le32 reserved32;
2169 + __le64 reserved[3];
2170 struct btrfs_timespec atime;
2171 struct btrfs_timespec ctime;
2172 struct btrfs_timespec mtime;
2173 @@ -1155,6 +1158,8 @@ struct btrfs_root {
2174 #define BTRFS_MOUNT_NOSSD (1 << 9)
2175 #define BTRFS_MOUNT_DISCARD (1 << 10)
2177 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2179 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2180 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2181 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2182 @@ -1174,6 +1179,10 @@ struct btrfs_root {
2183 #define BTRFS_INODE_NOATIME (1 << 9)
2184 #define BTRFS_INODE_DIRSYNC (1 << 10)
2186 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2187 +#define BTRFS_INODE_BARRIER (1 << 25)
2188 +#define BTRFS_INODE_COW (1 << 26)
2191 /* some macros to generate set/get funcs for the struct fields. This
2192 * assumes there is a lefoo_to_cpu for every type, so lets make a simple
2193 @@ -1376,6 +1385,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2194 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2195 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2196 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2197 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2198 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2199 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2200 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2201 @@ -2338,6 +2348,7 @@ extern const struct dentry_operations bt
2202 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2203 void btrfs_update_iflags(struct inode *inode);
2204 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2205 +int btrfs_sync_flags(struct inode *inode, int, int);
2208 int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
2209 diff -NurpP --minimal linux-2.6.32.10/fs/btrfs/disk-io.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/disk-io.c
2210 --- linux-2.6.32.10/fs/btrfs/disk-io.c 2009-12-03 20:02:51.000000000 +0100
2211 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/disk-io.c 2009-12-03 20:04:56.000000000 +0100
2212 @@ -1723,6 +1723,9 @@ struct btrfs_root *open_ctree(struct sup
2216 + if (btrfs_test_opt(tree_root, TAGGED))
2217 + sb->s_flags |= MS_TAGGED;
2219 features = btrfs_super_incompat_flags(disk_super) &
2220 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2222 diff -NurpP --minimal linux-2.6.32.10/fs/btrfs/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/inode.c
2223 --- linux-2.6.32.10/fs/btrfs/inode.c 2009-12-03 20:02:51.000000000 +0100
2224 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/inode.c 2009-12-03 20:04:56.000000000 +0100
2226 #include <linux/xattr.h>
2227 #include <linux/posix_acl.h>
2228 #include <linux/falloc.h>
2229 +#include <linux/vs_tag.h>
2233 #include "disk-io.h"
2234 @@ -2242,6 +2244,8 @@ static void btrfs_read_locked_inode(stru
2236 u64 alloc_group_block;
2242 path = btrfs_alloc_path();
2243 @@ -2258,8 +2262,13 @@ static void btrfs_read_locked_inode(stru
2245 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2246 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2247 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2248 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2250 + uid = btrfs_inode_uid(leaf, inode_item);
2251 + gid = btrfs_inode_gid(leaf, inode_item);
2252 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2253 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2254 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2255 + btrfs_inode_tag(leaf, inode_item));
2256 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2258 tspec = btrfs_inode_atime(inode_item);
2259 @@ -2341,8 +2350,15 @@ static void fill_inode_item(struct btrfs
2260 struct btrfs_inode_item *item,
2261 struct inode *inode)
2263 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2264 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2265 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2266 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2268 + btrfs_set_inode_uid(leaf, item, uid);
2269 + btrfs_set_inode_gid(leaf, item, gid);
2270 +#ifdef CONFIG_TAGGING_INTERN
2271 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2274 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2275 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2276 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2277 @@ -4065,6 +4081,7 @@ static struct inode *btrfs_new_inode(str
2279 inode->i_gid = current_fsgid();
2281 + inode->i_tag = dx_current_fstag(root->fs_info->sb);
2282 inode->i_mode = mode;
2283 inode->i_ino = objectid;
2284 inode_set_bytes(inode, 0);
2285 @@ -5836,6 +5853,7 @@ static const struct inode_operations btr
2286 .listxattr = btrfs_listxattr,
2287 .removexattr = btrfs_removexattr,
2288 .permission = btrfs_permission,
2289 + .sync_flags = btrfs_sync_flags,
2291 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2292 .lookup = btrfs_lookup,
2293 @@ -5911,6 +5929,7 @@ static const struct inode_operations btr
2294 .permission = btrfs_permission,
2295 .fallocate = btrfs_fallocate,
2296 .fiemap = btrfs_fiemap,
2297 + .sync_flags = btrfs_sync_flags,
2299 static const struct inode_operations btrfs_special_inode_operations = {
2300 .getattr = btrfs_getattr,
2301 diff -NurpP --minimal linux-2.6.32.10/fs/btrfs/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/ioctl.c
2302 --- linux-2.6.32.10/fs/btrfs/ioctl.c 2009-12-03 20:02:51.000000000 +0100
2303 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
2304 @@ -67,10 +67,13 @@ static unsigned int btrfs_flags_to_ioctl
2306 unsigned int iflags = 0;
2308 - if (flags & BTRFS_INODE_SYNC)
2309 - iflags |= FS_SYNC_FL;
2310 if (flags & BTRFS_INODE_IMMUTABLE)
2311 iflags |= FS_IMMUTABLE_FL;
2312 + if (flags & BTRFS_INODE_IXUNLINK)
2313 + iflags |= FS_IXUNLINK_FL;
2315 + if (flags & BTRFS_INODE_SYNC)
2316 + iflags |= FS_SYNC_FL;
2317 if (flags & BTRFS_INODE_APPEND)
2318 iflags |= FS_APPEND_FL;
2319 if (flags & BTRFS_INODE_NODUMP)
2320 @@ -80,28 +83,78 @@ static unsigned int btrfs_flags_to_ioctl
2321 if (flags & BTRFS_INODE_DIRSYNC)
2322 iflags |= FS_DIRSYNC_FL;
2324 + if (flags & BTRFS_INODE_BARRIER)
2325 + iflags |= FS_BARRIER_FL;
2326 + if (flags & BTRFS_INODE_COW)
2327 + iflags |= FS_COW_FL;
2332 - * Update inode->i_flags based on the btrfs internal flags.
2333 + * Update inode->i_(v)flags based on the btrfs internal flags.
2335 void btrfs_update_iflags(struct inode *inode)
2337 struct btrfs_inode *ip = BTRFS_I(inode);
2339 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2340 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2341 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2343 - if (ip->flags & BTRFS_INODE_SYNC)
2344 - inode->i_flags |= S_SYNC;
2345 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2346 inode->i_flags |= S_IMMUTABLE;
2347 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2348 + inode->i_flags |= S_IXUNLINK;
2350 + if (ip->flags & BTRFS_INODE_SYNC)
2351 + inode->i_flags |= S_SYNC;
2352 if (ip->flags & BTRFS_INODE_APPEND)
2353 inode->i_flags |= S_APPEND;
2354 if (ip->flags & BTRFS_INODE_NOATIME)
2355 inode->i_flags |= S_NOATIME;
2356 if (ip->flags & BTRFS_INODE_DIRSYNC)
2357 inode->i_flags |= S_DIRSYNC;
2359 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2361 + if (ip->flags & BTRFS_INODE_BARRIER)
2362 + inode->i_vflags |= V_BARRIER;
2363 + if (ip->flags & BTRFS_INODE_COW)
2364 + inode->i_vflags |= V_COW;
2368 + * Update btrfs internal flags from inode->i_(v)flags.
2370 +void btrfs_update_flags(struct inode *inode)
2372 + struct btrfs_inode *ip = BTRFS_I(inode);
2374 + unsigned int flags = inode->i_flags;
2375 + unsigned int vflags = inode->i_vflags;
2377 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2378 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2379 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2380 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2382 + if (flags & S_IMMUTABLE)
2383 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2384 + if (flags & S_IXUNLINK)
2385 + ip->flags |= BTRFS_INODE_IXUNLINK;
2387 + if (flags & S_SYNC)
2388 + ip->flags |= BTRFS_INODE_SYNC;
2389 + if (flags & S_APPEND)
2390 + ip->flags |= BTRFS_INODE_APPEND;
2391 + if (flags & S_NOATIME)
2392 + ip->flags |= BTRFS_INODE_NOATIME;
2393 + if (flags & S_DIRSYNC)
2394 + ip->flags |= BTRFS_INODE_DIRSYNC;
2396 + if (vflags & V_BARRIER)
2397 + ip->flags |= BTRFS_INODE_BARRIER;
2398 + if (vflags & V_COW)
2399 + ip->flags |= BTRFS_INODE_COW;
2403 @@ -119,7 +172,7 @@ void btrfs_inherit_iflags(struct inode *
2404 flags = BTRFS_I(dir)->flags;
2406 if (S_ISREG(inode->i_mode))
2407 - flags &= ~BTRFS_INODE_DIRSYNC;
2408 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2409 else if (!S_ISDIR(inode->i_mode))
2410 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2412 @@ -127,6 +180,30 @@ void btrfs_inherit_iflags(struct inode *
2413 btrfs_update_iflags(inode);
2416 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2418 + struct btrfs_inode *ip = BTRFS_I(inode);
2419 + struct btrfs_root *root = ip->root;
2420 + struct btrfs_trans_handle *trans;
2423 + trans = btrfs_join_transaction(root, 1);
2426 + inode->i_flags = flags;
2427 + inode->i_vflags = vflags;
2428 + btrfs_update_flags(inode);
2430 + ret = btrfs_update_inode(trans, root, inode);
2433 + btrfs_update_iflags(inode);
2434 + inode->i_ctime = CURRENT_TIME;
2435 + btrfs_end_transaction(trans, root);
2440 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2442 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2443 @@ -149,6 +226,7 @@ static int btrfs_ioctl_setflags(struct f
2444 if (copy_from_user(&flags, arg, sizeof(flags)))
2447 + /* maybe add FS_IXUNLINK_FL ? */
2448 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2449 FS_NOATIME_FL | FS_NODUMP_FL | \
2450 FS_SYNC_FL | FS_DIRSYNC_FL))
2451 @@ -161,7 +239,8 @@ static int btrfs_ioctl_setflags(struct f
2453 flags = btrfs_mask_flags(inode->i_mode, flags);
2454 oldflags = btrfs_flags_to_ioctl(ip->flags);
2455 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2456 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2457 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2458 if (!capable(CAP_LINUX_IMMUTABLE)) {
2461 @@ -172,14 +251,19 @@ static int btrfs_ioctl_setflags(struct f
2465 - if (flags & FS_SYNC_FL)
2466 - ip->flags |= BTRFS_INODE_SYNC;
2468 - ip->flags &= ~BTRFS_INODE_SYNC;
2469 if (flags & FS_IMMUTABLE_FL)
2470 ip->flags |= BTRFS_INODE_IMMUTABLE;
2472 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2473 + if (flags & FS_IXUNLINK_FL)
2474 + ip->flags |= BTRFS_INODE_IXUNLINK;
2476 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2478 + if (flags & FS_SYNC_FL)
2479 + ip->flags |= BTRFS_INODE_SYNC;
2481 + ip->flags &= ~BTRFS_INODE_SYNC;
2482 if (flags & FS_APPEND_FL)
2483 ip->flags |= BTRFS_INODE_APPEND;
2485 diff -NurpP --minimal linux-2.6.32.10/fs/btrfs/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/super.c
2486 --- linux-2.6.32.10/fs/btrfs/super.c 2009-12-03 20:02:51.000000000 +0100
2487 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/btrfs/super.c 2009-12-03 20:04:56.000000000 +0100
2488 @@ -67,7 +67,7 @@ enum {
2489 Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier,
2490 Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
2491 Opt_compress, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
2492 - Opt_discard, Opt_err,
2493 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2496 static match_table_t tokens = {
2497 @@ -90,6 +90,9 @@ static match_table_t tokens = {
2498 {Opt_flushoncommit, "flushoncommit"},
2499 {Opt_ratio, "metadata_ratio=%d"},
2500 {Opt_discard, "discard"},
2502 + {Opt_notag, "notag"},
2503 + {Opt_tagid, "tagid=%u"},
2507 @@ -262,6 +265,22 @@ int btrfs_parse_options(struct btrfs_roo
2509 btrfs_set_opt(info->mount_opt, DISCARD);
2511 +#ifndef CONFIG_TAGGING_NONE
2513 + printk(KERN_INFO "btrfs: use tagging\n");
2514 + btrfs_set_opt(info->mount_opt, TAGGED);
2517 + printk(KERN_INFO "btrfs: disabled tagging\n");
2518 + btrfs_clear_opt(info->mount_opt, TAGGED);
2521 +#ifdef CONFIG_PROPAGATE
2524 + btrfs_set_opt(info->mount_opt, TAGGED);
2530 @@ -575,6 +594,12 @@ static int btrfs_remount(struct super_bl
2534 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2535 + printk("btrfs: %s: tagging not permitted on remount.\n",
2540 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2543 diff -NurpP --minimal linux-2.6.32.10/fs/char_dev.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/char_dev.c
2544 --- linux-2.6.32.10/fs/char_dev.c 2009-12-03 20:02:51.000000000 +0100
2545 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/char_dev.c 2009-12-03 20:04:56.000000000 +0100
2547 #include <linux/cdev.h>
2548 #include <linux/mutex.h>
2549 #include <linux/backing-dev.h>
2550 +#include <linux/vs_context.h>
2551 +#include <linux/vs_device.h>
2553 #include "internal.h"
2555 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
2557 struct cdev *new = NULL;
2561 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2563 + inode->i_mdev = mdev;
2565 spin_lock(&cdev_lock);
2568 struct kobject *kobj;
2571 spin_unlock(&cdev_lock);
2572 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2574 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2577 new = container_of(kobj, struct cdev, kobj);
2578 diff -NurpP --minimal linux-2.6.32.10/fs/dcache.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/dcache.c
2579 --- linux-2.6.32.10/fs/dcache.c 2009-12-03 20:02:51.000000000 +0100
2580 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/dcache.c 2009-12-03 20:04:56.000000000 +0100
2582 #include <linux/bootmem.h>
2583 #include <linux/fs_struct.h>
2584 #include <linux/hardirq.h>
2585 +#include <linux/vs_limit.h>
2586 #include "internal.h"
2588 int sysctl_vfs_cache_pressure __read_mostly = 100;
2589 @@ -230,6 +231,8 @@ repeat:
2593 + vx_dentry_dec(dentry);
2596 * AV: ->d_delete() is _NOT_ allowed to block now.
2598 @@ -321,6 +324,7 @@ static inline struct dentry * __dget_loc
2600 atomic_inc(&dentry->d_count);
2601 dentry_lru_del_init(dentry);
2602 + vx_dentry_inc(dentry);
2606 @@ -919,6 +923,9 @@ struct dentry *d_alloc(struct dentry * p
2607 struct dentry *dentry;
2610 + if (!vx_dentry_avail(1))
2613 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2616 @@ -964,6 +971,7 @@ struct dentry *d_alloc(struct dentry * p
2618 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2619 dentry_stat.nr_dentry++;
2620 + vx_dentry_inc(dentry);
2621 spin_unlock(&dcache_lock);
2624 @@ -1407,6 +1415,7 @@ struct dentry * __d_lookup(struct dentry
2627 atomic_inc(&dentry->d_count);
2628 + vx_dentry_inc(dentry);
2630 spin_unlock(&dentry->d_lock);
2632 diff -NurpP --minimal linux-2.6.32.10/fs/devpts/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/devpts/inode.c
2633 --- linux-2.6.32.10/fs/devpts/inode.c 2010-03-18 16:17:36.000000000 +0100
2634 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/devpts/inode.c 2009-12-29 00:36:26.000000000 +0100
2636 #include <linux/parser.h>
2637 #include <linux/fsnotify.h>
2638 #include <linux/seq_file.h>
2639 +#include <linux/vs_base.h>
2641 #define DEVPTS_DEFAULT_MODE 0600
2644 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2645 #define PTMX_MINOR 2
2647 +static int devpts_permission(struct inode *inode, int mask)
2649 + int ret = -EACCES;
2651 + /* devpts is xid tagged */
2652 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2653 + ret = generic_permission(inode, mask, NULL);
2657 +static struct inode_operations devpts_file_inode_operations = {
2658 + .permission = devpts_permission,
2661 extern int pty_limit; /* Config limit on Unix98 ptys */
2662 static DEFINE_MUTEX(allocated_ptys_lock);
2664 @@ -262,6 +277,25 @@ static int devpts_show_options(struct se
2668 +static int devpts_filter(struct dentry *de)
2670 + /* devpts is xid tagged */
2671 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2674 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2676 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2679 +static struct file_operations devpts_dir_operations = {
2680 + .open = dcache_dir_open,
2681 + .release = dcache_dir_close,
2682 + .llseek = dcache_dir_lseek,
2683 + .read = generic_read_dir,
2684 + .readdir = devpts_readdir,
2687 static const struct super_operations devpts_sops = {
2688 .statfs = simple_statfs,
2689 .remount_fs = devpts_remount,
2690 @@ -301,12 +335,15 @@ devpts_fill_super(struct super_block *s,
2691 inode = new_inode(s);
2696 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2697 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2698 inode->i_op = &simple_dir_inode_operations;
2699 - inode->i_fop = &simple_dir_operations;
2700 + inode->i_fop = &devpts_dir_operations;
2702 + /* devpts is xid tagged */
2703 + inode->i_tag = (tag_t)vx_current_xid();
2705 s->s_root = d_alloc_root(inode);
2707 @@ -497,6 +534,9 @@ int devpts_pty_new(struct inode *ptmx_in
2708 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2709 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2710 init_special_inode(inode, S_IFCHR|opts->mode, device);
2711 + /* devpts is xid tagged */
2712 + inode->i_tag = (tag_t)vx_current_xid();
2713 + inode->i_op = &devpts_file_inode_operations;
2714 inode->i_private = tty;
2715 tty->driver_data = inode;
2717 diff -NurpP --minimal linux-2.6.32.10/fs/exec.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/exec.c
2718 --- linux-2.6.32.10/fs/exec.c 2010-03-18 16:17:36.000000000 +0100
2719 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/exec.c 2010-03-18 16:53:06.000000000 +0100
2720 @@ -251,7 +251,9 @@ static int __bprm_mm_init(struct linux_b
2724 - mm->stack_vm = mm->total_vm = 1;
2726 + vx_vmpages_inc(mm);
2728 up_write(&mm->mmap_sem);
2729 bprm->p = vma->vm_end - sizeof(void *);
2731 @@ -1496,7 +1498,7 @@ static int format_corename(char *corenam
2732 /* UNIX time of coredump */
2735 - do_gettimeofday(&tv);
2736 + vx_gettimeofday(&tv);
2737 rc = snprintf(out_ptr, out_end - out_ptr,
2739 if (rc > out_end - out_ptr)
2740 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/balloc.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/balloc.c
2741 --- linux-2.6.32.10/fs/ext2/balloc.c 2009-06-11 17:13:03.000000000 +0200
2742 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/balloc.c 2009-12-03 20:04:56.000000000 +0100
2743 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2745 end = EXT2_BLOCKS_PER_GROUP(sb);
2748 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2751 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/ext2.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/ext2.h
2752 --- linux-2.6.32.10/fs/ext2/ext2.h 2009-09-10 15:26:21.000000000 +0200
2753 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/ext2.h 2009-12-03 20:04:56.000000000 +0100
2754 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
2755 int __ext2_write_begin(struct file *file, struct address_space *mapping,
2756 loff_t pos, unsigned len, unsigned flags,
2757 struct page **pagep, void **fsdata);
2758 +extern int ext2_sync_flags(struct inode *, int, int);
2761 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2762 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/file.c
2763 --- linux-2.6.32.10/fs/ext2/file.c 2009-12-03 20:02:51.000000000 +0100
2764 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/file.c 2009-12-03 20:04:56.000000000 +0100
2765 @@ -87,4 +87,5 @@ const struct inode_operations ext2_file_
2766 .setattr = ext2_setattr,
2767 .check_acl = ext2_check_acl,
2768 .fiemap = ext2_fiemap,
2769 + .sync_flags = ext2_sync_flags,
2771 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/ialloc.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/ialloc.c
2772 --- linux-2.6.32.10/fs/ext2/ialloc.c 2009-06-11 17:13:03.000000000 +0200
2773 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/ialloc.c 2009-12-03 20:04:56.000000000 +0100
2775 #include <linux/backing-dev.h>
2776 #include <linux/buffer_head.h>
2777 #include <linux/random.h>
2778 +#include <linux/vs_tag.h>
2782 @@ -560,6 +561,7 @@ got:
2784 inode->i_gid = current_fsgid();
2785 inode->i_mode = mode;
2786 + inode->i_tag = dx_current_fstag(sb);
2789 inode->i_blocks = 0;
2790 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/inode.c
2791 --- linux-2.6.32.10/fs/ext2/inode.c 2009-12-03 20:02:51.000000000 +0100
2792 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/inode.c 2009-12-03 20:04:56.000000000 +0100
2794 #include <linux/mpage.h>
2795 #include <linux/fiemap.h>
2796 #include <linux/namei.h>
2797 +#include <linux/vs_tag.h>
2801 @@ -1040,7 +1041,7 @@ void ext2_truncate(struct inode *inode)
2803 if (ext2_inode_is_fast_symlink(inode))
2805 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2806 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2809 blocksize = inode->i_sb->s_blocksize;
2810 @@ -1178,36 +1179,61 @@ void ext2_set_inode_flags(struct inode *
2812 unsigned int flags = EXT2_I(inode)->i_flags;
2814 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2815 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2816 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2819 + if (flags & EXT2_IMMUTABLE_FL)
2820 + inode->i_flags |= S_IMMUTABLE;
2821 + if (flags & EXT2_IXUNLINK_FL)
2822 + inode->i_flags |= S_IXUNLINK;
2824 if (flags & EXT2_SYNC_FL)
2825 inode->i_flags |= S_SYNC;
2826 if (flags & EXT2_APPEND_FL)
2827 inode->i_flags |= S_APPEND;
2828 - if (flags & EXT2_IMMUTABLE_FL)
2829 - inode->i_flags |= S_IMMUTABLE;
2830 if (flags & EXT2_NOATIME_FL)
2831 inode->i_flags |= S_NOATIME;
2832 if (flags & EXT2_DIRSYNC_FL)
2833 inode->i_flags |= S_DIRSYNC;
2835 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2837 + if (flags & EXT2_BARRIER_FL)
2838 + inode->i_vflags |= V_BARRIER;
2839 + if (flags & EXT2_COW_FL)
2840 + inode->i_vflags |= V_COW;
2843 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2844 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2846 unsigned int flags = ei->vfs_inode.i_flags;
2847 + unsigned int vflags = ei->vfs_inode.i_vflags;
2849 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2850 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2851 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2852 + EXT2_BARRIER_FL | EXT2_COW_FL);
2854 + if (flags & S_IMMUTABLE)
2855 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2856 + if (flags & S_IXUNLINK)
2857 + ei->i_flags |= EXT2_IXUNLINK_FL;
2859 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2860 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2862 ei->i_flags |= EXT2_SYNC_FL;
2863 if (flags & S_APPEND)
2864 ei->i_flags |= EXT2_APPEND_FL;
2865 - if (flags & S_IMMUTABLE)
2866 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2867 if (flags & S_NOATIME)
2868 ei->i_flags |= EXT2_NOATIME_FL;
2869 if (flags & S_DIRSYNC)
2870 ei->i_flags |= EXT2_DIRSYNC_FL;
2872 + if (vflags & V_BARRIER)
2873 + ei->i_flags |= EXT2_BARRIER_FL;
2874 + if (vflags & V_COW)
2875 + ei->i_flags |= EXT2_COW_FL;
2878 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2879 @@ -1217,6 +1243,8 @@ struct inode *ext2_iget (struct super_bl
2880 struct ext2_inode *raw_inode;
2881 struct inode *inode;
2887 inode = iget_locked(sb, ino);
2888 @@ -1235,12 +1263,17 @@ struct inode *ext2_iget (struct super_bl
2891 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2892 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2893 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2894 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2895 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2896 if (!(test_opt (inode->i_sb, NO_UID32))) {
2897 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2898 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2899 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2900 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2902 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2903 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2904 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2905 + le16_to_cpu(raw_inode->i_raw_tag));
2907 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2908 inode->i_size = le32_to_cpu(raw_inode->i_size);
2909 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2910 @@ -1338,8 +1371,8 @@ int ext2_write_inode(struct inode *inode
2911 struct ext2_inode_info *ei = EXT2_I(inode);
2912 struct super_block *sb = inode->i_sb;
2913 ino_t ino = inode->i_ino;
2914 - uid_t uid = inode->i_uid;
2915 - gid_t gid = inode->i_gid;
2916 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2917 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2918 struct buffer_head * bh;
2919 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2921 @@ -1375,6 +1408,9 @@ int ext2_write_inode(struct inode *inode
2922 raw_inode->i_uid_high = 0;
2923 raw_inode->i_gid_high = 0;
2925 +#ifdef CONFIG_TAGGING_INTERN
2926 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2928 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2929 raw_inode->i_size = cpu_to_le32(inode->i_size);
2930 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2931 @@ -1456,7 +1492,8 @@ int ext2_setattr(struct dentry *dentry,
2934 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2935 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2936 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2937 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2938 error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
2941 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/ioctl.c
2942 --- linux-2.6.32.10/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2943 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/ioctl.c 2009-12-03 20:04:56.000000000 +0100
2945 #include <asm/uaccess.h>
2948 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2950 + inode->i_flags = flags;
2951 + inode->i_vflags = vflags;
2952 + ext2_get_inode_flags(EXT2_I(inode));
2953 + inode->i_ctime = CURRENT_TIME_SEC;
2954 + mark_inode_dirty(inode);
2958 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2960 struct inode *inode = filp->f_dentry->d_inode;
2961 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2963 flags = ext2_mask_flags(inode->i_mode, flags);
2965 + if (IS_BARRIER(inode)) {
2966 + vxwprintk_task(1, "messing with the barrier.");
2970 mutex_lock(&inode->i_mutex);
2971 /* Is it quota file? Do not allow user to mess with it */
2972 if (IS_NOQUOTA(inode)) {
2973 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2975 * This test looks nicer. Thanks to Pauline Middelink
2977 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2978 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2979 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2980 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2981 if (!capable(CAP_LINUX_IMMUTABLE)) {
2982 mutex_unlock(&inode->i_mutex);
2984 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2988 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2989 + flags &= EXT2_FL_USER_MODIFIABLE;
2990 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2991 ei->i_flags = flags;
2992 mutex_unlock(&inode->i_mutex);
2993 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/namei.c
2994 --- linux-2.6.32.10/fs/ext2/namei.c 2009-12-03 20:02:51.000000000 +0100
2995 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/namei.c 2009-12-03 20:04:56.000000000 +0100
2999 #include <linux/pagemap.h>
3000 +#include <linux/vs_tag.h>
3004 @@ -74,6 +75,7 @@ static struct dentry *ext2_lookup(struct
3005 return ERR_PTR(-EIO);
3007 return ERR_CAST(inode);
3008 + dx_propagate_tag(nd, inode);
3012 @@ -401,6 +403,7 @@ const struct inode_operations ext2_dir_i
3014 .setattr = ext2_setattr,
3015 .check_acl = ext2_check_acl,
3016 + .sync_flags = ext2_sync_flags,
3019 const struct inode_operations ext2_special_inode_operations = {
3020 diff -NurpP --minimal linux-2.6.32.10/fs/ext2/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/super.c
3021 --- linux-2.6.32.10/fs/ext2/super.c 2009-09-10 15:26:21.000000000 +0200
3022 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext2/super.c 2009-12-03 20:04:56.000000000 +0100
3023 @@ -382,7 +382,8 @@ enum {
3024 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3025 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3026 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3027 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3028 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3029 + Opt_tag, Opt_notag, Opt_tagid
3032 static const match_table_t tokens = {
3033 @@ -410,6 +411,9 @@ static const match_table_t tokens = {
3035 {Opt_noacl, "noacl"},
3038 + {Opt_notag, "notag"},
3039 + {Opt_tagid, "tagid=%u"},
3040 {Opt_grpquota, "grpquota"},
3041 {Opt_ignore, "noquota"},
3042 {Opt_quota, "quota"},
3043 @@ -480,6 +484,20 @@ static int parse_options (char * options
3045 set_opt (sbi->s_mount_opt, NO_UID32);
3047 +#ifndef CONFIG_TAGGING_NONE
3049 + set_opt (sbi->s_mount_opt, TAGGED);
3052 + clear_opt (sbi->s_mount_opt, TAGGED);
3055 +#ifdef CONFIG_PROPAGATE
3058 + set_opt (sbi->s_mount_opt, TAGGED);
3062 clear_opt (sbi->s_mount_opt, CHECK);
3064 @@ -829,6 +847,8 @@ static int ext2_fill_super(struct super_
3065 if (!parse_options ((char *) data, sbi))
3068 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3069 + sb->s_flags |= MS_TAGGED;
3070 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3071 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3073 @@ -1175,6 +1195,14 @@ static int ext2_remount (struct super_bl
3077 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3078 + !(sb->s_flags & MS_TAGGED)) {
3079 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3082 + goto restore_opts;
3085 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3086 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3088 diff -NurpP --minimal linux-2.6.32.10/fs/ext3/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/file.c
3089 --- linux-2.6.32.10/fs/ext3/file.c 2009-12-03 20:02:51.000000000 +0100
3090 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/file.c 2009-12-03 20:04:56.000000000 +0100
3091 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
3093 .check_acl = ext3_check_acl,
3094 .fiemap = ext3_fiemap,
3095 + .sync_flags = ext3_sync_flags,
3098 diff -NurpP --minimal linux-2.6.32.10/fs/ext3/ialloc.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/ialloc.c
3099 --- linux-2.6.32.10/fs/ext3/ialloc.c 2009-09-10 15:26:21.000000000 +0200
3100 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/ialloc.c 2009-12-03 20:04:56.000000000 +0100
3102 #include <linux/buffer_head.h>
3103 #include <linux/random.h>
3104 #include <linux/bitops.h>
3105 +#include <linux/vs_tag.h>
3107 #include <asm/byteorder.h>
3109 @@ -548,6 +549,7 @@ got:
3111 inode->i_gid = current_fsgid();
3112 inode->i_mode = mode;
3113 + inode->i_tag = dx_current_fstag(sb);
3116 /* This is the optimal IO size (for stat), not the fs block size */
3117 diff -NurpP --minimal linux-2.6.32.10/fs/ext3/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/inode.c
3118 --- linux-2.6.32.10/fs/ext3/inode.c 2010-03-18 16:17:36.000000000 +0100
3119 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/inode.c 2009-12-29 00:36:26.000000000 +0100
3121 #include <linux/bio.h>
3122 #include <linux/fiemap.h>
3123 #include <linux/namei.h>
3124 +#include <linux/vs_tag.h>
3128 @@ -2343,7 +2344,7 @@ static void ext3_free_branches(handle_t
3130 int ext3_can_truncate(struct inode *inode)
3132 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3133 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3135 if (S_ISREG(inode->i_mode))
3137 @@ -2728,36 +2729,60 @@ void ext3_set_inode_flags(struct inode *
3139 unsigned int flags = EXT3_I(inode)->i_flags;
3141 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3142 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3143 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3145 + if (flags & EXT3_IMMUTABLE_FL)
3146 + inode->i_flags |= S_IMMUTABLE;
3147 + if (flags & EXT3_IXUNLINK_FL)
3148 + inode->i_flags |= S_IXUNLINK;
3150 if (flags & EXT3_SYNC_FL)
3151 inode->i_flags |= S_SYNC;
3152 if (flags & EXT3_APPEND_FL)
3153 inode->i_flags |= S_APPEND;
3154 - if (flags & EXT3_IMMUTABLE_FL)
3155 - inode->i_flags |= S_IMMUTABLE;
3156 if (flags & EXT3_NOATIME_FL)
3157 inode->i_flags |= S_NOATIME;
3158 if (flags & EXT3_DIRSYNC_FL)
3159 inode->i_flags |= S_DIRSYNC;
3161 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3163 + if (flags & EXT3_BARRIER_FL)
3164 + inode->i_vflags |= V_BARRIER;
3165 + if (flags & EXT3_COW_FL)
3166 + inode->i_vflags |= V_COW;
3169 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3170 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3172 unsigned int flags = ei->vfs_inode.i_flags;
3173 + unsigned int vflags = ei->vfs_inode.i_vflags;
3175 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3176 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3177 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3178 + EXT3_BARRIER_FL | EXT3_COW_FL);
3180 + if (flags & S_IMMUTABLE)
3181 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3182 + if (flags & S_IXUNLINK)
3183 + ei->i_flags |= EXT3_IXUNLINK_FL;
3185 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3186 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3188 ei->i_flags |= EXT3_SYNC_FL;
3189 if (flags & S_APPEND)
3190 ei->i_flags |= EXT3_APPEND_FL;
3191 - if (flags & S_IMMUTABLE)
3192 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3193 if (flags & S_NOATIME)
3194 ei->i_flags |= EXT3_NOATIME_FL;
3195 if (flags & S_DIRSYNC)
3196 ei->i_flags |= EXT3_DIRSYNC_FL;
3198 + if (vflags & V_BARRIER)
3199 + ei->i_flags |= EXT3_BARRIER_FL;
3200 + if (vflags & V_COW)
3201 + ei->i_flags |= EXT3_COW_FL;
3204 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3205 @@ -2771,6 +2796,8 @@ struct inode *ext3_iget(struct super_blo
3206 transaction_t *transaction;
3212 inode = iget_locked(sb, ino);
3214 @@ -2787,12 +2814,17 @@ struct inode *ext3_iget(struct super_blo
3216 raw_inode = ext3_raw_inode(&iloc);
3217 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3218 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3219 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3220 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3221 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3222 if(!(test_opt (inode->i_sb, NO_UID32))) {
3223 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3224 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3225 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3226 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3228 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3229 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3230 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3231 + le16_to_cpu(raw_inode->i_raw_tag));
3233 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3234 inode->i_size = le32_to_cpu(raw_inode->i_size);
3235 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3236 @@ -2947,6 +2979,8 @@ static int ext3_do_update_inode(handle_t
3237 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3238 struct ext3_inode_info *ei = EXT3_I(inode);
3239 struct buffer_head *bh = iloc->bh;
3240 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3241 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3242 int err = 0, rc, block;
3245 @@ -2961,29 +2995,32 @@ again:
3246 ext3_get_inode_flags(ei);
3247 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3248 if(!(test_opt(inode->i_sb, NO_UID32))) {
3249 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3250 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3251 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3252 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3254 * Fix up interoperability with old kernels. Otherwise, old inodes get
3255 * re-used with the upper 16 bits of the uid/gid intact
3258 raw_inode->i_uid_high =
3259 - cpu_to_le16(high_16_bits(inode->i_uid));
3260 + cpu_to_le16(high_16_bits(uid));
3261 raw_inode->i_gid_high =
3262 - cpu_to_le16(high_16_bits(inode->i_gid));
3263 + cpu_to_le16(high_16_bits(gid));
3265 raw_inode->i_uid_high = 0;
3266 raw_inode->i_gid_high = 0;
3269 raw_inode->i_uid_low =
3270 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3271 + cpu_to_le16(fs_high2lowuid(uid));
3272 raw_inode->i_gid_low =
3273 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3274 + cpu_to_le16(fs_high2lowgid(gid));
3275 raw_inode->i_uid_high = 0;
3276 raw_inode->i_gid_high = 0;
3278 +#ifdef CONFIG_TAGGING_INTERN
3279 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3281 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3282 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3283 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3284 @@ -3141,7 +3178,8 @@ int ext3_setattr(struct dentry *dentry,
3287 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3288 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3289 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3290 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3293 /* (user+group)*(old+new) structure, inode write (sb,
3294 @@ -3163,6 +3201,8 @@ int ext3_setattr(struct dentry *dentry,
3295 inode->i_uid = attr->ia_uid;
3296 if (attr->ia_valid & ATTR_GID)
3297 inode->i_gid = attr->ia_gid;
3298 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3299 + inode->i_tag = attr->ia_tag;
3300 error = ext3_mark_inode_dirty(handle, inode);
3301 ext3_journal_stop(handle);
3303 diff -NurpP --minimal linux-2.6.32.10/fs/ext3/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/ioctl.c
3304 --- linux-2.6.32.10/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3305 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/ioctl.c 2009-12-03 20:04:56.000000000 +0100
3309 #include <linux/fs.h>
3310 +#include <linux/mount.h>
3311 #include <linux/jbd.h>
3312 #include <linux/capability.h>
3313 #include <linux/ext3_fs.h>
3315 #include <linux/compat.h>
3316 #include <asm/uaccess.h>
3319 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3321 + handle_t *handle = NULL;
3322 + struct ext3_iloc iloc;
3325 + handle = ext3_journal_start(inode, 1);
3326 + if (IS_ERR(handle))
3327 + return PTR_ERR(handle);
3329 + if (IS_SYNC(inode))
3330 + handle->h_sync = 1;
3331 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3335 + inode->i_flags = flags;
3336 + inode->i_vflags = vflags;
3337 + ext3_get_inode_flags(EXT3_I(inode));
3338 + inode->i_ctime = CURRENT_TIME_SEC;
3340 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3342 + ext3_journal_stop(handle);
3346 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3348 struct inode *inode = filp->f_dentry->d_inode;
3349 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3351 flags = ext3_mask_flags(inode->i_mode, flags);
3353 + if (IS_BARRIER(inode)) {
3354 + vxwprintk_task(1, "messing with the barrier.");
3358 mutex_lock(&inode->i_mutex);
3360 /* Is it quota file? Do not allow user to mess with it */
3361 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3363 * This test looks nicer. Thanks to Pauline Middelink
3365 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3366 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3367 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3368 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3369 if (!capable(CAP_LINUX_IMMUTABLE))
3372 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3376 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3377 + flags &= EXT3_FL_USER_MODIFIABLE;
3378 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3379 ei->i_flags = flags;
3381 diff -NurpP --minimal linux-2.6.32.10/fs/ext3/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/namei.c
3382 --- linux-2.6.32.10/fs/ext3/namei.c 2009-12-03 20:02:51.000000000 +0100
3383 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/namei.c 2009-12-03 20:04:56.000000000 +0100
3385 #include <linux/quotaops.h>
3386 #include <linux/buffer_head.h>
3387 #include <linux/bio.h>
3388 +#include <linux/vs_tag.h>
3392 @@ -912,6 +913,7 @@ restart:
3394 ll_rw_block(READ_META, 1, &bh);
3396 + dx_propagate_tag(nd, inode);
3398 if ((bh = bh_use[ra_ptr++]) == NULL)
3400 @@ -2446,6 +2448,7 @@ const struct inode_operations ext3_dir_i
3401 .removexattr = generic_removexattr,
3403 .check_acl = ext3_check_acl,
3404 + .sync_flags = ext3_sync_flags,
3407 const struct inode_operations ext3_special_inode_operations = {
3408 diff -NurpP --minimal linux-2.6.32.10/fs/ext3/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/super.c
3409 --- linux-2.6.32.10/fs/ext3/super.c 2009-12-03 20:02:51.000000000 +0100
3410 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext3/super.c 2009-12-03 20:04:56.000000000 +0100
3411 @@ -789,7 +789,7 @@ enum {
3412 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3413 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
3414 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3416 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3419 static const match_table_t tokens = {
3420 @@ -842,6 +842,9 @@ static const match_table_t tokens = {
3421 {Opt_usrquota, "usrquota"},
3422 {Opt_barrier, "barrier=%u"},
3423 {Opt_resize, "resize"},
3425 + {Opt_notag, "notag"},
3426 + {Opt_tagid, "tagid=%u"},
3430 @@ -934,6 +937,20 @@ static int parse_options (char *options,
3432 set_opt (sbi->s_mount_opt, NO_UID32);
3434 +#ifndef CONFIG_TAGGING_NONE
3436 + set_opt (sbi->s_mount_opt, TAGGED);
3439 + clear_opt (sbi->s_mount_opt, TAGGED);
3442 +#ifdef CONFIG_PROPAGATE
3445 + set_opt (sbi->s_mount_opt, TAGGED);
3449 clear_opt (sbi->s_mount_opt, CHECK);
3451 @@ -1658,6 +1675,9 @@ static int ext3_fill_super (struct super
3455 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3456 + sb->s_flags |= MS_TAGGED;
3458 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3459 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3461 @@ -2527,6 +2547,14 @@ static int ext3_remount (struct super_bl
3462 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3463 ext3_abort(sb, __func__, "Abort forced by user");
3465 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3466 + !(sb->s_flags & MS_TAGGED)) {
3467 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3470 + goto restore_opts;
3473 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3474 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3476 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/ext4.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/ext4.h
3477 --- linux-2.6.32.10/fs/ext4/ext4.h 2010-03-18 16:17:36.000000000 +0100
3478 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/ext4.h 2010-01-13 14:33:47.000000000 +0100
3479 @@ -284,8 +284,12 @@ struct flex_groups {
3480 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
3481 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3482 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3483 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3484 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3486 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3487 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3489 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3490 #define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
3492 @@ -469,7 +473,8 @@ struct ext4_inode {
3493 __le16 l_i_file_acl_high;
3494 __le16 l_i_uid_high; /* these 2 fields */
3495 __le16 l_i_gid_high; /* were reserved2[0] */
3496 - __u32 l_i_reserved2;
3497 + __le16 l_i_tag; /* Context Tag */
3498 + __u16 l_i_reserved2;
3501 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3502 @@ -583,6 +588,7 @@ do { \
3503 #define i_gid_low i_gid
3504 #define i_uid_high osd2.linux2.l_i_uid_high
3505 #define i_gid_high osd2.linux2.l_i_gid_high
3506 +#define i_raw_tag osd2.linux2.l_i_tag
3507 #define i_reserved2 osd2.linux2.l_i_reserved2
3509 #elif defined(__GNU__)
3510 @@ -755,6 +761,7 @@ struct ext4_inode_info {
3511 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3512 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3513 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3514 +#define EXT4_MOUNT_TAGGED 0x400000 /* Enable Context Tags */
3515 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3516 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3517 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3518 @@ -1746,6 +1753,7 @@ extern int ext4_get_blocks(handle_t *han
3519 struct buffer_head *bh, int flags);
3520 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3521 __u64 start, __u64 len);
3522 +extern int ext4_sync_flags(struct inode *, int, int);
3524 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3525 __u64 start_orig, __u64 start_donor,
3526 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/file.c
3527 --- linux-2.6.32.10/fs/ext4/file.c 2009-12-03 20:02:51.000000000 +0100
3528 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/file.c 2009-12-03 20:04:56.000000000 +0100
3529 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
3530 .check_acl = ext4_check_acl,
3531 .fallocate = ext4_fallocate,
3532 .fiemap = ext4_fiemap,
3533 + .sync_flags = ext4_sync_flags,
3536 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/ialloc.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/ialloc.c
3537 --- linux-2.6.32.10/fs/ext4/ialloc.c 2009-12-03 20:02:51.000000000 +0100
3538 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/ialloc.c 2009-12-03 20:04:56.000000000 +0100
3540 #include <linux/random.h>
3541 #include <linux/bitops.h>
3542 #include <linux/blkdev.h>
3543 +#include <linux/vs_tag.h>
3544 #include <asm/byteorder.h>
3547 @@ -995,6 +996,7 @@ got:
3549 inode->i_gid = current_fsgid();
3550 inode->i_mode = mode;
3551 + inode->i_tag = dx_current_fstag(sb);
3553 inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
3554 /* This is the optimal IO size (for stat), not the fs block size */
3555 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/inode.c
3556 --- linux-2.6.32.10/fs/ext4/inode.c 2010-03-18 16:17:36.000000000 +0100
3557 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/inode.c 2010-01-13 14:33:47.000000000 +0100
3559 #include <linux/uio.h>
3560 #include <linux/bio.h>
3561 #include <linux/workqueue.h>
3562 +#include <linux/vs_tag.h>
3564 #include "ext4_jbd2.h"
3566 @@ -4378,7 +4379,7 @@ static void ext4_free_branches(handle_t
3568 int ext4_can_truncate(struct inode *inode)
3570 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3571 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3573 if (S_ISREG(inode->i_mode))
3575 @@ -4729,36 +4730,60 @@ void ext4_set_inode_flags(struct inode *
3577 unsigned int flags = EXT4_I(inode)->i_flags;
3579 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3580 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3581 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3583 + if (flags & EXT4_IMMUTABLE_FL)
3584 + inode->i_flags |= S_IMMUTABLE;
3585 + if (flags & EXT4_IXUNLINK_FL)
3586 + inode->i_flags |= S_IXUNLINK;
3588 if (flags & EXT4_SYNC_FL)
3589 inode->i_flags |= S_SYNC;
3590 if (flags & EXT4_APPEND_FL)
3591 inode->i_flags |= S_APPEND;
3592 - if (flags & EXT4_IMMUTABLE_FL)
3593 - inode->i_flags |= S_IMMUTABLE;
3594 if (flags & EXT4_NOATIME_FL)
3595 inode->i_flags |= S_NOATIME;
3596 if (flags & EXT4_DIRSYNC_FL)
3597 inode->i_flags |= S_DIRSYNC;
3599 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3601 + if (flags & EXT4_BARRIER_FL)
3602 + inode->i_vflags |= V_BARRIER;
3603 + if (flags & EXT4_COW_FL)
3604 + inode->i_vflags |= V_COW;
3607 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3608 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3610 unsigned int flags = ei->vfs_inode.i_flags;
3611 + unsigned int vflags = ei->vfs_inode.i_vflags;
3613 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3614 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3615 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3616 + EXT4_BARRIER_FL | EXT4_COW_FL);
3618 + if (flags & S_IMMUTABLE)
3619 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3620 + if (flags & S_IXUNLINK)
3621 + ei->i_flags |= EXT4_IXUNLINK_FL;
3623 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3624 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3626 ei->i_flags |= EXT4_SYNC_FL;
3627 if (flags & S_APPEND)
3628 ei->i_flags |= EXT4_APPEND_FL;
3629 - if (flags & S_IMMUTABLE)
3630 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3631 if (flags & S_NOATIME)
3632 ei->i_flags |= EXT4_NOATIME_FL;
3633 if (flags & S_DIRSYNC)
3634 ei->i_flags |= EXT4_DIRSYNC_FL;
3636 + if (vflags & V_BARRIER)
3637 + ei->i_flags |= EXT4_BARRIER_FL;
3638 + if (vflags & V_COW)
3639 + ei->i_flags |= EXT4_COW_FL;
3642 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3643 @@ -4793,6 +4818,8 @@ struct inode *ext4_iget(struct super_blo
3644 journal_t *journal = EXT4_SB(sb)->s_journal;
3650 inode = iget_locked(sb, ino);
3652 @@ -4808,12 +4835,16 @@ struct inode *ext4_iget(struct super_blo
3654 raw_inode = ext4_raw_inode(&iloc);
3655 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3656 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3657 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3658 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3659 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3660 if (!(test_opt(inode->i_sb, NO_UID32))) {
3661 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3662 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3663 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3664 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3666 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3667 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3668 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3669 + le16_to_cpu(raw_inode->i_raw_tag));
3670 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3673 @@ -5035,6 +5066,8 @@ static int ext4_do_update_inode(handle_t
3674 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3675 struct ext4_inode_info *ei = EXT4_I(inode);
3676 struct buffer_head *bh = iloc->bh;
3677 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3678 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3679 int err = 0, rc, block;
3681 /* For fields not not tracking in the in-memory inode,
3682 @@ -5045,29 +5078,32 @@ static int ext4_do_update_inode(handle_t
3683 ext4_get_inode_flags(ei);
3684 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3685 if (!(test_opt(inode->i_sb, NO_UID32))) {
3686 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3687 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3688 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3689 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3691 * Fix up interoperability with old kernels. Otherwise, old inodes get
3692 * re-used with the upper 16 bits of the uid/gid intact
3695 raw_inode->i_uid_high =
3696 - cpu_to_le16(high_16_bits(inode->i_uid));
3697 + cpu_to_le16(high_16_bits(uid));
3698 raw_inode->i_gid_high =
3699 - cpu_to_le16(high_16_bits(inode->i_gid));
3700 + cpu_to_le16(high_16_bits(gid));
3702 raw_inode->i_uid_high = 0;
3703 raw_inode->i_gid_high = 0;
3706 raw_inode->i_uid_low =
3707 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3708 + cpu_to_le16(fs_high2lowuid(uid));
3709 raw_inode->i_gid_low =
3710 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3711 + cpu_to_le16(fs_high2lowgid(gid));
3712 raw_inode->i_uid_high = 0;
3713 raw_inode->i_gid_high = 0;
3715 +#ifdef CONFIG_TAGGING_INTERN
3716 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3718 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3720 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3721 @@ -5252,7 +5288,8 @@ int ext4_setattr(struct dentry *dentry,
3724 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3725 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3726 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3727 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3730 /* (user+group)*(old+new) structure, inode write (sb,
3731 @@ -5274,6 +5311,8 @@ int ext4_setattr(struct dentry *dentry,
3732 inode->i_uid = attr->ia_uid;
3733 if (attr->ia_valid & ATTR_GID)
3734 inode->i_gid = attr->ia_gid;
3735 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3736 + inode->i_tag = attr->ia_tag;
3737 error = ext4_mark_inode_dirty(handle, inode);
3738 ext4_journal_stop(handle);
3740 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/ioctl.c
3741 --- linux-2.6.32.10/fs/ext4/ioctl.c 2010-03-18 16:17:36.000000000 +0100
3742 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/ioctl.c 2009-12-14 22:20:55.000000000 +0100
3744 #include <linux/compat.h>
3745 #include <linux/mount.h>
3746 #include <linux/file.h>
3747 +#include <linux/vs_tag.h>
3748 #include <asm/uaccess.h>
3749 #include "ext4_jbd2.h"
3753 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3755 + handle_t *handle = NULL;
3756 + struct ext4_iloc iloc;
3759 + handle = ext4_journal_start(inode, 1);
3760 + if (IS_ERR(handle))
3761 + return PTR_ERR(handle);
3763 + if (IS_SYNC(inode))
3764 + ext4_handle_sync(handle);
3765 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3769 + inode->i_flags = flags;
3770 + inode->i_vflags = vflags;
3771 + ext4_get_inode_flags(EXT4_I(inode));
3772 + inode->i_ctime = ext4_current_time(inode);
3774 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3776 + ext4_journal_stop(handle);
3780 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3782 struct inode *inode = filp->f_dentry->d_inode;
3783 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3785 flags = ext4_mask_flags(inode->i_mode, flags);
3787 + if (IS_BARRIER(inode)) {
3788 + vxwprintk_task(1, "messing with the barrier.");
3793 mutex_lock(&inode->i_mutex);
3794 /* Is it quota file? Do not allow user to mess with it */
3795 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3797 * This test looks nicer. Thanks to Pauline Middelink
3799 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3800 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3801 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3802 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3803 if (!capable(CAP_LINUX_IMMUTABLE))
3806 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/namei.c
3807 --- linux-2.6.32.10/fs/ext4/namei.c 2010-03-18 16:17:36.000000000 +0100
3808 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/namei.c 2009-12-14 22:20:55.000000000 +0100
3810 #include <linux/quotaops.h>
3811 #include <linux/buffer_head.h>
3812 #include <linux/bio.h>
3813 +#include <linux/vs_tag.h>
3815 #include "ext4_jbd2.h"
3817 @@ -941,6 +942,7 @@ restart:
3819 ll_rw_block(READ_META, 1, &bh);
3821 + dx_propagate_tag(nd, inode);
3823 if ((bh = bh_use[ra_ptr++]) == NULL)
3825 @@ -2533,6 +2535,7 @@ const struct inode_operations ext4_dir_i
3827 .check_acl = ext4_check_acl,
3828 .fiemap = ext4_fiemap,
3829 + .sync_flags = ext4_sync_flags,
3832 const struct inode_operations ext4_special_inode_operations = {
3833 diff -NurpP --minimal linux-2.6.32.10/fs/ext4/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/super.c
3834 --- linux-2.6.32.10/fs/ext4/super.c 2010-03-18 16:17:36.000000000 +0100
3835 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ext4/super.c 2010-01-13 14:33:47.000000000 +0100
3836 @@ -1096,6 +1096,7 @@ enum {
3837 Opt_block_validity, Opt_noblock_validity,
3838 Opt_inode_readahead_blks, Opt_journal_ioprio,
3839 Opt_discard, Opt_nodiscard,
3840 + Opt_tag, Opt_notag, Opt_tagid
3843 static const match_table_t tokens = {
3844 @@ -1163,6 +1164,9 @@ static const match_table_t tokens = {
3845 {Opt_noauto_da_alloc, "noauto_da_alloc"},
3846 {Opt_discard, "discard"},
3847 {Opt_nodiscard, "nodiscard"},
3849 + {Opt_notag, "notag"},
3850 + {Opt_tagid, "tagid=%u"},
3854 @@ -1260,6 +1264,20 @@ static int parse_options(char *options,
3856 set_opt(sbi->s_mount_opt, NO_UID32);
3858 +#ifndef CONFIG_TAGGING_NONE
3860 + set_opt (sbi->s_mount_opt, TAGGED);
3863 + clear_opt (sbi->s_mount_opt, TAGGED);
3866 +#ifdef CONFIG_PROPAGATE
3869 + set_opt (sbi->s_mount_opt, TAGGED);
3873 set_opt(sbi->s_mount_opt, DEBUG);
3875 @@ -2460,6 +2478,9 @@ static int ext4_fill_super(struct super_
3876 &journal_ioprio, NULL, 0))
3879 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3880 + sb->s_flags |= MS_TAGGED;
3882 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3883 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3885 @@ -3517,6 +3538,14 @@ static int ext4_remount(struct super_blo
3886 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3887 ext4_abort(sb, __func__, "Abort forced by user");
3889 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3890 + !(sb->s_flags & MS_TAGGED)) {
3891 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3894 + goto restore_opts;
3897 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3898 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3900 diff -NurpP --minimal linux-2.6.32.10/fs/fcntl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/fcntl.c
3901 --- linux-2.6.32.10/fs/fcntl.c 2010-03-18 16:17:36.000000000 +0100
3902 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/fcntl.c 2010-02-24 12:32:54.000000000 +0100
3904 #include <linux/signal.h>
3905 #include <linux/rcupdate.h>
3906 #include <linux/pid_namespace.h>
3907 +#include <linux/vs_limit.h>
3909 #include <asm/poll.h>
3910 #include <asm/siginfo.h>
3911 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3914 filp_close(tofree, files);
3916 + vx_openfd_inc(newfd); /* fd was unused */
3920 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3924 + if (!vx_files_avail(1))
3927 err = security_file_fcntl(filp, cmd, arg);
3929 diff -NurpP --minimal linux-2.6.32.10/fs/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/file.c
3930 --- linux-2.6.32.10/fs/file.c 2009-12-03 20:02:51.000000000 +0100
3931 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/file.c 2009-12-03 20:04:56.000000000 +0100
3933 #include <linux/spinlock.h>
3934 #include <linux/rcupdate.h>
3935 #include <linux/workqueue.h>
3936 +#include <linux/vs_limit.h>
3938 struct fdtable_defer {
3940 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
3941 struct file *f = *old_fds++;
3944 + /* TODO: sum it first for check and performance */
3945 + vx_openfd_inc(open_files - i);
3948 * The fd may be claimed in the fd bitmap but not yet
3949 @@ -476,6 +479,7 @@ repeat:
3951 FD_CLR(fd, fdt->close_on_exec);
3953 + vx_openfd_inc(fd);
3956 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3957 diff -NurpP --minimal linux-2.6.32.10/fs/file_table.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/file_table.c
3958 --- linux-2.6.32.10/fs/file_table.c 2010-03-18 16:17:36.000000000 +0100
3959 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/file_table.c 2010-03-18 16:53:06.000000000 +0100
3961 #include <linux/fsnotify.h>
3962 #include <linux/sysctl.h>
3963 #include <linux/percpu_counter.h>
3964 +#include <linux/vs_limit.h>
3965 +#include <linux/vs_context.h>
3967 #include <asm/atomic.h>
3969 @@ -131,6 +133,8 @@ struct file *get_empty_filp(void)
3970 spin_lock_init(&f->f_lock);
3971 eventpoll_init_file(f);
3972 /* f->f_version: 0 */
3973 + f->f_xid = vx_current_xid();
3978 @@ -285,6 +289,8 @@ void __fput(struct file *file)
3979 cdev_put(inode->i_cdev);
3980 fops_put(file->f_op);
3981 put_pid(file->f_owner.pid);
3982 + vx_files_dec(file);
3985 if (file->f_mode & FMODE_WRITE)
3986 drop_file_write_access(file);
3987 @@ -352,6 +358,8 @@ void put_filp(struct file *file)
3989 if (atomic_long_dec_and_test(&file->f_count)) {
3990 security_file_free(file);
3991 + vx_files_dec(file);
3996 diff -NurpP --minimal linux-2.6.32.10/fs/fs_struct.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/fs_struct.c
3997 --- linux-2.6.32.10/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
3998 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/fs_struct.c 2009-12-03 20:04:56.000000000 +0100
4000 #include <linux/path.h>
4001 #include <linux/slab.h>
4002 #include <linux/fs_struct.h>
4003 +#include <linux/vserver/global.h>
4006 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4007 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4009 path_put(&fs->root);
4011 + atomic_dec(&vs_global_fs);
4012 kmem_cache_free(fs_cachep, fs);
4015 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
4017 path_get(&old->pwd);
4018 read_unlock(&old->lock);
4019 + atomic_inc(&vs_global_fs);
4023 diff -NurpP --minimal linux-2.6.32.10/fs/gfs2/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/gfs2/file.c
4024 --- linux-2.6.32.10/fs/gfs2/file.c 2009-12-03 20:02:52.000000000 +0100
4025 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/gfs2/file.c 2009-12-03 20:04:56.000000000 +0100
4026 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4027 [7] = GFS2_DIF_NOATIME,
4028 [12] = GFS2_DIF_EXHASH,
4029 [14] = GFS2_DIF_INHERIT_JDATA,
4030 + [27] = GFS2_DIF_IXUNLINK,
4031 + [26] = GFS2_DIF_BARRIER,
4032 + [29] = GFS2_DIF_COW,
4035 static const u32 gfs2_to_fsflags[32] = {
4036 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4037 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4038 [gfs2fl_ExHash] = FS_INDEX_FL,
4039 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4040 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4041 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4042 + [gfs2fl_Cow] = FS_COW_FL,
4045 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4046 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4048 struct gfs2_inode *ip = GFS2_I(inode);
4049 unsigned int flags = inode->i_flags;
4050 + unsigned int vflags = inode->i_vflags;
4052 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4053 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4055 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4056 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4057 flags |= S_IMMUTABLE;
4058 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4059 + flags |= S_IXUNLINK;
4061 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4063 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4064 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4065 if (ip->i_diskflags & GFS2_DIF_SYNC)
4067 inode->i_flags = flags;
4069 + vflags &= ~(V_BARRIER | V_COW);
4071 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4072 + vflags |= V_BARRIER;
4073 + if (ip->i_diskflags & GFS2_DIF_COW)
4075 + inode->i_vflags = vflags;
4078 +void gfs2_get_inode_flags(struct inode *inode)
4080 + struct gfs2_inode *ip = GFS2_I(inode);
4081 + unsigned int flags = inode->i_flags;
4082 + unsigned int vflags = inode->i_vflags;
4084 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4085 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4086 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4087 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4089 + if (flags & S_IMMUTABLE)
4090 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4091 + if (flags & S_IXUNLINK)
4092 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4094 + if (flags & S_APPEND)
4095 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4096 + if (flags & S_NOATIME)
4097 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4098 + if (flags & S_SYNC)
4099 + ip->i_diskflags |= GFS2_DIF_SYNC;
4101 + if (vflags & V_BARRIER)
4102 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4103 + if (vflags & V_COW)
4104 + ip->i_diskflags |= GFS2_DIF_COW;
4107 /* Flags that can be set by user space */
4108 @@ -286,6 +335,37 @@ static int gfs2_set_flags(struct file *f
4109 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4112 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4114 + struct gfs2_inode *ip = GFS2_I(inode);
4115 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4116 + struct buffer_head *bh;
4117 + struct gfs2_holder gh;
4120 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4123 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4126 + error = gfs2_meta_inode_buffer(ip, &bh);
4128 + goto out_trans_end;
4129 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4130 + inode->i_flags = flags;
4131 + inode->i_vflags = vflags;
4132 + gfs2_get_inode_flags(inode);
4133 + gfs2_dinode_out(ip, bh->b_data);
4135 + gfs2_set_aops(inode);
4137 + gfs2_trans_end(sdp);
4139 + gfs2_glock_dq_uninit(&gh);
4143 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4146 diff -NurpP --minimal linux-2.6.32.10/fs/gfs2/inode.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/gfs2/inode.h
4147 --- linux-2.6.32.10/fs/gfs2/inode.h 2009-09-10 15:26:22.000000000 +0200
4148 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/gfs2/inode.h 2009-12-03 20:04:56.000000000 +0100
4149 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4150 extern const struct file_operations gfs2_dir_fops_nolock;
4152 extern void gfs2_set_inode_flags(struct inode *inode);
4153 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4155 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4156 extern const struct file_operations gfs2_file_fops;
4157 diff -NurpP --minimal linux-2.6.32.10/fs/gfs2/ops_inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/gfs2/ops_inode.c
4158 --- linux-2.6.32.10/fs/gfs2/ops_inode.c 2009-12-03 20:02:52.000000000 +0100
4159 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/gfs2/ops_inode.c 2009-12-03 20:04:56.000000000 +0100
4160 @@ -1400,6 +1400,7 @@ const struct inode_operations gfs2_file_
4161 .listxattr = gfs2_listxattr,
4162 .removexattr = gfs2_removexattr,
4163 .fiemap = gfs2_fiemap,
4164 + .sync_flags = gfs2_sync_flags,
4167 const struct inode_operations gfs2_dir_iops = {
4168 @@ -1420,6 +1421,7 @@ const struct inode_operations gfs2_dir_i
4169 .listxattr = gfs2_listxattr,
4170 .removexattr = gfs2_removexattr,
4171 .fiemap = gfs2_fiemap,
4172 + .sync_flags = gfs2_sync_flags,
4175 const struct inode_operations gfs2_symlink_iops = {
4176 diff -NurpP --minimal linux-2.6.32.10/fs/hfsplus/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/hfsplus/ioctl.c
4177 --- linux-2.6.32.10/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4178 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/hfsplus/ioctl.c 2009-12-03 20:04:56.000000000 +0100
4180 #include <linux/mount.h>
4181 #include <linux/sched.h>
4182 #include <linux/xattr.h>
4183 +#include <linux/mount.h>
4184 #include <asm/uaccess.h>
4185 #include "hfsplus_fs.h"
4187 diff -NurpP --minimal linux-2.6.32.10/fs/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/inode.c
4188 --- linux-2.6.32.10/fs/inode.c 2009-12-03 20:02:52.000000000 +0100
4189 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/inode.c 2009-12-03 20:04:56.000000000 +0100
4190 @@ -133,6 +133,9 @@ int inode_init_always(struct super_block
4191 struct address_space *const mapping = &inode->i_data;
4195 + /* essential because of inode slab reuse */
4197 inode->i_blkbits = sb->s_blocksize_bits;
4199 atomic_set(&inode->i_count, 1);
4200 @@ -153,6 +156,7 @@ int inode_init_always(struct super_block
4201 inode->i_bdev = NULL;
4202 inode->i_cdev = NULL;
4204 + inode->i_mdev = 0;
4205 inode->dirtied_when = 0;
4207 if (security_inode_alloc(inode))
4208 @@ -307,6 +311,8 @@ void __iget(struct inode *inode)
4209 inodes_stat.nr_unused--;
4212 +EXPORT_SYMBOL_GPL(__iget);
4215 * clear_inode - clear an inode
4216 * @inode: inode to clear
4217 @@ -1611,9 +1617,11 @@ void init_special_inode(struct inode *in
4218 if (S_ISCHR(mode)) {
4219 inode->i_fop = &def_chr_fops;
4220 inode->i_rdev = rdev;
4221 + inode->i_mdev = rdev;
4222 } else if (S_ISBLK(mode)) {
4223 inode->i_fop = &def_blk_fops;
4224 inode->i_rdev = rdev;
4225 + inode->i_mdev = rdev;
4226 } else if (S_ISFIFO(mode))
4227 inode->i_fop = &def_fifo_fops;
4228 else if (S_ISSOCK(mode))
4229 diff -NurpP --minimal linux-2.6.32.10/fs/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ioctl.c
4230 --- linux-2.6.32.10/fs/ioctl.c 2009-12-03 20:02:52.000000000 +0100
4231 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
4233 #include <linux/writeback.h>
4234 #include <linux/buffer_head.h>
4235 #include <linux/falloc.h>
4236 +#include <linux/proc_fs.h>
4237 +#include <linux/vserver/inode.h>
4238 +#include <linux/vs_tag.h>
4240 #include <asm/ioctls.h>
4242 diff -NurpP --minimal linux-2.6.32.10/fs/ioprio.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ioprio.c
4243 --- linux-2.6.32.10/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
4244 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ioprio.c 2009-12-03 20:04:56.000000000 +0100
4246 #include <linux/syscalls.h>
4247 #include <linux/security.h>
4248 #include <linux/pid_namespace.h>
4249 +#include <linux/vs_base.h>
4251 int set_task_ioprio(struct task_struct *task, int ioprio)
4253 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4255 pgrp = find_vpid(who);
4256 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4257 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4259 ret = set_task_ioprio(p, ioprio);
4262 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4264 pgrp = find_vpid(who);
4265 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4266 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4268 tmpio = get_task_ioprio(p);
4271 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/acl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/acl.c
4272 --- linux-2.6.32.10/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
4273 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/acl.c 2009-12-03 20:04:56.000000000 +0100
4274 @@ -216,7 +216,8 @@ int jfs_setattr(struct dentry *dentry, s
4277 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4278 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4279 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4280 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4281 if (vfs_dq_transfer(inode, iattr))
4284 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/file.c
4285 --- linux-2.6.32.10/fs/jfs/file.c 2009-12-03 20:02:52.000000000 +0100
4286 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/file.c 2009-12-03 20:04:56.000000000 +0100
4287 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4288 .setattr = jfs_setattr,
4289 .check_acl = jfs_check_acl,
4291 + .sync_flags = jfs_sync_flags,
4294 const struct file_operations jfs_file_operations = {
4295 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/ioctl.c
4296 --- linux-2.6.32.10/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4297 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
4299 #include <linux/mount.h>
4300 #include <linux/time.h>
4301 #include <linux/sched.h>
4302 +#include <linux/mount.h>
4303 #include <asm/current.h>
4304 #include <asm/uaccess.h>
4306 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4310 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4312 + inode->i_flags = flags;
4313 + inode->i_vflags = vflags;
4314 + jfs_get_inode_flags(JFS_IP(inode));
4315 + inode->i_ctime = CURRENT_TIME_SEC;
4316 + mark_inode_dirty(inode);
4320 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4322 struct inode *inode = filp->f_dentry->d_inode;
4323 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4324 if (!S_ISDIR(inode->i_mode))
4325 flags &= ~JFS_DIRSYNC_FL;
4327 + if (IS_BARRIER(inode)) {
4328 + vxwprintk_task(1, "messing with the barrier.");
4332 /* Is it quota file? Do not allow user to mess with it */
4333 if (IS_NOQUOTA(inode)) {
4335 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4336 * the relevant capability.
4338 if ((oldflags & JFS_IMMUTABLE_FL) ||
4339 - ((flags ^ oldflags) &
4340 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4341 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4342 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4343 if (!capable(CAP_LINUX_IMMUTABLE)) {
4344 mutex_unlock(&inode->i_mutex);
4346 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4350 - flags = flags & JFS_FL_USER_MODIFIABLE;
4351 + flags &= JFS_FL_USER_MODIFIABLE;
4352 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4353 jfs_inode->mode2 = flags;
4355 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/jfs_dinode.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_dinode.h
4356 --- linux-2.6.32.10/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4357 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_dinode.h 2009-12-03 20:04:56.000000000 +0100
4358 @@ -161,9 +161,13 @@ struct dinode {
4360 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4361 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4362 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4364 -#define JFS_FL_USER_VISIBLE 0x03F80000
4365 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4366 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4367 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4369 +#define JFS_FL_USER_VISIBLE 0x07F80000
4370 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4371 #define JFS_FL_INHERIT 0x03C80000
4373 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4374 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/jfs_filsys.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_filsys.h
4375 --- linux-2.6.32.10/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4376 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_filsys.h 2009-12-03 20:04:56.000000000 +0100
4378 #define JFS_NAME_MAX 255
4379 #define JFS_PATH_MAX BPSIZE
4381 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4384 * file system state (superblock state)
4385 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/jfs_imap.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_imap.c
4386 --- linux-2.6.32.10/fs/jfs/jfs_imap.c 2009-09-10 15:26:22.000000000 +0200
4387 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_imap.c 2009-12-03 20:04:56.000000000 +0100
4389 #include <linux/buffer_head.h>
4390 #include <linux/pagemap.h>
4391 #include <linux/quotaops.h>
4392 +#include <linux/vs_tag.h>
4394 #include "jfs_incore.h"
4395 #include "jfs_inode.h"
4396 @@ -3059,6 +3060,8 @@ static int copy_from_dinode(struct dinod
4398 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4399 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4403 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4404 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4405 @@ -3079,14 +3082,18 @@ static int copy_from_dinode(struct dinod
4407 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4409 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4410 + uid = le32_to_cpu(dip->di_uid);
4411 + gid = le32_to_cpu(dip->di_gid);
4412 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4414 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4416 ip->i_uid = jfs_ip->saved_uid;
4418 ip->i_uid = sbi->uid;
4421 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4422 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4424 ip->i_gid = jfs_ip->saved_gid;
4426 @@ -3151,14 +3158,12 @@ static void copy_to_dinode(struct dinode
4427 dip->di_size = cpu_to_le64(ip->i_size);
4428 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4429 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4430 - if (sbi->uid == -1)
4431 - dip->di_uid = cpu_to_le32(ip->i_uid);
4433 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4434 - if (sbi->gid == -1)
4435 - dip->di_gid = cpu_to_le32(ip->i_gid);
4437 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4439 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4440 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4441 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4442 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4444 jfs_get_inode_flags(jfs_ip);
4446 * mode2 is only needed for storing the higher order bits.
4447 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/jfs_inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_inode.c
4448 --- linux-2.6.32.10/fs/jfs/jfs_inode.c 2009-06-11 17:13:05.000000000 +0200
4449 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_inode.c 2009-12-03 20:04:56.000000000 +0100
4452 #include <linux/fs.h>
4453 #include <linux/quotaops.h>
4454 +#include <linux/vs_tag.h>
4455 #include "jfs_incore.h"
4456 #include "jfs_inode.h"
4457 #include "jfs_filsys.h"
4458 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4460 unsigned int flags = JFS_IP(inode)->mode2;
4462 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4463 - S_NOATIME | S_DIRSYNC | S_SYNC);
4464 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4465 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4467 if (flags & JFS_IMMUTABLE_FL)
4468 inode->i_flags |= S_IMMUTABLE;
4469 + if (flags & JFS_IXUNLINK_FL)
4470 + inode->i_flags |= S_IXUNLINK;
4472 + if (flags & JFS_SYNC_FL)
4473 + inode->i_flags |= S_SYNC;
4474 if (flags & JFS_APPEND_FL)
4475 inode->i_flags |= S_APPEND;
4476 if (flags & JFS_NOATIME_FL)
4477 inode->i_flags |= S_NOATIME;
4478 if (flags & JFS_DIRSYNC_FL)
4479 inode->i_flags |= S_DIRSYNC;
4480 - if (flags & JFS_SYNC_FL)
4481 - inode->i_flags |= S_SYNC;
4483 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4485 + if (flags & JFS_BARRIER_FL)
4486 + inode->i_vflags |= V_BARRIER;
4487 + if (flags & JFS_COW_FL)
4488 + inode->i_vflags |= V_COW;
4491 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4493 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4494 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4496 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4497 + JFS_APPEND_FL | JFS_NOATIME_FL |
4498 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4499 + JFS_BARRIER_FL | JFS_COW_FL);
4501 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4502 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4503 if (flags & S_IMMUTABLE)
4504 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4505 + if (flags & S_IXUNLINK)
4506 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4508 if (flags & S_APPEND)
4509 jfs_ip->mode2 |= JFS_APPEND_FL;
4510 if (flags & S_NOATIME)
4511 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4512 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4514 jfs_ip->mode2 |= JFS_SYNC_FL;
4516 + if (vflags & V_BARRIER)
4517 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4518 + if (vflags & V_COW)
4519 + jfs_ip->mode2 |= JFS_COW_FL;
4523 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
4526 inode->i_gid = current_fsgid();
4527 + inode->i_tag = dx_current_fstag(sb);
4530 * New inodes need to save sane values on disk when
4531 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/jfs_inode.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_inode.h
4532 --- linux-2.6.32.10/fs/jfs/jfs_inode.h 2009-06-11 17:13:05.000000000 +0200
4533 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/jfs_inode.h 2009-12-03 20:04:56.000000000 +0100
4534 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4535 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4536 int fh_len, int fh_type);
4537 extern void jfs_set_inode_flags(struct inode *);
4538 +extern int jfs_sync_flags(struct inode *, int, int);
4539 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4541 extern const struct address_space_operations jfs_aops;
4542 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/namei.c
4543 --- linux-2.6.32.10/fs/jfs/namei.c 2009-12-03 20:02:52.000000000 +0100
4544 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/namei.c 2009-12-03 20:04:56.000000000 +0100
4546 #include <linux/ctype.h>
4547 #include <linux/quotaops.h>
4548 #include <linux/exportfs.h>
4549 +#include <linux/vs_tag.h>
4550 #include "jfs_incore.h"
4551 #include "jfs_superblock.h"
4552 #include "jfs_inode.h"
4553 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4554 return ERR_CAST(ip);
4557 + dx_propagate_tag(nd, ip);
4558 dentry = d_splice_alias(ip, dentry);
4560 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4561 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4562 .setattr = jfs_setattr,
4563 .check_acl = jfs_check_acl,
4565 + .sync_flags = jfs_sync_flags,
4568 const struct file_operations jfs_dir_operations = {
4569 diff -NurpP --minimal linux-2.6.32.10/fs/jfs/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/super.c
4570 --- linux-2.6.32.10/fs/jfs/super.c 2009-12-03 20:02:52.000000000 +0100
4571 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/jfs/super.c 2009-12-03 20:04:56.000000000 +0100
4572 @@ -192,7 +192,8 @@ static void jfs_put_super(struct super_b
4574 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4575 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4576 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4577 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4578 + Opt_tag, Opt_notag, Opt_tagid
4581 static const match_table_t tokens = {
4582 @@ -202,6 +203,10 @@ static const match_table_t tokens = {
4583 {Opt_resize, "resize=%u"},
4584 {Opt_resize_nosize, "resize"},
4585 {Opt_errors, "errors=%s"},
4587 + {Opt_notag, "notag"},
4588 + {Opt_tagid, "tagid=%u"},
4589 + {Opt_tag, "tagxid"},
4590 {Opt_ignore, "noquota"},
4591 {Opt_ignore, "quota"},
4592 {Opt_usrquota, "usrquota"},
4593 @@ -336,6 +341,20 @@ static int parse_options(char *options,
4597 +#ifndef CONFIG_TAGGING_NONE
4599 + *flag |= JFS_TAGGED;
4602 + *flag &= JFS_TAGGED;
4605 +#ifdef CONFIG_PROPAGATE
4608 + *flag |= JFS_TAGGED;
4612 printk("jfs: Unrecognized mount option \"%s\" "
4613 " or missing value\n", p);
4614 @@ -366,6 +385,12 @@ static int jfs_remount(struct super_bloc
4615 if (!parse_options(data, sb, &newLVSize, &flag)) {
4618 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4619 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4626 if (sb->s_flags & MS_RDONLY) {
4627 @@ -449,6 +474,9 @@ static int jfs_fill_super(struct super_b
4628 #ifdef CONFIG_JFS_POSIX_ACL
4629 sb->s_flags |= MS_POSIXACL;
4631 + /* map mount option tagxid */
4632 + if (sbi->flag & JFS_TAGGED)
4633 + sb->s_flags |= MS_TAGGED;
4636 printk(KERN_ERR "resize option for remount only\n");
4637 diff -NurpP --minimal linux-2.6.32.10/fs/libfs.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/libfs.c
4638 --- linux-2.6.32.10/fs/libfs.c 2009-12-03 20:02:52.000000000 +0100
4639 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/libfs.c 2009-12-03 20:04:56.000000000 +0100
4640 @@ -127,7 +127,8 @@ static inline unsigned char dt_type(stru
4641 * both impossible due to the lock on directory.
4644 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4645 +static inline int do_dcache_readdir_filter(struct file *filp,
4646 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4648 struct dentry *dentry = filp->f_path.dentry;
4649 struct dentry *cursor = filp->private_data;
4650 @@ -160,6 +161,8 @@ int dcache_readdir(struct file * filp, v
4651 next = list_entry(p, struct dentry, d_u.d_child);
4652 if (d_unhashed(next) || !next->d_inode)
4654 + if (filter && !filter(next))
4657 spin_unlock(&dcache_lock);
4658 if (filldir(dirent, next->d_name.name,
4659 @@ -178,6 +181,18 @@ int dcache_readdir(struct file * filp, v
4663 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4665 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4668 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4669 + int (*filter)(struct dentry *))
4671 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4675 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4678 @@ -841,6 +856,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4679 EXPORT_SYMBOL(dcache_dir_lseek);
4680 EXPORT_SYMBOL(dcache_dir_open);
4681 EXPORT_SYMBOL(dcache_readdir);
4682 +EXPORT_SYMBOL(dcache_readdir_filter);
4683 EXPORT_SYMBOL(generic_read_dir);
4684 EXPORT_SYMBOL(get_sb_pseudo);
4685 EXPORT_SYMBOL(simple_write_begin);
4686 diff -NurpP --minimal linux-2.6.32.10/fs/locks.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/locks.c
4687 --- linux-2.6.32.10/fs/locks.c 2009-12-03 20:02:52.000000000 +0100
4688 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/locks.c 2009-12-03 20:04:56.000000000 +0100
4690 #include <linux/time.h>
4691 #include <linux/rcupdate.h>
4692 #include <linux/pid_namespace.h>
4693 +#include <linux/vs_base.h>
4694 +#include <linux/vs_limit.h>
4696 #include <asm/uaccess.h>
4698 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4699 /* Allocate an empty lock structure. */
4700 static struct file_lock *locks_alloc_lock(void)
4702 + if (!vx_locks_avail(1))
4704 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4707 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4708 BUG_ON(!list_empty(&fl->fl_block));
4709 BUG_ON(!list_empty(&fl->fl_link));
4712 locks_release_private(fl);
4713 kmem_cache_free(filelock_cache, fl);
4715 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
4716 fl->fl_start = fl->fl_end = 0;
4718 fl->fl_lmops = NULL;
4722 EXPORT_SYMBOL(locks_init_lock);
4723 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
4724 new->fl_file = fl->fl_file;
4725 new->fl_ops = fl->fl_ops;
4726 new->fl_lmops = fl->fl_lmops;
4727 + new->fl_xid = fl->fl_xid;
4729 locks_copy_private(new, fl);
4731 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
4732 fl->fl_flags = FL_FLOCK;
4734 fl->fl_end = OFFSET_MAX;
4736 + vxd_assert(filp->f_xid == vx_current_xid(),
4737 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4738 + fl->fl_xid = filp->f_xid;
4743 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
4745 fl->fl_owner = current->files;
4746 fl->fl_pid = current->tgid;
4747 + fl->fl_xid = vx_current_xid();
4750 fl->fl_flags = FL_LEASE;
4751 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
4753 return ERR_PTR(error);
4755 + fl->fl_xid = vx_current_xid();
4757 + vxd_assert(filp->f_xid == fl->fl_xid,
4758 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4760 error = lease_init(filp, type, fl);
4762 locks_free_lock(fl);
4763 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
4767 + new_fl->fl_xid = -1;
4769 for_each_lock(inode, before) {
4770 struct file_lock *fl = *before;
4771 @@ -790,6 +809,7 @@ find_conflict:
4773 locks_copy_lock(new_fl, request);
4774 locks_insert_lock(before, new_fl);
4775 + vx_locks_inc(new_fl);
4779 @@ -800,7 +820,8 @@ out:
4783 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4784 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4785 + struct file_lock *conflock, xid_t xid)
4787 struct file_lock *fl;
4788 struct file_lock *new_fl = NULL;
4789 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
4790 struct file_lock **before;
4791 int error, added = 0;
4793 + vxd_assert(xid == vx_current_xid(),
4794 + "xid(%d) == current(%d)", xid, vx_current_xid());
4796 * We may need two file_lock structures for this operation,
4797 * so we get them in advance to avoid races.
4798 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
4799 (request->fl_type != F_UNLCK ||
4800 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4801 new_fl = locks_alloc_lock();
4802 + new_fl->fl_xid = xid;
4803 + vx_locks_inc(new_fl);
4804 new_fl2 = locks_alloc_lock();
4805 + new_fl2->fl_xid = xid;
4806 + vx_locks_inc(new_fl2);
4810 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
4811 int posix_lock_file(struct file *filp, struct file_lock *fl,
4812 struct file_lock *conflock)
4814 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4815 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4816 + fl, conflock, filp->f_xid);
4818 EXPORT_SYMBOL(posix_lock_file);
4820 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
4821 fl.fl_end = offset + count - 1;
4824 - error = __posix_lock_file(inode, &fl, NULL);
4825 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4826 if (error != FILE_LOCK_DEFERRED)
4828 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4829 @@ -1424,6 +1452,7 @@ int generic_setlease(struct file *filp,
4831 locks_copy_lock(new_fl, lease);
4832 locks_insert_lock(before, new_fl);
4833 + vx_locks_inc(new_fl);
4837 @@ -1779,6 +1808,11 @@ int fcntl_setlk(unsigned int fd, struct
4838 if (file_lock == NULL)
4841 + vxd_assert(filp->f_xid == vx_current_xid(),
4842 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4843 + file_lock->fl_xid = filp->f_xid;
4844 + vx_locks_inc(file_lock);
4847 * This might block, so we do it before checking the inode.
4849 @@ -1897,6 +1931,11 @@ int fcntl_setlk64(unsigned int fd, struc
4850 if (file_lock == NULL)
4853 + vxd_assert(filp->f_xid == vx_current_xid(),
4854 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4855 + file_lock->fl_xid = filp->f_xid;
4856 + vx_locks_inc(file_lock);
4859 * This might block, so we do it before checking the inode.
4861 @@ -2162,8 +2201,11 @@ static int locks_show(struct seq_file *f
4863 lock_get_status(f, fl, (long)f->private, "");
4865 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4866 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4867 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4869 lock_get_status(f, bfl, (long)f->private, " ->");
4874 diff -NurpP --minimal linux-2.6.32.10/fs/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/namei.c
4875 --- linux-2.6.32.10/fs/namei.c 2010-03-18 16:17:36.000000000 +0100
4876 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/namei.c 2010-03-18 16:53:06.000000000 +0100
4878 #include <linux/fcntl.h>
4879 #include <linux/device_cgroup.h>
4880 #include <linux/fs_struct.h>
4881 +#include <linux/proc_fs.h>
4882 +#include <linux/vserver/inode.h>
4883 +#include <linux/vs_base.h>
4884 +#include <linux/vs_tag.h>
4885 +#include <linux/vs_cowbl.h>
4886 +#include <linux/vs_device.h>
4887 +#include <linux/vs_context.h>
4888 +#include <linux/pid_namespace.h>
4889 #include <asm/uaccess.h>
4891 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
4892 @@ -169,6 +177,77 @@ void putname(const char *name)
4893 EXPORT_SYMBOL(putname);
4896 +static inline int dx_barrier(const struct inode *inode)
4898 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4899 + vxwprintk_task(1, "did hit the barrier.");
4905 +static int __dx_permission(const struct inode *inode, int mask)
4907 + if (dx_barrier(inode))
4910 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4911 + /* devpts is xid tagged */
4912 + if (S_ISDIR(inode->i_mode) ||
4913 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4916 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4917 + struct proc_dir_entry *de = PDE(inode);
4919 + if (de && !vx_hide_check(0, de->vx_flags))
4922 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4924 + struct task_struct *tsk;
4926 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4927 + vx_flags(VXF_STATE_SETUP, 0))
4930 + pid = PROC_I(inode)->pid;
4934 + tsk = pid_task(pid, PIDTYPE_PID);
4935 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4936 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4937 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4941 + /* FIXME: Should we block some entries here? */
4946 + if (dx_notagcheck(inode->i_sb) ||
4947 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4956 +int dx_permission(const struct inode *inode, int mask)
4958 + int ret = __dx_permission(inode, mask);
4959 + if (unlikely(ret)) {
4960 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
4961 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4968 * This does basic POSIX ACL permission checking
4970 @@ -269,10 +348,14 @@ int inode_permission(struct inode *inode
4972 * Nobody gets write access to an immutable file.
4974 - if (IS_IMMUTABLE(inode))
4975 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4979 + retval = dx_permission(inode, mask);
4983 if (inode->i_op->permission)
4984 retval = inode->i_op->permission(inode, mask);
4986 @@ -448,6 +531,9 @@ static int exec_permission_lite(struct i
4990 + if (dx_barrier(inode))
4993 if (inode->i_op->permission) {
4994 ret = inode->i_op->permission(inode, MAY_EXEC);
4996 @@ -763,7 +849,8 @@ static __always_inline void follow_dotdo
4998 if (nd->path.dentry == nd->root.dentry &&
4999 nd->path.mnt == nd->root.mnt) {
5001 + /* for sane '/' avoid follow_mount() */
5004 spin_lock(&dcache_lock);
5005 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5006 @@ -799,16 +886,30 @@ static int do_lookup(struct nameidata *n
5008 struct vfsmount *mnt = nd->path.mnt;
5009 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5010 + struct inode *inode;
5014 if (dentry->d_op && dentry->d_op->d_revalidate)
5015 goto need_revalidate;
5016 + inode = dentry->d_inode;
5020 + if (__dx_permission(inode, MAY_ACCESS))
5025 path->dentry = dentry;
5026 __follow_mount(path);
5029 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
5030 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5031 + vxd_path(&nd->path), name->len, name->name);
5036 dentry = real_lookup(nd->path.dentry, name, nd);
5037 @@ -1400,7 +1501,7 @@ static int may_delete(struct inode *dir,
5040 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5041 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5042 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5045 if (!S_ISDIR(victim->d_inode->i_mode))
5046 @@ -1540,6 +1641,14 @@ int may_open(struct path *path, int acc_
5050 +#ifdef CONFIG_VSERVER_COWBL
5051 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5052 + if (IS_COW_LINK(inode))
5054 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5055 + mark_inode_dirty(inode);
5058 error = inode_permission(inode, acc_mode);
5061 @@ -1688,7 +1797,11 @@ struct file *do_filp_open(int dfd, const
5064 int flag = open_to_namei_flags(open_flag);
5066 +#ifdef CONFIG_VSERVER_COWBL
5072 acc_mode = MAY_OPEN | ACC_MODE(flag);
5074 @@ -1836,6 +1949,25 @@ ok:
5077 error = may_open(&nd.path, acc_mode, flag);
5078 +#ifdef CONFIG_VSERVER_COWBL
5079 + if (error == -EMLINK) {
5080 + struct dentry *dentry;
5081 + dentry = cow_break_link(pathname);
5082 + if (IS_ERR(dentry)) {
5083 + error = PTR_ERR(dentry);
5088 + mnt_drop_write(nd.path.mnt);
5089 + release_open_intent(&nd);
5090 + path_put(&nd.path);
5099 mnt_drop_write(nd.path.mnt);
5100 @@ -1998,9 +2130,17 @@ int vfs_mknod(struct inode *dir, struct
5104 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5105 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5108 + if (!capable(CAP_MKNOD))
5111 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5113 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5116 if (!dir->i_op->mknod)
5119 @@ -2467,7 +2607,7 @@ int vfs_link(struct dentry *old_dentry,
5121 * A link to an append-only or immutable file cannot be created.
5123 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5124 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5126 if (!dir->i_op->link)
5128 @@ -2840,6 +2980,219 @@ int vfs_follow_link(struct nameidata *nd
5129 return __vfs_follow_link(nd, link);
5133 +#ifdef CONFIG_VSERVER_COWBL
5135 +#include <linux/file.h>
5138 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5142 + return do_splice_direct(in, &ppos, out, len, 0);
5145 +struct dentry *cow_break_link(const char *pathname)
5147 + int ret, mode, pathlen, redo = 0;
5148 + struct nameidata old_nd, dir_nd;
5149 + struct path old_path, new_path;
5150 + struct dentry *dir, *res = NULL;
5151 + struct file *old_file;
5152 + struct file *new_file;
5153 + char *to, *path, pad='\251';
5156 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5157 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5162 + /* old_nd will have refs to dentry and mnt */
5163 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5164 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5166 + goto out_free_path;
5168 + old_path = old_nd.path;
5169 + mode = old_path.dentry->d_inode->i_mode;
5171 + to = d_path(&old_path, path, PATH_MAX-2);
5172 + pathlen = strlen(to);
5173 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5174 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5175 + old_path.dentry->d_name.len);
5177 + to[pathlen + 1] = 0;
5179 + to[pathlen] = pad--;
5181 + if (pad <= '\240')
5184 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5185 + /* dir_nd will have refs to dentry and mnt */
5186 + ret = path_lookup(to,
5187 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5188 + vxdprintk(VXD_CBIT(misc, 2),
5189 + "path_lookup(new): %d", ret);
5193 + /* this puppy downs the inode mutex */
5194 + new_path.dentry = lookup_create(&dir_nd, 0);
5195 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5196 + vxdprintk(VXD_CBIT(misc, 2),
5197 + "lookup_create(new): %p", new_path.dentry);
5198 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5199 + path_put(&dir_nd.path);
5202 + vxdprintk(VXD_CBIT(misc, 2),
5203 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5204 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5205 + new_path.dentry->d_name.len);
5206 + dir = dir_nd.path.dentry;
5208 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5209 + vxdprintk(VXD_CBIT(misc, 2),
5210 + "vfs_create(new): %d", ret);
5211 + if (ret == -EEXIST) {
5212 + mutex_unlock(&dir->d_inode->i_mutex);
5213 + dput(new_path.dentry);
5214 + path_put(&dir_nd.path);
5218 + goto out_unlock_new;
5220 + /* drop out early, ret passes ENOENT */
5222 + if ((redo = d_unhashed(old_path.dentry)))
5223 + goto out_unlock_new;
5225 + new_path.mnt = dir_nd.path.mnt;
5226 + dget(old_path.dentry);
5227 + mntget(old_path.mnt);
5228 + /* this one cleans up the dentry/mnt in case of failure */
5229 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5230 + O_RDONLY, current_cred());
5231 + vxdprintk(VXD_CBIT(misc, 2),
5232 + "dentry_open(old): %p", old_file);
5233 + if (!old_file || IS_ERR(old_file)) {
5234 + res = IS_ERR(old_file) ? (void *) old_file : res;
5235 + goto out_unlock_new;
5238 + dget(new_path.dentry);
5239 + mntget(new_path.mnt);
5240 + /* this one cleans up the dentry/mnt in case of failure */
5241 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5242 + O_WRONLY, current_cred());
5243 + vxdprintk(VXD_CBIT(misc, 2),
5244 + "dentry_open(new): %p", new_file);
5246 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5247 + if (!new_file || IS_ERR(new_file))
5248 + goto out_fput_old;
5250 + size = i_size_read(old_file->f_dentry->d_inode);
5251 + ret = do_cow_splice(old_file, new_file, size);
5252 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5254 + goto out_fput_both;
5255 + } else if (ret < size) {
5257 + goto out_fput_both;
5259 + struct inode *old_inode = old_path.dentry->d_inode;
5260 + struct inode *new_inode = new_path.dentry->d_inode;
5261 + struct iattr attr = {
5262 + .ia_uid = old_inode->i_uid,
5263 + .ia_gid = old_inode->i_gid,
5264 + .ia_valid = ATTR_UID | ATTR_GID
5267 + ret = inode_setattr(new_inode, &attr);
5269 + goto out_fput_both;
5272 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5274 + /* drop out late */
5276 + if ((redo = d_unhashed(old_path.dentry)))
5279 + vxdprintk(VXD_CBIT(misc, 2),
5280 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5281 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5282 + new_path.dentry->d_name.len,
5283 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5284 + old_path.dentry->d_name.len);
5285 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5286 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5287 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5288 + res = new_path.dentry;
5291 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5294 + vxdprintk(VXD_CBIT(misc, 3),
5295 + "fput(new_file=%p[#%ld])", new_file,
5296 + atomic_long_read(&new_file->f_count));
5300 + vxdprintk(VXD_CBIT(misc, 3),
5301 + "fput(old_file=%p[#%ld])", old_file,
5302 + atomic_long_read(&old_file->f_count));
5306 + mutex_unlock(&dir->d_inode->i_mutex);
5310 + /* error path cleanup */
5311 + vfs_unlink(dir->d_inode, new_path.dentry);
5312 + dput(new_path.dentry);
5316 + goto out_rel_both;
5317 + /* lookup dentry once again */
5318 + path_put(&old_nd.path);
5319 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5321 + goto out_rel_both;
5323 + new_path.dentry = old_nd.path.dentry;
5324 + vxdprintk(VXD_CBIT(misc, 2),
5325 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5326 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5327 + new_path.dentry->d_name.len);
5328 + dget(new_path.dentry);
5329 + res = new_path.dentry;
5332 + path_put(&dir_nd.path);
5334 + path_put(&old_nd.path);
5339 + res = ERR_PTR(ret);
5345 /* get the link contents into pagecache */
5346 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5348 diff -NurpP --minimal linux-2.6.32.10/fs/namespace.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/namespace.c
5349 --- linux-2.6.32.10/fs/namespace.c 2009-12-03 20:02:52.000000000 +0100
5350 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/namespace.c 2009-12-03 20:04:56.000000000 +0100
5352 #include <linux/log2.h>
5353 #include <linux/idr.h>
5354 #include <linux/fs_struct.h>
5355 +#include <linux/vs_base.h>
5356 +#include <linux/vs_context.h>
5357 +#include <linux/vs_tag.h>
5358 +#include <linux/vserver/space.h>
5359 +#include <linux/vserver/global.h>
5360 #include <asm/uaccess.h>
5361 #include <asm/unistd.h>
5363 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
5364 mnt->mnt_root = dget(root);
5365 mnt->mnt_mountpoint = mnt->mnt_root;
5366 mnt->mnt_parent = mnt;
5367 + mnt->mnt_tag = old->mnt_tag;
5369 if (flag & CL_SLAVE) {
5370 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5371 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
5372 seq_escape(m, s, " \t\n\\");
5375 +static int mnt_is_reachable(struct vfsmount *mnt)
5378 + struct dentry *point;
5381 + if (mnt == mnt->mnt_ns->root)
5384 + spin_lock(&vfsmount_lock);
5385 + root = current->fs->root;
5386 + point = root.dentry;
5388 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5389 + point = mnt->mnt_mountpoint;
5390 + mnt = mnt->mnt_parent;
5393 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5395 + spin_unlock(&vfsmount_lock);
5401 * Simple .show_options callback for filesystems which don't want to
5402 * implement more complex mount option showing.
5403 @@ -748,6 +779,8 @@ static int show_sb_opts(struct seq_file
5404 { MS_SYNCHRONOUS, ",sync" },
5405 { MS_DIRSYNC, ",dirsync" },
5406 { MS_MANDLOCK, ",mand" },
5407 + { MS_TAGGED, ",tag" },
5408 + { MS_NOTAGCHECK, ",notagcheck" },
5411 const struct proc_fs_info *fs_infop;
5412 @@ -795,10 +828,20 @@ static int show_vfsmnt(struct seq_file *
5414 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5416 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5418 - seq_path(m, &mnt_path, " \t\n\\");
5420 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5422 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5425 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5426 + mnt == current->fs->root.mnt) {
5427 + seq_puts(m, "/dev/root / ");
5429 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5431 + seq_path(m, &mnt_path, " \t\n\\");
5434 show_type(m, mnt->mnt_sb);
5435 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5436 err = show_sb_opts(m, mnt->mnt_sb);
5437 @@ -828,6 +871,11 @@ static int show_mountinfo(struct seq_fil
5438 struct path root = p->root;
5441 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5443 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5446 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5447 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5448 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5449 @@ -886,17 +934,27 @@ static int show_vfsstat(struct seq_file
5450 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5454 - if (mnt->mnt_devname) {
5455 - seq_puts(m, "device ");
5456 - mangle(m, mnt->mnt_devname);
5458 - seq_puts(m, "no device");
5459 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5461 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5465 - seq_puts(m, " mounted on ");
5466 - seq_path(m, &mnt_path, " \t\n\\");
5468 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5469 + mnt == current->fs->root.mnt) {
5470 + seq_puts(m, "device /dev/root mounted on / ");
5473 + if (mnt->mnt_devname) {
5474 + seq_puts(m, "device ");
5475 + mangle(m, mnt->mnt_devname);
5477 + seq_puts(m, "no device");
5480 + seq_puts(m, " mounted on ");
5481 + seq_path(m, &mnt_path, " \t\n\\");
5485 /* file system type */
5486 seq_puts(m, "with fstype ");
5487 @@ -1130,7 +1188,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5491 - if (!capable(CAP_SYS_ADMIN))
5492 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5495 retval = do_umount(path.mnt, flags);
5496 @@ -1156,7 +1214,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5498 static int mount_is_safe(struct path *path)
5500 - if (capable(CAP_SYS_ADMIN))
5501 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5505 @@ -1420,7 +1478,7 @@ static int do_change_type(struct path *p
5506 int type = flag & ~MS_REC;
5509 - if (!capable(CAP_SYS_ADMIN))
5510 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5513 if (path->dentry != path->mnt->mnt_root)
5514 @@ -1447,11 +1505,13 @@ static int do_change_type(struct path *p
5515 * do loopback mount.
5517 static int do_loopback(struct path *path, char *old_name,
5519 + tag_t tag, unsigned long flags, int mnt_flags)
5521 struct path old_path;
5522 struct vfsmount *mnt = NULL;
5523 int err = mount_is_safe(path);
5524 + int recurse = flags & MS_REC;
5528 if (!old_name || !*old_name)
5529 @@ -1485,6 +1545,7 @@ static int do_loopback(struct path *path
5530 spin_unlock(&vfsmount_lock);
5531 release_mounts(&umount_list);
5533 + mnt->mnt_flags = mnt_flags;
5536 up_write(&namespace_sem);
5537 @@ -1515,12 +1576,12 @@ static int change_mount_flags(struct vfs
5538 * on it - tough luck.
5540 static int do_remount(struct path *path, int flags, int mnt_flags,
5542 + void *data, xid_t xid)
5545 struct super_block *sb = path->mnt->mnt_sb;
5547 - if (!capable(CAP_SYS_ADMIN))
5548 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5551 if (!check_mnt(path->mnt))
5552 @@ -1562,7 +1623,7 @@ static int do_move_mount(struct path *pa
5553 struct path old_path, parent_path;
5556 - if (!capable(CAP_SYS_ADMIN))
5557 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5559 if (!old_name || !*old_name)
5561 @@ -1644,7 +1705,7 @@ static int do_new_mount(struct path *pat
5564 /* we need capabilities... */
5565 - if (!capable(CAP_SYS_ADMIN))
5566 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5570 @@ -1908,6 +1969,7 @@ long do_mount(char *dev_name, char *dir_
5577 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5578 @@ -1925,6 +1987,12 @@ long do_mount(char *dev_name, char *dir_
5579 if (!(flags & MS_NOATIME))
5580 mnt_flags |= MNT_RELATIME;
5582 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5583 + /* FIXME: bind and re-mounts get the tag flag? */
5584 + if (flags & (MS_BIND|MS_REMOUNT))
5585 + flags |= MS_TAGID;
5588 /* Separate the per-mountpoint flags */
5589 if (flags & MS_NOSUID)
5590 mnt_flags |= MNT_NOSUID;
5591 @@ -1941,6 +2009,8 @@ long do_mount(char *dev_name, char *dir_
5592 if (flags & MS_RDONLY)
5593 mnt_flags |= MNT_READONLY;
5595 + if (!capable(CAP_SYS_ADMIN))
5596 + mnt_flags |= MNT_NODEV;
5597 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5598 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5600 @@ -1957,9 +2027,9 @@ long do_mount(char *dev_name, char *dir_
5602 if (flags & MS_REMOUNT)
5603 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5606 else if (flags & MS_BIND)
5607 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5608 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5609 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5610 retval = do_change_type(&path, flags);
5611 else if (flags & MS_MOVE)
5612 @@ -2038,6 +2108,7 @@ static struct mnt_namespace *dup_mnt_ns(
5613 q = next_mnt(q, new_ns->root);
5615 up_write(&namespace_sem);
5616 + atomic_inc(&vs_global_mnt_ns);
5620 @@ -2182,9 +2253,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5621 down_write(&namespace_sem);
5622 mutex_lock(&old.dentry->d_inode->i_mutex);
5624 - if (IS_MNT_SHARED(old.mnt) ||
5625 + if ((IS_MNT_SHARED(old.mnt) ||
5626 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5627 - IS_MNT_SHARED(root.mnt->mnt_parent))
5628 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5629 + !vx_flags(VXF_STATE_SETUP, 0))
5631 if (!check_mnt(root.mnt))
5633 @@ -2320,6 +2392,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5634 spin_unlock(&vfsmount_lock);
5635 up_write(&namespace_sem);
5636 release_mounts(&umount_list);
5637 + atomic_dec(&vs_global_mnt_ns);
5640 EXPORT_SYMBOL(put_mnt_ns);
5641 diff -NurpP --minimal linux-2.6.32.10/fs/nfs/client.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/client.c
5642 --- linux-2.6.32.10/fs/nfs/client.c 2009-12-03 20:02:52.000000000 +0100
5643 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/client.c 2009-12-03 20:04:56.000000000 +0100
5644 @@ -738,6 +738,9 @@ static int nfs_init_server_rpcclient(str
5645 if (server->flags & NFS_MOUNT_SOFT)
5646 server->client->cl_softrtry = 1;
5648 + server->client->cl_tag = 0;
5649 + if (server->flags & NFS_MOUNT_TAGGED)
5650 + server->client->cl_tag = 1;
5654 @@ -909,6 +912,10 @@ static void nfs_server_set_fsinfo(struct
5655 server->acdirmin = server->acdirmax = 0;
5658 + /* FIXME: needs fsinfo
5659 + if (server->flags & NFS_MOUNT_TAGGED)
5660 + sb->s_flags |= MS_TAGGED; */
5662 server->maxfilesize = fsinfo->maxfilesize;
5664 /* We're airborne Set socket buffersize */
5665 diff -NurpP --minimal linux-2.6.32.10/fs/nfs/dir.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/dir.c
5666 --- linux-2.6.32.10/fs/nfs/dir.c 2009-12-03 20:02:52.000000000 +0100
5667 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/dir.c 2009-12-03 20:04:56.000000000 +0100
5669 #include <linux/namei.h>
5670 #include <linux/mount.h>
5671 #include <linux/sched.h>
5672 +#include <linux/vs_tag.h>
5674 #include "nfs4_fs.h"
5675 #include "delegation.h"
5676 @@ -949,6 +950,7 @@ static struct dentry *nfs_lookup(struct
5678 goto out_unblock_sillyrename;
5680 + dx_propagate_tag(nd, inode);
5682 res = d_materialise_unique(dentry, inode);
5684 diff -NurpP --minimal linux-2.6.32.10/fs/nfs/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/inode.c
5685 --- linux-2.6.32.10/fs/nfs/inode.c 2009-12-03 20:02:52.000000000 +0100
5686 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/inode.c 2009-12-03 20:04:56.000000000 +0100
5688 #include <linux/vfs.h>
5689 #include <linux/inet.h>
5690 #include <linux/nfs_xdr.h>
5691 +#include <linux/vs_tag.h>
5693 #include <asm/system.h>
5694 #include <asm/uaccess.h>
5695 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5696 if (inode->i_state & I_NEW) {
5697 struct nfs_inode *nfsi = NFS_I(inode);
5698 unsigned long now = jiffies;
5702 /* We set i_ino for the few things that still rely on it,
5703 * such as stat(2) */
5704 @@ -327,8 +330,8 @@ nfs_fhget(struct super_block *sb, struct
5705 nfsi->change_attr = 0;
5708 - inode->i_uid = -2;
5709 - inode->i_gid = -2;
5712 inode->i_blocks = 0;
5713 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5715 @@ -365,13 +368,13 @@ nfs_fhget(struct super_block *sb, struct
5716 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5717 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5718 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5719 - inode->i_uid = fattr->uid;
5721 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5722 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5723 | NFS_INO_INVALID_ACCESS
5724 | NFS_INO_INVALID_ACL;
5725 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5726 - inode->i_gid = fattr->gid;
5728 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5729 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5730 | NFS_INO_INVALID_ACCESS
5731 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
5733 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5735 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5736 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5737 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5738 + /* maybe fattr->xid someday */
5740 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5741 nfsi->attrtimeo_timestamp = now;
5742 nfsi->access_cache = RB_ROOT;
5743 @@ -496,6 +504,8 @@ void nfs_setattr_update_inode(struct ino
5744 inode->i_uid = attr->ia_uid;
5745 if ((attr->ia_valid & ATTR_GID) != 0)
5746 inode->i_gid = attr->ia_gid;
5747 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5748 + inode->i_tag = attr->ia_tag;
5749 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5750 spin_unlock(&inode->i_lock);
5752 @@ -906,6 +916,9 @@ static int nfs_check_inode_attributes(st
5753 struct nfs_inode *nfsi = NFS_I(inode);
5754 loff_t cur_size, new_isize;
5755 unsigned long invalid = 0;
5761 /* Has the inode gone and changed behind our back? */
5762 @@ -929,13 +942,18 @@ static int nfs_check_inode_attributes(st
5763 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5766 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5767 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5768 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5770 /* Have any file permissions changed? */
5771 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5772 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5773 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5774 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5775 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5776 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5777 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5778 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5779 + /* maybe check for tag too? */
5781 /* Has the link count changed? */
5782 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5783 @@ -1150,6 +1168,9 @@ static int nfs_update_inode(struct inode
5784 unsigned long invalid = 0;
5785 unsigned long now = jiffies;
5786 unsigned long save_cache_validity;
5791 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5792 __func__, inode->i_sb->s_id, inode->i_ino,
5793 @@ -1252,6 +1273,9 @@ static int nfs_update_inode(struct inode
5794 | NFS_INO_REVAL_PAGECACHE
5795 | NFS_INO_REVAL_FORCED);
5797 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5798 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5799 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5801 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5802 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5803 @@ -1271,9 +1295,9 @@ static int nfs_update_inode(struct inode
5804 | NFS_INO_REVAL_FORCED);
5806 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5807 - if (inode->i_uid != fattr->uid) {
5808 + if (uid != fattr->uid) {
5809 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5810 - inode->i_uid = fattr->uid;
5813 } else if (server->caps & NFS_CAP_OWNER)
5814 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5815 @@ -1282,9 +1306,9 @@ static int nfs_update_inode(struct inode
5816 | NFS_INO_REVAL_FORCED);
5818 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5819 - if (inode->i_gid != fattr->gid) {
5820 + if (gid != fattr->gid) {
5821 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5822 - inode->i_gid = fattr->gid;
5825 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5826 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5827 @@ -1292,6 +1316,10 @@ static int nfs_update_inode(struct inode
5828 | NFS_INO_INVALID_ACL
5829 | NFS_INO_REVAL_FORCED);
5831 + inode->i_uid = uid;
5832 + inode->i_gid = gid;
5833 + inode->i_tag = tag;
5835 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5836 if (inode->i_nlink != fattr->nlink) {
5837 invalid |= NFS_INO_INVALID_ATTR;
5838 diff -NurpP --minimal linux-2.6.32.10/fs/nfs/nfs3xdr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/nfs3xdr.c
5839 --- linux-2.6.32.10/fs/nfs/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
5840 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/nfs3xdr.c 2009-12-03 20:04:56.000000000 +0100
5842 #include <linux/nfs3.h>
5843 #include <linux/nfs_fs.h>
5844 #include <linux/nfsacl.h>
5845 +#include <linux/vs_tag.h>
5846 #include "internal.h"
5848 #define NFSDBG_FACILITY NFSDBG_XDR
5849 @@ -176,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5852 static inline __be32 *
5853 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5854 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5856 if (attr->ia_valid & ATTR_MODE) {
5858 @@ -184,15 +185,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5862 - if (attr->ia_valid & ATTR_UID) {
5863 + if (attr->ia_valid & ATTR_UID ||
5864 + (tag && (attr->ia_valid & ATTR_TAG))) {
5866 - *p++ = htonl(attr->ia_uid);
5867 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5871 - if (attr->ia_valid & ATTR_GID) {
5872 + if (attr->ia_valid & ATTR_GID ||
5873 + (tag && (attr->ia_valid & ATTR_TAG))) {
5875 - *p++ = htonl(attr->ia_gid);
5876 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5880 @@ -279,7 +282,8 @@ static int
5881 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5883 p = xdr_encode_fhandle(p, args->fh);
5884 - p = xdr_encode_sattr(p, args->sattr);
5885 + p = xdr_encode_sattr(p, args->sattr,
5886 + req->rq_task->tk_client->cl_tag);
5887 *p++ = htonl(args->guard);
5889 p = xdr_encode_time3(p, &args->guardtime);
5890 @@ -384,7 +388,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5891 *p++ = args->verifier[0];
5892 *p++ = args->verifier[1];
5894 - p = xdr_encode_sattr(p, args->sattr);
5895 + p = xdr_encode_sattr(p, args->sattr,
5896 + req->rq_task->tk_client->cl_tag);
5898 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5900 @@ -398,7 +403,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5902 p = xdr_encode_fhandle(p, args->fh);
5903 p = xdr_encode_array(p, args->name, args->len);
5904 - p = xdr_encode_sattr(p, args->sattr);
5905 + p = xdr_encode_sattr(p, args->sattr,
5906 + req->rq_task->tk_client->cl_tag);
5907 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5910 @@ -411,7 +417,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5912 p = xdr_encode_fhandle(p, args->fromfh);
5913 p = xdr_encode_array(p, args->fromname, args->fromlen);
5914 - p = xdr_encode_sattr(p, args->sattr);
5915 + p = xdr_encode_sattr(p, args->sattr,
5916 + req->rq_task->tk_client->cl_tag);
5917 *p++ = htonl(args->pathlen);
5918 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5920 @@ -429,7 +436,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5921 p = xdr_encode_fhandle(p, args->fh);
5922 p = xdr_encode_array(p, args->name, args->len);
5923 *p++ = htonl(args->type);
5924 - p = xdr_encode_sattr(p, args->sattr);
5925 + p = xdr_encode_sattr(p, args->sattr,
5926 + req->rq_task->tk_client->cl_tag);
5927 if (args->type == NF3CHR || args->type == NF3BLK) {
5928 *p++ = htonl(MAJOR(args->rdev));
5929 *p++ = htonl(MINOR(args->rdev));
5930 diff -NurpP --minimal linux-2.6.32.10/fs/nfs/nfsroot.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/nfsroot.c
5931 --- linux-2.6.32.10/fs/nfs/nfsroot.c 2009-09-10 15:26:23.000000000 +0200
5932 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/nfsroot.c 2009-12-03 20:04:56.000000000 +0100
5933 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
5935 /* Options that take integer arguments */
5936 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
5937 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
5938 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
5939 /* Options that take no arguments */
5940 Opt_soft, Opt_hard, Opt_intr,
5941 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
5942 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
5943 - Opt_acl, Opt_noacl,
5944 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
5948 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
5951 {Opt_noacl, "noacl"},
5953 + {Opt_notag, "notag"},
5954 + {Opt_tagid, "tagid=%u"},
5958 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
5960 nfs_data.flags |= NFS_MOUNT_NOACL;
5962 +#ifndef CONFIG_TAGGING_NONE
5964 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5967 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
5970 +#ifdef CONFIG_PROPAGATE
5973 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5977 printk(KERN_WARNING "Root-NFS: unknown "
5979 diff -NurpP --minimal linux-2.6.32.10/fs/nfs/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/super.c
5980 --- linux-2.6.32.10/fs/nfs/super.c 2010-03-18 16:17:36.000000000 +0100
5981 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfs/super.c 2010-02-24 12:32:54.000000000 +0100
5983 #include <linux/nfs_xdr.h>
5984 #include <linux/magic.h>
5985 #include <linux/parser.h>
5986 +#include <linux/vs_tag.h>
5988 #include <asm/system.h>
5989 #include <asm/uaccess.h>
5990 @@ -554,6 +555,7 @@ static void nfs_show_mount_options(struc
5991 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5992 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5993 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5994 + { NFS_MOUNT_TAGGED, ",tag", "" },
5997 const struct proc_nfs_info *nfs_infop;
5998 diff -NurpP --minimal linux-2.6.32.10/fs/nfsd/auth.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/auth.c
5999 --- linux-2.6.32.10/fs/nfsd/auth.c 2009-12-03 20:02:52.000000000 +0100
6000 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/auth.c 2009-12-03 20:04:56.000000000 +0100
6002 #include <linux/sunrpc/svcauth.h>
6003 #include <linux/nfsd/nfsd.h>
6004 #include <linux/nfsd/export.h>
6005 +#include <linux/vs_tag.h>
6008 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6009 @@ -44,6 +45,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6011 new->fsuid = rqstp->rq_cred.cr_uid;
6012 new->fsgid = rqstp->rq_cred.cr_gid;
6013 + /* FIXME: this desperately needs a tag :)
6014 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6017 rqgi = rqstp->rq_cred.cr_group_info;
6019 diff -NurpP --minimal linux-2.6.32.10/fs/nfsd/nfs3xdr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/nfs3xdr.c
6020 --- linux-2.6.32.10/fs/nfsd/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
6021 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/nfs3xdr.c 2009-12-03 20:04:56.000000000 +0100
6023 #include <linux/sunrpc/svc.h>
6024 #include <linux/nfsd/nfsd.h>
6025 #include <linux/nfsd/xdr3.h>
6026 +#include <linux/vs_tag.h>
6029 #define NFSDDBG_FACILITY NFSDDBG_XDR
6030 @@ -108,6 +109,8 @@ static __be32 *
6031 decode_sattr3(__be32 *p, struct iattr *iap)
6039 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6042 iap->ia_valid |= ATTR_UID;
6043 - iap->ia_uid = ntohl(*p++);
6044 + uid = ntohl(*p++);
6047 iap->ia_valid |= ATTR_GID;
6048 - iap->ia_gid = ntohl(*p++);
6049 + gid = ntohl(*p++);
6051 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6052 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6053 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6057 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6058 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6059 *p++ = htonl((u32) stat->mode);
6060 *p++ = htonl((u32) stat->nlink);
6061 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6062 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6063 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6064 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6065 + stat->uid, stat->tag)));
6066 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6067 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6068 + stat->gid, stat->tag)));
6069 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6070 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6072 diff -NurpP --minimal linux-2.6.32.10/fs/nfsd/nfs4xdr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/nfs4xdr.c
6073 --- linux-2.6.32.10/fs/nfsd/nfs4xdr.c 2009-12-03 20:02:52.000000000 +0100
6074 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/nfs4xdr.c 2009-12-03 20:04:56.000000000 +0100
6076 #include <linux/nfs4_acl.h>
6077 #include <linux/sunrpc/gss_api.h>
6078 #include <linux/sunrpc/svcauth_gss.h>
6079 +#include <linux/vs_tag.h>
6081 #define NFSDDBG_FACILITY NFSDDBG_XDR
6083 @@ -2050,14 +2051,18 @@ out_acl:
6084 WRITE32(stat.nlink);
6086 if (bmval1 & FATTR4_WORD1_OWNER) {
6087 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6088 + status = nfsd4_encode_user(rqstp,
6089 + TAGINO_UID(DX_TAG(dentry->d_inode),
6090 + stat.uid, stat.tag), &p, &buflen);
6091 if (status == nfserr_resource)
6096 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6097 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6098 + status = nfsd4_encode_group(rqstp,
6099 + TAGINO_GID(DX_TAG(dentry->d_inode),
6100 + stat.gid, stat.tag), &p, &buflen);
6101 if (status == nfserr_resource)
6104 diff -NurpP --minimal linux-2.6.32.10/fs/nfsd/nfsxdr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/nfsxdr.c
6105 --- linux-2.6.32.10/fs/nfsd/nfsxdr.c 2008-12-25 00:26:37.000000000 +0100
6106 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/nfsd/nfsxdr.c 2009-12-03 20:04:56.000000000 +0100
6108 #include <linux/nfsd/nfsd.h>
6109 #include <linux/nfsd/xdr.h>
6110 #include <linux/mm.h>
6111 +#include <linux/vs_tag.h>
6114 #define NFSDDBG_FACILITY NFSDDBG_XDR
6115 @@ -98,6 +99,8 @@ static __be32 *
6116 decode_sattr(__be32 *p, struct iattr *iap)
6124 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6126 if ((tmp = ntohl(*p++)) != (u32)-1) {
6127 iap->ia_valid |= ATTR_UID;
6128 - iap->ia_uid = tmp;
6131 if ((tmp = ntohl(*p++)) != (u32)-1) {
6132 iap->ia_valid |= ATTR_GID;
6133 - iap->ia_gid = tmp;
6136 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6137 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6138 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6139 if ((tmp = ntohl(*p++)) != (u32)-1) {
6140 iap->ia_valid |= ATTR_SIZE;
6142 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6143 *p++ = htonl(nfs_ftypes[type >> 12]);
6144 *p++ = htonl((u32) stat->mode);
6145 *p++ = htonl((u32) stat->nlink);
6146 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6147 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6148 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6149 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6150 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6151 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6153 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6154 *p++ = htonl(NFS_MAXPATHLEN);
6155 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/dlm/dlmfs.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/dlm/dlmfs.c
6156 --- linux-2.6.32.10/fs/ocfs2/dlm/dlmfs.c 2009-12-03 20:02:53.000000000 +0100
6157 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/dlm/dlmfs.c 2009-12-03 20:04:56.000000000 +0100
6159 #include <linux/init.h>
6160 #include <linux/string.h>
6161 #include <linux/backing-dev.h>
6162 +#include <linux/vs_tag.h>
6164 #include <asm/uaccess.h>
6166 @@ -342,6 +343,7 @@ static struct inode *dlmfs_get_root_inod
6167 inode->i_mode = mode;
6168 inode->i_uid = current_fsuid();
6169 inode->i_gid = current_fsgid();
6170 + inode->i_tag = dx_current_fstag(sb);
6171 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6172 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6174 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6175 inode->i_mode = mode;
6176 inode->i_uid = current_fsuid();
6177 inode->i_gid = current_fsgid();
6178 + inode->i_tag = dx_current_fstag(sb);
6179 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6180 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6182 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/dlmglue.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/dlmglue.c
6183 --- linux-2.6.32.10/fs/ocfs2/dlmglue.c 2009-12-03 20:02:53.000000000 +0100
6184 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/dlmglue.c 2009-12-03 20:04:56.000000000 +0100
6185 @@ -1991,6 +1991,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6186 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6187 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6188 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6189 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6190 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6191 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6192 lvb->lvb_iatime_packed =
6193 @@ -2045,6 +2046,7 @@ static void ocfs2_refresh_inode_from_lvb
6195 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6196 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6197 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6198 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6199 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6200 ocfs2_unpack_timespec(&inode->i_atime,
6201 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/dlmglue.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/dlmglue.h
6202 --- linux-2.6.32.10/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
6203 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/dlmglue.h 2009-12-03 20:04:56.000000000 +0100
6204 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6207 __be32 lvb_igeneration;
6208 - __be32 lvb_reserved2;
6210 + __be16 lvb_reserved2;
6213 #define OCFS2_QINFO_LVB_VERSION 1
6214 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/file.c
6215 --- linux-2.6.32.10/fs/ocfs2/file.c 2009-12-03 20:02:53.000000000 +0100
6216 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/file.c 2009-12-03 20:04:56.000000000 +0100
6217 @@ -960,13 +960,15 @@ int ocfs2_setattr(struct dentry *dentry,
6218 mlog(0, "uid change: %d\n", attr->ia_uid);
6219 if (attr->ia_valid & ATTR_GID)
6220 mlog(0, "gid change: %d\n", attr->ia_gid);
6221 + if (attr->ia_valid & ATTR_TAG)
6222 + mlog(0, "tag change: %d\n", attr->ia_tag);
6223 if (attr->ia_valid & ATTR_SIZE)
6224 mlog(0, "size change...\n");
6225 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6226 mlog(0, "time change...\n");
6228 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6229 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6230 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6231 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6232 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6234 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/inode.c
6235 --- linux-2.6.32.10/fs/ocfs2/inode.c 2009-12-03 20:02:53.000000000 +0100
6236 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/inode.c 2009-12-03 20:04:56.000000000 +0100
6238 #include <linux/highmem.h>
6239 #include <linux/pagemap.h>
6240 #include <linux/quotaops.h>
6241 +#include <linux/vs_tag.h>
6243 #include <asm/byteorder.h>
6245 @@ -79,11 +80,13 @@ void ocfs2_set_inode_flags(struct inode
6247 unsigned int flags = OCFS2_I(inode)->ip_attr;
6249 - inode->i_flags &= ~(S_IMMUTABLE |
6250 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6251 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6253 if (flags & OCFS2_IMMUTABLE_FL)
6254 inode->i_flags |= S_IMMUTABLE;
6255 + if (flags & OCFS2_IXUNLINK_FL)
6256 + inode->i_flags |= S_IXUNLINK;
6258 if (flags & OCFS2_SYNC_FL)
6259 inode->i_flags |= S_SYNC;
6260 @@ -93,25 +96,44 @@ void ocfs2_set_inode_flags(struct inode
6261 inode->i_flags |= S_NOATIME;
6262 if (flags & OCFS2_DIRSYNC_FL)
6263 inode->i_flags |= S_DIRSYNC;
6265 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6267 + if (flags & OCFS2_BARRIER_FL)
6268 + inode->i_vflags |= V_BARRIER;
6269 + if (flags & OCFS2_COW_FL)
6270 + inode->i_vflags |= V_COW;
6273 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6274 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6276 unsigned int flags = oi->vfs_inode.i_flags;
6277 + unsigned int vflags = oi->vfs_inode.i_vflags;
6279 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6280 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6281 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6282 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6284 + if (flags & S_IMMUTABLE)
6285 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6286 + if (flags & S_IXUNLINK)
6287 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6289 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6290 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6292 oi->ip_attr |= OCFS2_SYNC_FL;
6293 if (flags & S_APPEND)
6294 oi->ip_attr |= OCFS2_APPEND_FL;
6295 - if (flags & S_IMMUTABLE)
6296 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6297 if (flags & S_NOATIME)
6298 oi->ip_attr |= OCFS2_NOATIME_FL;
6299 if (flags & S_DIRSYNC)
6300 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6302 + if (vflags & V_BARRIER)
6303 + oi->ip_attr |= OCFS2_BARRIER_FL;
6304 + if (vflags & V_COW)
6305 + oi->ip_attr |= OCFS2_COW_FL;
6308 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6309 @@ -246,6 +268,8 @@ void ocfs2_populate_inode(struct inode *
6310 struct super_block *sb;
6311 struct ocfs2_super *osb;
6316 mlog_entry("(0x%p, size:%llu)\n", inode,
6317 (unsigned long long)le64_to_cpu(fe->i_size));
6318 @@ -277,8 +301,12 @@ void ocfs2_populate_inode(struct inode *
6319 inode->i_generation = le32_to_cpu(fe->i_generation);
6320 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6321 inode->i_mode = le16_to_cpu(fe->i_mode);
6322 - inode->i_uid = le32_to_cpu(fe->i_uid);
6323 - inode->i_gid = le32_to_cpu(fe->i_gid);
6324 + uid = le32_to_cpu(fe->i_uid);
6325 + gid = le32_to_cpu(fe->i_gid);
6326 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6327 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6328 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6329 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6331 /* Fast symlinks will have i_size but no allocated clusters. */
6332 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6333 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/inode.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/inode.h
6334 --- linux-2.6.32.10/fs/ocfs2/inode.h 2009-12-03 20:02:53.000000000 +0100
6335 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/inode.h 2009-12-03 20:04:56.000000000 +0100
6336 @@ -150,6 +150,7 @@ struct buffer_head *ocfs2_bread(struct i
6338 void ocfs2_set_inode_flags(struct inode *inode);
6339 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6340 +int ocfs2_sync_flags(struct inode *inode, int, int);
6342 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6344 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/ioctl.c
6345 --- linux-2.6.32.10/fs/ocfs2/ioctl.c 2009-12-03 20:02:53.000000000 +0100
6346 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/ioctl.c 2009-12-03 20:04:56.000000000 +0100
6347 @@ -42,7 +42,41 @@ static int ocfs2_get_inode_attr(struct i
6351 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6352 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6354 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6355 + struct buffer_head *bh = NULL;
6356 + handle_t *handle = NULL;
6359 + status = ocfs2_inode_lock(inode, &bh, 1);
6361 + mlog_errno(status);
6364 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6365 + if (IS_ERR(handle)) {
6366 + status = PTR_ERR(handle);
6367 + mlog_errno(status);
6371 + inode->i_flags = flags;
6372 + inode->i_vflags = vflags;
6373 + ocfs2_get_inode_flags(OCFS2_I(inode));
6375 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6377 + mlog_errno(status);
6379 + ocfs2_commit_trans(osb, handle);
6381 + ocfs2_inode_unlock(inode, 1);
6386 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6389 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6390 @@ -67,6 +101,11 @@ static int ocfs2_set_inode_attr(struct i
6391 if (!S_ISDIR(inode->i_mode))
6392 flags &= ~OCFS2_DIRSYNC_FL;
6394 + if (IS_BARRIER(inode)) {
6395 + vxwprintk_task(1, "messing with the barrier.");
6399 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6400 if (IS_ERR(handle)) {
6401 status = PTR_ERR(handle);
6402 @@ -108,6 +147,7 @@ bail:
6407 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6409 struct inode *inode = filp->f_path.dentry->d_inode;
6410 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/namei.c
6411 --- linux-2.6.32.10/fs/ocfs2/namei.c 2009-12-03 20:02:53.000000000 +0100
6412 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/namei.c 2009-12-03 20:04:56.000000000 +0100
6414 #include <linux/slab.h>
6415 #include <linux/highmem.h>
6416 #include <linux/quotaops.h>
6417 +#include <linux/vs_tag.h>
6419 #define MLOG_MASK_PREFIX ML_NAMEI
6420 #include <cluster/masklog.h>
6421 @@ -481,6 +482,7 @@ static int ocfs2_mknod_locked(struct ocf
6429 @@ -524,8 +526,11 @@ static int ocfs2_mknod_locked(struct ocf
6430 fe->i_blkno = cpu_to_le64(fe_blkno);
6431 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6432 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6433 - fe->i_uid = cpu_to_le32(inode->i_uid);
6434 - fe->i_gid = cpu_to_le32(inode->i_gid);
6436 + tag = dx_current_fstag(osb->sb);
6437 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6438 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6439 + inode->i_tag = tag;
6440 fe->i_mode = cpu_to_le16(inode->i_mode);
6441 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6442 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6443 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/ocfs2_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/ocfs2_fs.h
6444 --- linux-2.6.32.10/fs/ocfs2/ocfs2_fs.h 2009-12-03 20:02:53.000000000 +0100
6445 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/ocfs2_fs.h 2009-12-03 20:04:56.000000000 +0100
6446 @@ -231,18 +231,23 @@
6447 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
6449 /* Inode attributes, keep in sync with EXT2 */
6450 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6451 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6452 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6453 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6454 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6455 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6456 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6457 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6458 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6459 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6460 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6461 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6462 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6463 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6464 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6465 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6466 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6468 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6469 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6470 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6471 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6473 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6474 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6476 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6477 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6480 * Extent record flags (e_node.leaf.flags)
6481 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/ocfs2.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/ocfs2.h
6482 --- linux-2.6.32.10/fs/ocfs2/ocfs2.h 2009-12-03 20:02:53.000000000 +0100
6483 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/ocfs2.h 2009-12-03 20:04:56.000000000 +0100
6484 @@ -248,6 +248,7 @@ enum ocfs2_mount_options
6485 OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
6486 OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
6487 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
6488 + OCFS2_MOUNT_TAGGED = 1 << 11, /* use tagging */
6491 #define OCFS2_OSB_SOFT_RO 0x0001
6492 diff -NurpP --minimal linux-2.6.32.10/fs/ocfs2/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/super.c
6493 --- linux-2.6.32.10/fs/ocfs2/super.c 2009-12-03 20:02:53.000000000 +0100
6494 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/ocfs2/super.c 2009-12-03 20:04:56.000000000 +0100
6495 @@ -173,6 +173,7 @@ enum {
6499 + Opt_tag, Opt_notag, Opt_tagid,
6503 @@ -199,6 +200,9 @@ static const match_table_t tokens = {
6504 {Opt_noacl, "noacl"},
6505 {Opt_usrquota, "usrquota"},
6506 {Opt_grpquota, "grpquota"},
6508 + {Opt_notag, "notag"},
6509 + {Opt_tagid, "tagid=%u"},
6513 @@ -605,6 +609,13 @@ static int ocfs2_remount(struct super_bl
6517 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6518 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6520 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6524 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6525 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6527 @@ -1148,6 +1159,9 @@ static int ocfs2_fill_super(struct super
6529 ocfs2_complete_mount_recovery(osb);
6531 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6532 + sb->s_flags |= MS_TAGGED;
6534 if (ocfs2_mount_local(osb))
6535 snprintf(nodestr, sizeof(nodestr), "local");
6537 @@ -1426,6 +1440,20 @@ static int ocfs2_parse_options(struct su
6538 printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
6541 +#ifndef CONFIG_TAGGING_NONE
6543 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6546 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6549 +#ifdef CONFIG_PROPAGATE
6552 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6557 "Unrecognized mount option \"%s\" "
6558 diff -NurpP --minimal linux-2.6.32.10/fs/open.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/open.c
6559 --- linux-2.6.32.10/fs/open.c 2009-12-03 20:02:53.000000000 +0100
6560 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/open.c 2009-12-03 20:04:56.000000000 +0100
6562 #include <linux/audit.h>
6563 #include <linux/falloc.h>
6564 #include <linux/fs_struct.h>
6565 +#include <linux/vs_base.h>
6566 +#include <linux/vs_limit.h>
6567 +#include <linux/vs_tag.h>
6568 +#include <linux/vs_cowbl.h>
6570 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6572 int retval = -ENODEV;
6575 + struct super_block *sb = dentry->d_sb;
6578 - if (dentry->d_sb->s_op->statfs) {
6579 + if (sb->s_op->statfs) {
6580 memset(buf, 0, sizeof(*buf));
6581 retval = security_sb_statfs(dentry);
6584 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6585 + retval = sb->s_op->statfs(dentry, buf);
6586 if (retval == 0 && buf->f_frsize == 0)
6587 buf->f_frsize = buf->f_bsize;
6589 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6590 + vx_vsi_statfs(sb, buf);
6594 @@ -640,6 +648,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6595 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6599 + error = cow_check_and_break(&path);
6601 + goto dput_and_out;
6602 inode = path.dentry->d_inode;
6604 error = mnt_want_write(path.mnt);
6605 @@ -673,11 +685,11 @@ static int chown_common(struct dentry *
6606 newattrs.ia_valid = ATTR_CTIME;
6607 if (user != (uid_t) -1) {
6608 newattrs.ia_valid |= ATTR_UID;
6609 - newattrs.ia_uid = user;
6610 + newattrs.ia_uid = dx_map_uid(user);
6612 if (group != (gid_t) -1) {
6613 newattrs.ia_valid |= ATTR_GID;
6614 - newattrs.ia_gid = group;
6615 + newattrs.ia_gid = dx_map_gid(group);
6617 if (!S_ISDIR(inode->i_mode))
6618 newattrs.ia_valid |=
6619 @@ -700,7 +712,11 @@ SYSCALL_DEFINE3(chown, const char __user
6620 error = mnt_want_write(path.mnt);
6623 - error = chown_common(path.dentry, user, group);
6624 +#ifdef CONFIG_VSERVER_COWBL
6625 + error = cow_check_and_break(&path);
6628 + error = chown_common(path.dentry, user, group);
6629 mnt_drop_write(path.mnt);
6632 @@ -725,7 +741,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6633 error = mnt_want_write(path.mnt);
6636 - error = chown_common(path.dentry, user, group);
6637 +#ifdef CONFIG_VSERVER_COWBL
6638 + error = cow_check_and_break(&path);
6641 + error = chown_common(path.dentry, user, group);
6642 mnt_drop_write(path.mnt);
6645 @@ -744,7 +764,11 @@ SYSCALL_DEFINE3(lchown, const char __use
6646 error = mnt_want_write(path.mnt);
6649 - error = chown_common(path.dentry, user, group);
6650 +#ifdef CONFIG_VSERVER_COWBL
6651 + error = cow_check_and_break(&path);
6654 + error = chown_common(path.dentry, user, group);
6655 mnt_drop_write(path.mnt);
6658 @@ -990,6 +1014,7 @@ static void __put_unused_fd(struct files
6659 __FD_CLR(fd, fdt->open_fds);
6660 if (fd < files->next_fd)
6661 files->next_fd = fd;
6662 + vx_openfd_dec(fd);
6665 void put_unused_fd(unsigned int fd)
6666 diff -NurpP --minimal linux-2.6.32.10/fs/proc/array.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/array.c
6667 --- linux-2.6.32.10/fs/proc/array.c 2009-12-03 20:02:53.000000000 +0100
6668 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/array.c 2009-12-03 20:04:56.000000000 +0100
6670 #include <linux/ptrace.h>
6671 #include <linux/tracehook.h>
6672 #include <linux/swapops.h>
6673 +#include <linux/vs_context.h>
6674 +#include <linux/vs_network.h>
6676 #include <asm/pgtable.h>
6677 #include <asm/processor.h>
6678 @@ -139,8 +141,9 @@ static const char *task_state_array[] =
6679 "D (disk sleep)", /* 2 */
6680 "T (stopped)", /* 4 */
6681 "T (tracing stop)", /* 8 */
6682 - "Z (zombie)", /* 16 */
6683 - "X (dead)" /* 32 */
6684 + "H (on hold)", /* 16 */
6685 + "Z (zombie)", /* 32 */
6686 + "X (dead)", /* 64 */
6689 static inline const char *get_task_state(struct task_struct *tsk)
6690 @@ -167,6 +170,9 @@ static inline void task_state(struct seq
6692 ppid = pid_alive(p) ?
6693 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6694 + if (unlikely(vx_current_initpid(p->pid)))
6699 struct task_struct *tracer = tracehook_tracer_task(p);
6700 @@ -282,7 +288,7 @@ static inline void task_sig(struct seq_f
6703 static void render_cap_t(struct seq_file *m, const char *header,
6705 + struct vx_info *vxi, kernel_cap_t *a)
6709 @@ -307,10 +313,11 @@ static inline void task_cap(struct seq_f
6710 cap_bset = cred->cap_bset;
6713 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6714 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6715 - render_cap_t(m, "CapEff:\t", &cap_effective);
6716 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6717 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6718 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6719 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6720 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6721 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6724 static inline void task_context_switch_counts(struct seq_file *m,
6725 @@ -410,6 +417,42 @@ static void task_show_stack_usage(struct
6727 #endif /* CONFIG_MMU */
6729 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6730 + struct pid *pid, struct task_struct *task)
6732 + seq_printf(m, "Proxy:\t%p(%c)\n"
6740 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6741 + atomic_read(&task->nsproxy->count),
6742 + task->nsproxy->uts_ns,
6743 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6744 + task->nsproxy->ipc_ns,
6745 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6746 + task->nsproxy->mnt_ns,
6747 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6748 + task->nsproxy->pid_ns,
6749 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6750 + task->nsproxy->net_ns,
6751 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6755 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6757 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6760 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6761 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6765 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6766 struct pid *pid, struct task_struct *task)
6768 @@ -425,6 +468,7 @@ int proc_pid_status(struct seq_file *m,
6771 cpuset_task_status_allowed(m, task);
6772 + task_vs_id(m, task);
6773 #if defined(CONFIG_S390)
6774 task_show_regs(m, task);
6776 @@ -542,6 +586,17 @@ static int do_task_stat(struct seq_file
6777 /* convert nsec -> ticks */
6778 start_time = nsec_to_clock_t(start_time);
6780 + /* fixup start time for virt uptime */
6781 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6782 + unsigned long long bias =
6783 + current->vx_info->cvirt.bias_clock;
6785 + if (start_time > bias)
6786 + start_time -= bias;
6791 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6792 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6793 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6794 diff -NurpP --minimal linux-2.6.32.10/fs/proc/base.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/base.c
6795 --- linux-2.6.32.10/fs/proc/base.c 2010-03-18 16:17:37.000000000 +0100
6796 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/base.c 2010-03-18 16:53:06.000000000 +0100
6798 #include <linux/elf.h>
6799 #include <linux/pid_namespace.h>
6800 #include <linux/fs_struct.h>
6801 +#include <linux/vs_context.h>
6802 +#include <linux/vs_network.h>
6803 #include "internal.h"
6806 @@ -1047,12 +1049,17 @@ static ssize_t oom_adjust_write(struct f
6810 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6811 + if (oom_adjust < task->signal->oom_adj &&
6812 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6813 unlock_task_sighand(task, &flags);
6814 put_task_struct(task);
6818 + /* prevent guest processes from circumventing the oom killer */
6819 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6820 + oom_adjust = OOM_ADJUST_MIN;
6822 task->signal->oom_adj = oom_adjust;
6824 unlock_task_sighand(task, &flags);
6825 @@ -1092,7 +1099,7 @@ static ssize_t proc_loginuid_write(struc
6829 - if (!capable(CAP_AUDIT_CONTROL))
6830 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6833 if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
6834 @@ -1458,6 +1465,8 @@ static struct inode *proc_pid_make_inode
6835 inode->i_gid = cred->egid;
6838 + /* procfs is xid tagged */
6839 + inode->i_tag = (tag_t)vx_task_xid(task);
6840 security_task_to_inode(task, inode);
6843 @@ -2008,6 +2017,13 @@ static struct dentry *proc_pident_lookup
6847 + /* TODO: maybe we can come up with a generic approach? */
6848 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6849 + (dentry->d_name.len == 5) &&
6850 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6851 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6855 * Yes, it does not scale. And it should not. Don't add
6856 * new entries into /proc/<tgid>/ without very good reasons.
6857 @@ -2413,7 +2429,7 @@ out_iput:
6858 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6860 struct dentry *error;
6861 - struct task_struct *task = get_proc_task(dir);
6862 + struct task_struct *task = get_proc_task_real(dir);
6863 const struct pid_entry *p, *last;
6865 error = ERR_PTR(-ENOENT);
6866 @@ -2503,6 +2519,9 @@ static int proc_pid_personality(struct s
6867 static const struct file_operations proc_task_operations;
6868 static const struct inode_operations proc_task_inode_operations;
6870 +extern int proc_pid_vx_info(struct task_struct *, char *);
6871 +extern int proc_pid_nx_info(struct task_struct *, char *);
6873 static const struct pid_entry tgid_base_stuff[] = {
6874 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6875 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6876 @@ -2561,6 +2580,8 @@ static const struct pid_entry tgid_base_
6877 #ifdef CONFIG_CGROUPS
6878 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6880 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6881 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6882 INF("oom_score", S_IRUGO, proc_oom_score),
6883 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6884 #ifdef CONFIG_AUDITSYSCALL
6885 @@ -2576,6 +2597,7 @@ static const struct pid_entry tgid_base_
6886 #ifdef CONFIG_TASK_IO_ACCOUNTING
6887 INF("io", S_IRUGO, proc_tgid_io_accounting),
6889 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6892 static int proc_tgid_base_readdir(struct file * filp,
6893 @@ -2767,7 +2789,7 @@ retry:
6895 pid = find_ge_pid(iter.tgid, ns);
6897 - iter.tgid = pid_nr_ns(pid, ns);
6898 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6899 iter.task = pid_task(pid, PIDTYPE_PID);
6900 /* What we to know is if the pid we have find is the
6901 * pid of a thread_group_leader. Testing for task
6902 @@ -2797,7 +2819,7 @@ static int proc_pid_fill_cache(struct fi
6903 struct tgid_iter iter)
6905 char name[PROC_NUMBUF];
6906 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6907 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6908 return proc_fill_cache(filp, dirent, filldir, name, len,
6909 proc_pid_instantiate, iter.task, NULL);
6911 @@ -2806,7 +2828,7 @@ static int proc_pid_fill_cache(struct fi
6912 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6914 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6915 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6916 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6917 struct tgid_iter iter;
6918 struct pid_namespace *ns;
6920 @@ -2826,6 +2848,8 @@ int proc_pid_readdir(struct file * filp,
6922 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6923 filp->f_pos = iter.tgid + TGID_OFFSET;
6924 + if (!vx_proc_task_visible(iter.task))
6926 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6927 put_task_struct(iter.task);
6929 @@ -2972,6 +2996,8 @@ static struct dentry *proc_task_lookup(s
6930 tid = name_to_int(dentry);
6933 + if (vx_current_initpid(tid))
6936 ns = dentry->d_sb->s_fs_info;
6938 diff -NurpP --minimal linux-2.6.32.10/fs/proc/generic.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/generic.c
6939 --- linux-2.6.32.10/fs/proc/generic.c 2009-06-11 17:13:07.000000000 +0200
6940 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/generic.c 2009-12-03 20:04:56.000000000 +0100
6942 #include <linux/bitops.h>
6943 #include <linux/spinlock.h>
6944 #include <linux/completion.h>
6945 +#include <linux/vserver/inode.h>
6946 #include <asm/uaccess.h>
6948 #include "internal.h"
6949 @@ -425,6 +426,8 @@ struct dentry *proc_lookup_de(struct pro
6950 for (de = de->subdir; de ; de = de->next) {
6951 if (de->namelen != dentry->d_name.len)
6953 + if (!vx_hide_check(0, de->vx_flags))
6955 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6958 @@ -433,6 +436,8 @@ struct dentry *proc_lookup_de(struct pro
6959 spin_unlock(&proc_subdir_lock);
6961 inode = proc_get_inode(dir->i_sb, ino, de);
6962 + /* generic proc entries belong to the host */
6967 @@ -510,6 +515,8 @@ int proc_readdir_de(struct proc_dir_entr
6969 /* filldir passes info to user space */
6971 + if (!vx_hide_check(0, de->vx_flags))
6973 spin_unlock(&proc_subdir_lock);
6974 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6975 de->low_ino, de->mode >> 12) < 0) {
6976 @@ -517,6 +524,7 @@ int proc_readdir_de(struct proc_dir_entr
6979 spin_lock(&proc_subdir_lock);
6984 @@ -631,6 +639,7 @@ static struct proc_dir_entry *__proc_cre
6986 atomic_set(&ent->count, 1);
6988 + ent->vx_flags = IATTR_PROC_DEFAULT;
6989 spin_lock_init(&ent->pde_unload_lock);
6990 ent->pde_unload_completion = NULL;
6991 INIT_LIST_HEAD(&ent->pde_openers);
6992 @@ -654,7 +663,8 @@ struct proc_dir_entry *proc_symlink(cons
6998 + ent->vx_flags = IATTR_PROC_SYMLINK;
7002 diff -NurpP --minimal linux-2.6.32.10/fs/proc/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/inode.c
7003 --- linux-2.6.32.10/fs/proc/inode.c 2009-06-11 17:13:07.000000000 +0200
7004 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/inode.c 2009-12-03 20:04:56.000000000 +0100
7005 @@ -459,6 +459,8 @@ struct inode *proc_get_inode(struct supe
7006 inode->i_uid = de->uid;
7007 inode->i_gid = de->gid;
7010 + PROC_I(inode)->vx_flags = de->vx_flags;
7012 inode->i_size = de->size;
7014 diff -NurpP --minimal linux-2.6.32.10/fs/proc/internal.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/internal.h
7015 --- linux-2.6.32.10/fs/proc/internal.h 2009-09-10 15:26:23.000000000 +0200
7016 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/internal.h 2009-12-03 20:04:56.000000000 +0100
7020 #include <linux/proc_fs.h>
7021 +#include <linux/vs_pid.h>
7023 extern struct proc_dir_entry proc_root;
7024 #ifdef CONFIG_PROC_SYSCTL
7025 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7026 struct pid *pid, struct task_struct *task);
7027 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7028 struct pid *pid, struct task_struct *task);
7029 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7030 + struct pid *pid, struct task_struct *task);
7032 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7034 extern const struct file_operations proc_maps_operations;
7035 @@ -70,11 +74,16 @@ static inline struct pid *proc_pid(struc
7036 return PROC_I(inode)->pid;
7039 -static inline struct task_struct *get_proc_task(struct inode *inode)
7040 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7042 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7045 +static inline struct task_struct *get_proc_task(struct inode *inode)
7047 + return vx_get_proc_task(inode, proc_pid(inode));
7050 static inline int proc_fd(struct inode *inode)
7052 return PROC_I(inode)->fd;
7053 diff -NurpP --minimal linux-2.6.32.10/fs/proc/loadavg.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/loadavg.c
7054 --- linux-2.6.32.10/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7055 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/loadavg.c 2009-12-03 20:04:56.000000000 +0100
7058 static int loadavg_proc_show(struct seq_file *m, void *v)
7060 + unsigned long running;
7061 + unsigned int threads;
7062 unsigned long avnrun[3];
7064 get_avenrun(avnrun, FIXED_1/200, 0);
7066 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7067 + struct vx_info *vxi = current_vx_info();
7069 + running = atomic_read(&vxi->cvirt.nr_running);
7070 + threads = atomic_read(&vxi->cvirt.nr_threads);
7072 + running = nr_running();
7073 + threads = nr_threads;
7076 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7077 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7078 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7079 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7080 - nr_running(), nr_threads,
7082 task_active_pid_ns(current)->last_pid);
7085 diff -NurpP --minimal linux-2.6.32.10/fs/proc/meminfo.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/meminfo.c
7086 --- linux-2.6.32.10/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7087 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/meminfo.c 2010-02-05 00:31:48.000000000 +0100
7088 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7089 allowed = ((totalram_pages - hugetlb_total_pages())
7090 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7092 - cached = global_page_state(NR_FILE_PAGES) -
7093 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7094 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7095 total_swapcache_pages - i.bufferram;
7098 diff -NurpP --minimal linux-2.6.32.10/fs/proc/root.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/root.c
7099 --- linux-2.6.32.10/fs/proc/root.c 2009-06-11 17:13:07.000000000 +0200
7100 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/root.c 2009-12-03 20:04:56.000000000 +0100
7102 #include <linux/bitops.h>
7103 #include <linux/mount.h>
7104 #include <linux/pid_namespace.h>
7105 +#include <linux/vserver/inode.h>
7107 #include "internal.h"
7109 +struct proc_dir_entry *proc_virtual;
7111 +extern void proc_vx_init(void);
7113 static int proc_test_super(struct super_block *sb, void *data)
7115 return sb->s_fs_info == data;
7116 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
7118 proc_mkdir("bus", NULL);
7123 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7124 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7125 .proc_iops = &proc_root_inode_operations,
7126 .proc_fops = &proc_root_operations,
7127 .parent = &proc_root,
7128 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7131 int pid_ns_prepare_proc(struct pid_namespace *ns)
7132 diff -NurpP --minimal linux-2.6.32.10/fs/proc/uptime.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/uptime.c
7133 --- linux-2.6.32.10/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7134 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/proc/uptime.c 2009-12-03 20:04:56.000000000 +0100
7136 #include <linux/sched.h>
7137 #include <linux/seq_file.h>
7138 #include <linux/time.h>
7139 -#include <linux/kernel_stat.h>
7140 +#include <linux/vserver/cvirt.h>
7141 #include <asm/cputime.h>
7143 static int uptime_proc_show(struct seq_file *m, void *v)
7145 struct timespec uptime;
7146 struct timespec idle;
7148 - cputime_t idletime = cputime_zero;
7150 - for_each_possible_cpu(i)
7151 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7152 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7154 do_posix_clock_monotonic_gettime(&uptime);
7155 monotonic_to_bootbased(&uptime);
7156 cputime_to_timespec(idletime, &idle);
7158 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7159 + vx_vsi_uptime(&uptime, &idle);
7161 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7162 (unsigned long) uptime.tv_sec,
7163 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7164 diff -NurpP --minimal linux-2.6.32.10/fs/quota/quota.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/quota/quota.c
7165 --- linux-2.6.32.10/fs/quota/quota.c 2009-09-10 15:26:24.000000000 +0200
7166 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/quota/quota.c 2009-12-03 20:04:56.000000000 +0100
7168 #include <linux/capability.h>
7169 #include <linux/quotaops.h>
7170 #include <linux/types.h>
7171 +#include <linux/vs_context.h>
7173 /* Check validity of generic quotactl commands */
7174 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd,
7175 @@ -83,11 +84,11 @@ static int generic_quotactl_valid(struct
7176 if (cmd == Q_GETQUOTA) {
7177 if (((type == USRQUOTA && current_euid() != id) ||
7178 (type == GRPQUOTA && !in_egroup_p(id))) &&
7179 - !capable(CAP_SYS_ADMIN))
7180 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7183 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7184 - if (!capable(CAP_SYS_ADMIN))
7185 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7189 @@ -135,10 +136,10 @@ static int xqm_quotactl_valid(struct sup
7190 if (cmd == Q_XGETQUOTA) {
7191 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7192 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7193 - !capable(CAP_SYS_ADMIN))
7194 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7196 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7197 - if (!capable(CAP_SYS_ADMIN))
7198 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7202 @@ -351,6 +352,46 @@ static int do_quotactl(struct super_bloc
7206 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7208 +#include <linux/vroot.h>
7209 +#include <linux/major.h>
7210 +#include <linux/module.h>
7211 +#include <linux/kallsyms.h>
7212 +#include <linux/vserver/debug.h>
7214 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7216 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7218 +int register_vroot_grb(vroot_grb_func *func) {
7221 + spin_lock(&vroot_grb_lock);
7222 + if (!vroot_get_real_bdev) {
7223 + vroot_get_real_bdev = func;
7226 + spin_unlock(&vroot_grb_lock);
7229 +EXPORT_SYMBOL(register_vroot_grb);
7231 +int unregister_vroot_grb(vroot_grb_func *func) {
7232 + int ret = -EINVAL;
7234 + spin_lock(&vroot_grb_lock);
7235 + if (vroot_get_real_bdev) {
7236 + vroot_get_real_bdev = NULL;
7239 + spin_unlock(&vroot_grb_lock);
7242 +EXPORT_SYMBOL(unregister_vroot_grb);
7247 * look up a superblock on which quota ops will be performed
7248 * - use the name of a block device to find the superblock thereon
7249 @@ -368,6 +409,22 @@ static struct super_block *quotactl_bloc
7252 return ERR_CAST(bdev);
7253 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7254 + if (bdev && bdev->bd_inode &&
7255 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7256 + struct block_device *bdnew = (void *)-EINVAL;
7258 + if (vroot_get_real_bdev)
7259 + bdnew = vroot_get_real_bdev(bdev);
7261 + vxdprintk(VXD_CBIT(misc, 0),
7262 + "vroot_get_real_bdev not set");
7264 + if (IS_ERR(bdnew))
7265 + return ERR_PTR(PTR_ERR(bdnew));
7269 sb = get_super(bdev);
7272 diff -NurpP --minimal linux-2.6.32.10/fs/reiserfs/file.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/file.c
7273 --- linux-2.6.32.10/fs/reiserfs/file.c 2009-06-11 17:13:08.000000000 +0200
7274 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/file.c 2009-12-03 20:04:56.000000000 +0100
7275 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7276 .listxattr = reiserfs_listxattr,
7277 .removexattr = reiserfs_removexattr,
7278 .permission = reiserfs_permission,
7279 + .sync_flags = reiserfs_sync_flags,
7281 diff -NurpP --minimal linux-2.6.32.10/fs/reiserfs/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/inode.c
7282 --- linux-2.6.32.10/fs/reiserfs/inode.c 2010-03-18 16:17:37.000000000 +0100
7283 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/inode.c 2010-01-26 20:35:35.000000000 +0100
7285 #include <linux/writeback.h>
7286 #include <linux/quotaops.h>
7287 #include <linux/swap.h>
7288 +#include <linux/vs_tag.h>
7290 int reiserfs_commit_write(struct file *f, struct page *page,
7291 unsigned from, unsigned to);
7292 @@ -1117,6 +1118,8 @@ static void init_inode(struct inode *ino
7293 struct buffer_head *bh;
7294 struct item_head *ih;
7298 //int version = ITEM_VERSION_1;
7300 bh = PATH_PLAST_BUFFER(path);
7301 @@ -1138,12 +1141,13 @@ static void init_inode(struct inode *ino
7302 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7303 unsigned long blocks;
7305 + uid = sd_v1_uid(sd);
7306 + gid = sd_v1_gid(sd);
7308 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7309 set_inode_sd_version(inode, STAT_DATA_V1);
7310 inode->i_mode = sd_v1_mode(sd);
7311 inode->i_nlink = sd_v1_nlink(sd);
7312 - inode->i_uid = sd_v1_uid(sd);
7313 - inode->i_gid = sd_v1_gid(sd);
7314 inode->i_size = sd_v1_size(sd);
7315 inode->i_atime.tv_sec = sd_v1_atime(sd);
7316 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7317 @@ -1185,11 +1189,12 @@ static void init_inode(struct inode *ino
7318 // (directories and symlinks)
7319 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7321 + uid = sd_v2_uid(sd);
7322 + gid = sd_v2_gid(sd);
7324 inode->i_mode = sd_v2_mode(sd);
7325 inode->i_nlink = sd_v2_nlink(sd);
7326 - inode->i_uid = sd_v2_uid(sd);
7327 inode->i_size = sd_v2_size(sd);
7328 - inode->i_gid = sd_v2_gid(sd);
7329 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7330 inode->i_atime.tv_sec = sd_v2_atime(sd);
7331 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7332 @@ -1219,6 +1224,10 @@ static void init_inode(struct inode *ino
7333 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7336 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7337 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7338 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7341 if (S_ISREG(inode->i_mode)) {
7342 inode->i_op = &reiserfs_file_inode_operations;
7343 @@ -1241,13 +1250,15 @@ static void init_inode(struct inode *ino
7344 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7346 struct stat_data *sd_v2 = (struct stat_data *)sd;
7347 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7348 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7351 + set_sd_v2_uid(sd_v2, uid);
7352 + set_sd_v2_gid(sd_v2, gid);
7353 set_sd_v2_mode(sd_v2, inode->i_mode);
7354 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7355 - set_sd_v2_uid(sd_v2, inode->i_uid);
7356 set_sd_v2_size(sd_v2, size);
7357 - set_sd_v2_gid(sd_v2, inode->i_gid);
7358 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7359 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7360 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7361 @@ -2839,14 +2850,19 @@ int reiserfs_commit_write(struct file *f
7362 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7364 if (reiserfs_attrs(inode->i_sb)) {
7365 - if (sd_attrs & REISERFS_SYNC_FL)
7366 - inode->i_flags |= S_SYNC;
7368 - inode->i_flags &= ~S_SYNC;
7369 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7370 inode->i_flags |= S_IMMUTABLE;
7372 inode->i_flags &= ~S_IMMUTABLE;
7373 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7374 + inode->i_flags |= S_IXUNLINK;
7376 + inode->i_flags &= ~S_IXUNLINK;
7378 + if (sd_attrs & REISERFS_SYNC_FL)
7379 + inode->i_flags |= S_SYNC;
7381 + inode->i_flags &= ~S_SYNC;
7382 if (sd_attrs & REISERFS_APPEND_FL)
7383 inode->i_flags |= S_APPEND;
7385 @@ -2859,6 +2875,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7386 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7388 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7390 + if (sd_attrs & REISERFS_BARRIER_FL)
7391 + inode->i_vflags |= V_BARRIER;
7393 + inode->i_vflags &= ~V_BARRIER;
7394 + if (sd_attrs & REISERFS_COW_FL)
7395 + inode->i_vflags |= V_COW;
7397 + inode->i_vflags &= ~V_COW;
7401 @@ -2869,6 +2894,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7402 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7404 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7405 + if (inode->i_flags & S_IXUNLINK)
7406 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7408 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7410 if (inode->i_flags & S_SYNC)
7411 *sd_attrs |= REISERFS_SYNC_FL;
7413 @@ -2881,6 +2911,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7414 *sd_attrs |= REISERFS_NOTAIL_FL;
7416 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7418 + if (inode->i_vflags & V_BARRIER)
7419 + *sd_attrs |= REISERFS_BARRIER_FL;
7421 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7422 + if (inode->i_vflags & V_COW)
7423 + *sd_attrs |= REISERFS_COW_FL;
7425 + *sd_attrs &= ~REISERFS_COW_FL;
7429 @@ -3101,9 +3140,11 @@ int reiserfs_setattr(struct dentry *dent
7432 error = inode_change_ok(inode, attr);
7435 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7436 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7437 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7438 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7439 error = reiserfs_chown_xattrs(inode, attr);
7442 @@ -3133,6 +3174,9 @@ int reiserfs_setattr(struct dentry *dent
7443 inode->i_uid = attr->ia_uid;
7444 if (attr->ia_valid & ATTR_GID)
7445 inode->i_gid = attr->ia_gid;
7446 + if ((attr->ia_valid & ATTR_TAG) &&
7448 + inode->i_tag = attr->ia_tag;
7449 mark_inode_dirty(inode);
7451 journal_end(&th, inode->i_sb, jbegin_count);
7452 diff -NurpP --minimal linux-2.6.32.10/fs/reiserfs/ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/ioctl.c
7453 --- linux-2.6.32.10/fs/reiserfs/ioctl.c 2009-06-11 17:13:08.000000000 +0200
7454 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/ioctl.c 2009-12-03 20:04:56.000000000 +0100
7456 #include <linux/mount.h>
7457 #include <linux/reiserfs_fs.h>
7458 #include <linux/time.h>
7459 +#include <linux/mount.h>
7460 #include <asm/uaccess.h>
7461 #include <linux/pagemap.h>
7462 #include <linux/smp_lock.h>
7463 #include <linux/compat.h>
7466 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7468 + __u16 sd_attrs = 0;
7470 + inode->i_flags = flags;
7471 + inode->i_vflags = vflags;
7473 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7474 + REISERFS_I(inode)->i_attrs = sd_attrs;
7475 + inode->i_ctime = CURRENT_TIME_SEC;
7476 + mark_inode_dirty(inode);
7481 ** reiserfs_ioctl - handler for ioctl for inode
7482 ** supported commands:
7484 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7487 - unsigned int flags;
7488 + unsigned int flags, oldflags;
7492 @@ -43,6 +59,7 @@ int reiserfs_ioctl(struct inode *inode,
7494 flags = REISERFS_I(inode)->i_attrs;
7495 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7496 + flags &= REISERFS_FL_USER_VISIBLE;
7497 return put_user(flags, (int __user *)arg);
7498 case REISERFS_IOC_SETFLAGS:{
7499 if (!reiserfs_attrs(inode->i_sb))
7500 @@ -60,6 +77,10 @@ int reiserfs_ioctl(struct inode *inode,
7504 + if (IS_BARRIER(inode)) {
7505 + vxwprintk_task(1, "messing with the barrier.");
7509 * Is it quota file? Do not allow user to mess with it
7511 @@ -84,6 +105,10 @@ int reiserfs_ioctl(struct inode *inode,
7516 + oldflags = REISERFS_I(inode)->i_attrs;
7517 + flags &= REISERFS_FL_USER_MODIFIABLE;
7518 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7519 sd_attrs_to_i_attrs(flags, inode);
7520 REISERFS_I(inode)->i_attrs = flags;
7521 inode->i_ctime = CURRENT_TIME_SEC;
7522 diff -NurpP --minimal linux-2.6.32.10/fs/reiserfs/namei.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/namei.c
7523 --- linux-2.6.32.10/fs/reiserfs/namei.c 2009-06-11 17:13:08.000000000 +0200
7524 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/namei.c 2009-12-03 20:04:56.000000000 +0100
7526 #include <linux/reiserfs_acl.h>
7527 #include <linux/reiserfs_xattr.h>
7528 #include <linux/quotaops.h>
7529 +#include <linux/vs_tag.h>
7531 #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; }
7532 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7533 @@ -354,6 +355,7 @@ static struct dentry *reiserfs_lookup(st
7534 if (retval == IO_ERROR) {
7535 return ERR_PTR(-EIO);
7537 + dx_propagate_tag(nd, inode);
7539 return d_splice_alias(inode, dentry);
7541 @@ -570,6 +572,7 @@ static int new_inode_init(struct inode *
7543 inode->i_gid = current_fsgid();
7545 + inode->i_tag = dx_current_fstag(inode->i_sb);
7549 @@ -1515,6 +1518,7 @@ const struct inode_operations reiserfs_d
7550 .listxattr = reiserfs_listxattr,
7551 .removexattr = reiserfs_removexattr,
7552 .permission = reiserfs_permission,
7553 + .sync_flags = reiserfs_sync_flags,
7557 diff -NurpP --minimal linux-2.6.32.10/fs/reiserfs/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/super.c
7558 --- linux-2.6.32.10/fs/reiserfs/super.c 2009-12-03 20:02:53.000000000 +0100
7559 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/super.c 2009-12-03 20:04:56.000000000 +0100
7560 @@ -884,6 +884,14 @@ static int reiserfs_parse_options(struct
7561 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7562 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7564 +#ifndef CONFIG_TAGGING_NONE
7565 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7566 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7567 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7569 +#ifdef CONFIG_PROPAGATE
7570 + {"tag",.arg_required = 'T',.values = NULL},
7572 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7573 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7574 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7575 @@ -1190,6 +1198,14 @@ static int reiserfs_remount(struct super
7576 handle_quota_files(s, qf_names, &qfmt);
7579 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7580 + !(s->s_flags & MS_TAGGED)) {
7581 + reiserfs_warning(s, "super-vs01",
7582 + "reiserfs: tagging not permitted on remount.");
7589 /* Add options that are safe here */
7590 @@ -1652,6 +1668,10 @@ static int reiserfs_fill_super(struct su
7594 + /* map mount option tagxid */
7595 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7596 + s->s_flags |= MS_TAGGED;
7598 rs = SB_DISK_SUPER_BLOCK(s);
7599 /* Let's do basic sanity check to verify that underlying device is not
7600 smaller than the filesystem. If the check fails then abort and scream,
7601 diff -NurpP --minimal linux-2.6.32.10/fs/reiserfs/xattr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/xattr.c
7602 --- linux-2.6.32.10/fs/reiserfs/xattr.c 2009-09-10 15:26:24.000000000 +0200
7603 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/reiserfs/xattr.c 2009-12-03 20:04:56.000000000 +0100
7605 #include <linux/namei.h>
7606 #include <linux/errno.h>
7607 #include <linux/fs.h>
7608 +#include <linux/mount.h>
7609 #include <linux/file.h>
7610 #include <linux/pagemap.h>
7611 #include <linux/xattr.h>
7612 diff -NurpP --minimal linux-2.6.32.10/fs/stat.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/stat.c
7613 --- linux-2.6.32.10/fs/stat.c 2010-03-18 16:17:37.000000000 +0100
7614 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/stat.c 2010-01-13 14:33:47.000000000 +0100
7615 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7616 stat->nlink = inode->i_nlink;
7617 stat->uid = inode->i_uid;
7618 stat->gid = inode->i_gid;
7619 + stat->tag = inode->i_tag;
7620 stat->rdev = inode->i_rdev;
7621 stat->atime = inode->i_atime;
7622 stat->mtime = inode->i_mtime;
7623 diff -NurpP --minimal linux-2.6.32.10/fs/super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/super.c
7624 --- linux-2.6.32.10/fs/super.c 2010-03-18 16:17:37.000000000 +0100
7625 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/super.c 2010-02-12 10:59:55.000000000 +0100
7627 #include <linux/kobject.h>
7628 #include <linux/mutex.h>
7629 #include <linux/file.h>
7630 +#include <linux/devpts_fs.h>
7631 +#include <linux/proc_fs.h>
7632 +#include <linux/vs_context.h>
7633 #include <asm/uaccess.h>
7634 #include "internal.h"
7636 @@ -914,12 +917,18 @@ struct vfsmount *
7637 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7639 struct vfsmount *mnt;
7640 + struct super_block *sb;
7641 char *secdata = NULL;
7645 return ERR_PTR(-ENODEV);
7648 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7649 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7653 mnt = alloc_vfsmnt(name);
7655 @@ -938,9 +947,17 @@ vfs_kern_mount(struct file_system_type *
7656 error = type->get_sb(type, flags, name, data, mnt);
7658 goto out_free_secdata;
7659 - BUG_ON(!mnt->mnt_sb);
7661 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7666 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7667 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7668 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7671 + error = security_sb_kern_mount(sb, flags, secdata);
7675 diff -NurpP --minimal linux-2.6.32.10/fs/sysfs/mount.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/sysfs/mount.c
7676 --- linux-2.6.32.10/fs/sysfs/mount.c 2009-06-11 17:13:08.000000000 +0200
7677 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/sysfs/mount.c 2009-12-03 20:04:56.000000000 +0100
7678 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7680 sb->s_blocksize = PAGE_CACHE_SIZE;
7681 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7682 - sb->s_magic = SYSFS_MAGIC;
7683 + sb->s_magic = SYSFS_SUPER_MAGIC;
7684 sb->s_op = &sysfs_ops;
7685 sb->s_time_gran = 1;
7687 diff -NurpP --minimal linux-2.6.32.10/fs/utimes.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/utimes.c
7688 --- linux-2.6.32.10/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7689 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/utimes.c 2009-12-03 20:04:56.000000000 +0100
7691 #include <linux/stat.h>
7692 #include <linux/utime.h>
7693 #include <linux/syscalls.h>
7694 +#include <linux/mount.h>
7695 +#include <linux/vs_cowbl.h>
7696 #include <asm/uaccess.h>
7697 #include <asm/unistd.h>
7699 diff -NurpP --minimal linux-2.6.32.10/fs/xattr.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xattr.c
7700 --- linux-2.6.32.10/fs/xattr.c 2009-12-03 20:02:53.000000000 +0100
7701 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xattr.c 2010-03-13 21:50:00.000000000 +0100
7703 #include <linux/module.h>
7704 #include <linux/fsnotify.h>
7705 #include <linux/audit.h>
7706 +#include <linux/mount.h>
7707 #include <asm/uaccess.h>
7710 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7711 * The trusted.* namespace can only be accessed by a privileged user.
7713 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7714 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7715 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7717 /* In user.* namespace, only regular files and directories can have
7718 * extended attributes. For sticky directories, only the owner and
7719 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_ioctl.c
7720 --- linux-2.6.32.10/fs/xfs/linux-2.6/xfs_ioctl.c 2009-09-10 15:26:24.000000000 +0200
7721 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_ioctl.c 2009-12-03 20:04:56.000000000 +0100
7723 #include "xfs_dir2_sf.h"
7724 #include "xfs_dinode.h"
7725 #include "xfs_inode.h"
7726 -#include "xfs_ioctl.h"
7727 #include "xfs_btree.h"
7728 #include "xfs_ialloc.h"
7729 #include "xfs_rtalloc.h"
7730 @@ -742,6 +741,10 @@ xfs_merge_ioc_xflags(
7731 xflags |= XFS_XFLAG_IMMUTABLE;
7733 xflags &= ~XFS_XFLAG_IMMUTABLE;
7734 + if (flags & FS_IXUNLINK_FL)
7735 + xflags |= XFS_XFLAG_IXUNLINK;
7737 + xflags &= ~XFS_XFLAG_IXUNLINK;
7738 if (flags & FS_APPEND_FL)
7739 xflags |= XFS_XFLAG_APPEND;
7741 @@ -770,6 +773,8 @@ xfs_di2lxflags(
7743 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7744 flags |= FS_IMMUTABLE_FL;
7745 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7746 + flags |= FS_IXUNLINK_FL;
7747 if (di_flags & XFS_DIFLAG_APPEND)
7748 flags |= FS_APPEND_FL;
7749 if (di_flags & XFS_DIFLAG_SYNC)
7750 @@ -828,6 +833,8 @@ xfs_set_diflags(
7751 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7752 if (xflags & XFS_XFLAG_IMMUTABLE)
7753 di_flags |= XFS_DIFLAG_IMMUTABLE;
7754 + if (xflags & XFS_XFLAG_IXUNLINK)
7755 + di_flags |= XFS_DIFLAG_IXUNLINK;
7756 if (xflags & XFS_XFLAG_APPEND)
7757 di_flags |= XFS_DIFLAG_APPEND;
7758 if (xflags & XFS_XFLAG_SYNC)
7759 @@ -870,6 +877,10 @@ xfs_diflags_to_linux(
7760 inode->i_flags |= S_IMMUTABLE;
7762 inode->i_flags &= ~S_IMMUTABLE;
7763 + if (xflags & XFS_XFLAG_IXUNLINK)
7764 + inode->i_flags |= S_IXUNLINK;
7766 + inode->i_flags &= ~S_IXUNLINK;
7767 if (xflags & XFS_XFLAG_APPEND)
7768 inode->i_flags |= S_APPEND;
7770 @@ -1346,10 +1357,18 @@ xfs_file_ioctl(
7771 case XFS_IOC_FSGETXATTRA:
7772 return xfs_ioc_fsgetxattr(ip, 1, arg);
7773 case XFS_IOC_FSSETXATTR:
7774 + if (IS_BARRIER(inode)) {
7775 + vxwprintk_task(1, "messing with the barrier.");
7776 + return -XFS_ERROR(EACCES);
7778 return xfs_ioc_fssetxattr(ip, filp, arg);
7779 case XFS_IOC_GETXFLAGS:
7780 return xfs_ioc_getxflags(ip, arg);
7781 case XFS_IOC_SETXFLAGS:
7782 + if (IS_BARRIER(inode)) {
7783 + vxwprintk_task(1, "messing with the barrier.");
7784 + return -XFS_ERROR(EACCES);
7786 return xfs_ioc_setxflags(ip, filp, arg);
7788 case XFS_IOC_FSSETDM: {
7789 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_ioctl.h
7790 --- linux-2.6.32.10/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
7791 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_ioctl.h 2009-12-03 20:04:56.000000000 +0100
7792 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7793 void __user *uhandle,
7798 + struct inode *inode,
7805 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_iops.c
7806 --- linux-2.6.32.10/fs/xfs/linux-2.6/xfs_iops.c 2009-12-03 20:02:53.000000000 +0100
7807 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_iops.c 2009-12-03 20:04:56.000000000 +0100
7809 #include "xfs_attr_sf.h"
7810 #include "xfs_dinode.h"
7811 #include "xfs_inode.h"
7812 +#include "xfs_ioctl.h"
7813 #include "xfs_bmap.h"
7814 #include "xfs_btree.h"
7815 #include "xfs_ialloc.h"
7817 #include <linux/security.h>
7818 #include <linux/falloc.h>
7819 #include <linux/fiemap.h>
7820 +#include <linux/vs_tag.h>
7823 * Bring the timestamps in the XFS inode uptodate.
7824 @@ -495,6 +497,7 @@ xfs_vn_getattr(
7825 stat->nlink = ip->i_d.di_nlink;
7826 stat->uid = ip->i_d.di_uid;
7827 stat->gid = ip->i_d.di_gid;
7828 + stat->tag = ip->i_d.di_tag;
7829 stat->ino = ip->i_ino;
7830 stat->atime = inode->i_atime;
7831 stat->mtime = inode->i_mtime;
7832 @@ -686,6 +689,7 @@ static const struct inode_operations xfs
7833 .listxattr = xfs_vn_listxattr,
7834 .fallocate = xfs_vn_fallocate,
7835 .fiemap = xfs_vn_fiemap,
7836 + .sync_flags = xfs_sync_flags,
7839 static const struct inode_operations xfs_dir_inode_operations = {
7840 @@ -711,6 +715,7 @@ static const struct inode_operations xfs
7841 .getxattr = generic_getxattr,
7842 .removexattr = generic_removexattr,
7843 .listxattr = xfs_vn_listxattr,
7844 + .sync_flags = xfs_sync_flags,
7847 static const struct inode_operations xfs_dir_ci_inode_operations = {
7848 @@ -760,6 +765,10 @@ xfs_diflags_to_iflags(
7849 inode->i_flags |= S_IMMUTABLE;
7851 inode->i_flags &= ~S_IMMUTABLE;
7852 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7853 + inode->i_flags |= S_IXUNLINK;
7855 + inode->i_flags &= ~S_IXUNLINK;
7856 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7857 inode->i_flags |= S_APPEND;
7859 @@ -772,6 +781,15 @@ xfs_diflags_to_iflags(
7860 inode->i_flags |= S_NOATIME;
7862 inode->i_flags &= ~S_NOATIME;
7864 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7865 + inode->i_vflags |= V_BARRIER;
7867 + inode->i_vflags &= ~V_BARRIER;
7868 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7869 + inode->i_vflags |= V_COW;
7871 + inode->i_vflags &= ~V_COW;
7875 @@ -800,6 +818,7 @@ xfs_setup_inode(
7876 inode->i_nlink = ip->i_d.di_nlink;
7877 inode->i_uid = ip->i_d.di_uid;
7878 inode->i_gid = ip->i_d.di_gid;
7879 + inode->i_tag = ip->i_d.di_tag;
7881 switch (inode->i_mode & S_IFMT) {
7883 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_linux.h
7884 --- linux-2.6.32.10/fs/xfs/linux-2.6/xfs_linux.h 2009-09-10 15:26:24.000000000 +0200
7885 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_linux.h 2009-12-03 20:04:56.000000000 +0100
7888 #define current_cpu() (raw_smp_processor_id())
7889 #define current_pid() (current->pid)
7890 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7891 #define current_test_flags(f) (current->flags & (f))
7892 #define current_set_flags_nested(sp, f) \
7893 (*(sp) = current->flags, current->flags |= (f))
7894 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/linux-2.6/xfs_super.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_super.c
7895 --- linux-2.6.32.10/fs/xfs/linux-2.6/xfs_super.c 2009-12-03 20:02:53.000000000 +0100
7896 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/linux-2.6/xfs_super.c 2009-12-03 20:04:56.000000000 +0100
7897 @@ -117,6 +117,9 @@ mempool_t *xfs_ioend_pool;
7898 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
7899 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
7900 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
7901 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7902 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7903 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7906 * Table driven mount option parser.
7907 @@ -125,10 +128,14 @@ mempool_t *xfs_ioend_pool;
7908 * in the future, too.
7911 + Opt_tag, Opt_notag,
7912 Opt_barrier, Opt_nobarrier, Opt_err
7915 static const match_table_t tokens = {
7916 + {Opt_tag, "tagxid"},
7918 + {Opt_notag, "notag"},
7919 {Opt_barrier, "barrier"},
7920 {Opt_nobarrier, "nobarrier"},
7922 @@ -382,6 +389,19 @@ xfs_parseargs(
7923 } else if (!strcmp(this_char, "irixsgid")) {
7925 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7926 +#ifndef CONFIG_TAGGING_NONE
7927 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7928 + mp->m_flags |= XFS_MOUNT_TAGGED;
7929 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7930 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7931 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7932 + mp->m_flags |= XFS_MOUNT_TAGGED;
7934 +#ifdef CONFIG_PROPAGATE
7935 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7937 + mp->m_flags |= XFS_MOUNT_TAGGED;
7941 "XFS: unknown mount option [%s].", this_char);
7942 @@ -1270,6 +1290,16 @@ xfs_fs_remount(
7944 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7947 + if (!(sb->s_flags & MS_TAGGED)) {
7949 + "XFS: %s: tagging not permitted on remount.\n",
7958 * Logically we would return an error here to prevent
7959 @@ -1477,6 +1507,9 @@ xfs_fs_fill_super(
7961 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
7963 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7964 + sb->s_flags |= MS_TAGGED;
7966 sb->s_magic = XFS_SB_MAGIC;
7967 sb->s_blocksize = mp->m_sb.sb_blocksize;
7968 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
7969 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_dinode.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_dinode.h
7970 --- linux-2.6.32.10/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
7971 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_dinode.h 2009-12-03 20:04:56.000000000 +0100
7972 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
7973 __be32 di_gid; /* owner's group id */
7974 __be32 di_nlink; /* number of links to file */
7975 __be16 di_projid; /* owner's project id */
7976 - __u8 di_pad[8]; /* unused, zeroed space */
7977 + __be16 di_tag; /* context tagging */
7978 + __be16 di_vflags; /* vserver specific flags */
7979 + __u8 di_pad[4]; /* unused, zeroed space */
7980 __be16 di_flushiter; /* incremented on flush */
7981 xfs_timestamp_t di_atime; /* time last accessed */
7982 xfs_timestamp_t di_mtime; /* time last modified */
7983 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
7984 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7985 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7986 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7987 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7989 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7990 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7991 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7992 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
7993 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7994 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7995 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7996 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7998 #ifdef CONFIG_XFS_RT
7999 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8000 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
8001 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8002 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8003 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8004 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8005 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8006 + XFS_DIFLAG_IXUNLINK)
8008 +#define XFS_DIVFLAG_BARRIER 0x01
8009 +#define XFS_DIVFLAG_COW 0x02
8011 #endif /* __XFS_DINODE_H__ */
8012 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_fs.h
8013 --- linux-2.6.32.10/fs/xfs/xfs_fs.h 2009-12-03 20:02:53.000000000 +0100
8014 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_fs.h 2009-12-03 20:04:56.000000000 +0100
8015 @@ -67,6 +67,9 @@ struct fsxattr {
8016 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8017 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8018 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8019 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8020 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8021 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8022 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8025 @@ -292,7 +295,8 @@ typedef struct xfs_bstat {
8026 __s32 bs_extents; /* number of extents */
8027 __u32 bs_gen; /* generation count */
8028 __u16 bs_projid; /* project id */
8029 - unsigned char bs_pad[14]; /* pad space, unused */
8030 + __u16 bs_tag; /* context tagging */
8031 + unsigned char bs_pad[12]; /* pad space, unused */
8032 __u32 bs_dmevmask; /* DMIG event mask */
8033 __u16 bs_dmstate; /* DMIG state info */
8034 __u16 bs_aextents; /* attribute number of extents */
8035 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_ialloc.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_ialloc.c
8036 --- linux-2.6.32.10/fs/xfs/xfs_ialloc.c 2009-12-03 20:02:53.000000000 +0100
8037 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_ialloc.c 2009-12-03 20:04:56.000000000 +0100
8039 #include "xfs_error.h"
8040 #include "xfs_bmap.h"
8044 * Allocation group level functions.
8046 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_inode.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_inode.c
8047 --- linux-2.6.32.10/fs/xfs/xfs_inode.c 2009-12-03 20:02:54.000000000 +0100
8048 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_inode.c 2009-12-03 20:04:56.000000000 +0100
8049 @@ -249,6 +249,7 @@ xfs_inotobp(
8053 +#include <linux/vs_tag.h>
8056 * This routine is called to map an inode to the buffer containing
8057 @@ -654,15 +655,25 @@ xfs_iformat_btree(
8059 xfs_dinode_from_disk(
8061 - xfs_dinode_t *from)
8062 + xfs_dinode_t *from,
8065 + uint32_t uid, gid, tag;
8067 to->di_magic = be16_to_cpu(from->di_magic);
8068 to->di_mode = be16_to_cpu(from->di_mode);
8069 to->di_version = from ->di_version;
8070 to->di_format = from->di_format;
8071 to->di_onlink = be16_to_cpu(from->di_onlink);
8072 - to->di_uid = be32_to_cpu(from->di_uid);
8073 - to->di_gid = be32_to_cpu(from->di_gid);
8075 + uid = be32_to_cpu(from->di_uid);
8076 + gid = be32_to_cpu(from->di_gid);
8077 + tag = be16_to_cpu(from->di_tag);
8079 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8080 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8081 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8083 to->di_nlink = be32_to_cpu(from->di_nlink);
8084 to->di_projid = be16_to_cpu(from->di_projid);
8085 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8086 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
8087 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8088 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8089 to->di_flags = be16_to_cpu(from->di_flags);
8090 + to->di_vflags = be16_to_cpu(from->di_vflags);
8091 to->di_gen = be32_to_cpu(from->di_gen);
8097 - xfs_icdinode_t *from)
8098 + xfs_icdinode_t *from,
8101 to->di_magic = cpu_to_be16(from->di_magic);
8102 to->di_mode = cpu_to_be16(from->di_mode);
8103 to->di_version = from ->di_version;
8104 to->di_format = from->di_format;
8105 to->di_onlink = cpu_to_be16(from->di_onlink);
8106 - to->di_uid = cpu_to_be32(from->di_uid);
8107 - to->di_gid = cpu_to_be32(from->di_gid);
8109 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8110 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8111 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8113 to->di_nlink = cpu_to_be32(from->di_nlink);
8114 to->di_projid = cpu_to_be16(from->di_projid);
8115 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8116 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
8117 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8118 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8119 to->di_flags = cpu_to_be16(from->di_flags);
8120 + to->di_vflags = cpu_to_be16(from->di_vflags);
8121 to->di_gen = cpu_to_be32(from->di_gen);
8126 - __uint16_t di_flags)
8127 + __uint16_t di_flags,
8128 + __uint16_t di_vflags)
8132 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
8133 flags |= XFS_XFLAG_PREALLOC;
8134 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8135 flags |= XFS_XFLAG_IMMUTABLE;
8136 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8137 + flags |= XFS_XFLAG_IXUNLINK;
8138 if (di_flags & XFS_DIFLAG_APPEND)
8139 flags |= XFS_XFLAG_APPEND;
8140 if (di_flags & XFS_DIFLAG_SYNC)
8141 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
8142 flags |= XFS_XFLAG_FILESTREAM;
8145 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8146 + flags |= FS_BARRIER_FL;
8147 + if (di_vflags & XFS_DIVFLAG_COW)
8148 + flags |= FS_COW_FL;
8152 @@ -767,7 +791,7 @@ xfs_ip2xflags(
8154 xfs_icdinode_t *dic = &ip->i_d;
8156 - return _xfs_dic2xflags(dic->di_flags) |
8157 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8158 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8161 @@ -775,7 +799,8 @@ uint
8165 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8166 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8167 + be16_to_cpu(dip->di_vflags)) |
8168 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8171 @@ -811,7 +836,6 @@ xfs_iread(
8174 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8177 * If we got something that isn't an inode it means someone
8178 * (nfs or dmi) has a stale handle.
8179 @@ -836,7 +860,8 @@ xfs_iread(
8180 * Otherwise, just get the truly permanent information.
8183 - xfs_dinode_from_disk(&ip->i_d, dip);
8184 + xfs_dinode_from_disk(&ip->i_d, dip,
8185 + mp->m_flags & XFS_MOUNT_TAGGED);
8186 error = xfs_iformat(ip, dip);
8189 @@ -1036,6 +1061,7 @@ xfs_ialloc(
8190 ASSERT(ip->i_d.di_nlink == nlink);
8191 ip->i_d.di_uid = current_fsuid();
8192 ip->i_d.di_gid = current_fsgid();
8193 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8194 ip->i_d.di_projid = prid;
8195 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8197 @@ -1096,6 +1122,7 @@ xfs_ialloc(
8198 ip->i_d.di_dmevmask = 0;
8199 ip->i_d.di_dmstate = 0;
8200 ip->i_d.di_flags = 0;
8201 + ip->i_d.di_vflags = 0;
8202 flags = XFS_ILOG_CORE;
8203 switch (mode & S_IFMT) {
8205 @@ -2172,6 +2199,7 @@ xfs_ifree(
8207 ip->i_d.di_mode = 0; /* mark incore inode as free */
8208 ip->i_d.di_flags = 0;
8209 + ip->i_d.di_vflags = 0;
8210 ip->i_d.di_dmevmask = 0;
8211 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8212 ip->i_df.if_ext_max =
8213 @@ -3139,7 +3167,8 @@ xfs_iflush_int(
8214 * because if the inode is dirty at all the core must
8217 - xfs_dinode_to_disk(dip, &ip->i_d);
8218 + xfs_dinode_to_disk(dip, &ip->i_d,
8219 + mp->m_flags & XFS_MOUNT_TAGGED);
8221 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8222 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8223 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_inode.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_inode.h
8224 --- linux-2.6.32.10/fs/xfs/xfs_inode.h 2009-12-03 20:02:54.000000000 +0100
8225 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_inode.h 2009-12-03 20:04:56.000000000 +0100
8226 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8227 __uint32_t di_gid; /* owner's group id */
8228 __uint32_t di_nlink; /* number of links to file */
8229 __uint16_t di_projid; /* owner's project id */
8230 - __uint8_t di_pad[8]; /* unused, zeroed space */
8231 + __uint16_t di_tag; /* context tagging */
8232 + __uint16_t di_vflags; /* vserver specific flags */
8233 + __uint8_t di_pad[4]; /* unused, zeroed space */
8234 __uint16_t di_flushiter; /* incremented on flush */
8235 xfs_ictimestamp_t di_atime; /* time last accessed */
8236 xfs_ictimestamp_t di_mtime; /* time last modified */
8237 @@ -569,7 +571,7 @@ int xfs_itobp(struct xfs_mount *, struc
8238 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8239 struct xfs_inode *, xfs_daddr_t, uint);
8240 void xfs_dinode_to_disk(struct xfs_dinode *,
8241 - struct xfs_icdinode *);
8242 + struct xfs_icdinode *, int);
8243 void xfs_idestroy_fork(struct xfs_inode *, int);
8244 void xfs_idata_realloc(struct xfs_inode *, int, int);
8245 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8246 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_itable.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_itable.c
8247 --- linux-2.6.32.10/fs/xfs/xfs_itable.c 2009-12-03 20:02:54.000000000 +0100
8248 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_itable.c 2009-12-03 20:04:56.000000000 +0100
8249 @@ -84,6 +84,7 @@ xfs_bulkstat_one_iget(
8250 buf->bs_mode = dic->di_mode;
8251 buf->bs_uid = dic->di_uid;
8252 buf->bs_gid = dic->di_gid;
8253 + buf->bs_tag = dic->di_tag;
8254 buf->bs_size = dic->di_size;
8257 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_log_recover.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_log_recover.c
8258 --- linux-2.6.32.10/fs/xfs/xfs_log_recover.c 2009-12-03 20:02:54.000000000 +0100
8259 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_log_recover.c 2009-12-03 20:04:56.000000000 +0100
8260 @@ -2467,7 +2467,8 @@ xlog_recover_do_inode_trans(
8263 /* The core is in in-core format */
8264 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8265 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8266 + mp->m_flags & XFS_MOUNT_TAGGED);
8268 /* the rest is in on-disk format */
8269 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8270 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_mount.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_mount.h
8271 --- linux-2.6.32.10/fs/xfs/xfs_mount.h 2009-12-03 20:02:54.000000000 +0100
8272 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_mount.h 2009-12-03 20:04:56.000000000 +0100
8273 @@ -283,6 +283,7 @@ typedef struct xfs_mount {
8275 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8277 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8280 * Default minimum read and write sizes.
8281 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_vnodeops.c linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_vnodeops.c
8282 --- linux-2.6.32.10/fs/xfs/xfs_vnodeops.c 2009-12-03 20:02:54.000000000 +0100
8283 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_vnodeops.c 2009-12-03 20:04:56.000000000 +0100
8285 #include "xfs_filestream.h"
8286 #include "xfs_vnodeops.h"
8290 +xfs_get_inode_flags(
8293 + struct inode *inode = VFS_I(ip);
8294 + unsigned int flags = inode->i_flags;
8295 + unsigned int vflags = inode->i_vflags;
8297 + if (flags & S_IMMUTABLE)
8298 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8300 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8301 + if (flags & S_IXUNLINK)
8302 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8304 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8306 + if (vflags & V_BARRIER)
8307 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8309 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8310 + if (vflags & V_COW)
8311 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8313 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8318 + struct inode *inode,
8322 + struct xfs_inode *ip = XFS_I(inode);
8323 + struct xfs_mount *mp = ip->i_mount;
8324 + struct xfs_trans *tp;
8325 + unsigned int lock_flags = 0;
8328 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8329 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8333 + lock_flags = XFS_ILOCK_EXCL;
8334 + xfs_ilock(ip, lock_flags);
8336 + xfs_trans_ijoin(tp, ip, lock_flags);
8337 + xfs_trans_ihold(tp, ip);
8339 + inode->i_flags = flags;
8340 + inode->i_vflags = vflags;
8341 + xfs_get_inode_flags(ip);
8343 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8344 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8346 + XFS_STATS_INC(xs_ig_attrchg);
8348 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8349 + xfs_trans_set_sync(tp);
8350 + code = xfs_trans_commit(tp, 0);
8351 + xfs_iunlock(ip, lock_flags);
8355 + xfs_trans_cancel(tp, 0);
8357 + xfs_iunlock(ip, lock_flags);
8364 struct xfs_inode *ip,
8365 @@ -69,6 +143,7 @@ xfs_setattr(
8366 uint commit_flags=0;
8367 uid_t uid=0, iuid=0;
8368 gid_t gid=0, igid=0;
8369 + tag_t tag=0, itag=0;
8371 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8372 int need_iolock = 1;
8373 @@ -165,7 +240,7 @@ xfs_setattr(
8375 * Change file ownership. Must be the owner or privileged.
8377 - if (mask & (ATTR_UID|ATTR_GID)) {
8378 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8380 * These IDs could have changed since we last looked at them.
8381 * But, we're assured that if the ownership did change
8382 @@ -174,8 +249,10 @@ xfs_setattr(
8384 iuid = ip->i_d.di_uid;
8385 igid = ip->i_d.di_gid;
8386 + itag = ip->i_d.di_tag;
8387 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8388 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8389 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8392 * Do a quota reservation only if uid/gid is actually
8393 @@ -183,7 +260,8 @@ xfs_setattr(
8395 if (XFS_IS_QUOTA_RUNNING(mp) &&
8396 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8397 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8398 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8399 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8401 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8402 capable(CAP_FOWNER) ?
8403 @@ -336,7 +414,7 @@ xfs_setattr(
8405 * Change file ownership. Must be the owner or privileged.
8407 - if (mask & (ATTR_UID|ATTR_GID)) {
8408 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8410 * CAP_FSETID overrides the following restrictions:
8412 @@ -352,6 +430,10 @@ xfs_setattr(
8413 * Change the ownerships and register quota modifications
8414 * in the transaction.
8416 + if (itag != tag) {
8417 + ip->i_d.di_tag = tag;
8418 + inode->i_tag = tag;
8421 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8422 ASSERT(mask & ATTR_UID);
8423 diff -NurpP --minimal linux-2.6.32.10/fs/xfs/xfs_vnodeops.h linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_vnodeops.h
8424 --- linux-2.6.32.10/fs/xfs/xfs_vnodeops.h 2009-09-10 15:26:24.000000000 +0200
8425 +++ linux-2.6.32.10-vs2.3.0.36.29.2/fs/xfs/xfs_vnodeops.h 2009-12-03 20:04:56.000000000 +0100
8426 @@ -14,6 +14,7 @@ struct xfs_inode;
8430 +int xfs_sync_xflags(struct xfs_inode *ip);
8431 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8432 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8433 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8434 diff -NurpP --minimal linux-2.6.32.10/include/asm-generic/tlb.h linux-2.6.32.10-vs2.3.0.36.29.2/include/asm-generic/tlb.h
8435 --- linux-2.6.32.10/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8436 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/asm-generic/tlb.h 2009-12-03 20:04:56.000000000 +0100
8438 #define _ASM_GENERIC__TLB_H
8440 #include <linux/swap.h>
8441 +#include <linux/vs_memory.h>
8442 #include <asm/pgalloc.h>
8443 #include <asm/tlbflush.h>
8445 diff -NurpP --minimal linux-2.6.32.10/include/linux/capability.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/capability.h
8446 --- linux-2.6.32.10/include/linux/capability.h 2009-12-03 20:02:54.000000000 +0100
8447 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/capability.h 2009-12-03 20:04:56.000000000 +0100
8448 @@ -285,6 +285,7 @@ struct cpu_vfs_cap_data {
8449 arbitrary SCSI commands */
8450 /* Allow setting encryption key on loopback filesystem */
8451 /* Allow setting zone reclaim policy */
8452 +/* Allow the selection of a security context */
8454 #define CAP_SYS_ADMIN 21
8456 @@ -357,7 +358,13 @@ struct cpu_vfs_cap_data {
8458 #define CAP_MAC_ADMIN 33
8460 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8461 +/* Allow context manipulations */
8462 +/* Allow changing context info on files */
8464 +#define CAP_CONTEXT 34
8467 +#define CAP_LAST_CAP CAP_CONTEXT
8469 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8471 diff -NurpP --minimal linux-2.6.32.10/include/linux/devpts_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/devpts_fs.h
8472 --- linux-2.6.32.10/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8473 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/devpts_fs.h 2009-12-03 20:04:56.000000000 +0100
8474 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8479 #endif /* _LINUX_DEVPTS_FS_H */
8480 diff -NurpP --minimal linux-2.6.32.10/include/linux/ext2_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/ext2_fs.h
8481 --- linux-2.6.32.10/include/linux/ext2_fs.h 2009-03-24 14:22:41.000000000 +0100
8482 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/ext2_fs.h 2009-12-03 20:04:56.000000000 +0100
8483 @@ -189,8 +189,12 @@ struct ext2_group_desc
8484 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8485 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8486 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8487 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8488 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8490 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8491 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8493 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8494 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8496 @@ -274,7 +278,8 @@ struct ext2_inode {
8498 __le16 l_i_uid_high; /* these 2 fields */
8499 __le16 l_i_gid_high; /* were reserved2[0] */
8500 - __u32 l_i_reserved2;
8501 + __le16 l_i_tag; /* Context Tag */
8502 + __u16 l_i_reserved2;
8505 __u8 h_i_frag; /* Fragment number */
8506 @@ -303,6 +308,7 @@ struct ext2_inode {
8507 #define i_gid_low i_gid
8508 #define i_uid_high osd2.linux2.l_i_uid_high
8509 #define i_gid_high osd2.linux2.l_i_gid_high
8510 +#define i_raw_tag osd2.linux2.l_i_tag
8511 #define i_reserved2 osd2.linux2.l_i_reserved2
8514 @@ -347,6 +353,7 @@ struct ext2_inode {
8515 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8516 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8517 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8518 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8521 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8522 diff -NurpP --minimal linux-2.6.32.10/include/linux/ext3_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/ext3_fs.h
8523 --- linux-2.6.32.10/include/linux/ext3_fs.h 2009-09-10 15:26:25.000000000 +0200
8524 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/ext3_fs.h 2009-12-03 20:04:56.000000000 +0100
8525 @@ -173,10 +173,14 @@ struct ext3_group_desc
8526 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8527 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8528 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8529 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8530 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8532 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8533 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8534 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8535 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8537 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8538 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8540 /* Flags that should be inherited by new inodes from their parent. */
8541 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8542 @@ -320,7 +324,8 @@ struct ext3_inode {
8544 __le16 l_i_uid_high; /* these 2 fields */
8545 __le16 l_i_gid_high; /* were reserved2[0] */
8546 - __u32 l_i_reserved2;
8547 + __le16 l_i_tag; /* Context Tag */
8548 + __u16 l_i_reserved2;
8551 __u8 h_i_frag; /* Fragment number */
8552 @@ -351,6 +356,7 @@ struct ext3_inode {
8553 #define i_gid_low i_gid
8554 #define i_uid_high osd2.linux2.l_i_uid_high
8555 #define i_gid_high osd2.linux2.l_i_gid_high
8556 +#define i_raw_tag osd2.linux2.l_i_tag
8557 #define i_reserved2 osd2.linux2.l_i_reserved2
8559 #elif defined(__GNU__)
8560 @@ -414,6 +420,7 @@ struct ext3_inode {
8561 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8562 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8563 * error in ordered mode */
8564 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8566 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8567 #ifndef _LINUX_EXT2_FS_H
8568 @@ -892,6 +899,7 @@ extern void ext3_get_inode_flags(struct
8569 extern void ext3_set_aops(struct inode *inode);
8570 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8571 u64 start, u64 len);
8572 +extern int ext3_sync_flags(struct inode *, int, int);
8575 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8576 diff -NurpP --minimal linux-2.6.32.10/include/linux/fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/fs.h
8577 --- linux-2.6.32.10/include/linux/fs.h 2010-03-18 16:17:37.000000000 +0100
8578 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/fs.h 2010-03-18 16:53:06.000000000 +0100
8579 @@ -208,6 +208,9 @@ struct inodes_stat_t {
8580 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8581 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8582 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8583 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8584 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8585 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8586 #define MS_ACTIVE (1<<30)
8587 #define MS_NOUSER (1<<31)
8589 @@ -234,6 +237,14 @@ struct inodes_stat_t {
8590 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8591 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8592 #define S_PRIVATE 512 /* Inode is fs-internal */
8593 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8595 +/* Linux-VServer related Inode flags */
8599 +#define V_BARRIER 4 /* Barrier for chroot() */
8600 +#define V_COW 8 /* Copy on Write */
8603 * Note that nosuid etc flags are inode-specific: setting some file-system
8604 @@ -256,12 +267,15 @@ struct inodes_stat_t {
8605 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8606 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8607 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8608 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8609 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8610 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8611 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8612 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8614 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8615 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8616 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8617 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8618 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8619 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8621 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8622 @@ -269,6 +283,16 @@ struct inodes_stat_t {
8623 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8624 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8626 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8628 +#ifdef CONFIG_VSERVER_COWBL
8629 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8630 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8632 +# define IS_COW(inode) (0)
8633 +# define IS_COW_LINK(inode) (0)
8636 /* the read-only stuff doesn't really belong here, but any other place is
8637 probably as bad and I don't want to create yet another include file. */
8639 @@ -350,11 +374,14 @@ struct inodes_stat_t {
8640 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8641 #define FS_EXTENT_FL 0x00080000 /* Extents */
8642 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8643 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8644 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8646 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8647 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8648 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8649 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8651 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8652 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8654 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8655 #define SYNC_FILE_RANGE_WRITE 2
8656 @@ -436,6 +463,7 @@ typedef void (dio_iodone_t)(struct kiocb
8657 #define ATTR_KILL_PRIV (1 << 14)
8658 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8659 #define ATTR_TIMES_SET (1 << 16)
8660 +#define ATTR_TAG (1 << 17)
8663 * This is the Inode Attributes structure, used for notify_change(). It
8664 @@ -451,6 +479,7 @@ struct iattr {
8670 struct timespec ia_atime;
8671 struct timespec ia_mtime;
8672 @@ -464,6 +493,9 @@ struct iattr {
8673 struct file *ia_file;
8676 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8677 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8680 * Includes for diskquotas.
8682 @@ -729,7 +761,9 @@ struct inode {
8683 unsigned int i_nlink;
8691 #ifdef __NEED_I_SIZE_ORDERED
8692 @@ -776,7 +810,8 @@ struct inode {
8693 unsigned long i_state;
8694 unsigned long dirtied_when; /* jiffies of first dirtying */
8696 - unsigned int i_flags;
8697 + unsigned short i_flags;
8698 + unsigned short i_vflags;
8700 atomic_t i_writecount;
8701 #ifdef CONFIG_SECURITY
8702 @@ -864,12 +899,12 @@ static inline void i_size_write(struct i
8704 static inline unsigned iminor(const struct inode *inode)
8706 - return MINOR(inode->i_rdev);
8707 + return MINOR(inode->i_mdev);
8710 static inline unsigned imajor(const struct inode *inode)
8712 - return MAJOR(inode->i_rdev);
8713 + return MAJOR(inode->i_mdev);
8716 extern struct block_device *I_BDEV(struct inode *inode);
8717 @@ -928,6 +963,7 @@ struct file {
8719 struct fown_struct f_owner;
8720 const struct cred *f_cred;
8722 struct file_ra_state f_ra;
8725 @@ -1069,6 +1105,7 @@ struct file_lock {
8726 struct file *fl_file;
8731 struct fasync_struct * fl_fasync; /* for lease break notifications */
8732 unsigned long fl_break_time; /* for nonblocking lease breaks */
8733 @@ -1534,6 +1571,7 @@ struct inode_operations {
8734 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8735 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8736 int (*removexattr) (struct dentry *, const char *);
8737 + int (*sync_flags) (struct inode *, int, int);
8738 void (*truncate_range)(struct inode *, loff_t, loff_t);
8739 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8741 @@ -1554,6 +1592,7 @@ extern ssize_t vfs_readv(struct file *,
8742 unsigned long, loff_t *);
8743 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8744 unsigned long, loff_t *);
8745 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8747 struct super_operations {
8748 struct inode *(*alloc_inode)(struct super_block *sb);
8749 @@ -2351,6 +2390,7 @@ extern int dcache_dir_open(struct inode
8750 extern int dcache_dir_close(struct inode *, struct file *);
8751 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8752 extern int dcache_readdir(struct file *, void *, filldir_t);
8753 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8754 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8755 extern int simple_statfs(struct dentry *, struct kstatfs *);
8756 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8757 diff -NurpP --minimal linux-2.6.32.10/include/linux/gfs2_ondisk.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/gfs2_ondisk.h
8758 --- linux-2.6.32.10/include/linux/gfs2_ondisk.h 2009-12-03 20:02:55.000000000 +0100
8759 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/gfs2_ondisk.h 2009-12-03 20:04:56.000000000 +0100
8760 @@ -235,6 +235,9 @@ enum {
8764 + gfs2fl_IXUnlink = 16,
8765 + gfs2fl_Barrier = 17,
8767 gfs2fl_TruncInProg = 29,
8768 gfs2fl_InheritDirectio = 30,
8769 gfs2fl_InheritJdata = 31,
8770 @@ -251,6 +254,9 @@ enum {
8771 #define GFS2_DIF_NOATIME 0x00000080
8772 #define GFS2_DIF_SYNC 0x00000100
8773 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8774 +#define GFS2_DIF_IXUNLINK 0x00010000
8775 +#define GFS2_DIF_BARRIER 0x00020000
8776 +#define GFS2_DIF_COW 0x00040000
8777 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8778 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8779 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8780 diff -NurpP --minimal linux-2.6.32.10/include/linux/if_tun.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/if_tun.h
8781 --- linux-2.6.32.10/include/linux/if_tun.h 2009-12-03 20:02:55.000000000 +0100
8782 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/if_tun.h 2009-12-03 20:04:56.000000000 +0100
8784 #define TUNGETIFF _IOR('T', 210, unsigned int)
8785 #define TUNGETSNDBUF _IOR('T', 211, int)
8786 #define TUNSETSNDBUF _IOW('T', 212, int)
8787 +#define TUNSETNID _IOW('T', 215, int)
8789 /* TUNSETIFF ifr flags */
8790 #define IFF_TUN 0x0001
8791 diff -NurpP --minimal linux-2.6.32.10/include/linux/init_task.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/init_task.h
8792 --- linux-2.6.32.10/include/linux/init_task.h 2009-12-03 20:02:55.000000000 +0100
8793 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/init_task.h 2009-12-03 20:04:56.000000000 +0100
8794 @@ -184,6 +184,10 @@ extern struct cred init_cred;
8796 INIT_TRACE_RECURSION \
8797 INIT_TASK_RCU_PREEMPT(tsk) \
8799 + .vx_info = NULL, \
8801 + .nx_info = NULL, \
8805 diff -NurpP --minimal linux-2.6.32.10/include/linux/ipc.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/ipc.h
8806 --- linux-2.6.32.10/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8807 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/ipc.h 2009-12-03 20:04:56.000000000 +0100
8808 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8816 diff -NurpP --minimal linux-2.6.32.10/include/linux/Kbuild linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/Kbuild
8817 --- linux-2.6.32.10/include/linux/Kbuild 2009-12-03 20:02:54.000000000 +0100
8818 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/Kbuild 2009-12-03 20:04:56.000000000 +0100
8819 @@ -382,5 +382,8 @@ unifdef-y += xattr.h
8822 objhdr-y += version.h
8824 +header-y += vserver/
8828 diff -NurpP --minimal linux-2.6.32.10/include/linux/loop.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/loop.h
8829 --- linux-2.6.32.10/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8830 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/loop.h 2009-12-03 20:04:56.000000000 +0100
8831 @@ -45,6 +45,7 @@ struct loop_device {
8832 struct loop_func_table *lo_encryption;
8834 uid_t lo_key_owner; /* Who set the key */
8836 int (*ioctl)(struct loop_device *, int cmd,
8839 diff -NurpP --minimal linux-2.6.32.10/include/linux/magic.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/magic.h
8840 --- linux-2.6.32.10/include/linux/magic.h 2009-12-03 20:02:55.000000000 +0100
8841 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/magic.h 2009-12-03 20:04:56.000000000 +0100
8844 #define ADFS_SUPER_MAGIC 0xadf5
8845 #define AFFS_SUPER_MAGIC 0xadff
8846 -#define AFS_SUPER_MAGIC 0x5346414F
8847 +#define AFS_SUPER_MAGIC 0x5346414F
8848 #define AUTOFS_SUPER_MAGIC 0x0187
8849 #define CODA_SUPER_MAGIC 0x73757245
8850 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8852 #define NFS_SUPER_MAGIC 0x6969
8853 #define OPENPROM_SUPER_MAGIC 0x9fa1
8854 #define PROC_SUPER_MAGIC 0x9fa0
8855 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8856 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8858 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8859 diff -NurpP --minimal linux-2.6.32.10/include/linux/major.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/major.h
8860 --- linux-2.6.32.10/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8861 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/major.h 2009-12-03 20:04:56.000000000 +0100
8863 #define HD_MAJOR IDE0_MAJOR
8864 #define PTY_SLAVE_MAJOR 3
8866 +#define VROOT_MAJOR 4
8867 #define TTYAUX_MAJOR 5
8870 diff -NurpP --minimal linux-2.6.32.10/include/linux/memcontrol.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/memcontrol.h
8871 --- linux-2.6.32.10/include/linux/memcontrol.h 2009-12-03 20:02:55.000000000 +0100
8872 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/memcontrol.h 2010-02-05 00:15:49.000000000 +0100
8873 @@ -70,6 +70,13 @@ int task_in_mem_cgroup(struct task_struc
8875 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8877 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8878 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8880 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8881 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8882 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8885 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8887 diff -NurpP --minimal linux-2.6.32.10/include/linux/mm_types.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/mm_types.h
8888 --- linux-2.6.32.10/include/linux/mm_types.h 2009-12-03 20:02:55.000000000 +0100
8889 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/mm_types.h 2009-12-03 20:04:56.000000000 +0100
8890 @@ -246,6 +246,7 @@ struct mm_struct {
8892 /* Architecture-specific MM context */
8893 mm_context_t context;
8894 + struct vx_info *mm_vx_info;
8896 /* Swap token stuff */
8898 diff -NurpP --minimal linux-2.6.32.10/include/linux/mount.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/mount.h
8899 --- linux-2.6.32.10/include/linux/mount.h 2009-09-10 15:26:25.000000000 +0200
8900 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/mount.h 2009-12-03 20:04:56.000000000 +0100
8901 @@ -36,6 +36,9 @@ struct mnt_namespace;
8902 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8903 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8905 +#define MNT_TAGID 0x10000
8906 +#define MNT_NOTAG 0x20000
8909 struct list_head mnt_hash;
8910 struct vfsmount *mnt_parent; /* fs we are mounted on */
8911 @@ -70,6 +73,7 @@ struct vfsmount {
8915 + tag_t mnt_tag; /* tagging used for vfsmount */
8918 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
8919 diff -NurpP --minimal linux-2.6.32.10/include/linux/net.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/net.h
8920 --- linux-2.6.32.10/include/linux/net.h 2009-12-03 20:02:55.000000000 +0100
8921 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/net.h 2009-12-03 20:04:56.000000000 +0100
8922 @@ -69,6 +69,7 @@ struct net;
8923 #define SOCK_NOSPACE 2
8924 #define SOCK_PASSCRED 3
8925 #define SOCK_PASSSEC 4
8926 +#define SOCK_USER_SOCKET 5
8928 #ifndef ARCH_HAS_SOCKET_TYPES
8930 diff -NurpP --minimal linux-2.6.32.10/include/linux/nfs_mount.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/nfs_mount.h
8931 --- linux-2.6.32.10/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
8932 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/nfs_mount.h 2009-12-03 20:04:56.000000000 +0100
8933 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8934 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8935 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8936 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8937 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8938 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8939 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8941 /* The following are for internal use only */
8942 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8943 diff -NurpP --minimal linux-2.6.32.10/include/linux/nsproxy.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/nsproxy.h
8944 --- linux-2.6.32.10/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
8945 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/nsproxy.h 2009-12-03 20:04:56.000000000 +0100
8948 #include <linux/spinlock.h>
8949 #include <linux/sched.h>
8950 +#include <linux/vserver/debug.h>
8952 struct mnt_namespace;
8953 struct uts_namespace;
8954 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8957 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8958 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8959 void exit_task_namespaces(struct task_struct *tsk);
8960 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8961 void free_nsproxy(struct nsproxy *ns);
8962 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8963 struct fs_struct *);
8965 -static inline void put_nsproxy(struct nsproxy *ns)
8966 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8968 +static inline void __get_nsproxy(struct nsproxy *ns,
8969 + const char *_file, int _line)
8971 - if (atomic_dec_and_test(&ns->count)) {
8974 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8975 + ns, atomic_read(&ns->count), _file, _line);
8976 + atomic_inc(&ns->count);
8979 -static inline void get_nsproxy(struct nsproxy *ns)
8980 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8982 +static inline void __put_nsproxy(struct nsproxy *ns,
8983 + const char *_file, int _line)
8985 - atomic_inc(&ns->count);
8986 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8987 + ns, atomic_read(&ns->count), _file, _line);
8988 + if (atomic_dec_and_test(&ns->count)) {
8993 #ifdef CONFIG_CGROUP_NS
8994 diff -NurpP --minimal linux-2.6.32.10/include/linux/pid.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/pid.h
8995 --- linux-2.6.32.10/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
8996 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/pid.h 2009-12-03 20:04:56.000000000 +0100
8997 @@ -8,7 +8,8 @@ enum pid_type
9007 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9010 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9011 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9012 pid_t pid_vnr(struct pid *pid);
9014 #define do_each_pid_task(pid, type, task) \
9015 diff -NurpP --minimal linux-2.6.32.10/include/linux/proc_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/proc_fs.h
9016 --- linux-2.6.32.10/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9017 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/proc_fs.h 2009-12-03 20:04:56.000000000 +0100
9018 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9024 const struct inode_operations *proc_iops;
9026 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9027 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9034 int (*proc_get_link)(struct inode *, struct path *);
9035 int (*proc_read)(struct task_struct *task, char *page);
9036 int (*proc_show)(struct seq_file *m,
9037 struct pid_namespace *ns, struct pid *pid,
9038 struct task_struct *task);
9039 + int (*proc_vs_read)(char *page);
9040 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9041 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9044 struct ctl_table_header;
9045 @@ -263,6 +270,7 @@ struct ctl_table;
9052 struct proc_dir_entry *pde;
9053 diff -NurpP --minimal linux-2.6.32.10/include/linux/quotaops.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/quotaops.h
9054 --- linux-2.6.32.10/include/linux/quotaops.h 2009-12-03 20:02:56.000000000 +0100
9055 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/quotaops.h 2009-12-03 20:04:56.000000000 +0100
9057 #define _LINUX_QUOTAOPS_
9059 #include <linux/fs.h>
9060 +#include <linux/vs_dlimit.h>
9062 static inline struct quota_info *sb_dqopt(struct super_block *sb)
9064 @@ -154,10 +155,14 @@ static inline void vfs_dq_init(struct in
9065 * a transaction (deadlocks possible otherwise) */
9066 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9068 + if (dl_alloc_space(inode, nr))
9070 if (sb_any_quota_active(inode->i_sb)) {
9071 /* Used space is updated in alloc_space() */
9072 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
9073 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) {
9074 + dl_free_space(inode, nr);
9079 inode_add_bytes(inode, nr);
9080 @@ -174,10 +179,14 @@ static inline int vfs_dq_prealloc_space(
9082 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9084 + if (dl_alloc_space(inode, nr))
9086 if (sb_any_quota_active(inode->i_sb)) {
9087 /* Used space is updated in alloc_space() */
9088 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
9089 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) {
9090 + dl_free_space(inode, nr);
9095 inode_add_bytes(inode, nr);
9096 @@ -194,20 +203,28 @@ static inline int vfs_dq_alloc_space(str
9098 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9100 + if (dl_reserve_space(inode, nr))
9102 if (sb_any_quota_active(inode->i_sb)) {
9103 /* Used space is updated in alloc_space() */
9104 - if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
9105 + if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) {
9106 + dl_release_space(inode, nr);
9113 static inline int vfs_dq_alloc_inode(struct inode *inode)
9115 + if (dl_alloc_inode(inode))
9117 if (sb_any_quota_active(inode->i_sb)) {
9119 - if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
9120 + if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
9121 + dl_free_inode(inode);
9127 @@ -217,9 +234,13 @@ static inline int vfs_dq_alloc_inode(str
9129 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9131 + if (dl_claim_space(inode, nr))
9133 if (sb_any_quota_active(inode->i_sb)) {
9134 - if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
9135 + if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
9136 + dl_release_space(inode, nr);
9140 inode_add_bytes(inode, nr);
9142 @@ -235,6 +256,7 @@ void vfs_dq_release_reservation_space(st
9144 if (sb_any_quota_active(inode->i_sb))
9145 inode->i_sb->dq_op->release_rsv(inode, nr);
9146 + dl_release_space(inode, nr);
9149 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9150 @@ -243,6 +265,7 @@ static inline void vfs_dq_free_space_nod
9151 inode->i_sb->dq_op->free_space(inode, nr);
9153 inode_sub_bytes(inode, nr);
9154 + dl_free_space(inode, nr);
9157 static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
9158 @@ -255,6 +278,7 @@ static inline void vfs_dq_free_inode(str
9160 if (sb_any_quota_active(inode->i_sb))
9161 inode->i_sb->dq_op->free_inode(inode, 1);
9162 + dl_free_inode(inode);
9165 /* Cannot be called inside a transaction */
9166 @@ -358,6 +382,8 @@ static inline int vfs_dq_transfer(struct
9168 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9170 + if (dl_alloc_space(inode, nr))
9172 inode_add_bytes(inode, nr);
9175 @@ -371,6 +397,8 @@ static inline int vfs_dq_prealloc_space(
9177 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9179 + if (dl_alloc_space(inode, nr))
9181 inode_add_bytes(inode, nr);
9184 @@ -384,22 +412,28 @@ static inline int vfs_dq_alloc_space(str
9186 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9188 + if (dl_reserve_space(inode, nr))
9193 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9195 + if (dl_claim_space(inode, nr))
9197 return vfs_dq_alloc_space(inode, nr);
9201 int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
9203 + dl_release_space(inode, nr);
9207 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9209 + dl_free_space(inode, nr);
9210 inode_sub_bytes(inode, nr);
9213 diff -NurpP --minimal linux-2.6.32.10/include/linux/reboot.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/reboot.h
9214 --- linux-2.6.32.10/include/linux/reboot.h 2008-12-25 00:26:37.000000000 +0100
9215 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/reboot.h 2009-12-03 22:06:59.000000000 +0100
9217 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9218 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9219 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9220 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9224 diff -NurpP --minimal linux-2.6.32.10/include/linux/reiserfs_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/reiserfs_fs.h
9225 --- linux-2.6.32.10/include/linux/reiserfs_fs.h 2009-09-10 15:26:26.000000000 +0200
9226 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/reiserfs_fs.h 2009-12-03 20:04:56.000000000 +0100
9227 @@ -899,6 +899,11 @@ struct stat_data_v1 {
9228 #define REISERFS_COMPR_FL FS_COMPR_FL
9229 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9231 +/* unfortunately reiserfs sdattr is only 16 bit */
9232 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9233 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9234 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9236 /* persistent flags that file inherits from the parent directory */
9237 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9238 REISERFS_SYNC_FL | \
9239 @@ -908,6 +913,9 @@ struct stat_data_v1 {
9240 REISERFS_COMPR_FL | \
9241 REISERFS_NOTAIL_FL )
9243 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9244 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9246 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9249 @@ -1989,6 +1997,7 @@ static inline void reiserfs_update_sd(st
9250 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9251 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9252 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9253 +int reiserfs_sync_flags(struct inode *inode, int, int);
9256 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9257 diff -NurpP --minimal linux-2.6.32.10/include/linux/reiserfs_fs_sb.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/reiserfs_fs_sb.h
9258 --- linux-2.6.32.10/include/linux/reiserfs_fs_sb.h 2009-09-10 15:26:26.000000000 +0200
9259 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/reiserfs_fs_sb.h 2009-12-03 20:04:56.000000000 +0100
9260 @@ -456,6 +456,7 @@ enum reiserfs_mount_options {
9261 REISERFS_EXPOSE_PRIVROOT,
9262 REISERFS_BARRIER_NONE,
9263 REISERFS_BARRIER_FLUSH,
9266 /* Actions on error */
9267 REISERFS_ERROR_PANIC,
9268 diff -NurpP --minimal linux-2.6.32.10/include/linux/sched.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sched.h
9269 --- linux-2.6.32.10/include/linux/sched.h 2010-03-18 16:17:37.000000000 +0100
9270 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sched.h 2010-03-18 16:53:06.000000000 +0100
9271 @@ -390,25 +390,28 @@ extern void arch_unmap_area_topdown(stru
9272 * The mm counters are not protected by its page_table_lock,
9273 * so must be incremented atomically.
9275 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9276 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9277 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9278 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9279 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9280 +#define __set_mm_counter(mm, member, value) \
9281 + atomic_long_set(&(mm)->_##member, value)
9282 +#define get_mm_counter(mm, member) \
9283 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9285 #else /* !USE_SPLIT_PTLOCKS */
9287 * The mm counters are protected by its page_table_lock,
9288 * so can be incremented directly.
9290 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9291 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9292 #define get_mm_counter(mm, member) ((mm)->_##member)
9293 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9294 -#define inc_mm_counter(mm, member) (mm)->_##member++
9295 -#define dec_mm_counter(mm, member) (mm)->_##member--
9297 #endif /* !USE_SPLIT_PTLOCKS */
9299 +#define set_mm_counter(mm, member, value) \
9300 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9301 +#define add_mm_counter(mm, member, value) \
9302 + vx_ ## member ## pages_add((mm), (value))
9303 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9304 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9306 #define get_mm_rss(mm) \
9307 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9308 #define update_hiwater_rss(mm) do { \
9309 @@ -1186,6 +1189,12 @@ struct sched_entity {
9310 u64 nr_wakeups_affine_attempts;
9311 u64 nr_wakeups_passive;
9312 u64 nr_wakeups_idle;
9313 +#ifdef CONFIG_CFS_HARD_LIMITS
9314 + u64 throttle_start;
9316 + u64 throttle_count;
9321 #ifdef CONFIG_FAIR_GROUP_SCHED
9322 @@ -1396,6 +1405,14 @@ struct task_struct {
9326 +/* vserver context data */
9327 + struct vx_info *vx_info;
9328 + struct nx_info *nx_info;
9334 /* Thread group tracking */
9337 @@ -1621,6 +1638,11 @@ struct pid_namespace;
9338 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9339 struct pid_namespace *ns);
9341 +#include <linux/vserver/base.h>
9342 +#include <linux/vserver/context.h>
9343 +#include <linux/vserver/debug.h>
9344 +#include <linux/vserver/pid.h>
9346 static inline pid_t task_pid_nr(struct task_struct *tsk)
9349 @@ -1634,7 +1656,8 @@ static inline pid_t task_pid_nr_ns(struc
9351 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9353 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9354 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9355 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9359 @@ -1647,7 +1670,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9361 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9363 - return pid_vnr(task_tgid(tsk));
9364 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9368 diff -NurpP --minimal linux-2.6.32.10/include/linux/shmem_fs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/shmem_fs.h
9369 --- linux-2.6.32.10/include/linux/shmem_fs.h 2009-12-03 20:02:56.000000000 +0100
9370 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/shmem_fs.h 2009-12-03 20:04:56.000000000 +0100
9373 #define SHMEM_NR_DIRECT 16
9375 +#define TMPFS_SUPER_MAGIC 0x01021994
9378 struct shmem_inode_info {
9380 unsigned long flags;
9381 diff -NurpP --minimal linux-2.6.32.10/include/linux/stat.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/stat.h
9382 --- linux-2.6.32.10/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9383 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/stat.h 2009-12-03 20:04:56.000000000 +0100
9384 @@ -66,6 +66,7 @@ struct kstat {
9391 struct timespec atime;
9392 diff -NurpP --minimal linux-2.6.32.10/include/linux/sunrpc/auth.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sunrpc/auth.h
9393 --- linux-2.6.32.10/include/linux/sunrpc/auth.h 2009-12-03 20:02:56.000000000 +0100
9394 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sunrpc/auth.h 2009-12-03 20:04:56.000000000 +0100
9400 struct group_info *group_info;
9401 unsigned char machine_cred : 1;
9403 diff -NurpP --minimal linux-2.6.32.10/include/linux/sunrpc/clnt.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sunrpc/clnt.h
9404 --- linux-2.6.32.10/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
9405 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sunrpc/clnt.h 2009-12-03 20:04:56.000000000 +0100
9406 @@ -49,7 +49,8 @@ struct rpc_clnt {
9407 unsigned int cl_softrtry : 1,/* soft timeouts */
9408 cl_discrtry : 1,/* disconnect before retry */
9409 cl_autobind : 1,/* use getport() */
9410 - cl_chatty : 1;/* be verbose */
9411 + cl_chatty : 1,/* be verbose */
9412 + cl_tag : 1;/* context tagging */
9414 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9415 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9416 diff -NurpP --minimal linux-2.6.32.10/include/linux/syscalls.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/syscalls.h
9417 --- linux-2.6.32.10/include/linux/syscalls.h 2010-03-18 16:17:37.000000000 +0100
9418 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/syscalls.h 2010-01-20 04:21:33.000000000 +0100
9419 @@ -546,6 +546,8 @@ asmlinkage long sys_symlink(const char _
9420 asmlinkage long sys_unlink(const char __user *pathname);
9421 asmlinkage long sys_rename(const char __user *oldname,
9422 const char __user *newname);
9423 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9425 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9426 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9428 diff -NurpP --minimal linux-2.6.32.10/include/linux/sysctl.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sysctl.h
9429 --- linux-2.6.32.10/include/linux/sysctl.h 2010-03-18 16:17:37.000000000 +0100
9430 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sysctl.h 2010-02-12 10:59:55.000000000 +0100
9431 @@ -69,6 +69,7 @@ enum
9432 CTL_ABI=9, /* Binary emulation */
9433 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9434 CTL_ARLAN=254, /* arlan wireless driver */
9435 + CTL_VSERVER=4242, /* Linux-VServer debug */
9436 CTL_S390DBF=5677, /* s390 debug */
9437 CTL_SUNRPC=7249, /* sunrpc debug */
9438 CTL_PM=9899, /* frv power management */
9439 @@ -103,6 +104,7 @@ enum
9441 KERN_PANIC=15, /* int: panic timeout */
9442 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9443 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9445 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9446 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9447 diff -NurpP --minimal linux-2.6.32.10/include/linux/sysfs.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sysfs.h
9448 --- linux-2.6.32.10/include/linux/sysfs.h 2008-12-25 00:26:37.000000000 +0100
9449 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/sysfs.h 2009-12-03 20:04:56.000000000 +0100
9451 #include <linux/list.h>
9452 #include <asm/atomic.h>
9454 +#define SYSFS_SUPER_MAGIC 0x62656572
9459 diff -NurpP --minimal linux-2.6.32.10/include/linux/time.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/time.h
9460 --- linux-2.6.32.10/include/linux/time.h 2010-03-18 16:17:37.000000000 +0100
9461 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/time.h 2010-02-12 10:59:55.000000000 +0100
9462 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
9463 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9467 +#include <linux/vs_time.h>
9469 #endif /* __KERNEL__ */
9471 #define NFDBITS __NFDBITS
9472 diff -NurpP --minimal linux-2.6.32.10/include/linux/types.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/types.h
9473 --- linux-2.6.32.10/include/linux/types.h 2009-09-10 15:26:26.000000000 +0200
9474 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/types.h 2009-12-03 20:04:56.000000000 +0100
9475 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
9476 typedef __kernel_gid32_t gid_t;
9477 typedef __kernel_uid16_t uid16_t;
9478 typedef __kernel_gid16_t gid16_t;
9479 +typedef unsigned int xid_t;
9480 +typedef unsigned int nid_t;
9481 +typedef unsigned int tag_t;
9483 typedef unsigned long uintptr_t;
9485 diff -NurpP --minimal linux-2.6.32.10/include/linux/vroot.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vroot.h
9486 --- linux-2.6.32.10/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9487 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vroot.h 2009-12-03 20:04:56.000000000 +0100
9491 + * include/linux/vroot.h
9493 + * written by Herbert Pötzl, 9/11/2002
9494 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9496 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9497 + * Redistribution of this file is permitted under the
9498 + * GNU General Public License.
9501 +#ifndef _LINUX_VROOT_H
9502 +#define _LINUX_VROOT_H
9507 +/* Possible states of device */
9513 +struct vroot_device {
9517 + struct semaphore vr_ctl_mutex;
9518 + struct block_device *vr_device;
9523 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9525 +extern int register_vroot_grb(vroot_grb_func *);
9526 +extern int unregister_vroot_grb(vroot_grb_func *);
9528 +#endif /* __KERNEL__ */
9530 +#define MAX_VROOT_DEFAULT 8
9533 + * IOCTL commands --- we will commandeer 0x56 ('V')
9536 +#define VROOT_SET_DEV 0x5600
9537 +#define VROOT_CLR_DEV 0x5601
9539 +#endif /* _LINUX_VROOT_H */
9540 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_base.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_base.h
9541 --- linux-2.6.32.10/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9542 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_base.h 2009-12-03 20:04:56.000000000 +0100
9547 +#include "vserver/base.h"
9548 +#include "vserver/check.h"
9549 +#include "vserver/debug.h"
9552 +#warning duplicate inclusion
9554 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_context.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_context.h
9555 --- linux-2.6.32.10/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9556 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_context.h 2009-12-03 20:04:56.000000000 +0100
9558 +#ifndef _VS_CONTEXT_H
9559 +#define _VS_CONTEXT_H
9561 +#include "vserver/base.h"
9562 +#include "vserver/check.h"
9563 +#include "vserver/context.h"
9564 +#include "vserver/history.h"
9565 +#include "vserver/debug.h"
9567 +#include <linux/sched.h>
9570 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9572 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9573 + const char *_file, int _line, void *_here)
9578 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9579 + vxi, vxi ? vxi->vx_id : 0,
9580 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9582 + __vxh_get_vx_info(vxi, _here);
9584 + atomic_inc(&vxi->vx_usecnt);
9589 +extern void free_vx_info(struct vx_info *);
9591 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9593 +static inline void __put_vx_info(struct vx_info *vxi,
9594 + const char *_file, int _line, void *_here)
9599 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9600 + vxi, vxi ? vxi->vx_id : 0,
9601 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9603 + __vxh_put_vx_info(vxi, _here);
9605 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9606 + free_vx_info(vxi);
9610 +#define init_vx_info(p, i) \
9611 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9613 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9614 + const char *_file, int _line, void *_here)
9617 + vxlprintk(VXD_CBIT(xid, 3),
9618 + "init_vx_info(%p[#%d.%d])",
9619 + vxi, vxi ? vxi->vx_id : 0,
9620 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9622 + __vxh_init_vx_info(vxi, vxp, _here);
9624 + atomic_inc(&vxi->vx_usecnt);
9630 +#define set_vx_info(p, i) \
9631 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9633 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9634 + const char *_file, int _line, void *_here)
9636 + struct vx_info *vxo;
9641 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9642 + vxi, vxi ? vxi->vx_id : 0,
9643 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9645 + __vxh_set_vx_info(vxi, vxp, _here);
9647 + atomic_inc(&vxi->vx_usecnt);
9648 + vxo = xchg(vxp, vxi);
9653 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9655 +static inline void __clr_vx_info(struct vx_info **vxp,
9656 + const char *_file, int _line, void *_here)
9658 + struct vx_info *vxo;
9660 + vxo = xchg(vxp, NULL);
9664 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9665 + vxo, vxo ? vxo->vx_id : 0,
9666 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9668 + __vxh_clr_vx_info(vxo, vxp, _here);
9670 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9671 + free_vx_info(vxo);
9675 +#define claim_vx_info(v, p) \
9676 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9678 +static inline void __claim_vx_info(struct vx_info *vxi,
9679 + struct task_struct *task,
9680 + const char *_file, int _line, void *_here)
9682 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9683 + vxi, vxi ? vxi->vx_id : 0,
9684 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9685 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9686 + task, _file, _line);
9687 + __vxh_claim_vx_info(vxi, task, _here);
9689 + atomic_inc(&vxi->vx_tasks);
9693 +extern void unhash_vx_info(struct vx_info *);
9695 +#define release_vx_info(v, p) \
9696 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9698 +static inline void __release_vx_info(struct vx_info *vxi,
9699 + struct task_struct *task,
9700 + const char *_file, int _line, void *_here)
9702 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9703 + vxi, vxi ? vxi->vx_id : 0,
9704 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9705 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9706 + task, _file, _line);
9707 + __vxh_release_vx_info(vxi, task, _here);
9711 + if (atomic_dec_and_test(&vxi->vx_tasks))
9712 + unhash_vx_info(vxi);
9716 +#define task_get_vx_info(p) \
9717 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9719 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9720 + const char *_file, int _line, void *_here)
9722 + struct vx_info *vxi;
9725 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9727 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9733 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9735 + if (waitqueue_active(&vxi->vx_wait))
9736 + wake_up_interruptible(&vxi->vx_wait);
9740 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9742 +static inline void __enter_vx_info(struct vx_info *vxi,
9743 + struct vx_info_save *vxis, const char *_file, int _line)
9745 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9746 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9747 + current->xid, current->vx_info, _file, _line);
9748 + vxis->vxi = xchg(¤t->vx_info, vxi);
9749 + vxis->xid = current->xid;
9750 + current->xid = vxi ? vxi->vx_id : 0;
9753 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9755 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9756 + const char *_file, int _line)
9758 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9759 + vxis, vxis->xid, vxis->vxi, current,
9760 + current->xid, current->vx_info, _file, _line);
9761 + (void)xchg(¤t->vx_info, vxis->vxi);
9762 + current->xid = vxis->xid;
9766 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9768 + vxis->vxi = xchg(¤t->vx_info, NULL);
9769 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9772 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9774 + (void)xchg(¤t->xid, vxis->xid);
9775 + (void)xchg(¤t->vx_info, vxis->vxi);
9778 +#define task_is_init(p) \
9779 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9781 +static inline int __task_is_init(struct task_struct *p,
9782 + const char *_file, int _line, void *_here)
9784 + int is_init = is_global_init(p);
9788 + is_init = p->vx_info->vx_initpid == p->pid;
9793 +extern void exit_vx_info(struct task_struct *, int);
9794 +extern void exit_vx_info_early(struct task_struct *, int);
9798 +#warning duplicate inclusion
9800 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_cowbl.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_cowbl.h
9801 --- linux-2.6.32.10/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9802 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_cowbl.h 2009-12-03 20:04:56.000000000 +0100
9804 +#ifndef _VS_COWBL_H
9805 +#define _VS_COWBL_H
9807 +#include <linux/fs.h>
9808 +#include <linux/dcache.h>
9809 +#include <linux/namei.h>
9811 +extern struct dentry *cow_break_link(const char *pathname);
9813 +static inline int cow_check_and_break(struct path *path)
9815 + struct inode *inode = path->dentry->d_inode;
9818 + /* do we need this check? */
9819 + if (IS_RDONLY(inode))
9822 + if (IS_COW(inode)) {
9823 + if (IS_COW_LINK(inode)) {
9824 + struct dentry *new_dentry, *old_dentry = path->dentry;
9827 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9831 + pp = d_path(path, buf, PATH_MAX);
9832 + new_dentry = cow_break_link(pp);
9834 + if (!IS_ERR(new_dentry)) {
9835 + path->dentry = new_dentry;
9838 + error = PTR_ERR(new_dentry);
9840 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9841 + inode->i_ctime = CURRENT_TIME;
9842 + mark_inode_dirty(inode);
9849 +#warning duplicate inclusion
9851 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_cvirt.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_cvirt.h
9852 --- linux-2.6.32.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9853 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_cvirt.h 2009-12-03 20:04:56.000000000 +0100
9855 +#ifndef _VS_CVIRT_H
9856 +#define _VS_CVIRT_H
9858 +#include "vserver/cvirt.h"
9859 +#include "vserver/context.h"
9860 +#include "vserver/base.h"
9861 +#include "vserver/check.h"
9862 +#include "vserver/debug.h"
9865 +static inline void vx_activate_task(struct task_struct *p)
9867 + struct vx_info *vxi;
9869 + if ((vxi = p->vx_info)) {
9870 + vx_update_load(vxi);
9871 + atomic_inc(&vxi->cvirt.nr_running);
9875 +static inline void vx_deactivate_task(struct task_struct *p)
9877 + struct vx_info *vxi;
9879 + if ((vxi = p->vx_info)) {
9880 + vx_update_load(vxi);
9881 + atomic_dec(&vxi->cvirt.nr_running);
9885 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9887 + struct vx_info *vxi;
9889 + if ((vxi = p->vx_info))
9890 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9893 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9895 + struct vx_info *vxi;
9897 + if ((vxi = p->vx_info))
9898 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9903 +#warning duplicate inclusion
9905 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_device.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_device.h
9906 --- linux-2.6.32.10/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9907 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_device.h 2009-12-03 20:04:56.000000000 +0100
9909 +#ifndef _VS_DEVICE_H
9910 +#define _VS_DEVICE_H
9912 +#include "vserver/base.h"
9913 +#include "vserver/device.h"
9914 +#include "vserver/debug.h"
9917 +#ifdef CONFIG_VSERVER_DEVICE
9919 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9921 +#define vs_device_perm(v, d, m, p) \
9922 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9927 +int vs_map_device(struct vx_info *vxi,
9928 + dev_t device, dev_t *target, umode_t mode)
9935 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9940 +#define vs_map_chrdev(d, t, p) \
9941 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9942 +#define vs_map_blkdev(d, t, p) \
9943 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9945 +#define vs_chrdev_perm(d, p) \
9946 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9947 +#define vs_blkdev_perm(d, p) \
9948 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9952 +#warning duplicate inclusion
9954 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_dlimit.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_dlimit.h
9955 --- linux-2.6.32.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9956 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_dlimit.h 2009-12-03 20:04:56.000000000 +0100
9958 +#ifndef _VS_DLIMIT_H
9959 +#define _VS_DLIMIT_H
9961 +#include <linux/fs.h>
9963 +#include "vserver/dlimit.h"
9964 +#include "vserver/base.h"
9965 +#include "vserver/debug.h"
9968 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9970 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9971 + const char *_file, int _line)
9975 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9976 + dli, dli ? dli->dl_tag : 0,
9977 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9979 + atomic_inc(&dli->dl_usecnt);
9984 +#define free_dl_info(i) \
9985 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9987 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9989 +static inline void __put_dl_info(struct dl_info *dli,
9990 + const char *_file, int _line)
9994 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9995 + dli, dli ? dli->dl_tag : 0,
9996 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9998 + if (atomic_dec_and_test(&dli->dl_usecnt))
9999 + free_dl_info(dli);
10003 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10005 +static inline int __dl_alloc_space(struct super_block *sb,
10006 + tag_t tag, dlsize_t nr, const char *file, int line)
10008 + struct dl_info *dli = NULL;
10013 + dli = locate_dl_info(sb, tag);
10017 + spin_lock(&dli->dl_lock);
10018 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10020 + dli->dl_space_used += nr;
10021 + spin_unlock(&dli->dl_lock);
10022 + put_dl_info(dli);
10024 + vxlprintk(VXD_CBIT(dlim, 1),
10025 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10026 + sb, tag, __dlimit_char(dli), (long long)nr,
10027 + ret, file, line);
10031 +static inline void __dl_free_space(struct super_block *sb,
10032 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10034 + struct dl_info *dli = NULL;
10038 + dli = locate_dl_info(sb, tag);
10042 + spin_lock(&dli->dl_lock);
10043 + if (dli->dl_space_used > nr)
10044 + dli->dl_space_used -= nr;
10046 + dli->dl_space_used = 0;
10047 + spin_unlock(&dli->dl_lock);
10048 + put_dl_info(dli);
10050 + vxlprintk(VXD_CBIT(dlim, 1),
10051 + "FREE (%p,#%d)%c %lld bytes",
10052 + sb, tag, __dlimit_char(dli), (long long)nr,
10056 +static inline int __dl_alloc_inode(struct super_block *sb,
10057 + tag_t tag, const char *_file, int _line)
10059 + struct dl_info *dli;
10062 + dli = locate_dl_info(sb, tag);
10066 + spin_lock(&dli->dl_lock);
10067 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
10069 + dli->dl_inodes_used++;
10070 + spin_unlock(&dli->dl_lock);
10071 + put_dl_info(dli);
10073 + vxlprintk(VXD_CBIT(dlim, 0),
10074 + "ALLOC (%p,#%d)%c inode (%d)",
10075 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10079 +static inline void __dl_free_inode(struct super_block *sb,
10080 + tag_t tag, const char *_file, int _line)
10082 + struct dl_info *dli;
10084 + dli = locate_dl_info(sb, tag);
10088 + spin_lock(&dli->dl_lock);
10089 + if (dli->dl_inodes_used > 1)
10090 + dli->dl_inodes_used--;
10092 + dli->dl_inodes_used = 0;
10093 + spin_unlock(&dli->dl_lock);
10094 + put_dl_info(dli);
10096 + vxlprintk(VXD_CBIT(dlim, 0),
10097 + "FREE (%p,#%d)%c inode",
10098 + sb, tag, __dlimit_char(dli), _file, _line);
10101 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10102 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10103 + const char *_file, int _line)
10105 + struct dl_info *dli;
10106 + uint64_t broot, bfree;
10108 + dli = locate_dl_info(sb, tag);
10112 + spin_lock(&dli->dl_lock);
10113 + broot = (dli->dl_space_total -
10114 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10115 + >> sb->s_blocksize_bits;
10116 + bfree = (dli->dl_space_total - dli->dl_space_used)
10117 + >> sb->s_blocksize_bits;
10118 + spin_unlock(&dli->dl_lock);
10120 + vxlprintk(VXD_CBIT(dlim, 2),
10121 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10122 + (long long)bfree, (long long)broot,
10123 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10125 + if (free_blocks) {
10126 + if (*free_blocks > bfree)
10127 + *free_blocks = bfree;
10129 + if (root_blocks) {
10130 + if (*root_blocks > broot)
10131 + *root_blocks = broot;
10133 + put_dl_info(dli);
10136 +#define dl_prealloc_space(in, bytes) \
10137 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10138 + __FILE__, __LINE__ )
10140 +#define dl_alloc_space(in, bytes) \
10141 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10142 + __FILE__, __LINE__ )
10144 +#define dl_reserve_space(in, bytes) \
10145 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10146 + __FILE__, __LINE__ )
10148 +#define dl_claim_space(in, bytes) (0)
10150 +#define dl_release_space(in, bytes) \
10151 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10152 + __FILE__, __LINE__ )
10154 +#define dl_free_space(in, bytes) \
10155 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10156 + __FILE__, __LINE__ )
10160 +#define dl_alloc_inode(in) \
10161 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10163 +#define dl_free_inode(in) \
10164 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10167 +#define dl_adjust_block(sb, tag, fb, rb) \
10168 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10172 +#warning duplicate inclusion
10174 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/base.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/base.h
10175 --- linux-2.6.32.10/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10176 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/base.h 2009-12-03 20:04:56.000000000 +0100
10178 +#ifndef _VX_BASE_H
10179 +#define _VX_BASE_H
10182 +/* context state changes */
10194 +#define vx_task_xid(t) ((t)->xid)
10196 +#define vx_current_xid() vx_task_xid(current)
10198 +#define current_vx_info() (current->vx_info)
10201 +#define nx_task_nid(t) ((t)->nid)
10203 +#define nx_current_nid() nx_task_nid(current)
10205 +#define current_nx_info() (current->nx_info)
10208 +/* generic flag merging */
10210 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10212 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10214 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10216 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10219 +/* context flags */
10221 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10223 +#define vx_current_flags() __vx_flags(current_vx_info())
10225 +#define vx_info_flags(v, m, f) \
10226 + vs_check_flags(__vx_flags(v), m, f)
10228 +#define task_vx_flags(t, m, f) \
10229 + ((t) && vx_info_flags((t)->vx_info, m, f))
10231 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10234 +/* context caps */
10236 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10238 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10240 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10242 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10246 +/* network flags */
10248 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10250 +#define nx_current_flags() __nx_flags(current_nx_info())
10252 +#define nx_info_flags(n, m, f) \
10253 + vs_check_flags(__nx_flags(n), m, f)
10255 +#define task_nx_flags(t, m, f) \
10256 + ((t) && nx_info_flags((t)->nx_info, m, f))
10258 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10261 +/* network caps */
10263 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10265 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10267 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10269 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10272 +/* context mask capabilities */
10274 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10276 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10278 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10281 +/* context bcap mask */
10283 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10285 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10288 +/* mask given bcaps */
10290 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10292 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10295 +/* masked cap_bset */
10297 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10299 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10302 +#define vx_info_mbcap(v, b) \
10303 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10304 + vx_info_bcaps(v, b) : (b))
10306 +#define task_vx_mbcap(t, b) \
10307 + vx_info_mbcap((t)->vx_info, (t)->b)
10309 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10312 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10314 +#define vx_capable(b, c) (capable(b) || \
10315 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10317 +#define nx_capable(b, c) (capable(b) || \
10318 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10320 +#define vx_task_initpid(t, n) \
10321 + ((t)->vx_info && \
10322 + ((t)->vx_info->vx_initpid == (n)))
10324 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10327 +/* context unshare mask */
10329 +#define __vx_umask(v) ((v)->vx_umask)
10331 +#define vx_current_umask() __vx_umask(current_vx_info())
10333 +#define vx_can_unshare(b, f) (capable(b) || \
10334 + (cap_raised(current_cap(), b) && \
10335 + !((f) & ~vx_current_umask())))
10338 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10340 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10343 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10345 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10348 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cacct_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct_cmd.h
10349 --- linux-2.6.32.10/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10350 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct_cmd.h 2009-12-03 20:04:56.000000000 +0100
10352 +#ifndef _VX_CACCT_CMD_H
10353 +#define _VX_CACCT_CMD_H
10356 +/* virtual host info name commands */
10358 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10360 +struct vcmd_sock_stat_v0 {
10362 + uint32_t count[3];
10363 + uint64_t total[3];
10369 +#include <linux/compiler.h>
10371 +extern int vc_sock_stat(struct vx_info *, void __user *);
10373 +#endif /* __KERNEL__ */
10374 +#endif /* _VX_CACCT_CMD_H */
10375 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cacct_def.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct_def.h
10376 --- linux-2.6.32.10/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10377 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct_def.h 2009-12-03 20:04:56.000000000 +0100
10379 +#ifndef _VX_CACCT_DEF_H
10380 +#define _VX_CACCT_DEF_H
10382 +#include <asm/atomic.h>
10383 +#include <linux/vserver/cacct.h>
10386 +struct _vx_sock_acc {
10387 + atomic_long_t count;
10388 + atomic_long_t total;
10391 +/* context sub struct */
10393 +struct _vx_cacct {
10394 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10395 + atomic_t slab[8];
10396 + atomic_t page[6][8];
10399 +#ifdef CONFIG_VSERVER_DEBUG
10401 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10405 + printk("\t_vx_cacct:");
10406 + for (i = 0; i < 6; i++) {
10407 + struct _vx_sock_acc *ptr = cacct->sock[i];
10409 + printk("\t [%d] =", i);
10410 + for (j = 0; j < 3; j++) {
10411 + printk(" [%d] = %8lu, %8lu", j,
10412 + atomic_long_read(&ptr[j].count),
10413 + atomic_long_read(&ptr[j].total));
10421 +#endif /* _VX_CACCT_DEF_H */
10422 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cacct.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct.h
10423 --- linux-2.6.32.10/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10424 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct.h 2009-12-03 20:04:56.000000000 +0100
10426 +#ifndef _VX_CACCT_H
10427 +#define _VX_CACCT_H
10430 +enum sock_acc_field {
10431 + VXA_SOCK_UNSPEC = 0,
10437 + VXA_SOCK_SIZE /* array size */
10440 +#endif /* _VX_CACCT_H */
10441 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cacct_int.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct_int.h
10442 --- linux-2.6.32.10/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10443 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cacct_int.h 2009-12-03 20:04:56.000000000 +0100
10445 +#ifndef _VX_CACCT_INT_H
10446 +#define _VX_CACCT_INT_H
10452 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10454 + return atomic_long_read(&cacct->sock[type][pos].count);
10459 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10461 + return atomic_long_read(&cacct->sock[type][pos].total);
10464 +#endif /* __KERNEL__ */
10465 +#endif /* _VX_CACCT_INT_H */
10466 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/check.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/check.h
10467 --- linux-2.6.32.10/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10468 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/check.h 2009-12-03 20:04:56.000000000 +0100
10470 +#ifndef _VS_CHECK_H
10471 +#define _VS_CHECK_H
10474 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10476 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10477 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10479 +#define MIN_D_CONTEXT 65536
10482 +/* check conditions */
10484 +#define VS_ADMIN 0x0001
10485 +#define VS_WATCH 0x0002
10486 +#define VS_HIDE 0x0004
10487 +#define VS_HOSTID 0x0008
10489 +#define VS_IDENT 0x0010
10490 +#define VS_EQUIV 0x0020
10491 +#define VS_PARENT 0x0040
10492 +#define VS_CHILD 0x0080
10494 +#define VS_ARG_MASK 0x00F0
10496 +#define VS_DYNAMIC 0x0100
10497 +#define VS_STATIC 0x0200
10499 +#define VS_ATR_MASK 0x0F00
10501 +#ifdef CONFIG_VSERVER_PRIVACY
10502 +#define VS_ADMIN_P (0)
10503 +#define VS_WATCH_P (0)
10505 +#define VS_ADMIN_P VS_ADMIN
10506 +#define VS_WATCH_P VS_WATCH
10509 +#define VS_HARDIRQ 0x1000
10510 +#define VS_SOFTIRQ 0x2000
10511 +#define VS_IRQ 0x4000
10513 +#define VS_IRQ_MASK 0xF000
10515 +#include <linux/hardirq.h>
10518 + * check current context for ADMIN/WATCH and
10519 + * optionally against supplied argument
10521 +static inline int __vs_check(int cid, int id, unsigned int mode)
10523 + if (mode & VS_ARG_MASK) {
10524 + if ((mode & VS_IDENT) && (id == cid))
10527 + if (mode & VS_ATR_MASK) {
10528 + if ((mode & VS_DYNAMIC) &&
10529 + (id >= MIN_D_CONTEXT) &&
10530 + (id <= MAX_S_CONTEXT))
10532 + if ((mode & VS_STATIC) &&
10533 + (id > 1) && (id < MIN_D_CONTEXT))
10536 + if (mode & VS_IRQ_MASK) {
10537 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10539 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10541 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10544 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10545 + ((mode & VS_WATCH) && (cid == 1)) ||
10546 + ((mode & VS_HOSTID) && (id == 0)));
10549 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10551 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10554 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10556 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10559 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/context_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/context_cmd.h
10560 --- linux-2.6.32.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10561 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/context_cmd.h 2009-12-03 20:04:56.000000000 +0100
10563 +#ifndef _VX_CONTEXT_CMD_H
10564 +#define _VX_CONTEXT_CMD_H
10567 +/* vinfo commands */
10569 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10572 +extern int vc_task_xid(uint32_t);
10574 +#endif /* __KERNEL__ */
10576 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10578 +struct vcmd_vx_info_v0 {
10580 + uint32_t initpid;
10581 + /* more to come */
10585 +extern int vc_vx_info(struct vx_info *, void __user *);
10587 +#endif /* __KERNEL__ */
10589 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10591 +struct vcmd_ctx_stat_v0 {
10594 + /* more to come */
10598 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10600 +#endif /* __KERNEL__ */
10602 +/* context commands */
10604 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10605 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10607 +struct vcmd_ctx_create {
10608 + uint64_t flagword;
10611 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10612 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10614 +struct vcmd_ctx_migrate {
10615 + uint64_t flagword;
10619 +extern int vc_ctx_create(uint32_t, void __user *);
10620 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10622 +#endif /* __KERNEL__ */
10625 +/* flag commands */
10627 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10628 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10630 +struct vcmd_ctx_flags_v0 {
10631 + uint64_t flagword;
10636 +extern int vc_get_cflags(struct vx_info *, void __user *);
10637 +extern int vc_set_cflags(struct vx_info *, void __user *);
10639 +#endif /* __KERNEL__ */
10642 +/* context caps commands */
10644 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10645 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10647 +struct vcmd_ctx_caps_v1 {
10653 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10654 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10656 +#endif /* __KERNEL__ */
10659 +/* bcaps commands */
10661 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10662 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10664 +struct vcmd_bcaps {
10670 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10671 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10673 +#endif /* __KERNEL__ */
10676 +/* umask commands */
10678 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10679 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10681 +struct vcmd_umask {
10687 +extern int vc_get_umask(struct vx_info *, void __user *);
10688 +extern int vc_set_umask(struct vx_info *, void __user *);
10690 +#endif /* __KERNEL__ */
10695 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10696 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10698 +struct vcmd_badness_v0 {
10703 +extern int vc_get_badness(struct vx_info *, void __user *);
10704 +extern int vc_set_badness(struct vx_info *, void __user *);
10706 +#endif /* __KERNEL__ */
10707 +#endif /* _VX_CONTEXT_CMD_H */
10708 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/context.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/context.h
10709 --- linux-2.6.32.10/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10710 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/context.h 2010-03-13 21:50:00.000000000 +0100
10712 +#ifndef _VX_CONTEXT_H
10713 +#define _VX_CONTEXT_H
10715 +#include <linux/types.h>
10716 +#include <linux/capability.h>
10719 +/* context flags */
10721 +#define VXF_INFO_SCHED 0x00000002
10722 +#define VXF_INFO_NPROC 0x00000004
10723 +#define VXF_INFO_PRIVATE 0x00000008
10725 +#define VXF_INFO_INIT 0x00000010
10726 +#define VXF_INFO_HIDE 0x00000020
10727 +#define VXF_INFO_ULIMIT 0x00000040
10728 +#define VXF_INFO_NSPACE 0x00000080
10730 +#define VXF_SCHED_HARD 0x00000100
10731 +#define VXF_SCHED_PRIO 0x00000200
10732 +#define VXF_SCHED_PAUSE 0x00000400
10734 +#define VXF_VIRT_MEM 0x00010000
10735 +#define VXF_VIRT_UPTIME 0x00020000
10736 +#define VXF_VIRT_CPU 0x00040000
10737 +#define VXF_VIRT_LOAD 0x00080000
10738 +#define VXF_VIRT_TIME 0x00100000
10740 +#define VXF_HIDE_MOUNT 0x01000000
10741 +/* was VXF_HIDE_NETIF 0x02000000 */
10742 +#define VXF_HIDE_VINFO 0x04000000
10744 +#define VXF_STATE_SETUP (1ULL << 32)
10745 +#define VXF_STATE_INIT (1ULL << 33)
10746 +#define VXF_STATE_ADMIN (1ULL << 34)
10748 +#define VXF_SC_HELPER (1ULL << 36)
10749 +#define VXF_REBOOT_KILL (1ULL << 37)
10750 +#define VXF_PERSISTENT (1ULL << 38)
10752 +#define VXF_FORK_RSS (1ULL << 48)
10753 +#define VXF_PROLIFIC (1ULL << 49)
10755 +#define VXF_IGNEG_NICE (1ULL << 52)
10757 +#define VXF_ONE_TIME (0x0007ULL << 32)
10759 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10762 +/* context migration */
10764 +#define VXM_SET_INIT 0x00000001
10765 +#define VXM_SET_REAPER 0x00000002
10767 +/* context caps */
10769 +#define VXC_CAP_MASK 0x00000000
10771 +#define VXC_SET_UTSNAME 0x00000001
10772 +#define VXC_SET_RLIMIT 0x00000002
10773 +#define VXC_FS_SECURITY 0x00000004
10774 +#define VXC_FS_TRUSTED 0x00000008
10775 +#define VXC_TIOCSTI 0x00000010
10777 +/* was VXC_RAW_ICMP 0x00000100 */
10778 +#define VXC_SYSLOG 0x00001000
10779 +#define VXC_OOM_ADJUST 0x00002000
10780 +#define VXC_AUDIT_CONTROL 0x00004000
10782 +#define VXC_SECURE_MOUNT 0x00010000
10783 +#define VXC_SECURE_REMOUNT 0x00020000
10784 +#define VXC_BINARY_MOUNT 0x00040000
10786 +#define VXC_QUOTA_CTL 0x00100000
10787 +#define VXC_ADMIN_MAPPER 0x00200000
10788 +#define VXC_ADMIN_CLOOP 0x00400000
10790 +#define VXC_KTHREAD 0x01000000
10791 +#define VXC_NAMESPACE 0x02000000
10796 +#include <linux/list.h>
10797 +#include <linux/spinlock.h>
10798 +#include <linux/rcupdate.h>
10800 +#include "limit_def.h"
10801 +#include "sched_def.h"
10802 +#include "cvirt_def.h"
10803 +#include "cacct_def.h"
10804 +#include "device_def.h"
10806 +#define VX_SPACES 2
10808 +struct _vx_info_pc {
10809 + struct _vx_sched_pc sched_pc;
10810 + struct _vx_cvirt_pc cvirt_pc;
10814 + struct hlist_node vx_hlist; /* linked list of contexts */
10815 + xid_t vx_id; /* context id */
10816 + atomic_t vx_usecnt; /* usage count */
10817 + atomic_t vx_tasks; /* tasks count */
10818 + struct vx_info *vx_parent; /* parent context */
10819 + int vx_state; /* context state */
10821 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10822 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10823 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
10825 + uint64_t vx_flags; /* context flags */
10826 + uint64_t vx_ccaps; /* context caps (vserver) */
10827 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10828 + unsigned long vx_umask; /* unshare mask (guest) */
10830 + struct task_struct *vx_reaper; /* guest reaper process */
10831 + pid_t vx_initpid; /* PID of guest init */
10832 + int64_t vx_badness_bias; /* OOM points bias */
10834 + struct _vx_limit limit; /* vserver limits */
10835 + struct _vx_sched sched; /* vserver scheduler */
10836 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10837 + struct _vx_cacct cacct; /* context accounting */
10839 + struct _vx_device dmap; /* default device map targets */
10841 +#ifndef CONFIG_SMP
10842 + struct _vx_info_pc info_pc; /* per cpu data */
10844 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10847 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10848 + int reboot_cmd; /* last sys_reboot() cmd */
10849 + int exit_code; /* last process exit code */
10851 + char vx_name[65]; /* vserver name */
10854 +#ifndef CONFIG_SMP
10855 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10856 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10858 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10859 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10862 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10865 +struct vx_info_save {
10866 + struct vx_info *vxi;
10871 +/* status flags */
10873 +#define VXS_HASHED 0x0001
10874 +#define VXS_PAUSED 0x0010
10875 +#define VXS_SHUTDOWN 0x0100
10876 +#define VXS_HELPER 0x1000
10877 +#define VXS_RELEASED 0x8000
10880 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10881 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10883 +extern struct vx_info *lookup_vx_info(int);
10884 +extern struct vx_info *lookup_or_create_vx_info(int);
10886 +extern int get_xid_list(int, unsigned int *, int);
10887 +extern int xid_is_hashed(xid_t);
10889 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10891 +extern long vs_state_change(struct vx_info *, unsigned int);
10894 +#endif /* __KERNEL__ */
10895 +#endif /* _VX_CONTEXT_H */
10896 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cvirt_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cvirt_cmd.h
10897 --- linux-2.6.32.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10898 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cvirt_cmd.h 2009-12-03 20:04:56.000000000 +0100
10900 +#ifndef _VX_CVIRT_CMD_H
10901 +#define _VX_CVIRT_CMD_H
10904 +/* virtual host info name commands */
10906 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10907 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10909 +struct vcmd_vhi_name_v0 {
10915 +enum vhi_name_field {
10916 + VHIN_CONTEXT = 0,
10928 +#include <linux/compiler.h>
10930 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10931 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10933 +#endif /* __KERNEL__ */
10935 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10937 +struct vcmd_virt_stat_v0 {
10940 + uint32_t nr_threads;
10941 + uint32_t nr_running;
10942 + uint32_t nr_uninterruptible;
10943 + uint32_t nr_onhold;
10944 + uint32_t nr_forks;
10945 + uint32_t load[3];
10949 +extern int vc_virt_stat(struct vx_info *, void __user *);
10951 +#endif /* __KERNEL__ */
10952 +#endif /* _VX_CVIRT_CMD_H */
10953 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cvirt_def.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cvirt_def.h
10954 --- linux-2.6.32.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10955 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cvirt_def.h 2009-12-03 20:04:56.000000000 +0100
10957 +#ifndef _VX_CVIRT_DEF_H
10958 +#define _VX_CVIRT_DEF_H
10960 +#include <linux/jiffies.h>
10961 +#include <linux/spinlock.h>
10962 +#include <linux/wait.h>
10963 +#include <linux/time.h>
10964 +#include <asm/atomic.h>
10967 +struct _vx_usage_stat {
10971 + uint64_t softirq;
10977 +struct _vx_syslog {
10978 + wait_queue_head_t log_wait;
10979 + spinlock_t logbuf_lock; /* lock for the log buffer */
10981 + unsigned long log_start; /* next char to be read by syslog() */
10982 + unsigned long con_start; /* next char to be sent to consoles */
10983 + unsigned long log_end; /* most-recently-written-char + 1 */
10984 + unsigned long logged_chars; /* #chars since last read+clear operation */
10986 + char log_buf[1024];
10990 +/* context sub struct */
10992 +struct _vx_cvirt {
10993 + atomic_t nr_threads; /* number of current threads */
10994 + atomic_t nr_running; /* number of running threads */
10995 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10997 + atomic_t nr_onhold; /* processes on hold */
10998 + uint32_t onhold_last; /* jiffies when put on hold */
11000 + struct timeval bias_tv; /* time offset to the host */
11001 + struct timespec bias_idle;
11002 + struct timespec bias_uptime; /* context creation point */
11003 + uint64_t bias_clock; /* offset in clock_t */
11005 + spinlock_t load_lock; /* lock for the load averages */
11006 + atomic_t load_updates; /* nr of load updates done so far */
11007 + uint32_t load_last; /* last time load was calculated */
11008 + uint32_t load[3]; /* load averages 1,5,15 */
11010 + atomic_t total_forks; /* number of forks so far */
11012 + struct _vx_syslog syslog;
11015 +struct _vx_cvirt_pc {
11016 + struct _vx_usage_stat cpustat;
11020 +#ifdef CONFIG_VSERVER_DEBUG
11022 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11024 + printk("\t_vx_cvirt:\n");
11025 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11026 + atomic_read(&cvirt->nr_threads),
11027 + atomic_read(&cvirt->nr_running),
11028 + atomic_read(&cvirt->nr_uninterruptible),
11029 + atomic_read(&cvirt->nr_onhold));
11030 + /* add rest here */
11031 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11036 +#endif /* _VX_CVIRT_DEF_H */
11037 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/cvirt.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cvirt.h
11038 --- linux-2.6.32.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11039 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/cvirt.h 2009-12-03 20:04:56.000000000 +0100
11041 +#ifndef _VX_CVIRT_H
11042 +#define _VX_CVIRT_H
11049 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11054 +void vx_update_load(struct vx_info *);
11057 +int vx_do_syslog(int, char __user *, int);
11059 +#endif /* __KERNEL__ */
11060 +#endif /* _VX_CVIRT_H */
11061 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/debug_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/debug_cmd.h
11062 --- linux-2.6.32.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11063 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/debug_cmd.h 2009-12-03 20:04:56.000000000 +0100
11065 +#ifndef _VX_DEBUG_CMD_H
11066 +#define _VX_DEBUG_CMD_H
11069 +/* debug commands */
11071 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11073 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11074 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11076 +struct vcmd_read_history_v0 {
11079 + char __user *data;
11082 +struct vcmd_read_monitor_v0 {
11085 + char __user *data;
11091 +#ifdef CONFIG_COMPAT
11093 +#include <asm/compat.h>
11095 +struct vcmd_read_history_v0_x32 {
11098 + compat_uptr_t data_ptr;
11101 +struct vcmd_read_monitor_v0_x32 {
11104 + compat_uptr_t data_ptr;
11107 +#endif /* CONFIG_COMPAT */
11109 +extern int vc_dump_history(uint32_t);
11111 +extern int vc_read_history(uint32_t, void __user *);
11112 +extern int vc_read_monitor(uint32_t, void __user *);
11114 +#ifdef CONFIG_COMPAT
11116 +extern int vc_read_history_x32(uint32_t, void __user *);
11117 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11119 +#endif /* CONFIG_COMPAT */
11121 +#endif /* __KERNEL__ */
11122 +#endif /* _VX_DEBUG_CMD_H */
11123 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/debug.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/debug.h
11124 --- linux-2.6.32.10/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11125 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/debug.h 2009-12-03 20:04:56.000000000 +0100
11127 +#ifndef _VX_DEBUG_H
11128 +#define _VX_DEBUG_H
11131 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11132 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11133 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11135 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11136 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11137 +#define VXF_DEV "%p[%lu,%d:%d]"
11140 +#define vxd_path(p) \
11141 + ({ static char _buffer[PATH_MAX]; \
11142 + d_path(p, _buffer, sizeof(_buffer)); })
11144 +#define vxd_cond_path(n) \
11145 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11148 +#ifdef CONFIG_VSERVER_DEBUG
11150 +extern unsigned int vx_debug_switch;
11151 +extern unsigned int vx_debug_xid;
11152 +extern unsigned int vx_debug_nid;
11153 +extern unsigned int vx_debug_tag;
11154 +extern unsigned int vx_debug_net;
11155 +extern unsigned int vx_debug_limit;
11156 +extern unsigned int vx_debug_cres;
11157 +extern unsigned int vx_debug_dlim;
11158 +extern unsigned int vx_debug_quota;
11159 +extern unsigned int vx_debug_cvirt;
11160 +extern unsigned int vx_debug_space;
11161 +extern unsigned int vx_debug_misc;
11164 +#define VX_LOGLEVEL "vxD: "
11165 +#define VX_PROC_FMT "%p: "
11166 +#define VX_PROCESS current
11168 +#define vxdprintk(c, f, x...) \
11171 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11172 + VX_PROCESS , ##x); \
11175 +#define vxlprintk(c, f, x...) \
11178 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11181 +#define vxfprintk(c, f, x...) \
11184 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11190 +void dump_vx_info(struct vx_info *, int);
11191 +void dump_vx_info_inactive(int);
11193 +#else /* CONFIG_VSERVER_DEBUG */
11195 +#define vx_debug_switch 0
11196 +#define vx_debug_xid 0
11197 +#define vx_debug_nid 0
11198 +#define vx_debug_tag 0
11199 +#define vx_debug_net 0
11200 +#define vx_debug_limit 0
11201 +#define vx_debug_cres 0
11202 +#define vx_debug_dlim 0
11203 +#define vx_debug_cvirt 0
11205 +#define vxdprintk(x...) do { } while (0)
11206 +#define vxlprintk(x...) do { } while (0)
11207 +#define vxfprintk(x...) do { } while (0)
11209 +#endif /* CONFIG_VSERVER_DEBUG */
11212 +#ifdef CONFIG_VSERVER_WARN
11214 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11215 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11216 +#define VX_WARN_XID "[xid #%u] "
11217 +#define VX_WARN_NID "[nid #%u] "
11218 +#define VX_WARN_TAG "[tag #%u] "
11220 +#define vxwprintk(c, f, x...) \
11223 + printk(VX_WARNLEVEL f "\n", ##x); \
11226 +#else /* CONFIG_VSERVER_WARN */
11228 +#define vxwprintk(x...) do { } while (0)
11230 +#endif /* CONFIG_VSERVER_WARN */
11232 +#define vxwprintk_task(c, f, x...) \
11233 + vxwprintk(c, VX_WARN_TASK f, \
11234 + current->comm, current->pid, \
11235 + current->xid, current->nid, current->tag, ##x)
11236 +#define vxwprintk_xid(c, f, x...) \
11237 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11238 +#define vxwprintk_nid(c, f, x...) \
11239 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11240 +#define vxwprintk_tag(c, f, x...) \
11241 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11243 +#ifdef CONFIG_VSERVER_DEBUG
11244 +#define vxd_assert_lock(l) assert_spin_locked(l)
11245 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11246 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11248 +#define vxd_assert_lock(l) do { } while (0)
11249 +#define vxd_assert(c, f, x...) do { } while (0)
11253 +#endif /* _VX_DEBUG_H */
11254 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/device_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/device_cmd.h
11255 --- linux-2.6.32.10/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11256 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/device_cmd.h 2009-12-03 20:04:56.000000000 +0100
11258 +#ifndef _VX_DEVICE_CMD_H
11259 +#define _VX_DEVICE_CMD_H
11262 +/* device vserver commands */
11264 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11265 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11267 +struct vcmd_set_mapping_v0 {
11268 + const char __user *device;
11269 + const char __user *target;
11276 +#ifdef CONFIG_COMPAT
11278 +#include <asm/compat.h>
11280 +struct vcmd_set_mapping_v0_x32 {
11281 + compat_uptr_t device_ptr;
11282 + compat_uptr_t target_ptr;
11286 +#endif /* CONFIG_COMPAT */
11288 +#include <linux/compiler.h>
11290 +extern int vc_set_mapping(struct vx_info *, void __user *);
11291 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11293 +#ifdef CONFIG_COMPAT
11295 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11296 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11298 +#endif /* CONFIG_COMPAT */
11300 +#endif /* __KERNEL__ */
11301 +#endif /* _VX_DEVICE_CMD_H */
11302 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/device_def.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/device_def.h
11303 --- linux-2.6.32.10/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11304 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/device_def.h 2009-12-03 20:04:56.000000000 +0100
11306 +#ifndef _VX_DEVICE_DEF_H
11307 +#define _VX_DEVICE_DEF_H
11309 +#include <linux/types.h>
11311 +struct vx_dmap_target {
11316 +struct _vx_device {
11317 +#ifdef CONFIG_VSERVER_DEVICE
11318 + struct vx_dmap_target targets[2];
11322 +#endif /* _VX_DEVICE_DEF_H */
11323 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/device.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/device.h
11324 --- linux-2.6.32.10/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11325 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/device.h 2009-12-03 20:04:56.000000000 +0100
11327 +#ifndef _VX_DEVICE_H
11328 +#define _VX_DEVICE_H
11331 +#define DATTR_CREATE 0x00000001
11332 +#define DATTR_OPEN 0x00000002
11334 +#define DATTR_REMAP 0x00000010
11336 +#define DATTR_MASK 0x00000013
11339 +#else /* _VX_DEVICE_H */
11340 +#warning duplicate inclusion
11341 +#endif /* _VX_DEVICE_H */
11342 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/dlimit_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/dlimit_cmd.h
11343 --- linux-2.6.32.10/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11344 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/dlimit_cmd.h 2009-12-10 16:43:43.000000000 +0100
11346 +#ifndef _VX_DLIMIT_CMD_H
11347 +#define _VX_DLIMIT_CMD_H
11350 +/* dlimit vserver commands */
11352 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11353 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11355 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11356 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11358 +struct vcmd_ctx_dlimit_base_v0 {
11359 + const char __user *name;
11363 +struct vcmd_ctx_dlimit_v0 {
11364 + const char __user *name;
11365 + uint32_t space_used; /* used space in kbytes */
11366 + uint32_t space_total; /* maximum space in kbytes */
11367 + uint32_t inodes_used; /* used inodes */
11368 + uint32_t inodes_total; /* maximum inodes */
11369 + uint32_t reserved; /* reserved for root in % */
11373 +#define CDLIM_UNSET ((uint32_t)0UL)
11374 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11375 +#define CDLIM_KEEP ((uint32_t)~1UL)
11377 +#define DLIME_UNIT 0
11378 +#define DLIME_KILO 1
11379 +#define DLIME_MEGA 2
11380 +#define DLIME_GIGA 3
11382 +#define DLIMF_SHIFT 0x10
11384 +#define DLIMS_USED 0
11385 +#define DLIMS_TOTAL 2
11388 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11390 + int exp = (flags & DLIMF_SHIFT) ?
11391 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11392 + return ((uint64_t)val) << (10 * exp);
11396 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11400 + if (*flags & DLIMF_SHIFT) {
11401 + while (val > (1LL << 32) && (exp < 3)) {
11405 + *flags &= ~(DLIME_GIGA << shift);
11406 + *flags |= exp << shift;
11414 +#ifdef CONFIG_COMPAT
11416 +#include <asm/compat.h>
11418 +struct vcmd_ctx_dlimit_base_v0_x32 {
11419 + compat_uptr_t name_ptr;
11423 +struct vcmd_ctx_dlimit_v0_x32 {
11424 + compat_uptr_t name_ptr;
11425 + uint32_t space_used; /* used space in kbytes */
11426 + uint32_t space_total; /* maximum space in kbytes */
11427 + uint32_t inodes_used; /* used inodes */
11428 + uint32_t inodes_total; /* maximum inodes */
11429 + uint32_t reserved; /* reserved for root in % */
11433 +#endif /* CONFIG_COMPAT */
11435 +#include <linux/compiler.h>
11437 +extern int vc_add_dlimit(uint32_t, void __user *);
11438 +extern int vc_rem_dlimit(uint32_t, void __user *);
11440 +extern int vc_set_dlimit(uint32_t, void __user *);
11441 +extern int vc_get_dlimit(uint32_t, void __user *);
11443 +#ifdef CONFIG_COMPAT
11445 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11446 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11448 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11449 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11451 +#endif /* CONFIG_COMPAT */
11453 +#endif /* __KERNEL__ */
11454 +#endif /* _VX_DLIMIT_CMD_H */
11455 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/dlimit.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/dlimit.h
11456 --- linux-2.6.32.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11457 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/dlimit.h 2009-12-03 20:04:56.000000000 +0100
11459 +#ifndef _VX_DLIMIT_H
11460 +#define _VX_DLIMIT_H
11462 +#include "switch.h"
11467 +/* keep in sync with CDLIM_INFINITY */
11469 +#define DLIM_INFINITY (~0ULL)
11471 +#include <linux/spinlock.h>
11472 +#include <linux/rcupdate.h>
11474 +struct super_block;
11477 + struct hlist_node dl_hlist; /* linked list of contexts */
11478 + struct rcu_head dl_rcu; /* the rcu head */
11479 + tag_t dl_tag; /* context tag */
11480 + atomic_t dl_usecnt; /* usage count */
11481 + atomic_t dl_refcnt; /* reference count */
11483 + struct super_block *dl_sb; /* associated superblock */
11485 + spinlock_t dl_lock; /* protect the values */
11487 + unsigned long long dl_space_used; /* used space in bytes */
11488 + unsigned long long dl_space_total; /* maximum space in bytes */
11489 + unsigned long dl_inodes_used; /* used inodes */
11490 + unsigned long dl_inodes_total; /* maximum inodes */
11492 + unsigned int dl_nrlmult; /* non root limit mult */
11497 +extern void rcu_free_dl_info(struct rcu_head *);
11498 +extern void unhash_dl_info(struct dl_info *);
11500 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11505 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11507 +typedef uint64_t dlsize_t;
11509 +#endif /* __KERNEL__ */
11510 +#else /* _VX_DLIMIT_H */
11511 +#warning duplicate inclusion
11512 +#endif /* _VX_DLIMIT_H */
11513 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/global.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/global.h
11514 --- linux-2.6.32.10/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11515 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/global.h 2009-12-03 20:04:56.000000000 +0100
11517 +#ifndef _VX_GLOBAL_H
11518 +#define _VX_GLOBAL_H
11521 +extern atomic_t vx_global_ctotal;
11522 +extern atomic_t vx_global_cactive;
11524 +extern atomic_t nx_global_ctotal;
11525 +extern atomic_t nx_global_cactive;
11527 +extern atomic_t vs_global_nsproxy;
11528 +extern atomic_t vs_global_fs;
11529 +extern atomic_t vs_global_mnt_ns;
11530 +extern atomic_t vs_global_uts_ns;
11531 +extern atomic_t vs_global_user_ns;
11532 +extern atomic_t vs_global_pid_ns;
11535 +#endif /* _VX_GLOBAL_H */
11536 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/history.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/history.h
11537 --- linux-2.6.32.10/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11538 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/history.h 2009-12-03 20:04:56.000000000 +0100
11540 +#ifndef _VX_HISTORY_H
11541 +#define _VX_HISTORY_H
11546 + VXH_THROW_OOPS = 1,
11550 + VXH_INIT_VX_INFO,
11553 + VXH_CLAIM_VX_INFO,
11554 + VXH_RELEASE_VX_INFO,
11555 + VXH_ALLOC_VX_INFO,
11556 + VXH_DEALLOC_VX_INFO,
11557 + VXH_HASH_VX_INFO,
11558 + VXH_UNHASH_VX_INFO,
11560 + VXH_LOOKUP_VX_INFO,
11561 + VXH_CREATE_VX_INFO,
11564 +struct _vxhe_vxi {
11565 + struct vx_info *ptr;
11571 +struct _vxhe_set_clr {
11575 +struct _vxhe_loc_lookup {
11579 +struct _vx_hist_entry {
11581 + unsigned short seq;
11582 + unsigned short type;
11583 + struct _vxhe_vxi vxi;
11585 + struct _vxhe_set_clr sc;
11586 + struct _vxhe_loc_lookup ll;
11590 +#ifdef CONFIG_VSERVER_HISTORY
11592 +extern unsigned volatile int vxh_active;
11594 +struct _vx_hist_entry *vxh_advance(void *loc);
11598 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11600 + entry->vxi.ptr = vxi;
11602 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11603 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11604 + entry->vxi.xid = vxi->vx_id;
11609 +#define __HERE__ current_text_addr()
11611 +#define __VXH_BODY(__type, __data, __here) \
11612 + struct _vx_hist_entry *entry; \
11614 + preempt_disable(); \
11615 + entry = vxh_advance(__here); \
11617 + entry->type = __type; \
11618 + preempt_enable();
11621 + /* pass vxi only */
11623 +#define __VXH_SMPL \
11624 + __vxh_copy_vxi(entry, vxi)
11627 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11629 + __VXH_BODY(__type, __VXH_SMPL, __here)
11632 + /* pass vxi and data (void *) */
11634 +#define __VXH_DATA \
11635 + __vxh_copy_vxi(entry, vxi); \
11636 + entry->sc.data = data
11639 +void __vxh_data(struct vx_info *vxi, void *data,
11640 + int __type, void *__here)
11642 + __VXH_BODY(__type, __VXH_DATA, __here)
11645 + /* pass vxi and arg (long) */
11647 +#define __VXH_LONG \
11648 + __vxh_copy_vxi(entry, vxi); \
11649 + entry->ll.arg = arg
11652 +void __vxh_long(struct vx_info *vxi, long arg,
11653 + int __type, void *__here)
11655 + __VXH_BODY(__type, __VXH_LONG, __here)
11660 +void __vxh_throw_oops(void *__here)
11662 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11663 + /* prevent further acquisition */
11668 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11670 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11671 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11673 +#define __vxh_init_vx_info(v, d, h) \
11674 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11675 +#define __vxh_set_vx_info(v, d, h) \
11676 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11677 +#define __vxh_clr_vx_info(v, d, h) \
11678 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11680 +#define __vxh_claim_vx_info(v, d, h) \
11681 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11682 +#define __vxh_release_vx_info(v, d, h) \
11683 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11685 +#define vxh_alloc_vx_info(v) \
11686 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11687 +#define vxh_dealloc_vx_info(v) \
11688 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11690 +#define vxh_hash_vx_info(v) \
11691 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11692 +#define vxh_unhash_vx_info(v) \
11693 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11695 +#define vxh_loc_vx_info(v, l) \
11696 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11697 +#define vxh_lookup_vx_info(v, l) \
11698 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11699 +#define vxh_create_vx_info(v, l) \
11700 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11702 +extern void vxh_dump_history(void);
11705 +#else /* CONFIG_VSERVER_HISTORY */
11707 +#define __HERE__ 0
11709 +#define vxh_throw_oops() do { } while (0)
11711 +#define __vxh_get_vx_info(v, h) do { } while (0)
11712 +#define __vxh_put_vx_info(v, h) do { } while (0)
11714 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11715 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11716 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11718 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11719 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11721 +#define vxh_alloc_vx_info(v) do { } while (0)
11722 +#define vxh_dealloc_vx_info(v) do { } while (0)
11724 +#define vxh_hash_vx_info(v) do { } while (0)
11725 +#define vxh_unhash_vx_info(v) do { } while (0)
11727 +#define vxh_loc_vx_info(v, l) do { } while (0)
11728 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11729 +#define vxh_create_vx_info(v, l) do { } while (0)
11731 +#define vxh_dump_history() do { } while (0)
11734 +#endif /* CONFIG_VSERVER_HISTORY */
11736 +#endif /* _VX_HISTORY_H */
11737 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/inode_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/inode_cmd.h
11738 --- linux-2.6.32.10/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11739 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/inode_cmd.h 2009-12-03 20:04:56.000000000 +0100
11741 +#ifndef _VX_INODE_CMD_H
11742 +#define _VX_INODE_CMD_H
11745 +/* inode vserver commands */
11747 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11748 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11750 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11751 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11753 +struct vcmd_ctx_iattr_v1 {
11754 + const char __user *name;
11760 +struct vcmd_ctx_fiattr_v0 {
11770 +#ifdef CONFIG_COMPAT
11772 +#include <asm/compat.h>
11774 +struct vcmd_ctx_iattr_v1_x32 {
11775 + compat_uptr_t name_ptr;
11781 +#endif /* CONFIG_COMPAT */
11783 +#include <linux/compiler.h>
11785 +extern int vc_get_iattr(void __user *);
11786 +extern int vc_set_iattr(void __user *);
11788 +extern int vc_fget_iattr(uint32_t, void __user *);
11789 +extern int vc_fset_iattr(uint32_t, void __user *);
11791 +#ifdef CONFIG_COMPAT
11793 +extern int vc_get_iattr_x32(void __user *);
11794 +extern int vc_set_iattr_x32(void __user *);
11796 +#endif /* CONFIG_COMPAT */
11798 +#endif /* __KERNEL__ */
11799 +#endif /* _VX_INODE_CMD_H */
11800 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/inode.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/inode.h
11801 --- linux-2.6.32.10/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11802 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/inode.h 2009-12-03 20:04:56.000000000 +0100
11804 +#ifndef _VX_INODE_H
11805 +#define _VX_INODE_H
11808 +#define IATTR_TAG 0x01000000
11810 +#define IATTR_ADMIN 0x00000001
11811 +#define IATTR_WATCH 0x00000002
11812 +#define IATTR_HIDE 0x00000004
11813 +#define IATTR_FLAGS 0x00000007
11815 +#define IATTR_BARRIER 0x00010000
11816 +#define IATTR_IXUNLINK 0x00020000
11817 +#define IATTR_IMMUTABLE 0x00040000
11818 +#define IATTR_COW 0x00080000
11823 +#ifdef CONFIG_VSERVER_PROC_SECURE
11824 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11825 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11827 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11828 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11831 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11833 +#endif /* __KERNEL__ */
11835 +/* inode ioctls */
11837 +#define FIOC_GETXFLG _IOR('x', 5, long)
11838 +#define FIOC_SETXFLG _IOW('x', 6, long)
11840 +#else /* _VX_INODE_H */
11841 +#warning duplicate inclusion
11842 +#endif /* _VX_INODE_H */
11843 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/Kbuild linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/Kbuild
11844 --- linux-2.6.32.10/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11845 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/Kbuild 2009-12-03 20:04:56.000000000 +0100
11848 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11849 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11850 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11851 + debug_cmd.h device_cmd.h
11853 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11855 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/limit_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit_cmd.h
11856 --- linux-2.6.32.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11857 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit_cmd.h 2009-12-03 20:04:56.000000000 +0100
11859 +#ifndef _VX_LIMIT_CMD_H
11860 +#define _VX_LIMIT_CMD_H
11863 +/* rlimit vserver commands */
11865 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11866 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11867 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11868 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
11869 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11871 +struct vcmd_ctx_rlimit_v0 {
11873 + uint64_t minimum;
11874 + uint64_t softlimit;
11875 + uint64_t maximum;
11878 +struct vcmd_ctx_rlimit_mask_v0 {
11879 + uint32_t minimum;
11880 + uint32_t softlimit;
11881 + uint32_t maximum;
11884 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11886 +struct vcmd_rlimit_stat_v0 {
11890 + uint64_t minimum;
11891 + uint64_t maximum;
11894 +#define CRLIM_UNSET (0ULL)
11895 +#define CRLIM_INFINITY (~0ULL)
11896 +#define CRLIM_KEEP (~1ULL)
11900 +#ifdef CONFIG_IA32_EMULATION
11902 +struct vcmd_ctx_rlimit_v0_x32 {
11904 + uint64_t minimum;
11905 + uint64_t softlimit;
11906 + uint64_t maximum;
11907 +} __attribute__ ((packed));
11909 +#endif /* CONFIG_IA32_EMULATION */
11911 +#include <linux/compiler.h>
11913 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11914 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11915 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11916 +extern int vc_reset_hits(struct vx_info *, void __user *);
11917 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11919 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11921 +#ifdef CONFIG_IA32_EMULATION
11923 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11924 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11926 +#endif /* CONFIG_IA32_EMULATION */
11928 +#endif /* __KERNEL__ */
11929 +#endif /* _VX_LIMIT_CMD_H */
11930 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/limit_def.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit_def.h
11931 --- linux-2.6.32.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11932 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit_def.h 2009-12-03 20:04:56.000000000 +0100
11934 +#ifndef _VX_LIMIT_DEF_H
11935 +#define _VX_LIMIT_DEF_H
11937 +#include <asm/atomic.h>
11938 +#include <asm/resource.h>
11940 +#include "limit.h"
11943 +struct _vx_res_limit {
11944 + rlim_t soft; /* Context soft limit */
11945 + rlim_t hard; /* Context hard limit */
11947 + rlim_atomic_t rcur; /* Current value */
11948 + rlim_t rmin; /* Context minimum */
11949 + rlim_t rmax; /* Context maximum */
11951 + atomic_t lhit; /* Limit hits */
11954 +/* context sub struct */
11956 +struct _vx_limit {
11957 + struct _vx_res_limit res[NUM_LIMITS];
11960 +#ifdef CONFIG_VSERVER_DEBUG
11962 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11966 + printk("\t_vx_limit:");
11967 + for (i = 0; i < NUM_LIMITS; i++) {
11968 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11969 + i, (unsigned long)__rlim_get(limit, i),
11970 + (unsigned long)__rlim_rmin(limit, i),
11971 + (unsigned long)__rlim_rmax(limit, i),
11972 + (long)__rlim_soft(limit, i),
11973 + (long)__rlim_hard(limit, i),
11974 + atomic_read(&__rlim_lhit(limit, i)));
11980 +#endif /* _VX_LIMIT_DEF_H */
11981 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/limit.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit.h
11982 --- linux-2.6.32.10/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11983 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit.h 2010-02-05 00:34:02.000000000 +0100
11985 +#ifndef _VX_LIMIT_H
11986 +#define _VX_LIMIT_H
11988 +#define VLIMIT_NSOCK 16
11989 +#define VLIMIT_OPENFD 17
11990 +#define VLIMIT_ANON 18
11991 +#define VLIMIT_SHMEM 19
11992 +#define VLIMIT_SEMARY 20
11993 +#define VLIMIT_NSEMS 21
11994 +#define VLIMIT_DENTRY 22
11995 +#define VLIMIT_MAPPED 23
12000 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12002 +/* keep in sync with CRLIM_INFINITY */
12004 +#define VLIM_INFINITY (~0ULL)
12006 +#include <asm/atomic.h>
12007 +#include <asm/resource.h>
12009 +#ifndef RLIM_INFINITY
12010 +#warning RLIM_INFINITY is undefined
12013 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12015 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12016 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12018 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12019 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12020 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12022 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12023 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12025 +typedef atomic_long_t rlim_atomic_t;
12026 +typedef unsigned long rlim_t;
12028 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12029 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12030 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12031 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12032 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12033 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12036 +#if (RLIM_INFINITY == VLIM_INFINITY)
12037 +#define VX_VLIM(r) ((long long)(long)(r))
12038 +#define VX_RLIM(v) ((rlim_t)(v))
12040 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12041 + ? VLIM_INFINITY : (long long)(r))
12042 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12043 + ? RLIM_INFINITY : (rlim_t)(v))
12048 +void vx_vsi_meminfo(struct sysinfo *);
12049 +void vx_vsi_swapinfo(struct sysinfo *);
12050 +long vx_vsi_cached(struct sysinfo *);
12052 +#define NUM_LIMITS 24
12054 +#endif /* __KERNEL__ */
12055 +#endif /* _VX_LIMIT_H */
12056 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/limit_int.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit_int.h
12057 --- linux-2.6.32.10/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12058 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/limit_int.h 2009-12-03 20:04:56.000000000 +0100
12060 +#ifndef _VX_LIMIT_INT_H
12061 +#define _VX_LIMIT_INT_H
12063 +#include "context.h"
12067 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12068 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12070 +extern const char *vlimit_name[NUM_LIMITS];
12072 +static inline void __vx_acc_cres(struct vx_info *vxi,
12073 + int res, int dir, void *_data, char *_file, int _line)
12075 + if (VXD_RCRES_COND(res))
12076 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12077 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12078 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12079 + (dir > 0) ? "++" : "--", _data, _file, _line);
12084 + __rlim_inc(&vxi->limit, res);
12086 + __rlim_dec(&vxi->limit, res);
12089 +static inline void __vx_add_cres(struct vx_info *vxi,
12090 + int res, int amount, void *_data, char *_file, int _line)
12092 + if (VXD_RCRES_COND(res))
12093 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12094 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12095 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12096 + amount, _data, _file, _line);
12101 + __rlim_add(&vxi->limit, res, amount);
12105 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12107 + int cond = (value > __rlim_rmax(limit, res));
12110 + __rlim_rmax(limit, res) = value;
12115 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12117 + int cond = (value < __rlim_rmin(limit, res));
12120 + __rlim_rmin(limit, res) = value;
12125 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12127 + if (!__vx_cres_adjust_max(limit, res, value))
12128 + __vx_cres_adjust_min(limit, res, value);
12133 + +1 ... no limit hit
12134 + -1 ... over soft limit
12135 + 0 ... over hard limit */
12137 +static inline int __vx_cres_avail(struct vx_info *vxi,
12138 + int res, int num, char *_file, int _line)
12140 + struct _vx_limit *limit;
12143 + if (VXD_RLIMIT_COND(res))
12144 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12145 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12146 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12147 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12148 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12149 + num, _file, _line);
12153 + limit = &vxi->limit;
12154 + value = __rlim_get(limit, res);
12156 + if (!__vx_cres_adjust_max(limit, res, value))
12157 + __vx_cres_adjust_min(limit, res, value);
12162 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12164 + if (value + num <= __rlim_soft(limit, res))
12167 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12169 + if (value + num <= __rlim_hard(limit, res))
12172 + __rlim_hit(limit, res);
12177 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12180 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12182 + rlim_t value, sum = 0;
12185 + while ((res = *array++)) {
12186 + value = __rlim_get(limit, res);
12187 + __vx_cres_fixup(limit, res, value);
12194 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12196 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12197 + int res = *array;
12199 + if (value == __rlim_get(limit, res))
12202 + __rlim_set(limit, res, value);
12203 + /* now adjust min/max */
12204 + if (!__vx_cres_adjust_max(limit, res, value))
12205 + __vx_cres_adjust_min(limit, res, value);
12210 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12211 + const int *array, int num, char *_file, int _line)
12213 + struct _vx_limit *limit;
12214 + rlim_t value = 0;
12222 + limit = &vxi->limit;
12224 + value = __vx_cres_array_sum(limit, array + 1);
12226 + __rlim_set(limit, res, value);
12227 + __vx_cres_fixup(limit, res, value);
12229 + return __vx_cres_avail(vxi, res, num, _file, _line);
12233 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12238 + /* complex resources first */
12239 + if ((id < 0) || (id == RLIMIT_RSS))
12240 + __vx_cres_array_fixup(limit, VLA_RSS);
12242 + for (res = 0; res < NUM_LIMITS; res++) {
12243 + if ((id > 0) && (res != id))
12246 + value = __rlim_get(limit, res);
12247 + __vx_cres_fixup(limit, res, value);
12249 + /* not supposed to happen, maybe warn? */
12250 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12251 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12256 +#endif /* __KERNEL__ */
12257 +#endif /* _VX_LIMIT_INT_H */
12258 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/monitor.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/monitor.h
12259 --- linux-2.6.32.10/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12260 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/monitor.h 2009-12-03 20:04:56.000000000 +0100
12262 +#ifndef _VX_MONITOR_H
12263 +#define _VX_MONITOR_H
12265 +#include <linux/types.h>
12272 + VXM_UPDATE = 0x20,
12276 + VXM_RQINFO_1 = 0x24,
12279 + VXM_ACTIVATE = 0x40,
12286 + VXM_MIGRATE = 0x48,
12289 + /* all other bits are flags */
12290 + VXM_SCHED = 0x80,
12293 +struct _vxm_update_1 {
12294 + uint32_t tokens_max;
12295 + uint32_t fill_rate;
12296 + uint32_t interval;
12299 +struct _vxm_update_2 {
12300 + uint32_t tokens_min;
12301 + uint32_t fill_rate;
12302 + uint32_t interval;
12305 +struct _vxm_rqinfo_1 {
12306 + uint16_t running;
12310 + uint32_t idle_tokens;
12313 +struct _vxm_rqinfo_2 {
12314 + uint32_t norm_time;
12315 + uint32_t idle_time;
12316 + uint32_t idle_skip;
12319 +struct _vxm_sched {
12321 + uint32_t norm_time;
12322 + uint32_t idle_time;
12325 +struct _vxm_task {
12330 +struct _vxm_event {
12339 + struct _vxm_task tsk;
12343 +struct _vx_mon_entry {
12347 + struct _vxm_event ev;
12348 + struct _vxm_sched sd;
12349 + struct _vxm_update_1 u1;
12350 + struct _vxm_update_2 u2;
12351 + struct _vxm_rqinfo_1 q1;
12352 + struct _vxm_rqinfo_2 q2;
12357 +#endif /* _VX_MONITOR_H */
12358 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/network_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/network_cmd.h
12359 --- linux-2.6.32.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12360 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/network_cmd.h 2009-12-03 20:04:56.000000000 +0100
12362 +#ifndef _VX_NETWORK_CMD_H
12363 +#define _VX_NETWORK_CMD_H
12366 +/* vinfo commands */
12368 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12371 +extern int vc_task_nid(uint32_t);
12373 +#endif /* __KERNEL__ */
12375 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12377 +struct vcmd_nx_info_v0 {
12379 + /* more to come */
12383 +extern int vc_nx_info(struct nx_info *, void __user *);
12385 +#endif /* __KERNEL__ */
12387 +#include <linux/in.h>
12388 +#include <linux/in6.h>
12390 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12391 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12393 +struct vcmd_net_create {
12394 + uint64_t flagword;
12397 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12399 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12400 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12402 +struct vcmd_net_addr_v0 {
12405 + struct in_addr ip[4];
12406 + struct in_addr mask[4];
12409 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12410 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12412 +struct vcmd_net_addr_ipv4_v1 {
12415 + struct in_addr ip;
12416 + struct in_addr mask;
12419 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12420 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12422 +struct vcmd_net_addr_ipv6_v1 {
12426 + struct in6_addr ip;
12427 + struct in6_addr mask;
12430 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12431 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12433 +struct vcmd_match_ipv4_v0 {
12438 + struct in_addr ip;
12439 + struct in_addr ip2;
12440 + struct in_addr mask;
12443 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12444 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12446 +struct vcmd_match_ipv6_v0 {
12451 + struct in6_addr ip;
12452 + struct in6_addr ip2;
12453 + struct in6_addr mask;
12458 +extern int vc_net_create(uint32_t, void __user *);
12459 +extern int vc_net_migrate(struct nx_info *, void __user *);
12461 +extern int vc_net_add(struct nx_info *, void __user *);
12462 +extern int vc_net_remove(struct nx_info *, void __user *);
12464 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12465 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12467 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12468 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12470 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12471 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12473 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12474 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12476 +#endif /* __KERNEL__ */
12479 +/* flag commands */
12481 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12482 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12484 +struct vcmd_net_flags_v0 {
12485 + uint64_t flagword;
12490 +extern int vc_get_nflags(struct nx_info *, void __user *);
12491 +extern int vc_set_nflags(struct nx_info *, void __user *);
12493 +#endif /* __KERNEL__ */
12496 +/* network caps commands */
12498 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12499 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12501 +struct vcmd_net_caps_v0 {
12507 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12508 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12510 +#endif /* __KERNEL__ */
12511 +#endif /* _VX_CONTEXT_CMD_H */
12512 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/network.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/network.h
12513 --- linux-2.6.32.10/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12514 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/network.h 2009-12-03 20:04:56.000000000 +0100
12516 +#ifndef _VX_NETWORK_H
12517 +#define _VX_NETWORK_H
12519 +#include <linux/types.h>
12522 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12525 +/* network flags */
12527 +#define NXF_INFO_PRIVATE 0x00000008
12529 +#define NXF_SINGLE_IP 0x00000100
12530 +#define NXF_LBACK_REMAP 0x00000200
12531 +#define NXF_LBACK_ALLOW 0x00000400
12533 +#define NXF_HIDE_NETIF 0x02000000
12534 +#define NXF_HIDE_LBACK 0x04000000
12536 +#define NXF_STATE_SETUP (1ULL << 32)
12537 +#define NXF_STATE_ADMIN (1ULL << 34)
12539 +#define NXF_SC_HELPER (1ULL << 36)
12540 +#define NXF_PERSISTENT (1ULL << 38)
12542 +#define NXF_ONE_TIME (0x0005ULL << 32)
12545 +#define NXF_INIT_SET (__nxf_init_set())
12547 +static inline uint64_t __nxf_init_set(void) {
12548 + return NXF_STATE_ADMIN
12549 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12550 + | NXF_LBACK_REMAP
12553 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12556 + | NXF_HIDE_NETIF;
12560 +/* network caps */
12562 +#define NXC_TUN_CREATE 0x00000001
12564 +#define NXC_RAW_ICMP 0x00000100
12567 +/* address types */
12569 +#define NXA_TYPE_IPV4 0x0001
12570 +#define NXA_TYPE_IPV6 0x0002
12572 +#define NXA_TYPE_NONE 0x0000
12573 +#define NXA_TYPE_ANY 0x00FF
12575 +#define NXA_TYPE_ADDR 0x0010
12576 +#define NXA_TYPE_MASK 0x0020
12577 +#define NXA_TYPE_RANGE 0x0040
12579 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12581 +#define NXA_MOD_BCAST 0x0100
12582 +#define NXA_MOD_LBACK 0x0200
12584 +#define NXA_LOOPBACK 0x1000
12586 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12587 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12591 +#include <linux/list.h>
12592 +#include <linux/spinlock.h>
12593 +#include <linux/rcupdate.h>
12594 +#include <linux/in.h>
12595 +#include <linux/in6.h>
12596 +#include <asm/atomic.h>
12598 +struct nx_addr_v4 {
12599 + struct nx_addr_v4 *next;
12600 + struct in_addr ip[2];
12601 + struct in_addr mask;
12606 +struct nx_addr_v6 {
12607 + struct nx_addr_v6 *next;
12608 + struct in6_addr ip;
12609 + struct in6_addr mask;
12616 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12617 + nid_t nx_id; /* vnet id */
12618 + atomic_t nx_usecnt; /* usage count */
12619 + atomic_t nx_tasks; /* tasks count */
12620 + int nx_state; /* context state */
12622 + uint64_t nx_flags; /* network flag word */
12623 + uint64_t nx_ncaps; /* network capabilities */
12625 + struct in_addr v4_lback; /* Loopback address */
12626 + struct in_addr v4_bcast; /* Broadcast address */
12627 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12628 +#ifdef CONFIG_IPV6
12629 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12631 + char nx_name[65]; /* network context name */
12635 +/* status flags */
12637 +#define NXS_HASHED 0x0001
12638 +#define NXS_SHUTDOWN 0x0100
12639 +#define NXS_RELEASED 0x8000
12641 +extern struct nx_info *lookup_nx_info(int);
12643 +extern int get_nid_list(int, unsigned int *, int);
12644 +extern int nid_is_hashed(nid_t);
12646 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12648 +extern long vs_net_change(struct nx_info *, unsigned int);
12653 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12654 +#ifdef CONFIG_IPV6
12655 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12657 +#define NX_IPV6(n) (0)
12660 +#endif /* __KERNEL__ */
12661 +#endif /* _VX_NETWORK_H */
12662 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/percpu.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/percpu.h
12663 --- linux-2.6.32.10/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12664 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/percpu.h 2009-12-03 20:04:56.000000000 +0100
12666 +#ifndef _VX_PERCPU_H
12667 +#define _VX_PERCPU_H
12669 +#include "cvirt_def.h"
12670 +#include "sched_def.h"
12672 +struct _vx_percpu {
12673 + struct _vx_cvirt_pc cvirt;
12674 + struct _vx_sched_pc sched;
12677 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12679 +#endif /* _VX_PERCPU_H */
12680 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/pid.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/pid.h
12681 --- linux-2.6.32.10/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12682 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/pid.h 2009-12-03 20:04:56.000000000 +0100
12684 +#ifndef _VSERVER_PID_H
12685 +#define _VSERVER_PID_H
12687 +/* pid faking stuff */
12689 +#define vx_info_map_pid(v, p) \
12690 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12691 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12692 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12693 +#define vx_map_tgid(p) vx_map_pid(p)
12695 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12696 + const char *func, const char *file, int line)
12698 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12699 + vxfprintk(VXD_CBIT(cvirt, 2),
12700 + "vx_map_tgid: %p/%llx: %d -> %d",
12701 + vxi, (long long)vxi->vx_flags, pid,
12702 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12703 + func, file, line);
12706 + if (pid == vxi->vx_initpid)
12712 +#define vx_info_rmap_pid(v, p) \
12713 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12714 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12715 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12717 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12718 + const char *func, const char *file, int line)
12720 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12721 + vxfprintk(VXD_CBIT(cvirt, 2),
12722 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12723 + vxi, (long long)vxi->vx_flags, pid,
12724 + (pid == 1) ? vxi->vx_initpid : pid,
12725 + func, file, line);
12726 + if ((pid == 1) && vxi->vx_initpid)
12727 + return vxi->vx_initpid;
12728 + if (pid == vxi->vx_initpid)
12735 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/sched_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/sched_cmd.h
12736 --- linux-2.6.32.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12737 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/sched_cmd.h 2009-12-03 20:04:56.000000000 +0100
12739 +#ifndef _VX_SCHED_CMD_H
12740 +#define _VX_SCHED_CMD_H
12743 +/* sched vserver commands */
12745 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12746 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12747 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12749 +struct vcmd_set_sched_v2 {
12750 + int32_t fill_rate;
12751 + int32_t interval;
12753 + int32_t tokens_min;
12754 + int32_t tokens_max;
12755 + uint64_t cpu_mask;
12758 +struct vcmd_set_sched_v3 {
12759 + uint32_t set_mask;
12760 + int32_t fill_rate;
12761 + int32_t interval;
12763 + int32_t tokens_min;
12764 + int32_t tokens_max;
12765 + int32_t priority_bias;
12768 +struct vcmd_set_sched_v4 {
12769 + uint32_t set_mask;
12770 + int32_t fill_rate;
12771 + int32_t interval;
12773 + int32_t tokens_min;
12774 + int32_t tokens_max;
12775 + int32_t prio_bias;
12777 + int32_t bucket_id;
12780 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12781 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12783 +struct vcmd_sched_v5 {
12786 + int32_t bucket_id;
12787 + int32_t fill_rate[2];
12788 + int32_t interval[2];
12790 + int32_t tokens_min;
12791 + int32_t tokens_max;
12792 + int32_t prio_bias;
12795 +#define VXSM_FILL_RATE 0x0001
12796 +#define VXSM_INTERVAL 0x0002
12797 +#define VXSM_FILL_RATE2 0x0004
12798 +#define VXSM_INTERVAL2 0x0008
12799 +#define VXSM_TOKENS 0x0010
12800 +#define VXSM_TOKENS_MIN 0x0020
12801 +#define VXSM_TOKENS_MAX 0x0040
12802 +#define VXSM_PRIO_BIAS 0x0100
12804 +#define VXSM_IDLE_TIME 0x0200
12805 +#define VXSM_FORCE 0x0400
12807 +#define VXSM_V3_MASK 0x0173
12808 +#define VXSM_SET_MASK 0x01FF
12810 +#define VXSM_CPU_ID 0x1000
12811 +#define VXSM_BUCKET_ID 0x2000
12813 +#define VXSM_MSEC 0x4000
12815 +#define SCHED_KEEP (-2) /* only for v2 */
12819 +#include <linux/compiler.h>
12821 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12822 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12823 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12824 +extern int vc_set_sched(struct vx_info *, void __user *);
12825 +extern int vc_get_sched(struct vx_info *, void __user *);
12827 +#endif /* __KERNEL__ */
12829 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12831 +struct vcmd_sched_info {
12833 + int32_t bucket_id;
12834 + uint64_t user_msec;
12835 + uint64_t sys_msec;
12836 + uint64_t hold_msec;
12837 + uint32_t token_usec;
12838 + int32_t vavavoom;
12843 +extern int vc_sched_info(struct vx_info *, void __user *);
12845 +#endif /* __KERNEL__ */
12846 +#endif /* _VX_SCHED_CMD_H */
12847 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/sched_def.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/sched_def.h
12848 --- linux-2.6.32.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12849 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/sched_def.h 2009-12-03 20:04:56.000000000 +0100
12851 +#ifndef _VX_SCHED_DEF_H
12852 +#define _VX_SCHED_DEF_H
12854 +#include <linux/spinlock.h>
12855 +#include <linux/jiffies.h>
12856 +#include <linux/cpumask.h>
12857 +#include <asm/atomic.h>
12858 +#include <asm/param.h>
12861 +/* context sub struct */
12863 +struct _vx_sched {
12864 + spinlock_t tokens_lock; /* lock for token bucket */
12866 + int tokens; /* number of CPU tokens */
12867 + int fill_rate[2]; /* Fill rate: add X tokens... */
12868 + int interval[2]; /* Divisor: per Y jiffies */
12869 + int tokens_min; /* Limit: minimum for unhold */
12870 + int tokens_max; /* Limit: no more than N tokens */
12872 + int prio_bias; /* bias offset for priority */
12874 + unsigned update_mask; /* which features should be updated */
12875 + cpumask_t update; /* CPUs which should update */
12878 +struct _vx_sched_pc {
12879 + int tokens; /* number of CPU tokens */
12880 + int flags; /* bucket flags */
12882 + int fill_rate[2]; /* Fill rate: add X tokens... */
12883 + int interval[2]; /* Divisor: per Y jiffies */
12884 + int tokens_min; /* Limit: minimum for unhold */
12885 + int tokens_max; /* Limit: no more than N tokens */
12887 + int prio_bias; /* bias offset for priority */
12888 + int vavavoom; /* last calculated vavavoom */
12890 + unsigned long norm_time; /* last time accounted */
12891 + unsigned long idle_time; /* non linear time for fair sched */
12892 + unsigned long token_time; /* token time for accounting */
12893 + unsigned long onhold; /* jiffies when put on hold */
12895 + uint64_t user_ticks; /* token tick events */
12896 + uint64_t sys_ticks; /* token tick events */
12897 + uint64_t hold_ticks; /* token ticks paused */
12901 +#define VXSF_ONHOLD 0x0001
12902 +#define VXSF_IDLE_TIME 0x0100
12904 +#ifdef CONFIG_VSERVER_DEBUG
12906 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12908 + printk("\t_vx_sched:\n");
12909 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12910 + sched->fill_rate[0], sched->interval[0],
12911 + sched->fill_rate[1], sched->interval[1],
12912 + sched->tokens_min, sched->tokens_max);
12913 + printk("\t priority = %4d\n", sched->prio_bias);
12918 +#endif /* _VX_SCHED_DEF_H */
12919 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/sched.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/sched.h
12920 --- linux-2.6.32.10/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12921 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/sched.h 2009-12-03 20:04:56.000000000 +0100
12923 +#ifndef _VX_SCHED_H
12924 +#define _VX_SCHED_H
12931 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12936 +void vx_update_load(struct vx_info *);
12939 +int vx_tokens_recalc(struct _vx_sched_pc *,
12940 + unsigned long *, unsigned long *, int [2]);
12942 +void vx_update_sched_param(struct _vx_sched *sched,
12943 + struct _vx_sched_pc *sched_pc);
12945 +#endif /* __KERNEL__ */
12946 +#else /* _VX_SCHED_H */
12947 +#warning duplicate inclusion
12948 +#endif /* _VX_SCHED_H */
12949 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/signal_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/signal_cmd.h
12950 --- linux-2.6.32.10/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12951 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/signal_cmd.h 2009-12-03 20:04:56.000000000 +0100
12953 +#ifndef _VX_SIGNAL_CMD_H
12954 +#define _VX_SIGNAL_CMD_H
12957 +/* signalling vserver commands */
12959 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12960 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12962 +struct vcmd_ctx_kill_v0 {
12967 +struct vcmd_wait_exit_v0 {
12968 + int32_t reboot_cmd;
12969 + int32_t exit_code;
12974 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12975 +extern int vc_wait_exit(struct vx_info *, void __user *);
12977 +#endif /* __KERNEL__ */
12979 +/* process alteration commands */
12981 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12982 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12984 +struct vcmd_pflags_v0 {
12985 + uint32_t flagword;
12991 +extern int vc_get_pflags(uint32_t pid, void __user *);
12992 +extern int vc_set_pflags(uint32_t pid, void __user *);
12994 +#endif /* __KERNEL__ */
12995 +#endif /* _VX_SIGNAL_CMD_H */
12996 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/signal.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/signal.h
12997 --- linux-2.6.32.10/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12998 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/signal.h 2009-12-03 20:04:56.000000000 +0100
13000 +#ifndef _VX_SIGNAL_H
13001 +#define _VX_SIGNAL_H
13008 +int vx_info_kill(struct vx_info *, int, int);
13010 +#endif /* __KERNEL__ */
13011 +#else /* _VX_SIGNAL_H */
13012 +#warning duplicate inclusion
13013 +#endif /* _VX_SIGNAL_H */
13014 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/space_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/space_cmd.h
13015 --- linux-2.6.32.10/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13016 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/space_cmd.h 2009-12-03 20:04:56.000000000 +0100
13018 +#ifndef _VX_SPACE_CMD_H
13019 +#define _VX_SPACE_CMD_H
13022 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13023 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13024 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13026 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13027 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13028 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13030 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13032 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13033 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13036 +struct vcmd_space_mask_v1 {
13040 +struct vcmd_space_mask_v2 {
13048 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13049 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13050 +extern int vc_enter_space(struct vx_info *, void __user *);
13051 +extern int vc_set_space(struct vx_info *, void __user *);
13052 +extern int vc_get_space_mask(void __user *, int);
13054 +#endif /* __KERNEL__ */
13055 +#endif /* _VX_SPACE_CMD_H */
13056 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/space.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/space.h
13057 --- linux-2.6.32.10/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13058 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/space.h 2009-12-03 20:04:56.000000000 +0100
13060 +#ifndef _VX_SPACE_H
13061 +#define _VX_SPACE_H
13063 +#include <linux/types.h>
13067 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13069 +#else /* _VX_SPACE_H */
13070 +#warning duplicate inclusion
13071 +#endif /* _VX_SPACE_H */
13072 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/switch.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/switch.h
13073 --- linux-2.6.32.10/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13074 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/switch.h 2009-12-03 20:04:56.000000000 +0100
13076 +#ifndef _VX_SWITCH_H
13077 +#define _VX_SWITCH_H
13079 +#include <linux/types.h>
13082 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13083 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13084 +#define VC_VERSION(c) ((c) & 0xFFF)
13086 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13087 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13091 + Syscall Matrix V2.8
13093 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13094 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13095 + |INFO |SETUP | |MOVE | | | | | |
13096 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13097 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13098 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13099 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13100 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13101 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13102 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13103 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13104 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13105 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13106 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13107 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13108 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13109 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13110 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13111 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13112 + OTHER |VSTAT | | | | | | |VINFO | |
13113 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13114 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13115 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13116 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13117 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13118 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13119 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13120 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13124 +#define VC_CAT_VERSION 0
13126 +#define VC_CAT_VSETUP 1
13127 +#define VC_CAT_VHOST 2
13129 +#define VC_CAT_DEVICE 6
13131 +#define VC_CAT_VPROC 9
13132 +#define VC_CAT_PROCALT 10
13133 +#define VC_CAT_PROCMIG 11
13134 +#define VC_CAT_PROCTRL 12
13136 +#define VC_CAT_SCHED 14
13137 +#define VC_CAT_MEMCTRL 20
13139 +#define VC_CAT_VNET 25
13140 +#define VC_CAT_NETALT 26
13141 +#define VC_CAT_NETMIG 27
13142 +#define VC_CAT_NETCTRL 28
13144 +#define VC_CAT_TAGMIG 35
13145 +#define VC_CAT_DLIMIT 36
13146 +#define VC_CAT_INODE 38
13148 +#define VC_CAT_VSTAT 40
13149 +#define VC_CAT_VINFO 46
13150 +#define VC_CAT_EVENT 48
13152 +#define VC_CAT_FLAGS 52
13153 +#define VC_CAT_VSPACE 54
13154 +#define VC_CAT_DEBUG 56
13155 +#define VC_CAT_RLIMIT 60
13157 +#define VC_CAT_SYSTEST 61
13158 +#define VC_CAT_COMPAT 63
13160 +/* query version */
13162 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13163 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13168 +#include <linux/errno.h>
13170 +#endif /* __KERNEL__ */
13172 +#endif /* _VX_SWITCH_H */
13174 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/tag_cmd.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/tag_cmd.h
13175 --- linux-2.6.32.10/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13176 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/tag_cmd.h 2009-12-03 20:04:56.000000000 +0100
13178 +#ifndef _VX_TAG_CMD_H
13179 +#define _VX_TAG_CMD_H
13182 +/* vinfo commands */
13184 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13187 +extern int vc_task_tag(uint32_t);
13189 +#endif /* __KERNEL__ */
13191 +/* context commands */
13193 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13196 +extern int vc_tag_migrate(uint32_t);
13198 +#endif /* __KERNEL__ */
13199 +#endif /* _VX_TAG_CMD_H */
13200 diff -NurpP --minimal linux-2.6.32.10/include/linux/vserver/tag.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/tag.h
13201 --- linux-2.6.32.10/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13202 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vserver/tag.h 2009-12-03 20:04:56.000000000 +0100
13207 +#include <linux/types.h>
13210 +#define DX_TAG(in) (IS_TAGGED(in))
13213 +#ifdef CONFIG_TAG_NFSD
13214 +#define DX_TAG_NFSD 1
13216 +#define DX_TAG_NFSD 0
13220 +#ifdef CONFIG_TAGGING_NONE
13222 +#define MAX_UID 0xFFFFFFFF
13223 +#define MAX_GID 0xFFFFFFFF
13225 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13227 +#define TAGINO_UID(cond, uid, tag) (uid)
13228 +#define TAGINO_GID(cond, gid, tag) (gid)
13233 +#ifdef CONFIG_TAGGING_GID16
13235 +#define MAX_UID 0xFFFFFFFF
13236 +#define MAX_GID 0x0000FFFF
13238 +#define INOTAG_TAG(cond, uid, gid, tag) \
13239 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13241 +#define TAGINO_UID(cond, uid, tag) (uid)
13242 +#define TAGINO_GID(cond, gid, tag) \
13243 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13248 +#ifdef CONFIG_TAGGING_ID24
13250 +#define MAX_UID 0x00FFFFFF
13251 +#define MAX_GID 0x00FFFFFF
13253 +#define INOTAG_TAG(cond, uid, gid, tag) \
13254 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13256 +#define TAGINO_UID(cond, uid, tag) \
13257 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13258 +#define TAGINO_GID(cond, gid, tag) \
13259 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13264 +#ifdef CONFIG_TAGGING_UID16
13266 +#define MAX_UID 0x0000FFFF
13267 +#define MAX_GID 0xFFFFFFFF
13269 +#define INOTAG_TAG(cond, uid, gid, tag) \
13270 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13272 +#define TAGINO_UID(cond, uid, tag) \
13273 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13274 +#define TAGINO_GID(cond, gid, tag) (gid)
13279 +#ifdef CONFIG_TAGGING_INTERN
13281 +#define MAX_UID 0xFFFFFFFF
13282 +#define MAX_GID 0xFFFFFFFF
13284 +#define INOTAG_TAG(cond, uid, gid, tag) \
13285 + ((cond) ? (tag) : 0)
13287 +#define TAGINO_UID(cond, uid, tag) (uid)
13288 +#define TAGINO_GID(cond, gid, tag) (gid)
13293 +#ifndef CONFIG_TAGGING_NONE
13294 +#define dx_current_fstag(sb) \
13295 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13297 +#define dx_current_fstag(sb) (0)
13300 +#ifndef CONFIG_TAGGING_INTERN
13301 +#define TAGINO_TAG(cond, tag) (0)
13303 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13306 +#define INOTAG_UID(cond, uid, gid) \
13307 + ((cond) ? ((uid) & MAX_UID) : (uid))
13308 +#define INOTAG_GID(cond, uid, gid) \
13309 + ((cond) ? ((gid) & MAX_GID) : (gid))
13312 +static inline uid_t dx_map_uid(uid_t uid)
13314 + if ((uid > MAX_UID) && (uid != -1))
13316 + return (uid & MAX_UID);
13319 +static inline gid_t dx_map_gid(gid_t gid)
13321 + if ((gid > MAX_GID) && (gid != -1))
13323 + return (gid & MAX_GID);
13331 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13333 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13334 + unsigned long *flags);
13336 +#ifdef CONFIG_PROPAGATE
13338 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13340 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13343 +#define dx_propagate_tag(n, i) do { } while (0)
13346 +#endif /* _DX_TAG_H */
13347 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_inet6.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_inet6.h
13348 --- linux-2.6.32.10/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13349 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_inet6.h 2009-12-03 20:04:56.000000000 +0100
13351 +#ifndef _VS_INET6_H
13352 +#define _VS_INET6_H
13354 +#include "vserver/base.h"
13355 +#include "vserver/network.h"
13356 +#include "vserver/debug.h"
13358 +#include <net/ipv6.h>
13360 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13361 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13364 +#ifdef CONFIG_IPV6
13367 +int v6_addr_match(struct nx_addr_v6 *nxa,
13368 + const struct in6_addr *addr, uint16_t mask)
13372 + switch (nxa->type & mask) {
13373 + case NXA_TYPE_MASK:
13374 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13376 + case NXA_TYPE_ADDR:
13377 + ret = ipv6_addr_equal(&nxa->ip, addr);
13379 + case NXA_TYPE_ANY:
13383 + vxdprintk(VXD_CBIT(net, 0),
13384 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13385 + nxa, NXAV6(nxa), addr, mask, ret);
13390 +int v6_addr_in_nx_info(struct nx_info *nxi,
13391 + const struct in6_addr *addr, uint16_t mask)
13393 + struct nx_addr_v6 *nxa;
13398 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13399 + if (v6_addr_match(nxa, addr, mask))
13403 + vxdprintk(VXD_CBIT(net, 0),
13404 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13405 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13410 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13412 + /* FIXME: needs full range checks */
13413 + return v6_addr_match(nxa, &addr->ip, mask);
13417 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13419 + struct nx_addr_v6 *ptr;
13421 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13422 + if (v6_nx_addr_match(ptr, nxa, mask))
13429 + * Check if a given address matches for a socket
13431 + * nxi: the socket's nx_info if any
13432 + * addr: to be verified address
13435 +int v6_sock_addr_match (
13436 + struct nx_info *nxi,
13437 + struct inet_sock *inet,
13438 + struct in6_addr *addr)
13440 + struct sock *sk = &inet->sk;
13441 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13443 + if (!ipv6_addr_any(addr) &&
13444 + ipv6_addr_equal(saddr, addr))
13446 + if (ipv6_addr_any(saddr))
13447 + return v6_addr_in_nx_info(nxi, addr, -1);
13452 + * check if address is covered by socket
13454 + * sk: the socket to check against
13455 + * addr: the address in question (must be != 0)
13459 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13461 + struct nx_info *nxi = sk->sk_nx_info;
13462 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13464 + vxdprintk(VXD_CBIT(net, 5),
13465 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13466 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13467 + (sk->sk_socket?sk->sk_socket->flags:0));
13469 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13470 + return v6_addr_match(nxa, saddr, -1);
13471 + } else if (nxi) { /* match against nx_info */
13472 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13473 + } else { /* unrestricted any socket */
13479 +/* inet related checks and helpers */
13483 +struct net_device;
13487 +#include <linux/netdevice.h>
13488 +#include <linux/inetdevice.h>
13489 +#include <net/inet_timewait_sock.h>
13492 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13493 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13494 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13499 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13505 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13509 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13511 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13512 + nxi, nxi ? nxi->nx_id : 0, ifa,
13513 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13515 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13517 + if (v6_ifa_in_nx_info(ifa, nxi))
13523 +struct nx_v6_sock_addr {
13524 + struct in6_addr saddr; /* Address used for validation */
13525 + struct in6_addr baddr; /* Address used for socket bind */
13529 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13530 + struct nx_v6_sock_addr *nsa)
13532 + // struct sock *sk = &inet->sk;
13533 + // struct nx_info *nxi = sk->sk_nx_info;
13534 + struct in6_addr saddr = addr->sin6_addr;
13535 + struct in6_addr baddr = saddr;
13537 + nsa->saddr = saddr;
13538 + nsa->baddr = baddr;
13543 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13545 + // struct sock *sk = &inet->sk;
13546 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13548 + // *saddr = nsa->baddr;
13549 + // inet->saddr = nsa->baddr;
13553 +int nx_info_has_v6(struct nx_info *nxi)
13557 + if (NX_IPV6(nxi))
13562 +#else /* CONFIG_IPV6 */
13565 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13572 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13578 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13584 +int nx_info_has_v6(struct nx_info *nxi)
13589 +#endif /* CONFIG_IPV6 */
13591 +#define current_nx_info_has_v6() \
13592 + nx_info_has_v6(current_nx_info())
13595 +#warning duplicate inclusion
13597 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_inet.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_inet.h
13598 --- linux-2.6.32.10/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13599 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_inet.h 2009-12-03 20:04:56.000000000 +0100
13601 +#ifndef _VS_INET_H
13602 +#define _VS_INET_H
13604 +#include "vserver/base.h"
13605 +#include "vserver/network.h"
13606 +#include "vserver/debug.h"
13608 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13610 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13611 + NIPQUAD((a)->mask), (a)->type
13612 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13616 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13618 + __be32 ip = nxa->ip[0].s_addr;
13619 + __be32 mask = nxa->mask.s_addr;
13620 + __be32 bcast = ip | ~mask;
13623 + switch (nxa->type & tmask) {
13624 + case NXA_TYPE_MASK:
13625 + ret = (ip == (addr & mask));
13627 + case NXA_TYPE_ADDR:
13631 + /* fall through to broadcast */
13632 + case NXA_MOD_BCAST:
13633 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13635 + case NXA_TYPE_RANGE:
13636 + ret = ((nxa->ip[0].s_addr <= addr) &&
13637 + (nxa->ip[1].s_addr > addr));
13639 + case NXA_TYPE_ANY:
13644 + vxdprintk(VXD_CBIT(net, 0),
13645 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13646 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13651 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13653 + struct nx_addr_v4 *nxa;
13660 + /* allow 127.0.0.1 when remapping lback */
13661 + if ((tmask & NXA_LOOPBACK) &&
13662 + (addr == IPI_LOOPBACK) &&
13663 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13666 + /* check for lback address */
13667 + if ((tmask & NXA_MOD_LBACK) &&
13668 + (nxi->v4_lback.s_addr == addr))
13671 + /* check for broadcast address */
13672 + if ((tmask & NXA_MOD_BCAST) &&
13673 + (nxi->v4_bcast.s_addr == addr))
13676 + /* check for v4 addresses */
13677 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13678 + if (v4_addr_match(nxa, addr, tmask))
13682 + vxdprintk(VXD_CBIT(net, 0),
13683 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13684 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13689 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13691 + /* FIXME: needs full range checks */
13692 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13696 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13698 + struct nx_addr_v4 *ptr;
13700 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13701 + if (v4_nx_addr_match(ptr, nxa, mask))
13706 +#include <net/inet_sock.h>
13709 + * Check if a given address matches for a socket
13711 + * nxi: the socket's nx_info if any
13712 + * addr: to be verified address
13715 +int v4_sock_addr_match (
13716 + struct nx_info *nxi,
13717 + struct inet_sock *inet,
13720 + __be32 saddr = inet->rcv_saddr;
13721 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13723 + if (addr && (saddr == addr || bcast == addr))
13726 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13731 +/* inet related checks and helpers */
13735 +struct net_device;
13738 +#ifdef CONFIG_INET
13740 +#include <linux/netdevice.h>
13741 +#include <linux/inetdevice.h>
13742 +#include <net/inet_sock.h>
13743 +#include <net/inet_timewait_sock.h>
13746 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13747 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13748 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13752 + * check if address is covered by socket
13754 + * sk: the socket to check against
13755 + * addr: the address in question (must be != 0)
13759 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13761 + struct nx_info *nxi = sk->sk_nx_info;
13762 + __be32 saddr = inet_rcv_saddr(sk);
13764 + vxdprintk(VXD_CBIT(net, 5),
13765 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13766 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13767 + (sk->sk_socket?sk->sk_socket->flags:0));
13769 + if (saddr) { /* direct address match */
13770 + return v4_addr_match(nxa, saddr, -1);
13771 + } else if (nxi) { /* match against nx_info */
13772 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13773 + } else { /* unrestricted any socket */
13781 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13783 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13784 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13785 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13787 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13789 + if (dev_in_nx_info(dev, nxi))
13796 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13802 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13806 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13808 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13809 + nxi, nxi ? nxi->nx_id : 0, ifa,
13810 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13812 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13814 + if (v4_ifa_in_nx_info(ifa, nxi))
13820 +struct nx_v4_sock_addr {
13821 + __be32 saddr; /* Address used for validation */
13822 + __be32 baddr; /* Address used for socket bind */
13826 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13827 + struct nx_v4_sock_addr *nsa)
13829 + struct sock *sk = &inet->sk;
13830 + struct nx_info *nxi = sk->sk_nx_info;
13831 + __be32 saddr = addr->sin_addr.s_addr;
13832 + __be32 baddr = saddr;
13834 + vxdprintk(VXD_CBIT(net, 3),
13835 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13836 + sk, sk->sk_nx_info, sk->sk_socket,
13837 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13841 + if (saddr == INADDR_ANY) {
13842 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13843 + baddr = nxi->v4.ip[0].s_addr;
13844 + } else if (saddr == IPI_LOOPBACK) {
13845 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13846 + baddr = nxi->v4_lback.s_addr;
13847 + } else { /* normal address bind */
13848 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13849 + return -EADDRNOTAVAIL;
13853 + vxdprintk(VXD_CBIT(net, 3),
13854 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13855 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13857 + nsa->saddr = saddr;
13858 + nsa->baddr = baddr;
13863 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13865 + inet->saddr = nsa->baddr;
13866 + inet->rcv_saddr = nsa->baddr;
13871 + * helper to simplify inet_lookup_listener
13873 + * nxi: the socket's nx_info if any
13874 + * addr: to be verified address
13875 + * saddr: socket address
13877 +static inline int v4_inet_addr_match (
13878 + struct nx_info *nxi,
13882 + if (addr && (saddr == addr))
13885 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13889 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13891 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13892 + (addr == nxi->v4_lback.s_addr))
13893 + return IPI_LOOPBACK;
13898 +int nx_info_has_v4(struct nx_info *nxi)
13902 + if (NX_IPV4(nxi))
13904 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13909 +#else /* CONFIG_INET */
13912 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13918 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13924 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13930 +int nx_info_has_v4(struct nx_info *nxi)
13935 +#endif /* CONFIG_INET */
13937 +#define current_nx_info_has_v4() \
13938 + nx_info_has_v4(current_nx_info())
13941 +// #warning duplicate inclusion
13943 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_limit.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_limit.h
13944 --- linux-2.6.32.10/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13945 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_limit.h 2009-12-03 20:04:56.000000000 +0100
13947 +#ifndef _VS_LIMIT_H
13948 +#define _VS_LIMIT_H
13950 +#include "vserver/limit.h"
13951 +#include "vserver/base.h"
13952 +#include "vserver/context.h"
13953 +#include "vserver/debug.h"
13954 +#include "vserver/context.h"
13955 +#include "vserver/limit_int.h"
13958 +#define vx_acc_cres(v, d, p, r) \
13959 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13961 +#define vx_acc_cres_cond(x, d, p, r) \
13962 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13963 + r, d, p, __FILE__, __LINE__)
13966 +#define vx_add_cres(v, a, p, r) \
13967 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13968 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13970 +#define vx_add_cres_cond(x, a, p, r) \
13971 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13972 + r, a, p, __FILE__, __LINE__)
13973 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13976 +/* process and file limits */
13978 +#define vx_nproc_inc(p) \
13979 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13981 +#define vx_nproc_dec(p) \
13982 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13984 +#define vx_files_inc(f) \
13985 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13987 +#define vx_files_dec(f) \
13988 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13990 +#define vx_locks_inc(l) \
13991 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13993 +#define vx_locks_dec(l) \
13994 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13996 +#define vx_openfd_inc(f) \
13997 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
13999 +#define vx_openfd_dec(f) \
14000 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
14003 +#define vx_cres_avail(v, n, r) \
14004 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
14007 +#define vx_nproc_avail(n) \
14008 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
14010 +#define vx_files_avail(n) \
14011 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
14013 +#define vx_locks_avail(n) \
14014 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
14016 +#define vx_openfd_avail(n) \
14017 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
14020 +/* dentry limits */
14022 +#define vx_dentry_inc(d) do { \
14023 + if (atomic_read(&d->d_count) == 1) \
14024 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
14027 +#define vx_dentry_dec(d) do { \
14028 + if (atomic_read(&d->d_count) == 0) \
14029 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
14032 +#define vx_dentry_avail(n) \
14033 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
14036 +/* socket limits */
14038 +#define vx_sock_inc(s) \
14039 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14041 +#define vx_sock_dec(s) \
14042 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14044 +#define vx_sock_avail(n) \
14045 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
14048 +/* ipc resource limits */
14050 +#define vx_ipcmsg_add(v, u, a) \
14051 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14053 +#define vx_ipcmsg_sub(v, u, a) \
14054 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14056 +#define vx_ipcmsg_avail(v, a) \
14057 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14060 +#define vx_ipcshm_add(v, k, a) \
14061 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14063 +#define vx_ipcshm_sub(v, k, a) \
14064 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14066 +#define vx_ipcshm_avail(v, a) \
14067 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14070 +#define vx_semary_inc(a) \
14071 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
14073 +#define vx_semary_dec(a) \
14074 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
14077 +#define vx_nsems_add(a,n) \
14078 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14080 +#define vx_nsems_sub(a,n) \
14081 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14085 +#warning duplicate inclusion
14087 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_memory.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_memory.h
14088 --- linux-2.6.32.10/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14089 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_memory.h 2009-12-03 20:04:56.000000000 +0100
14091 +#ifndef _VS_MEMORY_H
14092 +#define _VS_MEMORY_H
14094 +#include "vserver/limit.h"
14095 +#include "vserver/base.h"
14096 +#include "vserver/context.h"
14097 +#include "vserver/debug.h"
14098 +#include "vserver/context.h"
14099 +#include "vserver/limit_int.h"
14102 +#define __acc_add_long(a, v) (*(v) += (a))
14103 +#define __acc_inc_long(v) (++*(v))
14104 +#define __acc_dec_long(v) (--*(v))
14106 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14107 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14108 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14109 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14110 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14111 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14112 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14113 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14114 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14117 +#define vx_acc_page(m, d, v, r) do { \
14119 + __acc_inc_long(&(m)->v); \
14121 + __acc_dec_long(&(m)->v); \
14122 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14125 +#define vx_acc_page_atomic(m, d, v, r) do { \
14127 + __acc_inc_atomic(&(m)->v); \
14129 + __acc_dec_atomic(&(m)->v); \
14130 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14134 +#define vx_acc_pages(m, p, v, r) do { \
14135 + unsigned long __p = (p); \
14136 + __acc_add_long(__p, &(m)->v); \
14137 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14140 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14141 + unsigned long __p = (p); \
14142 + __acc_add_atomic(__p, &(m)->v); \
14143 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14148 +#define vx_acc_vmpage(m, d) \
14149 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14150 +#define vx_acc_vmlpage(m, d) \
14151 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14152 +#define vx_acc_file_rsspage(m, d) \
14153 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14154 +#define vx_acc_anon_rsspage(m, d) \
14155 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14157 +#define vx_acc_vmpages(m, p) \
14158 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14159 +#define vx_acc_vmlpages(m, p) \
14160 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14161 +#define vx_acc_file_rsspages(m, p) \
14162 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14163 +#define vx_acc_anon_rsspages(m, p) \
14164 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14166 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14167 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14169 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14170 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14171 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14172 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14174 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14175 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14176 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14177 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14179 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14180 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14181 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14182 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14184 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14185 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14186 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14187 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14190 +#define vx_pages_avail(m, p, r) \
14191 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14193 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14194 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14195 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14196 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14198 +#define vx_rss_avail(m, p) \
14199 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14203 + VXPT_UNKNOWN = 0,
14212 +#define vx_page_fault(mm, vma, type, ret)
14216 +void __vx_page_fault(struct mm_struct *mm,
14217 + struct vm_area_struct *vma, int type, int ret)
14219 + struct vx_info *vxi = mm->mm_vx_info;
14222 + static char *page_type[6] =
14223 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14224 + static char *page_what[4] =
14225 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14231 + what = (ret & 0x3);
14233 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14234 + type, what, ret, page_type[type], page_what[what]);
14236 + if (ret & VM_FAULT_WRITE)
14238 + atomic_inc(&vxi->cacct.page[type][what]);
14241 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14245 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14248 +#warning duplicate inclusion
14250 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_network.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_network.h
14251 --- linux-2.6.32.10/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14252 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_network.h 2009-12-03 20:04:56.000000000 +0100
14254 +#ifndef _NX_VS_NETWORK_H
14255 +#define _NX_VS_NETWORK_H
14257 +#include "vserver/context.h"
14258 +#include "vserver/network.h"
14259 +#include "vserver/base.h"
14260 +#include "vserver/check.h"
14261 +#include "vserver/debug.h"
14263 +#include <linux/sched.h>
14266 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14268 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14269 + const char *_file, int _line)
14274 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14275 + nxi, nxi ? nxi->nx_id : 0,
14276 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14279 + atomic_inc(&nxi->nx_usecnt);
14284 +extern void free_nx_info(struct nx_info *);
14286 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14288 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14293 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14294 + nxi, nxi ? nxi->nx_id : 0,
14295 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14298 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14299 + free_nx_info(nxi);
14303 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14305 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14306 + const char *_file, int _line)
14309 + vxlprintk(VXD_CBIT(nid, 3),
14310 + "init_nx_info(%p[#%d.%d])",
14311 + nxi, nxi ? nxi->nx_id : 0,
14312 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14315 + atomic_inc(&nxi->nx_usecnt);
14321 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14323 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14324 + const char *_file, int _line)
14326 + struct nx_info *nxo;
14331 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14332 + nxi, nxi ? nxi->nx_id : 0,
14333 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14336 + atomic_inc(&nxi->nx_usecnt);
14337 + nxo = xchg(nxp, nxi);
14341 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14343 +static inline void __clr_nx_info(struct nx_info **nxp,
14344 + const char *_file, int _line)
14346 + struct nx_info *nxo;
14348 + nxo = xchg(nxp, NULL);
14352 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14353 + nxo, nxo ? nxo->nx_id : 0,
14354 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14357 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14358 + free_nx_info(nxo);
14362 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14364 +static inline void __claim_nx_info(struct nx_info *nxi,
14365 + struct task_struct *task, const char *_file, int _line)
14367 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14368 + nxi, nxi ? nxi->nx_id : 0,
14369 + nxi?atomic_read(&nxi->nx_usecnt):0,
14370 + nxi?atomic_read(&nxi->nx_tasks):0,
14371 + task, _file, _line);
14373 + atomic_inc(&nxi->nx_tasks);
14377 +extern void unhash_nx_info(struct nx_info *);
14379 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14381 +static inline void __release_nx_info(struct nx_info *nxi,
14382 + struct task_struct *task, const char *_file, int _line)
14384 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14385 + nxi, nxi ? nxi->nx_id : 0,
14386 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14387 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14388 + task, _file, _line);
14392 + if (atomic_dec_and_test(&nxi->nx_tasks))
14393 + unhash_nx_info(nxi);
14397 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14399 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14400 + const char *_file, int _line)
14402 + struct nx_info *nxi;
14405 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14406 + p, _file, _line);
14407 + nxi = __get_nx_info(p->nx_info, _file, _line);
14413 +static inline void exit_nx_info(struct task_struct *p)
14416 + release_nx_info(p->nx_info, p);
14421 +#warning duplicate inclusion
14423 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_pid.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_pid.h
14424 --- linux-2.6.32.10/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14425 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_pid.h 2009-12-03 20:04:56.000000000 +0100
14430 +#include "vserver/base.h"
14431 +#include "vserver/check.h"
14432 +#include "vserver/context.h"
14433 +#include "vserver/debug.h"
14434 +#include "vserver/pid.h"
14435 +#include <linux/pid_namespace.h>
14438 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14441 +int vx_proc_task_visible(struct task_struct *task)
14443 + if ((task->pid == 1) &&
14444 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14445 + /* show a blend through init */
14447 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14454 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14459 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14461 + struct task_struct *task = find_task_by_real_pid(pid);
14463 + if (task && !vx_proc_task_visible(task)) {
14464 + vxdprintk(VXD_CBIT(misc, 6),
14465 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14466 + task, task->xid, task->pid,
14467 + current, current->xid, current->pid);
14476 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14478 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14480 + if (task && !vx_proc_task_visible(task)) {
14481 + vxdprintk(VXD_CBIT(misc, 6),
14482 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14483 + task, task->xid, task->pid,
14484 + current, current->xid, current->pid);
14485 + put_task_struct(task);
14494 +struct task_struct *vx_child_reaper(struct task_struct *p)
14496 + struct vx_info *vxi = p->vx_info;
14497 + struct task_struct *reaper = child_reaper(p);
14502 + BUG_ON(!p->vx_info->vx_reaper);
14504 + /* child reaper for the guest reaper */
14505 + if (vxi->vx_reaper == p)
14508 + reaper = vxi->vx_reaper;
14510 + vxdprintk(VXD_CBIT(xid, 7),
14511 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14512 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14520 +#warning duplicate inclusion
14522 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_sched.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_sched.h
14523 --- linux-2.6.32.10/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14524 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_sched.h 2009-12-03 20:04:56.000000000 +0100
14526 +#ifndef _VS_SCHED_H
14527 +#define _VS_SCHED_H
14529 +#include "vserver/base.h"
14530 +#include "vserver/context.h"
14531 +#include "vserver/sched.h"
14534 +#define VAVAVOOM_RATIO 50
14536 +#define MAX_PRIO_BIAS 20
14537 +#define MIN_PRIO_BIAS -20
14540 +#ifdef CONFIG_VSERVER_HARDCPU
14543 + * effective_prio - return the priority that is based on the static
14544 + * priority but is modified by bonuses/penalties.
14546 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14547 + * into a -4 ... 0 ... +4 bonus/penalty range.
14549 + * Additionally, we scale another amount based on the number of
14550 + * CPU tokens currently held by the context, if the process is
14551 + * part of a context (and the appropriate SCHED flag is set).
14552 + * This ranges from -5 ... 0 ... +15, quadratically.
14554 + * So, the total bonus is -9 .. 0 .. +19
14555 + * We use ~50% of the full 0...39 priority range so that:
14557 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14558 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14559 + * unless that context is far exceeding its CPU allocation.
14561 + * Both properties are important to certain workloads.
14564 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14566 + int vavavoom, max;
14568 + /* lots of tokens = lots of vavavoom
14569 + * no tokens = no vavavoom */
14570 + if ((vavavoom = sched_pc->tokens) >= 0) {
14571 + max = sched_pc->tokens_max;
14572 + vavavoom = max - vavavoom;
14574 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14575 + * (vavavoom*vavavoom - (max >> 2)) / max;
14583 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14585 + struct vx_info *vxi = p->vx_info;
14586 + struct _vx_sched_pc *sched_pc;
14591 + sched_pc = &vx_cpu(vxi, sched_pc);
14592 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14593 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14595 + sched_pc->vavavoom = vavavoom;
14596 + prio += vavavoom;
14598 + prio += sched_pc->prio_bias;
14602 +#else /* !CONFIG_VSERVER_HARDCPU */
14605 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14607 + struct vx_info *vxi = p->vx_info;
14610 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14614 +#endif /* CONFIG_VSERVER_HARDCPU */
14617 +static inline void vx_account_user(struct vx_info *vxi,
14618 + cputime_t cputime, int nice)
14622 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14625 +static inline void vx_account_system(struct vx_info *vxi,
14626 + cputime_t cputime, int idle)
14630 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14634 +#warning duplicate inclusion
14636 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_socket.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_socket.h
14637 --- linux-2.6.32.10/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14638 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_socket.h 2009-12-03 20:04:56.000000000 +0100
14640 +#ifndef _VS_SOCKET_H
14641 +#define _VS_SOCKET_H
14643 +#include "vserver/debug.h"
14644 +#include "vserver/base.h"
14645 +#include "vserver/cacct.h"
14646 +#include "vserver/context.h"
14647 +#include "vserver/tag.h"
14650 +/* socket accounting */
14652 +#include <linux/socket.h>
14654 +static inline int vx_sock_type(int family)
14656 + switch (family) {
14658 + return VXA_SOCK_UNSPEC;
14660 + return VXA_SOCK_UNIX;
14662 + return VXA_SOCK_INET;
14664 + return VXA_SOCK_INET6;
14666 + return VXA_SOCK_PACKET;
14668 + return VXA_SOCK_OTHER;
14672 +#define vx_acc_sock(v, f, p, s) \
14673 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14675 +static inline void __vx_acc_sock(struct vx_info *vxi,
14676 + int family, int pos, int size, char *file, int line)
14679 + int type = vx_sock_type(family);
14681 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14682 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14686 +#define vx_sock_recv(sk, s) \
14687 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14688 +#define vx_sock_send(sk, s) \
14689 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14690 +#define vx_sock_fail(sk, s) \
14691 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14694 +#define sock_vx_init(s) do { \
14695 + (s)->sk_xid = 0; \
14696 + (s)->sk_vx_info = NULL; \
14699 +#define sock_nx_init(s) do { \
14700 + (s)->sk_nid = 0; \
14701 + (s)->sk_nx_info = NULL; \
14705 +#warning duplicate inclusion
14707 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_tag.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_tag.h
14708 --- linux-2.6.32.10/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14709 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_tag.h 2009-12-03 20:04:56.000000000 +0100
14714 +#include <linux/vserver/tag.h>
14716 +/* check conditions */
14718 +#define DX_ADMIN 0x0001
14719 +#define DX_WATCH 0x0002
14720 +#define DX_HOSTID 0x0008
14722 +#define DX_IDENT 0x0010
14724 +#define DX_ARG_MASK 0x0010
14727 +#define dx_task_tag(t) ((t)->tag)
14729 +#define dx_current_tag() dx_task_tag(current)
14731 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14733 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14737 + * check current context for ADMIN/WATCH and
14738 + * optionally against supplied argument
14740 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14742 + if (mode & DX_ARG_MASK) {
14743 + if ((mode & DX_IDENT) && (id == cid))
14746 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14747 + ((mode & DX_WATCH) && (cid == 1)) ||
14748 + ((mode & DX_HOSTID) && (id == 0)));
14752 +int dx_permission(const struct inode *inode, int mask);
14756 +#warning duplicate inclusion
14758 diff -NurpP --minimal linux-2.6.32.10/include/linux/vs_time.h linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_time.h
14759 --- linux-2.6.32.10/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14760 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/linux/vs_time.h 2009-12-03 20:04:56.000000000 +0100
14762 +#ifndef _VS_TIME_H
14763 +#define _VS_TIME_H
14766 +/* time faking stuff */
14768 +#ifdef CONFIG_VSERVER_VTIME
14770 +extern void vx_gettimeofday(struct timeval *tv);
14771 +extern int vx_settimeofday(struct timespec *ts);
14774 +#define vx_gettimeofday(t) do_gettimeofday(t)
14775 +#define vx_settimeofday(t) do_settimeofday(t)
14779 +#warning duplicate inclusion
14781 diff -NurpP --minimal linux-2.6.32.10/include/net/addrconf.h linux-2.6.32.10-vs2.3.0.36.29.2/include/net/addrconf.h
14782 --- linux-2.6.32.10/include/net/addrconf.h 2009-12-03 20:02:57.000000000 +0100
14783 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/net/addrconf.h 2009-12-03 20:04:56.000000000 +0100
14784 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14785 struct net_device *dev,
14786 const struct in6_addr *daddr,
14787 unsigned int srcprefs,
14788 - struct in6_addr *saddr);
14789 + struct in6_addr *saddr,
14790 + struct nx_info *nxi);
14791 extern int ipv6_get_lladdr(struct net_device *dev,
14792 struct in6_addr *addr,
14793 unsigned char banned_flags);
14794 diff -NurpP --minimal linux-2.6.32.10/include/net/af_unix.h linux-2.6.32.10-vs2.3.0.36.29.2/include/net/af_unix.h
14795 --- linux-2.6.32.10/include/net/af_unix.h 2008-12-25 00:26:37.000000000 +0100
14796 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/net/af_unix.h 2009-12-03 20:04:56.000000000 +0100
14798 #include <linux/socket.h>
14799 #include <linux/un.h>
14800 #include <linux/mutex.h>
14801 +#include <linux/vs_base.h>
14802 #include <net/sock.h>
14804 extern void unix_inflight(struct file *fp);
14805 diff -NurpP --minimal linux-2.6.32.10/include/net/inet_timewait_sock.h linux-2.6.32.10-vs2.3.0.36.29.2/include/net/inet_timewait_sock.h
14806 --- linux-2.6.32.10/include/net/inet_timewait_sock.h 2009-12-03 20:02:57.000000000 +0100
14807 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/net/inet_timewait_sock.h 2009-12-03 20:04:56.000000000 +0100
14808 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14809 #define tw_hash __tw_common.skc_hash
14810 #define tw_prot __tw_common.skc_prot
14811 #define tw_net __tw_common.skc_net
14812 +#define tw_xid __tw_common.skc_xid
14813 +#define tw_vx_info __tw_common.skc_vx_info
14814 +#define tw_nid __tw_common.skc_nid
14815 +#define tw_nx_info __tw_common.skc_nx_info
14817 volatile unsigned char tw_substate;
14818 /* 3 bits hole, try to pack */
14819 diff -NurpP --minimal linux-2.6.32.10/include/net/route.h linux-2.6.32.10-vs2.3.0.36.29.2/include/net/route.h
14820 --- linux-2.6.32.10/include/net/route.h 2009-09-10 15:26:27.000000000 +0200
14821 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/net/route.h 2009-12-03 20:04:56.000000000 +0100
14822 @@ -135,6 +135,9 @@ static inline void ip_rt_put(struct rtab
14823 dst_release(&rt->u.dst);
14826 +#include <linux/vs_base.h>
14827 +#include <linux/vs_inet.h>
14829 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14831 extern const __u8 ip_tos2prio[16];
14832 @@ -144,6 +147,9 @@ static inline char rt_tos2priority(u8 to
14833 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14836 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14837 + struct rtable **, struct flowi *);
14839 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14840 __be32 src, u32 tos, int oif, u8 protocol,
14841 __be16 sport, __be16 dport, struct sock *sk,
14842 @@ -161,11 +167,24 @@ static inline int ip_route_connect(struc
14845 struct net *net = sock_net(sk);
14846 + struct nx_info *nx_info = current_nx_info();
14848 if (inet_sk(sk)->transparent)
14849 fl.flags |= FLOWI_FLAG_ANYSRC;
14851 - if (!dst || !src) {
14853 + nx_info = sk->sk_nx_info;
14855 + vxdprintk(VXD_CBIT(net, 4),
14856 + "ip_route_connect(%p) %p,%p;%lx",
14857 + sk, nx_info, sk->sk_socket,
14858 + (sk->sk_socket?sk->sk_socket->flags:0));
14860 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14864 + if (!fl.fl4_dst || !fl.fl4_src) {
14865 err = __ip_route_output_key(net, rp, &fl);
14868 diff -NurpP --minimal linux-2.6.32.10/include/net/sock.h linux-2.6.32.10-vs2.3.0.36.29.2/include/net/sock.h
14869 --- linux-2.6.32.10/include/net/sock.h 2009-12-03 20:02:57.000000000 +0100
14870 +++ linux-2.6.32.10-vs2.3.0.36.29.2/include/net/sock.h 2009-12-03 20:04:56.000000000 +0100
14871 @@ -139,6 +139,10 @@ struct sock_common {
14872 #ifdef CONFIG_NET_NS
14873 struct net *skc_net;
14876 + struct vx_info *skc_vx_info;
14878 + struct nx_info *skc_nx_info;
14882 @@ -225,6 +229,10 @@ struct sock {
14883 #define sk_bind_node __sk_common.skc_bind_node
14884 #define sk_prot __sk_common.skc_prot
14885 #define sk_net __sk_common.skc_net
14886 +#define sk_xid __sk_common.skc_xid
14887 +#define sk_vx_info __sk_common.skc_vx_info
14888 +#define sk_nid __sk_common.skc_nid
14889 +#define sk_nx_info __sk_common.skc_nx_info
14890 kmemcheck_bitfield_begin(flags);
14891 unsigned int sk_shutdown : 2,
14893 diff -NurpP --minimal linux-2.6.32.10/init/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/init/Kconfig
14894 --- linux-2.6.32.10/init/Kconfig 2009-12-03 20:02:57.000000000 +0100
14895 +++ linux-2.6.32.10-vs2.3.0.36.29.2/init/Kconfig 2009-12-03 20:04:56.000000000 +0100
14896 @@ -477,6 +477,19 @@ config CGROUP_SCHED
14900 +config CFS_HARD_LIMITS
14901 + bool "Hard Limits for CFS Group Scheduler"
14902 + depends on EXPERIMENTAL
14903 + depends on FAIR_GROUP_SCHED && CGROUP_SCHED
14906 + This option enables hard limiting of CPU time obtained by
14907 + a fair task group. Use this if you want to throttle a group of tasks
14908 + based on its CPU usage. For more details refer to
14909 + Documentation/scheduler/sched-cfs-hard-limits.txt
14914 boolean "Control Group support"
14916 diff -NurpP --minimal linux-2.6.32.10/init/main.c linux-2.6.32.10-vs2.3.0.36.29.2/init/main.c
14917 --- linux-2.6.32.10/init/main.c 2009-12-03 20:02:57.000000000 +0100
14918 +++ linux-2.6.32.10-vs2.3.0.36.29.2/init/main.c 2009-12-03 20:04:56.000000000 +0100
14920 #include <linux/sfi.h>
14921 #include <linux/shmem_fs.h>
14922 #include <trace/boot.h>
14923 +#include <linux/vserver/percpu.h>
14925 #include <asm/io.h>
14926 #include <asm/bugs.h>
14927 diff -NurpP --minimal linux-2.6.32.10/ipc/mqueue.c linux-2.6.32.10-vs2.3.0.36.29.2/ipc/mqueue.c
14928 --- linux-2.6.32.10/ipc/mqueue.c 2009-12-03 20:02:57.000000000 +0100
14929 +++ linux-2.6.32.10-vs2.3.0.36.29.2/ipc/mqueue.c 2009-12-03 20:04:56.000000000 +0100
14931 #include <linux/pid.h>
14932 #include <linux/ipc_namespace.h>
14933 #include <linux/ima.h>
14934 +#include <linux/vs_context.h>
14935 +#include <linux/vs_limit.h>
14937 #include <net/sock.h>
14939 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14940 struct sigevent notify;
14941 struct pid* notify_owner;
14942 struct user_struct *user; /* user who created, for accounting */
14943 + struct vx_info *vxi;
14944 struct sock *notify_sock;
14945 struct sk_buff *notify_cookie;
14947 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
14948 if (S_ISREG(mode)) {
14949 struct mqueue_inode_info *info;
14950 struct task_struct *p = current;
14951 + struct vx_info *vxi = p->vx_info;
14952 unsigned long mq_bytes, mq_msg_tblsz;
14954 inode->i_fop = &mqueue_file_operations;
14955 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14956 info->notify_owner = NULL;
14958 info->user = NULL; /* set when all is ok */
14959 + info->vxi = NULL;
14960 memset(&info->attr, 0, sizeof(info->attr));
14961 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14962 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14963 @@ -153,22 +158,26 @@ static struct inode *mqueue_get_inode(st
14964 spin_lock(&mq_lock);
14965 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14966 u->mq_bytes + mq_bytes >
14967 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14968 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14969 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14970 spin_unlock(&mq_lock);
14973 u->mq_bytes += mq_bytes;
14974 + vx_ipcmsg_add(vxi, u, mq_bytes);
14975 spin_unlock(&mq_lock);
14977 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14978 if (!info->messages) {
14979 spin_lock(&mq_lock);
14980 u->mq_bytes -= mq_bytes;
14981 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14982 spin_unlock(&mq_lock);
14986 info->user = get_uid(u);
14987 + info->vxi = get_vx_info(vxi);
14988 } else if (S_ISDIR(mode)) {
14990 /* Some things misbehave if size == 0 on a directory */
14991 @@ -269,8 +278,11 @@ static void mqueue_delete_inode(struct i
14992 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14995 + struct vx_info *vxi = info->vxi;
14997 spin_lock(&mq_lock);
14998 user->mq_bytes -= mq_bytes;
14999 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15001 * get_ns_from_inode() ensures that the
15002 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
15003 @@ -280,6 +292,7 @@ static void mqueue_delete_inode(struct i
15005 ipc_ns->mq_queues_count--;
15006 spin_unlock(&mq_lock);
15007 + put_vx_info(vxi);
15011 diff -NurpP --minimal linux-2.6.32.10/ipc/msg.c linux-2.6.32.10-vs2.3.0.36.29.2/ipc/msg.c
15012 --- linux-2.6.32.10/ipc/msg.c 2010-03-18 16:17:37.000000000 +0100
15013 +++ linux-2.6.32.10-vs2.3.0.36.29.2/ipc/msg.c 2010-02-12 10:59:55.000000000 +0100
15015 #include <linux/rwsem.h>
15016 #include <linux/nsproxy.h>
15017 #include <linux/ipc_namespace.h>
15018 +#include <linux/vs_base.h>
15020 #include <asm/current.h>
15021 #include <asm/uaccess.h>
15022 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
15024 msq->q_perm.mode = msgflg & S_IRWXUGO;
15025 msq->q_perm.key = key;
15026 + msq->q_perm.xid = vx_current_xid();
15028 msq->q_perm.security = NULL;
15029 retval = security_msg_queue_alloc(msq);
15030 diff -NurpP --minimal linux-2.6.32.10/ipc/namespace.c linux-2.6.32.10-vs2.3.0.36.29.2/ipc/namespace.c
15031 --- linux-2.6.32.10/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
15032 +++ linux-2.6.32.10-vs2.3.0.36.29.2/ipc/namespace.c 2009-12-03 20:04:56.000000000 +0100
15034 #include <linux/slab.h>
15035 #include <linux/fs.h>
15036 #include <linux/mount.h>
15037 +#include <linux/vs_base.h>
15038 +#include <linux/vserver/global.h>
15042 diff -NurpP --minimal linux-2.6.32.10/ipc/sem.c linux-2.6.32.10-vs2.3.0.36.29.2/ipc/sem.c
15043 --- linux-2.6.32.10/ipc/sem.c 2010-03-18 16:17:37.000000000 +0100
15044 +++ linux-2.6.32.10-vs2.3.0.36.29.2/ipc/sem.c 2010-02-12 10:59:55.000000000 +0100
15046 #include <linux/rwsem.h>
15047 #include <linux/nsproxy.h>
15048 #include <linux/ipc_namespace.h>
15049 +#include <linux/vs_base.h>
15050 +#include <linux/vs_limit.h>
15052 #include <asm/uaccess.h>
15054 @@ -256,6 +258,7 @@ static int newary(struct ipc_namespace *
15056 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15057 sma->sem_perm.key = key;
15058 + sma->sem_perm.xid = vx_current_xid();
15060 sma->sem_perm.security = NULL;
15061 retval = security_sem_alloc(sma);
15062 @@ -271,6 +274,9 @@ static int newary(struct ipc_namespace *
15065 ns->used_sems += nsems;
15066 + /* FIXME: obsoleted? */
15067 + vx_semary_inc(sma);
15068 + vx_nsems_add(sma, nsems);
15070 sma->sem_base = (struct sem *) &sma[1];
15071 INIT_LIST_HEAD(&sma->sem_pending);
15072 @@ -547,6 +553,9 @@ static void freeary(struct ipc_namespace
15075 ns->used_sems -= sma->sem_nsems;
15076 + /* FIXME: obsoleted? */
15077 + vx_nsems_sub(sma, sma->sem_nsems);
15078 + vx_semary_dec(sma);
15079 security_sem_free(sma);
15080 ipc_rcu_putref(sma);
15082 diff -NurpP --minimal linux-2.6.32.10/ipc/shm.c linux-2.6.32.10-vs2.3.0.36.29.2/ipc/shm.c
15083 --- linux-2.6.32.10/ipc/shm.c 2010-03-18 16:17:37.000000000 +0100
15084 +++ linux-2.6.32.10-vs2.3.0.36.29.2/ipc/shm.c 2010-02-12 10:59:55.000000000 +0100
15086 #include <linux/mount.h>
15087 #include <linux/ipc_namespace.h>
15088 #include <linux/ima.h>
15089 +#include <linux/vs_context.h>
15090 +#include <linux/vs_limit.h>
15092 #include <asm/uaccess.h>
15094 @@ -170,7 +172,12 @@ static void shm_open(struct vm_area_stru
15096 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15098 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15099 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15100 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15102 + vx_ipcshm_sub(vxi, shp, numpages);
15103 + ns->shm_tot -= numpages;
15107 if (!is_file_hugepages(shp->shm_file))
15108 @@ -180,6 +187,7 @@ static void shm_destroy(struct ipc_names
15110 fput (shp->shm_file);
15111 security_shm_free(shp);
15112 + put_vx_info(vxi);
15113 ipc_rcu_putref(shp);
15116 @@ -350,11 +358,15 @@ static int newseg(struct ipc_namespace *
15117 if (ns->shm_tot + numpages > ns->shm_ctlall)
15120 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
15123 shp = ipc_rcu_alloc(sizeof(*shp));
15127 shp->shm_perm.key = key;
15128 + shp->shm_perm.xid = vx_current_xid();
15129 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15130 shp->mlock_user = NULL;
15132 @@ -408,6 +420,7 @@ static int newseg(struct ipc_namespace *
15133 ns->shm_tot += numpages;
15134 error = shp->shm_perm.id;
15136 + vx_ipcshm_add(current_vx_info(), key, numpages);
15140 diff -NurpP --minimal linux-2.6.32.10/kernel/capability.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/capability.c
15141 --- linux-2.6.32.10/kernel/capability.c 2009-03-24 14:22:44.000000000 +0100
15142 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/capability.c 2009-12-03 20:04:56.000000000 +0100
15144 #include <linux/security.h>
15145 #include <linux/syscalls.h>
15146 #include <linux/pid_namespace.h>
15147 +#include <linux/vs_context.h>
15148 #include <asm/uaccess.h>
15149 #include "cred-internals.h"
15151 @@ -122,6 +123,7 @@ static int cap_validate_magic(cap_user_h
15157 * The only thing that can change the capabilities of the current
15158 * process is the current process. As such, we can't be in this code
15159 @@ -289,6 +291,8 @@ error:
15163 +#include <linux/vserver/base.h>
15166 * capable - Determine if the current task has a superior capability in effect
15167 * @cap: The capability to be tested for
15168 @@ -301,6 +305,9 @@ error:
15170 int capable(int cap)
15172 + /* here for now so we don't require task locking */
15173 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15175 if (unlikely(!cap_valid(cap))) {
15176 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15178 diff -NurpP --minimal linux-2.6.32.10/kernel/compat.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/compat.c
15179 --- linux-2.6.32.10/kernel/compat.c 2009-09-10 15:26:27.000000000 +0200
15180 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/compat.c 2009-12-03 20:04:56.000000000 +0100
15181 @@ -902,7 +902,7 @@ asmlinkage long compat_sys_time(compat_t
15185 - do_gettimeofday(&tv);
15186 + vx_gettimeofday(&tv);
15190 @@ -927,7 +927,7 @@ asmlinkage long compat_sys_stime(compat_
15194 - do_settimeofday(&tv);
15195 + vx_settimeofday(&tv);
15199 diff -NurpP --minimal linux-2.6.32.10/kernel/exit.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/exit.c
15200 --- linux-2.6.32.10/kernel/exit.c 2009-12-03 20:02:57.000000000 +0100
15201 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/exit.c 2009-12-03 20:04:56.000000000 +0100
15203 #include <linux/fs_struct.h>
15204 #include <linux/init_task.h>
15205 #include <linux/perf_event.h>
15206 +#include <linux/vs_limit.h>
15207 +#include <linux/vs_context.h>
15208 +#include <linux/vs_network.h>
15209 +#include <linux/vs_pid.h>
15210 #include <trace/events/sched.h>
15212 #include <asm/uaccess.h>
15213 @@ -488,9 +492,11 @@ static void close_files(struct files_str
15214 filp_close(file, files);
15217 + vx_openfd_dec(i);
15225 @@ -1011,11 +1017,16 @@ NORET_TYPE void do_exit(long code)
15227 validate_creds_for_do_exit(tsk);
15229 + /* needs to stay after exit_notify() */
15230 + exit_vx_info(tsk, code);
15231 + exit_nx_info(tsk);
15235 /* causes final put_task_struct in finish_task_switch(). */
15236 tsk->state = TASK_DEAD;
15238 + printk("bad task: %p [%lx]\n", current, current->state);
15240 /* Avoid "noreturn function does return". */
15242 diff -NurpP --minimal linux-2.6.32.10/kernel/fork.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/fork.c
15243 --- linux-2.6.32.10/kernel/fork.c 2009-12-03 20:02:57.000000000 +0100
15244 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/fork.c 2009-12-03 20:04:56.000000000 +0100
15246 #include <linux/magic.h>
15247 #include <linux/perf_event.h>
15248 #include <linux/posix-timers.h>
15249 +#include <linux/vs_context.h>
15250 +#include <linux/vs_network.h>
15251 +#include <linux/vs_limit.h>
15252 +#include <linux/vs_memory.h>
15254 #include <asm/pgtable.h>
15255 #include <asm/pgalloc.h>
15256 @@ -151,6 +155,8 @@ void free_task(struct task_struct *tsk)
15257 account_kernel_stack(tsk->stack, -1);
15258 free_thread_info(tsk->stack);
15259 rt_mutex_debug_task_free(tsk);
15260 + clr_vx_info(&tsk->vx_info);
15261 + clr_nx_info(&tsk->nx_info);
15262 ftrace_graph_exit_task(tsk);
15263 free_task_struct(tsk);
15265 @@ -296,6 +302,8 @@ static int dup_mmap(struct mm_struct *mm
15266 mm->free_area_cache = oldmm->mmap_base;
15267 mm->cached_hole_size = ~0UL;
15269 + __set_mm_counter(mm, file_rss, 0);
15270 + __set_mm_counter(mm, anon_rss, 0);
15271 cpumask_clear(mm_cpumask(mm));
15272 mm->mm_rb = RB_ROOT;
15273 rb_link = &mm->mm_rb.rb_node;
15274 @@ -310,7 +318,7 @@ static int dup_mmap(struct mm_struct *mm
15276 if (mpnt->vm_flags & VM_DONTCOPY) {
15277 long pages = vma_pages(mpnt);
15278 - mm->total_vm -= pages;
15279 + vx_vmpages_sub(mm, pages);
15280 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15283 @@ -452,8 +460,8 @@ static struct mm_struct * mm_init(struct
15284 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
15285 mm->core_state = NULL;
15287 - set_mm_counter(mm, file_rss, 0);
15288 - set_mm_counter(mm, anon_rss, 0);
15289 + __set_mm_counter(mm, file_rss, 0);
15290 + __set_mm_counter(mm, anon_rss, 0);
15291 spin_lock_init(&mm->page_table_lock);
15292 mm->free_area_cache = TASK_UNMAPPED_BASE;
15293 mm->cached_hole_size = ~0UL;
15294 @@ -463,6 +471,7 @@ static struct mm_struct * mm_init(struct
15295 if (likely(!mm_alloc_pgd(mm))) {
15297 mmu_notifier_mm_init(mm);
15298 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15302 @@ -496,6 +505,7 @@ void __mmdrop(struct mm_struct *mm)
15304 destroy_context(mm);
15305 mmu_notifier_mm_destroy(mm);
15306 + clr_vx_info(&mm->mm_vx_info);
15309 EXPORT_SYMBOL_GPL(__mmdrop);
15310 @@ -631,6 +641,7 @@ struct mm_struct *dup_mm(struct task_str
15313 memcpy(mm, oldmm, sizeof(*mm));
15314 + mm->mm_vx_info = NULL;
15316 /* Initializing for Swap token stuff */
15317 mm->token_priority = 0;
15318 @@ -669,6 +680,7 @@ fail_nocontext:
15319 * If init_new_context() failed, we cannot use mmput() to free the mm
15320 * because it calls destroy_context()
15322 + clr_vx_info(&mm->mm_vx_info);
15326 @@ -980,6 +992,8 @@ static struct task_struct *copy_process(
15328 struct task_struct *p;
15329 int cgroup_callbacks_done = 0;
15330 + struct vx_info *vxi;
15331 + struct nx_info *nxi;
15333 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15334 return ERR_PTR(-EINVAL);
15335 @@ -1026,12 +1040,28 @@ static struct task_struct *copy_process(
15336 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15337 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15339 + init_vx_info(&p->vx_info, current_vx_info());
15340 + init_nx_info(&p->nx_info, current_nx_info());
15342 + /* check vserver memory */
15343 + if (p->mm && !(clone_flags & CLONE_VM)) {
15344 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15345 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15347 + goto bad_fork_free;
15349 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15350 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15351 + goto bad_fork_cleanup_vm;
15354 + if (!vx_nproc_avail(1))
15355 + goto bad_fork_cleanup_vm;
15356 if (atomic_read(&p->real_cred->user->processes) >=
15357 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15358 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15359 p->real_cred->user != INIT_USER)
15360 - goto bad_fork_free;
15361 + goto bad_fork_cleanup_vm;
15364 retval = copy_creds(p, clone_flags);
15365 @@ -1300,6 +1330,18 @@ static struct task_struct *copy_process(
15368 spin_unlock(¤t->sighand->siglock);
15370 + /* p is copy of current */
15371 + vxi = p->vx_info;
15373 + claim_vx_info(vxi, p);
15374 + atomic_inc(&vxi->cvirt.nr_threads);
15375 + atomic_inc(&vxi->cvirt.total_forks);
15378 + nxi = p->nx_info;
15380 + claim_nx_info(nxi, p);
15381 write_unlock_irq(&tasklist_lock);
15382 proc_fork_connector(p);
15383 cgroup_post_fork(p);
15384 @@ -1341,6 +1383,9 @@ bad_fork_cleanup_cgroup:
15385 bad_fork_cleanup_count:
15386 atomic_dec(&p->cred->user->processes);
15388 +bad_fork_cleanup_vm:
15389 + if (p->mm && !(clone_flags & CLONE_VM))
15390 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15394 diff -NurpP --minimal linux-2.6.32.10/kernel/kthread.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/kthread.c
15395 --- linux-2.6.32.10/kernel/kthread.c 2009-12-03 20:02:58.000000000 +0100
15396 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/kthread.c 2009-12-03 20:04:56.000000000 +0100
15398 #include <linux/file.h>
15399 #include <linux/module.h>
15400 #include <linux/mutex.h>
15401 +#include <linux/vs_pid.h>
15402 #include <trace/events/sched.h>
15404 static DEFINE_SPINLOCK(kthread_create_lock);
15405 diff -NurpP --minimal linux-2.6.32.10/kernel/Makefile linux-2.6.32.10-vs2.3.0.36.29.2/kernel/Makefile
15406 --- linux-2.6.32.10/kernel/Makefile 2009-12-03 20:02:57.000000000 +0100
15407 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/Makefile 2009-12-03 20:04:56.000000000 +0100
15408 @@ -23,6 +23,7 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
15409 CFLAGS_REMOVE_sched_clock.o = -pg
15413 obj-$(CONFIG_FREEZER) += freezer.o
15414 obj-$(CONFIG_PROFILING) += profile.o
15415 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15416 diff -NurpP --minimal linux-2.6.32.10/kernel/nsproxy.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/nsproxy.c
15417 --- linux-2.6.32.10/kernel/nsproxy.c 2009-09-10 15:26:28.000000000 +0200
15418 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/nsproxy.c 2009-12-03 20:04:56.000000000 +0100
15420 #include <linux/mnt_namespace.h>
15421 #include <linux/utsname.h>
15422 #include <linux/pid_namespace.h>
15423 +#include <linux/vserver/global.h>
15424 +#include <linux/vserver/debug.h>
15425 #include <net/net_namespace.h>
15426 #include <linux/ipc_namespace.h>
15428 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
15429 struct nsproxy *nsproxy;
15431 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15434 atomic_set(&nsproxy->count, 1);
15435 + atomic_inc(&vs_global_nsproxy);
15437 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15441 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
15442 * Return the newly created nsproxy. Do not attach this to the task,
15443 * leave it to the caller to do proper locking and attach it to task.
15445 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15446 - struct task_struct *tsk, struct fs_struct *new_fs)
15447 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15448 + struct nsproxy *orig, struct fs_struct *new_fs)
15450 struct nsproxy *new_nsp;
15453 + vxdprintk(VXD_CBIT(space, 4),
15454 + "unshare_namespaces(0x%08lx,%p,%p)",
15455 + flags, orig, new_fs);
15457 new_nsp = create_nsproxy();
15459 return ERR_PTR(-ENOMEM);
15461 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15462 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15463 if (IS_ERR(new_nsp->mnt_ns)) {
15464 err = PTR_ERR(new_nsp->mnt_ns);
15468 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15469 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15470 if (IS_ERR(new_nsp->uts_ns)) {
15471 err = PTR_ERR(new_nsp->uts_ns);
15475 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15476 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15477 if (IS_ERR(new_nsp->ipc_ns)) {
15478 err = PTR_ERR(new_nsp->ipc_ns);
15482 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15483 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15484 if (IS_ERR(new_nsp->pid_ns)) {
15485 err = PTR_ERR(new_nsp->pid_ns);
15489 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15491 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15492 + if (IS_ERR(new_nsp->user_ns)) {
15493 + err = PTR_ERR(new_nsp->user_ns);
15497 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15498 if (IS_ERR(new_nsp->net_ns)) {
15499 err = PTR_ERR(new_nsp->net_ns);
15501 @@ -100,6 +116,38 @@ out_ns:
15502 return ERR_PTR(err);
15505 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15506 + struct fs_struct *new_fs)
15508 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15512 + * copies the nsproxy, setting refcount to 1, and grabbing a
15513 + * reference to all contained namespaces.
15515 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15517 + struct nsproxy *ns = create_nsproxy();
15520 + memcpy(ns, orig, sizeof(struct nsproxy));
15521 + atomic_set(&ns->count, 1);
15524 + get_mnt_ns(ns->mnt_ns);
15526 + get_uts_ns(ns->uts_ns);
15528 + get_ipc_ns(ns->ipc_ns);
15530 + get_pid_ns(ns->pid_ns);
15532 + get_net(ns->net_ns);
15538 * called from clone. This now handles copy for nsproxy and all
15539 * namespaces therein.
15540 @@ -107,9 +155,12 @@ out_ns:
15541 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15543 struct nsproxy *old_ns = tsk->nsproxy;
15544 - struct nsproxy *new_ns;
15545 + struct nsproxy *new_ns = NULL;
15548 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15549 + flags, tsk, old_ns);
15554 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
15555 CLONE_NEWPID | CLONE_NEWNET)))
15558 - if (!capable(CAP_SYS_ADMIN)) {
15559 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15563 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
15566 put_nsproxy(old_ns);
15567 + vxdprintk(VXD_CBIT(space, 3),
15568 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15569 + flags, tsk, old_ns, err, new_ns);
15573 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
15574 put_ipc_ns(ns->ipc_ns);
15576 put_pid_ns(ns->pid_ns);
15577 - put_net(ns->net_ns);
15579 + put_net(ns->net_ns);
15580 + atomic_dec(&vs_global_nsproxy);
15581 kmem_cache_free(nsproxy_cachep, ns);
15584 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned
15588 + vxdprintk(VXD_CBIT(space, 4),
15589 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15590 + unshare_flags, current->nsproxy);
15592 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15596 - if (!capable(CAP_SYS_ADMIN))
15597 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15600 *new_nsp = create_new_namespaces(unshare_flags, current,
15601 diff -NurpP --minimal linux-2.6.32.10/kernel/pid.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/pid.c
15602 --- linux-2.6.32.10/kernel/pid.c 2009-12-03 20:02:58.000000000 +0100
15603 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/pid.c 2009-12-03 20:04:56.000000000 +0100
15605 #include <linux/pid_namespace.h>
15606 #include <linux/init_task.h>
15607 #include <linux/syscalls.h>
15608 +#include <linux/vs_pid.h>
15610 #define pid_hashfn(nr, ns) \
15611 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15612 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15614 struct pid *find_vpid(int nr)
15616 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15617 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15619 EXPORT_SYMBOL_GPL(find_vpid);
15621 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
15622 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15624 struct task_struct *result = NULL;
15626 + if (type == PIDTYPE_REALPID)
15627 + type = PIDTYPE_PID;
15629 struct hlist_node *first;
15630 first = rcu_dereference(pid->tasks[type].first);
15631 @@ -380,7 +384,7 @@ EXPORT_SYMBOL(pid_task);
15633 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15635 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15636 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15639 struct task_struct *find_task_by_vpid(pid_t vnr)
15640 @@ -422,7 +426,7 @@ struct pid *find_get_pid(pid_t nr)
15642 EXPORT_SYMBOL_GPL(find_get_pid);
15644 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15645 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15649 @@ -435,6 +439,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15653 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15655 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15658 pid_t pid_vnr(struct pid *pid)
15660 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15661 diff -NurpP --minimal linux-2.6.32.10/kernel/pid_namespace.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/pid_namespace.c
15662 --- linux-2.6.32.10/kernel/pid_namespace.c 2009-12-03 20:02:58.000000000 +0100
15663 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/pid_namespace.c 2009-12-03 20:04:56.000000000 +0100
15665 #include <linux/syscalls.h>
15666 #include <linux/err.h>
15667 #include <linux/acct.h>
15668 +#include <linux/vserver/global.h>
15670 #define BITS_PER_PAGE (PAGE_SIZE*8)
15672 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
15675 kref_init(&ns->kref);
15676 + atomic_inc(&vs_global_pid_ns);
15678 ns->parent = get_pid_ns(parent_pid_ns);
15680 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
15682 for (i = 0; i < PIDMAP_ENTRIES; i++)
15683 kfree(ns->pidmap[i].page);
15684 + atomic_dec(&vs_global_pid_ns);
15685 kmem_cache_free(pid_ns_cachep, ns);
15688 diff -NurpP --minimal linux-2.6.32.10/kernel/posix-timers.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/posix-timers.c
15689 --- linux-2.6.32.10/kernel/posix-timers.c 2009-12-03 20:02:58.000000000 +0100
15690 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/posix-timers.c 2009-12-03 20:04:56.000000000 +0100
15692 #include <linux/wait.h>
15693 #include <linux/workqueue.h>
15694 #include <linux/module.h>
15695 +#include <linux/vs_context.h>
15698 * Management arrays for POSIX timers. Timers are kept in slab memory
15699 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15701 struct task_struct *task;
15702 int shared, ret = -1;
15705 * FIXME: if ->sigq is queued we can race with
15706 * dequeue_signal()->do_schedule_next_timer().
15707 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15709 task = pid_task(timr->it_pid, PIDTYPE_PID);
15711 + struct vx_info_save vxis;
15712 + struct vx_info *vxi;
15714 + vxi = get_vx_info(task->vx_info);
15715 + enter_vx_info(vxi, &vxis);
15716 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15717 ret = send_sigqueue(timr->sigq, task, shared);
15718 + leave_vx_info(&vxis);
15719 + put_vx_info(vxi);
15723 /* If we failed to send the signal the timer stops. */
15726 diff -NurpP --minimal linux-2.6.32.10/kernel/printk.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/printk.c
15727 --- linux-2.6.32.10/kernel/printk.c 2009-12-03 20:02:58.000000000 +0100
15728 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/printk.c 2009-12-03 20:04:56.000000000 +0100
15730 #include <linux/bootmem.h>
15731 #include <linux/syscalls.h>
15732 #include <linux/kexec.h>
15733 +#include <linux/vs_cvirt.h>
15735 #include <asm/uaccess.h>
15737 @@ -276,18 +277,13 @@ int do_syslog(int type, char __user *buf
15738 unsigned i, j, limit, count;
15744 error = security_syslog(type);
15749 - case 0: /* Close log */
15751 - case 1: /* Open log */
15753 - case 2: /* Read from log */
15754 + if ((type >= 2) && (type <= 4)) {
15756 if (!buf || len < 0)
15758 @@ -298,6 +294,16 @@ int do_syslog(int type, char __user *buf
15763 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15764 + return vx_do_syslog(type, buf, len);
15767 + case 0: /* Close log */
15769 + case 1: /* Open log */
15771 + case 2: /* Read from log */
15772 error = wait_event_interruptible(log_wait,
15773 (log_start - log_end));
15775 @@ -322,16 +328,6 @@ int do_syslog(int type, char __user *buf
15778 case 3: /* Read last kernel messages */
15780 - if (!buf || len < 0)
15785 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15790 if (count > log_buf_len)
15791 count = log_buf_len;
15792 diff -NurpP --minimal linux-2.6.32.10/kernel/ptrace.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/ptrace.c
15793 --- linux-2.6.32.10/kernel/ptrace.c 2009-12-03 20:02:58.000000000 +0100
15794 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/ptrace.c 2009-12-03 20:04:56.000000000 +0100
15796 #include <linux/pid_namespace.h>
15797 #include <linux/syscalls.h>
15798 #include <linux/uaccess.h>
15799 +#include <linux/vs_context.h>
15803 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
15804 dumpable = get_dumpable(task->mm);
15805 if (!dumpable && !capable(CAP_SYS_PTRACE))
15807 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15809 + if (!vx_check(task->xid, VS_IDENT) &&
15810 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15813 return security_ptrace_access_check(task, mode);
15815 @@ -621,6 +627,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15820 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15821 + goto out_put_task_struct;
15823 if (request == PTRACE_ATTACH) {
15824 ret = ptrace_attach(child);
15826 diff -NurpP --minimal linux-2.6.32.10/kernel/sched.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched.c
15827 --- linux-2.6.32.10/kernel/sched.c 2010-03-18 16:17:37.000000000 +0100
15828 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched.c 2010-03-18 16:53:06.000000000 +0100
15830 #include <linux/debugfs.h>
15831 #include <linux/ctype.h>
15832 #include <linux/ftrace.h>
15833 +#include <linux/vs_sched.h>
15834 +#include <linux/vs_cvirt.h>
15836 #include <asm/tlb.h>
15837 #include <asm/irq_regs.h>
15838 @@ -237,6 +239,15 @@ static DEFINE_MUTEX(sched_domains_mutex)
15840 #include <linux/cgroup.h>
15842 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
15843 +struct cfs_bandwidth {
15844 + spinlock_t cfs_runtime_lock;
15845 + ktime_t cfs_period;
15847 + struct hrtimer cfs_period_timer;
15853 static LIST_HEAD(task_groups);
15854 @@ -257,6 +268,9 @@ struct task_group {
15855 /* runqueue "owned" by this group on each cpu */
15856 struct cfs_rq **cfs_rq;
15857 unsigned long shares;
15858 +#ifdef CONFIG_CFS_HARD_LIMITS
15859 + struct cfs_bandwidth cfs_bandwidth;
15863 #ifdef CONFIG_RT_GROUP_SCHED
15864 @@ -446,6 +460,19 @@ struct cfs_rq {
15865 unsigned long rq_weight;
15868 +#ifdef CONFIG_CFS_HARD_LIMITS
15869 + /* set when the group is throttled on this cpu */
15870 + int cfs_throttled;
15872 + /* runtime currently consumed by the group on this rq */
15875 + /* runtime available to the group on this rq */
15878 + /* Protects the cfs runtime related fields of this cfs_rq */
15879 + spinlock_t cfs_runtime_lock;
15883 /* Real-Time classes' related field in a runqueue: */
15884 @@ -1610,6 +1637,7 @@ static void update_group_shares_cpu(stru
15888 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq);
15890 * Re-compute the task group their per cpu shares over the given domain.
15891 * This needs to be done in a bottom-up fashion because the rq weight of a
15892 @@ -1637,8 +1665,10 @@ static int tg_shares_up(struct task_grou
15893 * If there are currently no tasks on the cpu pretend there
15894 * is one of average load so that when a new task gets to
15895 * run here it will not get delayed by group starvation.
15896 + * Also if the group is throttled on this cpu, pretend that
15897 + * it has no tasks.
15900 + if (!weight || cfs_rq_throttled(tg->cfs_rq[i]))
15901 weight = NICE_0_LOAD;
15903 rq_weight += weight;
15904 @@ -1815,6 +1845,175 @@ static void cfs_rq_set_shares(struct cfs
15905 static void calc_load_account_active(struct rq *this_rq);
15906 static void update_sysctl(void);
15909 +#if defined(CONFIG_RT_GROUP_SCHED) || defined(CONFIG_FAIR_GROUP_SCHED)
15912 +static inline const struct cpumask *sched_bw_period_mask(void)
15914 + return cpu_rq(smp_processor_id())->rd->span;
15916 +#else /* !CONFIG_SMP */
15917 +static inline const struct cpumask *sched_bw_period_mask(void)
15919 + return cpu_online_mask;
15921 +#endif /* CONFIG_SMP */
15924 +static inline const struct cpumask *sched_bw_period_mask(void)
15926 + return cpu_online_mask;
15931 +#ifdef CONFIG_FAIR_GROUP_SCHED
15932 +#ifdef CONFIG_CFS_HARD_LIMITS
15935 + * Runtime allowed for a cfs group before it is hard limited.
15936 + * default: Infinite which means no hard limiting.
15938 +u64 sched_cfs_runtime = RUNTIME_INF;
15941 + * period over which we hard limit the cfs group's bandwidth.
15944 +u64 sched_cfs_period = 500000;
15946 +static inline u64 global_cfs_period(void)
15948 + return sched_cfs_period * NSEC_PER_USEC;
15951 +static inline u64 global_cfs_runtime(void)
15953 + return RUNTIME_INF;
15956 +void do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b);
15958 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
15960 + spin_lock(&cfs_rq->cfs_runtime_lock);
15963 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
15965 + spin_unlock(&cfs_rq->cfs_runtime_lock);
15969 + * Refresh the runtimes of the throttled groups.
15970 + * But nothing much to do now, will populate this in later patches.
15972 +static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)
15974 + struct cfs_bandwidth *cfs_b =
15975 + container_of(timer, struct cfs_bandwidth, cfs_period_timer);
15977 + do_sched_cfs_period_timer(cfs_b);
15978 + hrtimer_add_expires_ns(timer, ktime_to_ns(cfs_b->cfs_period));
15979 + return HRTIMER_RESTART;
15983 + * TODO: Check if this kind of timer setup is sufficient for cfs or
15984 + * should we do what rt is doing.
15986 +static void start_cfs_bandwidth(struct task_group *tg)
15988 + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
15991 + * Timer isn't setup for groups with infinite runtime
15993 + if (cfs_b->cfs_runtime == RUNTIME_INF)
15996 + if (hrtimer_active(&cfs_b->cfs_period_timer))
15999 + hrtimer_start_range_ns(&cfs_b->cfs_period_timer, cfs_b->cfs_period,
16000 + 0, HRTIMER_MODE_REL);
16003 +static void init_cfs_bandwidth(struct task_group *tg)
16005 + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
16007 + cfs_b->cfs_period = ns_to_ktime(global_cfs_period());
16008 + cfs_b->cfs_runtime = global_cfs_runtime();
16010 + spin_lock_init(&cfs_b->cfs_runtime_lock);
16012 + hrtimer_init(&cfs_b->cfs_period_timer,
16013 + CLOCK_MONOTONIC, HRTIMER_MODE_REL);
16014 + cfs_b->cfs_period_timer.function = &sched_cfs_period_timer;
16017 +static inline void destroy_cfs_bandwidth(struct task_group *tg)
16019 + hrtimer_cancel(&tg->cfs_bandwidth.cfs_period_timer);
16022 +static void init_cfs_hard_limits(struct cfs_rq *cfs_rq, struct task_group *tg)
16024 + cfs_rq->cfs_time = 0;
16025 + cfs_rq->cfs_throttled = 0;
16026 + cfs_rq->cfs_runtime = tg->cfs_bandwidth.cfs_runtime;
16027 + spin_lock_init(&cfs_rq->cfs_runtime_lock);
16030 +#else /* !CONFIG_CFS_HARD_LIMITS */
16032 +static void init_cfs_bandwidth(struct task_group *tg)
16037 +static inline void destroy_cfs_bandwidth(struct task_group *tg)
16042 +static void init_cfs_hard_limits(struct cfs_rq *cfs_rq, struct task_group *tg)
16047 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
16052 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
16057 +#endif /* CONFIG_CFS_HARD_LIMITS */
16058 +#else /* !CONFIG_FAIR_GROUP_SCHED */
16060 +static inline void cfs_rq_runtime_lock(struct cfs_rq *cfs_rq)
16065 +static inline void cfs_rq_runtime_unlock(struct cfs_rq *cfs_rq)
16070 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16075 +#endif /* CONFIG_FAIR_GROUP_SCHED */
16077 #include "sched_stats.h"
16078 #include "sched_idletask.c"
16079 #include "sched_fair.c"
16080 @@ -2980,9 +3179,17 @@ EXPORT_SYMBOL(avenrun);
16082 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
16084 - loads[0] = (avenrun[0] + offset) << shift;
16085 - loads[1] = (avenrun[1] + offset) << shift;
16086 - loads[2] = (avenrun[2] + offset) << shift;
16087 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
16088 + struct vx_info *vxi = current_vx_info();
16090 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
16091 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
16092 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
16094 + loads[0] = (avenrun[0] + offset) << shift;
16095 + loads[1] = (avenrun[1] + offset) << shift;
16096 + loads[2] = (avenrun[2] + offset) << shift;
16100 static unsigned long
16101 @@ -5035,16 +5242,19 @@ void account_user_time(struct task_struc
16102 cputime_t cputime_scaled)
16104 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16105 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16107 + int nice = (TASK_NICE(p) > 0);
16109 /* Add user time to process. */
16110 p->utime = cputime_add(p->utime, cputime);
16111 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
16112 + vx_account_user(vxi, cputime, nice);
16113 account_group_user_time(p, cputime);
16115 /* Add user time to cpustat. */
16116 tmp = cputime_to_cputime64(cputime);
16117 - if (TASK_NICE(p) > 0)
16119 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16121 cpustat->user = cputime64_add(cpustat->user, tmp);
16122 @@ -5090,6 +5300,7 @@ void account_system_time(struct task_str
16123 cputime_t cputime, cputime_t cputime_scaled)
16125 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16126 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16129 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
16130 @@ -5100,6 +5311,7 @@ void account_system_time(struct task_str
16131 /* Add system time to process. */
16132 p->stime = cputime_add(p->stime, cputime);
16133 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
16134 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
16135 account_group_system_time(p, cputime);
16137 /* Add system time to cpustat. */
16138 @@ -6136,7 +6348,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16141 if (increment < 0 && !can_nice(current, nice))
16143 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16145 retval = security_task_setnice(current, nice);
16147 @@ -9199,6 +9411,32 @@ static int update_sched_domains(struct n
16152 +static void disable_runtime(struct rq *rq)
16154 + unsigned long flags;
16156 + spin_lock_irqsave(&rq->lock, flags);
16157 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16158 + disable_runtime_cfs(rq);
16160 + disable_runtime_rt(rq);
16161 + spin_unlock_irqrestore(&rq->lock, flags);
16164 +static void enable_runtime(struct rq *rq)
16166 + unsigned long flags;
16168 + spin_lock_irqsave(&rq->lock, flags);
16169 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16170 + enable_runtime_cfs(rq);
16172 + enable_runtime_rt(rq);
16173 + spin_unlock_irqrestore(&rq->lock, flags);
16177 static int update_runtime(struct notifier_block *nfb,
16178 unsigned long action, void *hcpu)
16180 @@ -9331,6 +9569,7 @@ static void init_tg_cfs_entry(struct tas
16181 struct rq *rq = cpu_rq(cpu);
16182 tg->cfs_rq[cpu] = cfs_rq;
16183 init_cfs_rq(cfs_rq, rq);
16184 + init_cfs_hard_limits(cfs_rq, tg);
16187 list_add(&cfs_rq->leaf_cfs_rq_list, &rq->leaf_cfs_rq_list);
16188 @@ -9460,6 +9699,10 @@ void __init sched_init(void)
16189 #endif /* CONFIG_USER_SCHED */
16190 #endif /* CONFIG_RT_GROUP_SCHED */
16192 +#ifdef CONFIG_FAIR_GROUP_SCHED
16193 + init_cfs_bandwidth(&init_task_group);
16196 #ifdef CONFIG_GROUP_SCHED
16197 list_add(&init_task_group.list, &task_groups);
16198 INIT_LIST_HEAD(&init_task_group.children);
16199 @@ -9486,6 +9729,7 @@ void __init sched_init(void)
16200 init_cfs_rq(&rq->cfs, rq);
16201 init_rt_rq(&rq->rt, rq);
16202 #ifdef CONFIG_FAIR_GROUP_SCHED
16203 + init_cfs_hard_limits(&rq->cfs, &init_task_group);
16204 init_task_group.shares = init_task_group_load;
16205 INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
16206 #ifdef CONFIG_CGROUP_SCHED
16207 @@ -9765,6 +10009,7 @@ static void free_fair_sched_group(struct
16211 + destroy_cfs_bandwidth(tg);
16212 for_each_possible_cpu(i) {
16214 kfree(tg->cfs_rq[i]);
16215 @@ -9791,6 +10036,7 @@ int alloc_fair_sched_group(struct task_g
16219 + init_cfs_bandwidth(tg);
16220 tg->shares = NICE_0_LOAD;
16222 for_each_possible_cpu(i) {
16223 @@ -10514,6 +10760,100 @@ static u64 cpu_shares_read_u64(struct cg
16225 return (u64) tg->shares;
16228 +#ifdef CONFIG_CFS_HARD_LIMITS
16230 +static int tg_set_cfs_bandwidth(struct task_group *tg,
16231 + u64 cfs_period, u64 cfs_runtime)
16235 + spin_lock_irq(&tg->cfs_bandwidth.cfs_runtime_lock);
16236 + tg->cfs_bandwidth.cfs_period = ns_to_ktime(cfs_period);
16237 + tg->cfs_bandwidth.cfs_runtime = cfs_runtime;
16239 + for_each_possible_cpu(i) {
16240 + struct cfs_rq *cfs_rq = tg->cfs_rq[i];
16242 + cfs_rq_runtime_lock(cfs_rq);
16243 + cfs_rq->cfs_runtime = cfs_runtime;
16244 + cfs_rq_runtime_unlock(cfs_rq);
16247 + start_cfs_bandwidth(tg);
16248 + spin_unlock_irq(&tg->cfs_bandwidth.cfs_runtime_lock);
16252 +int tg_set_cfs_runtime(struct task_group *tg, long cfs_runtime_us)
16254 + u64 cfs_runtime, cfs_period;
16256 + cfs_period = ktime_to_ns(tg->cfs_bandwidth.cfs_period);
16257 + cfs_runtime = (u64)cfs_runtime_us * NSEC_PER_USEC;
16258 + if (cfs_runtime_us < 0)
16259 + cfs_runtime = RUNTIME_INF;
16261 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16264 +long tg_get_cfs_runtime(struct task_group *tg)
16266 + u64 cfs_runtime_us;
16268 + if (tg->cfs_bandwidth.cfs_runtime == RUNTIME_INF)
16271 + cfs_runtime_us = tg->cfs_bandwidth.cfs_runtime;
16272 + do_div(cfs_runtime_us, NSEC_PER_USEC);
16273 + return cfs_runtime_us;
16276 +int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
16278 + u64 cfs_runtime, cfs_period;
16280 + cfs_period = (u64)cfs_period_us * NSEC_PER_USEC;
16281 + cfs_runtime = tg->cfs_bandwidth.cfs_runtime;
16283 + if (cfs_period == 0)
16286 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16289 +long tg_get_cfs_period(struct task_group *tg)
16291 + u64 cfs_period_us;
16293 + cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.cfs_period);
16294 + do_div(cfs_period_us, NSEC_PER_USEC);
16295 + return cfs_period_us;
16298 +static s64 cpu_cfs_runtime_read_s64(struct cgroup *cgrp, struct cftype *cft)
16300 + return tg_get_cfs_runtime(cgroup_tg(cgrp));
16303 +static int cpu_cfs_runtime_write_s64(struct cgroup *cgrp, struct cftype *cftype,
16304 + s64 cfs_runtime_us)
16306 + return tg_set_cfs_runtime(cgroup_tg(cgrp), cfs_runtime_us);
16309 +static u64 cpu_cfs_period_read_u64(struct cgroup *cgrp, struct cftype *cft)
16311 + return tg_get_cfs_period(cgroup_tg(cgrp));
16314 +static int cpu_cfs_period_write_u64(struct cgroup *cgrp, struct cftype *cftype,
16315 + u64 cfs_period_us)
16317 + return tg_set_cfs_period(cgroup_tg(cgrp), cfs_period_us);
16320 +#endif /* CONFIG_CFS_HARD_LIMITS */
16321 #endif /* CONFIG_FAIR_GROUP_SCHED */
16323 #ifdef CONFIG_RT_GROUP_SCHED
16324 @@ -10547,6 +10887,18 @@ static struct cftype cpu_files[] = {
16325 .read_u64 = cpu_shares_read_u64,
16326 .write_u64 = cpu_shares_write_u64,
16328 +#ifdef CONFIG_CFS_HARD_LIMITS
16330 + .name = "cfs_runtime_us",
16331 + .read_s64 = cpu_cfs_runtime_read_s64,
16332 + .write_s64 = cpu_cfs_runtime_write_s64,
16335 + .name = "cfs_period_us",
16336 + .read_u64 = cpu_cfs_period_read_u64,
16337 + .write_u64 = cpu_cfs_period_write_u64,
16339 +#endif /* CONFIG_CFS_HARD_LIMITS */
16341 #ifdef CONFIG_RT_GROUP_SCHED
16343 diff -NurpP --minimal linux-2.6.32.10/kernel/sched_debug.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched_debug.c
16344 --- linux-2.6.32.10/kernel/sched_debug.c 2010-03-18 16:17:38.000000000 +0100
16345 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched_debug.c 2009-12-29 00:36:26.000000000 +0100
16346 @@ -80,6 +80,11 @@ static void print_cfs_group_stats(struct
16350 +#ifdef CONFIG_CFS_HARD_LIMITS
16351 + PN(se->throttle_max);
16352 + PN(se->throttle_sum);
16353 + P(se->throttle_count);
16356 P(se->load.weight);
16358 @@ -214,6 +219,16 @@ void print_cfs_rq(struct seq_file *m, in
16360 SEQ_printf(m, " .%-30s: %lu\n", "shares", cfs_rq->shares);
16362 +#ifdef CONFIG_CFS_HARD_LIMITS
16363 + spin_lock_irqsave(&rq->lock, flags);
16364 + SEQ_printf(m, " .%-30s: %d\n", "cfs_throttled",
16365 + cfs_rq->cfs_throttled);
16366 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_time",
16367 + SPLIT_NS(cfs_rq->cfs_time));
16368 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_runtime",
16369 + SPLIT_NS(cfs_rq->cfs_runtime));
16370 + spin_unlock_irqrestore(&rq->lock, flags);
16371 +#endif /* CONFIG_CFS_HARD_LIMITS */
16372 print_cfs_group_stats(m, cpu, cfs_rq->tg);
16375 @@ -314,7 +329,7 @@ static int sched_debug_show(struct seq_f
16376 u64 now = ktime_to_ns(ktime_get());
16379 - SEQ_printf(m, "Sched Debug Version: v0.09, %s %.*s\n",
16380 + SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n",
16381 init_utsname()->release,
16382 (int)strcspn(init_utsname()->version, " "),
16383 init_utsname()->version);
16384 diff -NurpP --minimal linux-2.6.32.10/kernel/sched_fair.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched_fair.c
16385 --- linux-2.6.32.10/kernel/sched_fair.c 2010-03-18 16:17:38.000000000 +0100
16386 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched_fair.c 2010-02-12 10:59:55.000000000 +0100
16387 @@ -192,7 +192,308 @@ find_matching_se(struct sched_entity **s
16391 -#else /* !CONFIG_FAIR_GROUP_SCHED */
16392 +#ifdef CONFIG_CFS_HARD_LIMITS
16394 +static inline void update_stats_throttle_start(struct cfs_rq *cfs_rq,
16395 + struct sched_entity *se)
16397 + schedstat_set(se->throttle_start, rq_of(cfs_rq)->clock);
16400 +static inline void update_stats_throttle_end(struct cfs_rq *cfs_rq,
16401 + struct sched_entity *se)
16403 + schedstat_set(se->throttle_max, max(se->throttle_max,
16404 + rq_of(cfs_rq)->clock - se->throttle_start));
16405 + schedstat_set(se->throttle_count, se->throttle_count + 1);
16406 + schedstat_set(se->throttle_sum, se->throttle_sum +
16407 + rq_of(cfs_rq)->clock - se->throttle_start);
16408 + schedstat_set(se->throttle_start, 0);
16412 +struct cfs_rq *sched_cfs_period_cfs_rq(struct cfs_bandwidth *cfs_b, int cpu)
16414 + return container_of(cfs_b, struct task_group,
16415 + cfs_bandwidth)->cfs_rq[cpu];
16418 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16420 + return cfs_rq->cfs_throttled;
16425 + * Ensure this RQ takes back all the runtime it lend to its neighbours.
16427 +static void disable_runtime_cfs(struct rq *rq)
16429 + struct root_domain *rd = rq->rd;
16430 + struct cfs_rq *cfs_rq;
16432 + if (unlikely(!scheduler_running))
16435 + for_each_leaf_cfs_rq(rq, cfs_rq) {
16436 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16440 + spin_lock(&cfs_b->cfs_runtime_lock);
16441 + spin_lock(&cfs_rq->cfs_runtime_lock);
16444 + * Either we're all are infinity and nobody needs to borrow,
16445 + * or we're already disabled and this have nothing to do, or
16446 + * we have exactly the right amount of runtime to take out.
16448 + if (cfs_rq->cfs_runtime == RUNTIME_INF ||
16449 + cfs_rq->cfs_runtime == cfs_b->cfs_runtime)
16451 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16454 + * Calculate the difference between what we started out with
16455 + * and what we current have, that's the amount of runtime
16456 + * we lend and now have to reclaim.
16458 + want = cfs_b->cfs_runtime - cfs_rq->cfs_runtime;
16461 + * Greedy reclaim, take back as much as possible.
16463 + for_each_cpu(i, rd->span) {
16464 + struct cfs_rq *iter = sched_cfs_period_cfs_rq(cfs_b, i);
16468 + * Can't reclaim from ourselves or disabled runqueues.
16470 + if (iter == cfs_rq || iter->cfs_runtime == RUNTIME_INF)
16473 + spin_lock(&iter->cfs_runtime_lock);
16475 + diff = min_t(s64, iter->cfs_runtime, want);
16476 + iter->cfs_runtime -= diff;
16479 + iter->cfs_runtime -= want;
16483 + spin_unlock(&iter->cfs_runtime_lock);
16488 + spin_lock(&cfs_rq->cfs_runtime_lock);
16490 + * We cannot be left wanting - that would mean some
16491 + * runtime leaked out of the system.
16496 + * Disable all the borrow logic by pretending we have infinite
16497 + * runtime - in which case borrowing doesn't make sense.
16499 + cfs_rq->cfs_runtime = RUNTIME_INF;
16500 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16501 + spin_unlock(&cfs_b->cfs_runtime_lock);
16505 +static void enable_runtime_cfs(struct rq *rq)
16507 + struct cfs_rq *cfs_rq;
16509 + if (unlikely(!scheduler_running))
16513 + * Reset each runqueue's bandwidth settings
16515 + for_each_leaf_cfs_rq(rq, cfs_rq) {
16516 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16518 + spin_lock(&cfs_b->cfs_runtime_lock);
16519 + spin_lock(&cfs_rq->cfs_runtime_lock);
16520 + cfs_rq->cfs_runtime = cfs_b->cfs_runtime;
16521 + cfs_rq->cfs_time = 0;
16522 + cfs_rq->cfs_throttled = 0;
16523 + spin_unlock(&cfs_rq->cfs_runtime_lock);
16524 + spin_unlock(&cfs_b->cfs_runtime_lock);
16529 + * Ran out of runtime, check if we can borrow some from others
16530 + * instead of getting throttled right away.
16532 +static void do_cfs_balance_runtime(struct cfs_rq *cfs_rq)
16534 + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth;
16535 + const struct cpumask *span = sched_bw_period_mask();
16539 + weight = cpumask_weight(span);
16540 + spin_lock(&cfs_b->cfs_runtime_lock);
16541 + cfs_period = ktime_to_ns(cfs_b->cfs_period);
16543 + for_each_cpu(i, span) {
16544 + struct cfs_rq *borrow_cfs_rq =
16545 + sched_cfs_period_cfs_rq(cfs_b, i);
16548 + if (borrow_cfs_rq == cfs_rq)
16551 + cfs_rq_runtime_lock(borrow_cfs_rq);
16552 + if (borrow_cfs_rq->cfs_runtime == RUNTIME_INF) {
16553 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16557 + diff = borrow_cfs_rq->cfs_runtime - borrow_cfs_rq->cfs_time;
16559 + diff = div_u64((u64)diff, weight);
16560 + if (cfs_rq->cfs_runtime + diff > cfs_period)
16561 + diff = cfs_period - cfs_rq->cfs_runtime;
16562 + borrow_cfs_rq->cfs_runtime -= diff;
16563 + cfs_rq->cfs_runtime += diff;
16564 + if (cfs_rq->cfs_runtime == cfs_period) {
16565 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16569 + cfs_rq_runtime_unlock(borrow_cfs_rq);
16571 + spin_unlock(&cfs_b->cfs_runtime_lock);
16575 + * Called with rq->runtime_lock held.
16577 +static void cfs_balance_runtime(struct cfs_rq *cfs_rq)
16579 + cfs_rq_runtime_unlock(cfs_rq);
16580 + do_cfs_balance_runtime(cfs_rq);
16581 + cfs_rq_runtime_lock(cfs_rq);
16584 +#else /* !CONFIG_SMP */
16586 +static void cfs_balance_runtime(struct cfs_rq *cfs_rq)
16590 +#endif /* CONFIG_SMP */
16593 + * Check if group entity exceeded its runtime. If so, mark the cfs_rq as
16594 + * throttled mark the current task for reschedling.
16596 +static void sched_cfs_runtime_exceeded(struct sched_entity *se,
16597 + struct task_struct *tsk_curr, unsigned long delta_exec)
16599 + struct cfs_rq *cfs_rq;
16601 + cfs_rq = group_cfs_rq(se);
16603 + if (cfs_rq->cfs_runtime == RUNTIME_INF)
16606 + cfs_rq->cfs_time += delta_exec;
16608 + if (cfs_rq_throttled(cfs_rq))
16611 + if (cfs_rq->cfs_time > cfs_rq->cfs_runtime)
16612 + cfs_balance_runtime(cfs_rq);
16614 + if (cfs_rq->cfs_time > cfs_rq->cfs_runtime) {
16615 + cfs_rq->cfs_throttled = 1;
16616 + update_stats_throttle_start(cfs_rq, se);
16617 + resched_task(tsk_curr);
16621 +static inline void update_curr_group(struct sched_entity *curr,
16622 + unsigned long delta_exec, struct task_struct *tsk_curr)
16624 + sched_cfs_runtime_exceeded(curr, tsk_curr, delta_exec);
16627 +static void enqueue_entity_locked(struct cfs_rq *cfs_rq,
16628 + struct sched_entity *se, int wakeup);
16630 +static void enqueue_throttled_entity(struct rq *rq, struct sched_entity *se)
16632 + for_each_sched_entity(se) {
16633 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16635 + if (se->on_rq || cfs_rq_throttled(gcfs_rq) ||
16636 + !gcfs_rq->nr_running)
16638 + enqueue_entity_locked(cfs_rq_of(se), se, 0);
16643 + * Refresh runtimes of all cfs_rqs in this group, i,e.,
16644 + * refresh runtimes of the representative cfs_rq of this
16645 + * tg on all cpus. Enqueue any throttled entity back.
16647 +void do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b)
16650 + const struct cpumask *span = sched_bw_period_mask();
16651 + unsigned long flags;
16653 + for_each_cpu(i, span) {
16654 + struct rq *rq = cpu_rq(i);
16655 + struct cfs_rq *cfs_rq = sched_cfs_period_cfs_rq(cfs_b, i);
16656 + struct sched_entity *se = cfs_rq->tg->se[i];
16658 + spin_lock_irqsave(&rq->lock, flags);
16659 + cfs_rq_runtime_lock(cfs_rq);
16660 + cfs_rq->cfs_time = 0;
16661 + if (cfs_rq_throttled(cfs_rq)) {
16662 + update_rq_clock(rq);
16663 + update_stats_throttle_end(cfs_rq, se);
16664 + cfs_rq->cfs_throttled = 0;
16665 + enqueue_throttled_entity(rq, se);
16667 + cfs_rq_runtime_unlock(cfs_rq);
16668 + spin_unlock_irqrestore(&rq->lock, flags);
16674 +static inline void update_curr_group(struct sched_entity *curr,
16675 + unsigned long delta_exec, struct task_struct *tsk_curr)
16680 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
16685 +#endif /* CONFIG_CFS_HARD_LIMITS */
16687 +#else /* CONFIG_FAIR_GROUP_SCHED */
16689 +static inline void update_curr_group(struct sched_entity *curr,
16690 + unsigned long delta_exec, struct task_struct *tsk_curr)
16695 static inline struct task_struct *task_of(struct sched_entity *se)
16697 @@ -254,7 +555,6 @@ find_matching_se(struct sched_entity **s
16699 #endif /* CONFIG_FAIR_GROUP_SCHED */
16702 /**************************************************************
16703 * Scheduling class tree data structure manipulation methods:
16705 @@ -492,14 +792,25 @@ __update_curr(struct cfs_rq *cfs_rq, str
16706 update_min_vruntime(cfs_rq);
16709 -static void update_curr(struct cfs_rq *cfs_rq)
16710 +static void update_curr_task(struct sched_entity *curr,
16711 + unsigned long delta_exec)
16713 + struct task_struct *curtask = task_of(curr);
16715 + trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
16716 + cpuacct_charge(curtask, delta_exec);
16717 + account_group_exec_runtime(curtask, delta_exec);
16720 +static int update_curr_common(struct cfs_rq *cfs_rq, unsigned long *delta)
16722 struct sched_entity *curr = cfs_rq->curr;
16723 - u64 now = rq_of(cfs_rq)->clock;
16724 + struct rq *rq = rq_of(cfs_rq);
16725 + u64 now = rq->clock;
16726 unsigned long delta_exec;
16728 if (unlikely(!curr))
16733 * Get the amount of time the current task was running
16734 @@ -508,17 +819,29 @@ static void update_curr(struct cfs_rq *c
16736 delta_exec = (unsigned long)(now - curr->exec_start);
16741 __update_curr(cfs_rq, curr, delta_exec);
16742 curr->exec_start = now;
16743 + *delta = delta_exec;
16747 - if (entity_is_task(curr)) {
16748 - struct task_struct *curtask = task_of(curr);
16749 +static void update_curr(struct cfs_rq *cfs_rq)
16751 + struct sched_entity *curr = cfs_rq->curr;
16752 + struct rq *rq = rq_of(cfs_rq);
16753 + unsigned long delta_exec;
16755 - trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
16756 - cpuacct_charge(curtask, delta_exec);
16757 - account_group_exec_runtime(curtask, delta_exec);
16758 + if (update_curr_common(cfs_rq, &delta_exec))
16761 + if (entity_is_task(curr))
16762 + update_curr_task(curr, delta_exec);
16764 + cfs_rq_runtime_lock(group_cfs_rq(curr));
16765 + update_curr_group(curr, delta_exec, rq->curr);
16766 + cfs_rq_runtime_unlock(group_cfs_rq(curr));
16770 @@ -743,13 +1066,9 @@ place_entity(struct cfs_rq *cfs_rq, stru
16771 se->vruntime = vruntime;
16775 -enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int wakeup)
16776 +static void enqueue_entity_common(struct cfs_rq *cfs_rq,
16777 + struct sched_entity *se, int wakeup)
16780 - * Update run-time statistics of the 'current'.
16782 - update_curr(cfs_rq);
16783 account_entity_enqueue(cfs_rq, se);
16786 @@ -761,6 +1080,29 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16787 check_spread(cfs_rq, se);
16788 if (se != cfs_rq->curr)
16789 __enqueue_entity(cfs_rq, se);
16791 + if (entity_is_task(se))
16792 + vx_activate_task(task_of(se));
16795 +static void enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
16799 + * Update run-time statistics of the 'current'.
16801 + update_curr(cfs_rq);
16802 + enqueue_entity_common(cfs_rq, se, wakeup);
16805 +static void enqueue_entity_locked(struct cfs_rq *cfs_rq,
16806 + struct sched_entity *se, int wakeup)
16809 + * Update run-time statistics of the 'current'.
16811 + // update_curr_locked(cfs_rq);
16812 + enqueue_entity_common(cfs_rq, se, wakeup);
16815 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
16816 @@ -804,6 +1146,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16818 if (se != cfs_rq->curr)
16819 __dequeue_entity(cfs_rq, se);
16820 + if (entity_is_task(se))
16821 + vx_deactivate_task(task_of(se));
16822 account_entity_dequeue(cfs_rq, se);
16823 update_min_vruntime(cfs_rq);
16825 @@ -900,6 +1244,32 @@ static struct sched_entity *pick_next_en
16830 + * Called from put_prev_entity()
16831 + * If a group entity (@se) is found to be throttled, it will not be put back
16832 + * on @cfs_rq, which is equivalent to dequeing it.
16834 +static int dequeue_throttled_entity(struct cfs_rq *cfs_rq,
16835 + struct sched_entity *se)
16837 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16839 + if (entity_is_task(se))
16842 + cfs_rq_runtime_lock(gcfs_rq);
16843 + if (!cfs_rq_throttled(gcfs_rq) && gcfs_rq->nr_running) {
16844 + cfs_rq_runtime_unlock(gcfs_rq);
16848 + __clear_buddies(cfs_rq, se);
16849 + account_entity_dequeue(cfs_rq, se);
16850 + cfs_rq->curr = NULL;
16851 + cfs_rq_runtime_unlock(gcfs_rq);
16855 static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
16858 @@ -911,6 +1281,8 @@ static void put_prev_entity(struct cfs_r
16860 check_spread(cfs_rq, prev);
16862 + if (dequeue_throttled_entity(cfs_rq, prev))
16864 update_stats_wait_start(cfs_rq, prev);
16865 /* Put 'current' back into the tree. */
16866 __enqueue_entity(cfs_rq, prev);
16867 @@ -1007,10 +1379,28 @@ static inline void hrtick_update(struct
16871 +static int enqueue_group_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
16874 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
16877 + cfs_rq_runtime_lock(gcfs_rq);
16878 + if (cfs_rq_throttled(gcfs_rq)) {
16882 + enqueue_entity_locked(cfs_rq, se, wakeup);
16884 + cfs_rq_runtime_unlock(gcfs_rq);
16889 * The enqueue_task method is called before nr_running is
16890 * increased. Here we update the fair scheduling stats and
16891 * then put the task into the rbtree:
16892 + * Don't enqueue a throttled entity further into the hierarchy.
16894 static void enqueue_task_fair(struct rq *rq, struct task_struct *p, int wakeup)
16896 @@ -1020,11 +1410,15 @@ static void enqueue_task_fair(struct rq
16897 for_each_sched_entity(se) {
16901 cfs_rq = cfs_rq_of(se);
16902 - enqueue_entity(cfs_rq, se, wakeup);
16903 + if (entity_is_task(se))
16904 + enqueue_entity(cfs_rq, se, wakeup);
16906 + if (enqueue_group_entity(cfs_rq, se, wakeup))
16914 @@ -1044,6 +1438,17 @@ static void dequeue_task_fair(struct rq
16915 /* Don't dequeue parent if it has other entities besides us */
16916 if (cfs_rq->load.weight)
16920 + * If this cfs_rq is throttled, then it is already
16923 + cfs_rq_runtime_lock(cfs_rq);
16924 + if (cfs_rq_throttled(cfs_rq)) {
16925 + cfs_rq_runtime_unlock(cfs_rq);
16928 + cfs_rq_runtime_unlock(cfs_rq);
16932 @@ -1821,9 +2226,10 @@ load_balance_fair(struct rq *this_rq, in
16933 u64 rem_load, moved_load;
16937 + * empty group or throttled group
16939 - if (!busiest_cfs_rq->task_weight)
16940 + if (!busiest_cfs_rq->task_weight ||
16941 + cfs_rq_throttled(busiest_cfs_rq))
16944 rem_load = (u64)rem_load_move * busiest_weight;
16945 @@ -1872,6 +2278,12 @@ move_one_task_fair(struct rq *this_rq, i
16947 for_each_leaf_cfs_rq(busiest, busy_cfs_rq) {
16949 + * Don't move task from a throttled cfs_rq
16951 + if (cfs_rq_throttled(busy_cfs_rq))
16955 * pass busy_cfs_rq argument into
16956 * load_balance_[start|next]_fair iterators
16958 diff -NurpP --minimal linux-2.6.32.10/kernel/sched_rt.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched_rt.c
16959 --- linux-2.6.32.10/kernel/sched_rt.c 2009-12-03 20:02:58.000000000 +0100
16960 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sched_rt.c 2009-12-03 20:04:56.000000000 +0100
16961 @@ -235,18 +235,6 @@ static int rt_se_boosted(struct sched_rt
16962 return p->prio != p->normal_prio;
16966 -static inline const struct cpumask *sched_rt_period_mask(void)
16968 - return cpu_rq(smp_processor_id())->rd->span;
16971 -static inline const struct cpumask *sched_rt_period_mask(void)
16973 - return cpu_online_mask;
16978 struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
16980 @@ -296,11 +284,6 @@ static inline int rt_rq_throttled(struct
16981 return rt_rq->rt_throttled;
16984 -static inline const struct cpumask *sched_rt_period_mask(void)
16986 - return cpu_online_mask;
16990 struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
16992 @@ -373,7 +356,7 @@ next:
16994 * Ensure this RQ takes back all the runtime it lend to its neighbours.
16996 -static void __disable_runtime(struct rq *rq)
16997 +static void disable_runtime_rt(struct rq *rq)
16999 struct root_domain *rd = rq->rd;
17000 struct rt_rq *rt_rq;
17001 @@ -450,16 +433,7 @@ balanced:
17005 -static void disable_runtime(struct rq *rq)
17007 - unsigned long flags;
17009 - spin_lock_irqsave(&rq->lock, flags);
17010 - __disable_runtime(rq);
17011 - spin_unlock_irqrestore(&rq->lock, flags);
17014 -static void __enable_runtime(struct rq *rq)
17015 +static void enable_runtime_rt(struct rq *rq)
17017 struct rt_rq *rt_rq;
17019 @@ -482,15 +456,6 @@ static void __enable_runtime(struct rq *
17023 -static void enable_runtime(struct rq *rq)
17025 - unsigned long flags;
17027 - spin_lock_irqsave(&rq->lock, flags);
17028 - __enable_runtime(rq);
17029 - spin_unlock_irqrestore(&rq->lock, flags);
17032 static int balance_runtime(struct rt_rq *rt_rq)
17035 @@ -518,7 +483,7 @@ static int do_sched_rt_period_timer(stru
17036 if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
17039 - span = sched_rt_period_mask();
17040 + span = sched_bw_period_mask();
17041 for_each_cpu(i, span) {
17043 struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
17044 @@ -1564,7 +1529,7 @@ static void rq_online_rt(struct rq *rq)
17045 if (rq->rt.overloaded)
17046 rt_set_overload(rq);
17048 - __enable_runtime(rq);
17049 + enable_runtime_rt(rq);
17051 cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio.curr);
17053 @@ -1575,7 +1540,7 @@ static void rq_offline_rt(struct rq *rq)
17054 if (rq->rt.overloaded)
17055 rt_clear_overload(rq);
17057 - __disable_runtime(rq);
17058 + disable_runtime_rt(rq);
17060 cpupri_set(&rq->rd->cpupri, rq->cpu, CPUPRI_INVALID);
17062 diff -NurpP --minimal linux-2.6.32.10/kernel/signal.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/signal.c
17063 --- linux-2.6.32.10/kernel/signal.c 2010-03-18 16:17:38.000000000 +0100
17064 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/signal.c 2010-03-13 22:09:19.000000000 +0100
17066 #include <linux/freezer.h>
17067 #include <linux/pid_namespace.h>
17068 #include <linux/nsproxy.h>
17069 +#include <linux/vs_context.h>
17070 +#include <linux/vs_pid.h>
17071 #include <trace/events/sched.h>
17073 #include <asm/param.h>
17074 @@ -598,6 +600,14 @@ static int check_kill_permission(int sig
17075 if (!valid_signal(sig))
17078 + if ((info != SEND_SIG_NOINFO) &&
17079 + (is_si_special(info) || !SI_FROMUSER(info)))
17082 + vxdprintk(VXD_CBIT(misc, 7),
17083 + "check_kill_permission(%d,%p,%p[#%u,%u])",
17084 + sig, info, t, vx_task_xid(t), t->pid);
17086 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
17089 @@ -625,6 +635,20 @@ static int check_kill_permission(int sig
17094 + if (t->pid == 1 && current->xid)
17098 + /* FIXME: we shouldn't return ESRCH ever, to avoid
17099 + loops, maybe ENOENT or EACCES? */
17100 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17101 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
17102 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17103 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
17107 return security_task_kill(t, info, sig, 0);
17110 @@ -1113,7 +1137,7 @@ int kill_pid_info(int sig, struct siginf
17113 p = pid_task(pid, PIDTYPE_PID);
17115 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17116 error = group_send_sig_info(sig, info, p);
17117 if (unlikely(error == -ESRCH))
17119 @@ -1152,7 +1176,7 @@ int kill_pid_info_as_uid(int sig, struct
17121 read_lock(&tasklist_lock);
17122 p = pid_task(pid, PIDTYPE_PID);
17124 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17128 @@ -1206,8 +1230,10 @@ static int kill_something_info(int sig,
17129 struct task_struct * p;
17131 for_each_process(p) {
17132 - if (task_pid_vnr(p) > 1 &&
17133 - !same_thread_group(p, current)) {
17134 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17135 + task_pid_vnr(p) > 1 &&
17136 + !same_thread_group(p, current) &&
17137 + !vx_current_initpid(p->pid)) {
17138 int err = group_send_sig_info(sig, info, p);
17141 @@ -1872,6 +1898,11 @@ relock:
17142 !sig_kernel_only(signr))
17145 + /* virtual init is protected against user signals */
17146 + if ((info->si_code == SI_USER) &&
17147 + vx_current_initpid(current->pid))
17150 if (sig_kernel_stop(signr)) {
17152 * The default action is to stop all threads in
17153 diff -NurpP --minimal linux-2.6.32.10/kernel/softirq.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/softirq.c
17154 --- linux-2.6.32.10/kernel/softirq.c 2009-12-03 20:02:58.000000000 +0100
17155 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/softirq.c 2009-12-03 20:04:56.000000000 +0100
17157 #include <linux/ftrace.h>
17158 #include <linux/smp.h>
17159 #include <linux/tick.h>
17160 +#include <linux/vs_context.h>
17162 #define CREATE_TRACE_POINTS
17163 #include <trace/events/irq.h>
17164 diff -NurpP --minimal linux-2.6.32.10/kernel/sys.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sys.c
17165 --- linux-2.6.32.10/kernel/sys.c 2009-12-03 20:02:58.000000000 +0100
17166 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sys.c 2009-12-03 20:04:56.000000000 +0100
17168 #include <linux/syscalls.h>
17169 #include <linux/kprobes.h>
17170 #include <linux/user_namespace.h>
17171 +#include <linux/vs_pid.h>
17173 #include <asm/uaccess.h>
17174 #include <asm/io.h>
17175 @@ -130,7 +131,10 @@ static int set_one_prio(struct task_stru
17178 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17180 + if (vx_flags(VXF_IGNEG_NICE, 0))
17186 no_nice = security_task_setnice(p, niceval);
17187 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17189 pgrp = task_pgrp(current);
17190 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17191 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17193 error = set_one_prio(p, niceval, error);
17194 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17196 @@ -240,6 +246,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17198 pgrp = task_pgrp(current);
17199 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17200 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17202 niceval = 20 - task_nice(p);
17203 if (niceval > retval)
17205 @@ -349,6 +357,9 @@ void kernel_power_off(void)
17206 machine_power_off();
17208 EXPORT_SYMBOL_GPL(kernel_power_off);
17210 +long vs_reboot(unsigned int, void __user *);
17213 * Reboot system call: for obvious reasons only root may call it,
17214 * and even root needs to set up some magic numbers in the registers
17215 @@ -381,6 +392,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17216 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17217 cmd = LINUX_REBOOT_CMD_HALT;
17219 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17220 + return vs_reboot(cmd, arg);
17224 case LINUX_REBOOT_CMD_RESTART:
17225 @@ -1133,7 +1147,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17227 char tmp[__NEW_UTS_LEN];
17229 - if (!capable(CAP_SYS_ADMIN))
17230 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17232 if (len < 0 || len > __NEW_UTS_LEN)
17234 @@ -1182,7 +1196,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17236 char tmp[__NEW_UTS_LEN];
17238 - if (!capable(CAP_SYS_ADMIN))
17239 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17241 if (len < 0 || len > __NEW_UTS_LEN)
17243 @@ -1251,7 +1265,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17245 old_rlim = current->signal->rlim + resource;
17246 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17247 - !capable(CAP_SYS_RESOURCE))
17248 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17250 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17252 diff -NurpP --minimal linux-2.6.32.10/kernel/sysctl.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sysctl.c
17253 --- linux-2.6.32.10/kernel/sysctl.c 2010-03-18 16:17:38.000000000 +0100
17254 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sysctl.c 2010-01-20 04:21:33.000000000 +0100
17255 @@ -124,6 +124,7 @@ static int ngroups_max = NGROUPS_MAX;
17256 extern char modprobe_path[];
17257 extern int modules_disabled;
17259 +extern char vshelper_path[];
17260 #ifdef CONFIG_CHR_DEV_SG
17261 extern int sg_big_buff;
17263 @@ -593,6 +594,15 @@ static struct ctl_table kern_table[] = {
17264 .strategy = &sysctl_string,
17268 + .ctl_name = KERN_VSHELPER,
17269 + .procname = "vshelper",
17270 + .data = &vshelper_path,
17273 + .proc_handler = &proc_dostring,
17274 + .strategy = &sysctl_string,
17276 #ifdef CONFIG_CHR_DEV_SG
17278 .ctl_name = KERN_SG_BIG_BUFF,
17279 diff -NurpP --minimal linux-2.6.32.10/kernel/sysctl_check.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sysctl_check.c
17280 --- linux-2.6.32.10/kernel/sysctl_check.c 2010-03-18 16:17:38.000000000 +0100
17281 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/sysctl_check.c 2010-02-12 10:59:55.000000000 +0100
17282 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
17284 { KERN_PANIC, "panic" },
17285 { KERN_REALROOTDEV, "real-root-dev" },
17286 + { KERN_VSHELPER, "vshelper", },
17288 { KERN_SPARC_REBOOT, "reboot-cmd" },
17289 { KERN_CTLALTDEL, "ctrl-alt-del" },
17290 @@ -1218,6 +1219,22 @@ static const struct trans_ctl_table tran
17294 +static struct trans_ctl_table trans_vserver_table[] = {
17295 + { 1, "debug_switch" },
17296 + { 2, "debug_xid" },
17297 + { 3, "debug_nid" },
17298 + { 4, "debug_tag" },
17299 + { 5, "debug_net" },
17300 + { 6, "debug_limit" },
17301 + { 7, "debug_cres" },
17302 + { 8, "debug_dlim" },
17303 + { 9, "debug_quota" },
17304 + { 10, "debug_cvirt" },
17305 + { 11, "debug_space" },
17306 + { 12, "debug_misc" },
17310 static const struct trans_ctl_table trans_root_table[] = {
17311 { CTL_KERN, "kernel", trans_kern_table },
17312 { CTL_VM, "vm", trans_vm_table },
17313 @@ -1234,6 +1251,7 @@ static const struct trans_ctl_table tran
17314 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
17315 { CTL_PM, "pm", trans_pm_table },
17316 { CTL_FRV, "frv", trans_frv_table },
17317 + { CTL_VSERVER, "vserver", trans_vserver_table },
17321 diff -NurpP --minimal linux-2.6.32.10/kernel/time.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/time.c
17322 --- linux-2.6.32.10/kernel/time.c 2009-12-03 20:02:58.000000000 +0100
17323 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/time.c 2009-12-03 20:04:56.000000000 +0100
17324 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
17325 SYSCALL_DEFINE1(time, time_t __user *, tloc)
17327 time_t i = get_seconds();
17328 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17331 if (put_user(i,tloc))
17332 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17336 - do_settimeofday(&tv);
17337 + vx_settimeofday(&tv);
17341 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17343 if (likely(tv != NULL)) {
17344 struct timeval ktv;
17345 - do_gettimeofday(&ktv);
17346 + vx_gettimeofday(&ktv);
17347 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17350 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
17351 /* SMP safe, again the code in arch/foo/time.c should
17352 * globally block out interrupts when it runs.
17354 - return do_settimeofday(tv);
17355 + return vx_settimeofday(tv);
17359 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
17363 - do_gettimeofday(&x);
17364 + vx_gettimeofday(&x);
17365 tv->tv_sec = x.tv_sec;
17366 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17368 diff -NurpP --minimal linux-2.6.32.10/kernel/timer.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/timer.c
17369 --- linux-2.6.32.10/kernel/timer.c 2009-12-03 20:02:58.000000000 +0100
17370 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/timer.c 2009-12-03 20:04:56.000000000 +0100
17372 #include <linux/kallsyms.h>
17373 #include <linux/perf_event.h>
17374 #include <linux/sched.h>
17375 +#include <linux/vs_base.h>
17376 +#include <linux/vs_cvirt.h>
17377 +#include <linux/vs_pid.h>
17378 +#include <linux/vserver/sched.h>
17380 #include <asm/uaccess.h>
17381 #include <asm/unistd.h>
17382 @@ -1255,12 +1259,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17389 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17390 - * should be moved into arch/i386 instead?
17394 * sys_getpid - return the thread group id of the current process
17395 @@ -1289,10 +1287,23 @@ SYSCALL_DEFINE0(getppid)
17397 pid = task_tgid_vnr(current->real_parent);
17399 + return vx_map_pid(pid);
17406 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17409 +asmlinkage long do_getxpid(long *ppid)
17411 + *ppid = sys_getppid();
17412 + return sys_getpid();
17415 +#else /* _alpha_ */
17417 SYSCALL_DEFINE0(getuid)
17419 /* Only we change this so SMP safe */
17420 diff -NurpP --minimal linux-2.6.32.10/kernel/user.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/user.c
17421 --- linux-2.6.32.10/kernel/user.c 2009-12-03 20:02:58.000000000 +0100
17422 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/user.c 2009-12-03 20:04:56.000000000 +0100
17423 @@ -251,10 +251,10 @@ static struct kobj_type uids_ktype = {
17425 * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
17427 -static int uids_user_create(struct user_struct *up)
17428 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17430 struct kobject *kobj = &up->kobj;
17434 memset(kobj, 0, sizeof(struct kobject));
17435 if (up->user_ns != &init_user_ns)
17436 @@ -282,7 +282,7 @@ int __init uids_sysfs_init(void)
17440 - return uids_user_create(&root_user);
17441 + return uids_user_create(NULL, &root_user);
17444 /* delayed work function to remove sysfs directory for a user and free up
17445 @@ -353,7 +353,8 @@ static struct user_struct *uid_hash_find
17448 int uids_sysfs_init(void) { return 0; }
17449 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17450 +static inline int uids_user_create(struct user_namespace *ns,
17451 + struct user_struct *up) { return 0; }
17452 static inline void uids_mutex_lock(void) { }
17453 static inline void uids_mutex_unlock(void) { }
17455 @@ -450,7 +451,7 @@ struct user_struct *alloc_uid(struct use
17457 new->user_ns = get_user_ns(ns);
17459 - if (uids_user_create(new))
17460 + if (uids_user_create(ns, new))
17461 goto out_destoy_sched;
17464 diff -NurpP --minimal linux-2.6.32.10/kernel/user_namespace.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/user_namespace.c
17465 --- linux-2.6.32.10/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
17466 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/user_namespace.c 2009-12-03 20:04:56.000000000 +0100
17468 #include <linux/slab.h>
17469 #include <linux/user_namespace.h>
17470 #include <linux/cred.h>
17471 +#include <linux/vserver/global.h>
17474 * Create a new user namespace, deriving the creator from the user in the
17475 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17478 kref_init(&ns->kref);
17479 + atomic_inc(&vs_global_user_ns);
17481 for (n = 0; n < UIDHASH_SZ; ++n)
17482 INIT_HLIST_HEAD(ns->uidhash_table + n);
17483 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17484 struct user_namespace *ns =
17485 container_of(kref, struct user_namespace, kref);
17487 + /* FIXME: maybe move into destroyer? */
17488 + atomic_dec(&vs_global_user_ns);
17489 INIT_WORK(&ns->destroyer, free_user_ns_work);
17490 schedule_work(&ns->destroyer);
17492 diff -NurpP --minimal linux-2.6.32.10/kernel/utsname.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/utsname.c
17493 --- linux-2.6.32.10/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
17494 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/utsname.c 2009-12-03 20:04:56.000000000 +0100
17495 @@ -14,14 +14,17 @@
17496 #include <linux/utsname.h>
17497 #include <linux/err.h>
17498 #include <linux/slab.h>
17499 +#include <linux/vserver/global.h>
17501 static struct uts_namespace *create_uts_ns(void)
17503 struct uts_namespace *uts_ns;
17505 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17508 kref_init(&uts_ns->kref);
17509 + atomic_inc(&vs_global_uts_ns);
17514 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17515 struct uts_namespace *ns;
17517 ns = container_of(kref, struct uts_namespace, kref);
17518 + atomic_dec(&vs_global_uts_ns);
17521 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/cacct.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cacct.c
17522 --- linux-2.6.32.10/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17523 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cacct.c 2009-12-03 20:04:56.000000000 +0100
17526 + * linux/kernel/vserver/cacct.c
17528 + * Virtual Server: Context Accounting
17530 + * Copyright (C) 2006-2007 Herbert Pötzl
17532 + * V0.01 added accounting stats
17536 +#include <linux/types.h>
17537 +#include <linux/vs_context.h>
17538 +#include <linux/vserver/cacct_cmd.h>
17539 +#include <linux/vserver/cacct_int.h>
17541 +#include <asm/errno.h>
17542 +#include <asm/uaccess.h>
17545 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17547 + struct vcmd_sock_stat_v0 vc_data;
17550 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17553 + field = vc_data.field;
17554 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17557 + for (j = 0; j < 3; j++) {
17558 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17559 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17562 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17567 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/cacct_init.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cacct_init.h
17568 --- linux-2.6.32.10/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17569 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cacct_init.h 2009-12-03 20:04:56.000000000 +0100
17573 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17578 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17579 + for (j = 0; j < 3; j++) {
17580 + atomic_long_set(&cacct->sock[i][j].count, 0);
17581 + atomic_long_set(&cacct->sock[i][j].total, 0);
17584 + for (i = 0; i < 8; i++)
17585 + atomic_set(&cacct->slab[i], 0);
17586 + for (i = 0; i < 5; i++)
17587 + for (j = 0; j < 4; j++)
17588 + atomic_set(&cacct->page[i][j], 0);
17591 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17596 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/cacct_proc.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cacct_proc.h
17597 --- linux-2.6.32.10/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17598 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cacct_proc.h 2009-12-03 20:04:56.000000000 +0100
17600 +#ifndef _VX_CACCT_PROC_H
17601 +#define _VX_CACCT_PROC_H
17603 +#include <linux/vserver/cacct_int.h>
17606 +#define VX_SOCKA_TOP \
17607 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17609 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17611 + int i, j, length = 0;
17612 + static char *type[VXA_SOCK_SIZE] = {
17613 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17616 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17617 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17618 + length += sprintf(buffer + length, "%s:", type[i]);
17619 + for (j = 0; j < 3; j++) {
17620 + length += sprintf(buffer + length,
17621 + "\t%10lu/%-10lu",
17622 + vx_sock_count(cacct, i, j),
17623 + vx_sock_total(cacct, i, j));
17625 + buffer[length++] = '\n';
17628 + length += sprintf(buffer + length, "\n");
17629 + length += sprintf(buffer + length,
17630 + "slab:\t %8u %8u %8u %8u\n",
17631 + atomic_read(&cacct->slab[1]),
17632 + atomic_read(&cacct->slab[4]),
17633 + atomic_read(&cacct->slab[0]),
17634 + atomic_read(&cacct->slab[2]));
17636 + length += sprintf(buffer + length, "\n");
17637 + for (i = 0; i < 5; i++) {
17638 + length += sprintf(buffer + length,
17639 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17640 + atomic_read(&cacct->page[i][0]),
17641 + atomic_read(&cacct->page[i][1]),
17642 + atomic_read(&cacct->page[i][2]),
17643 + atomic_read(&cacct->page[i][3]),
17644 + atomic_read(&cacct->page[i][4]),
17645 + atomic_read(&cacct->page[i][5]),
17646 + atomic_read(&cacct->page[i][6]),
17647 + atomic_read(&cacct->page[i][7]));
17652 +#endif /* _VX_CACCT_PROC_H */
17653 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/context.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/context.c
17654 --- linux-2.6.32.10/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17655 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/context.c 2010-03-13 21:49:35.000000000 +0100
17658 + * linux/kernel/vserver/context.c
17660 + * Virtual Server: Context Support
17662 + * Copyright (C) 2003-2007 Herbert Pötzl
17664 + * V0.01 context helper
17665 + * V0.02 vx_ctx_kill syscall command
17666 + * V0.03 replaced context_info calls
17667 + * V0.04 redesign of struct (de)alloc
17668 + * V0.05 rlimit basic implementation
17669 + * V0.06 task_xid and info commands
17670 + * V0.07 context flags and caps
17671 + * V0.08 switch to RCU based hash
17672 + * V0.09 revert to non RCU for now
17673 + * V0.10 and back to working RCU hash
17674 + * V0.11 and back to locking again
17675 + * V0.12 referenced context store
17676 + * V0.13 separate per cpu data
17677 + * V0.14 changed vcmds to vxi arg
17678 + * V0.15 added context stat
17679 + * V0.16 have __create claim() the vxi
17680 + * V0.17 removed older and legacy stuff
17684 +#include <linux/slab.h>
17685 +#include <linux/types.h>
17686 +#include <linux/security.h>
17687 +#include <linux/pid_namespace.h>
17689 +#include <linux/vserver/context.h>
17690 +#include <linux/vserver/network.h>
17691 +#include <linux/vserver/debug.h>
17692 +#include <linux/vserver/limit.h>
17693 +#include <linux/vserver/limit_int.h>
17694 +#include <linux/vserver/space.h>
17695 +#include <linux/init_task.h>
17696 +#include <linux/fs_struct.h>
17698 +#include <linux/vs_context.h>
17699 +#include <linux/vs_limit.h>
17700 +#include <linux/vs_pid.h>
17701 +#include <linux/vserver/context_cmd.h>
17703 +#include "cvirt_init.h"
17704 +#include "cacct_init.h"
17705 +#include "limit_init.h"
17706 +#include "sched_init.h"
17709 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17710 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17713 +/* now inactive context structures */
17715 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17717 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17720 +/* __alloc_vx_info()
17722 + * allocate an initialized vx_info struct
17723 + * doesn't make it visible (hash) */
17725 +static struct vx_info *__alloc_vx_info(xid_t xid)
17727 + struct vx_info *new = NULL;
17730 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17732 + /* would this benefit from a slab cache? */
17733 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17737 + memset(new, 0, sizeof(struct vx_info));
17739 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17740 + if (!new->ptr_pc)
17743 + new->vx_id = xid;
17744 + INIT_HLIST_NODE(&new->vx_hlist);
17745 + atomic_set(&new->vx_usecnt, 0);
17746 + atomic_set(&new->vx_tasks, 0);
17747 + new->vx_parent = NULL;
17748 + new->vx_state = 0;
17749 + init_waitqueue_head(&new->vx_wait);
17751 + /* prepare reaper */
17752 + get_task_struct(init_pid_ns.child_reaper);
17753 + new->vx_reaper = init_pid_ns.child_reaper;
17754 + new->vx_badness_bias = 0;
17756 + /* rest of init goes here */
17757 + vx_info_init_limit(&new->limit);
17758 + vx_info_init_sched(&new->sched);
17759 + vx_info_init_cvirt(&new->cvirt);
17760 + vx_info_init_cacct(&new->cacct);
17762 + /* per cpu data structures */
17763 + for_each_possible_cpu(cpu) {
17764 + vx_info_init_sched_pc(
17765 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17766 + vx_info_init_cvirt_pc(
17767 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17770 + new->vx_flags = VXF_INIT_SET;
17771 + cap_set_init_eff(new->vx_bcaps);
17772 + new->vx_ccaps = 0;
17773 + new->vx_umask = 0;
17775 + new->reboot_cmd = 0;
17776 + new->exit_code = 0;
17778 + // preconfig fs entries
17779 + for (index = 0; index < VX_SPACES; index++) {
17780 + write_lock(&init_fs.lock);
17782 + write_unlock(&init_fs.lock);
17783 + new->vx_fs[index] = &init_fs;
17786 + vxdprintk(VXD_CBIT(xid, 0),
17787 + "alloc_vx_info(%d) = %p", xid, new);
17788 + vxh_alloc_vx_info(new);
17789 + atomic_inc(&vx_global_ctotal);
17798 +/* __dealloc_vx_info()
17800 + * final disposal of vx_info */
17802 +static void __dealloc_vx_info(struct vx_info *vxi)
17804 +#ifdef CONFIG_VSERVER_WARN
17805 + struct vx_info_save vxis;
17808 + vxdprintk(VXD_CBIT(xid, 0),
17809 + "dealloc_vx_info(%p)", vxi);
17810 + vxh_dealloc_vx_info(vxi);
17812 +#ifdef CONFIG_VSERVER_WARN
17813 + enter_vx_info(vxi, &vxis);
17814 + vx_info_exit_limit(&vxi->limit);
17815 + vx_info_exit_sched(&vxi->sched);
17816 + vx_info_exit_cvirt(&vxi->cvirt);
17817 + vx_info_exit_cacct(&vxi->cacct);
17819 + for_each_possible_cpu(cpu) {
17820 + vx_info_exit_sched_pc(
17821 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17822 + vx_info_exit_cvirt_pc(
17823 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17825 + leave_vx_info(&vxis);
17829 + vxi->vx_state |= VXS_RELEASED;
17832 + free_percpu(vxi->ptr_pc);
17835 + atomic_dec(&vx_global_ctotal);
17838 +static void __shutdown_vx_info(struct vx_info *vxi)
17840 + struct nsproxy *nsproxy;
17841 + struct fs_struct *fs;
17846 + vxi->vx_state |= VXS_SHUTDOWN;
17847 + vs_state_change(vxi, VSC_SHUTDOWN);
17849 + for (index = 0; index < VX_SPACES; index++) {
17850 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17852 + put_nsproxy(nsproxy);
17854 + fs = xchg(&vxi->vx_fs[index], NULL);
17855 + write_lock(&fs->lock);
17856 + kill = !--fs->users;
17857 + write_unlock(&fs->lock);
17859 + free_fs_struct(fs);
17863 +/* exported stuff */
17865 +void free_vx_info(struct vx_info *vxi)
17867 + unsigned long flags;
17870 + /* check for reference counts first */
17871 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17872 + BUG_ON(atomic_read(&vxi->vx_tasks));
17874 + /* context must not be hashed */
17875 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17877 + /* context shutdown is mandatory */
17878 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17880 + /* nsproxy and fs check */
17881 + for (index = 0; index < VX_SPACES; index++) {
17882 + BUG_ON(vxi->vx_nsproxy[index]);
17883 + BUG_ON(vxi->vx_fs[index]);
17886 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17887 + hlist_del(&vxi->vx_hlist);
17888 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17890 + __dealloc_vx_info(vxi);
17894 +/* hash table for vx_info hash */
17896 +#define VX_HASH_SIZE 13
17898 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17899 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17901 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17904 +static inline unsigned int __hashval(xid_t xid)
17906 + return (xid % VX_HASH_SIZE);
17911 +/* __hash_vx_info()
17913 + * add the vxi to the global hash table
17914 + * requires the hash_lock to be held */
17916 +static inline void __hash_vx_info(struct vx_info *vxi)
17918 + struct hlist_head *head;
17920 + vxd_assert_lock(&vx_info_hash_lock);
17921 + vxdprintk(VXD_CBIT(xid, 4),
17922 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17923 + vxh_hash_vx_info(vxi);
17925 + /* context must not be hashed */
17926 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17928 + vxi->vx_state |= VXS_HASHED;
17929 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17930 + hlist_add_head(&vxi->vx_hlist, head);
17931 + atomic_inc(&vx_global_cactive);
17934 +/* __unhash_vx_info()
17936 + * remove the vxi from the global hash table
17937 + * requires the hash_lock to be held */
17939 +static inline void __unhash_vx_info(struct vx_info *vxi)
17941 + unsigned long flags;
17943 + vxd_assert_lock(&vx_info_hash_lock);
17944 + vxdprintk(VXD_CBIT(xid, 4),
17945 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17946 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17947 + vxh_unhash_vx_info(vxi);
17949 + /* context must be hashed */
17950 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17951 + /* but without tasks */
17952 + BUG_ON(atomic_read(&vxi->vx_tasks));
17954 + vxi->vx_state &= ~VXS_HASHED;
17955 + hlist_del_init(&vxi->vx_hlist);
17956 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17957 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17958 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17959 + atomic_dec(&vx_global_cactive);
17963 +/* __lookup_vx_info()
17965 + * requires the hash_lock to be held
17966 + * doesn't increment the vx_refcnt */
17968 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17970 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17971 + struct hlist_node *pos;
17972 + struct vx_info *vxi;
17974 + vxd_assert_lock(&vx_info_hash_lock);
17975 + hlist_for_each(pos, head) {
17976 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17978 + if (vxi->vx_id == xid)
17983 + vxdprintk(VXD_CBIT(xid, 0),
17984 + "__lookup_vx_info(#%u): %p[#%u]",
17985 + xid, vxi, vxi ? vxi->vx_id : 0);
17986 + vxh_lookup_vx_info(vxi, xid);
17991 +/* __create_vx_info()
17993 + * create the requested context
17994 + * get(), claim() and hash it */
17996 +static struct vx_info *__create_vx_info(int id)
17998 + struct vx_info *new, *vxi = NULL;
18000 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18002 + if (!(new = __alloc_vx_info(id)))
18003 + return ERR_PTR(-ENOMEM);
18005 + /* required to make dynamic xids unique */
18006 + spin_lock(&vx_info_hash_lock);
18008 + /* static context requested */
18009 + if ((vxi = __lookup_vx_info(id))) {
18010 + vxdprintk(VXD_CBIT(xid, 0),
18011 + "create_vx_info(%d) = %p (already there)", id, vxi);
18012 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18013 + vxi = ERR_PTR(-EBUSY);
18015 + vxi = ERR_PTR(-EEXIST);
18018 + /* new context */
18019 + vxdprintk(VXD_CBIT(xid, 0),
18020 + "create_vx_info(%d) = %p (new)", id, new);
18021 + claim_vx_info(new, NULL);
18022 + __hash_vx_info(get_vx_info(new));
18023 + vxi = new, new = NULL;
18026 + spin_unlock(&vx_info_hash_lock);
18027 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18029 + __dealloc_vx_info(new);
18034 +/* exported stuff */
18037 +void unhash_vx_info(struct vx_info *vxi)
18039 + __shutdown_vx_info(vxi);
18040 + spin_lock(&vx_info_hash_lock);
18041 + __unhash_vx_info(vxi);
18042 + spin_unlock(&vx_info_hash_lock);
18043 + __wakeup_vx_info(vxi);
18047 +/* lookup_vx_info()
18049 + * search for a vx_info and get() it
18050 + * negative id means current */
18052 +struct vx_info *lookup_vx_info(int id)
18054 + struct vx_info *vxi = NULL;
18057 + vxi = get_vx_info(current_vx_info());
18058 + } else if (id > 1) {
18059 + spin_lock(&vx_info_hash_lock);
18060 + vxi = get_vx_info(__lookup_vx_info(id));
18061 + spin_unlock(&vx_info_hash_lock);
18066 +/* xid_is_hashed()
18068 + * verify that xid is still hashed */
18070 +int xid_is_hashed(xid_t xid)
18074 + spin_lock(&vx_info_hash_lock);
18075 + hashed = (__lookup_vx_info(xid) != NULL);
18076 + spin_unlock(&vx_info_hash_lock);
18080 +#ifdef CONFIG_PROC_FS
18084 + * get a subset of hashed xids for proc
18085 + * assumes size is at least one */
18087 +int get_xid_list(int index, unsigned int *xids, int size)
18089 + int hindex, nr_xids = 0;
18091 + /* only show current and children */
18092 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18095 + xids[nr_xids] = vx_current_xid();
18099 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18100 + struct hlist_head *head = &vx_info_hash[hindex];
18101 + struct hlist_node *pos;
18103 + spin_lock(&vx_info_hash_lock);
18104 + hlist_for_each(pos, head) {
18105 + struct vx_info *vxi;
18110 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18111 + xids[nr_xids] = vxi->vx_id;
18112 + if (++nr_xids >= size) {
18113 + spin_unlock(&vx_info_hash_lock);
18117 + /* keep the lock time short */
18118 + spin_unlock(&vx_info_hash_lock);
18125 +#ifdef CONFIG_VSERVER_DEBUG
18127 +void dump_vx_info_inactive(int level)
18129 + struct hlist_node *entry, *next;
18131 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18132 + struct vx_info *vxi =
18133 + list_entry(entry, struct vx_info, vx_hlist);
18135 + dump_vx_info(vxi, level);
18142 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18144 + struct user_struct *new_user, *old_user;
18149 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18152 + new_user = alloc_uid(vxi->vx_id, p->uid);
18156 + old_user = p->user;
18157 + if (new_user != old_user) {
18158 + atomic_inc(&new_user->processes);
18159 + atomic_dec(&old_user->processes);
18160 + p->user = new_user;
18162 + free_uid(old_user);
18168 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18170 + // p->cap_effective &= vxi->vx_cap_bset;
18171 + p->cap_effective =
18172 + cap_intersect(p->cap_effective, vxi->cap_bset);
18173 + // p->cap_inheritable &= vxi->vx_cap_bset;
18174 + p->cap_inheritable =
18175 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18176 + // p->cap_permitted &= vxi->vx_cap_bset;
18177 + p->cap_permitted =
18178 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18183 +#include <linux/file.h>
18184 +#include <linux/fdtable.h>
18186 +static int vx_openfd_task(struct task_struct *tsk)
18188 + struct files_struct *files = tsk->files;
18189 + struct fdtable *fdt;
18190 + const unsigned long *bptr;
18191 + int count, total;
18193 + /* no rcu_read_lock() because of spin_lock() */
18194 + spin_lock(&files->file_lock);
18195 + fdt = files_fdtable(files);
18196 + bptr = fdt->open_fds->fds_bits;
18197 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18198 + for (total = 0; count > 0; count--) {
18200 + total += hweight_long(*bptr);
18203 + spin_unlock(&files->file_lock);
18208 +/* for *space compatibility */
18210 +asmlinkage long sys_unshare(unsigned long);
18213 + * migrate task to new context
18214 + * gets vxi, puts old_vxi on change
18215 + * optionally unshares namespaces (hack)
18218 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18220 + struct vx_info *old_vxi;
18226 + vxdprintk(VXD_CBIT(xid, 5),
18227 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18228 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18230 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18231 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18234 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18237 + old_vxi = task_get_vx_info(p);
18238 + if (old_vxi == vxi)
18241 +// if (!(ret = vx_migrate_user(p, vxi))) {
18246 + openfd = vx_openfd_task(p);
18249 + atomic_dec(&old_vxi->cvirt.nr_threads);
18250 + atomic_dec(&old_vxi->cvirt.nr_running);
18251 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18252 + /* FIXME: what about the struct files here? */
18253 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18254 + /* account for the executable */
18255 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18257 + atomic_inc(&vxi->cvirt.nr_threads);
18258 + atomic_inc(&vxi->cvirt.nr_running);
18259 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18260 + /* FIXME: what about the struct files here? */
18261 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18262 + /* account for the executable */
18263 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18266 + release_vx_info(old_vxi, p);
18267 + clr_vx_info(&p->vx_info);
18269 + claim_vx_info(vxi, p);
18270 + set_vx_info(&p->vx_info, vxi);
18271 + p->xid = vxi->vx_id;
18273 + vxdprintk(VXD_CBIT(xid, 5),
18274 + "moved task %p into vxi:%p[#%d]",
18275 + p, vxi, vxi->vx_id);
18277 + // vx_mask_cap_bset(vxi, p);
18280 + /* hack for *spaces to provide compatibility */
18282 + struct nsproxy *old_nsp, *new_nsp;
18284 + ret = unshare_nsproxy_namespaces(
18285 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18290 + old_nsp = xchg(&p->nsproxy, new_nsp);
18291 + vx_set_space(vxi,
18292 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18293 + put_nsproxy(old_nsp);
18297 + put_vx_info(old_vxi);
18301 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18303 + struct task_struct *old_reaper;
18308 + vxdprintk(VXD_CBIT(xid, 6),
18309 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18310 + vxi, vxi->vx_id, p, p->xid, p->pid);
18312 + old_reaper = vxi->vx_reaper;
18313 + if (old_reaper == p)
18316 + /* set new child reaper */
18317 + get_task_struct(p);
18318 + vxi->vx_reaper = p;
18319 + put_task_struct(old_reaper);
18323 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18328 + vxdprintk(VXD_CBIT(xid, 6),
18329 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18330 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18332 + vxi->vx_flags &= ~VXF_STATE_INIT;
18333 + // vxi->vx_initpid = p->tgid;
18334 + vxi->vx_initpid = p->pid;
18338 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18340 + vxdprintk(VXD_CBIT(xid, 6),
18341 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18342 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18344 + vxi->exit_code = code;
18345 + vxi->vx_initpid = 0;
18349 +void vx_set_persistent(struct vx_info *vxi)
18351 + vxdprintk(VXD_CBIT(xid, 6),
18352 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18354 + get_vx_info(vxi);
18355 + claim_vx_info(vxi, NULL);
18358 +void vx_clear_persistent(struct vx_info *vxi)
18360 + vxdprintk(VXD_CBIT(xid, 6),
18361 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18363 + release_vx_info(vxi, NULL);
18364 + put_vx_info(vxi);
18367 +void vx_update_persistent(struct vx_info *vxi)
18369 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18370 + vx_set_persistent(vxi);
18372 + vx_clear_persistent(vxi);
18376 +/* task must be current or locked */
18378 +void exit_vx_info(struct task_struct *p, int code)
18380 + struct vx_info *vxi = p->vx_info;
18383 + atomic_dec(&vxi->cvirt.nr_threads);
18386 + vxi->exit_code = code;
18387 + release_vx_info(vxi, p);
18391 +void exit_vx_info_early(struct task_struct *p, int code)
18393 + struct vx_info *vxi = p->vx_info;
18396 + if (vxi->vx_initpid == p->pid)
18397 + vx_exit_init(vxi, p, code);
18398 + if (vxi->vx_reaper == p)
18399 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18404 +/* vserver syscall commands below here */
18406 +/* taks xid and vx_info functions */
18408 +#include <asm/uaccess.h>
18411 +int vc_task_xid(uint32_t id)
18416 + struct task_struct *tsk;
18418 + read_lock(&tasklist_lock);
18419 + tsk = find_task_by_real_pid(id);
18420 + xid = (tsk) ? tsk->xid : -ESRCH;
18421 + read_unlock(&tasklist_lock);
18423 + xid = vx_current_xid();
18428 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18430 + struct vcmd_vx_info_v0 vc_data;
18432 + vc_data.xid = vxi->vx_id;
18433 + vc_data.initpid = vxi->vx_initpid;
18435 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18441 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18443 + struct vcmd_ctx_stat_v0 vc_data;
18445 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18446 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18448 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18454 +/* context functions */
18456 +int vc_ctx_create(uint32_t xid, void __user *data)
18458 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18459 + struct vx_info *new_vxi;
18462 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18465 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18468 + new_vxi = __create_vx_info(xid);
18469 + if (IS_ERR(new_vxi))
18470 + return PTR_ERR(new_vxi);
18472 + /* initial flags */
18473 + new_vxi->vx_flags = vc_data.flagword;
18476 + if (vs_state_change(new_vxi, VSC_STARTUP))
18479 + ret = vx_migrate_task(current, new_vxi, (!data));
18483 + /* return context id on success */
18484 + ret = new_vxi->vx_id;
18486 + /* get a reference for persistent contexts */
18487 + if ((vc_data.flagword & VXF_PERSISTENT))
18488 + vx_set_persistent(new_vxi);
18490 + release_vx_info(new_vxi, NULL);
18491 + put_vx_info(new_vxi);
18496 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18498 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18501 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18504 + ret = vx_migrate_task(current, vxi, 0);
18507 + if (vc_data.flagword & VXM_SET_INIT)
18508 + ret = vx_set_init(vxi, current);
18511 + if (vc_data.flagword & VXM_SET_REAPER)
18512 + ret = vx_set_reaper(vxi, current);
18517 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18519 + struct vcmd_ctx_flags_v0 vc_data;
18521 + vc_data.flagword = vxi->vx_flags;
18523 + /* special STATE flag handling */
18524 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18526 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18531 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18533 + struct vcmd_ctx_flags_v0 vc_data;
18534 + uint64_t mask, trigger;
18536 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18539 + /* special STATE flag handling */
18540 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18541 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18543 + if (vxi == current_vx_info()) {
18544 + /* if (trigger & VXF_STATE_SETUP)
18545 + vx_mask_cap_bset(vxi, current); */
18546 + if (trigger & VXF_STATE_INIT) {
18549 + ret = vx_set_init(vxi, current);
18552 + ret = vx_set_reaper(vxi, current);
18558 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18559 + vc_data.flagword, mask);
18560 + if (trigger & VXF_PERSISTENT)
18561 + vx_update_persistent(vxi);
18567 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18569 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18571 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18575 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18577 + kernel_cap_t c = __cap_empty_set;
18579 + c.cap[0] = v & 0xFFFFFFFF;
18580 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18582 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18587 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18590 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18592 + *ccaps = vxi->vx_ccaps;
18597 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18599 + struct vcmd_ctx_caps_v1 vc_data;
18602 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18605 + vc_data.cmask = ~0ULL;
18607 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18612 +static int do_set_caps(struct vx_info *vxi,
18613 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18615 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18618 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18619 + bcaps, bmask, ccaps, cmask);
18621 + vxi->vx_bcaps = cap_t_from_caps(
18622 + vs_mask_flags(bcold, bcaps, bmask));
18623 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18628 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18630 + struct vcmd_ctx_caps_v1 vc_data;
18632 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18635 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18638 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18640 + struct vcmd_bcaps vc_data;
18643 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18646 + vc_data.bmask = ~0ULL;
18648 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18653 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18655 + struct vcmd_bcaps vc_data;
18657 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18660 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18664 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18666 + struct vcmd_umask vc_data;
18668 + vc_data.umask = vxi->vx_umask;
18669 + vc_data.mask = ~0ULL;
18671 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18676 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18678 + struct vcmd_umask vc_data;
18680 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18683 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18684 + vc_data.umask, vc_data.mask);
18689 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18691 + struct vcmd_badness_v0 vc_data;
18693 + vc_data.bias = vxi->vx_badness_bias;
18695 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18700 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18702 + struct vcmd_badness_v0 vc_data;
18704 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18707 + vxi->vx_badness_bias = vc_data.bias;
18711 +#include <linux/module.h>
18713 +EXPORT_SYMBOL_GPL(free_vx_info);
18715 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/cvirt.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cvirt.c
18716 --- linux-2.6.32.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18717 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cvirt.c 2009-12-03 20:04:56.000000000 +0100
18720 + * linux/kernel/vserver/cvirt.c
18722 + * Virtual Server: Context Virtualization
18724 + * Copyright (C) 2004-2007 Herbert Pötzl
18726 + * V0.01 broken out from limit.c
18727 + * V0.02 added utsname stuff
18728 + * V0.03 changed vcmds to vxi arg
18732 +#include <linux/types.h>
18733 +#include <linux/utsname.h>
18734 +#include <linux/vs_cvirt.h>
18735 +#include <linux/vserver/switch.h>
18736 +#include <linux/vserver/cvirt_cmd.h>
18738 +#include <asm/uaccess.h>
18741 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18743 + struct vx_info *vxi = current_vx_info();
18745 + set_normalized_timespec(uptime,
18746 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18747 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18750 + set_normalized_timespec(idle,
18751 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18752 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18756 +uint64_t vx_idle_jiffies(void)
18758 + return init_task.utime + init_task.stime;
18763 +static inline uint32_t __update_loadavg(uint32_t load,
18764 + int wsize, int delta, int n)
18766 + unsigned long long calc, prev;
18768 + /* just set it to n */
18769 + if (unlikely(delta >= wsize))
18770 + return (n << FSHIFT);
18772 + calc = delta * n;
18774 + prev = (wsize - delta);
18777 + do_div(calc, wsize);
18782 +void vx_update_load(struct vx_info *vxi)
18784 + uint32_t now, last, delta;
18785 + unsigned int nr_running, nr_uninterruptible;
18786 + unsigned int total;
18787 + unsigned long flags;
18789 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18792 + last = vxi->cvirt.load_last;
18793 + delta = now - last;
18795 + if (delta < 5*HZ)
18798 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18799 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18800 + total = nr_running + nr_uninterruptible;
18802 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18803 + 60*HZ, delta, total);
18804 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18805 + 5*60*HZ, delta, total);
18806 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18807 + 15*60*HZ, delta, total);
18809 + vxi->cvirt.load_last = now;
18811 + atomic_inc(&vxi->cvirt.load_updates);
18812 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18817 + * Commands to do_syslog:
18819 + * 0 -- Close the log. Currently a NOP.
18820 + * 1 -- Open the log. Currently a NOP.
18821 + * 2 -- Read from the log.
18822 + * 3 -- Read all messages remaining in the ring buffer.
18823 + * 4 -- Read and clear all messages remaining in the ring buffer
18824 + * 5 -- Clear ring buffer.
18825 + * 6 -- Disable printk's to console
18826 + * 7 -- Enable printk's to console
18827 + * 8 -- Set level of messages printed to console
18828 + * 9 -- Return number of unread characters in the log buffer
18829 + * 10 -- Return size of the log buffer
18831 +int vx_do_syslog(int type, char __user *buf, int len)
18834 + int do_clear = 0;
18835 + struct vx_info *vxi = current_vx_info();
18836 + struct _vx_syslog *log;
18840 + log = &vxi->cvirt.syslog;
18843 + case 0: /* Close log */
18844 + case 1: /* Open log */
18846 + case 2: /* Read from log */
18847 + error = wait_event_interruptible(log->log_wait,
18848 + (log->log_start - log->log_end));
18851 + spin_lock_irq(&log->logbuf_lock);
18852 + spin_unlock_irq(&log->logbuf_lock);
18854 + case 4: /* Read/clear last kernel messages */
18856 + /* fall through */
18857 + case 3: /* Read last kernel messages */
18860 + case 5: /* Clear ring buffer */
18863 + case 6: /* Disable logging to console */
18864 + case 7: /* Enable logging to console */
18865 + case 8: /* Set level of messages printed to console */
18868 + case 9: /* Number of chars in the log buffer */
18870 + case 10: /* Size of the log buffer */
18880 +/* virtual host info names */
18882 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18884 + struct nsproxy *nsproxy;
18885 + struct uts_namespace *uts;
18887 + if (id == VHIN_CONTEXT)
18888 + return vxi->vx_name;
18890 + nsproxy = vxi->vx_nsproxy[0];
18894 + uts = nsproxy->uts_ns;
18899 + case VHIN_SYSNAME:
18900 + return uts->name.sysname;
18901 + case VHIN_NODENAME:
18902 + return uts->name.nodename;
18903 + case VHIN_RELEASE:
18904 + return uts->name.release;
18905 + case VHIN_VERSION:
18906 + return uts->name.version;
18907 + case VHIN_MACHINE:
18908 + return uts->name.machine;
18909 + case VHIN_DOMAINNAME:
18910 + return uts->name.domainname;
18917 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18919 + struct vcmd_vhi_name_v0 vc_data;
18922 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18925 + name = vx_vhi_name(vxi, vc_data.field);
18929 + memcpy(name, vc_data.name, 65);
18933 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18935 + struct vcmd_vhi_name_v0 vc_data;
18938 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18941 + name = vx_vhi_name(vxi, vc_data.field);
18945 + memcpy(vc_data.name, name, 65);
18946 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18952 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18954 + struct vcmd_virt_stat_v0 vc_data;
18955 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18956 + struct timespec uptime;
18958 + do_posix_clock_monotonic_gettime(&uptime);
18959 + set_normalized_timespec(&uptime,
18960 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18961 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18963 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18964 + vc_data.uptime = timespec_to_ns(&uptime);
18965 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18966 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18967 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18968 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18969 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18970 + vc_data.load[0] = cvirt->load[0];
18971 + vc_data.load[1] = cvirt->load[1];
18972 + vc_data.load[2] = cvirt->load[2];
18974 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18980 +#ifdef CONFIG_VSERVER_VTIME
18982 +/* virtualized time base */
18984 +void vx_gettimeofday(struct timeval *tv)
18986 + struct vx_info *vxi;
18988 + do_gettimeofday(tv);
18989 + if (!vx_flags(VXF_VIRT_TIME, 0))
18992 + vxi = current_vx_info();
18993 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
18994 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
18996 + if (tv->tv_usec >= USEC_PER_SEC) {
18998 + tv->tv_usec -= USEC_PER_SEC;
18999 + } else if (tv->tv_usec < 0) {
19001 + tv->tv_usec += USEC_PER_SEC;
19005 +int vx_settimeofday(struct timespec *ts)
19007 + struct timeval tv;
19008 + struct vx_info *vxi;
19010 + if (!vx_flags(VXF_VIRT_TIME, 0))
19011 + return do_settimeofday(ts);
19013 + do_gettimeofday(&tv);
19014 + vxi = current_vx_info();
19015 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19016 + vxi->cvirt.bias_tv.tv_usec =
19017 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19023 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/cvirt_init.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cvirt_init.h
19024 --- linux-2.6.32.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
19025 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cvirt_init.h 2009-12-03 20:04:56.000000000 +0100
19029 +extern uint64_t vx_idle_jiffies(void);
19031 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19033 + uint64_t idle_jiffies = vx_idle_jiffies();
19034 + uint64_t nsuptime;
19036 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19037 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19038 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19039 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19040 + cvirt->bias_tv.tv_sec = 0;
19041 + cvirt->bias_tv.tv_usec = 0;
19043 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19044 + atomic_set(&cvirt->nr_threads, 0);
19045 + atomic_set(&cvirt->nr_running, 0);
19046 + atomic_set(&cvirt->nr_uninterruptible, 0);
19047 + atomic_set(&cvirt->nr_onhold, 0);
19049 + spin_lock_init(&cvirt->load_lock);
19050 + cvirt->load_last = jiffies;
19051 + atomic_set(&cvirt->load_updates, 0);
19052 + cvirt->load[0] = 0;
19053 + cvirt->load[1] = 0;
19054 + cvirt->load[2] = 0;
19055 + atomic_set(&cvirt->total_forks, 0);
19057 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19058 + init_waitqueue_head(&cvirt->syslog.log_wait);
19059 + cvirt->syslog.log_start = 0;
19060 + cvirt->syslog.log_end = 0;
19061 + cvirt->syslog.con_start = 0;
19062 + cvirt->syslog.logged_chars = 0;
19066 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19068 + // cvirt_pc->cpustat = { 0 };
19071 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19075 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19076 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19078 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19079 + "!!! cvirt: %p[nr_running] = %d on exit.",
19081 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19082 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19084 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19085 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19091 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19096 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/cvirt_proc.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cvirt_proc.h
19097 --- linux-2.6.32.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
19098 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/cvirt_proc.h 2009-12-03 20:04:56.000000000 +0100
19100 +#ifndef _VX_CVIRT_PROC_H
19101 +#define _VX_CVIRT_PROC_H
19103 +#include <linux/nsproxy.h>
19104 +#include <linux/mnt_namespace.h>
19105 +#include <linux/ipc_namespace.h>
19106 +#include <linux/utsname.h>
19107 +#include <linux/ipc.h>
19111 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19113 + struct mnt_namespace *ns;
19114 + struct uts_namespace *uts;
19115 + struct ipc_namespace *ipc;
19116 + struct path path;
19117 + char *pstr, *root;
19123 + length += sprintf(buffer + length,
19124 + "NSProxy:\t%p [%p,%p,%p]\n",
19125 + nsproxy, nsproxy->mnt_ns,
19126 + nsproxy->uts_ns, nsproxy->ipc_ns);
19128 + ns = nsproxy->mnt_ns;
19132 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19136 + path.mnt = ns->root;
19137 + path.dentry = ns->root->mnt_root;
19138 + root = d_path(&path, pstr, PATH_MAX - 2);
19139 + length += sprintf(buffer + length,
19140 + "Namespace:\t%p [#%u]\n"
19141 + "RootPath:\t%s\n",
19142 + ns, atomic_read(&ns->count),
19147 + uts = nsproxy->uts_ns;
19151 + length += sprintf(buffer + length,
19152 + "SysName:\t%.*s\n"
19153 + "NodeName:\t%.*s\n"
19154 + "Release:\t%.*s\n"
19155 + "Version:\t%.*s\n"
19156 + "Machine:\t%.*s\n"
19157 + "DomainName:\t%.*s\n",
19158 + __NEW_UTS_LEN, uts->name.sysname,
19159 + __NEW_UTS_LEN, uts->name.nodename,
19160 + __NEW_UTS_LEN, uts->name.release,
19161 + __NEW_UTS_LEN, uts->name.version,
19162 + __NEW_UTS_LEN, uts->name.machine,
19163 + __NEW_UTS_LEN, uts->name.domainname);
19166 + ipc = nsproxy->ipc_ns;
19170 + length += sprintf(buffer + length,
19171 + "SEMS:\t\t%d %d %d %d %d\n"
19172 + "MSG:\t\t%d %d %d\n"
19173 + "SHM:\t\t%lu %lu %d %d\n",
19174 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19175 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19177 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19178 + (unsigned long)ipc->shm_ctlmax,
19179 + (unsigned long)ipc->shm_ctlall,
19180 + ipc->shm_ctlmni, ipc->shm_tot);
19187 +#include <linux/sched.h>
19189 +#define LOAD_INT(x) ((x) >> FSHIFT)
19190 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19193 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19198 + length += sprintf(buffer + length,
19199 + "BiasUptime:\t%lu.%02lu\n",
19200 + (unsigned long)cvirt->bias_uptime.tv_sec,
19201 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19203 + a = cvirt->load[0] + (FIXED_1 / 200);
19204 + b = cvirt->load[1] + (FIXED_1 / 200);
19205 + c = cvirt->load[2] + (FIXED_1 / 200);
19206 + length += sprintf(buffer + length,
19207 + "nr_threads:\t%d\n"
19208 + "nr_running:\t%d\n"
19209 + "nr_unintr:\t%d\n"
19210 + "nr_onhold:\t%d\n"
19211 + "load_updates:\t%d\n"
19212 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19213 + "total_forks:\t%d\n",
19214 + atomic_read(&cvirt->nr_threads),
19215 + atomic_read(&cvirt->nr_running),
19216 + atomic_read(&cvirt->nr_uninterruptible),
19217 + atomic_read(&cvirt->nr_onhold),
19218 + atomic_read(&cvirt->load_updates),
19219 + LOAD_INT(a), LOAD_FRAC(a),
19220 + LOAD_INT(b), LOAD_FRAC(b),
19221 + LOAD_INT(c), LOAD_FRAC(c),
19222 + atomic_read(&cvirt->total_forks));
19227 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19228 + char *buffer, int cpu)
19234 +#endif /* _VX_CVIRT_PROC_H */
19235 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/debug.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/debug.c
19236 --- linux-2.6.32.10/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19237 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/debug.c 2009-12-03 20:04:56.000000000 +0100
19240 + * kernel/vserver/debug.c
19242 + * Copyright (C) 2005-2007 Herbert Pötzl
19244 + * V0.01 vx_info dump support
19248 +#include <linux/module.h>
19250 +#include <linux/vserver/context.h>
19253 +void dump_vx_info(struct vx_info *vxi, int level)
19255 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19256 + atomic_read(&vxi->vx_usecnt),
19257 + atomic_read(&vxi->vx_tasks),
19260 + __dump_vx_limit(&vxi->limit);
19261 + __dump_vx_sched(&vxi->sched);
19262 + __dump_vx_cvirt(&vxi->cvirt);
19263 + __dump_vx_cacct(&vxi->cacct);
19269 +EXPORT_SYMBOL_GPL(dump_vx_info);
19271 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/device.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/device.c
19272 --- linux-2.6.32.10/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19273 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/device.c 2009-12-03 20:04:56.000000000 +0100
19276 + * linux/kernel/vserver/device.c
19278 + * Linux-VServer: Device Support
19280 + * Copyright (C) 2006 Herbert Pötzl
19281 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19283 + * V0.01 device mapping basics
19284 + * V0.02 added defaults
19288 +#include <linux/slab.h>
19289 +#include <linux/rcupdate.h>
19290 +#include <linux/fs.h>
19291 +#include <linux/namei.h>
19292 +#include <linux/hash.h>
19294 +#include <asm/errno.h>
19295 +#include <asm/uaccess.h>
19296 +#include <linux/vserver/base.h>
19297 +#include <linux/vserver/debug.h>
19298 +#include <linux/vserver/context.h>
19299 +#include <linux/vserver/device.h>
19300 +#include <linux/vserver/device_cmd.h>
19303 +#define DMAP_HASH_BITS 4
19306 +struct vs_mapping {
19308 + struct hlist_node hlist;
19309 + struct list_head list;
19311 +#define dm_hlist u.hlist
19312 +#define dm_list u.list
19315 + struct vx_dmap_target target;
19319 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19321 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19323 +static struct vx_dmap_target dmap_defaults[2] = {
19324 + { .flags = DATTR_OPEN },
19325 + { .flags = DATTR_OPEN },
19329 +struct kmem_cache *dmap_cachep __read_mostly;
19331 +int __init dmap_cache_init(void)
19333 + dmap_cachep = kmem_cache_create("dmap_cache",
19334 + sizeof(struct vs_mapping), 0,
19335 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19339 +__initcall(dmap_cache_init);
19342 +static inline unsigned int __hashval(dev_t dev, int bits)
19344 + return hash_long((unsigned long)dev, bits);
19348 +/* __hash_mapping()
19349 + * add the mapping to the hash table
19351 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19353 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19354 + struct hlist_head *head, *hash = dmap_main_hash;
19355 + int device = vdm->device;
19357 + spin_lock(hash_lock);
19358 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19359 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19361 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19362 + hlist_add_head(&vdm->dm_hlist, head);
19363 + spin_unlock(hash_lock);
19367 +static inline int __mode_to_default(umode_t mode)
19380 +/* __set_default()
19383 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19384 + struct vx_dmap_target *vdmt)
19386 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19387 + spin_lock(hash_lock);
19390 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19392 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19395 + spin_unlock(hash_lock);
19397 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19398 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19402 +/* __remove_default()
19403 + * remove a default
19405 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19407 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19408 + spin_lock(hash_lock);
19411 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19412 + else /* remove == reset */
19413 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19415 + spin_unlock(hash_lock);
19420 +/* __find_mapping()
19421 + * find a mapping in the hash table
19423 + * caller must hold hash_lock
19425 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19426 + struct vs_mapping **local, struct vs_mapping **global)
19428 + struct hlist_head *hash = dmap_main_hash;
19429 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19430 + struct hlist_node *pos;
19431 + struct vs_mapping *vdm;
19437 + hlist_for_each(pos, head) {
19438 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19440 + if ((vdm->device == device) &&
19441 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19442 + if (vdm->xid == xid) {
19445 + } else if (global && vdm->xid == 0)
19450 + if (global && *global)
19457 +/* __lookup_mapping()
19458 + * find a mapping and store the result in target and flags
19460 +static inline int __lookup_mapping(struct vx_info *vxi,
19461 + dev_t device, dev_t *target, int *flags, umode_t mode)
19463 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19464 + struct vs_mapping *vdm, *global;
19465 + struct vx_dmap_target *vdmt;
19467 + xid_t xid = vxi->vx_id;
19470 + spin_lock(hash_lock);
19471 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19473 + vdmt = &vdm->target;
19477 + index = __mode_to_default(mode);
19478 + if (vxi && vxi->dmap.targets[index].flags) {
19480 + vdmt = &vxi->dmap.targets[index];
19481 + } else if (global) {
19483 + vdmt = &global->target;
19487 + vdmt = &dmap_defaults[index];
19491 + if (target && (vdmt->flags & DATTR_REMAP))
19492 + *target = vdmt->target;
19494 + *target = device;
19496 + *flags = vdmt->flags;
19498 + spin_unlock(hash_lock);
19504 +/* __remove_mapping()
19505 + * remove a mapping from the hash table
19507 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19510 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19511 + struct vs_mapping *vdm = NULL;
19514 + spin_lock(hash_lock);
19516 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19518 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19519 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19522 + hlist_del(&vdm->dm_hlist);
19525 + spin_unlock(hash_lock);
19527 + kmem_cache_free(dmap_cachep, vdm);
19533 +int vs_map_device(struct vx_info *vxi,
19534 + dev_t device, dev_t *target, umode_t mode)
19536 + int ret, flags = DATTR_MASK;
19540 + *target = device;
19543 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19544 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19545 + device, target ? *target : 0, flags, mode, ret);
19547 + return (flags & DATTR_MASK);
19552 +static int do_set_mapping(struct vx_info *vxi,
19553 + dev_t device, dev_t target, int flags, umode_t mode)
19556 + struct vs_mapping *new;
19558 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19562 + INIT_HLIST_NODE(&new->dm_hlist);
19563 + new->device = device;
19564 + new->target.target = target;
19565 + new->target.flags = flags | mode;
19566 + new->xid = (vxi ? vxi->vx_id : 0);
19568 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19569 + __hash_mapping(vxi, new);
19571 + struct vx_dmap_target new = {
19572 + .target = target,
19573 + .flags = flags | mode,
19575 + __set_default(vxi, mode, &new);
19581 +static int do_unset_mapping(struct vx_info *vxi,
19582 + dev_t device, dev_t target, int flags, umode_t mode)
19584 + int ret = -EINVAL;
19587 + ret = __remove_mapping(vxi, device, mode);
19591 + ret = __remove_default(vxi, mode);
19601 +static inline int __user_device(const char __user *name, dev_t *dev,
19604 + struct nameidata nd;
19611 + ret = user_lpath(name, &nd.path);
19614 + if (nd.path.dentry->d_inode) {
19615 + *dev = nd.path.dentry->d_inode->i_rdev;
19616 + *mode = nd.path.dentry->d_inode->i_mode;
19618 + path_put(&nd.path);
19622 +static inline int __mapping_mode(dev_t device, dev_t target,
19623 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19626 + *mode = device_mode & S_IFMT;
19628 + *mode = target_mode & S_IFMT;
19632 + /* if both given, device and target mode have to match */
19633 + if (device && target &&
19634 + ((device_mode ^ target_mode) & S_IFMT))
19640 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19641 + const char __user *target_path, int flags, int set)
19643 + dev_t device = ~0, target = ~0;
19644 + umode_t device_mode = 0, target_mode = 0, mode;
19647 + ret = __user_device(device_path, &device, &device_mode);
19650 + ret = __user_device(target_path, &target, &target_mode);
19654 + ret = __mapping_mode(device, target,
19655 + device_mode, target_mode, &mode);
19660 + return do_set_mapping(vxi, device, target,
19663 + return do_unset_mapping(vxi, device, target,
19668 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19670 + struct vcmd_set_mapping_v0 vc_data;
19672 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19675 + return do_mapping(vxi, vc_data.device, vc_data.target,
19676 + vc_data.flags, 1);
19679 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19681 + struct vcmd_set_mapping_v0 vc_data;
19683 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19686 + return do_mapping(vxi, vc_data.device, vc_data.target,
19687 + vc_data.flags, 0);
19691 +#ifdef CONFIG_COMPAT
19693 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19695 + struct vcmd_set_mapping_v0_x32 vc_data;
19697 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19700 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19701 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19704 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19706 + struct vcmd_set_mapping_v0_x32 vc_data;
19708 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19711 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19712 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19715 +#endif /* CONFIG_COMPAT */
19718 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/dlimit.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/dlimit.c
19719 --- linux-2.6.32.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19720 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/dlimit.c 2009-12-03 20:04:56.000000000 +0100
19723 + * linux/kernel/vserver/dlimit.c
19725 + * Virtual Server: Context Disk Limits
19727 + * Copyright (C) 2004-2009 Herbert Pötzl
19729 + * V0.01 initial version
19730 + * V0.02 compat32 splitup
19731 + * V0.03 extended interface
19735 +#include <linux/statfs.h>
19736 +#include <linux/sched.h>
19737 +#include <linux/namei.h>
19738 +#include <linux/vs_tag.h>
19739 +#include <linux/vs_dlimit.h>
19740 +#include <linux/vserver/dlimit_cmd.h>
19742 +#include <asm/uaccess.h>
19744 +/* __alloc_dl_info()
19746 + * allocate an initialized dl_info struct
19747 + * doesn't make it visible (hash) */
19749 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19751 + struct dl_info *new = NULL;
19753 + vxdprintk(VXD_CBIT(dlim, 5),
19754 + "alloc_dl_info(%p,%d)*", sb, tag);
19756 + /* would this benefit from a slab cache? */
19757 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19761 + memset(new, 0, sizeof(struct dl_info));
19762 + new->dl_tag = tag;
19764 + INIT_RCU_HEAD(&new->dl_rcu);
19765 + INIT_HLIST_NODE(&new->dl_hlist);
19766 + spin_lock_init(&new->dl_lock);
19767 + atomic_set(&new->dl_refcnt, 0);
19768 + atomic_set(&new->dl_usecnt, 0);
19770 + /* rest of init goes here */
19772 + vxdprintk(VXD_CBIT(dlim, 4),
19773 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19777 +/* __dealloc_dl_info()
19779 + * final disposal of dl_info */
19781 +static void __dealloc_dl_info(struct dl_info *dli)
19783 + vxdprintk(VXD_CBIT(dlim, 4),
19784 + "dealloc_dl_info(%p)", dli);
19786 + dli->dl_hlist.next = LIST_POISON1;
19787 + dli->dl_tag = -1;
19790 + BUG_ON(atomic_read(&dli->dl_usecnt));
19791 + BUG_ON(atomic_read(&dli->dl_refcnt));
19797 +/* hash table for dl_info hash */
19799 +#define DL_HASH_SIZE 13
19801 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19803 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19806 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19808 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19813 +/* __hash_dl_info()
19815 + * add the dli to the global hash table
19816 + * requires the hash_lock to be held */
19818 +static inline void __hash_dl_info(struct dl_info *dli)
19820 + struct hlist_head *head;
19822 + vxdprintk(VXD_CBIT(dlim, 6),
19823 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19824 + get_dl_info(dli);
19825 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19826 + hlist_add_head_rcu(&dli->dl_hlist, head);
19829 +/* __unhash_dl_info()
19831 + * remove the dli from the global hash table
19832 + * requires the hash_lock to be held */
19834 +static inline void __unhash_dl_info(struct dl_info *dli)
19836 + vxdprintk(VXD_CBIT(dlim, 6),
19837 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19838 + hlist_del_rcu(&dli->dl_hlist);
19839 + put_dl_info(dli);
19843 +/* __lookup_dl_info()
19845 + * requires the rcu_read_lock()
19846 + * doesn't increment the dl_refcnt */
19848 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19850 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19851 + struct hlist_node *pos;
19852 + struct dl_info *dli;
19854 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19856 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19864 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19866 + struct dl_info *dli;
19869 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19870 + vxdprintk(VXD_CBIT(dlim, 7),
19871 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19872 + rcu_read_unlock();
19876 +void rcu_free_dl_info(struct rcu_head *head)
19878 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19879 + int usecnt, refcnt;
19881 + BUG_ON(!dli || !head);
19883 + usecnt = atomic_read(&dli->dl_usecnt);
19884 + BUG_ON(usecnt < 0);
19886 + refcnt = atomic_read(&dli->dl_refcnt);
19887 + BUG_ON(refcnt < 0);
19889 + vxdprintk(VXD_CBIT(dlim, 3),
19890 + "rcu_free_dl_info(%p)", dli);
19892 + __dealloc_dl_info(dli);
19894 + printk("!!! rcu didn't free\n");
19900 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19901 + uint32_t flags, int add)
19903 + struct path path;
19906 + ret = user_lpath(name, &path);
19908 + struct super_block *sb;
19909 + struct dl_info *dli;
19912 + if (!path.dentry->d_inode)
19913 + goto out_release;
19914 + if (!(sb = path.dentry->d_inode->i_sb))
19915 + goto out_release;
19918 + dli = __alloc_dl_info(sb, id);
19919 + spin_lock(&dl_info_hash_lock);
19922 + if (__lookup_dl_info(sb, id))
19924 + __hash_dl_info(dli);
19927 + spin_lock(&dl_info_hash_lock);
19928 + dli = __lookup_dl_info(sb, id);
19933 + __unhash_dl_info(dli);
19937 + spin_unlock(&dl_info_hash_lock);
19939 + __dealloc_dl_info(dli);
19946 +int vc_add_dlimit(uint32_t id, void __user *data)
19948 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19950 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19953 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19956 +int vc_rem_dlimit(uint32_t id, void __user *data)
19958 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19960 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19963 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19966 +#ifdef CONFIG_COMPAT
19968 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19970 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19972 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19975 + return do_addrem_dlimit(id,
19976 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19979 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19981 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19983 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19986 + return do_addrem_dlimit(id,
19987 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19990 +#endif /* CONFIG_COMPAT */
19994 +int do_set_dlimit(uint32_t id, const char __user *name,
19995 + uint32_t space_used, uint32_t space_total,
19996 + uint32_t inodes_used, uint32_t inodes_total,
19997 + uint32_t reserved, uint32_t flags)
19999 + struct path path;
20002 + ret = user_lpath(name, &path);
20004 + struct super_block *sb;
20005 + struct dl_info *dli;
20008 + if (!path.dentry->d_inode)
20009 + goto out_release;
20010 + if (!(sb = path.dentry->d_inode->i_sb))
20011 + goto out_release;
20013 + /* sanity checks */
20014 + if ((reserved != CDLIM_KEEP &&
20015 + reserved > 100) ||
20016 + (inodes_used != CDLIM_KEEP &&
20017 + inodes_used > inodes_total) ||
20018 + (space_used != CDLIM_KEEP &&
20019 + space_used > space_total))
20020 + goto out_release;
20023 + dli = locate_dl_info(sb, id);
20025 + goto out_release;
20027 + spin_lock(&dli->dl_lock);
20029 + if (inodes_used != CDLIM_KEEP)
20030 + dli->dl_inodes_used = inodes_used;
20031 + if (inodes_total != CDLIM_KEEP)
20032 + dli->dl_inodes_total = inodes_total;
20033 + if (space_used != CDLIM_KEEP)
20034 + dli->dl_space_used = dlimit_space_32to64(
20035 + space_used, flags, DLIMS_USED);
20037 + if (space_total == CDLIM_INFINITY)
20038 + dli->dl_space_total = DLIM_INFINITY;
20039 + else if (space_total != CDLIM_KEEP)
20040 + dli->dl_space_total = dlimit_space_32to64(
20041 + space_total, flags, DLIMS_TOTAL);
20043 + if (reserved != CDLIM_KEEP)
20044 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20046 + spin_unlock(&dli->dl_lock);
20048 + put_dl_info(dli);
20057 +int vc_set_dlimit(uint32_t id, void __user *data)
20059 + struct vcmd_ctx_dlimit_v0 vc_data;
20061 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20064 + return do_set_dlimit(id, vc_data.name,
20065 + vc_data.space_used, vc_data.space_total,
20066 + vc_data.inodes_used, vc_data.inodes_total,
20067 + vc_data.reserved, vc_data.flags);
20070 +#ifdef CONFIG_COMPAT
20072 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20074 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20076 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20079 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20080 + vc_data.space_used, vc_data.space_total,
20081 + vc_data.inodes_used, vc_data.inodes_total,
20082 + vc_data.reserved, vc_data.flags);
20085 +#endif /* CONFIG_COMPAT */
20089 +int do_get_dlimit(uint32_t id, const char __user *name,
20090 + uint32_t *space_used, uint32_t *space_total,
20091 + uint32_t *inodes_used, uint32_t *inodes_total,
20092 + uint32_t *reserved, uint32_t *flags)
20094 + struct path path;
20097 + ret = user_lpath(name, &path);
20099 + struct super_block *sb;
20100 + struct dl_info *dli;
20103 + if (!path.dentry->d_inode)
20104 + goto out_release;
20105 + if (!(sb = path.dentry->d_inode->i_sb))
20106 + goto out_release;
20109 + dli = locate_dl_info(sb, id);
20111 + goto out_release;
20113 + spin_lock(&dli->dl_lock);
20114 + *inodes_used = dli->dl_inodes_used;
20115 + *inodes_total = dli->dl_inodes_total;
20117 + *space_used = dlimit_space_64to32(
20118 + dli->dl_space_used, flags, DLIMS_USED);
20120 + if (dli->dl_space_total == DLIM_INFINITY)
20121 + *space_total = CDLIM_INFINITY;
20123 + *space_total = dlimit_space_64to32(
20124 + dli->dl_space_total, flags, DLIMS_TOTAL);
20126 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20127 + spin_unlock(&dli->dl_lock);
20129 + put_dl_info(dli);
20140 +int vc_get_dlimit(uint32_t id, void __user *data)
20142 + struct vcmd_ctx_dlimit_v0 vc_data;
20145 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20148 + ret = do_get_dlimit(id, vc_data.name,
20149 + &vc_data.space_used, &vc_data.space_total,
20150 + &vc_data.inodes_used, &vc_data.inodes_total,
20151 + &vc_data.reserved, &vc_data.flags);
20155 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20160 +#ifdef CONFIG_COMPAT
20162 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20164 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20167 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20170 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20171 + &vc_data.space_used, &vc_data.space_total,
20172 + &vc_data.inodes_used, &vc_data.inodes_total,
20173 + &vc_data.reserved, &vc_data.flags);
20177 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20182 +#endif /* CONFIG_COMPAT */
20185 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20187 + struct dl_info *dli;
20188 + __u64 blimit, bfree, bavail;
20191 + dli = locate_dl_info(sb, dx_current_tag());
20195 + spin_lock(&dli->dl_lock);
20196 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20199 + /* reduce max inodes available to limit */
20200 + if (buf->f_files > dli->dl_inodes_total)
20201 + buf->f_files = dli->dl_inodes_total;
20203 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20204 + /* reduce free inodes to min */
20205 + if (ifree < buf->f_ffree)
20206 + buf->f_ffree = ifree;
20209 + if (dli->dl_space_total == DLIM_INFINITY)
20212 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20214 + if (dli->dl_space_total < dli->dl_space_used)
20217 + bfree = (dli->dl_space_total - dli->dl_space_used)
20218 + >> sb->s_blocksize_bits;
20220 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20221 + if (bavail < dli->dl_space_used)
20224 + bavail = (bavail - dli->dl_space_used)
20225 + >> sb->s_blocksize_bits;
20227 + /* reduce max space available to limit */
20228 + if (buf->f_blocks > blimit)
20229 + buf->f_blocks = blimit;
20231 + /* reduce free space to min */
20232 + if (bfree < buf->f_bfree)
20233 + buf->f_bfree = bfree;
20235 + /* reduce avail space to min */
20236 + if (bavail < buf->f_bavail)
20237 + buf->f_bavail = bavail;
20240 + spin_unlock(&dli->dl_lock);
20241 + put_dl_info(dli);
20246 +#include <linux/module.h>
20248 +EXPORT_SYMBOL_GPL(locate_dl_info);
20249 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20251 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/helper.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/helper.c
20252 --- linux-2.6.32.10/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20253 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/helper.c 2009-12-03 22:20:22.000000000 +0100
20256 + * linux/kernel/vserver/helper.c
20258 + * Virtual Context Support
20260 + * Copyright (C) 2004-2007 Herbert Pötzl
20262 + * V0.01 basic helper
20266 +#include <linux/kmod.h>
20267 +#include <linux/reboot.h>
20268 +#include <linux/vs_context.h>
20269 +#include <linux/vs_network.h>
20270 +#include <linux/vserver/signal.h>
20273 +char vshelper_path[255] = "/sbin/vshelper";
20276 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20280 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20281 + printk( KERN_WARNING
20282 + "%s: (%s %s) returned %s with %d\n",
20283 + name, argv[1], argv[2],
20284 + sync ? "sync" : "async", ret);
20286 + vxdprintk(VXD_CBIT(switch, 4),
20287 + "%s: (%s %s) returned %s with %d",
20288 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20293 + * vshelper path is set via /proc/sys
20294 + * invoked by vserver sys_reboot(), with
20295 + * the following arguments
20297 + * argv [0] = vshelper_path;
20298 + * argv [1] = action: "restart", "halt", "poweroff", ...
20299 + * argv [2] = context identifier
20301 + * envp [*] = type-specific parameters
20304 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20306 + char id_buf[8], cmd_buf[16];
20307 + char uid_buf[16], pid_buf[16];
20310 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20311 + char *envp[] = {"HOME=/", "TERM=linux",
20312 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20313 + uid_buf, pid_buf, cmd_buf, 0};
20315 + if (vx_info_state(vxi, VXS_HELPER))
20317 + vxi->vx_state |= VXS_HELPER;
20319 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20321 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20322 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20323 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20326 + case LINUX_REBOOT_CMD_RESTART:
20327 + argv[1] = "restart";
20330 + case LINUX_REBOOT_CMD_HALT:
20331 + argv[1] = "halt";
20334 + case LINUX_REBOOT_CMD_POWER_OFF:
20335 + argv[1] = "poweroff";
20338 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20339 + argv[1] = "swsusp";
20342 + case LINUX_REBOOT_CMD_OOM:
20347 + vxi->vx_state &= ~VXS_HELPER;
20351 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20352 + vxi->vx_state &= ~VXS_HELPER;
20353 + __wakeup_vx_info(vxi);
20354 + return (ret) ? -EPERM : 0;
20358 +long vs_reboot(unsigned int cmd, void __user *arg)
20360 + struct vx_info *vxi = current_vx_info();
20363 + vxdprintk(VXD_CBIT(misc, 5),
20364 + "vs_reboot(%p[#%d],%u)",
20365 + vxi, vxi ? vxi->vx_id : 0, cmd);
20367 + ret = vs_reboot_helper(vxi, cmd, arg);
20371 + vxi->reboot_cmd = cmd;
20372 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20374 + case LINUX_REBOOT_CMD_RESTART:
20375 + case LINUX_REBOOT_CMD_HALT:
20376 + case LINUX_REBOOT_CMD_POWER_OFF:
20377 + vx_info_kill(vxi, 0, SIGKILL);
20378 + vx_info_kill(vxi, 1, SIGKILL);
20386 +long vs_oom_action(unsigned int cmd)
20388 + struct vx_info *vxi = current_vx_info();
20391 + vxdprintk(VXD_CBIT(misc, 5),
20392 + "vs_oom_action(%p[#%d],%u)",
20393 + vxi, vxi ? vxi->vx_id : 0, cmd);
20395 + ret = vs_reboot_helper(vxi, cmd, NULL);
20399 + vxi->reboot_cmd = cmd;
20400 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20401 + vx_info_kill(vxi, 0, SIGKILL);
20402 + vx_info_kill(vxi, 1, SIGKILL);
20408 + * argv [0] = vshelper_path;
20409 + * argv [1] = action: "startup", "shutdown"
20410 + * argv [2] = context identifier
20412 + * envp [*] = type-specific parameters
20415 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20417 + char id_buf[8], cmd_buf[16];
20418 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20419 + char *envp[] = {"HOME=/", "TERM=linux",
20420 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20422 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20425 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20426 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20429 + case VSC_STARTUP:
20430 + argv[1] = "startup";
20432 + case VSC_SHUTDOWN:
20433 + argv[1] = "shutdown";
20439 + return do_vshelper(vshelper_path, argv, envp, 1);
20444 + * argv [0] = vshelper_path;
20445 + * argv [1] = action: "netup", "netdown"
20446 + * argv [2] = context identifier
20448 + * envp [*] = type-specific parameters
20451 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20453 + char id_buf[8], cmd_buf[16];
20454 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20455 + char *envp[] = {"HOME=/", "TERM=linux",
20456 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20458 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20461 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20462 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20466 + argv[1] = "netup";
20468 + case VSC_NETDOWN:
20469 + argv[1] = "netdown";
20475 + return do_vshelper(vshelper_path, argv, envp, 1);
20478 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/history.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/history.c
20479 --- linux-2.6.32.10/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20480 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/history.c 2009-12-03 20:04:56.000000000 +0100
20483 + * kernel/vserver/history.c
20485 + * Virtual Context History Backtrace
20487 + * Copyright (C) 2004-2007 Herbert Pötzl
20489 + * V0.01 basic structure
20490 + * V0.02 hash/unhash and trace
20491 + * V0.03 preemption fixes
20495 +#include <linux/module.h>
20496 +#include <asm/uaccess.h>
20498 +#include <linux/vserver/context.h>
20499 +#include <linux/vserver/debug.h>
20500 +#include <linux/vserver/debug_cmd.h>
20501 +#include <linux/vserver/history.h>
20504 +#ifdef CONFIG_VSERVER_HISTORY
20505 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20507 +#define VXH_SIZE 64
20510 +struct _vx_history {
20511 + unsigned int counter;
20513 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20517 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20519 +unsigned volatile int vxh_active = 1;
20521 +static atomic_t sequence = ATOMIC_INIT(0);
20526 + * requires disabled preemption */
20528 +struct _vx_hist_entry *vxh_advance(void *loc)
20530 + unsigned int cpu = smp_processor_id();
20531 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20532 + struct _vx_hist_entry *entry;
20533 + unsigned int index;
20535 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20536 + entry = &hist->entry[index];
20538 + entry->seq = atomic_inc_return(&sequence);
20539 + entry->loc = loc;
20543 +EXPORT_SYMBOL_GPL(vxh_advance);
20546 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20548 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20551 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20553 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20554 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20555 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20556 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20558 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20560 + switch (e->type) {
20561 + case VXH_THROW_OOPS:
20562 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20565 + case VXH_GET_VX_INFO:
20566 + case VXH_PUT_VX_INFO:
20567 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20569 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20570 + VXH_VXI_ARGS(e));
20573 + case VXH_INIT_VX_INFO:
20574 + case VXH_SET_VX_INFO:
20575 + case VXH_CLR_VX_INFO:
20576 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20578 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20579 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20580 + VXH_VXI_ARGS(e), e->sc.data);
20583 + case VXH_CLAIM_VX_INFO:
20584 + case VXH_RELEASE_VX_INFO:
20585 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20587 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20588 + VXH_VXI_ARGS(e), e->sc.data);
20591 + case VXH_ALLOC_VX_INFO:
20592 + case VXH_DEALLOC_VX_INFO:
20593 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20595 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20596 + VXH_VXI_ARGS(e));
20599 + case VXH_HASH_VX_INFO:
20600 + case VXH_UNHASH_VX_INFO:
20601 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20603 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20604 + VXH_VXI_ARGS(e));
20607 + case VXH_LOC_VX_INFO:
20608 + case VXH_LOOKUP_VX_INFO:
20609 + case VXH_CREATE_VX_INFO:
20610 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20612 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20613 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20614 + e->ll.arg, VXH_VXI_ARGS(e));
20619 +static void __vxh_dump_history(void)
20621 + unsigned int i, cpu;
20623 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20624 + atomic_read(&sequence), NR_CPUS);
20626 + for (i = 0; i < VXH_SIZE; i++) {
20627 + for_each_online_cpu(cpu) {
20628 + struct _vx_history *hist =
20629 + &per_cpu(vx_history_buffer, cpu);
20630 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20631 + struct _vx_hist_entry *entry = &hist->entry[index];
20633 + vxh_dump_entry(entry, cpu);
20638 +void vxh_dump_history(void)
20642 + local_irq_enable();
20644 + local_irq_disable();
20646 + __vxh_dump_history();
20650 +/* vserver syscall commands below here */
20653 +int vc_dump_history(uint32_t id)
20656 + __vxh_dump_history();
20663 +int do_read_history(struct __user _vx_hist_entry *data,
20664 + int cpu, uint32_t *index, uint32_t *count)
20666 + int pos, ret = 0;
20667 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20668 + int end = hist->counter;
20669 + int start = end - VXH_SIZE + 2;
20670 + int idx = *index;
20672 + /* special case: get current pos */
20678 + /* have we lost some data? */
20682 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20683 + struct _vx_hist_entry *entry =
20684 + &hist->entry[idx % VXH_SIZE];
20686 + /* send entry to userspace */
20687 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20691 + /* save new index and count */
20694 + return ret ? ret : (*index < end);
20697 +int vc_read_history(uint32_t id, void __user *data)
20699 + struct vcmd_read_history_v0 vc_data;
20702 + if (id >= NR_CPUS)
20705 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20708 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20709 + id, &vc_data.index, &vc_data.count);
20711 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20716 +#ifdef CONFIG_COMPAT
20718 +int vc_read_history_x32(uint32_t id, void __user *data)
20720 + struct vcmd_read_history_v0_x32 vc_data;
20723 + if (id >= NR_CPUS)
20726 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20729 + ret = do_read_history((struct __user _vx_hist_entry *)
20730 + compat_ptr(vc_data.data_ptr),
20731 + id, &vc_data.index, &vc_data.count);
20733 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20738 +#endif /* CONFIG_COMPAT */
20740 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/inet.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/inet.c
20741 --- linux-2.6.32.10/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20742 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/inet.c 2009-12-03 20:04:56.000000000 +0100
20745 +#include <linux/in.h>
20746 +#include <linux/inetdevice.h>
20747 +#include <linux/vs_inet.h>
20748 +#include <linux/vs_inet6.h>
20749 +#include <linux/vserver/debug.h>
20750 +#include <net/route.h>
20751 +#include <net/addrconf.h>
20754 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20758 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20761 + struct nx_addr_v4 *ptr;
20763 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20764 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20771 + vxdprintk(VXD_CBIT(net, 2),
20772 + "nx_v4_addr_conflict(%p,%p): %d",
20773 + nxi1, nxi2, ret);
20779 +#ifdef CONFIG_IPV6
20781 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20785 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20788 + struct nx_addr_v6 *ptr;
20790 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20791 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20798 + vxdprintk(VXD_CBIT(net, 2),
20799 + "nx_v6_addr_conflict(%p,%p): %d",
20800 + nxi1, nxi2, ret);
20807 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20809 + struct in_device *in_dev;
20810 + struct in_ifaddr **ifap;
20811 + struct in_ifaddr *ifa;
20816 + in_dev = in_dev_get(dev);
20820 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20821 + ifap = &ifa->ifa_next) {
20822 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20827 + in_dev_put(in_dev);
20833 +#ifdef CONFIG_IPV6
20835 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20837 + struct inet6_dev *in_dev;
20838 + struct inet6_ifaddr **ifap;
20839 + struct inet6_ifaddr *ifa;
20844 + in_dev = in6_dev_get(dev);
20848 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20849 + ifap = &ifa->if_next) {
20850 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20855 + in6_dev_put(in_dev);
20862 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20868 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20870 +#ifdef CONFIG_IPV6
20872 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20877 + vxdprintk(VXD_CBIT(net, 3),
20878 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20879 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20883 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20884 + struct rtable **rp, struct flowi *fl)
20889 + /* FIXME: handle lback only case */
20890 + if (!NX_IPV4(nxi))
20893 + vxdprintk(VXD_CBIT(net, 4),
20894 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20895 + nxi, nxi ? nxi->nx_id : 0,
20896 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20898 + /* single IP is unconditional */
20899 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20900 + (fl->fl4_src == INADDR_ANY))
20901 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20903 + if (fl->fl4_src == INADDR_ANY) {
20904 + struct nx_addr_v4 *ptr;
20905 + __be32 found = 0;
20908 + err = __ip_route_output_key(net, rp, fl);
20910 + found = (*rp)->rt_src;
20912 + vxdprintk(VXD_CBIT(net, 4),
20913 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20914 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20915 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20919 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20920 + __be32 primary = ptr->ip[0].s_addr;
20921 + __be32 mask = ptr->mask.s_addr;
20922 + __be32 neta = primary & mask;
20924 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20925 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20926 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20927 + NIPQUAD(mask), NIPQUAD(neta));
20928 + if ((found & mask) != neta)
20931 + fl->fl4_src = primary;
20932 + err = __ip_route_output_key(net, rp, fl);
20933 + vxdprintk(VXD_CBIT(net, 4),
20934 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20935 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20937 + found = (*rp)->rt_src;
20939 + if (found == primary)
20943 + /* still no source ip? */
20944 + found = ipv4_is_loopback(fl->fl4_dst)
20945 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20947 + /* assign src ip to flow */
20948 + fl->fl4_src = found;
20951 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20955 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20956 + if (ipv4_is_loopback(fl->fl4_dst))
20957 + fl->fl4_dst = nxi->v4_lback.s_addr;
20958 + if (ipv4_is_loopback(fl->fl4_src))
20959 + fl->fl4_src = nxi->v4_lback.s_addr;
20960 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20961 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20967 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20969 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/init.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/init.c
20970 --- linux-2.6.32.10/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20971 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/init.c 2009-12-03 20:04:56.000000000 +0100
20974 + * linux/kernel/init.c
20976 + * Virtual Server Init
20978 + * Copyright (C) 2004-2007 Herbert Pötzl
20980 + * V0.01 basic structure
20984 +#include <linux/init.h>
20986 +int vserver_register_sysctl(void);
20987 +void vserver_unregister_sysctl(void);
20990 +static int __init init_vserver(void)
20994 +#ifdef CONFIG_VSERVER_DEBUG
20995 + vserver_register_sysctl();
21001 +static void __exit exit_vserver(void)
21004 +#ifdef CONFIG_VSERVER_DEBUG
21005 + vserver_unregister_sysctl();
21010 +/* FIXME: GFP_ZONETYPES gone
21011 +long vx_slab[GFP_ZONETYPES]; */
21015 +module_init(init_vserver);
21016 +module_exit(exit_vserver);
21018 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/inode.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/inode.c
21019 --- linux-2.6.32.10/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21020 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/inode.c 2009-12-03 20:04:56.000000000 +0100
21023 + * linux/kernel/vserver/inode.c
21025 + * Virtual Server: File System Support
21027 + * Copyright (C) 2004-2007 Herbert Pötzl
21029 + * V0.01 separated from vcontext V0.05
21030 + * V0.02 moved to tag (instead of xid)
21034 +#include <linux/tty.h>
21035 +#include <linux/proc_fs.h>
21036 +#include <linux/devpts_fs.h>
21037 +#include <linux/fs.h>
21038 +#include <linux/file.h>
21039 +#include <linux/mount.h>
21040 +#include <linux/parser.h>
21041 +#include <linux/namei.h>
21042 +#include <linux/vserver/inode.h>
21043 +#include <linux/vserver/inode_cmd.h>
21044 +#include <linux/vs_base.h>
21045 +#include <linux/vs_tag.h>
21047 +#include <asm/uaccess.h>
21050 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21052 + struct proc_dir_entry *entry;
21054 + if (!in || !in->i_sb)
21057 + *flags = IATTR_TAG
21058 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21059 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21060 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21061 + | (IS_COW(in) ? IATTR_COW : 0);
21062 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21064 + if (S_ISDIR(in->i_mode))
21065 + *mask |= IATTR_BARRIER;
21067 + if (IS_TAGGED(in)) {
21068 + *tag = in->i_tag;
21069 + *mask |= IATTR_TAG;
21072 + switch (in->i_sb->s_magic) {
21073 + case PROC_SUPER_MAGIC:
21074 + entry = PROC_I(in)->pde;
21076 + /* check for specific inodes? */
21078 + *mask |= IATTR_FLAGS;
21080 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21082 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21085 + case DEVPTS_SUPER_MAGIC:
21086 + *tag = in->i_tag;
21087 + *mask |= IATTR_TAG;
21096 +int vc_get_iattr(void __user *data)
21098 + struct path path;
21099 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21102 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21105 + ret = user_lpath(vc_data.name, &path);
21107 + ret = __vc_get_iattr(path.dentry->d_inode,
21108 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21114 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21119 +#ifdef CONFIG_COMPAT
21121 +int vc_get_iattr_x32(void __user *data)
21123 + struct path path;
21124 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21127 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21130 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21132 + ret = __vc_get_iattr(path.dentry->d_inode,
21133 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21139 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21144 +#endif /* CONFIG_COMPAT */
21147 +int vc_fget_iattr(uint32_t fd, void __user *data)
21149 + struct file *filp;
21150 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21153 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21157 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21160 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21161 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21165 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21171 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21173 + struct inode *in = de->d_inode;
21174 + int error = 0, is_proc = 0, has_tag = 0;
21175 + struct iattr attr = { 0 };
21177 + if (!in || !in->i_sb)
21180 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21181 + if ((*mask & IATTR_FLAGS) && !is_proc)
21184 + has_tag = IS_TAGGED(in) ||
21185 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21186 + if ((*mask & IATTR_TAG) && !has_tag)
21189 + mutex_lock(&in->i_mutex);
21190 + if (*mask & IATTR_TAG) {
21191 + attr.ia_tag = *tag;
21192 + attr.ia_valid |= ATTR_TAG;
21195 + if (*mask & IATTR_FLAGS) {
21196 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21197 + unsigned int iflags = PROC_I(in)->vx_flags;
21199 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21200 + | (*flags & IATTR_FLAGS);
21201 + PROC_I(in)->vx_flags = iflags;
21203 + entry->vx_flags = iflags;
21206 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21207 + IATTR_BARRIER | IATTR_COW)) {
21208 + int iflags = in->i_flags;
21209 + int vflags = in->i_vflags;
21211 + if (*mask & IATTR_IMMUTABLE) {
21212 + if (*flags & IATTR_IMMUTABLE)
21213 + iflags |= S_IMMUTABLE;
21215 + iflags &= ~S_IMMUTABLE;
21217 + if (*mask & IATTR_IXUNLINK) {
21218 + if (*flags & IATTR_IXUNLINK)
21219 + iflags |= S_IXUNLINK;
21221 + iflags &= ~S_IXUNLINK;
21223 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21224 + if (*flags & IATTR_BARRIER)
21225 + vflags |= V_BARRIER;
21227 + vflags &= ~V_BARRIER;
21229 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21230 + if (*flags & IATTR_COW)
21233 + vflags &= ~V_COW;
21235 + if (in->i_op && in->i_op->sync_flags) {
21236 + error = in->i_op->sync_flags(in, iflags, vflags);
21242 + if (attr.ia_valid) {
21243 + if (in->i_op && in->i_op->setattr)
21244 + error = in->i_op->setattr(de, &attr);
21246 + error = inode_change_ok(in, &attr);
21248 + error = inode_setattr(in, &attr);
21253 + mutex_unlock(&in->i_mutex);
21257 +int vc_set_iattr(void __user *data)
21259 + struct path path;
21260 + struct vcmd_ctx_iattr_v1 vc_data;
21263 + if (!capable(CAP_LINUX_IMMUTABLE))
21265 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21268 + ret = user_lpath(vc_data.name, &path);
21270 + ret = __vc_set_iattr(path.dentry,
21271 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21275 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21280 +#ifdef CONFIG_COMPAT
21282 +int vc_set_iattr_x32(void __user *data)
21284 + struct path path;
21285 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21288 + if (!capable(CAP_LINUX_IMMUTABLE))
21290 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21293 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21295 + ret = __vc_set_iattr(path.dentry,
21296 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21300 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21305 +#endif /* CONFIG_COMPAT */
21307 +int vc_fset_iattr(uint32_t fd, void __user *data)
21309 + struct file *filp;
21310 + struct vcmd_ctx_fiattr_v0 vc_data;
21313 + if (!capable(CAP_LINUX_IMMUTABLE))
21315 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21319 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21322 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21323 + &vc_data.flags, &vc_data.mask);
21327 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21333 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21335 +static match_table_t tokens = {
21336 + {Opt_notagcheck, "notagcheck"},
21337 +#ifdef CONFIG_PROPAGATE
21338 + {Opt_notag, "notag"},
21339 + {Opt_tag, "tag"},
21340 + {Opt_tagid, "tagid=%u"},
21346 +static void __dx_parse_remove(char *string, char *opt)
21348 + char *p = strstr(string, opt);
21352 + while (*q != '\0' && *q != ',')
21361 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21362 + unsigned long *flags)
21365 + substring_t args[MAX_OPT_ARGS];
21366 + int token, option = 0;
21367 + char *s, *p, *opts;
21371 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21376 + while ((p = strsep(&opts, ",")) != NULL) {
21377 + token = match_token(p, tokens, args);
21379 + vxdprintk(VXD_CBIT(tag, 7),
21380 + "dx_parse_tag(»%s«): %d:#%d",
21381 + p, token, option);
21384 +#ifdef CONFIG_PROPAGATE
21389 + __dx_parse_remove(s, "tag");
21390 + *mnt_flags |= MNT_TAGID;
21391 + set |= MNT_TAGID;
21395 + __dx_parse_remove(s, "notag");
21396 + *mnt_flags |= MNT_NOTAG;
21397 + set |= MNT_NOTAG;
21400 + if (tag && !match_int(args, &option))
21403 + __dx_parse_remove(s, "tagid");
21404 + *mnt_flags |= MNT_TAGID;
21405 + set |= MNT_TAGID;
21408 + case Opt_notagcheck:
21410 + __dx_parse_remove(s, "notagcheck");
21411 + *flags |= MS_NOTAGCHECK;
21412 + set |= MS_NOTAGCHECK;
21417 + strcpy(string, s);
21422 +#ifdef CONFIG_PROPAGATE
21424 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21426 + tag_t new_tag = 0;
21427 + struct vfsmount *mnt;
21432 + mnt = nd->path.mnt;
21436 + propagate = (mnt->mnt_flags & MNT_TAGID);
21438 + new_tag = mnt->mnt_tag;
21440 + vxdprintk(VXD_CBIT(tag, 7),
21441 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21442 + inode, inode->i_ino, inode->i_tag,
21443 + new_tag, (propagate) ? 1 : 0);
21446 + inode->i_tag = new_tag;
21449 +#include <linux/module.h>
21451 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21453 +#endif /* CONFIG_PROPAGATE */
21455 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/Kconfig
21456 --- linux-2.6.32.10/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21457 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/Kconfig 2010-02-14 01:02:13.000000000 +0100
21460 +# Linux VServer configuration
21463 +menu "Linux VServer"
21465 +config VSERVER_AUTO_LBACK
21466 + bool "Automatically Assign Loopback IP"
21469 + Automatically assign a guest specific loopback
21470 + IP and add it to the kernel network stack on
21473 +config VSERVER_AUTO_SINGLE
21474 + bool "Automatic Single IP Special Casing"
21475 + depends on EXPERIMENTAL
21478 + This allows network contexts with a single IP to
21479 + automatically remap 0.0.0.0 bindings to that IP,
21480 + avoiding further network checks and improving
21483 + (note: such guests do not allow to change the ip
21484 + on the fly and do not show loopback addresses)
21486 +config VSERVER_COWBL
21487 + bool "Enable COW Immutable Link Breaking"
21490 + This enables the COW (Copy-On-Write) link break code.
21491 + It allows you to treat unified files like normal files
21492 + when writing to them (which will implicitely break the
21493 + link and create a copy of the unified file)
21495 +config VSERVER_VTIME
21496 + bool "Enable Virtualized Guest Time"
21497 + depends on EXPERIMENTAL
21500 + This enables per guest time offsets to allow for
21501 + adjusting the system clock individually per guest.
21502 + this adds some overhead to the time functions and
21503 + therefore should not be enabled without good reason.
21505 +config VSERVER_DEVICE
21506 + bool "Enable Guest Device Mapping"
21507 + depends on EXPERIMENTAL
21510 + This enables generic device remapping.
21512 +config VSERVER_PROC_SECURE
21513 + bool "Enable Proc Security"
21514 + depends on PROC_FS
21517 + This configures ProcFS security to initially hide
21518 + non-process entries for all contexts except the main and
21519 + spectator context (i.e. for all guests), which is a secure
21522 + (note: on 1.2x the entries were visible by default)
21524 +config VSERVER_HARDCPU
21525 + bool "Enable Hard CPU Limits"
21528 + Activate the Hard CPU Limits
21530 + This will compile in code that allows the Token Bucket
21531 + Scheduler to put processes on hold when a context's
21532 + tokens are depleted (provided that its per-context
21533 + sched_hard flag is set).
21535 + Processes belonging to that context will not be able
21536 + to consume CPU resources again until a per-context
21537 + configured minimum of tokens has been reached.
21539 +config VSERVER_IDLETIME
21540 + bool "Avoid idle CPUs by skipping Time"
21541 + depends on VSERVER_HARDCPU
21544 + This option allows the scheduler to artificially
21545 + advance time (per cpu) when otherwise the idle
21546 + task would be scheduled, thus keeping the cpu
21547 + busy and sharing the available resources among
21548 + certain contexts.
21550 +config VSERVER_IDLELIMIT
21551 + bool "Limit the IDLE task"
21552 + depends on VSERVER_HARDCPU
21555 + Limit the idle slices, so the the next context
21556 + will be scheduled as soon as possible.
21558 + This might improve interactivity and latency, but
21559 + will also marginally increase scheduling overhead.
21562 + prompt "Persistent Inode Tagging"
21563 + default TAGGING_ID24
21565 + This adds persistent context information to filesystems
21566 + mounted with the tagxid option. Tagging is a requirement
21567 + for per-context disk limits and per-context quota.
21570 +config TAGGING_NONE
21573 + do not store per-context information in inodes.
21575 +config TAGGING_UID16
21576 + bool "UID16/GID32"
21578 + reduces UID to 16 bit, but leaves GID at 32 bit.
21580 +config TAGGING_GID16
21581 + bool "UID32/GID16"
21583 + reduces GID to 16 bit, but leaves UID at 32 bit.
21585 +config TAGGING_ID24
21586 + bool "UID24/GID24"
21588 + uses the upper 8bit from UID and GID for XID tagging
21589 + which leaves 24bit for UID/GID each, which should be
21590 + more than sufficient for normal use.
21592 +config TAGGING_INTERN
21593 + bool "UID32/GID32"
21595 + this uses otherwise reserved inode fields in the on
21596 + disk representation, which limits the use to a few
21597 + filesystems (currently ext2 and ext3)
21602 + bool "Tag NFSD User Auth and Files"
21605 + Enable this if you do want the in-kernel NFS
21606 + Server to use the tagging specified above.
21607 + (will require patched clients too)
21609 +config VSERVER_PRIVACY
21610 + bool "Honor Privacy Aspects of Guests"
21613 + When enabled, most context checks will disallow
21614 + access to structures assigned to a specific context,
21615 + like ptys or loop devices.
21617 +config VSERVER_CONTEXTS
21618 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
21620 + default "768" if 64BIT
21623 + This setting will optimize certain data structures
21624 + and memory allocations according to the expected
21627 + note: this is not a strict upper limit.
21629 +config VSERVER_WARN
21630 + bool "VServer Warnings"
21633 + This enables various runtime warnings, which will
21634 + notify about potential manipulation attempts or
21635 + resource shortage. It is generally considered to
21636 + be a good idea to have that enabled.
21638 +config VSERVER_DEBUG
21639 + bool "VServer Debugging Code"
21642 + Set this to yes if you want to be able to activate
21643 + debugging output at runtime. It adds a very small
21644 + overhead to all vserver related functions and
21645 + increases the kernel size by about 20k.
21647 +config VSERVER_HISTORY
21648 + bool "VServer History Tracing"
21649 + depends on VSERVER_DEBUG
21652 + Set this to yes if you want to record the history of
21653 + linux-vserver activities, so they can be replayed in
21654 + the event of a kernel panic or oops.
21656 +config VSERVER_HISTORY_SIZE
21657 + int "Per-CPU History Size (32-65536)"
21658 + depends on VSERVER_HISTORY
21662 + This allows you to specify the number of entries in
21663 + the per-CPU history buffer.
21665 +config VSERVER_MONITOR
21666 + bool "VServer Scheduling Monitor"
21667 + depends on VSERVER_DISABLED
21670 + Set this to yes if you want to record the scheduling
21671 + decisions, so that they can be relayed to userspace
21672 + for detailed analysis.
21674 +config VSERVER_MONITOR_SIZE
21675 + int "Per-CPU Monitor Queue Size (32-65536)"
21676 + depends on VSERVER_MONITOR
21680 + This allows you to specify the number of entries in
21681 + the per-CPU scheduling monitor buffer.
21683 +config VSERVER_MONITOR_SYNC
21684 + int "Per-CPU Monitor Sync Interval (0-65536)"
21685 + depends on VSERVER_MONITOR
21689 + This allows you to specify the interval in ticks
21690 + when a time sync entry is inserted.
21698 + select NAMESPACES
21704 +config VSERVER_SECURITY
21706 + depends on SECURITY
21708 + select SECURITY_CAPABILITIES
21710 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/limit.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/limit.c
21711 --- linux-2.6.32.10/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21712 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/limit.c 2010-03-02 21:11:00.000000000 +0100
21715 + * linux/kernel/vserver/limit.c
21717 + * Virtual Server: Context Limits
21719 + * Copyright (C) 2004-2010 Herbert Pötzl
21721 + * V0.01 broken out from vcontext V0.05
21722 + * V0.02 changed vcmds to vxi arg
21723 + * V0.03 added memory cgroup support
21727 +#include <linux/sched.h>
21728 +#include <linux/module.h>
21729 +#include <linux/memcontrol.h>
21730 +#include <linux/res_counter.h>
21731 +#include <linux/vs_limit.h>
21732 +#include <linux/vserver/limit.h>
21733 +#include <linux/vserver/limit_cmd.h>
21735 +#include <asm/uaccess.h>
21738 +const char *vlimit_name[NUM_LIMITS] = {
21739 + [RLIMIT_CPU] = "CPU",
21740 + [RLIMIT_RSS] = "RSS",
21741 + [RLIMIT_NPROC] = "NPROC",
21742 + [RLIMIT_NOFILE] = "NOFILE",
21743 + [RLIMIT_MEMLOCK] = "VML",
21744 + [RLIMIT_AS] = "VM",
21745 + [RLIMIT_LOCKS] = "LOCKS",
21746 + [RLIMIT_SIGPENDING] = "SIGP",
21747 + [RLIMIT_MSGQUEUE] = "MSGQ",
21749 + [VLIMIT_NSOCK] = "NSOCK",
21750 + [VLIMIT_OPENFD] = "OPENFD",
21751 + [VLIMIT_ANON] = "ANON",
21752 + [VLIMIT_SHMEM] = "SHMEM",
21753 + [VLIMIT_DENTRY] = "DENTRY",
21756 +EXPORT_SYMBOL_GPL(vlimit_name);
21758 +#define MASK_ENTRY(x) (1 << (x))
21760 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21763 + , /* softlimit */
21764 + MASK_ENTRY( RLIMIT_RSS ) |
21765 + MASK_ENTRY( VLIMIT_ANON ) |
21768 + MASK_ENTRY( RLIMIT_RSS ) |
21769 + MASK_ENTRY( RLIMIT_NPROC ) |
21770 + MASK_ENTRY( RLIMIT_NOFILE ) |
21771 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21772 + MASK_ENTRY( RLIMIT_AS ) |
21773 + MASK_ENTRY( RLIMIT_LOCKS ) |
21774 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21776 + MASK_ENTRY( VLIMIT_NSOCK ) |
21777 + MASK_ENTRY( VLIMIT_OPENFD ) |
21778 + MASK_ENTRY( VLIMIT_ANON ) |
21779 + MASK_ENTRY( VLIMIT_SHMEM ) |
21780 + MASK_ENTRY( VLIMIT_DENTRY ) |
21783 + /* accounting only */
21784 +uint32_t account_mask =
21785 + MASK_ENTRY( VLIMIT_SEMARY ) |
21786 + MASK_ENTRY( VLIMIT_NSEMS ) |
21787 + MASK_ENTRY( VLIMIT_MAPPED ) |
21791 +static int is_valid_vlimit(int id)
21793 + uint32_t mask = vlimit_mask.minimum |
21794 + vlimit_mask.softlimit | vlimit_mask.maximum;
21795 + return mask & (1 << id);
21798 +static int is_accounted_vlimit(int id)
21800 + if (is_valid_vlimit(id))
21802 + return account_mask & (1 << id);
21806 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21808 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21809 + return VX_VLIM(limit);
21812 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21814 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21815 + return VX_VLIM(limit);
21818 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21819 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21821 + if (!is_valid_vlimit(id))
21825 + *minimum = CRLIM_UNSET;
21827 + *softlimit = vc_get_soft(vxi, id);
21829 + *maximum = vc_get_hard(vxi, id);
21833 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21835 + struct vcmd_ctx_rlimit_v0 vc_data;
21838 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21841 + ret = do_get_rlimit(vxi, vc_data.id,
21842 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21846 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21851 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21852 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21854 + if (!is_valid_vlimit(id))
21857 + if (maximum != CRLIM_KEEP)
21858 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21859 + if (softlimit != CRLIM_KEEP)
21860 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21862 + /* clamp soft limit */
21863 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21864 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21869 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21871 + struct vcmd_ctx_rlimit_v0 vc_data;
21873 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21876 + return do_set_rlimit(vxi, vc_data.id,
21877 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21880 +#ifdef CONFIG_IA32_EMULATION
21882 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21884 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21886 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21889 + return do_set_rlimit(vxi, vc_data.id,
21890 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21893 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21895 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21898 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21901 + ret = do_get_rlimit(vxi, vc_data.id,
21902 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21906 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21911 +#endif /* CONFIG_IA32_EMULATION */
21914 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21916 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21922 +static inline void vx_reset_hits(struct _vx_limit *limit)
21926 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21927 + atomic_set(&__rlim_lhit(limit, lim), 0);
21931 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21933 + vx_reset_hits(&vxi->limit);
21937 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21942 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21943 + value = __rlim_get(limit, lim);
21944 + __rlim_rmax(limit, lim) = value;
21945 + __rlim_rmin(limit, lim) = value;
21949 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21951 + vx_reset_minmax(&vxi->limit);
21956 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21958 + struct vcmd_rlimit_stat_v0 vc_data;
21959 + struct _vx_limit *limit = &vxi->limit;
21962 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21966 + if (!is_accounted_vlimit(id))
21969 + vx_limit_fixup(limit, id);
21970 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21971 + vc_data.value = __rlim_get(limit, id);
21972 + vc_data.minimum = __rlim_rmin(limit, id);
21973 + vc_data.maximum = __rlim_rmax(limit, id);
21975 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21981 +void vx_vsi_meminfo(struct sysinfo *val)
21983 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21984 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21985 + u64 res_limit, res_usage;
21990 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21991 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21993 + if (res_limit != RESOURCE_MAX)
21994 + val->totalram = (res_limit >> PAGE_SHIFT);
21995 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21996 + val->bufferram = 0;
21997 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR */
21998 + struct vx_info *vxi = current_vx_info();
21999 + unsigned long totalram, freeram;
22002 + /* we blindly accept the max */
22003 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22004 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
22006 + /* total minus used equals free */
22007 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22008 + freeram = (v < totalram) ? totalram - v : 0;
22010 + val->totalram = totalram;
22011 + val->freeram = freeram;
22012 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22013 + val->totalhigh = 0;
22014 + val->freehigh = 0;
22018 +void vx_vsi_swapinfo(struct sysinfo *val)
22020 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22021 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22022 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
22023 + s64 swap_limit, swap_usage;
22028 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22029 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22030 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22031 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22033 + if (res_limit == RESOURCE_MAX)
22036 + swap_limit = memsw_limit - res_limit;
22037 + if (memsw_limit != RESOURCE_MAX)
22038 + val->totalswap = swap_limit >> PAGE_SHIFT;
22040 + swap_usage = memsw_usage - res_usage;
22041 + val->freeswap = (swap_usage < swap_limit) ?
22042 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22043 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22044 + struct vx_info *vxi = current_vx_info();
22045 + unsigned long totalswap, freeswap;
22048 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22049 + if (v == RLIM_INFINITY) {
22050 + val->freeswap = val->totalswap;
22054 + /* we blindly accept the max */
22055 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
22056 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22058 + /* currently 'used' swap */
22059 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22060 + w -= (w > v) ? v : w;
22062 + /* total minus used equals free */
22063 + freeswap = (w < totalswap) ? totalswap - w : 0;
22065 + val->totalswap = totalswap;
22066 + val->freeswap = freeswap;
22067 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22071 +long vx_vsi_cached(struct sysinfo *val)
22073 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22074 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22076 + return mem_cgroup_stat_read_cache(mcg);
22083 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22085 + struct vx_info *vxi = mm->mm_vx_info;
22086 + unsigned long points;
22092 + points = vxi->vx_badness_bias;
22094 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22095 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22096 + points += (v > w) ? (v - w) : 0;
22101 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/limit_init.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/limit_init.h
22102 --- linux-2.6.32.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
22103 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/limit_init.h 2009-12-03 20:04:56.000000000 +0100
22107 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22111 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22112 + __rlim_soft(limit, lim) = RLIM_INFINITY;
22113 + __rlim_hard(limit, lim) = RLIM_INFINITY;
22114 + __rlim_set(limit, lim, 0);
22115 + atomic_set(&__rlim_lhit(limit, lim), 0);
22116 + __rlim_rmin(limit, lim) = 0;
22117 + __rlim_rmax(limit, lim) = 0;
22121 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22126 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22127 + if ((1 << lim) & VLIM_NOCHECK)
22129 + value = __rlim_get(limit, lim);
22130 + vxwprintk_xid(value,
22131 + "!!! limit: %p[%s,%d] = %ld on exit.",
22132 + limit, vlimit_name[lim], lim, (long)value);
22136 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/limit_proc.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/limit_proc.h
22137 --- linux-2.6.32.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
22138 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/limit_proc.h 2009-12-03 20:04:56.000000000 +0100
22140 +#ifndef _VX_LIMIT_PROC_H
22141 +#define _VX_LIMIT_PROC_H
22143 +#include <linux/vserver/limit_int.h>
22146 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22147 +#define VX_LIMIT_TOP \
22148 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
22150 +#define VX_LIMIT_ARG(r) \
22151 + (unsigned long)__rlim_get(limit, r), \
22152 + (unsigned long)__rlim_rmin(limit, r), \
22153 + (unsigned long)__rlim_rmax(limit, r), \
22154 + VX_VLIM(__rlim_soft(limit, r)), \
22155 + VX_VLIM(__rlim_hard(limit, r)), \
22156 + atomic_read(&__rlim_lhit(limit, r))
22158 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22160 + vx_limit_fixup(limit, -1);
22161 + return sprintf(buffer, VX_LIMIT_TOP
22162 + "PROC" VX_LIMIT_FMT
22163 + "VM" VX_LIMIT_FMT
22164 + "VML" VX_LIMIT_FMT
22165 + "RSS" VX_LIMIT_FMT
22166 + "ANON" VX_LIMIT_FMT
22167 + "RMAP" VX_LIMIT_FMT
22168 + "FILES" VX_LIMIT_FMT
22169 + "OFD" VX_LIMIT_FMT
22170 + "LOCKS" VX_LIMIT_FMT
22171 + "SOCK" VX_LIMIT_FMT
22172 + "MSGQ" VX_LIMIT_FMT
22173 + "SHM" VX_LIMIT_FMT
22174 + "SEMA" VX_LIMIT_FMT
22175 + "SEMS" VX_LIMIT_FMT
22176 + "DENT" VX_LIMIT_FMT,
22177 + VX_LIMIT_ARG(RLIMIT_NPROC),
22178 + VX_LIMIT_ARG(RLIMIT_AS),
22179 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22180 + VX_LIMIT_ARG(RLIMIT_RSS),
22181 + VX_LIMIT_ARG(VLIMIT_ANON),
22182 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22183 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22184 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22185 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22186 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22187 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22188 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22189 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22190 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22191 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22194 +#endif /* _VX_LIMIT_PROC_H */
22197 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/Makefile linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/Makefile
22198 --- linux-2.6.32.10/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
22199 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/Makefile 2009-12-03 20:04:56.000000000 +0100
22202 +# Makefile for the Linux vserver routines.
22206 +obj-y += vserver.o
22208 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
22209 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
22212 +vserver-$(CONFIG_INET) += inet.o
22213 +vserver-$(CONFIG_PROC_FS) += proc.o
22214 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22215 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22216 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22217 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22219 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/monitor.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/monitor.c
22220 --- linux-2.6.32.10/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
22221 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/monitor.c 2009-12-03 20:04:56.000000000 +0100
22224 + * kernel/vserver/monitor.c
22226 + * Virtual Context Scheduler Monitor
22228 + * Copyright (C) 2006-2007 Herbert Pötzl
22230 + * V0.01 basic design
22234 +#include <linux/module.h>
22235 +#include <linux/jiffies.h>
22236 +#include <asm/uaccess.h>
22237 +#include <asm/atomic.h>
22239 +#include <linux/vserver/monitor.h>
22240 +#include <linux/vserver/debug_cmd.h>
22243 +#ifdef CONFIG_VSERVER_MONITOR
22244 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
22246 +#define VXM_SIZE 64
22249 +struct _vx_monitor {
22250 + unsigned int counter;
22252 + struct _vx_mon_entry entry[VXM_SIZE+1];
22256 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22258 +unsigned volatile int vxm_active = 1;
22260 +static atomic_t sequence = ATOMIC_INIT(0);
22265 + * requires disabled preemption */
22267 +struct _vx_mon_entry *vxm_advance(int cpu)
22269 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22270 + struct _vx_mon_entry *entry;
22271 + unsigned int index;
22273 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22274 + entry = &mon->entry[index];
22276 + entry->ev.seq = atomic_inc_return(&sequence);
22277 + entry->ev.jif = jiffies;
22281 +EXPORT_SYMBOL_GPL(vxm_advance);
22284 +int do_read_monitor(struct __user _vx_mon_entry *data,
22285 + int cpu, uint32_t *index, uint32_t *count)
22287 + int pos, ret = 0;
22288 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22289 + int end = mon->counter;
22290 + int start = end - VXM_SIZE + 2;
22291 + int idx = *index;
22293 + /* special case: get current pos */
22299 + /* have we lost some data? */
22303 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22304 + struct _vx_mon_entry *entry =
22305 + &mon->entry[idx % VXM_SIZE];
22307 + /* send entry to userspace */
22308 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22312 + /* save new index and count */
22315 + return ret ? ret : (*index < end);
22318 +int vc_read_monitor(uint32_t id, void __user *data)
22320 + struct vcmd_read_monitor_v0 vc_data;
22323 + if (id >= NR_CPUS)
22326 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22329 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22330 + id, &vc_data.index, &vc_data.count);
22332 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22337 +#ifdef CONFIG_COMPAT
22339 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22341 + struct vcmd_read_monitor_v0_x32 vc_data;
22344 + if (id >= NR_CPUS)
22347 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22350 + ret = do_read_monitor((struct __user _vx_mon_entry *)
22351 + compat_ptr(vc_data.data_ptr),
22352 + id, &vc_data.index, &vc_data.count);
22354 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22359 +#endif /* CONFIG_COMPAT */
22361 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/network.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/network.c
22362 --- linux-2.6.32.10/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22363 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/network.c 2009-12-03 20:04:56.000000000 +0100
22366 + * linux/kernel/vserver/network.c
22368 + * Virtual Server: Network Support
22370 + * Copyright (C) 2003-2007 Herbert Pötzl
22372 + * V0.01 broken out from vcontext V0.05
22373 + * V0.02 cleaned up implementation
22374 + * V0.03 added equiv nx commands
22375 + * V0.04 switch to RCU based hash
22376 + * V0.05 and back to locking again
22377 + * V0.06 changed vcmds to nxi arg
22378 + * V0.07 have __create claim() the nxi
22382 +#include <linux/err.h>
22383 +#include <linux/slab.h>
22384 +#include <linux/rcupdate.h>
22386 +#include <linux/vs_network.h>
22387 +#include <linux/vs_pid.h>
22388 +#include <linux/vserver/network_cmd.h>
22391 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22392 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22394 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22395 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22398 +static int __init init_network(void)
22400 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22401 + sizeof(struct nx_addr_v4), 0,
22402 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22403 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22404 + sizeof(struct nx_addr_v6), 0,
22405 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22410 +/* __alloc_nx_addr_v4() */
22412 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22414 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22415 + nx_addr_v4_cachep, GFP_KERNEL);
22417 + if (!IS_ERR(nxa))
22418 + memset(nxa, 0, sizeof(*nxa));
22422 +/* __dealloc_nx_addr_v4() */
22424 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22426 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22429 +/* __dealloc_nx_addr_v4_all() */
22431 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22434 + struct nx_addr_v4 *next = nxa->next;
22436 + __dealloc_nx_addr_v4(nxa);
22442 +#ifdef CONFIG_IPV6
22444 +/* __alloc_nx_addr_v6() */
22446 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22448 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22449 + nx_addr_v6_cachep, GFP_KERNEL);
22451 + if (!IS_ERR(nxa))
22452 + memset(nxa, 0, sizeof(*nxa));
22456 +/* __dealloc_nx_addr_v6() */
22458 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22460 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22463 +/* __dealloc_nx_addr_v6_all() */
22465 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22468 + struct nx_addr_v6 *next = nxa->next;
22470 + __dealloc_nx_addr_v6(nxa);
22475 +#endif /* CONFIG_IPV6 */
22477 +/* __alloc_nx_info()
22479 + * allocate an initialized nx_info struct
22480 + * doesn't make it visible (hash) */
22482 +static struct nx_info *__alloc_nx_info(nid_t nid)
22484 + struct nx_info *new = NULL;
22486 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22488 + /* would this benefit from a slab cache? */
22489 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22493 + memset(new, 0, sizeof(struct nx_info));
22494 + new->nx_id = nid;
22495 + INIT_HLIST_NODE(&new->nx_hlist);
22496 + atomic_set(&new->nx_usecnt, 0);
22497 + atomic_set(&new->nx_tasks, 0);
22498 + new->nx_state = 0;
22500 + new->nx_flags = NXF_INIT_SET;
22502 + /* rest of init goes here */
22504 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22505 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22507 + vxdprintk(VXD_CBIT(nid, 0),
22508 + "alloc_nx_info(%d) = %p", nid, new);
22509 + atomic_inc(&nx_global_ctotal);
22513 +/* __dealloc_nx_info()
22515 + * final disposal of nx_info */
22517 +static void __dealloc_nx_info(struct nx_info *nxi)
22519 + vxdprintk(VXD_CBIT(nid, 0),
22520 + "dealloc_nx_info(%p)", nxi);
22522 + nxi->nx_hlist.next = LIST_POISON1;
22525 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22526 + BUG_ON(atomic_read(&nxi->nx_tasks));
22528 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22530 + nxi->nx_state |= NXS_RELEASED;
22532 + atomic_dec(&nx_global_ctotal);
22535 +static void __shutdown_nx_info(struct nx_info *nxi)
22537 + nxi->nx_state |= NXS_SHUTDOWN;
22538 + vs_net_change(nxi, VSC_NETDOWN);
22541 +/* exported stuff */
22543 +void free_nx_info(struct nx_info *nxi)
22545 + /* context shutdown is mandatory */
22546 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22548 + /* context must not be hashed */
22549 + BUG_ON(nxi->nx_state & NXS_HASHED);
22551 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22552 + BUG_ON(atomic_read(&nxi->nx_tasks));
22554 + __dealloc_nx_info(nxi);
22558 +void __nx_set_lback(struct nx_info *nxi)
22560 + int nid = nxi->nx_id;
22561 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22563 + nxi->v4_lback.s_addr = lback;
22566 +extern int __nx_inet_add_lback(__be32 addr);
22567 +extern int __nx_inet_del_lback(__be32 addr);
22570 +/* hash table for nx_info hash */
22572 +#define NX_HASH_SIZE 13
22574 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22576 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22579 +static inline unsigned int __hashval(nid_t nid)
22581 + return (nid % NX_HASH_SIZE);
22586 +/* __hash_nx_info()
22588 + * add the nxi to the global hash table
22589 + * requires the hash_lock to be held */
22591 +static inline void __hash_nx_info(struct nx_info *nxi)
22593 + struct hlist_head *head;
22595 + vxd_assert_lock(&nx_info_hash_lock);
22596 + vxdprintk(VXD_CBIT(nid, 4),
22597 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22599 + /* context must not be hashed */
22600 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22602 + nxi->nx_state |= NXS_HASHED;
22603 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22604 + hlist_add_head(&nxi->nx_hlist, head);
22605 + atomic_inc(&nx_global_cactive);
22608 +/* __unhash_nx_info()
22610 + * remove the nxi from the global hash table
22611 + * requires the hash_lock to be held */
22613 +static inline void __unhash_nx_info(struct nx_info *nxi)
22615 + vxd_assert_lock(&nx_info_hash_lock);
22616 + vxdprintk(VXD_CBIT(nid, 4),
22617 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22618 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22620 + /* context must be hashed */
22621 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22622 + /* but without tasks */
22623 + BUG_ON(atomic_read(&nxi->nx_tasks));
22625 + nxi->nx_state &= ~NXS_HASHED;
22626 + hlist_del(&nxi->nx_hlist);
22627 + atomic_dec(&nx_global_cactive);
22631 +/* __lookup_nx_info()
22633 + * requires the hash_lock to be held
22634 + * doesn't increment the nx_refcnt */
22636 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22638 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22639 + struct hlist_node *pos;
22640 + struct nx_info *nxi;
22642 + vxd_assert_lock(&nx_info_hash_lock);
22643 + hlist_for_each(pos, head) {
22644 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22646 + if (nxi->nx_id == nid)
22651 + vxdprintk(VXD_CBIT(nid, 0),
22652 + "__lookup_nx_info(#%u): %p[#%u]",
22653 + nid, nxi, nxi ? nxi->nx_id : 0);
22658 +/* __create_nx_info()
22660 + * create the requested context
22661 + * get(), claim() and hash it */
22663 +static struct nx_info *__create_nx_info(int id)
22665 + struct nx_info *new, *nxi = NULL;
22667 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22669 + if (!(new = __alloc_nx_info(id)))
22670 + return ERR_PTR(-ENOMEM);
22672 + /* required to make dynamic xids unique */
22673 + spin_lock(&nx_info_hash_lock);
22675 + /* static context requested */
22676 + if ((nxi = __lookup_nx_info(id))) {
22677 + vxdprintk(VXD_CBIT(nid, 0),
22678 + "create_nx_info(%d) = %p (already there)", id, nxi);
22679 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22680 + nxi = ERR_PTR(-EBUSY);
22682 + nxi = ERR_PTR(-EEXIST);
22685 + /* new context */
22686 + vxdprintk(VXD_CBIT(nid, 0),
22687 + "create_nx_info(%d) = %p (new)", id, new);
22688 + claim_nx_info(new, NULL);
22689 + __nx_set_lback(new);
22690 + __hash_nx_info(get_nx_info(new));
22691 + nxi = new, new = NULL;
22694 + spin_unlock(&nx_info_hash_lock);
22696 + __dealloc_nx_info(new);
22702 +/* exported stuff */
22705 +void unhash_nx_info(struct nx_info *nxi)
22707 + __shutdown_nx_info(nxi);
22708 + spin_lock(&nx_info_hash_lock);
22709 + __unhash_nx_info(nxi);
22710 + spin_unlock(&nx_info_hash_lock);
22713 +/* lookup_nx_info()
22715 + * search for a nx_info and get() it
22716 + * negative id means current */
22718 +struct nx_info *lookup_nx_info(int id)
22720 + struct nx_info *nxi = NULL;
22723 + nxi = get_nx_info(current_nx_info());
22724 + } else if (id > 1) {
22725 + spin_lock(&nx_info_hash_lock);
22726 + nxi = get_nx_info(__lookup_nx_info(id));
22727 + spin_unlock(&nx_info_hash_lock);
22732 +/* nid_is_hashed()
22734 + * verify that nid is still hashed */
22736 +int nid_is_hashed(nid_t nid)
22740 + spin_lock(&nx_info_hash_lock);
22741 + hashed = (__lookup_nx_info(nid) != NULL);
22742 + spin_unlock(&nx_info_hash_lock);
22747 +#ifdef CONFIG_PROC_FS
22751 + * get a subset of hashed nids for proc
22752 + * assumes size is at least one */
22754 +int get_nid_list(int index, unsigned int *nids, int size)
22756 + int hindex, nr_nids = 0;
22758 + /* only show current and children */
22759 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22762 + nids[nr_nids] = nx_current_nid();
22766 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22767 + struct hlist_head *head = &nx_info_hash[hindex];
22768 + struct hlist_node *pos;
22770 + spin_lock(&nx_info_hash_lock);
22771 + hlist_for_each(pos, head) {
22772 + struct nx_info *nxi;
22777 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22778 + nids[nr_nids] = nxi->nx_id;
22779 + if (++nr_nids >= size) {
22780 + spin_unlock(&nx_info_hash_lock);
22784 + /* keep the lock time short */
22785 + spin_unlock(&nx_info_hash_lock);
22794 + * migrate task to new network
22795 + * gets nxi, puts old_nxi on change
22798 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22800 + struct nx_info *old_nxi;
22806 + vxdprintk(VXD_CBIT(nid, 5),
22807 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22808 + p, nxi, nxi->nx_id,
22809 + atomic_read(&nxi->nx_usecnt),
22810 + atomic_read(&nxi->nx_tasks));
22812 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22813 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22816 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22819 + /* maybe disallow this completely? */
22820 + old_nxi = task_get_nx_info(p);
22821 + if (old_nxi == nxi)
22826 + clr_nx_info(&p->nx_info);
22827 + claim_nx_info(nxi, p);
22828 + set_nx_info(&p->nx_info, nxi);
22829 + p->nid = nxi->nx_id;
22832 + vxdprintk(VXD_CBIT(nid, 5),
22833 + "moved task %p into nxi:%p[#%d]",
22834 + p, nxi, nxi->nx_id);
22837 + release_nx_info(old_nxi, p);
22840 + put_nx_info(old_nxi);
22845 +void nx_set_persistent(struct nx_info *nxi)
22847 + vxdprintk(VXD_CBIT(nid, 6),
22848 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22850 + get_nx_info(nxi);
22851 + claim_nx_info(nxi, NULL);
22854 +void nx_clear_persistent(struct nx_info *nxi)
22856 + vxdprintk(VXD_CBIT(nid, 6),
22857 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22859 + release_nx_info(nxi, NULL);
22860 + put_nx_info(nxi);
22863 +void nx_update_persistent(struct nx_info *nxi)
22865 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22866 + nx_set_persistent(nxi);
22868 + nx_clear_persistent(nxi);
22871 +/* vserver syscall commands below here */
22873 +/* taks nid and nx_info functions */
22875 +#include <asm/uaccess.h>
22878 +int vc_task_nid(uint32_t id)
22883 + struct task_struct *tsk;
22885 + read_lock(&tasklist_lock);
22886 + tsk = find_task_by_real_pid(id);
22887 + nid = (tsk) ? tsk->nid : -ESRCH;
22888 + read_unlock(&tasklist_lock);
22890 + nid = nx_current_nid();
22895 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22897 + struct vcmd_nx_info_v0 vc_data;
22899 + vc_data.nid = nxi->nx_id;
22901 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22907 +/* network functions */
22909 +int vc_net_create(uint32_t nid, void __user *data)
22911 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22912 + struct nx_info *new_nxi;
22915 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22918 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22921 + new_nxi = __create_nx_info(nid);
22922 + if (IS_ERR(new_nxi))
22923 + return PTR_ERR(new_nxi);
22925 + /* initial flags */
22926 + new_nxi->nx_flags = vc_data.flagword;
22929 + if (vs_net_change(new_nxi, VSC_NETUP))
22932 + ret = nx_migrate_task(current, new_nxi);
22936 + /* return context id on success */
22937 + ret = new_nxi->nx_id;
22939 + /* get a reference for persistent contexts */
22940 + if ((vc_data.flagword & NXF_PERSISTENT))
22941 + nx_set_persistent(new_nxi);
22943 + release_nx_info(new_nxi, NULL);
22944 + put_nx_info(new_nxi);
22949 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22951 + return nx_migrate_task(current, nxi);
22956 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22957 + uint16_t type, uint16_t flags)
22959 + struct nx_addr_v4 *nxa = &nxi->v4;
22961 + if (NX_IPV4(nxi)) {
22962 + /* locate last entry */
22963 + for (; nxa->next; nxa = nxa->next);
22964 + nxa->next = __alloc_nx_addr_v4();
22968 + return PTR_ERR(nxa);
22971 + if (nxi->v4.next)
22972 + /* remove single ip for ip list */
22973 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22975 + nxa->ip[0].s_addr = ip;
22976 + nxa->ip[1].s_addr = ip2;
22977 + nxa->mask.s_addr = mask;
22978 + nxa->type = type;
22979 + nxa->flags = flags;
22984 +int vc_net_add(struct nx_info *nxi, void __user *data)
22986 + struct vcmd_net_addr_v0 vc_data;
22987 + int index, ret = 0;
22989 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22992 + switch (vc_data.type) {
22993 + case NXA_TYPE_IPV4:
22994 + if ((vc_data.count < 1) || (vc_data.count > 4))
22998 + while (index < vc_data.count) {
22999 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
23000 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
23008 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23009 + nxi->v4_bcast = vc_data.ip[0];
23013 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
23014 + nxi->v4_lback = vc_data.ip[0];
23025 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23027 + struct vcmd_net_addr_v0 vc_data;
23029 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23032 + switch (vc_data.type) {
23033 + case NXA_TYPE_ANY:
23034 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23035 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23045 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23047 + struct vcmd_net_addr_ipv4_v1 vc_data;
23049 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23052 + switch (vc_data.type) {
23053 + case NXA_TYPE_ADDR:
23054 + case NXA_TYPE_RANGE:
23055 + case NXA_TYPE_MASK:
23056 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23057 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23059 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23060 + nxi->v4_bcast = vc_data.ip;
23063 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23064 + nxi->v4_lback = vc_data.ip;
23073 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23075 + struct vcmd_net_addr_ipv4_v1 vc_data;
23077 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23080 + switch (vc_data.type) {
23081 +/* case NXA_TYPE_ADDR:
23084 + case NXA_TYPE_ANY:
23085 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23086 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23096 +#ifdef CONFIG_IPV6
23098 +int do_add_v6_addr(struct nx_info *nxi,
23099 + struct in6_addr *ip, struct in6_addr *mask,
23100 + uint32_t prefix, uint16_t type, uint16_t flags)
23102 + struct nx_addr_v6 *nxa = &nxi->v6;
23104 + if (NX_IPV6(nxi)) {
23105 + /* locate last entry */
23106 + for (; nxa->next; nxa = nxa->next);
23107 + nxa->next = __alloc_nx_addr_v6();
23111 + return PTR_ERR(nxa);
23115 + nxa->mask = *mask;
23116 + nxa->prefix = prefix;
23117 + nxa->type = type;
23118 + nxa->flags = flags;
23123 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23125 + struct vcmd_net_addr_ipv6_v1 vc_data;
23127 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23130 + switch (vc_data.type) {
23131 + case NXA_TYPE_ADDR:
23132 + case NXA_TYPE_MASK:
23133 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23134 + vc_data.prefix, vc_data.type, vc_data.flags);
23141 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23143 + struct vcmd_net_addr_ipv6_v1 vc_data;
23145 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23148 + switch (vc_data.type) {
23149 + case NXA_TYPE_ANY:
23150 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23151 + memset(&nxi->v6, 0, sizeof(nxi->v6));
23160 +#endif /* CONFIG_IPV6 */
23163 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23165 + struct vcmd_net_flags_v0 vc_data;
23167 + vc_data.flagword = nxi->nx_flags;
23169 + /* special STATE flag handling */
23170 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23172 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23177 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23179 + struct vcmd_net_flags_v0 vc_data;
23180 + uint64_t mask, trigger;
23182 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23185 + /* special STATE flag handling */
23186 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23187 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23189 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23190 + vc_data.flagword, mask);
23191 + if (trigger & NXF_PERSISTENT)
23192 + nx_update_persistent(nxi);
23197 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23199 + struct vcmd_net_caps_v0 vc_data;
23201 + vc_data.ncaps = nxi->nx_ncaps;
23202 + vc_data.cmask = ~0ULL;
23204 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23209 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23211 + struct vcmd_net_caps_v0 vc_data;
23213 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23216 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23217 + vc_data.ncaps, vc_data.cmask);
23222 +#include <linux/module.h>
23224 +module_init(init_network);
23226 +EXPORT_SYMBOL_GPL(free_nx_info);
23227 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23229 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/proc.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/proc.c
23230 --- linux-2.6.32.10/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
23231 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/proc.c 2009-12-03 20:04:56.000000000 +0100
23234 + * linux/kernel/vserver/proc.c
23236 + * Virtual Context Support
23238 + * Copyright (C) 2003-2007 Herbert Pötzl
23240 + * V0.01 basic structure
23241 + * V0.02 adaptation vs1.3.0
23242 + * V0.03 proc permissions
23243 + * V0.04 locking/generic
23244 + * V0.05 next generation procfs
23245 + * V0.06 inode validation
23246 + * V0.07 generic rewrite vid
23247 + * V0.08 remove inode type
23251 +#include <linux/proc_fs.h>
23252 +#include <linux/fs_struct.h>
23253 +#include <linux/mount.h>
23254 +#include <asm/unistd.h>
23256 +#include <linux/vs_context.h>
23257 +#include <linux/vs_network.h>
23258 +#include <linux/vs_cvirt.h>
23260 +#include <linux/in.h>
23261 +#include <linux/inetdevice.h>
23262 +#include <linux/vs_inet.h>
23263 +#include <linux/vs_inet6.h>
23265 +#include <linux/vserver/global.h>
23267 +#include "cvirt_proc.h"
23268 +#include "cacct_proc.h"
23269 +#include "limit_proc.h"
23270 +#include "sched_proc.h"
23271 +#include "vci_config.h"
23274 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23278 + CAP_FOR_EACH_U32(__capi) {
23279 + buffer += sprintf(buffer, "%08x",
23280 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23286 +static struct proc_dir_entry *proc_virtual;
23288 +static struct proc_dir_entry *proc_virtnet;
23291 +/* first the actual feeds */
23294 +static int proc_vci(char *buffer)
23296 + return sprintf(buffer,
23297 + "VCIVersion:\t%04x:%04x\n"
23298 + "VCISyscall:\t%d\n"
23299 + "VCIKernel:\t%08x\n",
23300 + VCI_VERSION >> 16,
23301 + VCI_VERSION & 0xFFFF,
23303 + vci_kernel_config());
23306 +static int proc_virtual_info(char *buffer)
23308 + return proc_vci(buffer);
23311 +static int proc_virtual_status(char *buffer)
23313 + return sprintf(buffer,
23315 + "#CActive:\t%d\n"
23316 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23317 + "#InitTask:\t%d\t%d %d\n",
23318 + atomic_read(&vx_global_ctotal),
23319 + atomic_read(&vx_global_cactive),
23320 + atomic_read(&vs_global_nsproxy),
23321 + atomic_read(&vs_global_fs),
23322 + atomic_read(&vs_global_mnt_ns),
23323 + atomic_read(&vs_global_uts_ns),
23324 + atomic_read(&nr_ipc_ns),
23325 + atomic_read(&vs_global_user_ns),
23326 + atomic_read(&vs_global_pid_ns),
23327 + atomic_read(&init_task.usage),
23328 + atomic_read(&init_task.nsproxy->count),
23329 + init_task.fs->users);
23333 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23337 + length = sprintf(buffer,
23345 + vxi->vx_badness_bias);
23349 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23351 + char *orig = buffer;
23353 + buffer += sprintf(buffer,
23356 + "Flags:\t%016llx\n",
23357 + atomic_read(&vxi->vx_usecnt),
23358 + atomic_read(&vxi->vx_tasks),
23359 + (unsigned long long)vxi->vx_flags);
23361 + buffer += sprintf(buffer, "BCaps:\t");
23362 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23363 + buffer += sprintf(buffer, "\n");
23365 + buffer += sprintf(buffer,
23366 + "CCaps:\t%016llx\n"
23367 + "Spaces:\t%08lx %08lx\n",
23368 + (unsigned long long)vxi->vx_ccaps,
23369 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23370 + return buffer - orig;
23373 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23375 + return vx_info_proc_limit(&vxi->limit, buffer);
23378 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23382 + length = vx_info_proc_sched(&vxi->sched, buffer);
23383 + for_each_online_cpu(cpu) {
23384 + length += vx_info_proc_sched_pc(
23385 + &vx_per_cpu(vxi, sched_pc, cpu),
23386 + buffer + length, cpu);
23391 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23393 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23396 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23398 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23401 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23405 + vx_update_load(vxi);
23406 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23407 + for_each_online_cpu(cpu) {
23408 + length += vx_info_proc_cvirt_pc(
23409 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23410 + buffer + length, cpu);
23415 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23417 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23421 +static int proc_virtnet_info(char *buffer)
23423 + return proc_vci(buffer);
23426 +static int proc_virtnet_status(char *buffer)
23428 + return sprintf(buffer,
23430 + "#CActive:\t%d\n",
23431 + atomic_read(&nx_global_ctotal),
23432 + atomic_read(&nx_global_cactive));
23435 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23437 + struct nx_addr_v4 *v4a;
23438 +#ifdef CONFIG_IPV6
23439 + struct nx_addr_v6 *v6a;
23443 + length = sprintf(buffer,
23446 + "Bcast:\t" NIPQUAD_FMT "\n"
23447 + "Lback:\t" NIPQUAD_FMT "\n",
23450 + NIPQUAD(nxi->v4_bcast.s_addr),
23451 + NIPQUAD(nxi->v4_lback.s_addr));
23453 + if (!NX_IPV4(nxi))
23455 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23456 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23459 +#ifdef CONFIG_IPV6
23460 + if (!NX_IPV6(nxi))
23462 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23463 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23470 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23474 + length = sprintf(buffer,
23477 + "Flags:\t%016llx\n"
23478 + "NCaps:\t%016llx\n",
23479 + atomic_read(&nxi->nx_usecnt),
23480 + atomic_read(&nxi->nx_tasks),
23481 + (unsigned long long)nxi->nx_flags,
23482 + (unsigned long long)nxi->nx_ncaps);
23488 +/* here the inode helpers */
23494 + struct inode_operations *iop;
23495 + struct file_operations *fop;
23496 + union proc_op op;
23499 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23501 + struct inode *inode = new_inode(sb);
23506 + inode->i_mode = p->mode;
23508 + inode->i_op = p->iop;
23510 + inode->i_fop = p->fop;
23512 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23513 + inode->i_flags |= S_IMMUTABLE;
23515 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23517 + inode->i_uid = 0;
23518 + inode->i_gid = 0;
23519 + inode->i_tag = 0;
23524 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23525 + struct dentry *dentry, int id, void *ptr)
23527 + struct vs_entry *p = ptr;
23528 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23529 + struct dentry *error = ERR_PTR(-EINVAL);
23534 + PROC_I(inode)->op = p->op;
23535 + PROC_I(inode)->fd = id;
23536 + d_add(dentry, inode);
23544 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23547 + * Fill a directory entry.
23549 + * If possible create the dcache entry and derive our inode number and
23550 + * file type from dcache entry.
23552 + * Since all of the proc inode numbers are dynamically generated, the inode
23553 + * numbers do not exist until the inode is cache. This means creating the
23554 + * the dcache entry in readdir is necessary to keep the inode numbers
23555 + * reported by readdir in sync with the inode numbers reported
23558 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23559 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23561 + struct dentry *child, *dir = filp->f_dentry;
23562 + struct inode *inode;
23563 + struct qstr qname;
23565 + unsigned type = DT_UNKNOWN;
23567 + qname.name = name;
23569 + qname.hash = full_name_hash(name, len);
23571 + child = d_lookup(dir, &qname);
23573 + struct dentry *new;
23574 + new = d_alloc(dir, &qname);
23576 + child = instantiate(dir->d_inode, new, id, ptr);
23583 + if (!child || IS_ERR(child) || !child->d_inode)
23584 + goto end_instantiate;
23585 + inode = child->d_inode;
23587 + ino = inode->i_ino;
23588 + type = inode->i_mode >> 12;
23593 + ino = find_inode_number(dir, &qname);
23596 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23601 +/* get and revalidate vx_info/xid */
23604 +struct vx_info *get_proc_vx_info(struct inode *inode)
23606 + return lookup_vx_info(PROC_I(inode)->fd);
23609 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23611 + struct inode *inode = dentry->d_inode;
23612 + xid_t xid = PROC_I(inode)->fd;
23614 + if (!xid || xid_is_hashed(xid))
23621 +/* get and revalidate nx_info/nid */
23623 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23625 + struct inode *inode = dentry->d_inode;
23626 + nid_t nid = PROC_I(inode)->fd;
23628 + if (!nid || nid_is_hashed(nid))
23636 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23638 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23639 + size_t count, loff_t *ppos)
23641 + struct inode *inode = file->f_dentry->d_inode;
23642 + unsigned long page;
23643 + ssize_t length = 0;
23645 + if (count > PROC_BLOCK_SIZE)
23646 + count = PROC_BLOCK_SIZE;
23648 + /* fade that out as soon as stable */
23649 + WARN_ON(PROC_I(inode)->fd);
23651 + if (!(page = __get_free_page(GFP_KERNEL)))
23654 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23655 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23658 + length = simple_read_from_buffer(buf, count, ppos,
23659 + (char *)page, length);
23665 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23666 + size_t count, loff_t *ppos)
23668 + struct inode *inode = file->f_dentry->d_inode;
23669 + struct vx_info *vxi = NULL;
23670 + xid_t xid = PROC_I(inode)->fd;
23671 + unsigned long page;
23672 + ssize_t length = 0;
23674 + if (count > PROC_BLOCK_SIZE)
23675 + count = PROC_BLOCK_SIZE;
23677 + /* fade that out as soon as stable */
23679 + vxi = lookup_vx_info(xid);
23683 + length = -ENOMEM;
23684 + if (!(page = __get_free_page(GFP_KERNEL)))
23687 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23688 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23691 + length = simple_read_from_buffer(buf, count, ppos,
23692 + (char *)page, length);
23696 + put_vx_info(vxi);
23701 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23702 + size_t count, loff_t *ppos)
23704 + struct inode *inode = file->f_dentry->d_inode;
23705 + struct nx_info *nxi = NULL;
23706 + nid_t nid = PROC_I(inode)->fd;
23707 + unsigned long page;
23708 + ssize_t length = 0;
23710 + if (count > PROC_BLOCK_SIZE)
23711 + count = PROC_BLOCK_SIZE;
23713 + /* fade that out as soon as stable */
23715 + nxi = lookup_nx_info(nid);
23719 + length = -ENOMEM;
23720 + if (!(page = __get_free_page(GFP_KERNEL)))
23723 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23724 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23727 + length = simple_read_from_buffer(buf, count, ppos,
23728 + (char *)page, length);
23732 + put_nx_info(nxi);
23739 +/* here comes the lower level */
23742 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23743 + .len = sizeof(NAME) - 1, \
23744 + .name = (NAME), \
23752 +#define DIR(NAME, MODE, OTYPE) \
23753 + NOD(NAME, (S_IFDIR | (MODE)), \
23754 + &proc_ ## OTYPE ## _inode_operations, \
23755 + &proc_ ## OTYPE ## _file_operations, { } )
23757 +#define INF(NAME, MODE, OTYPE) \
23758 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23759 + &proc_vs_info_file_operations, \
23760 + { .proc_vs_read = &proc_##OTYPE } )
23762 +#define VINF(NAME, MODE, OTYPE) \
23763 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23764 + &proc_vx_info_file_operations, \
23765 + { .proc_vxi_read = &proc_##OTYPE } )
23767 +#define NINF(NAME, MODE, OTYPE) \
23768 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23769 + &proc_nx_info_file_operations, \
23770 + { .proc_nxi_read = &proc_##OTYPE } )
23773 +static struct file_operations proc_vs_info_file_operations = {
23774 + .read = proc_vs_info_read,
23777 +static struct file_operations proc_vx_info_file_operations = {
23778 + .read = proc_vx_info_read,
23781 +static struct dentry_operations proc_xid_dentry_operations = {
23782 + .d_revalidate = proc_xid_revalidate,
23785 +static struct vs_entry vx_base_stuff[] = {
23786 + VINF("info", S_IRUGO, vxi_info),
23787 + VINF("status", S_IRUGO, vxi_status),
23788 + VINF("limit", S_IRUGO, vxi_limit),
23789 + VINF("sched", S_IRUGO, vxi_sched),
23790 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23791 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23792 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23793 + VINF("cacct", S_IRUGO, vxi_cacct),
23800 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23801 + struct dentry *dentry, int id, void *ptr)
23803 + dentry->d_op = &proc_xid_dentry_operations;
23804 + return vs_proc_instantiate(dir, dentry, id, ptr);
23807 +static struct dentry *proc_xid_lookup(struct inode *dir,
23808 + struct dentry *dentry, struct nameidata *nd)
23810 + struct vs_entry *p = vx_base_stuff;
23811 + struct dentry *error = ERR_PTR(-ENOENT);
23813 + for (; p->name; p++) {
23814 + if (p->len != dentry->d_name.len)
23816 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23822 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23827 +static int proc_xid_readdir(struct file *filp,
23828 + void *dirent, filldir_t filldir)
23830 + struct dentry *dentry = filp->f_dentry;
23831 + struct inode *inode = dentry->d_inode;
23832 + struct vs_entry *p = vx_base_stuff;
23833 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23837 + pos = filp->f_pos;
23840 + ino = inode->i_ino;
23841 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23844 + /* fall through */
23846 + ino = parent_ino(dentry);
23847 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23850 + /* fall through */
23853 + if (index >= size)
23855 + for (p += index; p->name; p++) {
23856 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23857 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23863 + filp->f_pos = pos;
23869 +static struct file_operations proc_nx_info_file_operations = {
23870 + .read = proc_nx_info_read,
23873 +static struct dentry_operations proc_nid_dentry_operations = {
23874 + .d_revalidate = proc_nid_revalidate,
23877 +static struct vs_entry nx_base_stuff[] = {
23878 + NINF("info", S_IRUGO, nxi_info),
23879 + NINF("status", S_IRUGO, nxi_status),
23884 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23885 + struct dentry *dentry, int id, void *ptr)
23887 + dentry->d_op = &proc_nid_dentry_operations;
23888 + return vs_proc_instantiate(dir, dentry, id, ptr);
23891 +static struct dentry *proc_nid_lookup(struct inode *dir,
23892 + struct dentry *dentry, struct nameidata *nd)
23894 + struct vs_entry *p = nx_base_stuff;
23895 + struct dentry *error = ERR_PTR(-ENOENT);
23897 + for (; p->name; p++) {
23898 + if (p->len != dentry->d_name.len)
23900 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23906 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23911 +static int proc_nid_readdir(struct file *filp,
23912 + void *dirent, filldir_t filldir)
23914 + struct dentry *dentry = filp->f_dentry;
23915 + struct inode *inode = dentry->d_inode;
23916 + struct vs_entry *p = nx_base_stuff;
23917 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23921 + pos = filp->f_pos;
23924 + ino = inode->i_ino;
23925 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23928 + /* fall through */
23930 + ino = parent_ino(dentry);
23931 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23934 + /* fall through */
23937 + if (index >= size)
23939 + for (p += index; p->name; p++) {
23940 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23941 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23947 + filp->f_pos = pos;
23952 +#define MAX_MULBY10 ((~0U - 9) / 10)
23954 +static inline int atovid(const char *str, int len)
23959 + while (len-- > 0) {
23964 + if (vid >= MAX_MULBY10)
23974 +/* now the upper level (virtual) */
23977 +static struct file_operations proc_xid_file_operations = {
23978 + .read = generic_read_dir,
23979 + .readdir = proc_xid_readdir,
23982 +static struct inode_operations proc_xid_inode_operations = {
23983 + .lookup = proc_xid_lookup,
23986 +static struct vs_entry vx_virtual_stuff[] = {
23987 + INF("info", S_IRUGO, virtual_info),
23988 + INF("status", S_IRUGO, virtual_status),
23989 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23993 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23994 + struct dentry *dentry, struct nameidata *nd)
23996 + struct vs_entry *p = vx_virtual_stuff;
23997 + struct dentry *error = ERR_PTR(-ENOENT);
24000 + for (; p->name; p++) {
24001 + if (p->len != dentry->d_name.len)
24003 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24007 + goto instantiate;
24009 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24010 + if ((id < 0) || !xid_is_hashed(id))
24014 + error = proc_xid_instantiate(dir, dentry, id, p);
24019 +static struct file_operations proc_nid_file_operations = {
24020 + .read = generic_read_dir,
24021 + .readdir = proc_nid_readdir,
24024 +static struct inode_operations proc_nid_inode_operations = {
24025 + .lookup = proc_nid_lookup,
24028 +static struct vs_entry nx_virtnet_stuff[] = {
24029 + INF("info", S_IRUGO, virtnet_info),
24030 + INF("status", S_IRUGO, virtnet_status),
24031 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
24035 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24036 + struct dentry *dentry, struct nameidata *nd)
24038 + struct vs_entry *p = nx_virtnet_stuff;
24039 + struct dentry *error = ERR_PTR(-ENOENT);
24042 + for (; p->name; p++) {
24043 + if (p->len != dentry->d_name.len)
24045 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24049 + goto instantiate;
24051 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24052 + if ((id < 0) || !nid_is_hashed(id))
24056 + error = proc_nid_instantiate(dir, dentry, id, p);
24062 +#define PROC_MAXVIDS 32
24064 +int proc_virtual_readdir(struct file *filp,
24065 + void *dirent, filldir_t filldir)
24067 + struct dentry *dentry = filp->f_dentry;
24068 + struct inode *inode = dentry->d_inode;
24069 + struct vs_entry *p = vx_virtual_stuff;
24070 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24072 + unsigned int xid_array[PROC_MAXVIDS];
24073 + char buf[PROC_NUMBUF];
24074 + unsigned int nr_xids, i;
24077 + pos = filp->f_pos;
24080 + ino = inode->i_ino;
24081 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24084 + /* fall through */
24086 + ino = parent_ino(dentry);
24087 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24090 + /* fall through */
24093 + if (index >= size)
24095 + for (p += index; p->name; p++) {
24096 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24097 + vs_proc_instantiate, 0, p))
24102 + index = pos - size;
24103 + p = &vx_virtual_stuff[size - 1];
24104 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24105 + for (i = 0; i < nr_xids; i++) {
24106 + int n, xid = xid_array[i];
24107 + unsigned int j = PROC_NUMBUF;
24111 + buf[--j] = '0' + (n % 10);
24114 + if (proc_fill_cache(filp, dirent, filldir,
24115 + buf + j, PROC_NUMBUF - j,
24116 + vs_proc_instantiate, xid, p))
24122 + filp->f_pos = pos;
24126 +static int proc_virtual_getattr(struct vfsmount *mnt,
24127 + struct dentry *dentry, struct kstat *stat)
24129 + struct inode *inode = dentry->d_inode;
24131 + generic_fillattr(inode, stat);
24132 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
24136 +static struct file_operations proc_virtual_dir_operations = {
24137 + .read = generic_read_dir,
24138 + .readdir = proc_virtual_readdir,
24141 +static struct inode_operations proc_virtual_dir_inode_operations = {
24142 + .getattr = proc_virtual_getattr,
24143 + .lookup = proc_virtual_lookup,
24150 +int proc_virtnet_readdir(struct file *filp,
24151 + void *dirent, filldir_t filldir)
24153 + struct dentry *dentry = filp->f_dentry;
24154 + struct inode *inode = dentry->d_inode;
24155 + struct vs_entry *p = nx_virtnet_stuff;
24156 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24158 + unsigned int nid_array[PROC_MAXVIDS];
24159 + char buf[PROC_NUMBUF];
24160 + unsigned int nr_nids, i;
24163 + pos = filp->f_pos;
24166 + ino = inode->i_ino;
24167 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24170 + /* fall through */
24172 + ino = parent_ino(dentry);
24173 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24176 + /* fall through */
24179 + if (index >= size)
24181 + for (p += index; p->name; p++) {
24182 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24183 + vs_proc_instantiate, 0, p))
24188 + index = pos - size;
24189 + p = &nx_virtnet_stuff[size - 1];
24190 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24191 + for (i = 0; i < nr_nids; i++) {
24192 + int n, nid = nid_array[i];
24193 + unsigned int j = PROC_NUMBUF;
24197 + buf[--j] = '0' + (n % 10);
24200 + if (proc_fill_cache(filp, dirent, filldir,
24201 + buf + j, PROC_NUMBUF - j,
24202 + vs_proc_instantiate, nid, p))
24208 + filp->f_pos = pos;
24212 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24213 + struct dentry *dentry, struct kstat *stat)
24215 + struct inode *inode = dentry->d_inode;
24217 + generic_fillattr(inode, stat);
24218 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
24222 +static struct file_operations proc_virtnet_dir_operations = {
24223 + .read = generic_read_dir,
24224 + .readdir = proc_virtnet_readdir,
24227 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24228 + .getattr = proc_virtnet_getattr,
24229 + .lookup = proc_virtnet_lookup,
24234 +void proc_vx_init(void)
24236 + struct proc_dir_entry *ent;
24238 + ent = proc_mkdir("virtual", 0);
24240 + ent->proc_fops = &proc_virtual_dir_operations;
24241 + ent->proc_iops = &proc_virtual_dir_inode_operations;
24243 + proc_virtual = ent;
24245 + ent = proc_mkdir("virtnet", 0);
24247 + ent->proc_fops = &proc_virtnet_dir_operations;
24248 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
24250 + proc_virtnet = ent;
24256 +/* per pid info */
24259 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24261 + struct vx_info *vxi;
24262 + char *orig = buffer;
24264 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24266 + vxi = task_get_vx_info(p);
24270 + buffer += sprintf(buffer, "BCaps:\t");
24271 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24272 + buffer += sprintf(buffer, "\n");
24273 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24274 + (unsigned long long)vxi->vx_ccaps);
24275 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24276 + (unsigned long long)vxi->vx_flags);
24277 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24279 + put_vx_info(vxi);
24281 + return buffer - orig;
24285 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24287 + struct nx_info *nxi;
24288 + struct nx_addr_v4 *v4a;
24289 +#ifdef CONFIG_IPV6
24290 + struct nx_addr_v6 *v6a;
24292 + char *orig = buffer;
24295 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24297 + nxi = task_get_nx_info(p);
24301 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24302 + (unsigned long long)nxi->nx_ncaps);
24303 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24304 + (unsigned long long)nxi->nx_flags);
24306 + buffer += sprintf(buffer,
24307 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24308 + NIPQUAD(nxi->v4_bcast.s_addr));
24309 + buffer += sprintf (buffer,
24310 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24311 + NIPQUAD(nxi->v4_lback.s_addr));
24312 + if (!NX_IPV4(nxi))
24314 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24315 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24318 +#ifdef CONFIG_IPV6
24319 + if (!NX_IPV6(nxi))
24321 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24322 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24326 + put_nx_info(nxi);
24328 + return buffer - orig;
24331 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/sched.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sched.c
24332 --- linux-2.6.32.10/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24333 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sched.c 2009-12-03 20:04:56.000000000 +0100
24336 + * linux/kernel/vserver/sched.c
24338 + * Virtual Server: Scheduler Support
24340 + * Copyright (C) 2004-2007 Herbert Pötzl
24342 + * V0.01 adapted Sam Vilains version to 2.6.3
24343 + * V0.02 removed legacy interface
24344 + * V0.03 changed vcmds to vxi arg
24345 + * V0.04 removed older and legacy interfaces
24349 +#include <linux/vs_context.h>
24350 +#include <linux/vs_sched.h>
24351 +#include <linux/vserver/sched_cmd.h>
24353 +#include <asm/uaccess.h>
24356 +#define vxd_check_range(val, min, max) do { \
24357 + vxlprintk((val < min) || (val > max), \
24358 + "check_range(%ld,%ld,%ld)", \
24359 + (long)val, (long)min, (long)max, \
24360 + __FILE__, __LINE__); \
24364 +void vx_update_sched_param(struct _vx_sched *sched,
24365 + struct _vx_sched_pc *sched_pc)
24367 + unsigned int set_mask = sched->update_mask;
24369 + if (set_mask & VXSM_FILL_RATE)
24370 + sched_pc->fill_rate[0] = sched->fill_rate[0];
24371 + if (set_mask & VXSM_INTERVAL)
24372 + sched_pc->interval[0] = sched->interval[0];
24373 + if (set_mask & VXSM_FILL_RATE2)
24374 + sched_pc->fill_rate[1] = sched->fill_rate[1];
24375 + if (set_mask & VXSM_INTERVAL2)
24376 + sched_pc->interval[1] = sched->interval[1];
24377 + if (set_mask & VXSM_TOKENS)
24378 + sched_pc->tokens = sched->tokens;
24379 + if (set_mask & VXSM_TOKENS_MIN)
24380 + sched_pc->tokens_min = sched->tokens_min;
24381 + if (set_mask & VXSM_TOKENS_MAX)
24382 + sched_pc->tokens_max = sched->tokens_max;
24383 + if (set_mask & VXSM_PRIO_BIAS)
24384 + sched_pc->prio_bias = sched->prio_bias;
24386 + if (set_mask & VXSM_IDLE_TIME)
24387 + sched_pc->flags |= VXSF_IDLE_TIME;
24389 + sched_pc->flags &= ~VXSF_IDLE_TIME;
24392 + sched_pc->norm_time = jiffies;
24397 + * recalculate the context's scheduling tokens
24399 + * ret > 0 : number of tokens available
24400 + * ret < 0 : on hold, check delta_min[]
24401 + * -1 only jiffies
24402 + * -2 also idle time
24405 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24406 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24410 + int flags = sched_pc->flags;
24412 + /* how much time did pass? */
24413 + delta = *norm_time - sched_pc->norm_time;
24414 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24415 + vxd_check_range(delta, 0, INT_MAX);
24417 + if (delta >= sched_pc->interval[0]) {
24418 + long tokens, integral;
24420 + /* calc integral token part */
24421 + tokens = delta / sched_pc->interval[0];
24422 + integral = tokens * sched_pc->interval[0];
24423 + tokens *= sched_pc->fill_rate[0];
24424 +#ifdef CONFIG_VSERVER_HARDCPU
24425 + delta_min[0] = delta - integral;
24426 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24428 + /* advance time */
24429 + sched_pc->norm_time += delta;
24432 + sched_pc->tokens += tokens;
24433 + sched_pc->token_time += tokens;
24435 + delta_min[0] = delta;
24437 +#ifdef CONFIG_VSERVER_IDLETIME
24438 + if (!(flags & VXSF_IDLE_TIME))
24441 + /* how much was the idle skip? */
24442 + delta = *idle_time - sched_pc->idle_time;
24443 + vxd_check_range(delta, 0, INT_MAX);
24445 + if (delta >= sched_pc->interval[1]) {
24446 + long tokens, integral;
24448 + /* calc fair share token part */
24449 + tokens = delta / sched_pc->interval[1];
24450 + integral = tokens * sched_pc->interval[1];
24451 + tokens *= sched_pc->fill_rate[1];
24452 + delta_min[1] = delta - integral;
24453 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24455 + /* advance idle time */
24456 + sched_pc->idle_time += integral;
24459 + sched_pc->tokens += tokens;
24460 + sched_pc->token_time += tokens;
24462 + delta_min[1] = delta;
24466 + /* clip at maximum */
24467 + if (sched_pc->tokens > sched_pc->tokens_max)
24468 + sched_pc->tokens = sched_pc->tokens_max;
24469 + tokens = sched_pc->tokens;
24471 + if ((flags & VXSF_ONHOLD)) {
24472 + /* can we unhold? */
24473 + if (tokens >= sched_pc->tokens_min) {
24474 + flags &= ~VXSF_ONHOLD;
24475 + sched_pc->hold_ticks +=
24476 + *norm_time - sched_pc->onhold;
24480 + /* put on hold? */
24481 + if (tokens <= 0) {
24482 + flags |= VXSF_ONHOLD;
24483 + sched_pc->onhold = *norm_time;
24487 + sched_pc->flags = flags;
24491 + tokens = sched_pc->tokens_min - tokens;
24492 + sched_pc->flags = flags;
24493 + // BUG_ON(tokens < 0); probably doesn't hold anymore
24495 +#ifdef CONFIG_VSERVER_HARDCPU
24496 + /* next interval? */
24497 + if (!sched_pc->fill_rate[0])
24498 + delta_min[0] = HZ;
24499 + else if (tokens > sched_pc->fill_rate[0])
24500 + delta_min[0] += sched_pc->interval[0] *
24501 + tokens / sched_pc->fill_rate[0];
24503 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24504 + vxd_check_range(delta_min[0], 0, INT_MAX);
24506 +#ifdef CONFIG_VSERVER_IDLETIME
24507 + if (!(flags & VXSF_IDLE_TIME))
24510 + /* next interval? */
24511 + if (!sched_pc->fill_rate[1])
24512 + delta_min[1] = HZ;
24513 + else if (tokens > sched_pc->fill_rate[1])
24514 + delta_min[1] += sched_pc->interval[1] *
24515 + tokens / sched_pc->fill_rate[1];
24517 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24518 + vxd_check_range(delta_min[1], 0, INT_MAX);
24523 +#endif /* CONFIG_VSERVER_IDLETIME */
24526 +#endif /* CONFIG_VSERVER_HARDCPU */
24529 +static inline unsigned long msec_to_ticks(unsigned long msec)
24531 + return msecs_to_jiffies(msec);
24534 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24536 + return jiffies_to_msecs(ticks);
24539 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24541 + return jiffies_to_usecs(ticks);
24545 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24547 + unsigned int set_mask = data->mask;
24548 + unsigned int update_mask;
24551 + /* Sanity check data values */
24552 + if (data->tokens_max <= 0)
24553 + data->tokens_max = HZ;
24554 + if (data->tokens_min < 0)
24555 + data->tokens_min = HZ / 3;
24556 + if (data->tokens_min >= data->tokens_max)
24557 + data->tokens_min = data->tokens_max;
24559 + if (data->prio_bias > MAX_PRIO_BIAS)
24560 + data->prio_bias = MAX_PRIO_BIAS;
24561 + if (data->prio_bias < MIN_PRIO_BIAS)
24562 + data->prio_bias = MIN_PRIO_BIAS;
24564 + spin_lock(&vxi->sched.tokens_lock);
24566 + /* sync up on delayed updates */
24567 + for_each_cpu_mask(cpu, vxi->sched.update)
24568 + vx_update_sched_param(&vxi->sched,
24569 + &vx_per_cpu(vxi, sched_pc, cpu));
24571 + if (set_mask & VXSM_FILL_RATE)
24572 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24573 + if (set_mask & VXSM_FILL_RATE2)
24574 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24575 + if (set_mask & VXSM_INTERVAL)
24576 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24577 + msec_to_ticks(data->interval[0]) : data->interval[0];
24578 + if (set_mask & VXSM_INTERVAL2)
24579 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24580 + msec_to_ticks(data->interval[1]) : data->interval[1];
24581 + if (set_mask & VXSM_TOKENS)
24582 + vxi->sched.tokens = data->tokens;
24583 + if (set_mask & VXSM_TOKENS_MIN)
24584 + vxi->sched.tokens_min = data->tokens_min;
24585 + if (set_mask & VXSM_TOKENS_MAX)
24586 + vxi->sched.tokens_max = data->tokens_max;
24587 + if (set_mask & VXSM_PRIO_BIAS)
24588 + vxi->sched.prio_bias = data->prio_bias;
24590 + /* Sanity check rate/interval */
24591 + for (i = 0; i < 2; i++) {
24592 + if (data->fill_rate[i] < 0)
24593 + data->fill_rate[i] = 0;
24594 + if (data->interval[i] <= 0)
24595 + data->interval[i] = HZ;
24598 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24599 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24600 + vxi->sched.update_mask = update_mask;
24604 + if (set_mask & VXSM_CPU_ID) {
24605 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24606 + cpus_and(vxi->sched.update, cpu_online_map,
24607 + vxi->sched.update);
24609 + vxi->sched.update = cpu_online_map;
24611 + /* forced reload? */
24612 + if (set_mask & VXSM_FORCE) {
24613 + for_each_cpu_mask(cpu, vxi->sched.update)
24614 + vx_update_sched_param(&vxi->sched,
24615 + &vx_per_cpu(vxi, sched_pc, cpu));
24616 + vxi->sched.update = CPU_MASK_NONE;
24619 + /* on UP we update immediately */
24620 + vx_update_sched_param(&vxi->sched,
24621 + &vx_per_cpu(vxi, sched_pc, 0));
24624 + spin_unlock(&vxi->sched.tokens_lock);
24629 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24630 +#define COPY_PRI(C) C(prio_bias)
24631 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24632 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24633 + C(fill_rate[1]); C(interval[1]);
24635 +#define COPY_VALUE(name) vc_data.name = data->name
24637 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24639 + struct vcmd_sched_v5 vc_data;
24641 + vc_data.mask = data->set_mask;
24642 + COPY_IDS(COPY_VALUE);
24643 + COPY_PRI(COPY_VALUE);
24644 + COPY_TOK(COPY_VALUE);
24645 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24646 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24647 + return do_set_sched(vxi, &vc_data);
24650 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24652 + struct vcmd_set_sched_v4 vc_data;
24654 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24657 + return do_set_sched_v4(vxi, &vc_data);
24660 + /* latest interface is v5 */
24662 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24664 + struct vcmd_sched_v5 vc_data;
24666 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24669 + return do_set_sched(vxi, &vc_data);
24673 +#define COPY_PRI(C) C(prio_bias)
24674 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24675 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24676 + C(fill_rate[1]); C(interval[1]);
24678 +#define COPY_VALUE(name) vc_data.name = data->name
24681 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24683 + struct vcmd_sched_v5 vc_data;
24685 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24688 + if (vc_data.mask & VXSM_CPU_ID) {
24689 + int cpu = vc_data.cpu_id;
24690 + struct _vx_sched_pc *data;
24692 + if (!cpu_possible(cpu))
24695 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24696 + COPY_TOK(COPY_VALUE);
24697 + COPY_PRI(COPY_VALUE);
24698 + COPY_FRI(COPY_VALUE);
24700 + if (data->flags & VXSF_IDLE_TIME)
24701 + vc_data.mask |= VXSM_IDLE_TIME;
24703 + struct _vx_sched *data = &vxi->sched;
24705 + COPY_TOK(COPY_VALUE);
24706 + COPY_PRI(COPY_VALUE);
24707 + COPY_FRI(COPY_VALUE);
24710 + if (vc_data.mask & VXSM_MSEC) {
24711 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24712 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24715 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24721 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24723 + struct vcmd_sched_info vc_data;
24726 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24729 + cpu = vc_data.cpu_id;
24730 + if (!cpu_possible(cpu))
24734 + struct _vx_sched_pc *sched_pc =
24735 + &vx_per_cpu(vxi, sched_pc, cpu);
24737 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24738 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24739 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24740 + vc_data.vavavoom = sched_pc->vavavoom;
24742 + vc_data.token_usec = ticks_to_usec(1);
24744 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24749 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/sched_init.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sched_init.h
24750 --- linux-2.6.32.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24751 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sched_init.h 2009-12-03 20:04:56.000000000 +0100
24754 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24756 + static struct lock_class_key tokens_lock_key;
24758 + /* scheduling; hard code starting values as constants */
24759 + sched->fill_rate[0] = 1;
24760 + sched->interval[0] = 4;
24761 + sched->fill_rate[1] = 1;
24762 + sched->interval[1] = 8;
24763 + sched->tokens = HZ >> 2;
24764 + sched->tokens_min = HZ >> 4;
24765 + sched->tokens_max = HZ >> 1;
24766 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24767 + sched->prio_bias = 0;
24769 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24773 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24775 + sched_pc->fill_rate[0] = 1;
24776 + sched_pc->interval[0] = 4;
24777 + sched_pc->fill_rate[1] = 1;
24778 + sched_pc->interval[1] = 8;
24779 + sched_pc->tokens = HZ >> 2;
24780 + sched_pc->tokens_min = HZ >> 4;
24781 + sched_pc->tokens_max = HZ >> 1;
24782 + sched_pc->prio_bias = 0;
24783 + sched_pc->vavavoom = 0;
24784 + sched_pc->token_time = 0;
24785 + sched_pc->idle_time = 0;
24786 + sched_pc->norm_time = jiffies;
24788 + sched_pc->user_ticks = 0;
24789 + sched_pc->sys_ticks = 0;
24790 + sched_pc->hold_ticks = 0;
24793 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24799 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24803 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/sched_proc.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sched_proc.h
24804 --- linux-2.6.32.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24805 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sched_proc.h 2009-12-03 20:04:56.000000000 +0100
24807 +#ifndef _VX_SCHED_PROC_H
24808 +#define _VX_SCHED_PROC_H
24812 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24816 + length += sprintf(buffer,
24817 + "FillRate:\t%8d,%d\n"
24818 + "Interval:\t%8d,%d\n"
24819 + "TokensMin:\t%8d\n"
24820 + "TokensMax:\t%8d\n"
24821 + "PrioBias:\t%8d\n",
24822 + sched->fill_rate[0],
24823 + sched->fill_rate[1],
24824 + sched->interval[0],
24825 + sched->interval[1],
24826 + sched->tokens_min,
24827 + sched->tokens_max,
24828 + sched->prio_bias);
24833 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24834 + char *buffer, int cpu)
24838 + length += sprintf(buffer + length,
24839 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24840 + (unsigned long long)sched_pc->user_ticks,
24841 + (unsigned long long)sched_pc->sys_ticks,
24842 + (unsigned long long)sched_pc->hold_ticks,
24843 + sched_pc->token_time,
24844 + sched_pc->idle_time);
24845 + length += sprintf(buffer + length,
24846 + " %c%c %d %d %d %d/%d %d/%d",
24847 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24848 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24849 + sched_pc->tokens,
24850 + sched_pc->tokens_min,
24851 + sched_pc->tokens_max,
24852 + sched_pc->fill_rate[0],
24853 + sched_pc->interval[0],
24854 + sched_pc->fill_rate[1],
24855 + sched_pc->interval[1]);
24856 + length += sprintf(buffer + length,
24858 + sched_pc->prio_bias,
24859 + sched_pc->vavavoom);
24863 +#endif /* _VX_SCHED_PROC_H */
24864 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/signal.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/signal.c
24865 --- linux-2.6.32.10/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24866 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/signal.c 2009-12-03 20:04:56.000000000 +0100
24869 + * linux/kernel/vserver/signal.c
24871 + * Virtual Server: Signal Support
24873 + * Copyright (C) 2003-2007 Herbert Pötzl
24875 + * V0.01 broken out from vcontext V0.05
24876 + * V0.02 changed vcmds to vxi arg
24877 + * V0.03 adjusted siginfo for kill
24881 +#include <asm/uaccess.h>
24883 +#include <linux/vs_context.h>
24884 +#include <linux/vs_pid.h>
24885 +#include <linux/vserver/signal_cmd.h>
24888 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24890 + int retval, count = 0;
24891 + struct task_struct *p;
24892 + struct siginfo *sip = SEND_SIG_PRIV;
24895 + vxdprintk(VXD_CBIT(misc, 4),
24896 + "vx_info_kill(%p[#%d],%d,%d)*",
24897 + vxi, vxi->vx_id, pid, sig);
24898 + read_lock(&tasklist_lock);
24902 + for_each_process(p) {
24905 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24906 + (pid && vxi->vx_initpid == p->pid))
24909 + err = group_send_sig_info(sig, sip, p);
24911 + if (err != -EPERM)
24917 + if (vxi->vx_initpid) {
24918 + pid = vxi->vx_initpid;
24919 + /* for now, only SIGINT to private init ... */
24920 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24921 + /* ... as long as there are tasks left */
24922 + (atomic_read(&vxi->vx_tasks) > 1))
24925 + /* fallthrough */
24927 + p = find_task_by_real_pid(pid);
24929 + if (vx_task_xid(p) == vxi->vx_id)
24930 + retval = group_send_sig_info(sig, sip, p);
24934 + read_unlock(&tasklist_lock);
24935 + vxdprintk(VXD_CBIT(misc, 4),
24936 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24937 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24941 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24943 + struct vcmd_ctx_kill_v0 vc_data;
24945 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24948 + /* special check to allow guest shutdown */
24949 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24950 + /* forbid killall pid=0 when init is present */
24951 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24952 + (vc_data.pid > 1)))
24955 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24959 +static int __wait_exit(struct vx_info *vxi)
24961 + DECLARE_WAITQUEUE(wait, current);
24964 + add_wait_queue(&vxi->vx_wait, &wait);
24965 + set_current_state(TASK_INTERRUPTIBLE);
24968 + if (vx_info_state(vxi,
24969 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24971 + if (signal_pending(current)) {
24972 + ret = -ERESTARTSYS;
24979 + set_current_state(TASK_RUNNING);
24980 + remove_wait_queue(&vxi->vx_wait, &wait);
24986 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24988 + struct vcmd_wait_exit_v0 vc_data;
24991 + ret = __wait_exit(vxi);
24992 + vc_data.reboot_cmd = vxi->reboot_cmd;
24993 + vc_data.exit_code = vxi->exit_code;
24995 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25000 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/space.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/space.c
25001 --- linux-2.6.32.10/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
25002 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/space.c 2009-12-03 20:04:56.000000000 +0100
25005 + * linux/kernel/vserver/space.c
25007 + * Virtual Server: Context Space Support
25009 + * Copyright (C) 2003-2007 Herbert Pötzl
25011 + * V0.01 broken out from context.c 0.07
25012 + * V0.02 added task locking for namespace
25013 + * V0.03 broken out vx_enter_namespace
25014 + * V0.04 added *space support and commands
25018 +#include <linux/utsname.h>
25019 +#include <linux/nsproxy.h>
25020 +#include <linux/err.h>
25021 +#include <linux/fs_struct.h>
25022 +#include <asm/uaccess.h>
25024 +#include <linux/vs_context.h>
25025 +#include <linux/vserver/space.h>
25026 +#include <linux/vserver/space_cmd.h>
25028 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
25029 +atomic_t vs_global_fs = ATOMIC_INIT(0);
25030 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
25031 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
25032 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
25033 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
25036 +/* namespace functions */
25038 +#include <linux/mnt_namespace.h>
25039 +#include <linux/user_namespace.h>
25040 +#include <linux/pid_namespace.h>
25041 +#include <linux/ipc_namespace.h>
25042 +#include <net/net_namespace.h>
25045 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
25046 + .mask = CLONE_FS |
25054 +static const struct vcmd_space_mask_v1 space_mask = {
25055 + .mask = CLONE_FS |
25060 +#ifdef CONFIG_PID_NS
25063 +#ifdef CONFIG_NET_NS
25069 +static const struct vcmd_space_mask_v1 default_space_mask = {
25070 + .mask = CLONE_FS |
25075 +#ifdef CONFIG_PID_NS
25082 + * build a new nsproxy mix
25083 + * assumes that both proxies are 'const'
25084 + * does not touch nsproxy refcounts
25085 + * will hold a reference on the result.
25088 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25089 + struct nsproxy *new_nsproxy, unsigned long mask)
25091 + struct mnt_namespace *old_ns;
25092 + struct uts_namespace *old_uts;
25093 + struct ipc_namespace *old_ipc;
25094 +#ifdef CONFIG_PID_NS
25095 + struct pid_namespace *old_pid;
25097 +#ifdef CONFIG_NET_NS
25098 + struct net *old_net;
25100 + struct nsproxy *nsproxy;
25102 + nsproxy = copy_nsproxy(old_nsproxy);
25106 + if (mask & CLONE_NEWNS) {
25107 + old_ns = nsproxy->mnt_ns;
25108 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25109 + if (nsproxy->mnt_ns)
25110 + get_mnt_ns(nsproxy->mnt_ns);
25114 + if (mask & CLONE_NEWUTS) {
25115 + old_uts = nsproxy->uts_ns;
25116 + nsproxy->uts_ns = new_nsproxy->uts_ns;
25117 + if (nsproxy->uts_ns)
25118 + get_uts_ns(nsproxy->uts_ns);
25122 + if (mask & CLONE_NEWIPC) {
25123 + old_ipc = nsproxy->ipc_ns;
25124 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25125 + if (nsproxy->ipc_ns)
25126 + get_ipc_ns(nsproxy->ipc_ns);
25130 +#ifdef CONFIG_PID_NS
25131 + if (mask & CLONE_NEWPID) {
25132 + old_pid = nsproxy->pid_ns;
25133 + nsproxy->pid_ns = new_nsproxy->pid_ns;
25134 + if (nsproxy->pid_ns)
25135 + get_pid_ns(nsproxy->pid_ns);
25139 +#ifdef CONFIG_NET_NS
25140 + if (mask & CLONE_NEWNET) {
25141 + old_net = nsproxy->net_ns;
25142 + nsproxy->net_ns = new_nsproxy->net_ns;
25143 + if (nsproxy->net_ns)
25144 + get_net(nsproxy->net_ns);
25149 + put_mnt_ns(old_ns);
25151 + put_uts_ns(old_uts);
25153 + put_ipc_ns(old_ipc);
25154 +#ifdef CONFIG_PID_NS
25156 + put_pid_ns(old_pid);
25158 +#ifdef CONFIG_NET_NS
25160 + put_net(old_net);
25168 + * merge two nsproxy structs into a new one.
25169 + * will hold a reference on the result.
25173 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25174 + struct nsproxy *proxy, unsigned long mask)
25176 + struct nsproxy null_proxy = { .mnt_ns = NULL };
25182 + /* vs_mix_nsproxy returns with reference */
25183 + return vs_mix_nsproxy(old ? old : &null_proxy,
25186 + get_nsproxy(proxy);
25191 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25193 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
25194 + struct fs_struct *fs_cur, *fs = NULL;
25195 + int ret, kill = 0;
25197 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25198 + vxi, vxi->vx_id, mask, index);
25200 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25204 + mask = vxi->vx_nsmask[index];
25206 + if ((mask & vxi->vx_nsmask[index]) != mask)
25209 + if (mask & CLONE_FS) {
25210 + fs = copy_fs_struct(vxi->vx_fs[index]);
25214 + proxy = vxi->vx_nsproxy[index];
25216 + vxdprintk(VXD_CBIT(space, 9),
25217 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25218 + vxi, vxi->vx_id, mask, index, proxy, fs);
25220 + task_lock(current);
25221 + fs_cur = current->fs;
25223 + if (mask & CLONE_FS) {
25224 + write_lock(&fs_cur->lock);
25225 + current->fs = fs;
25226 + kill = !--fs_cur->users;
25227 + write_unlock(&fs_cur->lock);
25230 + proxy_cur = current->nsproxy;
25231 + get_nsproxy(proxy_cur);
25232 + task_unlock(current);
25235 + free_fs_struct(fs_cur);
25237 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25238 + if (IS_ERR(proxy_new)) {
25239 + ret = PTR_ERR(proxy_new);
25243 + proxy_new = xchg(¤t->nsproxy, proxy_new);
25247 + put_nsproxy(proxy_new);
25250 + put_nsproxy(proxy_cur);
25255 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25257 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25258 + struct fs_struct *fs_vxi, *fs;
25259 + int ret, kill = 0;
25261 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25262 + vxi, vxi->vx_id, mask, index);
25265 + mask = default_space_mask.mask;
25267 + if ((mask & space_mask.mask) != mask)
25270 + proxy_vxi = vxi->vx_nsproxy[index];
25271 + fs_vxi = vxi->vx_fs[index];
25273 + if (mask & CLONE_FS) {
25274 + fs = copy_fs_struct(current->fs);
25279 + task_lock(current);
25281 + if (mask & CLONE_FS) {
25282 + write_lock(&fs_vxi->lock);
25283 + vxi->vx_fs[index] = fs;
25284 + kill = !--fs_vxi->users;
25285 + write_unlock(&fs_vxi->lock);
25288 + proxy_cur = current->nsproxy;
25289 + get_nsproxy(proxy_cur);
25290 + task_unlock(current);
25293 + free_fs_struct(fs_vxi);
25295 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25296 + if (IS_ERR(proxy_new)) {
25297 + ret = PTR_ERR(proxy_new);
25301 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25302 + vxi->vx_nsmask[index] |= mask;
25306 + put_nsproxy(proxy_new);
25309 + put_nsproxy(proxy_cur);
25314 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25316 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25318 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25321 + return vx_enter_space(vxi, vc_data.mask, 0);
25324 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25326 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25328 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25331 + if (vc_data.index >= VX_SPACES)
25334 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25337 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25339 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25341 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25344 + return vx_set_space(vxi, vc_data.mask, 0);
25347 +int vc_set_space(struct vx_info *vxi, void __user *data)
25349 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25351 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25354 + if (vc_data.index >= VX_SPACES)
25357 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
25360 +int vc_get_space_mask(void __user *data, int type)
25362 + const struct vcmd_space_mask_v1 *mask;
25365 + mask = &space_mask_v0;
25366 + else if (type == 1)
25367 + mask = &space_mask;
25369 + mask = &default_space_mask;
25371 + vxdprintk(VXD_CBIT(space, 10),
25372 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25374 + if (copy_to_user(data, mask, sizeof(*mask)))
25379 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/switch.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/switch.c
25380 --- linux-2.6.32.10/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25381 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/switch.c 2009-12-03 20:04:56.000000000 +0100
25384 + * linux/kernel/vserver/switch.c
25386 + * Virtual Server: Syscall Switch
25388 + * Copyright (C) 2003-2007 Herbert Pötzl
25390 + * V0.01 syscall switch
25391 + * V0.02 added signal to context
25392 + * V0.03 added rlimit functions
25393 + * V0.04 added iattr, task/xid functions
25394 + * V0.05 added debug/history stuff
25395 + * V0.06 added compat32 layer
25396 + * V0.07 vcmd args and perms
25397 + * V0.08 added status commands
25398 + * V0.09 added tag commands
25399 + * V0.10 added oom bias
25400 + * V0.11 added device commands
25404 +#include <linux/vs_context.h>
25405 +#include <linux/vs_network.h>
25406 +#include <linux/vserver/switch.h>
25408 +#include "vci_config.h"
25412 +int vc_get_version(uint32_t id)
25414 + return VCI_VERSION;
25418 +int vc_get_vci(uint32_t id)
25420 + return vci_kernel_config();
25423 +#include <linux/vserver/context_cmd.h>
25424 +#include <linux/vserver/cvirt_cmd.h>
25425 +#include <linux/vserver/cacct_cmd.h>
25426 +#include <linux/vserver/limit_cmd.h>
25427 +#include <linux/vserver/network_cmd.h>
25428 +#include <linux/vserver/sched_cmd.h>
25429 +#include <linux/vserver/debug_cmd.h>
25430 +#include <linux/vserver/inode_cmd.h>
25431 +#include <linux/vserver/dlimit_cmd.h>
25432 +#include <linux/vserver/signal_cmd.h>
25433 +#include <linux/vserver/space_cmd.h>
25434 +#include <linux/vserver/tag_cmd.h>
25435 +#include <linux/vserver/device_cmd.h>
25437 +#include <linux/vserver/inode.h>
25438 +#include <linux/vserver/dlimit.h>
25441 +#ifdef CONFIG_COMPAT
25442 +#define __COMPAT(name, id, data, compat) \
25443 + (compat) ? name ## _x32(id, data) : name(id, data)
25444 +#define __COMPAT_NO_ID(name, data, compat) \
25445 + (compat) ? name ## _x32(data) : name(data)
25447 +#define __COMPAT(name, id, data, compat) \
25449 +#define __COMPAT_NO_ID(name, data, compat) \
25455 +long do_vcmd(uint32_t cmd, uint32_t id,
25456 + struct vx_info *vxi, struct nx_info *nxi,
25457 + void __user *data, int compat)
25461 + case VCMD_get_version:
25462 + return vc_get_version(id);
25463 + case VCMD_get_vci:
25464 + return vc_get_vci(id);
25466 + case VCMD_task_xid:
25467 + return vc_task_xid(id);
25468 + case VCMD_vx_info:
25469 + return vc_vx_info(vxi, data);
25471 + case VCMD_task_nid:
25472 + return vc_task_nid(id);
25473 + case VCMD_nx_info:
25474 + return vc_nx_info(nxi, data);
25476 + case VCMD_task_tag:
25477 + return vc_task_tag(id);
25479 + case VCMD_set_space_v1:
25480 + return vc_set_space_v1(vxi, data);
25481 + /* this is version 2 */
25482 + case VCMD_set_space:
25483 + return vc_set_space(vxi, data);
25485 + case VCMD_get_space_mask_v0:
25486 + return vc_get_space_mask(data, 0);
25487 + /* this is version 1 */
25488 + case VCMD_get_space_mask:
25489 + return vc_get_space_mask(data, 1);
25491 + case VCMD_get_space_default:
25492 + return vc_get_space_mask(data, -1);
25494 +#ifdef CONFIG_IA32_EMULATION
25495 + case VCMD_get_rlimit:
25496 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25497 + case VCMD_set_rlimit:
25498 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25500 + case VCMD_get_rlimit:
25501 + return vc_get_rlimit(vxi, data);
25502 + case VCMD_set_rlimit:
25503 + return vc_set_rlimit(vxi, data);
25505 + case VCMD_get_rlimit_mask:
25506 + return vc_get_rlimit_mask(id, data);
25507 + case VCMD_reset_hits:
25508 + return vc_reset_hits(vxi, data);
25509 + case VCMD_reset_minmax:
25510 + return vc_reset_minmax(vxi, data);
25512 + case VCMD_get_vhi_name:
25513 + return vc_get_vhi_name(vxi, data);
25514 + case VCMD_set_vhi_name:
25515 + return vc_set_vhi_name(vxi, data);
25517 + case VCMD_ctx_stat:
25518 + return vc_ctx_stat(vxi, data);
25519 + case VCMD_virt_stat:
25520 + return vc_virt_stat(vxi, data);
25521 + case VCMD_sock_stat:
25522 + return vc_sock_stat(vxi, data);
25523 + case VCMD_rlimit_stat:
25524 + return vc_rlimit_stat(vxi, data);
25526 + case VCMD_set_cflags:
25527 + return vc_set_cflags(vxi, data);
25528 + case VCMD_get_cflags:
25529 + return vc_get_cflags(vxi, data);
25531 + /* this is version 1 */
25532 + case VCMD_set_ccaps:
25533 + return vc_set_ccaps(vxi, data);
25534 + /* this is version 1 */
25535 + case VCMD_get_ccaps:
25536 + return vc_get_ccaps(vxi, data);
25537 + case VCMD_set_bcaps:
25538 + return vc_set_bcaps(vxi, data);
25539 + case VCMD_get_bcaps:
25540 + return vc_get_bcaps(vxi, data);
25542 + case VCMD_set_badness:
25543 + return vc_set_badness(vxi, data);
25544 + case VCMD_get_badness:
25545 + return vc_get_badness(vxi, data);
25547 + case VCMD_set_nflags:
25548 + return vc_set_nflags(nxi, data);
25549 + case VCMD_get_nflags:
25550 + return vc_get_nflags(nxi, data);
25552 + case VCMD_set_ncaps:
25553 + return vc_set_ncaps(nxi, data);
25554 + case VCMD_get_ncaps:
25555 + return vc_get_ncaps(nxi, data);
25557 + case VCMD_set_sched_v4:
25558 + return vc_set_sched_v4(vxi, data);
25559 + /* this is version 5 */
25560 + case VCMD_set_sched:
25561 + return vc_set_sched(vxi, data);
25562 + case VCMD_get_sched:
25563 + return vc_get_sched(vxi, data);
25564 + case VCMD_sched_info:
25565 + return vc_sched_info(vxi, data);
25567 + case VCMD_add_dlimit:
25568 + return __COMPAT(vc_add_dlimit, id, data, compat);
25569 + case VCMD_rem_dlimit:
25570 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25571 + case VCMD_set_dlimit:
25572 + return __COMPAT(vc_set_dlimit, id, data, compat);
25573 + case VCMD_get_dlimit:
25574 + return __COMPAT(vc_get_dlimit, id, data, compat);
25576 + case VCMD_ctx_kill:
25577 + return vc_ctx_kill(vxi, data);
25579 + case VCMD_wait_exit:
25580 + return vc_wait_exit(vxi, data);
25582 + case VCMD_get_iattr:
25583 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25584 + case VCMD_set_iattr:
25585 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25587 + case VCMD_fget_iattr:
25588 + return vc_fget_iattr(id, data);
25589 + case VCMD_fset_iattr:
25590 + return vc_fset_iattr(id, data);
25592 + case VCMD_enter_space_v0:
25593 + return vc_enter_space_v1(vxi, NULL);
25594 + case VCMD_enter_space_v1:
25595 + return vc_enter_space_v1(vxi, data);
25596 + /* this is version 2 */
25597 + case VCMD_enter_space:
25598 + return vc_enter_space(vxi, data);
25600 + case VCMD_ctx_create_v0:
25601 + return vc_ctx_create(id, NULL);
25602 + case VCMD_ctx_create:
25603 + return vc_ctx_create(id, data);
25604 + case VCMD_ctx_migrate_v0:
25605 + return vc_ctx_migrate(vxi, NULL);
25606 + case VCMD_ctx_migrate:
25607 + return vc_ctx_migrate(vxi, data);
25609 + case VCMD_net_create_v0:
25610 + return vc_net_create(id, NULL);
25611 + case VCMD_net_create:
25612 + return vc_net_create(id, data);
25613 + case VCMD_net_migrate:
25614 + return vc_net_migrate(nxi, data);
25616 + case VCMD_tag_migrate:
25617 + return vc_tag_migrate(id);
25619 + case VCMD_net_add:
25620 + return vc_net_add(nxi, data);
25621 + case VCMD_net_remove:
25622 + return vc_net_remove(nxi, data);
25624 + case VCMD_net_add_ipv4:
25625 + return vc_net_add_ipv4(nxi, data);
25626 + case VCMD_net_remove_ipv4:
25627 + return vc_net_remove_ipv4(nxi, data);
25628 +#ifdef CONFIG_IPV6
25629 + case VCMD_net_add_ipv6:
25630 + return vc_net_add_ipv6(nxi, data);
25631 + case VCMD_net_remove_ipv6:
25632 + return vc_net_remove_ipv6(nxi, data);
25634 +/* case VCMD_add_match_ipv4:
25635 + return vc_add_match_ipv4(nxi, data);
25636 + case VCMD_get_match_ipv4:
25637 + return vc_get_match_ipv4(nxi, data);
25638 +#ifdef CONFIG_IPV6
25639 + case VCMD_add_match_ipv6:
25640 + return vc_add_match_ipv6(nxi, data);
25641 + case VCMD_get_match_ipv6:
25642 + return vc_get_match_ipv6(nxi, data);
25645 +#ifdef CONFIG_VSERVER_DEVICE
25646 + case VCMD_set_mapping:
25647 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25648 + case VCMD_unset_mapping:
25649 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25651 +#ifdef CONFIG_VSERVER_HISTORY
25652 + case VCMD_dump_history:
25653 + return vc_dump_history(id);
25654 + case VCMD_read_history:
25655 + return __COMPAT(vc_read_history, id, data, compat);
25657 +#ifdef CONFIG_VSERVER_MONITOR
25658 + case VCMD_read_monitor:
25659 + return __COMPAT(vc_read_monitor, id, data, compat);
25662 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25663 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25669 +#define __VCMD(vcmd, _perm, _args, _flags) \
25670 + case VCMD_ ## vcmd: perm = _perm; \
25671 + args = _args; flags = _flags; break
25674 +#define VCA_NONE 0x00
25675 +#define VCA_VXI 0x01
25676 +#define VCA_NXI 0x02
25678 +#define VCF_NONE 0x00
25679 +#define VCF_INFO 0x01
25680 +#define VCF_ADMIN 0x02
25681 +#define VCF_ARES 0x06 /* includes admin */
25682 +#define VCF_SETUP 0x08
25684 +#define VCF_ZIDOK 0x10 /* zero id okay */
25688 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25691 + int permit = -1, state = 0;
25692 + int perm = -1, args = 0, flags = 0;
25693 + struct vx_info *vxi = NULL;
25694 + struct nx_info *nxi = NULL;
25697 + /* unpriviledged commands */
25698 + __VCMD(get_version, 0, VCA_NONE, 0);
25699 + __VCMD(get_vci, 0, VCA_NONE, 0);
25700 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25701 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25702 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25703 + __VCMD(get_space_default,0, VCA_NONE, 0);
25705 + /* info commands */
25706 + __VCMD(task_xid, 2, VCA_NONE, 0);
25707 + __VCMD(reset_hits, 2, VCA_VXI, 0);
25708 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25709 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25710 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25711 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25712 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25713 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25714 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25715 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25717 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25718 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25719 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25720 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25722 + __VCMD(task_nid, 2, VCA_NONE, 0);
25723 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25724 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25725 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25727 + __VCMD(task_tag, 2, VCA_NONE, 0);
25729 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25730 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25731 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25732 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25733 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25735 + /* lower admin commands */
25736 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25737 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25738 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25739 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25740 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25741 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25742 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25743 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25745 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25746 + __VCMD(net_create, 5, VCA_NONE, 0);
25747 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25749 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25751 + /* higher admin commands */
25752 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25753 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25754 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25756 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25757 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25758 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25759 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25761 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25762 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25763 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25764 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25766 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25767 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25768 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25769 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25770 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25771 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25772 +#ifdef CONFIG_IPV6
25773 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25774 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25776 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25777 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25778 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25779 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25780 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25782 +#ifdef CONFIG_VSERVER_DEVICE
25783 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25784 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25786 + /* debug level admin commands */
25787 +#ifdef CONFIG_VSERVER_HISTORY
25788 + __VCMD(dump_history, 9, VCA_NONE, 0);
25789 + __VCMD(read_history, 9, VCA_NONE, 0);
25791 +#ifdef CONFIG_VSERVER_MONITOR
25792 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25799 + vxdprintk(VXD_CBIT(switch, 0),
25800 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25801 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25802 + VC_VERSION(cmd), id, data, compat,
25803 + perm, args, flags);
25810 + if (!capable(CAP_CONTEXT))
25814 + /* moved here from the individual commands */
25816 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25820 + /* vcmd involves resource management */
25822 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25826 + /* various legacy exceptions */
25828 + /* will go away when spectator is a cap */
25829 + case VCMD_ctx_migrate_v0:
25830 + case VCMD_ctx_migrate:
25832 + current->xid = 1;
25838 + /* will go away when spectator is a cap */
25839 + case VCMD_net_migrate:
25841 + current->nid = 1;
25848 + /* vcmds are fine by default */
25851 + /* admin type vcmds require admin ... */
25852 + if (flags & VCF_ADMIN)
25853 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25855 + /* ... but setup type vcmds override that */
25856 + if (!permit && (flags & VCF_SETUP))
25857 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25865 + if (!id && (flags & VCF_ZIDOK))
25869 + if (args & VCA_VXI) {
25870 + vxi = lookup_vx_info(id);
25874 + if ((flags & VCF_ADMIN) &&
25875 + /* special case kill for shutdown */
25876 + (cmd != VCMD_ctx_kill) &&
25877 + /* can context be administrated? */
25878 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25884 + if (args & VCA_NXI) {
25885 + nxi = lookup_nx_info(id);
25889 + if ((flags & VCF_ADMIN) &&
25890 + /* can context be administrated? */
25891 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25898 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25901 + if ((args & VCA_NXI) && nxi)
25902 + put_nx_info(nxi);
25904 + if ((args & VCA_VXI) && vxi)
25905 + put_vx_info(vxi);
25907 + vxdprintk(VXD_CBIT(switch, 1),
25908 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25909 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25910 + VC_VERSION(cmd), ret, ret, state, permit);
25915 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25917 + return do_vserver(cmd, id, data, 0);
25920 +#ifdef CONFIG_COMPAT
25923 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25925 + return do_vserver(cmd, id, data, 1);
25928 +#endif /* CONFIG_COMPAT */
25929 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/sysctl.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sysctl.c
25930 --- linux-2.6.32.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25931 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/sysctl.c 2010-01-13 15:21:01.000000000 +0100
25934 + * kernel/vserver/sysctl.c
25936 + * Virtual Context Support
25938 + * Copyright (C) 2004-2007 Herbert Pötzl
25940 + * V0.01 basic structure
25944 +#include <linux/module.h>
25945 +#include <linux/ctype.h>
25946 +#include <linux/sysctl.h>
25947 +#include <linux/parser.h>
25948 +#include <asm/uaccess.h>
25952 + CTL_DEBUG_ERROR = 0,
25953 + CTL_DEBUG_SWITCH = 1,
25968 +unsigned int vx_debug_switch = 0;
25969 +unsigned int vx_debug_xid = 0;
25970 +unsigned int vx_debug_nid = 0;
25971 +unsigned int vx_debug_tag = 0;
25972 +unsigned int vx_debug_net = 0;
25973 +unsigned int vx_debug_limit = 0;
25974 +unsigned int vx_debug_cres = 0;
25975 +unsigned int vx_debug_dlim = 0;
25976 +unsigned int vx_debug_quota = 0;
25977 +unsigned int vx_debug_cvirt = 0;
25978 +unsigned int vx_debug_space = 0;
25979 +unsigned int vx_debug_misc = 0;
25982 +static struct ctl_table_header *vserver_table_header;
25983 +static ctl_table vserver_root_table[];
25986 +void vserver_register_sysctl(void)
25988 + if (!vserver_table_header) {
25989 + vserver_table_header = register_sysctl_table(vserver_root_table);
25994 +void vserver_unregister_sysctl(void)
25996 + if (vserver_table_header) {
25997 + unregister_sysctl_table(vserver_table_header);
25998 + vserver_table_header = NULL;
26003 +static int proc_dodebug(ctl_table *table, int write,
26004 + void __user *buffer, size_t *lenp, loff_t *ppos)
26006 + char tmpbuf[20], *p, c;
26007 + unsigned int value;
26008 + size_t left, len;
26010 + if ((*ppos && !write) || !*lenp) {
26018 + if (!access_ok(VERIFY_READ, buffer, left))
26020 + p = (char *)buffer;
26021 + while (left && __get_user(c, p) >= 0 && isspace(c))
26026 + if (left > sizeof(tmpbuf) - 1)
26028 + if (copy_from_user(tmpbuf, p, left))
26030 + tmpbuf[left] = '\0';
26032 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
26033 + value = 10 * value + (*p - '0');
26034 + if (*p && !isspace(*p))
26036 + while (left && isspace(*p))
26038 + *(unsigned int *)table->data = value;
26040 + if (!access_ok(VERIFY_WRITE, buffer, left))
26042 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
26045 + if (__copy_to_user(buffer, tmpbuf, len))
26047 + if ((left -= len) > 0) {
26048 + if (put_user('\n', (char *)buffer + len))
26062 +#define CTL_ENTRY(ctl, name) \
26064 + .ctl_name = ctl, \
26065 + .procname = #name, \
26066 + .data = &vx_ ## name, \
26067 + .maxlen = sizeof(int), \
26069 + .proc_handler = &proc_dodebug, \
26070 + .strategy = &sysctl_intvec, \
26071 + .extra1 = &zero, \
26072 + .extra2 = &zero, \
26075 +static ctl_table vserver_debug_table[] = {
26076 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
26077 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
26078 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
26079 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
26080 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
26081 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
26082 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
26083 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
26084 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
26085 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
26086 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
26087 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
26088 + { .ctl_name = 0 }
26091 +static ctl_table vserver_root_table[] = {
26093 + .ctl_name = CTL_VSERVER,
26094 + .procname = "vserver",
26096 + .child = vserver_debug_table
26098 + { .ctl_name = 0 }
26102 +static match_table_t tokens = {
26103 + { CTL_DEBUG_SWITCH, "switch=%x" },
26104 + { CTL_DEBUG_XID, "xid=%x" },
26105 + { CTL_DEBUG_NID, "nid=%x" },
26106 + { CTL_DEBUG_TAG, "tag=%x" },
26107 + { CTL_DEBUG_NET, "net=%x" },
26108 + { CTL_DEBUG_LIMIT, "limit=%x" },
26109 + { CTL_DEBUG_CRES, "cres=%x" },
26110 + { CTL_DEBUG_DLIM, "dlim=%x" },
26111 + { CTL_DEBUG_QUOTA, "quota=%x" },
26112 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
26113 + { CTL_DEBUG_SPACE, "space=%x" },
26114 + { CTL_DEBUG_MISC, "misc=%x" },
26115 + { CTL_DEBUG_ERROR, NULL }
26118 +#define HANDLE_CASE(id, name, val) \
26119 + case CTL_DEBUG_ ## id: \
26120 + vx_debug_ ## name = val; \
26121 + printk("vs_debug_" #name "=0x%x\n", val); \
26125 +static int __init vs_debug_setup(char *str)
26130 + printk("vs_debug_setup(%s)\n", str);
26131 + while ((p = strsep(&str, ",")) != NULL) {
26132 + substring_t args[MAX_OPT_ARGS];
26133 + unsigned int value;
26138 + token = match_token(p, tokens, args);
26139 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26142 + HANDLE_CASE(SWITCH, switch, value);
26143 + HANDLE_CASE(XID, xid, value);
26144 + HANDLE_CASE(NID, nid, value);
26145 + HANDLE_CASE(TAG, tag, value);
26146 + HANDLE_CASE(NET, net, value);
26147 + HANDLE_CASE(LIMIT, limit, value);
26148 + HANDLE_CASE(CRES, cres, value);
26149 + HANDLE_CASE(DLIM, dlim, value);
26150 + HANDLE_CASE(QUOTA, quota, value);
26151 + HANDLE_CASE(CVIRT, cvirt, value);
26152 + HANDLE_CASE(SPACE, space, value);
26153 + HANDLE_CASE(MISC, misc, value);
26162 +__setup("vsdebug=", vs_debug_setup);
26166 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26167 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26168 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26169 +EXPORT_SYMBOL_GPL(vx_debug_net);
26170 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26171 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26172 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26173 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26174 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26175 +EXPORT_SYMBOL_GPL(vx_debug_space);
26176 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26178 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/tag.c linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/tag.c
26179 --- linux-2.6.32.10/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26180 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/tag.c 2009-12-03 20:04:56.000000000 +0100
26183 + * linux/kernel/vserver/tag.c
26185 + * Virtual Server: Shallow Tag Space
26187 + * Copyright (C) 2007 Herbert Pötzl
26189 + * V0.01 basic implementation
26193 +#include <linux/sched.h>
26194 +#include <linux/vserver/debug.h>
26195 +#include <linux/vs_pid.h>
26196 +#include <linux/vs_tag.h>
26198 +#include <linux/vserver/tag_cmd.h>
26201 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26206 + vxdprintk(VXD_CBIT(tag, 5),
26207 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26213 + vxdprintk(VXD_CBIT(tag, 5),
26214 + "moved task %p into [#%d]", p, tag);
26218 +/* vserver syscall commands below here */
26220 +/* taks xid and vx_info functions */
26223 +int vc_task_tag(uint32_t id)
26228 + struct task_struct *tsk;
26229 + read_lock(&tasklist_lock);
26230 + tsk = find_task_by_real_pid(id);
26231 + tag = (tsk) ? tsk->tag : -ESRCH;
26232 + read_unlock(&tasklist_lock);
26234 + tag = dx_current_tag();
26239 +int vc_tag_migrate(uint32_t tag)
26241 + return dx_migrate_task(current, tag & 0xFFFF);
26245 diff -NurpP --minimal linux-2.6.32.10/kernel/vserver/vci_config.h linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/vci_config.h
26246 --- linux-2.6.32.10/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
26247 +++ linux-2.6.32.10-vs2.3.0.36.29.2/kernel/vserver/vci_config.h 2009-12-03 20:04:56.000000000 +0100
26250 +/* interface version */
26252 +#define VCI_VERSION 0x00020305
26256 + VCI_KCBIT_NO_DYNAMIC = 0,
26258 + VCI_KCBIT_PROC_SECURE = 4,
26259 + VCI_KCBIT_HARDCPU = 5,
26260 + VCI_KCBIT_IDLELIMIT = 6,
26261 + VCI_KCBIT_IDLETIME = 7,
26263 + VCI_KCBIT_COWBL = 8,
26264 + VCI_KCBIT_FULLCOWBL = 9,
26265 + VCI_KCBIT_SPACES = 10,
26266 + VCI_KCBIT_NETV2 = 11,
26268 + VCI_KCBIT_DEBUG = 16,
26269 + VCI_KCBIT_HISTORY = 20,
26270 + VCI_KCBIT_TAGGED = 24,
26271 + VCI_KCBIT_PPTAG = 28,
26273 + VCI_KCBIT_MORE = 31,
26277 +static inline uint32_t vci_kernel_config(void)
26280 + (1 << VCI_KCBIT_NO_DYNAMIC) |
26282 + /* configured features */
26283 +#ifdef CONFIG_VSERVER_PROC_SECURE
26284 + (1 << VCI_KCBIT_PROC_SECURE) |
26286 +#ifdef CONFIG_VSERVER_HARDCPU
26287 + (1 << VCI_KCBIT_HARDCPU) |
26289 +#ifdef CONFIG_VSERVER_IDLELIMIT
26290 + (1 << VCI_KCBIT_IDLELIMIT) |
26292 +#ifdef CONFIG_VSERVER_IDLETIME
26293 + (1 << VCI_KCBIT_IDLETIME) |
26295 +#ifdef CONFIG_VSERVER_COWBL
26296 + (1 << VCI_KCBIT_COWBL) |
26297 + (1 << VCI_KCBIT_FULLCOWBL) |
26299 + (1 << VCI_KCBIT_SPACES) |
26300 + (1 << VCI_KCBIT_NETV2) |
26302 + /* debug options */
26303 +#ifdef CONFIG_VSERVER_DEBUG
26304 + (1 << VCI_KCBIT_DEBUG) |
26306 +#ifdef CONFIG_VSERVER_HISTORY
26307 + (1 << VCI_KCBIT_HISTORY) |
26310 + /* inode context tagging */
26311 +#if defined(CONFIG_TAGGING_NONE)
26312 + (0 << VCI_KCBIT_TAGGED) |
26313 +#elif defined(CONFIG_TAGGING_UID16)
26314 + (1 << VCI_KCBIT_TAGGED) |
26315 +#elif defined(CONFIG_TAGGING_GID16)
26316 + (2 << VCI_KCBIT_TAGGED) |
26317 +#elif defined(CONFIG_TAGGING_ID24)
26318 + (3 << VCI_KCBIT_TAGGED) |
26319 +#elif defined(CONFIG_TAGGING_INTERN)
26320 + (4 << VCI_KCBIT_TAGGED) |
26321 +#elif defined(CONFIG_TAGGING_RUNTIME)
26322 + (5 << VCI_KCBIT_TAGGED) |
26324 + (7 << VCI_KCBIT_TAGGED) |
26326 + (1 << VCI_KCBIT_PPTAG) |
26330 diff -NurpP --minimal linux-2.6.32.10/mm/allocpercpu.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/allocpercpu.c
26331 --- linux-2.6.32.10/mm/allocpercpu.c 2009-12-03 20:02:58.000000000 +0100
26332 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/allocpercpu.c 2009-12-03 20:04:56.000000000 +0100
26333 @@ -160,12 +160,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
26335 void __init setup_per_cpu_areas(void)
26337 - unsigned long size, i;
26338 + unsigned long size, vspc, i;
26340 unsigned long nr_possible_cpus = num_possible_cpus();
26342 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
26344 /* Copy section for each CPU (we discard the original) */
26345 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
26346 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
26347 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
26349 for_each_possible_cpu(i) {
26350 diff -NurpP --minimal linux-2.6.32.10/mm/filemap_xip.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/filemap_xip.c
26351 --- linux-2.6.32.10/mm/filemap_xip.c 2009-12-03 20:02:58.000000000 +0100
26352 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/filemap_xip.c 2009-12-03 20:04:56.000000000 +0100
26354 #include <linux/sched.h>
26355 #include <linux/seqlock.h>
26356 #include <linux/mutex.h>
26357 +#include <linux/vs_memory.h>
26358 #include <asm/tlbflush.h>
26359 #include <asm/io.h>
26361 diff -NurpP --minimal linux-2.6.32.10/mm/fremap.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/fremap.c
26362 --- linux-2.6.32.10/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
26363 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/fremap.c 2009-12-03 20:04:56.000000000 +0100
26365 #include <linux/module.h>
26366 #include <linux/syscalls.h>
26367 #include <linux/mmu_notifier.h>
26368 +#include <linux/vs_memory.h>
26370 #include <asm/mmu_context.h>
26371 #include <asm/cacheflush.h>
26372 diff -NurpP --minimal linux-2.6.32.10/mm/hugetlb.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/hugetlb.c
26373 --- linux-2.6.32.10/mm/hugetlb.c 2009-12-03 20:02:58.000000000 +0100
26374 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/hugetlb.c 2009-12-03 20:04:56.000000000 +0100
26376 #include <asm/io.h>
26378 #include <linux/hugetlb.h>
26379 +#include <linux/vs_memory.h>
26380 #include "internal.h"
26382 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26383 diff -NurpP --minimal linux-2.6.32.10/mm/memcontrol.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/memcontrol.c
26384 --- linux-2.6.32.10/mm/memcontrol.c 2010-03-18 16:17:38.000000000 +0100
26385 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/memcontrol.c 2010-02-05 02:26:48.000000000 +0100
26386 @@ -549,6 +549,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26387 struct mem_cgroup, css);
26390 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26392 + return res_counter_read_u64(&mem->res, member);
26395 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26397 + return res_counter_read_u64(&mem->memsw, member);
26400 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26402 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
26405 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26407 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
26410 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26412 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_MAPPED_FILE);
26415 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26417 struct mem_cgroup *mem = NULL;
26418 diff -NurpP --minimal linux-2.6.32.10/mm/memory.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/memory.c
26419 --- linux-2.6.32.10/mm/memory.c 2010-03-18 16:17:38.000000000 +0100
26420 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/memory.c 2009-12-30 00:58:19.000000000 +0100
26422 #include <linux/kallsyms.h>
26423 #include <linux/swapops.h>
26424 #include <linux/elf.h>
26425 +// #include <linux/vs_memory.h>
26427 #include <asm/io.h>
26428 #include <asm/pgalloc.h>
26429 @@ -647,6 +648,9 @@ static int copy_pte_range(struct mm_stru
26433 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26437 rss[1] = rss[0] = 0;
26438 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26439 @@ -2645,6 +2649,8 @@ static int do_anonymous_page(struct mm_s
26440 /* Allocate our own private page. */
26441 pte_unmap(page_table);
26443 + if (!vx_rss_avail(mm, 1))
26445 if (unlikely(anon_vma_prepare(vma)))
26447 page = alloc_zeroed_user_highpage_movable(vma, address);
26448 @@ -2936,6 +2942,7 @@ static inline int handle_pte_fault(struc
26452 + int ret = 0, type = VXPT_UNKNOWN;
26455 if (!pte_present(entry)) {
26456 @@ -2960,9 +2967,12 @@ static inline int handle_pte_fault(struc
26457 if (unlikely(!pte_same(*pte, entry)))
26459 if (flags & FAULT_FLAG_WRITE) {
26460 - if (!pte_write(entry))
26461 - return do_wp_page(mm, vma, address,
26462 + if (!pte_write(entry)) {
26463 + ret = do_wp_page(mm, vma, address,
26464 pte, pmd, ptl, entry);
26465 + type = VXPT_WRITE;
26468 entry = pte_mkdirty(entry);
26470 entry = pte_mkyoung(entry);
26471 @@ -2980,7 +2990,10 @@ static inline int handle_pte_fault(struc
26474 pte_unmap_unlock(pte, ptl);
26478 + vx_page_fault(mm, vma, type, ret);
26483 diff -NurpP --minimal linux-2.6.32.10/mm/mlock.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/mlock.c
26484 --- linux-2.6.32.10/mm/mlock.c 2010-03-18 16:17:38.000000000 +0100
26485 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/mlock.c 2010-01-13 14:33:47.000000000 +0100
26487 #include <linux/rmap.h>
26488 #include <linux/mmzone.h>
26489 #include <linux/hugetlb.h>
26490 +#include <linux/vs_memory.h>
26492 #include "internal.h"
26494 @@ -401,7 +402,7 @@ success:
26495 nr_pages = (end - start) >> PAGE_SHIFT;
26497 nr_pages = -nr_pages;
26498 - mm->locked_vm += nr_pages;
26499 + vx_vmlocked_add(mm, nr_pages);
26502 * vm_flags is protected by the mmap_sem held in write mode.
26503 @@ -474,7 +475,7 @@ static int do_mlock(unsigned long start,
26505 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26507 - unsigned long locked;
26508 + unsigned long locked, grow;
26509 unsigned long lock_limit;
26510 int error = -ENOMEM;
26512 @@ -487,8 +488,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26513 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26514 start &= PAGE_MASK;
26516 - locked = len >> PAGE_SHIFT;
26517 - locked += current->mm->locked_vm;
26518 + grow = len >> PAGE_SHIFT;
26519 + if (!vx_vmlocked_avail(current->mm, grow))
26521 + locked = current->mm->locked_vm + grow;
26523 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26524 lock_limit >>= PAGE_SHIFT;
26525 @@ -496,6 +499,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26526 /* check against resource limits */
26527 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26528 error = do_mlock(start, len, 1);
26530 up_write(¤t->mm->mmap_sem);
26533 @@ -557,6 +561,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
26534 lock_limit >>= PAGE_SHIFT;
26537 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26539 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26540 capable(CAP_IPC_LOCK))
26541 ret = do_mlockall(flags);
26542 @@ -631,8 +637,10 @@ int account_locked_memory(struct mm_stru
26546 - mm->total_vm += pgsz;
26547 - mm->locked_vm += pgsz;
26548 + // mm->total_vm += pgsz;
26549 + vx_vmpages_add(mm, pgsz);
26550 + // mm->locked_vm += pgsz;
26551 + vx_vmlocked_add(mm, pgsz);
26555 @@ -646,8 +654,10 @@ void refund_locked_memory(struct mm_stru
26557 down_write(&mm->mmap_sem);
26559 - mm->total_vm -= pgsz;
26560 - mm->locked_vm -= pgsz;
26561 + // mm->total_vm -= pgsz;
26562 + vx_vmpages_sub(mm, pgsz);
26563 + // mm->locked_vm -= pgsz;
26564 + vx_vmlocked_sub(mm, pgsz);
26566 up_write(&mm->mmap_sem);
26568 diff -NurpP --minimal linux-2.6.32.10/mm/mmap.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/mmap.c
26569 --- linux-2.6.32.10/mm/mmap.c 2010-03-18 16:17:38.000000000 +0100
26570 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/mmap.c 2010-01-20 04:21:33.000000000 +0100
26571 @@ -1214,7 +1214,8 @@ munmap_back:
26573 perf_event_mmap(vma);
26575 - mm->total_vm += len >> PAGE_SHIFT;
26576 + // mm->total_vm += len >> PAGE_SHIFT;
26577 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26578 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26579 if (vm_flags & VM_LOCKED) {
26581 @@ -1223,7 +1224,8 @@ out:
26582 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
26584 return nr_pages; /* vma gone! */
26585 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
26586 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
26587 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
26588 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
26589 make_pages_present(addr, addr + len);
26591 @@ -1578,9 +1580,9 @@ static int acct_stack_growth(struct vm_a
26594 /* Ok, everything looks good - let it rip */
26595 - mm->total_vm += grow;
26596 + vx_vmpages_add(mm, grow);
26597 if (vma->vm_flags & VM_LOCKED)
26598 - mm->locked_vm += grow;
26599 + vx_vmlocked_add(mm, grow);
26600 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26603 @@ -1755,7 +1757,8 @@ static void remove_vma_list(struct mm_st
26605 long nrpages = vma_pages(vma);
26607 - mm->total_vm -= nrpages;
26608 + // mm->total_vm -= nrpages;
26609 + vx_vmpages_sub(mm, nrpages);
26610 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26611 vma = remove_vma(vma);
26613 @@ -1927,7 +1930,8 @@ int do_munmap(struct mm_struct *mm, unsi
26614 struct vm_area_struct *tmp = vma;
26615 while (tmp && tmp->vm_start < end) {
26616 if (tmp->vm_flags & VM_LOCKED) {
26617 - mm->locked_vm -= vma_pages(tmp);
26618 + // mm->locked_vm -= vma_pages(tmp);
26619 + vx_vmlocked_sub(mm, vma_pages(tmp));
26620 munlock_vma_pages_all(tmp);
26622 tmp = tmp->vm_next;
26623 @@ -2010,6 +2014,8 @@ unsigned long do_brk(unsigned long addr,
26624 lock_limit >>= PAGE_SHIFT;
26625 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26627 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26632 @@ -2036,7 +2042,8 @@ unsigned long do_brk(unsigned long addr,
26633 if (mm->map_count > sysctl_max_map_count)
26636 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26637 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26638 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26641 /* Can we just expand an old private anonymous mapping? */
26642 @@ -2062,10 +2069,13 @@ unsigned long do_brk(unsigned long addr,
26643 vma->vm_page_prot = vm_get_page_prot(flags);
26644 vma_link(mm, vma, prev, rb_link, rb_parent);
26646 - mm->total_vm += len >> PAGE_SHIFT;
26647 + // mm->total_vm += len >> PAGE_SHIFT;
26648 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26650 if (flags & VM_LOCKED) {
26651 if (!mlock_vma_pages_range(vma, addr, addr + len))
26652 - mm->locked_vm += (len >> PAGE_SHIFT);
26653 + // mm->locked_vm += (len >> PAGE_SHIFT);
26654 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26658 @@ -2109,6 +2119,11 @@ void exit_mmap(struct mm_struct *mm)
26659 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
26660 tlb_finish_mmu(tlb, 0, end);
26662 + set_mm_counter(mm, file_rss, 0);
26663 + set_mm_counter(mm, anon_rss, 0);
26664 + vx_vmpages_sub(mm, mm->total_vm);
26665 + vx_vmlocked_sub(mm, mm->locked_vm);
26668 * Walk the list again, actually closing and freeing it,
26669 * with preemption enabled, without holding any MM locks.
26670 @@ -2148,7 +2163,8 @@ int insert_vm_struct(struct mm_struct *
26671 if (__vma && __vma->vm_start < vma->vm_end)
26673 if ((vma->vm_flags & VM_ACCOUNT) &&
26674 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
26675 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
26676 + !vx_vmpages_avail(mm, vma_pages(vma))))
26678 vma_link(mm, vma, prev, rb_link, rb_parent);
26680 @@ -2224,6 +2240,8 @@ int may_expand_vm(struct mm_struct *mm,
26682 if (cur + npages > lim)
26684 + if (!vx_vmpages_avail(mm, npages))
26689 @@ -2301,7 +2319,7 @@ int install_special_mapping(struct mm_st
26693 - mm->total_vm += len >> PAGE_SHIFT;
26694 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26696 perf_event_mmap(vma);
26698 diff -NurpP --minimal linux-2.6.32.10/mm/mremap.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/mremap.c
26699 --- linux-2.6.32.10/mm/mremap.c 2010-03-18 16:17:38.000000000 +0100
26700 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/mremap.c 2010-01-20 04:28:22.000000000 +0100
26702 #include <linux/security.h>
26703 #include <linux/syscalls.h>
26704 #include <linux/mmu_notifier.h>
26705 +#include <linux/vs_memory.h>
26707 #include <asm/uaccess.h>
26708 #include <asm/cacheflush.h>
26709 @@ -234,7 +235,7 @@ static unsigned long move_vma(struct vm_
26710 * If this were a serious issue, we'd add a flag to do_munmap().
26712 hiwater_vm = mm->hiwater_vm;
26713 - mm->total_vm += new_len >> PAGE_SHIFT;
26714 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26715 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26717 if (do_munmap(mm, old_addr, old_len) < 0) {
26718 @@ -252,7 +253,7 @@ static unsigned long move_vma(struct vm_
26721 if (vm_flags & VM_LOCKED) {
26722 - mm->locked_vm += new_len >> PAGE_SHIFT;
26723 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26724 if (new_len > old_len)
26725 mlock_vma_pages_range(new_vma, new_addr + old_len,
26726 new_addr + new_len);
26727 @@ -463,10 +464,12 @@ unsigned long do_mremap(unsigned long ad
26728 vma_adjust(vma, vma->vm_start,
26729 addr + new_len, vma->vm_pgoff, NULL);
26731 - mm->total_vm += pages;
26732 + // mm->total_vm += pages;
26733 + vx_vmpages_add(mm, pages);
26734 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26735 if (vma->vm_flags & VM_LOCKED) {
26736 - mm->locked_vm += pages;
26737 + // mm->locked_vm += pages;
26738 + vx_vmlocked_add(mm, pages);
26739 mlock_vma_pages_range(vma, addr + old_len,
26742 diff -NurpP --minimal linux-2.6.32.10/mm/nommu.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/nommu.c
26743 --- linux-2.6.32.10/mm/nommu.c 2009-12-03 20:02:58.000000000 +0100
26744 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/nommu.c 2009-12-03 20:04:56.000000000 +0100
26745 @@ -1346,7 +1346,7 @@ unsigned long do_mmap_pgoff(struct file
26746 /* okay... we have a mapping; now we have to register it */
26747 result = vma->vm_start;
26749 - current->mm->total_vm += len >> PAGE_SHIFT;
26750 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26753 add_vma_to_mm(current->mm, vma);
26754 @@ -1606,7 +1606,7 @@ void exit_mmap(struct mm_struct *mm)
26758 - mm->total_vm = 0;
26759 + vx_vmpages_sub(mm, mm->total_vm);
26761 while ((vma = mm->mmap)) {
26762 mm->mmap = vma->vm_next;
26763 diff -NurpP --minimal linux-2.6.32.10/mm/oom_kill.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/oom_kill.c
26764 --- linux-2.6.32.10/mm/oom_kill.c 2010-03-18 16:17:38.000000000 +0100
26765 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/oom_kill.c 2010-03-18 16:53:06.000000000 +0100
26767 #include <linux/notifier.h>
26768 #include <linux/memcontrol.h>
26769 #include <linux/security.h>
26770 +#include <linux/reboot.h>
26771 +#include <linux/vs_memory.h>
26772 +#include <linux/vs_context.h>
26774 int sysctl_panic_on_oom;
26775 int sysctl_oom_kill_allocating_task;
26776 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
26777 points >>= -(oom_adj);
26781 + * add points for context badness and
26782 + * reduce badness for processes belonging to
26783 + * a different context
26786 + points += vx_badness(p, mm);
26788 + if ((vx_current_xid() > 1) &&
26789 + vx_current_xid() != vx_task_xid(p))
26793 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26794 - p->pid, p->comm, points);
26795 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26796 + task_pid_nr(p), p->xid, p->comm, points);
26800 @@ -230,6 +245,7 @@ static struct task_struct *select_bad_pr
26801 struct task_struct *p;
26802 struct task_struct *chosen = NULL;
26803 struct timespec uptime;
26804 + unsigned xid = vx_current_xid();
26807 do_posix_clock_monotonic_gettime(&uptime);
26808 @@ -242,11 +258,14 @@ static struct task_struct *select_bad_pr
26812 - /* skip the init task */
26813 - if (is_global_init(p))
26814 + /* skip the init task, global and per guest */
26815 + if (task_is_init(p))
26817 if (mem && !task_in_mem_cgroup(p, mem))
26819 + /* skip other guest and host processes if oom in guest */
26820 + if (xid && vx_task_xid(p) != xid)
26824 * This task already has access to memory reserves and is
26825 @@ -357,8 +376,8 @@ static void __oom_kill_task(struct task_
26829 - printk(KERN_ERR "Killed process %d (%s)\n",
26830 - task_pid_nr(p), p->comm);
26831 + printk(KERN_ERR "Killed process %s(%d:#%u)\n",
26832 + p->comm, task_pid_nr(p), p->xid);
26835 * We give our sacrificial lamb high priority and access to
26836 @@ -419,8 +438,8 @@ static int oom_kill_process(struct task_
26840 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26841 - message, task_pid_nr(p), p->comm, points);
26842 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26843 + message, p->comm, task_pid_nr(p), p->xid, points);
26845 /* Try to kill a child first */
26846 list_for_each_entry(c, &p->children, sibling) {
26847 @@ -521,6 +540,8 @@ void clear_zonelist_oom(struct zonelist
26848 spin_unlock(&zone_scan_lock);
26851 +long vs_oom_action(unsigned int);
26854 * Must be called with tasklist_lock held for read.
26856 @@ -546,7 +567,11 @@ retry:
26857 /* Found nothing?!?! Either we hang forever, or we panic. */
26859 read_unlock(&tasklist_lock);
26860 - panic("Out of memory and no killable processes...\n");
26861 + /* avoid panic for guest OOM */
26862 + if (current->xid)
26863 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
26865 + panic("Out of memory and no killable processes...\n");
26868 if (oom_kill_process(p, gfp_mask, order, points, NULL,
26869 diff -NurpP --minimal linux-2.6.32.10/mm/page_alloc.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/page_alloc.c
26870 --- linux-2.6.32.10/mm/page_alloc.c 2010-03-18 16:17:38.000000000 +0100
26871 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/page_alloc.c 2010-02-12 10:59:55.000000000 +0100
26873 #include <linux/page_cgroup.h>
26874 #include <linux/debugobjects.h>
26875 #include <linux/kmemleak.h>
26876 +#include <linux/vs_base.h>
26877 +#include <linux/vs_limit.h>
26878 #include <trace/events/kmem.h>
26880 #include <asm/tlbflush.h>
26881 @@ -2131,6 +2133,9 @@ void si_meminfo(struct sysinfo *val)
26882 val->totalhigh = totalhigh_pages;
26883 val->freehigh = nr_free_highpages();
26884 val->mem_unit = PAGE_SIZE;
26886 + if (vx_flags(VXF_VIRT_MEM, 0))
26887 + vx_vsi_meminfo(val);
26890 EXPORT_SYMBOL(si_meminfo);
26891 @@ -2151,6 +2156,9 @@ void si_meminfo_node(struct sysinfo *val
26894 val->mem_unit = PAGE_SIZE;
26896 + if (vx_flags(VXF_VIRT_MEM, 0))
26897 + vx_vsi_meminfo(val);
26901 diff -NurpP --minimal linux-2.6.32.10/mm/rmap.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/rmap.c
26902 --- linux-2.6.32.10/mm/rmap.c 2009-12-03 20:02:58.000000000 +0100
26903 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/rmap.c 2009-12-03 20:04:56.000000000 +0100
26905 #include <linux/memcontrol.h>
26906 #include <linux/mmu_notifier.h>
26907 #include <linux/migrate.h>
26908 +#include <linux/vs_memory.h>
26910 #include <asm/tlbflush.h>
26912 diff -NurpP --minimal linux-2.6.32.10/mm/shmem.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/shmem.c
26913 --- linux-2.6.32.10/mm/shmem.c 2009-12-03 20:02:58.000000000 +0100
26914 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/shmem.c 2009-12-03 20:04:56.000000000 +0100
26915 @@ -1781,7 +1781,7 @@ static int shmem_statfs(struct dentry *d
26917 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26919 - buf->f_type = TMPFS_MAGIC;
26920 + buf->f_type = TMPFS_SUPER_MAGIC;
26921 buf->f_bsize = PAGE_CACHE_SIZE;
26922 buf->f_namelen = NAME_MAX;
26923 spin_lock(&sbinfo->stat_lock);
26924 @@ -2346,7 +2346,7 @@ int shmem_fill_super(struct super_block
26925 sb->s_maxbytes = SHMEM_MAX_BYTES;
26926 sb->s_blocksize = PAGE_CACHE_SIZE;
26927 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26928 - sb->s_magic = TMPFS_MAGIC;
26929 + sb->s_magic = TMPFS_SUPER_MAGIC;
26930 sb->s_op = &shmem_ops;
26931 sb->s_time_gran = 1;
26932 #ifdef CONFIG_TMPFS_POSIX_ACL
26933 diff -NurpP --minimal linux-2.6.32.10/mm/slab.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/slab.c
26934 --- linux-2.6.32.10/mm/slab.c 2010-03-18 16:17:38.000000000 +0100
26935 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/slab.c 2010-03-18 16:53:06.000000000 +0100
26936 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
26937 #define STATS_INC_FREEMISS(x) do { } while (0)
26940 +#include "slab_vs.h"
26945 @@ -3251,6 +3253,7 @@ retry:
26947 obj = slab_get_obj(cachep, slabp, nodeid);
26948 check_slabp(cachep, slabp);
26949 + vx_slab_alloc(cachep, flags);
26950 l3->free_objects--;
26951 /* move slabp to correct slabp list: */
26952 list_del(&slabp->list);
26953 @@ -3327,6 +3330,7 @@ __cache_alloc_node(struct kmem_cache *ca
26954 /* ___cache_alloc_node can fall back to other nodes */
26955 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26957 + vx_slab_alloc(cachep, flags);
26958 local_irq_restore(save_flags);
26959 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26960 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26961 @@ -3513,6 +3517,7 @@ static inline void __cache_free(struct k
26963 kmemleak_free_recursive(objp, cachep->flags);
26964 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26965 + vx_slab_free(cachep);
26967 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26969 diff -NurpP --minimal linux-2.6.32.10/mm/slab_vs.h linux-2.6.32.10-vs2.3.0.36.29.2/mm/slab_vs.h
26970 --- linux-2.6.32.10/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26971 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/slab_vs.h 2009-12-03 20:04:56.000000000 +0100
26974 +#include <linux/vserver/context.h>
26976 +#include <linux/vs_context.h>
26979 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26981 + int what = gfp_zone(cachep->gfpflags);
26982 + struct vx_info *vxi = current_vx_info();
26987 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26991 +void vx_slab_free(struct kmem_cache *cachep)
26993 + int what = gfp_zone(cachep->gfpflags);
26994 + struct vx_info *vxi = current_vx_info();
26999 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
27002 diff -NurpP --minimal linux-2.6.32.10/mm/swapfile.c linux-2.6.32.10-vs2.3.0.36.29.2/mm/swapfile.c
27003 --- linux-2.6.32.10/mm/swapfile.c 2009-12-03 20:02:58.000000000 +0100
27004 +++ linux-2.6.32.10-vs2.3.0.36.29.2/mm/swapfile.c 2009-12-03 20:04:56.000000000 +0100
27006 #include <asm/tlbflush.h>
27007 #include <linux/swapops.h>
27008 #include <linux/page_cgroup.h>
27009 +#include <linux/vs_base.h>
27010 +#include <linux/vs_memory.h>
27012 static DEFINE_SPINLOCK(swap_lock);
27013 static unsigned int nr_swapfiles;
27014 @@ -1680,6 +1682,8 @@ static void *swap_next(struct seq_file *
27015 if (v == SEQ_START_TOKEN)
27018 + if (vx_flags(VXF_VIRT_MEM, 0))
27023 @@ -1707,6 +1711,16 @@ static int swap_show(struct seq_file *sw
27025 if (ptr == SEQ_START_TOKEN) {
27026 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
27027 + if (vx_flags(VXF_VIRT_MEM, 0)) {
27028 + struct sysinfo si;
27030 + vx_vsi_swapinfo(&si);
27031 + if (si.totalswap < (1 << 10))
27033 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
27034 + "hdv0", "partition", si.totalswap >> 10,
27035 + (si.totalswap - si.freeswap) >> 10, -1);
27040 @@ -2064,6 +2078,8 @@ void si_swapinfo(struct sysinfo *val)
27041 val->freeswap = nr_swap_pages + nr_to_be_unused;
27042 val->totalswap = total_swap_pages + nr_to_be_unused;
27043 spin_unlock(&swap_lock);
27044 + if (vx_flags(VXF_VIRT_MEM, 0))
27045 + vx_vsi_swapinfo(val);
27049 diff -NurpP --minimal linux-2.6.32.10/net/core/dev.c linux-2.6.32.10-vs2.3.0.36.29.2/net/core/dev.c
27050 --- linux-2.6.32.10/net/core/dev.c 2010-03-18 16:17:38.000000000 +0100
27051 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/core/dev.c 2010-03-18 16:53:06.000000000 +0100
27052 @@ -126,6 +126,7 @@
27053 #include <linux/in.h>
27054 #include <linux/jhash.h>
27055 #include <linux/random.h>
27056 +#include <linux/vs_inet.h>
27057 #include <trace/events/napi.h>
27059 #include "net-sysfs.h"
27060 @@ -591,7 +592,8 @@ struct net_device *__dev_get_by_name(str
27061 hlist_for_each(p, dev_name_hash(net, name)) {
27062 struct net_device *dev
27063 = hlist_entry(p, struct net_device, name_hlist);
27064 - if (!strncmp(dev->name, name, IFNAMSIZ))
27065 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
27066 + nx_dev_visible(current_nx_info(), dev))
27070 @@ -642,7 +644,8 @@ struct net_device *__dev_get_by_index(st
27071 hlist_for_each(p, dev_index_hash(net, ifindex)) {
27072 struct net_device *dev
27073 = hlist_entry(p, struct net_device, index_hlist);
27074 - if (dev->ifindex == ifindex)
27075 + if ((dev->ifindex == ifindex) &&
27076 + nx_dev_visible(current_nx_info(), dev))
27080 @@ -695,10 +698,12 @@ struct net_device *dev_getbyhwaddr(struc
27084 - for_each_netdev(net, dev)
27085 + for_each_netdev(net, dev) {
27086 if (dev->type == type &&
27087 - !memcmp(dev->dev_addr, ha, dev->addr_len))
27088 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
27089 + nx_dev_visible(current_nx_info(), dev))
27095 @@ -709,9 +714,11 @@ struct net_device *__dev_getfirstbyhwtyp
27096 struct net_device *dev;
27099 - for_each_netdev(net, dev)
27100 - if (dev->type == type)
27101 + for_each_netdev(net, dev) {
27102 + if ((dev->type == type) &&
27103 + nx_dev_visible(current_nx_info(), dev))
27109 @@ -830,6 +837,8 @@ static int __dev_alloc_name(struct net *
27111 if (i < 0 || i >= max_netdevices)
27113 + if (!nx_dev_visible(current_nx_info(), d))
27116 /* avoid cases where sscanf is not exact inverse of printf */
27117 snprintf(buf, IFNAMSIZ, name, i);
27118 @@ -2984,6 +2993,8 @@ static int dev_ifconf(struct net *net, c
27121 for_each_netdev(net, dev) {
27122 + if (!nx_dev_visible(current_nx_info(), dev))
27124 for (i = 0; i < NPROTO; i++) {
27125 if (gifconf_list[i]) {
27127 @@ -3052,6 +3063,9 @@ static void dev_seq_printf_stats(struct
27129 const struct net_device_stats *stats = dev_get_stats(dev);
27131 + if (!nx_dev_visible(current_nx_info(), dev))
27134 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
27135 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
27136 dev->name, stats->rx_bytes, stats->rx_packets,
27137 @@ -5317,7 +5331,6 @@ int dev_change_net_namespace(struct net_
27138 if (dev->dev.parent)
27142 /* Ensure the device has been registrered */
27144 if (dev->reg_state != NETREG_REGISTERED)
27145 diff -NurpP --minimal linux-2.6.32.10/net/core/rtnetlink.c linux-2.6.32.10-vs2.3.0.36.29.2/net/core/rtnetlink.c
27146 --- linux-2.6.32.10/net/core/rtnetlink.c 2010-03-18 16:17:38.000000000 +0100
27147 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/core/rtnetlink.c 2009-12-29 00:36:26.000000000 +0100
27148 @@ -688,6 +688,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
27151 for_each_netdev(net, dev) {
27152 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
27156 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
27157 @@ -1222,6 +1224,9 @@ void rtmsg_ifinfo(int type, struct net_d
27158 struct sk_buff *skb;
27159 int err = -ENOBUFS;
27161 + if (!nx_dev_visible(current_nx_info(), dev))
27164 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
27167 diff -NurpP --minimal linux-2.6.32.10/net/core/sock.c linux-2.6.32.10-vs2.3.0.36.29.2/net/core/sock.c
27168 --- linux-2.6.32.10/net/core/sock.c 2010-03-18 16:17:38.000000000 +0100
27169 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/core/sock.c 2010-02-12 10:59:55.000000000 +0100
27170 @@ -125,6 +125,10 @@
27171 #include <linux/ipsec.h>
27173 #include <linux/filter.h>
27174 +#include <linux/vs_socket.h>
27175 +#include <linux/vs_limit.h>
27176 +#include <linux/vs_context.h>
27177 +#include <linux/vs_network.h>
27180 #include <net/tcp.h>
27181 @@ -984,6 +988,8 @@ static struct sock *sk_prot_alloc(struct
27182 if (!try_module_get(prot->owner))
27185 + sock_vx_init(sk);
27186 + sock_nx_init(sk);
27190 @@ -1063,6 +1069,11 @@ static void __sk_free(struct sock *sk)
27191 __func__, atomic_read(&sk->sk_omem_alloc));
27193 put_net(sock_net(sk));
27195 + clr_vx_info(&sk->sk_vx_info);
27197 + clr_nx_info(&sk->sk_nx_info);
27199 sk_prot_free(sk->sk_prot_creator, sk);
27202 @@ -1110,6 +1121,8 @@ struct sock *sk_clone(const struct sock
27205 get_net(sock_net(newsk));
27206 + sock_vx_init(newsk);
27207 + sock_nx_init(newsk);
27208 sk_node_init(&newsk->sk_node);
27209 sock_lock_init(newsk);
27210 bh_lock_sock(newsk);
27211 @@ -1164,6 +1177,12 @@ struct sock *sk_clone(const struct sock
27213 atomic_set(&newsk->sk_refcnt, 2);
27215 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
27216 + newsk->sk_xid = sk->sk_xid;
27217 + vx_sock_inc(newsk);
27218 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
27219 + newsk->sk_nid = sk->sk_nid;
27222 * Increment the counter in the same struct proto as the master
27223 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
27224 @@ -1886,6 +1905,12 @@ void sock_init_data(struct socket *sock,
27226 sk->sk_stamp = ktime_set(-1L, 0);
27228 + set_vx_info(&sk->sk_vx_info, current_vx_info());
27229 + sk->sk_xid = vx_current_xid();
27231 + set_nx_info(&sk->sk_nx_info, current_nx_info());
27232 + sk->sk_nid = nx_current_nid();
27235 * Before updating sk_refcnt, we must commit prior changes to memory
27236 * (Documentation/RCU/rculist_nulls.txt for details)
27237 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/af_inet.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/af_inet.c
27238 --- linux-2.6.32.10/net/ipv4/af_inet.c 2009-12-03 20:02:59.000000000 +0100
27239 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/af_inet.c 2009-12-03 20:04:56.000000000 +0100
27240 @@ -115,6 +115,7 @@
27241 #ifdef CONFIG_IP_MROUTE
27242 #include <linux/mroute.h>
27244 +#include <linux/vs_limit.h>
27247 /* The inetsw table contains everything that inet_create needs to
27248 @@ -325,9 +326,12 @@ lookup_protocol:
27252 + if ((protocol == IPPROTO_ICMP) &&
27253 + nx_capable(answer->capability, NXC_RAW_ICMP))
27255 if (answer->capability > 0 && !capable(answer->capability))
27256 goto out_rcu_unlock;
27259 err = -EAFNOSUPPORT;
27260 if (!inet_netns_ok(net, protocol))
27261 goto out_rcu_unlock;
27262 @@ -447,6 +451,7 @@ int inet_bind(struct socket *sock, struc
27263 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
27264 struct sock *sk = sock->sk;
27265 struct inet_sock *inet = inet_sk(sk);
27266 + struct nx_v4_sock_addr nsa;
27267 unsigned short snum;
27270 @@ -460,7 +465,11 @@ int inet_bind(struct socket *sock, struc
27271 if (addr_len < sizeof(struct sockaddr_in))
27274 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27275 + err = v4_map_sock_addr(inet, addr, &nsa);
27279 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27281 /* Not specified by any standard per-se, however it breaks too
27282 * many applications when removed. It is unfortunate since
27283 @@ -472,7 +481,7 @@ int inet_bind(struct socket *sock, struc
27284 err = -EADDRNOTAVAIL;
27285 if (!sysctl_ip_nonlocal_bind &&
27286 !(inet->freebind || inet->transparent) &&
27287 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
27288 + nsa.saddr != htonl(INADDR_ANY) &&
27289 chk_addr_ret != RTN_LOCAL &&
27290 chk_addr_ret != RTN_MULTICAST &&
27291 chk_addr_ret != RTN_BROADCAST)
27292 @@ -497,7 +506,7 @@ int inet_bind(struct socket *sock, struc
27293 if (sk->sk_state != TCP_CLOSE || inet->num)
27294 goto out_release_sock;
27296 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27297 + v4_set_sock_addr(inet, &nsa);
27298 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27299 inet->saddr = 0; /* Use device */
27301 @@ -694,11 +703,13 @@ int inet_getname(struct socket *sock, st
27304 sin->sin_port = inet->dport;
27305 - sin->sin_addr.s_addr = inet->daddr;
27306 + sin->sin_addr.s_addr =
27307 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27309 __be32 addr = inet->rcv_saddr;
27311 addr = inet->saddr;
27312 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
27313 sin->sin_port = inet->sport;
27314 sin->sin_addr.s_addr = addr;
27316 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/devinet.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/devinet.c
27317 --- linux-2.6.32.10/net/ipv4/devinet.c 2010-03-18 16:17:38.000000000 +0100
27318 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/devinet.c 2010-03-18 16:53:06.000000000 +0100
27319 @@ -413,6 +413,7 @@ struct in_device *inetdev_by_index(struc
27324 /* Called only from RTNL semaphored context. No locks. */
27326 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
27327 @@ -653,6 +654,8 @@ int devinet_ioctl(struct net *net, unsig
27330 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
27331 + struct nx_info *nxi = current_nx_info();
27333 if (tryaddrmatch) {
27334 /* Matthias Andree */
27335 /* compare label and address (4.4BSD style) */
27336 @@ -661,6 +664,8 @@ int devinet_ioctl(struct net *net, unsig
27337 This is checked above. */
27338 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27339 ifap = &ifa->ifa_next) {
27340 + if (!nx_v4_ifa_visible(nxi, ifa))
27342 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
27343 sin_orig.sin_addr.s_addr ==
27344 ifa->ifa_address) {
27345 @@ -673,9 +678,12 @@ int devinet_ioctl(struct net *net, unsig
27346 comparing just the label */
27348 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27349 - ifap = &ifa->ifa_next)
27350 + ifap = &ifa->ifa_next) {
27351 + if (!nx_v4_ifa_visible(nxi, ifa))
27353 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27359 @@ -826,6 +834,8 @@ static int inet_gifconf(struct net_devic
27362 for (; ifa; ifa = ifa->ifa_next) {
27363 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27366 done += sizeof(ifr);
27368 @@ -1174,6 +1184,7 @@ static int inet_dump_ifaddr(struct sk_bu
27369 struct net_device *dev;
27370 struct in_device *in_dev;
27371 struct in_ifaddr *ifa;
27372 + struct sock *sk = skb->sk;
27373 int s_ip_idx, s_idx = cb->args[0];
27375 s_ip_idx = ip_idx = cb->args[1];
27376 @@ -1188,6 +1199,8 @@ static int inet_dump_ifaddr(struct sk_bu
27378 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27379 ifa = ifa->ifa_next, ip_idx++) {
27380 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27382 if (ip_idx < s_ip_idx)
27384 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
27385 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/fib_hash.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/fib_hash.c
27386 --- linux-2.6.32.10/net/ipv4/fib_hash.c 2009-09-10 15:26:29.000000000 +0200
27387 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/fib_hash.c 2009-12-03 20:04:56.000000000 +0100
27388 @@ -1021,7 +1021,7 @@ static int fib_seq_show(struct seq_file
27389 prefix = f->fn_key;
27390 mask = FZ_MASK(iter->zone);
27391 flags = fib_flag_trans(fa->fa_type, mask, fi);
27393 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27395 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27396 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27397 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/inet_connection_sock.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/inet_connection_sock.c
27398 --- linux-2.6.32.10/net/ipv4/inet_connection_sock.c 2009-12-03 20:02:59.000000000 +0100
27399 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/inet_connection_sock.c 2009-12-03 20:04:56.000000000 +0100
27400 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
27402 EXPORT_SYMBOL(inet_get_local_port_range);
27404 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27406 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
27407 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
27409 + if (inet_v6_ipv6only(sk2))
27412 + if (sk1_rcv_saddr &&
27414 + sk1_rcv_saddr == sk2_rcv_saddr)
27417 + if (sk1_rcv_saddr &&
27418 + !sk2_rcv_saddr &&
27419 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27422 + if (sk2_rcv_saddr &&
27423 + !sk1_rcv_saddr &&
27424 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27427 + if (!sk1_rcv_saddr &&
27428 + !sk2_rcv_saddr &&
27429 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27435 int inet_csk_bind_conflict(const struct sock *sk,
27436 const struct inet_bind_bucket *tb)
27438 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27440 struct hlist_node *node;
27441 int reuse = sk->sk_reuse;
27442 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
27443 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27444 if (!reuse || !sk2->sk_reuse ||
27445 sk2->sk_state == TCP_LISTEN) {
27446 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27447 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27448 - sk2_rcv_saddr == sk_rcv_saddr)
27449 + if (ipv4_rcv_saddr_equal(sk, sk2))
27453 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/inet_diag.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/inet_diag.c
27454 --- linux-2.6.32.10/net/ipv4/inet_diag.c 2009-09-10 15:26:29.000000000 +0200
27455 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/inet_diag.c 2009-12-03 20:04:56.000000000 +0100
27457 #include <linux/stddef.h>
27459 #include <linux/inet_diag.h>
27460 +#include <linux/vs_network.h>
27461 +#include <linux/vs_inet.h>
27463 static const struct inet_diag_handler **inet_diag_table;
27465 @@ -118,8 +120,8 @@ static int inet_csk_diag_fill(struct soc
27467 r->id.idiag_sport = inet->sport;
27468 r->id.idiag_dport = inet->dport;
27469 - r->id.idiag_src[0] = inet->rcv_saddr;
27470 - r->id.idiag_dst[0] = inet->daddr;
27471 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
27472 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27474 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27475 if (r->idiag_family == AF_INET6) {
27476 @@ -204,8 +206,8 @@ static int inet_twsk_diag_fill(struct in
27477 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27478 r->id.idiag_sport = tw->tw_sport;
27479 r->id.idiag_dport = tw->tw_dport;
27480 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
27481 - r->id.idiag_dst[0] = tw->tw_daddr;
27482 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27483 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27484 r->idiag_state = tw->tw_substate;
27485 r->idiag_timer = 3;
27486 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
27487 @@ -262,6 +264,7 @@ static int inet_diag_get_exact(struct sk
27490 if (req->idiag_family == AF_INET) {
27491 + /* TODO: lback */
27492 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27493 req->id.idiag_dport, req->id.idiag_src[0],
27494 req->id.idiag_sport, req->id.idiag_if);
27495 @@ -504,6 +507,7 @@ static int inet_csk_diag_dump(struct soc
27499 + /* TODO: lback */
27500 entry.saddr = &inet->rcv_saddr;
27501 entry.daddr = &inet->daddr;
27503 @@ -540,6 +544,7 @@ static int inet_twsk_diag_dump(struct in
27507 + /* TODO: lback */
27508 entry.saddr = &tw->tw_rcv_saddr;
27509 entry.daddr = &tw->tw_daddr;
27511 @@ -586,8 +591,8 @@ static int inet_diag_fill_req(struct sk_
27513 r->id.idiag_sport = inet->sport;
27514 r->id.idiag_dport = ireq->rmt_port;
27515 - r->id.idiag_src[0] = ireq->loc_addr;
27516 - r->id.idiag_dst[0] = ireq->rmt_addr;
27517 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27518 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27519 r->idiag_expires = jiffies_to_msecs(tmo);
27520 r->idiag_rqueue = 0;
27521 r->idiag_wqueue = 0;
27522 @@ -657,6 +662,7 @@ static int inet_diag_dump_reqs(struct sk
27526 + /* TODO: lback */
27528 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27529 (entry.family == AF_INET6) ?
27530 @@ -727,6 +733,8 @@ static int inet_diag_dump(struct sk_buff
27531 sk_nulls_for_each(sk, node, &ilb->head) {
27532 struct inet_sock *inet = inet_sk(sk);
27534 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27539 @@ -793,6 +801,8 @@ skip_listen_ht:
27540 sk_nulls_for_each(sk, node, &head->chain) {
27541 struct inet_sock *inet = inet_sk(sk);
27543 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27547 if (!(r->idiag_states & (1 << sk->sk_state)))
27548 @@ -817,6 +827,8 @@ next_normal:
27549 inet_twsk_for_each(tw, node,
27552 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27556 if (r->id.idiag_sport != tw->tw_sport &&
27557 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/inet_hashtables.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/inet_hashtables.c
27558 --- linux-2.6.32.10/net/ipv4/inet_hashtables.c 2009-06-11 17:13:29.000000000 +0200
27559 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/inet_hashtables.c 2009-12-03 20:04:56.000000000 +0100
27562 #include <net/inet_connection_sock.h>
27563 #include <net/inet_hashtables.h>
27564 +#include <net/route.h>
27565 #include <net/ip.h>
27568 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
27569 if (rcv_saddr != daddr)
27573 + /* block non nx_info ips */
27574 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27575 + daddr, NXA_MASK_BIND))
27578 if (sk->sk_bound_dev_if) {
27579 if (sk->sk_bound_dev_if != dif)
27580 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
27581 * wildcarded during the search since they can never be otherwise.
27585 struct sock *__inet_lookup_listener(struct net *net,
27586 struct inet_hashinfo *hashinfo,
27587 const __be32 daddr, const unsigned short hnum,
27588 @@ -174,6 +179,7 @@ begin:
27594 * if the nulls value we got at the end of this lookup is
27595 * not the expected one, we must restart lookup.
27596 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/netfilter/nf_nat_helper.c
27597 --- linux-2.6.32.10/net/ipv4/netfilter/nf_nat_helper.c 2009-12-03 20:02:59.000000000 +0100
27598 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/netfilter/nf_nat_helper.c 2009-12-03 20:04:56.000000000 +0100
27600 #include <net/route.h>
27602 #include <linux/netfilter_ipv4.h>
27603 +#include <net/route.h>
27604 #include <net/netfilter/nf_conntrack.h>
27605 #include <net/netfilter/nf_conntrack_helper.h>
27606 #include <net/netfilter/nf_conntrack_ecache.h>
27607 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/netfilter.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/netfilter.c
27608 --- linux-2.6.32.10/net/ipv4/netfilter.c 2009-09-10 15:26:29.000000000 +0200
27609 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/netfilter.c 2009-12-03 20:04:56.000000000 +0100
27611 #include <linux/netfilter_ipv4.h>
27612 #include <linux/ip.h>
27613 #include <linux/skbuff.h>
27614 -#include <net/route.h>
27615 +// #include <net/route.h>
27616 #include <net/xfrm.h>
27617 #include <net/ip.h>
27618 #include <net/netfilter/nf_queue.h>
27619 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/raw.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/raw.c
27620 --- linux-2.6.32.10/net/ipv4/raw.c 2009-12-03 20:02:59.000000000 +0100
27621 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/raw.c 2009-12-03 20:04:56.000000000 +0100
27622 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27624 if (net_eq(sock_net(sk), net) && inet->num == num &&
27625 !(inet->daddr && inet->daddr != raddr) &&
27626 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27627 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27628 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27629 goto found; /* gotcha */
27631 @@ -383,6 +383,12 @@ static int raw_send_hdrinc(struct sock *
27632 icmp_out_count(net, ((struct icmphdr *)
27633 skb_transport_header(skb))->type);
27636 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27637 + sk->sk_nx_info &&
27638 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27641 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27644 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
27647 security_sk_classify_flow(sk, &fl);
27648 + if (sk->sk_nx_info) {
27649 + err = ip_v4_find_src(sock_net(sk),
27650 + sk->sk_nx_info, &rt, &fl);
27655 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27658 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
27660 struct inet_sock *inet = inet_sk(sk);
27661 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27662 + struct nx_v4_sock_addr nsa = { 0 };
27666 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27668 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27669 + v4_map_sock_addr(inet, addr, &nsa);
27670 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27671 ret = -EADDRNOTAVAIL;
27672 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27673 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27674 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27676 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27677 + v4_set_sock_addr(inet, &nsa);
27678 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27679 inet->saddr = 0; /* Use device */
27681 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
27682 /* Copy the address. */
27684 sin->sin_family = AF_INET;
27685 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27686 + sin->sin_addr.s_addr =
27687 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27689 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27691 @@ -875,7 +891,8 @@ static struct sock *raw_get_first(struct
27692 struct hlist_node *node;
27694 sk_for_each(sk, node, &state->h->ht[state->bucket])
27695 - if (sock_net(sk) == seq_file_net(seq))
27696 + if ((sock_net(sk) == seq_file_net(seq)) &&
27697 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27701 @@ -891,7 +908,8 @@ static struct sock *raw_get_next(struct
27705 - } while (sk && sock_net(sk) != seq_file_net(seq));
27706 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27707 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27709 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27710 sk = sk_head(&state->h->ht[state->bucket]);
27711 @@ -950,7 +968,10 @@ static void raw_sock_seq_show(struct seq
27713 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27714 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27715 - i, src, srcp, dest, destp, sp->sk_state,
27717 + nx_map_sock_lback(current_nx_info(), src), srcp,
27718 + nx_map_sock_lback(current_nx_info(), dest), destp,
27720 sk_wmem_alloc_get(sp),
27721 sk_rmem_alloc_get(sp),
27722 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27723 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/tcp.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/tcp.c
27724 --- linux-2.6.32.10/net/ipv4/tcp.c 2009-12-03 20:02:59.000000000 +0100
27725 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/tcp.c 2009-12-03 20:04:56.000000000 +0100
27726 @@ -264,6 +264,7 @@
27727 #include <linux/cache.h>
27728 #include <linux/err.h>
27729 #include <linux/crypto.h>
27730 +#include <linux/in.h>
27732 #include <net/icmp.h>
27733 #include <net/tcp.h>
27734 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/tcp_ipv4.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/tcp_ipv4.c
27735 --- linux-2.6.32.10/net/ipv4/tcp_ipv4.c 2009-12-03 20:03:00.000000000 +0100
27736 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/tcp_ipv4.c 2009-12-03 20:04:56.000000000 +0100
27737 @@ -1925,6 +1925,12 @@ static void *listening_get_next(struct s
27738 req = req->dl_next;
27741 + vxdprintk(VXD_CBIT(net, 6),
27742 + "sk,req: %p [#%d] (from %d)", req->sk,
27743 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27745 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27747 if (req->rsk_ops->family == st->family) {
27750 @@ -1949,6 +1955,10 @@ get_req:
27753 sk_nulls_for_each_from(sk, node) {
27754 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27755 + sk, sk->sk_nid, nx_current_nid());
27756 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27758 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27761 @@ -2012,6 +2022,11 @@ static void *established_get_first(struc
27763 spin_lock_bh(lock);
27764 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27765 + vxdprintk(VXD_CBIT(net, 6),
27766 + "sk,egf: %p [#%d] (from %d)",
27767 + sk, sk->sk_nid, nx_current_nid());
27768 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27770 if (sk->sk_family != st->family ||
27771 !net_eq(sock_net(sk), net)) {
27773 @@ -2022,6 +2037,11 @@ static void *established_get_first(struc
27774 st->state = TCP_SEQ_STATE_TIME_WAIT;
27775 inet_twsk_for_each(tw, node,
27776 &tcp_hashinfo.ehash[st->bucket].twchain) {
27777 + vxdprintk(VXD_CBIT(net, 6),
27778 + "tw: %p [#%d] (from %d)",
27779 + tw, tw->tw_nid, nx_current_nid());
27780 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27782 if (tw->tw_family != st->family ||
27783 !net_eq(twsk_net(tw), net)) {
27785 @@ -2050,7 +2070,9 @@ static void *established_get_next(struct
27789 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27790 + while (tw && (tw->tw_family != st->family ||
27791 + !net_eq(twsk_net(tw), net) ||
27792 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27796 @@ -2073,6 +2095,11 @@ get_tw:
27797 sk = sk_nulls_next(sk);
27799 sk_nulls_for_each_from(sk, node) {
27800 + vxdprintk(VXD_CBIT(net, 6),
27801 + "sk,egn: %p [#%d] (from %d)",
27802 + sk, sk->sk_nid, nx_current_nid());
27803 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27805 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27808 @@ -2224,9 +2251,9 @@ static void get_openreq4(struct sock *sk
27809 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27810 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27813 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27814 ntohs(inet_sk(sk)->sport),
27816 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27817 ntohs(ireq->rmt_port),
27819 0, 0, /* could print option size, but that is af dependent. */
27820 @@ -2269,7 +2296,10 @@ static void get_tcp4_sock(struct sock *s
27822 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27823 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27824 - i, src, srcp, dest, destp, sk->sk_state,
27826 + nx_map_sock_lback(current_nx_info(), src), srcp,
27827 + nx_map_sock_lback(current_nx_info(), dest), destp,
27829 tp->write_seq - tp->snd_una,
27830 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
27831 (tp->rcv_nxt - tp->copied_seq),
27832 @@ -2305,7 +2335,10 @@ static void get_timewait4_sock(struct in
27834 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27835 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27836 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27838 + nx_map_sock_lback(current_nx_info(), src), srcp,
27839 + nx_map_sock_lback(current_nx_info(), dest), destp,
27840 + tw->tw_substate, 0, 0,
27841 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27842 atomic_read(&tw->tw_refcnt), tw, len);
27844 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/tcp_minisocks.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/tcp_minisocks.c
27845 --- linux-2.6.32.10/net/ipv4/tcp_minisocks.c 2009-12-03 20:03:00.000000000 +0100
27846 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/tcp_minisocks.c 2009-12-03 20:04:56.000000000 +0100
27848 #include <net/inet_common.h>
27849 #include <net/xfrm.h>
27851 +#include <linux/vs_limit.h>
27852 +#include <linux/vs_socket.h>
27853 +#include <linux/vs_context.h>
27855 #ifdef CONFIG_SYSCTL
27856 #define SYNC_INIT 0 /* let the user enable it */
27858 @@ -294,6 +298,11 @@ void tcp_time_wait(struct sock *sk, int
27859 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27860 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27862 + tw->tw_xid = sk->sk_xid;
27863 + tw->tw_vx_info = NULL;
27864 + tw->tw_nid = sk->sk_nid;
27865 + tw->tw_nx_info = NULL;
27867 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27868 if (tw->tw_family == PF_INET6) {
27869 struct ipv6_pinfo *np = inet6_sk(sk);
27870 diff -NurpP --minimal linux-2.6.32.10/net/ipv4/udp.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/udp.c
27871 --- linux-2.6.32.10/net/ipv4/udp.c 2009-12-03 20:03:00.000000000 +0100
27872 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv4/udp.c 2009-12-03 20:04:56.000000000 +0100
27873 @@ -224,14 +224,7 @@ fail:
27875 EXPORT_SYMBOL(udp_lib_get_port);
27877 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27879 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27881 - return (!ipv6_only_sock(sk2) &&
27882 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27883 - inet1->rcv_saddr == inet2->rcv_saddr));
27885 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27887 int udp_v4_get_port(struct sock *sk, unsigned short snum)
27889 @@ -253,6 +246,11 @@ static inline int compute_score(struct s
27890 if (inet->rcv_saddr != daddr)
27894 + /* block non nx_info ips */
27895 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27896 + daddr, NXA_MASK_BIND))
27900 if (inet->daddr != saddr)
27901 @@ -273,6 +271,7 @@ static inline int compute_score(struct s
27906 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27907 * harder than this. -DaveM
27909 @@ -294,6 +293,11 @@ begin:
27910 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27911 score = compute_score(sk, net, saddr, hnum, sport,
27912 daddr, dport, dif);
27913 + /* FIXME: disabled?
27914 + if (score == 9) {
27918 if (score > badness) {
27921 @@ -307,6 +311,7 @@ begin:
27922 if (get_nulls_value(node) != hash)
27927 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27929 @@ -316,6 +321,7 @@ begin:
27937 @@ -358,7 +364,7 @@ static inline struct sock *udp_v4_mcast_
27938 s->sk_hash != hnum ||
27939 (inet->daddr && inet->daddr != rmt_addr) ||
27940 (inet->dport != rmt_port && inet->dport) ||
27941 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27942 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27943 ipv6_only_sock(s) ||
27944 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27946 @@ -707,8 +713,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27947 { .sport = inet->sport,
27948 .dport = dport } } };
27949 struct net *net = sock_net(sk);
27950 + struct nx_info *nxi = sk->sk_nx_info;
27952 security_sk_classify_flow(sk, &fl);
27953 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27957 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27959 if (err == -ENETUNREACH)
27960 @@ -988,7 +999,8 @@ try_again:
27962 sin->sin_family = AF_INET;
27963 sin->sin_port = udp_hdr(skb)->source;
27964 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27965 + sin->sin_addr.s_addr = nx_map_sock_lback(
27966 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27967 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27969 if (inet->cmsg_flags)
27970 @@ -1627,6 +1639,8 @@ static struct sock *udp_get_first(struct
27971 sk_nulls_for_each(sk, node, &hslot->head) {
27972 if (!net_eq(sock_net(sk), net))
27974 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27976 if (sk->sk_family == state->family)
27979 @@ -1644,7 +1658,9 @@ static struct sock *udp_get_next(struct
27982 sk = sk_nulls_next(sk);
27983 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27984 + } while (sk && (!net_eq(sock_net(sk), net) ||
27985 + sk->sk_family != state->family ||
27986 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27989 if (state->bucket < UDP_HTABLE_SIZE)
27990 @@ -1751,7 +1767,10 @@ static void udp4_format_sock(struct sock
27992 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27993 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27994 - bucket, src, srcp, dest, destp, sp->sk_state,
27996 + nx_map_sock_lback(current_nx_info(), src), srcp,
27997 + nx_map_sock_lback(current_nx_info(), dest), destp,
27999 sk_wmem_alloc_get(sp),
28000 sk_rmem_alloc_get(sp),
28001 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28002 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/addrconf.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/addrconf.c
28003 --- linux-2.6.32.10/net/ipv6/addrconf.c 2010-03-18 16:17:38.000000000 +0100
28004 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/addrconf.c 2010-03-18 16:53:06.000000000 +0100
28007 #include <linux/proc_fs.h>
28008 #include <linux/seq_file.h>
28009 +#include <linux/vs_network.h>
28010 +#include <linux/vs_inet6.h>
28012 /* Set to 3 to get tracing... */
28013 #define ACONF_DEBUG 2
28014 @@ -1122,7 +1124,7 @@ out:
28016 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
28017 const struct in6_addr *daddr, unsigned int prefs,
28018 - struct in6_addr *saddr)
28019 + struct in6_addr *saddr, struct nx_info *nxi)
28021 struct ipv6_saddr_score scores[2],
28022 *score = &scores[0], *hiscore = &scores[1];
28023 @@ -1195,6 +1197,8 @@ int ipv6_dev_get_saddr(struct net *net,
28027 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
28031 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
28032 @@ -3003,7 +3007,10 @@ static void if6_seq_stop(struct seq_file
28033 static int if6_seq_show(struct seq_file *seq, void *v)
28035 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
28036 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28038 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
28039 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
28040 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28042 ifp->idev->dev->ifindex,
28044 @@ -3500,6 +3507,12 @@ static int inet6_dump_addr(struct sk_buf
28045 struct ifmcaddr6 *ifmca;
28046 struct ifacaddr6 *ifaca;
28047 struct net *net = sock_net(skb->sk);
28048 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28050 + /* disable ipv6 on non v6 guests */
28051 + if (nxi && !nx_info_has_v6(nxi))
28055 s_idx = cb->args[0];
28056 s_ip_idx = ip_idx = cb->args[1];
28057 @@ -3521,6 +3534,8 @@ static int inet6_dump_addr(struct sk_buf
28058 ifa = ifa->if_next, ip_idx++) {
28059 if (ip_idx < s_ip_idx)
28061 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
28063 err = inet6_fill_ifaddr(skb, ifa,
28064 NETLINK_CB(cb->skb).pid,
28065 cb->nlh->nlmsg_seq,
28066 @@ -3534,6 +3549,8 @@ static int inet6_dump_addr(struct sk_buf
28067 ifmca = ifmca->next, ip_idx++) {
28068 if (ip_idx < s_ip_idx)
28070 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
28072 err = inet6_fill_ifmcaddr(skb, ifmca,
28073 NETLINK_CB(cb->skb).pid,
28074 cb->nlh->nlmsg_seq,
28075 @@ -3547,6 +3564,8 @@ static int inet6_dump_addr(struct sk_buf
28076 ifaca = ifaca->aca_next, ip_idx++) {
28077 if (ip_idx < s_ip_idx)
28079 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
28081 err = inet6_fill_ifacaddr(skb, ifaca,
28082 NETLINK_CB(cb->skb).pid,
28083 cb->nlh->nlmsg_seq,
28084 @@ -3833,12 +3852,19 @@ static int inet6_dump_ifinfo(struct sk_b
28085 int s_idx = cb->args[0];
28086 struct net_device *dev;
28087 struct inet6_dev *idev;
28088 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28090 + /* FIXME: maybe disable ipv6 on non v6 guests?
28091 + if (skb->sk && skb->sk->sk_vx_info)
28092 + return skb->len; */
28094 read_lock(&dev_base_lock);
28096 for_each_netdev(net, dev) {
28099 + if (!v6_dev_in_nx_info(dev, nxi))
28101 if ((idev = in6_dev_get(dev)) == NULL)
28103 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
28104 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/af_inet6.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/af_inet6.c
28105 --- linux-2.6.32.10/net/ipv6/af_inet6.c 2009-12-03 20:03:00.000000000 +0100
28106 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/af_inet6.c 2009-12-03 20:04:56.000000000 +0100
28108 #include <linux/netdevice.h>
28109 #include <linux/icmpv6.h>
28110 #include <linux/netfilter_ipv6.h>
28111 +#include <linux/vs_inet.h>
28112 +#include <linux/vs_inet6.h>
28114 #include <net/ip.h>
28115 #include <net/ipv6.h>
28116 @@ -158,9 +160,12 @@ lookup_protocol:
28120 + if ((protocol == IPPROTO_ICMPV6) &&
28121 + nx_capable(answer->capability, NXC_RAW_ICMP))
28123 if (answer->capability > 0 && !capable(answer->capability))
28124 goto out_rcu_unlock;
28127 sock->ops = answer->ops;
28128 answer_prot = answer->prot;
28129 answer_no_check = answer->no_check;
28130 @@ -259,6 +264,7 @@ int inet6_bind(struct socket *sock, stru
28131 struct inet_sock *inet = inet_sk(sk);
28132 struct ipv6_pinfo *np = inet6_sk(sk);
28133 struct net *net = sock_net(sk);
28134 + struct nx_v6_sock_addr nsa;
28136 unsigned short snum;
28138 @@ -270,6 +276,11 @@ int inet6_bind(struct socket *sock, stru
28140 if (addr_len < SIN6_LEN_RFC2133)
28143 + err = v6_map_sock_addr(inet, addr, &nsa);
28147 addr_type = ipv6_addr_type(&addr->sin6_addr);
28148 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
28150 @@ -301,6 +312,7 @@ int inet6_bind(struct socket *sock, stru
28151 /* Reproduce AF_INET checks to make the bindings consitant */
28152 v4addr = addr->sin6_addr.s6_addr32[3];
28153 chk_addr_ret = inet_addr_type(net, v4addr);
28155 if (!sysctl_ip_nonlocal_bind &&
28156 !(inet->freebind || inet->transparent) &&
28157 v4addr != htonl(INADDR_ANY) &&
28158 @@ -310,6 +322,10 @@ int inet6_bind(struct socket *sock, stru
28159 err = -EADDRNOTAVAIL;
28162 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
28163 + err = -EADDRNOTAVAIL;
28167 if (addr_type != IPV6_ADDR_ANY) {
28168 struct net_device *dev = NULL;
28169 @@ -335,6 +351,11 @@ int inet6_bind(struct socket *sock, stru
28173 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28174 + err = -EADDRNOTAVAIL;
28178 /* ipv4 addr of the socket is invalid. Only the
28179 * unspecified and mapped address have a v4 equivalent.
28181 @@ -353,6 +374,8 @@ int inet6_bind(struct socket *sock, stru
28185 + v6_set_sock_addr(inet, &nsa);
28187 inet->rcv_saddr = v4addr;
28188 inet->saddr = v4addr;
28190 @@ -448,9 +471,11 @@ int inet6_getname(struct socket *sock, s
28192 sin->sin6_port = inet->dport;
28193 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
28194 + /* FIXME: remap lback? */
28196 sin->sin6_flowinfo = np->flow_label;
28198 + /* FIXME: remap lback? */
28199 if (ipv6_addr_any(&np->rcv_saddr))
28200 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
28202 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/fib6_rules.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/fib6_rules.c
28203 --- linux-2.6.32.10/net/ipv6/fib6_rules.c 2009-09-10 15:26:30.000000000 +0200
28204 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/fib6_rules.c 2009-12-03 20:04:56.000000000 +0100
28205 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
28206 if (ipv6_dev_get_saddr(net,
28207 ip6_dst_idev(&rt->u.dst)->dev,
28208 &flp->fl6_dst, srcprefs,
28212 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
28214 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/inet6_hashtables.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/inet6_hashtables.c
28215 --- linux-2.6.32.10/net/ipv6/inet6_hashtables.c 2009-03-24 14:22:46.000000000 +0100
28216 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/inet6_hashtables.c 2009-12-03 20:04:56.000000000 +0100
28219 #include <linux/module.h>
28220 #include <linux/random.h>
28221 +#include <linux/vs_inet6.h>
28223 #include <net/inet_connection_sock.h>
28224 #include <net/inet_hashtables.h>
28225 @@ -76,7 +77,6 @@ struct sock *__inet6_lookup_established(
28226 unsigned int slot = hash & (hashinfo->ehash_size - 1);
28227 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
28232 sk_nulls_for_each_rcu(sk, node, &head->chain) {
28233 @@ -88,7 +88,7 @@ begin:
28241 if (get_nulls_value(node) != slot)
28242 @@ -134,6 +134,9 @@ static int inline compute_score(struct s
28243 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28247 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28250 if (sk->sk_bound_dev_if) {
28251 if (sk->sk_bound_dev_if != dif)
28252 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/ip6_output.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/ip6_output.c
28253 --- linux-2.6.32.10/net/ipv6/ip6_output.c 2009-12-03 20:03:00.000000000 +0100
28254 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/ip6_output.c 2009-12-03 20:04:56.000000000 +0100
28255 @@ -934,7 +934,7 @@ static int ip6_dst_lookup_tail(struct so
28256 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
28258 sk ? inet6_sk(sk)->srcprefs : 0,
28260 + &fl->fl6_src, sk->sk_nx_info);
28262 goto out_err_release;
28264 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/Kconfig linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/Kconfig
28265 --- linux-2.6.32.10/net/ipv6/Kconfig 2009-09-10 15:26:30.000000000 +0200
28266 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/Kconfig 2009-12-03 20:04:56.000000000 +0100
28269 # IPv6 as module will cause a CRASH if you try to unload it
28271 - tristate "The IPv6 protocol"
28273 + bool "The IPv6 protocol"
28276 This is complemental support for the IP version 6.
28277 You will still be able to do traditional IPv4 networking as well.
28278 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/ndisc.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/ndisc.c
28279 --- linux-2.6.32.10/net/ipv6/ndisc.c 2009-12-03 20:03:00.000000000 +0100
28280 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/ndisc.c 2009-12-03 20:04:56.000000000 +0100
28281 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
28283 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
28284 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
28286 + &tmpaddr, NULL /* FIXME: ? */ ))
28288 src_addr = &tmpaddr;
28290 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/raw.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/raw.c
28291 --- linux-2.6.32.10/net/ipv6/raw.c 2009-12-03 20:03:00.000000000 +0100
28292 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/raw.c 2009-12-03 20:04:56.000000000 +0100
28294 #include <linux/icmpv6.h>
28295 #include <linux/netfilter.h>
28296 #include <linux/netfilter_ipv6.h>
28297 +#include <linux/vs_inet6.h>
28298 #include <linux/skbuff.h>
28299 #include <asm/uaccess.h>
28300 #include <asm/ioctls.h>
28301 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
28305 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28306 + err = -EADDRNOTAVAIL;
28312 /* ipv4 addr of the socket is invalid. Only the
28313 * unspecified and mapped address have a v4 equivalent.
28315 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/route.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/route.c
28316 --- linux-2.6.32.10/net/ipv6/route.c 2009-12-03 20:03:00.000000000 +0100
28317 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/route.c 2009-12-03 20:04:56.000000000 +0100
28318 @@ -2257,7 +2257,8 @@ static int rt6_fill_node(struct net *net
28319 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
28320 struct in6_addr saddr_buf;
28321 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
28322 - dst, 0, &saddr_buf) == 0)
28323 + dst, 0, &saddr_buf,
28324 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
28325 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
28328 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/tcp_ipv6.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/tcp_ipv6.c
28329 --- linux-2.6.32.10/net/ipv6/tcp_ipv6.c 2009-12-03 20:03:00.000000000 +0100
28330 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/tcp_ipv6.c 2009-12-03 20:04:56.000000000 +0100
28333 #include <linux/crypto.h>
28334 #include <linux/scatterlist.h>
28335 +#include <linux/vs_inet6.h>
28337 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
28338 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
28339 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
28340 * connect() to INADDR_ANY means loopback (BSD'ism).
28343 - if(ipv6_addr_any(&usin->sin6_addr))
28344 - usin->sin6_addr.s6_addr[15] = 0x1;
28345 + if(ipv6_addr_any(&usin->sin6_addr)) {
28346 + struct nx_info *nxi = sk->sk_nx_info;
28348 + if (nxi && nx_info_has_v6(nxi))
28349 + /* FIXME: remap lback? */
28350 + usin->sin6_addr = nxi->v6.ip;
28352 + usin->sin6_addr.s6_addr[15] = 0x1;
28355 addr_type = ipv6_addr_type(&usin->sin6_addr);
28357 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/udp.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/udp.c
28358 --- linux-2.6.32.10/net/ipv6/udp.c 2009-12-03 20:03:00.000000000 +0100
28359 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/udp.c 2009-12-03 20:04:56.000000000 +0100
28362 #include <linux/proc_fs.h>
28363 #include <linux/seq_file.h>
28364 +#include <linux/vs_inet6.h>
28365 #include "udp_impl.h"
28367 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28368 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
28369 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28371 /* if both are mapped, treat as IPv4 */
28372 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28373 - return (!sk2_ipv6only &&
28374 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28375 + if (!sk2_ipv6only &&
28376 (!sk_rcv_saddr || !sk2_rcv_saddr ||
28377 - sk_rcv_saddr == sk2_rcv_saddr));
28378 + sk_rcv_saddr == sk2_rcv_saddr))
28384 if (addr_type2 == IPV6_ADDR_ANY &&
28385 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28389 if (addr_type == IPV6_ADDR_ANY &&
28390 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28394 if (sk2_rcv_saddr6 &&
28395 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28402 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
28403 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28404 + if (!sk2_rcv_saddr)
28405 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28406 + if (!sk_rcv_saddr)
28407 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28410 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28411 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28412 + else if (addr_type2 == IPV6_ADDR_ANY)
28413 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28414 + else if (addr_type == IPV6_ADDR_ANY) {
28415 + if (addr_type2 == IPV6_ADDR_MAPPED)
28416 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28418 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28423 int udp_v6_get_port(struct sock *sk, unsigned short snum)
28424 @@ -109,6 +135,10 @@ static inline int compute_score(struct s
28425 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28429 + /* block non nx_info ips */
28430 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28433 if (!ipv6_addr_any(&np->daddr)) {
28434 if (!ipv6_addr_equal(&np->daddr, saddr))
28435 diff -NurpP --minimal linux-2.6.32.10/net/ipv6/xfrm6_policy.c linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/xfrm6_policy.c
28436 --- linux-2.6.32.10/net/ipv6/xfrm6_policy.c 2009-12-03 20:03:00.000000000 +0100
28437 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/ipv6/xfrm6_policy.c 2009-12-03 20:04:56.000000000 +0100
28438 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
28439 dev = ip6_dst_idev(dst)->dev;
28440 ipv6_dev_get_saddr(dev_net(dev), dev,
28441 (struct in6_addr *)&daddr->a6, 0,
28442 - (struct in6_addr *)&saddr->a6);
28443 + (struct in6_addr *)&saddr->a6, NULL);
28447 diff -NurpP --minimal linux-2.6.32.10/net/netlink/af_netlink.c linux-2.6.32.10-vs2.3.0.36.29.2/net/netlink/af_netlink.c
28448 --- linux-2.6.32.10/net/netlink/af_netlink.c 2009-12-03 20:03:01.000000000 +0100
28449 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/netlink/af_netlink.c 2009-12-03 20:04:56.000000000 +0100
28451 #include <linux/types.h>
28452 #include <linux/audit.h>
28453 #include <linux/mutex.h>
28454 +#include <linux/vs_context.h>
28455 +#include <linux/vs_network.h>
28456 +#include <linux/vs_limit.h>
28458 #include <net/net_namespace.h>
28459 #include <net/sock.h>
28460 @@ -1899,6 +1902,8 @@ static struct sock *netlink_seq_socket_i
28461 sk_for_each(s, node, &hash->table[j]) {
28462 if (sock_net(s) != seq_file_net(seq))
28464 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28468 iter->hash_idx = j;
28469 @@ -1933,7 +1938,8 @@ static void *netlink_seq_next(struct seq
28473 - } while (s && sock_net(s) != seq_file_net(seq));
28474 + } while (s && (sock_net(s) != seq_file_net(seq) ||
28475 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28479 @@ -1945,7 +1951,8 @@ static void *netlink_seq_next(struct seq
28481 for (; j <= hash->mask; j++) {
28482 s = sk_head(&hash->table[j]);
28483 - while (s && sock_net(s) != seq_file_net(seq))
28484 + while (s && (sock_net(s) != seq_file_net(seq) ||
28485 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28489 diff -NurpP --minimal linux-2.6.32.10/net/sctp/ipv6.c linux-2.6.32.10-vs2.3.0.36.29.2/net/sctp/ipv6.c
28490 --- linux-2.6.32.10/net/sctp/ipv6.c 2009-12-03 20:03:01.000000000 +0100
28491 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/sctp/ipv6.c 2009-12-03 20:04:56.000000000 +0100
28492 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
28493 dst ? ip6_dst_idev(dst)->dev : NULL,
28494 &daddr->v6.sin6_addr,
28495 inet6_sk(&sk->inet.sk)->srcprefs,
28496 - &saddr->v6.sin6_addr);
28497 + &saddr->v6.sin6_addr,
28498 + asoc->base.sk->sk_nx_info);
28499 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28500 &saddr->v6.sin6_addr);
28502 diff -NurpP --minimal linux-2.6.32.10/net/socket.c linux-2.6.32.10-vs2.3.0.36.29.2/net/socket.c
28503 --- linux-2.6.32.10/net/socket.c 2009-12-03 20:03:01.000000000 +0100
28504 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/socket.c 2009-12-03 20:04:56.000000000 +0100
28507 #include <net/sock.h>
28508 #include <linux/netfilter.h>
28509 +#include <linux/vs_base.h>
28510 +#include <linux/vs_socket.h>
28511 +#include <linux/vs_inet.h>
28512 +#include <linux/vs_inet6.h>
28514 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
28515 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
28516 @@ -559,7 +563,7 @@ static inline int __sock_sendmsg(struct
28517 struct msghdr *msg, size_t size)
28519 struct sock_iocb *si = kiocb_to_siocb(iocb);
28525 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct
28529 - return sock->ops->sendmsg(iocb, sock, msg, size);
28530 + len = sock->ops->sendmsg(iocb, sock, msg, size);
28533 + vx_sock_send(sock->sk, size);
28535 + vx_sock_fail(sock->sk, size);
28537 + vxdprintk(VXD_CBIT(net, 7),
28538 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28540 + (sock->sk)?sock->sk->sk_nx_info:0,
28541 + (sock->sk)?sock->sk->sk_vx_info:0,
28542 + (sock->sk)?sock->sk->sk_xid:0,
28543 + (sock->sk)?sock->sk->sk_nid:0,
28544 + (unsigned int)size, len);
28548 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28549 @@ -671,7 +690,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
28550 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28551 struct msghdr *msg, size_t size, int flags)
28555 struct sock_iocb *si = kiocb_to_siocb(iocb);
28558 @@ -684,7 +703,18 @@ static inline int __sock_recvmsg(struct
28562 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28563 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28564 + if ((len >= 0) && sock->sk)
28565 + vx_sock_recv(sock->sk, len);
28566 + vxdprintk(VXD_CBIT(net, 7),
28567 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28569 + (sock->sk)?sock->sk->sk_nx_info:0,
28570 + (sock->sk)?sock->sk->sk_vx_info:0,
28571 + (sock->sk)?sock->sk->sk_xid:0,
28572 + (sock->sk)?sock->sk->sk_nid:0,
28573 + (unsigned int)size, len);
28577 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
28578 @@ -1155,6 +1185,13 @@ static int __sock_create(struct net *net
28579 if (type < 0 || type >= SOCK_MAX)
28582 + if (!nx_check(0, VS_ADMIN)) {
28583 + if (family == PF_INET && !current_nx_info_has_v4())
28584 + return -EAFNOSUPPORT;
28585 + if (family == PF_INET6 && !current_nx_info_has_v6())
28586 + return -EAFNOSUPPORT;
28591 This uglymoron is moved from INET layer to here to avoid
28592 @@ -1287,6 +1324,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28596 + set_bit(SOCK_USER_SOCKET, &sock->flags);
28597 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28600 @@ -1328,10 +1366,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28601 err = sock_create(family, type, protocol, &sock1);
28604 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
28606 err = sock_create(family, type, protocol, &sock2);
28608 goto out_release_1;
28609 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
28611 err = sock1->ops->socketpair(sock1, sock2);
28613 diff -NurpP --minimal linux-2.6.32.10/net/sunrpc/auth.c linux-2.6.32.10-vs2.3.0.36.29.2/net/sunrpc/auth.c
28614 --- linux-2.6.32.10/net/sunrpc/auth.c 2009-12-03 20:03:01.000000000 +0100
28615 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/sunrpc/auth.c 2009-12-03 20:04:56.000000000 +0100
28617 #include <linux/hash.h>
28618 #include <linux/sunrpc/clnt.h>
28619 #include <linux/spinlock.h>
28620 +#include <linux/vs_tag.h>
28623 # define RPCDBG_FACILITY RPCDBG_AUTH
28624 @@ -360,6 +361,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28625 memset(&acred, 0, sizeof(acred));
28626 acred.uid = cred->fsuid;
28627 acred.gid = cred->fsgid;
28628 + acred.tag = dx_current_tag();
28629 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28631 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28632 @@ -400,6 +402,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28633 struct auth_cred acred = {
28636 + .tag = dx_current_tag(),
28638 struct rpc_cred *ret;
28640 diff -NurpP --minimal linux-2.6.32.10/net/sunrpc/auth_unix.c linux-2.6.32.10-vs2.3.0.36.29.2/net/sunrpc/auth_unix.c
28641 --- linux-2.6.32.10/net/sunrpc/auth_unix.c 2008-12-25 00:26:37.000000000 +0100
28642 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/sunrpc/auth_unix.c 2009-12-03 20:04:56.000000000 +0100
28643 @@ -11,12 +11,14 @@
28644 #include <linux/module.h>
28645 #include <linux/sunrpc/clnt.h>
28646 #include <linux/sunrpc/auth.h>
28647 +#include <linux/vs_tag.h>
28649 #define NFS_NGROUPS 16
28652 struct rpc_cred uc_base;
28655 gid_t uc_gids[NFS_NGROUPS];
28657 #define uc_uid uc_base.cr_uid
28658 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28659 groups = NFS_NGROUPS;
28661 cred->uc_gid = acred->gid;
28662 + cred->uc_tag = acred->tag;
28663 for (i = 0; i < groups; i++)
28664 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28665 if (i < NFS_NGROUPS)
28666 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28670 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28671 + if (cred->uc_uid != acred->uid ||
28672 + cred->uc_gid != acred->gid ||
28673 + cred->uc_tag != acred->tag)
28676 if (acred->group_info != NULL)
28677 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
28678 struct rpc_clnt *clnt = task->tk_client;
28679 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28680 __be32 *base, *hold;
28684 *p++ = htonl(RPC_AUTH_UNIX);
28686 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
28687 * Copy the UTS nodename captured when the client was created.
28689 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28690 + tag = task->tk_client->cl_tag;
28692 - *p++ = htonl((u32) cred->uc_uid);
28693 - *p++ = htonl((u32) cred->uc_gid);
28694 + *p++ = htonl((u32) TAGINO_UID(tag,
28695 + cred->uc_uid, cred->uc_tag));
28696 + *p++ = htonl((u32) TAGINO_GID(tag,
28697 + cred->uc_gid, cred->uc_tag));
28699 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28700 *p++ = htonl((u32) cred->uc_gids[i]);
28701 diff -NurpP --minimal linux-2.6.32.10/net/sunrpc/clnt.c linux-2.6.32.10-vs2.3.0.36.29.2/net/sunrpc/clnt.c
28702 --- linux-2.6.32.10/net/sunrpc/clnt.c 2009-12-03 20:03:01.000000000 +0100
28703 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/sunrpc/clnt.c 2009-12-03 20:04:56.000000000 +0100
28705 #include <linux/utsname.h>
28706 #include <linux/workqueue.h>
28707 #include <linux/in6.h>
28708 +#include <linux/vs_cvirt.h>
28710 #include <linux/sunrpc/clnt.h>
28711 #include <linux/sunrpc/rpc_pipe_fs.h>
28712 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28713 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28714 clnt->cl_chatty = 1;
28716 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28717 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28718 + clnt->cl_tag = 1; */
28721 EXPORT_SYMBOL_GPL(rpc_create);
28722 diff -NurpP --minimal linux-2.6.32.10/net/unix/af_unix.c linux-2.6.32.10-vs2.3.0.36.29.2/net/unix/af_unix.c
28723 --- linux-2.6.32.10/net/unix/af_unix.c 2009-12-03 20:03:01.000000000 +0100
28724 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/unix/af_unix.c 2009-12-03 20:04:56.000000000 +0100
28725 @@ -114,6 +114,8 @@
28726 #include <linux/mount.h>
28727 #include <net/checksum.h>
28728 #include <linux/security.h>
28729 +#include <linux/vs_context.h>
28730 +#include <linux/vs_limit.h>
28732 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28733 static DEFINE_SPINLOCK(unix_table_lock);
28734 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28735 if (!net_eq(sock_net(s), net))
28738 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28740 if (u->addr->len == len &&
28741 !memcmp(u->addr->name, sunname, len))
28743 @@ -2114,6 +2118,8 @@ static struct sock *unix_seq_idx(struct
28744 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28745 if (sock_net(s) != seq_file_net(seq))
28747 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28752 @@ -2138,7 +2144,8 @@ static void *unix_seq_next(struct seq_fi
28753 sk = first_unix_socket(&iter->i);
28755 sk = next_unix_socket(&iter->i, sk);
28756 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28757 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28758 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28759 sk = next_unix_socket(&iter->i, sk);
28762 diff -NurpP --minimal linux-2.6.32.10/net/x25/af_x25.c linux-2.6.32.10-vs2.3.0.36.29.2/net/x25/af_x25.c
28763 --- linux-2.6.32.10/net/x25/af_x25.c 2009-12-03 20:03:01.000000000 +0100
28764 +++ linux-2.6.32.10-vs2.3.0.36.29.2/net/x25/af_x25.c 2009-12-03 20:04:56.000000000 +0100
28765 @@ -519,7 +519,10 @@ static int x25_create(struct net *net, s
28769 - sock_init_data(sock, sk);
28770 + sk->sk_socket = sock;
28771 + sk->sk_type = sock->type;
28772 + sk->sk_sleep = &sock->wait;
28775 x25_init_timers(sk);
28777 diff -NurpP --minimal linux-2.6.32.10/scripts/checksyscalls.sh linux-2.6.32.10-vs2.3.0.36.29.2/scripts/checksyscalls.sh
28778 --- linux-2.6.32.10/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
28779 +++ linux-2.6.32.10-vs2.3.0.36.29.2/scripts/checksyscalls.sh 2009-12-03 20:04:56.000000000 +0100
28780 @@ -194,7 +194,6 @@ cat << EOF
28781 #define __IGNORE_afs_syscall
28782 #define __IGNORE_getpmsg
28783 #define __IGNORE_putpmsg
28784 -#define __IGNORE_vserver
28788 diff -NurpP --minimal linux-2.6.32.10/security/commoncap.c linux-2.6.32.10-vs2.3.0.36.29.2/security/commoncap.c
28789 --- linux-2.6.32.10/security/commoncap.c 2009-12-03 20:03:02.000000000 +0100
28790 +++ linux-2.6.32.10-vs2.3.0.36.29.2/security/commoncap.c 2010-03-13 21:50:18.000000000 +0100
28792 #include <linux/sched.h>
28793 #include <linux/prctl.h>
28794 #include <linux/securebits.h>
28795 +#include <linux/vs_context.h>
28798 * If a non-root user executes a setuid-root binary in
28799 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
28801 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28803 - NETLINK_CB(skb).eff_cap = current_cap();
28804 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28808 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
28813 EXPORT_SYMBOL(cap_netlink_recv);
28816 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28817 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28820 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28821 + struct vx_info *vxi = tsk->vx_info;
28824 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28825 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28826 + cap_raised(tsk->cap_effective, cap),
28827 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28830 + /* special case SETUP */
28831 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28832 + /* FIXME: maybe use cred instead? */
28833 + cap_raised(tsk->cred->cap_effective, cap))
28836 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28840 @@ -618,7 +635,7 @@ int cap_inode_setxattr(struct dentry *de
28842 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28843 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28844 - !capable(CAP_SYS_ADMIN))
28845 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28849 @@ -644,7 +661,7 @@ int cap_inode_removexattr(struct dentry
28851 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28852 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28853 - !capable(CAP_SYS_ADMIN))
28854 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28858 @@ -962,7 +979,8 @@ error:
28860 int cap_syslog(int type)
28862 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
28863 + if ((type != 3 && type != 10) &&
28864 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28868 diff -NurpP --minimal linux-2.6.32.10/security/selinux/hooks.c linux-2.6.32.10-vs2.3.0.36.29.2/security/selinux/hooks.c
28869 --- linux-2.6.32.10/security/selinux/hooks.c 2010-03-18 16:17:38.000000000 +0100
28870 +++ linux-2.6.32.10-vs2.3.0.36.29.2/security/selinux/hooks.c 2010-02-12 10:59:55.000000000 +0100
28872 #include <linux/dccp.h>
28873 #include <linux/quota.h>
28874 #include <linux/un.h> /* for Unix socket types */
28875 -#include <net/af_unix.h> /* for Unix socket types */
28876 #include <linux/parser.h>
28877 #include <linux/nfs_mount.h>
28878 #include <net/ipv6.h>
28879 diff -NurpP --minimal linux-2.6.32.10/security/selinux/include/av_permissions.h linux-2.6.32.10-vs2.3.0.36.29.2/security/selinux/include/av_permissions.h
28880 --- linux-2.6.32.10/security/selinux/include/av_permissions.h 2009-12-03 20:03:02.000000000 +0100
28881 +++ linux-2.6.32.10-vs2.3.0.36.29.2/security/selinux/include/av_permissions.h 2009-12-03 20:04:56.000000000 +0100
28882 @@ -565,6 +565,7 @@
28883 #define CAPABILITY__SETFCAP 0x80000000UL
28884 #define CAPABILITY2__MAC_OVERRIDE 0x00000001UL
28885 #define CAPABILITY2__MAC_ADMIN 0x00000002UL
28886 +#define CAPABILITY2__CONTEXT 0x00000004UL
28887 #define NETLINK_ROUTE_SOCKET__IOCTL 0x00000001UL
28888 #define NETLINK_ROUTE_SOCKET__READ 0x00000002UL
28889 #define NETLINK_ROUTE_SOCKET__WRITE 0x00000004UL
28890 diff -NurpP --minimal linux-2.6.32.10/security/selinux/include/av_perm_to_string.h linux-2.6.32.10-vs2.3.0.36.29.2/security/selinux/include/av_perm_to_string.h
28891 --- linux-2.6.32.10/security/selinux/include/av_perm_to_string.h 2009-12-03 20:03:02.000000000 +0100
28892 +++ linux-2.6.32.10-vs2.3.0.36.29.2/security/selinux/include/av_perm_to_string.h 2009-12-03 20:04:56.000000000 +0100
28893 @@ -142,6 +142,7 @@
28894 S_(SECCLASS_CAPABILITY, CAPABILITY__SETFCAP, "setfcap")
28895 S_(SECCLASS_CAPABILITY2, CAPABILITY2__MAC_OVERRIDE, "mac_override")
28896 S_(SECCLASS_CAPABILITY2, CAPABILITY2__MAC_ADMIN, "mac_admin")
28897 + S_(SECCLASS_CAPABILITY2, CAPABILITY2__CONTEXT, "context")
28898 S_(SECCLASS_NETLINK_ROUTE_SOCKET, NETLINK_ROUTE_SOCKET__NLMSG_READ, "nlmsg_read")
28899 S_(SECCLASS_NETLINK_ROUTE_SOCKET, NETLINK_ROUTE_SOCKET__NLMSG_WRITE, "nlmsg_write")
28900 S_(SECCLASS_NETLINK_FIREWALL_SOCKET, NETLINK_FIREWALL_SOCKET__NLMSG_READ, "nlmsg_read")