1 diff -NurpP --minimal linux-2.6.33/arch/alpha/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/alpha/Kconfig
2 --- linux-2.6.33/arch/alpha/Kconfig 2010-02-25 11:51:18.000000000 +0100
3 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/Kconfig 2010-02-25 12:02:16.000000000 +0100
4 @@ -675,6 +675,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.33/arch/alpha/kernel/entry.S linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/entry.S
14 --- linux-2.6.33/arch/alpha/kernel/entry.S 2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/entry.S 2010-02-25 12:02:16.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.33/arch/alpha/kernel/osf_sys.c linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.33/arch/alpha/kernel/osf_sys.c 2010-02-25 11:51:19.000000000 +0100
50 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/osf_sys.c 2010-02-25 12:02:16.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.33/arch/alpha/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.33/arch/alpha/kernel/ptrace.c 2009-09-10 15:25:14.000000000 +0200
62 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/ptrace.c 2010-02-25 12:02:16.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.33/arch/alpha/kernel/systbls.S linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/systbls.S
72 --- linux-2.6.33/arch/alpha/kernel/systbls.S 2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/systbls.S 2010-02-25 12:02:16.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.33/arch/alpha/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/traps.c
84 --- linux-2.6.33/arch/alpha/kernel/traps.c 2009-06-11 17:11:46.000000000 +0200
85 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/alpha/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/alpha/mm/fault.c
97 --- linux-2.6.33/arch/alpha/mm/fault.c 2009-09-10 15:25:14.000000000 +0200
98 +++ linux-2.6.33-vs2.3.0.36.30/arch/alpha/mm/fault.c 2010-02-25 12:02:16.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.33/arch/arm/include/asm/tlb.h linux-2.6.33-vs2.3.0.36.30/arch/arm/include/asm/tlb.h
111 --- linux-2.6.33/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
112 +++ linux-2.6.33-vs2.3.0.36.30/arch/arm/include/asm/tlb.h 2010-02-25 12:02:16.000000000 +0100
115 #else /* !CONFIG_MMU */
117 +#include <linux/vs_memory.h>
118 #include <asm/pgalloc.h>
121 diff -NurpP --minimal linux-2.6.33/arch/arm/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/arm/Kconfig
122 --- linux-2.6.33/arch/arm/Kconfig 2010-02-25 11:51:19.000000000 +0100
123 +++ linux-2.6.33-vs2.3.0.36.30/arch/arm/Kconfig 2010-02-25 12:02:16.000000000 +0100
124 @@ -1542,6 +1542,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.33/arch/arm/kernel/calls.S linux-2.6.33-vs2.3.0.36.30/arch/arm/kernel/calls.S
134 --- linux-2.6.33/arch/arm/kernel/calls.S 2010-02-25 11:51:20.000000000 +0100
135 +++ linux-2.6.33-vs2.3.0.36.30/arch/arm/kernel/calls.S 2010-02-25 12:02:16.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.33/arch/arm/kernel/process.c linux-2.6.33-vs2.3.0.36.30/arch/arm/kernel/process.c
146 --- linux-2.6.33/arch/arm/kernel/process.c 2010-02-25 11:51:20.000000000 +0100
147 +++ linux-2.6.33-vs2.3.0.36.30/arch/arm/kernel/process.c 2010-02-25 12:02:16.000000000 +0100
148 @@ -270,7 +270,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.33/arch/arm/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/arm/kernel/traps.c
159 --- linux-2.6.33/arch/arm/kernel/traps.c 2009-12-03 20:01:50.000000000 +0100
160 +++ linux-2.6.33-vs2.3.0.36.30/arch/arm/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/avr32/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/avr32/mm/fault.c
173 --- linux-2.6.33/arch/avr32/mm/fault.c 2009-09-10 15:25:20.000000000 +0200
174 +++ linux-2.6.33-vs2.3.0.36.30/arch/avr32/mm/fault.c 2010-02-25 12:02:16.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.33/arch/cris/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/cris/Kconfig
186 --- linux-2.6.33/arch/cris/Kconfig 2009-06-11 17:11:56.000000000 +0200
187 +++ linux-2.6.33-vs2.3.0.36.30/arch/cris/Kconfig 2010-02-25 12:02:16.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.33/arch/cris/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/cris/mm/fault.c
198 --- linux-2.6.33/arch/cris/mm/fault.c 2010-02-25 11:51:26.000000000 +0100
199 +++ linux-2.6.33-vs2.3.0.36.30/arch/cris/mm/fault.c 2010-02-25 12:02:16.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.33/arch/frv/kernel/kernel_thread.S linux-2.6.33-vs2.3.0.36.30/arch/frv/kernel/kernel_thread.S
211 --- linux-2.6.33/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
212 +++ linux-2.6.33-vs2.3.0.36.30/arch/frv/kernel/kernel_thread.S 2010-02-25 12:02:16.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.33/arch/frv/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/frv/mm/fault.c
223 --- linux-2.6.33/arch/frv/mm/fault.c 2009-09-10 15:25:22.000000000 +0200
224 +++ linux-2.6.33-vs2.3.0.36.30/arch/frv/mm/fault.c 2010-02-25 12:02:16.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.33/arch/h8300/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/h8300/Kconfig
236 --- linux-2.6.33/arch/h8300/Kconfig 2010-02-25 11:51:26.000000000 +0100
237 +++ linux-2.6.33-vs2.3.0.36.30/arch/h8300/Kconfig 2010-02-25 12:02:16.000000000 +0100
238 @@ -230,6 +230,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.33/arch/ia64/ia32/ia32_entry.S linux-2.6.33-vs2.3.0.36.30/arch/ia64/ia32/ia32_entry.S
248 --- linux-2.6.33/arch/ia64/ia32/ia32_entry.S 2010-02-25 11:51:26.000000000 +0100
249 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/ia32/ia32_entry.S 2010-02-25 12:02:16.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.33/arch/ia64/include/asm/tlb.h linux-2.6.33-vs2.3.0.36.30/arch/ia64/include/asm/tlb.h
260 --- linux-2.6.33/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
261 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/include/asm/tlb.h 2010-02-25 12:02:16.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.33/arch/ia64/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/ia64/Kconfig
271 --- linux-2.6.33/arch/ia64/Kconfig 2010-02-25 11:51:26.000000000 +0100
272 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/Kconfig 2010-02-25 12:02:16.000000000 +0100
273 @@ -682,6 +682,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.33/arch/ia64/kernel/entry.S linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/entry.S
283 --- linux-2.6.33/arch/ia64/kernel/entry.S 2010-02-25 11:51:26.000000000 +0100
284 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/entry.S 2010-02-25 12:02:16.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.33/arch/ia64/kernel/perfmon.c linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/perfmon.c
295 --- linux-2.6.33/arch/ia64/kernel/perfmon.c 2010-02-25 11:51:26.000000000 +0100
296 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/perfmon.c 2010-02-25 12:02:16.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 @@ -2367,7 +2368,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.33/arch/ia64/kernel/process.c linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/process.c
315 --- linux-2.6.33/arch/ia64/kernel/process.c 2009-12-03 20:01:56.000000000 +0100
316 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/process.c 2010-02-25 12:02:16.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.33/arch/ia64/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/ptrace.c
329 --- linux-2.6.33/arch/ia64/kernel/ptrace.c 2009-09-10 15:25:22.000000000 +0200
330 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/ptrace.c 2010-02-25 12:02:16.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.33/arch/ia64/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/traps.c
340 --- linux-2.6.33/arch/ia64/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
341 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/ia64/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/ia64/mm/fault.c
367 --- linux-2.6.33/arch/ia64/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
368 +++ linux-2.6.33-vs2.3.0.36.30/arch/ia64/mm/fault.c 2010-02-25 12:02:16.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.33/arch/m32r/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/m32r/kernel/traps.c
388 --- linux-2.6.33/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
389 +++ linux-2.6.33-vs2.3.0.36.30/arch/m32r/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/m32r/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/m32r/mm/fault.c
403 --- linux-2.6.33/arch/m32r/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.33-vs2.3.0.36.30/arch/m32r/mm/fault.c 2010-02-25 12:02:16.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.33/arch/m68k/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/m68k/Kconfig
416 --- linux-2.6.33/arch/m68k/Kconfig 2009-12-03 20:01:57.000000000 +0100
417 +++ linux-2.6.33-vs2.3.0.36.30/arch/m68k/Kconfig 2010-02-25 12:02:16.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.33/arch/m68k/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30/arch/m68k/kernel/ptrace.c
428 --- linux-2.6.33/arch/m68k/kernel/ptrace.c 2010-02-25 11:51:27.000000000 +0100
429 +++ linux-2.6.33-vs2.3.0.36.30/arch/m68k/kernel/ptrace.c 2010-02-25 12:02:16.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 @@ -249,6 +250,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.33/arch/m68k/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/m68k/kernel/traps.c
448 --- linux-2.6.33/arch/m68k/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
449 +++ linux-2.6.33-vs2.3.0.36.30/arch/m68k/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/m68k/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/m68k/mm/fault.c
462 --- linux-2.6.33/arch/m68k/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
463 +++ linux-2.6.33-vs2.3.0.36.30/arch/m68k/mm/fault.c 2010-02-25 12:02:16.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.33/arch/m68knommu/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/m68knommu/Kconfig
475 --- linux-2.6.33/arch/m68knommu/Kconfig 2010-02-25 11:51:27.000000000 +0100
476 +++ linux-2.6.33-vs2.3.0.36.30/arch/m68knommu/Kconfig 2010-02-25 12:02:16.000000000 +0100
477 @@ -734,6 +734,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.33/arch/m68knommu/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/m68knommu/kernel/traps.c
487 --- linux-2.6.33/arch/m68knommu/kernel/traps.c 2009-09-10 15:25:23.000000000 +0200
488 +++ linux-2.6.33-vs2.3.0.36.30/arch/m68knommu/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/microblaze/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/microblaze/mm/fault.c
502 --- linux-2.6.33/arch/microblaze/mm/fault.c 2009-09-10 15:25:24.000000000 +0200
503 +++ linux-2.6.33-vs2.3.0.36.30/arch/microblaze/mm/fault.c 2010-02-25 12:02:16.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.33/arch/mips/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/mips/Kconfig
515 --- linux-2.6.33/arch/mips/Kconfig 2010-02-25 11:51:27.000000000 +0100
516 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/Kconfig 2010-02-25 12:02:16.000000000 +0100
517 @@ -2220,6 +2220,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.33/arch/mips/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/ptrace.c
527 --- linux-2.6.33/arch/mips/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
528 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/ptrace.c 2010-02-25 12:02:16.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.33/arch/mips/kernel/scall32-o32.S linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall32-o32.S
548 --- linux-2.6.33/arch/mips/kernel/scall32-o32.S 2010-02-25 11:51:28.000000000 +0100
549 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall32-o32.S 2010-02-25 12:02:16.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.33/arch/mips/kernel/scall64-64.S linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall64-64.S
560 --- linux-2.6.33/arch/mips/kernel/scall64-64.S 2010-02-25 11:51:28.000000000 +0100
561 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall64-64.S 2010-02-25 12:02:16.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.33/arch/mips/kernel/scall64-n32.S linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall64-n32.S
572 --- linux-2.6.33/arch/mips/kernel/scall64-n32.S 2010-02-25 11:51:28.000000000 +0100
573 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall64-n32.S 2010-02-25 12:02:16.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.33/arch/mips/kernel/scall64-o32.S linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall64-o32.S
584 --- linux-2.6.33/arch/mips/kernel/scall64-o32.S 2010-02-25 11:51:28.000000000 +0100
585 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/scall64-o32.S 2010-02-25 12:02:16.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.33/arch/mips/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/traps.c
596 --- linux-2.6.33/arch/mips/kernel/traps.c 2010-02-25 11:51:28.000000000 +0100
597 +++ linux-2.6.33-vs2.3.0.36.30/arch/mips/kernel/traps.c 2010-02-25 12:02:16.000000000 +0100
598 @@ -333,9 +333,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.33/arch/mn10300/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/mn10300/mm/fault.c
613 --- linux-2.6.33/arch/mn10300/mm/fault.c 2009-09-10 15:25:39.000000000 +0200
614 +++ linux-2.6.33-vs2.3.0.36.30/arch/mn10300/mm/fault.c 2010-02-25 12:02:16.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.33/arch/parisc/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/parisc/Kconfig
626 --- linux-2.6.33/arch/parisc/Kconfig 2010-02-25 11:51:29.000000000 +0100
627 +++ linux-2.6.33-vs2.3.0.36.30/arch/parisc/Kconfig 2010-02-25 12:02:16.000000000 +0100
628 @@ -293,6 +293,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.33/arch/parisc/kernel/syscall_table.S linux-2.6.33-vs2.3.0.36.30/arch/parisc/kernel/syscall_table.S
638 --- linux-2.6.33/arch/parisc/kernel/syscall_table.S 2010-02-25 11:51:29.000000000 +0100
639 +++ linux-2.6.33-vs2.3.0.36.30/arch/parisc/kernel/syscall_table.S 2010-02-25 12:02:16.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.33/arch/parisc/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/parisc/kernel/traps.c
650 --- linux-2.6.33/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
651 +++ linux-2.6.33-vs2.3.0.36.30/arch/parisc/kernel/traps.c 2010-02-25 12:02:16.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.33/arch/parisc/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/parisc/mm/fault.c
676 --- linux-2.6.33/arch/parisc/mm/fault.c 2009-09-10 15:25:40.000000000 +0200
677 +++ linux-2.6.33-vs2.3.0.36.30/arch/parisc/mm/fault.c 2010-02-25 12:02:16.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.33/arch/powerpc/include/asm/unistd.h linux-2.6.33-vs2.3.0.36.30/arch/powerpc/include/asm/unistd.h
701 --- linux-2.6.33/arch/powerpc/include/asm/unistd.h 2009-12-03 20:02:01.000000000 +0100
702 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/include/asm/unistd.h 2010-02-25 12:02:16.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.33/arch/powerpc/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/powerpc/Kconfig
713 --- linux-2.6.33/arch/powerpc/Kconfig 2010-02-25 11:51:29.000000000 +0100
714 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/Kconfig 2010-02-25 12:02:16.000000000 +0100
715 @@ -968,6 +968,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.33/arch/powerpc/kernel/irq.c linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/irq.c
725 --- linux-2.6.33/arch/powerpc/kernel/irq.c 2010-02-25 11:51:31.000000000 +0100
726 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/irq.c 2010-02-25 12:02:16.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.33/arch/powerpc/kernel/process.c linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/process.c
736 --- linux-2.6.33/arch/powerpc/kernel/process.c 2010-02-25 11:51:31.000000000 +0100
737 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/process.c 2010-02-25 12:02:16.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.33/arch/powerpc/kernel/traps.c linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/traps.c
751 --- linux-2.6.33/arch/powerpc/kernel/traps.c 2010-02-25 11:51:31.000000000 +0100
752 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/traps.c 2010-02-25 12:02:16.000000000 +0100
753 @@ -918,8 +918,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.33/arch/powerpc/kernel/vdso.c linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/vdso.c
766 --- linux-2.6.33/arch/powerpc/kernel/vdso.c 2010-02-25 11:51:31.000000000 +0100
767 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/kernel/vdso.c 2010-02-25 12:02:16.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.33/arch/powerpc/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/powerpc/mm/fault.c
777 --- linux-2.6.33/arch/powerpc/mm/fault.c 2010-02-25 11:51:31.000000000 +0100
778 +++ linux-2.6.33-vs2.3.0.36.30/arch/powerpc/mm/fault.c 2010-02-25 12:02:16.000000000 +0100
779 @@ -364,7 +364,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.33/arch/s390/include/asm/tlb.h linux-2.6.33-vs2.3.0.36.30/arch/s390/include/asm/tlb.h
790 --- linux-2.6.33/arch/s390/include/asm/tlb.h 2009-09-10 15:25:43.000000000 +0200
791 +++ linux-2.6.33-vs2.3.0.36.30/arch/s390/include/asm/tlb.h 2010-02-25 12:02:16.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.33/arch/s390/include/asm/unistd.h linux-2.6.33-vs2.3.0.36.30/arch/s390/include/asm/unistd.h
802 --- linux-2.6.33/arch/s390/include/asm/unistd.h 2010-02-25 11:51:32.000000000 +0100
803 +++ linux-2.6.33-vs2.3.0.36.30/arch/s390/include/asm/unistd.h 2010-02-25 12:02:16.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.33/arch/s390/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/s390/Kconfig
814 --- linux-2.6.33/arch/s390/Kconfig 2010-02-25 11:51:32.000000000 +0100
815 +++ linux-2.6.33-vs2.3.0.36.30/arch/s390/Kconfig 2010-02-25 12:02:16.000000000 +0100
816 @@ -629,6 +629,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.33/arch/s390/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30/arch/s390/kernel/ptrace.c
826 --- linux-2.6.33/arch/s390/kernel/ptrace.c 2010-02-25 11:51:32.000000000 +0100
827 +++ linux-2.6.33-vs2.3.0.36.30/arch/s390/kernel/ptrace.c 2010-02-25 12:02:16.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.33/arch/s390/kernel/syscalls.S linux-2.6.33-vs2.3.0.36.30/arch/s390/kernel/syscalls.S
837 --- linux-2.6.33/arch/s390/kernel/syscalls.S 2009-12-03 20:02:03.000000000 +0100
838 +++ linux-2.6.33-vs2.3.0.36.30/arch/s390/kernel/syscalls.S 2010-02-25 12:02:16.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.33/arch/sh/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/sh/Kconfig
849 --- linux-2.6.33/arch/sh/Kconfig 2010-02-25 11:51:32.000000000 +0100
850 +++ linux-2.6.33-vs2.3.0.36.30/arch/sh/Kconfig 2010-02-25 12:02:16.000000000 +0100
851 @@ -860,6 +860,8 @@ source "fs/Kconfig"
853 source "arch/sh/Kconfig.debug"
855 +source "kernel/vserver/Kconfig"
857 source "security/Kconfig"
859 source "crypto/Kconfig"
860 diff -NurpP --minimal linux-2.6.33/arch/sh/kernel/irq.c linux-2.6.33-vs2.3.0.36.30/arch/sh/kernel/irq.c
861 --- linux-2.6.33/arch/sh/kernel/irq.c 2010-02-25 11:51:33.000000000 +0100
862 +++ linux-2.6.33-vs2.3.0.36.30/arch/sh/kernel/irq.c 2010-02-25 12:02:16.000000000 +0100
864 #include <linux/kernel_stat.h>
865 #include <linux/seq_file.h>
866 #include <linux/ftrace.h>
867 +// #include <linux/vs_context.h>
868 #include <asm/processor.h>
869 #include <asm/machvec.h>
870 #include <asm/uaccess.h>
871 diff -NurpP --minimal linux-2.6.33/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.33-vs2.3.0.36.30/arch/sh/kernel/vsyscall/vsyscall.c
872 --- linux-2.6.33/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:18:42.000000000 +0100
873 +++ linux-2.6.33-vs2.3.0.36.30/arch/sh/kernel/vsyscall/vsyscall.c 2010-02-25 12:02:16.000000000 +0100
875 #include <linux/elf.h>
876 #include <linux/sched.h>
877 #include <linux/err.h>
878 +#include <linux/vs_memory.h>
881 * Should the kernel map a VDSO page into processes and pass its
882 diff -NurpP --minimal linux-2.6.33/arch/sh/mm/fault_32.c linux-2.6.33-vs2.3.0.36.30/arch/sh/mm/fault_32.c
883 --- linux-2.6.33/arch/sh/mm/fault_32.c 2009-12-03 20:02:14.000000000 +0100
884 +++ linux-2.6.33-vs2.3.0.36.30/arch/sh/mm/fault_32.c 2010-02-25 12:02:16.000000000 +0100
885 @@ -292,7 +292,8 @@ out_of_memory:
886 down_read(&mm->mmap_sem);
889 - printk("VM: killing process %s\n", tsk->comm);
890 + printk("VM: killing process %s(%d:#%u)\n",
891 + tsk->comm, task_pid_nr(tsk), tsk->xid);
893 do_group_exit(SIGKILL);
895 diff -NurpP --minimal linux-2.6.33/arch/sh/mm/tlbflush_64.c linux-2.6.33-vs2.3.0.36.30/arch/sh/mm/tlbflush_64.c
896 --- linux-2.6.33/arch/sh/mm/tlbflush_64.c 2009-12-03 20:02:14.000000000 +0100
897 +++ linux-2.6.33-vs2.3.0.36.30/arch/sh/mm/tlbflush_64.c 2010-02-25 12:02:16.000000000 +0100
898 @@ -306,7 +306,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.33/arch/sparc/include/asm/tlb_64.h linux-2.6.33-vs2.3.0.36.30/arch/sparc/include/asm/tlb_64.h
909 --- linux-2.6.33/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
910 +++ linux-2.6.33-vs2.3.0.36.30/arch/sparc/include/asm/tlb_64.h 2010-02-25 12:02:16.000000000 +0100
913 #include <linux/swap.h>
914 #include <linux/pagemap.h>
915 +#include <linux/vs_memory.h>
916 #include <asm/pgalloc.h>
917 #include <asm/tlbflush.h>
918 #include <asm/mmu_context.h>
919 diff -NurpP --minimal linux-2.6.33/arch/sparc/include/asm/unistd.h linux-2.6.33-vs2.3.0.36.30/arch/sparc/include/asm/unistd.h
920 --- linux-2.6.33/arch/sparc/include/asm/unistd.h 2010-02-25 11:51:34.000000000 +0100
921 +++ linux-2.6.33-vs2.3.0.36.30/arch/sparc/include/asm/unistd.h 2010-02-25 12:02:16.000000000 +0100
923 #define __NR_timer_getoverrun 264
924 #define __NR_timer_delete 265
925 #define __NR_timer_create 266
926 -/* #define __NR_vserver 267 Reserved for VSERVER */
927 +#define __NR_vserver 267
928 #define __NR_io_setup 268
929 #define __NR_io_destroy 269
930 #define __NR_io_submit 270
931 diff -NurpP --minimal linux-2.6.33/arch/sparc/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/sparc/Kconfig
932 --- linux-2.6.33/arch/sparc/Kconfig 2010-02-25 11:51:33.000000000 +0100
933 +++ linux-2.6.33-vs2.3.0.36.30/arch/sparc/Kconfig 2010-02-25 12:02:16.000000000 +0100
934 @@ -561,6 +561,8 @@ source "fs/Kconfig"
936 source "arch/sparc/Kconfig.debug"
938 +source "kernel/vserver/Kconfig"
940 source "security/Kconfig"
942 source "crypto/Kconfig"
943 diff -NurpP --minimal linux-2.6.33/arch/sparc/kernel/systbls_32.S linux-2.6.33-vs2.3.0.36.30/arch/sparc/kernel/systbls_32.S
944 --- linux-2.6.33/arch/sparc/kernel/systbls_32.S 2010-02-25 11:51:34.000000000 +0100
945 +++ linux-2.6.33-vs2.3.0.36.30/arch/sparc/kernel/systbls_32.S 2010-02-25 12:02:16.000000000 +0100
946 @@ -70,7 +70,7 @@ sys_call_table:
947 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
948 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
949 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
950 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
951 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
952 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
953 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
954 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
955 diff -NurpP --minimal linux-2.6.33/arch/sparc/kernel/systbls_64.S linux-2.6.33-vs2.3.0.36.30/arch/sparc/kernel/systbls_64.S
956 --- linux-2.6.33/arch/sparc/kernel/systbls_64.S 2010-02-25 11:51:34.000000000 +0100
957 +++ linux-2.6.33-vs2.3.0.36.30/arch/sparc/kernel/systbls_64.S 2010-02-25 12:02:16.000000000 +0100
958 @@ -71,7 +71,7 @@ sys_call_table32:
959 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
960 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
961 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
962 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
963 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
964 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
965 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
966 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
967 @@ -146,7 +146,7 @@ sys_call_table:
968 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
969 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
970 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
971 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
972 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
973 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
974 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
975 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
976 diff -NurpP --minimal linux-2.6.33/arch/x86/ia32/ia32entry.S linux-2.6.33-vs2.3.0.36.30/arch/x86/ia32/ia32entry.S
977 --- linux-2.6.33/arch/x86/ia32/ia32entry.S 2010-02-25 11:51:34.000000000 +0100
978 +++ linux-2.6.33-vs2.3.0.36.30/arch/x86/ia32/ia32entry.S 2010-02-25 12:02:16.000000000 +0100
979 @@ -777,7 +777,7 @@ ia32_sys_call_table:
980 .quad sys_tgkill /* 270 */
981 .quad compat_sys_utimes
982 .quad sys32_fadvise64_64
983 - .quad quiet_ni_syscall /* sys_vserver */
984 + .quad sys32_vserver
986 .quad compat_sys_get_mempolicy /* 275 */
987 .quad sys_set_mempolicy
988 diff -NurpP --minimal linux-2.6.33/arch/x86/include/asm/unistd_64.h linux-2.6.33-vs2.3.0.36.30/arch/x86/include/asm/unistd_64.h
989 --- linux-2.6.33/arch/x86/include/asm/unistd_64.h 2010-02-25 11:51:34.000000000 +0100
990 +++ linux-2.6.33-vs2.3.0.36.30/arch/x86/include/asm/unistd_64.h 2010-02-25 12:02:16.000000000 +0100
991 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
992 #define __NR_utimes 235
993 __SYSCALL(__NR_utimes, sys_utimes)
994 #define __NR_vserver 236
995 -__SYSCALL(__NR_vserver, sys_ni_syscall)
996 +__SYSCALL(__NR_vserver, sys_vserver)
997 #define __NR_mbind 237
998 __SYSCALL(__NR_mbind, sys_mbind)
999 #define __NR_set_mempolicy 238
1000 diff -NurpP --minimal linux-2.6.33/arch/x86/Kconfig linux-2.6.33-vs2.3.0.36.30/arch/x86/Kconfig
1001 --- linux-2.6.33/arch/x86/Kconfig 2010-02-25 11:51:34.000000000 +0100
1002 +++ linux-2.6.33-vs2.3.0.36.30/arch/x86/Kconfig 2010-02-25 12:02:16.000000000 +0100
1003 @@ -2083,6 +2083,8 @@ source "fs/Kconfig"
1005 source "arch/x86/Kconfig.debug"
1007 +source "kernel/vserver/Kconfig"
1009 source "security/Kconfig"
1011 source "crypto/Kconfig"
1012 diff -NurpP --minimal linux-2.6.33/arch/x86/kernel/syscall_table_32.S linux-2.6.33-vs2.3.0.36.30/arch/x86/kernel/syscall_table_32.S
1013 --- linux-2.6.33/arch/x86/kernel/syscall_table_32.S 2010-02-25 11:51:35.000000000 +0100
1014 +++ linux-2.6.33-vs2.3.0.36.30/arch/x86/kernel/syscall_table_32.S 2010-02-25 12:02:16.000000000 +0100
1015 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1016 .long sys_tgkill /* 270 */
1018 .long sys_fadvise64_64
1019 - .long sys_ni_syscall /* sys_vserver */
1022 .long sys_get_mempolicy
1023 .long sys_set_mempolicy
1024 diff -NurpP --minimal linux-2.6.33/arch/xtensa/mm/fault.c linux-2.6.33-vs2.3.0.36.30/arch/xtensa/mm/fault.c
1025 --- linux-2.6.33/arch/xtensa/mm/fault.c 2009-09-10 15:25:48.000000000 +0200
1026 +++ linux-2.6.33-vs2.3.0.36.30/arch/xtensa/mm/fault.c 2010-02-25 12:02:16.000000000 +0100
1027 @@ -151,7 +151,8 @@ out_of_memory:
1028 down_read(&mm->mmap_sem);
1031 - printk("VM: killing process %s\n", current->comm);
1032 + printk("VM: killing process %s(%d:#%u)\n",
1033 + current->comm, task_pid_nr(current), current->xid);
1034 if (user_mode(regs))
1035 do_group_exit(SIGKILL);
1036 bad_page_fault(regs, address, SIGKILL);
1037 diff -NurpP --minimal linux-2.6.33/Documentation/scheduler/sched-cfs-hard-limits.txt linux-2.6.33-vs2.3.0.36.30/Documentation/scheduler/sched-cfs-hard-limits.txt
1038 --- linux-2.6.33/Documentation/scheduler/sched-cfs-hard-limits.txt 1970-01-01 01:00:00.000000000 +0100
1039 +++ linux-2.6.33-vs2.3.0.36.30/Documentation/scheduler/sched-cfs-hard-limits.txt 2010-02-25 12:02:16.000000000 +0100
1041 +CPU HARD LIMITS FOR CFS GROUPS
1042 +==============================
1051 +CFS is a proportional share scheduler which tries to divide the CPU time
1052 +proportionately between tasks or groups of tasks (task group/cgroup) depending
1053 +on the priority/weight of the task or shares assigned to groups of tasks.
1054 +In CFS, a task/task group can get more than its share of CPU if there are
1055 +enough idle CPU cycles available in the system, due to the work conserving
1056 +nature of the scheduler. However in certain scenarios (like pay-per-use),
1057 +it is desirable not to provide extra time to a group even in the presence
1058 +of idle CPU cycles. This is where hard limiting can be of use.
1060 +Hard limits for task groups can be set by specifying how much CPU runtime a
1061 +group can consume within a given period. If the group consumes more CPU time
1062 +than the runtime in a given period, it gets throttled. None of the tasks of
1063 +the throttled group gets to run until the runtime of the group gets refreshed
1064 +at the beginning of the next period.
1069 +Hard limit feature adds 2 cgroup files for CFS group scheduler:
1071 +cfs_runtime_us: Hard limit for the group in microseconds.
1073 +cfs_period_us: Time period in microseconds within which hard limits is
1076 +A group gets created with default values for runtime (infinite runtime which
1077 +means hard limits disabled) and period (0.5s). Each group can set its own
1078 +values for runtime and period independent of other groups in the system.
1083 +# mount -t cgroup -ocpu none /cgroups/
1087 +# echo 250000 > cfs_runtime_us /* set a 250ms runtime or limit */
1088 +# echo 500000 > cfs_period_us /* set a 500ms period */
1089 diff -NurpP --minimal linux-2.6.33/Documentation/vserver/debug.txt linux-2.6.33-vs2.3.0.36.30/Documentation/vserver/debug.txt
1090 --- linux-2.6.33/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1091 +++ linux-2.6.33-vs2.3.0.36.30/Documentation/vserver/debug.txt 2010-02-25 12:02:16.000000000 +0100
1096 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1097 + "vx_rmap_tgid: %p/%llx: %d -> %d"
1101 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
1102 + "FREE (%p,#%d)%c inode"
1103 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1104 + "FREE (%p,#%d)%c %lld bytes"
1105 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1106 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1107 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1108 + "rcu_free_dl_info(%p)"
1109 + 4 10 "alloc_dl_info(%p,%d) = %p"
1110 + "dealloc_dl_info(%p)"
1111 + "get_dl_info(%p[#%d.%d])"
1112 + "put_dl_info(%p[#%d.%d])"
1113 + 5 20 "alloc_dl_info(%p,%d)*"
1114 + 6 40 "__hash_dl_info: %p[#%d]"
1115 + "__unhash_dl_info: %p[#%d]"
1116 + 7 80 "locate_dl_info(%p,#%d) = %p"
1120 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
1121 + "new_dqhash: %p [#0x%08x]"
1122 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1123 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1124 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1125 + "vroot_get_real_bdev not set"
1126 + 1 2 "cow_break_link(»%s«)"
1127 + "temp copy »%s«"
1128 + 2 4 "dentry_open(new): %p"
1129 + "dentry_open(old): %p"
1130 + "lookup_create(new): %p"
1132 + "path_lookup(old): %d"
1133 + "vfs_create(new): %d"
1135 + "vfs_sendfile: %d"
1136 + 3 8 "fput(new_file=%p[#%d])"
1137 + "fput(old_file=%p[#%d])"
1138 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1139 + "vx_info_kill(%p[#%d],%d,%d)*"
1140 + 5 20 "vs_reboot(%p[#%d],%d)"
1141 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1145 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1146 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1147 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
1148 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
1149 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
1150 + 6 40 "sk,egf: %p [#%d] (from %d)"
1151 + "sk,egn: %p [#%d] (from %d)"
1152 + "sk,req: %p [#%d] (from %d)"
1153 + "sk: %p [#%d] (from %d)"
1154 + "tw: %p [#%d] (from %d)"
1155 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
1156 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
1160 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
1161 + "alloc_nx_info(%d) = %p"
1162 + "create_nx_info(%d) (dynamic rejected)"
1163 + "create_nx_info(%d) = %p (already there)"
1164 + "create_nx_info(%d) = %p (new)"
1165 + "dealloc_nx_info(%p)"
1166 + 1 2 "alloc_nx_info(%d)*"
1167 + "create_nx_info(%d)*"
1168 + 2 4 "get_nx_info(%p[#%d.%d])"
1169 + "put_nx_info(%p[#%d.%d])"
1170 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1171 + "clr_nx_info(%p[#%d.%d])"
1172 + "init_nx_info(%p[#%d.%d])"
1173 + "release_nx_info(%p[#%d.%d.%d]) %p"
1174 + "set_nx_info(%p[#%d.%d])"
1175 + 4 10 "__hash_nx_info: %p[#%d]"
1176 + "__nx_dynamic_id: [#%d]"
1177 + "__unhash_nx_info: %p[#%d.%d.%d]"
1178 + 5 20 "moved task %p into nxi:%p[#%d]"
1179 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
1180 + "task_get_nx_info(%p)"
1181 + 6 40 "nx_clear_persistent(%p[#%d])"
1185 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
1186 + 1 2 "quota_sync_dqh(%p,%d)"
1187 + "sync_dquots(%p,%d)"
1188 + "sync_dquots_dqh(%p,%d)"
1189 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1193 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1194 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1195 + 4 10 "%s: (%s %s) returned %s with %d"
1199 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1200 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1204 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1205 + "alloc_vx_info(%d) = %p"
1206 + "alloc_vx_info(%d)*"
1207 + "create_vx_info(%d) (dynamic rejected)"
1208 + "create_vx_info(%d) = %p (already there)"
1209 + "create_vx_info(%d) = %p (new)"
1210 + "dealloc_vx_info(%p)"
1211 + "loc_vx_info(%d) = %p (found)"
1212 + "loc_vx_info(%d) = %p (new)"
1213 + "loc_vx_info(%d) = %p (not available)"
1214 + 1 2 "create_vx_info(%d)*"
1215 + "loc_vx_info(%d)*"
1216 + 2 4 "get_vx_info(%p[#%d.%d])"
1217 + "put_vx_info(%p[#%d.%d])"
1218 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1219 + "clr_vx_info(%p[#%d.%d])"
1220 + "init_vx_info(%p[#%d.%d])"
1221 + "release_vx_info(%p[#%d.%d.%d]) %p"
1222 + "set_vx_info(%p[#%d.%d])"
1223 + 4 10 "__hash_vx_info: %p[#%d]"
1224 + "__unhash_vx_info: %p[#%d.%d.%d]"
1225 + "__vx_dynamic_id: [#%d]"
1226 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1227 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1228 + "moved task %p into vxi:%p[#%d]"
1229 + "task_get_vx_info(%p)"
1230 + "vx_migrate_task(%p,%p[#%d.%d])"
1231 + 6 40 "vx_clear_persistent(%p[#%d])"
1232 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1233 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1234 + "vx_set_persistent(%p[#%d])"
1235 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1236 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1241 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1242 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1244 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1245 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1246 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1247 diff -NurpP --minimal linux-2.6.33/drivers/block/Kconfig linux-2.6.33-vs2.3.0.36.30/drivers/block/Kconfig
1248 --- linux-2.6.33/drivers/block/Kconfig 2010-02-25 11:51:36.000000000 +0100
1249 +++ linux-2.6.33-vs2.3.0.36.30/drivers/block/Kconfig 2010-02-25 12:02:16.000000000 +0100
1250 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1252 source "drivers/block/drbd/Kconfig"
1254 +config BLK_DEV_VROOT
1255 + tristate "Virtual Root device support"
1256 + depends on QUOTACTL
1258 + Saying Y here will allow you to use quota/fs ioctls on a shared
1259 + partition within a virtual server without compromising security.
1262 tristate "Network block device support"
1264 diff -NurpP --minimal linux-2.6.33/drivers/block/loop.c linux-2.6.33-vs2.3.0.36.30/drivers/block/loop.c
1265 --- linux-2.6.33/drivers/block/loop.c 2009-12-03 20:02:19.000000000 +0100
1266 +++ linux-2.6.33-vs2.3.0.36.30/drivers/block/loop.c 2010-02-25 12:02:16.000000000 +0100
1268 #include <linux/gfp.h>
1269 #include <linux/kthread.h>
1270 #include <linux/splice.h>
1271 +#include <linux/vs_context.h>
1273 #include <asm/uaccess.h>
1275 @@ -812,6 +813,7 @@ static int loop_set_fd(struct loop_devic
1276 lo->lo_blocksize = lo_blocksize;
1277 lo->lo_device = bdev;
1278 lo->lo_flags = lo_flags;
1279 + lo->lo_xid = vx_current_xid();
1280 lo->lo_backing_file = file;
1281 lo->transfer = transfer_none;
1283 @@ -937,6 +939,7 @@ static int loop_clr_fd(struct loop_devic
1284 lo->lo_encrypt_key_size = 0;
1286 lo->lo_thread = NULL;
1288 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1289 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1290 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1291 @@ -971,7 +974,7 @@ loop_set_status(struct loop_device *lo,
1293 if (lo->lo_encrypt_key_size &&
1294 lo->lo_key_owner != uid &&
1295 - !capable(CAP_SYS_ADMIN))
1296 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1298 if (lo->lo_state != Lo_bound)
1300 @@ -1055,7 +1058,8 @@ loop_get_status(struct loop_device *lo,
1301 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1302 info->lo_encrypt_type =
1303 lo->lo_encryption ? lo->lo_encryption->number : 0;
1304 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1305 + if (lo->lo_encrypt_key_size &&
1306 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1307 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1308 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1309 lo->lo_encrypt_key_size);
1310 @@ -1399,6 +1403,9 @@ static int lo_open(struct block_device *
1312 struct loop_device *lo = bdev->bd_disk->private_data;
1314 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1317 mutex_lock(&lo->lo_ctl_mutex);
1319 mutex_unlock(&lo->lo_ctl_mutex);
1320 diff -NurpP --minimal linux-2.6.33/drivers/block/Makefile linux-2.6.33-vs2.3.0.36.30/drivers/block/Makefile
1321 --- linux-2.6.33/drivers/block/Makefile 2010-02-25 11:51:36.000000000 +0100
1322 +++ linux-2.6.33-vs2.3.0.36.30/drivers/block/Makefile 2010-02-25 12:02:16.000000000 +0100
1323 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1324 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1325 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1326 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1327 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1329 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1330 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
1331 diff -NurpP --minimal linux-2.6.33/drivers/block/vroot.c linux-2.6.33-vs2.3.0.36.30/drivers/block/vroot.c
1332 --- linux-2.6.33/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1333 +++ linux-2.6.33-vs2.3.0.36.30/drivers/block/vroot.c 2010-02-25 12:02:16.000000000 +0100
1336 + * linux/drivers/block/vroot.c
1338 + * written by Herbert Pötzl, 9/11/2002
1339 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1341 + * based on the loop.c code by Theodore Ts'o.
1343 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1344 + * Redistribution of this file is permitted under the
1345 + * GNU General Public License.
1349 +#include <linux/module.h>
1350 +#include <linux/moduleparam.h>
1351 +#include <linux/file.h>
1352 +#include <linux/major.h>
1353 +#include <linux/blkdev.h>
1355 +#include <linux/vroot.h>
1356 +#include <linux/vs_context.h>
1359 +static int max_vroot = 8;
1361 +static struct vroot_device *vroot_dev;
1362 +static struct gendisk **disks;
1365 +static int vroot_set_dev(
1366 + struct vroot_device *vr,
1367 + struct block_device *bdev,
1370 + struct block_device *real_bdev;
1371 + struct file *file;
1372 + struct inode *inode;
1376 + if (vr->vr_state != Vr_unbound)
1385 + inode = file->f_dentry->d_inode;
1388 + if (S_ISBLK(inode->i_mode)) {
1389 + real_bdev = inode->i_bdev;
1390 + vr->vr_device = real_bdev;
1391 + __iget(real_bdev->bd_inode);
1395 + vxdprintk(VXD_CBIT(misc, 0),
1396 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1397 + vr->vr_number, VXD_DEV(real_bdev));
1399 + vr->vr_state = Vr_bound;
1408 +static int vroot_clr_dev(
1409 + struct vroot_device *vr,
1410 + struct block_device *bdev)
1412 + struct block_device *real_bdev;
1414 + if (vr->vr_state != Vr_bound)
1416 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1419 + real_bdev = vr->vr_device;
1421 + vxdprintk(VXD_CBIT(misc, 0),
1422 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1423 + vr->vr_number, VXD_DEV(real_bdev));
1426 + vr->vr_state = Vr_unbound;
1427 + vr->vr_device = NULL;
1432 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1433 + unsigned int cmd, unsigned long arg)
1435 + struct vroot_device *vr = bdev->bd_disk->private_data;
1438 + down(&vr->vr_ctl_mutex);
1440 + case VROOT_SET_DEV:
1441 + err = vroot_set_dev(vr, bdev, arg);
1443 + case VROOT_CLR_DEV:
1444 + err = vroot_clr_dev(vr, bdev);
1450 + up(&vr->vr_ctl_mutex);
1454 +static int vr_open(struct block_device *bdev, fmode_t mode)
1456 + struct vroot_device *vr = bdev->bd_disk->private_data;
1458 + down(&vr->vr_ctl_mutex);
1460 + up(&vr->vr_ctl_mutex);
1464 +static int vr_release(struct gendisk *disk, fmode_t mode)
1466 + struct vroot_device *vr = disk->private_data;
1468 + down(&vr->vr_ctl_mutex);
1470 + up(&vr->vr_ctl_mutex);
1474 +static struct block_device_operations vr_fops = {
1475 + .owner = THIS_MODULE,
1477 + .release = vr_release,
1478 + .ioctl = vr_ioctl,
1481 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1483 + struct inode *inode = bdev->bd_inode;
1484 + struct vroot_device *vr;
1485 + struct block_device *real_bdev;
1486 + int minor = iminor(inode);
1488 + vr = &vroot_dev[minor];
1489 + real_bdev = vr->vr_device;
1491 + vxdprintk(VXD_CBIT(misc, 0),
1492 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1493 + vr->vr_number, VXD_DEV(real_bdev));
1495 + if (vr->vr_state != Vr_bound)
1496 + return ERR_PTR(-ENXIO);
1498 + __iget(real_bdev->bd_inode);
1503 + * And now the modules code and kernel interface.
1506 +module_param(max_vroot, int, 0);
1508 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1509 +MODULE_LICENSE("GPL");
1510 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1512 +MODULE_AUTHOR ("Herbert Pötzl");
1513 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1516 +int __init vroot_init(void)
1520 + if (max_vroot < 1 || max_vroot > 256) {
1521 + max_vroot = MAX_VROOT_DEFAULT;
1522 + printk(KERN_WARNING "vroot: invalid max_vroot "
1523 + "(must be between 1 and 256), "
1524 + "using default (%d)\n", max_vroot);
1527 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1531 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1534 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1536 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1540 + for (i = 0; i < max_vroot; i++) {
1541 + disks[i] = alloc_disk(1);
1544 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1545 + if (!disks[i]->queue)
1549 + for (i = 0; i < max_vroot; i++) {
1550 + struct vroot_device *vr = &vroot_dev[i];
1551 + struct gendisk *disk = disks[i];
1553 + memset(vr, 0, sizeof(*vr));
1554 + init_MUTEX(&vr->vr_ctl_mutex);
1555 + vr->vr_number = i;
1556 + disk->major = VROOT_MAJOR;
1557 + disk->first_minor = i;
1558 + disk->fops = &vr_fops;
1559 + sprintf(disk->disk_name, "vroot%d", i);
1560 + disk->private_data = vr;
1563 + err = register_vroot_grb(&__vroot_get_real_bdev);
1567 + for (i = 0; i < max_vroot; i++)
1568 + add_disk(disks[i]);
1569 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1574 + put_disk(disks[i]);
1579 + unregister_blkdev(VROOT_MAJOR, "vroot");
1580 + printk(KERN_ERR "vroot: ran out of memory\n");
1584 +void vroot_exit(void)
1588 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1589 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1591 + for (i = 0; i < max_vroot; i++) {
1592 + del_gendisk(disks[i]);
1593 + put_disk(disks[i]);
1595 + unregister_blkdev(VROOT_MAJOR, "vroot");
1601 +module_init(vroot_init);
1602 +module_exit(vroot_exit);
1606 +static int __init max_vroot_setup(char *str)
1608 + max_vroot = simple_strtol(str, NULL, 0);
1612 +__setup("max_vroot=", max_vroot_setup);
1616 diff -NurpP --minimal linux-2.6.33/drivers/char/sysrq.c linux-2.6.33-vs2.3.0.36.30/drivers/char/sysrq.c
1617 --- linux-2.6.33/drivers/char/sysrq.c 2010-02-25 11:51:37.000000000 +0100
1618 +++ linux-2.6.33-vs2.3.0.36.30/drivers/char/sysrq.c 2010-02-25 12:02:16.000000000 +0100
1620 #include <linux/workqueue.h>
1621 #include <linux/hrtimer.h>
1622 #include <linux/oom.h>
1623 +#include <linux/vserver/debug.h>
1625 #include <asm/ptrace.h>
1626 #include <asm/irq_regs.h>
1627 @@ -391,6 +392,21 @@ static struct sysrq_key_op sysrq_unrt_op
1628 .enable_mask = SYSRQ_ENABLE_RTNICE,
1632 +#ifdef CONFIG_VSERVER_DEBUG
1633 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1635 + dump_vx_info_inactive((key == 'x')?0:1);
1638 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1639 + .handler = sysrq_handle_vxinfo,
1640 + .help_msg = "conteXt",
1641 + .action_msg = "Show Context Info",
1642 + .enable_mask = SYSRQ_ENABLE_DUMP,
1646 /* Key Operations table and lock */
1647 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1649 @@ -445,7 +461,11 @@ static struct sysrq_key_op *sysrq_key_ta
1651 &sysrq_showstate_blocked_op, /* w */
1652 /* x: May be registered on ppc/powerpc for xmon */
1653 +#ifdef CONFIG_VSERVER_DEBUG
1654 + &sysrq_showvxinfo_op, /* x */
1658 /* y: May be registered on sparc64 for global register dump */
1660 &sysrq_ftrace_dump_op, /* z */
1661 @@ -460,6 +480,8 @@ static int sysrq_key_table_key2index(int
1663 else if ((key >= 'a') && (key <= 'z'))
1664 retval = key + 10 - 'a';
1665 + else if ((key >= 'A') && (key <= 'Z'))
1666 + retval = key + 10 - 'A';
1670 diff -NurpP --minimal linux-2.6.33/drivers/char/tty_io.c linux-2.6.33-vs2.3.0.36.30/drivers/char/tty_io.c
1671 --- linux-2.6.33/drivers/char/tty_io.c 2010-02-25 11:51:37.000000000 +0100
1672 +++ linux-2.6.33-vs2.3.0.36.30/drivers/char/tty_io.c 2010-02-25 12:02:16.000000000 +0100
1675 #include <linux/kmod.h>
1676 #include <linux/nsproxy.h>
1677 +#include <linux/vs_pid.h>
1679 #undef TTY_DEBUG_HANGUP
1681 @@ -1989,7 +1990,8 @@ static int tiocsti(struct tty_struct *tt
1683 struct tty_ldisc *ld;
1685 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1686 + if (((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) ||
1687 + !vx_ccaps(VXC_TIOCSTI))
1689 if (get_user(ch, p))
1691 @@ -2277,6 +2279,7 @@ static int tiocspgrp(struct tty_struct *
1693 if (get_user(pgrp_nr, p))
1695 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1699 diff -NurpP --minimal linux-2.6.33/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.33-vs2.3.0.36.30/drivers/infiniband/hw/ipath/ipath_user_pages.c
1700 --- linux-2.6.33/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-03 20:02:23.000000000 +0100
1701 +++ linux-2.6.33-vs2.3.0.36.30/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-02-25 12:02:16.000000000 +0100
1703 #include <linux/mm.h>
1704 #include <linux/device.h>
1705 #include <linux/sched.h>
1706 +#include <linux/vs_memory.h>
1708 #include "ipath_kernel.h"
1710 @@ -62,7 +63,8 @@ static int __get_user_pages(unsigned lon
1711 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1714 - if (num_pages > lock_limit) {
1715 + if (num_pages > lock_limit ||
1716 + !vx_vmlocked_avail(current->mm, num_pages)) {
1720 @@ -79,7 +81,7 @@ static int __get_user_pages(unsigned lon
1724 - current->mm->locked_vm += num_pages;
1725 + vx_vmlocked_add(current->mm, num_pages);
1729 @@ -178,7 +180,7 @@ void ipath_release_user_pages(struct pag
1731 __ipath_release_user_pages(p, num_pages, 1);
1733 - current->mm->locked_vm -= num_pages;
1734 + vx_vmlocked_sub(current->mm, num_pages);
1736 up_write(¤t->mm->mmap_sem);
1738 @@ -195,7 +197,7 @@ static void user_pages_account(struct wo
1739 container_of(_work, struct ipath_user_pages_work, work);
1741 down_write(&work->mm->mmap_sem);
1742 - work->mm->locked_vm -= work->num_pages;
1743 + vx_vmlocked_sub(work->mm, work->num_pages);
1744 up_write(&work->mm->mmap_sem);
1747 diff -NurpP --minimal linux-2.6.33/drivers/md/dm.c linux-2.6.33-vs2.3.0.36.30/drivers/md/dm.c
1748 --- linux-2.6.33/drivers/md/dm.c 2010-02-25 11:51:41.000000000 +0100
1749 +++ linux-2.6.33-vs2.3.0.36.30/drivers/md/dm.c 2010-02-25 12:10:11.000000000 +0100
1751 #include <linux/slab.h>
1752 #include <linux/idr.h>
1753 #include <linux/hdreg.h>
1754 +#include <linux/vs_base.h>
1756 #include <trace/events/block.h>
1758 @@ -119,6 +120,7 @@ struct mapped_device {
1761 atomic_t open_count;
1764 unsigned long flags;
1766 @@ -337,6 +339,7 @@ int dm_deleting_md(struct mapped_device
1767 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1769 struct mapped_device *md;
1772 spin_lock(&_minor_lock);
1774 @@ -345,18 +348,19 @@ static int dm_blk_open(struct block_devi
1777 if (test_bit(DMF_FREEING, &md->flags) ||
1778 - dm_deleting_md(md)) {
1780 + dm_deleting_md(md))
1784 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1789 atomic_inc(&md->open_count);
1793 spin_unlock(&_minor_lock);
1795 - return md ? 0 : -ENXIO;
1799 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1800 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
1805 + * Get the xid associated with a dm device
1807 +xid_t dm_get_xid(struct mapped_device *md)
1812 /*-----------------------------------------------------------------
1814 * A more elegant soln is in the works that uses the queue
1815 @@ -1886,6 +1898,7 @@ static struct mapped_device *alloc_dev(i
1816 INIT_LIST_HEAD(&md->uevent_list);
1817 spin_lock_init(&md->uevent_lock);
1819 + md->xid = vx_current_xid();
1820 md->queue = blk_init_queue(dm_request_fn, NULL);
1823 diff -NurpP --minimal linux-2.6.33/drivers/md/dm.h linux-2.6.33-vs2.3.0.36.30/drivers/md/dm.h
1824 --- linux-2.6.33/drivers/md/dm.h 2010-02-25 11:51:41.000000000 +0100
1825 +++ linux-2.6.33-vs2.3.0.36.30/drivers/md/dm.h 2010-02-25 12:02:16.000000000 +0100
1826 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1828 struct dm_md_mempools;
1830 +xid_t dm_get_xid(struct mapped_device *md);
1832 /*-----------------------------------------------------------------
1833 * Internal table functions.
1834 *---------------------------------------------------------------*/
1835 diff -NurpP --minimal linux-2.6.33/drivers/md/dm-ioctl.c linux-2.6.33-vs2.3.0.36.30/drivers/md/dm-ioctl.c
1836 --- linux-2.6.33/drivers/md/dm-ioctl.c 2010-02-25 11:51:41.000000000 +0100
1837 +++ linux-2.6.33-vs2.3.0.36.30/drivers/md/dm-ioctl.c 2010-02-25 12:02:16.000000000 +0100
1839 #include <linux/dm-ioctl.h>
1840 #include <linux/hdreg.h>
1841 #include <linux/compat.h>
1842 +#include <linux/vs_context.h>
1844 #include <asm/uaccess.h>
1846 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1847 unsigned int h = hash_str(str);
1849 list_for_each_entry (hc, _name_buckets + h, name_list)
1850 - if (!strcmp(hc->name, str)) {
1851 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1852 + !strcmp(hc->name, str)) {
1856 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1857 unsigned int h = hash_str(str);
1859 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1860 - if (!strcmp(hc->uuid, str)) {
1861 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1862 + !strcmp(hc->uuid, str)) {
1866 @@ -363,6 +366,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1868 static int remove_all(struct dm_ioctl *param, size_t param_size)
1870 + if (!vx_check(0, VS_ADMIN))
1873 dm_hash_remove_all(1);
1874 param->data_size = 0;
1876 @@ -410,6 +416,8 @@ static int list_devices(struct dm_ioctl
1878 for (i = 0; i < NUM_BUCKETS; i++) {
1879 list_for_each_entry (hc, _name_buckets + i, name_list) {
1880 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1882 needed += sizeof(struct dm_name_list);
1883 needed += strlen(hc->name) + 1;
1884 needed += ALIGN_MASK;
1885 @@ -433,6 +441,8 @@ static int list_devices(struct dm_ioctl
1887 for (i = 0; i < NUM_BUCKETS; i++) {
1888 list_for_each_entry (hc, _name_buckets + i, name_list) {
1889 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1892 old_nl->next = (uint32_t) ((void *) nl -
1894 @@ -667,10 +677,11 @@ static struct hash_cell *__find_device_h
1898 - mdptr = dm_get_mdptr(md);
1899 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1900 + mdptr = dm_get_mdptr(md);
1908 @@ -1508,8 +1519,8 @@ static int ctl_ioctl(uint command, struc
1912 - /* only root can play with this */
1913 - if (!capable(CAP_SYS_ADMIN))
1914 + /* only root and certain contexts can play with this */
1915 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1918 if (_IOC_TYPE(command) != DM_IOCTL)
1919 diff -NurpP --minimal linux-2.6.33/drivers/net/tun.c linux-2.6.33-vs2.3.0.36.30/drivers/net/tun.c
1920 --- linux-2.6.33/drivers/net/tun.c 2010-02-25 11:51:53.000000000 +0100
1921 +++ linux-2.6.33-vs2.3.0.36.30/drivers/net/tun.c 2010-02-25 12:02:16.000000000 +0100
1923 #include <linux/crc32.h>
1924 #include <linux/nsproxy.h>
1925 #include <linux/virtio_net.h>
1926 +#include <linux/vs_network.h>
1927 #include <net/net_namespace.h>
1928 #include <net/netns/generic.h>
1929 #include <net/rtnetlink.h>
1930 @@ -102,6 +103,7 @@ struct tun_struct {
1936 struct net_device *dev;
1937 struct fasync_struct *fasync;
1938 @@ -816,6 +818,7 @@ static void tun_setup(struct net_device
1942 + tun->nid = current->nid;
1944 dev->ethtool_ops = &tun_ethtool_ops;
1945 dev->destructor = tun_free_netdev;
1946 @@ -932,7 +935,7 @@ static int tun_set_iff(struct net *net,
1948 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1949 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1950 - !capable(CAP_NET_ADMIN))
1951 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1953 err = security_tun_dev_attach(tun->socket.sk);
1955 @@ -946,7 +949,7 @@ static int tun_set_iff(struct net *net,
1957 unsigned long flags = 0;
1959 - if (!capable(CAP_NET_ADMIN))
1960 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1962 err = security_tun_dev_create();
1964 @@ -1013,6 +1016,9 @@ static int tun_set_iff(struct net *net,
1966 sk->sk_destruct = tun_sock_destruct;
1968 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1971 err = tun_attach(tun, file);
1974 @@ -1202,6 +1208,16 @@ static long __tun_chr_ioctl(struct file
1975 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1979 + if (!capable(CAP_CONTEXT))
1982 + /* Set nid owner of the device */
1983 + tun->nid = (nid_t) arg;
1985 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1989 /* Only allow setting the type when the interface is down */
1990 if (tun->dev->flags & IFF_UP) {
1991 diff -NurpP --minimal linux-2.6.33/fs/attr.c linux-2.6.33-vs2.3.0.36.30/fs/attr.c
1992 --- linux-2.6.33/fs/attr.c 2009-12-03 20:02:51.000000000 +0100
1993 +++ linux-2.6.33-vs2.3.0.36.30/fs/attr.c 2010-02-25 12:02:16.000000000 +0100
1995 #include <linux/fcntl.h>
1996 #include <linux/quotaops.h>
1997 #include <linux/security.h>
1998 +#include <linux/proc_fs.h>
1999 +#include <linux/devpts_fs.h>
2000 +#include <linux/vs_tag.h>
2002 /* Taken over from the old code... */
2004 @@ -55,6 +58,10 @@ int inode_change_ok(const struct inode *
2005 if (!is_owner_or_cap(inode))
2009 + if (dx_permission(inode, MAY_WRITE))
2015 @@ -120,6 +127,8 @@ int inode_setattr(struct inode * inode,
2016 inode->i_uid = attr->ia_uid;
2017 if (ia_valid & ATTR_GID)
2018 inode->i_gid = attr->ia_gid;
2019 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2020 + inode->i_tag = attr->ia_tag;
2021 if (ia_valid & ATTR_ATIME)
2022 inode->i_atime = timespec_trunc(attr->ia_atime,
2023 inode->i_sb->s_time_gran);
2024 @@ -214,7 +223,8 @@ int notify_change(struct dentry * dentry
2025 error = inode_change_ok(inode, attr);
2027 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2028 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2029 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2030 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2031 error = vfs_dq_transfer(inode, attr) ?
2034 diff -NurpP --minimal linux-2.6.33/fs/binfmt_aout.c linux-2.6.33-vs2.3.0.36.30/fs/binfmt_aout.c
2035 --- linux-2.6.33/fs/binfmt_aout.c 2010-02-25 11:52:04.000000000 +0100
2036 +++ linux-2.6.33-vs2.3.0.36.30/fs/binfmt_aout.c 2010-02-25 12:02:16.000000000 +0100
2038 #include <linux/binfmts.h>
2039 #include <linux/personality.h>
2040 #include <linux/init.h>
2041 +#include <linux/vs_memory.h>
2043 #include <asm/system.h>
2044 #include <asm/uaccess.h>
2045 diff -NurpP --minimal linux-2.6.33/fs/binfmt_elf.c linux-2.6.33-vs2.3.0.36.30/fs/binfmt_elf.c
2046 --- linux-2.6.33/fs/binfmt_elf.c 2010-02-25 11:52:04.000000000 +0100
2047 +++ linux-2.6.33-vs2.3.0.36.30/fs/binfmt_elf.c 2010-02-25 12:02:16.000000000 +0100
2049 #include <linux/random.h>
2050 #include <linux/elf.h>
2051 #include <linux/utsname.h>
2052 +#include <linux/vs_memory.h>
2053 #include <asm/uaccess.h>
2054 #include <asm/param.h>
2055 #include <asm/page.h>
2056 diff -NurpP --minimal linux-2.6.33/fs/binfmt_flat.c linux-2.6.33-vs2.3.0.36.30/fs/binfmt_flat.c
2057 --- linux-2.6.33/fs/binfmt_flat.c 2010-02-25 11:52:04.000000000 +0100
2058 +++ linux-2.6.33-vs2.3.0.36.30/fs/binfmt_flat.c 2010-02-25 12:02:16.000000000 +0100
2060 #include <linux/init.h>
2061 #include <linux/flat.h>
2062 #include <linux/syscalls.h>
2063 +#include <linux/vs_memory.h>
2065 #include <asm/byteorder.h>
2066 #include <asm/system.h>
2067 diff -NurpP --minimal linux-2.6.33/fs/binfmt_som.c linux-2.6.33-vs2.3.0.36.30/fs/binfmt_som.c
2068 --- linux-2.6.33/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2069 +++ linux-2.6.33-vs2.3.0.36.30/fs/binfmt_som.c 2010-02-25 12:02:16.000000000 +0100
2071 #include <linux/shm.h>
2072 #include <linux/personality.h>
2073 #include <linux/init.h>
2074 +#include <linux/vs_memory.h>
2076 #include <asm/uaccess.h>
2077 #include <asm/pgtable.h>
2078 diff -NurpP --minimal linux-2.6.33/fs/block_dev.c linux-2.6.33-vs2.3.0.36.30/fs/block_dev.c
2079 --- linux-2.6.33/fs/block_dev.c 2010-02-25 11:52:04.000000000 +0100
2080 +++ linux-2.6.33-vs2.3.0.36.30/fs/block_dev.c 2010-02-25 12:02:16.000000000 +0100
2082 #include <linux/namei.h>
2083 #include <linux/log2.h>
2084 #include <linux/kmemleak.h>
2085 +#include <linux/vs_device.h>
2086 #include <asm/uaccess.h>
2087 #include "internal.h"
2089 @@ -566,6 +567,7 @@ struct block_device *bdget(dev_t dev)
2090 bdev->bd_invalidated = 0;
2091 inode->i_mode = S_IFBLK;
2092 inode->i_rdev = dev;
2093 + inode->i_mdev = dev;
2094 inode->i_bdev = bdev;
2095 inode->i_data.a_ops = &def_blk_aops;
2096 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2097 @@ -612,6 +614,11 @@ EXPORT_SYMBOL(bdput);
2098 static struct block_device *bd_acquire(struct inode *inode)
2100 struct block_device *bdev;
2103 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2105 + inode->i_mdev = mdev;
2107 spin_lock(&bdev_lock);
2108 bdev = inode->i_bdev;
2109 @@ -622,7 +629,7 @@ static struct block_device *bd_acquire(s
2111 spin_unlock(&bdev_lock);
2113 - bdev = bdget(inode->i_rdev);
2114 + bdev = bdget(mdev);
2116 spin_lock(&bdev_lock);
2117 if (!inode->i_bdev) {
2118 diff -NurpP --minimal linux-2.6.33/fs/btrfs/ctree.h linux-2.6.33-vs2.3.0.36.30/fs/btrfs/ctree.h
2119 --- linux-2.6.33/fs/btrfs/ctree.h 2010-02-25 11:52:04.000000000 +0100
2120 +++ linux-2.6.33-vs2.3.0.36.30/fs/btrfs/ctree.h 2010-02-25 12:02:16.000000000 +0100
2121 @@ -547,11 +547,14 @@ struct btrfs_inode_item {
2122 /* modification sequence number for NFS */
2127 * a little future expansion, for more than this we can
2128 * just grow the inode item and version it
2130 - __le64 reserved[4];
2131 + __le16 reserved16;
2132 + __le32 reserved32;
2133 + __le64 reserved[3];
2134 struct btrfs_timespec atime;
2135 struct btrfs_timespec ctime;
2136 struct btrfs_timespec mtime;
2137 @@ -1163,6 +1166,8 @@ struct btrfs_root {
2138 #define BTRFS_MOUNT_DISCARD (1 << 10)
2139 #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
2141 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2143 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2144 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2145 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2146 @@ -1182,6 +1187,10 @@ struct btrfs_root {
2147 #define BTRFS_INODE_NOATIME (1 << 9)
2148 #define BTRFS_INODE_DIRSYNC (1 << 10)
2150 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2151 +#define BTRFS_INODE_BARRIER (1 << 25)
2152 +#define BTRFS_INODE_COW (1 << 26)
2155 /* some macros to generate set/get funcs for the struct fields. This
2156 * assumes there is a lefoo_to_cpu for every type, so lets make a simple
2157 @@ -1384,6 +1393,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2158 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2159 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2160 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2161 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2162 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2163 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2164 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2165 @@ -2357,6 +2367,7 @@ extern const struct dentry_operations bt
2166 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2167 void btrfs_update_iflags(struct inode *inode);
2168 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2169 +int btrfs_sync_flags(struct inode *inode, int, int);
2172 int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
2173 diff -NurpP --minimal linux-2.6.33/fs/btrfs/disk-io.c linux-2.6.33-vs2.3.0.36.30/fs/btrfs/disk-io.c
2174 --- linux-2.6.33/fs/btrfs/disk-io.c 2010-02-25 11:52:04.000000000 +0100
2175 +++ linux-2.6.33-vs2.3.0.36.30/fs/btrfs/disk-io.c 2010-02-25 12:02:16.000000000 +0100
2176 @@ -1726,6 +1726,9 @@ struct btrfs_root *open_ctree(struct sup
2180 + if (btrfs_test_opt(tree_root, TAGGED))
2181 + sb->s_flags |= MS_TAGGED;
2183 features = btrfs_super_incompat_flags(disk_super) &
2184 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2186 diff -NurpP --minimal linux-2.6.33/fs/btrfs/inode.c linux-2.6.33-vs2.3.0.36.30/fs/btrfs/inode.c
2187 --- linux-2.6.33/fs/btrfs/inode.c 2010-02-25 11:52:04.000000000 +0100
2188 +++ linux-2.6.33-vs2.3.0.36.30/fs/btrfs/inode.c 2010-02-25 12:02:16.000000000 +0100
2190 #include <linux/xattr.h>
2191 #include <linux/posix_acl.h>
2192 #include <linux/falloc.h>
2193 +#include <linux/vs_tag.h>
2197 #include "disk-io.h"
2198 @@ -2264,6 +2266,8 @@ static void btrfs_read_locked_inode(stru
2200 u64 alloc_group_block;
2206 path = btrfs_alloc_path();
2207 @@ -2280,8 +2284,13 @@ static void btrfs_read_locked_inode(stru
2209 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2210 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2211 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2212 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2214 + uid = btrfs_inode_uid(leaf, inode_item);
2215 + gid = btrfs_inode_gid(leaf, inode_item);
2216 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2217 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2218 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2219 + btrfs_inode_tag(leaf, inode_item));
2220 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2222 tspec = btrfs_inode_atime(inode_item);
2223 @@ -2363,8 +2372,15 @@ static void fill_inode_item(struct btrfs
2224 struct btrfs_inode_item *item,
2225 struct inode *inode)
2227 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2228 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2229 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2230 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2232 + btrfs_set_inode_uid(leaf, item, uid);
2233 + btrfs_set_inode_gid(leaf, item, gid);
2234 +#ifdef CONFIG_TAGGING_INTERN
2235 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2238 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2239 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2240 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2241 @@ -4154,6 +4170,7 @@ static struct inode *btrfs_new_inode(str
2243 inode->i_gid = current_fsgid();
2245 + inode->i_tag = dx_current_fstag(root->fs_info->sb);
2246 inode->i_mode = mode;
2247 inode->i_ino = objectid;
2248 inode_set_bytes(inode, 0);
2249 @@ -5955,6 +5972,7 @@ static const struct inode_operations btr
2250 .listxattr = btrfs_listxattr,
2251 .removexattr = btrfs_removexattr,
2252 .permission = btrfs_permission,
2253 + .sync_flags = btrfs_sync_flags,
2255 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2256 .lookup = btrfs_lookup,
2257 @@ -6030,6 +6048,7 @@ static const struct inode_operations btr
2258 .permission = btrfs_permission,
2259 .fallocate = btrfs_fallocate,
2260 .fiemap = btrfs_fiemap,
2261 + .sync_flags = btrfs_sync_flags,
2263 static const struct inode_operations btrfs_special_inode_operations = {
2264 .getattr = btrfs_getattr,
2265 diff -NurpP --minimal linux-2.6.33/fs/btrfs/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/btrfs/ioctl.c
2266 --- linux-2.6.33/fs/btrfs/ioctl.c 2010-02-25 11:52:04.000000000 +0100
2267 +++ linux-2.6.33-vs2.3.0.36.30/fs/btrfs/ioctl.c 2010-02-25 12:02:16.000000000 +0100
2268 @@ -67,10 +67,13 @@ static unsigned int btrfs_flags_to_ioctl
2270 unsigned int iflags = 0;
2272 - if (flags & BTRFS_INODE_SYNC)
2273 - iflags |= FS_SYNC_FL;
2274 if (flags & BTRFS_INODE_IMMUTABLE)
2275 iflags |= FS_IMMUTABLE_FL;
2276 + if (flags & BTRFS_INODE_IXUNLINK)
2277 + iflags |= FS_IXUNLINK_FL;
2279 + if (flags & BTRFS_INODE_SYNC)
2280 + iflags |= FS_SYNC_FL;
2281 if (flags & BTRFS_INODE_APPEND)
2282 iflags |= FS_APPEND_FL;
2283 if (flags & BTRFS_INODE_NODUMP)
2284 @@ -80,28 +83,78 @@ static unsigned int btrfs_flags_to_ioctl
2285 if (flags & BTRFS_INODE_DIRSYNC)
2286 iflags |= FS_DIRSYNC_FL;
2288 + if (flags & BTRFS_INODE_BARRIER)
2289 + iflags |= FS_BARRIER_FL;
2290 + if (flags & BTRFS_INODE_COW)
2291 + iflags |= FS_COW_FL;
2296 - * Update inode->i_flags based on the btrfs internal flags.
2297 + * Update inode->i_(v)flags based on the btrfs internal flags.
2299 void btrfs_update_iflags(struct inode *inode)
2301 struct btrfs_inode *ip = BTRFS_I(inode);
2303 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2304 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2305 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2307 - if (ip->flags & BTRFS_INODE_SYNC)
2308 - inode->i_flags |= S_SYNC;
2309 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2310 inode->i_flags |= S_IMMUTABLE;
2311 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2312 + inode->i_flags |= S_IXUNLINK;
2314 + if (ip->flags & BTRFS_INODE_SYNC)
2315 + inode->i_flags |= S_SYNC;
2316 if (ip->flags & BTRFS_INODE_APPEND)
2317 inode->i_flags |= S_APPEND;
2318 if (ip->flags & BTRFS_INODE_NOATIME)
2319 inode->i_flags |= S_NOATIME;
2320 if (ip->flags & BTRFS_INODE_DIRSYNC)
2321 inode->i_flags |= S_DIRSYNC;
2323 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2325 + if (ip->flags & BTRFS_INODE_BARRIER)
2326 + inode->i_vflags |= V_BARRIER;
2327 + if (ip->flags & BTRFS_INODE_COW)
2328 + inode->i_vflags |= V_COW;
2332 + * Update btrfs internal flags from inode->i_(v)flags.
2334 +void btrfs_update_flags(struct inode *inode)
2336 + struct btrfs_inode *ip = BTRFS_I(inode);
2338 + unsigned int flags = inode->i_flags;
2339 + unsigned int vflags = inode->i_vflags;
2341 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2342 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2343 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2344 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2346 + if (flags & S_IMMUTABLE)
2347 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2348 + if (flags & S_IXUNLINK)
2349 + ip->flags |= BTRFS_INODE_IXUNLINK;
2351 + if (flags & S_SYNC)
2352 + ip->flags |= BTRFS_INODE_SYNC;
2353 + if (flags & S_APPEND)
2354 + ip->flags |= BTRFS_INODE_APPEND;
2355 + if (flags & S_NOATIME)
2356 + ip->flags |= BTRFS_INODE_NOATIME;
2357 + if (flags & S_DIRSYNC)
2358 + ip->flags |= BTRFS_INODE_DIRSYNC;
2360 + if (vflags & V_BARRIER)
2361 + ip->flags |= BTRFS_INODE_BARRIER;
2362 + if (vflags & V_COW)
2363 + ip->flags |= BTRFS_INODE_COW;
2367 @@ -119,7 +172,7 @@ void btrfs_inherit_iflags(struct inode *
2368 flags = BTRFS_I(dir)->flags;
2370 if (S_ISREG(inode->i_mode))
2371 - flags &= ~BTRFS_INODE_DIRSYNC;
2372 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2373 else if (!S_ISDIR(inode->i_mode))
2374 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2376 @@ -127,6 +180,30 @@ void btrfs_inherit_iflags(struct inode *
2377 btrfs_update_iflags(inode);
2380 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2382 + struct btrfs_inode *ip = BTRFS_I(inode);
2383 + struct btrfs_root *root = ip->root;
2384 + struct btrfs_trans_handle *trans;
2387 + trans = btrfs_join_transaction(root, 1);
2390 + inode->i_flags = flags;
2391 + inode->i_vflags = vflags;
2392 + btrfs_update_flags(inode);
2394 + ret = btrfs_update_inode(trans, root, inode);
2397 + btrfs_update_iflags(inode);
2398 + inode->i_ctime = CURRENT_TIME;
2399 + btrfs_end_transaction(trans, root);
2404 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2406 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2407 @@ -149,6 +226,7 @@ static int btrfs_ioctl_setflags(struct f
2408 if (copy_from_user(&flags, arg, sizeof(flags)))
2411 + /* maybe add FS_IXUNLINK_FL ? */
2412 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2413 FS_NOATIME_FL | FS_NODUMP_FL | \
2414 FS_SYNC_FL | FS_DIRSYNC_FL))
2415 @@ -161,7 +239,8 @@ static int btrfs_ioctl_setflags(struct f
2417 flags = btrfs_mask_flags(inode->i_mode, flags);
2418 oldflags = btrfs_flags_to_ioctl(ip->flags);
2419 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2420 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2421 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2422 if (!capable(CAP_LINUX_IMMUTABLE)) {
2425 @@ -172,14 +251,19 @@ static int btrfs_ioctl_setflags(struct f
2429 - if (flags & FS_SYNC_FL)
2430 - ip->flags |= BTRFS_INODE_SYNC;
2432 - ip->flags &= ~BTRFS_INODE_SYNC;
2433 if (flags & FS_IMMUTABLE_FL)
2434 ip->flags |= BTRFS_INODE_IMMUTABLE;
2436 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2437 + if (flags & FS_IXUNLINK_FL)
2438 + ip->flags |= BTRFS_INODE_IXUNLINK;
2440 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2442 + if (flags & FS_SYNC_FL)
2443 + ip->flags |= BTRFS_INODE_SYNC;
2445 + ip->flags &= ~BTRFS_INODE_SYNC;
2446 if (flags & FS_APPEND_FL)
2447 ip->flags |= BTRFS_INODE_APPEND;
2449 diff -NurpP --minimal linux-2.6.33/fs/btrfs/super.c linux-2.6.33-vs2.3.0.36.30/fs/btrfs/super.c
2450 --- linux-2.6.33/fs/btrfs/super.c 2010-02-25 11:52:04.000000000 +0100
2451 +++ linux-2.6.33-vs2.3.0.36.30/fs/btrfs/super.c 2010-02-25 15:33:43.000000000 +0100
2452 @@ -68,7 +68,7 @@ enum {
2453 Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
2454 Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio,
2456 - Opt_discard, Opt_err,
2457 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2460 static match_table_t tokens = {
2461 @@ -92,6 +92,9 @@ static match_table_t tokens = {
2462 {Opt_flushoncommit, "flushoncommit"},
2463 {Opt_ratio, "metadata_ratio=%d"},
2464 {Opt_discard, "discard"},
2466 + {Opt_notag, "notag"},
2467 + {Opt_tagid, "tagid=%u"},
2471 @@ -270,6 +273,22 @@ int btrfs_parse_options(struct btrfs_roo
2473 btrfs_set_opt(info->mount_opt, DISCARD);
2475 +#ifndef CONFIG_TAGGING_NONE
2477 + printk(KERN_INFO "btrfs: use tagging\n");
2478 + btrfs_set_opt(info->mount_opt, TAGGED);
2481 + printk(KERN_INFO "btrfs: disabled tagging\n");
2482 + btrfs_clear_opt(info->mount_opt, TAGGED);
2485 +#ifdef CONFIG_PROPAGATE
2488 + btrfs_set_opt(info->mount_opt, TAGGED);
2492 printk(KERN_INFO "btrfs: unrecognized mount option "
2494 @@ -591,6 +610,12 @@ static int btrfs_remount(struct super_bl
2498 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2499 + printk("btrfs: %s: tagging not permitted on remount.\n",
2504 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2507 diff -NurpP --minimal linux-2.6.33/fs/char_dev.c linux-2.6.33-vs2.3.0.36.30/fs/char_dev.c
2508 --- linux-2.6.33/fs/char_dev.c 2009-12-03 20:02:51.000000000 +0100
2509 +++ linux-2.6.33-vs2.3.0.36.30/fs/char_dev.c 2010-02-25 12:02:16.000000000 +0100
2511 #include <linux/cdev.h>
2512 #include <linux/mutex.h>
2513 #include <linux/backing-dev.h>
2514 +#include <linux/vs_context.h>
2515 +#include <linux/vs_device.h>
2517 #include "internal.h"
2519 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
2521 struct cdev *new = NULL;
2525 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2527 + inode->i_mdev = mdev;
2529 spin_lock(&cdev_lock);
2532 struct kobject *kobj;
2535 spin_unlock(&cdev_lock);
2536 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2538 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2541 new = container_of(kobj, struct cdev, kobj);
2542 diff -NurpP --minimal linux-2.6.33/fs/dcache.c linux-2.6.33-vs2.3.0.36.30/fs/dcache.c
2543 --- linux-2.6.33/fs/dcache.c 2010-02-25 11:52:05.000000000 +0100
2544 +++ linux-2.6.33-vs2.3.0.36.30/fs/dcache.c 2010-02-25 12:02:16.000000000 +0100
2546 #include <linux/bootmem.h>
2547 #include <linux/fs_struct.h>
2548 #include <linux/hardirq.h>
2549 +#include <linux/vs_limit.h>
2550 #include "internal.h"
2552 int sysctl_vfs_cache_pressure __read_mostly = 100;
2553 @@ -230,6 +231,8 @@ repeat:
2557 + vx_dentry_dec(dentry);
2560 * AV: ->d_delete() is _NOT_ allowed to block now.
2562 @@ -321,6 +324,7 @@ static inline struct dentry * __dget_loc
2564 atomic_inc(&dentry->d_count);
2565 dentry_lru_del_init(dentry);
2566 + vx_dentry_inc(dentry);
2570 @@ -919,6 +923,9 @@ struct dentry *d_alloc(struct dentry * p
2571 struct dentry *dentry;
2574 + if (!vx_dentry_avail(1))
2577 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2580 @@ -964,6 +971,7 @@ struct dentry *d_alloc(struct dentry * p
2582 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2583 dentry_stat.nr_dentry++;
2584 + vx_dentry_inc(dentry);
2585 spin_unlock(&dcache_lock);
2588 @@ -1408,6 +1416,7 @@ struct dentry * __d_lookup(struct dentry
2591 atomic_inc(&dentry->d_count);
2592 + vx_dentry_inc(dentry);
2594 spin_unlock(&dentry->d_lock);
2596 diff -NurpP --minimal linux-2.6.33/fs/devpts/inode.c linux-2.6.33-vs2.3.0.36.30/fs/devpts/inode.c
2597 --- linux-2.6.33/fs/devpts/inode.c 2010-02-25 11:52:05.000000000 +0100
2598 +++ linux-2.6.33-vs2.3.0.36.30/fs/devpts/inode.c 2010-02-25 12:02:16.000000000 +0100
2600 #include <linux/parser.h>
2601 #include <linux/fsnotify.h>
2602 #include <linux/seq_file.h>
2603 +#include <linux/vs_base.h>
2605 #define DEVPTS_DEFAULT_MODE 0600
2608 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2609 #define PTMX_MINOR 2
2611 +static int devpts_permission(struct inode *inode, int mask)
2613 + int ret = -EACCES;
2615 + /* devpts is xid tagged */
2616 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2617 + ret = generic_permission(inode, mask, NULL);
2621 +static struct inode_operations devpts_file_inode_operations = {
2622 + .permission = devpts_permission,
2625 extern int pty_limit; /* Config limit on Unix98 ptys */
2626 static DEFINE_MUTEX(allocated_ptys_lock);
2628 @@ -262,6 +277,25 @@ static int devpts_show_options(struct se
2632 +static int devpts_filter(struct dentry *de)
2634 + /* devpts is xid tagged */
2635 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2638 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2640 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2643 +static struct file_operations devpts_dir_operations = {
2644 + .open = dcache_dir_open,
2645 + .release = dcache_dir_close,
2646 + .llseek = dcache_dir_lseek,
2647 + .read = generic_read_dir,
2648 + .readdir = devpts_readdir,
2651 static const struct super_operations devpts_sops = {
2652 .statfs = simple_statfs,
2653 .remount_fs = devpts_remount,
2654 @@ -301,12 +335,15 @@ devpts_fill_super(struct super_block *s,
2655 inode = new_inode(s);
2660 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2661 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2662 inode->i_op = &simple_dir_inode_operations;
2663 - inode->i_fop = &simple_dir_operations;
2664 + inode->i_fop = &devpts_dir_operations;
2666 + /* devpts is xid tagged */
2667 + inode->i_tag = (tag_t)vx_current_xid();
2669 s->s_root = d_alloc_root(inode);
2671 @@ -497,6 +534,9 @@ int devpts_pty_new(struct inode *ptmx_in
2672 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2673 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2674 init_special_inode(inode, S_IFCHR|opts->mode, device);
2675 + /* devpts is xid tagged */
2676 + inode->i_tag = (tag_t)vx_current_xid();
2677 + inode->i_op = &devpts_file_inode_operations;
2678 inode->i_private = tty;
2679 tty->driver_data = inode;
2681 diff -NurpP --minimal linux-2.6.33/fs/exec.c linux-2.6.33-vs2.3.0.36.30/fs/exec.c
2682 --- linux-2.6.33/fs/exec.c 2010-02-25 11:52:05.000000000 +0100
2683 +++ linux-2.6.33-vs2.3.0.36.30/fs/exec.c 2010-02-25 12:02:16.000000000 +0100
2684 @@ -250,7 +250,9 @@ static int __bprm_mm_init(struct linux_b
2688 - mm->stack_vm = mm->total_vm = 1;
2690 + vx_vmpages_inc(mm);
2692 up_write(&mm->mmap_sem);
2693 bprm->p = vma->vm_end - sizeof(void *);
2695 @@ -1503,7 +1505,7 @@ static int format_corename(char *corenam
2696 /* UNIX time of coredump */
2699 - do_gettimeofday(&tv);
2700 + vx_gettimeofday(&tv);
2701 rc = snprintf(out_ptr, out_end - out_ptr,
2703 if (rc > out_end - out_ptr)
2704 diff -NurpP --minimal linux-2.6.33/fs/ext2/balloc.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/balloc.c
2705 --- linux-2.6.33/fs/ext2/balloc.c 2009-06-11 17:13:03.000000000 +0200
2706 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/balloc.c 2010-02-25 12:02:16.000000000 +0100
2707 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2709 end = EXT2_BLOCKS_PER_GROUP(sb);
2712 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2715 diff -NurpP --minimal linux-2.6.33/fs/ext2/ext2.h linux-2.6.33-vs2.3.0.36.30/fs/ext2/ext2.h
2716 --- linux-2.6.33/fs/ext2/ext2.h 2010-02-25 11:52:05.000000000 +0100
2717 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/ext2.h 2010-02-25 12:02:16.000000000 +0100
2718 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
2719 int __ext2_write_begin(struct file *file, struct address_space *mapping,
2720 loff_t pos, unsigned len, unsigned flags,
2721 struct page **pagep, void **fsdata);
2722 +extern int ext2_sync_flags(struct inode *, int, int);
2725 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2726 diff -NurpP --minimal linux-2.6.33/fs/ext2/file.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/file.c
2727 --- linux-2.6.33/fs/ext2/file.c 2010-02-25 11:52:05.000000000 +0100
2728 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/file.c 2010-02-25 12:02:16.000000000 +0100
2729 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2730 .setattr = ext2_setattr,
2731 .check_acl = ext2_check_acl,
2732 .fiemap = ext2_fiemap,
2733 + .sync_flags = ext2_sync_flags,
2735 diff -NurpP --minimal linux-2.6.33/fs/ext2/ialloc.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/ialloc.c
2736 --- linux-2.6.33/fs/ext2/ialloc.c 2009-06-11 17:13:03.000000000 +0200
2737 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/ialloc.c 2010-02-25 12:02:16.000000000 +0100
2739 #include <linux/backing-dev.h>
2740 #include <linux/buffer_head.h>
2741 #include <linux/random.h>
2742 +#include <linux/vs_tag.h>
2746 @@ -560,6 +561,7 @@ got:
2748 inode->i_gid = current_fsgid();
2749 inode->i_mode = mode;
2750 + inode->i_tag = dx_current_fstag(sb);
2753 inode->i_blocks = 0;
2754 diff -NurpP --minimal linux-2.6.33/fs/ext2/inode.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/inode.c
2755 --- linux-2.6.33/fs/ext2/inode.c 2010-02-25 11:52:05.000000000 +0100
2756 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/inode.c 2010-02-25 12:02:16.000000000 +0100
2758 #include <linux/mpage.h>
2759 #include <linux/fiemap.h>
2760 #include <linux/namei.h>
2761 +#include <linux/vs_tag.h>
2765 @@ -1042,7 +1043,7 @@ void ext2_truncate(struct inode *inode)
2767 if (ext2_inode_is_fast_symlink(inode))
2769 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2770 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2773 blocksize = inode->i_sb->s_blocksize;
2774 @@ -1180,36 +1181,61 @@ void ext2_set_inode_flags(struct inode *
2776 unsigned int flags = EXT2_I(inode)->i_flags;
2778 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2779 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2780 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2783 + if (flags & EXT2_IMMUTABLE_FL)
2784 + inode->i_flags |= S_IMMUTABLE;
2785 + if (flags & EXT2_IXUNLINK_FL)
2786 + inode->i_flags |= S_IXUNLINK;
2788 if (flags & EXT2_SYNC_FL)
2789 inode->i_flags |= S_SYNC;
2790 if (flags & EXT2_APPEND_FL)
2791 inode->i_flags |= S_APPEND;
2792 - if (flags & EXT2_IMMUTABLE_FL)
2793 - inode->i_flags |= S_IMMUTABLE;
2794 if (flags & EXT2_NOATIME_FL)
2795 inode->i_flags |= S_NOATIME;
2796 if (flags & EXT2_DIRSYNC_FL)
2797 inode->i_flags |= S_DIRSYNC;
2799 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2801 + if (flags & EXT2_BARRIER_FL)
2802 + inode->i_vflags |= V_BARRIER;
2803 + if (flags & EXT2_COW_FL)
2804 + inode->i_vflags |= V_COW;
2807 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2808 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2810 unsigned int flags = ei->vfs_inode.i_flags;
2811 + unsigned int vflags = ei->vfs_inode.i_vflags;
2813 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2814 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2815 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2816 + EXT2_BARRIER_FL | EXT2_COW_FL);
2818 + if (flags & S_IMMUTABLE)
2819 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2820 + if (flags & S_IXUNLINK)
2821 + ei->i_flags |= EXT2_IXUNLINK_FL;
2823 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2824 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2826 ei->i_flags |= EXT2_SYNC_FL;
2827 if (flags & S_APPEND)
2828 ei->i_flags |= EXT2_APPEND_FL;
2829 - if (flags & S_IMMUTABLE)
2830 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2831 if (flags & S_NOATIME)
2832 ei->i_flags |= EXT2_NOATIME_FL;
2833 if (flags & S_DIRSYNC)
2834 ei->i_flags |= EXT2_DIRSYNC_FL;
2836 + if (vflags & V_BARRIER)
2837 + ei->i_flags |= EXT2_BARRIER_FL;
2838 + if (vflags & V_COW)
2839 + ei->i_flags |= EXT2_COW_FL;
2842 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2843 @@ -1219,6 +1245,8 @@ struct inode *ext2_iget (struct super_bl
2844 struct ext2_inode *raw_inode;
2845 struct inode *inode;
2851 inode = iget_locked(sb, ino);
2852 @@ -1237,12 +1265,17 @@ struct inode *ext2_iget (struct super_bl
2855 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2856 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2857 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2858 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2859 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2860 if (!(test_opt (inode->i_sb, NO_UID32))) {
2861 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2862 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2863 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2864 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2866 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2867 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2868 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2869 + le16_to_cpu(raw_inode->i_raw_tag));
2871 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2872 inode->i_size = le32_to_cpu(raw_inode->i_size);
2873 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2874 @@ -1340,8 +1373,8 @@ int ext2_write_inode(struct inode *inode
2875 struct ext2_inode_info *ei = EXT2_I(inode);
2876 struct super_block *sb = inode->i_sb;
2877 ino_t ino = inode->i_ino;
2878 - uid_t uid = inode->i_uid;
2879 - gid_t gid = inode->i_gid;
2880 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2881 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2882 struct buffer_head * bh;
2883 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2885 @@ -1377,6 +1410,9 @@ int ext2_write_inode(struct inode *inode
2886 raw_inode->i_uid_high = 0;
2887 raw_inode->i_gid_high = 0;
2889 +#ifdef CONFIG_TAGGING_INTERN
2890 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2892 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2893 raw_inode->i_size = cpu_to_le32(inode->i_size);
2894 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2895 @@ -1458,7 +1494,8 @@ int ext2_setattr(struct dentry *dentry,
2898 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2899 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2900 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2901 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2902 error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
2905 diff -NurpP --minimal linux-2.6.33/fs/ext2/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/ioctl.c
2906 --- linux-2.6.33/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2907 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/ioctl.c 2010-02-25 12:02:16.000000000 +0100
2909 #include <asm/uaccess.h>
2912 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2914 + inode->i_flags = flags;
2915 + inode->i_vflags = vflags;
2916 + ext2_get_inode_flags(EXT2_I(inode));
2917 + inode->i_ctime = CURRENT_TIME_SEC;
2918 + mark_inode_dirty(inode);
2922 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2924 struct inode *inode = filp->f_dentry->d_inode;
2925 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2927 flags = ext2_mask_flags(inode->i_mode, flags);
2929 + if (IS_BARRIER(inode)) {
2930 + vxwprintk_task(1, "messing with the barrier.");
2934 mutex_lock(&inode->i_mutex);
2935 /* Is it quota file? Do not allow user to mess with it */
2936 if (IS_NOQUOTA(inode)) {
2937 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2939 * This test looks nicer. Thanks to Pauline Middelink
2941 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2942 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2943 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2944 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2945 if (!capable(CAP_LINUX_IMMUTABLE)) {
2946 mutex_unlock(&inode->i_mutex);
2948 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2952 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2953 + flags &= EXT2_FL_USER_MODIFIABLE;
2954 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2955 ei->i_flags = flags;
2956 mutex_unlock(&inode->i_mutex);
2957 diff -NurpP --minimal linux-2.6.33/fs/ext2/namei.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/namei.c
2958 --- linux-2.6.33/fs/ext2/namei.c 2009-12-03 20:02:51.000000000 +0100
2959 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/namei.c 2010-02-25 12:02:16.000000000 +0100
2963 #include <linux/pagemap.h>
2964 +#include <linux/vs_tag.h>
2968 @@ -74,6 +75,7 @@ static struct dentry *ext2_lookup(struct
2969 return ERR_PTR(-EIO);
2971 return ERR_CAST(inode);
2972 + dx_propagate_tag(nd, inode);
2976 @@ -401,6 +403,7 @@ const struct inode_operations ext2_dir_i
2978 .setattr = ext2_setattr,
2979 .check_acl = ext2_check_acl,
2980 + .sync_flags = ext2_sync_flags,
2983 const struct inode_operations ext2_special_inode_operations = {
2984 diff -NurpP --minimal linux-2.6.33/fs/ext2/super.c linux-2.6.33-vs2.3.0.36.30/fs/ext2/super.c
2985 --- linux-2.6.33/fs/ext2/super.c 2010-02-25 11:52:05.000000000 +0100
2986 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext2/super.c 2010-02-25 12:02:16.000000000 +0100
2987 @@ -382,7 +382,8 @@ enum {
2988 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2989 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2990 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2991 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2992 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2993 + Opt_tag, Opt_notag, Opt_tagid
2996 static const match_table_t tokens = {
2997 @@ -410,6 +411,9 @@ static const match_table_t tokens = {
2999 {Opt_noacl, "noacl"},
3002 + {Opt_notag, "notag"},
3003 + {Opt_tagid, "tagid=%u"},
3004 {Opt_grpquota, "grpquota"},
3005 {Opt_ignore, "noquota"},
3006 {Opt_quota, "quota"},
3007 @@ -480,6 +484,20 @@ static int parse_options(char *options,
3009 set_opt (sbi->s_mount_opt, NO_UID32);
3011 +#ifndef CONFIG_TAGGING_NONE
3013 + set_opt (sbi->s_mount_opt, TAGGED);
3016 + clear_opt (sbi->s_mount_opt, TAGGED);
3019 +#ifdef CONFIG_PROPAGATE
3022 + set_opt (sbi->s_mount_opt, TAGGED);
3026 clear_opt (sbi->s_mount_opt, CHECK);
3028 @@ -836,6 +854,8 @@ static int ext2_fill_super(struct super_
3029 if (!parse_options((char *) data, sb))
3032 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3033 + sb->s_flags |= MS_TAGGED;
3034 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3035 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3037 @@ -1229,6 +1249,14 @@ static int ext2_remount (struct super_bl
3041 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3042 + !(sb->s_flags & MS_TAGGED)) {
3043 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3046 + goto restore_opts;
3049 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3050 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3052 diff -NurpP --minimal linux-2.6.33/fs/ext3/file.c linux-2.6.33-vs2.3.0.36.30/fs/ext3/file.c
3053 --- linux-2.6.33/fs/ext3/file.c 2009-12-03 20:02:51.000000000 +0100
3054 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext3/file.c 2010-02-25 12:02:16.000000000 +0100
3055 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
3057 .check_acl = ext3_check_acl,
3058 .fiemap = ext3_fiemap,
3059 + .sync_flags = ext3_sync_flags,
3062 diff -NurpP --minimal linux-2.6.33/fs/ext3/ialloc.c linux-2.6.33-vs2.3.0.36.30/fs/ext3/ialloc.c
3063 --- linux-2.6.33/fs/ext3/ialloc.c 2009-09-10 15:26:21.000000000 +0200
3064 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext3/ialloc.c 2010-02-25 12:02:16.000000000 +0100
3066 #include <linux/buffer_head.h>
3067 #include <linux/random.h>
3068 #include <linux/bitops.h>
3069 +#include <linux/vs_tag.h>
3071 #include <asm/byteorder.h>
3073 @@ -548,6 +549,7 @@ got:
3075 inode->i_gid = current_fsgid();
3076 inode->i_mode = mode;
3077 + inode->i_tag = dx_current_fstag(sb);
3080 /* This is the optimal IO size (for stat), not the fs block size */
3081 diff -NurpP --minimal linux-2.6.33/fs/ext3/inode.c linux-2.6.33-vs2.3.0.36.30/fs/ext3/inode.c
3082 --- linux-2.6.33/fs/ext3/inode.c 2010-02-25 11:52:05.000000000 +0100
3083 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext3/inode.c 2010-02-25 12:02:16.000000000 +0100
3085 #include <linux/bio.h>
3086 #include <linux/fiemap.h>
3087 #include <linux/namei.h>
3088 +#include <linux/vs_tag.h>
3092 @@ -2343,7 +2344,7 @@ static void ext3_free_branches(handle_t
3094 int ext3_can_truncate(struct inode *inode)
3096 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3097 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3099 if (S_ISREG(inode->i_mode))
3101 @@ -2728,36 +2729,60 @@ void ext3_set_inode_flags(struct inode *
3103 unsigned int flags = EXT3_I(inode)->i_flags;
3105 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3106 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3107 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3109 + if (flags & EXT3_IMMUTABLE_FL)
3110 + inode->i_flags |= S_IMMUTABLE;
3111 + if (flags & EXT3_IXUNLINK_FL)
3112 + inode->i_flags |= S_IXUNLINK;
3114 if (flags & EXT3_SYNC_FL)
3115 inode->i_flags |= S_SYNC;
3116 if (flags & EXT3_APPEND_FL)
3117 inode->i_flags |= S_APPEND;
3118 - if (flags & EXT3_IMMUTABLE_FL)
3119 - inode->i_flags |= S_IMMUTABLE;
3120 if (flags & EXT3_NOATIME_FL)
3121 inode->i_flags |= S_NOATIME;
3122 if (flags & EXT3_DIRSYNC_FL)
3123 inode->i_flags |= S_DIRSYNC;
3125 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3127 + if (flags & EXT3_BARRIER_FL)
3128 + inode->i_vflags |= V_BARRIER;
3129 + if (flags & EXT3_COW_FL)
3130 + inode->i_vflags |= V_COW;
3133 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3134 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3136 unsigned int flags = ei->vfs_inode.i_flags;
3137 + unsigned int vflags = ei->vfs_inode.i_vflags;
3139 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3140 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3141 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3142 + EXT3_BARRIER_FL | EXT3_COW_FL);
3144 + if (flags & S_IMMUTABLE)
3145 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3146 + if (flags & S_IXUNLINK)
3147 + ei->i_flags |= EXT3_IXUNLINK_FL;
3149 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3150 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3152 ei->i_flags |= EXT3_SYNC_FL;
3153 if (flags & S_APPEND)
3154 ei->i_flags |= EXT3_APPEND_FL;
3155 - if (flags & S_IMMUTABLE)
3156 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3157 if (flags & S_NOATIME)
3158 ei->i_flags |= EXT3_NOATIME_FL;
3159 if (flags & S_DIRSYNC)
3160 ei->i_flags |= EXT3_DIRSYNC_FL;
3162 + if (vflags & V_BARRIER)
3163 + ei->i_flags |= EXT3_BARRIER_FL;
3164 + if (vflags & V_COW)
3165 + ei->i_flags |= EXT3_COW_FL;
3168 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3169 @@ -2771,6 +2796,8 @@ struct inode *ext3_iget(struct super_blo
3170 transaction_t *transaction;
3176 inode = iget_locked(sb, ino);
3178 @@ -2787,12 +2814,17 @@ struct inode *ext3_iget(struct super_blo
3180 raw_inode = ext3_raw_inode(&iloc);
3181 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3182 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3183 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3184 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3185 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3186 if(!(test_opt (inode->i_sb, NO_UID32))) {
3187 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3188 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3189 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3190 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3192 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3193 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3194 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3195 + le16_to_cpu(raw_inode->i_raw_tag));
3197 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3198 inode->i_size = le32_to_cpu(raw_inode->i_size);
3199 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3200 @@ -2947,6 +2979,8 @@ static int ext3_do_update_inode(handle_t
3201 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3202 struct ext3_inode_info *ei = EXT3_I(inode);
3203 struct buffer_head *bh = iloc->bh;
3204 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3205 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3206 int err = 0, rc, block;
3209 @@ -2961,29 +2995,32 @@ again:
3210 ext3_get_inode_flags(ei);
3211 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3212 if(!(test_opt(inode->i_sb, NO_UID32))) {
3213 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3214 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3215 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3216 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3218 * Fix up interoperability with old kernels. Otherwise, old inodes get
3219 * re-used with the upper 16 bits of the uid/gid intact
3222 raw_inode->i_uid_high =
3223 - cpu_to_le16(high_16_bits(inode->i_uid));
3224 + cpu_to_le16(high_16_bits(uid));
3225 raw_inode->i_gid_high =
3226 - cpu_to_le16(high_16_bits(inode->i_gid));
3227 + cpu_to_le16(high_16_bits(gid));
3229 raw_inode->i_uid_high = 0;
3230 raw_inode->i_gid_high = 0;
3233 raw_inode->i_uid_low =
3234 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3235 + cpu_to_le16(fs_high2lowuid(uid));
3236 raw_inode->i_gid_low =
3237 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3238 + cpu_to_le16(fs_high2lowgid(gid));
3239 raw_inode->i_uid_high = 0;
3240 raw_inode->i_gid_high = 0;
3242 +#ifdef CONFIG_TAGGING_INTERN
3243 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3245 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3246 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3247 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3248 @@ -3141,7 +3178,8 @@ int ext3_setattr(struct dentry *dentry,
3251 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3252 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3253 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3254 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3257 /* (user+group)*(old+new) structure, inode write (sb,
3258 @@ -3163,6 +3201,8 @@ int ext3_setattr(struct dentry *dentry,
3259 inode->i_uid = attr->ia_uid;
3260 if (attr->ia_valid & ATTR_GID)
3261 inode->i_gid = attr->ia_gid;
3262 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3263 + inode->i_tag = attr->ia_tag;
3264 error = ext3_mark_inode_dirty(handle, inode);
3265 ext3_journal_stop(handle);
3267 diff -NurpP --minimal linux-2.6.33/fs/ext3/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/ext3/ioctl.c
3268 --- linux-2.6.33/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3269 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext3/ioctl.c 2010-02-25 12:02:16.000000000 +0100
3273 #include <linux/fs.h>
3274 +#include <linux/mount.h>
3275 #include <linux/jbd.h>
3276 #include <linux/capability.h>
3277 #include <linux/ext3_fs.h>
3279 #include <linux/compat.h>
3280 #include <asm/uaccess.h>
3283 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3285 + handle_t *handle = NULL;
3286 + struct ext3_iloc iloc;
3289 + handle = ext3_journal_start(inode, 1);
3290 + if (IS_ERR(handle))
3291 + return PTR_ERR(handle);
3293 + if (IS_SYNC(inode))
3294 + handle->h_sync = 1;
3295 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3299 + inode->i_flags = flags;
3300 + inode->i_vflags = vflags;
3301 + ext3_get_inode_flags(EXT3_I(inode));
3302 + inode->i_ctime = CURRENT_TIME_SEC;
3304 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3306 + ext3_journal_stop(handle);
3310 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3312 struct inode *inode = filp->f_dentry->d_inode;
3313 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3315 flags = ext3_mask_flags(inode->i_mode, flags);
3317 + if (IS_BARRIER(inode)) {
3318 + vxwprintk_task(1, "messing with the barrier.");
3322 mutex_lock(&inode->i_mutex);
3324 /* Is it quota file? Do not allow user to mess with it */
3325 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3327 * This test looks nicer. Thanks to Pauline Middelink
3329 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3330 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3331 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3332 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3333 if (!capable(CAP_LINUX_IMMUTABLE))
3336 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3340 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3341 + flags &= EXT3_FL_USER_MODIFIABLE;
3342 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3343 ei->i_flags = flags;
3345 diff -NurpP --minimal linux-2.6.33/fs/ext3/namei.c linux-2.6.33-vs2.3.0.36.30/fs/ext3/namei.c
3346 --- linux-2.6.33/fs/ext3/namei.c 2010-02-25 11:52:05.000000000 +0100
3347 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext3/namei.c 2010-02-25 12:02:16.000000000 +0100
3349 #include <linux/quotaops.h>
3350 #include <linux/buffer_head.h>
3351 #include <linux/bio.h>
3352 +#include <linux/vs_tag.h>
3356 @@ -912,6 +913,7 @@ restart:
3358 ll_rw_block(READ_META, 1, &bh);
3360 + dx_propagate_tag(nd, inode);
3362 if ((bh = bh_use[ra_ptr++]) == NULL)
3364 @@ -2448,6 +2450,7 @@ const struct inode_operations ext3_dir_i
3365 .removexattr = generic_removexattr,
3367 .check_acl = ext3_check_acl,
3368 + .sync_flags = ext3_sync_flags,
3371 const struct inode_operations ext3_special_inode_operations = {
3372 diff -NurpP --minimal linux-2.6.33/fs/ext3/super.c linux-2.6.33-vs2.3.0.36.30/fs/ext3/super.c
3373 --- linux-2.6.33/fs/ext3/super.c 2010-02-25 11:52:05.000000000 +0100
3374 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext3/super.c 2010-02-25 13:29:21.000000000 +0100
3375 @@ -817,7 +817,7 @@ enum {
3376 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3377 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3378 Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
3379 - Opt_usrquota, Opt_grpquota
3380 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3383 static const match_table_t tokens = {
3384 @@ -872,6 +872,9 @@ static const match_table_t tokens = {
3385 {Opt_usrquota, "usrquota"},
3386 {Opt_barrier, "barrier=%u"},
3387 {Opt_resize, "resize"},
3389 + {Opt_notag, "notag"},
3390 + {Opt_tagid, "tagid=%u"},
3394 @@ -964,6 +967,20 @@ static int parse_options (char *options,
3396 set_opt (sbi->s_mount_opt, NO_UID32);
3398 +#ifndef CONFIG_TAGGING_NONE
3400 + set_opt (sbi->s_mount_opt, TAGGED);
3403 + clear_opt (sbi->s_mount_opt, TAGGED);
3406 +#ifdef CONFIG_PROPAGATE
3409 + set_opt (sbi->s_mount_opt, TAGGED);
3413 clear_opt (sbi->s_mount_opt, CHECK);
3415 @@ -1693,6 +1710,9 @@ static int ext3_fill_super (struct super
3419 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3420 + sb->s_flags |= MS_TAGGED;
3422 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3423 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3425 @@ -2564,6 +2584,14 @@ static int ext3_remount (struct super_bl
3426 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3427 ext3_abort(sb, __func__, "Abort forced by user");
3429 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3430 + !(sb->s_flags & MS_TAGGED)) {
3431 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3434 + goto restore_opts;
3437 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3438 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3440 diff -NurpP --minimal linux-2.6.33/fs/ext4/ext4.h linux-2.6.33-vs2.3.0.36.30/fs/ext4/ext4.h
3441 --- linux-2.6.33/fs/ext4/ext4.h 2010-02-25 11:52:05.000000000 +0100
3442 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/ext4.h 2010-02-25 12:02:16.000000000 +0100
3443 @@ -284,8 +284,12 @@ struct flex_groups {
3444 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
3445 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3446 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3447 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3448 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3450 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3451 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3453 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3454 #define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
3456 @@ -472,7 +476,8 @@ struct ext4_inode {
3457 __le16 l_i_file_acl_high;
3458 __le16 l_i_uid_high; /* these 2 fields */
3459 __le16 l_i_gid_high; /* were reserved2[0] */
3460 - __u32 l_i_reserved2;
3461 + __le16 l_i_tag; /* Context Tag */
3462 + __u16 l_i_reserved2;
3465 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3466 @@ -586,6 +591,7 @@ do { \
3467 #define i_gid_low i_gid
3468 #define i_uid_high osd2.linux2.l_i_uid_high
3469 #define i_gid_high osd2.linux2.l_i_gid_high
3470 +#define i_raw_tag osd2.linux2.l_i_tag
3471 #define i_reserved2 osd2.linux2.l_i_reserved2
3473 #elif defined(__GNU__)
3474 @@ -760,6 +766,7 @@ struct ext4_inode_info {
3475 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3476 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3477 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3478 +#define EXT4_MOUNT_TAGGED 0x400000 /* Enable Context Tags */
3479 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3480 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3481 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3482 @@ -1750,6 +1757,7 @@ extern int ext4_get_blocks(handle_t *han
3483 struct buffer_head *bh, int flags);
3484 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3485 __u64 start, __u64 len);
3486 +extern int ext4_sync_flags(struct inode *, int, int);
3488 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3489 __u64 start_orig, __u64 start_donor,
3490 diff -NurpP --minimal linux-2.6.33/fs/ext4/file.c linux-2.6.33-vs2.3.0.36.30/fs/ext4/file.c
3491 --- linux-2.6.33/fs/ext4/file.c 2009-12-03 20:02:51.000000000 +0100
3492 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/file.c 2010-02-25 12:02:16.000000000 +0100
3493 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
3494 .check_acl = ext4_check_acl,
3495 .fallocate = ext4_fallocate,
3496 .fiemap = ext4_fiemap,
3497 + .sync_flags = ext4_sync_flags,
3500 diff -NurpP --minimal linux-2.6.33/fs/ext4/ialloc.c linux-2.6.33-vs2.3.0.36.30/fs/ext4/ialloc.c
3501 --- linux-2.6.33/fs/ext4/ialloc.c 2009-12-03 20:02:51.000000000 +0100
3502 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/ialloc.c 2010-02-25 12:02:16.000000000 +0100
3504 #include <linux/random.h>
3505 #include <linux/bitops.h>
3506 #include <linux/blkdev.h>
3507 +#include <linux/vs_tag.h>
3508 #include <asm/byteorder.h>
3511 @@ -995,6 +996,7 @@ got:
3513 inode->i_gid = current_fsgid();
3514 inode->i_mode = mode;
3515 + inode->i_tag = dx_current_fstag(sb);
3517 inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
3518 /* This is the optimal IO size (for stat), not the fs block size */
3519 diff -NurpP --minimal linux-2.6.33/fs/ext4/inode.c linux-2.6.33-vs2.3.0.36.30/fs/ext4/inode.c
3520 --- linux-2.6.33/fs/ext4/inode.c 2010-02-25 11:52:05.000000000 +0100
3521 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/inode.c 2010-02-25 12:02:16.000000000 +0100
3523 #include <linux/uio.h>
3524 #include <linux/bio.h>
3525 #include <linux/workqueue.h>
3526 +#include <linux/vs_tag.h>
3528 #include "ext4_jbd2.h"
3530 @@ -4376,7 +4377,7 @@ static void ext4_free_branches(handle_t
3532 int ext4_can_truncate(struct inode *inode)
3534 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3535 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3537 if (S_ISREG(inode->i_mode))
3539 @@ -4727,36 +4728,60 @@ void ext4_set_inode_flags(struct inode *
3541 unsigned int flags = EXT4_I(inode)->i_flags;
3543 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3544 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3545 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3547 + if (flags & EXT4_IMMUTABLE_FL)
3548 + inode->i_flags |= S_IMMUTABLE;
3549 + if (flags & EXT4_IXUNLINK_FL)
3550 + inode->i_flags |= S_IXUNLINK;
3552 if (flags & EXT4_SYNC_FL)
3553 inode->i_flags |= S_SYNC;
3554 if (flags & EXT4_APPEND_FL)
3555 inode->i_flags |= S_APPEND;
3556 - if (flags & EXT4_IMMUTABLE_FL)
3557 - inode->i_flags |= S_IMMUTABLE;
3558 if (flags & EXT4_NOATIME_FL)
3559 inode->i_flags |= S_NOATIME;
3560 if (flags & EXT4_DIRSYNC_FL)
3561 inode->i_flags |= S_DIRSYNC;
3563 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3565 + if (flags & EXT4_BARRIER_FL)
3566 + inode->i_vflags |= V_BARRIER;
3567 + if (flags & EXT4_COW_FL)
3568 + inode->i_vflags |= V_COW;
3571 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3572 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3574 unsigned int flags = ei->vfs_inode.i_flags;
3575 + unsigned int vflags = ei->vfs_inode.i_vflags;
3577 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3578 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3579 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3580 + EXT4_BARRIER_FL | EXT4_COW_FL);
3582 + if (flags & S_IMMUTABLE)
3583 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3584 + if (flags & S_IXUNLINK)
3585 + ei->i_flags |= EXT4_IXUNLINK_FL;
3587 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3588 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3590 ei->i_flags |= EXT4_SYNC_FL;
3591 if (flags & S_APPEND)
3592 ei->i_flags |= EXT4_APPEND_FL;
3593 - if (flags & S_IMMUTABLE)
3594 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3595 if (flags & S_NOATIME)
3596 ei->i_flags |= EXT4_NOATIME_FL;
3597 if (flags & S_DIRSYNC)
3598 ei->i_flags |= EXT4_DIRSYNC_FL;
3600 + if (vflags & V_BARRIER)
3601 + ei->i_flags |= EXT4_BARRIER_FL;
3602 + if (vflags & V_COW)
3603 + ei->i_flags |= EXT4_COW_FL;
3606 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3607 @@ -4791,6 +4816,8 @@ struct inode *ext4_iget(struct super_blo
3608 journal_t *journal = EXT4_SB(sb)->s_journal;
3614 inode = iget_locked(sb, ino);
3616 @@ -4806,12 +4833,16 @@ struct inode *ext4_iget(struct super_blo
3618 raw_inode = ext4_raw_inode(&iloc);
3619 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3620 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3621 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3622 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3623 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3624 if (!(test_opt(inode->i_sb, NO_UID32))) {
3625 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3626 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3627 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3628 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3630 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3631 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3632 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3633 + le16_to_cpu(raw_inode->i_raw_tag));
3634 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3637 @@ -5033,6 +5064,8 @@ static int ext4_do_update_inode(handle_t
3638 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3639 struct ext4_inode_info *ei = EXT4_I(inode);
3640 struct buffer_head *bh = iloc->bh;
3641 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3642 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3643 int err = 0, rc, block;
3645 /* For fields not not tracking in the in-memory inode,
3646 @@ -5043,29 +5076,32 @@ static int ext4_do_update_inode(handle_t
3647 ext4_get_inode_flags(ei);
3648 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3649 if (!(test_opt(inode->i_sb, NO_UID32))) {
3650 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3651 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3652 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3653 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3655 * Fix up interoperability with old kernels. Otherwise, old inodes get
3656 * re-used with the upper 16 bits of the uid/gid intact
3659 raw_inode->i_uid_high =
3660 - cpu_to_le16(high_16_bits(inode->i_uid));
3661 + cpu_to_le16(high_16_bits(uid));
3662 raw_inode->i_gid_high =
3663 - cpu_to_le16(high_16_bits(inode->i_gid));
3664 + cpu_to_le16(high_16_bits(gid));
3666 raw_inode->i_uid_high = 0;
3667 raw_inode->i_gid_high = 0;
3670 raw_inode->i_uid_low =
3671 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3672 + cpu_to_le16(fs_high2lowuid(uid));
3673 raw_inode->i_gid_low =
3674 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3675 + cpu_to_le16(fs_high2lowgid(gid));
3676 raw_inode->i_uid_high = 0;
3677 raw_inode->i_gid_high = 0;
3679 +#ifdef CONFIG_TAGGING_INTERN
3680 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3682 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3684 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3685 @@ -5250,7 +5286,8 @@ int ext4_setattr(struct dentry *dentry,
3688 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3689 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3690 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3691 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3694 /* (user+group)*(old+new) structure, inode write (sb,
3695 @@ -5272,6 +5309,8 @@ int ext4_setattr(struct dentry *dentry,
3696 inode->i_uid = attr->ia_uid;
3697 if (attr->ia_valid & ATTR_GID)
3698 inode->i_gid = attr->ia_gid;
3699 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3700 + inode->i_tag = attr->ia_tag;
3701 error = ext4_mark_inode_dirty(handle, inode);
3702 ext4_journal_stop(handle);
3704 diff -NurpP --minimal linux-2.6.33/fs/ext4/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/ext4/ioctl.c
3705 --- linux-2.6.33/fs/ext4/ioctl.c 2010-02-25 11:52:05.000000000 +0100
3706 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/ioctl.c 2010-02-25 12:02:16.000000000 +0100
3708 #include <linux/compat.h>
3709 #include <linux/mount.h>
3710 #include <linux/file.h>
3711 +#include <linux/vs_tag.h>
3712 #include <asm/uaccess.h>
3713 #include "ext4_jbd2.h"
3717 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3719 + handle_t *handle = NULL;
3720 + struct ext4_iloc iloc;
3723 + handle = ext4_journal_start(inode, 1);
3724 + if (IS_ERR(handle))
3725 + return PTR_ERR(handle);
3727 + if (IS_SYNC(inode))
3728 + ext4_handle_sync(handle);
3729 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3733 + inode->i_flags = flags;
3734 + inode->i_vflags = vflags;
3735 + ext4_get_inode_flags(EXT4_I(inode));
3736 + inode->i_ctime = ext4_current_time(inode);
3738 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3740 + ext4_journal_stop(handle);
3744 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3746 struct inode *inode = filp->f_dentry->d_inode;
3747 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3749 flags = ext4_mask_flags(inode->i_mode, flags);
3751 + if (IS_BARRIER(inode)) {
3752 + vxwprintk_task(1, "messing with the barrier.");
3757 mutex_lock(&inode->i_mutex);
3758 /* Is it quota file? Do not allow user to mess with it */
3759 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3761 * This test looks nicer. Thanks to Pauline Middelink
3763 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3764 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3765 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3766 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3767 if (!capable(CAP_LINUX_IMMUTABLE))
3770 diff -NurpP --minimal linux-2.6.33/fs/ext4/namei.c linux-2.6.33-vs2.3.0.36.30/fs/ext4/namei.c
3771 --- linux-2.6.33/fs/ext4/namei.c 2010-02-25 11:52:05.000000000 +0100
3772 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/namei.c 2010-02-25 12:02:16.000000000 +0100
3774 #include <linux/quotaops.h>
3775 #include <linux/buffer_head.h>
3776 #include <linux/bio.h>
3777 +#include <linux/vs_tag.h>
3779 #include "ext4_jbd2.h"
3781 @@ -941,6 +942,7 @@ restart:
3783 ll_rw_block(READ_META, 1, &bh);
3785 + dx_propagate_tag(nd, inode);
3787 if ((bh = bh_use[ra_ptr++]) == NULL)
3789 @@ -2533,6 +2535,7 @@ const struct inode_operations ext4_dir_i
3791 .check_acl = ext4_check_acl,
3792 .fiemap = ext4_fiemap,
3793 + .sync_flags = ext4_sync_flags,
3796 const struct inode_operations ext4_special_inode_operations = {
3797 diff -NurpP --minimal linux-2.6.33/fs/ext4/super.c linux-2.6.33-vs2.3.0.36.30/fs/ext4/super.c
3798 --- linux-2.6.33/fs/ext4/super.c 2010-02-25 11:52:05.000000000 +0100
3799 +++ linux-2.6.33-vs2.3.0.36.30/fs/ext4/super.c 2010-02-25 12:02:16.000000000 +0100
3800 @@ -1110,6 +1110,7 @@ enum {
3801 Opt_block_validity, Opt_noblock_validity,
3802 Opt_inode_readahead_blks, Opt_journal_ioprio,
3803 Opt_discard, Opt_nodiscard,
3804 + Opt_tag, Opt_notag, Opt_tagid
3807 static const match_table_t tokens = {
3808 @@ -1178,6 +1179,9 @@ static const match_table_t tokens = {
3809 {Opt_noauto_da_alloc, "noauto_da_alloc"},
3810 {Opt_discard, "discard"},
3811 {Opt_nodiscard, "nodiscard"},
3813 + {Opt_notag, "notag"},
3814 + {Opt_tagid, "tagid=%u"},
3818 @@ -1275,6 +1279,20 @@ static int parse_options(char *options,
3820 set_opt(sbi->s_mount_opt, NO_UID32);
3822 +#ifndef CONFIG_TAGGING_NONE
3824 + set_opt (sbi->s_mount_opt, TAGGED);
3827 + clear_opt (sbi->s_mount_opt, TAGGED);
3830 +#ifdef CONFIG_PROPAGATE
3833 + set_opt (sbi->s_mount_opt, TAGGED);
3837 set_opt(sbi->s_mount_opt, DEBUG);
3839 @@ -2476,6 +2494,9 @@ static int ext4_fill_super(struct super_
3840 &journal_ioprio, NULL, 0))
3843 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3844 + sb->s_flags |= MS_TAGGED;
3846 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3847 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3849 @@ -3513,6 +3534,14 @@ static int ext4_remount(struct super_blo
3850 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3851 ext4_abort(sb, __func__, "Abort forced by user");
3853 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3854 + !(sb->s_flags & MS_TAGGED)) {
3855 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3858 + goto restore_opts;
3861 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3862 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3864 diff -NurpP --minimal linux-2.6.33/fs/fcntl.c linux-2.6.33-vs2.3.0.36.30/fs/fcntl.c
3865 --- linux-2.6.33/fs/fcntl.c 2010-02-25 11:52:05.000000000 +0100
3866 +++ linux-2.6.33-vs2.3.0.36.30/fs/fcntl.c 2010-02-25 12:02:16.000000000 +0100
3868 #include <linux/signal.h>
3869 #include <linux/rcupdate.h>
3870 #include <linux/pid_namespace.h>
3871 +#include <linux/vs_limit.h>
3873 #include <asm/poll.h>
3874 #include <asm/siginfo.h>
3875 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3878 filp_close(tofree, files);
3880 + vx_openfd_inc(newfd); /* fd was unused */
3884 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3888 + if (!vx_files_avail(1))
3891 err = security_file_fcntl(filp, cmd, arg);
3893 diff -NurpP --minimal linux-2.6.33/fs/file.c linux-2.6.33-vs2.3.0.36.30/fs/file.c
3894 --- linux-2.6.33/fs/file.c 2009-12-03 20:02:51.000000000 +0100
3895 +++ linux-2.6.33-vs2.3.0.36.30/fs/file.c 2010-02-25 12:02:16.000000000 +0100
3897 #include <linux/spinlock.h>
3898 #include <linux/rcupdate.h>
3899 #include <linux/workqueue.h>
3900 +#include <linux/vs_limit.h>
3902 struct fdtable_defer {
3904 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
3905 struct file *f = *old_fds++;
3908 + /* TODO: sum it first for check and performance */
3909 + vx_openfd_inc(open_files - i);
3912 * The fd may be claimed in the fd bitmap but not yet
3913 @@ -476,6 +479,7 @@ repeat:
3915 FD_CLR(fd, fdt->close_on_exec);
3917 + vx_openfd_inc(fd);
3920 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3921 diff -NurpP --minimal linux-2.6.33/fs/file_table.c linux-2.6.33-vs2.3.0.36.30/fs/file_table.c
3922 --- linux-2.6.33/fs/file_table.c 2010-02-25 11:52:05.000000000 +0100
3923 +++ linux-2.6.33-vs2.3.0.36.30/fs/file_table.c 2010-02-25 13:28:39.000000000 +0100
3925 #include <linux/sysctl.h>
3926 #include <linux/percpu_counter.h>
3927 #include <linux/ima.h>
3928 +#include <linux/vs_limit.h>
3929 +#include <linux/vs_context.h>
3931 #include <asm/atomic.h>
3933 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
3934 spin_lock_init(&f->f_lock);
3935 eventpoll_init_file(f);
3936 /* f->f_version: 0 */
3937 + f->f_xid = vx_current_xid();
3942 @@ -258,6 +262,8 @@ void __fput(struct file *file)
3943 cdev_put(inode->i_cdev);
3944 fops_put(file->f_op);
3945 put_pid(file->f_owner.pid);
3946 + vx_files_dec(file);
3949 if (file->f_mode & FMODE_WRITE)
3950 drop_file_write_access(file);
3951 @@ -325,6 +331,8 @@ void put_filp(struct file *file)
3953 if (atomic_long_dec_and_test(&file->f_count)) {
3954 security_file_free(file);
3955 + vx_files_dec(file);
3960 diff -NurpP --minimal linux-2.6.33/fs/fs_struct.c linux-2.6.33-vs2.3.0.36.30/fs/fs_struct.c
3961 --- linux-2.6.33/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
3962 +++ linux-2.6.33-vs2.3.0.36.30/fs/fs_struct.c 2010-02-25 12:02:16.000000000 +0100
3964 #include <linux/path.h>
3965 #include <linux/slab.h>
3966 #include <linux/fs_struct.h>
3967 +#include <linux/vserver/global.h>
3970 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
3971 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
3973 path_put(&fs->root);
3975 + atomic_dec(&vs_global_fs);
3976 kmem_cache_free(fs_cachep, fs);
3979 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
3981 path_get(&old->pwd);
3982 read_unlock(&old->lock);
3983 + atomic_inc(&vs_global_fs);
3987 diff -NurpP --minimal linux-2.6.33/fs/gfs2/file.c linux-2.6.33-vs2.3.0.36.30/fs/gfs2/file.c
3988 --- linux-2.6.33/fs/gfs2/file.c 2010-02-25 11:52:05.000000000 +0100
3989 +++ linux-2.6.33-vs2.3.0.36.30/fs/gfs2/file.c 2010-02-25 12:02:16.000000000 +0100
3990 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
3991 [7] = GFS2_DIF_NOATIME,
3992 [12] = GFS2_DIF_EXHASH,
3993 [14] = GFS2_DIF_INHERIT_JDATA,
3994 + [27] = GFS2_DIF_IXUNLINK,
3995 + [26] = GFS2_DIF_BARRIER,
3996 + [29] = GFS2_DIF_COW,
3999 static const u32 gfs2_to_fsflags[32] = {
4000 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4001 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4002 [gfs2fl_ExHash] = FS_INDEX_FL,
4003 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4004 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4005 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4006 + [gfs2fl_Cow] = FS_COW_FL,
4009 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4010 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4012 struct gfs2_inode *ip = GFS2_I(inode);
4013 unsigned int flags = inode->i_flags;
4014 + unsigned int vflags = inode->i_vflags;
4016 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4017 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4019 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4020 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4021 flags |= S_IMMUTABLE;
4022 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4023 + flags |= S_IXUNLINK;
4025 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4027 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4028 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4029 if (ip->i_diskflags & GFS2_DIF_SYNC)
4031 inode->i_flags = flags;
4033 + vflags &= ~(V_BARRIER | V_COW);
4035 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4036 + vflags |= V_BARRIER;
4037 + if (ip->i_diskflags & GFS2_DIF_COW)
4039 + inode->i_vflags = vflags;
4042 +void gfs2_get_inode_flags(struct inode *inode)
4044 + struct gfs2_inode *ip = GFS2_I(inode);
4045 + unsigned int flags = inode->i_flags;
4046 + unsigned int vflags = inode->i_vflags;
4048 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4049 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4050 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4051 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4053 + if (flags & S_IMMUTABLE)
4054 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4055 + if (flags & S_IXUNLINK)
4056 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4058 + if (flags & S_APPEND)
4059 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4060 + if (flags & S_NOATIME)
4061 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4062 + if (flags & S_SYNC)
4063 + ip->i_diskflags |= GFS2_DIF_SYNC;
4065 + if (vflags & V_BARRIER)
4066 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4067 + if (vflags & V_COW)
4068 + ip->i_diskflags |= GFS2_DIF_COW;
4071 /* Flags that can be set by user space */
4072 @@ -286,6 +335,37 @@ static int gfs2_set_flags(struct file *f
4073 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4076 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4078 + struct gfs2_inode *ip = GFS2_I(inode);
4079 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4080 + struct buffer_head *bh;
4081 + struct gfs2_holder gh;
4084 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4087 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4090 + error = gfs2_meta_inode_buffer(ip, &bh);
4092 + goto out_trans_end;
4093 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4094 + inode->i_flags = flags;
4095 + inode->i_vflags = vflags;
4096 + gfs2_get_inode_flags(inode);
4097 + gfs2_dinode_out(ip, bh->b_data);
4099 + gfs2_set_aops(inode);
4101 + gfs2_trans_end(sdp);
4103 + gfs2_glock_dq_uninit(&gh);
4107 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4110 diff -NurpP --minimal linux-2.6.33/fs/gfs2/inode.h linux-2.6.33-vs2.3.0.36.30/fs/gfs2/inode.h
4111 --- linux-2.6.33/fs/gfs2/inode.h 2009-09-10 15:26:22.000000000 +0200
4112 +++ linux-2.6.33-vs2.3.0.36.30/fs/gfs2/inode.h 2010-02-25 12:02:16.000000000 +0100
4113 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4114 extern const struct file_operations gfs2_dir_fops_nolock;
4116 extern void gfs2_set_inode_flags(struct inode *inode);
4117 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4119 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4120 extern const struct file_operations gfs2_file_fops;
4121 diff -NurpP --minimal linux-2.6.33/fs/gfs2/ops_inode.c linux-2.6.33-vs2.3.0.36.30/fs/gfs2/ops_inode.c
4122 --- linux-2.6.33/fs/gfs2/ops_inode.c 2010-02-25 11:52:05.000000000 +0100
4123 +++ linux-2.6.33-vs2.3.0.36.30/fs/gfs2/ops_inode.c 2010-02-25 12:02:16.000000000 +0100
4124 @@ -1403,6 +1403,7 @@ const struct inode_operations gfs2_file_
4125 .listxattr = gfs2_listxattr,
4126 .removexattr = gfs2_removexattr,
4127 .fiemap = gfs2_fiemap,
4128 + .sync_flags = gfs2_sync_flags,
4131 const struct inode_operations gfs2_dir_iops = {
4132 @@ -1423,6 +1424,7 @@ const struct inode_operations gfs2_dir_i
4133 .listxattr = gfs2_listxattr,
4134 .removexattr = gfs2_removexattr,
4135 .fiemap = gfs2_fiemap,
4136 + .sync_flags = gfs2_sync_flags,
4139 const struct inode_operations gfs2_symlink_iops = {
4140 diff -NurpP --minimal linux-2.6.33/fs/hfsplus/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/hfsplus/ioctl.c
4141 --- linux-2.6.33/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4142 +++ linux-2.6.33-vs2.3.0.36.30/fs/hfsplus/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4144 #include <linux/mount.h>
4145 #include <linux/sched.h>
4146 #include <linux/xattr.h>
4147 +#include <linux/mount.h>
4148 #include <asm/uaccess.h>
4149 #include "hfsplus_fs.h"
4151 diff -NurpP --minimal linux-2.6.33/fs/inode.c linux-2.6.33-vs2.3.0.36.30/fs/inode.c
4152 --- linux-2.6.33/fs/inode.c 2010-02-25 11:52:05.000000000 +0100
4153 +++ linux-2.6.33-vs2.3.0.36.30/fs/inode.c 2010-02-25 12:02:16.000000000 +0100
4154 @@ -132,6 +132,9 @@ int inode_init_always(struct super_block
4155 struct address_space *const mapping = &inode->i_data;
4159 + /* essential because of inode slab reuse */
4161 inode->i_blkbits = sb->s_blocksize_bits;
4163 atomic_set(&inode->i_count, 1);
4164 @@ -152,6 +155,7 @@ int inode_init_always(struct super_block
4165 inode->i_bdev = NULL;
4166 inode->i_cdev = NULL;
4168 + inode->i_mdev = 0;
4169 inode->dirtied_when = 0;
4171 if (security_inode_alloc(inode))
4172 @@ -297,6 +301,8 @@ void __iget(struct inode *inode)
4173 inodes_stat.nr_unused--;
4176 +EXPORT_SYMBOL_GPL(__iget);
4179 * clear_inode - clear an inode
4180 * @inode: inode to clear
4181 @@ -1601,9 +1607,11 @@ void init_special_inode(struct inode *in
4182 if (S_ISCHR(mode)) {
4183 inode->i_fop = &def_chr_fops;
4184 inode->i_rdev = rdev;
4185 + inode->i_mdev = rdev;
4186 } else if (S_ISBLK(mode)) {
4187 inode->i_fop = &def_blk_fops;
4188 inode->i_rdev = rdev;
4189 + inode->i_mdev = rdev;
4190 } else if (S_ISFIFO(mode))
4191 inode->i_fop = &def_fifo_fops;
4192 else if (S_ISSOCK(mode))
4193 diff -NurpP --minimal linux-2.6.33/fs/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/ioctl.c
4194 --- linux-2.6.33/fs/ioctl.c 2009-12-03 20:02:52.000000000 +0100
4195 +++ linux-2.6.33-vs2.3.0.36.30/fs/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4197 #include <linux/writeback.h>
4198 #include <linux/buffer_head.h>
4199 #include <linux/falloc.h>
4200 +#include <linux/proc_fs.h>
4201 +#include <linux/vserver/inode.h>
4202 +#include <linux/vs_tag.h>
4204 #include <asm/ioctls.h>
4206 diff -NurpP --minimal linux-2.6.33/fs/ioprio.c linux-2.6.33-vs2.3.0.36.30/fs/ioprio.c
4207 --- linux-2.6.33/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
4208 +++ linux-2.6.33-vs2.3.0.36.30/fs/ioprio.c 2010-02-25 12:02:16.000000000 +0100
4210 #include <linux/syscalls.h>
4211 #include <linux/security.h>
4212 #include <linux/pid_namespace.h>
4213 +#include <linux/vs_base.h>
4215 int set_task_ioprio(struct task_struct *task, int ioprio)
4217 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4219 pgrp = find_vpid(who);
4220 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4221 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4223 ret = set_task_ioprio(p, ioprio);
4226 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4228 pgrp = find_vpid(who);
4229 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4230 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4232 tmpio = get_task_ioprio(p);
4235 diff -NurpP --minimal linux-2.6.33/fs/jfs/acl.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/acl.c
4236 --- linux-2.6.33/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
4237 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/acl.c 2010-02-25 12:02:16.000000000 +0100
4238 @@ -216,7 +216,8 @@ int jfs_setattr(struct dentry *dentry, s
4241 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4242 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4243 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4244 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4245 if (vfs_dq_transfer(inode, iattr))
4248 diff -NurpP --minimal linux-2.6.33/fs/jfs/file.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/file.c
4249 --- linux-2.6.33/fs/jfs/file.c 2009-12-03 20:02:52.000000000 +0100
4250 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/file.c 2010-02-25 12:02:16.000000000 +0100
4251 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4252 .setattr = jfs_setattr,
4253 .check_acl = jfs_check_acl,
4255 + .sync_flags = jfs_sync_flags,
4258 const struct file_operations jfs_file_operations = {
4259 diff -NurpP --minimal linux-2.6.33/fs/jfs/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/ioctl.c
4260 --- linux-2.6.33/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4261 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4263 #include <linux/mount.h>
4264 #include <linux/time.h>
4265 #include <linux/sched.h>
4266 +#include <linux/mount.h>
4267 #include <asm/current.h>
4268 #include <asm/uaccess.h>
4270 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4274 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4276 + inode->i_flags = flags;
4277 + inode->i_vflags = vflags;
4278 + jfs_get_inode_flags(JFS_IP(inode));
4279 + inode->i_ctime = CURRENT_TIME_SEC;
4280 + mark_inode_dirty(inode);
4284 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4286 struct inode *inode = filp->f_dentry->d_inode;
4287 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4288 if (!S_ISDIR(inode->i_mode))
4289 flags &= ~JFS_DIRSYNC_FL;
4291 + if (IS_BARRIER(inode)) {
4292 + vxwprintk_task(1, "messing with the barrier.");
4296 /* Is it quota file? Do not allow user to mess with it */
4297 if (IS_NOQUOTA(inode)) {
4299 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4300 * the relevant capability.
4302 if ((oldflags & JFS_IMMUTABLE_FL) ||
4303 - ((flags ^ oldflags) &
4304 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4305 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4306 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4307 if (!capable(CAP_LINUX_IMMUTABLE)) {
4308 mutex_unlock(&inode->i_mutex);
4310 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4314 - flags = flags & JFS_FL_USER_MODIFIABLE;
4315 + flags &= JFS_FL_USER_MODIFIABLE;
4316 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4317 jfs_inode->mode2 = flags;
4319 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_dinode.h linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_dinode.h
4320 --- linux-2.6.33/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4321 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_dinode.h 2010-02-25 12:02:16.000000000 +0100
4322 @@ -161,9 +161,13 @@ struct dinode {
4324 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4325 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4326 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4328 -#define JFS_FL_USER_VISIBLE 0x03F80000
4329 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4330 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4331 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4333 +#define JFS_FL_USER_VISIBLE 0x07F80000
4334 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4335 #define JFS_FL_INHERIT 0x03C80000
4337 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4338 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_filsys.h linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_filsys.h
4339 --- linux-2.6.33/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4340 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_filsys.h 2010-02-25 12:02:16.000000000 +0100
4342 #define JFS_NAME_MAX 255
4343 #define JFS_PATH_MAX BPSIZE
4345 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4348 * file system state (superblock state)
4349 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_imap.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_imap.c
4350 --- linux-2.6.33/fs/jfs/jfs_imap.c 2009-09-10 15:26:22.000000000 +0200
4351 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_imap.c 2010-02-25 12:02:16.000000000 +0100
4353 #include <linux/buffer_head.h>
4354 #include <linux/pagemap.h>
4355 #include <linux/quotaops.h>
4356 +#include <linux/vs_tag.h>
4358 #include "jfs_incore.h"
4359 #include "jfs_inode.h"
4360 @@ -3059,6 +3060,8 @@ static int copy_from_dinode(struct dinod
4362 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4363 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4367 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4368 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4369 @@ -3079,14 +3082,18 @@ static int copy_from_dinode(struct dinod
4371 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4373 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4374 + uid = le32_to_cpu(dip->di_uid);
4375 + gid = le32_to_cpu(dip->di_gid);
4376 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4378 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4380 ip->i_uid = jfs_ip->saved_uid;
4382 ip->i_uid = sbi->uid;
4385 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4386 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4388 ip->i_gid = jfs_ip->saved_gid;
4390 @@ -3151,14 +3158,12 @@ static void copy_to_dinode(struct dinode
4391 dip->di_size = cpu_to_le64(ip->i_size);
4392 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4393 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4394 - if (sbi->uid == -1)
4395 - dip->di_uid = cpu_to_le32(ip->i_uid);
4397 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4398 - if (sbi->gid == -1)
4399 - dip->di_gid = cpu_to_le32(ip->i_gid);
4401 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4403 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4404 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4405 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4406 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4408 jfs_get_inode_flags(jfs_ip);
4410 * mode2 is only needed for storing the higher order bits.
4411 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_inode.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_inode.c
4412 --- linux-2.6.33/fs/jfs/jfs_inode.c 2009-06-11 17:13:05.000000000 +0200
4413 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_inode.c 2010-02-25 12:02:16.000000000 +0100
4416 #include <linux/fs.h>
4417 #include <linux/quotaops.h>
4418 +#include <linux/vs_tag.h>
4419 #include "jfs_incore.h"
4420 #include "jfs_inode.h"
4421 #include "jfs_filsys.h"
4422 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4424 unsigned int flags = JFS_IP(inode)->mode2;
4426 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4427 - S_NOATIME | S_DIRSYNC | S_SYNC);
4428 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4429 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4431 if (flags & JFS_IMMUTABLE_FL)
4432 inode->i_flags |= S_IMMUTABLE;
4433 + if (flags & JFS_IXUNLINK_FL)
4434 + inode->i_flags |= S_IXUNLINK;
4436 + if (flags & JFS_SYNC_FL)
4437 + inode->i_flags |= S_SYNC;
4438 if (flags & JFS_APPEND_FL)
4439 inode->i_flags |= S_APPEND;
4440 if (flags & JFS_NOATIME_FL)
4441 inode->i_flags |= S_NOATIME;
4442 if (flags & JFS_DIRSYNC_FL)
4443 inode->i_flags |= S_DIRSYNC;
4444 - if (flags & JFS_SYNC_FL)
4445 - inode->i_flags |= S_SYNC;
4447 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4449 + if (flags & JFS_BARRIER_FL)
4450 + inode->i_vflags |= V_BARRIER;
4451 + if (flags & JFS_COW_FL)
4452 + inode->i_vflags |= V_COW;
4455 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4457 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4458 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4460 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4461 + JFS_APPEND_FL | JFS_NOATIME_FL |
4462 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4463 + JFS_BARRIER_FL | JFS_COW_FL);
4465 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4466 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4467 if (flags & S_IMMUTABLE)
4468 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4469 + if (flags & S_IXUNLINK)
4470 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4472 if (flags & S_APPEND)
4473 jfs_ip->mode2 |= JFS_APPEND_FL;
4474 if (flags & S_NOATIME)
4475 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4476 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4478 jfs_ip->mode2 |= JFS_SYNC_FL;
4480 + if (vflags & V_BARRIER)
4481 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4482 + if (vflags & V_COW)
4483 + jfs_ip->mode2 |= JFS_COW_FL;
4487 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
4490 inode->i_gid = current_fsgid();
4491 + inode->i_tag = dx_current_fstag(sb);
4494 * New inodes need to save sane values on disk when
4495 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_inode.h linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_inode.h
4496 --- linux-2.6.33/fs/jfs/jfs_inode.h 2009-06-11 17:13:05.000000000 +0200
4497 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/jfs_inode.h 2010-02-25 12:02:16.000000000 +0100
4498 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4499 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4500 int fh_len, int fh_type);
4501 extern void jfs_set_inode_flags(struct inode *);
4502 +extern int jfs_sync_flags(struct inode *, int, int);
4503 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4505 extern const struct address_space_operations jfs_aops;
4506 diff -NurpP --minimal linux-2.6.33/fs/jfs/namei.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/namei.c
4507 --- linux-2.6.33/fs/jfs/namei.c 2009-12-03 20:02:52.000000000 +0100
4508 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/namei.c 2010-02-25 12:02:16.000000000 +0100
4510 #include <linux/ctype.h>
4511 #include <linux/quotaops.h>
4512 #include <linux/exportfs.h>
4513 +#include <linux/vs_tag.h>
4514 #include "jfs_incore.h"
4515 #include "jfs_superblock.h"
4516 #include "jfs_inode.h"
4517 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4518 return ERR_CAST(ip);
4521 + dx_propagate_tag(nd, ip);
4522 dentry = d_splice_alias(ip, dentry);
4524 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4525 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4526 .setattr = jfs_setattr,
4527 .check_acl = jfs_check_acl,
4529 + .sync_flags = jfs_sync_flags,
4532 const struct file_operations jfs_dir_operations = {
4533 diff -NurpP --minimal linux-2.6.33/fs/jfs/super.c linux-2.6.33-vs2.3.0.36.30/fs/jfs/super.c
4534 --- linux-2.6.33/fs/jfs/super.c 2010-02-25 11:52:05.000000000 +0100
4535 +++ linux-2.6.33-vs2.3.0.36.30/fs/jfs/super.c 2010-02-25 12:02:16.000000000 +0100
4536 @@ -192,7 +192,8 @@ static void jfs_put_super(struct super_b
4538 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4539 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4540 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4541 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4542 + Opt_tag, Opt_notag, Opt_tagid
4545 static const match_table_t tokens = {
4546 @@ -202,6 +203,10 @@ static const match_table_t tokens = {
4547 {Opt_resize, "resize=%u"},
4548 {Opt_resize_nosize, "resize"},
4549 {Opt_errors, "errors=%s"},
4551 + {Opt_notag, "notag"},
4552 + {Opt_tagid, "tagid=%u"},
4553 + {Opt_tag, "tagxid"},
4554 {Opt_ignore, "noquota"},
4555 {Opt_ignore, "quota"},
4556 {Opt_usrquota, "usrquota"},
4557 @@ -336,6 +341,20 @@ static int parse_options(char *options,
4561 +#ifndef CONFIG_TAGGING_NONE
4563 + *flag |= JFS_TAGGED;
4566 + *flag &= JFS_TAGGED;
4569 +#ifdef CONFIG_PROPAGATE
4572 + *flag |= JFS_TAGGED;
4576 printk("jfs: Unrecognized mount option \"%s\" "
4577 " or missing value\n", p);
4578 @@ -366,6 +385,12 @@ static int jfs_remount(struct super_bloc
4579 if (!parse_options(data, sb, &newLVSize, &flag)) {
4582 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4583 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4590 if (sb->s_flags & MS_RDONLY) {
4591 @@ -449,6 +474,9 @@ static int jfs_fill_super(struct super_b
4592 #ifdef CONFIG_JFS_POSIX_ACL
4593 sb->s_flags |= MS_POSIXACL;
4595 + /* map mount option tagxid */
4596 + if (sbi->flag & JFS_TAGGED)
4597 + sb->s_flags |= MS_TAGGED;
4600 printk(KERN_ERR "resize option for remount only\n");
4601 diff -NurpP --minimal linux-2.6.33/fs/libfs.c linux-2.6.33-vs2.3.0.36.30/fs/libfs.c
4602 --- linux-2.6.33/fs/libfs.c 2010-02-25 11:52:05.000000000 +0100
4603 +++ linux-2.6.33-vs2.3.0.36.30/fs/libfs.c 2010-02-25 12:02:16.000000000 +0100
4604 @@ -127,7 +127,8 @@ static inline unsigned char dt_type(stru
4605 * both impossible due to the lock on directory.
4608 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4609 +static inline int do_dcache_readdir_filter(struct file *filp,
4610 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4612 struct dentry *dentry = filp->f_path.dentry;
4613 struct dentry *cursor = filp->private_data;
4614 @@ -160,6 +161,8 @@ int dcache_readdir(struct file * filp, v
4615 next = list_entry(p, struct dentry, d_u.d_child);
4616 if (d_unhashed(next) || !next->d_inode)
4618 + if (filter && !filter(next))
4621 spin_unlock(&dcache_lock);
4622 if (filldir(dirent, next->d_name.name,
4623 @@ -178,6 +181,18 @@ int dcache_readdir(struct file * filp, v
4627 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4629 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4632 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4633 + int (*filter)(struct dentry *))
4635 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4639 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4642 @@ -841,6 +856,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4643 EXPORT_SYMBOL(dcache_dir_lseek);
4644 EXPORT_SYMBOL(dcache_dir_open);
4645 EXPORT_SYMBOL(dcache_readdir);
4646 +EXPORT_SYMBOL(dcache_readdir_filter);
4647 EXPORT_SYMBOL(generic_read_dir);
4648 EXPORT_SYMBOL(get_sb_pseudo);
4649 EXPORT_SYMBOL(simple_write_begin);
4650 diff -NurpP --minimal linux-2.6.33/fs/locks.c linux-2.6.33-vs2.3.0.36.30/fs/locks.c
4651 --- linux-2.6.33/fs/locks.c 2009-12-03 20:02:52.000000000 +0100
4652 +++ linux-2.6.33-vs2.3.0.36.30/fs/locks.c 2010-02-25 12:02:16.000000000 +0100
4654 #include <linux/time.h>
4655 #include <linux/rcupdate.h>
4656 #include <linux/pid_namespace.h>
4657 +#include <linux/vs_base.h>
4658 +#include <linux/vs_limit.h>
4660 #include <asm/uaccess.h>
4662 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4663 /* Allocate an empty lock structure. */
4664 static struct file_lock *locks_alloc_lock(void)
4666 + if (!vx_locks_avail(1))
4668 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4671 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4672 BUG_ON(!list_empty(&fl->fl_block));
4673 BUG_ON(!list_empty(&fl->fl_link));
4676 locks_release_private(fl);
4677 kmem_cache_free(filelock_cache, fl);
4679 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
4680 fl->fl_start = fl->fl_end = 0;
4682 fl->fl_lmops = NULL;
4686 EXPORT_SYMBOL(locks_init_lock);
4687 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
4688 new->fl_file = fl->fl_file;
4689 new->fl_ops = fl->fl_ops;
4690 new->fl_lmops = fl->fl_lmops;
4691 + new->fl_xid = fl->fl_xid;
4693 locks_copy_private(new, fl);
4695 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
4696 fl->fl_flags = FL_FLOCK;
4698 fl->fl_end = OFFSET_MAX;
4700 + vxd_assert(filp->f_xid == vx_current_xid(),
4701 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4702 + fl->fl_xid = filp->f_xid;
4707 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
4709 fl->fl_owner = current->files;
4710 fl->fl_pid = current->tgid;
4711 + fl->fl_xid = vx_current_xid();
4714 fl->fl_flags = FL_LEASE;
4715 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
4717 return ERR_PTR(error);
4719 + fl->fl_xid = vx_current_xid();
4721 + vxd_assert(filp->f_xid == fl->fl_xid,
4722 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4724 error = lease_init(filp, type, fl);
4726 locks_free_lock(fl);
4727 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
4731 + new_fl->fl_xid = -1;
4733 for_each_lock(inode, before) {
4734 struct file_lock *fl = *before;
4735 @@ -790,6 +809,7 @@ find_conflict:
4737 locks_copy_lock(new_fl, request);
4738 locks_insert_lock(before, new_fl);
4739 + vx_locks_inc(new_fl);
4743 @@ -800,7 +820,8 @@ out:
4747 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4748 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4749 + struct file_lock *conflock, xid_t xid)
4751 struct file_lock *fl;
4752 struct file_lock *new_fl = NULL;
4753 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
4754 struct file_lock **before;
4755 int error, added = 0;
4757 + vxd_assert(xid == vx_current_xid(),
4758 + "xid(%d) == current(%d)", xid, vx_current_xid());
4760 * We may need two file_lock structures for this operation,
4761 * so we get them in advance to avoid races.
4762 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
4763 (request->fl_type != F_UNLCK ||
4764 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4765 new_fl = locks_alloc_lock();
4766 + new_fl->fl_xid = xid;
4767 + vx_locks_inc(new_fl);
4768 new_fl2 = locks_alloc_lock();
4769 + new_fl2->fl_xid = xid;
4770 + vx_locks_inc(new_fl2);
4774 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
4775 int posix_lock_file(struct file *filp, struct file_lock *fl,
4776 struct file_lock *conflock)
4778 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4779 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4780 + fl, conflock, filp->f_xid);
4782 EXPORT_SYMBOL(posix_lock_file);
4784 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
4785 fl.fl_end = offset + count - 1;
4788 - error = __posix_lock_file(inode, &fl, NULL);
4789 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4790 if (error != FILE_LOCK_DEFERRED)
4792 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4793 @@ -1424,6 +1452,7 @@ int generic_setlease(struct file *filp,
4795 locks_copy_lock(new_fl, lease);
4796 locks_insert_lock(before, new_fl);
4797 + vx_locks_inc(new_fl);
4801 @@ -1779,6 +1808,11 @@ int fcntl_setlk(unsigned int fd, struct
4802 if (file_lock == NULL)
4805 + vxd_assert(filp->f_xid == vx_current_xid(),
4806 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4807 + file_lock->fl_xid = filp->f_xid;
4808 + vx_locks_inc(file_lock);
4811 * This might block, so we do it before checking the inode.
4813 @@ -1897,6 +1931,11 @@ int fcntl_setlk64(unsigned int fd, struc
4814 if (file_lock == NULL)
4817 + vxd_assert(filp->f_xid == vx_current_xid(),
4818 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4819 + file_lock->fl_xid = filp->f_xid;
4820 + vx_locks_inc(file_lock);
4823 * This might block, so we do it before checking the inode.
4825 @@ -2162,8 +2201,11 @@ static int locks_show(struct seq_file *f
4827 lock_get_status(f, fl, (long)f->private, "");
4829 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4830 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4831 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4833 lock_get_status(f, bfl, (long)f->private, " ->");
4838 diff -NurpP --minimal linux-2.6.33/fs/namei.c linux-2.6.33-vs2.3.0.36.30/fs/namei.c
4839 --- linux-2.6.33/fs/namei.c 2010-02-25 11:52:05.000000000 +0100
4840 +++ linux-2.6.33-vs2.3.0.36.30/fs/namei.c 2010-02-25 15:31:15.000000000 +0100
4842 #include <linux/fcntl.h>
4843 #include <linux/device_cgroup.h>
4844 #include <linux/fs_struct.h>
4845 +#include <linux/proc_fs.h>
4846 +#include <linux/vserver/inode.h>
4847 +#include <linux/vs_base.h>
4848 +#include <linux/vs_tag.h>
4849 +#include <linux/vs_cowbl.h>
4850 +#include <linux/vs_device.h>
4851 +#include <linux/vs_context.h>
4852 +#include <linux/pid_namespace.h>
4853 #include <asm/uaccess.h>
4855 #include "internal.h"
4856 @@ -167,6 +175,77 @@ void putname(const char *name)
4857 EXPORT_SYMBOL(putname);
4860 +static inline int dx_barrier(const struct inode *inode)
4862 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4863 + vxwprintk_task(1, "did hit the barrier.");
4869 +static int __dx_permission(const struct inode *inode, int mask)
4871 + if (dx_barrier(inode))
4874 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4875 + /* devpts is xid tagged */
4876 + if (S_ISDIR(inode->i_mode) ||
4877 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4880 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4881 + struct proc_dir_entry *de = PDE(inode);
4883 + if (de && !vx_hide_check(0, de->vx_flags))
4886 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4888 + struct task_struct *tsk;
4890 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4891 + vx_flags(VXF_STATE_SETUP, 0))
4894 + pid = PROC_I(inode)->pid;
4898 + tsk = pid_task(pid, PIDTYPE_PID);
4899 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4900 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4901 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4905 + /* FIXME: Should we block some entries here? */
4910 + if (dx_notagcheck(inode->i_sb) ||
4911 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4920 +int dx_permission(const struct inode *inode, int mask)
4922 + int ret = __dx_permission(inode, mask);
4923 + if (unlikely(ret)) {
4924 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
4925 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4932 * This does basic POSIX ACL permission checking
4934 @@ -267,10 +346,14 @@ int inode_permission(struct inode *inode
4936 * Nobody gets write access to an immutable file.
4938 - if (IS_IMMUTABLE(inode))
4939 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4943 + retval = dx_permission(inode, mask);
4947 if (inode->i_op->permission)
4948 retval = inode->i_op->permission(inode, mask);
4950 @@ -465,6 +548,9 @@ static int exec_permission(struct inode
4954 + if (dx_barrier(inode))
4957 if (inode->i_op->permission) {
4958 ret = inode->i_op->permission(inode, MAY_EXEC);
4960 @@ -694,7 +780,8 @@ static __always_inline void follow_dotdo
4962 if (nd->path.dentry == nd->root.dentry &&
4963 nd->path.mnt == nd->root.mnt) {
4965 + /* for sane '/' avoid follow_mount() */
4968 spin_lock(&dcache_lock);
4969 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4970 @@ -730,7 +817,7 @@ static int do_lookup(struct nameidata *n
4972 struct vfsmount *mnt = nd->path.mnt;
4973 struct dentry *dentry, *parent;
4974 - struct inode *dir;
4975 + struct inode *dir, *inode;
4977 * See if the low-level filesystem might want
4978 * to use its own hash..
4979 @@ -746,12 +833,26 @@ static int do_lookup(struct nameidata *n
4981 if (dentry->d_op && dentry->d_op->d_revalidate)
4982 goto need_revalidate;
4984 + inode = dentry->d_inode;
4988 + if (__dx_permission(inode, MAY_ACCESS))
4992 path->dentry = dentry;
4993 __follow_mount(path);
4997 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
4998 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
4999 + vxd_path(&nd->path), name->len, name->name);
5004 parent = nd->path.dentry;
5005 dir = parent->d_inode;
5006 @@ -1355,7 +1456,7 @@ static int may_delete(struct inode *dir,
5009 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5010 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5011 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5014 if (!S_ISDIR(victim->d_inode->i_mode))
5015 @@ -1495,6 +1596,14 @@ int may_open(struct path *path, int acc_
5019 +#ifdef CONFIG_VSERVER_COWBL
5020 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5021 + if (IS_COW_LINK(inode))
5023 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5024 + mark_inode_dirty(inode);
5027 error = inode_permission(inode, acc_mode);
5030 @@ -1621,6 +1730,11 @@ struct file *do_filp_open(int dfd, const
5031 int flag = open_to_namei_flags(open_flag);
5032 int force_reval = 0;
5034 +#ifdef CONFIG_VSERVER_COWBL
5040 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
5041 * check for O_DSYNC if the need any syncing at all we enforce it's
5042 @@ -1799,6 +1913,25 @@ ok:
5045 error = may_open(&nd.path, acc_mode, flag);
5046 +#ifdef CONFIG_VSERVER_COWBL
5047 + if (error == -EMLINK) {
5048 + struct dentry *dentry;
5049 + dentry = cow_break_link(pathname);
5050 + if (IS_ERR(dentry)) {
5051 + error = PTR_ERR(dentry);
5055 + if (will_truncate)
5056 + mnt_drop_write(nd.path.mnt);
5057 + release_open_intent(&nd);
5058 + path_put(&nd.path);
5067 mnt_drop_write(nd.path.mnt);
5068 @@ -1982,9 +2115,17 @@ int vfs_mknod(struct inode *dir, struct
5072 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5073 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5076 + if (!capable(CAP_MKNOD))
5079 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5081 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5084 if (!dir->i_op->mknod)
5087 @@ -2451,7 +2592,7 @@ int vfs_link(struct dentry *old_dentry,
5089 * A link to an append-only or immutable file cannot be created.
5091 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5092 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5094 if (!dir->i_op->link)
5096 @@ -2824,6 +2965,219 @@ int vfs_follow_link(struct nameidata *nd
5097 return __vfs_follow_link(nd, link);
5101 +#ifdef CONFIG_VSERVER_COWBL
5103 +#include <linux/file.h>
5106 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5110 + return do_splice_direct(in, &ppos, out, len, 0);
5113 +struct dentry *cow_break_link(const char *pathname)
5115 + int ret, mode, pathlen, redo = 0;
5116 + struct nameidata old_nd, dir_nd;
5117 + struct path old_path, new_path;
5118 + struct dentry *dir, *res = NULL;
5119 + struct file *old_file;
5120 + struct file *new_file;
5121 + char *to, *path, pad='\251';
5124 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5125 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5130 + /* old_nd will have refs to dentry and mnt */
5131 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5132 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5134 + goto out_free_path;
5136 + old_path = old_nd.path;
5137 + mode = old_path.dentry->d_inode->i_mode;
5139 + to = d_path(&old_path, path, PATH_MAX-2);
5140 + pathlen = strlen(to);
5141 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5142 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5143 + old_path.dentry->d_name.len);
5145 + to[pathlen + 1] = 0;
5147 + to[pathlen] = pad--;
5149 + if (pad <= '\240')
5152 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5153 + /* dir_nd will have refs to dentry and mnt */
5154 + ret = path_lookup(to,
5155 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5156 + vxdprintk(VXD_CBIT(misc, 2),
5157 + "path_lookup(new): %d", ret);
5161 + /* this puppy downs the inode mutex */
5162 + new_path.dentry = lookup_create(&dir_nd, 0);
5163 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5164 + vxdprintk(VXD_CBIT(misc, 2),
5165 + "lookup_create(new): %p", new_path.dentry);
5166 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5167 + path_put(&dir_nd.path);
5170 + vxdprintk(VXD_CBIT(misc, 2),
5171 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5172 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5173 + new_path.dentry->d_name.len);
5174 + dir = dir_nd.path.dentry;
5176 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5177 + vxdprintk(VXD_CBIT(misc, 2),
5178 + "vfs_create(new): %d", ret);
5179 + if (ret == -EEXIST) {
5180 + mutex_unlock(&dir->d_inode->i_mutex);
5181 + dput(new_path.dentry);
5182 + path_put(&dir_nd.path);
5186 + goto out_unlock_new;
5188 + /* drop out early, ret passes ENOENT */
5190 + if ((redo = d_unhashed(old_path.dentry)))
5191 + goto out_unlock_new;
5193 + new_path.mnt = dir_nd.path.mnt;
5194 + dget(old_path.dentry);
5195 + mntget(old_path.mnt);
5196 + /* this one cleans up the dentry/mnt in case of failure */
5197 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5198 + O_RDONLY, current_cred());
5199 + vxdprintk(VXD_CBIT(misc, 2),
5200 + "dentry_open(old): %p", old_file);
5201 + if (!old_file || IS_ERR(old_file)) {
5202 + res = IS_ERR(old_file) ? (void *) old_file : res;
5203 + goto out_unlock_new;
5206 + dget(new_path.dentry);
5207 + mntget(new_path.mnt);
5208 + /* this one cleans up the dentry/mnt in case of failure */
5209 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5210 + O_WRONLY, current_cred());
5211 + vxdprintk(VXD_CBIT(misc, 2),
5212 + "dentry_open(new): %p", new_file);
5214 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5215 + if (!new_file || IS_ERR(new_file))
5216 + goto out_fput_old;
5218 + size = i_size_read(old_file->f_dentry->d_inode);
5219 + ret = do_cow_splice(old_file, new_file, size);
5220 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5222 + goto out_fput_both;
5223 + } else if (ret < size) {
5225 + goto out_fput_both;
5227 + struct inode *old_inode = old_path.dentry->d_inode;
5228 + struct inode *new_inode = new_path.dentry->d_inode;
5229 + struct iattr attr = {
5230 + .ia_uid = old_inode->i_uid,
5231 + .ia_gid = old_inode->i_gid,
5232 + .ia_valid = ATTR_UID | ATTR_GID
5235 + ret = inode_setattr(new_inode, &attr);
5237 + goto out_fput_both;
5240 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5242 + /* drop out late */
5244 + if ((redo = d_unhashed(old_path.dentry)))
5247 + vxdprintk(VXD_CBIT(misc, 2),
5248 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5249 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5250 + new_path.dentry->d_name.len,
5251 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5252 + old_path.dentry->d_name.len);
5253 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5254 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5255 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5256 + res = new_path.dentry;
5259 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5262 + vxdprintk(VXD_CBIT(misc, 3),
5263 + "fput(new_file=%p[#%ld])", new_file,
5264 + atomic_long_read(&new_file->f_count));
5268 + vxdprintk(VXD_CBIT(misc, 3),
5269 + "fput(old_file=%p[#%ld])", old_file,
5270 + atomic_long_read(&old_file->f_count));
5274 + mutex_unlock(&dir->d_inode->i_mutex);
5278 + /* error path cleanup */
5279 + vfs_unlink(dir->d_inode, new_path.dentry);
5280 + dput(new_path.dentry);
5284 + goto out_rel_both;
5285 + /* lookup dentry once again */
5286 + path_put(&old_nd.path);
5287 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5289 + goto out_rel_both;
5291 + new_path.dentry = old_nd.path.dentry;
5292 + vxdprintk(VXD_CBIT(misc, 2),
5293 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5294 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5295 + new_path.dentry->d_name.len);
5296 + dget(new_path.dentry);
5297 + res = new_path.dentry;
5300 + path_put(&dir_nd.path);
5302 + path_put(&old_nd.path);
5307 + res = ERR_PTR(ret);
5313 /* get the link contents into pagecache */
5314 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5316 diff -NurpP --minimal linux-2.6.33/fs/namespace.c linux-2.6.33-vs2.3.0.36.30/fs/namespace.c
5317 --- linux-2.6.33/fs/namespace.c 2010-02-25 11:52:05.000000000 +0100
5318 +++ linux-2.6.33-vs2.3.0.36.30/fs/namespace.c 2010-02-25 12:02:16.000000000 +0100
5320 #include <linux/log2.h>
5321 #include <linux/idr.h>
5322 #include <linux/fs_struct.h>
5323 +#include <linux/vs_base.h>
5324 +#include <linux/vs_context.h>
5325 +#include <linux/vs_tag.h>
5326 +#include <linux/vserver/space.h>
5327 +#include <linux/vserver/global.h>
5328 #include <asm/uaccess.h>
5329 #include <asm/unistd.h>
5331 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
5332 mnt->mnt_root = dget(root);
5333 mnt->mnt_mountpoint = mnt->mnt_root;
5334 mnt->mnt_parent = mnt;
5335 + mnt->mnt_tag = old->mnt_tag;
5337 if (flag & CL_SLAVE) {
5338 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5339 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
5340 seq_escape(m, s, " \t\n\\");
5343 +static int mnt_is_reachable(struct vfsmount *mnt)
5346 + struct dentry *point;
5349 + if (mnt == mnt->mnt_ns->root)
5352 + spin_lock(&vfsmount_lock);
5353 + root = current->fs->root;
5354 + point = root.dentry;
5356 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5357 + point = mnt->mnt_mountpoint;
5358 + mnt = mnt->mnt_parent;
5361 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5363 + spin_unlock(&vfsmount_lock);
5369 * Simple .show_options callback for filesystems which don't want to
5370 * implement more complex mount option showing.
5371 @@ -748,6 +779,8 @@ static int show_sb_opts(struct seq_file
5372 { MS_SYNCHRONOUS, ",sync" },
5373 { MS_DIRSYNC, ",dirsync" },
5374 { MS_MANDLOCK, ",mand" },
5375 + { MS_TAGGED, ",tag" },
5376 + { MS_NOTAGCHECK, ",notagcheck" },
5379 const struct proc_fs_info *fs_infop;
5380 @@ -795,10 +828,20 @@ static int show_vfsmnt(struct seq_file *
5382 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5384 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5386 - seq_path(m, &mnt_path, " \t\n\\");
5388 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5390 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5393 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5394 + mnt == current->fs->root.mnt) {
5395 + seq_puts(m, "/dev/root / ");
5397 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5399 + seq_path(m, &mnt_path, " \t\n\\");
5402 show_type(m, mnt->mnt_sb);
5403 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5404 err = show_sb_opts(m, mnt->mnt_sb);
5405 @@ -828,6 +871,11 @@ static int show_mountinfo(struct seq_fil
5406 struct path root = p->root;
5409 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5411 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5414 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5415 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5416 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5417 @@ -886,17 +934,27 @@ static int show_vfsstat(struct seq_file
5418 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5422 - if (mnt->mnt_devname) {
5423 - seq_puts(m, "device ");
5424 - mangle(m, mnt->mnt_devname);
5426 - seq_puts(m, "no device");
5427 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5429 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5433 - seq_puts(m, " mounted on ");
5434 - seq_path(m, &mnt_path, " \t\n\\");
5436 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5437 + mnt == current->fs->root.mnt) {
5438 + seq_puts(m, "device /dev/root mounted on / ");
5441 + if (mnt->mnt_devname) {
5442 + seq_puts(m, "device ");
5443 + mangle(m, mnt->mnt_devname);
5445 + seq_puts(m, "no device");
5448 + seq_puts(m, " mounted on ");
5449 + seq_path(m, &mnt_path, " \t\n\\");
5453 /* file system type */
5454 seq_puts(m, "with fstype ");
5455 @@ -1132,7 +1190,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5459 - if (!capable(CAP_SYS_ADMIN))
5460 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5463 retval = do_umount(path.mnt, flags);
5464 @@ -1158,7 +1216,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5466 static int mount_is_safe(struct path *path)
5468 - if (capable(CAP_SYS_ADMIN))
5469 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5473 @@ -1422,7 +1480,7 @@ static int do_change_type(struct path *p
5474 int type = flag & ~MS_REC;
5477 - if (!capable(CAP_SYS_ADMIN))
5478 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5481 if (path->dentry != path->mnt->mnt_root)
5482 @@ -1449,11 +1507,13 @@ static int do_change_type(struct path *p
5483 * do loopback mount.
5485 static int do_loopback(struct path *path, char *old_name,
5487 + tag_t tag, unsigned long flags, int mnt_flags)
5489 struct path old_path;
5490 struct vfsmount *mnt = NULL;
5491 int err = mount_is_safe(path);
5492 + int recurse = flags & MS_REC;
5496 if (!old_name || !*old_name)
5497 @@ -1487,6 +1547,7 @@ static int do_loopback(struct path *path
5498 spin_unlock(&vfsmount_lock);
5499 release_mounts(&umount_list);
5501 + mnt->mnt_flags = mnt_flags;
5504 up_write(&namespace_sem);
5505 @@ -1517,12 +1578,12 @@ static int change_mount_flags(struct vfs
5506 * on it - tough luck.
5508 static int do_remount(struct path *path, int flags, int mnt_flags,
5510 + void *data, xid_t xid)
5513 struct super_block *sb = path->mnt->mnt_sb;
5515 - if (!capable(CAP_SYS_ADMIN))
5516 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5519 if (!check_mnt(path->mnt))
5520 @@ -1568,7 +1629,7 @@ static int do_move_mount(struct path *pa
5521 struct path old_path, parent_path;
5524 - if (!capable(CAP_SYS_ADMIN))
5525 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5527 if (!old_name || !*old_name)
5529 @@ -1650,7 +1711,7 @@ static int do_new_mount(struct path *pat
5532 /* we need capabilities... */
5533 - if (!capable(CAP_SYS_ADMIN))
5534 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5538 @@ -1916,6 +1977,7 @@ long do_mount(char *dev_name, char *dir_
5545 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5546 @@ -1943,6 +2005,12 @@ long do_mount(char *dev_name, char *dir_
5547 if (!(flags & MS_NOATIME))
5548 mnt_flags |= MNT_RELATIME;
5550 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5551 + /* FIXME: bind and re-mounts get the tag flag? */
5552 + if (flags & (MS_BIND|MS_REMOUNT))
5553 + flags |= MS_TAGID;
5556 /* Separate the per-mountpoint flags */
5557 if (flags & MS_NOSUID)
5558 mnt_flags |= MNT_NOSUID;
5559 @@ -1959,15 +2027,17 @@ long do_mount(char *dev_name, char *dir_
5560 if (flags & MS_RDONLY)
5561 mnt_flags |= MNT_READONLY;
5563 + if (!capable(CAP_SYS_ADMIN))
5564 + mnt_flags |= MNT_NODEV;
5565 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5566 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5569 if (flags & MS_REMOUNT)
5570 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5573 else if (flags & MS_BIND)
5574 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5575 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5576 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5577 retval = do_change_type(&path, flags);
5578 else if (flags & MS_MOVE)
5579 @@ -2046,6 +2116,7 @@ static struct mnt_namespace *dup_mnt_ns(
5580 q = next_mnt(q, new_ns->root);
5582 up_write(&namespace_sem);
5583 + atomic_inc(&vs_global_mnt_ns);
5587 @@ -2190,9 +2261,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5588 down_write(&namespace_sem);
5589 mutex_lock(&old.dentry->d_inode->i_mutex);
5591 - if (IS_MNT_SHARED(old.mnt) ||
5592 + if ((IS_MNT_SHARED(old.mnt) ||
5593 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5594 - IS_MNT_SHARED(root.mnt->mnt_parent))
5595 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5596 + !vx_flags(VXF_STATE_SETUP, 0))
5598 if (!check_mnt(root.mnt))
5600 @@ -2328,6 +2400,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5601 spin_unlock(&vfsmount_lock);
5602 up_write(&namespace_sem);
5603 release_mounts(&umount_list);
5604 + atomic_dec(&vs_global_mnt_ns);
5607 EXPORT_SYMBOL(put_mnt_ns);
5608 diff -NurpP --minimal linux-2.6.33/fs/nfs/client.c linux-2.6.33-vs2.3.0.36.30/fs/nfs/client.c
5609 --- linux-2.6.33/fs/nfs/client.c 2010-02-25 11:52:05.000000000 +0100
5610 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfs/client.c 2010-02-25 12:02:16.000000000 +0100
5611 @@ -738,6 +738,9 @@ static int nfs_init_server_rpcclient(str
5612 if (server->flags & NFS_MOUNT_SOFT)
5613 server->client->cl_softrtry = 1;
5615 + server->client->cl_tag = 0;
5616 + if (server->flags & NFS_MOUNT_TAGGED)
5617 + server->client->cl_tag = 1;
5621 @@ -909,6 +912,10 @@ static void nfs_server_set_fsinfo(struct
5622 server->acdirmin = server->acdirmax = 0;
5625 + /* FIXME: needs fsinfo
5626 + if (server->flags & NFS_MOUNT_TAGGED)
5627 + sb->s_flags |= MS_TAGGED; */
5629 server->maxfilesize = fsinfo->maxfilesize;
5631 /* We're airborne Set socket buffersize */
5632 diff -NurpP --minimal linux-2.6.33/fs/nfs/dir.c linux-2.6.33-vs2.3.0.36.30/fs/nfs/dir.c
5633 --- linux-2.6.33/fs/nfs/dir.c 2010-02-25 11:52:05.000000000 +0100
5634 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfs/dir.c 2010-02-25 12:02:16.000000000 +0100
5636 #include <linux/namei.h>
5637 #include <linux/mount.h>
5638 #include <linux/sched.h>
5639 +#include <linux/vs_tag.h>
5641 #include "nfs4_fs.h"
5642 #include "delegation.h"
5643 @@ -949,6 +950,7 @@ static struct dentry *nfs_lookup(struct
5645 goto out_unblock_sillyrename;
5647 + dx_propagate_tag(nd, inode);
5649 res = d_materialise_unique(dentry, inode);
5651 diff -NurpP --minimal linux-2.6.33/fs/nfs/inode.c linux-2.6.33-vs2.3.0.36.30/fs/nfs/inode.c
5652 --- linux-2.6.33/fs/nfs/inode.c 2010-02-25 11:52:05.000000000 +0100
5653 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfs/inode.c 2010-02-25 12:02:16.000000000 +0100
5655 #include <linux/vfs.h>
5656 #include <linux/inet.h>
5657 #include <linux/nfs_xdr.h>
5658 +#include <linux/vs_tag.h>
5660 #include <asm/system.h>
5661 #include <asm/uaccess.h>
5662 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5663 if (inode->i_state & I_NEW) {
5664 struct nfs_inode *nfsi = NFS_I(inode);
5665 unsigned long now = jiffies;
5669 /* We set i_ino for the few things that still rely on it,
5670 * such as stat(2) */
5671 @@ -327,8 +330,8 @@ nfs_fhget(struct super_block *sb, struct
5672 nfsi->change_attr = 0;
5675 - inode->i_uid = -2;
5676 - inode->i_gid = -2;
5679 inode->i_blocks = 0;
5680 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5682 @@ -365,13 +368,13 @@ nfs_fhget(struct super_block *sb, struct
5683 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5684 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5685 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5686 - inode->i_uid = fattr->uid;
5688 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5689 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5690 | NFS_INO_INVALID_ACCESS
5691 | NFS_INO_INVALID_ACL;
5692 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5693 - inode->i_gid = fattr->gid;
5695 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5696 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5697 | NFS_INO_INVALID_ACCESS
5698 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
5700 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5702 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5703 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5704 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5705 + /* maybe fattr->xid someday */
5707 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5708 nfsi->attrtimeo_timestamp = now;
5709 nfsi->access_cache = RB_ROOT;
5710 @@ -496,6 +504,8 @@ void nfs_setattr_update_inode(struct ino
5711 inode->i_uid = attr->ia_uid;
5712 if ((attr->ia_valid & ATTR_GID) != 0)
5713 inode->i_gid = attr->ia_gid;
5714 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5715 + inode->i_tag = attr->ia_tag;
5716 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5717 spin_unlock(&inode->i_lock);
5719 @@ -906,6 +916,9 @@ static int nfs_check_inode_attributes(st
5720 struct nfs_inode *nfsi = NFS_I(inode);
5721 loff_t cur_size, new_isize;
5722 unsigned long invalid = 0;
5728 /* Has the inode gone and changed behind our back? */
5729 @@ -929,13 +942,18 @@ static int nfs_check_inode_attributes(st
5730 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5733 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5734 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5735 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5737 /* Have any file permissions changed? */
5738 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5739 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5740 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5741 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5742 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5743 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5744 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5745 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5746 + /* maybe check for tag too? */
5748 /* Has the link count changed? */
5749 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5750 @@ -1150,6 +1168,9 @@ static int nfs_update_inode(struct inode
5751 unsigned long invalid = 0;
5752 unsigned long now = jiffies;
5753 unsigned long save_cache_validity;
5758 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5759 __func__, inode->i_sb->s_id, inode->i_ino,
5760 @@ -1252,6 +1273,9 @@ static int nfs_update_inode(struct inode
5761 | NFS_INO_REVAL_PAGECACHE
5762 | NFS_INO_REVAL_FORCED);
5764 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5765 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5766 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5768 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5769 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5770 @@ -1273,9 +1297,9 @@ static int nfs_update_inode(struct inode
5771 | NFS_INO_REVAL_FORCED);
5773 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5774 - if (inode->i_uid != fattr->uid) {
5775 + if (uid != fattr->uid) {
5776 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5777 - inode->i_uid = fattr->uid;
5780 } else if (server->caps & NFS_CAP_OWNER)
5781 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5782 @@ -1284,9 +1308,9 @@ static int nfs_update_inode(struct inode
5783 | NFS_INO_REVAL_FORCED);
5785 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5786 - if (inode->i_gid != fattr->gid) {
5787 + if (gid != fattr->gid) {
5788 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5789 - inode->i_gid = fattr->gid;
5792 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5793 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5794 @@ -1294,6 +1318,10 @@ static int nfs_update_inode(struct inode
5795 | NFS_INO_INVALID_ACL
5796 | NFS_INO_REVAL_FORCED);
5798 + inode->i_uid = uid;
5799 + inode->i_gid = gid;
5800 + inode->i_tag = tag;
5802 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5803 if (inode->i_nlink != fattr->nlink) {
5804 invalid |= NFS_INO_INVALID_ATTR;
5805 diff -NurpP --minimal linux-2.6.33/fs/nfs/nfs3xdr.c linux-2.6.33-vs2.3.0.36.30/fs/nfs/nfs3xdr.c
5806 --- linux-2.6.33/fs/nfs/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
5807 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfs/nfs3xdr.c 2010-02-25 12:02:16.000000000 +0100
5809 #include <linux/nfs3.h>
5810 #include <linux/nfs_fs.h>
5811 #include <linux/nfsacl.h>
5812 +#include <linux/vs_tag.h>
5813 #include "internal.h"
5815 #define NFSDBG_FACILITY NFSDBG_XDR
5816 @@ -176,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5819 static inline __be32 *
5820 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5821 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5823 if (attr->ia_valid & ATTR_MODE) {
5825 @@ -184,15 +185,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5829 - if (attr->ia_valid & ATTR_UID) {
5830 + if (attr->ia_valid & ATTR_UID ||
5831 + (tag && (attr->ia_valid & ATTR_TAG))) {
5833 - *p++ = htonl(attr->ia_uid);
5834 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5838 - if (attr->ia_valid & ATTR_GID) {
5839 + if (attr->ia_valid & ATTR_GID ||
5840 + (tag && (attr->ia_valid & ATTR_TAG))) {
5842 - *p++ = htonl(attr->ia_gid);
5843 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5847 @@ -279,7 +282,8 @@ static int
5848 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5850 p = xdr_encode_fhandle(p, args->fh);
5851 - p = xdr_encode_sattr(p, args->sattr);
5852 + p = xdr_encode_sattr(p, args->sattr,
5853 + req->rq_task->tk_client->cl_tag);
5854 *p++ = htonl(args->guard);
5856 p = xdr_encode_time3(p, &args->guardtime);
5857 @@ -384,7 +388,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5858 *p++ = args->verifier[0];
5859 *p++ = args->verifier[1];
5861 - p = xdr_encode_sattr(p, args->sattr);
5862 + p = xdr_encode_sattr(p, args->sattr,
5863 + req->rq_task->tk_client->cl_tag);
5865 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5867 @@ -398,7 +403,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5869 p = xdr_encode_fhandle(p, args->fh);
5870 p = xdr_encode_array(p, args->name, args->len);
5871 - p = xdr_encode_sattr(p, args->sattr);
5872 + p = xdr_encode_sattr(p, args->sattr,
5873 + req->rq_task->tk_client->cl_tag);
5874 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5877 @@ -411,7 +417,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5879 p = xdr_encode_fhandle(p, args->fromfh);
5880 p = xdr_encode_array(p, args->fromname, args->fromlen);
5881 - p = xdr_encode_sattr(p, args->sattr);
5882 + p = xdr_encode_sattr(p, args->sattr,
5883 + req->rq_task->tk_client->cl_tag);
5884 *p++ = htonl(args->pathlen);
5885 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5887 @@ -429,7 +436,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5888 p = xdr_encode_fhandle(p, args->fh);
5889 p = xdr_encode_array(p, args->name, args->len);
5890 *p++ = htonl(args->type);
5891 - p = xdr_encode_sattr(p, args->sattr);
5892 + p = xdr_encode_sattr(p, args->sattr,
5893 + req->rq_task->tk_client->cl_tag);
5894 if (args->type == NF3CHR || args->type == NF3BLK) {
5895 *p++ = htonl(MAJOR(args->rdev));
5896 *p++ = htonl(MINOR(args->rdev));
5897 diff -NurpP --minimal linux-2.6.33/fs/nfs/nfsroot.c linux-2.6.33-vs2.3.0.36.30/fs/nfs/nfsroot.c
5898 --- linux-2.6.33/fs/nfs/nfsroot.c 2009-09-10 15:26:23.000000000 +0200
5899 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfs/nfsroot.c 2010-02-25 12:02:16.000000000 +0100
5900 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
5902 /* Options that take integer arguments */
5903 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
5904 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
5905 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
5906 /* Options that take no arguments */
5907 Opt_soft, Opt_hard, Opt_intr,
5908 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
5909 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
5910 - Opt_acl, Opt_noacl,
5911 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
5915 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
5918 {Opt_noacl, "noacl"},
5920 + {Opt_notag, "notag"},
5921 + {Opt_tagid, "tagid=%u"},
5925 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
5927 nfs_data.flags |= NFS_MOUNT_NOACL;
5929 +#ifndef CONFIG_TAGGING_NONE
5931 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5934 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
5937 +#ifdef CONFIG_PROPAGATE
5940 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5944 printk(KERN_WARNING "Root-NFS: unknown "
5946 diff -NurpP --minimal linux-2.6.33/fs/nfs/super.c linux-2.6.33-vs2.3.0.36.30/fs/nfs/super.c
5947 --- linux-2.6.33/fs/nfs/super.c 2010-02-25 11:52:05.000000000 +0100
5948 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfs/super.c 2010-02-25 12:02:16.000000000 +0100
5950 #include <linux/nfs_xdr.h>
5951 #include <linux/magic.h>
5952 #include <linux/parser.h>
5953 +#include <linux/vs_tag.h>
5955 #include <asm/system.h>
5956 #include <asm/uaccess.h>
5957 @@ -585,6 +586,7 @@ static void nfs_show_mount_options(struc
5958 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5959 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5960 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5961 + { NFS_MOUNT_TAGGED, ",tag", "" },
5964 const struct proc_nfs_info *nfs_infop;
5965 diff -NurpP --minimal linux-2.6.33/fs/nfsd/auth.c linux-2.6.33-vs2.3.0.36.30/fs/nfsd/auth.c
5966 --- linux-2.6.33/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5967 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfsd/auth.c 2010-02-25 13:17:41.000000000 +0100
5969 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5971 #include <linux/sched.h>
5972 +#include <linux/vs_tag.h>
5976 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5978 new->fsuid = rqstp->rq_cred.cr_uid;
5979 new->fsgid = rqstp->rq_cred.cr_gid;
5980 + /* FIXME: this desperately needs a tag :)
5981 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5984 rqgi = rqstp->rq_cred.cr_group_info;
5986 diff -NurpP --minimal linux-2.6.33/fs/nfsd/nfs3xdr.c linux-2.6.33-vs2.3.0.36.30/fs/nfsd/nfs3xdr.c
5987 --- linux-2.6.33/fs/nfsd/nfs3xdr.c 2010-02-25 11:52:05.000000000 +0100
5988 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfsd/nfs3xdr.c 2010-02-25 13:18:45.000000000 +0100
5992 #include <linux/namei.h>
5993 +#include <linux/vs_tag.h>
5997 @@ -95,6 +96,8 @@ static __be32 *
5998 decode_sattr3(__be32 *p, struct iattr *iap)
6006 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6009 iap->ia_valid |= ATTR_UID;
6010 - iap->ia_uid = ntohl(*p++);
6011 + uid = ntohl(*p++);
6014 iap->ia_valid |= ATTR_GID;
6015 - iap->ia_gid = ntohl(*p++);
6016 + gid = ntohl(*p++);
6018 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6019 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6020 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6024 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6025 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6026 *p++ = htonl((u32) stat->mode);
6027 *p++ = htonl((u32) stat->nlink);
6028 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6029 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6030 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6031 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6032 + stat->uid, stat->tag)));
6033 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6034 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6035 + stat->gid, stat->tag)));
6036 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6037 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6039 diff -NurpP --minimal linux-2.6.33/fs/nfsd/nfs4xdr.c linux-2.6.33-vs2.3.0.36.30/fs/nfsd/nfs4xdr.c
6040 --- linux-2.6.33/fs/nfsd/nfs4xdr.c 2010-02-25 11:52:05.000000000 +0100
6041 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfsd/nfs4xdr.c 2010-02-25 12:02:16.000000000 +0100
6043 #include <linux/nfsd_idmap.h>
6044 #include <linux/nfs4_acl.h>
6045 #include <linux/sunrpc/svcauth_gss.h>
6046 +#include <linux/vs_tag.h>
6050 @@ -2042,14 +2043,18 @@ out_acl:
6051 WRITE32(stat.nlink);
6053 if (bmval1 & FATTR4_WORD1_OWNER) {
6054 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6055 + status = nfsd4_encode_user(rqstp,
6056 + TAGINO_UID(DX_TAG(dentry->d_inode),
6057 + stat.uid, stat.tag), &p, &buflen);
6058 if (status == nfserr_resource)
6063 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6064 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6065 + status = nfsd4_encode_group(rqstp,
6066 + TAGINO_GID(DX_TAG(dentry->d_inode),
6067 + stat.gid, stat.tag), &p, &buflen);
6068 if (status == nfserr_resource)
6071 diff -NurpP --minimal linux-2.6.33/fs/nfsd/nfsxdr.c linux-2.6.33-vs2.3.0.36.30/fs/nfsd/nfsxdr.c
6072 --- linux-2.6.33/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6073 +++ linux-2.6.33-vs2.3.0.36.30/fs/nfsd/nfsxdr.c 2010-02-25 13:18:10.000000000 +0100
6078 +#include <linux/vs_tag.h>
6080 #define NFSDDBG_FACILITY NFSDDBG_XDR
6082 @@ -88,6 +89,8 @@ static __be32 *
6083 decode_sattr(__be32 *p, struct iattr *iap)
6091 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6093 if ((tmp = ntohl(*p++)) != (u32)-1) {
6094 iap->ia_valid |= ATTR_UID;
6095 - iap->ia_uid = tmp;
6098 if ((tmp = ntohl(*p++)) != (u32)-1) {
6099 iap->ia_valid |= ATTR_GID;
6100 - iap->ia_gid = tmp;
6103 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6104 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6105 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6106 if ((tmp = ntohl(*p++)) != (u32)-1) {
6107 iap->ia_valid |= ATTR_SIZE;
6109 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6110 *p++ = htonl(nfs_ftypes[type >> 12]);
6111 *p++ = htonl((u32) stat->mode);
6112 *p++ = htonl((u32) stat->nlink);
6113 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6114 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6115 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6116 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6117 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6118 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6120 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6121 *p++ = htonl(NFS_MAXPATHLEN);
6122 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/dlm/dlmfs.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/dlm/dlmfs.c
6123 --- linux-2.6.33/fs/ocfs2/dlm/dlmfs.c 2009-12-03 20:02:53.000000000 +0100
6124 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/dlm/dlmfs.c 2010-02-25 12:02:16.000000000 +0100
6126 #include <linux/init.h>
6127 #include <linux/string.h>
6128 #include <linux/backing-dev.h>
6129 +#include <linux/vs_tag.h>
6131 #include <asm/uaccess.h>
6133 @@ -342,6 +343,7 @@ static struct inode *dlmfs_get_root_inod
6134 inode->i_mode = mode;
6135 inode->i_uid = current_fsuid();
6136 inode->i_gid = current_fsgid();
6137 + inode->i_tag = dx_current_fstag(sb);
6138 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6139 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6141 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6142 inode->i_mode = mode;
6143 inode->i_uid = current_fsuid();
6144 inode->i_gid = current_fsgid();
6145 + inode->i_tag = dx_current_fstag(sb);
6146 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6147 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6149 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/dlmglue.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/dlmglue.c
6150 --- linux-2.6.33/fs/ocfs2/dlmglue.c 2010-02-25 11:52:06.000000000 +0100
6151 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/dlmglue.c 2010-02-25 12:02:16.000000000 +0100
6152 @@ -2023,6 +2023,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6153 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6154 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6155 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6156 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6157 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6158 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6159 lvb->lvb_iatime_packed =
6160 @@ -2077,6 +2078,7 @@ static void ocfs2_refresh_inode_from_lvb
6162 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6163 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6164 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6165 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6166 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6167 ocfs2_unpack_timespec(&inode->i_atime,
6168 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/dlmglue.h linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/dlmglue.h
6169 --- linux-2.6.33/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
6170 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/dlmglue.h 2010-02-25 12:02:16.000000000 +0100
6171 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6174 __be32 lvb_igeneration;
6175 - __be32 lvb_reserved2;
6177 + __be16 lvb_reserved2;
6180 #define OCFS2_QINFO_LVB_VERSION 1
6181 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/file.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/file.c
6182 --- linux-2.6.33/fs/ocfs2/file.c 2010-02-25 11:52:06.000000000 +0100
6183 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/file.c 2010-02-25 12:02:16.000000000 +0100
6184 @@ -960,13 +960,15 @@ int ocfs2_setattr(struct dentry *dentry,
6185 mlog(0, "uid change: %d\n", attr->ia_uid);
6186 if (attr->ia_valid & ATTR_GID)
6187 mlog(0, "gid change: %d\n", attr->ia_gid);
6188 + if (attr->ia_valid & ATTR_TAG)
6189 + mlog(0, "tag change: %d\n", attr->ia_tag);
6190 if (attr->ia_valid & ATTR_SIZE)
6191 mlog(0, "size change...\n");
6192 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6193 mlog(0, "time change...\n");
6195 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6196 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6197 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6198 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6199 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6201 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/inode.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/inode.c
6202 --- linux-2.6.33/fs/ocfs2/inode.c 2010-02-25 11:52:06.000000000 +0100
6203 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/inode.c 2010-02-25 12:02:16.000000000 +0100
6205 #include <linux/highmem.h>
6206 #include <linux/pagemap.h>
6207 #include <linux/quotaops.h>
6208 +#include <linux/vs_tag.h>
6210 #include <asm/byteorder.h>
6212 @@ -79,11 +80,13 @@ void ocfs2_set_inode_flags(struct inode
6214 unsigned int flags = OCFS2_I(inode)->ip_attr;
6216 - inode->i_flags &= ~(S_IMMUTABLE |
6217 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6218 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6220 if (flags & OCFS2_IMMUTABLE_FL)
6221 inode->i_flags |= S_IMMUTABLE;
6222 + if (flags & OCFS2_IXUNLINK_FL)
6223 + inode->i_flags |= S_IXUNLINK;
6225 if (flags & OCFS2_SYNC_FL)
6226 inode->i_flags |= S_SYNC;
6227 @@ -93,25 +96,44 @@ void ocfs2_set_inode_flags(struct inode
6228 inode->i_flags |= S_NOATIME;
6229 if (flags & OCFS2_DIRSYNC_FL)
6230 inode->i_flags |= S_DIRSYNC;
6232 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6234 + if (flags & OCFS2_BARRIER_FL)
6235 + inode->i_vflags |= V_BARRIER;
6236 + if (flags & OCFS2_COW_FL)
6237 + inode->i_vflags |= V_COW;
6240 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6241 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6243 unsigned int flags = oi->vfs_inode.i_flags;
6244 + unsigned int vflags = oi->vfs_inode.i_vflags;
6246 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6247 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6248 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6249 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6251 + if (flags & S_IMMUTABLE)
6252 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6253 + if (flags & S_IXUNLINK)
6254 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6256 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6257 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6259 oi->ip_attr |= OCFS2_SYNC_FL;
6260 if (flags & S_APPEND)
6261 oi->ip_attr |= OCFS2_APPEND_FL;
6262 - if (flags & S_IMMUTABLE)
6263 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6264 if (flags & S_NOATIME)
6265 oi->ip_attr |= OCFS2_NOATIME_FL;
6266 if (flags & S_DIRSYNC)
6267 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6269 + if (vflags & V_BARRIER)
6270 + oi->ip_attr |= OCFS2_BARRIER_FL;
6271 + if (vflags & V_COW)
6272 + oi->ip_attr |= OCFS2_COW_FL;
6275 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6276 @@ -246,6 +268,8 @@ void ocfs2_populate_inode(struct inode *
6277 struct super_block *sb;
6278 struct ocfs2_super *osb;
6283 mlog_entry("(0x%p, size:%llu)\n", inode,
6284 (unsigned long long)le64_to_cpu(fe->i_size));
6285 @@ -277,8 +301,12 @@ void ocfs2_populate_inode(struct inode *
6286 inode->i_generation = le32_to_cpu(fe->i_generation);
6287 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6288 inode->i_mode = le16_to_cpu(fe->i_mode);
6289 - inode->i_uid = le32_to_cpu(fe->i_uid);
6290 - inode->i_gid = le32_to_cpu(fe->i_gid);
6291 + uid = le32_to_cpu(fe->i_uid);
6292 + gid = le32_to_cpu(fe->i_gid);
6293 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6294 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6295 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6296 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6298 /* Fast symlinks will have i_size but no allocated clusters. */
6299 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6300 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/inode.h linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/inode.h
6301 --- linux-2.6.33/fs/ocfs2/inode.h 2009-12-03 20:02:53.000000000 +0100
6302 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/inode.h 2010-02-25 12:02:16.000000000 +0100
6303 @@ -150,6 +150,7 @@ struct buffer_head *ocfs2_bread(struct i
6305 void ocfs2_set_inode_flags(struct inode *inode);
6306 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6307 +int ocfs2_sync_flags(struct inode *inode, int, int);
6309 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6311 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/ioctl.c
6312 --- linux-2.6.33/fs/ocfs2/ioctl.c 2010-02-25 11:52:06.000000000 +0100
6313 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/ioctl.c 2010-02-25 12:02:16.000000000 +0100
6314 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
6318 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6319 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6321 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6322 + struct buffer_head *bh = NULL;
6323 + handle_t *handle = NULL;
6326 + status = ocfs2_inode_lock(inode, &bh, 1);
6328 + mlog_errno(status);
6331 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6332 + if (IS_ERR(handle)) {
6333 + status = PTR_ERR(handle);
6334 + mlog_errno(status);
6338 + inode->i_flags = flags;
6339 + inode->i_vflags = vflags;
6340 + ocfs2_get_inode_flags(OCFS2_I(inode));
6342 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6344 + mlog_errno(status);
6346 + ocfs2_commit_trans(osb, handle);
6348 + ocfs2_inode_unlock(inode, 1);
6353 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6356 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6357 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
6358 if (!S_ISDIR(inode->i_mode))
6359 flags &= ~OCFS2_DIRSYNC_FL;
6361 + if (IS_BARRIER(inode)) {
6362 + vxwprintk_task(1, "messing with the barrier.");
6366 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6367 if (IS_ERR(handle)) {
6368 status = PTR_ERR(handle);
6369 @@ -109,6 +148,7 @@ bail:
6374 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6376 struct inode *inode = filp->f_path.dentry->d_inode;
6377 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/namei.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/namei.c
6378 --- linux-2.6.33/fs/ocfs2/namei.c 2010-02-25 11:52:06.000000000 +0100
6379 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/namei.c 2010-02-25 12:02:16.000000000 +0100
6381 #include <linux/slab.h>
6382 #include <linux/highmem.h>
6383 #include <linux/quotaops.h>
6384 +#include <linux/vs_tag.h>
6386 #define MLOG_MASK_PREFIX ML_NAMEI
6387 #include <cluster/masklog.h>
6388 @@ -481,6 +482,7 @@ static int ocfs2_mknod_locked(struct ocf
6396 @@ -524,8 +526,11 @@ static int ocfs2_mknod_locked(struct ocf
6397 fe->i_blkno = cpu_to_le64(fe_blkno);
6398 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6399 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6400 - fe->i_uid = cpu_to_le32(inode->i_uid);
6401 - fe->i_gid = cpu_to_le32(inode->i_gid);
6403 + tag = dx_current_fstag(osb->sb);
6404 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6405 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6406 + inode->i_tag = tag;
6407 fe->i_mode = cpu_to_le16(inode->i_mode);
6408 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6409 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6410 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/ocfs2_fs.h linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/ocfs2_fs.h
6411 --- linux-2.6.33/fs/ocfs2/ocfs2_fs.h 2010-02-25 11:52:06.000000000 +0100
6412 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/ocfs2_fs.h 2010-02-25 12:02:16.000000000 +0100
6413 @@ -231,18 +231,23 @@
6414 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
6416 /* Inode attributes, keep in sync with EXT2 */
6417 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6418 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6419 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6420 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6421 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6422 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6423 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6424 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6425 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6426 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6427 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6428 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6429 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6430 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6431 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6432 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6433 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6435 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6436 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6437 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6438 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6440 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6441 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6443 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6444 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6447 * Extent record flags (e_node.leaf.flags)
6448 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/ocfs2.h linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/ocfs2.h
6449 --- linux-2.6.33/fs/ocfs2/ocfs2.h 2010-02-25 11:52:06.000000000 +0100
6450 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/ocfs2.h 2010-02-25 13:22:33.000000000 +0100
6451 @@ -254,6 +254,7 @@ enum ocfs2_mount_options
6453 OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
6454 OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
6455 + OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
6458 #define OCFS2_OSB_SOFT_RO 0x0001
6459 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/super.c linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/super.c
6460 --- linux-2.6.33/fs/ocfs2/super.c 2010-02-25 11:52:06.000000000 +0100
6461 +++ linux-2.6.33-vs2.3.0.36.30/fs/ocfs2/super.c 2010-02-25 13:23:24.000000000 +0100
6462 @@ -175,6 +175,7 @@ enum {
6466 + Opt_tag, Opt_notag, Opt_tagid,
6470 @@ -201,6 +202,9 @@ static const match_table_t tokens = {
6471 {Opt_noacl, "noacl"},
6472 {Opt_usrquota, "usrquota"},
6473 {Opt_grpquota, "grpquota"},
6475 + {Opt_notag, "notag"},
6476 + {Opt_tagid, "tagid=%u"},
6480 @@ -608,6 +612,13 @@ static int ocfs2_remount(struct super_bl
6484 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6485 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6487 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6491 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6492 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6494 @@ -1138,6 +1149,9 @@ static int ocfs2_fill_super(struct super
6496 ocfs2_complete_mount_recovery(osb);
6498 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6499 + sb->s_flags |= MS_TAGGED;
6501 if (ocfs2_mount_local(osb))
6502 snprintf(nodestr, sizeof(nodestr), "local");
6504 @@ -1429,6 +1443,20 @@ static int ocfs2_parse_options(struct su
6505 mopt->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL;
6506 mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
6508 +#ifndef CONFIG_TAGGING_NONE
6510 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6513 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6516 +#ifdef CONFIG_PROPAGATE
6519 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6524 "Unrecognized mount option \"%s\" "
6525 diff -NurpP --minimal linux-2.6.33/fs/open.c linux-2.6.33-vs2.3.0.36.30/fs/open.c
6526 --- linux-2.6.33/fs/open.c 2010-02-25 11:52:06.000000000 +0100
6527 +++ linux-2.6.33-vs2.3.0.36.30/fs/open.c 2010-02-25 13:17:13.000000000 +0100
6529 #include <linux/falloc.h>
6530 #include <linux/fs_struct.h>
6531 #include <linux/ima.h>
6532 +#include <linux/vs_base.h>
6533 +#include <linux/vs_limit.h>
6534 +#include <linux/vs_tag.h>
6535 +#include <linux/vs_cowbl.h>
6537 #include "internal.h"
6539 @@ -39,16 +43,20 @@ int vfs_statfs(struct dentry *dentry, st
6540 int retval = -ENODEV;
6543 + struct super_block *sb = dentry->d_sb;
6546 - if (dentry->d_sb->s_op->statfs) {
6547 + if (sb->s_op->statfs) {
6548 memset(buf, 0, sizeof(*buf));
6549 retval = security_sb_statfs(dentry);
6552 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6553 + retval = sb->s_op->statfs(dentry, buf);
6554 if (retval == 0 && buf->f_frsize == 0)
6555 buf->f_frsize = buf->f_bsize;
6557 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6558 + vx_vsi_statfs(sb, buf);
6562 @@ -650,6 +658,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6563 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6567 + error = cow_check_and_break(&path);
6569 + goto dput_and_out;
6570 inode = path.dentry->d_inode;
6572 error = mnt_want_write(path.mnt);
6573 @@ -687,11 +699,11 @@ static int chown_common(struct path *pat
6574 newattrs.ia_valid = ATTR_CTIME;
6575 if (user != (uid_t) -1) {
6576 newattrs.ia_valid |= ATTR_UID;
6577 - newattrs.ia_uid = user;
6578 + newattrs.ia_uid = dx_map_uid(user);
6580 if (group != (gid_t) -1) {
6581 newattrs.ia_valid |= ATTR_GID;
6582 - newattrs.ia_gid = group;
6583 + newattrs.ia_gid = dx_map_gid(group);
6585 if (!S_ISDIR(inode->i_mode))
6586 newattrs.ia_valid |=
6587 @@ -716,6 +728,10 @@ SYSCALL_DEFINE3(chown, const char __user
6588 error = mnt_want_write(path.mnt);
6591 +#ifdef CONFIG_VSERVER_COWBL
6592 + error = cow_check_and_break(&path);
6595 error = chown_common(&path, user, group);
6596 mnt_drop_write(path.mnt);
6598 @@ -741,6 +757,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6599 error = mnt_want_write(path.mnt);
6602 +#ifdef CONFIG_VSERVER_COWBL
6603 + error = cow_check_and_break(&path);
6606 error = chown_common(&path, user, group);
6607 mnt_drop_write(path.mnt);
6609 @@ -760,6 +780,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6610 error = mnt_want_write(path.mnt);
6613 +#ifdef CONFIG_VSERVER_COWBL
6614 + error = cow_check_and_break(&path);
6617 error = chown_common(&path, user, group);
6618 mnt_drop_write(path.mnt);
6620 @@ -1006,6 +1030,7 @@ static void __put_unused_fd(struct files
6621 __FD_CLR(fd, fdt->open_fds);
6622 if (fd < files->next_fd)
6623 files->next_fd = fd;
6624 + vx_openfd_dec(fd);
6627 void put_unused_fd(unsigned int fd)
6628 diff -NurpP --minimal linux-2.6.33/fs/proc/array.c linux-2.6.33-vs2.3.0.36.30/fs/proc/array.c
6629 --- linux-2.6.33/fs/proc/array.c 2010-02-25 11:52:06.000000000 +0100
6630 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/array.c 2010-02-25 12:02:16.000000000 +0100
6632 #include <linux/ptrace.h>
6633 #include <linux/tracehook.h>
6634 #include <linux/swapops.h>
6635 +#include <linux/vs_context.h>
6636 +#include <linux/vs_network.h>
6638 #include <asm/pgtable.h>
6639 #include <asm/processor.h>
6640 @@ -172,6 +174,9 @@ static inline void task_state(struct seq
6642 ppid = pid_alive(p) ?
6643 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6644 + if (unlikely(vx_current_initpid(p->pid)))
6649 struct task_struct *tracer = tracehook_tracer_task(p);
6650 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6653 static void render_cap_t(struct seq_file *m, const char *header,
6655 + struct vx_info *vxi, kernel_cap_t *a)
6659 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6660 cap_bset = cred->cap_bset;
6663 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6664 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6665 - render_cap_t(m, "CapEff:\t", &cap_effective);
6666 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6667 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6668 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6669 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6670 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6671 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6674 static inline void task_context_switch_counts(struct seq_file *m,
6675 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6676 seq_printf(m, "\n");
6679 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6680 + struct pid *pid, struct task_struct *task)
6682 + seq_printf(m, "Proxy:\t%p(%c)\n"
6690 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6691 + atomic_read(&task->nsproxy->count),
6692 + task->nsproxy->uts_ns,
6693 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6694 + task->nsproxy->ipc_ns,
6695 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6696 + task->nsproxy->mnt_ns,
6697 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6698 + task->nsproxy->pid_ns,
6699 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6700 + task->nsproxy->net_ns,
6701 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6705 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6707 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6710 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6711 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6715 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6716 struct pid *pid, struct task_struct *task)
6718 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6720 task_cpus_allowed(m, task);
6721 cpuset_task_status_allowed(m, task);
6722 + task_vs_id(m, task);
6723 #if defined(CONFIG_S390)
6724 task_show_regs(m, task);
6726 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file
6727 /* convert nsec -> ticks */
6728 start_time = nsec_to_clock_t(start_time);
6730 + /* fixup start time for virt uptime */
6731 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6732 + unsigned long long bias =
6733 + current->vx_info->cvirt.bias_clock;
6735 + if (start_time > bias)
6736 + start_time -= bias;
6741 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6742 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6743 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6744 diff -NurpP --minimal linux-2.6.33/fs/proc/base.c linux-2.6.33-vs2.3.0.36.30/fs/proc/base.c
6745 --- linux-2.6.33/fs/proc/base.c 2010-02-25 11:52:06.000000000 +0100
6746 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/base.c 2010-02-25 12:02:16.000000000 +0100
6748 #include <linux/elf.h>
6749 #include <linux/pid_namespace.h>
6750 #include <linux/fs_struct.h>
6751 +#include <linux/vs_context.h>
6752 +#include <linux/vs_network.h>
6753 #include "internal.h"
6756 @@ -1047,12 +1049,17 @@ static ssize_t oom_adjust_write(struct f
6760 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6761 + if (oom_adjust < task->signal->oom_adj &&
6762 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6763 unlock_task_sighand(task, &flags);
6764 put_task_struct(task);
6768 + /* prevent guest processes from circumventing the oom killer */
6769 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6770 + oom_adjust = OOM_ADJUST_MIN;
6772 task->signal->oom_adj = oom_adjust;
6774 unlock_task_sighand(task, &flags);
6775 @@ -1092,7 +1099,7 @@ static ssize_t proc_loginuid_write(struc
6779 - if (!capable(CAP_AUDIT_CONTROL))
6780 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6783 if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
6784 @@ -1523,6 +1530,8 @@ static struct inode *proc_pid_make_inode
6785 inode->i_gid = cred->egid;
6788 + /* procfs is xid tagged */
6789 + inode->i_tag = (tag_t)vx_task_xid(task);
6790 security_task_to_inode(task, inode);
6793 @@ -2073,6 +2082,13 @@ static struct dentry *proc_pident_lookup
6797 + /* TODO: maybe we can come up with a generic approach? */
6798 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6799 + (dentry->d_name.len == 5) &&
6800 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6801 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6805 * Yes, it does not scale. And it should not. Don't add
6806 * new entries into /proc/<tgid>/ without very good reasons.
6807 @@ -2478,7 +2494,7 @@ out_iput:
6808 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6810 struct dentry *error;
6811 - struct task_struct *task = get_proc_task(dir);
6812 + struct task_struct *task = get_proc_task_real(dir);
6813 const struct pid_entry *p, *last;
6815 error = ERR_PTR(-ENOENT);
6816 @@ -2568,6 +2584,9 @@ static int proc_pid_personality(struct s
6817 static const struct file_operations proc_task_operations;
6818 static const struct inode_operations proc_task_inode_operations;
6820 +extern int proc_pid_vx_info(struct task_struct *, char *);
6821 +extern int proc_pid_nx_info(struct task_struct *, char *);
6823 static const struct pid_entry tgid_base_stuff[] = {
6824 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6825 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6826 @@ -2627,6 +2646,8 @@ static const struct pid_entry tgid_base_
6827 #ifdef CONFIG_CGROUPS
6828 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6830 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6831 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6832 INF("oom_score", S_IRUGO, proc_oom_score),
6833 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6834 #ifdef CONFIG_AUDITSYSCALL
6835 @@ -2642,6 +2663,7 @@ static const struct pid_entry tgid_base_
6836 #ifdef CONFIG_TASK_IO_ACCOUNTING
6837 INF("io", S_IRUGO, proc_tgid_io_accounting),
6839 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6842 static int proc_tgid_base_readdir(struct file * filp,
6843 @@ -2833,7 +2855,7 @@ retry:
6845 pid = find_ge_pid(iter.tgid, ns);
6847 - iter.tgid = pid_nr_ns(pid, ns);
6848 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6849 iter.task = pid_task(pid, PIDTYPE_PID);
6850 /* What we to know is if the pid we have find is the
6851 * pid of a thread_group_leader. Testing for task
6852 @@ -2863,7 +2885,7 @@ static int proc_pid_fill_cache(struct fi
6853 struct tgid_iter iter)
6855 char name[PROC_NUMBUF];
6856 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6857 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6858 return proc_fill_cache(filp, dirent, filldir, name, len,
6859 proc_pid_instantiate, iter.task, NULL);
6861 @@ -2872,7 +2894,7 @@ static int proc_pid_fill_cache(struct fi
6862 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6864 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6865 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6866 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6867 struct tgid_iter iter;
6868 struct pid_namespace *ns;
6870 @@ -2892,6 +2914,8 @@ int proc_pid_readdir(struct file * filp,
6872 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6873 filp->f_pos = iter.tgid + TGID_OFFSET;
6874 + if (!vx_proc_task_visible(iter.task))
6876 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6877 put_task_struct(iter.task);
6879 @@ -3039,6 +3063,8 @@ static struct dentry *proc_task_lookup(s
6880 tid = name_to_int(dentry);
6883 + if (vx_current_initpid(tid))
6886 ns = dentry->d_sb->s_fs_info;
6888 diff -NurpP --minimal linux-2.6.33/fs/proc/generic.c linux-2.6.33-vs2.3.0.36.30/fs/proc/generic.c
6889 --- linux-2.6.33/fs/proc/generic.c 2010-02-25 11:52:06.000000000 +0100
6890 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/generic.c 2010-02-25 13:20:40.000000000 +0100
6892 #include <linux/bitops.h>
6893 #include <linux/spinlock.h>
6894 #include <linux/completion.h>
6895 +#include <linux/vserver/inode.h>
6896 #include <asm/uaccess.h>
6898 #include "internal.h"
6899 @@ -425,6 +426,8 @@ struct dentry *proc_lookup_de(struct pro
6900 for (de = de->subdir; de ; de = de->next) {
6901 if (de->namelen != dentry->d_name.len)
6903 + if (!vx_hide_check(0, de->vx_flags))
6905 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6908 @@ -433,6 +436,8 @@ struct dentry *proc_lookup_de(struct pro
6909 spin_unlock(&proc_subdir_lock);
6911 inode = proc_get_inode(dir->i_sb, ino, de);
6912 + /* generic proc entries belong to the host */
6917 @@ -510,6 +515,8 @@ int proc_readdir_de(struct proc_dir_entr
6919 /* filldir passes info to user space */
6921 + if (!vx_hide_check(0, de->vx_flags))
6923 spin_unlock(&proc_subdir_lock);
6924 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6925 de->low_ino, de->mode >> 12) < 0) {
6926 @@ -517,6 +524,7 @@ int proc_readdir_de(struct proc_dir_entr
6929 spin_lock(&proc_subdir_lock);
6934 @@ -631,6 +639,7 @@ static struct proc_dir_entry *__proc_cre
6936 atomic_set(&ent->count, 1);
6938 + ent->vx_flags = IATTR_PROC_DEFAULT;
6939 spin_lock_init(&ent->pde_unload_lock);
6940 ent->pde_unload_completion = NULL;
6941 INIT_LIST_HEAD(&ent->pde_openers);
6942 @@ -654,7 +663,8 @@ struct proc_dir_entry *proc_symlink(cons
6948 + ent->vx_flags = IATTR_PROC_SYMLINK;
6952 diff -NurpP --minimal linux-2.6.33/fs/proc/inode.c linux-2.6.33-vs2.3.0.36.30/fs/proc/inode.c
6953 --- linux-2.6.33/fs/proc/inode.c 2010-02-25 11:52:06.000000000 +0100
6954 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/inode.c 2010-02-25 12:02:16.000000000 +0100
6955 @@ -436,6 +436,8 @@ struct inode *proc_get_inode(struct supe
6956 inode->i_uid = de->uid;
6957 inode->i_gid = de->gid;
6960 + PROC_I(inode)->vx_flags = de->vx_flags;
6962 inode->i_size = de->size;
6964 diff -NurpP --minimal linux-2.6.33/fs/proc/internal.h linux-2.6.33-vs2.3.0.36.30/fs/proc/internal.h
6965 --- linux-2.6.33/fs/proc/internal.h 2010-02-25 11:52:06.000000000 +0100
6966 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/internal.h 2010-02-25 12:02:16.000000000 +0100
6970 #include <linux/proc_fs.h>
6971 +#include <linux/vs_pid.h>
6973 extern struct proc_dir_entry proc_root;
6974 #ifdef CONFIG_PROC_SYSCTL
6975 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6976 struct pid *pid, struct task_struct *task);
6977 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6978 struct pid *pid, struct task_struct *task);
6979 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6980 + struct pid *pid, struct task_struct *task);
6982 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6984 extern const struct file_operations proc_maps_operations;
6985 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
6986 return PROC_I(inode)->pid;
6989 -static inline struct task_struct *get_proc_task(struct inode *inode)
6990 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6992 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6995 +static inline struct task_struct *get_proc_task(struct inode *inode)
6997 + return vx_get_proc_task(inode, proc_pid(inode));
7000 static inline int proc_fd(struct inode *inode)
7002 return PROC_I(inode)->fd;
7003 diff -NurpP --minimal linux-2.6.33/fs/proc/loadavg.c linux-2.6.33-vs2.3.0.36.30/fs/proc/loadavg.c
7004 --- linux-2.6.33/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7005 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/loadavg.c 2010-02-25 12:02:16.000000000 +0100
7008 static int loadavg_proc_show(struct seq_file *m, void *v)
7010 + unsigned long running;
7011 + unsigned int threads;
7012 unsigned long avnrun[3];
7014 get_avenrun(avnrun, FIXED_1/200, 0);
7016 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7017 + struct vx_info *vxi = current_vx_info();
7019 + running = atomic_read(&vxi->cvirt.nr_running);
7020 + threads = atomic_read(&vxi->cvirt.nr_threads);
7022 + running = nr_running();
7023 + threads = nr_threads;
7026 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7027 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7028 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7029 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7030 - nr_running(), nr_threads,
7032 task_active_pid_ns(current)->last_pid);
7035 diff -NurpP --minimal linux-2.6.33/fs/proc/meminfo.c linux-2.6.33-vs2.3.0.36.30/fs/proc/meminfo.c
7036 --- linux-2.6.33/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7037 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/meminfo.c 2010-02-25 12:02:16.000000000 +0100
7038 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7039 allowed = ((totalram_pages - hugetlb_total_pages())
7040 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7042 - cached = global_page_state(NR_FILE_PAGES) -
7043 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7044 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7045 total_swapcache_pages - i.bufferram;
7048 diff -NurpP --minimal linux-2.6.33/fs/proc/root.c linux-2.6.33-vs2.3.0.36.30/fs/proc/root.c
7049 --- linux-2.6.33/fs/proc/root.c 2009-06-11 17:13:07.000000000 +0200
7050 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/root.c 2010-02-25 12:02:16.000000000 +0100
7052 #include <linux/bitops.h>
7053 #include <linux/mount.h>
7054 #include <linux/pid_namespace.h>
7055 +#include <linux/vserver/inode.h>
7057 #include "internal.h"
7059 +struct proc_dir_entry *proc_virtual;
7061 +extern void proc_vx_init(void);
7063 static int proc_test_super(struct super_block *sb, void *data)
7065 return sb->s_fs_info == data;
7066 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
7068 proc_mkdir("bus", NULL);
7073 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7074 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7075 .proc_iops = &proc_root_inode_operations,
7076 .proc_fops = &proc_root_operations,
7077 .parent = &proc_root,
7078 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7081 int pid_ns_prepare_proc(struct pid_namespace *ns)
7082 diff -NurpP --minimal linux-2.6.33/fs/proc/uptime.c linux-2.6.33-vs2.3.0.36.30/fs/proc/uptime.c
7083 --- linux-2.6.33/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7084 +++ linux-2.6.33-vs2.3.0.36.30/fs/proc/uptime.c 2010-02-25 12:02:16.000000000 +0100
7086 #include <linux/sched.h>
7087 #include <linux/seq_file.h>
7088 #include <linux/time.h>
7089 -#include <linux/kernel_stat.h>
7090 +#include <linux/vserver/cvirt.h>
7091 #include <asm/cputime.h>
7093 static int uptime_proc_show(struct seq_file *m, void *v)
7095 struct timespec uptime;
7096 struct timespec idle;
7098 - cputime_t idletime = cputime_zero;
7100 - for_each_possible_cpu(i)
7101 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7102 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7104 do_posix_clock_monotonic_gettime(&uptime);
7105 monotonic_to_bootbased(&uptime);
7106 cputime_to_timespec(idletime, &idle);
7108 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7109 + vx_vsi_uptime(&uptime, &idle);
7111 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7112 (unsigned long) uptime.tv_sec,
7113 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7114 diff -NurpP --minimal linux-2.6.33/fs/quota/quota.c linux-2.6.33-vs2.3.0.36.30/fs/quota/quota.c
7115 --- linux-2.6.33/fs/quota/quota.c 2010-02-25 11:52:06.000000000 +0100
7116 +++ linux-2.6.33-vs2.3.0.36.30/fs/quota/quota.c 2010-02-25 13:25:13.000000000 +0100
7118 #include <linux/capability.h>
7119 #include <linux/quotaops.h>
7120 #include <linux/types.h>
7121 +#include <linux/vs_context.h>
7122 #include <net/netlink.h>
7123 #include <net/genetlink.h>
7125 @@ -85,11 +86,11 @@ static int generic_quotactl_valid(struct
7126 if (cmd == Q_GETQUOTA) {
7127 if (((type == USRQUOTA && current_euid() != id) ||
7128 (type == GRPQUOTA && !in_egroup_p(id))) &&
7129 - !capable(CAP_SYS_ADMIN))
7130 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7133 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7134 - if (!capable(CAP_SYS_ADMIN))
7135 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7139 @@ -137,10 +138,10 @@ static int xqm_quotactl_valid(struct sup
7140 if (cmd == Q_XGETQUOTA) {
7141 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7142 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7143 - !capable(CAP_SYS_ADMIN))
7144 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7146 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7147 - if (!capable(CAP_SYS_ADMIN))
7148 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7152 @@ -353,6 +354,46 @@ static int do_quotactl(struct super_bloc
7156 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7158 +#include <linux/vroot.h>
7159 +#include <linux/major.h>
7160 +#include <linux/module.h>
7161 +#include <linux/kallsyms.h>
7162 +#include <linux/vserver/debug.h>
7164 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7166 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7168 +int register_vroot_grb(vroot_grb_func *func) {
7171 + spin_lock(&vroot_grb_lock);
7172 + if (!vroot_get_real_bdev) {
7173 + vroot_get_real_bdev = func;
7176 + spin_unlock(&vroot_grb_lock);
7179 +EXPORT_SYMBOL(register_vroot_grb);
7181 +int unregister_vroot_grb(vroot_grb_func *func) {
7182 + int ret = -EINVAL;
7184 + spin_lock(&vroot_grb_lock);
7185 + if (vroot_get_real_bdev) {
7186 + vroot_get_real_bdev = NULL;
7189 + spin_unlock(&vroot_grb_lock);
7192 +EXPORT_SYMBOL(unregister_vroot_grb);
7197 * look up a superblock on which quota ops will be performed
7198 * - use the name of a block device to find the superblock thereon
7199 @@ -370,6 +411,22 @@ static struct super_block *quotactl_bloc
7202 return ERR_CAST(bdev);
7203 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7204 + if (bdev && bdev->bd_inode &&
7205 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7206 + struct block_device *bdnew = (void *)-EINVAL;
7208 + if (vroot_get_real_bdev)
7209 + bdnew = vroot_get_real_bdev(bdev);
7211 + vxdprintk(VXD_CBIT(misc, 0),
7212 + "vroot_get_real_bdev not set");
7214 + if (IS_ERR(bdnew))
7215 + return ERR_PTR(PTR_ERR(bdnew));
7219 sb = get_super(bdev);
7222 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/file.c linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/file.c
7223 --- linux-2.6.33/fs/reiserfs/file.c 2010-02-25 11:52:06.000000000 +0100
7224 +++ linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/file.c 2010-02-25 12:02:16.000000000 +0100
7225 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7226 .listxattr = reiserfs_listxattr,
7227 .removexattr = reiserfs_removexattr,
7228 .permission = reiserfs_permission,
7229 + .sync_flags = reiserfs_sync_flags,
7231 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/inode.c linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/inode.c
7232 --- linux-2.6.33/fs/reiserfs/inode.c 2010-02-25 11:52:06.000000000 +0100
7233 +++ linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/inode.c 2010-02-25 12:02:16.000000000 +0100
7235 #include <linux/writeback.h>
7236 #include <linux/quotaops.h>
7237 #include <linux/swap.h>
7238 +#include <linux/vs_tag.h>
7240 int reiserfs_commit_write(struct file *f, struct page *page,
7241 unsigned from, unsigned to);
7242 @@ -1121,6 +1122,8 @@ static void init_inode(struct inode *ino
7243 struct buffer_head *bh;
7244 struct item_head *ih;
7248 //int version = ITEM_VERSION_1;
7250 bh = PATH_PLAST_BUFFER(path);
7251 @@ -1142,12 +1145,13 @@ static void init_inode(struct inode *ino
7252 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7253 unsigned long blocks;
7255 + uid = sd_v1_uid(sd);
7256 + gid = sd_v1_gid(sd);
7258 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7259 set_inode_sd_version(inode, STAT_DATA_V1);
7260 inode->i_mode = sd_v1_mode(sd);
7261 inode->i_nlink = sd_v1_nlink(sd);
7262 - inode->i_uid = sd_v1_uid(sd);
7263 - inode->i_gid = sd_v1_gid(sd);
7264 inode->i_size = sd_v1_size(sd);
7265 inode->i_atime.tv_sec = sd_v1_atime(sd);
7266 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7267 @@ -1189,11 +1193,12 @@ static void init_inode(struct inode *ino
7268 // (directories and symlinks)
7269 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7271 + uid = sd_v2_uid(sd);
7272 + gid = sd_v2_gid(sd);
7274 inode->i_mode = sd_v2_mode(sd);
7275 inode->i_nlink = sd_v2_nlink(sd);
7276 - inode->i_uid = sd_v2_uid(sd);
7277 inode->i_size = sd_v2_size(sd);
7278 - inode->i_gid = sd_v2_gid(sd);
7279 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7280 inode->i_atime.tv_sec = sd_v2_atime(sd);
7281 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7282 @@ -1223,6 +1228,10 @@ static void init_inode(struct inode *ino
7283 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7286 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7287 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7288 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7291 if (S_ISREG(inode->i_mode)) {
7292 inode->i_op = &reiserfs_file_inode_operations;
7293 @@ -1245,13 +1254,15 @@ static void init_inode(struct inode *ino
7294 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7296 struct stat_data *sd_v2 = (struct stat_data *)sd;
7297 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7298 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7301 + set_sd_v2_uid(sd_v2, uid);
7302 + set_sd_v2_gid(sd_v2, gid);
7303 set_sd_v2_mode(sd_v2, inode->i_mode);
7304 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7305 - set_sd_v2_uid(sd_v2, inode->i_uid);
7306 set_sd_v2_size(sd_v2, size);
7307 - set_sd_v2_gid(sd_v2, inode->i_gid);
7308 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7309 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7310 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7311 @@ -2852,14 +2863,19 @@ int reiserfs_commit_write(struct file *f
7312 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7314 if (reiserfs_attrs(inode->i_sb)) {
7315 - if (sd_attrs & REISERFS_SYNC_FL)
7316 - inode->i_flags |= S_SYNC;
7318 - inode->i_flags &= ~S_SYNC;
7319 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7320 inode->i_flags |= S_IMMUTABLE;
7322 inode->i_flags &= ~S_IMMUTABLE;
7323 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7324 + inode->i_flags |= S_IXUNLINK;
7326 + inode->i_flags &= ~S_IXUNLINK;
7328 + if (sd_attrs & REISERFS_SYNC_FL)
7329 + inode->i_flags |= S_SYNC;
7331 + inode->i_flags &= ~S_SYNC;
7332 if (sd_attrs & REISERFS_APPEND_FL)
7333 inode->i_flags |= S_APPEND;
7335 @@ -2872,6 +2888,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7336 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7338 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7340 + if (sd_attrs & REISERFS_BARRIER_FL)
7341 + inode->i_vflags |= V_BARRIER;
7343 + inode->i_vflags &= ~V_BARRIER;
7344 + if (sd_attrs & REISERFS_COW_FL)
7345 + inode->i_vflags |= V_COW;
7347 + inode->i_vflags &= ~V_COW;
7351 @@ -2882,6 +2907,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7352 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7354 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7355 + if (inode->i_flags & S_IXUNLINK)
7356 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7358 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7360 if (inode->i_flags & S_SYNC)
7361 *sd_attrs |= REISERFS_SYNC_FL;
7363 @@ -2894,6 +2924,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7364 *sd_attrs |= REISERFS_NOTAIL_FL;
7366 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7368 + if (inode->i_vflags & V_BARRIER)
7369 + *sd_attrs |= REISERFS_BARRIER_FL;
7371 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7372 + if (inode->i_vflags & V_COW)
7373 + *sd_attrs |= REISERFS_COW_FL;
7375 + *sd_attrs &= ~REISERFS_COW_FL;
7379 @@ -3115,9 +3154,11 @@ int reiserfs_setattr(struct dentry *dent
7382 error = inode_change_ok(inode, attr);
7385 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7386 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7387 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7388 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7389 error = reiserfs_chown_xattrs(inode, attr);
7392 @@ -3147,6 +3188,9 @@ int reiserfs_setattr(struct dentry *dent
7393 inode->i_uid = attr->ia_uid;
7394 if (attr->ia_valid & ATTR_GID)
7395 inode->i_gid = attr->ia_gid;
7396 + if ((attr->ia_valid & ATTR_TAG) &&
7398 + inode->i_tag = attr->ia_tag;
7399 mark_inode_dirty(inode);
7401 journal_end(&th, inode->i_sb, jbegin_count);
7402 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/ioctl.c
7403 --- linux-2.6.33/fs/reiserfs/ioctl.c 2010-02-25 11:52:06.000000000 +0100
7404 +++ linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/ioctl.c 2010-02-25 13:21:56.000000000 +0100
7406 #include <linux/mount.h>
7407 #include <linux/reiserfs_fs.h>
7408 #include <linux/time.h>
7409 +#include <linux/mount.h>
7410 #include <asm/uaccess.h>
7411 #include <linux/pagemap.h>
7412 #include <linux/smp_lock.h>
7413 #include <linux/compat.h>
7416 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7418 + __u16 sd_attrs = 0;
7420 + inode->i_flags = flags;
7421 + inode->i_vflags = vflags;
7423 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7424 + REISERFS_I(inode)->i_attrs = sd_attrs;
7425 + inode->i_ctime = CURRENT_TIME_SEC;
7426 + mark_inode_dirty(inode);
7431 * reiserfs_ioctl - handler for ioctl for inode
7432 * supported commands:
7434 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7436 struct inode *inode = filp->f_path.dentry->d_inode;
7437 - unsigned int flags;
7438 + unsigned int flags, oldflags;
7441 reiserfs_write_lock(inode->i_sb);
7442 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
7444 flags = REISERFS_I(inode)->i_attrs;
7445 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7446 + flags &= REISERFS_FL_USER_VISIBLE;
7447 err = put_user(flags, (int __user *)arg);
7449 case REISERFS_IOC_SETFLAGS:{
7450 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
7454 + if (IS_BARRIER(inode)) {
7455 + vxwprintk_task(1, "messing with the barrier.");
7459 * Is it quota file? Do not allow user to mess with it
7461 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
7466 + oldflags = REISERFS_I(inode)->i_attrs;
7467 + flags &= REISERFS_FL_USER_MODIFIABLE;
7468 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7469 sd_attrs_to_i_attrs(flags, inode);
7470 REISERFS_I(inode)->i_attrs = flags;
7471 inode->i_ctime = CURRENT_TIME_SEC;
7472 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/namei.c linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/namei.c
7473 --- linux-2.6.33/fs/reiserfs/namei.c 2010-02-25 11:52:06.000000000 +0100
7474 +++ linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/namei.c 2010-02-25 12:02:16.000000000 +0100
7476 #include <linux/reiserfs_acl.h>
7477 #include <linux/reiserfs_xattr.h>
7478 #include <linux/quotaops.h>
7479 +#include <linux/vs_tag.h>
7481 #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; }
7482 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7483 @@ -361,6 +362,7 @@ static struct dentry *reiserfs_lookup(st
7484 if (retval == IO_ERROR) {
7485 return ERR_PTR(-EIO);
7487 + dx_propagate_tag(nd, inode);
7489 return d_splice_alias(inode, dentry);
7491 @@ -577,6 +579,7 @@ static int new_inode_init(struct inode *
7493 inode->i_gid = current_fsgid();
7495 + inode->i_tag = dx_current_fstag(inode->i_sb);
7499 @@ -1524,6 +1527,7 @@ const struct inode_operations reiserfs_d
7500 .listxattr = reiserfs_listxattr,
7501 .removexattr = reiserfs_removexattr,
7502 .permission = reiserfs_permission,
7503 + .sync_flags = reiserfs_sync_flags,
7507 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/super.c linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/super.c
7508 --- linux-2.6.33/fs/reiserfs/super.c 2010-02-25 11:52:06.000000000 +0100
7509 +++ linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/super.c 2010-02-25 12:02:16.000000000 +0100
7510 @@ -887,6 +887,14 @@ static int reiserfs_parse_options(struct
7511 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7512 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7514 +#ifndef CONFIG_TAGGING_NONE
7515 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7516 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7517 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7519 +#ifdef CONFIG_PROPAGATE
7520 + {"tag",.arg_required = 'T',.values = NULL},
7522 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7523 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7524 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7525 @@ -1196,6 +1204,14 @@ static int reiserfs_remount(struct super
7526 handle_quota_files(s, qf_names, &qfmt);
7529 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7530 + !(s->s_flags & MS_TAGGED)) {
7531 + reiserfs_warning(s, "super-vs01",
7532 + "reiserfs: tagging not permitted on remount.");
7539 /* Add options that are safe here */
7540 @@ -1674,6 +1690,10 @@ static int reiserfs_fill_super(struct su
7544 + /* map mount option tagxid */
7545 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7546 + s->s_flags |= MS_TAGGED;
7548 rs = SB_DISK_SUPER_BLOCK(s);
7549 /* Let's do basic sanity check to verify that underlying device is not
7550 smaller than the filesystem. If the check fails then abort and scream,
7551 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/xattr.c linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/xattr.c
7552 --- linux-2.6.33/fs/reiserfs/xattr.c 2010-02-25 11:52:06.000000000 +0100
7553 +++ linux-2.6.33-vs2.3.0.36.30/fs/reiserfs/xattr.c 2010-02-25 12:02:16.000000000 +0100
7555 #include <linux/namei.h>
7556 #include <linux/errno.h>
7557 #include <linux/fs.h>
7558 +#include <linux/mount.h>
7559 #include <linux/file.h>
7560 #include <linux/pagemap.h>
7561 #include <linux/xattr.h>
7562 diff -NurpP --minimal linux-2.6.33/fs/stat.c linux-2.6.33-vs2.3.0.36.30/fs/stat.c
7563 --- linux-2.6.33/fs/stat.c 2010-02-25 11:52:06.000000000 +0100
7564 +++ linux-2.6.33-vs2.3.0.36.30/fs/stat.c 2010-02-25 12:02:16.000000000 +0100
7565 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7566 stat->nlink = inode->i_nlink;
7567 stat->uid = inode->i_uid;
7568 stat->gid = inode->i_gid;
7569 + stat->tag = inode->i_tag;
7570 stat->rdev = inode->i_rdev;
7571 stat->atime = inode->i_atime;
7572 stat->mtime = inode->i_mtime;
7573 diff -NurpP --minimal linux-2.6.33/fs/super.c linux-2.6.33-vs2.3.0.36.30/fs/super.c
7574 --- linux-2.6.33/fs/super.c 2010-02-25 11:52:06.000000000 +0100
7575 +++ linux-2.6.33-vs2.3.0.36.30/fs/super.c 2010-02-25 12:02:16.000000000 +0100
7577 #include <linux/kobject.h>
7578 #include <linux/mutex.h>
7579 #include <linux/file.h>
7580 +#include <linux/devpts_fs.h>
7581 +#include <linux/proc_fs.h>
7582 +#include <linux/vs_context.h>
7583 #include <asm/uaccess.h>
7584 #include "internal.h"
7586 @@ -914,12 +917,18 @@ struct vfsmount *
7587 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7589 struct vfsmount *mnt;
7590 + struct super_block *sb;
7591 char *secdata = NULL;
7595 return ERR_PTR(-ENODEV);
7598 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7599 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7603 mnt = alloc_vfsmnt(name);
7605 @@ -938,9 +947,17 @@ vfs_kern_mount(struct file_system_type *
7606 error = type->get_sb(type, flags, name, data, mnt);
7608 goto out_free_secdata;
7609 - BUG_ON(!mnt->mnt_sb);
7611 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7616 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7617 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7618 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7621 + error = security_sb_kern_mount(sb, flags, secdata);
7625 diff -NurpP --minimal linux-2.6.33/fs/sysfs/mount.c linux-2.6.33-vs2.3.0.36.30/fs/sysfs/mount.c
7626 --- linux-2.6.33/fs/sysfs/mount.c 2009-06-11 17:13:08.000000000 +0200
7627 +++ linux-2.6.33-vs2.3.0.36.30/fs/sysfs/mount.c 2010-02-25 12:02:16.000000000 +0100
7628 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7630 sb->s_blocksize = PAGE_CACHE_SIZE;
7631 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7632 - sb->s_magic = SYSFS_MAGIC;
7633 + sb->s_magic = SYSFS_SUPER_MAGIC;
7634 sb->s_op = &sysfs_ops;
7635 sb->s_time_gran = 1;
7637 diff -NurpP --minimal linux-2.6.33/fs/utimes.c linux-2.6.33-vs2.3.0.36.30/fs/utimes.c
7638 --- linux-2.6.33/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7639 +++ linux-2.6.33-vs2.3.0.36.30/fs/utimes.c 2010-02-25 12:02:16.000000000 +0100
7641 #include <linux/stat.h>
7642 #include <linux/utime.h>
7643 #include <linux/syscalls.h>
7644 +#include <linux/mount.h>
7645 +#include <linux/vs_cowbl.h>
7646 #include <asm/uaccess.h>
7647 #include <asm/unistd.h>
7649 diff -NurpP --minimal linux-2.6.33/fs/xattr.c linux-2.6.33-vs2.3.0.36.30/fs/xattr.c
7650 --- linux-2.6.33/fs/xattr.c 2010-02-25 11:52:06.000000000 +0100
7651 +++ linux-2.6.33-vs2.3.0.36.30/fs/xattr.c 2010-02-25 12:02:16.000000000 +0100
7653 #include <linux/module.h>
7654 #include <linux/fsnotify.h>
7655 #include <linux/audit.h>
7656 +#include <linux/mount.h>
7657 #include <asm/uaccess.h>
7660 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_ioctl.c
7661 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 11:52:06.000000000 +0100
7662 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 12:02:16.000000000 +0100
7664 #include "xfs_dir2_sf.h"
7665 #include "xfs_dinode.h"
7666 #include "xfs_inode.h"
7667 -#include "xfs_ioctl.h"
7668 #include "xfs_btree.h"
7669 #include "xfs_ialloc.h"
7670 #include "xfs_rtalloc.h"
7671 @@ -743,6 +742,10 @@ xfs_merge_ioc_xflags(
7672 xflags |= XFS_XFLAG_IMMUTABLE;
7674 xflags &= ~XFS_XFLAG_IMMUTABLE;
7675 + if (flags & FS_IXUNLINK_FL)
7676 + xflags |= XFS_XFLAG_IXUNLINK;
7678 + xflags &= ~XFS_XFLAG_IXUNLINK;
7679 if (flags & FS_APPEND_FL)
7680 xflags |= XFS_XFLAG_APPEND;
7682 @@ -771,6 +774,8 @@ xfs_di2lxflags(
7684 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7685 flags |= FS_IMMUTABLE_FL;
7686 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7687 + flags |= FS_IXUNLINK_FL;
7688 if (di_flags & XFS_DIFLAG_APPEND)
7689 flags |= FS_APPEND_FL;
7690 if (di_flags & XFS_DIFLAG_SYNC)
7691 @@ -829,6 +834,8 @@ xfs_set_diflags(
7692 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7693 if (xflags & XFS_XFLAG_IMMUTABLE)
7694 di_flags |= XFS_DIFLAG_IMMUTABLE;
7695 + if (xflags & XFS_XFLAG_IXUNLINK)
7696 + di_flags |= XFS_DIFLAG_IXUNLINK;
7697 if (xflags & XFS_XFLAG_APPEND)
7698 di_flags |= XFS_DIFLAG_APPEND;
7699 if (xflags & XFS_XFLAG_SYNC)
7700 @@ -871,6 +878,10 @@ xfs_diflags_to_linux(
7701 inode->i_flags |= S_IMMUTABLE;
7703 inode->i_flags &= ~S_IMMUTABLE;
7704 + if (xflags & XFS_XFLAG_IXUNLINK)
7705 + inode->i_flags |= S_IXUNLINK;
7707 + inode->i_flags &= ~S_IXUNLINK;
7708 if (xflags & XFS_XFLAG_APPEND)
7709 inode->i_flags |= S_APPEND;
7711 @@ -1347,10 +1358,18 @@ xfs_file_ioctl(
7712 case XFS_IOC_FSGETXATTRA:
7713 return xfs_ioc_fsgetxattr(ip, 1, arg);
7714 case XFS_IOC_FSSETXATTR:
7715 + if (IS_BARRIER(inode)) {
7716 + vxwprintk_task(1, "messing with the barrier.");
7717 + return -XFS_ERROR(EACCES);
7719 return xfs_ioc_fssetxattr(ip, filp, arg);
7720 case XFS_IOC_GETXFLAGS:
7721 return xfs_ioc_getxflags(ip, arg);
7722 case XFS_IOC_SETXFLAGS:
7723 + if (IS_BARRIER(inode)) {
7724 + vxwprintk_task(1, "messing with the barrier.");
7725 + return -XFS_ERROR(EACCES);
7727 return xfs_ioc_setxflags(ip, filp, arg);
7729 case XFS_IOC_FSSETDM: {
7730 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_ioctl.h
7731 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
7732 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_ioctl.h 2010-02-25 12:02:16.000000000 +0100
7733 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7734 void __user *uhandle,
7739 + struct inode *inode,
7746 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_iops.c
7747 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_iops.c 2010-02-25 11:52:06.000000000 +0100
7748 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_iops.c 2010-02-25 12:02:16.000000000 +0100
7750 #include "xfs_attr_sf.h"
7751 #include "xfs_dinode.h"
7752 #include "xfs_inode.h"
7753 +#include "xfs_ioctl.h"
7754 #include "xfs_bmap.h"
7755 #include "xfs_btree.h"
7756 #include "xfs_ialloc.h"
7758 #include <linux/security.h>
7759 #include <linux/falloc.h>
7760 #include <linux/fiemap.h>
7761 +#include <linux/vs_tag.h>
7764 * Bring the timestamps in the XFS inode uptodate.
7765 @@ -496,6 +498,7 @@ xfs_vn_getattr(
7766 stat->nlink = ip->i_d.di_nlink;
7767 stat->uid = ip->i_d.di_uid;
7768 stat->gid = ip->i_d.di_gid;
7769 + stat->tag = ip->i_d.di_tag;
7770 stat->ino = ip->i_ino;
7771 stat->atime = inode->i_atime;
7772 stat->mtime = inode->i_mtime;
7773 @@ -687,6 +690,7 @@ static const struct inode_operations xfs
7774 .listxattr = xfs_vn_listxattr,
7775 .fallocate = xfs_vn_fallocate,
7776 .fiemap = xfs_vn_fiemap,
7777 + .sync_flags = xfs_sync_flags,
7780 static const struct inode_operations xfs_dir_inode_operations = {
7781 @@ -712,6 +716,7 @@ static const struct inode_operations xfs
7782 .getxattr = generic_getxattr,
7783 .removexattr = generic_removexattr,
7784 .listxattr = xfs_vn_listxattr,
7785 + .sync_flags = xfs_sync_flags,
7788 static const struct inode_operations xfs_dir_ci_inode_operations = {
7789 @@ -761,6 +766,10 @@ xfs_diflags_to_iflags(
7790 inode->i_flags |= S_IMMUTABLE;
7792 inode->i_flags &= ~S_IMMUTABLE;
7793 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7794 + inode->i_flags |= S_IXUNLINK;
7796 + inode->i_flags &= ~S_IXUNLINK;
7797 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7798 inode->i_flags |= S_APPEND;
7800 @@ -773,6 +782,15 @@ xfs_diflags_to_iflags(
7801 inode->i_flags |= S_NOATIME;
7803 inode->i_flags &= ~S_NOATIME;
7805 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7806 + inode->i_vflags |= V_BARRIER;
7808 + inode->i_vflags &= ~V_BARRIER;
7809 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7810 + inode->i_vflags |= V_COW;
7812 + inode->i_vflags &= ~V_COW;
7816 @@ -801,6 +819,7 @@ xfs_setup_inode(
7817 inode->i_nlink = ip->i_d.di_nlink;
7818 inode->i_uid = ip->i_d.di_uid;
7819 inode->i_gid = ip->i_d.di_gid;
7820 + inode->i_tag = ip->i_d.di_tag;
7822 switch (inode->i_mode & S_IFMT) {
7824 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_linux.h
7825 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 11:52:06.000000000 +0100
7826 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 12:02:16.000000000 +0100
7829 #define current_cpu() (raw_smp_processor_id())
7830 #define current_pid() (current->pid)
7831 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7832 #define current_test_flags(f) (current->flags & (f))
7833 #define current_set_flags_nested(sp, f) \
7834 (*(sp) = current->flags, current->flags |= (f))
7835 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_super.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_super.c
7836 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 11:52:06.000000000 +0100
7837 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 12:02:16.000000000 +0100
7838 @@ -118,6 +118,9 @@ mempool_t *xfs_ioend_pool;
7839 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
7840 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
7841 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
7842 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7843 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7844 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7847 * Table driven mount option parser.
7848 @@ -126,10 +129,14 @@ mempool_t *xfs_ioend_pool;
7849 * in the future, too.
7852 + Opt_tag, Opt_notag,
7853 Opt_barrier, Opt_nobarrier, Opt_err
7856 static const match_table_t tokens = {
7857 + {Opt_tag, "tagxid"},
7859 + {Opt_notag, "notag"},
7860 {Opt_barrier, "barrier"},
7861 {Opt_nobarrier, "nobarrier"},
7863 @@ -383,6 +390,19 @@ xfs_parseargs(
7864 } else if (!strcmp(this_char, "irixsgid")) {
7866 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7867 +#ifndef CONFIG_TAGGING_NONE
7868 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7869 + mp->m_flags |= XFS_MOUNT_TAGGED;
7870 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7871 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7872 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7873 + mp->m_flags |= XFS_MOUNT_TAGGED;
7875 +#ifdef CONFIG_PROPAGATE
7876 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7878 + mp->m_flags |= XFS_MOUNT_TAGGED;
7882 "XFS: unknown mount option [%s].", this_char);
7883 @@ -1290,6 +1310,16 @@ xfs_fs_remount(
7885 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7888 + if (!(sb->s_flags & MS_TAGGED)) {
7890 + "XFS: %s: tagging not permitted on remount.\n",
7899 * Logically we would return an error here to prevent
7900 @@ -1497,6 +1527,9 @@ xfs_fs_fill_super(
7902 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
7904 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7905 + sb->s_flags |= MS_TAGGED;
7907 sb->s_magic = XFS_SB_MAGIC;
7908 sb->s_blocksize = mp->m_sb.sb_blocksize;
7909 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
7910 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_dinode.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_dinode.h
7911 --- linux-2.6.33/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
7912 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_dinode.h 2010-02-25 12:02:16.000000000 +0100
7913 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
7914 __be32 di_gid; /* owner's group id */
7915 __be32 di_nlink; /* number of links to file */
7916 __be16 di_projid; /* owner's project id */
7917 - __u8 di_pad[8]; /* unused, zeroed space */
7918 + __be16 di_tag; /* context tagging */
7919 + __be16 di_vflags; /* vserver specific flags */
7920 + __u8 di_pad[4]; /* unused, zeroed space */
7921 __be16 di_flushiter; /* incremented on flush */
7922 xfs_timestamp_t di_atime; /* time last accessed */
7923 xfs_timestamp_t di_mtime; /* time last modified */
7924 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
7925 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7926 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7927 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7928 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7930 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7931 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7932 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7933 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
7934 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7935 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7936 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7937 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7939 #ifdef CONFIG_XFS_RT
7940 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7941 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
7942 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7943 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7944 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7945 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7946 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7947 + XFS_DIFLAG_IXUNLINK)
7949 +#define XFS_DIVFLAG_BARRIER 0x01
7950 +#define XFS_DIVFLAG_COW 0x02
7952 #endif /* __XFS_DINODE_H__ */
7953 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_fs.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_fs.h
7954 --- linux-2.6.33/fs/xfs/xfs_fs.h 2009-12-03 20:02:53.000000000 +0100
7955 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_fs.h 2010-02-25 12:02:16.000000000 +0100
7956 @@ -67,6 +67,9 @@ struct fsxattr {
7957 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7958 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7959 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7960 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7961 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7962 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7963 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7966 @@ -292,7 +295,8 @@ typedef struct xfs_bstat {
7967 __s32 bs_extents; /* number of extents */
7968 __u32 bs_gen; /* generation count */
7969 __u16 bs_projid; /* project id */
7970 - unsigned char bs_pad[14]; /* pad space, unused */
7971 + __u16 bs_tag; /* context tagging */
7972 + unsigned char bs_pad[12]; /* pad space, unused */
7973 __u32 bs_dmevmask; /* DMIG event mask */
7974 __u16 bs_dmstate; /* DMIG state info */
7975 __u16 bs_aextents; /* attribute number of extents */
7976 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_ialloc.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_ialloc.c
7977 --- linux-2.6.33/fs/xfs/xfs_ialloc.c 2010-02-25 11:52:06.000000000 +0100
7978 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_ialloc.c 2010-02-25 12:02:16.000000000 +0100
7980 #include "xfs_error.h"
7981 #include "xfs_bmap.h"
7985 * Allocation group level functions.
7987 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_inode.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_inode.c
7988 --- linux-2.6.33/fs/xfs/xfs_inode.c 2010-02-25 11:52:06.000000000 +0100
7989 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_inode.c 2010-02-25 12:02:16.000000000 +0100
7990 @@ -249,6 +249,7 @@ xfs_inotobp(
7994 +#include <linux/vs_tag.h>
7997 * This routine is called to map an inode to the buffer containing
7998 @@ -654,15 +655,25 @@ xfs_iformat_btree(
8000 xfs_dinode_from_disk(
8002 - xfs_dinode_t *from)
8003 + xfs_dinode_t *from,
8006 + uint32_t uid, gid, tag;
8008 to->di_magic = be16_to_cpu(from->di_magic);
8009 to->di_mode = be16_to_cpu(from->di_mode);
8010 to->di_version = from ->di_version;
8011 to->di_format = from->di_format;
8012 to->di_onlink = be16_to_cpu(from->di_onlink);
8013 - to->di_uid = be32_to_cpu(from->di_uid);
8014 - to->di_gid = be32_to_cpu(from->di_gid);
8016 + uid = be32_to_cpu(from->di_uid);
8017 + gid = be32_to_cpu(from->di_gid);
8018 + tag = be16_to_cpu(from->di_tag);
8020 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8021 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8022 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8024 to->di_nlink = be32_to_cpu(from->di_nlink);
8025 to->di_projid = be16_to_cpu(from->di_projid);
8026 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8027 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
8028 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8029 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8030 to->di_flags = be16_to_cpu(from->di_flags);
8031 + to->di_vflags = be16_to_cpu(from->di_vflags);
8032 to->di_gen = be32_to_cpu(from->di_gen);
8038 - xfs_icdinode_t *from)
8039 + xfs_icdinode_t *from,
8042 to->di_magic = cpu_to_be16(from->di_magic);
8043 to->di_mode = cpu_to_be16(from->di_mode);
8044 to->di_version = from ->di_version;
8045 to->di_format = from->di_format;
8046 to->di_onlink = cpu_to_be16(from->di_onlink);
8047 - to->di_uid = cpu_to_be32(from->di_uid);
8048 - to->di_gid = cpu_to_be32(from->di_gid);
8050 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8051 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8052 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8054 to->di_nlink = cpu_to_be32(from->di_nlink);
8055 to->di_projid = cpu_to_be16(from->di_projid);
8056 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8057 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
8058 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8059 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8060 to->di_flags = cpu_to_be16(from->di_flags);
8061 + to->di_vflags = cpu_to_be16(from->di_vflags);
8062 to->di_gen = cpu_to_be32(from->di_gen);
8067 - __uint16_t di_flags)
8068 + __uint16_t di_flags,
8069 + __uint16_t di_vflags)
8073 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
8074 flags |= XFS_XFLAG_PREALLOC;
8075 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8076 flags |= XFS_XFLAG_IMMUTABLE;
8077 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8078 + flags |= XFS_XFLAG_IXUNLINK;
8079 if (di_flags & XFS_DIFLAG_APPEND)
8080 flags |= XFS_XFLAG_APPEND;
8081 if (di_flags & XFS_DIFLAG_SYNC)
8082 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
8083 flags |= XFS_XFLAG_FILESTREAM;
8086 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8087 + flags |= FS_BARRIER_FL;
8088 + if (di_vflags & XFS_DIVFLAG_COW)
8089 + flags |= FS_COW_FL;
8093 @@ -767,7 +791,7 @@ xfs_ip2xflags(
8095 xfs_icdinode_t *dic = &ip->i_d;
8097 - return _xfs_dic2xflags(dic->di_flags) |
8098 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8099 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8102 @@ -775,7 +799,8 @@ uint
8106 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8107 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8108 + be16_to_cpu(dip->di_vflags)) |
8109 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8112 @@ -811,7 +836,6 @@ xfs_iread(
8115 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8118 * If we got something that isn't an inode it means someone
8119 * (nfs or dmi) has a stale handle.
8120 @@ -836,7 +860,8 @@ xfs_iread(
8121 * Otherwise, just get the truly permanent information.
8124 - xfs_dinode_from_disk(&ip->i_d, dip);
8125 + xfs_dinode_from_disk(&ip->i_d, dip,
8126 + mp->m_flags & XFS_MOUNT_TAGGED);
8127 error = xfs_iformat(ip, dip);
8130 @@ -1036,6 +1061,7 @@ xfs_ialloc(
8131 ASSERT(ip->i_d.di_nlink == nlink);
8132 ip->i_d.di_uid = current_fsuid();
8133 ip->i_d.di_gid = current_fsgid();
8134 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8135 ip->i_d.di_projid = prid;
8136 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8138 @@ -1096,6 +1122,7 @@ xfs_ialloc(
8139 ip->i_d.di_dmevmask = 0;
8140 ip->i_d.di_dmstate = 0;
8141 ip->i_d.di_flags = 0;
8142 + ip->i_d.di_vflags = 0;
8143 flags = XFS_ILOG_CORE;
8144 switch (mode & S_IFMT) {
8146 @@ -2136,6 +2163,7 @@ xfs_ifree(
8148 ip->i_d.di_mode = 0; /* mark incore inode as free */
8149 ip->i_d.di_flags = 0;
8150 + ip->i_d.di_vflags = 0;
8151 ip->i_d.di_dmevmask = 0;
8152 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8153 ip->i_df.if_ext_max =
8154 @@ -3116,7 +3144,8 @@ xfs_iflush_int(
8155 * because if the inode is dirty at all the core must
8158 - xfs_dinode_to_disk(dip, &ip->i_d);
8159 + xfs_dinode_to_disk(dip, &ip->i_d,
8160 + mp->m_flags & XFS_MOUNT_TAGGED);
8162 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8163 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8164 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_inode.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_inode.h
8165 --- linux-2.6.33/fs/xfs/xfs_inode.h 2010-02-25 11:52:06.000000000 +0100
8166 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_inode.h 2010-02-25 12:02:16.000000000 +0100
8167 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8168 __uint32_t di_gid; /* owner's group id */
8169 __uint32_t di_nlink; /* number of links to file */
8170 __uint16_t di_projid; /* owner's project id */
8171 - __uint8_t di_pad[8]; /* unused, zeroed space */
8172 + __uint16_t di_tag; /* context tagging */
8173 + __uint16_t di_vflags; /* vserver specific flags */
8174 + __uint8_t di_pad[4]; /* unused, zeroed space */
8175 __uint16_t di_flushiter; /* incremented on flush */
8176 xfs_ictimestamp_t di_atime; /* time last accessed */
8177 xfs_ictimestamp_t di_mtime; /* time last modified */
8178 @@ -521,7 +523,7 @@ int xfs_itobp(struct xfs_mount *, struc
8179 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8180 struct xfs_inode *, xfs_daddr_t, uint);
8181 void xfs_dinode_to_disk(struct xfs_dinode *,
8182 - struct xfs_icdinode *);
8183 + struct xfs_icdinode *, int);
8184 void xfs_idestroy_fork(struct xfs_inode *, int);
8185 void xfs_idata_realloc(struct xfs_inode *, int, int);
8186 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8187 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_itable.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_itable.c
8188 --- linux-2.6.33/fs/xfs/xfs_itable.c 2009-12-03 20:02:54.000000000 +0100
8189 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_itable.c 2010-02-25 12:02:16.000000000 +0100
8190 @@ -84,6 +84,7 @@ xfs_bulkstat_one_iget(
8191 buf->bs_mode = dic->di_mode;
8192 buf->bs_uid = dic->di_uid;
8193 buf->bs_gid = dic->di_gid;
8194 + buf->bs_tag = dic->di_tag;
8195 buf->bs_size = dic->di_size;
8198 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_log_recover.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_log_recover.c
8199 --- linux-2.6.33/fs/xfs/xfs_log_recover.c 2010-02-25 11:52:06.000000000 +0100
8200 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_log_recover.c 2010-02-25 12:02:16.000000000 +0100
8201 @@ -2462,7 +2462,8 @@ xlog_recover_do_inode_trans(
8204 /* The core is in in-core format */
8205 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8206 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8207 + mp->m_flags & XFS_MOUNT_TAGGED);
8209 /* the rest is in on-disk format */
8210 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8211 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_mount.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_mount.h
8212 --- linux-2.6.33/fs/xfs/xfs_mount.h 2010-02-25 11:52:06.000000000 +0100
8213 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_mount.h 2010-02-25 12:02:16.000000000 +0100
8214 @@ -298,6 +298,7 @@ typedef struct xfs_mount {
8216 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8218 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8221 * Default minimum read and write sizes.
8222 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_vnodeops.c linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_vnodeops.c
8223 --- linux-2.6.33/fs/xfs/xfs_vnodeops.c 2010-02-25 11:52:06.000000000 +0100
8224 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_vnodeops.c 2010-02-25 13:24:14.000000000 +0100
8226 #include "xfs_vnodeops.h"
8227 #include "xfs_trace.h"
8231 +xfs_get_inode_flags(
8234 + struct inode *inode = VFS_I(ip);
8235 + unsigned int flags = inode->i_flags;
8236 + unsigned int vflags = inode->i_vflags;
8238 + if (flags & S_IMMUTABLE)
8239 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8241 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8242 + if (flags & S_IXUNLINK)
8243 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8245 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8247 + if (vflags & V_BARRIER)
8248 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8250 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8251 + if (vflags & V_COW)
8252 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8254 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8259 + struct inode *inode,
8263 + struct xfs_inode *ip = XFS_I(inode);
8264 + struct xfs_mount *mp = ip->i_mount;
8265 + struct xfs_trans *tp;
8266 + unsigned int lock_flags = 0;
8269 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8270 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8274 + lock_flags = XFS_ILOCK_EXCL;
8275 + xfs_ilock(ip, lock_flags);
8277 + xfs_trans_ijoin(tp, ip, lock_flags);
8278 + xfs_trans_ihold(tp, ip);
8280 + inode->i_flags = flags;
8281 + inode->i_vflags = vflags;
8282 + xfs_get_inode_flags(ip);
8284 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8285 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8287 + XFS_STATS_INC(xs_ig_attrchg);
8289 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8290 + xfs_trans_set_sync(tp);
8291 + code = xfs_trans_commit(tp, 0);
8292 + xfs_iunlock(ip, lock_flags);
8296 + xfs_trans_cancel(tp, 0);
8298 + xfs_iunlock(ip, lock_flags);
8305 struct xfs_inode *ip,
8306 @@ -70,6 +144,7 @@ xfs_setattr(
8307 uint commit_flags=0;
8308 uid_t uid=0, iuid=0;
8309 gid_t gid=0, igid=0;
8310 + tag_t tag=0, itag=0;
8311 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8312 int need_iolock = 1;
8314 @@ -162,7 +237,7 @@ xfs_setattr(
8316 * Change file ownership. Must be the owner or privileged.
8318 - if (mask & (ATTR_UID|ATTR_GID)) {
8319 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8321 * These IDs could have changed since we last looked at them.
8322 * But, we're assured that if the ownership did change
8323 @@ -171,8 +246,10 @@ xfs_setattr(
8325 iuid = ip->i_d.di_uid;
8326 igid = ip->i_d.di_gid;
8327 + itag = ip->i_d.di_tag;
8328 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8329 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8330 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8333 * Do a quota reservation only if uid/gid is actually
8334 @@ -180,7 +257,8 @@ xfs_setattr(
8336 if (XFS_IS_QUOTA_RUNNING(mp) &&
8337 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8338 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8339 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8340 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8342 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8343 capable(CAP_FOWNER) ?
8344 @@ -341,7 +419,7 @@ xfs_setattr(
8346 * Change file ownership. Must be the owner or privileged.
8348 - if (mask & (ATTR_UID|ATTR_GID)) {
8349 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8351 * CAP_FSETID overrides the following restrictions:
8353 @@ -357,6 +435,10 @@ xfs_setattr(
8354 * Change the ownerships and register quota modifications
8355 * in the transaction.
8357 + if (itag != tag) {
8358 + ip->i_d.di_tag = tag;
8359 + inode->i_tag = tag;
8362 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8363 ASSERT(mask & ATTR_UID);
8364 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_vnodeops.h linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_vnodeops.h
8365 --- linux-2.6.33/fs/xfs/xfs_vnodeops.h 2010-02-25 11:52:06.000000000 +0100
8366 +++ linux-2.6.33-vs2.3.0.36.30/fs/xfs/xfs_vnodeops.h 2010-02-25 12:02:16.000000000 +0100
8367 @@ -14,6 +14,7 @@ struct xfs_inode;
8371 +int xfs_sync_xflags(struct xfs_inode *ip);
8372 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8373 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8374 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8375 diff -NurpP --minimal linux-2.6.33/include/asm-generic/tlb.h linux-2.6.33-vs2.3.0.36.30/include/asm-generic/tlb.h
8376 --- linux-2.6.33/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8377 +++ linux-2.6.33-vs2.3.0.36.30/include/asm-generic/tlb.h 2010-02-25 12:02:16.000000000 +0100
8379 #define _ASM_GENERIC__TLB_H
8381 #include <linux/swap.h>
8382 +#include <linux/vs_memory.h>
8383 #include <asm/pgalloc.h>
8384 #include <asm/tlbflush.h>
8386 diff -NurpP --minimal linux-2.6.33/include/linux/capability.h linux-2.6.33-vs2.3.0.36.30/include/linux/capability.h
8387 --- linux-2.6.33/include/linux/capability.h 2010-02-25 11:52:07.000000000 +0100
8388 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/capability.h 2010-02-25 12:02:16.000000000 +0100
8389 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
8390 arbitrary SCSI commands */
8391 /* Allow setting encryption key on loopback filesystem */
8392 /* Allow setting zone reclaim policy */
8393 +/* Allow the selection of a security context */
8395 #define CAP_SYS_ADMIN 21
8397 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
8399 #define CAP_MAC_ADMIN 33
8401 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8402 +/* Allow context manipulations */
8403 +/* Allow changing context info on files */
8405 +#define CAP_CONTEXT 34
8408 +#define CAP_LAST_CAP CAP_CONTEXT
8410 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8412 diff -NurpP --minimal linux-2.6.33/include/linux/devpts_fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/devpts_fs.h
8413 --- linux-2.6.33/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8414 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/devpts_fs.h 2010-02-25 12:02:16.000000000 +0100
8415 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8420 #endif /* _LINUX_DEVPTS_FS_H */
8421 diff -NurpP --minimal linux-2.6.33/include/linux/ext2_fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/ext2_fs.h
8422 --- linux-2.6.33/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8423 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/ext2_fs.h 2010-02-25 12:02:16.000000000 +0100
8424 @@ -189,8 +189,12 @@ struct ext2_group_desc
8425 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8426 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8427 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8428 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8429 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8431 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8432 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8434 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8435 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8437 @@ -274,7 +278,8 @@ struct ext2_inode {
8439 __le16 l_i_uid_high; /* these 2 fields */
8440 __le16 l_i_gid_high; /* were reserved2[0] */
8441 - __u32 l_i_reserved2;
8442 + __le16 l_i_tag; /* Context Tag */
8443 + __u16 l_i_reserved2;
8446 __u8 h_i_frag; /* Fragment number */
8447 @@ -303,6 +308,7 @@ struct ext2_inode {
8448 #define i_gid_low i_gid
8449 #define i_uid_high osd2.linux2.l_i_uid_high
8450 #define i_gid_high osd2.linux2.l_i_gid_high
8451 +#define i_raw_tag osd2.linux2.l_i_tag
8452 #define i_reserved2 osd2.linux2.l_i_reserved2
8455 @@ -347,6 +353,7 @@ struct ext2_inode {
8456 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8457 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8458 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8459 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8462 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8463 diff -NurpP --minimal linux-2.6.33/include/linux/ext3_fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/ext3_fs.h
8464 --- linux-2.6.33/include/linux/ext3_fs.h 2010-02-25 11:52:07.000000000 +0100
8465 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/ext3_fs.h 2010-02-25 12:02:16.000000000 +0100
8466 @@ -173,10 +173,14 @@ struct ext3_group_desc
8467 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8468 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8469 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8470 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8471 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8473 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8474 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8475 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8476 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8478 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8479 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8481 /* Flags that should be inherited by new inodes from their parent. */
8482 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8483 @@ -320,7 +324,8 @@ struct ext3_inode {
8485 __le16 l_i_uid_high; /* these 2 fields */
8486 __le16 l_i_gid_high; /* were reserved2[0] */
8487 - __u32 l_i_reserved2;
8488 + __le16 l_i_tag; /* Context Tag */
8489 + __u16 l_i_reserved2;
8492 __u8 h_i_frag; /* Fragment number */
8493 @@ -351,6 +356,7 @@ struct ext3_inode {
8494 #define i_gid_low i_gid
8495 #define i_uid_high osd2.linux2.l_i_uid_high
8496 #define i_gid_high osd2.linux2.l_i_gid_high
8497 +#define i_raw_tag osd2.linux2.l_i_tag
8498 #define i_reserved2 osd2.linux2.l_i_reserved2
8500 #elif defined(__GNU__)
8501 @@ -414,6 +420,7 @@ struct ext3_inode {
8502 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8503 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8504 * error in ordered mode */
8505 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8507 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8508 #ifndef _LINUX_EXT2_FS_H
8509 @@ -892,6 +899,7 @@ extern void ext3_get_inode_flags(struct
8510 extern void ext3_set_aops(struct inode *inode);
8511 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8512 u64 start, u64 len);
8513 +extern int ext3_sync_flags(struct inode *, int, int);
8516 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8517 diff -NurpP --minimal linux-2.6.33/include/linux/fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/fs.h
8518 --- linux-2.6.33/include/linux/fs.h 2010-02-25 11:52:07.000000000 +0100
8519 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/fs.h 2010-02-25 13:36:54.000000000 +0100
8520 @@ -206,6 +206,9 @@ struct inodes_stat_t {
8521 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8522 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8523 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8524 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8525 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8526 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8527 #define MS_ACTIVE (1<<30)
8528 #define MS_NOUSER (1<<31)
8530 @@ -232,6 +235,14 @@ struct inodes_stat_t {
8531 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8532 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8533 #define S_PRIVATE 512 /* Inode is fs-internal */
8534 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8536 +/* Linux-VServer related Inode flags */
8540 +#define V_BARRIER 4 /* Barrier for chroot() */
8541 +#define V_COW 8 /* Copy on Write */
8544 * Note that nosuid etc flags are inode-specific: setting some file-system
8545 @@ -254,12 +265,15 @@ struct inodes_stat_t {
8546 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8547 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8548 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8549 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8550 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8551 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8552 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8553 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8555 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8556 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8557 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8558 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8559 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8560 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8562 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8563 @@ -267,6 +281,16 @@ struct inodes_stat_t {
8564 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8565 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8567 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8569 +#ifdef CONFIG_VSERVER_COWBL
8570 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8571 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8573 +# define IS_COW(inode) (0)
8574 +# define IS_COW_LINK(inode) (0)
8577 /* the read-only stuff doesn't really belong here, but any other place is
8578 probably as bad and I don't want to create yet another include file. */
8580 @@ -349,11 +373,14 @@ struct inodes_stat_t {
8581 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8582 #define FS_EXTENT_FL 0x00080000 /* Extents */
8583 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8584 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8585 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8587 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8588 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8589 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8590 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8592 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8593 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8595 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8596 #define SYNC_FILE_RANGE_WRITE 2
8597 @@ -435,6 +462,7 @@ typedef void (dio_iodone_t)(struct kiocb
8598 #define ATTR_KILL_PRIV (1 << 14)
8599 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8600 #define ATTR_TIMES_SET (1 << 16)
8601 +#define ATTR_TAG (1 << 17)
8604 * This is the Inode Attributes structure, used for notify_change(). It
8605 @@ -450,6 +478,7 @@ struct iattr {
8611 struct timespec ia_atime;
8612 struct timespec ia_mtime;
8613 @@ -463,6 +492,9 @@ struct iattr {
8614 struct file *ia_file;
8617 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8618 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8621 * Includes for diskquotas.
8623 @@ -728,7 +760,9 @@ struct inode {
8624 unsigned int i_nlink;
8630 unsigned int i_blkbits;
8633 @@ -775,7 +809,8 @@ struct inode {
8634 unsigned long i_state;
8635 unsigned long dirtied_when; /* jiffies of first dirtying */
8637 - unsigned int i_flags;
8638 + unsigned short i_flags;
8639 + unsigned short i_vflags;
8641 atomic_t i_writecount;
8642 #ifdef CONFIG_SECURITY
8643 @@ -863,12 +898,12 @@ static inline void i_size_write(struct i
8645 static inline unsigned iminor(const struct inode *inode)
8647 - return MINOR(inode->i_rdev);
8648 + return MINOR(inode->i_mdev);
8651 static inline unsigned imajor(const struct inode *inode)
8653 - return MAJOR(inode->i_rdev);
8654 + return MAJOR(inode->i_mdev);
8657 extern struct block_device *I_BDEV(struct inode *inode);
8658 @@ -927,6 +962,7 @@ struct file {
8660 struct fown_struct f_owner;
8661 const struct cred *f_cred;
8663 struct file_ra_state f_ra;
8666 @@ -1068,6 +1104,7 @@ struct file_lock {
8667 struct file *fl_file;
8672 struct fasync_struct * fl_fasync; /* for lease break notifications */
8673 unsigned long fl_break_time; /* for nonblocking lease breaks */
8674 @@ -1529,6 +1566,7 @@ struct inode_operations {
8675 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8676 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8677 int (*removexattr) (struct dentry *, const char *);
8678 + int (*sync_flags) (struct inode *, int, int);
8679 void (*truncate_range)(struct inode *, loff_t, loff_t);
8680 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8682 @@ -1549,6 +1587,7 @@ extern ssize_t vfs_readv(struct file *,
8683 unsigned long, loff_t *);
8684 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8685 unsigned long, loff_t *);
8686 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8688 struct super_operations {
8689 struct inode *(*alloc_inode)(struct super_block *sb);
8690 @@ -2331,6 +2370,7 @@ extern int dcache_dir_open(struct inode
8691 extern int dcache_dir_close(struct inode *, struct file *);
8692 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8693 extern int dcache_readdir(struct file *, void *, filldir_t);
8694 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8695 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8696 extern int simple_statfs(struct dentry *, struct kstatfs *);
8697 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8698 diff -NurpP --minimal linux-2.6.33/include/linux/gfs2_ondisk.h linux-2.6.33-vs2.3.0.36.30/include/linux/gfs2_ondisk.h
8699 --- linux-2.6.33/include/linux/gfs2_ondisk.h 2010-02-25 11:52:07.000000000 +0100
8700 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/gfs2_ondisk.h 2010-02-25 12:02:16.000000000 +0100
8701 @@ -239,6 +239,9 @@ enum {
8705 + gfs2fl_IXUnlink = 16,
8706 + gfs2fl_Barrier = 17,
8708 gfs2fl_TruncInProg = 29,
8709 gfs2fl_InheritDirectio = 30,
8710 gfs2fl_InheritJdata = 31,
8711 @@ -255,6 +258,9 @@ enum {
8712 #define GFS2_DIF_NOATIME 0x00000080
8713 #define GFS2_DIF_SYNC 0x00000100
8714 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8715 +#define GFS2_DIF_IXUNLINK 0x00010000
8716 +#define GFS2_DIF_BARRIER 0x00020000
8717 +#define GFS2_DIF_COW 0x00040000
8718 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8719 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8720 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8721 diff -NurpP --minimal linux-2.6.33/include/linux/if_tun.h linux-2.6.33-vs2.3.0.36.30/include/linux/if_tun.h
8722 --- linux-2.6.33/include/linux/if_tun.h 2009-12-03 20:02:55.000000000 +0100
8723 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/if_tun.h 2010-02-25 12:02:16.000000000 +0100
8725 #define TUNGETIFF _IOR('T', 210, unsigned int)
8726 #define TUNGETSNDBUF _IOR('T', 211, int)
8727 #define TUNSETSNDBUF _IOW('T', 212, int)
8728 +#define TUNSETNID _IOW('T', 215, int)
8730 /* TUNSETIFF ifr flags */
8731 #define IFF_TUN 0x0001
8732 diff -NurpP --minimal linux-2.6.33/include/linux/init_task.h linux-2.6.33-vs2.3.0.36.30/include/linux/init_task.h
8733 --- linux-2.6.33/include/linux/init_task.h 2010-02-25 11:52:07.000000000 +0100
8734 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/init_task.h 2010-02-25 12:02:16.000000000 +0100
8735 @@ -180,6 +180,10 @@ extern struct cred init_cred;
8737 INIT_TRACE_RECURSION \
8738 INIT_TASK_RCU_PREEMPT(tsk) \
8740 + .vx_info = NULL, \
8742 + .nx_info = NULL, \
8746 diff -NurpP --minimal linux-2.6.33/include/linux/ipc.h linux-2.6.33-vs2.3.0.36.30/include/linux/ipc.h
8747 --- linux-2.6.33/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8748 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/ipc.h 2010-02-25 12:02:16.000000000 +0100
8749 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8757 diff -NurpP --minimal linux-2.6.33/include/linux/Kbuild linux-2.6.33-vs2.3.0.36.30/include/linux/Kbuild
8758 --- linux-2.6.33/include/linux/Kbuild 2010-02-25 11:52:07.000000000 +0100
8759 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/Kbuild 2010-02-25 12:02:16.000000000 +0100
8760 @@ -383,5 +383,8 @@ unifdef-y += xattr.h
8763 objhdr-y += version.h
8765 +header-y += vserver/
8769 diff -NurpP --minimal linux-2.6.33/include/linux/loop.h linux-2.6.33-vs2.3.0.36.30/include/linux/loop.h
8770 --- linux-2.6.33/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8771 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/loop.h 2010-02-25 12:02:16.000000000 +0100
8772 @@ -45,6 +45,7 @@ struct loop_device {
8773 struct loop_func_table *lo_encryption;
8775 uid_t lo_key_owner; /* Who set the key */
8777 int (*ioctl)(struct loop_device *, int cmd,
8780 diff -NurpP --minimal linux-2.6.33/include/linux/magic.h linux-2.6.33-vs2.3.0.36.30/include/linux/magic.h
8781 --- linux-2.6.33/include/linux/magic.h 2009-12-03 20:02:55.000000000 +0100
8782 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/magic.h 2010-02-25 12:02:16.000000000 +0100
8785 #define ADFS_SUPER_MAGIC 0xadf5
8786 #define AFFS_SUPER_MAGIC 0xadff
8787 -#define AFS_SUPER_MAGIC 0x5346414F
8788 +#define AFS_SUPER_MAGIC 0x5346414F
8789 #define AUTOFS_SUPER_MAGIC 0x0187
8790 #define CODA_SUPER_MAGIC 0x73757245
8791 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8793 #define NFS_SUPER_MAGIC 0x6969
8794 #define OPENPROM_SUPER_MAGIC 0x9fa1
8795 #define PROC_SUPER_MAGIC 0x9fa0
8796 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8797 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8799 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8800 diff -NurpP --minimal linux-2.6.33/include/linux/major.h linux-2.6.33-vs2.3.0.36.30/include/linux/major.h
8801 --- linux-2.6.33/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8802 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/major.h 2010-02-25 12:02:16.000000000 +0100
8804 #define HD_MAJOR IDE0_MAJOR
8805 #define PTY_SLAVE_MAJOR 3
8807 +#define VROOT_MAJOR 4
8808 #define TTYAUX_MAJOR 5
8811 diff -NurpP --minimal linux-2.6.33/include/linux/memcontrol.h linux-2.6.33-vs2.3.0.36.30/include/linux/memcontrol.h
8812 --- linux-2.6.33/include/linux/memcontrol.h 2010-02-25 11:52:07.000000000 +0100
8813 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/memcontrol.h 2010-02-25 12:02:16.000000000 +0100
8814 @@ -76,6 +76,13 @@ int task_in_mem_cgroup(struct task_struc
8815 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
8816 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8818 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8819 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8821 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8822 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8823 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8826 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8828 diff -NurpP --minimal linux-2.6.33/include/linux/mm_types.h linux-2.6.33-vs2.3.0.36.30/include/linux/mm_types.h
8829 --- linux-2.6.33/include/linux/mm_types.h 2010-02-25 11:52:07.000000000 +0100
8830 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/mm_types.h 2010-02-25 12:02:16.000000000 +0100
8831 @@ -250,6 +250,7 @@ struct mm_struct {
8833 /* Architecture-specific MM context */
8834 mm_context_t context;
8835 + struct vx_info *mm_vx_info;
8837 /* Swap token stuff */
8839 diff -NurpP --minimal linux-2.6.33/include/linux/mount.h linux-2.6.33-vs2.3.0.36.30/include/linux/mount.h
8840 --- linux-2.6.33/include/linux/mount.h 2009-09-10 15:26:25.000000000 +0200
8841 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/mount.h 2010-02-25 12:02:16.000000000 +0100
8842 @@ -36,6 +36,9 @@ struct mnt_namespace;
8843 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8844 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8846 +#define MNT_TAGID 0x10000
8847 +#define MNT_NOTAG 0x20000
8850 struct list_head mnt_hash;
8851 struct vfsmount *mnt_parent; /* fs we are mounted on */
8852 @@ -70,6 +73,7 @@ struct vfsmount {
8856 + tag_t mnt_tag; /* tagging used for vfsmount */
8859 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
8860 diff -NurpP --minimal linux-2.6.33/include/linux/net.h linux-2.6.33-vs2.3.0.36.30/include/linux/net.h
8861 --- linux-2.6.33/include/linux/net.h 2010-02-25 11:52:07.000000000 +0100
8862 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/net.h 2010-02-25 12:02:16.000000000 +0100
8863 @@ -70,6 +70,7 @@ struct net;
8864 #define SOCK_NOSPACE 2
8865 #define SOCK_PASSCRED 3
8866 #define SOCK_PASSSEC 4
8867 +#define SOCK_USER_SOCKET 5
8869 #ifndef ARCH_HAS_SOCKET_TYPES
8871 diff -NurpP --minimal linux-2.6.33/include/linux/nfs_mount.h linux-2.6.33-vs2.3.0.36.30/include/linux/nfs_mount.h
8872 --- linux-2.6.33/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
8873 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/nfs_mount.h 2010-02-25 12:02:16.000000000 +0100
8874 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8875 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8876 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8877 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8878 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8879 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8880 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8882 /* The following are for internal use only */
8883 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8884 diff -NurpP --minimal linux-2.6.33/include/linux/nsproxy.h linux-2.6.33-vs2.3.0.36.30/include/linux/nsproxy.h
8885 --- linux-2.6.33/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
8886 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/nsproxy.h 2010-02-25 12:02:16.000000000 +0100
8889 #include <linux/spinlock.h>
8890 #include <linux/sched.h>
8891 +#include <linux/vserver/debug.h>
8893 struct mnt_namespace;
8894 struct uts_namespace;
8895 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8898 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8899 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8900 void exit_task_namespaces(struct task_struct *tsk);
8901 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8902 void free_nsproxy(struct nsproxy *ns);
8903 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8904 struct fs_struct *);
8906 -static inline void put_nsproxy(struct nsproxy *ns)
8907 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8909 +static inline void __get_nsproxy(struct nsproxy *ns,
8910 + const char *_file, int _line)
8912 - if (atomic_dec_and_test(&ns->count)) {
8915 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8916 + ns, atomic_read(&ns->count), _file, _line);
8917 + atomic_inc(&ns->count);
8920 -static inline void get_nsproxy(struct nsproxy *ns)
8921 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8923 +static inline void __put_nsproxy(struct nsproxy *ns,
8924 + const char *_file, int _line)
8926 - atomic_inc(&ns->count);
8927 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8928 + ns, atomic_read(&ns->count), _file, _line);
8929 + if (atomic_dec_and_test(&ns->count)) {
8934 #ifdef CONFIG_CGROUP_NS
8935 diff -NurpP --minimal linux-2.6.33/include/linux/pid.h linux-2.6.33-vs2.3.0.36.30/include/linux/pid.h
8936 --- linux-2.6.33/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
8937 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/pid.h 2010-02-25 12:02:16.000000000 +0100
8938 @@ -8,7 +8,8 @@ enum pid_type
8948 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
8951 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8952 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8953 pid_t pid_vnr(struct pid *pid);
8955 #define do_each_pid_task(pid, type, task) \
8956 diff -NurpP --minimal linux-2.6.33/include/linux/proc_fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/proc_fs.h
8957 --- linux-2.6.33/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
8958 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/proc_fs.h 2010-02-25 12:02:16.000000000 +0100
8959 @@ -56,6 +56,7 @@ struct proc_dir_entry {
8965 const struct inode_operations *proc_iops;
8967 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
8968 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
8975 int (*proc_get_link)(struct inode *, struct path *);
8976 int (*proc_read)(struct task_struct *task, char *page);
8977 int (*proc_show)(struct seq_file *m,
8978 struct pid_namespace *ns, struct pid *pid,
8979 struct task_struct *task);
8980 + int (*proc_vs_read)(char *page);
8981 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8982 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8985 struct ctl_table_header;
8986 @@ -263,6 +270,7 @@ struct ctl_table;
8993 struct proc_dir_entry *pde;
8994 diff -NurpP --minimal linux-2.6.33/include/linux/quotaops.h linux-2.6.33-vs2.3.0.36.30/include/linux/quotaops.h
8995 --- linux-2.6.33/include/linux/quotaops.h 2009-12-03 20:02:56.000000000 +0100
8996 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/quotaops.h 2010-02-25 12:02:16.000000000 +0100
8998 #define _LINUX_QUOTAOPS_
9000 #include <linux/fs.h>
9001 +#include <linux/vs_dlimit.h>
9003 static inline struct quota_info *sb_dqopt(struct super_block *sb)
9005 @@ -154,10 +155,14 @@ static inline void vfs_dq_init(struct in
9006 * a transaction (deadlocks possible otherwise) */
9007 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9009 + if (dl_alloc_space(inode, nr))
9011 if (sb_any_quota_active(inode->i_sb)) {
9012 /* Used space is updated in alloc_space() */
9013 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
9014 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) {
9015 + dl_free_space(inode, nr);
9020 inode_add_bytes(inode, nr);
9021 @@ -174,10 +179,14 @@ static inline int vfs_dq_prealloc_space(
9023 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9025 + if (dl_alloc_space(inode, nr))
9027 if (sb_any_quota_active(inode->i_sb)) {
9028 /* Used space is updated in alloc_space() */
9029 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
9030 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) {
9031 + dl_free_space(inode, nr);
9036 inode_add_bytes(inode, nr);
9037 @@ -194,20 +203,28 @@ static inline int vfs_dq_alloc_space(str
9039 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9041 + if (dl_reserve_space(inode, nr))
9043 if (sb_any_quota_active(inode->i_sb)) {
9044 /* Used space is updated in alloc_space() */
9045 - if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
9046 + if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) {
9047 + dl_release_space(inode, nr);
9054 static inline int vfs_dq_alloc_inode(struct inode *inode)
9056 + if (dl_alloc_inode(inode))
9058 if (sb_any_quota_active(inode->i_sb)) {
9060 - if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
9061 + if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
9062 + dl_free_inode(inode);
9068 @@ -217,9 +234,13 @@ static inline int vfs_dq_alloc_inode(str
9070 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9072 + if (dl_claim_space(inode, nr))
9074 if (sb_any_quota_active(inode->i_sb)) {
9075 - if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
9076 + if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
9077 + dl_release_space(inode, nr);
9081 inode_add_bytes(inode, nr);
9083 @@ -235,6 +256,7 @@ void vfs_dq_release_reservation_space(st
9085 if (sb_any_quota_active(inode->i_sb))
9086 inode->i_sb->dq_op->release_rsv(inode, nr);
9087 + dl_release_space(inode, nr);
9090 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9091 @@ -243,6 +265,7 @@ static inline void vfs_dq_free_space_nod
9092 inode->i_sb->dq_op->free_space(inode, nr);
9094 inode_sub_bytes(inode, nr);
9095 + dl_free_space(inode, nr);
9098 static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
9099 @@ -255,6 +278,7 @@ static inline void vfs_dq_free_inode(str
9101 if (sb_any_quota_active(inode->i_sb))
9102 inode->i_sb->dq_op->free_inode(inode, 1);
9103 + dl_free_inode(inode);
9106 /* Cannot be called inside a transaction */
9107 @@ -358,6 +382,8 @@ static inline int vfs_dq_transfer(struct
9109 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9111 + if (dl_alloc_space(inode, nr))
9113 inode_add_bytes(inode, nr);
9116 @@ -371,6 +397,8 @@ static inline int vfs_dq_prealloc_space(
9118 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9120 + if (dl_alloc_space(inode, nr))
9122 inode_add_bytes(inode, nr);
9125 @@ -384,22 +412,28 @@ static inline int vfs_dq_alloc_space(str
9127 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9129 + if (dl_reserve_space(inode, nr))
9134 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9136 + if (dl_claim_space(inode, nr))
9138 return vfs_dq_alloc_space(inode, nr);
9142 int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
9144 + dl_release_space(inode, nr);
9148 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9150 + dl_free_space(inode, nr);
9151 inode_sub_bytes(inode, nr);
9154 diff -NurpP --minimal linux-2.6.33/include/linux/reboot.h linux-2.6.33-vs2.3.0.36.30/include/linux/reboot.h
9155 --- linux-2.6.33/include/linux/reboot.h 2008-12-25 00:26:37.000000000 +0100
9156 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/reboot.h 2010-02-25 12:02:16.000000000 +0100
9158 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9159 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9160 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9161 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9165 diff -NurpP --minimal linux-2.6.33/include/linux/reiserfs_fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/reiserfs_fs.h
9166 --- linux-2.6.33/include/linux/reiserfs_fs.h 2010-02-25 11:52:07.000000000 +0100
9167 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/reiserfs_fs.h 2010-02-25 12:02:16.000000000 +0100
9168 @@ -977,6 +977,11 @@ struct stat_data_v1 {
9169 #define REISERFS_COMPR_FL FS_COMPR_FL
9170 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9172 +/* unfortunately reiserfs sdattr is only 16 bit */
9173 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9174 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9175 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9177 /* persistent flags that file inherits from the parent directory */
9178 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9179 REISERFS_SYNC_FL | \
9180 @@ -986,6 +991,9 @@ struct stat_data_v1 {
9181 REISERFS_COMPR_FL | \
9182 REISERFS_NOTAIL_FL )
9184 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9185 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9187 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9190 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
9191 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9192 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9193 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9194 +int reiserfs_sync_flags(struct inode *inode, int, int);
9197 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9198 diff -NurpP --minimal linux-2.6.33/include/linux/reiserfs_fs_sb.h linux-2.6.33-vs2.3.0.36.30/include/linux/reiserfs_fs_sb.h
9199 --- linux-2.6.33/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9200 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/reiserfs_fs_sb.h 2010-02-25 12:02:16.000000000 +0100
9201 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9202 REISERFS_EXPOSE_PRIVROOT,
9203 REISERFS_BARRIER_NONE,
9204 REISERFS_BARRIER_FLUSH,
9207 /* Actions on error */
9208 REISERFS_ERROR_PANIC,
9209 diff -NurpP --minimal linux-2.6.33/include/linux/sched.h linux-2.6.33-vs2.3.0.36.30/include/linux/sched.h
9210 --- linux-2.6.33/include/linux/sched.h 2010-02-25 11:52:07.000000000 +0100
9211 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/sched.h 2010-02-25 12:02:16.000000000 +0100
9212 @@ -401,25 +401,28 @@ static inline void arch_pick_mmap_layout
9213 * The mm counters are not protected by its page_table_lock,
9214 * so must be incremented atomically.
9216 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9217 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9218 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9219 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9220 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9221 +#define __set_mm_counter(mm, member, value) \
9222 + atomic_long_set(&(mm)->_##member, value)
9223 +#define get_mm_counter(mm, member) \
9224 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9226 #else /* !USE_SPLIT_PTLOCKS */
9228 * The mm counters are protected by its page_table_lock,
9229 * so can be incremented directly.
9231 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9232 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9233 #define get_mm_counter(mm, member) ((mm)->_##member)
9234 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9235 -#define inc_mm_counter(mm, member) (mm)->_##member++
9236 -#define dec_mm_counter(mm, member) (mm)->_##member--
9238 #endif /* !USE_SPLIT_PTLOCKS */
9240 +#define set_mm_counter(mm, member, value) \
9241 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9242 +#define add_mm_counter(mm, member, value) \
9243 + vx_ ## member ## pages_add((mm), (value))
9244 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9245 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9247 #define get_mm_rss(mm) \
9248 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9249 #define update_hiwater_rss(mm) do { \
9250 @@ -1200,6 +1203,12 @@ struct sched_entity {
9251 u64 nr_wakeups_affine_attempts;
9252 u64 nr_wakeups_passive;
9253 u64 nr_wakeups_idle;
9254 +#ifdef CONFIG_CFS_HARD_LIMITS
9255 + u64 throttle_start;
9257 + u64 throttle_count;
9262 #ifdef CONFIG_FAIR_GROUP_SCHED
9263 @@ -1412,6 +1421,14 @@ struct task_struct {
9267 +/* vserver context data */
9268 + struct vx_info *vx_info;
9269 + struct nx_info *nx_info;
9275 /* Thread group tracking */
9278 @@ -1645,6 +1662,11 @@ struct pid_namespace;
9279 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9280 struct pid_namespace *ns);
9282 +#include <linux/vserver/base.h>
9283 +#include <linux/vserver/context.h>
9284 +#include <linux/vserver/debug.h>
9285 +#include <linux/vserver/pid.h>
9287 static inline pid_t task_pid_nr(struct task_struct *tsk)
9290 @@ -1658,7 +1680,8 @@ static inline pid_t task_pid_nr_ns(struc
9292 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9294 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9295 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9296 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9300 @@ -1671,7 +1694,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9302 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9304 - return pid_vnr(task_tgid(tsk));
9305 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9309 diff -NurpP --minimal linux-2.6.33/include/linux/shmem_fs.h linux-2.6.33-vs2.3.0.36.30/include/linux/shmem_fs.h
9310 --- linux-2.6.33/include/linux/shmem_fs.h 2010-02-25 11:52:08.000000000 +0100
9311 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/shmem_fs.h 2010-02-25 12:02:16.000000000 +0100
9314 #define SHMEM_NR_DIRECT 16
9316 +#define TMPFS_SUPER_MAGIC 0x01021994
9319 struct shmem_inode_info {
9321 unsigned long flags;
9322 diff -NurpP --minimal linux-2.6.33/include/linux/stat.h linux-2.6.33-vs2.3.0.36.30/include/linux/stat.h
9323 --- linux-2.6.33/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9324 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/stat.h 2010-02-25 12:02:16.000000000 +0100
9325 @@ -66,6 +66,7 @@ struct kstat {
9332 struct timespec atime;
9333 diff -NurpP --minimal linux-2.6.33/include/linux/sunrpc/auth.h linux-2.6.33-vs2.3.0.36.30/include/linux/sunrpc/auth.h
9334 --- linux-2.6.33/include/linux/sunrpc/auth.h 2009-12-03 20:02:56.000000000 +0100
9335 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/sunrpc/auth.h 2010-02-25 12:02:16.000000000 +0100
9341 struct group_info *group_info;
9342 unsigned char machine_cred : 1;
9344 diff -NurpP --minimal linux-2.6.33/include/linux/sunrpc/clnt.h linux-2.6.33-vs2.3.0.36.30/include/linux/sunrpc/clnt.h
9345 --- linux-2.6.33/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
9346 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/sunrpc/clnt.h 2010-02-25 12:02:16.000000000 +0100
9347 @@ -49,7 +49,8 @@ struct rpc_clnt {
9348 unsigned int cl_softrtry : 1,/* soft timeouts */
9349 cl_discrtry : 1,/* disconnect before retry */
9350 cl_autobind : 1,/* use getport() */
9351 - cl_chatty : 1;/* be verbose */
9352 + cl_chatty : 1,/* be verbose */
9353 + cl_tag : 1;/* context tagging */
9355 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9356 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9357 diff -NurpP --minimal linux-2.6.33/include/linux/syscalls.h linux-2.6.33-vs2.3.0.36.30/include/linux/syscalls.h
9358 --- linux-2.6.33/include/linux/syscalls.h 2010-02-25 11:52:08.000000000 +0100
9359 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/syscalls.h 2010-02-25 12:02:16.000000000 +0100
9360 @@ -496,6 +496,8 @@ asmlinkage long sys_symlink(const char _
9361 asmlinkage long sys_unlink(const char __user *pathname);
9362 asmlinkage long sys_rename(const char __user *oldname,
9363 const char __user *newname);
9364 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9366 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9367 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9369 diff -NurpP --minimal linux-2.6.33/include/linux/sysctl.h linux-2.6.33-vs2.3.0.36.30/include/linux/sysctl.h
9370 --- linux-2.6.33/include/linux/sysctl.h 2010-02-25 11:52:08.000000000 +0100
9371 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/sysctl.h 2010-02-25 12:02:16.000000000 +0100
9372 @@ -60,6 +60,7 @@ enum
9373 CTL_ABI=9, /* Binary emulation */
9374 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9375 CTL_ARLAN=254, /* arlan wireless driver */
9376 + CTL_VSERVER=4242, /* Linux-VServer debug */
9377 CTL_S390DBF=5677, /* s390 debug */
9378 CTL_SUNRPC=7249, /* sunrpc debug */
9379 CTL_PM=9899, /* frv power management */
9380 @@ -94,6 +95,7 @@ enum
9382 KERN_PANIC=15, /* int: panic timeout */
9383 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9384 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9386 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9387 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9388 diff -NurpP --minimal linux-2.6.33/include/linux/sysfs.h linux-2.6.33-vs2.3.0.36.30/include/linux/sysfs.h
9389 --- linux-2.6.33/include/linux/sysfs.h 2010-02-25 11:52:08.000000000 +0100
9390 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/sysfs.h 2010-02-25 12:02:16.000000000 +0100
9392 #include <linux/list.h>
9393 #include <asm/atomic.h>
9395 +#define SYSFS_SUPER_MAGIC 0x62656572
9400 diff -NurpP --minimal linux-2.6.33/include/linux/time.h linux-2.6.33-vs2.3.0.36.30/include/linux/time.h
9401 --- linux-2.6.33/include/linux/time.h 2010-02-25 11:52:08.000000000 +0100
9402 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/time.h 2010-02-25 12:02:16.000000000 +0100
9403 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
9404 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9408 +#include <linux/vs_time.h>
9410 #endif /* __KERNEL__ */
9412 #define NFDBITS __NFDBITS
9413 diff -NurpP --minimal linux-2.6.33/include/linux/types.h linux-2.6.33-vs2.3.0.36.30/include/linux/types.h
9414 --- linux-2.6.33/include/linux/types.h 2009-09-10 15:26:26.000000000 +0200
9415 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/types.h 2010-02-25 12:02:16.000000000 +0100
9416 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
9417 typedef __kernel_gid32_t gid_t;
9418 typedef __kernel_uid16_t uid16_t;
9419 typedef __kernel_gid16_t gid16_t;
9420 +typedef unsigned int xid_t;
9421 +typedef unsigned int nid_t;
9422 +typedef unsigned int tag_t;
9424 typedef unsigned long uintptr_t;
9426 diff -NurpP --minimal linux-2.6.33/include/linux/vroot.h linux-2.6.33-vs2.3.0.36.30/include/linux/vroot.h
9427 --- linux-2.6.33/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9428 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vroot.h 2010-02-25 12:02:16.000000000 +0100
9432 + * include/linux/vroot.h
9434 + * written by Herbert Pötzl, 9/11/2002
9435 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9437 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9438 + * Redistribution of this file is permitted under the
9439 + * GNU General Public License.
9442 +#ifndef _LINUX_VROOT_H
9443 +#define _LINUX_VROOT_H
9448 +/* Possible states of device */
9454 +struct vroot_device {
9458 + struct semaphore vr_ctl_mutex;
9459 + struct block_device *vr_device;
9464 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9466 +extern int register_vroot_grb(vroot_grb_func *);
9467 +extern int unregister_vroot_grb(vroot_grb_func *);
9469 +#endif /* __KERNEL__ */
9471 +#define MAX_VROOT_DEFAULT 8
9474 + * IOCTL commands --- we will commandeer 0x56 ('V')
9477 +#define VROOT_SET_DEV 0x5600
9478 +#define VROOT_CLR_DEV 0x5601
9480 +#endif /* _LINUX_VROOT_H */
9481 diff -NurpP --minimal linux-2.6.33/include/linux/vs_base.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_base.h
9482 --- linux-2.6.33/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9483 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_base.h 2010-02-25 12:02:16.000000000 +0100
9488 +#include "vserver/base.h"
9489 +#include "vserver/check.h"
9490 +#include "vserver/debug.h"
9493 +#warning duplicate inclusion
9495 diff -NurpP --minimal linux-2.6.33/include/linux/vs_context.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_context.h
9496 --- linux-2.6.33/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9497 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_context.h 2010-02-25 12:02:16.000000000 +0100
9499 +#ifndef _VS_CONTEXT_H
9500 +#define _VS_CONTEXT_H
9502 +#include "vserver/base.h"
9503 +#include "vserver/check.h"
9504 +#include "vserver/context.h"
9505 +#include "vserver/history.h"
9506 +#include "vserver/debug.h"
9508 +#include <linux/sched.h>
9511 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9513 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9514 + const char *_file, int _line, void *_here)
9519 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9520 + vxi, vxi ? vxi->vx_id : 0,
9521 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9523 + __vxh_get_vx_info(vxi, _here);
9525 + atomic_inc(&vxi->vx_usecnt);
9530 +extern void free_vx_info(struct vx_info *);
9532 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9534 +static inline void __put_vx_info(struct vx_info *vxi,
9535 + const char *_file, int _line, void *_here)
9540 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9541 + vxi, vxi ? vxi->vx_id : 0,
9542 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9544 + __vxh_put_vx_info(vxi, _here);
9546 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9547 + free_vx_info(vxi);
9551 +#define init_vx_info(p, i) \
9552 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9554 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9555 + const char *_file, int _line, void *_here)
9558 + vxlprintk(VXD_CBIT(xid, 3),
9559 + "init_vx_info(%p[#%d.%d])",
9560 + vxi, vxi ? vxi->vx_id : 0,
9561 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9563 + __vxh_init_vx_info(vxi, vxp, _here);
9565 + atomic_inc(&vxi->vx_usecnt);
9571 +#define set_vx_info(p, i) \
9572 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9574 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9575 + const char *_file, int _line, void *_here)
9577 + struct vx_info *vxo;
9582 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9583 + vxi, vxi ? vxi->vx_id : 0,
9584 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9586 + __vxh_set_vx_info(vxi, vxp, _here);
9588 + atomic_inc(&vxi->vx_usecnt);
9589 + vxo = xchg(vxp, vxi);
9594 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9596 +static inline void __clr_vx_info(struct vx_info **vxp,
9597 + const char *_file, int _line, void *_here)
9599 + struct vx_info *vxo;
9601 + vxo = xchg(vxp, NULL);
9605 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9606 + vxo, vxo ? vxo->vx_id : 0,
9607 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9609 + __vxh_clr_vx_info(vxo, vxp, _here);
9611 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9612 + free_vx_info(vxo);
9616 +#define claim_vx_info(v, p) \
9617 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9619 +static inline void __claim_vx_info(struct vx_info *vxi,
9620 + struct task_struct *task,
9621 + const char *_file, int _line, void *_here)
9623 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9624 + vxi, vxi ? vxi->vx_id : 0,
9625 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9626 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9627 + task, _file, _line);
9628 + __vxh_claim_vx_info(vxi, task, _here);
9630 + atomic_inc(&vxi->vx_tasks);
9634 +extern void unhash_vx_info(struct vx_info *);
9636 +#define release_vx_info(v, p) \
9637 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9639 +static inline void __release_vx_info(struct vx_info *vxi,
9640 + struct task_struct *task,
9641 + const char *_file, int _line, void *_here)
9643 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9644 + vxi, vxi ? vxi->vx_id : 0,
9645 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9646 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9647 + task, _file, _line);
9648 + __vxh_release_vx_info(vxi, task, _here);
9652 + if (atomic_dec_and_test(&vxi->vx_tasks))
9653 + unhash_vx_info(vxi);
9657 +#define task_get_vx_info(p) \
9658 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9660 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9661 + const char *_file, int _line, void *_here)
9663 + struct vx_info *vxi;
9666 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9668 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9674 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9676 + if (waitqueue_active(&vxi->vx_wait))
9677 + wake_up_interruptible(&vxi->vx_wait);
9681 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9683 +static inline void __enter_vx_info(struct vx_info *vxi,
9684 + struct vx_info_save *vxis, const char *_file, int _line)
9686 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9687 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9688 + current->xid, current->vx_info, _file, _line);
9689 + vxis->vxi = xchg(¤t->vx_info, vxi);
9690 + vxis->xid = current->xid;
9691 + current->xid = vxi ? vxi->vx_id : 0;
9694 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9696 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9697 + const char *_file, int _line)
9699 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9700 + vxis, vxis->xid, vxis->vxi, current,
9701 + current->xid, current->vx_info, _file, _line);
9702 + (void)xchg(¤t->vx_info, vxis->vxi);
9703 + current->xid = vxis->xid;
9707 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9709 + vxis->vxi = xchg(¤t->vx_info, NULL);
9710 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9713 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9715 + (void)xchg(¤t->xid, vxis->xid);
9716 + (void)xchg(¤t->vx_info, vxis->vxi);
9719 +#define task_is_init(p) \
9720 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9722 +static inline int __task_is_init(struct task_struct *p,
9723 + const char *_file, int _line, void *_here)
9725 + int is_init = is_global_init(p);
9729 + is_init = p->vx_info->vx_initpid == p->pid;
9734 +extern void exit_vx_info(struct task_struct *, int);
9735 +extern void exit_vx_info_early(struct task_struct *, int);
9739 +#warning duplicate inclusion
9741 diff -NurpP --minimal linux-2.6.33/include/linux/vs_cowbl.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_cowbl.h
9742 --- linux-2.6.33/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9743 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_cowbl.h 2010-02-25 12:02:16.000000000 +0100
9745 +#ifndef _VS_COWBL_H
9746 +#define _VS_COWBL_H
9748 +#include <linux/fs.h>
9749 +#include <linux/dcache.h>
9750 +#include <linux/namei.h>
9752 +extern struct dentry *cow_break_link(const char *pathname);
9754 +static inline int cow_check_and_break(struct path *path)
9756 + struct inode *inode = path->dentry->d_inode;
9759 + /* do we need this check? */
9760 + if (IS_RDONLY(inode))
9763 + if (IS_COW(inode)) {
9764 + if (IS_COW_LINK(inode)) {
9765 + struct dentry *new_dentry, *old_dentry = path->dentry;
9768 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9772 + pp = d_path(path, buf, PATH_MAX);
9773 + new_dentry = cow_break_link(pp);
9775 + if (!IS_ERR(new_dentry)) {
9776 + path->dentry = new_dentry;
9779 + error = PTR_ERR(new_dentry);
9781 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9782 + inode->i_ctime = CURRENT_TIME;
9783 + mark_inode_dirty(inode);
9790 +#warning duplicate inclusion
9792 diff -NurpP --minimal linux-2.6.33/include/linux/vs_cvirt.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_cvirt.h
9793 --- linux-2.6.33/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9794 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_cvirt.h 2010-02-25 12:02:16.000000000 +0100
9796 +#ifndef _VS_CVIRT_H
9797 +#define _VS_CVIRT_H
9799 +#include "vserver/cvirt.h"
9800 +#include "vserver/context.h"
9801 +#include "vserver/base.h"
9802 +#include "vserver/check.h"
9803 +#include "vserver/debug.h"
9806 +static inline void vx_activate_task(struct task_struct *p)
9808 + struct vx_info *vxi;
9810 + if ((vxi = p->vx_info)) {
9811 + vx_update_load(vxi);
9812 + atomic_inc(&vxi->cvirt.nr_running);
9816 +static inline void vx_deactivate_task(struct task_struct *p)
9818 + struct vx_info *vxi;
9820 + if ((vxi = p->vx_info)) {
9821 + vx_update_load(vxi);
9822 + atomic_dec(&vxi->cvirt.nr_running);
9826 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9828 + struct vx_info *vxi;
9830 + if ((vxi = p->vx_info))
9831 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9834 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9836 + struct vx_info *vxi;
9838 + if ((vxi = p->vx_info))
9839 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9844 +#warning duplicate inclusion
9846 diff -NurpP --minimal linux-2.6.33/include/linux/vs_device.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_device.h
9847 --- linux-2.6.33/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9848 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_device.h 2010-02-25 12:02:16.000000000 +0100
9850 +#ifndef _VS_DEVICE_H
9851 +#define _VS_DEVICE_H
9853 +#include "vserver/base.h"
9854 +#include "vserver/device.h"
9855 +#include "vserver/debug.h"
9858 +#ifdef CONFIG_VSERVER_DEVICE
9860 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9862 +#define vs_device_perm(v, d, m, p) \
9863 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9868 +int vs_map_device(struct vx_info *vxi,
9869 + dev_t device, dev_t *target, umode_t mode)
9876 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9881 +#define vs_map_chrdev(d, t, p) \
9882 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9883 +#define vs_map_blkdev(d, t, p) \
9884 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9886 +#define vs_chrdev_perm(d, p) \
9887 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9888 +#define vs_blkdev_perm(d, p) \
9889 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9893 +#warning duplicate inclusion
9895 diff -NurpP --minimal linux-2.6.33/include/linux/vs_dlimit.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_dlimit.h
9896 --- linux-2.6.33/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9897 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_dlimit.h 2010-02-25 12:02:16.000000000 +0100
9899 +#ifndef _VS_DLIMIT_H
9900 +#define _VS_DLIMIT_H
9902 +#include <linux/fs.h>
9904 +#include "vserver/dlimit.h"
9905 +#include "vserver/base.h"
9906 +#include "vserver/debug.h"
9909 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9911 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9912 + const char *_file, int _line)
9916 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9917 + dli, dli ? dli->dl_tag : 0,
9918 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9920 + atomic_inc(&dli->dl_usecnt);
9925 +#define free_dl_info(i) \
9926 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9928 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9930 +static inline void __put_dl_info(struct dl_info *dli,
9931 + const char *_file, int _line)
9935 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9936 + dli, dli ? dli->dl_tag : 0,
9937 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9939 + if (atomic_dec_and_test(&dli->dl_usecnt))
9940 + free_dl_info(dli);
9944 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9946 +static inline int __dl_alloc_space(struct super_block *sb,
9947 + tag_t tag, dlsize_t nr, const char *file, int line)
9949 + struct dl_info *dli = NULL;
9954 + dli = locate_dl_info(sb, tag);
9958 + spin_lock(&dli->dl_lock);
9959 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9961 + dli->dl_space_used += nr;
9962 + spin_unlock(&dli->dl_lock);
9965 + vxlprintk(VXD_CBIT(dlim, 1),
9966 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9967 + sb, tag, __dlimit_char(dli), (long long)nr,
9972 +static inline void __dl_free_space(struct super_block *sb,
9973 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9975 + struct dl_info *dli = NULL;
9979 + dli = locate_dl_info(sb, tag);
9983 + spin_lock(&dli->dl_lock);
9984 + if (dli->dl_space_used > nr)
9985 + dli->dl_space_used -= nr;
9987 + dli->dl_space_used = 0;
9988 + spin_unlock(&dli->dl_lock);
9991 + vxlprintk(VXD_CBIT(dlim, 1),
9992 + "FREE (%p,#%d)%c %lld bytes",
9993 + sb, tag, __dlimit_char(dli), (long long)nr,
9997 +static inline int __dl_alloc_inode(struct super_block *sb,
9998 + tag_t tag, const char *_file, int _line)
10000 + struct dl_info *dli;
10003 + dli = locate_dl_info(sb, tag);
10007 + spin_lock(&dli->dl_lock);
10008 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
10010 + dli->dl_inodes_used++;
10011 + spin_unlock(&dli->dl_lock);
10012 + put_dl_info(dli);
10014 + vxlprintk(VXD_CBIT(dlim, 0),
10015 + "ALLOC (%p,#%d)%c inode (%d)",
10016 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10020 +static inline void __dl_free_inode(struct super_block *sb,
10021 + tag_t tag, const char *_file, int _line)
10023 + struct dl_info *dli;
10025 + dli = locate_dl_info(sb, tag);
10029 + spin_lock(&dli->dl_lock);
10030 + if (dli->dl_inodes_used > 1)
10031 + dli->dl_inodes_used--;
10033 + dli->dl_inodes_used = 0;
10034 + spin_unlock(&dli->dl_lock);
10035 + put_dl_info(dli);
10037 + vxlprintk(VXD_CBIT(dlim, 0),
10038 + "FREE (%p,#%d)%c inode",
10039 + sb, tag, __dlimit_char(dli), _file, _line);
10042 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10043 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10044 + const char *_file, int _line)
10046 + struct dl_info *dli;
10047 + uint64_t broot, bfree;
10049 + dli = locate_dl_info(sb, tag);
10053 + spin_lock(&dli->dl_lock);
10054 + broot = (dli->dl_space_total -
10055 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10056 + >> sb->s_blocksize_bits;
10057 + bfree = (dli->dl_space_total - dli->dl_space_used)
10058 + >> sb->s_blocksize_bits;
10059 + spin_unlock(&dli->dl_lock);
10061 + vxlprintk(VXD_CBIT(dlim, 2),
10062 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10063 + (long long)bfree, (long long)broot,
10064 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10066 + if (free_blocks) {
10067 + if (*free_blocks > bfree)
10068 + *free_blocks = bfree;
10070 + if (root_blocks) {
10071 + if (*root_blocks > broot)
10072 + *root_blocks = broot;
10074 + put_dl_info(dli);
10077 +#define dl_prealloc_space(in, bytes) \
10078 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10079 + __FILE__, __LINE__ )
10081 +#define dl_alloc_space(in, bytes) \
10082 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10083 + __FILE__, __LINE__ )
10085 +#define dl_reserve_space(in, bytes) \
10086 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10087 + __FILE__, __LINE__ )
10089 +#define dl_claim_space(in, bytes) (0)
10091 +#define dl_release_space(in, bytes) \
10092 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10093 + __FILE__, __LINE__ )
10095 +#define dl_free_space(in, bytes) \
10096 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10097 + __FILE__, __LINE__ )
10101 +#define dl_alloc_inode(in) \
10102 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10104 +#define dl_free_inode(in) \
10105 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10108 +#define dl_adjust_block(sb, tag, fb, rb) \
10109 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10113 +#warning duplicate inclusion
10115 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/base.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/base.h
10116 --- linux-2.6.33/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10117 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/base.h 2010-02-25 12:02:16.000000000 +0100
10119 +#ifndef _VX_BASE_H
10120 +#define _VX_BASE_H
10123 +/* context state changes */
10135 +#define vx_task_xid(t) ((t)->xid)
10137 +#define vx_current_xid() vx_task_xid(current)
10139 +#define current_vx_info() (current->vx_info)
10142 +#define nx_task_nid(t) ((t)->nid)
10144 +#define nx_current_nid() nx_task_nid(current)
10146 +#define current_nx_info() (current->nx_info)
10149 +/* generic flag merging */
10151 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10153 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10155 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10157 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10160 +/* context flags */
10162 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10164 +#define vx_current_flags() __vx_flags(current_vx_info())
10166 +#define vx_info_flags(v, m, f) \
10167 + vs_check_flags(__vx_flags(v), m, f)
10169 +#define task_vx_flags(t, m, f) \
10170 + ((t) && vx_info_flags((t)->vx_info, m, f))
10172 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10175 +/* context caps */
10177 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10179 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10181 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10183 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10187 +/* network flags */
10189 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10191 +#define nx_current_flags() __nx_flags(current_nx_info())
10193 +#define nx_info_flags(n, m, f) \
10194 + vs_check_flags(__nx_flags(n), m, f)
10196 +#define task_nx_flags(t, m, f) \
10197 + ((t) && nx_info_flags((t)->nx_info, m, f))
10199 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10202 +/* network caps */
10204 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10206 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10208 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10210 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10213 +/* context mask capabilities */
10215 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10217 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10219 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10222 +/* context bcap mask */
10224 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10226 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10229 +/* mask given bcaps */
10231 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10233 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10236 +/* masked cap_bset */
10238 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10240 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10243 +#define vx_info_mbcap(v, b) \
10244 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10245 + vx_info_bcaps(v, b) : (b))
10247 +#define task_vx_mbcap(t, b) \
10248 + vx_info_mbcap((t)->vx_info, (t)->b)
10250 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10253 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10255 +#define vx_capable(b, c) (capable(b) || \
10256 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10258 +#define nx_capable(b, c) (capable(b) || \
10259 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10261 +#define vx_task_initpid(t, n) \
10262 + ((t)->vx_info && \
10263 + ((t)->vx_info->vx_initpid == (n)))
10265 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10268 +/* context unshare mask */
10270 +#define __vx_umask(v) ((v)->vx_umask)
10272 +#define vx_current_umask() __vx_umask(current_vx_info())
10274 +#define vx_can_unshare(b, f) (capable(b) || \
10275 + (cap_raised(current_cap(), b) && \
10276 + !((f) & ~vx_current_umask())))
10279 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10281 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10284 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10286 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10289 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct_cmd.h
10290 --- linux-2.6.33/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10291 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct_cmd.h 2010-02-25 12:02:16.000000000 +0100
10293 +#ifndef _VX_CACCT_CMD_H
10294 +#define _VX_CACCT_CMD_H
10297 +/* virtual host info name commands */
10299 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10301 +struct vcmd_sock_stat_v0 {
10303 + uint32_t count[3];
10304 + uint64_t total[3];
10310 +#include <linux/compiler.h>
10312 +extern int vc_sock_stat(struct vx_info *, void __user *);
10314 +#endif /* __KERNEL__ */
10315 +#endif /* _VX_CACCT_CMD_H */
10316 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct_def.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct_def.h
10317 --- linux-2.6.33/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10318 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct_def.h 2010-02-25 12:02:16.000000000 +0100
10320 +#ifndef _VX_CACCT_DEF_H
10321 +#define _VX_CACCT_DEF_H
10323 +#include <asm/atomic.h>
10324 +#include <linux/vserver/cacct.h>
10327 +struct _vx_sock_acc {
10328 + atomic_long_t count;
10329 + atomic_long_t total;
10332 +/* context sub struct */
10334 +struct _vx_cacct {
10335 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10336 + atomic_t slab[8];
10337 + atomic_t page[6][8];
10340 +#ifdef CONFIG_VSERVER_DEBUG
10342 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10346 + printk("\t_vx_cacct:");
10347 + for (i = 0; i < 6; i++) {
10348 + struct _vx_sock_acc *ptr = cacct->sock[i];
10350 + printk("\t [%d] =", i);
10351 + for (j = 0; j < 3; j++) {
10352 + printk(" [%d] = %8lu, %8lu", j,
10353 + atomic_long_read(&ptr[j].count),
10354 + atomic_long_read(&ptr[j].total));
10362 +#endif /* _VX_CACCT_DEF_H */
10363 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct.h
10364 --- linux-2.6.33/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10365 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct.h 2010-02-25 12:02:16.000000000 +0100
10367 +#ifndef _VX_CACCT_H
10368 +#define _VX_CACCT_H
10371 +enum sock_acc_field {
10372 + VXA_SOCK_UNSPEC = 0,
10378 + VXA_SOCK_SIZE /* array size */
10381 +#endif /* _VX_CACCT_H */
10382 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct_int.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct_int.h
10383 --- linux-2.6.33/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10384 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cacct_int.h 2010-02-25 12:02:16.000000000 +0100
10386 +#ifndef _VX_CACCT_INT_H
10387 +#define _VX_CACCT_INT_H
10393 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10395 + return atomic_long_read(&cacct->sock[type][pos].count);
10400 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10402 + return atomic_long_read(&cacct->sock[type][pos].total);
10405 +#endif /* __KERNEL__ */
10406 +#endif /* _VX_CACCT_INT_H */
10407 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/check.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/check.h
10408 --- linux-2.6.33/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10409 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/check.h 2010-02-25 12:02:16.000000000 +0100
10411 +#ifndef _VS_CHECK_H
10412 +#define _VS_CHECK_H
10415 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10417 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10418 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10420 +#define MIN_D_CONTEXT 65536
10423 +/* check conditions */
10425 +#define VS_ADMIN 0x0001
10426 +#define VS_WATCH 0x0002
10427 +#define VS_HIDE 0x0004
10428 +#define VS_HOSTID 0x0008
10430 +#define VS_IDENT 0x0010
10431 +#define VS_EQUIV 0x0020
10432 +#define VS_PARENT 0x0040
10433 +#define VS_CHILD 0x0080
10435 +#define VS_ARG_MASK 0x00F0
10437 +#define VS_DYNAMIC 0x0100
10438 +#define VS_STATIC 0x0200
10440 +#define VS_ATR_MASK 0x0F00
10442 +#ifdef CONFIG_VSERVER_PRIVACY
10443 +#define VS_ADMIN_P (0)
10444 +#define VS_WATCH_P (0)
10446 +#define VS_ADMIN_P VS_ADMIN
10447 +#define VS_WATCH_P VS_WATCH
10450 +#define VS_HARDIRQ 0x1000
10451 +#define VS_SOFTIRQ 0x2000
10452 +#define VS_IRQ 0x4000
10454 +#define VS_IRQ_MASK 0xF000
10456 +#include <linux/hardirq.h>
10459 + * check current context for ADMIN/WATCH and
10460 + * optionally against supplied argument
10462 +static inline int __vs_check(int cid, int id, unsigned int mode)
10464 + if (mode & VS_ARG_MASK) {
10465 + if ((mode & VS_IDENT) && (id == cid))
10468 + if (mode & VS_ATR_MASK) {
10469 + if ((mode & VS_DYNAMIC) &&
10470 + (id >= MIN_D_CONTEXT) &&
10471 + (id <= MAX_S_CONTEXT))
10473 + if ((mode & VS_STATIC) &&
10474 + (id > 1) && (id < MIN_D_CONTEXT))
10477 + if (mode & VS_IRQ_MASK) {
10478 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10480 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10482 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10485 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10486 + ((mode & VS_WATCH) && (cid == 1)) ||
10487 + ((mode & VS_HOSTID) && (id == 0)));
10490 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10492 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10495 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10497 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10500 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/context_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/context_cmd.h
10501 --- linux-2.6.33/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10502 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/context_cmd.h 2010-02-25 12:02:16.000000000 +0100
10504 +#ifndef _VX_CONTEXT_CMD_H
10505 +#define _VX_CONTEXT_CMD_H
10508 +/* vinfo commands */
10510 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10513 +extern int vc_task_xid(uint32_t);
10515 +#endif /* __KERNEL__ */
10517 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10519 +struct vcmd_vx_info_v0 {
10521 + uint32_t initpid;
10522 + /* more to come */
10526 +extern int vc_vx_info(struct vx_info *, void __user *);
10528 +#endif /* __KERNEL__ */
10530 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10532 +struct vcmd_ctx_stat_v0 {
10535 + /* more to come */
10539 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10541 +#endif /* __KERNEL__ */
10543 +/* context commands */
10545 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10546 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10548 +struct vcmd_ctx_create {
10549 + uint64_t flagword;
10552 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10553 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10555 +struct vcmd_ctx_migrate {
10556 + uint64_t flagword;
10560 +extern int vc_ctx_create(uint32_t, void __user *);
10561 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10563 +#endif /* __KERNEL__ */
10566 +/* flag commands */
10568 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10569 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10571 +struct vcmd_ctx_flags_v0 {
10572 + uint64_t flagword;
10577 +extern int vc_get_cflags(struct vx_info *, void __user *);
10578 +extern int vc_set_cflags(struct vx_info *, void __user *);
10580 +#endif /* __KERNEL__ */
10583 +/* context caps commands */
10585 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10586 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10588 +struct vcmd_ctx_caps_v1 {
10594 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10595 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10597 +#endif /* __KERNEL__ */
10600 +/* bcaps commands */
10602 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10603 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10605 +struct vcmd_bcaps {
10611 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10612 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10614 +#endif /* __KERNEL__ */
10617 +/* umask commands */
10619 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10620 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10622 +struct vcmd_umask {
10628 +extern int vc_get_umask(struct vx_info *, void __user *);
10629 +extern int vc_set_umask(struct vx_info *, void __user *);
10631 +#endif /* __KERNEL__ */
10636 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10637 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10639 +struct vcmd_badness_v0 {
10644 +extern int vc_get_badness(struct vx_info *, void __user *);
10645 +extern int vc_set_badness(struct vx_info *, void __user *);
10647 +#endif /* __KERNEL__ */
10648 +#endif /* _VX_CONTEXT_CMD_H */
10649 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/context.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/context.h
10650 --- linux-2.6.33/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10651 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/context.h 2010-02-25 12:02:16.000000000 +0100
10653 +#ifndef _VX_CONTEXT_H
10654 +#define _VX_CONTEXT_H
10656 +#include <linux/types.h>
10657 +#include <linux/capability.h>
10660 +/* context flags */
10662 +#define VXF_INFO_SCHED 0x00000002
10663 +#define VXF_INFO_NPROC 0x00000004
10664 +#define VXF_INFO_PRIVATE 0x00000008
10666 +#define VXF_INFO_INIT 0x00000010
10667 +#define VXF_INFO_HIDE 0x00000020
10668 +#define VXF_INFO_ULIMIT 0x00000040
10669 +#define VXF_INFO_NSPACE 0x00000080
10671 +#define VXF_SCHED_HARD 0x00000100
10672 +#define VXF_SCHED_PRIO 0x00000200
10673 +#define VXF_SCHED_PAUSE 0x00000400
10675 +#define VXF_VIRT_MEM 0x00010000
10676 +#define VXF_VIRT_UPTIME 0x00020000
10677 +#define VXF_VIRT_CPU 0x00040000
10678 +#define VXF_VIRT_LOAD 0x00080000
10679 +#define VXF_VIRT_TIME 0x00100000
10681 +#define VXF_HIDE_MOUNT 0x01000000
10682 +/* was VXF_HIDE_NETIF 0x02000000 */
10683 +#define VXF_HIDE_VINFO 0x04000000
10685 +#define VXF_STATE_SETUP (1ULL << 32)
10686 +#define VXF_STATE_INIT (1ULL << 33)
10687 +#define VXF_STATE_ADMIN (1ULL << 34)
10689 +#define VXF_SC_HELPER (1ULL << 36)
10690 +#define VXF_REBOOT_KILL (1ULL << 37)
10691 +#define VXF_PERSISTENT (1ULL << 38)
10693 +#define VXF_FORK_RSS (1ULL << 48)
10694 +#define VXF_PROLIFIC (1ULL << 49)
10696 +#define VXF_IGNEG_NICE (1ULL << 52)
10698 +#define VXF_ONE_TIME (0x0007ULL << 32)
10700 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10703 +/* context migration */
10705 +#define VXM_SET_INIT 0x00000001
10706 +#define VXM_SET_REAPER 0x00000002
10708 +/* context caps */
10710 +#define VXC_CAP_MASK 0x00000000
10712 +#define VXC_SET_UTSNAME 0x00000001
10713 +#define VXC_SET_RLIMIT 0x00000002
10714 +#define VXC_FS_SECURITY 0x00000004
10715 +#define VXC_TIOCSTI 0x00000010
10717 +/* was VXC_RAW_ICMP 0x00000100 */
10718 +#define VXC_SYSLOG 0x00001000
10719 +#define VXC_OOM_ADJUST 0x00002000
10720 +#define VXC_AUDIT_CONTROL 0x00004000
10722 +#define VXC_SECURE_MOUNT 0x00010000
10723 +#define VXC_SECURE_REMOUNT 0x00020000
10724 +#define VXC_BINARY_MOUNT 0x00040000
10726 +#define VXC_QUOTA_CTL 0x00100000
10727 +#define VXC_ADMIN_MAPPER 0x00200000
10728 +#define VXC_ADMIN_CLOOP 0x00400000
10730 +#define VXC_KTHREAD 0x01000000
10731 +#define VXC_NAMESPACE 0x02000000
10736 +#include <linux/list.h>
10737 +#include <linux/spinlock.h>
10738 +#include <linux/rcupdate.h>
10740 +#include "limit_def.h"
10741 +#include "sched_def.h"
10742 +#include "cvirt_def.h"
10743 +#include "cacct_def.h"
10744 +#include "device_def.h"
10746 +#define VX_SPACES 2
10748 +struct _vx_info_pc {
10749 + struct _vx_sched_pc sched_pc;
10750 + struct _vx_cvirt_pc cvirt_pc;
10754 + struct hlist_node vx_hlist; /* linked list of contexts */
10755 + xid_t vx_id; /* context id */
10756 + atomic_t vx_usecnt; /* usage count */
10757 + atomic_t vx_tasks; /* tasks count */
10758 + struct vx_info *vx_parent; /* parent context */
10759 + int vx_state; /* context state */
10761 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10762 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10763 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
10765 + uint64_t vx_flags; /* context flags */
10766 + uint64_t vx_ccaps; /* context caps (vserver) */
10767 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10768 + unsigned long vx_umask; /* unshare mask (guest) */
10770 + struct task_struct *vx_reaper; /* guest reaper process */
10771 + pid_t vx_initpid; /* PID of guest init */
10772 + int64_t vx_badness_bias; /* OOM points bias */
10774 + struct _vx_limit limit; /* vserver limits */
10775 + struct _vx_sched sched; /* vserver scheduler */
10776 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10777 + struct _vx_cacct cacct; /* context accounting */
10779 + struct _vx_device dmap; /* default device map targets */
10781 +#ifndef CONFIG_SMP
10782 + struct _vx_info_pc info_pc; /* per cpu data */
10784 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10787 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10788 + int reboot_cmd; /* last sys_reboot() cmd */
10789 + int exit_code; /* last process exit code */
10791 + char vx_name[65]; /* vserver name */
10794 +#ifndef CONFIG_SMP
10795 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10796 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10798 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10799 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10802 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10805 +struct vx_info_save {
10806 + struct vx_info *vxi;
10811 +/* status flags */
10813 +#define VXS_HASHED 0x0001
10814 +#define VXS_PAUSED 0x0010
10815 +#define VXS_SHUTDOWN 0x0100
10816 +#define VXS_HELPER 0x1000
10817 +#define VXS_RELEASED 0x8000
10820 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10821 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10823 +extern struct vx_info *lookup_vx_info(int);
10824 +extern struct vx_info *lookup_or_create_vx_info(int);
10826 +extern int get_xid_list(int, unsigned int *, int);
10827 +extern int xid_is_hashed(xid_t);
10829 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10831 +extern long vs_state_change(struct vx_info *, unsigned int);
10834 +#endif /* __KERNEL__ */
10835 +#endif /* _VX_CONTEXT_H */
10836 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cvirt_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cvirt_cmd.h
10837 --- linux-2.6.33/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10838 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cvirt_cmd.h 2010-02-25 12:02:16.000000000 +0100
10840 +#ifndef _VX_CVIRT_CMD_H
10841 +#define _VX_CVIRT_CMD_H
10844 +/* virtual host info name commands */
10846 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10847 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10849 +struct vcmd_vhi_name_v0 {
10855 +enum vhi_name_field {
10856 + VHIN_CONTEXT = 0,
10868 +#include <linux/compiler.h>
10870 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10871 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10873 +#endif /* __KERNEL__ */
10875 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10877 +struct vcmd_virt_stat_v0 {
10880 + uint32_t nr_threads;
10881 + uint32_t nr_running;
10882 + uint32_t nr_uninterruptible;
10883 + uint32_t nr_onhold;
10884 + uint32_t nr_forks;
10885 + uint32_t load[3];
10889 +extern int vc_virt_stat(struct vx_info *, void __user *);
10891 +#endif /* __KERNEL__ */
10892 +#endif /* _VX_CVIRT_CMD_H */
10893 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cvirt_def.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cvirt_def.h
10894 --- linux-2.6.33/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10895 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cvirt_def.h 2010-02-25 12:02:16.000000000 +0100
10897 +#ifndef _VX_CVIRT_DEF_H
10898 +#define _VX_CVIRT_DEF_H
10900 +#include <linux/jiffies.h>
10901 +#include <linux/spinlock.h>
10902 +#include <linux/wait.h>
10903 +#include <linux/time.h>
10904 +#include <asm/atomic.h>
10907 +struct _vx_usage_stat {
10911 + uint64_t softirq;
10917 +struct _vx_syslog {
10918 + wait_queue_head_t log_wait;
10919 + spinlock_t logbuf_lock; /* lock for the log buffer */
10921 + unsigned long log_start; /* next char to be read by syslog() */
10922 + unsigned long con_start; /* next char to be sent to consoles */
10923 + unsigned long log_end; /* most-recently-written-char + 1 */
10924 + unsigned long logged_chars; /* #chars since last read+clear operation */
10926 + char log_buf[1024];
10930 +/* context sub struct */
10932 +struct _vx_cvirt {
10933 + atomic_t nr_threads; /* number of current threads */
10934 + atomic_t nr_running; /* number of running threads */
10935 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10937 + atomic_t nr_onhold; /* processes on hold */
10938 + uint32_t onhold_last; /* jiffies when put on hold */
10940 + struct timeval bias_tv; /* time offset to the host */
10941 + struct timespec bias_idle;
10942 + struct timespec bias_uptime; /* context creation point */
10943 + uint64_t bias_clock; /* offset in clock_t */
10945 + spinlock_t load_lock; /* lock for the load averages */
10946 + atomic_t load_updates; /* nr of load updates done so far */
10947 + uint32_t load_last; /* last time load was calculated */
10948 + uint32_t load[3]; /* load averages 1,5,15 */
10950 + atomic_t total_forks; /* number of forks so far */
10952 + struct _vx_syslog syslog;
10955 +struct _vx_cvirt_pc {
10956 + struct _vx_usage_stat cpustat;
10960 +#ifdef CONFIG_VSERVER_DEBUG
10962 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10964 + printk("\t_vx_cvirt:\n");
10965 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10966 + atomic_read(&cvirt->nr_threads),
10967 + atomic_read(&cvirt->nr_running),
10968 + atomic_read(&cvirt->nr_uninterruptible),
10969 + atomic_read(&cvirt->nr_onhold));
10970 + /* add rest here */
10971 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10976 +#endif /* _VX_CVIRT_DEF_H */
10977 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cvirt.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cvirt.h
10978 --- linux-2.6.33/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
10979 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/cvirt.h 2010-02-25 12:02:16.000000000 +0100
10981 +#ifndef _VX_CVIRT_H
10982 +#define _VX_CVIRT_H
10989 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10994 +void vx_update_load(struct vx_info *);
10997 +int vx_do_syslog(int, char __user *, int);
10999 +#endif /* __KERNEL__ */
11000 +#endif /* _VX_CVIRT_H */
11001 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/debug_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/debug_cmd.h
11002 --- linux-2.6.33/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11003 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/debug_cmd.h 2010-02-25 12:02:16.000000000 +0100
11005 +#ifndef _VX_DEBUG_CMD_H
11006 +#define _VX_DEBUG_CMD_H
11009 +/* debug commands */
11011 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11013 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11014 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11016 +struct vcmd_read_history_v0 {
11019 + char __user *data;
11022 +struct vcmd_read_monitor_v0 {
11025 + char __user *data;
11031 +#ifdef CONFIG_COMPAT
11033 +#include <asm/compat.h>
11035 +struct vcmd_read_history_v0_x32 {
11038 + compat_uptr_t data_ptr;
11041 +struct vcmd_read_monitor_v0_x32 {
11044 + compat_uptr_t data_ptr;
11047 +#endif /* CONFIG_COMPAT */
11049 +extern int vc_dump_history(uint32_t);
11051 +extern int vc_read_history(uint32_t, void __user *);
11052 +extern int vc_read_monitor(uint32_t, void __user *);
11054 +#ifdef CONFIG_COMPAT
11056 +extern int vc_read_history_x32(uint32_t, void __user *);
11057 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11059 +#endif /* CONFIG_COMPAT */
11061 +#endif /* __KERNEL__ */
11062 +#endif /* _VX_DEBUG_CMD_H */
11063 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/debug.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/debug.h
11064 --- linux-2.6.33/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11065 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/debug.h 2010-02-25 12:02:16.000000000 +0100
11067 +#ifndef _VX_DEBUG_H
11068 +#define _VX_DEBUG_H
11071 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11072 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11073 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11075 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11076 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11077 +#define VXF_DEV "%p[%lu,%d:%d]"
11080 +#define vxd_path(p) \
11081 + ({ static char _buffer[PATH_MAX]; \
11082 + d_path(p, _buffer, sizeof(_buffer)); })
11084 +#define vxd_cond_path(n) \
11085 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11088 +#ifdef CONFIG_VSERVER_DEBUG
11090 +extern unsigned int vx_debug_switch;
11091 +extern unsigned int vx_debug_xid;
11092 +extern unsigned int vx_debug_nid;
11093 +extern unsigned int vx_debug_tag;
11094 +extern unsigned int vx_debug_net;
11095 +extern unsigned int vx_debug_limit;
11096 +extern unsigned int vx_debug_cres;
11097 +extern unsigned int vx_debug_dlim;
11098 +extern unsigned int vx_debug_quota;
11099 +extern unsigned int vx_debug_cvirt;
11100 +extern unsigned int vx_debug_space;
11101 +extern unsigned int vx_debug_misc;
11104 +#define VX_LOGLEVEL "vxD: "
11105 +#define VX_PROC_FMT "%p: "
11106 +#define VX_PROCESS current
11108 +#define vxdprintk(c, f, x...) \
11111 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11112 + VX_PROCESS , ##x); \
11115 +#define vxlprintk(c, f, x...) \
11118 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11121 +#define vxfprintk(c, f, x...) \
11124 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11130 +void dump_vx_info(struct vx_info *, int);
11131 +void dump_vx_info_inactive(int);
11133 +#else /* CONFIG_VSERVER_DEBUG */
11135 +#define vx_debug_switch 0
11136 +#define vx_debug_xid 0
11137 +#define vx_debug_nid 0
11138 +#define vx_debug_tag 0
11139 +#define vx_debug_net 0
11140 +#define vx_debug_limit 0
11141 +#define vx_debug_cres 0
11142 +#define vx_debug_dlim 0
11143 +#define vx_debug_cvirt 0
11145 +#define vxdprintk(x...) do { } while (0)
11146 +#define vxlprintk(x...) do { } while (0)
11147 +#define vxfprintk(x...) do { } while (0)
11149 +#endif /* CONFIG_VSERVER_DEBUG */
11152 +#ifdef CONFIG_VSERVER_WARN
11154 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11155 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11156 +#define VX_WARN_XID "[xid #%u] "
11157 +#define VX_WARN_NID "[nid #%u] "
11158 +#define VX_WARN_TAG "[tag #%u] "
11160 +#define vxwprintk(c, f, x...) \
11163 + printk(VX_WARNLEVEL f "\n", ##x); \
11166 +#else /* CONFIG_VSERVER_WARN */
11168 +#define vxwprintk(x...) do { } while (0)
11170 +#endif /* CONFIG_VSERVER_WARN */
11172 +#define vxwprintk_task(c, f, x...) \
11173 + vxwprintk(c, VX_WARN_TASK f, \
11174 + current->comm, current->pid, \
11175 + current->xid, current->nid, current->tag, ##x)
11176 +#define vxwprintk_xid(c, f, x...) \
11177 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11178 +#define vxwprintk_nid(c, f, x...) \
11179 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11180 +#define vxwprintk_tag(c, f, x...) \
11181 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11183 +#ifdef CONFIG_VSERVER_DEBUG
11184 +#define vxd_assert_lock(l) assert_spin_locked(l)
11185 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11186 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11188 +#define vxd_assert_lock(l) do { } while (0)
11189 +#define vxd_assert(c, f, x...) do { } while (0)
11193 +#endif /* _VX_DEBUG_H */
11194 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/device_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/device_cmd.h
11195 --- linux-2.6.33/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11196 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/device_cmd.h 2010-02-25 12:02:16.000000000 +0100
11198 +#ifndef _VX_DEVICE_CMD_H
11199 +#define _VX_DEVICE_CMD_H
11202 +/* device vserver commands */
11204 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11205 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11207 +struct vcmd_set_mapping_v0 {
11208 + const char __user *device;
11209 + const char __user *target;
11216 +#ifdef CONFIG_COMPAT
11218 +#include <asm/compat.h>
11220 +struct vcmd_set_mapping_v0_x32 {
11221 + compat_uptr_t device_ptr;
11222 + compat_uptr_t target_ptr;
11226 +#endif /* CONFIG_COMPAT */
11228 +#include <linux/compiler.h>
11230 +extern int vc_set_mapping(struct vx_info *, void __user *);
11231 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11233 +#ifdef CONFIG_COMPAT
11235 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11236 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11238 +#endif /* CONFIG_COMPAT */
11240 +#endif /* __KERNEL__ */
11241 +#endif /* _VX_DEVICE_CMD_H */
11242 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/device_def.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/device_def.h
11243 --- linux-2.6.33/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11244 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/device_def.h 2010-02-25 12:02:16.000000000 +0100
11246 +#ifndef _VX_DEVICE_DEF_H
11247 +#define _VX_DEVICE_DEF_H
11249 +#include <linux/types.h>
11251 +struct vx_dmap_target {
11256 +struct _vx_device {
11257 +#ifdef CONFIG_VSERVER_DEVICE
11258 + struct vx_dmap_target targets[2];
11262 +#endif /* _VX_DEVICE_DEF_H */
11263 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/device.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/device.h
11264 --- linux-2.6.33/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11265 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/device.h 2010-02-25 12:02:16.000000000 +0100
11267 +#ifndef _VX_DEVICE_H
11268 +#define _VX_DEVICE_H
11271 +#define DATTR_CREATE 0x00000001
11272 +#define DATTR_OPEN 0x00000002
11274 +#define DATTR_REMAP 0x00000010
11276 +#define DATTR_MASK 0x00000013
11279 +#else /* _VX_DEVICE_H */
11280 +#warning duplicate inclusion
11281 +#endif /* _VX_DEVICE_H */
11282 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/dlimit_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/dlimit_cmd.h
11283 --- linux-2.6.33/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11284 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/dlimit_cmd.h 2010-02-25 12:02:16.000000000 +0100
11286 +#ifndef _VX_DLIMIT_CMD_H
11287 +#define _VX_DLIMIT_CMD_H
11290 +/* dlimit vserver commands */
11292 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11293 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11295 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11296 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11298 +struct vcmd_ctx_dlimit_base_v0 {
11299 + const char __user *name;
11303 +struct vcmd_ctx_dlimit_v0 {
11304 + const char __user *name;
11305 + uint32_t space_used; /* used space in kbytes */
11306 + uint32_t space_total; /* maximum space in kbytes */
11307 + uint32_t inodes_used; /* used inodes */
11308 + uint32_t inodes_total; /* maximum inodes */
11309 + uint32_t reserved; /* reserved for root in % */
11313 +#define CDLIM_UNSET ((uint32_t)0UL)
11314 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11315 +#define CDLIM_KEEP ((uint32_t)~1UL)
11317 +#define DLIME_UNIT 0
11318 +#define DLIME_KILO 1
11319 +#define DLIME_MEGA 2
11320 +#define DLIME_GIGA 3
11322 +#define DLIMF_SHIFT 0x10
11324 +#define DLIMS_USED 0
11325 +#define DLIMS_TOTAL 2
11328 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11330 + int exp = (flags & DLIMF_SHIFT) ?
11331 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11332 + return ((uint64_t)val) << (10 * exp);
11336 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11340 + if (*flags & DLIMF_SHIFT) {
11341 + while (val > (1LL << 32) && (exp < 3)) {
11345 + *flags &= ~(DLIME_GIGA << shift);
11346 + *flags |= exp << shift;
11354 +#ifdef CONFIG_COMPAT
11356 +#include <asm/compat.h>
11358 +struct vcmd_ctx_dlimit_base_v0_x32 {
11359 + compat_uptr_t name_ptr;
11363 +struct vcmd_ctx_dlimit_v0_x32 {
11364 + compat_uptr_t name_ptr;
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 +#endif /* CONFIG_COMPAT */
11375 +#include <linux/compiler.h>
11377 +extern int vc_add_dlimit(uint32_t, void __user *);
11378 +extern int vc_rem_dlimit(uint32_t, void __user *);
11380 +extern int vc_set_dlimit(uint32_t, void __user *);
11381 +extern int vc_get_dlimit(uint32_t, void __user *);
11383 +#ifdef CONFIG_COMPAT
11385 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11386 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11388 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11389 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11391 +#endif /* CONFIG_COMPAT */
11393 +#endif /* __KERNEL__ */
11394 +#endif /* _VX_DLIMIT_CMD_H */
11395 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/dlimit.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/dlimit.h
11396 --- linux-2.6.33/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11397 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/dlimit.h 2010-02-25 12:02:16.000000000 +0100
11399 +#ifndef _VX_DLIMIT_H
11400 +#define _VX_DLIMIT_H
11402 +#include "switch.h"
11407 +/* keep in sync with CDLIM_INFINITY */
11409 +#define DLIM_INFINITY (~0ULL)
11411 +#include <linux/spinlock.h>
11412 +#include <linux/rcupdate.h>
11414 +struct super_block;
11417 + struct hlist_node dl_hlist; /* linked list of contexts */
11418 + struct rcu_head dl_rcu; /* the rcu head */
11419 + tag_t dl_tag; /* context tag */
11420 + atomic_t dl_usecnt; /* usage count */
11421 + atomic_t dl_refcnt; /* reference count */
11423 + struct super_block *dl_sb; /* associated superblock */
11425 + spinlock_t dl_lock; /* protect the values */
11427 + unsigned long long dl_space_used; /* used space in bytes */
11428 + unsigned long long dl_space_total; /* maximum space in bytes */
11429 + unsigned long dl_inodes_used; /* used inodes */
11430 + unsigned long dl_inodes_total; /* maximum inodes */
11432 + unsigned int dl_nrlmult; /* non root limit mult */
11437 +extern void rcu_free_dl_info(struct rcu_head *);
11438 +extern void unhash_dl_info(struct dl_info *);
11440 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11445 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11447 +typedef uint64_t dlsize_t;
11449 +#endif /* __KERNEL__ */
11450 +#else /* _VX_DLIMIT_H */
11451 +#warning duplicate inclusion
11452 +#endif /* _VX_DLIMIT_H */
11453 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/global.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/global.h
11454 --- linux-2.6.33/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11455 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/global.h 2010-02-25 12:02:16.000000000 +0100
11457 +#ifndef _VX_GLOBAL_H
11458 +#define _VX_GLOBAL_H
11461 +extern atomic_t vx_global_ctotal;
11462 +extern atomic_t vx_global_cactive;
11464 +extern atomic_t nx_global_ctotal;
11465 +extern atomic_t nx_global_cactive;
11467 +extern atomic_t vs_global_nsproxy;
11468 +extern atomic_t vs_global_fs;
11469 +extern atomic_t vs_global_mnt_ns;
11470 +extern atomic_t vs_global_uts_ns;
11471 +extern atomic_t vs_global_user_ns;
11472 +extern atomic_t vs_global_pid_ns;
11475 +#endif /* _VX_GLOBAL_H */
11476 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/history.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/history.h
11477 --- linux-2.6.33/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11478 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/history.h 2010-02-25 12:02:16.000000000 +0100
11480 +#ifndef _VX_HISTORY_H
11481 +#define _VX_HISTORY_H
11486 + VXH_THROW_OOPS = 1,
11490 + VXH_INIT_VX_INFO,
11493 + VXH_CLAIM_VX_INFO,
11494 + VXH_RELEASE_VX_INFO,
11495 + VXH_ALLOC_VX_INFO,
11496 + VXH_DEALLOC_VX_INFO,
11497 + VXH_HASH_VX_INFO,
11498 + VXH_UNHASH_VX_INFO,
11500 + VXH_LOOKUP_VX_INFO,
11501 + VXH_CREATE_VX_INFO,
11504 +struct _vxhe_vxi {
11505 + struct vx_info *ptr;
11511 +struct _vxhe_set_clr {
11515 +struct _vxhe_loc_lookup {
11519 +struct _vx_hist_entry {
11521 + unsigned short seq;
11522 + unsigned short type;
11523 + struct _vxhe_vxi vxi;
11525 + struct _vxhe_set_clr sc;
11526 + struct _vxhe_loc_lookup ll;
11530 +#ifdef CONFIG_VSERVER_HISTORY
11532 +extern unsigned volatile int vxh_active;
11534 +struct _vx_hist_entry *vxh_advance(void *loc);
11538 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11540 + entry->vxi.ptr = vxi;
11542 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11543 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11544 + entry->vxi.xid = vxi->vx_id;
11549 +#define __HERE__ current_text_addr()
11551 +#define __VXH_BODY(__type, __data, __here) \
11552 + struct _vx_hist_entry *entry; \
11554 + preempt_disable(); \
11555 + entry = vxh_advance(__here); \
11557 + entry->type = __type; \
11558 + preempt_enable();
11561 + /* pass vxi only */
11563 +#define __VXH_SMPL \
11564 + __vxh_copy_vxi(entry, vxi)
11567 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11569 + __VXH_BODY(__type, __VXH_SMPL, __here)
11572 + /* pass vxi and data (void *) */
11574 +#define __VXH_DATA \
11575 + __vxh_copy_vxi(entry, vxi); \
11576 + entry->sc.data = data
11579 +void __vxh_data(struct vx_info *vxi, void *data,
11580 + int __type, void *__here)
11582 + __VXH_BODY(__type, __VXH_DATA, __here)
11585 + /* pass vxi and arg (long) */
11587 +#define __VXH_LONG \
11588 + __vxh_copy_vxi(entry, vxi); \
11589 + entry->ll.arg = arg
11592 +void __vxh_long(struct vx_info *vxi, long arg,
11593 + int __type, void *__here)
11595 + __VXH_BODY(__type, __VXH_LONG, __here)
11600 +void __vxh_throw_oops(void *__here)
11602 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11603 + /* prevent further acquisition */
11608 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11610 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11611 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11613 +#define __vxh_init_vx_info(v, d, h) \
11614 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11615 +#define __vxh_set_vx_info(v, d, h) \
11616 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11617 +#define __vxh_clr_vx_info(v, d, h) \
11618 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11620 +#define __vxh_claim_vx_info(v, d, h) \
11621 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11622 +#define __vxh_release_vx_info(v, d, h) \
11623 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11625 +#define vxh_alloc_vx_info(v) \
11626 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11627 +#define vxh_dealloc_vx_info(v) \
11628 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11630 +#define vxh_hash_vx_info(v) \
11631 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11632 +#define vxh_unhash_vx_info(v) \
11633 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11635 +#define vxh_loc_vx_info(v, l) \
11636 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11637 +#define vxh_lookup_vx_info(v, l) \
11638 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11639 +#define vxh_create_vx_info(v, l) \
11640 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11642 +extern void vxh_dump_history(void);
11645 +#else /* CONFIG_VSERVER_HISTORY */
11647 +#define __HERE__ 0
11649 +#define vxh_throw_oops() do { } while (0)
11651 +#define __vxh_get_vx_info(v, h) do { } while (0)
11652 +#define __vxh_put_vx_info(v, h) do { } while (0)
11654 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11655 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11656 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11658 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11659 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11661 +#define vxh_alloc_vx_info(v) do { } while (0)
11662 +#define vxh_dealloc_vx_info(v) do { } while (0)
11664 +#define vxh_hash_vx_info(v) do { } while (0)
11665 +#define vxh_unhash_vx_info(v) do { } while (0)
11667 +#define vxh_loc_vx_info(v, l) do { } while (0)
11668 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11669 +#define vxh_create_vx_info(v, l) do { } while (0)
11671 +#define vxh_dump_history() do { } while (0)
11674 +#endif /* CONFIG_VSERVER_HISTORY */
11676 +#endif /* _VX_HISTORY_H */
11677 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/inode_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/inode_cmd.h
11678 --- linux-2.6.33/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11679 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/inode_cmd.h 2010-02-25 12:02:16.000000000 +0100
11681 +#ifndef _VX_INODE_CMD_H
11682 +#define _VX_INODE_CMD_H
11685 +/* inode vserver commands */
11687 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11688 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11690 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11691 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11693 +struct vcmd_ctx_iattr_v1 {
11694 + const char __user *name;
11700 +struct vcmd_ctx_fiattr_v0 {
11710 +#ifdef CONFIG_COMPAT
11712 +#include <asm/compat.h>
11714 +struct vcmd_ctx_iattr_v1_x32 {
11715 + compat_uptr_t name_ptr;
11721 +#endif /* CONFIG_COMPAT */
11723 +#include <linux/compiler.h>
11725 +extern int vc_get_iattr(void __user *);
11726 +extern int vc_set_iattr(void __user *);
11728 +extern int vc_fget_iattr(uint32_t, void __user *);
11729 +extern int vc_fset_iattr(uint32_t, void __user *);
11731 +#ifdef CONFIG_COMPAT
11733 +extern int vc_get_iattr_x32(void __user *);
11734 +extern int vc_set_iattr_x32(void __user *);
11736 +#endif /* CONFIG_COMPAT */
11738 +#endif /* __KERNEL__ */
11739 +#endif /* _VX_INODE_CMD_H */
11740 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/inode.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/inode.h
11741 --- linux-2.6.33/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11742 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/inode.h 2010-02-25 12:02:16.000000000 +0100
11744 +#ifndef _VX_INODE_H
11745 +#define _VX_INODE_H
11748 +#define IATTR_TAG 0x01000000
11750 +#define IATTR_ADMIN 0x00000001
11751 +#define IATTR_WATCH 0x00000002
11752 +#define IATTR_HIDE 0x00000004
11753 +#define IATTR_FLAGS 0x00000007
11755 +#define IATTR_BARRIER 0x00010000
11756 +#define IATTR_IXUNLINK 0x00020000
11757 +#define IATTR_IMMUTABLE 0x00040000
11758 +#define IATTR_COW 0x00080000
11763 +#ifdef CONFIG_VSERVER_PROC_SECURE
11764 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11765 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11767 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11768 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11771 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11773 +#endif /* __KERNEL__ */
11775 +/* inode ioctls */
11777 +#define FIOC_GETXFLG _IOR('x', 5, long)
11778 +#define FIOC_SETXFLG _IOW('x', 6, long)
11780 +#else /* _VX_INODE_H */
11781 +#warning duplicate inclusion
11782 +#endif /* _VX_INODE_H */
11783 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/Kbuild linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/Kbuild
11784 --- linux-2.6.33/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11785 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/Kbuild 2010-02-25 12:02:16.000000000 +0100
11788 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11789 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11790 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11791 + debug_cmd.h device_cmd.h
11793 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11795 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit_cmd.h
11796 --- linux-2.6.33/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11797 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit_cmd.h 2010-02-25 12:02:16.000000000 +0100
11799 +#ifndef _VX_LIMIT_CMD_H
11800 +#define _VX_LIMIT_CMD_H
11803 +/* rlimit vserver commands */
11805 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11806 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11807 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11808 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
11809 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11811 +struct vcmd_ctx_rlimit_v0 {
11813 + uint64_t minimum;
11814 + uint64_t softlimit;
11815 + uint64_t maximum;
11818 +struct vcmd_ctx_rlimit_mask_v0 {
11819 + uint32_t minimum;
11820 + uint32_t softlimit;
11821 + uint32_t maximum;
11824 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11826 +struct vcmd_rlimit_stat_v0 {
11830 + uint64_t minimum;
11831 + uint64_t maximum;
11834 +#define CRLIM_UNSET (0ULL)
11835 +#define CRLIM_INFINITY (~0ULL)
11836 +#define CRLIM_KEEP (~1ULL)
11840 +#ifdef CONFIG_IA32_EMULATION
11842 +struct vcmd_ctx_rlimit_v0_x32 {
11844 + uint64_t minimum;
11845 + uint64_t softlimit;
11846 + uint64_t maximum;
11847 +} __attribute__ ((packed));
11849 +#endif /* CONFIG_IA32_EMULATION */
11851 +#include <linux/compiler.h>
11853 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11854 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11855 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11856 +extern int vc_reset_hits(struct vx_info *, void __user *);
11857 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11859 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11861 +#ifdef CONFIG_IA32_EMULATION
11863 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11864 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11866 +#endif /* CONFIG_IA32_EMULATION */
11868 +#endif /* __KERNEL__ */
11869 +#endif /* _VX_LIMIT_CMD_H */
11870 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit_def.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit_def.h
11871 --- linux-2.6.33/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11872 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit_def.h 2010-02-25 12:02:16.000000000 +0100
11874 +#ifndef _VX_LIMIT_DEF_H
11875 +#define _VX_LIMIT_DEF_H
11877 +#include <asm/atomic.h>
11878 +#include <asm/resource.h>
11880 +#include "limit.h"
11883 +struct _vx_res_limit {
11884 + rlim_t soft; /* Context soft limit */
11885 + rlim_t hard; /* Context hard limit */
11887 + rlim_atomic_t rcur; /* Current value */
11888 + rlim_t rmin; /* Context minimum */
11889 + rlim_t rmax; /* Context maximum */
11891 + atomic_t lhit; /* Limit hits */
11894 +/* context sub struct */
11896 +struct _vx_limit {
11897 + struct _vx_res_limit res[NUM_LIMITS];
11900 +#ifdef CONFIG_VSERVER_DEBUG
11902 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11906 + printk("\t_vx_limit:");
11907 + for (i = 0; i < NUM_LIMITS; i++) {
11908 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11909 + i, (unsigned long)__rlim_get(limit, i),
11910 + (unsigned long)__rlim_rmin(limit, i),
11911 + (unsigned long)__rlim_rmax(limit, i),
11912 + (long)__rlim_soft(limit, i),
11913 + (long)__rlim_hard(limit, i),
11914 + atomic_read(&__rlim_lhit(limit, i)));
11920 +#endif /* _VX_LIMIT_DEF_H */
11921 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit.h
11922 --- linux-2.6.33/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11923 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit.h 2010-02-25 12:02:16.000000000 +0100
11925 +#ifndef _VX_LIMIT_H
11926 +#define _VX_LIMIT_H
11928 +#define VLIMIT_NSOCK 16
11929 +#define VLIMIT_OPENFD 17
11930 +#define VLIMIT_ANON 18
11931 +#define VLIMIT_SHMEM 19
11932 +#define VLIMIT_SEMARY 20
11933 +#define VLIMIT_NSEMS 21
11934 +#define VLIMIT_DENTRY 22
11935 +#define VLIMIT_MAPPED 23
11940 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11942 +/* keep in sync with CRLIM_INFINITY */
11944 +#define VLIM_INFINITY (~0ULL)
11946 +#include <asm/atomic.h>
11947 +#include <asm/resource.h>
11949 +#ifndef RLIM_INFINITY
11950 +#warning RLIM_INFINITY is undefined
11953 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11955 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11956 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11958 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11959 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11960 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11962 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11963 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11965 +typedef atomic_long_t rlim_atomic_t;
11966 +typedef unsigned long rlim_t;
11968 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11969 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11970 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11971 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11972 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11973 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11976 +#if (RLIM_INFINITY == VLIM_INFINITY)
11977 +#define VX_VLIM(r) ((long long)(long)(r))
11978 +#define VX_RLIM(v) ((rlim_t)(v))
11980 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11981 + ? VLIM_INFINITY : (long long)(r))
11982 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11983 + ? RLIM_INFINITY : (rlim_t)(v))
11988 +void vx_vsi_meminfo(struct sysinfo *);
11989 +void vx_vsi_swapinfo(struct sysinfo *);
11990 +long vx_vsi_cached(struct sysinfo *);
11992 +#define NUM_LIMITS 24
11994 +#endif /* __KERNEL__ */
11995 +#endif /* _VX_LIMIT_H */
11996 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit_int.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit_int.h
11997 --- linux-2.6.33/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
11998 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/limit_int.h 2010-02-25 12:02:16.000000000 +0100
12000 +#ifndef _VX_LIMIT_INT_H
12001 +#define _VX_LIMIT_INT_H
12003 +#include "context.h"
12007 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12008 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12010 +extern const char *vlimit_name[NUM_LIMITS];
12012 +static inline void __vx_acc_cres(struct vx_info *vxi,
12013 + int res, int dir, void *_data, char *_file, int _line)
12015 + if (VXD_RCRES_COND(res))
12016 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12017 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12018 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12019 + (dir > 0) ? "++" : "--", _data, _file, _line);
12024 + __rlim_inc(&vxi->limit, res);
12026 + __rlim_dec(&vxi->limit, res);
12029 +static inline void __vx_add_cres(struct vx_info *vxi,
12030 + int res, int amount, void *_data, char *_file, int _line)
12032 + if (VXD_RCRES_COND(res))
12033 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12034 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12035 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12036 + amount, _data, _file, _line);
12041 + __rlim_add(&vxi->limit, res, amount);
12045 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12047 + int cond = (value > __rlim_rmax(limit, res));
12050 + __rlim_rmax(limit, res) = value;
12055 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12057 + int cond = (value < __rlim_rmin(limit, res));
12060 + __rlim_rmin(limit, res) = value;
12065 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12067 + if (!__vx_cres_adjust_max(limit, res, value))
12068 + __vx_cres_adjust_min(limit, res, value);
12073 + +1 ... no limit hit
12074 + -1 ... over soft limit
12075 + 0 ... over hard limit */
12077 +static inline int __vx_cres_avail(struct vx_info *vxi,
12078 + int res, int num, char *_file, int _line)
12080 + struct _vx_limit *limit;
12083 + if (VXD_RLIMIT_COND(res))
12084 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12085 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12086 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12087 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12088 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12089 + num, _file, _line);
12093 + limit = &vxi->limit;
12094 + value = __rlim_get(limit, res);
12096 + if (!__vx_cres_adjust_max(limit, res, value))
12097 + __vx_cres_adjust_min(limit, res, value);
12102 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12104 + if (value + num <= __rlim_soft(limit, res))
12107 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12109 + if (value + num <= __rlim_hard(limit, res))
12112 + __rlim_hit(limit, res);
12117 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12120 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12122 + rlim_t value, sum = 0;
12125 + while ((res = *array++)) {
12126 + value = __rlim_get(limit, res);
12127 + __vx_cres_fixup(limit, res, value);
12134 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12136 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12137 + int res = *array;
12139 + if (value == __rlim_get(limit, res))
12142 + __rlim_set(limit, res, value);
12143 + /* now adjust min/max */
12144 + if (!__vx_cres_adjust_max(limit, res, value))
12145 + __vx_cres_adjust_min(limit, res, value);
12150 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12151 + const int *array, int num, char *_file, int _line)
12153 + struct _vx_limit *limit;
12154 + rlim_t value = 0;
12162 + limit = &vxi->limit;
12164 + value = __vx_cres_array_sum(limit, array + 1);
12166 + __rlim_set(limit, res, value);
12167 + __vx_cres_fixup(limit, res, value);
12169 + return __vx_cres_avail(vxi, res, num, _file, _line);
12173 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12178 + /* complex resources first */
12179 + if ((id < 0) || (id == RLIMIT_RSS))
12180 + __vx_cres_array_fixup(limit, VLA_RSS);
12182 + for (res = 0; res < NUM_LIMITS; res++) {
12183 + if ((id > 0) && (res != id))
12186 + value = __rlim_get(limit, res);
12187 + __vx_cres_fixup(limit, res, value);
12189 + /* not supposed to happen, maybe warn? */
12190 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12191 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12196 +#endif /* __KERNEL__ */
12197 +#endif /* _VX_LIMIT_INT_H */
12198 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/monitor.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/monitor.h
12199 --- linux-2.6.33/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12200 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/monitor.h 2010-02-25 12:02:16.000000000 +0100
12202 +#ifndef _VX_MONITOR_H
12203 +#define _VX_MONITOR_H
12205 +#include <linux/types.h>
12212 + VXM_UPDATE = 0x20,
12216 + VXM_RQINFO_1 = 0x24,
12219 + VXM_ACTIVATE = 0x40,
12226 + VXM_MIGRATE = 0x48,
12229 + /* all other bits are flags */
12230 + VXM_SCHED = 0x80,
12233 +struct _vxm_update_1 {
12234 + uint32_t tokens_max;
12235 + uint32_t fill_rate;
12236 + uint32_t interval;
12239 +struct _vxm_update_2 {
12240 + uint32_t tokens_min;
12241 + uint32_t fill_rate;
12242 + uint32_t interval;
12245 +struct _vxm_rqinfo_1 {
12246 + uint16_t running;
12250 + uint32_t idle_tokens;
12253 +struct _vxm_rqinfo_2 {
12254 + uint32_t norm_time;
12255 + uint32_t idle_time;
12256 + uint32_t idle_skip;
12259 +struct _vxm_sched {
12261 + uint32_t norm_time;
12262 + uint32_t idle_time;
12265 +struct _vxm_task {
12270 +struct _vxm_event {
12279 + struct _vxm_task tsk;
12283 +struct _vx_mon_entry {
12287 + struct _vxm_event ev;
12288 + struct _vxm_sched sd;
12289 + struct _vxm_update_1 u1;
12290 + struct _vxm_update_2 u2;
12291 + struct _vxm_rqinfo_1 q1;
12292 + struct _vxm_rqinfo_2 q2;
12297 +#endif /* _VX_MONITOR_H */
12298 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/network_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/network_cmd.h
12299 --- linux-2.6.33/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12300 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/network_cmd.h 2010-02-25 12:02:16.000000000 +0100
12302 +#ifndef _VX_NETWORK_CMD_H
12303 +#define _VX_NETWORK_CMD_H
12306 +/* vinfo commands */
12308 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12311 +extern int vc_task_nid(uint32_t);
12313 +#endif /* __KERNEL__ */
12315 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12317 +struct vcmd_nx_info_v0 {
12319 + /* more to come */
12323 +extern int vc_nx_info(struct nx_info *, void __user *);
12325 +#endif /* __KERNEL__ */
12327 +#include <linux/in.h>
12328 +#include <linux/in6.h>
12330 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12331 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12333 +struct vcmd_net_create {
12334 + uint64_t flagword;
12337 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12339 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12340 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12342 +struct vcmd_net_addr_v0 {
12345 + struct in_addr ip[4];
12346 + struct in_addr mask[4];
12349 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12350 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12352 +struct vcmd_net_addr_ipv4_v1 {
12355 + struct in_addr ip;
12356 + struct in_addr mask;
12359 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12360 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12362 +struct vcmd_net_addr_ipv6_v1 {
12366 + struct in6_addr ip;
12367 + struct in6_addr mask;
12370 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12371 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12373 +struct vcmd_match_ipv4_v0 {
12378 + struct in_addr ip;
12379 + struct in_addr ip2;
12380 + struct in_addr mask;
12383 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12384 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12386 +struct vcmd_match_ipv6_v0 {
12391 + struct in6_addr ip;
12392 + struct in6_addr ip2;
12393 + struct in6_addr mask;
12398 +extern int vc_net_create(uint32_t, void __user *);
12399 +extern int vc_net_migrate(struct nx_info *, void __user *);
12401 +extern int vc_net_add(struct nx_info *, void __user *);
12402 +extern int vc_net_remove(struct nx_info *, void __user *);
12404 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12405 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12407 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12408 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12410 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12411 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12413 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12414 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12416 +#endif /* __KERNEL__ */
12419 +/* flag commands */
12421 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12422 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12424 +struct vcmd_net_flags_v0 {
12425 + uint64_t flagword;
12430 +extern int vc_get_nflags(struct nx_info *, void __user *);
12431 +extern int vc_set_nflags(struct nx_info *, void __user *);
12433 +#endif /* __KERNEL__ */
12436 +/* network caps commands */
12438 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12439 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12441 +struct vcmd_net_caps_v0 {
12447 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12448 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12450 +#endif /* __KERNEL__ */
12451 +#endif /* _VX_CONTEXT_CMD_H */
12452 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/network.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/network.h
12453 --- linux-2.6.33/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12454 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/network.h 2010-02-25 12:02:16.000000000 +0100
12456 +#ifndef _VX_NETWORK_H
12457 +#define _VX_NETWORK_H
12459 +#include <linux/types.h>
12462 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12465 +/* network flags */
12467 +#define NXF_INFO_PRIVATE 0x00000008
12469 +#define NXF_SINGLE_IP 0x00000100
12470 +#define NXF_LBACK_REMAP 0x00000200
12471 +#define NXF_LBACK_ALLOW 0x00000400
12473 +#define NXF_HIDE_NETIF 0x02000000
12474 +#define NXF_HIDE_LBACK 0x04000000
12476 +#define NXF_STATE_SETUP (1ULL << 32)
12477 +#define NXF_STATE_ADMIN (1ULL << 34)
12479 +#define NXF_SC_HELPER (1ULL << 36)
12480 +#define NXF_PERSISTENT (1ULL << 38)
12482 +#define NXF_ONE_TIME (0x0005ULL << 32)
12485 +#define NXF_INIT_SET (__nxf_init_set())
12487 +static inline uint64_t __nxf_init_set(void) {
12488 + return NXF_STATE_ADMIN
12489 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12490 + | NXF_LBACK_REMAP
12493 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12496 + | NXF_HIDE_NETIF;
12500 +/* network caps */
12502 +#define NXC_TUN_CREATE 0x00000001
12504 +#define NXC_RAW_ICMP 0x00000100
12507 +/* address types */
12509 +#define NXA_TYPE_IPV4 0x0001
12510 +#define NXA_TYPE_IPV6 0x0002
12512 +#define NXA_TYPE_NONE 0x0000
12513 +#define NXA_TYPE_ANY 0x00FF
12515 +#define NXA_TYPE_ADDR 0x0010
12516 +#define NXA_TYPE_MASK 0x0020
12517 +#define NXA_TYPE_RANGE 0x0040
12519 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12521 +#define NXA_MOD_BCAST 0x0100
12522 +#define NXA_MOD_LBACK 0x0200
12524 +#define NXA_LOOPBACK 0x1000
12526 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12527 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12531 +#include <linux/list.h>
12532 +#include <linux/spinlock.h>
12533 +#include <linux/rcupdate.h>
12534 +#include <linux/in.h>
12535 +#include <linux/in6.h>
12536 +#include <asm/atomic.h>
12538 +struct nx_addr_v4 {
12539 + struct nx_addr_v4 *next;
12540 + struct in_addr ip[2];
12541 + struct in_addr mask;
12546 +struct nx_addr_v6 {
12547 + struct nx_addr_v6 *next;
12548 + struct in6_addr ip;
12549 + struct in6_addr mask;
12556 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12557 + nid_t nx_id; /* vnet id */
12558 + atomic_t nx_usecnt; /* usage count */
12559 + atomic_t nx_tasks; /* tasks count */
12560 + int nx_state; /* context state */
12562 + uint64_t nx_flags; /* network flag word */
12563 + uint64_t nx_ncaps; /* network capabilities */
12565 + struct in_addr v4_lback; /* Loopback address */
12566 + struct in_addr v4_bcast; /* Broadcast address */
12567 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12568 +#ifdef CONFIG_IPV6
12569 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12571 + char nx_name[65]; /* network context name */
12575 +/* status flags */
12577 +#define NXS_HASHED 0x0001
12578 +#define NXS_SHUTDOWN 0x0100
12579 +#define NXS_RELEASED 0x8000
12581 +extern struct nx_info *lookup_nx_info(int);
12583 +extern int get_nid_list(int, unsigned int *, int);
12584 +extern int nid_is_hashed(nid_t);
12586 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12588 +extern long vs_net_change(struct nx_info *, unsigned int);
12593 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12594 +#ifdef CONFIG_IPV6
12595 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12597 +#define NX_IPV6(n) (0)
12600 +#endif /* __KERNEL__ */
12601 +#endif /* _VX_NETWORK_H */
12602 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/percpu.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/percpu.h
12603 --- linux-2.6.33/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12604 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/percpu.h 2010-02-25 12:02:16.000000000 +0100
12606 +#ifndef _VX_PERCPU_H
12607 +#define _VX_PERCPU_H
12609 +#include "cvirt_def.h"
12610 +#include "sched_def.h"
12612 +struct _vx_percpu {
12613 + struct _vx_cvirt_pc cvirt;
12614 + struct _vx_sched_pc sched;
12617 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12619 +#endif /* _VX_PERCPU_H */
12620 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/pid.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/pid.h
12621 --- linux-2.6.33/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12622 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/pid.h 2010-02-25 12:02:16.000000000 +0100
12624 +#ifndef _VSERVER_PID_H
12625 +#define _VSERVER_PID_H
12627 +/* pid faking stuff */
12629 +#define vx_info_map_pid(v, p) \
12630 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12631 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12632 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12633 +#define vx_map_tgid(p) vx_map_pid(p)
12635 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12636 + const char *func, const char *file, int line)
12638 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12639 + vxfprintk(VXD_CBIT(cvirt, 2),
12640 + "vx_map_tgid: %p/%llx: %d -> %d",
12641 + vxi, (long long)vxi->vx_flags, pid,
12642 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12643 + func, file, line);
12646 + if (pid == vxi->vx_initpid)
12652 +#define vx_info_rmap_pid(v, p) \
12653 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12654 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12655 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12657 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12658 + const char *func, const char *file, int line)
12660 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12661 + vxfprintk(VXD_CBIT(cvirt, 2),
12662 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12663 + vxi, (long long)vxi->vx_flags, pid,
12664 + (pid == 1) ? vxi->vx_initpid : pid,
12665 + func, file, line);
12666 + if ((pid == 1) && vxi->vx_initpid)
12667 + return vxi->vx_initpid;
12668 + if (pid == vxi->vx_initpid)
12675 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/sched_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/sched_cmd.h
12676 --- linux-2.6.33/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12677 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/sched_cmd.h 2010-02-25 12:02:16.000000000 +0100
12679 +#ifndef _VX_SCHED_CMD_H
12680 +#define _VX_SCHED_CMD_H
12683 +/* sched vserver commands */
12685 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12686 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12687 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12689 +struct vcmd_set_sched_v2 {
12690 + int32_t fill_rate;
12691 + int32_t interval;
12693 + int32_t tokens_min;
12694 + int32_t tokens_max;
12695 + uint64_t cpu_mask;
12698 +struct vcmd_set_sched_v3 {
12699 + uint32_t set_mask;
12700 + int32_t fill_rate;
12701 + int32_t interval;
12703 + int32_t tokens_min;
12704 + int32_t tokens_max;
12705 + int32_t priority_bias;
12708 +struct vcmd_set_sched_v4 {
12709 + uint32_t set_mask;
12710 + int32_t fill_rate;
12711 + int32_t interval;
12713 + int32_t tokens_min;
12714 + int32_t tokens_max;
12715 + int32_t prio_bias;
12717 + int32_t bucket_id;
12720 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12721 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12723 +struct vcmd_sched_v5 {
12726 + int32_t bucket_id;
12727 + int32_t fill_rate[2];
12728 + int32_t interval[2];
12730 + int32_t tokens_min;
12731 + int32_t tokens_max;
12732 + int32_t prio_bias;
12735 +#define VXSM_FILL_RATE 0x0001
12736 +#define VXSM_INTERVAL 0x0002
12737 +#define VXSM_FILL_RATE2 0x0004
12738 +#define VXSM_INTERVAL2 0x0008
12739 +#define VXSM_TOKENS 0x0010
12740 +#define VXSM_TOKENS_MIN 0x0020
12741 +#define VXSM_TOKENS_MAX 0x0040
12742 +#define VXSM_PRIO_BIAS 0x0100
12744 +#define VXSM_IDLE_TIME 0x0200
12745 +#define VXSM_FORCE 0x0400
12747 +#define VXSM_V3_MASK 0x0173
12748 +#define VXSM_SET_MASK 0x01FF
12750 +#define VXSM_CPU_ID 0x1000
12751 +#define VXSM_BUCKET_ID 0x2000
12753 +#define VXSM_MSEC 0x4000
12755 +#define SCHED_KEEP (-2) /* only for v2 */
12759 +#include <linux/compiler.h>
12761 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12762 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12763 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12764 +extern int vc_set_sched(struct vx_info *, void __user *);
12765 +extern int vc_get_sched(struct vx_info *, void __user *);
12767 +#endif /* __KERNEL__ */
12769 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12771 +struct vcmd_sched_info {
12773 + int32_t bucket_id;
12774 + uint64_t user_msec;
12775 + uint64_t sys_msec;
12776 + uint64_t hold_msec;
12777 + uint32_t token_usec;
12778 + int32_t vavavoom;
12783 +extern int vc_sched_info(struct vx_info *, void __user *);
12785 +#endif /* __KERNEL__ */
12786 +#endif /* _VX_SCHED_CMD_H */
12787 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/sched_def.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/sched_def.h
12788 --- linux-2.6.33/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12789 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/sched_def.h 2010-02-25 12:02:16.000000000 +0100
12791 +#ifndef _VX_SCHED_DEF_H
12792 +#define _VX_SCHED_DEF_H
12794 +#include <linux/spinlock.h>
12795 +#include <linux/jiffies.h>
12796 +#include <linux/cpumask.h>
12797 +#include <asm/atomic.h>
12798 +#include <asm/param.h>
12801 +/* context sub struct */
12803 +struct _vx_sched {
12804 + spinlock_t tokens_lock; /* lock for token bucket */
12806 + int tokens; /* number of CPU tokens */
12807 + int fill_rate[2]; /* Fill rate: add X tokens... */
12808 + int interval[2]; /* Divisor: per Y jiffies */
12809 + int tokens_min; /* Limit: minimum for unhold */
12810 + int tokens_max; /* Limit: no more than N tokens */
12812 + int prio_bias; /* bias offset for priority */
12814 + unsigned update_mask; /* which features should be updated */
12815 + cpumask_t update; /* CPUs which should update */
12818 +struct _vx_sched_pc {
12819 + int tokens; /* number of CPU tokens */
12820 + int flags; /* bucket flags */
12822 + int fill_rate[2]; /* Fill rate: add X tokens... */
12823 + int interval[2]; /* Divisor: per Y jiffies */
12824 + int tokens_min; /* Limit: minimum for unhold */
12825 + int tokens_max; /* Limit: no more than N tokens */
12827 + int prio_bias; /* bias offset for priority */
12828 + int vavavoom; /* last calculated vavavoom */
12830 + unsigned long norm_time; /* last time accounted */
12831 + unsigned long idle_time; /* non linear time for fair sched */
12832 + unsigned long token_time; /* token time for accounting */
12833 + unsigned long onhold; /* jiffies when put on hold */
12835 + uint64_t user_ticks; /* token tick events */
12836 + uint64_t sys_ticks; /* token tick events */
12837 + uint64_t hold_ticks; /* token ticks paused */
12841 +#define VXSF_ONHOLD 0x0001
12842 +#define VXSF_IDLE_TIME 0x0100
12844 +#ifdef CONFIG_VSERVER_DEBUG
12846 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12848 + printk("\t_vx_sched:\n");
12849 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12850 + sched->fill_rate[0], sched->interval[0],
12851 + sched->fill_rate[1], sched->interval[1],
12852 + sched->tokens_min, sched->tokens_max);
12853 + printk("\t priority = %4d\n", sched->prio_bias);
12858 +#endif /* _VX_SCHED_DEF_H */
12859 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/sched.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/sched.h
12860 --- linux-2.6.33/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12861 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/sched.h 2010-02-25 12:02:16.000000000 +0100
12863 +#ifndef _VX_SCHED_H
12864 +#define _VX_SCHED_H
12871 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12876 +void vx_update_load(struct vx_info *);
12879 +int vx_tokens_recalc(struct _vx_sched_pc *,
12880 + unsigned long *, unsigned long *, int [2]);
12882 +void vx_update_sched_param(struct _vx_sched *sched,
12883 + struct _vx_sched_pc *sched_pc);
12885 +#endif /* __KERNEL__ */
12886 +#else /* _VX_SCHED_H */
12887 +#warning duplicate inclusion
12888 +#endif /* _VX_SCHED_H */
12889 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/signal_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/signal_cmd.h
12890 --- linux-2.6.33/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12891 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/signal_cmd.h 2010-02-25 12:02:16.000000000 +0100
12893 +#ifndef _VX_SIGNAL_CMD_H
12894 +#define _VX_SIGNAL_CMD_H
12897 +/* signalling vserver commands */
12899 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12900 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12902 +struct vcmd_ctx_kill_v0 {
12907 +struct vcmd_wait_exit_v0 {
12908 + int32_t reboot_cmd;
12909 + int32_t exit_code;
12914 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12915 +extern int vc_wait_exit(struct vx_info *, void __user *);
12917 +#endif /* __KERNEL__ */
12919 +/* process alteration commands */
12921 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12922 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12924 +struct vcmd_pflags_v0 {
12925 + uint32_t flagword;
12931 +extern int vc_get_pflags(uint32_t pid, void __user *);
12932 +extern int vc_set_pflags(uint32_t pid, void __user *);
12934 +#endif /* __KERNEL__ */
12935 +#endif /* _VX_SIGNAL_CMD_H */
12936 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/signal.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/signal.h
12937 --- linux-2.6.33/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12938 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/signal.h 2010-02-25 12:02:16.000000000 +0100
12940 +#ifndef _VX_SIGNAL_H
12941 +#define _VX_SIGNAL_H
12948 +int vx_info_kill(struct vx_info *, int, int);
12950 +#endif /* __KERNEL__ */
12951 +#else /* _VX_SIGNAL_H */
12952 +#warning duplicate inclusion
12953 +#endif /* _VX_SIGNAL_H */
12954 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/space_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/space_cmd.h
12955 --- linux-2.6.33/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12956 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/space_cmd.h 2010-02-25 12:02:16.000000000 +0100
12958 +#ifndef _VX_SPACE_CMD_H
12959 +#define _VX_SPACE_CMD_H
12962 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12963 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
12964 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
12966 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12967 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
12968 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
12970 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12972 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
12973 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
12976 +struct vcmd_space_mask_v1 {
12980 +struct vcmd_space_mask_v2 {
12988 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12989 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12990 +extern int vc_enter_space(struct vx_info *, void __user *);
12991 +extern int vc_set_space(struct vx_info *, void __user *);
12992 +extern int vc_get_space_mask(void __user *, int);
12994 +#endif /* __KERNEL__ */
12995 +#endif /* _VX_SPACE_CMD_H */
12996 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/space.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/space.h
12997 --- linux-2.6.33/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
12998 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/space.h 2010-02-25 12:02:16.000000000 +0100
13000 +#ifndef _VX_SPACE_H
13001 +#define _VX_SPACE_H
13003 +#include <linux/types.h>
13007 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13009 +#else /* _VX_SPACE_H */
13010 +#warning duplicate inclusion
13011 +#endif /* _VX_SPACE_H */
13012 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/switch.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/switch.h
13013 --- linux-2.6.33/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13014 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/switch.h 2010-02-25 12:02:16.000000000 +0100
13016 +#ifndef _VX_SWITCH_H
13017 +#define _VX_SWITCH_H
13019 +#include <linux/types.h>
13022 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13023 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13024 +#define VC_VERSION(c) ((c) & 0xFFF)
13026 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13027 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13031 + Syscall Matrix V2.8
13033 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13034 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13035 + |INFO |SETUP | |MOVE | | | | | |
13036 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13037 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13038 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13039 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13040 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13041 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13042 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13043 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13044 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13045 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13046 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13047 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13048 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13049 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13050 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13051 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13052 + OTHER |VSTAT | | | | | | |VINFO | |
13053 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13054 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13055 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13056 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13057 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13058 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13059 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13060 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13064 +#define VC_CAT_VERSION 0
13066 +#define VC_CAT_VSETUP 1
13067 +#define VC_CAT_VHOST 2
13069 +#define VC_CAT_DEVICE 6
13071 +#define VC_CAT_VPROC 9
13072 +#define VC_CAT_PROCALT 10
13073 +#define VC_CAT_PROCMIG 11
13074 +#define VC_CAT_PROCTRL 12
13076 +#define VC_CAT_SCHED 14
13077 +#define VC_CAT_MEMCTRL 20
13079 +#define VC_CAT_VNET 25
13080 +#define VC_CAT_NETALT 26
13081 +#define VC_CAT_NETMIG 27
13082 +#define VC_CAT_NETCTRL 28
13084 +#define VC_CAT_TAGMIG 35
13085 +#define VC_CAT_DLIMIT 36
13086 +#define VC_CAT_INODE 38
13088 +#define VC_CAT_VSTAT 40
13089 +#define VC_CAT_VINFO 46
13090 +#define VC_CAT_EVENT 48
13092 +#define VC_CAT_FLAGS 52
13093 +#define VC_CAT_VSPACE 54
13094 +#define VC_CAT_DEBUG 56
13095 +#define VC_CAT_RLIMIT 60
13097 +#define VC_CAT_SYSTEST 61
13098 +#define VC_CAT_COMPAT 63
13100 +/* query version */
13102 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13103 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13108 +#include <linux/errno.h>
13110 +#endif /* __KERNEL__ */
13112 +#endif /* _VX_SWITCH_H */
13114 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/tag_cmd.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/tag_cmd.h
13115 --- linux-2.6.33/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13116 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/tag_cmd.h 2010-02-25 12:02:16.000000000 +0100
13118 +#ifndef _VX_TAG_CMD_H
13119 +#define _VX_TAG_CMD_H
13122 +/* vinfo commands */
13124 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13127 +extern int vc_task_tag(uint32_t);
13129 +#endif /* __KERNEL__ */
13131 +/* context commands */
13133 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13136 +extern int vc_tag_migrate(uint32_t);
13138 +#endif /* __KERNEL__ */
13139 +#endif /* _VX_TAG_CMD_H */
13140 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/tag.h linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/tag.h
13141 --- linux-2.6.33/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13142 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vserver/tag.h 2010-02-25 12:02:16.000000000 +0100
13147 +#include <linux/types.h>
13150 +#define DX_TAG(in) (IS_TAGGED(in))
13153 +#ifdef CONFIG_TAG_NFSD
13154 +#define DX_TAG_NFSD 1
13156 +#define DX_TAG_NFSD 0
13160 +#ifdef CONFIG_TAGGING_NONE
13162 +#define MAX_UID 0xFFFFFFFF
13163 +#define MAX_GID 0xFFFFFFFF
13165 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13167 +#define TAGINO_UID(cond, uid, tag) (uid)
13168 +#define TAGINO_GID(cond, gid, tag) (gid)
13173 +#ifdef CONFIG_TAGGING_GID16
13175 +#define MAX_UID 0xFFFFFFFF
13176 +#define MAX_GID 0x0000FFFF
13178 +#define INOTAG_TAG(cond, uid, gid, tag) \
13179 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13181 +#define TAGINO_UID(cond, uid, tag) (uid)
13182 +#define TAGINO_GID(cond, gid, tag) \
13183 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13188 +#ifdef CONFIG_TAGGING_ID24
13190 +#define MAX_UID 0x00FFFFFF
13191 +#define MAX_GID 0x00FFFFFF
13193 +#define INOTAG_TAG(cond, uid, gid, tag) \
13194 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13196 +#define TAGINO_UID(cond, uid, tag) \
13197 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13198 +#define TAGINO_GID(cond, gid, tag) \
13199 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13204 +#ifdef CONFIG_TAGGING_UID16
13206 +#define MAX_UID 0x0000FFFF
13207 +#define MAX_GID 0xFFFFFFFF
13209 +#define INOTAG_TAG(cond, uid, gid, tag) \
13210 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13212 +#define TAGINO_UID(cond, uid, tag) \
13213 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13214 +#define TAGINO_GID(cond, gid, tag) (gid)
13219 +#ifdef CONFIG_TAGGING_INTERN
13221 +#define MAX_UID 0xFFFFFFFF
13222 +#define MAX_GID 0xFFFFFFFF
13224 +#define INOTAG_TAG(cond, uid, gid, tag) \
13225 + ((cond) ? (tag) : 0)
13227 +#define TAGINO_UID(cond, uid, tag) (uid)
13228 +#define TAGINO_GID(cond, gid, tag) (gid)
13233 +#ifndef CONFIG_TAGGING_NONE
13234 +#define dx_current_fstag(sb) \
13235 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13237 +#define dx_current_fstag(sb) (0)
13240 +#ifndef CONFIG_TAGGING_INTERN
13241 +#define TAGINO_TAG(cond, tag) (0)
13243 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13246 +#define INOTAG_UID(cond, uid, gid) \
13247 + ((cond) ? ((uid) & MAX_UID) : (uid))
13248 +#define INOTAG_GID(cond, uid, gid) \
13249 + ((cond) ? ((gid) & MAX_GID) : (gid))
13252 +static inline uid_t dx_map_uid(uid_t uid)
13254 + if ((uid > MAX_UID) && (uid != -1))
13256 + return (uid & MAX_UID);
13259 +static inline gid_t dx_map_gid(gid_t gid)
13261 + if ((gid > MAX_GID) && (gid != -1))
13263 + return (gid & MAX_GID);
13271 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13273 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13274 + unsigned long *flags);
13276 +#ifdef CONFIG_PROPAGATE
13278 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13280 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13283 +#define dx_propagate_tag(n, i) do { } while (0)
13286 +#endif /* _DX_TAG_H */
13287 diff -NurpP --minimal linux-2.6.33/include/linux/vs_inet6.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_inet6.h
13288 --- linux-2.6.33/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13289 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_inet6.h 2010-02-25 14:47:08.000000000 +0100
13291 +#ifndef _VS_INET6_H
13292 +#define _VS_INET6_H
13294 +#include "vserver/base.h"
13295 +#include "vserver/network.h"
13296 +#include "vserver/debug.h"
13298 +#include <net/ipv6.h>
13300 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13301 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13304 +#ifdef CONFIG_IPV6
13307 +int v6_addr_match(struct nx_addr_v6 *nxa,
13308 + const struct in6_addr *addr, uint16_t mask)
13312 + switch (nxa->type & mask) {
13313 + case NXA_TYPE_MASK:
13314 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13316 + case NXA_TYPE_ADDR:
13317 + ret = ipv6_addr_equal(&nxa->ip, addr);
13319 + case NXA_TYPE_ANY:
13323 + vxdprintk(VXD_CBIT(net, 0),
13324 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13325 + nxa, NXAV6(nxa), addr, mask, ret);
13330 +int v6_addr_in_nx_info(struct nx_info *nxi,
13331 + const struct in6_addr *addr, uint16_t mask)
13333 + struct nx_addr_v6 *nxa;
13338 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13339 + if (v6_addr_match(nxa, addr, mask))
13343 + vxdprintk(VXD_CBIT(net, 0),
13344 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13345 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13350 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13352 + /* FIXME: needs full range checks */
13353 + return v6_addr_match(nxa, &addr->ip, mask);
13357 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13359 + struct nx_addr_v6 *ptr;
13361 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13362 + if (v6_nx_addr_match(ptr, nxa, mask))
13369 + * Check if a given address matches for a socket
13371 + * nxi: the socket's nx_info if any
13372 + * addr: to be verified address
13375 +int v6_sock_addr_match (
13376 + struct nx_info *nxi,
13377 + struct inet_sock *inet,
13378 + struct in6_addr *addr)
13380 + struct sock *sk = &inet->sk;
13381 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13383 + if (!ipv6_addr_any(addr) &&
13384 + ipv6_addr_equal(saddr, addr))
13386 + if (ipv6_addr_any(saddr))
13387 + return v6_addr_in_nx_info(nxi, addr, -1);
13392 + * check if address is covered by socket
13394 + * sk: the socket to check against
13395 + * addr: the address in question (must be != 0)
13399 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13401 + struct nx_info *nxi = sk->sk_nx_info;
13402 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13404 + vxdprintk(VXD_CBIT(net, 5),
13405 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13406 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13407 + (sk->sk_socket?sk->sk_socket->flags:0));
13409 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13410 + return v6_addr_match(nxa, saddr, -1);
13411 + } else if (nxi) { /* match against nx_info */
13412 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13413 + } else { /* unrestricted any socket */
13419 +/* inet related checks and helpers */
13423 +struct net_device;
13427 +#include <linux/netdevice.h>
13428 +#include <linux/inetdevice.h>
13429 +#include <net/inet_timewait_sock.h>
13432 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13433 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13434 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13439 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13445 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13449 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13451 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13452 + nxi, nxi ? nxi->nx_id : 0, ifa,
13453 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13455 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13457 + if (v6_ifa_in_nx_info(ifa, nxi))
13463 +struct nx_v6_sock_addr {
13464 + struct in6_addr saddr; /* Address used for validation */
13465 + struct in6_addr baddr; /* Address used for socket bind */
13469 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13470 + struct nx_v6_sock_addr *nsa)
13472 + // struct sock *sk = &inet->sk;
13473 + // struct nx_info *nxi = sk->sk_nx_info;
13474 + struct in6_addr saddr = addr->sin6_addr;
13475 + struct in6_addr baddr = saddr;
13477 + nsa->saddr = saddr;
13478 + nsa->baddr = baddr;
13483 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13485 + // struct sock *sk = &inet->sk;
13486 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13488 + // *saddr = nsa->baddr;
13489 + // inet->inet_saddr = nsa->baddr;
13493 +int nx_info_has_v6(struct nx_info *nxi)
13497 + if (NX_IPV6(nxi))
13502 +#else /* CONFIG_IPV6 */
13505 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13512 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13518 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13524 +int nx_info_has_v6(struct nx_info *nxi)
13529 +#endif /* CONFIG_IPV6 */
13531 +#define current_nx_info_has_v6() \
13532 + nx_info_has_v6(current_nx_info())
13535 +#warning duplicate inclusion
13537 diff -NurpP --minimal linux-2.6.33/include/linux/vs_inet.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_inet.h
13538 --- linux-2.6.33/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13539 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_inet.h 2010-02-25 14:45:44.000000000 +0100
13541 +#ifndef _VS_INET_H
13542 +#define _VS_INET_H
13544 +#include "vserver/base.h"
13545 +#include "vserver/network.h"
13546 +#include "vserver/debug.h"
13548 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13550 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13551 + NIPQUAD((a)->mask), (a)->type
13552 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13556 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13558 + __be32 ip = nxa->ip[0].s_addr;
13559 + __be32 mask = nxa->mask.s_addr;
13560 + __be32 bcast = ip | ~mask;
13563 + switch (nxa->type & tmask) {
13564 + case NXA_TYPE_MASK:
13565 + ret = (ip == (addr & mask));
13567 + case NXA_TYPE_ADDR:
13571 + /* fall through to broadcast */
13572 + case NXA_MOD_BCAST:
13573 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13575 + case NXA_TYPE_RANGE:
13576 + ret = ((nxa->ip[0].s_addr <= addr) &&
13577 + (nxa->ip[1].s_addr > addr));
13579 + case NXA_TYPE_ANY:
13584 + vxdprintk(VXD_CBIT(net, 0),
13585 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13586 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13591 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13593 + struct nx_addr_v4 *nxa;
13600 + /* allow 127.0.0.1 when remapping lback */
13601 + if ((tmask & NXA_LOOPBACK) &&
13602 + (addr == IPI_LOOPBACK) &&
13603 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13606 + /* check for lback address */
13607 + if ((tmask & NXA_MOD_LBACK) &&
13608 + (nxi->v4_lback.s_addr == addr))
13611 + /* check for broadcast address */
13612 + if ((tmask & NXA_MOD_BCAST) &&
13613 + (nxi->v4_bcast.s_addr == addr))
13616 + /* check for v4 addresses */
13617 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13618 + if (v4_addr_match(nxa, addr, tmask))
13622 + vxdprintk(VXD_CBIT(net, 0),
13623 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13624 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13629 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13631 + /* FIXME: needs full range checks */
13632 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13636 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13638 + struct nx_addr_v4 *ptr;
13640 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13641 + if (v4_nx_addr_match(ptr, nxa, mask))
13646 +#include <net/inet_sock.h>
13649 + * Check if a given address matches for a socket
13651 + * nxi: the socket's nx_info if any
13652 + * addr: to be verified address
13655 +int v4_sock_addr_match (
13656 + struct nx_info *nxi,
13657 + struct inet_sock *inet,
13660 + __be32 saddr = inet->inet_rcv_saddr;
13661 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13663 + if (addr && (saddr == addr || bcast == addr))
13666 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13671 +/* inet related checks and helpers */
13675 +struct net_device;
13678 +#ifdef CONFIG_INET
13680 +#include <linux/netdevice.h>
13681 +#include <linux/inetdevice.h>
13682 +#include <net/inet_sock.h>
13683 +#include <net/inet_timewait_sock.h>
13686 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13687 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13688 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13692 + * check if address is covered by socket
13694 + * sk: the socket to check against
13695 + * addr: the address in question (must be != 0)
13699 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13701 + struct nx_info *nxi = sk->sk_nx_info;
13702 + __be32 saddr = inet_rcv_saddr(sk);
13704 + vxdprintk(VXD_CBIT(net, 5),
13705 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13706 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13707 + (sk->sk_socket?sk->sk_socket->flags:0));
13709 + if (saddr) { /* direct address match */
13710 + return v4_addr_match(nxa, saddr, -1);
13711 + } else if (nxi) { /* match against nx_info */
13712 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13713 + } else { /* unrestricted any socket */
13721 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13723 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13724 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13725 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13727 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13729 + if (dev_in_nx_info(dev, nxi))
13736 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13742 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13746 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13748 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13749 + nxi, nxi ? nxi->nx_id : 0, ifa,
13750 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13752 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13754 + if (v4_ifa_in_nx_info(ifa, nxi))
13760 +struct nx_v4_sock_addr {
13761 + __be32 saddr; /* Address used for validation */
13762 + __be32 baddr; /* Address used for socket bind */
13766 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13767 + struct nx_v4_sock_addr *nsa)
13769 + struct sock *sk = &inet->sk;
13770 + struct nx_info *nxi = sk->sk_nx_info;
13771 + __be32 saddr = addr->sin_addr.s_addr;
13772 + __be32 baddr = saddr;
13774 + vxdprintk(VXD_CBIT(net, 3),
13775 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13776 + sk, sk->sk_nx_info, sk->sk_socket,
13777 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13781 + if (saddr == INADDR_ANY) {
13782 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13783 + baddr = nxi->v4.ip[0].s_addr;
13784 + } else if (saddr == IPI_LOOPBACK) {
13785 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13786 + baddr = nxi->v4_lback.s_addr;
13787 + } else { /* normal address bind */
13788 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13789 + return -EADDRNOTAVAIL;
13793 + vxdprintk(VXD_CBIT(net, 3),
13794 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13795 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13797 + nsa->saddr = saddr;
13798 + nsa->baddr = baddr;
13803 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13805 + inet->inet_saddr = nsa->baddr;
13806 + inet->inet_rcv_saddr = nsa->baddr;
13811 + * helper to simplify inet_lookup_listener
13813 + * nxi: the socket's nx_info if any
13814 + * addr: to be verified address
13815 + * saddr: socket address
13817 +static inline int v4_inet_addr_match (
13818 + struct nx_info *nxi,
13822 + if (addr && (saddr == addr))
13825 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13829 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13831 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13832 + (addr == nxi->v4_lback.s_addr))
13833 + return IPI_LOOPBACK;
13838 +int nx_info_has_v4(struct nx_info *nxi)
13842 + if (NX_IPV4(nxi))
13844 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13849 +#else /* CONFIG_INET */
13852 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13858 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13864 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13870 +int nx_info_has_v4(struct nx_info *nxi)
13875 +#endif /* CONFIG_INET */
13877 +#define current_nx_info_has_v4() \
13878 + nx_info_has_v4(current_nx_info())
13881 +// #warning duplicate inclusion
13883 diff -NurpP --minimal linux-2.6.33/include/linux/vs_limit.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_limit.h
13884 --- linux-2.6.33/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13885 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_limit.h 2010-02-25 12:02:16.000000000 +0100
13887 +#ifndef _VS_LIMIT_H
13888 +#define _VS_LIMIT_H
13890 +#include "vserver/limit.h"
13891 +#include "vserver/base.h"
13892 +#include "vserver/context.h"
13893 +#include "vserver/debug.h"
13894 +#include "vserver/context.h"
13895 +#include "vserver/limit_int.h"
13898 +#define vx_acc_cres(v, d, p, r) \
13899 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13901 +#define vx_acc_cres_cond(x, d, p, r) \
13902 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13903 + r, d, p, __FILE__, __LINE__)
13906 +#define vx_add_cres(v, a, p, r) \
13907 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13908 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13910 +#define vx_add_cres_cond(x, a, p, r) \
13911 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13912 + r, a, p, __FILE__, __LINE__)
13913 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13916 +/* process and file limits */
13918 +#define vx_nproc_inc(p) \
13919 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13921 +#define vx_nproc_dec(p) \
13922 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13924 +#define vx_files_inc(f) \
13925 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13927 +#define vx_files_dec(f) \
13928 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13930 +#define vx_locks_inc(l) \
13931 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13933 +#define vx_locks_dec(l) \
13934 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13936 +#define vx_openfd_inc(f) \
13937 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
13939 +#define vx_openfd_dec(f) \
13940 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
13943 +#define vx_cres_avail(v, n, r) \
13944 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13947 +#define vx_nproc_avail(n) \
13948 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
13950 +#define vx_files_avail(n) \
13951 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
13953 +#define vx_locks_avail(n) \
13954 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
13956 +#define vx_openfd_avail(n) \
13957 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
13960 +/* dentry limits */
13962 +#define vx_dentry_inc(d) do { \
13963 + if (atomic_read(&d->d_count) == 1) \
13964 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
13967 +#define vx_dentry_dec(d) do { \
13968 + if (atomic_read(&d->d_count) == 0) \
13969 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
13972 +#define vx_dentry_avail(n) \
13973 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
13976 +/* socket limits */
13978 +#define vx_sock_inc(s) \
13979 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13981 +#define vx_sock_dec(s) \
13982 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13984 +#define vx_sock_avail(n) \
13985 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
13988 +/* ipc resource limits */
13990 +#define vx_ipcmsg_add(v, u, a) \
13991 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13993 +#define vx_ipcmsg_sub(v, u, a) \
13994 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13996 +#define vx_ipcmsg_avail(v, a) \
13997 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14000 +#define vx_ipcshm_add(v, k, a) \
14001 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14003 +#define vx_ipcshm_sub(v, k, a) \
14004 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14006 +#define vx_ipcshm_avail(v, a) \
14007 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14010 +#define vx_semary_inc(a) \
14011 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
14013 +#define vx_semary_dec(a) \
14014 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
14017 +#define vx_nsems_add(a,n) \
14018 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14020 +#define vx_nsems_sub(a,n) \
14021 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14025 +#warning duplicate inclusion
14027 diff -NurpP --minimal linux-2.6.33/include/linux/vs_memory.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_memory.h
14028 --- linux-2.6.33/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14029 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_memory.h 2010-02-25 12:02:16.000000000 +0100
14031 +#ifndef _VS_MEMORY_H
14032 +#define _VS_MEMORY_H
14034 +#include "vserver/limit.h"
14035 +#include "vserver/base.h"
14036 +#include "vserver/context.h"
14037 +#include "vserver/debug.h"
14038 +#include "vserver/context.h"
14039 +#include "vserver/limit_int.h"
14042 +#define __acc_add_long(a, v) (*(v) += (a))
14043 +#define __acc_inc_long(v) (++*(v))
14044 +#define __acc_dec_long(v) (--*(v))
14046 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14047 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14048 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14049 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14050 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14051 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14052 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14053 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14054 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14057 +#define vx_acc_page(m, d, v, r) do { \
14059 + __acc_inc_long(&(m)->v); \
14061 + __acc_dec_long(&(m)->v); \
14062 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14065 +#define vx_acc_page_atomic(m, d, v, r) do { \
14067 + __acc_inc_atomic(&(m)->v); \
14069 + __acc_dec_atomic(&(m)->v); \
14070 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14074 +#define vx_acc_pages(m, p, v, r) do { \
14075 + unsigned long __p = (p); \
14076 + __acc_add_long(__p, &(m)->v); \
14077 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14080 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14081 + unsigned long __p = (p); \
14082 + __acc_add_atomic(__p, &(m)->v); \
14083 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14088 +#define vx_acc_vmpage(m, d) \
14089 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14090 +#define vx_acc_vmlpage(m, d) \
14091 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14092 +#define vx_acc_file_rsspage(m, d) \
14093 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14094 +#define vx_acc_anon_rsspage(m, d) \
14095 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14097 +#define vx_acc_vmpages(m, p) \
14098 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14099 +#define vx_acc_vmlpages(m, p) \
14100 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14101 +#define vx_acc_file_rsspages(m, p) \
14102 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14103 +#define vx_acc_anon_rsspages(m, p) \
14104 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14106 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14107 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14109 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14110 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14111 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14112 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14114 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14115 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14116 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14117 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14119 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14120 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14121 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14122 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14124 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14125 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14126 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14127 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14130 +#define vx_pages_avail(m, p, r) \
14131 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14133 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14134 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14135 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14136 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14138 +#define vx_rss_avail(m, p) \
14139 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14143 + VXPT_UNKNOWN = 0,
14152 +#define vx_page_fault(mm, vma, type, ret)
14156 +void __vx_page_fault(struct mm_struct *mm,
14157 + struct vm_area_struct *vma, int type, int ret)
14159 + struct vx_info *vxi = mm->mm_vx_info;
14162 + static char *page_type[6] =
14163 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14164 + static char *page_what[4] =
14165 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14171 + what = (ret & 0x3);
14173 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14174 + type, what, ret, page_type[type], page_what[what]);
14176 + if (ret & VM_FAULT_WRITE)
14178 + atomic_inc(&vxi->cacct.page[type][what]);
14181 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14185 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14188 +#warning duplicate inclusion
14190 diff -NurpP --minimal linux-2.6.33/include/linux/vs_network.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_network.h
14191 --- linux-2.6.33/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14192 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_network.h 2010-02-25 12:02:16.000000000 +0100
14194 +#ifndef _NX_VS_NETWORK_H
14195 +#define _NX_VS_NETWORK_H
14197 +#include "vserver/context.h"
14198 +#include "vserver/network.h"
14199 +#include "vserver/base.h"
14200 +#include "vserver/check.h"
14201 +#include "vserver/debug.h"
14203 +#include <linux/sched.h>
14206 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14208 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14209 + const char *_file, int _line)
14214 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14215 + nxi, nxi ? nxi->nx_id : 0,
14216 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14219 + atomic_inc(&nxi->nx_usecnt);
14224 +extern void free_nx_info(struct nx_info *);
14226 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14228 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14233 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14234 + nxi, nxi ? nxi->nx_id : 0,
14235 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14238 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14239 + free_nx_info(nxi);
14243 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14245 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14246 + const char *_file, int _line)
14249 + vxlprintk(VXD_CBIT(nid, 3),
14250 + "init_nx_info(%p[#%d.%d])",
14251 + nxi, nxi ? nxi->nx_id : 0,
14252 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14255 + atomic_inc(&nxi->nx_usecnt);
14261 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14263 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14264 + const char *_file, int _line)
14266 + struct nx_info *nxo;
14271 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14272 + nxi, nxi ? nxi->nx_id : 0,
14273 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14276 + atomic_inc(&nxi->nx_usecnt);
14277 + nxo = xchg(nxp, nxi);
14281 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14283 +static inline void __clr_nx_info(struct nx_info **nxp,
14284 + const char *_file, int _line)
14286 + struct nx_info *nxo;
14288 + nxo = xchg(nxp, NULL);
14292 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14293 + nxo, nxo ? nxo->nx_id : 0,
14294 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14297 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14298 + free_nx_info(nxo);
14302 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14304 +static inline void __claim_nx_info(struct nx_info *nxi,
14305 + struct task_struct *task, const char *_file, int _line)
14307 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14308 + nxi, nxi ? nxi->nx_id : 0,
14309 + nxi?atomic_read(&nxi->nx_usecnt):0,
14310 + nxi?atomic_read(&nxi->nx_tasks):0,
14311 + task, _file, _line);
14313 + atomic_inc(&nxi->nx_tasks);
14317 +extern void unhash_nx_info(struct nx_info *);
14319 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14321 +static inline void __release_nx_info(struct nx_info *nxi,
14322 + struct task_struct *task, const char *_file, int _line)
14324 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14325 + nxi, nxi ? nxi->nx_id : 0,
14326 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14327 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14328 + task, _file, _line);
14332 + if (atomic_dec_and_test(&nxi->nx_tasks))
14333 + unhash_nx_info(nxi);
14337 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14339 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14340 + const char *_file, int _line)
14342 + struct nx_info *nxi;
14345 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14346 + p, _file, _line);
14347 + nxi = __get_nx_info(p->nx_info, _file, _line);
14353 +static inline void exit_nx_info(struct task_struct *p)
14356 + release_nx_info(p->nx_info, p);
14361 +#warning duplicate inclusion
14363 diff -NurpP --minimal linux-2.6.33/include/linux/vs_pid.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_pid.h
14364 --- linux-2.6.33/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14365 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_pid.h 2010-02-25 12:02:16.000000000 +0100
14370 +#include "vserver/base.h"
14371 +#include "vserver/check.h"
14372 +#include "vserver/context.h"
14373 +#include "vserver/debug.h"
14374 +#include "vserver/pid.h"
14375 +#include <linux/pid_namespace.h>
14378 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14381 +int vx_proc_task_visible(struct task_struct *task)
14383 + if ((task->pid == 1) &&
14384 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14385 + /* show a blend through init */
14387 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14394 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14399 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14401 + struct task_struct *task = find_task_by_real_pid(pid);
14403 + if (task && !vx_proc_task_visible(task)) {
14404 + vxdprintk(VXD_CBIT(misc, 6),
14405 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14406 + task, task->xid, task->pid,
14407 + current, current->xid, current->pid);
14416 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14418 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14420 + if (task && !vx_proc_task_visible(task)) {
14421 + vxdprintk(VXD_CBIT(misc, 6),
14422 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14423 + task, task->xid, task->pid,
14424 + current, current->xid, current->pid);
14425 + put_task_struct(task);
14434 +struct task_struct *vx_child_reaper(struct task_struct *p)
14436 + struct vx_info *vxi = p->vx_info;
14437 + struct task_struct *reaper = child_reaper(p);
14442 + BUG_ON(!p->vx_info->vx_reaper);
14444 + /* child reaper for the guest reaper */
14445 + if (vxi->vx_reaper == p)
14448 + reaper = vxi->vx_reaper;
14450 + vxdprintk(VXD_CBIT(xid, 7),
14451 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14452 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14460 +#warning duplicate inclusion
14462 diff -NurpP --minimal linux-2.6.33/include/linux/vs_sched.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_sched.h
14463 --- linux-2.6.33/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14464 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_sched.h 2010-02-25 12:02:16.000000000 +0100
14466 +#ifndef _VS_SCHED_H
14467 +#define _VS_SCHED_H
14469 +#include "vserver/base.h"
14470 +#include "vserver/context.h"
14471 +#include "vserver/sched.h"
14474 +#define VAVAVOOM_RATIO 50
14476 +#define MAX_PRIO_BIAS 20
14477 +#define MIN_PRIO_BIAS -20
14480 +#ifdef CONFIG_VSERVER_HARDCPU
14483 + * effective_prio - return the priority that is based on the static
14484 + * priority but is modified by bonuses/penalties.
14486 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14487 + * into a -4 ... 0 ... +4 bonus/penalty range.
14489 + * Additionally, we scale another amount based on the number of
14490 + * CPU tokens currently held by the context, if the process is
14491 + * part of a context (and the appropriate SCHED flag is set).
14492 + * This ranges from -5 ... 0 ... +15, quadratically.
14494 + * So, the total bonus is -9 .. 0 .. +19
14495 + * We use ~50% of the full 0...39 priority range so that:
14497 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14498 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14499 + * unless that context is far exceeding its CPU allocation.
14501 + * Both properties are important to certain workloads.
14504 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14506 + int vavavoom, max;
14508 + /* lots of tokens = lots of vavavoom
14509 + * no tokens = no vavavoom */
14510 + if ((vavavoom = sched_pc->tokens) >= 0) {
14511 + max = sched_pc->tokens_max;
14512 + vavavoom = max - vavavoom;
14514 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14515 + * (vavavoom*vavavoom - (max >> 2)) / max;
14523 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14525 + struct vx_info *vxi = p->vx_info;
14526 + struct _vx_sched_pc *sched_pc;
14531 + sched_pc = &vx_cpu(vxi, sched_pc);
14532 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14533 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14535 + sched_pc->vavavoom = vavavoom;
14536 + prio += vavavoom;
14538 + prio += sched_pc->prio_bias;
14542 +#else /* !CONFIG_VSERVER_HARDCPU */
14545 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14547 + struct vx_info *vxi = p->vx_info;
14550 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14554 +#endif /* CONFIG_VSERVER_HARDCPU */
14557 +static inline void vx_account_user(struct vx_info *vxi,
14558 + cputime_t cputime, int nice)
14562 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14565 +static inline void vx_account_system(struct vx_info *vxi,
14566 + cputime_t cputime, int idle)
14570 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14574 +#warning duplicate inclusion
14576 diff -NurpP --minimal linux-2.6.33/include/linux/vs_socket.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_socket.h
14577 --- linux-2.6.33/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14578 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_socket.h 2010-02-25 12:02:16.000000000 +0100
14580 +#ifndef _VS_SOCKET_H
14581 +#define _VS_SOCKET_H
14583 +#include "vserver/debug.h"
14584 +#include "vserver/base.h"
14585 +#include "vserver/cacct.h"
14586 +#include "vserver/context.h"
14587 +#include "vserver/tag.h"
14590 +/* socket accounting */
14592 +#include <linux/socket.h>
14594 +static inline int vx_sock_type(int family)
14596 + switch (family) {
14598 + return VXA_SOCK_UNSPEC;
14600 + return VXA_SOCK_UNIX;
14602 + return VXA_SOCK_INET;
14604 + return VXA_SOCK_INET6;
14606 + return VXA_SOCK_PACKET;
14608 + return VXA_SOCK_OTHER;
14612 +#define vx_acc_sock(v, f, p, s) \
14613 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14615 +static inline void __vx_acc_sock(struct vx_info *vxi,
14616 + int family, int pos, int size, char *file, int line)
14619 + int type = vx_sock_type(family);
14621 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14622 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14626 +#define vx_sock_recv(sk, s) \
14627 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14628 +#define vx_sock_send(sk, s) \
14629 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14630 +#define vx_sock_fail(sk, s) \
14631 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14634 +#define sock_vx_init(s) do { \
14635 + (s)->sk_xid = 0; \
14636 + (s)->sk_vx_info = NULL; \
14639 +#define sock_nx_init(s) do { \
14640 + (s)->sk_nid = 0; \
14641 + (s)->sk_nx_info = NULL; \
14645 +#warning duplicate inclusion
14647 diff -NurpP --minimal linux-2.6.33/include/linux/vs_tag.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_tag.h
14648 --- linux-2.6.33/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14649 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_tag.h 2010-02-25 12:02:16.000000000 +0100
14654 +#include <linux/vserver/tag.h>
14656 +/* check conditions */
14658 +#define DX_ADMIN 0x0001
14659 +#define DX_WATCH 0x0002
14660 +#define DX_HOSTID 0x0008
14662 +#define DX_IDENT 0x0010
14664 +#define DX_ARG_MASK 0x0010
14667 +#define dx_task_tag(t) ((t)->tag)
14669 +#define dx_current_tag() dx_task_tag(current)
14671 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14673 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14677 + * check current context for ADMIN/WATCH and
14678 + * optionally against supplied argument
14680 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14682 + if (mode & DX_ARG_MASK) {
14683 + if ((mode & DX_IDENT) && (id == cid))
14686 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14687 + ((mode & DX_WATCH) && (cid == 1)) ||
14688 + ((mode & DX_HOSTID) && (id == 0)));
14692 +int dx_permission(const struct inode *inode, int mask);
14696 +#warning duplicate inclusion
14698 diff -NurpP --minimal linux-2.6.33/include/linux/vs_time.h linux-2.6.33-vs2.3.0.36.30/include/linux/vs_time.h
14699 --- linux-2.6.33/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14700 +++ linux-2.6.33-vs2.3.0.36.30/include/linux/vs_time.h 2010-02-25 12:02:16.000000000 +0100
14702 +#ifndef _VS_TIME_H
14703 +#define _VS_TIME_H
14706 +/* time faking stuff */
14708 +#ifdef CONFIG_VSERVER_VTIME
14710 +extern void vx_gettimeofday(struct timeval *tv);
14711 +extern int vx_settimeofday(struct timespec *ts);
14714 +#define vx_gettimeofday(t) do_gettimeofday(t)
14715 +#define vx_settimeofday(t) do_settimeofday(t)
14719 +#warning duplicate inclusion
14721 diff -NurpP --minimal linux-2.6.33/include/net/addrconf.h linux-2.6.33-vs2.3.0.36.30/include/net/addrconf.h
14722 --- linux-2.6.33/include/net/addrconf.h 2009-12-03 20:02:57.000000000 +0100
14723 +++ linux-2.6.33-vs2.3.0.36.30/include/net/addrconf.h 2010-02-25 12:02:16.000000000 +0100
14724 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14725 struct net_device *dev,
14726 const struct in6_addr *daddr,
14727 unsigned int srcprefs,
14728 - struct in6_addr *saddr);
14729 + struct in6_addr *saddr,
14730 + struct nx_info *nxi);
14731 extern int ipv6_get_lladdr(struct net_device *dev,
14732 struct in6_addr *addr,
14733 unsigned char banned_flags);
14734 diff -NurpP --minimal linux-2.6.33/include/net/af_unix.h linux-2.6.33-vs2.3.0.36.30/include/net/af_unix.h
14735 --- linux-2.6.33/include/net/af_unix.h 2008-12-25 00:26:37.000000000 +0100
14736 +++ linux-2.6.33-vs2.3.0.36.30/include/net/af_unix.h 2010-02-25 12:02:16.000000000 +0100
14738 #include <linux/socket.h>
14739 #include <linux/un.h>
14740 #include <linux/mutex.h>
14741 +#include <linux/vs_base.h>
14742 #include <net/sock.h>
14744 extern void unix_inflight(struct file *fp);
14745 diff -NurpP --minimal linux-2.6.33/include/net/inet_timewait_sock.h linux-2.6.33-vs2.3.0.36.30/include/net/inet_timewait_sock.h
14746 --- linux-2.6.33/include/net/inet_timewait_sock.h 2010-02-25 11:52:08.000000000 +0100
14747 +++ linux-2.6.33-vs2.3.0.36.30/include/net/inet_timewait_sock.h 2010-02-25 12:02:16.000000000 +0100
14748 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14749 #define tw_hash __tw_common.skc_hash
14750 #define tw_prot __tw_common.skc_prot
14751 #define tw_net __tw_common.skc_net
14752 +#define tw_xid __tw_common.skc_xid
14753 +#define tw_vx_info __tw_common.skc_vx_info
14754 +#define tw_nid __tw_common.skc_nid
14755 +#define tw_nx_info __tw_common.skc_nx_info
14757 volatile unsigned char tw_substate;
14758 /* 3 bits hole, try to pack */
14759 diff -NurpP --minimal linux-2.6.33/include/net/route.h linux-2.6.33-vs2.3.0.36.30/include/net/route.h
14760 --- linux-2.6.33/include/net/route.h 2010-02-25 11:52:08.000000000 +0100
14761 +++ linux-2.6.33-vs2.3.0.36.30/include/net/route.h 2010-02-25 12:02:16.000000000 +0100
14762 @@ -132,6 +132,9 @@ static inline void ip_rt_put(struct rtab
14763 dst_release(&rt->u.dst);
14766 +#include <linux/vs_base.h>
14767 +#include <linux/vs_inet.h>
14769 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14771 extern const __u8 ip_tos2prio[16];
14772 @@ -141,6 +144,9 @@ static inline char rt_tos2priority(u8 to
14773 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14776 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14777 + struct rtable **, struct flowi *);
14779 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14780 __be32 src, u32 tos, int oif, u8 protocol,
14781 __be16 sport, __be16 dport, struct sock *sk,
14782 @@ -158,11 +164,24 @@ static inline int ip_route_connect(struc
14785 struct net *net = sock_net(sk);
14786 + struct nx_info *nx_info = current_nx_info();
14788 if (inet_sk(sk)->transparent)
14789 fl.flags |= FLOWI_FLAG_ANYSRC;
14791 - if (!dst || !src) {
14793 + nx_info = sk->sk_nx_info;
14795 + vxdprintk(VXD_CBIT(net, 4),
14796 + "ip_route_connect(%p) %p,%p;%lx",
14797 + sk, nx_info, sk->sk_socket,
14798 + (sk->sk_socket?sk->sk_socket->flags:0));
14800 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14804 + if (!fl.fl4_dst || !fl.fl4_src) {
14805 err = __ip_route_output_key(net, rp, &fl);
14808 diff -NurpP --minimal linux-2.6.33/include/net/sock.h linux-2.6.33-vs2.3.0.36.30/include/net/sock.h
14809 --- linux-2.6.33/include/net/sock.h 2010-02-25 11:52:08.000000000 +0100
14810 +++ linux-2.6.33-vs2.3.0.36.30/include/net/sock.h 2010-02-25 12:02:16.000000000 +0100
14811 @@ -149,6 +149,10 @@ struct sock_common {
14812 #ifdef CONFIG_NET_NS
14813 struct net *skc_net;
14816 + struct vx_info *skc_vx_info;
14818 + struct nx_info *skc_nx_info;
14822 @@ -236,6 +240,10 @@ struct sock {
14823 #define sk_bind_node __sk_common.skc_bind_node
14824 #define sk_prot __sk_common.skc_prot
14825 #define sk_net __sk_common.skc_net
14826 +#define sk_xid __sk_common.skc_xid
14827 +#define sk_vx_info __sk_common.skc_vx_info
14828 +#define sk_nid __sk_common.skc_nid
14829 +#define sk_nx_info __sk_common.skc_nx_info
14830 kmemcheck_bitfield_begin(flags);
14831 unsigned int sk_shutdown : 2,
14833 diff -NurpP --minimal linux-2.6.33/init/Kconfig linux-2.6.33-vs2.3.0.36.30/init/Kconfig
14834 --- linux-2.6.33/init/Kconfig 2010-02-25 11:52:09.000000000 +0100
14835 +++ linux-2.6.33-vs2.3.0.36.30/init/Kconfig 2010-02-25 12:02:16.000000000 +0100
14836 @@ -496,6 +496,19 @@ config CGROUP_SCHED
14840 +config CFS_HARD_LIMITS
14841 + bool "Hard Limits for CFS Group Scheduler"
14842 + depends on EXPERIMENTAL
14843 + depends on FAIR_GROUP_SCHED && CGROUP_SCHED
14846 + This option enables hard limiting of CPU time obtained by
14847 + a fair task group. Use this if you want to throttle a group of tasks
14848 + based on its CPU usage. For more details refer to
14849 + Documentation/scheduler/sched-cfs-hard-limits.txt
14854 boolean "Control Group support"
14856 diff -NurpP --minimal linux-2.6.33/init/main.c linux-2.6.33-vs2.3.0.36.30/init/main.c
14857 --- linux-2.6.33/init/main.c 2010-02-25 11:52:09.000000000 +0100
14858 +++ linux-2.6.33-vs2.3.0.36.30/init/main.c 2010-02-25 12:02:16.000000000 +0100
14860 #include <linux/sfi.h>
14861 #include <linux/shmem_fs.h>
14862 #include <trace/boot.h>
14863 +#include <linux/vserver/percpu.h>
14865 #include <asm/io.h>
14866 #include <asm/bugs.h>
14867 diff -NurpP --minimal linux-2.6.33/ipc/mqueue.c linux-2.6.33-vs2.3.0.36.30/ipc/mqueue.c
14868 --- linux-2.6.33/ipc/mqueue.c 2010-02-25 11:52:09.000000000 +0100
14869 +++ linux-2.6.33-vs2.3.0.36.30/ipc/mqueue.c 2010-02-25 12:21:21.000000000 +0100
14871 #include <linux/nsproxy.h>
14872 #include <linux/pid.h>
14873 #include <linux/ipc_namespace.h>
14874 +#include <linux/vs_context.h>
14875 +#include <linux/vs_limit.h>
14877 #include <net/sock.h>
14879 @@ -65,6 +67,7 @@ struct mqueue_inode_info {
14880 struct sigevent notify;
14881 struct pid* notify_owner;
14882 struct user_struct *user; /* user who created, for accounting */
14883 + struct vx_info *vxi;
14884 struct sock *notify_sock;
14885 struct sk_buff *notify_cookie;
14887 @@ -124,6 +127,7 @@ static struct inode *mqueue_get_inode(st
14888 if (S_ISREG(mode)) {
14889 struct mqueue_inode_info *info;
14890 struct task_struct *p = current;
14891 + struct vx_info *vxi = p->vx_info;
14892 unsigned long mq_bytes, mq_msg_tblsz;
14894 inode->i_fop = &mqueue_file_operations;
14895 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
14896 info->notify_owner = NULL;
14898 info->user = NULL; /* set when all is ok */
14899 + info->vxi = NULL;
14900 memset(&info->attr, 0, sizeof(info->attr));
14901 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14902 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14903 @@ -152,22 +157,26 @@ static struct inode *mqueue_get_inode(st
14904 spin_lock(&mq_lock);
14905 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14906 u->mq_bytes + mq_bytes >
14907 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14908 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14909 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14910 spin_unlock(&mq_lock);
14913 u->mq_bytes += mq_bytes;
14914 + vx_ipcmsg_add(vxi, u, mq_bytes);
14915 spin_unlock(&mq_lock);
14917 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14918 if (!info->messages) {
14919 spin_lock(&mq_lock);
14920 u->mq_bytes -= mq_bytes;
14921 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14922 spin_unlock(&mq_lock);
14926 info->user = get_uid(u);
14927 + info->vxi = get_vx_info(vxi);
14928 } else if (S_ISDIR(mode)) {
14930 /* Some things misbehave if size == 0 on a directory */
14931 @@ -268,8 +277,11 @@ static void mqueue_delete_inode(struct i
14932 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14935 + struct vx_info *vxi = info->vxi;
14937 spin_lock(&mq_lock);
14938 user->mq_bytes -= mq_bytes;
14939 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14941 * get_ns_from_inode() ensures that the
14942 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14943 @@ -279,6 +291,7 @@ static void mqueue_delete_inode(struct i
14945 ipc_ns->mq_queues_count--;
14946 spin_unlock(&mq_lock);
14947 + put_vx_info(vxi);
14951 diff -NurpP --minimal linux-2.6.33/ipc/msg.c linux-2.6.33-vs2.3.0.36.30/ipc/msg.c
14952 --- linux-2.6.33/ipc/msg.c 2010-02-25 11:52:09.000000000 +0100
14953 +++ linux-2.6.33-vs2.3.0.36.30/ipc/msg.c 2010-02-25 12:02:16.000000000 +0100
14955 #include <linux/rwsem.h>
14956 #include <linux/nsproxy.h>
14957 #include <linux/ipc_namespace.h>
14958 +#include <linux/vs_base.h>
14960 #include <asm/current.h>
14961 #include <asm/uaccess.h>
14962 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
14964 msq->q_perm.mode = msgflg & S_IRWXUGO;
14965 msq->q_perm.key = key;
14966 + msq->q_perm.xid = vx_current_xid();
14968 msq->q_perm.security = NULL;
14969 retval = security_msg_queue_alloc(msq);
14970 diff -NurpP --minimal linux-2.6.33/ipc/namespace.c linux-2.6.33-vs2.3.0.36.30/ipc/namespace.c
14971 --- linux-2.6.33/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14972 +++ linux-2.6.33-vs2.3.0.36.30/ipc/namespace.c 2010-02-25 12:02:16.000000000 +0100
14974 #include <linux/slab.h>
14975 #include <linux/fs.h>
14976 #include <linux/mount.h>
14977 +#include <linux/vs_base.h>
14978 +#include <linux/vserver/global.h>
14982 diff -NurpP --minimal linux-2.6.33/ipc/sem.c linux-2.6.33-vs2.3.0.36.30/ipc/sem.c
14983 --- linux-2.6.33/ipc/sem.c 2010-02-25 11:52:09.000000000 +0100
14984 +++ linux-2.6.33-vs2.3.0.36.30/ipc/sem.c 2010-02-25 12:02:16.000000000 +0100
14986 #include <linux/rwsem.h>
14987 #include <linux/nsproxy.h>
14988 #include <linux/ipc_namespace.h>
14989 +#include <linux/vs_base.h>
14990 +#include <linux/vs_limit.h>
14992 #include <asm/uaccess.h>
14994 @@ -257,6 +259,7 @@ static int newary(struct ipc_namespace *
14996 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14997 sma->sem_perm.key = key;
14998 + sma->sem_perm.xid = vx_current_xid();
15000 sma->sem_perm.security = NULL;
15001 retval = security_sem_alloc(sma);
15002 @@ -272,6 +275,9 @@ static int newary(struct ipc_namespace *
15005 ns->used_sems += nsems;
15006 + /* FIXME: obsoleted? */
15007 + vx_semary_inc(sma);
15008 + vx_nsems_add(sma, nsems);
15010 sma->sem_base = (struct sem *) &sma[1];
15012 @@ -595,6 +601,9 @@ static void freeary(struct ipc_namespace
15015 ns->used_sems -= sma->sem_nsems;
15016 + /* FIXME: obsoleted? */
15017 + vx_nsems_sub(sma, sma->sem_nsems);
15018 + vx_semary_dec(sma);
15019 security_sem_free(sma);
15020 ipc_rcu_putref(sma);
15022 diff -NurpP --minimal linux-2.6.33/ipc/shm.c linux-2.6.33-vs2.3.0.36.30/ipc/shm.c
15023 --- linux-2.6.33/ipc/shm.c 2010-02-25 11:52:09.000000000 +0100
15024 +++ linux-2.6.33-vs2.3.0.36.30/ipc/shm.c 2010-02-25 12:23:04.000000000 +0100
15026 #include <linux/nsproxy.h>
15027 #include <linux/mount.h>
15028 #include <linux/ipc_namespace.h>
15029 +#include <linux/vs_context.h>
15030 +#include <linux/vs_limit.h>
15032 #include <asm/uaccess.h>
15034 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
15036 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15038 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15039 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15040 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15042 + vx_ipcshm_sub(vxi, shp, numpages);
15043 + ns->shm_tot -= numpages;
15047 if (!is_file_hugepages(shp->shm_file))
15048 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
15050 fput (shp->shm_file);
15051 security_shm_free(shp);
15052 + put_vx_info(vxi);
15053 ipc_rcu_putref(shp);
15056 @@ -352,11 +360,15 @@ static int newseg(struct ipc_namespace *
15057 if (ns->shm_tot + numpages > ns->shm_ctlall)
15060 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
15063 shp = ipc_rcu_alloc(sizeof(*shp));
15067 shp->shm_perm.key = key;
15068 + shp->shm_perm.xid = vx_current_xid();
15069 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15070 shp->mlock_user = NULL;
15072 @@ -410,6 +422,7 @@ static int newseg(struct ipc_namespace *
15073 ns->shm_tot += numpages;
15074 error = shp->shm_perm.id;
15076 + vx_ipcshm_add(current_vx_info(), key, numpages);
15080 diff -NurpP --minimal linux-2.6.33/kernel/capability.c linux-2.6.33-vs2.3.0.36.30/kernel/capability.c
15081 --- linux-2.6.33/kernel/capability.c 2010-02-25 11:52:09.000000000 +0100
15082 +++ linux-2.6.33-vs2.3.0.36.30/kernel/capability.c 2010-02-25 12:02:16.000000000 +0100
15084 #include <linux/security.h>
15085 #include <linux/syscalls.h>
15086 #include <linux/pid_namespace.h>
15087 +#include <linux/vs_context.h>
15088 #include <asm/uaccess.h>
15089 #include "cred-internals.h"
15091 @@ -120,6 +121,7 @@ static int cap_validate_magic(cap_user_h
15097 * The only thing that can change the capabilities of the current
15098 * process is the current process. As such, we can't be in this code
15099 @@ -290,6 +292,8 @@ error:
15103 +#include <linux/vserver/base.h>
15106 * capable - Determine if the current task has a superior capability in effect
15107 * @cap: The capability to be tested for
15108 @@ -302,6 +306,9 @@ error:
15110 int capable(int cap)
15112 + /* here for now so we don't require task locking */
15113 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15115 if (unlikely(!cap_valid(cap))) {
15116 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15118 diff -NurpP --minimal linux-2.6.33/kernel/compat.c linux-2.6.33-vs2.3.0.36.30/kernel/compat.c
15119 --- linux-2.6.33/kernel/compat.c 2009-09-10 15:26:27.000000000 +0200
15120 +++ linux-2.6.33-vs2.3.0.36.30/kernel/compat.c 2010-02-25 12:02:16.000000000 +0100
15121 @@ -902,7 +902,7 @@ asmlinkage long compat_sys_time(compat_t
15125 - do_gettimeofday(&tv);
15126 + vx_gettimeofday(&tv);
15130 @@ -927,7 +927,7 @@ asmlinkage long compat_sys_stime(compat_
15134 - do_settimeofday(&tv);
15135 + vx_settimeofday(&tv);
15139 diff -NurpP --minimal linux-2.6.33/kernel/exit.c linux-2.6.33-vs2.3.0.36.30/kernel/exit.c
15140 --- linux-2.6.33/kernel/exit.c 2010-02-25 11:52:09.000000000 +0100
15141 +++ linux-2.6.33-vs2.3.0.36.30/kernel/exit.c 2010-02-25 12:02:16.000000000 +0100
15143 #include <linux/fs_struct.h>
15144 #include <linux/init_task.h>
15145 #include <linux/perf_event.h>
15146 +#include <linux/vs_limit.h>
15147 +#include <linux/vs_context.h>
15148 +#include <linux/vs_network.h>
15149 +#include <linux/vs_pid.h>
15150 #include <trace/events/sched.h>
15151 #include <linux/hw_breakpoint.h>
15153 @@ -489,9 +493,11 @@ static void close_files(struct files_str
15154 filp_close(file, files);
15157 + vx_openfd_dec(i);
15165 @@ -1019,11 +1025,16 @@ NORET_TYPE void do_exit(long code)
15167 validate_creds_for_do_exit(tsk);
15169 + /* needs to stay after exit_notify() */
15170 + exit_vx_info(tsk, code);
15171 + exit_nx_info(tsk);
15175 /* causes final put_task_struct in finish_task_switch(). */
15176 tsk->state = TASK_DEAD;
15178 + printk("bad task: %p [%lx]\n", current, current->state);
15180 /* Avoid "noreturn function does return". */
15182 diff -NurpP --minimal linux-2.6.33/kernel/fork.c linux-2.6.33-vs2.3.0.36.30/kernel/fork.c
15183 --- linux-2.6.33/kernel/fork.c 2010-02-25 11:52:09.000000000 +0100
15184 +++ linux-2.6.33-vs2.3.0.36.30/kernel/fork.c 2010-02-25 12:23:31.000000000 +0100
15186 #include <linux/perf_event.h>
15187 #include <linux/posix-timers.h>
15188 #include <linux/user-return-notifier.h>
15189 +#include <linux/vs_context.h>
15190 +#include <linux/vs_network.h>
15191 +#include <linux/vs_limit.h>
15192 +#include <linux/vs_memory.h>
15194 #include <asm/pgtable.h>
15195 #include <asm/pgalloc.h>
15196 @@ -152,6 +156,8 @@ void free_task(struct task_struct *tsk)
15197 account_kernel_stack(tsk->stack, -1);
15198 free_thread_info(tsk->stack);
15199 rt_mutex_debug_task_free(tsk);
15200 + clr_vx_info(&tsk->vx_info);
15201 + clr_nx_info(&tsk->nx_info);
15202 ftrace_graph_exit_task(tsk);
15203 free_task_struct(tsk);
15205 @@ -298,6 +304,8 @@ static int dup_mmap(struct mm_struct *mm
15206 mm->free_area_cache = oldmm->mmap_base;
15207 mm->cached_hole_size = ~0UL;
15209 + __set_mm_counter(mm, file_rss, 0);
15210 + __set_mm_counter(mm, anon_rss, 0);
15211 cpumask_clear(mm_cpumask(mm));
15212 mm->mm_rb = RB_ROOT;
15213 rb_link = &mm->mm_rb.rb_node;
15214 @@ -312,7 +320,7 @@ static int dup_mmap(struct mm_struct *mm
15216 if (mpnt->vm_flags & VM_DONTCOPY) {
15217 long pages = vma_pages(mpnt);
15218 - mm->total_vm -= pages;
15219 + vx_vmpages_sub(mm, pages);
15220 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15223 @@ -454,8 +462,8 @@ static struct mm_struct * mm_init(struct
15224 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
15225 mm->core_state = NULL;
15227 - set_mm_counter(mm, file_rss, 0);
15228 - set_mm_counter(mm, anon_rss, 0);
15229 + __set_mm_counter(mm, file_rss, 0);
15230 + __set_mm_counter(mm, anon_rss, 0);
15231 spin_lock_init(&mm->page_table_lock);
15232 mm->free_area_cache = TASK_UNMAPPED_BASE;
15233 mm->cached_hole_size = ~0UL;
15234 @@ -465,6 +473,7 @@ static struct mm_struct * mm_init(struct
15235 if (likely(!mm_alloc_pgd(mm))) {
15237 mmu_notifier_mm_init(mm);
15238 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15242 @@ -498,6 +507,7 @@ void __mmdrop(struct mm_struct *mm)
15244 destroy_context(mm);
15245 mmu_notifier_mm_destroy(mm);
15246 + clr_vx_info(&mm->mm_vx_info);
15249 EXPORT_SYMBOL_GPL(__mmdrop);
15250 @@ -633,6 +643,7 @@ struct mm_struct *dup_mm(struct task_str
15253 memcpy(mm, oldmm, sizeof(*mm));
15254 + mm->mm_vx_info = NULL;
15256 /* Initializing for Swap token stuff */
15257 mm->token_priority = 0;
15258 @@ -671,6 +682,7 @@ fail_nocontext:
15259 * If init_new_context() failed, we cannot use mmput() to free the mm
15260 * because it calls destroy_context()
15262 + clr_vx_info(&mm->mm_vx_info);
15266 @@ -985,6 +997,8 @@ static struct task_struct *copy_process(
15268 struct task_struct *p;
15269 int cgroup_callbacks_done = 0;
15270 + struct vx_info *vxi;
15271 + struct nx_info *nxi;
15273 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15274 return ERR_PTR(-EINVAL);
15275 @@ -1031,12 +1045,28 @@ static struct task_struct *copy_process(
15276 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15277 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15279 + init_vx_info(&p->vx_info, current_vx_info());
15280 + init_nx_info(&p->nx_info, current_nx_info());
15282 + /* check vserver memory */
15283 + if (p->mm && !(clone_flags & CLONE_VM)) {
15284 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15285 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15287 + goto bad_fork_free;
15289 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15290 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15291 + goto bad_fork_cleanup_vm;
15294 + if (!vx_nproc_avail(1))
15295 + goto bad_fork_cleanup_vm;
15296 if (atomic_read(&p->real_cred->user->processes) >=
15297 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15298 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15299 p->real_cred->user != INIT_USER)
15300 - goto bad_fork_free;
15301 + goto bad_fork_cleanup_vm;
15304 retval = copy_creds(p, clone_flags);
15305 @@ -1297,6 +1327,18 @@ static struct task_struct *copy_process(
15308 spin_unlock(¤t->sighand->siglock);
15310 + /* p is copy of current */
15311 + vxi = p->vx_info;
15313 + claim_vx_info(vxi, p);
15314 + atomic_inc(&vxi->cvirt.nr_threads);
15315 + atomic_inc(&vxi->cvirt.total_forks);
15318 + nxi = p->nx_info;
15320 + claim_nx_info(nxi, p);
15321 write_unlock_irq(&tasklist_lock);
15322 proc_fork_connector(p);
15323 cgroup_post_fork(p);
15324 @@ -1339,6 +1381,9 @@ bad_fork_cleanup_cgroup:
15325 bad_fork_cleanup_count:
15326 atomic_dec(&p->cred->user->processes);
15328 +bad_fork_cleanup_vm:
15329 + if (p->mm && !(clone_flags & CLONE_VM))
15330 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15334 diff -NurpP --minimal linux-2.6.33/kernel/kthread.c linux-2.6.33-vs2.3.0.36.30/kernel/kthread.c
15335 --- linux-2.6.33/kernel/kthread.c 2010-02-25 11:52:09.000000000 +0100
15336 +++ linux-2.6.33-vs2.3.0.36.30/kernel/kthread.c 2010-02-25 12:02:16.000000000 +0100
15338 #include <linux/file.h>
15339 #include <linux/module.h>
15340 #include <linux/mutex.h>
15341 +#include <linux/vs_pid.h>
15342 #include <trace/events/sched.h>
15344 static DEFINE_SPINLOCK(kthread_create_lock);
15345 diff -NurpP --minimal linux-2.6.33/kernel/Makefile linux-2.6.33-vs2.3.0.36.30/kernel/Makefile
15346 --- linux-2.6.33/kernel/Makefile 2010-02-25 11:52:09.000000000 +0100
15347 +++ linux-2.6.33-vs2.3.0.36.30/kernel/Makefile 2010-02-25 12:02:16.000000000 +0100
15348 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
15349 CFLAGS_REMOVE_perf_event.o = -pg
15353 obj-$(CONFIG_FREEZER) += freezer.o
15354 obj-$(CONFIG_PROFILING) += profile.o
15355 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15356 diff -NurpP --minimal linux-2.6.33/kernel/nsproxy.c linux-2.6.33-vs2.3.0.36.30/kernel/nsproxy.c
15357 --- linux-2.6.33/kernel/nsproxy.c 2009-09-10 15:26:28.000000000 +0200
15358 +++ linux-2.6.33-vs2.3.0.36.30/kernel/nsproxy.c 2010-02-25 12:02:16.000000000 +0100
15360 #include <linux/mnt_namespace.h>
15361 #include <linux/utsname.h>
15362 #include <linux/pid_namespace.h>
15363 +#include <linux/vserver/global.h>
15364 +#include <linux/vserver/debug.h>
15365 #include <net/net_namespace.h>
15366 #include <linux/ipc_namespace.h>
15368 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
15369 struct nsproxy *nsproxy;
15371 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15374 atomic_set(&nsproxy->count, 1);
15375 + atomic_inc(&vs_global_nsproxy);
15377 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15381 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
15382 * Return the newly created nsproxy. Do not attach this to the task,
15383 * leave it to the caller to do proper locking and attach it to task.
15385 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15386 - struct task_struct *tsk, struct fs_struct *new_fs)
15387 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15388 + struct nsproxy *orig, struct fs_struct *new_fs)
15390 struct nsproxy *new_nsp;
15393 + vxdprintk(VXD_CBIT(space, 4),
15394 + "unshare_namespaces(0x%08lx,%p,%p)",
15395 + flags, orig, new_fs);
15397 new_nsp = create_nsproxy();
15399 return ERR_PTR(-ENOMEM);
15401 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15402 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15403 if (IS_ERR(new_nsp->mnt_ns)) {
15404 err = PTR_ERR(new_nsp->mnt_ns);
15408 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15409 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15410 if (IS_ERR(new_nsp->uts_ns)) {
15411 err = PTR_ERR(new_nsp->uts_ns);
15415 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15416 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15417 if (IS_ERR(new_nsp->ipc_ns)) {
15418 err = PTR_ERR(new_nsp->ipc_ns);
15422 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15423 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15424 if (IS_ERR(new_nsp->pid_ns)) {
15425 err = PTR_ERR(new_nsp->pid_ns);
15429 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15431 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15432 + if (IS_ERR(new_nsp->user_ns)) {
15433 + err = PTR_ERR(new_nsp->user_ns);
15437 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15438 if (IS_ERR(new_nsp->net_ns)) {
15439 err = PTR_ERR(new_nsp->net_ns);
15441 @@ -100,6 +116,38 @@ out_ns:
15442 return ERR_PTR(err);
15445 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15446 + struct fs_struct *new_fs)
15448 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15452 + * copies the nsproxy, setting refcount to 1, and grabbing a
15453 + * reference to all contained namespaces.
15455 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15457 + struct nsproxy *ns = create_nsproxy();
15460 + memcpy(ns, orig, sizeof(struct nsproxy));
15461 + atomic_set(&ns->count, 1);
15464 + get_mnt_ns(ns->mnt_ns);
15466 + get_uts_ns(ns->uts_ns);
15468 + get_ipc_ns(ns->ipc_ns);
15470 + get_pid_ns(ns->pid_ns);
15472 + get_net(ns->net_ns);
15478 * called from clone. This now handles copy for nsproxy and all
15479 * namespaces therein.
15480 @@ -107,9 +155,12 @@ out_ns:
15481 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15483 struct nsproxy *old_ns = tsk->nsproxy;
15484 - struct nsproxy *new_ns;
15485 + struct nsproxy *new_ns = NULL;
15488 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15489 + flags, tsk, old_ns);
15494 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
15495 CLONE_NEWPID | CLONE_NEWNET)))
15498 - if (!capable(CAP_SYS_ADMIN)) {
15499 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15503 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
15506 put_nsproxy(old_ns);
15507 + vxdprintk(VXD_CBIT(space, 3),
15508 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15509 + flags, tsk, old_ns, err, new_ns);
15513 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
15514 put_ipc_ns(ns->ipc_ns);
15516 put_pid_ns(ns->pid_ns);
15517 - put_net(ns->net_ns);
15519 + put_net(ns->net_ns);
15520 + atomic_dec(&vs_global_nsproxy);
15521 kmem_cache_free(nsproxy_cachep, ns);
15524 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned
15528 + vxdprintk(VXD_CBIT(space, 4),
15529 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15530 + unshare_flags, current->nsproxy);
15532 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15536 - if (!capable(CAP_SYS_ADMIN))
15537 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15540 *new_nsp = create_new_namespaces(unshare_flags, current,
15541 diff -NurpP --minimal linux-2.6.33/kernel/pid.c linux-2.6.33-vs2.3.0.36.30/kernel/pid.c
15542 --- linux-2.6.33/kernel/pid.c 2010-02-25 11:52:09.000000000 +0100
15543 +++ linux-2.6.33-vs2.3.0.36.30/kernel/pid.c 2010-02-25 12:02:16.000000000 +0100
15545 #include <linux/pid_namespace.h>
15546 #include <linux/init_task.h>
15547 #include <linux/syscalls.h>
15548 +#include <linux/vs_pid.h>
15550 #define pid_hashfn(nr, ns) \
15551 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15552 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15554 struct pid *find_vpid(int nr)
15556 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15557 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15559 EXPORT_SYMBOL_GPL(find_vpid);
15561 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
15562 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15564 struct task_struct *result = NULL;
15566 + if (type == PIDTYPE_REALPID)
15567 + type = PIDTYPE_PID;
15569 struct hlist_node *first;
15570 first = rcu_dereference(pid->tasks[type].first);
15571 @@ -380,7 +384,7 @@ EXPORT_SYMBOL(pid_task);
15573 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15575 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15576 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15579 struct task_struct *find_task_by_vpid(pid_t vnr)
15580 @@ -422,7 +426,7 @@ struct pid *find_get_pid(pid_t nr)
15582 EXPORT_SYMBOL_GPL(find_get_pid);
15584 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15585 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15589 @@ -435,6 +439,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15593 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15595 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15598 pid_t pid_vnr(struct pid *pid)
15600 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15601 diff -NurpP --minimal linux-2.6.33/kernel/pid_namespace.c linux-2.6.33-vs2.3.0.36.30/kernel/pid_namespace.c
15602 --- linux-2.6.33/kernel/pid_namespace.c 2009-12-03 20:02:58.000000000 +0100
15603 +++ linux-2.6.33-vs2.3.0.36.30/kernel/pid_namespace.c 2010-02-25 12:02:16.000000000 +0100
15605 #include <linux/syscalls.h>
15606 #include <linux/err.h>
15607 #include <linux/acct.h>
15608 +#include <linux/vserver/global.h>
15610 #define BITS_PER_PAGE (PAGE_SIZE*8)
15612 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
15615 kref_init(&ns->kref);
15616 + atomic_inc(&vs_global_pid_ns);
15618 ns->parent = get_pid_ns(parent_pid_ns);
15620 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
15622 for (i = 0; i < PIDMAP_ENTRIES; i++)
15623 kfree(ns->pidmap[i].page);
15624 + atomic_dec(&vs_global_pid_ns);
15625 kmem_cache_free(pid_ns_cachep, ns);
15628 diff -NurpP --minimal linux-2.6.33/kernel/posix-timers.c linux-2.6.33-vs2.3.0.36.30/kernel/posix-timers.c
15629 --- linux-2.6.33/kernel/posix-timers.c 2009-12-03 20:02:58.000000000 +0100
15630 +++ linux-2.6.33-vs2.3.0.36.30/kernel/posix-timers.c 2010-02-25 12:02:16.000000000 +0100
15632 #include <linux/wait.h>
15633 #include <linux/workqueue.h>
15634 #include <linux/module.h>
15635 +#include <linux/vs_context.h>
15638 * Management arrays for POSIX timers. Timers are kept in slab memory
15639 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15641 struct task_struct *task;
15642 int shared, ret = -1;
15645 * FIXME: if ->sigq is queued we can race with
15646 * dequeue_signal()->do_schedule_next_timer().
15647 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15649 task = pid_task(timr->it_pid, PIDTYPE_PID);
15651 + struct vx_info_save vxis;
15652 + struct vx_info *vxi;
15654 + vxi = get_vx_info(task->vx_info);
15655 + enter_vx_info(vxi, &vxis);
15656 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15657 ret = send_sigqueue(timr->sigq, task, shared);
15658 + leave_vx_info(&vxis);
15659 + put_vx_info(vxi);
15663 /* If we failed to send the signal the timer stops. */
15666 diff -NurpP --minimal linux-2.6.33/kernel/printk.c linux-2.6.33-vs2.3.0.36.30/kernel/printk.c
15667 --- linux-2.6.33/kernel/printk.c 2010-02-25 11:52:09.000000000 +0100
15668 +++ linux-2.6.33-vs2.3.0.36.30/kernel/printk.c 2010-02-25 13:11:15.000000000 +0100
15670 #include <linux/kexec.h>
15671 #include <linux/ratelimit.h>
15672 #include <linux/kmsg_dump.h>
15673 +#include <linux/vs_cvirt.h>
15675 #include <asm/uaccess.h>
15677 @@ -278,18 +279,13 @@ int do_syslog(int type, char __user *buf
15678 unsigned i, j, limit, count;
15684 error = security_syslog(type);
15689 - case 0: /* Close log */
15691 - case 1: /* Open log */
15693 - case 2: /* Read from log */
15694 + if ((type >= 2) && (type <= 4)) {
15696 if (!buf || len < 0)
15698 @@ -300,6 +296,16 @@ int do_syslog(int type, char __user *buf
15703 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15704 + return vx_do_syslog(type, buf, len);
15707 + case 0: /* Close log */
15709 + case 1: /* Open log */
15711 + case 2: /* Read from log */
15712 error = wait_event_interruptible(log_wait,
15713 (log_start - log_end));
15715 @@ -324,16 +330,6 @@ int do_syslog(int type, char __user *buf
15718 case 3: /* Read last kernel messages */
15720 - if (!buf || len < 0)
15725 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15730 if (count > log_buf_len)
15731 count = log_buf_len;
15732 diff -NurpP --minimal linux-2.6.33/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30/kernel/ptrace.c
15733 --- linux-2.6.33/kernel/ptrace.c 2009-12-03 20:02:58.000000000 +0100
15734 +++ linux-2.6.33-vs2.3.0.36.30/kernel/ptrace.c 2010-02-25 12:02:16.000000000 +0100
15736 #include <linux/pid_namespace.h>
15737 #include <linux/syscalls.h>
15738 #include <linux/uaccess.h>
15739 +#include <linux/vs_context.h>
15743 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
15744 dumpable = get_dumpable(task->mm);
15745 if (!dumpable && !capable(CAP_SYS_PTRACE))
15747 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15749 + if (!vx_check(task->xid, VS_IDENT) &&
15750 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15753 return security_ptrace_access_check(task, mode);
15755 @@ -621,6 +627,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15760 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15761 + goto out_put_task_struct;
15763 if (request == PTRACE_ATTACH) {
15764 ret = ptrace_attach(child);
15766 diff -NurpP --minimal linux-2.6.33/kernel/sched.c linux-2.6.33-vs2.3.0.36.30/kernel/sched.c
15767 --- linux-2.6.33/kernel/sched.c 2010-02-25 11:52:09.000000000 +0100
15768 +++ linux-2.6.33-vs2.3.0.36.30/kernel/sched.c 2010-02-25 14:42:44.000000000 +0100
15770 #include <linux/debugfs.h>
15771 #include <linux/ctype.h>
15772 #include <linux/ftrace.h>
15773 +#include <linux/vs_sched.h>
15774 +#include <linux/vs_cvirt.h>
15776 #include <asm/tlb.h>
15777 #include <asm/irq_regs.h>
15778 @@ -3009,9 +3011,17 @@ EXPORT_SYMBOL(avenrun);
15780 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15782 - loads[0] = (avenrun[0] + offset) << shift;
15783 - loads[1] = (avenrun[1] + offset) << shift;
15784 - loads[2] = (avenrun[2] + offset) << shift;
15785 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15786 + struct vx_info *vxi = current_vx_info();
15788 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15789 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15790 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15792 + loads[0] = (avenrun[0] + offset) << shift;
15793 + loads[1] = (avenrun[1] + offset) << shift;
15794 + loads[2] = (avenrun[2] + offset) << shift;
15798 static unsigned long
15799 @@ -5046,16 +5056,19 @@ void account_user_time(struct task_struc
15800 cputime_t cputime_scaled)
15802 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15803 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15805 + int nice = (TASK_NICE(p) > 0);
15807 /* Add user time to process. */
15808 p->utime = cputime_add(p->utime, cputime);
15809 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15810 + vx_account_user(vxi, cputime, nice);
15811 account_group_user_time(p, cputime);
15813 /* Add user time to cpustat. */
15814 tmp = cputime_to_cputime64(cputime);
15815 - if (TASK_NICE(p) > 0)
15817 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15819 cpustat->user = cputime64_add(cpustat->user, tmp);
15820 @@ -5106,6 +5119,7 @@ void account_system_time(struct task_str
15821 cputime_t cputime, cputime_t cputime_scaled)
15823 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15824 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15827 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15828 @@ -5116,6 +5130,7 @@ void account_system_time(struct task_str
15829 /* Add system time to process. */
15830 p->stime = cputime_add(p->stime, cputime);
15831 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15832 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15833 account_group_system_time(p, cputime);
15835 /* Add system time to cpustat. */
15836 @@ -6180,7 +6195,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15839 if (increment < 0 && !can_nice(current, nice))
15841 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15843 retval = security_task_setnice(current, nice);
15845 diff -NurpP --minimal linux-2.6.33/kernel/sched_debug.c linux-2.6.33-vs2.3.0.36.30/kernel/sched_debug.c
15846 --- linux-2.6.33/kernel/sched_debug.c 2010-02-25 11:52:09.000000000 +0100
15847 +++ linux-2.6.33-vs2.3.0.36.30/kernel/sched_debug.c 2010-02-25 12:02:16.000000000 +0100
15848 @@ -80,6 +80,11 @@ static void print_cfs_group_stats(struct
15852 +#ifdef CONFIG_CFS_HARD_LIMITS
15853 + PN(se->throttle_max);
15854 + PN(se->throttle_sum);
15855 + P(se->throttle_count);
15858 P(se->load.weight);
15860 @@ -214,6 +219,16 @@ void print_cfs_rq(struct seq_file *m, in
15862 SEQ_printf(m, " .%-30s: %lu\n", "shares", cfs_rq->shares);
15864 +#ifdef CONFIG_CFS_HARD_LIMITS
15865 + spin_lock_irqsave(&rq->lock, flags);
15866 + SEQ_printf(m, " .%-30s: %d\n", "cfs_throttled",
15867 + cfs_rq->cfs_throttled);
15868 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_time",
15869 + SPLIT_NS(cfs_rq->cfs_time));
15870 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "cfs_runtime",
15871 + SPLIT_NS(cfs_rq->cfs_runtime));
15872 + spin_unlock_irqrestore(&rq->lock, flags);
15873 +#endif /* CONFIG_CFS_HARD_LIMITS */
15874 print_cfs_group_stats(m, cpu, cfs_rq->tg);
15877 @@ -320,7 +335,7 @@ static int sched_debug_show(struct seq_f
15878 u64 now = ktime_to_ns(ktime_get());
15881 - SEQ_printf(m, "Sched Debug Version: v0.09, %s %.*s\n",
15882 + SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n",
15883 init_utsname()->release,
15884 (int)strcspn(init_utsname()->version, " "),
15885 init_utsname()->version);
15886 diff -NurpP --minimal linux-2.6.33/kernel/sched_fair.c linux-2.6.33-vs2.3.0.36.30/kernel/sched_fair.c
15887 --- linux-2.6.33/kernel/sched_fair.c 2010-02-25 11:52:09.000000000 +0100
15888 +++ linux-2.6.33-vs2.3.0.36.30/kernel/sched_fair.c 2010-02-25 14:42:58.000000000 +0100
15889 @@ -794,6 +794,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15890 check_spread(cfs_rq, se);
15891 if (se != cfs_rq->curr)
15892 __enqueue_entity(cfs_rq, se);
15894 + if (entity_is_task(se))
15895 + vx_activate_task(task_of(se));
15898 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15899 @@ -837,6 +840,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15901 if (se != cfs_rq->curr)
15902 __dequeue_entity(cfs_rq, se);
15903 + if (entity_is_task(se))
15904 + vx_deactivate_task(task_of(se));
15905 account_entity_dequeue(cfs_rq, se);
15906 update_min_vruntime(cfs_rq);
15908 diff -NurpP --minimal linux-2.6.33/kernel/signal.c linux-2.6.33-vs2.3.0.36.30/kernel/signal.c
15909 --- linux-2.6.33/kernel/signal.c 2010-02-25 11:52:09.000000000 +0100
15910 +++ linux-2.6.33-vs2.3.0.36.30/kernel/signal.c 2010-02-25 13:10:38.000000000 +0100
15912 #include <linux/freezer.h>
15913 #include <linux/pid_namespace.h>
15914 #include <linux/nsproxy.h>
15915 +#include <linux/vs_context.h>
15916 +#include <linux/vs_pid.h>
15917 #define CREATE_TRACE_POINTS
15918 #include <trace/events/signal.h>
15920 @@ -629,9 +631,18 @@ static int check_kill_permission(int sig
15924 + vxdprintk(VXD_CBIT(misc, 7),
15925 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15926 + sig, info, t, vx_task_xid(t), t->pid);
15928 if (!valid_signal(sig))
15931 +/* FIXME: needed? if so, why?
15932 + if ((info != SEND_SIG_NOINFO) &&
15933 + (is_si_special(info) || !si_fromuser(info)))
15936 if (!si_fromuser(info))
15939 @@ -659,6 +670,20 @@ static int check_kill_permission(int sig
15944 + if (t->pid == 1 && current->xid)
15948 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15949 + loops, maybe ENOENT or EACCES? */
15950 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15951 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15952 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15953 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15957 return security_task_kill(t, info, sig, 0);
15960 @@ -1147,7 +1172,7 @@ int kill_pid_info(int sig, struct siginf
15963 p = pid_task(pid, PIDTYPE_PID);
15965 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15966 error = group_send_sig_info(sig, info, p);
15967 if (unlikely(error == -ESRCH))
15969 @@ -1187,7 +1212,7 @@ int kill_pid_info_as_uid(int sig, struct
15972 p = pid_task(pid, PIDTYPE_PID);
15974 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15978 @@ -1242,8 +1267,10 @@ static int kill_something_info(int sig,
15979 struct task_struct * p;
15981 for_each_process(p) {
15982 - if (task_pid_vnr(p) > 1 &&
15983 - !same_thread_group(p, current)) {
15984 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15985 + task_pid_vnr(p) > 1 &&
15986 + !same_thread_group(p, current) &&
15987 + !vx_current_initpid(p->pid)) {
15988 int err = group_send_sig_info(sig, info, p);
15991 @@ -1910,6 +1937,11 @@ relock:
15992 !sig_kernel_only(signr))
15995 + /* virtual init is protected against user signals */
15996 + if ((info->si_code == SI_USER) &&
15997 + vx_current_initpid(current->pid))
16000 if (sig_kernel_stop(signr)) {
16002 * The default action is to stop all threads in
16003 diff -NurpP --minimal linux-2.6.33/kernel/softirq.c linux-2.6.33-vs2.3.0.36.30/kernel/softirq.c
16004 --- linux-2.6.33/kernel/softirq.c 2010-02-25 11:52:09.000000000 +0100
16005 +++ linux-2.6.33-vs2.3.0.36.30/kernel/softirq.c 2010-02-25 12:02:16.000000000 +0100
16007 #include <linux/ftrace.h>
16008 #include <linux/smp.h>
16009 #include <linux/tick.h>
16010 +#include <linux/vs_context.h>
16012 #define CREATE_TRACE_POINTS
16013 #include <trace/events/irq.h>
16014 diff -NurpP --minimal linux-2.6.33/kernel/sys.c linux-2.6.33-vs2.3.0.36.30/kernel/sys.c
16015 --- linux-2.6.33/kernel/sys.c 2010-02-25 11:52:09.000000000 +0100
16016 +++ linux-2.6.33-vs2.3.0.36.30/kernel/sys.c 2010-02-25 13:13:03.000000000 +0100
16018 #include <linux/syscalls.h>
16019 #include <linux/kprobes.h>
16020 #include <linux/user_namespace.h>
16021 +#include <linux/vs_pid.h>
16023 #include <asm/uaccess.h>
16024 #include <asm/io.h>
16025 @@ -129,7 +130,10 @@ static int set_one_prio(struct task_stru
16028 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16030 + if (vx_flags(VXF_IGNEG_NICE, 0))
16036 no_nice = security_task_setnice(p, niceval);
16037 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
16039 pgrp = task_pgrp(current);
16040 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16041 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16043 error = set_one_prio(p, niceval, error);
16044 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16046 @@ -242,6 +248,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
16048 pgrp = task_pgrp(current);
16049 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16050 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16052 niceval = 20 - task_nice(p);
16053 if (niceval > retval)
16055 @@ -355,6 +363,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
16057 static DEFINE_MUTEX(reboot_mutex);
16059 +long vs_reboot(unsigned int, void __user *);
16062 * Reboot system call: for obvious reasons only root may call it,
16063 * and even root needs to set up some magic numbers in the registers
16064 @@ -387,6 +397,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
16065 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16066 cmd = LINUX_REBOOT_CMD_HALT;
16068 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16069 + return vs_reboot(cmd, arg);
16071 mutex_lock(&reboot_mutex);
16073 case LINUX_REBOOT_CMD_RESTART:
16074 @@ -1136,7 +1149,7 @@ SYSCALL_DEFINE2(sethostname, char __user
16076 char tmp[__NEW_UTS_LEN];
16078 - if (!capable(CAP_SYS_ADMIN))
16079 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16081 if (len < 0 || len > __NEW_UTS_LEN)
16083 @@ -1185,7 +1198,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
16085 char tmp[__NEW_UTS_LEN];
16087 - if (!capable(CAP_SYS_ADMIN))
16088 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16090 if (len < 0 || len > __NEW_UTS_LEN)
16092 @@ -1254,7 +1267,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
16094 old_rlim = current->signal->rlim + resource;
16095 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
16096 - !capable(CAP_SYS_RESOURCE))
16097 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
16099 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
16101 diff -NurpP --minimal linux-2.6.33/kernel/sysctl_binary.c linux-2.6.33-vs2.3.0.36.30/kernel/sysctl_binary.c
16102 --- linux-2.6.33/kernel/sysctl_binary.c 2010-02-25 11:52:09.000000000 +0100
16103 +++ linux-2.6.33-vs2.3.0.36.30/kernel/sysctl_binary.c 2010-02-25 12:40:06.000000000 +0100
16104 @@ -71,6 +71,7 @@ static const struct bin_table bin_kern_t
16106 { CTL_INT, KERN_PANIC, "panic" },
16107 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
16108 + { CTL_STR, KERN_VSHELPER, "vshelper" },
16110 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
16111 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
16112 diff -NurpP --minimal linux-2.6.33/kernel/sysctl.c linux-2.6.33-vs2.3.0.36.30/kernel/sysctl.c
16113 --- linux-2.6.33/kernel/sysctl.c 2010-02-25 11:52:09.000000000 +0100
16114 +++ linux-2.6.33-vs2.3.0.36.30/kernel/sysctl.c 2010-02-25 14:43:48.000000000 +0100
16115 @@ -123,6 +123,7 @@ static int ngroups_max = NGROUPS_MAX;
16116 extern char modprobe_path[];
16117 extern int modules_disabled;
16119 +extern char vshelper_path[];
16120 #ifdef CONFIG_CHR_DEV_SG
16121 extern int sg_big_buff;
16123 @@ -553,6 +554,13 @@ static struct ctl_table kern_table[] = {
16124 .proc_handler = proc_dostring,
16128 + .procname = "vshelper",
16129 + .data = &vshelper_path,
16132 + .proc_handler = &proc_dostring,
16134 #ifdef CONFIG_CHR_DEV_SG
16136 .procname = "sg-big-buff",
16137 diff -NurpP --minimal linux-2.6.33/kernel/time.c linux-2.6.33-vs2.3.0.36.30/kernel/time.c
16138 --- linux-2.6.33/kernel/time.c 2010-02-25 11:52:09.000000000 +0100
16139 +++ linux-2.6.33-vs2.3.0.36.30/kernel/time.c 2010-02-25 12:02:16.000000000 +0100
16140 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
16141 SYSCALL_DEFINE1(time, time_t __user *, tloc)
16143 time_t i = get_seconds();
16144 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
16147 if (put_user(i,tloc))
16148 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
16152 - do_settimeofday(&tv);
16153 + vx_settimeofday(&tv);
16157 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
16159 if (likely(tv != NULL)) {
16160 struct timeval ktv;
16161 - do_gettimeofday(&ktv);
16162 + vx_gettimeofday(&ktv);
16163 if (copy_to_user(tv, &ktv, sizeof(ktv)))
16166 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
16167 /* SMP safe, again the code in arch/foo/time.c should
16168 * globally block out interrupts when it runs.
16170 - return do_settimeofday(tv);
16171 + return vx_settimeofday(tv);
16175 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
16179 - do_gettimeofday(&x);
16180 + vx_gettimeofday(&x);
16181 tv->tv_sec = x.tv_sec;
16182 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
16184 diff -NurpP --minimal linux-2.6.33/kernel/timer.c linux-2.6.33-vs2.3.0.36.30/kernel/timer.c
16185 --- linux-2.6.33/kernel/timer.c 2010-02-25 11:52:09.000000000 +0100
16186 +++ linux-2.6.33-vs2.3.0.36.30/kernel/timer.c 2010-02-25 12:02:16.000000000 +0100
16188 #include <linux/kallsyms.h>
16189 #include <linux/perf_event.h>
16190 #include <linux/sched.h>
16191 +#include <linux/vs_base.h>
16192 +#include <linux/vs_cvirt.h>
16193 +#include <linux/vs_pid.h>
16194 +#include <linux/vserver/sched.h>
16196 #include <asm/uaccess.h>
16197 #include <asm/unistd.h>
16198 @@ -1252,12 +1256,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
16205 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
16206 - * should be moved into arch/i386 instead?
16210 * sys_getpid - return the thread group id of the current process
16211 @@ -1286,10 +1284,23 @@ SYSCALL_DEFINE0(getppid)
16213 pid = task_tgid_vnr(current->real_parent);
16215 + return vx_map_pid(pid);
16222 + * The Alpha uses getxpid, getxuid, and getxgid instead.
16225 +asmlinkage long do_getxpid(long *ppid)
16227 + *ppid = sys_getppid();
16228 + return sys_getpid();
16231 +#else /* _alpha_ */
16233 SYSCALL_DEFINE0(getuid)
16235 /* Only we change this so SMP safe */
16236 diff -NurpP --minimal linux-2.6.33/kernel/user.c linux-2.6.33-vs2.3.0.36.30/kernel/user.c
16237 --- linux-2.6.33/kernel/user.c 2009-12-03 20:02:58.000000000 +0100
16238 +++ linux-2.6.33-vs2.3.0.36.30/kernel/user.c 2010-02-25 12:02:16.000000000 +0100
16239 @@ -251,10 +251,10 @@ static struct kobj_type uids_ktype = {
16241 * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
16243 -static int uids_user_create(struct user_struct *up)
16244 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
16246 struct kobject *kobj = &up->kobj;
16250 memset(kobj, 0, sizeof(struct kobject));
16251 if (up->user_ns != &init_user_ns)
16252 @@ -282,7 +282,7 @@ int __init uids_sysfs_init(void)
16256 - return uids_user_create(&root_user);
16257 + return uids_user_create(NULL, &root_user);
16260 /* delayed work function to remove sysfs directory for a user and free up
16261 @@ -353,7 +353,8 @@ static struct user_struct *uid_hash_find
16264 int uids_sysfs_init(void) { return 0; }
16265 -static inline int uids_user_create(struct user_struct *up) { return 0; }
16266 +static inline int uids_user_create(struct user_namespace *ns,
16267 + struct user_struct *up) { return 0; }
16268 static inline void uids_mutex_lock(void) { }
16269 static inline void uids_mutex_unlock(void) { }
16271 @@ -450,7 +451,7 @@ struct user_struct *alloc_uid(struct use
16273 new->user_ns = get_user_ns(ns);
16275 - if (uids_user_create(new))
16276 + if (uids_user_create(ns, new))
16277 goto out_destoy_sched;
16280 diff -NurpP --minimal linux-2.6.33/kernel/user_namespace.c linux-2.6.33-vs2.3.0.36.30/kernel/user_namespace.c
16281 --- linux-2.6.33/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
16282 +++ linux-2.6.33-vs2.3.0.36.30/kernel/user_namespace.c 2010-02-25 12:02:16.000000000 +0100
16284 #include <linux/slab.h>
16285 #include <linux/user_namespace.h>
16286 #include <linux/cred.h>
16287 +#include <linux/vserver/global.h>
16290 * Create a new user namespace, deriving the creator from the user in the
16291 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
16294 kref_init(&ns->kref);
16295 + atomic_inc(&vs_global_user_ns);
16297 for (n = 0; n < UIDHASH_SZ; ++n)
16298 INIT_HLIST_HEAD(ns->uidhash_table + n);
16299 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
16300 struct user_namespace *ns =
16301 container_of(kref, struct user_namespace, kref);
16303 + /* FIXME: maybe move into destroyer? */
16304 + atomic_dec(&vs_global_user_ns);
16305 INIT_WORK(&ns->destroyer, free_user_ns_work);
16306 schedule_work(&ns->destroyer);
16308 diff -NurpP --minimal linux-2.6.33/kernel/utsname.c linux-2.6.33-vs2.3.0.36.30/kernel/utsname.c
16309 --- linux-2.6.33/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
16310 +++ linux-2.6.33-vs2.3.0.36.30/kernel/utsname.c 2010-02-25 12:02:16.000000000 +0100
16311 @@ -14,14 +14,17 @@
16312 #include <linux/utsname.h>
16313 #include <linux/err.h>
16314 #include <linux/slab.h>
16315 +#include <linux/vserver/global.h>
16317 static struct uts_namespace *create_uts_ns(void)
16319 struct uts_namespace *uts_ns;
16321 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
16324 kref_init(&uts_ns->kref);
16325 + atomic_inc(&vs_global_uts_ns);
16330 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
16331 struct uts_namespace *ns;
16333 ns = container_of(kref, struct uts_namespace, kref);
16334 + atomic_dec(&vs_global_uts_ns);
16337 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cacct.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cacct.c
16338 --- linux-2.6.33/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16339 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cacct.c 2010-02-25 12:02:16.000000000 +0100
16342 + * linux/kernel/vserver/cacct.c
16344 + * Virtual Server: Context Accounting
16346 + * Copyright (C) 2006-2007 Herbert Pötzl
16348 + * V0.01 added accounting stats
16352 +#include <linux/types.h>
16353 +#include <linux/vs_context.h>
16354 +#include <linux/vserver/cacct_cmd.h>
16355 +#include <linux/vserver/cacct_int.h>
16357 +#include <asm/errno.h>
16358 +#include <asm/uaccess.h>
16361 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16363 + struct vcmd_sock_stat_v0 vc_data;
16366 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16369 + field = vc_data.field;
16370 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16373 + for (j = 0; j < 3; j++) {
16374 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16375 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16378 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16383 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cacct_init.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cacct_init.h
16384 --- linux-2.6.33/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16385 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cacct_init.h 2010-02-25 12:02:16.000000000 +0100
16389 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16394 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16395 + for (j = 0; j < 3; j++) {
16396 + atomic_long_set(&cacct->sock[i][j].count, 0);
16397 + atomic_long_set(&cacct->sock[i][j].total, 0);
16400 + for (i = 0; i < 8; i++)
16401 + atomic_set(&cacct->slab[i], 0);
16402 + for (i = 0; i < 5; i++)
16403 + for (j = 0; j < 4; j++)
16404 + atomic_set(&cacct->page[i][j], 0);
16407 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16412 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cacct_proc.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cacct_proc.h
16413 --- linux-2.6.33/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16414 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cacct_proc.h 2010-02-25 12:02:16.000000000 +0100
16416 +#ifndef _VX_CACCT_PROC_H
16417 +#define _VX_CACCT_PROC_H
16419 +#include <linux/vserver/cacct_int.h>
16422 +#define VX_SOCKA_TOP \
16423 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16425 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16427 + int i, j, length = 0;
16428 + static char *type[VXA_SOCK_SIZE] = {
16429 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16432 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16433 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16434 + length += sprintf(buffer + length, "%s:", type[i]);
16435 + for (j = 0; j < 3; j++) {
16436 + length += sprintf(buffer + length,
16437 + "\t%10lu/%-10lu",
16438 + vx_sock_count(cacct, i, j),
16439 + vx_sock_total(cacct, i, j));
16441 + buffer[length++] = '\n';
16444 + length += sprintf(buffer + length, "\n");
16445 + length += sprintf(buffer + length,
16446 + "slab:\t %8u %8u %8u %8u\n",
16447 + atomic_read(&cacct->slab[1]),
16448 + atomic_read(&cacct->slab[4]),
16449 + atomic_read(&cacct->slab[0]),
16450 + atomic_read(&cacct->slab[2]));
16452 + length += sprintf(buffer + length, "\n");
16453 + for (i = 0; i < 5; i++) {
16454 + length += sprintf(buffer + length,
16455 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16456 + atomic_read(&cacct->page[i][0]),
16457 + atomic_read(&cacct->page[i][1]),
16458 + atomic_read(&cacct->page[i][2]),
16459 + atomic_read(&cacct->page[i][3]),
16460 + atomic_read(&cacct->page[i][4]),
16461 + atomic_read(&cacct->page[i][5]),
16462 + atomic_read(&cacct->page[i][6]),
16463 + atomic_read(&cacct->page[i][7]));
16468 +#endif /* _VX_CACCT_PROC_H */
16469 diff -NurpP --minimal linux-2.6.33/kernel/vserver/context.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/context.c
16470 --- linux-2.6.33/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16471 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/context.c 2010-02-25 12:02:16.000000000 +0100
16474 + * linux/kernel/vserver/context.c
16476 + * Virtual Server: Context Support
16478 + * Copyright (C) 2003-2007 Herbert Pötzl
16480 + * V0.01 context helper
16481 + * V0.02 vx_ctx_kill syscall command
16482 + * V0.03 replaced context_info calls
16483 + * V0.04 redesign of struct (de)alloc
16484 + * V0.05 rlimit basic implementation
16485 + * V0.06 task_xid and info commands
16486 + * V0.07 context flags and caps
16487 + * V0.08 switch to RCU based hash
16488 + * V0.09 revert to non RCU for now
16489 + * V0.10 and back to working RCU hash
16490 + * V0.11 and back to locking again
16491 + * V0.12 referenced context store
16492 + * V0.13 separate per cpu data
16493 + * V0.14 changed vcmds to vxi arg
16494 + * V0.15 added context stat
16495 + * V0.16 have __create claim() the vxi
16496 + * V0.17 removed older and legacy stuff
16500 +#include <linux/slab.h>
16501 +#include <linux/types.h>
16502 +#include <linux/security.h>
16503 +#include <linux/pid_namespace.h>
16505 +#include <linux/vserver/context.h>
16506 +#include <linux/vserver/network.h>
16507 +#include <linux/vserver/debug.h>
16508 +#include <linux/vserver/limit.h>
16509 +#include <linux/vserver/limit_int.h>
16510 +#include <linux/vserver/space.h>
16511 +#include <linux/init_task.h>
16512 +#include <linux/fs_struct.h>
16514 +#include <linux/vs_context.h>
16515 +#include <linux/vs_limit.h>
16516 +#include <linux/vs_pid.h>
16517 +#include <linux/vserver/context_cmd.h>
16519 +#include "cvirt_init.h"
16520 +#include "cacct_init.h"
16521 +#include "limit_init.h"
16522 +#include "sched_init.h"
16525 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16526 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16529 +/* now inactive context structures */
16531 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16533 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16536 +/* __alloc_vx_info()
16538 + * allocate an initialized vx_info struct
16539 + * doesn't make it visible (hash) */
16541 +static struct vx_info *__alloc_vx_info(xid_t xid)
16543 + struct vx_info *new = NULL;
16546 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16548 + /* would this benefit from a slab cache? */
16549 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16553 + memset(new, 0, sizeof(struct vx_info));
16555 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16556 + if (!new->ptr_pc)
16559 + new->vx_id = xid;
16560 + INIT_HLIST_NODE(&new->vx_hlist);
16561 + atomic_set(&new->vx_usecnt, 0);
16562 + atomic_set(&new->vx_tasks, 0);
16563 + new->vx_parent = NULL;
16564 + new->vx_state = 0;
16565 + init_waitqueue_head(&new->vx_wait);
16567 + /* prepare reaper */
16568 + get_task_struct(init_pid_ns.child_reaper);
16569 + new->vx_reaper = init_pid_ns.child_reaper;
16570 + new->vx_badness_bias = 0;
16572 + /* rest of init goes here */
16573 + vx_info_init_limit(&new->limit);
16574 + vx_info_init_sched(&new->sched);
16575 + vx_info_init_cvirt(&new->cvirt);
16576 + vx_info_init_cacct(&new->cacct);
16578 + /* per cpu data structures */
16579 + for_each_possible_cpu(cpu) {
16580 + vx_info_init_sched_pc(
16581 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16582 + vx_info_init_cvirt_pc(
16583 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16586 + new->vx_flags = VXF_INIT_SET;
16587 + cap_set_init_eff(new->vx_bcaps);
16588 + new->vx_ccaps = 0;
16589 + new->vx_umask = 0;
16591 + new->reboot_cmd = 0;
16592 + new->exit_code = 0;
16594 + // preconfig fs entries
16595 + for (index = 0; index < VX_SPACES; index++) {
16596 + write_lock(&init_fs.lock);
16598 + write_unlock(&init_fs.lock);
16599 + new->vx_fs[index] = &init_fs;
16602 + vxdprintk(VXD_CBIT(xid, 0),
16603 + "alloc_vx_info(%d) = %p", xid, new);
16604 + vxh_alloc_vx_info(new);
16605 + atomic_inc(&vx_global_ctotal);
16614 +/* __dealloc_vx_info()
16616 + * final disposal of vx_info */
16618 +static void __dealloc_vx_info(struct vx_info *vxi)
16620 + struct vx_info_save vxis;
16623 + vxdprintk(VXD_CBIT(xid, 0),
16624 + "dealloc_vx_info(%p)", vxi);
16625 + vxh_dealloc_vx_info(vxi);
16627 +#ifdef CONFIG_VSERVER_WARN
16628 + enter_vx_info(vxi, &vxis);
16629 + vx_info_exit_limit(&vxi->limit);
16630 + vx_info_exit_sched(&vxi->sched);
16631 + vx_info_exit_cvirt(&vxi->cvirt);
16632 + vx_info_exit_cacct(&vxi->cacct);
16634 + for_each_possible_cpu(cpu) {
16635 + vx_info_exit_sched_pc(
16636 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16637 + vx_info_exit_cvirt_pc(
16638 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16640 + leave_vx_info(&vxis);
16644 + vxi->vx_state |= VXS_RELEASED;
16647 + free_percpu(vxi->ptr_pc);
16650 + atomic_dec(&vx_global_ctotal);
16653 +static void __shutdown_vx_info(struct vx_info *vxi)
16655 + struct nsproxy *nsproxy;
16656 + struct fs_struct *fs;
16661 + vxi->vx_state |= VXS_SHUTDOWN;
16662 + vs_state_change(vxi, VSC_SHUTDOWN);
16664 + for (index = 0; index < VX_SPACES; index++) {
16665 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
16667 + put_nsproxy(nsproxy);
16669 + fs = xchg(&vxi->vx_fs[index], NULL);
16670 + write_lock(&fs->lock);
16671 + kill = !--fs->users;
16672 + write_unlock(&fs->lock);
16674 + free_fs_struct(fs);
16678 +/* exported stuff */
16680 +void free_vx_info(struct vx_info *vxi)
16682 + unsigned long flags;
16685 + /* check for reference counts first */
16686 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16687 + BUG_ON(atomic_read(&vxi->vx_tasks));
16689 + /* context must not be hashed */
16690 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16692 + /* context shutdown is mandatory */
16693 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16695 + /* nsproxy and fs check */
16696 + for (index = 0; index < VX_SPACES; index++) {
16697 + BUG_ON(vxi->vx_nsproxy[index]);
16698 + BUG_ON(vxi->vx_fs[index]);
16701 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16702 + hlist_del(&vxi->vx_hlist);
16703 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16705 + __dealloc_vx_info(vxi);
16709 +/* hash table for vx_info hash */
16711 +#define VX_HASH_SIZE 13
16713 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16714 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16716 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16719 +static inline unsigned int __hashval(xid_t xid)
16721 + return (xid % VX_HASH_SIZE);
16726 +/* __hash_vx_info()
16728 + * add the vxi to the global hash table
16729 + * requires the hash_lock to be held */
16731 +static inline void __hash_vx_info(struct vx_info *vxi)
16733 + struct hlist_head *head;
16735 + vxd_assert_lock(&vx_info_hash_lock);
16736 + vxdprintk(VXD_CBIT(xid, 4),
16737 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16738 + vxh_hash_vx_info(vxi);
16740 + /* context must not be hashed */
16741 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16743 + vxi->vx_state |= VXS_HASHED;
16744 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16745 + hlist_add_head(&vxi->vx_hlist, head);
16746 + atomic_inc(&vx_global_cactive);
16749 +/* __unhash_vx_info()
16751 + * remove the vxi from the global hash table
16752 + * requires the hash_lock to be held */
16754 +static inline void __unhash_vx_info(struct vx_info *vxi)
16756 + unsigned long flags;
16758 + vxd_assert_lock(&vx_info_hash_lock);
16759 + vxdprintk(VXD_CBIT(xid, 4),
16760 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16761 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16762 + vxh_unhash_vx_info(vxi);
16764 + /* context must be hashed */
16765 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16766 + /* but without tasks */
16767 + BUG_ON(atomic_read(&vxi->vx_tasks));
16769 + vxi->vx_state &= ~VXS_HASHED;
16770 + hlist_del_init(&vxi->vx_hlist);
16771 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16772 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16773 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16774 + atomic_dec(&vx_global_cactive);
16778 +/* __lookup_vx_info()
16780 + * requires the hash_lock to be held
16781 + * doesn't increment the vx_refcnt */
16783 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16785 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16786 + struct hlist_node *pos;
16787 + struct vx_info *vxi;
16789 + vxd_assert_lock(&vx_info_hash_lock);
16790 + hlist_for_each(pos, head) {
16791 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16793 + if (vxi->vx_id == xid)
16798 + vxdprintk(VXD_CBIT(xid, 0),
16799 + "__lookup_vx_info(#%u): %p[#%u]",
16800 + xid, vxi, vxi ? vxi->vx_id : 0);
16801 + vxh_lookup_vx_info(vxi, xid);
16806 +/* __create_vx_info()
16808 + * create the requested context
16809 + * get(), claim() and hash it */
16811 +static struct vx_info *__create_vx_info(int id)
16813 + struct vx_info *new, *vxi = NULL;
16815 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16817 + if (!(new = __alloc_vx_info(id)))
16818 + return ERR_PTR(-ENOMEM);
16820 + /* required to make dynamic xids unique */
16821 + spin_lock(&vx_info_hash_lock);
16823 + /* static context requested */
16824 + if ((vxi = __lookup_vx_info(id))) {
16825 + vxdprintk(VXD_CBIT(xid, 0),
16826 + "create_vx_info(%d) = %p (already there)", id, vxi);
16827 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16828 + vxi = ERR_PTR(-EBUSY);
16830 + vxi = ERR_PTR(-EEXIST);
16833 + /* new context */
16834 + vxdprintk(VXD_CBIT(xid, 0),
16835 + "create_vx_info(%d) = %p (new)", id, new);
16836 + claim_vx_info(new, NULL);
16837 + __hash_vx_info(get_vx_info(new));
16838 + vxi = new, new = NULL;
16841 + spin_unlock(&vx_info_hash_lock);
16842 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16844 + __dealloc_vx_info(new);
16849 +/* exported stuff */
16852 +void unhash_vx_info(struct vx_info *vxi)
16854 + __shutdown_vx_info(vxi);
16855 + spin_lock(&vx_info_hash_lock);
16856 + __unhash_vx_info(vxi);
16857 + spin_unlock(&vx_info_hash_lock);
16858 + __wakeup_vx_info(vxi);
16862 +/* lookup_vx_info()
16864 + * search for a vx_info and get() it
16865 + * negative id means current */
16867 +struct vx_info *lookup_vx_info(int id)
16869 + struct vx_info *vxi = NULL;
16872 + vxi = get_vx_info(current_vx_info());
16873 + } else if (id > 1) {
16874 + spin_lock(&vx_info_hash_lock);
16875 + vxi = get_vx_info(__lookup_vx_info(id));
16876 + spin_unlock(&vx_info_hash_lock);
16881 +/* xid_is_hashed()
16883 + * verify that xid is still hashed */
16885 +int xid_is_hashed(xid_t xid)
16889 + spin_lock(&vx_info_hash_lock);
16890 + hashed = (__lookup_vx_info(xid) != NULL);
16891 + spin_unlock(&vx_info_hash_lock);
16895 +#ifdef CONFIG_PROC_FS
16899 + * get a subset of hashed xids for proc
16900 + * assumes size is at least one */
16902 +int get_xid_list(int index, unsigned int *xids, int size)
16904 + int hindex, nr_xids = 0;
16906 + /* only show current and children */
16907 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16910 + xids[nr_xids] = vx_current_xid();
16914 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16915 + struct hlist_head *head = &vx_info_hash[hindex];
16916 + struct hlist_node *pos;
16918 + spin_lock(&vx_info_hash_lock);
16919 + hlist_for_each(pos, head) {
16920 + struct vx_info *vxi;
16925 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16926 + xids[nr_xids] = vxi->vx_id;
16927 + if (++nr_xids >= size) {
16928 + spin_unlock(&vx_info_hash_lock);
16932 + /* keep the lock time short */
16933 + spin_unlock(&vx_info_hash_lock);
16940 +#ifdef CONFIG_VSERVER_DEBUG
16942 +void dump_vx_info_inactive(int level)
16944 + struct hlist_node *entry, *next;
16946 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16947 + struct vx_info *vxi =
16948 + list_entry(entry, struct vx_info, vx_hlist);
16950 + dump_vx_info(vxi, level);
16957 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16959 + struct user_struct *new_user, *old_user;
16964 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16967 + new_user = alloc_uid(vxi->vx_id, p->uid);
16971 + old_user = p->user;
16972 + if (new_user != old_user) {
16973 + atomic_inc(&new_user->processes);
16974 + atomic_dec(&old_user->processes);
16975 + p->user = new_user;
16977 + free_uid(old_user);
16983 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16985 + // p->cap_effective &= vxi->vx_cap_bset;
16986 + p->cap_effective =
16987 + cap_intersect(p->cap_effective, vxi->cap_bset);
16988 + // p->cap_inheritable &= vxi->vx_cap_bset;
16989 + p->cap_inheritable =
16990 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16991 + // p->cap_permitted &= vxi->vx_cap_bset;
16992 + p->cap_permitted =
16993 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16998 +#include <linux/file.h>
16999 +#include <linux/fdtable.h>
17001 +static int vx_openfd_task(struct task_struct *tsk)
17003 + struct files_struct *files = tsk->files;
17004 + struct fdtable *fdt;
17005 + const unsigned long *bptr;
17006 + int count, total;
17008 + /* no rcu_read_lock() because of spin_lock() */
17009 + spin_lock(&files->file_lock);
17010 + fdt = files_fdtable(files);
17011 + bptr = fdt->open_fds->fds_bits;
17012 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
17013 + for (total = 0; count > 0; count--) {
17015 + total += hweight_long(*bptr);
17018 + spin_unlock(&files->file_lock);
17023 +/* for *space compatibility */
17025 +asmlinkage long sys_unshare(unsigned long);
17028 + * migrate task to new context
17029 + * gets vxi, puts old_vxi on change
17030 + * optionally unshares namespaces (hack)
17033 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17035 + struct vx_info *old_vxi;
17041 + vxdprintk(VXD_CBIT(xid, 5),
17042 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17043 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17045 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17046 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17049 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17052 + old_vxi = task_get_vx_info(p);
17053 + if (old_vxi == vxi)
17056 +// if (!(ret = vx_migrate_user(p, vxi))) {
17061 + openfd = vx_openfd_task(p);
17064 + atomic_dec(&old_vxi->cvirt.nr_threads);
17065 + atomic_dec(&old_vxi->cvirt.nr_running);
17066 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17067 + /* FIXME: what about the struct files here? */
17068 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17069 + /* account for the executable */
17070 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17072 + atomic_inc(&vxi->cvirt.nr_threads);
17073 + atomic_inc(&vxi->cvirt.nr_running);
17074 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17075 + /* FIXME: what about the struct files here? */
17076 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17077 + /* account for the executable */
17078 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17081 + release_vx_info(old_vxi, p);
17082 + clr_vx_info(&p->vx_info);
17084 + claim_vx_info(vxi, p);
17085 + set_vx_info(&p->vx_info, vxi);
17086 + p->xid = vxi->vx_id;
17088 + vxdprintk(VXD_CBIT(xid, 5),
17089 + "moved task %p into vxi:%p[#%d]",
17090 + p, vxi, vxi->vx_id);
17092 + // vx_mask_cap_bset(vxi, p);
17095 + /* hack for *spaces to provide compatibility */
17097 + struct nsproxy *old_nsp, *new_nsp;
17099 + ret = unshare_nsproxy_namespaces(
17100 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17105 + old_nsp = xchg(&p->nsproxy, new_nsp);
17106 + vx_set_space(vxi,
17107 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
17108 + put_nsproxy(old_nsp);
17112 + put_vx_info(old_vxi);
17116 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17118 + struct task_struct *old_reaper;
17123 + vxdprintk(VXD_CBIT(xid, 6),
17124 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17125 + vxi, vxi->vx_id, p, p->xid, p->pid);
17127 + old_reaper = vxi->vx_reaper;
17128 + if (old_reaper == p)
17131 + /* set new child reaper */
17132 + get_task_struct(p);
17133 + vxi->vx_reaper = p;
17134 + put_task_struct(old_reaper);
17138 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17143 + vxdprintk(VXD_CBIT(xid, 6),
17144 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17145 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17147 + vxi->vx_flags &= ~VXF_STATE_INIT;
17148 + // vxi->vx_initpid = p->tgid;
17149 + vxi->vx_initpid = p->pid;
17153 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17155 + vxdprintk(VXD_CBIT(xid, 6),
17156 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17157 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17159 + vxi->exit_code = code;
17160 + vxi->vx_initpid = 0;
17164 +void vx_set_persistent(struct vx_info *vxi)
17166 + vxdprintk(VXD_CBIT(xid, 6),
17167 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
17169 + get_vx_info(vxi);
17170 + claim_vx_info(vxi, NULL);
17173 +void vx_clear_persistent(struct vx_info *vxi)
17175 + vxdprintk(VXD_CBIT(xid, 6),
17176 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17178 + release_vx_info(vxi, NULL);
17179 + put_vx_info(vxi);
17182 +void vx_update_persistent(struct vx_info *vxi)
17184 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17185 + vx_set_persistent(vxi);
17187 + vx_clear_persistent(vxi);
17191 +/* task must be current or locked */
17193 +void exit_vx_info(struct task_struct *p, int code)
17195 + struct vx_info *vxi = p->vx_info;
17198 + atomic_dec(&vxi->cvirt.nr_threads);
17201 + vxi->exit_code = code;
17202 + release_vx_info(vxi, p);
17206 +void exit_vx_info_early(struct task_struct *p, int code)
17208 + struct vx_info *vxi = p->vx_info;
17211 + if (vxi->vx_initpid == p->pid)
17212 + vx_exit_init(vxi, p, code);
17213 + if (vxi->vx_reaper == p)
17214 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17219 +/* vserver syscall commands below here */
17221 +/* taks xid and vx_info functions */
17223 +#include <asm/uaccess.h>
17226 +int vc_task_xid(uint32_t id)
17231 + struct task_struct *tsk;
17233 + read_lock(&tasklist_lock);
17234 + tsk = find_task_by_real_pid(id);
17235 + xid = (tsk) ? tsk->xid : -ESRCH;
17236 + read_unlock(&tasklist_lock);
17238 + xid = vx_current_xid();
17243 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17245 + struct vcmd_vx_info_v0 vc_data;
17247 + vc_data.xid = vxi->vx_id;
17248 + vc_data.initpid = vxi->vx_initpid;
17250 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17256 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17258 + struct vcmd_ctx_stat_v0 vc_data;
17260 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17261 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17263 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17269 +/* context functions */
17271 +int vc_ctx_create(uint32_t xid, void __user *data)
17273 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17274 + struct vx_info *new_vxi;
17277 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17280 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17283 + new_vxi = __create_vx_info(xid);
17284 + if (IS_ERR(new_vxi))
17285 + return PTR_ERR(new_vxi);
17287 + /* initial flags */
17288 + new_vxi->vx_flags = vc_data.flagword;
17291 + if (vs_state_change(new_vxi, VSC_STARTUP))
17294 + ret = vx_migrate_task(current, new_vxi, (!data));
17298 + /* return context id on success */
17299 + ret = new_vxi->vx_id;
17301 + /* get a reference for persistent contexts */
17302 + if ((vc_data.flagword & VXF_PERSISTENT))
17303 + vx_set_persistent(new_vxi);
17305 + release_vx_info(new_vxi, NULL);
17306 + put_vx_info(new_vxi);
17311 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17313 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17316 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17319 + ret = vx_migrate_task(current, vxi, 0);
17322 + if (vc_data.flagword & VXM_SET_INIT)
17323 + ret = vx_set_init(vxi, current);
17326 + if (vc_data.flagword & VXM_SET_REAPER)
17327 + ret = vx_set_reaper(vxi, current);
17332 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17334 + struct vcmd_ctx_flags_v0 vc_data;
17336 + vc_data.flagword = vxi->vx_flags;
17338 + /* special STATE flag handling */
17339 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17341 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17346 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17348 + struct vcmd_ctx_flags_v0 vc_data;
17349 + uint64_t mask, trigger;
17351 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17354 + /* special STATE flag handling */
17355 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17356 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17358 + if (vxi == current_vx_info()) {
17359 + /* if (trigger & VXF_STATE_SETUP)
17360 + vx_mask_cap_bset(vxi, current); */
17361 + if (trigger & VXF_STATE_INIT) {
17364 + ret = vx_set_init(vxi, current);
17367 + ret = vx_set_reaper(vxi, current);
17373 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17374 + vc_data.flagword, mask);
17375 + if (trigger & VXF_PERSISTENT)
17376 + vx_update_persistent(vxi);
17382 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17384 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17386 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17390 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17392 + kernel_cap_t c = __cap_empty_set;
17394 + c.cap[0] = v & 0xFFFFFFFF;
17395 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17397 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17402 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17405 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17407 + *ccaps = vxi->vx_ccaps;
17412 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17414 + struct vcmd_ctx_caps_v1 vc_data;
17417 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17420 + vc_data.cmask = ~0ULL;
17422 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17427 +static int do_set_caps(struct vx_info *vxi,
17428 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17430 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17433 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17434 + bcaps, bmask, ccaps, cmask);
17436 + vxi->vx_bcaps = cap_t_from_caps(
17437 + vs_mask_flags(bcold, bcaps, bmask));
17438 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17443 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17445 + struct vcmd_ctx_caps_v1 vc_data;
17447 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17450 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17453 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17455 + struct vcmd_bcaps vc_data;
17458 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17461 + vc_data.bmask = ~0ULL;
17463 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17468 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17470 + struct vcmd_bcaps vc_data;
17472 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17475 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17479 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17481 + struct vcmd_umask vc_data;
17483 + vc_data.umask = vxi->vx_umask;
17484 + vc_data.mask = ~0ULL;
17486 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17491 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17493 + struct vcmd_umask vc_data;
17495 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17498 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17499 + vc_data.umask, vc_data.mask);
17504 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17506 + struct vcmd_badness_v0 vc_data;
17508 + vc_data.bias = vxi->vx_badness_bias;
17510 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17515 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17517 + struct vcmd_badness_v0 vc_data;
17519 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17522 + vxi->vx_badness_bias = vc_data.bias;
17526 +#include <linux/module.h>
17528 +EXPORT_SYMBOL_GPL(free_vx_info);
17530 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cvirt.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cvirt.c
17531 --- linux-2.6.33/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17532 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cvirt.c 2010-02-25 12:02:16.000000000 +0100
17535 + * linux/kernel/vserver/cvirt.c
17537 + * Virtual Server: Context Virtualization
17539 + * Copyright (C) 2004-2007 Herbert Pötzl
17541 + * V0.01 broken out from limit.c
17542 + * V0.02 added utsname stuff
17543 + * V0.03 changed vcmds to vxi arg
17547 +#include <linux/types.h>
17548 +#include <linux/utsname.h>
17549 +#include <linux/vs_cvirt.h>
17550 +#include <linux/vserver/switch.h>
17551 +#include <linux/vserver/cvirt_cmd.h>
17553 +#include <asm/uaccess.h>
17556 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17558 + struct vx_info *vxi = current_vx_info();
17560 + set_normalized_timespec(uptime,
17561 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17562 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17565 + set_normalized_timespec(idle,
17566 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17567 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17571 +uint64_t vx_idle_jiffies(void)
17573 + return init_task.utime + init_task.stime;
17578 +static inline uint32_t __update_loadavg(uint32_t load,
17579 + int wsize, int delta, int n)
17581 + unsigned long long calc, prev;
17583 + /* just set it to n */
17584 + if (unlikely(delta >= wsize))
17585 + return (n << FSHIFT);
17587 + calc = delta * n;
17589 + prev = (wsize - delta);
17592 + do_div(calc, wsize);
17597 +void vx_update_load(struct vx_info *vxi)
17599 + uint32_t now, last, delta;
17600 + unsigned int nr_running, nr_uninterruptible;
17601 + unsigned int total;
17602 + unsigned long flags;
17604 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17607 + last = vxi->cvirt.load_last;
17608 + delta = now - last;
17610 + if (delta < 5*HZ)
17613 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17614 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17615 + total = nr_running + nr_uninterruptible;
17617 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17618 + 60*HZ, delta, total);
17619 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17620 + 5*60*HZ, delta, total);
17621 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17622 + 15*60*HZ, delta, total);
17624 + vxi->cvirt.load_last = now;
17626 + atomic_inc(&vxi->cvirt.load_updates);
17627 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17632 + * Commands to do_syslog:
17634 + * 0 -- Close the log. Currently a NOP.
17635 + * 1 -- Open the log. Currently a NOP.
17636 + * 2 -- Read from the log.
17637 + * 3 -- Read all messages remaining in the ring buffer.
17638 + * 4 -- Read and clear all messages remaining in the ring buffer
17639 + * 5 -- Clear ring buffer.
17640 + * 6 -- Disable printk's to console
17641 + * 7 -- Enable printk's to console
17642 + * 8 -- Set level of messages printed to console
17643 + * 9 -- Return number of unread characters in the log buffer
17644 + * 10 -- Return size of the log buffer
17646 +int vx_do_syslog(int type, char __user *buf, int len)
17649 + int do_clear = 0;
17650 + struct vx_info *vxi = current_vx_info();
17651 + struct _vx_syslog *log;
17655 + log = &vxi->cvirt.syslog;
17658 + case 0: /* Close log */
17659 + case 1: /* Open log */
17661 + case 2: /* Read from log */
17662 + error = wait_event_interruptible(log->log_wait,
17663 + (log->log_start - log->log_end));
17666 + spin_lock_irq(&log->logbuf_lock);
17667 + spin_unlock_irq(&log->logbuf_lock);
17669 + case 4: /* Read/clear last kernel messages */
17671 + /* fall through */
17672 + case 3: /* Read last kernel messages */
17675 + case 5: /* Clear ring buffer */
17678 + case 6: /* Disable logging to console */
17679 + case 7: /* Enable logging to console */
17680 + case 8: /* Set level of messages printed to console */
17683 + case 9: /* Number of chars in the log buffer */
17685 + case 10: /* Size of the log buffer */
17695 +/* virtual host info names */
17697 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17699 + struct nsproxy *nsproxy;
17700 + struct uts_namespace *uts;
17702 + if (id == VHIN_CONTEXT)
17703 + return vxi->vx_name;
17705 + nsproxy = vxi->vx_nsproxy[0];
17709 + uts = nsproxy->uts_ns;
17714 + case VHIN_SYSNAME:
17715 + return uts->name.sysname;
17716 + case VHIN_NODENAME:
17717 + return uts->name.nodename;
17718 + case VHIN_RELEASE:
17719 + return uts->name.release;
17720 + case VHIN_VERSION:
17721 + return uts->name.version;
17722 + case VHIN_MACHINE:
17723 + return uts->name.machine;
17724 + case VHIN_DOMAINNAME:
17725 + return uts->name.domainname;
17732 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17734 + struct vcmd_vhi_name_v0 vc_data;
17737 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17740 + name = vx_vhi_name(vxi, vc_data.field);
17744 + memcpy(name, vc_data.name, 65);
17748 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17750 + struct vcmd_vhi_name_v0 vc_data;
17753 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17756 + name = vx_vhi_name(vxi, vc_data.field);
17760 + memcpy(vc_data.name, name, 65);
17761 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17767 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17769 + struct vcmd_virt_stat_v0 vc_data;
17770 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17771 + struct timespec uptime;
17773 + do_posix_clock_monotonic_gettime(&uptime);
17774 + set_normalized_timespec(&uptime,
17775 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17776 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17778 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
17779 + vc_data.uptime = timespec_to_ns(&uptime);
17780 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17781 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17782 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17783 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17784 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17785 + vc_data.load[0] = cvirt->load[0];
17786 + vc_data.load[1] = cvirt->load[1];
17787 + vc_data.load[2] = cvirt->load[2];
17789 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17795 +#ifdef CONFIG_VSERVER_VTIME
17797 +/* virtualized time base */
17799 +void vx_gettimeofday(struct timeval *tv)
17801 + struct vx_info *vxi;
17803 + do_gettimeofday(tv);
17804 + if (!vx_flags(VXF_VIRT_TIME, 0))
17807 + vxi = current_vx_info();
17808 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
17809 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
17811 + if (tv->tv_usec >= USEC_PER_SEC) {
17813 + tv->tv_usec -= USEC_PER_SEC;
17814 + } else if (tv->tv_usec < 0) {
17816 + tv->tv_usec += USEC_PER_SEC;
17820 +int vx_settimeofday(struct timespec *ts)
17822 + struct timeval tv;
17823 + struct vx_info *vxi;
17825 + if (!vx_flags(VXF_VIRT_TIME, 0))
17826 + return do_settimeofday(ts);
17828 + do_gettimeofday(&tv);
17829 + vxi = current_vx_info();
17830 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
17831 + vxi->cvirt.bias_tv.tv_usec =
17832 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
17838 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cvirt_init.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cvirt_init.h
17839 --- linux-2.6.33/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17840 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cvirt_init.h 2010-02-25 12:02:16.000000000 +0100
17844 +extern uint64_t vx_idle_jiffies(void);
17846 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17848 + uint64_t idle_jiffies = vx_idle_jiffies();
17849 + uint64_t nsuptime;
17851 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17852 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17853 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17854 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17855 + cvirt->bias_tv.tv_sec = 0;
17856 + cvirt->bias_tv.tv_usec = 0;
17858 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17859 + atomic_set(&cvirt->nr_threads, 0);
17860 + atomic_set(&cvirt->nr_running, 0);
17861 + atomic_set(&cvirt->nr_uninterruptible, 0);
17862 + atomic_set(&cvirt->nr_onhold, 0);
17864 + spin_lock_init(&cvirt->load_lock);
17865 + cvirt->load_last = jiffies;
17866 + atomic_set(&cvirt->load_updates, 0);
17867 + cvirt->load[0] = 0;
17868 + cvirt->load[1] = 0;
17869 + cvirt->load[2] = 0;
17870 + atomic_set(&cvirt->total_forks, 0);
17872 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17873 + init_waitqueue_head(&cvirt->syslog.log_wait);
17874 + cvirt->syslog.log_start = 0;
17875 + cvirt->syslog.log_end = 0;
17876 + cvirt->syslog.con_start = 0;
17877 + cvirt->syslog.logged_chars = 0;
17881 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17883 + // cvirt_pc->cpustat = { 0 };
17886 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17890 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17891 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17893 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17894 + "!!! cvirt: %p[nr_running] = %d on exit.",
17896 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17897 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17899 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17900 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17906 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17911 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cvirt_proc.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cvirt_proc.h
17912 --- linux-2.6.33/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17913 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/cvirt_proc.h 2010-02-25 12:02:16.000000000 +0100
17915 +#ifndef _VX_CVIRT_PROC_H
17916 +#define _VX_CVIRT_PROC_H
17918 +#include <linux/nsproxy.h>
17919 +#include <linux/mnt_namespace.h>
17920 +#include <linux/ipc_namespace.h>
17921 +#include <linux/utsname.h>
17922 +#include <linux/ipc.h>
17926 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17928 + struct mnt_namespace *ns;
17929 + struct uts_namespace *uts;
17930 + struct ipc_namespace *ipc;
17931 + struct path path;
17932 + char *pstr, *root;
17938 + length += sprintf(buffer + length,
17939 + "NSProxy:\t%p [%p,%p,%p]\n",
17940 + nsproxy, nsproxy->mnt_ns,
17941 + nsproxy->uts_ns, nsproxy->ipc_ns);
17943 + ns = nsproxy->mnt_ns;
17947 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17951 + path.mnt = ns->root;
17952 + path.dentry = ns->root->mnt_root;
17953 + root = d_path(&path, pstr, PATH_MAX - 2);
17954 + length += sprintf(buffer + length,
17955 + "Namespace:\t%p [#%u]\n"
17956 + "RootPath:\t%s\n",
17957 + ns, atomic_read(&ns->count),
17962 + uts = nsproxy->uts_ns;
17966 + length += sprintf(buffer + length,
17967 + "SysName:\t%.*s\n"
17968 + "NodeName:\t%.*s\n"
17969 + "Release:\t%.*s\n"
17970 + "Version:\t%.*s\n"
17971 + "Machine:\t%.*s\n"
17972 + "DomainName:\t%.*s\n",
17973 + __NEW_UTS_LEN, uts->name.sysname,
17974 + __NEW_UTS_LEN, uts->name.nodename,
17975 + __NEW_UTS_LEN, uts->name.release,
17976 + __NEW_UTS_LEN, uts->name.version,
17977 + __NEW_UTS_LEN, uts->name.machine,
17978 + __NEW_UTS_LEN, uts->name.domainname);
17981 + ipc = nsproxy->ipc_ns;
17985 + length += sprintf(buffer + length,
17986 + "SEMS:\t\t%d %d %d %d %d\n"
17987 + "MSG:\t\t%d %d %d\n"
17988 + "SHM:\t\t%lu %lu %d %d\n",
17989 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17990 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17992 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17993 + (unsigned long)ipc->shm_ctlmax,
17994 + (unsigned long)ipc->shm_ctlall,
17995 + ipc->shm_ctlmni, ipc->shm_tot);
18002 +#include <linux/sched.h>
18004 +#define LOAD_INT(x) ((x) >> FSHIFT)
18005 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18008 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18013 + length += sprintf(buffer + length,
18014 + "BiasUptime:\t%lu.%02lu\n",
18015 + (unsigned long)cvirt->bias_uptime.tv_sec,
18016 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18018 + a = cvirt->load[0] + (FIXED_1 / 200);
18019 + b = cvirt->load[1] + (FIXED_1 / 200);
18020 + c = cvirt->load[2] + (FIXED_1 / 200);
18021 + length += sprintf(buffer + length,
18022 + "nr_threads:\t%d\n"
18023 + "nr_running:\t%d\n"
18024 + "nr_unintr:\t%d\n"
18025 + "nr_onhold:\t%d\n"
18026 + "load_updates:\t%d\n"
18027 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18028 + "total_forks:\t%d\n",
18029 + atomic_read(&cvirt->nr_threads),
18030 + atomic_read(&cvirt->nr_running),
18031 + atomic_read(&cvirt->nr_uninterruptible),
18032 + atomic_read(&cvirt->nr_onhold),
18033 + atomic_read(&cvirt->load_updates),
18034 + LOAD_INT(a), LOAD_FRAC(a),
18035 + LOAD_INT(b), LOAD_FRAC(b),
18036 + LOAD_INT(c), LOAD_FRAC(c),
18037 + atomic_read(&cvirt->total_forks));
18042 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18043 + char *buffer, int cpu)
18049 +#endif /* _VX_CVIRT_PROC_H */
18050 diff -NurpP --minimal linux-2.6.33/kernel/vserver/debug.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/debug.c
18051 --- linux-2.6.33/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18052 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/debug.c 2010-02-25 12:02:16.000000000 +0100
18055 + * kernel/vserver/debug.c
18057 + * Copyright (C) 2005-2007 Herbert Pötzl
18059 + * V0.01 vx_info dump support
18063 +#include <linux/module.h>
18065 +#include <linux/vserver/context.h>
18068 +void dump_vx_info(struct vx_info *vxi, int level)
18070 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18071 + atomic_read(&vxi->vx_usecnt),
18072 + atomic_read(&vxi->vx_tasks),
18075 + __dump_vx_limit(&vxi->limit);
18076 + __dump_vx_sched(&vxi->sched);
18077 + __dump_vx_cvirt(&vxi->cvirt);
18078 + __dump_vx_cacct(&vxi->cacct);
18084 +EXPORT_SYMBOL_GPL(dump_vx_info);
18086 diff -NurpP --minimal linux-2.6.33/kernel/vserver/device.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/device.c
18087 --- linux-2.6.33/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18088 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/device.c 2010-02-25 12:02:16.000000000 +0100
18091 + * linux/kernel/vserver/device.c
18093 + * Linux-VServer: Device Support
18095 + * Copyright (C) 2006 Herbert Pötzl
18096 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18098 + * V0.01 device mapping basics
18099 + * V0.02 added defaults
18103 +#include <linux/slab.h>
18104 +#include <linux/rcupdate.h>
18105 +#include <linux/fs.h>
18106 +#include <linux/namei.h>
18107 +#include <linux/hash.h>
18109 +#include <asm/errno.h>
18110 +#include <asm/uaccess.h>
18111 +#include <linux/vserver/base.h>
18112 +#include <linux/vserver/debug.h>
18113 +#include <linux/vserver/context.h>
18114 +#include <linux/vserver/device.h>
18115 +#include <linux/vserver/device_cmd.h>
18118 +#define DMAP_HASH_BITS 4
18121 +struct vs_mapping {
18123 + struct hlist_node hlist;
18124 + struct list_head list;
18126 +#define dm_hlist u.hlist
18127 +#define dm_list u.list
18130 + struct vx_dmap_target target;
18134 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18136 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18138 +static struct vx_dmap_target dmap_defaults[2] = {
18139 + { .flags = DATTR_OPEN },
18140 + { .flags = DATTR_OPEN },
18144 +struct kmem_cache *dmap_cachep __read_mostly;
18146 +int __init dmap_cache_init(void)
18148 + dmap_cachep = kmem_cache_create("dmap_cache",
18149 + sizeof(struct vs_mapping), 0,
18150 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18154 +__initcall(dmap_cache_init);
18157 +static inline unsigned int __hashval(dev_t dev, int bits)
18159 + return hash_long((unsigned long)dev, bits);
18163 +/* __hash_mapping()
18164 + * add the mapping to the hash table
18166 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18168 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18169 + struct hlist_head *head, *hash = dmap_main_hash;
18170 + int device = vdm->device;
18172 + spin_lock(hash_lock);
18173 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18174 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18176 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18177 + hlist_add_head(&vdm->dm_hlist, head);
18178 + spin_unlock(hash_lock);
18182 +static inline int __mode_to_default(umode_t mode)
18195 +/* __set_default()
18198 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18199 + struct vx_dmap_target *vdmt)
18201 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18202 + spin_lock(hash_lock);
18205 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18207 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18210 + spin_unlock(hash_lock);
18212 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18213 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18217 +/* __remove_default()
18218 + * remove a default
18220 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18222 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18223 + spin_lock(hash_lock);
18226 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18227 + else /* remove == reset */
18228 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18230 + spin_unlock(hash_lock);
18235 +/* __find_mapping()
18236 + * find a mapping in the hash table
18238 + * caller must hold hash_lock
18240 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18241 + struct vs_mapping **local, struct vs_mapping **global)
18243 + struct hlist_head *hash = dmap_main_hash;
18244 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18245 + struct hlist_node *pos;
18246 + struct vs_mapping *vdm;
18252 + hlist_for_each(pos, head) {
18253 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18255 + if ((vdm->device == device) &&
18256 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18257 + if (vdm->xid == xid) {
18260 + } else if (global && vdm->xid == 0)
18265 + if (global && *global)
18272 +/* __lookup_mapping()
18273 + * find a mapping and store the result in target and flags
18275 +static inline int __lookup_mapping(struct vx_info *vxi,
18276 + dev_t device, dev_t *target, int *flags, umode_t mode)
18278 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18279 + struct vs_mapping *vdm, *global;
18280 + struct vx_dmap_target *vdmt;
18282 + xid_t xid = vxi->vx_id;
18285 + spin_lock(hash_lock);
18286 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18288 + vdmt = &vdm->target;
18292 + index = __mode_to_default(mode);
18293 + if (vxi && vxi->dmap.targets[index].flags) {
18295 + vdmt = &vxi->dmap.targets[index];
18296 + } else if (global) {
18298 + vdmt = &global->target;
18302 + vdmt = &dmap_defaults[index];
18306 + if (target && (vdmt->flags & DATTR_REMAP))
18307 + *target = vdmt->target;
18309 + *target = device;
18311 + *flags = vdmt->flags;
18313 + spin_unlock(hash_lock);
18319 +/* __remove_mapping()
18320 + * remove a mapping from the hash table
18322 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18325 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18326 + struct vs_mapping *vdm = NULL;
18329 + spin_lock(hash_lock);
18331 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18333 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18334 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18337 + hlist_del(&vdm->dm_hlist);
18340 + spin_unlock(hash_lock);
18342 + kmem_cache_free(dmap_cachep, vdm);
18348 +int vs_map_device(struct vx_info *vxi,
18349 + dev_t device, dev_t *target, umode_t mode)
18351 + int ret, flags = DATTR_MASK;
18355 + *target = device;
18358 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18359 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18360 + device, target ? *target : 0, flags, mode, ret);
18362 + return (flags & DATTR_MASK);
18367 +static int do_set_mapping(struct vx_info *vxi,
18368 + dev_t device, dev_t target, int flags, umode_t mode)
18371 + struct vs_mapping *new;
18373 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18377 + INIT_HLIST_NODE(&new->dm_hlist);
18378 + new->device = device;
18379 + new->target.target = target;
18380 + new->target.flags = flags | mode;
18381 + new->xid = (vxi ? vxi->vx_id : 0);
18383 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18384 + __hash_mapping(vxi, new);
18386 + struct vx_dmap_target new = {
18387 + .target = target,
18388 + .flags = flags | mode,
18390 + __set_default(vxi, mode, &new);
18396 +static int do_unset_mapping(struct vx_info *vxi,
18397 + dev_t device, dev_t target, int flags, umode_t mode)
18399 + int ret = -EINVAL;
18402 + ret = __remove_mapping(vxi, device, mode);
18406 + ret = __remove_default(vxi, mode);
18416 +static inline int __user_device(const char __user *name, dev_t *dev,
18419 + struct nameidata nd;
18426 + ret = user_lpath(name, &nd.path);
18429 + if (nd.path.dentry->d_inode) {
18430 + *dev = nd.path.dentry->d_inode->i_rdev;
18431 + *mode = nd.path.dentry->d_inode->i_mode;
18433 + path_put(&nd.path);
18437 +static inline int __mapping_mode(dev_t device, dev_t target,
18438 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18441 + *mode = device_mode & S_IFMT;
18443 + *mode = target_mode & S_IFMT;
18447 + /* if both given, device and target mode have to match */
18448 + if (device && target &&
18449 + ((device_mode ^ target_mode) & S_IFMT))
18455 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18456 + const char __user *target_path, int flags, int set)
18458 + dev_t device = ~0, target = ~0;
18459 + umode_t device_mode = 0, target_mode = 0, mode;
18462 + ret = __user_device(device_path, &device, &device_mode);
18465 + ret = __user_device(target_path, &target, &target_mode);
18469 + ret = __mapping_mode(device, target,
18470 + device_mode, target_mode, &mode);
18475 + return do_set_mapping(vxi, device, target,
18478 + return do_unset_mapping(vxi, device, target,
18483 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18485 + struct vcmd_set_mapping_v0 vc_data;
18487 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18490 + return do_mapping(vxi, vc_data.device, vc_data.target,
18491 + vc_data.flags, 1);
18494 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18496 + struct vcmd_set_mapping_v0 vc_data;
18498 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18501 + return do_mapping(vxi, vc_data.device, vc_data.target,
18502 + vc_data.flags, 0);
18506 +#ifdef CONFIG_COMPAT
18508 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18510 + struct vcmd_set_mapping_v0_x32 vc_data;
18512 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18515 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18516 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18519 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18521 + struct vcmd_set_mapping_v0_x32 vc_data;
18523 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18526 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18527 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18530 +#endif /* CONFIG_COMPAT */
18533 diff -NurpP --minimal linux-2.6.33/kernel/vserver/dlimit.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/dlimit.c
18534 --- linux-2.6.33/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18535 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/dlimit.c 2010-02-25 12:02:16.000000000 +0100
18538 + * linux/kernel/vserver/dlimit.c
18540 + * Virtual Server: Context Disk Limits
18542 + * Copyright (C) 2004-2009 Herbert Pötzl
18544 + * V0.01 initial version
18545 + * V0.02 compat32 splitup
18546 + * V0.03 extended interface
18550 +#include <linux/statfs.h>
18551 +#include <linux/sched.h>
18552 +#include <linux/namei.h>
18553 +#include <linux/vs_tag.h>
18554 +#include <linux/vs_dlimit.h>
18555 +#include <linux/vserver/dlimit_cmd.h>
18557 +#include <asm/uaccess.h>
18559 +/* __alloc_dl_info()
18561 + * allocate an initialized dl_info struct
18562 + * doesn't make it visible (hash) */
18564 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18566 + struct dl_info *new = NULL;
18568 + vxdprintk(VXD_CBIT(dlim, 5),
18569 + "alloc_dl_info(%p,%d)*", sb, tag);
18571 + /* would this benefit from a slab cache? */
18572 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18576 + memset(new, 0, sizeof(struct dl_info));
18577 + new->dl_tag = tag;
18579 + INIT_RCU_HEAD(&new->dl_rcu);
18580 + INIT_HLIST_NODE(&new->dl_hlist);
18581 + spin_lock_init(&new->dl_lock);
18582 + atomic_set(&new->dl_refcnt, 0);
18583 + atomic_set(&new->dl_usecnt, 0);
18585 + /* rest of init goes here */
18587 + vxdprintk(VXD_CBIT(dlim, 4),
18588 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18592 +/* __dealloc_dl_info()
18594 + * final disposal of dl_info */
18596 +static void __dealloc_dl_info(struct dl_info *dli)
18598 + vxdprintk(VXD_CBIT(dlim, 4),
18599 + "dealloc_dl_info(%p)", dli);
18601 + dli->dl_hlist.next = LIST_POISON1;
18602 + dli->dl_tag = -1;
18605 + BUG_ON(atomic_read(&dli->dl_usecnt));
18606 + BUG_ON(atomic_read(&dli->dl_refcnt));
18612 +/* hash table for dl_info hash */
18614 +#define DL_HASH_SIZE 13
18616 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18618 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18621 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18623 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18628 +/* __hash_dl_info()
18630 + * add the dli to the global hash table
18631 + * requires the hash_lock to be held */
18633 +static inline void __hash_dl_info(struct dl_info *dli)
18635 + struct hlist_head *head;
18637 + vxdprintk(VXD_CBIT(dlim, 6),
18638 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18639 + get_dl_info(dli);
18640 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18641 + hlist_add_head_rcu(&dli->dl_hlist, head);
18644 +/* __unhash_dl_info()
18646 + * remove the dli from the global hash table
18647 + * requires the hash_lock to be held */
18649 +static inline void __unhash_dl_info(struct dl_info *dli)
18651 + vxdprintk(VXD_CBIT(dlim, 6),
18652 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18653 + hlist_del_rcu(&dli->dl_hlist);
18654 + put_dl_info(dli);
18658 +/* __lookup_dl_info()
18660 + * requires the rcu_read_lock()
18661 + * doesn't increment the dl_refcnt */
18663 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18665 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18666 + struct hlist_node *pos;
18667 + struct dl_info *dli;
18669 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18671 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18679 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18681 + struct dl_info *dli;
18684 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18685 + vxdprintk(VXD_CBIT(dlim, 7),
18686 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18687 + rcu_read_unlock();
18691 +void rcu_free_dl_info(struct rcu_head *head)
18693 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18694 + int usecnt, refcnt;
18696 + BUG_ON(!dli || !head);
18698 + usecnt = atomic_read(&dli->dl_usecnt);
18699 + BUG_ON(usecnt < 0);
18701 + refcnt = atomic_read(&dli->dl_refcnt);
18702 + BUG_ON(refcnt < 0);
18704 + vxdprintk(VXD_CBIT(dlim, 3),
18705 + "rcu_free_dl_info(%p)", dli);
18707 + __dealloc_dl_info(dli);
18709 + printk("!!! rcu didn't free\n");
18715 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18716 + uint32_t flags, int add)
18718 + struct path path;
18721 + ret = user_lpath(name, &path);
18723 + struct super_block *sb;
18724 + struct dl_info *dli;
18727 + if (!path.dentry->d_inode)
18728 + goto out_release;
18729 + if (!(sb = path.dentry->d_inode->i_sb))
18730 + goto out_release;
18733 + dli = __alloc_dl_info(sb, id);
18734 + spin_lock(&dl_info_hash_lock);
18737 + if (__lookup_dl_info(sb, id))
18739 + __hash_dl_info(dli);
18742 + spin_lock(&dl_info_hash_lock);
18743 + dli = __lookup_dl_info(sb, id);
18748 + __unhash_dl_info(dli);
18752 + spin_unlock(&dl_info_hash_lock);
18754 + __dealloc_dl_info(dli);
18761 +int vc_add_dlimit(uint32_t id, void __user *data)
18763 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18765 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18768 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18771 +int vc_rem_dlimit(uint32_t id, void __user *data)
18773 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18775 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18778 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18781 +#ifdef CONFIG_COMPAT
18783 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18785 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18787 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18790 + return do_addrem_dlimit(id,
18791 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18794 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18796 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18798 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18801 + return do_addrem_dlimit(id,
18802 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18805 +#endif /* CONFIG_COMPAT */
18809 +int do_set_dlimit(uint32_t id, const char __user *name,
18810 + uint32_t space_used, uint32_t space_total,
18811 + uint32_t inodes_used, uint32_t inodes_total,
18812 + uint32_t reserved, uint32_t flags)
18814 + struct path path;
18817 + ret = user_lpath(name, &path);
18819 + struct super_block *sb;
18820 + struct dl_info *dli;
18823 + if (!path.dentry->d_inode)
18824 + goto out_release;
18825 + if (!(sb = path.dentry->d_inode->i_sb))
18826 + goto out_release;
18828 + /* sanity checks */
18829 + if ((reserved != CDLIM_KEEP &&
18830 + reserved > 100) ||
18831 + (inodes_used != CDLIM_KEEP &&
18832 + inodes_used > inodes_total) ||
18833 + (space_used != CDLIM_KEEP &&
18834 + space_used > space_total))
18835 + goto out_release;
18838 + dli = locate_dl_info(sb, id);
18840 + goto out_release;
18842 + spin_lock(&dli->dl_lock);
18844 + if (inodes_used != CDLIM_KEEP)
18845 + dli->dl_inodes_used = inodes_used;
18846 + if (inodes_total != CDLIM_KEEP)
18847 + dli->dl_inodes_total = inodes_total;
18848 + if (space_used != CDLIM_KEEP)
18849 + dli->dl_space_used = dlimit_space_32to64(
18850 + space_used, flags, DLIMS_USED);
18852 + if (space_total == CDLIM_INFINITY)
18853 + dli->dl_space_total = DLIM_INFINITY;
18854 + else if (space_total != CDLIM_KEEP)
18855 + dli->dl_space_total = dlimit_space_32to64(
18856 + space_total, flags, DLIMS_TOTAL);
18858 + if (reserved != CDLIM_KEEP)
18859 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18861 + spin_unlock(&dli->dl_lock);
18863 + put_dl_info(dli);
18872 +int vc_set_dlimit(uint32_t id, void __user *data)
18874 + struct vcmd_ctx_dlimit_v0 vc_data;
18876 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18879 + return do_set_dlimit(id, vc_data.name,
18880 + vc_data.space_used, vc_data.space_total,
18881 + vc_data.inodes_used, vc_data.inodes_total,
18882 + vc_data.reserved, vc_data.flags);
18885 +#ifdef CONFIG_COMPAT
18887 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18889 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18891 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18894 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18895 + vc_data.space_used, vc_data.space_total,
18896 + vc_data.inodes_used, vc_data.inodes_total,
18897 + vc_data.reserved, vc_data.flags);
18900 +#endif /* CONFIG_COMPAT */
18904 +int do_get_dlimit(uint32_t id, const char __user *name,
18905 + uint32_t *space_used, uint32_t *space_total,
18906 + uint32_t *inodes_used, uint32_t *inodes_total,
18907 + uint32_t *reserved, uint32_t *flags)
18909 + struct path path;
18912 + ret = user_lpath(name, &path);
18914 + struct super_block *sb;
18915 + struct dl_info *dli;
18918 + if (!path.dentry->d_inode)
18919 + goto out_release;
18920 + if (!(sb = path.dentry->d_inode->i_sb))
18921 + goto out_release;
18924 + dli = locate_dl_info(sb, id);
18926 + goto out_release;
18928 + spin_lock(&dli->dl_lock);
18929 + *inodes_used = dli->dl_inodes_used;
18930 + *inodes_total = dli->dl_inodes_total;
18932 + *space_used = dlimit_space_64to32(
18933 + dli->dl_space_used, flags, DLIMS_USED);
18935 + if (dli->dl_space_total == DLIM_INFINITY)
18936 + *space_total = CDLIM_INFINITY;
18938 + *space_total = dlimit_space_64to32(
18939 + dli->dl_space_total, flags, DLIMS_TOTAL);
18941 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18942 + spin_unlock(&dli->dl_lock);
18944 + put_dl_info(dli);
18955 +int vc_get_dlimit(uint32_t id, void __user *data)
18957 + struct vcmd_ctx_dlimit_v0 vc_data;
18960 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18963 + ret = do_get_dlimit(id, vc_data.name,
18964 + &vc_data.space_used, &vc_data.space_total,
18965 + &vc_data.inodes_used, &vc_data.inodes_total,
18966 + &vc_data.reserved, &vc_data.flags);
18970 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18975 +#ifdef CONFIG_COMPAT
18977 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18979 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18982 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18985 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18986 + &vc_data.space_used, &vc_data.space_total,
18987 + &vc_data.inodes_used, &vc_data.inodes_total,
18988 + &vc_data.reserved, &vc_data.flags);
18992 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18997 +#endif /* CONFIG_COMPAT */
19000 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19002 + struct dl_info *dli;
19003 + __u64 blimit, bfree, bavail;
19006 + dli = locate_dl_info(sb, dx_current_tag());
19010 + spin_lock(&dli->dl_lock);
19011 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19014 + /* reduce max inodes available to limit */
19015 + if (buf->f_files > dli->dl_inodes_total)
19016 + buf->f_files = dli->dl_inodes_total;
19018 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19019 + /* reduce free inodes to min */
19020 + if (ifree < buf->f_ffree)
19021 + buf->f_ffree = ifree;
19024 + if (dli->dl_space_total == DLIM_INFINITY)
19027 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19029 + if (dli->dl_space_total < dli->dl_space_used)
19032 + bfree = (dli->dl_space_total - dli->dl_space_used)
19033 + >> sb->s_blocksize_bits;
19035 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19036 + if (bavail < dli->dl_space_used)
19039 + bavail = (bavail - dli->dl_space_used)
19040 + >> sb->s_blocksize_bits;
19042 + /* reduce max space available to limit */
19043 + if (buf->f_blocks > blimit)
19044 + buf->f_blocks = blimit;
19046 + /* reduce free space to min */
19047 + if (bfree < buf->f_bfree)
19048 + buf->f_bfree = bfree;
19050 + /* reduce avail space to min */
19051 + if (bavail < buf->f_bavail)
19052 + buf->f_bavail = bavail;
19055 + spin_unlock(&dli->dl_lock);
19056 + put_dl_info(dli);
19061 +#include <linux/module.h>
19063 +EXPORT_SYMBOL_GPL(locate_dl_info);
19064 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19066 diff -NurpP --minimal linux-2.6.33/kernel/vserver/helper.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/helper.c
19067 --- linux-2.6.33/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19068 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/helper.c 2010-02-25 12:02:16.000000000 +0100
19071 + * linux/kernel/vserver/helper.c
19073 + * Virtual Context Support
19075 + * Copyright (C) 2004-2007 Herbert Pötzl
19077 + * V0.01 basic helper
19081 +#include <linux/kmod.h>
19082 +#include <linux/reboot.h>
19083 +#include <linux/vs_context.h>
19084 +#include <linux/vs_network.h>
19085 +#include <linux/vserver/signal.h>
19088 +char vshelper_path[255] = "/sbin/vshelper";
19091 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19095 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19096 + printk( KERN_WARNING
19097 + "%s: (%s %s) returned %s with %d\n",
19098 + name, argv[1], argv[2],
19099 + sync ? "sync" : "async", ret);
19101 + vxdprintk(VXD_CBIT(switch, 4),
19102 + "%s: (%s %s) returned %s with %d",
19103 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19108 + * vshelper path is set via /proc/sys
19109 + * invoked by vserver sys_reboot(), with
19110 + * the following arguments
19112 + * argv [0] = vshelper_path;
19113 + * argv [1] = action: "restart", "halt", "poweroff", ...
19114 + * argv [2] = context identifier
19116 + * envp [*] = type-specific parameters
19119 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19121 + char id_buf[8], cmd_buf[16];
19122 + char uid_buf[16], pid_buf[16];
19125 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19126 + char *envp[] = {"HOME=/", "TERM=linux",
19127 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19128 + uid_buf, pid_buf, cmd_buf, 0};
19130 + if (vx_info_state(vxi, VXS_HELPER))
19132 + vxi->vx_state |= VXS_HELPER;
19134 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19136 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19137 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
19138 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19141 + case LINUX_REBOOT_CMD_RESTART:
19142 + argv[1] = "restart";
19145 + case LINUX_REBOOT_CMD_HALT:
19146 + argv[1] = "halt";
19149 + case LINUX_REBOOT_CMD_POWER_OFF:
19150 + argv[1] = "poweroff";
19153 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19154 + argv[1] = "swsusp";
19157 + case LINUX_REBOOT_CMD_OOM:
19162 + vxi->vx_state &= ~VXS_HELPER;
19166 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19167 + vxi->vx_state &= ~VXS_HELPER;
19168 + __wakeup_vx_info(vxi);
19169 + return (ret) ? -EPERM : 0;
19173 +long vs_reboot(unsigned int cmd, void __user *arg)
19175 + struct vx_info *vxi = current_vx_info();
19178 + vxdprintk(VXD_CBIT(misc, 5),
19179 + "vs_reboot(%p[#%d],%u)",
19180 + vxi, vxi ? vxi->vx_id : 0, cmd);
19182 + ret = vs_reboot_helper(vxi, cmd, arg);
19186 + vxi->reboot_cmd = cmd;
19187 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19189 + case LINUX_REBOOT_CMD_RESTART:
19190 + case LINUX_REBOOT_CMD_HALT:
19191 + case LINUX_REBOOT_CMD_POWER_OFF:
19192 + vx_info_kill(vxi, 0, SIGKILL);
19193 + vx_info_kill(vxi, 1, SIGKILL);
19201 +long vs_oom_action(unsigned int cmd)
19203 + struct vx_info *vxi = current_vx_info();
19206 + vxdprintk(VXD_CBIT(misc, 5),
19207 + "vs_oom_action(%p[#%d],%u)",
19208 + vxi, vxi ? vxi->vx_id : 0, cmd);
19210 + ret = vs_reboot_helper(vxi, cmd, NULL);
19214 + vxi->reboot_cmd = cmd;
19215 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19216 + vx_info_kill(vxi, 0, SIGKILL);
19217 + vx_info_kill(vxi, 1, SIGKILL);
19223 + * argv [0] = vshelper_path;
19224 + * argv [1] = action: "startup", "shutdown"
19225 + * argv [2] = context identifier
19227 + * envp [*] = type-specific parameters
19230 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19232 + char id_buf[8], cmd_buf[16];
19233 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19234 + char *envp[] = {"HOME=/", "TERM=linux",
19235 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19237 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19240 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19241 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19244 + case VSC_STARTUP:
19245 + argv[1] = "startup";
19247 + case VSC_SHUTDOWN:
19248 + argv[1] = "shutdown";
19254 + return do_vshelper(vshelper_path, argv, envp, 1);
19259 + * argv [0] = vshelper_path;
19260 + * argv [1] = action: "netup", "netdown"
19261 + * argv [2] = context identifier
19263 + * envp [*] = type-specific parameters
19266 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19268 + char id_buf[8], cmd_buf[16];
19269 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19270 + char *envp[] = {"HOME=/", "TERM=linux",
19271 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19273 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19276 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19277 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19281 + argv[1] = "netup";
19283 + case VSC_NETDOWN:
19284 + argv[1] = "netdown";
19290 + return do_vshelper(vshelper_path, argv, envp, 1);
19293 diff -NurpP --minimal linux-2.6.33/kernel/vserver/history.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/history.c
19294 --- linux-2.6.33/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19295 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/history.c 2010-02-25 12:02:16.000000000 +0100
19298 + * kernel/vserver/history.c
19300 + * Virtual Context History Backtrace
19302 + * Copyright (C) 2004-2007 Herbert Pötzl
19304 + * V0.01 basic structure
19305 + * V0.02 hash/unhash and trace
19306 + * V0.03 preemption fixes
19310 +#include <linux/module.h>
19311 +#include <asm/uaccess.h>
19313 +#include <linux/vserver/context.h>
19314 +#include <linux/vserver/debug.h>
19315 +#include <linux/vserver/debug_cmd.h>
19316 +#include <linux/vserver/history.h>
19319 +#ifdef CONFIG_VSERVER_HISTORY
19320 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19322 +#define VXH_SIZE 64
19325 +struct _vx_history {
19326 + unsigned int counter;
19328 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19332 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19334 +unsigned volatile int vxh_active = 1;
19336 +static atomic_t sequence = ATOMIC_INIT(0);
19341 + * requires disabled preemption */
19343 +struct _vx_hist_entry *vxh_advance(void *loc)
19345 + unsigned int cpu = smp_processor_id();
19346 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19347 + struct _vx_hist_entry *entry;
19348 + unsigned int index;
19350 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19351 + entry = &hist->entry[index];
19353 + entry->seq = atomic_inc_return(&sequence);
19354 + entry->loc = loc;
19358 +EXPORT_SYMBOL_GPL(vxh_advance);
19361 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19363 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19366 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19368 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19369 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19370 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19371 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19373 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19375 + switch (e->type) {
19376 + case VXH_THROW_OOPS:
19377 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19380 + case VXH_GET_VX_INFO:
19381 + case VXH_PUT_VX_INFO:
19382 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19384 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19385 + VXH_VXI_ARGS(e));
19388 + case VXH_INIT_VX_INFO:
19389 + case VXH_SET_VX_INFO:
19390 + case VXH_CLR_VX_INFO:
19391 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19393 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19394 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19395 + VXH_VXI_ARGS(e), e->sc.data);
19398 + case VXH_CLAIM_VX_INFO:
19399 + case VXH_RELEASE_VX_INFO:
19400 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19402 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19403 + VXH_VXI_ARGS(e), e->sc.data);
19406 + case VXH_ALLOC_VX_INFO:
19407 + case VXH_DEALLOC_VX_INFO:
19408 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19410 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19411 + VXH_VXI_ARGS(e));
19414 + case VXH_HASH_VX_INFO:
19415 + case VXH_UNHASH_VX_INFO:
19416 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19418 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19419 + VXH_VXI_ARGS(e));
19422 + case VXH_LOC_VX_INFO:
19423 + case VXH_LOOKUP_VX_INFO:
19424 + case VXH_CREATE_VX_INFO:
19425 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19427 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19428 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19429 + e->ll.arg, VXH_VXI_ARGS(e));
19434 +static void __vxh_dump_history(void)
19436 + unsigned int i, cpu;
19438 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19439 + atomic_read(&sequence), NR_CPUS);
19441 + for (i = 0; i < VXH_SIZE; i++) {
19442 + for_each_online_cpu(cpu) {
19443 + struct _vx_history *hist =
19444 + &per_cpu(vx_history_buffer, cpu);
19445 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19446 + struct _vx_hist_entry *entry = &hist->entry[index];
19448 + vxh_dump_entry(entry, cpu);
19453 +void vxh_dump_history(void)
19457 + local_irq_enable();
19459 + local_irq_disable();
19461 + __vxh_dump_history();
19465 +/* vserver syscall commands below here */
19468 +int vc_dump_history(uint32_t id)
19471 + __vxh_dump_history();
19478 +int do_read_history(struct __user _vx_hist_entry *data,
19479 + int cpu, uint32_t *index, uint32_t *count)
19481 + int pos, ret = 0;
19482 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19483 + int end = hist->counter;
19484 + int start = end - VXH_SIZE + 2;
19485 + int idx = *index;
19487 + /* special case: get current pos */
19493 + /* have we lost some data? */
19497 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19498 + struct _vx_hist_entry *entry =
19499 + &hist->entry[idx % VXH_SIZE];
19501 + /* send entry to userspace */
19502 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19506 + /* save new index and count */
19509 + return ret ? ret : (*index < end);
19512 +int vc_read_history(uint32_t id, void __user *data)
19514 + struct vcmd_read_history_v0 vc_data;
19517 + if (id >= NR_CPUS)
19520 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19523 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19524 + id, &vc_data.index, &vc_data.count);
19526 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19531 +#ifdef CONFIG_COMPAT
19533 +int vc_read_history_x32(uint32_t id, void __user *data)
19535 + struct vcmd_read_history_v0_x32 vc_data;
19538 + if (id >= NR_CPUS)
19541 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19544 + ret = do_read_history((struct __user _vx_hist_entry *)
19545 + compat_ptr(vc_data.data_ptr),
19546 + id, &vc_data.index, &vc_data.count);
19548 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19553 +#endif /* CONFIG_COMPAT */
19555 diff -NurpP --minimal linux-2.6.33/kernel/vserver/inet.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/inet.c
19556 --- linux-2.6.33/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19557 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/inet.c 2010-02-25 12:02:16.000000000 +0100
19560 +#include <linux/in.h>
19561 +#include <linux/inetdevice.h>
19562 +#include <linux/vs_inet.h>
19563 +#include <linux/vs_inet6.h>
19564 +#include <linux/vserver/debug.h>
19565 +#include <net/route.h>
19566 +#include <net/addrconf.h>
19569 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19573 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19576 + struct nx_addr_v4 *ptr;
19578 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19579 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19586 + vxdprintk(VXD_CBIT(net, 2),
19587 + "nx_v4_addr_conflict(%p,%p): %d",
19588 + nxi1, nxi2, ret);
19594 +#ifdef CONFIG_IPV6
19596 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19600 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19603 + struct nx_addr_v6 *ptr;
19605 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19606 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19613 + vxdprintk(VXD_CBIT(net, 2),
19614 + "nx_v6_addr_conflict(%p,%p): %d",
19615 + nxi1, nxi2, ret);
19622 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19624 + struct in_device *in_dev;
19625 + struct in_ifaddr **ifap;
19626 + struct in_ifaddr *ifa;
19631 + in_dev = in_dev_get(dev);
19635 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19636 + ifap = &ifa->ifa_next) {
19637 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19642 + in_dev_put(in_dev);
19648 +#ifdef CONFIG_IPV6
19650 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19652 + struct inet6_dev *in_dev;
19653 + struct inet6_ifaddr **ifap;
19654 + struct inet6_ifaddr *ifa;
19659 + in_dev = in6_dev_get(dev);
19663 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19664 + ifap = &ifa->if_next) {
19665 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19670 + in6_dev_put(in_dev);
19677 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19683 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19685 +#ifdef CONFIG_IPV6
19687 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19692 + vxdprintk(VXD_CBIT(net, 3),
19693 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19694 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19698 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19699 + struct rtable **rp, struct flowi *fl)
19704 + /* FIXME: handle lback only case */
19705 + if (!NX_IPV4(nxi))
19708 + vxdprintk(VXD_CBIT(net, 4),
19709 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19710 + nxi, nxi ? nxi->nx_id : 0,
19711 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19713 + /* single IP is unconditional */
19714 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19715 + (fl->fl4_src == INADDR_ANY))
19716 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19718 + if (fl->fl4_src == INADDR_ANY) {
19719 + struct nx_addr_v4 *ptr;
19720 + __be32 found = 0;
19723 + err = __ip_route_output_key(net, rp, fl);
19725 + found = (*rp)->rt_src;
19727 + vxdprintk(VXD_CBIT(net, 4),
19728 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19729 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19730 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19734 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19735 + __be32 primary = ptr->ip[0].s_addr;
19736 + __be32 mask = ptr->mask.s_addr;
19737 + __be32 neta = primary & mask;
19739 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19740 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19741 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19742 + NIPQUAD(mask), NIPQUAD(neta));
19743 + if ((found & mask) != neta)
19746 + fl->fl4_src = primary;
19747 + err = __ip_route_output_key(net, rp, fl);
19748 + vxdprintk(VXD_CBIT(net, 4),
19749 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19750 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19752 + found = (*rp)->rt_src;
19754 + if (found == primary)
19758 + /* still no source ip? */
19759 + found = ipv4_is_loopback(fl->fl4_dst)
19760 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19762 + /* assign src ip to flow */
19763 + fl->fl4_src = found;
19766 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19770 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19771 + if (ipv4_is_loopback(fl->fl4_dst))
19772 + fl->fl4_dst = nxi->v4_lback.s_addr;
19773 + if (ipv4_is_loopback(fl->fl4_src))
19774 + fl->fl4_src = nxi->v4_lback.s_addr;
19775 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19776 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19782 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19784 diff -NurpP --minimal linux-2.6.33/kernel/vserver/init.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/init.c
19785 --- linux-2.6.33/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19786 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/init.c 2010-02-25 12:02:16.000000000 +0100
19789 + * linux/kernel/init.c
19791 + * Virtual Server Init
19793 + * Copyright (C) 2004-2007 Herbert Pötzl
19795 + * V0.01 basic structure
19799 +#include <linux/init.h>
19801 +int vserver_register_sysctl(void);
19802 +void vserver_unregister_sysctl(void);
19805 +static int __init init_vserver(void)
19809 +#ifdef CONFIG_VSERVER_DEBUG
19810 + vserver_register_sysctl();
19816 +static void __exit exit_vserver(void)
19819 +#ifdef CONFIG_VSERVER_DEBUG
19820 + vserver_unregister_sysctl();
19825 +/* FIXME: GFP_ZONETYPES gone
19826 +long vx_slab[GFP_ZONETYPES]; */
19830 +module_init(init_vserver);
19831 +module_exit(exit_vserver);
19833 diff -NurpP --minimal linux-2.6.33/kernel/vserver/inode.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/inode.c
19834 --- linux-2.6.33/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19835 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/inode.c 2010-02-25 12:02:16.000000000 +0100
19838 + * linux/kernel/vserver/inode.c
19840 + * Virtual Server: File System Support
19842 + * Copyright (C) 2004-2007 Herbert Pötzl
19844 + * V0.01 separated from vcontext V0.05
19845 + * V0.02 moved to tag (instead of xid)
19849 +#include <linux/tty.h>
19850 +#include <linux/proc_fs.h>
19851 +#include <linux/devpts_fs.h>
19852 +#include <linux/fs.h>
19853 +#include <linux/file.h>
19854 +#include <linux/mount.h>
19855 +#include <linux/parser.h>
19856 +#include <linux/namei.h>
19857 +#include <linux/vserver/inode.h>
19858 +#include <linux/vserver/inode_cmd.h>
19859 +#include <linux/vs_base.h>
19860 +#include <linux/vs_tag.h>
19862 +#include <asm/uaccess.h>
19865 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19867 + struct proc_dir_entry *entry;
19869 + if (!in || !in->i_sb)
19872 + *flags = IATTR_TAG
19873 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19874 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19875 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19876 + | (IS_COW(in) ? IATTR_COW : 0);
19877 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19879 + if (S_ISDIR(in->i_mode))
19880 + *mask |= IATTR_BARRIER;
19882 + if (IS_TAGGED(in)) {
19883 + *tag = in->i_tag;
19884 + *mask |= IATTR_TAG;
19887 + switch (in->i_sb->s_magic) {
19888 + case PROC_SUPER_MAGIC:
19889 + entry = PROC_I(in)->pde;
19891 + /* check for specific inodes? */
19893 + *mask |= IATTR_FLAGS;
19895 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19897 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19900 + case DEVPTS_SUPER_MAGIC:
19901 + *tag = in->i_tag;
19902 + *mask |= IATTR_TAG;
19911 +int vc_get_iattr(void __user *data)
19913 + struct path path;
19914 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19917 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19920 + ret = user_lpath(vc_data.name, &path);
19922 + ret = __vc_get_iattr(path.dentry->d_inode,
19923 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19929 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19934 +#ifdef CONFIG_COMPAT
19936 +int vc_get_iattr_x32(void __user *data)
19938 + struct path path;
19939 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19942 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19945 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19947 + ret = __vc_get_iattr(path.dentry->d_inode,
19948 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19954 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19959 +#endif /* CONFIG_COMPAT */
19962 +int vc_fget_iattr(uint32_t fd, void __user *data)
19964 + struct file *filp;
19965 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19968 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19972 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19975 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19976 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19980 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19986 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19988 + struct inode *in = de->d_inode;
19989 + int error = 0, is_proc = 0, has_tag = 0;
19990 + struct iattr attr = { 0 };
19992 + if (!in || !in->i_sb)
19995 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19996 + if ((*mask & IATTR_FLAGS) && !is_proc)
19999 + has_tag = IS_TAGGED(in) ||
20000 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20001 + if ((*mask & IATTR_TAG) && !has_tag)
20004 + mutex_lock(&in->i_mutex);
20005 + if (*mask & IATTR_TAG) {
20006 + attr.ia_tag = *tag;
20007 + attr.ia_valid |= ATTR_TAG;
20010 + if (*mask & IATTR_FLAGS) {
20011 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20012 + unsigned int iflags = PROC_I(in)->vx_flags;
20014 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20015 + | (*flags & IATTR_FLAGS);
20016 + PROC_I(in)->vx_flags = iflags;
20018 + entry->vx_flags = iflags;
20021 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
20022 + IATTR_BARRIER | IATTR_COW)) {
20023 + int iflags = in->i_flags;
20024 + int vflags = in->i_vflags;
20026 + if (*mask & IATTR_IMMUTABLE) {
20027 + if (*flags & IATTR_IMMUTABLE)
20028 + iflags |= S_IMMUTABLE;
20030 + iflags &= ~S_IMMUTABLE;
20032 + if (*mask & IATTR_IXUNLINK) {
20033 + if (*flags & IATTR_IXUNLINK)
20034 + iflags |= S_IXUNLINK;
20036 + iflags &= ~S_IXUNLINK;
20038 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20039 + if (*flags & IATTR_BARRIER)
20040 + vflags |= V_BARRIER;
20042 + vflags &= ~V_BARRIER;
20044 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
20045 + if (*flags & IATTR_COW)
20048 + vflags &= ~V_COW;
20050 + if (in->i_op && in->i_op->sync_flags) {
20051 + error = in->i_op->sync_flags(in, iflags, vflags);
20057 + if (attr.ia_valid) {
20058 + if (in->i_op && in->i_op->setattr)
20059 + error = in->i_op->setattr(de, &attr);
20061 + error = inode_change_ok(in, &attr);
20063 + error = inode_setattr(in, &attr);
20068 + mutex_unlock(&in->i_mutex);
20072 +int vc_set_iattr(void __user *data)
20074 + struct path path;
20075 + struct vcmd_ctx_iattr_v1 vc_data;
20078 + if (!capable(CAP_LINUX_IMMUTABLE))
20080 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20083 + ret = user_lpath(vc_data.name, &path);
20085 + ret = __vc_set_iattr(path.dentry,
20086 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20090 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20095 +#ifdef CONFIG_COMPAT
20097 +int vc_set_iattr_x32(void __user *data)
20099 + struct path path;
20100 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20103 + if (!capable(CAP_LINUX_IMMUTABLE))
20105 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20108 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20110 + ret = __vc_set_iattr(path.dentry,
20111 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20115 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20120 +#endif /* CONFIG_COMPAT */
20122 +int vc_fset_iattr(uint32_t fd, void __user *data)
20124 + struct file *filp;
20125 + struct vcmd_ctx_fiattr_v0 vc_data;
20128 + if (!capable(CAP_LINUX_IMMUTABLE))
20130 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20134 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20137 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20138 + &vc_data.flags, &vc_data.mask);
20142 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20148 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20150 +static match_table_t tokens = {
20151 + {Opt_notagcheck, "notagcheck"},
20152 +#ifdef CONFIG_PROPAGATE
20153 + {Opt_notag, "notag"},
20154 + {Opt_tag, "tag"},
20155 + {Opt_tagid, "tagid=%u"},
20161 +static void __dx_parse_remove(char *string, char *opt)
20163 + char *p = strstr(string, opt);
20167 + while (*q != '\0' && *q != ',')
20176 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20177 + unsigned long *flags)
20180 + substring_t args[MAX_OPT_ARGS];
20181 + int token, option = 0;
20182 + char *s, *p, *opts;
20186 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20191 + while ((p = strsep(&opts, ",")) != NULL) {
20192 + token = match_token(p, tokens, args);
20194 + vxdprintk(VXD_CBIT(tag, 7),
20195 + "dx_parse_tag(»%s«): %d:#%d",
20196 + p, token, option);
20199 +#ifdef CONFIG_PROPAGATE
20204 + __dx_parse_remove(s, "tag");
20205 + *mnt_flags |= MNT_TAGID;
20206 + set |= MNT_TAGID;
20210 + __dx_parse_remove(s, "notag");
20211 + *mnt_flags |= MNT_NOTAG;
20212 + set |= MNT_NOTAG;
20215 + if (tag && !match_int(args, &option))
20218 + __dx_parse_remove(s, "tagid");
20219 + *mnt_flags |= MNT_TAGID;
20220 + set |= MNT_TAGID;
20223 + case Opt_notagcheck:
20225 + __dx_parse_remove(s, "notagcheck");
20226 + *flags |= MS_NOTAGCHECK;
20227 + set |= MS_NOTAGCHECK;
20232 + strcpy(string, s);
20237 +#ifdef CONFIG_PROPAGATE
20239 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20241 + tag_t new_tag = 0;
20242 + struct vfsmount *mnt;
20247 + mnt = nd->path.mnt;
20251 + propagate = (mnt->mnt_flags & MNT_TAGID);
20253 + new_tag = mnt->mnt_tag;
20255 + vxdprintk(VXD_CBIT(tag, 7),
20256 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20257 + inode, inode->i_ino, inode->i_tag,
20258 + new_tag, (propagate) ? 1 : 0);
20261 + inode->i_tag = new_tag;
20264 +#include <linux/module.h>
20266 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20268 +#endif /* CONFIG_PROPAGATE */
20270 diff -NurpP --minimal linux-2.6.33/kernel/vserver/Kconfig linux-2.6.33-vs2.3.0.36.30/kernel/vserver/Kconfig
20271 --- linux-2.6.33/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
20272 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/Kconfig 2010-02-25 12:02:16.000000000 +0100
20275 +# Linux VServer configuration
20278 +menu "Linux VServer"
20280 +config VSERVER_AUTO_LBACK
20281 + bool "Automatically Assign Loopback IP"
20284 + Automatically assign a guest specific loopback
20285 + IP and add it to the kernel network stack on
20288 +config VSERVER_AUTO_SINGLE
20289 + bool "Automatic Single IP Special Casing"
20290 + depends on EXPERIMENTAL
20293 + This allows network contexts with a single IP to
20294 + automatically remap 0.0.0.0 bindings to that IP,
20295 + avoiding further network checks and improving
20298 + (note: such guests do not allow to change the ip
20299 + on the fly and do not show loopback addresses)
20301 +config VSERVER_COWBL
20302 + bool "Enable COW Immutable Link Breaking"
20305 + This enables the COW (Copy-On-Write) link break code.
20306 + It allows you to treat unified files like normal files
20307 + when writing to them (which will implicitely break the
20308 + link and create a copy of the unified file)
20310 +config VSERVER_VTIME
20311 + bool "Enable Virtualized Guest Time"
20312 + depends on EXPERIMENTAL
20315 + This enables per guest time offsets to allow for
20316 + adjusting the system clock individually per guest.
20317 + this adds some overhead to the time functions and
20318 + therefore should not be enabled without good reason.
20320 +config VSERVER_DEVICE
20321 + bool "Enable Guest Device Mapping"
20322 + depends on EXPERIMENTAL
20325 + This enables generic device remapping.
20327 +config VSERVER_PROC_SECURE
20328 + bool "Enable Proc Security"
20329 + depends on PROC_FS
20332 + This configures ProcFS security to initially hide
20333 + non-process entries for all contexts except the main and
20334 + spectator context (i.e. for all guests), which is a secure
20337 + (note: on 1.2x the entries were visible by default)
20339 +config VSERVER_HARDCPU
20340 + bool "Enable Hard CPU Limits"
20343 + Activate the Hard CPU Limits
20345 + This will compile in code that allows the Token Bucket
20346 + Scheduler to put processes on hold when a context's
20347 + tokens are depleted (provided that its per-context
20348 + sched_hard flag is set).
20350 + Processes belonging to that context will not be able
20351 + to consume CPU resources again until a per-context
20352 + configured minimum of tokens has been reached.
20354 +config VSERVER_IDLETIME
20355 + bool "Avoid idle CPUs by skipping Time"
20356 + depends on VSERVER_HARDCPU
20359 + This option allows the scheduler to artificially
20360 + advance time (per cpu) when otherwise the idle
20361 + task would be scheduled, thus keeping the cpu
20362 + busy and sharing the available resources among
20363 + certain contexts.
20365 +config VSERVER_IDLELIMIT
20366 + bool "Limit the IDLE task"
20367 + depends on VSERVER_HARDCPU
20370 + Limit the idle slices, so the the next context
20371 + will be scheduled as soon as possible.
20373 + This might improve interactivity and latency, but
20374 + will also marginally increase scheduling overhead.
20377 + prompt "Persistent Inode Tagging"
20378 + default TAGGING_ID24
20380 + This adds persistent context information to filesystems
20381 + mounted with the tagxid option. Tagging is a requirement
20382 + for per-context disk limits and per-context quota.
20385 +config TAGGING_NONE
20388 + do not store per-context information in inodes.
20390 +config TAGGING_UID16
20391 + bool "UID16/GID32"
20393 + reduces UID to 16 bit, but leaves GID at 32 bit.
20395 +config TAGGING_GID16
20396 + bool "UID32/GID16"
20398 + reduces GID to 16 bit, but leaves UID at 32 bit.
20400 +config TAGGING_ID24
20401 + bool "UID24/GID24"
20403 + uses the upper 8bit from UID and GID for XID tagging
20404 + which leaves 24bit for UID/GID each, which should be
20405 + more than sufficient for normal use.
20407 +config TAGGING_INTERN
20408 + bool "UID32/GID32"
20410 + this uses otherwise reserved inode fields in the on
20411 + disk representation, which limits the use to a few
20412 + filesystems (currently ext2 and ext3)
20417 + bool "Tag NFSD User Auth and Files"
20420 + Enable this if you do want the in-kernel NFS
20421 + Server to use the tagging specified above.
20422 + (will require patched clients too)
20424 +config VSERVER_PRIVACY
20425 + bool "Honor Privacy Aspects of Guests"
20428 + When enabled, most context checks will disallow
20429 + access to structures assigned to a specific context,
20430 + like ptys or loop devices.
20432 +config VSERVER_CONTEXTS
20433 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20435 + default "768" if 64BIT
20438 + This setting will optimize certain data structures
20439 + and memory allocations according to the expected
20442 + note: this is not a strict upper limit.
20444 +config VSERVER_WARN
20445 + bool "VServer Warnings"
20448 + This enables various runtime warnings, which will
20449 + notify about potential manipulation attempts or
20450 + resource shortage. It is generally considered to
20451 + be a good idea to have that enabled.
20453 +config VSERVER_DEBUG
20454 + bool "VServer Debugging Code"
20457 + Set this to yes if you want to be able to activate
20458 + debugging output at runtime. It adds a very small
20459 + overhead to all vserver related functions and
20460 + increases the kernel size by about 20k.
20462 +config VSERVER_HISTORY
20463 + bool "VServer History Tracing"
20464 + depends on VSERVER_DEBUG
20467 + Set this to yes if you want to record the history of
20468 + linux-vserver activities, so they can be replayed in
20469 + the event of a kernel panic or oops.
20471 +config VSERVER_HISTORY_SIZE
20472 + int "Per-CPU History Size (32-65536)"
20473 + depends on VSERVER_HISTORY
20477 + This allows you to specify the number of entries in
20478 + the per-CPU history buffer.
20480 +config VSERVER_MONITOR
20481 + bool "VServer Scheduling Monitor"
20482 + depends on VSERVER_DISABLED
20485 + Set this to yes if you want to record the scheduling
20486 + decisions, so that they can be relayed to userspace
20487 + for detailed analysis.
20489 +config VSERVER_MONITOR_SIZE
20490 + int "Per-CPU Monitor Queue Size (32-65536)"
20491 + depends on VSERVER_MONITOR
20495 + This allows you to specify the number of entries in
20496 + the per-CPU scheduling monitor buffer.
20498 +config VSERVER_MONITOR_SYNC
20499 + int "Per-CPU Monitor Sync Interval (0-65536)"
20500 + depends on VSERVER_MONITOR
20504 + This allows you to specify the interval in ticks
20505 + when a time sync entry is inserted.
20513 + select NAMESPACES
20519 +config VSERVER_SECURITY
20521 + depends on SECURITY
20523 + select SECURITY_CAPABILITIES
20525 diff -NurpP --minimal linux-2.6.33/kernel/vserver/limit.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/limit.c
20526 --- linux-2.6.33/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20527 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/limit.c 2010-02-25 12:02:16.000000000 +0100
20530 + * linux/kernel/vserver/limit.c
20532 + * Virtual Server: Context Limits
20534 + * Copyright (C) 2004-2010 Herbert Pötzl
20536 + * V0.01 broken out from vcontext V0.05
20537 + * V0.02 changed vcmds to vxi arg
20538 + * V0.03 added memory cgroup support
20542 +#include <linux/sched.h>
20543 +#include <linux/module.h>
20544 +#include <linux/memcontrol.h>
20545 +#include <linux/res_counter.h>
20546 +#include <linux/vs_limit.h>
20547 +#include <linux/vserver/limit.h>
20548 +#include <linux/vserver/limit_cmd.h>
20550 +#include <asm/uaccess.h>
20553 +const char *vlimit_name[NUM_LIMITS] = {
20554 + [RLIMIT_CPU] = "CPU",
20555 + [RLIMIT_RSS] = "RSS",
20556 + [RLIMIT_NPROC] = "NPROC",
20557 + [RLIMIT_NOFILE] = "NOFILE",
20558 + [RLIMIT_MEMLOCK] = "VML",
20559 + [RLIMIT_AS] = "VM",
20560 + [RLIMIT_LOCKS] = "LOCKS",
20561 + [RLIMIT_SIGPENDING] = "SIGP",
20562 + [RLIMIT_MSGQUEUE] = "MSGQ",
20564 + [VLIMIT_NSOCK] = "NSOCK",
20565 + [VLIMIT_OPENFD] = "OPENFD",
20566 + [VLIMIT_ANON] = "ANON",
20567 + [VLIMIT_SHMEM] = "SHMEM",
20568 + [VLIMIT_DENTRY] = "DENTRY",
20571 +EXPORT_SYMBOL_GPL(vlimit_name);
20573 +#define MASK_ENTRY(x) (1 << (x))
20575 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20578 + , /* softlimit */
20579 + MASK_ENTRY( RLIMIT_RSS ) |
20580 + MASK_ENTRY( VLIMIT_ANON ) |
20583 + MASK_ENTRY( RLIMIT_RSS ) |
20584 + MASK_ENTRY( RLIMIT_NPROC ) |
20585 + MASK_ENTRY( RLIMIT_NOFILE ) |
20586 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
20587 + MASK_ENTRY( RLIMIT_AS ) |
20588 + MASK_ENTRY( RLIMIT_LOCKS ) |
20589 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20591 + MASK_ENTRY( VLIMIT_NSOCK ) |
20592 + MASK_ENTRY( VLIMIT_OPENFD ) |
20593 + MASK_ENTRY( VLIMIT_ANON ) |
20594 + MASK_ENTRY( VLIMIT_SHMEM ) |
20595 + MASK_ENTRY( VLIMIT_DENTRY ) |
20598 + /* accounting only */
20599 +uint32_t account_mask =
20600 + MASK_ENTRY( VLIMIT_SEMARY ) |
20601 + MASK_ENTRY( VLIMIT_NSEMS ) |
20602 + MASK_ENTRY( VLIMIT_MAPPED ) |
20606 +static int is_valid_vlimit(int id)
20608 + uint32_t mask = vlimit_mask.minimum |
20609 + vlimit_mask.softlimit | vlimit_mask.maximum;
20610 + return mask & (1 << id);
20613 +static int is_accounted_vlimit(int id)
20615 + if (is_valid_vlimit(id))
20617 + return account_mask & (1 << id);
20621 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20623 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20624 + return VX_VLIM(limit);
20627 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20629 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20630 + return VX_VLIM(limit);
20633 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20634 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20636 + if (!is_valid_vlimit(id))
20640 + *minimum = CRLIM_UNSET;
20642 + *softlimit = vc_get_soft(vxi, id);
20644 + *maximum = vc_get_hard(vxi, id);
20648 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20650 + struct vcmd_ctx_rlimit_v0 vc_data;
20653 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20656 + ret = do_get_rlimit(vxi, vc_data.id,
20657 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20661 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20666 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20667 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20669 + if (!is_valid_vlimit(id))
20672 + if (maximum != CRLIM_KEEP)
20673 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20674 + if (softlimit != CRLIM_KEEP)
20675 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20677 + /* clamp soft limit */
20678 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20679 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20684 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20686 + struct vcmd_ctx_rlimit_v0 vc_data;
20688 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20691 + return do_set_rlimit(vxi, vc_data.id,
20692 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20695 +#ifdef CONFIG_IA32_EMULATION
20697 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20699 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20701 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20704 + return do_set_rlimit(vxi, vc_data.id,
20705 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20708 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20710 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20713 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20716 + ret = do_get_rlimit(vxi, vc_data.id,
20717 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20721 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20726 +#endif /* CONFIG_IA32_EMULATION */
20729 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20731 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20737 +static inline void vx_reset_hits(struct _vx_limit *limit)
20741 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20742 + atomic_set(&__rlim_lhit(limit, lim), 0);
20746 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20748 + vx_reset_hits(&vxi->limit);
20752 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20757 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20758 + value = __rlim_get(limit, lim);
20759 + __rlim_rmax(limit, lim) = value;
20760 + __rlim_rmin(limit, lim) = value;
20764 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20766 + vx_reset_minmax(&vxi->limit);
20771 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20773 + struct vcmd_rlimit_stat_v0 vc_data;
20774 + struct _vx_limit *limit = &vxi->limit;
20777 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20781 + if (!is_accounted_vlimit(id))
20784 + vx_limit_fixup(limit, id);
20785 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20786 + vc_data.value = __rlim_get(limit, id);
20787 + vc_data.minimum = __rlim_rmin(limit, id);
20788 + vc_data.maximum = __rlim_rmax(limit, id);
20790 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20796 +void vx_vsi_meminfo(struct sysinfo *val)
20798 +#ifdef CGROUP_MEM_RES_CTLR
20799 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20800 + u64 res_limit, res_usage;
20805 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20806 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20808 + if (res_limit != RESOURCE_MAX)
20809 + val->totalram = (res_limit >> PAGE_SHIFT);
20810 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20811 + val->bufferram = 0;
20813 + struct vx_info *vxi = current_vx_info();
20814 + unsigned long totalram, freeram;
20817 + /* we blindly accept the max */
20818 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20819 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
20821 + /* total minus used equals free */
20822 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20823 + freeram = (v < totalram) ? totalram - v : 0;
20825 + val->totalram = totalram;
20826 + val->freeram = freeram;
20828 + val->totalhigh = 0;
20829 + val->freehigh = 0;
20833 +void vx_vsi_swapinfo(struct sysinfo *val)
20835 +#ifdef CGROUP_MEM_RES_CTLR_SWAP
20836 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20837 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20838 + s64 swap_limit, swap_usage;
20843 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20844 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20845 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20846 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20848 + if (res_limit == RESOURCE_MAX)
20851 + swap_limit = memsw_limit - res_limit;
20852 + if (memsw_limit != RESOURCE_MAX)
20853 + val->totalswap = swap_limit >> PAGE_SHIFT;
20855 + swap_usage = memsw_usage - res_usage;
20856 + val->freeswap = (swap_usage < swap_limit) ?
20857 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20859 + struct vx_info *vxi = current_vx_info();
20860 + unsigned long totalswap, freeswap;
20863 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20864 + if (v == RLIM_INFINITY) {
20865 + val->freeswap = val->totalswap;
20869 + /* we blindly accept the max */
20870 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
20871 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
20873 + /* currently 'used' swap */
20874 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20875 + w -= (w > v) ? v : w;
20877 + /* total minus used equals free */
20878 + freeswap = (w < totalswap) ? totalswap - w : 0;
20880 + val->totalswap = totalswap;
20881 + val->freeswap = freeswap;
20886 +long vx_vsi_cached(struct sysinfo *val)
20888 +#ifdef CGROUP_MEM_RES_CTLR
20889 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20891 + return mem_cgroup_stat_read_cache(mcg);
20898 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20900 + struct vx_info *vxi = mm->mm_vx_info;
20901 + unsigned long points;
20907 + points = vxi->vx_badness_bias;
20909 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20910 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20911 + points += (v > w) ? (v - w) : 0;
20916 diff -NurpP --minimal linux-2.6.33/kernel/vserver/limit_init.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/limit_init.h
20917 --- linux-2.6.33/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20918 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/limit_init.h 2010-02-25 12:02:16.000000000 +0100
20922 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20926 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20927 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20928 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20929 + __rlim_set(limit, lim, 0);
20930 + atomic_set(&__rlim_lhit(limit, lim), 0);
20931 + __rlim_rmin(limit, lim) = 0;
20932 + __rlim_rmax(limit, lim) = 0;
20936 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20941 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20942 + if ((1 << lim) & VLIM_NOCHECK)
20944 + value = __rlim_get(limit, lim);
20945 + vxwprintk_xid(value,
20946 + "!!! limit: %p[%s,%d] = %ld on exit.",
20947 + limit, vlimit_name[lim], lim, (long)value);
20951 diff -NurpP --minimal linux-2.6.33/kernel/vserver/limit_proc.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/limit_proc.h
20952 --- linux-2.6.33/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20953 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/limit_proc.h 2010-02-25 12:02:16.000000000 +0100
20955 +#ifndef _VX_LIMIT_PROC_H
20956 +#define _VX_LIMIT_PROC_H
20958 +#include <linux/vserver/limit_int.h>
20961 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20962 +#define VX_LIMIT_TOP \
20963 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20965 +#define VX_LIMIT_ARG(r) \
20966 + (unsigned long)__rlim_get(limit, r), \
20967 + (unsigned long)__rlim_rmin(limit, r), \
20968 + (unsigned long)__rlim_rmax(limit, r), \
20969 + VX_VLIM(__rlim_soft(limit, r)), \
20970 + VX_VLIM(__rlim_hard(limit, r)), \
20971 + atomic_read(&__rlim_lhit(limit, r))
20973 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20975 + vx_limit_fixup(limit, -1);
20976 + return sprintf(buffer, VX_LIMIT_TOP
20977 + "PROC" VX_LIMIT_FMT
20978 + "VM" VX_LIMIT_FMT
20979 + "VML" VX_LIMIT_FMT
20980 + "RSS" VX_LIMIT_FMT
20981 + "ANON" VX_LIMIT_FMT
20982 + "RMAP" VX_LIMIT_FMT
20983 + "FILES" VX_LIMIT_FMT
20984 + "OFD" VX_LIMIT_FMT
20985 + "LOCKS" VX_LIMIT_FMT
20986 + "SOCK" VX_LIMIT_FMT
20987 + "MSGQ" VX_LIMIT_FMT
20988 + "SHM" VX_LIMIT_FMT
20989 + "SEMA" VX_LIMIT_FMT
20990 + "SEMS" VX_LIMIT_FMT
20991 + "DENT" VX_LIMIT_FMT,
20992 + VX_LIMIT_ARG(RLIMIT_NPROC),
20993 + VX_LIMIT_ARG(RLIMIT_AS),
20994 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20995 + VX_LIMIT_ARG(RLIMIT_RSS),
20996 + VX_LIMIT_ARG(VLIMIT_ANON),
20997 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20998 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20999 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21000 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21001 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21002 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21003 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21004 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21005 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21006 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21009 +#endif /* _VX_LIMIT_PROC_H */
21012 diff -NurpP --minimal linux-2.6.33/kernel/vserver/Makefile linux-2.6.33-vs2.3.0.36.30/kernel/vserver/Makefile
21013 --- linux-2.6.33/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21014 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/Makefile 2010-02-25 12:02:16.000000000 +0100
21017 +# Makefile for the Linux vserver routines.
21021 +obj-y += vserver.o
21023 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21024 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21027 +vserver-$(CONFIG_INET) += inet.o
21028 +vserver-$(CONFIG_PROC_FS) += proc.o
21029 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21030 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21031 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21032 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21034 diff -NurpP --minimal linux-2.6.33/kernel/vserver/monitor.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/monitor.c
21035 --- linux-2.6.33/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21036 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/monitor.c 2010-02-25 12:02:16.000000000 +0100
21039 + * kernel/vserver/monitor.c
21041 + * Virtual Context Scheduler Monitor
21043 + * Copyright (C) 2006-2007 Herbert Pötzl
21045 + * V0.01 basic design
21049 +#include <linux/module.h>
21050 +#include <linux/jiffies.h>
21051 +#include <asm/uaccess.h>
21052 +#include <asm/atomic.h>
21054 +#include <linux/vserver/monitor.h>
21055 +#include <linux/vserver/debug_cmd.h>
21058 +#ifdef CONFIG_VSERVER_MONITOR
21059 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21061 +#define VXM_SIZE 64
21064 +struct _vx_monitor {
21065 + unsigned int counter;
21067 + struct _vx_mon_entry entry[VXM_SIZE+1];
21071 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21073 +unsigned volatile int vxm_active = 1;
21075 +static atomic_t sequence = ATOMIC_INIT(0);
21080 + * requires disabled preemption */
21082 +struct _vx_mon_entry *vxm_advance(int cpu)
21084 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21085 + struct _vx_mon_entry *entry;
21086 + unsigned int index;
21088 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21089 + entry = &mon->entry[index];
21091 + entry->ev.seq = atomic_inc_return(&sequence);
21092 + entry->ev.jif = jiffies;
21096 +EXPORT_SYMBOL_GPL(vxm_advance);
21099 +int do_read_monitor(struct __user _vx_mon_entry *data,
21100 + int cpu, uint32_t *index, uint32_t *count)
21102 + int pos, ret = 0;
21103 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21104 + int end = mon->counter;
21105 + int start = end - VXM_SIZE + 2;
21106 + int idx = *index;
21108 + /* special case: get current pos */
21114 + /* have we lost some data? */
21118 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21119 + struct _vx_mon_entry *entry =
21120 + &mon->entry[idx % VXM_SIZE];
21122 + /* send entry to userspace */
21123 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21127 + /* save new index and count */
21130 + return ret ? ret : (*index < end);
21133 +int vc_read_monitor(uint32_t id, void __user *data)
21135 + struct vcmd_read_monitor_v0 vc_data;
21138 + if (id >= NR_CPUS)
21141 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21144 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21145 + id, &vc_data.index, &vc_data.count);
21147 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21152 +#ifdef CONFIG_COMPAT
21154 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21156 + struct vcmd_read_monitor_v0_x32 vc_data;
21159 + if (id >= NR_CPUS)
21162 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21165 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21166 + compat_ptr(vc_data.data_ptr),
21167 + id, &vc_data.index, &vc_data.count);
21169 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21174 +#endif /* CONFIG_COMPAT */
21176 diff -NurpP --minimal linux-2.6.33/kernel/vserver/network.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/network.c
21177 --- linux-2.6.33/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
21178 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/network.c 2010-02-25 12:02:16.000000000 +0100
21181 + * linux/kernel/vserver/network.c
21183 + * Virtual Server: Network Support
21185 + * Copyright (C) 2003-2007 Herbert Pötzl
21187 + * V0.01 broken out from vcontext V0.05
21188 + * V0.02 cleaned up implementation
21189 + * V0.03 added equiv nx commands
21190 + * V0.04 switch to RCU based hash
21191 + * V0.05 and back to locking again
21192 + * V0.06 changed vcmds to nxi arg
21193 + * V0.07 have __create claim() the nxi
21197 +#include <linux/err.h>
21198 +#include <linux/slab.h>
21199 +#include <linux/rcupdate.h>
21201 +#include <linux/vs_network.h>
21202 +#include <linux/vs_pid.h>
21203 +#include <linux/vserver/network_cmd.h>
21206 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21207 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21209 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
21210 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
21213 +static int __init init_network(void)
21215 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
21216 + sizeof(struct nx_addr_v4), 0,
21217 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21218 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
21219 + sizeof(struct nx_addr_v6), 0,
21220 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21225 +/* __alloc_nx_addr_v4() */
21227 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
21229 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
21230 + nx_addr_v4_cachep, GFP_KERNEL);
21232 + if (!IS_ERR(nxa))
21233 + memset(nxa, 0, sizeof(*nxa));
21237 +/* __dealloc_nx_addr_v4() */
21239 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
21241 + kmem_cache_free(nx_addr_v4_cachep, nxa);
21244 +/* __dealloc_nx_addr_v4_all() */
21246 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21249 + struct nx_addr_v4 *next = nxa->next;
21251 + __dealloc_nx_addr_v4(nxa);
21257 +#ifdef CONFIG_IPV6
21259 +/* __alloc_nx_addr_v6() */
21261 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21263 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21264 + nx_addr_v6_cachep, GFP_KERNEL);
21266 + if (!IS_ERR(nxa))
21267 + memset(nxa, 0, sizeof(*nxa));
21271 +/* __dealloc_nx_addr_v6() */
21273 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21275 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21278 +/* __dealloc_nx_addr_v6_all() */
21280 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21283 + struct nx_addr_v6 *next = nxa->next;
21285 + __dealloc_nx_addr_v6(nxa);
21290 +#endif /* CONFIG_IPV6 */
21292 +/* __alloc_nx_info()
21294 + * allocate an initialized nx_info struct
21295 + * doesn't make it visible (hash) */
21297 +static struct nx_info *__alloc_nx_info(nid_t nid)
21299 + struct nx_info *new = NULL;
21301 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
21303 + /* would this benefit from a slab cache? */
21304 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
21308 + memset(new, 0, sizeof(struct nx_info));
21309 + new->nx_id = nid;
21310 + INIT_HLIST_NODE(&new->nx_hlist);
21311 + atomic_set(&new->nx_usecnt, 0);
21312 + atomic_set(&new->nx_tasks, 0);
21313 + new->nx_state = 0;
21315 + new->nx_flags = NXF_INIT_SET;
21317 + /* rest of init goes here */
21319 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
21320 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
21322 + vxdprintk(VXD_CBIT(nid, 0),
21323 + "alloc_nx_info(%d) = %p", nid, new);
21324 + atomic_inc(&nx_global_ctotal);
21328 +/* __dealloc_nx_info()
21330 + * final disposal of nx_info */
21332 +static void __dealloc_nx_info(struct nx_info *nxi)
21334 + vxdprintk(VXD_CBIT(nid, 0),
21335 + "dealloc_nx_info(%p)", nxi);
21337 + nxi->nx_hlist.next = LIST_POISON1;
21340 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21341 + BUG_ON(atomic_read(&nxi->nx_tasks));
21343 + __dealloc_nx_addr_v4_all(nxi->v4.next);
21345 + nxi->nx_state |= NXS_RELEASED;
21347 + atomic_dec(&nx_global_ctotal);
21350 +static void __shutdown_nx_info(struct nx_info *nxi)
21352 + nxi->nx_state |= NXS_SHUTDOWN;
21353 + vs_net_change(nxi, VSC_NETDOWN);
21356 +/* exported stuff */
21358 +void free_nx_info(struct nx_info *nxi)
21360 + /* context shutdown is mandatory */
21361 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
21363 + /* context must not be hashed */
21364 + BUG_ON(nxi->nx_state & NXS_HASHED);
21366 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21367 + BUG_ON(atomic_read(&nxi->nx_tasks));
21369 + __dealloc_nx_info(nxi);
21373 +void __nx_set_lback(struct nx_info *nxi)
21375 + int nid = nxi->nx_id;
21376 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
21378 + nxi->v4_lback.s_addr = lback;
21381 +extern int __nx_inet_add_lback(__be32 addr);
21382 +extern int __nx_inet_del_lback(__be32 addr);
21385 +/* hash table for nx_info hash */
21387 +#define NX_HASH_SIZE 13
21389 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
21391 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
21394 +static inline unsigned int __hashval(nid_t nid)
21396 + return (nid % NX_HASH_SIZE);
21401 +/* __hash_nx_info()
21403 + * add the nxi to the global hash table
21404 + * requires the hash_lock to be held */
21406 +static inline void __hash_nx_info(struct nx_info *nxi)
21408 + struct hlist_head *head;
21410 + vxd_assert_lock(&nx_info_hash_lock);
21411 + vxdprintk(VXD_CBIT(nid, 4),
21412 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
21414 + /* context must not be hashed */
21415 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
21417 + nxi->nx_state |= NXS_HASHED;
21418 + head = &nx_info_hash[__hashval(nxi->nx_id)];
21419 + hlist_add_head(&nxi->nx_hlist, head);
21420 + atomic_inc(&nx_global_cactive);
21423 +/* __unhash_nx_info()
21425 + * remove the nxi from the global hash table
21426 + * requires the hash_lock to be held */
21428 +static inline void __unhash_nx_info(struct nx_info *nxi)
21430 + vxd_assert_lock(&nx_info_hash_lock);
21431 + vxdprintk(VXD_CBIT(nid, 4),
21432 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
21433 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
21435 + /* context must be hashed */
21436 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
21437 + /* but without tasks */
21438 + BUG_ON(atomic_read(&nxi->nx_tasks));
21440 + nxi->nx_state &= ~NXS_HASHED;
21441 + hlist_del(&nxi->nx_hlist);
21442 + atomic_dec(&nx_global_cactive);
21446 +/* __lookup_nx_info()
21448 + * requires the hash_lock to be held
21449 + * doesn't increment the nx_refcnt */
21451 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
21453 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
21454 + struct hlist_node *pos;
21455 + struct nx_info *nxi;
21457 + vxd_assert_lock(&nx_info_hash_lock);
21458 + hlist_for_each(pos, head) {
21459 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21461 + if (nxi->nx_id == nid)
21466 + vxdprintk(VXD_CBIT(nid, 0),
21467 + "__lookup_nx_info(#%u): %p[#%u]",
21468 + nid, nxi, nxi ? nxi->nx_id : 0);
21473 +/* __create_nx_info()
21475 + * create the requested context
21476 + * get(), claim() and hash it */
21478 +static struct nx_info *__create_nx_info(int id)
21480 + struct nx_info *new, *nxi = NULL;
21482 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21484 + if (!(new = __alloc_nx_info(id)))
21485 + return ERR_PTR(-ENOMEM);
21487 + /* required to make dynamic xids unique */
21488 + spin_lock(&nx_info_hash_lock);
21490 + /* static context requested */
21491 + if ((nxi = __lookup_nx_info(id))) {
21492 + vxdprintk(VXD_CBIT(nid, 0),
21493 + "create_nx_info(%d) = %p (already there)", id, nxi);
21494 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21495 + nxi = ERR_PTR(-EBUSY);
21497 + nxi = ERR_PTR(-EEXIST);
21500 + /* new context */
21501 + vxdprintk(VXD_CBIT(nid, 0),
21502 + "create_nx_info(%d) = %p (new)", id, new);
21503 + claim_nx_info(new, NULL);
21504 + __nx_set_lback(new);
21505 + __hash_nx_info(get_nx_info(new));
21506 + nxi = new, new = NULL;
21509 + spin_unlock(&nx_info_hash_lock);
21511 + __dealloc_nx_info(new);
21517 +/* exported stuff */
21520 +void unhash_nx_info(struct nx_info *nxi)
21522 + __shutdown_nx_info(nxi);
21523 + spin_lock(&nx_info_hash_lock);
21524 + __unhash_nx_info(nxi);
21525 + spin_unlock(&nx_info_hash_lock);
21528 +/* lookup_nx_info()
21530 + * search for a nx_info and get() it
21531 + * negative id means current */
21533 +struct nx_info *lookup_nx_info(int id)
21535 + struct nx_info *nxi = NULL;
21538 + nxi = get_nx_info(current_nx_info());
21539 + } else if (id > 1) {
21540 + spin_lock(&nx_info_hash_lock);
21541 + nxi = get_nx_info(__lookup_nx_info(id));
21542 + spin_unlock(&nx_info_hash_lock);
21547 +/* nid_is_hashed()
21549 + * verify that nid is still hashed */
21551 +int nid_is_hashed(nid_t nid)
21555 + spin_lock(&nx_info_hash_lock);
21556 + hashed = (__lookup_nx_info(nid) != NULL);
21557 + spin_unlock(&nx_info_hash_lock);
21562 +#ifdef CONFIG_PROC_FS
21566 + * get a subset of hashed nids for proc
21567 + * assumes size is at least one */
21569 +int get_nid_list(int index, unsigned int *nids, int size)
21571 + int hindex, nr_nids = 0;
21573 + /* only show current and children */
21574 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21577 + nids[nr_nids] = nx_current_nid();
21581 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21582 + struct hlist_head *head = &nx_info_hash[hindex];
21583 + struct hlist_node *pos;
21585 + spin_lock(&nx_info_hash_lock);
21586 + hlist_for_each(pos, head) {
21587 + struct nx_info *nxi;
21592 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21593 + nids[nr_nids] = nxi->nx_id;
21594 + if (++nr_nids >= size) {
21595 + spin_unlock(&nx_info_hash_lock);
21599 + /* keep the lock time short */
21600 + spin_unlock(&nx_info_hash_lock);
21609 + * migrate task to new network
21610 + * gets nxi, puts old_nxi on change
21613 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21615 + struct nx_info *old_nxi;
21621 + vxdprintk(VXD_CBIT(nid, 5),
21622 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21623 + p, nxi, nxi->nx_id,
21624 + atomic_read(&nxi->nx_usecnt),
21625 + atomic_read(&nxi->nx_tasks));
21627 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21628 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21631 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21634 + /* maybe disallow this completely? */
21635 + old_nxi = task_get_nx_info(p);
21636 + if (old_nxi == nxi)
21641 + clr_nx_info(&p->nx_info);
21642 + claim_nx_info(nxi, p);
21643 + set_nx_info(&p->nx_info, nxi);
21644 + p->nid = nxi->nx_id;
21647 + vxdprintk(VXD_CBIT(nid, 5),
21648 + "moved task %p into nxi:%p[#%d]",
21649 + p, nxi, nxi->nx_id);
21652 + release_nx_info(old_nxi, p);
21655 + put_nx_info(old_nxi);
21660 +void nx_set_persistent(struct nx_info *nxi)
21662 + vxdprintk(VXD_CBIT(nid, 6),
21663 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21665 + get_nx_info(nxi);
21666 + claim_nx_info(nxi, NULL);
21669 +void nx_clear_persistent(struct nx_info *nxi)
21671 + vxdprintk(VXD_CBIT(nid, 6),
21672 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21674 + release_nx_info(nxi, NULL);
21675 + put_nx_info(nxi);
21678 +void nx_update_persistent(struct nx_info *nxi)
21680 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21681 + nx_set_persistent(nxi);
21683 + nx_clear_persistent(nxi);
21686 +/* vserver syscall commands below here */
21688 +/* taks nid and nx_info functions */
21690 +#include <asm/uaccess.h>
21693 +int vc_task_nid(uint32_t id)
21698 + struct task_struct *tsk;
21700 + read_lock(&tasklist_lock);
21701 + tsk = find_task_by_real_pid(id);
21702 + nid = (tsk) ? tsk->nid : -ESRCH;
21703 + read_unlock(&tasklist_lock);
21705 + nid = nx_current_nid();
21710 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21712 + struct vcmd_nx_info_v0 vc_data;
21714 + vc_data.nid = nxi->nx_id;
21716 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21722 +/* network functions */
21724 +int vc_net_create(uint32_t nid, void __user *data)
21726 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21727 + struct nx_info *new_nxi;
21730 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21733 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21736 + new_nxi = __create_nx_info(nid);
21737 + if (IS_ERR(new_nxi))
21738 + return PTR_ERR(new_nxi);
21740 + /* initial flags */
21741 + new_nxi->nx_flags = vc_data.flagword;
21744 + if (vs_net_change(new_nxi, VSC_NETUP))
21747 + ret = nx_migrate_task(current, new_nxi);
21751 + /* return context id on success */
21752 + ret = new_nxi->nx_id;
21754 + /* get a reference for persistent contexts */
21755 + if ((vc_data.flagword & NXF_PERSISTENT))
21756 + nx_set_persistent(new_nxi);
21758 + release_nx_info(new_nxi, NULL);
21759 + put_nx_info(new_nxi);
21764 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21766 + return nx_migrate_task(current, nxi);
21771 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21772 + uint16_t type, uint16_t flags)
21774 + struct nx_addr_v4 *nxa = &nxi->v4;
21776 + if (NX_IPV4(nxi)) {
21777 + /* locate last entry */
21778 + for (; nxa->next; nxa = nxa->next);
21779 + nxa->next = __alloc_nx_addr_v4();
21783 + return PTR_ERR(nxa);
21786 + if (nxi->v4.next)
21787 + /* remove single ip for ip list */
21788 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21790 + nxa->ip[0].s_addr = ip;
21791 + nxa->ip[1].s_addr = ip2;
21792 + nxa->mask.s_addr = mask;
21793 + nxa->type = type;
21794 + nxa->flags = flags;
21799 +int vc_net_add(struct nx_info *nxi, void __user *data)
21801 + struct vcmd_net_addr_v0 vc_data;
21802 + int index, ret = 0;
21804 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21807 + switch (vc_data.type) {
21808 + case NXA_TYPE_IPV4:
21809 + if ((vc_data.count < 1) || (vc_data.count > 4))
21813 + while (index < vc_data.count) {
21814 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21815 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21823 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21824 + nxi->v4_bcast = vc_data.ip[0];
21828 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21829 + nxi->v4_lback = vc_data.ip[0];
21840 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21842 + struct vcmd_net_addr_v0 vc_data;
21844 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21847 + switch (vc_data.type) {
21848 + case NXA_TYPE_ANY:
21849 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21850 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21860 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21862 + struct vcmd_net_addr_ipv4_v1 vc_data;
21864 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21867 + switch (vc_data.type) {
21868 + case NXA_TYPE_ADDR:
21869 + case NXA_TYPE_RANGE:
21870 + case NXA_TYPE_MASK:
21871 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21872 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21874 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21875 + nxi->v4_bcast = vc_data.ip;
21878 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21879 + nxi->v4_lback = vc_data.ip;
21888 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21890 + struct vcmd_net_addr_ipv4_v1 vc_data;
21892 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21895 + switch (vc_data.type) {
21896 +/* case NXA_TYPE_ADDR:
21899 + case NXA_TYPE_ANY:
21900 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21901 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21911 +#ifdef CONFIG_IPV6
21913 +int do_add_v6_addr(struct nx_info *nxi,
21914 + struct in6_addr *ip, struct in6_addr *mask,
21915 + uint32_t prefix, uint16_t type, uint16_t flags)
21917 + struct nx_addr_v6 *nxa = &nxi->v6;
21919 + if (NX_IPV6(nxi)) {
21920 + /* locate last entry */
21921 + for (; nxa->next; nxa = nxa->next);
21922 + nxa->next = __alloc_nx_addr_v6();
21926 + return PTR_ERR(nxa);
21930 + nxa->mask = *mask;
21931 + nxa->prefix = prefix;
21932 + nxa->type = type;
21933 + nxa->flags = flags;
21938 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21940 + struct vcmd_net_addr_ipv6_v1 vc_data;
21942 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21945 + switch (vc_data.type) {
21946 + case NXA_TYPE_ADDR:
21947 + case NXA_TYPE_MASK:
21948 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21949 + vc_data.prefix, vc_data.type, vc_data.flags);
21956 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21958 + struct vcmd_net_addr_ipv6_v1 vc_data;
21960 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21963 + switch (vc_data.type) {
21964 + case NXA_TYPE_ANY:
21965 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21966 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21975 +#endif /* CONFIG_IPV6 */
21978 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21980 + struct vcmd_net_flags_v0 vc_data;
21982 + vc_data.flagword = nxi->nx_flags;
21984 + /* special STATE flag handling */
21985 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21987 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21992 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21994 + struct vcmd_net_flags_v0 vc_data;
21995 + uint64_t mask, trigger;
21997 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22000 + /* special STATE flag handling */
22001 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22002 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22004 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22005 + vc_data.flagword, mask);
22006 + if (trigger & NXF_PERSISTENT)
22007 + nx_update_persistent(nxi);
22012 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22014 + struct vcmd_net_caps_v0 vc_data;
22016 + vc_data.ncaps = nxi->nx_ncaps;
22017 + vc_data.cmask = ~0ULL;
22019 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22024 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22026 + struct vcmd_net_caps_v0 vc_data;
22028 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22031 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22032 + vc_data.ncaps, vc_data.cmask);
22037 +#include <linux/module.h>
22039 +module_init(init_network);
22041 +EXPORT_SYMBOL_GPL(free_nx_info);
22042 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22044 diff -NurpP --minimal linux-2.6.33/kernel/vserver/proc.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/proc.c
22045 --- linux-2.6.33/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22046 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/proc.c 2010-02-25 12:02:16.000000000 +0100
22049 + * linux/kernel/vserver/proc.c
22051 + * Virtual Context Support
22053 + * Copyright (C) 2003-2007 Herbert Pötzl
22055 + * V0.01 basic structure
22056 + * V0.02 adaptation vs1.3.0
22057 + * V0.03 proc permissions
22058 + * V0.04 locking/generic
22059 + * V0.05 next generation procfs
22060 + * V0.06 inode validation
22061 + * V0.07 generic rewrite vid
22062 + * V0.08 remove inode type
22066 +#include <linux/proc_fs.h>
22067 +#include <linux/fs_struct.h>
22068 +#include <linux/mount.h>
22069 +#include <asm/unistd.h>
22071 +#include <linux/vs_context.h>
22072 +#include <linux/vs_network.h>
22073 +#include <linux/vs_cvirt.h>
22075 +#include <linux/in.h>
22076 +#include <linux/inetdevice.h>
22077 +#include <linux/vs_inet.h>
22078 +#include <linux/vs_inet6.h>
22080 +#include <linux/vserver/global.h>
22082 +#include "cvirt_proc.h"
22083 +#include "cacct_proc.h"
22084 +#include "limit_proc.h"
22085 +#include "sched_proc.h"
22086 +#include "vci_config.h"
22089 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22093 + CAP_FOR_EACH_U32(__capi) {
22094 + buffer += sprintf(buffer, "%08x",
22095 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22101 +static struct proc_dir_entry *proc_virtual;
22103 +static struct proc_dir_entry *proc_virtnet;
22106 +/* first the actual feeds */
22109 +static int proc_vci(char *buffer)
22111 + return sprintf(buffer,
22112 + "VCIVersion:\t%04x:%04x\n"
22113 + "VCISyscall:\t%d\n"
22114 + "VCIKernel:\t%08x\n",
22115 + VCI_VERSION >> 16,
22116 + VCI_VERSION & 0xFFFF,
22118 + vci_kernel_config());
22121 +static int proc_virtual_info(char *buffer)
22123 + return proc_vci(buffer);
22126 +static int proc_virtual_status(char *buffer)
22128 + return sprintf(buffer,
22130 + "#CActive:\t%d\n"
22131 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
22132 + "#InitTask:\t%d\t%d %d\n",
22133 + atomic_read(&vx_global_ctotal),
22134 + atomic_read(&vx_global_cactive),
22135 + atomic_read(&vs_global_nsproxy),
22136 + atomic_read(&vs_global_fs),
22137 + atomic_read(&vs_global_mnt_ns),
22138 + atomic_read(&vs_global_uts_ns),
22139 + atomic_read(&nr_ipc_ns),
22140 + atomic_read(&vs_global_user_ns),
22141 + atomic_read(&vs_global_pid_ns),
22142 + atomic_read(&init_task.usage),
22143 + atomic_read(&init_task.nsproxy->count),
22144 + init_task.fs->users);
22148 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22152 + length = sprintf(buffer,
22160 + vxi->vx_badness_bias);
22164 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22166 + char *orig = buffer;
22168 + buffer += sprintf(buffer,
22171 + "Flags:\t%016llx\n",
22172 + atomic_read(&vxi->vx_usecnt),
22173 + atomic_read(&vxi->vx_tasks),
22174 + (unsigned long long)vxi->vx_flags);
22176 + buffer += sprintf(buffer, "BCaps:\t");
22177 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22178 + buffer += sprintf(buffer, "\n");
22180 + buffer += sprintf(buffer,
22181 + "CCaps:\t%016llx\n"
22182 + "Spaces:\t%08lx %08lx\n",
22183 + (unsigned long long)vxi->vx_ccaps,
22184 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
22185 + return buffer - orig;
22188 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22190 + return vx_info_proc_limit(&vxi->limit, buffer);
22193 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22197 + length = vx_info_proc_sched(&vxi->sched, buffer);
22198 + for_each_online_cpu(cpu) {
22199 + length += vx_info_proc_sched_pc(
22200 + &vx_per_cpu(vxi, sched_pc, cpu),
22201 + buffer + length, cpu);
22206 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
22208 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
22211 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
22213 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
22216 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22220 + vx_update_load(vxi);
22221 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22222 + for_each_online_cpu(cpu) {
22223 + length += vx_info_proc_cvirt_pc(
22224 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22225 + buffer + length, cpu);
22230 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22232 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22236 +static int proc_virtnet_info(char *buffer)
22238 + return proc_vci(buffer);
22241 +static int proc_virtnet_status(char *buffer)
22243 + return sprintf(buffer,
22245 + "#CActive:\t%d\n",
22246 + atomic_read(&nx_global_ctotal),
22247 + atomic_read(&nx_global_cactive));
22250 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22252 + struct nx_addr_v4 *v4a;
22253 +#ifdef CONFIG_IPV6
22254 + struct nx_addr_v6 *v6a;
22258 + length = sprintf(buffer,
22261 + "Bcast:\t" NIPQUAD_FMT "\n"
22262 + "Lback:\t" NIPQUAD_FMT "\n",
22265 + NIPQUAD(nxi->v4_bcast.s_addr),
22266 + NIPQUAD(nxi->v4_lback.s_addr));
22268 + if (!NX_IPV4(nxi))
22270 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22271 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22274 +#ifdef CONFIG_IPV6
22275 + if (!NX_IPV6(nxi))
22277 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22278 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22285 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22289 + length = sprintf(buffer,
22292 + "Flags:\t%016llx\n"
22293 + "NCaps:\t%016llx\n",
22294 + atomic_read(&nxi->nx_usecnt),
22295 + atomic_read(&nxi->nx_tasks),
22296 + (unsigned long long)nxi->nx_flags,
22297 + (unsigned long long)nxi->nx_ncaps);
22303 +/* here the inode helpers */
22309 + struct inode_operations *iop;
22310 + struct file_operations *fop;
22311 + union proc_op op;
22314 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
22316 + struct inode *inode = new_inode(sb);
22321 + inode->i_mode = p->mode;
22323 + inode->i_op = p->iop;
22325 + inode->i_fop = p->fop;
22327 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
22328 + inode->i_flags |= S_IMMUTABLE;
22330 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
22332 + inode->i_uid = 0;
22333 + inode->i_gid = 0;
22334 + inode->i_tag = 0;
22339 +static struct dentry *vs_proc_instantiate(struct inode *dir,
22340 + struct dentry *dentry, int id, void *ptr)
22342 + struct vs_entry *p = ptr;
22343 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
22344 + struct dentry *error = ERR_PTR(-EINVAL);
22349 + PROC_I(inode)->op = p->op;
22350 + PROC_I(inode)->fd = id;
22351 + d_add(dentry, inode);
22359 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
22362 + * Fill a directory entry.
22364 + * If possible create the dcache entry and derive our inode number and
22365 + * file type from dcache entry.
22367 + * Since all of the proc inode numbers are dynamically generated, the inode
22368 + * numbers do not exist until the inode is cache. This means creating the
22369 + * the dcache entry in readdir is necessary to keep the inode numbers
22370 + * reported by readdir in sync with the inode numbers reported
22373 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
22374 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
22376 + struct dentry *child, *dir = filp->f_dentry;
22377 + struct inode *inode;
22378 + struct qstr qname;
22380 + unsigned type = DT_UNKNOWN;
22382 + qname.name = name;
22384 + qname.hash = full_name_hash(name, len);
22386 + child = d_lookup(dir, &qname);
22388 + struct dentry *new;
22389 + new = d_alloc(dir, &qname);
22391 + child = instantiate(dir->d_inode, new, id, ptr);
22398 + if (!child || IS_ERR(child) || !child->d_inode)
22399 + goto end_instantiate;
22400 + inode = child->d_inode;
22402 + ino = inode->i_ino;
22403 + type = inode->i_mode >> 12;
22408 + ino = find_inode_number(dir, &qname);
22411 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22416 +/* get and revalidate vx_info/xid */
22419 +struct vx_info *get_proc_vx_info(struct inode *inode)
22421 + return lookup_vx_info(PROC_I(inode)->fd);
22424 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22426 + struct inode *inode = dentry->d_inode;
22427 + xid_t xid = PROC_I(inode)->fd;
22429 + if (!xid || xid_is_hashed(xid))
22436 +/* get and revalidate nx_info/nid */
22438 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22440 + struct inode *inode = dentry->d_inode;
22441 + nid_t nid = PROC_I(inode)->fd;
22443 + if (!nid || nid_is_hashed(nid))
22451 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22453 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22454 + size_t count, loff_t *ppos)
22456 + struct inode *inode = file->f_dentry->d_inode;
22457 + unsigned long page;
22458 + ssize_t length = 0;
22460 + if (count > PROC_BLOCK_SIZE)
22461 + count = PROC_BLOCK_SIZE;
22463 + /* fade that out as soon as stable */
22464 + WARN_ON(PROC_I(inode)->fd);
22466 + if (!(page = __get_free_page(GFP_KERNEL)))
22469 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22470 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22473 + length = simple_read_from_buffer(buf, count, ppos,
22474 + (char *)page, length);
22480 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22481 + size_t count, loff_t *ppos)
22483 + struct inode *inode = file->f_dentry->d_inode;
22484 + struct vx_info *vxi = NULL;
22485 + xid_t xid = PROC_I(inode)->fd;
22486 + unsigned long page;
22487 + ssize_t length = 0;
22489 + if (count > PROC_BLOCK_SIZE)
22490 + count = PROC_BLOCK_SIZE;
22492 + /* fade that out as soon as stable */
22494 + vxi = lookup_vx_info(xid);
22498 + length = -ENOMEM;
22499 + if (!(page = __get_free_page(GFP_KERNEL)))
22502 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22503 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22506 + length = simple_read_from_buffer(buf, count, ppos,
22507 + (char *)page, length);
22511 + put_vx_info(vxi);
22516 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22517 + size_t count, loff_t *ppos)
22519 + struct inode *inode = file->f_dentry->d_inode;
22520 + struct nx_info *nxi = NULL;
22521 + nid_t nid = PROC_I(inode)->fd;
22522 + unsigned long page;
22523 + ssize_t length = 0;
22525 + if (count > PROC_BLOCK_SIZE)
22526 + count = PROC_BLOCK_SIZE;
22528 + /* fade that out as soon as stable */
22530 + nxi = lookup_nx_info(nid);
22534 + length = -ENOMEM;
22535 + if (!(page = __get_free_page(GFP_KERNEL)))
22538 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22539 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22542 + length = simple_read_from_buffer(buf, count, ppos,
22543 + (char *)page, length);
22547 + put_nx_info(nxi);
22554 +/* here comes the lower level */
22557 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22558 + .len = sizeof(NAME) - 1, \
22559 + .name = (NAME), \
22567 +#define DIR(NAME, MODE, OTYPE) \
22568 + NOD(NAME, (S_IFDIR | (MODE)), \
22569 + &proc_ ## OTYPE ## _inode_operations, \
22570 + &proc_ ## OTYPE ## _file_operations, { } )
22572 +#define INF(NAME, MODE, OTYPE) \
22573 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22574 + &proc_vs_info_file_operations, \
22575 + { .proc_vs_read = &proc_##OTYPE } )
22577 +#define VINF(NAME, MODE, OTYPE) \
22578 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22579 + &proc_vx_info_file_operations, \
22580 + { .proc_vxi_read = &proc_##OTYPE } )
22582 +#define NINF(NAME, MODE, OTYPE) \
22583 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22584 + &proc_nx_info_file_operations, \
22585 + { .proc_nxi_read = &proc_##OTYPE } )
22588 +static struct file_operations proc_vs_info_file_operations = {
22589 + .read = proc_vs_info_read,
22592 +static struct file_operations proc_vx_info_file_operations = {
22593 + .read = proc_vx_info_read,
22596 +static struct dentry_operations proc_xid_dentry_operations = {
22597 + .d_revalidate = proc_xid_revalidate,
22600 +static struct vs_entry vx_base_stuff[] = {
22601 + VINF("info", S_IRUGO, vxi_info),
22602 + VINF("status", S_IRUGO, vxi_status),
22603 + VINF("limit", S_IRUGO, vxi_limit),
22604 + VINF("sched", S_IRUGO, vxi_sched),
22605 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22606 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22607 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22608 + VINF("cacct", S_IRUGO, vxi_cacct),
22615 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22616 + struct dentry *dentry, int id, void *ptr)
22618 + dentry->d_op = &proc_xid_dentry_operations;
22619 + return vs_proc_instantiate(dir, dentry, id, ptr);
22622 +static struct dentry *proc_xid_lookup(struct inode *dir,
22623 + struct dentry *dentry, struct nameidata *nd)
22625 + struct vs_entry *p = vx_base_stuff;
22626 + struct dentry *error = ERR_PTR(-ENOENT);
22628 + for (; p->name; p++) {
22629 + if (p->len != dentry->d_name.len)
22631 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22637 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22642 +static int proc_xid_readdir(struct file *filp,
22643 + void *dirent, filldir_t filldir)
22645 + struct dentry *dentry = filp->f_dentry;
22646 + struct inode *inode = dentry->d_inode;
22647 + struct vs_entry *p = vx_base_stuff;
22648 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22652 + pos = filp->f_pos;
22655 + ino = inode->i_ino;
22656 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22659 + /* fall through */
22661 + ino = parent_ino(dentry);
22662 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22665 + /* fall through */
22668 + if (index >= size)
22670 + for (p += index; p->name; p++) {
22671 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22672 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22678 + filp->f_pos = pos;
22684 +static struct file_operations proc_nx_info_file_operations = {
22685 + .read = proc_nx_info_read,
22688 +static struct dentry_operations proc_nid_dentry_operations = {
22689 + .d_revalidate = proc_nid_revalidate,
22692 +static struct vs_entry nx_base_stuff[] = {
22693 + NINF("info", S_IRUGO, nxi_info),
22694 + NINF("status", S_IRUGO, nxi_status),
22699 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22700 + struct dentry *dentry, int id, void *ptr)
22702 + dentry->d_op = &proc_nid_dentry_operations;
22703 + return vs_proc_instantiate(dir, dentry, id, ptr);
22706 +static struct dentry *proc_nid_lookup(struct inode *dir,
22707 + struct dentry *dentry, struct nameidata *nd)
22709 + struct vs_entry *p = nx_base_stuff;
22710 + struct dentry *error = ERR_PTR(-ENOENT);
22712 + for (; p->name; p++) {
22713 + if (p->len != dentry->d_name.len)
22715 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22721 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22726 +static int proc_nid_readdir(struct file *filp,
22727 + void *dirent, filldir_t filldir)
22729 + struct dentry *dentry = filp->f_dentry;
22730 + struct inode *inode = dentry->d_inode;
22731 + struct vs_entry *p = nx_base_stuff;
22732 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22736 + pos = filp->f_pos;
22739 + ino = inode->i_ino;
22740 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22743 + /* fall through */
22745 + ino = parent_ino(dentry);
22746 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22749 + /* fall through */
22752 + if (index >= size)
22754 + for (p += index; p->name; p++) {
22755 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22756 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22762 + filp->f_pos = pos;
22767 +#define MAX_MULBY10 ((~0U - 9) / 10)
22769 +static inline int atovid(const char *str, int len)
22774 + while (len-- > 0) {
22779 + if (vid >= MAX_MULBY10)
22789 +/* now the upper level (virtual) */
22792 +static struct file_operations proc_xid_file_operations = {
22793 + .read = generic_read_dir,
22794 + .readdir = proc_xid_readdir,
22797 +static struct inode_operations proc_xid_inode_operations = {
22798 + .lookup = proc_xid_lookup,
22801 +static struct vs_entry vx_virtual_stuff[] = {
22802 + INF("info", S_IRUGO, virtual_info),
22803 + INF("status", S_IRUGO, virtual_status),
22804 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22808 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22809 + struct dentry *dentry, struct nameidata *nd)
22811 + struct vs_entry *p = vx_virtual_stuff;
22812 + struct dentry *error = ERR_PTR(-ENOENT);
22815 + for (; p->name; p++) {
22816 + if (p->len != dentry->d_name.len)
22818 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22822 + goto instantiate;
22824 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22825 + if ((id < 0) || !xid_is_hashed(id))
22829 + error = proc_xid_instantiate(dir, dentry, id, p);
22834 +static struct file_operations proc_nid_file_operations = {
22835 + .read = generic_read_dir,
22836 + .readdir = proc_nid_readdir,
22839 +static struct inode_operations proc_nid_inode_operations = {
22840 + .lookup = proc_nid_lookup,
22843 +static struct vs_entry nx_virtnet_stuff[] = {
22844 + INF("info", S_IRUGO, virtnet_info),
22845 + INF("status", S_IRUGO, virtnet_status),
22846 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22850 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22851 + struct dentry *dentry, struct nameidata *nd)
22853 + struct vs_entry *p = nx_virtnet_stuff;
22854 + struct dentry *error = ERR_PTR(-ENOENT);
22857 + for (; p->name; p++) {
22858 + if (p->len != dentry->d_name.len)
22860 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22864 + goto instantiate;
22866 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22867 + if ((id < 0) || !nid_is_hashed(id))
22871 + error = proc_nid_instantiate(dir, dentry, id, p);
22877 +#define PROC_MAXVIDS 32
22879 +int proc_virtual_readdir(struct file *filp,
22880 + void *dirent, filldir_t filldir)
22882 + struct dentry *dentry = filp->f_dentry;
22883 + struct inode *inode = dentry->d_inode;
22884 + struct vs_entry *p = vx_virtual_stuff;
22885 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22887 + unsigned int xid_array[PROC_MAXVIDS];
22888 + char buf[PROC_NUMBUF];
22889 + unsigned int nr_xids, i;
22892 + pos = filp->f_pos;
22895 + ino = inode->i_ino;
22896 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22899 + /* fall through */
22901 + ino = parent_ino(dentry);
22902 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22905 + /* fall through */
22908 + if (index >= size)
22910 + for (p += index; p->name; p++) {
22911 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22912 + vs_proc_instantiate, 0, p))
22917 + index = pos - size;
22918 + p = &vx_virtual_stuff[size - 1];
22919 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22920 + for (i = 0; i < nr_xids; i++) {
22921 + int n, xid = xid_array[i];
22922 + unsigned int j = PROC_NUMBUF;
22926 + buf[--j] = '0' + (n % 10);
22929 + if (proc_fill_cache(filp, dirent, filldir,
22930 + buf + j, PROC_NUMBUF - j,
22931 + vs_proc_instantiate, xid, p))
22937 + filp->f_pos = pos;
22941 +static int proc_virtual_getattr(struct vfsmount *mnt,
22942 + struct dentry *dentry, struct kstat *stat)
22944 + struct inode *inode = dentry->d_inode;
22946 + generic_fillattr(inode, stat);
22947 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22951 +static struct file_operations proc_virtual_dir_operations = {
22952 + .read = generic_read_dir,
22953 + .readdir = proc_virtual_readdir,
22956 +static struct inode_operations proc_virtual_dir_inode_operations = {
22957 + .getattr = proc_virtual_getattr,
22958 + .lookup = proc_virtual_lookup,
22965 +int proc_virtnet_readdir(struct file *filp,
22966 + void *dirent, filldir_t filldir)
22968 + struct dentry *dentry = filp->f_dentry;
22969 + struct inode *inode = dentry->d_inode;
22970 + struct vs_entry *p = nx_virtnet_stuff;
22971 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22973 + unsigned int nid_array[PROC_MAXVIDS];
22974 + char buf[PROC_NUMBUF];
22975 + unsigned int nr_nids, i;
22978 + pos = filp->f_pos;
22981 + ino = inode->i_ino;
22982 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22985 + /* fall through */
22987 + ino = parent_ino(dentry);
22988 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22991 + /* fall through */
22994 + if (index >= size)
22996 + for (p += index; p->name; p++) {
22997 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22998 + vs_proc_instantiate, 0, p))
23003 + index = pos - size;
23004 + p = &nx_virtnet_stuff[size - 1];
23005 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23006 + for (i = 0; i < nr_nids; i++) {
23007 + int n, nid = nid_array[i];
23008 + unsigned int j = PROC_NUMBUF;
23012 + buf[--j] = '0' + (n % 10);
23015 + if (proc_fill_cache(filp, dirent, filldir,
23016 + buf + j, PROC_NUMBUF - j,
23017 + vs_proc_instantiate, nid, p))
23023 + filp->f_pos = pos;
23027 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23028 + struct dentry *dentry, struct kstat *stat)
23030 + struct inode *inode = dentry->d_inode;
23032 + generic_fillattr(inode, stat);
23033 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23037 +static struct file_operations proc_virtnet_dir_operations = {
23038 + .read = generic_read_dir,
23039 + .readdir = proc_virtnet_readdir,
23042 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23043 + .getattr = proc_virtnet_getattr,
23044 + .lookup = proc_virtnet_lookup,
23049 +void proc_vx_init(void)
23051 + struct proc_dir_entry *ent;
23053 + ent = proc_mkdir("virtual", 0);
23055 + ent->proc_fops = &proc_virtual_dir_operations;
23056 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23058 + proc_virtual = ent;
23060 + ent = proc_mkdir("virtnet", 0);
23062 + ent->proc_fops = &proc_virtnet_dir_operations;
23063 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23065 + proc_virtnet = ent;
23071 +/* per pid info */
23074 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23076 + struct vx_info *vxi;
23077 + char *orig = buffer;
23079 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23081 + vxi = task_get_vx_info(p);
23085 + buffer += sprintf(buffer, "BCaps:\t");
23086 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23087 + buffer += sprintf(buffer, "\n");
23088 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23089 + (unsigned long long)vxi->vx_ccaps);
23090 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23091 + (unsigned long long)vxi->vx_flags);
23092 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23094 + put_vx_info(vxi);
23096 + return buffer - orig;
23100 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23102 + struct nx_info *nxi;
23103 + struct nx_addr_v4 *v4a;
23104 +#ifdef CONFIG_IPV6
23105 + struct nx_addr_v6 *v6a;
23107 + char *orig = buffer;
23110 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23112 + nxi = task_get_nx_info(p);
23116 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23117 + (unsigned long long)nxi->nx_ncaps);
23118 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23119 + (unsigned long long)nxi->nx_flags);
23121 + buffer += sprintf(buffer,
23122 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23123 + NIPQUAD(nxi->v4_bcast.s_addr));
23124 + buffer += sprintf (buffer,
23125 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23126 + NIPQUAD(nxi->v4_lback.s_addr));
23127 + if (!NX_IPV4(nxi))
23129 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23130 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23133 +#ifdef CONFIG_IPV6
23134 + if (!NX_IPV6(nxi))
23136 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23137 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
23141 + put_nx_info(nxi);
23143 + return buffer - orig;
23146 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sched.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sched.c
23147 --- linux-2.6.33/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
23148 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sched.c 2010-02-25 12:02:16.000000000 +0100
23151 + * linux/kernel/vserver/sched.c
23153 + * Virtual Server: Scheduler Support
23155 + * Copyright (C) 2004-2007 Herbert Pötzl
23157 + * V0.01 adapted Sam Vilains version to 2.6.3
23158 + * V0.02 removed legacy interface
23159 + * V0.03 changed vcmds to vxi arg
23160 + * V0.04 removed older and legacy interfaces
23164 +#include <linux/vs_context.h>
23165 +#include <linux/vs_sched.h>
23166 +#include <linux/vserver/sched_cmd.h>
23168 +#include <asm/uaccess.h>
23171 +#define vxd_check_range(val, min, max) do { \
23172 + vxlprintk((val < min) || (val > max), \
23173 + "check_range(%ld,%ld,%ld)", \
23174 + (long)val, (long)min, (long)max, \
23175 + __FILE__, __LINE__); \
23179 +void vx_update_sched_param(struct _vx_sched *sched,
23180 + struct _vx_sched_pc *sched_pc)
23182 + unsigned int set_mask = sched->update_mask;
23184 + if (set_mask & VXSM_FILL_RATE)
23185 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23186 + if (set_mask & VXSM_INTERVAL)
23187 + sched_pc->interval[0] = sched->interval[0];
23188 + if (set_mask & VXSM_FILL_RATE2)
23189 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23190 + if (set_mask & VXSM_INTERVAL2)
23191 + sched_pc->interval[1] = sched->interval[1];
23192 + if (set_mask & VXSM_TOKENS)
23193 + sched_pc->tokens = sched->tokens;
23194 + if (set_mask & VXSM_TOKENS_MIN)
23195 + sched_pc->tokens_min = sched->tokens_min;
23196 + if (set_mask & VXSM_TOKENS_MAX)
23197 + sched_pc->tokens_max = sched->tokens_max;
23198 + if (set_mask & VXSM_PRIO_BIAS)
23199 + sched_pc->prio_bias = sched->prio_bias;
23201 + if (set_mask & VXSM_IDLE_TIME)
23202 + sched_pc->flags |= VXSF_IDLE_TIME;
23204 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23207 + sched_pc->norm_time = jiffies;
23212 + * recalculate the context's scheduling tokens
23214 + * ret > 0 : number of tokens available
23215 + * ret < 0 : on hold, check delta_min[]
23216 + * -1 only jiffies
23217 + * -2 also idle time
23220 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23221 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23225 + int flags = sched_pc->flags;
23227 + /* how much time did pass? */
23228 + delta = *norm_time - sched_pc->norm_time;
23229 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
23230 + vxd_check_range(delta, 0, INT_MAX);
23232 + if (delta >= sched_pc->interval[0]) {
23233 + long tokens, integral;
23235 + /* calc integral token part */
23236 + tokens = delta / sched_pc->interval[0];
23237 + integral = tokens * sched_pc->interval[0];
23238 + tokens *= sched_pc->fill_rate[0];
23239 +#ifdef CONFIG_VSERVER_HARDCPU
23240 + delta_min[0] = delta - integral;
23241 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23243 + /* advance time */
23244 + sched_pc->norm_time += delta;
23247 + sched_pc->tokens += tokens;
23248 + sched_pc->token_time += tokens;
23250 + delta_min[0] = delta;
23252 +#ifdef CONFIG_VSERVER_IDLETIME
23253 + if (!(flags & VXSF_IDLE_TIME))
23256 + /* how much was the idle skip? */
23257 + delta = *idle_time - sched_pc->idle_time;
23258 + vxd_check_range(delta, 0, INT_MAX);
23260 + if (delta >= sched_pc->interval[1]) {
23261 + long tokens, integral;
23263 + /* calc fair share token part */
23264 + tokens = delta / sched_pc->interval[1];
23265 + integral = tokens * sched_pc->interval[1];
23266 + tokens *= sched_pc->fill_rate[1];
23267 + delta_min[1] = delta - integral;
23268 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23270 + /* advance idle time */
23271 + sched_pc->idle_time += integral;
23274 + sched_pc->tokens += tokens;
23275 + sched_pc->token_time += tokens;
23277 + delta_min[1] = delta;
23281 + /* clip at maximum */
23282 + if (sched_pc->tokens > sched_pc->tokens_max)
23283 + sched_pc->tokens = sched_pc->tokens_max;
23284 + tokens = sched_pc->tokens;
23286 + if ((flags & VXSF_ONHOLD)) {
23287 + /* can we unhold? */
23288 + if (tokens >= sched_pc->tokens_min) {
23289 + flags &= ~VXSF_ONHOLD;
23290 + sched_pc->hold_ticks +=
23291 + *norm_time - sched_pc->onhold;
23295 + /* put on hold? */
23296 + if (tokens <= 0) {
23297 + flags |= VXSF_ONHOLD;
23298 + sched_pc->onhold = *norm_time;
23302 + sched_pc->flags = flags;
23306 + tokens = sched_pc->tokens_min - tokens;
23307 + sched_pc->flags = flags;
23308 + // BUG_ON(tokens < 0); probably doesn't hold anymore
23310 +#ifdef CONFIG_VSERVER_HARDCPU
23311 + /* next interval? */
23312 + if (!sched_pc->fill_rate[0])
23313 + delta_min[0] = HZ;
23314 + else if (tokens > sched_pc->fill_rate[0])
23315 + delta_min[0] += sched_pc->interval[0] *
23316 + tokens / sched_pc->fill_rate[0];
23318 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
23319 + vxd_check_range(delta_min[0], 0, INT_MAX);
23321 +#ifdef CONFIG_VSERVER_IDLETIME
23322 + if (!(flags & VXSF_IDLE_TIME))
23325 + /* next interval? */
23326 + if (!sched_pc->fill_rate[1])
23327 + delta_min[1] = HZ;
23328 + else if (tokens > sched_pc->fill_rate[1])
23329 + delta_min[1] += sched_pc->interval[1] *
23330 + tokens / sched_pc->fill_rate[1];
23332 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
23333 + vxd_check_range(delta_min[1], 0, INT_MAX);
23338 +#endif /* CONFIG_VSERVER_IDLETIME */
23341 +#endif /* CONFIG_VSERVER_HARDCPU */
23344 +static inline unsigned long msec_to_ticks(unsigned long msec)
23346 + return msecs_to_jiffies(msec);
23349 +static inline unsigned long ticks_to_msec(unsigned long ticks)
23351 + return jiffies_to_msecs(ticks);
23354 +static inline unsigned long ticks_to_usec(unsigned long ticks)
23356 + return jiffies_to_usecs(ticks);
23360 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
23362 + unsigned int set_mask = data->mask;
23363 + unsigned int update_mask;
23366 + /* Sanity check data values */
23367 + if (data->tokens_max <= 0)
23368 + data->tokens_max = HZ;
23369 + if (data->tokens_min < 0)
23370 + data->tokens_min = HZ / 3;
23371 + if (data->tokens_min >= data->tokens_max)
23372 + data->tokens_min = data->tokens_max;
23374 + if (data->prio_bias > MAX_PRIO_BIAS)
23375 + data->prio_bias = MAX_PRIO_BIAS;
23376 + if (data->prio_bias < MIN_PRIO_BIAS)
23377 + data->prio_bias = MIN_PRIO_BIAS;
23379 + spin_lock(&vxi->sched.tokens_lock);
23381 + /* sync up on delayed updates */
23382 + for_each_cpu_mask(cpu, vxi->sched.update)
23383 + vx_update_sched_param(&vxi->sched,
23384 + &vx_per_cpu(vxi, sched_pc, cpu));
23386 + if (set_mask & VXSM_FILL_RATE)
23387 + vxi->sched.fill_rate[0] = data->fill_rate[0];
23388 + if (set_mask & VXSM_FILL_RATE2)
23389 + vxi->sched.fill_rate[1] = data->fill_rate[1];
23390 + if (set_mask & VXSM_INTERVAL)
23391 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
23392 + msec_to_ticks(data->interval[0]) : data->interval[0];
23393 + if (set_mask & VXSM_INTERVAL2)
23394 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
23395 + msec_to_ticks(data->interval[1]) : data->interval[1];
23396 + if (set_mask & VXSM_TOKENS)
23397 + vxi->sched.tokens = data->tokens;
23398 + if (set_mask & VXSM_TOKENS_MIN)
23399 + vxi->sched.tokens_min = data->tokens_min;
23400 + if (set_mask & VXSM_TOKENS_MAX)
23401 + vxi->sched.tokens_max = data->tokens_max;
23402 + if (set_mask & VXSM_PRIO_BIAS)
23403 + vxi->sched.prio_bias = data->prio_bias;
23405 + /* Sanity check rate/interval */
23406 + for (i = 0; i < 2; i++) {
23407 + if (data->fill_rate[i] < 0)
23408 + data->fill_rate[i] = 0;
23409 + if (data->interval[i] <= 0)
23410 + data->interval[i] = HZ;
23413 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
23414 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
23415 + vxi->sched.update_mask = update_mask;
23419 + if (set_mask & VXSM_CPU_ID) {
23420 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
23421 + cpus_and(vxi->sched.update, cpu_online_map,
23422 + vxi->sched.update);
23424 + vxi->sched.update = cpu_online_map;
23426 + /* forced reload? */
23427 + if (set_mask & VXSM_FORCE) {
23428 + for_each_cpu_mask(cpu, vxi->sched.update)
23429 + vx_update_sched_param(&vxi->sched,
23430 + &vx_per_cpu(vxi, sched_pc, cpu));
23431 + vxi->sched.update = CPU_MASK_NONE;
23434 + /* on UP we update immediately */
23435 + vx_update_sched_param(&vxi->sched,
23436 + &vx_per_cpu(vxi, sched_pc, 0));
23439 + spin_unlock(&vxi->sched.tokens_lock);
23444 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
23445 +#define COPY_PRI(C) C(prio_bias)
23446 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23447 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23448 + C(fill_rate[1]); C(interval[1]);
23450 +#define COPY_VALUE(name) vc_data.name = data->name
23452 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
23454 + struct vcmd_sched_v5 vc_data;
23456 + vc_data.mask = data->set_mask;
23457 + COPY_IDS(COPY_VALUE);
23458 + COPY_PRI(COPY_VALUE);
23459 + COPY_TOK(COPY_VALUE);
23460 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
23461 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
23462 + return do_set_sched(vxi, &vc_data);
23465 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
23467 + struct vcmd_set_sched_v4 vc_data;
23469 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23472 + return do_set_sched_v4(vxi, &vc_data);
23475 + /* latest interface is v5 */
23477 +int vc_set_sched(struct vx_info *vxi, void __user *data)
23479 + struct vcmd_sched_v5 vc_data;
23481 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23484 + return do_set_sched(vxi, &vc_data);
23488 +#define COPY_PRI(C) C(prio_bias)
23489 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23490 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23491 + C(fill_rate[1]); C(interval[1]);
23493 +#define COPY_VALUE(name) vc_data.name = data->name
23496 +int vc_get_sched(struct vx_info *vxi, void __user *data)
23498 + struct vcmd_sched_v5 vc_data;
23500 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23503 + if (vc_data.mask & VXSM_CPU_ID) {
23504 + int cpu = vc_data.cpu_id;
23505 + struct _vx_sched_pc *data;
23507 + if (!cpu_possible(cpu))
23510 + data = &vx_per_cpu(vxi, sched_pc, cpu);
23511 + COPY_TOK(COPY_VALUE);
23512 + COPY_PRI(COPY_VALUE);
23513 + COPY_FRI(COPY_VALUE);
23515 + if (data->flags & VXSF_IDLE_TIME)
23516 + vc_data.mask |= VXSM_IDLE_TIME;
23518 + struct _vx_sched *data = &vxi->sched;
23520 + COPY_TOK(COPY_VALUE);
23521 + COPY_PRI(COPY_VALUE);
23522 + COPY_FRI(COPY_VALUE);
23525 + if (vc_data.mask & VXSM_MSEC) {
23526 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
23527 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
23530 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23536 +int vc_sched_info(struct vx_info *vxi, void __user *data)
23538 + struct vcmd_sched_info vc_data;
23541 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23544 + cpu = vc_data.cpu_id;
23545 + if (!cpu_possible(cpu))
23549 + struct _vx_sched_pc *sched_pc =
23550 + &vx_per_cpu(vxi, sched_pc, cpu);
23552 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
23553 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
23554 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
23555 + vc_data.vavavoom = sched_pc->vavavoom;
23557 + vc_data.token_usec = ticks_to_usec(1);
23559 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23564 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sched_init.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sched_init.h
23565 --- linux-2.6.33/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
23566 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sched_init.h 2010-02-25 12:02:16.000000000 +0100
23569 +static inline void vx_info_init_sched(struct _vx_sched *sched)
23571 + static struct lock_class_key tokens_lock_key;
23573 + /* scheduling; hard code starting values as constants */
23574 + sched->fill_rate[0] = 1;
23575 + sched->interval[0] = 4;
23576 + sched->fill_rate[1] = 1;
23577 + sched->interval[1] = 8;
23578 + sched->tokens = HZ >> 2;
23579 + sched->tokens_min = HZ >> 4;
23580 + sched->tokens_max = HZ >> 1;
23581 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
23582 + sched->prio_bias = 0;
23584 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
23588 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
23590 + sched_pc->fill_rate[0] = 1;
23591 + sched_pc->interval[0] = 4;
23592 + sched_pc->fill_rate[1] = 1;
23593 + sched_pc->interval[1] = 8;
23594 + sched_pc->tokens = HZ >> 2;
23595 + sched_pc->tokens_min = HZ >> 4;
23596 + sched_pc->tokens_max = HZ >> 1;
23597 + sched_pc->prio_bias = 0;
23598 + sched_pc->vavavoom = 0;
23599 + sched_pc->token_time = 0;
23600 + sched_pc->idle_time = 0;
23601 + sched_pc->norm_time = jiffies;
23603 + sched_pc->user_ticks = 0;
23604 + sched_pc->sys_ticks = 0;
23605 + sched_pc->hold_ticks = 0;
23608 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
23614 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
23618 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sched_proc.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sched_proc.h
23619 --- linux-2.6.33/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
23620 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sched_proc.h 2010-02-25 12:02:16.000000000 +0100
23622 +#ifndef _VX_SCHED_PROC_H
23623 +#define _VX_SCHED_PROC_H
23627 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
23631 + length += sprintf(buffer,
23632 + "FillRate:\t%8d,%d\n"
23633 + "Interval:\t%8d,%d\n"
23634 + "TokensMin:\t%8d\n"
23635 + "TokensMax:\t%8d\n"
23636 + "PrioBias:\t%8d\n",
23637 + sched->fill_rate[0],
23638 + sched->fill_rate[1],
23639 + sched->interval[0],
23640 + sched->interval[1],
23641 + sched->tokens_min,
23642 + sched->tokens_max,
23643 + sched->prio_bias);
23648 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
23649 + char *buffer, int cpu)
23653 + length += sprintf(buffer + length,
23654 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
23655 + (unsigned long long)sched_pc->user_ticks,
23656 + (unsigned long long)sched_pc->sys_ticks,
23657 + (unsigned long long)sched_pc->hold_ticks,
23658 + sched_pc->token_time,
23659 + sched_pc->idle_time);
23660 + length += sprintf(buffer + length,
23661 + " %c%c %d %d %d %d/%d %d/%d",
23662 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
23663 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
23664 + sched_pc->tokens,
23665 + sched_pc->tokens_min,
23666 + sched_pc->tokens_max,
23667 + sched_pc->fill_rate[0],
23668 + sched_pc->interval[0],
23669 + sched_pc->fill_rate[1],
23670 + sched_pc->interval[1]);
23671 + length += sprintf(buffer + length,
23673 + sched_pc->prio_bias,
23674 + sched_pc->vavavoom);
23678 +#endif /* _VX_SCHED_PROC_H */
23679 diff -NurpP --minimal linux-2.6.33/kernel/vserver/signal.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/signal.c
23680 --- linux-2.6.33/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
23681 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/signal.c 2010-02-25 12:02:16.000000000 +0100
23684 + * linux/kernel/vserver/signal.c
23686 + * Virtual Server: Signal Support
23688 + * Copyright (C) 2003-2007 Herbert Pötzl
23690 + * V0.01 broken out from vcontext V0.05
23691 + * V0.02 changed vcmds to vxi arg
23692 + * V0.03 adjusted siginfo for kill
23696 +#include <asm/uaccess.h>
23698 +#include <linux/vs_context.h>
23699 +#include <linux/vs_pid.h>
23700 +#include <linux/vserver/signal_cmd.h>
23703 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
23705 + int retval, count = 0;
23706 + struct task_struct *p;
23707 + struct siginfo *sip = SEND_SIG_PRIV;
23710 + vxdprintk(VXD_CBIT(misc, 4),
23711 + "vx_info_kill(%p[#%d],%d,%d)*",
23712 + vxi, vxi->vx_id, pid, sig);
23713 + read_lock(&tasklist_lock);
23717 + for_each_process(p) {
23720 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
23721 + (pid && vxi->vx_initpid == p->pid))
23724 + err = group_send_sig_info(sig, sip, p);
23726 + if (err != -EPERM)
23732 + if (vxi->vx_initpid) {
23733 + pid = vxi->vx_initpid;
23734 + /* for now, only SIGINT to private init ... */
23735 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
23736 + /* ... as long as there are tasks left */
23737 + (atomic_read(&vxi->vx_tasks) > 1))
23740 + /* fallthrough */
23742 + p = find_task_by_real_pid(pid);
23744 + if (vx_task_xid(p) == vxi->vx_id)
23745 + retval = group_send_sig_info(sig, sip, p);
23749 + read_unlock(&tasklist_lock);
23750 + vxdprintk(VXD_CBIT(misc, 4),
23751 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
23752 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
23756 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
23758 + struct vcmd_ctx_kill_v0 vc_data;
23760 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23763 + /* special check to allow guest shutdown */
23764 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
23765 + /* forbid killall pid=0 when init is present */
23766 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
23767 + (vc_data.pid > 1)))
23770 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
23774 +static int __wait_exit(struct vx_info *vxi)
23776 + DECLARE_WAITQUEUE(wait, current);
23779 + add_wait_queue(&vxi->vx_wait, &wait);
23780 + set_current_state(TASK_INTERRUPTIBLE);
23783 + if (vx_info_state(vxi,
23784 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
23786 + if (signal_pending(current)) {
23787 + ret = -ERESTARTSYS;
23794 + set_current_state(TASK_RUNNING);
23795 + remove_wait_queue(&vxi->vx_wait, &wait);
23801 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
23803 + struct vcmd_wait_exit_v0 vc_data;
23806 + ret = __wait_exit(vxi);
23807 + vc_data.reboot_cmd = vxi->reboot_cmd;
23808 + vc_data.exit_code = vxi->exit_code;
23810 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23815 diff -NurpP --minimal linux-2.6.33/kernel/vserver/space.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/space.c
23816 --- linux-2.6.33/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
23817 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/space.c 2010-02-25 12:02:16.000000000 +0100
23820 + * linux/kernel/vserver/space.c
23822 + * Virtual Server: Context Space Support
23824 + * Copyright (C) 2003-2007 Herbert Pötzl
23826 + * V0.01 broken out from context.c 0.07
23827 + * V0.02 added task locking for namespace
23828 + * V0.03 broken out vx_enter_namespace
23829 + * V0.04 added *space support and commands
23833 +#include <linux/utsname.h>
23834 +#include <linux/nsproxy.h>
23835 +#include <linux/err.h>
23836 +#include <linux/fs_struct.h>
23837 +#include <asm/uaccess.h>
23839 +#include <linux/vs_context.h>
23840 +#include <linux/vserver/space.h>
23841 +#include <linux/vserver/space_cmd.h>
23843 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
23844 +atomic_t vs_global_fs = ATOMIC_INIT(0);
23845 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
23846 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
23847 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
23848 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
23851 +/* namespace functions */
23853 +#include <linux/mnt_namespace.h>
23854 +#include <linux/user_namespace.h>
23855 +#include <linux/pid_namespace.h>
23856 +#include <linux/ipc_namespace.h>
23857 +#include <net/net_namespace.h>
23860 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
23861 + .mask = CLONE_FS |
23869 +static const struct vcmd_space_mask_v1 space_mask = {
23870 + .mask = CLONE_FS |
23875 +#ifdef CONFIG_PID_NS
23878 +#ifdef CONFIG_NET_NS
23884 +static const struct vcmd_space_mask_v1 default_space_mask = {
23885 + .mask = CLONE_FS |
23890 +#ifdef CONFIG_PID_NS
23897 + * build a new nsproxy mix
23898 + * assumes that both proxies are 'const'
23899 + * does not touch nsproxy refcounts
23900 + * will hold a reference on the result.
23903 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
23904 + struct nsproxy *new_nsproxy, unsigned long mask)
23906 + struct mnt_namespace *old_ns;
23907 + struct uts_namespace *old_uts;
23908 + struct ipc_namespace *old_ipc;
23909 +#ifdef CONFIG_PID_NS
23910 + struct pid_namespace *old_pid;
23912 +#ifdef CONFIG_NET_NS
23913 + struct net *old_net;
23915 + struct nsproxy *nsproxy;
23917 + nsproxy = copy_nsproxy(old_nsproxy);
23921 + if (mask & CLONE_NEWNS) {
23922 + old_ns = nsproxy->mnt_ns;
23923 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23924 + if (nsproxy->mnt_ns)
23925 + get_mnt_ns(nsproxy->mnt_ns);
23929 + if (mask & CLONE_NEWUTS) {
23930 + old_uts = nsproxy->uts_ns;
23931 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23932 + if (nsproxy->uts_ns)
23933 + get_uts_ns(nsproxy->uts_ns);
23937 + if (mask & CLONE_NEWIPC) {
23938 + old_ipc = nsproxy->ipc_ns;
23939 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23940 + if (nsproxy->ipc_ns)
23941 + get_ipc_ns(nsproxy->ipc_ns);
23945 +#ifdef CONFIG_PID_NS
23946 + if (mask & CLONE_NEWPID) {
23947 + old_pid = nsproxy->pid_ns;
23948 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23949 + if (nsproxy->pid_ns)
23950 + get_pid_ns(nsproxy->pid_ns);
23954 +#ifdef CONFIG_NET_NS
23955 + if (mask & CLONE_NEWNET) {
23956 + old_net = nsproxy->net_ns;
23957 + nsproxy->net_ns = new_nsproxy->net_ns;
23958 + if (nsproxy->net_ns)
23959 + get_net(nsproxy->net_ns);
23964 + put_mnt_ns(old_ns);
23966 + put_uts_ns(old_uts);
23968 + put_ipc_ns(old_ipc);
23969 +#ifdef CONFIG_PID_NS
23971 + put_pid_ns(old_pid);
23973 +#ifdef CONFIG_NET_NS
23975 + put_net(old_net);
23983 + * merge two nsproxy structs into a new one.
23984 + * will hold a reference on the result.
23988 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23989 + struct nsproxy *proxy, unsigned long mask)
23991 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23997 + /* vs_mix_nsproxy returns with reference */
23998 + return vs_mix_nsproxy(old ? old : &null_proxy,
24001 + get_nsproxy(proxy);
24006 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24008 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24009 + struct fs_struct *fs_cur, *fs = NULL;
24010 + int ret, kill = 0;
24012 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24013 + vxi, vxi->vx_id, mask, index);
24015 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24019 + mask = vxi->vx_nsmask[index];
24021 + if ((mask & vxi->vx_nsmask[index]) != mask)
24024 + if (mask & CLONE_FS) {
24025 + fs = copy_fs_struct(vxi->vx_fs[index]);
24029 + proxy = vxi->vx_nsproxy[index];
24031 + vxdprintk(VXD_CBIT(space, 9),
24032 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
24033 + vxi, vxi->vx_id, mask, index, proxy, fs);
24035 + task_lock(current);
24036 + fs_cur = current->fs;
24038 + if (mask & CLONE_FS) {
24039 + write_lock(&fs_cur->lock);
24040 + current->fs = fs;
24041 + kill = !--fs_cur->users;
24042 + write_unlock(&fs_cur->lock);
24045 + proxy_cur = current->nsproxy;
24046 + get_nsproxy(proxy_cur);
24047 + task_unlock(current);
24050 + free_fs_struct(fs_cur);
24052 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24053 + if (IS_ERR(proxy_new)) {
24054 + ret = PTR_ERR(proxy_new);
24058 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24062 + put_nsproxy(proxy_new);
24065 + put_nsproxy(proxy_cur);
24070 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24072 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24073 + struct fs_struct *fs_vxi, *fs;
24074 + int ret, kill = 0;
24076 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24077 + vxi, vxi->vx_id, mask, index);
24080 + mask = default_space_mask.mask;
24082 + if ((mask & space_mask.mask) != mask)
24085 + proxy_vxi = vxi->vx_nsproxy[index];
24086 + fs_vxi = vxi->vx_fs[index];
24088 + if (mask & CLONE_FS) {
24089 + fs = copy_fs_struct(current->fs);
24094 + task_lock(current);
24096 + if (mask & CLONE_FS) {
24097 + write_lock(&fs_vxi->lock);
24098 + vxi->vx_fs[index] = fs;
24099 + kill = !--fs_vxi->users;
24100 + write_unlock(&fs_vxi->lock);
24103 + proxy_cur = current->nsproxy;
24104 + get_nsproxy(proxy_cur);
24105 + task_unlock(current);
24108 + free_fs_struct(fs_vxi);
24110 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24111 + if (IS_ERR(proxy_new)) {
24112 + ret = PTR_ERR(proxy_new);
24116 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
24117 + vxi->vx_nsmask[index] |= mask;
24121 + put_nsproxy(proxy_new);
24124 + put_nsproxy(proxy_cur);
24129 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24131 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24133 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24136 + return vx_enter_space(vxi, vc_data.mask, 0);
24139 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24141 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24143 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24146 + if (vc_data.index >= VX_SPACES)
24149 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24152 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24154 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24156 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24159 + return vx_set_space(vxi, vc_data.mask, 0);
24162 +int vc_set_space(struct vx_info *vxi, void __user *data)
24164 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24166 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24169 + if (vc_data.index >= VX_SPACES)
24172 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
24175 +int vc_get_space_mask(void __user *data, int type)
24177 + const struct vcmd_space_mask_v1 *mask;
24180 + mask = &space_mask_v0;
24181 + else if (type == 1)
24182 + mask = &space_mask;
24184 + mask = &default_space_mask;
24186 + vxdprintk(VXD_CBIT(space, 10),
24187 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24189 + if (copy_to_user(data, mask, sizeof(*mask)))
24194 diff -NurpP --minimal linux-2.6.33/kernel/vserver/switch.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/switch.c
24195 --- linux-2.6.33/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24196 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/switch.c 2010-02-25 12:02:16.000000000 +0100
24199 + * linux/kernel/vserver/switch.c
24201 + * Virtual Server: Syscall Switch
24203 + * Copyright (C) 2003-2007 Herbert Pötzl
24205 + * V0.01 syscall switch
24206 + * V0.02 added signal to context
24207 + * V0.03 added rlimit functions
24208 + * V0.04 added iattr, task/xid functions
24209 + * V0.05 added debug/history stuff
24210 + * V0.06 added compat32 layer
24211 + * V0.07 vcmd args and perms
24212 + * V0.08 added status commands
24213 + * V0.09 added tag commands
24214 + * V0.10 added oom bias
24215 + * V0.11 added device commands
24219 +#include <linux/vs_context.h>
24220 +#include <linux/vs_network.h>
24221 +#include <linux/vserver/switch.h>
24223 +#include "vci_config.h"
24227 +int vc_get_version(uint32_t id)
24229 + return VCI_VERSION;
24233 +int vc_get_vci(uint32_t id)
24235 + return vci_kernel_config();
24238 +#include <linux/vserver/context_cmd.h>
24239 +#include <linux/vserver/cvirt_cmd.h>
24240 +#include <linux/vserver/cacct_cmd.h>
24241 +#include <linux/vserver/limit_cmd.h>
24242 +#include <linux/vserver/network_cmd.h>
24243 +#include <linux/vserver/sched_cmd.h>
24244 +#include <linux/vserver/debug_cmd.h>
24245 +#include <linux/vserver/inode_cmd.h>
24246 +#include <linux/vserver/dlimit_cmd.h>
24247 +#include <linux/vserver/signal_cmd.h>
24248 +#include <linux/vserver/space_cmd.h>
24249 +#include <linux/vserver/tag_cmd.h>
24250 +#include <linux/vserver/device_cmd.h>
24252 +#include <linux/vserver/inode.h>
24253 +#include <linux/vserver/dlimit.h>
24256 +#ifdef CONFIG_COMPAT
24257 +#define __COMPAT(name, id, data, compat) \
24258 + (compat) ? name ## _x32(id, data) : name(id, data)
24259 +#define __COMPAT_NO_ID(name, data, compat) \
24260 + (compat) ? name ## _x32(data) : name(data)
24262 +#define __COMPAT(name, id, data, compat) \
24264 +#define __COMPAT_NO_ID(name, data, compat) \
24270 +long do_vcmd(uint32_t cmd, uint32_t id,
24271 + struct vx_info *vxi, struct nx_info *nxi,
24272 + void __user *data, int compat)
24276 + case VCMD_get_version:
24277 + return vc_get_version(id);
24278 + case VCMD_get_vci:
24279 + return vc_get_vci(id);
24281 + case VCMD_task_xid:
24282 + return vc_task_xid(id);
24283 + case VCMD_vx_info:
24284 + return vc_vx_info(vxi, data);
24286 + case VCMD_task_nid:
24287 + return vc_task_nid(id);
24288 + case VCMD_nx_info:
24289 + return vc_nx_info(nxi, data);
24291 + case VCMD_task_tag:
24292 + return vc_task_tag(id);
24294 + case VCMD_set_space_v1:
24295 + return vc_set_space_v1(vxi, data);
24296 + /* this is version 2 */
24297 + case VCMD_set_space:
24298 + return vc_set_space(vxi, data);
24300 + case VCMD_get_space_mask_v0:
24301 + return vc_get_space_mask(data, 0);
24302 + /* this is version 1 */
24303 + case VCMD_get_space_mask:
24304 + return vc_get_space_mask(data, 1);
24306 + case VCMD_get_space_default:
24307 + return vc_get_space_mask(data, -1);
24309 +#ifdef CONFIG_IA32_EMULATION
24310 + case VCMD_get_rlimit:
24311 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24312 + case VCMD_set_rlimit:
24313 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24315 + case VCMD_get_rlimit:
24316 + return vc_get_rlimit(vxi, data);
24317 + case VCMD_set_rlimit:
24318 + return vc_set_rlimit(vxi, data);
24320 + case VCMD_get_rlimit_mask:
24321 + return vc_get_rlimit_mask(id, data);
24322 + case VCMD_reset_hits:
24323 + return vc_reset_hits(vxi, data);
24324 + case VCMD_reset_minmax:
24325 + return vc_reset_minmax(vxi, data);
24327 + case VCMD_get_vhi_name:
24328 + return vc_get_vhi_name(vxi, data);
24329 + case VCMD_set_vhi_name:
24330 + return vc_set_vhi_name(vxi, data);
24332 + case VCMD_ctx_stat:
24333 + return vc_ctx_stat(vxi, data);
24334 + case VCMD_virt_stat:
24335 + return vc_virt_stat(vxi, data);
24336 + case VCMD_sock_stat:
24337 + return vc_sock_stat(vxi, data);
24338 + case VCMD_rlimit_stat:
24339 + return vc_rlimit_stat(vxi, data);
24341 + case VCMD_set_cflags:
24342 + return vc_set_cflags(vxi, data);
24343 + case VCMD_get_cflags:
24344 + return vc_get_cflags(vxi, data);
24346 + /* this is version 1 */
24347 + case VCMD_set_ccaps:
24348 + return vc_set_ccaps(vxi, data);
24349 + /* this is version 1 */
24350 + case VCMD_get_ccaps:
24351 + return vc_get_ccaps(vxi, data);
24352 + case VCMD_set_bcaps:
24353 + return vc_set_bcaps(vxi, data);
24354 + case VCMD_get_bcaps:
24355 + return vc_get_bcaps(vxi, data);
24357 + case VCMD_set_badness:
24358 + return vc_set_badness(vxi, data);
24359 + case VCMD_get_badness:
24360 + return vc_get_badness(vxi, data);
24362 + case VCMD_set_nflags:
24363 + return vc_set_nflags(nxi, data);
24364 + case VCMD_get_nflags:
24365 + return vc_get_nflags(nxi, data);
24367 + case VCMD_set_ncaps:
24368 + return vc_set_ncaps(nxi, data);
24369 + case VCMD_get_ncaps:
24370 + return vc_get_ncaps(nxi, data);
24372 + case VCMD_set_sched_v4:
24373 + return vc_set_sched_v4(vxi, data);
24374 + /* this is version 5 */
24375 + case VCMD_set_sched:
24376 + return vc_set_sched(vxi, data);
24377 + case VCMD_get_sched:
24378 + return vc_get_sched(vxi, data);
24379 + case VCMD_sched_info:
24380 + return vc_sched_info(vxi, data);
24382 + case VCMD_add_dlimit:
24383 + return __COMPAT(vc_add_dlimit, id, data, compat);
24384 + case VCMD_rem_dlimit:
24385 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24386 + case VCMD_set_dlimit:
24387 + return __COMPAT(vc_set_dlimit, id, data, compat);
24388 + case VCMD_get_dlimit:
24389 + return __COMPAT(vc_get_dlimit, id, data, compat);
24391 + case VCMD_ctx_kill:
24392 + return vc_ctx_kill(vxi, data);
24394 + case VCMD_wait_exit:
24395 + return vc_wait_exit(vxi, data);
24397 + case VCMD_get_iattr:
24398 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24399 + case VCMD_set_iattr:
24400 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24402 + case VCMD_fget_iattr:
24403 + return vc_fget_iattr(id, data);
24404 + case VCMD_fset_iattr:
24405 + return vc_fset_iattr(id, data);
24407 + case VCMD_enter_space_v0:
24408 + return vc_enter_space_v1(vxi, NULL);
24409 + case VCMD_enter_space_v1:
24410 + return vc_enter_space_v1(vxi, data);
24411 + /* this is version 2 */
24412 + case VCMD_enter_space:
24413 + return vc_enter_space(vxi, data);
24415 + case VCMD_ctx_create_v0:
24416 + return vc_ctx_create(id, NULL);
24417 + case VCMD_ctx_create:
24418 + return vc_ctx_create(id, data);
24419 + case VCMD_ctx_migrate_v0:
24420 + return vc_ctx_migrate(vxi, NULL);
24421 + case VCMD_ctx_migrate:
24422 + return vc_ctx_migrate(vxi, data);
24424 + case VCMD_net_create_v0:
24425 + return vc_net_create(id, NULL);
24426 + case VCMD_net_create:
24427 + return vc_net_create(id, data);
24428 + case VCMD_net_migrate:
24429 + return vc_net_migrate(nxi, data);
24431 + case VCMD_tag_migrate:
24432 + return vc_tag_migrate(id);
24434 + case VCMD_net_add:
24435 + return vc_net_add(nxi, data);
24436 + case VCMD_net_remove:
24437 + return vc_net_remove(nxi, data);
24439 + case VCMD_net_add_ipv4:
24440 + return vc_net_add_ipv4(nxi, data);
24441 + case VCMD_net_remove_ipv4:
24442 + return vc_net_remove_ipv4(nxi, data);
24443 +#ifdef CONFIG_IPV6
24444 + case VCMD_net_add_ipv6:
24445 + return vc_net_add_ipv6(nxi, data);
24446 + case VCMD_net_remove_ipv6:
24447 + return vc_net_remove_ipv6(nxi, data);
24449 +/* case VCMD_add_match_ipv4:
24450 + return vc_add_match_ipv4(nxi, data);
24451 + case VCMD_get_match_ipv4:
24452 + return vc_get_match_ipv4(nxi, data);
24453 +#ifdef CONFIG_IPV6
24454 + case VCMD_add_match_ipv6:
24455 + return vc_add_match_ipv6(nxi, data);
24456 + case VCMD_get_match_ipv6:
24457 + return vc_get_match_ipv6(nxi, data);
24460 +#ifdef CONFIG_VSERVER_DEVICE
24461 + case VCMD_set_mapping:
24462 + return __COMPAT(vc_set_mapping, vxi, data, compat);
24463 + case VCMD_unset_mapping:
24464 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
24466 +#ifdef CONFIG_VSERVER_HISTORY
24467 + case VCMD_dump_history:
24468 + return vc_dump_history(id);
24469 + case VCMD_read_history:
24470 + return __COMPAT(vc_read_history, id, data, compat);
24472 +#ifdef CONFIG_VSERVER_MONITOR
24473 + case VCMD_read_monitor:
24474 + return __COMPAT(vc_read_monitor, id, data, compat);
24477 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
24478 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
24484 +#define __VCMD(vcmd, _perm, _args, _flags) \
24485 + case VCMD_ ## vcmd: perm = _perm; \
24486 + args = _args; flags = _flags; break
24489 +#define VCA_NONE 0x00
24490 +#define VCA_VXI 0x01
24491 +#define VCA_NXI 0x02
24493 +#define VCF_NONE 0x00
24494 +#define VCF_INFO 0x01
24495 +#define VCF_ADMIN 0x02
24496 +#define VCF_ARES 0x06 /* includes admin */
24497 +#define VCF_SETUP 0x08
24499 +#define VCF_ZIDOK 0x10 /* zero id okay */
24503 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
24506 + int permit = -1, state = 0;
24507 + int perm = -1, args = 0, flags = 0;
24508 + struct vx_info *vxi = NULL;
24509 + struct nx_info *nxi = NULL;
24512 + /* unpriviledged commands */
24513 + __VCMD(get_version, 0, VCA_NONE, 0);
24514 + __VCMD(get_vci, 0, VCA_NONE, 0);
24515 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
24516 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
24517 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
24518 + __VCMD(get_space_default,0, VCA_NONE, 0);
24520 + /* info commands */
24521 + __VCMD(task_xid, 2, VCA_NONE, 0);
24522 + __VCMD(reset_hits, 2, VCA_VXI, 0);
24523 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
24524 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
24525 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
24526 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
24527 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
24528 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
24529 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
24530 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
24532 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
24533 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
24534 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
24535 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
24537 + __VCMD(task_nid, 2, VCA_NONE, 0);
24538 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
24539 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
24540 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
24542 + __VCMD(task_tag, 2, VCA_NONE, 0);
24544 + __VCMD(get_iattr, 2, VCA_NONE, 0);
24545 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
24546 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
24547 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
24548 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
24550 + /* lower admin commands */
24551 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
24552 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
24553 + __VCMD(ctx_create, 5, VCA_NONE, 0);
24554 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
24555 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
24556 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
24557 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
24558 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
24560 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
24561 + __VCMD(net_create, 5, VCA_NONE, 0);
24562 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
24564 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
24566 + /* higher admin commands */
24567 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
24568 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24569 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24571 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24572 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24573 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24574 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24576 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24577 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24578 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24579 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24581 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24582 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24583 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24584 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24585 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24586 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24587 +#ifdef CONFIG_IPV6
24588 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24589 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24591 + __VCMD(set_iattr, 7, VCA_NONE, 0);
24592 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
24593 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
24594 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
24595 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
24597 +#ifdef CONFIG_VSERVER_DEVICE
24598 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
24599 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
24601 + /* debug level admin commands */
24602 +#ifdef CONFIG_VSERVER_HISTORY
24603 + __VCMD(dump_history, 9, VCA_NONE, 0);
24604 + __VCMD(read_history, 9, VCA_NONE, 0);
24606 +#ifdef CONFIG_VSERVER_MONITOR
24607 + __VCMD(read_monitor, 9, VCA_NONE, 0);
24614 + vxdprintk(VXD_CBIT(switch, 0),
24615 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
24616 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24617 + VC_VERSION(cmd), id, data, compat,
24618 + perm, args, flags);
24625 + if (!capable(CAP_CONTEXT))
24629 + /* moved here from the individual commands */
24631 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
24635 + /* vcmd involves resource management */
24637 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
24641 + /* various legacy exceptions */
24643 + /* will go away when spectator is a cap */
24644 + case VCMD_ctx_migrate_v0:
24645 + case VCMD_ctx_migrate:
24647 + current->xid = 1;
24653 + /* will go away when spectator is a cap */
24654 + case VCMD_net_migrate:
24656 + current->nid = 1;
24663 + /* vcmds are fine by default */
24666 + /* admin type vcmds require admin ... */
24667 + if (flags & VCF_ADMIN)
24668 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
24670 + /* ... but setup type vcmds override that */
24671 + if (!permit && (flags & VCF_SETUP))
24672 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
24680 + if (!id && (flags & VCF_ZIDOK))
24684 + if (args & VCA_VXI) {
24685 + vxi = lookup_vx_info(id);
24689 + if ((flags & VCF_ADMIN) &&
24690 + /* special case kill for shutdown */
24691 + (cmd != VCMD_ctx_kill) &&
24692 + /* can context be administrated? */
24693 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
24699 + if (args & VCA_NXI) {
24700 + nxi = lookup_nx_info(id);
24704 + if ((flags & VCF_ADMIN) &&
24705 + /* can context be administrated? */
24706 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
24713 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
24716 + if ((args & VCA_NXI) && nxi)
24717 + put_nx_info(nxi);
24719 + if ((args & VCA_VXI) && vxi)
24720 + put_vx_info(vxi);
24722 + vxdprintk(VXD_CBIT(switch, 1),
24723 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
24724 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24725 + VC_VERSION(cmd), ret, ret, state, permit);
24730 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
24732 + return do_vserver(cmd, id, data, 0);
24735 +#ifdef CONFIG_COMPAT
24738 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
24740 + return do_vserver(cmd, id, data, 1);
24743 +#endif /* CONFIG_COMPAT */
24744 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sysctl.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sysctl.c
24745 --- linux-2.6.33/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
24746 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/sysctl.c 2010-02-25 15:14:16.000000000 +0100
24749 + * kernel/vserver/sysctl.c
24751 + * Virtual Context Support
24753 + * Copyright (C) 2004-2007 Herbert Pötzl
24755 + * V0.01 basic structure
24759 +#include <linux/module.h>
24760 +#include <linux/ctype.h>
24761 +#include <linux/sysctl.h>
24762 +#include <linux/parser.h>
24763 +#include <asm/uaccess.h>
24766 + CTL_DEBUG_ERROR = 0,
24767 + CTL_DEBUG_SWITCH = 1,
24782 +unsigned int vx_debug_switch = 0;
24783 +unsigned int vx_debug_xid = 0;
24784 +unsigned int vx_debug_nid = 0;
24785 +unsigned int vx_debug_tag = 0;
24786 +unsigned int vx_debug_net = 0;
24787 +unsigned int vx_debug_limit = 0;
24788 +unsigned int vx_debug_cres = 0;
24789 +unsigned int vx_debug_dlim = 0;
24790 +unsigned int vx_debug_quota = 0;
24791 +unsigned int vx_debug_cvirt = 0;
24792 +unsigned int vx_debug_space = 0;
24793 +unsigned int vx_debug_misc = 0;
24796 +static struct ctl_table_header *vserver_table_header;
24797 +static ctl_table vserver_root_table[];
24800 +void vserver_register_sysctl(void)
24802 + if (!vserver_table_header) {
24803 + vserver_table_header = register_sysctl_table(vserver_root_table);
24808 +void vserver_unregister_sysctl(void)
24810 + if (vserver_table_header) {
24811 + unregister_sysctl_table(vserver_table_header);
24812 + vserver_table_header = NULL;
24817 +static int proc_dodebug(ctl_table *table, int write,
24818 + void __user *buffer, size_t *lenp, loff_t *ppos)
24820 + char tmpbuf[20], *p, c;
24821 + unsigned int value;
24822 + size_t left, len;
24824 + if ((*ppos && !write) || !*lenp) {
24832 + if (!access_ok(VERIFY_READ, buffer, left))
24834 + p = (char *)buffer;
24835 + while (left && __get_user(c, p) >= 0 && isspace(c))
24840 + if (left > sizeof(tmpbuf) - 1)
24842 + if (copy_from_user(tmpbuf, p, left))
24844 + tmpbuf[left] = '\0';
24846 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
24847 + value = 10 * value + (*p - '0');
24848 + if (*p && !isspace(*p))
24850 + while (left && isspace(*p))
24852 + *(unsigned int *)table->data = value;
24854 + if (!access_ok(VERIFY_WRITE, buffer, left))
24856 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
24859 + if (__copy_to_user(buffer, tmpbuf, len))
24861 + if ((left -= len) > 0) {
24862 + if (put_user('\n', (char *)buffer + len))
24876 +#define CTL_ENTRY(ctl, name) \
24878 + .procname = #name, \
24879 + .data = &vx_ ## name, \
24880 + .maxlen = sizeof(int), \
24882 + .proc_handler = &proc_dodebug, \
24883 + .extra1 = &zero, \
24884 + .extra2 = &zero, \
24887 +static ctl_table vserver_debug_table[] = {
24888 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24889 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24890 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24891 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24892 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24893 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24894 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24895 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24896 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24897 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24898 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24899 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24903 +static ctl_table vserver_root_table[] = {
24905 + .procname = "vserver",
24907 + .child = vserver_debug_table
24913 +static match_table_t tokens = {
24914 + { CTL_DEBUG_SWITCH, "switch=%x" },
24915 + { CTL_DEBUG_XID, "xid=%x" },
24916 + { CTL_DEBUG_NID, "nid=%x" },
24917 + { CTL_DEBUG_TAG, "tag=%x" },
24918 + { CTL_DEBUG_NET, "net=%x" },
24919 + { CTL_DEBUG_LIMIT, "limit=%x" },
24920 + { CTL_DEBUG_CRES, "cres=%x" },
24921 + { CTL_DEBUG_DLIM, "dlim=%x" },
24922 + { CTL_DEBUG_QUOTA, "quota=%x" },
24923 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24924 + { CTL_DEBUG_SPACE, "space=%x" },
24925 + { CTL_DEBUG_MISC, "misc=%x" },
24926 + { CTL_DEBUG_ERROR, NULL }
24929 +#define HANDLE_CASE(id, name, val) \
24930 + case CTL_DEBUG_ ## id: \
24931 + vx_debug_ ## name = val; \
24932 + printk("vs_debug_" #name "=0x%x\n", val); \
24936 +static int __init vs_debug_setup(char *str)
24941 + printk("vs_debug_setup(%s)\n", str);
24942 + while ((p = strsep(&str, ",")) != NULL) {
24943 + substring_t args[MAX_OPT_ARGS];
24944 + unsigned int value;
24949 + token = match_token(p, tokens, args);
24950 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24953 + HANDLE_CASE(SWITCH, switch, value);
24954 + HANDLE_CASE(XID, xid, value);
24955 + HANDLE_CASE(NID, nid, value);
24956 + HANDLE_CASE(TAG, tag, value);
24957 + HANDLE_CASE(NET, net, value);
24958 + HANDLE_CASE(LIMIT, limit, value);
24959 + HANDLE_CASE(CRES, cres, value);
24960 + HANDLE_CASE(DLIM, dlim, value);
24961 + HANDLE_CASE(QUOTA, quota, value);
24962 + HANDLE_CASE(CVIRT, cvirt, value);
24963 + HANDLE_CASE(SPACE, space, value);
24964 + HANDLE_CASE(MISC, misc, value);
24973 +__setup("vsdebug=", vs_debug_setup);
24977 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24978 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24979 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24980 +EXPORT_SYMBOL_GPL(vx_debug_net);
24981 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24982 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24983 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24984 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24985 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24986 +EXPORT_SYMBOL_GPL(vx_debug_space);
24987 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24989 diff -NurpP --minimal linux-2.6.33/kernel/vserver/tag.c linux-2.6.33-vs2.3.0.36.30/kernel/vserver/tag.c
24990 --- linux-2.6.33/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24991 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/tag.c 2010-02-25 12:02:16.000000000 +0100
24994 + * linux/kernel/vserver/tag.c
24996 + * Virtual Server: Shallow Tag Space
24998 + * Copyright (C) 2007 Herbert Pötzl
25000 + * V0.01 basic implementation
25004 +#include <linux/sched.h>
25005 +#include <linux/vserver/debug.h>
25006 +#include <linux/vs_pid.h>
25007 +#include <linux/vs_tag.h>
25009 +#include <linux/vserver/tag_cmd.h>
25012 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25017 + vxdprintk(VXD_CBIT(tag, 5),
25018 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25024 + vxdprintk(VXD_CBIT(tag, 5),
25025 + "moved task %p into [#%d]", p, tag);
25029 +/* vserver syscall commands below here */
25031 +/* taks xid and vx_info functions */
25034 +int vc_task_tag(uint32_t id)
25039 + struct task_struct *tsk;
25040 + read_lock(&tasklist_lock);
25041 + tsk = find_task_by_real_pid(id);
25042 + tag = (tsk) ? tsk->tag : -ESRCH;
25043 + read_unlock(&tasklist_lock);
25045 + tag = dx_current_tag();
25050 +int vc_tag_migrate(uint32_t tag)
25052 + return dx_migrate_task(current, tag & 0xFFFF);
25056 diff -NurpP --minimal linux-2.6.33/kernel/vserver/vci_config.h linux-2.6.33-vs2.3.0.36.30/kernel/vserver/vci_config.h
25057 --- linux-2.6.33/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25058 +++ linux-2.6.33-vs2.3.0.36.30/kernel/vserver/vci_config.h 2010-02-25 12:02:16.000000000 +0100
25061 +/* interface version */
25063 +#define VCI_VERSION 0x00020305
25067 + VCI_KCBIT_NO_DYNAMIC = 0,
25069 + VCI_KCBIT_PROC_SECURE = 4,
25070 + VCI_KCBIT_HARDCPU = 5,
25071 + VCI_KCBIT_IDLELIMIT = 6,
25072 + VCI_KCBIT_IDLETIME = 7,
25074 + VCI_KCBIT_COWBL = 8,
25075 + VCI_KCBIT_FULLCOWBL = 9,
25076 + VCI_KCBIT_SPACES = 10,
25077 + VCI_KCBIT_NETV2 = 11,
25079 + VCI_KCBIT_DEBUG = 16,
25080 + VCI_KCBIT_HISTORY = 20,
25081 + VCI_KCBIT_TAGGED = 24,
25082 + VCI_KCBIT_PPTAG = 28,
25084 + VCI_KCBIT_MORE = 31,
25088 +static inline uint32_t vci_kernel_config(void)
25091 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25093 + /* configured features */
25094 +#ifdef CONFIG_VSERVER_PROC_SECURE
25095 + (1 << VCI_KCBIT_PROC_SECURE) |
25097 +#ifdef CONFIG_VSERVER_HARDCPU
25098 + (1 << VCI_KCBIT_HARDCPU) |
25100 +#ifdef CONFIG_VSERVER_IDLELIMIT
25101 + (1 << VCI_KCBIT_IDLELIMIT) |
25103 +#ifdef CONFIG_VSERVER_IDLETIME
25104 + (1 << VCI_KCBIT_IDLETIME) |
25106 +#ifdef CONFIG_VSERVER_COWBL
25107 + (1 << VCI_KCBIT_COWBL) |
25108 + (1 << VCI_KCBIT_FULLCOWBL) |
25110 + (1 << VCI_KCBIT_SPACES) |
25111 + (1 << VCI_KCBIT_NETV2) |
25113 + /* debug options */
25114 +#ifdef CONFIG_VSERVER_DEBUG
25115 + (1 << VCI_KCBIT_DEBUG) |
25117 +#ifdef CONFIG_VSERVER_HISTORY
25118 + (1 << VCI_KCBIT_HISTORY) |
25121 + /* inode context tagging */
25122 +#if defined(CONFIG_TAGGING_NONE)
25123 + (0 << VCI_KCBIT_TAGGED) |
25124 +#elif defined(CONFIG_TAGGING_UID16)
25125 + (1 << VCI_KCBIT_TAGGED) |
25126 +#elif defined(CONFIG_TAGGING_GID16)
25127 + (2 << VCI_KCBIT_TAGGED) |
25128 +#elif defined(CONFIG_TAGGING_ID24)
25129 + (3 << VCI_KCBIT_TAGGED) |
25130 +#elif defined(CONFIG_TAGGING_INTERN)
25131 + (4 << VCI_KCBIT_TAGGED) |
25132 +#elif defined(CONFIG_TAGGING_RUNTIME)
25133 + (5 << VCI_KCBIT_TAGGED) |
25135 + (7 << VCI_KCBIT_TAGGED) |
25137 + (1 << VCI_KCBIT_PPTAG) |
25141 diff -NurpP --minimal linux-2.6.33/mm/filemap_xip.c linux-2.6.33-vs2.3.0.36.30/mm/filemap_xip.c
25142 --- linux-2.6.33/mm/filemap_xip.c 2009-12-03 20:02:58.000000000 +0100
25143 +++ linux-2.6.33-vs2.3.0.36.30/mm/filemap_xip.c 2010-02-25 12:02:16.000000000 +0100
25145 #include <linux/sched.h>
25146 #include <linux/seqlock.h>
25147 #include <linux/mutex.h>
25148 +#include <linux/vs_memory.h>
25149 #include <asm/tlbflush.h>
25150 #include <asm/io.h>
25152 diff -NurpP --minimal linux-2.6.33/mm/fremap.c linux-2.6.33-vs2.3.0.36.30/mm/fremap.c
25153 --- linux-2.6.33/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
25154 +++ linux-2.6.33-vs2.3.0.36.30/mm/fremap.c 2010-02-25 12:02:16.000000000 +0100
25156 #include <linux/module.h>
25157 #include <linux/syscalls.h>
25158 #include <linux/mmu_notifier.h>
25159 +#include <linux/vs_memory.h>
25161 #include <asm/mmu_context.h>
25162 #include <asm/cacheflush.h>
25163 diff -NurpP --minimal linux-2.6.33/mm/hugetlb.c linux-2.6.33-vs2.3.0.36.30/mm/hugetlb.c
25164 --- linux-2.6.33/mm/hugetlb.c 2010-02-25 11:52:09.000000000 +0100
25165 +++ linux-2.6.33-vs2.3.0.36.30/mm/hugetlb.c 2010-02-25 12:16:11.000000000 +0100
25168 #include <linux/hugetlb.h>
25169 #include <linux/node.h>
25170 +#include <linux/vs_memory.h>
25171 #include "internal.h"
25173 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25174 diff -NurpP --minimal linux-2.6.33/mm/memcontrol.c linux-2.6.33-vs2.3.0.36.30/mm/memcontrol.c
25175 --- linux-2.6.33/mm/memcontrol.c 2010-02-25 11:52:09.000000000 +0100
25176 +++ linux-2.6.33-vs2.3.0.36.30/mm/memcontrol.c 2010-02-25 12:02:16.000000000 +0100
25177 @@ -555,6 +555,31 @@ struct mem_cgroup *mem_cgroup_from_task(
25178 struct mem_cgroup, css);
25181 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
25183 + return res_counter_read_u64(&mem->res, member);
25186 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
25188 + return res_counter_read_u64(&mem->memsw, member);
25191 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
25193 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
25196 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
25198 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
25201 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
25203 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
25206 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
25208 struct mem_cgroup *mem = NULL;
25209 diff -NurpP --minimal linux-2.6.33/mm/memory.c linux-2.6.33-vs2.3.0.36.30/mm/memory.c
25210 --- linux-2.6.33/mm/memory.c 2010-02-25 11:52:09.000000000 +0100
25211 +++ linux-2.6.33-vs2.3.0.36.30/mm/memory.c 2010-02-25 12:02:16.000000000 +0100
25213 #include <linux/kallsyms.h>
25214 #include <linux/swapops.h>
25215 #include <linux/elf.h>
25216 +// #include <linux/vs_memory.h>
25218 #include <asm/io.h>
25219 #include <asm/pgalloc.h>
25220 @@ -651,6 +652,9 @@ static int copy_pte_range(struct mm_stru
25222 swp_entry_t entry = (swp_entry_t){0};
25224 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25228 rss[1] = rss[0] = 0;
25229 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25230 @@ -2670,6 +2674,8 @@ static int do_anonymous_page(struct mm_s
25231 /* Allocate our own private page. */
25232 pte_unmap(page_table);
25234 + if (!vx_rss_avail(mm, 1))
25236 if (unlikely(anon_vma_prepare(vma)))
25238 page = alloc_zeroed_user_highpage_movable(vma, address);
25239 @@ -2961,6 +2967,7 @@ static inline int handle_pte_fault(struc
25243 + int ret = 0, type = VXPT_UNKNOWN;
25246 if (!pte_present(entry)) {
25247 @@ -2985,9 +2992,12 @@ static inline int handle_pte_fault(struc
25248 if (unlikely(!pte_same(*pte, entry)))
25250 if (flags & FAULT_FLAG_WRITE) {
25251 - if (!pte_write(entry))
25252 - return do_wp_page(mm, vma, address,
25253 + if (!pte_write(entry)) {
25254 + ret = do_wp_page(mm, vma, address,
25255 pte, pmd, ptl, entry);
25256 + type = VXPT_WRITE;
25259 entry = pte_mkdirty(entry);
25261 entry = pte_mkyoung(entry);
25262 @@ -3005,7 +3015,10 @@ static inline int handle_pte_fault(struc
25265 pte_unmap_unlock(pte, ptl);
25269 + vx_page_fault(mm, vma, type, ret);
25274 diff -NurpP --minimal linux-2.6.33/mm/mlock.c linux-2.6.33-vs2.3.0.36.30/mm/mlock.c
25275 --- linux-2.6.33/mm/mlock.c 2010-02-25 11:52:09.000000000 +0100
25276 +++ linux-2.6.33-vs2.3.0.36.30/mm/mlock.c 2010-02-25 12:02:16.000000000 +0100
25278 #include <linux/rmap.h>
25279 #include <linux/mmzone.h>
25280 #include <linux/hugetlb.h>
25281 +#include <linux/vs_memory.h>
25283 #include "internal.h"
25285 @@ -398,7 +399,7 @@ success:
25286 nr_pages = (end - start) >> PAGE_SHIFT;
25288 nr_pages = -nr_pages;
25289 - mm->locked_vm += nr_pages;
25290 + vx_vmlocked_add(mm, nr_pages);
25293 * vm_flags is protected by the mmap_sem held in write mode.
25294 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
25296 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
25298 - unsigned long locked;
25299 + unsigned long locked, grow;
25300 unsigned long lock_limit;
25301 int error = -ENOMEM;
25303 @@ -484,8 +485,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25304 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25305 start &= PAGE_MASK;
25307 - locked = len >> PAGE_SHIFT;
25308 - locked += current->mm->locked_vm;
25309 + grow = len >> PAGE_SHIFT;
25310 + if (!vx_vmlocked_avail(current->mm, grow))
25312 + locked = current->mm->locked_vm + grow;
25314 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
25315 lock_limit >>= PAGE_SHIFT;
25316 @@ -493,6 +496,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25317 /* check against resource limits */
25318 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
25319 error = do_mlock(start, len, 1);
25321 up_write(¤t->mm->mmap_sem);
25324 @@ -554,6 +558,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
25325 lock_limit >>= PAGE_SHIFT;
25328 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
25330 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
25331 capable(CAP_IPC_LOCK))
25332 ret = do_mlockall(flags);
25333 @@ -628,8 +634,10 @@ int account_locked_memory(struct mm_stru
25337 - mm->total_vm += pgsz;
25338 - mm->locked_vm += pgsz;
25339 + // mm->total_vm += pgsz;
25340 + vx_vmpages_add(mm, pgsz);
25341 + // mm->locked_vm += pgsz;
25342 + vx_vmlocked_add(mm, pgsz);
25346 @@ -643,8 +651,10 @@ void refund_locked_memory(struct mm_stru
25348 down_write(&mm->mmap_sem);
25350 - mm->total_vm -= pgsz;
25351 - mm->locked_vm -= pgsz;
25352 + // mm->total_vm -= pgsz;
25353 + vx_vmpages_sub(mm, pgsz);
25354 + // mm->locked_vm -= pgsz;
25355 + vx_vmlocked_sub(mm, pgsz);
25357 up_write(&mm->mmap_sem);
25359 diff -NurpP --minimal linux-2.6.33/mm/mmap.c linux-2.6.33-vs2.3.0.36.30/mm/mmap.c
25360 --- linux-2.6.33/mm/mmap.c 2010-02-25 11:52:09.000000000 +0100
25361 +++ linux-2.6.33-vs2.3.0.36.30/mm/mmap.c 2010-02-25 12:02:16.000000000 +0100
25362 @@ -1262,7 +1262,8 @@ munmap_back:
25364 perf_event_mmap(vma);
25366 - mm->total_vm += len >> PAGE_SHIFT;
25367 + // mm->total_vm += len >> PAGE_SHIFT;
25368 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25369 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
25370 if (vm_flags & VM_LOCKED) {
25372 @@ -1271,7 +1272,8 @@ out:
25373 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
25375 return nr_pages; /* vma gone! */
25376 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
25377 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
25378 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
25379 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
25380 make_pages_present(addr, addr + len);
25382 @@ -1626,9 +1628,9 @@ static int acct_stack_growth(struct vm_a
25385 /* Ok, everything looks good - let it rip */
25386 - mm->total_vm += grow;
25387 + vx_vmpages_add(mm, grow);
25388 if (vma->vm_flags & VM_LOCKED)
25389 - mm->locked_vm += grow;
25390 + vx_vmlocked_add(mm, grow);
25391 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
25394 @@ -1803,7 +1805,8 @@ static void remove_vma_list(struct mm_st
25396 long nrpages = vma_pages(vma);
25398 - mm->total_vm -= nrpages;
25399 + // mm->total_vm -= nrpages;
25400 + vx_vmpages_sub(mm, nrpages);
25401 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
25402 vma = remove_vma(vma);
25404 @@ -1995,7 +1998,8 @@ int do_munmap(struct mm_struct *mm, unsi
25405 struct vm_area_struct *tmp = vma;
25406 while (tmp && tmp->vm_start < end) {
25407 if (tmp->vm_flags & VM_LOCKED) {
25408 - mm->locked_vm -= vma_pages(tmp);
25409 + // mm->locked_vm -= vma_pages(tmp);
25410 + vx_vmlocked_sub(mm, vma_pages(tmp));
25411 munlock_vma_pages_all(tmp);
25413 tmp = tmp->vm_next;
25414 @@ -2078,6 +2082,8 @@ unsigned long do_brk(unsigned long addr,
25415 lock_limit >>= PAGE_SHIFT;
25416 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25418 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
25423 @@ -2104,7 +2110,8 @@ unsigned long do_brk(unsigned long addr,
25424 if (mm->map_count > sysctl_max_map_count)
25427 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
25428 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
25429 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
25432 /* Can we just expand an old private anonymous mapping? */
25433 @@ -2130,10 +2137,13 @@ unsigned long do_brk(unsigned long addr,
25434 vma->vm_page_prot = vm_get_page_prot(flags);
25435 vma_link(mm, vma, prev, rb_link, rb_parent);
25437 - mm->total_vm += len >> PAGE_SHIFT;
25438 + // mm->total_vm += len >> PAGE_SHIFT;
25439 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25441 if (flags & VM_LOCKED) {
25442 if (!mlock_vma_pages_range(vma, addr, addr + len))
25443 - mm->locked_vm += (len >> PAGE_SHIFT);
25444 + // mm->locked_vm += (len >> PAGE_SHIFT);
25445 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25449 @@ -2177,6 +2187,11 @@ void exit_mmap(struct mm_struct *mm)
25450 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
25451 tlb_finish_mmu(tlb, 0, end);
25453 + set_mm_counter(mm, file_rss, 0);
25454 + set_mm_counter(mm, anon_rss, 0);
25455 + vx_vmpages_sub(mm, mm->total_vm);
25456 + vx_vmlocked_sub(mm, mm->locked_vm);
25459 * Walk the list again, actually closing and freeing it,
25460 * with preemption enabled, without holding any MM locks.
25461 @@ -2216,7 +2231,8 @@ int insert_vm_struct(struct mm_struct *
25462 if (__vma && __vma->vm_start < vma->vm_end)
25464 if ((vma->vm_flags & VM_ACCOUNT) &&
25465 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
25466 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
25467 + !vx_vmpages_avail(mm, vma_pages(vma))))
25469 vma_link(mm, vma, prev, rb_link, rb_parent);
25471 @@ -2292,6 +2308,8 @@ int may_expand_vm(struct mm_struct *mm,
25473 if (cur + npages > lim)
25475 + if (!vx_vmpages_avail(mm, npages))
25480 @@ -2369,7 +2387,7 @@ int install_special_mapping(struct mm_st
25484 - mm->total_vm += len >> PAGE_SHIFT;
25485 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25487 perf_event_mmap(vma);
25489 diff -NurpP --minimal linux-2.6.33/mm/mremap.c linux-2.6.33-vs2.3.0.36.30/mm/mremap.c
25490 --- linux-2.6.33/mm/mremap.c 2010-02-25 11:52:09.000000000 +0100
25491 +++ linux-2.6.33-vs2.3.0.36.30/mm/mremap.c 2010-02-25 12:02:16.000000000 +0100
25493 #include <linux/security.h>
25494 #include <linux/syscalls.h>
25495 #include <linux/mmu_notifier.h>
25496 +#include <linux/vs_memory.h>
25498 #include <asm/uaccess.h>
25499 #include <asm/cacheflush.h>
25500 @@ -234,7 +235,7 @@ static unsigned long move_vma(struct vm_
25501 * If this were a serious issue, we'd add a flag to do_munmap().
25503 hiwater_vm = mm->hiwater_vm;
25504 - mm->total_vm += new_len >> PAGE_SHIFT;
25505 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
25506 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
25508 if (do_munmap(mm, old_addr, old_len) < 0) {
25509 @@ -252,7 +253,7 @@ static unsigned long move_vma(struct vm_
25512 if (vm_flags & VM_LOCKED) {
25513 - mm->locked_vm += new_len >> PAGE_SHIFT;
25514 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
25515 if (new_len > old_len)
25516 mlock_vma_pages_range(new_vma, new_addr + old_len,
25517 new_addr + new_len);
25518 @@ -463,10 +464,12 @@ unsigned long do_mremap(unsigned long ad
25519 vma_adjust(vma, vma->vm_start,
25520 addr + new_len, vma->vm_pgoff, NULL);
25522 - mm->total_vm += pages;
25523 + // mm->total_vm += pages;
25524 + vx_vmpages_add(mm, pages);
25525 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
25526 if (vma->vm_flags & VM_LOCKED) {
25527 - mm->locked_vm += pages;
25528 + // mm->locked_vm += pages;
25529 + vx_vmlocked_add(mm, pages);
25530 mlock_vma_pages_range(vma, addr + old_len,
25533 diff -NurpP --minimal linux-2.6.33/mm/nommu.c linux-2.6.33-vs2.3.0.36.30/mm/nommu.c
25534 --- linux-2.6.33/mm/nommu.c 2010-02-25 11:52:09.000000000 +0100
25535 +++ linux-2.6.33-vs2.3.0.36.30/mm/nommu.c 2010-02-25 12:02:16.000000000 +0100
25536 @@ -1349,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file
25537 /* okay... we have a mapping; now we have to register it */
25538 result = vma->vm_start;
25540 - current->mm->total_vm += len >> PAGE_SHIFT;
25541 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
25544 add_vma_to_mm(current->mm, vma);
25545 @@ -1637,7 +1637,7 @@ void exit_mmap(struct mm_struct *mm)
25549 - mm->total_vm = 0;
25550 + vx_vmpages_sub(mm, mm->total_vm);
25552 while ((vma = mm->mmap)) {
25553 mm->mmap = vma->vm_next;
25554 diff -NurpP --minimal linux-2.6.33/mm/oom_kill.c linux-2.6.33-vs2.3.0.36.30/mm/oom_kill.c
25555 --- linux-2.6.33/mm/oom_kill.c 2010-02-25 11:52:09.000000000 +0100
25556 +++ linux-2.6.33-vs2.3.0.36.30/mm/oom_kill.c 2010-02-25 12:20:14.000000000 +0100
25558 #include <linux/notifier.h>
25559 #include <linux/memcontrol.h>
25560 #include <linux/security.h>
25561 +#include <linux/reboot.h>
25562 +#include <linux/vs_memory.h>
25563 +#include <linux/vs_context.h>
25565 int sysctl_panic_on_oom;
25566 int sysctl_oom_kill_allocating_task;
25567 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
25568 points >>= -(oom_adj);
25572 + * add points for context badness and
25573 + * reduce badness for processes belonging to
25574 + * a different context
25577 + points += vx_badness(p, mm);
25579 + if ((vx_current_xid() > 1) &&
25580 + vx_current_xid() != vx_task_xid(p))
25584 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
25585 - p->pid, p->comm, points);
25586 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
25587 + task_pid_nr(p), p->xid, p->comm, points);
25591 @@ -249,6 +264,7 @@ static struct task_struct *select_bad_pr
25592 struct task_struct *p;
25593 struct task_struct *chosen = NULL;
25594 struct timespec uptime;
25595 + unsigned xid = vx_current_xid();
25598 do_posix_clock_monotonic_gettime(&uptime);
25599 @@ -261,11 +277,14 @@ static struct task_struct *select_bad_pr
25603 - /* skip the init task */
25604 - if (is_global_init(p))
25605 + /* skip the init task, global and per guest */
25606 + if (task_is_init(p))
25608 if (mem && !task_in_mem_cgroup(p, mem))
25610 + /* skip other guest and host processes if oom in guest */
25611 + if (xid && vx_task_xid(p) != xid)
25615 * This task already has access to memory reserves and is
25616 @@ -397,9 +416,9 @@ static void __oom_kill_task(struct task_
25620 - printk(KERN_ERR "Killed process %d (%s) "
25621 + printk(KERN_ERR "Killed process %s(%d:#%u) "
25622 "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
25623 - task_pid_nr(p), p->comm,
25624 + p->comm, task_pid_nr(p), p->xid,
25625 K(p->mm->total_vm),
25626 K(get_mm_counter(p->mm, anon_rss)),
25627 K(get_mm_counter(p->mm, file_rss)));
25628 @@ -452,8 +471,8 @@ static int oom_kill_process(struct task_
25632 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
25633 - message, task_pid_nr(p), p->comm, points);
25634 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
25635 + message, p->comm, task_pid_nr(p), p->xid, points);
25637 /* Try to kill a child first */
25638 list_for_each_entry(c, &p->children, sibling) {
25639 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist
25640 spin_unlock(&zone_scan_lock);
25643 +long vs_oom_action(unsigned int);
25646 * Must be called with tasklist_lock held for read.
25648 @@ -580,7 +601,11 @@ retry:
25650 read_unlock(&tasklist_lock);
25651 dump_header(NULL, gfp_mask, order, NULL);
25652 - panic("Out of memory and no killable processes...\n");
25653 + /* avoid panic for guest OOM */
25654 + if (current->xid)
25655 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
25657 + panic("Out of memory and no killable processes...\n");
25660 if (oom_kill_process(p, gfp_mask, order, points, NULL,
25661 diff -NurpP --minimal linux-2.6.33/mm/page_alloc.c linux-2.6.33-vs2.3.0.36.30/mm/page_alloc.c
25662 --- linux-2.6.33/mm/page_alloc.c 2010-02-25 11:52:09.000000000 +0100
25663 +++ linux-2.6.33-vs2.3.0.36.30/mm/page_alloc.c 2010-02-25 12:16:45.000000000 +0100
25665 #include <linux/debugobjects.h>
25666 #include <linux/kmemleak.h>
25667 #include <linux/memory.h>
25668 +#include <linux/vs_base.h>
25669 +#include <linux/vs_limit.h>
25670 #include <trace/events/kmem.h>
25672 #include <asm/tlbflush.h>
25673 @@ -2138,6 +2140,9 @@ void si_meminfo(struct sysinfo *val)
25674 val->totalhigh = totalhigh_pages;
25675 val->freehigh = nr_free_highpages();
25676 val->mem_unit = PAGE_SIZE;
25678 + if (vx_flags(VXF_VIRT_MEM, 0))
25679 + vx_vsi_meminfo(val);
25682 EXPORT_SYMBOL(si_meminfo);
25683 @@ -2158,6 +2163,9 @@ void si_meminfo_node(struct sysinfo *val
25686 val->mem_unit = PAGE_SIZE;
25688 + if (vx_flags(VXF_VIRT_MEM, 0))
25689 + vx_vsi_meminfo(val);
25693 diff -NurpP --minimal linux-2.6.33/mm/rmap.c linux-2.6.33-vs2.3.0.36.30/mm/rmap.c
25694 --- linux-2.6.33/mm/rmap.c 2010-02-25 11:52:09.000000000 +0100
25695 +++ linux-2.6.33-vs2.3.0.36.30/mm/rmap.c 2010-02-25 12:02:16.000000000 +0100
25697 #include <linux/memcontrol.h>
25698 #include <linux/mmu_notifier.h>
25699 #include <linux/migrate.h>
25700 +#include <linux/vs_memory.h>
25702 #include <asm/tlbflush.h>
25704 diff -NurpP --minimal linux-2.6.33/mm/shmem.c linux-2.6.33-vs2.3.0.36.30/mm/shmem.c
25705 --- linux-2.6.33/mm/shmem.c 2010-02-25 11:52:09.000000000 +0100
25706 +++ linux-2.6.33-vs2.3.0.36.30/mm/shmem.c 2010-02-25 12:02:16.000000000 +0100
25707 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
25709 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
25711 - buf->f_type = TMPFS_MAGIC;
25712 + buf->f_type = TMPFS_SUPER_MAGIC;
25713 buf->f_bsize = PAGE_CACHE_SIZE;
25714 buf->f_namelen = NAME_MAX;
25715 spin_lock(&sbinfo->stat_lock);
25716 @@ -2358,7 +2358,7 @@ int shmem_fill_super(struct super_block
25717 sb->s_maxbytes = SHMEM_MAX_BYTES;
25718 sb->s_blocksize = PAGE_CACHE_SIZE;
25719 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
25720 - sb->s_magic = TMPFS_MAGIC;
25721 + sb->s_magic = TMPFS_SUPER_MAGIC;
25722 sb->s_op = &shmem_ops;
25723 sb->s_time_gran = 1;
25724 #ifdef CONFIG_TMPFS_POSIX_ACL
25725 diff -NurpP --minimal linux-2.6.33/mm/slab.c linux-2.6.33-vs2.3.0.36.30/mm/slab.c
25726 --- linux-2.6.33/mm/slab.c 2010-02-25 11:52:09.000000000 +0100
25727 +++ linux-2.6.33-vs2.3.0.36.30/mm/slab.c 2010-02-25 12:02:16.000000000 +0100
25728 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
25729 #define STATS_INC_FREEMISS(x) do { } while (0)
25732 +#include "slab_vs.h"
25737 @@ -3275,6 +3277,7 @@ retry:
25739 obj = slab_get_obj(cachep, slabp, nodeid);
25740 check_slabp(cachep, slabp);
25741 + vx_slab_alloc(cachep, flags);
25742 l3->free_objects--;
25743 /* move slabp to correct slabp list: */
25744 list_del(&slabp->list);
25745 @@ -3351,6 +3354,7 @@ __cache_alloc_node(struct kmem_cache *ca
25746 /* ___cache_alloc_node can fall back to other nodes */
25747 ptr = ____cache_alloc_node(cachep, flags, nodeid);
25749 + vx_slab_alloc(cachep, flags);
25750 local_irq_restore(save_flags);
25751 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
25752 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
25753 @@ -3537,6 +3541,7 @@ static inline void __cache_free(struct k
25755 kmemleak_free_recursive(objp, cachep->flags);
25756 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
25757 + vx_slab_free(cachep);
25759 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
25761 diff -NurpP --minimal linux-2.6.33/mm/slab_vs.h linux-2.6.33-vs2.3.0.36.30/mm/slab_vs.h
25762 --- linux-2.6.33/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
25763 +++ linux-2.6.33-vs2.3.0.36.30/mm/slab_vs.h 2010-02-25 12:02:16.000000000 +0100
25766 +#include <linux/vserver/context.h>
25768 +#include <linux/vs_context.h>
25771 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
25773 + int what = gfp_zone(cachep->gfpflags);
25774 + struct vx_info *vxi = current_vx_info();
25779 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
25783 +void vx_slab_free(struct kmem_cache *cachep)
25785 + int what = gfp_zone(cachep->gfpflags);
25786 + struct vx_info *vxi = current_vx_info();
25791 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
25794 diff -NurpP --minimal linux-2.6.33/mm/swapfile.c linux-2.6.33-vs2.3.0.36.30/mm/swapfile.c
25795 --- linux-2.6.33/mm/swapfile.c 2010-02-25 11:52:09.000000000 +0100
25796 +++ linux-2.6.33-vs2.3.0.36.30/mm/swapfile.c 2010-02-25 12:02:16.000000000 +0100
25798 #include <asm/tlbflush.h>
25799 #include <linux/swapops.h>
25800 #include <linux/page_cgroup.h>
25801 +#include <linux/vs_base.h>
25802 +#include <linux/vs_memory.h>
25804 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
25806 @@ -1693,6 +1695,16 @@ static int swap_show(struct seq_file *sw
25808 if (si == SEQ_START_TOKEN) {
25809 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
25810 + if (vx_flags(VXF_VIRT_MEM, 0)) {
25811 + struct sysinfo si;
25813 + vx_vsi_swapinfo(&si);
25814 + if (si.totalswap < (1 << 10))
25816 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
25817 + "hdv0", "partition", si.totalswap >> 10,
25818 + (si.totalswap - si.freeswap) >> 10, -1);
25823 @@ -2071,6 +2083,8 @@ void si_swapinfo(struct sysinfo *val)
25824 val->freeswap = nr_swap_pages + nr_to_be_unused;
25825 val->totalswap = total_swap_pages + nr_to_be_unused;
25826 spin_unlock(&swap_lock);
25827 + if (vx_flags(VXF_VIRT_MEM, 0))
25828 + vx_vsi_swapinfo(val);
25832 diff -NurpP --minimal linux-2.6.33/net/core/dev.c linux-2.6.33-vs2.3.0.36.30/net/core/dev.c
25833 --- linux-2.6.33/net/core/dev.c 2010-02-25 11:52:10.000000000 +0100
25834 +++ linux-2.6.33-vs2.3.0.36.30/net/core/dev.c 2010-02-25 14:02:39.000000000 +0100
25835 @@ -128,6 +128,7 @@
25836 #include <linux/in.h>
25837 #include <linux/jhash.h>
25838 #include <linux/random.h>
25839 +#include <linux/vs_inet.h>
25840 #include <trace/events/napi.h>
25842 #include "net-sysfs.h"
25843 @@ -593,7 +594,8 @@ struct net_device *__dev_get_by_name(str
25844 struct hlist_head *head = dev_name_hash(net, name);
25846 hlist_for_each_entry(dev, p, head, name_hlist)
25847 - if (!strncmp(dev->name, name, IFNAMSIZ))
25848 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
25849 + nx_dev_visible(current_nx_info(), dev))
25853 @@ -619,7 +621,8 @@ struct net_device *dev_get_by_name_rcu(s
25854 struct hlist_head *head = dev_name_hash(net, name);
25856 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
25857 - if (!strncmp(dev->name, name, IFNAMSIZ))
25858 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
25859 + nx_dev_visible(current_nx_info(), dev))
25863 @@ -670,7 +673,8 @@ struct net_device *__dev_get_by_index(st
25864 struct hlist_head *head = dev_index_hash(net, ifindex);
25866 hlist_for_each_entry(dev, p, head, index_hlist)
25867 - if (dev->ifindex == ifindex)
25868 + if ((dev->ifindex == ifindex) &&
25869 + nx_dev_visible(current_nx_info(), dev))
25873 @@ -695,7 +699,8 @@ struct net_device *dev_get_by_index_rcu(
25874 struct hlist_head *head = dev_index_hash(net, ifindex);
25876 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
25877 - if (dev->ifindex == ifindex)
25878 + if ((dev->ifindex == ifindex) &&
25879 + nx_dev_visible(current_nx_info(), dev))
25883 @@ -748,10 +753,12 @@ struct net_device *dev_getbyhwaddr(struc
25887 - for_each_netdev(net, dev)
25888 + for_each_netdev(net, dev) {
25889 if (dev->type == type &&
25890 - !memcmp(dev->dev_addr, ha, dev->addr_len))
25891 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
25892 + nx_dev_visible(current_nx_info(), dev))
25898 @@ -762,9 +769,11 @@ struct net_device *__dev_getfirstbyhwtyp
25899 struct net_device *dev;
25902 - for_each_netdev(net, dev)
25903 - if (dev->type == type)
25904 + for_each_netdev(net, dev) {
25905 + if ((dev->type == type) &&
25906 + nx_dev_visible(current_nx_info(), dev))
25912 @@ -883,6 +892,8 @@ static int __dev_alloc_name(struct net *
25914 if (i < 0 || i >= max_netdevices)
25916 + if (!nx_dev_visible(current_nx_info(), d))
25919 /* avoid cases where sscanf is not exact inverse of printf */
25920 snprintf(buf, IFNAMSIZ, name, i);
25921 @@ -3115,6 +3126,8 @@ static int dev_ifconf(struct net *net, c
25924 for_each_netdev(net, dev) {
25925 + if (!nx_dev_visible(current_nx_info(), dev))
25927 for (i = 0; i < NPROTO; i++) {
25928 if (gifconf_list[i]) {
25930 @@ -3185,6 +3198,9 @@ static void dev_seq_printf_stats(struct
25932 const struct net_device_stats *stats = dev_get_stats(dev);
25934 + if (!nx_dev_visible(current_nx_info(), dev))
25937 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
25938 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
25939 dev->name, stats->rx_bytes, stats->rx_packets,
25940 @@ -5528,7 +5544,6 @@ int dev_change_net_namespace(struct net_
25941 if (dev->dev.parent)
25945 /* Ensure the device has been registrered */
25947 if (dev->reg_state != NETREG_REGISTERED)
25948 diff -NurpP --minimal linux-2.6.33/net/core/rtnetlink.c linux-2.6.33-vs2.3.0.36.30/net/core/rtnetlink.c
25949 --- linux-2.6.33/net/core/rtnetlink.c 2010-02-25 11:52:10.000000000 +0100
25950 +++ linux-2.6.33-vs2.3.0.36.30/net/core/rtnetlink.c 2010-02-25 13:59:02.000000000 +0100
25951 @@ -695,6 +695,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
25952 hlist_for_each_entry(dev, node, head, index_hlist) {
25955 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
25957 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
25958 NETLINK_CB(cb->skb).pid,
25959 cb->nlh->nlmsg_seq, 0,
25960 @@ -1252,6 +1254,9 @@ void rtmsg_ifinfo(int type, struct net_d
25961 struct sk_buff *skb;
25962 int err = -ENOBUFS;
25964 + if (!nx_dev_visible(current_nx_info(), dev))
25967 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
25970 diff -NurpP --minimal linux-2.6.33/net/core/sock.c linux-2.6.33-vs2.3.0.36.30/net/core/sock.c
25971 --- linux-2.6.33/net/core/sock.c 2010-02-25 11:52:10.000000000 +0100
25972 +++ linux-2.6.33-vs2.3.0.36.30/net/core/sock.c 2010-02-25 12:02:16.000000000 +0100
25973 @@ -125,6 +125,10 @@
25974 #include <linux/ipsec.h>
25976 #include <linux/filter.h>
25977 +#include <linux/vs_socket.h>
25978 +#include <linux/vs_limit.h>
25979 +#include <linux/vs_context.h>
25980 +#include <linux/vs_network.h>
25983 #include <net/tcp.h>
25984 @@ -1008,6 +1012,8 @@ static struct sock *sk_prot_alloc(struct
25986 sk_tx_queue_clear(sk);
25988 + sock_vx_init(sk);
25989 + sock_nx_init(sk);
25993 @@ -1087,6 +1093,11 @@ static void __sk_free(struct sock *sk)
25994 __func__, atomic_read(&sk->sk_omem_alloc));
25996 put_net(sock_net(sk));
25998 + clr_vx_info(&sk->sk_vx_info);
26000 + clr_nx_info(&sk->sk_nx_info);
26002 sk_prot_free(sk->sk_prot_creator, sk);
26005 @@ -1134,6 +1145,8 @@ struct sock *sk_clone(const struct sock
26008 get_net(sock_net(newsk));
26009 + sock_vx_init(newsk);
26010 + sock_nx_init(newsk);
26011 sk_node_init(&newsk->sk_node);
26012 sock_lock_init(newsk);
26013 bh_lock_sock(newsk);
26014 @@ -1188,6 +1201,12 @@ struct sock *sk_clone(const struct sock
26016 atomic_set(&newsk->sk_refcnt, 2);
26018 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26019 + newsk->sk_xid = sk->sk_xid;
26020 + vx_sock_inc(newsk);
26021 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26022 + newsk->sk_nid = sk->sk_nid;
26025 * Increment the counter in the same struct proto as the master
26026 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26027 @@ -1910,6 +1929,12 @@ void sock_init_data(struct socket *sock,
26029 sk->sk_stamp = ktime_set(-1L, 0);
26031 + set_vx_info(&sk->sk_vx_info, current_vx_info());
26032 + sk->sk_xid = vx_current_xid();
26034 + set_nx_info(&sk->sk_nx_info, current_nx_info());
26035 + sk->sk_nid = nx_current_nid();
26038 * Before updating sk_refcnt, we must commit prior changes to memory
26039 * (Documentation/RCU/rculist_nulls.txt for details)
26040 diff -NurpP --minimal linux-2.6.33/net/ipv4/af_inet.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/af_inet.c
26041 --- linux-2.6.33/net/ipv4/af_inet.c 2010-02-25 11:52:10.000000000 +0100
26042 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/af_inet.c 2010-02-25 15:53:12.000000000 +0100
26043 @@ -115,6 +115,7 @@
26044 #ifdef CONFIG_IP_MROUTE
26045 #include <linux/mroute.h>
26047 +#include <linux/vs_limit.h>
26050 /* The inetsw table contains everything that inet_create needs to
26051 @@ -326,9 +327,13 @@ lookup_protocol:
26055 + if ((protocol == IPPROTO_ICMP) &&
26056 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26059 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26060 goto out_rcu_unlock;
26063 err = -EAFNOSUPPORT;
26064 if (!inet_netns_ok(net, protocol))
26065 goto out_rcu_unlock;
26066 @@ -448,6 +453,7 @@ int inet_bind(struct socket *sock, struc
26067 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26068 struct sock *sk = sock->sk;
26069 struct inet_sock *inet = inet_sk(sk);
26070 + struct nx_v4_sock_addr nsa;
26071 unsigned short snum;
26074 @@ -461,7 +467,11 @@ int inet_bind(struct socket *sock, struc
26075 if (addr_len < sizeof(struct sockaddr_in))
26078 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26079 + err = v4_map_sock_addr(inet, addr, &nsa);
26083 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26085 /* Not specified by any standard per-se, however it breaks too
26086 * many applications when removed. It is unfortunate since
26087 @@ -473,7 +483,7 @@ int inet_bind(struct socket *sock, struc
26088 err = -EADDRNOTAVAIL;
26089 if (!sysctl_ip_nonlocal_bind &&
26090 !(inet->freebind || inet->transparent) &&
26091 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26092 + nsa.saddr != htonl(INADDR_ANY) &&
26093 chk_addr_ret != RTN_LOCAL &&
26094 chk_addr_ret != RTN_MULTICAST &&
26095 chk_addr_ret != RTN_BROADCAST)
26096 @@ -498,7 +508,7 @@ int inet_bind(struct socket *sock, struc
26097 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26098 goto out_release_sock;
26100 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26101 + v4_set_sock_addr(inet, &nsa);
26102 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26103 inet->inet_saddr = 0; /* Use device */
26105 @@ -695,11 +705,13 @@ int inet_getname(struct socket *sock, st
26108 sin->sin_port = inet->inet_dport;
26109 - sin->sin_addr.s_addr = inet->inet_daddr;
26110 + sin->sin_addr.s_addr =
26111 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26113 __be32 addr = inet->inet_rcv_saddr;
26115 addr = inet->inet_saddr;
26116 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26117 sin->sin_port = inet->inet_sport;
26118 sin->sin_addr.s_addr = addr;
26120 diff -NurpP --minimal linux-2.6.33/net/ipv4/devinet.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/devinet.c
26121 --- linux-2.6.33/net/ipv4/devinet.c 2010-02-25 11:52:10.000000000 +0100
26122 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/devinet.c 2010-02-25 14:19:58.000000000 +0100
26123 @@ -416,6 +416,7 @@ struct in_device *inetdev_by_index(struc
26125 EXPORT_SYMBOL(inetdev_by_index);
26128 /* Called only from RTNL semaphored context. No locks. */
26130 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26131 @@ -658,6 +659,8 @@ int devinet_ioctl(struct net *net, unsig
26133 in_dev = __in_dev_get_rtnl(dev);
26135 + struct nx_info *nxi = current_nx_info();
26137 if (tryaddrmatch) {
26138 /* Matthias Andree */
26139 /* compare label and address (4.4BSD style) */
26140 @@ -666,6 +669,8 @@ int devinet_ioctl(struct net *net, unsig
26141 This is checked above. */
26142 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26143 ifap = &ifa->ifa_next) {
26144 + if (!nx_v4_ifa_visible(nxi, ifa))
26146 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26147 sin_orig.sin_addr.s_addr ==
26148 ifa->ifa_address) {
26149 @@ -678,9 +683,12 @@ int devinet_ioctl(struct net *net, unsig
26150 comparing just the label */
26152 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26153 - ifap = &ifa->ifa_next)
26154 + ifap = &ifa->ifa_next) {
26155 + if (!nx_v4_ifa_visible(nxi, ifa))
26157 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26163 @@ -832,6 +840,8 @@ static int inet_gifconf(struct net_devic
26166 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
26167 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
26170 done += sizeof(ifr);
26172 @@ -1180,6 +1190,7 @@ static int inet_dump_ifaddr(struct sk_bu
26173 struct net_device *dev;
26174 struct in_device *in_dev;
26175 struct in_ifaddr *ifa;
26176 + struct sock *sk = skb->sk;
26177 struct hlist_head *head;
26178 struct hlist_node *node;
26180 @@ -1202,6 +1213,8 @@ static int inet_dump_ifaddr(struct sk_bu
26182 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26183 ifa = ifa->ifa_next, ip_idx++) {
26184 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26186 if (ip_idx < s_ip_idx)
26188 if (inet_fill_ifaddr(skb, ifa,
26189 diff -NurpP --minimal linux-2.6.33/net/ipv4/fib_hash.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/fib_hash.c
26190 --- linux-2.6.33/net/ipv4/fib_hash.c 2010-02-25 11:52:10.000000000 +0100
26191 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/fib_hash.c 2010-02-25 12:02:16.000000000 +0100
26192 @@ -1016,7 +1016,7 @@ static int fib_seq_show(struct seq_file
26193 prefix = f->fn_key;
26194 mask = FZ_MASK(iter->zone);
26195 flags = fib_flag_trans(fa->fa_type, mask, fi);
26197 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
26199 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
26200 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26201 diff -NurpP --minimal linux-2.6.33/net/ipv4/inet_connection_sock.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/inet_connection_sock.c
26202 --- linux-2.6.33/net/ipv4/inet_connection_sock.c 2010-02-25 11:52:10.000000000 +0100
26203 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/inet_connection_sock.c 2010-02-25 12:02:16.000000000 +0100
26204 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
26206 EXPORT_SYMBOL(inet_get_local_port_range);
26208 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26210 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
26211 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26213 + if (inet_v6_ipv6only(sk2))
26216 + if (sk1_rcv_saddr &&
26218 + sk1_rcv_saddr == sk2_rcv_saddr)
26221 + if (sk1_rcv_saddr &&
26222 + !sk2_rcv_saddr &&
26223 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26226 + if (sk2_rcv_saddr &&
26227 + !sk1_rcv_saddr &&
26228 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26231 + if (!sk1_rcv_saddr &&
26232 + !sk2_rcv_saddr &&
26233 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26239 int inet_csk_bind_conflict(const struct sock *sk,
26240 const struct inet_bind_bucket *tb)
26242 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26244 struct hlist_node *node;
26245 int reuse = sk->sk_reuse;
26246 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
26247 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26248 if (!reuse || !sk2->sk_reuse ||
26249 sk2->sk_state == TCP_LISTEN) {
26250 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26251 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26252 - sk2_rcv_saddr == sk_rcv_saddr)
26253 + if (ipv4_rcv_saddr_equal(sk, sk2))
26257 diff -NurpP --minimal linux-2.6.33/net/ipv4/inet_diag.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/inet_diag.c
26258 --- linux-2.6.33/net/ipv4/inet_diag.c 2010-02-25 11:52:10.000000000 +0100
26259 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/inet_diag.c 2010-02-25 14:16:01.000000000 +0100
26261 #include <linux/stddef.h>
26263 #include <linux/inet_diag.h>
26264 +#include <linux/vs_network.h>
26265 +#include <linux/vs_inet.h>
26267 static const struct inet_diag_handler **inet_diag_table;
26269 @@ -118,8 +120,10 @@ static int inet_csk_diag_fill(struct soc
26271 r->id.idiag_sport = inet->inet_sport;
26272 r->id.idiag_dport = inet->inet_dport;
26273 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
26274 - r->id.idiag_dst[0] = inet->inet_daddr;
26275 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
26276 + inet->inet_rcv_saddr);
26277 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
26278 + inet->inet_daddr);
26280 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26281 if (r->idiag_family == AF_INET6) {
26282 @@ -204,8 +208,8 @@ static int inet_twsk_diag_fill(struct in
26283 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26284 r->id.idiag_sport = tw->tw_sport;
26285 r->id.idiag_dport = tw->tw_dport;
26286 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26287 - r->id.idiag_dst[0] = tw->tw_daddr;
26288 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26289 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26290 r->idiag_state = tw->tw_substate;
26291 r->idiag_timer = 3;
26292 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26293 @@ -262,6 +266,7 @@ static int inet_diag_get_exact(struct sk
26296 if (req->idiag_family == AF_INET) {
26297 + /* TODO: lback */
26298 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26299 req->id.idiag_dport, req->id.idiag_src[0],
26300 req->id.idiag_sport, req->id.idiag_if);
26301 @@ -504,6 +509,7 @@ static int inet_csk_diag_dump(struct soc
26305 + /* TODO: lback */
26306 entry.saddr = &inet->inet_rcv_saddr;
26307 entry.daddr = &inet->inet_daddr;
26309 @@ -540,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
26313 + /* TODO: lback */
26314 entry.saddr = &tw->tw_rcv_saddr;
26315 entry.daddr = &tw->tw_daddr;
26317 @@ -586,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
26319 r->id.idiag_sport = inet->inet_sport;
26320 r->id.idiag_dport = ireq->rmt_port;
26321 - r->id.idiag_src[0] = ireq->loc_addr;
26322 - r->id.idiag_dst[0] = ireq->rmt_addr;
26323 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26324 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26325 r->idiag_expires = jiffies_to_msecs(tmo);
26326 r->idiag_rqueue = 0;
26327 r->idiag_wqueue = 0;
26328 @@ -657,6 +664,7 @@ static int inet_diag_dump_reqs(struct sk
26332 + /* TODO: lback */
26334 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26335 (entry.family == AF_INET6) ?
26336 @@ -727,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
26337 sk_nulls_for_each(sk, node, &ilb->head) {
26338 struct inet_sock *inet = inet_sk(sk);
26340 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26345 @@ -793,6 +803,8 @@ skip_listen_ht:
26346 sk_nulls_for_each(sk, node, &head->chain) {
26347 struct inet_sock *inet = inet_sk(sk);
26349 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26353 if (!(r->idiag_states & (1 << sk->sk_state)))
26354 @@ -817,6 +829,8 @@ next_normal:
26355 inet_twsk_for_each(tw, node,
26358 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26362 if (r->id.idiag_sport != tw->tw_sport &&
26363 diff -NurpP --minimal linux-2.6.33/net/ipv4/inet_hashtables.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/inet_hashtables.c
26364 --- linux-2.6.33/net/ipv4/inet_hashtables.c 2010-02-25 11:52:10.000000000 +0100
26365 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/inet_hashtables.c 2010-02-25 12:02:16.000000000 +0100
26368 #include <net/inet_connection_sock.h>
26369 #include <net/inet_hashtables.h>
26370 +#include <net/route.h>
26371 #include <net/ip.h>
26374 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
26375 if (rcv_saddr != daddr)
26379 + /* block non nx_info ips */
26380 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26381 + daddr, NXA_MASK_BIND))
26384 if (sk->sk_bound_dev_if) {
26385 if (sk->sk_bound_dev_if != dif)
26386 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
26387 * wildcarded during the search since they can never be otherwise.
26391 struct sock *__inet_lookup_listener(struct net *net,
26392 struct inet_hashinfo *hashinfo,
26393 const __be32 daddr, const unsigned short hnum,
26394 @@ -174,6 +179,7 @@ begin:
26400 * if the nulls value we got at the end of this lookup is
26401 * not the expected one, we must restart lookup.
26402 diff -NurpP --minimal linux-2.6.33/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/netfilter/nf_nat_helper.c
26403 --- linux-2.6.33/net/ipv4/netfilter/nf_nat_helper.c 2010-02-25 11:52:10.000000000 +0100
26404 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/netfilter/nf_nat_helper.c 2010-02-25 12:02:16.000000000 +0100
26406 #include <net/route.h>
26408 #include <linux/netfilter_ipv4.h>
26409 +#include <net/route.h>
26410 #include <net/netfilter/nf_conntrack.h>
26411 #include <net/netfilter/nf_conntrack_helper.h>
26412 #include <net/netfilter/nf_conntrack_ecache.h>
26413 diff -NurpP --minimal linux-2.6.33/net/ipv4/netfilter.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/netfilter.c
26414 --- linux-2.6.33/net/ipv4/netfilter.c 2010-02-25 11:52:10.000000000 +0100
26415 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/netfilter.c 2010-02-25 12:02:16.000000000 +0100
26417 #include <linux/netfilter_ipv4.h>
26418 #include <linux/ip.h>
26419 #include <linux/skbuff.h>
26420 -#include <net/route.h>
26421 +// #include <net/route.h>
26422 #include <net/xfrm.h>
26423 #include <net/ip.h>
26424 #include <net/netfilter/nf_queue.h>
26425 diff -NurpP --minimal linux-2.6.33/net/ipv4/raw.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/raw.c
26426 --- linux-2.6.33/net/ipv4/raw.c 2010-02-25 11:52:10.000000000 +0100
26427 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/raw.c 2010-02-25 14:07:52.000000000 +0100
26428 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
26430 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
26431 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
26432 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
26433 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
26434 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26435 goto found; /* gotcha */
26437 @@ -382,6 +382,12 @@ static int raw_send_hdrinc(struct sock *
26438 icmp_out_count(net, ((struct icmphdr *)
26439 skb_transport_header(skb))->type);
26442 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
26443 + sk->sk_nx_info &&
26444 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
26447 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
26450 @@ -562,6 +568,13 @@ static int raw_sendmsg(struct kiocb *ioc
26453 security_sk_classify_flow(sk, &fl);
26454 + if (sk->sk_nx_info) {
26455 + err = ip_v4_find_src(sock_net(sk),
26456 + sk->sk_nx_info, &rt, &fl);
26461 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
26464 @@ -634,17 +647,19 @@ static int raw_bind(struct sock *sk, str
26466 struct inet_sock *inet = inet_sk(sk);
26467 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
26468 + struct nx_v4_sock_addr nsa = { 0 };
26472 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
26474 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26475 + v4_map_sock_addr(inet, addr, &nsa);
26476 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26477 ret = -EADDRNOTAVAIL;
26478 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
26479 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
26480 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
26482 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26483 + v4_set_sock_addr(inet, &nsa);
26484 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26485 inet->inet_saddr = 0; /* Use device */
26487 @@ -696,7 +711,8 @@ static int raw_recvmsg(struct kiocb *ioc
26488 /* Copy the address. */
26490 sin->sin_family = AF_INET;
26491 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26492 + sin->sin_addr.s_addr =
26493 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
26495 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
26497 @@ -874,7 +890,8 @@ static struct sock *raw_get_first(struct
26498 struct hlist_node *node;
26500 sk_for_each(sk, node, &state->h->ht[state->bucket])
26501 - if (sock_net(sk) == seq_file_net(seq))
26502 + if ((sock_net(sk) == seq_file_net(seq)) &&
26503 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26507 @@ -890,7 +907,8 @@ static struct sock *raw_get_next(struct
26511 - } while (sk && sock_net(sk) != seq_file_net(seq));
26512 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
26513 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26515 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
26516 sk = sk_head(&state->h->ht[state->bucket]);
26517 @@ -949,7 +967,10 @@ static void raw_sock_seq_show(struct seq
26519 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
26520 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
26521 - i, src, srcp, dest, destp, sp->sk_state,
26523 + nx_map_sock_lback(current_nx_info(), src), srcp,
26524 + nx_map_sock_lback(current_nx_info(), dest), destp,
26526 sk_wmem_alloc_get(sp),
26527 sk_rmem_alloc_get(sp),
26528 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26529 diff -NurpP --minimal linux-2.6.33/net/ipv4/tcp.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/tcp.c
26530 --- linux-2.6.33/net/ipv4/tcp.c 2010-02-25 11:52:10.000000000 +0100
26531 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/tcp.c 2010-02-25 14:03:32.000000000 +0100
26532 @@ -265,6 +265,7 @@
26533 #include <linux/err.h>
26534 #include <linux/crypto.h>
26535 #include <linux/time.h>
26536 +#include <linux/in.h>
26538 #include <net/icmp.h>
26539 #include <net/tcp.h>
26540 diff -NurpP --minimal linux-2.6.33/net/ipv4/tcp_ipv4.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/tcp_ipv4.c
26541 --- linux-2.6.33/net/ipv4/tcp_ipv4.c 2010-02-25 11:52:10.000000000 +0100
26542 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/tcp_ipv4.c 2010-02-25 14:08:55.000000000 +0100
26543 @@ -1988,6 +1988,12 @@ static void *listening_get_next(struct s
26544 req = req->dl_next;
26547 + vxdprintk(VXD_CBIT(net, 6),
26548 + "sk,req: %p [#%d] (from %d)", req->sk,
26549 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26551 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26553 if (req->rsk_ops->family == st->family) {
26556 @@ -2012,6 +2018,10 @@ get_req:
26559 sk_nulls_for_each_from(sk, node) {
26560 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26561 + sk, sk->sk_nid, nx_current_nid());
26562 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26564 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
26567 @@ -2075,6 +2085,11 @@ static void *established_get_first(struc
26569 spin_lock_bh(lock);
26570 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26571 + vxdprintk(VXD_CBIT(net, 6),
26572 + "sk,egf: %p [#%d] (from %d)",
26573 + sk, sk->sk_nid, nx_current_nid());
26574 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26576 if (sk->sk_family != st->family ||
26577 !net_eq(sock_net(sk), net)) {
26579 @@ -2085,6 +2100,11 @@ static void *established_get_first(struc
26580 st->state = TCP_SEQ_STATE_TIME_WAIT;
26581 inet_twsk_for_each(tw, node,
26582 &tcp_hashinfo.ehash[st->bucket].twchain) {
26583 + vxdprintk(VXD_CBIT(net, 6),
26584 + "tw: %p [#%d] (from %d)",
26585 + tw, tw->tw_nid, nx_current_nid());
26586 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26588 if (tw->tw_family != st->family ||
26589 !net_eq(twsk_net(tw), net)) {
26591 @@ -2113,7 +2133,9 @@ static void *established_get_next(struct
26595 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
26596 + while (tw && (tw->tw_family != st->family ||
26597 + !net_eq(twsk_net(tw), net) ||
26598 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26602 @@ -2136,6 +2158,11 @@ get_tw:
26603 sk = sk_nulls_next(sk);
26605 sk_nulls_for_each_from(sk, node) {
26606 + vxdprintk(VXD_CBIT(net, 6),
26607 + "sk,egn: %p [#%d] (from %d)",
26608 + sk, sk->sk_nid, nx_current_nid());
26609 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26611 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
26614 @@ -2287,9 +2314,9 @@ static void get_openreq4(struct sock *sk
26615 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26616 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
26619 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
26620 ntohs(inet_sk(sk)->inet_sport),
26622 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
26623 ntohs(ireq->rmt_port),
26625 0, 0, /* could print option size, but that is af dependent. */
26626 @@ -2341,7 +2368,10 @@ static void get_tcp4_sock(struct sock *s
26628 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
26629 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
26630 - i, src, srcp, dest, destp, sk->sk_state,
26632 + nx_map_sock_lback(current_nx_info(), src), srcp,
26633 + nx_map_sock_lback(current_nx_info(), dest), destp,
26635 tp->write_seq - tp->snd_una,
26638 @@ -2376,7 +2406,10 @@ static void get_timewait4_sock(struct in
26640 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26641 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
26642 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
26644 + nx_map_sock_lback(current_nx_info(), src), srcp,
26645 + nx_map_sock_lback(current_nx_info(), dest), destp,
26646 + tw->tw_substate, 0, 0,
26647 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
26648 atomic_read(&tw->tw_refcnt), tw, len);
26650 diff -NurpP --minimal linux-2.6.33/net/ipv4/tcp_minisocks.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/tcp_minisocks.c
26651 --- linux-2.6.33/net/ipv4/tcp_minisocks.c 2010-02-25 11:52:10.000000000 +0100
26652 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/tcp_minisocks.c 2010-02-25 14:03:06.000000000 +0100
26654 #include <linux/module.h>
26655 #include <linux/sysctl.h>
26656 #include <linux/workqueue.h>
26657 +#include <linux/vs_limit.h>
26658 +#include <linux/vs_socket.h>
26659 +#include <linux/vs_context.h>
26660 #include <net/tcp.h>
26661 #include <net/inet_common.h>
26662 #include <net/xfrm.h>
26663 @@ -289,6 +292,11 @@ void tcp_time_wait(struct sock *sk, int
26664 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26665 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26667 + tw->tw_xid = sk->sk_xid;
26668 + tw->tw_vx_info = NULL;
26669 + tw->tw_nid = sk->sk_nid;
26670 + tw->tw_nx_info = NULL;
26672 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26673 if (tw->tw_family == PF_INET6) {
26674 struct ipv6_pinfo *np = inet6_sk(sk);
26675 diff -NurpP --minimal linux-2.6.33/net/ipv4/udp.c linux-2.6.33-vs2.3.0.36.30/net/ipv4/udp.c
26676 --- linux-2.6.33/net/ipv4/udp.c 2010-02-25 11:52:10.000000000 +0100
26677 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv4/udp.c 2010-02-25 14:18:12.000000000 +0100
26678 @@ -294,14 +294,7 @@ fail:
26680 EXPORT_SYMBOL(udp_lib_get_port);
26682 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26684 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
26686 - return (!ipv6_only_sock(sk2) &&
26687 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
26688 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
26690 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
26692 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
26694 @@ -336,6 +329,11 @@ static inline int compute_score(struct s
26695 if (inet->inet_rcv_saddr != daddr)
26699 + /* block non nx_info ips */
26700 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26701 + daddr, NXA_MASK_BIND))
26704 if (inet->inet_daddr) {
26705 if (inet->inet_daddr != saddr)
26706 @@ -439,6 +437,7 @@ exact_match:
26711 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
26712 * harder than this. -DaveM
26714 @@ -484,6 +483,11 @@ begin:
26715 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
26716 score = compute_score(sk, net, saddr, hnum, sport,
26717 daddr, dport, dif);
26718 + /* FIXME: disabled?
26719 + if (score == 9) {
26723 if (score > badness) {
26726 @@ -497,6 +501,7 @@ begin:
26727 if (get_nulls_value(node) != slot)
26732 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
26734 @@ -506,6 +511,7 @@ begin:
26742 @@ -548,8 +554,7 @@ static inline struct sock *udp_v4_mcast_
26743 udp_sk(s)->udp_port_hash != hnum ||
26744 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
26745 (inet->inet_dport != rmt_port && inet->inet_dport) ||
26746 - (inet->inet_rcv_saddr &&
26747 - inet->inet_rcv_saddr != loc_addr) ||
26748 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
26749 ipv6_only_sock(s) ||
26750 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
26752 @@ -898,8 +903,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
26753 { .sport = inet->inet_sport,
26754 .dport = dport } } };
26755 struct net *net = sock_net(sk);
26756 + struct nx_info *nxi = sk->sk_nx_info;
26758 security_sk_classify_flow(sk, &fl);
26759 + err = ip_v4_find_src(net, nxi, &rt, &fl);
26763 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
26765 if (err == -ENETUNREACH)
26766 @@ -1180,7 +1190,8 @@ try_again:
26768 sin->sin_family = AF_INET;
26769 sin->sin_port = udp_hdr(skb)->source;
26770 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26771 + sin->sin_addr.s_addr = nx_map_sock_lback(
26772 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
26773 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
26775 if (inet->cmsg_flags)
26776 @@ -1865,6 +1876,8 @@ static struct sock *udp_get_first(struct
26777 sk_nulls_for_each(sk, node, &hslot->head) {
26778 if (!net_eq(sock_net(sk), net))
26780 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26782 if (sk->sk_family == state->family)
26785 @@ -1882,7 +1895,9 @@ static struct sock *udp_get_next(struct
26788 sk = sk_nulls_next(sk);
26789 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
26790 + } while (sk && (!net_eq(sock_net(sk), net) ||
26791 + sk->sk_family != state->family ||
26792 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26795 if (state->bucket <= state->udp_table->mask)
26796 @@ -1989,7 +2004,10 @@ static void udp4_format_sock(struct sock
26798 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
26799 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
26800 - bucket, src, srcp, dest, destp, sp->sk_state,
26802 + nx_map_sock_lback(current_nx_info(), src), srcp,
26803 + nx_map_sock_lback(current_nx_info(), dest), destp,
26805 sk_wmem_alloc_get(sp),
26806 sk_rmem_alloc_get(sp),
26807 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26808 diff -NurpP --minimal linux-2.6.33/net/ipv6/addrconf.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/addrconf.c
26809 --- linux-2.6.33/net/ipv6/addrconf.c 2010-02-25 11:52:10.000000000 +0100
26810 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/addrconf.c 2010-02-25 13:40:38.000000000 +0100
26813 #include <linux/proc_fs.h>
26814 #include <linux/seq_file.h>
26815 +#include <linux/vs_network.h>
26816 +#include <linux/vs_inet6.h>
26818 /* Set to 3 to get tracing... */
26819 #define ACONF_DEBUG 2
26820 @@ -1120,7 +1122,7 @@ out:
26822 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
26823 const struct in6_addr *daddr, unsigned int prefs,
26824 - struct in6_addr *saddr)
26825 + struct in6_addr *saddr, struct nx_info *nxi)
26827 struct ipv6_saddr_score scores[2],
26828 *score = &scores[0], *hiscore = &scores[1];
26829 @@ -1192,6 +1194,8 @@ int ipv6_dev_get_saddr(struct net *net,
26833 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
26837 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
26838 @@ -2999,7 +3003,10 @@ static void if6_seq_stop(struct seq_file
26839 static int if6_seq_show(struct seq_file *seq, void *v)
26841 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
26842 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
26844 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
26845 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
26846 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
26848 ifp->idev->dev->ifindex,
26850 @@ -3494,6 +3501,11 @@ static int in6_dump_addrs(struct inet6_d
26851 struct ifacaddr6 *ifaca;
26853 int ip_idx = *p_ip_idx;
26854 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
26856 + /* disable ipv6 on non v6 guests */
26857 + if (nxi && !nx_info_has_v6(nxi))
26860 read_lock_bh(&idev->lock);
26862 @@ -3503,6 +3515,8 @@ static int in6_dump_addrs(struct inet6_d
26863 ifa = ifa->if_next, ip_idx++) {
26864 if (ip_idx < s_ip_idx)
26866 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
26868 err = inet6_fill_ifaddr(skb, ifa,
26869 NETLINK_CB(cb->skb).pid,
26870 cb->nlh->nlmsg_seq,
26871 @@ -3518,6 +3532,8 @@ static int in6_dump_addrs(struct inet6_d
26872 ifmca = ifmca->next, ip_idx++) {
26873 if (ip_idx < s_ip_idx)
26875 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
26877 err = inet6_fill_ifmcaddr(skb, ifmca,
26878 NETLINK_CB(cb->skb).pid,
26879 cb->nlh->nlmsg_seq,
26880 @@ -3533,6 +3549,8 @@ static int in6_dump_addrs(struct inet6_d
26881 ifaca = ifaca->aca_next, ip_idx++) {
26882 if (ip_idx < s_ip_idx)
26884 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
26886 err = inet6_fill_ifacaddr(skb, ifaca,
26887 NETLINK_CB(cb->skb).pid,
26888 cb->nlh->nlmsg_seq,
26889 @@ -3861,6 +3879,11 @@ static int inet6_dump_ifinfo(struct sk_b
26890 struct inet6_dev *idev;
26891 struct hlist_head *head;
26892 struct hlist_node *node;
26893 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
26895 + /* FIXME: maybe disable ipv6 on non v6 guests?
26896 + if (skb->sk && skb->sk->sk_vx_info)
26897 + return skb->len; */
26900 s_idx = cb->args[1];
26901 @@ -3872,6 +3895,8 @@ static int inet6_dump_ifinfo(struct sk_b
26902 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
26905 + if (!v6_dev_in_nx_info(dev, nxi))
26907 idev = __in6_dev_get(dev);
26910 diff -NurpP --minimal linux-2.6.33/net/ipv6/af_inet6.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/af_inet6.c
26911 --- linux-2.6.33/net/ipv6/af_inet6.c 2010-02-25 11:52:10.000000000 +0100
26912 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/af_inet6.c 2010-02-25 15:54:53.000000000 +0100
26914 #include <linux/netdevice.h>
26915 #include <linux/icmpv6.h>
26916 #include <linux/netfilter_ipv6.h>
26917 +#include <linux/vs_inet.h>
26918 +#include <linux/vs_inet6.h>
26920 #include <net/ip.h>
26921 #include <net/ipv6.h>
26922 @@ -159,9 +161,12 @@ lookup_protocol:
26926 + if ((protocol == IPPROTO_ICMPV6) &&
26927 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26929 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26930 goto out_rcu_unlock;
26933 sock->ops = answer->ops;
26934 answer_prot = answer->prot;
26935 answer_no_check = answer->no_check;
26936 @@ -260,6 +265,7 @@ int inet6_bind(struct socket *sock, stru
26937 struct inet_sock *inet = inet_sk(sk);
26938 struct ipv6_pinfo *np = inet6_sk(sk);
26939 struct net *net = sock_net(sk);
26940 + struct nx_v6_sock_addr nsa;
26942 unsigned short snum;
26944 @@ -271,6 +277,11 @@ int inet6_bind(struct socket *sock, stru
26946 if (addr_len < SIN6_LEN_RFC2133)
26949 + err = v6_map_sock_addr(inet, addr, &nsa);
26953 addr_type = ipv6_addr_type(&addr->sin6_addr);
26954 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
26956 @@ -302,6 +313,7 @@ int inet6_bind(struct socket *sock, stru
26957 /* Reproduce AF_INET checks to make the bindings consitant */
26958 v4addr = addr->sin6_addr.s6_addr32[3];
26959 chk_addr_ret = inet_addr_type(net, v4addr);
26961 if (!sysctl_ip_nonlocal_bind &&
26962 !(inet->freebind || inet->transparent) &&
26963 v4addr != htonl(INADDR_ANY) &&
26964 @@ -311,6 +323,10 @@ int inet6_bind(struct socket *sock, stru
26965 err = -EADDRNOTAVAIL;
26968 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
26969 + err = -EADDRNOTAVAIL;
26973 if (addr_type != IPV6_ADDR_ANY) {
26974 struct net_device *dev = NULL;
26975 @@ -337,6 +353,11 @@ int inet6_bind(struct socket *sock, stru
26979 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
26980 + err = -EADDRNOTAVAIL;
26984 /* ipv4 addr of the socket is invalid. Only the
26985 * unspecified and mapped address have a v4 equivalent.
26987 @@ -352,6 +373,9 @@ int inet6_bind(struct socket *sock, stru
26991 + /* what's that for? */
26992 + v6_set_sock_addr(inet, &nsa);
26994 inet->inet_rcv_saddr = v4addr;
26995 inet->inet_saddr = v4addr;
26997 @@ -450,9 +474,11 @@ int inet6_getname(struct socket *sock, s
26999 sin->sin6_port = inet->inet_dport;
27000 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27001 + /* FIXME: remap lback? */
27003 sin->sin6_flowinfo = np->flow_label;
27005 + /* FIXME: remap lback? */
27006 if (ipv6_addr_any(&np->rcv_saddr))
27007 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27009 diff -NurpP --minimal linux-2.6.33/net/ipv6/fib6_rules.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/fib6_rules.c
27010 --- linux-2.6.33/net/ipv6/fib6_rules.c 2010-02-25 11:52:10.000000000 +0100
27011 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/fib6_rules.c 2010-02-25 12:02:16.000000000 +0100
27012 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
27013 if (ipv6_dev_get_saddr(net,
27014 ip6_dst_idev(&rt->u.dst)->dev,
27015 &flp->fl6_dst, srcprefs,
27019 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27021 diff -NurpP --minimal linux-2.6.33/net/ipv6/inet6_hashtables.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/inet6_hashtables.c
27022 --- linux-2.6.33/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
27023 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/inet6_hashtables.c 2010-02-25 12:02:16.000000000 +0100
27026 #include <linux/module.h>
27027 #include <linux/random.h>
27028 +#include <linux/vs_inet6.h>
27030 #include <net/inet_connection_sock.h>
27031 #include <net/inet_hashtables.h>
27032 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
27033 unsigned int slot = hash & hashinfo->ehash_mask;
27034 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27039 sk_nulls_for_each_rcu(sk, node, &head->chain) {
27040 @@ -94,7 +94,7 @@ begin:
27048 if (get_nulls_value(node) != slot)
27049 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
27050 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27054 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27057 if (sk->sk_bound_dev_if) {
27058 if (sk->sk_bound_dev_if != dif)
27059 diff -NurpP --minimal linux-2.6.33/net/ipv6/ip6_output.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/ip6_output.c
27060 --- linux-2.6.33/net/ipv6/ip6_output.c 2010-02-25 11:52:10.000000000 +0100
27061 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/ip6_output.c 2010-02-25 12:02:16.000000000 +0100
27062 @@ -933,7 +933,7 @@ static int ip6_dst_lookup_tail(struct so
27063 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27065 sk ? inet6_sk(sk)->srcprefs : 0,
27067 + &fl->fl6_src, sk->sk_nx_info);
27069 goto out_err_release;
27071 diff -NurpP --minimal linux-2.6.33/net/ipv6/Kconfig linux-2.6.33-vs2.3.0.36.30/net/ipv6/Kconfig
27072 --- linux-2.6.33/net/ipv6/Kconfig 2010-02-25 11:52:10.000000000 +0100
27073 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/Kconfig 2010-02-25 12:02:16.000000000 +0100
27076 # IPv6 as module will cause a CRASH if you try to unload it
27078 - tristate "The IPv6 protocol"
27080 + bool "The IPv6 protocol"
27083 This is complemental support for the IP version 6.
27084 You will still be able to do traditional IPv4 networking as well.
27085 diff -NurpP --minimal linux-2.6.33/net/ipv6/ndisc.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/ndisc.c
27086 --- linux-2.6.33/net/ipv6/ndisc.c 2010-02-25 11:52:10.000000000 +0100
27087 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/ndisc.c 2010-02-25 12:02:16.000000000 +0100
27088 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
27090 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27091 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27093 + &tmpaddr, NULL /* FIXME: ? */ ))
27095 src_addr = &tmpaddr;
27097 diff -NurpP --minimal linux-2.6.33/net/ipv6/raw.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/raw.c
27098 --- linux-2.6.33/net/ipv6/raw.c 2010-02-25 11:52:11.000000000 +0100
27099 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/raw.c 2010-02-25 12:02:16.000000000 +0100
27101 #include <linux/icmpv6.h>
27102 #include <linux/netfilter.h>
27103 #include <linux/netfilter_ipv6.h>
27104 +#include <linux/vs_inet6.h>
27105 #include <linux/skbuff.h>
27106 #include <asm/uaccess.h>
27107 #include <asm/ioctls.h>
27108 @@ -282,6 +283,13 @@ static int rawv6_bind(struct sock *sk, s
27112 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27113 + err = -EADDRNOTAVAIL;
27119 /* ipv4 addr of the socket is invalid. Only the
27120 * unspecified and mapped address have a v4 equivalent.
27122 diff -NurpP --minimal linux-2.6.33/net/ipv6/route.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/route.c
27123 --- linux-2.6.33/net/ipv6/route.c 2010-02-25 11:52:11.000000000 +0100
27124 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/route.c 2010-02-25 12:02:16.000000000 +0100
27125 @@ -2258,7 +2258,8 @@ static int rt6_fill_node(struct net *net
27126 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27127 struct in6_addr saddr_buf;
27128 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27129 - dst, 0, &saddr_buf) == 0)
27130 + dst, 0, &saddr_buf,
27131 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27132 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27135 diff -NurpP --minimal linux-2.6.33/net/ipv6/tcp_ipv6.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/tcp_ipv6.c
27136 --- linux-2.6.33/net/ipv6/tcp_ipv6.c 2010-02-25 11:52:11.000000000 +0100
27137 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/tcp_ipv6.c 2010-02-25 12:02:16.000000000 +0100
27140 #include <linux/crypto.h>
27141 #include <linux/scatterlist.h>
27142 +#include <linux/vs_inet6.h>
27144 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27145 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27146 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
27147 * connect() to INADDR_ANY means loopback (BSD'ism).
27150 - if(ipv6_addr_any(&usin->sin6_addr))
27151 - usin->sin6_addr.s6_addr[15] = 0x1;
27152 + if(ipv6_addr_any(&usin->sin6_addr)) {
27153 + struct nx_info *nxi = sk->sk_nx_info;
27155 + if (nxi && nx_info_has_v6(nxi))
27156 + /* FIXME: remap lback? */
27157 + usin->sin6_addr = nxi->v6.ip;
27159 + usin->sin6_addr.s6_addr[15] = 0x1;
27162 addr_type = ipv6_addr_type(&usin->sin6_addr);
27164 diff -NurpP --minimal linux-2.6.33/net/ipv6/udp.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/udp.c
27165 --- linux-2.6.33/net/ipv6/udp.c 2010-02-25 11:52:11.000000000 +0100
27166 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/udp.c 2010-02-25 15:58:22.000000000 +0100
27167 @@ -47,13 +47,14 @@
27169 #include <linux/proc_fs.h>
27170 #include <linux/seq_file.h>
27171 +#include <linux/vs_inet6.h>
27172 #include "udp_impl.h"
27174 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27176 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27177 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27178 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
27179 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
27180 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27181 int sk_ipv6only = ipv6_only_sock(sk);
27182 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27183 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
27184 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27186 /* if both are mapped, treat as IPv4 */
27187 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
27188 - return (!sk2_ipv6only &&
27189 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
27190 - sk1_rcv_saddr == sk2_rcv_saddr));
27191 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
27192 + if (!sk2_ipv6only &&
27193 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
27194 + sk_rcv_saddr == sk2_rcv_saddr))
27200 if (addr_type2 == IPV6_ADDR_ANY &&
27201 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27205 if (addr_type == IPV6_ADDR_ANY &&
27206 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27210 if (sk2_rcv_saddr6 &&
27211 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27218 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
27219 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
27220 + if (!sk2_rcv_saddr)
27221 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
27222 + if (!sk_rcv_saddr)
27223 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
27226 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
27227 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
27228 + else if (addr_type2 == IPV6_ADDR_ANY)
27229 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
27230 + else if (addr_type == IPV6_ADDR_ANY) {
27231 + if (addr_type2 == IPV6_ADDR_MAPPED)
27232 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
27234 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
27239 static unsigned int udp6_portaddr_hash(struct net *net,
27240 @@ -133,6 +159,10 @@ static inline int compute_score(struct s
27241 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27245 + /* block non nx_info ips */
27246 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27249 if (!ipv6_addr_any(&np->daddr)) {
27250 if (!ipv6_addr_equal(&np->daddr, saddr))
27251 diff -NurpP --minimal linux-2.6.33/net/ipv6/xfrm6_policy.c linux-2.6.33-vs2.3.0.36.30/net/ipv6/xfrm6_policy.c
27252 --- linux-2.6.33/net/ipv6/xfrm6_policy.c 2010-02-25 11:52:11.000000000 +0100
27253 +++ linux-2.6.33-vs2.3.0.36.30/net/ipv6/xfrm6_policy.c 2010-02-25 12:02:16.000000000 +0100
27254 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
27255 dev = ip6_dst_idev(dst)->dev;
27256 ipv6_dev_get_saddr(dev_net(dev), dev,
27257 (struct in6_addr *)&daddr->a6, 0,
27258 - (struct in6_addr *)&saddr->a6);
27259 + (struct in6_addr *)&saddr->a6, NULL);
27263 diff -NurpP --minimal linux-2.6.33/net/netlink/af_netlink.c linux-2.6.33-vs2.3.0.36.30/net/netlink/af_netlink.c
27264 --- linux-2.6.33/net/netlink/af_netlink.c 2010-02-25 11:52:11.000000000 +0100
27265 +++ linux-2.6.33-vs2.3.0.36.30/net/netlink/af_netlink.c 2010-02-25 12:02:16.000000000 +0100
27267 #include <linux/types.h>
27268 #include <linux/audit.h>
27269 #include <linux/mutex.h>
27270 +#include <linux/vs_context.h>
27271 +#include <linux/vs_network.h>
27272 +#include <linux/vs_limit.h>
27274 #include <net/net_namespace.h>
27275 #include <net/sock.h>
27276 @@ -1905,6 +1908,8 @@ static struct sock *netlink_seq_socket_i
27277 sk_for_each(s, node, &hash->table[j]) {
27278 if (sock_net(s) != seq_file_net(seq))
27280 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27284 iter->hash_idx = j;
27285 @@ -1939,7 +1944,8 @@ static void *netlink_seq_next(struct seq
27289 - } while (s && sock_net(s) != seq_file_net(seq));
27290 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27291 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27295 @@ -1951,7 +1957,8 @@ static void *netlink_seq_next(struct seq
27297 for (; j <= hash->mask; j++) {
27298 s = sk_head(&hash->table[j]);
27299 - while (s && sock_net(s) != seq_file_net(seq))
27300 + while (s && (sock_net(s) != seq_file_net(seq) ||
27301 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27305 diff -NurpP --minimal linux-2.6.33/net/sctp/ipv6.c linux-2.6.33-vs2.3.0.36.30/net/sctp/ipv6.c
27306 --- linux-2.6.33/net/sctp/ipv6.c 2010-02-25 11:52:12.000000000 +0100
27307 +++ linux-2.6.33-vs2.3.0.36.30/net/sctp/ipv6.c 2010-02-25 12:02:16.000000000 +0100
27308 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
27309 dst ? ip6_dst_idev(dst)->dev : NULL,
27310 &daddr->v6.sin6_addr,
27311 inet6_sk(&sk->inet.sk)->srcprefs,
27312 - &saddr->v6.sin6_addr);
27313 + &saddr->v6.sin6_addr,
27314 + asoc->base.sk->sk_nx_info);
27315 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
27316 &saddr->v6.sin6_addr);
27318 diff -NurpP --minimal linux-2.6.33/net/socket.c linux-2.6.33-vs2.3.0.36.30/net/socket.c
27319 --- linux-2.6.33/net/socket.c 2010-02-25 11:52:12.000000000 +0100
27320 +++ linux-2.6.33-vs2.3.0.36.30/net/socket.c 2010-02-25 13:51:25.000000000 +0100
27323 #include <net/sock.h>
27324 #include <linux/netfilter.h>
27325 +#include <linux/vs_base.h>
27326 +#include <linux/vs_socket.h>
27327 +#include <linux/vs_inet.h>
27328 +#include <linux/vs_inet6.h>
27330 #include <linux/if_tun.h>
27331 #include <linux/ipv6_route.h>
27332 @@ -539,7 +543,7 @@ static inline int __sock_sendmsg(struct
27333 struct msghdr *msg, size_t size)
27335 struct sock_iocb *si = kiocb_to_siocb(iocb);
27341 @@ -550,7 +554,22 @@ static inline int __sock_sendmsg(struct
27345 - return sock->ops->sendmsg(iocb, sock, msg, size);
27346 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27349 + vx_sock_send(sock->sk, size);
27351 + vx_sock_fail(sock->sk, size);
27353 + vxdprintk(VXD_CBIT(net, 7),
27354 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27356 + (sock->sk)?sock->sk->sk_nx_info:0,
27357 + (sock->sk)?sock->sk->sk_vx_info:0,
27358 + (sock->sk)?sock->sk->sk_xid:0,
27359 + (sock->sk)?sock->sk->sk_nid:0,
27360 + (unsigned int)size, len);
27364 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27365 @@ -667,6 +686,7 @@ static inline int __sock_recvmsg_nosec(s
27366 struct msghdr *msg, size_t size, int flags)
27368 struct sock_iocb *si = kiocb_to_siocb(iocb);
27373 @@ -674,7 +694,18 @@ static inline int __sock_recvmsg_nosec(s
27377 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27378 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27379 + if ((len >= 0) && sock->sk)
27380 + vx_sock_recv(sock->sk, len);
27381 + vxdprintk(VXD_CBIT(net, 7),
27382 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27384 + (sock->sk)?sock->sk->sk_nx_info:0,
27385 + (sock->sk)?sock->sk->sk_vx_info:0,
27386 + (sock->sk)?sock->sk->sk_xid:0,
27387 + (sock->sk)?sock->sk->sk_nid:0,
27388 + (unsigned int)size, len);
27392 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27393 @@ -1182,6 +1213,13 @@ static int __sock_create(struct net *net
27394 if (type < 0 || type >= SOCK_MAX)
27397 + if (!nx_check(0, VS_ADMIN)) {
27398 + if (family == PF_INET && !current_nx_info_has_v4())
27399 + return -EAFNOSUPPORT;
27400 + if (family == PF_INET6 && !current_nx_info_has_v6())
27401 + return -EAFNOSUPPORT;
27406 This uglymoron is moved from INET layer to here to avoid
27407 @@ -1314,6 +1352,7 @@ SYSCALL_DEFINE3(socket, int, family, int
27411 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27412 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27415 @@ -1355,10 +1394,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
27416 err = sock_create(family, type, protocol, &sock1);
27419 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27421 err = sock_create(family, type, protocol, &sock2);
27423 goto out_release_1;
27424 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27426 err = sock1->ops->socketpair(sock1, sock2);
27428 diff -NurpP --minimal linux-2.6.33/net/sunrpc/auth.c linux-2.6.33-vs2.3.0.36.30/net/sunrpc/auth.c
27429 --- linux-2.6.33/net/sunrpc/auth.c 2010-02-25 11:52:12.000000000 +0100
27430 +++ linux-2.6.33-vs2.3.0.36.30/net/sunrpc/auth.c 2010-02-25 12:02:16.000000000 +0100
27432 #include <linux/hash.h>
27433 #include <linux/sunrpc/clnt.h>
27434 #include <linux/spinlock.h>
27435 +#include <linux/vs_tag.h>
27438 # define RPCDBG_FACILITY RPCDBG_AUTH
27439 @@ -363,6 +364,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27440 memset(&acred, 0, sizeof(acred));
27441 acred.uid = cred->fsuid;
27442 acred.gid = cred->fsgid;
27443 + acred.tag = dx_current_tag();
27444 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
27446 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
27447 @@ -403,6 +405,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27448 struct auth_cred acred = {
27451 + .tag = dx_current_tag(),
27453 struct rpc_cred *ret;
27455 diff -NurpP --minimal linux-2.6.33/net/sunrpc/auth_unix.c linux-2.6.33-vs2.3.0.36.30/net/sunrpc/auth_unix.c
27456 --- linux-2.6.33/net/sunrpc/auth_unix.c 2008-12-25 00:26:37.000000000 +0100
27457 +++ linux-2.6.33-vs2.3.0.36.30/net/sunrpc/auth_unix.c 2010-02-25 12:02:16.000000000 +0100
27458 @@ -11,12 +11,14 @@
27459 #include <linux/module.h>
27460 #include <linux/sunrpc/clnt.h>
27461 #include <linux/sunrpc/auth.h>
27462 +#include <linux/vs_tag.h>
27464 #define NFS_NGROUPS 16
27467 struct rpc_cred uc_base;
27470 gid_t uc_gids[NFS_NGROUPS];
27472 #define uc_uid uc_base.cr_uid
27473 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
27474 groups = NFS_NGROUPS;
27476 cred->uc_gid = acred->gid;
27477 + cred->uc_tag = acred->tag;
27478 for (i = 0; i < groups; i++)
27479 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27480 if (i < NFS_NGROUPS)
27481 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
27485 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
27486 + if (cred->uc_uid != acred->uid ||
27487 + cred->uc_gid != acred->gid ||
27488 + cred->uc_tag != acred->tag)
27491 if (acred->group_info != NULL)
27492 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
27493 struct rpc_clnt *clnt = task->tk_client;
27494 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
27495 __be32 *base, *hold;
27499 *p++ = htonl(RPC_AUTH_UNIX);
27501 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
27502 * Copy the UTS nodename captured when the client was created.
27504 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27505 + tag = task->tk_client->cl_tag;
27507 - *p++ = htonl((u32) cred->uc_uid);
27508 - *p++ = htonl((u32) cred->uc_gid);
27509 + *p++ = htonl((u32) TAGINO_UID(tag,
27510 + cred->uc_uid, cred->uc_tag));
27511 + *p++ = htonl((u32) TAGINO_GID(tag,
27512 + cred->uc_gid, cred->uc_tag));
27514 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27515 *p++ = htonl((u32) cred->uc_gids[i]);
27516 diff -NurpP --minimal linux-2.6.33/net/sunrpc/clnt.c linux-2.6.33-vs2.3.0.36.30/net/sunrpc/clnt.c
27517 --- linux-2.6.33/net/sunrpc/clnt.c 2010-02-25 11:52:12.000000000 +0100
27518 +++ linux-2.6.33-vs2.3.0.36.30/net/sunrpc/clnt.c 2010-02-25 12:02:16.000000000 +0100
27520 #include <linux/utsname.h>
27521 #include <linux/workqueue.h>
27522 #include <linux/in6.h>
27523 +#include <linux/vs_cvirt.h>
27525 #include <linux/sunrpc/clnt.h>
27526 #include <linux/sunrpc/rpc_pipe_fs.h>
27527 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27528 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
27529 clnt->cl_chatty = 1;
27531 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27532 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27533 + clnt->cl_tag = 1; */
27536 EXPORT_SYMBOL_GPL(rpc_create);
27537 diff -NurpP --minimal linux-2.6.33/net/unix/af_unix.c linux-2.6.33-vs2.3.0.36.30/net/unix/af_unix.c
27538 --- linux-2.6.33/net/unix/af_unix.c 2010-02-25 11:52:12.000000000 +0100
27539 +++ linux-2.6.33-vs2.3.0.36.30/net/unix/af_unix.c 2010-02-25 12:02:16.000000000 +0100
27540 @@ -114,6 +114,8 @@
27541 #include <linux/mount.h>
27542 #include <net/checksum.h>
27543 #include <linux/security.h>
27544 +#include <linux/vs_context.h>
27545 +#include <linux/vs_limit.h>
27547 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
27548 static DEFINE_SPINLOCK(unix_table_lock);
27549 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
27550 if (!net_eq(sock_net(s), net))
27553 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27555 if (u->addr->len == len &&
27556 !memcmp(u->addr->name, sunname, len))
27558 @@ -2115,6 +2119,8 @@ static struct sock *unix_seq_idx(struct
27559 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
27560 if (sock_net(s) != seq_file_net(seq))
27562 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27567 @@ -2139,7 +2145,8 @@ static void *unix_seq_next(struct seq_fi
27568 sk = first_unix_socket(&iter->i);
27570 sk = next_unix_socket(&iter->i, sk);
27571 - while (sk && (sock_net(sk) != seq_file_net(seq)))
27572 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
27573 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
27574 sk = next_unix_socket(&iter->i, sk);
27577 diff -NurpP --minimal linux-2.6.33/net/x25/af_x25.c linux-2.6.33-vs2.3.0.36.30/net/x25/af_x25.c
27578 --- linux-2.6.33/net/x25/af_x25.c 2010-02-25 11:52:12.000000000 +0100
27579 +++ linux-2.6.33-vs2.3.0.36.30/net/x25/af_x25.c 2010-02-25 12:02:16.000000000 +0100
27580 @@ -526,7 +526,10 @@ static int x25_create(struct net *net, s
27584 - sock_init_data(sock, sk);
27585 + sk->sk_socket = sock;
27586 + sk->sk_type = sock->type;
27587 + sk->sk_sleep = &sock->wait;
27590 x25_init_timers(sk);
27592 diff -NurpP --minimal linux-2.6.33/scripts/checksyscalls.sh linux-2.6.33-vs2.3.0.36.30/scripts/checksyscalls.sh
27593 --- linux-2.6.33/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
27594 +++ linux-2.6.33-vs2.3.0.36.30/scripts/checksyscalls.sh 2010-02-25 12:02:16.000000000 +0100
27595 @@ -194,7 +194,6 @@ cat << EOF
27596 #define __IGNORE_afs_syscall
27597 #define __IGNORE_getpmsg
27598 #define __IGNORE_putpmsg
27599 -#define __IGNORE_vserver
27603 diff -NurpP --minimal linux-2.6.33/security/commoncap.c linux-2.6.33-vs2.3.0.36.30/security/commoncap.c
27604 --- linux-2.6.33/security/commoncap.c 2010-02-25 11:52:12.000000000 +0100
27605 +++ linux-2.6.33-vs2.3.0.36.30/security/commoncap.c 2010-02-25 12:02:16.000000000 +0100
27607 #include <linux/sched.h>
27608 #include <linux/prctl.h>
27609 #include <linux/securebits.h>
27610 +#include <linux/vs_context.h>
27613 * If a non-root user executes a setuid-root binary in
27614 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
27616 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27618 - NETLINK_CB(skb).eff_cap = current_cap();
27619 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
27623 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
27628 EXPORT_SYMBOL(cap_netlink_recv);
27631 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
27632 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
27635 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
27636 + struct vx_info *vxi = tsk->vx_info;
27639 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
27640 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
27641 + cap_raised(tsk->cap_effective, cap),
27642 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
27645 + /* special case SETUP */
27646 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
27647 + /* FIXME: maybe use cred instead? */
27648 + cap_raised(tsk->cred->cap_effective, cap))
27651 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
27655 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry
27657 if (!strncmp(name, XATTR_SECURITY_PREFIX,
27658 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
27659 - !capable(CAP_SYS_ADMIN))
27660 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
27664 @@ -894,7 +911,8 @@ error:
27666 int cap_syslog(int type)
27668 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
27669 + if ((type != 3 && type != 10) &&
27670 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27674 @@ -946,3 +964,4 @@ int cap_file_mmap(struct file *file, uns
27679 diff -NurpP --minimal linux-2.6.33/security/selinux/hooks.c linux-2.6.33-vs2.3.0.36.30/security/selinux/hooks.c
27680 --- linux-2.6.33/security/selinux/hooks.c 2010-02-25 11:52:12.000000000 +0100
27681 +++ linux-2.6.33-vs2.3.0.36.30/security/selinux/hooks.c 2010-02-25 12:02:16.000000000 +0100
27683 #include <linux/dccp.h>
27684 #include <linux/quota.h>
27685 #include <linux/un.h> /* for Unix socket types */
27686 -#include <net/af_unix.h> /* for Unix socket types */
27687 #include <linux/parser.h>
27688 #include <linux/nfs_mount.h>
27689 #include <net/ipv6.h>