1 diff -NurpP --minimal linux-2.6.33/arch/alpha/Kconfig linux-2.6.33-vs2.3.0.36.30.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/Documentation/scheduler/sched-cfs-hard-limits.txt 2010-02-25 16:25:27.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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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/gpu/drm/radeon/r100_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r100_reg_safe.h
1700 --- linux-2.6.33/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1701 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r100_reg_safe.h 2010-02-27 15:52:40.000000000 +0100
1703 +static const unsigned r100_reg_safe_bm[102] = {
1704 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1705 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1706 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1707 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1708 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1709 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1710 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1711 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1712 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1713 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1714 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1715 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1716 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1717 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1718 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1719 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1720 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1721 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1722 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1723 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1724 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1725 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1726 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1727 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1728 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1729 + 0xFFFFFFFF, 0xFFFFFFEF,
1731 diff -NurpP --minimal linux-2.6.33/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r200_reg_safe.h
1732 --- linux-2.6.33/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1733 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r200_reg_safe.h 2010-02-27 15:52:44.000000000 +0100
1735 +static const unsigned r200_reg_safe_bm[102] = {
1736 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1737 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1738 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1739 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1740 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1741 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1742 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1743 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1744 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1745 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1746 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1747 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1748 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1749 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1750 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1751 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1752 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1753 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1754 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1755 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1756 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1757 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1758 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1759 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1760 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1761 + 0xFFFFFE3F, 0xFFFFFFEF,
1763 diff -NurpP --minimal linux-2.6.33/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r300_reg_safe.h
1764 --- linux-2.6.33/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1765 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r300_reg_safe.h 2010-02-27 15:52:41.000000000 +0100
1767 +static const unsigned r300_reg_safe_bm[159] = {
1768 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1769 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1770 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1771 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1772 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1773 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1774 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1775 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1776 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1777 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1778 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1779 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1780 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1781 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1782 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1783 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1784 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1785 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1786 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1787 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1788 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1789 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1790 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1791 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1792 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1793 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1794 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1795 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1796 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1797 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1798 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1799 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1800 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1801 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1802 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1803 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1804 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1805 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1806 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1807 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1809 diff -NurpP --minimal linux-2.6.33/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r420_reg_safe.h
1810 --- linux-2.6.33/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1811 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/r420_reg_safe.h 2010-02-27 15:52:41.000000000 +0100
1813 +static const unsigned r420_reg_safe_bm[159] = {
1814 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1815 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1816 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1817 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1818 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1819 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1820 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1821 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1822 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1823 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1824 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1825 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1826 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1827 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1828 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1829 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1830 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1831 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1832 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1833 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1834 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1835 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1836 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1837 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1838 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1839 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1840 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1841 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1842 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1843 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1844 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1845 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1846 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1847 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1848 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1849 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1850 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1851 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1852 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1853 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1855 diff -NurpP --minimal linux-2.6.33/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/rn50_reg_safe.h
1856 --- linux-2.6.33/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1857 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/rn50_reg_safe.h 2010-02-27 15:52:40.000000000 +0100
1859 +static const unsigned rn50_reg_safe_bm[102] = {
1860 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1861 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1862 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1863 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1864 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1865 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1866 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1867 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1868 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1869 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1870 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1871 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1872 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1873 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1874 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1875 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1876 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1877 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1878 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1879 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1880 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1881 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1882 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1883 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1884 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1885 + 0xFFFFFFFF, 0xFFFFFFFF,
1887 diff -NurpP --minimal linux-2.6.33/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/rs600_reg_safe.h
1888 --- linux-2.6.33/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1889 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/rs600_reg_safe.h 2010-02-27 15:52:42.000000000 +0100
1891 +static const unsigned rs600_reg_safe_bm[219] = {
1892 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1893 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1894 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1895 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1896 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1897 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1898 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1899 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1900 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1901 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1902 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1903 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1904 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1905 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1906 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1907 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1908 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1909 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1910 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1911 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1912 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1913 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1914 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1915 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1916 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1917 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1918 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1919 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1920 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1921 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1922 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1923 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1924 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1925 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1926 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1927 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1928 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1929 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1930 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1931 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1932 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1933 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1934 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1935 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1936 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1937 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1938 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1939 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1940 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1941 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1942 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1943 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1944 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1945 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1946 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1948 diff -NurpP --minimal linux-2.6.33/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/rv515_reg_safe.h
1949 --- linux-2.6.33/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1950 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/gpu/drm/radeon/rv515_reg_safe.h 2010-02-27 15:52:42.000000000 +0100
1952 +static const unsigned rv515_reg_safe_bm[219] = {
1953 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1954 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1955 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1956 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1957 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1958 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1959 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1960 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1961 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1962 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1963 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1964 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1965 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1966 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1967 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1968 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1969 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1970 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1971 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
1972 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1973 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1974 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1975 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1976 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1977 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1978 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1979 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1980 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1981 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1982 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1983 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1984 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1985 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1986 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1987 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1988 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1989 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1990 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1991 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1992 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
1993 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1994 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1995 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1996 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1997 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1998 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1999 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2000 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2001 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2002 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2003 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2004 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2005 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2006 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2007 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2009 diff -NurpP --minimal linux-2.6.33/drivers/infiniband/core/addr.c linux-2.6.33-vs2.3.0.36.30.1/drivers/infiniband/core/addr.c
2010 --- linux-2.6.33/drivers/infiniband/core/addr.c 2010-02-25 11:51:39.000000000 +0100
2011 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/infiniband/core/addr.c 2010-02-26 10:39:59.000000000 +0100
2012 @@ -251,7 +251,7 @@ static int addr6_resolve(struct sockaddr
2014 if (ipv6_addr_any(&fl.fl6_src)) {
2015 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
2016 - &fl.fl6_dst, 0, &fl.fl6_src);
2017 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
2021 diff -NurpP --minimal linux-2.6.33/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.33-vs2.3.0.36.30.1/drivers/infiniband/hw/ipath/ipath_user_pages.c
2022 --- linux-2.6.33/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-12-03 20:02:23.000000000 +0100
2023 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-02-25 12:02:16.000000000 +0100
2025 #include <linux/mm.h>
2026 #include <linux/device.h>
2027 #include <linux/sched.h>
2028 +#include <linux/vs_memory.h>
2030 #include "ipath_kernel.h"
2032 @@ -62,7 +63,8 @@ static int __get_user_pages(unsigned lon
2033 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
2036 - if (num_pages > lock_limit) {
2037 + if (num_pages > lock_limit ||
2038 + !vx_vmlocked_avail(current->mm, num_pages)) {
2042 @@ -79,7 +81,7 @@ static int __get_user_pages(unsigned lon
2046 - current->mm->locked_vm += num_pages;
2047 + vx_vmlocked_add(current->mm, num_pages);
2051 @@ -178,7 +180,7 @@ void ipath_release_user_pages(struct pag
2053 __ipath_release_user_pages(p, num_pages, 1);
2055 - current->mm->locked_vm -= num_pages;
2056 + vx_vmlocked_sub(current->mm, num_pages);
2058 up_write(¤t->mm->mmap_sem);
2060 @@ -195,7 +197,7 @@ static void user_pages_account(struct wo
2061 container_of(_work, struct ipath_user_pages_work, work);
2063 down_write(&work->mm->mmap_sem);
2064 - work->mm->locked_vm -= work->num_pages;
2065 + vx_vmlocked_sub(work->mm, work->num_pages);
2066 up_write(&work->mm->mmap_sem);
2069 diff -NurpP --minimal linux-2.6.33/drivers/md/dm.c linux-2.6.33-vs2.3.0.36.30.1/drivers/md/dm.c
2070 --- linux-2.6.33/drivers/md/dm.c 2010-02-25 11:51:41.000000000 +0100
2071 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/md/dm.c 2010-02-25 12:10:11.000000000 +0100
2073 #include <linux/slab.h>
2074 #include <linux/idr.h>
2075 #include <linux/hdreg.h>
2076 +#include <linux/vs_base.h>
2078 #include <trace/events/block.h>
2080 @@ -119,6 +120,7 @@ struct mapped_device {
2083 atomic_t open_count;
2086 unsigned long flags;
2088 @@ -337,6 +339,7 @@ int dm_deleting_md(struct mapped_device
2089 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
2091 struct mapped_device *md;
2094 spin_lock(&_minor_lock);
2096 @@ -345,18 +348,19 @@ static int dm_blk_open(struct block_devi
2099 if (test_bit(DMF_FREEING, &md->flags) ||
2100 - dm_deleting_md(md)) {
2102 + dm_deleting_md(md))
2106 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
2111 atomic_inc(&md->open_count);
2115 spin_unlock(&_minor_lock);
2117 - return md ? 0 : -ENXIO;
2121 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
2122 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
2127 + * Get the xid associated with a dm device
2129 +xid_t dm_get_xid(struct mapped_device *md)
2134 /*-----------------------------------------------------------------
2136 * A more elegant soln is in the works that uses the queue
2137 @@ -1886,6 +1898,7 @@ static struct mapped_device *alloc_dev(i
2138 INIT_LIST_HEAD(&md->uevent_list);
2139 spin_lock_init(&md->uevent_lock);
2141 + md->xid = vx_current_xid();
2142 md->queue = blk_init_queue(dm_request_fn, NULL);
2145 diff -NurpP --minimal linux-2.6.33/drivers/md/dm.h linux-2.6.33-vs2.3.0.36.30.1/drivers/md/dm.h
2146 --- linux-2.6.33/drivers/md/dm.h 2010-02-25 11:51:41.000000000 +0100
2147 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/md/dm.h 2010-02-25 12:02:16.000000000 +0100
2148 @@ -41,6 +41,8 @@ struct dm_dev_internal {
2150 struct dm_md_mempools;
2152 +xid_t dm_get_xid(struct mapped_device *md);
2154 /*-----------------------------------------------------------------
2155 * Internal table functions.
2156 *---------------------------------------------------------------*/
2157 diff -NurpP --minimal linux-2.6.33/drivers/md/dm-ioctl.c linux-2.6.33-vs2.3.0.36.30.1/drivers/md/dm-ioctl.c
2158 --- linux-2.6.33/drivers/md/dm-ioctl.c 2010-02-25 11:51:41.000000000 +0100
2159 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/md/dm-ioctl.c 2010-02-25 12:02:16.000000000 +0100
2161 #include <linux/dm-ioctl.h>
2162 #include <linux/hdreg.h>
2163 #include <linux/compat.h>
2164 +#include <linux/vs_context.h>
2166 #include <asm/uaccess.h>
2168 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
2169 unsigned int h = hash_str(str);
2171 list_for_each_entry (hc, _name_buckets + h, name_list)
2172 - if (!strcmp(hc->name, str)) {
2173 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2174 + !strcmp(hc->name, str)) {
2178 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
2179 unsigned int h = hash_str(str);
2181 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
2182 - if (!strcmp(hc->uuid, str)) {
2183 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2184 + !strcmp(hc->uuid, str)) {
2188 @@ -363,6 +366,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
2190 static int remove_all(struct dm_ioctl *param, size_t param_size)
2192 + if (!vx_check(0, VS_ADMIN))
2195 dm_hash_remove_all(1);
2196 param->data_size = 0;
2198 @@ -410,6 +416,8 @@ static int list_devices(struct dm_ioctl
2200 for (i = 0; i < NUM_BUCKETS; i++) {
2201 list_for_each_entry (hc, _name_buckets + i, name_list) {
2202 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2204 needed += sizeof(struct dm_name_list);
2205 needed += strlen(hc->name) + 1;
2206 needed += ALIGN_MASK;
2207 @@ -433,6 +441,8 @@ static int list_devices(struct dm_ioctl
2209 for (i = 0; i < NUM_BUCKETS; i++) {
2210 list_for_each_entry (hc, _name_buckets + i, name_list) {
2211 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2214 old_nl->next = (uint32_t) ((void *) nl -
2216 @@ -667,10 +677,11 @@ static struct hash_cell *__find_device_h
2220 - mdptr = dm_get_mdptr(md);
2221 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2222 + mdptr = dm_get_mdptr(md);
2230 @@ -1508,8 +1519,8 @@ static int ctl_ioctl(uint command, struc
2234 - /* only root can play with this */
2235 - if (!capable(CAP_SYS_ADMIN))
2236 + /* only root and certain contexts can play with this */
2237 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2240 if (_IOC_TYPE(command) != DM_IOCTL)
2241 diff -NurpP --minimal linux-2.6.33/drivers/net/tun.c linux-2.6.33-vs2.3.0.36.30.1/drivers/net/tun.c
2242 --- linux-2.6.33/drivers/net/tun.c 2010-02-25 11:51:53.000000000 +0100
2243 +++ linux-2.6.33-vs2.3.0.36.30.1/drivers/net/tun.c 2010-02-25 12:02:16.000000000 +0100
2245 #include <linux/crc32.h>
2246 #include <linux/nsproxy.h>
2247 #include <linux/virtio_net.h>
2248 +#include <linux/vs_network.h>
2249 #include <net/net_namespace.h>
2250 #include <net/netns/generic.h>
2251 #include <net/rtnetlink.h>
2252 @@ -102,6 +103,7 @@ struct tun_struct {
2258 struct net_device *dev;
2259 struct fasync_struct *fasync;
2260 @@ -816,6 +818,7 @@ static void tun_setup(struct net_device
2264 + tun->nid = current->nid;
2266 dev->ethtool_ops = &tun_ethtool_ops;
2267 dev->destructor = tun_free_netdev;
2268 @@ -932,7 +935,7 @@ static int tun_set_iff(struct net *net,
2270 if (((tun->owner != -1 && cred->euid != tun->owner) ||
2271 (tun->group != -1 && !in_egroup_p(tun->group))) &&
2272 - !capable(CAP_NET_ADMIN))
2273 + !cap_raised(current_cap(), CAP_NET_ADMIN))
2275 err = security_tun_dev_attach(tun->socket.sk);
2277 @@ -946,7 +949,7 @@ static int tun_set_iff(struct net *net,
2279 unsigned long flags = 0;
2281 - if (!capable(CAP_NET_ADMIN))
2282 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
2284 err = security_tun_dev_create();
2286 @@ -1013,6 +1016,9 @@ static int tun_set_iff(struct net *net,
2288 sk->sk_destruct = tun_sock_destruct;
2290 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
2293 err = tun_attach(tun, file);
2296 @@ -1202,6 +1208,16 @@ static long __tun_chr_ioctl(struct file
2297 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
2301 + if (!capable(CAP_CONTEXT))
2304 + /* Set nid owner of the device */
2305 + tun->nid = (nid_t) arg;
2307 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
2311 /* Only allow setting the type when the interface is down */
2312 if (tun->dev->flags & IFF_UP) {
2313 diff -NurpP --minimal linux-2.6.33/fs/attr.c linux-2.6.33-vs2.3.0.36.30.1/fs/attr.c
2314 --- linux-2.6.33/fs/attr.c 2009-12-03 20:02:51.000000000 +0100
2315 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/attr.c 2010-02-25 12:02:16.000000000 +0100
2317 #include <linux/fcntl.h>
2318 #include <linux/quotaops.h>
2319 #include <linux/security.h>
2320 +#include <linux/proc_fs.h>
2321 +#include <linux/devpts_fs.h>
2322 +#include <linux/vs_tag.h>
2324 /* Taken over from the old code... */
2326 @@ -55,6 +58,10 @@ int inode_change_ok(const struct inode *
2327 if (!is_owner_or_cap(inode))
2331 + if (dx_permission(inode, MAY_WRITE))
2337 @@ -120,6 +127,8 @@ int inode_setattr(struct inode * inode,
2338 inode->i_uid = attr->ia_uid;
2339 if (ia_valid & ATTR_GID)
2340 inode->i_gid = attr->ia_gid;
2341 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2342 + inode->i_tag = attr->ia_tag;
2343 if (ia_valid & ATTR_ATIME)
2344 inode->i_atime = timespec_trunc(attr->ia_atime,
2345 inode->i_sb->s_time_gran);
2346 @@ -214,7 +223,8 @@ int notify_change(struct dentry * dentry
2347 error = inode_change_ok(inode, attr);
2349 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2350 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2351 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2352 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2353 error = vfs_dq_transfer(inode, attr) ?
2356 diff -NurpP --minimal linux-2.6.33/fs/binfmt_aout.c linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_aout.c
2357 --- linux-2.6.33/fs/binfmt_aout.c 2010-02-25 11:52:04.000000000 +0100
2358 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_aout.c 2010-02-25 12:02:16.000000000 +0100
2360 #include <linux/binfmts.h>
2361 #include <linux/personality.h>
2362 #include <linux/init.h>
2363 +#include <linux/vs_memory.h>
2365 #include <asm/system.h>
2366 #include <asm/uaccess.h>
2367 diff -NurpP --minimal linux-2.6.33/fs/binfmt_elf.c linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_elf.c
2368 --- linux-2.6.33/fs/binfmt_elf.c 2010-02-25 11:52:04.000000000 +0100
2369 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_elf.c 2010-02-25 12:02:16.000000000 +0100
2371 #include <linux/random.h>
2372 #include <linux/elf.h>
2373 #include <linux/utsname.h>
2374 +#include <linux/vs_memory.h>
2375 #include <asm/uaccess.h>
2376 #include <asm/param.h>
2377 #include <asm/page.h>
2378 diff -NurpP --minimal linux-2.6.33/fs/binfmt_flat.c linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_flat.c
2379 --- linux-2.6.33/fs/binfmt_flat.c 2010-02-25 11:52:04.000000000 +0100
2380 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_flat.c 2010-02-25 12:02:16.000000000 +0100
2382 #include <linux/init.h>
2383 #include <linux/flat.h>
2384 #include <linux/syscalls.h>
2385 +#include <linux/vs_memory.h>
2387 #include <asm/byteorder.h>
2388 #include <asm/system.h>
2389 diff -NurpP --minimal linux-2.6.33/fs/binfmt_som.c linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_som.c
2390 --- linux-2.6.33/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2391 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/binfmt_som.c 2010-02-25 12:02:16.000000000 +0100
2393 #include <linux/shm.h>
2394 #include <linux/personality.h>
2395 #include <linux/init.h>
2396 +#include <linux/vs_memory.h>
2398 #include <asm/uaccess.h>
2399 #include <asm/pgtable.h>
2400 diff -NurpP --minimal linux-2.6.33/fs/block_dev.c linux-2.6.33-vs2.3.0.36.30.1/fs/block_dev.c
2401 --- linux-2.6.33/fs/block_dev.c 2010-02-25 11:52:04.000000000 +0100
2402 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/block_dev.c 2010-02-25 12:02:16.000000000 +0100
2404 #include <linux/namei.h>
2405 #include <linux/log2.h>
2406 #include <linux/kmemleak.h>
2407 +#include <linux/vs_device.h>
2408 #include <asm/uaccess.h>
2409 #include "internal.h"
2411 @@ -566,6 +567,7 @@ struct block_device *bdget(dev_t dev)
2412 bdev->bd_invalidated = 0;
2413 inode->i_mode = S_IFBLK;
2414 inode->i_rdev = dev;
2415 + inode->i_mdev = dev;
2416 inode->i_bdev = bdev;
2417 inode->i_data.a_ops = &def_blk_aops;
2418 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2419 @@ -612,6 +614,11 @@ EXPORT_SYMBOL(bdput);
2420 static struct block_device *bd_acquire(struct inode *inode)
2422 struct block_device *bdev;
2425 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2427 + inode->i_mdev = mdev;
2429 spin_lock(&bdev_lock);
2430 bdev = inode->i_bdev;
2431 @@ -622,7 +629,7 @@ static struct block_device *bd_acquire(s
2433 spin_unlock(&bdev_lock);
2435 - bdev = bdget(inode->i_rdev);
2436 + bdev = bdget(mdev);
2438 spin_lock(&bdev_lock);
2439 if (!inode->i_bdev) {
2440 diff -NurpP --minimal linux-2.6.33/fs/btrfs/ctree.h linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/ctree.h
2441 --- linux-2.6.33/fs/btrfs/ctree.h 2010-02-25 11:52:04.000000000 +0100
2442 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/ctree.h 2010-02-25 12:02:16.000000000 +0100
2443 @@ -547,11 +547,14 @@ struct btrfs_inode_item {
2444 /* modification sequence number for NFS */
2449 * a little future expansion, for more than this we can
2450 * just grow the inode item and version it
2452 - __le64 reserved[4];
2453 + __le16 reserved16;
2454 + __le32 reserved32;
2455 + __le64 reserved[3];
2456 struct btrfs_timespec atime;
2457 struct btrfs_timespec ctime;
2458 struct btrfs_timespec mtime;
2459 @@ -1163,6 +1166,8 @@ struct btrfs_root {
2460 #define BTRFS_MOUNT_DISCARD (1 << 10)
2461 #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
2463 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2465 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2466 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2467 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2468 @@ -1182,6 +1187,10 @@ struct btrfs_root {
2469 #define BTRFS_INODE_NOATIME (1 << 9)
2470 #define BTRFS_INODE_DIRSYNC (1 << 10)
2472 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2473 +#define BTRFS_INODE_BARRIER (1 << 25)
2474 +#define BTRFS_INODE_COW (1 << 26)
2477 /* some macros to generate set/get funcs for the struct fields. This
2478 * assumes there is a lefoo_to_cpu for every type, so lets make a simple
2479 @@ -1384,6 +1393,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2480 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2481 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2482 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2483 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2484 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2485 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2486 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2487 @@ -2357,6 +2367,7 @@ extern const struct dentry_operations bt
2488 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2489 void btrfs_update_iflags(struct inode *inode);
2490 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2491 +int btrfs_sync_flags(struct inode *inode, int, int);
2494 int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
2495 diff -NurpP --minimal linux-2.6.33/fs/btrfs/disk-io.c linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/disk-io.c
2496 --- linux-2.6.33/fs/btrfs/disk-io.c 2010-02-25 11:52:04.000000000 +0100
2497 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/disk-io.c 2010-02-25 12:02:16.000000000 +0100
2498 @@ -1726,6 +1726,9 @@ struct btrfs_root *open_ctree(struct sup
2502 + if (btrfs_test_opt(tree_root, TAGGED))
2503 + sb->s_flags |= MS_TAGGED;
2505 features = btrfs_super_incompat_flags(disk_super) &
2506 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2508 diff -NurpP --minimal linux-2.6.33/fs/btrfs/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/inode.c
2509 --- linux-2.6.33/fs/btrfs/inode.c 2010-02-25 11:52:04.000000000 +0100
2510 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/inode.c 2010-02-25 12:02:16.000000000 +0100
2512 #include <linux/xattr.h>
2513 #include <linux/posix_acl.h>
2514 #include <linux/falloc.h>
2515 +#include <linux/vs_tag.h>
2519 #include "disk-io.h"
2520 @@ -2264,6 +2266,8 @@ static void btrfs_read_locked_inode(stru
2522 u64 alloc_group_block;
2528 path = btrfs_alloc_path();
2529 @@ -2280,8 +2284,13 @@ static void btrfs_read_locked_inode(stru
2531 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2532 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2533 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2534 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2536 + uid = btrfs_inode_uid(leaf, inode_item);
2537 + gid = btrfs_inode_gid(leaf, inode_item);
2538 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2539 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2540 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2541 + btrfs_inode_tag(leaf, inode_item));
2542 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2544 tspec = btrfs_inode_atime(inode_item);
2545 @@ -2363,8 +2372,15 @@ static void fill_inode_item(struct btrfs
2546 struct btrfs_inode_item *item,
2547 struct inode *inode)
2549 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2550 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2551 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2552 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2554 + btrfs_set_inode_uid(leaf, item, uid);
2555 + btrfs_set_inode_gid(leaf, item, gid);
2556 +#ifdef CONFIG_TAGGING_INTERN
2557 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2560 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2561 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2562 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2563 @@ -4154,6 +4170,7 @@ static struct inode *btrfs_new_inode(str
2565 inode->i_gid = current_fsgid();
2567 + inode->i_tag = dx_current_fstag(root->fs_info->sb);
2568 inode->i_mode = mode;
2569 inode->i_ino = objectid;
2570 inode_set_bytes(inode, 0);
2571 @@ -5955,6 +5972,7 @@ static const struct inode_operations btr
2572 .listxattr = btrfs_listxattr,
2573 .removexattr = btrfs_removexattr,
2574 .permission = btrfs_permission,
2575 + .sync_flags = btrfs_sync_flags,
2577 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2578 .lookup = btrfs_lookup,
2579 @@ -6030,6 +6048,7 @@ static const struct inode_operations btr
2580 .permission = btrfs_permission,
2581 .fallocate = btrfs_fallocate,
2582 .fiemap = btrfs_fiemap,
2583 + .sync_flags = btrfs_sync_flags,
2585 static const struct inode_operations btrfs_special_inode_operations = {
2586 .getattr = btrfs_getattr,
2587 diff -NurpP --minimal linux-2.6.33/fs/btrfs/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/ioctl.c
2588 --- linux-2.6.33/fs/btrfs/ioctl.c 2010-02-25 11:52:04.000000000 +0100
2589 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/ioctl.c 2010-02-25 12:02:16.000000000 +0100
2590 @@ -67,10 +67,13 @@ static unsigned int btrfs_flags_to_ioctl
2592 unsigned int iflags = 0;
2594 - if (flags & BTRFS_INODE_SYNC)
2595 - iflags |= FS_SYNC_FL;
2596 if (flags & BTRFS_INODE_IMMUTABLE)
2597 iflags |= FS_IMMUTABLE_FL;
2598 + if (flags & BTRFS_INODE_IXUNLINK)
2599 + iflags |= FS_IXUNLINK_FL;
2601 + if (flags & BTRFS_INODE_SYNC)
2602 + iflags |= FS_SYNC_FL;
2603 if (flags & BTRFS_INODE_APPEND)
2604 iflags |= FS_APPEND_FL;
2605 if (flags & BTRFS_INODE_NODUMP)
2606 @@ -80,28 +83,78 @@ static unsigned int btrfs_flags_to_ioctl
2607 if (flags & BTRFS_INODE_DIRSYNC)
2608 iflags |= FS_DIRSYNC_FL;
2610 + if (flags & BTRFS_INODE_BARRIER)
2611 + iflags |= FS_BARRIER_FL;
2612 + if (flags & BTRFS_INODE_COW)
2613 + iflags |= FS_COW_FL;
2618 - * Update inode->i_flags based on the btrfs internal flags.
2619 + * Update inode->i_(v)flags based on the btrfs internal flags.
2621 void btrfs_update_iflags(struct inode *inode)
2623 struct btrfs_inode *ip = BTRFS_I(inode);
2625 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2626 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2627 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2629 - if (ip->flags & BTRFS_INODE_SYNC)
2630 - inode->i_flags |= S_SYNC;
2631 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2632 inode->i_flags |= S_IMMUTABLE;
2633 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2634 + inode->i_flags |= S_IXUNLINK;
2636 + if (ip->flags & BTRFS_INODE_SYNC)
2637 + inode->i_flags |= S_SYNC;
2638 if (ip->flags & BTRFS_INODE_APPEND)
2639 inode->i_flags |= S_APPEND;
2640 if (ip->flags & BTRFS_INODE_NOATIME)
2641 inode->i_flags |= S_NOATIME;
2642 if (ip->flags & BTRFS_INODE_DIRSYNC)
2643 inode->i_flags |= S_DIRSYNC;
2645 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2647 + if (ip->flags & BTRFS_INODE_BARRIER)
2648 + inode->i_vflags |= V_BARRIER;
2649 + if (ip->flags & BTRFS_INODE_COW)
2650 + inode->i_vflags |= V_COW;
2654 + * Update btrfs internal flags from inode->i_(v)flags.
2656 +void btrfs_update_flags(struct inode *inode)
2658 + struct btrfs_inode *ip = BTRFS_I(inode);
2660 + unsigned int flags = inode->i_flags;
2661 + unsigned int vflags = inode->i_vflags;
2663 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2664 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2665 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2666 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2668 + if (flags & S_IMMUTABLE)
2669 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2670 + if (flags & S_IXUNLINK)
2671 + ip->flags |= BTRFS_INODE_IXUNLINK;
2673 + if (flags & S_SYNC)
2674 + ip->flags |= BTRFS_INODE_SYNC;
2675 + if (flags & S_APPEND)
2676 + ip->flags |= BTRFS_INODE_APPEND;
2677 + if (flags & S_NOATIME)
2678 + ip->flags |= BTRFS_INODE_NOATIME;
2679 + if (flags & S_DIRSYNC)
2680 + ip->flags |= BTRFS_INODE_DIRSYNC;
2682 + if (vflags & V_BARRIER)
2683 + ip->flags |= BTRFS_INODE_BARRIER;
2684 + if (vflags & V_COW)
2685 + ip->flags |= BTRFS_INODE_COW;
2689 @@ -119,7 +172,7 @@ void btrfs_inherit_iflags(struct inode *
2690 flags = BTRFS_I(dir)->flags;
2692 if (S_ISREG(inode->i_mode))
2693 - flags &= ~BTRFS_INODE_DIRSYNC;
2694 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2695 else if (!S_ISDIR(inode->i_mode))
2696 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2698 @@ -127,6 +180,30 @@ void btrfs_inherit_iflags(struct inode *
2699 btrfs_update_iflags(inode);
2702 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2704 + struct btrfs_inode *ip = BTRFS_I(inode);
2705 + struct btrfs_root *root = ip->root;
2706 + struct btrfs_trans_handle *trans;
2709 + trans = btrfs_join_transaction(root, 1);
2712 + inode->i_flags = flags;
2713 + inode->i_vflags = vflags;
2714 + btrfs_update_flags(inode);
2716 + ret = btrfs_update_inode(trans, root, inode);
2719 + btrfs_update_iflags(inode);
2720 + inode->i_ctime = CURRENT_TIME;
2721 + btrfs_end_transaction(trans, root);
2726 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2728 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2729 @@ -149,6 +226,7 @@ static int btrfs_ioctl_setflags(struct f
2730 if (copy_from_user(&flags, arg, sizeof(flags)))
2733 + /* maybe add FS_IXUNLINK_FL ? */
2734 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2735 FS_NOATIME_FL | FS_NODUMP_FL | \
2736 FS_SYNC_FL | FS_DIRSYNC_FL))
2737 @@ -161,7 +239,8 @@ static int btrfs_ioctl_setflags(struct f
2739 flags = btrfs_mask_flags(inode->i_mode, flags);
2740 oldflags = btrfs_flags_to_ioctl(ip->flags);
2741 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2742 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2743 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2744 if (!capable(CAP_LINUX_IMMUTABLE)) {
2747 @@ -172,14 +251,19 @@ static int btrfs_ioctl_setflags(struct f
2751 - if (flags & FS_SYNC_FL)
2752 - ip->flags |= BTRFS_INODE_SYNC;
2754 - ip->flags &= ~BTRFS_INODE_SYNC;
2755 if (flags & FS_IMMUTABLE_FL)
2756 ip->flags |= BTRFS_INODE_IMMUTABLE;
2758 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2759 + if (flags & FS_IXUNLINK_FL)
2760 + ip->flags |= BTRFS_INODE_IXUNLINK;
2762 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2764 + if (flags & FS_SYNC_FL)
2765 + ip->flags |= BTRFS_INODE_SYNC;
2767 + ip->flags &= ~BTRFS_INODE_SYNC;
2768 if (flags & FS_APPEND_FL)
2769 ip->flags |= BTRFS_INODE_APPEND;
2771 diff -NurpP --minimal linux-2.6.33/fs/btrfs/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/super.c
2772 --- linux-2.6.33/fs/btrfs/super.c 2010-02-25 11:52:04.000000000 +0100
2773 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/btrfs/super.c 2010-02-25 15:33:43.000000000 +0100
2774 @@ -68,7 +68,7 @@ enum {
2775 Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
2776 Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio,
2778 - Opt_discard, Opt_err,
2779 + Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
2782 static match_table_t tokens = {
2783 @@ -92,6 +92,9 @@ static match_table_t tokens = {
2784 {Opt_flushoncommit, "flushoncommit"},
2785 {Opt_ratio, "metadata_ratio=%d"},
2786 {Opt_discard, "discard"},
2788 + {Opt_notag, "notag"},
2789 + {Opt_tagid, "tagid=%u"},
2793 @@ -270,6 +273,22 @@ int btrfs_parse_options(struct btrfs_roo
2795 btrfs_set_opt(info->mount_opt, DISCARD);
2797 +#ifndef CONFIG_TAGGING_NONE
2799 + printk(KERN_INFO "btrfs: use tagging\n");
2800 + btrfs_set_opt(info->mount_opt, TAGGED);
2803 + printk(KERN_INFO "btrfs: disabled tagging\n");
2804 + btrfs_clear_opt(info->mount_opt, TAGGED);
2807 +#ifdef CONFIG_PROPAGATE
2810 + btrfs_set_opt(info->mount_opt, TAGGED);
2814 printk(KERN_INFO "btrfs: unrecognized mount option "
2816 @@ -591,6 +610,12 @@ static int btrfs_remount(struct super_bl
2820 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2821 + printk("btrfs: %s: tagging not permitted on remount.\n",
2826 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2829 diff -NurpP --minimal linux-2.6.33/fs/char_dev.c linux-2.6.33-vs2.3.0.36.30.1/fs/char_dev.c
2830 --- linux-2.6.33/fs/char_dev.c 2009-12-03 20:02:51.000000000 +0100
2831 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/char_dev.c 2010-02-25 12:02:16.000000000 +0100
2833 #include <linux/cdev.h>
2834 #include <linux/mutex.h>
2835 #include <linux/backing-dev.h>
2836 +#include <linux/vs_context.h>
2837 +#include <linux/vs_device.h>
2839 #include "internal.h"
2841 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
2843 struct cdev *new = NULL;
2847 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2849 + inode->i_mdev = mdev;
2851 spin_lock(&cdev_lock);
2854 struct kobject *kobj;
2857 spin_unlock(&cdev_lock);
2858 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2860 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2863 new = container_of(kobj, struct cdev, kobj);
2864 diff -NurpP --minimal linux-2.6.33/fs/dcache.c linux-2.6.33-vs2.3.0.36.30.1/fs/dcache.c
2865 --- linux-2.6.33/fs/dcache.c 2010-02-25 11:52:05.000000000 +0100
2866 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/dcache.c 2010-02-25 12:02:16.000000000 +0100
2868 #include <linux/bootmem.h>
2869 #include <linux/fs_struct.h>
2870 #include <linux/hardirq.h>
2871 +#include <linux/vs_limit.h>
2872 #include "internal.h"
2874 int sysctl_vfs_cache_pressure __read_mostly = 100;
2875 @@ -230,6 +231,8 @@ repeat:
2879 + vx_dentry_dec(dentry);
2882 * AV: ->d_delete() is _NOT_ allowed to block now.
2884 @@ -321,6 +324,7 @@ static inline struct dentry * __dget_loc
2886 atomic_inc(&dentry->d_count);
2887 dentry_lru_del_init(dentry);
2888 + vx_dentry_inc(dentry);
2892 @@ -919,6 +923,9 @@ struct dentry *d_alloc(struct dentry * p
2893 struct dentry *dentry;
2896 + if (!vx_dentry_avail(1))
2899 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2902 @@ -964,6 +971,7 @@ struct dentry *d_alloc(struct dentry * p
2904 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2905 dentry_stat.nr_dentry++;
2906 + vx_dentry_inc(dentry);
2907 spin_unlock(&dcache_lock);
2910 @@ -1408,6 +1416,7 @@ struct dentry * __d_lookup(struct dentry
2913 atomic_inc(&dentry->d_count);
2914 + vx_dentry_inc(dentry);
2916 spin_unlock(&dentry->d_lock);
2918 diff -NurpP --minimal linux-2.6.33/fs/devpts/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/devpts/inode.c
2919 --- linux-2.6.33/fs/devpts/inode.c 2010-02-25 11:52:05.000000000 +0100
2920 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/devpts/inode.c 2010-02-25 12:02:16.000000000 +0100
2922 #include <linux/parser.h>
2923 #include <linux/fsnotify.h>
2924 #include <linux/seq_file.h>
2925 +#include <linux/vs_base.h>
2927 #define DEVPTS_DEFAULT_MODE 0600
2930 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2931 #define PTMX_MINOR 2
2933 +static int devpts_permission(struct inode *inode, int mask)
2935 + int ret = -EACCES;
2937 + /* devpts is xid tagged */
2938 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2939 + ret = generic_permission(inode, mask, NULL);
2943 +static struct inode_operations devpts_file_inode_operations = {
2944 + .permission = devpts_permission,
2947 extern int pty_limit; /* Config limit on Unix98 ptys */
2948 static DEFINE_MUTEX(allocated_ptys_lock);
2950 @@ -262,6 +277,25 @@ static int devpts_show_options(struct se
2954 +static int devpts_filter(struct dentry *de)
2956 + /* devpts is xid tagged */
2957 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2960 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2962 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2965 +static struct file_operations devpts_dir_operations = {
2966 + .open = dcache_dir_open,
2967 + .release = dcache_dir_close,
2968 + .llseek = dcache_dir_lseek,
2969 + .read = generic_read_dir,
2970 + .readdir = devpts_readdir,
2973 static const struct super_operations devpts_sops = {
2974 .statfs = simple_statfs,
2975 .remount_fs = devpts_remount,
2976 @@ -301,12 +335,15 @@ devpts_fill_super(struct super_block *s,
2977 inode = new_inode(s);
2982 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2983 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2984 inode->i_op = &simple_dir_inode_operations;
2985 - inode->i_fop = &simple_dir_operations;
2986 + inode->i_fop = &devpts_dir_operations;
2988 + /* devpts is xid tagged */
2989 + inode->i_tag = (tag_t)vx_current_xid();
2991 s->s_root = d_alloc_root(inode);
2993 @@ -497,6 +534,9 @@ int devpts_pty_new(struct inode *ptmx_in
2994 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2995 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2996 init_special_inode(inode, S_IFCHR|opts->mode, device);
2997 + /* devpts is xid tagged */
2998 + inode->i_tag = (tag_t)vx_current_xid();
2999 + inode->i_op = &devpts_file_inode_operations;
3000 inode->i_private = tty;
3001 tty->driver_data = inode;
3003 diff -NurpP --minimal linux-2.6.33/fs/exec.c linux-2.6.33-vs2.3.0.36.30.1/fs/exec.c
3004 --- linux-2.6.33/fs/exec.c 2010-02-25 11:52:05.000000000 +0100
3005 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/exec.c 2010-02-25 12:02:16.000000000 +0100
3006 @@ -250,7 +250,9 @@ static int __bprm_mm_init(struct linux_b
3010 - mm->stack_vm = mm->total_vm = 1;
3012 + vx_vmpages_inc(mm);
3014 up_write(&mm->mmap_sem);
3015 bprm->p = vma->vm_end - sizeof(void *);
3017 @@ -1503,7 +1505,7 @@ static int format_corename(char *corenam
3018 /* UNIX time of coredump */
3021 - do_gettimeofday(&tv);
3022 + vx_gettimeofday(&tv);
3023 rc = snprintf(out_ptr, out_end - out_ptr,
3025 if (rc > out_end - out_ptr)
3026 diff -NurpP --minimal linux-2.6.33/fs/ext2/balloc.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/balloc.c
3027 --- linux-2.6.33/fs/ext2/balloc.c 2009-06-11 17:13:03.000000000 +0200
3028 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/balloc.c 2010-02-25 12:02:16.000000000 +0100
3029 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
3031 end = EXT2_BLOCKS_PER_GROUP(sb);
3034 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
3037 diff -NurpP --minimal linux-2.6.33/fs/ext2/ext2.h linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/ext2.h
3038 --- linux-2.6.33/fs/ext2/ext2.h 2010-02-25 11:52:05.000000000 +0100
3039 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/ext2.h 2010-02-25 12:02:16.000000000 +0100
3040 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
3041 int __ext2_write_begin(struct file *file, struct address_space *mapping,
3042 loff_t pos, unsigned len, unsigned flags,
3043 struct page **pagep, void **fsdata);
3044 +extern int ext2_sync_flags(struct inode *, int, int);
3047 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
3048 diff -NurpP --minimal linux-2.6.33/fs/ext2/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/file.c
3049 --- linux-2.6.33/fs/ext2/file.c 2010-02-25 11:52:05.000000000 +0100
3050 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/file.c 2010-02-25 12:02:16.000000000 +0100
3051 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
3052 .setattr = ext2_setattr,
3053 .check_acl = ext2_check_acl,
3054 .fiemap = ext2_fiemap,
3055 + .sync_flags = ext2_sync_flags,
3057 diff -NurpP --minimal linux-2.6.33/fs/ext2/ialloc.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/ialloc.c
3058 --- linux-2.6.33/fs/ext2/ialloc.c 2009-06-11 17:13:03.000000000 +0200
3059 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/ialloc.c 2010-02-25 12:02:16.000000000 +0100
3061 #include <linux/backing-dev.h>
3062 #include <linux/buffer_head.h>
3063 #include <linux/random.h>
3064 +#include <linux/vs_tag.h>
3068 @@ -560,6 +561,7 @@ got:
3070 inode->i_gid = current_fsgid();
3071 inode->i_mode = mode;
3072 + inode->i_tag = dx_current_fstag(sb);
3075 inode->i_blocks = 0;
3076 diff -NurpP --minimal linux-2.6.33/fs/ext2/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/inode.c
3077 --- linux-2.6.33/fs/ext2/inode.c 2010-02-25 11:52:05.000000000 +0100
3078 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/inode.c 2010-02-25 12:02:16.000000000 +0100
3080 #include <linux/mpage.h>
3081 #include <linux/fiemap.h>
3082 #include <linux/namei.h>
3083 +#include <linux/vs_tag.h>
3087 @@ -1042,7 +1043,7 @@ void ext2_truncate(struct inode *inode)
3089 if (ext2_inode_is_fast_symlink(inode))
3091 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3092 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3095 blocksize = inode->i_sb->s_blocksize;
3096 @@ -1180,36 +1181,61 @@ void ext2_set_inode_flags(struct inode *
3098 unsigned int flags = EXT2_I(inode)->i_flags;
3100 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3101 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3102 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3105 + if (flags & EXT2_IMMUTABLE_FL)
3106 + inode->i_flags |= S_IMMUTABLE;
3107 + if (flags & EXT2_IXUNLINK_FL)
3108 + inode->i_flags |= S_IXUNLINK;
3110 if (flags & EXT2_SYNC_FL)
3111 inode->i_flags |= S_SYNC;
3112 if (flags & EXT2_APPEND_FL)
3113 inode->i_flags |= S_APPEND;
3114 - if (flags & EXT2_IMMUTABLE_FL)
3115 - inode->i_flags |= S_IMMUTABLE;
3116 if (flags & EXT2_NOATIME_FL)
3117 inode->i_flags |= S_NOATIME;
3118 if (flags & EXT2_DIRSYNC_FL)
3119 inode->i_flags |= S_DIRSYNC;
3121 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3123 + if (flags & EXT2_BARRIER_FL)
3124 + inode->i_vflags |= V_BARRIER;
3125 + if (flags & EXT2_COW_FL)
3126 + inode->i_vflags |= V_COW;
3129 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
3130 void ext2_get_inode_flags(struct ext2_inode_info *ei)
3132 unsigned int flags = ei->vfs_inode.i_flags;
3133 + unsigned int vflags = ei->vfs_inode.i_vflags;
3135 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
3136 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
3137 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
3138 + EXT2_BARRIER_FL | EXT2_COW_FL);
3140 + if (flags & S_IMMUTABLE)
3141 + ei->i_flags |= EXT2_IMMUTABLE_FL;
3142 + if (flags & S_IXUNLINK)
3143 + ei->i_flags |= EXT2_IXUNLINK_FL;
3145 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
3146 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
3148 ei->i_flags |= EXT2_SYNC_FL;
3149 if (flags & S_APPEND)
3150 ei->i_flags |= EXT2_APPEND_FL;
3151 - if (flags & S_IMMUTABLE)
3152 - ei->i_flags |= EXT2_IMMUTABLE_FL;
3153 if (flags & S_NOATIME)
3154 ei->i_flags |= EXT2_NOATIME_FL;
3155 if (flags & S_DIRSYNC)
3156 ei->i_flags |= EXT2_DIRSYNC_FL;
3158 + if (vflags & V_BARRIER)
3159 + ei->i_flags |= EXT2_BARRIER_FL;
3160 + if (vflags & V_COW)
3161 + ei->i_flags |= EXT2_COW_FL;
3164 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
3165 @@ -1219,6 +1245,8 @@ struct inode *ext2_iget (struct super_bl
3166 struct ext2_inode *raw_inode;
3167 struct inode *inode;
3173 inode = iget_locked(sb, ino);
3174 @@ -1237,12 +1265,17 @@ struct inode *ext2_iget (struct super_bl
3177 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3178 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3179 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3180 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3181 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3182 if (!(test_opt (inode->i_sb, NO_UID32))) {
3183 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3184 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3185 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3186 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3188 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3189 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3190 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3191 + le16_to_cpu(raw_inode->i_raw_tag));
3193 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3194 inode->i_size = le32_to_cpu(raw_inode->i_size);
3195 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3196 @@ -1340,8 +1373,8 @@ int ext2_write_inode(struct inode *inode
3197 struct ext2_inode_info *ei = EXT2_I(inode);
3198 struct super_block *sb = inode->i_sb;
3199 ino_t ino = inode->i_ino;
3200 - uid_t uid = inode->i_uid;
3201 - gid_t gid = inode->i_gid;
3202 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3203 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3204 struct buffer_head * bh;
3205 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
3207 @@ -1377,6 +1410,9 @@ int ext2_write_inode(struct inode *inode
3208 raw_inode->i_uid_high = 0;
3209 raw_inode->i_gid_high = 0;
3211 +#ifdef CONFIG_TAGGING_INTERN
3212 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3214 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3215 raw_inode->i_size = cpu_to_le32(inode->i_size);
3216 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3217 @@ -1458,7 +1494,8 @@ int ext2_setattr(struct dentry *dentry,
3220 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3221 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3222 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3223 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3224 error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
3227 diff -NurpP --minimal linux-2.6.33/fs/ext2/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/ioctl.c
3228 --- linux-2.6.33/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
3229 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/ioctl.c 2010-02-25 12:02:16.000000000 +0100
3231 #include <asm/uaccess.h>
3234 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
3236 + inode->i_flags = flags;
3237 + inode->i_vflags = vflags;
3238 + ext2_get_inode_flags(EXT2_I(inode));
3239 + inode->i_ctime = CURRENT_TIME_SEC;
3240 + mark_inode_dirty(inode);
3244 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3246 struct inode *inode = filp->f_dentry->d_inode;
3247 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
3249 flags = ext2_mask_flags(inode->i_mode, flags);
3251 + if (IS_BARRIER(inode)) {
3252 + vxwprintk_task(1, "messing with the barrier.");
3256 mutex_lock(&inode->i_mutex);
3257 /* Is it quota file? Do not allow user to mess with it */
3258 if (IS_NOQUOTA(inode)) {
3259 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
3261 * This test looks nicer. Thanks to Pauline Middelink
3263 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3264 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3265 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3266 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
3267 if (!capable(CAP_LINUX_IMMUTABLE)) {
3268 mutex_unlock(&inode->i_mutex);
3270 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
3274 - flags = flags & EXT2_FL_USER_MODIFIABLE;
3275 + flags &= EXT2_FL_USER_MODIFIABLE;
3276 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
3277 ei->i_flags = flags;
3278 mutex_unlock(&inode->i_mutex);
3279 diff -NurpP --minimal linux-2.6.33/fs/ext2/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/namei.c
3280 --- linux-2.6.33/fs/ext2/namei.c 2009-12-03 20:02:51.000000000 +0100
3281 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/namei.c 2010-02-25 12:02:16.000000000 +0100
3285 #include <linux/pagemap.h>
3286 +#include <linux/vs_tag.h>
3290 @@ -74,6 +75,7 @@ static struct dentry *ext2_lookup(struct
3291 return ERR_PTR(-EIO);
3293 return ERR_CAST(inode);
3294 + dx_propagate_tag(nd, inode);
3298 @@ -401,6 +403,7 @@ const struct inode_operations ext2_dir_i
3300 .setattr = ext2_setattr,
3301 .check_acl = ext2_check_acl,
3302 + .sync_flags = ext2_sync_flags,
3305 const struct inode_operations ext2_special_inode_operations = {
3306 diff -NurpP --minimal linux-2.6.33/fs/ext2/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/super.c
3307 --- linux-2.6.33/fs/ext2/super.c 2010-02-25 11:52:05.000000000 +0100
3308 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext2/super.c 2010-02-25 12:02:16.000000000 +0100
3309 @@ -382,7 +382,8 @@ enum {
3310 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3311 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3312 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3313 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3314 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3315 + Opt_tag, Opt_notag, Opt_tagid
3318 static const match_table_t tokens = {
3319 @@ -410,6 +411,9 @@ static const match_table_t tokens = {
3321 {Opt_noacl, "noacl"},
3324 + {Opt_notag, "notag"},
3325 + {Opt_tagid, "tagid=%u"},
3326 {Opt_grpquota, "grpquota"},
3327 {Opt_ignore, "noquota"},
3328 {Opt_quota, "quota"},
3329 @@ -480,6 +484,20 @@ static int parse_options(char *options,
3331 set_opt (sbi->s_mount_opt, NO_UID32);
3333 +#ifndef CONFIG_TAGGING_NONE
3335 + set_opt (sbi->s_mount_opt, TAGGED);
3338 + clear_opt (sbi->s_mount_opt, TAGGED);
3341 +#ifdef CONFIG_PROPAGATE
3344 + set_opt (sbi->s_mount_opt, TAGGED);
3348 clear_opt (sbi->s_mount_opt, CHECK);
3350 @@ -836,6 +854,8 @@ static int ext2_fill_super(struct super_
3351 if (!parse_options((char *) data, sb))
3354 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3355 + sb->s_flags |= MS_TAGGED;
3356 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3357 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3359 @@ -1229,6 +1249,14 @@ static int ext2_remount (struct super_bl
3363 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3364 + !(sb->s_flags & MS_TAGGED)) {
3365 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3368 + goto restore_opts;
3371 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3372 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3374 diff -NurpP --minimal linux-2.6.33/fs/ext3/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/file.c
3375 --- linux-2.6.33/fs/ext3/file.c 2009-12-03 20:02:51.000000000 +0100
3376 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/file.c 2010-02-25 12:02:16.000000000 +0100
3377 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
3379 .check_acl = ext3_check_acl,
3380 .fiemap = ext3_fiemap,
3381 + .sync_flags = ext3_sync_flags,
3384 diff -NurpP --minimal linux-2.6.33/fs/ext3/ialloc.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/ialloc.c
3385 --- linux-2.6.33/fs/ext3/ialloc.c 2009-09-10 15:26:21.000000000 +0200
3386 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/ialloc.c 2010-02-25 12:02:16.000000000 +0100
3388 #include <linux/buffer_head.h>
3389 #include <linux/random.h>
3390 #include <linux/bitops.h>
3391 +#include <linux/vs_tag.h>
3393 #include <asm/byteorder.h>
3395 @@ -548,6 +549,7 @@ got:
3397 inode->i_gid = current_fsgid();
3398 inode->i_mode = mode;
3399 + inode->i_tag = dx_current_fstag(sb);
3402 /* This is the optimal IO size (for stat), not the fs block size */
3403 diff -NurpP --minimal linux-2.6.33/fs/ext3/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/inode.c
3404 --- linux-2.6.33/fs/ext3/inode.c 2010-02-25 11:52:05.000000000 +0100
3405 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/inode.c 2010-02-25 12:02:16.000000000 +0100
3407 #include <linux/bio.h>
3408 #include <linux/fiemap.h>
3409 #include <linux/namei.h>
3410 +#include <linux/vs_tag.h>
3414 @@ -2343,7 +2344,7 @@ static void ext3_free_branches(handle_t
3416 int ext3_can_truncate(struct inode *inode)
3418 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3419 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3421 if (S_ISREG(inode->i_mode))
3423 @@ -2728,36 +2729,60 @@ void ext3_set_inode_flags(struct inode *
3425 unsigned int flags = EXT3_I(inode)->i_flags;
3427 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3428 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3429 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3431 + if (flags & EXT3_IMMUTABLE_FL)
3432 + inode->i_flags |= S_IMMUTABLE;
3433 + if (flags & EXT3_IXUNLINK_FL)
3434 + inode->i_flags |= S_IXUNLINK;
3436 if (flags & EXT3_SYNC_FL)
3437 inode->i_flags |= S_SYNC;
3438 if (flags & EXT3_APPEND_FL)
3439 inode->i_flags |= S_APPEND;
3440 - if (flags & EXT3_IMMUTABLE_FL)
3441 - inode->i_flags |= S_IMMUTABLE;
3442 if (flags & EXT3_NOATIME_FL)
3443 inode->i_flags |= S_NOATIME;
3444 if (flags & EXT3_DIRSYNC_FL)
3445 inode->i_flags |= S_DIRSYNC;
3447 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3449 + if (flags & EXT3_BARRIER_FL)
3450 + inode->i_vflags |= V_BARRIER;
3451 + if (flags & EXT3_COW_FL)
3452 + inode->i_vflags |= V_COW;
3455 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3456 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3458 unsigned int flags = ei->vfs_inode.i_flags;
3459 + unsigned int vflags = ei->vfs_inode.i_vflags;
3461 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3462 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3463 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3464 + EXT3_BARRIER_FL | EXT3_COW_FL);
3466 + if (flags & S_IMMUTABLE)
3467 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3468 + if (flags & S_IXUNLINK)
3469 + ei->i_flags |= EXT3_IXUNLINK_FL;
3471 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3472 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3474 ei->i_flags |= EXT3_SYNC_FL;
3475 if (flags & S_APPEND)
3476 ei->i_flags |= EXT3_APPEND_FL;
3477 - if (flags & S_IMMUTABLE)
3478 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3479 if (flags & S_NOATIME)
3480 ei->i_flags |= EXT3_NOATIME_FL;
3481 if (flags & S_DIRSYNC)
3482 ei->i_flags |= EXT3_DIRSYNC_FL;
3484 + if (vflags & V_BARRIER)
3485 + ei->i_flags |= EXT3_BARRIER_FL;
3486 + if (vflags & V_COW)
3487 + ei->i_flags |= EXT3_COW_FL;
3490 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3491 @@ -2771,6 +2796,8 @@ struct inode *ext3_iget(struct super_blo
3492 transaction_t *transaction;
3498 inode = iget_locked(sb, ino);
3500 @@ -2787,12 +2814,17 @@ struct inode *ext3_iget(struct super_blo
3502 raw_inode = ext3_raw_inode(&iloc);
3503 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3504 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3505 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3506 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3507 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3508 if(!(test_opt (inode->i_sb, NO_UID32))) {
3509 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3510 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3511 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3512 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3514 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3515 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3516 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3517 + le16_to_cpu(raw_inode->i_raw_tag));
3519 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3520 inode->i_size = le32_to_cpu(raw_inode->i_size);
3521 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3522 @@ -2947,6 +2979,8 @@ static int ext3_do_update_inode(handle_t
3523 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3524 struct ext3_inode_info *ei = EXT3_I(inode);
3525 struct buffer_head *bh = iloc->bh;
3526 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3527 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3528 int err = 0, rc, block;
3531 @@ -2961,29 +2995,32 @@ again:
3532 ext3_get_inode_flags(ei);
3533 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3534 if(!(test_opt(inode->i_sb, NO_UID32))) {
3535 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3536 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3537 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3538 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3540 * Fix up interoperability with old kernels. Otherwise, old inodes get
3541 * re-used with the upper 16 bits of the uid/gid intact
3544 raw_inode->i_uid_high =
3545 - cpu_to_le16(high_16_bits(inode->i_uid));
3546 + cpu_to_le16(high_16_bits(uid));
3547 raw_inode->i_gid_high =
3548 - cpu_to_le16(high_16_bits(inode->i_gid));
3549 + cpu_to_le16(high_16_bits(gid));
3551 raw_inode->i_uid_high = 0;
3552 raw_inode->i_gid_high = 0;
3555 raw_inode->i_uid_low =
3556 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3557 + cpu_to_le16(fs_high2lowuid(uid));
3558 raw_inode->i_gid_low =
3559 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3560 + cpu_to_le16(fs_high2lowgid(gid));
3561 raw_inode->i_uid_high = 0;
3562 raw_inode->i_gid_high = 0;
3564 +#ifdef CONFIG_TAGGING_INTERN
3565 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3567 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3568 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3569 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3570 @@ -3141,7 +3178,8 @@ int ext3_setattr(struct dentry *dentry,
3573 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3574 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3575 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3576 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3579 /* (user+group)*(old+new) structure, inode write (sb,
3580 @@ -3163,6 +3201,8 @@ int ext3_setattr(struct dentry *dentry,
3581 inode->i_uid = attr->ia_uid;
3582 if (attr->ia_valid & ATTR_GID)
3583 inode->i_gid = attr->ia_gid;
3584 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3585 + inode->i_tag = attr->ia_tag;
3586 error = ext3_mark_inode_dirty(handle, inode);
3587 ext3_journal_stop(handle);
3589 diff -NurpP --minimal linux-2.6.33/fs/ext3/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/ioctl.c
3590 --- linux-2.6.33/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3591 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/ioctl.c 2010-02-25 12:02:16.000000000 +0100
3595 #include <linux/fs.h>
3596 +#include <linux/mount.h>
3597 #include <linux/jbd.h>
3598 #include <linux/capability.h>
3599 #include <linux/ext3_fs.h>
3601 #include <linux/compat.h>
3602 #include <asm/uaccess.h>
3605 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3607 + handle_t *handle = NULL;
3608 + struct ext3_iloc iloc;
3611 + handle = ext3_journal_start(inode, 1);
3612 + if (IS_ERR(handle))
3613 + return PTR_ERR(handle);
3615 + if (IS_SYNC(inode))
3616 + handle->h_sync = 1;
3617 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3621 + inode->i_flags = flags;
3622 + inode->i_vflags = vflags;
3623 + ext3_get_inode_flags(EXT3_I(inode));
3624 + inode->i_ctime = CURRENT_TIME_SEC;
3626 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3628 + ext3_journal_stop(handle);
3632 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3634 struct inode *inode = filp->f_dentry->d_inode;
3635 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3637 flags = ext3_mask_flags(inode->i_mode, flags);
3639 + if (IS_BARRIER(inode)) {
3640 + vxwprintk_task(1, "messing with the barrier.");
3644 mutex_lock(&inode->i_mutex);
3646 /* Is it quota file? Do not allow user to mess with it */
3647 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3649 * This test looks nicer. Thanks to Pauline Middelink
3651 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3652 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3653 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3654 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3655 if (!capable(CAP_LINUX_IMMUTABLE))
3658 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3662 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3663 + flags &= EXT3_FL_USER_MODIFIABLE;
3664 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3665 ei->i_flags = flags;
3667 diff -NurpP --minimal linux-2.6.33/fs/ext3/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/namei.c
3668 --- linux-2.6.33/fs/ext3/namei.c 2010-02-25 11:52:05.000000000 +0100
3669 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/namei.c 2010-02-25 12:02:16.000000000 +0100
3671 #include <linux/quotaops.h>
3672 #include <linux/buffer_head.h>
3673 #include <linux/bio.h>
3674 +#include <linux/vs_tag.h>
3678 @@ -912,6 +913,7 @@ restart:
3680 ll_rw_block(READ_META, 1, &bh);
3682 + dx_propagate_tag(nd, inode);
3684 if ((bh = bh_use[ra_ptr++]) == NULL)
3686 @@ -2448,6 +2450,7 @@ const struct inode_operations ext3_dir_i
3687 .removexattr = generic_removexattr,
3689 .check_acl = ext3_check_acl,
3690 + .sync_flags = ext3_sync_flags,
3693 const struct inode_operations ext3_special_inode_operations = {
3694 diff -NurpP --minimal linux-2.6.33/fs/ext3/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/super.c
3695 --- linux-2.6.33/fs/ext3/super.c 2010-02-25 11:52:05.000000000 +0100
3696 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext3/super.c 2010-02-25 13:29:21.000000000 +0100
3697 @@ -817,7 +817,7 @@ enum {
3698 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3699 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3700 Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
3701 - Opt_usrquota, Opt_grpquota
3702 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3705 static const match_table_t tokens = {
3706 @@ -872,6 +872,9 @@ static const match_table_t tokens = {
3707 {Opt_usrquota, "usrquota"},
3708 {Opt_barrier, "barrier=%u"},
3709 {Opt_resize, "resize"},
3711 + {Opt_notag, "notag"},
3712 + {Opt_tagid, "tagid=%u"},
3716 @@ -964,6 +967,20 @@ static int parse_options (char *options,
3718 set_opt (sbi->s_mount_opt, NO_UID32);
3720 +#ifndef CONFIG_TAGGING_NONE
3722 + set_opt (sbi->s_mount_opt, TAGGED);
3725 + clear_opt (sbi->s_mount_opt, TAGGED);
3728 +#ifdef CONFIG_PROPAGATE
3731 + set_opt (sbi->s_mount_opt, TAGGED);
3735 clear_opt (sbi->s_mount_opt, CHECK);
3737 @@ -1693,6 +1710,9 @@ static int ext3_fill_super (struct super
3741 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3742 + sb->s_flags |= MS_TAGGED;
3744 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3745 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3747 @@ -2564,6 +2584,14 @@ static int ext3_remount (struct super_bl
3748 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3749 ext3_abort(sb, __func__, "Abort forced by user");
3751 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3752 + !(sb->s_flags & MS_TAGGED)) {
3753 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3756 + goto restore_opts;
3759 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3760 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3762 diff -NurpP --minimal linux-2.6.33/fs/ext4/ext4.h linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/ext4.h
3763 --- linux-2.6.33/fs/ext4/ext4.h 2010-02-25 11:52:05.000000000 +0100
3764 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/ext4.h 2010-02-25 12:02:16.000000000 +0100
3765 @@ -284,8 +284,12 @@ struct flex_groups {
3766 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
3767 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3768 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3769 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3770 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3772 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3773 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3775 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3776 #define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
3778 @@ -472,7 +476,8 @@ struct ext4_inode {
3779 __le16 l_i_file_acl_high;
3780 __le16 l_i_uid_high; /* these 2 fields */
3781 __le16 l_i_gid_high; /* were reserved2[0] */
3782 - __u32 l_i_reserved2;
3783 + __le16 l_i_tag; /* Context Tag */
3784 + __u16 l_i_reserved2;
3787 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3788 @@ -586,6 +591,7 @@ do { \
3789 #define i_gid_low i_gid
3790 #define i_uid_high osd2.linux2.l_i_uid_high
3791 #define i_gid_high osd2.linux2.l_i_gid_high
3792 +#define i_raw_tag osd2.linux2.l_i_tag
3793 #define i_reserved2 osd2.linux2.l_i_reserved2
3795 #elif defined(__GNU__)
3796 @@ -760,6 +766,7 @@ struct ext4_inode_info {
3797 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3798 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3799 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3800 +#define EXT4_MOUNT_TAGGED 0x400000 /* Enable Context Tags */
3801 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
3802 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
3803 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3804 @@ -1750,6 +1757,7 @@ extern int ext4_get_blocks(handle_t *han
3805 struct buffer_head *bh, int flags);
3806 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3807 __u64 start, __u64 len);
3808 +extern int ext4_sync_flags(struct inode *, int, int);
3810 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3811 __u64 start_orig, __u64 start_donor,
3812 diff -NurpP --minimal linux-2.6.33/fs/ext4/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/file.c
3813 --- linux-2.6.33/fs/ext4/file.c 2009-12-03 20:02:51.000000000 +0100
3814 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/file.c 2010-02-25 12:02:16.000000000 +0100
3815 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
3816 .check_acl = ext4_check_acl,
3817 .fallocate = ext4_fallocate,
3818 .fiemap = ext4_fiemap,
3819 + .sync_flags = ext4_sync_flags,
3822 diff -NurpP --minimal linux-2.6.33/fs/ext4/ialloc.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/ialloc.c
3823 --- linux-2.6.33/fs/ext4/ialloc.c 2009-12-03 20:02:51.000000000 +0100
3824 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/ialloc.c 2010-02-25 12:02:16.000000000 +0100
3826 #include <linux/random.h>
3827 #include <linux/bitops.h>
3828 #include <linux/blkdev.h>
3829 +#include <linux/vs_tag.h>
3830 #include <asm/byteorder.h>
3833 @@ -995,6 +996,7 @@ got:
3835 inode->i_gid = current_fsgid();
3836 inode->i_mode = mode;
3837 + inode->i_tag = dx_current_fstag(sb);
3839 inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
3840 /* This is the optimal IO size (for stat), not the fs block size */
3841 diff -NurpP --minimal linux-2.6.33/fs/ext4/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/inode.c
3842 --- linux-2.6.33/fs/ext4/inode.c 2010-02-25 11:52:05.000000000 +0100
3843 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/inode.c 2010-02-25 12:02:16.000000000 +0100
3845 #include <linux/uio.h>
3846 #include <linux/bio.h>
3847 #include <linux/workqueue.h>
3848 +#include <linux/vs_tag.h>
3850 #include "ext4_jbd2.h"
3852 @@ -4376,7 +4377,7 @@ static void ext4_free_branches(handle_t
3854 int ext4_can_truncate(struct inode *inode)
3856 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3857 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3859 if (S_ISREG(inode->i_mode))
3861 @@ -4727,36 +4728,60 @@ void ext4_set_inode_flags(struct inode *
3863 unsigned int flags = EXT4_I(inode)->i_flags;
3865 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3866 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3867 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3869 + if (flags & EXT4_IMMUTABLE_FL)
3870 + inode->i_flags |= S_IMMUTABLE;
3871 + if (flags & EXT4_IXUNLINK_FL)
3872 + inode->i_flags |= S_IXUNLINK;
3874 if (flags & EXT4_SYNC_FL)
3875 inode->i_flags |= S_SYNC;
3876 if (flags & EXT4_APPEND_FL)
3877 inode->i_flags |= S_APPEND;
3878 - if (flags & EXT4_IMMUTABLE_FL)
3879 - inode->i_flags |= S_IMMUTABLE;
3880 if (flags & EXT4_NOATIME_FL)
3881 inode->i_flags |= S_NOATIME;
3882 if (flags & EXT4_DIRSYNC_FL)
3883 inode->i_flags |= S_DIRSYNC;
3885 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3887 + if (flags & EXT4_BARRIER_FL)
3888 + inode->i_vflags |= V_BARRIER;
3889 + if (flags & EXT4_COW_FL)
3890 + inode->i_vflags |= V_COW;
3893 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3894 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3896 unsigned int flags = ei->vfs_inode.i_flags;
3897 + unsigned int vflags = ei->vfs_inode.i_vflags;
3899 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3900 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3901 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3902 + EXT4_BARRIER_FL | EXT4_COW_FL);
3904 + if (flags & S_IMMUTABLE)
3905 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3906 + if (flags & S_IXUNLINK)
3907 + ei->i_flags |= EXT4_IXUNLINK_FL;
3909 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3910 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3912 ei->i_flags |= EXT4_SYNC_FL;
3913 if (flags & S_APPEND)
3914 ei->i_flags |= EXT4_APPEND_FL;
3915 - if (flags & S_IMMUTABLE)
3916 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3917 if (flags & S_NOATIME)
3918 ei->i_flags |= EXT4_NOATIME_FL;
3919 if (flags & S_DIRSYNC)
3920 ei->i_flags |= EXT4_DIRSYNC_FL;
3922 + if (vflags & V_BARRIER)
3923 + ei->i_flags |= EXT4_BARRIER_FL;
3924 + if (vflags & V_COW)
3925 + ei->i_flags |= EXT4_COW_FL;
3928 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3929 @@ -4791,6 +4816,8 @@ struct inode *ext4_iget(struct super_blo
3930 journal_t *journal = EXT4_SB(sb)->s_journal;
3936 inode = iget_locked(sb, ino);
3938 @@ -4806,12 +4833,16 @@ struct inode *ext4_iget(struct super_blo
3940 raw_inode = ext4_raw_inode(&iloc);
3941 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3942 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3943 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3944 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3945 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3946 if (!(test_opt(inode->i_sb, NO_UID32))) {
3947 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3948 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3949 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3950 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3952 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3953 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3954 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3955 + le16_to_cpu(raw_inode->i_raw_tag));
3956 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3959 @@ -5033,6 +5064,8 @@ static int ext4_do_update_inode(handle_t
3960 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3961 struct ext4_inode_info *ei = EXT4_I(inode);
3962 struct buffer_head *bh = iloc->bh;
3963 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3964 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3965 int err = 0, rc, block;
3967 /* For fields not not tracking in the in-memory inode,
3968 @@ -5043,29 +5076,32 @@ static int ext4_do_update_inode(handle_t
3969 ext4_get_inode_flags(ei);
3970 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3971 if (!(test_opt(inode->i_sb, NO_UID32))) {
3972 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3973 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3974 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3975 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3977 * Fix up interoperability with old kernels. Otherwise, old inodes get
3978 * re-used with the upper 16 bits of the uid/gid intact
3981 raw_inode->i_uid_high =
3982 - cpu_to_le16(high_16_bits(inode->i_uid));
3983 + cpu_to_le16(high_16_bits(uid));
3984 raw_inode->i_gid_high =
3985 - cpu_to_le16(high_16_bits(inode->i_gid));
3986 + cpu_to_le16(high_16_bits(gid));
3988 raw_inode->i_uid_high = 0;
3989 raw_inode->i_gid_high = 0;
3992 raw_inode->i_uid_low =
3993 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3994 + cpu_to_le16(fs_high2lowuid(uid));
3995 raw_inode->i_gid_low =
3996 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3997 + cpu_to_le16(fs_high2lowgid(gid));
3998 raw_inode->i_uid_high = 0;
3999 raw_inode->i_gid_high = 0;
4001 +#ifdef CONFIG_TAGGING_INTERN
4002 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4004 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4006 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
4007 @@ -5250,7 +5286,8 @@ int ext4_setattr(struct dentry *dentry,
4010 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4011 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4012 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4013 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4016 /* (user+group)*(old+new) structure, inode write (sb,
4017 @@ -5272,6 +5309,8 @@ int ext4_setattr(struct dentry *dentry,
4018 inode->i_uid = attr->ia_uid;
4019 if (attr->ia_valid & ATTR_GID)
4020 inode->i_gid = attr->ia_gid;
4021 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4022 + inode->i_tag = attr->ia_tag;
4023 error = ext4_mark_inode_dirty(handle, inode);
4024 ext4_journal_stop(handle);
4026 diff -NurpP --minimal linux-2.6.33/fs/ext4/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/ioctl.c
4027 --- linux-2.6.33/fs/ext4/ioctl.c 2010-02-25 11:52:05.000000000 +0100
4028 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4030 #include <linux/compat.h>
4031 #include <linux/mount.h>
4032 #include <linux/file.h>
4033 +#include <linux/vs_tag.h>
4034 #include <asm/uaccess.h>
4035 #include "ext4_jbd2.h"
4039 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
4041 + handle_t *handle = NULL;
4042 + struct ext4_iloc iloc;
4045 + handle = ext4_journal_start(inode, 1);
4046 + if (IS_ERR(handle))
4047 + return PTR_ERR(handle);
4049 + if (IS_SYNC(inode))
4050 + ext4_handle_sync(handle);
4051 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4055 + inode->i_flags = flags;
4056 + inode->i_vflags = vflags;
4057 + ext4_get_inode_flags(EXT4_I(inode));
4058 + inode->i_ctime = ext4_current_time(inode);
4060 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4062 + ext4_journal_stop(handle);
4066 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4068 struct inode *inode = filp->f_dentry->d_inode;
4069 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
4071 flags = ext4_mask_flags(inode->i_mode, flags);
4073 + if (IS_BARRIER(inode)) {
4074 + vxwprintk_task(1, "messing with the barrier.");
4079 mutex_lock(&inode->i_mutex);
4080 /* Is it quota file? Do not allow user to mess with it */
4081 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
4083 * This test looks nicer. Thanks to Pauline Middelink
4085 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4086 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4087 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4088 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
4089 if (!capable(CAP_LINUX_IMMUTABLE))
4092 diff -NurpP --minimal linux-2.6.33/fs/ext4/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/namei.c
4093 --- linux-2.6.33/fs/ext4/namei.c 2010-02-25 11:52:05.000000000 +0100
4094 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/namei.c 2010-02-25 12:02:16.000000000 +0100
4096 #include <linux/quotaops.h>
4097 #include <linux/buffer_head.h>
4098 #include <linux/bio.h>
4099 +#include <linux/vs_tag.h>
4101 #include "ext4_jbd2.h"
4103 @@ -941,6 +942,7 @@ restart:
4105 ll_rw_block(READ_META, 1, &bh);
4107 + dx_propagate_tag(nd, inode);
4109 if ((bh = bh_use[ra_ptr++]) == NULL)
4111 @@ -2533,6 +2535,7 @@ const struct inode_operations ext4_dir_i
4113 .check_acl = ext4_check_acl,
4114 .fiemap = ext4_fiemap,
4115 + .sync_flags = ext4_sync_flags,
4118 const struct inode_operations ext4_special_inode_operations = {
4119 diff -NurpP --minimal linux-2.6.33/fs/ext4/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/super.c
4120 --- linux-2.6.33/fs/ext4/super.c 2010-02-25 11:52:05.000000000 +0100
4121 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ext4/super.c 2010-02-25 12:02:16.000000000 +0100
4122 @@ -1110,6 +1110,7 @@ enum {
4123 Opt_block_validity, Opt_noblock_validity,
4124 Opt_inode_readahead_blks, Opt_journal_ioprio,
4125 Opt_discard, Opt_nodiscard,
4126 + Opt_tag, Opt_notag, Opt_tagid
4129 static const match_table_t tokens = {
4130 @@ -1178,6 +1179,9 @@ static const match_table_t tokens = {
4131 {Opt_noauto_da_alloc, "noauto_da_alloc"},
4132 {Opt_discard, "discard"},
4133 {Opt_nodiscard, "nodiscard"},
4135 + {Opt_notag, "notag"},
4136 + {Opt_tagid, "tagid=%u"},
4140 @@ -1275,6 +1279,20 @@ static int parse_options(char *options,
4142 set_opt(sbi->s_mount_opt, NO_UID32);
4144 +#ifndef CONFIG_TAGGING_NONE
4146 + set_opt (sbi->s_mount_opt, TAGGED);
4149 + clear_opt (sbi->s_mount_opt, TAGGED);
4152 +#ifdef CONFIG_PROPAGATE
4155 + set_opt (sbi->s_mount_opt, TAGGED);
4159 set_opt(sbi->s_mount_opt, DEBUG);
4161 @@ -2476,6 +2494,9 @@ static int ext4_fill_super(struct super_
4162 &journal_ioprio, NULL, 0))
4165 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4166 + sb->s_flags |= MS_TAGGED;
4168 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4169 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4171 @@ -3513,6 +3534,14 @@ static int ext4_remount(struct super_blo
4172 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
4173 ext4_abort(sb, __func__, "Abort forced by user");
4175 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4176 + !(sb->s_flags & MS_TAGGED)) {
4177 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4180 + goto restore_opts;
4183 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4184 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4186 diff -NurpP --minimal linux-2.6.33/fs/fcntl.c linux-2.6.33-vs2.3.0.36.30.1/fs/fcntl.c
4187 --- linux-2.6.33/fs/fcntl.c 2010-02-25 11:52:05.000000000 +0100
4188 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/fcntl.c 2010-02-25 12:02:16.000000000 +0100
4190 #include <linux/signal.h>
4191 #include <linux/rcupdate.h>
4192 #include <linux/pid_namespace.h>
4193 +#include <linux/vs_limit.h>
4195 #include <asm/poll.h>
4196 #include <asm/siginfo.h>
4197 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
4200 filp_close(tofree, files);
4202 + vx_openfd_inc(newfd); /* fd was unused */
4206 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
4210 + if (!vx_files_avail(1))
4213 err = security_file_fcntl(filp, cmd, arg);
4215 diff -NurpP --minimal linux-2.6.33/fs/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/file.c
4216 --- linux-2.6.33/fs/file.c 2009-12-03 20:02:51.000000000 +0100
4217 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/file.c 2010-02-25 12:02:16.000000000 +0100
4219 #include <linux/spinlock.h>
4220 #include <linux/rcupdate.h>
4221 #include <linux/workqueue.h>
4222 +#include <linux/vs_limit.h>
4224 struct fdtable_defer {
4226 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
4227 struct file *f = *old_fds++;
4230 + /* TODO: sum it first for check and performance */
4231 + vx_openfd_inc(open_files - i);
4234 * The fd may be claimed in the fd bitmap but not yet
4235 @@ -476,6 +479,7 @@ repeat:
4237 FD_CLR(fd, fdt->close_on_exec);
4239 + vx_openfd_inc(fd);
4242 if (rcu_dereference(fdt->fd[fd]) != NULL) {
4243 diff -NurpP --minimal linux-2.6.33/fs/file_table.c linux-2.6.33-vs2.3.0.36.30.1/fs/file_table.c
4244 --- linux-2.6.33/fs/file_table.c 2010-02-25 11:52:05.000000000 +0100
4245 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/file_table.c 2010-02-25 13:28:39.000000000 +0100
4247 #include <linux/sysctl.h>
4248 #include <linux/percpu_counter.h>
4249 #include <linux/ima.h>
4250 +#include <linux/vs_limit.h>
4251 +#include <linux/vs_context.h>
4253 #include <asm/atomic.h>
4255 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
4256 spin_lock_init(&f->f_lock);
4257 eventpoll_init_file(f);
4258 /* f->f_version: 0 */
4259 + f->f_xid = vx_current_xid();
4264 @@ -258,6 +262,8 @@ void __fput(struct file *file)
4265 cdev_put(inode->i_cdev);
4266 fops_put(file->f_op);
4267 put_pid(file->f_owner.pid);
4268 + vx_files_dec(file);
4271 if (file->f_mode & FMODE_WRITE)
4272 drop_file_write_access(file);
4273 @@ -325,6 +331,8 @@ void put_filp(struct file *file)
4275 if (atomic_long_dec_and_test(&file->f_count)) {
4276 security_file_free(file);
4277 + vx_files_dec(file);
4282 diff -NurpP --minimal linux-2.6.33/fs/fs_struct.c linux-2.6.33-vs2.3.0.36.30.1/fs/fs_struct.c
4283 --- linux-2.6.33/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
4284 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/fs_struct.c 2010-02-25 12:02:16.000000000 +0100
4286 #include <linux/path.h>
4287 #include <linux/slab.h>
4288 #include <linux/fs_struct.h>
4289 +#include <linux/vserver/global.h>
4292 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4293 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4295 path_put(&fs->root);
4297 + atomic_dec(&vs_global_fs);
4298 kmem_cache_free(fs_cachep, fs);
4301 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct
4303 path_get(&old->pwd);
4304 read_unlock(&old->lock);
4305 + atomic_inc(&vs_global_fs);
4309 diff -NurpP --minimal linux-2.6.33/fs/gfs2/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/gfs2/file.c
4310 --- linux-2.6.33/fs/gfs2/file.c 2010-02-25 11:52:05.000000000 +0100
4311 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/gfs2/file.c 2010-02-25 12:02:16.000000000 +0100
4312 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4313 [7] = GFS2_DIF_NOATIME,
4314 [12] = GFS2_DIF_EXHASH,
4315 [14] = GFS2_DIF_INHERIT_JDATA,
4316 + [27] = GFS2_DIF_IXUNLINK,
4317 + [26] = GFS2_DIF_BARRIER,
4318 + [29] = GFS2_DIF_COW,
4321 static const u32 gfs2_to_fsflags[32] = {
4322 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4323 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4324 [gfs2fl_ExHash] = FS_INDEX_FL,
4325 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4326 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4327 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4328 + [gfs2fl_Cow] = FS_COW_FL,
4331 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4332 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4334 struct gfs2_inode *ip = GFS2_I(inode);
4335 unsigned int flags = inode->i_flags;
4336 + unsigned int vflags = inode->i_vflags;
4338 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4339 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4341 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4342 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4343 flags |= S_IMMUTABLE;
4344 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4345 + flags |= S_IXUNLINK;
4347 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4349 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4350 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4351 if (ip->i_diskflags & GFS2_DIF_SYNC)
4353 inode->i_flags = flags;
4355 + vflags &= ~(V_BARRIER | V_COW);
4357 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4358 + vflags |= V_BARRIER;
4359 + if (ip->i_diskflags & GFS2_DIF_COW)
4361 + inode->i_vflags = vflags;
4364 +void gfs2_get_inode_flags(struct inode *inode)
4366 + struct gfs2_inode *ip = GFS2_I(inode);
4367 + unsigned int flags = inode->i_flags;
4368 + unsigned int vflags = inode->i_vflags;
4370 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4371 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4372 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4373 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4375 + if (flags & S_IMMUTABLE)
4376 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4377 + if (flags & S_IXUNLINK)
4378 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4380 + if (flags & S_APPEND)
4381 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4382 + if (flags & S_NOATIME)
4383 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4384 + if (flags & S_SYNC)
4385 + ip->i_diskflags |= GFS2_DIF_SYNC;
4387 + if (vflags & V_BARRIER)
4388 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4389 + if (vflags & V_COW)
4390 + ip->i_diskflags |= GFS2_DIF_COW;
4393 /* Flags that can be set by user space */
4394 @@ -286,6 +335,37 @@ static int gfs2_set_flags(struct file *f
4395 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4398 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4400 + struct gfs2_inode *ip = GFS2_I(inode);
4401 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4402 + struct buffer_head *bh;
4403 + struct gfs2_holder gh;
4406 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4409 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4412 + error = gfs2_meta_inode_buffer(ip, &bh);
4414 + goto out_trans_end;
4415 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4416 + inode->i_flags = flags;
4417 + inode->i_vflags = vflags;
4418 + gfs2_get_inode_flags(inode);
4419 + gfs2_dinode_out(ip, bh->b_data);
4421 + gfs2_set_aops(inode);
4423 + gfs2_trans_end(sdp);
4425 + gfs2_glock_dq_uninit(&gh);
4429 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4432 diff -NurpP --minimal linux-2.6.33/fs/gfs2/inode.h linux-2.6.33-vs2.3.0.36.30.1/fs/gfs2/inode.h
4433 --- linux-2.6.33/fs/gfs2/inode.h 2009-09-10 15:26:22.000000000 +0200
4434 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/gfs2/inode.h 2010-02-25 12:02:16.000000000 +0100
4435 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
4436 extern const struct file_operations gfs2_dir_fops_nolock;
4438 extern void gfs2_set_inode_flags(struct inode *inode);
4439 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4441 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4442 extern const struct file_operations gfs2_file_fops;
4443 diff -NurpP --minimal linux-2.6.33/fs/gfs2/ops_inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/gfs2/ops_inode.c
4444 --- linux-2.6.33/fs/gfs2/ops_inode.c 2010-02-25 11:52:05.000000000 +0100
4445 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/gfs2/ops_inode.c 2010-02-25 12:02:16.000000000 +0100
4446 @@ -1403,6 +1403,7 @@ const struct inode_operations gfs2_file_
4447 .listxattr = gfs2_listxattr,
4448 .removexattr = gfs2_removexattr,
4449 .fiemap = gfs2_fiemap,
4450 + .sync_flags = gfs2_sync_flags,
4453 const struct inode_operations gfs2_dir_iops = {
4454 @@ -1423,6 +1424,7 @@ const struct inode_operations gfs2_dir_i
4455 .listxattr = gfs2_listxattr,
4456 .removexattr = gfs2_removexattr,
4457 .fiemap = gfs2_fiemap,
4458 + .sync_flags = gfs2_sync_flags,
4461 const struct inode_operations gfs2_symlink_iops = {
4462 diff -NurpP --minimal linux-2.6.33/fs/hfsplus/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/hfsplus/ioctl.c
4463 --- linux-2.6.33/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4464 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/hfsplus/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4466 #include <linux/mount.h>
4467 #include <linux/sched.h>
4468 #include <linux/xattr.h>
4469 +#include <linux/mount.h>
4470 #include <asm/uaccess.h>
4471 #include "hfsplus_fs.h"
4473 diff -NurpP --minimal linux-2.6.33/fs/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/inode.c
4474 --- linux-2.6.33/fs/inode.c 2010-02-25 11:52:05.000000000 +0100
4475 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/inode.c 2010-02-25 12:02:16.000000000 +0100
4476 @@ -132,6 +132,9 @@ int inode_init_always(struct super_block
4477 struct address_space *const mapping = &inode->i_data;
4481 + /* essential because of inode slab reuse */
4483 inode->i_blkbits = sb->s_blocksize_bits;
4485 atomic_set(&inode->i_count, 1);
4486 @@ -152,6 +155,7 @@ int inode_init_always(struct super_block
4487 inode->i_bdev = NULL;
4488 inode->i_cdev = NULL;
4490 + inode->i_mdev = 0;
4491 inode->dirtied_when = 0;
4493 if (security_inode_alloc(inode))
4494 @@ -297,6 +301,8 @@ void __iget(struct inode *inode)
4495 inodes_stat.nr_unused--;
4498 +EXPORT_SYMBOL_GPL(__iget);
4501 * clear_inode - clear an inode
4502 * @inode: inode to clear
4503 @@ -1601,9 +1607,11 @@ void init_special_inode(struct inode *in
4504 if (S_ISCHR(mode)) {
4505 inode->i_fop = &def_chr_fops;
4506 inode->i_rdev = rdev;
4507 + inode->i_mdev = rdev;
4508 } else if (S_ISBLK(mode)) {
4509 inode->i_fop = &def_blk_fops;
4510 inode->i_rdev = rdev;
4511 + inode->i_mdev = rdev;
4512 } else if (S_ISFIFO(mode))
4513 inode->i_fop = &def_fifo_fops;
4514 else if (S_ISSOCK(mode))
4515 diff -NurpP --minimal linux-2.6.33/fs/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/ioctl.c
4516 --- linux-2.6.33/fs/ioctl.c 2009-12-03 20:02:52.000000000 +0100
4517 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4519 #include <linux/writeback.h>
4520 #include <linux/buffer_head.h>
4521 #include <linux/falloc.h>
4522 +#include <linux/proc_fs.h>
4523 +#include <linux/vserver/inode.h>
4524 +#include <linux/vs_tag.h>
4526 #include <asm/ioctls.h>
4528 diff -NurpP --minimal linux-2.6.33/fs/ioprio.c linux-2.6.33-vs2.3.0.36.30.1/fs/ioprio.c
4529 --- linux-2.6.33/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
4530 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ioprio.c 2010-02-25 12:02:16.000000000 +0100
4532 #include <linux/syscalls.h>
4533 #include <linux/security.h>
4534 #include <linux/pid_namespace.h>
4535 +#include <linux/vs_base.h>
4537 int set_task_ioprio(struct task_struct *task, int ioprio)
4539 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4541 pgrp = find_vpid(who);
4542 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4543 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4545 ret = set_task_ioprio(p, ioprio);
4548 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4550 pgrp = find_vpid(who);
4551 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4552 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4554 tmpio = get_task_ioprio(p);
4557 diff -NurpP --minimal linux-2.6.33/fs/jfs/acl.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/acl.c
4558 --- linux-2.6.33/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
4559 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/acl.c 2010-02-25 12:02:16.000000000 +0100
4560 @@ -216,7 +216,8 @@ int jfs_setattr(struct dentry *dentry, s
4563 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4564 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4565 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4566 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4567 if (vfs_dq_transfer(inode, iattr))
4570 diff -NurpP --minimal linux-2.6.33/fs/jfs/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/file.c
4571 --- linux-2.6.33/fs/jfs/file.c 2009-12-03 20:02:52.000000000 +0100
4572 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/file.c 2010-02-25 12:02:16.000000000 +0100
4573 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4574 .setattr = jfs_setattr,
4575 .check_acl = jfs_check_acl,
4577 + .sync_flags = jfs_sync_flags,
4580 const struct file_operations jfs_file_operations = {
4581 diff -NurpP --minimal linux-2.6.33/fs/jfs/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/ioctl.c
4582 --- linux-2.6.33/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4583 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/ioctl.c 2010-02-25 12:02:16.000000000 +0100
4585 #include <linux/mount.h>
4586 #include <linux/time.h>
4587 #include <linux/sched.h>
4588 +#include <linux/mount.h>
4589 #include <asm/current.h>
4590 #include <asm/uaccess.h>
4592 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4596 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4598 + inode->i_flags = flags;
4599 + inode->i_vflags = vflags;
4600 + jfs_get_inode_flags(JFS_IP(inode));
4601 + inode->i_ctime = CURRENT_TIME_SEC;
4602 + mark_inode_dirty(inode);
4606 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4608 struct inode *inode = filp->f_dentry->d_inode;
4609 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4610 if (!S_ISDIR(inode->i_mode))
4611 flags &= ~JFS_DIRSYNC_FL;
4613 + if (IS_BARRIER(inode)) {
4614 + vxwprintk_task(1, "messing with the barrier.");
4618 /* Is it quota file? Do not allow user to mess with it */
4619 if (IS_NOQUOTA(inode)) {
4621 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4622 * the relevant capability.
4624 if ((oldflags & JFS_IMMUTABLE_FL) ||
4625 - ((flags ^ oldflags) &
4626 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4627 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4628 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4629 if (!capable(CAP_LINUX_IMMUTABLE)) {
4630 mutex_unlock(&inode->i_mutex);
4632 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4636 - flags = flags & JFS_FL_USER_MODIFIABLE;
4637 + flags &= JFS_FL_USER_MODIFIABLE;
4638 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4639 jfs_inode->mode2 = flags;
4641 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_dinode.h linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_dinode.h
4642 --- linux-2.6.33/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4643 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_dinode.h 2010-02-25 12:02:16.000000000 +0100
4644 @@ -161,9 +161,13 @@ struct dinode {
4646 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4647 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4648 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4650 -#define JFS_FL_USER_VISIBLE 0x03F80000
4651 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4652 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4653 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4655 +#define JFS_FL_USER_VISIBLE 0x07F80000
4656 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4657 #define JFS_FL_INHERIT 0x03C80000
4659 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4660 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_filsys.h linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_filsys.h
4661 --- linux-2.6.33/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4662 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_filsys.h 2010-02-25 12:02:16.000000000 +0100
4664 #define JFS_NAME_MAX 255
4665 #define JFS_PATH_MAX BPSIZE
4667 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4670 * file system state (superblock state)
4671 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_imap.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_imap.c
4672 --- linux-2.6.33/fs/jfs/jfs_imap.c 2009-09-10 15:26:22.000000000 +0200
4673 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_imap.c 2010-02-25 12:02:16.000000000 +0100
4675 #include <linux/buffer_head.h>
4676 #include <linux/pagemap.h>
4677 #include <linux/quotaops.h>
4678 +#include <linux/vs_tag.h>
4680 #include "jfs_incore.h"
4681 #include "jfs_inode.h"
4682 @@ -3059,6 +3060,8 @@ static int copy_from_dinode(struct dinod
4684 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4685 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4689 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4690 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4691 @@ -3079,14 +3082,18 @@ static int copy_from_dinode(struct dinod
4693 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4695 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4696 + uid = le32_to_cpu(dip->di_uid);
4697 + gid = le32_to_cpu(dip->di_gid);
4698 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4700 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4702 ip->i_uid = jfs_ip->saved_uid;
4704 ip->i_uid = sbi->uid;
4707 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4708 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4710 ip->i_gid = jfs_ip->saved_gid;
4712 @@ -3151,14 +3158,12 @@ static void copy_to_dinode(struct dinode
4713 dip->di_size = cpu_to_le64(ip->i_size);
4714 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4715 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4716 - if (sbi->uid == -1)
4717 - dip->di_uid = cpu_to_le32(ip->i_uid);
4719 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4720 - if (sbi->gid == -1)
4721 - dip->di_gid = cpu_to_le32(ip->i_gid);
4723 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4725 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4726 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4727 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4728 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4730 jfs_get_inode_flags(jfs_ip);
4732 * mode2 is only needed for storing the higher order bits.
4733 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_inode.c
4734 --- linux-2.6.33/fs/jfs/jfs_inode.c 2009-06-11 17:13:05.000000000 +0200
4735 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_inode.c 2010-02-25 12:02:16.000000000 +0100
4738 #include <linux/fs.h>
4739 #include <linux/quotaops.h>
4740 +#include <linux/vs_tag.h>
4741 #include "jfs_incore.h"
4742 #include "jfs_inode.h"
4743 #include "jfs_filsys.h"
4744 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4746 unsigned int flags = JFS_IP(inode)->mode2;
4748 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4749 - S_NOATIME | S_DIRSYNC | S_SYNC);
4750 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4751 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4753 if (flags & JFS_IMMUTABLE_FL)
4754 inode->i_flags |= S_IMMUTABLE;
4755 + if (flags & JFS_IXUNLINK_FL)
4756 + inode->i_flags |= S_IXUNLINK;
4758 + if (flags & JFS_SYNC_FL)
4759 + inode->i_flags |= S_SYNC;
4760 if (flags & JFS_APPEND_FL)
4761 inode->i_flags |= S_APPEND;
4762 if (flags & JFS_NOATIME_FL)
4763 inode->i_flags |= S_NOATIME;
4764 if (flags & JFS_DIRSYNC_FL)
4765 inode->i_flags |= S_DIRSYNC;
4766 - if (flags & JFS_SYNC_FL)
4767 - inode->i_flags |= S_SYNC;
4769 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4771 + if (flags & JFS_BARRIER_FL)
4772 + inode->i_vflags |= V_BARRIER;
4773 + if (flags & JFS_COW_FL)
4774 + inode->i_vflags |= V_COW;
4777 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4779 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4780 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4782 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4783 + JFS_APPEND_FL | JFS_NOATIME_FL |
4784 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4785 + JFS_BARRIER_FL | JFS_COW_FL);
4787 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4788 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4789 if (flags & S_IMMUTABLE)
4790 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4791 + if (flags & S_IXUNLINK)
4792 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4794 if (flags & S_APPEND)
4795 jfs_ip->mode2 |= JFS_APPEND_FL;
4796 if (flags & S_NOATIME)
4797 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4798 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4800 jfs_ip->mode2 |= JFS_SYNC_FL;
4802 + if (vflags & V_BARRIER)
4803 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4804 + if (vflags & V_COW)
4805 + jfs_ip->mode2 |= JFS_COW_FL;
4809 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
4812 inode->i_gid = current_fsgid();
4813 + inode->i_tag = dx_current_fstag(sb);
4816 * New inodes need to save sane values on disk when
4817 diff -NurpP --minimal linux-2.6.33/fs/jfs/jfs_inode.h linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_inode.h
4818 --- linux-2.6.33/fs/jfs/jfs_inode.h 2009-06-11 17:13:05.000000000 +0200
4819 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/jfs_inode.h 2010-02-25 12:02:16.000000000 +0100
4820 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4821 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4822 int fh_len, int fh_type);
4823 extern void jfs_set_inode_flags(struct inode *);
4824 +extern int jfs_sync_flags(struct inode *, int, int);
4825 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4827 extern const struct address_space_operations jfs_aops;
4828 diff -NurpP --minimal linux-2.6.33/fs/jfs/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/namei.c
4829 --- linux-2.6.33/fs/jfs/namei.c 2009-12-03 20:02:52.000000000 +0100
4830 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/namei.c 2010-02-25 12:02:16.000000000 +0100
4832 #include <linux/ctype.h>
4833 #include <linux/quotaops.h>
4834 #include <linux/exportfs.h>
4835 +#include <linux/vs_tag.h>
4836 #include "jfs_incore.h"
4837 #include "jfs_superblock.h"
4838 #include "jfs_inode.h"
4839 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4840 return ERR_CAST(ip);
4843 + dx_propagate_tag(nd, ip);
4844 dentry = d_splice_alias(ip, dentry);
4846 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4847 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4848 .setattr = jfs_setattr,
4849 .check_acl = jfs_check_acl,
4851 + .sync_flags = jfs_sync_flags,
4854 const struct file_operations jfs_dir_operations = {
4855 diff -NurpP --minimal linux-2.6.33/fs/jfs/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/super.c
4856 --- linux-2.6.33/fs/jfs/super.c 2010-02-25 11:52:05.000000000 +0100
4857 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/jfs/super.c 2010-02-25 12:02:16.000000000 +0100
4858 @@ -192,7 +192,8 @@ static void jfs_put_super(struct super_b
4860 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4861 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4862 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4863 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4864 + Opt_tag, Opt_notag, Opt_tagid
4867 static const match_table_t tokens = {
4868 @@ -202,6 +203,10 @@ static const match_table_t tokens = {
4869 {Opt_resize, "resize=%u"},
4870 {Opt_resize_nosize, "resize"},
4871 {Opt_errors, "errors=%s"},
4873 + {Opt_notag, "notag"},
4874 + {Opt_tagid, "tagid=%u"},
4875 + {Opt_tag, "tagxid"},
4876 {Opt_ignore, "noquota"},
4877 {Opt_ignore, "quota"},
4878 {Opt_usrquota, "usrquota"},
4879 @@ -336,6 +341,20 @@ static int parse_options(char *options,
4883 +#ifndef CONFIG_TAGGING_NONE
4885 + *flag |= JFS_TAGGED;
4888 + *flag &= JFS_TAGGED;
4891 +#ifdef CONFIG_PROPAGATE
4894 + *flag |= JFS_TAGGED;
4898 printk("jfs: Unrecognized mount option \"%s\" "
4899 " or missing value\n", p);
4900 @@ -366,6 +385,12 @@ static int jfs_remount(struct super_bloc
4901 if (!parse_options(data, sb, &newLVSize, &flag)) {
4904 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4905 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4912 if (sb->s_flags & MS_RDONLY) {
4913 @@ -449,6 +474,9 @@ static int jfs_fill_super(struct super_b
4914 #ifdef CONFIG_JFS_POSIX_ACL
4915 sb->s_flags |= MS_POSIXACL;
4917 + /* map mount option tagxid */
4918 + if (sbi->flag & JFS_TAGGED)
4919 + sb->s_flags |= MS_TAGGED;
4922 printk(KERN_ERR "resize option for remount only\n");
4923 diff -NurpP --minimal linux-2.6.33/fs/libfs.c linux-2.6.33-vs2.3.0.36.30.1/fs/libfs.c
4924 --- linux-2.6.33/fs/libfs.c 2010-02-25 11:52:05.000000000 +0100
4925 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/libfs.c 2010-02-25 12:02:16.000000000 +0100
4926 @@ -127,7 +127,8 @@ static inline unsigned char dt_type(stru
4927 * both impossible due to the lock on directory.
4930 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4931 +static inline int do_dcache_readdir_filter(struct file *filp,
4932 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4934 struct dentry *dentry = filp->f_path.dentry;
4935 struct dentry *cursor = filp->private_data;
4936 @@ -160,6 +161,8 @@ int dcache_readdir(struct file * filp, v
4937 next = list_entry(p, struct dentry, d_u.d_child);
4938 if (d_unhashed(next) || !next->d_inode)
4940 + if (filter && !filter(next))
4943 spin_unlock(&dcache_lock);
4944 if (filldir(dirent, next->d_name.name,
4945 @@ -178,6 +181,18 @@ int dcache_readdir(struct file * filp, v
4949 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4951 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4954 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4955 + int (*filter)(struct dentry *))
4957 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4961 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4964 @@ -841,6 +856,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4965 EXPORT_SYMBOL(dcache_dir_lseek);
4966 EXPORT_SYMBOL(dcache_dir_open);
4967 EXPORT_SYMBOL(dcache_readdir);
4968 +EXPORT_SYMBOL(dcache_readdir_filter);
4969 EXPORT_SYMBOL(generic_read_dir);
4970 EXPORT_SYMBOL(get_sb_pseudo);
4971 EXPORT_SYMBOL(simple_write_begin);
4972 diff -NurpP --minimal linux-2.6.33/fs/locks.c linux-2.6.33-vs2.3.0.36.30.1/fs/locks.c
4973 --- linux-2.6.33/fs/locks.c 2009-12-03 20:02:52.000000000 +0100
4974 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/locks.c 2010-02-25 12:02:16.000000000 +0100
4976 #include <linux/time.h>
4977 #include <linux/rcupdate.h>
4978 #include <linux/pid_namespace.h>
4979 +#include <linux/vs_base.h>
4980 +#include <linux/vs_limit.h>
4982 #include <asm/uaccess.h>
4984 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4985 /* Allocate an empty lock structure. */
4986 static struct file_lock *locks_alloc_lock(void)
4988 + if (!vx_locks_avail(1))
4990 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4993 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
4994 BUG_ON(!list_empty(&fl->fl_block));
4995 BUG_ON(!list_empty(&fl->fl_link));
4998 locks_release_private(fl);
4999 kmem_cache_free(filelock_cache, fl);
5001 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
5002 fl->fl_start = fl->fl_end = 0;
5004 fl->fl_lmops = NULL;
5008 EXPORT_SYMBOL(locks_init_lock);
5009 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
5010 new->fl_file = fl->fl_file;
5011 new->fl_ops = fl->fl_ops;
5012 new->fl_lmops = fl->fl_lmops;
5013 + new->fl_xid = fl->fl_xid;
5015 locks_copy_private(new, fl);
5017 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
5018 fl->fl_flags = FL_FLOCK;
5020 fl->fl_end = OFFSET_MAX;
5022 + vxd_assert(filp->f_xid == vx_current_xid(),
5023 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5024 + fl->fl_xid = filp->f_xid;
5029 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
5031 fl->fl_owner = current->files;
5032 fl->fl_pid = current->tgid;
5033 + fl->fl_xid = vx_current_xid();
5036 fl->fl_flags = FL_LEASE;
5037 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
5039 return ERR_PTR(error);
5041 + fl->fl_xid = vx_current_xid();
5043 + vxd_assert(filp->f_xid == fl->fl_xid,
5044 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
5046 error = lease_init(filp, type, fl);
5048 locks_free_lock(fl);
5049 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
5053 + new_fl->fl_xid = -1;
5055 for_each_lock(inode, before) {
5056 struct file_lock *fl = *before;
5057 @@ -790,6 +809,7 @@ find_conflict:
5059 locks_copy_lock(new_fl, request);
5060 locks_insert_lock(before, new_fl);
5061 + vx_locks_inc(new_fl);
5065 @@ -800,7 +820,8 @@ out:
5069 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
5070 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
5071 + struct file_lock *conflock, xid_t xid)
5073 struct file_lock *fl;
5074 struct file_lock *new_fl = NULL;
5075 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
5076 struct file_lock **before;
5077 int error, added = 0;
5079 + vxd_assert(xid == vx_current_xid(),
5080 + "xid(%d) == current(%d)", xid, vx_current_xid());
5082 * We may need two file_lock structures for this operation,
5083 * so we get them in advance to avoid races.
5084 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
5085 (request->fl_type != F_UNLCK ||
5086 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
5087 new_fl = locks_alloc_lock();
5088 + new_fl->fl_xid = xid;
5089 + vx_locks_inc(new_fl);
5090 new_fl2 = locks_alloc_lock();
5091 + new_fl2->fl_xid = xid;
5092 + vx_locks_inc(new_fl2);
5096 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
5097 int posix_lock_file(struct file *filp, struct file_lock *fl,
5098 struct file_lock *conflock)
5100 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
5101 + return __posix_lock_file(filp->f_path.dentry->d_inode,
5102 + fl, conflock, filp->f_xid);
5104 EXPORT_SYMBOL(posix_lock_file);
5106 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
5107 fl.fl_end = offset + count - 1;
5110 - error = __posix_lock_file(inode, &fl, NULL);
5111 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
5112 if (error != FILE_LOCK_DEFERRED)
5114 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
5115 @@ -1424,6 +1452,7 @@ int generic_setlease(struct file *filp,
5117 locks_copy_lock(new_fl, lease);
5118 locks_insert_lock(before, new_fl);
5119 + vx_locks_inc(new_fl);
5123 @@ -1779,6 +1808,11 @@ int fcntl_setlk(unsigned int fd, struct
5124 if (file_lock == NULL)
5127 + vxd_assert(filp->f_xid == vx_current_xid(),
5128 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5129 + file_lock->fl_xid = filp->f_xid;
5130 + vx_locks_inc(file_lock);
5133 * This might block, so we do it before checking the inode.
5135 @@ -1897,6 +1931,11 @@ int fcntl_setlk64(unsigned int fd, struc
5136 if (file_lock == NULL)
5139 + vxd_assert(filp->f_xid == vx_current_xid(),
5140 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5141 + file_lock->fl_xid = filp->f_xid;
5142 + vx_locks_inc(file_lock);
5145 * This might block, so we do it before checking the inode.
5147 @@ -2162,8 +2201,11 @@ static int locks_show(struct seq_file *f
5149 lock_get_status(f, fl, (long)f->private, "");
5151 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
5152 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
5153 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
5155 lock_get_status(f, bfl, (long)f->private, " ->");
5160 diff -NurpP --minimal linux-2.6.33/fs/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/namei.c
5161 --- linux-2.6.33/fs/namei.c 2010-02-25 11:52:05.000000000 +0100
5162 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/namei.c 2010-02-25 15:31:15.000000000 +0100
5164 #include <linux/fcntl.h>
5165 #include <linux/device_cgroup.h>
5166 #include <linux/fs_struct.h>
5167 +#include <linux/proc_fs.h>
5168 +#include <linux/vserver/inode.h>
5169 +#include <linux/vs_base.h>
5170 +#include <linux/vs_tag.h>
5171 +#include <linux/vs_cowbl.h>
5172 +#include <linux/vs_device.h>
5173 +#include <linux/vs_context.h>
5174 +#include <linux/pid_namespace.h>
5175 #include <asm/uaccess.h>
5177 #include "internal.h"
5178 @@ -167,6 +175,77 @@ void putname(const char *name)
5179 EXPORT_SYMBOL(putname);
5182 +static inline int dx_barrier(const struct inode *inode)
5184 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
5185 + vxwprintk_task(1, "did hit the barrier.");
5191 +static int __dx_permission(const struct inode *inode, int mask)
5193 + if (dx_barrier(inode))
5196 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
5197 + /* devpts is xid tagged */
5198 + if (S_ISDIR(inode->i_mode) ||
5199 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
5202 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5203 + struct proc_dir_entry *de = PDE(inode);
5205 + if (de && !vx_hide_check(0, de->vx_flags))
5208 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
5210 + struct task_struct *tsk;
5212 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
5213 + vx_flags(VXF_STATE_SETUP, 0))
5216 + pid = PROC_I(inode)->pid;
5220 + tsk = pid_task(pid, PIDTYPE_PID);
5221 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
5222 + tsk, (tsk ? vx_task_xid(tsk) : 0));
5223 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
5227 + /* FIXME: Should we block some entries here? */
5232 + if (dx_notagcheck(inode->i_sb) ||
5233 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
5242 +int dx_permission(const struct inode *inode, int mask)
5244 + int ret = __dx_permission(inode, mask);
5245 + if (unlikely(ret)) {
5246 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
5247 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5254 * This does basic POSIX ACL permission checking
5256 @@ -267,10 +346,14 @@ int inode_permission(struct inode *inode
5258 * Nobody gets write access to an immutable file.
5260 - if (IS_IMMUTABLE(inode))
5261 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5265 + retval = dx_permission(inode, mask);
5269 if (inode->i_op->permission)
5270 retval = inode->i_op->permission(inode, mask);
5272 @@ -465,6 +548,9 @@ static int exec_permission(struct inode
5276 + if (dx_barrier(inode))
5279 if (inode->i_op->permission) {
5280 ret = inode->i_op->permission(inode, MAY_EXEC);
5282 @@ -694,7 +780,8 @@ static __always_inline void follow_dotdo
5284 if (nd->path.dentry == nd->root.dentry &&
5285 nd->path.mnt == nd->root.mnt) {
5287 + /* for sane '/' avoid follow_mount() */
5290 spin_lock(&dcache_lock);
5291 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5292 @@ -730,7 +817,7 @@ static int do_lookup(struct nameidata *n
5294 struct vfsmount *mnt = nd->path.mnt;
5295 struct dentry *dentry, *parent;
5296 - struct inode *dir;
5297 + struct inode *dir, *inode;
5299 * See if the low-level filesystem might want
5300 * to use its own hash..
5301 @@ -746,12 +833,26 @@ static int do_lookup(struct nameidata *n
5303 if (dentry->d_op && dentry->d_op->d_revalidate)
5304 goto need_revalidate;
5306 + inode = dentry->d_inode;
5310 + if (__dx_permission(inode, MAY_ACCESS))
5314 path->dentry = dentry;
5315 __follow_mount(path);
5319 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s/%.*s«.",
5320 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5321 + vxd_path(&nd->path), name->len, name->name);
5326 parent = nd->path.dentry;
5327 dir = parent->d_inode;
5328 @@ -1355,7 +1456,7 @@ static int may_delete(struct inode *dir,
5331 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5332 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5333 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5336 if (!S_ISDIR(victim->d_inode->i_mode))
5337 @@ -1495,6 +1596,14 @@ int may_open(struct path *path, int acc_
5341 +#ifdef CONFIG_VSERVER_COWBL
5342 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5343 + if (IS_COW_LINK(inode))
5345 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5346 + mark_inode_dirty(inode);
5349 error = inode_permission(inode, acc_mode);
5352 @@ -1621,6 +1730,11 @@ struct file *do_filp_open(int dfd, const
5353 int flag = open_to_namei_flags(open_flag);
5354 int force_reval = 0;
5356 +#ifdef CONFIG_VSERVER_COWBL
5362 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
5363 * check for O_DSYNC if the need any syncing at all we enforce it's
5364 @@ -1799,6 +1913,25 @@ ok:
5367 error = may_open(&nd.path, acc_mode, flag);
5368 +#ifdef CONFIG_VSERVER_COWBL
5369 + if (error == -EMLINK) {
5370 + struct dentry *dentry;
5371 + dentry = cow_break_link(pathname);
5372 + if (IS_ERR(dentry)) {
5373 + error = PTR_ERR(dentry);
5377 + if (will_truncate)
5378 + mnt_drop_write(nd.path.mnt);
5379 + release_open_intent(&nd);
5380 + path_put(&nd.path);
5389 mnt_drop_write(nd.path.mnt);
5390 @@ -1982,9 +2115,17 @@ int vfs_mknod(struct inode *dir, struct
5394 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5395 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5398 + if (!capable(CAP_MKNOD))
5401 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5403 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5406 if (!dir->i_op->mknod)
5409 @@ -2451,7 +2592,7 @@ int vfs_link(struct dentry *old_dentry,
5411 * A link to an append-only or immutable file cannot be created.
5413 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5414 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5416 if (!dir->i_op->link)
5418 @@ -2824,6 +2965,219 @@ int vfs_follow_link(struct nameidata *nd
5419 return __vfs_follow_link(nd, link);
5423 +#ifdef CONFIG_VSERVER_COWBL
5425 +#include <linux/file.h>
5428 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5432 + return do_splice_direct(in, &ppos, out, len, 0);
5435 +struct dentry *cow_break_link(const char *pathname)
5437 + int ret, mode, pathlen, redo = 0;
5438 + struct nameidata old_nd, dir_nd;
5439 + struct path old_path, new_path;
5440 + struct dentry *dir, *res = NULL;
5441 + struct file *old_file;
5442 + struct file *new_file;
5443 + char *to, *path, pad='\251';
5446 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5447 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5452 + /* old_nd will have refs to dentry and mnt */
5453 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5454 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5456 + goto out_free_path;
5458 + old_path = old_nd.path;
5459 + mode = old_path.dentry->d_inode->i_mode;
5461 + to = d_path(&old_path, path, PATH_MAX-2);
5462 + pathlen = strlen(to);
5463 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5464 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5465 + old_path.dentry->d_name.len);
5467 + to[pathlen + 1] = 0;
5469 + to[pathlen] = pad--;
5471 + if (pad <= '\240')
5474 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5475 + /* dir_nd will have refs to dentry and mnt */
5476 + ret = path_lookup(to,
5477 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5478 + vxdprintk(VXD_CBIT(misc, 2),
5479 + "path_lookup(new): %d", ret);
5483 + /* this puppy downs the inode mutex */
5484 + new_path.dentry = lookup_create(&dir_nd, 0);
5485 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5486 + vxdprintk(VXD_CBIT(misc, 2),
5487 + "lookup_create(new): %p", new_path.dentry);
5488 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5489 + path_put(&dir_nd.path);
5492 + vxdprintk(VXD_CBIT(misc, 2),
5493 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5494 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5495 + new_path.dentry->d_name.len);
5496 + dir = dir_nd.path.dentry;
5498 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5499 + vxdprintk(VXD_CBIT(misc, 2),
5500 + "vfs_create(new): %d", ret);
5501 + if (ret == -EEXIST) {
5502 + mutex_unlock(&dir->d_inode->i_mutex);
5503 + dput(new_path.dentry);
5504 + path_put(&dir_nd.path);
5508 + goto out_unlock_new;
5510 + /* drop out early, ret passes ENOENT */
5512 + if ((redo = d_unhashed(old_path.dentry)))
5513 + goto out_unlock_new;
5515 + new_path.mnt = dir_nd.path.mnt;
5516 + dget(old_path.dentry);
5517 + mntget(old_path.mnt);
5518 + /* this one cleans up the dentry/mnt in case of failure */
5519 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5520 + O_RDONLY, current_cred());
5521 + vxdprintk(VXD_CBIT(misc, 2),
5522 + "dentry_open(old): %p", old_file);
5523 + if (!old_file || IS_ERR(old_file)) {
5524 + res = IS_ERR(old_file) ? (void *) old_file : res;
5525 + goto out_unlock_new;
5528 + dget(new_path.dentry);
5529 + mntget(new_path.mnt);
5530 + /* this one cleans up the dentry/mnt in case of failure */
5531 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5532 + O_WRONLY, current_cred());
5533 + vxdprintk(VXD_CBIT(misc, 2),
5534 + "dentry_open(new): %p", new_file);
5536 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5537 + if (!new_file || IS_ERR(new_file))
5538 + goto out_fput_old;
5540 + size = i_size_read(old_file->f_dentry->d_inode);
5541 + ret = do_cow_splice(old_file, new_file, size);
5542 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5544 + goto out_fput_both;
5545 + } else if (ret < size) {
5547 + goto out_fput_both;
5549 + struct inode *old_inode = old_path.dentry->d_inode;
5550 + struct inode *new_inode = new_path.dentry->d_inode;
5551 + struct iattr attr = {
5552 + .ia_uid = old_inode->i_uid,
5553 + .ia_gid = old_inode->i_gid,
5554 + .ia_valid = ATTR_UID | ATTR_GID
5557 + ret = inode_setattr(new_inode, &attr);
5559 + goto out_fput_both;
5562 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5564 + /* drop out late */
5566 + if ((redo = d_unhashed(old_path.dentry)))
5569 + vxdprintk(VXD_CBIT(misc, 2),
5570 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5571 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5572 + new_path.dentry->d_name.len,
5573 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5574 + old_path.dentry->d_name.len);
5575 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5576 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5577 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5578 + res = new_path.dentry;
5581 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5584 + vxdprintk(VXD_CBIT(misc, 3),
5585 + "fput(new_file=%p[#%ld])", new_file,
5586 + atomic_long_read(&new_file->f_count));
5590 + vxdprintk(VXD_CBIT(misc, 3),
5591 + "fput(old_file=%p[#%ld])", old_file,
5592 + atomic_long_read(&old_file->f_count));
5596 + mutex_unlock(&dir->d_inode->i_mutex);
5600 + /* error path cleanup */
5601 + vfs_unlink(dir->d_inode, new_path.dentry);
5602 + dput(new_path.dentry);
5606 + goto out_rel_both;
5607 + /* lookup dentry once again */
5608 + path_put(&old_nd.path);
5609 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5611 + goto out_rel_both;
5613 + new_path.dentry = old_nd.path.dentry;
5614 + vxdprintk(VXD_CBIT(misc, 2),
5615 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5616 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5617 + new_path.dentry->d_name.len);
5618 + dget(new_path.dentry);
5619 + res = new_path.dentry;
5622 + path_put(&dir_nd.path);
5624 + path_put(&old_nd.path);
5629 + res = ERR_PTR(ret);
5635 /* get the link contents into pagecache */
5636 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5638 diff -NurpP --minimal linux-2.6.33/fs/namespace.c linux-2.6.33-vs2.3.0.36.30.1/fs/namespace.c
5639 --- linux-2.6.33/fs/namespace.c 2010-02-25 11:52:05.000000000 +0100
5640 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/namespace.c 2010-02-25 12:02:16.000000000 +0100
5642 #include <linux/log2.h>
5643 #include <linux/idr.h>
5644 #include <linux/fs_struct.h>
5645 +#include <linux/vs_base.h>
5646 +#include <linux/vs_context.h>
5647 +#include <linux/vs_tag.h>
5648 +#include <linux/vserver/space.h>
5649 +#include <linux/vserver/global.h>
5650 #include <asm/uaccess.h>
5651 #include <asm/unistd.h>
5653 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
5654 mnt->mnt_root = dget(root);
5655 mnt->mnt_mountpoint = mnt->mnt_root;
5656 mnt->mnt_parent = mnt;
5657 + mnt->mnt_tag = old->mnt_tag;
5659 if (flag & CL_SLAVE) {
5660 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5661 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
5662 seq_escape(m, s, " \t\n\\");
5665 +static int mnt_is_reachable(struct vfsmount *mnt)
5668 + struct dentry *point;
5671 + if (mnt == mnt->mnt_ns->root)
5674 + spin_lock(&vfsmount_lock);
5675 + root = current->fs->root;
5676 + point = root.dentry;
5678 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5679 + point = mnt->mnt_mountpoint;
5680 + mnt = mnt->mnt_parent;
5683 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5685 + spin_unlock(&vfsmount_lock);
5691 * Simple .show_options callback for filesystems which don't want to
5692 * implement more complex mount option showing.
5693 @@ -748,6 +779,8 @@ static int show_sb_opts(struct seq_file
5694 { MS_SYNCHRONOUS, ",sync" },
5695 { MS_DIRSYNC, ",dirsync" },
5696 { MS_MANDLOCK, ",mand" },
5697 + { MS_TAGGED, ",tag" },
5698 + { MS_NOTAGCHECK, ",notagcheck" },
5701 const struct proc_fs_info *fs_infop;
5702 @@ -795,10 +828,20 @@ static int show_vfsmnt(struct seq_file *
5704 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5706 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5708 - seq_path(m, &mnt_path, " \t\n\\");
5710 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5712 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5715 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5716 + mnt == current->fs->root.mnt) {
5717 + seq_puts(m, "/dev/root / ");
5719 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5721 + seq_path(m, &mnt_path, " \t\n\\");
5724 show_type(m, mnt->mnt_sb);
5725 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5726 err = show_sb_opts(m, mnt->mnt_sb);
5727 @@ -828,6 +871,11 @@ static int show_mountinfo(struct seq_fil
5728 struct path root = p->root;
5731 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5733 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5736 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5737 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5738 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5739 @@ -886,17 +934,27 @@ static int show_vfsstat(struct seq_file
5740 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5744 - if (mnt->mnt_devname) {
5745 - seq_puts(m, "device ");
5746 - mangle(m, mnt->mnt_devname);
5748 - seq_puts(m, "no device");
5749 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5751 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5755 - seq_puts(m, " mounted on ");
5756 - seq_path(m, &mnt_path, " \t\n\\");
5758 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5759 + mnt == current->fs->root.mnt) {
5760 + seq_puts(m, "device /dev/root mounted on / ");
5763 + if (mnt->mnt_devname) {
5764 + seq_puts(m, "device ");
5765 + mangle(m, mnt->mnt_devname);
5767 + seq_puts(m, "no device");
5770 + seq_puts(m, " mounted on ");
5771 + seq_path(m, &mnt_path, " \t\n\\");
5775 /* file system type */
5776 seq_puts(m, "with fstype ");
5777 @@ -1132,7 +1190,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5781 - if (!capable(CAP_SYS_ADMIN))
5782 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5785 retval = do_umount(path.mnt, flags);
5786 @@ -1158,7 +1216,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5788 static int mount_is_safe(struct path *path)
5790 - if (capable(CAP_SYS_ADMIN))
5791 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5795 @@ -1422,7 +1480,7 @@ static int do_change_type(struct path *p
5796 int type = flag & ~MS_REC;
5799 - if (!capable(CAP_SYS_ADMIN))
5800 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5803 if (path->dentry != path->mnt->mnt_root)
5804 @@ -1449,11 +1507,13 @@ static int do_change_type(struct path *p
5805 * do loopback mount.
5807 static int do_loopback(struct path *path, char *old_name,
5809 + tag_t tag, unsigned long flags, int mnt_flags)
5811 struct path old_path;
5812 struct vfsmount *mnt = NULL;
5813 int err = mount_is_safe(path);
5814 + int recurse = flags & MS_REC;
5818 if (!old_name || !*old_name)
5819 @@ -1487,6 +1547,7 @@ static int do_loopback(struct path *path
5820 spin_unlock(&vfsmount_lock);
5821 release_mounts(&umount_list);
5823 + mnt->mnt_flags = mnt_flags;
5826 up_write(&namespace_sem);
5827 @@ -1517,12 +1578,12 @@ static int change_mount_flags(struct vfs
5828 * on it - tough luck.
5830 static int do_remount(struct path *path, int flags, int mnt_flags,
5832 + void *data, xid_t xid)
5835 struct super_block *sb = path->mnt->mnt_sb;
5837 - if (!capable(CAP_SYS_ADMIN))
5838 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5841 if (!check_mnt(path->mnt))
5842 @@ -1568,7 +1629,7 @@ static int do_move_mount(struct path *pa
5843 struct path old_path, parent_path;
5846 - if (!capable(CAP_SYS_ADMIN))
5847 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5849 if (!old_name || !*old_name)
5851 @@ -1650,7 +1711,7 @@ static int do_new_mount(struct path *pat
5854 /* we need capabilities... */
5855 - if (!capable(CAP_SYS_ADMIN))
5856 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5860 @@ -1916,6 +1977,7 @@ long do_mount(char *dev_name, char *dir_
5867 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5868 @@ -1943,6 +2005,12 @@ long do_mount(char *dev_name, char *dir_
5869 if (!(flags & MS_NOATIME))
5870 mnt_flags |= MNT_RELATIME;
5872 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5873 + /* FIXME: bind and re-mounts get the tag flag? */
5874 + if (flags & (MS_BIND|MS_REMOUNT))
5875 + flags |= MS_TAGID;
5878 /* Separate the per-mountpoint flags */
5879 if (flags & MS_NOSUID)
5880 mnt_flags |= MNT_NOSUID;
5881 @@ -1959,15 +2027,17 @@ long do_mount(char *dev_name, char *dir_
5882 if (flags & MS_RDONLY)
5883 mnt_flags |= MNT_READONLY;
5885 + if (!capable(CAP_SYS_ADMIN))
5886 + mnt_flags |= MNT_NODEV;
5887 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5888 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5891 if (flags & MS_REMOUNT)
5892 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5895 else if (flags & MS_BIND)
5896 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5897 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5898 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5899 retval = do_change_type(&path, flags);
5900 else if (flags & MS_MOVE)
5901 @@ -2046,6 +2116,7 @@ static struct mnt_namespace *dup_mnt_ns(
5902 q = next_mnt(q, new_ns->root);
5904 up_write(&namespace_sem);
5905 + atomic_inc(&vs_global_mnt_ns);
5909 @@ -2190,9 +2261,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5910 down_write(&namespace_sem);
5911 mutex_lock(&old.dentry->d_inode->i_mutex);
5913 - if (IS_MNT_SHARED(old.mnt) ||
5914 + if ((IS_MNT_SHARED(old.mnt) ||
5915 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5916 - IS_MNT_SHARED(root.mnt->mnt_parent))
5917 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5918 + !vx_flags(VXF_STATE_SETUP, 0))
5920 if (!check_mnt(root.mnt))
5922 @@ -2328,6 +2400,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5923 spin_unlock(&vfsmount_lock);
5924 up_write(&namespace_sem);
5925 release_mounts(&umount_list);
5926 + atomic_dec(&vs_global_mnt_ns);
5929 EXPORT_SYMBOL(put_mnt_ns);
5930 diff -NurpP --minimal linux-2.6.33/fs/nfs/client.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/client.c
5931 --- linux-2.6.33/fs/nfs/client.c 2010-02-25 11:52:05.000000000 +0100
5932 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/client.c 2010-02-25 12:02:16.000000000 +0100
5933 @@ -738,6 +738,9 @@ static int nfs_init_server_rpcclient(str
5934 if (server->flags & NFS_MOUNT_SOFT)
5935 server->client->cl_softrtry = 1;
5937 + server->client->cl_tag = 0;
5938 + if (server->flags & NFS_MOUNT_TAGGED)
5939 + server->client->cl_tag = 1;
5943 @@ -909,6 +912,10 @@ static void nfs_server_set_fsinfo(struct
5944 server->acdirmin = server->acdirmax = 0;
5947 + /* FIXME: needs fsinfo
5948 + if (server->flags & NFS_MOUNT_TAGGED)
5949 + sb->s_flags |= MS_TAGGED; */
5951 server->maxfilesize = fsinfo->maxfilesize;
5953 /* We're airborne Set socket buffersize */
5954 diff -NurpP --minimal linux-2.6.33/fs/nfs/dir.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/dir.c
5955 --- linux-2.6.33/fs/nfs/dir.c 2010-02-25 11:52:05.000000000 +0100
5956 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/dir.c 2010-02-25 12:02:16.000000000 +0100
5958 #include <linux/namei.h>
5959 #include <linux/mount.h>
5960 #include <linux/sched.h>
5961 +#include <linux/vs_tag.h>
5963 #include "nfs4_fs.h"
5964 #include "delegation.h"
5965 @@ -949,6 +950,7 @@ static struct dentry *nfs_lookup(struct
5967 goto out_unblock_sillyrename;
5969 + dx_propagate_tag(nd, inode);
5971 res = d_materialise_unique(dentry, inode);
5973 diff -NurpP --minimal linux-2.6.33/fs/nfs/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/inode.c
5974 --- linux-2.6.33/fs/nfs/inode.c 2010-02-25 11:52:05.000000000 +0100
5975 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/inode.c 2010-02-25 12:02:16.000000000 +0100
5977 #include <linux/vfs.h>
5978 #include <linux/inet.h>
5979 #include <linux/nfs_xdr.h>
5980 +#include <linux/vs_tag.h>
5982 #include <asm/system.h>
5983 #include <asm/uaccess.h>
5984 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5985 if (inode->i_state & I_NEW) {
5986 struct nfs_inode *nfsi = NFS_I(inode);
5987 unsigned long now = jiffies;
5991 /* We set i_ino for the few things that still rely on it,
5992 * such as stat(2) */
5993 @@ -327,8 +330,8 @@ nfs_fhget(struct super_block *sb, struct
5994 nfsi->change_attr = 0;
5997 - inode->i_uid = -2;
5998 - inode->i_gid = -2;
6001 inode->i_blocks = 0;
6002 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
6004 @@ -365,13 +368,13 @@ nfs_fhget(struct super_block *sb, struct
6005 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
6006 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
6007 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
6008 - inode->i_uid = fattr->uid;
6010 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
6011 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
6012 | NFS_INO_INVALID_ACCESS
6013 | NFS_INO_INVALID_ACL;
6014 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
6015 - inode->i_gid = fattr->gid;
6017 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
6018 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
6019 | NFS_INO_INVALID_ACCESS
6020 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
6022 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
6024 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6025 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6026 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6027 + /* maybe fattr->xid someday */
6029 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
6030 nfsi->attrtimeo_timestamp = now;
6031 nfsi->access_cache = RB_ROOT;
6032 @@ -496,6 +504,8 @@ void nfs_setattr_update_inode(struct ino
6033 inode->i_uid = attr->ia_uid;
6034 if ((attr->ia_valid & ATTR_GID) != 0)
6035 inode->i_gid = attr->ia_gid;
6036 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
6037 + inode->i_tag = attr->ia_tag;
6038 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
6039 spin_unlock(&inode->i_lock);
6041 @@ -906,6 +916,9 @@ static int nfs_check_inode_attributes(st
6042 struct nfs_inode *nfsi = NFS_I(inode);
6043 loff_t cur_size, new_isize;
6044 unsigned long invalid = 0;
6050 /* Has the inode gone and changed behind our back? */
6051 @@ -929,13 +942,18 @@ static int nfs_check_inode_attributes(st
6052 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
6055 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
6056 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
6057 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
6059 /* Have any file permissions changed? */
6060 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
6061 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
6062 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
6063 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
6064 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
6065 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
6066 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
6067 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
6068 + /* maybe check for tag too? */
6070 /* Has the link count changed? */
6071 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
6072 @@ -1150,6 +1168,9 @@ static int nfs_update_inode(struct inode
6073 unsigned long invalid = 0;
6074 unsigned long now = jiffies;
6075 unsigned long save_cache_validity;
6080 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
6081 __func__, inode->i_sb->s_id, inode->i_ino,
6082 @@ -1252,6 +1273,9 @@ static int nfs_update_inode(struct inode
6083 | NFS_INO_REVAL_PAGECACHE
6084 | NFS_INO_REVAL_FORCED);
6086 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
6087 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
6088 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
6090 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
6091 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
6092 @@ -1273,9 +1297,9 @@ static int nfs_update_inode(struct inode
6093 | NFS_INO_REVAL_FORCED);
6095 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
6096 - if (inode->i_uid != fattr->uid) {
6097 + if (uid != fattr->uid) {
6098 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
6099 - inode->i_uid = fattr->uid;
6102 } else if (server->caps & NFS_CAP_OWNER)
6103 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
6104 @@ -1284,9 +1308,9 @@ static int nfs_update_inode(struct inode
6105 | NFS_INO_REVAL_FORCED);
6107 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
6108 - if (inode->i_gid != fattr->gid) {
6109 + if (gid != fattr->gid) {
6110 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
6111 - inode->i_gid = fattr->gid;
6114 } else if (server->caps & NFS_CAP_OWNER_GROUP)
6115 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
6116 @@ -1294,6 +1318,10 @@ static int nfs_update_inode(struct inode
6117 | NFS_INO_INVALID_ACL
6118 | NFS_INO_REVAL_FORCED);
6120 + inode->i_uid = uid;
6121 + inode->i_gid = gid;
6122 + inode->i_tag = tag;
6124 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
6125 if (inode->i_nlink != fattr->nlink) {
6126 invalid |= NFS_INO_INVALID_ATTR;
6127 diff -NurpP --minimal linux-2.6.33/fs/nfs/nfs3xdr.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/nfs3xdr.c
6128 --- linux-2.6.33/fs/nfs/nfs3xdr.c 2009-12-03 20:02:52.000000000 +0100
6129 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/nfs3xdr.c 2010-02-25 12:02:16.000000000 +0100
6131 #include <linux/nfs3.h>
6132 #include <linux/nfs_fs.h>
6133 #include <linux/nfsacl.h>
6134 +#include <linux/vs_tag.h>
6135 #include "internal.h"
6137 #define NFSDBG_FACILITY NFSDBG_XDR
6138 @@ -176,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
6141 static inline __be32 *
6142 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
6143 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
6145 if (attr->ia_valid & ATTR_MODE) {
6147 @@ -184,15 +185,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
6151 - if (attr->ia_valid & ATTR_UID) {
6152 + if (attr->ia_valid & ATTR_UID ||
6153 + (tag && (attr->ia_valid & ATTR_TAG))) {
6155 - *p++ = htonl(attr->ia_uid);
6156 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
6160 - if (attr->ia_valid & ATTR_GID) {
6161 + if (attr->ia_valid & ATTR_GID ||
6162 + (tag && (attr->ia_valid & ATTR_TAG))) {
6164 - *p++ = htonl(attr->ia_gid);
6165 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
6169 @@ -279,7 +282,8 @@ static int
6170 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
6172 p = xdr_encode_fhandle(p, args->fh);
6173 - p = xdr_encode_sattr(p, args->sattr);
6174 + p = xdr_encode_sattr(p, args->sattr,
6175 + req->rq_task->tk_client->cl_tag);
6176 *p++ = htonl(args->guard);
6178 p = xdr_encode_time3(p, &args->guardtime);
6179 @@ -384,7 +388,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
6180 *p++ = args->verifier[0];
6181 *p++ = args->verifier[1];
6183 - p = xdr_encode_sattr(p, args->sattr);
6184 + p = xdr_encode_sattr(p, args->sattr,
6185 + req->rq_task->tk_client->cl_tag);
6187 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6189 @@ -398,7 +403,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
6191 p = xdr_encode_fhandle(p, args->fh);
6192 p = xdr_encode_array(p, args->name, args->len);
6193 - p = xdr_encode_sattr(p, args->sattr);
6194 + p = xdr_encode_sattr(p, args->sattr,
6195 + req->rq_task->tk_client->cl_tag);
6196 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6199 @@ -411,7 +417,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6201 p = xdr_encode_fhandle(p, args->fromfh);
6202 p = xdr_encode_array(p, args->fromname, args->fromlen);
6203 - p = xdr_encode_sattr(p, args->sattr);
6204 + p = xdr_encode_sattr(p, args->sattr,
6205 + req->rq_task->tk_client->cl_tag);
6206 *p++ = htonl(args->pathlen);
6207 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6209 @@ -429,7 +436,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6210 p = xdr_encode_fhandle(p, args->fh);
6211 p = xdr_encode_array(p, args->name, args->len);
6212 *p++ = htonl(args->type);
6213 - p = xdr_encode_sattr(p, args->sattr);
6214 + p = xdr_encode_sattr(p, args->sattr,
6215 + req->rq_task->tk_client->cl_tag);
6216 if (args->type == NF3CHR || args->type == NF3BLK) {
6217 *p++ = htonl(MAJOR(args->rdev));
6218 *p++ = htonl(MINOR(args->rdev));
6219 diff -NurpP --minimal linux-2.6.33/fs/nfs/nfsroot.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/nfsroot.c
6220 --- linux-2.6.33/fs/nfs/nfsroot.c 2009-09-10 15:26:23.000000000 +0200
6221 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/nfsroot.c 2010-02-25 12:02:16.000000000 +0100
6222 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0; /
6224 /* Options that take integer arguments */
6225 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6226 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6227 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6228 /* Options that take no arguments */
6229 Opt_soft, Opt_hard, Opt_intr,
6230 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6231 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6232 - Opt_acl, Opt_noacl,
6233 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6237 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
6240 {Opt_noacl, "noacl"},
6242 + {Opt_notag, "notag"},
6243 + {Opt_tagid, "tagid=%u"},
6247 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
6249 nfs_data.flags |= NFS_MOUNT_NOACL;
6251 +#ifndef CONFIG_TAGGING_NONE
6253 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6256 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6259 +#ifdef CONFIG_PROPAGATE
6262 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6266 printk(KERN_WARNING "Root-NFS: unknown "
6268 diff -NurpP --minimal linux-2.6.33/fs/nfs/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/super.c
6269 --- linux-2.6.33/fs/nfs/super.c 2010-02-25 11:52:05.000000000 +0100
6270 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfs/super.c 2010-02-25 12:02:16.000000000 +0100
6272 #include <linux/nfs_xdr.h>
6273 #include <linux/magic.h>
6274 #include <linux/parser.h>
6275 +#include <linux/vs_tag.h>
6277 #include <asm/system.h>
6278 #include <asm/uaccess.h>
6279 @@ -585,6 +586,7 @@ static void nfs_show_mount_options(struc
6280 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6281 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6282 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6283 + { NFS_MOUNT_TAGGED, ",tag", "" },
6286 const struct proc_nfs_info *nfs_infop;
6287 diff -NurpP --minimal linux-2.6.33/fs/nfsd/auth.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/auth.c
6288 --- linux-2.6.33/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
6289 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/auth.c 2010-02-25 13:17:41.000000000 +0100
6291 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
6293 #include <linux/sched.h>
6294 +#include <linux/vs_tag.h>
6298 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6300 new->fsuid = rqstp->rq_cred.cr_uid;
6301 new->fsgid = rqstp->rq_cred.cr_gid;
6302 + /* FIXME: this desperately needs a tag :)
6303 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6306 rqgi = rqstp->rq_cred.cr_group_info;
6308 diff -NurpP --minimal linux-2.6.33/fs/nfsd/nfs3xdr.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/nfs3xdr.c
6309 --- linux-2.6.33/fs/nfsd/nfs3xdr.c 2010-02-25 11:52:05.000000000 +0100
6310 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/nfs3xdr.c 2010-02-25 13:18:45.000000000 +0100
6314 #include <linux/namei.h>
6315 +#include <linux/vs_tag.h>
6319 @@ -95,6 +96,8 @@ static __be32 *
6320 decode_sattr3(__be32 *p, struct iattr *iap)
6328 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6331 iap->ia_valid |= ATTR_UID;
6332 - iap->ia_uid = ntohl(*p++);
6333 + uid = ntohl(*p++);
6336 iap->ia_valid |= ATTR_GID;
6337 - iap->ia_gid = ntohl(*p++);
6338 + gid = ntohl(*p++);
6340 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6341 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6342 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6346 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6347 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6348 *p++ = htonl((u32) stat->mode);
6349 *p++ = htonl((u32) stat->nlink);
6350 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6351 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6352 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6353 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6354 + stat->uid, stat->tag)));
6355 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6356 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6357 + stat->gid, stat->tag)));
6358 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6359 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6361 diff -NurpP --minimal linux-2.6.33/fs/nfsd/nfs4xdr.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/nfs4xdr.c
6362 --- linux-2.6.33/fs/nfsd/nfs4xdr.c 2010-02-25 11:52:05.000000000 +0100
6363 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/nfs4xdr.c 2010-02-25 12:02:16.000000000 +0100
6365 #include <linux/nfsd_idmap.h>
6366 #include <linux/nfs4_acl.h>
6367 #include <linux/sunrpc/svcauth_gss.h>
6368 +#include <linux/vs_tag.h>
6372 @@ -2042,14 +2043,18 @@ out_acl:
6373 WRITE32(stat.nlink);
6375 if (bmval1 & FATTR4_WORD1_OWNER) {
6376 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6377 + status = nfsd4_encode_user(rqstp,
6378 + TAGINO_UID(DX_TAG(dentry->d_inode),
6379 + stat.uid, stat.tag), &p, &buflen);
6380 if (status == nfserr_resource)
6385 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6386 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6387 + status = nfsd4_encode_group(rqstp,
6388 + TAGINO_GID(DX_TAG(dentry->d_inode),
6389 + stat.gid, stat.tag), &p, &buflen);
6390 if (status == nfserr_resource)
6393 diff -NurpP --minimal linux-2.6.33/fs/nfsd/nfsxdr.c linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/nfsxdr.c
6394 --- linux-2.6.33/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6395 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/nfsd/nfsxdr.c 2010-02-25 13:18:10.000000000 +0100
6400 +#include <linux/vs_tag.h>
6402 #define NFSDDBG_FACILITY NFSDDBG_XDR
6404 @@ -88,6 +89,8 @@ static __be32 *
6405 decode_sattr(__be32 *p, struct iattr *iap)
6413 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6415 if ((tmp = ntohl(*p++)) != (u32)-1) {
6416 iap->ia_valid |= ATTR_UID;
6417 - iap->ia_uid = tmp;
6420 if ((tmp = ntohl(*p++)) != (u32)-1) {
6421 iap->ia_valid |= ATTR_GID;
6422 - iap->ia_gid = tmp;
6425 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6426 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6427 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6428 if ((tmp = ntohl(*p++)) != (u32)-1) {
6429 iap->ia_valid |= ATTR_SIZE;
6431 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6432 *p++ = htonl(nfs_ftypes[type >> 12]);
6433 *p++ = htonl((u32) stat->mode);
6434 *p++ = htonl((u32) stat->nlink);
6435 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6436 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6437 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6438 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6439 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6440 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6442 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6443 *p++ = htonl(NFS_MAXPATHLEN);
6444 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/dlm/dlmfs.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/dlm/dlmfs.c
6445 --- linux-2.6.33/fs/ocfs2/dlm/dlmfs.c 2009-12-03 20:02:53.000000000 +0100
6446 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/dlm/dlmfs.c 2010-02-25 12:02:16.000000000 +0100
6448 #include <linux/init.h>
6449 #include <linux/string.h>
6450 #include <linux/backing-dev.h>
6451 +#include <linux/vs_tag.h>
6453 #include <asm/uaccess.h>
6455 @@ -342,6 +343,7 @@ static struct inode *dlmfs_get_root_inod
6456 inode->i_mode = mode;
6457 inode->i_uid = current_fsuid();
6458 inode->i_gid = current_fsgid();
6459 + inode->i_tag = dx_current_fstag(sb);
6460 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6461 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6463 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6464 inode->i_mode = mode;
6465 inode->i_uid = current_fsuid();
6466 inode->i_gid = current_fsgid();
6467 + inode->i_tag = dx_current_fstag(sb);
6468 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6469 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6471 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/dlmglue.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/dlmglue.c
6472 --- linux-2.6.33/fs/ocfs2/dlmglue.c 2010-02-25 11:52:06.000000000 +0100
6473 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/dlmglue.c 2010-02-25 12:02:16.000000000 +0100
6474 @@ -2023,6 +2023,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6475 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6476 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6477 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6478 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6479 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6480 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6481 lvb->lvb_iatime_packed =
6482 @@ -2077,6 +2078,7 @@ static void ocfs2_refresh_inode_from_lvb
6484 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6485 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6486 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6487 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6488 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6489 ocfs2_unpack_timespec(&inode->i_atime,
6490 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/dlmglue.h linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/dlmglue.h
6491 --- linux-2.6.33/fs/ocfs2/dlmglue.h 2009-12-03 20:02:53.000000000 +0100
6492 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/dlmglue.h 2010-02-25 12:02:16.000000000 +0100
6493 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6496 __be32 lvb_igeneration;
6497 - __be32 lvb_reserved2;
6499 + __be16 lvb_reserved2;
6502 #define OCFS2_QINFO_LVB_VERSION 1
6503 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/file.c
6504 --- linux-2.6.33/fs/ocfs2/file.c 2010-02-25 11:52:06.000000000 +0100
6505 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/file.c 2010-02-25 12:02:16.000000000 +0100
6506 @@ -960,13 +960,15 @@ int ocfs2_setattr(struct dentry *dentry,
6507 mlog(0, "uid change: %d\n", attr->ia_uid);
6508 if (attr->ia_valid & ATTR_GID)
6509 mlog(0, "gid change: %d\n", attr->ia_gid);
6510 + if (attr->ia_valid & ATTR_TAG)
6511 + mlog(0, "tag change: %d\n", attr->ia_tag);
6512 if (attr->ia_valid & ATTR_SIZE)
6513 mlog(0, "size change...\n");
6514 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6515 mlog(0, "time change...\n");
6517 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6518 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6519 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6520 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6521 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6523 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/inode.c
6524 --- linux-2.6.33/fs/ocfs2/inode.c 2010-02-25 11:52:06.000000000 +0100
6525 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/inode.c 2010-02-25 12:02:16.000000000 +0100
6527 #include <linux/highmem.h>
6528 #include <linux/pagemap.h>
6529 #include <linux/quotaops.h>
6530 +#include <linux/vs_tag.h>
6532 #include <asm/byteorder.h>
6534 @@ -79,11 +80,13 @@ void ocfs2_set_inode_flags(struct inode
6536 unsigned int flags = OCFS2_I(inode)->ip_attr;
6538 - inode->i_flags &= ~(S_IMMUTABLE |
6539 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6540 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6542 if (flags & OCFS2_IMMUTABLE_FL)
6543 inode->i_flags |= S_IMMUTABLE;
6544 + if (flags & OCFS2_IXUNLINK_FL)
6545 + inode->i_flags |= S_IXUNLINK;
6547 if (flags & OCFS2_SYNC_FL)
6548 inode->i_flags |= S_SYNC;
6549 @@ -93,25 +96,44 @@ void ocfs2_set_inode_flags(struct inode
6550 inode->i_flags |= S_NOATIME;
6551 if (flags & OCFS2_DIRSYNC_FL)
6552 inode->i_flags |= S_DIRSYNC;
6554 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6556 + if (flags & OCFS2_BARRIER_FL)
6557 + inode->i_vflags |= V_BARRIER;
6558 + if (flags & OCFS2_COW_FL)
6559 + inode->i_vflags |= V_COW;
6562 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6563 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6565 unsigned int flags = oi->vfs_inode.i_flags;
6566 + unsigned int vflags = oi->vfs_inode.i_vflags;
6568 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6569 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6570 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6571 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6573 + if (flags & S_IMMUTABLE)
6574 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6575 + if (flags & S_IXUNLINK)
6576 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6578 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6579 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6581 oi->ip_attr |= OCFS2_SYNC_FL;
6582 if (flags & S_APPEND)
6583 oi->ip_attr |= OCFS2_APPEND_FL;
6584 - if (flags & S_IMMUTABLE)
6585 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6586 if (flags & S_NOATIME)
6587 oi->ip_attr |= OCFS2_NOATIME_FL;
6588 if (flags & S_DIRSYNC)
6589 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6591 + if (vflags & V_BARRIER)
6592 + oi->ip_attr |= OCFS2_BARRIER_FL;
6593 + if (vflags & V_COW)
6594 + oi->ip_attr |= OCFS2_COW_FL;
6597 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6598 @@ -246,6 +268,8 @@ void ocfs2_populate_inode(struct inode *
6599 struct super_block *sb;
6600 struct ocfs2_super *osb;
6605 mlog_entry("(0x%p, size:%llu)\n", inode,
6606 (unsigned long long)le64_to_cpu(fe->i_size));
6607 @@ -277,8 +301,12 @@ void ocfs2_populate_inode(struct inode *
6608 inode->i_generation = le32_to_cpu(fe->i_generation);
6609 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6610 inode->i_mode = le16_to_cpu(fe->i_mode);
6611 - inode->i_uid = le32_to_cpu(fe->i_uid);
6612 - inode->i_gid = le32_to_cpu(fe->i_gid);
6613 + uid = le32_to_cpu(fe->i_uid);
6614 + gid = le32_to_cpu(fe->i_gid);
6615 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6616 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6617 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6618 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6620 /* Fast symlinks will have i_size but no allocated clusters. */
6621 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6622 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/inode.h linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/inode.h
6623 --- linux-2.6.33/fs/ocfs2/inode.h 2009-12-03 20:02:53.000000000 +0100
6624 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/inode.h 2010-02-25 12:02:16.000000000 +0100
6625 @@ -150,6 +150,7 @@ struct buffer_head *ocfs2_bread(struct i
6627 void ocfs2_set_inode_flags(struct inode *inode);
6628 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6629 +int ocfs2_sync_flags(struct inode *inode, int, int);
6631 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6633 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/ioctl.c
6634 --- linux-2.6.33/fs/ocfs2/ioctl.c 2010-02-25 11:52:06.000000000 +0100
6635 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/ioctl.c 2010-02-25 12:02:16.000000000 +0100
6636 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
6640 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6641 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6643 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6644 + struct buffer_head *bh = NULL;
6645 + handle_t *handle = NULL;
6648 + status = ocfs2_inode_lock(inode, &bh, 1);
6650 + mlog_errno(status);
6653 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6654 + if (IS_ERR(handle)) {
6655 + status = PTR_ERR(handle);
6656 + mlog_errno(status);
6660 + inode->i_flags = flags;
6661 + inode->i_vflags = vflags;
6662 + ocfs2_get_inode_flags(OCFS2_I(inode));
6664 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6666 + mlog_errno(status);
6668 + ocfs2_commit_trans(osb, handle);
6670 + ocfs2_inode_unlock(inode, 1);
6675 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6678 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6679 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
6680 if (!S_ISDIR(inode->i_mode))
6681 flags &= ~OCFS2_DIRSYNC_FL;
6683 + if (IS_BARRIER(inode)) {
6684 + vxwprintk_task(1, "messing with the barrier.");
6688 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6689 if (IS_ERR(handle)) {
6690 status = PTR_ERR(handle);
6691 @@ -109,6 +148,7 @@ bail:
6696 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6698 struct inode *inode = filp->f_path.dentry->d_inode;
6699 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/namei.c
6700 --- linux-2.6.33/fs/ocfs2/namei.c 2010-02-25 11:52:06.000000000 +0100
6701 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/namei.c 2010-02-25 12:02:16.000000000 +0100
6703 #include <linux/slab.h>
6704 #include <linux/highmem.h>
6705 #include <linux/quotaops.h>
6706 +#include <linux/vs_tag.h>
6708 #define MLOG_MASK_PREFIX ML_NAMEI
6709 #include <cluster/masklog.h>
6710 @@ -481,6 +482,7 @@ static int ocfs2_mknod_locked(struct ocf
6718 @@ -524,8 +526,11 @@ static int ocfs2_mknod_locked(struct ocf
6719 fe->i_blkno = cpu_to_le64(fe_blkno);
6720 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6721 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6722 - fe->i_uid = cpu_to_le32(inode->i_uid);
6723 - fe->i_gid = cpu_to_le32(inode->i_gid);
6725 + tag = dx_current_fstag(osb->sb);
6726 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6727 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6728 + inode->i_tag = tag;
6729 fe->i_mode = cpu_to_le16(inode->i_mode);
6730 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6731 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6732 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/ocfs2_fs.h linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/ocfs2_fs.h
6733 --- linux-2.6.33/fs/ocfs2/ocfs2_fs.h 2010-02-25 11:52:06.000000000 +0100
6734 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/ocfs2_fs.h 2010-02-25 12:02:16.000000000 +0100
6735 @@ -231,18 +231,23 @@
6736 #define OCFS2_HAS_REFCOUNT_FL (0x0010)
6738 /* Inode attributes, keep in sync with EXT2 */
6739 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6740 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6741 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6742 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6743 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6744 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6745 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6746 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6747 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6748 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6749 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6750 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6751 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6752 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6753 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6754 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6755 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6757 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6758 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6759 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6760 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6762 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6763 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6765 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6766 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6769 * Extent record flags (e_node.leaf.flags)
6770 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/ocfs2.h linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/ocfs2.h
6771 --- linux-2.6.33/fs/ocfs2/ocfs2.h 2010-02-25 11:52:06.000000000 +0100
6772 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/ocfs2.h 2010-02-25 13:22:33.000000000 +0100
6773 @@ -254,6 +254,7 @@ enum ocfs2_mount_options
6775 OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
6776 OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
6777 + OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
6780 #define OCFS2_OSB_SOFT_RO 0x0001
6781 diff -NurpP --minimal linux-2.6.33/fs/ocfs2/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/super.c
6782 --- linux-2.6.33/fs/ocfs2/super.c 2010-02-25 11:52:06.000000000 +0100
6783 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/ocfs2/super.c 2010-02-25 13:23:24.000000000 +0100
6784 @@ -175,6 +175,7 @@ enum {
6788 + Opt_tag, Opt_notag, Opt_tagid,
6792 @@ -201,6 +202,9 @@ static const match_table_t tokens = {
6793 {Opt_noacl, "noacl"},
6794 {Opt_usrquota, "usrquota"},
6795 {Opt_grpquota, "grpquota"},
6797 + {Opt_notag, "notag"},
6798 + {Opt_tagid, "tagid=%u"},
6802 @@ -608,6 +612,13 @@ static int ocfs2_remount(struct super_bl
6806 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6807 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6809 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6813 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6814 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6816 @@ -1138,6 +1149,9 @@ static int ocfs2_fill_super(struct super
6818 ocfs2_complete_mount_recovery(osb);
6820 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6821 + sb->s_flags |= MS_TAGGED;
6823 if (ocfs2_mount_local(osb))
6824 snprintf(nodestr, sizeof(nodestr), "local");
6826 @@ -1429,6 +1443,20 @@ static int ocfs2_parse_options(struct su
6827 mopt->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL;
6828 mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
6830 +#ifndef CONFIG_TAGGING_NONE
6832 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6835 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6838 +#ifdef CONFIG_PROPAGATE
6841 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6846 "Unrecognized mount option \"%s\" "
6847 diff -NurpP --minimal linux-2.6.33/fs/open.c linux-2.6.33-vs2.3.0.36.30.1/fs/open.c
6848 --- linux-2.6.33/fs/open.c 2010-02-25 11:52:06.000000000 +0100
6849 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/open.c 2010-02-25 13:17:13.000000000 +0100
6851 #include <linux/falloc.h>
6852 #include <linux/fs_struct.h>
6853 #include <linux/ima.h>
6854 +#include <linux/vs_base.h>
6855 +#include <linux/vs_limit.h>
6856 +#include <linux/vs_tag.h>
6857 +#include <linux/vs_cowbl.h>
6859 #include "internal.h"
6861 @@ -39,16 +43,20 @@ int vfs_statfs(struct dentry *dentry, st
6862 int retval = -ENODEV;
6865 + struct super_block *sb = dentry->d_sb;
6868 - if (dentry->d_sb->s_op->statfs) {
6869 + if (sb->s_op->statfs) {
6870 memset(buf, 0, sizeof(*buf));
6871 retval = security_sb_statfs(dentry);
6874 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6875 + retval = sb->s_op->statfs(dentry, buf);
6876 if (retval == 0 && buf->f_frsize == 0)
6877 buf->f_frsize = buf->f_bsize;
6879 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6880 + vx_vsi_statfs(sb, buf);
6884 @@ -650,6 +658,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6885 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6889 + error = cow_check_and_break(&path);
6891 + goto dput_and_out;
6892 inode = path.dentry->d_inode;
6894 error = mnt_want_write(path.mnt);
6895 @@ -687,11 +699,11 @@ static int chown_common(struct path *pat
6896 newattrs.ia_valid = ATTR_CTIME;
6897 if (user != (uid_t) -1) {
6898 newattrs.ia_valid |= ATTR_UID;
6899 - newattrs.ia_uid = user;
6900 + newattrs.ia_uid = dx_map_uid(user);
6902 if (group != (gid_t) -1) {
6903 newattrs.ia_valid |= ATTR_GID;
6904 - newattrs.ia_gid = group;
6905 + newattrs.ia_gid = dx_map_gid(group);
6907 if (!S_ISDIR(inode->i_mode))
6908 newattrs.ia_valid |=
6909 @@ -716,6 +728,10 @@ SYSCALL_DEFINE3(chown, const char __user
6910 error = mnt_want_write(path.mnt);
6913 +#ifdef CONFIG_VSERVER_COWBL
6914 + error = cow_check_and_break(&path);
6917 error = chown_common(&path, user, group);
6918 mnt_drop_write(path.mnt);
6920 @@ -741,6 +757,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6921 error = mnt_want_write(path.mnt);
6924 +#ifdef CONFIG_VSERVER_COWBL
6925 + error = cow_check_and_break(&path);
6928 error = chown_common(&path, user, group);
6929 mnt_drop_write(path.mnt);
6931 @@ -760,6 +780,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6932 error = mnt_want_write(path.mnt);
6935 +#ifdef CONFIG_VSERVER_COWBL
6936 + error = cow_check_and_break(&path);
6939 error = chown_common(&path, user, group);
6940 mnt_drop_write(path.mnt);
6942 @@ -1006,6 +1030,7 @@ static void __put_unused_fd(struct files
6943 __FD_CLR(fd, fdt->open_fds);
6944 if (fd < files->next_fd)
6945 files->next_fd = fd;
6946 + vx_openfd_dec(fd);
6949 void put_unused_fd(unsigned int fd)
6950 diff -NurpP --minimal linux-2.6.33/fs/proc/array.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/array.c
6951 --- linux-2.6.33/fs/proc/array.c 2010-02-25 11:52:06.000000000 +0100
6952 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/array.c 2010-02-25 12:02:16.000000000 +0100
6954 #include <linux/ptrace.h>
6955 #include <linux/tracehook.h>
6956 #include <linux/swapops.h>
6957 +#include <linux/vs_context.h>
6958 +#include <linux/vs_network.h>
6960 #include <asm/pgtable.h>
6961 #include <asm/processor.h>
6962 @@ -172,6 +174,9 @@ static inline void task_state(struct seq
6964 ppid = pid_alive(p) ?
6965 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6966 + if (unlikely(vx_current_initpid(p->pid)))
6971 struct task_struct *tracer = tracehook_tracer_task(p);
6972 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6975 static void render_cap_t(struct seq_file *m, const char *header,
6977 + struct vx_info *vxi, kernel_cap_t *a)
6981 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6982 cap_bset = cred->cap_bset;
6985 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6986 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6987 - render_cap_t(m, "CapEff:\t", &cap_effective);
6988 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6989 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6990 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6991 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6992 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6993 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6996 static inline void task_context_switch_counts(struct seq_file *m,
6997 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6998 seq_printf(m, "\n");
7001 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7002 + struct pid *pid, struct task_struct *task)
7004 + seq_printf(m, "Proxy:\t%p(%c)\n"
7012 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
7013 + atomic_read(&task->nsproxy->count),
7014 + task->nsproxy->uts_ns,
7015 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
7016 + task->nsproxy->ipc_ns,
7017 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
7018 + task->nsproxy->mnt_ns,
7019 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
7020 + task->nsproxy->pid_ns,
7021 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
7022 + task->nsproxy->net_ns,
7023 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
7027 +void task_vs_id(struct seq_file *m, struct task_struct *task)
7029 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
7032 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
7033 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
7037 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
7038 struct pid *pid, struct task_struct *task)
7040 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
7042 task_cpus_allowed(m, task);
7043 cpuset_task_status_allowed(m, task);
7044 + task_vs_id(m, task);
7045 #if defined(CONFIG_S390)
7046 task_show_regs(m, task);
7048 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file
7049 /* convert nsec -> ticks */
7050 start_time = nsec_to_clock_t(start_time);
7052 + /* fixup start time for virt uptime */
7053 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
7054 + unsigned long long bias =
7055 + current->vx_info->cvirt.bias_clock;
7057 + if (start_time > bias)
7058 + start_time -= bias;
7063 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
7064 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
7065 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
7066 diff -NurpP --minimal linux-2.6.33/fs/proc/base.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/base.c
7067 --- linux-2.6.33/fs/proc/base.c 2010-02-25 11:52:06.000000000 +0100
7068 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/base.c 2010-02-25 12:02:16.000000000 +0100
7070 #include <linux/elf.h>
7071 #include <linux/pid_namespace.h>
7072 #include <linux/fs_struct.h>
7073 +#include <linux/vs_context.h>
7074 +#include <linux/vs_network.h>
7075 #include "internal.h"
7078 @@ -1047,12 +1049,17 @@ static ssize_t oom_adjust_write(struct f
7082 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
7083 + if (oom_adjust < task->signal->oom_adj &&
7084 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
7085 unlock_task_sighand(task, &flags);
7086 put_task_struct(task);
7090 + /* prevent guest processes from circumventing the oom killer */
7091 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
7092 + oom_adjust = OOM_ADJUST_MIN;
7094 task->signal->oom_adj = oom_adjust;
7096 unlock_task_sighand(task, &flags);
7097 @@ -1092,7 +1099,7 @@ static ssize_t proc_loginuid_write(struc
7101 - if (!capable(CAP_AUDIT_CONTROL))
7102 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
7105 if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
7106 @@ -1523,6 +1530,8 @@ static struct inode *proc_pid_make_inode
7107 inode->i_gid = cred->egid;
7110 + /* procfs is xid tagged */
7111 + inode->i_tag = (tag_t)vx_task_xid(task);
7112 security_task_to_inode(task, inode);
7115 @@ -2073,6 +2082,13 @@ static struct dentry *proc_pident_lookup
7119 + /* TODO: maybe we can come up with a generic approach? */
7120 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
7121 + (dentry->d_name.len == 5) &&
7122 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
7123 + !memcmp(dentry->d_name.name, "ninfo", 5)))
7127 * Yes, it does not scale. And it should not. Don't add
7128 * new entries into /proc/<tgid>/ without very good reasons.
7129 @@ -2478,7 +2494,7 @@ out_iput:
7130 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
7132 struct dentry *error;
7133 - struct task_struct *task = get_proc_task(dir);
7134 + struct task_struct *task = get_proc_task_real(dir);
7135 const struct pid_entry *p, *last;
7137 error = ERR_PTR(-ENOENT);
7138 @@ -2568,6 +2584,9 @@ static int proc_pid_personality(struct s
7139 static const struct file_operations proc_task_operations;
7140 static const struct inode_operations proc_task_inode_operations;
7142 +extern int proc_pid_vx_info(struct task_struct *, char *);
7143 +extern int proc_pid_nx_info(struct task_struct *, char *);
7145 static const struct pid_entry tgid_base_stuff[] = {
7146 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
7147 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
7148 @@ -2627,6 +2646,8 @@ static const struct pid_entry tgid_base_
7149 #ifdef CONFIG_CGROUPS
7150 REG("cgroup", S_IRUGO, proc_cgroup_operations),
7152 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
7153 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
7154 INF("oom_score", S_IRUGO, proc_oom_score),
7155 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
7156 #ifdef CONFIG_AUDITSYSCALL
7157 @@ -2642,6 +2663,7 @@ static const struct pid_entry tgid_base_
7158 #ifdef CONFIG_TASK_IO_ACCOUNTING
7159 INF("io", S_IRUGO, proc_tgid_io_accounting),
7161 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
7164 static int proc_tgid_base_readdir(struct file * filp,
7165 @@ -2833,7 +2855,7 @@ retry:
7167 pid = find_ge_pid(iter.tgid, ns);
7169 - iter.tgid = pid_nr_ns(pid, ns);
7170 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
7171 iter.task = pid_task(pid, PIDTYPE_PID);
7172 /* What we to know is if the pid we have find is the
7173 * pid of a thread_group_leader. Testing for task
7174 @@ -2863,7 +2885,7 @@ static int proc_pid_fill_cache(struct fi
7175 struct tgid_iter iter)
7177 char name[PROC_NUMBUF];
7178 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7179 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7180 return proc_fill_cache(filp, dirent, filldir, name, len,
7181 proc_pid_instantiate, iter.task, NULL);
7183 @@ -2872,7 +2894,7 @@ static int proc_pid_fill_cache(struct fi
7184 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7186 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7187 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7188 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7189 struct tgid_iter iter;
7190 struct pid_namespace *ns;
7192 @@ -2892,6 +2914,8 @@ int proc_pid_readdir(struct file * filp,
7194 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7195 filp->f_pos = iter.tgid + TGID_OFFSET;
7196 + if (!vx_proc_task_visible(iter.task))
7198 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7199 put_task_struct(iter.task);
7201 @@ -3039,6 +3063,8 @@ static struct dentry *proc_task_lookup(s
7202 tid = name_to_int(dentry);
7205 + if (vx_current_initpid(tid))
7208 ns = dentry->d_sb->s_fs_info;
7210 diff -NurpP --minimal linux-2.6.33/fs/proc/generic.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/generic.c
7211 --- linux-2.6.33/fs/proc/generic.c 2010-02-25 11:52:06.000000000 +0100
7212 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/generic.c 2010-02-25 13:20:40.000000000 +0100
7214 #include <linux/bitops.h>
7215 #include <linux/spinlock.h>
7216 #include <linux/completion.h>
7217 +#include <linux/vserver/inode.h>
7218 #include <asm/uaccess.h>
7220 #include "internal.h"
7221 @@ -425,6 +426,8 @@ struct dentry *proc_lookup_de(struct pro
7222 for (de = de->subdir; de ; de = de->next) {
7223 if (de->namelen != dentry->d_name.len)
7225 + if (!vx_hide_check(0, de->vx_flags))
7227 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7230 @@ -433,6 +436,8 @@ struct dentry *proc_lookup_de(struct pro
7231 spin_unlock(&proc_subdir_lock);
7233 inode = proc_get_inode(dir->i_sb, ino, de);
7234 + /* generic proc entries belong to the host */
7239 @@ -510,6 +515,8 @@ int proc_readdir_de(struct proc_dir_entr
7241 /* filldir passes info to user space */
7243 + if (!vx_hide_check(0, de->vx_flags))
7245 spin_unlock(&proc_subdir_lock);
7246 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7247 de->low_ino, de->mode >> 12) < 0) {
7248 @@ -517,6 +524,7 @@ int proc_readdir_de(struct proc_dir_entr
7251 spin_lock(&proc_subdir_lock);
7256 @@ -631,6 +639,7 @@ static struct proc_dir_entry *__proc_cre
7258 atomic_set(&ent->count, 1);
7260 + ent->vx_flags = IATTR_PROC_DEFAULT;
7261 spin_lock_init(&ent->pde_unload_lock);
7262 ent->pde_unload_completion = NULL;
7263 INIT_LIST_HEAD(&ent->pde_openers);
7264 @@ -654,7 +663,8 @@ struct proc_dir_entry *proc_symlink(cons
7270 + ent->vx_flags = IATTR_PROC_SYMLINK;
7274 diff -NurpP --minimal linux-2.6.33/fs/proc/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/inode.c
7275 --- linux-2.6.33/fs/proc/inode.c 2010-02-25 11:52:06.000000000 +0100
7276 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/inode.c 2010-02-25 12:02:16.000000000 +0100
7277 @@ -436,6 +436,8 @@ struct inode *proc_get_inode(struct supe
7278 inode->i_uid = de->uid;
7279 inode->i_gid = de->gid;
7282 + PROC_I(inode)->vx_flags = de->vx_flags;
7284 inode->i_size = de->size;
7286 diff -NurpP --minimal linux-2.6.33/fs/proc/internal.h linux-2.6.33-vs2.3.0.36.30.1/fs/proc/internal.h
7287 --- linux-2.6.33/fs/proc/internal.h 2010-02-25 11:52:06.000000000 +0100
7288 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/internal.h 2010-02-25 12:02:16.000000000 +0100
7292 #include <linux/proc_fs.h>
7293 +#include <linux/vs_pid.h>
7295 extern struct proc_dir_entry proc_root;
7296 #ifdef CONFIG_PROC_SYSCTL
7297 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7298 struct pid *pid, struct task_struct *task);
7299 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7300 struct pid *pid, struct task_struct *task);
7301 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7302 + struct pid *pid, struct task_struct *task);
7304 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7306 extern const struct file_operations proc_maps_operations;
7307 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
7308 return PROC_I(inode)->pid;
7311 -static inline struct task_struct *get_proc_task(struct inode *inode)
7312 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7314 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7317 +static inline struct task_struct *get_proc_task(struct inode *inode)
7319 + return vx_get_proc_task(inode, proc_pid(inode));
7322 static inline int proc_fd(struct inode *inode)
7324 return PROC_I(inode)->fd;
7325 diff -NurpP --minimal linux-2.6.33/fs/proc/loadavg.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/loadavg.c
7326 --- linux-2.6.33/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7327 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/loadavg.c 2010-02-25 12:02:16.000000000 +0100
7330 static int loadavg_proc_show(struct seq_file *m, void *v)
7332 + unsigned long running;
7333 + unsigned int threads;
7334 unsigned long avnrun[3];
7336 get_avenrun(avnrun, FIXED_1/200, 0);
7338 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7339 + struct vx_info *vxi = current_vx_info();
7341 + running = atomic_read(&vxi->cvirt.nr_running);
7342 + threads = atomic_read(&vxi->cvirt.nr_threads);
7344 + running = nr_running();
7345 + threads = nr_threads;
7348 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7349 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7350 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7351 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7352 - nr_running(), nr_threads,
7354 task_active_pid_ns(current)->last_pid);
7357 diff -NurpP --minimal linux-2.6.33/fs/proc/meminfo.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/meminfo.c
7358 --- linux-2.6.33/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7359 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/meminfo.c 2010-02-25 12:02:16.000000000 +0100
7360 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7361 allowed = ((totalram_pages - hugetlb_total_pages())
7362 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7364 - cached = global_page_state(NR_FILE_PAGES) -
7365 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7366 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7367 total_swapcache_pages - i.bufferram;
7370 diff -NurpP --minimal linux-2.6.33/fs/proc/root.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/root.c
7371 --- linux-2.6.33/fs/proc/root.c 2009-06-11 17:13:07.000000000 +0200
7372 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/root.c 2010-02-25 12:02:16.000000000 +0100
7374 #include <linux/bitops.h>
7375 #include <linux/mount.h>
7376 #include <linux/pid_namespace.h>
7377 +#include <linux/vserver/inode.h>
7379 #include "internal.h"
7381 +struct proc_dir_entry *proc_virtual;
7383 +extern void proc_vx_init(void);
7385 static int proc_test_super(struct super_block *sb, void *data)
7387 return sb->s_fs_info == data;
7388 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
7390 proc_mkdir("bus", NULL);
7395 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7396 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7397 .proc_iops = &proc_root_inode_operations,
7398 .proc_fops = &proc_root_operations,
7399 .parent = &proc_root,
7400 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7403 int pid_ns_prepare_proc(struct pid_namespace *ns)
7404 diff -NurpP --minimal linux-2.6.33/fs/proc/uptime.c linux-2.6.33-vs2.3.0.36.30.1/fs/proc/uptime.c
7405 --- linux-2.6.33/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7406 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/proc/uptime.c 2010-02-25 12:02:16.000000000 +0100
7408 #include <linux/sched.h>
7409 #include <linux/seq_file.h>
7410 #include <linux/time.h>
7411 -#include <linux/kernel_stat.h>
7412 +#include <linux/vserver/cvirt.h>
7413 #include <asm/cputime.h>
7415 static int uptime_proc_show(struct seq_file *m, void *v)
7417 struct timespec uptime;
7418 struct timespec idle;
7420 - cputime_t idletime = cputime_zero;
7422 - for_each_possible_cpu(i)
7423 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7424 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7426 do_posix_clock_monotonic_gettime(&uptime);
7427 monotonic_to_bootbased(&uptime);
7428 cputime_to_timespec(idletime, &idle);
7430 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7431 + vx_vsi_uptime(&uptime, &idle);
7433 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7434 (unsigned long) uptime.tv_sec,
7435 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7436 diff -NurpP --minimal linux-2.6.33/fs/quota/quota.c linux-2.6.33-vs2.3.0.36.30.1/fs/quota/quota.c
7437 --- linux-2.6.33/fs/quota/quota.c 2010-02-25 11:52:06.000000000 +0100
7438 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/quota/quota.c 2010-02-25 13:25:13.000000000 +0100
7440 #include <linux/capability.h>
7441 #include <linux/quotaops.h>
7442 #include <linux/types.h>
7443 +#include <linux/vs_context.h>
7444 #include <net/netlink.h>
7445 #include <net/genetlink.h>
7447 @@ -85,11 +86,11 @@ static int generic_quotactl_valid(struct
7448 if (cmd == Q_GETQUOTA) {
7449 if (((type == USRQUOTA && current_euid() != id) ||
7450 (type == GRPQUOTA && !in_egroup_p(id))) &&
7451 - !capable(CAP_SYS_ADMIN))
7452 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7455 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7456 - if (!capable(CAP_SYS_ADMIN))
7457 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7461 @@ -137,10 +138,10 @@ static int xqm_quotactl_valid(struct sup
7462 if (cmd == Q_XGETQUOTA) {
7463 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7464 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7465 - !capable(CAP_SYS_ADMIN))
7466 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7468 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7469 - if (!capable(CAP_SYS_ADMIN))
7470 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7474 @@ -353,6 +354,46 @@ static int do_quotactl(struct super_bloc
7478 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7480 +#include <linux/vroot.h>
7481 +#include <linux/major.h>
7482 +#include <linux/module.h>
7483 +#include <linux/kallsyms.h>
7484 +#include <linux/vserver/debug.h>
7486 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7488 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7490 +int register_vroot_grb(vroot_grb_func *func) {
7493 + spin_lock(&vroot_grb_lock);
7494 + if (!vroot_get_real_bdev) {
7495 + vroot_get_real_bdev = func;
7498 + spin_unlock(&vroot_grb_lock);
7501 +EXPORT_SYMBOL(register_vroot_grb);
7503 +int unregister_vroot_grb(vroot_grb_func *func) {
7504 + int ret = -EINVAL;
7506 + spin_lock(&vroot_grb_lock);
7507 + if (vroot_get_real_bdev) {
7508 + vroot_get_real_bdev = NULL;
7511 + spin_unlock(&vroot_grb_lock);
7514 +EXPORT_SYMBOL(unregister_vroot_grb);
7519 * look up a superblock on which quota ops will be performed
7520 * - use the name of a block device to find the superblock thereon
7521 @@ -370,6 +411,22 @@ static struct super_block *quotactl_bloc
7524 return ERR_CAST(bdev);
7525 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7526 + if (bdev && bdev->bd_inode &&
7527 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7528 + struct block_device *bdnew = (void *)-EINVAL;
7530 + if (vroot_get_real_bdev)
7531 + bdnew = vroot_get_real_bdev(bdev);
7533 + vxdprintk(VXD_CBIT(misc, 0),
7534 + "vroot_get_real_bdev not set");
7536 + if (IS_ERR(bdnew))
7537 + return ERR_PTR(PTR_ERR(bdnew));
7541 sb = get_super(bdev);
7544 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/file.c linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/file.c
7545 --- linux-2.6.33/fs/reiserfs/file.c 2010-02-25 11:52:06.000000000 +0100
7546 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/file.c 2010-02-25 12:02:16.000000000 +0100
7547 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7548 .listxattr = reiserfs_listxattr,
7549 .removexattr = reiserfs_removexattr,
7550 .permission = reiserfs_permission,
7551 + .sync_flags = reiserfs_sync_flags,
7553 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/inode.c
7554 --- linux-2.6.33/fs/reiserfs/inode.c 2010-02-25 11:52:06.000000000 +0100
7555 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/inode.c 2010-02-25 12:02:16.000000000 +0100
7557 #include <linux/writeback.h>
7558 #include <linux/quotaops.h>
7559 #include <linux/swap.h>
7560 +#include <linux/vs_tag.h>
7562 int reiserfs_commit_write(struct file *f, struct page *page,
7563 unsigned from, unsigned to);
7564 @@ -1121,6 +1122,8 @@ static void init_inode(struct inode *ino
7565 struct buffer_head *bh;
7566 struct item_head *ih;
7570 //int version = ITEM_VERSION_1;
7572 bh = PATH_PLAST_BUFFER(path);
7573 @@ -1142,12 +1145,13 @@ static void init_inode(struct inode *ino
7574 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7575 unsigned long blocks;
7577 + uid = sd_v1_uid(sd);
7578 + gid = sd_v1_gid(sd);
7580 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7581 set_inode_sd_version(inode, STAT_DATA_V1);
7582 inode->i_mode = sd_v1_mode(sd);
7583 inode->i_nlink = sd_v1_nlink(sd);
7584 - inode->i_uid = sd_v1_uid(sd);
7585 - inode->i_gid = sd_v1_gid(sd);
7586 inode->i_size = sd_v1_size(sd);
7587 inode->i_atime.tv_sec = sd_v1_atime(sd);
7588 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7589 @@ -1189,11 +1193,12 @@ static void init_inode(struct inode *ino
7590 // (directories and symlinks)
7591 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7593 + uid = sd_v2_uid(sd);
7594 + gid = sd_v2_gid(sd);
7596 inode->i_mode = sd_v2_mode(sd);
7597 inode->i_nlink = sd_v2_nlink(sd);
7598 - inode->i_uid = sd_v2_uid(sd);
7599 inode->i_size = sd_v2_size(sd);
7600 - inode->i_gid = sd_v2_gid(sd);
7601 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7602 inode->i_atime.tv_sec = sd_v2_atime(sd);
7603 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7604 @@ -1223,6 +1228,10 @@ static void init_inode(struct inode *ino
7605 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7608 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7609 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7610 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7613 if (S_ISREG(inode->i_mode)) {
7614 inode->i_op = &reiserfs_file_inode_operations;
7615 @@ -1245,13 +1254,15 @@ static void init_inode(struct inode *ino
7616 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7618 struct stat_data *sd_v2 = (struct stat_data *)sd;
7619 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7620 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7623 + set_sd_v2_uid(sd_v2, uid);
7624 + set_sd_v2_gid(sd_v2, gid);
7625 set_sd_v2_mode(sd_v2, inode->i_mode);
7626 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7627 - set_sd_v2_uid(sd_v2, inode->i_uid);
7628 set_sd_v2_size(sd_v2, size);
7629 - set_sd_v2_gid(sd_v2, inode->i_gid);
7630 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7631 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7632 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7633 @@ -2852,14 +2863,19 @@ int reiserfs_commit_write(struct file *f
7634 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7636 if (reiserfs_attrs(inode->i_sb)) {
7637 - if (sd_attrs & REISERFS_SYNC_FL)
7638 - inode->i_flags |= S_SYNC;
7640 - inode->i_flags &= ~S_SYNC;
7641 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7642 inode->i_flags |= S_IMMUTABLE;
7644 inode->i_flags &= ~S_IMMUTABLE;
7645 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7646 + inode->i_flags |= S_IXUNLINK;
7648 + inode->i_flags &= ~S_IXUNLINK;
7650 + if (sd_attrs & REISERFS_SYNC_FL)
7651 + inode->i_flags |= S_SYNC;
7653 + inode->i_flags &= ~S_SYNC;
7654 if (sd_attrs & REISERFS_APPEND_FL)
7655 inode->i_flags |= S_APPEND;
7657 @@ -2872,6 +2888,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7658 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7660 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7662 + if (sd_attrs & REISERFS_BARRIER_FL)
7663 + inode->i_vflags |= V_BARRIER;
7665 + inode->i_vflags &= ~V_BARRIER;
7666 + if (sd_attrs & REISERFS_COW_FL)
7667 + inode->i_vflags |= V_COW;
7669 + inode->i_vflags &= ~V_COW;
7673 @@ -2882,6 +2907,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7674 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7676 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7677 + if (inode->i_flags & S_IXUNLINK)
7678 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7680 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7682 if (inode->i_flags & S_SYNC)
7683 *sd_attrs |= REISERFS_SYNC_FL;
7685 @@ -2894,6 +2924,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7686 *sd_attrs |= REISERFS_NOTAIL_FL;
7688 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7690 + if (inode->i_vflags & V_BARRIER)
7691 + *sd_attrs |= REISERFS_BARRIER_FL;
7693 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7694 + if (inode->i_vflags & V_COW)
7695 + *sd_attrs |= REISERFS_COW_FL;
7697 + *sd_attrs &= ~REISERFS_COW_FL;
7701 @@ -3115,9 +3154,11 @@ int reiserfs_setattr(struct dentry *dent
7704 error = inode_change_ok(inode, attr);
7707 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7708 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7709 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7710 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7711 error = reiserfs_chown_xattrs(inode, attr);
7714 @@ -3147,6 +3188,9 @@ int reiserfs_setattr(struct dentry *dent
7715 inode->i_uid = attr->ia_uid;
7716 if (attr->ia_valid & ATTR_GID)
7717 inode->i_gid = attr->ia_gid;
7718 + if ((attr->ia_valid & ATTR_TAG) &&
7720 + inode->i_tag = attr->ia_tag;
7721 mark_inode_dirty(inode);
7723 journal_end(&th, inode->i_sb, jbegin_count);
7724 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/ioctl.c
7725 --- linux-2.6.33/fs/reiserfs/ioctl.c 2010-02-25 11:52:06.000000000 +0100
7726 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/ioctl.c 2010-02-25 13:21:56.000000000 +0100
7728 #include <linux/mount.h>
7729 #include <linux/reiserfs_fs.h>
7730 #include <linux/time.h>
7731 +#include <linux/mount.h>
7732 #include <asm/uaccess.h>
7733 #include <linux/pagemap.h>
7734 #include <linux/smp_lock.h>
7735 #include <linux/compat.h>
7738 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7740 + __u16 sd_attrs = 0;
7742 + inode->i_flags = flags;
7743 + inode->i_vflags = vflags;
7745 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7746 + REISERFS_I(inode)->i_attrs = sd_attrs;
7747 + inode->i_ctime = CURRENT_TIME_SEC;
7748 + mark_inode_dirty(inode);
7753 * reiserfs_ioctl - handler for ioctl for inode
7754 * supported commands:
7756 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7758 struct inode *inode = filp->f_path.dentry->d_inode;
7759 - unsigned int flags;
7760 + unsigned int flags, oldflags;
7763 reiserfs_write_lock(inode->i_sb);
7764 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
7766 flags = REISERFS_I(inode)->i_attrs;
7767 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7768 + flags &= REISERFS_FL_USER_VISIBLE;
7769 err = put_user(flags, (int __user *)arg);
7771 case REISERFS_IOC_SETFLAGS:{
7772 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
7776 + if (IS_BARRIER(inode)) {
7777 + vxwprintk_task(1, "messing with the barrier.");
7781 * Is it quota file? Do not allow user to mess with it
7783 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
7788 + oldflags = REISERFS_I(inode)->i_attrs;
7789 + flags &= REISERFS_FL_USER_MODIFIABLE;
7790 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7791 sd_attrs_to_i_attrs(flags, inode);
7792 REISERFS_I(inode)->i_attrs = flags;
7793 inode->i_ctime = CURRENT_TIME_SEC;
7794 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/namei.c linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/namei.c
7795 --- linux-2.6.33/fs/reiserfs/namei.c 2010-02-25 11:52:06.000000000 +0100
7796 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/namei.c 2010-02-25 12:02:16.000000000 +0100
7798 #include <linux/reiserfs_acl.h>
7799 #include <linux/reiserfs_xattr.h>
7800 #include <linux/quotaops.h>
7801 +#include <linux/vs_tag.h>
7803 #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; }
7804 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7805 @@ -361,6 +362,7 @@ static struct dentry *reiserfs_lookup(st
7806 if (retval == IO_ERROR) {
7807 return ERR_PTR(-EIO);
7809 + dx_propagate_tag(nd, inode);
7811 return d_splice_alias(inode, dentry);
7813 @@ -577,6 +579,7 @@ static int new_inode_init(struct inode *
7815 inode->i_gid = current_fsgid();
7817 + inode->i_tag = dx_current_fstag(inode->i_sb);
7821 @@ -1524,6 +1527,7 @@ const struct inode_operations reiserfs_d
7822 .listxattr = reiserfs_listxattr,
7823 .removexattr = reiserfs_removexattr,
7824 .permission = reiserfs_permission,
7825 + .sync_flags = reiserfs_sync_flags,
7829 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/super.c
7830 --- linux-2.6.33/fs/reiserfs/super.c 2010-02-25 11:52:06.000000000 +0100
7831 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/super.c 2010-02-25 12:02:16.000000000 +0100
7832 @@ -887,6 +887,14 @@ static int reiserfs_parse_options(struct
7833 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7834 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7836 +#ifndef CONFIG_TAGGING_NONE
7837 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7838 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7839 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7841 +#ifdef CONFIG_PROPAGATE
7842 + {"tag",.arg_required = 'T',.values = NULL},
7844 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7845 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7846 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7847 @@ -1196,6 +1204,14 @@ static int reiserfs_remount(struct super
7848 handle_quota_files(s, qf_names, &qfmt);
7851 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7852 + !(s->s_flags & MS_TAGGED)) {
7853 + reiserfs_warning(s, "super-vs01",
7854 + "reiserfs: tagging not permitted on remount.");
7861 /* Add options that are safe here */
7862 @@ -1674,6 +1690,10 @@ static int reiserfs_fill_super(struct su
7866 + /* map mount option tagxid */
7867 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7868 + s->s_flags |= MS_TAGGED;
7870 rs = SB_DISK_SUPER_BLOCK(s);
7871 /* Let's do basic sanity check to verify that underlying device is not
7872 smaller than the filesystem. If the check fails then abort and scream,
7873 diff -NurpP --minimal linux-2.6.33/fs/reiserfs/xattr.c linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/xattr.c
7874 --- linux-2.6.33/fs/reiserfs/xattr.c 2010-02-25 11:52:06.000000000 +0100
7875 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/reiserfs/xattr.c 2010-02-25 12:02:16.000000000 +0100
7877 #include <linux/namei.h>
7878 #include <linux/errno.h>
7879 #include <linux/fs.h>
7880 +#include <linux/mount.h>
7881 #include <linux/file.h>
7882 #include <linux/pagemap.h>
7883 #include <linux/xattr.h>
7884 diff -NurpP --minimal linux-2.6.33/fs/stat.c linux-2.6.33-vs2.3.0.36.30.1/fs/stat.c
7885 --- linux-2.6.33/fs/stat.c 2010-02-25 11:52:06.000000000 +0100
7886 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/stat.c 2010-02-25 12:02:16.000000000 +0100
7887 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7888 stat->nlink = inode->i_nlink;
7889 stat->uid = inode->i_uid;
7890 stat->gid = inode->i_gid;
7891 + stat->tag = inode->i_tag;
7892 stat->rdev = inode->i_rdev;
7893 stat->atime = inode->i_atime;
7894 stat->mtime = inode->i_mtime;
7895 diff -NurpP --minimal linux-2.6.33/fs/super.c linux-2.6.33-vs2.3.0.36.30.1/fs/super.c
7896 --- linux-2.6.33/fs/super.c 2010-02-25 11:52:06.000000000 +0100
7897 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/super.c 2010-02-25 12:02:16.000000000 +0100
7899 #include <linux/kobject.h>
7900 #include <linux/mutex.h>
7901 #include <linux/file.h>
7902 +#include <linux/devpts_fs.h>
7903 +#include <linux/proc_fs.h>
7904 +#include <linux/vs_context.h>
7905 #include <asm/uaccess.h>
7906 #include "internal.h"
7908 @@ -914,12 +917,18 @@ struct vfsmount *
7909 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7911 struct vfsmount *mnt;
7912 + struct super_block *sb;
7913 char *secdata = NULL;
7917 return ERR_PTR(-ENODEV);
7920 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7921 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7925 mnt = alloc_vfsmnt(name);
7927 @@ -938,9 +947,17 @@ vfs_kern_mount(struct file_system_type *
7928 error = type->get_sb(type, flags, name, data, mnt);
7930 goto out_free_secdata;
7931 - BUG_ON(!mnt->mnt_sb);
7933 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7938 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7939 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7940 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7943 + error = security_sb_kern_mount(sb, flags, secdata);
7947 diff -NurpP --minimal linux-2.6.33/fs/sysfs/mount.c linux-2.6.33-vs2.3.0.36.30.1/fs/sysfs/mount.c
7948 --- linux-2.6.33/fs/sysfs/mount.c 2009-06-11 17:13:08.000000000 +0200
7949 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/sysfs/mount.c 2010-02-25 12:02:16.000000000 +0100
7950 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7952 sb->s_blocksize = PAGE_CACHE_SIZE;
7953 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7954 - sb->s_magic = SYSFS_MAGIC;
7955 + sb->s_magic = SYSFS_SUPER_MAGIC;
7956 sb->s_op = &sysfs_ops;
7957 sb->s_time_gran = 1;
7959 diff -NurpP --minimal linux-2.6.33/fs/utimes.c linux-2.6.33-vs2.3.0.36.30.1/fs/utimes.c
7960 --- linux-2.6.33/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7961 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/utimes.c 2010-02-25 12:02:16.000000000 +0100
7963 #include <linux/stat.h>
7964 #include <linux/utime.h>
7965 #include <linux/syscalls.h>
7966 +#include <linux/mount.h>
7967 +#include <linux/vs_cowbl.h>
7968 #include <asm/uaccess.h>
7969 #include <asm/unistd.h>
7971 diff -NurpP --minimal linux-2.6.33/fs/xattr.c linux-2.6.33-vs2.3.0.36.30.1/fs/xattr.c
7972 --- linux-2.6.33/fs/xattr.c 2010-02-25 11:52:06.000000000 +0100
7973 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xattr.c 2010-02-25 12:02:16.000000000 +0100
7975 #include <linux/module.h>
7976 #include <linux/fsnotify.h>
7977 #include <linux/audit.h>
7978 +#include <linux/mount.h>
7979 #include <asm/uaccess.h>
7982 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_ioctl.c
7983 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 11:52:06.000000000 +0100
7984 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 12:02:16.000000000 +0100
7986 #include "xfs_dir2_sf.h"
7987 #include "xfs_dinode.h"
7988 #include "xfs_inode.h"
7989 -#include "xfs_ioctl.h"
7990 #include "xfs_btree.h"
7991 #include "xfs_ialloc.h"
7992 #include "xfs_rtalloc.h"
7993 @@ -743,6 +742,10 @@ xfs_merge_ioc_xflags(
7994 xflags |= XFS_XFLAG_IMMUTABLE;
7996 xflags &= ~XFS_XFLAG_IMMUTABLE;
7997 + if (flags & FS_IXUNLINK_FL)
7998 + xflags |= XFS_XFLAG_IXUNLINK;
8000 + xflags &= ~XFS_XFLAG_IXUNLINK;
8001 if (flags & FS_APPEND_FL)
8002 xflags |= XFS_XFLAG_APPEND;
8004 @@ -771,6 +774,8 @@ xfs_di2lxflags(
8006 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8007 flags |= FS_IMMUTABLE_FL;
8008 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8009 + flags |= FS_IXUNLINK_FL;
8010 if (di_flags & XFS_DIFLAG_APPEND)
8011 flags |= FS_APPEND_FL;
8012 if (di_flags & XFS_DIFLAG_SYNC)
8013 @@ -829,6 +834,8 @@ xfs_set_diflags(
8014 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
8015 if (xflags & XFS_XFLAG_IMMUTABLE)
8016 di_flags |= XFS_DIFLAG_IMMUTABLE;
8017 + if (xflags & XFS_XFLAG_IXUNLINK)
8018 + di_flags |= XFS_DIFLAG_IXUNLINK;
8019 if (xflags & XFS_XFLAG_APPEND)
8020 di_flags |= XFS_DIFLAG_APPEND;
8021 if (xflags & XFS_XFLAG_SYNC)
8022 @@ -871,6 +878,10 @@ xfs_diflags_to_linux(
8023 inode->i_flags |= S_IMMUTABLE;
8025 inode->i_flags &= ~S_IMMUTABLE;
8026 + if (xflags & XFS_XFLAG_IXUNLINK)
8027 + inode->i_flags |= S_IXUNLINK;
8029 + inode->i_flags &= ~S_IXUNLINK;
8030 if (xflags & XFS_XFLAG_APPEND)
8031 inode->i_flags |= S_APPEND;
8033 @@ -1347,10 +1358,18 @@ xfs_file_ioctl(
8034 case XFS_IOC_FSGETXATTRA:
8035 return xfs_ioc_fsgetxattr(ip, 1, arg);
8036 case XFS_IOC_FSSETXATTR:
8037 + if (IS_BARRIER(inode)) {
8038 + vxwprintk_task(1, "messing with the barrier.");
8039 + return -XFS_ERROR(EACCES);
8041 return xfs_ioc_fssetxattr(ip, filp, arg);
8042 case XFS_IOC_GETXFLAGS:
8043 return xfs_ioc_getxflags(ip, arg);
8044 case XFS_IOC_SETXFLAGS:
8045 + if (IS_BARRIER(inode)) {
8046 + vxwprintk_task(1, "messing with the barrier.");
8047 + return -XFS_ERROR(EACCES);
8049 return xfs_ioc_setxflags(ip, filp, arg);
8051 case XFS_IOC_FSSETDM: {
8052 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_ioctl.h
8053 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
8054 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_ioctl.h 2010-02-25 12:02:16.000000000 +0100
8055 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
8056 void __user *uhandle,
8061 + struct inode *inode,
8068 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_iops.c
8069 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_iops.c 2010-02-25 11:52:06.000000000 +0100
8070 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_iops.c 2010-02-25 12:02:16.000000000 +0100
8072 #include "xfs_attr_sf.h"
8073 #include "xfs_dinode.h"
8074 #include "xfs_inode.h"
8075 +#include "xfs_ioctl.h"
8076 #include "xfs_bmap.h"
8077 #include "xfs_btree.h"
8078 #include "xfs_ialloc.h"
8080 #include <linux/security.h>
8081 #include <linux/falloc.h>
8082 #include <linux/fiemap.h>
8083 +#include <linux/vs_tag.h>
8086 * Bring the timestamps in the XFS inode uptodate.
8087 @@ -496,6 +498,7 @@ xfs_vn_getattr(
8088 stat->nlink = ip->i_d.di_nlink;
8089 stat->uid = ip->i_d.di_uid;
8090 stat->gid = ip->i_d.di_gid;
8091 + stat->tag = ip->i_d.di_tag;
8092 stat->ino = ip->i_ino;
8093 stat->atime = inode->i_atime;
8094 stat->mtime = inode->i_mtime;
8095 @@ -687,6 +690,7 @@ static const struct inode_operations xfs
8096 .listxattr = xfs_vn_listxattr,
8097 .fallocate = xfs_vn_fallocate,
8098 .fiemap = xfs_vn_fiemap,
8099 + .sync_flags = xfs_sync_flags,
8102 static const struct inode_operations xfs_dir_inode_operations = {
8103 @@ -712,6 +716,7 @@ static const struct inode_operations xfs
8104 .getxattr = generic_getxattr,
8105 .removexattr = generic_removexattr,
8106 .listxattr = xfs_vn_listxattr,
8107 + .sync_flags = xfs_sync_flags,
8110 static const struct inode_operations xfs_dir_ci_inode_operations = {
8111 @@ -761,6 +766,10 @@ xfs_diflags_to_iflags(
8112 inode->i_flags |= S_IMMUTABLE;
8114 inode->i_flags &= ~S_IMMUTABLE;
8115 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
8116 + inode->i_flags |= S_IXUNLINK;
8118 + inode->i_flags &= ~S_IXUNLINK;
8119 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
8120 inode->i_flags |= S_APPEND;
8122 @@ -773,6 +782,15 @@ xfs_diflags_to_iflags(
8123 inode->i_flags |= S_NOATIME;
8125 inode->i_flags &= ~S_NOATIME;
8127 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
8128 + inode->i_vflags |= V_BARRIER;
8130 + inode->i_vflags &= ~V_BARRIER;
8131 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8132 + inode->i_vflags |= V_COW;
8134 + inode->i_vflags &= ~V_COW;
8138 @@ -801,6 +819,7 @@ xfs_setup_inode(
8139 inode->i_nlink = ip->i_d.di_nlink;
8140 inode->i_uid = ip->i_d.di_uid;
8141 inode->i_gid = ip->i_d.di_gid;
8142 + inode->i_tag = ip->i_d.di_tag;
8144 switch (inode->i_mode & S_IFMT) {
8146 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_linux.h
8147 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 11:52:06.000000000 +0100
8148 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 12:02:16.000000000 +0100
8151 #define current_cpu() (raw_smp_processor_id())
8152 #define current_pid() (current->pid)
8153 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
8154 #define current_test_flags(f) (current->flags & (f))
8155 #define current_set_flags_nested(sp, f) \
8156 (*(sp) = current->flags, current->flags |= (f))
8157 diff -NurpP --minimal linux-2.6.33/fs/xfs/linux-2.6/xfs_super.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_super.c
8158 --- linux-2.6.33/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 11:52:06.000000000 +0100
8159 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 12:02:16.000000000 +0100
8160 @@ -118,6 +118,9 @@ mempool_t *xfs_ioend_pool;
8161 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
8162 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
8163 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
8164 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8165 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8166 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8169 * Table driven mount option parser.
8170 @@ -126,10 +129,14 @@ mempool_t *xfs_ioend_pool;
8171 * in the future, too.
8174 + Opt_tag, Opt_notag,
8175 Opt_barrier, Opt_nobarrier, Opt_err
8178 static const match_table_t tokens = {
8179 + {Opt_tag, "tagxid"},
8181 + {Opt_notag, "notag"},
8182 {Opt_barrier, "barrier"},
8183 {Opt_nobarrier, "nobarrier"},
8185 @@ -383,6 +390,19 @@ xfs_parseargs(
8186 } else if (!strcmp(this_char, "irixsgid")) {
8188 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8189 +#ifndef CONFIG_TAGGING_NONE
8190 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8191 + mp->m_flags |= XFS_MOUNT_TAGGED;
8192 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8193 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
8194 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8195 + mp->m_flags |= XFS_MOUNT_TAGGED;
8197 +#ifdef CONFIG_PROPAGATE
8198 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8200 + mp->m_flags |= XFS_MOUNT_TAGGED;
8204 "XFS: unknown mount option [%s].", this_char);
8205 @@ -1290,6 +1310,16 @@ xfs_fs_remount(
8207 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8210 + if (!(sb->s_flags & MS_TAGGED)) {
8212 + "XFS: %s: tagging not permitted on remount.\n",
8221 * Logically we would return an error here to prevent
8222 @@ -1497,6 +1527,9 @@ xfs_fs_fill_super(
8224 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
8226 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8227 + sb->s_flags |= MS_TAGGED;
8229 sb->s_magic = XFS_SB_MAGIC;
8230 sb->s_blocksize = mp->m_sb.sb_blocksize;
8231 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
8232 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_dinode.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_dinode.h
8233 --- linux-2.6.33/fs/xfs/xfs_dinode.h 2009-06-11 17:13:09.000000000 +0200
8234 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_dinode.h 2010-02-25 12:02:16.000000000 +0100
8235 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
8236 __be32 di_gid; /* owner's group id */
8237 __be32 di_nlink; /* number of links to file */
8238 __be16 di_projid; /* owner's project id */
8239 - __u8 di_pad[8]; /* unused, zeroed space */
8240 + __be16 di_tag; /* context tagging */
8241 + __be16 di_vflags; /* vserver specific flags */
8242 + __u8 di_pad[4]; /* unused, zeroed space */
8243 __be16 di_flushiter; /* incremented on flush */
8244 xfs_timestamp_t di_atime; /* time last accessed */
8245 xfs_timestamp_t di_mtime; /* time last modified */
8246 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
8247 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8248 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8249 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8250 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8252 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8253 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8254 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8255 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
8256 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8257 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8258 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8259 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8261 #ifdef CONFIG_XFS_RT
8262 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8263 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
8264 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8265 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8266 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8267 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8268 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8269 + XFS_DIFLAG_IXUNLINK)
8271 +#define XFS_DIVFLAG_BARRIER 0x01
8272 +#define XFS_DIVFLAG_COW 0x02
8274 #endif /* __XFS_DINODE_H__ */
8275 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_fs.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_fs.h
8276 --- linux-2.6.33/fs/xfs/xfs_fs.h 2009-12-03 20:02:53.000000000 +0100
8277 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_fs.h 2010-02-25 12:02:16.000000000 +0100
8278 @@ -67,6 +67,9 @@ struct fsxattr {
8279 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8280 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8281 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8282 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8283 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8284 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8285 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8288 @@ -292,7 +295,8 @@ typedef struct xfs_bstat {
8289 __s32 bs_extents; /* number of extents */
8290 __u32 bs_gen; /* generation count */
8291 __u16 bs_projid; /* project id */
8292 - unsigned char bs_pad[14]; /* pad space, unused */
8293 + __u16 bs_tag; /* context tagging */
8294 + unsigned char bs_pad[12]; /* pad space, unused */
8295 __u32 bs_dmevmask; /* DMIG event mask */
8296 __u16 bs_dmstate; /* DMIG state info */
8297 __u16 bs_aextents; /* attribute number of extents */
8298 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_ialloc.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_ialloc.c
8299 --- linux-2.6.33/fs/xfs/xfs_ialloc.c 2010-02-25 11:52:06.000000000 +0100
8300 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_ialloc.c 2010-02-25 12:02:16.000000000 +0100
8302 #include "xfs_error.h"
8303 #include "xfs_bmap.h"
8307 * Allocation group level functions.
8309 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_inode.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_inode.c
8310 --- linux-2.6.33/fs/xfs/xfs_inode.c 2010-02-25 11:52:06.000000000 +0100
8311 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_inode.c 2010-02-25 12:02:16.000000000 +0100
8312 @@ -249,6 +249,7 @@ xfs_inotobp(
8316 +#include <linux/vs_tag.h>
8319 * This routine is called to map an inode to the buffer containing
8320 @@ -654,15 +655,25 @@ xfs_iformat_btree(
8322 xfs_dinode_from_disk(
8324 - xfs_dinode_t *from)
8325 + xfs_dinode_t *from,
8328 + uint32_t uid, gid, tag;
8330 to->di_magic = be16_to_cpu(from->di_magic);
8331 to->di_mode = be16_to_cpu(from->di_mode);
8332 to->di_version = from ->di_version;
8333 to->di_format = from->di_format;
8334 to->di_onlink = be16_to_cpu(from->di_onlink);
8335 - to->di_uid = be32_to_cpu(from->di_uid);
8336 - to->di_gid = be32_to_cpu(from->di_gid);
8338 + uid = be32_to_cpu(from->di_uid);
8339 + gid = be32_to_cpu(from->di_gid);
8340 + tag = be16_to_cpu(from->di_tag);
8342 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8343 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8344 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8346 to->di_nlink = be32_to_cpu(from->di_nlink);
8347 to->di_projid = be16_to_cpu(from->di_projid);
8348 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8349 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
8350 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8351 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8352 to->di_flags = be16_to_cpu(from->di_flags);
8353 + to->di_vflags = be16_to_cpu(from->di_vflags);
8354 to->di_gen = be32_to_cpu(from->di_gen);
8360 - xfs_icdinode_t *from)
8361 + xfs_icdinode_t *from,
8364 to->di_magic = cpu_to_be16(from->di_magic);
8365 to->di_mode = cpu_to_be16(from->di_mode);
8366 to->di_version = from ->di_version;
8367 to->di_format = from->di_format;
8368 to->di_onlink = cpu_to_be16(from->di_onlink);
8369 - to->di_uid = cpu_to_be32(from->di_uid);
8370 - to->di_gid = cpu_to_be32(from->di_gid);
8372 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8373 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8374 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8376 to->di_nlink = cpu_to_be32(from->di_nlink);
8377 to->di_projid = cpu_to_be16(from->di_projid);
8378 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8379 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
8380 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8381 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8382 to->di_flags = cpu_to_be16(from->di_flags);
8383 + to->di_vflags = cpu_to_be16(from->di_vflags);
8384 to->di_gen = cpu_to_be32(from->di_gen);
8389 - __uint16_t di_flags)
8390 + __uint16_t di_flags,
8391 + __uint16_t di_vflags)
8395 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
8396 flags |= XFS_XFLAG_PREALLOC;
8397 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8398 flags |= XFS_XFLAG_IMMUTABLE;
8399 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8400 + flags |= XFS_XFLAG_IXUNLINK;
8401 if (di_flags & XFS_DIFLAG_APPEND)
8402 flags |= XFS_XFLAG_APPEND;
8403 if (di_flags & XFS_DIFLAG_SYNC)
8404 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
8405 flags |= XFS_XFLAG_FILESTREAM;
8408 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8409 + flags |= FS_BARRIER_FL;
8410 + if (di_vflags & XFS_DIVFLAG_COW)
8411 + flags |= FS_COW_FL;
8415 @@ -767,7 +791,7 @@ xfs_ip2xflags(
8417 xfs_icdinode_t *dic = &ip->i_d;
8419 - return _xfs_dic2xflags(dic->di_flags) |
8420 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8421 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8424 @@ -775,7 +799,8 @@ uint
8428 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8429 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8430 + be16_to_cpu(dip->di_vflags)) |
8431 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8434 @@ -811,7 +836,6 @@ xfs_iread(
8437 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8440 * If we got something that isn't an inode it means someone
8441 * (nfs or dmi) has a stale handle.
8442 @@ -836,7 +860,8 @@ xfs_iread(
8443 * Otherwise, just get the truly permanent information.
8446 - xfs_dinode_from_disk(&ip->i_d, dip);
8447 + xfs_dinode_from_disk(&ip->i_d, dip,
8448 + mp->m_flags & XFS_MOUNT_TAGGED);
8449 error = xfs_iformat(ip, dip);
8452 @@ -1036,6 +1061,7 @@ xfs_ialloc(
8453 ASSERT(ip->i_d.di_nlink == nlink);
8454 ip->i_d.di_uid = current_fsuid();
8455 ip->i_d.di_gid = current_fsgid();
8456 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8457 ip->i_d.di_projid = prid;
8458 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8460 @@ -1096,6 +1122,7 @@ xfs_ialloc(
8461 ip->i_d.di_dmevmask = 0;
8462 ip->i_d.di_dmstate = 0;
8463 ip->i_d.di_flags = 0;
8464 + ip->i_d.di_vflags = 0;
8465 flags = XFS_ILOG_CORE;
8466 switch (mode & S_IFMT) {
8468 @@ -2136,6 +2163,7 @@ xfs_ifree(
8470 ip->i_d.di_mode = 0; /* mark incore inode as free */
8471 ip->i_d.di_flags = 0;
8472 + ip->i_d.di_vflags = 0;
8473 ip->i_d.di_dmevmask = 0;
8474 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8475 ip->i_df.if_ext_max =
8476 @@ -3116,7 +3144,8 @@ xfs_iflush_int(
8477 * because if the inode is dirty at all the core must
8480 - xfs_dinode_to_disk(dip, &ip->i_d);
8481 + xfs_dinode_to_disk(dip, &ip->i_d,
8482 + mp->m_flags & XFS_MOUNT_TAGGED);
8484 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8485 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8486 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_inode.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_inode.h
8487 --- linux-2.6.33/fs/xfs/xfs_inode.h 2010-02-25 11:52:06.000000000 +0100
8488 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_inode.h 2010-02-25 12:02:16.000000000 +0100
8489 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
8490 __uint32_t di_gid; /* owner's group id */
8491 __uint32_t di_nlink; /* number of links to file */
8492 __uint16_t di_projid; /* owner's project id */
8493 - __uint8_t di_pad[8]; /* unused, zeroed space */
8494 + __uint16_t di_tag; /* context tagging */
8495 + __uint16_t di_vflags; /* vserver specific flags */
8496 + __uint8_t di_pad[4]; /* unused, zeroed space */
8497 __uint16_t di_flushiter; /* incremented on flush */
8498 xfs_ictimestamp_t di_atime; /* time last accessed */
8499 xfs_ictimestamp_t di_mtime; /* time last modified */
8500 @@ -521,7 +523,7 @@ int xfs_itobp(struct xfs_mount *, struc
8501 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8502 struct xfs_inode *, xfs_daddr_t, uint);
8503 void xfs_dinode_to_disk(struct xfs_dinode *,
8504 - struct xfs_icdinode *);
8505 + struct xfs_icdinode *, int);
8506 void xfs_idestroy_fork(struct xfs_inode *, int);
8507 void xfs_idata_realloc(struct xfs_inode *, int, int);
8508 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8509 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_itable.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_itable.c
8510 --- linux-2.6.33/fs/xfs/xfs_itable.c 2009-12-03 20:02:54.000000000 +0100
8511 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_itable.c 2010-02-25 12:02:16.000000000 +0100
8512 @@ -84,6 +84,7 @@ xfs_bulkstat_one_iget(
8513 buf->bs_mode = dic->di_mode;
8514 buf->bs_uid = dic->di_uid;
8515 buf->bs_gid = dic->di_gid;
8516 + buf->bs_tag = dic->di_tag;
8517 buf->bs_size = dic->di_size;
8520 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_log_recover.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_log_recover.c
8521 --- linux-2.6.33/fs/xfs/xfs_log_recover.c 2010-02-25 11:52:06.000000000 +0100
8522 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_log_recover.c 2010-02-25 12:02:16.000000000 +0100
8523 @@ -2462,7 +2462,8 @@ xlog_recover_do_inode_trans(
8526 /* The core is in in-core format */
8527 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8528 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8529 + mp->m_flags & XFS_MOUNT_TAGGED);
8531 /* the rest is in on-disk format */
8532 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8533 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_mount.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_mount.h
8534 --- linux-2.6.33/fs/xfs/xfs_mount.h 2010-02-25 11:52:06.000000000 +0100
8535 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_mount.h 2010-02-25 12:02:16.000000000 +0100
8536 @@ -298,6 +298,7 @@ typedef struct xfs_mount {
8538 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8540 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8543 * Default minimum read and write sizes.
8544 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_vnodeops.c linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_vnodeops.c
8545 --- linux-2.6.33/fs/xfs/xfs_vnodeops.c 2010-02-25 11:52:06.000000000 +0100
8546 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_vnodeops.c 2010-02-25 13:24:14.000000000 +0100
8548 #include "xfs_vnodeops.h"
8549 #include "xfs_trace.h"
8553 +xfs_get_inode_flags(
8556 + struct inode *inode = VFS_I(ip);
8557 + unsigned int flags = inode->i_flags;
8558 + unsigned int vflags = inode->i_vflags;
8560 + if (flags & S_IMMUTABLE)
8561 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8563 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8564 + if (flags & S_IXUNLINK)
8565 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8567 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8569 + if (vflags & V_BARRIER)
8570 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8572 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8573 + if (vflags & V_COW)
8574 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8576 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8581 + struct inode *inode,
8585 + struct xfs_inode *ip = XFS_I(inode);
8586 + struct xfs_mount *mp = ip->i_mount;
8587 + struct xfs_trans *tp;
8588 + unsigned int lock_flags = 0;
8591 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8592 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8596 + lock_flags = XFS_ILOCK_EXCL;
8597 + xfs_ilock(ip, lock_flags);
8599 + xfs_trans_ijoin(tp, ip, lock_flags);
8600 + xfs_trans_ihold(tp, ip);
8602 + inode->i_flags = flags;
8603 + inode->i_vflags = vflags;
8604 + xfs_get_inode_flags(ip);
8606 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8607 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8609 + XFS_STATS_INC(xs_ig_attrchg);
8611 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8612 + xfs_trans_set_sync(tp);
8613 + code = xfs_trans_commit(tp, 0);
8614 + xfs_iunlock(ip, lock_flags);
8618 + xfs_trans_cancel(tp, 0);
8620 + xfs_iunlock(ip, lock_flags);
8627 struct xfs_inode *ip,
8628 @@ -70,6 +144,7 @@ xfs_setattr(
8629 uint commit_flags=0;
8630 uid_t uid=0, iuid=0;
8631 gid_t gid=0, igid=0;
8632 + tag_t tag=0, itag=0;
8633 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8634 int need_iolock = 1;
8636 @@ -162,7 +237,7 @@ xfs_setattr(
8638 * Change file ownership. Must be the owner or privileged.
8640 - if (mask & (ATTR_UID|ATTR_GID)) {
8641 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8643 * These IDs could have changed since we last looked at them.
8644 * But, we're assured that if the ownership did change
8645 @@ -171,8 +246,10 @@ xfs_setattr(
8647 iuid = ip->i_d.di_uid;
8648 igid = ip->i_d.di_gid;
8649 + itag = ip->i_d.di_tag;
8650 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8651 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8652 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8655 * Do a quota reservation only if uid/gid is actually
8656 @@ -180,7 +257,8 @@ xfs_setattr(
8658 if (XFS_IS_QUOTA_RUNNING(mp) &&
8659 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8660 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8661 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8662 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8664 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8665 capable(CAP_FOWNER) ?
8666 @@ -341,7 +419,7 @@ xfs_setattr(
8668 * Change file ownership. Must be the owner or privileged.
8670 - if (mask & (ATTR_UID|ATTR_GID)) {
8671 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8673 * CAP_FSETID overrides the following restrictions:
8675 @@ -357,6 +435,10 @@ xfs_setattr(
8676 * Change the ownerships and register quota modifications
8677 * in the transaction.
8679 + if (itag != tag) {
8680 + ip->i_d.di_tag = tag;
8681 + inode->i_tag = tag;
8684 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8685 ASSERT(mask & ATTR_UID);
8686 diff -NurpP --minimal linux-2.6.33/fs/xfs/xfs_vnodeops.h linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_vnodeops.h
8687 --- linux-2.6.33/fs/xfs/xfs_vnodeops.h 2010-02-25 11:52:06.000000000 +0100
8688 +++ linux-2.6.33-vs2.3.0.36.30.1/fs/xfs/xfs_vnodeops.h 2010-02-25 12:02:16.000000000 +0100
8689 @@ -14,6 +14,7 @@ struct xfs_inode;
8693 +int xfs_sync_xflags(struct xfs_inode *ip);
8694 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8695 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8696 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8697 diff -NurpP --minimal linux-2.6.33/include/asm-generic/tlb.h linux-2.6.33-vs2.3.0.36.30.1/include/asm-generic/tlb.h
8698 --- linux-2.6.33/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8699 +++ linux-2.6.33-vs2.3.0.36.30.1/include/asm-generic/tlb.h 2010-02-25 12:02:16.000000000 +0100
8701 #define _ASM_GENERIC__TLB_H
8703 #include <linux/swap.h>
8704 +#include <linux/vs_memory.h>
8705 #include <asm/pgalloc.h>
8706 #include <asm/tlbflush.h>
8708 diff -NurpP --minimal linux-2.6.33/include/linux/capability.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/capability.h
8709 --- linux-2.6.33/include/linux/capability.h 2010-02-25 11:52:07.000000000 +0100
8710 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/capability.h 2010-02-25 12:02:16.000000000 +0100
8711 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
8712 arbitrary SCSI commands */
8713 /* Allow setting encryption key on loopback filesystem */
8714 /* Allow setting zone reclaim policy */
8715 +/* Allow the selection of a security context */
8717 #define CAP_SYS_ADMIN 21
8719 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
8721 #define CAP_MAC_ADMIN 33
8723 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8724 +/* Allow context manipulations */
8725 +/* Allow changing context info on files */
8727 +#define CAP_CONTEXT 34
8730 +#define CAP_LAST_CAP CAP_CONTEXT
8732 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8734 diff -NurpP --minimal linux-2.6.33/include/linux/devpts_fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/devpts_fs.h
8735 --- linux-2.6.33/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8736 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/devpts_fs.h 2010-02-25 12:02:16.000000000 +0100
8737 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8742 #endif /* _LINUX_DEVPTS_FS_H */
8743 diff -NurpP --minimal linux-2.6.33/include/linux/ext2_fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/ext2_fs.h
8744 --- linux-2.6.33/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8745 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/ext2_fs.h 2010-02-25 12:02:16.000000000 +0100
8746 @@ -189,8 +189,12 @@ struct ext2_group_desc
8747 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8748 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8749 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8750 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8751 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8753 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8754 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8756 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8757 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8759 @@ -274,7 +278,8 @@ struct ext2_inode {
8761 __le16 l_i_uid_high; /* these 2 fields */
8762 __le16 l_i_gid_high; /* were reserved2[0] */
8763 - __u32 l_i_reserved2;
8764 + __le16 l_i_tag; /* Context Tag */
8765 + __u16 l_i_reserved2;
8768 __u8 h_i_frag; /* Fragment number */
8769 @@ -303,6 +308,7 @@ struct ext2_inode {
8770 #define i_gid_low i_gid
8771 #define i_uid_high osd2.linux2.l_i_uid_high
8772 #define i_gid_high osd2.linux2.l_i_gid_high
8773 +#define i_raw_tag osd2.linux2.l_i_tag
8774 #define i_reserved2 osd2.linux2.l_i_reserved2
8777 @@ -347,6 +353,7 @@ struct ext2_inode {
8778 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8779 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8780 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8781 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8784 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8785 diff -NurpP --minimal linux-2.6.33/include/linux/ext3_fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/ext3_fs.h
8786 --- linux-2.6.33/include/linux/ext3_fs.h 2010-02-25 11:52:07.000000000 +0100
8787 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/ext3_fs.h 2010-02-25 12:02:16.000000000 +0100
8788 @@ -173,10 +173,14 @@ struct ext3_group_desc
8789 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8790 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8791 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8792 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8793 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8795 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8796 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8797 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8798 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8800 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8801 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8803 /* Flags that should be inherited by new inodes from their parent. */
8804 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8805 @@ -320,7 +324,8 @@ struct ext3_inode {
8807 __le16 l_i_uid_high; /* these 2 fields */
8808 __le16 l_i_gid_high; /* were reserved2[0] */
8809 - __u32 l_i_reserved2;
8810 + __le16 l_i_tag; /* Context Tag */
8811 + __u16 l_i_reserved2;
8814 __u8 h_i_frag; /* Fragment number */
8815 @@ -351,6 +356,7 @@ struct ext3_inode {
8816 #define i_gid_low i_gid
8817 #define i_uid_high osd2.linux2.l_i_uid_high
8818 #define i_gid_high osd2.linux2.l_i_gid_high
8819 +#define i_raw_tag osd2.linux2.l_i_tag
8820 #define i_reserved2 osd2.linux2.l_i_reserved2
8822 #elif defined(__GNU__)
8823 @@ -414,6 +420,7 @@ struct ext3_inode {
8824 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8825 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8826 * error in ordered mode */
8827 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8829 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8830 #ifndef _LINUX_EXT2_FS_H
8831 @@ -892,6 +899,7 @@ extern void ext3_get_inode_flags(struct
8832 extern void ext3_set_aops(struct inode *inode);
8833 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8834 u64 start, u64 len);
8835 +extern int ext3_sync_flags(struct inode *, int, int);
8838 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8839 diff -NurpP --minimal linux-2.6.33/include/linux/fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/fs.h
8840 --- linux-2.6.33/include/linux/fs.h 2010-02-25 11:52:07.000000000 +0100
8841 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/fs.h 2010-02-25 13:36:54.000000000 +0100
8842 @@ -206,6 +206,9 @@ struct inodes_stat_t {
8843 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8844 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8845 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8846 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8847 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8848 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8849 #define MS_ACTIVE (1<<30)
8850 #define MS_NOUSER (1<<31)
8852 @@ -232,6 +235,14 @@ struct inodes_stat_t {
8853 #define S_NOCMTIME 128 /* Do not update file c/mtime */
8854 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8855 #define S_PRIVATE 512 /* Inode is fs-internal */
8856 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
8858 +/* Linux-VServer related Inode flags */
8862 +#define V_BARRIER 4 /* Barrier for chroot() */
8863 +#define V_COW 8 /* Copy on Write */
8866 * Note that nosuid etc flags are inode-specific: setting some file-system
8867 @@ -254,12 +265,15 @@ struct inodes_stat_t {
8868 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8869 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8870 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8871 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8872 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8873 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8874 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8875 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8877 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8878 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8879 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8880 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8881 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8882 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8884 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8885 @@ -267,6 +281,16 @@ struct inodes_stat_t {
8886 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8887 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8889 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8891 +#ifdef CONFIG_VSERVER_COWBL
8892 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8893 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8895 +# define IS_COW(inode) (0)
8896 +# define IS_COW_LINK(inode) (0)
8899 /* the read-only stuff doesn't really belong here, but any other place is
8900 probably as bad and I don't want to create yet another include file. */
8902 @@ -349,11 +373,14 @@ struct inodes_stat_t {
8903 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8904 #define FS_EXTENT_FL 0x00080000 /* Extents */
8905 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8906 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8907 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8909 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8910 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8911 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8912 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8914 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8915 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8917 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8918 #define SYNC_FILE_RANGE_WRITE 2
8919 @@ -435,6 +462,7 @@ typedef void (dio_iodone_t)(struct kiocb
8920 #define ATTR_KILL_PRIV (1 << 14)
8921 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8922 #define ATTR_TIMES_SET (1 << 16)
8923 +#define ATTR_TAG (1 << 17)
8926 * This is the Inode Attributes structure, used for notify_change(). It
8927 @@ -450,6 +478,7 @@ struct iattr {
8933 struct timespec ia_atime;
8934 struct timespec ia_mtime;
8935 @@ -463,6 +492,9 @@ struct iattr {
8936 struct file *ia_file;
8939 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8940 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8943 * Includes for diskquotas.
8945 @@ -728,7 +760,9 @@ struct inode {
8946 unsigned int i_nlink;
8952 unsigned int i_blkbits;
8955 @@ -775,7 +809,8 @@ struct inode {
8956 unsigned long i_state;
8957 unsigned long dirtied_when; /* jiffies of first dirtying */
8959 - unsigned int i_flags;
8960 + unsigned short i_flags;
8961 + unsigned short i_vflags;
8963 atomic_t i_writecount;
8964 #ifdef CONFIG_SECURITY
8965 @@ -863,12 +898,12 @@ static inline void i_size_write(struct i
8967 static inline unsigned iminor(const struct inode *inode)
8969 - return MINOR(inode->i_rdev);
8970 + return MINOR(inode->i_mdev);
8973 static inline unsigned imajor(const struct inode *inode)
8975 - return MAJOR(inode->i_rdev);
8976 + return MAJOR(inode->i_mdev);
8979 extern struct block_device *I_BDEV(struct inode *inode);
8980 @@ -927,6 +962,7 @@ struct file {
8982 struct fown_struct f_owner;
8983 const struct cred *f_cred;
8985 struct file_ra_state f_ra;
8988 @@ -1068,6 +1104,7 @@ struct file_lock {
8989 struct file *fl_file;
8994 struct fasync_struct * fl_fasync; /* for lease break notifications */
8995 unsigned long fl_break_time; /* for nonblocking lease breaks */
8996 @@ -1529,6 +1566,7 @@ struct inode_operations {
8997 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8998 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8999 int (*removexattr) (struct dentry *, const char *);
9000 + int (*sync_flags) (struct inode *, int, int);
9001 void (*truncate_range)(struct inode *, loff_t, loff_t);
9002 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
9004 @@ -1549,6 +1587,7 @@ extern ssize_t vfs_readv(struct file *,
9005 unsigned long, loff_t *);
9006 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
9007 unsigned long, loff_t *);
9008 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
9010 struct super_operations {
9011 struct inode *(*alloc_inode)(struct super_block *sb);
9012 @@ -2331,6 +2370,7 @@ extern int dcache_dir_open(struct inode
9013 extern int dcache_dir_close(struct inode *, struct file *);
9014 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
9015 extern int dcache_readdir(struct file *, void *, filldir_t);
9016 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
9017 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
9018 extern int simple_statfs(struct dentry *, struct kstatfs *);
9019 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
9020 diff -NurpP --minimal linux-2.6.33/include/linux/gfs2_ondisk.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/gfs2_ondisk.h
9021 --- linux-2.6.33/include/linux/gfs2_ondisk.h 2010-02-25 11:52:07.000000000 +0100
9022 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/gfs2_ondisk.h 2010-02-25 12:02:16.000000000 +0100
9023 @@ -239,6 +239,9 @@ enum {
9027 + gfs2fl_IXUnlink = 16,
9028 + gfs2fl_Barrier = 17,
9030 gfs2fl_TruncInProg = 29,
9031 gfs2fl_InheritDirectio = 30,
9032 gfs2fl_InheritJdata = 31,
9033 @@ -255,6 +258,9 @@ enum {
9034 #define GFS2_DIF_NOATIME 0x00000080
9035 #define GFS2_DIF_SYNC 0x00000100
9036 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
9037 +#define GFS2_DIF_IXUNLINK 0x00010000
9038 +#define GFS2_DIF_BARRIER 0x00020000
9039 +#define GFS2_DIF_COW 0x00040000
9040 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
9041 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
9042 #define GFS2_DIF_INHERIT_JDATA 0x80000000
9043 diff -NurpP --minimal linux-2.6.33/include/linux/if_tun.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/if_tun.h
9044 --- linux-2.6.33/include/linux/if_tun.h 2009-12-03 20:02:55.000000000 +0100
9045 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/if_tun.h 2010-02-25 12:02:16.000000000 +0100
9047 #define TUNGETIFF _IOR('T', 210, unsigned int)
9048 #define TUNGETSNDBUF _IOR('T', 211, int)
9049 #define TUNSETSNDBUF _IOW('T', 212, int)
9050 +#define TUNSETNID _IOW('T', 215, int)
9052 /* TUNSETIFF ifr flags */
9053 #define IFF_TUN 0x0001
9054 diff -NurpP --minimal linux-2.6.33/include/linux/init_task.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/init_task.h
9055 --- linux-2.6.33/include/linux/init_task.h 2010-02-25 11:52:07.000000000 +0100
9056 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/init_task.h 2010-02-25 12:02:16.000000000 +0100
9057 @@ -180,6 +180,10 @@ extern struct cred init_cred;
9059 INIT_TRACE_RECURSION \
9060 INIT_TASK_RCU_PREEMPT(tsk) \
9062 + .vx_info = NULL, \
9064 + .nx_info = NULL, \
9068 diff -NurpP --minimal linux-2.6.33/include/linux/ipc.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/ipc.h
9069 --- linux-2.6.33/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
9070 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/ipc.h 2010-02-25 12:02:16.000000000 +0100
9071 @@ -91,6 +91,7 @@ struct kern_ipc_perm
9079 diff -NurpP --minimal linux-2.6.33/include/linux/Kbuild linux-2.6.33-vs2.3.0.36.30.1/include/linux/Kbuild
9080 --- linux-2.6.33/include/linux/Kbuild 2010-02-25 11:52:07.000000000 +0100
9081 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/Kbuild 2010-02-25 12:02:16.000000000 +0100
9082 @@ -383,5 +383,8 @@ unifdef-y += xattr.h
9085 objhdr-y += version.h
9087 +header-y += vserver/
9091 diff -NurpP --minimal linux-2.6.33/include/linux/loop.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/loop.h
9092 --- linux-2.6.33/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
9093 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/loop.h 2010-02-25 12:02:16.000000000 +0100
9094 @@ -45,6 +45,7 @@ struct loop_device {
9095 struct loop_func_table *lo_encryption;
9097 uid_t lo_key_owner; /* Who set the key */
9099 int (*ioctl)(struct loop_device *, int cmd,
9102 diff -NurpP --minimal linux-2.6.33/include/linux/magic.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/magic.h
9103 --- linux-2.6.33/include/linux/magic.h 2009-12-03 20:02:55.000000000 +0100
9104 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/magic.h 2010-02-25 12:02:16.000000000 +0100
9107 #define ADFS_SUPER_MAGIC 0xadf5
9108 #define AFFS_SUPER_MAGIC 0xadff
9109 -#define AFS_SUPER_MAGIC 0x5346414F
9110 +#define AFS_SUPER_MAGIC 0x5346414F
9111 #define AUTOFS_SUPER_MAGIC 0x0187
9112 #define CODA_SUPER_MAGIC 0x73757245
9113 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
9115 #define NFS_SUPER_MAGIC 0x6969
9116 #define OPENPROM_SUPER_MAGIC 0x9fa1
9117 #define PROC_SUPER_MAGIC 0x9fa0
9118 +#define DEVPTS_SUPER_MAGIC 0x1cd1
9119 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
9121 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
9122 diff -NurpP --minimal linux-2.6.33/include/linux/major.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/major.h
9123 --- linux-2.6.33/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
9124 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/major.h 2010-02-25 12:02:16.000000000 +0100
9126 #define HD_MAJOR IDE0_MAJOR
9127 #define PTY_SLAVE_MAJOR 3
9129 +#define VROOT_MAJOR 4
9130 #define TTYAUX_MAJOR 5
9133 diff -NurpP --minimal linux-2.6.33/include/linux/memcontrol.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/memcontrol.h
9134 --- linux-2.6.33/include/linux/memcontrol.h 2010-02-25 11:52:07.000000000 +0100
9135 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/memcontrol.h 2010-02-25 12:02:16.000000000 +0100
9136 @@ -76,6 +76,13 @@ int task_in_mem_cgroup(struct task_struc
9137 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
9138 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
9140 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
9141 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
9143 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
9144 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
9145 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
9148 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
9150 diff -NurpP --minimal linux-2.6.33/include/linux/mm_types.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/mm_types.h
9151 --- linux-2.6.33/include/linux/mm_types.h 2010-02-25 11:52:07.000000000 +0100
9152 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/mm_types.h 2010-02-25 12:02:16.000000000 +0100
9153 @@ -250,6 +250,7 @@ struct mm_struct {
9155 /* Architecture-specific MM context */
9156 mm_context_t context;
9157 + struct vx_info *mm_vx_info;
9159 /* Swap token stuff */
9161 diff -NurpP --minimal linux-2.6.33/include/linux/mount.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/mount.h
9162 --- linux-2.6.33/include/linux/mount.h 2009-09-10 15:26:25.000000000 +0200
9163 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/mount.h 2010-02-25 12:02:16.000000000 +0100
9164 @@ -36,6 +36,9 @@ struct mnt_namespace;
9165 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
9166 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
9168 +#define MNT_TAGID 0x10000
9169 +#define MNT_NOTAG 0x20000
9172 struct list_head mnt_hash;
9173 struct vfsmount *mnt_parent; /* fs we are mounted on */
9174 @@ -70,6 +73,7 @@ struct vfsmount {
9178 + tag_t mnt_tag; /* tagging used for vfsmount */
9181 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
9182 diff -NurpP --minimal linux-2.6.33/include/linux/net.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/net.h
9183 --- linux-2.6.33/include/linux/net.h 2010-02-25 11:52:07.000000000 +0100
9184 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/net.h 2010-02-25 12:02:16.000000000 +0100
9185 @@ -70,6 +70,7 @@ struct net;
9186 #define SOCK_NOSPACE 2
9187 #define SOCK_PASSCRED 3
9188 #define SOCK_PASSSEC 4
9189 +#define SOCK_USER_SOCKET 5
9191 #ifndef ARCH_HAS_SOCKET_TYPES
9193 diff -NurpP --minimal linux-2.6.33/include/linux/nfs_mount.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/nfs_mount.h
9194 --- linux-2.6.33/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
9195 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/nfs_mount.h 2010-02-25 12:02:16.000000000 +0100
9196 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9197 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9198 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9199 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9200 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9201 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9202 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9204 /* The following are for internal use only */
9205 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9206 diff -NurpP --minimal linux-2.6.33/include/linux/nsproxy.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/nsproxy.h
9207 --- linux-2.6.33/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9208 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/nsproxy.h 2010-02-25 12:02:16.000000000 +0100
9211 #include <linux/spinlock.h>
9212 #include <linux/sched.h>
9213 +#include <linux/vserver/debug.h>
9215 struct mnt_namespace;
9216 struct uts_namespace;
9217 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9220 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9221 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9222 void exit_task_namespaces(struct task_struct *tsk);
9223 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9224 void free_nsproxy(struct nsproxy *ns);
9225 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9226 struct fs_struct *);
9228 -static inline void put_nsproxy(struct nsproxy *ns)
9229 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9231 +static inline void __get_nsproxy(struct nsproxy *ns,
9232 + const char *_file, int _line)
9234 - if (atomic_dec_and_test(&ns->count)) {
9237 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9238 + ns, atomic_read(&ns->count), _file, _line);
9239 + atomic_inc(&ns->count);
9242 -static inline void get_nsproxy(struct nsproxy *ns)
9243 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9245 +static inline void __put_nsproxy(struct nsproxy *ns,
9246 + const char *_file, int _line)
9248 - atomic_inc(&ns->count);
9249 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9250 + ns, atomic_read(&ns->count), _file, _line);
9251 + if (atomic_dec_and_test(&ns->count)) {
9256 #ifdef CONFIG_CGROUP_NS
9257 diff -NurpP --minimal linux-2.6.33/include/linux/pid.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/pid.h
9258 --- linux-2.6.33/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9259 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/pid.h 2010-02-25 12:02:16.000000000 +0100
9260 @@ -8,7 +8,8 @@ enum pid_type
9270 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9273 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9274 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9275 pid_t pid_vnr(struct pid *pid);
9277 #define do_each_pid_task(pid, type, task) \
9278 diff -NurpP --minimal linux-2.6.33/include/linux/proc_fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/proc_fs.h
9279 --- linux-2.6.33/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9280 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/proc_fs.h 2010-02-25 12:02:16.000000000 +0100
9281 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9287 const struct inode_operations *proc_iops;
9289 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9290 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9297 int (*proc_get_link)(struct inode *, struct path *);
9298 int (*proc_read)(struct task_struct *task, char *page);
9299 int (*proc_show)(struct seq_file *m,
9300 struct pid_namespace *ns, struct pid *pid,
9301 struct task_struct *task);
9302 + int (*proc_vs_read)(char *page);
9303 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9304 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9307 struct ctl_table_header;
9308 @@ -263,6 +270,7 @@ struct ctl_table;
9315 struct proc_dir_entry *pde;
9316 diff -NurpP --minimal linux-2.6.33/include/linux/quotaops.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/quotaops.h
9317 --- linux-2.6.33/include/linux/quotaops.h 2009-12-03 20:02:56.000000000 +0100
9318 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/quotaops.h 2010-02-25 12:02:16.000000000 +0100
9320 #define _LINUX_QUOTAOPS_
9322 #include <linux/fs.h>
9323 +#include <linux/vs_dlimit.h>
9325 static inline struct quota_info *sb_dqopt(struct super_block *sb)
9327 @@ -154,10 +155,14 @@ static inline void vfs_dq_init(struct in
9328 * a transaction (deadlocks possible otherwise) */
9329 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9331 + if (dl_alloc_space(inode, nr))
9333 if (sb_any_quota_active(inode->i_sb)) {
9334 /* Used space is updated in alloc_space() */
9335 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
9336 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) {
9337 + dl_free_space(inode, nr);
9342 inode_add_bytes(inode, nr);
9343 @@ -174,10 +179,14 @@ static inline int vfs_dq_prealloc_space(
9345 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9347 + if (dl_alloc_space(inode, nr))
9349 if (sb_any_quota_active(inode->i_sb)) {
9350 /* Used space is updated in alloc_space() */
9351 - if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
9352 + if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) {
9353 + dl_free_space(inode, nr);
9358 inode_add_bytes(inode, nr);
9359 @@ -194,20 +203,28 @@ static inline int vfs_dq_alloc_space(str
9361 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9363 + if (dl_reserve_space(inode, nr))
9365 if (sb_any_quota_active(inode->i_sb)) {
9366 /* Used space is updated in alloc_space() */
9367 - if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
9368 + if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) {
9369 + dl_release_space(inode, nr);
9376 static inline int vfs_dq_alloc_inode(struct inode *inode)
9378 + if (dl_alloc_inode(inode))
9380 if (sb_any_quota_active(inode->i_sb)) {
9382 - if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
9383 + if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
9384 + dl_free_inode(inode);
9390 @@ -217,9 +234,13 @@ static inline int vfs_dq_alloc_inode(str
9392 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9394 + if (dl_claim_space(inode, nr))
9396 if (sb_any_quota_active(inode->i_sb)) {
9397 - if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
9398 + if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
9399 + dl_release_space(inode, nr);
9403 inode_add_bytes(inode, nr);
9405 @@ -235,6 +256,7 @@ void vfs_dq_release_reservation_space(st
9407 if (sb_any_quota_active(inode->i_sb))
9408 inode->i_sb->dq_op->release_rsv(inode, nr);
9409 + dl_release_space(inode, nr);
9412 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9413 @@ -243,6 +265,7 @@ static inline void vfs_dq_free_space_nod
9414 inode->i_sb->dq_op->free_space(inode, nr);
9416 inode_sub_bytes(inode, nr);
9417 + dl_free_space(inode, nr);
9420 static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
9421 @@ -255,6 +278,7 @@ static inline void vfs_dq_free_inode(str
9423 if (sb_any_quota_active(inode->i_sb))
9424 inode->i_sb->dq_op->free_inode(inode, 1);
9425 + dl_free_inode(inode);
9428 /* Cannot be called inside a transaction */
9429 @@ -358,6 +382,8 @@ static inline int vfs_dq_transfer(struct
9431 static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
9433 + if (dl_alloc_space(inode, nr))
9435 inode_add_bytes(inode, nr);
9438 @@ -371,6 +397,8 @@ static inline int vfs_dq_prealloc_space(
9440 static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
9442 + if (dl_alloc_space(inode, nr))
9444 inode_add_bytes(inode, nr);
9447 @@ -384,22 +412,28 @@ static inline int vfs_dq_alloc_space(str
9449 static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
9451 + if (dl_reserve_space(inode, nr))
9456 static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
9458 + if (dl_claim_space(inode, nr))
9460 return vfs_dq_alloc_space(inode, nr);
9464 int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
9466 + dl_release_space(inode, nr);
9470 static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
9472 + dl_free_space(inode, nr);
9473 inode_sub_bytes(inode, nr);
9476 diff -NurpP --minimal linux-2.6.33/include/linux/reboot.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/reboot.h
9477 --- linux-2.6.33/include/linux/reboot.h 2008-12-25 00:26:37.000000000 +0100
9478 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/reboot.h 2010-02-25 12:02:16.000000000 +0100
9480 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9481 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9482 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9483 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9487 diff -NurpP --minimal linux-2.6.33/include/linux/reiserfs_fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/reiserfs_fs.h
9488 --- linux-2.6.33/include/linux/reiserfs_fs.h 2010-02-25 11:52:07.000000000 +0100
9489 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/reiserfs_fs.h 2010-02-25 12:02:16.000000000 +0100
9490 @@ -977,6 +977,11 @@ struct stat_data_v1 {
9491 #define REISERFS_COMPR_FL FS_COMPR_FL
9492 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9494 +/* unfortunately reiserfs sdattr is only 16 bit */
9495 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9496 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9497 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9499 /* persistent flags that file inherits from the parent directory */
9500 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9501 REISERFS_SYNC_FL | \
9502 @@ -986,6 +991,9 @@ struct stat_data_v1 {
9503 REISERFS_COMPR_FL | \
9504 REISERFS_NOTAIL_FL )
9506 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9507 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9509 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9512 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
9513 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9514 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9515 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9516 +int reiserfs_sync_flags(struct inode *inode, int, int);
9519 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9520 diff -NurpP --minimal linux-2.6.33/include/linux/reiserfs_fs_sb.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/reiserfs_fs_sb.h
9521 --- linux-2.6.33/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9522 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/reiserfs_fs_sb.h 2010-02-25 12:02:16.000000000 +0100
9523 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9524 REISERFS_EXPOSE_PRIVROOT,
9525 REISERFS_BARRIER_NONE,
9526 REISERFS_BARRIER_FLUSH,
9529 /* Actions on error */
9530 REISERFS_ERROR_PANIC,
9531 diff -NurpP --minimal linux-2.6.33/include/linux/sched.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/sched.h
9532 --- linux-2.6.33/include/linux/sched.h 2010-02-25 11:52:07.000000000 +0100
9533 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/sched.h 2010-02-25 16:23:29.000000000 +0100
9534 @@ -401,25 +401,28 @@ static inline void arch_pick_mmap_layout
9535 * The mm counters are not protected by its page_table_lock,
9536 * so must be incremented atomically.
9538 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9539 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9540 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9541 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9542 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9543 +#define __set_mm_counter(mm, member, value) \
9544 + atomic_long_set(&(mm)->_##member, value)
9545 +#define get_mm_counter(mm, member) \
9546 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9548 #else /* !USE_SPLIT_PTLOCKS */
9550 * The mm counters are protected by its page_table_lock,
9551 * so can be incremented directly.
9553 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9554 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9555 #define get_mm_counter(mm, member) ((mm)->_##member)
9556 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9557 -#define inc_mm_counter(mm, member) (mm)->_##member++
9558 -#define dec_mm_counter(mm, member) (mm)->_##member--
9560 #endif /* !USE_SPLIT_PTLOCKS */
9562 +#define set_mm_counter(mm, member, value) \
9563 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9564 +#define add_mm_counter(mm, member, value) \
9565 + vx_ ## member ## pages_add((mm), (value))
9566 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9567 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9569 #define get_mm_rss(mm) \
9570 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9571 #define update_hiwater_rss(mm) do { \
9572 @@ -1200,6 +1203,12 @@ struct sched_entity {
9573 u64 nr_wakeups_affine_attempts;
9574 u64 nr_wakeups_passive;
9575 u64 nr_wakeups_idle;
9576 +#ifdef CONFIG_CFS_HARD_LIMITS
9577 + u64 throttle_start;
9579 + u64 throttle_count;
9584 #ifdef CONFIG_FAIR_GROUP_SCHED
9585 @@ -1412,6 +1421,14 @@ struct task_struct {
9589 +/* vserver context data */
9590 + struct vx_info *vx_info;
9591 + struct nx_info *nx_info;
9597 /* Thread group tracking */
9600 @@ -1645,6 +1662,11 @@ struct pid_namespace;
9601 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9602 struct pid_namespace *ns);
9604 +#include <linux/vserver/base.h>
9605 +#include <linux/vserver/context.h>
9606 +#include <linux/vserver/debug.h>
9607 +#include <linux/vserver/pid.h>
9609 static inline pid_t task_pid_nr(struct task_struct *tsk)
9612 @@ -1658,7 +1680,8 @@ static inline pid_t task_pid_nr_ns(struc
9614 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9616 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9617 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9618 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9622 @@ -1671,7 +1694,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9624 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9626 - return pid_vnr(task_tgid(tsk));
9627 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9631 diff -NurpP --minimal linux-2.6.33/include/linux/shmem_fs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/shmem_fs.h
9632 --- linux-2.6.33/include/linux/shmem_fs.h 2010-02-25 11:52:08.000000000 +0100
9633 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/shmem_fs.h 2010-02-25 12:02:16.000000000 +0100
9636 #define SHMEM_NR_DIRECT 16
9638 +#define TMPFS_SUPER_MAGIC 0x01021994
9641 struct shmem_inode_info {
9643 unsigned long flags;
9644 diff -NurpP --minimal linux-2.6.33/include/linux/stat.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/stat.h
9645 --- linux-2.6.33/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9646 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/stat.h 2010-02-25 12:02:16.000000000 +0100
9647 @@ -66,6 +66,7 @@ struct kstat {
9654 struct timespec atime;
9655 diff -NurpP --minimal linux-2.6.33/include/linux/sunrpc/auth.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/sunrpc/auth.h
9656 --- linux-2.6.33/include/linux/sunrpc/auth.h 2009-12-03 20:02:56.000000000 +0100
9657 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/sunrpc/auth.h 2010-02-25 12:02:16.000000000 +0100
9663 struct group_info *group_info;
9664 unsigned char machine_cred : 1;
9666 diff -NurpP --minimal linux-2.6.33/include/linux/sunrpc/clnt.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/sunrpc/clnt.h
9667 --- linux-2.6.33/include/linux/sunrpc/clnt.h 2009-12-03 20:02:56.000000000 +0100
9668 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/sunrpc/clnt.h 2010-02-25 12:02:16.000000000 +0100
9669 @@ -49,7 +49,8 @@ struct rpc_clnt {
9670 unsigned int cl_softrtry : 1,/* soft timeouts */
9671 cl_discrtry : 1,/* disconnect before retry */
9672 cl_autobind : 1,/* use getport() */
9673 - cl_chatty : 1;/* be verbose */
9674 + cl_chatty : 1,/* be verbose */
9675 + cl_tag : 1;/* context tagging */
9677 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9678 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9679 diff -NurpP --minimal linux-2.6.33/include/linux/syscalls.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/syscalls.h
9680 --- linux-2.6.33/include/linux/syscalls.h 2010-02-25 11:52:08.000000000 +0100
9681 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/syscalls.h 2010-02-25 12:02:16.000000000 +0100
9682 @@ -496,6 +496,8 @@ asmlinkage long sys_symlink(const char _
9683 asmlinkage long sys_unlink(const char __user *pathname);
9684 asmlinkage long sys_rename(const char __user *oldname,
9685 const char __user *newname);
9686 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9688 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9689 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9691 diff -NurpP --minimal linux-2.6.33/include/linux/sysctl.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/sysctl.h
9692 --- linux-2.6.33/include/linux/sysctl.h 2010-02-25 11:52:08.000000000 +0100
9693 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/sysctl.h 2010-02-25 12:02:16.000000000 +0100
9694 @@ -60,6 +60,7 @@ enum
9695 CTL_ABI=9, /* Binary emulation */
9696 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9697 CTL_ARLAN=254, /* arlan wireless driver */
9698 + CTL_VSERVER=4242, /* Linux-VServer debug */
9699 CTL_S390DBF=5677, /* s390 debug */
9700 CTL_SUNRPC=7249, /* sunrpc debug */
9701 CTL_PM=9899, /* frv power management */
9702 @@ -94,6 +95,7 @@ enum
9704 KERN_PANIC=15, /* int: panic timeout */
9705 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9706 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9708 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9709 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9710 diff -NurpP --minimal linux-2.6.33/include/linux/sysfs.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/sysfs.h
9711 --- linux-2.6.33/include/linux/sysfs.h 2010-02-25 11:52:08.000000000 +0100
9712 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/sysfs.h 2010-02-25 12:02:16.000000000 +0100
9714 #include <linux/list.h>
9715 #include <asm/atomic.h>
9717 +#define SYSFS_SUPER_MAGIC 0x62656572
9722 diff -NurpP --minimal linux-2.6.33/include/linux/time.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/time.h
9723 --- linux-2.6.33/include/linux/time.h 2010-02-25 11:52:08.000000000 +0100
9724 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/time.h 2010-02-25 12:02:16.000000000 +0100
9725 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
9726 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9730 +#include <linux/vs_time.h>
9732 #endif /* __KERNEL__ */
9734 #define NFDBITS __NFDBITS
9735 diff -NurpP --minimal linux-2.6.33/include/linux/types.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/types.h
9736 --- linux-2.6.33/include/linux/types.h 2009-09-10 15:26:26.000000000 +0200
9737 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/types.h 2010-02-25 12:02:16.000000000 +0100
9738 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t uid_t;
9739 typedef __kernel_gid32_t gid_t;
9740 typedef __kernel_uid16_t uid16_t;
9741 typedef __kernel_gid16_t gid16_t;
9742 +typedef unsigned int xid_t;
9743 +typedef unsigned int nid_t;
9744 +typedef unsigned int tag_t;
9746 typedef unsigned long uintptr_t;
9748 diff -NurpP --minimal linux-2.6.33/include/linux/vroot.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vroot.h
9749 --- linux-2.6.33/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9750 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vroot.h 2010-02-25 12:02:16.000000000 +0100
9754 + * include/linux/vroot.h
9756 + * written by Herbert Pötzl, 9/11/2002
9757 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9759 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9760 + * Redistribution of this file is permitted under the
9761 + * GNU General Public License.
9764 +#ifndef _LINUX_VROOT_H
9765 +#define _LINUX_VROOT_H
9770 +/* Possible states of device */
9776 +struct vroot_device {
9780 + struct semaphore vr_ctl_mutex;
9781 + struct block_device *vr_device;
9786 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9788 +extern int register_vroot_grb(vroot_grb_func *);
9789 +extern int unregister_vroot_grb(vroot_grb_func *);
9791 +#endif /* __KERNEL__ */
9793 +#define MAX_VROOT_DEFAULT 8
9796 + * IOCTL commands --- we will commandeer 0x56 ('V')
9799 +#define VROOT_SET_DEV 0x5600
9800 +#define VROOT_CLR_DEV 0x5601
9802 +#endif /* _LINUX_VROOT_H */
9803 diff -NurpP --minimal linux-2.6.33/include/linux/vs_base.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_base.h
9804 --- linux-2.6.33/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9805 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_base.h 2010-02-25 12:02:16.000000000 +0100
9810 +#include "vserver/base.h"
9811 +#include "vserver/check.h"
9812 +#include "vserver/debug.h"
9815 +#warning duplicate inclusion
9817 diff -NurpP --minimal linux-2.6.33/include/linux/vs_context.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_context.h
9818 --- linux-2.6.33/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9819 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_context.h 2010-02-25 12:02:16.000000000 +0100
9821 +#ifndef _VS_CONTEXT_H
9822 +#define _VS_CONTEXT_H
9824 +#include "vserver/base.h"
9825 +#include "vserver/check.h"
9826 +#include "vserver/context.h"
9827 +#include "vserver/history.h"
9828 +#include "vserver/debug.h"
9830 +#include <linux/sched.h>
9833 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9835 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9836 + const char *_file, int _line, void *_here)
9841 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9842 + vxi, vxi ? vxi->vx_id : 0,
9843 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9845 + __vxh_get_vx_info(vxi, _here);
9847 + atomic_inc(&vxi->vx_usecnt);
9852 +extern void free_vx_info(struct vx_info *);
9854 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9856 +static inline void __put_vx_info(struct vx_info *vxi,
9857 + const char *_file, int _line, void *_here)
9862 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9863 + vxi, vxi ? vxi->vx_id : 0,
9864 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9866 + __vxh_put_vx_info(vxi, _here);
9868 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9869 + free_vx_info(vxi);
9873 +#define init_vx_info(p, i) \
9874 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9876 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9877 + const char *_file, int _line, void *_here)
9880 + vxlprintk(VXD_CBIT(xid, 3),
9881 + "init_vx_info(%p[#%d.%d])",
9882 + vxi, vxi ? vxi->vx_id : 0,
9883 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9885 + __vxh_init_vx_info(vxi, vxp, _here);
9887 + atomic_inc(&vxi->vx_usecnt);
9893 +#define set_vx_info(p, i) \
9894 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9896 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9897 + const char *_file, int _line, void *_here)
9899 + struct vx_info *vxo;
9904 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9905 + vxi, vxi ? vxi->vx_id : 0,
9906 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9908 + __vxh_set_vx_info(vxi, vxp, _here);
9910 + atomic_inc(&vxi->vx_usecnt);
9911 + vxo = xchg(vxp, vxi);
9916 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9918 +static inline void __clr_vx_info(struct vx_info **vxp,
9919 + const char *_file, int _line, void *_here)
9921 + struct vx_info *vxo;
9923 + vxo = xchg(vxp, NULL);
9927 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9928 + vxo, vxo ? vxo->vx_id : 0,
9929 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9931 + __vxh_clr_vx_info(vxo, vxp, _here);
9933 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9934 + free_vx_info(vxo);
9938 +#define claim_vx_info(v, p) \
9939 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9941 +static inline void __claim_vx_info(struct vx_info *vxi,
9942 + struct task_struct *task,
9943 + const char *_file, int _line, void *_here)
9945 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9946 + vxi, vxi ? vxi->vx_id : 0,
9947 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9948 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9949 + task, _file, _line);
9950 + __vxh_claim_vx_info(vxi, task, _here);
9952 + atomic_inc(&vxi->vx_tasks);
9956 +extern void unhash_vx_info(struct vx_info *);
9958 +#define release_vx_info(v, p) \
9959 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9961 +static inline void __release_vx_info(struct vx_info *vxi,
9962 + struct task_struct *task,
9963 + const char *_file, int _line, void *_here)
9965 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9966 + vxi, vxi ? vxi->vx_id : 0,
9967 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9968 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9969 + task, _file, _line);
9970 + __vxh_release_vx_info(vxi, task, _here);
9974 + if (atomic_dec_and_test(&vxi->vx_tasks))
9975 + unhash_vx_info(vxi);
9979 +#define task_get_vx_info(p) \
9980 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9982 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9983 + const char *_file, int _line, void *_here)
9985 + struct vx_info *vxi;
9988 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9990 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9996 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9998 + if (waitqueue_active(&vxi->vx_wait))
9999 + wake_up_interruptible(&vxi->vx_wait);
10003 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
10005 +static inline void __enter_vx_info(struct vx_info *vxi,
10006 + struct vx_info_save *vxis, const char *_file, int _line)
10008 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
10009 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
10010 + current->xid, current->vx_info, _file, _line);
10011 + vxis->vxi = xchg(¤t->vx_info, vxi);
10012 + vxis->xid = current->xid;
10013 + current->xid = vxi ? vxi->vx_id : 0;
10016 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
10018 +static inline void __leave_vx_info(struct vx_info_save *vxis,
10019 + const char *_file, int _line)
10021 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
10022 + vxis, vxis->xid, vxis->vxi, current,
10023 + current->xid, current->vx_info, _file, _line);
10024 + (void)xchg(¤t->vx_info, vxis->vxi);
10025 + current->xid = vxis->xid;
10029 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
10031 + vxis->vxi = xchg(¤t->vx_info, NULL);
10032 + vxis->xid = xchg(¤t->xid, (xid_t)0);
10035 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
10037 + (void)xchg(¤t->xid, vxis->xid);
10038 + (void)xchg(¤t->vx_info, vxis->vxi);
10041 +#define task_is_init(p) \
10042 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
10044 +static inline int __task_is_init(struct task_struct *p,
10045 + const char *_file, int _line, void *_here)
10047 + int is_init = is_global_init(p);
10051 + is_init = p->vx_info->vx_initpid == p->pid;
10056 +extern void exit_vx_info(struct task_struct *, int);
10057 +extern void exit_vx_info_early(struct task_struct *, int);
10061 +#warning duplicate inclusion
10063 diff -NurpP --minimal linux-2.6.33/include/linux/vs_cowbl.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_cowbl.h
10064 --- linux-2.6.33/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
10065 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_cowbl.h 2010-02-25 12:02:16.000000000 +0100
10067 +#ifndef _VS_COWBL_H
10068 +#define _VS_COWBL_H
10070 +#include <linux/fs.h>
10071 +#include <linux/dcache.h>
10072 +#include <linux/namei.h>
10074 +extern struct dentry *cow_break_link(const char *pathname);
10076 +static inline int cow_check_and_break(struct path *path)
10078 + struct inode *inode = path->dentry->d_inode;
10081 + /* do we need this check? */
10082 + if (IS_RDONLY(inode))
10085 + if (IS_COW(inode)) {
10086 + if (IS_COW_LINK(inode)) {
10087 + struct dentry *new_dentry, *old_dentry = path->dentry;
10090 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
10094 + pp = d_path(path, buf, PATH_MAX);
10095 + new_dentry = cow_break_link(pp);
10097 + if (!IS_ERR(new_dentry)) {
10098 + path->dentry = new_dentry;
10099 + dput(old_dentry);
10101 + error = PTR_ERR(new_dentry);
10103 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
10104 + inode->i_ctime = CURRENT_TIME;
10105 + mark_inode_dirty(inode);
10112 +#warning duplicate inclusion
10114 diff -NurpP --minimal linux-2.6.33/include/linux/vs_cvirt.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_cvirt.h
10115 --- linux-2.6.33/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
10116 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_cvirt.h 2010-02-25 12:02:16.000000000 +0100
10118 +#ifndef _VS_CVIRT_H
10119 +#define _VS_CVIRT_H
10121 +#include "vserver/cvirt.h"
10122 +#include "vserver/context.h"
10123 +#include "vserver/base.h"
10124 +#include "vserver/check.h"
10125 +#include "vserver/debug.h"
10128 +static inline void vx_activate_task(struct task_struct *p)
10130 + struct vx_info *vxi;
10132 + if ((vxi = p->vx_info)) {
10133 + vx_update_load(vxi);
10134 + atomic_inc(&vxi->cvirt.nr_running);
10138 +static inline void vx_deactivate_task(struct task_struct *p)
10140 + struct vx_info *vxi;
10142 + if ((vxi = p->vx_info)) {
10143 + vx_update_load(vxi);
10144 + atomic_dec(&vxi->cvirt.nr_running);
10148 +static inline void vx_uninterruptible_inc(struct task_struct *p)
10150 + struct vx_info *vxi;
10152 + if ((vxi = p->vx_info))
10153 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
10156 +static inline void vx_uninterruptible_dec(struct task_struct *p)
10158 + struct vx_info *vxi;
10160 + if ((vxi = p->vx_info))
10161 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
10166 +#warning duplicate inclusion
10168 diff -NurpP --minimal linux-2.6.33/include/linux/vs_device.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_device.h
10169 --- linux-2.6.33/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
10170 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_device.h 2010-02-25 12:02:16.000000000 +0100
10172 +#ifndef _VS_DEVICE_H
10173 +#define _VS_DEVICE_H
10175 +#include "vserver/base.h"
10176 +#include "vserver/device.h"
10177 +#include "vserver/debug.h"
10180 +#ifdef CONFIG_VSERVER_DEVICE
10182 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
10184 +#define vs_device_perm(v, d, m, p) \
10185 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
10190 +int vs_map_device(struct vx_info *vxi,
10191 + dev_t device, dev_t *target, umode_t mode)
10194 + *target = device;
10198 +#define vs_device_perm(v, d, m, p) ((p) == (p))
10203 +#define vs_map_chrdev(d, t, p) \
10204 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
10205 +#define vs_map_blkdev(d, t, p) \
10206 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
10208 +#define vs_chrdev_perm(d, p) \
10209 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
10210 +#define vs_blkdev_perm(d, p) \
10211 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
10215 +#warning duplicate inclusion
10217 diff -NurpP --minimal linux-2.6.33/include/linux/vs_dlimit.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_dlimit.h
10218 --- linux-2.6.33/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
10219 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_dlimit.h 2010-02-25 12:02:16.000000000 +0100
10221 +#ifndef _VS_DLIMIT_H
10222 +#define _VS_DLIMIT_H
10224 +#include <linux/fs.h>
10226 +#include "vserver/dlimit.h"
10227 +#include "vserver/base.h"
10228 +#include "vserver/debug.h"
10231 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
10233 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
10234 + const char *_file, int _line)
10238 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
10239 + dli, dli ? dli->dl_tag : 0,
10240 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10242 + atomic_inc(&dli->dl_usecnt);
10247 +#define free_dl_info(i) \
10248 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
10250 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
10252 +static inline void __put_dl_info(struct dl_info *dli,
10253 + const char *_file, int _line)
10257 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10258 + dli, dli ? dli->dl_tag : 0,
10259 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10261 + if (atomic_dec_and_test(&dli->dl_usecnt))
10262 + free_dl_info(dli);
10266 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10268 +static inline int __dl_alloc_space(struct super_block *sb,
10269 + tag_t tag, dlsize_t nr, const char *file, int line)
10271 + struct dl_info *dli = NULL;
10276 + dli = locate_dl_info(sb, tag);
10280 + spin_lock(&dli->dl_lock);
10281 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10283 + dli->dl_space_used += nr;
10284 + spin_unlock(&dli->dl_lock);
10285 + put_dl_info(dli);
10287 + vxlprintk(VXD_CBIT(dlim, 1),
10288 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10289 + sb, tag, __dlimit_char(dli), (long long)nr,
10290 + ret, file, line);
10294 +static inline void __dl_free_space(struct super_block *sb,
10295 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10297 + struct dl_info *dli = NULL;
10301 + dli = locate_dl_info(sb, tag);
10305 + spin_lock(&dli->dl_lock);
10306 + if (dli->dl_space_used > nr)
10307 + dli->dl_space_used -= nr;
10309 + dli->dl_space_used = 0;
10310 + spin_unlock(&dli->dl_lock);
10311 + put_dl_info(dli);
10313 + vxlprintk(VXD_CBIT(dlim, 1),
10314 + "FREE (%p,#%d)%c %lld bytes",
10315 + sb, tag, __dlimit_char(dli), (long long)nr,
10319 +static inline int __dl_alloc_inode(struct super_block *sb,
10320 + tag_t tag, const char *_file, int _line)
10322 + struct dl_info *dli;
10325 + dli = locate_dl_info(sb, tag);
10329 + spin_lock(&dli->dl_lock);
10330 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
10332 + dli->dl_inodes_used++;
10333 + spin_unlock(&dli->dl_lock);
10334 + put_dl_info(dli);
10336 + vxlprintk(VXD_CBIT(dlim, 0),
10337 + "ALLOC (%p,#%d)%c inode (%d)",
10338 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10342 +static inline void __dl_free_inode(struct super_block *sb,
10343 + tag_t tag, const char *_file, int _line)
10345 + struct dl_info *dli;
10347 + dli = locate_dl_info(sb, tag);
10351 + spin_lock(&dli->dl_lock);
10352 + if (dli->dl_inodes_used > 1)
10353 + dli->dl_inodes_used--;
10355 + dli->dl_inodes_used = 0;
10356 + spin_unlock(&dli->dl_lock);
10357 + put_dl_info(dli);
10359 + vxlprintk(VXD_CBIT(dlim, 0),
10360 + "FREE (%p,#%d)%c inode",
10361 + sb, tag, __dlimit_char(dli), _file, _line);
10364 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10365 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10366 + const char *_file, int _line)
10368 + struct dl_info *dli;
10369 + uint64_t broot, bfree;
10371 + dli = locate_dl_info(sb, tag);
10375 + spin_lock(&dli->dl_lock);
10376 + broot = (dli->dl_space_total -
10377 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10378 + >> sb->s_blocksize_bits;
10379 + bfree = (dli->dl_space_total - dli->dl_space_used)
10380 + >> sb->s_blocksize_bits;
10381 + spin_unlock(&dli->dl_lock);
10383 + vxlprintk(VXD_CBIT(dlim, 2),
10384 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10385 + (long long)bfree, (long long)broot,
10386 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10388 + if (free_blocks) {
10389 + if (*free_blocks > bfree)
10390 + *free_blocks = bfree;
10392 + if (root_blocks) {
10393 + if (*root_blocks > broot)
10394 + *root_blocks = broot;
10396 + put_dl_info(dli);
10399 +#define dl_prealloc_space(in, bytes) \
10400 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10401 + __FILE__, __LINE__ )
10403 +#define dl_alloc_space(in, bytes) \
10404 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10405 + __FILE__, __LINE__ )
10407 +#define dl_reserve_space(in, bytes) \
10408 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10409 + __FILE__, __LINE__ )
10411 +#define dl_claim_space(in, bytes) (0)
10413 +#define dl_release_space(in, bytes) \
10414 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10415 + __FILE__, __LINE__ )
10417 +#define dl_free_space(in, bytes) \
10418 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10419 + __FILE__, __LINE__ )
10423 +#define dl_alloc_inode(in) \
10424 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10426 +#define dl_free_inode(in) \
10427 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10430 +#define dl_adjust_block(sb, tag, fb, rb) \
10431 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10435 +#warning duplicate inclusion
10437 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/base.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/base.h
10438 --- linux-2.6.33/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10439 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/base.h 2010-02-25 12:02:16.000000000 +0100
10441 +#ifndef _VX_BASE_H
10442 +#define _VX_BASE_H
10445 +/* context state changes */
10457 +#define vx_task_xid(t) ((t)->xid)
10459 +#define vx_current_xid() vx_task_xid(current)
10461 +#define current_vx_info() (current->vx_info)
10464 +#define nx_task_nid(t) ((t)->nid)
10466 +#define nx_current_nid() nx_task_nid(current)
10468 +#define current_nx_info() (current->nx_info)
10471 +/* generic flag merging */
10473 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10475 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10477 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10479 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10482 +/* context flags */
10484 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10486 +#define vx_current_flags() __vx_flags(current_vx_info())
10488 +#define vx_info_flags(v, m, f) \
10489 + vs_check_flags(__vx_flags(v), m, f)
10491 +#define task_vx_flags(t, m, f) \
10492 + ((t) && vx_info_flags((t)->vx_info, m, f))
10494 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10497 +/* context caps */
10499 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10501 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10503 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10505 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10509 +/* network flags */
10511 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10513 +#define nx_current_flags() __nx_flags(current_nx_info())
10515 +#define nx_info_flags(n, m, f) \
10516 + vs_check_flags(__nx_flags(n), m, f)
10518 +#define task_nx_flags(t, m, f) \
10519 + ((t) && nx_info_flags((t)->nx_info, m, f))
10521 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10524 +/* network caps */
10526 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10528 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10530 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10532 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10535 +/* context mask capabilities */
10537 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10539 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10541 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10544 +/* context bcap mask */
10546 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10548 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10551 +/* mask given bcaps */
10553 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10555 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10558 +/* masked cap_bset */
10560 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10562 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10565 +#define vx_info_mbcap(v, b) \
10566 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10567 + vx_info_bcaps(v, b) : (b))
10569 +#define task_vx_mbcap(t, b) \
10570 + vx_info_mbcap((t)->vx_info, (t)->b)
10572 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10575 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10577 +#define vx_capable(b, c) (capable(b) || \
10578 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10580 +#define nx_capable(b, c) (capable(b) || \
10581 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10583 +#define vx_task_initpid(t, n) \
10584 + ((t)->vx_info && \
10585 + ((t)->vx_info->vx_initpid == (n)))
10587 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10590 +/* context unshare mask */
10592 +#define __vx_umask(v) ((v)->vx_umask)
10594 +#define vx_current_umask() __vx_umask(current_vx_info())
10596 +#define vx_can_unshare(b, f) (capable(b) || \
10597 + (cap_raised(current_cap(), b) && \
10598 + !((f) & ~vx_current_umask())))
10601 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10603 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10606 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10608 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10611 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct_cmd.h
10612 --- linux-2.6.33/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10613 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct_cmd.h 2010-02-25 12:02:16.000000000 +0100
10615 +#ifndef _VX_CACCT_CMD_H
10616 +#define _VX_CACCT_CMD_H
10619 +/* virtual host info name commands */
10621 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10623 +struct vcmd_sock_stat_v0 {
10625 + uint32_t count[3];
10626 + uint64_t total[3];
10632 +#include <linux/compiler.h>
10634 +extern int vc_sock_stat(struct vx_info *, void __user *);
10636 +#endif /* __KERNEL__ */
10637 +#endif /* _VX_CACCT_CMD_H */
10638 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct_def.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct_def.h
10639 --- linux-2.6.33/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10640 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct_def.h 2010-02-25 12:02:16.000000000 +0100
10642 +#ifndef _VX_CACCT_DEF_H
10643 +#define _VX_CACCT_DEF_H
10645 +#include <asm/atomic.h>
10646 +#include <linux/vserver/cacct.h>
10649 +struct _vx_sock_acc {
10650 + atomic_long_t count;
10651 + atomic_long_t total;
10654 +/* context sub struct */
10656 +struct _vx_cacct {
10657 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10658 + atomic_t slab[8];
10659 + atomic_t page[6][8];
10662 +#ifdef CONFIG_VSERVER_DEBUG
10664 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10668 + printk("\t_vx_cacct:");
10669 + for (i = 0; i < 6; i++) {
10670 + struct _vx_sock_acc *ptr = cacct->sock[i];
10672 + printk("\t [%d] =", i);
10673 + for (j = 0; j < 3; j++) {
10674 + printk(" [%d] = %8lu, %8lu", j,
10675 + atomic_long_read(&ptr[j].count),
10676 + atomic_long_read(&ptr[j].total));
10684 +#endif /* _VX_CACCT_DEF_H */
10685 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct.h
10686 --- linux-2.6.33/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10687 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct.h 2010-02-25 12:02:16.000000000 +0100
10689 +#ifndef _VX_CACCT_H
10690 +#define _VX_CACCT_H
10693 +enum sock_acc_field {
10694 + VXA_SOCK_UNSPEC = 0,
10700 + VXA_SOCK_SIZE /* array size */
10703 +#endif /* _VX_CACCT_H */
10704 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cacct_int.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct_int.h
10705 --- linux-2.6.33/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10706 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cacct_int.h 2010-02-25 12:02:16.000000000 +0100
10708 +#ifndef _VX_CACCT_INT_H
10709 +#define _VX_CACCT_INT_H
10715 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10717 + return atomic_long_read(&cacct->sock[type][pos].count);
10722 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10724 + return atomic_long_read(&cacct->sock[type][pos].total);
10727 +#endif /* __KERNEL__ */
10728 +#endif /* _VX_CACCT_INT_H */
10729 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/check.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/check.h
10730 --- linux-2.6.33/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10731 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/check.h 2010-02-25 12:02:16.000000000 +0100
10733 +#ifndef _VS_CHECK_H
10734 +#define _VS_CHECK_H
10737 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10739 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10740 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10742 +#define MIN_D_CONTEXT 65536
10745 +/* check conditions */
10747 +#define VS_ADMIN 0x0001
10748 +#define VS_WATCH 0x0002
10749 +#define VS_HIDE 0x0004
10750 +#define VS_HOSTID 0x0008
10752 +#define VS_IDENT 0x0010
10753 +#define VS_EQUIV 0x0020
10754 +#define VS_PARENT 0x0040
10755 +#define VS_CHILD 0x0080
10757 +#define VS_ARG_MASK 0x00F0
10759 +#define VS_DYNAMIC 0x0100
10760 +#define VS_STATIC 0x0200
10762 +#define VS_ATR_MASK 0x0F00
10764 +#ifdef CONFIG_VSERVER_PRIVACY
10765 +#define VS_ADMIN_P (0)
10766 +#define VS_WATCH_P (0)
10768 +#define VS_ADMIN_P VS_ADMIN
10769 +#define VS_WATCH_P VS_WATCH
10772 +#define VS_HARDIRQ 0x1000
10773 +#define VS_SOFTIRQ 0x2000
10774 +#define VS_IRQ 0x4000
10776 +#define VS_IRQ_MASK 0xF000
10778 +#include <linux/hardirq.h>
10781 + * check current context for ADMIN/WATCH and
10782 + * optionally against supplied argument
10784 +static inline int __vs_check(int cid, int id, unsigned int mode)
10786 + if (mode & VS_ARG_MASK) {
10787 + if ((mode & VS_IDENT) && (id == cid))
10790 + if (mode & VS_ATR_MASK) {
10791 + if ((mode & VS_DYNAMIC) &&
10792 + (id >= MIN_D_CONTEXT) &&
10793 + (id <= MAX_S_CONTEXT))
10795 + if ((mode & VS_STATIC) &&
10796 + (id > 1) && (id < MIN_D_CONTEXT))
10799 + if (mode & VS_IRQ_MASK) {
10800 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10802 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10804 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10807 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10808 + ((mode & VS_WATCH) && (cid == 1)) ||
10809 + ((mode & VS_HOSTID) && (id == 0)));
10812 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10814 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10817 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10819 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10822 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/context_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/context_cmd.h
10823 --- linux-2.6.33/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10824 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/context_cmd.h 2010-02-25 12:02:16.000000000 +0100
10826 +#ifndef _VX_CONTEXT_CMD_H
10827 +#define _VX_CONTEXT_CMD_H
10830 +/* vinfo commands */
10832 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10835 +extern int vc_task_xid(uint32_t);
10837 +#endif /* __KERNEL__ */
10839 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10841 +struct vcmd_vx_info_v0 {
10843 + uint32_t initpid;
10844 + /* more to come */
10848 +extern int vc_vx_info(struct vx_info *, void __user *);
10850 +#endif /* __KERNEL__ */
10852 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10854 +struct vcmd_ctx_stat_v0 {
10857 + /* more to come */
10861 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10863 +#endif /* __KERNEL__ */
10865 +/* context commands */
10867 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10868 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10870 +struct vcmd_ctx_create {
10871 + uint64_t flagword;
10874 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10875 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10877 +struct vcmd_ctx_migrate {
10878 + uint64_t flagword;
10882 +extern int vc_ctx_create(uint32_t, void __user *);
10883 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10885 +#endif /* __KERNEL__ */
10888 +/* flag commands */
10890 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10891 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10893 +struct vcmd_ctx_flags_v0 {
10894 + uint64_t flagword;
10899 +extern int vc_get_cflags(struct vx_info *, void __user *);
10900 +extern int vc_set_cflags(struct vx_info *, void __user *);
10902 +#endif /* __KERNEL__ */
10905 +/* context caps commands */
10907 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10908 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10910 +struct vcmd_ctx_caps_v1 {
10916 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10917 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10919 +#endif /* __KERNEL__ */
10922 +/* bcaps commands */
10924 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10925 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10927 +struct vcmd_bcaps {
10933 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10934 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10936 +#endif /* __KERNEL__ */
10939 +/* umask commands */
10941 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10942 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10944 +struct vcmd_umask {
10950 +extern int vc_get_umask(struct vx_info *, void __user *);
10951 +extern int vc_set_umask(struct vx_info *, void __user *);
10953 +#endif /* __KERNEL__ */
10958 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10959 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10961 +struct vcmd_badness_v0 {
10966 +extern int vc_get_badness(struct vx_info *, void __user *);
10967 +extern int vc_set_badness(struct vx_info *, void __user *);
10969 +#endif /* __KERNEL__ */
10970 +#endif /* _VX_CONTEXT_CMD_H */
10971 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/context.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/context.h
10972 --- linux-2.6.33/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10973 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/context.h 2010-02-25 12:02:16.000000000 +0100
10975 +#ifndef _VX_CONTEXT_H
10976 +#define _VX_CONTEXT_H
10978 +#include <linux/types.h>
10979 +#include <linux/capability.h>
10982 +/* context flags */
10984 +#define VXF_INFO_SCHED 0x00000002
10985 +#define VXF_INFO_NPROC 0x00000004
10986 +#define VXF_INFO_PRIVATE 0x00000008
10988 +#define VXF_INFO_INIT 0x00000010
10989 +#define VXF_INFO_HIDE 0x00000020
10990 +#define VXF_INFO_ULIMIT 0x00000040
10991 +#define VXF_INFO_NSPACE 0x00000080
10993 +#define VXF_SCHED_HARD 0x00000100
10994 +#define VXF_SCHED_PRIO 0x00000200
10995 +#define VXF_SCHED_PAUSE 0x00000400
10997 +#define VXF_VIRT_MEM 0x00010000
10998 +#define VXF_VIRT_UPTIME 0x00020000
10999 +#define VXF_VIRT_CPU 0x00040000
11000 +#define VXF_VIRT_LOAD 0x00080000
11001 +#define VXF_VIRT_TIME 0x00100000
11003 +#define VXF_HIDE_MOUNT 0x01000000
11004 +/* was VXF_HIDE_NETIF 0x02000000 */
11005 +#define VXF_HIDE_VINFO 0x04000000
11007 +#define VXF_STATE_SETUP (1ULL << 32)
11008 +#define VXF_STATE_INIT (1ULL << 33)
11009 +#define VXF_STATE_ADMIN (1ULL << 34)
11011 +#define VXF_SC_HELPER (1ULL << 36)
11012 +#define VXF_REBOOT_KILL (1ULL << 37)
11013 +#define VXF_PERSISTENT (1ULL << 38)
11015 +#define VXF_FORK_RSS (1ULL << 48)
11016 +#define VXF_PROLIFIC (1ULL << 49)
11018 +#define VXF_IGNEG_NICE (1ULL << 52)
11020 +#define VXF_ONE_TIME (0x0007ULL << 32)
11022 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11025 +/* context migration */
11027 +#define VXM_SET_INIT 0x00000001
11028 +#define VXM_SET_REAPER 0x00000002
11030 +/* context caps */
11032 +#define VXC_CAP_MASK 0x00000000
11034 +#define VXC_SET_UTSNAME 0x00000001
11035 +#define VXC_SET_RLIMIT 0x00000002
11036 +#define VXC_FS_SECURITY 0x00000004
11037 +#define VXC_TIOCSTI 0x00000010
11039 +/* was VXC_RAW_ICMP 0x00000100 */
11040 +#define VXC_SYSLOG 0x00001000
11041 +#define VXC_OOM_ADJUST 0x00002000
11042 +#define VXC_AUDIT_CONTROL 0x00004000
11044 +#define VXC_SECURE_MOUNT 0x00010000
11045 +#define VXC_SECURE_REMOUNT 0x00020000
11046 +#define VXC_BINARY_MOUNT 0x00040000
11048 +#define VXC_QUOTA_CTL 0x00100000
11049 +#define VXC_ADMIN_MAPPER 0x00200000
11050 +#define VXC_ADMIN_CLOOP 0x00400000
11052 +#define VXC_KTHREAD 0x01000000
11053 +#define VXC_NAMESPACE 0x02000000
11058 +#include <linux/list.h>
11059 +#include <linux/spinlock.h>
11060 +#include <linux/rcupdate.h>
11062 +#include "limit_def.h"
11063 +#include "sched_def.h"
11064 +#include "cvirt_def.h"
11065 +#include "cacct_def.h"
11066 +#include "device_def.h"
11068 +#define VX_SPACES 2
11070 +struct _vx_info_pc {
11071 + struct _vx_sched_pc sched_pc;
11072 + struct _vx_cvirt_pc cvirt_pc;
11076 + struct hlist_node vx_hlist; /* linked list of contexts */
11077 + xid_t vx_id; /* context id */
11078 + atomic_t vx_usecnt; /* usage count */
11079 + atomic_t vx_tasks; /* tasks count */
11080 + struct vx_info *vx_parent; /* parent context */
11081 + int vx_state; /* context state */
11083 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
11084 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
11085 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
11087 + uint64_t vx_flags; /* context flags */
11088 + uint64_t vx_ccaps; /* context caps (vserver) */
11089 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11090 + unsigned long vx_umask; /* unshare mask (guest) */
11092 + struct task_struct *vx_reaper; /* guest reaper process */
11093 + pid_t vx_initpid; /* PID of guest init */
11094 + int64_t vx_badness_bias; /* OOM points bias */
11096 + struct _vx_limit limit; /* vserver limits */
11097 + struct _vx_sched sched; /* vserver scheduler */
11098 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11099 + struct _vx_cacct cacct; /* context accounting */
11101 + struct _vx_device dmap; /* default device map targets */
11103 +#ifndef CONFIG_SMP
11104 + struct _vx_info_pc info_pc; /* per cpu data */
11106 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11109 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11110 + int reboot_cmd; /* last sys_reboot() cmd */
11111 + int exit_code; /* last process exit code */
11113 + char vx_name[65]; /* vserver name */
11116 +#ifndef CONFIG_SMP
11117 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11118 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11120 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11121 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11124 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11127 +struct vx_info_save {
11128 + struct vx_info *vxi;
11133 +/* status flags */
11135 +#define VXS_HASHED 0x0001
11136 +#define VXS_PAUSED 0x0010
11137 +#define VXS_SHUTDOWN 0x0100
11138 +#define VXS_HELPER 0x1000
11139 +#define VXS_RELEASED 0x8000
11142 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11143 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11145 +extern struct vx_info *lookup_vx_info(int);
11146 +extern struct vx_info *lookup_or_create_vx_info(int);
11148 +extern int get_xid_list(int, unsigned int *, int);
11149 +extern int xid_is_hashed(xid_t);
11151 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11153 +extern long vs_state_change(struct vx_info *, unsigned int);
11156 +#endif /* __KERNEL__ */
11157 +#endif /* _VX_CONTEXT_H */
11158 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cvirt_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cvirt_cmd.h
11159 --- linux-2.6.33/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11160 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cvirt_cmd.h 2010-02-25 12:02:16.000000000 +0100
11162 +#ifndef _VX_CVIRT_CMD_H
11163 +#define _VX_CVIRT_CMD_H
11166 +/* virtual host info name commands */
11168 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11169 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11171 +struct vcmd_vhi_name_v0 {
11177 +enum vhi_name_field {
11178 + VHIN_CONTEXT = 0,
11190 +#include <linux/compiler.h>
11192 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11193 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11195 +#endif /* __KERNEL__ */
11197 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11199 +struct vcmd_virt_stat_v0 {
11202 + uint32_t nr_threads;
11203 + uint32_t nr_running;
11204 + uint32_t nr_uninterruptible;
11205 + uint32_t nr_onhold;
11206 + uint32_t nr_forks;
11207 + uint32_t load[3];
11211 +extern int vc_virt_stat(struct vx_info *, void __user *);
11213 +#endif /* __KERNEL__ */
11214 +#endif /* _VX_CVIRT_CMD_H */
11215 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cvirt_def.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cvirt_def.h
11216 --- linux-2.6.33/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11217 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cvirt_def.h 2010-02-25 12:02:16.000000000 +0100
11219 +#ifndef _VX_CVIRT_DEF_H
11220 +#define _VX_CVIRT_DEF_H
11222 +#include <linux/jiffies.h>
11223 +#include <linux/spinlock.h>
11224 +#include <linux/wait.h>
11225 +#include <linux/time.h>
11226 +#include <asm/atomic.h>
11229 +struct _vx_usage_stat {
11233 + uint64_t softirq;
11239 +struct _vx_syslog {
11240 + wait_queue_head_t log_wait;
11241 + spinlock_t logbuf_lock; /* lock for the log buffer */
11243 + unsigned long log_start; /* next char to be read by syslog() */
11244 + unsigned long con_start; /* next char to be sent to consoles */
11245 + unsigned long log_end; /* most-recently-written-char + 1 */
11246 + unsigned long logged_chars; /* #chars since last read+clear operation */
11248 + char log_buf[1024];
11252 +/* context sub struct */
11254 +struct _vx_cvirt {
11255 + atomic_t nr_threads; /* number of current threads */
11256 + atomic_t nr_running; /* number of running threads */
11257 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11259 + atomic_t nr_onhold; /* processes on hold */
11260 + uint32_t onhold_last; /* jiffies when put on hold */
11262 + struct timeval bias_tv; /* time offset to the host */
11263 + struct timespec bias_idle;
11264 + struct timespec bias_uptime; /* context creation point */
11265 + uint64_t bias_clock; /* offset in clock_t */
11267 + spinlock_t load_lock; /* lock for the load averages */
11268 + atomic_t load_updates; /* nr of load updates done so far */
11269 + uint32_t load_last; /* last time load was calculated */
11270 + uint32_t load[3]; /* load averages 1,5,15 */
11272 + atomic_t total_forks; /* number of forks so far */
11274 + struct _vx_syslog syslog;
11277 +struct _vx_cvirt_pc {
11278 + struct _vx_usage_stat cpustat;
11282 +#ifdef CONFIG_VSERVER_DEBUG
11284 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11286 + printk("\t_vx_cvirt:\n");
11287 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11288 + atomic_read(&cvirt->nr_threads),
11289 + atomic_read(&cvirt->nr_running),
11290 + atomic_read(&cvirt->nr_uninterruptible),
11291 + atomic_read(&cvirt->nr_onhold));
11292 + /* add rest here */
11293 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11298 +#endif /* _VX_CVIRT_DEF_H */
11299 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/cvirt.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cvirt.h
11300 --- linux-2.6.33/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11301 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/cvirt.h 2010-02-25 12:02:16.000000000 +0100
11303 +#ifndef _VX_CVIRT_H
11304 +#define _VX_CVIRT_H
11311 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11316 +void vx_update_load(struct vx_info *);
11319 +int vx_do_syslog(int, char __user *, int);
11321 +#endif /* __KERNEL__ */
11322 +#endif /* _VX_CVIRT_H */
11323 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/debug_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/debug_cmd.h
11324 --- linux-2.6.33/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11325 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/debug_cmd.h 2010-02-25 12:02:16.000000000 +0100
11327 +#ifndef _VX_DEBUG_CMD_H
11328 +#define _VX_DEBUG_CMD_H
11331 +/* debug commands */
11333 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11335 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11336 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11338 +struct vcmd_read_history_v0 {
11341 + char __user *data;
11344 +struct vcmd_read_monitor_v0 {
11347 + char __user *data;
11353 +#ifdef CONFIG_COMPAT
11355 +#include <asm/compat.h>
11357 +struct vcmd_read_history_v0_x32 {
11360 + compat_uptr_t data_ptr;
11363 +struct vcmd_read_monitor_v0_x32 {
11366 + compat_uptr_t data_ptr;
11369 +#endif /* CONFIG_COMPAT */
11371 +extern int vc_dump_history(uint32_t);
11373 +extern int vc_read_history(uint32_t, void __user *);
11374 +extern int vc_read_monitor(uint32_t, void __user *);
11376 +#ifdef CONFIG_COMPAT
11378 +extern int vc_read_history_x32(uint32_t, void __user *);
11379 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11381 +#endif /* CONFIG_COMPAT */
11383 +#endif /* __KERNEL__ */
11384 +#endif /* _VX_DEBUG_CMD_H */
11385 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/debug.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/debug.h
11386 --- linux-2.6.33/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11387 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/debug.h 2010-02-25 12:02:16.000000000 +0100
11389 +#ifndef _VX_DEBUG_H
11390 +#define _VX_DEBUG_H
11393 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11394 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11395 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11397 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11398 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11399 +#define VXF_DEV "%p[%lu,%d:%d]"
11402 +#define vxd_path(p) \
11403 + ({ static char _buffer[PATH_MAX]; \
11404 + d_path(p, _buffer, sizeof(_buffer)); })
11406 +#define vxd_cond_path(n) \
11407 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11410 +#ifdef CONFIG_VSERVER_DEBUG
11412 +extern unsigned int vx_debug_switch;
11413 +extern unsigned int vx_debug_xid;
11414 +extern unsigned int vx_debug_nid;
11415 +extern unsigned int vx_debug_tag;
11416 +extern unsigned int vx_debug_net;
11417 +extern unsigned int vx_debug_limit;
11418 +extern unsigned int vx_debug_cres;
11419 +extern unsigned int vx_debug_dlim;
11420 +extern unsigned int vx_debug_quota;
11421 +extern unsigned int vx_debug_cvirt;
11422 +extern unsigned int vx_debug_space;
11423 +extern unsigned int vx_debug_misc;
11426 +#define VX_LOGLEVEL "vxD: "
11427 +#define VX_PROC_FMT "%p: "
11428 +#define VX_PROCESS current
11430 +#define vxdprintk(c, f, x...) \
11433 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11434 + VX_PROCESS , ##x); \
11437 +#define vxlprintk(c, f, x...) \
11440 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11443 +#define vxfprintk(c, f, x...) \
11446 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11452 +void dump_vx_info(struct vx_info *, int);
11453 +void dump_vx_info_inactive(int);
11455 +#else /* CONFIG_VSERVER_DEBUG */
11457 +#define vx_debug_switch 0
11458 +#define vx_debug_xid 0
11459 +#define vx_debug_nid 0
11460 +#define vx_debug_tag 0
11461 +#define vx_debug_net 0
11462 +#define vx_debug_limit 0
11463 +#define vx_debug_cres 0
11464 +#define vx_debug_dlim 0
11465 +#define vx_debug_cvirt 0
11467 +#define vxdprintk(x...) do { } while (0)
11468 +#define vxlprintk(x...) do { } while (0)
11469 +#define vxfprintk(x...) do { } while (0)
11471 +#endif /* CONFIG_VSERVER_DEBUG */
11474 +#ifdef CONFIG_VSERVER_WARN
11476 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11477 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11478 +#define VX_WARN_XID "[xid #%u] "
11479 +#define VX_WARN_NID "[nid #%u] "
11480 +#define VX_WARN_TAG "[tag #%u] "
11482 +#define vxwprintk(c, f, x...) \
11485 + printk(VX_WARNLEVEL f "\n", ##x); \
11488 +#else /* CONFIG_VSERVER_WARN */
11490 +#define vxwprintk(x...) do { } while (0)
11492 +#endif /* CONFIG_VSERVER_WARN */
11494 +#define vxwprintk_task(c, f, x...) \
11495 + vxwprintk(c, VX_WARN_TASK f, \
11496 + current->comm, current->pid, \
11497 + current->xid, current->nid, current->tag, ##x)
11498 +#define vxwprintk_xid(c, f, x...) \
11499 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11500 +#define vxwprintk_nid(c, f, x...) \
11501 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11502 +#define vxwprintk_tag(c, f, x...) \
11503 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11505 +#ifdef CONFIG_VSERVER_DEBUG
11506 +#define vxd_assert_lock(l) assert_spin_locked(l)
11507 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11508 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11510 +#define vxd_assert_lock(l) do { } while (0)
11511 +#define vxd_assert(c, f, x...) do { } while (0)
11515 +#endif /* _VX_DEBUG_H */
11516 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/device_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/device_cmd.h
11517 --- linux-2.6.33/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11518 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/device_cmd.h 2010-02-25 12:02:16.000000000 +0100
11520 +#ifndef _VX_DEVICE_CMD_H
11521 +#define _VX_DEVICE_CMD_H
11524 +/* device vserver commands */
11526 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11527 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11529 +struct vcmd_set_mapping_v0 {
11530 + const char __user *device;
11531 + const char __user *target;
11538 +#ifdef CONFIG_COMPAT
11540 +#include <asm/compat.h>
11542 +struct vcmd_set_mapping_v0_x32 {
11543 + compat_uptr_t device_ptr;
11544 + compat_uptr_t target_ptr;
11548 +#endif /* CONFIG_COMPAT */
11550 +#include <linux/compiler.h>
11552 +extern int vc_set_mapping(struct vx_info *, void __user *);
11553 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11555 +#ifdef CONFIG_COMPAT
11557 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11558 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11560 +#endif /* CONFIG_COMPAT */
11562 +#endif /* __KERNEL__ */
11563 +#endif /* _VX_DEVICE_CMD_H */
11564 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/device_def.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/device_def.h
11565 --- linux-2.6.33/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11566 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/device_def.h 2010-02-25 12:02:16.000000000 +0100
11568 +#ifndef _VX_DEVICE_DEF_H
11569 +#define _VX_DEVICE_DEF_H
11571 +#include <linux/types.h>
11573 +struct vx_dmap_target {
11578 +struct _vx_device {
11579 +#ifdef CONFIG_VSERVER_DEVICE
11580 + struct vx_dmap_target targets[2];
11584 +#endif /* _VX_DEVICE_DEF_H */
11585 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/device.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/device.h
11586 --- linux-2.6.33/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11587 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/device.h 2010-02-25 12:02:16.000000000 +0100
11589 +#ifndef _VX_DEVICE_H
11590 +#define _VX_DEVICE_H
11593 +#define DATTR_CREATE 0x00000001
11594 +#define DATTR_OPEN 0x00000002
11596 +#define DATTR_REMAP 0x00000010
11598 +#define DATTR_MASK 0x00000013
11601 +#else /* _VX_DEVICE_H */
11602 +#warning duplicate inclusion
11603 +#endif /* _VX_DEVICE_H */
11604 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/dlimit_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/dlimit_cmd.h
11605 --- linux-2.6.33/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11606 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/dlimit_cmd.h 2010-02-25 12:02:16.000000000 +0100
11608 +#ifndef _VX_DLIMIT_CMD_H
11609 +#define _VX_DLIMIT_CMD_H
11612 +/* dlimit vserver commands */
11614 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11615 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11617 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11618 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11620 +struct vcmd_ctx_dlimit_base_v0 {
11621 + const char __user *name;
11625 +struct vcmd_ctx_dlimit_v0 {
11626 + const char __user *name;
11627 + uint32_t space_used; /* used space in kbytes */
11628 + uint32_t space_total; /* maximum space in kbytes */
11629 + uint32_t inodes_used; /* used inodes */
11630 + uint32_t inodes_total; /* maximum inodes */
11631 + uint32_t reserved; /* reserved for root in % */
11635 +#define CDLIM_UNSET ((uint32_t)0UL)
11636 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11637 +#define CDLIM_KEEP ((uint32_t)~1UL)
11639 +#define DLIME_UNIT 0
11640 +#define DLIME_KILO 1
11641 +#define DLIME_MEGA 2
11642 +#define DLIME_GIGA 3
11644 +#define DLIMF_SHIFT 0x10
11646 +#define DLIMS_USED 0
11647 +#define DLIMS_TOTAL 2
11650 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11652 + int exp = (flags & DLIMF_SHIFT) ?
11653 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11654 + return ((uint64_t)val) << (10 * exp);
11658 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11662 + if (*flags & DLIMF_SHIFT) {
11663 + while (val > (1LL << 32) && (exp < 3)) {
11667 + *flags &= ~(DLIME_GIGA << shift);
11668 + *flags |= exp << shift;
11676 +#ifdef CONFIG_COMPAT
11678 +#include <asm/compat.h>
11680 +struct vcmd_ctx_dlimit_base_v0_x32 {
11681 + compat_uptr_t name_ptr;
11685 +struct vcmd_ctx_dlimit_v0_x32 {
11686 + compat_uptr_t name_ptr;
11687 + uint32_t space_used; /* used space in kbytes */
11688 + uint32_t space_total; /* maximum space in kbytes */
11689 + uint32_t inodes_used; /* used inodes */
11690 + uint32_t inodes_total; /* maximum inodes */
11691 + uint32_t reserved; /* reserved for root in % */
11695 +#endif /* CONFIG_COMPAT */
11697 +#include <linux/compiler.h>
11699 +extern int vc_add_dlimit(uint32_t, void __user *);
11700 +extern int vc_rem_dlimit(uint32_t, void __user *);
11702 +extern int vc_set_dlimit(uint32_t, void __user *);
11703 +extern int vc_get_dlimit(uint32_t, void __user *);
11705 +#ifdef CONFIG_COMPAT
11707 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11708 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11710 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11711 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11713 +#endif /* CONFIG_COMPAT */
11715 +#endif /* __KERNEL__ */
11716 +#endif /* _VX_DLIMIT_CMD_H */
11717 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/dlimit.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/dlimit.h
11718 --- linux-2.6.33/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11719 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/dlimit.h 2010-02-25 12:02:16.000000000 +0100
11721 +#ifndef _VX_DLIMIT_H
11722 +#define _VX_DLIMIT_H
11724 +#include "switch.h"
11729 +/* keep in sync with CDLIM_INFINITY */
11731 +#define DLIM_INFINITY (~0ULL)
11733 +#include <linux/spinlock.h>
11734 +#include <linux/rcupdate.h>
11736 +struct super_block;
11739 + struct hlist_node dl_hlist; /* linked list of contexts */
11740 + struct rcu_head dl_rcu; /* the rcu head */
11741 + tag_t dl_tag; /* context tag */
11742 + atomic_t dl_usecnt; /* usage count */
11743 + atomic_t dl_refcnt; /* reference count */
11745 + struct super_block *dl_sb; /* associated superblock */
11747 + spinlock_t dl_lock; /* protect the values */
11749 + unsigned long long dl_space_used; /* used space in bytes */
11750 + unsigned long long dl_space_total; /* maximum space in bytes */
11751 + unsigned long dl_inodes_used; /* used inodes */
11752 + unsigned long dl_inodes_total; /* maximum inodes */
11754 + unsigned int dl_nrlmult; /* non root limit mult */
11759 +extern void rcu_free_dl_info(struct rcu_head *);
11760 +extern void unhash_dl_info(struct dl_info *);
11762 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11767 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11769 +typedef uint64_t dlsize_t;
11771 +#endif /* __KERNEL__ */
11772 +#else /* _VX_DLIMIT_H */
11773 +#warning duplicate inclusion
11774 +#endif /* _VX_DLIMIT_H */
11775 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/global.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/global.h
11776 --- linux-2.6.33/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11777 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/global.h 2010-02-25 12:02:16.000000000 +0100
11779 +#ifndef _VX_GLOBAL_H
11780 +#define _VX_GLOBAL_H
11783 +extern atomic_t vx_global_ctotal;
11784 +extern atomic_t vx_global_cactive;
11786 +extern atomic_t nx_global_ctotal;
11787 +extern atomic_t nx_global_cactive;
11789 +extern atomic_t vs_global_nsproxy;
11790 +extern atomic_t vs_global_fs;
11791 +extern atomic_t vs_global_mnt_ns;
11792 +extern atomic_t vs_global_uts_ns;
11793 +extern atomic_t vs_global_user_ns;
11794 +extern atomic_t vs_global_pid_ns;
11797 +#endif /* _VX_GLOBAL_H */
11798 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/history.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/history.h
11799 --- linux-2.6.33/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11800 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/history.h 2010-02-25 12:02:16.000000000 +0100
11802 +#ifndef _VX_HISTORY_H
11803 +#define _VX_HISTORY_H
11808 + VXH_THROW_OOPS = 1,
11812 + VXH_INIT_VX_INFO,
11815 + VXH_CLAIM_VX_INFO,
11816 + VXH_RELEASE_VX_INFO,
11817 + VXH_ALLOC_VX_INFO,
11818 + VXH_DEALLOC_VX_INFO,
11819 + VXH_HASH_VX_INFO,
11820 + VXH_UNHASH_VX_INFO,
11822 + VXH_LOOKUP_VX_INFO,
11823 + VXH_CREATE_VX_INFO,
11826 +struct _vxhe_vxi {
11827 + struct vx_info *ptr;
11833 +struct _vxhe_set_clr {
11837 +struct _vxhe_loc_lookup {
11841 +struct _vx_hist_entry {
11843 + unsigned short seq;
11844 + unsigned short type;
11845 + struct _vxhe_vxi vxi;
11847 + struct _vxhe_set_clr sc;
11848 + struct _vxhe_loc_lookup ll;
11852 +#ifdef CONFIG_VSERVER_HISTORY
11854 +extern unsigned volatile int vxh_active;
11856 +struct _vx_hist_entry *vxh_advance(void *loc);
11860 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11862 + entry->vxi.ptr = vxi;
11864 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11865 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11866 + entry->vxi.xid = vxi->vx_id;
11871 +#define __HERE__ current_text_addr()
11873 +#define __VXH_BODY(__type, __data, __here) \
11874 + struct _vx_hist_entry *entry; \
11876 + preempt_disable(); \
11877 + entry = vxh_advance(__here); \
11879 + entry->type = __type; \
11880 + preempt_enable();
11883 + /* pass vxi only */
11885 +#define __VXH_SMPL \
11886 + __vxh_copy_vxi(entry, vxi)
11889 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11891 + __VXH_BODY(__type, __VXH_SMPL, __here)
11894 + /* pass vxi and data (void *) */
11896 +#define __VXH_DATA \
11897 + __vxh_copy_vxi(entry, vxi); \
11898 + entry->sc.data = data
11901 +void __vxh_data(struct vx_info *vxi, void *data,
11902 + int __type, void *__here)
11904 + __VXH_BODY(__type, __VXH_DATA, __here)
11907 + /* pass vxi and arg (long) */
11909 +#define __VXH_LONG \
11910 + __vxh_copy_vxi(entry, vxi); \
11911 + entry->ll.arg = arg
11914 +void __vxh_long(struct vx_info *vxi, long arg,
11915 + int __type, void *__here)
11917 + __VXH_BODY(__type, __VXH_LONG, __here)
11922 +void __vxh_throw_oops(void *__here)
11924 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11925 + /* prevent further acquisition */
11930 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11932 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11933 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11935 +#define __vxh_init_vx_info(v, d, h) \
11936 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11937 +#define __vxh_set_vx_info(v, d, h) \
11938 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11939 +#define __vxh_clr_vx_info(v, d, h) \
11940 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11942 +#define __vxh_claim_vx_info(v, d, h) \
11943 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11944 +#define __vxh_release_vx_info(v, d, h) \
11945 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11947 +#define vxh_alloc_vx_info(v) \
11948 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11949 +#define vxh_dealloc_vx_info(v) \
11950 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11952 +#define vxh_hash_vx_info(v) \
11953 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11954 +#define vxh_unhash_vx_info(v) \
11955 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11957 +#define vxh_loc_vx_info(v, l) \
11958 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11959 +#define vxh_lookup_vx_info(v, l) \
11960 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11961 +#define vxh_create_vx_info(v, l) \
11962 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11964 +extern void vxh_dump_history(void);
11967 +#else /* CONFIG_VSERVER_HISTORY */
11969 +#define __HERE__ 0
11971 +#define vxh_throw_oops() do { } while (0)
11973 +#define __vxh_get_vx_info(v, h) do { } while (0)
11974 +#define __vxh_put_vx_info(v, h) do { } while (0)
11976 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11977 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11978 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11980 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11981 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11983 +#define vxh_alloc_vx_info(v) do { } while (0)
11984 +#define vxh_dealloc_vx_info(v) do { } while (0)
11986 +#define vxh_hash_vx_info(v) do { } while (0)
11987 +#define vxh_unhash_vx_info(v) do { } while (0)
11989 +#define vxh_loc_vx_info(v, l) do { } while (0)
11990 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11991 +#define vxh_create_vx_info(v, l) do { } while (0)
11993 +#define vxh_dump_history() do { } while (0)
11996 +#endif /* CONFIG_VSERVER_HISTORY */
11998 +#endif /* _VX_HISTORY_H */
11999 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/inode_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/inode_cmd.h
12000 --- linux-2.6.33/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12001 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/inode_cmd.h 2010-02-25 12:02:16.000000000 +0100
12003 +#ifndef _VX_INODE_CMD_H
12004 +#define _VX_INODE_CMD_H
12007 +/* inode vserver commands */
12009 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12010 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12012 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12013 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12015 +struct vcmd_ctx_iattr_v1 {
12016 + const char __user *name;
12022 +struct vcmd_ctx_fiattr_v0 {
12032 +#ifdef CONFIG_COMPAT
12034 +#include <asm/compat.h>
12036 +struct vcmd_ctx_iattr_v1_x32 {
12037 + compat_uptr_t name_ptr;
12043 +#endif /* CONFIG_COMPAT */
12045 +#include <linux/compiler.h>
12047 +extern int vc_get_iattr(void __user *);
12048 +extern int vc_set_iattr(void __user *);
12050 +extern int vc_fget_iattr(uint32_t, void __user *);
12051 +extern int vc_fset_iattr(uint32_t, void __user *);
12053 +#ifdef CONFIG_COMPAT
12055 +extern int vc_get_iattr_x32(void __user *);
12056 +extern int vc_set_iattr_x32(void __user *);
12058 +#endif /* CONFIG_COMPAT */
12060 +#endif /* __KERNEL__ */
12061 +#endif /* _VX_INODE_CMD_H */
12062 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/inode.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/inode.h
12063 --- linux-2.6.33/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12064 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/inode.h 2010-02-25 12:02:16.000000000 +0100
12066 +#ifndef _VX_INODE_H
12067 +#define _VX_INODE_H
12070 +#define IATTR_TAG 0x01000000
12072 +#define IATTR_ADMIN 0x00000001
12073 +#define IATTR_WATCH 0x00000002
12074 +#define IATTR_HIDE 0x00000004
12075 +#define IATTR_FLAGS 0x00000007
12077 +#define IATTR_BARRIER 0x00010000
12078 +#define IATTR_IXUNLINK 0x00020000
12079 +#define IATTR_IMMUTABLE 0x00040000
12080 +#define IATTR_COW 0x00080000
12085 +#ifdef CONFIG_VSERVER_PROC_SECURE
12086 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12087 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12089 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12090 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12093 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12095 +#endif /* __KERNEL__ */
12097 +/* inode ioctls */
12099 +#define FIOC_GETXFLG _IOR('x', 5, long)
12100 +#define FIOC_SETXFLG _IOW('x', 6, long)
12102 +#else /* _VX_INODE_H */
12103 +#warning duplicate inclusion
12104 +#endif /* _VX_INODE_H */
12105 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/Kbuild linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/Kbuild
12106 --- linux-2.6.33/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
12107 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/Kbuild 2010-02-25 12:02:16.000000000 +0100
12110 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
12111 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12112 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12113 + debug_cmd.h device_cmd.h
12115 +unifdef-y += switch.h network.h monitor.h inode.h device.h
12117 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit_cmd.h
12118 --- linux-2.6.33/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12119 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit_cmd.h 2010-02-25 12:02:16.000000000 +0100
12121 +#ifndef _VX_LIMIT_CMD_H
12122 +#define _VX_LIMIT_CMD_H
12125 +/* rlimit vserver commands */
12127 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12128 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12129 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12130 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12131 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12133 +struct vcmd_ctx_rlimit_v0 {
12135 + uint64_t minimum;
12136 + uint64_t softlimit;
12137 + uint64_t maximum;
12140 +struct vcmd_ctx_rlimit_mask_v0 {
12141 + uint32_t minimum;
12142 + uint32_t softlimit;
12143 + uint32_t maximum;
12146 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12148 +struct vcmd_rlimit_stat_v0 {
12152 + uint64_t minimum;
12153 + uint64_t maximum;
12156 +#define CRLIM_UNSET (0ULL)
12157 +#define CRLIM_INFINITY (~0ULL)
12158 +#define CRLIM_KEEP (~1ULL)
12162 +#ifdef CONFIG_IA32_EMULATION
12164 +struct vcmd_ctx_rlimit_v0_x32 {
12166 + uint64_t minimum;
12167 + uint64_t softlimit;
12168 + uint64_t maximum;
12169 +} __attribute__ ((packed));
12171 +#endif /* CONFIG_IA32_EMULATION */
12173 +#include <linux/compiler.h>
12175 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12176 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12177 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12178 +extern int vc_reset_hits(struct vx_info *, void __user *);
12179 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12181 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12183 +#ifdef CONFIG_IA32_EMULATION
12185 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12186 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12188 +#endif /* CONFIG_IA32_EMULATION */
12190 +#endif /* __KERNEL__ */
12191 +#endif /* _VX_LIMIT_CMD_H */
12192 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit_def.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit_def.h
12193 --- linux-2.6.33/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12194 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit_def.h 2010-02-25 12:02:16.000000000 +0100
12196 +#ifndef _VX_LIMIT_DEF_H
12197 +#define _VX_LIMIT_DEF_H
12199 +#include <asm/atomic.h>
12200 +#include <asm/resource.h>
12202 +#include "limit.h"
12205 +struct _vx_res_limit {
12206 + rlim_t soft; /* Context soft limit */
12207 + rlim_t hard; /* Context hard limit */
12209 + rlim_atomic_t rcur; /* Current value */
12210 + rlim_t rmin; /* Context minimum */
12211 + rlim_t rmax; /* Context maximum */
12213 + atomic_t lhit; /* Limit hits */
12216 +/* context sub struct */
12218 +struct _vx_limit {
12219 + struct _vx_res_limit res[NUM_LIMITS];
12222 +#ifdef CONFIG_VSERVER_DEBUG
12224 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12228 + printk("\t_vx_limit:");
12229 + for (i = 0; i < NUM_LIMITS; i++) {
12230 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12231 + i, (unsigned long)__rlim_get(limit, i),
12232 + (unsigned long)__rlim_rmin(limit, i),
12233 + (unsigned long)__rlim_rmax(limit, i),
12234 + (long)__rlim_soft(limit, i),
12235 + (long)__rlim_hard(limit, i),
12236 + atomic_read(&__rlim_lhit(limit, i)));
12242 +#endif /* _VX_LIMIT_DEF_H */
12243 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit.h
12244 --- linux-2.6.33/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12245 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit.h 2010-02-25 12:02:16.000000000 +0100
12247 +#ifndef _VX_LIMIT_H
12248 +#define _VX_LIMIT_H
12250 +#define VLIMIT_NSOCK 16
12251 +#define VLIMIT_OPENFD 17
12252 +#define VLIMIT_ANON 18
12253 +#define VLIMIT_SHMEM 19
12254 +#define VLIMIT_SEMARY 20
12255 +#define VLIMIT_NSEMS 21
12256 +#define VLIMIT_DENTRY 22
12257 +#define VLIMIT_MAPPED 23
12262 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12264 +/* keep in sync with CRLIM_INFINITY */
12266 +#define VLIM_INFINITY (~0ULL)
12268 +#include <asm/atomic.h>
12269 +#include <asm/resource.h>
12271 +#ifndef RLIM_INFINITY
12272 +#warning RLIM_INFINITY is undefined
12275 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12277 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12278 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12280 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12281 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12282 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12284 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12285 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12287 +typedef atomic_long_t rlim_atomic_t;
12288 +typedef unsigned long rlim_t;
12290 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12291 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12292 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12293 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12294 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12295 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12298 +#if (RLIM_INFINITY == VLIM_INFINITY)
12299 +#define VX_VLIM(r) ((long long)(long)(r))
12300 +#define VX_RLIM(v) ((rlim_t)(v))
12302 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12303 + ? VLIM_INFINITY : (long long)(r))
12304 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12305 + ? RLIM_INFINITY : (rlim_t)(v))
12310 +void vx_vsi_meminfo(struct sysinfo *);
12311 +void vx_vsi_swapinfo(struct sysinfo *);
12312 +long vx_vsi_cached(struct sysinfo *);
12314 +#define NUM_LIMITS 24
12316 +#endif /* __KERNEL__ */
12317 +#endif /* _VX_LIMIT_H */
12318 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/limit_int.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit_int.h
12319 --- linux-2.6.33/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12320 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/limit_int.h 2010-02-25 12:02:16.000000000 +0100
12322 +#ifndef _VX_LIMIT_INT_H
12323 +#define _VX_LIMIT_INT_H
12325 +#include "context.h"
12329 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12330 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12332 +extern const char *vlimit_name[NUM_LIMITS];
12334 +static inline void __vx_acc_cres(struct vx_info *vxi,
12335 + int res, int dir, void *_data, char *_file, int _line)
12337 + if (VXD_RCRES_COND(res))
12338 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12339 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12340 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12341 + (dir > 0) ? "++" : "--", _data, _file, _line);
12346 + __rlim_inc(&vxi->limit, res);
12348 + __rlim_dec(&vxi->limit, res);
12351 +static inline void __vx_add_cres(struct vx_info *vxi,
12352 + int res, int amount, void *_data, char *_file, int _line)
12354 + if (VXD_RCRES_COND(res))
12355 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12356 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12357 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12358 + amount, _data, _file, _line);
12363 + __rlim_add(&vxi->limit, res, amount);
12367 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12369 + int cond = (value > __rlim_rmax(limit, res));
12372 + __rlim_rmax(limit, res) = value;
12377 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12379 + int cond = (value < __rlim_rmin(limit, res));
12382 + __rlim_rmin(limit, res) = value;
12387 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12389 + if (!__vx_cres_adjust_max(limit, res, value))
12390 + __vx_cres_adjust_min(limit, res, value);
12395 + +1 ... no limit hit
12396 + -1 ... over soft limit
12397 + 0 ... over hard limit */
12399 +static inline int __vx_cres_avail(struct vx_info *vxi,
12400 + int res, int num, char *_file, int _line)
12402 + struct _vx_limit *limit;
12405 + if (VXD_RLIMIT_COND(res))
12406 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12407 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12408 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12409 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12410 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12411 + num, _file, _line);
12415 + limit = &vxi->limit;
12416 + value = __rlim_get(limit, res);
12418 + if (!__vx_cres_adjust_max(limit, res, value))
12419 + __vx_cres_adjust_min(limit, res, value);
12424 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12426 + if (value + num <= __rlim_soft(limit, res))
12429 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12431 + if (value + num <= __rlim_hard(limit, res))
12434 + __rlim_hit(limit, res);
12439 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12442 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12444 + rlim_t value, sum = 0;
12447 + while ((res = *array++)) {
12448 + value = __rlim_get(limit, res);
12449 + __vx_cres_fixup(limit, res, value);
12456 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12458 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12459 + int res = *array;
12461 + if (value == __rlim_get(limit, res))
12464 + __rlim_set(limit, res, value);
12465 + /* now adjust min/max */
12466 + if (!__vx_cres_adjust_max(limit, res, value))
12467 + __vx_cres_adjust_min(limit, res, value);
12472 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12473 + const int *array, int num, char *_file, int _line)
12475 + struct _vx_limit *limit;
12476 + rlim_t value = 0;
12484 + limit = &vxi->limit;
12486 + value = __vx_cres_array_sum(limit, array + 1);
12488 + __rlim_set(limit, res, value);
12489 + __vx_cres_fixup(limit, res, value);
12491 + return __vx_cres_avail(vxi, res, num, _file, _line);
12495 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12500 + /* complex resources first */
12501 + if ((id < 0) || (id == RLIMIT_RSS))
12502 + __vx_cres_array_fixup(limit, VLA_RSS);
12504 + for (res = 0; res < NUM_LIMITS; res++) {
12505 + if ((id > 0) && (res != id))
12508 + value = __rlim_get(limit, res);
12509 + __vx_cres_fixup(limit, res, value);
12511 + /* not supposed to happen, maybe warn? */
12512 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12513 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12518 +#endif /* __KERNEL__ */
12519 +#endif /* _VX_LIMIT_INT_H */
12520 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/monitor.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/monitor.h
12521 --- linux-2.6.33/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12522 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/monitor.h 2010-02-25 12:02:16.000000000 +0100
12524 +#ifndef _VX_MONITOR_H
12525 +#define _VX_MONITOR_H
12527 +#include <linux/types.h>
12534 + VXM_UPDATE = 0x20,
12538 + VXM_RQINFO_1 = 0x24,
12541 + VXM_ACTIVATE = 0x40,
12548 + VXM_MIGRATE = 0x48,
12551 + /* all other bits are flags */
12552 + VXM_SCHED = 0x80,
12555 +struct _vxm_update_1 {
12556 + uint32_t tokens_max;
12557 + uint32_t fill_rate;
12558 + uint32_t interval;
12561 +struct _vxm_update_2 {
12562 + uint32_t tokens_min;
12563 + uint32_t fill_rate;
12564 + uint32_t interval;
12567 +struct _vxm_rqinfo_1 {
12568 + uint16_t running;
12572 + uint32_t idle_tokens;
12575 +struct _vxm_rqinfo_2 {
12576 + uint32_t norm_time;
12577 + uint32_t idle_time;
12578 + uint32_t idle_skip;
12581 +struct _vxm_sched {
12583 + uint32_t norm_time;
12584 + uint32_t idle_time;
12587 +struct _vxm_task {
12592 +struct _vxm_event {
12601 + struct _vxm_task tsk;
12605 +struct _vx_mon_entry {
12609 + struct _vxm_event ev;
12610 + struct _vxm_sched sd;
12611 + struct _vxm_update_1 u1;
12612 + struct _vxm_update_2 u2;
12613 + struct _vxm_rqinfo_1 q1;
12614 + struct _vxm_rqinfo_2 q2;
12619 +#endif /* _VX_MONITOR_H */
12620 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/network_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/network_cmd.h
12621 --- linux-2.6.33/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12622 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/network_cmd.h 2010-02-25 12:02:16.000000000 +0100
12624 +#ifndef _VX_NETWORK_CMD_H
12625 +#define _VX_NETWORK_CMD_H
12628 +/* vinfo commands */
12630 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12633 +extern int vc_task_nid(uint32_t);
12635 +#endif /* __KERNEL__ */
12637 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12639 +struct vcmd_nx_info_v0 {
12641 + /* more to come */
12645 +extern int vc_nx_info(struct nx_info *, void __user *);
12647 +#endif /* __KERNEL__ */
12649 +#include <linux/in.h>
12650 +#include <linux/in6.h>
12652 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12653 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12655 +struct vcmd_net_create {
12656 + uint64_t flagword;
12659 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12661 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12662 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12664 +struct vcmd_net_addr_v0 {
12667 + struct in_addr ip[4];
12668 + struct in_addr mask[4];
12671 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12672 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12674 +struct vcmd_net_addr_ipv4_v1 {
12677 + struct in_addr ip;
12678 + struct in_addr mask;
12681 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12682 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12684 +struct vcmd_net_addr_ipv6_v1 {
12688 + struct in6_addr ip;
12689 + struct in6_addr mask;
12692 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12693 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12695 +struct vcmd_match_ipv4_v0 {
12700 + struct in_addr ip;
12701 + struct in_addr ip2;
12702 + struct in_addr mask;
12705 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12706 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12708 +struct vcmd_match_ipv6_v0 {
12713 + struct in6_addr ip;
12714 + struct in6_addr ip2;
12715 + struct in6_addr mask;
12720 +extern int vc_net_create(uint32_t, void __user *);
12721 +extern int vc_net_migrate(struct nx_info *, void __user *);
12723 +extern int vc_net_add(struct nx_info *, void __user *);
12724 +extern int vc_net_remove(struct nx_info *, void __user *);
12726 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12727 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12729 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12730 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12732 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12733 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12735 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12736 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12738 +#endif /* __KERNEL__ */
12741 +/* flag commands */
12743 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12744 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12746 +struct vcmd_net_flags_v0 {
12747 + uint64_t flagword;
12752 +extern int vc_get_nflags(struct nx_info *, void __user *);
12753 +extern int vc_set_nflags(struct nx_info *, void __user *);
12755 +#endif /* __KERNEL__ */
12758 +/* network caps commands */
12760 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12761 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12763 +struct vcmd_net_caps_v0 {
12769 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12770 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12772 +#endif /* __KERNEL__ */
12773 +#endif /* _VX_CONTEXT_CMD_H */
12774 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/network.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/network.h
12775 --- linux-2.6.33/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12776 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/network.h 2010-02-25 12:02:16.000000000 +0100
12778 +#ifndef _VX_NETWORK_H
12779 +#define _VX_NETWORK_H
12781 +#include <linux/types.h>
12784 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12787 +/* network flags */
12789 +#define NXF_INFO_PRIVATE 0x00000008
12791 +#define NXF_SINGLE_IP 0x00000100
12792 +#define NXF_LBACK_REMAP 0x00000200
12793 +#define NXF_LBACK_ALLOW 0x00000400
12795 +#define NXF_HIDE_NETIF 0x02000000
12796 +#define NXF_HIDE_LBACK 0x04000000
12798 +#define NXF_STATE_SETUP (1ULL << 32)
12799 +#define NXF_STATE_ADMIN (1ULL << 34)
12801 +#define NXF_SC_HELPER (1ULL << 36)
12802 +#define NXF_PERSISTENT (1ULL << 38)
12804 +#define NXF_ONE_TIME (0x0005ULL << 32)
12807 +#define NXF_INIT_SET (__nxf_init_set())
12809 +static inline uint64_t __nxf_init_set(void) {
12810 + return NXF_STATE_ADMIN
12811 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12812 + | NXF_LBACK_REMAP
12815 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12818 + | NXF_HIDE_NETIF;
12822 +/* network caps */
12824 +#define NXC_TUN_CREATE 0x00000001
12826 +#define NXC_RAW_ICMP 0x00000100
12829 +/* address types */
12831 +#define NXA_TYPE_IPV4 0x0001
12832 +#define NXA_TYPE_IPV6 0x0002
12834 +#define NXA_TYPE_NONE 0x0000
12835 +#define NXA_TYPE_ANY 0x00FF
12837 +#define NXA_TYPE_ADDR 0x0010
12838 +#define NXA_TYPE_MASK 0x0020
12839 +#define NXA_TYPE_RANGE 0x0040
12841 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12843 +#define NXA_MOD_BCAST 0x0100
12844 +#define NXA_MOD_LBACK 0x0200
12846 +#define NXA_LOOPBACK 0x1000
12848 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12849 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12853 +#include <linux/list.h>
12854 +#include <linux/spinlock.h>
12855 +#include <linux/rcupdate.h>
12856 +#include <linux/in.h>
12857 +#include <linux/in6.h>
12858 +#include <asm/atomic.h>
12860 +struct nx_addr_v4 {
12861 + struct nx_addr_v4 *next;
12862 + struct in_addr ip[2];
12863 + struct in_addr mask;
12868 +struct nx_addr_v6 {
12869 + struct nx_addr_v6 *next;
12870 + struct in6_addr ip;
12871 + struct in6_addr mask;
12878 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12879 + nid_t nx_id; /* vnet id */
12880 + atomic_t nx_usecnt; /* usage count */
12881 + atomic_t nx_tasks; /* tasks count */
12882 + int nx_state; /* context state */
12884 + uint64_t nx_flags; /* network flag word */
12885 + uint64_t nx_ncaps; /* network capabilities */
12887 + struct in_addr v4_lback; /* Loopback address */
12888 + struct in_addr v4_bcast; /* Broadcast address */
12889 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12890 +#ifdef CONFIG_IPV6
12891 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12893 + char nx_name[65]; /* network context name */
12897 +/* status flags */
12899 +#define NXS_HASHED 0x0001
12900 +#define NXS_SHUTDOWN 0x0100
12901 +#define NXS_RELEASED 0x8000
12903 +extern struct nx_info *lookup_nx_info(int);
12905 +extern int get_nid_list(int, unsigned int *, int);
12906 +extern int nid_is_hashed(nid_t);
12908 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12910 +extern long vs_net_change(struct nx_info *, unsigned int);
12915 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12916 +#ifdef CONFIG_IPV6
12917 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12919 +#define NX_IPV6(n) (0)
12922 +#endif /* __KERNEL__ */
12923 +#endif /* _VX_NETWORK_H */
12924 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/percpu.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/percpu.h
12925 --- linux-2.6.33/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12926 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/percpu.h 2010-02-25 12:02:16.000000000 +0100
12928 +#ifndef _VX_PERCPU_H
12929 +#define _VX_PERCPU_H
12931 +#include "cvirt_def.h"
12932 +#include "sched_def.h"
12934 +struct _vx_percpu {
12935 + struct _vx_cvirt_pc cvirt;
12936 + struct _vx_sched_pc sched;
12939 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12941 +#endif /* _VX_PERCPU_H */
12942 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/pid.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/pid.h
12943 --- linux-2.6.33/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12944 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/pid.h 2010-02-25 12:02:16.000000000 +0100
12946 +#ifndef _VSERVER_PID_H
12947 +#define _VSERVER_PID_H
12949 +/* pid faking stuff */
12951 +#define vx_info_map_pid(v, p) \
12952 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12953 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12954 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12955 +#define vx_map_tgid(p) vx_map_pid(p)
12957 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12958 + const char *func, const char *file, int line)
12960 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12961 + vxfprintk(VXD_CBIT(cvirt, 2),
12962 + "vx_map_tgid: %p/%llx: %d -> %d",
12963 + vxi, (long long)vxi->vx_flags, pid,
12964 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12965 + func, file, line);
12968 + if (pid == vxi->vx_initpid)
12974 +#define vx_info_rmap_pid(v, p) \
12975 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12976 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12977 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12979 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12980 + const char *func, const char *file, int line)
12982 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12983 + vxfprintk(VXD_CBIT(cvirt, 2),
12984 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12985 + vxi, (long long)vxi->vx_flags, pid,
12986 + (pid == 1) ? vxi->vx_initpid : pid,
12987 + func, file, line);
12988 + if ((pid == 1) && vxi->vx_initpid)
12989 + return vxi->vx_initpid;
12990 + if (pid == vxi->vx_initpid)
12997 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/sched_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/sched_cmd.h
12998 --- linux-2.6.33/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12999 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/sched_cmd.h 2010-02-25 12:02:16.000000000 +0100
13001 +#ifndef _VX_SCHED_CMD_H
13002 +#define _VX_SCHED_CMD_H
13005 +/* sched vserver commands */
13007 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
13008 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
13009 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
13011 +struct vcmd_set_sched_v2 {
13012 + int32_t fill_rate;
13013 + int32_t interval;
13015 + int32_t tokens_min;
13016 + int32_t tokens_max;
13017 + uint64_t cpu_mask;
13020 +struct vcmd_set_sched_v3 {
13021 + uint32_t set_mask;
13022 + int32_t fill_rate;
13023 + int32_t interval;
13025 + int32_t tokens_min;
13026 + int32_t tokens_max;
13027 + int32_t priority_bias;
13030 +struct vcmd_set_sched_v4 {
13031 + uint32_t set_mask;
13032 + int32_t fill_rate;
13033 + int32_t interval;
13035 + int32_t tokens_min;
13036 + int32_t tokens_max;
13037 + int32_t prio_bias;
13039 + int32_t bucket_id;
13042 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
13043 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
13045 +struct vcmd_sched_v5 {
13048 + int32_t bucket_id;
13049 + int32_t fill_rate[2];
13050 + int32_t interval[2];
13052 + int32_t tokens_min;
13053 + int32_t tokens_max;
13054 + int32_t prio_bias;
13057 +#define VXSM_FILL_RATE 0x0001
13058 +#define VXSM_INTERVAL 0x0002
13059 +#define VXSM_FILL_RATE2 0x0004
13060 +#define VXSM_INTERVAL2 0x0008
13061 +#define VXSM_TOKENS 0x0010
13062 +#define VXSM_TOKENS_MIN 0x0020
13063 +#define VXSM_TOKENS_MAX 0x0040
13064 +#define VXSM_PRIO_BIAS 0x0100
13066 +#define VXSM_IDLE_TIME 0x0200
13067 +#define VXSM_FORCE 0x0400
13069 +#define VXSM_V3_MASK 0x0173
13070 +#define VXSM_SET_MASK 0x01FF
13072 +#define VXSM_CPU_ID 0x1000
13073 +#define VXSM_BUCKET_ID 0x2000
13075 +#define VXSM_MSEC 0x4000
13077 +#define SCHED_KEEP (-2) /* only for v2 */
13081 +#include <linux/compiler.h>
13083 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
13084 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
13085 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
13086 +extern int vc_set_sched(struct vx_info *, void __user *);
13087 +extern int vc_get_sched(struct vx_info *, void __user *);
13089 +#endif /* __KERNEL__ */
13091 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
13093 +struct vcmd_sched_info {
13095 + int32_t bucket_id;
13096 + uint64_t user_msec;
13097 + uint64_t sys_msec;
13098 + uint64_t hold_msec;
13099 + uint32_t token_usec;
13100 + int32_t vavavoom;
13105 +extern int vc_sched_info(struct vx_info *, void __user *);
13107 +#endif /* __KERNEL__ */
13108 +#endif /* _VX_SCHED_CMD_H */
13109 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/sched_def.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/sched_def.h
13110 --- linux-2.6.33/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13111 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/sched_def.h 2010-02-25 12:02:16.000000000 +0100
13113 +#ifndef _VX_SCHED_DEF_H
13114 +#define _VX_SCHED_DEF_H
13116 +#include <linux/spinlock.h>
13117 +#include <linux/jiffies.h>
13118 +#include <linux/cpumask.h>
13119 +#include <asm/atomic.h>
13120 +#include <asm/param.h>
13123 +/* context sub struct */
13125 +struct _vx_sched {
13126 + spinlock_t tokens_lock; /* lock for token bucket */
13128 + int tokens; /* number of CPU tokens */
13129 + int fill_rate[2]; /* Fill rate: add X tokens... */
13130 + int interval[2]; /* Divisor: per Y jiffies */
13131 + int tokens_min; /* Limit: minimum for unhold */
13132 + int tokens_max; /* Limit: no more than N tokens */
13134 + int prio_bias; /* bias offset for priority */
13136 + unsigned update_mask; /* which features should be updated */
13137 + cpumask_t update; /* CPUs which should update */
13140 +struct _vx_sched_pc {
13141 + int tokens; /* number of CPU tokens */
13142 + int flags; /* bucket flags */
13144 + int fill_rate[2]; /* Fill rate: add X tokens... */
13145 + int interval[2]; /* Divisor: per Y jiffies */
13146 + int tokens_min; /* Limit: minimum for unhold */
13147 + int tokens_max; /* Limit: no more than N tokens */
13149 + int prio_bias; /* bias offset for priority */
13150 + int vavavoom; /* last calculated vavavoom */
13152 + unsigned long norm_time; /* last time accounted */
13153 + unsigned long idle_time; /* non linear time for fair sched */
13154 + unsigned long token_time; /* token time for accounting */
13155 + unsigned long onhold; /* jiffies when put on hold */
13157 + uint64_t user_ticks; /* token tick events */
13158 + uint64_t sys_ticks; /* token tick events */
13159 + uint64_t hold_ticks; /* token ticks paused */
13163 +#define VXSF_ONHOLD 0x0001
13164 +#define VXSF_IDLE_TIME 0x0100
13166 +#ifdef CONFIG_VSERVER_DEBUG
13168 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13170 + printk("\t_vx_sched:\n");
13171 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
13172 + sched->fill_rate[0], sched->interval[0],
13173 + sched->fill_rate[1], sched->interval[1],
13174 + sched->tokens_min, sched->tokens_max);
13175 + printk("\t priority = %4d\n", sched->prio_bias);
13180 +#endif /* _VX_SCHED_DEF_H */
13181 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/sched.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/sched.h
13182 --- linux-2.6.33/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13183 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/sched.h 2010-02-25 12:02:16.000000000 +0100
13185 +#ifndef _VX_SCHED_H
13186 +#define _VX_SCHED_H
13193 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13198 +void vx_update_load(struct vx_info *);
13201 +int vx_tokens_recalc(struct _vx_sched_pc *,
13202 + unsigned long *, unsigned long *, int [2]);
13204 +void vx_update_sched_param(struct _vx_sched *sched,
13205 + struct _vx_sched_pc *sched_pc);
13207 +#endif /* __KERNEL__ */
13208 +#else /* _VX_SCHED_H */
13209 +#warning duplicate inclusion
13210 +#endif /* _VX_SCHED_H */
13211 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/signal_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/signal_cmd.h
13212 --- linux-2.6.33/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13213 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/signal_cmd.h 2010-02-25 12:02:16.000000000 +0100
13215 +#ifndef _VX_SIGNAL_CMD_H
13216 +#define _VX_SIGNAL_CMD_H
13219 +/* signalling vserver commands */
13221 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13222 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13224 +struct vcmd_ctx_kill_v0 {
13229 +struct vcmd_wait_exit_v0 {
13230 + int32_t reboot_cmd;
13231 + int32_t exit_code;
13236 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13237 +extern int vc_wait_exit(struct vx_info *, void __user *);
13239 +#endif /* __KERNEL__ */
13241 +/* process alteration commands */
13243 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13244 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13246 +struct vcmd_pflags_v0 {
13247 + uint32_t flagword;
13253 +extern int vc_get_pflags(uint32_t pid, void __user *);
13254 +extern int vc_set_pflags(uint32_t pid, void __user *);
13256 +#endif /* __KERNEL__ */
13257 +#endif /* _VX_SIGNAL_CMD_H */
13258 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/signal.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/signal.h
13259 --- linux-2.6.33/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13260 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/signal.h 2010-02-25 12:02:16.000000000 +0100
13262 +#ifndef _VX_SIGNAL_H
13263 +#define _VX_SIGNAL_H
13270 +int vx_info_kill(struct vx_info *, int, int);
13272 +#endif /* __KERNEL__ */
13273 +#else /* _VX_SIGNAL_H */
13274 +#warning duplicate inclusion
13275 +#endif /* _VX_SIGNAL_H */
13276 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/space_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/space_cmd.h
13277 --- linux-2.6.33/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13278 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/space_cmd.h 2010-02-25 12:02:16.000000000 +0100
13280 +#ifndef _VX_SPACE_CMD_H
13281 +#define _VX_SPACE_CMD_H
13284 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13285 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13286 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13288 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13289 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13290 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13292 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13294 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13295 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13298 +struct vcmd_space_mask_v1 {
13302 +struct vcmd_space_mask_v2 {
13310 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13311 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13312 +extern int vc_enter_space(struct vx_info *, void __user *);
13313 +extern int vc_set_space(struct vx_info *, void __user *);
13314 +extern int vc_get_space_mask(void __user *, int);
13316 +#endif /* __KERNEL__ */
13317 +#endif /* _VX_SPACE_CMD_H */
13318 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/space.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/space.h
13319 --- linux-2.6.33/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13320 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/space.h 2010-02-25 12:02:16.000000000 +0100
13322 +#ifndef _VX_SPACE_H
13323 +#define _VX_SPACE_H
13325 +#include <linux/types.h>
13329 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13331 +#else /* _VX_SPACE_H */
13332 +#warning duplicate inclusion
13333 +#endif /* _VX_SPACE_H */
13334 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/switch.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/switch.h
13335 --- linux-2.6.33/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13336 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/switch.h 2010-02-25 12:02:16.000000000 +0100
13338 +#ifndef _VX_SWITCH_H
13339 +#define _VX_SWITCH_H
13341 +#include <linux/types.h>
13344 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13345 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13346 +#define VC_VERSION(c) ((c) & 0xFFF)
13348 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13349 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13353 + Syscall Matrix V2.8
13355 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13356 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13357 + |INFO |SETUP | |MOVE | | | | | |
13358 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13359 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13360 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13361 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13362 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13363 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13364 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13365 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13366 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13367 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13368 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13369 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13370 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13371 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13372 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13373 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13374 + OTHER |VSTAT | | | | | | |VINFO | |
13375 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13376 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13377 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13378 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13379 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13380 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13381 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13382 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13386 +#define VC_CAT_VERSION 0
13388 +#define VC_CAT_VSETUP 1
13389 +#define VC_CAT_VHOST 2
13391 +#define VC_CAT_DEVICE 6
13393 +#define VC_CAT_VPROC 9
13394 +#define VC_CAT_PROCALT 10
13395 +#define VC_CAT_PROCMIG 11
13396 +#define VC_CAT_PROCTRL 12
13398 +#define VC_CAT_SCHED 14
13399 +#define VC_CAT_MEMCTRL 20
13401 +#define VC_CAT_VNET 25
13402 +#define VC_CAT_NETALT 26
13403 +#define VC_CAT_NETMIG 27
13404 +#define VC_CAT_NETCTRL 28
13406 +#define VC_CAT_TAGMIG 35
13407 +#define VC_CAT_DLIMIT 36
13408 +#define VC_CAT_INODE 38
13410 +#define VC_CAT_VSTAT 40
13411 +#define VC_CAT_VINFO 46
13412 +#define VC_CAT_EVENT 48
13414 +#define VC_CAT_FLAGS 52
13415 +#define VC_CAT_VSPACE 54
13416 +#define VC_CAT_DEBUG 56
13417 +#define VC_CAT_RLIMIT 60
13419 +#define VC_CAT_SYSTEST 61
13420 +#define VC_CAT_COMPAT 63
13422 +/* query version */
13424 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13425 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13430 +#include <linux/errno.h>
13432 +#endif /* __KERNEL__ */
13434 +#endif /* _VX_SWITCH_H */
13436 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/tag_cmd.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/tag_cmd.h
13437 --- linux-2.6.33/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13438 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/tag_cmd.h 2010-02-25 12:02:16.000000000 +0100
13440 +#ifndef _VX_TAG_CMD_H
13441 +#define _VX_TAG_CMD_H
13444 +/* vinfo commands */
13446 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13449 +extern int vc_task_tag(uint32_t);
13451 +#endif /* __KERNEL__ */
13453 +/* context commands */
13455 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13458 +extern int vc_tag_migrate(uint32_t);
13460 +#endif /* __KERNEL__ */
13461 +#endif /* _VX_TAG_CMD_H */
13462 diff -NurpP --minimal linux-2.6.33/include/linux/vserver/tag.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/tag.h
13463 --- linux-2.6.33/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13464 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/tag.h 2010-02-25 12:02:16.000000000 +0100
13469 +#include <linux/types.h>
13472 +#define DX_TAG(in) (IS_TAGGED(in))
13475 +#ifdef CONFIG_TAG_NFSD
13476 +#define DX_TAG_NFSD 1
13478 +#define DX_TAG_NFSD 0
13482 +#ifdef CONFIG_TAGGING_NONE
13484 +#define MAX_UID 0xFFFFFFFF
13485 +#define MAX_GID 0xFFFFFFFF
13487 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13489 +#define TAGINO_UID(cond, uid, tag) (uid)
13490 +#define TAGINO_GID(cond, gid, tag) (gid)
13495 +#ifdef CONFIG_TAGGING_GID16
13497 +#define MAX_UID 0xFFFFFFFF
13498 +#define MAX_GID 0x0000FFFF
13500 +#define INOTAG_TAG(cond, uid, gid, tag) \
13501 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13503 +#define TAGINO_UID(cond, uid, tag) (uid)
13504 +#define TAGINO_GID(cond, gid, tag) \
13505 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13510 +#ifdef CONFIG_TAGGING_ID24
13512 +#define MAX_UID 0x00FFFFFF
13513 +#define MAX_GID 0x00FFFFFF
13515 +#define INOTAG_TAG(cond, uid, gid, tag) \
13516 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13518 +#define TAGINO_UID(cond, uid, tag) \
13519 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13520 +#define TAGINO_GID(cond, gid, tag) \
13521 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13526 +#ifdef CONFIG_TAGGING_UID16
13528 +#define MAX_UID 0x0000FFFF
13529 +#define MAX_GID 0xFFFFFFFF
13531 +#define INOTAG_TAG(cond, uid, gid, tag) \
13532 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13534 +#define TAGINO_UID(cond, uid, tag) \
13535 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13536 +#define TAGINO_GID(cond, gid, tag) (gid)
13541 +#ifdef CONFIG_TAGGING_INTERN
13543 +#define MAX_UID 0xFFFFFFFF
13544 +#define MAX_GID 0xFFFFFFFF
13546 +#define INOTAG_TAG(cond, uid, gid, tag) \
13547 + ((cond) ? (tag) : 0)
13549 +#define TAGINO_UID(cond, uid, tag) (uid)
13550 +#define TAGINO_GID(cond, gid, tag) (gid)
13555 +#ifndef CONFIG_TAGGING_NONE
13556 +#define dx_current_fstag(sb) \
13557 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13559 +#define dx_current_fstag(sb) (0)
13562 +#ifndef CONFIG_TAGGING_INTERN
13563 +#define TAGINO_TAG(cond, tag) (0)
13565 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13568 +#define INOTAG_UID(cond, uid, gid) \
13569 + ((cond) ? ((uid) & MAX_UID) : (uid))
13570 +#define INOTAG_GID(cond, uid, gid) \
13571 + ((cond) ? ((gid) & MAX_GID) : (gid))
13574 +static inline uid_t dx_map_uid(uid_t uid)
13576 + if ((uid > MAX_UID) && (uid != -1))
13578 + return (uid & MAX_UID);
13581 +static inline gid_t dx_map_gid(gid_t gid)
13583 + if ((gid > MAX_GID) && (gid != -1))
13585 + return (gid & MAX_GID);
13593 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13595 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13596 + unsigned long *flags);
13598 +#ifdef CONFIG_PROPAGATE
13600 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13602 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13605 +#define dx_propagate_tag(n, i) do { } while (0)
13608 +#endif /* _DX_TAG_H */
13609 diff -NurpP --minimal linux-2.6.33/include/linux/vs_inet6.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_inet6.h
13610 --- linux-2.6.33/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13611 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_inet6.h 2010-02-25 14:47:08.000000000 +0100
13613 +#ifndef _VS_INET6_H
13614 +#define _VS_INET6_H
13616 +#include "vserver/base.h"
13617 +#include "vserver/network.h"
13618 +#include "vserver/debug.h"
13620 +#include <net/ipv6.h>
13622 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13623 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13626 +#ifdef CONFIG_IPV6
13629 +int v6_addr_match(struct nx_addr_v6 *nxa,
13630 + const struct in6_addr *addr, uint16_t mask)
13634 + switch (nxa->type & mask) {
13635 + case NXA_TYPE_MASK:
13636 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13638 + case NXA_TYPE_ADDR:
13639 + ret = ipv6_addr_equal(&nxa->ip, addr);
13641 + case NXA_TYPE_ANY:
13645 + vxdprintk(VXD_CBIT(net, 0),
13646 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13647 + nxa, NXAV6(nxa), addr, mask, ret);
13652 +int v6_addr_in_nx_info(struct nx_info *nxi,
13653 + const struct in6_addr *addr, uint16_t mask)
13655 + struct nx_addr_v6 *nxa;
13660 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13661 + if (v6_addr_match(nxa, addr, mask))
13665 + vxdprintk(VXD_CBIT(net, 0),
13666 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13667 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13672 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13674 + /* FIXME: needs full range checks */
13675 + return v6_addr_match(nxa, &addr->ip, mask);
13679 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13681 + struct nx_addr_v6 *ptr;
13683 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13684 + if (v6_nx_addr_match(ptr, nxa, mask))
13691 + * Check if a given address matches for a socket
13693 + * nxi: the socket's nx_info if any
13694 + * addr: to be verified address
13697 +int v6_sock_addr_match (
13698 + struct nx_info *nxi,
13699 + struct inet_sock *inet,
13700 + struct in6_addr *addr)
13702 + struct sock *sk = &inet->sk;
13703 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13705 + if (!ipv6_addr_any(addr) &&
13706 + ipv6_addr_equal(saddr, addr))
13708 + if (ipv6_addr_any(saddr))
13709 + return v6_addr_in_nx_info(nxi, addr, -1);
13714 + * check if address is covered by socket
13716 + * sk: the socket to check against
13717 + * addr: the address in question (must be != 0)
13721 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13723 + struct nx_info *nxi = sk->sk_nx_info;
13724 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13726 + vxdprintk(VXD_CBIT(net, 5),
13727 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13728 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13729 + (sk->sk_socket?sk->sk_socket->flags:0));
13731 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13732 + return v6_addr_match(nxa, saddr, -1);
13733 + } else if (nxi) { /* match against nx_info */
13734 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13735 + } else { /* unrestricted any socket */
13741 +/* inet related checks and helpers */
13745 +struct net_device;
13749 +#include <linux/netdevice.h>
13750 +#include <linux/inetdevice.h>
13751 +#include <net/inet_timewait_sock.h>
13754 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13755 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13756 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13761 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13767 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13771 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13773 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13774 + nxi, nxi ? nxi->nx_id : 0, ifa,
13775 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13777 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13779 + if (v6_ifa_in_nx_info(ifa, nxi))
13785 +struct nx_v6_sock_addr {
13786 + struct in6_addr saddr; /* Address used for validation */
13787 + struct in6_addr baddr; /* Address used for socket bind */
13791 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13792 + struct nx_v6_sock_addr *nsa)
13794 + // struct sock *sk = &inet->sk;
13795 + // struct nx_info *nxi = sk->sk_nx_info;
13796 + struct in6_addr saddr = addr->sin6_addr;
13797 + struct in6_addr baddr = saddr;
13799 + nsa->saddr = saddr;
13800 + nsa->baddr = baddr;
13805 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13807 + // struct sock *sk = &inet->sk;
13808 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13810 + // *saddr = nsa->baddr;
13811 + // inet->inet_saddr = nsa->baddr;
13815 +int nx_info_has_v6(struct nx_info *nxi)
13819 + if (NX_IPV6(nxi))
13824 +#else /* CONFIG_IPV6 */
13827 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13834 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13840 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13846 +int nx_info_has_v6(struct nx_info *nxi)
13851 +#endif /* CONFIG_IPV6 */
13853 +#define current_nx_info_has_v6() \
13854 + nx_info_has_v6(current_nx_info())
13857 +#warning duplicate inclusion
13859 diff -NurpP --minimal linux-2.6.33/include/linux/vs_inet.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_inet.h
13860 --- linux-2.6.33/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13861 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_inet.h 2010-02-25 14:45:44.000000000 +0100
13863 +#ifndef _VS_INET_H
13864 +#define _VS_INET_H
13866 +#include "vserver/base.h"
13867 +#include "vserver/network.h"
13868 +#include "vserver/debug.h"
13870 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13872 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13873 + NIPQUAD((a)->mask), (a)->type
13874 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13878 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13880 + __be32 ip = nxa->ip[0].s_addr;
13881 + __be32 mask = nxa->mask.s_addr;
13882 + __be32 bcast = ip | ~mask;
13885 + switch (nxa->type & tmask) {
13886 + case NXA_TYPE_MASK:
13887 + ret = (ip == (addr & mask));
13889 + case NXA_TYPE_ADDR:
13893 + /* fall through to broadcast */
13894 + case NXA_MOD_BCAST:
13895 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13897 + case NXA_TYPE_RANGE:
13898 + ret = ((nxa->ip[0].s_addr <= addr) &&
13899 + (nxa->ip[1].s_addr > addr));
13901 + case NXA_TYPE_ANY:
13906 + vxdprintk(VXD_CBIT(net, 0),
13907 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13908 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13913 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13915 + struct nx_addr_v4 *nxa;
13922 + /* allow 127.0.0.1 when remapping lback */
13923 + if ((tmask & NXA_LOOPBACK) &&
13924 + (addr == IPI_LOOPBACK) &&
13925 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13928 + /* check for lback address */
13929 + if ((tmask & NXA_MOD_LBACK) &&
13930 + (nxi->v4_lback.s_addr == addr))
13933 + /* check for broadcast address */
13934 + if ((tmask & NXA_MOD_BCAST) &&
13935 + (nxi->v4_bcast.s_addr == addr))
13938 + /* check for v4 addresses */
13939 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13940 + if (v4_addr_match(nxa, addr, tmask))
13944 + vxdprintk(VXD_CBIT(net, 0),
13945 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13946 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13951 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13953 + /* FIXME: needs full range checks */
13954 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13958 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13960 + struct nx_addr_v4 *ptr;
13962 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13963 + if (v4_nx_addr_match(ptr, nxa, mask))
13968 +#include <net/inet_sock.h>
13971 + * Check if a given address matches for a socket
13973 + * nxi: the socket's nx_info if any
13974 + * addr: to be verified address
13977 +int v4_sock_addr_match (
13978 + struct nx_info *nxi,
13979 + struct inet_sock *inet,
13982 + __be32 saddr = inet->inet_rcv_saddr;
13983 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13985 + if (addr && (saddr == addr || bcast == addr))
13988 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13993 +/* inet related checks and helpers */
13997 +struct net_device;
14000 +#ifdef CONFIG_INET
14002 +#include <linux/netdevice.h>
14003 +#include <linux/inetdevice.h>
14004 +#include <net/inet_sock.h>
14005 +#include <net/inet_timewait_sock.h>
14008 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14009 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
14010 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
14014 + * check if address is covered by socket
14016 + * sk: the socket to check against
14017 + * addr: the address in question (must be != 0)
14021 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
14023 + struct nx_info *nxi = sk->sk_nx_info;
14024 + __be32 saddr = inet_rcv_saddr(sk);
14026 + vxdprintk(VXD_CBIT(net, 5),
14027 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
14028 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
14029 + (sk->sk_socket?sk->sk_socket->flags:0));
14031 + if (saddr) { /* direct address match */
14032 + return v4_addr_match(nxa, saddr, -1);
14033 + } else if (nxi) { /* match against nx_info */
14034 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
14035 + } else { /* unrestricted any socket */
14043 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
14045 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
14046 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
14047 + nxi ? dev_in_nx_info(dev, nxi) : 0);
14049 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
14051 + if (dev_in_nx_info(dev, nxi))
14058 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
14064 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
14068 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
14070 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
14071 + nxi, nxi ? nxi->nx_id : 0, ifa,
14072 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
14074 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
14076 + if (v4_ifa_in_nx_info(ifa, nxi))
14082 +struct nx_v4_sock_addr {
14083 + __be32 saddr; /* Address used for validation */
14084 + __be32 baddr; /* Address used for socket bind */
14088 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
14089 + struct nx_v4_sock_addr *nsa)
14091 + struct sock *sk = &inet->sk;
14092 + struct nx_info *nxi = sk->sk_nx_info;
14093 + __be32 saddr = addr->sin_addr.s_addr;
14094 + __be32 baddr = saddr;
14096 + vxdprintk(VXD_CBIT(net, 3),
14097 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
14098 + sk, sk->sk_nx_info, sk->sk_socket,
14099 + (sk->sk_socket ? sk->sk_socket->flags : 0),
14103 + if (saddr == INADDR_ANY) {
14104 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
14105 + baddr = nxi->v4.ip[0].s_addr;
14106 + } else if (saddr == IPI_LOOPBACK) {
14107 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14108 + baddr = nxi->v4_lback.s_addr;
14109 + } else { /* normal address bind */
14110 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
14111 + return -EADDRNOTAVAIL;
14115 + vxdprintk(VXD_CBIT(net, 3),
14116 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
14117 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
14119 + nsa->saddr = saddr;
14120 + nsa->baddr = baddr;
14125 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
14127 + inet->inet_saddr = nsa->baddr;
14128 + inet->inet_rcv_saddr = nsa->baddr;
14133 + * helper to simplify inet_lookup_listener
14135 + * nxi: the socket's nx_info if any
14136 + * addr: to be verified address
14137 + * saddr: socket address
14139 +static inline int v4_inet_addr_match (
14140 + struct nx_info *nxi,
14144 + if (addr && (saddr == addr))
14147 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
14151 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
14153 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
14154 + (addr == nxi->v4_lback.s_addr))
14155 + return IPI_LOOPBACK;
14160 +int nx_info_has_v4(struct nx_info *nxi)
14164 + if (NX_IPV4(nxi))
14166 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14171 +#else /* CONFIG_INET */
14174 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
14180 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14186 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14192 +int nx_info_has_v4(struct nx_info *nxi)
14197 +#endif /* CONFIG_INET */
14199 +#define current_nx_info_has_v4() \
14200 + nx_info_has_v4(current_nx_info())
14203 +// #warning duplicate inclusion
14205 diff -NurpP --minimal linux-2.6.33/include/linux/vs_limit.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_limit.h
14206 --- linux-2.6.33/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
14207 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_limit.h 2010-02-25 12:02:16.000000000 +0100
14209 +#ifndef _VS_LIMIT_H
14210 +#define _VS_LIMIT_H
14212 +#include "vserver/limit.h"
14213 +#include "vserver/base.h"
14214 +#include "vserver/context.h"
14215 +#include "vserver/debug.h"
14216 +#include "vserver/context.h"
14217 +#include "vserver/limit_int.h"
14220 +#define vx_acc_cres(v, d, p, r) \
14221 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
14223 +#define vx_acc_cres_cond(x, d, p, r) \
14224 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
14225 + r, d, p, __FILE__, __LINE__)
14228 +#define vx_add_cres(v, a, p, r) \
14229 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
14230 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
14232 +#define vx_add_cres_cond(x, a, p, r) \
14233 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
14234 + r, a, p, __FILE__, __LINE__)
14235 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
14238 +/* process and file limits */
14240 +#define vx_nproc_inc(p) \
14241 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
14243 +#define vx_nproc_dec(p) \
14244 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
14246 +#define vx_files_inc(f) \
14247 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
14249 +#define vx_files_dec(f) \
14250 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
14252 +#define vx_locks_inc(l) \
14253 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
14255 +#define vx_locks_dec(l) \
14256 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
14258 +#define vx_openfd_inc(f) \
14259 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
14261 +#define vx_openfd_dec(f) \
14262 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
14265 +#define vx_cres_avail(v, n, r) \
14266 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
14269 +#define vx_nproc_avail(n) \
14270 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
14272 +#define vx_files_avail(n) \
14273 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
14275 +#define vx_locks_avail(n) \
14276 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
14278 +#define vx_openfd_avail(n) \
14279 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
14282 +/* dentry limits */
14284 +#define vx_dentry_inc(d) do { \
14285 + if (atomic_read(&d->d_count) == 1) \
14286 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
14289 +#define vx_dentry_dec(d) do { \
14290 + if (atomic_read(&d->d_count) == 0) \
14291 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
14294 +#define vx_dentry_avail(n) \
14295 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
14298 +/* socket limits */
14300 +#define vx_sock_inc(s) \
14301 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14303 +#define vx_sock_dec(s) \
14304 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14306 +#define vx_sock_avail(n) \
14307 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
14310 +/* ipc resource limits */
14312 +#define vx_ipcmsg_add(v, u, a) \
14313 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14315 +#define vx_ipcmsg_sub(v, u, a) \
14316 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14318 +#define vx_ipcmsg_avail(v, a) \
14319 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14322 +#define vx_ipcshm_add(v, k, a) \
14323 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14325 +#define vx_ipcshm_sub(v, k, a) \
14326 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14328 +#define vx_ipcshm_avail(v, a) \
14329 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14332 +#define vx_semary_inc(a) \
14333 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
14335 +#define vx_semary_dec(a) \
14336 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
14339 +#define vx_nsems_add(a,n) \
14340 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14342 +#define vx_nsems_sub(a,n) \
14343 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
14347 +#warning duplicate inclusion
14349 diff -NurpP --minimal linux-2.6.33/include/linux/vs_memory.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_memory.h
14350 --- linux-2.6.33/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14351 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_memory.h 2010-02-25 12:02:16.000000000 +0100
14353 +#ifndef _VS_MEMORY_H
14354 +#define _VS_MEMORY_H
14356 +#include "vserver/limit.h"
14357 +#include "vserver/base.h"
14358 +#include "vserver/context.h"
14359 +#include "vserver/debug.h"
14360 +#include "vserver/context.h"
14361 +#include "vserver/limit_int.h"
14364 +#define __acc_add_long(a, v) (*(v) += (a))
14365 +#define __acc_inc_long(v) (++*(v))
14366 +#define __acc_dec_long(v) (--*(v))
14368 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14369 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14370 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14371 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14372 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14373 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14374 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14375 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14376 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14379 +#define vx_acc_page(m, d, v, r) do { \
14381 + __acc_inc_long(&(m)->v); \
14383 + __acc_dec_long(&(m)->v); \
14384 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14387 +#define vx_acc_page_atomic(m, d, v, r) do { \
14389 + __acc_inc_atomic(&(m)->v); \
14391 + __acc_dec_atomic(&(m)->v); \
14392 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14396 +#define vx_acc_pages(m, p, v, r) do { \
14397 + unsigned long __p = (p); \
14398 + __acc_add_long(__p, &(m)->v); \
14399 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14402 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14403 + unsigned long __p = (p); \
14404 + __acc_add_atomic(__p, &(m)->v); \
14405 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14410 +#define vx_acc_vmpage(m, d) \
14411 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14412 +#define vx_acc_vmlpage(m, d) \
14413 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14414 +#define vx_acc_file_rsspage(m, d) \
14415 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14416 +#define vx_acc_anon_rsspage(m, d) \
14417 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14419 +#define vx_acc_vmpages(m, p) \
14420 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14421 +#define vx_acc_vmlpages(m, p) \
14422 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14423 +#define vx_acc_file_rsspages(m, p) \
14424 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14425 +#define vx_acc_anon_rsspages(m, p) \
14426 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14428 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14429 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14431 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14432 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14433 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14434 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14436 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14437 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14438 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14439 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14441 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14442 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14443 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14444 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14446 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14447 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14448 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14449 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14452 +#define vx_pages_avail(m, p, r) \
14453 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14455 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14456 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14457 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14458 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14460 +#define vx_rss_avail(m, p) \
14461 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14465 + VXPT_UNKNOWN = 0,
14474 +#define vx_page_fault(mm, vma, type, ret)
14478 +void __vx_page_fault(struct mm_struct *mm,
14479 + struct vm_area_struct *vma, int type, int ret)
14481 + struct vx_info *vxi = mm->mm_vx_info;
14484 + static char *page_type[6] =
14485 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14486 + static char *page_what[4] =
14487 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14493 + what = (ret & 0x3);
14495 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14496 + type, what, ret, page_type[type], page_what[what]);
14498 + if (ret & VM_FAULT_WRITE)
14500 + atomic_inc(&vxi->cacct.page[type][what]);
14503 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14507 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14510 +#warning duplicate inclusion
14512 diff -NurpP --minimal linux-2.6.33/include/linux/vs_network.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_network.h
14513 --- linux-2.6.33/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14514 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_network.h 2010-02-25 12:02:16.000000000 +0100
14516 +#ifndef _NX_VS_NETWORK_H
14517 +#define _NX_VS_NETWORK_H
14519 +#include "vserver/context.h"
14520 +#include "vserver/network.h"
14521 +#include "vserver/base.h"
14522 +#include "vserver/check.h"
14523 +#include "vserver/debug.h"
14525 +#include <linux/sched.h>
14528 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14530 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14531 + const char *_file, int _line)
14536 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14537 + nxi, nxi ? nxi->nx_id : 0,
14538 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14541 + atomic_inc(&nxi->nx_usecnt);
14546 +extern void free_nx_info(struct nx_info *);
14548 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14550 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14555 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14556 + nxi, nxi ? nxi->nx_id : 0,
14557 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14560 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14561 + free_nx_info(nxi);
14565 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14567 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14568 + const char *_file, int _line)
14571 + vxlprintk(VXD_CBIT(nid, 3),
14572 + "init_nx_info(%p[#%d.%d])",
14573 + nxi, nxi ? nxi->nx_id : 0,
14574 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14577 + atomic_inc(&nxi->nx_usecnt);
14583 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14585 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14586 + const char *_file, int _line)
14588 + struct nx_info *nxo;
14593 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14594 + nxi, nxi ? nxi->nx_id : 0,
14595 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14598 + atomic_inc(&nxi->nx_usecnt);
14599 + nxo = xchg(nxp, nxi);
14603 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14605 +static inline void __clr_nx_info(struct nx_info **nxp,
14606 + const char *_file, int _line)
14608 + struct nx_info *nxo;
14610 + nxo = xchg(nxp, NULL);
14614 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14615 + nxo, nxo ? nxo->nx_id : 0,
14616 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14619 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14620 + free_nx_info(nxo);
14624 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14626 +static inline void __claim_nx_info(struct nx_info *nxi,
14627 + struct task_struct *task, const char *_file, int _line)
14629 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14630 + nxi, nxi ? nxi->nx_id : 0,
14631 + nxi?atomic_read(&nxi->nx_usecnt):0,
14632 + nxi?atomic_read(&nxi->nx_tasks):0,
14633 + task, _file, _line);
14635 + atomic_inc(&nxi->nx_tasks);
14639 +extern void unhash_nx_info(struct nx_info *);
14641 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14643 +static inline void __release_nx_info(struct nx_info *nxi,
14644 + struct task_struct *task, const char *_file, int _line)
14646 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14647 + nxi, nxi ? nxi->nx_id : 0,
14648 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14649 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14650 + task, _file, _line);
14654 + if (atomic_dec_and_test(&nxi->nx_tasks))
14655 + unhash_nx_info(nxi);
14659 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14661 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14662 + const char *_file, int _line)
14664 + struct nx_info *nxi;
14667 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14668 + p, _file, _line);
14669 + nxi = __get_nx_info(p->nx_info, _file, _line);
14675 +static inline void exit_nx_info(struct task_struct *p)
14678 + release_nx_info(p->nx_info, p);
14683 +#warning duplicate inclusion
14685 diff -NurpP --minimal linux-2.6.33/include/linux/vs_pid.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_pid.h
14686 --- linux-2.6.33/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14687 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_pid.h 2010-02-25 12:02:16.000000000 +0100
14692 +#include "vserver/base.h"
14693 +#include "vserver/check.h"
14694 +#include "vserver/context.h"
14695 +#include "vserver/debug.h"
14696 +#include "vserver/pid.h"
14697 +#include <linux/pid_namespace.h>
14700 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14703 +int vx_proc_task_visible(struct task_struct *task)
14705 + if ((task->pid == 1) &&
14706 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14707 + /* show a blend through init */
14709 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14716 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14721 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14723 + struct task_struct *task = find_task_by_real_pid(pid);
14725 + if (task && !vx_proc_task_visible(task)) {
14726 + vxdprintk(VXD_CBIT(misc, 6),
14727 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14728 + task, task->xid, task->pid,
14729 + current, current->xid, current->pid);
14738 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14740 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14742 + if (task && !vx_proc_task_visible(task)) {
14743 + vxdprintk(VXD_CBIT(misc, 6),
14744 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14745 + task, task->xid, task->pid,
14746 + current, current->xid, current->pid);
14747 + put_task_struct(task);
14756 +struct task_struct *vx_child_reaper(struct task_struct *p)
14758 + struct vx_info *vxi = p->vx_info;
14759 + struct task_struct *reaper = child_reaper(p);
14764 + BUG_ON(!p->vx_info->vx_reaper);
14766 + /* child reaper for the guest reaper */
14767 + if (vxi->vx_reaper == p)
14770 + reaper = vxi->vx_reaper;
14772 + vxdprintk(VXD_CBIT(xid, 7),
14773 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14774 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14782 +#warning duplicate inclusion
14784 diff -NurpP --minimal linux-2.6.33/include/linux/vs_sched.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_sched.h
14785 --- linux-2.6.33/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14786 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_sched.h 2010-02-25 12:02:16.000000000 +0100
14788 +#ifndef _VS_SCHED_H
14789 +#define _VS_SCHED_H
14791 +#include "vserver/base.h"
14792 +#include "vserver/context.h"
14793 +#include "vserver/sched.h"
14796 +#define VAVAVOOM_RATIO 50
14798 +#define MAX_PRIO_BIAS 20
14799 +#define MIN_PRIO_BIAS -20
14802 +#ifdef CONFIG_VSERVER_HARDCPU
14805 + * effective_prio - return the priority that is based on the static
14806 + * priority but is modified by bonuses/penalties.
14808 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14809 + * into a -4 ... 0 ... +4 bonus/penalty range.
14811 + * Additionally, we scale another amount based on the number of
14812 + * CPU tokens currently held by the context, if the process is
14813 + * part of a context (and the appropriate SCHED flag is set).
14814 + * This ranges from -5 ... 0 ... +15, quadratically.
14816 + * So, the total bonus is -9 .. 0 .. +19
14817 + * We use ~50% of the full 0...39 priority range so that:
14819 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14820 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14821 + * unless that context is far exceeding its CPU allocation.
14823 + * Both properties are important to certain workloads.
14826 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14828 + int vavavoom, max;
14830 + /* lots of tokens = lots of vavavoom
14831 + * no tokens = no vavavoom */
14832 + if ((vavavoom = sched_pc->tokens) >= 0) {
14833 + max = sched_pc->tokens_max;
14834 + vavavoom = max - vavavoom;
14836 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14837 + * (vavavoom*vavavoom - (max >> 2)) / max;
14845 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14847 + struct vx_info *vxi = p->vx_info;
14848 + struct _vx_sched_pc *sched_pc;
14853 + sched_pc = &vx_cpu(vxi, sched_pc);
14854 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14855 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14857 + sched_pc->vavavoom = vavavoom;
14858 + prio += vavavoom;
14860 + prio += sched_pc->prio_bias;
14864 +#else /* !CONFIG_VSERVER_HARDCPU */
14867 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14869 + struct vx_info *vxi = p->vx_info;
14872 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14876 +#endif /* CONFIG_VSERVER_HARDCPU */
14879 +static inline void vx_account_user(struct vx_info *vxi,
14880 + cputime_t cputime, int nice)
14884 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14887 +static inline void vx_account_system(struct vx_info *vxi,
14888 + cputime_t cputime, int idle)
14892 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14896 +#warning duplicate inclusion
14898 diff -NurpP --minimal linux-2.6.33/include/linux/vs_socket.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_socket.h
14899 --- linux-2.6.33/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14900 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_socket.h 2010-02-25 12:02:16.000000000 +0100
14902 +#ifndef _VS_SOCKET_H
14903 +#define _VS_SOCKET_H
14905 +#include "vserver/debug.h"
14906 +#include "vserver/base.h"
14907 +#include "vserver/cacct.h"
14908 +#include "vserver/context.h"
14909 +#include "vserver/tag.h"
14912 +/* socket accounting */
14914 +#include <linux/socket.h>
14916 +static inline int vx_sock_type(int family)
14918 + switch (family) {
14920 + return VXA_SOCK_UNSPEC;
14922 + return VXA_SOCK_UNIX;
14924 + return VXA_SOCK_INET;
14926 + return VXA_SOCK_INET6;
14928 + return VXA_SOCK_PACKET;
14930 + return VXA_SOCK_OTHER;
14934 +#define vx_acc_sock(v, f, p, s) \
14935 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14937 +static inline void __vx_acc_sock(struct vx_info *vxi,
14938 + int family, int pos, int size, char *file, int line)
14941 + int type = vx_sock_type(family);
14943 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14944 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14948 +#define vx_sock_recv(sk, s) \
14949 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14950 +#define vx_sock_send(sk, s) \
14951 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14952 +#define vx_sock_fail(sk, s) \
14953 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14956 +#define sock_vx_init(s) do { \
14957 + (s)->sk_xid = 0; \
14958 + (s)->sk_vx_info = NULL; \
14961 +#define sock_nx_init(s) do { \
14962 + (s)->sk_nid = 0; \
14963 + (s)->sk_nx_info = NULL; \
14967 +#warning duplicate inclusion
14969 diff -NurpP --minimal linux-2.6.33/include/linux/vs_tag.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_tag.h
14970 --- linux-2.6.33/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14971 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_tag.h 2010-02-25 12:02:16.000000000 +0100
14976 +#include <linux/vserver/tag.h>
14978 +/* check conditions */
14980 +#define DX_ADMIN 0x0001
14981 +#define DX_WATCH 0x0002
14982 +#define DX_HOSTID 0x0008
14984 +#define DX_IDENT 0x0010
14986 +#define DX_ARG_MASK 0x0010
14989 +#define dx_task_tag(t) ((t)->tag)
14991 +#define dx_current_tag() dx_task_tag(current)
14993 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14995 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14999 + * check current context for ADMIN/WATCH and
15000 + * optionally against supplied argument
15002 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
15004 + if (mode & DX_ARG_MASK) {
15005 + if ((mode & DX_IDENT) && (id == cid))
15008 + return (((mode & DX_ADMIN) && (cid == 0)) ||
15009 + ((mode & DX_WATCH) && (cid == 1)) ||
15010 + ((mode & DX_HOSTID) && (id == 0)));
15014 +int dx_permission(const struct inode *inode, int mask);
15018 +#warning duplicate inclusion
15020 diff -NurpP --minimal linux-2.6.33/include/linux/vs_time.h linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_time.h
15021 --- linux-2.6.33/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
15022 +++ linux-2.6.33-vs2.3.0.36.30.1/include/linux/vs_time.h 2010-02-25 12:02:16.000000000 +0100
15024 +#ifndef _VS_TIME_H
15025 +#define _VS_TIME_H
15028 +/* time faking stuff */
15030 +#ifdef CONFIG_VSERVER_VTIME
15032 +extern void vx_gettimeofday(struct timeval *tv);
15033 +extern int vx_settimeofday(struct timespec *ts);
15036 +#define vx_gettimeofday(t) do_gettimeofday(t)
15037 +#define vx_settimeofday(t) do_settimeofday(t)
15041 +#warning duplicate inclusion
15043 diff -NurpP --minimal linux-2.6.33/include/net/addrconf.h linux-2.6.33-vs2.3.0.36.30.1/include/net/addrconf.h
15044 --- linux-2.6.33/include/net/addrconf.h 2009-12-03 20:02:57.000000000 +0100
15045 +++ linux-2.6.33-vs2.3.0.36.30.1/include/net/addrconf.h 2010-02-25 12:02:16.000000000 +0100
15046 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
15047 struct net_device *dev,
15048 const struct in6_addr *daddr,
15049 unsigned int srcprefs,
15050 - struct in6_addr *saddr);
15051 + struct in6_addr *saddr,
15052 + struct nx_info *nxi);
15053 extern int ipv6_get_lladdr(struct net_device *dev,
15054 struct in6_addr *addr,
15055 unsigned char banned_flags);
15056 diff -NurpP --minimal linux-2.6.33/include/net/af_unix.h linux-2.6.33-vs2.3.0.36.30.1/include/net/af_unix.h
15057 --- linux-2.6.33/include/net/af_unix.h 2008-12-25 00:26:37.000000000 +0100
15058 +++ linux-2.6.33-vs2.3.0.36.30.1/include/net/af_unix.h 2010-02-25 12:02:16.000000000 +0100
15060 #include <linux/socket.h>
15061 #include <linux/un.h>
15062 #include <linux/mutex.h>
15063 +#include <linux/vs_base.h>
15064 #include <net/sock.h>
15066 extern void unix_inflight(struct file *fp);
15067 diff -NurpP --minimal linux-2.6.33/include/net/inet_timewait_sock.h linux-2.6.33-vs2.3.0.36.30.1/include/net/inet_timewait_sock.h
15068 --- linux-2.6.33/include/net/inet_timewait_sock.h 2010-02-25 11:52:08.000000000 +0100
15069 +++ linux-2.6.33-vs2.3.0.36.30.1/include/net/inet_timewait_sock.h 2010-02-25 12:02:16.000000000 +0100
15070 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
15071 #define tw_hash __tw_common.skc_hash
15072 #define tw_prot __tw_common.skc_prot
15073 #define tw_net __tw_common.skc_net
15074 +#define tw_xid __tw_common.skc_xid
15075 +#define tw_vx_info __tw_common.skc_vx_info
15076 +#define tw_nid __tw_common.skc_nid
15077 +#define tw_nx_info __tw_common.skc_nx_info
15079 volatile unsigned char tw_substate;
15080 /* 3 bits hole, try to pack */
15081 diff -NurpP --minimal linux-2.6.33/include/net/route.h linux-2.6.33-vs2.3.0.36.30.1/include/net/route.h
15082 --- linux-2.6.33/include/net/route.h 2010-02-25 11:52:08.000000000 +0100
15083 +++ linux-2.6.33-vs2.3.0.36.30.1/include/net/route.h 2010-02-25 12:02:16.000000000 +0100
15084 @@ -132,6 +132,9 @@ static inline void ip_rt_put(struct rtab
15085 dst_release(&rt->u.dst);
15088 +#include <linux/vs_base.h>
15089 +#include <linux/vs_inet.h>
15091 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
15093 extern const __u8 ip_tos2prio[16];
15094 @@ -141,6 +144,9 @@ static inline char rt_tos2priority(u8 to
15095 return ip_tos2prio[IPTOS_TOS(tos)>>1];
15098 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
15099 + struct rtable **, struct flowi *);
15101 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
15102 __be32 src, u32 tos, int oif, u8 protocol,
15103 __be16 sport, __be16 dport, struct sock *sk,
15104 @@ -158,11 +164,24 @@ static inline int ip_route_connect(struc
15107 struct net *net = sock_net(sk);
15108 + struct nx_info *nx_info = current_nx_info();
15110 if (inet_sk(sk)->transparent)
15111 fl.flags |= FLOWI_FLAG_ANYSRC;
15113 - if (!dst || !src) {
15115 + nx_info = sk->sk_nx_info;
15117 + vxdprintk(VXD_CBIT(net, 4),
15118 + "ip_route_connect(%p) %p,%p;%lx",
15119 + sk, nx_info, sk->sk_socket,
15120 + (sk->sk_socket?sk->sk_socket->flags:0));
15122 + err = ip_v4_find_src(net, nx_info, rp, &fl);
15126 + if (!fl.fl4_dst || !fl.fl4_src) {
15127 err = __ip_route_output_key(net, rp, &fl);
15130 diff -NurpP --minimal linux-2.6.33/include/net/sock.h linux-2.6.33-vs2.3.0.36.30.1/include/net/sock.h
15131 --- linux-2.6.33/include/net/sock.h 2010-02-25 11:52:08.000000000 +0100
15132 +++ linux-2.6.33-vs2.3.0.36.30.1/include/net/sock.h 2010-02-25 12:02:16.000000000 +0100
15133 @@ -149,6 +149,10 @@ struct sock_common {
15134 #ifdef CONFIG_NET_NS
15135 struct net *skc_net;
15138 + struct vx_info *skc_vx_info;
15140 + struct nx_info *skc_nx_info;
15144 @@ -236,6 +240,10 @@ struct sock {
15145 #define sk_bind_node __sk_common.skc_bind_node
15146 #define sk_prot __sk_common.skc_prot
15147 #define sk_net __sk_common.skc_net
15148 +#define sk_xid __sk_common.skc_xid
15149 +#define sk_vx_info __sk_common.skc_vx_info
15150 +#define sk_nid __sk_common.skc_nid
15151 +#define sk_nx_info __sk_common.skc_nx_info
15152 kmemcheck_bitfield_begin(flags);
15153 unsigned int sk_shutdown : 2,
15155 diff -NurpP --minimal linux-2.6.33/init/Kconfig linux-2.6.33-vs2.3.0.36.30.1/init/Kconfig
15156 --- linux-2.6.33/init/Kconfig 2010-02-25 11:52:09.000000000 +0100
15157 +++ linux-2.6.33-vs2.3.0.36.30.1/init/Kconfig 2010-02-25 16:27:44.000000000 +0100
15158 @@ -496,8 +496,22 @@ config CGROUP_SCHED
15162 +config CFS_HARD_LIMITS
15163 + bool "Hard Limits for CFS Group Scheduler"
15164 + depends on EXPERIMENTAL
15165 + depends on FAIR_GROUP_SCHED && CGROUP_SCHED
15168 + This option enables hard limiting of CPU time obtained by
15169 + a fair task group. Use this if you want to throttle a group of tasks
15170 + based on its CPU usage. For more details refer to
15171 + Documentation/scheduler/sched-cfs-hard-limits.txt
15176 boolean "Control Group support"
15179 This option adds support for grouping sets of processes together, for
15180 use with process control subsystems such as Cpusets, CFS, memory
15181 @@ -525,6 +539,7 @@ config CGROUP_DEBUG
15183 bool "Namespace cgroup subsystem"
15187 Provides a simple namespace cgroup subsystem to
15188 provide hierarchical naming of sets of namespaces,
15189 diff -NurpP --minimal linux-2.6.33/init/main.c linux-2.6.33-vs2.3.0.36.30.1/init/main.c
15190 --- linux-2.6.33/init/main.c 2010-02-25 11:52:09.000000000 +0100
15191 +++ linux-2.6.33-vs2.3.0.36.30.1/init/main.c 2010-02-25 12:02:16.000000000 +0100
15193 #include <linux/sfi.h>
15194 #include <linux/shmem_fs.h>
15195 #include <trace/boot.h>
15196 +#include <linux/vserver/percpu.h>
15198 #include <asm/io.h>
15199 #include <asm/bugs.h>
15200 diff -NurpP --minimal linux-2.6.33/ipc/mqueue.c linux-2.6.33-vs2.3.0.36.30.1/ipc/mqueue.c
15201 --- linux-2.6.33/ipc/mqueue.c 2010-02-25 11:52:09.000000000 +0100
15202 +++ linux-2.6.33-vs2.3.0.36.30.1/ipc/mqueue.c 2010-02-25 12:21:21.000000000 +0100
15204 #include <linux/nsproxy.h>
15205 #include <linux/pid.h>
15206 #include <linux/ipc_namespace.h>
15207 +#include <linux/vs_context.h>
15208 +#include <linux/vs_limit.h>
15210 #include <net/sock.h>
15212 @@ -65,6 +67,7 @@ struct mqueue_inode_info {
15213 struct sigevent notify;
15214 struct pid* notify_owner;
15215 struct user_struct *user; /* user who created, for accounting */
15216 + struct vx_info *vxi;
15217 struct sock *notify_sock;
15218 struct sk_buff *notify_cookie;
15220 @@ -124,6 +127,7 @@ static struct inode *mqueue_get_inode(st
15221 if (S_ISREG(mode)) {
15222 struct mqueue_inode_info *info;
15223 struct task_struct *p = current;
15224 + struct vx_info *vxi = p->vx_info;
15225 unsigned long mq_bytes, mq_msg_tblsz;
15227 inode->i_fop = &mqueue_file_operations;
15228 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
15229 info->notify_owner = NULL;
15231 info->user = NULL; /* set when all is ok */
15232 + info->vxi = NULL;
15233 memset(&info->attr, 0, sizeof(info->attr));
15234 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
15235 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
15236 @@ -152,22 +157,26 @@ static struct inode *mqueue_get_inode(st
15237 spin_lock(&mq_lock);
15238 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15239 u->mq_bytes + mq_bytes >
15240 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
15241 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
15242 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
15243 spin_unlock(&mq_lock);
15246 u->mq_bytes += mq_bytes;
15247 + vx_ipcmsg_add(vxi, u, mq_bytes);
15248 spin_unlock(&mq_lock);
15250 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
15251 if (!info->messages) {
15252 spin_lock(&mq_lock);
15253 u->mq_bytes -= mq_bytes;
15254 + vx_ipcmsg_sub(vxi, u, mq_bytes);
15255 spin_unlock(&mq_lock);
15259 info->user = get_uid(u);
15260 + info->vxi = get_vx_info(vxi);
15261 } else if (S_ISDIR(mode)) {
15263 /* Some things misbehave if size == 0 on a directory */
15264 @@ -268,8 +277,11 @@ static void mqueue_delete_inode(struct i
15265 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
15268 + struct vx_info *vxi = info->vxi;
15270 spin_lock(&mq_lock);
15271 user->mq_bytes -= mq_bytes;
15272 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15274 * get_ns_from_inode() ensures that the
15275 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
15276 @@ -279,6 +291,7 @@ static void mqueue_delete_inode(struct i
15278 ipc_ns->mq_queues_count--;
15279 spin_unlock(&mq_lock);
15280 + put_vx_info(vxi);
15284 diff -NurpP --minimal linux-2.6.33/ipc/msg.c linux-2.6.33-vs2.3.0.36.30.1/ipc/msg.c
15285 --- linux-2.6.33/ipc/msg.c 2010-02-25 11:52:09.000000000 +0100
15286 +++ linux-2.6.33-vs2.3.0.36.30.1/ipc/msg.c 2010-02-25 12:02:16.000000000 +0100
15288 #include <linux/rwsem.h>
15289 #include <linux/nsproxy.h>
15290 #include <linux/ipc_namespace.h>
15291 +#include <linux/vs_base.h>
15293 #include <asm/current.h>
15294 #include <asm/uaccess.h>
15295 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
15297 msq->q_perm.mode = msgflg & S_IRWXUGO;
15298 msq->q_perm.key = key;
15299 + msq->q_perm.xid = vx_current_xid();
15301 msq->q_perm.security = NULL;
15302 retval = security_msg_queue_alloc(msq);
15303 diff -NurpP --minimal linux-2.6.33/ipc/namespace.c linux-2.6.33-vs2.3.0.36.30.1/ipc/namespace.c
15304 --- linux-2.6.33/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
15305 +++ linux-2.6.33-vs2.3.0.36.30.1/ipc/namespace.c 2010-02-25 12:02:16.000000000 +0100
15307 #include <linux/slab.h>
15308 #include <linux/fs.h>
15309 #include <linux/mount.h>
15310 +#include <linux/vs_base.h>
15311 +#include <linux/vserver/global.h>
15315 diff -NurpP --minimal linux-2.6.33/ipc/sem.c linux-2.6.33-vs2.3.0.36.30.1/ipc/sem.c
15316 --- linux-2.6.33/ipc/sem.c 2010-02-25 11:52:09.000000000 +0100
15317 +++ linux-2.6.33-vs2.3.0.36.30.1/ipc/sem.c 2010-02-25 12:02:16.000000000 +0100
15319 #include <linux/rwsem.h>
15320 #include <linux/nsproxy.h>
15321 #include <linux/ipc_namespace.h>
15322 +#include <linux/vs_base.h>
15323 +#include <linux/vs_limit.h>
15325 #include <asm/uaccess.h>
15327 @@ -257,6 +259,7 @@ static int newary(struct ipc_namespace *
15329 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15330 sma->sem_perm.key = key;
15331 + sma->sem_perm.xid = vx_current_xid();
15333 sma->sem_perm.security = NULL;
15334 retval = security_sem_alloc(sma);
15335 @@ -272,6 +275,9 @@ static int newary(struct ipc_namespace *
15338 ns->used_sems += nsems;
15339 + /* FIXME: obsoleted? */
15340 + vx_semary_inc(sma);
15341 + vx_nsems_add(sma, nsems);
15343 sma->sem_base = (struct sem *) &sma[1];
15345 @@ -595,6 +601,9 @@ static void freeary(struct ipc_namespace
15348 ns->used_sems -= sma->sem_nsems;
15349 + /* FIXME: obsoleted? */
15350 + vx_nsems_sub(sma, sma->sem_nsems);
15351 + vx_semary_dec(sma);
15352 security_sem_free(sma);
15353 ipc_rcu_putref(sma);
15355 diff -NurpP --minimal linux-2.6.33/ipc/shm.c linux-2.6.33-vs2.3.0.36.30.1/ipc/shm.c
15356 --- linux-2.6.33/ipc/shm.c 2010-02-25 11:52:09.000000000 +0100
15357 +++ linux-2.6.33-vs2.3.0.36.30.1/ipc/shm.c 2010-02-25 12:23:04.000000000 +0100
15359 #include <linux/nsproxy.h>
15360 #include <linux/mount.h>
15361 #include <linux/ipc_namespace.h>
15362 +#include <linux/vs_context.h>
15363 +#include <linux/vs_limit.h>
15365 #include <asm/uaccess.h>
15367 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
15369 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15371 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15372 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15373 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15375 + vx_ipcshm_sub(vxi, shp, numpages);
15376 + ns->shm_tot -= numpages;
15380 if (!is_file_hugepages(shp->shm_file))
15381 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
15383 fput (shp->shm_file);
15384 security_shm_free(shp);
15385 + put_vx_info(vxi);
15386 ipc_rcu_putref(shp);
15389 @@ -352,11 +360,15 @@ static int newseg(struct ipc_namespace *
15390 if (ns->shm_tot + numpages > ns->shm_ctlall)
15393 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
15396 shp = ipc_rcu_alloc(sizeof(*shp));
15400 shp->shm_perm.key = key;
15401 + shp->shm_perm.xid = vx_current_xid();
15402 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15403 shp->mlock_user = NULL;
15405 @@ -410,6 +422,7 @@ static int newseg(struct ipc_namespace *
15406 ns->shm_tot += numpages;
15407 error = shp->shm_perm.id;
15409 + vx_ipcshm_add(current_vx_info(), key, numpages);
15413 diff -NurpP --minimal linux-2.6.33/kernel/capability.c linux-2.6.33-vs2.3.0.36.30.1/kernel/capability.c
15414 --- linux-2.6.33/kernel/capability.c 2010-02-25 11:52:09.000000000 +0100
15415 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/capability.c 2010-02-25 12:02:16.000000000 +0100
15417 #include <linux/security.h>
15418 #include <linux/syscalls.h>
15419 #include <linux/pid_namespace.h>
15420 +#include <linux/vs_context.h>
15421 #include <asm/uaccess.h>
15422 #include "cred-internals.h"
15424 @@ -120,6 +121,7 @@ static int cap_validate_magic(cap_user_h
15430 * The only thing that can change the capabilities of the current
15431 * process is the current process. As such, we can't be in this code
15432 @@ -290,6 +292,8 @@ error:
15436 +#include <linux/vserver/base.h>
15439 * capable - Determine if the current task has a superior capability in effect
15440 * @cap: The capability to be tested for
15441 @@ -302,6 +306,9 @@ error:
15443 int capable(int cap)
15445 + /* here for now so we don't require task locking */
15446 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15448 if (unlikely(!cap_valid(cap))) {
15449 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15451 diff -NurpP --minimal linux-2.6.33/kernel/compat.c linux-2.6.33-vs2.3.0.36.30.1/kernel/compat.c
15452 --- linux-2.6.33/kernel/compat.c 2009-09-10 15:26:27.000000000 +0200
15453 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/compat.c 2010-02-25 12:02:16.000000000 +0100
15454 @@ -902,7 +902,7 @@ asmlinkage long compat_sys_time(compat_t
15458 - do_gettimeofday(&tv);
15459 + vx_gettimeofday(&tv);
15463 @@ -927,7 +927,7 @@ asmlinkage long compat_sys_stime(compat_
15467 - do_settimeofday(&tv);
15468 + vx_settimeofday(&tv);
15472 diff -NurpP --minimal linux-2.6.33/kernel/exit.c linux-2.6.33-vs2.3.0.36.30.1/kernel/exit.c
15473 --- linux-2.6.33/kernel/exit.c 2010-02-25 11:52:09.000000000 +0100
15474 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/exit.c 2010-02-25 12:02:16.000000000 +0100
15476 #include <linux/fs_struct.h>
15477 #include <linux/init_task.h>
15478 #include <linux/perf_event.h>
15479 +#include <linux/vs_limit.h>
15480 +#include <linux/vs_context.h>
15481 +#include <linux/vs_network.h>
15482 +#include <linux/vs_pid.h>
15483 #include <trace/events/sched.h>
15484 #include <linux/hw_breakpoint.h>
15486 @@ -489,9 +493,11 @@ static void close_files(struct files_str
15487 filp_close(file, files);
15490 + vx_openfd_dec(i);
15498 @@ -1019,11 +1025,16 @@ NORET_TYPE void do_exit(long code)
15500 validate_creds_for_do_exit(tsk);
15502 + /* needs to stay after exit_notify() */
15503 + exit_vx_info(tsk, code);
15504 + exit_nx_info(tsk);
15508 /* causes final put_task_struct in finish_task_switch(). */
15509 tsk->state = TASK_DEAD;
15511 + printk("bad task: %p [%lx]\n", current, current->state);
15513 /* Avoid "noreturn function does return". */
15515 diff -NurpP --minimal linux-2.6.33/kernel/fork.c linux-2.6.33-vs2.3.0.36.30.1/kernel/fork.c
15516 --- linux-2.6.33/kernel/fork.c 2010-02-25 11:52:09.000000000 +0100
15517 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/fork.c 2010-02-25 12:23:31.000000000 +0100
15519 #include <linux/perf_event.h>
15520 #include <linux/posix-timers.h>
15521 #include <linux/user-return-notifier.h>
15522 +#include <linux/vs_context.h>
15523 +#include <linux/vs_network.h>
15524 +#include <linux/vs_limit.h>
15525 +#include <linux/vs_memory.h>
15527 #include <asm/pgtable.h>
15528 #include <asm/pgalloc.h>
15529 @@ -152,6 +156,8 @@ void free_task(struct task_struct *tsk)
15530 account_kernel_stack(tsk->stack, -1);
15531 free_thread_info(tsk->stack);
15532 rt_mutex_debug_task_free(tsk);
15533 + clr_vx_info(&tsk->vx_info);
15534 + clr_nx_info(&tsk->nx_info);
15535 ftrace_graph_exit_task(tsk);
15536 free_task_struct(tsk);
15538 @@ -298,6 +304,8 @@ static int dup_mmap(struct mm_struct *mm
15539 mm->free_area_cache = oldmm->mmap_base;
15540 mm->cached_hole_size = ~0UL;
15542 + __set_mm_counter(mm, file_rss, 0);
15543 + __set_mm_counter(mm, anon_rss, 0);
15544 cpumask_clear(mm_cpumask(mm));
15545 mm->mm_rb = RB_ROOT;
15546 rb_link = &mm->mm_rb.rb_node;
15547 @@ -312,7 +320,7 @@ static int dup_mmap(struct mm_struct *mm
15549 if (mpnt->vm_flags & VM_DONTCOPY) {
15550 long pages = vma_pages(mpnt);
15551 - mm->total_vm -= pages;
15552 + vx_vmpages_sub(mm, pages);
15553 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15556 @@ -454,8 +462,8 @@ static struct mm_struct * mm_init(struct
15557 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
15558 mm->core_state = NULL;
15560 - set_mm_counter(mm, file_rss, 0);
15561 - set_mm_counter(mm, anon_rss, 0);
15562 + __set_mm_counter(mm, file_rss, 0);
15563 + __set_mm_counter(mm, anon_rss, 0);
15564 spin_lock_init(&mm->page_table_lock);
15565 mm->free_area_cache = TASK_UNMAPPED_BASE;
15566 mm->cached_hole_size = ~0UL;
15567 @@ -465,6 +473,7 @@ static struct mm_struct * mm_init(struct
15568 if (likely(!mm_alloc_pgd(mm))) {
15570 mmu_notifier_mm_init(mm);
15571 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15575 @@ -498,6 +507,7 @@ void __mmdrop(struct mm_struct *mm)
15577 destroy_context(mm);
15578 mmu_notifier_mm_destroy(mm);
15579 + clr_vx_info(&mm->mm_vx_info);
15582 EXPORT_SYMBOL_GPL(__mmdrop);
15583 @@ -633,6 +643,7 @@ struct mm_struct *dup_mm(struct task_str
15586 memcpy(mm, oldmm, sizeof(*mm));
15587 + mm->mm_vx_info = NULL;
15589 /* Initializing for Swap token stuff */
15590 mm->token_priority = 0;
15591 @@ -671,6 +682,7 @@ fail_nocontext:
15592 * If init_new_context() failed, we cannot use mmput() to free the mm
15593 * because it calls destroy_context()
15595 + clr_vx_info(&mm->mm_vx_info);
15599 @@ -985,6 +997,8 @@ static struct task_struct *copy_process(
15601 struct task_struct *p;
15602 int cgroup_callbacks_done = 0;
15603 + struct vx_info *vxi;
15604 + struct nx_info *nxi;
15606 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15607 return ERR_PTR(-EINVAL);
15608 @@ -1031,12 +1045,28 @@ static struct task_struct *copy_process(
15609 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15610 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15612 + init_vx_info(&p->vx_info, current_vx_info());
15613 + init_nx_info(&p->nx_info, current_nx_info());
15615 + /* check vserver memory */
15616 + if (p->mm && !(clone_flags & CLONE_VM)) {
15617 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15618 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15620 + goto bad_fork_free;
15622 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15623 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15624 + goto bad_fork_cleanup_vm;
15627 + if (!vx_nproc_avail(1))
15628 + goto bad_fork_cleanup_vm;
15629 if (atomic_read(&p->real_cred->user->processes) >=
15630 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15631 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15632 p->real_cred->user != INIT_USER)
15633 - goto bad_fork_free;
15634 + goto bad_fork_cleanup_vm;
15637 retval = copy_creds(p, clone_flags);
15638 @@ -1297,6 +1327,18 @@ static struct task_struct *copy_process(
15641 spin_unlock(¤t->sighand->siglock);
15643 + /* p is copy of current */
15644 + vxi = p->vx_info;
15646 + claim_vx_info(vxi, p);
15647 + atomic_inc(&vxi->cvirt.nr_threads);
15648 + atomic_inc(&vxi->cvirt.total_forks);
15651 + nxi = p->nx_info;
15653 + claim_nx_info(nxi, p);
15654 write_unlock_irq(&tasklist_lock);
15655 proc_fork_connector(p);
15656 cgroup_post_fork(p);
15657 @@ -1339,6 +1381,9 @@ bad_fork_cleanup_cgroup:
15658 bad_fork_cleanup_count:
15659 atomic_dec(&p->cred->user->processes);
15661 +bad_fork_cleanup_vm:
15662 + if (p->mm && !(clone_flags & CLONE_VM))
15663 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15667 diff -NurpP --minimal linux-2.6.33/kernel/kthread.c linux-2.6.33-vs2.3.0.36.30.1/kernel/kthread.c
15668 --- linux-2.6.33/kernel/kthread.c 2010-02-25 11:52:09.000000000 +0100
15669 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/kthread.c 2010-02-25 12:02:16.000000000 +0100
15671 #include <linux/file.h>
15672 #include <linux/module.h>
15673 #include <linux/mutex.h>
15674 +#include <linux/vs_pid.h>
15675 #include <trace/events/sched.h>
15677 static DEFINE_SPINLOCK(kthread_create_lock);
15678 diff -NurpP --minimal linux-2.6.33/kernel/Makefile linux-2.6.33-vs2.3.0.36.30.1/kernel/Makefile
15679 --- linux-2.6.33/kernel/Makefile 2010-02-25 11:52:09.000000000 +0100
15680 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/Makefile 2010-02-25 12:02:16.000000000 +0100
15681 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
15682 CFLAGS_REMOVE_perf_event.o = -pg
15686 obj-$(CONFIG_FREEZER) += freezer.o
15687 obj-$(CONFIG_PROFILING) += profile.o
15688 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15689 diff -NurpP --minimal linux-2.6.33/kernel/nsproxy.c linux-2.6.33-vs2.3.0.36.30.1/kernel/nsproxy.c
15690 --- linux-2.6.33/kernel/nsproxy.c 2009-09-10 15:26:28.000000000 +0200
15691 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/nsproxy.c 2010-02-25 12:02:16.000000000 +0100
15693 #include <linux/mnt_namespace.h>
15694 #include <linux/utsname.h>
15695 #include <linux/pid_namespace.h>
15696 +#include <linux/vserver/global.h>
15697 +#include <linux/vserver/debug.h>
15698 #include <net/net_namespace.h>
15699 #include <linux/ipc_namespace.h>
15701 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
15702 struct nsproxy *nsproxy;
15704 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15707 atomic_set(&nsproxy->count, 1);
15708 + atomic_inc(&vs_global_nsproxy);
15710 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15714 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
15715 * Return the newly created nsproxy. Do not attach this to the task,
15716 * leave it to the caller to do proper locking and attach it to task.
15718 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15719 - struct task_struct *tsk, struct fs_struct *new_fs)
15720 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15721 + struct nsproxy *orig, struct fs_struct *new_fs)
15723 struct nsproxy *new_nsp;
15726 + vxdprintk(VXD_CBIT(space, 4),
15727 + "unshare_namespaces(0x%08lx,%p,%p)",
15728 + flags, orig, new_fs);
15730 new_nsp = create_nsproxy();
15732 return ERR_PTR(-ENOMEM);
15734 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15735 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15736 if (IS_ERR(new_nsp->mnt_ns)) {
15737 err = PTR_ERR(new_nsp->mnt_ns);
15741 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15742 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15743 if (IS_ERR(new_nsp->uts_ns)) {
15744 err = PTR_ERR(new_nsp->uts_ns);
15748 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15749 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15750 if (IS_ERR(new_nsp->ipc_ns)) {
15751 err = PTR_ERR(new_nsp->ipc_ns);
15755 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15756 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15757 if (IS_ERR(new_nsp->pid_ns)) {
15758 err = PTR_ERR(new_nsp->pid_ns);
15762 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15764 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15765 + if (IS_ERR(new_nsp->user_ns)) {
15766 + err = PTR_ERR(new_nsp->user_ns);
15770 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15771 if (IS_ERR(new_nsp->net_ns)) {
15772 err = PTR_ERR(new_nsp->net_ns);
15774 @@ -100,6 +116,38 @@ out_ns:
15775 return ERR_PTR(err);
15778 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15779 + struct fs_struct *new_fs)
15781 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15785 + * copies the nsproxy, setting refcount to 1, and grabbing a
15786 + * reference to all contained namespaces.
15788 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15790 + struct nsproxy *ns = create_nsproxy();
15793 + memcpy(ns, orig, sizeof(struct nsproxy));
15794 + atomic_set(&ns->count, 1);
15797 + get_mnt_ns(ns->mnt_ns);
15799 + get_uts_ns(ns->uts_ns);
15801 + get_ipc_ns(ns->ipc_ns);
15803 + get_pid_ns(ns->pid_ns);
15805 + get_net(ns->net_ns);
15811 * called from clone. This now handles copy for nsproxy and all
15812 * namespaces therein.
15813 @@ -107,9 +155,12 @@ out_ns:
15814 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15816 struct nsproxy *old_ns = tsk->nsproxy;
15817 - struct nsproxy *new_ns;
15818 + struct nsproxy *new_ns = NULL;
15821 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15822 + flags, tsk, old_ns);
15827 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
15828 CLONE_NEWPID | CLONE_NEWNET)))
15831 - if (!capable(CAP_SYS_ADMIN)) {
15832 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15836 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
15839 put_nsproxy(old_ns);
15840 + vxdprintk(VXD_CBIT(space, 3),
15841 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15842 + flags, tsk, old_ns, err, new_ns);
15846 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
15847 put_ipc_ns(ns->ipc_ns);
15849 put_pid_ns(ns->pid_ns);
15850 - put_net(ns->net_ns);
15852 + put_net(ns->net_ns);
15853 + atomic_dec(&vs_global_nsproxy);
15854 kmem_cache_free(nsproxy_cachep, ns);
15857 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned
15861 + vxdprintk(VXD_CBIT(space, 4),
15862 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15863 + unshare_flags, current->nsproxy);
15865 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15869 - if (!capable(CAP_SYS_ADMIN))
15870 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15873 *new_nsp = create_new_namespaces(unshare_flags, current,
15874 diff -NurpP --minimal linux-2.6.33/kernel/pid.c linux-2.6.33-vs2.3.0.36.30.1/kernel/pid.c
15875 --- linux-2.6.33/kernel/pid.c 2010-02-25 11:52:09.000000000 +0100
15876 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/pid.c 2010-02-25 12:02:16.000000000 +0100
15878 #include <linux/pid_namespace.h>
15879 #include <linux/init_task.h>
15880 #include <linux/syscalls.h>
15881 +#include <linux/vs_pid.h>
15883 #define pid_hashfn(nr, ns) \
15884 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15885 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15887 struct pid *find_vpid(int nr)
15889 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15890 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15892 EXPORT_SYMBOL_GPL(find_vpid);
15894 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
15895 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15897 struct task_struct *result = NULL;
15899 + if (type == PIDTYPE_REALPID)
15900 + type = PIDTYPE_PID;
15902 struct hlist_node *first;
15903 first = rcu_dereference(pid->tasks[type].first);
15904 @@ -380,7 +384,7 @@ EXPORT_SYMBOL(pid_task);
15906 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15908 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15909 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15912 struct task_struct *find_task_by_vpid(pid_t vnr)
15913 @@ -422,7 +426,7 @@ struct pid *find_get_pid(pid_t nr)
15915 EXPORT_SYMBOL_GPL(find_get_pid);
15917 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15918 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15922 @@ -435,6 +439,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15926 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15928 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15931 pid_t pid_vnr(struct pid *pid)
15933 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15934 diff -NurpP --minimal linux-2.6.33/kernel/pid_namespace.c linux-2.6.33-vs2.3.0.36.30.1/kernel/pid_namespace.c
15935 --- linux-2.6.33/kernel/pid_namespace.c 2009-12-03 20:02:58.000000000 +0100
15936 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/pid_namespace.c 2010-02-25 12:02:16.000000000 +0100
15938 #include <linux/syscalls.h>
15939 #include <linux/err.h>
15940 #include <linux/acct.h>
15941 +#include <linux/vserver/global.h>
15943 #define BITS_PER_PAGE (PAGE_SIZE*8)
15945 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
15948 kref_init(&ns->kref);
15949 + atomic_inc(&vs_global_pid_ns);
15951 ns->parent = get_pid_ns(parent_pid_ns);
15953 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
15955 for (i = 0; i < PIDMAP_ENTRIES; i++)
15956 kfree(ns->pidmap[i].page);
15957 + atomic_dec(&vs_global_pid_ns);
15958 kmem_cache_free(pid_ns_cachep, ns);
15961 diff -NurpP --minimal linux-2.6.33/kernel/posix-timers.c linux-2.6.33-vs2.3.0.36.30.1/kernel/posix-timers.c
15962 --- linux-2.6.33/kernel/posix-timers.c 2009-12-03 20:02:58.000000000 +0100
15963 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/posix-timers.c 2010-02-25 12:02:16.000000000 +0100
15965 #include <linux/wait.h>
15966 #include <linux/workqueue.h>
15967 #include <linux/module.h>
15968 +#include <linux/vs_context.h>
15971 * Management arrays for POSIX timers. Timers are kept in slab memory
15972 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15974 struct task_struct *task;
15975 int shared, ret = -1;
15978 * FIXME: if ->sigq is queued we can race with
15979 * dequeue_signal()->do_schedule_next_timer().
15980 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15982 task = pid_task(timr->it_pid, PIDTYPE_PID);
15984 + struct vx_info_save vxis;
15985 + struct vx_info *vxi;
15987 + vxi = get_vx_info(task->vx_info);
15988 + enter_vx_info(vxi, &vxis);
15989 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15990 ret = send_sigqueue(timr->sigq, task, shared);
15991 + leave_vx_info(&vxis);
15992 + put_vx_info(vxi);
15996 /* If we failed to send the signal the timer stops. */
15999 diff -NurpP --minimal linux-2.6.33/kernel/printk.c linux-2.6.33-vs2.3.0.36.30.1/kernel/printk.c
16000 --- linux-2.6.33/kernel/printk.c 2010-02-25 11:52:09.000000000 +0100
16001 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/printk.c 2010-02-25 13:11:15.000000000 +0100
16003 #include <linux/kexec.h>
16004 #include <linux/ratelimit.h>
16005 #include <linux/kmsg_dump.h>
16006 +#include <linux/vs_cvirt.h>
16008 #include <asm/uaccess.h>
16010 @@ -278,18 +279,13 @@ int do_syslog(int type, char __user *buf
16011 unsigned i, j, limit, count;
16017 error = security_syslog(type);
16022 - case 0: /* Close log */
16024 - case 1: /* Open log */
16026 - case 2: /* Read from log */
16027 + if ((type >= 2) && (type <= 4)) {
16029 if (!buf || len < 0)
16031 @@ -300,6 +296,16 @@ int do_syslog(int type, char __user *buf
16036 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16037 + return vx_do_syslog(type, buf, len);
16040 + case 0: /* Close log */
16042 + case 1: /* Open log */
16044 + case 2: /* Read from log */
16045 error = wait_event_interruptible(log_wait,
16046 (log_start - log_end));
16048 @@ -324,16 +330,6 @@ int do_syslog(int type, char __user *buf
16051 case 3: /* Read last kernel messages */
16053 - if (!buf || len < 0)
16058 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16063 if (count > log_buf_len)
16064 count = log_buf_len;
16065 diff -NurpP --minimal linux-2.6.33/kernel/ptrace.c linux-2.6.33-vs2.3.0.36.30.1/kernel/ptrace.c
16066 --- linux-2.6.33/kernel/ptrace.c 2009-12-03 20:02:58.000000000 +0100
16067 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/ptrace.c 2010-02-25 12:02:16.000000000 +0100
16069 #include <linux/pid_namespace.h>
16070 #include <linux/syscalls.h>
16071 #include <linux/uaccess.h>
16072 +#include <linux/vs_context.h>
16076 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
16077 dumpable = get_dumpable(task->mm);
16078 if (!dumpable && !capable(CAP_SYS_PTRACE))
16080 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16082 + if (!vx_check(task->xid, VS_IDENT) &&
16083 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16086 return security_ptrace_access_check(task, mode);
16088 @@ -621,6 +627,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
16093 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16094 + goto out_put_task_struct;
16096 if (request == PTRACE_ATTACH) {
16097 ret = ptrace_attach(child);
16099 diff -NurpP --minimal linux-2.6.33/kernel/sched.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sched.c
16100 --- linux-2.6.33/kernel/sched.c 2010-02-25 11:52:09.000000000 +0100
16101 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sched.c 2010-02-25 16:24:45.000000000 +0100
16103 #include <linux/debugfs.h>
16104 #include <linux/ctype.h>
16105 #include <linux/ftrace.h>
16106 +#include <linux/vs_sched.h>
16107 +#include <linux/vs_cvirt.h>
16109 #include <asm/tlb.h>
16110 #include <asm/irq_regs.h>
16111 @@ -139,50 +141,59 @@ struct rt_prio_array {
16112 struct list_head queue[MAX_RT_PRIO];
16115 -struct rt_bandwidth {
16116 +struct sched_bandwidth {
16117 /* nests inside the rq lock: */
16118 - raw_spinlock_t rt_runtime_lock;
16119 - ktime_t rt_period;
16121 - struct hrtimer rt_period_timer;
16122 + raw_spinlock_t runtime_lock;
16125 + struct hrtimer period_timer;
16128 -static struct rt_bandwidth def_rt_bandwidth;
16129 +static struct sched_bandwidth def_rt_bandwidth;
16131 -static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
16132 +static int do_sched_rt_period_timer(struct sched_bandwidth *sched_b, int overrun);
16133 +static int do_sched_cfs_period_timer(struct sched_bandwidth *sched_b, int overrun);
16135 -static enum hrtimer_restart sched_rt_period_timer(struct hrtimer *timer)
16136 +static enum hrtimer_restart sched_period_timer(struct hrtimer *timer, int rt)
16138 - struct rt_bandwidth *rt_b =
16139 - container_of(timer, struct rt_bandwidth, rt_period_timer);
16140 + struct sched_bandwidth *sched_b =
16141 + container_of(timer, struct sched_bandwidth, period_timer);
16147 now = hrtimer_cb_get_time(timer);
16148 - overrun = hrtimer_forward(timer, now, rt_b->rt_period);
16149 + overrun = hrtimer_forward(timer, now, sched_b->period);
16154 - idle = do_sched_rt_period_timer(rt_b, overrun);
16156 + idle = do_sched_rt_period_timer(sched_b, overrun);
16158 + idle = do_sched_cfs_period_timer(sched_b, overrun);
16161 return idle ? HRTIMER_NORESTART : HRTIMER_RESTART;
16165 -void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime)
16166 +static enum hrtimer_restart sched_rt_period_timer(struct hrtimer *timer)
16168 - rt_b->rt_period = ns_to_ktime(period);
16169 - rt_b->rt_runtime = runtime;
16170 + return sched_period_timer(timer, 1);
16173 - raw_spin_lock_init(&rt_b->rt_runtime_lock);
16174 +static void init_sched_bandwidth(struct sched_bandwidth *sched_b, u64 period,
16175 + u64 runtime, enum hrtimer_restart (*period_timer)(struct hrtimer *))
16177 + sched_b->period = ns_to_ktime(period);
16178 + sched_b->runtime = runtime;
16180 - hrtimer_init(&rt_b->rt_period_timer,
16181 + raw_spin_lock_init(&sched_b->runtime_lock);
16183 + hrtimer_init(&sched_b->period_timer,
16184 CLOCK_MONOTONIC, HRTIMER_MODE_REL);
16185 - rt_b->rt_period_timer.function = sched_rt_period_timer;
16186 + sched_b->period_timer.function = *period_timer;
16189 static inline int rt_bandwidth_enabled(void)
16190 @@ -190,40 +201,43 @@ static inline int rt_bandwidth_enabled(v
16191 return sysctl_sched_rt_runtime >= 0;
16194 -static void start_rt_bandwidth(struct rt_bandwidth *rt_b)
16195 +static void start_sched_bandwidth(struct sched_bandwidth *sched_b, int rt)
16199 - if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
16200 + if (rt && !rt_bandwidth_enabled())
16203 - if (hrtimer_active(&rt_b->rt_period_timer))
16204 + if (sched_b->runtime == RUNTIME_INF)
16207 - raw_spin_lock(&rt_b->rt_runtime_lock);
16208 + if (hrtimer_active(&sched_b->period_timer))
16211 + raw_spin_lock(&sched_b->runtime_lock);
16213 unsigned long delta;
16214 ktime_t soft, hard;
16216 - if (hrtimer_active(&rt_b->rt_period_timer))
16217 + if (hrtimer_active(&sched_b->period_timer))
16220 - now = hrtimer_cb_get_time(&rt_b->rt_period_timer);
16221 - hrtimer_forward(&rt_b->rt_period_timer, now, rt_b->rt_period);
16222 + now = hrtimer_cb_get_time(&sched_b->period_timer);
16223 + hrtimer_forward(&sched_b->period_timer, now, sched_b->period);
16225 - soft = hrtimer_get_softexpires(&rt_b->rt_period_timer);
16226 - hard = hrtimer_get_expires(&rt_b->rt_period_timer);
16227 + soft = hrtimer_get_softexpires(&sched_b->period_timer);
16228 + hard = hrtimer_get_expires(&sched_b->period_timer);
16229 delta = ktime_to_ns(ktime_sub(hard, soft));
16230 - __hrtimer_start_range_ns(&rt_b->rt_period_timer, soft, delta,
16231 + __hrtimer_start_range_ns(&sched_b->period_timer, soft, delta,
16232 HRTIMER_MODE_ABS_PINNED, 0);
16234 - raw_spin_unlock(&rt_b->rt_runtime_lock);
16235 + raw_spin_unlock(&sched_b->runtime_lock);
16238 -#ifdef CONFIG_RT_GROUP_SCHED
16239 -static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b)
16240 +#if defined CONFIG_RT_GROUP_SCHED || defined CONFIG_FAIR_GROUP_SCHED
16241 +static void destroy_sched_bandwidth(struct sched_bandwidth *sched_b)
16243 - hrtimer_cancel(&rt_b->rt_period_timer);
16244 + hrtimer_cancel(&sched_b->period_timer);
16248 @@ -257,13 +271,14 @@ struct task_group {
16249 /* runqueue "owned" by this group on each cpu */
16250 struct cfs_rq **cfs_rq;
16251 unsigned long shares;
16252 + struct sched_bandwidth cfs_bandwidth;
16255 #ifdef CONFIG_RT_GROUP_SCHED
16256 struct sched_rt_entity **rt_se;
16257 struct rt_rq **rt_rq;
16259 - struct rt_bandwidth rt_bandwidth;
16260 + struct sched_bandwidth rt_bandwidth;
16263 struct rcu_head rcu;
16264 @@ -385,6 +400,14 @@ static inline struct task_group *task_gr
16266 #endif /* CONFIG_GROUP_SCHED */
16268 +struct rq_bandwidth {
16272 + /* Nests inside the rq lock: */
16273 + raw_spinlock_t runtime_lock;
16276 /* CFS-related fields in a runqueue */
16278 struct load_weight load;
16279 @@ -446,6 +469,7 @@ struct cfs_rq {
16280 unsigned long rq_weight;
16283 + struct rq_bandwidth rq_bandwidth;
16286 /* Real-Time classes' related field in a runqueue: */
16287 @@ -466,11 +490,7 @@ struct rt_rq {
16289 struct plist_head pushable_tasks;
16291 - int rt_throttled;
16294 - /* Nests inside the rq lock: */
16295 - raw_spinlock_t rt_runtime_lock;
16296 + struct rq_bandwidth rq_bandwidth;
16298 #ifdef CONFIG_RT_GROUP_SCHED
16299 unsigned long rt_nr_boosted;
16300 @@ -1608,6 +1628,7 @@ static void update_group_shares_cpu(stru
16304 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq);
16306 * Re-compute the task group their per cpu shares over the given domain.
16307 * This needs to be done in a bottom-up fashion because the rq weight of a
16308 @@ -1636,8 +1657,10 @@ static int tg_shares_up(struct task_grou
16309 * If there are currently no tasks on the cpu pretend there
16310 * is one of average load so that when a new task gets to
16311 * run here it will not get delayed by group starvation.
16312 + * Also if the group is throttled on this cpu, pretend that
16313 + * it has no tasks.
16316 + if (!weight || cfs_rq_throttled(tg->cfs_rq[i]))
16317 weight = NICE_0_LOAD;
16319 sum_weight += weight;
16320 @@ -1834,6 +1857,297 @@ static inline void __set_task_cpu(struct
16325 +#if defined(CONFIG_RT_GROUP_SCHED) || defined(CONFIG_FAIR_GROUP_SCHED)
16328 +static inline const struct cpumask *sched_bw_period_mask(void)
16330 + return cpu_rq(smp_processor_id())->rd->span;
16332 +#else /* !CONFIG_SMP */
16333 +static inline const struct cpumask *sched_bw_period_mask(void)
16335 + return cpu_online_mask;
16337 +#endif /* CONFIG_SMP */
16340 +static inline const struct cpumask *sched_bw_period_mask(void)
16342 + return cpu_online_mask;
16347 +static void init_rq_bandwidth(struct rq_bandwidth *rq_b, u64 runtime)
16350 + rq_b->throttled = 0;
16351 + rq_b->runtime = runtime;
16352 + raw_spin_lock_init(&rq_b->runtime_lock);
16355 +#ifdef CONFIG_RT_GROUP_SCHED
16358 +struct rt_rq *sched_rt_period_rt_rq(struct sched_bandwidth *rt_b, int cpu)
16360 + return container_of(rt_b, struct task_group, rt_bandwidth)->rt_rq[cpu];
16366 +struct rt_rq *sched_rt_period_rt_rq(struct sched_bandwidth *rt_b, int cpu)
16368 + return &cpu_rq(cpu)->rt;
16373 +#ifdef CONFIG_FAIR_GROUP_SCHED
16375 +struct cfs_rq *sched_cfs_period_cfs_rq(struct sched_bandwidth *cfs_b, int cpu)
16377 + return container_of(cfs_b, struct task_group,
16378 + cfs_bandwidth)->cfs_rq[cpu];
16384 +struct cfs_rq *sched_cfs_period_cfs_rq(struct sched_bandwidth *cfs_b, int cpu)
16386 + return &cpu_rq(cpu)->cfs;
16393 +void __disable_runtime(struct rq *rq, struct sched_bandwidth *sched_b,
16394 + struct rq_bandwidth *rq_b, int rt)
16396 + struct root_domain *rd = rq->rd;
16400 + raw_spin_lock(&sched_b->runtime_lock);
16401 + raw_spin_lock(&rq_b->runtime_lock);
16404 + * Either we're all inf and nobody needs to borrow, or we're
16405 + * already disabled and thus have nothing to do, or we have
16406 + * exactly the right amount of runtime to take out.
16408 + if (rq_b->runtime == RUNTIME_INF || rq_b->runtime == sched_b->runtime)
16411 + raw_spin_unlock(&rq_b->runtime_lock);
16414 + * Calculate the difference between what we started out with
16415 + * and what we current have, that's the amount of runtime
16416 + * we lend and now have to reclaim.
16418 + want = sched_b->runtime - rq_b->runtime;
16421 + * Greedy reclaim, take back as much as we can.
16423 + for_each_cpu(i, rd->span) {
16424 + struct rq_bandwidth *iter;
16428 + iter = &(sched_rt_period_rt_rq(sched_b, i)->rq_bandwidth);
16430 + iter = &(sched_cfs_period_cfs_rq(sched_b, i)->rq_bandwidth);
16432 + * Can't reclaim from ourselves or disabled runqueues.
16434 + if (iter == rq_b || iter->runtime == RUNTIME_INF)
16437 + raw_spin_lock(&iter->runtime_lock);
16439 + diff = min_t(s64, iter->runtime, want);
16440 + iter->runtime -= diff;
16443 + iter->runtime -= want;
16446 + raw_spin_unlock(&iter->runtime_lock);
16452 + raw_spin_lock(&rq_b->runtime_lock);
16454 + * We cannot be left wanting - that would mean some runtime
16455 + * leaked out of the system.
16461 + * Disable all the borrow logic by pretending we have inf
16462 + * runtime - in which case borrowing doesn't make sense.
16464 + rq_b->runtime = RUNTIME_INF;
16465 + raw_spin_unlock(&rq_b->runtime_lock);
16466 + raw_spin_unlock(&sched_b->runtime_lock);
16469 +void disable_runtime_rt(struct rq *rq);
16470 +void disable_runtime_cfs(struct rq *rq);
16471 +static void disable_runtime(struct rq *rq)
16473 + unsigned long flags;
16475 + raw_spin_lock_irqsave(&rq->lock, flags);
16476 + disable_runtime_rt(rq);
16477 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16478 + disable_runtime_cfs(rq);
16480 + raw_spin_unlock_irqrestore(&rq->lock, flags);
16483 +void __enable_runtime(struct sched_bandwidth *sched_b,
16484 + struct rq_bandwidth *rq_b)
16486 + raw_spin_lock(&sched_b->runtime_lock);
16487 + raw_spin_lock(&rq_b->runtime_lock);
16488 + rq_b->runtime = sched_b->runtime;
16490 + rq_b->throttled = 0;
16491 + raw_spin_unlock(&rq_b->runtime_lock);
16492 + raw_spin_unlock(&sched_b->runtime_lock);
16495 +void enable_runtime_rt(struct rq *rq);
16496 +void enable_runtime_cfs(struct rq *rq);
16497 +static void enable_runtime(struct rq *rq)
16499 + unsigned long flags;
16501 + raw_spin_lock_irqsave(&rq->lock, flags);
16502 + enable_runtime_rt(rq);
16503 +#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_CFS_HARD_LIMITS)
16504 + enable_runtime_cfs(rq);
16506 + raw_spin_unlock_irqrestore(&rq->lock, flags);
16510 + * We ran out of runtime, see if we can borrow some from our neighbours.
16512 +static void do_balance_runtime(struct rq_bandwidth *rq_b,
16513 + struct sched_bandwidth *sched_b, int rt)
16515 + struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
16519 + weight = cpumask_weight(rd->span);
16521 + raw_spin_lock(&sched_b->runtime_lock);
16522 + period = ktime_to_ns(sched_b->period);
16523 + for_each_cpu(i, rd->span) {
16524 + struct rq_bandwidth *iter;
16528 + iter = &(sched_rt_period_rt_rq(sched_b, i)->rq_bandwidth);
16530 + iter = &(sched_cfs_period_cfs_rq(sched_b, i)->rq_bandwidth);
16532 + if (iter == rq_b)
16535 + raw_spin_lock(&iter->runtime_lock);
16537 + * Either all rqs have inf runtime and there's nothing to steal
16538 + * or __disable_runtime() below sets a specific rq to inf to
16539 + * indicate its been disabled and disalow stealing.
16541 + if (iter->runtime == RUNTIME_INF)
16545 + * From runqueues with spare time, take 1/n part of their
16546 + * spare time, but no more than our period.
16548 + diff = iter->runtime - iter->time;
16550 + diff = div_u64((u64)diff, weight);
16551 + if (rq_b->runtime + diff > period)
16552 + diff = period - rq_b->runtime;
16553 + iter->runtime -= diff;
16554 + rq_b->runtime += diff;
16555 + if (rq_b->runtime == period) {
16556 + raw_spin_unlock(&iter->runtime_lock);
16561 + raw_spin_unlock(&iter->runtime_lock);
16563 + raw_spin_unlock(&sched_b->runtime_lock);
16566 +static void balance_runtime(struct rq_bandwidth *rq_b,
16567 + struct sched_bandwidth *sched_b, int rt)
16569 + if (rq_b->time > rq_b->runtime) {
16570 + raw_spin_unlock(&rq_b->runtime_lock);
16571 + do_balance_runtime(rq_b, sched_b, rt);
16572 + raw_spin_lock(&rq_b->runtime_lock);
16575 +#else /* !CONFIG_SMP */
16576 +static inline void balance_runtime(struct rq_bandwidth *rq_b,
16577 + struct sched_bandwidth *sched_b, int rt)
16581 +#endif /* CONFIG_SMP */
16584 + * Runtime allowed for a cfs group before it is hard limited.
16585 + * default: Infinite which means no hard limiting.
16587 +u64 sched_cfs_runtime = RUNTIME_INF;
16590 + * period over which we hard limit the cfs group's bandwidth.
16593 +u64 sched_cfs_period = 500000;
16595 +static inline u64 global_cfs_period(void)
16597 + return sched_cfs_period * NSEC_PER_USEC;
16600 +static inline u64 global_cfs_runtime(void)
16602 + return RUNTIME_INF;
16605 +#ifdef CONFIG_FAIR_GROUP_SCHED
16607 + * Refresh the runtimes of the throttled groups.
16609 +static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)
16611 + return sched_period_timer(timer, 0);
16615 #include "sched_stats.h"
16616 #include "sched_idletask.c"
16617 #include "sched_fair.c"
16618 @@ -3009,9 +3323,17 @@ EXPORT_SYMBOL(avenrun);
16620 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
16622 - loads[0] = (avenrun[0] + offset) << shift;
16623 - loads[1] = (avenrun[1] + offset) << shift;
16624 - loads[2] = (avenrun[2] + offset) << shift;
16625 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
16626 + struct vx_info *vxi = current_vx_info();
16628 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
16629 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
16630 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
16632 + loads[0] = (avenrun[0] + offset) << shift;
16633 + loads[1] = (avenrun[1] + offset) << shift;
16634 + loads[2] = (avenrun[2] + offset) << shift;
16638 static unsigned long
16639 @@ -5046,16 +5368,19 @@ void account_user_time(struct task_struc
16640 cputime_t cputime_scaled)
16642 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16643 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16645 + int nice = (TASK_NICE(p) > 0);
16647 /* Add user time to process. */
16648 p->utime = cputime_add(p->utime, cputime);
16649 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
16650 + vx_account_user(vxi, cputime, nice);
16651 account_group_user_time(p, cputime);
16653 /* Add user time to cpustat. */
16654 tmp = cputime_to_cputime64(cputime);
16655 - if (TASK_NICE(p) > 0)
16657 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16659 cpustat->user = cputime64_add(cpustat->user, tmp);
16660 @@ -5106,6 +5431,7 @@ void account_system_time(struct task_str
16661 cputime_t cputime, cputime_t cputime_scaled)
16663 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16664 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16667 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
16668 @@ -5116,6 +5442,7 @@ void account_system_time(struct task_str
16669 /* Add system time to process. */
16670 p->stime = cputime_add(p->stime, cputime);
16671 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
16672 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
16673 account_group_system_time(p, cputime);
16675 /* Add system time to cpustat. */
16676 @@ -6180,7 +6507,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16679 if (increment < 0 && !can_nice(current, nice))
16681 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16683 retval = security_task_setnice(current, nice);
16685 @@ -6358,7 +6685,7 @@ recheck:
16688 if (rt_bandwidth_enabled() && rt_policy(policy) &&
16689 - task_group(p)->rt_bandwidth.rt_runtime == 0)
16690 + task_group(p)->rt_bandwidth.runtime == 0)
16694 @@ -9401,11 +9728,7 @@ static void init_rt_rq(struct rt_rq *rt_
16695 rt_rq->overloaded = 0;
16696 plist_head_init_raw(&rt_rq->pushable_tasks, &rq->lock);
16699 - rt_rq->rt_time = 0;
16700 - rt_rq->rt_throttled = 0;
16701 - rt_rq->rt_runtime = 0;
16702 - raw_spin_lock_init(&rt_rq->rt_runtime_lock);
16703 + init_rq_bandwidth(&rt_rq->rq_bandwidth, 0);
16705 #ifdef CONFIG_RT_GROUP_SCHED
16706 rt_rq->rt_nr_boosted = 0;
16707 @@ -9421,6 +9744,7 @@ static void init_tg_cfs_entry(struct tas
16708 struct rq *rq = cpu_rq(cpu);
16709 tg->cfs_rq[cpu] = cfs_rq;
16710 init_cfs_rq(cfs_rq, rq);
16711 + init_rq_bandwidth(&cfs_rq->rq_bandwidth, tg->cfs_bandwidth.runtime);
16714 list_add(&cfs_rq->leaf_cfs_rq_list, &rq->leaf_cfs_rq_list);
16715 @@ -9453,7 +9777,7 @@ static void init_tg_rt_entry(struct task
16716 init_rt_rq(rt_rq, rq);
16718 rt_rq->rt_se = rt_se;
16719 - rt_rq->rt_runtime = tg->rt_bandwidth.rt_runtime;
16720 + rt_rq->rq_bandwidth.runtime = tg->rt_bandwidth.runtime;
16722 list_add(&rt_rq->leaf_rt_rq_list, &rq->leaf_rt_rq_list);
16724 @@ -9534,18 +9858,24 @@ void __init sched_init(void)
16725 init_defrootdomain();
16728 - init_rt_bandwidth(&def_rt_bandwidth,
16729 - global_rt_period(), global_rt_runtime());
16730 + init_sched_bandwidth(&def_rt_bandwidth, global_rt_period(),
16731 + global_rt_runtime(), &sched_rt_period_timer);
16733 #ifdef CONFIG_RT_GROUP_SCHED
16734 - init_rt_bandwidth(&init_task_group.rt_bandwidth,
16735 - global_rt_period(), global_rt_runtime());
16736 + init_sched_bandwidth(&init_task_group.rt_bandwidth, global_rt_period(),
16737 + global_rt_runtime(), &sched_rt_period_timer);
16738 #ifdef CONFIG_USER_SCHED
16739 - init_rt_bandwidth(&root_task_group.rt_bandwidth,
16740 - global_rt_period(), RUNTIME_INF);
16741 + init_sched_bandwidth(&root_task_group.rt_bandwidth, global_rt_period(),
16742 + RUNTIME_INF, &sched_rt_period_timer);
16743 #endif /* CONFIG_USER_SCHED */
16744 #endif /* CONFIG_RT_GROUP_SCHED */
16746 +#ifdef CONFIG_FAIR_GROUP_SCHED
16747 + init_sched_bandwidth(&init_task_group.cfs_bandwidth,
16748 + global_cfs_period(), global_cfs_runtime(),
16749 + &sched_cfs_period_timer);
16752 #ifdef CONFIG_GROUP_SCHED
16753 list_add(&init_task_group.list, &task_groups);
16754 INIT_LIST_HEAD(&init_task_group.children);
16755 @@ -9572,6 +9902,8 @@ void __init sched_init(void)
16756 init_cfs_rq(&rq->cfs, rq);
16757 init_rt_rq(&rq->rt, rq);
16758 #ifdef CONFIG_FAIR_GROUP_SCHED
16759 + init_rq_bandwidth(&rq->cfs.rq_bandwidth,
16760 + init_task_group.cfs_bandwidth.runtime);
16761 init_task_group.shares = init_task_group_load;
16762 INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
16763 #ifdef CONFIG_CGROUP_SCHED
16764 @@ -9617,7 +9949,7 @@ void __init sched_init(void)
16766 #endif /* CONFIG_FAIR_GROUP_SCHED */
16768 - rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime;
16769 + rq->rt.rq_bandwidth.runtime = def_rt_bandwidth.runtime;
16770 #ifdef CONFIG_RT_GROUP_SCHED
16771 INIT_LIST_HEAD(&rq->leaf_rt_rq_list);
16772 #ifdef CONFIG_CGROUP_SCHED
16773 @@ -9851,6 +10183,7 @@ static void free_fair_sched_group(struct
16777 + destroy_sched_bandwidth(&tg->cfs_bandwidth);
16778 for_each_possible_cpu(i) {
16780 kfree(tg->cfs_rq[i]);
16781 @@ -9877,6 +10210,8 @@ int alloc_fair_sched_group(struct task_g
16785 + init_sched_bandwidth(&tg->cfs_bandwidth, global_cfs_period(),
16786 + global_cfs_runtime(), &sched_cfs_period_timer);
16787 tg->shares = NICE_0_LOAD;
16789 for_each_possible_cpu(i) {
16790 @@ -9938,7 +10273,7 @@ static void free_rt_sched_group(struct t
16794 - destroy_rt_bandwidth(&tg->rt_bandwidth);
16795 + destroy_sched_bandwidth(&tg->rt_bandwidth);
16797 for_each_possible_cpu(i) {
16799 @@ -9966,8 +10301,9 @@ int alloc_rt_sched_group(struct task_gro
16803 - init_rt_bandwidth(&tg->rt_bandwidth,
16804 - ktime_to_ns(def_rt_bandwidth.rt_period), 0);
16805 + init_sched_bandwidth(&tg->rt_bandwidth,
16806 + ktime_to_ns(def_rt_bandwidth.period), 0,
16807 + &sched_rt_period_timer);
16809 for_each_possible_cpu(i) {
16811 @@ -10266,8 +10602,8 @@ static int tg_schedulable(struct task_gr
16812 unsigned long total, sum = 0;
16813 u64 period, runtime;
16815 - period = ktime_to_ns(tg->rt_bandwidth.rt_period);
16816 - runtime = tg->rt_bandwidth.rt_runtime;
16817 + period = ktime_to_ns(tg->rt_bandwidth.period);
16818 + runtime = tg->rt_bandwidth.runtime;
16821 period = d->rt_period;
16822 @@ -10305,8 +10641,8 @@ static int tg_schedulable(struct task_gr
16823 * The sum of our children's runtime should not exceed our own.
16825 list_for_each_entry_rcu(child, &tg->children, siblings) {
16826 - period = ktime_to_ns(child->rt_bandwidth.rt_period);
16827 - runtime = child->rt_bandwidth.rt_runtime;
16828 + period = ktime_to_ns(child->rt_bandwidth.period);
16829 + runtime = child->rt_bandwidth.runtime;
16831 if (child == d->tg) {
16832 period = d->rt_period;
16833 @@ -10344,18 +10680,18 @@ static int tg_set_bandwidth(struct task_
16837 - raw_spin_lock_irq(&tg->rt_bandwidth.rt_runtime_lock);
16838 - tg->rt_bandwidth.rt_period = ns_to_ktime(rt_period);
16839 - tg->rt_bandwidth.rt_runtime = rt_runtime;
16840 + raw_spin_lock_irq(&tg->rt_bandwidth.runtime_lock);
16841 + tg->rt_bandwidth.period = ns_to_ktime(rt_period);
16842 + tg->rt_bandwidth.runtime = rt_runtime;
16844 for_each_possible_cpu(i) {
16845 struct rt_rq *rt_rq = tg->rt_rq[i];
16847 - raw_spin_lock(&rt_rq->rt_runtime_lock);
16848 - rt_rq->rt_runtime = rt_runtime;
16849 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
16850 + raw_spin_lock(&rt_rq->rq_bandwidth.runtime_lock);
16851 + rt_rq->rq_bandwidth.runtime = rt_runtime;
16852 + raw_spin_unlock(&rt_rq->rq_bandwidth.runtime_lock);
16854 - raw_spin_unlock_irq(&tg->rt_bandwidth.rt_runtime_lock);
16855 + raw_spin_unlock_irq(&tg->rt_bandwidth.runtime_lock);
16857 read_unlock(&tasklist_lock);
16858 mutex_unlock(&rt_constraints_mutex);
16859 @@ -10367,7 +10703,7 @@ int sched_group_set_rt_runtime(struct ta
16861 u64 rt_runtime, rt_period;
16863 - rt_period = ktime_to_ns(tg->rt_bandwidth.rt_period);
16864 + rt_period = ktime_to_ns(tg->rt_bandwidth.period);
16865 rt_runtime = (u64)rt_runtime_us * NSEC_PER_USEC;
16866 if (rt_runtime_us < 0)
16867 rt_runtime = RUNTIME_INF;
16868 @@ -10379,10 +10715,10 @@ long sched_group_rt_runtime(struct task_
16872 - if (tg->rt_bandwidth.rt_runtime == RUNTIME_INF)
16873 + if (tg->rt_bandwidth.runtime == RUNTIME_INF)
16876 - rt_runtime_us = tg->rt_bandwidth.rt_runtime;
16877 + rt_runtime_us = tg->rt_bandwidth.runtime;
16878 do_div(rt_runtime_us, NSEC_PER_USEC);
16879 return rt_runtime_us;
16881 @@ -10392,7 +10728,7 @@ int sched_group_set_rt_period(struct tas
16882 u64 rt_runtime, rt_period;
16884 rt_period = (u64)rt_period_us * NSEC_PER_USEC;
16885 - rt_runtime = tg->rt_bandwidth.rt_runtime;
16886 + rt_runtime = tg->rt_bandwidth.runtime;
16888 if (rt_period == 0)
16890 @@ -10404,7 +10740,7 @@ long sched_group_rt_period(struct task_g
16894 - rt_period_us = ktime_to_ns(tg->rt_bandwidth.rt_period);
16895 + rt_period_us = ktime_to_ns(tg->rt_bandwidth.period);
16896 do_div(rt_period_us, NSEC_PER_USEC);
16897 return rt_period_us;
16899 @@ -10438,7 +10774,7 @@ static int sched_rt_global_constraints(v
16900 int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk)
16902 /* Don't accept realtime tasks when there is no way for them to run */
16903 - if (rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0)
16904 + if (rt_task(tsk) && tg->rt_bandwidth.runtime == 0)
16908 @@ -10460,15 +10796,15 @@ static int sched_rt_global_constraints(v
16909 if (sysctl_sched_rt_runtime == 0)
16912 - raw_spin_lock_irqsave(&def_rt_bandwidth.rt_runtime_lock, flags);
16913 + raw_spin_lock_irqsave(&def_rt_bandwidth.runtime_lock, flags);
16914 for_each_possible_cpu(i) {
16915 struct rt_rq *rt_rq = &cpu_rq(i)->rt;
16917 - raw_spin_lock(&rt_rq->rt_runtime_lock);
16918 - rt_rq->rt_runtime = global_rt_runtime();
16919 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
16920 + raw_spin_lock(&rt_rq->rq_bandwidth.runtime_lock);
16921 + rt_rq->rq_bandwidth.runtime = global_rt_runtime();
16922 + raw_spin_unlock(&rt_rq->rq_bandwidth.runtime_lock);
16924 - raw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);
16925 + raw_spin_unlock_irqrestore(&def_rt_bandwidth.runtime_lock, flags);
16929 @@ -10494,8 +10830,8 @@ int sched_rt_handler(struct ctl_table *t
16930 sysctl_sched_rt_period = old_period;
16931 sysctl_sched_rt_runtime = old_runtime;
16933 - def_rt_bandwidth.rt_runtime = global_rt_runtime();
16934 - def_rt_bandwidth.rt_period =
16935 + def_rt_bandwidth.runtime = global_rt_runtime();
16936 + def_rt_bandwidth.period =
16937 ns_to_ktime(global_rt_period());
16940 @@ -10604,6 +10940,102 @@ static u64 cpu_shares_read_u64(struct cg
16942 return (u64) tg->shares;
16945 +#ifdef CONFIG_CFS_HARD_LIMITS
16947 +static int tg_set_cfs_bandwidth(struct task_group *tg,
16948 + u64 cfs_period, u64 cfs_runtime)
16952 + if (tg == &init_task_group)
16955 + raw_spin_lock_irq(&tg->cfs_bandwidth.runtime_lock);
16956 + tg->cfs_bandwidth.period = ns_to_ktime(cfs_period);
16957 + tg->cfs_bandwidth.runtime = cfs_runtime;
16959 + for_each_possible_cpu(i) {
16960 + struct cfs_rq *cfs_rq = tg->cfs_rq[i];
16962 + raw_spin_lock(&cfs_rq->rq_bandwidth.runtime_lock);
16963 + cfs_rq->rq_bandwidth.runtime = cfs_runtime;
16964 + raw_spin_unlock(&cfs_rq->rq_bandwidth.runtime_lock);
16967 + raw_spin_unlock_irq(&tg->cfs_bandwidth.runtime_lock);
16971 +int tg_set_cfs_runtime(struct task_group *tg, long cfs_runtime_us)
16973 + u64 cfs_runtime, cfs_period;
16975 + cfs_period = ktime_to_ns(tg->cfs_bandwidth.period);
16976 + cfs_runtime = (u64)cfs_runtime_us * NSEC_PER_USEC;
16977 + if (cfs_runtime_us < 0)
16978 + cfs_runtime = RUNTIME_INF;
16980 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
16983 +long tg_get_cfs_runtime(struct task_group *tg)
16985 + u64 cfs_runtime_us;
16987 + if (tg->cfs_bandwidth.runtime == RUNTIME_INF)
16990 + cfs_runtime_us = tg->cfs_bandwidth.runtime;
16991 + do_div(cfs_runtime_us, NSEC_PER_USEC);
16992 + return cfs_runtime_us;
16995 +int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
16997 + u64 cfs_runtime, cfs_period;
16999 + cfs_period = (u64)cfs_period_us * NSEC_PER_USEC;
17000 + cfs_runtime = tg->cfs_bandwidth.runtime;
17002 + if (cfs_period == 0)
17005 + return tg_set_cfs_bandwidth(tg, cfs_period, cfs_runtime);
17008 +long tg_get_cfs_period(struct task_group *tg)
17010 + u64 cfs_period_us;
17012 + cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.period);
17013 + do_div(cfs_period_us, NSEC_PER_USEC);
17014 + return cfs_period_us;
17017 +static s64 cpu_cfs_runtime_read_s64(struct cgroup *cgrp, struct cftype *cft)
17019 + return tg_get_cfs_runtime(cgroup_tg(cgrp));
17022 +static int cpu_cfs_runtime_write_s64(struct cgroup *cgrp, struct cftype *cftype,
17023 + s64 cfs_runtime_us)
17025 + return tg_set_cfs_runtime(cgroup_tg(cgrp), cfs_runtime_us);
17028 +static u64 cpu_cfs_period_read_u64(struct cgroup *cgrp, struct cftype *cft)
17030 + return tg_get_cfs_period(cgroup_tg(cgrp));
17033 +static int cpu_cfs_period_write_u64(struct cgroup *cgrp, struct cftype *cftype,
17034 + u64 cfs_period_us)
17036 + return tg_set_cfs_period(cgroup_tg(cgrp), cfs_period_us);
17039 +#endif /* CONFIG_CFS_HARD_LIMITS */
17040 #endif /* CONFIG_FAIR_GROUP_SCHED */
17042 #ifdef CONFIG_RT_GROUP_SCHED
17043 @@ -10637,6 +11069,18 @@ static struct cftype cpu_files[] = {
17044 .read_u64 = cpu_shares_read_u64,
17045 .write_u64 = cpu_shares_write_u64,
17047 +#ifdef CONFIG_CFS_HARD_LIMITS
17049 + .name = "cfs_runtime_us",
17050 + .read_s64 = cpu_cfs_runtime_read_s64,
17051 + .write_s64 = cpu_cfs_runtime_write_s64,
17054 + .name = "cfs_period_us",
17055 + .read_u64 = cpu_cfs_period_read_u64,
17056 + .write_u64 = cpu_cfs_period_write_u64,
17058 +#endif /* CONFIG_CFS_HARD_LIMITS */
17060 #ifdef CONFIG_RT_GROUP_SCHED
17062 diff -NurpP --minimal linux-2.6.33/kernel/sched_debug.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sched_debug.c
17063 --- linux-2.6.33/kernel/sched_debug.c 2010-02-25 11:52:09.000000000 +0100
17064 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sched_debug.c 2010-02-25 18:09:39.000000000 +0100
17065 @@ -80,6 +80,11 @@ static void print_cfs_group_stats(struct
17069 +#ifdef CONFIG_CFS_HARD_LIMITS
17070 + PN(se->throttle_max);
17071 + PN(se->throttle_sum);
17072 + P(se->throttle_count);
17075 P(se->load.weight);
17077 @@ -214,6 +219,16 @@ void print_cfs_rq(struct seq_file *m, in
17079 SEQ_printf(m, " .%-30s: %lu\n", "shares", cfs_rq->shares);
17081 +#ifdef CONFIG_CFS_HARD_LIMITS
17082 + raw_spin_lock_irqsave(&rq->lock, flags);
17083 + SEQ_printf(m, " .%-30s: %d\n", "rq_bandwidth.throttled",
17084 + cfs_rq->rq_bandwidth.throttled);
17085 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "rq_bandwidth.time",
17086 + SPLIT_NS(cfs_rq->rq_bandwidth.time));
17087 + SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "rq_bandwidth.runtime",
17088 + SPLIT_NS(cfs_rq->rq_bandwidth.runtime));
17089 + raw_spin_unlock_irqrestore(&rq->lock, flags);
17090 +#endif /* CONFIG_CFS_HARD_LIMITS */
17091 print_cfs_group_stats(m, cpu, cfs_rq->tg);
17094 @@ -238,9 +253,9 @@ void print_rt_rq(struct seq_file *m, int
17095 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x))
17101 + P(rq_bandwidth.throttled);
17102 + PN(rq_bandwidth.time);
17103 + PN(rq_bandwidth.runtime);
17107 @@ -320,7 +335,7 @@ static int sched_debug_show(struct seq_f
17108 u64 now = ktime_to_ns(ktime_get());
17111 - SEQ_printf(m, "Sched Debug Version: v0.09, %s %.*s\n",
17112 + SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n",
17113 init_utsname()->release,
17114 (int)strcspn(init_utsname()->version, " "),
17115 init_utsname()->version);
17116 diff -NurpP --minimal linux-2.6.33/kernel/sched_fair.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sched_fair.c
17117 --- linux-2.6.33/kernel/sched_fair.c 2010-02-25 11:52:09.000000000 +0100
17118 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sched_fair.c 2010-02-25 16:24:45.000000000 +0100
17119 @@ -205,7 +205,205 @@ find_matching_se(struct sched_entity **s
17123 -#else /* !CONFIG_FAIR_GROUP_SCHED */
17124 +static inline struct sched_bandwidth *sched_cfs_bandwidth(struct cfs_rq *cfs_rq)
17126 + return &cfs_rq->tg->cfs_bandwidth;
17129 +static inline void start_cfs_bandwidth(struct cfs_rq *cfs_rq)
17132 + start_sched_bandwidth(sched_cfs_bandwidth(cfs_rq), 0);
17136 +#ifdef CONFIG_CFS_HARD_LIMITS
17138 +static inline void update_stats_throttle_start(struct cfs_rq *cfs_rq,
17139 + struct sched_entity *se)
17141 + schedstat_set(se->throttle_start, rq_of(cfs_rq)->clock);
17144 +static inline void update_stats_throttle_end(struct cfs_rq *cfs_rq,
17145 + struct sched_entity *se)
17147 + schedstat_set(se->throttle_max, max(se->throttle_max,
17148 + rq_of(cfs_rq)->clock - se->throttle_start));
17149 + schedstat_set(se->throttle_count, se->throttle_count + 1);
17150 + schedstat_set(se->throttle_sum, se->throttle_sum +
17151 + rq_of(cfs_rq)->clock - se->throttle_start);
17152 + schedstat_set(se->throttle_start, 0);
17155 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
17157 + return cfs_rq->rq_bandwidth.throttled;
17162 + * Ensure this RQ takes back all the runtime it lend to its neighbours.
17164 +void disable_runtime_cfs(struct rq *rq)
17166 + struct cfs_rq *cfs_rq;
17168 + if (unlikely(!scheduler_running))
17171 + for_each_leaf_cfs_rq(rq, cfs_rq) {
17172 + struct sched_bandwidth *sched_b = sched_cfs_bandwidth(cfs_rq);
17173 + __disable_runtime(rq, sched_b, &cfs_rq->rq_bandwidth, 0);
17177 +void enable_runtime_cfs(struct rq *rq)
17179 + struct cfs_rq *cfs_rq;
17181 + if (unlikely(!scheduler_running))
17185 + * Reset each runqueue's bandwidth settings
17187 + for_each_leaf_cfs_rq(rq, cfs_rq) {
17188 + struct sched_bandwidth *sched_b = sched_cfs_bandwidth(cfs_rq);
17189 + __enable_runtime(sched_b, &cfs_rq->rq_bandwidth);
17193 +#endif /* CONFIG_SMP */
17196 + * Check if group entity exceeded its runtime. If so, mark the cfs_rq as
17197 + * throttled mark the current task for reschedling.
17199 +static void sched_cfs_runtime_exceeded(struct sched_entity *se,
17200 + struct task_struct *tsk_curr, unsigned long delta_exec)
17202 + struct cfs_rq *cfs_rq;
17204 + cfs_rq = group_cfs_rq(se);
17206 + if (cfs_rq->rq_bandwidth.runtime == RUNTIME_INF)
17209 + cfs_rq->rq_bandwidth.time += delta_exec;
17211 + if (cfs_rq_throttled(cfs_rq))
17214 + if (cfs_rq->rq_bandwidth.time > cfs_rq->rq_bandwidth.runtime)
17215 + balance_runtime(&cfs_rq->rq_bandwidth,
17216 + sched_cfs_bandwidth(cfs_rq), 0);
17218 + if (cfs_rq->rq_bandwidth.time > cfs_rq->rq_bandwidth.runtime) {
17219 + cfs_rq->rq_bandwidth.throttled = 1;
17220 + update_stats_throttle_start(cfs_rq, se);
17221 + resched_task(tsk_curr);
17225 +static inline void update_curr_group(struct sched_entity *curr,
17226 + unsigned long delta_exec, struct task_struct *tsk_curr)
17228 + sched_cfs_runtime_exceeded(curr, tsk_curr, delta_exec);
17231 +static void enqueue_entity(struct cfs_rq *cfs_rq,
17232 + struct sched_entity *se, int wakeup);
17234 +static void enqueue_throttled_entity(struct rq *rq, struct sched_entity *se)
17236 + for_each_sched_entity(se) {
17237 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
17239 + if (se->on_rq || cfs_rq_throttled(gcfs_rq) ||
17240 + !gcfs_rq->nr_running)
17242 + enqueue_entity(cfs_rq_of(se), se, 0);
17247 + * Refresh runtimes of all cfs_rqs in this group, i,e.,
17248 + * refresh runtimes of the representative cfs_rq of this
17249 + * tg on all cpus. Enqueue any throttled entity back.
17251 +static int do_sched_cfs_period_timer(struct sched_bandwidth *cfs_b, int overrun)
17254 + const struct cpumask *span;
17256 + if (cfs_b->runtime == RUNTIME_INF)
17259 + span = sched_bw_period_mask();
17260 + for_each_cpu(i, span) {
17262 + struct rq *rq = cpu_rq(i);
17263 + struct cfs_rq *cfs_rq = sched_cfs_period_cfs_rq(cfs_b, i);
17264 + struct sched_entity *se = cfs_rq->tg->se[i];
17266 + raw_spin_lock(&rq->lock);
17267 + if (cfs_rq->rq_bandwidth.time) {
17270 + raw_spin_lock(&cfs_rq->rq_bandwidth.runtime_lock);
17271 + if (cfs_rq_throttled(cfs_rq))
17272 + balance_runtime(&cfs_rq->rq_bandwidth,
17273 + sched_cfs_bandwidth(cfs_rq), 0);
17274 + runtime = cfs_rq->rq_bandwidth.runtime;
17275 + cfs_rq->rq_bandwidth.time -= min(cfs_rq->rq_bandwidth.time, overrun*runtime);
17276 + if (cfs_rq_throttled(cfs_rq) &&
17277 + cfs_rq->rq_bandwidth.time < runtime) {
17278 + cfs_rq->rq_bandwidth.throttled = 0;
17279 + update_rq_clock(rq);
17280 + update_stats_throttle_end(cfs_rq, se);
17283 + if (cfs_rq->rq_bandwidth.time || cfs_rq->nr_running)
17285 + raw_spin_unlock(&cfs_rq->rq_bandwidth.runtime_lock);
17286 + } else if (cfs_rq->nr_running)
17290 + enqueue_throttled_entity(rq, se);
17291 + raw_spin_unlock(&rq->lock);
17298 +static inline void update_curr_group(struct sched_entity *curr,
17299 + unsigned long delta_exec, struct task_struct *tsk_curr)
17304 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
17309 +static int do_sched_cfs_period_timer(struct sched_bandwidth *cfs_b, int overrun)
17314 +#endif /* CONFIG_CFS_HARD_LIMITS */
17316 +#else /* CONFIG_FAIR_GROUP_SCHED */
17318 +static inline void update_curr_group(struct sched_entity *curr,
17319 + unsigned long delta_exec, struct task_struct *tsk_curr)
17324 static inline struct task_struct *task_of(struct sched_entity *se)
17326 @@ -265,8 +463,22 @@ find_matching_se(struct sched_entity **s
17330 -#endif /* CONFIG_FAIR_GROUP_SCHED */
17331 +static inline void start_cfs_bandwidth(struct cfs_rq *cfs_rq)
17336 +static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq)
17341 +static int do_sched_cfs_period_timer(struct sched_bandwidth *cfs_b, int overrun)
17346 +#endif /* CONFIG_FAIR_GROUP_SCHED */
17348 /**************************************************************
17349 * Scheduling class tree data structure manipulation methods:
17350 @@ -360,6 +572,7 @@ static void __enqueue_entity(struct cfs_
17352 rb_link_node(&se->run_node, parent, link);
17353 rb_insert_color(&se->run_node, &cfs_rq->tasks_timeline);
17354 + start_cfs_bandwidth(cfs_rq);
17357 static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
17358 @@ -515,14 +728,25 @@ __update_curr(struct cfs_rq *cfs_rq, str
17359 update_min_vruntime(cfs_rq);
17362 -static void update_curr(struct cfs_rq *cfs_rq)
17363 +static void update_curr_task(struct sched_entity *curr,
17364 + unsigned long delta_exec)
17366 + struct task_struct *curtask = task_of(curr);
17368 + trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
17369 + cpuacct_charge(curtask, delta_exec);
17370 + account_group_exec_runtime(curtask, delta_exec);
17373 +static int update_curr_common(struct cfs_rq *cfs_rq, unsigned long *delta)
17375 struct sched_entity *curr = cfs_rq->curr;
17376 - u64 now = rq_of(cfs_rq)->clock;
17377 + struct rq *rq = rq_of(cfs_rq);
17378 + u64 now = rq->clock;
17379 unsigned long delta_exec;
17381 if (unlikely(!curr))
17386 * Get the amount of time the current task was running
17387 @@ -531,17 +755,31 @@ static void update_curr(struct cfs_rq *c
17389 delta_exec = (unsigned long)(now - curr->exec_start);
17394 __update_curr(cfs_rq, curr, delta_exec);
17395 curr->exec_start = now;
17396 + *delta = delta_exec;
17400 - if (entity_is_task(curr)) {
17401 - struct task_struct *curtask = task_of(curr);
17402 +static void update_curr(struct cfs_rq *cfs_rq)
17404 + struct sched_entity *curr = cfs_rq->curr;
17405 + struct rq *rq = rq_of(cfs_rq);
17406 + unsigned long delta_exec;
17407 + struct rq_bandwidth *rq_b;
17409 - trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
17410 - cpuacct_charge(curtask, delta_exec);
17411 - account_group_exec_runtime(curtask, delta_exec);
17412 + if (update_curr_common(cfs_rq, &delta_exec))
17415 + if (entity_is_task(curr))
17416 + update_curr_task(curr, delta_exec);
17418 + rq_b = &group_cfs_rq(curr)->rq_bandwidth;
17419 + raw_spin_lock(&rq_b->runtime_lock);
17420 + update_curr_group(curr, delta_exec, rq->curr);
17421 + raw_spin_unlock(&rq_b->runtime_lock);
17425 @@ -769,6 +1007,22 @@ place_entity(struct cfs_rq *cfs_rq, stru
17426 #define ENQUEUE_WAKEUP 1
17427 #define ENQUEUE_MIGRATE 2
17429 +static void enqueue_entity_common(struct cfs_rq *cfs_rq,
17430 + struct sched_entity *se, int flags)
17432 + account_entity_enqueue(cfs_rq, se);
17434 + if (flags & ENQUEUE_WAKEUP) {
17435 + place_entity(cfs_rq, se, 0);
17436 + enqueue_sleeper(cfs_rq, se);
17439 + update_stats_enqueue(cfs_rq, se);
17440 + check_spread(cfs_rq, se);
17441 + if (se != cfs_rq->curr)
17442 + __enqueue_entity(cfs_rq, se);
17446 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
17448 @@ -783,17 +1037,10 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17449 * Update run-time statistics of the 'current'.
17451 update_curr(cfs_rq);
17452 - account_entity_enqueue(cfs_rq, se);
17454 - if (flags & ENQUEUE_WAKEUP) {
17455 - place_entity(cfs_rq, se, 0);
17456 - enqueue_sleeper(cfs_rq, se);
17458 + enqueue_entity_common(cfs_rq, se, flags);
17460 - update_stats_enqueue(cfs_rq, se);
17461 - check_spread(cfs_rq, se);
17462 - if (se != cfs_rq->curr)
17463 - __enqueue_entity(cfs_rq, se);
17464 + if (entity_is_task(se))
17465 + vx_activate_task(task_of(se));
17468 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17469 @@ -837,6 +1084,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17471 if (se != cfs_rq->curr)
17472 __dequeue_entity(cfs_rq, se);
17473 + if (entity_is_task(se))
17474 + vx_deactivate_task(task_of(se));
17475 account_entity_dequeue(cfs_rq, se);
17476 update_min_vruntime(cfs_rq);
17478 @@ -941,6 +1190,28 @@ static struct sched_entity *pick_next_en
17483 + * Called from put_prev_entity()
17484 + * If a group entity (@se) is found to be throttled, it will not be put back
17485 + * on @cfs_rq, which is equivalent to dequeing it.
17487 +static int dequeue_throttled_entity(struct cfs_rq *cfs_rq,
17488 + struct sched_entity *se)
17490 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
17492 + if (entity_is_task(se))
17495 + if (!cfs_rq_throttled(gcfs_rq) && gcfs_rq->nr_running)
17498 + __clear_buddies(cfs_rq, se);
17499 + account_entity_dequeue(cfs_rq, se);
17500 + cfs_rq->curr = NULL;
17504 static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
17507 @@ -952,6 +1223,8 @@ static void put_prev_entity(struct cfs_r
17509 check_spread(cfs_rq, prev);
17511 + if (dequeue_throttled_entity(cfs_rq, prev))
17513 update_stats_wait_start(cfs_rq, prev);
17514 /* Put 'current' back into the tree. */
17515 __enqueue_entity(cfs_rq, prev);
17516 @@ -1048,10 +1321,26 @@ static inline void hrtick_update(struct
17520 +static int enqueue_group_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
17523 + struct cfs_rq *gcfs_rq = group_cfs_rq(se);
17526 + if (cfs_rq_throttled(gcfs_rq)) {
17530 + enqueue_entity(cfs_rq, se, flags);
17536 * The enqueue_task method is called before nr_running is
17537 * increased. Here we update the fair scheduling stats and
17538 * then put the task into the rbtree:
17539 + * Don't enqueue a throttled entity further into the hierarchy.
17541 static void enqueue_task_fair(struct rq *rq, struct task_struct *p, int wakeup)
17543 @@ -1067,11 +1356,15 @@ static void enqueue_task_fair(struct rq
17544 for_each_sched_entity(se) {
17548 cfs_rq = cfs_rq_of(se);
17549 - enqueue_entity(cfs_rq, se, flags);
17550 + if (entity_is_task(se))
17551 + enqueue_entity(cfs_rq, se, flags);
17553 + if (enqueue_group_entity(cfs_rq, se, flags))
17555 flags = ENQUEUE_WAKEUP;
17561 @@ -1091,6 +1384,13 @@ static void dequeue_task_fair(struct rq
17562 /* Don't dequeue parent if it has other entities besides us */
17563 if (cfs_rq->load.weight)
17567 + * If this cfs_rq is throttled, then it is already
17570 + if (cfs_rq_throttled(cfs_rq))
17575 @@ -1889,9 +2189,10 @@ load_balance_fair(struct rq *this_rq, in
17576 u64 rem_load, moved_load;
17580 + * empty group or throttled group
17582 - if (!busiest_cfs_rq->task_weight)
17583 + if (!busiest_cfs_rq->task_weight ||
17584 + cfs_rq_throttled(busiest_cfs_rq))
17587 rem_load = (u64)rem_load_move * busiest_weight;
17588 @@ -1940,6 +2241,12 @@ move_one_task_fair(struct rq *this_rq, i
17590 for_each_leaf_cfs_rq(busiest, busy_cfs_rq) {
17592 + * Don't move task from a throttled cfs_rq
17594 + if (cfs_rq_throttled(busy_cfs_rq))
17598 * pass busy_cfs_rq argument into
17599 * load_balance_[start|next]_fair iterators
17601 diff -NurpP --minimal linux-2.6.33/kernel/sched_rt.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sched_rt.c
17602 --- linux-2.6.33/kernel/sched_rt.c 2010-02-25 11:52:09.000000000 +0100
17603 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sched_rt.c 2010-02-25 16:19:21.000000000 +0100
17604 @@ -175,12 +175,12 @@ static inline u64 sched_rt_runtime(struc
17606 return RUNTIME_INF;
17608 - return rt_rq->rt_runtime;
17609 + return rt_rq->rq_bandwidth.runtime;
17612 static inline u64 sched_rt_period(struct rt_rq *rt_rq)
17614 - return ktime_to_ns(rt_rq->tg->rt_bandwidth.rt_period);
17615 + return ktime_to_ns(rt_rq->tg->rt_bandwidth.period);
17618 #define for_each_leaf_rt_rq(rt_rq, rq) \
17619 @@ -220,7 +220,7 @@ static void sched_rt_rq_dequeue(struct r
17621 static inline int rt_rq_throttled(struct rt_rq *rt_rq)
17623 - return rt_rq->rt_throttled && !rt_rq->rt_nr_boosted;
17624 + return rt_rq->rq_bandwidth.throttled && !rt_rq->rt_nr_boosted;
17627 static int rt_se_boosted(struct sched_rt_entity *rt_se)
17628 @@ -235,25 +235,7 @@ static int rt_se_boosted(struct sched_rt
17629 return p->prio != p->normal_prio;
17633 -static inline const struct cpumask *sched_rt_period_mask(void)
17635 - return cpu_rq(smp_processor_id())->rd->span;
17638 -static inline const struct cpumask *sched_rt_period_mask(void)
17640 - return cpu_online_mask;
17645 -struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
17647 - return container_of(rt_b, struct task_group, rt_bandwidth)->rt_rq[cpu];
17650 -static inline struct rt_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
17651 +static inline struct sched_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
17653 return &rt_rq->tg->rt_bandwidth;
17655 @@ -262,12 +244,12 @@ static inline struct rt_bandwidth *sched
17657 static inline u64 sched_rt_runtime(struct rt_rq *rt_rq)
17659 - return rt_rq->rt_runtime;
17660 + return rt_rq->rq_bandwidth.runtime;
17663 static inline u64 sched_rt_period(struct rt_rq *rt_rq)
17665 - return ktime_to_ns(def_rt_bandwidth.rt_period);
17666 + return ktime_to_ns(def_rt_bandwidth.period);
17669 #define for_each_leaf_rt_rq(rt_rq, rq) \
17670 @@ -293,21 +275,10 @@ static inline void sched_rt_rq_dequeue(s
17672 static inline int rt_rq_throttled(struct rt_rq *rt_rq)
17674 - return rt_rq->rt_throttled;
17677 -static inline const struct cpumask *sched_rt_period_mask(void)
17679 - return cpu_online_mask;
17683 -struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
17685 - return &cpu_rq(cpu)->rt;
17686 + return rt_rq->rq_bandwidth.throttled;
17689 -static inline struct rt_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
17690 +static inline struct sched_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
17692 return &def_rt_bandwidth;
17694 @@ -315,151 +286,24 @@ static inline struct rt_bandwidth *sched
17695 #endif /* CONFIG_RT_GROUP_SCHED */
17699 - * We ran out of runtime, see if we can borrow some from our neighbours.
17701 -static int do_balance_runtime(struct rt_rq *rt_rq)
17703 - struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
17704 - struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
17705 - int i, weight, more = 0;
17708 - weight = cpumask_weight(rd->span);
17710 - raw_spin_lock(&rt_b->rt_runtime_lock);
17711 - rt_period = ktime_to_ns(rt_b->rt_period);
17712 - for_each_cpu(i, rd->span) {
17713 - struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i);
17716 - if (iter == rt_rq)
17719 - raw_spin_lock(&iter->rt_runtime_lock);
17721 - * Either all rqs have inf runtime and there's nothing to steal
17722 - * or __disable_runtime() below sets a specific rq to inf to
17723 - * indicate its been disabled and disalow stealing.
17725 - if (iter->rt_runtime == RUNTIME_INF)
17729 - * From runqueues with spare time, take 1/n part of their
17730 - * spare time, but no more than our period.
17732 - diff = iter->rt_runtime - iter->rt_time;
17734 - diff = div_u64((u64)diff, weight);
17735 - if (rt_rq->rt_runtime + diff > rt_period)
17736 - diff = rt_period - rt_rq->rt_runtime;
17737 - iter->rt_runtime -= diff;
17738 - rt_rq->rt_runtime += diff;
17740 - if (rt_rq->rt_runtime == rt_period) {
17741 - raw_spin_unlock(&iter->rt_runtime_lock);
17746 - raw_spin_unlock(&iter->rt_runtime_lock);
17748 - raw_spin_unlock(&rt_b->rt_runtime_lock);
17754 * Ensure this RQ takes back all the runtime it lend to its neighbours.
17756 -static void __disable_runtime(struct rq *rq)
17757 +void disable_runtime_rt(struct rq *rq)
17759 - struct root_domain *rd = rq->rd;
17760 struct rt_rq *rt_rq;
17762 if (unlikely(!scheduler_running))
17765 for_each_leaf_rt_rq(rt_rq, rq) {
17766 - struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
17770 - raw_spin_lock(&rt_b->rt_runtime_lock);
17771 - raw_spin_lock(&rt_rq->rt_runtime_lock);
17773 - * Either we're all inf and nobody needs to borrow, or we're
17774 - * already disabled and thus have nothing to do, or we have
17775 - * exactly the right amount of runtime to take out.
17777 - if (rt_rq->rt_runtime == RUNTIME_INF ||
17778 - rt_rq->rt_runtime == rt_b->rt_runtime)
17780 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
17783 - * Calculate the difference between what we started out with
17784 - * and what we current have, that's the amount of runtime
17785 - * we lend and now have to reclaim.
17787 - want = rt_b->rt_runtime - rt_rq->rt_runtime;
17790 - * Greedy reclaim, take back as much as we can.
17792 - for_each_cpu(i, rd->span) {
17793 - struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i);
17797 - * Can't reclaim from ourselves or disabled runqueues.
17799 - if (iter == rt_rq || iter->rt_runtime == RUNTIME_INF)
17802 - raw_spin_lock(&iter->rt_runtime_lock);
17804 - diff = min_t(s64, iter->rt_runtime, want);
17805 - iter->rt_runtime -= diff;
17808 - iter->rt_runtime -= want;
17811 - raw_spin_unlock(&iter->rt_runtime_lock);
17817 - raw_spin_lock(&rt_rq->rt_runtime_lock);
17819 - * We cannot be left wanting - that would mean some runtime
17820 - * leaked out of the system.
17825 - * Disable all the borrow logic by pretending we have inf
17826 - * runtime - in which case borrowing doesn't make sense.
17828 - rt_rq->rt_runtime = RUNTIME_INF;
17829 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
17830 - raw_spin_unlock(&rt_b->rt_runtime_lock);
17831 + struct sched_bandwidth *sched_b = sched_rt_bandwidth(rt_rq);
17832 + __disable_runtime(rq, sched_b, &rt_rq->rq_bandwidth, 1);
17836 -static void disable_runtime(struct rq *rq)
17838 - unsigned long flags;
17840 - raw_spin_lock_irqsave(&rq->lock, flags);
17841 - __disable_runtime(rq);
17842 - raw_spin_unlock_irqrestore(&rq->lock, flags);
17845 -static void __enable_runtime(struct rq *rq)
17846 +void enable_runtime_rt(struct rq *rq)
17848 struct rt_rq *rt_rq;
17850 @@ -470,76 +314,44 @@ static void __enable_runtime(struct rq *
17851 * Reset each runqueue's bandwidth settings
17853 for_each_leaf_rt_rq(rt_rq, rq) {
17854 - struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
17856 - raw_spin_lock(&rt_b->rt_runtime_lock);
17857 - raw_spin_lock(&rt_rq->rt_runtime_lock);
17858 - rt_rq->rt_runtime = rt_b->rt_runtime;
17859 - rt_rq->rt_time = 0;
17860 - rt_rq->rt_throttled = 0;
17861 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
17862 - raw_spin_unlock(&rt_b->rt_runtime_lock);
17863 + struct sched_bandwidth *sched_b = sched_rt_bandwidth(rt_rq);
17864 + __enable_runtime(sched_b, &rt_rq->rq_bandwidth);
17868 -static void enable_runtime(struct rq *rq)
17870 - unsigned long flags;
17872 - raw_spin_lock_irqsave(&rq->lock, flags);
17873 - __enable_runtime(rq);
17874 - raw_spin_unlock_irqrestore(&rq->lock, flags);
17877 -static int balance_runtime(struct rt_rq *rt_rq)
17881 - if (rt_rq->rt_time > rt_rq->rt_runtime) {
17882 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
17883 - more = do_balance_runtime(rt_rq);
17884 - raw_spin_lock(&rt_rq->rt_runtime_lock);
17889 -#else /* !CONFIG_SMP */
17890 -static inline int balance_runtime(struct rt_rq *rt_rq)
17894 -#endif /* CONFIG_SMP */
17897 -static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
17898 +static int do_sched_rt_period_timer(struct sched_bandwidth *rt_b, int overrun)
17901 const struct cpumask *span;
17903 - if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
17904 + if (!rt_bandwidth_enabled() || rt_b->runtime == RUNTIME_INF)
17907 - span = sched_rt_period_mask();
17908 + span = sched_bw_period_mask();
17909 for_each_cpu(i, span) {
17911 struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
17912 struct rq *rq = rq_of_rt_rq(rt_rq);
17914 raw_spin_lock(&rq->lock);
17915 - if (rt_rq->rt_time) {
17916 + if (rt_rq->rq_bandwidth.time) {
17919 - raw_spin_lock(&rt_rq->rt_runtime_lock);
17920 - if (rt_rq->rt_throttled)
17921 - balance_runtime(rt_rq);
17922 - runtime = rt_rq->rt_runtime;
17923 - rt_rq->rt_time -= min(rt_rq->rt_time, overrun*runtime);
17924 - if (rt_rq->rt_throttled && rt_rq->rt_time < runtime) {
17925 - rt_rq->rt_throttled = 0;
17926 + raw_spin_lock(&rt_rq->rq_bandwidth.runtime_lock);
17927 + if (rt_rq->rq_bandwidth.throttled)
17928 + balance_runtime(&rt_rq->rq_bandwidth,
17929 + sched_rt_bandwidth(rt_rq), 1);
17930 + runtime = rt_rq->rq_bandwidth.runtime;
17931 + rt_rq->rq_bandwidth.time -= min(rt_rq->rq_bandwidth.time, overrun*runtime);
17932 + if (rt_rq->rq_bandwidth.throttled && rt_rq->rq_bandwidth.time < runtime) {
17933 + rt_rq->rq_bandwidth.throttled = 0;
17936 - if (rt_rq->rt_time || rt_rq->rt_nr_running)
17937 + if (rt_rq->rq_bandwidth.time || rt_rq->rt_nr_running)
17939 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
17940 + raw_spin_unlock(&rt_rq->rq_bandwidth.runtime_lock);
17941 } else if (rt_rq->rt_nr_running)
17944 @@ -567,19 +379,19 @@ static int sched_rt_runtime_exceeded(str
17946 u64 runtime = sched_rt_runtime(rt_rq);
17948 - if (rt_rq->rt_throttled)
17949 + if (rt_rq->rq_bandwidth.throttled)
17950 return rt_rq_throttled(rt_rq);
17952 if (sched_rt_runtime(rt_rq) >= sched_rt_period(rt_rq))
17955 - balance_runtime(rt_rq);
17956 + balance_runtime(&rt_rq->rq_bandwidth, sched_rt_bandwidth(rt_rq), 1);
17957 runtime = sched_rt_runtime(rt_rq);
17958 if (runtime == RUNTIME_INF)
17961 - if (rt_rq->rt_time > runtime) {
17962 - rt_rq->rt_throttled = 1;
17963 + if (rt_rq->rq_bandwidth.time > runtime) {
17964 + rt_rq->rq_bandwidth.throttled = 1;
17965 if (rt_rq_throttled(rt_rq)) {
17966 sched_rt_rq_dequeue(rt_rq);
17968 @@ -624,11 +436,11 @@ static void update_curr_rt(struct rq *rq
17969 rt_rq = rt_rq_of_se(rt_se);
17971 if (sched_rt_runtime(rt_rq) != RUNTIME_INF) {
17972 - raw_spin_lock(&rt_rq->rt_runtime_lock);
17973 - rt_rq->rt_time += delta_exec;
17974 + raw_spin_lock(&rt_rq->rq_bandwidth.runtime_lock);
17975 + rt_rq->rq_bandwidth.time += delta_exec;
17976 if (sched_rt_runtime_exceeded(rt_rq))
17977 resched_task(curr);
17978 - raw_spin_unlock(&rt_rq->rt_runtime_lock);
17979 + raw_spin_unlock(&rt_rq->rq_bandwidth.runtime_lock);
17983 @@ -753,7 +565,7 @@ inc_rt_group(struct sched_rt_entity *rt_
17984 rt_rq->rt_nr_boosted++;
17987 - start_rt_bandwidth(&rt_rq->tg->rt_bandwidth);
17988 + start_sched_bandwidth(&rt_rq->tg->rt_bandwidth, 1);
17992 @@ -770,7 +582,7 @@ dec_rt_group(struct sched_rt_entity *rt_
17994 inc_rt_group(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
17996 - start_rt_bandwidth(&def_rt_bandwidth);
17997 + start_sched_bandwidth(&def_rt_bandwidth, 1);
18001 @@ -1551,7 +1363,7 @@ static void rq_online_rt(struct rq *rq)
18002 if (rq->rt.overloaded)
18003 rt_set_overload(rq);
18005 - __enable_runtime(rq);
18006 + enable_runtime_rt(rq);
18008 cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio.curr);
18010 @@ -1562,7 +1374,7 @@ static void rq_offline_rt(struct rq *rq)
18011 if (rq->rt.overloaded)
18012 rt_clear_overload(rq);
18014 - __disable_runtime(rq);
18015 + disable_runtime_rt(rq);
18017 cpupri_set(&rq->rd->cpupri, rq->cpu, CPUPRI_INVALID);
18019 diff -NurpP --minimal linux-2.6.33/kernel/signal.c linux-2.6.33-vs2.3.0.36.30.1/kernel/signal.c
18020 --- linux-2.6.33/kernel/signal.c 2010-02-25 11:52:09.000000000 +0100
18021 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/signal.c 2010-02-25 13:10:38.000000000 +0100
18023 #include <linux/freezer.h>
18024 #include <linux/pid_namespace.h>
18025 #include <linux/nsproxy.h>
18026 +#include <linux/vs_context.h>
18027 +#include <linux/vs_pid.h>
18028 #define CREATE_TRACE_POINTS
18029 #include <trace/events/signal.h>
18031 @@ -629,9 +631,18 @@ static int check_kill_permission(int sig
18035 + vxdprintk(VXD_CBIT(misc, 7),
18036 + "check_kill_permission(%d,%p,%p[#%u,%u])",
18037 + sig, info, t, vx_task_xid(t), t->pid);
18039 if (!valid_signal(sig))
18042 +/* FIXME: needed? if so, why?
18043 + if ((info != SEND_SIG_NOINFO) &&
18044 + (is_si_special(info) || !si_fromuser(info)))
18047 if (!si_fromuser(info))
18050 @@ -659,6 +670,20 @@ static int check_kill_permission(int sig
18055 + if (t->pid == 1 && current->xid)
18059 + /* FIXME: we shouldn't return ESRCH ever, to avoid
18060 + loops, maybe ENOENT or EACCES? */
18061 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
18062 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
18063 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
18064 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
18068 return security_task_kill(t, info, sig, 0);
18071 @@ -1147,7 +1172,7 @@ int kill_pid_info(int sig, struct siginf
18074 p = pid_task(pid, PIDTYPE_PID);
18076 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
18077 error = group_send_sig_info(sig, info, p);
18078 if (unlikely(error == -ESRCH))
18080 @@ -1187,7 +1212,7 @@ int kill_pid_info_as_uid(int sig, struct
18083 p = pid_task(pid, PIDTYPE_PID);
18085 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
18089 @@ -1242,8 +1267,10 @@ static int kill_something_info(int sig,
18090 struct task_struct * p;
18092 for_each_process(p) {
18093 - if (task_pid_vnr(p) > 1 &&
18094 - !same_thread_group(p, current)) {
18095 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
18096 + task_pid_vnr(p) > 1 &&
18097 + !same_thread_group(p, current) &&
18098 + !vx_current_initpid(p->pid)) {
18099 int err = group_send_sig_info(sig, info, p);
18102 @@ -1910,6 +1937,11 @@ relock:
18103 !sig_kernel_only(signr))
18106 + /* virtual init is protected against user signals */
18107 + if ((info->si_code == SI_USER) &&
18108 + vx_current_initpid(current->pid))
18111 if (sig_kernel_stop(signr)) {
18113 * The default action is to stop all threads in
18114 diff -NurpP --minimal linux-2.6.33/kernel/softirq.c linux-2.6.33-vs2.3.0.36.30.1/kernel/softirq.c
18115 --- linux-2.6.33/kernel/softirq.c 2010-02-25 11:52:09.000000000 +0100
18116 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/softirq.c 2010-02-25 12:02:16.000000000 +0100
18118 #include <linux/ftrace.h>
18119 #include <linux/smp.h>
18120 #include <linux/tick.h>
18121 +#include <linux/vs_context.h>
18123 #define CREATE_TRACE_POINTS
18124 #include <trace/events/irq.h>
18125 diff -NurpP --minimal linux-2.6.33/kernel/sys.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sys.c
18126 --- linux-2.6.33/kernel/sys.c 2010-02-25 11:52:09.000000000 +0100
18127 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sys.c 2010-02-25 13:13:03.000000000 +0100
18129 #include <linux/syscalls.h>
18130 #include <linux/kprobes.h>
18131 #include <linux/user_namespace.h>
18132 +#include <linux/vs_pid.h>
18134 #include <asm/uaccess.h>
18135 #include <asm/io.h>
18136 @@ -129,7 +130,10 @@ static int set_one_prio(struct task_stru
18139 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
18141 + if (vx_flags(VXF_IGNEG_NICE, 0))
18147 no_nice = security_task_setnice(p, niceval);
18148 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
18150 pgrp = task_pgrp(current);
18151 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
18152 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
18154 error = set_one_prio(p, niceval, error);
18155 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
18157 @@ -242,6 +248,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
18159 pgrp = task_pgrp(current);
18160 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
18161 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
18163 niceval = 20 - task_nice(p);
18164 if (niceval > retval)
18166 @@ -355,6 +363,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
18168 static DEFINE_MUTEX(reboot_mutex);
18170 +long vs_reboot(unsigned int, void __user *);
18173 * Reboot system call: for obvious reasons only root may call it,
18174 * and even root needs to set up some magic numbers in the registers
18175 @@ -387,6 +397,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
18176 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
18177 cmd = LINUX_REBOOT_CMD_HALT;
18179 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
18180 + return vs_reboot(cmd, arg);
18182 mutex_lock(&reboot_mutex);
18184 case LINUX_REBOOT_CMD_RESTART:
18185 @@ -1136,7 +1149,7 @@ SYSCALL_DEFINE2(sethostname, char __user
18187 char tmp[__NEW_UTS_LEN];
18189 - if (!capable(CAP_SYS_ADMIN))
18190 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
18192 if (len < 0 || len > __NEW_UTS_LEN)
18194 @@ -1185,7 +1198,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
18196 char tmp[__NEW_UTS_LEN];
18198 - if (!capable(CAP_SYS_ADMIN))
18199 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
18201 if (len < 0 || len > __NEW_UTS_LEN)
18203 @@ -1254,7 +1267,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
18205 old_rlim = current->signal->rlim + resource;
18206 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
18207 - !capable(CAP_SYS_RESOURCE))
18208 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
18210 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
18212 diff -NurpP --minimal linux-2.6.33/kernel/sysctl_binary.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sysctl_binary.c
18213 --- linux-2.6.33/kernel/sysctl_binary.c 2010-02-25 11:52:09.000000000 +0100
18214 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sysctl_binary.c 2010-02-25 12:40:06.000000000 +0100
18215 @@ -71,6 +71,7 @@ static const struct bin_table bin_kern_t
18217 { CTL_INT, KERN_PANIC, "panic" },
18218 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
18219 + { CTL_STR, KERN_VSHELPER, "vshelper" },
18221 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
18222 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
18223 diff -NurpP --minimal linux-2.6.33/kernel/sysctl.c linux-2.6.33-vs2.3.0.36.30.1/kernel/sysctl.c
18224 --- linux-2.6.33/kernel/sysctl.c 2010-02-25 11:52:09.000000000 +0100
18225 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/sysctl.c 2010-02-25 14:43:48.000000000 +0100
18226 @@ -123,6 +123,7 @@ static int ngroups_max = NGROUPS_MAX;
18227 extern char modprobe_path[];
18228 extern int modules_disabled;
18230 +extern char vshelper_path[];
18231 #ifdef CONFIG_CHR_DEV_SG
18232 extern int sg_big_buff;
18234 @@ -553,6 +554,13 @@ static struct ctl_table kern_table[] = {
18235 .proc_handler = proc_dostring,
18239 + .procname = "vshelper",
18240 + .data = &vshelper_path,
18243 + .proc_handler = &proc_dostring,
18245 #ifdef CONFIG_CHR_DEV_SG
18247 .procname = "sg-big-buff",
18248 diff -NurpP --minimal linux-2.6.33/kernel/time.c linux-2.6.33-vs2.3.0.36.30.1/kernel/time.c
18249 --- linux-2.6.33/kernel/time.c 2010-02-25 11:52:09.000000000 +0100
18250 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/time.c 2010-02-25 12:02:16.000000000 +0100
18251 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
18252 SYSCALL_DEFINE1(time, time_t __user *, tloc)
18254 time_t i = get_seconds();
18255 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
18258 if (put_user(i,tloc))
18259 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
18263 - do_settimeofday(&tv);
18264 + vx_settimeofday(&tv);
18268 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
18270 if (likely(tv != NULL)) {
18271 struct timeval ktv;
18272 - do_gettimeofday(&ktv);
18273 + vx_gettimeofday(&ktv);
18274 if (copy_to_user(tv, &ktv, sizeof(ktv)))
18277 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
18278 /* SMP safe, again the code in arch/foo/time.c should
18279 * globally block out interrupts when it runs.
18281 - return do_settimeofday(tv);
18282 + return vx_settimeofday(tv);
18286 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
18290 - do_gettimeofday(&x);
18291 + vx_gettimeofday(&x);
18292 tv->tv_sec = x.tv_sec;
18293 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
18295 diff -NurpP --minimal linux-2.6.33/kernel/timer.c linux-2.6.33-vs2.3.0.36.30.1/kernel/timer.c
18296 --- linux-2.6.33/kernel/timer.c 2010-02-25 11:52:09.000000000 +0100
18297 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/timer.c 2010-02-25 12:02:16.000000000 +0100
18299 #include <linux/kallsyms.h>
18300 #include <linux/perf_event.h>
18301 #include <linux/sched.h>
18302 +#include <linux/vs_base.h>
18303 +#include <linux/vs_cvirt.h>
18304 +#include <linux/vs_pid.h>
18305 +#include <linux/vserver/sched.h>
18307 #include <asm/uaccess.h>
18308 #include <asm/unistd.h>
18309 @@ -1252,12 +1256,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
18316 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
18317 - * should be moved into arch/i386 instead?
18321 * sys_getpid - return the thread group id of the current process
18322 @@ -1286,10 +1284,23 @@ SYSCALL_DEFINE0(getppid)
18324 pid = task_tgid_vnr(current->real_parent);
18326 + return vx_map_pid(pid);
18333 + * The Alpha uses getxpid, getxuid, and getxgid instead.
18336 +asmlinkage long do_getxpid(long *ppid)
18338 + *ppid = sys_getppid();
18339 + return sys_getpid();
18342 +#else /* _alpha_ */
18344 SYSCALL_DEFINE0(getuid)
18346 /* Only we change this so SMP safe */
18347 diff -NurpP --minimal linux-2.6.33/kernel/user.c linux-2.6.33-vs2.3.0.36.30.1/kernel/user.c
18348 --- linux-2.6.33/kernel/user.c 2009-12-03 20:02:58.000000000 +0100
18349 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/user.c 2010-02-25 12:02:16.000000000 +0100
18350 @@ -251,10 +251,10 @@ static struct kobj_type uids_ktype = {
18352 * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
18354 -static int uids_user_create(struct user_struct *up)
18355 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
18357 struct kobject *kobj = &up->kobj;
18361 memset(kobj, 0, sizeof(struct kobject));
18362 if (up->user_ns != &init_user_ns)
18363 @@ -282,7 +282,7 @@ int __init uids_sysfs_init(void)
18367 - return uids_user_create(&root_user);
18368 + return uids_user_create(NULL, &root_user);
18371 /* delayed work function to remove sysfs directory for a user and free up
18372 @@ -353,7 +353,8 @@ static struct user_struct *uid_hash_find
18375 int uids_sysfs_init(void) { return 0; }
18376 -static inline int uids_user_create(struct user_struct *up) { return 0; }
18377 +static inline int uids_user_create(struct user_namespace *ns,
18378 + struct user_struct *up) { return 0; }
18379 static inline void uids_mutex_lock(void) { }
18380 static inline void uids_mutex_unlock(void) { }
18382 @@ -450,7 +451,7 @@ struct user_struct *alloc_uid(struct use
18384 new->user_ns = get_user_ns(ns);
18386 - if (uids_user_create(new))
18387 + if (uids_user_create(ns, new))
18388 goto out_destoy_sched;
18391 diff -NurpP --minimal linux-2.6.33/kernel/user_namespace.c linux-2.6.33-vs2.3.0.36.30.1/kernel/user_namespace.c
18392 --- linux-2.6.33/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
18393 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/user_namespace.c 2010-02-25 12:02:16.000000000 +0100
18395 #include <linux/slab.h>
18396 #include <linux/user_namespace.h>
18397 #include <linux/cred.h>
18398 +#include <linux/vserver/global.h>
18401 * Create a new user namespace, deriving the creator from the user in the
18402 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
18405 kref_init(&ns->kref);
18406 + atomic_inc(&vs_global_user_ns);
18408 for (n = 0; n < UIDHASH_SZ; ++n)
18409 INIT_HLIST_HEAD(ns->uidhash_table + n);
18410 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
18411 struct user_namespace *ns =
18412 container_of(kref, struct user_namespace, kref);
18414 + /* FIXME: maybe move into destroyer? */
18415 + atomic_dec(&vs_global_user_ns);
18416 INIT_WORK(&ns->destroyer, free_user_ns_work);
18417 schedule_work(&ns->destroyer);
18419 diff -NurpP --minimal linux-2.6.33/kernel/utsname.c linux-2.6.33-vs2.3.0.36.30.1/kernel/utsname.c
18420 --- linux-2.6.33/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
18421 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/utsname.c 2010-02-25 12:02:16.000000000 +0100
18422 @@ -14,14 +14,17 @@
18423 #include <linux/utsname.h>
18424 #include <linux/err.h>
18425 #include <linux/slab.h>
18426 +#include <linux/vserver/global.h>
18428 static struct uts_namespace *create_uts_ns(void)
18430 struct uts_namespace *uts_ns;
18432 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
18435 kref_init(&uts_ns->kref);
18436 + atomic_inc(&vs_global_uts_ns);
18441 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
18442 struct uts_namespace *ns;
18444 ns = container_of(kref, struct uts_namespace, kref);
18445 + atomic_dec(&vs_global_uts_ns);
18448 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cacct.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cacct.c
18449 --- linux-2.6.33/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
18450 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cacct.c 2010-02-25 12:02:16.000000000 +0100
18453 + * linux/kernel/vserver/cacct.c
18455 + * Virtual Server: Context Accounting
18457 + * Copyright (C) 2006-2007 Herbert Pötzl
18459 + * V0.01 added accounting stats
18463 +#include <linux/types.h>
18464 +#include <linux/vs_context.h>
18465 +#include <linux/vserver/cacct_cmd.h>
18466 +#include <linux/vserver/cacct_int.h>
18468 +#include <asm/errno.h>
18469 +#include <asm/uaccess.h>
18472 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
18474 + struct vcmd_sock_stat_v0 vc_data;
18477 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18480 + field = vc_data.field;
18481 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
18484 + for (j = 0; j < 3; j++) {
18485 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
18486 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
18489 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18494 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cacct_init.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cacct_init.h
18495 --- linux-2.6.33/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
18496 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cacct_init.h 2010-02-25 12:02:16.000000000 +0100
18500 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
18505 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
18506 + for (j = 0; j < 3; j++) {
18507 + atomic_long_set(&cacct->sock[i][j].count, 0);
18508 + atomic_long_set(&cacct->sock[i][j].total, 0);
18511 + for (i = 0; i < 8; i++)
18512 + atomic_set(&cacct->slab[i], 0);
18513 + for (i = 0; i < 5; i++)
18514 + for (j = 0; j < 4; j++)
18515 + atomic_set(&cacct->page[i][j], 0);
18518 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
18523 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cacct_proc.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cacct_proc.h
18524 --- linux-2.6.33/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
18525 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cacct_proc.h 2010-02-25 12:02:16.000000000 +0100
18527 +#ifndef _VX_CACCT_PROC_H
18528 +#define _VX_CACCT_PROC_H
18530 +#include <linux/vserver/cacct_int.h>
18533 +#define VX_SOCKA_TOP \
18534 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
18536 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
18538 + int i, j, length = 0;
18539 + static char *type[VXA_SOCK_SIZE] = {
18540 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
18543 + length += sprintf(buffer + length, VX_SOCKA_TOP);
18544 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
18545 + length += sprintf(buffer + length, "%s:", type[i]);
18546 + for (j = 0; j < 3; j++) {
18547 + length += sprintf(buffer + length,
18548 + "\t%10lu/%-10lu",
18549 + vx_sock_count(cacct, i, j),
18550 + vx_sock_total(cacct, i, j));
18552 + buffer[length++] = '\n';
18555 + length += sprintf(buffer + length, "\n");
18556 + length += sprintf(buffer + length,
18557 + "slab:\t %8u %8u %8u %8u\n",
18558 + atomic_read(&cacct->slab[1]),
18559 + atomic_read(&cacct->slab[4]),
18560 + atomic_read(&cacct->slab[0]),
18561 + atomic_read(&cacct->slab[2]));
18563 + length += sprintf(buffer + length, "\n");
18564 + for (i = 0; i < 5; i++) {
18565 + length += sprintf(buffer + length,
18566 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
18567 + atomic_read(&cacct->page[i][0]),
18568 + atomic_read(&cacct->page[i][1]),
18569 + atomic_read(&cacct->page[i][2]),
18570 + atomic_read(&cacct->page[i][3]),
18571 + atomic_read(&cacct->page[i][4]),
18572 + atomic_read(&cacct->page[i][5]),
18573 + atomic_read(&cacct->page[i][6]),
18574 + atomic_read(&cacct->page[i][7]));
18579 +#endif /* _VX_CACCT_PROC_H */
18580 diff -NurpP --minimal linux-2.6.33/kernel/vserver/context.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/context.c
18581 --- linux-2.6.33/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
18582 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/context.c 2010-02-25 12:02:16.000000000 +0100
18585 + * linux/kernel/vserver/context.c
18587 + * Virtual Server: Context Support
18589 + * Copyright (C) 2003-2007 Herbert Pötzl
18591 + * V0.01 context helper
18592 + * V0.02 vx_ctx_kill syscall command
18593 + * V0.03 replaced context_info calls
18594 + * V0.04 redesign of struct (de)alloc
18595 + * V0.05 rlimit basic implementation
18596 + * V0.06 task_xid and info commands
18597 + * V0.07 context flags and caps
18598 + * V0.08 switch to RCU based hash
18599 + * V0.09 revert to non RCU for now
18600 + * V0.10 and back to working RCU hash
18601 + * V0.11 and back to locking again
18602 + * V0.12 referenced context store
18603 + * V0.13 separate per cpu data
18604 + * V0.14 changed vcmds to vxi arg
18605 + * V0.15 added context stat
18606 + * V0.16 have __create claim() the vxi
18607 + * V0.17 removed older and legacy stuff
18611 +#include <linux/slab.h>
18612 +#include <linux/types.h>
18613 +#include <linux/security.h>
18614 +#include <linux/pid_namespace.h>
18616 +#include <linux/vserver/context.h>
18617 +#include <linux/vserver/network.h>
18618 +#include <linux/vserver/debug.h>
18619 +#include <linux/vserver/limit.h>
18620 +#include <linux/vserver/limit_int.h>
18621 +#include <linux/vserver/space.h>
18622 +#include <linux/init_task.h>
18623 +#include <linux/fs_struct.h>
18625 +#include <linux/vs_context.h>
18626 +#include <linux/vs_limit.h>
18627 +#include <linux/vs_pid.h>
18628 +#include <linux/vserver/context_cmd.h>
18630 +#include "cvirt_init.h"
18631 +#include "cacct_init.h"
18632 +#include "limit_init.h"
18633 +#include "sched_init.h"
18636 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
18637 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
18640 +/* now inactive context structures */
18642 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
18644 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
18647 +/* __alloc_vx_info()
18649 + * allocate an initialized vx_info struct
18650 + * doesn't make it visible (hash) */
18652 +static struct vx_info *__alloc_vx_info(xid_t xid)
18654 + struct vx_info *new = NULL;
18657 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
18659 + /* would this benefit from a slab cache? */
18660 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
18664 + memset(new, 0, sizeof(struct vx_info));
18666 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
18667 + if (!new->ptr_pc)
18670 + new->vx_id = xid;
18671 + INIT_HLIST_NODE(&new->vx_hlist);
18672 + atomic_set(&new->vx_usecnt, 0);
18673 + atomic_set(&new->vx_tasks, 0);
18674 + new->vx_parent = NULL;
18675 + new->vx_state = 0;
18676 + init_waitqueue_head(&new->vx_wait);
18678 + /* prepare reaper */
18679 + get_task_struct(init_pid_ns.child_reaper);
18680 + new->vx_reaper = init_pid_ns.child_reaper;
18681 + new->vx_badness_bias = 0;
18683 + /* rest of init goes here */
18684 + vx_info_init_limit(&new->limit);
18685 + vx_info_init_sched(&new->sched);
18686 + vx_info_init_cvirt(&new->cvirt);
18687 + vx_info_init_cacct(&new->cacct);
18689 + /* per cpu data structures */
18690 + for_each_possible_cpu(cpu) {
18691 + vx_info_init_sched_pc(
18692 + &vx_per_cpu(new, sched_pc, cpu), cpu);
18693 + vx_info_init_cvirt_pc(
18694 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
18697 + new->vx_flags = VXF_INIT_SET;
18698 + cap_set_init_eff(new->vx_bcaps);
18699 + new->vx_ccaps = 0;
18700 + new->vx_umask = 0;
18702 + new->reboot_cmd = 0;
18703 + new->exit_code = 0;
18705 + // preconfig fs entries
18706 + for (index = 0; index < VX_SPACES; index++) {
18707 + write_lock(&init_fs.lock);
18709 + write_unlock(&init_fs.lock);
18710 + new->vx_fs[index] = &init_fs;
18713 + vxdprintk(VXD_CBIT(xid, 0),
18714 + "alloc_vx_info(%d) = %p", xid, new);
18715 + vxh_alloc_vx_info(new);
18716 + atomic_inc(&vx_global_ctotal);
18725 +/* __dealloc_vx_info()
18727 + * final disposal of vx_info */
18729 +static void __dealloc_vx_info(struct vx_info *vxi)
18731 + struct vx_info_save vxis;
18734 + vxdprintk(VXD_CBIT(xid, 0),
18735 + "dealloc_vx_info(%p)", vxi);
18736 + vxh_dealloc_vx_info(vxi);
18738 +#ifdef CONFIG_VSERVER_WARN
18739 + enter_vx_info(vxi, &vxis);
18740 + vx_info_exit_limit(&vxi->limit);
18741 + vx_info_exit_sched(&vxi->sched);
18742 + vx_info_exit_cvirt(&vxi->cvirt);
18743 + vx_info_exit_cacct(&vxi->cacct);
18745 + for_each_possible_cpu(cpu) {
18746 + vx_info_exit_sched_pc(
18747 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18748 + vx_info_exit_cvirt_pc(
18749 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18751 + leave_vx_info(&vxis);
18755 + vxi->vx_state |= VXS_RELEASED;
18758 + free_percpu(vxi->ptr_pc);
18761 + atomic_dec(&vx_global_ctotal);
18764 +static void __shutdown_vx_info(struct vx_info *vxi)
18766 + struct nsproxy *nsproxy;
18767 + struct fs_struct *fs;
18772 + vxi->vx_state |= VXS_SHUTDOWN;
18773 + vs_state_change(vxi, VSC_SHUTDOWN);
18775 + for (index = 0; index < VX_SPACES; index++) {
18776 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
18778 + put_nsproxy(nsproxy);
18780 + fs = xchg(&vxi->vx_fs[index], NULL);
18781 + write_lock(&fs->lock);
18782 + kill = !--fs->users;
18783 + write_unlock(&fs->lock);
18785 + free_fs_struct(fs);
18789 +/* exported stuff */
18791 +void free_vx_info(struct vx_info *vxi)
18793 + unsigned long flags;
18796 + /* check for reference counts first */
18797 + BUG_ON(atomic_read(&vxi->vx_usecnt));
18798 + BUG_ON(atomic_read(&vxi->vx_tasks));
18800 + /* context must not be hashed */
18801 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18803 + /* context shutdown is mandatory */
18804 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18806 + /* nsproxy and fs check */
18807 + for (index = 0; index < VX_SPACES; index++) {
18808 + BUG_ON(vxi->vx_nsproxy[index]);
18809 + BUG_ON(vxi->vx_fs[index]);
18812 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18813 + hlist_del(&vxi->vx_hlist);
18814 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18816 + __dealloc_vx_info(vxi);
18820 +/* hash table for vx_info hash */
18822 +#define VX_HASH_SIZE 13
18824 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18825 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18827 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
18830 +static inline unsigned int __hashval(xid_t xid)
18832 + return (xid % VX_HASH_SIZE);
18837 +/* __hash_vx_info()
18839 + * add the vxi to the global hash table
18840 + * requires the hash_lock to be held */
18842 +static inline void __hash_vx_info(struct vx_info *vxi)
18844 + struct hlist_head *head;
18846 + vxd_assert_lock(&vx_info_hash_lock);
18847 + vxdprintk(VXD_CBIT(xid, 4),
18848 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18849 + vxh_hash_vx_info(vxi);
18851 + /* context must not be hashed */
18852 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18854 + vxi->vx_state |= VXS_HASHED;
18855 + head = &vx_info_hash[__hashval(vxi->vx_id)];
18856 + hlist_add_head(&vxi->vx_hlist, head);
18857 + atomic_inc(&vx_global_cactive);
18860 +/* __unhash_vx_info()
18862 + * remove the vxi from the global hash table
18863 + * requires the hash_lock to be held */
18865 +static inline void __unhash_vx_info(struct vx_info *vxi)
18867 + unsigned long flags;
18869 + vxd_assert_lock(&vx_info_hash_lock);
18870 + vxdprintk(VXD_CBIT(xid, 4),
18871 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18872 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18873 + vxh_unhash_vx_info(vxi);
18875 + /* context must be hashed */
18876 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18877 + /* but without tasks */
18878 + BUG_ON(atomic_read(&vxi->vx_tasks));
18880 + vxi->vx_state &= ~VXS_HASHED;
18881 + hlist_del_init(&vxi->vx_hlist);
18882 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18883 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18884 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18885 + atomic_dec(&vx_global_cactive);
18889 +/* __lookup_vx_info()
18891 + * requires the hash_lock to be held
18892 + * doesn't increment the vx_refcnt */
18894 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18896 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18897 + struct hlist_node *pos;
18898 + struct vx_info *vxi;
18900 + vxd_assert_lock(&vx_info_hash_lock);
18901 + hlist_for_each(pos, head) {
18902 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18904 + if (vxi->vx_id == xid)
18909 + vxdprintk(VXD_CBIT(xid, 0),
18910 + "__lookup_vx_info(#%u): %p[#%u]",
18911 + xid, vxi, vxi ? vxi->vx_id : 0);
18912 + vxh_lookup_vx_info(vxi, xid);
18917 +/* __create_vx_info()
18919 + * create the requested context
18920 + * get(), claim() and hash it */
18922 +static struct vx_info *__create_vx_info(int id)
18924 + struct vx_info *new, *vxi = NULL;
18926 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18928 + if (!(new = __alloc_vx_info(id)))
18929 + return ERR_PTR(-ENOMEM);
18931 + /* required to make dynamic xids unique */
18932 + spin_lock(&vx_info_hash_lock);
18934 + /* static context requested */
18935 + if ((vxi = __lookup_vx_info(id))) {
18936 + vxdprintk(VXD_CBIT(xid, 0),
18937 + "create_vx_info(%d) = %p (already there)", id, vxi);
18938 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18939 + vxi = ERR_PTR(-EBUSY);
18941 + vxi = ERR_PTR(-EEXIST);
18944 + /* new context */
18945 + vxdprintk(VXD_CBIT(xid, 0),
18946 + "create_vx_info(%d) = %p (new)", id, new);
18947 + claim_vx_info(new, NULL);
18948 + __hash_vx_info(get_vx_info(new));
18949 + vxi = new, new = NULL;
18952 + spin_unlock(&vx_info_hash_lock);
18953 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18955 + __dealloc_vx_info(new);
18960 +/* exported stuff */
18963 +void unhash_vx_info(struct vx_info *vxi)
18965 + __shutdown_vx_info(vxi);
18966 + spin_lock(&vx_info_hash_lock);
18967 + __unhash_vx_info(vxi);
18968 + spin_unlock(&vx_info_hash_lock);
18969 + __wakeup_vx_info(vxi);
18973 +/* lookup_vx_info()
18975 + * search for a vx_info and get() it
18976 + * negative id means current */
18978 +struct vx_info *lookup_vx_info(int id)
18980 + struct vx_info *vxi = NULL;
18983 + vxi = get_vx_info(current_vx_info());
18984 + } else if (id > 1) {
18985 + spin_lock(&vx_info_hash_lock);
18986 + vxi = get_vx_info(__lookup_vx_info(id));
18987 + spin_unlock(&vx_info_hash_lock);
18992 +/* xid_is_hashed()
18994 + * verify that xid is still hashed */
18996 +int xid_is_hashed(xid_t xid)
19000 + spin_lock(&vx_info_hash_lock);
19001 + hashed = (__lookup_vx_info(xid) != NULL);
19002 + spin_unlock(&vx_info_hash_lock);
19006 +#ifdef CONFIG_PROC_FS
19010 + * get a subset of hashed xids for proc
19011 + * assumes size is at least one */
19013 +int get_xid_list(int index, unsigned int *xids, int size)
19015 + int hindex, nr_xids = 0;
19017 + /* only show current and children */
19018 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
19021 + xids[nr_xids] = vx_current_xid();
19025 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
19026 + struct hlist_head *head = &vx_info_hash[hindex];
19027 + struct hlist_node *pos;
19029 + spin_lock(&vx_info_hash_lock);
19030 + hlist_for_each(pos, head) {
19031 + struct vx_info *vxi;
19036 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
19037 + xids[nr_xids] = vxi->vx_id;
19038 + if (++nr_xids >= size) {
19039 + spin_unlock(&vx_info_hash_lock);
19043 + /* keep the lock time short */
19044 + spin_unlock(&vx_info_hash_lock);
19051 +#ifdef CONFIG_VSERVER_DEBUG
19053 +void dump_vx_info_inactive(int level)
19055 + struct hlist_node *entry, *next;
19057 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
19058 + struct vx_info *vxi =
19059 + list_entry(entry, struct vx_info, vx_hlist);
19061 + dump_vx_info(vxi, level);
19068 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
19070 + struct user_struct *new_user, *old_user;
19075 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
19078 + new_user = alloc_uid(vxi->vx_id, p->uid);
19082 + old_user = p->user;
19083 + if (new_user != old_user) {
19084 + atomic_inc(&new_user->processes);
19085 + atomic_dec(&old_user->processes);
19086 + p->user = new_user;
19088 + free_uid(old_user);
19094 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
19096 + // p->cap_effective &= vxi->vx_cap_bset;
19097 + p->cap_effective =
19098 + cap_intersect(p->cap_effective, vxi->cap_bset);
19099 + // p->cap_inheritable &= vxi->vx_cap_bset;
19100 + p->cap_inheritable =
19101 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
19102 + // p->cap_permitted &= vxi->vx_cap_bset;
19103 + p->cap_permitted =
19104 + cap_intersect(p->cap_permitted, vxi->cap_bset);
19109 +#include <linux/file.h>
19110 +#include <linux/fdtable.h>
19112 +static int vx_openfd_task(struct task_struct *tsk)
19114 + struct files_struct *files = tsk->files;
19115 + struct fdtable *fdt;
19116 + const unsigned long *bptr;
19117 + int count, total;
19119 + /* no rcu_read_lock() because of spin_lock() */
19120 + spin_lock(&files->file_lock);
19121 + fdt = files_fdtable(files);
19122 + bptr = fdt->open_fds->fds_bits;
19123 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
19124 + for (total = 0; count > 0; count--) {
19126 + total += hweight_long(*bptr);
19129 + spin_unlock(&files->file_lock);
19134 +/* for *space compatibility */
19136 +asmlinkage long sys_unshare(unsigned long);
19139 + * migrate task to new context
19140 + * gets vxi, puts old_vxi on change
19141 + * optionally unshares namespaces (hack)
19144 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
19146 + struct vx_info *old_vxi;
19152 + vxdprintk(VXD_CBIT(xid, 5),
19153 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
19154 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
19156 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
19157 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
19160 + if (vx_info_state(vxi, VXS_SHUTDOWN))
19163 + old_vxi = task_get_vx_info(p);
19164 + if (old_vxi == vxi)
19167 +// if (!(ret = vx_migrate_user(p, vxi))) {
19172 + openfd = vx_openfd_task(p);
19175 + atomic_dec(&old_vxi->cvirt.nr_threads);
19176 + atomic_dec(&old_vxi->cvirt.nr_running);
19177 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
19178 + /* FIXME: what about the struct files here? */
19179 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
19180 + /* account for the executable */
19181 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
19183 + atomic_inc(&vxi->cvirt.nr_threads);
19184 + atomic_inc(&vxi->cvirt.nr_running);
19185 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
19186 + /* FIXME: what about the struct files here? */
19187 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
19188 + /* account for the executable */
19189 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
19192 + release_vx_info(old_vxi, p);
19193 + clr_vx_info(&p->vx_info);
19195 + claim_vx_info(vxi, p);
19196 + set_vx_info(&p->vx_info, vxi);
19197 + p->xid = vxi->vx_id;
19199 + vxdprintk(VXD_CBIT(xid, 5),
19200 + "moved task %p into vxi:%p[#%d]",
19201 + p, vxi, vxi->vx_id);
19203 + // vx_mask_cap_bset(vxi, p);
19206 + /* hack for *spaces to provide compatibility */
19208 + struct nsproxy *old_nsp, *new_nsp;
19210 + ret = unshare_nsproxy_namespaces(
19211 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
19216 + old_nsp = xchg(&p->nsproxy, new_nsp);
19217 + vx_set_space(vxi,
19218 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
19219 + put_nsproxy(old_nsp);
19223 + put_vx_info(old_vxi);
19227 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
19229 + struct task_struct *old_reaper;
19234 + vxdprintk(VXD_CBIT(xid, 6),
19235 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
19236 + vxi, vxi->vx_id, p, p->xid, p->pid);
19238 + old_reaper = vxi->vx_reaper;
19239 + if (old_reaper == p)
19242 + /* set new child reaper */
19243 + get_task_struct(p);
19244 + vxi->vx_reaper = p;
19245 + put_task_struct(old_reaper);
19249 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
19254 + vxdprintk(VXD_CBIT(xid, 6),
19255 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
19256 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
19258 + vxi->vx_flags &= ~VXF_STATE_INIT;
19259 + // vxi->vx_initpid = p->tgid;
19260 + vxi->vx_initpid = p->pid;
19264 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
19266 + vxdprintk(VXD_CBIT(xid, 6),
19267 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
19268 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
19270 + vxi->exit_code = code;
19271 + vxi->vx_initpid = 0;
19275 +void vx_set_persistent(struct vx_info *vxi)
19277 + vxdprintk(VXD_CBIT(xid, 6),
19278 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
19280 + get_vx_info(vxi);
19281 + claim_vx_info(vxi, NULL);
19284 +void vx_clear_persistent(struct vx_info *vxi)
19286 + vxdprintk(VXD_CBIT(xid, 6),
19287 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
19289 + release_vx_info(vxi, NULL);
19290 + put_vx_info(vxi);
19293 +void vx_update_persistent(struct vx_info *vxi)
19295 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
19296 + vx_set_persistent(vxi);
19298 + vx_clear_persistent(vxi);
19302 +/* task must be current or locked */
19304 +void exit_vx_info(struct task_struct *p, int code)
19306 + struct vx_info *vxi = p->vx_info;
19309 + atomic_dec(&vxi->cvirt.nr_threads);
19312 + vxi->exit_code = code;
19313 + release_vx_info(vxi, p);
19317 +void exit_vx_info_early(struct task_struct *p, int code)
19319 + struct vx_info *vxi = p->vx_info;
19322 + if (vxi->vx_initpid == p->pid)
19323 + vx_exit_init(vxi, p, code);
19324 + if (vxi->vx_reaper == p)
19325 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
19330 +/* vserver syscall commands below here */
19332 +/* taks xid and vx_info functions */
19334 +#include <asm/uaccess.h>
19337 +int vc_task_xid(uint32_t id)
19342 + struct task_struct *tsk;
19344 + read_lock(&tasklist_lock);
19345 + tsk = find_task_by_real_pid(id);
19346 + xid = (tsk) ? tsk->xid : -ESRCH;
19347 + read_unlock(&tasklist_lock);
19349 + xid = vx_current_xid();
19354 +int vc_vx_info(struct vx_info *vxi, void __user *data)
19356 + struct vcmd_vx_info_v0 vc_data;
19358 + vc_data.xid = vxi->vx_id;
19359 + vc_data.initpid = vxi->vx_initpid;
19361 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19367 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
19369 + struct vcmd_ctx_stat_v0 vc_data;
19371 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
19372 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
19374 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19380 +/* context functions */
19382 +int vc_ctx_create(uint32_t xid, void __user *data)
19384 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
19385 + struct vx_info *new_vxi;
19388 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
19391 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
19394 + new_vxi = __create_vx_info(xid);
19395 + if (IS_ERR(new_vxi))
19396 + return PTR_ERR(new_vxi);
19398 + /* initial flags */
19399 + new_vxi->vx_flags = vc_data.flagword;
19402 + if (vs_state_change(new_vxi, VSC_STARTUP))
19405 + ret = vx_migrate_task(current, new_vxi, (!data));
19409 + /* return context id on success */
19410 + ret = new_vxi->vx_id;
19412 + /* get a reference for persistent contexts */
19413 + if ((vc_data.flagword & VXF_PERSISTENT))
19414 + vx_set_persistent(new_vxi);
19416 + release_vx_info(new_vxi, NULL);
19417 + put_vx_info(new_vxi);
19422 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
19424 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
19427 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
19430 + ret = vx_migrate_task(current, vxi, 0);
19433 + if (vc_data.flagword & VXM_SET_INIT)
19434 + ret = vx_set_init(vxi, current);
19437 + if (vc_data.flagword & VXM_SET_REAPER)
19438 + ret = vx_set_reaper(vxi, current);
19443 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
19445 + struct vcmd_ctx_flags_v0 vc_data;
19447 + vc_data.flagword = vxi->vx_flags;
19449 + /* special STATE flag handling */
19450 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
19452 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19457 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
19459 + struct vcmd_ctx_flags_v0 vc_data;
19460 + uint64_t mask, trigger;
19462 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19465 + /* special STATE flag handling */
19466 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
19467 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
19469 + if (vxi == current_vx_info()) {
19470 + /* if (trigger & VXF_STATE_SETUP)
19471 + vx_mask_cap_bset(vxi, current); */
19472 + if (trigger & VXF_STATE_INIT) {
19475 + ret = vx_set_init(vxi, current);
19478 + ret = vx_set_reaper(vxi, current);
19484 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
19485 + vc_data.flagword, mask);
19486 + if (trigger & VXF_PERSISTENT)
19487 + vx_update_persistent(vxi);
19493 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
19495 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
19497 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
19501 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
19503 + kernel_cap_t c = __cap_empty_set;
19505 + c.cap[0] = v & 0xFFFFFFFF;
19506 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
19508 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
19513 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
19516 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
19518 + *ccaps = vxi->vx_ccaps;
19523 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
19525 + struct vcmd_ctx_caps_v1 vc_data;
19528 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
19531 + vc_data.cmask = ~0ULL;
19533 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19538 +static int do_set_caps(struct vx_info *vxi,
19539 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
19541 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
19544 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
19545 + bcaps, bmask, ccaps, cmask);
19547 + vxi->vx_bcaps = cap_t_from_caps(
19548 + vs_mask_flags(bcold, bcaps, bmask));
19549 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
19554 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
19556 + struct vcmd_ctx_caps_v1 vc_data;
19558 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19561 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
19564 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
19566 + struct vcmd_bcaps vc_data;
19569 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
19572 + vc_data.bmask = ~0ULL;
19574 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19579 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
19581 + struct vcmd_bcaps vc_data;
19583 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19586 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
19590 +int vc_get_umask(struct vx_info *vxi, void __user *data)
19592 + struct vcmd_umask vc_data;
19594 + vc_data.umask = vxi->vx_umask;
19595 + vc_data.mask = ~0ULL;
19597 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19602 +int vc_set_umask(struct vx_info *vxi, void __user *data)
19604 + struct vcmd_umask vc_data;
19606 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19609 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
19610 + vc_data.umask, vc_data.mask);
19615 +int vc_get_badness(struct vx_info *vxi, void __user *data)
19617 + struct vcmd_badness_v0 vc_data;
19619 + vc_data.bias = vxi->vx_badness_bias;
19621 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19626 +int vc_set_badness(struct vx_info *vxi, void __user *data)
19628 + struct vcmd_badness_v0 vc_data;
19630 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19633 + vxi->vx_badness_bias = vc_data.bias;
19637 +#include <linux/module.h>
19639 +EXPORT_SYMBOL_GPL(free_vx_info);
19641 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cvirt.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cvirt.c
19642 --- linux-2.6.33/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
19643 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cvirt.c 2010-02-25 12:02:16.000000000 +0100
19646 + * linux/kernel/vserver/cvirt.c
19648 + * Virtual Server: Context Virtualization
19650 + * Copyright (C) 2004-2007 Herbert Pötzl
19652 + * V0.01 broken out from limit.c
19653 + * V0.02 added utsname stuff
19654 + * V0.03 changed vcmds to vxi arg
19658 +#include <linux/types.h>
19659 +#include <linux/utsname.h>
19660 +#include <linux/vs_cvirt.h>
19661 +#include <linux/vserver/switch.h>
19662 +#include <linux/vserver/cvirt_cmd.h>
19664 +#include <asm/uaccess.h>
19667 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
19669 + struct vx_info *vxi = current_vx_info();
19671 + set_normalized_timespec(uptime,
19672 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
19673 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
19676 + set_normalized_timespec(idle,
19677 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
19678 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
19682 +uint64_t vx_idle_jiffies(void)
19684 + return init_task.utime + init_task.stime;
19689 +static inline uint32_t __update_loadavg(uint32_t load,
19690 + int wsize, int delta, int n)
19692 + unsigned long long calc, prev;
19694 + /* just set it to n */
19695 + if (unlikely(delta >= wsize))
19696 + return (n << FSHIFT);
19698 + calc = delta * n;
19700 + prev = (wsize - delta);
19703 + do_div(calc, wsize);
19708 +void vx_update_load(struct vx_info *vxi)
19710 + uint32_t now, last, delta;
19711 + unsigned int nr_running, nr_uninterruptible;
19712 + unsigned int total;
19713 + unsigned long flags;
19715 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19718 + last = vxi->cvirt.load_last;
19719 + delta = now - last;
19721 + if (delta < 5*HZ)
19724 + nr_running = atomic_read(&vxi->cvirt.nr_running);
19725 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19726 + total = nr_running + nr_uninterruptible;
19728 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19729 + 60*HZ, delta, total);
19730 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19731 + 5*60*HZ, delta, total);
19732 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19733 + 15*60*HZ, delta, total);
19735 + vxi->cvirt.load_last = now;
19737 + atomic_inc(&vxi->cvirt.load_updates);
19738 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19743 + * Commands to do_syslog:
19745 + * 0 -- Close the log. Currently a NOP.
19746 + * 1 -- Open the log. Currently a NOP.
19747 + * 2 -- Read from the log.
19748 + * 3 -- Read all messages remaining in the ring buffer.
19749 + * 4 -- Read and clear all messages remaining in the ring buffer
19750 + * 5 -- Clear ring buffer.
19751 + * 6 -- Disable printk's to console
19752 + * 7 -- Enable printk's to console
19753 + * 8 -- Set level of messages printed to console
19754 + * 9 -- Return number of unread characters in the log buffer
19755 + * 10 -- Return size of the log buffer
19757 +int vx_do_syslog(int type, char __user *buf, int len)
19760 + int do_clear = 0;
19761 + struct vx_info *vxi = current_vx_info();
19762 + struct _vx_syslog *log;
19766 + log = &vxi->cvirt.syslog;
19769 + case 0: /* Close log */
19770 + case 1: /* Open log */
19772 + case 2: /* Read from log */
19773 + error = wait_event_interruptible(log->log_wait,
19774 + (log->log_start - log->log_end));
19777 + spin_lock_irq(&log->logbuf_lock);
19778 + spin_unlock_irq(&log->logbuf_lock);
19780 + case 4: /* Read/clear last kernel messages */
19782 + /* fall through */
19783 + case 3: /* Read last kernel messages */
19786 + case 5: /* Clear ring buffer */
19789 + case 6: /* Disable logging to console */
19790 + case 7: /* Enable logging to console */
19791 + case 8: /* Set level of messages printed to console */
19794 + case 9: /* Number of chars in the log buffer */
19796 + case 10: /* Size of the log buffer */
19806 +/* virtual host info names */
19808 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19810 + struct nsproxy *nsproxy;
19811 + struct uts_namespace *uts;
19813 + if (id == VHIN_CONTEXT)
19814 + return vxi->vx_name;
19816 + nsproxy = vxi->vx_nsproxy[0];
19820 + uts = nsproxy->uts_ns;
19825 + case VHIN_SYSNAME:
19826 + return uts->name.sysname;
19827 + case VHIN_NODENAME:
19828 + return uts->name.nodename;
19829 + case VHIN_RELEASE:
19830 + return uts->name.release;
19831 + case VHIN_VERSION:
19832 + return uts->name.version;
19833 + case VHIN_MACHINE:
19834 + return uts->name.machine;
19835 + case VHIN_DOMAINNAME:
19836 + return uts->name.domainname;
19843 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19845 + struct vcmd_vhi_name_v0 vc_data;
19848 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19851 + name = vx_vhi_name(vxi, vc_data.field);
19855 + memcpy(name, vc_data.name, 65);
19859 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19861 + struct vcmd_vhi_name_v0 vc_data;
19864 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19867 + name = vx_vhi_name(vxi, vc_data.field);
19871 + memcpy(vc_data.name, name, 65);
19872 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19878 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19880 + struct vcmd_virt_stat_v0 vc_data;
19881 + struct _vx_cvirt *cvirt = &vxi->cvirt;
19882 + struct timespec uptime;
19884 + do_posix_clock_monotonic_gettime(&uptime);
19885 + set_normalized_timespec(&uptime,
19886 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19887 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19889 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
19890 + vc_data.uptime = timespec_to_ns(&uptime);
19891 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19892 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
19893 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19894 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19895 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19896 + vc_data.load[0] = cvirt->load[0];
19897 + vc_data.load[1] = cvirt->load[1];
19898 + vc_data.load[2] = cvirt->load[2];
19900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19906 +#ifdef CONFIG_VSERVER_VTIME
19908 +/* virtualized time base */
19910 +void vx_gettimeofday(struct timeval *tv)
19912 + struct vx_info *vxi;
19914 + do_gettimeofday(tv);
19915 + if (!vx_flags(VXF_VIRT_TIME, 0))
19918 + vxi = current_vx_info();
19919 + tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
19920 + tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
19922 + if (tv->tv_usec >= USEC_PER_SEC) {
19924 + tv->tv_usec -= USEC_PER_SEC;
19925 + } else if (tv->tv_usec < 0) {
19927 + tv->tv_usec += USEC_PER_SEC;
19931 +int vx_settimeofday(struct timespec *ts)
19933 + struct timeval tv;
19934 + struct vx_info *vxi;
19936 + if (!vx_flags(VXF_VIRT_TIME, 0))
19937 + return do_settimeofday(ts);
19939 + do_gettimeofday(&tv);
19940 + vxi = current_vx_info();
19941 + vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19942 + vxi->cvirt.bias_tv.tv_usec =
19943 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19949 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cvirt_init.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cvirt_init.h
19950 --- linux-2.6.33/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
19951 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cvirt_init.h 2010-02-25 12:02:16.000000000 +0100
19955 +extern uint64_t vx_idle_jiffies(void);
19957 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19959 + uint64_t idle_jiffies = vx_idle_jiffies();
19960 + uint64_t nsuptime;
19962 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19963 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19964 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19965 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19966 + cvirt->bias_tv.tv_sec = 0;
19967 + cvirt->bias_tv.tv_usec = 0;
19969 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19970 + atomic_set(&cvirt->nr_threads, 0);
19971 + atomic_set(&cvirt->nr_running, 0);
19972 + atomic_set(&cvirt->nr_uninterruptible, 0);
19973 + atomic_set(&cvirt->nr_onhold, 0);
19975 + spin_lock_init(&cvirt->load_lock);
19976 + cvirt->load_last = jiffies;
19977 + atomic_set(&cvirt->load_updates, 0);
19978 + cvirt->load[0] = 0;
19979 + cvirt->load[1] = 0;
19980 + cvirt->load[2] = 0;
19981 + atomic_set(&cvirt->total_forks, 0);
19983 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19984 + init_waitqueue_head(&cvirt->syslog.log_wait);
19985 + cvirt->syslog.log_start = 0;
19986 + cvirt->syslog.log_end = 0;
19987 + cvirt->syslog.con_start = 0;
19988 + cvirt->syslog.logged_chars = 0;
19992 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19994 + // cvirt_pc->cpustat = { 0 };
19997 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
20001 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
20002 + "!!! cvirt: %p[nr_threads] = %d on exit.",
20004 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
20005 + "!!! cvirt: %p[nr_running] = %d on exit.",
20007 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
20008 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
20010 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
20011 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
20017 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
20022 diff -NurpP --minimal linux-2.6.33/kernel/vserver/cvirt_proc.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cvirt_proc.h
20023 --- linux-2.6.33/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
20024 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/cvirt_proc.h 2010-02-25 12:02:16.000000000 +0100
20026 +#ifndef _VX_CVIRT_PROC_H
20027 +#define _VX_CVIRT_PROC_H
20029 +#include <linux/nsproxy.h>
20030 +#include <linux/mnt_namespace.h>
20031 +#include <linux/ipc_namespace.h>
20032 +#include <linux/utsname.h>
20033 +#include <linux/ipc.h>
20037 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
20039 + struct mnt_namespace *ns;
20040 + struct uts_namespace *uts;
20041 + struct ipc_namespace *ipc;
20042 + struct path path;
20043 + char *pstr, *root;
20049 + length += sprintf(buffer + length,
20050 + "NSProxy:\t%p [%p,%p,%p]\n",
20051 + nsproxy, nsproxy->mnt_ns,
20052 + nsproxy->uts_ns, nsproxy->ipc_ns);
20054 + ns = nsproxy->mnt_ns;
20058 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
20062 + path.mnt = ns->root;
20063 + path.dentry = ns->root->mnt_root;
20064 + root = d_path(&path, pstr, PATH_MAX - 2);
20065 + length += sprintf(buffer + length,
20066 + "Namespace:\t%p [#%u]\n"
20067 + "RootPath:\t%s\n",
20068 + ns, atomic_read(&ns->count),
20073 + uts = nsproxy->uts_ns;
20077 + length += sprintf(buffer + length,
20078 + "SysName:\t%.*s\n"
20079 + "NodeName:\t%.*s\n"
20080 + "Release:\t%.*s\n"
20081 + "Version:\t%.*s\n"
20082 + "Machine:\t%.*s\n"
20083 + "DomainName:\t%.*s\n",
20084 + __NEW_UTS_LEN, uts->name.sysname,
20085 + __NEW_UTS_LEN, uts->name.nodename,
20086 + __NEW_UTS_LEN, uts->name.release,
20087 + __NEW_UTS_LEN, uts->name.version,
20088 + __NEW_UTS_LEN, uts->name.machine,
20089 + __NEW_UTS_LEN, uts->name.domainname);
20092 + ipc = nsproxy->ipc_ns;
20096 + length += sprintf(buffer + length,
20097 + "SEMS:\t\t%d %d %d %d %d\n"
20098 + "MSG:\t\t%d %d %d\n"
20099 + "SHM:\t\t%lu %lu %d %d\n",
20100 + ipc->sem_ctls[0], ipc->sem_ctls[1],
20101 + ipc->sem_ctls[2], ipc->sem_ctls[3],
20103 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
20104 + (unsigned long)ipc->shm_ctlmax,
20105 + (unsigned long)ipc->shm_ctlall,
20106 + ipc->shm_ctlmni, ipc->shm_tot);
20113 +#include <linux/sched.h>
20115 +#define LOAD_INT(x) ((x) >> FSHIFT)
20116 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
20119 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
20124 + length += sprintf(buffer + length,
20125 + "BiasUptime:\t%lu.%02lu\n",
20126 + (unsigned long)cvirt->bias_uptime.tv_sec,
20127 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
20129 + a = cvirt->load[0] + (FIXED_1 / 200);
20130 + b = cvirt->load[1] + (FIXED_1 / 200);
20131 + c = cvirt->load[2] + (FIXED_1 / 200);
20132 + length += sprintf(buffer + length,
20133 + "nr_threads:\t%d\n"
20134 + "nr_running:\t%d\n"
20135 + "nr_unintr:\t%d\n"
20136 + "nr_onhold:\t%d\n"
20137 + "load_updates:\t%d\n"
20138 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
20139 + "total_forks:\t%d\n",
20140 + atomic_read(&cvirt->nr_threads),
20141 + atomic_read(&cvirt->nr_running),
20142 + atomic_read(&cvirt->nr_uninterruptible),
20143 + atomic_read(&cvirt->nr_onhold),
20144 + atomic_read(&cvirt->load_updates),
20145 + LOAD_INT(a), LOAD_FRAC(a),
20146 + LOAD_INT(b), LOAD_FRAC(b),
20147 + LOAD_INT(c), LOAD_FRAC(c),
20148 + atomic_read(&cvirt->total_forks));
20153 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
20154 + char *buffer, int cpu)
20160 +#endif /* _VX_CVIRT_PROC_H */
20161 diff -NurpP --minimal linux-2.6.33/kernel/vserver/debug.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/debug.c
20162 --- linux-2.6.33/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
20163 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/debug.c 2010-02-25 12:02:16.000000000 +0100
20166 + * kernel/vserver/debug.c
20168 + * Copyright (C) 2005-2007 Herbert Pötzl
20170 + * V0.01 vx_info dump support
20174 +#include <linux/module.h>
20176 +#include <linux/vserver/context.h>
20179 +void dump_vx_info(struct vx_info *vxi, int level)
20181 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
20182 + atomic_read(&vxi->vx_usecnt),
20183 + atomic_read(&vxi->vx_tasks),
20186 + __dump_vx_limit(&vxi->limit);
20187 + __dump_vx_sched(&vxi->sched);
20188 + __dump_vx_cvirt(&vxi->cvirt);
20189 + __dump_vx_cacct(&vxi->cacct);
20195 +EXPORT_SYMBOL_GPL(dump_vx_info);
20197 diff -NurpP --minimal linux-2.6.33/kernel/vserver/device.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/device.c
20198 --- linux-2.6.33/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
20199 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/device.c 2010-02-25 12:02:16.000000000 +0100
20202 + * linux/kernel/vserver/device.c
20204 + * Linux-VServer: Device Support
20206 + * Copyright (C) 2006 Herbert Pötzl
20207 + * Copyright (C) 2007 Daniel Hokka Zakrisson
20209 + * V0.01 device mapping basics
20210 + * V0.02 added defaults
20214 +#include <linux/slab.h>
20215 +#include <linux/rcupdate.h>
20216 +#include <linux/fs.h>
20217 +#include <linux/namei.h>
20218 +#include <linux/hash.h>
20220 +#include <asm/errno.h>
20221 +#include <asm/uaccess.h>
20222 +#include <linux/vserver/base.h>
20223 +#include <linux/vserver/debug.h>
20224 +#include <linux/vserver/context.h>
20225 +#include <linux/vserver/device.h>
20226 +#include <linux/vserver/device_cmd.h>
20229 +#define DMAP_HASH_BITS 4
20232 +struct vs_mapping {
20234 + struct hlist_node hlist;
20235 + struct list_head list;
20237 +#define dm_hlist u.hlist
20238 +#define dm_list u.list
20241 + struct vx_dmap_target target;
20245 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
20247 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
20249 +static struct vx_dmap_target dmap_defaults[2] = {
20250 + { .flags = DATTR_OPEN },
20251 + { .flags = DATTR_OPEN },
20255 +struct kmem_cache *dmap_cachep __read_mostly;
20257 +int __init dmap_cache_init(void)
20259 + dmap_cachep = kmem_cache_create("dmap_cache",
20260 + sizeof(struct vs_mapping), 0,
20261 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20265 +__initcall(dmap_cache_init);
20268 +static inline unsigned int __hashval(dev_t dev, int bits)
20270 + return hash_long((unsigned long)dev, bits);
20274 +/* __hash_mapping()
20275 + * add the mapping to the hash table
20277 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
20279 + spinlock_t *hash_lock = &dmap_main_hash_lock;
20280 + struct hlist_head *head, *hash = dmap_main_hash;
20281 + int device = vdm->device;
20283 + spin_lock(hash_lock);
20284 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
20285 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
20287 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
20288 + hlist_add_head(&vdm->dm_hlist, head);
20289 + spin_unlock(hash_lock);
20293 +static inline int __mode_to_default(umode_t mode)
20306 +/* __set_default()
20309 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
20310 + struct vx_dmap_target *vdmt)
20312 + spinlock_t *hash_lock = &dmap_main_hash_lock;
20313 + spin_lock(hash_lock);
20316 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
20318 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
20321 + spin_unlock(hash_lock);
20323 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
20324 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
20328 +/* __remove_default()
20329 + * remove a default
20331 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
20333 + spinlock_t *hash_lock = &dmap_main_hash_lock;
20334 + spin_lock(hash_lock);
20337 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
20338 + else /* remove == reset */
20339 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
20341 + spin_unlock(hash_lock);
20346 +/* __find_mapping()
20347 + * find a mapping in the hash table
20349 + * caller must hold hash_lock
20351 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
20352 + struct vs_mapping **local, struct vs_mapping **global)
20354 + struct hlist_head *hash = dmap_main_hash;
20355 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
20356 + struct hlist_node *pos;
20357 + struct vs_mapping *vdm;
20363 + hlist_for_each(pos, head) {
20364 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
20366 + if ((vdm->device == device) &&
20367 + !((vdm->target.flags ^ mode) & S_IFMT)) {
20368 + if (vdm->xid == xid) {
20371 + } else if (global && vdm->xid == 0)
20376 + if (global && *global)
20383 +/* __lookup_mapping()
20384 + * find a mapping and store the result in target and flags
20386 +static inline int __lookup_mapping(struct vx_info *vxi,
20387 + dev_t device, dev_t *target, int *flags, umode_t mode)
20389 + spinlock_t *hash_lock = &dmap_main_hash_lock;
20390 + struct vs_mapping *vdm, *global;
20391 + struct vx_dmap_target *vdmt;
20393 + xid_t xid = vxi->vx_id;
20396 + spin_lock(hash_lock);
20397 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
20399 + vdmt = &vdm->target;
20403 + index = __mode_to_default(mode);
20404 + if (vxi && vxi->dmap.targets[index].flags) {
20406 + vdmt = &vxi->dmap.targets[index];
20407 + } else if (global) {
20409 + vdmt = &global->target;
20413 + vdmt = &dmap_defaults[index];
20417 + if (target && (vdmt->flags & DATTR_REMAP))
20418 + *target = vdmt->target;
20420 + *target = device;
20422 + *flags = vdmt->flags;
20424 + spin_unlock(hash_lock);
20430 +/* __remove_mapping()
20431 + * remove a mapping from the hash table
20433 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
20436 + spinlock_t *hash_lock = &dmap_main_hash_lock;
20437 + struct vs_mapping *vdm = NULL;
20440 + spin_lock(hash_lock);
20442 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
20444 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
20445 + vxi, vxi ? vxi->vx_id : 0, device, mode);
20448 + hlist_del(&vdm->dm_hlist);
20451 + spin_unlock(hash_lock);
20453 + kmem_cache_free(dmap_cachep, vdm);
20459 +int vs_map_device(struct vx_info *vxi,
20460 + dev_t device, dev_t *target, umode_t mode)
20462 + int ret, flags = DATTR_MASK;
20466 + *target = device;
20469 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
20470 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
20471 + device, target ? *target : 0, flags, mode, ret);
20473 + return (flags & DATTR_MASK);
20478 +static int do_set_mapping(struct vx_info *vxi,
20479 + dev_t device, dev_t target, int flags, umode_t mode)
20482 + struct vs_mapping *new;
20484 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
20488 + INIT_HLIST_NODE(&new->dm_hlist);
20489 + new->device = device;
20490 + new->target.target = target;
20491 + new->target.flags = flags | mode;
20492 + new->xid = (vxi ? vxi->vx_id : 0);
20494 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
20495 + __hash_mapping(vxi, new);
20497 + struct vx_dmap_target new = {
20498 + .target = target,
20499 + .flags = flags | mode,
20501 + __set_default(vxi, mode, &new);
20507 +static int do_unset_mapping(struct vx_info *vxi,
20508 + dev_t device, dev_t target, int flags, umode_t mode)
20510 + int ret = -EINVAL;
20513 + ret = __remove_mapping(vxi, device, mode);
20517 + ret = __remove_default(vxi, mode);
20527 +static inline int __user_device(const char __user *name, dev_t *dev,
20530 + struct nameidata nd;
20537 + ret = user_lpath(name, &nd.path);
20540 + if (nd.path.dentry->d_inode) {
20541 + *dev = nd.path.dentry->d_inode->i_rdev;
20542 + *mode = nd.path.dentry->d_inode->i_mode;
20544 + path_put(&nd.path);
20548 +static inline int __mapping_mode(dev_t device, dev_t target,
20549 + umode_t device_mode, umode_t target_mode, umode_t *mode)
20552 + *mode = device_mode & S_IFMT;
20554 + *mode = target_mode & S_IFMT;
20558 + /* if both given, device and target mode have to match */
20559 + if (device && target &&
20560 + ((device_mode ^ target_mode) & S_IFMT))
20566 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
20567 + const char __user *target_path, int flags, int set)
20569 + dev_t device = ~0, target = ~0;
20570 + umode_t device_mode = 0, target_mode = 0, mode;
20573 + ret = __user_device(device_path, &device, &device_mode);
20576 + ret = __user_device(target_path, &target, &target_mode);
20580 + ret = __mapping_mode(device, target,
20581 + device_mode, target_mode, &mode);
20586 + return do_set_mapping(vxi, device, target,
20589 + return do_unset_mapping(vxi, device, target,
20594 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
20596 + struct vcmd_set_mapping_v0 vc_data;
20598 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20601 + return do_mapping(vxi, vc_data.device, vc_data.target,
20602 + vc_data.flags, 1);
20605 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
20607 + struct vcmd_set_mapping_v0 vc_data;
20609 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20612 + return do_mapping(vxi, vc_data.device, vc_data.target,
20613 + vc_data.flags, 0);
20617 +#ifdef CONFIG_COMPAT
20619 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
20621 + struct vcmd_set_mapping_v0_x32 vc_data;
20623 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20626 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20627 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
20630 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
20632 + struct vcmd_set_mapping_v0_x32 vc_data;
20634 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20637 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20638 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
20641 +#endif /* CONFIG_COMPAT */
20644 diff -NurpP --minimal linux-2.6.33/kernel/vserver/dlimit.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/dlimit.c
20645 --- linux-2.6.33/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
20646 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/dlimit.c 2010-02-25 12:02:16.000000000 +0100
20649 + * linux/kernel/vserver/dlimit.c
20651 + * Virtual Server: Context Disk Limits
20653 + * Copyright (C) 2004-2009 Herbert Pötzl
20655 + * V0.01 initial version
20656 + * V0.02 compat32 splitup
20657 + * V0.03 extended interface
20661 +#include <linux/statfs.h>
20662 +#include <linux/sched.h>
20663 +#include <linux/namei.h>
20664 +#include <linux/vs_tag.h>
20665 +#include <linux/vs_dlimit.h>
20666 +#include <linux/vserver/dlimit_cmd.h>
20668 +#include <asm/uaccess.h>
20670 +/* __alloc_dl_info()
20672 + * allocate an initialized dl_info struct
20673 + * doesn't make it visible (hash) */
20675 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
20677 + struct dl_info *new = NULL;
20679 + vxdprintk(VXD_CBIT(dlim, 5),
20680 + "alloc_dl_info(%p,%d)*", sb, tag);
20682 + /* would this benefit from a slab cache? */
20683 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
20687 + memset(new, 0, sizeof(struct dl_info));
20688 + new->dl_tag = tag;
20690 + INIT_RCU_HEAD(&new->dl_rcu);
20691 + INIT_HLIST_NODE(&new->dl_hlist);
20692 + spin_lock_init(&new->dl_lock);
20693 + atomic_set(&new->dl_refcnt, 0);
20694 + atomic_set(&new->dl_usecnt, 0);
20696 + /* rest of init goes here */
20698 + vxdprintk(VXD_CBIT(dlim, 4),
20699 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
20703 +/* __dealloc_dl_info()
20705 + * final disposal of dl_info */
20707 +static void __dealloc_dl_info(struct dl_info *dli)
20709 + vxdprintk(VXD_CBIT(dlim, 4),
20710 + "dealloc_dl_info(%p)", dli);
20712 + dli->dl_hlist.next = LIST_POISON1;
20713 + dli->dl_tag = -1;
20716 + BUG_ON(atomic_read(&dli->dl_usecnt));
20717 + BUG_ON(atomic_read(&dli->dl_refcnt));
20723 +/* hash table for dl_info hash */
20725 +#define DL_HASH_SIZE 13
20727 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
20729 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
20732 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20734 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20739 +/* __hash_dl_info()
20741 + * add the dli to the global hash table
20742 + * requires the hash_lock to be held */
20744 +static inline void __hash_dl_info(struct dl_info *dli)
20746 + struct hlist_head *head;
20748 + vxdprintk(VXD_CBIT(dlim, 6),
20749 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20750 + get_dl_info(dli);
20751 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20752 + hlist_add_head_rcu(&dli->dl_hlist, head);
20755 +/* __unhash_dl_info()
20757 + * remove the dli from the global hash table
20758 + * requires the hash_lock to be held */
20760 +static inline void __unhash_dl_info(struct dl_info *dli)
20762 + vxdprintk(VXD_CBIT(dlim, 6),
20763 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20764 + hlist_del_rcu(&dli->dl_hlist);
20765 + put_dl_info(dli);
20769 +/* __lookup_dl_info()
20771 + * requires the rcu_read_lock()
20772 + * doesn't increment the dl_refcnt */
20774 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20776 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20777 + struct hlist_node *pos;
20778 + struct dl_info *dli;
20780 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20782 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
20790 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20792 + struct dl_info *dli;
20795 + dli = get_dl_info(__lookup_dl_info(sb, tag));
20796 + vxdprintk(VXD_CBIT(dlim, 7),
20797 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20798 + rcu_read_unlock();
20802 +void rcu_free_dl_info(struct rcu_head *head)
20804 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20805 + int usecnt, refcnt;
20807 + BUG_ON(!dli || !head);
20809 + usecnt = atomic_read(&dli->dl_usecnt);
20810 + BUG_ON(usecnt < 0);
20812 + refcnt = atomic_read(&dli->dl_refcnt);
20813 + BUG_ON(refcnt < 0);
20815 + vxdprintk(VXD_CBIT(dlim, 3),
20816 + "rcu_free_dl_info(%p)", dli);
20818 + __dealloc_dl_info(dli);
20820 + printk("!!! rcu didn't free\n");
20826 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20827 + uint32_t flags, int add)
20829 + struct path path;
20832 + ret = user_lpath(name, &path);
20834 + struct super_block *sb;
20835 + struct dl_info *dli;
20838 + if (!path.dentry->d_inode)
20839 + goto out_release;
20840 + if (!(sb = path.dentry->d_inode->i_sb))
20841 + goto out_release;
20844 + dli = __alloc_dl_info(sb, id);
20845 + spin_lock(&dl_info_hash_lock);
20848 + if (__lookup_dl_info(sb, id))
20850 + __hash_dl_info(dli);
20853 + spin_lock(&dl_info_hash_lock);
20854 + dli = __lookup_dl_info(sb, id);
20859 + __unhash_dl_info(dli);
20863 + spin_unlock(&dl_info_hash_lock);
20865 + __dealloc_dl_info(dli);
20872 +int vc_add_dlimit(uint32_t id, void __user *data)
20874 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20876 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20879 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20882 +int vc_rem_dlimit(uint32_t id, void __user *data)
20884 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20886 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20889 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20892 +#ifdef CONFIG_COMPAT
20894 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20896 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20898 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20901 + return do_addrem_dlimit(id,
20902 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20905 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20907 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20909 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20912 + return do_addrem_dlimit(id,
20913 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20916 +#endif /* CONFIG_COMPAT */
20920 +int do_set_dlimit(uint32_t id, const char __user *name,
20921 + uint32_t space_used, uint32_t space_total,
20922 + uint32_t inodes_used, uint32_t inodes_total,
20923 + uint32_t reserved, uint32_t flags)
20925 + struct path path;
20928 + ret = user_lpath(name, &path);
20930 + struct super_block *sb;
20931 + struct dl_info *dli;
20934 + if (!path.dentry->d_inode)
20935 + goto out_release;
20936 + if (!(sb = path.dentry->d_inode->i_sb))
20937 + goto out_release;
20939 + /* sanity checks */
20940 + if ((reserved != CDLIM_KEEP &&
20941 + reserved > 100) ||
20942 + (inodes_used != CDLIM_KEEP &&
20943 + inodes_used > inodes_total) ||
20944 + (space_used != CDLIM_KEEP &&
20945 + space_used > space_total))
20946 + goto out_release;
20949 + dli = locate_dl_info(sb, id);
20951 + goto out_release;
20953 + spin_lock(&dli->dl_lock);
20955 + if (inodes_used != CDLIM_KEEP)
20956 + dli->dl_inodes_used = inodes_used;
20957 + if (inodes_total != CDLIM_KEEP)
20958 + dli->dl_inodes_total = inodes_total;
20959 + if (space_used != CDLIM_KEEP)
20960 + dli->dl_space_used = dlimit_space_32to64(
20961 + space_used, flags, DLIMS_USED);
20963 + if (space_total == CDLIM_INFINITY)
20964 + dli->dl_space_total = DLIM_INFINITY;
20965 + else if (space_total != CDLIM_KEEP)
20966 + dli->dl_space_total = dlimit_space_32to64(
20967 + space_total, flags, DLIMS_TOTAL);
20969 + if (reserved != CDLIM_KEEP)
20970 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20972 + spin_unlock(&dli->dl_lock);
20974 + put_dl_info(dli);
20983 +int vc_set_dlimit(uint32_t id, void __user *data)
20985 + struct vcmd_ctx_dlimit_v0 vc_data;
20987 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20990 + return do_set_dlimit(id, vc_data.name,
20991 + vc_data.space_used, vc_data.space_total,
20992 + vc_data.inodes_used, vc_data.inodes_total,
20993 + vc_data.reserved, vc_data.flags);
20996 +#ifdef CONFIG_COMPAT
20998 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
21000 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
21002 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21005 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
21006 + vc_data.space_used, vc_data.space_total,
21007 + vc_data.inodes_used, vc_data.inodes_total,
21008 + vc_data.reserved, vc_data.flags);
21011 +#endif /* CONFIG_COMPAT */
21015 +int do_get_dlimit(uint32_t id, const char __user *name,
21016 + uint32_t *space_used, uint32_t *space_total,
21017 + uint32_t *inodes_used, uint32_t *inodes_total,
21018 + uint32_t *reserved, uint32_t *flags)
21020 + struct path path;
21023 + ret = user_lpath(name, &path);
21025 + struct super_block *sb;
21026 + struct dl_info *dli;
21029 + if (!path.dentry->d_inode)
21030 + goto out_release;
21031 + if (!(sb = path.dentry->d_inode->i_sb))
21032 + goto out_release;
21035 + dli = locate_dl_info(sb, id);
21037 + goto out_release;
21039 + spin_lock(&dli->dl_lock);
21040 + *inodes_used = dli->dl_inodes_used;
21041 + *inodes_total = dli->dl_inodes_total;
21043 + *space_used = dlimit_space_64to32(
21044 + dli->dl_space_used, flags, DLIMS_USED);
21046 + if (dli->dl_space_total == DLIM_INFINITY)
21047 + *space_total = CDLIM_INFINITY;
21049 + *space_total = dlimit_space_64to32(
21050 + dli->dl_space_total, flags, DLIMS_TOTAL);
21052 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
21053 + spin_unlock(&dli->dl_lock);
21055 + put_dl_info(dli);
21066 +int vc_get_dlimit(uint32_t id, void __user *data)
21068 + struct vcmd_ctx_dlimit_v0 vc_data;
21071 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21074 + ret = do_get_dlimit(id, vc_data.name,
21075 + &vc_data.space_used, &vc_data.space_total,
21076 + &vc_data.inodes_used, &vc_data.inodes_total,
21077 + &vc_data.reserved, &vc_data.flags);
21081 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21086 +#ifdef CONFIG_COMPAT
21088 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
21090 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
21093 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21096 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
21097 + &vc_data.space_used, &vc_data.space_total,
21098 + &vc_data.inodes_used, &vc_data.inodes_total,
21099 + &vc_data.reserved, &vc_data.flags);
21103 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21108 +#endif /* CONFIG_COMPAT */
21111 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
21113 + struct dl_info *dli;
21114 + __u64 blimit, bfree, bavail;
21117 + dli = locate_dl_info(sb, dx_current_tag());
21121 + spin_lock(&dli->dl_lock);
21122 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
21125 + /* reduce max inodes available to limit */
21126 + if (buf->f_files > dli->dl_inodes_total)
21127 + buf->f_files = dli->dl_inodes_total;
21129 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
21130 + /* reduce free inodes to min */
21131 + if (ifree < buf->f_ffree)
21132 + buf->f_ffree = ifree;
21135 + if (dli->dl_space_total == DLIM_INFINITY)
21138 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
21140 + if (dli->dl_space_total < dli->dl_space_used)
21143 + bfree = (dli->dl_space_total - dli->dl_space_used)
21144 + >> sb->s_blocksize_bits;
21146 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
21147 + if (bavail < dli->dl_space_used)
21150 + bavail = (bavail - dli->dl_space_used)
21151 + >> sb->s_blocksize_bits;
21153 + /* reduce max space available to limit */
21154 + if (buf->f_blocks > blimit)
21155 + buf->f_blocks = blimit;
21157 + /* reduce free space to min */
21158 + if (bfree < buf->f_bfree)
21159 + buf->f_bfree = bfree;
21161 + /* reduce avail space to min */
21162 + if (bavail < buf->f_bavail)
21163 + buf->f_bavail = bavail;
21166 + spin_unlock(&dli->dl_lock);
21167 + put_dl_info(dli);
21172 +#include <linux/module.h>
21174 +EXPORT_SYMBOL_GPL(locate_dl_info);
21175 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
21177 diff -NurpP --minimal linux-2.6.33/kernel/vserver/helper.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/helper.c
21178 --- linux-2.6.33/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
21179 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/helper.c 2010-02-25 12:02:16.000000000 +0100
21182 + * linux/kernel/vserver/helper.c
21184 + * Virtual Context Support
21186 + * Copyright (C) 2004-2007 Herbert Pötzl
21188 + * V0.01 basic helper
21192 +#include <linux/kmod.h>
21193 +#include <linux/reboot.h>
21194 +#include <linux/vs_context.h>
21195 +#include <linux/vs_network.h>
21196 +#include <linux/vserver/signal.h>
21199 +char vshelper_path[255] = "/sbin/vshelper";
21202 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
21206 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
21207 + printk( KERN_WARNING
21208 + "%s: (%s %s) returned %s with %d\n",
21209 + name, argv[1], argv[2],
21210 + sync ? "sync" : "async", ret);
21212 + vxdprintk(VXD_CBIT(switch, 4),
21213 + "%s: (%s %s) returned %s with %d",
21214 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
21219 + * vshelper path is set via /proc/sys
21220 + * invoked by vserver sys_reboot(), with
21221 + * the following arguments
21223 + * argv [0] = vshelper_path;
21224 + * argv [1] = action: "restart", "halt", "poweroff", ...
21225 + * argv [2] = context identifier
21227 + * envp [*] = type-specific parameters
21230 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
21232 + char id_buf[8], cmd_buf[16];
21233 + char uid_buf[16], pid_buf[16];
21236 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
21237 + char *envp[] = {"HOME=/", "TERM=linux",
21238 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
21239 + uid_buf, pid_buf, cmd_buf, 0};
21241 + if (vx_info_state(vxi, VXS_HELPER))
21243 + vxi->vx_state |= VXS_HELPER;
21245 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
21247 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
21248 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
21249 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
21252 + case LINUX_REBOOT_CMD_RESTART:
21253 + argv[1] = "restart";
21256 + case LINUX_REBOOT_CMD_HALT:
21257 + argv[1] = "halt";
21260 + case LINUX_REBOOT_CMD_POWER_OFF:
21261 + argv[1] = "poweroff";
21264 + case LINUX_REBOOT_CMD_SW_SUSPEND:
21265 + argv[1] = "swsusp";
21268 + case LINUX_REBOOT_CMD_OOM:
21273 + vxi->vx_state &= ~VXS_HELPER;
21277 + ret = do_vshelper(vshelper_path, argv, envp, 0);
21278 + vxi->vx_state &= ~VXS_HELPER;
21279 + __wakeup_vx_info(vxi);
21280 + return (ret) ? -EPERM : 0;
21284 +long vs_reboot(unsigned int cmd, void __user *arg)
21286 + struct vx_info *vxi = current_vx_info();
21289 + vxdprintk(VXD_CBIT(misc, 5),
21290 + "vs_reboot(%p[#%d],%u)",
21291 + vxi, vxi ? vxi->vx_id : 0, cmd);
21293 + ret = vs_reboot_helper(vxi, cmd, arg);
21297 + vxi->reboot_cmd = cmd;
21298 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
21300 + case LINUX_REBOOT_CMD_RESTART:
21301 + case LINUX_REBOOT_CMD_HALT:
21302 + case LINUX_REBOOT_CMD_POWER_OFF:
21303 + vx_info_kill(vxi, 0, SIGKILL);
21304 + vx_info_kill(vxi, 1, SIGKILL);
21312 +long vs_oom_action(unsigned int cmd)
21314 + struct vx_info *vxi = current_vx_info();
21317 + vxdprintk(VXD_CBIT(misc, 5),
21318 + "vs_oom_action(%p[#%d],%u)",
21319 + vxi, vxi ? vxi->vx_id : 0, cmd);
21321 + ret = vs_reboot_helper(vxi, cmd, NULL);
21325 + vxi->reboot_cmd = cmd;
21326 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
21327 + vx_info_kill(vxi, 0, SIGKILL);
21328 + vx_info_kill(vxi, 1, SIGKILL);
21334 + * argv [0] = vshelper_path;
21335 + * argv [1] = action: "startup", "shutdown"
21336 + * argv [2] = context identifier
21338 + * envp [*] = type-specific parameters
21341 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
21343 + char id_buf[8], cmd_buf[16];
21344 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
21345 + char *envp[] = {"HOME=/", "TERM=linux",
21346 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
21348 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
21351 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
21352 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
21355 + case VSC_STARTUP:
21356 + argv[1] = "startup";
21358 + case VSC_SHUTDOWN:
21359 + argv[1] = "shutdown";
21365 + return do_vshelper(vshelper_path, argv, envp, 1);
21370 + * argv [0] = vshelper_path;
21371 + * argv [1] = action: "netup", "netdown"
21372 + * argv [2] = context identifier
21374 + * envp [*] = type-specific parameters
21377 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
21379 + char id_buf[8], cmd_buf[16];
21380 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
21381 + char *envp[] = {"HOME=/", "TERM=linux",
21382 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
21384 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
21387 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
21388 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
21392 + argv[1] = "netup";
21394 + case VSC_NETDOWN:
21395 + argv[1] = "netdown";
21401 + return do_vshelper(vshelper_path, argv, envp, 1);
21404 diff -NurpP --minimal linux-2.6.33/kernel/vserver/history.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/history.c
21405 --- linux-2.6.33/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
21406 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/history.c 2010-02-25 12:02:16.000000000 +0100
21409 + * kernel/vserver/history.c
21411 + * Virtual Context History Backtrace
21413 + * Copyright (C) 2004-2007 Herbert Pötzl
21415 + * V0.01 basic structure
21416 + * V0.02 hash/unhash and trace
21417 + * V0.03 preemption fixes
21421 +#include <linux/module.h>
21422 +#include <asm/uaccess.h>
21424 +#include <linux/vserver/context.h>
21425 +#include <linux/vserver/debug.h>
21426 +#include <linux/vserver/debug_cmd.h>
21427 +#include <linux/vserver/history.h>
21430 +#ifdef CONFIG_VSERVER_HISTORY
21431 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
21433 +#define VXH_SIZE 64
21436 +struct _vx_history {
21437 + unsigned int counter;
21439 + struct _vx_hist_entry entry[VXH_SIZE + 1];
21443 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
21445 +unsigned volatile int vxh_active = 1;
21447 +static atomic_t sequence = ATOMIC_INIT(0);
21452 + * requires disabled preemption */
21454 +struct _vx_hist_entry *vxh_advance(void *loc)
21456 + unsigned int cpu = smp_processor_id();
21457 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21458 + struct _vx_hist_entry *entry;
21459 + unsigned int index;
21461 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
21462 + entry = &hist->entry[index];
21464 + entry->seq = atomic_inc_return(&sequence);
21465 + entry->loc = loc;
21469 +EXPORT_SYMBOL_GPL(vxh_advance);
21472 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
21474 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
21477 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
21479 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
21480 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
21481 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
21482 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
21484 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
21486 + switch (e->type) {
21487 + case VXH_THROW_OOPS:
21488 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
21491 + case VXH_GET_VX_INFO:
21492 + case VXH_PUT_VX_INFO:
21493 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21495 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
21496 + VXH_VXI_ARGS(e));
21499 + case VXH_INIT_VX_INFO:
21500 + case VXH_SET_VX_INFO:
21501 + case VXH_CLR_VX_INFO:
21502 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21504 + (e->type == VXH_INIT_VX_INFO) ? "init" :
21505 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
21506 + VXH_VXI_ARGS(e), e->sc.data);
21509 + case VXH_CLAIM_VX_INFO:
21510 + case VXH_RELEASE_VX_INFO:
21511 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21513 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
21514 + VXH_VXI_ARGS(e), e->sc.data);
21517 + case VXH_ALLOC_VX_INFO:
21518 + case VXH_DEALLOC_VX_INFO:
21519 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21521 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
21522 + VXH_VXI_ARGS(e));
21525 + case VXH_HASH_VX_INFO:
21526 + case VXH_UNHASH_VX_INFO:
21527 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
21529 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
21530 + VXH_VXI_ARGS(e));
21533 + case VXH_LOC_VX_INFO:
21534 + case VXH_LOOKUP_VX_INFO:
21535 + case VXH_CREATE_VX_INFO:
21536 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
21538 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
21539 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
21540 + e->ll.arg, VXH_VXI_ARGS(e));
21545 +static void __vxh_dump_history(void)
21547 + unsigned int i, cpu;
21549 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
21550 + atomic_read(&sequence), NR_CPUS);
21552 + for (i = 0; i < VXH_SIZE; i++) {
21553 + for_each_online_cpu(cpu) {
21554 + struct _vx_history *hist =
21555 + &per_cpu(vx_history_buffer, cpu);
21556 + unsigned int index = (hist->counter - i) % VXH_SIZE;
21557 + struct _vx_hist_entry *entry = &hist->entry[index];
21559 + vxh_dump_entry(entry, cpu);
21564 +void vxh_dump_history(void)
21568 + local_irq_enable();
21570 + local_irq_disable();
21572 + __vxh_dump_history();
21576 +/* vserver syscall commands below here */
21579 +int vc_dump_history(uint32_t id)
21582 + __vxh_dump_history();
21589 +int do_read_history(struct __user _vx_hist_entry *data,
21590 + int cpu, uint32_t *index, uint32_t *count)
21592 + int pos, ret = 0;
21593 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21594 + int end = hist->counter;
21595 + int start = end - VXH_SIZE + 2;
21596 + int idx = *index;
21598 + /* special case: get current pos */
21604 + /* have we lost some data? */
21608 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21609 + struct _vx_hist_entry *entry =
21610 + &hist->entry[idx % VXH_SIZE];
21612 + /* send entry to userspace */
21613 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21617 + /* save new index and count */
21620 + return ret ? ret : (*index < end);
21623 +int vc_read_history(uint32_t id, void __user *data)
21625 + struct vcmd_read_history_v0 vc_data;
21628 + if (id >= NR_CPUS)
21631 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21634 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
21635 + id, &vc_data.index, &vc_data.count);
21637 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21642 +#ifdef CONFIG_COMPAT
21644 +int vc_read_history_x32(uint32_t id, void __user *data)
21646 + struct vcmd_read_history_v0_x32 vc_data;
21649 + if (id >= NR_CPUS)
21652 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21655 + ret = do_read_history((struct __user _vx_hist_entry *)
21656 + compat_ptr(vc_data.data_ptr),
21657 + id, &vc_data.index, &vc_data.count);
21659 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21664 +#endif /* CONFIG_COMPAT */
21666 diff -NurpP --minimal linux-2.6.33/kernel/vserver/inet.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/inet.c
21667 --- linux-2.6.33/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
21668 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/inet.c 2010-02-25 12:02:16.000000000 +0100
21671 +#include <linux/in.h>
21672 +#include <linux/inetdevice.h>
21673 +#include <linux/vs_inet.h>
21674 +#include <linux/vs_inet6.h>
21675 +#include <linux/vserver/debug.h>
21676 +#include <net/route.h>
21677 +#include <net/addrconf.h>
21680 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21684 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
21687 + struct nx_addr_v4 *ptr;
21689 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
21690 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21697 + vxdprintk(VXD_CBIT(net, 2),
21698 + "nx_v4_addr_conflict(%p,%p): %d",
21699 + nxi1, nxi2, ret);
21705 +#ifdef CONFIG_IPV6
21707 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21711 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
21714 + struct nx_addr_v6 *ptr;
21716 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
21717 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21724 + vxdprintk(VXD_CBIT(net, 2),
21725 + "nx_v6_addr_conflict(%p,%p): %d",
21726 + nxi1, nxi2, ret);
21733 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21735 + struct in_device *in_dev;
21736 + struct in_ifaddr **ifap;
21737 + struct in_ifaddr *ifa;
21742 + in_dev = in_dev_get(dev);
21746 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
21747 + ifap = &ifa->ifa_next) {
21748 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
21753 + in_dev_put(in_dev);
21759 +#ifdef CONFIG_IPV6
21761 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21763 + struct inet6_dev *in_dev;
21764 + struct inet6_ifaddr **ifap;
21765 + struct inet6_ifaddr *ifa;
21770 + in_dev = in6_dev_get(dev);
21774 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
21775 + ifap = &ifa->if_next) {
21776 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
21781 + in6_dev_put(in_dev);
21788 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21794 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
21796 +#ifdef CONFIG_IPV6
21798 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
21803 + vxdprintk(VXD_CBIT(net, 3),
21804 + "dev_in_nx_info(%p,%p[#%d]) = %d",
21805 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
21809 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
21810 + struct rtable **rp, struct flowi *fl)
21815 + /* FIXME: handle lback only case */
21816 + if (!NX_IPV4(nxi))
21819 + vxdprintk(VXD_CBIT(net, 4),
21820 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
21821 + nxi, nxi ? nxi->nx_id : 0,
21822 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
21824 + /* single IP is unconditional */
21825 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21826 + (fl->fl4_src == INADDR_ANY))
21827 + fl->fl4_src = nxi->v4.ip[0].s_addr;
21829 + if (fl->fl4_src == INADDR_ANY) {
21830 + struct nx_addr_v4 *ptr;
21831 + __be32 found = 0;
21834 + err = __ip_route_output_key(net, rp, fl);
21836 + found = (*rp)->rt_src;
21838 + vxdprintk(VXD_CBIT(net, 4),
21839 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21840 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
21841 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21845 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21846 + __be32 primary = ptr->ip[0].s_addr;
21847 + __be32 mask = ptr->mask.s_addr;
21848 + __be32 neta = primary & mask;
21850 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21851 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21852 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21853 + NIPQUAD(mask), NIPQUAD(neta));
21854 + if ((found & mask) != neta)
21857 + fl->fl4_src = primary;
21858 + err = __ip_route_output_key(net, rp, fl);
21859 + vxdprintk(VXD_CBIT(net, 4),
21860 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21861 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
21863 + found = (*rp)->rt_src;
21865 + if (found == primary)
21869 + /* still no source ip? */
21870 + found = ipv4_is_loopback(fl->fl4_dst)
21871 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21873 + /* assign src ip to flow */
21874 + fl->fl4_src = found;
21877 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
21881 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21882 + if (ipv4_is_loopback(fl->fl4_dst))
21883 + fl->fl4_dst = nxi->v4_lback.s_addr;
21884 + if (ipv4_is_loopback(fl->fl4_src))
21885 + fl->fl4_src = nxi->v4_lback.s_addr;
21886 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
21887 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21893 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21895 diff -NurpP --minimal linux-2.6.33/kernel/vserver/init.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/init.c
21896 --- linux-2.6.33/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
21897 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/init.c 2010-02-25 12:02:16.000000000 +0100
21900 + * linux/kernel/init.c
21902 + * Virtual Server Init
21904 + * Copyright (C) 2004-2007 Herbert Pötzl
21906 + * V0.01 basic structure
21910 +#include <linux/init.h>
21912 +int vserver_register_sysctl(void);
21913 +void vserver_unregister_sysctl(void);
21916 +static int __init init_vserver(void)
21920 +#ifdef CONFIG_VSERVER_DEBUG
21921 + vserver_register_sysctl();
21927 +static void __exit exit_vserver(void)
21930 +#ifdef CONFIG_VSERVER_DEBUG
21931 + vserver_unregister_sysctl();
21936 +/* FIXME: GFP_ZONETYPES gone
21937 +long vx_slab[GFP_ZONETYPES]; */
21941 +module_init(init_vserver);
21942 +module_exit(exit_vserver);
21944 diff -NurpP --minimal linux-2.6.33/kernel/vserver/inode.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/inode.c
21945 --- linux-2.6.33/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21946 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/inode.c 2010-02-25 12:02:16.000000000 +0100
21949 + * linux/kernel/vserver/inode.c
21951 + * Virtual Server: File System Support
21953 + * Copyright (C) 2004-2007 Herbert Pötzl
21955 + * V0.01 separated from vcontext V0.05
21956 + * V0.02 moved to tag (instead of xid)
21960 +#include <linux/tty.h>
21961 +#include <linux/proc_fs.h>
21962 +#include <linux/devpts_fs.h>
21963 +#include <linux/fs.h>
21964 +#include <linux/file.h>
21965 +#include <linux/mount.h>
21966 +#include <linux/parser.h>
21967 +#include <linux/namei.h>
21968 +#include <linux/vserver/inode.h>
21969 +#include <linux/vserver/inode_cmd.h>
21970 +#include <linux/vs_base.h>
21971 +#include <linux/vs_tag.h>
21973 +#include <asm/uaccess.h>
21976 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21978 + struct proc_dir_entry *entry;
21980 + if (!in || !in->i_sb)
21983 + *flags = IATTR_TAG
21984 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21985 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21986 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21987 + | (IS_COW(in) ? IATTR_COW : 0);
21988 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21990 + if (S_ISDIR(in->i_mode))
21991 + *mask |= IATTR_BARRIER;
21993 + if (IS_TAGGED(in)) {
21994 + *tag = in->i_tag;
21995 + *mask |= IATTR_TAG;
21998 + switch (in->i_sb->s_magic) {
21999 + case PROC_SUPER_MAGIC:
22000 + entry = PROC_I(in)->pde;
22002 + /* check for specific inodes? */
22004 + *mask |= IATTR_FLAGS;
22006 + *flags |= (entry->vx_flags & IATTR_FLAGS);
22008 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
22011 + case DEVPTS_SUPER_MAGIC:
22012 + *tag = in->i_tag;
22013 + *mask |= IATTR_TAG;
22022 +int vc_get_iattr(void __user *data)
22024 + struct path path;
22025 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
22028 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22031 + ret = user_lpath(vc_data.name, &path);
22033 + ret = __vc_get_iattr(path.dentry->d_inode,
22034 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22040 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22045 +#ifdef CONFIG_COMPAT
22047 +int vc_get_iattr_x32(void __user *data)
22049 + struct path path;
22050 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
22053 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22056 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
22058 + ret = __vc_get_iattr(path.dentry->d_inode,
22059 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22065 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22070 +#endif /* CONFIG_COMPAT */
22073 +int vc_fget_iattr(uint32_t fd, void __user *data)
22075 + struct file *filp;
22076 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
22079 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22083 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
22086 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
22087 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22091 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22097 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
22099 + struct inode *in = de->d_inode;
22100 + int error = 0, is_proc = 0, has_tag = 0;
22101 + struct iattr attr = { 0 };
22103 + if (!in || !in->i_sb)
22106 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
22107 + if ((*mask & IATTR_FLAGS) && !is_proc)
22110 + has_tag = IS_TAGGED(in) ||
22111 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
22112 + if ((*mask & IATTR_TAG) && !has_tag)
22115 + mutex_lock(&in->i_mutex);
22116 + if (*mask & IATTR_TAG) {
22117 + attr.ia_tag = *tag;
22118 + attr.ia_valid |= ATTR_TAG;
22121 + if (*mask & IATTR_FLAGS) {
22122 + struct proc_dir_entry *entry = PROC_I(in)->pde;
22123 + unsigned int iflags = PROC_I(in)->vx_flags;
22125 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
22126 + | (*flags & IATTR_FLAGS);
22127 + PROC_I(in)->vx_flags = iflags;
22129 + entry->vx_flags = iflags;
22132 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
22133 + IATTR_BARRIER | IATTR_COW)) {
22134 + int iflags = in->i_flags;
22135 + int vflags = in->i_vflags;
22137 + if (*mask & IATTR_IMMUTABLE) {
22138 + if (*flags & IATTR_IMMUTABLE)
22139 + iflags |= S_IMMUTABLE;
22141 + iflags &= ~S_IMMUTABLE;
22143 + if (*mask & IATTR_IXUNLINK) {
22144 + if (*flags & IATTR_IXUNLINK)
22145 + iflags |= S_IXUNLINK;
22147 + iflags &= ~S_IXUNLINK;
22149 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
22150 + if (*flags & IATTR_BARRIER)
22151 + vflags |= V_BARRIER;
22153 + vflags &= ~V_BARRIER;
22155 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
22156 + if (*flags & IATTR_COW)
22159 + vflags &= ~V_COW;
22161 + if (in->i_op && in->i_op->sync_flags) {
22162 + error = in->i_op->sync_flags(in, iflags, vflags);
22168 + if (attr.ia_valid) {
22169 + if (in->i_op && in->i_op->setattr)
22170 + error = in->i_op->setattr(de, &attr);
22172 + error = inode_change_ok(in, &attr);
22174 + error = inode_setattr(in, &attr);
22179 + mutex_unlock(&in->i_mutex);
22183 +int vc_set_iattr(void __user *data)
22185 + struct path path;
22186 + struct vcmd_ctx_iattr_v1 vc_data;
22189 + if (!capable(CAP_LINUX_IMMUTABLE))
22191 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22194 + ret = user_lpath(vc_data.name, &path);
22196 + ret = __vc_set_iattr(path.dentry,
22197 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22201 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22206 +#ifdef CONFIG_COMPAT
22208 +int vc_set_iattr_x32(void __user *data)
22210 + struct path path;
22211 + struct vcmd_ctx_iattr_v1_x32 vc_data;
22214 + if (!capable(CAP_LINUX_IMMUTABLE))
22216 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22219 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
22221 + ret = __vc_set_iattr(path.dentry,
22222 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22226 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22231 +#endif /* CONFIG_COMPAT */
22233 +int vc_fset_iattr(uint32_t fd, void __user *data)
22235 + struct file *filp;
22236 + struct vcmd_ctx_fiattr_v0 vc_data;
22239 + if (!capable(CAP_LINUX_IMMUTABLE))
22241 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22245 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
22248 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
22249 + &vc_data.flags, &vc_data.mask);
22253 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22259 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
22261 +static match_table_t tokens = {
22262 + {Opt_notagcheck, "notagcheck"},
22263 +#ifdef CONFIG_PROPAGATE
22264 + {Opt_notag, "notag"},
22265 + {Opt_tag, "tag"},
22266 + {Opt_tagid, "tagid=%u"},
22272 +static void __dx_parse_remove(char *string, char *opt)
22274 + char *p = strstr(string, opt);
22278 + while (*q != '\0' && *q != ',')
22287 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
22288 + unsigned long *flags)
22291 + substring_t args[MAX_OPT_ARGS];
22292 + int token, option = 0;
22293 + char *s, *p, *opts;
22297 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
22302 + while ((p = strsep(&opts, ",")) != NULL) {
22303 + token = match_token(p, tokens, args);
22305 + vxdprintk(VXD_CBIT(tag, 7),
22306 + "dx_parse_tag(»%s«): %d:#%d",
22307 + p, token, option);
22310 +#ifdef CONFIG_PROPAGATE
22315 + __dx_parse_remove(s, "tag");
22316 + *mnt_flags |= MNT_TAGID;
22317 + set |= MNT_TAGID;
22321 + __dx_parse_remove(s, "notag");
22322 + *mnt_flags |= MNT_NOTAG;
22323 + set |= MNT_NOTAG;
22326 + if (tag && !match_int(args, &option))
22329 + __dx_parse_remove(s, "tagid");
22330 + *mnt_flags |= MNT_TAGID;
22331 + set |= MNT_TAGID;
22334 + case Opt_notagcheck:
22336 + __dx_parse_remove(s, "notagcheck");
22337 + *flags |= MS_NOTAGCHECK;
22338 + set |= MS_NOTAGCHECK;
22343 + strcpy(string, s);
22348 +#ifdef CONFIG_PROPAGATE
22350 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
22352 + tag_t new_tag = 0;
22353 + struct vfsmount *mnt;
22358 + mnt = nd->path.mnt;
22362 + propagate = (mnt->mnt_flags & MNT_TAGID);
22364 + new_tag = mnt->mnt_tag;
22366 + vxdprintk(VXD_CBIT(tag, 7),
22367 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
22368 + inode, inode->i_ino, inode->i_tag,
22369 + new_tag, (propagate) ? 1 : 0);
22372 + inode->i_tag = new_tag;
22375 +#include <linux/module.h>
22377 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
22379 +#endif /* CONFIG_PROPAGATE */
22381 diff -NurpP --minimal linux-2.6.33/kernel/vserver/Kconfig linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/Kconfig
22382 --- linux-2.6.33/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
22383 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/Kconfig 2010-02-25 12:02:16.000000000 +0100
22386 +# Linux VServer configuration
22389 +menu "Linux VServer"
22391 +config VSERVER_AUTO_LBACK
22392 + bool "Automatically Assign Loopback IP"
22395 + Automatically assign a guest specific loopback
22396 + IP and add it to the kernel network stack on
22399 +config VSERVER_AUTO_SINGLE
22400 + bool "Automatic Single IP Special Casing"
22401 + depends on EXPERIMENTAL
22404 + This allows network contexts with a single IP to
22405 + automatically remap 0.0.0.0 bindings to that IP,
22406 + avoiding further network checks and improving
22409 + (note: such guests do not allow to change the ip
22410 + on the fly and do not show loopback addresses)
22412 +config VSERVER_COWBL
22413 + bool "Enable COW Immutable Link Breaking"
22416 + This enables the COW (Copy-On-Write) link break code.
22417 + It allows you to treat unified files like normal files
22418 + when writing to them (which will implicitely break the
22419 + link and create a copy of the unified file)
22421 +config VSERVER_VTIME
22422 + bool "Enable Virtualized Guest Time"
22423 + depends on EXPERIMENTAL
22426 + This enables per guest time offsets to allow for
22427 + adjusting the system clock individually per guest.
22428 + this adds some overhead to the time functions and
22429 + therefore should not be enabled without good reason.
22431 +config VSERVER_DEVICE
22432 + bool "Enable Guest Device Mapping"
22433 + depends on EXPERIMENTAL
22436 + This enables generic device remapping.
22438 +config VSERVER_PROC_SECURE
22439 + bool "Enable Proc Security"
22440 + depends on PROC_FS
22443 + This configures ProcFS security to initially hide
22444 + non-process entries for all contexts except the main and
22445 + spectator context (i.e. for all guests), which is a secure
22448 + (note: on 1.2x the entries were visible by default)
22450 +config VSERVER_HARDCPU
22451 + bool "Enable Hard CPU Limits"
22454 + Activate the Hard CPU Limits
22456 + This will compile in code that allows the Token Bucket
22457 + Scheduler to put processes on hold when a context's
22458 + tokens are depleted (provided that its per-context
22459 + sched_hard flag is set).
22461 + Processes belonging to that context will not be able
22462 + to consume CPU resources again until a per-context
22463 + configured minimum of tokens has been reached.
22465 +config VSERVER_IDLETIME
22466 + bool "Avoid idle CPUs by skipping Time"
22467 + depends on VSERVER_HARDCPU
22470 + This option allows the scheduler to artificially
22471 + advance time (per cpu) when otherwise the idle
22472 + task would be scheduled, thus keeping the cpu
22473 + busy and sharing the available resources among
22474 + certain contexts.
22476 +config VSERVER_IDLELIMIT
22477 + bool "Limit the IDLE task"
22478 + depends on VSERVER_HARDCPU
22481 + Limit the idle slices, so the the next context
22482 + will be scheduled as soon as possible.
22484 + This might improve interactivity and latency, but
22485 + will also marginally increase scheduling overhead.
22488 + prompt "Persistent Inode Tagging"
22489 + default TAGGING_ID24
22491 + This adds persistent context information to filesystems
22492 + mounted with the tagxid option. Tagging is a requirement
22493 + for per-context disk limits and per-context quota.
22496 +config TAGGING_NONE
22499 + do not store per-context information in inodes.
22501 +config TAGGING_UID16
22502 + bool "UID16/GID32"
22504 + reduces UID to 16 bit, but leaves GID at 32 bit.
22506 +config TAGGING_GID16
22507 + bool "UID32/GID16"
22509 + reduces GID to 16 bit, but leaves UID at 32 bit.
22511 +config TAGGING_ID24
22512 + bool "UID24/GID24"
22514 + uses the upper 8bit from UID and GID for XID tagging
22515 + which leaves 24bit for UID/GID each, which should be
22516 + more than sufficient for normal use.
22518 +config TAGGING_INTERN
22519 + bool "UID32/GID32"
22521 + this uses otherwise reserved inode fields in the on
22522 + disk representation, which limits the use to a few
22523 + filesystems (currently ext2 and ext3)
22528 + bool "Tag NFSD User Auth and Files"
22531 + Enable this if you do want the in-kernel NFS
22532 + Server to use the tagging specified above.
22533 + (will require patched clients too)
22535 +config VSERVER_PRIVACY
22536 + bool "Honor Privacy Aspects of Guests"
22539 + When enabled, most context checks will disallow
22540 + access to structures assigned to a specific context,
22541 + like ptys or loop devices.
22543 +config VSERVER_CONTEXTS
22544 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
22546 + default "768" if 64BIT
22549 + This setting will optimize certain data structures
22550 + and memory allocations according to the expected
22553 + note: this is not a strict upper limit.
22555 +config VSERVER_WARN
22556 + bool "VServer Warnings"
22559 + This enables various runtime warnings, which will
22560 + notify about potential manipulation attempts or
22561 + resource shortage. It is generally considered to
22562 + be a good idea to have that enabled.
22564 +config VSERVER_DEBUG
22565 + bool "VServer Debugging Code"
22568 + Set this to yes if you want to be able to activate
22569 + debugging output at runtime. It adds a very small
22570 + overhead to all vserver related functions and
22571 + increases the kernel size by about 20k.
22573 +config VSERVER_HISTORY
22574 + bool "VServer History Tracing"
22575 + depends on VSERVER_DEBUG
22578 + Set this to yes if you want to record the history of
22579 + linux-vserver activities, so they can be replayed in
22580 + the event of a kernel panic or oops.
22582 +config VSERVER_HISTORY_SIZE
22583 + int "Per-CPU History Size (32-65536)"
22584 + depends on VSERVER_HISTORY
22588 + This allows you to specify the number of entries in
22589 + the per-CPU history buffer.
22591 +config VSERVER_MONITOR
22592 + bool "VServer Scheduling Monitor"
22593 + depends on VSERVER_DISABLED
22596 + Set this to yes if you want to record the scheduling
22597 + decisions, so that they can be relayed to userspace
22598 + for detailed analysis.
22600 +config VSERVER_MONITOR_SIZE
22601 + int "Per-CPU Monitor Queue Size (32-65536)"
22602 + depends on VSERVER_MONITOR
22606 + This allows you to specify the number of entries in
22607 + the per-CPU scheduling monitor buffer.
22609 +config VSERVER_MONITOR_SYNC
22610 + int "Per-CPU Monitor Sync Interval (0-65536)"
22611 + depends on VSERVER_MONITOR
22615 + This allows you to specify the interval in ticks
22616 + when a time sync entry is inserted.
22624 + select NAMESPACES
22630 +config VSERVER_SECURITY
22632 + depends on SECURITY
22634 + select SECURITY_CAPABILITIES
22636 diff -NurpP --minimal linux-2.6.33/kernel/vserver/limit.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/limit.c
22637 --- linux-2.6.33/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
22638 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/limit.c 2010-03-02 21:45:20.000000000 +0100
22641 + * linux/kernel/vserver/limit.c
22643 + * Virtual Server: Context Limits
22645 + * Copyright (C) 2004-2010 Herbert Pötzl
22647 + * V0.01 broken out from vcontext V0.05
22648 + * V0.02 changed vcmds to vxi arg
22649 + * V0.03 added memory cgroup support
22653 +#include <linux/sched.h>
22654 +#include <linux/module.h>
22655 +#include <linux/memcontrol.h>
22656 +#include <linux/res_counter.h>
22657 +#include <linux/vs_limit.h>
22658 +#include <linux/vserver/limit.h>
22659 +#include <linux/vserver/limit_cmd.h>
22661 +#include <asm/uaccess.h>
22664 +const char *vlimit_name[NUM_LIMITS] = {
22665 + [RLIMIT_CPU] = "CPU",
22666 + [RLIMIT_RSS] = "RSS",
22667 + [RLIMIT_NPROC] = "NPROC",
22668 + [RLIMIT_NOFILE] = "NOFILE",
22669 + [RLIMIT_MEMLOCK] = "VML",
22670 + [RLIMIT_AS] = "VM",
22671 + [RLIMIT_LOCKS] = "LOCKS",
22672 + [RLIMIT_SIGPENDING] = "SIGP",
22673 + [RLIMIT_MSGQUEUE] = "MSGQ",
22675 + [VLIMIT_NSOCK] = "NSOCK",
22676 + [VLIMIT_OPENFD] = "OPENFD",
22677 + [VLIMIT_ANON] = "ANON",
22678 + [VLIMIT_SHMEM] = "SHMEM",
22679 + [VLIMIT_DENTRY] = "DENTRY",
22682 +EXPORT_SYMBOL_GPL(vlimit_name);
22684 +#define MASK_ENTRY(x) (1 << (x))
22686 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
22689 + , /* softlimit */
22690 + MASK_ENTRY( RLIMIT_RSS ) |
22691 + MASK_ENTRY( VLIMIT_ANON ) |
22694 + MASK_ENTRY( RLIMIT_RSS ) |
22695 + MASK_ENTRY( RLIMIT_NPROC ) |
22696 + MASK_ENTRY( RLIMIT_NOFILE ) |
22697 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
22698 + MASK_ENTRY( RLIMIT_AS ) |
22699 + MASK_ENTRY( RLIMIT_LOCKS ) |
22700 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
22702 + MASK_ENTRY( VLIMIT_NSOCK ) |
22703 + MASK_ENTRY( VLIMIT_OPENFD ) |
22704 + MASK_ENTRY( VLIMIT_ANON ) |
22705 + MASK_ENTRY( VLIMIT_SHMEM ) |
22706 + MASK_ENTRY( VLIMIT_DENTRY ) |
22709 + /* accounting only */
22710 +uint32_t account_mask =
22711 + MASK_ENTRY( VLIMIT_SEMARY ) |
22712 + MASK_ENTRY( VLIMIT_NSEMS ) |
22713 + MASK_ENTRY( VLIMIT_MAPPED ) |
22717 +static int is_valid_vlimit(int id)
22719 + uint32_t mask = vlimit_mask.minimum |
22720 + vlimit_mask.softlimit | vlimit_mask.maximum;
22721 + return mask & (1 << id);
22724 +static int is_accounted_vlimit(int id)
22726 + if (is_valid_vlimit(id))
22728 + return account_mask & (1 << id);
22732 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
22734 + rlim_t limit = __rlim_soft(&vxi->limit, id);
22735 + return VX_VLIM(limit);
22738 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
22740 + rlim_t limit = __rlim_hard(&vxi->limit, id);
22741 + return VX_VLIM(limit);
22744 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
22745 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
22747 + if (!is_valid_vlimit(id))
22751 + *minimum = CRLIM_UNSET;
22753 + *softlimit = vc_get_soft(vxi, id);
22755 + *maximum = vc_get_hard(vxi, id);
22759 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
22761 + struct vcmd_ctx_rlimit_v0 vc_data;
22764 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22767 + ret = do_get_rlimit(vxi, vc_data.id,
22768 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22772 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22777 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
22778 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
22780 + if (!is_valid_vlimit(id))
22783 + if (maximum != CRLIM_KEEP)
22784 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
22785 + if (softlimit != CRLIM_KEEP)
22786 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
22788 + /* clamp soft limit */
22789 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
22790 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
22795 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
22797 + struct vcmd_ctx_rlimit_v0 vc_data;
22799 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22802 + return do_set_rlimit(vxi, vc_data.id,
22803 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22806 +#ifdef CONFIG_IA32_EMULATION
22808 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
22810 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
22812 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22815 + return do_set_rlimit(vxi, vc_data.id,
22816 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22819 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
22821 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
22824 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22827 + ret = do_get_rlimit(vxi, vc_data.id,
22828 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22832 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22837 +#endif /* CONFIG_IA32_EMULATION */
22840 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
22842 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
22848 +static inline void vx_reset_hits(struct _vx_limit *limit)
22852 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22853 + atomic_set(&__rlim_lhit(limit, lim), 0);
22857 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
22859 + vx_reset_hits(&vxi->limit);
22863 +static inline void vx_reset_minmax(struct _vx_limit *limit)
22868 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22869 + value = __rlim_get(limit, lim);
22870 + __rlim_rmax(limit, lim) = value;
22871 + __rlim_rmin(limit, lim) = value;
22875 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
22877 + vx_reset_minmax(&vxi->limit);
22882 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
22884 + struct vcmd_rlimit_stat_v0 vc_data;
22885 + struct _vx_limit *limit = &vxi->limit;
22888 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22892 + if (!is_accounted_vlimit(id))
22895 + vx_limit_fixup(limit, id);
22896 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
22897 + vc_data.value = __rlim_get(limit, id);
22898 + vc_data.minimum = __rlim_rmin(limit, id);
22899 + vc_data.maximum = __rlim_rmax(limit, id);
22901 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22907 +void vx_vsi_meminfo(struct sysinfo *val)
22909 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22910 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22911 + u64 res_limit, res_usage;
22916 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22917 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22919 + if (res_limit != RESOURCE_MAX)
22920 + val->totalram = (res_limit >> PAGE_SHIFT);
22921 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
22922 + val->bufferram = 0;
22923 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR */
22924 + struct vx_info *vxi = current_vx_info();
22925 + unsigned long totalram, freeram;
22928 + /* we blindly accept the max */
22929 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22930 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
22932 + /* total minus used equals free */
22933 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22934 + freeram = (v < totalram) ? totalram - v : 0;
22936 + val->totalram = totalram;
22937 + val->freeram = freeram;
22938 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22939 + val->totalhigh = 0;
22940 + val->freehigh = 0;
22944 +void vx_vsi_swapinfo(struct sysinfo *val)
22946 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22947 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22948 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
22949 + s64 swap_limit, swap_usage;
22954 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22955 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22956 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22957 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22959 + if (res_limit == RESOURCE_MAX)
22962 + swap_limit = memsw_limit - res_limit;
22963 + if (memsw_limit != RESOURCE_MAX)
22964 + val->totalswap = swap_limit >> PAGE_SHIFT;
22966 + swap_usage = memsw_usage - res_usage;
22967 + val->freeswap = (swap_usage < swap_limit) ?
22968 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22969 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22970 + struct vx_info *vxi = current_vx_info();
22971 + unsigned long totalswap, freeswap;
22974 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22975 + if (v == RLIM_INFINITY) {
22976 + val->freeswap = val->totalswap;
22980 + /* we blindly accept the max */
22981 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
22982 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22984 + /* currently 'used' swap */
22985 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22986 + w -= (w > v) ? v : w;
22988 + /* total minus used equals free */
22989 + freeswap = (w < totalswap) ? totalswap - w : 0;
22991 + val->totalswap = totalswap;
22992 + val->freeswap = freeswap;
22993 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22997 +long vx_vsi_cached(struct sysinfo *val)
22999 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23000 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
23002 + return mem_cgroup_stat_read_cache(mcg);
23009 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
23011 + struct vx_info *vxi = mm->mm_vx_info;
23012 + unsigned long points;
23018 + points = vxi->vx_badness_bias;
23020 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23021 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23022 + points += (v > w) ? (v - w) : 0;
23027 diff -NurpP --minimal linux-2.6.33/kernel/vserver/limit_init.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/limit_init.h
23028 --- linux-2.6.33/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
23029 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/limit_init.h 2010-02-25 12:02:16.000000000 +0100
23033 +static inline void vx_info_init_limit(struct _vx_limit *limit)
23037 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23038 + __rlim_soft(limit, lim) = RLIM_INFINITY;
23039 + __rlim_hard(limit, lim) = RLIM_INFINITY;
23040 + __rlim_set(limit, lim, 0);
23041 + atomic_set(&__rlim_lhit(limit, lim), 0);
23042 + __rlim_rmin(limit, lim) = 0;
23043 + __rlim_rmax(limit, lim) = 0;
23047 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
23052 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23053 + if ((1 << lim) & VLIM_NOCHECK)
23055 + value = __rlim_get(limit, lim);
23056 + vxwprintk_xid(value,
23057 + "!!! limit: %p[%s,%d] = %ld on exit.",
23058 + limit, vlimit_name[lim], lim, (long)value);
23062 diff -NurpP --minimal linux-2.6.33/kernel/vserver/limit_proc.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/limit_proc.h
23063 --- linux-2.6.33/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
23064 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/limit_proc.h 2010-02-25 12:02:16.000000000 +0100
23066 +#ifndef _VX_LIMIT_PROC_H
23067 +#define _VX_LIMIT_PROC_H
23069 +#include <linux/vserver/limit_int.h>
23072 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
23073 +#define VX_LIMIT_TOP \
23074 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
23076 +#define VX_LIMIT_ARG(r) \
23077 + (unsigned long)__rlim_get(limit, r), \
23078 + (unsigned long)__rlim_rmin(limit, r), \
23079 + (unsigned long)__rlim_rmax(limit, r), \
23080 + VX_VLIM(__rlim_soft(limit, r)), \
23081 + VX_VLIM(__rlim_hard(limit, r)), \
23082 + atomic_read(&__rlim_lhit(limit, r))
23084 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
23086 + vx_limit_fixup(limit, -1);
23087 + return sprintf(buffer, VX_LIMIT_TOP
23088 + "PROC" VX_LIMIT_FMT
23089 + "VM" VX_LIMIT_FMT
23090 + "VML" VX_LIMIT_FMT
23091 + "RSS" VX_LIMIT_FMT
23092 + "ANON" VX_LIMIT_FMT
23093 + "RMAP" VX_LIMIT_FMT
23094 + "FILES" VX_LIMIT_FMT
23095 + "OFD" VX_LIMIT_FMT
23096 + "LOCKS" VX_LIMIT_FMT
23097 + "SOCK" VX_LIMIT_FMT
23098 + "MSGQ" VX_LIMIT_FMT
23099 + "SHM" VX_LIMIT_FMT
23100 + "SEMA" VX_LIMIT_FMT
23101 + "SEMS" VX_LIMIT_FMT
23102 + "DENT" VX_LIMIT_FMT,
23103 + VX_LIMIT_ARG(RLIMIT_NPROC),
23104 + VX_LIMIT_ARG(RLIMIT_AS),
23105 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
23106 + VX_LIMIT_ARG(RLIMIT_RSS),
23107 + VX_LIMIT_ARG(VLIMIT_ANON),
23108 + VX_LIMIT_ARG(VLIMIT_MAPPED),
23109 + VX_LIMIT_ARG(RLIMIT_NOFILE),
23110 + VX_LIMIT_ARG(VLIMIT_OPENFD),
23111 + VX_LIMIT_ARG(RLIMIT_LOCKS),
23112 + VX_LIMIT_ARG(VLIMIT_NSOCK),
23113 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
23114 + VX_LIMIT_ARG(VLIMIT_SHMEM),
23115 + VX_LIMIT_ARG(VLIMIT_SEMARY),
23116 + VX_LIMIT_ARG(VLIMIT_NSEMS),
23117 + VX_LIMIT_ARG(VLIMIT_DENTRY));
23120 +#endif /* _VX_LIMIT_PROC_H */
23123 diff -NurpP --minimal linux-2.6.33/kernel/vserver/Makefile linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/Makefile
23124 --- linux-2.6.33/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
23125 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/Makefile 2010-02-25 12:02:16.000000000 +0100
23128 +# Makefile for the Linux vserver routines.
23132 +obj-y += vserver.o
23134 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
23135 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
23138 +vserver-$(CONFIG_INET) += inet.o
23139 +vserver-$(CONFIG_PROC_FS) += proc.o
23140 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
23141 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
23142 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
23143 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
23145 diff -NurpP --minimal linux-2.6.33/kernel/vserver/monitor.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/monitor.c
23146 --- linux-2.6.33/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
23147 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/monitor.c 2010-02-25 12:02:16.000000000 +0100
23150 + * kernel/vserver/monitor.c
23152 + * Virtual Context Scheduler Monitor
23154 + * Copyright (C) 2006-2007 Herbert Pötzl
23156 + * V0.01 basic design
23160 +#include <linux/module.h>
23161 +#include <linux/jiffies.h>
23162 +#include <asm/uaccess.h>
23163 +#include <asm/atomic.h>
23165 +#include <linux/vserver/monitor.h>
23166 +#include <linux/vserver/debug_cmd.h>
23169 +#ifdef CONFIG_VSERVER_MONITOR
23170 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
23172 +#define VXM_SIZE 64
23175 +struct _vx_monitor {
23176 + unsigned int counter;
23178 + struct _vx_mon_entry entry[VXM_SIZE+1];
23182 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
23184 +unsigned volatile int vxm_active = 1;
23186 +static atomic_t sequence = ATOMIC_INIT(0);
23191 + * requires disabled preemption */
23193 +struct _vx_mon_entry *vxm_advance(int cpu)
23195 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
23196 + struct _vx_mon_entry *entry;
23197 + unsigned int index;
23199 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
23200 + entry = &mon->entry[index];
23202 + entry->ev.seq = atomic_inc_return(&sequence);
23203 + entry->ev.jif = jiffies;
23207 +EXPORT_SYMBOL_GPL(vxm_advance);
23210 +int do_read_monitor(struct __user _vx_mon_entry *data,
23211 + int cpu, uint32_t *index, uint32_t *count)
23213 + int pos, ret = 0;
23214 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
23215 + int end = mon->counter;
23216 + int start = end - VXM_SIZE + 2;
23217 + int idx = *index;
23219 + /* special case: get current pos */
23225 + /* have we lost some data? */
23229 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
23230 + struct _vx_mon_entry *entry =
23231 + &mon->entry[idx % VXM_SIZE];
23233 + /* send entry to userspace */
23234 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
23238 + /* save new index and count */
23241 + return ret ? ret : (*index < end);
23244 +int vc_read_monitor(uint32_t id, void __user *data)
23246 + struct vcmd_read_monitor_v0 vc_data;
23249 + if (id >= NR_CPUS)
23252 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23255 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
23256 + id, &vc_data.index, &vc_data.count);
23258 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23263 +#ifdef CONFIG_COMPAT
23265 +int vc_read_monitor_x32(uint32_t id, void __user *data)
23267 + struct vcmd_read_monitor_v0_x32 vc_data;
23270 + if (id >= NR_CPUS)
23273 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23276 + ret = do_read_monitor((struct __user _vx_mon_entry *)
23277 + compat_ptr(vc_data.data_ptr),
23278 + id, &vc_data.index, &vc_data.count);
23280 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23285 +#endif /* CONFIG_COMPAT */
23287 diff -NurpP --minimal linux-2.6.33/kernel/vserver/network.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/network.c
23288 --- linux-2.6.33/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
23289 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/network.c 2010-02-25 12:02:16.000000000 +0100
23292 + * linux/kernel/vserver/network.c
23294 + * Virtual Server: Network Support
23296 + * Copyright (C) 2003-2007 Herbert Pötzl
23298 + * V0.01 broken out from vcontext V0.05
23299 + * V0.02 cleaned up implementation
23300 + * V0.03 added equiv nx commands
23301 + * V0.04 switch to RCU based hash
23302 + * V0.05 and back to locking again
23303 + * V0.06 changed vcmds to nxi arg
23304 + * V0.07 have __create claim() the nxi
23308 +#include <linux/err.h>
23309 +#include <linux/slab.h>
23310 +#include <linux/rcupdate.h>
23312 +#include <linux/vs_network.h>
23313 +#include <linux/vs_pid.h>
23314 +#include <linux/vserver/network_cmd.h>
23317 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
23318 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
23320 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
23321 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
23324 +static int __init init_network(void)
23326 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
23327 + sizeof(struct nx_addr_v4), 0,
23328 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
23329 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
23330 + sizeof(struct nx_addr_v6), 0,
23331 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
23336 +/* __alloc_nx_addr_v4() */
23338 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
23340 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
23341 + nx_addr_v4_cachep, GFP_KERNEL);
23343 + if (!IS_ERR(nxa))
23344 + memset(nxa, 0, sizeof(*nxa));
23348 +/* __dealloc_nx_addr_v4() */
23350 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
23352 + kmem_cache_free(nx_addr_v4_cachep, nxa);
23355 +/* __dealloc_nx_addr_v4_all() */
23357 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
23360 + struct nx_addr_v4 *next = nxa->next;
23362 + __dealloc_nx_addr_v4(nxa);
23368 +#ifdef CONFIG_IPV6
23370 +/* __alloc_nx_addr_v6() */
23372 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
23374 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
23375 + nx_addr_v6_cachep, GFP_KERNEL);
23377 + if (!IS_ERR(nxa))
23378 + memset(nxa, 0, sizeof(*nxa));
23382 +/* __dealloc_nx_addr_v6() */
23384 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
23386 + kmem_cache_free(nx_addr_v6_cachep, nxa);
23389 +/* __dealloc_nx_addr_v6_all() */
23391 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
23394 + struct nx_addr_v6 *next = nxa->next;
23396 + __dealloc_nx_addr_v6(nxa);
23401 +#endif /* CONFIG_IPV6 */
23403 +/* __alloc_nx_info()
23405 + * allocate an initialized nx_info struct
23406 + * doesn't make it visible (hash) */
23408 +static struct nx_info *__alloc_nx_info(nid_t nid)
23410 + struct nx_info *new = NULL;
23412 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
23414 + /* would this benefit from a slab cache? */
23415 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
23419 + memset(new, 0, sizeof(struct nx_info));
23420 + new->nx_id = nid;
23421 + INIT_HLIST_NODE(&new->nx_hlist);
23422 + atomic_set(&new->nx_usecnt, 0);
23423 + atomic_set(&new->nx_tasks, 0);
23424 + new->nx_state = 0;
23426 + new->nx_flags = NXF_INIT_SET;
23428 + /* rest of init goes here */
23430 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
23431 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
23433 + vxdprintk(VXD_CBIT(nid, 0),
23434 + "alloc_nx_info(%d) = %p", nid, new);
23435 + atomic_inc(&nx_global_ctotal);
23439 +/* __dealloc_nx_info()
23441 + * final disposal of nx_info */
23443 +static void __dealloc_nx_info(struct nx_info *nxi)
23445 + vxdprintk(VXD_CBIT(nid, 0),
23446 + "dealloc_nx_info(%p)", nxi);
23448 + nxi->nx_hlist.next = LIST_POISON1;
23451 + BUG_ON(atomic_read(&nxi->nx_usecnt));
23452 + BUG_ON(atomic_read(&nxi->nx_tasks));
23454 + __dealloc_nx_addr_v4_all(nxi->v4.next);
23456 + nxi->nx_state |= NXS_RELEASED;
23458 + atomic_dec(&nx_global_ctotal);
23461 +static void __shutdown_nx_info(struct nx_info *nxi)
23463 + nxi->nx_state |= NXS_SHUTDOWN;
23464 + vs_net_change(nxi, VSC_NETDOWN);
23467 +/* exported stuff */
23469 +void free_nx_info(struct nx_info *nxi)
23471 + /* context shutdown is mandatory */
23472 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
23474 + /* context must not be hashed */
23475 + BUG_ON(nxi->nx_state & NXS_HASHED);
23477 + BUG_ON(atomic_read(&nxi->nx_usecnt));
23478 + BUG_ON(atomic_read(&nxi->nx_tasks));
23480 + __dealloc_nx_info(nxi);
23484 +void __nx_set_lback(struct nx_info *nxi)
23486 + int nid = nxi->nx_id;
23487 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
23489 + nxi->v4_lback.s_addr = lback;
23492 +extern int __nx_inet_add_lback(__be32 addr);
23493 +extern int __nx_inet_del_lback(__be32 addr);
23496 +/* hash table for nx_info hash */
23498 +#define NX_HASH_SIZE 13
23500 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
23502 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
23505 +static inline unsigned int __hashval(nid_t nid)
23507 + return (nid % NX_HASH_SIZE);
23512 +/* __hash_nx_info()
23514 + * add the nxi to the global hash table
23515 + * requires the hash_lock to be held */
23517 +static inline void __hash_nx_info(struct nx_info *nxi)
23519 + struct hlist_head *head;
23521 + vxd_assert_lock(&nx_info_hash_lock);
23522 + vxdprintk(VXD_CBIT(nid, 4),
23523 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
23525 + /* context must not be hashed */
23526 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
23528 + nxi->nx_state |= NXS_HASHED;
23529 + head = &nx_info_hash[__hashval(nxi->nx_id)];
23530 + hlist_add_head(&nxi->nx_hlist, head);
23531 + atomic_inc(&nx_global_cactive);
23534 +/* __unhash_nx_info()
23536 + * remove the nxi from the global hash table
23537 + * requires the hash_lock to be held */
23539 +static inline void __unhash_nx_info(struct nx_info *nxi)
23541 + vxd_assert_lock(&nx_info_hash_lock);
23542 + vxdprintk(VXD_CBIT(nid, 4),
23543 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
23544 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
23546 + /* context must be hashed */
23547 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
23548 + /* but without tasks */
23549 + BUG_ON(atomic_read(&nxi->nx_tasks));
23551 + nxi->nx_state &= ~NXS_HASHED;
23552 + hlist_del(&nxi->nx_hlist);
23553 + atomic_dec(&nx_global_cactive);
23557 +/* __lookup_nx_info()
23559 + * requires the hash_lock to be held
23560 + * doesn't increment the nx_refcnt */
23562 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
23564 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
23565 + struct hlist_node *pos;
23566 + struct nx_info *nxi;
23568 + vxd_assert_lock(&nx_info_hash_lock);
23569 + hlist_for_each(pos, head) {
23570 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
23572 + if (nxi->nx_id == nid)
23577 + vxdprintk(VXD_CBIT(nid, 0),
23578 + "__lookup_nx_info(#%u): %p[#%u]",
23579 + nid, nxi, nxi ? nxi->nx_id : 0);
23584 +/* __create_nx_info()
23586 + * create the requested context
23587 + * get(), claim() and hash it */
23589 +static struct nx_info *__create_nx_info(int id)
23591 + struct nx_info *new, *nxi = NULL;
23593 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
23595 + if (!(new = __alloc_nx_info(id)))
23596 + return ERR_PTR(-ENOMEM);
23598 + /* required to make dynamic xids unique */
23599 + spin_lock(&nx_info_hash_lock);
23601 + /* static context requested */
23602 + if ((nxi = __lookup_nx_info(id))) {
23603 + vxdprintk(VXD_CBIT(nid, 0),
23604 + "create_nx_info(%d) = %p (already there)", id, nxi);
23605 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
23606 + nxi = ERR_PTR(-EBUSY);
23608 + nxi = ERR_PTR(-EEXIST);
23611 + /* new context */
23612 + vxdprintk(VXD_CBIT(nid, 0),
23613 + "create_nx_info(%d) = %p (new)", id, new);
23614 + claim_nx_info(new, NULL);
23615 + __nx_set_lback(new);
23616 + __hash_nx_info(get_nx_info(new));
23617 + nxi = new, new = NULL;
23620 + spin_unlock(&nx_info_hash_lock);
23622 + __dealloc_nx_info(new);
23628 +/* exported stuff */
23631 +void unhash_nx_info(struct nx_info *nxi)
23633 + __shutdown_nx_info(nxi);
23634 + spin_lock(&nx_info_hash_lock);
23635 + __unhash_nx_info(nxi);
23636 + spin_unlock(&nx_info_hash_lock);
23639 +/* lookup_nx_info()
23641 + * search for a nx_info and get() it
23642 + * negative id means current */
23644 +struct nx_info *lookup_nx_info(int id)
23646 + struct nx_info *nxi = NULL;
23649 + nxi = get_nx_info(current_nx_info());
23650 + } else if (id > 1) {
23651 + spin_lock(&nx_info_hash_lock);
23652 + nxi = get_nx_info(__lookup_nx_info(id));
23653 + spin_unlock(&nx_info_hash_lock);
23658 +/* nid_is_hashed()
23660 + * verify that nid is still hashed */
23662 +int nid_is_hashed(nid_t nid)
23666 + spin_lock(&nx_info_hash_lock);
23667 + hashed = (__lookup_nx_info(nid) != NULL);
23668 + spin_unlock(&nx_info_hash_lock);
23673 +#ifdef CONFIG_PROC_FS
23677 + * get a subset of hashed nids for proc
23678 + * assumes size is at least one */
23680 +int get_nid_list(int index, unsigned int *nids, int size)
23682 + int hindex, nr_nids = 0;
23684 + /* only show current and children */
23685 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
23688 + nids[nr_nids] = nx_current_nid();
23692 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
23693 + struct hlist_head *head = &nx_info_hash[hindex];
23694 + struct hlist_node *pos;
23696 + spin_lock(&nx_info_hash_lock);
23697 + hlist_for_each(pos, head) {
23698 + struct nx_info *nxi;
23703 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
23704 + nids[nr_nids] = nxi->nx_id;
23705 + if (++nr_nids >= size) {
23706 + spin_unlock(&nx_info_hash_lock);
23710 + /* keep the lock time short */
23711 + spin_unlock(&nx_info_hash_lock);
23720 + * migrate task to new network
23721 + * gets nxi, puts old_nxi on change
23724 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
23726 + struct nx_info *old_nxi;
23732 + vxdprintk(VXD_CBIT(nid, 5),
23733 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
23734 + p, nxi, nxi->nx_id,
23735 + atomic_read(&nxi->nx_usecnt),
23736 + atomic_read(&nxi->nx_tasks));
23738 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
23739 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
23742 + if (nx_info_state(nxi, NXS_SHUTDOWN))
23745 + /* maybe disallow this completely? */
23746 + old_nxi = task_get_nx_info(p);
23747 + if (old_nxi == nxi)
23752 + clr_nx_info(&p->nx_info);
23753 + claim_nx_info(nxi, p);
23754 + set_nx_info(&p->nx_info, nxi);
23755 + p->nid = nxi->nx_id;
23758 + vxdprintk(VXD_CBIT(nid, 5),
23759 + "moved task %p into nxi:%p[#%d]",
23760 + p, nxi, nxi->nx_id);
23763 + release_nx_info(old_nxi, p);
23766 + put_nx_info(old_nxi);
23771 +void nx_set_persistent(struct nx_info *nxi)
23773 + vxdprintk(VXD_CBIT(nid, 6),
23774 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
23776 + get_nx_info(nxi);
23777 + claim_nx_info(nxi, NULL);
23780 +void nx_clear_persistent(struct nx_info *nxi)
23782 + vxdprintk(VXD_CBIT(nid, 6),
23783 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
23785 + release_nx_info(nxi, NULL);
23786 + put_nx_info(nxi);
23789 +void nx_update_persistent(struct nx_info *nxi)
23791 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
23792 + nx_set_persistent(nxi);
23794 + nx_clear_persistent(nxi);
23797 +/* vserver syscall commands below here */
23799 +/* taks nid and nx_info functions */
23801 +#include <asm/uaccess.h>
23804 +int vc_task_nid(uint32_t id)
23809 + struct task_struct *tsk;
23811 + read_lock(&tasklist_lock);
23812 + tsk = find_task_by_real_pid(id);
23813 + nid = (tsk) ? tsk->nid : -ESRCH;
23814 + read_unlock(&tasklist_lock);
23816 + nid = nx_current_nid();
23821 +int vc_nx_info(struct nx_info *nxi, void __user *data)
23823 + struct vcmd_nx_info_v0 vc_data;
23825 + vc_data.nid = nxi->nx_id;
23827 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23833 +/* network functions */
23835 +int vc_net_create(uint32_t nid, void __user *data)
23837 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
23838 + struct nx_info *new_nxi;
23841 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23844 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
23847 + new_nxi = __create_nx_info(nid);
23848 + if (IS_ERR(new_nxi))
23849 + return PTR_ERR(new_nxi);
23851 + /* initial flags */
23852 + new_nxi->nx_flags = vc_data.flagword;
23855 + if (vs_net_change(new_nxi, VSC_NETUP))
23858 + ret = nx_migrate_task(current, new_nxi);
23862 + /* return context id on success */
23863 + ret = new_nxi->nx_id;
23865 + /* get a reference for persistent contexts */
23866 + if ((vc_data.flagword & NXF_PERSISTENT))
23867 + nx_set_persistent(new_nxi);
23869 + release_nx_info(new_nxi, NULL);
23870 + put_nx_info(new_nxi);
23875 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
23877 + return nx_migrate_task(current, nxi);
23882 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
23883 + uint16_t type, uint16_t flags)
23885 + struct nx_addr_v4 *nxa = &nxi->v4;
23887 + if (NX_IPV4(nxi)) {
23888 + /* locate last entry */
23889 + for (; nxa->next; nxa = nxa->next);
23890 + nxa->next = __alloc_nx_addr_v4();
23894 + return PTR_ERR(nxa);
23897 + if (nxi->v4.next)
23898 + /* remove single ip for ip list */
23899 + nxi->nx_flags &= ~NXF_SINGLE_IP;
23901 + nxa->ip[0].s_addr = ip;
23902 + nxa->ip[1].s_addr = ip2;
23903 + nxa->mask.s_addr = mask;
23904 + nxa->type = type;
23905 + nxa->flags = flags;
23910 +int vc_net_add(struct nx_info *nxi, void __user *data)
23912 + struct vcmd_net_addr_v0 vc_data;
23913 + int index, ret = 0;
23915 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23918 + switch (vc_data.type) {
23919 + case NXA_TYPE_IPV4:
23920 + if ((vc_data.count < 1) || (vc_data.count > 4))
23924 + while (index < vc_data.count) {
23925 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
23926 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
23934 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23935 + nxi->v4_bcast = vc_data.ip[0];
23939 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
23940 + nxi->v4_lback = vc_data.ip[0];
23951 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23953 + struct vcmd_net_addr_v0 vc_data;
23955 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23958 + switch (vc_data.type) {
23959 + case NXA_TYPE_ANY:
23960 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23961 + memset(&nxi->v4, 0, sizeof(nxi->v4));
23971 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23973 + struct vcmd_net_addr_ipv4_v1 vc_data;
23975 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23978 + switch (vc_data.type) {
23979 + case NXA_TYPE_ADDR:
23980 + case NXA_TYPE_RANGE:
23981 + case NXA_TYPE_MASK:
23982 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23983 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23985 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23986 + nxi->v4_bcast = vc_data.ip;
23989 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23990 + nxi->v4_lback = vc_data.ip;
23999 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
24001 + struct vcmd_net_addr_ipv4_v1 vc_data;
24003 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24006 + switch (vc_data.type) {
24007 +/* case NXA_TYPE_ADDR:
24010 + case NXA_TYPE_ANY:
24011 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24012 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24022 +#ifdef CONFIG_IPV6
24024 +int do_add_v6_addr(struct nx_info *nxi,
24025 + struct in6_addr *ip, struct in6_addr *mask,
24026 + uint32_t prefix, uint16_t type, uint16_t flags)
24028 + struct nx_addr_v6 *nxa = &nxi->v6;
24030 + if (NX_IPV6(nxi)) {
24031 + /* locate last entry */
24032 + for (; nxa->next; nxa = nxa->next);
24033 + nxa->next = __alloc_nx_addr_v6();
24037 + return PTR_ERR(nxa);
24041 + nxa->mask = *mask;
24042 + nxa->prefix = prefix;
24043 + nxa->type = type;
24044 + nxa->flags = flags;
24049 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
24051 + struct vcmd_net_addr_ipv6_v1 vc_data;
24053 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24056 + switch (vc_data.type) {
24057 + case NXA_TYPE_ADDR:
24058 + case NXA_TYPE_MASK:
24059 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
24060 + vc_data.prefix, vc_data.type, vc_data.flags);
24067 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
24069 + struct vcmd_net_addr_ipv6_v1 vc_data;
24071 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24074 + switch (vc_data.type) {
24075 + case NXA_TYPE_ANY:
24076 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
24077 + memset(&nxi->v6, 0, sizeof(nxi->v6));
24086 +#endif /* CONFIG_IPV6 */
24089 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
24091 + struct vcmd_net_flags_v0 vc_data;
24093 + vc_data.flagword = nxi->nx_flags;
24095 + /* special STATE flag handling */
24096 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
24098 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24103 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
24105 + struct vcmd_net_flags_v0 vc_data;
24106 + uint64_t mask, trigger;
24108 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24111 + /* special STATE flag handling */
24112 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
24113 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
24115 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
24116 + vc_data.flagword, mask);
24117 + if (trigger & NXF_PERSISTENT)
24118 + nx_update_persistent(nxi);
24123 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
24125 + struct vcmd_net_caps_v0 vc_data;
24127 + vc_data.ncaps = nxi->nx_ncaps;
24128 + vc_data.cmask = ~0ULL;
24130 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24135 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
24137 + struct vcmd_net_caps_v0 vc_data;
24139 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24142 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
24143 + vc_data.ncaps, vc_data.cmask);
24148 +#include <linux/module.h>
24150 +module_init(init_network);
24152 +EXPORT_SYMBOL_GPL(free_nx_info);
24153 +EXPORT_SYMBOL_GPL(unhash_nx_info);
24155 diff -NurpP --minimal linux-2.6.33/kernel/vserver/proc.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/proc.c
24156 --- linux-2.6.33/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
24157 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/proc.c 2010-02-25 12:02:16.000000000 +0100
24160 + * linux/kernel/vserver/proc.c
24162 + * Virtual Context Support
24164 + * Copyright (C) 2003-2007 Herbert Pötzl
24166 + * V0.01 basic structure
24167 + * V0.02 adaptation vs1.3.0
24168 + * V0.03 proc permissions
24169 + * V0.04 locking/generic
24170 + * V0.05 next generation procfs
24171 + * V0.06 inode validation
24172 + * V0.07 generic rewrite vid
24173 + * V0.08 remove inode type
24177 +#include <linux/proc_fs.h>
24178 +#include <linux/fs_struct.h>
24179 +#include <linux/mount.h>
24180 +#include <asm/unistd.h>
24182 +#include <linux/vs_context.h>
24183 +#include <linux/vs_network.h>
24184 +#include <linux/vs_cvirt.h>
24186 +#include <linux/in.h>
24187 +#include <linux/inetdevice.h>
24188 +#include <linux/vs_inet.h>
24189 +#include <linux/vs_inet6.h>
24191 +#include <linux/vserver/global.h>
24193 +#include "cvirt_proc.h"
24194 +#include "cacct_proc.h"
24195 +#include "limit_proc.h"
24196 +#include "sched_proc.h"
24197 +#include "vci_config.h"
24200 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
24204 + CAP_FOR_EACH_U32(__capi) {
24205 + buffer += sprintf(buffer, "%08x",
24206 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
24212 +static struct proc_dir_entry *proc_virtual;
24214 +static struct proc_dir_entry *proc_virtnet;
24217 +/* first the actual feeds */
24220 +static int proc_vci(char *buffer)
24222 + return sprintf(buffer,
24223 + "VCIVersion:\t%04x:%04x\n"
24224 + "VCISyscall:\t%d\n"
24225 + "VCIKernel:\t%08x\n",
24226 + VCI_VERSION >> 16,
24227 + VCI_VERSION & 0xFFFF,
24229 + vci_kernel_config());
24232 +static int proc_virtual_info(char *buffer)
24234 + return proc_vci(buffer);
24237 +static int proc_virtual_status(char *buffer)
24239 + return sprintf(buffer,
24241 + "#CActive:\t%d\n"
24242 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
24243 + "#InitTask:\t%d\t%d %d\n",
24244 + atomic_read(&vx_global_ctotal),
24245 + atomic_read(&vx_global_cactive),
24246 + atomic_read(&vs_global_nsproxy),
24247 + atomic_read(&vs_global_fs),
24248 + atomic_read(&vs_global_mnt_ns),
24249 + atomic_read(&vs_global_uts_ns),
24250 + atomic_read(&nr_ipc_ns),
24251 + atomic_read(&vs_global_user_ns),
24252 + atomic_read(&vs_global_pid_ns),
24253 + atomic_read(&init_task.usage),
24254 + atomic_read(&init_task.nsproxy->count),
24255 + init_task.fs->users);
24259 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
24263 + length = sprintf(buffer,
24271 + vxi->vx_badness_bias);
24275 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
24277 + char *orig = buffer;
24279 + buffer += sprintf(buffer,
24282 + "Flags:\t%016llx\n",
24283 + atomic_read(&vxi->vx_usecnt),
24284 + atomic_read(&vxi->vx_tasks),
24285 + (unsigned long long)vxi->vx_flags);
24287 + buffer += sprintf(buffer, "BCaps:\t");
24288 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24289 + buffer += sprintf(buffer, "\n");
24291 + buffer += sprintf(buffer,
24292 + "CCaps:\t%016llx\n"
24293 + "Spaces:\t%08lx %08lx\n",
24294 + (unsigned long long)vxi->vx_ccaps,
24295 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
24296 + return buffer - orig;
24299 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
24301 + return vx_info_proc_limit(&vxi->limit, buffer);
24304 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
24308 + length = vx_info_proc_sched(&vxi->sched, buffer);
24309 + for_each_online_cpu(cpu) {
24310 + length += vx_info_proc_sched_pc(
24311 + &vx_per_cpu(vxi, sched_pc, cpu),
24312 + buffer + length, cpu);
24317 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
24319 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
24322 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
24324 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
24327 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
24331 + vx_update_load(vxi);
24332 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
24333 + for_each_online_cpu(cpu) {
24334 + length += vx_info_proc_cvirt_pc(
24335 + &vx_per_cpu(vxi, cvirt_pc, cpu),
24336 + buffer + length, cpu);
24341 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
24343 + return vx_info_proc_cacct(&vxi->cacct, buffer);
24347 +static int proc_virtnet_info(char *buffer)
24349 + return proc_vci(buffer);
24352 +static int proc_virtnet_status(char *buffer)
24354 + return sprintf(buffer,
24356 + "#CActive:\t%d\n",
24357 + atomic_read(&nx_global_ctotal),
24358 + atomic_read(&nx_global_cactive));
24361 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
24363 + struct nx_addr_v4 *v4a;
24364 +#ifdef CONFIG_IPV6
24365 + struct nx_addr_v6 *v6a;
24369 + length = sprintf(buffer,
24372 + "Bcast:\t" NIPQUAD_FMT "\n"
24373 + "Lback:\t" NIPQUAD_FMT "\n",
24376 + NIPQUAD(nxi->v4_bcast.s_addr),
24377 + NIPQUAD(nxi->v4_lback.s_addr));
24379 + if (!NX_IPV4(nxi))
24381 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24382 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
24385 +#ifdef CONFIG_IPV6
24386 + if (!NX_IPV6(nxi))
24388 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24389 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
24396 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
24400 + length = sprintf(buffer,
24403 + "Flags:\t%016llx\n"
24404 + "NCaps:\t%016llx\n",
24405 + atomic_read(&nxi->nx_usecnt),
24406 + atomic_read(&nxi->nx_tasks),
24407 + (unsigned long long)nxi->nx_flags,
24408 + (unsigned long long)nxi->nx_ncaps);
24414 +/* here the inode helpers */
24420 + struct inode_operations *iop;
24421 + struct file_operations *fop;
24422 + union proc_op op;
24425 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
24427 + struct inode *inode = new_inode(sb);
24432 + inode->i_mode = p->mode;
24434 + inode->i_op = p->iop;
24436 + inode->i_fop = p->fop;
24438 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
24439 + inode->i_flags |= S_IMMUTABLE;
24441 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
24443 + inode->i_uid = 0;
24444 + inode->i_gid = 0;
24445 + inode->i_tag = 0;
24450 +static struct dentry *vs_proc_instantiate(struct inode *dir,
24451 + struct dentry *dentry, int id, void *ptr)
24453 + struct vs_entry *p = ptr;
24454 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
24455 + struct dentry *error = ERR_PTR(-EINVAL);
24460 + PROC_I(inode)->op = p->op;
24461 + PROC_I(inode)->fd = id;
24462 + d_add(dentry, inode);
24470 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
24473 + * Fill a directory entry.
24475 + * If possible create the dcache entry and derive our inode number and
24476 + * file type from dcache entry.
24478 + * Since all of the proc inode numbers are dynamically generated, the inode
24479 + * numbers do not exist until the inode is cache. This means creating the
24480 + * the dcache entry in readdir is necessary to keep the inode numbers
24481 + * reported by readdir in sync with the inode numbers reported
24484 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
24485 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
24487 + struct dentry *child, *dir = filp->f_dentry;
24488 + struct inode *inode;
24489 + struct qstr qname;
24491 + unsigned type = DT_UNKNOWN;
24493 + qname.name = name;
24495 + qname.hash = full_name_hash(name, len);
24497 + child = d_lookup(dir, &qname);
24499 + struct dentry *new;
24500 + new = d_alloc(dir, &qname);
24502 + child = instantiate(dir->d_inode, new, id, ptr);
24509 + if (!child || IS_ERR(child) || !child->d_inode)
24510 + goto end_instantiate;
24511 + inode = child->d_inode;
24513 + ino = inode->i_ino;
24514 + type = inode->i_mode >> 12;
24519 + ino = find_inode_number(dir, &qname);
24522 + return filldir(dirent, name, len, filp->f_pos, ino, type);
24527 +/* get and revalidate vx_info/xid */
24530 +struct vx_info *get_proc_vx_info(struct inode *inode)
24532 + return lookup_vx_info(PROC_I(inode)->fd);
24535 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
24537 + struct inode *inode = dentry->d_inode;
24538 + xid_t xid = PROC_I(inode)->fd;
24540 + if (!xid || xid_is_hashed(xid))
24547 +/* get and revalidate nx_info/nid */
24549 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
24551 + struct inode *inode = dentry->d_inode;
24552 + nid_t nid = PROC_I(inode)->fd;
24554 + if (!nid || nid_is_hashed(nid))
24562 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
24564 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
24565 + size_t count, loff_t *ppos)
24567 + struct inode *inode = file->f_dentry->d_inode;
24568 + unsigned long page;
24569 + ssize_t length = 0;
24571 + if (count > PROC_BLOCK_SIZE)
24572 + count = PROC_BLOCK_SIZE;
24574 + /* fade that out as soon as stable */
24575 + WARN_ON(PROC_I(inode)->fd);
24577 + if (!(page = __get_free_page(GFP_KERNEL)))
24580 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
24581 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
24584 + length = simple_read_from_buffer(buf, count, ppos,
24585 + (char *)page, length);
24591 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
24592 + size_t count, loff_t *ppos)
24594 + struct inode *inode = file->f_dentry->d_inode;
24595 + struct vx_info *vxi = NULL;
24596 + xid_t xid = PROC_I(inode)->fd;
24597 + unsigned long page;
24598 + ssize_t length = 0;
24600 + if (count > PROC_BLOCK_SIZE)
24601 + count = PROC_BLOCK_SIZE;
24603 + /* fade that out as soon as stable */
24605 + vxi = lookup_vx_info(xid);
24609 + length = -ENOMEM;
24610 + if (!(page = __get_free_page(GFP_KERNEL)))
24613 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
24614 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
24617 + length = simple_read_from_buffer(buf, count, ppos,
24618 + (char *)page, length);
24622 + put_vx_info(vxi);
24627 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
24628 + size_t count, loff_t *ppos)
24630 + struct inode *inode = file->f_dentry->d_inode;
24631 + struct nx_info *nxi = NULL;
24632 + nid_t nid = PROC_I(inode)->fd;
24633 + unsigned long page;
24634 + ssize_t length = 0;
24636 + if (count > PROC_BLOCK_SIZE)
24637 + count = PROC_BLOCK_SIZE;
24639 + /* fade that out as soon as stable */
24641 + nxi = lookup_nx_info(nid);
24645 + length = -ENOMEM;
24646 + if (!(page = __get_free_page(GFP_KERNEL)))
24649 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
24650 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
24653 + length = simple_read_from_buffer(buf, count, ppos,
24654 + (char *)page, length);
24658 + put_nx_info(nxi);
24665 +/* here comes the lower level */
24668 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
24669 + .len = sizeof(NAME) - 1, \
24670 + .name = (NAME), \
24678 +#define DIR(NAME, MODE, OTYPE) \
24679 + NOD(NAME, (S_IFDIR | (MODE)), \
24680 + &proc_ ## OTYPE ## _inode_operations, \
24681 + &proc_ ## OTYPE ## _file_operations, { } )
24683 +#define INF(NAME, MODE, OTYPE) \
24684 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
24685 + &proc_vs_info_file_operations, \
24686 + { .proc_vs_read = &proc_##OTYPE } )
24688 +#define VINF(NAME, MODE, OTYPE) \
24689 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
24690 + &proc_vx_info_file_operations, \
24691 + { .proc_vxi_read = &proc_##OTYPE } )
24693 +#define NINF(NAME, MODE, OTYPE) \
24694 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
24695 + &proc_nx_info_file_operations, \
24696 + { .proc_nxi_read = &proc_##OTYPE } )
24699 +static struct file_operations proc_vs_info_file_operations = {
24700 + .read = proc_vs_info_read,
24703 +static struct file_operations proc_vx_info_file_operations = {
24704 + .read = proc_vx_info_read,
24707 +static struct dentry_operations proc_xid_dentry_operations = {
24708 + .d_revalidate = proc_xid_revalidate,
24711 +static struct vs_entry vx_base_stuff[] = {
24712 + VINF("info", S_IRUGO, vxi_info),
24713 + VINF("status", S_IRUGO, vxi_status),
24714 + VINF("limit", S_IRUGO, vxi_limit),
24715 + VINF("sched", S_IRUGO, vxi_sched),
24716 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
24717 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
24718 + VINF("cvirt", S_IRUGO, vxi_cvirt),
24719 + VINF("cacct", S_IRUGO, vxi_cacct),
24726 +static struct dentry *proc_xid_instantiate(struct inode *dir,
24727 + struct dentry *dentry, int id, void *ptr)
24729 + dentry->d_op = &proc_xid_dentry_operations;
24730 + return vs_proc_instantiate(dir, dentry, id, ptr);
24733 +static struct dentry *proc_xid_lookup(struct inode *dir,
24734 + struct dentry *dentry, struct nameidata *nd)
24736 + struct vs_entry *p = vx_base_stuff;
24737 + struct dentry *error = ERR_PTR(-ENOENT);
24739 + for (; p->name; p++) {
24740 + if (p->len != dentry->d_name.len)
24742 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24748 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
24753 +static int proc_xid_readdir(struct file *filp,
24754 + void *dirent, filldir_t filldir)
24756 + struct dentry *dentry = filp->f_dentry;
24757 + struct inode *inode = dentry->d_inode;
24758 + struct vs_entry *p = vx_base_stuff;
24759 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
24763 + pos = filp->f_pos;
24766 + ino = inode->i_ino;
24767 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24770 + /* fall through */
24772 + ino = parent_ino(dentry);
24773 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24776 + /* fall through */
24779 + if (index >= size)
24781 + for (p += index; p->name; p++) {
24782 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24783 + vs_proc_instantiate, PROC_I(inode)->fd, p))
24789 + filp->f_pos = pos;
24795 +static struct file_operations proc_nx_info_file_operations = {
24796 + .read = proc_nx_info_read,
24799 +static struct dentry_operations proc_nid_dentry_operations = {
24800 + .d_revalidate = proc_nid_revalidate,
24803 +static struct vs_entry nx_base_stuff[] = {
24804 + NINF("info", S_IRUGO, nxi_info),
24805 + NINF("status", S_IRUGO, nxi_status),
24810 +static struct dentry *proc_nid_instantiate(struct inode *dir,
24811 + struct dentry *dentry, int id, void *ptr)
24813 + dentry->d_op = &proc_nid_dentry_operations;
24814 + return vs_proc_instantiate(dir, dentry, id, ptr);
24817 +static struct dentry *proc_nid_lookup(struct inode *dir,
24818 + struct dentry *dentry, struct nameidata *nd)
24820 + struct vs_entry *p = nx_base_stuff;
24821 + struct dentry *error = ERR_PTR(-ENOENT);
24823 + for (; p->name; p++) {
24824 + if (p->len != dentry->d_name.len)
24826 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24832 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
24837 +static int proc_nid_readdir(struct file *filp,
24838 + void *dirent, filldir_t filldir)
24840 + struct dentry *dentry = filp->f_dentry;
24841 + struct inode *inode = dentry->d_inode;
24842 + struct vs_entry *p = nx_base_stuff;
24843 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
24847 + pos = filp->f_pos;
24850 + ino = inode->i_ino;
24851 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24854 + /* fall through */
24856 + ino = parent_ino(dentry);
24857 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24860 + /* fall through */
24863 + if (index >= size)
24865 + for (p += index; p->name; p++) {
24866 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24867 + vs_proc_instantiate, PROC_I(inode)->fd, p))
24873 + filp->f_pos = pos;
24878 +#define MAX_MULBY10 ((~0U - 9) / 10)
24880 +static inline int atovid(const char *str, int len)
24885 + while (len-- > 0) {
24890 + if (vid >= MAX_MULBY10)
24900 +/* now the upper level (virtual) */
24903 +static struct file_operations proc_xid_file_operations = {
24904 + .read = generic_read_dir,
24905 + .readdir = proc_xid_readdir,
24908 +static struct inode_operations proc_xid_inode_operations = {
24909 + .lookup = proc_xid_lookup,
24912 +static struct vs_entry vx_virtual_stuff[] = {
24913 + INF("info", S_IRUGO, virtual_info),
24914 + INF("status", S_IRUGO, virtual_status),
24915 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
24919 +static struct dentry *proc_virtual_lookup(struct inode *dir,
24920 + struct dentry *dentry, struct nameidata *nd)
24922 + struct vs_entry *p = vx_virtual_stuff;
24923 + struct dentry *error = ERR_PTR(-ENOENT);
24926 + for (; p->name; p++) {
24927 + if (p->len != dentry->d_name.len)
24929 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24933 + goto instantiate;
24935 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24936 + if ((id < 0) || !xid_is_hashed(id))
24940 + error = proc_xid_instantiate(dir, dentry, id, p);
24945 +static struct file_operations proc_nid_file_operations = {
24946 + .read = generic_read_dir,
24947 + .readdir = proc_nid_readdir,
24950 +static struct inode_operations proc_nid_inode_operations = {
24951 + .lookup = proc_nid_lookup,
24954 +static struct vs_entry nx_virtnet_stuff[] = {
24955 + INF("info", S_IRUGO, virtnet_info),
24956 + INF("status", S_IRUGO, virtnet_status),
24957 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
24961 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24962 + struct dentry *dentry, struct nameidata *nd)
24964 + struct vs_entry *p = nx_virtnet_stuff;
24965 + struct dentry *error = ERR_PTR(-ENOENT);
24968 + for (; p->name; p++) {
24969 + if (p->len != dentry->d_name.len)
24971 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24975 + goto instantiate;
24977 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24978 + if ((id < 0) || !nid_is_hashed(id))
24982 + error = proc_nid_instantiate(dir, dentry, id, p);
24988 +#define PROC_MAXVIDS 32
24990 +int proc_virtual_readdir(struct file *filp,
24991 + void *dirent, filldir_t filldir)
24993 + struct dentry *dentry = filp->f_dentry;
24994 + struct inode *inode = dentry->d_inode;
24995 + struct vs_entry *p = vx_virtual_stuff;
24996 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24998 + unsigned int xid_array[PROC_MAXVIDS];
24999 + char buf[PROC_NUMBUF];
25000 + unsigned int nr_xids, i;
25003 + pos = filp->f_pos;
25006 + ino = inode->i_ino;
25007 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25010 + /* fall through */
25012 + ino = parent_ino(dentry);
25013 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25016 + /* fall through */
25019 + if (index >= size)
25021 + for (p += index; p->name; p++) {
25022 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25023 + vs_proc_instantiate, 0, p))
25028 + index = pos - size;
25029 + p = &vx_virtual_stuff[size - 1];
25030 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
25031 + for (i = 0; i < nr_xids; i++) {
25032 + int n, xid = xid_array[i];
25033 + unsigned int j = PROC_NUMBUF;
25037 + buf[--j] = '0' + (n % 10);
25040 + if (proc_fill_cache(filp, dirent, filldir,
25041 + buf + j, PROC_NUMBUF - j,
25042 + vs_proc_instantiate, xid, p))
25048 + filp->f_pos = pos;
25052 +static int proc_virtual_getattr(struct vfsmount *mnt,
25053 + struct dentry *dentry, struct kstat *stat)
25055 + struct inode *inode = dentry->d_inode;
25057 + generic_fillattr(inode, stat);
25058 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
25062 +static struct file_operations proc_virtual_dir_operations = {
25063 + .read = generic_read_dir,
25064 + .readdir = proc_virtual_readdir,
25067 +static struct inode_operations proc_virtual_dir_inode_operations = {
25068 + .getattr = proc_virtual_getattr,
25069 + .lookup = proc_virtual_lookup,
25076 +int proc_virtnet_readdir(struct file *filp,
25077 + void *dirent, filldir_t filldir)
25079 + struct dentry *dentry = filp->f_dentry;
25080 + struct inode *inode = dentry->d_inode;
25081 + struct vs_entry *p = nx_virtnet_stuff;
25082 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
25084 + unsigned int nid_array[PROC_MAXVIDS];
25085 + char buf[PROC_NUMBUF];
25086 + unsigned int nr_nids, i;
25089 + pos = filp->f_pos;
25092 + ino = inode->i_ino;
25093 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25096 + /* fall through */
25098 + ino = parent_ino(dentry);
25099 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25102 + /* fall through */
25105 + if (index >= size)
25107 + for (p += index; p->name; p++) {
25108 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25109 + vs_proc_instantiate, 0, p))
25114 + index = pos - size;
25115 + p = &nx_virtnet_stuff[size - 1];
25116 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
25117 + for (i = 0; i < nr_nids; i++) {
25118 + int n, nid = nid_array[i];
25119 + unsigned int j = PROC_NUMBUF;
25123 + buf[--j] = '0' + (n % 10);
25126 + if (proc_fill_cache(filp, dirent, filldir,
25127 + buf + j, PROC_NUMBUF - j,
25128 + vs_proc_instantiate, nid, p))
25134 + filp->f_pos = pos;
25138 +static int proc_virtnet_getattr(struct vfsmount *mnt,
25139 + struct dentry *dentry, struct kstat *stat)
25141 + struct inode *inode = dentry->d_inode;
25143 + generic_fillattr(inode, stat);
25144 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
25148 +static struct file_operations proc_virtnet_dir_operations = {
25149 + .read = generic_read_dir,
25150 + .readdir = proc_virtnet_readdir,
25153 +static struct inode_operations proc_virtnet_dir_inode_operations = {
25154 + .getattr = proc_virtnet_getattr,
25155 + .lookup = proc_virtnet_lookup,
25160 +void proc_vx_init(void)
25162 + struct proc_dir_entry *ent;
25164 + ent = proc_mkdir("virtual", 0);
25166 + ent->proc_fops = &proc_virtual_dir_operations;
25167 + ent->proc_iops = &proc_virtual_dir_inode_operations;
25169 + proc_virtual = ent;
25171 + ent = proc_mkdir("virtnet", 0);
25173 + ent->proc_fops = &proc_virtnet_dir_operations;
25174 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
25176 + proc_virtnet = ent;
25182 +/* per pid info */
25185 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
25187 + struct vx_info *vxi;
25188 + char *orig = buffer;
25190 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
25192 + vxi = task_get_vx_info(p);
25196 + buffer += sprintf(buffer, "BCaps:\t");
25197 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
25198 + buffer += sprintf(buffer, "\n");
25199 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
25200 + (unsigned long long)vxi->vx_ccaps);
25201 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
25202 + (unsigned long long)vxi->vx_flags);
25203 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
25205 + put_vx_info(vxi);
25207 + return buffer - orig;
25211 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
25213 + struct nx_info *nxi;
25214 + struct nx_addr_v4 *v4a;
25215 +#ifdef CONFIG_IPV6
25216 + struct nx_addr_v6 *v6a;
25218 + char *orig = buffer;
25221 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
25223 + nxi = task_get_nx_info(p);
25227 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
25228 + (unsigned long long)nxi->nx_ncaps);
25229 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
25230 + (unsigned long long)nxi->nx_flags);
25232 + buffer += sprintf(buffer,
25233 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
25234 + NIPQUAD(nxi->v4_bcast.s_addr));
25235 + buffer += sprintf (buffer,
25236 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
25237 + NIPQUAD(nxi->v4_lback.s_addr));
25238 + if (!NX_IPV4(nxi))
25240 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
25241 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
25244 +#ifdef CONFIG_IPV6
25245 + if (!NX_IPV6(nxi))
25247 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
25248 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
25252 + put_nx_info(nxi);
25254 + return buffer - orig;
25257 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sched.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sched.c
25258 --- linux-2.6.33/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
25259 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sched.c 2010-02-25 12:02:16.000000000 +0100
25262 + * linux/kernel/vserver/sched.c
25264 + * Virtual Server: Scheduler Support
25266 + * Copyright (C) 2004-2007 Herbert Pötzl
25268 + * V0.01 adapted Sam Vilains version to 2.6.3
25269 + * V0.02 removed legacy interface
25270 + * V0.03 changed vcmds to vxi arg
25271 + * V0.04 removed older and legacy interfaces
25275 +#include <linux/vs_context.h>
25276 +#include <linux/vs_sched.h>
25277 +#include <linux/vserver/sched_cmd.h>
25279 +#include <asm/uaccess.h>
25282 +#define vxd_check_range(val, min, max) do { \
25283 + vxlprintk((val < min) || (val > max), \
25284 + "check_range(%ld,%ld,%ld)", \
25285 + (long)val, (long)min, (long)max, \
25286 + __FILE__, __LINE__); \
25290 +void vx_update_sched_param(struct _vx_sched *sched,
25291 + struct _vx_sched_pc *sched_pc)
25293 + unsigned int set_mask = sched->update_mask;
25295 + if (set_mask & VXSM_FILL_RATE)
25296 + sched_pc->fill_rate[0] = sched->fill_rate[0];
25297 + if (set_mask & VXSM_INTERVAL)
25298 + sched_pc->interval[0] = sched->interval[0];
25299 + if (set_mask & VXSM_FILL_RATE2)
25300 + sched_pc->fill_rate[1] = sched->fill_rate[1];
25301 + if (set_mask & VXSM_INTERVAL2)
25302 + sched_pc->interval[1] = sched->interval[1];
25303 + if (set_mask & VXSM_TOKENS)
25304 + sched_pc->tokens = sched->tokens;
25305 + if (set_mask & VXSM_TOKENS_MIN)
25306 + sched_pc->tokens_min = sched->tokens_min;
25307 + if (set_mask & VXSM_TOKENS_MAX)
25308 + sched_pc->tokens_max = sched->tokens_max;
25309 + if (set_mask & VXSM_PRIO_BIAS)
25310 + sched_pc->prio_bias = sched->prio_bias;
25312 + if (set_mask & VXSM_IDLE_TIME)
25313 + sched_pc->flags |= VXSF_IDLE_TIME;
25315 + sched_pc->flags &= ~VXSF_IDLE_TIME;
25318 + sched_pc->norm_time = jiffies;
25323 + * recalculate the context's scheduling tokens
25325 + * ret > 0 : number of tokens available
25326 + * ret < 0 : on hold, check delta_min[]
25327 + * -1 only jiffies
25328 + * -2 also idle time
25331 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
25332 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
25336 + int flags = sched_pc->flags;
25338 + /* how much time did pass? */
25339 + delta = *norm_time - sched_pc->norm_time;
25340 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
25341 + vxd_check_range(delta, 0, INT_MAX);
25343 + if (delta >= sched_pc->interval[0]) {
25344 + long tokens, integral;
25346 + /* calc integral token part */
25347 + tokens = delta / sched_pc->interval[0];
25348 + integral = tokens * sched_pc->interval[0];
25349 + tokens *= sched_pc->fill_rate[0];
25350 +#ifdef CONFIG_VSERVER_HARDCPU
25351 + delta_min[0] = delta - integral;
25352 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
25354 + /* advance time */
25355 + sched_pc->norm_time += delta;
25358 + sched_pc->tokens += tokens;
25359 + sched_pc->token_time += tokens;
25361 + delta_min[0] = delta;
25363 +#ifdef CONFIG_VSERVER_IDLETIME
25364 + if (!(flags & VXSF_IDLE_TIME))
25367 + /* how much was the idle skip? */
25368 + delta = *idle_time - sched_pc->idle_time;
25369 + vxd_check_range(delta, 0, INT_MAX);
25371 + if (delta >= sched_pc->interval[1]) {
25372 + long tokens, integral;
25374 + /* calc fair share token part */
25375 + tokens = delta / sched_pc->interval[1];
25376 + integral = tokens * sched_pc->interval[1];
25377 + tokens *= sched_pc->fill_rate[1];
25378 + delta_min[1] = delta - integral;
25379 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
25381 + /* advance idle time */
25382 + sched_pc->idle_time += integral;
25385 + sched_pc->tokens += tokens;
25386 + sched_pc->token_time += tokens;
25388 + delta_min[1] = delta;
25392 + /* clip at maximum */
25393 + if (sched_pc->tokens > sched_pc->tokens_max)
25394 + sched_pc->tokens = sched_pc->tokens_max;
25395 + tokens = sched_pc->tokens;
25397 + if ((flags & VXSF_ONHOLD)) {
25398 + /* can we unhold? */
25399 + if (tokens >= sched_pc->tokens_min) {
25400 + flags &= ~VXSF_ONHOLD;
25401 + sched_pc->hold_ticks +=
25402 + *norm_time - sched_pc->onhold;
25406 + /* put on hold? */
25407 + if (tokens <= 0) {
25408 + flags |= VXSF_ONHOLD;
25409 + sched_pc->onhold = *norm_time;
25413 + sched_pc->flags = flags;
25417 + tokens = sched_pc->tokens_min - tokens;
25418 + sched_pc->flags = flags;
25419 + // BUG_ON(tokens < 0); probably doesn't hold anymore
25421 +#ifdef CONFIG_VSERVER_HARDCPU
25422 + /* next interval? */
25423 + if (!sched_pc->fill_rate[0])
25424 + delta_min[0] = HZ;
25425 + else if (tokens > sched_pc->fill_rate[0])
25426 + delta_min[0] += sched_pc->interval[0] *
25427 + tokens / sched_pc->fill_rate[0];
25429 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
25430 + vxd_check_range(delta_min[0], 0, INT_MAX);
25432 +#ifdef CONFIG_VSERVER_IDLETIME
25433 + if (!(flags & VXSF_IDLE_TIME))
25436 + /* next interval? */
25437 + if (!sched_pc->fill_rate[1])
25438 + delta_min[1] = HZ;
25439 + else if (tokens > sched_pc->fill_rate[1])
25440 + delta_min[1] += sched_pc->interval[1] *
25441 + tokens / sched_pc->fill_rate[1];
25443 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
25444 + vxd_check_range(delta_min[1], 0, INT_MAX);
25449 +#endif /* CONFIG_VSERVER_IDLETIME */
25452 +#endif /* CONFIG_VSERVER_HARDCPU */
25455 +static inline unsigned long msec_to_ticks(unsigned long msec)
25457 + return msecs_to_jiffies(msec);
25460 +static inline unsigned long ticks_to_msec(unsigned long ticks)
25462 + return jiffies_to_msecs(ticks);
25465 +static inline unsigned long ticks_to_usec(unsigned long ticks)
25467 + return jiffies_to_usecs(ticks);
25471 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
25473 + unsigned int set_mask = data->mask;
25474 + unsigned int update_mask;
25477 + /* Sanity check data values */
25478 + if (data->tokens_max <= 0)
25479 + data->tokens_max = HZ;
25480 + if (data->tokens_min < 0)
25481 + data->tokens_min = HZ / 3;
25482 + if (data->tokens_min >= data->tokens_max)
25483 + data->tokens_min = data->tokens_max;
25485 + if (data->prio_bias > MAX_PRIO_BIAS)
25486 + data->prio_bias = MAX_PRIO_BIAS;
25487 + if (data->prio_bias < MIN_PRIO_BIAS)
25488 + data->prio_bias = MIN_PRIO_BIAS;
25490 + spin_lock(&vxi->sched.tokens_lock);
25492 + /* sync up on delayed updates */
25493 + for_each_cpu_mask(cpu, vxi->sched.update)
25494 + vx_update_sched_param(&vxi->sched,
25495 + &vx_per_cpu(vxi, sched_pc, cpu));
25497 + if (set_mask & VXSM_FILL_RATE)
25498 + vxi->sched.fill_rate[0] = data->fill_rate[0];
25499 + if (set_mask & VXSM_FILL_RATE2)
25500 + vxi->sched.fill_rate[1] = data->fill_rate[1];
25501 + if (set_mask & VXSM_INTERVAL)
25502 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
25503 + msec_to_ticks(data->interval[0]) : data->interval[0];
25504 + if (set_mask & VXSM_INTERVAL2)
25505 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
25506 + msec_to_ticks(data->interval[1]) : data->interval[1];
25507 + if (set_mask & VXSM_TOKENS)
25508 + vxi->sched.tokens = data->tokens;
25509 + if (set_mask & VXSM_TOKENS_MIN)
25510 + vxi->sched.tokens_min = data->tokens_min;
25511 + if (set_mask & VXSM_TOKENS_MAX)
25512 + vxi->sched.tokens_max = data->tokens_max;
25513 + if (set_mask & VXSM_PRIO_BIAS)
25514 + vxi->sched.prio_bias = data->prio_bias;
25516 + /* Sanity check rate/interval */
25517 + for (i = 0; i < 2; i++) {
25518 + if (data->fill_rate[i] < 0)
25519 + data->fill_rate[i] = 0;
25520 + if (data->interval[i] <= 0)
25521 + data->interval[i] = HZ;
25524 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
25525 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
25526 + vxi->sched.update_mask = update_mask;
25530 + if (set_mask & VXSM_CPU_ID) {
25531 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
25532 + cpus_and(vxi->sched.update, cpu_online_map,
25533 + vxi->sched.update);
25535 + vxi->sched.update = cpu_online_map;
25537 + /* forced reload? */
25538 + if (set_mask & VXSM_FORCE) {
25539 + for_each_cpu_mask(cpu, vxi->sched.update)
25540 + vx_update_sched_param(&vxi->sched,
25541 + &vx_per_cpu(vxi, sched_pc, cpu));
25542 + vxi->sched.update = CPU_MASK_NONE;
25545 + /* on UP we update immediately */
25546 + vx_update_sched_param(&vxi->sched,
25547 + &vx_per_cpu(vxi, sched_pc, 0));
25550 + spin_unlock(&vxi->sched.tokens_lock);
25555 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
25556 +#define COPY_PRI(C) C(prio_bias)
25557 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
25558 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
25559 + C(fill_rate[1]); C(interval[1]);
25561 +#define COPY_VALUE(name) vc_data.name = data->name
25563 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
25565 + struct vcmd_sched_v5 vc_data;
25567 + vc_data.mask = data->set_mask;
25568 + COPY_IDS(COPY_VALUE);
25569 + COPY_PRI(COPY_VALUE);
25570 + COPY_TOK(COPY_VALUE);
25571 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
25572 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
25573 + return do_set_sched(vxi, &vc_data);
25576 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
25578 + struct vcmd_set_sched_v4 vc_data;
25580 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25583 + return do_set_sched_v4(vxi, &vc_data);
25586 + /* latest interface is v5 */
25588 +int vc_set_sched(struct vx_info *vxi, void __user *data)
25590 + struct vcmd_sched_v5 vc_data;
25592 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25595 + return do_set_sched(vxi, &vc_data);
25599 +#define COPY_PRI(C) C(prio_bias)
25600 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
25601 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
25602 + C(fill_rate[1]); C(interval[1]);
25604 +#define COPY_VALUE(name) vc_data.name = data->name
25607 +int vc_get_sched(struct vx_info *vxi, void __user *data)
25609 + struct vcmd_sched_v5 vc_data;
25611 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25614 + if (vc_data.mask & VXSM_CPU_ID) {
25615 + int cpu = vc_data.cpu_id;
25616 + struct _vx_sched_pc *data;
25618 + if (!cpu_possible(cpu))
25621 + data = &vx_per_cpu(vxi, sched_pc, cpu);
25622 + COPY_TOK(COPY_VALUE);
25623 + COPY_PRI(COPY_VALUE);
25624 + COPY_FRI(COPY_VALUE);
25626 + if (data->flags & VXSF_IDLE_TIME)
25627 + vc_data.mask |= VXSM_IDLE_TIME;
25629 + struct _vx_sched *data = &vxi->sched;
25631 + COPY_TOK(COPY_VALUE);
25632 + COPY_PRI(COPY_VALUE);
25633 + COPY_FRI(COPY_VALUE);
25636 + if (vc_data.mask & VXSM_MSEC) {
25637 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
25638 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
25641 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25647 +int vc_sched_info(struct vx_info *vxi, void __user *data)
25649 + struct vcmd_sched_info vc_data;
25652 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25655 + cpu = vc_data.cpu_id;
25656 + if (!cpu_possible(cpu))
25660 + struct _vx_sched_pc *sched_pc =
25661 + &vx_per_cpu(vxi, sched_pc, cpu);
25663 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
25664 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
25665 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
25666 + vc_data.vavavoom = sched_pc->vavavoom;
25668 + vc_data.token_usec = ticks_to_usec(1);
25670 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25675 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sched_init.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sched_init.h
25676 --- linux-2.6.33/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
25677 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sched_init.h 2010-02-25 12:02:16.000000000 +0100
25680 +static inline void vx_info_init_sched(struct _vx_sched *sched)
25682 + static struct lock_class_key tokens_lock_key;
25684 + /* scheduling; hard code starting values as constants */
25685 + sched->fill_rate[0] = 1;
25686 + sched->interval[0] = 4;
25687 + sched->fill_rate[1] = 1;
25688 + sched->interval[1] = 8;
25689 + sched->tokens = HZ >> 2;
25690 + sched->tokens_min = HZ >> 4;
25691 + sched->tokens_max = HZ >> 1;
25692 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
25693 + sched->prio_bias = 0;
25695 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
25699 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
25701 + sched_pc->fill_rate[0] = 1;
25702 + sched_pc->interval[0] = 4;
25703 + sched_pc->fill_rate[1] = 1;
25704 + sched_pc->interval[1] = 8;
25705 + sched_pc->tokens = HZ >> 2;
25706 + sched_pc->tokens_min = HZ >> 4;
25707 + sched_pc->tokens_max = HZ >> 1;
25708 + sched_pc->prio_bias = 0;
25709 + sched_pc->vavavoom = 0;
25710 + sched_pc->token_time = 0;
25711 + sched_pc->idle_time = 0;
25712 + sched_pc->norm_time = jiffies;
25714 + sched_pc->user_ticks = 0;
25715 + sched_pc->sys_ticks = 0;
25716 + sched_pc->hold_ticks = 0;
25719 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
25725 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
25729 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sched_proc.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sched_proc.h
25730 --- linux-2.6.33/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
25731 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sched_proc.h 2010-02-25 12:02:16.000000000 +0100
25733 +#ifndef _VX_SCHED_PROC_H
25734 +#define _VX_SCHED_PROC_H
25738 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
25742 + length += sprintf(buffer,
25743 + "FillRate:\t%8d,%d\n"
25744 + "Interval:\t%8d,%d\n"
25745 + "TokensMin:\t%8d\n"
25746 + "TokensMax:\t%8d\n"
25747 + "PrioBias:\t%8d\n",
25748 + sched->fill_rate[0],
25749 + sched->fill_rate[1],
25750 + sched->interval[0],
25751 + sched->interval[1],
25752 + sched->tokens_min,
25753 + sched->tokens_max,
25754 + sched->prio_bias);
25759 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
25760 + char *buffer, int cpu)
25764 + length += sprintf(buffer + length,
25765 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
25766 + (unsigned long long)sched_pc->user_ticks,
25767 + (unsigned long long)sched_pc->sys_ticks,
25768 + (unsigned long long)sched_pc->hold_ticks,
25769 + sched_pc->token_time,
25770 + sched_pc->idle_time);
25771 + length += sprintf(buffer + length,
25772 + " %c%c %d %d %d %d/%d %d/%d",
25773 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
25774 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
25775 + sched_pc->tokens,
25776 + sched_pc->tokens_min,
25777 + sched_pc->tokens_max,
25778 + sched_pc->fill_rate[0],
25779 + sched_pc->interval[0],
25780 + sched_pc->fill_rate[1],
25781 + sched_pc->interval[1]);
25782 + length += sprintf(buffer + length,
25784 + sched_pc->prio_bias,
25785 + sched_pc->vavavoom);
25789 +#endif /* _VX_SCHED_PROC_H */
25790 diff -NurpP --minimal linux-2.6.33/kernel/vserver/signal.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/signal.c
25791 --- linux-2.6.33/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
25792 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/signal.c 2010-02-25 12:02:16.000000000 +0100
25795 + * linux/kernel/vserver/signal.c
25797 + * Virtual Server: Signal Support
25799 + * Copyright (C) 2003-2007 Herbert Pötzl
25801 + * V0.01 broken out from vcontext V0.05
25802 + * V0.02 changed vcmds to vxi arg
25803 + * V0.03 adjusted siginfo for kill
25807 +#include <asm/uaccess.h>
25809 +#include <linux/vs_context.h>
25810 +#include <linux/vs_pid.h>
25811 +#include <linux/vserver/signal_cmd.h>
25814 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
25816 + int retval, count = 0;
25817 + struct task_struct *p;
25818 + struct siginfo *sip = SEND_SIG_PRIV;
25821 + vxdprintk(VXD_CBIT(misc, 4),
25822 + "vx_info_kill(%p[#%d],%d,%d)*",
25823 + vxi, vxi->vx_id, pid, sig);
25824 + read_lock(&tasklist_lock);
25828 + for_each_process(p) {
25831 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
25832 + (pid && vxi->vx_initpid == p->pid))
25835 + err = group_send_sig_info(sig, sip, p);
25837 + if (err != -EPERM)
25843 + if (vxi->vx_initpid) {
25844 + pid = vxi->vx_initpid;
25845 + /* for now, only SIGINT to private init ... */
25846 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
25847 + /* ... as long as there are tasks left */
25848 + (atomic_read(&vxi->vx_tasks) > 1))
25851 + /* fallthrough */
25853 + p = find_task_by_real_pid(pid);
25855 + if (vx_task_xid(p) == vxi->vx_id)
25856 + retval = group_send_sig_info(sig, sip, p);
25860 + read_unlock(&tasklist_lock);
25861 + vxdprintk(VXD_CBIT(misc, 4),
25862 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
25863 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
25867 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
25869 + struct vcmd_ctx_kill_v0 vc_data;
25871 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25874 + /* special check to allow guest shutdown */
25875 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
25876 + /* forbid killall pid=0 when init is present */
25877 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
25878 + (vc_data.pid > 1)))
25881 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
25885 +static int __wait_exit(struct vx_info *vxi)
25887 + DECLARE_WAITQUEUE(wait, current);
25890 + add_wait_queue(&vxi->vx_wait, &wait);
25891 + set_current_state(TASK_INTERRUPTIBLE);
25894 + if (vx_info_state(vxi,
25895 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
25897 + if (signal_pending(current)) {
25898 + ret = -ERESTARTSYS;
25905 + set_current_state(TASK_RUNNING);
25906 + remove_wait_queue(&vxi->vx_wait, &wait);
25912 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
25914 + struct vcmd_wait_exit_v0 vc_data;
25917 + ret = __wait_exit(vxi);
25918 + vc_data.reboot_cmd = vxi->reboot_cmd;
25919 + vc_data.exit_code = vxi->exit_code;
25921 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25926 diff -NurpP --minimal linux-2.6.33/kernel/vserver/space.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/space.c
25927 --- linux-2.6.33/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
25928 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/space.c 2010-02-25 12:02:16.000000000 +0100
25931 + * linux/kernel/vserver/space.c
25933 + * Virtual Server: Context Space Support
25935 + * Copyright (C) 2003-2007 Herbert Pötzl
25937 + * V0.01 broken out from context.c 0.07
25938 + * V0.02 added task locking for namespace
25939 + * V0.03 broken out vx_enter_namespace
25940 + * V0.04 added *space support and commands
25944 +#include <linux/utsname.h>
25945 +#include <linux/nsproxy.h>
25946 +#include <linux/err.h>
25947 +#include <linux/fs_struct.h>
25948 +#include <asm/uaccess.h>
25950 +#include <linux/vs_context.h>
25951 +#include <linux/vserver/space.h>
25952 +#include <linux/vserver/space_cmd.h>
25954 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
25955 +atomic_t vs_global_fs = ATOMIC_INIT(0);
25956 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
25957 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
25958 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
25959 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
25962 +/* namespace functions */
25964 +#include <linux/mnt_namespace.h>
25965 +#include <linux/user_namespace.h>
25966 +#include <linux/pid_namespace.h>
25967 +#include <linux/ipc_namespace.h>
25968 +#include <net/net_namespace.h>
25971 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
25972 + .mask = CLONE_FS |
25980 +static const struct vcmd_space_mask_v1 space_mask = {
25981 + .mask = CLONE_FS |
25986 +#ifdef CONFIG_PID_NS
25989 +#ifdef CONFIG_NET_NS
25995 +static const struct vcmd_space_mask_v1 default_space_mask = {
25996 + .mask = CLONE_FS |
26001 +#ifdef CONFIG_PID_NS
26008 + * build a new nsproxy mix
26009 + * assumes that both proxies are 'const'
26010 + * does not touch nsproxy refcounts
26011 + * will hold a reference on the result.
26014 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
26015 + struct nsproxy *new_nsproxy, unsigned long mask)
26017 + struct mnt_namespace *old_ns;
26018 + struct uts_namespace *old_uts;
26019 + struct ipc_namespace *old_ipc;
26020 +#ifdef CONFIG_PID_NS
26021 + struct pid_namespace *old_pid;
26023 +#ifdef CONFIG_NET_NS
26024 + struct net *old_net;
26026 + struct nsproxy *nsproxy;
26028 + nsproxy = copy_nsproxy(old_nsproxy);
26032 + if (mask & CLONE_NEWNS) {
26033 + old_ns = nsproxy->mnt_ns;
26034 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
26035 + if (nsproxy->mnt_ns)
26036 + get_mnt_ns(nsproxy->mnt_ns);
26040 + if (mask & CLONE_NEWUTS) {
26041 + old_uts = nsproxy->uts_ns;
26042 + nsproxy->uts_ns = new_nsproxy->uts_ns;
26043 + if (nsproxy->uts_ns)
26044 + get_uts_ns(nsproxy->uts_ns);
26048 + if (mask & CLONE_NEWIPC) {
26049 + old_ipc = nsproxy->ipc_ns;
26050 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
26051 + if (nsproxy->ipc_ns)
26052 + get_ipc_ns(nsproxy->ipc_ns);
26056 +#ifdef CONFIG_PID_NS
26057 + if (mask & CLONE_NEWPID) {
26058 + old_pid = nsproxy->pid_ns;
26059 + nsproxy->pid_ns = new_nsproxy->pid_ns;
26060 + if (nsproxy->pid_ns)
26061 + get_pid_ns(nsproxy->pid_ns);
26065 +#ifdef CONFIG_NET_NS
26066 + if (mask & CLONE_NEWNET) {
26067 + old_net = nsproxy->net_ns;
26068 + nsproxy->net_ns = new_nsproxy->net_ns;
26069 + if (nsproxy->net_ns)
26070 + get_net(nsproxy->net_ns);
26075 + put_mnt_ns(old_ns);
26077 + put_uts_ns(old_uts);
26079 + put_ipc_ns(old_ipc);
26080 +#ifdef CONFIG_PID_NS
26082 + put_pid_ns(old_pid);
26084 +#ifdef CONFIG_NET_NS
26086 + put_net(old_net);
26094 + * merge two nsproxy structs into a new one.
26095 + * will hold a reference on the result.
26099 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
26100 + struct nsproxy *proxy, unsigned long mask)
26102 + struct nsproxy null_proxy = { .mnt_ns = NULL };
26108 + /* vs_mix_nsproxy returns with reference */
26109 + return vs_mix_nsproxy(old ? old : &null_proxy,
26112 + get_nsproxy(proxy);
26117 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
26119 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
26120 + struct fs_struct *fs_cur, *fs = NULL;
26121 + int ret, kill = 0;
26123 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
26124 + vxi, vxi->vx_id, mask, index);
26126 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
26130 + mask = vxi->vx_nsmask[index];
26132 + if ((mask & vxi->vx_nsmask[index]) != mask)
26135 + if (mask & CLONE_FS) {
26136 + fs = copy_fs_struct(vxi->vx_fs[index]);
26140 + proxy = vxi->vx_nsproxy[index];
26142 + vxdprintk(VXD_CBIT(space, 9),
26143 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
26144 + vxi, vxi->vx_id, mask, index, proxy, fs);
26146 + task_lock(current);
26147 + fs_cur = current->fs;
26149 + if (mask & CLONE_FS) {
26150 + write_lock(&fs_cur->lock);
26151 + current->fs = fs;
26152 + kill = !--fs_cur->users;
26153 + write_unlock(&fs_cur->lock);
26156 + proxy_cur = current->nsproxy;
26157 + get_nsproxy(proxy_cur);
26158 + task_unlock(current);
26161 + free_fs_struct(fs_cur);
26163 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
26164 + if (IS_ERR(proxy_new)) {
26165 + ret = PTR_ERR(proxy_new);
26169 + proxy_new = xchg(¤t->nsproxy, proxy_new);
26173 + put_nsproxy(proxy_new);
26176 + put_nsproxy(proxy_cur);
26181 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
26183 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
26184 + struct fs_struct *fs_vxi, *fs;
26185 + int ret, kill = 0;
26187 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
26188 + vxi, vxi->vx_id, mask, index);
26191 + mask = default_space_mask.mask;
26193 + if ((mask & space_mask.mask) != mask)
26196 + proxy_vxi = vxi->vx_nsproxy[index];
26197 + fs_vxi = vxi->vx_fs[index];
26199 + if (mask & CLONE_FS) {
26200 + fs = copy_fs_struct(current->fs);
26205 + task_lock(current);
26207 + if (mask & CLONE_FS) {
26208 + write_lock(&fs_vxi->lock);
26209 + vxi->vx_fs[index] = fs;
26210 + kill = !--fs_vxi->users;
26211 + write_unlock(&fs_vxi->lock);
26214 + proxy_cur = current->nsproxy;
26215 + get_nsproxy(proxy_cur);
26216 + task_unlock(current);
26219 + free_fs_struct(fs_vxi);
26221 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
26222 + if (IS_ERR(proxy_new)) {
26223 + ret = PTR_ERR(proxy_new);
26227 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
26228 + vxi->vx_nsmask[index] |= mask;
26232 + put_nsproxy(proxy_new);
26235 + put_nsproxy(proxy_cur);
26240 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
26242 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
26244 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26247 + return vx_enter_space(vxi, vc_data.mask, 0);
26250 +int vc_enter_space(struct vx_info *vxi, void __user *data)
26252 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
26254 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26257 + if (vc_data.index >= VX_SPACES)
26260 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
26263 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
26265 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
26267 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26270 + return vx_set_space(vxi, vc_data.mask, 0);
26273 +int vc_set_space(struct vx_info *vxi, void __user *data)
26275 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
26277 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26280 + if (vc_data.index >= VX_SPACES)
26283 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
26286 +int vc_get_space_mask(void __user *data, int type)
26288 + const struct vcmd_space_mask_v1 *mask;
26291 + mask = &space_mask_v0;
26292 + else if (type == 1)
26293 + mask = &space_mask;
26295 + mask = &default_space_mask;
26297 + vxdprintk(VXD_CBIT(space, 10),
26298 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
26300 + if (copy_to_user(data, mask, sizeof(*mask)))
26305 diff -NurpP --minimal linux-2.6.33/kernel/vserver/switch.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/switch.c
26306 --- linux-2.6.33/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
26307 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/switch.c 2010-02-25 12:02:16.000000000 +0100
26310 + * linux/kernel/vserver/switch.c
26312 + * Virtual Server: Syscall Switch
26314 + * Copyright (C) 2003-2007 Herbert Pötzl
26316 + * V0.01 syscall switch
26317 + * V0.02 added signal to context
26318 + * V0.03 added rlimit functions
26319 + * V0.04 added iattr, task/xid functions
26320 + * V0.05 added debug/history stuff
26321 + * V0.06 added compat32 layer
26322 + * V0.07 vcmd args and perms
26323 + * V0.08 added status commands
26324 + * V0.09 added tag commands
26325 + * V0.10 added oom bias
26326 + * V0.11 added device commands
26330 +#include <linux/vs_context.h>
26331 +#include <linux/vs_network.h>
26332 +#include <linux/vserver/switch.h>
26334 +#include "vci_config.h"
26338 +int vc_get_version(uint32_t id)
26340 + return VCI_VERSION;
26344 +int vc_get_vci(uint32_t id)
26346 + return vci_kernel_config();
26349 +#include <linux/vserver/context_cmd.h>
26350 +#include <linux/vserver/cvirt_cmd.h>
26351 +#include <linux/vserver/cacct_cmd.h>
26352 +#include <linux/vserver/limit_cmd.h>
26353 +#include <linux/vserver/network_cmd.h>
26354 +#include <linux/vserver/sched_cmd.h>
26355 +#include <linux/vserver/debug_cmd.h>
26356 +#include <linux/vserver/inode_cmd.h>
26357 +#include <linux/vserver/dlimit_cmd.h>
26358 +#include <linux/vserver/signal_cmd.h>
26359 +#include <linux/vserver/space_cmd.h>
26360 +#include <linux/vserver/tag_cmd.h>
26361 +#include <linux/vserver/device_cmd.h>
26363 +#include <linux/vserver/inode.h>
26364 +#include <linux/vserver/dlimit.h>
26367 +#ifdef CONFIG_COMPAT
26368 +#define __COMPAT(name, id, data, compat) \
26369 + (compat) ? name ## _x32(id, data) : name(id, data)
26370 +#define __COMPAT_NO_ID(name, data, compat) \
26371 + (compat) ? name ## _x32(data) : name(data)
26373 +#define __COMPAT(name, id, data, compat) \
26375 +#define __COMPAT_NO_ID(name, data, compat) \
26381 +long do_vcmd(uint32_t cmd, uint32_t id,
26382 + struct vx_info *vxi, struct nx_info *nxi,
26383 + void __user *data, int compat)
26387 + case VCMD_get_version:
26388 + return vc_get_version(id);
26389 + case VCMD_get_vci:
26390 + return vc_get_vci(id);
26392 + case VCMD_task_xid:
26393 + return vc_task_xid(id);
26394 + case VCMD_vx_info:
26395 + return vc_vx_info(vxi, data);
26397 + case VCMD_task_nid:
26398 + return vc_task_nid(id);
26399 + case VCMD_nx_info:
26400 + return vc_nx_info(nxi, data);
26402 + case VCMD_task_tag:
26403 + return vc_task_tag(id);
26405 + case VCMD_set_space_v1:
26406 + return vc_set_space_v1(vxi, data);
26407 + /* this is version 2 */
26408 + case VCMD_set_space:
26409 + return vc_set_space(vxi, data);
26411 + case VCMD_get_space_mask_v0:
26412 + return vc_get_space_mask(data, 0);
26413 + /* this is version 1 */
26414 + case VCMD_get_space_mask:
26415 + return vc_get_space_mask(data, 1);
26417 + case VCMD_get_space_default:
26418 + return vc_get_space_mask(data, -1);
26420 +#ifdef CONFIG_IA32_EMULATION
26421 + case VCMD_get_rlimit:
26422 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
26423 + case VCMD_set_rlimit:
26424 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
26426 + case VCMD_get_rlimit:
26427 + return vc_get_rlimit(vxi, data);
26428 + case VCMD_set_rlimit:
26429 + return vc_set_rlimit(vxi, data);
26431 + case VCMD_get_rlimit_mask:
26432 + return vc_get_rlimit_mask(id, data);
26433 + case VCMD_reset_hits:
26434 + return vc_reset_hits(vxi, data);
26435 + case VCMD_reset_minmax:
26436 + return vc_reset_minmax(vxi, data);
26438 + case VCMD_get_vhi_name:
26439 + return vc_get_vhi_name(vxi, data);
26440 + case VCMD_set_vhi_name:
26441 + return vc_set_vhi_name(vxi, data);
26443 + case VCMD_ctx_stat:
26444 + return vc_ctx_stat(vxi, data);
26445 + case VCMD_virt_stat:
26446 + return vc_virt_stat(vxi, data);
26447 + case VCMD_sock_stat:
26448 + return vc_sock_stat(vxi, data);
26449 + case VCMD_rlimit_stat:
26450 + return vc_rlimit_stat(vxi, data);
26452 + case VCMD_set_cflags:
26453 + return vc_set_cflags(vxi, data);
26454 + case VCMD_get_cflags:
26455 + return vc_get_cflags(vxi, data);
26457 + /* this is version 1 */
26458 + case VCMD_set_ccaps:
26459 + return vc_set_ccaps(vxi, data);
26460 + /* this is version 1 */
26461 + case VCMD_get_ccaps:
26462 + return vc_get_ccaps(vxi, data);
26463 + case VCMD_set_bcaps:
26464 + return vc_set_bcaps(vxi, data);
26465 + case VCMD_get_bcaps:
26466 + return vc_get_bcaps(vxi, data);
26468 + case VCMD_set_badness:
26469 + return vc_set_badness(vxi, data);
26470 + case VCMD_get_badness:
26471 + return vc_get_badness(vxi, data);
26473 + case VCMD_set_nflags:
26474 + return vc_set_nflags(nxi, data);
26475 + case VCMD_get_nflags:
26476 + return vc_get_nflags(nxi, data);
26478 + case VCMD_set_ncaps:
26479 + return vc_set_ncaps(nxi, data);
26480 + case VCMD_get_ncaps:
26481 + return vc_get_ncaps(nxi, data);
26483 + case VCMD_set_sched_v4:
26484 + return vc_set_sched_v4(vxi, data);
26485 + /* this is version 5 */
26486 + case VCMD_set_sched:
26487 + return vc_set_sched(vxi, data);
26488 + case VCMD_get_sched:
26489 + return vc_get_sched(vxi, data);
26490 + case VCMD_sched_info:
26491 + return vc_sched_info(vxi, data);
26493 + case VCMD_add_dlimit:
26494 + return __COMPAT(vc_add_dlimit, id, data, compat);
26495 + case VCMD_rem_dlimit:
26496 + return __COMPAT(vc_rem_dlimit, id, data, compat);
26497 + case VCMD_set_dlimit:
26498 + return __COMPAT(vc_set_dlimit, id, data, compat);
26499 + case VCMD_get_dlimit:
26500 + return __COMPAT(vc_get_dlimit, id, data, compat);
26502 + case VCMD_ctx_kill:
26503 + return vc_ctx_kill(vxi, data);
26505 + case VCMD_wait_exit:
26506 + return vc_wait_exit(vxi, data);
26508 + case VCMD_get_iattr:
26509 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
26510 + case VCMD_set_iattr:
26511 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
26513 + case VCMD_fget_iattr:
26514 + return vc_fget_iattr(id, data);
26515 + case VCMD_fset_iattr:
26516 + return vc_fset_iattr(id, data);
26518 + case VCMD_enter_space_v0:
26519 + return vc_enter_space_v1(vxi, NULL);
26520 + case VCMD_enter_space_v1:
26521 + return vc_enter_space_v1(vxi, data);
26522 + /* this is version 2 */
26523 + case VCMD_enter_space:
26524 + return vc_enter_space(vxi, data);
26526 + case VCMD_ctx_create_v0:
26527 + return vc_ctx_create(id, NULL);
26528 + case VCMD_ctx_create:
26529 + return vc_ctx_create(id, data);
26530 + case VCMD_ctx_migrate_v0:
26531 + return vc_ctx_migrate(vxi, NULL);
26532 + case VCMD_ctx_migrate:
26533 + return vc_ctx_migrate(vxi, data);
26535 + case VCMD_net_create_v0:
26536 + return vc_net_create(id, NULL);
26537 + case VCMD_net_create:
26538 + return vc_net_create(id, data);
26539 + case VCMD_net_migrate:
26540 + return vc_net_migrate(nxi, data);
26542 + case VCMD_tag_migrate:
26543 + return vc_tag_migrate(id);
26545 + case VCMD_net_add:
26546 + return vc_net_add(nxi, data);
26547 + case VCMD_net_remove:
26548 + return vc_net_remove(nxi, data);
26550 + case VCMD_net_add_ipv4:
26551 + return vc_net_add_ipv4(nxi, data);
26552 + case VCMD_net_remove_ipv4:
26553 + return vc_net_remove_ipv4(nxi, data);
26554 +#ifdef CONFIG_IPV6
26555 + case VCMD_net_add_ipv6:
26556 + return vc_net_add_ipv6(nxi, data);
26557 + case VCMD_net_remove_ipv6:
26558 + return vc_net_remove_ipv6(nxi, data);
26560 +/* case VCMD_add_match_ipv4:
26561 + return vc_add_match_ipv4(nxi, data);
26562 + case VCMD_get_match_ipv4:
26563 + return vc_get_match_ipv4(nxi, data);
26564 +#ifdef CONFIG_IPV6
26565 + case VCMD_add_match_ipv6:
26566 + return vc_add_match_ipv6(nxi, data);
26567 + case VCMD_get_match_ipv6:
26568 + return vc_get_match_ipv6(nxi, data);
26571 +#ifdef CONFIG_VSERVER_DEVICE
26572 + case VCMD_set_mapping:
26573 + return __COMPAT(vc_set_mapping, vxi, data, compat);
26574 + case VCMD_unset_mapping:
26575 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
26577 +#ifdef CONFIG_VSERVER_HISTORY
26578 + case VCMD_dump_history:
26579 + return vc_dump_history(id);
26580 + case VCMD_read_history:
26581 + return __COMPAT(vc_read_history, id, data, compat);
26583 +#ifdef CONFIG_VSERVER_MONITOR
26584 + case VCMD_read_monitor:
26585 + return __COMPAT(vc_read_monitor, id, data, compat);
26588 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
26589 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
26595 +#define __VCMD(vcmd, _perm, _args, _flags) \
26596 + case VCMD_ ## vcmd: perm = _perm; \
26597 + args = _args; flags = _flags; break
26600 +#define VCA_NONE 0x00
26601 +#define VCA_VXI 0x01
26602 +#define VCA_NXI 0x02
26604 +#define VCF_NONE 0x00
26605 +#define VCF_INFO 0x01
26606 +#define VCF_ADMIN 0x02
26607 +#define VCF_ARES 0x06 /* includes admin */
26608 +#define VCF_SETUP 0x08
26610 +#define VCF_ZIDOK 0x10 /* zero id okay */
26614 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
26617 + int permit = -1, state = 0;
26618 + int perm = -1, args = 0, flags = 0;
26619 + struct vx_info *vxi = NULL;
26620 + struct nx_info *nxi = NULL;
26623 + /* unpriviledged commands */
26624 + __VCMD(get_version, 0, VCA_NONE, 0);
26625 + __VCMD(get_vci, 0, VCA_NONE, 0);
26626 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
26627 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
26628 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
26629 + __VCMD(get_space_default,0, VCA_NONE, 0);
26631 + /* info commands */
26632 + __VCMD(task_xid, 2, VCA_NONE, 0);
26633 + __VCMD(reset_hits, 2, VCA_VXI, 0);
26634 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
26635 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
26636 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
26637 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
26638 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
26639 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
26640 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
26641 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
26643 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
26644 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
26645 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
26646 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
26648 + __VCMD(task_nid, 2, VCA_NONE, 0);
26649 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
26650 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
26651 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
26653 + __VCMD(task_tag, 2, VCA_NONE, 0);
26655 + __VCMD(get_iattr, 2, VCA_NONE, 0);
26656 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
26657 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
26658 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
26659 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
26661 + /* lower admin commands */
26662 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
26663 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
26664 + __VCMD(ctx_create, 5, VCA_NONE, 0);
26665 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
26666 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
26667 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
26668 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
26669 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
26671 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
26672 + __VCMD(net_create, 5, VCA_NONE, 0);
26673 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
26675 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
26677 + /* higher admin commands */
26678 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
26679 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26680 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26682 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26683 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26684 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26685 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26687 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26688 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26689 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26690 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
26692 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
26693 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
26694 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
26695 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
26696 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
26697 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
26698 +#ifdef CONFIG_IPV6
26699 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
26700 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
26702 + __VCMD(set_iattr, 7, VCA_NONE, 0);
26703 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
26704 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
26705 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
26706 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
26708 +#ifdef CONFIG_VSERVER_DEVICE
26709 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
26710 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
26712 + /* debug level admin commands */
26713 +#ifdef CONFIG_VSERVER_HISTORY
26714 + __VCMD(dump_history, 9, VCA_NONE, 0);
26715 + __VCMD(read_history, 9, VCA_NONE, 0);
26717 +#ifdef CONFIG_VSERVER_MONITOR
26718 + __VCMD(read_monitor, 9, VCA_NONE, 0);
26725 + vxdprintk(VXD_CBIT(switch, 0),
26726 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
26727 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
26728 + VC_VERSION(cmd), id, data, compat,
26729 + perm, args, flags);
26736 + if (!capable(CAP_CONTEXT))
26740 + /* moved here from the individual commands */
26742 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
26746 + /* vcmd involves resource management */
26748 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
26752 + /* various legacy exceptions */
26754 + /* will go away when spectator is a cap */
26755 + case VCMD_ctx_migrate_v0:
26756 + case VCMD_ctx_migrate:
26758 + current->xid = 1;
26764 + /* will go away when spectator is a cap */
26765 + case VCMD_net_migrate:
26767 + current->nid = 1;
26774 + /* vcmds are fine by default */
26777 + /* admin type vcmds require admin ... */
26778 + if (flags & VCF_ADMIN)
26779 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
26781 + /* ... but setup type vcmds override that */
26782 + if (!permit && (flags & VCF_SETUP))
26783 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
26791 + if (!id && (flags & VCF_ZIDOK))
26795 + if (args & VCA_VXI) {
26796 + vxi = lookup_vx_info(id);
26800 + if ((flags & VCF_ADMIN) &&
26801 + /* special case kill for shutdown */
26802 + (cmd != VCMD_ctx_kill) &&
26803 + /* can context be administrated? */
26804 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
26810 + if (args & VCA_NXI) {
26811 + nxi = lookup_nx_info(id);
26815 + if ((flags & VCF_ADMIN) &&
26816 + /* can context be administrated? */
26817 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
26824 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
26827 + if ((args & VCA_NXI) && nxi)
26828 + put_nx_info(nxi);
26830 + if ((args & VCA_VXI) && vxi)
26831 + put_vx_info(vxi);
26833 + vxdprintk(VXD_CBIT(switch, 1),
26834 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
26835 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
26836 + VC_VERSION(cmd), ret, ret, state, permit);
26841 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
26843 + return do_vserver(cmd, id, data, 0);
26846 +#ifdef CONFIG_COMPAT
26849 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
26851 + return do_vserver(cmd, id, data, 1);
26854 +#endif /* CONFIG_COMPAT */
26855 diff -NurpP --minimal linux-2.6.33/kernel/vserver/sysctl.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sysctl.c
26856 --- linux-2.6.33/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
26857 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/sysctl.c 2010-02-25 15:14:16.000000000 +0100
26860 + * kernel/vserver/sysctl.c
26862 + * Virtual Context Support
26864 + * Copyright (C) 2004-2007 Herbert Pötzl
26866 + * V0.01 basic structure
26870 +#include <linux/module.h>
26871 +#include <linux/ctype.h>
26872 +#include <linux/sysctl.h>
26873 +#include <linux/parser.h>
26874 +#include <asm/uaccess.h>
26877 + CTL_DEBUG_ERROR = 0,
26878 + CTL_DEBUG_SWITCH = 1,
26893 +unsigned int vx_debug_switch = 0;
26894 +unsigned int vx_debug_xid = 0;
26895 +unsigned int vx_debug_nid = 0;
26896 +unsigned int vx_debug_tag = 0;
26897 +unsigned int vx_debug_net = 0;
26898 +unsigned int vx_debug_limit = 0;
26899 +unsigned int vx_debug_cres = 0;
26900 +unsigned int vx_debug_dlim = 0;
26901 +unsigned int vx_debug_quota = 0;
26902 +unsigned int vx_debug_cvirt = 0;
26903 +unsigned int vx_debug_space = 0;
26904 +unsigned int vx_debug_misc = 0;
26907 +static struct ctl_table_header *vserver_table_header;
26908 +static ctl_table vserver_root_table[];
26911 +void vserver_register_sysctl(void)
26913 + if (!vserver_table_header) {
26914 + vserver_table_header = register_sysctl_table(vserver_root_table);
26919 +void vserver_unregister_sysctl(void)
26921 + if (vserver_table_header) {
26922 + unregister_sysctl_table(vserver_table_header);
26923 + vserver_table_header = NULL;
26928 +static int proc_dodebug(ctl_table *table, int write,
26929 + void __user *buffer, size_t *lenp, loff_t *ppos)
26931 + char tmpbuf[20], *p, c;
26932 + unsigned int value;
26933 + size_t left, len;
26935 + if ((*ppos && !write) || !*lenp) {
26943 + if (!access_ok(VERIFY_READ, buffer, left))
26945 + p = (char *)buffer;
26946 + while (left && __get_user(c, p) >= 0 && isspace(c))
26951 + if (left > sizeof(tmpbuf) - 1)
26953 + if (copy_from_user(tmpbuf, p, left))
26955 + tmpbuf[left] = '\0';
26957 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
26958 + value = 10 * value + (*p - '0');
26959 + if (*p && !isspace(*p))
26961 + while (left && isspace(*p))
26963 + *(unsigned int *)table->data = value;
26965 + if (!access_ok(VERIFY_WRITE, buffer, left))
26967 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
26970 + if (__copy_to_user(buffer, tmpbuf, len))
26972 + if ((left -= len) > 0) {
26973 + if (put_user('\n', (char *)buffer + len))
26987 +#define CTL_ENTRY(ctl, name) \
26989 + .procname = #name, \
26990 + .data = &vx_ ## name, \
26991 + .maxlen = sizeof(int), \
26993 + .proc_handler = &proc_dodebug, \
26994 + .extra1 = &zero, \
26995 + .extra2 = &zero, \
26998 +static ctl_table vserver_debug_table[] = {
26999 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
27000 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
27001 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
27002 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
27003 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
27004 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
27005 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
27006 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
27007 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
27008 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
27009 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
27010 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
27014 +static ctl_table vserver_root_table[] = {
27016 + .procname = "vserver",
27018 + .child = vserver_debug_table
27024 +static match_table_t tokens = {
27025 + { CTL_DEBUG_SWITCH, "switch=%x" },
27026 + { CTL_DEBUG_XID, "xid=%x" },
27027 + { CTL_DEBUG_NID, "nid=%x" },
27028 + { CTL_DEBUG_TAG, "tag=%x" },
27029 + { CTL_DEBUG_NET, "net=%x" },
27030 + { CTL_DEBUG_LIMIT, "limit=%x" },
27031 + { CTL_DEBUG_CRES, "cres=%x" },
27032 + { CTL_DEBUG_DLIM, "dlim=%x" },
27033 + { CTL_DEBUG_QUOTA, "quota=%x" },
27034 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
27035 + { CTL_DEBUG_SPACE, "space=%x" },
27036 + { CTL_DEBUG_MISC, "misc=%x" },
27037 + { CTL_DEBUG_ERROR, NULL }
27040 +#define HANDLE_CASE(id, name, val) \
27041 + case CTL_DEBUG_ ## id: \
27042 + vx_debug_ ## name = val; \
27043 + printk("vs_debug_" #name "=0x%x\n", val); \
27047 +static int __init vs_debug_setup(char *str)
27052 + printk("vs_debug_setup(%s)\n", str);
27053 + while ((p = strsep(&str, ",")) != NULL) {
27054 + substring_t args[MAX_OPT_ARGS];
27055 + unsigned int value;
27060 + token = match_token(p, tokens, args);
27061 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
27064 + HANDLE_CASE(SWITCH, switch, value);
27065 + HANDLE_CASE(XID, xid, value);
27066 + HANDLE_CASE(NID, nid, value);
27067 + HANDLE_CASE(TAG, tag, value);
27068 + HANDLE_CASE(NET, net, value);
27069 + HANDLE_CASE(LIMIT, limit, value);
27070 + HANDLE_CASE(CRES, cres, value);
27071 + HANDLE_CASE(DLIM, dlim, value);
27072 + HANDLE_CASE(QUOTA, quota, value);
27073 + HANDLE_CASE(CVIRT, cvirt, value);
27074 + HANDLE_CASE(SPACE, space, value);
27075 + HANDLE_CASE(MISC, misc, value);
27084 +__setup("vsdebug=", vs_debug_setup);
27088 +EXPORT_SYMBOL_GPL(vx_debug_switch);
27089 +EXPORT_SYMBOL_GPL(vx_debug_xid);
27090 +EXPORT_SYMBOL_GPL(vx_debug_nid);
27091 +EXPORT_SYMBOL_GPL(vx_debug_net);
27092 +EXPORT_SYMBOL_GPL(vx_debug_limit);
27093 +EXPORT_SYMBOL_GPL(vx_debug_cres);
27094 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
27095 +EXPORT_SYMBOL_GPL(vx_debug_quota);
27096 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
27097 +EXPORT_SYMBOL_GPL(vx_debug_space);
27098 +EXPORT_SYMBOL_GPL(vx_debug_misc);
27100 diff -NurpP --minimal linux-2.6.33/kernel/vserver/tag.c linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/tag.c
27101 --- linux-2.6.33/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
27102 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/tag.c 2010-02-25 12:02:16.000000000 +0100
27105 + * linux/kernel/vserver/tag.c
27107 + * Virtual Server: Shallow Tag Space
27109 + * Copyright (C) 2007 Herbert Pötzl
27111 + * V0.01 basic implementation
27115 +#include <linux/sched.h>
27116 +#include <linux/vserver/debug.h>
27117 +#include <linux/vs_pid.h>
27118 +#include <linux/vs_tag.h>
27120 +#include <linux/vserver/tag_cmd.h>
27123 +int dx_migrate_task(struct task_struct *p, tag_t tag)
27128 + vxdprintk(VXD_CBIT(tag, 5),
27129 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
27135 + vxdprintk(VXD_CBIT(tag, 5),
27136 + "moved task %p into [#%d]", p, tag);
27140 +/* vserver syscall commands below here */
27142 +/* taks xid and vx_info functions */
27145 +int vc_task_tag(uint32_t id)
27150 + struct task_struct *tsk;
27151 + read_lock(&tasklist_lock);
27152 + tsk = find_task_by_real_pid(id);
27153 + tag = (tsk) ? tsk->tag : -ESRCH;
27154 + read_unlock(&tasklist_lock);
27156 + tag = dx_current_tag();
27161 +int vc_tag_migrate(uint32_t tag)
27163 + return dx_migrate_task(current, tag & 0xFFFF);
27167 diff -NurpP --minimal linux-2.6.33/kernel/vserver/vci_config.h linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/vci_config.h
27168 --- linux-2.6.33/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
27169 +++ linux-2.6.33-vs2.3.0.36.30.1/kernel/vserver/vci_config.h 2010-02-25 12:02:16.000000000 +0100
27172 +/* interface version */
27174 +#define VCI_VERSION 0x00020305
27178 + VCI_KCBIT_NO_DYNAMIC = 0,
27180 + VCI_KCBIT_PROC_SECURE = 4,
27181 + VCI_KCBIT_HARDCPU = 5,
27182 + VCI_KCBIT_IDLELIMIT = 6,
27183 + VCI_KCBIT_IDLETIME = 7,
27185 + VCI_KCBIT_COWBL = 8,
27186 + VCI_KCBIT_FULLCOWBL = 9,
27187 + VCI_KCBIT_SPACES = 10,
27188 + VCI_KCBIT_NETV2 = 11,
27190 + VCI_KCBIT_DEBUG = 16,
27191 + VCI_KCBIT_HISTORY = 20,
27192 + VCI_KCBIT_TAGGED = 24,
27193 + VCI_KCBIT_PPTAG = 28,
27195 + VCI_KCBIT_MORE = 31,
27199 +static inline uint32_t vci_kernel_config(void)
27202 + (1 << VCI_KCBIT_NO_DYNAMIC) |
27204 + /* configured features */
27205 +#ifdef CONFIG_VSERVER_PROC_SECURE
27206 + (1 << VCI_KCBIT_PROC_SECURE) |
27208 +#ifdef CONFIG_VSERVER_HARDCPU
27209 + (1 << VCI_KCBIT_HARDCPU) |
27211 +#ifdef CONFIG_VSERVER_IDLELIMIT
27212 + (1 << VCI_KCBIT_IDLELIMIT) |
27214 +#ifdef CONFIG_VSERVER_IDLETIME
27215 + (1 << VCI_KCBIT_IDLETIME) |
27217 +#ifdef CONFIG_VSERVER_COWBL
27218 + (1 << VCI_KCBIT_COWBL) |
27219 + (1 << VCI_KCBIT_FULLCOWBL) |
27221 + (1 << VCI_KCBIT_SPACES) |
27222 + (1 << VCI_KCBIT_NETV2) |
27224 + /* debug options */
27225 +#ifdef CONFIG_VSERVER_DEBUG
27226 + (1 << VCI_KCBIT_DEBUG) |
27228 +#ifdef CONFIG_VSERVER_HISTORY
27229 + (1 << VCI_KCBIT_HISTORY) |
27232 + /* inode context tagging */
27233 +#if defined(CONFIG_TAGGING_NONE)
27234 + (0 << VCI_KCBIT_TAGGED) |
27235 +#elif defined(CONFIG_TAGGING_UID16)
27236 + (1 << VCI_KCBIT_TAGGED) |
27237 +#elif defined(CONFIG_TAGGING_GID16)
27238 + (2 << VCI_KCBIT_TAGGED) |
27239 +#elif defined(CONFIG_TAGGING_ID24)
27240 + (3 << VCI_KCBIT_TAGGED) |
27241 +#elif defined(CONFIG_TAGGING_INTERN)
27242 + (4 << VCI_KCBIT_TAGGED) |
27243 +#elif defined(CONFIG_TAGGING_RUNTIME)
27244 + (5 << VCI_KCBIT_TAGGED) |
27246 + (7 << VCI_KCBIT_TAGGED) |
27248 + (1 << VCI_KCBIT_PPTAG) |
27252 diff -NurpP --minimal linux-2.6.33/mm/filemap_xip.c linux-2.6.33-vs2.3.0.36.30.1/mm/filemap_xip.c
27253 --- linux-2.6.33/mm/filemap_xip.c 2009-12-03 20:02:58.000000000 +0100
27254 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/filemap_xip.c 2010-02-25 12:02:16.000000000 +0100
27256 #include <linux/sched.h>
27257 #include <linux/seqlock.h>
27258 #include <linux/mutex.h>
27259 +#include <linux/vs_memory.h>
27260 #include <asm/tlbflush.h>
27261 #include <asm/io.h>
27263 diff -NurpP --minimal linux-2.6.33/mm/fremap.c linux-2.6.33-vs2.3.0.36.30.1/mm/fremap.c
27264 --- linux-2.6.33/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
27265 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/fremap.c 2010-02-25 12:02:16.000000000 +0100
27267 #include <linux/module.h>
27268 #include <linux/syscalls.h>
27269 #include <linux/mmu_notifier.h>
27270 +#include <linux/vs_memory.h>
27272 #include <asm/mmu_context.h>
27273 #include <asm/cacheflush.h>
27274 diff -NurpP --minimal linux-2.6.33/mm/hugetlb.c linux-2.6.33-vs2.3.0.36.30.1/mm/hugetlb.c
27275 --- linux-2.6.33/mm/hugetlb.c 2010-02-25 11:52:09.000000000 +0100
27276 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/hugetlb.c 2010-02-25 12:16:11.000000000 +0100
27279 #include <linux/hugetlb.h>
27280 #include <linux/node.h>
27281 +#include <linux/vs_memory.h>
27282 #include "internal.h"
27284 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
27285 diff -NurpP --minimal linux-2.6.33/mm/memcontrol.c linux-2.6.33-vs2.3.0.36.30.1/mm/memcontrol.c
27286 --- linux-2.6.33/mm/memcontrol.c 2010-02-25 11:52:09.000000000 +0100
27287 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/memcontrol.c 2010-02-26 10:04:15.000000000 +0100
27288 @@ -555,6 +555,31 @@ struct mem_cgroup *mem_cgroup_from_task(
27289 struct mem_cgroup, css);
27292 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
27294 + return res_counter_read_u64(&mem->res, member);
27297 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
27299 + return res_counter_read_u64(&mem->memsw, member);
27302 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
27304 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
27307 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
27309 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
27312 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
27314 + return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
27317 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
27319 struct mem_cgroup *mem = NULL;
27320 diff -NurpP --minimal linux-2.6.33/mm/memory.c linux-2.6.33-vs2.3.0.36.30.1/mm/memory.c
27321 --- linux-2.6.33/mm/memory.c 2010-02-25 11:52:09.000000000 +0100
27322 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/memory.c 2010-02-25 12:02:16.000000000 +0100
27324 #include <linux/kallsyms.h>
27325 #include <linux/swapops.h>
27326 #include <linux/elf.h>
27327 +// #include <linux/vs_memory.h>
27329 #include <asm/io.h>
27330 #include <asm/pgalloc.h>
27331 @@ -651,6 +652,9 @@ static int copy_pte_range(struct mm_stru
27333 swp_entry_t entry = (swp_entry_t){0};
27335 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
27339 rss[1] = rss[0] = 0;
27340 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
27341 @@ -2670,6 +2674,8 @@ static int do_anonymous_page(struct mm_s
27342 /* Allocate our own private page. */
27343 pte_unmap(page_table);
27345 + if (!vx_rss_avail(mm, 1))
27347 if (unlikely(anon_vma_prepare(vma)))
27349 page = alloc_zeroed_user_highpage_movable(vma, address);
27350 @@ -2961,6 +2967,7 @@ static inline int handle_pte_fault(struc
27354 + int ret = 0, type = VXPT_UNKNOWN;
27357 if (!pte_present(entry)) {
27358 @@ -2985,9 +2992,12 @@ static inline int handle_pte_fault(struc
27359 if (unlikely(!pte_same(*pte, entry)))
27361 if (flags & FAULT_FLAG_WRITE) {
27362 - if (!pte_write(entry))
27363 - return do_wp_page(mm, vma, address,
27364 + if (!pte_write(entry)) {
27365 + ret = do_wp_page(mm, vma, address,
27366 pte, pmd, ptl, entry);
27367 + type = VXPT_WRITE;
27370 entry = pte_mkdirty(entry);
27372 entry = pte_mkyoung(entry);
27373 @@ -3005,7 +3015,10 @@ static inline int handle_pte_fault(struc
27376 pte_unmap_unlock(pte, ptl);
27380 + vx_page_fault(mm, vma, type, ret);
27385 diff -NurpP --minimal linux-2.6.33/mm/mlock.c linux-2.6.33-vs2.3.0.36.30.1/mm/mlock.c
27386 --- linux-2.6.33/mm/mlock.c 2010-02-25 11:52:09.000000000 +0100
27387 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/mlock.c 2010-02-25 12:02:16.000000000 +0100
27389 #include <linux/rmap.h>
27390 #include <linux/mmzone.h>
27391 #include <linux/hugetlb.h>
27392 +#include <linux/vs_memory.h>
27394 #include "internal.h"
27396 @@ -398,7 +399,7 @@ success:
27397 nr_pages = (end - start) >> PAGE_SHIFT;
27399 nr_pages = -nr_pages;
27400 - mm->locked_vm += nr_pages;
27401 + vx_vmlocked_add(mm, nr_pages);
27404 * vm_flags is protected by the mmap_sem held in write mode.
27405 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
27407 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
27409 - unsigned long locked;
27410 + unsigned long locked, grow;
27411 unsigned long lock_limit;
27412 int error = -ENOMEM;
27414 @@ -484,8 +485,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
27415 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
27416 start &= PAGE_MASK;
27418 - locked = len >> PAGE_SHIFT;
27419 - locked += current->mm->locked_vm;
27420 + grow = len >> PAGE_SHIFT;
27421 + if (!vx_vmlocked_avail(current->mm, grow))
27423 + locked = current->mm->locked_vm + grow;
27425 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
27426 lock_limit >>= PAGE_SHIFT;
27427 @@ -493,6 +496,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
27428 /* check against resource limits */
27429 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
27430 error = do_mlock(start, len, 1);
27432 up_write(¤t->mm->mmap_sem);
27435 @@ -554,6 +558,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
27436 lock_limit >>= PAGE_SHIFT;
27439 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
27441 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
27442 capable(CAP_IPC_LOCK))
27443 ret = do_mlockall(flags);
27444 @@ -628,8 +634,10 @@ int account_locked_memory(struct mm_stru
27448 - mm->total_vm += pgsz;
27449 - mm->locked_vm += pgsz;
27450 + // mm->total_vm += pgsz;
27451 + vx_vmpages_add(mm, pgsz);
27452 + // mm->locked_vm += pgsz;
27453 + vx_vmlocked_add(mm, pgsz);
27457 @@ -643,8 +651,10 @@ void refund_locked_memory(struct mm_stru
27459 down_write(&mm->mmap_sem);
27461 - mm->total_vm -= pgsz;
27462 - mm->locked_vm -= pgsz;
27463 + // mm->total_vm -= pgsz;
27464 + vx_vmpages_sub(mm, pgsz);
27465 + // mm->locked_vm -= pgsz;
27466 + vx_vmlocked_sub(mm, pgsz);
27468 up_write(&mm->mmap_sem);
27470 diff -NurpP --minimal linux-2.6.33/mm/mmap.c linux-2.6.33-vs2.3.0.36.30.1/mm/mmap.c
27471 --- linux-2.6.33/mm/mmap.c 2010-02-25 11:52:09.000000000 +0100
27472 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/mmap.c 2010-02-25 12:02:16.000000000 +0100
27473 @@ -1262,7 +1262,8 @@ munmap_back:
27475 perf_event_mmap(vma);
27477 - mm->total_vm += len >> PAGE_SHIFT;
27478 + // mm->total_vm += len >> PAGE_SHIFT;
27479 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
27480 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
27481 if (vm_flags & VM_LOCKED) {
27483 @@ -1271,7 +1272,8 @@ out:
27484 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
27486 return nr_pages; /* vma gone! */
27487 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
27488 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
27489 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
27490 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
27491 make_pages_present(addr, addr + len);
27493 @@ -1626,9 +1628,9 @@ static int acct_stack_growth(struct vm_a
27496 /* Ok, everything looks good - let it rip */
27497 - mm->total_vm += grow;
27498 + vx_vmpages_add(mm, grow);
27499 if (vma->vm_flags & VM_LOCKED)
27500 - mm->locked_vm += grow;
27501 + vx_vmlocked_add(mm, grow);
27502 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
27505 @@ -1803,7 +1805,8 @@ static void remove_vma_list(struct mm_st
27507 long nrpages = vma_pages(vma);
27509 - mm->total_vm -= nrpages;
27510 + // mm->total_vm -= nrpages;
27511 + vx_vmpages_sub(mm, nrpages);
27512 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
27513 vma = remove_vma(vma);
27515 @@ -1995,7 +1998,8 @@ int do_munmap(struct mm_struct *mm, unsi
27516 struct vm_area_struct *tmp = vma;
27517 while (tmp && tmp->vm_start < end) {
27518 if (tmp->vm_flags & VM_LOCKED) {
27519 - mm->locked_vm -= vma_pages(tmp);
27520 + // mm->locked_vm -= vma_pages(tmp);
27521 + vx_vmlocked_sub(mm, vma_pages(tmp));
27522 munlock_vma_pages_all(tmp);
27524 tmp = tmp->vm_next;
27525 @@ -2078,6 +2082,8 @@ unsigned long do_brk(unsigned long addr,
27526 lock_limit >>= PAGE_SHIFT;
27527 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
27529 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
27534 @@ -2104,7 +2110,8 @@ unsigned long do_brk(unsigned long addr,
27535 if (mm->map_count > sysctl_max_map_count)
27538 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
27539 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
27540 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
27543 /* Can we just expand an old private anonymous mapping? */
27544 @@ -2130,10 +2137,13 @@ unsigned long do_brk(unsigned long addr,
27545 vma->vm_page_prot = vm_get_page_prot(flags);
27546 vma_link(mm, vma, prev, rb_link, rb_parent);
27548 - mm->total_vm += len >> PAGE_SHIFT;
27549 + // mm->total_vm += len >> PAGE_SHIFT;
27550 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
27552 if (flags & VM_LOCKED) {
27553 if (!mlock_vma_pages_range(vma, addr, addr + len))
27554 - mm->locked_vm += (len >> PAGE_SHIFT);
27555 + // mm->locked_vm += (len >> PAGE_SHIFT);
27556 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
27560 @@ -2177,6 +2187,11 @@ void exit_mmap(struct mm_struct *mm)
27561 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
27562 tlb_finish_mmu(tlb, 0, end);
27564 + set_mm_counter(mm, file_rss, 0);
27565 + set_mm_counter(mm, anon_rss, 0);
27566 + vx_vmpages_sub(mm, mm->total_vm);
27567 + vx_vmlocked_sub(mm, mm->locked_vm);
27570 * Walk the list again, actually closing and freeing it,
27571 * with preemption enabled, without holding any MM locks.
27572 @@ -2216,7 +2231,8 @@ int insert_vm_struct(struct mm_struct *
27573 if (__vma && __vma->vm_start < vma->vm_end)
27575 if ((vma->vm_flags & VM_ACCOUNT) &&
27576 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
27577 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
27578 + !vx_vmpages_avail(mm, vma_pages(vma))))
27580 vma_link(mm, vma, prev, rb_link, rb_parent);
27582 @@ -2292,6 +2308,8 @@ int may_expand_vm(struct mm_struct *mm,
27584 if (cur + npages > lim)
27586 + if (!vx_vmpages_avail(mm, npages))
27591 @@ -2369,7 +2387,7 @@ int install_special_mapping(struct mm_st
27595 - mm->total_vm += len >> PAGE_SHIFT;
27596 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
27598 perf_event_mmap(vma);
27600 diff -NurpP --minimal linux-2.6.33/mm/mremap.c linux-2.6.33-vs2.3.0.36.30.1/mm/mremap.c
27601 --- linux-2.6.33/mm/mremap.c 2010-02-25 11:52:09.000000000 +0100
27602 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/mremap.c 2010-02-25 12:02:16.000000000 +0100
27604 #include <linux/security.h>
27605 #include <linux/syscalls.h>
27606 #include <linux/mmu_notifier.h>
27607 +#include <linux/vs_memory.h>
27609 #include <asm/uaccess.h>
27610 #include <asm/cacheflush.h>
27611 @@ -234,7 +235,7 @@ static unsigned long move_vma(struct vm_
27612 * If this were a serious issue, we'd add a flag to do_munmap().
27614 hiwater_vm = mm->hiwater_vm;
27615 - mm->total_vm += new_len >> PAGE_SHIFT;
27616 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
27617 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
27619 if (do_munmap(mm, old_addr, old_len) < 0) {
27620 @@ -252,7 +253,7 @@ static unsigned long move_vma(struct vm_
27623 if (vm_flags & VM_LOCKED) {
27624 - mm->locked_vm += new_len >> PAGE_SHIFT;
27625 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
27626 if (new_len > old_len)
27627 mlock_vma_pages_range(new_vma, new_addr + old_len,
27628 new_addr + new_len);
27629 @@ -463,10 +464,12 @@ unsigned long do_mremap(unsigned long ad
27630 vma_adjust(vma, vma->vm_start,
27631 addr + new_len, vma->vm_pgoff, NULL);
27633 - mm->total_vm += pages;
27634 + // mm->total_vm += pages;
27635 + vx_vmpages_add(mm, pages);
27636 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
27637 if (vma->vm_flags & VM_LOCKED) {
27638 - mm->locked_vm += pages;
27639 + // mm->locked_vm += pages;
27640 + vx_vmlocked_add(mm, pages);
27641 mlock_vma_pages_range(vma, addr + old_len,
27644 diff -NurpP --minimal linux-2.6.33/mm/nommu.c linux-2.6.33-vs2.3.0.36.30.1/mm/nommu.c
27645 --- linux-2.6.33/mm/nommu.c 2010-02-25 11:52:09.000000000 +0100
27646 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/nommu.c 2010-02-25 12:02:16.000000000 +0100
27647 @@ -1349,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file
27648 /* okay... we have a mapping; now we have to register it */
27649 result = vma->vm_start;
27651 - current->mm->total_vm += len >> PAGE_SHIFT;
27652 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
27655 add_vma_to_mm(current->mm, vma);
27656 @@ -1637,7 +1637,7 @@ void exit_mmap(struct mm_struct *mm)
27660 - mm->total_vm = 0;
27661 + vx_vmpages_sub(mm, mm->total_vm);
27663 while ((vma = mm->mmap)) {
27664 mm->mmap = vma->vm_next;
27665 diff -NurpP --minimal linux-2.6.33/mm/oom_kill.c linux-2.6.33-vs2.3.0.36.30.1/mm/oom_kill.c
27666 --- linux-2.6.33/mm/oom_kill.c 2010-02-25 11:52:09.000000000 +0100
27667 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/oom_kill.c 2010-02-25 12:20:14.000000000 +0100
27669 #include <linux/notifier.h>
27670 #include <linux/memcontrol.h>
27671 #include <linux/security.h>
27672 +#include <linux/reboot.h>
27673 +#include <linux/vs_memory.h>
27674 +#include <linux/vs_context.h>
27676 int sysctl_panic_on_oom;
27677 int sysctl_oom_kill_allocating_task;
27678 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
27679 points >>= -(oom_adj);
27683 + * add points for context badness and
27684 + * reduce badness for processes belonging to
27685 + * a different context
27688 + points += vx_badness(p, mm);
27690 + if ((vx_current_xid() > 1) &&
27691 + vx_current_xid() != vx_task_xid(p))
27695 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
27696 - p->pid, p->comm, points);
27697 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
27698 + task_pid_nr(p), p->xid, p->comm, points);
27702 @@ -249,6 +264,7 @@ static struct task_struct *select_bad_pr
27703 struct task_struct *p;
27704 struct task_struct *chosen = NULL;
27705 struct timespec uptime;
27706 + unsigned xid = vx_current_xid();
27709 do_posix_clock_monotonic_gettime(&uptime);
27710 @@ -261,11 +277,14 @@ static struct task_struct *select_bad_pr
27714 - /* skip the init task */
27715 - if (is_global_init(p))
27716 + /* skip the init task, global and per guest */
27717 + if (task_is_init(p))
27719 if (mem && !task_in_mem_cgroup(p, mem))
27721 + /* skip other guest and host processes if oom in guest */
27722 + if (xid && vx_task_xid(p) != xid)
27726 * This task already has access to memory reserves and is
27727 @@ -397,9 +416,9 @@ static void __oom_kill_task(struct task_
27731 - printk(KERN_ERR "Killed process %d (%s) "
27732 + printk(KERN_ERR "Killed process %s(%d:#%u) "
27733 "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
27734 - task_pid_nr(p), p->comm,
27735 + p->comm, task_pid_nr(p), p->xid,
27736 K(p->mm->total_vm),
27737 K(get_mm_counter(p->mm, anon_rss)),
27738 K(get_mm_counter(p->mm, file_rss)));
27739 @@ -452,8 +471,8 @@ static int oom_kill_process(struct task_
27743 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
27744 - message, task_pid_nr(p), p->comm, points);
27745 + printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
27746 + message, p->comm, task_pid_nr(p), p->xid, points);
27748 /* Try to kill a child first */
27749 list_for_each_entry(c, &p->children, sibling) {
27750 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist
27751 spin_unlock(&zone_scan_lock);
27754 +long vs_oom_action(unsigned int);
27757 * Must be called with tasklist_lock held for read.
27759 @@ -580,7 +601,11 @@ retry:
27761 read_unlock(&tasklist_lock);
27762 dump_header(NULL, gfp_mask, order, NULL);
27763 - panic("Out of memory and no killable processes...\n");
27764 + /* avoid panic for guest OOM */
27765 + if (current->xid)
27766 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
27768 + panic("Out of memory and no killable processes...\n");
27771 if (oom_kill_process(p, gfp_mask, order, points, NULL,
27772 diff -NurpP --minimal linux-2.6.33/mm/page_alloc.c linux-2.6.33-vs2.3.0.36.30.1/mm/page_alloc.c
27773 --- linux-2.6.33/mm/page_alloc.c 2010-02-25 11:52:09.000000000 +0100
27774 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/page_alloc.c 2010-02-25 12:16:45.000000000 +0100
27776 #include <linux/debugobjects.h>
27777 #include <linux/kmemleak.h>
27778 #include <linux/memory.h>
27779 +#include <linux/vs_base.h>
27780 +#include <linux/vs_limit.h>
27781 #include <trace/events/kmem.h>
27783 #include <asm/tlbflush.h>
27784 @@ -2138,6 +2140,9 @@ void si_meminfo(struct sysinfo *val)
27785 val->totalhigh = totalhigh_pages;
27786 val->freehigh = nr_free_highpages();
27787 val->mem_unit = PAGE_SIZE;
27789 + if (vx_flags(VXF_VIRT_MEM, 0))
27790 + vx_vsi_meminfo(val);
27793 EXPORT_SYMBOL(si_meminfo);
27794 @@ -2158,6 +2163,9 @@ void si_meminfo_node(struct sysinfo *val
27797 val->mem_unit = PAGE_SIZE;
27799 + if (vx_flags(VXF_VIRT_MEM, 0))
27800 + vx_vsi_meminfo(val);
27804 diff -NurpP --minimal linux-2.6.33/mm/rmap.c linux-2.6.33-vs2.3.0.36.30.1/mm/rmap.c
27805 --- linux-2.6.33/mm/rmap.c 2010-02-25 11:52:09.000000000 +0100
27806 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/rmap.c 2010-02-25 12:02:16.000000000 +0100
27808 #include <linux/memcontrol.h>
27809 #include <linux/mmu_notifier.h>
27810 #include <linux/migrate.h>
27811 +#include <linux/vs_memory.h>
27813 #include <asm/tlbflush.h>
27815 diff -NurpP --minimal linux-2.6.33/mm/shmem.c linux-2.6.33-vs2.3.0.36.30.1/mm/shmem.c
27816 --- linux-2.6.33/mm/shmem.c 2010-02-25 11:52:09.000000000 +0100
27817 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/shmem.c 2010-02-25 12:02:16.000000000 +0100
27818 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
27820 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
27822 - buf->f_type = TMPFS_MAGIC;
27823 + buf->f_type = TMPFS_SUPER_MAGIC;
27824 buf->f_bsize = PAGE_CACHE_SIZE;
27825 buf->f_namelen = NAME_MAX;
27826 spin_lock(&sbinfo->stat_lock);
27827 @@ -2358,7 +2358,7 @@ int shmem_fill_super(struct super_block
27828 sb->s_maxbytes = SHMEM_MAX_BYTES;
27829 sb->s_blocksize = PAGE_CACHE_SIZE;
27830 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
27831 - sb->s_magic = TMPFS_MAGIC;
27832 + sb->s_magic = TMPFS_SUPER_MAGIC;
27833 sb->s_op = &shmem_ops;
27834 sb->s_time_gran = 1;
27835 #ifdef CONFIG_TMPFS_POSIX_ACL
27836 diff -NurpP --minimal linux-2.6.33/mm/slab.c linux-2.6.33-vs2.3.0.36.30.1/mm/slab.c
27837 --- linux-2.6.33/mm/slab.c 2010-02-25 11:52:09.000000000 +0100
27838 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/slab.c 2010-02-25 12:02:16.000000000 +0100
27839 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
27840 #define STATS_INC_FREEMISS(x) do { } while (0)
27843 +#include "slab_vs.h"
27848 @@ -3275,6 +3277,7 @@ retry:
27850 obj = slab_get_obj(cachep, slabp, nodeid);
27851 check_slabp(cachep, slabp);
27852 + vx_slab_alloc(cachep, flags);
27853 l3->free_objects--;
27854 /* move slabp to correct slabp list: */
27855 list_del(&slabp->list);
27856 @@ -3351,6 +3354,7 @@ __cache_alloc_node(struct kmem_cache *ca
27857 /* ___cache_alloc_node can fall back to other nodes */
27858 ptr = ____cache_alloc_node(cachep, flags, nodeid);
27860 + vx_slab_alloc(cachep, flags);
27861 local_irq_restore(save_flags);
27862 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
27863 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
27864 @@ -3537,6 +3541,7 @@ static inline void __cache_free(struct k
27866 kmemleak_free_recursive(objp, cachep->flags);
27867 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
27868 + vx_slab_free(cachep);
27870 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
27872 diff -NurpP --minimal linux-2.6.33/mm/slab_vs.h linux-2.6.33-vs2.3.0.36.30.1/mm/slab_vs.h
27873 --- linux-2.6.33/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
27874 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/slab_vs.h 2010-02-25 12:02:16.000000000 +0100
27877 +#include <linux/vserver/context.h>
27879 +#include <linux/vs_context.h>
27882 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
27884 + int what = gfp_zone(cachep->gfpflags);
27885 + struct vx_info *vxi = current_vx_info();
27890 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
27894 +void vx_slab_free(struct kmem_cache *cachep)
27896 + int what = gfp_zone(cachep->gfpflags);
27897 + struct vx_info *vxi = current_vx_info();
27902 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
27905 diff -NurpP --minimal linux-2.6.33/mm/swapfile.c linux-2.6.33-vs2.3.0.36.30.1/mm/swapfile.c
27906 --- linux-2.6.33/mm/swapfile.c 2010-02-25 11:52:09.000000000 +0100
27907 +++ linux-2.6.33-vs2.3.0.36.30.1/mm/swapfile.c 2010-02-25 12:02:16.000000000 +0100
27909 #include <asm/tlbflush.h>
27910 #include <linux/swapops.h>
27911 #include <linux/page_cgroup.h>
27912 +#include <linux/vs_base.h>
27913 +#include <linux/vs_memory.h>
27915 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
27917 @@ -1693,6 +1695,16 @@ static int swap_show(struct seq_file *sw
27919 if (si == SEQ_START_TOKEN) {
27920 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
27921 + if (vx_flags(VXF_VIRT_MEM, 0)) {
27922 + struct sysinfo si;
27924 + vx_vsi_swapinfo(&si);
27925 + if (si.totalswap < (1 << 10))
27927 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
27928 + "hdv0", "partition", si.totalswap >> 10,
27929 + (si.totalswap - si.freeswap) >> 10, -1);
27934 @@ -2071,6 +2083,8 @@ void si_swapinfo(struct sysinfo *val)
27935 val->freeswap = nr_swap_pages + nr_to_be_unused;
27936 val->totalswap = total_swap_pages + nr_to_be_unused;
27937 spin_unlock(&swap_lock);
27938 + if (vx_flags(VXF_VIRT_MEM, 0))
27939 + vx_vsi_swapinfo(val);
27943 diff -NurpP --minimal linux-2.6.33/net/core/dev.c linux-2.6.33-vs2.3.0.36.30.1/net/core/dev.c
27944 --- linux-2.6.33/net/core/dev.c 2010-02-25 11:52:10.000000000 +0100
27945 +++ linux-2.6.33-vs2.3.0.36.30.1/net/core/dev.c 2010-02-25 14:02:39.000000000 +0100
27946 @@ -128,6 +128,7 @@
27947 #include <linux/in.h>
27948 #include <linux/jhash.h>
27949 #include <linux/random.h>
27950 +#include <linux/vs_inet.h>
27951 #include <trace/events/napi.h>
27953 #include "net-sysfs.h"
27954 @@ -593,7 +594,8 @@ struct net_device *__dev_get_by_name(str
27955 struct hlist_head *head = dev_name_hash(net, name);
27957 hlist_for_each_entry(dev, p, head, name_hlist)
27958 - if (!strncmp(dev->name, name, IFNAMSIZ))
27959 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
27960 + nx_dev_visible(current_nx_info(), dev))
27964 @@ -619,7 +621,8 @@ struct net_device *dev_get_by_name_rcu(s
27965 struct hlist_head *head = dev_name_hash(net, name);
27967 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
27968 - if (!strncmp(dev->name, name, IFNAMSIZ))
27969 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
27970 + nx_dev_visible(current_nx_info(), dev))
27974 @@ -670,7 +673,8 @@ struct net_device *__dev_get_by_index(st
27975 struct hlist_head *head = dev_index_hash(net, ifindex);
27977 hlist_for_each_entry(dev, p, head, index_hlist)
27978 - if (dev->ifindex == ifindex)
27979 + if ((dev->ifindex == ifindex) &&
27980 + nx_dev_visible(current_nx_info(), dev))
27984 @@ -695,7 +699,8 @@ struct net_device *dev_get_by_index_rcu(
27985 struct hlist_head *head = dev_index_hash(net, ifindex);
27987 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
27988 - if (dev->ifindex == ifindex)
27989 + if ((dev->ifindex == ifindex) &&
27990 + nx_dev_visible(current_nx_info(), dev))
27994 @@ -748,10 +753,12 @@ struct net_device *dev_getbyhwaddr(struc
27998 - for_each_netdev(net, dev)
27999 + for_each_netdev(net, dev) {
28000 if (dev->type == type &&
28001 - !memcmp(dev->dev_addr, ha, dev->addr_len))
28002 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
28003 + nx_dev_visible(current_nx_info(), dev))
28009 @@ -762,9 +769,11 @@ struct net_device *__dev_getfirstbyhwtyp
28010 struct net_device *dev;
28013 - for_each_netdev(net, dev)
28014 - if (dev->type == type)
28015 + for_each_netdev(net, dev) {
28016 + if ((dev->type == type) &&
28017 + nx_dev_visible(current_nx_info(), dev))
28023 @@ -883,6 +892,8 @@ static int __dev_alloc_name(struct net *
28025 if (i < 0 || i >= max_netdevices)
28027 + if (!nx_dev_visible(current_nx_info(), d))
28030 /* avoid cases where sscanf is not exact inverse of printf */
28031 snprintf(buf, IFNAMSIZ, name, i);
28032 @@ -3115,6 +3126,8 @@ static int dev_ifconf(struct net *net, c
28035 for_each_netdev(net, dev) {
28036 + if (!nx_dev_visible(current_nx_info(), dev))
28038 for (i = 0; i < NPROTO; i++) {
28039 if (gifconf_list[i]) {
28041 @@ -3185,6 +3198,9 @@ static void dev_seq_printf_stats(struct
28043 const struct net_device_stats *stats = dev_get_stats(dev);
28045 + if (!nx_dev_visible(current_nx_info(), dev))
28048 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
28049 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
28050 dev->name, stats->rx_bytes, stats->rx_packets,
28051 @@ -5528,7 +5544,6 @@ int dev_change_net_namespace(struct net_
28052 if (dev->dev.parent)
28056 /* Ensure the device has been registrered */
28058 if (dev->reg_state != NETREG_REGISTERED)
28059 diff -NurpP --minimal linux-2.6.33/net/core/rtnetlink.c linux-2.6.33-vs2.3.0.36.30.1/net/core/rtnetlink.c
28060 --- linux-2.6.33/net/core/rtnetlink.c 2010-02-25 11:52:10.000000000 +0100
28061 +++ linux-2.6.33-vs2.3.0.36.30.1/net/core/rtnetlink.c 2010-02-25 13:59:02.000000000 +0100
28062 @@ -695,6 +695,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
28063 hlist_for_each_entry(dev, node, head, index_hlist) {
28066 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
28068 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
28069 NETLINK_CB(cb->skb).pid,
28070 cb->nlh->nlmsg_seq, 0,
28071 @@ -1252,6 +1254,9 @@ void rtmsg_ifinfo(int type, struct net_d
28072 struct sk_buff *skb;
28073 int err = -ENOBUFS;
28075 + if (!nx_dev_visible(current_nx_info(), dev))
28078 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
28081 diff -NurpP --minimal linux-2.6.33/net/core/sock.c linux-2.6.33-vs2.3.0.36.30.1/net/core/sock.c
28082 --- linux-2.6.33/net/core/sock.c 2010-02-25 11:52:10.000000000 +0100
28083 +++ linux-2.6.33-vs2.3.0.36.30.1/net/core/sock.c 2010-02-25 12:02:16.000000000 +0100
28084 @@ -125,6 +125,10 @@
28085 #include <linux/ipsec.h>
28087 #include <linux/filter.h>
28088 +#include <linux/vs_socket.h>
28089 +#include <linux/vs_limit.h>
28090 +#include <linux/vs_context.h>
28091 +#include <linux/vs_network.h>
28094 #include <net/tcp.h>
28095 @@ -1008,6 +1012,8 @@ static struct sock *sk_prot_alloc(struct
28097 sk_tx_queue_clear(sk);
28099 + sock_vx_init(sk);
28100 + sock_nx_init(sk);
28104 @@ -1087,6 +1093,11 @@ static void __sk_free(struct sock *sk)
28105 __func__, atomic_read(&sk->sk_omem_alloc));
28107 put_net(sock_net(sk));
28109 + clr_vx_info(&sk->sk_vx_info);
28111 + clr_nx_info(&sk->sk_nx_info);
28113 sk_prot_free(sk->sk_prot_creator, sk);
28116 @@ -1134,6 +1145,8 @@ struct sock *sk_clone(const struct sock
28119 get_net(sock_net(newsk));
28120 + sock_vx_init(newsk);
28121 + sock_nx_init(newsk);
28122 sk_node_init(&newsk->sk_node);
28123 sock_lock_init(newsk);
28124 bh_lock_sock(newsk);
28125 @@ -1188,6 +1201,12 @@ struct sock *sk_clone(const struct sock
28127 atomic_set(&newsk->sk_refcnt, 2);
28129 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
28130 + newsk->sk_xid = sk->sk_xid;
28131 + vx_sock_inc(newsk);
28132 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
28133 + newsk->sk_nid = sk->sk_nid;
28136 * Increment the counter in the same struct proto as the master
28137 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
28138 @@ -1910,6 +1929,12 @@ void sock_init_data(struct socket *sock,
28140 sk->sk_stamp = ktime_set(-1L, 0);
28142 + set_vx_info(&sk->sk_vx_info, current_vx_info());
28143 + sk->sk_xid = vx_current_xid();
28145 + set_nx_info(&sk->sk_nx_info, current_nx_info());
28146 + sk->sk_nid = nx_current_nid();
28149 * Before updating sk_refcnt, we must commit prior changes to memory
28150 * (Documentation/RCU/rculist_nulls.txt for details)
28151 diff -NurpP --minimal linux-2.6.33/net/ipv4/af_inet.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/af_inet.c
28152 --- linux-2.6.33/net/ipv4/af_inet.c 2010-02-25 11:52:10.000000000 +0100
28153 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/af_inet.c 2010-02-25 15:53:12.000000000 +0100
28154 @@ -115,6 +115,7 @@
28155 #ifdef CONFIG_IP_MROUTE
28156 #include <linux/mroute.h>
28158 +#include <linux/vs_limit.h>
28161 /* The inetsw table contains everything that inet_create needs to
28162 @@ -326,9 +327,13 @@ lookup_protocol:
28166 + if ((protocol == IPPROTO_ICMP) &&
28167 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
28170 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
28171 goto out_rcu_unlock;
28174 err = -EAFNOSUPPORT;
28175 if (!inet_netns_ok(net, protocol))
28176 goto out_rcu_unlock;
28177 @@ -448,6 +453,7 @@ int inet_bind(struct socket *sock, struc
28178 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
28179 struct sock *sk = sock->sk;
28180 struct inet_sock *inet = inet_sk(sk);
28181 + struct nx_v4_sock_addr nsa;
28182 unsigned short snum;
28185 @@ -461,7 +467,11 @@ int inet_bind(struct socket *sock, struc
28186 if (addr_len < sizeof(struct sockaddr_in))
28189 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
28190 + err = v4_map_sock_addr(inet, addr, &nsa);
28194 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
28196 /* Not specified by any standard per-se, however it breaks too
28197 * many applications when removed. It is unfortunate since
28198 @@ -473,7 +483,7 @@ int inet_bind(struct socket *sock, struc
28199 err = -EADDRNOTAVAIL;
28200 if (!sysctl_ip_nonlocal_bind &&
28201 !(inet->freebind || inet->transparent) &&
28202 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
28203 + nsa.saddr != htonl(INADDR_ANY) &&
28204 chk_addr_ret != RTN_LOCAL &&
28205 chk_addr_ret != RTN_MULTICAST &&
28206 chk_addr_ret != RTN_BROADCAST)
28207 @@ -498,7 +508,7 @@ int inet_bind(struct socket *sock, struc
28208 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
28209 goto out_release_sock;
28211 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
28212 + v4_set_sock_addr(inet, &nsa);
28213 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28214 inet->inet_saddr = 0; /* Use device */
28216 @@ -695,11 +705,13 @@ int inet_getname(struct socket *sock, st
28219 sin->sin_port = inet->inet_dport;
28220 - sin->sin_addr.s_addr = inet->inet_daddr;
28221 + sin->sin_addr.s_addr =
28222 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
28224 __be32 addr = inet->inet_rcv_saddr;
28226 addr = inet->inet_saddr;
28227 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
28228 sin->sin_port = inet->inet_sport;
28229 sin->sin_addr.s_addr = addr;
28231 diff -NurpP --minimal linux-2.6.33/net/ipv4/devinet.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/devinet.c
28232 --- linux-2.6.33/net/ipv4/devinet.c 2010-02-25 11:52:10.000000000 +0100
28233 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/devinet.c 2010-02-25 14:19:58.000000000 +0100
28234 @@ -416,6 +416,7 @@ struct in_device *inetdev_by_index(struc
28236 EXPORT_SYMBOL(inetdev_by_index);
28239 /* Called only from RTNL semaphored context. No locks. */
28241 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
28242 @@ -658,6 +659,8 @@ int devinet_ioctl(struct net *net, unsig
28244 in_dev = __in_dev_get_rtnl(dev);
28246 + struct nx_info *nxi = current_nx_info();
28248 if (tryaddrmatch) {
28249 /* Matthias Andree */
28250 /* compare label and address (4.4BSD style) */
28251 @@ -666,6 +669,8 @@ int devinet_ioctl(struct net *net, unsig
28252 This is checked above. */
28253 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28254 ifap = &ifa->ifa_next) {
28255 + if (!nx_v4_ifa_visible(nxi, ifa))
28257 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
28258 sin_orig.sin_addr.s_addr ==
28259 ifa->ifa_address) {
28260 @@ -678,9 +683,12 @@ int devinet_ioctl(struct net *net, unsig
28261 comparing just the label */
28263 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28264 - ifap = &ifa->ifa_next)
28265 + ifap = &ifa->ifa_next) {
28266 + if (!nx_v4_ifa_visible(nxi, ifa))
28268 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
28274 @@ -832,6 +840,8 @@ static int inet_gifconf(struct net_devic
28277 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
28278 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
28281 done += sizeof(ifr);
28283 @@ -1180,6 +1190,7 @@ static int inet_dump_ifaddr(struct sk_bu
28284 struct net_device *dev;
28285 struct in_device *in_dev;
28286 struct in_ifaddr *ifa;
28287 + struct sock *sk = skb->sk;
28288 struct hlist_head *head;
28289 struct hlist_node *node;
28291 @@ -1202,6 +1213,8 @@ static int inet_dump_ifaddr(struct sk_bu
28293 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
28294 ifa = ifa->ifa_next, ip_idx++) {
28295 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
28297 if (ip_idx < s_ip_idx)
28299 if (inet_fill_ifaddr(skb, ifa,
28300 diff -NurpP --minimal linux-2.6.33/net/ipv4/fib_hash.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/fib_hash.c
28301 --- linux-2.6.33/net/ipv4/fib_hash.c 2010-02-25 11:52:10.000000000 +0100
28302 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/fib_hash.c 2010-02-25 12:02:16.000000000 +0100
28303 @@ -1016,7 +1016,7 @@ static int fib_seq_show(struct seq_file
28304 prefix = f->fn_key;
28305 mask = FZ_MASK(iter->zone);
28306 flags = fib_flag_trans(fa->fa_type, mask, fi);
28308 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
28310 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
28311 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
28312 diff -NurpP --minimal linux-2.6.33/net/ipv4/inet_connection_sock.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/inet_connection_sock.c
28313 --- linux-2.6.33/net/ipv4/inet_connection_sock.c 2010-02-25 11:52:10.000000000 +0100
28314 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/inet_connection_sock.c 2010-02-25 12:02:16.000000000 +0100
28315 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
28317 EXPORT_SYMBOL(inet_get_local_port_range);
28319 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28321 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
28322 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
28324 + if (inet_v6_ipv6only(sk2))
28327 + if (sk1_rcv_saddr &&
28329 + sk1_rcv_saddr == sk2_rcv_saddr)
28332 + if (sk1_rcv_saddr &&
28333 + !sk2_rcv_saddr &&
28334 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
28337 + if (sk2_rcv_saddr &&
28338 + !sk1_rcv_saddr &&
28339 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
28342 + if (!sk1_rcv_saddr &&
28343 + !sk2_rcv_saddr &&
28344 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
28350 int inet_csk_bind_conflict(const struct sock *sk,
28351 const struct inet_bind_bucket *tb)
28353 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
28355 struct hlist_node *node;
28356 int reuse = sk->sk_reuse;
28357 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
28358 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
28359 if (!reuse || !sk2->sk_reuse ||
28360 sk2->sk_state == TCP_LISTEN) {
28361 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28362 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
28363 - sk2_rcv_saddr == sk_rcv_saddr)
28364 + if (ipv4_rcv_saddr_equal(sk, sk2))
28368 diff -NurpP --minimal linux-2.6.33/net/ipv4/inet_diag.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/inet_diag.c
28369 --- linux-2.6.33/net/ipv4/inet_diag.c 2010-02-25 11:52:10.000000000 +0100
28370 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/inet_diag.c 2010-02-25 14:16:01.000000000 +0100
28372 #include <linux/stddef.h>
28374 #include <linux/inet_diag.h>
28375 +#include <linux/vs_network.h>
28376 +#include <linux/vs_inet.h>
28378 static const struct inet_diag_handler **inet_diag_table;
28380 @@ -118,8 +120,10 @@ static int inet_csk_diag_fill(struct soc
28382 r->id.idiag_sport = inet->inet_sport;
28383 r->id.idiag_dport = inet->inet_dport;
28384 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
28385 - r->id.idiag_dst[0] = inet->inet_daddr;
28386 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
28387 + inet->inet_rcv_saddr);
28388 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
28389 + inet->inet_daddr);
28391 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28392 if (r->idiag_family == AF_INET6) {
28393 @@ -204,8 +208,8 @@ static int inet_twsk_diag_fill(struct in
28394 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
28395 r->id.idiag_sport = tw->tw_sport;
28396 r->id.idiag_dport = tw->tw_dport;
28397 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
28398 - r->id.idiag_dst[0] = tw->tw_daddr;
28399 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
28400 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
28401 r->idiag_state = tw->tw_substate;
28402 r->idiag_timer = 3;
28403 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
28404 @@ -262,6 +266,7 @@ static int inet_diag_get_exact(struct sk
28407 if (req->idiag_family == AF_INET) {
28408 + /* TODO: lback */
28409 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
28410 req->id.idiag_dport, req->id.idiag_src[0],
28411 req->id.idiag_sport, req->id.idiag_if);
28412 @@ -504,6 +509,7 @@ static int inet_csk_diag_dump(struct soc
28416 + /* TODO: lback */
28417 entry.saddr = &inet->inet_rcv_saddr;
28418 entry.daddr = &inet->inet_daddr;
28420 @@ -540,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
28424 + /* TODO: lback */
28425 entry.saddr = &tw->tw_rcv_saddr;
28426 entry.daddr = &tw->tw_daddr;
28428 @@ -586,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
28430 r->id.idiag_sport = inet->inet_sport;
28431 r->id.idiag_dport = ireq->rmt_port;
28432 - r->id.idiag_src[0] = ireq->loc_addr;
28433 - r->id.idiag_dst[0] = ireq->rmt_addr;
28434 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
28435 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
28436 r->idiag_expires = jiffies_to_msecs(tmo);
28437 r->idiag_rqueue = 0;
28438 r->idiag_wqueue = 0;
28439 @@ -657,6 +664,7 @@ static int inet_diag_dump_reqs(struct sk
28443 + /* TODO: lback */
28445 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28446 (entry.family == AF_INET6) ?
28447 @@ -727,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
28448 sk_nulls_for_each(sk, node, &ilb->head) {
28449 struct inet_sock *inet = inet_sk(sk);
28451 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28456 @@ -793,6 +803,8 @@ skip_listen_ht:
28457 sk_nulls_for_each(sk, node, &head->chain) {
28458 struct inet_sock *inet = inet_sk(sk);
28460 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28464 if (!(r->idiag_states & (1 << sk->sk_state)))
28465 @@ -817,6 +829,8 @@ next_normal:
28466 inet_twsk_for_each(tw, node,
28469 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28473 if (r->id.idiag_sport != tw->tw_sport &&
28474 diff -NurpP --minimal linux-2.6.33/net/ipv4/inet_hashtables.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/inet_hashtables.c
28475 --- linux-2.6.33/net/ipv4/inet_hashtables.c 2010-02-25 11:52:10.000000000 +0100
28476 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/inet_hashtables.c 2010-02-25 12:02:16.000000000 +0100
28479 #include <net/inet_connection_sock.h>
28480 #include <net/inet_hashtables.h>
28481 +#include <net/route.h>
28482 #include <net/ip.h>
28485 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
28486 if (rcv_saddr != daddr)
28490 + /* block non nx_info ips */
28491 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
28492 + daddr, NXA_MASK_BIND))
28495 if (sk->sk_bound_dev_if) {
28496 if (sk->sk_bound_dev_if != dif)
28497 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
28498 * wildcarded during the search since they can never be otherwise.
28502 struct sock *__inet_lookup_listener(struct net *net,
28503 struct inet_hashinfo *hashinfo,
28504 const __be32 daddr, const unsigned short hnum,
28505 @@ -174,6 +179,7 @@ begin:
28511 * if the nulls value we got at the end of this lookup is
28512 * not the expected one, we must restart lookup.
28513 diff -NurpP --minimal linux-2.6.33/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/netfilter/nf_nat_helper.c
28514 --- linux-2.6.33/net/ipv4/netfilter/nf_nat_helper.c 2010-02-25 11:52:10.000000000 +0100
28515 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/netfilter/nf_nat_helper.c 2010-02-25 12:02:16.000000000 +0100
28517 #include <net/route.h>
28519 #include <linux/netfilter_ipv4.h>
28520 +#include <net/route.h>
28521 #include <net/netfilter/nf_conntrack.h>
28522 #include <net/netfilter/nf_conntrack_helper.h>
28523 #include <net/netfilter/nf_conntrack_ecache.h>
28524 diff -NurpP --minimal linux-2.6.33/net/ipv4/netfilter.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/netfilter.c
28525 --- linux-2.6.33/net/ipv4/netfilter.c 2010-02-25 11:52:10.000000000 +0100
28526 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/netfilter.c 2010-02-25 12:02:16.000000000 +0100
28528 #include <linux/netfilter_ipv4.h>
28529 #include <linux/ip.h>
28530 #include <linux/skbuff.h>
28531 -#include <net/route.h>
28532 +// #include <net/route.h>
28533 #include <net/xfrm.h>
28534 #include <net/ip.h>
28535 #include <net/netfilter/nf_queue.h>
28536 diff -NurpP --minimal linux-2.6.33/net/ipv4/raw.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/raw.c
28537 --- linux-2.6.33/net/ipv4/raw.c 2010-02-25 11:52:10.000000000 +0100
28538 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/raw.c 2010-02-25 14:07:52.000000000 +0100
28539 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
28541 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
28542 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
28543 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
28544 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
28545 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
28546 goto found; /* gotcha */
28548 @@ -382,6 +382,12 @@ static int raw_send_hdrinc(struct sock *
28549 icmp_out_count(net, ((struct icmphdr *)
28550 skb_transport_header(skb))->type);
28553 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
28554 + sk->sk_nx_info &&
28555 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
28558 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
28561 @@ -562,6 +568,13 @@ static int raw_sendmsg(struct kiocb *ioc
28564 security_sk_classify_flow(sk, &fl);
28565 + if (sk->sk_nx_info) {
28566 + err = ip_v4_find_src(sock_net(sk),
28567 + sk->sk_nx_info, &rt, &fl);
28572 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
28575 @@ -634,17 +647,19 @@ static int raw_bind(struct sock *sk, str
28577 struct inet_sock *inet = inet_sk(sk);
28578 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
28579 + struct nx_v4_sock_addr nsa = { 0 };
28583 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
28585 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
28586 + v4_map_sock_addr(inet, addr, &nsa);
28587 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
28588 ret = -EADDRNOTAVAIL;
28589 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
28590 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
28591 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
28593 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
28594 + v4_set_sock_addr(inet, &nsa);
28595 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28596 inet->inet_saddr = 0; /* Use device */
28598 @@ -696,7 +711,8 @@ static int raw_recvmsg(struct kiocb *ioc
28599 /* Copy the address. */
28601 sin->sin_family = AF_INET;
28602 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
28603 + sin->sin_addr.s_addr =
28604 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
28606 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
28608 @@ -874,7 +890,8 @@ static struct sock *raw_get_first(struct
28609 struct hlist_node *node;
28611 sk_for_each(sk, node, &state->h->ht[state->bucket])
28612 - if (sock_net(sk) == seq_file_net(seq))
28613 + if ((sock_net(sk) == seq_file_net(seq)) &&
28614 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28618 @@ -890,7 +907,8 @@ static struct sock *raw_get_next(struct
28622 - } while (sk && sock_net(sk) != seq_file_net(seq));
28623 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
28624 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
28626 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
28627 sk = sk_head(&state->h->ht[state->bucket]);
28628 @@ -949,7 +967,10 @@ static void raw_sock_seq_show(struct seq
28630 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
28631 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
28632 - i, src, srcp, dest, destp, sp->sk_state,
28634 + nx_map_sock_lback(current_nx_info(), src), srcp,
28635 + nx_map_sock_lback(current_nx_info(), dest), destp,
28637 sk_wmem_alloc_get(sp),
28638 sk_rmem_alloc_get(sp),
28639 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28640 diff -NurpP --minimal linux-2.6.33/net/ipv4/tcp.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/tcp.c
28641 --- linux-2.6.33/net/ipv4/tcp.c 2010-02-25 11:52:10.000000000 +0100
28642 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/tcp.c 2010-02-25 14:03:32.000000000 +0100
28643 @@ -265,6 +265,7 @@
28644 #include <linux/err.h>
28645 #include <linux/crypto.h>
28646 #include <linux/time.h>
28647 +#include <linux/in.h>
28649 #include <net/icmp.h>
28650 #include <net/tcp.h>
28651 diff -NurpP --minimal linux-2.6.33/net/ipv4/tcp_ipv4.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/tcp_ipv4.c
28652 --- linux-2.6.33/net/ipv4/tcp_ipv4.c 2010-02-25 11:52:10.000000000 +0100
28653 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/tcp_ipv4.c 2010-02-25 14:08:55.000000000 +0100
28654 @@ -1988,6 +1988,12 @@ static void *listening_get_next(struct s
28655 req = req->dl_next;
28658 + vxdprintk(VXD_CBIT(net, 6),
28659 + "sk,req: %p [#%d] (from %d)", req->sk,
28660 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
28662 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
28664 if (req->rsk_ops->family == st->family) {
28667 @@ -2012,6 +2018,10 @@ get_req:
28670 sk_nulls_for_each_from(sk, node) {
28671 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
28672 + sk, sk->sk_nid, nx_current_nid());
28673 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28675 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
28678 @@ -2075,6 +2085,11 @@ static void *established_get_first(struc
28680 spin_lock_bh(lock);
28681 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
28682 + vxdprintk(VXD_CBIT(net, 6),
28683 + "sk,egf: %p [#%d] (from %d)",
28684 + sk, sk->sk_nid, nx_current_nid());
28685 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28687 if (sk->sk_family != st->family ||
28688 !net_eq(sock_net(sk), net)) {
28690 @@ -2085,6 +2100,11 @@ static void *established_get_first(struc
28691 st->state = TCP_SEQ_STATE_TIME_WAIT;
28692 inet_twsk_for_each(tw, node,
28693 &tcp_hashinfo.ehash[st->bucket].twchain) {
28694 + vxdprintk(VXD_CBIT(net, 6),
28695 + "tw: %p [#%d] (from %d)",
28696 + tw, tw->tw_nid, nx_current_nid());
28697 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28699 if (tw->tw_family != st->family ||
28700 !net_eq(twsk_net(tw), net)) {
28702 @@ -2113,7 +2133,9 @@ static void *established_get_next(struct
28706 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
28707 + while (tw && (tw->tw_family != st->family ||
28708 + !net_eq(twsk_net(tw), net) ||
28709 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
28713 @@ -2136,6 +2158,11 @@ get_tw:
28714 sk = sk_nulls_next(sk);
28716 sk_nulls_for_each_from(sk, node) {
28717 + vxdprintk(VXD_CBIT(net, 6),
28718 + "sk,egn: %p [#%d] (from %d)",
28719 + sk, sk->sk_nid, nx_current_nid());
28720 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28722 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
28725 @@ -2287,9 +2314,9 @@ static void get_openreq4(struct sock *sk
28726 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
28727 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
28730 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
28731 ntohs(inet_sk(sk)->inet_sport),
28733 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
28734 ntohs(ireq->rmt_port),
28736 0, 0, /* could print option size, but that is af dependent. */
28737 @@ -2341,7 +2368,10 @@ static void get_tcp4_sock(struct sock *s
28739 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
28740 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
28741 - i, src, srcp, dest, destp, sk->sk_state,
28743 + nx_map_sock_lback(current_nx_info(), src), srcp,
28744 + nx_map_sock_lback(current_nx_info(), dest), destp,
28746 tp->write_seq - tp->snd_una,
28749 @@ -2376,7 +2406,10 @@ static void get_timewait4_sock(struct in
28751 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
28752 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
28753 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
28755 + nx_map_sock_lback(current_nx_info(), src), srcp,
28756 + nx_map_sock_lback(current_nx_info(), dest), destp,
28757 + tw->tw_substate, 0, 0,
28758 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
28759 atomic_read(&tw->tw_refcnt), tw, len);
28761 diff -NurpP --minimal linux-2.6.33/net/ipv4/tcp_minisocks.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/tcp_minisocks.c
28762 --- linux-2.6.33/net/ipv4/tcp_minisocks.c 2010-02-25 11:52:10.000000000 +0100
28763 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/tcp_minisocks.c 2010-02-25 14:03:06.000000000 +0100
28765 #include <linux/module.h>
28766 #include <linux/sysctl.h>
28767 #include <linux/workqueue.h>
28768 +#include <linux/vs_limit.h>
28769 +#include <linux/vs_socket.h>
28770 +#include <linux/vs_context.h>
28771 #include <net/tcp.h>
28772 #include <net/inet_common.h>
28773 #include <net/xfrm.h>
28774 @@ -289,6 +292,11 @@ void tcp_time_wait(struct sock *sk, int
28775 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
28776 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
28778 + tw->tw_xid = sk->sk_xid;
28779 + tw->tw_vx_info = NULL;
28780 + tw->tw_nid = sk->sk_nid;
28781 + tw->tw_nx_info = NULL;
28783 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
28784 if (tw->tw_family == PF_INET6) {
28785 struct ipv6_pinfo *np = inet6_sk(sk);
28786 diff -NurpP --minimal linux-2.6.33/net/ipv4/udp.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/udp.c
28787 --- linux-2.6.33/net/ipv4/udp.c 2010-02-25 11:52:10.000000000 +0100
28788 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv4/udp.c 2010-02-25 14:18:12.000000000 +0100
28789 @@ -294,14 +294,7 @@ fail:
28791 EXPORT_SYMBOL(udp_lib_get_port);
28793 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28795 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
28797 - return (!ipv6_only_sock(sk2) &&
28798 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
28799 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
28801 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
28803 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
28805 @@ -336,6 +329,11 @@ static inline int compute_score(struct s
28806 if (inet->inet_rcv_saddr != daddr)
28810 + /* block non nx_info ips */
28811 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
28812 + daddr, NXA_MASK_BIND))
28815 if (inet->inet_daddr) {
28816 if (inet->inet_daddr != saddr)
28817 @@ -439,6 +437,7 @@ exact_match:
28822 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
28823 * harder than this. -DaveM
28825 @@ -484,6 +483,11 @@ begin:
28826 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
28827 score = compute_score(sk, net, saddr, hnum, sport,
28828 daddr, dport, dif);
28829 + /* FIXME: disabled?
28830 + if (score == 9) {
28834 if (score > badness) {
28837 @@ -497,6 +501,7 @@ begin:
28838 if (get_nulls_value(node) != slot)
28843 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
28845 @@ -506,6 +511,7 @@ begin:
28853 @@ -548,8 +554,7 @@ static inline struct sock *udp_v4_mcast_
28854 udp_sk(s)->udp_port_hash != hnum ||
28855 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
28856 (inet->inet_dport != rmt_port && inet->inet_dport) ||
28857 - (inet->inet_rcv_saddr &&
28858 - inet->inet_rcv_saddr != loc_addr) ||
28859 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
28860 ipv6_only_sock(s) ||
28861 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
28863 @@ -898,8 +903,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
28864 { .sport = inet->inet_sport,
28865 .dport = dport } } };
28866 struct net *net = sock_net(sk);
28867 + struct nx_info *nxi = sk->sk_nx_info;
28869 security_sk_classify_flow(sk, &fl);
28870 + err = ip_v4_find_src(net, nxi, &rt, &fl);
28874 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
28876 if (err == -ENETUNREACH)
28877 @@ -1180,7 +1190,8 @@ try_again:
28879 sin->sin_family = AF_INET;
28880 sin->sin_port = udp_hdr(skb)->source;
28881 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
28882 + sin->sin_addr.s_addr = nx_map_sock_lback(
28883 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
28884 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
28886 if (inet->cmsg_flags)
28887 @@ -1865,6 +1876,8 @@ static struct sock *udp_get_first(struct
28888 sk_nulls_for_each(sk, node, &hslot->head) {
28889 if (!net_eq(sock_net(sk), net))
28891 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28893 if (sk->sk_family == state->family)
28896 @@ -1882,7 +1895,9 @@ static struct sock *udp_get_next(struct
28899 sk = sk_nulls_next(sk);
28900 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
28901 + } while (sk && (!net_eq(sock_net(sk), net) ||
28902 + sk->sk_family != state->family ||
28903 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
28906 if (state->bucket <= state->udp_table->mask)
28907 @@ -1989,7 +2004,10 @@ static void udp4_format_sock(struct sock
28909 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
28910 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
28911 - bucket, src, srcp, dest, destp, sp->sk_state,
28913 + nx_map_sock_lback(current_nx_info(), src), srcp,
28914 + nx_map_sock_lback(current_nx_info(), dest), destp,
28916 sk_wmem_alloc_get(sp),
28917 sk_rmem_alloc_get(sp),
28918 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28919 diff -NurpP --minimal linux-2.6.33/net/ipv6/addrconf.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/addrconf.c
28920 --- linux-2.6.33/net/ipv6/addrconf.c 2010-02-25 11:52:10.000000000 +0100
28921 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/addrconf.c 2010-02-25 13:40:38.000000000 +0100
28924 #include <linux/proc_fs.h>
28925 #include <linux/seq_file.h>
28926 +#include <linux/vs_network.h>
28927 +#include <linux/vs_inet6.h>
28929 /* Set to 3 to get tracing... */
28930 #define ACONF_DEBUG 2
28931 @@ -1120,7 +1122,7 @@ out:
28933 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
28934 const struct in6_addr *daddr, unsigned int prefs,
28935 - struct in6_addr *saddr)
28936 + struct in6_addr *saddr, struct nx_info *nxi)
28938 struct ipv6_saddr_score scores[2],
28939 *score = &scores[0], *hiscore = &scores[1];
28940 @@ -1192,6 +1194,8 @@ int ipv6_dev_get_saddr(struct net *net,
28944 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
28948 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
28949 @@ -2999,7 +3003,10 @@ static void if6_seq_stop(struct seq_file
28950 static int if6_seq_show(struct seq_file *seq, void *v)
28952 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
28953 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28955 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
28956 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
28957 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28959 ifp->idev->dev->ifindex,
28961 @@ -3494,6 +3501,11 @@ static int in6_dump_addrs(struct inet6_d
28962 struct ifacaddr6 *ifaca;
28964 int ip_idx = *p_ip_idx;
28965 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28967 + /* disable ipv6 on non v6 guests */
28968 + if (nxi && !nx_info_has_v6(nxi))
28971 read_lock_bh(&idev->lock);
28973 @@ -3503,6 +3515,8 @@ static int in6_dump_addrs(struct inet6_d
28974 ifa = ifa->if_next, ip_idx++) {
28975 if (ip_idx < s_ip_idx)
28977 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
28979 err = inet6_fill_ifaddr(skb, ifa,
28980 NETLINK_CB(cb->skb).pid,
28981 cb->nlh->nlmsg_seq,
28982 @@ -3518,6 +3532,8 @@ static int in6_dump_addrs(struct inet6_d
28983 ifmca = ifmca->next, ip_idx++) {
28984 if (ip_idx < s_ip_idx)
28986 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
28988 err = inet6_fill_ifmcaddr(skb, ifmca,
28989 NETLINK_CB(cb->skb).pid,
28990 cb->nlh->nlmsg_seq,
28991 @@ -3533,6 +3549,8 @@ static int in6_dump_addrs(struct inet6_d
28992 ifaca = ifaca->aca_next, ip_idx++) {
28993 if (ip_idx < s_ip_idx)
28995 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
28997 err = inet6_fill_ifacaddr(skb, ifaca,
28998 NETLINK_CB(cb->skb).pid,
28999 cb->nlh->nlmsg_seq,
29000 @@ -3861,6 +3879,11 @@ static int inet6_dump_ifinfo(struct sk_b
29001 struct inet6_dev *idev;
29002 struct hlist_head *head;
29003 struct hlist_node *node;
29004 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29006 + /* FIXME: maybe disable ipv6 on non v6 guests?
29007 + if (skb->sk && skb->sk->sk_vx_info)
29008 + return skb->len; */
29011 s_idx = cb->args[1];
29012 @@ -3872,6 +3895,8 @@ static int inet6_dump_ifinfo(struct sk_b
29013 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
29016 + if (!v6_dev_in_nx_info(dev, nxi))
29018 idev = __in6_dev_get(dev);
29021 diff -NurpP --minimal linux-2.6.33/net/ipv6/af_inet6.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/af_inet6.c
29022 --- linux-2.6.33/net/ipv6/af_inet6.c 2010-02-25 11:52:10.000000000 +0100
29023 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/af_inet6.c 2010-02-25 15:54:53.000000000 +0100
29025 #include <linux/netdevice.h>
29026 #include <linux/icmpv6.h>
29027 #include <linux/netfilter_ipv6.h>
29028 +#include <linux/vs_inet.h>
29029 +#include <linux/vs_inet6.h>
29031 #include <net/ip.h>
29032 #include <net/ipv6.h>
29033 @@ -159,9 +161,12 @@ lookup_protocol:
29037 + if ((protocol == IPPROTO_ICMPV6) &&
29038 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
29040 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
29041 goto out_rcu_unlock;
29044 sock->ops = answer->ops;
29045 answer_prot = answer->prot;
29046 answer_no_check = answer->no_check;
29047 @@ -260,6 +265,7 @@ int inet6_bind(struct socket *sock, stru
29048 struct inet_sock *inet = inet_sk(sk);
29049 struct ipv6_pinfo *np = inet6_sk(sk);
29050 struct net *net = sock_net(sk);
29051 + struct nx_v6_sock_addr nsa;
29053 unsigned short snum;
29055 @@ -271,6 +277,11 @@ int inet6_bind(struct socket *sock, stru
29057 if (addr_len < SIN6_LEN_RFC2133)
29060 + err = v6_map_sock_addr(inet, addr, &nsa);
29064 addr_type = ipv6_addr_type(&addr->sin6_addr);
29065 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
29067 @@ -302,6 +313,7 @@ int inet6_bind(struct socket *sock, stru
29068 /* Reproduce AF_INET checks to make the bindings consitant */
29069 v4addr = addr->sin6_addr.s6_addr32[3];
29070 chk_addr_ret = inet_addr_type(net, v4addr);
29072 if (!sysctl_ip_nonlocal_bind &&
29073 !(inet->freebind || inet->transparent) &&
29074 v4addr != htonl(INADDR_ANY) &&
29075 @@ -311,6 +323,10 @@ int inet6_bind(struct socket *sock, stru
29076 err = -EADDRNOTAVAIL;
29079 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
29080 + err = -EADDRNOTAVAIL;
29084 if (addr_type != IPV6_ADDR_ANY) {
29085 struct net_device *dev = NULL;
29086 @@ -337,6 +353,11 @@ int inet6_bind(struct socket *sock, stru
29090 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29091 + err = -EADDRNOTAVAIL;
29095 /* ipv4 addr of the socket is invalid. Only the
29096 * unspecified and mapped address have a v4 equivalent.
29098 @@ -352,6 +373,9 @@ int inet6_bind(struct socket *sock, stru
29102 + /* what's that for? */
29103 + v6_set_sock_addr(inet, &nsa);
29105 inet->inet_rcv_saddr = v4addr;
29106 inet->inet_saddr = v4addr;
29108 @@ -450,9 +474,11 @@ int inet6_getname(struct socket *sock, s
29110 sin->sin6_port = inet->inet_dport;
29111 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
29112 + /* FIXME: remap lback? */
29114 sin->sin6_flowinfo = np->flow_label;
29116 + /* FIXME: remap lback? */
29117 if (ipv6_addr_any(&np->rcv_saddr))
29118 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
29120 diff -NurpP --minimal linux-2.6.33/net/ipv6/fib6_rules.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/fib6_rules.c
29121 --- linux-2.6.33/net/ipv6/fib6_rules.c 2010-02-25 11:52:10.000000000 +0100
29122 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/fib6_rules.c 2010-02-25 12:02:16.000000000 +0100
29123 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
29124 if (ipv6_dev_get_saddr(net,
29125 ip6_dst_idev(&rt->u.dst)->dev,
29126 &flp->fl6_dst, srcprefs,
29130 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
29132 diff -NurpP --minimal linux-2.6.33/net/ipv6/inet6_hashtables.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/inet6_hashtables.c
29133 --- linux-2.6.33/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
29134 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/inet6_hashtables.c 2010-02-25 12:02:16.000000000 +0100
29137 #include <linux/module.h>
29138 #include <linux/random.h>
29139 +#include <linux/vs_inet6.h>
29141 #include <net/inet_connection_sock.h>
29142 #include <net/inet_hashtables.h>
29143 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
29144 unsigned int slot = hash & hashinfo->ehash_mask;
29145 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
29150 sk_nulls_for_each_rcu(sk, node, &head->chain) {
29151 @@ -94,7 +94,7 @@ begin:
29159 if (get_nulls_value(node) != slot)
29160 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
29161 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29165 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29168 if (sk->sk_bound_dev_if) {
29169 if (sk->sk_bound_dev_if != dif)
29170 diff -NurpP --minimal linux-2.6.33/net/ipv6/ip6_output.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/ip6_output.c
29171 --- linux-2.6.33/net/ipv6/ip6_output.c 2010-02-25 11:52:10.000000000 +0100
29172 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/ip6_output.c 2010-02-25 12:02:16.000000000 +0100
29173 @@ -933,7 +933,7 @@ static int ip6_dst_lookup_tail(struct so
29174 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
29176 sk ? inet6_sk(sk)->srcprefs : 0,
29178 + &fl->fl6_src, sk->sk_nx_info);
29180 goto out_err_release;
29182 diff -NurpP --minimal linux-2.6.33/net/ipv6/Kconfig linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/Kconfig
29183 --- linux-2.6.33/net/ipv6/Kconfig 2010-02-25 11:52:10.000000000 +0100
29184 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/Kconfig 2010-02-25 12:02:16.000000000 +0100
29187 # IPv6 as module will cause a CRASH if you try to unload it
29189 - tristate "The IPv6 protocol"
29191 + bool "The IPv6 protocol"
29194 This is complemental support for the IP version 6.
29195 You will still be able to do traditional IPv4 networking as well.
29196 diff -NurpP --minimal linux-2.6.33/net/ipv6/ndisc.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/ndisc.c
29197 --- linux-2.6.33/net/ipv6/ndisc.c 2010-02-25 11:52:10.000000000 +0100
29198 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/ndisc.c 2010-02-25 12:02:16.000000000 +0100
29199 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
29201 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
29202 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
29204 + &tmpaddr, NULL /* FIXME: ? */ ))
29206 src_addr = &tmpaddr;
29208 diff -NurpP --minimal linux-2.6.33/net/ipv6/raw.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/raw.c
29209 --- linux-2.6.33/net/ipv6/raw.c 2010-02-25 11:52:11.000000000 +0100
29210 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/raw.c 2010-02-25 12:02:16.000000000 +0100
29212 #include <linux/icmpv6.h>
29213 #include <linux/netfilter.h>
29214 #include <linux/netfilter_ipv6.h>
29215 +#include <linux/vs_inet6.h>
29216 #include <linux/skbuff.h>
29217 #include <asm/uaccess.h>
29218 #include <asm/ioctls.h>
29219 @@ -282,6 +283,13 @@ static int rawv6_bind(struct sock *sk, s
29223 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29224 + err = -EADDRNOTAVAIL;
29230 /* ipv4 addr of the socket is invalid. Only the
29231 * unspecified and mapped address have a v4 equivalent.
29233 diff -NurpP --minimal linux-2.6.33/net/ipv6/route.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/route.c
29234 --- linux-2.6.33/net/ipv6/route.c 2010-02-25 11:52:11.000000000 +0100
29235 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/route.c 2010-02-25 12:02:16.000000000 +0100
29236 @@ -2258,7 +2258,8 @@ static int rt6_fill_node(struct net *net
29237 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
29238 struct in6_addr saddr_buf;
29239 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
29240 - dst, 0, &saddr_buf) == 0)
29241 + dst, 0, &saddr_buf,
29242 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
29243 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
29246 diff -NurpP --minimal linux-2.6.33/net/ipv6/tcp_ipv6.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/tcp_ipv6.c
29247 --- linux-2.6.33/net/ipv6/tcp_ipv6.c 2010-02-25 11:52:11.000000000 +0100
29248 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/tcp_ipv6.c 2010-02-25 12:02:16.000000000 +0100
29251 #include <linux/crypto.h>
29252 #include <linux/scatterlist.h>
29253 +#include <linux/vs_inet6.h>
29255 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
29256 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
29257 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
29258 * connect() to INADDR_ANY means loopback (BSD'ism).
29261 - if(ipv6_addr_any(&usin->sin6_addr))
29262 - usin->sin6_addr.s6_addr[15] = 0x1;
29263 + if(ipv6_addr_any(&usin->sin6_addr)) {
29264 + struct nx_info *nxi = sk->sk_nx_info;
29266 + if (nxi && nx_info_has_v6(nxi))
29267 + /* FIXME: remap lback? */
29268 + usin->sin6_addr = nxi->v6.ip;
29270 + usin->sin6_addr.s6_addr[15] = 0x1;
29273 addr_type = ipv6_addr_type(&usin->sin6_addr);
29275 diff -NurpP --minimal linux-2.6.33/net/ipv6/udp.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/udp.c
29276 --- linux-2.6.33/net/ipv6/udp.c 2010-02-25 11:52:11.000000000 +0100
29277 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/udp.c 2010-02-25 15:58:22.000000000 +0100
29278 @@ -47,13 +47,14 @@
29280 #include <linux/proc_fs.h>
29281 #include <linux/seq_file.h>
29282 +#include <linux/vs_inet6.h>
29283 #include "udp_impl.h"
29285 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
29287 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
29288 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
29289 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
29290 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
29291 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
29292 int sk_ipv6only = ipv6_only_sock(sk);
29293 int sk2_ipv6only = inet_v6_ipv6only(sk2);
29294 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
29295 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
29297 /* if both are mapped, treat as IPv4 */
29298 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
29299 - return (!sk2_ipv6only &&
29300 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
29301 - sk1_rcv_saddr == sk2_rcv_saddr));
29302 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
29303 + if (!sk2_ipv6only &&
29304 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
29305 + sk_rcv_saddr == sk2_rcv_saddr))
29311 if (addr_type2 == IPV6_ADDR_ANY &&
29312 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
29316 if (addr_type == IPV6_ADDR_ANY &&
29317 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
29321 if (sk2_rcv_saddr6 &&
29322 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
29329 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
29330 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
29331 + if (!sk2_rcv_saddr)
29332 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
29333 + if (!sk_rcv_saddr)
29334 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
29337 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
29338 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
29339 + else if (addr_type2 == IPV6_ADDR_ANY)
29340 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
29341 + else if (addr_type == IPV6_ADDR_ANY) {
29342 + if (addr_type2 == IPV6_ADDR_MAPPED)
29343 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
29345 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
29350 static unsigned int udp6_portaddr_hash(struct net *net,
29351 @@ -133,6 +159,10 @@ static inline int compute_score(struct s
29352 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29356 + /* block non nx_info ips */
29357 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29360 if (!ipv6_addr_any(&np->daddr)) {
29361 if (!ipv6_addr_equal(&np->daddr, saddr))
29362 diff -NurpP --minimal linux-2.6.33/net/ipv6/xfrm6_policy.c linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/xfrm6_policy.c
29363 --- linux-2.6.33/net/ipv6/xfrm6_policy.c 2010-02-25 11:52:11.000000000 +0100
29364 +++ linux-2.6.33-vs2.3.0.36.30.1/net/ipv6/xfrm6_policy.c 2010-02-25 12:02:16.000000000 +0100
29365 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
29366 dev = ip6_dst_idev(dst)->dev;
29367 ipv6_dev_get_saddr(dev_net(dev), dev,
29368 (struct in6_addr *)&daddr->a6, 0,
29369 - (struct in6_addr *)&saddr->a6);
29370 + (struct in6_addr *)&saddr->a6, NULL);
29374 diff -NurpP --minimal linux-2.6.33/net/netlink/af_netlink.c linux-2.6.33-vs2.3.0.36.30.1/net/netlink/af_netlink.c
29375 --- linux-2.6.33/net/netlink/af_netlink.c 2010-02-25 11:52:11.000000000 +0100
29376 +++ linux-2.6.33-vs2.3.0.36.30.1/net/netlink/af_netlink.c 2010-02-25 12:02:16.000000000 +0100
29378 #include <linux/types.h>
29379 #include <linux/audit.h>
29380 #include <linux/mutex.h>
29381 +#include <linux/vs_context.h>
29382 +#include <linux/vs_network.h>
29383 +#include <linux/vs_limit.h>
29385 #include <net/net_namespace.h>
29386 #include <net/sock.h>
29387 @@ -1905,6 +1908,8 @@ static struct sock *netlink_seq_socket_i
29388 sk_for_each(s, node, &hash->table[j]) {
29389 if (sock_net(s) != seq_file_net(seq))
29391 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29395 iter->hash_idx = j;
29396 @@ -1939,7 +1944,8 @@ static void *netlink_seq_next(struct seq
29400 - } while (s && sock_net(s) != seq_file_net(seq));
29401 + } while (s && (sock_net(s) != seq_file_net(seq) ||
29402 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
29406 @@ -1951,7 +1957,8 @@ static void *netlink_seq_next(struct seq
29408 for (; j <= hash->mask; j++) {
29409 s = sk_head(&hash->table[j]);
29410 - while (s && sock_net(s) != seq_file_net(seq))
29411 + while (s && (sock_net(s) != seq_file_net(seq) ||
29412 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
29416 diff -NurpP --minimal linux-2.6.33/net/sctp/ipv6.c linux-2.6.33-vs2.3.0.36.30.1/net/sctp/ipv6.c
29417 --- linux-2.6.33/net/sctp/ipv6.c 2010-02-25 11:52:12.000000000 +0100
29418 +++ linux-2.6.33-vs2.3.0.36.30.1/net/sctp/ipv6.c 2010-02-25 12:02:16.000000000 +0100
29419 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
29420 dst ? ip6_dst_idev(dst)->dev : NULL,
29421 &daddr->v6.sin6_addr,
29422 inet6_sk(&sk->inet.sk)->srcprefs,
29423 - &saddr->v6.sin6_addr);
29424 + &saddr->v6.sin6_addr,
29425 + asoc->base.sk->sk_nx_info);
29426 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
29427 &saddr->v6.sin6_addr);
29429 diff -NurpP --minimal linux-2.6.33/net/socket.c linux-2.6.33-vs2.3.0.36.30.1/net/socket.c
29430 --- linux-2.6.33/net/socket.c 2010-02-25 11:52:12.000000000 +0100
29431 +++ linux-2.6.33-vs2.3.0.36.30.1/net/socket.c 2010-02-25 13:51:25.000000000 +0100
29434 #include <net/sock.h>
29435 #include <linux/netfilter.h>
29436 +#include <linux/vs_base.h>
29437 +#include <linux/vs_socket.h>
29438 +#include <linux/vs_inet.h>
29439 +#include <linux/vs_inet6.h>
29441 #include <linux/if_tun.h>
29442 #include <linux/ipv6_route.h>
29443 @@ -539,7 +543,7 @@ static inline int __sock_sendmsg(struct
29444 struct msghdr *msg, size_t size)
29446 struct sock_iocb *si = kiocb_to_siocb(iocb);
29452 @@ -550,7 +554,22 @@ static inline int __sock_sendmsg(struct
29456 - return sock->ops->sendmsg(iocb, sock, msg, size);
29457 + len = sock->ops->sendmsg(iocb, sock, msg, size);
29460 + vx_sock_send(sock->sk, size);
29462 + vx_sock_fail(sock->sk, size);
29464 + vxdprintk(VXD_CBIT(net, 7),
29465 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29467 + (sock->sk)?sock->sk->sk_nx_info:0,
29468 + (sock->sk)?sock->sk->sk_vx_info:0,
29469 + (sock->sk)?sock->sk->sk_xid:0,
29470 + (sock->sk)?sock->sk->sk_nid:0,
29471 + (unsigned int)size, len);
29475 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29476 @@ -667,6 +686,7 @@ static inline int __sock_recvmsg_nosec(s
29477 struct msghdr *msg, size_t size, int flags)
29479 struct sock_iocb *si = kiocb_to_siocb(iocb);
29484 @@ -674,7 +694,18 @@ static inline int __sock_recvmsg_nosec(s
29488 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29489 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29490 + if ((len >= 0) && sock->sk)
29491 + vx_sock_recv(sock->sk, len);
29492 + vxdprintk(VXD_CBIT(net, 7),
29493 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29495 + (sock->sk)?sock->sk->sk_nx_info:0,
29496 + (sock->sk)?sock->sk->sk_vx_info:0,
29497 + (sock->sk)?sock->sk->sk_xid:0,
29498 + (sock->sk)?sock->sk->sk_nid:0,
29499 + (unsigned int)size, len);
29503 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29504 @@ -1182,6 +1213,13 @@ static int __sock_create(struct net *net
29505 if (type < 0 || type >= SOCK_MAX)
29508 + if (!nx_check(0, VS_ADMIN)) {
29509 + if (family == PF_INET && !current_nx_info_has_v4())
29510 + return -EAFNOSUPPORT;
29511 + if (family == PF_INET6 && !current_nx_info_has_v6())
29512 + return -EAFNOSUPPORT;
29517 This uglymoron is moved from INET layer to here to avoid
29518 @@ -1314,6 +1352,7 @@ SYSCALL_DEFINE3(socket, int, family, int
29522 + set_bit(SOCK_USER_SOCKET, &sock->flags);
29523 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
29526 @@ -1355,10 +1394,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
29527 err = sock_create(family, type, protocol, &sock1);
29530 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
29532 err = sock_create(family, type, protocol, &sock2);
29534 goto out_release_1;
29535 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
29537 err = sock1->ops->socketpair(sock1, sock2);
29539 diff -NurpP --minimal linux-2.6.33/net/sunrpc/auth.c linux-2.6.33-vs2.3.0.36.30.1/net/sunrpc/auth.c
29540 --- linux-2.6.33/net/sunrpc/auth.c 2010-02-25 11:52:12.000000000 +0100
29541 +++ linux-2.6.33-vs2.3.0.36.30.1/net/sunrpc/auth.c 2010-02-25 12:02:16.000000000 +0100
29543 #include <linux/hash.h>
29544 #include <linux/sunrpc/clnt.h>
29545 #include <linux/spinlock.h>
29546 +#include <linux/vs_tag.h>
29549 # define RPCDBG_FACILITY RPCDBG_AUTH
29550 @@ -363,6 +364,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
29551 memset(&acred, 0, sizeof(acred));
29552 acred.uid = cred->fsuid;
29553 acred.gid = cred->fsgid;
29554 + acred.tag = dx_current_tag();
29555 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
29557 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
29558 @@ -403,6 +405,7 @@ rpcauth_bind_root_cred(struct rpc_task *
29559 struct auth_cred acred = {
29562 + .tag = dx_current_tag(),
29564 struct rpc_cred *ret;
29566 diff -NurpP --minimal linux-2.6.33/net/sunrpc/auth_unix.c linux-2.6.33-vs2.3.0.36.30.1/net/sunrpc/auth_unix.c
29567 --- linux-2.6.33/net/sunrpc/auth_unix.c 2008-12-25 00:26:37.000000000 +0100
29568 +++ linux-2.6.33-vs2.3.0.36.30.1/net/sunrpc/auth_unix.c 2010-02-25 12:02:16.000000000 +0100
29569 @@ -11,12 +11,14 @@
29570 #include <linux/module.h>
29571 #include <linux/sunrpc/clnt.h>
29572 #include <linux/sunrpc/auth.h>
29573 +#include <linux/vs_tag.h>
29575 #define NFS_NGROUPS 16
29578 struct rpc_cred uc_base;
29581 gid_t uc_gids[NFS_NGROUPS];
29583 #define uc_uid uc_base.cr_uid
29584 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
29585 groups = NFS_NGROUPS;
29587 cred->uc_gid = acred->gid;
29588 + cred->uc_tag = acred->tag;
29589 for (i = 0; i < groups; i++)
29590 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
29591 if (i < NFS_NGROUPS)
29592 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
29596 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
29597 + if (cred->uc_uid != acred->uid ||
29598 + cred->uc_gid != acred->gid ||
29599 + cred->uc_tag != acred->tag)
29602 if (acred->group_info != NULL)
29603 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
29604 struct rpc_clnt *clnt = task->tk_client;
29605 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
29606 __be32 *base, *hold;
29610 *p++ = htonl(RPC_AUTH_UNIX);
29612 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
29613 * Copy the UTS nodename captured when the client was created.
29615 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
29616 + tag = task->tk_client->cl_tag;
29618 - *p++ = htonl((u32) cred->uc_uid);
29619 - *p++ = htonl((u32) cred->uc_gid);
29620 + *p++ = htonl((u32) TAGINO_UID(tag,
29621 + cred->uc_uid, cred->uc_tag));
29622 + *p++ = htonl((u32) TAGINO_GID(tag,
29623 + cred->uc_gid, cred->uc_tag));
29625 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
29626 *p++ = htonl((u32) cred->uc_gids[i]);
29627 diff -NurpP --minimal linux-2.6.33/net/sunrpc/clnt.c linux-2.6.33-vs2.3.0.36.30.1/net/sunrpc/clnt.c
29628 --- linux-2.6.33/net/sunrpc/clnt.c 2010-02-25 11:52:12.000000000 +0100
29629 +++ linux-2.6.33-vs2.3.0.36.30.1/net/sunrpc/clnt.c 2010-02-25 12:02:16.000000000 +0100
29631 #include <linux/utsname.h>
29632 #include <linux/workqueue.h>
29633 #include <linux/in6.h>
29634 +#include <linux/vs_cvirt.h>
29636 #include <linux/sunrpc/clnt.h>
29637 #include <linux/sunrpc/rpc_pipe_fs.h>
29638 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
29639 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
29640 clnt->cl_chatty = 1;
29642 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
29643 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
29644 + clnt->cl_tag = 1; */
29647 EXPORT_SYMBOL_GPL(rpc_create);
29648 diff -NurpP --minimal linux-2.6.33/net/unix/af_unix.c linux-2.6.33-vs2.3.0.36.30.1/net/unix/af_unix.c
29649 --- linux-2.6.33/net/unix/af_unix.c 2010-02-25 11:52:12.000000000 +0100
29650 +++ linux-2.6.33-vs2.3.0.36.30.1/net/unix/af_unix.c 2010-02-25 12:02:16.000000000 +0100
29651 @@ -114,6 +114,8 @@
29652 #include <linux/mount.h>
29653 #include <net/checksum.h>
29654 #include <linux/security.h>
29655 +#include <linux/vs_context.h>
29656 +#include <linux/vs_limit.h>
29658 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
29659 static DEFINE_SPINLOCK(unix_table_lock);
29660 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
29661 if (!net_eq(sock_net(s), net))
29664 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29666 if (u->addr->len == len &&
29667 !memcmp(u->addr->name, sunname, len))
29669 @@ -2115,6 +2119,8 @@ static struct sock *unix_seq_idx(struct
29670 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
29671 if (sock_net(s) != seq_file_net(seq))
29673 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29678 @@ -2139,7 +2145,8 @@ static void *unix_seq_next(struct seq_fi
29679 sk = first_unix_socket(&iter->i);
29681 sk = next_unix_socket(&iter->i, sk);
29682 - while (sk && (sock_net(sk) != seq_file_net(seq)))
29683 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
29684 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
29685 sk = next_unix_socket(&iter->i, sk);
29688 diff -NurpP --minimal linux-2.6.33/net/x25/af_x25.c linux-2.6.33-vs2.3.0.36.30.1/net/x25/af_x25.c
29689 --- linux-2.6.33/net/x25/af_x25.c 2010-02-25 11:52:12.000000000 +0100
29690 +++ linux-2.6.33-vs2.3.0.36.30.1/net/x25/af_x25.c 2010-02-25 12:02:16.000000000 +0100
29691 @@ -526,7 +526,10 @@ static int x25_create(struct net *net, s
29695 - sock_init_data(sock, sk);
29696 + sk->sk_socket = sock;
29697 + sk->sk_type = sock->type;
29698 + sk->sk_sleep = &sock->wait;
29701 x25_init_timers(sk);
29703 diff -NurpP --minimal linux-2.6.33/scripts/checksyscalls.sh linux-2.6.33-vs2.3.0.36.30.1/scripts/checksyscalls.sh
29704 --- linux-2.6.33/scripts/checksyscalls.sh 2009-09-10 15:26:31.000000000 +0200
29705 +++ linux-2.6.33-vs2.3.0.36.30.1/scripts/checksyscalls.sh 2010-02-25 12:02:16.000000000 +0100
29706 @@ -194,7 +194,6 @@ cat << EOF
29707 #define __IGNORE_afs_syscall
29708 #define __IGNORE_getpmsg
29709 #define __IGNORE_putpmsg
29710 -#define __IGNORE_vserver
29714 diff -NurpP --minimal linux-2.6.33/security/commoncap.c linux-2.6.33-vs2.3.0.36.30.1/security/commoncap.c
29715 --- linux-2.6.33/security/commoncap.c 2010-02-25 11:52:12.000000000 +0100
29716 +++ linux-2.6.33-vs2.3.0.36.30.1/security/commoncap.c 2010-02-25 12:02:16.000000000 +0100
29718 #include <linux/sched.h>
29719 #include <linux/prctl.h>
29720 #include <linux/securebits.h>
29721 +#include <linux/vs_context.h>
29724 * If a non-root user executes a setuid-root binary in
29725 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
29727 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
29729 - NETLINK_CB(skb).eff_cap = current_cap();
29730 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
29734 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
29739 EXPORT_SYMBOL(cap_netlink_recv);
29742 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
29743 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
29746 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
29747 + struct vx_info *vxi = tsk->vx_info;
29750 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
29751 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
29752 + cap_raised(tsk->cap_effective, cap),
29753 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
29756 + /* special case SETUP */
29757 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
29758 + /* FIXME: maybe use cred instead? */
29759 + cap_raised(tsk->cred->cap_effective, cap))
29762 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
29766 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry
29768 if (!strncmp(name, XATTR_SECURITY_PREFIX,
29769 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
29770 - !capable(CAP_SYS_ADMIN))
29771 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
29775 @@ -894,7 +911,8 @@ error:
29777 int cap_syslog(int type)
29779 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
29780 + if ((type != 3 && type != 10) &&
29781 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
29785 @@ -946,3 +964,4 @@ int cap_file_mmap(struct file *file, uns
29790 diff -NurpP --minimal linux-2.6.33/security/selinux/av_permissions.h linux-2.6.33-vs2.3.0.36.30.1/security/selinux/av_permissions.h
29791 --- linux-2.6.33/security/selinux/av_permissions.h 1970-01-01 01:00:00.000000000 +0100
29792 +++ linux-2.6.33-vs2.3.0.36.30.1/security/selinux/av_permissions.h 2010-02-27 15:49:05.000000000 +0100
29794 +/* This file is automatically generated. Do not edit. */
29795 +#ifndef _SELINUX_AV_PERMISSIONS_H_
29796 +#define _SELINUX_AV_PERMISSIONS_H_
29798 +#define SECURITY__COMPUTE_AV 0x00000001UL
29799 +#define SECURITY__COMPUTE_CREATE 0x00000002UL
29800 +#define SECURITY__COMPUTE_MEMBER 0x00000004UL
29801 +#define SECURITY__CHECK_CONTEXT 0x00000008UL
29802 +#define SECURITY__LOAD_POLICY 0x00000010UL
29803 +#define SECURITY__COMPUTE_RELABEL 0x00000020UL
29804 +#define SECURITY__COMPUTE_USER 0x00000040UL
29805 +#define SECURITY__SETENFORCE 0x00000080UL
29806 +#define SECURITY__SETBOOL 0x00000100UL
29807 +#define SECURITY__SETSECPARAM 0x00000200UL
29808 +#define SECURITY__SETCHECKREQPROT 0x00000400UL
29809 +#define PROCESS__FORK 0x00000001UL
29810 +#define PROCESS__TRANSITION 0x00000002UL
29811 +#define PROCESS__SIGCHLD 0x00000004UL
29812 +#define PROCESS__SIGKILL 0x00000008UL
29813 +#define PROCESS__SIGSTOP 0x00000010UL
29814 +#define PROCESS__SIGNULL 0x00000020UL
29815 +#define PROCESS__SIGNAL 0x00000040UL
29816 +#define PROCESS__PTRACE 0x00000080UL
29817 +#define PROCESS__GETSCHED 0x00000100UL
29818 +#define PROCESS__SETSCHED 0x00000200UL
29819 +#define PROCESS__GETSESSION 0x00000400UL
29820 +#define PROCESS__GETPGID 0x00000800UL
29821 +#define PROCESS__SETPGID 0x00001000UL
29822 +#define PROCESS__GETCAP 0x00002000UL
29823 +#define PROCESS__SETCAP 0x00004000UL
29824 +#define PROCESS__SHARE 0x00008000UL
29825 +#define PROCESS__GETATTR 0x00010000UL
29826 +#define PROCESS__SETEXEC 0x00020000UL
29827 +#define PROCESS__SETFSCREATE 0x00040000UL
29828 +#define PROCESS__NOATSECURE 0x00080000UL
29829 +#define PROCESS__SIGINH 0x00100000UL
29830 +#define PROCESS__SETRLIMIT 0x00200000UL
29831 +#define PROCESS__RLIMITINH 0x00400000UL
29832 +#define PROCESS__DYNTRANSITION 0x00800000UL
29833 +#define PROCESS__SETCURRENT 0x01000000UL
29834 +#define PROCESS__EXECMEM 0x02000000UL
29835 +#define PROCESS__EXECSTACK 0x04000000UL
29836 +#define PROCESS__EXECHEAP 0x08000000UL
29837 +#define PROCESS__SETKEYCREATE 0x10000000UL
29838 +#define PROCESS__SETSOCKCREATE 0x20000000UL
29839 +#define SYSTEM__IPC_INFO 0x00000001UL
29840 +#define SYSTEM__SYSLOG_READ 0x00000002UL
29841 +#define SYSTEM__SYSLOG_MOD 0x00000004UL
29842 +#define SYSTEM__SYSLOG_CONSOLE 0x00000008UL
29843 +#define SYSTEM__MODULE_REQUEST 0x00000010UL
29844 +#define CAPABILITY__CHOWN 0x00000001UL
29845 +#define CAPABILITY__DAC_OVERRIDE 0x00000002UL
29846 +#define CAPABILITY__DAC_READ_SEARCH 0x00000004UL
29847 +#define CAPABILITY__FOWNER 0x00000008UL
29848 +#define CAPABILITY__FSETID 0x00000010UL
29849 +#define CAPABILITY__KILL 0x00000020UL
29850 +#define CAPABILITY__SETGID 0x00000040UL
29851 +#define CAPABILITY__SETUID 0x00000080UL
29852 +#define CAPABILITY__SETPCAP 0x00000100UL
29853 +#define CAPABILITY__LINUX_IMMUTABLE 0x00000200UL
29854 +#define CAPABILITY__NET_BIND_SERVICE 0x00000400UL
29855 +#define CAPABILITY__NET_BROADCAST 0x00000800UL
29856 +#define CAPABILITY__NET_ADMIN 0x00001000UL
29857 +#define CAPABILITY__NET_RAW 0x00002000UL
29858 +#define CAPABILITY__IPC_LOCK 0x00004000UL
29859 +#define CAPABILITY__IPC_OWNER 0x00008000UL
29860 +#define CAPABILITY__SYS_MODULE 0x00010000UL
29861 +#define CAPABILITY__SYS_RAWIO 0x00020000UL
29862 +#define CAPABILITY__SYS_CHROOT 0x00040000UL
29863 +#define CAPABILITY__SYS_PTRACE 0x00080000UL
29864 +#define CAPABILITY__SYS_PACCT 0x00100000UL
29865 +#define CAPABILITY__SYS_ADMIN 0x00200000UL
29866 +#define CAPABILITY__SYS_BOOT 0x00400000UL
29867 +#define CAPABILITY__SYS_NICE 0x00800000UL
29868 +#define CAPABILITY__SYS_RESOURCE 0x01000000UL
29869 +#define CAPABILITY__SYS_TIME 0x02000000UL
29870 +#define CAPABILITY__SYS_TTY_CONFIG 0x04000000UL
29871 +#define CAPABILITY__MKNOD 0x08000000UL
29872 +#define CAPABILITY__LEASE 0x10000000UL
29873 +#define CAPABILITY__AUDIT_WRITE 0x20000000UL
29874 +#define CAPABILITY__AUDIT_CONTROL 0x40000000UL
29875 +#define CAPABILITY__SETFCAP 0x80000000UL
29876 +#define FILESYSTEM__MOUNT 0x00000001UL
29877 +#define FILESYSTEM__REMOUNT 0x00000002UL
29878 +#define FILESYSTEM__UNMOUNT 0x00000004UL
29879 +#define FILESYSTEM__GETATTR 0x00000008UL
29880 +#define FILESYSTEM__RELABELFROM 0x00000010UL
29881 +#define FILESYSTEM__RELABELTO 0x00000020UL
29882 +#define FILESYSTEM__TRANSITION 0x00000040UL
29883 +#define FILESYSTEM__ASSOCIATE 0x00000080UL
29884 +#define FILESYSTEM__QUOTAMOD 0x00000100UL
29885 +#define FILESYSTEM__QUOTAGET 0x00000200UL
29886 +#define FILE__IOCTL 0x00000001UL
29887 +#define FILE__READ 0x00000002UL
29888 +#define FILE__WRITE 0x00000004UL
29889 +#define FILE__CREATE 0x00000008UL
29890 +#define FILE__GETATTR 0x00000010UL
29891 +#define FILE__SETATTR 0x00000020UL
29892 +#define FILE__LOCK 0x00000040UL
29893 +#define FILE__RELABELFROM 0x00000080UL
29894 +#define FILE__RELABELTO 0x00000100UL
29895 +#define FILE__APPEND 0x00000200UL
29896 +#define FILE__UNLINK 0x00000400UL
29897 +#define FILE__LINK 0x00000800UL
29898 +#define FILE__RENAME 0x00001000UL
29899 +#define FILE__EXECUTE 0x00002000UL
29900 +#define FILE__SWAPON 0x00004000UL
29901 +#define FILE__QUOTAON 0x00008000UL
29902 +#define FILE__MOUNTON 0x00010000UL
29903 +#define FILE__EXECUTE_NO_TRANS 0x00020000UL
29904 +#define FILE__ENTRYPOINT 0x00040000UL
29905 +#define FILE__EXECMOD 0x00080000UL
29906 +#define FILE__OPEN 0x00100000UL
29907 +#define DIR__IOCTL 0x00000001UL
29908 +#define DIR__READ 0x00000002UL
29909 +#define DIR__WRITE 0x00000004UL
29910 +#define DIR__CREATE 0x00000008UL
29911 +#define DIR__GETATTR 0x00000010UL
29912 +#define DIR__SETATTR 0x00000020UL
29913 +#define DIR__LOCK 0x00000040UL
29914 +#define DIR__RELABELFROM 0x00000080UL
29915 +#define DIR__RELABELTO 0x00000100UL
29916 +#define DIR__APPEND 0x00000200UL
29917 +#define DIR__UNLINK 0x00000400UL
29918 +#define DIR__LINK 0x00000800UL
29919 +#define DIR__RENAME 0x00001000UL
29920 +#define DIR__EXECUTE 0x00002000UL
29921 +#define DIR__SWAPON 0x00004000UL
29922 +#define DIR__QUOTAON 0x00008000UL
29923 +#define DIR__MOUNTON 0x00010000UL
29924 +#define DIR__ADD_NAME 0x00020000UL
29925 +#define DIR__REMOVE_NAME 0x00040000UL
29926 +#define DIR__REPARENT 0x00080000UL
29927 +#define DIR__SEARCH 0x00100000UL
29928 +#define DIR__RMDIR 0x00200000UL
29929 +#define DIR__OPEN 0x00400000UL
29930 +#define FD__USE 0x00000001UL
29931 +#define LNK_FILE__IOCTL 0x00000001UL
29932 +#define LNK_FILE__READ 0x00000002UL
29933 +#define LNK_FILE__WRITE 0x00000004UL
29934 +#define LNK_FILE__CREATE 0x00000008UL
29935 +#define LNK_FILE__GETATTR 0x00000010UL
29936 +#define LNK_FILE__SETATTR 0x00000020UL
29937 +#define LNK_FILE__LOCK 0x00000040UL
29938 +#define LNK_FILE__RELABELFROM 0x00000080UL
29939 +#define LNK_FILE__RELABELTO 0x00000100UL
29940 +#define LNK_FILE__APPEND 0x00000200UL
29941 +#define LNK_FILE__UNLINK 0x00000400UL
29942 +#define LNK_FILE__LINK 0x00000800UL
29943 +#define LNK_FILE__RENAME 0x00001000UL
29944 +#define LNK_FILE__EXECUTE 0x00002000UL
29945 +#define LNK_FILE__SWAPON 0x00004000UL
29946 +#define LNK_FILE__QUOTAON 0x00008000UL
29947 +#define LNK_FILE__MOUNTON 0x00010000UL
29948 +#define CHR_FILE__IOCTL 0x00000001UL
29949 +#define CHR_FILE__READ 0x00000002UL
29950 +#define CHR_FILE__WRITE 0x00000004UL
29951 +#define CHR_FILE__CREATE 0x00000008UL
29952 +#define CHR_FILE__GETATTR 0x00000010UL
29953 +#define CHR_FILE__SETATTR 0x00000020UL
29954 +#define CHR_FILE__LOCK 0x00000040UL
29955 +#define CHR_FILE__RELABELFROM 0x00000080UL
29956 +#define CHR_FILE__RELABELTO 0x00000100UL
29957 +#define CHR_FILE__APPEND 0x00000200UL
29958 +#define CHR_FILE__UNLINK 0x00000400UL
29959 +#define CHR_FILE__LINK 0x00000800UL
29960 +#define CHR_FILE__RENAME 0x00001000UL
29961 +#define CHR_FILE__EXECUTE 0x00002000UL
29962 +#define CHR_FILE__SWAPON 0x00004000UL
29963 +#define CHR_FILE__QUOTAON 0x00008000UL
29964 +#define CHR_FILE__MOUNTON 0x00010000UL
29965 +#define CHR_FILE__EXECUTE_NO_TRANS 0x00020000UL
29966 +#define CHR_FILE__ENTRYPOINT 0x00040000UL
29967 +#define CHR_FILE__EXECMOD 0x00080000UL
29968 +#define CHR_FILE__OPEN 0x00100000UL
29969 +#define BLK_FILE__IOCTL 0x00000001UL
29970 +#define BLK_FILE__READ 0x00000002UL
29971 +#define BLK_FILE__WRITE 0x00000004UL
29972 +#define BLK_FILE__CREATE 0x00000008UL
29973 +#define BLK_FILE__GETATTR 0x00000010UL
29974 +#define BLK_FILE__SETATTR 0x00000020UL
29975 +#define BLK_FILE__LOCK 0x00000040UL
29976 +#define BLK_FILE__RELABELFROM 0x00000080UL
29977 +#define BLK_FILE__RELABELTO 0x00000100UL
29978 +#define BLK_FILE__APPEND 0x00000200UL
29979 +#define BLK_FILE__UNLINK 0x00000400UL
29980 +#define BLK_FILE__LINK 0x00000800UL
29981 +#define BLK_FILE__RENAME 0x00001000UL
29982 +#define BLK_FILE__EXECUTE 0x00002000UL
29983 +#define BLK_FILE__SWAPON 0x00004000UL
29984 +#define BLK_FILE__QUOTAON 0x00008000UL
29985 +#define BLK_FILE__MOUNTON 0x00010000UL
29986 +#define BLK_FILE__OPEN 0x00020000UL
29987 +#define SOCK_FILE__IOCTL 0x00000001UL
29988 +#define SOCK_FILE__READ 0x00000002UL
29989 +#define SOCK_FILE__WRITE 0x00000004UL
29990 +#define SOCK_FILE__CREATE 0x00000008UL
29991 +#define SOCK_FILE__GETATTR 0x00000010UL
29992 +#define SOCK_FILE__SETATTR 0x00000020UL
29993 +#define SOCK_FILE__LOCK 0x00000040UL
29994 +#define SOCK_FILE__RELABELFROM 0x00000080UL
29995 +#define SOCK_FILE__RELABELTO 0x00000100UL
29996 +#define SOCK_FILE__APPEND 0x00000200UL
29997 +#define SOCK_FILE__UNLINK 0x00000400UL
29998 +#define SOCK_FILE__LINK 0x00000800UL
29999 +#define SOCK_FILE__RENAME 0x00001000UL
30000 +#define SOCK_FILE__EXECUTE 0x00002000UL
30001 +#define SOCK_FILE__SWAPON 0x00004000UL
30002 +#define SOCK_FILE__QUOTAON 0x00008000UL
30003 +#define SOCK_FILE__MOUNTON 0x00010000UL
30004 +#define SOCK_FILE__OPEN 0x00020000UL
30005 +#define FIFO_FILE__IOCTL 0x00000001UL
30006 +#define FIFO_FILE__READ 0x00000002UL
30007 +#define FIFO_FILE__WRITE 0x00000004UL
30008 +#define FIFO_FILE__CREATE 0x00000008UL
30009 +#define FIFO_FILE__GETATTR 0x00000010UL
30010 +#define FIFO_FILE__SETATTR 0x00000020UL
30011 +#define FIFO_FILE__LOCK 0x00000040UL
30012 +#define FIFO_FILE__RELABELFROM 0x00000080UL
30013 +#define FIFO_FILE__RELABELTO 0x00000100UL
30014 +#define FIFO_FILE__APPEND 0x00000200UL
30015 +#define FIFO_FILE__UNLINK 0x00000400UL
30016 +#define FIFO_FILE__LINK 0x00000800UL
30017 +#define FIFO_FILE__RENAME 0x00001000UL
30018 +#define FIFO_FILE__EXECUTE 0x00002000UL
30019 +#define FIFO_FILE__SWAPON 0x00004000UL
30020 +#define FIFO_FILE__QUOTAON 0x00008000UL
30021 +#define FIFO_FILE__MOUNTON 0x00010000UL
30022 +#define FIFO_FILE__OPEN 0x00020000UL
30023 +#define SOCKET__IOCTL 0x00000001UL
30024 +#define SOCKET__READ 0x00000002UL
30025 +#define SOCKET__WRITE 0x00000004UL
30026 +#define SOCKET__CREATE 0x00000008UL
30027 +#define SOCKET__GETATTR 0x00000010UL
30028 +#define SOCKET__SETATTR 0x00000020UL
30029 +#define SOCKET__LOCK 0x00000040UL
30030 +#define SOCKET__RELABELFROM 0x00000080UL
30031 +#define SOCKET__RELABELTO 0x00000100UL
30032 +#define SOCKET__APPEND 0x00000200UL
30033 +#define SOCKET__BIND 0x00000400UL
30034 +#define SOCKET__CONNECT 0x00000800UL
30035 +#define SOCKET__LISTEN 0x00001000UL
30036 +#define SOCKET__ACCEPT 0x00002000UL
30037 +#define SOCKET__GETOPT 0x00004000UL
30038 +#define SOCKET__SETOPT 0x00008000UL
30039 +#define SOCKET__SHUTDOWN 0x00010000UL
30040 +#define SOCKET__RECVFROM 0x00020000UL
30041 +#define SOCKET__SENDTO 0x00040000UL
30042 +#define SOCKET__RECV_MSG 0x00080000UL
30043 +#define SOCKET__SEND_MSG 0x00100000UL
30044 +#define SOCKET__NAME_BIND 0x00200000UL
30045 +#define TCP_SOCKET__IOCTL 0x00000001UL
30046 +#define TCP_SOCKET__READ 0x00000002UL
30047 +#define TCP_SOCKET__WRITE 0x00000004UL
30048 +#define TCP_SOCKET__CREATE 0x00000008UL
30049 +#define TCP_SOCKET__GETATTR 0x00000010UL
30050 +#define TCP_SOCKET__SETATTR 0x00000020UL
30051 +#define TCP_SOCKET__LOCK 0x00000040UL
30052 +#define TCP_SOCKET__RELABELFROM 0x00000080UL
30053 +#define TCP_SOCKET__RELABELTO 0x00000100UL
30054 +#define TCP_SOCKET__APPEND 0x00000200UL
30055 +#define TCP_SOCKET__BIND 0x00000400UL
30056 +#define TCP_SOCKET__CONNECT 0x00000800UL
30057 +#define TCP_SOCKET__LISTEN 0x00001000UL
30058 +#define TCP_SOCKET__ACCEPT 0x00002000UL
30059 +#define TCP_SOCKET__GETOPT 0x00004000UL
30060 +#define TCP_SOCKET__SETOPT 0x00008000UL
30061 +#define TCP_SOCKET__SHUTDOWN 0x00010000UL
30062 +#define TCP_SOCKET__RECVFROM 0x00020000UL
30063 +#define TCP_SOCKET__SENDTO 0x00040000UL
30064 +#define TCP_SOCKET__RECV_MSG 0x00080000UL
30065 +#define TCP_SOCKET__SEND_MSG 0x00100000UL
30066 +#define TCP_SOCKET__NAME_BIND 0x00200000UL
30067 +#define TCP_SOCKET__CONNECTTO 0x00400000UL
30068 +#define TCP_SOCKET__NEWCONN 0x00800000UL
30069 +#define TCP_SOCKET__ACCEPTFROM 0x01000000UL
30070 +#define TCP_SOCKET__NODE_BIND 0x02000000UL
30071 +#define TCP_SOCKET__NAME_CONNECT 0x04000000UL
30072 +#define UDP_SOCKET__IOCTL 0x00000001UL
30073 +#define UDP_SOCKET__READ 0x00000002UL
30074 +#define UDP_SOCKET__WRITE 0x00000004UL
30075 +#define UDP_SOCKET__CREATE 0x00000008UL
30076 +#define UDP_SOCKET__GETATTR 0x00000010UL
30077 +#define UDP_SOCKET__SETATTR 0x00000020UL
30078 +#define UDP_SOCKET__LOCK 0x00000040UL
30079 +#define UDP_SOCKET__RELABELFROM 0x00000080UL
30080 +#define UDP_SOCKET__RELABELTO 0x00000100UL
30081 +#define UDP_SOCKET__APPEND 0x00000200UL
30082 +#define UDP_SOCKET__BIND 0x00000400UL
30083 +#define UDP_SOCKET__CONNECT 0x00000800UL
30084 +#define UDP_SOCKET__LISTEN 0x00001000UL
30085 +#define UDP_SOCKET__ACCEPT 0x00002000UL
30086 +#define UDP_SOCKET__GETOPT 0x00004000UL
30087 +#define UDP_SOCKET__SETOPT 0x00008000UL
30088 +#define UDP_SOCKET__SHUTDOWN 0x00010000UL
30089 +#define UDP_SOCKET__RECVFROM 0x00020000UL
30090 +#define UDP_SOCKET__SENDTO 0x00040000UL
30091 +#define UDP_SOCKET__RECV_MSG 0x00080000UL
30092 +#define UDP_SOCKET__SEND_MSG 0x00100000UL
30093 +#define UDP_SOCKET__NAME_BIND 0x00200000UL
30094 +#define UDP_SOCKET__NODE_BIND 0x00400000UL
30095 +#define RAWIP_SOCKET__IOCTL 0x00000001UL
30096 +#define RAWIP_SOCKET__READ 0x00000002UL
30097 +#define RAWIP_SOCKET__WRITE 0x00000004UL
30098 +#define RAWIP_SOCKET__CREATE 0x00000008UL
30099 +#define RAWIP_SOCKET__GETATTR 0x00000010UL
30100 +#define RAWIP_SOCKET__SETATTR 0x00000020UL
30101 +#define RAWIP_SOCKET__LOCK 0x00000040UL
30102 +#define RAWIP_SOCKET__RELABELFROM 0x00000080UL
30103 +#define RAWIP_SOCKET__RELABELTO 0x00000100UL
30104 +#define RAWIP_SOCKET__APPEND 0x00000200UL
30105 +#define RAWIP_SOCKET__BIND 0x00000400UL
30106 +#define RAWIP_SOCKET__CONNECT 0x00000800UL
30107 +#define RAWIP_SOCKET__LISTEN 0x00001000UL
30108 +#define RAWIP_SOCKET__ACCEPT 0x00002000UL
30109 +#define RAWIP_SOCKET__GETOPT 0x00004000UL
30110 +#define RAWIP_SOCKET__SETOPT 0x00008000UL
30111 +#define RAWIP_SOCKET__SHUTDOWN 0x00010000UL
30112 +#define RAWIP_SOCKET__RECVFROM 0x00020000UL
30113 +#define RAWIP_SOCKET__SENDTO 0x00040000UL
30114 +#define RAWIP_SOCKET__RECV_MSG 0x00080000UL
30115 +#define RAWIP_SOCKET__SEND_MSG 0x00100000UL
30116 +#define RAWIP_SOCKET__NAME_BIND 0x00200000UL
30117 +#define RAWIP_SOCKET__NODE_BIND 0x00400000UL
30118 +#define NODE__TCP_RECV 0x00000001UL
30119 +#define NODE__TCP_SEND 0x00000002UL
30120 +#define NODE__UDP_RECV 0x00000004UL
30121 +#define NODE__UDP_SEND 0x00000008UL
30122 +#define NODE__RAWIP_RECV 0x00000010UL
30123 +#define NODE__RAWIP_SEND 0x00000020UL
30124 +#define NODE__ENFORCE_DEST 0x00000040UL
30125 +#define NODE__DCCP_RECV 0x00000080UL
30126 +#define NODE__DCCP_SEND 0x00000100UL
30127 +#define NODE__RECVFROM 0x00000200UL
30128 +#define NODE__SENDTO 0x00000400UL
30129 +#define NETIF__TCP_RECV 0x00000001UL
30130 +#define NETIF__TCP_SEND 0x00000002UL
30131 +#define NETIF__UDP_RECV 0x00000004UL
30132 +#define NETIF__UDP_SEND 0x00000008UL
30133 +#define NETIF__RAWIP_RECV 0x00000010UL
30134 +#define NETIF__RAWIP_SEND 0x00000020UL
30135 +#define NETIF__DCCP_RECV 0x00000040UL
30136 +#define NETIF__DCCP_SEND 0x00000080UL
30137 +#define NETIF__INGRESS 0x00000100UL
30138 +#define NETIF__EGRESS 0x00000200UL
30139 +#define NETLINK_SOCKET__IOCTL 0x00000001UL
30140 +#define NETLINK_SOCKET__READ 0x00000002UL
30141 +#define NETLINK_SOCKET__WRITE 0x00000004UL
30142 +#define NETLINK_SOCKET__CREATE 0x00000008UL
30143 +#define NETLINK_SOCKET__GETATTR 0x00000010UL
30144 +#define NETLINK_SOCKET__SETATTR 0x00000020UL
30145 +#define NETLINK_SOCKET__LOCK 0x00000040UL
30146 +#define NETLINK_SOCKET__RELABELFROM 0x00000080UL
30147 +#define NETLINK_SOCKET__RELABELTO 0x00000100UL
30148 +#define NETLINK_SOCKET__APPEND 0x00000200UL
30149 +#define NETLINK_SOCKET__BIND 0x00000400UL
30150 +#define NETLINK_SOCKET__CONNECT 0x00000800UL
30151 +#define NETLINK_SOCKET__LISTEN 0x00001000UL
30152 +#define NETLINK_SOCKET__ACCEPT 0x00002000UL
30153 +#define NETLINK_SOCKET__GETOPT 0x00004000UL
30154 +#define NETLINK_SOCKET__SETOPT 0x00008000UL
30155 +#define NETLINK_SOCKET__SHUTDOWN 0x00010000UL
30156 +#define NETLINK_SOCKET__RECVFROM 0x00020000UL
30157 +#define NETLINK_SOCKET__SENDTO 0x00040000UL
30158 +#define NETLINK_SOCKET__RECV_MSG 0x00080000UL
30159 +#define NETLINK_SOCKET__SEND_MSG 0x00100000UL
30160 +#define NETLINK_SOCKET__NAME_BIND 0x00200000UL
30161 +#define PACKET_SOCKET__IOCTL 0x00000001UL
30162 +#define PACKET_SOCKET__READ 0x00000002UL
30163 +#define PACKET_SOCKET__WRITE 0x00000004UL
30164 +#define PACKET_SOCKET__CREATE 0x00000008UL
30165 +#define PACKET_SOCKET__GETATTR 0x00000010UL
30166 +#define PACKET_SOCKET__SETATTR 0x00000020UL
30167 +#define PACKET_SOCKET__LOCK 0x00000040UL
30168 +#define PACKET_SOCKET__RELABELFROM 0x00000080UL
30169 +#define PACKET_SOCKET__RELABELTO 0x00000100UL
30170 +#define PACKET_SOCKET__APPEND 0x00000200UL
30171 +#define PACKET_SOCKET__BIND 0x00000400UL
30172 +#define PACKET_SOCKET__CONNECT 0x00000800UL
30173 +#define PACKET_SOCKET__LISTEN 0x00001000UL
30174 +#define PACKET_SOCKET__ACCEPT 0x00002000UL
30175 +#define PACKET_SOCKET__GETOPT 0x00004000UL
30176 +#define PACKET_SOCKET__SETOPT 0x00008000UL
30177 +#define PACKET_SOCKET__SHUTDOWN 0x00010000UL
30178 +#define PACKET_SOCKET__RECVFROM 0x00020000UL
30179 +#define PACKET_SOCKET__SENDTO 0x00040000UL
30180 +#define PACKET_SOCKET__RECV_MSG 0x00080000UL
30181 +#define PACKET_SOCKET__SEND_MSG 0x00100000UL
30182 +#define PACKET_SOCKET__NAME_BIND 0x00200000UL
30183 +#define KEY_SOCKET__IOCTL 0x00000001UL
30184 +#define KEY_SOCKET__READ 0x00000002UL
30185 +#define KEY_SOCKET__WRITE 0x00000004UL
30186 +#define KEY_SOCKET__CREATE 0x00000008UL
30187 +#define KEY_SOCKET__GETATTR 0x00000010UL
30188 +#define KEY_SOCKET__SETATTR 0x00000020UL
30189 +#define KEY_SOCKET__LOCK 0x00000040UL
30190 +#define KEY_SOCKET__RELABELFROM 0x00000080UL
30191 +#define KEY_SOCKET__RELABELTO 0x00000100UL
30192 +#define KEY_SOCKET__APPEND 0x00000200UL
30193 +#define KEY_SOCKET__BIND 0x00000400UL
30194 +#define KEY_SOCKET__CONNECT 0x00000800UL
30195 +#define KEY_SOCKET__LISTEN 0x00001000UL
30196 +#define KEY_SOCKET__ACCEPT 0x00002000UL
30197 +#define KEY_SOCKET__GETOPT 0x00004000UL
30198 +#define KEY_SOCKET__SETOPT 0x00008000UL
30199 +#define KEY_SOCKET__SHUTDOWN 0x00010000UL
30200 +#define KEY_SOCKET__RECVFROM 0x00020000UL
30201 +#define KEY_SOCKET__SENDTO 0x00040000UL
30202 +#define KEY_SOCKET__RECV_MSG 0x00080000UL
30203 +#define KEY_SOCKET__SEND_MSG 0x00100000UL
30204 +#define KEY_SOCKET__NAME_BIND 0x00200000UL
30205 +#define UNIX_STREAM_SOCKET__IOCTL 0x00000001UL
30206 +#define UNIX_STREAM_SOCKET__READ 0x00000002UL
30207 +#define UNIX_STREAM_SOCKET__WRITE 0x00000004UL
30208 +#define UNIX_STREAM_SOCKET__CREATE 0x00000008UL
30209 +#define UNIX_STREAM_SOCKET__GETATTR 0x00000010UL
30210 +#define UNIX_STREAM_SOCKET__SETATTR 0x00000020UL
30211 +#define UNIX_STREAM_SOCKET__LOCK 0x00000040UL
30212 +#define UNIX_STREAM_SOCKET__RELABELFROM 0x00000080UL
30213 +#define UNIX_STREAM_SOCKET__RELABELTO 0x00000100UL
30214 +#define UNIX_STREAM_SOCKET__APPEND 0x00000200UL
30215 +#define UNIX_STREAM_SOCKET__BIND 0x00000400UL
30216 +#define UNIX_STREAM_SOCKET__CONNECT 0x00000800UL
30217 +#define UNIX_STREAM_SOCKET__LISTEN 0x00001000UL
30218 +#define UNIX_STREAM_SOCKET__ACCEPT 0x00002000UL
30219 +#define UNIX_STREAM_SOCKET__GETOPT 0x00004000UL
30220 +#define UNIX_STREAM_SOCKET__SETOPT 0x00008000UL
30221 +#define UNIX_STREAM_SOCKET__SHUTDOWN 0x00010000UL
30222 +#define UNIX_STREAM_SOCKET__RECVFROM 0x00020000UL
30223 +#define UNIX_STREAM_SOCKET__SENDTO 0x00040000UL
30224 +#define UNIX_STREAM_SOCKET__RECV_MSG 0x00080000UL
30225 +#define UNIX_STREAM_SOCKET__SEND_MSG 0x00100000UL
30226 +#define UNIX_STREAM_SOCKET__NAME_BIND 0x00200000UL
30227 +#define UNIX_STREAM_SOCKET__CONNECTTO 0x00400000UL
30228 +#define UNIX_STREAM_SOCKET__NEWCONN 0x00800000UL
30229 +#define UNIX_STREAM_SOCKET__ACCEPTFROM 0x01000000UL
30230 +#define UNIX_DGRAM_SOCKET__IOCTL 0x00000001UL
30231 +#define UNIX_DGRAM_SOCKET__READ 0x00000002UL
30232 +#define UNIX_DGRAM_SOCKET__WRITE 0x00000004UL
30233 +#define UNIX_DGRAM_SOCKET__CREATE 0x00000008UL
30234 +#define UNIX_DGRAM_SOCKET__GETATTR 0x00000010UL
30235 +#define UNIX_DGRAM_SOCKET__SETATTR 0x00000020UL
30236 +#define UNIX_DGRAM_SOCKET__LOCK 0x00000040UL
30237 +#define UNIX_DGRAM_SOCKET__RELABELFROM 0x00000080UL
30238 +#define UNIX_DGRAM_SOCKET__RELABELTO 0x00000100UL
30239 +#define UNIX_DGRAM_SOCKET__APPEND 0x00000200UL
30240 +#define UNIX_DGRAM_SOCKET__BIND 0x00000400UL
30241 +#define UNIX_DGRAM_SOCKET__CONNECT 0x00000800UL
30242 +#define UNIX_DGRAM_SOCKET__LISTEN 0x00001000UL
30243 +#define UNIX_DGRAM_SOCKET__ACCEPT 0x00002000UL
30244 +#define UNIX_DGRAM_SOCKET__GETOPT 0x00004000UL
30245 +#define UNIX_DGRAM_SOCKET__SETOPT 0x00008000UL
30246 +#define UNIX_DGRAM_SOCKET__SHUTDOWN 0x00010000UL
30247 +#define UNIX_DGRAM_SOCKET__RECVFROM 0x00020000UL
30248 +#define UNIX_DGRAM_SOCKET__SENDTO 0x00040000UL
30249 +#define UNIX_DGRAM_SOCKET__RECV_MSG 0x00080000UL
30250 +#define UNIX_DGRAM_SOCKET__SEND_MSG 0x00100000UL
30251 +#define UNIX_DGRAM_SOCKET__NAME_BIND 0x00200000UL
30252 +#define SEM__CREATE 0x00000001UL
30253 +#define SEM__DESTROY 0x00000002UL
30254 +#define SEM__GETATTR 0x00000004UL
30255 +#define SEM__SETATTR 0x00000008UL
30256 +#define SEM__READ 0x00000010UL
30257 +#define SEM__WRITE 0x00000020UL
30258 +#define SEM__ASSOCIATE 0x00000040UL
30259 +#define SEM__UNIX_READ 0x00000080UL
30260 +#define SEM__UNIX_WRITE 0x00000100UL
30261 +#define MSG__SEND 0x00000001UL
30262 +#define MSG__RECEIVE 0x00000002UL
30263 +#define MSGQ__CREATE 0x00000001UL
30264 +#define MSGQ__DESTROY 0x00000002UL
30265 +#define MSGQ__GETATTR 0x00000004UL
30266 +#define MSGQ__SETATTR 0x00000008UL
30267 +#define MSGQ__READ 0x00000010UL
30268 +#define MSGQ__WRITE 0x00000020UL
30269 +#define MSGQ__ASSOCIATE 0x00000040UL
30270 +#define MSGQ__UNIX_READ 0x00000080UL
30271 +#define MSGQ__UNIX_WRITE 0x00000100UL
30272 +#define MSGQ__ENQUEUE 0x00000200UL
30273 +#define SHM__CREATE 0x00000001UL
30274 +#define SHM__DESTROY 0x00000002UL
30275 +#define SHM__GETATTR 0x00000004UL
30276 +#define SHM__SETATTR 0x00000008UL
30277 +#define SHM__READ 0x00000010UL
30278 +#define SHM__WRITE 0x00000020UL
30279 +#define SHM__ASSOCIATE 0x00000040UL
30280 +#define SHM__UNIX_READ 0x00000080UL
30281 +#define SHM__UNIX_WRITE 0x00000100UL
30282 +#define SHM__LOCK 0x00000200UL
30283 +#define IPC__CREATE 0x00000001UL
30284 +#define IPC__DESTROY 0x00000002UL
30285 +#define IPC__GETATTR 0x00000004UL
30286 +#define IPC__SETATTR 0x00000008UL
30287 +#define IPC__READ 0x00000010UL
30288 +#define IPC__WRITE 0x00000020UL
30289 +#define IPC__ASSOCIATE 0x00000040UL
30290 +#define IPC__UNIX_READ 0x00000080UL
30291 +#define IPC__UNIX_WRITE 0x00000100UL
30292 +#define NETLINK_ROUTE_SOCKET__IOCTL 0x00000001UL
30293 +#define NETLINK_ROUTE_SOCKET__READ 0x00000002UL
30294 +#define NETLINK_ROUTE_SOCKET__WRITE 0x00000004UL
30295 +#define NETLINK_ROUTE_SOCKET__CREATE 0x00000008UL
30296 +#define NETLINK_ROUTE_SOCKET__GETATTR 0x00000010UL
30297 +#define NETLINK_ROUTE_SOCKET__SETATTR 0x00000020UL
30298 +#define NETLINK_ROUTE_SOCKET__LOCK 0x00000040UL
30299 +#define NETLINK_ROUTE_SOCKET__RELABELFROM 0x00000080UL
30300 +#define NETLINK_ROUTE_SOCKET__RELABELTO 0x00000100UL
30301 +#define NETLINK_ROUTE_SOCKET__APPEND 0x00000200UL
30302 +#define NETLINK_ROUTE_SOCKET__BIND 0x00000400UL
30303 +#define NETLINK_ROUTE_SOCKET__CONNECT 0x00000800UL
30304 +#define NETLINK_ROUTE_SOCKET__LISTEN 0x00001000UL
30305 +#define NETLINK_ROUTE_SOCKET__ACCEPT 0x00002000UL
30306 +#define NETLINK_ROUTE_SOCKET__GETOPT 0x00004000UL
30307 +#define NETLINK_ROUTE_SOCKET__SETOPT 0x00008000UL
30308 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN 0x00010000UL
30309 +#define NETLINK_ROUTE_SOCKET__RECVFROM 0x00020000UL
30310 +#define NETLINK_ROUTE_SOCKET__SENDTO 0x00040000UL
30311 +#define NETLINK_ROUTE_SOCKET__RECV_MSG 0x00080000UL
30312 +#define NETLINK_ROUTE_SOCKET__SEND_MSG 0x00100000UL
30313 +#define NETLINK_ROUTE_SOCKET__NAME_BIND 0x00200000UL
30314 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ 0x00400000UL
30315 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE 0x00800000UL
30316 +#define NETLINK_FIREWALL_SOCKET__IOCTL 0x00000001UL
30317 +#define NETLINK_FIREWALL_SOCKET__READ 0x00000002UL
30318 +#define NETLINK_FIREWALL_SOCKET__WRITE 0x00000004UL
30319 +#define NETLINK_FIREWALL_SOCKET__CREATE 0x00000008UL
30320 +#define NETLINK_FIREWALL_SOCKET__GETATTR 0x00000010UL
30321 +#define NETLINK_FIREWALL_SOCKET__SETATTR 0x00000020UL
30322 +#define NETLINK_FIREWALL_SOCKET__LOCK 0x00000040UL
30323 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM 0x00000080UL
30324 +#define NETLINK_FIREWALL_SOCKET__RELABELTO 0x00000100UL
30325 +#define NETLINK_FIREWALL_SOCKET__APPEND 0x00000200UL
30326 +#define NETLINK_FIREWALL_SOCKET__BIND 0x00000400UL
30327 +#define NETLINK_FIREWALL_SOCKET__CONNECT 0x00000800UL
30328 +#define NETLINK_FIREWALL_SOCKET__LISTEN 0x00001000UL
30329 +#define NETLINK_FIREWALL_SOCKET__ACCEPT 0x00002000UL
30330 +#define NETLINK_FIREWALL_SOCKET__GETOPT 0x00004000UL
30331 +#define NETLINK_FIREWALL_SOCKET__SETOPT 0x00008000UL
30332 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN 0x00010000UL
30333 +#define NETLINK_FIREWALL_SOCKET__RECVFROM 0x00020000UL
30334 +#define NETLINK_FIREWALL_SOCKET__SENDTO 0x00040000UL
30335 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG 0x00080000UL
30336 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG 0x00100000UL
30337 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND 0x00200000UL
30338 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ 0x00400000UL
30339 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE 0x00800000UL
30340 +#define NETLINK_TCPDIAG_SOCKET__IOCTL 0x00000001UL
30341 +#define NETLINK_TCPDIAG_SOCKET__READ 0x00000002UL
30342 +#define NETLINK_TCPDIAG_SOCKET__WRITE 0x00000004UL
30343 +#define NETLINK_TCPDIAG_SOCKET__CREATE 0x00000008UL
30344 +#define NETLINK_TCPDIAG_SOCKET__GETATTR 0x00000010UL
30345 +#define NETLINK_TCPDIAG_SOCKET__SETATTR 0x00000020UL
30346 +#define NETLINK_TCPDIAG_SOCKET__LOCK 0x00000040UL
30347 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM 0x00000080UL
30348 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO 0x00000100UL
30349 +#define NETLINK_TCPDIAG_SOCKET__APPEND 0x00000200UL
30350 +#define NETLINK_TCPDIAG_SOCKET__BIND 0x00000400UL
30351 +#define NETLINK_TCPDIAG_SOCKET__CONNECT 0x00000800UL
30352 +#define NETLINK_TCPDIAG_SOCKET__LISTEN 0x00001000UL
30353 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT 0x00002000UL
30354 +#define NETLINK_TCPDIAG_SOCKET__GETOPT 0x00004000UL
30355 +#define NETLINK_TCPDIAG_SOCKET__SETOPT 0x00008000UL
30356 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN 0x00010000UL
30357 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM 0x00020000UL
30358 +#define NETLINK_TCPDIAG_SOCKET__SENDTO 0x00040000UL
30359 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG 0x00080000UL
30360 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG 0x00100000UL
30361 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND 0x00200000UL
30362 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ 0x00400000UL
30363 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE 0x00800000UL
30364 +#define NETLINK_NFLOG_SOCKET__IOCTL 0x00000001UL
30365 +#define NETLINK_NFLOG_SOCKET__READ 0x00000002UL
30366 +#define NETLINK_NFLOG_SOCKET__WRITE 0x00000004UL
30367 +#define NETLINK_NFLOG_SOCKET__CREATE 0x00000008UL
30368 +#define NETLINK_NFLOG_SOCKET__GETATTR 0x00000010UL
30369 +#define NETLINK_NFLOG_SOCKET__SETATTR 0x00000020UL
30370 +#define NETLINK_NFLOG_SOCKET__LOCK 0x00000040UL
30371 +#define NETLINK_NFLOG_SOCKET__RELABELFROM 0x00000080UL
30372 +#define NETLINK_NFLOG_SOCKET__RELABELTO 0x00000100UL
30373 +#define NETLINK_NFLOG_SOCKET__APPEND 0x00000200UL
30374 +#define NETLINK_NFLOG_SOCKET__BIND 0x00000400UL
30375 +#define NETLINK_NFLOG_SOCKET__CONNECT 0x00000800UL
30376 +#define NETLINK_NFLOG_SOCKET__LISTEN 0x00001000UL
30377 +#define NETLINK_NFLOG_SOCKET__ACCEPT 0x00002000UL
30378 +#define NETLINK_NFLOG_SOCKET__GETOPT 0x00004000UL
30379 +#define NETLINK_NFLOG_SOCKET__SETOPT 0x00008000UL
30380 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN 0x00010000UL
30381 +#define NETLINK_NFLOG_SOCKET__RECVFROM 0x00020000UL
30382 +#define NETLINK_NFLOG_SOCKET__SENDTO 0x00040000UL
30383 +#define NETLINK_NFLOG_SOCKET__RECV_MSG 0x00080000UL
30384 +#define NETLINK_NFLOG_SOCKET__SEND_MSG 0x00100000UL
30385 +#define NETLINK_NFLOG_SOCKET__NAME_BIND 0x00200000UL
30386 +#define NETLINK_XFRM_SOCKET__IOCTL 0x00000001UL
30387 +#define NETLINK_XFRM_SOCKET__READ 0x00000002UL
30388 +#define NETLINK_XFRM_SOCKET__WRITE 0x00000004UL
30389 +#define NETLINK_XFRM_SOCKET__CREATE 0x00000008UL
30390 +#define NETLINK_XFRM_SOCKET__GETATTR 0x00000010UL
30391 +#define NETLINK_XFRM_SOCKET__SETATTR 0x00000020UL
30392 +#define NETLINK_XFRM_SOCKET__LOCK 0x00000040UL
30393 +#define NETLINK_XFRM_SOCKET__RELABELFROM 0x00000080UL
30394 +#define NETLINK_XFRM_SOCKET__RELABELTO 0x00000100UL
30395 +#define NETLINK_XFRM_SOCKET__APPEND 0x00000200UL
30396 +#define NETLINK_XFRM_SOCKET__BIND 0x00000400UL
30397 +#define NETLINK_XFRM_SOCKET__CONNECT 0x00000800UL
30398 +#define NETLINK_XFRM_SOCKET__LISTEN 0x00001000UL
30399 +#define NETLINK_XFRM_SOCKET__ACCEPT 0x00002000UL
30400 +#define NETLINK_XFRM_SOCKET__GETOPT 0x00004000UL
30401 +#define NETLINK_XFRM_SOCKET__SETOPT 0x00008000UL
30402 +#define NETLINK_XFRM_SOCKET__SHUTDOWN 0x00010000UL
30403 +#define NETLINK_XFRM_SOCKET__RECVFROM 0x00020000UL
30404 +#define NETLINK_XFRM_SOCKET__SENDTO 0x00040000UL
30405 +#define NETLINK_XFRM_SOCKET__RECV_MSG 0x00080000UL
30406 +#define NETLINK_XFRM_SOCKET__SEND_MSG 0x00100000UL
30407 +#define NETLINK_XFRM_SOCKET__NAME_BIND 0x00200000UL
30408 +#define NETLINK_XFRM_SOCKET__NLMSG_READ 0x00400000UL
30409 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE 0x00800000UL
30410 +#define NETLINK_SELINUX_SOCKET__IOCTL 0x00000001UL
30411 +#define NETLINK_SELINUX_SOCKET__READ 0x00000002UL
30412 +#define NETLINK_SELINUX_SOCKET__WRITE 0x00000004UL
30413 +#define NETLINK_SELINUX_SOCKET__CREATE 0x00000008UL
30414 +#define NETLINK_SELINUX_SOCKET__GETATTR 0x00000010UL
30415 +#define NETLINK_SELINUX_SOCKET__SETATTR 0x00000020UL
30416 +#define NETLINK_SELINUX_SOCKET__LOCK 0x00000040UL
30417 +#define NETLINK_SELINUX_SOCKET__RELABELFROM 0x00000080UL
30418 +#define NETLINK_SELINUX_SOCKET__RELABELTO 0x00000100UL
30419 +#define NETLINK_SELINUX_SOCKET__APPEND 0x00000200UL
30420 +#define NETLINK_SELINUX_SOCKET__BIND 0x00000400UL
30421 +#define NETLINK_SELINUX_SOCKET__CONNECT 0x00000800UL
30422 +#define NETLINK_SELINUX_SOCKET__LISTEN 0x00001000UL
30423 +#define NETLINK_SELINUX_SOCKET__ACCEPT 0x00002000UL
30424 +#define NETLINK_SELINUX_SOCKET__GETOPT 0x00004000UL
30425 +#define NETLINK_SELINUX_SOCKET__SETOPT 0x00008000UL
30426 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN 0x00010000UL
30427 +#define NETLINK_SELINUX_SOCKET__RECVFROM 0x00020000UL
30428 +#define NETLINK_SELINUX_SOCKET__SENDTO 0x00040000UL
30429 +#define NETLINK_SELINUX_SOCKET__RECV_MSG 0x00080000UL
30430 +#define NETLINK_SELINUX_SOCKET__SEND_MSG 0x00100000UL
30431 +#define NETLINK_SELINUX_SOCKET__NAME_BIND 0x00200000UL
30432 +#define NETLINK_AUDIT_SOCKET__IOCTL 0x00000001UL
30433 +#define NETLINK_AUDIT_SOCKET__READ 0x00000002UL
30434 +#define NETLINK_AUDIT_SOCKET__WRITE 0x00000004UL
30435 +#define NETLINK_AUDIT_SOCKET__CREATE 0x00000008UL
30436 +#define NETLINK_AUDIT_SOCKET__GETATTR 0x00000010UL
30437 +#define NETLINK_AUDIT_SOCKET__SETATTR 0x00000020UL
30438 +#define NETLINK_AUDIT_SOCKET__LOCK 0x00000040UL
30439 +#define NETLINK_AUDIT_SOCKET__RELABELFROM 0x00000080UL
30440 +#define NETLINK_AUDIT_SOCKET__RELABELTO 0x00000100UL
30441 +#define NETLINK_AUDIT_SOCKET__APPEND 0x00000200UL
30442 +#define NETLINK_AUDIT_SOCKET__BIND 0x00000400UL
30443 +#define NETLINK_AUDIT_SOCKET__CONNECT 0x00000800UL
30444 +#define NETLINK_AUDIT_SOCKET__LISTEN 0x00001000UL
30445 +#define NETLINK_AUDIT_SOCKET__ACCEPT 0x00002000UL
30446 +#define NETLINK_AUDIT_SOCKET__GETOPT 0x00004000UL
30447 +#define NETLINK_AUDIT_SOCKET__SETOPT 0x00008000UL
30448 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN 0x00010000UL
30449 +#define NETLINK_AUDIT_SOCKET__RECVFROM 0x00020000UL
30450 +#define NETLINK_AUDIT_SOCKET__SENDTO 0x00040000UL
30451 +#define NETLINK_AUDIT_SOCKET__RECV_MSG 0x00080000UL
30452 +#define NETLINK_AUDIT_SOCKET__SEND_MSG 0x00100000UL
30453 +#define NETLINK_AUDIT_SOCKET__NAME_BIND 0x00200000UL
30454 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ 0x00400000UL
30455 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE 0x00800000UL
30456 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY 0x01000000UL
30457 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV 0x02000000UL
30458 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT 0x04000000UL
30459 +#define NETLINK_IP6FW_SOCKET__IOCTL 0x00000001UL
30460 +#define NETLINK_IP6FW_SOCKET__READ 0x00000002UL
30461 +#define NETLINK_IP6FW_SOCKET__WRITE 0x00000004UL
30462 +#define NETLINK_IP6FW_SOCKET__CREATE 0x00000008UL
30463 +#define NETLINK_IP6FW_SOCKET__GETATTR 0x00000010UL
30464 +#define NETLINK_IP6FW_SOCKET__SETATTR 0x00000020UL
30465 +#define NETLINK_IP6FW_SOCKET__LOCK 0x00000040UL
30466 +#define NETLINK_IP6FW_SOCKET__RELABELFROM 0x00000080UL
30467 +#define NETLINK_IP6FW_SOCKET__RELABELTO 0x00000100UL
30468 +#define NETLINK_IP6FW_SOCKET__APPEND 0x00000200UL
30469 +#define NETLINK_IP6FW_SOCKET__BIND 0x00000400UL
30470 +#define NETLINK_IP6FW_SOCKET__CONNECT 0x00000800UL
30471 +#define NETLINK_IP6FW_SOCKET__LISTEN 0x00001000UL
30472 +#define NETLINK_IP6FW_SOCKET__ACCEPT 0x00002000UL
30473 +#define NETLINK_IP6FW_SOCKET__GETOPT 0x00004000UL
30474 +#define NETLINK_IP6FW_SOCKET__SETOPT 0x00008000UL
30475 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN 0x00010000UL
30476 +#define NETLINK_IP6FW_SOCKET__RECVFROM 0x00020000UL
30477 +#define NETLINK_IP6FW_SOCKET__SENDTO 0x00040000UL
30478 +#define NETLINK_IP6FW_SOCKET__RECV_MSG 0x00080000UL
30479 +#define NETLINK_IP6FW_SOCKET__SEND_MSG 0x00100000UL
30480 +#define NETLINK_IP6FW_SOCKET__NAME_BIND 0x00200000UL
30481 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ 0x00400000UL
30482 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE 0x00800000UL
30483 +#define NETLINK_DNRT_SOCKET__IOCTL 0x00000001UL
30484 +#define NETLINK_DNRT_SOCKET__READ 0x00000002UL
30485 +#define NETLINK_DNRT_SOCKET__WRITE 0x00000004UL
30486 +#define NETLINK_DNRT_SOCKET__CREATE 0x00000008UL
30487 +#define NETLINK_DNRT_SOCKET__GETATTR 0x00000010UL
30488 +#define NETLINK_DNRT_SOCKET__SETATTR 0x00000020UL
30489 +#define NETLINK_DNRT_SOCKET__LOCK 0x00000040UL
30490 +#define NETLINK_DNRT_SOCKET__RELABELFROM 0x00000080UL
30491 +#define NETLINK_DNRT_SOCKET__RELABELTO 0x00000100UL
30492 +#define NETLINK_DNRT_SOCKET__APPEND 0x00000200UL
30493 +#define NETLINK_DNRT_SOCKET__BIND 0x00000400UL
30494 +#define NETLINK_DNRT_SOCKET__CONNECT 0x00000800UL
30495 +#define NETLINK_DNRT_SOCKET__LISTEN 0x00001000UL
30496 +#define NETLINK_DNRT_SOCKET__ACCEPT 0x00002000UL
30497 +#define NETLINK_DNRT_SOCKET__GETOPT 0x00004000UL
30498 +#define NETLINK_DNRT_SOCKET__SETOPT 0x00008000UL
30499 +#define NETLINK_DNRT_SOCKET__SHUTDOWN 0x00010000UL
30500 +#define NETLINK_DNRT_SOCKET__RECVFROM 0x00020000UL
30501 +#define NETLINK_DNRT_SOCKET__SENDTO 0x00040000UL
30502 +#define NETLINK_DNRT_SOCKET__RECV_MSG 0x00080000UL
30503 +#define NETLINK_DNRT_SOCKET__SEND_MSG 0x00100000UL
30504 +#define NETLINK_DNRT_SOCKET__NAME_BIND 0x00200000UL
30505 +#define ASSOCIATION__SENDTO 0x00000001UL
30506 +#define ASSOCIATION__RECVFROM 0x00000002UL
30507 +#define ASSOCIATION__SETCONTEXT 0x00000004UL
30508 +#define ASSOCIATION__POLMATCH 0x00000008UL
30509 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL
30510 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL
30511 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE 0x00000004UL
30512 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE 0x00000008UL
30513 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR 0x00000010UL
30514 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR 0x00000020UL
30515 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK 0x00000040UL
30516 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
30517 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO 0x00000100UL
30518 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND 0x00000200UL
30519 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND 0x00000400UL
30520 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT 0x00000800UL
30521 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN 0x00001000UL
30522 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT 0x00002000UL
30523 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT 0x00004000UL
30524 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT 0x00008000UL
30525 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN 0x00010000UL
30526 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM 0x00020000UL
30527 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO 0x00040000UL
30528 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG 0x00080000UL
30529 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG 0x00100000UL
30530 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND 0x00200000UL
30531 +#define APPLETALK_SOCKET__IOCTL 0x00000001UL
30532 +#define APPLETALK_SOCKET__READ 0x00000002UL
30533 +#define APPLETALK_SOCKET__WRITE 0x00000004UL
30534 +#define APPLETALK_SOCKET__CREATE 0x00000008UL
30535 +#define APPLETALK_SOCKET__GETATTR 0x00000010UL
30536 +#define APPLETALK_SOCKET__SETATTR 0x00000020UL
30537 +#define APPLETALK_SOCKET__LOCK 0x00000040UL
30538 +#define APPLETALK_SOCKET__RELABELFROM 0x00000080UL
30539 +#define APPLETALK_SOCKET__RELABELTO 0x00000100UL
30540 +#define APPLETALK_SOCKET__APPEND 0x00000200UL
30541 +#define APPLETALK_SOCKET__BIND 0x00000400UL
30542 +#define APPLETALK_SOCKET__CONNECT 0x00000800UL
30543 +#define APPLETALK_SOCKET__LISTEN 0x00001000UL
30544 +#define APPLETALK_SOCKET__ACCEPT 0x00002000UL
30545 +#define APPLETALK_SOCKET__GETOPT 0x00004000UL
30546 +#define APPLETALK_SOCKET__SETOPT 0x00008000UL
30547 +#define APPLETALK_SOCKET__SHUTDOWN 0x00010000UL
30548 +#define APPLETALK_SOCKET__RECVFROM 0x00020000UL
30549 +#define APPLETALK_SOCKET__SENDTO 0x00040000UL
30550 +#define APPLETALK_SOCKET__RECV_MSG 0x00080000UL
30551 +#define APPLETALK_SOCKET__SEND_MSG 0x00100000UL
30552 +#define APPLETALK_SOCKET__NAME_BIND 0x00200000UL
30553 +#define PACKET__SEND 0x00000001UL
30554 +#define PACKET__RECV 0x00000002UL
30555 +#define PACKET__RELABELTO 0x00000004UL
30556 +#define PACKET__FLOW_IN 0x00000008UL
30557 +#define PACKET__FLOW_OUT 0x00000010UL
30558 +#define PACKET__FORWARD_IN 0x00000020UL
30559 +#define PACKET__FORWARD_OUT 0x00000040UL
30560 +#define KEY__VIEW 0x00000001UL
30561 +#define KEY__READ 0x00000002UL
30562 +#define KEY__WRITE 0x00000004UL
30563 +#define KEY__SEARCH 0x00000008UL
30564 +#define KEY__LINK 0x00000010UL
30565 +#define KEY__SETATTR 0x00000020UL
30566 +#define KEY__CREATE 0x00000040UL
30567 +#define DCCP_SOCKET__IOCTL 0x00000001UL
30568 +#define DCCP_SOCKET__READ 0x00000002UL
30569 +#define DCCP_SOCKET__WRITE 0x00000004UL
30570 +#define DCCP_SOCKET__CREATE 0x00000008UL
30571 +#define DCCP_SOCKET__GETATTR 0x00000010UL
30572 +#define DCCP_SOCKET__SETATTR 0x00000020UL
30573 +#define DCCP_SOCKET__LOCK 0x00000040UL
30574 +#define DCCP_SOCKET__RELABELFROM 0x00000080UL
30575 +#define DCCP_SOCKET__RELABELTO 0x00000100UL
30576 +#define DCCP_SOCKET__APPEND 0x00000200UL
30577 +#define DCCP_SOCKET__BIND 0x00000400UL
30578 +#define DCCP_SOCKET__CONNECT 0x00000800UL
30579 +#define DCCP_SOCKET__LISTEN 0x00001000UL
30580 +#define DCCP_SOCKET__ACCEPT 0x00002000UL
30581 +#define DCCP_SOCKET__GETOPT 0x00004000UL
30582 +#define DCCP_SOCKET__SETOPT 0x00008000UL
30583 +#define DCCP_SOCKET__SHUTDOWN 0x00010000UL
30584 +#define DCCP_SOCKET__RECVFROM 0x00020000UL
30585 +#define DCCP_SOCKET__SENDTO 0x00040000UL
30586 +#define DCCP_SOCKET__RECV_MSG 0x00080000UL
30587 +#define DCCP_SOCKET__SEND_MSG 0x00100000UL
30588 +#define DCCP_SOCKET__NAME_BIND 0x00200000UL
30589 +#define DCCP_SOCKET__NODE_BIND 0x00400000UL
30590 +#define DCCP_SOCKET__NAME_CONNECT 0x00800000UL
30591 +#define MEMPROTECT__MMAP_ZERO 0x00000001UL
30592 +#define PEER__RECV 0x00000001UL
30593 +#define CAPABILITY2__MAC_OVERRIDE 0x00000001UL
30594 +#define CAPABILITY2__MAC_ADMIN 0x00000002UL
30595 +#define KERNEL_SERVICE__USE_AS_OVERRIDE 0x00000001UL
30596 +#define KERNEL_SERVICE__CREATE_FILES_AS 0x00000002UL
30597 +#define TUN_SOCKET__IOCTL 0x00000001UL
30598 +#define TUN_SOCKET__READ 0x00000002UL
30599 +#define TUN_SOCKET__WRITE 0x00000004UL
30600 +#define TUN_SOCKET__CREATE 0x00000008UL
30601 +#define TUN_SOCKET__GETATTR 0x00000010UL
30602 +#define TUN_SOCKET__SETATTR 0x00000020UL
30603 +#define TUN_SOCKET__LOCK 0x00000040UL
30604 +#define TUN_SOCKET__RELABELFROM 0x00000080UL
30605 +#define TUN_SOCKET__RELABELTO 0x00000100UL
30606 +#define TUN_SOCKET__APPEND 0x00000200UL
30607 +#define TUN_SOCKET__BIND 0x00000400UL
30608 +#define TUN_SOCKET__CONNECT 0x00000800UL
30609 +#define TUN_SOCKET__LISTEN 0x00001000UL
30610 +#define TUN_SOCKET__ACCEPT 0x00002000UL
30611 +#define TUN_SOCKET__GETOPT 0x00004000UL
30612 +#define TUN_SOCKET__SETOPT 0x00008000UL
30613 +#define TUN_SOCKET__SHUTDOWN 0x00010000UL
30614 +#define TUN_SOCKET__RECVFROM 0x00020000UL
30615 +#define TUN_SOCKET__SENDTO 0x00040000UL
30616 +#define TUN_SOCKET__RECV_MSG 0x00080000UL
30617 +#define TUN_SOCKET__SEND_MSG 0x00100000UL
30618 +#define TUN_SOCKET__NAME_BIND 0x00200000UL
30621 diff -NurpP --minimal linux-2.6.33/security/selinux/hooks.c linux-2.6.33-vs2.3.0.36.30.1/security/selinux/hooks.c
30622 --- linux-2.6.33/security/selinux/hooks.c 2010-02-25 11:52:12.000000000 +0100
30623 +++ linux-2.6.33-vs2.3.0.36.30.1/security/selinux/hooks.c 2010-02-25 12:02:16.000000000 +0100
30625 #include <linux/dccp.h>
30626 #include <linux/quota.h>
30627 #include <linux/un.h> /* for Unix socket types */
30628 -#include <net/af_unix.h> /* for Unix socket types */
30629 #include <linux/parser.h>
30630 #include <linux/nfs_mount.h>
30631 #include <net/ipv6.h>
30632 diff -NurpP linux-2.6.33-vs2.3.0.36.30.1/security/commoncap.c linux-2.6.33-vs2.3.0.36.30.2/security/commoncap.c
30633 --- linux-2.6.33-vs2.3.0.36.30.1/security/commoncap.c 2010-02-25 12:02:16.000000000 +0100
30634 +++ linux-2.6.33-vs2.3.0.36.30.2/security/commoncap.c 2010-03-05 15:30:01.000000000 +0100
30635 @@ -587,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
30637 if (!strncmp(name, XATTR_SECURITY_PREFIX,
30638 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
30639 - !capable(CAP_SYS_ADMIN))
30640 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
30644 diff -NurpP linux-2.6.33-vs2.3.0.36.30.1/fs/xattr.c linux-2.6.33-vs2.3.0.36.30.2/fs/xattr.c
30645 --- linux-2.6.33-vs2.3.0.36.30.1/fs/xattr.c 2010-02-25 12:02:16.000000000 +0100
30646 +++ linux-2.6.33-vs2.3.0.36.30.2/fs/xattr.c 2010-03-05 19:55:41.000000000 +0100
30647 @@ -50,7 +50,7 @@ xattr_permission(struct inode *inode, co
30648 * The trusted.* namespace can only be accessed by a privileged user.
30650 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
30651 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
30652 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
30654 /* In user.* namespace, only regular files and directories can have
30655 * extended attributes. For sticky directories, only the owner and
30656 diff -NurpP linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/context.h linux-2.6.33-vs2.3.0.36.30.2/include/linux/vserver/context.h
30657 --- linux-2.6.33-vs2.3.0.36.30.1/include/linux/vserver/context.h 2010-02-25 12:02:16.000000000 +0100
30658 +++ linux-2.6.33-vs2.3.0.36.30.2/include/linux/vserver/context.h 2010-03-05 19:53:00.000000000 +0100
30660 #define VXC_SET_UTSNAME 0x00000001
30661 #define VXC_SET_RLIMIT 0x00000002
30662 #define VXC_FS_SECURITY 0x00000004
30663 +#define VXC_FS_TRUSTED 0x00000008
30664 #define VXC_TIOCSTI 0x00000010
30666 /* was VXC_RAW_ICMP 0x00000100 */