1 diff -NurpP --minimal linux-2.6.29/arch/alpha/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/Kconfig
2 --- linux-2.6.29/arch/alpha/Kconfig 2009-03-24 14:18:07.000000000 +0100
3 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/Kconfig 2009-03-24 14:48:16.000000000 +0100
4 @@ -666,6 +666,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.29/arch/alpha/kernel/entry.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/entry.S
14 --- linux-2.6.29/arch/alpha/kernel/entry.S 2009-03-24 14:18:07.000000000 +0100
15 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/entry.S 2009-03-24 14:48: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.29/arch/alpha/kernel/osf_sys.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.29/arch/alpha/kernel/osf_sys.c 2009-03-24 14:18:07.000000000 +0100
50 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/osf_sys.c 2009-03-24 14:48:16.000000000 +0100
51 @@ -877,7 +877,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.29/arch/alpha/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.29/arch/alpha/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
62 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/ptrace.c 2009-02-22 22:54:24.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.29/arch/alpha/kernel/systbls.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/systbls.S
72 --- linux-2.6.29/arch/alpha/kernel/systbls.S 2009-03-24 14:18:08.000000000 +0100
73 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/systbls.S 2009-03-24 14:48: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.29/arch/alpha/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/traps.c
84 --- linux-2.6.29/arch/alpha/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
85 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/kernel/traps.c 2009-02-22 22:54:24.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.29/arch/alpha/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/mm/fault.c
97 --- linux-2.6.29/arch/alpha/mm/fault.c 2008-12-25 00:26:37.000000000 +0100
98 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/alpha/mm/fault.c 2009-02-22 22:54:24.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.29/arch/arm/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/Kconfig
111 --- linux-2.6.29/arch/arm/Kconfig 2009-03-24 14:18:08.000000000 +0100
112 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/Kconfig 2009-03-24 14:48:16.000000000 +0100
113 @@ -1333,6 +1333,8 @@ source "fs/Kconfig"
115 source "arch/arm/Kconfig.debug"
117 +source "kernel/vserver/Kconfig"
119 source "security/Kconfig"
121 source "crypto/Kconfig"
122 diff -NurpP --minimal linux-2.6.29/arch/arm/kernel/calls.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/kernel/calls.S
123 --- linux-2.6.29/arch/arm/kernel/calls.S 2009-03-24 14:18:09.000000000 +0100
124 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/kernel/calls.S 2009-02-22 22:54:24.000000000 +0100
126 /* 310 */ CALL(sys_request_key)
128 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
129 -/* vserver */ CALL(sys_ni_syscall)
132 /* 315 */ CALL(sys_ioprio_get)
133 CALL(sys_inotify_init)
134 diff -NurpP --minimal linux-2.6.29/arch/arm/kernel/process.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/kernel/process.c
135 --- linux-2.6.29/arch/arm/kernel/process.c 2008-12-25 00:26:37.000000000 +0100
136 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/kernel/process.c 2009-02-22 22:54:24.000000000 +0100
137 @@ -262,7 +262,8 @@ void __show_regs(struct pt_regs *regs)
138 void show_regs(struct pt_regs * regs)
141 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
142 + printk("Pid: %d[#%u], comm: %20s\n",
143 + task_pid_nr(current), current->xid, current->comm);
147 diff -NurpP --minimal linux-2.6.29/arch/arm/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/kernel/traps.c
148 --- linux-2.6.29/arch/arm/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
149 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
150 @@ -214,8 +214,8 @@ static void __die(const char *str, int e
151 str, err, ++die_counter);
154 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
155 - tsk->comm, task_pid_nr(tsk), thread + 1);
156 + printk("Process %s (pid: %d:#%u, stack limit = 0x%p)\n",
157 + tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
159 if (!user_mode(regs) || in_interrupt()) {
160 dump_mem("Stack: ", regs->ARM_sp,
161 diff -NurpP --minimal linux-2.6.29/arch/arm/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/mm/fault.c
162 --- linux-2.6.29/arch/arm/mm/fault.c 2009-03-24 14:18:17.000000000 +0100
163 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/arm/mm/fault.c 2009-03-24 14:48:17.000000000 +0100
164 @@ -294,7 +294,8 @@ do_page_fault(unsigned long addr, unsign
165 * happened to us that made us unable to handle
166 * the page fault gracefully.
168 - printk("VM: killing process %s\n", tsk->comm);
169 + printk("VM: killing process %s(%d:#%u)\n",
170 + tsk->comm, task_pid_nr(tsk), tsk->xid);
171 do_group_exit(SIGKILL);
174 diff -NurpP --minimal linux-2.6.29/arch/cris/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/cris/Kconfig
175 --- linux-2.6.29/arch/cris/Kconfig 2009-03-24 14:18:23.000000000 +0100
176 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/cris/Kconfig 2009-03-24 14:48:19.000000000 +0100
177 @@ -685,6 +685,8 @@ source "drivers/staging/Kconfig"
179 source "arch/cris/Kconfig.debug"
181 +source "kernel/vserver/Kconfig"
183 source "security/Kconfig"
185 source "crypto/Kconfig"
186 diff -NurpP --minimal linux-2.6.29/arch/frv/kernel/kernel_thread.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/frv/kernel/kernel_thread.S
187 --- linux-2.6.29/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
188 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/frv/kernel/kernel_thread.S 2009-02-22 22:54:24.000000000 +0100
189 @@ -37,7 +37,7 @@ kernel_thread:
191 # start by forking the current process, but with shared VM
192 setlos.p #__NR_clone,gr7 ; syscall number
193 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
194 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
195 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
197 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
198 diff -NurpP --minimal linux-2.6.29/arch/h8300/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/h8300/Kconfig
199 --- linux-2.6.29/arch/h8300/Kconfig 2009-03-24 14:18:24.000000000 +0100
200 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/h8300/Kconfig 2009-03-24 14:48:19.000000000 +0100
201 @@ -226,6 +226,8 @@ source "fs/Kconfig"
203 source "arch/h8300/Kconfig.debug"
205 +source "kernel/vserver/Kconfig"
207 source "security/Kconfig"
209 source "crypto/Kconfig"
210 diff -NurpP --minimal linux-2.6.29/arch/ia64/ia32/ia32_entry.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/ia32/ia32_entry.S
211 --- linux-2.6.29/arch/ia64/ia32/ia32_entry.S 2009-03-24 14:18:24.000000000 +0100
212 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/ia32/ia32_entry.S 2009-02-22 22:54:24.000000000 +0100
213 @@ -451,7 +451,7 @@ ia32_syscall_table:
214 data8 sys_tgkill /* 270 */
215 data8 compat_sys_utimes
216 data8 sys32_fadvise64_64
217 - data8 sys_ni_syscall
218 + data8 sys32_vserver
220 data8 sys_ni_syscall /* 275 */
222 diff -NurpP --minimal linux-2.6.29/arch/ia64/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/Kconfig
223 --- linux-2.6.29/arch/ia64/Kconfig 2009-03-24 14:18:24.000000000 +0100
224 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/Kconfig 2009-03-24 14:48:19.000000000 +0100
225 @@ -672,6 +672,8 @@ source "fs/Kconfig"
227 source "arch/ia64/Kconfig.debug"
229 +source "kernel/vserver/Kconfig"
231 source "security/Kconfig"
233 source "crypto/Kconfig"
234 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/entry.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/entry.S
235 --- linux-2.6.29/arch/ia64/kernel/entry.S 2009-03-24 14:18:25.000000000 +0100
236 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/entry.S 2009-02-22 22:54:24.000000000 +0100
237 @@ -1653,7 +1653,7 @@ sys_call_table:
239 data8 sys_mq_getsetattr
241 - data8 sys_ni_syscall // reserved for vserver
243 data8 sys_waitid // 1270
245 data8 sys_request_key
246 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/perfmon.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/perfmon.c
247 --- linux-2.6.29/arch/ia64/kernel/perfmon.c 2009-03-24 14:18:25.000000000 +0100
248 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/perfmon.c 2009-03-24 14:48:19.000000000 +0100
250 #include <linux/rcupdate.h>
251 #include <linux/completion.h>
252 #include <linux/tracehook.h>
253 +#include <linux/vs_memory.h>
255 #include <asm/errno.h>
256 #include <asm/intrinsics.h>
257 @@ -2372,7 +2373,7 @@ pfm_smpl_buffer_alloc(struct task_struct
259 insert_vm_struct(mm, vma);
261 - mm->total_vm += size >> PAGE_SHIFT;
262 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
263 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
265 up_write(&task->mm->mmap_sem);
266 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/process.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/process.c
267 --- linux-2.6.29/arch/ia64/kernel/process.c 2008-12-25 00:26:37.000000000 +0100
268 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/process.c 2009-02-22 22:54:24.000000000 +0100
269 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
270 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
273 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
274 - smp_processor_id(), current->comm);
275 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
276 + current->xid, smp_processor_id(), current->comm);
277 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
278 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
279 init_utsname()->release);
280 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/ptrace.c
281 --- linux-2.6.29/arch/ia64/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
282 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
284 #include <linux/regset.h>
285 #include <linux/elf.h>
286 #include <linux/tracehook.h>
287 +#include <linux/vs_base.h>
289 #include <asm/pgtable.h>
290 #include <asm/processor.h>
291 diff -NurpP --minimal linux-2.6.29/arch/ia64/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/traps.c
292 --- linux-2.6.29/arch/ia64/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
293 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
294 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
297 if (++die.lock_owner_depth < 3) {
298 - printk("%s[%d]: %s %ld [%d]\n",
299 - current->comm, task_pid_nr(current), str, err, ++die_counter);
300 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
301 + current->comm, task_pid_nr(current), current->xid,
302 + str, err, ++die_counter);
303 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
306 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
307 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
308 last.time = current_jiffies + 5 * HZ;
310 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
311 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
312 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
313 + current->comm, task_pid_nr(current), current->xid,
314 + regs->cr_iip + ia64_psr(regs)->ri, isr);
318 diff -NurpP --minimal linux-2.6.29/arch/ia64/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/mm/fault.c
319 --- linux-2.6.29/arch/ia64/mm/fault.c 2008-12-25 00:26:37.000000000 +0100
320 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/ia64/mm/fault.c 2009-02-22 22:54:24.000000000 +0100
322 #include <linux/interrupt.h>
323 #include <linux/kprobes.h>
324 #include <linux/kdebug.h>
325 +#include <linux/vs_memory.h>
327 #include <asm/pgtable.h>
328 #include <asm/processor.h>
329 diff -NurpP --minimal linux-2.6.29/arch/m32r/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/m32r/kernel/traps.c
330 --- linux-2.6.29/arch/m32r/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
331 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/m32r/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
332 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
334 printk("SPI: %08lx\n", sp);
336 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
337 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
338 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
339 + current->comm, task_pid_nr(current), current->xid,
340 + 0xffff & i, 4096+(unsigned long)current);
343 * When in-kernel, we also print out the stack and code at the
344 diff -NurpP --minimal linux-2.6.29/arch/m68k/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68k/Kconfig
345 --- linux-2.6.29/arch/m68k/Kconfig 2009-03-24 14:18:26.000000000 +0100
346 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68k/Kconfig 2009-03-24 14:48:20.000000000 +0100
347 @@ -616,6 +616,8 @@ source "fs/Kconfig"
349 source "arch/m68k/Kconfig.debug"
351 +source "kernel/vserver/Kconfig"
353 source "security/Kconfig"
355 source "crypto/Kconfig"
356 diff -NurpP --minimal linux-2.6.29/arch/m68k/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68k/kernel/ptrace.c
357 --- linux-2.6.29/arch/m68k/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
358 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68k/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
360 #include <linux/ptrace.h>
361 #include <linux/user.h>
362 #include <linux/signal.h>
363 +#include <linux/vs_base.h>
365 #include <asm/uaccess.h>
366 #include <asm/page.h>
367 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
368 ret = ptrace_request(child, request, addr, data);
371 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
376 diff -NurpP --minimal linux-2.6.29/arch/m68k/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68k/kernel/traps.c
377 --- linux-2.6.29/arch/m68k/kernel/traps.c 2009-03-24 14:18:26.000000000 +0100
378 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68k/kernel/traps.c 2009-03-24 14:48:20.000000000 +0100
379 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
380 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
381 regs->d4, regs->d5, regs->a0, regs->a1);
383 - printk("Process %s (pid: %d, task=%p)\n",
384 - current->comm, task_pid_nr(current), current);
385 + printk("Process %s (pid: %d[#%u], task=%p)\n",
386 + current->comm, task_pid_nr(current), current->xid, current);
387 addr = (unsigned long)&fp->un;
388 printk("Frame format=%X ", regs->format);
389 switch (regs->format) {
390 diff -NurpP --minimal linux-2.6.29/arch/m68knommu/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68knommu/Kconfig
391 --- linux-2.6.29/arch/m68knommu/Kconfig 2009-03-24 14:18:27.000000000 +0100
392 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68knommu/Kconfig 2009-03-24 14:48:20.000000000 +0100
393 @@ -720,6 +720,8 @@ source "fs/Kconfig"
395 source "arch/m68knommu/Kconfig.debug"
397 +source "kernel/vserver/Kconfig"
399 source "security/Kconfig"
401 source "crypto/Kconfig"
402 diff -NurpP --minimal linux-2.6.29/arch/m68knommu/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68knommu/kernel/traps.c
403 --- linux-2.6.29/arch/m68knommu/kernel/traps.c 2008-12-25 00:26:37.000000000 +0100
404 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/m68knommu/kernel/traps.c 2009-02-22 22:54:24.000000000 +0100
405 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
406 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
407 fp->d4, fp->d5, fp->a0, fp->a1);
409 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
410 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
411 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
412 + current->comm, task_pid_nr(current), current->xid,
413 + PAGE_SIZE+(unsigned long)current);
414 show_stack(NULL, (unsigned long *)(fp + 1));
415 add_taint(TAINT_DIE);
417 diff -NurpP --minimal linux-2.6.29/arch/mips/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/Kconfig
418 --- linux-2.6.29/arch/mips/Kconfig 2009-03-24 14:18:29.000000000 +0100
419 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/Kconfig 2009-03-24 14:48:21.000000000 +0100
420 @@ -2142,6 +2142,8 @@ source "fs/Kconfig"
422 source "arch/mips/Kconfig.debug"
424 +source "kernel/vserver/Kconfig"
426 source "security/Kconfig"
428 source "crypto/Kconfig"
429 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/ptrace.c
430 --- linux-2.6.29/arch/mips/kernel/ptrace.c 2008-12-25 00:26:37.000000000 +0100
431 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/ptrace.c 2009-02-22 22:54:24.000000000 +0100
433 #include <linux/security.h>
434 #include <linux/audit.h>
435 #include <linux/seccomp.h>
436 +#include <linux/vs_base.h>
438 #include <asm/byteorder.h>
440 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
444 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
448 /* when I and D space are separate, these will need to be fixed. */
449 case PTRACE_PEEKTEXT: /* read word at location addr. */
450 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall32-o32.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall32-o32.S
451 --- linux-2.6.29/arch/mips/kernel/scall32-o32.S 2009-03-24 14:18:31.000000000 +0100
452 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall32-o32.S 2009-03-24 14:48:21.000000000 +0100
453 @@ -597,7 +597,7 @@ einval: li v0, -ENOSYS
454 sys sys_mq_timedreceive 5
455 sys sys_mq_notify 2 /* 4275 */
456 sys sys_mq_getsetattr 3
457 - sys sys_ni_syscall 0 /* sys_vserver */
460 sys sys_ni_syscall 0 /* available, was setaltroot */
461 sys sys_add_key 5 /* 4280 */
462 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall64-64.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall64-64.S
463 --- linux-2.6.29/arch/mips/kernel/scall64-64.S 2009-03-24 14:18:31.000000000 +0100
464 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall64-64.S 2009-03-24 14:48:21.000000000 +0100
465 @@ -434,7 +434,7 @@ sys_call_table:
466 PTR sys_mq_timedreceive
468 PTR sys_mq_getsetattr /* 5235 */
469 - PTR sys_ni_syscall /* sys_vserver */
472 PTR sys_ni_syscall /* available, was setaltroot */
474 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall64-n32.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall64-n32.S
475 --- linux-2.6.29/arch/mips/kernel/scall64-n32.S 2009-03-24 14:18:31.000000000 +0100
476 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall64-n32.S 2009-03-24 14:48:21.000000000 +0100
477 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
478 PTR compat_sys_mq_timedreceive
479 PTR compat_sys_mq_notify
480 PTR compat_sys_mq_getsetattr
481 - PTR sys_ni_syscall /* 6240, sys_vserver */
482 + PTR sys32_vserver /* 6240 */
483 PTR compat_sys_waitid
484 PTR sys_ni_syscall /* available, was setaltroot */
486 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/scall64-o32.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall64-o32.S
487 --- linux-2.6.29/arch/mips/kernel/scall64-o32.S 2009-03-24 14:18:31.000000000 +0100
488 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/scall64-o32.S 2009-03-24 14:59:48.000000000 +0100
489 @@ -480,7 +480,7 @@ sys_call_table:
490 PTR compat_sys_mq_timedreceive
491 PTR compat_sys_mq_notify /* 4275 */
492 PTR compat_sys_mq_getsetattr
493 - PTR sys_ni_syscall /* sys_vserver */
496 PTR sys_ni_syscall /* available, was setaltroot */
497 PTR sys_add_key /* 4280 */
498 diff -NurpP --minimal linux-2.6.29/arch/mips/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/traps.c
499 --- linux-2.6.29/arch/mips/kernel/traps.c 2009-03-24 14:18:31.000000000 +0100
500 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/mips/kernel/traps.c 2009-03-24 14:48:21.000000000 +0100
501 @@ -335,9 +335,10 @@ void show_registers(const struct pt_regs
505 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
506 - current->comm, current->pid, current_thread_info(), current,
507 - field, current_thread_info()->tp_value);
508 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
509 + current->comm, task_pid_nr(current), current->xid,
510 + current_thread_info(), current,
511 + field, current_thread_info()->tp_value);
512 if (cpu_has_userlocal) {
515 diff -NurpP --minimal linux-2.6.29/arch/parisc/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/Kconfig
516 --- linux-2.6.29/arch/parisc/Kconfig 2009-03-24 14:18:32.000000000 +0100
517 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/Kconfig 2009-03-24 14:48:21.000000000 +0100
518 @@ -281,6 +281,8 @@ source "fs/Kconfig"
520 source "arch/parisc/Kconfig.debug"
522 +source "kernel/vserver/Kconfig"
524 source "security/Kconfig"
526 source "crypto/Kconfig"
527 diff -NurpP --minimal linux-2.6.29/arch/parisc/kernel/syscall_table.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/kernel/syscall_table.S
528 --- linux-2.6.29/arch/parisc/kernel/syscall_table.S 2008-12-25 00:26:37.000000000 +0100
529 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/kernel/syscall_table.S 2009-02-22 22:54:24.000000000 +0100
531 ENTRY_COMP(mbind) /* 260 */
532 ENTRY_COMP(get_mempolicy)
533 ENTRY_COMP(set_mempolicy)
534 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
535 + ENTRY_DIFF(vserver)
537 ENTRY_SAME(request_key) /* 265 */
539 diff -NurpP --minimal linux-2.6.29/arch/parisc/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/kernel/traps.c
540 --- linux-2.6.29/arch/parisc/kernel/traps.c 2009-03-24 14:18:32.000000000 +0100
541 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/kernel/traps.c 2009-03-24 14:48:21.000000000 +0100
542 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
546 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
547 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
548 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
549 + current->comm, task_pid_nr(current), current->xid,
550 + str, err, regs->iaoq[0]);
551 #ifdef PRINT_USER_FAULTS
552 /* XXX for debugging only */
554 @@ -269,8 +270,8 @@ KERN_CRIT " || |
555 pdc_console_restart();
558 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
559 - current->comm, task_pid_nr(current), str, err);
560 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
561 + current->comm, task_pid_nr(current), current->xid, str, err);
563 /* Wot's wrong wif bein' racy? */
564 if (current->thread.flags & PARISC_KERNEL_DEATH) {
565 diff -NurpP --minimal linux-2.6.29/arch/parisc/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/mm/fault.c
566 --- linux-2.6.29/arch/parisc/mm/fault.c 2009-03-24 14:18:33.000000000 +0100
567 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/parisc/mm/fault.c 2009-03-24 14:48:21.000000000 +0100
568 @@ -238,8 +238,9 @@ bad_area:
570 #ifdef PRINT_USER_FAULTS
571 printk(KERN_DEBUG "\n");
572 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
573 - task_pid_nr(tsk), tsk->comm, code, address);
574 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
575 + "command='%s' type=%lu address=0x%08lx\n",
576 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
578 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
579 vma->vm_start, vma->vm_end);
580 @@ -265,7 +266,8 @@ no_context:
583 up_read(&mm->mmap_sem);
584 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
585 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
586 + current->comm, current->pid, current->xid);
588 do_group_exit(SIGKILL);
590 diff -NurpP --minimal linux-2.6.29/arch/powerpc/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/Kconfig
591 --- linux-2.6.29/arch/powerpc/Kconfig 2009-03-24 14:18:33.000000000 +0100
592 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/Kconfig 2009-03-24 14:48:22.000000000 +0100
593 @@ -882,6 +882,8 @@ source "lib/Kconfig"
595 source "arch/powerpc/Kconfig.debug"
597 +source "kernel/vserver/Kconfig"
599 source "security/Kconfig"
602 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/irq.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/irq.c
603 --- linux-2.6.29/arch/powerpc/kernel/irq.c 2009-03-24 14:18:35.000000000 +0100
604 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/irq.c 2009-03-24 14:48:22.000000000 +0100
606 #include <linux/bootmem.h>
607 #include <linux/pci.h>
608 #include <linux/debugfs.h>
609 +#include <linux/vs_context.h>
611 #include <asm/uaccess.h>
612 #include <asm/system.h>
613 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/process.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/process.c
614 --- linux-2.6.29/arch/powerpc/kernel/process.c 2009-03-24 14:18:35.000000000 +0100
615 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/process.c 2009-03-24 14:48:22.000000000 +0100
616 @@ -516,8 +516,9 @@ void show_regs(struct pt_regs * regs)
618 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
620 - printk("TASK = %p[%d] '%s' THREAD: %p",
621 - current, task_pid_nr(current), current->comm, task_thread_info(current));
622 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
623 + current, task_pid_nr(current), current->xid,
624 + current->comm, task_thread_info(current));
627 printk(" CPU: %d", raw_smp_processor_id());
628 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/traps.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/traps.c
629 --- linux-2.6.29/arch/powerpc/kernel/traps.c 2009-03-24 14:18:35.000000000 +0100
630 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/traps.c 2009-03-24 14:48:22.000000000 +0100
631 @@ -940,8 +940,9 @@ void nonrecoverable_exception(struct pt_
633 void trace_syscall(struct pt_regs *regs)
635 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
636 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
637 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
638 + current, task_pid_nr(current), current->xid,
639 + regs->nip, regs->link, regs->gpr[0],
640 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
643 diff -NurpP --minimal linux-2.6.29/arch/powerpc/kernel/vdso.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/vdso.c
644 --- linux-2.6.29/arch/powerpc/kernel/vdso.c 2009-03-24 14:18:35.000000000 +0100
645 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/kernel/vdso.c 2009-03-24 14:48:22.000000000 +0100
647 #include <linux/security.h>
648 #include <linux/bootmem.h>
649 #include <linux/lmb.h>
650 +#include <linux/vs_memory.h>
652 #include <asm/pgtable.h>
653 #include <asm/system.h>
654 diff -NurpP --minimal linux-2.6.29/arch/powerpc/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/mm/fault.c
655 --- linux-2.6.29/arch/powerpc/mm/fault.c 2009-03-24 14:18:36.000000000 +0100
656 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/powerpc/mm/fault.c 2009-03-24 14:48:22.000000000 +0100
657 @@ -362,7 +362,8 @@ out_of_memory:
658 down_read(&mm->mmap_sem);
661 - printk("VM: killing process %s\n", current->comm);
662 + printk("VM: killing process %s(%d:#%u)\n",
663 + current->comm, current->pid, current->xid);
665 do_group_exit(SIGKILL);
667 diff -NurpP --minimal linux-2.6.29/arch/s390/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/Kconfig
668 --- linux-2.6.29/arch/s390/Kconfig 2009-03-24 14:18:38.000000000 +0100
669 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/Kconfig 2009-03-24 14:48:22.000000000 +0100
670 @@ -586,6 +586,8 @@ source "fs/Kconfig"
672 source "arch/s390/Kconfig.debug"
674 +source "kernel/vserver/Kconfig"
676 source "security/Kconfig"
678 source "crypto/Kconfig"
679 diff -NurpP --minimal linux-2.6.29/arch/s390/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/kernel/ptrace.c
680 --- linux-2.6.29/arch/s390/kernel/ptrace.c 2009-03-24 14:18:40.000000000 +0100
681 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/kernel/ptrace.c 2009-03-24 14:48:22.000000000 +0100
683 #include <linux/elf.h>
684 #include <linux/regset.h>
685 #include <linux/tracehook.h>
686 +#include <linux/vs_base.h>
688 #include <asm/segment.h>
689 #include <asm/page.h>
690 diff -NurpP --minimal linux-2.6.29/arch/s390/kernel/syscalls.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/kernel/syscalls.S
691 --- linux-2.6.29/arch/s390/kernel/syscalls.S 2009-03-24 14:18:40.000000000 +0100
692 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/kernel/syscalls.S 2009-03-24 14:48:22.000000000 +0100
693 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
694 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
695 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
696 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
697 -NI_SYSCALL /* reserved for vserver */
698 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
699 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
700 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
701 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
702 diff -NurpP --minimal linux-2.6.29/arch/s390/mm/fault.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/mm/fault.c
703 --- linux-2.6.29/arch/s390/mm/fault.c 2008-12-25 00:26:37.000000000 +0100
704 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/s390/mm/fault.c 2009-02-22 22:54:24.000000000 +0100
705 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
706 down_read(&mm->mmap_sem);
709 - printk("VM: killing process %s\n", tsk->comm);
710 + printk("VM: killing process %s(%d:#%u)\n",
711 + tsk->comm, tsk->pid, tsk->xid);
712 if (regs->psw.mask & PSW_MASK_PSTATE)
713 do_group_exit(SIGKILL);
714 do_no_context(regs, error_code, address);
715 diff -NurpP --minimal linux-2.6.29/arch/sh/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/sh/Kconfig
716 --- linux-2.6.29/arch/sh/Kconfig 2009-03-24 14:18:40.000000000 +0100
717 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/sh/Kconfig 2009-03-24 14:48:22.000000000 +0100
718 @@ -694,6 +694,8 @@ source "fs/Kconfig"
720 source "arch/sh/Kconfig.debug"
722 +source "kernel/vserver/Kconfig"
724 source "security/Kconfig"
726 source "crypto/Kconfig"
727 diff -NurpP --minimal linux-2.6.29/arch/sh/kernel/irq.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/sh/kernel/irq.c
728 --- linux-2.6.29/arch/sh/kernel/irq.c 2008-12-25 00:26:37.000000000 +0100
729 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/sh/kernel/irq.c 2009-02-22 22:54:24.000000000 +0100
731 #include <linux/module.h>
732 #include <linux/kernel_stat.h>
733 #include <linux/seq_file.h>
734 +#include <linux/vs_context.h>
735 #include <asm/processor.h>
736 #include <asm/machvec.h>
737 #include <asm/uaccess.h>
738 diff -NurpP --minimal linux-2.6.29/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.29-vs2.3.0.36.9-pre3/arch/sh/kernel/vsyscall/vsyscall.c
739 --- linux-2.6.29/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:18:42.000000000 +0100
740 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/sh/kernel/vsyscall/vsyscall.c 2009-03-24 14:48:22.000000000 +0100
742 #include <linux/elf.h>
743 #include <linux/sched.h>
744 #include <linux/err.h>
745 +#include <linux/vs_memory.h>
748 * Should the kernel map a VDSO page into processes and pass its
749 diff -NurpP --minimal linux-2.6.29/arch/sparc/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/sparc/Kconfig
750 --- linux-2.6.29/arch/sparc/Kconfig 2009-03-24 14:18:43.000000000 +0100
751 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/sparc/Kconfig 2009-03-24 14:48:22.000000000 +0100
752 @@ -522,6 +522,8 @@ source "fs/Kconfig"
754 source "arch/sparc/Kconfig.debug"
756 +source "kernel/vserver/Kconfig"
758 source "security/Kconfig"
760 source "crypto/Kconfig"
761 diff -NurpP --minimal linux-2.6.29/arch/x86/ia32/ia32entry.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/ia32/ia32entry.S
762 --- linux-2.6.29/arch/x86/ia32/ia32entry.S 2009-03-24 14:18:48.000000000 +0100
763 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/ia32/ia32entry.S 2009-03-22 23:29:11.000000000 +0100
764 @@ -768,7 +768,7 @@ ia32_sys_call_table:
765 .quad sys_tgkill /* 270 */
766 .quad compat_sys_utimes
767 .quad sys32_fadvise64_64
768 - .quad quiet_ni_syscall /* sys_vserver */
769 + .quad sys32_vserver
771 .quad compat_sys_get_mempolicy /* 275 */
772 .quad sys_set_mempolicy
773 diff -NurpP --minimal linux-2.6.29/arch/x86/include/asm/unistd_64.h linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/include/asm/unistd_64.h
774 --- linux-2.6.29/arch/x86/include/asm/unistd_64.h 2008-12-25 00:26:37.000000000 +0100
775 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/include/asm/unistd_64.h 2009-02-22 22:54:24.000000000 +0100
776 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
777 #define __NR_utimes 235
778 __SYSCALL(__NR_utimes, sys_utimes)
779 #define __NR_vserver 236
780 -__SYSCALL(__NR_vserver, sys_ni_syscall)
781 +__SYSCALL(__NR_vserver, sys_vserver)
782 #define __NR_mbind 237
783 __SYSCALL(__NR_mbind, sys_mbind)
784 #define __NR_set_mempolicy 238
785 diff -NurpP --minimal linux-2.6.29/arch/x86/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/Kconfig
786 --- linux-2.6.29/arch/x86/Kconfig 2009-03-24 14:18:47.000000000 +0100
787 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/Kconfig 2009-03-24 14:48:23.000000000 +0100
788 @@ -1990,6 +1990,8 @@ source "fs/Kconfig"
790 source "arch/x86/Kconfig.debug"
792 +source "kernel/vserver/Kconfig"
794 source "security/Kconfig"
796 source "crypto/Kconfig"
797 diff -NurpP --minimal linux-2.6.29/arch/x86/kernel/syscall_table_32.S linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/kernel/syscall_table_32.S
798 --- linux-2.6.29/arch/x86/kernel/syscall_table_32.S 2009-03-24 14:18:51.000000000 +0100
799 +++ linux-2.6.29-vs2.3.0.36.9-pre3/arch/x86/kernel/syscall_table_32.S 2009-02-22 22:54:24.000000000 +0100
800 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
801 .long sys_tgkill /* 270 */
803 .long sys_fadvise64_64
804 - .long sys_ni_syscall /* sys_vserver */
807 .long sys_get_mempolicy
808 .long sys_set_mempolicy
809 diff -NurpP --minimal linux-2.6.29/Documentation/vserver/debug.txt linux-2.6.29-vs2.3.0.36.9-pre3/Documentation/vserver/debug.txt
810 --- linux-2.6.29/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
811 +++ linux-2.6.29-vs2.3.0.36.9-pre3/Documentation/vserver/debug.txt 2009-02-22 22:54:24.000000000 +0100
816 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
817 + "vx_rmap_tgid: %p/%llx: %d -> %d"
821 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
822 + "FREE (%p,#%d)%c inode"
823 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
824 + "FREE (%p,#%d)%c %lld bytes"
825 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
826 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
827 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
828 + "rcu_free_dl_info(%p)"
829 + 4 10 "alloc_dl_info(%p,%d) = %p"
830 + "dealloc_dl_info(%p)"
831 + "get_dl_info(%p[#%d.%d])"
832 + "put_dl_info(%p[#%d.%d])"
833 + 5 20 "alloc_dl_info(%p,%d)*"
834 + 6 40 "__hash_dl_info: %p[#%d]"
835 + "__unhash_dl_info: %p[#%d]"
836 + 7 80 "locate_dl_info(%p,#%d) = %p"
840 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
841 + "new_dqhash: %p [#0x%08x]"
842 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
843 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
844 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
845 + "vroot_get_real_bdev not set"
846 + 1 2 "cow_break_link(»%s«)"
848 + 2 4 "dentry_open(new): %p"
849 + "dentry_open(old): %p"
850 + "lookup_create(new): %p"
852 + "path_lookup(old): %d"
853 + "vfs_create(new): %d"
856 + 3 8 "fput(new_file=%p[#%d])"
857 + "fput(old_file=%p[#%d])"
858 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
859 + "vx_info_kill(%p[#%d],%d,%d)*"
860 + 5 20 "vs_reboot(%p[#%d],%d)"
861 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
865 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
866 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
867 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
868 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
869 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
870 + 6 40 "sk,egf: %p [#%d] (from %d)"
871 + "sk,egn: %p [#%d] (from %d)"
872 + "sk,req: %p [#%d] (from %d)"
873 + "sk: %p [#%d] (from %d)"
874 + "tw: %p [#%d] (from %d)"
875 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
876 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
880 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
881 + "alloc_nx_info(%d) = %p"
882 + "create_nx_info(%d) (dynamic rejected)"
883 + "create_nx_info(%d) = %p (already there)"
884 + "create_nx_info(%d) = %p (new)"
885 + "dealloc_nx_info(%p)"
886 + 1 2 "alloc_nx_info(%d)*"
887 + "create_nx_info(%d)*"
888 + 2 4 "get_nx_info(%p[#%d.%d])"
889 + "put_nx_info(%p[#%d.%d])"
890 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
891 + "clr_nx_info(%p[#%d.%d])"
892 + "init_nx_info(%p[#%d.%d])"
893 + "release_nx_info(%p[#%d.%d.%d]) %p"
894 + "set_nx_info(%p[#%d.%d])"
895 + 4 10 "__hash_nx_info: %p[#%d]"
896 + "__nx_dynamic_id: [#%d]"
897 + "__unhash_nx_info: %p[#%d.%d.%d]"
898 + 5 20 "moved task %p into nxi:%p[#%d]"
899 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
900 + "task_get_nx_info(%p)"
901 + 6 40 "nx_clear_persistent(%p[#%d])"
905 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
906 + 1 2 "quota_sync_dqh(%p,%d)"
907 + "sync_dquots(%p,%d)"
908 + "sync_dquots_dqh(%p,%d)"
909 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
913 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
914 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
915 + 4 10 "%s: (%s %s) returned %s with %d"
919 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
920 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
924 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
925 + "alloc_vx_info(%d) = %p"
926 + "alloc_vx_info(%d)*"
927 + "create_vx_info(%d) (dynamic rejected)"
928 + "create_vx_info(%d) = %p (already there)"
929 + "create_vx_info(%d) = %p (new)"
930 + "dealloc_vx_info(%p)"
931 + "loc_vx_info(%d) = %p (found)"
932 + "loc_vx_info(%d) = %p (new)"
933 + "loc_vx_info(%d) = %p (not available)"
934 + 1 2 "create_vx_info(%d)*"
936 + 2 4 "get_vx_info(%p[#%d.%d])"
937 + "put_vx_info(%p[#%d.%d])"
938 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
939 + "clr_vx_info(%p[#%d.%d])"
940 + "init_vx_info(%p[#%d.%d])"
941 + "release_vx_info(%p[#%d.%d.%d]) %p"
942 + "set_vx_info(%p[#%d.%d])"
943 + 4 10 "__hash_vx_info: %p[#%d]"
944 + "__unhash_vx_info: %p[#%d.%d.%d]"
945 + "__vx_dynamic_id: [#%d]"
946 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
947 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
948 + "moved task %p into vxi:%p[#%d]"
949 + "task_get_vx_info(%p)"
950 + "vx_migrate_task(%p,%p[#%d.%d])"
951 + 6 40 "vx_clear_persistent(%p[#%d])"
952 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
953 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
954 + "vx_set_persistent(%p[#%d])"
955 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
956 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
961 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
962 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
964 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
965 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
966 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
967 diff -NurpP --minimal linux-2.6.29/drivers/block/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/Kconfig
968 --- linux-2.6.29/drivers/block/Kconfig 2008-12-25 00:26:37.000000000 +0100
969 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/Kconfig 2009-02-22 22:54:24.000000000 +0100
970 @@ -264,6 +264,13 @@ config BLK_DEV_CRYPTOLOOP
971 instead, which can be configured to be on-disk compatible with the
974 +config BLK_DEV_VROOT
975 + tristate "Virtual Root device support"
976 + depends on QUOTACTL
978 + Saying Y here will allow you to use quota/fs ioctls on a shared
979 + partition within a virtual server without compromising security.
982 tristate "Network block device support"
984 diff -NurpP --minimal linux-2.6.29/drivers/block/loop.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/loop.c
985 --- linux-2.6.29/drivers/block/loop.c 2009-03-24 14:18:56.000000000 +0100
986 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/loop.c 2009-03-24 15:09:29.000000000 +0100
988 #include <linux/gfp.h>
989 #include <linux/kthread.h>
990 #include <linux/splice.h>
991 +#include <linux/vs_context.h>
993 #include <asm/uaccess.h>
995 @@ -809,6 +810,7 @@ static int loop_set_fd(struct loop_devic
996 lo->lo_blocksize = lo_blocksize;
997 lo->lo_device = bdev;
998 lo->lo_flags = lo_flags;
999 + lo->lo_xid = vx_current_xid();
1000 lo->lo_backing_file = file;
1001 lo->transfer = transfer_none;
1003 @@ -931,6 +933,7 @@ static int loop_clr_fd(struct loop_devic
1004 lo->lo_encrypt_key_size = 0;
1006 lo->lo_thread = NULL;
1008 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1009 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1010 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1011 @@ -958,7 +961,7 @@ loop_set_status(struct loop_device *lo,
1013 if (lo->lo_encrypt_key_size &&
1014 lo->lo_key_owner != uid &&
1015 - !capable(CAP_SYS_ADMIN))
1016 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1018 if (lo->lo_state != Lo_bound)
1020 @@ -1042,7 +1045,8 @@ loop_get_status(struct loop_device *lo,
1021 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1022 info->lo_encrypt_type =
1023 lo->lo_encryption ? lo->lo_encryption->number : 0;
1024 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1025 + if (lo->lo_encrypt_key_size &&
1026 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1027 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1028 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1029 lo->lo_encrypt_key_size);
1030 @@ -1351,6 +1355,9 @@ static int lo_open(struct block_device *
1032 struct loop_device *lo = bdev->bd_disk->private_data;
1034 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1037 mutex_lock(&lo->lo_ctl_mutex);
1039 mutex_unlock(&lo->lo_ctl_mutex);
1040 diff -NurpP --minimal linux-2.6.29/drivers/block/Makefile linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/Makefile
1041 --- linux-2.6.29/drivers/block/Makefile 2009-03-24 14:18:55.000000000 +0100
1042 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/Makefile 2009-03-24 14:48:25.000000000 +0100
1043 @@ -31,5 +31,6 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1044 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1045 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1046 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1047 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1049 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1050 diff -NurpP --minimal linux-2.6.29/drivers/block/vroot.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/vroot.c
1051 --- linux-2.6.29/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1052 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/block/vroot.c 2009-02-22 22:54:24.000000000 +0100
1055 + * linux/drivers/block/vroot.c
1057 + * written by Herbert Pötzl, 9/11/2002
1058 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1060 + * based on the loop.c code by Theodore Ts'o.
1062 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1063 + * Redistribution of this file is permitted under the
1064 + * GNU General Public License.
1068 +#include <linux/module.h>
1069 +#include <linux/moduleparam.h>
1070 +#include <linux/file.h>
1071 +#include <linux/major.h>
1072 +#include <linux/blkdev.h>
1074 +#include <linux/vroot.h>
1075 +#include <linux/vs_context.h>
1078 +static int max_vroot = 8;
1080 +static struct vroot_device *vroot_dev;
1081 +static struct gendisk **disks;
1084 +static int vroot_set_dev(
1085 + struct vroot_device *vr,
1086 + struct block_device *bdev,
1089 + struct block_device *real_bdev;
1090 + struct file *file;
1091 + struct inode *inode;
1095 + if (vr->vr_state != Vr_unbound)
1104 + inode = file->f_dentry->d_inode;
1107 + if (S_ISBLK(inode->i_mode)) {
1108 + real_bdev = inode->i_bdev;
1109 + vr->vr_device = real_bdev;
1110 + __iget(real_bdev->bd_inode);
1114 + vxdprintk(VXD_CBIT(misc, 0),
1115 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1116 + vr->vr_number, VXD_DEV(real_bdev));
1118 + vr->vr_state = Vr_bound;
1127 +static int vroot_clr_dev(
1128 + struct vroot_device *vr,
1129 + struct block_device *bdev)
1131 + struct block_device *real_bdev;
1133 + if (vr->vr_state != Vr_bound)
1135 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1138 + real_bdev = vr->vr_device;
1140 + vxdprintk(VXD_CBIT(misc, 0),
1141 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1142 + vr->vr_number, VXD_DEV(real_bdev));
1145 + vr->vr_state = Vr_unbound;
1146 + vr->vr_device = NULL;
1151 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1152 + unsigned int cmd, unsigned long arg)
1154 + struct vroot_device *vr = bdev->bd_disk->private_data;
1157 + down(&vr->vr_ctl_mutex);
1159 + case VROOT_SET_DEV:
1160 + err = vroot_set_dev(vr, bdev, arg);
1162 + case VROOT_CLR_DEV:
1163 + err = vroot_clr_dev(vr, bdev);
1169 + up(&vr->vr_ctl_mutex);
1173 +static int vr_open(struct block_device *bdev, fmode_t mode)
1175 + struct vroot_device *vr = bdev->bd_disk->private_data;
1177 + down(&vr->vr_ctl_mutex);
1179 + up(&vr->vr_ctl_mutex);
1183 +static int vr_release(struct gendisk *disk, fmode_t mode)
1185 + struct vroot_device *vr = disk->private_data;
1187 + down(&vr->vr_ctl_mutex);
1189 + up(&vr->vr_ctl_mutex);
1193 +static struct block_device_operations vr_fops = {
1194 + .owner = THIS_MODULE,
1196 + .release = vr_release,
1197 + .ioctl = vr_ioctl,
1200 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1202 + struct inode *inode = bdev->bd_inode;
1203 + struct vroot_device *vr;
1204 + struct block_device *real_bdev;
1205 + int minor = iminor(inode);
1207 + vr = &vroot_dev[minor];
1208 + real_bdev = vr->vr_device;
1210 + vxdprintk(VXD_CBIT(misc, 0),
1211 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1212 + vr->vr_number, VXD_DEV(real_bdev));
1214 + if (vr->vr_state != Vr_bound)
1215 + return ERR_PTR(-ENXIO);
1217 + __iget(real_bdev->bd_inode);
1222 + * And now the modules code and kernel interface.
1225 +module_param(max_vroot, int, 0);
1227 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1228 +MODULE_LICENSE("GPL");
1229 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1231 +MODULE_AUTHOR ("Herbert Pötzl");
1232 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1235 +int __init vroot_init(void)
1239 + if (max_vroot < 1 || max_vroot > 256) {
1240 + max_vroot = MAX_VROOT_DEFAULT;
1241 + printk(KERN_WARNING "vroot: invalid max_vroot "
1242 + "(must be between 1 and 256), "
1243 + "using default (%d)\n", max_vroot);
1246 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1250 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1253 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1255 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1259 + for (i = 0; i < max_vroot; i++) {
1260 + disks[i] = alloc_disk(1);
1263 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1264 + if (!disks[i]->queue)
1268 + for (i = 0; i < max_vroot; i++) {
1269 + struct vroot_device *vr = &vroot_dev[i];
1270 + struct gendisk *disk = disks[i];
1272 + memset(vr, 0, sizeof(*vr));
1273 + init_MUTEX(&vr->vr_ctl_mutex);
1274 + vr->vr_number = i;
1275 + disk->major = VROOT_MAJOR;
1276 + disk->first_minor = i;
1277 + disk->fops = &vr_fops;
1278 + sprintf(disk->disk_name, "vroot%d", i);
1279 + disk->private_data = vr;
1282 + err = register_vroot_grb(&__vroot_get_real_bdev);
1286 + for (i = 0; i < max_vroot; i++)
1287 + add_disk(disks[i]);
1288 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1293 + put_disk(disks[i]);
1298 + unregister_blkdev(VROOT_MAJOR, "vroot");
1299 + printk(KERN_ERR "vroot: ran out of memory\n");
1303 +void vroot_exit(void)
1307 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1308 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1310 + for (i = 0; i < max_vroot; i++) {
1311 + del_gendisk(disks[i]);
1312 + put_disk(disks[i]);
1314 + unregister_blkdev(VROOT_MAJOR, "vroot");
1320 +module_init(vroot_init);
1321 +module_exit(vroot_exit);
1325 +static int __init max_vroot_setup(char *str)
1327 + max_vroot = simple_strtol(str, NULL, 0);
1331 +__setup("max_vroot=", max_vroot_setup);
1335 diff -NurpP --minimal linux-2.6.29/drivers/char/sysrq.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/char/sysrq.c
1336 --- linux-2.6.29/drivers/char/sysrq.c 2009-03-24 14:18:57.000000000 +0100
1337 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/char/sysrq.c 2009-03-24 15:15:27.000000000 +0100
1339 #include <linux/irq.h>
1340 #include <linux/hrtimer.h>
1341 #include <linux/oom.h>
1342 +#include <linux/vserver/debug.h>
1344 #include <asm/ptrace.h>
1345 #include <asm/irq_regs.h>
1346 @@ -369,6 +370,21 @@ static struct sysrq_key_op sysrq_unrt_op
1347 .enable_mask = SYSRQ_ENABLE_RTNICE,
1351 +#ifdef CONFIG_VSERVER_DEBUG
1352 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1354 + dump_vx_info_inactive((key == 'x')?0:1);
1357 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1358 + .handler = sysrq_handle_vxinfo,
1359 + .help_msg = "conteXt",
1360 + .action_msg = "Show Context Info",
1361 + .enable_mask = SYSRQ_ENABLE_DUMP,
1365 /* Key Operations table and lock */
1366 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1368 @@ -419,7 +435,11 @@ static struct sysrq_key_op *sysrq_key_ta
1370 &sysrq_showstate_blocked_op, /* w */
1371 /* x: May be registered on ppc/powerpc for xmon */
1372 +#ifdef CONFIG_VSERVER_DEBUG
1373 + &sysrq_showvxinfo_op, /* x */
1377 /* y: May be registered on sparc64 for global register dump */
1379 &sysrq_ftrace_dump_op, /* z */
1380 @@ -434,6 +454,8 @@ static int sysrq_key_table_key2index(int
1382 else if ((key >= 'a') && (key <= 'z'))
1383 retval = key + 10 - 'a';
1384 + else if ((key >= 'A') && (key <= 'Z'))
1385 + retval = key + 10 - 'A';
1389 diff -NurpP --minimal linux-2.6.29/drivers/char/tty_io.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/char/tty_io.c
1390 --- linux-2.6.29/drivers/char/tty_io.c 2009-03-24 14:18:57.000000000 +0100
1391 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/char/tty_io.c 2009-03-24 14:48:25.000000000 +0100
1394 #include <linux/kmod.h>
1395 #include <linux/nsproxy.h>
1396 +#include <linux/vs_pid.h>
1398 #undef TTY_DEBUG_HANGUP
1400 @@ -2303,6 +2304,7 @@ static int tiocspgrp(struct tty_struct *
1402 if (get_user(pgrp_nr, p))
1404 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1408 diff -NurpP --minimal linux-2.6.29/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/infiniband/hw/ipath/ipath_user_pages.c
1409 --- linux-2.6.29/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-12-25 00:26:37.000000000 +0100
1410 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/infiniband/hw/ipath/ipath_user_pages.c 2009-02-22 22:54:24.000000000 +0100
1413 #include <linux/mm.h>
1414 #include <linux/device.h>
1415 +#include <linux/vs_memory.h>
1417 #include "ipath_kernel.h"
1419 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
1420 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1423 - if (num_pages > lock_limit) {
1424 + if (num_pages > lock_limit ||
1425 + !vx_vmlocked_avail(current->mm, num_pages)) {
1429 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
1433 - current->mm->locked_vm += num_pages;
1434 + vx_vmlocked_add(current->mm, num_pages);
1438 @@ -177,7 +179,7 @@ void ipath_release_user_pages(struct pag
1440 __ipath_release_user_pages(p, num_pages, 1);
1442 - current->mm->locked_vm -= num_pages;
1443 + vx_vmlocked_sub(current->mm, num_pages);
1445 up_write(¤t->mm->mmap_sem);
1447 @@ -194,7 +196,7 @@ static void user_pages_account(struct wo
1448 container_of(_work, struct ipath_user_pages_work, work);
1450 down_write(&work->mm->mmap_sem);
1451 - work->mm->locked_vm -= work->num_pages;
1452 + vx_vmlocked_sub(work->mm, work->num_pages);
1453 up_write(&work->mm->mmap_sem);
1456 diff -NurpP --minimal linux-2.6.29/drivers/md/dm.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/md/dm.c
1457 --- linux-2.6.29/drivers/md/dm.c 2009-03-24 14:19:05.000000000 +0100
1458 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/md/dm.c 2009-03-24 15:15:57.000000000 +0100
1460 #include <linux/hdreg.h>
1461 #include <linux/blktrace_api.h>
1462 #include <trace/block.h>
1463 +#include <linux/vs_base.h>
1465 #define DM_MSG_PREFIX "core"
1467 @@ -115,6 +116,7 @@ struct mapped_device {
1470 atomic_t open_count;
1473 unsigned long flags;
1475 @@ -295,6 +297,7 @@ static void __exit dm_exit(void)
1476 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1478 struct mapped_device *md;
1481 spin_lock(&_minor_lock);
1483 @@ -303,18 +306,19 @@ static int dm_blk_open(struct block_devi
1486 if (test_bit(DMF_FREEING, &md->flags) ||
1487 - test_bit(DMF_DELETING, &md->flags)) {
1489 + test_bit(DMF_DELETING, &md->flags))
1493 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1498 atomic_inc(&md->open_count);
1502 spin_unlock(&_minor_lock);
1504 - return md ? 0 : -ENXIO;
1508 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1509 @@ -504,6 +508,14 @@ int dm_set_geometry(struct mapped_device
1514 + * Get the xid associated with a dm device
1516 +xid_t dm_get_xid(struct mapped_device *md)
1521 /*-----------------------------------------------------------------
1523 * A more elegant soln is in the works that uses the queue
1524 @@ -1110,6 +1122,7 @@ static struct mapped_device *alloc_dev(i
1525 INIT_LIST_HEAD(&md->uevent_list);
1526 spin_lock_init(&md->uevent_lock);
1528 + md->xid = vx_current_xid();
1529 md->queue = blk_alloc_queue(GFP_KERNEL);
1532 diff -NurpP --minimal linux-2.6.29/drivers/md/dm.h linux-2.6.29-vs2.3.0.36.9-pre3/drivers/md/dm.h
1533 --- linux-2.6.29/drivers/md/dm.h 2009-03-24 14:19:05.000000000 +0100
1534 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/md/dm.h 2009-03-24 14:48:26.000000000 +0100
1535 @@ -54,6 +54,8 @@ int dm_table_any_congested(struct dm_tab
1536 #define dm_target_is_valid(t) ((t)->table)
1537 int dm_table_barrier_ok(struct dm_table *t);
1539 +xid_t dm_get_xid(struct mapped_device *md);
1541 /*-----------------------------------------------------------------
1542 * A registry of target types.
1543 *---------------------------------------------------------------*/
1544 diff -NurpP --minimal linux-2.6.29/drivers/md/dm-ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/md/dm-ioctl.c
1545 --- linux-2.6.29/drivers/md/dm-ioctl.c 2009-03-24 14:19:05.000000000 +0100
1546 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/md/dm-ioctl.c 2009-03-24 14:48:26.000000000 +0100
1548 #include <linux/dm-ioctl.h>
1549 #include <linux/hdreg.h>
1550 #include <linux/compat.h>
1551 +#include <linux/vs_context.h>
1553 #include <asm/uaccess.h>
1555 @@ -101,7 +102,8 @@ static struct hash_cell *__get_name_cell
1556 unsigned int h = hash_str(str);
1558 list_for_each_entry (hc, _name_buckets + h, name_list)
1559 - if (!strcmp(hc->name, str)) {
1560 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1561 + !strcmp(hc->name, str)) {
1565 @@ -115,7 +117,8 @@ static struct hash_cell *__get_uuid_cell
1566 unsigned int h = hash_str(str);
1568 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1569 - if (!strcmp(hc->uuid, str)) {
1570 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1571 + !strcmp(hc->uuid, str)) {
1575 @@ -352,6 +355,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1577 static int remove_all(struct dm_ioctl *param, size_t param_size)
1579 + if (!vx_check(0, VS_ADMIN))
1582 dm_hash_remove_all(1);
1583 param->data_size = 0;
1585 @@ -399,6 +405,8 @@ static int list_devices(struct dm_ioctl
1587 for (i = 0; i < NUM_BUCKETS; i++) {
1588 list_for_each_entry (hc, _name_buckets + i, name_list) {
1589 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1591 needed += sizeof(struct dm_name_list);
1592 needed += strlen(hc->name) + 1;
1593 needed += ALIGN_MASK;
1594 @@ -422,6 +430,8 @@ static int list_devices(struct dm_ioctl
1596 for (i = 0; i < NUM_BUCKETS; i++) {
1597 list_for_each_entry (hc, _name_buckets + i, name_list) {
1598 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1601 old_nl->next = (uint32_t) ((void *) nl -
1603 @@ -612,10 +622,11 @@ static struct hash_cell *__find_device_h
1607 - mdptr = dm_get_mdptr(md);
1608 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1609 + mdptr = dm_get_mdptr(md);
1617 @@ -1405,8 +1416,8 @@ static int ctl_ioctl(uint command, struc
1621 - /* only root can play with this */
1622 - if (!capable(CAP_SYS_ADMIN))
1623 + /* only root and certain contexts can play with this */
1624 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1627 if (_IOC_TYPE(command) != DM_IOCTL)
1628 diff -NurpP --minimal linux-2.6.29/drivers/net/tun.c linux-2.6.29-vs2.3.0.36.9-pre3/drivers/net/tun.c
1629 --- linux-2.6.29/drivers/net/tun.c 2009-03-24 14:19:23.000000000 +0100
1630 +++ linux-2.6.29-vs2.3.0.36.9-pre3/drivers/net/tun.c 2009-03-25 01:51:59.000000000 +0100
1632 #include <linux/crc32.h>
1633 #include <linux/nsproxy.h>
1634 #include <linux/virtio_net.h>
1635 +#include <linux/vs_network.h>
1636 #include <net/net_namespace.h>
1637 #include <net/netns/generic.h>
1639 @@ -93,6 +94,7 @@ struct tun_struct {
1645 wait_queue_head_t read_wait;
1646 struct sk_buff_head readq;
1647 @@ -697,6 +699,7 @@ static void tun_setup(struct net_device
1651 + tun->nid = current->nid;
1653 dev->ethtool_ops = &tun_ethtool_ops;
1654 dev->destructor = free_netdev;
1655 @@ -727,6 +730,9 @@ static int tun_set_iff(struct net *net,
1656 tn = net_generic(net, tun_net_id);
1657 tun = tun_get_by_name(tn, ifr->ifr_name);
1659 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1665 @@ -735,7 +741,7 @@ static int tun_set_iff(struct net *net,
1666 cred->euid != tun->owner) ||
1667 (tun->group != -1 &&
1668 cred->egid != tun->group)) &&
1669 - !capable(CAP_NET_ADMIN)) {
1670 + !cap_raised(current_cap(), CAP_NET_ADMIN)) {
1674 @@ -747,7 +753,7 @@ static int tun_set_iff(struct net *net,
1678 - if (!capable(CAP_NET_ADMIN))
1679 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1683 @@ -987,6 +993,16 @@ static int tun_chr_ioctl(struct inode *i
1684 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1688 + if (!capable(CAP_CONTEXT))
1691 + /* Set nid owner of the device */
1692 + tun->nid = (nid_t) arg;
1694 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1698 /* Only allow setting the type when the interface is down */
1700 diff -NurpP --minimal linux-2.6.29/fs/attr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/attr.c
1701 --- linux-2.6.29/fs/attr.c 2009-03-24 14:22:24.000000000 +0100
1702 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/attr.c 2009-03-24 14:48:34.000000000 +0100
1704 #include <linux/fcntl.h>
1705 #include <linux/quotaops.h>
1706 #include <linux/security.h>
1707 +#include <linux/proc_fs.h>
1708 +#include <linux/devpts_fs.h>
1709 +#include <linux/vs_tag.h>
1711 /* Taken over from the old code... */
1713 @@ -55,6 +58,10 @@ int inode_change_ok(struct inode *inode,
1714 if (!is_owner_or_cap(inode))
1718 + if (dx_permission(inode, MAY_WRITE))
1724 @@ -78,6 +85,8 @@ int inode_setattr(struct inode * inode,
1725 inode->i_uid = attr->ia_uid;
1726 if (ia_valid & ATTR_GID)
1727 inode->i_gid = attr->ia_gid;
1728 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1729 + inode->i_tag = attr->ia_tag;
1730 if (ia_valid & ATTR_ATIME)
1731 inode->i_atime = timespec_trunc(attr->ia_atime,
1732 inode->i_sb->s_time_gran);
1733 @@ -172,7 +181,8 @@ int notify_change(struct dentry * dentry
1734 error = inode_change_ok(inode, attr);
1736 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
1737 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
1738 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
1739 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
1740 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
1742 error = inode_setattr(inode, attr);
1743 diff -NurpP --minimal linux-2.6.29/fs/binfmt_aout.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_aout.c
1744 --- linux-2.6.29/fs/binfmt_aout.c 2009-03-24 14:22:24.000000000 +0100
1745 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_aout.c 2009-03-24 14:48:34.000000000 +0100
1747 #include <linux/binfmts.h>
1748 #include <linux/personality.h>
1749 #include <linux/init.h>
1750 +#include <linux/vs_memory.h>
1752 #include <asm/system.h>
1753 #include <asm/uaccess.h>
1754 diff -NurpP --minimal linux-2.6.29/fs/binfmt_elf.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_elf.c
1755 --- linux-2.6.29/fs/binfmt_elf.c 2009-03-24 14:22:24.000000000 +0100
1756 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_elf.c 2009-03-24 14:48:34.000000000 +0100
1758 #include <linux/random.h>
1759 #include <linux/elf.h>
1760 #include <linux/utsname.h>
1761 +#include <linux/vs_memory.h>
1762 #include <asm/uaccess.h>
1763 #include <asm/param.h>
1764 #include <asm/page.h>
1765 diff -NurpP --minimal linux-2.6.29/fs/binfmt_flat.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_flat.c
1766 --- linux-2.6.29/fs/binfmt_flat.c 2009-03-24 14:22:24.000000000 +0100
1767 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_flat.c 2009-03-24 14:48:34.000000000 +0100
1769 #include <linux/init.h>
1770 #include <linux/flat.h>
1771 #include <linux/syscalls.h>
1772 +#include <linux/vs_memory.h>
1774 #include <asm/byteorder.h>
1775 #include <asm/system.h>
1776 diff -NurpP --minimal linux-2.6.29/fs/binfmt_som.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_som.c
1777 --- linux-2.6.29/fs/binfmt_som.c 2009-03-24 14:22:24.000000000 +0100
1778 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/binfmt_som.c 2009-03-24 14:48:34.000000000 +0100
1780 #include <linux/shm.h>
1781 #include <linux/personality.h>
1782 #include <linux/init.h>
1783 +#include <linux/vs_memory.h>
1785 #include <asm/uaccess.h>
1786 #include <asm/pgtable.h>
1787 diff -NurpP --minimal linux-2.6.29/fs/block_dev.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/block_dev.c
1788 --- linux-2.6.29/fs/block_dev.c 2009-03-24 14:22:24.000000000 +0100
1789 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/block_dev.c 2009-03-24 14:48:34.000000000 +0100
1791 #include <linux/uio.h>
1792 #include <linux/namei.h>
1793 #include <linux/log2.h>
1794 +#include <linux/vs_device.h>
1795 #include <asm/uaccess.h>
1796 #include "internal.h"
1798 @@ -392,6 +393,7 @@ struct block_device *bdget(dev_t dev)
1799 bdev->bd_invalidated = 0;
1800 inode->i_mode = S_IFBLK;
1801 inode->i_rdev = dev;
1802 + inode->i_mdev = dev;
1803 inode->i_bdev = bdev;
1804 inode->i_data.a_ops = &def_blk_aops;
1805 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1806 @@ -428,6 +430,11 @@ EXPORT_SYMBOL(bdput);
1807 static struct block_device *bd_acquire(struct inode *inode)
1809 struct block_device *bdev;
1812 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1814 + inode->i_mdev = mdev;
1816 spin_lock(&bdev_lock);
1817 bdev = inode->i_bdev;
1818 @@ -438,7 +445,7 @@ static struct block_device *bd_acquire(s
1820 spin_unlock(&bdev_lock);
1822 - bdev = bdget(inode->i_rdev);
1823 + bdev = bdget(mdev);
1825 spin_lock(&bdev_lock);
1826 if (!inode->i_bdev) {
1827 diff -NurpP --minimal linux-2.6.29/fs/char_dev.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/char_dev.c
1828 --- linux-2.6.29/fs/char_dev.c 2009-03-24 14:22:25.000000000 +0100
1829 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/char_dev.c 2009-03-24 14:48:35.000000000 +0100
1831 #include <linux/cdev.h>
1832 #include <linux/mutex.h>
1833 #include <linux/backing-dev.h>
1834 +#include <linux/vs_context.h>
1835 +#include <linux/vs_device.h>
1837 #include "internal.h"
1839 @@ -358,14 +360,21 @@ static int chrdev_open(struct inode *ino
1841 struct cdev *new = NULL;
1845 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
1847 + inode->i_mdev = mdev;
1849 spin_lock(&cdev_lock);
1852 struct kobject *kobj;
1855 spin_unlock(&cdev_lock);
1856 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
1858 + kobj = kobj_lookup(cdev_map, mdev, &idx);
1861 new = container_of(kobj, struct cdev, kobj);
1862 diff -NurpP --minimal linux-2.6.29/fs/dcache.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/dcache.c
1863 --- linux-2.6.29/fs/dcache.c 2009-03-24 14:22:25.000000000 +0100
1864 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/dcache.c 2009-03-24 14:48:35.000000000 +0100
1866 #include <linux/seqlock.h>
1867 #include <linux/swap.h>
1868 #include <linux/bootmem.h>
1869 +#include <linux/vs_limit.h>
1870 #include "internal.h"
1872 int sysctl_vfs_cache_pressure __read_mostly = 100;
1873 @@ -229,6 +230,8 @@ repeat:
1877 + vx_dentry_dec(dentry);
1880 * AV: ->d_delete() is _NOT_ allowed to block now.
1882 @@ -320,6 +323,7 @@ static inline struct dentry * __dget_loc
1884 atomic_inc(&dentry->d_count);
1885 dentry_lru_del_init(dentry);
1886 + vx_dentry_inc(dentry);
1890 @@ -918,6 +922,9 @@ struct dentry *d_alloc(struct dentry * p
1891 struct dentry *dentry;
1894 + if (!vx_dentry_avail(1))
1897 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
1900 @@ -963,6 +970,7 @@ struct dentry *d_alloc(struct dentry * p
1902 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
1903 dentry_stat.nr_dentry++;
1904 + vx_dentry_inc(dentry);
1905 spin_unlock(&dcache_lock);
1908 @@ -1418,6 +1426,7 @@ struct dentry * __d_lookup(struct dentry
1911 atomic_inc(&dentry->d_count);
1912 + vx_dentry_inc(dentry);
1914 spin_unlock(&dentry->d_lock);
1916 diff -NurpP --minimal linux-2.6.29/fs/devpts/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/devpts/inode.c
1917 --- linux-2.6.29/fs/devpts/inode.c 2009-03-24 14:22:25.000000000 +0100
1918 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/devpts/inode.c 2009-03-24 15:32:47.000000000 +0100
1920 #include <linux/tty.h>
1921 #include <linux/mutex.h>
1922 #include <linux/idr.h>
1923 +#include <linux/magic.h>
1924 #include <linux/devpts_fs.h>
1925 #include <linux/parser.h>
1926 #include <linux/fsnotify.h>
1927 #include <linux/seq_file.h>
1929 -#define DEVPTS_SUPER_MAGIC 0x1cd1
1930 +#include <linux/vs_base.h>
1932 #define DEVPTS_DEFAULT_MODE 0600
1935 #define DEVPTS_DEFAULT_PTMX_MODE 0000
1936 #define PTMX_MINOR 2
1938 +static int devpts_permission(struct inode *inode, int mask)
1940 + int ret = -EACCES;
1942 + /* devpts is xid tagged */
1943 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
1944 + ret = generic_permission(inode, mask, NULL);
1948 +static struct inode_operations devpts_file_inode_operations = {
1949 + .permission = devpts_permission,
1952 extern int pty_limit; /* Config limit on Unix98 ptys */
1953 static DEFINE_MUTEX(allocated_ptys_lock);
1955 @@ -254,6 +268,25 @@ static int devpts_show_options(struct se
1959 +static int devpts_filter(struct dentry *de)
1961 + /* devpts is xid tagged */
1962 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
1965 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
1967 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
1970 +static struct file_operations devpts_dir_operations = {
1971 + .open = dcache_dir_open,
1972 + .release = dcache_dir_close,
1973 + .llseek = dcache_dir_lseek,
1974 + .read = generic_read_dir,
1975 + .readdir = devpts_readdir,
1978 static const struct super_operations devpts_sops = {
1979 .statfs = simple_statfs,
1980 .remount_fs = devpts_remount,
1981 @@ -293,12 +326,15 @@ devpts_fill_super(struct super_block *s,
1982 inode = new_inode(s);
1987 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
1988 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
1989 inode->i_op = &simple_dir_inode_operations;
1990 - inode->i_fop = &simple_dir_operations;
1991 + inode->i_fop = &devpts_dir_operations;
1993 + /* devpts is xid tagged */
1994 + inode->i_tag = (tag_t)vx_current_xid();
1996 s->s_root = d_alloc_root(inode);
1998 @@ -479,6 +515,7 @@ static int init_pts_mount(struct file_sy
2003 static int devpts_get_sb(struct file_system_type *fs_type,
2004 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
2006 @@ -590,6 +627,9 @@ int devpts_pty_new(struct inode *ptmx_in
2007 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2008 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2009 init_special_inode(inode, S_IFCHR|opts->mode, device);
2010 + /* devpts is xid tagged */
2011 + inode->i_tag = (tag_t)vx_current_xid();
2012 + inode->i_op = &devpts_file_inode_operations;
2013 inode->i_private = tty;
2014 tty->driver_data = inode;
2016 diff -NurpP --minimal linux-2.6.29/fs/exec.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/exec.c
2017 --- linux-2.6.29/fs/exec.c 2009-03-24 14:22:25.000000000 +0100
2018 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/exec.c 2009-03-24 15:34:21.000000000 +0100
2019 @@ -257,7 +257,9 @@ static int __bprm_mm_init(struct linux_b
2023 - mm->stack_vm = mm->total_vm = 1;
2025 + vx_vmpages_inc(mm);
2027 up_write(&mm->mmap_sem);
2028 bprm->p = vma->vm_end - sizeof(void *);
2030 @@ -1450,7 +1452,7 @@ static int format_corename(char *corenam
2031 /* UNIX time of coredump */
2034 - do_gettimeofday(&tv);
2035 + vx_gettimeofday(&tv);
2036 rc = snprintf(out_ptr, out_end - out_ptr,
2038 if (rc > out_end - out_ptr)
2039 diff -NurpP --minimal linux-2.6.29/fs/ext2/balloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/balloc.c
2040 --- linux-2.6.29/fs/ext2/balloc.c 2009-03-24 14:22:25.000000000 +0100
2041 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/balloc.c 2009-03-24 14:48:35.000000000 +0100
2043 #include <linux/sched.h>
2044 #include <linux/buffer_head.h>
2045 #include <linux/capability.h>
2046 +#include <linux/vs_dlimit.h>
2047 +#include <linux/vs_tag.h>
2050 * balloc.c contains the blocks allocation and deallocation routines
2051 @@ -569,6 +571,7 @@ do_more:
2055 + DLIMIT_FREE_BLOCK(inode, freed);
2056 release_blocks(sb, freed);
2057 DQUOT_FREE_BLOCK(inode, freed);
2059 @@ -701,7 +704,6 @@ ext2_try_to_allocate(struct super_block
2061 end = EXT2_BLOCKS_PER_GROUP(sb);
2064 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2067 @@ -1251,6 +1253,11 @@ ext2_fsblk_t ext2_new_blocks(struct inod
2071 + if (DLIMIT_ALLOC_BLOCK(inode, num)) {
2073 + DQUOT_FREE_BLOCK(inode, num);
2078 es = EXT2_SB(sb)->s_es;
2079 @@ -1409,6 +1416,7 @@ allocated:
2083 + DLIMIT_FREE_BLOCK(inode, *count-num);
2084 DQUOT_FREE_BLOCK(inode, *count-num);
2087 @@ -1419,8 +1427,10 @@ out:
2089 * Undo the block allocation
2091 - if (!performed_allocation)
2092 + if (!performed_allocation) {
2093 + DLIMIT_FREE_BLOCK(inode, *count);
2094 DQUOT_FREE_BLOCK(inode, *count);
2099 diff -NurpP --minimal linux-2.6.29/fs/ext2/ext2.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/ext2.h
2100 --- linux-2.6.29/fs/ext2/ext2.h 2008-12-25 00:26:37.000000000 +0100
2101 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/ext2.h 2009-02-22 22:54:25.000000000 +0100
2102 @@ -170,6 +170,7 @@ extern const struct file_operations ext2
2103 extern const struct address_space_operations ext2_aops;
2104 extern const struct address_space_operations ext2_aops_xip;
2105 extern const struct address_space_operations ext2_nobh_aops;
2106 +extern int ext2_sync_flags(struct inode *inode);
2109 extern const struct inode_operations ext2_dir_inode_operations;
2110 diff -NurpP --minimal linux-2.6.29/fs/ext2/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/file.c
2111 --- linux-2.6.29/fs/ext2/file.c 2008-12-25 00:26:37.000000000 +0100
2112 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/file.c 2009-02-22 22:54:25.000000000 +0100
2113 @@ -87,4 +87,5 @@ const struct inode_operations ext2_file_
2114 .setattr = ext2_setattr,
2115 .permission = ext2_permission,
2116 .fiemap = ext2_fiemap,
2117 + .sync_flags = ext2_sync_flags,
2119 diff -NurpP --minimal linux-2.6.29/fs/ext2/ialloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/ialloc.c
2120 --- linux-2.6.29/fs/ext2/ialloc.c 2009-03-24 14:22:25.000000000 +0100
2121 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/ialloc.c 2009-03-24 15:36:12.000000000 +0100
2123 #include <linux/backing-dev.h>
2124 #include <linux/buffer_head.h>
2125 #include <linux/random.h>
2126 +#include <linux/vs_dlimit.h>
2127 +#include <linux/vs_tag.h>
2131 @@ -123,6 +125,7 @@ void ext2_free_inode (struct inode * ino
2132 ext2_xattr_delete_inode(inode);
2133 DQUOT_FREE_INODE(inode);
2135 + DLIMIT_FREE_INODE(inode);
2138 es = EXT2_SB(sb)->s_es;
2139 @@ -454,6 +457,11 @@ struct inode *ext2_new_inode(struct inod
2141 return ERR_PTR(-ENOMEM);
2143 + inode->i_tag = dx_current_fstag(sb);
2144 + if (DLIMIT_ALLOC_INODE(inode)) {
2151 @@ -609,6 +617,7 @@ fail_free_drop:
2155 + DLIMIT_FREE_INODE(inode);
2156 inode->i_flags |= S_NOQUOTA;
2158 unlock_new_inode(inode);
2159 @@ -616,6 +625,8 @@ fail_drop:
2160 return ERR_PTR(err);
2163 + DLIMIT_FREE_INODE(inode);
2165 make_bad_inode(inode);
2167 return ERR_PTR(err);
2168 diff -NurpP --minimal linux-2.6.29/fs/ext2/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/inode.c
2169 --- linux-2.6.29/fs/ext2/inode.c 2009-03-24 14:22:25.000000000 +0100
2170 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/inode.c 2009-03-24 15:41:38.000000000 +0100
2172 #include <linux/mpage.h>
2173 #include <linux/fiemap.h>
2174 #include <linux/namei.h>
2175 +#include <linux/vs_tag.h>
2179 @@ -1018,7 +1019,7 @@ void ext2_truncate(struct inode *inode)
2181 if (ext2_inode_is_fast_symlink(inode))
2183 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2184 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2187 blocksize = inode->i_sb->s_blocksize;
2188 @@ -1156,38 +1157,72 @@ void ext2_set_inode_flags(struct inode *
2190 unsigned int flags = EXT2_I(inode)->i_flags;
2192 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2193 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2194 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2197 + if (flags & EXT2_IMMUTABLE_FL)
2198 + inode->i_flags |= S_IMMUTABLE;
2199 + if (flags & EXT2_IXUNLINK_FL)
2200 + inode->i_flags |= S_IXUNLINK;
2202 if (flags & EXT2_SYNC_FL)
2203 inode->i_flags |= S_SYNC;
2204 if (flags & EXT2_APPEND_FL)
2205 inode->i_flags |= S_APPEND;
2206 - if (flags & EXT2_IMMUTABLE_FL)
2207 - inode->i_flags |= S_IMMUTABLE;
2208 if (flags & EXT2_NOATIME_FL)
2209 inode->i_flags |= S_NOATIME;
2210 if (flags & EXT2_DIRSYNC_FL)
2211 inode->i_flags |= S_DIRSYNC;
2213 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2215 + if (flags & EXT2_BARRIER_FL)
2216 + inode->i_vflags |= V_BARRIER;
2217 + if (flags & EXT2_COW_FL)
2218 + inode->i_vflags |= V_COW;
2221 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2222 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2224 unsigned int flags = ei->vfs_inode.i_flags;
2225 + unsigned int vflags = ei->vfs_inode.i_vflags;
2227 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2228 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2229 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2230 + EXT2_BARRIER_FL | EXT2_COW_FL);
2232 + if (flags & S_IMMUTABLE)
2233 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2234 + if (flags & S_IXUNLINK)
2235 + ei->i_flags |= EXT2_IXUNLINK_FL;
2237 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2238 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2240 ei->i_flags |= EXT2_SYNC_FL;
2241 if (flags & S_APPEND)
2242 ei->i_flags |= EXT2_APPEND_FL;
2243 - if (flags & S_IMMUTABLE)
2244 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2245 if (flags & S_NOATIME)
2246 ei->i_flags |= EXT2_NOATIME_FL;
2247 if (flags & S_DIRSYNC)
2248 ei->i_flags |= EXT2_DIRSYNC_FL;
2250 + if (vflags & V_BARRIER)
2251 + ei->i_flags |= EXT2_BARRIER_FL;
2252 + if (vflags & V_COW)
2253 + ei->i_flags |= EXT2_COW_FL;
2256 +int ext2_sync_flags(struct inode *inode)
2258 + ext2_get_inode_flags(EXT2_I(inode));
2259 + inode->i_ctime = CURRENT_TIME;
2260 + mark_inode_dirty(inode);
2265 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2267 struct ext2_inode_info *ei;
2268 @@ -1195,6 +1230,8 @@ struct inode *ext2_iget (struct super_bl
2269 struct ext2_inode *raw_inode;
2270 struct inode *inode;
2276 inode = iget_locked(sb, ino);
2277 @@ -1217,12 +1254,17 @@ struct inode *ext2_iget (struct super_bl
2280 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2281 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2282 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2283 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2284 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2285 if (!(test_opt (inode->i_sb, NO_UID32))) {
2286 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2287 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2288 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2289 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2291 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2292 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2293 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2294 + le16_to_cpu(raw_inode->i_raw_tag));
2296 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2297 inode->i_size = le32_to_cpu(raw_inode->i_size);
2298 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2299 @@ -1320,8 +1362,8 @@ static int ext2_update_inode(struct inod
2300 struct ext2_inode_info *ei = EXT2_I(inode);
2301 struct super_block *sb = inode->i_sb;
2302 ino_t ino = inode->i_ino;
2303 - uid_t uid = inode->i_uid;
2304 - gid_t gid = inode->i_gid;
2305 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2306 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2307 struct buffer_head * bh;
2308 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2310 @@ -1357,6 +1399,9 @@ static int ext2_update_inode(struct inod
2311 raw_inode->i_uid_high = 0;
2312 raw_inode->i_gid_high = 0;
2314 +#ifdef CONFIG_TAGGING_INTERN
2315 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2317 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2318 raw_inode->i_size = cpu_to_le32(inode->i_size);
2319 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2320 @@ -1443,7 +1488,8 @@ int ext2_setattr(struct dentry *dentry,
2323 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2324 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2325 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2326 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2327 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
2330 diff -NurpP --minimal linux-2.6.29/fs/ext2/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/ioctl.c
2331 --- linux-2.6.29/fs/ext2/ioctl.c 2009-03-24 14:22:25.000000000 +0100
2332 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/ioctl.c 2009-03-24 14:48:35.000000000 +0100
2334 #include <linux/compat.h>
2335 #include <linux/mount.h>
2336 #include <linux/smp_lock.h>
2337 +#include <linux/mount.h>
2338 #include <asm/current.h>
2339 #include <asm/uaccess.h>
2341 @@ -52,6 +53,11 @@ long ext2_ioctl(struct file *filp, unsig
2343 flags = ext2_mask_flags(inode->i_mode, flags);
2345 + if (IS_BARRIER(inode)) {
2346 + vxwprintk_task(1, "messing with the barrier.");
2350 mutex_lock(&inode->i_mutex);
2351 /* Is it quota file? Do not allow user to mess with it */
2352 if (IS_NOQUOTA(inode)) {
2353 @@ -67,7 +73,9 @@ long ext2_ioctl(struct file *filp, unsig
2355 * This test looks nicer. Thanks to Pauline Middelink
2357 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2358 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2359 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2360 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2361 if (!capable(CAP_LINUX_IMMUTABLE)) {
2362 mutex_unlock(&inode->i_mutex);
2364 diff -NurpP --minimal linux-2.6.29/fs/ext2/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/namei.c
2365 --- linux-2.6.29/fs/ext2/namei.c 2009-03-24 14:22:25.000000000 +0100
2366 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/namei.c 2009-03-24 14:48:35.000000000 +0100
2370 #include <linux/pagemap.h>
2371 +#include <linux/vs_tag.h>
2375 @@ -68,6 +69,7 @@ static struct dentry *ext2_lookup(struct
2376 inode = ext2_iget(dir->i_sb, ino);
2378 return ERR_CAST(inode);
2379 + dx_propagate_tag(nd, inode);
2381 return d_splice_alias(inode, dentry);
2383 @@ -388,6 +390,7 @@ const struct inode_operations ext2_dir_i
2385 .setattr = ext2_setattr,
2386 .permission = ext2_permission,
2387 + .sync_flags = ext2_sync_flags,
2390 const struct inode_operations ext2_special_inode_operations = {
2391 @@ -399,4 +402,5 @@ const struct inode_operations ext2_speci
2393 .setattr = ext2_setattr,
2394 .permission = ext2_permission,
2395 + .sync_flags = ext2_sync_flags,
2397 diff -NurpP --minimal linux-2.6.29/fs/ext2/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/super.c
2398 --- linux-2.6.29/fs/ext2/super.c 2009-03-24 14:22:25.000000000 +0100
2399 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/super.c 2009-03-24 14:48:35.000000000 +0100
2400 @@ -391,7 +391,8 @@ enum {
2401 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2402 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2403 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2404 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2405 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2406 + Opt_tag, Opt_notag, Opt_tagid
2409 static const match_table_t tokens = {
2410 @@ -419,6 +420,9 @@ static const match_table_t tokens = {
2412 {Opt_noacl, "noacl"},
2415 + {Opt_notag, "notag"},
2416 + {Opt_tagid, "tagid=%u"},
2417 {Opt_grpquota, "grpquota"},
2418 {Opt_ignore, "noquota"},
2419 {Opt_quota, "quota"},
2420 @@ -489,6 +493,20 @@ static int parse_options (char * options
2422 set_opt (sbi->s_mount_opt, NO_UID32);
2424 +#ifndef CONFIG_TAGGING_NONE
2426 + set_opt (sbi->s_mount_opt, TAGGED);
2429 + clear_opt (sbi->s_mount_opt, TAGGED);
2432 +#ifdef CONFIG_PROPAGATE
2435 + set_opt (sbi->s_mount_opt, TAGGED);
2439 clear_opt (sbi->s_mount_opt, CHECK);
2441 @@ -838,6 +856,8 @@ static int ext2_fill_super(struct super_
2442 if (!parse_options ((char *) data, sbi))
2445 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2446 + sb->s_flags |= MS_TAGGED;
2447 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2448 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2450 @@ -1170,6 +1190,13 @@ static int ext2_remount (struct super_bl
2454 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2455 + !(sb->s_flags & MS_TAGGED)) {
2456 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2461 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2462 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2464 diff -NurpP --minimal linux-2.6.29/fs/ext2/symlink.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/symlink.c
2465 --- linux-2.6.29/fs/ext2/symlink.c 2008-12-25 00:26:37.000000000 +0100
2466 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/symlink.c 2009-02-22 22:54:25.000000000 +0100
2467 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
2468 .listxattr = ext2_listxattr,
2469 .removexattr = generic_removexattr,
2471 + .sync_flags = ext2_sync_flags,
2474 const struct inode_operations ext2_fast_symlink_inode_operations = {
2475 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
2476 .listxattr = ext2_listxattr,
2477 .removexattr = generic_removexattr,
2479 + .sync_flags = ext2_sync_flags,
2481 diff -NurpP --minimal linux-2.6.29/fs/ext2/xattr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/xattr.c
2482 --- linux-2.6.29/fs/ext2/xattr.c 2008-12-25 00:26:37.000000000 +0100
2483 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext2/xattr.c 2009-02-22 22:54:25.000000000 +0100
2485 #include <linux/mbcache.h>
2486 #include <linux/quotaops.h>
2487 #include <linux/rwsem.h>
2488 +#include <linux/vs_dlimit.h>
2492 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
2494 ea_bdebug(new_bh, "reusing block");
2497 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
2500 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
2501 + DLIMIT_FREE_BLOCK(inode, 1);
2502 unlock_buffer(new_bh);
2505 @@ -731,6 +736,7 @@ ext2_xattr_set2(struct inode *inode, str
2506 le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
2508 mb_cache_entry_release(ce);
2509 + DLIMIT_FREE_BLOCK(inode, 1);
2510 DQUOT_FREE_BLOCK(inode, 1);
2511 mark_buffer_dirty(old_bh);
2512 ea_bdebug(old_bh, "refcount now=%d",
2513 @@ -794,6 +800,7 @@ ext2_xattr_delete_inode(struct inode *in
2514 mark_buffer_dirty(bh);
2516 sync_dirty_buffer(bh);
2517 + DLIMIT_FREE_BLOCK(inode, 1);
2518 DQUOT_FREE_BLOCK(inode, 1);
2520 EXT2_I(inode)->i_file_acl = 0;
2521 diff -NurpP --minimal linux-2.6.29/fs/ext3/balloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/balloc.c
2522 --- linux-2.6.29/fs/ext3/balloc.c 2009-03-24 14:22:25.000000000 +0100
2523 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/balloc.c 2009-03-25 00:53:20.000000000 +0100
2525 #include <linux/ext3_jbd.h>
2526 #include <linux/quotaops.h>
2527 #include <linux/buffer_head.h>
2528 +#include <linux/vs_dlimit.h>
2529 +#include <linux/vs_tag.h>
2532 * balloc.c contains the blocks allocation and deallocation routines
2533 @@ -675,8 +677,10 @@ void ext3_free_blocks(handle_t *handle,
2536 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
2537 - if (dquot_freed_blocks)
2538 + if (dquot_freed_blocks) {
2539 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
2540 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
2545 @@ -1415,18 +1419,33 @@ out:
2547 * Check if filesystem has at least 1 free block available for allocation.
2549 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
2550 +static int ext3_has_free_blocks(struct super_block *sb)
2552 - ext3_fsblk_t free_blocks, root_blocks;
2553 + struct ext3_sb_info *sbi = EXT3_SB(sb);
2554 + unsigned long long free_blocks, root_blocks;
2557 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
2558 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
2559 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
2561 + vxdprintk(VXD_CBIT(dlim, 3),
2562 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
2563 + sb, free_blocks, root_blocks);
2565 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
2567 + cond = (free_blocks < root_blocks + 1 &&
2568 + !capable(CAP_SYS_RESOURCE) &&
2569 sbi->s_resuid != current_fsuid() &&
2570 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
2574 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
2576 + vxdprintk(VXD_CBIT(dlim, 3),
2577 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
2578 + sb, free_blocks, root_blocks,
2579 + !capable(CAP_SYS_RESOURCE)?'1':'0',
2580 + sbi->s_resuid, current_fsuid(), cond?0:1);
2582 + return (cond ? 0 : 1);
2586 @@ -1443,7 +1462,7 @@ static int ext3_has_free_blocks(struct e
2588 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
2590 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
2591 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
2594 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
2595 @@ -1506,6 +1525,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2599 + if (DLIMIT_ALLOC_BLOCK(inode, num))
2603 es = EXT3_SB(sb)->s_es;
2604 @@ -1522,7 +1543,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2605 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
2606 my_rsv = &block_i->rsv_window_node;
2608 - if (!ext3_has_free_blocks(sbi)) {
2609 + if (!ext3_has_free_blocks(sb)) {
2613 @@ -1715,12 +1736,16 @@ allocated:
2616 DQUOT_FREE_BLOCK(inode, *count-num);
2617 + DLIMIT_FREE_BLOCK(inode, *count-num);
2624 + if (!performed_allocation)
2625 + DLIMIT_FREE_BLOCK(inode, *count);
2629 ext3_std_error(sb, fatal);
2630 diff -NurpP --minimal linux-2.6.29/fs/ext3/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/file.c
2631 --- linux-2.6.29/fs/ext3/file.c 2008-12-25 00:26:37.000000000 +0100
2632 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/file.c 2009-02-22 22:54:25.000000000 +0100
2633 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
2635 .permission = ext3_permission,
2636 .fiemap = ext3_fiemap,
2637 + .sync_flags = ext3_sync_flags,
2640 diff -NurpP --minimal linux-2.6.29/fs/ext3/ialloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/ialloc.c
2641 --- linux-2.6.29/fs/ext3/ialloc.c 2009-03-24 14:22:25.000000000 +0100
2642 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/ialloc.c 2009-03-24 15:44:06.000000000 +0100
2644 #include <linux/buffer_head.h>
2645 #include <linux/random.h>
2646 #include <linux/bitops.h>
2647 +#include <linux/vs_dlimit.h>
2648 +#include <linux/vs_tag.h>
2650 #include <asm/byteorder.h>
2652 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
2653 ext3_xattr_delete_inode(handle, inode);
2654 DQUOT_FREE_INODE(inode);
2656 + DLIMIT_FREE_INODE(inode);
2658 is_directory = S_ISDIR(inode->i_mode);
2660 @@ -440,6 +443,12 @@ struct inode *ext3_new_inode(handle_t *h
2661 inode = new_inode(sb);
2663 return ERR_PTR(-ENOMEM);
2665 + inode->i_tag = dx_current_fstag(sb);
2666 + if (DLIMIT_ALLOC_INODE(inode)) {
2673 @@ -613,6 +622,8 @@ got:
2675 ext3_std_error(sb, err);
2677 + DLIMIT_FREE_INODE(inode);
2682 @@ -624,6 +635,7 @@ fail_free_drop:
2686 + DLIMIT_FREE_INODE(inode);
2687 inode->i_flags |= S_NOQUOTA;
2689 unlock_new_inode(inode);
2690 diff -NurpP --minimal linux-2.6.29/fs/ext3/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/inode.c
2691 --- linux-2.6.29/fs/ext3/inode.c 2009-03-24 14:22:25.000000000 +0100
2692 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/inode.c 2009-03-24 15:44:29.000000000 +0100
2694 #include <linux/bio.h>
2695 #include <linux/fiemap.h>
2696 #include <linux/namei.h>
2697 +#include <linux/vs_tag.h>
2701 @@ -2288,7 +2289,7 @@ static void ext3_free_branches(handle_t
2703 int ext3_can_truncate(struct inode *inode)
2705 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2706 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2708 if (S_ISREG(inode->i_mode))
2710 @@ -2662,36 +2663,84 @@ void ext3_set_inode_flags(struct inode *
2712 unsigned int flags = EXT3_I(inode)->i_flags;
2714 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2715 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2716 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2718 + if (flags & EXT3_IMMUTABLE_FL)
2719 + inode->i_flags |= S_IMMUTABLE;
2720 + if (flags & EXT3_IXUNLINK_FL)
2721 + inode->i_flags |= S_IXUNLINK;
2723 if (flags & EXT3_SYNC_FL)
2724 inode->i_flags |= S_SYNC;
2725 if (flags & EXT3_APPEND_FL)
2726 inode->i_flags |= S_APPEND;
2727 - if (flags & EXT3_IMMUTABLE_FL)
2728 - inode->i_flags |= S_IMMUTABLE;
2729 if (flags & EXT3_NOATIME_FL)
2730 inode->i_flags |= S_NOATIME;
2731 if (flags & EXT3_DIRSYNC_FL)
2732 inode->i_flags |= S_DIRSYNC;
2734 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2736 + if (flags & EXT3_BARRIER_FL)
2737 + inode->i_vflags |= V_BARRIER;
2738 + if (flags & EXT3_COW_FL)
2739 + inode->i_vflags |= V_COW;
2742 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2743 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2745 unsigned int flags = ei->vfs_inode.i_flags;
2746 + unsigned int vflags = ei->vfs_inode.i_vflags;
2748 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2749 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2750 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2751 + EXT3_BARRIER_FL | EXT3_COW_FL);
2753 + if (flags & S_IMMUTABLE)
2754 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2755 + if (flags & S_IXUNLINK)
2756 + ei->i_flags |= EXT3_IXUNLINK_FL;
2758 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2759 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2761 ei->i_flags |= EXT3_SYNC_FL;
2762 if (flags & S_APPEND)
2763 ei->i_flags |= EXT3_APPEND_FL;
2764 - if (flags & S_IMMUTABLE)
2765 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2766 if (flags & S_NOATIME)
2767 ei->i_flags |= EXT3_NOATIME_FL;
2768 if (flags & S_DIRSYNC)
2769 ei->i_flags |= EXT3_DIRSYNC_FL;
2771 + if (vflags & V_BARRIER)
2772 + ei->i_flags |= EXT3_BARRIER_FL;
2773 + if (vflags & V_COW)
2774 + ei->i_flags |= EXT3_COW_FL;
2777 +int ext3_sync_flags(struct inode *inode)
2779 + struct ext3_iloc iloc;
2783 + handle = ext3_journal_start(inode, 1);
2784 + if (IS_ERR(handle))
2785 + return PTR_ERR(handle);
2786 + if (IS_SYNC(inode))
2787 + handle->h_sync = 1;
2788 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2792 + ext3_get_inode_flags(EXT3_I(inode));
2793 + inode->i_ctime = CURRENT_TIME;
2795 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2797 + ext3_journal_stop(handle);
2801 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2802 @@ -2703,6 +2752,8 @@ struct inode *ext3_iget(struct super_blo
2803 struct inode *inode;
2809 inode = iget_locked(sb, ino);
2811 @@ -2723,12 +2774,17 @@ struct inode *ext3_iget(struct super_blo
2813 raw_inode = ext3_raw_inode(&iloc);
2814 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2815 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2816 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2817 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2818 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2819 if(!(test_opt (inode->i_sb, NO_UID32))) {
2820 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2821 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2822 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2823 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2825 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2826 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2827 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2828 + le16_to_cpu(raw_inode->i_raw_tag));
2830 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2831 inode->i_size = le32_to_cpu(raw_inode->i_size);
2832 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2833 @@ -2859,6 +2915,8 @@ static int ext3_do_update_inode(handle_t
2834 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2835 struct ext3_inode_info *ei = EXT3_I(inode);
2836 struct buffer_head *bh = iloc->bh;
2837 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2838 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2839 int err = 0, rc, block;
2841 /* For fields not not tracking in the in-memory inode,
2842 @@ -2869,29 +2927,32 @@ static int ext3_do_update_inode(handle_t
2843 ext3_get_inode_flags(ei);
2844 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2845 if(!(test_opt(inode->i_sb, NO_UID32))) {
2846 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2847 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2848 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2849 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2851 * Fix up interoperability with old kernels. Otherwise, old inodes get
2852 * re-used with the upper 16 bits of the uid/gid intact
2855 raw_inode->i_uid_high =
2856 - cpu_to_le16(high_16_bits(inode->i_uid));
2857 + cpu_to_le16(high_16_bits(uid));
2858 raw_inode->i_gid_high =
2859 - cpu_to_le16(high_16_bits(inode->i_gid));
2860 + cpu_to_le16(high_16_bits(gid));
2862 raw_inode->i_uid_high = 0;
2863 raw_inode->i_gid_high = 0;
2866 raw_inode->i_uid_low =
2867 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2868 + cpu_to_le16(fs_high2lowuid(uid));
2869 raw_inode->i_gid_low =
2870 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2871 + cpu_to_le16(fs_high2lowgid(gid));
2872 raw_inode->i_uid_high = 0;
2873 raw_inode->i_gid_high = 0;
2875 +#ifdef CONFIG_TAGGING_INTERN
2876 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2878 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2879 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2880 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2881 @@ -3044,7 +3105,8 @@ int ext3_setattr(struct dentry *dentry,
2884 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2885 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2886 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2887 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2890 /* (user+group)*(old+new) structure, inode write (sb,
2891 @@ -3066,6 +3128,8 @@ int ext3_setattr(struct dentry *dentry,
2892 inode->i_uid = attr->ia_uid;
2893 if (attr->ia_valid & ATTR_GID)
2894 inode->i_gid = attr->ia_gid;
2895 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2896 + inode->i_tag = attr->ia_tag;
2897 error = ext3_mark_inode_dirty(handle, inode);
2898 ext3_journal_stop(handle);
2900 diff -NurpP --minimal linux-2.6.29/fs/ext3/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/ioctl.c
2901 --- linux-2.6.29/fs/ext3/ioctl.c 2009-03-24 14:22:25.000000000 +0100
2902 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/ioctl.c 2009-03-24 14:48:35.000000000 +0100
2906 #include <linux/fs.h>
2907 +#include <linux/mount.h>
2908 #include <linux/jbd.h>
2909 #include <linux/capability.h>
2910 #include <linux/ext3_fs.h>
2912 #include <linux/time.h>
2913 #include <linux/compat.h>
2914 #include <linux/smp_lock.h>
2915 +#include <linux/vs_tag.h>
2916 #include <asm/uaccess.h>
2918 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
2919 @@ -55,6 +57,11 @@ int ext3_ioctl (struct inode * inode, st
2921 flags = ext3_mask_flags(inode->i_mode, flags);
2923 + if (IS_BARRIER(inode)) {
2924 + vxwprintk_task(1, "messing with the barrier.");
2928 mutex_lock(&inode->i_mutex);
2929 /* Is it quota file? Do not allow user to mess with it */
2930 if (IS_NOQUOTA(inode)) {
2931 @@ -73,7 +80,9 @@ int ext3_ioctl (struct inode * inode, st
2933 * This test looks nicer. Thanks to Pauline Middelink
2935 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2936 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2937 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2938 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2939 if (!capable(CAP_LINUX_IMMUTABLE)) {
2940 mutex_unlock(&inode->i_mutex);
2942 diff -NurpP --minimal linux-2.6.29/fs/ext3/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/namei.c
2943 --- linux-2.6.29/fs/ext3/namei.c 2009-03-24 14:22:25.000000000 +0100
2944 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/namei.c 2009-03-24 14:48:35.000000000 +0100
2946 #include <linux/quotaops.h>
2947 #include <linux/buffer_head.h>
2948 #include <linux/bio.h>
2949 +#include <linux/vs_tag.h>
2953 @@ -912,6 +913,7 @@ restart:
2955 ll_rw_block(READ_META, 1, &bh);
2957 + dx_propagate_tag(nd, inode);
2959 if ((bh = bh_use[ra_ptr++]) == NULL)
2961 @@ -2433,6 +2435,7 @@ const struct inode_operations ext3_dir_i
2962 .removexattr = generic_removexattr,
2964 .permission = ext3_permission,
2965 + .sync_flags = ext3_sync_flags,
2968 const struct inode_operations ext3_special_inode_operations = {
2969 @@ -2444,4 +2447,5 @@ const struct inode_operations ext3_speci
2970 .removexattr = generic_removexattr,
2972 .permission = ext3_permission,
2973 + .sync_flags = ext3_sync_flags,
2975 diff -NurpP --minimal linux-2.6.29/fs/ext3/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/super.c
2976 --- linux-2.6.29/fs/ext3/super.c 2009-03-24 14:22:25.000000000 +0100
2977 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/super.c 2009-03-24 14:48:35.000000000 +0100
2978 @@ -790,7 +790,7 @@ enum {
2979 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2980 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
2981 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
2983 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
2986 static const match_table_t tokens = {
2987 @@ -843,6 +843,9 @@ static const match_table_t tokens = {
2988 {Opt_usrquota, "usrquota"},
2989 {Opt_barrier, "barrier=%u"},
2990 {Opt_resize, "resize"},
2992 + {Opt_notag, "notag"},
2993 + {Opt_tagid, "tagid=%u"},
2997 @@ -935,6 +938,20 @@ static int parse_options (char *options,
2999 set_opt (sbi->s_mount_opt, NO_UID32);
3001 +#ifndef CONFIG_TAGGING_NONE
3003 + set_opt (sbi->s_mount_opt, TAGGED);
3006 + clear_opt (sbi->s_mount_opt, TAGGED);
3009 +#ifdef CONFIG_PROPAGATE
3012 + set_opt (sbi->s_mount_opt, TAGGED);
3016 clear_opt (sbi->s_mount_opt, CHECK);
3018 @@ -1653,6 +1670,9 @@ static int ext3_fill_super (struct super
3022 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3023 + sb->s_flags |= MS_TAGGED;
3025 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3026 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3028 @@ -2527,6 +2547,13 @@ static int ext3_remount (struct super_bl
3029 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3030 ext3_abort(sb, __func__, "Abort forced by user");
3032 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3033 + !(sb->s_flags & MS_TAGGED)) {
3034 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3039 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3040 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3042 diff -NurpP --minimal linux-2.6.29/fs/ext3/symlink.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/symlink.c
3043 --- linux-2.6.29/fs/ext3/symlink.c 2008-12-25 00:26:37.000000000 +0100
3044 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/symlink.c 2009-02-22 22:54:25.000000000 +0100
3045 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
3046 .listxattr = ext3_listxattr,
3047 .removexattr = generic_removexattr,
3049 + .sync_flags = ext3_sync_flags,
3052 const struct inode_operations ext3_fast_symlink_inode_operations = {
3053 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
3054 .listxattr = ext3_listxattr,
3055 .removexattr = generic_removexattr,
3057 + .sync_flags = ext3_sync_flags,
3059 diff -NurpP --minimal linux-2.6.29/fs/ext3/xattr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/xattr.c
3060 --- linux-2.6.29/fs/ext3/xattr.c 2008-12-25 00:26:37.000000000 +0100
3061 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext3/xattr.c 2009-02-22 22:54:25.000000000 +0100
3063 #include <linux/mbcache.h>
3064 #include <linux/quotaops.h>
3065 #include <linux/rwsem.h>
3066 +#include <linux/vs_dlimit.h>
3070 @@ -498,6 +499,7 @@ ext3_xattr_release_block(handle_t *handl
3071 error = ext3_journal_dirty_metadata(handle, bh);
3074 + DLIMIT_FREE_BLOCK(inode, 1);
3075 DQUOT_FREE_BLOCK(inode, 1);
3076 ea_bdebug(bh, "refcount now=%d; releasing",
3077 le32_to_cpu(BHDR(bh)->h_refcount));
3078 @@ -771,11 +773,14 @@ inserted:
3079 if (new_bh == bs->bh)
3080 ea_bdebug(new_bh, "keeping");
3083 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3085 /* The old block is released after updating
3088 if (DQUOT_ALLOC_BLOCK(inode, 1))
3090 + goto cleanup_dlimit;
3091 error = ext3_journal_get_write_access(handle,
3094 @@ -849,6 +854,8 @@ cleanup:
3097 DQUOT_FREE_BLOCK(inode, 1);
3099 + DLIMIT_FREE_BLOCK(inode, 1);
3103 diff -NurpP --minimal linux-2.6.29/fs/ext4/balloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/balloc.c
3104 --- linux-2.6.29/fs/ext4/balloc.c 2009-03-24 14:22:25.000000000 +0100
3105 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/balloc.c 2009-03-24 14:48:35.000000000 +0100
3107 #include <linux/jbd2.h>
3108 #include <linux/quotaops.h>
3109 #include <linux/buffer_head.h>
3110 +#include <linux/vs_dlimit.h>
3111 +#include <linux/vs_tag.h>
3113 #include "ext4_jbd2.h"
3115 @@ -535,8 +537,10 @@ void ext4_free_blocks(handle_t *handle,
3117 ext4_mb_free_blocks(handle, inode, block, count,
3118 metadata, &dquot_freed_blocks);
3119 - if (dquot_freed_blocks)
3120 + if (dquot_freed_blocks) {
3121 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3122 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3127 diff -NurpP --minimal linux-2.6.29/fs/ext4/ext4.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/ext4.h
3128 --- linux-2.6.29/fs/ext4/ext4.h 2009-03-24 14:22:25.000000000 +0100
3129 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/ext4.h 2009-03-24 15:44:56.000000000 +0100
3130 @@ -243,8 +243,12 @@ struct flex_groups {
3131 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3132 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3133 #define EXT4_EXT_MIGRATE 0x00100000 /* Inode is migrating */
3134 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3135 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3137 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3138 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3140 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3141 #define EXT4_FL_USER_MODIFIABLE 0x000B80FF /* User modifiable flags */
3143 @@ -541,6 +545,7 @@ do { \
3144 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3145 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
3146 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
3147 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
3149 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
3150 #ifndef _LINUX_EXT2_FS_H
3151 @@ -1076,6 +1081,7 @@ struct buffer_head *ext4_bread(handle_t
3152 ext4_lblk_t, int, int *);
3153 int ext4_get_block(struct inode *inode, sector_t iblock,
3154 struct buffer_head *bh_result, int create);
3155 +extern int ext4_sync_flags(struct inode *inode);
3157 extern struct inode *ext4_iget(struct super_block *, unsigned long);
3158 extern int ext4_write_inode(struct inode *, int);
3159 diff -NurpP --minimal linux-2.6.29/fs/ext4/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/file.c
3160 --- linux-2.6.29/fs/ext4/file.c 2009-03-24 14:22:25.000000000 +0100
3161 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/file.c 2009-03-24 14:48:35.000000000 +0100
3162 @@ -171,5 +171,6 @@ const struct inode_operations ext4_file_
3163 .permission = ext4_permission,
3164 .fallocate = ext4_fallocate,
3165 .fiemap = ext4_fiemap,
3166 + .sync_flags = ext4_sync_flags,
3169 diff -NurpP --minimal linux-2.6.29/fs/ext4/ialloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/ialloc.c
3170 --- linux-2.6.29/fs/ext4/ialloc.c 2009-03-24 14:22:25.000000000 +0100
3171 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/ialloc.c 2009-03-24 14:48:35.000000000 +0100
3173 #include <linux/random.h>
3174 #include <linux/bitops.h>
3175 #include <linux/blkdev.h>
3176 +#include <linux/vs_dlimit.h>
3177 +#include <linux/vs_tag.h>
3178 #include <asm/byteorder.h>
3180 #include "ext4_jbd2.h"
3181 @@ -224,6 +226,7 @@ void ext4_free_inode(handle_t *handle, s
3182 ext4_xattr_delete_inode(handle, inode);
3183 DQUOT_FREE_INODE(inode);
3185 + DLIMIT_FREE_INODE(inode);
3187 is_directory = S_ISDIR(inode->i_mode);
3189 @@ -711,6 +714,12 @@ struct inode *ext4_new_inode(handle_t *h
3190 inode = new_inode(sb);
3192 return ERR_PTR(-ENOMEM);
3194 + inode->i_tag = dx_current_fstag(sb);
3195 + if (DLIMIT_ALLOC_INODE(inode)) {
3202 @@ -889,7 +898,8 @@ got:
3203 * newly created directory and file only if -o extent mount option is
3206 - ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
3207 + ei->i_flags = EXT4_I(dir)->i_flags &
3208 + ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL|EXT4_IXUNLINK_FL|EXT4_BARRIER_FL);
3210 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
3211 /* dirsync only applies to directories */
3212 @@ -949,6 +959,8 @@ got:
3214 ext4_std_error(sb, err);
3216 + DLIMIT_FREE_INODE(inode);
3221 @@ -960,6 +972,7 @@ fail_free_drop:
3225 + DLIMIT_FREE_INODE(inode);
3226 inode->i_flags |= S_NOQUOTA;
3228 unlock_new_inode(inode);
3229 diff -NurpP --minimal linux-2.6.29/fs/ext4/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/inode.c
3230 --- linux-2.6.29/fs/ext4/inode.c 2009-03-24 14:22:25.000000000 +0100
3231 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/inode.c 2009-03-24 14:48:35.000000000 +0100
3233 #include <linux/namei.h>
3234 #include <linux/uio.h>
3235 #include <linux/bio.h>
3236 +#include <linux/vs_tag.h>
3237 #include "ext4_jbd2.h"
3240 @@ -3781,7 +3782,7 @@ static void ext4_free_branches(handle_t
3242 int ext4_can_truncate(struct inode *inode)
3244 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3245 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3247 if (S_ISREG(inode->i_mode))
3249 @@ -4134,37 +4135,86 @@ void ext4_set_inode_flags(struct inode *
3251 unsigned int flags = EXT4_I(inode)->i_flags;
3253 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3254 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3255 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3257 + if (flags & EXT4_IMMUTABLE_FL)
3258 + inode->i_flags |= S_IMMUTABLE;
3259 + if (flags & EXT4_IXUNLINK_FL)
3260 + inode->i_flags |= S_IXUNLINK;
3262 if (flags & EXT4_SYNC_FL)
3263 inode->i_flags |= S_SYNC;
3264 if (flags & EXT4_APPEND_FL)
3265 inode->i_flags |= S_APPEND;
3266 - if (flags & EXT4_IMMUTABLE_FL)
3267 - inode->i_flags |= S_IMMUTABLE;
3268 if (flags & EXT4_NOATIME_FL)
3269 inode->i_flags |= S_NOATIME;
3270 if (flags & EXT4_DIRSYNC_FL)
3271 inode->i_flags |= S_DIRSYNC;
3273 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3275 + if (flags & EXT4_BARRIER_FL)
3276 + inode->i_vflags |= V_BARRIER;
3277 + if (flags & EXT4_COW_FL)
3278 + inode->i_vflags |= V_COW;
3281 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3282 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3284 unsigned int flags = ei->vfs_inode.i_flags;
3285 + unsigned int vflags = ei->vfs_inode.i_vflags;
3287 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3288 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3289 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3290 + EXT4_BARRIER_FL | EXT4_COW_FL);
3292 + if (flags & S_IMMUTABLE)
3293 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3294 + if (flags & S_IXUNLINK)
3295 + ei->i_flags |= EXT4_IXUNLINK_FL;
3297 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3298 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3300 ei->i_flags |= EXT4_SYNC_FL;
3301 if (flags & S_APPEND)
3302 ei->i_flags |= EXT4_APPEND_FL;
3303 - if (flags & S_IMMUTABLE)
3304 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3305 if (flags & S_NOATIME)
3306 ei->i_flags |= EXT4_NOATIME_FL;
3307 if (flags & S_DIRSYNC)
3308 ei->i_flags |= EXT4_DIRSYNC_FL;
3310 + if (vflags & V_BARRIER)
3311 + ei->i_flags |= EXT4_BARRIER_FL;
3312 + if (vflags & V_COW)
3313 + ei->i_flags |= EXT4_COW_FL;
3316 +int ext4_sync_flags(struct inode *inode)
3318 + struct ext4_iloc iloc;
3322 + handle = ext4_journal_start(inode, 1);
3323 + if (IS_ERR(handle))
3324 + return PTR_ERR(handle);
3325 + if (IS_SYNC(inode))
3326 + handle->h_sync = 1;
3327 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3331 + ext4_get_inode_flags(EXT4_I(inode));
3332 + inode->i_ctime = CURRENT_TIME;
3334 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3336 + ext4_journal_stop(handle);
3340 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3341 struct ext4_inode_info *ei)
3343 @@ -4197,6 +4247,8 @@ struct inode *ext4_iget(struct super_blo
3344 struct inode *inode;
3350 inode = iget_locked(sb, ino);
3352 @@ -4216,12 +4268,16 @@ struct inode *ext4_iget(struct super_blo
3354 raw_inode = ext4_raw_inode(&iloc);
3355 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3356 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3357 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3358 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3359 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3360 if (!(test_opt(inode->i_sb, NO_UID32))) {
3361 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3362 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3363 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3364 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3366 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3367 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3368 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3369 + le16_to_cpu(raw_inode->i_raw_tag));
3370 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3373 @@ -4387,6 +4443,8 @@ static int ext4_do_update_inode(handle_t
3374 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3375 struct ext4_inode_info *ei = EXT4_I(inode);
3376 struct buffer_head *bh = iloc->bh;
3377 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3378 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3379 int err = 0, rc, block;
3381 /* For fields not not tracking in the in-memory inode,
3382 @@ -4397,29 +4455,32 @@ static int ext4_do_update_inode(handle_t
3383 ext4_get_inode_flags(ei);
3384 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3385 if (!(test_opt(inode->i_sb, NO_UID32))) {
3386 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3387 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3388 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3389 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3391 * Fix up interoperability with old kernels. Otherwise, old inodes get
3392 * re-used with the upper 16 bits of the uid/gid intact
3395 raw_inode->i_uid_high =
3396 - cpu_to_le16(high_16_bits(inode->i_uid));
3397 + cpu_to_le16(high_16_bits(uid));
3398 raw_inode->i_gid_high =
3399 - cpu_to_le16(high_16_bits(inode->i_gid));
3400 + cpu_to_le16(high_16_bits(gid));
3402 raw_inode->i_uid_high = 0;
3403 raw_inode->i_gid_high = 0;
3406 raw_inode->i_uid_low =
3407 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3408 + cpu_to_le16(fs_high2lowuid(uid));
3409 raw_inode->i_gid_low =
3410 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3411 + cpu_to_le16(fs_high2lowgid(gid));
3412 raw_inode->i_uid_high = 0;
3413 raw_inode->i_gid_high = 0;
3415 +#ifdef CONFIG_TAGGING_INTERN
3416 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3418 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3420 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3421 @@ -4601,7 +4662,8 @@ int ext4_setattr(struct dentry *dentry,
3424 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3425 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3426 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3427 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3430 /* (user+group)*(old+new) structure, inode write (sb,
3431 @@ -4623,6 +4685,8 @@ int ext4_setattr(struct dentry *dentry,
3432 inode->i_uid = attr->ia_uid;
3433 if (attr->ia_valid & ATTR_GID)
3434 inode->i_gid = attr->ia_gid;
3435 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3436 + inode->i_tag = attr->ia_tag;
3437 error = ext4_mark_inode_dirty(handle, inode);
3438 ext4_journal_stop(handle);
3440 diff -NurpP --minimal linux-2.6.29/fs/ext4/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/ioctl.c
3441 --- linux-2.6.29/fs/ext4/ioctl.c 2009-03-24 14:22:25.000000000 +0100
3442 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/ioctl.c 2009-03-24 14:48:35.000000000 +0100
3446 #include <linux/fs.h>
3447 +#include <linux/mount.h>
3448 #include <linux/jbd2.h>
3449 #include <linux/capability.h>
3450 #include <linux/time.h>
3451 #include <linux/compat.h>
3452 #include <linux/smp_lock.h>
3453 #include <linux/mount.h>
3454 +#include <linux/vs_tag.h>
3455 #include <asm/uaccess.h>
3456 #include "ext4_jbd2.h"
3458 @@ -51,6 +53,11 @@ long ext4_ioctl(struct file *filp, unsig
3459 if (!S_ISDIR(inode->i_mode))
3460 flags &= ~EXT4_DIRSYNC_FL;
3462 + if (IS_BARRIER(inode)) {
3463 + vxwprintk_task(1, "messing with the barrier.");
3468 mutex_lock(&inode->i_mutex);
3469 /* Is it quota file? Do not allow user to mess with it */
3470 @@ -68,7 +75,9 @@ long ext4_ioctl(struct file *filp, unsig
3472 * This test looks nicer. Thanks to Pauline Middelink
3474 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3475 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3476 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3477 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3478 if (!capable(CAP_LINUX_IMMUTABLE))
3481 diff -NurpP --minimal linux-2.6.29/fs/ext4/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/namei.c
3482 --- linux-2.6.29/fs/ext4/namei.c 2009-03-24 14:22:25.000000000 +0100
3483 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/namei.c 2009-03-24 14:48:35.000000000 +0100
3485 #include <linux/quotaops.h>
3486 #include <linux/buffer_head.h>
3487 #include <linux/bio.h>
3488 +#include <linux/vs_tag.h>
3490 #include "ext4_jbd2.h"
3492 @@ -917,6 +918,7 @@ restart:
3494 ll_rw_block(READ_META, 1, &bh);
3496 + dx_propagate_tag(nd, inode);
3498 if ((bh = bh_use[ra_ptr++]) == NULL)
3500 @@ -2481,6 +2483,7 @@ const struct inode_operations ext4_dir_i
3501 .removexattr = generic_removexattr,
3503 .permission = ext4_permission,
3504 + .sync_flags = ext4_sync_flags,
3507 const struct inode_operations ext4_special_inode_operations = {
3508 @@ -2492,4 +2495,5 @@ const struct inode_operations ext4_speci
3509 .removexattr = generic_removexattr,
3511 .permission = ext4_permission,
3512 + .sync_flags = ext4_sync_flags,
3514 diff -NurpP --minimal linux-2.6.29/fs/ext4/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/super.c
3515 --- linux-2.6.29/fs/ext4/super.c 2009-03-24 14:22:25.000000000 +0100
3516 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/super.c 2009-03-24 15:46:48.000000000 +0100
3517 @@ -1013,7 +1013,8 @@ enum {
3518 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3519 Opt_grpquota, Opt_i_version,
3520 Opt_stripe, Opt_delalloc, Opt_nodelalloc,
3521 - Opt_inode_readahead_blks, Opt_journal_ioprio
3522 + Opt_inode_readahead_blks, Opt_journal_ioprio,
3523 + Opt_tag, Opt_notag, Opt_tagid
3526 static const match_table_t tokens = {
3527 @@ -1073,6 +1074,9 @@ static const match_table_t tokens = {
3528 {Opt_nodelalloc, "nodelalloc"},
3529 {Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
3530 {Opt_journal_ioprio, "journal_ioprio=%u"},
3532 + {Opt_notag, "notag"},
3533 + {Opt_tagid, "tagid=%u"},
3537 @@ -1168,6 +1172,20 @@ static int parse_options(char *options,
3539 set_opt(sbi->s_mount_opt, NO_UID32);
3541 +#ifndef CONFIG_TAGGING_NONE
3543 + set_opt (sbi->s_mount_opt, TAGGED);
3546 + clear_opt (sbi->s_mount_opt, TAGGED);
3549 +#ifdef CONFIG_PROPAGATE
3552 + set_opt (sbi->s_mount_opt, TAGGED);
3556 set_opt(sbi->s_mount_opt, DEBUG);
3558 @@ -2113,6 +2131,9 @@ static int ext4_fill_super(struct super_
3559 &journal_ioprio, NULL, 0))
3562 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3563 + sb->s_flags |= MS_TAGGED;
3565 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3566 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3568 @@ -3160,6 +3181,13 @@ static int ext4_remount(struct super_blo
3569 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
3570 ext4_abort(sb, __func__, "Abort forced by user");
3572 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3573 + !(sb->s_flags & MS_TAGGED)) {
3574 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3579 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3580 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3582 diff -NurpP --minimal linux-2.6.29/fs/ext4/symlink.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/symlink.c
3583 --- linux-2.6.29/fs/ext4/symlink.c 2008-12-25 00:26:37.000000000 +0100
3584 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/symlink.c 2009-02-22 22:54:25.000000000 +0100
3585 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
3586 .listxattr = ext4_listxattr,
3587 .removexattr = generic_removexattr,
3589 + .sync_flags = ext4_sync_flags,
3592 const struct inode_operations ext4_fast_symlink_inode_operations = {
3593 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
3594 .listxattr = ext4_listxattr,
3595 .removexattr = generic_removexattr,
3597 + .sync_flags = ext4_sync_flags,
3599 diff -NurpP --minimal linux-2.6.29/fs/ext4/xattr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/xattr.c
3600 --- linux-2.6.29/fs/ext4/xattr.c 2009-03-24 14:22:25.000000000 +0100
3601 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ext4/xattr.c 2009-03-24 15:47:44.000000000 +0100
3603 #include <linux/mbcache.h>
3604 #include <linux/quotaops.h>
3605 #include <linux/rwsem.h>
3606 +#include <linux/vs_dlimit.h>
3607 #include "ext4_jbd2.h"
3610 @@ -490,6 +491,7 @@ ext4_xattr_release_block(handle_t *handl
3611 error = ext4_handle_dirty_metadata(handle, inode, bh);
3613 ext4_handle_sync(handle);
3614 + DLIMIT_FREE_BLOCK(inode, 1);
3615 DQUOT_FREE_BLOCK(inode, 1);
3616 ea_bdebug(bh, "refcount now=%d; releasing",
3617 le32_to_cpu(BHDR(bh)->h_refcount));
3618 @@ -781,11 +783,14 @@ inserted:
3619 if (new_bh == bs->bh)
3620 ea_bdebug(new_bh, "keeping");
3623 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3625 /* The old block is released after updating
3628 if (DQUOT_ALLOC_BLOCK(inode, 1))
3630 + goto cleanup_dlimit;
3631 error = ext4_journal_get_write_access(handle,
3634 @@ -861,6 +866,8 @@ cleanup:
3637 DQUOT_FREE_BLOCK(inode, 1);
3639 + DLIMIT_FREE_BLOCK(inode, 1);
3643 diff -NurpP --minimal linux-2.6.29/fs/fcntl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/fcntl.c
3644 --- linux-2.6.29/fs/fcntl.c 2009-03-24 14:22:25.000000000 +0100
3645 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/fcntl.c 2009-03-24 14:48:35.000000000 +0100
3647 #include <linux/rcupdate.h>
3648 #include <linux/pid_namespace.h>
3649 #include <linux/smp_lock.h>
3650 +#include <linux/vs_limit.h>
3652 #include <asm/poll.h>
3653 #include <asm/siginfo.h>
3654 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3657 filp_close(tofree, files);
3659 + vx_openfd_inc(newfd); /* fd was unused */
3663 @@ -343,6 +346,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3667 + if (!vx_files_avail(1))
3670 err = security_file_fcntl(filp, cmd, arg);
3672 diff -NurpP --minimal linux-2.6.29/fs/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/file.c
3673 --- linux-2.6.29/fs/file.c 2008-12-25 00:26:37.000000000 +0100
3674 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/file.c 2009-02-22 22:54:25.000000000 +0100
3676 #include <linux/spinlock.h>
3677 #include <linux/rcupdate.h>
3678 #include <linux/workqueue.h>
3679 +#include <linux/vs_limit.h>
3681 struct fdtable_defer {
3683 @@ -367,6 +368,8 @@ struct files_struct *dup_fd(struct files
3684 struct file *f = *old_fds++;
3687 + /* TODO: sum it first for check and performance */
3688 + vx_openfd_inc(open_files - i);
3691 * The fd may be claimed in the fd bitmap but not yet
3692 @@ -475,6 +478,7 @@ repeat:
3694 FD_CLR(fd, fdt->close_on_exec);
3696 + vx_openfd_inc(fd);
3699 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3700 diff -NurpP --minimal linux-2.6.29/fs/file_table.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/file_table.c
3701 --- linux-2.6.29/fs/file_table.c 2009-03-24 14:22:25.000000000 +0100
3702 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/file_table.c 2009-03-24 14:48:35.000000000 +0100
3704 #include <linux/fsnotify.h>
3705 #include <linux/sysctl.h>
3706 #include <linux/percpu_counter.h>
3707 +#include <linux/vs_limit.h>
3708 +#include <linux/vs_context.h>
3710 #include <asm/atomic.h>
3712 @@ -129,6 +131,8 @@ struct file *get_empty_filp(void)
3713 f->f_cred = get_cred(cred);
3714 eventpoll_init_file(f);
3715 /* f->f_version: 0 */
3716 + f->f_xid = vx_current_xid();
3721 @@ -283,6 +287,8 @@ void __fput(struct file *file)
3722 cdev_put(inode->i_cdev);
3723 fops_put(file->f_op);
3724 put_pid(file->f_owner.pid);
3725 + vx_files_dec(file);
3728 if (file->f_mode & FMODE_WRITE)
3729 drop_file_write_access(file);
3730 @@ -350,6 +356,8 @@ void put_filp(struct file *file)
3732 if (atomic_long_dec_and_test(&file->f_count)) {
3733 security_file_free(file);
3734 + vx_files_dec(file);
3739 diff -NurpP --minimal linux-2.6.29/fs/hfsplus/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/hfsplus/ioctl.c
3740 --- linux-2.6.29/fs/hfsplus/ioctl.c 2008-12-25 00:26:37.000000000 +0100
3741 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/hfsplus/ioctl.c 2009-02-22 22:54:25.000000000 +0100
3743 #include <linux/mount.h>
3744 #include <linux/sched.h>
3745 #include <linux/xattr.h>
3746 +#include <linux/mount.h>
3747 #include <asm/uaccess.h>
3748 #include "hfsplus_fs.h"
3750 diff -NurpP --minimal linux-2.6.29/fs/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/inode.c
3751 --- linux-2.6.29/fs/inode.c 2009-03-24 14:22:26.000000000 +0100
3752 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/inode.c 2009-03-25 00:51:55.000000000 +0100
3753 @@ -126,6 +126,9 @@ struct inode *inode_init_always(struct s
3754 struct address_space * const mapping = &inode->i_data;
3758 + /* essential because of inode slab reuse */
3760 inode->i_blkbits = sb->s_blocksize_bits;
3762 atomic_set(&inode->i_count, 1);
3763 @@ -146,6 +149,7 @@ struct inode *inode_init_always(struct s
3764 inode->i_bdev = NULL;
3765 inode->i_cdev = NULL;
3767 + inode->i_mdev = 0;
3768 inode->dirtied_when = 0;
3769 if (security_inode_alloc(inode)) {
3770 if (inode->i_sb->s_op->destroy_inode)
3771 @@ -267,6 +271,8 @@ void __iget(struct inode * inode)
3772 inodes_stat.nr_unused--;
3775 +EXPORT_SYMBOL_GPL(__iget);
3778 * clear_inode - clear an inode
3779 * @inode: inode to clear
3780 @@ -1539,9 +1545,11 @@ void init_special_inode(struct inode *in
3781 if (S_ISCHR(mode)) {
3782 inode->i_fop = &def_chr_fops;
3783 inode->i_rdev = rdev;
3784 + inode->i_mdev = rdev;
3785 } else if (S_ISBLK(mode)) {
3786 inode->i_fop = &def_blk_fops;
3787 inode->i_rdev = rdev;
3788 + inode->i_mdev = rdev;
3789 } else if (S_ISFIFO(mode))
3790 inode->i_fop = &def_fifo_fops;
3791 else if (S_ISSOCK(mode))
3792 diff -NurpP --minimal linux-2.6.29/fs/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ioctl.c
3793 --- linux-2.6.29/fs/ioctl.c 2009-03-24 14:22:26.000000000 +0100
3794 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ioctl.c 2009-03-24 14:48:35.000000000 +0100
3796 #include <linux/uaccess.h>
3797 #include <linux/writeback.h>
3798 #include <linux/buffer_head.h>
3799 +#include <linux/proc_fs.h>
3800 +#include <linux/vserver/inode.h>
3801 +#include <linux/vs_tag.h>
3803 #include <asm/ioctls.h>
3805 diff -NurpP --minimal linux-2.6.29/fs/ioprio.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ioprio.c
3806 --- linux-2.6.29/fs/ioprio.c 2009-03-24 14:22:26.000000000 +0100
3807 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ioprio.c 2009-03-24 14:48:35.000000000 +0100
3809 #include <linux/syscalls.h>
3810 #include <linux/security.h>
3811 #include <linux/pid_namespace.h>
3812 +#include <linux/vs_base.h>
3814 int set_task_ioprio(struct task_struct *task, int ioprio)
3816 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3818 pgrp = find_vpid(who);
3819 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3820 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3822 ret = set_task_ioprio(p, ioprio);
3825 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3827 pgrp = find_vpid(who);
3828 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3829 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3831 tmpio = get_task_ioprio(p);
3834 diff -NurpP --minimal linux-2.6.29/fs/jfs/acl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/acl.c
3835 --- linux-2.6.29/fs/jfs/acl.c 2008-12-25 00:26:37.000000000 +0100
3836 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/acl.c 2009-02-22 22:54:25.000000000 +0100
3837 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
3840 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3841 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3842 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3843 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3844 if (DQUOT_TRANSFER(inode, iattr))
3847 diff -NurpP --minimal linux-2.6.29/fs/jfs/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/file.c
3848 --- linux-2.6.29/fs/jfs/file.c 2008-12-25 00:26:37.000000000 +0100
3849 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/file.c 2009-02-22 22:54:25.000000000 +0100
3850 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
3851 .setattr = jfs_setattr,
3852 .permission = jfs_permission,
3854 + .sync_flags = jfs_sync_flags,
3857 const struct file_operations jfs_file_operations = {
3858 diff -NurpP --minimal linux-2.6.29/fs/jfs/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/inode.c
3859 --- linux-2.6.29/fs/jfs/inode.c 2009-03-24 14:22:26.000000000 +0100
3860 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/inode.c 2009-03-24 14:48:35.000000000 +0100
3862 #include <linux/buffer_head.h>
3863 #include <linux/pagemap.h>
3864 #include <linux/quotaops.h>
3865 +#include <linux/vs_dlimit.h>
3866 #include "jfs_incore.h"
3867 #include "jfs_inode.h"
3868 #include "jfs_filsys.h"
3869 @@ -161,6 +162,7 @@ void jfs_delete_inode(struct inode *inod
3871 DQUOT_FREE_INODE(inode);
3873 + DLIMIT_FREE_INODE(inode);
3877 diff -NurpP --minimal linux-2.6.29/fs/jfs/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/ioctl.c
3878 --- linux-2.6.29/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
3879 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/ioctl.c 2009-02-22 22:54:25.000000000 +0100
3881 #include <linux/mount.h>
3882 #include <linux/time.h>
3883 #include <linux/sched.h>
3884 +#include <linux/mount.h>
3885 #include <asm/current.h>
3886 #include <asm/uaccess.h>
3888 @@ -85,6 +86,11 @@ long jfs_ioctl(struct file *filp, unsign
3889 if (!S_ISDIR(inode->i_mode))
3890 flags &= ~JFS_DIRSYNC_FL;
3892 + if (IS_BARRIER(inode)) {
3893 + vxwprintk_task(1, "messing with the barrier.");
3897 /* Is it quota file? Do not allow user to mess with it */
3898 if (IS_NOQUOTA(inode)) {
3900 @@ -102,8 +108,8 @@ long jfs_ioctl(struct file *filp, unsign
3901 * the relevant capability.
3903 if ((oldflags & JFS_IMMUTABLE_FL) ||
3904 - ((flags ^ oldflags) &
3905 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3906 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3907 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3908 if (!capable(CAP_LINUX_IMMUTABLE)) {
3909 mutex_unlock(&inode->i_mutex);
3911 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_dinode.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_dinode.h
3912 --- linux-2.6.29/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3913 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_dinode.h 2009-02-22 22:54:25.000000000 +0100
3914 @@ -161,9 +161,13 @@ struct dinode {
3916 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3917 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3918 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3920 -#define JFS_FL_USER_VISIBLE 0x03F80000
3921 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3922 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3923 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3925 +#define JFS_FL_USER_VISIBLE 0x07F80000
3926 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3927 #define JFS_FL_INHERIT 0x03C80000
3929 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3930 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_dtree.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_dtree.c
3931 --- linux-2.6.29/fs/jfs/jfs_dtree.c 2008-12-25 00:26:37.000000000 +0100
3932 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_dtree.c 2009-02-22 22:54:25.000000000 +0100
3935 #include <linux/fs.h>
3936 #include <linux/quotaops.h>
3937 +#include <linux/vs_dlimit.h>
3938 #include "jfs_incore.h"
3939 #include "jfs_superblock.h"
3940 #include "jfs_filsys.h"
3941 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
3943 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
3945 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
3946 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
3949 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
3950 + goto clean_up_dquot;
3951 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
3952 + goto clean_up_dlimit;
3955 * Save the table, we're going to overwrite it with the
3956 @@ -480,6 +481,12 @@ static u32 add_index(tid_t tid, struct i
3961 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
3964 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
3968 jfs_ip->next_index--;
3969 @@ -951,6 +958,7 @@ static int dtSplitUp(tid_t tid,
3972 int quota_allocation = 0;
3973 + int dlimit_allocation = 0;
3975 /* get split page */
3977 @@ -1033,6 +1041,12 @@ static int dtSplitUp(tid_t tid,
3979 quota_allocation += n;
3981 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
3985 + dlimit_allocation += n;
3987 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
3990 @@ -1306,6 +1320,9 @@ static int dtSplitUp(tid_t tid,
3994 + /* Rollback dlimit allocation */
3995 + if (rc && dlimit_allocation)
3996 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
3997 /* Rollback quota allocation */
3998 if (rc && quota_allocation)
3999 DQUOT_FREE_BLOCK(ip, quota_allocation);
4000 @@ -1373,6 +1390,12 @@ static int dtSplitPage(tid_t tid, struct
4001 release_metapage(rmp);
4004 + /* Allocate blocks to dlimit. */
4005 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4006 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4007 + release_metapage(rmp);
4011 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
4013 @@ -1920,6 +1943,12 @@ static int dtSplitRoot(tid_t tid,
4014 release_metapage(rmp);
4017 + /* Allocate blocks to dlimit. */
4018 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4019 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4020 + release_metapage(rmp);
4024 BT_MARK_DIRTY(rmp, ip);
4026 @@ -2286,6 +2315,8 @@ static int dtDeleteUp(tid_t tid, struct
4028 xlen = lengthPXD(&fp->header.self);
4030 + /* Free dlimit allocation. */
4031 + DLIMIT_FREE_BLOCK(ip, xlen);
4032 /* Free quota allocation. */
4033 DQUOT_FREE_BLOCK(ip, xlen);
4035 @@ -2362,6 +2393,8 @@ static int dtDeleteUp(tid_t tid, struct
4037 xlen = lengthPXD(&p->header.self);
4039 + /* Free dlimit allocation */
4040 + DLIMIT_FREE_BLOCK(ip, xlen);
4041 /* Free quota allocation */
4042 DQUOT_FREE_BLOCK(ip, xlen);
4044 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_extent.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_extent.c
4045 --- linux-2.6.29/fs/jfs/jfs_extent.c 2008-12-25 00:26:37.000000000 +0100
4046 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_extent.c 2009-02-22 22:54:25.000000000 +0100
4049 #include <linux/fs.h>
4050 #include <linux/quotaops.h>
4051 +#include <linux/vs_dlimit.h>
4052 #include "jfs_incore.h"
4053 #include "jfs_inode.h"
4054 #include "jfs_superblock.h"
4055 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
4059 + /* Allocate blocks to dlimit. */
4060 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4061 + DQUOT_FREE_BLOCK(ip, nxlen);
4062 + dbFree(ip, nxaddr, (s64) nxlen);
4063 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
4067 /* determine the value of the extent flag */
4068 xflag = abnr ? XAD_NOTRECORDED : 0;
4070 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
4073 dbFree(ip, nxaddr, nxlen);
4074 + DLIMIT_FREE_BLOCK(ip, nxlen);
4075 DQUOT_FREE_BLOCK(ip, nxlen);
4076 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4078 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
4079 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4082 + /* Allocate blocks to dlimit. */
4083 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4084 + DQUOT_FREE_BLOCK(ip, nxlen);
4085 + dbFree(ip, nxaddr, (s64) nxlen);
4086 + up(&JFS_IP(ip)->commit_sem);
4090 delta = nxlen - xlen;
4092 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
4093 /* extend the extent */
4094 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
4095 dbFree(ip, xaddr + xlen, delta);
4096 + DLIMIT_FREE_BLOCK(ip, nxlen);
4097 DQUOT_FREE_BLOCK(ip, nxlen);
4100 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
4102 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
4103 dbFree(ip, nxaddr, nxlen);
4104 + DLIMIT_FREE_BLOCK(ip, nxlen);
4105 DQUOT_FREE_BLOCK(ip, nxlen);
4108 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_filsys.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_filsys.h
4109 --- linux-2.6.29/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4110 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_filsys.h 2009-02-22 22:54:25.000000000 +0100
4112 #define JFS_NAME_MAX 255
4113 #define JFS_PATH_MAX BPSIZE
4115 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4118 * file system state (superblock state)
4119 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_imap.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_imap.c
4120 --- linux-2.6.29/fs/jfs/jfs_imap.c 2009-03-24 14:22:26.000000000 +0100
4121 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_imap.c 2009-03-24 14:48:35.000000000 +0100
4123 #include <linux/buffer_head.h>
4124 #include <linux/pagemap.h>
4125 #include <linux/quotaops.h>
4126 +#include <linux/vs_tag.h>
4128 #include "jfs_incore.h"
4129 #include "jfs_inode.h"
4130 @@ -3062,6 +3063,8 @@ static int copy_from_dinode(struct dinod
4132 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4133 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4137 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4138 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4139 @@ -3082,14 +3085,18 @@ static int copy_from_dinode(struct dinod
4141 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4143 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4144 + uid = le32_to_cpu(dip->di_uid);
4145 + gid = le32_to_cpu(dip->di_gid);
4146 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4148 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4150 ip->i_uid = jfs_ip->saved_uid;
4152 ip->i_uid = sbi->uid;
4155 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4156 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4158 ip->i_gid = jfs_ip->saved_gid;
4160 @@ -3154,14 +3161,12 @@ static void copy_to_dinode(struct dinode
4161 dip->di_size = cpu_to_le64(ip->i_size);
4162 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4163 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4164 - if (sbi->uid == -1)
4165 - dip->di_uid = cpu_to_le32(ip->i_uid);
4167 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4168 - if (sbi->gid == -1)
4169 - dip->di_gid = cpu_to_le32(ip->i_gid);
4171 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4173 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4174 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4175 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4176 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4178 jfs_get_inode_flags(jfs_ip);
4180 * mode2 is only needed for storing the higher order bits.
4181 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_inode.c
4182 --- linux-2.6.29/fs/jfs/jfs_inode.c 2009-03-24 14:22:26.000000000 +0100
4183 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_inode.c 2009-03-24 15:58:01.000000000 +0100
4186 #include <linux/fs.h>
4187 #include <linux/quotaops.h>
4188 +#include <linux/vs_dlimit.h>
4189 +#include <linux/vs_tag.h>
4190 #include "jfs_incore.h"
4191 #include "jfs_inode.h"
4192 #include "jfs_filsys.h"
4193 @@ -30,29 +32,46 @@ void jfs_set_inode_flags(struct inode *i
4195 unsigned int flags = JFS_IP(inode)->mode2;
4197 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4198 - S_NOATIME | S_DIRSYNC | S_SYNC);
4199 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4200 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4202 if (flags & JFS_IMMUTABLE_FL)
4203 inode->i_flags |= S_IMMUTABLE;
4204 + if (flags & JFS_IXUNLINK_FL)
4205 + inode->i_flags |= S_IXUNLINK;
4207 + if (flags & JFS_SYNC_FL)
4208 + inode->i_flags |= S_SYNC;
4209 if (flags & JFS_APPEND_FL)
4210 inode->i_flags |= S_APPEND;
4211 if (flags & JFS_NOATIME_FL)
4212 inode->i_flags |= S_NOATIME;
4213 if (flags & JFS_DIRSYNC_FL)
4214 inode->i_flags |= S_DIRSYNC;
4215 - if (flags & JFS_SYNC_FL)
4216 - inode->i_flags |= S_SYNC;
4218 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4220 + if (flags & JFS_BARRIER_FL)
4221 + inode->i_vflags |= V_BARRIER;
4222 + if (flags & JFS_COW_FL)
4223 + inode->i_vflags |= V_COW;
4226 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4228 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4229 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4231 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4232 + JFS_APPEND_FL | JFS_NOATIME_FL |
4233 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4234 + JFS_BARRIER_FL | JFS_COW_FL);
4236 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4237 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4238 if (flags & S_IMMUTABLE)
4239 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4240 + if (flags & S_IXUNLINK)
4241 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4243 if (flags & S_APPEND)
4244 jfs_ip->mode2 |= JFS_APPEND_FL;
4245 if (flags & S_NOATIME)
4246 @@ -61,6 +80,19 @@ void jfs_get_inode_flags(struct jfs_inod
4247 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4249 jfs_ip->mode2 |= JFS_SYNC_FL;
4251 + if (vflags & V_BARRIER)
4252 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4253 + if (vflags & V_COW)
4254 + jfs_ip->mode2 |= JFS_COW_FL;
4257 +int jfs_sync_flags(struct inode *inode)
4259 + jfs_get_inode_flags(JFS_IP(inode));
4260 + inode->i_ctime = CURRENT_TIME;
4261 + mark_inode_dirty(inode);
4266 @@ -113,6 +145,12 @@ struct inode *ialloc(struct inode *paren
4267 jfs_inode->saved_uid = inode->i_uid;
4268 jfs_inode->saved_gid = inode->i_gid;
4270 + inode->i_tag = dx_current_fstag(sb);
4271 + if (DLIMIT_ALLOC_INODE(inode)) {
4277 * Allocate inode to quota.
4279 @@ -162,6 +200,8 @@ struct inode *ialloc(struct inode *paren
4283 + DLIMIT_FREE_INODE(inode);
4286 inode->i_flags |= S_NOQUOTA;
4288 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_inode.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_inode.h
4289 --- linux-2.6.29/fs/jfs/jfs_inode.h 2008-12-25 00:26:37.000000000 +0100
4290 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_inode.h 2009-02-22 22:54:25.000000000 +0100
4291 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4292 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4293 int fh_len, int fh_type);
4294 extern void jfs_set_inode_flags(struct inode *);
4295 +extern int jfs_sync_flags(struct inode *);
4296 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4298 extern const struct address_space_operations jfs_aops;
4299 diff -NurpP --minimal linux-2.6.29/fs/jfs/jfs_xtree.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_xtree.c
4300 --- linux-2.6.29/fs/jfs/jfs_xtree.c 2008-12-25 00:26:37.000000000 +0100
4301 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/jfs_xtree.c 2009-02-22 22:54:25.000000000 +0100
4303 #include <linux/module.h>
4304 #include <linux/quotaops.h>
4305 #include <linux/seq_file.h>
4306 +#include <linux/vs_dlimit.h>
4307 #include "jfs_incore.h"
4308 #include "jfs_filsys.h"
4309 #include "jfs_metapage.h"
4310 @@ -848,7 +849,12 @@ int xtInsert(tid_t tid, /* transaction
4312 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
4314 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
4315 + DQUOT_FREE_BLOCK(ip, xlen);
4318 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
4319 + DLIMIT_FREE_BLOCK(ip, xlen);
4320 DQUOT_FREE_BLOCK(ip, xlen);
4323 @@ -878,6 +884,7 @@ int xtInsert(tid_t tid, /* transaction
4324 /* undo data extent allocation */
4326 dbFree(ip, xaddr, (s64) xlen);
4327 + DLIMIT_FREE_BLOCK(ip, xlen);
4328 DQUOT_FREE_BLOCK(ip, xlen);
4331 @@ -1234,6 +1241,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
4333 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
4334 int quota_allocation = 0;
4335 + int dlimit_allocation = 0;
4338 sp = XT_PAGE(ip, smp);
4339 @@ -1253,6 +1261,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
4341 quota_allocation += lengthPXD(pxd);
4343 + /* Allocate blocks to dlimit. */
4344 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4348 + dlimit_allocation += lengthPXD(pxd);
4351 * allocate the new right page for the split
4353 @@ -1454,6 +1469,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
4357 + /* Rollback dlimit allocation. */
4358 + if (dlimit_allocation)
4359 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4360 /* Rollback quota allocation. */
4361 if (quota_allocation)
4362 DQUOT_FREE_BLOCK(ip, quota_allocation);
4363 @@ -1517,6 +1535,12 @@ xtSplitRoot(tid_t tid,
4364 release_metapage(rmp);
4367 + /* Allocate blocks to dlimit. */
4368 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4369 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4370 + release_metapage(rmp);
4374 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
4376 @@ -3940,6 +3964,8 @@ s64 xtTruncate(tid_t tid, struct inode *
4378 ip->i_size = newsize;
4380 + /* update dlimit allocation to reflect freed blocks */
4381 + DLIMIT_FREE_BLOCK(ip, nfreed);
4382 /* update quota allocation to reflect freed blocks */
4383 DQUOT_FREE_BLOCK(ip, nfreed);
4385 diff -NurpP --minimal linux-2.6.29/fs/jfs/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/namei.c
4386 --- linux-2.6.29/fs/jfs/namei.c 2009-03-24 14:22:26.000000000 +0100
4387 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/namei.c 2009-03-24 14:48:35.000000000 +0100
4389 #include <linux/ctype.h>
4390 #include <linux/quotaops.h>
4391 #include <linux/exportfs.h>
4392 +#include <linux/vs_tag.h>
4393 #include "jfs_incore.h"
4394 #include "jfs_superblock.h"
4395 #include "jfs_inode.h"
4396 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct
4397 return ERR_CAST(ip);
4400 + dx_propagate_tag(nd, ip);
4401 dentry = d_splice_alias(ip, dentry);
4403 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4404 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
4405 .setattr = jfs_setattr,
4406 .permission = jfs_permission,
4408 + .sync_flags = jfs_sync_flags,
4411 const struct file_operations jfs_dir_operations = {
4412 diff -NurpP --minimal linux-2.6.29/fs/jfs/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/super.c
4413 --- linux-2.6.29/fs/jfs/super.c 2009-03-24 14:22:26.000000000 +0100
4414 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/super.c 2009-03-24 14:48:35.000000000 +0100
4415 @@ -196,7 +196,8 @@ static void jfs_put_super(struct super_b
4417 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4418 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4419 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4420 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4421 + Opt_tag, Opt_notag, Opt_tagid
4424 static const match_table_t tokens = {
4425 @@ -206,6 +207,10 @@ static const match_table_t tokens = {
4426 {Opt_resize, "resize=%u"},
4427 {Opt_resize_nosize, "resize"},
4428 {Opt_errors, "errors=%s"},
4430 + {Opt_notag, "notag"},
4431 + {Opt_tagid, "tagid=%u"},
4432 + {Opt_tag, "tagxid"},
4433 {Opt_ignore, "noquota"},
4434 {Opt_ignore, "quota"},
4435 {Opt_usrquota, "usrquota"},
4436 @@ -340,6 +345,20 @@ static int parse_options(char *options,
4440 +#ifndef CONFIG_TAGGING_NONE
4442 + *flag |= JFS_TAGGED;
4445 + *flag &= JFS_TAGGED;
4448 +#ifdef CONFIG_PROPAGATE
4451 + *flag |= JFS_TAGGED;
4455 printk("jfs: Unrecognized mount option \"%s\" "
4456 " or missing value\n", p);
4457 @@ -370,6 +389,13 @@ static int jfs_remount(struct super_bloc
4458 if (!parse_options(data, sb, &newLVSize, &flag)) {
4462 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4463 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4469 if (sb->s_flags & MS_RDONLY) {
4471 @@ -441,6 +467,9 @@ static int jfs_fill_super(struct super_b
4472 #ifdef CONFIG_JFS_POSIX_ACL
4473 sb->s_flags |= MS_POSIXACL;
4475 + /* map mount option tagxid */
4476 + if (sbi->flag & JFS_TAGGED)
4477 + sb->s_flags |= MS_TAGGED;
4480 printk(KERN_ERR "resize option for remount only\n");
4481 diff -NurpP --minimal linux-2.6.29/fs/jfs/xattr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/xattr.c
4482 --- linux-2.6.29/fs/jfs/xattr.c 2008-12-25 00:26:37.000000000 +0100
4483 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/jfs/xattr.c 2009-02-22 22:54:25.000000000 +0100
4485 #include <linux/posix_acl_xattr.h>
4486 #include <linux/quotaops.h>
4487 #include <linux/security.h>
4488 +#include <linux/vs_dlimit.h>
4489 #include "jfs_incore.h"
4490 #include "jfs_superblock.h"
4491 #include "jfs_dmap.h"
4492 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
4493 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
4496 + /* Allocate new blocks to dlimit. */
4497 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
4498 + DQUOT_FREE_BLOCK(ip, nblocks);
4502 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
4504 + /*Rollback dlimit allocation. */
4505 + DLIMIT_FREE_BLOCK(ip, nblocks);
4506 /*Rollback quota allocation. */
4507 DQUOT_FREE_BLOCK(ip, nblocks);
4509 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
4512 /* Rollback quota allocation. */
4513 + DLIMIT_FREE_BLOCK(ip, nblocks);
4514 + /* Rollback quota allocation. */
4515 DQUOT_FREE_BLOCK(ip, nblocks);
4517 dbFree(ip, blkno, nblocks);
4518 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
4521 int quota_allocation = 0;
4522 + int dlimit_allocation = 0;
4524 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
4525 if (ji->ea.flag == 0)
4526 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
4528 quota_allocation = blocks_needed;
4530 + /* Allocate new blocks to dlimit. */
4532 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
4534 + dlimit_allocation = blocks_needed;
4536 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
4539 @@ -600,6 +617,9 @@ static int ea_get(struct inode *inode, s
4543 + /* Rollback dlimit allocation */
4544 + if (dlimit_allocation)
4545 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
4546 /* Rollback quota allocation */
4547 if (quota_allocation)
4548 DQUOT_FREE_BLOCK(inode, quota_allocation);
4549 @@ -676,8 +696,10 @@ static int ea_put(tid_t tid, struct inod
4552 /* If old blocks exist, they must be removed from quota allocation. */
4555 + DLIMIT_FREE_BLOCK(inode, old_blocks);
4556 DQUOT_FREE_BLOCK(inode, old_blocks);
4559 inode->i_ctime = CURRENT_TIME;
4561 diff -NurpP --minimal linux-2.6.29/fs/libfs.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/libfs.c
4562 --- linux-2.6.29/fs/libfs.c 2009-03-24 14:22:26.000000000 +0100
4563 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/libfs.c 2009-03-24 14:48:35.000000000 +0100
4564 @@ -125,7 +125,8 @@ static inline unsigned char dt_type(stru
4565 * both impossible due to the lock on directory.
4568 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4569 +static inline int do_dcache_readdir_filter(struct file *filp,
4570 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4572 struct dentry *dentry = filp->f_path.dentry;
4573 struct dentry *cursor = filp->private_data;
4574 @@ -158,6 +159,8 @@ int dcache_readdir(struct file * filp, v
4575 next = list_entry(p, struct dentry, d_u.d_child);
4576 if (d_unhashed(next) || !next->d_inode)
4578 + if (filter && !filter(next))
4581 spin_unlock(&dcache_lock);
4582 if (filldir(dirent, next->d_name.name,
4583 @@ -176,6 +179,18 @@ int dcache_readdir(struct file * filp, v
4587 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4589 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4592 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4593 + int (*filter)(struct dentry *))
4595 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4599 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4602 @@ -796,6 +811,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4603 EXPORT_SYMBOL(dcache_dir_lseek);
4604 EXPORT_SYMBOL(dcache_dir_open);
4605 EXPORT_SYMBOL(dcache_readdir);
4606 +EXPORT_SYMBOL(dcache_readdir_filter);
4607 EXPORT_SYMBOL(generic_read_dir);
4608 EXPORT_SYMBOL(get_sb_pseudo);
4609 EXPORT_SYMBOL(simple_write_begin);
4610 diff -NurpP --minimal linux-2.6.29/fs/locks.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/locks.c
4611 --- linux-2.6.29/fs/locks.c 2009-03-24 14:22:26.000000000 +0100
4612 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/locks.c 2009-03-24 14:48:35.000000000 +0100
4614 #include <linux/time.h>
4615 #include <linux/rcupdate.h>
4616 #include <linux/pid_namespace.h>
4617 +#include <linux/vs_base.h>
4618 +#include <linux/vs_limit.h>
4620 #include <asm/uaccess.h>
4622 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4623 /* Allocate an empty lock structure. */
4624 static struct file_lock *locks_alloc_lock(void)
4626 + if (!vx_locks_avail(1))
4628 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4631 @@ -173,6 +177,7 @@ static void locks_free_lock(struct file_
4632 BUG_ON(!list_empty(&fl->fl_block));
4633 BUG_ON(!list_empty(&fl->fl_link));
4636 locks_release_private(fl);
4637 kmem_cache_free(filelock_cache, fl);
4639 @@ -193,6 +198,7 @@ void locks_init_lock(struct file_lock *f
4640 fl->fl_start = fl->fl_end = 0;
4642 fl->fl_lmops = NULL;
4646 EXPORT_SYMBOL(locks_init_lock);
4647 @@ -247,6 +253,7 @@ void locks_copy_lock(struct file_lock *n
4648 new->fl_file = fl->fl_file;
4649 new->fl_ops = fl->fl_ops;
4650 new->fl_lmops = fl->fl_lmops;
4651 + new->fl_xid = fl->fl_xid;
4653 locks_copy_private(new, fl);
4655 @@ -285,6 +292,11 @@ static int flock_make_lock(struct file *
4656 fl->fl_flags = FL_FLOCK;
4658 fl->fl_end = OFFSET_MAX;
4660 + vxd_assert(filp->f_xid == vx_current_xid(),
4661 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4662 + fl->fl_xid = filp->f_xid;
4667 @@ -450,6 +462,7 @@ static int lease_init(struct file *filp,
4669 fl->fl_owner = current->files;
4670 fl->fl_pid = current->tgid;
4671 + fl->fl_xid = vx_current_xid();
4674 fl->fl_flags = FL_LEASE;
4675 @@ -469,6 +482,11 @@ static struct file_lock *lease_alloc(str
4677 return ERR_PTR(error);
4679 + fl->fl_xid = vx_current_xid();
4681 + vxd_assert(filp->f_xid == fl->fl_xid,
4682 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4684 error = lease_init(filp, type, fl);
4686 locks_free_lock(fl);
4687 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
4691 + new_fl->fl_xid = -1;
4693 for_each_lock(inode, before) {
4694 struct file_lock *fl = *before;
4695 @@ -789,6 +808,7 @@ find_conflict:
4697 locks_copy_lock(new_fl, request);
4698 locks_insert_lock(before, new_fl);
4699 + vx_locks_inc(new_fl);
4703 @@ -799,7 +819,8 @@ out:
4707 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4708 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4709 + struct file_lock *conflock, xid_t xid)
4711 struct file_lock *fl;
4712 struct file_lock *new_fl = NULL;
4713 @@ -809,6 +830,8 @@ static int __posix_lock_file(struct inod
4714 struct file_lock **before;
4715 int error, added = 0;
4717 + vxd_assert(xid == vx_current_xid(),
4718 + "xid(%d) == current(%d)", xid, vx_current_xid());
4720 * We may need two file_lock structures for this operation,
4721 * so we get them in advance to avoid races.
4722 @@ -819,7 +842,11 @@ static int __posix_lock_file(struct inod
4723 (request->fl_type != F_UNLCK ||
4724 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4725 new_fl = locks_alloc_lock();
4726 + new_fl->fl_xid = xid;
4727 + vx_locks_inc(new_fl);
4728 new_fl2 = locks_alloc_lock();
4729 + new_fl2->fl_xid = xid;
4730 + vx_locks_inc(new_fl2);
4734 @@ -1018,7 +1045,8 @@ static int __posix_lock_file(struct inod
4735 int posix_lock_file(struct file *filp, struct file_lock *fl,
4736 struct file_lock *conflock)
4738 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4739 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4740 + fl, conflock, filp->f_xid);
4742 EXPORT_SYMBOL(posix_lock_file);
4744 @@ -1108,7 +1136,7 @@ int locks_mandatory_area(int read_write,
4745 fl.fl_end = offset + count - 1;
4748 - error = __posix_lock_file(inode, &fl, NULL);
4749 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4750 if (error != FILE_LOCK_DEFERRED)
4752 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4753 @@ -1423,6 +1451,7 @@ int generic_setlease(struct file *filp,
4755 locks_copy_lock(new_fl, lease);
4756 locks_insert_lock(before, new_fl);
4757 + vx_locks_inc(new_fl);
4761 @@ -1778,6 +1807,11 @@ int fcntl_setlk(unsigned int fd, struct
4762 if (file_lock == NULL)
4765 + vxd_assert(filp->f_xid == vx_current_xid(),
4766 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4767 + file_lock->fl_xid = filp->f_xid;
4768 + vx_locks_inc(file_lock);
4771 * This might block, so we do it before checking the inode.
4773 @@ -1896,6 +1930,11 @@ int fcntl_setlk64(unsigned int fd, struc
4774 if (file_lock == NULL)
4777 + vxd_assert(filp->f_xid == vx_current_xid(),
4778 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4779 + file_lock->fl_xid = filp->f_xid;
4780 + vx_locks_inc(file_lock);
4783 * This might block, so we do it before checking the inode.
4785 @@ -2161,8 +2200,11 @@ static int locks_show(struct seq_file *f
4787 lock_get_status(f, fl, (long)f->private, "");
4789 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4790 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4791 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4793 lock_get_status(f, bfl, (long)f->private, " ->");
4798 diff -NurpP --minimal linux-2.6.29/fs/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/namei.c
4799 --- linux-2.6.29/fs/namei.c 2009-03-24 14:22:26.000000000 +0100
4800 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/namei.c 2009-03-25 00:50:11.000000000 +0100
4802 #include <linux/file.h>
4803 #include <linux/fcntl.h>
4804 #include <linux/device_cgroup.h>
4805 +#include <linux/proc_fs.h>
4806 +#include <linux/vserver/inode.h>
4807 +#include <linux/vs_base.h>
4808 +#include <linux/vs_tag.h>
4809 +#include <linux/vs_cowbl.h>
4810 +#include <linux/vs_device.h>
4811 +#include <linux/vs_context.h>
4812 +#include <linux/pid_namespace.h>
4813 #include <asm/uaccess.h>
4815 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
4816 @@ -167,6 +175,77 @@ void putname(const char *name)
4817 EXPORT_SYMBOL(putname);
4820 +static inline int dx_barrier(struct inode *inode)
4822 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4823 + vxwprintk_task(1, "did hit the barrier.");
4829 +static int __dx_permission(struct inode *inode, int mask)
4831 + if (dx_barrier(inode))
4834 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4835 + /* devpts is xid tagged */
4836 + if (S_ISDIR(inode->i_mode) ||
4837 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4840 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4841 + struct proc_dir_entry *de = PDE(inode);
4843 + if (de && !vx_hide_check(0, de->vx_flags))
4846 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4848 + struct task_struct *tsk;
4850 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4851 + vx_flags(VXF_STATE_SETUP, 0))
4854 + pid = PROC_I(inode)->pid;
4858 + tsk = pid_task(pid, PIDTYPE_PID);
4859 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4860 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4861 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4865 + /* FIXME: Should we block some entries here? */
4870 + if (dx_notagcheck(inode->i_sb) ||
4871 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4880 +int dx_permission(struct inode *inode, int mask)
4882 + int ret = __dx_permission(inode, mask);
4883 + if (unlikely(ret)) {
4884 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
4885 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4893 * generic_permission - check for access rights on a Posix-like filesystem
4894 @@ -253,10 +332,14 @@ int inode_permission(struct inode *inode
4896 * Nobody gets write access to an immutable file.
4898 - if (IS_IMMUTABLE(inode))
4899 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4903 + retval = dx_permission(inode, mask);
4907 if (inode->i_op->permission)
4908 retval = inode->i_op->permission(inode, mask);
4910 @@ -432,6 +515,8 @@ static int exec_permission_lite(struct i
4912 umode_t mode = inode->i_mode;
4914 + if (dx_barrier(inode))
4916 if (inode->i_op->permission)
4919 @@ -749,7 +834,8 @@ static __always_inline void follow_dotdo
4920 if (nd->path.dentry == fs->root.dentry &&
4921 nd->path.mnt == fs->root.mnt) {
4922 read_unlock(&fs->lock);
4924 + /* for sane '/' avoid follow_mount() */
4927 read_unlock(&fs->lock);
4928 spin_lock(&dcache_lock);
4929 @@ -786,16 +872,30 @@ static int do_lookup(struct nameidata *n
4931 struct vfsmount *mnt = nd->path.mnt;
4932 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
4933 + struct inode *inode;
4937 if (dentry->d_op && dentry->d_op->d_revalidate)
4938 goto need_revalidate;
4939 + inode = dentry->d_inode;
4943 + if (__dx_permission(inode, MAY_ACCESS))
4948 path->dentry = dentry;
4949 __follow_mount(path);
4952 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s«.",
4953 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
4954 + vxd_path(&nd->path));
4959 dentry = real_lookup(nd->path.dentry, name, nd);
4960 @@ -1364,7 +1464,7 @@ static int may_delete(struct inode *dir,
4963 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4964 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4965 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4968 if (!S_ISDIR(victim->d_inode->i_mode))
4969 @@ -1506,6 +1606,14 @@ int may_open(struct path *path, int acc_
4973 +#ifdef CONFIG_VSERVER_COWBL
4974 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
4975 + if (IS_COW_LINK(inode))
4977 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4978 + mark_inode_dirty(inode);
4981 error = inode_permission(inode, acc_mode);
4984 @@ -1639,6 +1747,11 @@ struct file *do_filp_open(int dfd, const
4986 int flag = open_to_namei_flags(open_flag);
4988 +#ifdef CONFIG_VSERVER_COWBL
4993 acc_mode = MAY_OPEN | ACC_MODE(flag);
4995 /* O_TRUNC implies we need access checks for write permissions */
4996 @@ -1771,6 +1884,25 @@ ok:
4999 error = may_open(&nd.path, acc_mode, flag);
5000 +#ifdef CONFIG_VSERVER_COWBL
5001 + if (error == -EMLINK) {
5002 + struct dentry *dentry;
5003 + dentry = cow_break_link(pathname);
5004 + if (IS_ERR(dentry)) {
5005 + error = PTR_ERR(dentry);
5010 + mnt_drop_write(nd.path.mnt);
5011 + release_open_intent(&nd);
5012 + path_put(&nd.path);
5021 mnt_drop_write(nd.path.mnt);
5022 @@ -1924,9 +2056,17 @@ int vfs_mknod(struct inode *dir, struct
5026 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5027 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5030 + if (!capable(CAP_MKNOD))
5033 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5035 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5038 if (!dir->i_op->mknod)
5041 @@ -2393,7 +2533,7 @@ int vfs_link(struct dentry *old_dentry,
5043 * A link to an append-only or immutable file cannot be created.
5045 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5046 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5048 if (!dir->i_op->link)
5050 @@ -2766,6 +2906,219 @@ int vfs_follow_link(struct nameidata *nd
5051 return __vfs_follow_link(nd, link);
5055 +#ifdef CONFIG_VSERVER_COWBL
5057 +#include <linux/file.h>
5060 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5064 + return do_splice_direct(in, &ppos, out, len, 0);
5067 +struct dentry *cow_break_link(const char *pathname)
5069 + int ret, mode, pathlen, redo = 0;
5070 + struct nameidata old_nd, dir_nd;
5071 + struct path old_path, new_path;
5072 + struct dentry *dir, *res = NULL;
5073 + struct file *old_file;
5074 + struct file *new_file;
5075 + char *to, *path, pad='\251';
5078 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5079 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5084 + /* old_nd will have refs to dentry and mnt */
5085 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5086 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5088 + goto out_free_path;
5090 + old_path = old_nd.path;
5091 + mode = old_path.dentry->d_inode->i_mode;
5093 + to = d_path(&old_path, path, PATH_MAX-2);
5094 + pathlen = strlen(to);
5095 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5096 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5097 + old_path.dentry->d_name.len);
5099 + to[pathlen + 1] = 0;
5101 + to[pathlen] = pad--;
5103 + if (pad <= '\240')
5106 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5107 + /* dir_nd will have refs to dentry and mnt */
5108 + ret = path_lookup(to,
5109 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5110 + vxdprintk(VXD_CBIT(misc, 2),
5111 + "path_lookup(new): %d", ret);
5115 + /* this puppy downs the inode mutex */
5116 + new_path.dentry = lookup_create(&dir_nd, 0);
5117 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5118 + vxdprintk(VXD_CBIT(misc, 2),
5119 + "lookup_create(new): %p", new_path.dentry);
5120 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5121 + path_put(&dir_nd.path);
5124 + vxdprintk(VXD_CBIT(misc, 2),
5125 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5126 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5127 + new_path.dentry->d_name.len);
5128 + dir = dir_nd.path.dentry;
5130 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5131 + vxdprintk(VXD_CBIT(misc, 2),
5132 + "vfs_create(new): %d", ret);
5133 + if (ret == -EEXIST) {
5134 + mutex_unlock(&dir->d_inode->i_mutex);
5135 + dput(new_path.dentry);
5136 + path_put(&dir_nd.path);
5140 + goto out_unlock_new;
5142 + /* drop out early, ret passes ENOENT */
5144 + if ((redo = d_unhashed(old_path.dentry)))
5145 + goto out_unlock_new;
5147 + new_path.mnt = dir_nd.path.mnt;
5148 + dget(old_path.dentry);
5149 + mntget(old_path.mnt);
5150 + /* this one cleans up the dentry/mnt in case of failure */
5151 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5152 + O_RDONLY, current_cred());
5153 + vxdprintk(VXD_CBIT(misc, 2),
5154 + "dentry_open(old): %p", old_file);
5155 + if (!old_file || IS_ERR(old_file)) {
5156 + res = IS_ERR(old_file) ? (void *) old_file : res;
5157 + goto out_unlock_new;
5160 + dget(new_path.dentry);
5161 + mntget(new_path.mnt);
5162 + /* this one cleans up the dentry/mnt in case of failure */
5163 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5164 + O_WRONLY, current_cred());
5165 + vxdprintk(VXD_CBIT(misc, 2),
5166 + "dentry_open(new): %p", new_file);
5168 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5169 + if (!new_file || IS_ERR(new_file))
5170 + goto out_fput_old;
5172 + size = i_size_read(old_file->f_dentry->d_inode);
5173 + ret = do_cow_splice(old_file, new_file, size);
5174 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5176 + goto out_fput_both;
5177 + } else if (ret < size) {
5179 + goto out_fput_both;
5181 + struct inode *old_inode = old_path.dentry->d_inode;
5182 + struct inode *new_inode = new_path.dentry->d_inode;
5183 + struct iattr attr = {
5184 + .ia_uid = old_inode->i_uid,
5185 + .ia_gid = old_inode->i_gid,
5186 + .ia_valid = ATTR_UID | ATTR_GID
5189 + ret = inode_setattr(new_inode, &attr);
5191 + goto out_fput_both;
5194 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5196 + /* drop out late */
5198 + if ((redo = d_unhashed(old_path.dentry)))
5201 + vxdprintk(VXD_CBIT(misc, 2),
5202 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5203 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5204 + new_path.dentry->d_name.len,
5205 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5206 + old_path.dentry->d_name.len);
5207 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5208 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5209 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5210 + res = new_path.dentry;
5213 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5216 + vxdprintk(VXD_CBIT(misc, 3),
5217 + "fput(new_file=%p[#%ld])", new_file,
5218 + atomic_read(&new_file->f_count));
5222 + vxdprintk(VXD_CBIT(misc, 3),
5223 + "fput(old_file=%p[#%ld])", old_file,
5224 + atomic_read(&old_file->f_count));
5228 + mutex_unlock(&dir->d_inode->i_mutex);
5232 + /* error path cleanup */
5233 + vfs_unlink(dir->d_inode, new_path.dentry);
5234 + dput(new_path.dentry);
5238 + goto out_rel_both;
5239 + /* lookup dentry once again */
5240 + path_put(&old_nd.path);
5241 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5243 + goto out_rel_both;
5245 + new_path.dentry = old_nd.path.dentry;
5246 + vxdprintk(VXD_CBIT(misc, 2),
5247 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5248 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5249 + new_path.dentry->d_name.len);
5250 + dget(new_path.dentry);
5251 + res = new_path.dentry;
5254 + path_put(&dir_nd.path);
5256 + path_put(&old_nd.path);
5261 + res = ERR_PTR(ret);
5267 /* get the link contents into pagecache */
5268 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5270 diff -NurpP --minimal linux-2.6.29/fs/namespace.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/namespace.c
5271 --- linux-2.6.29/fs/namespace.c 2009-03-24 14:22:26.000000000 +0100
5272 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/namespace.c 2009-03-24 14:48:35.000000000 +0100
5274 #include <linux/ramfs.h>
5275 #include <linux/log2.h>
5276 #include <linux/idr.h>
5277 +#include <linux/vs_base.h>
5278 +#include <linux/vs_context.h>
5279 +#include <linux/vs_tag.h>
5280 +#include <linux/vserver/space.h>
5281 +#include <linux/vserver/global.h>
5282 #include <asm/uaccess.h>
5283 #include <asm/unistd.h>
5285 @@ -573,6 +578,7 @@ static struct vfsmount *clone_mnt(struct
5286 mnt->mnt_root = dget(root);
5287 mnt->mnt_mountpoint = mnt->mnt_root;
5288 mnt->mnt_parent = mnt;
5289 + mnt->mnt_tag = old->mnt_tag;
5291 if (flag & CL_SLAVE) {
5292 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5293 @@ -687,6 +693,31 @@ static inline void mangle(struct seq_fil
5294 seq_escape(m, s, " \t\n\\");
5297 +static int mnt_is_reachable(struct vfsmount *mnt)
5300 + struct dentry *point;
5303 + if (mnt == mnt->mnt_ns->root)
5306 + spin_lock(&vfsmount_lock);
5307 + root = current->fs->root;
5308 + point = root.dentry;
5310 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5311 + point = mnt->mnt_mountpoint;
5312 + mnt = mnt->mnt_parent;
5315 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5317 + spin_unlock(&vfsmount_lock);
5323 * Simple .show_options callback for filesystems which don't want to
5324 * implement more complex mount option showing.
5325 @@ -759,6 +790,8 @@ static int show_sb_opts(struct seq_file
5326 { MS_SYNCHRONOUS, ",sync" },
5327 { MS_DIRSYNC, ",dirsync" },
5328 { MS_MANDLOCK, ",mand" },
5329 + { MS_TAGGED, ",tag" },
5330 + { MS_NOTAGCHECK, ",notagcheck" },
5333 const struct proc_fs_info *fs_infop;
5334 @@ -805,10 +838,20 @@ static int show_vfsmnt(struct seq_file *
5336 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5338 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5340 - seq_path(m, &mnt_path, " \t\n\\");
5342 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5344 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5347 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5348 + mnt == current->fs->root.mnt) {
5349 + seq_puts(m, "/dev/root / ");
5351 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5353 + seq_path(m, &mnt_path, " \t\n\\");
5356 show_type(m, mnt->mnt_sb);
5357 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5358 err = show_sb_opts(m, mnt->mnt_sb);
5359 @@ -838,6 +881,11 @@ static int show_mountinfo(struct seq_fil
5360 struct path root = p->root;
5363 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5365 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5368 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5369 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5370 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5371 @@ -896,17 +944,27 @@ static int show_vfsstat(struct seq_file
5372 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5376 - if (mnt->mnt_devname) {
5377 - seq_puts(m, "device ");
5378 - mangle(m, mnt->mnt_devname);
5380 - seq_puts(m, "no device");
5381 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5383 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5387 - seq_puts(m, " mounted on ");
5388 - seq_path(m, &mnt_path, " \t\n\\");
5390 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5391 + mnt == current->fs->root.mnt) {
5392 + seq_puts(m, "device /dev/root mounted on / ");
5395 + if (mnt->mnt_devname) {
5396 + seq_puts(m, "device ");
5397 + mangle(m, mnt->mnt_devname);
5399 + seq_puts(m, "no device");
5402 + seq_puts(m, " mounted on ");
5403 + seq_path(m, &mnt_path, " \t\n\\");
5407 /* file system type */
5408 seq_puts(m, "with fstype ");
5409 @@ -1145,7 +1203,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5413 - if (!capable(CAP_SYS_ADMIN))
5414 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5417 retval = do_umount(path.mnt, flags);
5418 @@ -1171,7 +1229,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5420 static int mount_is_safe(struct path *path)
5422 - if (capable(CAP_SYS_ADMIN))
5423 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5427 @@ -1462,11 +1520,13 @@ static int do_change_type(struct path *p
5428 * do loopback mount.
5430 static int do_loopback(struct path *path, char *old_name,
5432 + tag_t tag, unsigned long flags, int mnt_flags)
5434 struct path old_path;
5435 struct vfsmount *mnt = NULL;
5436 int err = mount_is_safe(path);
5437 + int recurse = flags & MS_REC;
5441 if (!old_name || !*old_name)
5442 @@ -1500,6 +1560,7 @@ static int do_loopback(struct path *path
5443 spin_unlock(&vfsmount_lock);
5444 release_mounts(&umount_list);
5446 + mnt->mnt_flags = mnt_flags;
5449 up_write(&namespace_sem);
5450 @@ -1530,12 +1591,12 @@ static int change_mount_flags(struct vfs
5451 * on it - tough luck.
5453 static int do_remount(struct path *path, int flags, int mnt_flags,
5455 + void *data, xid_t xid)
5458 struct super_block *sb = path->mnt->mnt_sb;
5460 - if (!capable(CAP_SYS_ADMIN))
5461 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5464 if (!check_mnt(path->mnt))
5465 @@ -1577,7 +1638,7 @@ static int do_move_mount(struct path *pa
5466 struct path old_path, parent_path;
5469 - if (!capable(CAP_SYS_ADMIN))
5470 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5472 if (!old_name || !*old_name)
5474 @@ -1659,7 +1720,7 @@ static int do_new_mount(struct path *pat
5477 /* we need capabilities... */
5478 - if (!capable(CAP_SYS_ADMIN))
5479 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5482 mnt = do_kern_mount(type, flags, name, data);
5483 @@ -1904,6 +1965,7 @@ long do_mount(char *dev_name, char *dir_
5490 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5491 @@ -1919,6 +1981,12 @@ long do_mount(char *dev_name, char *dir_
5493 ((char *)data_page)[PAGE_SIZE - 1] = 0;
5495 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5496 + /* FIXME: bind and re-mounts get the tag flag? */
5497 + if (flags & (MS_BIND|MS_REMOUNT))
5498 + flags |= MS_TAGID;
5501 /* Separate the per-mountpoint flags */
5502 if (flags & MS_NOSUID)
5503 mnt_flags |= MNT_NOSUID;
5504 @@ -1935,6 +2003,8 @@ long do_mount(char *dev_name, char *dir_
5505 if (flags & MS_RDONLY)
5506 mnt_flags |= MNT_READONLY;
5508 + if (!capable(CAP_SYS_ADMIN))
5509 + mnt_flags |= MNT_NODEV;
5510 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5511 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
5513 @@ -1950,9 +2020,9 @@ long do_mount(char *dev_name, char *dir_
5515 if (flags & MS_REMOUNT)
5516 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5519 else if (flags & MS_BIND)
5520 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5521 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5522 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5523 retval = do_change_type(&path, flags);
5524 else if (flags & MS_MOVE)
5525 @@ -2021,6 +2091,7 @@ static struct mnt_namespace *dup_mnt_ns(
5526 q = next_mnt(q, new_ns->root);
5528 up_write(&namespace_sem);
5529 + atomic_inc(&vs_global_mnt_ns);
5533 @@ -2348,5 +2419,6 @@ void __put_mnt_ns(struct mnt_namespace *
5534 spin_unlock(&vfsmount_lock);
5535 up_write(&namespace_sem);
5536 release_mounts(&umount_list);
5537 + atomic_dec(&vs_global_mnt_ns);
5540 diff -NurpP --minimal linux-2.6.29/fs/nfs/client.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/client.c
5541 --- linux-2.6.29/fs/nfs/client.c 2009-03-24 14:22:26.000000000 +0100
5542 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/client.c 2009-03-24 14:48:35.000000000 +0100
5543 @@ -696,6 +696,9 @@ static int nfs_init_server_rpcclient(str
5544 if (server->flags & NFS_MOUNT_SOFT)
5545 server->client->cl_softrtry = 1;
5547 + server->client->cl_tag = 0;
5548 + if (server->flags & NFS_MOUNT_TAGGED)
5549 + server->client->cl_tag = 1;
5553 @@ -862,6 +865,10 @@ static void nfs_server_set_fsinfo(struct
5554 server->acdirmin = server->acdirmax = 0;
5557 + /* FIXME: needs fsinfo
5558 + if (server->flags & NFS_MOUNT_TAGGED)
5559 + sb->s_flags |= MS_TAGGED; */
5561 server->maxfilesize = fsinfo->maxfilesize;
5563 /* We're airborne Set socket buffersize */
5564 diff -NurpP --minimal linux-2.6.29/fs/nfs/dir.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/dir.c
5565 --- linux-2.6.29/fs/nfs/dir.c 2009-03-24 14:22:26.000000000 +0100
5566 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/dir.c 2009-03-24 14:48:35.000000000 +0100
5568 #include <linux/namei.h>
5569 #include <linux/mount.h>
5570 #include <linux/sched.h>
5571 +#include <linux/vs_tag.h>
5573 #include "nfs4_fs.h"
5574 #include "delegation.h"
5575 @@ -950,6 +951,7 @@ static struct dentry *nfs_lookup(struct
5577 goto out_unblock_sillyrename;
5579 + dx_propagate_tag(nd, inode);
5581 res = d_materialise_unique(dentry, inode);
5583 diff -NurpP --minimal linux-2.6.29/fs/nfs/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/inode.c
5584 --- linux-2.6.29/fs/nfs/inode.c 2009-03-24 14:22:26.000000000 +0100
5585 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/inode.c 2009-03-24 14:48:35.000000000 +0100
5587 #include <linux/vfs.h>
5588 #include <linux/inet.h>
5589 #include <linux/nfs_xdr.h>
5590 +#include <linux/vs_tag.h>
5592 #include <asm/system.h>
5593 #include <asm/uaccess.h>
5594 @@ -313,8 +314,10 @@ nfs_fhget(struct super_block *sb, struct
5595 nfsi->change_attr = fattr->change_attr;
5596 inode->i_size = nfs_size_to_loff_t(fattr->size);
5597 inode->i_nlink = fattr->nlink;
5598 - inode->i_uid = fattr->uid;
5599 - inode->i_gid = fattr->gid;
5600 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5601 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5602 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5603 + /* maybe fattr->xid someday */
5604 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5606 * report the blocks in 512byte units
5607 @@ -462,6 +465,8 @@ void nfs_setattr_update_inode(struct ino
5608 inode->i_uid = attr->ia_uid;
5609 if ((attr->ia_valid & ATTR_GID) != 0)
5610 inode->i_gid = attr->ia_gid;
5611 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5612 + inode->i_tag = attr->ia_tag;
5613 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5614 spin_unlock(&inode->i_lock);
5616 @@ -850,6 +855,9 @@ static int nfs_check_inode_attributes(st
5617 struct nfs_inode *nfsi = NFS_I(inode);
5618 loff_t cur_size, new_isize;
5619 unsigned long invalid = 0;
5625 /* Has the inode gone and changed behind our back? */
5626 @@ -871,10 +879,15 @@ static int nfs_check_inode_attributes(st
5627 if (cur_size != new_isize && nfsi->npages == 0)
5628 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5630 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5631 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5632 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5634 /* Have any file permissions changed? */
5635 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
5636 - || inode->i_uid != fattr->uid
5637 - || inode->i_gid != fattr->gid)
5638 + || inode->i_uid != uid
5639 + || inode->i_gid != gid
5640 + || inode->i_tag != tag)
5641 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5643 /* Has the link count changed? */
5644 @@ -1073,6 +1086,9 @@ static int nfs_update_inode(struct inode
5645 loff_t cur_isize, new_isize;
5646 unsigned long invalid = 0;
5647 unsigned long now = jiffies;
5652 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5653 __func__, inode->i_sb->s_id, inode->i_ino,
5654 @@ -1146,9 +1162,14 @@ static int nfs_update_inode(struct inode
5655 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5656 nfsi->change_attr = fattr->change_attr;
5658 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5659 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5660 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5662 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
5663 - inode->i_uid != fattr->uid ||
5664 - inode->i_gid != fattr->gid)
5665 + inode->i_uid != uid ||
5666 + inode->i_gid != gid ||
5667 + inode->i_tag != tag)
5668 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5670 if (inode->i_nlink != fattr->nlink)
5671 @@ -1156,8 +1177,9 @@ static int nfs_update_inode(struct inode
5673 inode->i_mode = fattr->mode;
5674 inode->i_nlink = fattr->nlink;
5675 - inode->i_uid = fattr->uid;
5676 - inode->i_gid = fattr->gid;
5677 + inode->i_uid = uid;
5678 + inode->i_gid = gid;
5679 + inode->i_tag = tag;
5681 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5683 diff -NurpP --minimal linux-2.6.29/fs/nfs/nfs3xdr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/nfs3xdr.c
5684 --- linux-2.6.29/fs/nfs/nfs3xdr.c 2009-03-24 14:22:26.000000000 +0100
5685 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/nfs3xdr.c 2009-03-24 14:48:35.000000000 +0100
5687 #include <linux/nfs3.h>
5688 #include <linux/nfs_fs.h>
5689 #include <linux/nfsacl.h>
5690 +#include <linux/vs_tag.h>
5691 #include "internal.h"
5693 #define NFSDBG_FACILITY NFSDBG_XDR
5694 @@ -182,7 +183,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5697 static inline __be32 *
5698 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5699 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5701 if (attr->ia_valid & ATTR_MODE) {
5703 @@ -190,15 +191,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5707 - if (attr->ia_valid & ATTR_UID) {
5708 + if (attr->ia_valid & ATTR_UID ||
5709 + (tag && (attr->ia_valid & ATTR_TAG))) {
5711 - *p++ = htonl(attr->ia_uid);
5712 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5716 - if (attr->ia_valid & ATTR_GID) {
5717 + if (attr->ia_valid & ATTR_GID ||
5718 + (tag && (attr->ia_valid & ATTR_TAG))) {
5720 - *p++ = htonl(attr->ia_gid);
5721 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5725 @@ -283,7 +286,8 @@ static int
5726 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5728 p = xdr_encode_fhandle(p, args->fh);
5729 - p = xdr_encode_sattr(p, args->sattr);
5730 + p = xdr_encode_sattr(p, args->sattr,
5731 + req->rq_task->tk_client->cl_tag);
5732 *p++ = htonl(args->guard);
5734 p = xdr_encode_time3(p, &args->guardtime);
5735 @@ -388,7 +392,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5736 *p++ = args->verifier[0];
5737 *p++ = args->verifier[1];
5739 - p = xdr_encode_sattr(p, args->sattr);
5740 + p = xdr_encode_sattr(p, args->sattr,
5741 + req->rq_task->tk_client->cl_tag);
5743 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5745 @@ -402,7 +407,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5747 p = xdr_encode_fhandle(p, args->fh);
5748 p = xdr_encode_array(p, args->name, args->len);
5749 - p = xdr_encode_sattr(p, args->sattr);
5750 + p = xdr_encode_sattr(p, args->sattr,
5751 + req->rq_task->tk_client->cl_tag);
5752 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5755 @@ -415,7 +421,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5757 p = xdr_encode_fhandle(p, args->fromfh);
5758 p = xdr_encode_array(p, args->fromname, args->fromlen);
5759 - p = xdr_encode_sattr(p, args->sattr);
5760 + p = xdr_encode_sattr(p, args->sattr,
5761 + req->rq_task->tk_client->cl_tag);
5762 *p++ = htonl(args->pathlen);
5763 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5765 @@ -433,7 +440,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5766 p = xdr_encode_fhandle(p, args->fh);
5767 p = xdr_encode_array(p, args->name, args->len);
5768 *p++ = htonl(args->type);
5769 - p = xdr_encode_sattr(p, args->sattr);
5770 + p = xdr_encode_sattr(p, args->sattr,
5771 + req->rq_task->tk_client->cl_tag);
5772 if (args->type == NF3CHR || args->type == NF3BLK) {
5773 *p++ = htonl(MAJOR(args->rdev));
5774 *p++ = htonl(MINOR(args->rdev));
5775 diff -NurpP --minimal linux-2.6.29/fs/nfs/nfsroot.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/nfsroot.c
5776 --- linux-2.6.29/fs/nfs/nfsroot.c 2009-03-24 14:22:26.000000000 +0100
5777 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/nfsroot.c 2009-03-24 14:48:35.000000000 +0100
5778 @@ -119,12 +119,12 @@ static int mount_port __initdata = 0; /
5780 /* Options that take integer arguments */
5781 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
5782 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
5783 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
5784 /* Options that take no arguments */
5785 Opt_soft, Opt_hard, Opt_intr,
5786 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
5787 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
5788 - Opt_acl, Opt_noacl,
5789 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
5793 @@ -161,6 +161,9 @@ static match_table_t __initconst tokens
5796 {Opt_noacl, "noacl"},
5798 + {Opt_notag, "notag"},
5799 + {Opt_tagid, "tagid=%u"},
5803 @@ -272,6 +275,20 @@ static int __init root_nfs_parse(char *n
5805 nfs_data.flags |= NFS_MOUNT_NOACL;
5807 +#ifndef CONFIG_TAGGING_NONE
5809 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5812 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
5815 +#ifdef CONFIG_PROPAGATE
5818 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5822 printk(KERN_WARNING "Root-NFS: unknown "
5824 diff -NurpP --minimal linux-2.6.29/fs/nfs/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/super.c
5825 --- linux-2.6.29/fs/nfs/super.c 2009-03-24 14:22:26.000000000 +0100
5826 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfs/super.c 2009-03-24 16:02:06.000000000 +0100
5828 #include <linux/nfs_xdr.h>
5829 #include <linux/magic.h>
5830 #include <linux/parser.h>
5831 +#include <linux/vs_tag.h>
5833 #include <asm/system.h>
5834 #include <asm/uaccess.h>
5835 @@ -517,6 +518,7 @@ static void nfs_show_mount_options(struc
5836 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5837 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5838 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5839 + { NFS_MOUNT_TAGGED, ",tag", "" },
5842 const struct proc_nfs_info *nfs_infop;
5843 diff -NurpP --minimal linux-2.6.29/fs/nfsd/auth.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/auth.c
5844 --- linux-2.6.29/fs/nfsd/auth.c 2009-03-24 14:22:26.000000000 +0100
5845 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/auth.c 2009-03-24 16:09:39.000000000 +0100
5847 #include <linux/sunrpc/svcauth.h>
5848 #include <linux/nfsd/nfsd.h>
5849 #include <linux/nfsd/export.h>
5850 +#include <linux/vs_tag.h>
5853 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
5854 @@ -42,6 +43,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5856 new->fsuid = rqstp->rq_cred.cr_uid;
5857 new->fsgid = rqstp->rq_cred.cr_gid;
5858 + /* FIXME: this desperately needs a tag :)
5859 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5862 rqgi = rqstp->rq_cred.cr_group_info;
5864 @@ -69,7 +73,7 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5867 gi = get_group_info(rqgi);
5871 if (new->fsuid == (uid_t) -1)
5872 new->fsuid = exp->ex_anon_uid;
5873 @@ -94,6 +98,6 @@ oom:
5881 diff -NurpP --minimal linux-2.6.29/fs/nfsd/nfs3xdr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/nfs3xdr.c
5882 --- linux-2.6.29/fs/nfsd/nfs3xdr.c 2008-12-25 00:26:37.000000000 +0100
5883 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/nfs3xdr.c 2009-02-22 22:54:25.000000000 +0100
5885 #include <linux/sunrpc/svc.h>
5886 #include <linux/nfsd/nfsd.h>
5887 #include <linux/nfsd/xdr3.h>
5888 +#include <linux/vs_tag.h>
5891 #define NFSDDBG_FACILITY NFSDDBG_XDR
5892 @@ -108,6 +109,8 @@ static __be32 *
5893 decode_sattr3(__be32 *p, struct iattr *iap)
5901 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5904 iap->ia_valid |= ATTR_UID;
5905 - iap->ia_uid = ntohl(*p++);
5906 + uid = ntohl(*p++);
5909 iap->ia_valid |= ATTR_GID;
5910 - iap->ia_gid = ntohl(*p++);
5911 + gid = ntohl(*p++);
5913 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5914 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5915 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5919 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5920 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5921 *p++ = htonl((u32) stat->mode);
5922 *p++ = htonl((u32) stat->nlink);
5923 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5924 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5925 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5926 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5927 + stat->uid, stat->tag)));
5928 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5929 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5930 + stat->gid, stat->tag)));
5931 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5932 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5934 diff -NurpP --minimal linux-2.6.29/fs/nfsd/nfs4xdr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/nfs4xdr.c
5935 --- linux-2.6.29/fs/nfsd/nfs4xdr.c 2009-03-24 14:22:26.000000000 +0100
5936 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/nfs4xdr.c 2009-03-24 14:48:35.000000000 +0100
5938 #include <linux/nfs4_acl.h>
5939 #include <linux/sunrpc/gss_api.h>
5940 #include <linux/sunrpc/svcauth_gss.h>
5941 +#include <linux/vs_tag.h>
5943 #define NFSDDBG_FACILITY NFSDDBG_XDR
5945 @@ -1714,14 +1715,18 @@ out_acl:
5946 WRITE32(stat.nlink);
5948 if (bmval1 & FATTR4_WORD1_OWNER) {
5949 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5950 + status = nfsd4_encode_user(rqstp,
5951 + TAGINO_UID(DX_TAG(dentry->d_inode),
5952 + stat.uid, stat.tag), &p, &buflen);
5953 if (status == nfserr_resource)
5958 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5959 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5960 + status = nfsd4_encode_group(rqstp,
5961 + TAGINO_GID(DX_TAG(dentry->d_inode),
5962 + stat.gid, stat.tag), &p, &buflen);
5963 if (status == nfserr_resource)
5966 diff -NurpP --minimal linux-2.6.29/fs/nfsd/nfsxdr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/nfsxdr.c
5967 --- linux-2.6.29/fs/nfsd/nfsxdr.c 2008-12-25 00:26:37.000000000 +0100
5968 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/nfsd/nfsxdr.c 2009-02-22 22:54:25.000000000 +0100
5970 #include <linux/nfsd/nfsd.h>
5971 #include <linux/nfsd/xdr.h>
5972 #include <linux/mm.h>
5973 +#include <linux/vs_tag.h>
5976 #define NFSDDBG_FACILITY NFSDDBG_XDR
5977 @@ -98,6 +99,8 @@ static __be32 *
5978 decode_sattr(__be32 *p, struct iattr *iap)
5986 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5988 if ((tmp = ntohl(*p++)) != (u32)-1) {
5989 iap->ia_valid |= ATTR_UID;
5990 - iap->ia_uid = tmp;
5993 if ((tmp = ntohl(*p++)) != (u32)-1) {
5994 iap->ia_valid |= ATTR_GID;
5995 - iap->ia_gid = tmp;
5998 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5999 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6000 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6001 if ((tmp = ntohl(*p++)) != (u32)-1) {
6002 iap->ia_valid |= ATTR_SIZE;
6004 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6005 *p++ = htonl(nfs_ftypes[type >> 12]);
6006 *p++ = htonl((u32) stat->mode);
6007 *p++ = htonl((u32) stat->nlink);
6008 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6009 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6010 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6011 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6012 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6013 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6015 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6016 *p++ = htonl(NFS_MAXPATHLEN);
6017 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/dlm/dlmfs.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/dlm/dlmfs.c
6018 --- linux-2.6.29/fs/ocfs2/dlm/dlmfs.c 2009-03-24 14:22:27.000000000 +0100
6019 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/dlm/dlmfs.c 2009-03-24 16:10:48.000000000 +0100
6021 #include <linux/init.h>
6022 #include <linux/string.h>
6023 #include <linux/backing-dev.h>
6024 +#include <linux/vs_tag.h>
6026 #include <asm/uaccess.h>
6028 @@ -341,6 +342,7 @@ static struct inode *dlmfs_get_root_inod
6029 inode->i_mode = mode;
6030 inode->i_uid = current_fsuid();
6031 inode->i_gid = current_fsgid();
6032 + inode->i_tag = dx_current_fstag(sb);
6033 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6034 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6036 @@ -366,6 +368,7 @@ static struct inode *dlmfs_get_inode(str
6037 inode->i_mode = mode;
6038 inode->i_uid = current_fsuid();
6039 inode->i_gid = current_fsgid();
6040 + inode->i_tag = dx_current_fstag(sb);
6041 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6042 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6044 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/dlmglue.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/dlmglue.c
6045 --- linux-2.6.29/fs/ocfs2/dlmglue.c 2009-03-24 14:22:27.000000000 +0100
6046 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/dlmglue.c 2009-03-24 14:48:35.000000000 +0100
6047 @@ -1885,6 +1885,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6048 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6049 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6050 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6051 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6052 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6053 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6054 lvb->lvb_iatime_packed =
6055 @@ -1939,6 +1940,7 @@ static void ocfs2_refresh_inode_from_lvb
6057 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6058 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6059 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6060 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6061 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6062 ocfs2_unpack_timespec(&inode->i_atime,
6063 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/dlmglue.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/dlmglue.h
6064 --- linux-2.6.29/fs/ocfs2/dlmglue.h 2009-03-24 14:22:27.000000000 +0100
6065 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/dlmglue.h 2009-03-24 14:48:35.000000000 +0100
6066 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6069 __be32 lvb_igeneration;
6070 - __be32 lvb_reserved2;
6072 + __be16 lvb_reserved2;
6075 #define OCFS2_QINFO_LVB_VERSION 1
6076 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/file.c
6077 --- linux-2.6.29/fs/ocfs2/file.c 2009-03-24 14:22:27.000000000 +0100
6078 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/file.c 2009-03-24 14:48:35.000000000 +0100
6079 @@ -911,13 +911,15 @@ int ocfs2_setattr(struct dentry *dentry,
6080 mlog(0, "uid change: %d\n", attr->ia_uid);
6081 if (attr->ia_valid & ATTR_GID)
6082 mlog(0, "gid change: %d\n", attr->ia_gid);
6083 + if (attr->ia_valid & ATTR_TAG)
6084 + mlog(0, "tag change: %d\n", attr->ia_tag);
6085 if (attr->ia_valid & ATTR_SIZE)
6086 mlog(0, "size change...\n");
6087 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6088 mlog(0, "time change...\n");
6090 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6091 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6092 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6093 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6094 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6096 @@ -2070,6 +2072,7 @@ const struct inode_operations ocfs2_file
6097 .removexattr = generic_removexattr,
6098 .fallocate = ocfs2_fallocate,
6099 .fiemap = ocfs2_fiemap,
6100 + .sync_flags = ocfs2_sync_flags,
6103 const struct inode_operations ocfs2_special_file_iops = {
6104 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/inode.c
6105 --- linux-2.6.29/fs/ocfs2/inode.c 2009-03-24 14:22:27.000000000 +0100
6106 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/inode.c 2009-03-24 16:11:11.000000000 +0100
6108 #include <linux/highmem.h>
6109 #include <linux/pagemap.h>
6110 #include <linux/quotaops.h>
6111 +#include <linux/vs_tag.h>
6113 #include <asm/byteorder.h>
6117 #include "heartbeat.h"
6120 #include "journal.h"
6122 #include "suballoc.h"
6123 @@ -77,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6125 unsigned int flags = OCFS2_I(inode)->ip_attr;
6127 - inode->i_flags &= ~(S_IMMUTABLE |
6128 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6129 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6131 if (flags & OCFS2_IMMUTABLE_FL)
6132 inode->i_flags |= S_IMMUTABLE;
6133 + if (flags & OCFS2_IXUNLINK_FL)
6134 + inode->i_flags |= S_IXUNLINK;
6136 if (flags & OCFS2_SYNC_FL)
6137 inode->i_flags |= S_SYNC;
6138 @@ -91,25 +95,85 @@ void ocfs2_set_inode_flags(struct inode
6139 inode->i_flags |= S_NOATIME;
6140 if (flags & OCFS2_DIRSYNC_FL)
6141 inode->i_flags |= S_DIRSYNC;
6143 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6145 + if (flags & OCFS2_BARRIER_FL)
6146 + inode->i_vflags |= V_BARRIER;
6147 + if (flags & OCFS2_COW_FL)
6148 + inode->i_vflags |= V_COW;
6151 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6152 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6154 unsigned int flags = oi->vfs_inode.i_flags;
6155 + unsigned int vflags = oi->vfs_inode.i_vflags;
6157 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6158 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6159 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6160 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6162 + if (flags & S_IMMUTABLE)
6163 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6164 + if (flags & S_IXUNLINK)
6165 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6167 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6168 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6170 oi->ip_attr |= OCFS2_SYNC_FL;
6171 if (flags & S_APPEND)
6172 oi->ip_attr |= OCFS2_APPEND_FL;
6173 - if (flags & S_IMMUTABLE)
6174 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6175 if (flags & S_NOATIME)
6176 oi->ip_attr |= OCFS2_NOATIME_FL;
6177 if (flags & S_DIRSYNC)
6178 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6180 + if (vflags & V_BARRIER)
6181 + oi->ip_attr |= OCFS2_BARRIER_FL;
6182 + if (vflags & V_COW)
6183 + oi->ip_attr |= OCFS2_COW_FL;
6186 +int ocfs2_sync_flags(struct inode *inode)
6188 + struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6189 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6190 + handle_t *handle = NULL;
6191 + struct buffer_head *bh = NULL;
6194 + status = ocfs2_inode_lock(inode, &bh, 1);
6196 + mlog_errno(status);
6201 + if (IS_RDONLY(inode))
6204 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6205 + if (IS_ERR(handle)) {
6206 + status = PTR_ERR(handle);
6207 + mlog_errno(status);
6211 + ocfs2_get_inode_flags(ocfs2_inode);
6212 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6214 + mlog_errno(status);
6216 + ocfs2_commit_trans(osb, handle);
6218 + ocfs2_inode_unlock(inode, 1);
6223 + mlog_exit(status);
6227 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
6228 @@ -222,6 +286,8 @@ void ocfs2_populate_inode(struct inode *
6229 struct super_block *sb;
6230 struct ocfs2_super *osb;
6235 mlog_entry("(0x%p, size:%llu)\n", inode,
6236 (unsigned long long)le64_to_cpu(fe->i_size));
6237 @@ -253,8 +319,12 @@ void ocfs2_populate_inode(struct inode *
6238 inode->i_generation = le32_to_cpu(fe->i_generation);
6239 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6240 inode->i_mode = le16_to_cpu(fe->i_mode);
6241 - inode->i_uid = le32_to_cpu(fe->i_uid);
6242 - inode->i_gid = le32_to_cpu(fe->i_gid);
6243 + uid = le32_to_cpu(fe->i_uid);
6244 + gid = le32_to_cpu(fe->i_gid);
6245 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6246 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6247 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6248 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6250 /* Fast symlinks will have i_size but no allocated clusters. */
6251 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6252 @@ -1206,8 +1276,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
6254 fe->i_size = cpu_to_le64(i_size_read(inode));
6255 fe->i_links_count = cpu_to_le16(inode->i_nlink);
6256 - fe->i_uid = cpu_to_le32(inode->i_uid);
6257 - fe->i_gid = cpu_to_le32(inode->i_gid);
6258 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
6259 + inode->i_uid, inode->i_tag));
6260 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
6261 + inode->i_gid, inode->i_tag));
6262 + /* i_tag = = cpu_to_le16(inode->i_tag); */
6263 fe->i_mode = cpu_to_le16(inode->i_mode);
6264 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
6265 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
6266 @@ -1235,16 +1308,25 @@ leave:
6267 void ocfs2_refresh_inode(struct inode *inode,
6268 struct ocfs2_dinode *fe)
6273 spin_lock(&OCFS2_I(inode)->ip_lock);
6275 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
6276 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
6277 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
6278 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
6279 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
6280 ocfs2_set_inode_flags(inode);
6281 i_size_write(inode, le64_to_cpu(fe->i_size));
6282 inode->i_nlink = le16_to_cpu(fe->i_links_count);
6283 - inode->i_uid = le32_to_cpu(fe->i_uid);
6284 - inode->i_gid = le32_to_cpu(fe->i_gid);
6285 + uid = le32_to_cpu(fe->i_uid);
6286 + gid = le32_to_cpu(fe->i_gid);
6287 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6288 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6289 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6290 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6291 inode->i_mode = le16_to_cpu(fe->i_mode);
6292 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
6293 inode->i_blocks = 0;
6294 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/inode.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/inode.h
6295 --- linux-2.6.29/fs/ocfs2/inode.h 2009-03-24 14:22:27.000000000 +0100
6296 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/inode.h 2009-03-24 14:48:35.000000000 +0100
6297 @@ -147,6 +147,7 @@ struct buffer_head *ocfs2_bread(struct i
6299 void ocfs2_set_inode_flags(struct inode *inode);
6300 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6301 +int ocfs2_sync_flags(struct inode *inode);
6303 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6305 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ioctl.c
6306 --- linux-2.6.29/fs/ocfs2/ioctl.c 2008-12-25 00:26:37.000000000 +0100
6307 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ioctl.c 2009-02-22 22:54:25.000000000 +0100
6308 @@ -42,7 +42,7 @@ static int ocfs2_get_inode_attr(struct i
6312 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6313 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6316 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6317 @@ -67,6 +67,11 @@ static int ocfs2_set_inode_attr(struct i
6318 if (!S_ISDIR(inode->i_mode))
6319 flags &= ~OCFS2_DIRSYNC_FL;
6321 + if (IS_BARRIER(inode)) {
6322 + vxwprintk_task(1, "messing with the barrier.");
6326 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6327 if (IS_ERR(handle)) {
6328 status = PTR_ERR(handle);
6329 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ioctl.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ioctl.h
6330 --- linux-2.6.29/fs/ocfs2/ioctl.h 2008-12-25 00:26:37.000000000 +0100
6331 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ioctl.h 2009-02-22 22:54:25.000000000 +0100
6333 #ifndef OCFS2_IOCTL_H
6334 #define OCFS2_IOCTL_H
6336 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6339 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
6340 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
6342 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/namei.c
6343 --- linux-2.6.29/fs/ocfs2/namei.c 2009-03-24 14:22:27.000000000 +0100
6344 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/namei.c 2009-03-25 01:04:31.000000000 +0100
6346 #include <linux/slab.h>
6347 #include <linux/highmem.h>
6348 #include <linux/quotaops.h>
6349 +#include <linux/vs_tag.h>
6351 #define MLOG_MASK_PREFIX ML_NAMEI
6352 #include <cluster/masklog.h>
6353 @@ -462,6 +463,7 @@ static int ocfs2_mknod_locked(struct ocf
6354 struct ocfs2_extent_list *fel;
6359 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry,
6360 inode->i_mode, (unsigned long)dev, dentry->d_name.len,
6361 @@ -508,8 +510,11 @@ static int ocfs2_mknod_locked(struct ocf
6362 fe->i_blkno = cpu_to_le64(fe_blkno);
6363 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6364 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6365 - fe->i_uid = cpu_to_le32(inode->i_uid);
6366 - fe->i_gid = cpu_to_le32(inode->i_gid);
6368 + tag = dx_current_fstag(osb->sb);
6369 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6370 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6371 + inode->i_tag = tag;
6372 fe->i_mode = cpu_to_le16(inode->i_mode);
6373 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6374 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6375 @@ -2025,6 +2030,7 @@ const struct inode_operations ocfs2_dir_
6376 .rename = ocfs2_rename,
6377 .setattr = ocfs2_setattr,
6378 .getattr = ocfs2_getattr,
6379 + .sync_flags = ocfs2_sync_flags,
6380 .permission = ocfs2_permission,
6381 .setxattr = generic_setxattr,
6382 .getxattr = generic_getxattr,
6383 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ocfs2_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ocfs2_fs.h
6384 --- linux-2.6.29/fs/ocfs2/ocfs2_fs.h 2009-03-24 14:22:27.000000000 +0100
6385 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ocfs2_fs.h 2009-03-24 14:48:35.000000000 +0100
6386 @@ -219,18 +219,23 @@
6387 #define OCFS2_INDEXED_DIR_FL (0x0008)
6389 /* Inode attributes, keep in sync with EXT2 */
6390 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6391 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6392 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6393 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6394 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6395 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6396 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6397 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6398 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6399 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6400 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6401 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6402 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6403 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6404 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6405 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6406 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6408 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6409 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6410 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6411 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6413 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6414 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6416 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6417 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6420 * Extent record flags (e_node.leaf.flags)
6421 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/ocfs2.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ocfs2.h
6422 --- linux-2.6.29/fs/ocfs2/ocfs2.h 2009-03-24 14:22:27.000000000 +0100
6423 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/ocfs2.h 2009-03-24 16:18:22.000000000 +0100
6424 @@ -199,6 +199,7 @@ enum ocfs2_mount_options
6425 OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
6426 OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
6427 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
6428 + OCFS2_MOUNT_TAGGED = 1 << 11, /* use tagging */
6431 #define OCFS2_OSB_SOFT_RO 0x0001
6432 diff -NurpP --minimal linux-2.6.29/fs/ocfs2/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/super.c
6433 --- linux-2.6.29/fs/ocfs2/super.c 2009-03-24 14:22:27.000000000 +0100
6434 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/ocfs2/super.c 2009-03-24 16:19:44.000000000 +0100
6435 @@ -172,6 +172,7 @@ enum {
6439 + Opt_tag, Opt_notag, Opt_tagid,
6443 @@ -198,6 +199,9 @@ static const match_table_t tokens = {
6444 {Opt_noacl, "noacl"},
6445 {Opt_usrquota, "usrquota"},
6446 {Opt_grpquota, "grpquota"},
6448 + {Opt_notag, "notag"},
6449 + {Opt_tagid, "tagid=%u"},
6453 @@ -436,6 +440,13 @@ static int ocfs2_remount(struct super_bl
6457 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
6458 + !(sb->s_flags & MS_TAGGED)) {
6460 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6464 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6465 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6467 @@ -950,6 +961,9 @@ static int ocfs2_fill_super(struct super
6469 ocfs2_complete_mount_recovery(osb);
6471 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6472 + sb->s_flags |= MS_TAGGED;
6474 if (ocfs2_mount_local(osb))
6475 snprintf(nodestr, sizeof(nodestr), "local");
6477 @@ -1208,6 +1222,20 @@ static int ocfs2_parse_options(struct su
6478 printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
6481 +#ifndef CONFIG_TAGGING_NONE
6483 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6486 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6489 +#ifdef CONFIG_PROPAGATE
6492 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6497 "Unrecognized mount option \"%s\" "
6498 diff -NurpP --minimal linux-2.6.29/fs/open.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/open.c
6499 --- linux-2.6.29/fs/open.c 2009-03-24 14:22:27.000000000 +0100
6500 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/open.c 2009-03-24 14:48:35.000000000 +0100
6502 #include <linux/rcupdate.h>
6503 #include <linux/audit.h>
6504 #include <linux/falloc.h>
6505 +#include <linux/vs_base.h>
6506 +#include <linux/vs_limit.h>
6507 +#include <linux/vs_dlimit.h>
6508 +#include <linux/vs_tag.h>
6509 +#include <linux/vs_cowbl.h>
6511 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6513 int retval = -ENODEV;
6516 + struct super_block *sb = dentry->d_sb;
6519 - if (dentry->d_sb->s_op->statfs) {
6520 + if (sb->s_op->statfs) {
6521 memset(buf, 0, sizeof(*buf));
6522 retval = security_sb_statfs(dentry);
6525 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6526 + retval = sb->s_op->statfs(dentry, buf);
6527 if (retval == 0 && buf->f_frsize == 0)
6528 buf->f_frsize = buf->f_bsize;
6530 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6531 + vx_vsi_statfs(sb, buf);
6535 @@ -638,6 +647,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6536 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6540 + error = cow_check_and_break(&path);
6542 + goto dput_and_out;
6543 inode = path.dentry->d_inode;
6545 error = mnt_want_write(path.mnt);
6546 @@ -671,11 +684,11 @@ static int chown_common(struct dentry *
6547 newattrs.ia_valid = ATTR_CTIME;
6548 if (user != (uid_t) -1) {
6549 newattrs.ia_valid |= ATTR_UID;
6550 - newattrs.ia_uid = user;
6551 + newattrs.ia_uid = dx_map_uid(user);
6553 if (group != (gid_t) -1) {
6554 newattrs.ia_valid |= ATTR_GID;
6555 - newattrs.ia_gid = group;
6556 + newattrs.ia_gid = dx_map_gid(group);
6558 if (!S_ISDIR(inode->i_mode))
6559 newattrs.ia_valid |=
6560 @@ -698,7 +711,11 @@ SYSCALL_DEFINE3(chown, const char __user
6561 error = mnt_want_write(path.mnt);
6564 - error = chown_common(path.dentry, user, group);
6565 +#ifdef CONFIG_VSERVER_COWBL
6566 + error = cow_check_and_break(&path);
6569 + error = chown_common(path.dentry, user, group);
6570 mnt_drop_write(path.mnt);
6573 @@ -723,7 +740,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6574 error = mnt_want_write(path.mnt);
6577 - error = chown_common(path.dentry, user, group);
6578 +#ifdef CONFIG_VSERVER_COWBL
6579 + error = cow_check_and_break(&path);
6582 + error = chown_common(path.dentry, user, group);
6583 mnt_drop_write(path.mnt);
6586 @@ -742,7 +763,11 @@ SYSCALL_DEFINE3(lchown, const char __use
6587 error = mnt_want_write(path.mnt);
6590 - error = chown_common(path.dentry, user, group);
6591 +#ifdef CONFIG_VSERVER_COWBL
6592 + error = cow_check_and_break(&path);
6595 + error = chown_common(path.dentry, user, group);
6596 mnt_drop_write(path.mnt);
6599 @@ -986,6 +1011,7 @@ static void __put_unused_fd(struct files
6600 __FD_CLR(fd, fdt->open_fds);
6601 if (fd < files->next_fd)
6602 files->next_fd = fd;
6603 + vx_openfd_dec(fd);
6606 void put_unused_fd(unsigned int fd)
6607 diff -NurpP --minimal linux-2.6.29/fs/proc/array.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/array.c
6608 --- linux-2.6.29/fs/proc/array.c 2009-03-24 14:22:27.000000000 +0100
6609 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/array.c 2009-03-25 01:07:51.000000000 +0100
6611 #include <linux/seq_file.h>
6612 #include <linux/pid_namespace.h>
6613 #include <linux/tracehook.h>
6614 +#include <linux/vs_context.h>
6615 +#include <linux/vs_network.h>
6617 #include <asm/pgtable.h>
6618 #include <asm/processor.h>
6619 @@ -137,8 +139,9 @@ static const char *task_state_array[] =
6620 "D (disk sleep)", /* 2 */
6621 "T (stopped)", /* 4 */
6622 "T (tracing stop)", /* 8 */
6623 - "Z (zombie)", /* 16 */
6624 - "X (dead)" /* 32 */
6625 + "H (on hold)", /* 16 */
6626 + "Z (zombie)", /* 32 */
6627 + "X (dead)", /* 64 */
6630 static inline const char *get_task_state(struct task_struct *tsk)
6631 @@ -165,6 +168,9 @@ static inline void task_state(struct seq
6633 ppid = pid_alive(p) ?
6634 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6635 + if (unlikely(vx_current_initpid(p->pid)))
6640 struct task_struct *tracer = tracehook_tracer_task(p);
6641 @@ -280,7 +286,7 @@ static inline void task_sig(struct seq_f
6644 static void render_cap_t(struct seq_file *m, const char *header,
6646 + struct vx_info *vxi, kernel_cap_t *a)
6650 @@ -305,10 +311,11 @@ static inline void task_cap(struct seq_f
6651 cap_bset = cred->cap_bset;
6654 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6655 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6656 - render_cap_t(m, "CapEff:\t", &cap_effective);
6657 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6658 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6659 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6660 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6661 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6662 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6665 static inline void task_context_switch_counts(struct seq_file *m,
6666 @@ -320,6 +327,42 @@ static inline void task_context_switch_c
6670 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6671 + struct pid *pid, struct task_struct *task)
6673 + seq_printf(m, "Proxy:\t%p(%c)\n"
6681 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6682 + atomic_read(&task->nsproxy->count),
6683 + task->nsproxy->uts_ns,
6684 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6685 + task->nsproxy->ipc_ns,
6686 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6687 + task->nsproxy->mnt_ns,
6688 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6689 + task->nsproxy->pid_ns,
6690 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6691 + task->nsproxy->net_ns,
6692 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6696 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6698 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6701 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6702 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6706 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6707 struct pid *pid, struct task_struct *task)
6709 @@ -335,6 +378,7 @@ int proc_pid_status(struct seq_file *m,
6712 cpuset_task_status_allowed(m, task);
6713 + task_vs_id(m, task);
6714 #if defined(CONFIG_S390)
6715 task_show_regs(m, task);
6717 @@ -447,6 +491,17 @@ static int do_task_stat(struct seq_file
6718 /* convert nsec -> ticks */
6719 start_time = nsec_to_clock_t(start_time);
6721 + /* fixup start time for virt uptime */
6722 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6723 + unsigned long long bias =
6724 + current->vx_info->cvirt.bias_clock;
6726 + if (start_time > bias)
6727 + start_time -= bias;
6732 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6733 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6734 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6735 diff -NurpP --minimal linux-2.6.29/fs/proc/base.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/base.c
6736 --- linux-2.6.29/fs/proc/base.c 2009-03-24 14:22:27.000000000 +0100
6737 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/base.c 2009-03-24 16:29:35.000000000 +0100
6739 #include <linux/oom.h>
6740 #include <linux/elf.h>
6741 #include <linux/pid_namespace.h>
6742 +#include <linux/vs_context.h>
6743 +#include <linux/vs_network.h>
6744 #include "internal.h"
6747 @@ -1458,6 +1460,8 @@ static struct inode *proc_pid_make_inode
6748 inode->i_gid = cred->egid;
6751 + /* procfs is xid tagged */
6752 + inode->i_tag = (tag_t)vx_task_xid(task);
6753 security_task_to_inode(task, inode);
6756 @@ -2008,6 +2012,13 @@ static struct dentry *proc_pident_lookup
6760 + /* TODO: maybe we can come up with a generic approach? */
6761 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6762 + (dentry->d_name.len == 5) &&
6763 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6764 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6768 * Yes, it does not scale. And it should not. Don't add
6769 * new entries into /proc/<tgid>/ without very good reasons.
6770 @@ -2393,7 +2404,7 @@ out_iput:
6771 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6773 struct dentry *error;
6774 - struct task_struct *task = get_proc_task(dir);
6775 + struct task_struct *task = get_proc_task_real(dir);
6776 const struct pid_entry *p, *last;
6778 error = ERR_PTR(-ENOENT);
6779 @@ -2483,6 +2494,9 @@ static int proc_pid_personality(struct s
6780 static const struct file_operations proc_task_operations;
6781 static const struct inode_operations proc_task_inode_operations;
6783 +extern int proc_pid_vx_info(struct task_struct *, char *);
6784 +extern int proc_pid_nx_info(struct task_struct *, char *);
6786 static const struct pid_entry tgid_base_stuff[] = {
6787 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6788 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6789 @@ -2541,6 +2555,8 @@ static const struct pid_entry tgid_base_
6790 #ifdef CONFIG_CGROUPS
6791 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6793 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6794 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6795 INF("oom_score", S_IRUGO, proc_oom_score),
6796 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6797 #ifdef CONFIG_AUDITSYSCALL
6798 @@ -2556,6 +2572,7 @@ static const struct pid_entry tgid_base_
6799 #ifdef CONFIG_TASK_IO_ACCOUNTING
6800 INF("io", S_IRUGO, proc_tgid_io_accounting),
6802 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6805 static int proc_tgid_base_readdir(struct file * filp,
6806 @@ -2752,7 +2769,7 @@ retry:
6808 pid = find_ge_pid(iter.tgid, ns);
6810 - iter.tgid = pid_nr_ns(pid, ns);
6811 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6812 iter.task = pid_task(pid, PIDTYPE_PID);
6813 /* What we to know is if the pid we have find is the
6814 * pid of a thread_group_leader. Testing for task
6815 @@ -2782,7 +2799,7 @@ static int proc_pid_fill_cache(struct fi
6816 struct tgid_iter iter)
6818 char name[PROC_NUMBUF];
6819 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6820 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6821 return proc_fill_cache(filp, dirent, filldir, name, len,
6822 proc_pid_instantiate, iter.task, NULL);
6824 @@ -2791,7 +2808,7 @@ static int proc_pid_fill_cache(struct fi
6825 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6827 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6828 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6829 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6830 struct tgid_iter iter;
6831 struct pid_namespace *ns;
6833 @@ -2811,6 +2828,8 @@ int proc_pid_readdir(struct file * filp,
6835 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6836 filp->f_pos = iter.tgid + TGID_OFFSET;
6837 + if (!vx_proc_task_visible(iter.task))
6839 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6840 put_task_struct(iter.task);
6842 @@ -2957,6 +2976,8 @@ static struct dentry *proc_task_lookup(s
6843 tid = name_to_int(dentry);
6846 + if (vx_current_initpid(tid))
6849 ns = dentry->d_sb->s_fs_info;
6851 diff -NurpP --minimal linux-2.6.29/fs/proc/generic.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/generic.c
6852 --- linux-2.6.29/fs/proc/generic.c 2009-03-24 14:22:27.000000000 +0100
6853 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/generic.c 2009-03-24 14:48:35.000000000 +0100
6855 #include <linux/bitops.h>
6856 #include <linux/spinlock.h>
6857 #include <linux/completion.h>
6858 +#include <linux/vserver/inode.h>
6859 #include <asm/uaccess.h>
6861 #include "internal.h"
6862 @@ -382,6 +383,8 @@ struct dentry *proc_lookup_de(struct pro
6863 for (de = de->subdir; de ; de = de->next) {
6864 if (de->namelen != dentry->d_name.len)
6866 + if (!vx_hide_check(0, de->vx_flags))
6868 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6871 @@ -390,6 +393,8 @@ struct dentry *proc_lookup_de(struct pro
6872 spin_unlock(&proc_subdir_lock);
6874 inode = proc_get_inode(dir->i_sb, ino, de);
6875 + /* generic proc entries belong to the host */
6880 @@ -467,6 +472,8 @@ int proc_readdir_de(struct proc_dir_entr
6882 /* filldir passes info to user space */
6884 + if (!vx_hide_check(0, de->vx_flags))
6886 spin_unlock(&proc_subdir_lock);
6887 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6888 de->low_ino, de->mode >> 12) < 0) {
6889 @@ -474,6 +481,7 @@ int proc_readdir_de(struct proc_dir_entr
6892 spin_lock(&proc_subdir_lock);
6897 @@ -588,6 +596,7 @@ static struct proc_dir_entry *__proc_cre
6899 atomic_set(&ent->count, 1);
6901 + ent->vx_flags = IATTR_PROC_DEFAULT;
6902 spin_lock_init(&ent->pde_unload_lock);
6903 ent->pde_unload_completion = NULL;
6904 INIT_LIST_HEAD(&ent->pde_openers);
6905 @@ -611,7 +620,8 @@ struct proc_dir_entry *proc_symlink(cons
6911 + ent->vx_flags = IATTR_PROC_SYMLINK;
6915 diff -NurpP --minimal linux-2.6.29/fs/proc/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/inode.c
6916 --- linux-2.6.29/fs/proc/inode.c 2009-03-24 14:22:27.000000000 +0100
6917 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/inode.c 2009-03-24 14:48:35.000000000 +0100
6918 @@ -465,6 +465,8 @@ struct inode *proc_get_inode(struct supe
6919 inode->i_uid = de->uid;
6920 inode->i_gid = de->gid;
6923 + PROC_I(inode)->vx_flags = de->vx_flags;
6925 inode->i_size = de->size;
6927 diff -NurpP --minimal linux-2.6.29/fs/proc/internal.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/internal.h
6928 --- linux-2.6.29/fs/proc/internal.h 2009-03-24 14:22:27.000000000 +0100
6929 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/internal.h 2009-03-24 14:48:35.000000000 +0100
6933 #include <linux/proc_fs.h>
6934 +#include <linux/vs_pid.h>
6936 extern struct proc_dir_entry proc_root;
6937 #ifdef CONFIG_PROC_SYSCTL
6938 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6939 struct pid *pid, struct task_struct *task);
6940 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6941 struct pid *pid, struct task_struct *task);
6942 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6943 + struct pid *pid, struct task_struct *task);
6945 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6947 extern const struct file_operations proc_maps_operations;
6948 @@ -70,11 +74,16 @@ static inline struct pid *proc_pid(struc
6949 return PROC_I(inode)->pid;
6952 -static inline struct task_struct *get_proc_task(struct inode *inode)
6953 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6955 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6958 +static inline struct task_struct *get_proc_task(struct inode *inode)
6960 + return vx_get_proc_task(inode, proc_pid(inode));
6963 static inline int proc_fd(struct inode *inode)
6965 return PROC_I(inode)->fd;
6966 diff -NurpP --minimal linux-2.6.29/fs/proc/meminfo.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/meminfo.c
6967 --- linux-2.6.29/fs/proc/meminfo.c 2009-03-24 14:22:27.000000000 +0100
6968 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/meminfo.c 2009-03-24 14:48:35.000000000 +0100
6969 @@ -41,7 +41,7 @@ static int meminfo_proc_show(struct seq_
6971 cached = global_page_state(NR_FILE_PAGES) -
6972 total_swapcache_pages - i.bufferram;
6974 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
6977 get_vmalloc_info(&vmi);
6978 diff -NurpP --minimal linux-2.6.29/fs/proc/root.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/root.c
6979 --- linux-2.6.29/fs/proc/root.c 2009-03-24 14:22:27.000000000 +0100
6980 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/root.c 2009-03-24 14:48:35.000000000 +0100
6982 #include <linux/bitops.h>
6983 #include <linux/mount.h>
6984 #include <linux/pid_namespace.h>
6985 +#include <linux/vserver/inode.h>
6987 #include "internal.h"
6989 +struct proc_dir_entry *proc_virtual;
6991 +extern void proc_vx_init(void);
6993 static int proc_test_super(struct super_block *sb, void *data)
6995 return sb->s_fs_info == data;
6996 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
6998 proc_mkdir("bus", NULL);
7003 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7004 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
7005 .proc_iops = &proc_root_inode_operations,
7006 .proc_fops = &proc_root_operations,
7007 .parent = &proc_root,
7008 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7011 int pid_ns_prepare_proc(struct pid_namespace *ns)
7012 diff -NurpP --minimal linux-2.6.29/fs/proc/uptime.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/uptime.c
7013 --- linux-2.6.29/fs/proc/uptime.c 2008-12-25 00:26:37.000000000 +0100
7014 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/proc/uptime.c 2009-02-22 22:54:25.000000000 +0100
7016 #include <linux/proc_fs.h>
7017 #include <linux/sched.h>
7018 #include <linux/time.h>
7019 +#include <linux/vserver/cvirt.h>
7020 #include <asm/cputime.h>
7022 static int proc_calc_metrics(char *page, char **start, off_t off,
7023 @@ -29,6 +30,10 @@ static int uptime_read_proc(char *page,
7024 do_posix_clock_monotonic_gettime(&uptime);
7025 monotonic_to_bootbased(&uptime);
7026 cputime_to_timespec(idletime, &idle);
7028 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7029 + vx_vsi_uptime(&uptime, &idle);
7031 len = sprintf(page, "%lu.%02lu %lu.%02lu\n",
7032 (unsigned long) uptime.tv_sec,
7033 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7034 diff -NurpP --minimal linux-2.6.29/fs/quota.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/quota.c
7035 --- linux-2.6.29/fs/quota.c 2009-03-24 14:22:27.000000000 +0100
7036 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/quota.c 2009-03-24 14:48:35.000000000 +0100
7038 #include <linux/capability.h>
7039 #include <linux/quotaops.h>
7040 #include <linux/types.h>
7041 +#include <linux/vs_context.h>
7043 /* Check validity of generic quotactl commands */
7044 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
7045 @@ -81,11 +82,11 @@ static int generic_quotactl_valid(struct
7046 if (cmd == Q_GETQUOTA) {
7047 if (((type == USRQUOTA && current_euid() != id) ||
7048 (type == GRPQUOTA && !in_egroup_p(id))) &&
7049 - !capable(CAP_SYS_ADMIN))
7050 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7053 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7054 - if (!capable(CAP_SYS_ADMIN))
7055 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7059 @@ -132,10 +133,10 @@ static int xqm_quotactl_valid(struct sup
7060 if (cmd == Q_XGETQUOTA) {
7061 if (((type == XQM_USRQUOTA && current_euid() != id) ||
7062 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7063 - !capable(CAP_SYS_ADMIN))
7064 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7066 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7067 - if (!capable(CAP_SYS_ADMIN))
7068 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7072 @@ -337,6 +338,46 @@ static int do_quotactl(struct super_bloc
7076 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7078 +#include <linux/vroot.h>
7079 +#include <linux/major.h>
7080 +#include <linux/module.h>
7081 +#include <linux/kallsyms.h>
7082 +#include <linux/vserver/debug.h>
7084 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7086 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7088 +int register_vroot_grb(vroot_grb_func *func) {
7091 + spin_lock(&vroot_grb_lock);
7092 + if (!vroot_get_real_bdev) {
7093 + vroot_get_real_bdev = func;
7096 + spin_unlock(&vroot_grb_lock);
7099 +EXPORT_SYMBOL(register_vroot_grb);
7101 +int unregister_vroot_grb(vroot_grb_func *func) {
7102 + int ret = -EINVAL;
7104 + spin_lock(&vroot_grb_lock);
7105 + if (vroot_get_real_bdev) {
7106 + vroot_get_real_bdev = NULL;
7109 + spin_unlock(&vroot_grb_lock);
7112 +EXPORT_SYMBOL(unregister_vroot_grb);
7117 * look up a superblock on which quota ops will be performed
7118 * - use the name of a block device to find the superblock thereon
7119 @@ -354,6 +395,22 @@ static inline struct super_block *quotac
7122 return ERR_CAST(bdev);
7123 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7124 + if (bdev && bdev->bd_inode &&
7125 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7126 + struct block_device *bdnew = (void *)-EINVAL;
7128 + if (vroot_get_real_bdev)
7129 + bdnew = vroot_get_real_bdev(bdev);
7131 + vxdprintk(VXD_CBIT(misc, 0),
7132 + "vroot_get_real_bdev not set");
7134 + if (IS_ERR(bdnew))
7135 + return ERR_PTR(PTR_ERR(bdnew));
7139 sb = get_super(bdev);
7142 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/bitmap.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/bitmap.c
7143 --- linux-2.6.29/fs/reiserfs/bitmap.c 2008-12-25 00:26:37.000000000 +0100
7144 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/bitmap.c 2009-02-22 22:54:25.000000000 +0100
7146 #include <linux/reiserfs_fs_sb.h>
7147 #include <linux/reiserfs_fs_i.h>
7148 #include <linux/quotaops.h>
7149 +#include <linux/vs_dlimit.h>
7151 #define PREALLOCATION_SIZE 9
7153 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
7154 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
7156 journal_mark_dirty(th, s, sbh);
7157 - if (for_unformatted)
7158 + if (for_unformatted) {
7159 + DLIMIT_FREE_BLOCK(inode, 1);
7160 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
7164 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
7165 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
7166 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
7168 int nr_allocated = 0;
7171 determine_prealloc_size(hint);
7172 if (!hint->formatted_node) {
7173 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
7174 "reiserquota: allocating %d blocks id=%u",
7175 amount_needed, hint->inode->i_uid);
7178 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
7179 - if (quota_ret) /* Quota exceeded? */
7180 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
7183 return QUOTA_EXCEEDED;
7184 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
7185 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7187 + return NO_DISK_SPACE;
7190 if (hint->preallocate && hint->prealloc_size) {
7191 #ifdef REISERQUOTA_DEBUG
7192 reiserfs_debug(s, REISERFS_DEBUG_CODE,
7193 "reiserquota: allocating (prealloc) %d blocks id=%u",
7194 hint->prealloc_size, hint->inode->i_uid);
7197 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7198 - hint->prealloc_size);
7199 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7200 + hint->prealloc_size);
7202 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
7203 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7204 + hint->prealloc_size);
7208 hint->preallocate = hint->prealloc_size = 0;
7210 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
7212 hint->inode->i_uid);
7214 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
7215 + /* Free not allocated blocks */
7216 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
7217 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7218 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7220 while (nr_allocated--)
7221 reiserfs_free_block(hint->th, hint->inode,
7222 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
7223 REISERFS_I(hint->inode)->i_prealloc_count,
7224 hint->inode->i_uid);
7226 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
7227 - hint->prealloc_size - nr_allocated -
7228 - REISERFS_I(hint->inode)->
7229 - i_prealloc_count);
7230 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
7231 + REISERFS_I(hint->inode)->i_prealloc_count;
7232 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7233 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7237 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/file.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/file.c
7238 --- linux-2.6.29/fs/reiserfs/file.c 2008-12-25 00:26:37.000000000 +0100
7239 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/file.c 2009-02-22 22:54:25.000000000 +0100
7240 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
7241 .listxattr = reiserfs_listxattr,
7242 .removexattr = reiserfs_removexattr,
7243 .permission = reiserfs_permission,
7244 + .sync_flags = reiserfs_sync_flags,
7246 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/inode.c
7247 --- linux-2.6.29/fs/reiserfs/inode.c 2009-03-24 14:22:27.000000000 +0100
7248 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/inode.c 2009-03-24 14:48:35.000000000 +0100
7250 #include <linux/writeback.h>
7251 #include <linux/quotaops.h>
7252 #include <linux/swap.h>
7253 +#include <linux/vs_dlimit.h>
7254 +#include <linux/vs_tag.h>
7256 int reiserfs_commit_write(struct file *f, struct page *page,
7257 unsigned from, unsigned to);
7258 @@ -54,6 +56,7 @@ void reiserfs_delete_inode(struct inode
7259 * stat data deletion */
7261 DQUOT_FREE_INODE(inode);
7262 + DLIMIT_FREE_INODE(inode);
7264 if (journal_end(&th, inode->i_sb, jbegin_count))
7266 @@ -1116,6 +1119,8 @@ static void init_inode(struct inode *ino
7267 struct buffer_head *bh;
7268 struct item_head *ih;
7272 //int version = ITEM_VERSION_1;
7274 bh = PATH_PLAST_BUFFER(path);
7275 @@ -1139,12 +1144,13 @@ static void init_inode(struct inode *ino
7276 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7277 unsigned long blocks;
7279 + uid = sd_v1_uid(sd);
7280 + gid = sd_v1_gid(sd);
7282 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7283 set_inode_sd_version(inode, STAT_DATA_V1);
7284 inode->i_mode = sd_v1_mode(sd);
7285 inode->i_nlink = sd_v1_nlink(sd);
7286 - inode->i_uid = sd_v1_uid(sd);
7287 - inode->i_gid = sd_v1_gid(sd);
7288 inode->i_size = sd_v1_size(sd);
7289 inode->i_atime.tv_sec = sd_v1_atime(sd);
7290 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7291 @@ -1186,11 +1192,12 @@ static void init_inode(struct inode *ino
7292 // (directories and symlinks)
7293 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7295 + uid = sd_v2_uid(sd);
7296 + gid = sd_v2_gid(sd);
7298 inode->i_mode = sd_v2_mode(sd);
7299 inode->i_nlink = sd_v2_nlink(sd);
7300 - inode->i_uid = sd_v2_uid(sd);
7301 inode->i_size = sd_v2_size(sd);
7302 - inode->i_gid = sd_v2_gid(sd);
7303 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7304 inode->i_atime.tv_sec = sd_v2_atime(sd);
7305 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7306 @@ -1220,6 +1227,10 @@ static void init_inode(struct inode *ino
7307 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7310 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7311 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7312 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7315 if (S_ISREG(inode->i_mode)) {
7316 inode->i_op = &reiserfs_file_inode_operations;
7317 @@ -1242,13 +1253,15 @@ static void init_inode(struct inode *ino
7318 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7320 struct stat_data *sd_v2 = (struct stat_data *)sd;
7321 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7322 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7325 + set_sd_v2_uid(sd_v2, uid);
7326 + set_sd_v2_gid(sd_v2, gid);
7327 set_sd_v2_mode(sd_v2, inode->i_mode);
7328 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7329 - set_sd_v2_uid(sd_v2, inode->i_uid);
7330 set_sd_v2_size(sd_v2, size);
7331 - set_sd_v2_gid(sd_v2, inode->i_gid);
7332 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7333 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7334 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7335 @@ -1763,6 +1776,10 @@ int reiserfs_new_inode(struct reiserfs_t
7337 BUG_ON(!th->t_trans_id);
7339 + if (DLIMIT_ALLOC_INODE(inode)) {
7341 + goto out_bad_dlimit;
7343 if (DQUOT_ALLOC_INODE(inode)) {
7346 @@ -1950,6 +1967,9 @@ int reiserfs_new_inode(struct reiserfs_t
7347 DQUOT_FREE_INODE(inode);
7350 + DLIMIT_FREE_INODE(inode);
7353 journal_end(th, th->t_super, th->t_blocks_allocated);
7354 /* Drop can be outside and it needs more credits so it's better to have it outside */
7356 @@ -2837,14 +2857,19 @@ int reiserfs_commit_write(struct file *f
7357 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7359 if (reiserfs_attrs(inode->i_sb)) {
7360 - if (sd_attrs & REISERFS_SYNC_FL)
7361 - inode->i_flags |= S_SYNC;
7363 - inode->i_flags &= ~S_SYNC;
7364 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7365 inode->i_flags |= S_IMMUTABLE;
7367 inode->i_flags &= ~S_IMMUTABLE;
7368 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7369 + inode->i_flags |= S_IXUNLINK;
7371 + inode->i_flags &= ~S_IXUNLINK;
7373 + if (sd_attrs & REISERFS_SYNC_FL)
7374 + inode->i_flags |= S_SYNC;
7376 + inode->i_flags &= ~S_SYNC;
7377 if (sd_attrs & REISERFS_APPEND_FL)
7378 inode->i_flags |= S_APPEND;
7380 @@ -2857,6 +2882,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7381 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7383 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7385 + if (sd_attrs & REISERFS_BARRIER_FL)
7386 + inode->i_vflags |= V_BARRIER;
7388 + inode->i_vflags &= ~V_BARRIER;
7389 + if (sd_attrs & REISERFS_COW_FL)
7390 + inode->i_vflags |= V_COW;
7392 + inode->i_vflags &= ~V_COW;
7396 @@ -2867,6 +2901,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7397 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7399 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7400 + if (inode->i_flags & S_IXUNLINK)
7401 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7403 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7405 if (inode->i_flags & S_SYNC)
7406 *sd_attrs |= REISERFS_SYNC_FL;
7408 @@ -2879,6 +2918,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7409 *sd_attrs |= REISERFS_NOTAIL_FL;
7411 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7413 + if (inode->i_vflags & V_BARRIER)
7414 + *sd_attrs |= REISERFS_BARRIER_FL;
7416 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7417 + if (inode->i_vflags & V_COW)
7418 + *sd_attrs |= REISERFS_COW_FL;
7420 + *sd_attrs &= ~REISERFS_COW_FL;
7424 @@ -3046,6 +3094,22 @@ static ssize_t reiserfs_direct_IO(int rw
7425 reiserfs_get_blocks_direct_io, NULL);
7428 +int reiserfs_sync_flags(struct inode *inode)
7430 + u16 oldflags, newflags;
7432 + oldflags = REISERFS_I(inode)->i_attrs;
7433 + newflags = oldflags;
7434 + i_attrs_to_sd_attrs(inode, &newflags);
7436 + if (oldflags ^ newflags) {
7437 + REISERFS_I(inode)->i_attrs = newflags;
7438 + inode->i_ctime = CURRENT_TIME_SEC;
7439 + mark_inode_dirty(inode);
7444 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
7446 struct inode *inode = dentry->d_inode;
7447 @@ -3099,9 +3163,11 @@ int reiserfs_setattr(struct dentry *dent
7450 error = inode_change_ok(inode, attr);
7453 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7454 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7455 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7456 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7457 error = reiserfs_chown_xattrs(inode, attr);
7460 @@ -3131,6 +3197,9 @@ int reiserfs_setattr(struct dentry *dent
7461 inode->i_uid = attr->ia_uid;
7462 if (attr->ia_valid & ATTR_GID)
7463 inode->i_gid = attr->ia_gid;
7464 + if ((attr->ia_valid & ATTR_TAG) &&
7466 + inode->i_tag = attr->ia_tag;
7467 mark_inode_dirty(inode);
7469 journal_end(&th, inode->i_sb, jbegin_count);
7470 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/ioctl.c
7471 --- linux-2.6.29/fs/reiserfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
7472 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/ioctl.c 2009-02-22 22:54:25.000000000 +0100
7474 #include <linux/mount.h>
7475 #include <linux/reiserfs_fs.h>
7476 #include <linux/time.h>
7477 +#include <linux/mount.h>
7478 #include <asm/uaccess.h>
7479 #include <linux/pagemap.h>
7480 #include <linux/smp_lock.h>
7482 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7485 - unsigned int flags;
7486 + unsigned int flags, oldflags;
7490 @@ -43,6 +44,7 @@ int reiserfs_ioctl(struct inode *inode,
7492 flags = REISERFS_I(inode)->i_attrs;
7493 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7494 + flags &= REISERFS_FL_USER_VISIBLE;
7495 return put_user(flags, (int __user *)arg);
7496 case REISERFS_IOC_SETFLAGS:{
7497 if (!reiserfs_attrs(inode->i_sb))
7498 @@ -60,6 +62,10 @@ int reiserfs_ioctl(struct inode *inode,
7502 + if (IS_BARRIER(inode)) {
7503 + vxwprintk_task(1, "messing with the barrier.");
7507 * Is it quota file? Do not allow user to mess with it
7509 @@ -84,6 +90,10 @@ int reiserfs_ioctl(struct inode *inode,
7514 + oldflags = REISERFS_I(inode)->i_attrs;
7515 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
7516 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7517 sd_attrs_to_i_attrs(flags, inode);
7518 REISERFS_I(inode)->i_attrs = flags;
7519 inode->i_ctime = CURRENT_TIME_SEC;
7520 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/namei.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/namei.c
7521 --- linux-2.6.29/fs/reiserfs/namei.c 2009-03-24 14:22:27.000000000 +0100
7522 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/namei.c 2009-03-24 14:48:35.000000000 +0100
7524 #include <linux/reiserfs_acl.h>
7525 #include <linux/reiserfs_xattr.h>
7526 #include <linux/quotaops.h>
7527 +#include <linux/vs_tag.h>
7529 #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; }
7530 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7531 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
7532 reiserfs_write_unlock(dir->i_sb);
7533 return ERR_PTR(-EACCES);
7535 + dx_propagate_tag(nd, inode);
7537 /* Propogate the priv_object flag so we know we're in the priv tree */
7538 if (is_reiserfs_priv_object(dir))
7539 @@ -586,6 +588,7 @@ static int new_inode_init(struct inode *
7541 inode->i_gid = current_fsgid();
7543 + inode->i_tag = dx_current_fstag(inode->i_sb);
7547 @@ -1540,6 +1543,7 @@ const struct inode_operations reiserfs_d
7548 .listxattr = reiserfs_listxattr,
7549 .removexattr = reiserfs_removexattr,
7550 .permission = reiserfs_permission,
7551 + .sync_flags = reiserfs_sync_flags,
7555 @@ -1556,6 +1560,7 @@ const struct inode_operations reiserfs_s
7556 .listxattr = reiserfs_listxattr,
7557 .removexattr = reiserfs_removexattr,
7558 .permission = reiserfs_permission,
7559 + .sync_flags = reiserfs_sync_flags,
7563 @@ -1569,5 +1574,6 @@ const struct inode_operations reiserfs_s
7564 .listxattr = reiserfs_listxattr,
7565 .removexattr = reiserfs_removexattr,
7566 .permission = reiserfs_permission,
7567 + .sync_flags = reiserfs_sync_flags,
7570 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/stree.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/stree.c
7571 --- linux-2.6.29/fs/reiserfs/stree.c 2008-12-25 00:26:37.000000000 +0100
7572 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/stree.c 2009-02-22 22:54:25.000000000 +0100
7574 #include <linux/reiserfs_fs.h>
7575 #include <linux/buffer_head.h>
7576 #include <linux/quotaops.h>
7577 +#include <linux/vs_dlimit.h>
7579 /* Does the buffer contain a disk block which is in the tree. */
7580 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
7581 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
7582 "reiserquota delete_item(): freeing %u, id=%u type=%c",
7583 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
7585 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7586 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7588 /* Return deleted body length */
7589 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
7591 DQUOT_FREE_SPACE_NODIRTY(inode,
7593 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
7597 @@ -1734,6 +1737,7 @@ int reiserfs_cut_from_item(struct reiser
7598 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
7599 quota_cut_bytes, p_s_inode->i_uid, '?');
7601 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7602 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7605 @@ -1975,6 +1979,11 @@ int reiserfs_paste_into_item(struct reis
7606 pathrelse(p_s_search_path);
7609 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
7610 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7611 + pathrelse(p_s_search_path);
7614 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
7616 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
7617 @@ -2027,6 +2036,7 @@ int reiserfs_paste_into_item(struct reis
7618 n_pasted_size, inode->i_uid,
7619 key2type(&(p_s_key->on_disk_key)));
7621 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
7622 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7625 @@ -2064,6 +2074,11 @@ int reiserfs_insert_item(struct reiserfs
7626 pathrelse(p_s_path);
7629 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
7630 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7631 + pathrelse(p_s_path);
7635 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
7636 IH_SIZE + ih_item_len(p_s_ih));
7637 @@ -2111,7 +2126,9 @@ int reiserfs_insert_item(struct reiserfs
7638 "reiserquota insert_item(): freeing %u id=%u type=%c",
7639 quota_bytes, inode->i_uid, head2type(p_s_ih));
7643 + DLIMIT_FREE_SPACE(inode, quota_bytes);
7644 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7648 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/super.c
7649 --- linux-2.6.29/fs/reiserfs/super.c 2009-03-24 14:22:27.000000000 +0100
7650 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/super.c 2009-03-24 14:48:35.000000000 +0100
7651 @@ -902,6 +902,14 @@ static int reiserfs_parse_options(struct
7652 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7653 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7655 +#ifndef CONFIG_TAGGING_NONE
7656 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7657 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7658 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7660 +#ifdef CONFIG_PROPAGATE
7661 + {"tag",.arg_required = 'T',.values = NULL},
7663 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7664 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7665 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7666 @@ -1195,6 +1203,12 @@ static int reiserfs_remount(struct super
7667 handle_quota_files(s, qf_names, &qfmt);
7670 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7671 + !(s->s_flags & MS_TAGGED)) {
7672 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
7678 /* Add options that are safe here */
7679 @@ -1659,6 +1673,10 @@ static int reiserfs_fill_super(struct su
7683 + /* map mount option tagxid */
7684 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7685 + s->s_flags |= MS_TAGGED;
7687 rs = SB_DISK_SUPER_BLOCK(s);
7688 /* Let's do basic sanity check to verify that underlying device is not
7689 smaller than the filesystem. If the check fails then abort and scream,
7690 diff -NurpP --minimal linux-2.6.29/fs/reiserfs/xattr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/xattr.c
7691 --- linux-2.6.29/fs/reiserfs/xattr.c 2008-12-25 00:26:37.000000000 +0100
7692 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/reiserfs/xattr.c 2009-02-22 22:54:25.000000000 +0100
7694 #include <linux/namei.h>
7695 #include <linux/errno.h>
7696 #include <linux/fs.h>
7697 +#include <linux/mount.h>
7698 #include <linux/file.h>
7699 #include <linux/pagemap.h>
7700 #include <linux/xattr.h>
7701 diff -NurpP --minimal linux-2.6.29/fs/stat.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/stat.c
7702 --- linux-2.6.29/fs/stat.c 2009-03-24 14:22:36.000000000 +0100
7703 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/stat.c 2009-03-24 14:48:35.000000000 +0100
7704 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7705 stat->nlink = inode->i_nlink;
7706 stat->uid = inode->i_uid;
7707 stat->gid = inode->i_gid;
7708 + stat->tag = inode->i_tag;
7709 stat->rdev = inode->i_rdev;
7710 stat->atime = inode->i_atime;
7711 stat->mtime = inode->i_mtime;
7712 diff -NurpP --minimal linux-2.6.29/fs/super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/super.c
7713 --- linux-2.6.29/fs/super.c 2009-03-24 14:22:36.000000000 +0100
7714 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/super.c 2009-03-24 16:32:06.000000000 +0100
7716 #include <linux/mutex.h>
7717 #include <linux/file.h>
7718 #include <linux/async.h>
7719 +#include <linux/devpts_fs.h>
7720 +#include <linux/proc_fs.h>
7721 +#include <linux/vs_context.h>
7722 #include <asm/uaccess.h>
7723 #include "internal.h"
7725 @@ -918,12 +921,18 @@ struct vfsmount *
7726 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7728 struct vfsmount *mnt;
7729 + struct super_block *sb;
7730 char *secdata = NULL;
7734 return ERR_PTR(-ENODEV);
7737 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7738 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7742 mnt = alloc_vfsmnt(name);
7744 @@ -942,9 +951,17 @@ vfs_kern_mount(struct file_system_type *
7745 error = type->get_sb(type, flags, name, data, mnt);
7747 goto out_free_secdata;
7748 - BUG_ON(!mnt->mnt_sb);
7750 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7755 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7756 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7757 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7760 + error = security_sb_kern_mount(sb, flags, secdata);
7764 diff -NurpP --minimal linux-2.6.29/fs/sysfs/mount.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/sysfs/mount.c
7765 --- linux-2.6.29/fs/sysfs/mount.c 2008-12-25 00:26:37.000000000 +0100
7766 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/sysfs/mount.c 2009-02-22 22:54:25.000000000 +0100
7771 -/* Random magic number */
7772 -#define SYSFS_MAGIC 0x62656572
7774 static struct vfsmount *sysfs_mount;
7775 struct super_block * sysfs_sb = NULL;
7776 @@ -47,7 +45,7 @@ static int sysfs_fill_super(struct super
7778 sb->s_blocksize = PAGE_CACHE_SIZE;
7779 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7780 - sb->s_magic = SYSFS_MAGIC;
7781 + sb->s_magic = SYSFS_SUPER_MAGIC;
7782 sb->s_op = &sysfs_ops;
7783 sb->s_time_gran = 1;
7785 diff -NurpP --minimal linux-2.6.29/fs/utimes.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/utimes.c
7786 --- linux-2.6.29/fs/utimes.c 2009-03-24 14:22:37.000000000 +0100
7787 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/utimes.c 2009-02-22 22:54:25.000000000 +0100
7789 #include <linux/stat.h>
7790 #include <linux/utime.h>
7791 #include <linux/syscalls.h>
7792 +#include <linux/mount.h>
7793 +#include <linux/vs_cowbl.h>
7794 #include <asm/uaccess.h>
7795 #include <asm/unistd.h>
7797 diff -NurpP --minimal linux-2.6.29/fs/xattr.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xattr.c
7798 --- linux-2.6.29/fs/xattr.c 2009-03-24 14:22:37.000000000 +0100
7799 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xattr.c 2009-03-24 14:48:35.000000000 +0100
7801 #include <linux/module.h>
7802 #include <linux/fsnotify.h>
7803 #include <linux/audit.h>
7804 +#include <linux/mount.h>
7805 #include <asm/uaccess.h>
7808 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_ioctl.c
7809 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_ioctl.c 2009-03-24 14:22:37.000000000 +0100
7810 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_ioctl.c 2009-03-24 14:48:35.000000000 +0100
7811 @@ -769,6 +769,10 @@ xfs_merge_ioc_xflags(
7812 xflags |= XFS_XFLAG_IMMUTABLE;
7814 xflags &= ~XFS_XFLAG_IMMUTABLE;
7815 + if (flags & FS_IXUNLINK_FL)
7816 + xflags |= XFS_XFLAG_IXUNLINK;
7818 + xflags &= ~XFS_XFLAG_IXUNLINK;
7819 if (flags & FS_APPEND_FL)
7820 xflags |= XFS_XFLAG_APPEND;
7822 @@ -797,6 +801,8 @@ xfs_di2lxflags(
7824 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7825 flags |= FS_IMMUTABLE_FL;
7826 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7827 + flags |= FS_IXUNLINK_FL;
7828 if (di_flags & XFS_DIFLAG_APPEND)
7829 flags |= FS_APPEND_FL;
7830 if (di_flags & XFS_DIFLAG_SYNC)
7831 @@ -855,6 +861,8 @@ xfs_set_diflags(
7832 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7833 if (xflags & XFS_XFLAG_IMMUTABLE)
7834 di_flags |= XFS_DIFLAG_IMMUTABLE;
7835 + if (xflags & XFS_XFLAG_IXUNLINK)
7836 + di_flags |= XFS_DIFLAG_IXUNLINK;
7837 if (xflags & XFS_XFLAG_APPEND)
7838 di_flags |= XFS_DIFLAG_APPEND;
7839 if (xflags & XFS_XFLAG_SYNC)
7840 @@ -897,6 +905,10 @@ xfs_diflags_to_linux(
7841 inode->i_flags |= S_IMMUTABLE;
7843 inode->i_flags &= ~S_IMMUTABLE;
7844 + if (xflags & XFS_XFLAG_IXUNLINK)
7845 + inode->i_flags |= S_IXUNLINK;
7847 + inode->i_flags &= ~S_IXUNLINK;
7848 if (xflags & XFS_XFLAG_APPEND)
7849 inode->i_flags |= S_APPEND;
7851 @@ -1371,10 +1383,18 @@ xfs_file_ioctl(
7852 case XFS_IOC_FSGETXATTRA:
7853 return xfs_ioc_fsgetxattr(ip, 1, arg);
7854 case XFS_IOC_FSSETXATTR:
7855 + if (IS_BARRIER(inode)) {
7856 + vxwprintk_task(1, "messing with the barrier.");
7857 + return -XFS_ERROR(EACCES);
7859 return xfs_ioc_fssetxattr(ip, filp, arg);
7860 case XFS_IOC_GETXFLAGS:
7861 return xfs_ioc_getxflags(ip, arg);
7862 case XFS_IOC_SETXFLAGS:
7863 + if (IS_BARRIER(inode)) {
7864 + vxwprintk_task(1, "messing with the barrier.");
7865 + return -XFS_ERROR(EACCES);
7867 return xfs_ioc_setxflags(ip, filp, arg);
7869 case XFS_IOC_FSSETDM: {
7870 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_iops.c
7871 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_iops.c 2009-03-24 14:22:37.000000000 +0100
7872 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_iops.c 2009-03-24 16:33:10.000000000 +0100
7874 #include <linux/security.h>
7875 #include <linux/falloc.h>
7876 #include <linux/fiemap.h>
7877 +#include <linux/vs_tag.h>
7880 * Bring the atime in the XFS inode uptodate.
7881 @@ -552,6 +553,7 @@ xfs_vn_getattr(
7882 stat->nlink = ip->i_d.di_nlink;
7883 stat->uid = ip->i_d.di_uid;
7884 stat->gid = ip->i_d.di_gid;
7885 + stat->tag = ip->i_d.di_tag;
7886 stat->ino = ip->i_ino;
7888 stat->ino += mp->m_inoadd;
7889 @@ -591,6 +593,12 @@ xfs_vn_getattr(
7893 +xfs_vn_sync_xflags(struct inode *inode)
7895 + return -xfs_sync_xflags(XFS_I(inode));
7900 struct dentry *dentry,
7901 struct iattr *iattr)
7902 @@ -748,6 +756,7 @@ static const struct inode_operations xfs
7903 .listxattr = xfs_vn_listxattr,
7904 .fallocate = xfs_vn_fallocate,
7905 .fiemap = xfs_vn_fiemap,
7906 + .sync_flags = xfs_vn_sync_xflags,
7909 static const struct inode_operations xfs_dir_inode_operations = {
7910 @@ -773,6 +782,7 @@ static const struct inode_operations xfs
7911 .getxattr = generic_getxattr,
7912 .removexattr = generic_removexattr,
7913 .listxattr = xfs_vn_listxattr,
7914 + .sync_flags = xfs_vn_sync_xflags,
7917 static const struct inode_operations xfs_dir_ci_inode_operations = {
7918 @@ -822,6 +832,10 @@ xfs_diflags_to_iflags(
7919 inode->i_flags |= S_IMMUTABLE;
7921 inode->i_flags &= ~S_IMMUTABLE;
7922 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7923 + inode->i_flags |= S_IXUNLINK;
7925 + inode->i_flags &= ~S_IXUNLINK;
7926 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7927 inode->i_flags |= S_APPEND;
7929 @@ -834,6 +848,15 @@ xfs_diflags_to_iflags(
7930 inode->i_flags |= S_NOATIME;
7932 inode->i_flags &= ~S_NOATIME;
7934 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7935 + inode->i_vflags |= V_BARRIER;
7937 + inode->i_vflags &= ~V_BARRIER;
7938 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7939 + inode->i_vflags |= V_COW;
7941 + inode->i_vflags &= ~V_COW;
7945 @@ -862,6 +885,7 @@ xfs_setup_inode(
7946 inode->i_nlink = ip->i_d.di_nlink;
7947 inode->i_uid = ip->i_d.di_uid;
7948 inode->i_gid = ip->i_d.di_gid;
7949 + inode->i_tag = ip->i_d.di_tag;
7951 switch (inode->i_mode & S_IFMT) {
7953 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_linux.h
7954 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_linux.h 2009-03-24 14:22:37.000000000 +0100
7955 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_linux.h 2009-03-25 01:26:04.000000000 +0100
7958 #define current_cpu() (raw_smp_processor_id())
7959 #define current_pid() (current->pid)
7960 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
7961 #define current_test_flags(f) (current->flags & (f))
7962 #define current_set_flags_nested(sp, f) \
7963 (*(sp) = current->flags, current->flags |= (f))
7964 diff -NurpP --minimal linux-2.6.29/fs/xfs/linux-2.6/xfs_super.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_super.c
7965 --- linux-2.6.29/fs/xfs/linux-2.6/xfs_super.c 2009-03-24 14:22:37.000000000 +0100
7966 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/linux-2.6/xfs_super.c 2009-03-25 01:48:51.000000000 +0100
7967 @@ -120,6 +120,9 @@ mempool_t *xfs_ioend_pool;
7968 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
7969 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
7970 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
7971 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7972 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7973 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7976 * Table driven mount option parser.
7977 @@ -128,10 +131,14 @@ mempool_t *xfs_ioend_pool;
7978 * in the future, too.
7981 + Opt_tag, Opt_notag,
7982 Opt_barrier, Opt_nobarrier, Opt_err
7985 static const match_table_t tokens = {
7986 + {Opt_tag, "tagxid"},
7988 + {Opt_notag, "notag"},
7989 {Opt_barrier, "barrier"},
7990 {Opt_nobarrier, "nobarrier"},
7992 @@ -395,6 +402,19 @@ xfs_parseargs(
7993 } else if (!strcmp(this_char, "irixsgid")) {
7995 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7996 +#ifndef CONFIG_TAGGING_NONE
7997 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7998 + mp->m_flags |= XFS_MOUNT_TAGGED;
7999 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8000 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
8001 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8002 + mp->m_flags |= XFS_MOUNT_TAGGED;
8004 +#ifdef CONFIG_PROPAGATE
8005 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8007 + mp->m_flags |= XFS_MOUNT_TAGGED;
8011 "XFS: unknown mount option [%s].", this_char);
8012 @@ -1221,6 +1241,16 @@ xfs_fs_remount(
8014 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8017 + if (!(sb->s_flags & MS_TAGGED)) {
8019 + "XFS: %s: tagging not permitted on remount.\n",
8028 * Logically we would return an error here to prevent
8029 @@ -1480,6 +1510,9 @@ xfs_fs_fill_super(
8031 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
8033 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8034 + sb->s_flags |= MS_TAGGED;
8037 sb->s_magic = XFS_SB_MAGIC;
8038 sb->s_blocksize = mp->m_sb.sb_blocksize;
8039 diff -NurpP --minimal linux-2.6.29/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/quota/xfs_qm_syscalls.c
8040 --- linux-2.6.29/fs/xfs/quota/xfs_qm_syscalls.c 2009-03-24 14:22:37.000000000 +0100
8041 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/quota/xfs_qm_syscalls.c 2009-03-24 14:48:35.000000000 +0100
8042 @@ -426,7 +426,7 @@ xfs_qm_scall_quotaon(
8046 - if (!capable(CAP_SYS_ADMIN))
8047 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8048 return XFS_ERROR(EPERM);
8050 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
8051 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_dinode.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_dinode.h
8052 --- linux-2.6.29/fs/xfs/xfs_dinode.h 2009-03-24 14:22:37.000000000 +0100
8053 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_dinode.h 2009-03-24 16:38:27.000000000 +0100
8054 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
8055 __be32 di_gid; /* owner's group id */
8056 __be32 di_nlink; /* number of links to file */
8057 __be16 di_projid; /* owner's project id */
8058 - __u8 di_pad[8]; /* unused, zeroed space */
8059 + __be16 di_tag; /* context tagging */
8060 + __be16 di_vflags; /* vserver specific flags */
8061 + __u8 di_pad[4]; /* unused, zeroed space */
8062 __be16 di_flushiter; /* incremented on flush */
8063 xfs_timestamp_t di_atime; /* time last accessed */
8064 xfs_timestamp_t di_mtime; /* time last modified */
8065 @@ -181,6 +183,8 @@ static inline void xfs_dinode_put_rdev(s
8066 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8067 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8068 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8069 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8071 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8072 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8073 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8074 @@ -196,6 +200,7 @@ static inline void xfs_dinode_put_rdev(s
8075 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8076 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8077 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8078 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8080 #ifdef CONFIG_XFS_RT
8081 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8082 @@ -208,6 +213,10 @@ static inline void xfs_dinode_put_rdev(s
8083 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8084 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8085 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8086 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8087 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8088 + XFS_DIFLAG_IXUNLINK)
8090 +#define XFS_DIVFLAG_BARRIER 0x01
8091 +#define XFS_DIVFLAG_COW 0x02
8093 #endif /* __XFS_DINODE_H__ */
8094 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_fs.h
8095 --- linux-2.6.29/fs/xfs/xfs_fs.h 2009-03-24 14:22:37.000000000 +0100
8096 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_fs.h 2009-03-24 14:48:35.000000000 +0100
8097 @@ -67,6 +67,9 @@ struct fsxattr {
8098 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8099 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8100 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8101 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8102 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8103 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8104 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8107 @@ -289,7 +292,8 @@ typedef struct xfs_bstat {
8108 __s32 bs_extents; /* number of extents */
8109 __u32 bs_gen; /* generation count */
8110 __u16 bs_projid; /* project id */
8111 - unsigned char bs_pad[14]; /* pad space, unused */
8112 + __u16 bs_tag; /* context tagging */
8113 + unsigned char bs_pad[12]; /* pad space, unused */
8114 __u32 bs_dmevmask; /* DMIG event mask */
8115 __u16 bs_dmstate; /* DMIG state info */
8116 __u16 bs_aextents; /* attribute number of extents */
8117 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_ialloc.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_ialloc.c
8118 --- linux-2.6.29/fs/xfs/xfs_ialloc.c 2009-03-24 14:22:37.000000000 +0100
8119 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_ialloc.c 2009-03-24 17:03:17.000000000 +0100
8121 #include "xfs_error.h"
8122 #include "xfs_bmap.h"
8126 * Allocation group level functions.
8128 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_inode.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_inode.c
8129 --- linux-2.6.29/fs/xfs/xfs_inode.c 2009-03-24 14:22:37.000000000 +0100
8130 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_inode.c 2009-03-25 01:42:50.000000000 +0100
8131 @@ -250,6 +250,7 @@ xfs_inotobp(
8135 +#include <linux/vs_tag.h>
8138 * This routine is called to map an inode to the buffer containing
8139 @@ -645,15 +646,25 @@ xfs_iformat_btree(
8141 xfs_dinode_from_disk(
8143 - xfs_dinode_t *from)
8144 + xfs_dinode_t *from,
8147 + uint32_t uid, gid, tag;
8149 to->di_magic = be16_to_cpu(from->di_magic);
8150 to->di_mode = be16_to_cpu(from->di_mode);
8151 to->di_version = from ->di_version;
8152 to->di_format = from->di_format;
8153 to->di_onlink = be16_to_cpu(from->di_onlink);
8154 - to->di_uid = be32_to_cpu(from->di_uid);
8155 - to->di_gid = be32_to_cpu(from->di_gid);
8157 + uid = be32_to_cpu(from->di_uid);
8158 + gid = be32_to_cpu(from->di_gid);
8159 + tag = be16_to_cpu(from->di_tag);
8161 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8162 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8163 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8165 to->di_nlink = be32_to_cpu(from->di_nlink);
8166 to->di_projid = be16_to_cpu(from->di_projid);
8167 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8168 @@ -674,21 +685,26 @@ xfs_dinode_from_disk(
8169 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8170 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8171 to->di_flags = be16_to_cpu(from->di_flags);
8172 + to->di_vflags = be16_to_cpu(from->di_vflags);
8173 to->di_gen = be32_to_cpu(from->di_gen);
8179 - xfs_icdinode_t *from)
8180 + xfs_icdinode_t *from,
8183 to->di_magic = cpu_to_be16(from->di_magic);
8184 to->di_mode = cpu_to_be16(from->di_mode);
8185 to->di_version = from ->di_version;
8186 to->di_format = from->di_format;
8187 to->di_onlink = cpu_to_be16(from->di_onlink);
8188 - to->di_uid = cpu_to_be32(from->di_uid);
8189 - to->di_gid = cpu_to_be32(from->di_gid);
8191 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8192 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8193 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8195 to->di_nlink = cpu_to_be32(from->di_nlink);
8196 to->di_projid = cpu_to_be16(from->di_projid);
8197 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8198 @@ -709,12 +725,14 @@ xfs_dinode_to_disk(
8199 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8200 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8201 to->di_flags = cpu_to_be16(from->di_flags);
8202 + to->di_vflags = cpu_to_be16(from->di_vflags);
8203 to->di_gen = cpu_to_be32(from->di_gen);
8208 - __uint16_t di_flags)
8209 + __uint16_t di_flags,
8210 + __uint16_t di_vflags)
8214 @@ -725,6 +743,8 @@ _xfs_dic2xflags(
8215 flags |= XFS_XFLAG_PREALLOC;
8216 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8217 flags |= XFS_XFLAG_IMMUTABLE;
8218 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8219 + flags |= XFS_XFLAG_IXUNLINK;
8220 if (di_flags & XFS_DIFLAG_APPEND)
8221 flags |= XFS_XFLAG_APPEND;
8222 if (di_flags & XFS_DIFLAG_SYNC)
8223 @@ -749,6 +769,10 @@ _xfs_dic2xflags(
8224 flags |= XFS_XFLAG_FILESTREAM;
8227 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8228 + flags |= FS_BARRIER_FL;
8229 + if (di_vflags & XFS_DIVFLAG_COW)
8230 + flags |= FS_COW_FL;
8234 @@ -758,7 +782,7 @@ xfs_ip2xflags(
8236 xfs_icdinode_t *dic = &ip->i_d;
8238 - return _xfs_dic2xflags(dic->di_flags) |
8239 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8240 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8243 @@ -766,7 +790,8 @@ uint
8247 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8248 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8249 + be16_to_cpu(dip->di_vflags)) |
8250 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8253 @@ -802,7 +827,6 @@ xfs_iread(
8256 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8259 * If we got something that isn't an inode it means someone
8260 * (nfs or dmi) has a stale handle.
8261 @@ -827,7 +851,8 @@ xfs_iread(
8262 * Otherwise, just get the truly permanent information.
8265 - xfs_dinode_from_disk(&ip->i_d, dip);
8266 + xfs_dinode_from_disk(&ip->i_d, dip,
8267 + mp->m_flags & XFS_MOUNT_TAGGED);
8268 error = xfs_iformat(ip, dip);
8271 @@ -1027,6 +1052,7 @@ xfs_ialloc(
8272 ASSERT(ip->i_d.di_nlink == nlink);
8273 ip->i_d.di_uid = current_fsuid();
8274 ip->i_d.di_gid = current_fsgid();
8275 + ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
8276 ip->i_d.di_projid = prid;
8277 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8279 @@ -1087,6 +1113,7 @@ xfs_ialloc(
8280 ip->i_d.di_dmevmask = 0;
8281 ip->i_d.di_dmstate = 0;
8282 ip->i_d.di_flags = 0;
8283 + ip->i_d.di_vflags = 0;
8284 flags = XFS_ILOG_CORE;
8285 switch (mode & S_IFMT) {
8287 @@ -2161,6 +2188,7 @@ xfs_ifree(
8289 ip->i_d.di_mode = 0; /* mark incore inode as free */
8290 ip->i_d.di_flags = 0;
8291 + ip->i_d.di_vflags = 0;
8292 ip->i_d.di_dmevmask = 0;
8293 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8294 ip->i_df.if_ext_max =
8295 @@ -3128,7 +3156,8 @@ xfs_iflush_int(
8296 * because if the inode is dirty at all the core must
8299 - xfs_dinode_to_disk(dip, &ip->i_d);
8300 + xfs_dinode_to_disk(dip, &ip->i_d,
8301 + mp->m_flags & XFS_MOUNT_TAGGED);
8303 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8304 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8305 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_inode.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_inode.h
8306 --- linux-2.6.29/fs/xfs/xfs_inode.h 2009-03-24 14:22:37.000000000 +0100
8307 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_inode.h 2009-03-25 01:10:35.000000000 +0100
8308 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
8309 __uint32_t di_gid; /* owner's group id */
8310 __uint32_t di_nlink; /* number of links to file */
8311 __uint16_t di_projid; /* owner's project id */
8312 - __uint8_t di_pad[8]; /* unused, zeroed space */
8313 + __uint16_t di_tag; /* context tagging */
8314 + __uint16_t di_vflags; /* vserver specific flags */
8315 + __uint8_t di_pad[4]; /* unused, zeroed space */
8316 __uint16_t di_flushiter; /* incremented on flush */
8317 xfs_ictimestamp_t di_atime; /* time last accessed */
8318 xfs_ictimestamp_t di_mtime; /* time last modified */
8319 @@ -589,9 +591,9 @@ int xfs_itobp(struct xfs_mount *, struc
8320 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8321 struct xfs_inode *, xfs_daddr_t, uint);
8322 void xfs_dinode_from_disk(struct xfs_icdinode *,
8323 - struct xfs_dinode *);
8324 + struct xfs_dinode *, int);
8325 void xfs_dinode_to_disk(struct xfs_dinode *,
8326 - struct xfs_icdinode *);
8327 + struct xfs_icdinode *, int);
8328 void xfs_idestroy_fork(struct xfs_inode *, int);
8329 void xfs_idata_realloc(struct xfs_inode *, int, int);
8330 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8331 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_itable.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_itable.c
8332 --- linux-2.6.29/fs/xfs/xfs_itable.c 2009-03-24 14:22:37.000000000 +0100
8333 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_itable.c 2009-03-24 14:48:35.000000000 +0100
8334 @@ -82,6 +82,7 @@ xfs_bulkstat_one_iget(
8335 buf->bs_mode = dic->di_mode;
8336 buf->bs_uid = dic->di_uid;
8337 buf->bs_gid = dic->di_gid;
8338 + buf->bs_tag = dic->di_tag;
8339 buf->bs_size = dic->di_size;
8340 vn_atime_to_bstime(VFS_I(ip), &buf->bs_atime);
8341 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
8342 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_log_recover.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_log_recover.c
8343 --- linux-2.6.29/fs/xfs/xfs_log_recover.c 2009-03-24 14:22:37.000000000 +0100
8344 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_log_recover.c 2009-03-24 17:17:15.000000000 +0100
8345 @@ -2421,7 +2421,8 @@ xlog_recover_do_inode_trans(
8348 /* The core is in in-core format */
8349 - xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8350 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8351 + mp->m_flags & XFS_MOUNT_TAGGED);
8353 /* the rest is in on-disk format */
8354 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8355 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_mount.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_mount.h
8356 --- linux-2.6.29/fs/xfs/xfs_mount.h 2009-03-24 14:22:37.000000000 +0100
8357 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_mount.h 2009-03-24 14:48:35.000000000 +0100
8358 @@ -371,6 +371,7 @@ typedef struct xfs_mount {
8360 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8362 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8365 * Default minimum read and write sizes.
8366 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_vnodeops.c linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_vnodeops.c
8367 --- linux-2.6.29/fs/xfs/xfs_vnodeops.c 2009-03-24 14:22:37.000000000 +0100
8368 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_vnodeops.c 2009-03-24 17:18:40.000000000 +0100
8370 #include "xfs_filestream.h"
8371 #include "xfs_vnodeops.h"
8375 +xfs_get_inode_flags(
8378 + struct inode *inode = VFS_I(ip);
8379 + unsigned int flags = inode->i_flags;
8380 + unsigned int vflags = inode->i_vflags;
8382 + if (flags & S_IMMUTABLE)
8383 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8385 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8386 + if (flags & S_IXUNLINK)
8387 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8389 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8391 + if (vflags & V_BARRIER)
8392 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8394 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8395 + if (vflags & V_COW)
8396 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8398 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8405 + struct xfs_mount *mp = ip->i_mount;
8406 + struct xfs_trans *tp;
8407 + unsigned int lock_flags = 0;
8410 + xfs_itrace_entry(ip);
8412 + if (mp->m_flags & XFS_MOUNT_RDONLY)
8413 + return XFS_ERROR(EROFS);
8416 + * we acquire the inode lock and do an error checking pass.
8418 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8419 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8421 + goto error_return;
8423 + lock_flags = XFS_ILOCK_EXCL;
8424 + xfs_ilock(ip, lock_flags);
8426 + xfs_trans_ijoin(tp, ip, lock_flags);
8427 + xfs_trans_ihold(tp, ip);
8429 + xfs_get_inode_flags(ip);
8430 + // xfs_diflags_to_linux(ip);
8432 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8433 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8435 + XFS_STATS_INC(xs_ig_attrchg);
8438 + * If this is a synchronous mount, make sure that the
8439 + * transaction goes to disk before returning to the user.
8441 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8442 + xfs_trans_set_sync(tp);
8443 + code = xfs_trans_commit(tp, 0);
8444 + xfs_iunlock(ip, lock_flags);
8451 + xfs_trans_cancel(tp, 0);
8453 + xfs_iunlock(ip, lock_flags);
8459 struct xfs_inode *ip,
8460 @@ -68,6 +152,7 @@ xfs_setattr(
8461 uint commit_flags=0;
8462 uid_t uid=0, iuid=0;
8463 gid_t gid=0, igid=0;
8464 + tag_t tag=0, itag=0;
8466 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8467 int need_iolock = 1;
8468 @@ -164,7 +249,7 @@ xfs_setattr(
8470 * Change file ownership. Must be the owner or privileged.
8472 - if (mask & (ATTR_UID|ATTR_GID)) {
8473 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8475 * These IDs could have changed since we last looked at them.
8476 * But, we're assured that if the ownership did change
8477 @@ -173,15 +258,19 @@ xfs_setattr(
8479 iuid = ip->i_d.di_uid;
8480 igid = ip->i_d.di_gid;
8481 + itag = ip->i_d.di_tag;
8482 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8483 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8484 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8487 * Do a quota reservation only if uid/gid is actually
8490 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8491 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
8492 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8493 + (XFS_IS_GQUOTA_ON(mp) && itag != tag)) {
8494 + /* TODO: handle tagging? */
8496 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
8497 capable(CAP_FOWNER) ?
8498 @@ -334,7 +423,7 @@ xfs_setattr(
8500 * Change file ownership. Must be the owner or privileged.
8502 - if (mask & (ATTR_UID|ATTR_GID)) {
8503 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8505 * CAP_FSETID overrides the following restrictions:
8507 @@ -350,6 +439,10 @@ xfs_setattr(
8508 * Change the ownerships and register quota modifications
8509 * in the transaction.
8511 + if (itag != tag) {
8512 + ip->i_d.di_tag = tag;
8513 + inode->i_tag = tag;
8516 if (XFS_IS_UQUOTA_ON(mp)) {
8517 ASSERT(mask & ATTR_UID);
8518 diff -NurpP --minimal linux-2.6.29/fs/xfs/xfs_vnodeops.h linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_vnodeops.h
8519 --- linux-2.6.29/fs/xfs/xfs_vnodeops.h 2009-03-24 14:22:37.000000000 +0100
8520 +++ linux-2.6.29-vs2.3.0.36.9-pre3/fs/xfs/xfs_vnodeops.h 2009-03-24 17:19:30.000000000 +0100
8521 @@ -14,6 +14,7 @@ struct xfs_inode;
8525 +int xfs_sync_xflags(struct xfs_inode *ip);
8526 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8527 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8528 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8529 diff -NurpP --minimal linux-2.6.29/include/asm-generic/tlb.h linux-2.6.29-vs2.3.0.36.9-pre3/include/asm-generic/tlb.h
8530 --- linux-2.6.29/include/asm-generic/tlb.h 2008-12-25 00:26:37.000000000 +0100
8531 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/asm-generic/tlb.h 2009-02-22 22:54:26.000000000 +0100
8533 #define _ASM_GENERIC__TLB_H
8535 #include <linux/swap.h>
8536 +#include <linux/vs_memory.h>
8537 #include <asm/pgalloc.h>
8538 #include <asm/tlbflush.h>
8540 diff -NurpP --minimal linux-2.6.29/include/linux/capability.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/capability.h
8541 --- linux-2.6.29/include/linux/capability.h 2009-03-24 14:22:41.000000000 +0100
8542 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/capability.h 2009-03-24 14:48:35.000000000 +0100
8543 @@ -285,6 +285,7 @@ struct cpu_vfs_cap_data {
8544 arbitrary SCSI commands */
8545 /* Allow setting encryption key on loopback filesystem */
8546 /* Allow setting zone reclaim policy */
8547 +/* Allow the selection of a security context */
8549 #define CAP_SYS_ADMIN 21
8551 @@ -357,7 +358,13 @@ struct cpu_vfs_cap_data {
8553 #define CAP_MAC_ADMIN 33
8555 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8556 +/* Allow context manipulations */
8557 +/* Allow changing context info on files */
8559 +#define CAP_CONTEXT 34
8562 +#define CAP_LAST_CAP CAP_CONTEXT
8564 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8566 diff -NurpP --minimal linux-2.6.29/include/linux/devpts_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/devpts_fs.h
8567 --- linux-2.6.29/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8568 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/devpts_fs.h 2009-02-22 22:54:26.000000000 +0100
8569 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8574 #endif /* _LINUX_DEVPTS_FS_H */
8575 diff -NurpP --minimal linux-2.6.29/include/linux/ext2_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/ext2_fs.h
8576 --- linux-2.6.29/include/linux/ext2_fs.h 2009-03-24 14:22:41.000000000 +0100
8577 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/ext2_fs.h 2009-03-24 15:39:54.000000000 +0100
8578 @@ -189,8 +189,12 @@ struct ext2_group_desc
8579 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8580 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8581 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8582 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8583 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8585 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8586 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8588 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8589 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8591 @@ -271,7 +275,7 @@ struct ext2_inode {
8593 __u8 l_i_frag; /* Fragment number */
8594 __u8 l_i_fsize; /* Fragment size */
8596 + __u16 l_i_tag; /* Context Tag */
8597 __le16 l_i_uid_high; /* these 2 fields */
8598 __le16 l_i_gid_high; /* were reserved2[0] */
8599 __u32 l_i_reserved2;
8600 @@ -303,6 +307,7 @@ struct ext2_inode {
8601 #define i_gid_low i_gid
8602 #define i_uid_high osd2.linux2.l_i_uid_high
8603 #define i_gid_high osd2.linux2.l_i_gid_high
8604 +#define i_raw_tag osd2.linux2.l_i_tag
8605 #define i_reserved2 osd2.linux2.l_i_reserved2
8608 @@ -347,6 +352,7 @@ struct ext2_inode {
8609 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8610 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8611 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8612 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8615 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8616 diff -NurpP --minimal linux-2.6.29/include/linux/ext3_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/ext3_fs.h
8617 --- linux-2.6.29/include/linux/ext3_fs.h 2009-03-24 14:22:41.000000000 +0100
8618 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/ext3_fs.h 2009-03-24 14:48:36.000000000 +0100
8619 @@ -173,10 +173,14 @@ struct ext3_group_desc
8620 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8621 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8622 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8623 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8624 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8626 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8627 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8628 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8629 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8631 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8632 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8634 /* Flags that should be inherited by new inodes from their parent. */
8635 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8636 @@ -316,7 +320,7 @@ struct ext3_inode {
8638 __u8 l_i_frag; /* Fragment number */
8639 __u8 l_i_fsize; /* Fragment size */
8641 + __u16 l_i_tag; /* Context Tag */
8642 __le16 l_i_uid_high; /* these 2 fields */
8643 __le16 l_i_gid_high; /* were reserved2[0] */
8644 __u32 l_i_reserved2;
8645 @@ -350,6 +354,7 @@ struct ext3_inode {
8646 #define i_gid_low i_gid
8647 #define i_uid_high osd2.linux2.l_i_uid_high
8648 #define i_gid_high osd2.linux2.l_i_gid_high
8649 +#define i_raw_tag osd2.linux2.l_i_tag
8650 #define i_reserved2 osd2.linux2.l_i_reserved2
8652 #elif defined(__GNU__)
8653 @@ -413,6 +418,7 @@ struct ext3_inode {
8654 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8655 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8656 * error in ordered mode */
8657 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8659 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8660 #ifndef _LINUX_EXT2_FS_H
8661 @@ -874,6 +880,7 @@ struct buffer_head * ext3_bread (handle_
8662 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
8663 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
8664 int create, int extend_disksize);
8665 +extern int ext3_sync_flags(struct inode *inode);
8667 extern struct inode *ext3_iget(struct super_block *, unsigned long);
8668 extern int ext3_write_inode (struct inode *, int);
8669 diff -NurpP --minimal linux-2.6.29/include/linux/fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/fs.h
8670 --- linux-2.6.29/include/linux/fs.h 2009-03-24 14:22:41.000000000 +0100
8671 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/fs.h 2009-03-24 17:21:20.000000000 +0100
8672 @@ -141,6 +141,9 @@ struct inodes_stat_t {
8673 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
8674 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8675 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8676 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
8677 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
8678 +#define MS_NOTAGCHECK (1<<26) /* don't check tags */
8679 #define MS_ACTIVE (1<<30)
8680 #define MS_NOUSER (1<<31)
8682 @@ -167,6 +170,14 @@ struct inodes_stat_t {
8683 #define S_PRIVATE 512 /* Inode is fs-internal */
8684 #define S_ATOMIC_COPY 1024 /* Pages mapped with this inode need to be
8685 atomically copied (gem) */
8686 +#define S_IXUNLINK 2048 /* Immutable Invert on unlink */
8688 +/* Linux-VServer related Inode flags */
8692 +#define V_BARRIER 4 /* Barrier for chroot() */
8693 +#define V_COW 8 /* Copy on Write */
8696 * Note that nosuid etc flags are inode-specific: setting some file-system
8697 @@ -189,12 +200,15 @@ struct inodes_stat_t {
8698 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8699 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8700 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8701 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8702 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8703 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8704 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8705 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8707 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8708 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8709 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8710 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8711 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8712 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8714 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8715 @@ -202,6 +216,16 @@ struct inodes_stat_t {
8716 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
8717 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8719 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8721 +#ifdef CONFIG_VSERVER_COWBL
8722 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8723 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8725 +# define IS_COW(inode) (0)
8726 +# define IS_COW_LINK(inode) (0)
8729 /* the read-only stuff doesn't really belong here, but any other place is
8730 probably as bad and I don't want to create yet another include file. */
8732 @@ -279,11 +303,14 @@ struct inodes_stat_t {
8733 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8734 #define FS_EXTENT_FL 0x00080000 /* Extents */
8735 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8736 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8737 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8739 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8740 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8741 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8742 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8744 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8745 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8747 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8748 #define SYNC_FILE_RANGE_WRITE 2
8749 @@ -365,6 +392,7 @@ typedef void (dio_iodone_t)(struct kiocb
8750 #define ATTR_KILL_PRIV (1 << 14)
8751 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8752 #define ATTR_TIMES_SET (1 << 16)
8753 +#define ATTR_TAG (1 << 17)
8756 * This is the Inode Attributes structure, used for notify_change(). It
8757 @@ -380,6 +408,7 @@ struct iattr {
8763 struct timespec ia_atime;
8764 struct timespec ia_mtime;
8765 @@ -393,6 +422,9 @@ struct iattr {
8766 struct file *ia_file;
8769 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8770 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8773 * Includes for diskquotas.
8775 @@ -656,7 +688,9 @@ struct inode {
8776 unsigned int i_nlink;
8784 #ifdef __NEED_I_SIZE_ORDERED
8785 @@ -704,7 +738,8 @@ struct inode {
8786 unsigned long i_state;
8787 unsigned long dirtied_when; /* jiffies of first dirtying */
8789 - unsigned int i_flags;
8790 + unsigned short i_flags;
8791 + unsigned short i_vflags;
8793 atomic_t i_writecount;
8794 #ifdef CONFIG_SECURITY
8795 @@ -791,12 +826,12 @@ static inline void i_size_write(struct i
8797 static inline unsigned iminor(const struct inode *inode)
8799 - return MINOR(inode->i_rdev);
8800 + return MINOR(inode->i_mdev);
8803 static inline unsigned imajor(const struct inode *inode)
8805 - return MAJOR(inode->i_rdev);
8806 + return MAJOR(inode->i_mdev);
8809 extern struct block_device *I_BDEV(struct inode *inode);
8810 @@ -854,6 +889,7 @@ struct file {
8812 struct fown_struct f_owner;
8813 const struct cred *f_cred;
8815 struct file_ra_state f_ra;
8818 @@ -996,6 +1032,7 @@ struct file_lock {
8819 struct file *fl_file;
8824 struct fasync_struct * fl_fasync; /* for lease break notifications */
8825 unsigned long fl_break_time; /* for nonblocking lease breaks */
8826 @@ -1363,6 +1400,7 @@ struct inode_operations {
8828 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8830 + int (*sync_flags) (struct inode *);
8834 @@ -1378,6 +1416,7 @@ extern ssize_t vfs_readv(struct file *,
8835 unsigned long, loff_t *);
8836 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8837 unsigned long, loff_t *);
8838 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8840 struct super_operations {
8841 struct inode *(*alloc_inode)(struct super_block *sb);
8842 @@ -2096,6 +2135,7 @@ extern int dcache_dir_open(struct inode
8843 extern int dcache_dir_close(struct inode *, struct file *);
8844 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8845 extern int dcache_readdir(struct file *, void *, filldir_t);
8846 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8847 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8848 extern int simple_statfs(struct dentry *, struct kstatfs *);
8849 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
8850 diff -NurpP --minimal linux-2.6.29/include/linux/if_tun.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/if_tun.h
8851 --- linux-2.6.29/include/linux/if_tun.h 2008-12-25 00:26:37.000000000 +0100
8852 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/if_tun.h 2009-02-22 22:54:26.000000000 +0100
8854 #define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
8855 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
8856 #define TUNGETIFF _IOR('T', 210, unsigned int)
8857 +#define TUNSETNID _IOW('T', 215, int)
8859 /* TUNSETIFF ifr flags */
8860 #define IFF_TUN 0x0001
8861 diff -NurpP --minimal linux-2.6.29/include/linux/init_task.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/init_task.h
8862 --- linux-2.6.29/include/linux/init_task.h 2009-03-24 14:22:41.000000000 +0100
8863 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/init_task.h 2009-03-24 14:48:36.000000000 +0100
8864 @@ -184,6 +184,10 @@ extern struct cred init_cred;
8866 INIT_TRACE_IRQFLAGS \
8869 + .vx_info = NULL, \
8871 + .nx_info = NULL, \
8875 diff -NurpP --minimal linux-2.6.29/include/linux/interrupt.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/interrupt.h
8876 --- linux-2.6.29/include/linux/interrupt.h 2009-03-24 14:22:41.000000000 +0100
8877 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/interrupt.h 2009-03-24 14:48:36.000000000 +0100
8879 #include <linux/cpumask.h>
8880 #include <linux/irqreturn.h>
8881 #include <linux/irqnr.h>
8882 -#include <linux/hardirq.h>
8883 #include <linux/sched.h>
8884 +#include <linux/hardirq.h>
8885 #include <linux/irqflags.h>
8886 #include <linux/smp.h>
8887 #include <linux/percpu.h>
8888 diff -NurpP --minimal linux-2.6.29/include/linux/ipc.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/ipc.h
8889 --- linux-2.6.29/include/linux/ipc.h 2008-12-25 00:26:37.000000000 +0100
8890 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/ipc.h 2009-02-22 22:54:26.000000000 +0100
8891 @@ -93,6 +93,7 @@ struct kern_ipc_perm
8899 diff -NurpP --minimal linux-2.6.29/include/linux/Kbuild linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/Kbuild
8900 --- linux-2.6.29/include/linux/Kbuild 2009-03-24 14:22:40.000000000 +0100
8901 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/Kbuild 2009-03-24 17:22:07.000000000 +0100
8902 @@ -373,5 +373,8 @@ unifdef-y += xattr.h
8905 objhdr-y += version.h
8907 +header-y += vserver/
8911 diff -NurpP --minimal linux-2.6.29/include/linux/loop.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/loop.h
8912 --- linux-2.6.29/include/linux/loop.h 2009-03-24 14:22:42.000000000 +0100
8913 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/loop.h 2009-03-24 14:48:36.000000000 +0100
8914 @@ -45,6 +45,7 @@ struct loop_device {
8915 struct loop_func_table *lo_encryption;
8917 uid_t lo_key_owner; /* Who set the key */
8919 int (*ioctl)(struct loop_device *, int cmd,
8922 diff -NurpP --minimal linux-2.6.29/include/linux/magic.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/magic.h
8923 --- linux-2.6.29/include/linux/magic.h 2009-03-24 14:22:42.000000000 +0100
8924 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/magic.h 2009-03-24 14:48:36.000000000 +0100
8927 #define ADFS_SUPER_MAGIC 0xadf5
8928 #define AFFS_SUPER_MAGIC 0xadff
8929 -#define AFS_SUPER_MAGIC 0x5346414F
8930 +#define AFS_SUPER_MAGIC 0x5346414F
8931 #define AUTOFS_SUPER_MAGIC 0x0187
8932 #define CODA_SUPER_MAGIC 0x73757245
8933 #define DEBUGFS_MAGIC 0x64626720
8935 #define NFS_SUPER_MAGIC 0x6969
8936 #define OPENPROM_SUPER_MAGIC 0x9fa1
8937 #define PROC_SUPER_MAGIC 0x9fa0
8938 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8939 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8941 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8942 diff -NurpP --minimal linux-2.6.29/include/linux/major.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/major.h
8943 --- linux-2.6.29/include/linux/major.h 2008-12-25 00:26:37.000000000 +0100
8944 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/major.h 2009-02-22 22:54:26.000000000 +0100
8946 #define HD_MAJOR IDE0_MAJOR
8947 #define PTY_SLAVE_MAJOR 3
8949 +#define VROOT_MAJOR 4
8950 #define TTYAUX_MAJOR 5
8953 diff -NurpP --minimal linux-2.6.29/include/linux/mm_types.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/mm_types.h
8954 --- linux-2.6.29/include/linux/mm_types.h 2009-03-24 14:22:42.000000000 +0100
8955 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/mm_types.h 2009-03-24 14:48:36.000000000 +0100
8956 @@ -232,6 +232,7 @@ struct mm_struct {
8958 /* Architecture-specific MM context */
8959 mm_context_t context;
8960 + struct vx_info *mm_vx_info;
8962 /* Swap token stuff */
8964 diff -NurpP --minimal linux-2.6.29/include/linux/mount.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/mount.h
8965 --- linux-2.6.29/include/linux/mount.h 2008-12-25 00:26:37.000000000 +0100
8966 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/mount.h 2009-02-22 22:54:26.000000000 +0100
8967 @@ -35,6 +35,9 @@ struct mnt_namespace;
8968 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
8969 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
8971 +#define MNT_TAGID 0x10000
8972 +#define MNT_NOTAG 0x20000
8975 struct list_head mnt_hash;
8976 struct vfsmount *mnt_parent; /* fs we are mounted on */
8977 @@ -69,6 +72,7 @@ struct vfsmount {
8978 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
8980 atomic_t __mnt_writers;
8981 + tag_t mnt_tag; /* tagging used for vfsmount */
8984 static inline struct vfsmount *mntget(struct vfsmount *mnt)
8985 diff -NurpP --minimal linux-2.6.29/include/linux/net.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/net.h
8986 --- linux-2.6.29/include/linux/net.h 2008-12-25 00:26:37.000000000 +0100
8987 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/net.h 2009-02-22 22:54:26.000000000 +0100
8988 @@ -68,6 +68,7 @@ struct net;
8989 #define SOCK_NOSPACE 2
8990 #define SOCK_PASSCRED 3
8991 #define SOCK_PASSSEC 4
8992 +#define SOCK_USER_SOCKET 5
8994 #ifndef ARCH_HAS_SOCKET_TYPES
8996 diff -NurpP --minimal linux-2.6.29/include/linux/nfs_mount.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/nfs_mount.h
8997 --- linux-2.6.29/include/linux/nfs_mount.h 2009-03-24 14:22:43.000000000 +0100
8998 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/nfs_mount.h 2009-03-24 14:48:36.000000000 +0100
8999 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9000 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9001 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9002 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9003 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9004 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9005 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9007 /* The following are for internal use only */
9008 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9009 diff -NurpP --minimal linux-2.6.29/include/linux/nsproxy.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/nsproxy.h
9010 --- linux-2.6.29/include/linux/nsproxy.h 2009-03-24 14:22:43.000000000 +0100
9011 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/nsproxy.h 2009-03-24 14:48:36.000000000 +0100
9014 #include <linux/spinlock.h>
9015 #include <linux/sched.h>
9016 +#include <linux/vserver/debug.h>
9018 struct mnt_namespace;
9019 struct uts_namespace;
9020 @@ -62,22 +63,33 @@ static inline struct nsproxy *task_nspro
9023 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9024 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9025 void exit_task_namespaces(struct task_struct *tsk);
9026 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9027 void free_nsproxy(struct nsproxy *ns);
9028 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9029 struct fs_struct *);
9031 -static inline void put_nsproxy(struct nsproxy *ns)
9032 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9034 +static inline void __get_nsproxy(struct nsproxy *ns,
9035 + const char *_file, int _line)
9037 - if (atomic_dec_and_test(&ns->count)) {
9040 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9041 + ns, atomic_read(&ns->count), _file, _line);
9042 + atomic_inc(&ns->count);
9045 -static inline void get_nsproxy(struct nsproxy *ns)
9046 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9048 +static inline void __put_nsproxy(struct nsproxy *ns,
9049 + const char *_file, int _line)
9051 - atomic_inc(&ns->count);
9052 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9053 + ns, atomic_read(&ns->count), _file, _line);
9054 + if (atomic_dec_and_test(&ns->count)) {
9059 #ifdef CONFIG_CGROUP_NS
9060 diff -NurpP --minimal linux-2.6.29/include/linux/pid.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/pid.h
9061 --- linux-2.6.29/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9062 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/pid.h 2009-03-24 14:48:36.000000000 +0100
9063 @@ -8,7 +8,8 @@ enum pid_type
9073 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9076 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9077 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9078 pid_t pid_vnr(struct pid *pid);
9080 #define do_each_pid_task(pid, type, task) \
9081 diff -NurpP --minimal linux-2.6.29/include/linux/proc_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/proc_fs.h
9082 --- linux-2.6.29/include/linux/proc_fs.h 2008-12-25 00:26:37.000000000 +0100
9083 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/proc_fs.h 2009-02-22 22:54:26.000000000 +0100
9084 @@ -59,6 +59,7 @@ struct proc_dir_entry {
9090 const struct inode_operations *proc_iops;
9092 @@ -268,12 +269,18 @@ static inline void kclist_add(struct kco
9093 extern void kclist_add(struct kcore_list *, void *, size_t);
9100 int (*proc_get_link)(struct inode *, struct path *);
9101 int (*proc_read)(struct task_struct *task, char *page);
9102 int (*proc_show)(struct seq_file *m,
9103 struct pid_namespace *ns, struct pid *pid,
9104 struct task_struct *task);
9105 + int (*proc_vs_read)(char *page);
9106 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9107 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9110 struct ctl_table_header;
9111 @@ -281,6 +288,7 @@ struct ctl_table;
9118 struct proc_dir_entry *pde;
9119 diff -NurpP --minimal linux-2.6.29/include/linux/reiserfs_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/reiserfs_fs.h
9120 --- linux-2.6.29/include/linux/reiserfs_fs.h 2008-12-25 00:26:37.000000000 +0100
9121 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/reiserfs_fs.h 2009-02-22 22:54:26.000000000 +0100
9122 @@ -837,6 +837,11 @@ struct stat_data_v1 {
9123 #define REISERFS_COMPR_FL FS_COMPR_FL
9124 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9126 +/* unfortunately reiserfs sdattr is only 16 bit */
9127 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9128 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9129 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9131 /* persistent flags that file inherits from the parent directory */
9132 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9133 REISERFS_SYNC_FL | \
9134 @@ -846,6 +851,9 @@ struct stat_data_v1 {
9135 REISERFS_COMPR_FL | \
9136 REISERFS_NOTAIL_FL )
9138 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9139 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9141 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9144 @@ -1911,6 +1919,7 @@ static inline void reiserfs_update_sd(st
9145 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9146 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9147 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9148 +int reiserfs_sync_flags(struct inode *inode);
9151 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9152 diff -NurpP --minimal linux-2.6.29/include/linux/reiserfs_fs_sb.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/reiserfs_fs_sb.h
9153 --- linux-2.6.29/include/linux/reiserfs_fs_sb.h 2008-12-25 00:26:37.000000000 +0100
9154 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/reiserfs_fs_sb.h 2009-02-22 22:54:26.000000000 +0100
9155 @@ -456,6 +456,7 @@ enum reiserfs_mount_options {
9157 REISERFS_BARRIER_NONE,
9158 REISERFS_BARRIER_FLUSH,
9161 /* Actions on error */
9162 REISERFS_ERROR_PANIC,
9163 diff -NurpP --minimal linux-2.6.29/include/linux/sched.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sched.h
9164 --- linux-2.6.29/include/linux/sched.h 2009-03-24 14:22:43.000000000 +0100
9165 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sched.h 2009-03-24 14:48:36.000000000 +0100
9166 @@ -71,7 +71,6 @@ struct sched_param {
9167 #include <linux/fs_struct.h>
9168 #include <linux/compiler.h>
9169 #include <linux/completion.h>
9170 -#include <linux/pid.h>
9171 #include <linux/percpu.h>
9172 #include <linux/topology.h>
9173 #include <linux/proportions.h>
9174 @@ -88,6 +87,7 @@ struct sched_param {
9175 #include <linux/kobject.h>
9176 #include <linux/latencytop.h>
9177 #include <linux/cred.h>
9178 +#include <linux/pid.h>
9180 #include <asm/processor.h>
9182 @@ -176,12 +176,13 @@ extern unsigned long long time_sync_thre
9183 #define TASK_UNINTERRUPTIBLE 2
9184 #define __TASK_STOPPED 4
9185 #define __TASK_TRACED 8
9186 +#define TASK_ONHOLD 16
9187 /* in tsk->exit_state */
9188 -#define EXIT_ZOMBIE 16
9189 -#define EXIT_DEAD 32
9190 +#define EXIT_ZOMBIE 32
9191 +#define EXIT_DEAD 64
9192 /* in tsk->state again */
9193 -#define TASK_DEAD 64
9194 -#define TASK_WAKEKILL 128
9195 +#define TASK_DEAD 128
9196 +#define TASK_WAKEKILL 256
9198 /* Convenience macros for the sake of set_task_state */
9199 #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
9200 @@ -358,25 +359,28 @@ extern void arch_unmap_area_topdown(stru
9201 * The mm counters are not protected by its page_table_lock,
9202 * so must be incremented atomically.
9204 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9205 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9206 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9207 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9208 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9209 +#define __set_mm_counter(mm, member, value) \
9210 + atomic_long_set(&(mm)->_##member, value)
9211 +#define get_mm_counter(mm, member) \
9212 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9214 #else /* !USE_SPLIT_PTLOCKS */
9216 * The mm counters are protected by its page_table_lock,
9217 * so can be incremented directly.
9219 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9220 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9221 #define get_mm_counter(mm, member) ((mm)->_##member)
9222 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9223 -#define inc_mm_counter(mm, member) (mm)->_##member++
9224 -#define dec_mm_counter(mm, member) (mm)->_##member--
9226 #endif /* !USE_SPLIT_PTLOCKS */
9228 +#define set_mm_counter(mm, member, value) \
9229 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9230 +#define add_mm_counter(mm, member, value) \
9231 + vx_ ## member ## pages_add((mm), (value))
9232 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9233 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9235 #define get_mm_rss(mm) \
9236 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9237 #define update_hiwater_rss(mm) do { \
9238 @@ -1131,7 +1135,9 @@ struct task_struct {
9239 const struct sched_class *sched_class;
9240 struct sched_entity se;
9241 struct sched_rt_entity rt;
9243 +#ifdef CONFIG_VSERVER_HARDCPU
9244 + struct list_head hq;
9246 #ifdef CONFIG_PREEMPT_NOTIFIERS
9247 /* list of struct preempt_notifier: */
9248 struct hlist_head preempt_notifiers;
9249 @@ -1287,6 +1293,14 @@ struct task_struct {
9253 +/* vserver context data */
9254 + struct vx_info *vx_info;
9255 + struct nx_info *nx_info;
9261 /* Thread group tracking */
9264 @@ -1499,6 +1513,11 @@ struct pid_namespace;
9265 * see also pid_nr() etc in include/linux/pid.h
9268 +#include <linux/vserver/base.h>
9269 +#include <linux/vserver/context.h>
9270 +#include <linux/vserver/debug.h>
9271 +#include <linux/vserver/pid.h>
9273 static inline pid_t task_pid_nr(struct task_struct *tsk)
9276 @@ -1508,7 +1527,7 @@ pid_t task_pid_nr_ns(struct task_struct
9278 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9280 - return pid_vnr(task_pid(tsk));
9281 + return vx_map_pid(pid_vnr(task_pid(tsk)));
9285 @@ -1521,7 +1540,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9287 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9289 - return pid_vnr(task_tgid(tsk));
9290 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9294 diff -NurpP --minimal linux-2.6.29/include/linux/shmem_fs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/shmem_fs.h
9295 --- linux-2.6.29/include/linux/shmem_fs.h 2008-12-25 00:26:37.000000000 +0100
9296 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/shmem_fs.h 2009-02-22 22:54:26.000000000 +0100
9299 #define SHMEM_NR_DIRECT 16
9301 +#define TMPFS_SUPER_MAGIC 0x01021994
9304 struct shmem_inode_info {
9306 unsigned long flags;
9307 diff -NurpP --minimal linux-2.6.29/include/linux/stat.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/stat.h
9308 --- linux-2.6.29/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9309 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/stat.h 2009-02-22 22:54:26.000000000 +0100
9310 @@ -66,6 +66,7 @@ struct kstat {
9317 struct timespec atime;
9318 diff -NurpP --minimal linux-2.6.29/include/linux/sunrpc/auth.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sunrpc/auth.h
9319 --- linux-2.6.29/include/linux/sunrpc/auth.h 2008-12-25 00:26:37.000000000 +0100
9320 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sunrpc/auth.h 2009-02-22 22:54:26.000000000 +0100
9326 struct group_info *group_info;
9327 unsigned char machine_cred : 1;
9329 diff -NurpP --minimal linux-2.6.29/include/linux/sunrpc/clnt.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sunrpc/clnt.h
9330 --- linux-2.6.29/include/linux/sunrpc/clnt.h 2009-03-24 14:22:43.000000000 +0100
9331 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sunrpc/clnt.h 2009-03-24 14:48:36.000000000 +0100
9332 @@ -43,7 +43,8 @@ struct rpc_clnt {
9333 unsigned int cl_softrtry : 1,/* soft timeouts */
9334 cl_discrtry : 1,/* disconnect before retry */
9335 cl_autobind : 1,/* use getport() */
9336 - cl_chatty : 1;/* be verbose */
9337 + cl_chatty : 1,/* be verbose */
9338 + cl_tag : 1;/* context tagging */
9340 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9341 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9342 diff -NurpP --minimal linux-2.6.29/include/linux/syscalls.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/syscalls.h
9343 --- linux-2.6.29/include/linux/syscalls.h 2009-03-24 14:22:43.000000000 +0100
9344 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/syscalls.h 2009-03-24 14:48:36.000000000 +0100
9345 @@ -369,6 +369,8 @@ asmlinkage long sys_symlink(const char _
9346 asmlinkage long sys_unlink(const char __user *pathname);
9347 asmlinkage long sys_rename(const char __user *oldname,
9348 const char __user *newname);
9349 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9351 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9352 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9354 diff -NurpP --minimal linux-2.6.29/include/linux/sysctl.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sysctl.h
9355 --- linux-2.6.29/include/linux/sysctl.h 2008-12-25 00:26:37.000000000 +0100
9356 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sysctl.h 2009-02-22 22:54:26.000000000 +0100
9357 @@ -70,6 +70,7 @@ enum
9358 CTL_ABI=9, /* Binary emulation */
9359 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9360 CTL_ARLAN=254, /* arlan wireless driver */
9361 + CTL_VSERVER=4242, /* Linux-VServer debug */
9362 CTL_S390DBF=5677, /* s390 debug */
9363 CTL_SUNRPC=7249, /* sunrpc debug */
9364 CTL_PM=9899, /* frv power management */
9365 @@ -104,6 +105,7 @@ enum
9367 KERN_PANIC=15, /* int: panic timeout */
9368 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9369 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9371 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9372 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9373 diff -NurpP --minimal linux-2.6.29/include/linux/sysfs.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sysfs.h
9374 --- linux-2.6.29/include/linux/sysfs.h 2008-12-25 00:26:37.000000000 +0100
9375 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/sysfs.h 2009-02-22 22:54:26.000000000 +0100
9377 #include <linux/list.h>
9378 #include <asm/atomic.h>
9380 +#define SYSFS_SUPER_MAGIC 0x62656572
9385 diff -NurpP --minimal linux-2.6.29/include/linux/time.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/time.h
9386 --- linux-2.6.29/include/linux/time.h 2009-03-24 14:22:43.000000000 +0100
9387 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/time.h 2009-02-22 22:54:26.000000000 +0100
9388 @@ -190,6 +190,9 @@ static __always_inline void timespec_add
9389 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9393 +#include <linux/vs_time.h>
9395 #endif /* __KERNEL__ */
9397 #define NFDBITS __NFDBITS
9398 diff -NurpP --minimal linux-2.6.29/include/linux/types.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/types.h
9399 --- linux-2.6.29/include/linux/types.h 2009-03-24 14:22:43.000000000 +0100
9400 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/types.h 2009-03-24 14:48:36.000000000 +0100
9401 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
9402 typedef __kernel_gid32_t gid_t;
9403 typedef __kernel_uid16_t uid16_t;
9404 typedef __kernel_gid16_t gid16_t;
9405 +typedef unsigned int xid_t;
9406 +typedef unsigned int nid_t;
9407 +typedef unsigned int tag_t;
9409 typedef unsigned long uintptr_t;
9411 diff -NurpP --minimal linux-2.6.29/include/linux/vroot.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vroot.h
9412 --- linux-2.6.29/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9413 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vroot.h 2009-02-22 22:54:26.000000000 +0100
9417 + * include/linux/vroot.h
9419 + * written by Herbert Pötzl, 9/11/2002
9420 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9422 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9423 + * Redistribution of this file is permitted under the
9424 + * GNU General Public License.
9427 +#ifndef _LINUX_VROOT_H
9428 +#define _LINUX_VROOT_H
9433 +/* Possible states of device */
9439 +struct vroot_device {
9443 + struct semaphore vr_ctl_mutex;
9444 + struct block_device *vr_device;
9449 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9451 +extern int register_vroot_grb(vroot_grb_func *);
9452 +extern int unregister_vroot_grb(vroot_grb_func *);
9454 +#endif /* __KERNEL__ */
9456 +#define MAX_VROOT_DEFAULT 8
9459 + * IOCTL commands --- we will commandeer 0x56 ('V')
9462 +#define VROOT_SET_DEV 0x5600
9463 +#define VROOT_CLR_DEV 0x5601
9465 +#endif /* _LINUX_VROOT_H */
9466 diff -NurpP --minimal linux-2.6.29/include/linux/vs_base.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_base.h
9467 --- linux-2.6.29/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9468 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_base.h 2009-02-22 22:54:26.000000000 +0100
9473 +#include "vserver/base.h"
9474 +#include "vserver/check.h"
9475 +#include "vserver/debug.h"
9478 +#warning duplicate inclusion
9480 diff -NurpP --minimal linux-2.6.29/include/linux/vs_context.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_context.h
9481 --- linux-2.6.29/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9482 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_context.h 2009-02-22 22:54:26.000000000 +0100
9484 +#ifndef _VS_CONTEXT_H
9485 +#define _VS_CONTEXT_H
9487 +#include "vserver/base.h"
9488 +#include "vserver/check.h"
9489 +#include "vserver/context.h"
9490 +#include "vserver/history.h"
9491 +#include "vserver/debug.h"
9493 +#include <linux/sched.h>
9496 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9498 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9499 + const char *_file, int _line, void *_here)
9504 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9505 + vxi, vxi ? vxi->vx_id : 0,
9506 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9508 + __vxh_get_vx_info(vxi, _here);
9510 + atomic_inc(&vxi->vx_usecnt);
9515 +extern void free_vx_info(struct vx_info *);
9517 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9519 +static inline void __put_vx_info(struct vx_info *vxi,
9520 + const char *_file, int _line, void *_here)
9525 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9526 + vxi, vxi ? vxi->vx_id : 0,
9527 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9529 + __vxh_put_vx_info(vxi, _here);
9531 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9532 + free_vx_info(vxi);
9536 +#define init_vx_info(p, i) \
9537 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9539 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9540 + const char *_file, int _line, void *_here)
9543 + vxlprintk(VXD_CBIT(xid, 3),
9544 + "init_vx_info(%p[#%d.%d])",
9545 + vxi, vxi ? vxi->vx_id : 0,
9546 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9548 + __vxh_init_vx_info(vxi, vxp, _here);
9550 + atomic_inc(&vxi->vx_usecnt);
9556 +#define set_vx_info(p, i) \
9557 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9559 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9560 + const char *_file, int _line, void *_here)
9562 + struct vx_info *vxo;
9567 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9568 + vxi, vxi ? vxi->vx_id : 0,
9569 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9571 + __vxh_set_vx_info(vxi, vxp, _here);
9573 + atomic_inc(&vxi->vx_usecnt);
9574 + vxo = xchg(vxp, vxi);
9579 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9581 +static inline void __clr_vx_info(struct vx_info **vxp,
9582 + const char *_file, int _line, void *_here)
9584 + struct vx_info *vxo;
9586 + vxo = xchg(vxp, NULL);
9590 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9591 + vxo, vxo ? vxo->vx_id : 0,
9592 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9594 + __vxh_clr_vx_info(vxo, vxp, _here);
9596 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9597 + free_vx_info(vxo);
9601 +#define claim_vx_info(v, p) \
9602 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9604 +static inline void __claim_vx_info(struct vx_info *vxi,
9605 + struct task_struct *task,
9606 + const char *_file, int _line, void *_here)
9608 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9609 + vxi, vxi ? vxi->vx_id : 0,
9610 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9611 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9612 + task, _file, _line);
9613 + __vxh_claim_vx_info(vxi, task, _here);
9615 + atomic_inc(&vxi->vx_tasks);
9619 +extern void unhash_vx_info(struct vx_info *);
9621 +#define release_vx_info(v, p) \
9622 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9624 +static inline void __release_vx_info(struct vx_info *vxi,
9625 + struct task_struct *task,
9626 + const char *_file, int _line, void *_here)
9628 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9629 + vxi, vxi ? vxi->vx_id : 0,
9630 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9631 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9632 + task, _file, _line);
9633 + __vxh_release_vx_info(vxi, task, _here);
9637 + if (atomic_dec_and_test(&vxi->vx_tasks))
9638 + unhash_vx_info(vxi);
9642 +#define task_get_vx_info(p) \
9643 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9645 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9646 + const char *_file, int _line, void *_here)
9648 + struct vx_info *vxi;
9651 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9653 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9659 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9661 + if (waitqueue_active(&vxi->vx_wait))
9662 + wake_up_interruptible(&vxi->vx_wait);
9666 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9668 +static inline void __enter_vx_info(struct vx_info *vxi,
9669 + struct vx_info_save *vxis, const char *_file, int _line)
9671 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9672 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9673 + current->xid, current->vx_info, _file, _line);
9674 + vxis->vxi = xchg(¤t->vx_info, vxi);
9675 + vxis->xid = current->xid;
9676 + current->xid = vxi ? vxi->vx_id : 0;
9679 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9681 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9682 + const char *_file, int _line)
9684 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9685 + vxis, vxis->xid, vxis->vxi, current,
9686 + current->xid, current->vx_info, _file, _line);
9687 + (void)xchg(¤t->vx_info, vxis->vxi);
9688 + current->xid = vxis->xid;
9692 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9694 + vxis->vxi = xchg(¤t->vx_info, NULL);
9695 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9698 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9700 + (void)xchg(¤t->xid, vxis->xid);
9701 + (void)xchg(¤t->vx_info, vxis->vxi);
9704 +extern void exit_vx_info(struct task_struct *, int);
9705 +extern void exit_vx_info_early(struct task_struct *, int);
9709 +#warning duplicate inclusion
9711 diff -NurpP --minimal linux-2.6.29/include/linux/vs_cowbl.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_cowbl.h
9712 --- linux-2.6.29/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9713 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_cowbl.h 2009-02-22 22:54:26.000000000 +0100
9715 +#ifndef _VS_COWBL_H
9716 +#define _VS_COWBL_H
9718 +#include <linux/fs.h>
9719 +#include <linux/dcache.h>
9720 +#include <linux/namei.h>
9722 +extern struct dentry *cow_break_link(const char *pathname);
9724 +static inline int cow_check_and_break(struct path *path)
9726 + struct inode *inode = path->dentry->d_inode;
9729 + /* do we need this check? */
9730 + if (IS_RDONLY(inode))
9733 + if (IS_COW(inode)) {
9734 + if (IS_COW_LINK(inode)) {
9735 + struct dentry *new_dentry, *old_dentry = path->dentry;
9738 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9742 + pp = d_path(path, buf, PATH_MAX);
9743 + new_dentry = cow_break_link(pp);
9745 + if (!IS_ERR(new_dentry)) {
9746 + path->dentry = new_dentry;
9749 + error = PTR_ERR(new_dentry);
9751 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9752 + inode->i_ctime = CURRENT_TIME;
9753 + mark_inode_dirty(inode);
9760 +#warning duplicate inclusion
9762 diff -NurpP --minimal linux-2.6.29/include/linux/vs_cvirt.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_cvirt.h
9763 --- linux-2.6.29/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9764 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_cvirt.h 2009-02-22 22:54:26.000000000 +0100
9766 +#ifndef _VS_CVIRT_H
9767 +#define _VS_CVIRT_H
9769 +#include "vserver/cvirt.h"
9770 +#include "vserver/context.h"
9771 +#include "vserver/base.h"
9772 +#include "vserver/check.h"
9773 +#include "vserver/debug.h"
9776 +static inline void vx_activate_task(struct task_struct *p)
9778 + struct vx_info *vxi;
9780 + if ((vxi = p->vx_info)) {
9781 + vx_update_load(vxi);
9782 + atomic_inc(&vxi->cvirt.nr_running);
9786 +static inline void vx_deactivate_task(struct task_struct *p)
9788 + struct vx_info *vxi;
9790 + if ((vxi = p->vx_info)) {
9791 + vx_update_load(vxi);
9792 + atomic_dec(&vxi->cvirt.nr_running);
9796 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9798 + struct vx_info *vxi;
9800 + if ((vxi = p->vx_info))
9801 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9804 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9806 + struct vx_info *vxi;
9808 + if ((vxi = p->vx_info))
9809 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9814 +#warning duplicate inclusion
9816 diff -NurpP --minimal linux-2.6.29/include/linux/vs_device.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_device.h
9817 --- linux-2.6.29/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9818 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_device.h 2009-02-22 22:54:26.000000000 +0100
9820 +#ifndef _VS_DEVICE_H
9821 +#define _VS_DEVICE_H
9823 +#include "vserver/base.h"
9824 +#include "vserver/device.h"
9825 +#include "vserver/debug.h"
9828 +#ifdef CONFIG_VSERVER_DEVICE
9830 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9832 +#define vs_device_perm(v, d, m, p) \
9833 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9838 +int vs_map_device(struct vx_info *vxi,
9839 + dev_t device, dev_t *target, umode_t mode)
9846 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9851 +#define vs_map_chrdev(d, t, p) \
9852 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9853 +#define vs_map_blkdev(d, t, p) \
9854 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9856 +#define vs_chrdev_perm(d, p) \
9857 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9858 +#define vs_blkdev_perm(d, p) \
9859 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9863 +#warning duplicate inclusion
9865 diff -NurpP --minimal linux-2.6.29/include/linux/vs_dlimit.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_dlimit.h
9866 --- linux-2.6.29/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9867 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_dlimit.h 2009-02-22 22:54:26.000000000 +0100
9869 +#ifndef _VS_DLIMIT_H
9870 +#define _VS_DLIMIT_H
9872 +#include <linux/fs.h>
9874 +#include "vserver/dlimit.h"
9875 +#include "vserver/base.h"
9876 +#include "vserver/debug.h"
9879 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9881 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9882 + const char *_file, int _line)
9886 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9887 + dli, dli ? dli->dl_tag : 0,
9888 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9890 + atomic_inc(&dli->dl_usecnt);
9895 +#define free_dl_info(i) \
9896 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9898 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9900 +static inline void __put_dl_info(struct dl_info *dli,
9901 + const char *_file, int _line)
9905 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9906 + dli, dli ? dli->dl_tag : 0,
9907 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9909 + if (atomic_dec_and_test(&dli->dl_usecnt))
9910 + free_dl_info(dli);
9914 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9916 +static inline int __dl_alloc_space(struct super_block *sb,
9917 + tag_t tag, dlsize_t nr, const char *file, int line)
9919 + struct dl_info *dli = NULL;
9924 + dli = locate_dl_info(sb, tag);
9928 + spin_lock(&dli->dl_lock);
9929 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9931 + dli->dl_space_used += nr;
9932 + spin_unlock(&dli->dl_lock);
9935 + vxlprintk(VXD_CBIT(dlim, 1),
9936 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9937 + sb, tag, __dlimit_char(dli), (long long)nr,
9942 +static inline void __dl_free_space(struct super_block *sb,
9943 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9945 + struct dl_info *dli = NULL;
9949 + dli = locate_dl_info(sb, tag);
9953 + spin_lock(&dli->dl_lock);
9954 + if (dli->dl_space_used > nr)
9955 + dli->dl_space_used -= nr;
9957 + dli->dl_space_used = 0;
9958 + spin_unlock(&dli->dl_lock);
9961 + vxlprintk(VXD_CBIT(dlim, 1),
9962 + "FREE (%p,#%d)%c %lld bytes",
9963 + sb, tag, __dlimit_char(dli), (long long)nr,
9967 +static inline int __dl_alloc_inode(struct super_block *sb,
9968 + tag_t tag, const char *_file, int _line)
9970 + struct dl_info *dli;
9973 + dli = locate_dl_info(sb, tag);
9977 + spin_lock(&dli->dl_lock);
9978 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
9980 + dli->dl_inodes_used++;
9981 + spin_unlock(&dli->dl_lock);
9984 + vxlprintk(VXD_CBIT(dlim, 0),
9985 + "ALLOC (%p,#%d)%c inode (%d)",
9986 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9990 +static inline void __dl_free_inode(struct super_block *sb,
9991 + tag_t tag, const char *_file, int _line)
9993 + struct dl_info *dli;
9995 + dli = locate_dl_info(sb, tag);
9999 + spin_lock(&dli->dl_lock);
10000 + if (dli->dl_inodes_used > 1)
10001 + dli->dl_inodes_used--;
10003 + dli->dl_inodes_used = 0;
10004 + spin_unlock(&dli->dl_lock);
10005 + put_dl_info(dli);
10007 + vxlprintk(VXD_CBIT(dlim, 0),
10008 + "FREE (%p,#%d)%c inode",
10009 + sb, tag, __dlimit_char(dli), _file, _line);
10012 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10013 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10014 + const char *_file, int _line)
10016 + struct dl_info *dli;
10017 + uint64_t broot, bfree;
10019 + dli = locate_dl_info(sb, tag);
10023 + spin_lock(&dli->dl_lock);
10024 + broot = (dli->dl_space_total -
10025 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10026 + >> sb->s_blocksize_bits;
10027 + bfree = (dli->dl_space_total - dli->dl_space_used)
10028 + >> sb->s_blocksize_bits;
10029 + spin_unlock(&dli->dl_lock);
10031 + vxlprintk(VXD_CBIT(dlim, 2),
10032 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10033 + (long long)bfree, (long long)broot,
10034 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10036 + if (free_blocks) {
10037 + if (*free_blocks > bfree)
10038 + *free_blocks = bfree;
10040 + if (root_blocks) {
10041 + if (*root_blocks > broot)
10042 + *root_blocks = broot;
10044 + put_dl_info(dli);
10047 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
10048 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10049 + __FILE__, __LINE__ )
10051 +#define DLIMIT_FREE_SPACE(in, bytes) \
10052 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10053 + __FILE__, __LINE__ )
10055 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
10056 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
10057 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10058 + __FILE__, __LINE__ )
10060 +#define DLIMIT_FREE_BLOCK(in, nr) \
10061 + __dl_free_space((in)->i_sb, (in)->i_tag, \
10062 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10063 + __FILE__, __LINE__ )
10066 +#define DLIMIT_ALLOC_INODE(in) \
10067 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10069 +#define DLIMIT_FREE_INODE(in) \
10070 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10073 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
10074 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10078 +#warning duplicate inclusion
10080 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/base.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/base.h
10081 --- linux-2.6.29/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10082 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/base.h 2009-03-25 00:36:15.000000000 +0100
10084 +#ifndef _VX_BASE_H
10085 +#define _VX_BASE_H
10088 +/* context state changes */
10100 +#define vx_task_xid(t) ((t)->xid)
10102 +#define vx_current_xid() vx_task_xid(current)
10104 +#define current_vx_info() (current->vx_info)
10107 +#define nx_task_nid(t) ((t)->nid)
10109 +#define nx_current_nid() nx_task_nid(current)
10111 +#define current_nx_info() (current->nx_info)
10114 +/* generic flag merging */
10116 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10118 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10120 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10122 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10125 +/* context flags */
10127 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10129 +#define vx_current_flags() __vx_flags(current->vx_info)
10131 +#define vx_info_flags(v, m, f) \
10132 + vs_check_flags(__vx_flags(v), m, f)
10134 +#define task_vx_flags(t, m, f) \
10135 + ((t) && vx_info_flags((t)->vx_info, m, f))
10137 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
10140 +/* context caps */
10142 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10144 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
10146 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10148 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
10152 +/* network flags */
10154 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10156 +#define nx_current_flags() __nx_flags(current->nx_info)
10158 +#define nx_info_flags(n, m, f) \
10159 + vs_check_flags(__nx_flags(n), m, f)
10161 +#define task_nx_flags(t, m, f) \
10162 + ((t) && nx_info_flags((t)->nx_info, m, f))
10164 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
10167 +/* network caps */
10169 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10171 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
10173 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10175 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
10178 +/* context mask capabilities */
10180 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10182 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10184 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
10187 +/* context bcap mask */
10189 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10191 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
10194 +/* mask given bcaps */
10196 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10198 +#define vx_mbcaps(c) vx_info_mbcaps(current->vx_info, c)
10201 +/* masked cap_bset */
10203 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10205 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
10208 +#define vx_info_mbcap(v, b) \
10209 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10210 + vx_info_bcaps(v, b) : (b))
10212 +#define task_vx_mbcap(t, b) \
10213 + vx_info_mbcap((t)->vx_info, (t)->b)
10215 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10218 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10220 +#define vx_capable(b, c) (capable(b) || \
10221 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10223 +#define nx_capable(b, c) (capable(b) || \
10224 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10226 +#define vx_current_initpid(n) \
10227 + (current->vx_info && \
10228 + (current->vx_info->vx_initpid == (n)))
10231 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10233 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10236 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10238 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10241 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct_cmd.h
10242 --- linux-2.6.29/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10243 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct_cmd.h 2009-02-22 22:54:26.000000000 +0100
10245 +#ifndef _VX_CACCT_CMD_H
10246 +#define _VX_CACCT_CMD_H
10249 +/* virtual host info name commands */
10251 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10253 +struct vcmd_sock_stat_v0 {
10255 + uint32_t count[3];
10256 + uint64_t total[3];
10262 +#include <linux/compiler.h>
10264 +extern int vc_sock_stat(struct vx_info *, void __user *);
10266 +#endif /* __KERNEL__ */
10267 +#endif /* _VX_CACCT_CMD_H */
10268 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct_def.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct_def.h
10269 --- linux-2.6.29/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10270 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct_def.h 2009-02-22 22:54:26.000000000 +0100
10272 +#ifndef _VX_CACCT_DEF_H
10273 +#define _VX_CACCT_DEF_H
10275 +#include <asm/atomic.h>
10276 +#include <linux/vserver/cacct.h>
10279 +struct _vx_sock_acc {
10280 + atomic_long_t count;
10281 + atomic_long_t total;
10284 +/* context sub struct */
10286 +struct _vx_cacct {
10287 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10288 + atomic_t slab[8];
10289 + atomic_t page[6][8];
10292 +#ifdef CONFIG_VSERVER_DEBUG
10294 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10298 + printk("\t_vx_cacct:");
10299 + for (i = 0; i < 6; i++) {
10300 + struct _vx_sock_acc *ptr = cacct->sock[i];
10302 + printk("\t [%d] =", i);
10303 + for (j = 0; j < 3; j++) {
10304 + printk(" [%d] = %8lu, %8lu", j,
10305 + atomic_long_read(&ptr[j].count),
10306 + atomic_long_read(&ptr[j].total));
10314 +#endif /* _VX_CACCT_DEF_H */
10315 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct.h
10316 --- linux-2.6.29/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10317 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct.h 2009-02-22 22:54:26.000000000 +0100
10319 +#ifndef _VX_CACCT_H
10320 +#define _VX_CACCT_H
10323 +enum sock_acc_field {
10324 + VXA_SOCK_UNSPEC = 0,
10330 + VXA_SOCK_SIZE /* array size */
10333 +#endif /* _VX_CACCT_H */
10334 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cacct_int.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct_int.h
10335 --- linux-2.6.29/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10336 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cacct_int.h 2009-02-22 22:54:26.000000000 +0100
10338 +#ifndef _VX_CACCT_INT_H
10339 +#define _VX_CACCT_INT_H
10345 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10347 + return atomic_long_read(&cacct->sock[type][pos].count);
10352 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10354 + return atomic_long_read(&cacct->sock[type][pos].total);
10357 +#endif /* __KERNEL__ */
10358 +#endif /* _VX_CACCT_INT_H */
10359 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/check.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/check.h
10360 --- linux-2.6.29/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10361 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/check.h 2009-02-22 22:54:26.000000000 +0100
10363 +#ifndef _VS_CHECK_H
10364 +#define _VS_CHECK_H
10367 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10369 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10370 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10372 +#define MIN_D_CONTEXT 65536
10375 +/* check conditions */
10377 +#define VS_ADMIN 0x0001
10378 +#define VS_WATCH 0x0002
10379 +#define VS_HIDE 0x0004
10380 +#define VS_HOSTID 0x0008
10382 +#define VS_IDENT 0x0010
10383 +#define VS_EQUIV 0x0020
10384 +#define VS_PARENT 0x0040
10385 +#define VS_CHILD 0x0080
10387 +#define VS_ARG_MASK 0x00F0
10389 +#define VS_DYNAMIC 0x0100
10390 +#define VS_STATIC 0x0200
10392 +#define VS_ATR_MASK 0x0F00
10394 +#ifdef CONFIG_VSERVER_PRIVACY
10395 +#define VS_ADMIN_P (0)
10396 +#define VS_WATCH_P (0)
10398 +#define VS_ADMIN_P VS_ADMIN
10399 +#define VS_WATCH_P VS_WATCH
10402 +#define VS_HARDIRQ 0x1000
10403 +#define VS_SOFTIRQ 0x2000
10404 +#define VS_IRQ 0x4000
10406 +#define VS_IRQ_MASK 0xF000
10408 +#include <linux/hardirq.h>
10411 + * check current context for ADMIN/WATCH and
10412 + * optionally against supplied argument
10414 +static inline int __vs_check(int cid, int id, unsigned int mode)
10416 + if (mode & VS_ARG_MASK) {
10417 + if ((mode & VS_IDENT) && (id == cid))
10420 + if (mode & VS_ATR_MASK) {
10421 + if ((mode & VS_DYNAMIC) &&
10422 + (id >= MIN_D_CONTEXT) &&
10423 + (id <= MAX_S_CONTEXT))
10425 + if ((mode & VS_STATIC) &&
10426 + (id > 1) && (id < MIN_D_CONTEXT))
10429 + if (mode & VS_IRQ_MASK) {
10430 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10432 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10434 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10437 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10438 + ((mode & VS_WATCH) && (cid == 1)) ||
10439 + ((mode & VS_HOSTID) && (id == 0)));
10442 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10444 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10447 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10449 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10452 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/context_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/context_cmd.h
10453 --- linux-2.6.29/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10454 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/context_cmd.h 2009-02-22 22:54:26.000000000 +0100
10456 +#ifndef _VX_CONTEXT_CMD_H
10457 +#define _VX_CONTEXT_CMD_H
10460 +/* vinfo commands */
10462 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10465 +extern int vc_task_xid(uint32_t);
10467 +#endif /* __KERNEL__ */
10469 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10471 +struct vcmd_vx_info_v0 {
10473 + uint32_t initpid;
10474 + /* more to come */
10478 +extern int vc_vx_info(struct vx_info *, void __user *);
10480 +#endif /* __KERNEL__ */
10482 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10484 +struct vcmd_ctx_stat_v0 {
10487 + /* more to come */
10491 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10493 +#endif /* __KERNEL__ */
10495 +/* context commands */
10497 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10498 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10500 +struct vcmd_ctx_create {
10501 + uint64_t flagword;
10504 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10505 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10507 +struct vcmd_ctx_migrate {
10508 + uint64_t flagword;
10512 +extern int vc_ctx_create(uint32_t, void __user *);
10513 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10515 +#endif /* __KERNEL__ */
10518 +/* flag commands */
10520 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10521 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10523 +struct vcmd_ctx_flags_v0 {
10524 + uint64_t flagword;
10529 +extern int vc_get_cflags(struct vx_info *, void __user *);
10530 +extern int vc_set_cflags(struct vx_info *, void __user *);
10532 +#endif /* __KERNEL__ */
10535 +/* context caps commands */
10537 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10538 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10540 +struct vcmd_ctx_caps_v1 {
10546 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10547 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10549 +#endif /* __KERNEL__ */
10552 +/* bcaps commands */
10554 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10555 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10557 +struct vcmd_bcaps {
10563 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10564 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10566 +#endif /* __KERNEL__ */
10571 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10572 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10574 +struct vcmd_badness_v0 {
10579 +extern int vc_get_badness(struct vx_info *, void __user *);
10580 +extern int vc_set_badness(struct vx_info *, void __user *);
10582 +#endif /* __KERNEL__ */
10583 +#endif /* _VX_CONTEXT_CMD_H */
10584 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/context.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/context.h
10585 --- linux-2.6.29/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10586 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/context.h 2009-02-22 22:54:26.000000000 +0100
10588 +#ifndef _VX_CONTEXT_H
10589 +#define _VX_CONTEXT_H
10591 +#include <linux/types.h>
10592 +#include <linux/capability.h>
10595 +/* context flags */
10597 +#define VXF_INFO_SCHED 0x00000002
10598 +#define VXF_INFO_NPROC 0x00000004
10599 +#define VXF_INFO_PRIVATE 0x00000008
10601 +#define VXF_INFO_INIT 0x00000010
10602 +#define VXF_INFO_HIDE 0x00000020
10603 +#define VXF_INFO_ULIMIT 0x00000040
10604 +#define VXF_INFO_NSPACE 0x00000080
10606 +#define VXF_SCHED_HARD 0x00000100
10607 +#define VXF_SCHED_PRIO 0x00000200
10608 +#define VXF_SCHED_PAUSE 0x00000400
10610 +#define VXF_VIRT_MEM 0x00010000
10611 +#define VXF_VIRT_UPTIME 0x00020000
10612 +#define VXF_VIRT_CPU 0x00040000
10613 +#define VXF_VIRT_LOAD 0x00080000
10614 +#define VXF_VIRT_TIME 0x00100000
10616 +#define VXF_HIDE_MOUNT 0x01000000
10617 +/* was VXF_HIDE_NETIF 0x02000000 */
10618 +#define VXF_HIDE_VINFO 0x04000000
10620 +#define VXF_STATE_SETUP (1ULL << 32)
10621 +#define VXF_STATE_INIT (1ULL << 33)
10622 +#define VXF_STATE_ADMIN (1ULL << 34)
10624 +#define VXF_SC_HELPER (1ULL << 36)
10625 +#define VXF_REBOOT_KILL (1ULL << 37)
10626 +#define VXF_PERSISTENT (1ULL << 38)
10628 +#define VXF_FORK_RSS (1ULL << 48)
10629 +#define VXF_PROLIFIC (1ULL << 49)
10631 +#define VXF_IGNEG_NICE (1ULL << 52)
10633 +#define VXF_ONE_TIME (0x0007ULL << 32)
10635 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10638 +/* context migration */
10640 +#define VXM_SET_INIT 0x00000001
10641 +#define VXM_SET_REAPER 0x00000002
10643 +/* context caps */
10645 +#define VXC_CAP_MASK 0x00000000
10647 +#define VXC_SET_UTSNAME 0x00000001
10648 +#define VXC_SET_RLIMIT 0x00000002
10649 +#define VXC_FS_SECURITY 0x00000004
10651 +/* was VXC_RAW_ICMP 0x00000100 */
10652 +#define VXC_SYSLOG 0x00001000
10654 +#define VXC_SECURE_MOUNT 0x00010000
10655 +#define VXC_SECURE_REMOUNT 0x00020000
10656 +#define VXC_BINARY_MOUNT 0x00040000
10658 +#define VXC_QUOTA_CTL 0x00100000
10659 +#define VXC_ADMIN_MAPPER 0x00200000
10660 +#define VXC_ADMIN_CLOOP 0x00400000
10662 +#define VXC_KTHREAD 0x01000000
10667 +#include <linux/list.h>
10668 +#include <linux/spinlock.h>
10669 +#include <linux/rcupdate.h>
10671 +#include "limit_def.h"
10672 +#include "sched_def.h"
10673 +#include "cvirt_def.h"
10674 +#include "cacct_def.h"
10675 +#include "device_def.h"
10677 +#define VX_SPACES 2
10679 +struct _vx_info_pc {
10680 + struct _vx_sched_pc sched_pc;
10681 + struct _vx_cvirt_pc cvirt_pc;
10685 + struct hlist_node vx_hlist; /* linked list of contexts */
10686 + xid_t vx_id; /* context id */
10687 + atomic_t vx_usecnt; /* usage count */
10688 + atomic_t vx_tasks; /* tasks count */
10689 + struct vx_info *vx_parent; /* parent context */
10690 + int vx_state; /* context state */
10692 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10693 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10694 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
10696 + uint64_t vx_flags; /* context flags */
10697 + uint64_t vx_ccaps; /* context caps (vserver) */
10698 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10699 + // kernel_cap_t vx_cap_bset; /* the guest's bset */
10701 + struct task_struct *vx_reaper; /* guest reaper process */
10702 + pid_t vx_initpid; /* PID of guest init */
10703 + int64_t vx_badness_bias; /* OOM points bias */
10705 + struct _vx_limit limit; /* vserver limits */
10706 + struct _vx_sched sched; /* vserver scheduler */
10707 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10708 + struct _vx_cacct cacct; /* context accounting */
10710 + struct _vx_device dmap; /* default device map targets */
10712 +#ifndef CONFIG_SMP
10713 + struct _vx_info_pc info_pc; /* per cpu data */
10715 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10718 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10719 + int reboot_cmd; /* last sys_reboot() cmd */
10720 + int exit_code; /* last process exit code */
10722 + char vx_name[65]; /* vserver name */
10725 +#ifndef CONFIG_SMP
10726 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10727 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10729 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10730 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10733 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10736 +struct vx_info_save {
10737 + struct vx_info *vxi;
10742 +/* status flags */
10744 +#define VXS_HASHED 0x0001
10745 +#define VXS_PAUSED 0x0010
10746 +#define VXS_SHUTDOWN 0x0100
10747 +#define VXS_HELPER 0x1000
10748 +#define VXS_RELEASED 0x8000
10751 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10752 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10754 +extern struct vx_info *lookup_vx_info(int);
10755 +extern struct vx_info *lookup_or_create_vx_info(int);
10757 +extern int get_xid_list(int, unsigned int *, int);
10758 +extern int xid_is_hashed(xid_t);
10760 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10762 +extern long vs_state_change(struct vx_info *, unsigned int);
10765 +#endif /* __KERNEL__ */
10766 +#endif /* _VX_CONTEXT_H */
10767 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cvirt_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cvirt_cmd.h
10768 --- linux-2.6.29/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10769 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cvirt_cmd.h 2009-02-22 22:54:26.000000000 +0100
10771 +#ifndef _VX_CVIRT_CMD_H
10772 +#define _VX_CVIRT_CMD_H
10775 +/* virtual host info name commands */
10777 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10778 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10780 +struct vcmd_vhi_name_v0 {
10786 +enum vhi_name_field {
10787 + VHIN_CONTEXT = 0,
10799 +#include <linux/compiler.h>
10801 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10802 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10804 +#endif /* __KERNEL__ */
10806 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10808 +struct vcmd_virt_stat_v0 {
10811 + uint32_t nr_threads;
10812 + uint32_t nr_running;
10813 + uint32_t nr_uninterruptible;
10814 + uint32_t nr_onhold;
10815 + uint32_t nr_forks;
10816 + uint32_t load[3];
10820 +extern int vc_virt_stat(struct vx_info *, void __user *);
10822 +#endif /* __KERNEL__ */
10823 +#endif /* _VX_CVIRT_CMD_H */
10824 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cvirt_def.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cvirt_def.h
10825 --- linux-2.6.29/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10826 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cvirt_def.h 2009-02-22 22:54:26.000000000 +0100
10828 +#ifndef _VX_CVIRT_DEF_H
10829 +#define _VX_CVIRT_DEF_H
10831 +#include <linux/jiffies.h>
10832 +#include <linux/spinlock.h>
10833 +#include <linux/wait.h>
10834 +#include <linux/time.h>
10835 +#include <asm/atomic.h>
10838 +struct _vx_usage_stat {
10842 + uint64_t softirq;
10848 +struct _vx_syslog {
10849 + wait_queue_head_t log_wait;
10850 + spinlock_t logbuf_lock; /* lock for the log buffer */
10852 + unsigned long log_start; /* next char to be read by syslog() */
10853 + unsigned long con_start; /* next char to be sent to consoles */
10854 + unsigned long log_end; /* most-recently-written-char + 1 */
10855 + unsigned long logged_chars; /* #chars since last read+clear operation */
10857 + char log_buf[1024];
10861 +/* context sub struct */
10863 +struct _vx_cvirt {
10864 + atomic_t nr_threads; /* number of current threads */
10865 + atomic_t nr_running; /* number of running threads */
10866 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10868 + atomic_t nr_onhold; /* processes on hold */
10869 + uint32_t onhold_last; /* jiffies when put on hold */
10871 + struct timeval bias_tv; /* time offset to the host */
10872 + struct timespec bias_idle;
10873 + struct timespec bias_uptime; /* context creation point */
10874 + uint64_t bias_clock; /* offset in clock_t */
10876 + spinlock_t load_lock; /* lock for the load averages */
10877 + atomic_t load_updates; /* nr of load updates done so far */
10878 + uint32_t load_last; /* last time load was calculated */
10879 + uint32_t load[3]; /* load averages 1,5,15 */
10881 + atomic_t total_forks; /* number of forks so far */
10883 + struct _vx_syslog syslog;
10886 +struct _vx_cvirt_pc {
10887 + struct _vx_usage_stat cpustat;
10891 +#ifdef CONFIG_VSERVER_DEBUG
10893 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10895 + printk("\t_vx_cvirt:\n");
10896 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10897 + atomic_read(&cvirt->nr_threads),
10898 + atomic_read(&cvirt->nr_running),
10899 + atomic_read(&cvirt->nr_uninterruptible),
10900 + atomic_read(&cvirt->nr_onhold));
10901 + /* add rest here */
10902 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10907 +#endif /* _VX_CVIRT_DEF_H */
10908 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/cvirt.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cvirt.h
10909 --- linux-2.6.29/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
10910 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/cvirt.h 2009-02-22 22:54:26.000000000 +0100
10912 +#ifndef _VX_CVIRT_H
10913 +#define _VX_CVIRT_H
10920 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10925 +void vx_update_load(struct vx_info *);
10928 +int vx_do_syslog(int, char __user *, int);
10930 +#endif /* __KERNEL__ */
10931 +#endif /* _VX_CVIRT_H */
10932 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/debug_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/debug_cmd.h
10933 --- linux-2.6.29/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
10934 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/debug_cmd.h 2009-02-22 22:54:26.000000000 +0100
10936 +#ifndef _VX_DEBUG_CMD_H
10937 +#define _VX_DEBUG_CMD_H
10940 +/* debug commands */
10942 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
10944 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
10945 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
10947 +struct vcmd_read_history_v0 {
10950 + char __user *data;
10953 +struct vcmd_read_monitor_v0 {
10956 + char __user *data;
10962 +#ifdef CONFIG_COMPAT
10964 +#include <asm/compat.h>
10966 +struct vcmd_read_history_v0_x32 {
10969 + compat_uptr_t data_ptr;
10972 +struct vcmd_read_monitor_v0_x32 {
10975 + compat_uptr_t data_ptr;
10978 +#endif /* CONFIG_COMPAT */
10980 +extern int vc_dump_history(uint32_t);
10982 +extern int vc_read_history(uint32_t, void __user *);
10983 +extern int vc_read_monitor(uint32_t, void __user *);
10985 +#ifdef CONFIG_COMPAT
10987 +extern int vc_read_history_x32(uint32_t, void __user *);
10988 +extern int vc_read_monitor_x32(uint32_t, void __user *);
10990 +#endif /* CONFIG_COMPAT */
10992 +#endif /* __KERNEL__ */
10993 +#endif /* _VX_DEBUG_CMD_H */
10994 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/debug.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/debug.h
10995 --- linux-2.6.29/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
10996 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/debug.h 2009-02-22 22:54:26.000000000 +0100
10998 +#ifndef _VX_DEBUG_H
10999 +#define _VX_DEBUG_H
11002 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11003 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11004 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11006 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11007 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11008 +#define VXF_DEV "%p[%lu,%d:%d]"
11011 +#define vxd_path(p) \
11012 + ({ static char _buffer[PATH_MAX]; \
11013 + d_path(p, _buffer, sizeof(_buffer)); })
11015 +#define vxd_cond_path(n) \
11016 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11019 +#ifdef CONFIG_VSERVER_DEBUG
11021 +extern unsigned int vx_debug_switch;
11022 +extern unsigned int vx_debug_xid;
11023 +extern unsigned int vx_debug_nid;
11024 +extern unsigned int vx_debug_tag;
11025 +extern unsigned int vx_debug_net;
11026 +extern unsigned int vx_debug_limit;
11027 +extern unsigned int vx_debug_cres;
11028 +extern unsigned int vx_debug_dlim;
11029 +extern unsigned int vx_debug_quota;
11030 +extern unsigned int vx_debug_cvirt;
11031 +extern unsigned int vx_debug_space;
11032 +extern unsigned int vx_debug_misc;
11035 +#define VX_LOGLEVEL "vxD: "
11036 +#define VX_PROC_FMT "%p: "
11037 +#define VX_PROCESS current
11039 +#define vxdprintk(c, f, x...) \
11042 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11043 + VX_PROCESS , ##x); \
11046 +#define vxlprintk(c, f, x...) \
11049 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11052 +#define vxfprintk(c, f, x...) \
11055 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11061 +void dump_vx_info(struct vx_info *, int);
11062 +void dump_vx_info_inactive(int);
11064 +#else /* CONFIG_VSERVER_DEBUG */
11066 +#define vx_debug_switch 0
11067 +#define vx_debug_xid 0
11068 +#define vx_debug_nid 0
11069 +#define vx_debug_tag 0
11070 +#define vx_debug_net 0
11071 +#define vx_debug_limit 0
11072 +#define vx_debug_cres 0
11073 +#define vx_debug_dlim 0
11074 +#define vx_debug_cvirt 0
11076 +#define vxdprintk(x...) do { } while (0)
11077 +#define vxlprintk(x...) do { } while (0)
11078 +#define vxfprintk(x...) do { } while (0)
11080 +#endif /* CONFIG_VSERVER_DEBUG */
11083 +#ifdef CONFIG_VSERVER_WARN
11085 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11086 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11087 +#define VX_WARN_XID "[xid #%u] "
11088 +#define VX_WARN_NID "[nid #%u] "
11089 +#define VX_WARN_TAG "[tag #%u] "
11091 +#define vxwprintk(c, f, x...) \
11094 + printk(VX_WARNLEVEL f "\n", ##x); \
11097 +#else /* CONFIG_VSERVER_WARN */
11099 +#define vxwprintk(x...) do { } while (0)
11101 +#endif /* CONFIG_VSERVER_WARN */
11103 +#define vxwprintk_task(c, f, x...) \
11104 + vxwprintk(c, VX_WARN_TASK f, \
11105 + current->comm, current->pid, \
11106 + current->xid, current->nid, current->tag, ##x)
11107 +#define vxwprintk_xid(c, f, x...) \
11108 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11109 +#define vxwprintk_nid(c, f, x...) \
11110 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11111 +#define vxwprintk_tag(c, f, x...) \
11112 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11114 +#ifdef CONFIG_VSERVER_DEBUG
11115 +#define vxd_assert_lock(l) assert_spin_locked(l)
11116 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11117 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11119 +#define vxd_assert_lock(l) do { } while (0)
11120 +#define vxd_assert(c, f, x...) do { } while (0)
11124 +#endif /* _VX_DEBUG_H */
11125 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/device_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/device_cmd.h
11126 --- linux-2.6.29/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11127 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/device_cmd.h 2009-02-22 22:54:26.000000000 +0100
11129 +#ifndef _VX_DEVICE_CMD_H
11130 +#define _VX_DEVICE_CMD_H
11133 +/* device vserver commands */
11135 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11136 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11138 +struct vcmd_set_mapping_v0 {
11139 + const char __user *device;
11140 + const char __user *target;
11147 +#ifdef CONFIG_COMPAT
11149 +#include <asm/compat.h>
11151 +struct vcmd_set_mapping_v0_x32 {
11152 + compat_uptr_t device_ptr;
11153 + compat_uptr_t target_ptr;
11157 +#endif /* CONFIG_COMPAT */
11159 +#include <linux/compiler.h>
11161 +extern int vc_set_mapping(struct vx_info *, void __user *);
11162 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11164 +#ifdef CONFIG_COMPAT
11166 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11167 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11169 +#endif /* CONFIG_COMPAT */
11171 +#endif /* __KERNEL__ */
11172 +#endif /* _VX_DEVICE_CMD_H */
11173 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/device_def.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/device_def.h
11174 --- linux-2.6.29/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11175 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/device_def.h 2009-02-22 22:54:26.000000000 +0100
11177 +#ifndef _VX_DEVICE_DEF_H
11178 +#define _VX_DEVICE_DEF_H
11180 +#include <linux/types.h>
11182 +struct vx_dmap_target {
11187 +struct _vx_device {
11188 +#ifdef CONFIG_VSERVER_DEVICE
11189 + struct vx_dmap_target targets[2];
11193 +#endif /* _VX_DEVICE_DEF_H */
11194 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/device.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/device.h
11195 --- linux-2.6.29/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11196 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/device.h 2009-02-22 22:54:26.000000000 +0100
11198 +#ifndef _VX_DEVICE_H
11199 +#define _VX_DEVICE_H
11202 +#define DATTR_CREATE 0x00000001
11203 +#define DATTR_OPEN 0x00000002
11205 +#define DATTR_REMAP 0x00000010
11207 +#define DATTR_MASK 0x00000013
11210 +#else /* _VX_DEVICE_H */
11211 +#warning duplicate inclusion
11212 +#endif /* _VX_DEVICE_H */
11213 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/dlimit_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/dlimit_cmd.h
11214 --- linux-2.6.29/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11215 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/dlimit_cmd.h 2009-02-22 22:54:26.000000000 +0100
11217 +#ifndef _VX_DLIMIT_CMD_H
11218 +#define _VX_DLIMIT_CMD_H
11221 +/* dlimit vserver commands */
11223 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11224 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11226 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11227 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11229 +struct vcmd_ctx_dlimit_base_v0 {
11230 + const char __user *name;
11234 +struct vcmd_ctx_dlimit_v0 {
11235 + const char __user *name;
11236 + uint32_t space_used; /* used space in kbytes */
11237 + uint32_t space_total; /* maximum space in kbytes */
11238 + uint32_t inodes_used; /* used inodes */
11239 + uint32_t inodes_total; /* maximum inodes */
11240 + uint32_t reserved; /* reserved for root in % */
11244 +#define CDLIM_UNSET ((uint32_t)0UL)
11245 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11246 +#define CDLIM_KEEP ((uint32_t)~1UL)
11250 +#ifdef CONFIG_COMPAT
11252 +#include <asm/compat.h>
11254 +struct vcmd_ctx_dlimit_base_v0_x32 {
11255 + compat_uptr_t name_ptr;
11259 +struct vcmd_ctx_dlimit_v0_x32 {
11260 + compat_uptr_t name_ptr;
11261 + uint32_t space_used; /* used space in kbytes */
11262 + uint32_t space_total; /* maximum space in kbytes */
11263 + uint32_t inodes_used; /* used inodes */
11264 + uint32_t inodes_total; /* maximum inodes */
11265 + uint32_t reserved; /* reserved for root in % */
11269 +#endif /* CONFIG_COMPAT */
11271 +#include <linux/compiler.h>
11273 +extern int vc_add_dlimit(uint32_t, void __user *);
11274 +extern int vc_rem_dlimit(uint32_t, void __user *);
11276 +extern int vc_set_dlimit(uint32_t, void __user *);
11277 +extern int vc_get_dlimit(uint32_t, void __user *);
11279 +#ifdef CONFIG_COMPAT
11281 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11282 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11284 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11285 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11287 +#endif /* CONFIG_COMPAT */
11289 +#endif /* __KERNEL__ */
11290 +#endif /* _VX_DLIMIT_CMD_H */
11291 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/dlimit.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/dlimit.h
11292 --- linux-2.6.29/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11293 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/dlimit.h 2009-02-22 22:54:26.000000000 +0100
11295 +#ifndef _VX_DLIMIT_H
11296 +#define _VX_DLIMIT_H
11298 +#include "switch.h"
11303 +/* keep in sync with CDLIM_INFINITY */
11305 +#define DLIM_INFINITY (~0ULL)
11307 +#include <linux/spinlock.h>
11308 +#include <linux/rcupdate.h>
11310 +struct super_block;
11313 + struct hlist_node dl_hlist; /* linked list of contexts */
11314 + struct rcu_head dl_rcu; /* the rcu head */
11315 + tag_t dl_tag; /* context tag */
11316 + atomic_t dl_usecnt; /* usage count */
11317 + atomic_t dl_refcnt; /* reference count */
11319 + struct super_block *dl_sb; /* associated superblock */
11321 + spinlock_t dl_lock; /* protect the values */
11323 + unsigned long long dl_space_used; /* used space in bytes */
11324 + unsigned long long dl_space_total; /* maximum space in bytes */
11325 + unsigned long dl_inodes_used; /* used inodes */
11326 + unsigned long dl_inodes_total; /* maximum inodes */
11328 + unsigned int dl_nrlmult; /* non root limit mult */
11333 +extern void rcu_free_dl_info(struct rcu_head *);
11334 +extern void unhash_dl_info(struct dl_info *);
11336 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11341 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11343 +typedef uint64_t dlsize_t;
11345 +#endif /* __KERNEL__ */
11346 +#else /* _VX_DLIMIT_H */
11347 +#warning duplicate inclusion
11348 +#endif /* _VX_DLIMIT_H */
11349 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/global.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/global.h
11350 --- linux-2.6.29/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11351 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/global.h 2009-02-22 22:54:26.000000000 +0100
11353 +#ifndef _VX_GLOBAL_H
11354 +#define _VX_GLOBAL_H
11357 +extern atomic_t vx_global_ctotal;
11358 +extern atomic_t vx_global_cactive;
11360 +extern atomic_t nx_global_ctotal;
11361 +extern atomic_t nx_global_cactive;
11363 +extern atomic_t vs_global_nsproxy;
11364 +extern atomic_t vs_global_fs;
11365 +extern atomic_t vs_global_mnt_ns;
11366 +extern atomic_t vs_global_uts_ns;
11367 +extern atomic_t vs_global_ipc_ns;
11368 +extern atomic_t vs_global_user_ns;
11369 +extern atomic_t vs_global_pid_ns;
11372 +#endif /* _VX_GLOBAL_H */
11373 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/history.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/history.h
11374 --- linux-2.6.29/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11375 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/history.h 2009-02-22 22:54:26.000000000 +0100
11377 +#ifndef _VX_HISTORY_H
11378 +#define _VX_HISTORY_H
11383 + VXH_THROW_OOPS = 1,
11387 + VXH_INIT_VX_INFO,
11390 + VXH_CLAIM_VX_INFO,
11391 + VXH_RELEASE_VX_INFO,
11392 + VXH_ALLOC_VX_INFO,
11393 + VXH_DEALLOC_VX_INFO,
11394 + VXH_HASH_VX_INFO,
11395 + VXH_UNHASH_VX_INFO,
11397 + VXH_LOOKUP_VX_INFO,
11398 + VXH_CREATE_VX_INFO,
11401 +struct _vxhe_vxi {
11402 + struct vx_info *ptr;
11408 +struct _vxhe_set_clr {
11412 +struct _vxhe_loc_lookup {
11416 +struct _vx_hist_entry {
11418 + unsigned short seq;
11419 + unsigned short type;
11420 + struct _vxhe_vxi vxi;
11422 + struct _vxhe_set_clr sc;
11423 + struct _vxhe_loc_lookup ll;
11427 +#ifdef CONFIG_VSERVER_HISTORY
11429 +extern unsigned volatile int vxh_active;
11431 +struct _vx_hist_entry *vxh_advance(void *loc);
11435 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11437 + entry->vxi.ptr = vxi;
11439 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11440 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11441 + entry->vxi.xid = vxi->vx_id;
11446 +#define __HERE__ current_text_addr()
11448 +#define __VXH_BODY(__type, __data, __here) \
11449 + struct _vx_hist_entry *entry; \
11451 + preempt_disable(); \
11452 + entry = vxh_advance(__here); \
11454 + entry->type = __type; \
11455 + preempt_enable();
11458 + /* pass vxi only */
11460 +#define __VXH_SMPL \
11461 + __vxh_copy_vxi(entry, vxi)
11464 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11466 + __VXH_BODY(__type, __VXH_SMPL, __here)
11469 + /* pass vxi and data (void *) */
11471 +#define __VXH_DATA \
11472 + __vxh_copy_vxi(entry, vxi); \
11473 + entry->sc.data = data
11476 +void __vxh_data(struct vx_info *vxi, void *data,
11477 + int __type, void *__here)
11479 + __VXH_BODY(__type, __VXH_DATA, __here)
11482 + /* pass vxi and arg (long) */
11484 +#define __VXH_LONG \
11485 + __vxh_copy_vxi(entry, vxi); \
11486 + entry->ll.arg = arg
11489 +void __vxh_long(struct vx_info *vxi, long arg,
11490 + int __type, void *__here)
11492 + __VXH_BODY(__type, __VXH_LONG, __here)
11497 +void __vxh_throw_oops(void *__here)
11499 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11500 + /* prevent further acquisition */
11505 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11507 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11508 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11510 +#define __vxh_init_vx_info(v, d, h) \
11511 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11512 +#define __vxh_set_vx_info(v, d, h) \
11513 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11514 +#define __vxh_clr_vx_info(v, d, h) \
11515 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11517 +#define __vxh_claim_vx_info(v, d, h) \
11518 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11519 +#define __vxh_release_vx_info(v, d, h) \
11520 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11522 +#define vxh_alloc_vx_info(v) \
11523 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11524 +#define vxh_dealloc_vx_info(v) \
11525 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11527 +#define vxh_hash_vx_info(v) \
11528 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11529 +#define vxh_unhash_vx_info(v) \
11530 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11532 +#define vxh_loc_vx_info(v, l) \
11533 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11534 +#define vxh_lookup_vx_info(v, l) \
11535 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11536 +#define vxh_create_vx_info(v, l) \
11537 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11539 +extern void vxh_dump_history(void);
11542 +#else /* CONFIG_VSERVER_HISTORY */
11544 +#define __HERE__ 0
11546 +#define vxh_throw_oops() do { } while (0)
11548 +#define __vxh_get_vx_info(v, h) do { } while (0)
11549 +#define __vxh_put_vx_info(v, h) do { } while (0)
11551 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11552 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11553 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11555 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11556 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11558 +#define vxh_alloc_vx_info(v) do { } while (0)
11559 +#define vxh_dealloc_vx_info(v) do { } while (0)
11561 +#define vxh_hash_vx_info(v) do { } while (0)
11562 +#define vxh_unhash_vx_info(v) do { } while (0)
11564 +#define vxh_loc_vx_info(v, l) do { } while (0)
11565 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11566 +#define vxh_create_vx_info(v, l) do { } while (0)
11568 +#define vxh_dump_history() do { } while (0)
11571 +#endif /* CONFIG_VSERVER_HISTORY */
11573 +#endif /* _VX_HISTORY_H */
11574 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/inode_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/inode_cmd.h
11575 --- linux-2.6.29/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11576 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/inode_cmd.h 2009-02-22 22:54:26.000000000 +0100
11578 +#ifndef _VX_INODE_CMD_H
11579 +#define _VX_INODE_CMD_H
11582 +/* inode vserver commands */
11584 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11585 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11587 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11588 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11590 +struct vcmd_ctx_iattr_v1 {
11591 + const char __user *name;
11597 +struct vcmd_ctx_fiattr_v0 {
11607 +#ifdef CONFIG_COMPAT
11609 +#include <asm/compat.h>
11611 +struct vcmd_ctx_iattr_v1_x32 {
11612 + compat_uptr_t name_ptr;
11618 +#endif /* CONFIG_COMPAT */
11620 +#include <linux/compiler.h>
11622 +extern int vc_get_iattr(void __user *);
11623 +extern int vc_set_iattr(void __user *);
11625 +extern int vc_fget_iattr(uint32_t, void __user *);
11626 +extern int vc_fset_iattr(uint32_t, void __user *);
11628 +#ifdef CONFIG_COMPAT
11630 +extern int vc_get_iattr_x32(void __user *);
11631 +extern int vc_set_iattr_x32(void __user *);
11633 +#endif /* CONFIG_COMPAT */
11635 +#endif /* __KERNEL__ */
11636 +#endif /* _VX_INODE_CMD_H */
11637 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/inode.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/inode.h
11638 --- linux-2.6.29/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11639 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/inode.h 2009-02-22 22:54:26.000000000 +0100
11641 +#ifndef _VX_INODE_H
11642 +#define _VX_INODE_H
11645 +#define IATTR_TAG 0x01000000
11647 +#define IATTR_ADMIN 0x00000001
11648 +#define IATTR_WATCH 0x00000002
11649 +#define IATTR_HIDE 0x00000004
11650 +#define IATTR_FLAGS 0x00000007
11652 +#define IATTR_BARRIER 0x00010000
11653 +#define IATTR_IXUNLINK 0x00020000
11654 +#define IATTR_IMMUTABLE 0x00040000
11659 +#ifdef CONFIG_VSERVER_PROC_SECURE
11660 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11661 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11663 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11664 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11667 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11669 +#endif /* __KERNEL__ */
11671 +/* inode ioctls */
11673 +#define FIOC_GETXFLG _IOR('x', 5, long)
11674 +#define FIOC_SETXFLG _IOW('x', 6, long)
11676 +#else /* _VX_INODE_H */
11677 +#warning duplicate inclusion
11678 +#endif /* _VX_INODE_H */
11679 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/Kbuild linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/Kbuild
11680 --- linux-2.6.29/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11681 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/Kbuild 2009-02-22 22:54:26.000000000 +0100
11684 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11685 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11686 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11687 + debug_cmd.h device_cmd.h
11689 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11691 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit_cmd.h
11692 --- linux-2.6.29/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11693 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit_cmd.h 2009-02-22 22:54:26.000000000 +0100
11695 +#ifndef _VX_LIMIT_CMD_H
11696 +#define _VX_LIMIT_CMD_H
11699 +/* rlimit vserver commands */
11701 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11702 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11703 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11704 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11706 +struct vcmd_ctx_rlimit_v0 {
11708 + uint64_t minimum;
11709 + uint64_t softlimit;
11710 + uint64_t maximum;
11713 +struct vcmd_ctx_rlimit_mask_v0 {
11714 + uint32_t minimum;
11715 + uint32_t softlimit;
11716 + uint32_t maximum;
11719 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11721 +struct vcmd_rlimit_stat_v0 {
11725 + uint64_t minimum;
11726 + uint64_t maximum;
11729 +#define CRLIM_UNSET (0ULL)
11730 +#define CRLIM_INFINITY (~0ULL)
11731 +#define CRLIM_KEEP (~1ULL)
11735 +#ifdef CONFIG_IA32_EMULATION
11737 +struct vcmd_ctx_rlimit_v0_x32 {
11739 + uint64_t minimum;
11740 + uint64_t softlimit;
11741 + uint64_t maximum;
11742 +} __attribute__ ((packed));
11744 +#endif /* CONFIG_IA32_EMULATION */
11746 +#include <linux/compiler.h>
11748 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11749 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11750 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11751 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11753 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11755 +#ifdef CONFIG_IA32_EMULATION
11757 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11758 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11760 +#endif /* CONFIG_IA32_EMULATION */
11762 +#endif /* __KERNEL__ */
11763 +#endif /* _VX_LIMIT_CMD_H */
11764 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit_def.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit_def.h
11765 --- linux-2.6.29/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11766 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit_def.h 2009-02-22 22:54:26.000000000 +0100
11768 +#ifndef _VX_LIMIT_DEF_H
11769 +#define _VX_LIMIT_DEF_H
11771 +#include <asm/atomic.h>
11772 +#include <asm/resource.h>
11774 +#include "limit.h"
11777 +struct _vx_res_limit {
11778 + rlim_t soft; /* Context soft limit */
11779 + rlim_t hard; /* Context hard limit */
11781 + rlim_atomic_t rcur; /* Current value */
11782 + rlim_t rmin; /* Context minimum */
11783 + rlim_t rmax; /* Context maximum */
11785 + atomic_t lhit; /* Limit hits */
11788 +/* context sub struct */
11790 +struct _vx_limit {
11791 + struct _vx_res_limit res[NUM_LIMITS];
11794 +#ifdef CONFIG_VSERVER_DEBUG
11796 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11800 + printk("\t_vx_limit:");
11801 + for (i = 0; i < NUM_LIMITS; i++) {
11802 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11803 + i, (unsigned long)__rlim_get(limit, i),
11804 + (unsigned long)__rlim_rmin(limit, i),
11805 + (unsigned long)__rlim_rmax(limit, i),
11806 + (long)__rlim_soft(limit, i),
11807 + (long)__rlim_hard(limit, i),
11808 + atomic_read(&__rlim_lhit(limit, i)));
11814 +#endif /* _VX_LIMIT_DEF_H */
11815 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit.h
11816 --- linux-2.6.29/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11817 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit.h 2009-02-22 22:54:26.000000000 +0100
11819 +#ifndef _VX_LIMIT_H
11820 +#define _VX_LIMIT_H
11822 +#define VLIMIT_NSOCK 16
11823 +#define VLIMIT_OPENFD 17
11824 +#define VLIMIT_ANON 18
11825 +#define VLIMIT_SHMEM 19
11826 +#define VLIMIT_SEMARY 20
11827 +#define VLIMIT_NSEMS 21
11828 +#define VLIMIT_DENTRY 22
11829 +#define VLIMIT_MAPPED 23
11834 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11836 +/* keep in sync with CRLIM_INFINITY */
11838 +#define VLIM_INFINITY (~0ULL)
11840 +#include <asm/atomic.h>
11841 +#include <asm/resource.h>
11843 +#ifndef RLIM_INFINITY
11844 +#warning RLIM_INFINITY is undefined
11847 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11849 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11850 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11852 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11853 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11854 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11856 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11857 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11859 +typedef atomic_long_t rlim_atomic_t;
11860 +typedef unsigned long rlim_t;
11862 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11863 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11864 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11865 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11866 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11867 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11870 +#if (RLIM_INFINITY == VLIM_INFINITY)
11871 +#define VX_VLIM(r) ((long long)(long)(r))
11872 +#define VX_RLIM(v) ((rlim_t)(v))
11874 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11875 + ? VLIM_INFINITY : (long long)(r))
11876 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11877 + ? RLIM_INFINITY : (rlim_t)(v))
11882 +void vx_vsi_meminfo(struct sysinfo *);
11883 +void vx_vsi_swapinfo(struct sysinfo *);
11885 +#define NUM_LIMITS 24
11887 +#endif /* __KERNEL__ */
11888 +#endif /* _VX_LIMIT_H */
11889 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/limit_int.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit_int.h
11890 --- linux-2.6.29/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
11891 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/limit_int.h 2009-02-22 22:54:26.000000000 +0100
11893 +#ifndef _VX_LIMIT_INT_H
11894 +#define _VX_LIMIT_INT_H
11896 +#include "context.h"
11900 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11901 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11903 +extern const char *vlimit_name[NUM_LIMITS];
11905 +static inline void __vx_acc_cres(struct vx_info *vxi,
11906 + int res, int dir, void *_data, char *_file, int _line)
11908 + if (VXD_RCRES_COND(res))
11909 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
11910 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11911 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11912 + (dir > 0) ? "++" : "--", _data, _file, _line);
11917 + __rlim_inc(&vxi->limit, res);
11919 + __rlim_dec(&vxi->limit, res);
11922 +static inline void __vx_add_cres(struct vx_info *vxi,
11923 + int res, int amount, void *_data, char *_file, int _line)
11925 + if (VXD_RCRES_COND(res))
11926 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
11927 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11928 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11929 + amount, _data, _file, _line);
11934 + __rlim_add(&vxi->limit, res, amount);
11938 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
11940 + int cond = (value > __rlim_rmax(limit, res));
11943 + __rlim_rmax(limit, res) = value;
11948 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
11950 + int cond = (value < __rlim_rmin(limit, res));
11953 + __rlim_rmin(limit, res) = value;
11958 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
11960 + if (!__vx_cres_adjust_max(limit, res, value))
11961 + __vx_cres_adjust_min(limit, res, value);
11966 + +1 ... no limit hit
11967 + -1 ... over soft limit
11968 + 0 ... over hard limit */
11970 +static inline int __vx_cres_avail(struct vx_info *vxi,
11971 + int res, int num, char *_file, int _line)
11973 + struct _vx_limit *limit;
11976 + if (VXD_RLIMIT_COND(res))
11977 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
11978 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11979 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
11980 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
11981 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11982 + num, _file, _line);
11986 + limit = &vxi->limit;
11987 + value = __rlim_get(limit, res);
11989 + if (!__vx_cres_adjust_max(limit, res, value))
11990 + __vx_cres_adjust_min(limit, res, value);
11995 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
11997 + if (value + num <= __rlim_soft(limit, res))
12000 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12002 + if (value + num <= __rlim_hard(limit, res))
12005 + __rlim_hit(limit, res);
12010 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12013 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12015 + rlim_t value, sum = 0;
12018 + while ((res = *array++)) {
12019 + value = __rlim_get(limit, res);
12020 + __vx_cres_fixup(limit, res, value);
12027 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12029 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12030 + int res = *array;
12032 + if (value == __rlim_get(limit, res))
12035 + __rlim_set(limit, res, value);
12036 + /* now adjust min/max */
12037 + if (!__vx_cres_adjust_max(limit, res, value))
12038 + __vx_cres_adjust_min(limit, res, value);
12043 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12044 + const int *array, int num, char *_file, int _line)
12046 + struct _vx_limit *limit;
12047 + rlim_t value = 0;
12055 + limit = &vxi->limit;
12057 + value = __vx_cres_array_sum(limit, array + 1);
12059 + __rlim_set(limit, res, value);
12060 + __vx_cres_fixup(limit, res, value);
12062 + return __vx_cres_avail(vxi, res, num, _file, _line);
12066 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12071 + /* complex resources first */
12072 + if ((id < 0) || (id == RLIMIT_RSS))
12073 + __vx_cres_array_fixup(limit, VLA_RSS);
12075 + for (res = 0; res < NUM_LIMITS; res++) {
12076 + if ((id > 0) && (res != id))
12079 + value = __rlim_get(limit, res);
12080 + __vx_cres_fixup(limit, res, value);
12082 + /* not supposed to happen, maybe warn? */
12083 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12084 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12089 +#endif /* __KERNEL__ */
12090 +#endif /* _VX_LIMIT_INT_H */
12091 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/monitor.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/monitor.h
12092 --- linux-2.6.29/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12093 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/monitor.h 2009-02-22 22:54:26.000000000 +0100
12095 +#ifndef _VX_MONITOR_H
12096 +#define _VX_MONITOR_H
12098 +#include <linux/types.h>
12105 + VXM_UPDATE = 0x20,
12109 + VXM_RQINFO_1 = 0x24,
12112 + VXM_ACTIVATE = 0x40,
12119 + VXM_MIGRATE = 0x48,
12122 + /* all other bits are flags */
12123 + VXM_SCHED = 0x80,
12126 +struct _vxm_update_1 {
12127 + uint32_t tokens_max;
12128 + uint32_t fill_rate;
12129 + uint32_t interval;
12132 +struct _vxm_update_2 {
12133 + uint32_t tokens_min;
12134 + uint32_t fill_rate;
12135 + uint32_t interval;
12138 +struct _vxm_rqinfo_1 {
12139 + uint16_t running;
12143 + uint32_t idle_tokens;
12146 +struct _vxm_rqinfo_2 {
12147 + uint32_t norm_time;
12148 + uint32_t idle_time;
12149 + uint32_t idle_skip;
12152 +struct _vxm_sched {
12154 + uint32_t norm_time;
12155 + uint32_t idle_time;
12158 +struct _vxm_task {
12163 +struct _vxm_event {
12172 + struct _vxm_task tsk;
12176 +struct _vx_mon_entry {
12180 + struct _vxm_event ev;
12181 + struct _vxm_sched sd;
12182 + struct _vxm_update_1 u1;
12183 + struct _vxm_update_2 u2;
12184 + struct _vxm_rqinfo_1 q1;
12185 + struct _vxm_rqinfo_2 q2;
12190 +#endif /* _VX_MONITOR_H */
12191 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/network_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/network_cmd.h
12192 --- linux-2.6.29/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12193 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/network_cmd.h 2009-02-22 22:54:26.000000000 +0100
12195 +#ifndef _VX_NETWORK_CMD_H
12196 +#define _VX_NETWORK_CMD_H
12199 +/* vinfo commands */
12201 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12204 +extern int vc_task_nid(uint32_t);
12206 +#endif /* __KERNEL__ */
12208 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12210 +struct vcmd_nx_info_v0 {
12212 + /* more to come */
12216 +extern int vc_nx_info(struct nx_info *, void __user *);
12218 +#endif /* __KERNEL__ */
12220 +#include <linux/in.h>
12221 +#include <linux/in6.h>
12223 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12224 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12226 +struct vcmd_net_create {
12227 + uint64_t flagword;
12230 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12232 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12233 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12235 +struct vcmd_net_addr_v0 {
12238 + struct in_addr ip[4];
12239 + struct in_addr mask[4];
12242 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12243 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12245 +struct vcmd_net_addr_ipv4_v1 {
12248 + struct in_addr ip;
12249 + struct in_addr mask;
12252 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12253 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12255 +struct vcmd_net_addr_ipv6_v1 {
12259 + struct in6_addr ip;
12260 + struct in6_addr mask;
12263 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12264 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12266 +struct vcmd_match_ipv4_v0 {
12271 + struct in_addr ip;
12272 + struct in_addr ip2;
12273 + struct in_addr mask;
12276 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12277 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12279 +struct vcmd_match_ipv6_v0 {
12284 + struct in6_addr ip;
12285 + struct in6_addr ip2;
12286 + struct in6_addr mask;
12291 +extern int vc_net_create(uint32_t, void __user *);
12292 +extern int vc_net_migrate(struct nx_info *, void __user *);
12294 +extern int vc_net_add(struct nx_info *, void __user *);
12295 +extern int vc_net_remove(struct nx_info *, void __user *);
12297 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12298 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12300 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12301 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12303 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12304 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12306 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12307 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12309 +#endif /* __KERNEL__ */
12312 +/* flag commands */
12314 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12315 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12317 +struct vcmd_net_flags_v0 {
12318 + uint64_t flagword;
12323 +extern int vc_get_nflags(struct nx_info *, void __user *);
12324 +extern int vc_set_nflags(struct nx_info *, void __user *);
12326 +#endif /* __KERNEL__ */
12329 +/* network caps commands */
12331 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12332 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12334 +struct vcmd_net_caps_v0 {
12340 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12341 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12343 +#endif /* __KERNEL__ */
12344 +#endif /* _VX_CONTEXT_CMD_H */
12345 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/network.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/network.h
12346 --- linux-2.6.29/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12347 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/network.h 2009-02-22 22:54:26.000000000 +0100
12349 +#ifndef _VX_NETWORK_H
12350 +#define _VX_NETWORK_H
12352 +#include <linux/types.h>
12355 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12358 +/* network flags */
12360 +#define NXF_INFO_PRIVATE 0x00000008
12362 +#define NXF_SINGLE_IP 0x00000100
12363 +#define NXF_LBACK_REMAP 0x00000200
12364 +#define NXF_LBACK_ALLOW 0x00000400
12366 +#define NXF_HIDE_NETIF 0x02000000
12367 +#define NXF_HIDE_LBACK 0x04000000
12369 +#define NXF_STATE_SETUP (1ULL << 32)
12370 +#define NXF_STATE_ADMIN (1ULL << 34)
12372 +#define NXF_SC_HELPER (1ULL << 36)
12373 +#define NXF_PERSISTENT (1ULL << 38)
12375 +#define NXF_ONE_TIME (0x0005ULL << 32)
12378 +#define NXF_INIT_SET (__nxf_init_set())
12380 +static inline uint64_t __nxf_init_set(void) {
12381 + return NXF_STATE_ADMIN
12382 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12383 + | NXF_LBACK_REMAP
12386 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12389 + | NXF_HIDE_NETIF;
12393 +/* network caps */
12395 +#define NXC_TUN_CREATE 0x00000001
12397 +#define NXC_RAW_ICMP 0x00000100
12400 +/* address types */
12402 +#define NXA_TYPE_IPV4 0x0001
12403 +#define NXA_TYPE_IPV6 0x0002
12405 +#define NXA_TYPE_NONE 0x0000
12406 +#define NXA_TYPE_ANY 0x00FF
12408 +#define NXA_TYPE_ADDR 0x0010
12409 +#define NXA_TYPE_MASK 0x0020
12410 +#define NXA_TYPE_RANGE 0x0040
12412 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12414 +#define NXA_MOD_BCAST 0x0100
12415 +#define NXA_MOD_LBACK 0x0200
12417 +#define NXA_LOOPBACK 0x1000
12419 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12420 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12424 +#include <linux/list.h>
12425 +#include <linux/spinlock.h>
12426 +#include <linux/rcupdate.h>
12427 +#include <linux/in.h>
12428 +#include <linux/in6.h>
12429 +#include <asm/atomic.h>
12431 +struct nx_addr_v4 {
12432 + struct nx_addr_v4 *next;
12433 + struct in_addr ip[2];
12434 + struct in_addr mask;
12439 +struct nx_addr_v6 {
12440 + struct nx_addr_v6 *next;
12441 + struct in6_addr ip;
12442 + struct in6_addr mask;
12449 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12450 + nid_t nx_id; /* vnet id */
12451 + atomic_t nx_usecnt; /* usage count */
12452 + atomic_t nx_tasks; /* tasks count */
12453 + int nx_state; /* context state */
12455 + uint64_t nx_flags; /* network flag word */
12456 + uint64_t nx_ncaps; /* network capabilities */
12458 + struct in_addr v4_lback; /* Loopback address */
12459 + struct in_addr v4_bcast; /* Broadcast address */
12460 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12461 +#ifdef CONFIG_IPV6
12462 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12464 + char nx_name[65]; /* network context name */
12468 +/* status flags */
12470 +#define NXS_HASHED 0x0001
12471 +#define NXS_SHUTDOWN 0x0100
12472 +#define NXS_RELEASED 0x8000
12474 +extern struct nx_info *lookup_nx_info(int);
12476 +extern int get_nid_list(int, unsigned int *, int);
12477 +extern int nid_is_hashed(nid_t);
12479 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12481 +extern long vs_net_change(struct nx_info *, unsigned int);
12486 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12487 +#ifdef CONFIG_IPV6
12488 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12490 +#define NX_IPV6(n) (0)
12493 +#endif /* __KERNEL__ */
12494 +#endif /* _VX_NETWORK_H */
12495 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/percpu.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/percpu.h
12496 --- linux-2.6.29/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12497 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/percpu.h 2009-02-22 22:54:26.000000000 +0100
12499 +#ifndef _VX_PERCPU_H
12500 +#define _VX_PERCPU_H
12502 +#include "cvirt_def.h"
12503 +#include "sched_def.h"
12505 +struct _vx_percpu {
12506 + struct _vx_cvirt_pc cvirt;
12507 + struct _vx_sched_pc sched;
12510 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12512 +#endif /* _VX_PERCPU_H */
12513 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/pid.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/pid.h
12514 --- linux-2.6.29/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12515 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/pid.h 2009-02-22 22:54:26.000000000 +0100
12517 +#ifndef _VSERVER_PID_H
12518 +#define _VSERVER_PID_H
12520 +/* pid faking stuff */
12522 +#define vx_info_map_pid(v, p) \
12523 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12524 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12525 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12526 +#define vx_map_tgid(p) vx_map_pid(p)
12528 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12529 + const char *func, const char *file, int line)
12531 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12532 + vxfprintk(VXD_CBIT(cvirt, 2),
12533 + "vx_map_tgid: %p/%llx: %d -> %d",
12534 + vxi, (long long)vxi->vx_flags, pid,
12535 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12536 + func, file, line);
12539 + if (pid == vxi->vx_initpid)
12545 +#define vx_info_rmap_pid(v, p) \
12546 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12547 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12548 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12550 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12551 + const char *func, const char *file, int line)
12553 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12554 + vxfprintk(VXD_CBIT(cvirt, 2),
12555 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12556 + vxi, (long long)vxi->vx_flags, pid,
12557 + (pid == 1) ? vxi->vx_initpid : pid,
12558 + func, file, line);
12559 + if ((pid == 1) && vxi->vx_initpid)
12560 + return vxi->vx_initpid;
12561 + if (pid == vxi->vx_initpid)
12568 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/sched_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/sched_cmd.h
12569 --- linux-2.6.29/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12570 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/sched_cmd.h 2009-02-22 22:54:26.000000000 +0100
12572 +#ifndef _VX_SCHED_CMD_H
12573 +#define _VX_SCHED_CMD_H
12576 +/* sched vserver commands */
12578 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12579 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12580 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12582 +struct vcmd_set_sched_v2 {
12583 + int32_t fill_rate;
12584 + int32_t interval;
12586 + int32_t tokens_min;
12587 + int32_t tokens_max;
12588 + uint64_t cpu_mask;
12591 +struct vcmd_set_sched_v3 {
12592 + uint32_t set_mask;
12593 + int32_t fill_rate;
12594 + int32_t interval;
12596 + int32_t tokens_min;
12597 + int32_t tokens_max;
12598 + int32_t priority_bias;
12601 +struct vcmd_set_sched_v4 {
12602 + uint32_t set_mask;
12603 + int32_t fill_rate;
12604 + int32_t interval;
12606 + int32_t tokens_min;
12607 + int32_t tokens_max;
12608 + int32_t prio_bias;
12610 + int32_t bucket_id;
12613 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12614 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12616 +struct vcmd_sched_v5 {
12619 + int32_t bucket_id;
12620 + int32_t fill_rate[2];
12621 + int32_t interval[2];
12623 + int32_t tokens_min;
12624 + int32_t tokens_max;
12625 + int32_t prio_bias;
12628 +#define VXSM_FILL_RATE 0x0001
12629 +#define VXSM_INTERVAL 0x0002
12630 +#define VXSM_FILL_RATE2 0x0004
12631 +#define VXSM_INTERVAL2 0x0008
12632 +#define VXSM_TOKENS 0x0010
12633 +#define VXSM_TOKENS_MIN 0x0020
12634 +#define VXSM_TOKENS_MAX 0x0040
12635 +#define VXSM_PRIO_BIAS 0x0100
12637 +#define VXSM_IDLE_TIME 0x0200
12638 +#define VXSM_FORCE 0x0400
12640 +#define VXSM_V3_MASK 0x0173
12641 +#define VXSM_SET_MASK 0x01FF
12643 +#define VXSM_CPU_ID 0x1000
12644 +#define VXSM_BUCKET_ID 0x2000
12646 +#define VXSM_MSEC 0x4000
12648 +#define SCHED_KEEP (-2) /* only for v2 */
12652 +#include <linux/compiler.h>
12654 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12655 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12656 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12657 +extern int vc_set_sched(struct vx_info *, void __user *);
12658 +extern int vc_get_sched(struct vx_info *, void __user *);
12660 +#endif /* __KERNEL__ */
12662 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12664 +struct vcmd_sched_info {
12666 + int32_t bucket_id;
12667 + uint64_t user_msec;
12668 + uint64_t sys_msec;
12669 + uint64_t hold_msec;
12670 + uint32_t token_usec;
12671 + int32_t vavavoom;
12676 +extern int vc_sched_info(struct vx_info *, void __user *);
12678 +#endif /* __KERNEL__ */
12679 +#endif /* _VX_SCHED_CMD_H */
12680 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/sched_def.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/sched_def.h
12681 --- linux-2.6.29/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12682 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/sched_def.h 2009-02-22 22:54:26.000000000 +0100
12684 +#ifndef _VX_SCHED_DEF_H
12685 +#define _VX_SCHED_DEF_H
12687 +#include <linux/spinlock.h>
12688 +#include <linux/jiffies.h>
12689 +#include <linux/cpumask.h>
12690 +#include <asm/atomic.h>
12691 +#include <asm/param.h>
12694 +/* context sub struct */
12696 +struct _vx_sched {
12697 + spinlock_t tokens_lock; /* lock for token bucket */
12699 + int tokens; /* number of CPU tokens */
12700 + int fill_rate[2]; /* Fill rate: add X tokens... */
12701 + int interval[2]; /* Divisor: per Y jiffies */
12702 + int tokens_min; /* Limit: minimum for unhold */
12703 + int tokens_max; /* Limit: no more than N tokens */
12705 + int prio_bias; /* bias offset for priority */
12707 + unsigned update_mask; /* which features should be updated */
12708 + cpumask_t update; /* CPUs which should update */
12711 +struct _vx_sched_pc {
12712 + int tokens; /* number of CPU tokens */
12713 + int flags; /* bucket flags */
12715 + int fill_rate[2]; /* Fill rate: add X tokens... */
12716 + int interval[2]; /* Divisor: per Y jiffies */
12717 + int tokens_min; /* Limit: minimum for unhold */
12718 + int tokens_max; /* Limit: no more than N tokens */
12720 + int prio_bias; /* bias offset for priority */
12721 + int vavavoom; /* last calculated vavavoom */
12723 + unsigned long norm_time; /* last time accounted */
12724 + unsigned long idle_time; /* non linear time for fair sched */
12725 + unsigned long token_time; /* token time for accounting */
12726 + unsigned long onhold; /* jiffies when put on hold */
12728 + uint64_t user_ticks; /* token tick events */
12729 + uint64_t sys_ticks; /* token tick events */
12730 + uint64_t hold_ticks; /* token ticks paused */
12734 +#define VXSF_ONHOLD 0x0001
12735 +#define VXSF_IDLE_TIME 0x0100
12737 +#ifdef CONFIG_VSERVER_DEBUG
12739 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12741 + printk("\t_vx_sched:\n");
12742 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
12743 + sched->fill_rate[0], sched->interval[0],
12744 + sched->fill_rate[1], sched->interval[1],
12745 + sched->tokens_min, sched->tokens_max);
12746 + printk("\t priority = %4d\n", sched->prio_bias);
12751 +#endif /* _VX_SCHED_DEF_H */
12752 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/sched.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/sched.h
12753 --- linux-2.6.29/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12754 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/sched.h 2009-02-22 22:54:26.000000000 +0100
12756 +#ifndef _VX_SCHED_H
12757 +#define _VX_SCHED_H
12764 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12769 +void vx_update_load(struct vx_info *);
12772 +int vx_tokens_recalc(struct _vx_sched_pc *,
12773 + unsigned long *, unsigned long *, int [2]);
12775 +void vx_update_sched_param(struct _vx_sched *sched,
12776 + struct _vx_sched_pc *sched_pc);
12778 +#endif /* __KERNEL__ */
12779 +#else /* _VX_SCHED_H */
12780 +#warning duplicate inclusion
12781 +#endif /* _VX_SCHED_H */
12782 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/signal_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/signal_cmd.h
12783 --- linux-2.6.29/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12784 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/signal_cmd.h 2009-02-22 22:54:26.000000000 +0100
12786 +#ifndef _VX_SIGNAL_CMD_H
12787 +#define _VX_SIGNAL_CMD_H
12790 +/* signalling vserver commands */
12792 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12793 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12795 +struct vcmd_ctx_kill_v0 {
12800 +struct vcmd_wait_exit_v0 {
12801 + int32_t reboot_cmd;
12802 + int32_t exit_code;
12807 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12808 +extern int vc_wait_exit(struct vx_info *, void __user *);
12810 +#endif /* __KERNEL__ */
12812 +/* process alteration commands */
12814 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12815 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12817 +struct vcmd_pflags_v0 {
12818 + uint32_t flagword;
12824 +extern int vc_get_pflags(uint32_t pid, void __user *);
12825 +extern int vc_set_pflags(uint32_t pid, void __user *);
12827 +#endif /* __KERNEL__ */
12828 +#endif /* _VX_SIGNAL_CMD_H */
12829 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/signal.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/signal.h
12830 --- linux-2.6.29/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12831 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/signal.h 2009-02-22 22:54:26.000000000 +0100
12833 +#ifndef _VX_SIGNAL_H
12834 +#define _VX_SIGNAL_H
12841 +int vx_info_kill(struct vx_info *, int, int);
12843 +#endif /* __KERNEL__ */
12844 +#else /* _VX_SIGNAL_H */
12845 +#warning duplicate inclusion
12846 +#endif /* _VX_SIGNAL_H */
12847 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/space_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/space_cmd.h
12848 --- linux-2.6.29/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12849 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/space_cmd.h 2009-02-22 22:54:26.000000000 +0100
12851 +#ifndef _VX_SPACE_CMD_H
12852 +#define _VX_SPACE_CMD_H
12855 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12856 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
12857 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
12859 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12860 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
12861 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
12863 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12865 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
12866 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
12869 +struct vcmd_space_mask_v1 {
12873 +struct vcmd_space_mask_v2 {
12881 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12882 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12883 +extern int vc_enter_space(struct vx_info *, void __user *);
12884 +extern int vc_set_space(struct vx_info *, void __user *);
12885 +extern int vc_get_space_mask(void __user *, int);
12887 +#endif /* __KERNEL__ */
12888 +#endif /* _VX_SPACE_CMD_H */
12889 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/space.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/space.h
12890 --- linux-2.6.29/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
12891 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/space.h 2009-02-22 22:54:26.000000000 +0100
12893 +#ifndef _VX_SPACE_H
12894 +#define _VX_SPACE_H
12896 +#include <linux/types.h>
12900 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12902 +#else /* _VX_SPACE_H */
12903 +#warning duplicate inclusion
12904 +#endif /* _VX_SPACE_H */
12905 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/switch.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/switch.h
12906 --- linux-2.6.29/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
12907 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/switch.h 2009-02-22 22:54:26.000000000 +0100
12909 +#ifndef _VX_SWITCH_H
12910 +#define _VX_SWITCH_H
12912 +#include <linux/types.h>
12915 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
12916 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
12917 +#define VC_VERSION(c) ((c) & 0xFFF)
12919 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
12920 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
12924 + Syscall Matrix V2.8
12926 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
12927 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
12928 + |INFO |SETUP | |MOVE | | | | | |
12929 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12930 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
12931 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
12932 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12933 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
12934 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
12935 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12936 + MEMORY | | | | |MEMCTRL| | |SWAP | |
12937 + | 16| 17| 18| 19| 20| 21| | 22| 23|
12938 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12939 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
12940 + | 24| 25| 26| 27| 28| 29| | 30| 31|
12941 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12942 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
12943 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
12944 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12945 + OTHER |VSTAT | | | | | | |VINFO | |
12946 + | 40| 41| 42| 43| 44| 45| | 46| 47|
12947 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
12948 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
12949 + | 48| 49| 50| 51| 52| 53| | 54| 55|
12950 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12951 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
12952 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
12953 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12957 +#define VC_CAT_VERSION 0
12959 +#define VC_CAT_VSETUP 1
12960 +#define VC_CAT_VHOST 2
12962 +#define VC_CAT_DEVICE 6
12964 +#define VC_CAT_VPROC 9
12965 +#define VC_CAT_PROCALT 10
12966 +#define VC_CAT_PROCMIG 11
12967 +#define VC_CAT_PROCTRL 12
12969 +#define VC_CAT_SCHED 14
12970 +#define VC_CAT_MEMCTRL 20
12972 +#define VC_CAT_VNET 25
12973 +#define VC_CAT_NETALT 26
12974 +#define VC_CAT_NETMIG 27
12975 +#define VC_CAT_NETCTRL 28
12977 +#define VC_CAT_TAGMIG 35
12978 +#define VC_CAT_DLIMIT 36
12979 +#define VC_CAT_INODE 38
12981 +#define VC_CAT_VSTAT 40
12982 +#define VC_CAT_VINFO 46
12983 +#define VC_CAT_EVENT 48
12985 +#define VC_CAT_FLAGS 52
12986 +#define VC_CAT_VSPACE 54
12987 +#define VC_CAT_DEBUG 56
12988 +#define VC_CAT_RLIMIT 60
12990 +#define VC_CAT_SYSTEST 61
12991 +#define VC_CAT_COMPAT 63
12993 +/* query version */
12995 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
12996 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13001 +#include <linux/errno.h>
13003 +#endif /* __KERNEL__ */
13005 +#endif /* _VX_SWITCH_H */
13007 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/tag_cmd.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/tag_cmd.h
13008 --- linux-2.6.29/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13009 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/tag_cmd.h 2009-02-22 22:54:26.000000000 +0100
13011 +#ifndef _VX_TAG_CMD_H
13012 +#define _VX_TAG_CMD_H
13015 +/* vinfo commands */
13017 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13020 +extern int vc_task_tag(uint32_t);
13022 +#endif /* __KERNEL__ */
13024 +/* context commands */
13026 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13029 +extern int vc_tag_migrate(uint32_t);
13031 +#endif /* __KERNEL__ */
13032 +#endif /* _VX_TAG_CMD_H */
13033 diff -NurpP --minimal linux-2.6.29/include/linux/vserver/tag.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/tag.h
13034 --- linux-2.6.29/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13035 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vserver/tag.h 2009-02-22 22:54:26.000000000 +0100
13040 +#include <linux/types.h>
13043 +#define DX_TAG(in) (IS_TAGGED(in))
13046 +#ifdef CONFIG_TAG_NFSD
13047 +#define DX_TAG_NFSD 1
13049 +#define DX_TAG_NFSD 0
13053 +#ifdef CONFIG_TAGGING_NONE
13055 +#define MAX_UID 0xFFFFFFFF
13056 +#define MAX_GID 0xFFFFFFFF
13058 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13060 +#define TAGINO_UID(cond, uid, tag) (uid)
13061 +#define TAGINO_GID(cond, gid, tag) (gid)
13066 +#ifdef CONFIG_TAGGING_GID16
13068 +#define MAX_UID 0xFFFFFFFF
13069 +#define MAX_GID 0x0000FFFF
13071 +#define INOTAG_TAG(cond, uid, gid, tag) \
13072 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13074 +#define TAGINO_UID(cond, uid, tag) (uid)
13075 +#define TAGINO_GID(cond, gid, tag) \
13076 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13081 +#ifdef CONFIG_TAGGING_ID24
13083 +#define MAX_UID 0x00FFFFFF
13084 +#define MAX_GID 0x00FFFFFF
13086 +#define INOTAG_TAG(cond, uid, gid, tag) \
13087 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13089 +#define TAGINO_UID(cond, uid, tag) \
13090 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13091 +#define TAGINO_GID(cond, gid, tag) \
13092 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13097 +#ifdef CONFIG_TAGGING_UID16
13099 +#define MAX_UID 0x0000FFFF
13100 +#define MAX_GID 0xFFFFFFFF
13102 +#define INOTAG_TAG(cond, uid, gid, tag) \
13103 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13105 +#define TAGINO_UID(cond, uid, tag) \
13106 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13107 +#define TAGINO_GID(cond, gid, tag) (gid)
13112 +#ifdef CONFIG_TAGGING_INTERN
13114 +#define MAX_UID 0xFFFFFFFF
13115 +#define MAX_GID 0xFFFFFFFF
13117 +#define INOTAG_TAG(cond, uid, gid, tag) \
13118 + ((cond) ? (tag) : 0)
13120 +#define TAGINO_UID(cond, uid, tag) (uid)
13121 +#define TAGINO_GID(cond, gid, tag) (gid)
13126 +#ifndef CONFIG_TAGGING_NONE
13127 +#define dx_current_fstag(sb) \
13128 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13130 +#define dx_current_fstag(sb) (0)
13133 +#ifndef CONFIG_TAGGING_INTERN
13134 +#define TAGINO_TAG(cond, tag) (0)
13136 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13139 +#define INOTAG_UID(cond, uid, gid) \
13140 + ((cond) ? ((uid) & MAX_UID) : (uid))
13141 +#define INOTAG_GID(cond, uid, gid) \
13142 + ((cond) ? ((gid) & MAX_GID) : (gid))
13145 +static inline uid_t dx_map_uid(uid_t uid)
13147 + if ((uid > MAX_UID) && (uid != -1))
13149 + return (uid & MAX_UID);
13152 +static inline gid_t dx_map_gid(gid_t gid)
13154 + if ((gid > MAX_GID) && (gid != -1))
13156 + return (gid & MAX_GID);
13164 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13166 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13167 + unsigned long *flags);
13169 +#ifdef CONFIG_PROPAGATE
13171 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13173 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13176 +#define dx_propagate_tag(n, i) do { } while (0)
13179 +#endif /* _DX_TAG_H */
13180 diff -NurpP --minimal linux-2.6.29/include/linux/vs_inet6.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_inet6.h
13181 --- linux-2.6.29/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13182 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_inet6.h 2009-03-25 00:46:50.000000000 +0100
13184 +#ifndef _VS_INET6_H
13185 +#define _VS_INET6_H
13187 +#include "vserver/base.h"
13188 +#include "vserver/network.h"
13189 +#include "vserver/debug.h"
13191 +#include <net/ipv6.h>
13193 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13194 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13197 +#ifdef CONFIG_IPV6
13200 +int v6_addr_match(struct nx_addr_v6 *nxa,
13201 + const struct in6_addr *addr, uint16_t mask)
13205 + switch (nxa->type & mask) {
13206 + case NXA_TYPE_MASK:
13207 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13209 + case NXA_TYPE_ADDR:
13210 + ret = ipv6_addr_equal(&nxa->ip, addr);
13212 + case NXA_TYPE_ANY:
13216 + vxdprintk(VXD_CBIT(net, 0),
13217 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13218 + nxa, NXAV6(nxa), addr, mask, ret);
13223 +int v6_addr_in_nx_info(struct nx_info *nxi,
13224 + const struct in6_addr *addr, uint16_t mask)
13226 + struct nx_addr_v6 *nxa;
13231 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13232 + if (v6_addr_match(nxa, addr, mask))
13236 + vxdprintk(VXD_CBIT(net, 0),
13237 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13238 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13243 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13245 + /* FIXME: needs full range checks */
13246 + return v6_addr_match(nxa, &addr->ip, mask);
13250 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13252 + struct nx_addr_v6 *ptr;
13254 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13255 + if (v6_nx_addr_match(ptr, nxa, mask))
13262 + * Check if a given address matches for a socket
13264 + * nxi: the socket's nx_info if any
13265 + * addr: to be verified address
13268 +int v6_sock_addr_match (
13269 + struct nx_info *nxi,
13270 + struct inet_sock *inet,
13271 + struct in6_addr *addr)
13273 + struct sock *sk = &inet->sk;
13274 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13276 + if (!ipv6_addr_any(addr) &&
13277 + ipv6_addr_equal(saddr, addr))
13279 + if (ipv6_addr_any(saddr))
13280 + return v6_addr_in_nx_info(nxi, addr, -1);
13285 + * check if address is covered by socket
13287 + * sk: the socket to check against
13288 + * addr: the address in question (must be != 0)
13292 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13294 + struct nx_info *nxi = sk->sk_nx_info;
13295 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13297 + vxdprintk(VXD_CBIT(net, 5),
13298 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13299 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13300 + (sk->sk_socket?sk->sk_socket->flags:0));
13302 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13303 + return v6_addr_match(nxa, saddr, -1);
13304 + } else if (nxi) { /* match against nx_info */
13305 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13306 + } else { /* unrestricted any socket */
13312 +/* inet related checks and helpers */
13316 +struct net_device;
13320 +#include <linux/netdevice.h>
13321 +#include <linux/inetdevice.h>
13322 +#include <net/inet_timewait_sock.h>
13325 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13326 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13327 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13332 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13338 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13342 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13344 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13345 + nxi, nxi ? nxi->nx_id : 0, ifa,
13346 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13348 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13350 + if (v6_ifa_in_nx_info(ifa, nxi))
13356 +struct nx_v6_sock_addr {
13357 + struct in6_addr saddr; /* Address used for validation */
13358 + struct in6_addr baddr; /* Address used for socket bind */
13362 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13363 + struct nx_v6_sock_addr *nsa)
13365 + // struct sock *sk = &inet->sk;
13366 + // struct nx_info *nxi = sk->sk_nx_info;
13367 + struct in6_addr saddr = addr->sin6_addr;
13368 + struct in6_addr baddr = saddr;
13370 + nsa->saddr = saddr;
13371 + nsa->baddr = baddr;
13376 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13378 + // struct sock *sk = &inet->sk;
13379 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13381 + // *saddr = nsa->baddr;
13382 + // inet->saddr = nsa->baddr;
13386 +int nx_info_has_v6(struct nx_info *nxi)
13390 + if (NX_IPV6(nxi))
13395 +#else /* CONFIG_IPV6 */
13398 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13405 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13411 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13417 +int nx_info_has_v6(struct nx_info *nxi)
13422 +#endif /* CONFIG_IPV6 */
13424 +#define current_nx_info_has_v6() \
13425 + nx_info_has_v6(current_nx_info())
13428 +#warning duplicate inclusion
13430 diff -NurpP --minimal linux-2.6.29/include/linux/vs_inet.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_inet.h
13431 --- linux-2.6.29/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13432 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_inet.h 2009-02-22 22:54:26.000000000 +0100
13434 +#ifndef _VS_INET_H
13435 +#define _VS_INET_H
13437 +#include "vserver/base.h"
13438 +#include "vserver/network.h"
13439 +#include "vserver/debug.h"
13441 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13443 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13444 + NIPQUAD((a)->mask), (a)->type
13445 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13449 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13451 + __be32 ip = nxa->ip[0].s_addr;
13452 + __be32 mask = nxa->mask.s_addr;
13453 + __be32 bcast = ip | ~mask;
13456 + switch (nxa->type & tmask) {
13457 + case NXA_TYPE_MASK:
13458 + ret = (ip == (addr & mask));
13460 + case NXA_TYPE_ADDR:
13464 + /* fall through to broadcast */
13465 + case NXA_MOD_BCAST:
13466 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13468 + case NXA_TYPE_RANGE:
13469 + ret = ((nxa->ip[0].s_addr <= addr) &&
13470 + (nxa->ip[1].s_addr > addr));
13472 + case NXA_TYPE_ANY:
13477 + vxdprintk(VXD_CBIT(net, 0),
13478 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13479 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13484 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13486 + struct nx_addr_v4 *nxa;
13493 + /* allow 127.0.0.1 when remapping lback */
13494 + if ((tmask & NXA_LOOPBACK) &&
13495 + (addr == IPI_LOOPBACK) &&
13496 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13499 + /* check for lback address */
13500 + if ((tmask & NXA_MOD_LBACK) &&
13501 + (nxi->v4_lback.s_addr == addr))
13504 + /* check for broadcast address */
13505 + if ((tmask & NXA_MOD_BCAST) &&
13506 + (nxi->v4_bcast.s_addr == addr))
13509 + /* check for v4 addresses */
13510 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13511 + if (v4_addr_match(nxa, addr, tmask))
13515 + vxdprintk(VXD_CBIT(net, 0),
13516 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13517 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13522 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13524 + /* FIXME: needs full range checks */
13525 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13529 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13531 + struct nx_addr_v4 *ptr;
13533 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13534 + if (v4_nx_addr_match(ptr, nxa, mask))
13539 +#include <net/inet_sock.h>
13542 + * Check if a given address matches for a socket
13544 + * nxi: the socket's nx_info if any
13545 + * addr: to be verified address
13548 +int v4_sock_addr_match (
13549 + struct nx_info *nxi,
13550 + struct inet_sock *inet,
13553 + __be32 saddr = inet->rcv_saddr;
13554 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13556 + if (addr && (saddr == addr || bcast == addr))
13559 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13564 +/* inet related checks and helpers */
13568 +struct net_device;
13571 +#ifdef CONFIG_INET
13573 +#include <linux/netdevice.h>
13574 +#include <linux/inetdevice.h>
13575 +#include <net/inet_sock.h>
13576 +#include <net/inet_timewait_sock.h>
13579 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13580 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13581 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13585 + * check if address is covered by socket
13587 + * sk: the socket to check against
13588 + * addr: the address in question (must be != 0)
13592 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13594 + struct nx_info *nxi = sk->sk_nx_info;
13595 + __be32 saddr = inet_rcv_saddr(sk);
13597 + vxdprintk(VXD_CBIT(net, 5),
13598 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13599 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13600 + (sk->sk_socket?sk->sk_socket->flags:0));
13602 + if (saddr) { /* direct address match */
13603 + return v4_addr_match(nxa, saddr, -1);
13604 + } else if (nxi) { /* match against nx_info */
13605 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13606 + } else { /* unrestricted any socket */
13614 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13616 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13617 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13618 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13620 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13622 + if (dev_in_nx_info(dev, nxi))
13629 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13635 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13639 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13641 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13642 + nxi, nxi ? nxi->nx_id : 0, ifa,
13643 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13645 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13647 + if (v4_ifa_in_nx_info(ifa, nxi))
13653 +struct nx_v4_sock_addr {
13654 + __be32 saddr; /* Address used for validation */
13655 + __be32 baddr; /* Address used for socket bind */
13659 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13660 + struct nx_v4_sock_addr *nsa)
13662 + struct sock *sk = &inet->sk;
13663 + struct nx_info *nxi = sk->sk_nx_info;
13664 + __be32 saddr = addr->sin_addr.s_addr;
13665 + __be32 baddr = saddr;
13667 + vxdprintk(VXD_CBIT(net, 3),
13668 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13669 + sk, sk->sk_nx_info, sk->sk_socket,
13670 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13674 + if (saddr == INADDR_ANY) {
13675 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13676 + baddr = nxi->v4.ip[0].s_addr;
13677 + } else if (saddr == IPI_LOOPBACK) {
13678 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13679 + baddr = nxi->v4_lback.s_addr;
13680 + } else { /* normal address bind */
13681 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13682 + return -EADDRNOTAVAIL;
13686 + vxdprintk(VXD_CBIT(net, 3),
13687 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13688 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13690 + nsa->saddr = saddr;
13691 + nsa->baddr = baddr;
13696 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13698 + inet->saddr = nsa->baddr;
13699 + inet->rcv_saddr = nsa->baddr;
13704 + * helper to simplify inet_lookup_listener
13706 + * nxi: the socket's nx_info if any
13707 + * addr: to be verified address
13708 + * saddr: socket address
13710 +static inline int v4_inet_addr_match (
13711 + struct nx_info *nxi,
13715 + if (addr && (saddr == addr))
13718 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13722 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13724 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13725 + (addr == nxi->v4_lback.s_addr))
13726 + return IPI_LOOPBACK;
13731 +int nx_info_has_v4(struct nx_info *nxi)
13735 + if (NX_IPV4(nxi))
13737 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13742 +#else /* CONFIG_INET */
13745 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13751 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13757 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13763 +int nx_info_has_v4(struct nx_info *nxi)
13768 +#endif /* CONFIG_INET */
13770 +#define current_nx_info_has_v4() \
13771 + nx_info_has_v4(current_nx_info())
13774 +// #warning duplicate inclusion
13776 diff -NurpP --minimal linux-2.6.29/include/linux/vs_limit.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_limit.h
13777 --- linux-2.6.29/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13778 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_limit.h 2009-02-22 22:54:26.000000000 +0100
13780 +#ifndef _VS_LIMIT_H
13781 +#define _VS_LIMIT_H
13783 +#include "vserver/limit.h"
13784 +#include "vserver/base.h"
13785 +#include "vserver/context.h"
13786 +#include "vserver/debug.h"
13787 +#include "vserver/context.h"
13788 +#include "vserver/limit_int.h"
13791 +#define vx_acc_cres(v, d, p, r) \
13792 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13794 +#define vx_acc_cres_cond(x, d, p, r) \
13795 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13796 + r, d, p, __FILE__, __LINE__)
13799 +#define vx_add_cres(v, a, p, r) \
13800 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13801 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13803 +#define vx_add_cres_cond(x, a, p, r) \
13804 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13805 + r, a, p, __FILE__, __LINE__)
13806 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13809 +/* process and file limits */
13811 +#define vx_nproc_inc(p) \
13812 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13814 +#define vx_nproc_dec(p) \
13815 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13817 +#define vx_files_inc(f) \
13818 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13820 +#define vx_files_dec(f) \
13821 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13823 +#define vx_locks_inc(l) \
13824 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13826 +#define vx_locks_dec(l) \
13827 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13829 +#define vx_openfd_inc(f) \
13830 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
13832 +#define vx_openfd_dec(f) \
13833 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
13836 +#define vx_cres_avail(v, n, r) \
13837 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13840 +#define vx_nproc_avail(n) \
13841 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
13843 +#define vx_files_avail(n) \
13844 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
13846 +#define vx_locks_avail(n) \
13847 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
13849 +#define vx_openfd_avail(n) \
13850 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
13853 +/* dentry limits */
13855 +#define vx_dentry_inc(d) do { \
13856 + if (atomic_read(&d->d_count) == 1) \
13857 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
13860 +#define vx_dentry_dec(d) do { \
13861 + if (atomic_read(&d->d_count) == 0) \
13862 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
13865 +#define vx_dentry_avail(n) \
13866 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
13869 +/* socket limits */
13871 +#define vx_sock_inc(s) \
13872 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13874 +#define vx_sock_dec(s) \
13875 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13877 +#define vx_sock_avail(n) \
13878 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
13881 +/* ipc resource limits */
13883 +#define vx_ipcmsg_add(v, u, a) \
13884 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13886 +#define vx_ipcmsg_sub(v, u, a) \
13887 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13889 +#define vx_ipcmsg_avail(v, a) \
13890 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13893 +#define vx_ipcshm_add(v, k, a) \
13894 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13896 +#define vx_ipcshm_sub(v, k, a) \
13897 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13899 +#define vx_ipcshm_avail(v, a) \
13900 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13903 +#define vx_semary_inc(a) \
13904 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
13906 +#define vx_semary_dec(a) \
13907 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
13910 +#define vx_nsems_add(a,n) \
13911 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13913 +#define vx_nsems_sub(a,n) \
13914 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13918 +#warning duplicate inclusion
13920 diff -NurpP --minimal linux-2.6.29/include/linux/vs_memory.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_memory.h
13921 --- linux-2.6.29/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
13922 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_memory.h 2009-02-22 22:54:26.000000000 +0100
13924 +#ifndef _VS_MEMORY_H
13925 +#define _VS_MEMORY_H
13927 +#include "vserver/limit.h"
13928 +#include "vserver/base.h"
13929 +#include "vserver/context.h"
13930 +#include "vserver/debug.h"
13931 +#include "vserver/context.h"
13932 +#include "vserver/limit_int.h"
13935 +#define __acc_add_long(a, v) (*(v) += (a))
13936 +#define __acc_inc_long(v) (++*(v))
13937 +#define __acc_dec_long(v) (--*(v))
13939 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
13940 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
13941 +#define __acc_inc_atomic(v) atomic_long_inc(v)
13942 +#define __acc_dec_atomic(v) atomic_long_dec(v)
13943 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13944 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
13945 +#define __acc_inc_atomic(v) __acc_inc_long(v)
13946 +#define __acc_dec_atomic(v) __acc_dec_long(v)
13947 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13950 +#define vx_acc_page(m, d, v, r) do { \
13952 + __acc_inc_long(&(m)->v); \
13954 + __acc_dec_long(&(m)->v); \
13955 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13958 +#define vx_acc_page_atomic(m, d, v, r) do { \
13960 + __acc_inc_atomic(&(m)->v); \
13962 + __acc_dec_atomic(&(m)->v); \
13963 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13967 +#define vx_acc_pages(m, p, v, r) do { \
13968 + unsigned long __p = (p); \
13969 + __acc_add_long(__p, &(m)->v); \
13970 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13973 +#define vx_acc_pages_atomic(m, p, v, r) do { \
13974 + unsigned long __p = (p); \
13975 + __acc_add_atomic(__p, &(m)->v); \
13976 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13981 +#define vx_acc_vmpage(m, d) \
13982 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
13983 +#define vx_acc_vmlpage(m, d) \
13984 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
13985 +#define vx_acc_file_rsspage(m, d) \
13986 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
13987 +#define vx_acc_anon_rsspage(m, d) \
13988 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
13990 +#define vx_acc_vmpages(m, p) \
13991 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
13992 +#define vx_acc_vmlpages(m, p) \
13993 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
13994 +#define vx_acc_file_rsspages(m, p) \
13995 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
13996 +#define vx_acc_anon_rsspages(m, p) \
13997 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
13999 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14000 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14002 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14003 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14004 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14005 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14007 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14008 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14009 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14010 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14012 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14013 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14014 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14015 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14017 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14018 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14019 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14020 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14023 +#define vx_pages_avail(m, p, r) \
14024 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14026 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14027 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14028 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14029 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14031 +#define vx_rss_avail(m, p) \
14032 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14036 + VXPT_UNKNOWN = 0,
14045 +#define vx_page_fault(mm, vma, type, ret)
14049 +void __vx_page_fault(struct mm_struct *mm,
14050 + struct vm_area_struct *vma, int type, int ret)
14052 + struct vx_info *vxi = mm->mm_vx_info;
14055 + static char *page_type[6] =
14056 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14057 + static char *page_what[4] =
14058 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14064 + what = (ret & 0x3);
14066 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14067 + type, what, ret, page_type[type], page_what[what]);
14069 + if (ret & VM_FAULT_WRITE)
14071 + atomic_inc(&vxi->cacct.page[type][what]);
14074 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14078 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14081 +#warning duplicate inclusion
14083 diff -NurpP --minimal linux-2.6.29/include/linux/vs_network.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_network.h
14084 --- linux-2.6.29/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14085 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_network.h 2009-02-22 22:54:26.000000000 +0100
14087 +#ifndef _NX_VS_NETWORK_H
14088 +#define _NX_VS_NETWORK_H
14090 +#include "vserver/context.h"
14091 +#include "vserver/network.h"
14092 +#include "vserver/base.h"
14093 +#include "vserver/check.h"
14094 +#include "vserver/debug.h"
14096 +#include <linux/sched.h>
14099 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14101 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14102 + const char *_file, int _line)
14107 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14108 + nxi, nxi ? nxi->nx_id : 0,
14109 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14112 + atomic_inc(&nxi->nx_usecnt);
14117 +extern void free_nx_info(struct nx_info *);
14119 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14121 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14126 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14127 + nxi, nxi ? nxi->nx_id : 0,
14128 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14131 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14132 + free_nx_info(nxi);
14136 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14138 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14139 + const char *_file, int _line)
14142 + vxlprintk(VXD_CBIT(nid, 3),
14143 + "init_nx_info(%p[#%d.%d])",
14144 + nxi, nxi ? nxi->nx_id : 0,
14145 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14148 + atomic_inc(&nxi->nx_usecnt);
14154 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14156 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14157 + const char *_file, int _line)
14159 + struct nx_info *nxo;
14164 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14165 + nxi, nxi ? nxi->nx_id : 0,
14166 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14169 + atomic_inc(&nxi->nx_usecnt);
14170 + nxo = xchg(nxp, nxi);
14174 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14176 +static inline void __clr_nx_info(struct nx_info **nxp,
14177 + const char *_file, int _line)
14179 + struct nx_info *nxo;
14181 + nxo = xchg(nxp, NULL);
14185 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14186 + nxo, nxo ? nxo->nx_id : 0,
14187 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14190 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14191 + free_nx_info(nxo);
14195 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14197 +static inline void __claim_nx_info(struct nx_info *nxi,
14198 + struct task_struct *task, const char *_file, int _line)
14200 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14201 + nxi, nxi ? nxi->nx_id : 0,
14202 + nxi?atomic_read(&nxi->nx_usecnt):0,
14203 + nxi?atomic_read(&nxi->nx_tasks):0,
14204 + task, _file, _line);
14206 + atomic_inc(&nxi->nx_tasks);
14210 +extern void unhash_nx_info(struct nx_info *);
14212 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14214 +static inline void __release_nx_info(struct nx_info *nxi,
14215 + struct task_struct *task, const char *_file, int _line)
14217 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14218 + nxi, nxi ? nxi->nx_id : 0,
14219 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14220 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14221 + task, _file, _line);
14225 + if (atomic_dec_and_test(&nxi->nx_tasks))
14226 + unhash_nx_info(nxi);
14230 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14232 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14233 + const char *_file, int _line)
14235 + struct nx_info *nxi;
14238 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14239 + p, _file, _line);
14240 + nxi = __get_nx_info(p->nx_info, _file, _line);
14246 +static inline void exit_nx_info(struct task_struct *p)
14249 + release_nx_info(p->nx_info, p);
14254 +#warning duplicate inclusion
14256 diff -NurpP --minimal linux-2.6.29/include/linux/vs_pid.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_pid.h
14257 --- linux-2.6.29/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14258 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_pid.h 2009-02-22 22:54:26.000000000 +0100
14263 +#include "vserver/base.h"
14264 +#include "vserver/check.h"
14265 +#include "vserver/context.h"
14266 +#include "vserver/debug.h"
14267 +#include "vserver/pid.h"
14268 +#include <linux/pid_namespace.h>
14271 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14274 +int vx_proc_task_visible(struct task_struct *task)
14276 + if ((task->pid == 1) &&
14277 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14278 + /* show a blend through init */
14280 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14287 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14292 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14294 + struct task_struct *task = find_task_by_real_pid(pid);
14296 + if (task && !vx_proc_task_visible(task)) {
14297 + vxdprintk(VXD_CBIT(misc, 6),
14298 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14299 + task, task->xid, task->pid,
14300 + current, current->xid, current->pid);
14309 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14311 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14313 + if (task && !vx_proc_task_visible(task)) {
14314 + vxdprintk(VXD_CBIT(misc, 6),
14315 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14316 + task, task->xid, task->pid,
14317 + current, current->xid, current->pid);
14318 + put_task_struct(task);
14327 +struct task_struct *vx_child_reaper(struct task_struct *p)
14329 + struct vx_info *vxi = p->vx_info;
14330 + struct task_struct *reaper = child_reaper(p);
14335 + BUG_ON(!p->vx_info->vx_reaper);
14337 + /* child reaper for the guest reaper */
14338 + if (vxi->vx_reaper == p)
14341 + reaper = vxi->vx_reaper;
14343 + vxdprintk(VXD_CBIT(xid, 7),
14344 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14345 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14353 +#warning duplicate inclusion
14355 diff -NurpP --minimal linux-2.6.29/include/linux/vs_sched.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_sched.h
14356 --- linux-2.6.29/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14357 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_sched.h 2009-02-22 22:54:26.000000000 +0100
14359 +#ifndef _VS_SCHED_H
14360 +#define _VS_SCHED_H
14362 +#include "vserver/base.h"
14363 +#include "vserver/context.h"
14364 +#include "vserver/sched.h"
14367 +#define VAVAVOOM_RATIO 50
14369 +#define MAX_PRIO_BIAS 20
14370 +#define MIN_PRIO_BIAS -20
14373 +#ifdef CONFIG_VSERVER_HARDCPU
14376 + * effective_prio - return the priority that is based on the static
14377 + * priority but is modified by bonuses/penalties.
14379 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14380 + * into a -4 ... 0 ... +4 bonus/penalty range.
14382 + * Additionally, we scale another amount based on the number of
14383 + * CPU tokens currently held by the context, if the process is
14384 + * part of a context (and the appropriate SCHED flag is set).
14385 + * This ranges from -5 ... 0 ... +15, quadratically.
14387 + * So, the total bonus is -9 .. 0 .. +19
14388 + * We use ~50% of the full 0...39 priority range so that:
14390 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14391 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14392 + * unless that context is far exceeding its CPU allocation.
14394 + * Both properties are important to certain workloads.
14397 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14399 + int vavavoom, max;
14401 + /* lots of tokens = lots of vavavoom
14402 + * no tokens = no vavavoom */
14403 + if ((vavavoom = sched_pc->tokens) >= 0) {
14404 + max = sched_pc->tokens_max;
14405 + vavavoom = max - vavavoom;
14407 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14408 + * (vavavoom*vavavoom - (max >> 2)) / max;
14416 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14418 + struct vx_info *vxi = p->vx_info;
14419 + struct _vx_sched_pc *sched_pc;
14424 + sched_pc = &vx_cpu(vxi, sched_pc);
14425 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14426 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14428 + sched_pc->vavavoom = vavavoom;
14429 + prio += vavavoom;
14431 + prio += sched_pc->prio_bias;
14435 +#else /* !CONFIG_VSERVER_HARDCPU */
14438 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14440 + struct vx_info *vxi = p->vx_info;
14443 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14447 +#endif /* CONFIG_VSERVER_HARDCPU */
14450 +static inline void vx_account_user(struct vx_info *vxi,
14451 + cputime_t cputime, int nice)
14455 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14458 +static inline void vx_account_system(struct vx_info *vxi,
14459 + cputime_t cputime, int idle)
14463 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14467 +#warning duplicate inclusion
14469 diff -NurpP --minimal linux-2.6.29/include/linux/vs_socket.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_socket.h
14470 --- linux-2.6.29/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14471 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_socket.h 2009-02-22 22:54:26.000000000 +0100
14473 +#ifndef _VS_SOCKET_H
14474 +#define _VS_SOCKET_H
14476 +#include "vserver/debug.h"
14477 +#include "vserver/base.h"
14478 +#include "vserver/cacct.h"
14479 +#include "vserver/context.h"
14480 +#include "vserver/tag.h"
14483 +/* socket accounting */
14485 +#include <linux/socket.h>
14487 +static inline int vx_sock_type(int family)
14489 + switch (family) {
14491 + return VXA_SOCK_UNSPEC;
14493 + return VXA_SOCK_UNIX;
14495 + return VXA_SOCK_INET;
14497 + return VXA_SOCK_INET6;
14499 + return VXA_SOCK_PACKET;
14501 + return VXA_SOCK_OTHER;
14505 +#define vx_acc_sock(v, f, p, s) \
14506 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14508 +static inline void __vx_acc_sock(struct vx_info *vxi,
14509 + int family, int pos, int size, char *file, int line)
14512 + int type = vx_sock_type(family);
14514 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14515 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14519 +#define vx_sock_recv(sk, s) \
14520 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14521 +#define vx_sock_send(sk, s) \
14522 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14523 +#define vx_sock_fail(sk, s) \
14524 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14527 +#define sock_vx_init(s) do { \
14528 + (s)->sk_xid = 0; \
14529 + (s)->sk_vx_info = NULL; \
14532 +#define sock_nx_init(s) do { \
14533 + (s)->sk_nid = 0; \
14534 + (s)->sk_nx_info = NULL; \
14538 +#warning duplicate inclusion
14540 diff -NurpP --minimal linux-2.6.29/include/linux/vs_tag.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_tag.h
14541 --- linux-2.6.29/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14542 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_tag.h 2009-02-22 22:54:26.000000000 +0100
14547 +#include <linux/vserver/tag.h>
14549 +/* check conditions */
14551 +#define DX_ADMIN 0x0001
14552 +#define DX_WATCH 0x0002
14553 +#define DX_HOSTID 0x0008
14555 +#define DX_IDENT 0x0010
14557 +#define DX_ARG_MASK 0x0010
14560 +#define dx_task_tag(t) ((t)->tag)
14562 +#define dx_current_tag() dx_task_tag(current)
14564 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14566 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14570 + * check current context for ADMIN/WATCH and
14571 + * optionally against supplied argument
14573 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14575 + if (mode & DX_ARG_MASK) {
14576 + if ((mode & DX_IDENT) && (id == cid))
14579 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14580 + ((mode & DX_WATCH) && (cid == 1)) ||
14581 + ((mode & DX_HOSTID) && (id == 0)));
14585 +int dx_permission(struct inode *inode, int mask);
14589 +#warning duplicate inclusion
14591 diff -NurpP --minimal linux-2.6.29/include/linux/vs_time.h linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_time.h
14592 --- linux-2.6.29/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14593 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/linux/vs_time.h 2009-02-22 22:54:26.000000000 +0100
14595 +#ifndef _VS_TIME_H
14596 +#define _VS_TIME_H
14599 +/* time faking stuff */
14601 +#ifdef CONFIG_VSERVER_VTIME
14603 +extern void vx_gettimeofday(struct timeval *tv);
14604 +extern int vx_settimeofday(struct timespec *ts);
14607 +#define vx_gettimeofday(t) do_gettimeofday(t)
14608 +#define vx_settimeofday(t) do_settimeofday(t)
14612 +#warning duplicate inclusion
14614 diff -NurpP --minimal linux-2.6.29/include/net/addrconf.h linux-2.6.29-vs2.3.0.36.9-pre3/include/net/addrconf.h
14615 --- linux-2.6.29/include/net/addrconf.h 2008-12-25 00:26:37.000000000 +0100
14616 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/net/addrconf.h 2009-02-22 22:54:26.000000000 +0100
14617 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14618 struct net_device *dev,
14619 const struct in6_addr *daddr,
14620 unsigned int srcprefs,
14621 - struct in6_addr *saddr);
14622 + struct in6_addr *saddr,
14623 + struct nx_info *nxi);
14624 extern int ipv6_get_lladdr(struct net_device *dev,
14625 struct in6_addr *addr,
14626 unsigned char banned_flags);
14627 diff -NurpP --minimal linux-2.6.29/include/net/af_unix.h linux-2.6.29-vs2.3.0.36.9-pre3/include/net/af_unix.h
14628 --- linux-2.6.29/include/net/af_unix.h 2008-12-25 00:26:37.000000000 +0100
14629 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/net/af_unix.h 2009-02-22 22:54:26.000000000 +0100
14631 #include <linux/socket.h>
14632 #include <linux/un.h>
14633 #include <linux/mutex.h>
14634 +#include <linux/vs_base.h>
14635 #include <net/sock.h>
14637 extern void unix_inflight(struct file *fp);
14638 diff -NurpP --minimal linux-2.6.29/include/net/inet_timewait_sock.h linux-2.6.29-vs2.3.0.36.9-pre3/include/net/inet_timewait_sock.h
14639 --- linux-2.6.29/include/net/inet_timewait_sock.h 2009-03-24 14:22:44.000000000 +0100
14640 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/net/inet_timewait_sock.h 2009-03-24 14:48:36.000000000 +0100
14641 @@ -15,15 +15,14 @@
14642 #ifndef _INET_TIMEWAIT_SOCK_
14643 #define _INET_TIMEWAIT_SOCK_
14645 +// #include <net/inet_sock.h>
14646 +#include <net/sock.h>
14648 #include <linux/list.h>
14649 #include <linux/module.h>
14650 #include <linux/timer.h>
14651 #include <linux/types.h>
14652 #include <linux/workqueue.h>
14654 -#include <net/inet_sock.h>
14655 -#include <net/sock.h>
14656 #include <net/tcp_states.h>
14657 #include <net/timewait_sock.h>
14659 @@ -116,6 +115,10 @@ struct inet_timewait_sock {
14660 #define tw_hash __tw_common.skc_hash
14661 #define tw_prot __tw_common.skc_prot
14662 #define tw_net __tw_common.skc_net
14663 +#define tw_xid __tw_common.skc_xid
14664 +#define tw_vx_info __tw_common.skc_vx_info
14665 +#define tw_nid __tw_common.skc_nid
14666 +#define tw_nx_info __tw_common.skc_nx_info
14668 volatile unsigned char tw_substate;
14669 /* 3 bits hole, try to pack */
14670 diff -NurpP --minimal linux-2.6.29/include/net/route.h linux-2.6.29-vs2.3.0.36.9-pre3/include/net/route.h
14671 --- linux-2.6.29/include/net/route.h 2008-12-25 00:26:37.000000000 +0100
14672 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/net/route.h 2009-02-22 22:54:26.000000000 +0100
14673 @@ -135,6 +135,9 @@ static inline void ip_rt_put(struct rtab
14674 dst_release(&rt->u.dst);
14677 +#include <linux/vs_base.h>
14678 +#include <linux/vs_inet.h>
14680 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14682 extern const __u8 ip_tos2prio[16];
14683 @@ -144,6 +147,9 @@ static inline char rt_tos2priority(u8 to
14684 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14687 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14688 + struct rtable **, struct flowi *);
14690 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14691 __be32 src, u32 tos, int oif, u8 protocol,
14692 __be16 sport, __be16 dport, struct sock *sk,
14693 @@ -161,11 +167,24 @@ static inline int ip_route_connect(struc
14696 struct net *net = sock_net(sk);
14697 + struct nx_info *nx_info = current->nx_info;
14699 if (inet_sk(sk)->transparent)
14700 fl.flags |= FLOWI_FLAG_ANYSRC;
14702 - if (!dst || !src) {
14704 + nx_info = sk->sk_nx_info;
14706 + vxdprintk(VXD_CBIT(net, 4),
14707 + "ip_route_connect(%p) %p,%p;%lx",
14708 + sk, nx_info, sk->sk_socket,
14709 + (sk->sk_socket?sk->sk_socket->flags:0));
14711 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14715 + if (!fl.fl4_dst || !fl.fl4_src) {
14716 err = __ip_route_output_key(net, rp, &fl);
14719 diff -NurpP --minimal linux-2.6.29/include/net/sock.h linux-2.6.29-vs2.3.0.36.9-pre3/include/net/sock.h
14720 --- linux-2.6.29/include/net/sock.h 2009-03-24 14:22:44.000000000 +0100
14721 +++ linux-2.6.29-vs2.3.0.36.9-pre3/include/net/sock.h 2009-03-24 14:48:36.000000000 +0100
14722 @@ -134,6 +134,10 @@ struct sock_common {
14723 #ifdef CONFIG_NET_NS
14724 struct net *skc_net;
14727 + struct vx_info *skc_vx_info;
14729 + struct nx_info *skc_nx_info;
14733 @@ -218,6 +222,10 @@ struct sock {
14734 #define sk_hash __sk_common.skc_hash
14735 #define sk_prot __sk_common.skc_prot
14736 #define sk_net __sk_common.skc_net
14737 +#define sk_xid __sk_common.skc_xid
14738 +#define sk_vx_info __sk_common.skc_vx_info
14739 +#define sk_nid __sk_common.skc_nid
14740 +#define sk_nx_info __sk_common.skc_nx_info
14741 unsigned char sk_shutdown : 2,
14744 diff -NurpP --minimal linux-2.6.29/init/main.c linux-2.6.29-vs2.3.0.36.9-pre3/init/main.c
14745 --- linux-2.6.29/init/main.c 2009-03-24 14:22:44.000000000 +0100
14746 +++ linux-2.6.29-vs2.3.0.36.9-pre3/init/main.c 2009-03-24 17:22:37.000000000 +0100
14748 #include <linux/ftrace.h>
14749 #include <linux/async.h>
14750 #include <trace/boot.h>
14751 +#include <linux/vserver/percpu.h>
14753 #include <asm/io.h>
14754 #include <asm/bugs.h>
14755 @@ -381,12 +382,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
14757 static void __init setup_per_cpu_areas(void)
14759 - unsigned long size, i;
14760 + unsigned long size, vspc, i;
14762 unsigned long nr_possible_cpus = num_possible_cpus();
14764 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
14766 /* Copy section for each CPU (we discard the original) */
14767 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
14768 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
14769 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
14771 for_each_possible_cpu(i) {
14772 diff -NurpP --minimal linux-2.6.29/ipc/mqueue.c linux-2.6.29-vs2.3.0.36.9-pre3/ipc/mqueue.c
14773 --- linux-2.6.29/ipc/mqueue.c 2009-03-24 14:22:44.000000000 +0100
14774 +++ linux-2.6.29-vs2.3.0.36.9-pre3/ipc/mqueue.c 2009-03-24 17:24:19.000000000 +0100
14776 #include <linux/mutex.h>
14777 #include <linux/nsproxy.h>
14778 #include <linux/pid.h>
14779 +#include <linux/vs_context.h>
14780 +#include <linux/vs_limit.h>
14782 #include <net/sock.h>
14784 @@ -79,6 +81,7 @@ struct mqueue_inode_info {
14785 struct sigevent notify;
14786 struct pid* notify_owner;
14787 struct user_struct *user; /* user who created, for accounting */
14788 + struct vx_info *vxi;
14789 struct sock *notify_sock;
14790 struct sk_buff *notify_cookie;
14792 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14793 if (S_ISREG(mode)) {
14794 struct mqueue_inode_info *info;
14795 struct task_struct *p = current;
14796 + struct vx_info *vxi = p->vx_info;
14797 unsigned long mq_bytes, mq_msg_tblsz;
14799 inode->i_fop = &mqueue_file_operations;
14800 @@ -140,6 +144,7 @@ static struct inode *mqueue_get_inode(st
14801 info->notify_owner = NULL;
14803 info->user = NULL; /* set when all is ok */
14804 + info->vxi = NULL;
14805 memset(&info->attr, 0, sizeof(info->attr));
14806 info->attr.mq_maxmsg = msg_max;
14807 info->attr.mq_msgsize = msgsize_max;
14808 @@ -154,22 +159,26 @@ static struct inode *mqueue_get_inode(st
14809 spin_lock(&mq_lock);
14810 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14811 u->mq_bytes + mq_bytes >
14812 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
14813 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
14814 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14815 spin_unlock(&mq_lock);
14818 u->mq_bytes += mq_bytes;
14819 + vx_ipcmsg_add(vxi, u, mq_bytes);
14820 spin_unlock(&mq_lock);
14822 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
14823 if (!info->messages) {
14824 spin_lock(&mq_lock);
14825 u->mq_bytes -= mq_bytes;
14826 + vx_ipcmsg_sub(vxi, u, mq_bytes);
14827 spin_unlock(&mq_lock);
14831 info->user = get_uid(u);
14832 + info->vxi = get_vx_info(vxi);
14833 } else if (S_ISDIR(mode)) {
14835 /* Some things misbehave if size == 0 on a directory */
14836 @@ -260,10 +269,14 @@ static void mqueue_delete_inode(struct i
14837 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
14840 + struct vx_info *vxi = info->vxi;
14842 spin_lock(&mq_lock);
14843 user->mq_bytes -= mq_bytes;
14844 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14846 spin_unlock(&mq_lock);
14847 + put_vx_info(vxi);
14851 diff -NurpP --minimal linux-2.6.29/ipc/msg.c linux-2.6.29-vs2.3.0.36.9-pre3/ipc/msg.c
14852 --- linux-2.6.29/ipc/msg.c 2009-03-24 14:22:44.000000000 +0100
14853 +++ linux-2.6.29-vs2.3.0.36.9-pre3/ipc/msg.c 2009-02-22 22:54:26.000000000 +0100
14855 #include <linux/rwsem.h>
14856 #include <linux/nsproxy.h>
14857 #include <linux/ipc_namespace.h>
14858 +#include <linux/vs_base.h>
14860 #include <asm/current.h>
14861 #include <asm/uaccess.h>
14862 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14864 msq->q_perm.mode = msgflg & S_IRWXUGO;
14865 msq->q_perm.key = key;
14866 + msq->q_perm.xid = vx_current_xid();
14868 msq->q_perm.security = NULL;
14869 retval = security_msg_queue_alloc(msq);
14870 diff -NurpP --minimal linux-2.6.29/ipc/namespace.c linux-2.6.29-vs2.3.0.36.9-pre3/ipc/namespace.c
14871 --- linux-2.6.29/ipc/namespace.c 2008-12-25 00:26:37.000000000 +0100
14872 +++ linux-2.6.29-vs2.3.0.36.9-pre3/ipc/namespace.c 2009-02-22 22:54:26.000000000 +0100
14874 #include <linux/rcupdate.h>
14875 #include <linux/nsproxy.h>
14876 #include <linux/slab.h>
14877 +#include <linux/vs_base.h>
14878 +#include <linux/vserver/global.h>
14882 @@ -35,6 +37,7 @@ static struct ipc_namespace *clone_ipc_n
14883 register_ipcns_notifier(ns);
14885 kref_init(&ns->kref);
14886 + atomic_inc(&vs_global_ipc_ns);
14890 @@ -101,6 +104,7 @@ void free_ipc_ns(struct kref *kref)
14894 + atomic_dec(&vs_global_ipc_ns);
14896 atomic_dec(&nr_ipc_ns);
14898 diff -NurpP --minimal linux-2.6.29/ipc/sem.c linux-2.6.29-vs2.3.0.36.9-pre3/ipc/sem.c
14899 --- linux-2.6.29/ipc/sem.c 2009-03-24 14:22:44.000000000 +0100
14900 +++ linux-2.6.29-vs2.3.0.36.9-pre3/ipc/sem.c 2009-03-31 23:31:33.000000000 +0200
14902 #include <linux/rwsem.h>
14903 #include <linux/nsproxy.h>
14904 #include <linux/ipc_namespace.h>
14905 +#include <linux/vs_base.h>
14906 +#include <linux/vs_limit.h>
14908 #include <asm/uaccess.h>
14910 @@ -255,6 +257,7 @@ static int newary(struct ipc_namespace *
14912 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14913 sma->sem_perm.key = key;
14914 + sma->sem_perm.xid = vx_current_xid();
14916 sma->sem_perm.security = NULL;
14917 retval = security_sem_alloc(sma);
14918 @@ -270,6 +273,9 @@ static int newary(struct ipc_namespace *
14921 ns->used_sems += nsems;
14922 + /* FIXME: obsoleted? */
14923 + vx_semary_inc(sma);
14924 + vx_nsems_add(sma, nsems);
14926 sma->sem_base = (struct sem *) &sma[1];
14927 INIT_LIST_HEAD(&sma->sem_pending);
14928 @@ -546,6 +552,9 @@ static void freeary(struct ipc_namespace
14931 ns->used_sems -= sma->sem_nsems;
14932 + /* FIXME: obsoleted? */
14933 + vx_nsems_sub(sma, sma->sem_nsems);
14934 + vx_semary_dec(sma);
14935 security_sem_free(sma);
14936 ipc_rcu_putref(sma);
14938 diff -NurpP --minimal linux-2.6.29/ipc/shm.c linux-2.6.29-vs2.3.0.36.9-pre3/ipc/shm.c
14939 --- linux-2.6.29/ipc/shm.c 2009-03-24 14:22:44.000000000 +0100
14940 +++ linux-2.6.29-vs2.3.0.36.9-pre3/ipc/shm.c 2009-03-24 14:48:36.000000000 +0100
14942 #include <linux/nsproxy.h>
14943 #include <linux/mount.h>
14944 #include <linux/ipc_namespace.h>
14945 +#include <linux/vs_context.h>
14946 +#include <linux/vs_limit.h>
14948 #include <asm/uaccess.h>
14950 @@ -168,7 +170,12 @@ static void shm_open(struct vm_area_stru
14952 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14954 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14955 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14956 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14958 + vx_ipcshm_sub(vxi, shp, numpages);
14959 + ns->shm_tot -= numpages;
14963 if (!is_file_hugepages(shp->shm_file))
14964 @@ -178,6 +185,7 @@ static void shm_destroy(struct ipc_names
14966 fput (shp->shm_file);
14967 security_shm_free(shp);
14968 + put_vx_info(vxi);
14969 ipc_rcu_putref(shp);
14972 @@ -348,11 +356,15 @@ static int newseg(struct ipc_namespace *
14973 if (ns->shm_tot + numpages > ns->shm_ctlall)
14976 + if (!vx_ipcshm_avail(current->vx_info, numpages))
14979 shp = ipc_rcu_alloc(sizeof(*shp));
14983 shp->shm_perm.key = key;
14984 + shp->shm_perm.xid = vx_current_xid();
14985 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14986 shp->mlock_user = NULL;
14988 @@ -406,6 +418,7 @@ static int newseg(struct ipc_namespace *
14989 ns->shm_tot += numpages;
14990 error = shp->shm_perm.id;
14992 + vx_ipcshm_add(current->vx_info, key, numpages);
14996 diff -NurpP --minimal linux-2.6.29/kernel/capability.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/capability.c
14997 --- linux-2.6.29/kernel/capability.c 2009-03-24 14:22:44.000000000 +0100
14998 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/capability.c 2009-03-24 17:27:28.000000000 +0100
15000 #include <linux/security.h>
15001 #include <linux/syscalls.h>
15002 #include <linux/pid_namespace.h>
15003 +#include <linux/vs_context.h>
15004 #include <asm/uaccess.h>
15005 #include "cred-internals.h"
15007 @@ -122,6 +123,7 @@ static int cap_validate_magic(cap_user_h
15013 * The only thing that can change the capabilities of the current
15014 * process is the current process. As such, we can't be in this code
15015 @@ -289,6 +291,8 @@ error:
15019 +#include <linux/vserver/base.h>
15022 * capable - Determine if the current task has a superior capability in effect
15023 * @cap: The capability to be tested for
15024 @@ -301,6 +305,9 @@ error:
15026 int capable(int cap)
15028 + /* here for now so we don't require task locking */
15029 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15031 if (unlikely(!cap_valid(cap))) {
15032 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
15034 diff -NurpP --minimal linux-2.6.29/kernel/compat.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/compat.c
15035 --- linux-2.6.29/kernel/compat.c 2009-03-24 14:22:44.000000000 +0100
15036 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/compat.c 2009-03-24 14:48:36.000000000 +0100
15037 @@ -891,7 +891,7 @@ asmlinkage long compat_sys_time(compat_t
15041 - do_gettimeofday(&tv);
15042 + vx_gettimeofday(&tv);
15046 @@ -916,7 +916,7 @@ asmlinkage long compat_sys_stime(compat_
15050 - do_settimeofday(&tv);
15051 + vx_settimeofday(&tv);
15055 diff -NurpP --minimal linux-2.6.29/kernel/exit.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/exit.c
15056 --- linux-2.6.29/kernel/exit.c 2009-03-24 14:22:44.000000000 +0100
15057 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/exit.c 2009-03-24 17:28:40.000000000 +0100
15059 #include <linux/task_io_accounting_ops.h>
15060 #include <linux/tracehook.h>
15061 #include <linux/init_task.h>
15062 +#include <linux/vs_limit.h>
15063 +#include <linux/vs_context.h>
15064 +#include <linux/vs_network.h>
15065 +#include <linux/vs_pid.h>
15066 +#include <linux/vserver/global.h>
15067 #include <trace/sched.h>
15069 #include <asm/uaccess.h>
15070 @@ -502,9 +507,11 @@ static void close_files(struct files_str
15071 filp_close(file, files);
15074 + vx_openfd_dec(i);
15082 @@ -571,6 +578,7 @@ void put_fs_struct(struct fs_struct *fs)
15083 if (atomic_dec_and_test(&fs->count)) {
15084 path_put(&fs->root);
15085 path_put(&fs->pwd);
15086 + atomic_dec(&vs_global_fs);
15087 kmem_cache_free(fs_cachep, fs);
15090 @@ -1122,10 +1130,15 @@ NORET_TYPE void do_exit(long code)
15091 if (tsk->splice_pipe)
15092 __free_pipe_info(tsk->splice_pipe);
15094 + /* needs to stay after exit_notify() */
15095 + exit_vx_info(tsk, code);
15096 + exit_nx_info(tsk);
15099 /* causes final put_task_struct in finish_task_switch(). */
15100 tsk->state = TASK_DEAD;
15102 + printk("bad task: %p [%lx]\n", current, current->state);
15104 /* Avoid "noreturn function does return". */
15106 diff -NurpP --minimal linux-2.6.29/kernel/fork.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/fork.c
15107 --- linux-2.6.29/kernel/fork.c 2009-03-24 14:22:44.000000000 +0100
15108 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/fork.c 2009-03-24 17:31:42.000000000 +0100
15110 #include <linux/tty.h>
15111 #include <linux/proc_fs.h>
15112 #include <linux/blkdev.h>
15113 +#include <linux/vs_context.h>
15114 +#include <linux/vs_network.h>
15115 +#include <linux/vs_limit.h>
15116 +#include <linux/vs_memory.h>
15117 +#include <linux/vserver/global.h>
15118 #include <trace/sched.h>
15120 #include <asm/pgtable.h>
15121 @@ -140,6 +145,8 @@ void free_task(struct task_struct *tsk)
15122 prop_local_destroy_single(&tsk->dirties);
15123 free_thread_info(tsk->stack);
15124 rt_mutex_debug_task_free(tsk);
15125 + clr_vx_info(&tsk->vx_info);
15126 + clr_nx_info(&tsk->nx_info);
15127 ftrace_graph_exit_task(tsk);
15128 free_task_struct(tsk);
15130 @@ -279,6 +286,8 @@ static int dup_mmap(struct mm_struct *mm
15131 mm->free_area_cache = oldmm->mmap_base;
15132 mm->cached_hole_size = ~0UL;
15134 + __set_mm_counter(mm, file_rss, 0);
15135 + __set_mm_counter(mm, anon_rss, 0);
15136 cpus_clear(mm->cpu_vm_mask);
15137 mm->mm_rb = RB_ROOT;
15138 rb_link = &mm->mm_rb.rb_node;
15139 @@ -290,7 +299,7 @@ static int dup_mmap(struct mm_struct *mm
15141 if (mpnt->vm_flags & VM_DONTCOPY) {
15142 long pages = vma_pages(mpnt);
15143 - mm->total_vm -= pages;
15144 + vx_vmpages_sub(mm, pages);
15145 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15148 @@ -423,8 +432,8 @@ static struct mm_struct * mm_init(struct
15149 mm->flags = (current->mm) ? current->mm->flags : default_dump_filter;
15150 mm->core_state = NULL;
15152 - set_mm_counter(mm, file_rss, 0);
15153 - set_mm_counter(mm, anon_rss, 0);
15154 + __set_mm_counter(mm, file_rss, 0);
15155 + __set_mm_counter(mm, anon_rss, 0);
15156 spin_lock_init(&mm->page_table_lock);
15157 spin_lock_init(&mm->ioctx_lock);
15158 INIT_HLIST_HEAD(&mm->ioctx_list);
15159 @@ -435,6 +444,7 @@ static struct mm_struct * mm_init(struct
15160 if (likely(!mm_alloc_pgd(mm))) {
15162 mmu_notifier_mm_init(mm);
15163 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15167 @@ -468,6 +478,7 @@ void __mmdrop(struct mm_struct *mm)
15169 destroy_context(mm);
15170 mmu_notifier_mm_destroy(mm);
15171 + clr_vx_info(&mm->mm_vx_info);
15174 EXPORT_SYMBOL_GPL(__mmdrop);
15175 @@ -594,6 +605,7 @@ struct mm_struct *dup_mm(struct task_str
15178 memcpy(mm, oldmm, sizeof(*mm));
15179 + mm->mm_vx_info = NULL;
15181 /* Initializing for Swap token stuff */
15182 mm->token_priority = 0;
15183 @@ -627,6 +639,7 @@ fail_nocontext:
15184 * If init_new_context() failed, we cannot use mmput() to free the mm
15185 * because it calls destroy_context()
15187 + clr_vx_info(&mm->mm_vx_info);
15191 @@ -690,6 +703,7 @@ static struct fs_struct *__copy_fs_struc
15192 fs->pwd = old->pwd;
15193 path_get(&old->pwd);
15194 read_unlock(&old->lock);
15195 + atomic_inc(&vs_global_fs);
15199 @@ -955,6 +969,8 @@ static struct task_struct *copy_process(
15201 struct task_struct *p;
15202 int cgroup_callbacks_done = 0;
15203 + struct vx_info *vxi;
15204 + struct nx_info *nxi;
15206 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15207 return ERR_PTR(-EINVAL);
15208 @@ -989,12 +1005,28 @@ static struct task_struct *copy_process(
15209 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15210 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15212 + init_vx_info(&p->vx_info, current->vx_info);
15213 + init_nx_info(&p->nx_info, current->nx_info);
15215 + /* check vserver memory */
15216 + if (p->mm && !(clone_flags & CLONE_VM)) {
15217 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15218 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15220 + goto bad_fork_free;
15222 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15223 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15224 + goto bad_fork_cleanup_vm;
15227 + if (!vx_nproc_avail(1))
15228 + goto bad_fork_cleanup_vm;
15229 if (atomic_read(&p->real_cred->user->processes) >=
15230 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15231 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15232 p->real_cred->user != INIT_USER)
15233 - goto bad_fork_free;
15234 + goto bad_fork_cleanup_vm;
15237 retval = copy_creds(p, clone_flags);
15238 @@ -1271,6 +1303,18 @@ static struct task_struct *copy_process(
15241 spin_unlock(¤t->sighand->siglock);
15243 + /* p is copy of current */
15244 + vxi = p->vx_info;
15246 + claim_vx_info(vxi, p);
15247 + atomic_inc(&vxi->cvirt.nr_threads);
15248 + atomic_inc(&vxi->cvirt.total_forks);
15251 + nxi = p->nx_info;
15253 + claim_nx_info(nxi, p);
15254 write_unlock_irq(&tasklist_lock);
15255 proc_fork_connector(p);
15256 cgroup_post_fork(p);
15257 @@ -1315,6 +1359,9 @@ bad_fork_cleanup_count:
15258 atomic_dec(&p->cred->user->processes);
15259 put_cred(p->real_cred);
15261 +bad_fork_cleanup_vm:
15262 + if (p->mm && !(clone_flags & CLONE_VM))
15263 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15267 diff -NurpP --minimal linux-2.6.29/kernel/kthread.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/kthread.c
15268 --- linux-2.6.29/kernel/kthread.c 2009-03-24 14:22:44.000000000 +0100
15269 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/kthread.c 2009-03-24 14:48:36.000000000 +0100
15271 #include <linux/file.h>
15272 #include <linux/module.h>
15273 #include <linux/mutex.h>
15274 +#include <linux/vs_pid.h>
15275 #include <trace/sched.h>
15277 #define KTHREAD_NICE_LEVEL (-5)
15278 @@ -102,7 +103,7 @@ static void create_kthread(struct kthrea
15279 struct sched_param param = { .sched_priority = 0 };
15280 wait_for_completion(&create->started);
15281 read_lock(&tasklist_lock);
15282 - create->result = find_task_by_pid_ns(pid, &init_pid_ns);
15283 + create->result = find_task_by_real_pid(pid);
15284 read_unlock(&tasklist_lock);
15286 * root may have changed our (kthreadd's) priority or CPU mask.
15287 diff -NurpP --minimal linux-2.6.29/kernel/Makefile linux-2.6.29-vs2.3.0.36.9-pre3/kernel/Makefile
15288 --- linux-2.6.29/kernel/Makefile 2009-03-24 14:22:44.000000000 +0100
15289 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/Makefile 2009-03-24 14:48:36.000000000 +0100
15290 @@ -22,6 +22,7 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
15291 CFLAGS_REMOVE_sched_clock.o = -pg
15295 obj-$(CONFIG_FREEZER) += freezer.o
15296 obj-$(CONFIG_PROFILING) += profile.o
15297 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15298 diff -NurpP --minimal linux-2.6.29/kernel/nsproxy.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/nsproxy.c
15299 --- linux-2.6.29/kernel/nsproxy.c 2009-03-24 14:22:44.000000000 +0100
15300 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/nsproxy.c 2009-03-25 00:39:02.000000000 +0100
15302 #include <linux/mnt_namespace.h>
15303 #include <linux/utsname.h>
15304 #include <linux/pid_namespace.h>
15305 +#include <linux/vserver/global.h>
15306 +#include <linux/vserver/debug.h>
15307 #include <net/net_namespace.h>
15308 #include <linux/ipc_namespace.h>
15310 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
15312 memcpy(ns, orig, sizeof(struct nsproxy));
15313 atomic_set(&ns->count, 1);
15314 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
15315 + orig, atomic_read(&orig->count), ns);
15316 + atomic_inc(&vs_global_nsproxy);
15320 @@ -46,41 +51,52 @@ static inline struct nsproxy *clone_nspr
15321 * Return the newly created nsproxy. Do not attach this to the task,
15322 * leave it to the caller to do proper locking and attach it to task.
15324 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15325 - struct task_struct *tsk, struct fs_struct *new_fs)
15326 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15327 + struct nsproxy *orig, struct fs_struct *new_fs)
15329 struct nsproxy *new_nsp;
15332 - new_nsp = clone_nsproxy(tsk->nsproxy);
15333 + vxdprintk(VXD_CBIT(space, 4),
15334 + "unshare_namespaces(0x%08lx,%p,%p)",
15335 + flags, orig, new_fs);
15337 + new_nsp = clone_nsproxy(orig);
15339 return ERR_PTR(-ENOMEM);
15341 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15342 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15343 if (IS_ERR(new_nsp->mnt_ns)) {
15344 err = PTR_ERR(new_nsp->mnt_ns);
15348 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15349 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15350 if (IS_ERR(new_nsp->uts_ns)) {
15351 err = PTR_ERR(new_nsp->uts_ns);
15355 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15356 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15357 if (IS_ERR(new_nsp->ipc_ns)) {
15358 err = PTR_ERR(new_nsp->ipc_ns);
15362 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15363 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15364 if (IS_ERR(new_nsp->pid_ns)) {
15365 err = PTR_ERR(new_nsp->pid_ns);
15369 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15371 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15372 + if (IS_ERR(new_nsp->user_ns)) {
15373 + err = PTR_ERR(new_nsp->user_ns);
15377 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15378 if (IS_ERR(new_nsp->net_ns)) {
15379 err = PTR_ERR(new_nsp->net_ns);
15381 @@ -105,6 +121,35 @@ out_ns:
15382 return ERR_PTR(err);
15385 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15386 + struct fs_struct *new_fs)
15388 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15392 + * copies the nsproxy, setting refcount to 1, and grabbing a
15393 + * reference to all contained namespaces.
15395 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15397 + struct nsproxy *ns = clone_nsproxy(orig);
15401 + get_mnt_ns(ns->mnt_ns);
15403 + get_uts_ns(ns->uts_ns);
15405 + get_ipc_ns(ns->ipc_ns);
15407 + get_pid_ns(ns->pid_ns);
15409 + get_net(ns->net_ns);
15415 * called from clone. This now handles copy for nsproxy and all
15416 * namespaces therein.
15417 @@ -112,9 +157,12 @@ out_ns:
15418 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15420 struct nsproxy *old_ns = tsk->nsproxy;
15421 - struct nsproxy *new_ns;
15422 + struct nsproxy *new_ns = NULL;
15425 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15426 + flags, tsk, old_ns);
15431 @@ -151,6 +199,9 @@ int copy_namespaces(unsigned long flags,
15434 put_nsproxy(old_ns);
15435 + vxdprintk(VXD_CBIT(space, 3),
15436 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15437 + flags, tsk, old_ns, err, new_ns);
15441 @@ -164,7 +215,9 @@ void free_nsproxy(struct nsproxy *ns)
15442 put_ipc_ns(ns->ipc_ns);
15444 put_pid_ns(ns->pid_ns);
15445 - put_net(ns->net_ns);
15447 + put_net(ns->net_ns);
15448 + atomic_dec(&vs_global_nsproxy);
15449 kmem_cache_free(nsproxy_cachep, ns);
15452 @@ -177,6 +230,10 @@ int unshare_nsproxy_namespaces(unsigned
15456 + vxdprintk(VXD_CBIT(space, 4),
15457 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15458 + unshare_flags, current->nsproxy);
15460 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15463 diff -NurpP --minimal linux-2.6.29/kernel/pid.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/pid.c
15464 --- linux-2.6.29/kernel/pid.c 2009-03-24 14:22:44.000000000 +0100
15465 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/pid.c 2009-03-24 14:48:36.000000000 +0100
15467 #include <linux/pid_namespace.h>
15468 #include <linux/init_task.h>
15469 #include <linux/syscalls.h>
15470 +#include <linux/vs_pid.h>
15471 +#include <linux/vserver/global.h>
15473 #define pid_hashfn(nr, ns) \
15474 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15475 @@ -305,7 +307,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15477 struct pid *find_vpid(int nr)
15479 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15480 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15482 EXPORT_SYMBOL_GPL(find_vpid);
15484 @@ -365,6 +367,9 @@ void transfer_pid(struct task_struct *ol
15485 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15487 struct task_struct *result = NULL;
15489 + if (type == PIDTYPE_REALPID)
15490 + type = PIDTYPE_PID;
15492 struct hlist_node *first;
15493 first = rcu_dereference(pid->tasks[type].first);
15494 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid_type_ns);
15496 struct task_struct *find_task_by_vpid(pid_t vnr)
15498 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
15499 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
15500 current->nsproxy->pid_ns);
15502 EXPORT_SYMBOL(find_task_by_vpid);
15504 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15506 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
15507 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
15509 EXPORT_SYMBOL(find_task_by_pid_ns);
15511 @@ -431,7 +436,7 @@ struct pid *find_get_pid(pid_t nr)
15513 EXPORT_SYMBOL_GPL(find_get_pid);
15515 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15516 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15520 @@ -444,6 +449,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15524 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15526 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15529 pid_t pid_vnr(struct pid *pid)
15531 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15532 diff -NurpP --minimal linux-2.6.29/kernel/pid_namespace.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/pid_namespace.c
15533 --- linux-2.6.29/kernel/pid_namespace.c 2008-12-25 00:26:37.000000000 +0100
15534 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/pid_namespace.c 2009-02-22 22:54:26.000000000 +0100
15536 #include <linux/syscalls.h>
15537 #include <linux/err.h>
15538 #include <linux/acct.h>
15539 +#include <linux/vserver/global.h>
15541 #define BITS_PER_PAGE (PAGE_SIZE*8)
15543 @@ -85,6 +86,7 @@ static struct pid_namespace *create_pid_
15546 kref_init(&ns->kref);
15547 + atomic_inc(&vs_global_pid_ns);
15550 set_bit(0, ns->pidmap[0].page);
15551 @@ -109,6 +111,7 @@ static void destroy_pid_namespace(struct
15553 for (i = 0; i < PIDMAP_ENTRIES; i++)
15554 kfree(ns->pidmap[i].page);
15555 + atomic_dec(&vs_global_pid_ns);
15556 kmem_cache_free(pid_ns_cachep, ns);
15559 diff -NurpP --minimal linux-2.6.29/kernel/posix-timers.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/posix-timers.c
15560 --- linux-2.6.29/kernel/posix-timers.c 2009-03-24 14:22:44.000000000 +0100
15561 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/posix-timers.c 2009-03-24 17:36:18.000000000 +0100
15563 #include <linux/wait.h>
15564 #include <linux/workqueue.h>
15565 #include <linux/module.h>
15566 +#include <linux/vs_context.h>
15569 * Management arrays for POSIX timers. Timers are kept in slab memory
15570 @@ -321,6 +322,12 @@ int posix_timer_event(struct k_itimer *t
15572 struct task_struct *task;
15573 int shared, ret = -1;
15574 + struct vx_info_save vxis;
15575 + struct vx_info *vxi;
15577 + /* FIXME: move that down where we have the task */
15578 + vxi = task_get_vx_info(timr->it_process);
15579 + enter_vx_info(vxi, &vxis);
15581 * FIXME: if ->sigq is queued we can race with
15582 * dequeue_signal()->do_schedule_next_timer().
15583 @@ -341,6 +348,9 @@ int posix_timer_event(struct k_itimer *t
15584 ret = send_sigqueue(timr->sigq, task, shared);
15588 + leave_vx_info(&vxis);
15589 + put_vx_info(vxi);
15590 /* If we failed to send the signal the timer stops. */
15593 diff -NurpP --minimal linux-2.6.29/kernel/printk.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/printk.c
15594 --- linux-2.6.29/kernel/printk.c 2009-03-24 14:22:44.000000000 +0100
15595 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/printk.c 2009-03-24 14:48:36.000000000 +0100
15597 #include <linux/security.h>
15598 #include <linux/bootmem.h>
15599 #include <linux/syscalls.h>
15600 +#include <linux/vs_cvirt.h>
15602 #include <asm/uaccess.h>
15604 @@ -251,18 +252,13 @@ int do_syslog(int type, char __user *buf
15605 unsigned i, j, limit, count;
15611 error = security_syslog(type);
15616 - case 0: /* Close log */
15618 - case 1: /* Open log */
15620 - case 2: /* Read from log */
15621 + if ((type >= 2) && (type <= 4)) {
15623 if (!buf || len < 0)
15625 @@ -273,6 +269,16 @@ int do_syslog(int type, char __user *buf
15630 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15631 + return vx_do_syslog(type, buf, len);
15634 + case 0: /* Close log */
15636 + case 1: /* Open log */
15638 + case 2: /* Read from log */
15639 error = wait_event_interruptible(log_wait,
15640 (log_start - log_end));
15642 @@ -297,16 +303,6 @@ int do_syslog(int type, char __user *buf
15645 case 3: /* Read last kernel messages */
15647 - if (!buf || len < 0)
15652 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15657 if (count > log_buf_len)
15658 count = log_buf_len;
15659 diff -NurpP --minimal linux-2.6.29/kernel/ptrace.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/ptrace.c
15660 --- linux-2.6.29/kernel/ptrace.c 2009-03-24 14:22:44.000000000 +0100
15661 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/ptrace.c 2009-03-24 14:48:36.000000000 +0100
15663 #include <linux/audit.h>
15664 #include <linux/pid_namespace.h>
15665 #include <linux/syscalls.h>
15666 +#include <linux/vs_context.h>
15668 #include <asm/pgtable.h>
15669 #include <asm/uaccess.h>
15670 @@ -159,6 +160,11 @@ int __ptrace_may_access(struct task_stru
15671 dumpable = get_dumpable(task->mm);
15672 if (!dumpable && !capable(CAP_SYS_PTRACE))
15674 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15676 + if (!vx_check(task->xid, VS_IDENT) &&
15677 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15680 return security_ptrace_may_access(task, mode);
15682 @@ -596,6 +602,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15687 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15688 + goto out_put_task_struct;
15690 if (request == PTRACE_ATTACH) {
15691 ret = ptrace_attach(child);
15693 diff -NurpP --minimal linux-2.6.29/kernel/sched.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched.c
15694 --- linux-2.6.29/kernel/sched.c 2009-03-24 14:22:44.000000000 +0100
15695 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched.c 2009-03-24 21:52:21.000000000 +0100
15697 #include <linux/debugfs.h>
15698 #include <linux/ctype.h>
15699 #include <linux/ftrace.h>
15700 +#include <linux/vs_sched.h>
15701 +#include <linux/vs_cvirt.h>
15702 #include <trace/sched.h>
15704 #include <asm/tlb.h>
15705 @@ -610,6 +612,16 @@ struct rq {
15707 struct hrtimer hrtick_timer;
15709 + unsigned long norm_time;
15710 + unsigned long idle_time;
15711 +#ifdef CONFIG_VSERVER_IDLETIME
15714 +#ifdef CONFIG_VSERVER_HARDCPU
15715 + struct list_head hold_queue;
15716 + unsigned long nr_onhold;
15720 #ifdef CONFIG_SCHEDSTATS
15721 /* latency stats */
15722 @@ -1705,6 +1717,7 @@ static void update_avg(u64 *avg, u64 sam
15724 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
15726 + // BUG_ON(p->state & TASK_ONHOLD);
15727 sched_info_queued(p);
15728 p->sched_class->enqueue_task(rq, p, wakeup);
15730 @@ -1828,6 +1841,8 @@ static inline void check_class_changed(s
15731 p->sched_class->prio_changed(rq, p, oldprio, running);
15734 +#include "sched_mon.h"
15738 /* Used instead of source_load when we know the type == 0 */
15739 @@ -1915,6 +1930,7 @@ migrate_task(struct task_struct *p, int
15741 struct rq *rq = task_rq(p);
15743 + vxm_migrate_task(p, rq, dest_cpu);
15745 * If the task is not on a runqueue (and not running), then
15746 * it is sufficient to simply update the task's cpu field.
15747 @@ -2242,6 +2258,8 @@ static int sched_balance_self(int cpu, i
15749 #endif /* CONFIG_SMP */
15751 +#include "sched_hard.h"
15754 * try_to_wake_up - wake up a thread
15755 * @p: the to-be-woken-up thread
15756 @@ -2286,6 +2304,13 @@ static int try_to_wake_up(struct task_st
15757 rq = task_rq_lock(p, &flags);
15758 update_rq_clock(rq);
15759 old_state = p->state;
15761 + /* we need to unhold suspended tasks */
15762 + if (old_state & TASK_ONHOLD) {
15763 + vx_unhold_task(p, rq);
15764 + old_state = p->state;
15767 if (!(old_state & state))
15770 @@ -2307,6 +2332,12 @@ static int try_to_wake_up(struct task_st
15771 /* might preempt at this point */
15772 rq = task_rq_lock(p, &flags);
15773 old_state = p->state;
15775 + /* we need to unhold suspended tasks
15776 + if (old_state & TASK_ONHOLD) {
15777 + vx_unhold_task(p, rq);
15778 + old_state = p->state;
15780 if (!(old_state & state))
15783 @@ -4169,16 +4200,19 @@ void account_user_time(struct task_struc
15784 cputime_t cputime_scaled)
15786 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15787 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15789 + int nice = (TASK_NICE(p) > 0);
15791 /* Add user time to process. */
15792 p->utime = cputime_add(p->utime, cputime);
15793 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15794 + vx_account_user(vxi, cputime, nice);
15795 account_group_user_time(p, cputime);
15797 /* Add user time to cpustat. */
15798 tmp = cputime_to_cputime64(cputime);
15799 - if (TASK_NICE(p) > 0)
15801 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15803 cpustat->user = cputime64_add(cpustat->user, tmp);
15804 @@ -4222,6 +4256,7 @@ void account_system_time(struct task_str
15805 cputime_t cputime, cputime_t cputime_scaled)
15807 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15808 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15811 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15812 @@ -4232,6 +4267,7 @@ void account_system_time(struct task_str
15813 /* Add system time to process. */
15814 p->stime = cputime_add(p->stime, cputime);
15815 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15816 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15817 account_group_system_time(p, cputime);
15819 /* Add system time to cpustat. */
15820 @@ -4587,6 +4623,11 @@ need_resched_nonpreemptible:
15821 idle_balance(cpu, rq);
15823 prev->sched_class->put_prev_task(rq, prev);
15825 + vx_set_rq_time(rq, jiffies); /* update time */
15826 + vx_schedule(prev, rq, cpu); /* hold if over limit */
15827 + vx_try_unhold(rq, cpu); /* unhold if refilled */
15829 next = pick_next_task(rq, prev);
15831 if (likely(prev != next)) {
15832 @@ -5152,7 +5193,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15835 if (increment < 0 && !can_nice(current, nice))
15837 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15839 retval = security_task_setnice(current, nice);
15841 @@ -8428,7 +8469,10 @@ void __init sched_init(void)
15844 #endif /* CONFIG_FAIR_GROUP_SCHED */
15846 +#ifdef CONFIG_VSERVER_HARDCPU
15847 + INIT_LIST_HEAD(&rq->hold_queue);
15848 + rq->nr_onhold = 0;
15850 rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime;
15851 #ifdef CONFIG_RT_GROUP_SCHED
15852 INIT_LIST_HEAD(&rq->leaf_rt_rq_list);
15853 diff -NurpP --minimal linux-2.6.29/kernel/sched_fair.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched_fair.c
15854 --- linux-2.6.29/kernel/sched_fair.c 2009-03-24 14:22:45.000000000 +0100
15855 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched_fair.c 2009-03-24 14:48:36.000000000 +0100
15856 @@ -717,6 +717,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15857 check_spread(cfs_rq, se);
15858 if (se != cfs_rq->curr)
15859 __enqueue_entity(cfs_rq, se);
15861 + if (entity_is_task(se))
15862 + vx_activate_task(task_of(se));
15865 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15866 @@ -760,6 +763,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15868 if (se != cfs_rq->curr)
15869 __dequeue_entity(cfs_rq, se);
15870 + if (entity_is_task(se))
15871 + vx_deactivate_task(task_of(se));
15872 account_entity_dequeue(cfs_rq, se);
15873 update_min_vruntime(cfs_rq);
15875 diff -NurpP --minimal linux-2.6.29/kernel/sched_hard.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched_hard.h
15876 --- linux-2.6.29/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
15877 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched_hard.h 2009-02-22 22:54:26.000000000 +0100
15880 +#ifdef CONFIG_VSERVER_IDLELIMIT
15883 + * vx_idle_resched - reschedule after maxidle
15886 +void vx_idle_resched(struct rq *rq)
15888 + /* maybe have a better criterion for paused */
15889 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
15890 + set_need_resched();
15893 +#else /* !CONFIG_VSERVER_IDLELIMIT */
15895 +#define vx_idle_resched(rq)
15897 +#endif /* CONFIG_VSERVER_IDLELIMIT */
15901 +#ifdef CONFIG_VSERVER_IDLETIME
15903 +#define vx_set_rq_min_skip(rq, min) \
15904 + (rq)->idle_skip = (min)
15906 +#define vx_save_min_skip(ret, min, val) \
15907 + __vx_save_min_skip(ret, min, val)
15910 +void __vx_save_min_skip(int ret, int *min, int val)
15914 + if ((*min > val) || !*min)
15919 +int vx_try_skip(struct rq *rq, int cpu)
15921 + /* artificially advance time */
15922 + if (rq->idle_skip > 0) {
15923 + vxdprintk(list_empty(&rq->hold_queue),
15924 + "hold queue empty on cpu %d", cpu);
15925 + rq->idle_time += rq->idle_skip;
15926 + vxm_idle_skip(rq, cpu);
15932 +#else /* !CONFIG_VSERVER_IDLETIME */
15934 +#define vx_set_rq_min_skip(rq, min) \
15935 + ({ int dummy = (min); dummy; })
15937 +#define vx_save_min_skip(ret, min, val)
15940 +int vx_try_skip(struct rq *rq, int cpu)
15945 +#endif /* CONFIG_VSERVER_IDLETIME */
15949 +#ifdef CONFIG_VSERVER_HARDCPU
15951 +#define vx_set_rq_max_idle(rq, max) \
15952 + (rq)->idle_tokens = (max)
15954 +#define vx_save_max_idle(ret, min, val) \
15955 + __vx_save_max_idle(ret, min, val)
15958 +void __vx_save_max_idle(int ret, int *min, int val)
15966 + * vx_hold_task - put a task on the hold queue
15969 +void vx_hold_task(struct task_struct *p, struct rq *rq)
15971 + // printk("@ hold_task(%p[%lx])\n", p, p->state);
15973 + /* ignore dead/killed tasks */
15974 + if (unlikely(p->state & (TASK_DEAD | TASK_WAKEKILL)))
15977 + /* ignore sleeping tasks */
15978 + if (unlikely(p->state & TASK_NORMAL))
15981 + /* remove task from runqueue */
15982 + if (likely(p->se.on_rq))
15983 + dequeue_task(rq, p, 0);
15985 + printk("@ woops, task %p not on runqueue?\n", p);
15987 + p->state |= TASK_ONHOLD;
15988 + /* a new one on hold */
15990 + vxm_hold_task(p, rq);
15991 + list_add_tail(&p->hq, &rq->hold_queue);
15992 + // list_add_tail(&p->run_list, &rq->hold_queue);
15996 + * vx_unhold_task - put a task back to the runqueue
15999 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16001 + // printk("@ unhold_task(%p[%lx])\n", p, p->state);
16002 + list_del_init(&p->hq);
16003 + // list_del(&p->run_list);
16004 + /* one less waiting */
16006 + p->state &= ~TASK_ONHOLD;
16007 + enqueue_task(rq, p, 0);
16008 + // ? inc_nr_running(p, rq);
16009 + vxm_unhold_task(p, rq);
16013 + * vx_remove_hold - remove a task from the hold queue
16016 +void vx_remove_hold(struct task_struct *p, struct rq *rq)
16018 + printk("@ remove_hold(%p[%lx])\n", p, p->state);
16019 + list_del_init(&p->hq);
16020 + // list_del(&p->run_list);
16021 + /* one less waiting */
16023 + p->state &= ~TASK_ONHOLD;
16026 +unsigned long nr_onhold(void)
16028 + unsigned long i, sum = 0;
16030 + for_each_online_cpu(i)
16031 + sum += cpu_rq(i)->nr_onhold;
16039 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
16041 + return sched_pc->tokens;
16045 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16047 + sched_pc->tokens--;
16051 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16053 + struct vx_info *vxi = p->vx_info;
16055 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16056 + struct _vx_sched_pc *sched_pc =
16057 + &vx_per_cpu(vxi, sched_pc, cpu);
16060 + /* maybe we can simplify that to decrement
16061 + the token counter unconditional? */
16063 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
16064 + __vx_consume_token(sched_pc);
16066 + /* for tokens > 0, one token was consumed */
16070 + vxm_need_resched(p, slice, cpu);
16071 + return (slice == 0);
16075 +#define vx_set_rq_time(rq, time) do { \
16076 + rq->norm_time = time; \
16081 +void vx_try_unhold(struct rq *rq, int cpu)
16083 + struct vx_info *vxi = NULL;
16084 + struct list_head *l, *n;
16085 + int maxidle = HZ;
16088 + /* nothing to do? what about pause? */
16089 + if (list_empty(&rq->hold_queue))
16092 + list_for_each_safe(l, n, &rq->hold_queue) {
16093 + int ret, delta_min[2];
16094 + struct _vx_sched_pc *sched_pc;
16095 + struct task_struct *p;
16097 + p = list_entry(l, struct task_struct, hq);
16098 + /* don't bother with same context */
16099 + if (vxi == p->vx_info)
16102 + vxi = p->vx_info;
16103 + /* ignore paused contexts */
16104 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
16107 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16109 + /* recalc tokens */
16110 + vxm_sched_info(sched_pc, vxi, cpu);
16111 + ret = vx_tokens_recalc(sched_pc,
16112 + &rq->norm_time, &rq->idle_time, delta_min);
16113 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16116 + /* we found a runable context */
16117 + vx_unhold_task(p, rq);
16120 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
16121 + vx_save_min_skip(ret, &minskip, delta_min[1]);
16123 + vx_set_rq_max_idle(rq, maxidle);
16124 + vx_set_rq_min_skip(rq, minskip);
16125 + vxm_rq_max_min(rq, cpu);
16130 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16132 + struct vx_info *vxi = next->vx_info;
16133 + struct _vx_sched_pc *sched_pc;
16134 + int delta_min[2];
16140 + flags = vxi->vx_flags;
16142 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
16143 + goto put_on_hold;
16144 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
16147 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16149 + /* update scheduler params */
16150 + if (cpu_isset(cpu, vxi->sched.update)) {
16151 + vx_update_sched_param(&vxi->sched, sched_pc);
16152 + vxm_update_sched(sched_pc, vxi, cpu);
16153 + cpu_clear(cpu, vxi->sched.update);
16156 + vxm_sched_info(sched_pc, vxi, cpu);
16157 + ret = vx_tokens_recalc(sched_pc,
16158 + &rq->norm_time, &rq->idle_time, delta_min);
16159 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16161 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
16164 + if (unlikely(ret < 0)) {
16165 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
16166 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
16167 + vxm_rq_max_min(rq, cpu);
16169 + vx_hold_task(next, rq);
16176 +#else /* CONFIG_VSERVER_HARDCPU */
16179 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16185 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16190 +unsigned long nr_onhold(void)
16197 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16199 + return (slice == 0);
16203 +#define vx_set_rq_time(rq, time)
16206 +void vx_try_unhold(struct rq *rq, int cpu)
16212 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16214 + struct vx_info *vxi = next->vx_info;
16215 + struct _vx_sched_pc *sched_pc;
16216 + int delta_min[2];
16219 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
16222 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16223 + vxm_sched_info(sched_pc, vxi, cpu);
16224 + ret = vx_tokens_recalc(sched_pc,
16225 + &rq->norm_time, &rq->idle_time, delta_min);
16226 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16230 +#endif /* CONFIG_VSERVER_HARDCPU */
16232 diff -NurpP --minimal linux-2.6.29/kernel/sched_mon.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched_mon.h
16233 --- linux-2.6.29/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
16234 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sched_mon.h 2009-02-22 22:54:26.000000000 +0100
16237 +#include <linux/vserver/monitor.h>
16239 +#ifdef CONFIG_VSERVER_MONITOR
16241 +#ifdef CONFIG_VSERVER_HARDCPU
16242 +#define HARDCPU(x) (x)
16244 +#define HARDCPU(x) (0)
16247 +#ifdef CONFIG_VSERVER_IDLETIME
16248 +#define IDLETIME(x) (x)
16250 +#define IDLETIME(x) (0)
16253 +struct _vx_mon_entry *vxm_advance(int cpu);
16257 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
16259 + entry->type = type;
16260 + entry->xid = xid;
16264 +void __vxm_sync(int cpu)
16266 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16268 + __vxm_basic(entry, 0, VXM_SYNC);
16269 + entry->ev.sec = xtime.tv_sec;
16270 + entry->ev.nsec = xtime.tv_nsec;
16274 +void __vxm_task(struct task_struct *p, int type)
16276 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
16278 + __vxm_basic(entry, p->xid, type);
16279 + entry->ev.tsk.pid = p->pid;
16280 + entry->ev.tsk.state = p->state;
16284 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16286 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16288 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
16289 + entry->sd.tokens = s->tokens;
16290 + entry->sd.norm_time = s->norm_time;
16291 + entry->sd.idle_time = s->idle_time;
16295 +void __vxm_rqinfo1(struct rq *q, int cpu)
16297 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16299 + entry->type = VXM_RQINFO_1;
16300 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
16301 + entry->q1.running = q->nr_running;
16302 + entry->q1.onhold = HARDCPU(q->nr_onhold);
16303 + entry->q1.iowait = atomic_read(&q->nr_iowait);
16304 + entry->q1.uintr = q->nr_uninterruptible;
16305 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
16309 +void __vxm_rqinfo2(struct rq *q, int cpu)
16311 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16313 + entry->type = VXM_RQINFO_2;
16314 + entry->xid = (unsigned long)q & 0xffff;
16315 + entry->q2.norm_time = q->norm_time;
16316 + entry->q2.idle_time = q->idle_time;
16317 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
16321 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16323 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16325 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
16326 + entry->ev.tokens = s->tokens;
16330 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16332 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16334 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
16335 + entry->u1.tokens_max = s->tokens_max;
16336 + entry->u1.fill_rate = s->fill_rate[0];
16337 + entry->u1.interval = s->interval[0];
16341 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16343 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16345 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
16346 + entry->u2.tokens_min = s->tokens_min;
16347 + entry->u2.fill_rate = s->fill_rate[1];
16348 + entry->u2.interval = s->interval[1];
16352 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
16353 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
16354 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
16355 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
16356 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
16359 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
16361 + __vxm_task(p, VXM_MIGRATE);
16362 + __vxm_rqinfo1(rq, task_cpu(p));
16363 + __vxm_rqinfo2(rq, task_cpu(p));
16367 +void vxm_idle_skip(struct rq *rq, int cpu)
16369 + __vxm_rqinfo1(rq, cpu);
16370 + __vxm_rqinfo2(rq, cpu);
16374 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
16379 + __vxm_task(p, VXM_RESCHED);
16383 +void vxm_sync(unsigned long now, int cpu)
16385 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
16386 + (now % CONFIG_VSERVER_MONITOR_SYNC))
16392 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
16395 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
16396 + struct vx_info *vxi, int cpu)
16398 + __vxm_sched(s, vxi, cpu);
16399 + __vxm_rqinfo2(rq, cpu);
16403 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16405 + __vxm_sched(s, vxi, cpu);
16406 + __vxm_update(s, vxi, cpu);
16407 + __vxm_update1(s, vxi, cpu);
16408 + __vxm_update2(s, vxi, cpu);
16412 +void vxm_rq_max_min(struct rq *rq, int cpu)
16414 + __vxm_rqinfo1(rq, cpu);
16415 + __vxm_rqinfo2(rq, cpu);
16418 +#else /* CONFIG_VSERVER_MONITOR */
16420 +#define vxm_activate_task(t,q) do { } while (0)
16421 +#define vxm_activate_idle(t,q) do { } while (0)
16422 +#define vxm_deactivate_task(t,q) do { } while (0)
16423 +#define vxm_hold_task(t,q) do { } while (0)
16424 +#define vxm_unhold_task(t,q) do { } while (0)
16425 +#define vxm_migrate_task(t,q,d) do { } while (0)
16426 +#define vxm_idle_skip(q,c) do { } while (0)
16427 +#define vxm_need_resched(t,s,c) do { } while (0)
16428 +#define vxm_sync(s,c) do { } while (0)
16429 +#define vxm_sched_info(s,v,c) do { } while (0)
16430 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16431 +#define vxm_update_sched(s,v,c) do { } while (0)
16432 +#define vxm_rq_max_min(q,c) do { } while (0)
16434 +#endif /* CONFIG_VSERVER_MONITOR */
16436 diff -NurpP --minimal linux-2.6.29/kernel/signal.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/signal.c
16437 --- linux-2.6.29/kernel/signal.c 2009-03-24 14:22:45.000000000 +0100
16438 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/signal.c 2009-03-24 14:48:36.000000000 +0100
16440 #include <linux/freezer.h>
16441 #include <linux/pid_namespace.h>
16442 #include <linux/nsproxy.h>
16443 +#include <linux/vs_context.h>
16444 +#include <linux/vs_pid.h>
16445 #include <trace/sched.h>
16447 #include <asm/param.h>
16448 @@ -584,6 +586,14 @@ static int check_kill_permission(int sig
16449 if (!valid_signal(sig))
16452 + if ((info != SEND_SIG_NOINFO) &&
16453 + (is_si_special(info) || !SI_FROMUSER(info)))
16456 + vxdprintk(VXD_CBIT(misc, 7),
16457 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16458 + sig, info, t, vx_task_xid(t), t->pid);
16460 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
16463 @@ -611,6 +621,18 @@ static int check_kill_permission(int sig
16468 + if (t->pid == 1 && current->xid)
16472 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16473 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16474 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16475 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16479 return security_task_kill(t, info, sig, 0);
16482 @@ -1076,7 +1098,7 @@ int kill_pid_info(int sig, struct siginf
16485 p = pid_task(pid, PIDTYPE_PID);
16487 + if (p && vx_check(vx_task_xid(p), VS_ADMIN | VS_IDENT)) {
16488 error = group_send_sig_info(sig, info, p);
16489 if (unlikely(error == -ESRCH))
16491 @@ -1115,7 +1137,7 @@ int kill_pid_info_as_uid(int sig, struct
16493 read_lock(&tasklist_lock);
16494 p = pid_task(pid, PIDTYPE_PID);
16496 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16500 @@ -1169,8 +1191,10 @@ static int kill_something_info(int sig,
16501 struct task_struct * p;
16503 for_each_process(p) {
16504 - if (task_pid_vnr(p) > 1 &&
16505 - !same_thread_group(p, current)) {
16506 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16507 + task_pid_vnr(p) > 1 &&
16508 + !same_thread_group(p, current) &&
16509 + !vx_current_initpid(p->pid)) {
16510 int err = group_send_sig_info(sig, info, p);
16513 @@ -1849,6 +1873,11 @@ relock:
16514 !signal_group_exit(signal))
16517 + /* virtual init is protected against user signals */
16518 + if ((info->si_code == SI_USER) &&
16519 + vx_current_initpid(current->pid))
16522 if (sig_kernel_stop(signr)) {
16524 * The default action is to stop all threads in
16525 diff -NurpP --minimal linux-2.6.29/kernel/softirq.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/softirq.c
16526 --- linux-2.6.29/kernel/softirq.c 2009-03-24 14:22:45.000000000 +0100
16527 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/softirq.c 2009-03-24 14:48:36.000000000 +0100
16529 #include <linux/rcupdate.h>
16530 #include <linux/smp.h>
16531 #include <linux/tick.h>
16532 +#include <linux/vs_context.h>
16534 #include <asm/irq.h>
16536 diff -NurpP --minimal linux-2.6.29/kernel/sys.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sys.c
16537 --- linux-2.6.29/kernel/sys.c 2009-03-24 14:22:45.000000000 +0100
16538 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sys.c 2009-03-24 14:48:36.000000000 +0100
16540 #include <linux/syscalls.h>
16541 #include <linux/kprobes.h>
16542 #include <linux/user_namespace.h>
16543 +#include <linux/vs_pid.h>
16545 #include <asm/uaccess.h>
16546 #include <asm/io.h>
16547 @@ -128,7 +129,10 @@ static int set_one_prio(struct task_stru
16550 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16552 + if (vx_flags(VXF_IGNEG_NICE, 0))
16558 no_nice = security_task_setnice(p, niceval);
16559 @@ -177,6 +181,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
16561 pgrp = task_pgrp(current);
16562 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16563 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16565 error = set_one_prio(p, niceval, error);
16566 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16568 @@ -238,6 +244,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
16570 pgrp = task_pgrp(current);
16571 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16572 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16574 niceval = 20 - task_nice(p);
16575 if (niceval > retval)
16577 @@ -347,6 +355,9 @@ void kernel_power_off(void)
16578 machine_power_off();
16580 EXPORT_SYMBOL_GPL(kernel_power_off);
16582 +long vs_reboot(unsigned int, void __user *);
16585 * Reboot system call: for obvious reasons only root may call it,
16586 * and even root needs to set up some magic numbers in the registers
16587 @@ -378,6 +389,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
16588 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16589 cmd = LINUX_REBOOT_CMD_HALT;
16591 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16592 + return vs_reboot(cmd, arg);
16596 case LINUX_REBOOT_CMD_RESTART:
16597 @@ -1420,7 +1434,7 @@ SYSCALL_DEFINE2(sethostname, char __user
16599 char tmp[__NEW_UTS_LEN];
16601 - if (!capable(CAP_SYS_ADMIN))
16602 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16604 if (len < 0 || len > __NEW_UTS_LEN)
16606 @@ -1469,7 +1483,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
16608 char tmp[__NEW_UTS_LEN];
16610 - if (!capable(CAP_SYS_ADMIN))
16611 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16613 if (len < 0 || len > __NEW_UTS_LEN)
16615 @@ -1538,7 +1552,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
16617 old_rlim = current->signal->rlim + resource;
16618 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
16619 - !capable(CAP_SYS_RESOURCE))
16620 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
16622 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
16624 diff -NurpP --minimal linux-2.6.29/kernel/sysctl.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sysctl.c
16625 --- linux-2.6.29/kernel/sysctl.c 2009-03-24 14:22:45.000000000 +0100
16626 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sysctl.c 2009-03-24 14:48:36.000000000 +0100
16627 @@ -114,6 +114,7 @@ static int ngroups_max = NGROUPS_MAX;
16628 #ifdef CONFIG_MODULES
16629 extern char modprobe_path[];
16631 +extern char vshelper_path[];
16632 #ifdef CONFIG_CHR_DEV_SG
16633 extern int sg_big_buff;
16635 @@ -545,6 +546,15 @@ static struct ctl_table kern_table[] = {
16636 .strategy = &sysctl_string,
16640 + .ctl_name = KERN_VSHELPER,
16641 + .procname = "vshelper",
16642 + .data = &vshelper_path,
16645 + .proc_handler = &proc_dostring,
16646 + .strategy = &sysctl_string,
16648 #ifdef CONFIG_CHR_DEV_SG
16650 .ctl_name = KERN_SG_BIG_BUFF,
16651 diff -NurpP --minimal linux-2.6.29/kernel/sysctl_check.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sysctl_check.c
16652 --- linux-2.6.29/kernel/sysctl_check.c 2009-03-24 14:22:45.000000000 +0100
16653 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/sysctl_check.c 2009-03-24 14:48:36.000000000 +0100
16654 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
16656 { KERN_PANIC, "panic" },
16657 { KERN_REALROOTDEV, "real-root-dev" },
16658 + { KERN_VSHELPER, "vshelper", },
16660 { KERN_SPARC_REBOOT, "reboot-cmd" },
16661 { KERN_CTLALTDEL, "ctrl-alt-del" },
16662 @@ -1216,6 +1217,22 @@ static const struct trans_ctl_table tran
16666 +static struct trans_ctl_table trans_vserver_table[] = {
16667 + { 1, "debug_switch" },
16668 + { 2, "debug_xid" },
16669 + { 3, "debug_nid" },
16670 + { 4, "debug_tag" },
16671 + { 5, "debug_net" },
16672 + { 6, "debug_limit" },
16673 + { 7, "debug_cres" },
16674 + { 8, "debug_dlim" },
16675 + { 9, "debug_quota" },
16676 + { 10, "debug_cvirt" },
16677 + { 11, "debug_space" },
16678 + { 12, "debug_misc" },
16682 static const struct trans_ctl_table trans_root_table[] = {
16683 { CTL_KERN, "kernel", trans_kern_table },
16684 { CTL_VM, "vm", trans_vm_table },
16685 @@ -1232,6 +1249,7 @@ static const struct trans_ctl_table tran
16686 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
16687 { CTL_PM, "pm", trans_pm_table },
16688 { CTL_FRV, "frv", trans_frv_table },
16689 + { CTL_VSERVER, "vserver", trans_vserver_table },
16693 diff -NurpP --minimal linux-2.6.29/kernel/time.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/time.c
16694 --- linux-2.6.29/kernel/time.c 2009-03-24 14:22:45.000000000 +0100
16695 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/time.c 2009-03-24 14:48:36.000000000 +0100
16696 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
16697 SYSCALL_DEFINE1(time, time_t __user *, tloc)
16699 time_t i = get_seconds();
16700 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
16703 if (put_user(i,tloc))
16704 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
16708 - do_settimeofday(&tv);
16709 + vx_settimeofday(&tv);
16713 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
16715 if (likely(tv != NULL)) {
16716 struct timeval ktv;
16717 - do_gettimeofday(&ktv);
16718 + vx_gettimeofday(&ktv);
16719 if (copy_to_user(tv, &ktv, sizeof(ktv)))
16722 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec
16723 /* SMP safe, again the code in arch/foo/time.c should
16724 * globally block out interrupts when it runs.
16726 - return do_settimeofday(tv);
16727 + return vx_settimeofday(tv);
16731 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
16735 - do_gettimeofday(&x);
16736 + vx_gettimeofday(&x);
16737 tv->tv_sec = x.tv_sec;
16738 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
16740 diff -NurpP --minimal linux-2.6.29/kernel/timer.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/timer.c
16741 --- linux-2.6.29/kernel/timer.c 2009-03-24 14:22:45.000000000 +0100
16742 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/timer.c 2009-03-24 17:41:02.000000000 +0100
16744 #include <linux/delay.h>
16745 #include <linux/tick.h>
16746 #include <linux/kallsyms.h>
16747 +#include <linux/vs_base.h>
16748 +#include <linux/vs_cvirt.h>
16749 +#include <linux/vs_pid.h>
16750 +#include <linux/vserver/sched.h>
16752 #include <asm/uaccess.h>
16753 #include <asm/unistd.h>
16754 @@ -1018,6 +1022,25 @@ unsigned long get_next_timer_interrupt(u
16759 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16761 + sched_pc->tokens--;
16765 +void vx_hard_tick(struct task_struct *p, int cpu)
16767 + struct vx_info *vxi = p->vx_info;
16769 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16770 + struct _vx_sched_pc *sched_pc =
16771 + &vx_per_cpu(vxi, sched_pc, cpu);
16773 + __vx_consume_token(sched_pc);
16778 * Called from the timer interrupt handler to charge one tick to the current
16779 * process. user_tick is 1 if the tick is user time, 0 for system.
16780 @@ -1034,6 +1057,7 @@ void update_process_times(int user_tick)
16781 rcu_check_callbacks(cpu, user_tick);
16784 + vx_hard_tick(p, cpu);
16785 run_posix_cpu_timers(p);
16788 @@ -1136,12 +1160,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
16795 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
16796 - * should be moved into arch/i386 instead?
16800 * sys_getpid - return the thread group id of the current process
16801 @@ -1170,10 +1188,23 @@ SYSCALL_DEFINE0(getppid)
16803 pid = task_tgid_vnr(current->real_parent);
16805 + return vx_map_pid(pid);
16812 + * The Alpha uses getxpid, getxuid, and getxgid instead.
16815 +asmlinkage long do_getxpid(long *ppid)
16817 + *ppid = sys_getppid();
16818 + return sys_getpid();
16821 +#else /* _alpha_ */
16823 SYSCALL_DEFINE0(getuid)
16825 /* Only we change this so SMP safe */
16826 @@ -1344,6 +1375,8 @@ int do_sysinfo(struct sysinfo *info)
16827 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
16830 + if (vx_flags(VXF_VIRT_UPTIME, 0))
16831 + vx_vsi_uptime(&tp, NULL);
16832 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
16834 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
16835 diff -NurpP --minimal linux-2.6.29/kernel/user.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/user.c
16836 --- linux-2.6.29/kernel/user.c 2009-03-24 14:22:45.000000000 +0100
16837 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/user.c 2009-03-24 17:47:32.000000000 +0100
16838 @@ -249,10 +249,10 @@ static struct kobj_type uids_ktype = {
16840 * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
16842 -static int uids_user_create(struct user_struct *up)
16843 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
16845 struct kobject *kobj = &up->kobj;
16849 memset(kobj, 0, sizeof(struct kobject));
16850 if (up->user_ns != &init_user_ns)
16851 @@ -280,7 +280,7 @@ int __init uids_sysfs_init(void)
16855 - return uids_user_create(&root_user);
16856 + return uids_user_create(NULL, &root_user);
16859 /* work function to remove sysfs directory for a user and free up
16860 @@ -342,7 +342,8 @@ static void free_user(struct user_struct
16861 #else /* CONFIG_USER_SCHED && CONFIG_SYSFS */
16863 int uids_sysfs_init(void) { return 0; }
16864 -static inline int uids_user_create(struct user_struct *up) { return 0; }
16865 +static inline int uids_user_create(struct user_namespace *ns,
16866 + struct user_struct *up) { return 0; }
16867 static inline void uids_mutex_lock(void) { }
16868 static inline void uids_mutex_unlock(void) { }
16870 @@ -439,7 +440,7 @@ struct user_struct *alloc_uid(struct use
16872 new->user_ns = get_user_ns(ns);
16874 - if (uids_user_create(new))
16875 + if (uids_user_create(ns, new))
16876 goto out_destoy_sched;
16879 diff -NurpP --minimal linux-2.6.29/kernel/user_namespace.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/user_namespace.c
16880 --- linux-2.6.29/kernel/user_namespace.c 2009-03-24 14:22:45.000000000 +0100
16881 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/user_namespace.c 2009-03-24 18:05:19.000000000 +0100
16883 #include <linux/slab.h>
16884 #include <linux/user_namespace.h>
16885 #include <linux/cred.h>
16886 +#include <linux/vserver/global.h>
16889 * Create a new user namespace, deriving the creator from the user in the
16890 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
16893 kref_init(&ns->kref);
16894 + atomic_inc(&vs_global_user_ns);
16896 for (n = 0; n < UIDHASH_SZ; ++n)
16897 INIT_HLIST_HEAD(ns->uidhash_table + n);
16898 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
16899 struct user_namespace *ns =
16900 container_of(kref, struct user_namespace, kref);
16902 + /* FIXME: maybe move into destroyer? */
16903 + atomic_dec(&vs_global_user_ns);
16904 INIT_WORK(&ns->destroyer, free_user_ns_work);
16905 schedule_work(&ns->destroyer);
16907 diff -NurpP --minimal linux-2.6.29/kernel/utsname.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/utsname.c
16908 --- linux-2.6.29/kernel/utsname.c 2008-12-25 00:26:37.000000000 +0100
16909 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/utsname.c 2009-02-22 22:54:26.000000000 +0100
16911 #include <linux/utsname.h>
16912 #include <linux/err.h>
16913 #include <linux/slab.h>
16914 +#include <linux/vserver/global.h>
16917 * Clone a new ns copying an original utsname, setting refcount to 1
16918 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
16919 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
16921 kref_init(&ns->kref);
16922 + atomic_inc(&vs_global_uts_ns);
16926 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
16927 struct uts_namespace *ns;
16929 ns = container_of(kref, struct uts_namespace, kref);
16930 + atomic_dec(&vs_global_uts_ns);
16933 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cacct.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cacct.c
16934 --- linux-2.6.29/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16935 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cacct.c 2009-02-22 22:54:26.000000000 +0100
16938 + * linux/kernel/vserver/cacct.c
16940 + * Virtual Server: Context Accounting
16942 + * Copyright (C) 2006-2007 Herbert Pötzl
16944 + * V0.01 added accounting stats
16948 +#include <linux/types.h>
16949 +#include <linux/vs_context.h>
16950 +#include <linux/vserver/cacct_cmd.h>
16951 +#include <linux/vserver/cacct_int.h>
16953 +#include <asm/errno.h>
16954 +#include <asm/uaccess.h>
16957 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16959 + struct vcmd_sock_stat_v0 vc_data;
16962 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16965 + field = vc_data.field;
16966 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16969 + for (j = 0; j < 3; j++) {
16970 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16971 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16974 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16979 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cacct_init.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cacct_init.h
16980 --- linux-2.6.29/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16981 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cacct_init.h 2009-02-22 22:54:26.000000000 +0100
16985 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16990 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16991 + for (j = 0; j < 3; j++) {
16992 + atomic_set(&cacct->sock[i][j].count, 0);
16993 + atomic_set(&cacct->sock[i][j].total, 0);
16996 + for (i = 0; i < 8; i++)
16997 + atomic_set(&cacct->slab[i], 0);
16998 + for (i = 0; i < 5; i++)
16999 + for (j = 0; j < 4; j++)
17000 + atomic_set(&cacct->page[i][j], 0);
17003 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17008 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cacct_proc.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cacct_proc.h
17009 --- linux-2.6.29/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17010 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cacct_proc.h 2009-02-22 22:54:26.000000000 +0100
17012 +#ifndef _VX_CACCT_PROC_H
17013 +#define _VX_CACCT_PROC_H
17015 +#include <linux/vserver/cacct_int.h>
17018 +#define VX_SOCKA_TOP \
17019 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17021 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17023 + int i, j, length = 0;
17024 + static char *type[VXA_SOCK_SIZE] = {
17025 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17028 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17029 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17030 + length += sprintf(buffer + length, "%s:", type[i]);
17031 + for (j = 0; j < 3; j++) {
17032 + length += sprintf(buffer + length,
17033 + "\t%10lu/%-10lu",
17034 + vx_sock_count(cacct, i, j),
17035 + vx_sock_total(cacct, i, j));
17037 + buffer[length++] = '\n';
17040 + length += sprintf(buffer + length, "\n");
17041 + length += sprintf(buffer + length,
17042 + "slab:\t %8u %8u %8u %8u\n",
17043 + atomic_read(&cacct->slab[1]),
17044 + atomic_read(&cacct->slab[4]),
17045 + atomic_read(&cacct->slab[0]),
17046 + atomic_read(&cacct->slab[2]));
17048 + length += sprintf(buffer + length, "\n");
17049 + for (i = 0; i < 5; i++) {
17050 + length += sprintf(buffer + length,
17051 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17052 + atomic_read(&cacct->page[i][0]),
17053 + atomic_read(&cacct->page[i][1]),
17054 + atomic_read(&cacct->page[i][2]),
17055 + atomic_read(&cacct->page[i][3]),
17056 + atomic_read(&cacct->page[i][4]),
17057 + atomic_read(&cacct->page[i][5]),
17058 + atomic_read(&cacct->page[i][6]),
17059 + atomic_read(&cacct->page[i][7]));
17064 +#endif /* _VX_CACCT_PROC_H */
17065 diff -NurpP --minimal linux-2.6.29/kernel/vserver/context.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/context.c
17066 --- linux-2.6.29/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17067 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/context.c 2009-03-31 22:25:17.000000000 +0200
17070 + * linux/kernel/vserver/context.c
17072 + * Virtual Server: Context Support
17074 + * Copyright (C) 2003-2007 Herbert Pötzl
17076 + * V0.01 context helper
17077 + * V0.02 vx_ctx_kill syscall command
17078 + * V0.03 replaced context_info calls
17079 + * V0.04 redesign of struct (de)alloc
17080 + * V0.05 rlimit basic implementation
17081 + * V0.06 task_xid and info commands
17082 + * V0.07 context flags and caps
17083 + * V0.08 switch to RCU based hash
17084 + * V0.09 revert to non RCU for now
17085 + * V0.10 and back to working RCU hash
17086 + * V0.11 and back to locking again
17087 + * V0.12 referenced context store
17088 + * V0.13 separate per cpu data
17089 + * V0.14 changed vcmds to vxi arg
17090 + * V0.15 added context stat
17091 + * V0.16 have __create claim() the vxi
17092 + * V0.17 removed older and legacy stuff
17096 +#include <linux/slab.h>
17097 +#include <linux/types.h>
17098 +#include <linux/security.h>
17099 +#include <linux/pid_namespace.h>
17101 +#include <linux/vserver/context.h>
17102 +#include <linux/vserver/network.h>
17103 +#include <linux/vserver/debug.h>
17104 +#include <linux/vserver/limit.h>
17105 +#include <linux/vserver/limit_int.h>
17106 +#include <linux/vserver/space.h>
17108 +#include <linux/vs_context.h>
17109 +#include <linux/vs_limit.h>
17110 +#include <linux/vs_pid.h>
17111 +#include <linux/vserver/context_cmd.h>
17113 +#include "cvirt_init.h"
17114 +#include "cacct_init.h"
17115 +#include "limit_init.h"
17116 +#include "sched_init.h"
17119 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17120 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17123 +/* now inactive context structures */
17125 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17127 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17130 +/* __alloc_vx_info()
17132 + * allocate an initialized vx_info struct
17133 + * doesn't make it visible (hash) */
17135 +static struct vx_info *__alloc_vx_info(xid_t xid)
17137 + struct vx_info *new = NULL;
17140 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17142 + /* would this benefit from a slab cache? */
17143 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17147 + memset(new, 0, sizeof(struct vx_info));
17149 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17150 + if (!new->ptr_pc)
17153 + new->vx_id = xid;
17154 + INIT_HLIST_NODE(&new->vx_hlist);
17155 + atomic_set(&new->vx_usecnt, 0);
17156 + atomic_set(&new->vx_tasks, 0);
17157 + new->vx_parent = NULL;
17158 + new->vx_state = 0;
17159 + init_waitqueue_head(&new->vx_wait);
17161 + /* prepare reaper */
17162 + get_task_struct(init_pid_ns.child_reaper);
17163 + new->vx_reaper = init_pid_ns.child_reaper;
17164 + new->vx_badness_bias = 0;
17166 + /* rest of init goes here */
17167 + vx_info_init_limit(&new->limit);
17168 + vx_info_init_sched(&new->sched);
17169 + vx_info_init_cvirt(&new->cvirt);
17170 + vx_info_init_cacct(&new->cacct);
17172 + /* per cpu data structures */
17173 + for_each_possible_cpu(cpu) {
17174 + vx_info_init_sched_pc(
17175 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17176 + vx_info_init_cvirt_pc(
17177 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17180 + new->vx_flags = VXF_INIT_SET;
17181 + cap_set_init_eff(new->vx_bcaps);
17182 + new->vx_ccaps = 0;
17183 + // new->vx_cap_bset = current->cap_bset;
17185 + new->reboot_cmd = 0;
17186 + new->exit_code = 0;
17188 + vxdprintk(VXD_CBIT(xid, 0),
17189 + "alloc_vx_info(%d) = %p", xid, new);
17190 + vxh_alloc_vx_info(new);
17191 + atomic_inc(&vx_global_ctotal);
17200 +/* __dealloc_vx_info()
17202 + * final disposal of vx_info */
17204 +static void __dealloc_vx_info(struct vx_info *vxi)
17206 + struct vx_info_save vxis;
17209 + vxdprintk(VXD_CBIT(xid, 0),
17210 + "dealloc_vx_info(%p)", vxi);
17211 + vxh_dealloc_vx_info(vxi);
17213 +#ifdef CONFIG_VSERVER_WARN
17214 + enter_vx_info(vxi, &vxis);
17215 + vx_info_exit_limit(&vxi->limit);
17216 + vx_info_exit_sched(&vxi->sched);
17217 + vx_info_exit_cvirt(&vxi->cvirt);
17218 + vx_info_exit_cacct(&vxi->cacct);
17220 + for_each_possible_cpu(cpu) {
17221 + vx_info_exit_sched_pc(
17222 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17223 + vx_info_exit_cvirt_pc(
17224 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17226 + leave_vx_info(&vxis);
17230 + vxi->vx_state |= VXS_RELEASED;
17233 + free_percpu(vxi->ptr_pc);
17236 + atomic_dec(&vx_global_ctotal);
17239 +static void __shutdown_vx_info(struct vx_info *vxi)
17241 + struct nsproxy *nsproxy;
17242 + struct fs_struct *fs;
17247 + vxi->vx_state |= VXS_SHUTDOWN;
17248 + vs_state_change(vxi, VSC_SHUTDOWN);
17250 + for (index = 0; index < VX_SPACES; index++) {
17251 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17253 + put_nsproxy(nsproxy);
17255 + fs = xchg(&vxi->vx_fs[index], NULL);
17257 + put_fs_struct(fs);
17261 +/* exported stuff */
17263 +void free_vx_info(struct vx_info *vxi)
17265 + unsigned long flags;
17268 + /* check for reference counts first */
17269 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17270 + BUG_ON(atomic_read(&vxi->vx_tasks));
17272 + /* context must not be hashed */
17273 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17275 + /* context shutdown is mandatory */
17276 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17278 + /* nsproxy and fs check */
17279 + for (index = 0; index < VX_SPACES; index++) {
17280 + BUG_ON(vxi->vx_nsproxy[index]);
17281 + BUG_ON(vxi->vx_fs[index]);
17284 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17285 + hlist_del(&vxi->vx_hlist);
17286 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17288 + __dealloc_vx_info(vxi);
17292 +/* hash table for vx_info hash */
17294 +#define VX_HASH_SIZE 13
17296 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17297 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17299 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17302 +static inline unsigned int __hashval(xid_t xid)
17304 + return (xid % VX_HASH_SIZE);
17309 +/* __hash_vx_info()
17311 + * add the vxi to the global hash table
17312 + * requires the hash_lock to be held */
17314 +static inline void __hash_vx_info(struct vx_info *vxi)
17316 + struct hlist_head *head;
17318 + vxd_assert_lock(&vx_info_hash_lock);
17319 + vxdprintk(VXD_CBIT(xid, 4),
17320 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17321 + vxh_hash_vx_info(vxi);
17323 + /* context must not be hashed */
17324 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17326 + vxi->vx_state |= VXS_HASHED;
17327 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17328 + hlist_add_head(&vxi->vx_hlist, head);
17329 + atomic_inc(&vx_global_cactive);
17332 +/* __unhash_vx_info()
17334 + * remove the vxi from the global hash table
17335 + * requires the hash_lock to be held */
17337 +static inline void __unhash_vx_info(struct vx_info *vxi)
17339 + unsigned long flags;
17341 + vxd_assert_lock(&vx_info_hash_lock);
17342 + vxdprintk(VXD_CBIT(xid, 4),
17343 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17344 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17345 + vxh_unhash_vx_info(vxi);
17347 + /* context must be hashed */
17348 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17349 + /* but without tasks */
17350 + BUG_ON(atomic_read(&vxi->vx_tasks));
17352 + vxi->vx_state &= ~VXS_HASHED;
17353 + hlist_del_init(&vxi->vx_hlist);
17354 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17355 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17356 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17357 + atomic_dec(&vx_global_cactive);
17361 +/* __lookup_vx_info()
17363 + * requires the hash_lock to be held
17364 + * doesn't increment the vx_refcnt */
17366 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17368 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17369 + struct hlist_node *pos;
17370 + struct vx_info *vxi;
17372 + vxd_assert_lock(&vx_info_hash_lock);
17373 + hlist_for_each(pos, head) {
17374 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17376 + if (vxi->vx_id == xid)
17381 + vxdprintk(VXD_CBIT(xid, 0),
17382 + "__lookup_vx_info(#%u): %p[#%u]",
17383 + xid, vxi, vxi ? vxi->vx_id : 0);
17384 + vxh_lookup_vx_info(vxi, xid);
17389 +/* __create_vx_info()
17391 + * create the requested context
17392 + * get(), claim() and hash it */
17394 +static struct vx_info *__create_vx_info(int id)
17396 + struct vx_info *new, *vxi = NULL;
17398 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17400 + if (!(new = __alloc_vx_info(id)))
17401 + return ERR_PTR(-ENOMEM);
17403 + /* required to make dynamic xids unique */
17404 + spin_lock(&vx_info_hash_lock);
17406 + /* static context requested */
17407 + if ((vxi = __lookup_vx_info(id))) {
17408 + vxdprintk(VXD_CBIT(xid, 0),
17409 + "create_vx_info(%d) = %p (already there)", id, vxi);
17410 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17411 + vxi = ERR_PTR(-EBUSY);
17413 + vxi = ERR_PTR(-EEXIST);
17416 + /* new context */
17417 + vxdprintk(VXD_CBIT(xid, 0),
17418 + "create_vx_info(%d) = %p (new)", id, new);
17419 + claim_vx_info(new, NULL);
17420 + __hash_vx_info(get_vx_info(new));
17421 + vxi = new, new = NULL;
17424 + spin_unlock(&vx_info_hash_lock);
17425 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17427 + __dealloc_vx_info(new);
17432 +/* exported stuff */
17435 +void unhash_vx_info(struct vx_info *vxi)
17437 + __shutdown_vx_info(vxi);
17438 + spin_lock(&vx_info_hash_lock);
17439 + __unhash_vx_info(vxi);
17440 + spin_unlock(&vx_info_hash_lock);
17441 + __wakeup_vx_info(vxi);
17445 +/* lookup_vx_info()
17447 + * search for a vx_info and get() it
17448 + * negative id means current */
17450 +struct vx_info *lookup_vx_info(int id)
17452 + struct vx_info *vxi = NULL;
17455 + vxi = get_vx_info(current->vx_info);
17456 + } else if (id > 1) {
17457 + spin_lock(&vx_info_hash_lock);
17458 + vxi = get_vx_info(__lookup_vx_info(id));
17459 + spin_unlock(&vx_info_hash_lock);
17464 +/* xid_is_hashed()
17466 + * verify that xid is still hashed */
17468 +int xid_is_hashed(xid_t xid)
17472 + spin_lock(&vx_info_hash_lock);
17473 + hashed = (__lookup_vx_info(xid) != NULL);
17474 + spin_unlock(&vx_info_hash_lock);
17478 +#ifdef CONFIG_PROC_FS
17482 + * get a subset of hashed xids for proc
17483 + * assumes size is at least one */
17485 +int get_xid_list(int index, unsigned int *xids, int size)
17487 + int hindex, nr_xids = 0;
17489 + /* only show current and children */
17490 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
17493 + xids[nr_xids] = vx_current_xid();
17497 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
17498 + struct hlist_head *head = &vx_info_hash[hindex];
17499 + struct hlist_node *pos;
17501 + spin_lock(&vx_info_hash_lock);
17502 + hlist_for_each(pos, head) {
17503 + struct vx_info *vxi;
17508 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17509 + xids[nr_xids] = vxi->vx_id;
17510 + if (++nr_xids >= size) {
17511 + spin_unlock(&vx_info_hash_lock);
17515 + /* keep the lock time short */
17516 + spin_unlock(&vx_info_hash_lock);
17523 +#ifdef CONFIG_VSERVER_DEBUG
17525 +void dump_vx_info_inactive(int level)
17527 + struct hlist_node *entry, *next;
17529 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
17530 + struct vx_info *vxi =
17531 + list_entry(entry, struct vx_info, vx_hlist);
17533 + dump_vx_info(vxi, level);
17540 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
17542 + struct user_struct *new_user, *old_user;
17547 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
17550 + new_user = alloc_uid(vxi->vx_id, p->uid);
17554 + old_user = p->user;
17555 + if (new_user != old_user) {
17556 + atomic_inc(&new_user->processes);
17557 + atomic_dec(&old_user->processes);
17558 + p->user = new_user;
17560 + free_uid(old_user);
17566 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
17568 + // p->cap_effective &= vxi->vx_cap_bset;
17569 + p->cap_effective =
17570 + cap_intersect(p->cap_effective, vxi->cap_bset);
17571 + // p->cap_inheritable &= vxi->vx_cap_bset;
17572 + p->cap_inheritable =
17573 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
17574 + // p->cap_permitted &= vxi->vx_cap_bset;
17575 + p->cap_permitted =
17576 + cap_intersect(p->cap_permitted, vxi->cap_bset);
17581 +#include <linux/file.h>
17582 +#include <linux/fdtable.h>
17584 +static int vx_openfd_task(struct task_struct *tsk)
17586 + struct files_struct *files = tsk->files;
17587 + struct fdtable *fdt;
17588 + const unsigned long *bptr;
17589 + int count, total;
17591 + /* no rcu_read_lock() because of spin_lock() */
17592 + spin_lock(&files->file_lock);
17593 + fdt = files_fdtable(files);
17594 + bptr = fdt->open_fds->fds_bits;
17595 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
17596 + for (total = 0; count > 0; count--) {
17598 + total += hweight_long(*bptr);
17601 + spin_unlock(&files->file_lock);
17606 +/* for *space compatibility */
17608 +asmlinkage long sys_unshare(unsigned long);
17611 + * migrate task to new context
17612 + * gets vxi, puts old_vxi on change
17613 + * optionally unshares namespaces (hack)
17616 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17618 + struct vx_info *old_vxi;
17624 + vxdprintk(VXD_CBIT(xid, 5),
17625 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17626 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17628 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17629 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17632 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17635 + old_vxi = task_get_vx_info(p);
17636 + if (old_vxi == vxi)
17639 +// if (!(ret = vx_migrate_user(p, vxi))) {
17644 + openfd = vx_openfd_task(p);
17647 + atomic_dec(&old_vxi->cvirt.nr_threads);
17648 + atomic_dec(&old_vxi->cvirt.nr_running);
17649 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17650 + /* FIXME: what about the struct files here? */
17651 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17652 + /* account for the executable */
17653 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17655 + atomic_inc(&vxi->cvirt.nr_threads);
17656 + atomic_inc(&vxi->cvirt.nr_running);
17657 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17658 + /* FIXME: what about the struct files here? */
17659 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17660 + /* account for the executable */
17661 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17664 + release_vx_info(old_vxi, p);
17665 + clr_vx_info(&p->vx_info);
17667 + claim_vx_info(vxi, p);
17668 + set_vx_info(&p->vx_info, vxi);
17669 + p->xid = vxi->vx_id;
17671 + vxdprintk(VXD_CBIT(xid, 5),
17672 + "moved task %p into vxi:%p[#%d]",
17673 + p, vxi, vxi->vx_id);
17675 + // vx_mask_cap_bset(vxi, p);
17678 + /* hack for *spaces to provide compatibility */
17680 + struct nsproxy *old_nsp, *new_nsp;
17682 + ret = unshare_nsproxy_namespaces(
17683 + CLONE_NEWUTS | CLONE_NEWIPC,
17688 + old_nsp = xchg(&p->nsproxy, new_nsp);
17689 + vx_set_space(vxi,
17690 + CLONE_NEWUTS | CLONE_NEWIPC, 0);
17691 + put_nsproxy(old_nsp);
17695 + put_vx_info(old_vxi);
17699 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17701 + struct task_struct *old_reaper;
17706 + vxdprintk(VXD_CBIT(xid, 6),
17707 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17708 + vxi, vxi->vx_id, p, p->xid, p->pid);
17710 + old_reaper = vxi->vx_reaper;
17711 + if (old_reaper == p)
17714 + /* set new child reaper */
17715 + get_task_struct(p);
17716 + vxi->vx_reaper = p;
17717 + put_task_struct(old_reaper);
17721 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17726 + vxdprintk(VXD_CBIT(xid, 6),
17727 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17728 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17730 + vxi->vx_flags &= ~VXF_STATE_INIT;
17731 + vxi->vx_initpid = p->tgid;
17735 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17737 + vxdprintk(VXD_CBIT(xid, 6),
17738 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17739 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17741 + vxi->exit_code = code;
17742 + vxi->vx_initpid = 0;
17746 +void vx_set_persistent(struct vx_info *vxi)
17748 + vxdprintk(VXD_CBIT(xid, 6),
17749 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
17751 + get_vx_info(vxi);
17752 + claim_vx_info(vxi, NULL);
17755 +void vx_clear_persistent(struct vx_info *vxi)
17757 + vxdprintk(VXD_CBIT(xid, 6),
17758 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
17760 + release_vx_info(vxi, NULL);
17761 + put_vx_info(vxi);
17764 +void vx_update_persistent(struct vx_info *vxi)
17766 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
17767 + vx_set_persistent(vxi);
17769 + vx_clear_persistent(vxi);
17773 +/* task must be current or locked */
17775 +void exit_vx_info(struct task_struct *p, int code)
17777 + struct vx_info *vxi = p->vx_info;
17780 + atomic_dec(&vxi->cvirt.nr_threads);
17783 + vxi->exit_code = code;
17784 + release_vx_info(vxi, p);
17788 +void exit_vx_info_early(struct task_struct *p, int code)
17790 + struct vx_info *vxi = p->vx_info;
17793 + if (vxi->vx_initpid == p->tgid)
17794 + vx_exit_init(vxi, p, code);
17795 + if (vxi->vx_reaper == p)
17796 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
17801 +/* vserver syscall commands below here */
17803 +/* taks xid and vx_info functions */
17805 +#include <asm/uaccess.h>
17808 +int vc_task_xid(uint32_t id)
17813 + struct task_struct *tsk;
17815 + read_lock(&tasklist_lock);
17816 + tsk = find_task_by_real_pid(id);
17817 + xid = (tsk) ? tsk->xid : -ESRCH;
17818 + read_unlock(&tasklist_lock);
17820 + xid = vx_current_xid();
17825 +int vc_vx_info(struct vx_info *vxi, void __user *data)
17827 + struct vcmd_vx_info_v0 vc_data;
17829 + vc_data.xid = vxi->vx_id;
17830 + vc_data.initpid = vxi->vx_initpid;
17832 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17838 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
17840 + struct vcmd_ctx_stat_v0 vc_data;
17842 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
17843 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
17845 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17851 +/* context functions */
17853 +int vc_ctx_create(uint32_t xid, void __user *data)
17855 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
17856 + struct vx_info *new_vxi;
17859 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17862 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
17865 + new_vxi = __create_vx_info(xid);
17866 + if (IS_ERR(new_vxi))
17867 + return PTR_ERR(new_vxi);
17869 + /* initial flags */
17870 + new_vxi->vx_flags = vc_data.flagword;
17873 + if (vs_state_change(new_vxi, VSC_STARTUP))
17876 + ret = vx_migrate_task(current, new_vxi, (!data));
17880 + /* return context id on success */
17881 + ret = new_vxi->vx_id;
17883 + /* get a reference for persistent contexts */
17884 + if ((vc_data.flagword & VXF_PERSISTENT))
17885 + vx_set_persistent(new_vxi);
17887 + release_vx_info(new_vxi, NULL);
17888 + put_vx_info(new_vxi);
17893 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17895 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17898 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17901 + ret = vx_migrate_task(current, vxi, 0);
17904 + if (vc_data.flagword & VXM_SET_INIT)
17905 + ret = vx_set_init(vxi, current);
17908 + if (vc_data.flagword & VXM_SET_REAPER)
17909 + ret = vx_set_reaper(vxi, current);
17914 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17916 + struct vcmd_ctx_flags_v0 vc_data;
17918 + vc_data.flagword = vxi->vx_flags;
17920 + /* special STATE flag handling */
17921 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17923 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17928 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17930 + struct vcmd_ctx_flags_v0 vc_data;
17931 + uint64_t mask, trigger;
17933 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17936 + /* special STATE flag handling */
17937 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17938 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17940 + if (vxi == current->vx_info) {
17941 + /* if (trigger & VXF_STATE_SETUP)
17942 + vx_mask_cap_bset(vxi, current); */
17943 + if (trigger & VXF_STATE_INIT) {
17946 + ret = vx_set_init(vxi, current);
17949 + ret = vx_set_reaper(vxi, current);
17955 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17956 + vc_data.flagword, mask);
17957 + if (trigger & VXF_PERSISTENT)
17958 + vx_update_persistent(vxi);
17964 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17966 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17968 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17972 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17974 + kernel_cap_t c = __cap_empty_set;
17976 + c.cap[0] = v & 0xFFFFFFFF;
17977 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17979 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17984 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17987 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17989 + *ccaps = vxi->vx_ccaps;
17994 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17996 + struct vcmd_ctx_caps_v1 vc_data;
17999 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18002 + vc_data.cmask = ~0ULL;
18004 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18009 +static int do_set_caps(struct vx_info *vxi,
18010 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18012 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18015 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18016 + bcaps, bmask, ccaps, cmask);
18018 + vxi->vx_bcaps = cap_t_from_caps(
18019 + vs_mask_flags(bcold, bcaps, bmask));
18020 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18025 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18027 + struct vcmd_ctx_caps_v1 vc_data;
18029 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18032 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18035 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18037 + struct vcmd_bcaps vc_data;
18040 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18043 + vc_data.bmask = ~0ULL;
18045 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18050 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18052 + struct vcmd_bcaps vc_data;
18054 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18057 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18061 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18063 + struct vcmd_badness_v0 vc_data;
18065 + vc_data.bias = vxi->vx_badness_bias;
18067 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18072 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18074 + struct vcmd_badness_v0 vc_data;
18076 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18079 + vxi->vx_badness_bias = vc_data.bias;
18083 +#include <linux/module.h>
18085 +EXPORT_SYMBOL_GPL(free_vx_info);
18087 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cvirt.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cvirt.c
18088 --- linux-2.6.29/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18089 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cvirt.c 2009-02-22 22:54:26.000000000 +0100
18092 + * linux/kernel/vserver/cvirt.c
18094 + * Virtual Server: Context Virtualization
18096 + * Copyright (C) 2004-2007 Herbert Pötzl
18098 + * V0.01 broken out from limit.c
18099 + * V0.02 added utsname stuff
18100 + * V0.03 changed vcmds to vxi arg
18104 +#include <linux/types.h>
18105 +#include <linux/utsname.h>
18106 +#include <linux/vs_cvirt.h>
18107 +#include <linux/vserver/switch.h>
18108 +#include <linux/vserver/cvirt_cmd.h>
18110 +#include <asm/uaccess.h>
18113 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18115 + struct vx_info *vxi = current->vx_info;
18117 + set_normalized_timespec(uptime,
18118 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18119 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18122 + set_normalized_timespec(idle,
18123 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18124 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18128 +uint64_t vx_idle_jiffies(void)
18130 + return init_task.utime + init_task.stime;
18135 +static inline uint32_t __update_loadavg(uint32_t load,
18136 + int wsize, int delta, int n)
18138 + unsigned long long calc, prev;
18140 + /* just set it to n */
18141 + if (unlikely(delta >= wsize))
18142 + return (n << FSHIFT);
18144 + calc = delta * n;
18146 + prev = (wsize - delta);
18149 + do_div(calc, wsize);
18154 +void vx_update_load(struct vx_info *vxi)
18156 + uint32_t now, last, delta;
18157 + unsigned int nr_running, nr_uninterruptible;
18158 + unsigned int total;
18159 + unsigned long flags;
18161 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18164 + last = vxi->cvirt.load_last;
18165 + delta = now - last;
18167 + if (delta < 5*HZ)
18170 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18171 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18172 + total = nr_running + nr_uninterruptible;
18174 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18175 + 60*HZ, delta, total);
18176 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18177 + 5*60*HZ, delta, total);
18178 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18179 + 15*60*HZ, delta, total);
18181 + vxi->cvirt.load_last = now;
18183 + atomic_inc(&vxi->cvirt.load_updates);
18184 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18189 + * Commands to do_syslog:
18191 + * 0 -- Close the log. Currently a NOP.
18192 + * 1 -- Open the log. Currently a NOP.
18193 + * 2 -- Read from the log.
18194 + * 3 -- Read all messages remaining in the ring buffer.
18195 + * 4 -- Read and clear all messages remaining in the ring buffer
18196 + * 5 -- Clear ring buffer.
18197 + * 6 -- Disable printk's to console
18198 + * 7 -- Enable printk's to console
18199 + * 8 -- Set level of messages printed to console
18200 + * 9 -- Return number of unread characters in the log buffer
18201 + * 10 -- Return size of the log buffer
18203 +int vx_do_syslog(int type, char __user *buf, int len)
18206 + int do_clear = 0;
18207 + struct vx_info *vxi = current->vx_info;
18208 + struct _vx_syslog *log;
18212 + log = &vxi->cvirt.syslog;
18215 + case 0: /* Close log */
18216 + case 1: /* Open log */
18218 + case 2: /* Read from log */
18219 + error = wait_event_interruptible(log->log_wait,
18220 + (log->log_start - log->log_end));
18223 + spin_lock_irq(&log->logbuf_lock);
18224 + spin_unlock_irq(&log->logbuf_lock);
18226 + case 4: /* Read/clear last kernel messages */
18228 + /* fall through */
18229 + case 3: /* Read last kernel messages */
18232 + case 5: /* Clear ring buffer */
18235 + case 6: /* Disable logging to console */
18236 + case 7: /* Enable logging to console */
18237 + case 8: /* Set level of messages printed to console */
18240 + case 9: /* Number of chars in the log buffer */
18242 + case 10: /* Size of the log buffer */
18252 +/* virtual host info names */
18254 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18256 + struct nsproxy *nsproxy;
18257 + struct uts_namespace *uts;
18259 + if (id == VHIN_CONTEXT)
18260 + return vxi->vx_name;
18262 + nsproxy = vxi->vx_nsproxy[0];
18266 + uts = nsproxy->uts_ns;
18271 + case VHIN_SYSNAME:
18272 + return uts->name.sysname;
18273 + case VHIN_NODENAME:
18274 + return uts->name.nodename;
18275 + case VHIN_RELEASE:
18276 + return uts->name.release;
18277 + case VHIN_VERSION:
18278 + return uts->name.version;
18279 + case VHIN_MACHINE:
18280 + return uts->name.machine;
18281 + case VHIN_DOMAINNAME:
18282 + return uts->name.domainname;
18289 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18291 + struct vcmd_vhi_name_v0 vc_data;
18294 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18297 + name = vx_vhi_name(vxi, vc_data.field);
18301 + memcpy(name, vc_data.name, 65);
18305 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18307 + struct vcmd_vhi_name_v0 vc_data;
18310 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18313 + name = vx_vhi_name(vxi, vc_data.field);
18317 + memcpy(vc_data.name, name, 65);
18318 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18324 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18326 + struct vcmd_virt_stat_v0 vc_data;
18327 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18328 + struct timespec uptime;
18330 + do_posix_clock_monotonic_gettime(&uptime);
18331 + set_normalized_timespec(&uptime,
18332 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18333 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18335 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18336 + vc_data.uptime = timespec_to_ns(&uptime);
18337 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18338 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18339 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18340 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18341 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18342 + vc_data.load[0] = cvirt->load[0];
18343 + vc_data.load[1] = cvirt->load[1];
18344 + vc_data.load[2] = cvirt->load[2];
18346 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18352 +#ifdef CONFIG_VSERVER_VTIME
18354 +/* virtualized time base */
18356 +void vx_gettimeofday(struct timeval *tv)
18358 + do_gettimeofday(tv);
18359 + if (!vx_flags(VXF_VIRT_TIME, 0))
18362 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
18363 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
18365 + if (tv->tv_usec >= USEC_PER_SEC) {
18367 + tv->tv_usec -= USEC_PER_SEC;
18368 + } else if (tv->tv_usec < 0) {
18370 + tv->tv_usec += USEC_PER_SEC;
18374 +int vx_settimeofday(struct timespec *ts)
18376 + struct timeval tv;
18378 + if (!vx_flags(VXF_VIRT_TIME, 0))
18379 + return do_settimeofday(ts);
18381 + do_gettimeofday(&tv);
18382 + current->vx_info->cvirt.bias_tv.tv_sec =
18383 + ts->tv_sec - tv.tv_sec;
18384 + current->vx_info->cvirt.bias_tv.tv_usec =
18385 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18391 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cvirt_init.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cvirt_init.h
18392 --- linux-2.6.29/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
18393 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cvirt_init.h 2009-02-22 22:54:26.000000000 +0100
18397 +extern uint64_t vx_idle_jiffies(void);
18399 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18401 + uint64_t idle_jiffies = vx_idle_jiffies();
18402 + uint64_t nsuptime;
18404 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18405 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18406 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18407 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18408 + cvirt->bias_tv.tv_sec = 0;
18409 + cvirt->bias_tv.tv_usec = 0;
18411 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
18412 + atomic_set(&cvirt->nr_threads, 0);
18413 + atomic_set(&cvirt->nr_running, 0);
18414 + atomic_set(&cvirt->nr_uninterruptible, 0);
18415 + atomic_set(&cvirt->nr_onhold, 0);
18417 + spin_lock_init(&cvirt->load_lock);
18418 + cvirt->load_last = jiffies;
18419 + atomic_set(&cvirt->load_updates, 0);
18420 + cvirt->load[0] = 0;
18421 + cvirt->load[1] = 0;
18422 + cvirt->load[2] = 0;
18423 + atomic_set(&cvirt->total_forks, 0);
18425 + spin_lock_init(&cvirt->syslog.logbuf_lock);
18426 + init_waitqueue_head(&cvirt->syslog.log_wait);
18427 + cvirt->syslog.log_start = 0;
18428 + cvirt->syslog.log_end = 0;
18429 + cvirt->syslog.con_start = 0;
18430 + cvirt->syslog.logged_chars = 0;
18434 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18436 + // cvirt_pc->cpustat = { 0 };
18439 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
18443 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
18444 + "!!! cvirt: %p[nr_threads] = %d on exit.",
18446 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
18447 + "!!! cvirt: %p[nr_running] = %d on exit.",
18449 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
18450 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
18452 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
18453 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
18459 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18464 diff -NurpP --minimal linux-2.6.29/kernel/vserver/cvirt_proc.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cvirt_proc.h
18465 --- linux-2.6.29/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
18466 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/cvirt_proc.h 2009-02-22 22:54:26.000000000 +0100
18468 +#ifndef _VX_CVIRT_PROC_H
18469 +#define _VX_CVIRT_PROC_H
18471 +#include <linux/nsproxy.h>
18472 +#include <linux/mnt_namespace.h>
18473 +#include <linux/ipc_namespace.h>
18474 +#include <linux/utsname.h>
18475 +#include <linux/ipc.h>
18479 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
18481 + struct mnt_namespace *ns;
18482 + struct uts_namespace *uts;
18483 + struct ipc_namespace *ipc;
18484 + struct path path;
18485 + char *pstr, *root;
18491 + length += sprintf(buffer + length,
18492 + "NSProxy:\t%p [%p,%p,%p]\n",
18493 + nsproxy, nsproxy->mnt_ns,
18494 + nsproxy->uts_ns, nsproxy->ipc_ns);
18496 + ns = nsproxy->mnt_ns;
18500 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
18504 + path.mnt = ns->root;
18505 + path.dentry = ns->root->mnt_root;
18506 + root = d_path(&path, pstr, PATH_MAX - 2);
18507 + length += sprintf(buffer + length,
18508 + "Namespace:\t%p [#%u]\n"
18509 + "RootPath:\t%s\n",
18510 + ns, atomic_read(&ns->count),
18515 + uts = nsproxy->uts_ns;
18519 + length += sprintf(buffer + length,
18520 + "SysName:\t%.*s\n"
18521 + "NodeName:\t%.*s\n"
18522 + "Release:\t%.*s\n"
18523 + "Version:\t%.*s\n"
18524 + "Machine:\t%.*s\n"
18525 + "DomainName:\t%.*s\n",
18526 + __NEW_UTS_LEN, uts->name.sysname,
18527 + __NEW_UTS_LEN, uts->name.nodename,
18528 + __NEW_UTS_LEN, uts->name.release,
18529 + __NEW_UTS_LEN, uts->name.version,
18530 + __NEW_UTS_LEN, uts->name.machine,
18531 + __NEW_UTS_LEN, uts->name.domainname);
18534 + ipc = nsproxy->ipc_ns;
18538 + length += sprintf(buffer + length,
18539 + "SEMS:\t\t%d %d %d %d %d\n"
18540 + "MSG:\t\t%d %d %d\n"
18541 + "SHM:\t\t%lu %lu %d %d\n",
18542 + ipc->sem_ctls[0], ipc->sem_ctls[1],
18543 + ipc->sem_ctls[2], ipc->sem_ctls[3],
18545 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
18546 + (unsigned long)ipc->shm_ctlmax,
18547 + (unsigned long)ipc->shm_ctlall,
18548 + ipc->shm_ctlmni, ipc->shm_tot);
18555 +#include <linux/sched.h>
18557 +#define LOAD_INT(x) ((x) >> FSHIFT)
18558 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18561 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18566 + length += sprintf(buffer + length,
18567 + "BiasUptime:\t%lu.%02lu\n",
18568 + (unsigned long)cvirt->bias_uptime.tv_sec,
18569 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18571 + a = cvirt->load[0] + (FIXED_1 / 200);
18572 + b = cvirt->load[1] + (FIXED_1 / 200);
18573 + c = cvirt->load[2] + (FIXED_1 / 200);
18574 + length += sprintf(buffer + length,
18575 + "nr_threads:\t%d\n"
18576 + "nr_running:\t%d\n"
18577 + "nr_unintr:\t%d\n"
18578 + "nr_onhold:\t%d\n"
18579 + "load_updates:\t%d\n"
18580 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18581 + "total_forks:\t%d\n",
18582 + atomic_read(&cvirt->nr_threads),
18583 + atomic_read(&cvirt->nr_running),
18584 + atomic_read(&cvirt->nr_uninterruptible),
18585 + atomic_read(&cvirt->nr_onhold),
18586 + atomic_read(&cvirt->load_updates),
18587 + LOAD_INT(a), LOAD_FRAC(a),
18588 + LOAD_INT(b), LOAD_FRAC(b),
18589 + LOAD_INT(c), LOAD_FRAC(c),
18590 + atomic_read(&cvirt->total_forks));
18595 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18596 + char *buffer, int cpu)
18602 +#endif /* _VX_CVIRT_PROC_H */
18603 diff -NurpP --minimal linux-2.6.29/kernel/vserver/debug.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/debug.c
18604 --- linux-2.6.29/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18605 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/debug.c 2009-02-22 22:54:26.000000000 +0100
18608 + * kernel/vserver/debug.c
18610 + * Copyright (C) 2005-2007 Herbert Pötzl
18612 + * V0.01 vx_info dump support
18616 +#include <linux/module.h>
18618 +#include <linux/vserver/context.h>
18621 +void dump_vx_info(struct vx_info *vxi, int level)
18623 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18624 + atomic_read(&vxi->vx_usecnt),
18625 + atomic_read(&vxi->vx_tasks),
18628 + __dump_vx_limit(&vxi->limit);
18629 + __dump_vx_sched(&vxi->sched);
18630 + __dump_vx_cvirt(&vxi->cvirt);
18631 + __dump_vx_cacct(&vxi->cacct);
18637 +EXPORT_SYMBOL_GPL(dump_vx_info);
18639 diff -NurpP --minimal linux-2.6.29/kernel/vserver/device.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/device.c
18640 --- linux-2.6.29/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18641 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/device.c 2009-02-22 22:54:26.000000000 +0100
18644 + * linux/kernel/vserver/device.c
18646 + * Linux-VServer: Device Support
18648 + * Copyright (C) 2006 Herbert Pötzl
18649 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18651 + * V0.01 device mapping basics
18652 + * V0.02 added defaults
18656 +#include <linux/slab.h>
18657 +#include <linux/rcupdate.h>
18658 +#include <linux/fs.h>
18659 +#include <linux/namei.h>
18660 +#include <linux/hash.h>
18662 +#include <asm/errno.h>
18663 +#include <asm/uaccess.h>
18664 +#include <linux/vserver/base.h>
18665 +#include <linux/vserver/debug.h>
18666 +#include <linux/vserver/context.h>
18667 +#include <linux/vserver/device.h>
18668 +#include <linux/vserver/device_cmd.h>
18671 +#define DMAP_HASH_BITS 4
18674 +struct vs_mapping {
18676 + struct hlist_node hlist;
18677 + struct list_head list;
18679 +#define dm_hlist u.hlist
18680 +#define dm_list u.list
18683 + struct vx_dmap_target target;
18687 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18689 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18691 +static struct vx_dmap_target dmap_defaults[2] = {
18692 + { .flags = DATTR_OPEN },
18693 + { .flags = DATTR_OPEN },
18697 +struct kmem_cache *dmap_cachep __read_mostly;
18699 +int __init dmap_cache_init(void)
18701 + dmap_cachep = kmem_cache_create("dmap_cache",
18702 + sizeof(struct vs_mapping), 0,
18703 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18707 +__initcall(dmap_cache_init);
18710 +static inline unsigned int __hashval(dev_t dev, int bits)
18712 + return hash_long((unsigned long)dev, bits);
18716 +/* __hash_mapping()
18717 + * add the mapping to the hash table
18719 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18721 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18722 + struct hlist_head *head, *hash = dmap_main_hash;
18723 + int device = vdm->device;
18725 + spin_lock(hash_lock);
18726 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18727 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18729 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18730 + hlist_add_head(&vdm->dm_hlist, head);
18731 + spin_unlock(hash_lock);
18735 +static inline int __mode_to_default(umode_t mode)
18748 +/* __set_default()
18751 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
18752 + struct vx_dmap_target *vdmt)
18754 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18755 + spin_lock(hash_lock);
18758 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
18760 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
18763 + spin_unlock(hash_lock);
18765 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
18766 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
18770 +/* __remove_default()
18771 + * remove a default
18773 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
18775 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18776 + spin_lock(hash_lock);
18779 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
18780 + else /* remove == reset */
18781 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
18783 + spin_unlock(hash_lock);
18788 +/* __find_mapping()
18789 + * find a mapping in the hash table
18791 + * caller must hold hash_lock
18793 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
18794 + struct vs_mapping **local, struct vs_mapping **global)
18796 + struct hlist_head *hash = dmap_main_hash;
18797 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
18798 + struct hlist_node *pos;
18799 + struct vs_mapping *vdm;
18805 + hlist_for_each(pos, head) {
18806 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
18808 + if ((vdm->device == device) &&
18809 + !((vdm->target.flags ^ mode) & S_IFMT)) {
18810 + if (vdm->xid == xid) {
18813 + } else if (global && vdm->xid == 0)
18818 + if (global && *global)
18825 +/* __lookup_mapping()
18826 + * find a mapping and store the result in target and flags
18828 +static inline int __lookup_mapping(struct vx_info *vxi,
18829 + dev_t device, dev_t *target, int *flags, umode_t mode)
18831 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18832 + struct vs_mapping *vdm, *global;
18833 + struct vx_dmap_target *vdmt;
18835 + xid_t xid = vxi->vx_id;
18838 + spin_lock(hash_lock);
18839 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18841 + vdmt = &vdm->target;
18845 + index = __mode_to_default(mode);
18846 + if (vxi && vxi->dmap.targets[index].flags) {
18848 + vdmt = &vxi->dmap.targets[index];
18849 + } else if (global) {
18851 + vdmt = &global->target;
18855 + vdmt = &dmap_defaults[index];
18859 + if (target && (vdmt->flags & DATTR_REMAP))
18860 + *target = vdmt->target;
18862 + *target = device;
18864 + *flags = vdmt->flags;
18866 + spin_unlock(hash_lock);
18872 +/* __remove_mapping()
18873 + * remove a mapping from the hash table
18875 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18878 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18879 + struct vs_mapping *vdm = NULL;
18882 + spin_lock(hash_lock);
18884 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18886 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18887 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18890 + hlist_del(&vdm->dm_hlist);
18893 + spin_unlock(hash_lock);
18895 + kmem_cache_free(dmap_cachep, vdm);
18901 +int vs_map_device(struct vx_info *vxi,
18902 + dev_t device, dev_t *target, umode_t mode)
18904 + int ret, flags = DATTR_MASK;
18908 + *target = device;
18911 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18912 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18913 + device, target ? *target : 0, flags, mode, ret);
18915 + return (flags & DATTR_MASK);
18920 +static int do_set_mapping(struct vx_info *vxi,
18921 + dev_t device, dev_t target, int flags, umode_t mode)
18924 + struct vs_mapping *new;
18926 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18930 + INIT_HLIST_NODE(&new->dm_hlist);
18931 + new->device = device;
18932 + new->target.target = target;
18933 + new->target.flags = flags | mode;
18934 + new->xid = (vxi ? vxi->vx_id : 0);
18936 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18937 + __hash_mapping(vxi, new);
18939 + struct vx_dmap_target new = {
18940 + .target = target,
18941 + .flags = flags | mode,
18943 + __set_default(vxi, mode, &new);
18949 +static int do_unset_mapping(struct vx_info *vxi,
18950 + dev_t device, dev_t target, int flags, umode_t mode)
18952 + int ret = -EINVAL;
18955 + ret = __remove_mapping(vxi, device, mode);
18959 + ret = __remove_default(vxi, mode);
18969 +static inline int __user_device(const char __user *name, dev_t *dev,
18972 + struct nameidata nd;
18979 + ret = user_lpath(name, &nd.path);
18982 + if (nd.path.dentry->d_inode) {
18983 + *dev = nd.path.dentry->d_inode->i_rdev;
18984 + *mode = nd.path.dentry->d_inode->i_mode;
18986 + path_put(&nd.path);
18990 +static inline int __mapping_mode(dev_t device, dev_t target,
18991 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18994 + *mode = device_mode & S_IFMT;
18996 + *mode = target_mode & S_IFMT;
19000 + /* if both given, device and target mode have to match */
19001 + if (device && target &&
19002 + ((device_mode ^ target_mode) & S_IFMT))
19008 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19009 + const char __user *target_path, int flags, int set)
19011 + dev_t device = ~0, target = ~0;
19012 + umode_t device_mode = 0, target_mode = 0, mode;
19015 + ret = __user_device(device_path, &device, &device_mode);
19018 + ret = __user_device(target_path, &target, &target_mode);
19022 + ret = __mapping_mode(device, target,
19023 + device_mode, target_mode, &mode);
19028 + return do_set_mapping(vxi, device, target,
19031 + return do_unset_mapping(vxi, device, target,
19036 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19038 + struct vcmd_set_mapping_v0 vc_data;
19040 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19043 + return do_mapping(vxi, vc_data.device, vc_data.target,
19044 + vc_data.flags, 1);
19047 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19049 + struct vcmd_set_mapping_v0 vc_data;
19051 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19054 + return do_mapping(vxi, vc_data.device, vc_data.target,
19055 + vc_data.flags, 0);
19059 +#ifdef CONFIG_COMPAT
19061 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19063 + struct vcmd_set_mapping_v0_x32 vc_data;
19065 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19068 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19069 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19072 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19074 + struct vcmd_set_mapping_v0_x32 vc_data;
19076 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19079 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19080 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19083 +#endif /* CONFIG_COMPAT */
19086 diff -NurpP --minimal linux-2.6.29/kernel/vserver/dlimit.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/dlimit.c
19087 --- linux-2.6.29/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19088 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/dlimit.c 2009-02-22 22:54:26.000000000 +0100
19091 + * linux/kernel/vserver/dlimit.c
19093 + * Virtual Server: Context Disk Limits
19095 + * Copyright (C) 2004-2007 Herbert Pötzl
19097 + * V0.01 initial version
19098 + * V0.02 compat32 splitup
19102 +#include <linux/statfs.h>
19103 +#include <linux/sched.h>
19104 +#include <linux/namei.h>
19105 +#include <linux/vs_tag.h>
19106 +#include <linux/vs_dlimit.h>
19107 +#include <linux/vserver/dlimit_cmd.h>
19109 +#include <asm/uaccess.h>
19111 +/* __alloc_dl_info()
19113 + * allocate an initialized dl_info struct
19114 + * doesn't make it visible (hash) */
19116 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19118 + struct dl_info *new = NULL;
19120 + vxdprintk(VXD_CBIT(dlim, 5),
19121 + "alloc_dl_info(%p,%d)*", sb, tag);
19123 + /* would this benefit from a slab cache? */
19124 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19128 + memset(new, 0, sizeof(struct dl_info));
19129 + new->dl_tag = tag;
19131 + INIT_RCU_HEAD(&new->dl_rcu);
19132 + INIT_HLIST_NODE(&new->dl_hlist);
19133 + spin_lock_init(&new->dl_lock);
19134 + atomic_set(&new->dl_refcnt, 0);
19135 + atomic_set(&new->dl_usecnt, 0);
19137 + /* rest of init goes here */
19139 + vxdprintk(VXD_CBIT(dlim, 4),
19140 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19144 +/* __dealloc_dl_info()
19146 + * final disposal of dl_info */
19148 +static void __dealloc_dl_info(struct dl_info *dli)
19150 + vxdprintk(VXD_CBIT(dlim, 4),
19151 + "dealloc_dl_info(%p)", dli);
19153 + dli->dl_hlist.next = LIST_POISON1;
19154 + dli->dl_tag = -1;
19157 + BUG_ON(atomic_read(&dli->dl_usecnt));
19158 + BUG_ON(atomic_read(&dli->dl_refcnt));
19164 +/* hash table for dl_info hash */
19166 +#define DL_HASH_SIZE 13
19168 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19170 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19173 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19175 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19180 +/* __hash_dl_info()
19182 + * add the dli to the global hash table
19183 + * requires the hash_lock to be held */
19185 +static inline void __hash_dl_info(struct dl_info *dli)
19187 + struct hlist_head *head;
19189 + vxdprintk(VXD_CBIT(dlim, 6),
19190 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19191 + get_dl_info(dli);
19192 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19193 + hlist_add_head_rcu(&dli->dl_hlist, head);
19196 +/* __unhash_dl_info()
19198 + * remove the dli from the global hash table
19199 + * requires the hash_lock to be held */
19201 +static inline void __unhash_dl_info(struct dl_info *dli)
19203 + vxdprintk(VXD_CBIT(dlim, 6),
19204 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19205 + hlist_del_rcu(&dli->dl_hlist);
19206 + put_dl_info(dli);
19210 +/* __lookup_dl_info()
19212 + * requires the rcu_read_lock()
19213 + * doesn't increment the dl_refcnt */
19215 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19217 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19218 + struct hlist_node *pos;
19219 + struct dl_info *dli;
19221 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19223 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19231 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19233 + struct dl_info *dli;
19236 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19237 + vxdprintk(VXD_CBIT(dlim, 7),
19238 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19239 + rcu_read_unlock();
19243 +void rcu_free_dl_info(struct rcu_head *head)
19245 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19246 + int usecnt, refcnt;
19248 + BUG_ON(!dli || !head);
19250 + usecnt = atomic_read(&dli->dl_usecnt);
19251 + BUG_ON(usecnt < 0);
19253 + refcnt = atomic_read(&dli->dl_refcnt);
19254 + BUG_ON(refcnt < 0);
19256 + vxdprintk(VXD_CBIT(dlim, 3),
19257 + "rcu_free_dl_info(%p)", dli);
19259 + __dealloc_dl_info(dli);
19261 + printk("!!! rcu didn't free\n");
19267 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19268 + uint32_t flags, int add)
19270 + struct path path;
19273 + ret = user_lpath(name, &path);
19275 + struct super_block *sb;
19276 + struct dl_info *dli;
19279 + if (!path.dentry->d_inode)
19280 + goto out_release;
19281 + if (!(sb = path.dentry->d_inode->i_sb))
19282 + goto out_release;
19285 + dli = __alloc_dl_info(sb, id);
19286 + spin_lock(&dl_info_hash_lock);
19289 + if (__lookup_dl_info(sb, id))
19291 + __hash_dl_info(dli);
19294 + spin_lock(&dl_info_hash_lock);
19295 + dli = __lookup_dl_info(sb, id);
19300 + __unhash_dl_info(dli);
19304 + spin_unlock(&dl_info_hash_lock);
19306 + __dealloc_dl_info(dli);
19313 +int vc_add_dlimit(uint32_t id, void __user *data)
19315 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19317 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19320 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19323 +int vc_rem_dlimit(uint32_t id, void __user *data)
19325 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19327 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19330 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19333 +#ifdef CONFIG_COMPAT
19335 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19337 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19339 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19342 + return do_addrem_dlimit(id,
19343 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19346 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19348 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19350 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19353 + return do_addrem_dlimit(id,
19354 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19357 +#endif /* CONFIG_COMPAT */
19361 +int do_set_dlimit(uint32_t id, const char __user *name,
19362 + uint32_t space_used, uint32_t space_total,
19363 + uint32_t inodes_used, uint32_t inodes_total,
19364 + uint32_t reserved, uint32_t flags)
19366 + struct path path;
19369 + ret = user_lpath(name, &path);
19371 + struct super_block *sb;
19372 + struct dl_info *dli;
19375 + if (!path.dentry->d_inode)
19376 + goto out_release;
19377 + if (!(sb = path.dentry->d_inode->i_sb))
19378 + goto out_release;
19379 + if ((reserved != CDLIM_KEEP &&
19380 + reserved > 100) ||
19381 + (inodes_used != CDLIM_KEEP &&
19382 + inodes_used > inodes_total) ||
19383 + (space_used != CDLIM_KEEP &&
19384 + space_used > space_total))
19385 + goto out_release;
19388 + dli = locate_dl_info(sb, id);
19390 + goto out_release;
19392 + spin_lock(&dli->dl_lock);
19394 + if (inodes_used != CDLIM_KEEP)
19395 + dli->dl_inodes_used = inodes_used;
19396 + if (inodes_total != CDLIM_KEEP)
19397 + dli->dl_inodes_total = inodes_total;
19398 + if (space_used != CDLIM_KEEP) {
19399 + dli->dl_space_used = space_used;
19400 + dli->dl_space_used <<= 10;
19402 + if (space_total == CDLIM_INFINITY)
19403 + dli->dl_space_total = DLIM_INFINITY;
19404 + else if (space_total != CDLIM_KEEP) {
19405 + dli->dl_space_total = space_total;
19406 + dli->dl_space_total <<= 10;
19408 + if (reserved != CDLIM_KEEP)
19409 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
19411 + spin_unlock(&dli->dl_lock);
19413 + put_dl_info(dli);
19422 +int vc_set_dlimit(uint32_t id, void __user *data)
19424 + struct vcmd_ctx_dlimit_v0 vc_data;
19426 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19429 + return do_set_dlimit(id, vc_data.name,
19430 + vc_data.space_used, vc_data.space_total,
19431 + vc_data.inodes_used, vc_data.inodes_total,
19432 + vc_data.reserved, vc_data.flags);
19435 +#ifdef CONFIG_COMPAT
19437 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19439 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19441 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19444 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19445 + vc_data.space_used, vc_data.space_total,
19446 + vc_data.inodes_used, vc_data.inodes_total,
19447 + vc_data.reserved, vc_data.flags);
19450 +#endif /* CONFIG_COMPAT */
19454 +int do_get_dlimit(uint32_t id, const char __user *name,
19455 + uint32_t *space_used, uint32_t *space_total,
19456 + uint32_t *inodes_used, uint32_t *inodes_total,
19457 + uint32_t *reserved, uint32_t *flags)
19459 + struct path path;
19462 + ret = user_lpath(name, &path);
19464 + struct super_block *sb;
19465 + struct dl_info *dli;
19468 + if (!path.dentry->d_inode)
19469 + goto out_release;
19470 + if (!(sb = path.dentry->d_inode->i_sb))
19471 + goto out_release;
19474 + dli = locate_dl_info(sb, id);
19476 + goto out_release;
19478 + spin_lock(&dli->dl_lock);
19479 + *inodes_used = dli->dl_inodes_used;
19480 + *inodes_total = dli->dl_inodes_total;
19481 + *space_used = dli->dl_space_used >> 10;
19482 + if (dli->dl_space_total == DLIM_INFINITY)
19483 + *space_total = CDLIM_INFINITY;
19485 + *space_total = dli->dl_space_total >> 10;
19487 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19488 + spin_unlock(&dli->dl_lock);
19490 + put_dl_info(dli);
19501 +int vc_get_dlimit(uint32_t id, void __user *data)
19503 + struct vcmd_ctx_dlimit_v0 vc_data;
19506 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19509 + ret = do_get_dlimit(id, vc_data.name,
19510 + &vc_data.space_used, &vc_data.space_total,
19511 + &vc_data.inodes_used, &vc_data.inodes_total,
19512 + &vc_data.reserved, &vc_data.flags);
19516 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19521 +#ifdef CONFIG_COMPAT
19523 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19525 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19528 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19531 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19532 + &vc_data.space_used, &vc_data.space_total,
19533 + &vc_data.inodes_used, &vc_data.inodes_total,
19534 + &vc_data.reserved, &vc_data.flags);
19538 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19543 +#endif /* CONFIG_COMPAT */
19546 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19548 + struct dl_info *dli;
19549 + __u64 blimit, bfree, bavail;
19552 + dli = locate_dl_info(sb, dx_current_tag());
19556 + spin_lock(&dli->dl_lock);
19557 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19560 + /* reduce max inodes available to limit */
19561 + if (buf->f_files > dli->dl_inodes_total)
19562 + buf->f_files = dli->dl_inodes_total;
19564 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19565 + /* reduce free inodes to min */
19566 + if (ifree < buf->f_ffree)
19567 + buf->f_ffree = ifree;
19570 + if (dli->dl_space_total == DLIM_INFINITY)
19573 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19575 + if (dli->dl_space_total < dli->dl_space_used)
19578 + bfree = (dli->dl_space_total - dli->dl_space_used)
19579 + >> sb->s_blocksize_bits;
19581 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19582 + if (bavail < dli->dl_space_used)
19585 + bavail = (bavail - dli->dl_space_used)
19586 + >> sb->s_blocksize_bits;
19588 + /* reduce max space available to limit */
19589 + if (buf->f_blocks > blimit)
19590 + buf->f_blocks = blimit;
19592 + /* reduce free space to min */
19593 + if (bfree < buf->f_bfree)
19594 + buf->f_bfree = bfree;
19596 + /* reduce avail space to min */
19597 + if (bavail < buf->f_bavail)
19598 + buf->f_bavail = bavail;
19601 + spin_unlock(&dli->dl_lock);
19602 + put_dl_info(dli);
19607 +#include <linux/module.h>
19609 +EXPORT_SYMBOL_GPL(locate_dl_info);
19610 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19612 diff -NurpP --minimal linux-2.6.29/kernel/vserver/helper.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/helper.c
19613 --- linux-2.6.29/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19614 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/helper.c 2009-03-25 00:40:43.000000000 +0100
19617 + * linux/kernel/vserver/helper.c
19619 + * Virtual Context Support
19621 + * Copyright (C) 2004-2007 Herbert Pötzl
19623 + * V0.01 basic helper
19627 +#include <linux/kmod.h>
19628 +#include <linux/reboot.h>
19629 +#include <linux/vs_context.h>
19630 +#include <linux/vs_network.h>
19631 +#include <linux/vserver/signal.h>
19634 +char vshelper_path[255] = "/sbin/vshelper";
19637 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19641 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19642 + printk( KERN_WARNING
19643 + "%s: (%s %s) returned %s with %d\n",
19644 + name, argv[1], argv[2],
19645 + sync ? "sync" : "async", ret);
19647 + vxdprintk(VXD_CBIT(switch, 4),
19648 + "%s: (%s %s) returned %s with %d",
19649 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19654 + * vshelper path is set via /proc/sys
19655 + * invoked by vserver sys_reboot(), with
19656 + * the following arguments
19658 + * argv [0] = vshelper_path;
19659 + * argv [1] = action: "restart", "halt", "poweroff", ...
19660 + * argv [2] = context identifier
19662 + * envp [*] = type-specific parameters
19665 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19667 + char id_buf[8], cmd_buf[16];
19668 + char uid_buf[16], pid_buf[16];
19671 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19672 + char *envp[] = {"HOME=/", "TERM=linux",
19673 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19674 + uid_buf, pid_buf, cmd_buf, 0};
19676 + if (vx_info_state(vxi, VXS_HELPER))
19678 + vxi->vx_state |= VXS_HELPER;
19680 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19682 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19683 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
19684 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19687 + case LINUX_REBOOT_CMD_RESTART:
19688 + argv[1] = "restart";
19691 + case LINUX_REBOOT_CMD_HALT:
19692 + argv[1] = "halt";
19695 + case LINUX_REBOOT_CMD_POWER_OFF:
19696 + argv[1] = "poweroff";
19699 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19700 + argv[1] = "swsusp";
19704 + vxi->vx_state &= ~VXS_HELPER;
19708 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19709 + vxi->vx_state &= ~VXS_HELPER;
19710 + __wakeup_vx_info(vxi);
19711 + return (ret) ? -EPERM : 0;
19715 +long vs_reboot(unsigned int cmd, void __user *arg)
19717 + struct vx_info *vxi = current->vx_info;
19720 + vxdprintk(VXD_CBIT(misc, 5),
19721 + "vs_reboot(%p[#%d],%d)",
19722 + vxi, vxi ? vxi->vx_id : 0, cmd);
19724 + ret = vs_reboot_helper(vxi, cmd, arg);
19728 + vxi->reboot_cmd = cmd;
19729 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19731 + case LINUX_REBOOT_CMD_RESTART:
19732 + case LINUX_REBOOT_CMD_HALT:
19733 + case LINUX_REBOOT_CMD_POWER_OFF:
19734 + vx_info_kill(vxi, 0, SIGKILL);
19735 + vx_info_kill(vxi, 1, SIGKILL);
19745 + * argv [0] = vshelper_path;
19746 + * argv [1] = action: "startup", "shutdown"
19747 + * argv [2] = context identifier
19749 + * envp [*] = type-specific parameters
19752 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
19754 + char id_buf[8], cmd_buf[16];
19755 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19756 + char *envp[] = {"HOME=/", "TERM=linux",
19757 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19759 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
19762 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19763 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19766 + case VSC_STARTUP:
19767 + argv[1] = "startup";
19769 + case VSC_SHUTDOWN:
19770 + argv[1] = "shutdown";
19776 + return do_vshelper(vshelper_path, argv, envp, 1);
19781 + * argv [0] = vshelper_path;
19782 + * argv [1] = action: "netup", "netdown"
19783 + * argv [2] = context identifier
19785 + * envp [*] = type-specific parameters
19788 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
19790 + char id_buf[8], cmd_buf[16];
19791 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19792 + char *envp[] = {"HOME=/", "TERM=linux",
19793 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
19795 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
19798 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
19799 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19803 + argv[1] = "netup";
19805 + case VSC_NETDOWN:
19806 + argv[1] = "netdown";
19812 + return do_vshelper(vshelper_path, argv, envp, 1);
19815 diff -NurpP --minimal linux-2.6.29/kernel/vserver/history.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/history.c
19816 --- linux-2.6.29/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19817 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/history.c 2009-02-22 22:54:26.000000000 +0100
19820 + * kernel/vserver/history.c
19822 + * Virtual Context History Backtrace
19824 + * Copyright (C) 2004-2007 Herbert Pötzl
19826 + * V0.01 basic structure
19827 + * V0.02 hash/unhash and trace
19828 + * V0.03 preemption fixes
19832 +#include <linux/module.h>
19833 +#include <asm/uaccess.h>
19835 +#include <linux/vserver/context.h>
19836 +#include <linux/vserver/debug.h>
19837 +#include <linux/vserver/debug_cmd.h>
19838 +#include <linux/vserver/history.h>
19841 +#ifdef CONFIG_VSERVER_HISTORY
19842 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19844 +#define VXH_SIZE 64
19847 +struct _vx_history {
19848 + unsigned int counter;
19850 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19854 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19856 +unsigned volatile int vxh_active = 1;
19858 +static atomic_t sequence = ATOMIC_INIT(0);
19863 + * requires disabled preemption */
19865 +struct _vx_hist_entry *vxh_advance(void *loc)
19867 + unsigned int cpu = smp_processor_id();
19868 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19869 + struct _vx_hist_entry *entry;
19870 + unsigned int index;
19872 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19873 + entry = &hist->entry[index];
19875 + entry->seq = atomic_inc_return(&sequence);
19876 + entry->loc = loc;
19880 +EXPORT_SYMBOL_GPL(vxh_advance);
19883 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19885 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19888 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19890 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19891 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19892 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19893 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19895 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19897 + switch (e->type) {
19898 + case VXH_THROW_OOPS:
19899 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19902 + case VXH_GET_VX_INFO:
19903 + case VXH_PUT_VX_INFO:
19904 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19906 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19907 + VXH_VXI_ARGS(e));
19910 + case VXH_INIT_VX_INFO:
19911 + case VXH_SET_VX_INFO:
19912 + case VXH_CLR_VX_INFO:
19913 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19915 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19916 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19917 + VXH_VXI_ARGS(e), e->sc.data);
19920 + case VXH_CLAIM_VX_INFO:
19921 + case VXH_RELEASE_VX_INFO:
19922 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19924 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19925 + VXH_VXI_ARGS(e), e->sc.data);
19928 + case VXH_ALLOC_VX_INFO:
19929 + case VXH_DEALLOC_VX_INFO:
19930 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19932 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19933 + VXH_VXI_ARGS(e));
19936 + case VXH_HASH_VX_INFO:
19937 + case VXH_UNHASH_VX_INFO:
19938 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19940 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19941 + VXH_VXI_ARGS(e));
19944 + case VXH_LOC_VX_INFO:
19945 + case VXH_LOOKUP_VX_INFO:
19946 + case VXH_CREATE_VX_INFO:
19947 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19949 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19950 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19951 + e->ll.arg, VXH_VXI_ARGS(e));
19956 +static void __vxh_dump_history(void)
19958 + unsigned int i, cpu;
19960 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19961 + atomic_read(&sequence), NR_CPUS);
19963 + for (i = 0; i < VXH_SIZE; i++) {
19964 + for_each_online_cpu(cpu) {
19965 + struct _vx_history *hist =
19966 + &per_cpu(vx_history_buffer, cpu);
19967 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19968 + struct _vx_hist_entry *entry = &hist->entry[index];
19970 + vxh_dump_entry(entry, cpu);
19975 +void vxh_dump_history(void)
19979 + local_irq_enable();
19981 + local_irq_disable();
19983 + __vxh_dump_history();
19987 +/* vserver syscall commands below here */
19990 +int vc_dump_history(uint32_t id)
19993 + __vxh_dump_history();
20000 +int do_read_history(struct __user _vx_hist_entry *data,
20001 + int cpu, uint32_t *index, uint32_t *count)
20003 + int pos, ret = 0;
20004 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20005 + int end = hist->counter;
20006 + int start = end - VXH_SIZE + 2;
20007 + int idx = *index;
20009 + /* special case: get current pos */
20015 + /* have we lost some data? */
20019 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20020 + struct _vx_hist_entry *entry =
20021 + &hist->entry[idx % VXH_SIZE];
20023 + /* send entry to userspace */
20024 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20028 + /* save new index and count */
20031 + return ret ? ret : (*index < end);
20034 +int vc_read_history(uint32_t id, void __user *data)
20036 + struct vcmd_read_history_v0 vc_data;
20039 + if (id >= NR_CPUS)
20042 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20045 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20046 + id, &vc_data.index, &vc_data.count);
20048 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20053 +#ifdef CONFIG_COMPAT
20055 +int vc_read_history_x32(uint32_t id, void __user *data)
20057 + struct vcmd_read_history_v0_x32 vc_data;
20060 + if (id >= NR_CPUS)
20063 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20066 + ret = do_read_history((struct __user _vx_hist_entry *)
20067 + compat_ptr(vc_data.data_ptr),
20068 + id, &vc_data.index, &vc_data.count);
20070 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20075 +#endif /* CONFIG_COMPAT */
20077 diff -NurpP --minimal linux-2.6.29/kernel/vserver/inet.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/inet.c
20078 --- linux-2.6.29/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20079 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/inet.c 2009-02-22 22:54:26.000000000 +0100
20082 +#include <linux/in.h>
20083 +#include <linux/inetdevice.h>
20084 +#include <linux/vs_inet.h>
20085 +#include <linux/vs_inet6.h>
20086 +#include <linux/vserver/debug.h>
20087 +#include <net/route.h>
20088 +#include <net/addrconf.h>
20091 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20095 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20098 + struct nx_addr_v4 *ptr;
20100 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20101 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20108 + vxdprintk(VXD_CBIT(net, 2),
20109 + "nx_v4_addr_conflict(%p,%p): %d",
20110 + nxi1, nxi2, ret);
20116 +#ifdef CONFIG_IPV6
20118 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20122 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20125 + struct nx_addr_v6 *ptr;
20127 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20128 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20135 + vxdprintk(VXD_CBIT(net, 2),
20136 + "nx_v6_addr_conflict(%p,%p): %d",
20137 + nxi1, nxi2, ret);
20144 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20146 + struct in_device *in_dev;
20147 + struct in_ifaddr **ifap;
20148 + struct in_ifaddr *ifa;
20153 + in_dev = in_dev_get(dev);
20157 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20158 + ifap = &ifa->ifa_next) {
20159 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20164 + in_dev_put(in_dev);
20170 +#ifdef CONFIG_IPV6
20172 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20174 + struct inet6_dev *in_dev;
20175 + struct inet6_ifaddr **ifap;
20176 + struct inet6_ifaddr *ifa;
20181 + in_dev = in6_dev_get(dev);
20185 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20186 + ifap = &ifa->if_next) {
20187 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20192 + in6_dev_put(in_dev);
20199 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20205 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20207 +#ifdef CONFIG_IPV6
20209 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20214 + vxdprintk(VXD_CBIT(net, 3),
20215 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20216 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20220 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20221 + struct rtable **rp, struct flowi *fl)
20226 + /* FIXME: handle lback only case */
20227 + if (!NX_IPV4(nxi))
20230 + vxdprintk(VXD_CBIT(net, 4),
20231 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20232 + nxi, nxi ? nxi->nx_id : 0,
20233 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20235 + /* single IP is unconditional */
20236 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20237 + (fl->fl4_src == INADDR_ANY))
20238 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20240 + if (fl->fl4_src == INADDR_ANY) {
20241 + struct nx_addr_v4 *ptr;
20242 + __be32 found = 0;
20245 + err = __ip_route_output_key(net, rp, fl);
20247 + found = (*rp)->rt_src;
20249 + vxdprintk(VXD_CBIT(net, 4),
20250 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20251 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20252 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20256 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20257 + __be32 primary = ptr->ip[0].s_addr;
20258 + __be32 mask = ptr->mask.s_addr;
20259 + __be32 neta = primary & mask;
20261 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20262 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20263 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20264 + NIPQUAD(mask), NIPQUAD(neta));
20265 + if ((found & mask) != neta)
20268 + fl->fl4_src = primary;
20269 + err = __ip_route_output_key(net, rp, fl);
20270 + vxdprintk(VXD_CBIT(net, 4),
20271 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20272 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20274 + found = (*rp)->rt_src;
20276 + if (found == primary)
20280 + /* still no source ip? */
20281 + found = ipv4_is_loopback(fl->fl4_dst)
20282 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20284 + /* assign src ip to flow */
20285 + fl->fl4_src = found;
20288 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20292 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20293 + if (ipv4_is_loopback(fl->fl4_dst))
20294 + fl->fl4_dst = nxi->v4_lback.s_addr;
20295 + if (ipv4_is_loopback(fl->fl4_src))
20296 + fl->fl4_src = nxi->v4_lback.s_addr;
20297 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20298 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20304 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20306 diff -NurpP --minimal linux-2.6.29/kernel/vserver/init.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/init.c
20307 --- linux-2.6.29/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20308 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/init.c 2009-02-22 22:54:26.000000000 +0100
20311 + * linux/kernel/init.c
20313 + * Virtual Server Init
20315 + * Copyright (C) 2004-2007 Herbert Pötzl
20317 + * V0.01 basic structure
20321 +#include <linux/init.h>
20323 +int vserver_register_sysctl(void);
20324 +void vserver_unregister_sysctl(void);
20327 +static int __init init_vserver(void)
20331 +#ifdef CONFIG_VSERVER_DEBUG
20332 + vserver_register_sysctl();
20338 +static void __exit exit_vserver(void)
20341 +#ifdef CONFIG_VSERVER_DEBUG
20342 + vserver_unregister_sysctl();
20347 +/* FIXME: GFP_ZONETYPES gone
20348 +long vx_slab[GFP_ZONETYPES]; */
20352 +module_init(init_vserver);
20353 +module_exit(exit_vserver);
20355 diff -NurpP --minimal linux-2.6.29/kernel/vserver/inode.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/inode.c
20356 --- linux-2.6.29/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20357 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/inode.c 2009-02-22 22:54:26.000000000 +0100
20360 + * linux/kernel/vserver/inode.c
20362 + * Virtual Server: File System Support
20364 + * Copyright (C) 2004-2007 Herbert Pötzl
20366 + * V0.01 separated from vcontext V0.05
20367 + * V0.02 moved to tag (instead of xid)
20371 +#include <linux/tty.h>
20372 +#include <linux/proc_fs.h>
20373 +#include <linux/devpts_fs.h>
20374 +#include <linux/fs.h>
20375 +#include <linux/file.h>
20376 +#include <linux/mount.h>
20377 +#include <linux/parser.h>
20378 +#include <linux/namei.h>
20379 +#include <linux/vserver/inode.h>
20380 +#include <linux/vserver/inode_cmd.h>
20381 +#include <linux/vs_base.h>
20382 +#include <linux/vs_tag.h>
20384 +#include <asm/uaccess.h>
20387 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20389 + struct proc_dir_entry *entry;
20391 + if (!in || !in->i_sb)
20394 + *flags = IATTR_TAG
20395 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
20396 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
20397 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
20398 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE;
20400 + if (S_ISDIR(in->i_mode))
20401 + *mask |= IATTR_BARRIER;
20403 + if (IS_TAGGED(in)) {
20404 + *tag = in->i_tag;
20405 + *mask |= IATTR_TAG;
20408 + switch (in->i_sb->s_magic) {
20409 + case PROC_SUPER_MAGIC:
20410 + entry = PROC_I(in)->pde;
20412 + /* check for specific inodes? */
20414 + *mask |= IATTR_FLAGS;
20416 + *flags |= (entry->vx_flags & IATTR_FLAGS);
20418 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
20421 + case DEVPTS_SUPER_MAGIC:
20422 + *tag = in->i_tag;
20423 + *mask |= IATTR_TAG;
20432 +int vc_get_iattr(void __user *data)
20434 + struct path path;
20435 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
20438 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20441 + ret = user_lpath(vc_data.name, &path);
20443 + ret = __vc_get_iattr(path.dentry->d_inode,
20444 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20450 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20455 +#ifdef CONFIG_COMPAT
20457 +int vc_get_iattr_x32(void __user *data)
20459 + struct path path;
20460 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
20463 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20466 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20468 + ret = __vc_get_iattr(path.dentry->d_inode,
20469 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20475 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20480 +#endif /* CONFIG_COMPAT */
20483 +int vc_fget_iattr(uint32_t fd, void __user *data)
20485 + struct file *filp;
20486 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
20489 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20493 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20496 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20497 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20501 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20507 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20509 + struct inode *in = de->d_inode;
20510 + int error = 0, is_proc = 0, has_tag = 0;
20511 + struct iattr attr = { 0 };
20513 + if (!in || !in->i_sb)
20516 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20517 + if ((*mask & IATTR_FLAGS) && !is_proc)
20520 + has_tag = IS_TAGGED(in) ||
20521 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20522 + if ((*mask & IATTR_TAG) && !has_tag)
20525 + mutex_lock(&in->i_mutex);
20526 + if (*mask & IATTR_TAG) {
20527 + attr.ia_tag = *tag;
20528 + attr.ia_valid |= ATTR_TAG;
20531 + if (*mask & IATTR_FLAGS) {
20532 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20533 + unsigned int iflags = PROC_I(in)->vx_flags;
20535 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20536 + | (*flags & IATTR_FLAGS);
20537 + PROC_I(in)->vx_flags = iflags;
20539 + entry->vx_flags = iflags;
20542 + if (*mask & (IATTR_BARRIER | IATTR_IXUNLINK | IATTR_IMMUTABLE)) {
20543 + if (*mask & IATTR_IMMUTABLE) {
20544 + if (*flags & IATTR_IMMUTABLE)
20545 + in->i_flags |= S_IMMUTABLE;
20547 + in->i_flags &= ~S_IMMUTABLE;
20549 + if (*mask & IATTR_IXUNLINK) {
20550 + if (*flags & IATTR_IXUNLINK)
20551 + in->i_flags |= S_IXUNLINK;
20553 + in->i_flags &= ~S_IXUNLINK;
20555 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20556 + if (*flags & IATTR_BARRIER)
20557 + in->i_vflags |= V_BARRIER;
20559 + in->i_vflags &= ~V_BARRIER;
20561 + if (in->i_op && in->i_op->sync_flags) {
20562 + error = in->i_op->sync_flags(in);
20568 + if (attr.ia_valid) {
20569 + if (in->i_op && in->i_op->setattr)
20570 + error = in->i_op->setattr(de, &attr);
20572 + error = inode_change_ok(in, &attr);
20574 + error = inode_setattr(in, &attr);
20579 + mutex_unlock(&in->i_mutex);
20583 +int vc_set_iattr(void __user *data)
20585 + struct path path;
20586 + struct vcmd_ctx_iattr_v1 vc_data;
20589 + if (!capable(CAP_LINUX_IMMUTABLE))
20591 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20594 + ret = user_lpath(vc_data.name, &path);
20596 + ret = __vc_set_iattr(path.dentry,
20597 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20601 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20606 +#ifdef CONFIG_COMPAT
20608 +int vc_set_iattr_x32(void __user *data)
20610 + struct path path;
20611 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20614 + if (!capable(CAP_LINUX_IMMUTABLE))
20616 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20619 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20621 + ret = __vc_set_iattr(path.dentry,
20622 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20626 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20631 +#endif /* CONFIG_COMPAT */
20633 +int vc_fset_iattr(uint32_t fd, void __user *data)
20635 + struct file *filp;
20636 + struct vcmd_ctx_fiattr_v0 vc_data;
20639 + if (!capable(CAP_LINUX_IMMUTABLE))
20641 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20645 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20648 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20649 + &vc_data.flags, &vc_data.mask);
20653 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20659 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20661 +static match_table_t tokens = {
20662 + {Opt_notagcheck, "notagcheck"},
20663 +#ifdef CONFIG_PROPAGATE
20664 + {Opt_notag, "notag"},
20665 + {Opt_tag, "tag"},
20666 + {Opt_tagid, "tagid=%u"},
20672 +static void __dx_parse_remove(char *string, char *opt)
20674 + char *p = strstr(string, opt);
20678 + while (*q != '\0' && *q != ',')
20687 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20688 + unsigned long *flags)
20691 + substring_t args[MAX_OPT_ARGS];
20692 + int token, option = 0;
20693 + char *s, *p, *opts;
20697 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20702 + while ((p = strsep(&opts, ",")) != NULL) {
20703 + token = match_token(p, tokens, args);
20705 + vxdprintk(VXD_CBIT(tag, 7),
20706 + "dx_parse_tag(»%s«): %d:#%d",
20707 + p, token, option);
20710 +#ifdef CONFIG_PROPAGATE
20715 + __dx_parse_remove(s, "tag");
20716 + *mnt_flags |= MNT_TAGID;
20717 + set |= MNT_TAGID;
20721 + __dx_parse_remove(s, "notag");
20722 + *mnt_flags |= MNT_NOTAG;
20723 + set |= MNT_NOTAG;
20726 + if (tag && !match_int(args, &option))
20729 + __dx_parse_remove(s, "tagid");
20730 + *mnt_flags |= MNT_TAGID;
20731 + set |= MNT_TAGID;
20734 + case Opt_notagcheck:
20736 + __dx_parse_remove(s, "notagcheck");
20737 + *flags |= MS_NOTAGCHECK;
20738 + set |= MS_NOTAGCHECK;
20743 + strcpy(string, s);
20748 +#ifdef CONFIG_PROPAGATE
20750 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20752 + tag_t new_tag = 0;
20753 + struct vfsmount *mnt;
20758 + mnt = nd->path.mnt;
20762 + propagate = (mnt->mnt_flags & MNT_TAGID);
20764 + new_tag = mnt->mnt_tag;
20766 + vxdprintk(VXD_CBIT(tag, 7),
20767 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20768 + inode, inode->i_ino, inode->i_tag,
20769 + new_tag, (propagate) ? 1 : 0);
20772 + inode->i_tag = new_tag;
20775 +#include <linux/module.h>
20777 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20779 +#endif /* CONFIG_PROPAGATE */
20781 diff -NurpP --minimal linux-2.6.29/kernel/vserver/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/Kconfig
20782 --- linux-2.6.29/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
20783 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/Kconfig 2009-02-22 22:54:26.000000000 +0100
20786 +# Linux VServer configuration
20789 +menu "Linux VServer"
20791 +config VSERVER_AUTO_LBACK
20792 + bool "Automatically Assign Loopback IP"
20795 + Automatically assign a guest specific loopback
20796 + IP and add it to the kernel network stack on
20799 +config VSERVER_AUTO_SINGLE
20800 + bool "Automatic Single IP Special Casing"
20801 + depends on EXPERIMENTAL
20804 + This allows network contexts with a single IP to
20805 + automatically remap 0.0.0.0 bindings to that IP,
20806 + avoiding further network checks and improving
20809 + (note: such guests do not allow to change the ip
20810 + on the fly and do not show loopback addresses)
20812 +config VSERVER_COWBL
20813 + bool "Enable COW Immutable Link Breaking"
20816 + This enables the COW (Copy-On-Write) link break code.
20817 + It allows you to treat unified files like normal files
20818 + when writing to them (which will implicitely break the
20819 + link and create a copy of the unified file)
20821 +config VSERVER_VTIME
20822 + bool "Enable Virtualized Guest Time"
20823 + depends on EXPERIMENTAL
20826 + This enables per guest time offsets to allow for
20827 + adjusting the system clock individually per guest.
20828 + this adds some overhead to the time functions and
20829 + therefore should not be enabled without good reason.
20831 +config VSERVER_DEVICE
20832 + bool "Enable Guest Device Mapping"
20833 + depends on EXPERIMENTAL
20836 + This enables generic device remapping.
20838 +config VSERVER_PROC_SECURE
20839 + bool "Enable Proc Security"
20840 + depends on PROC_FS
20843 + This configures ProcFS security to initially hide
20844 + non-process entries for all contexts except the main and
20845 + spectator context (i.e. for all guests), which is a secure
20848 + (note: on 1.2x the entries were visible by default)
20850 +config VSERVER_HARDCPU
20851 + bool "Enable Hard CPU Limits"
20854 + Activate the Hard CPU Limits
20856 + This will compile in code that allows the Token Bucket
20857 + Scheduler to put processes on hold when a context's
20858 + tokens are depleted (provided that its per-context
20859 + sched_hard flag is set).
20861 + Processes belonging to that context will not be able
20862 + to consume CPU resources again until a per-context
20863 + configured minimum of tokens has been reached.
20865 +config VSERVER_IDLETIME
20866 + bool "Avoid idle CPUs by skipping Time"
20867 + depends on VSERVER_HARDCPU
20870 + This option allows the scheduler to artificially
20871 + advance time (per cpu) when otherwise the idle
20872 + task would be scheduled, thus keeping the cpu
20873 + busy and sharing the available resources among
20874 + certain contexts.
20876 +config VSERVER_IDLELIMIT
20877 + bool "Limit the IDLE task"
20878 + depends on VSERVER_HARDCPU
20881 + Limit the idle slices, so the the next context
20882 + will be scheduled as soon as possible.
20884 + This might improve interactivity and latency, but
20885 + will also marginally increase scheduling overhead.
20888 + prompt "Persistent Inode Tagging"
20889 + default TAGGING_ID24
20891 + This adds persistent context information to filesystems
20892 + mounted with the tagxid option. Tagging is a requirement
20893 + for per-context disk limits and per-context quota.
20896 +config TAGGING_NONE
20899 + do not store per-context information in inodes.
20901 +config TAGGING_UID16
20902 + bool "UID16/GID32"
20904 + reduces UID to 16 bit, but leaves GID at 32 bit.
20906 +config TAGGING_GID16
20907 + bool "UID32/GID16"
20909 + reduces GID to 16 bit, but leaves UID at 32 bit.
20911 +config TAGGING_ID24
20912 + bool "UID24/GID24"
20914 + uses the upper 8bit from UID and GID for XID tagging
20915 + which leaves 24bit for UID/GID each, which should be
20916 + more than sufficient for normal use.
20918 +config TAGGING_INTERN
20919 + bool "UID32/GID32"
20921 + this uses otherwise reserved inode fields in the on
20922 + disk representation, which limits the use to a few
20923 + filesystems (currently ext2 and ext3)
20928 + bool "Tag NFSD User Auth and Files"
20931 + Enable this if you do want the in-kernel NFS
20932 + Server to use the tagging specified above.
20933 + (will require patched clients too)
20935 +config VSERVER_PRIVACY
20936 + bool "Honor Privacy Aspects of Guests"
20939 + When enabled, most context checks will disallow
20940 + access to structures assigned to a specific context,
20941 + like ptys or loop devices.
20943 +config VSERVER_CONTEXTS
20944 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20946 + default "768" if 64BIT
20949 + This setting will optimize certain data structures
20950 + and memory allocations according to the expected
20953 + note: this is not a strict upper limit.
20955 +config VSERVER_WARN
20956 + bool "VServer Warnings"
20959 + This enables various runtime warnings, which will
20960 + notify about potential manipulation attempts or
20961 + resource shortage. It is generally considered to
20962 + be a good idea to have that enabled.
20964 +config VSERVER_DEBUG
20965 + bool "VServer Debugging Code"
20968 + Set this to yes if you want to be able to activate
20969 + debugging output at runtime. It adds a very small
20970 + overhead to all vserver related functions and
20971 + increases the kernel size by about 20k.
20973 +config VSERVER_HISTORY
20974 + bool "VServer History Tracing"
20975 + depends on VSERVER_DEBUG
20978 + Set this to yes if you want to record the history of
20979 + linux-vserver activities, so they can be replayed in
20980 + the event of a kernel panic or oops.
20982 +config VSERVER_HISTORY_SIZE
20983 + int "Per-CPU History Size (32-65536)"
20984 + depends on VSERVER_HISTORY
20988 + This allows you to specify the number of entries in
20989 + the per-CPU history buffer.
20991 +config VSERVER_MONITOR
20992 + bool "VServer Scheduling Monitor"
20993 + depends on VSERVER_DISABLED
20996 + Set this to yes if you want to record the scheduling
20997 + decisions, so that they can be relayed to userspace
20998 + for detailed analysis.
21000 +config VSERVER_MONITOR_SIZE
21001 + int "Per-CPU Monitor Queue Size (32-65536)"
21002 + depends on VSERVER_MONITOR
21006 + This allows you to specify the number of entries in
21007 + the per-CPU scheduling monitor buffer.
21009 +config VSERVER_MONITOR_SYNC
21010 + int "Per-CPU Monitor Sync Interval (0-65536)"
21011 + depends on VSERVER_MONITOR
21015 + This allows you to specify the interval in ticks
21016 + when a time sync entry is inserted.
21024 + select NAMESPACES
21030 +config VSERVER_SECURITY
21032 + depends on SECURITY
21034 + select SECURITY_CAPABILITIES
21036 diff -NurpP --minimal linux-2.6.29/kernel/vserver/limit.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/limit.c
21037 --- linux-2.6.29/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21038 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/limit.c 2009-02-22 22:54:26.000000000 +0100
21041 + * linux/kernel/vserver/limit.c
21043 + * Virtual Server: Context Limits
21045 + * Copyright (C) 2004-2007 Herbert Pötzl
21047 + * V0.01 broken out from vcontext V0.05
21048 + * V0.02 changed vcmds to vxi arg
21052 +#include <linux/sched.h>
21053 +#include <linux/module.h>
21054 +#include <linux/vs_limit.h>
21055 +#include <linux/vserver/limit.h>
21056 +#include <linux/vserver/limit_cmd.h>
21058 +#include <asm/uaccess.h>
21061 +const char *vlimit_name[NUM_LIMITS] = {
21062 + [RLIMIT_CPU] = "CPU",
21063 + [RLIMIT_RSS] = "RSS",
21064 + [RLIMIT_NPROC] = "NPROC",
21065 + [RLIMIT_NOFILE] = "NOFILE",
21066 + [RLIMIT_MEMLOCK] = "VML",
21067 + [RLIMIT_AS] = "VM",
21068 + [RLIMIT_LOCKS] = "LOCKS",
21069 + [RLIMIT_SIGPENDING] = "SIGP",
21070 + [RLIMIT_MSGQUEUE] = "MSGQ",
21072 + [VLIMIT_NSOCK] = "NSOCK",
21073 + [VLIMIT_OPENFD] = "OPENFD",
21074 + [VLIMIT_ANON] = "ANON",
21075 + [VLIMIT_SHMEM] = "SHMEM",
21076 + [VLIMIT_DENTRY] = "DENTRY",
21079 +EXPORT_SYMBOL_GPL(vlimit_name);
21081 +#define MASK_ENTRY(x) (1 << (x))
21083 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21086 + , /* softlimit */
21087 + MASK_ENTRY( RLIMIT_RSS ) |
21088 + MASK_ENTRY( VLIMIT_ANON ) |
21091 + MASK_ENTRY( RLIMIT_RSS ) |
21092 + MASK_ENTRY( RLIMIT_NPROC ) |
21093 + MASK_ENTRY( RLIMIT_NOFILE ) |
21094 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21095 + MASK_ENTRY( RLIMIT_AS ) |
21096 + MASK_ENTRY( RLIMIT_LOCKS ) |
21097 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21099 + MASK_ENTRY( VLIMIT_NSOCK ) |
21100 + MASK_ENTRY( VLIMIT_OPENFD ) |
21101 + MASK_ENTRY( VLIMIT_ANON ) |
21102 + MASK_ENTRY( VLIMIT_SHMEM ) |
21103 + MASK_ENTRY( VLIMIT_DENTRY ) |
21106 + /* accounting only */
21107 +uint32_t account_mask =
21108 + MASK_ENTRY( VLIMIT_SEMARY ) |
21109 + MASK_ENTRY( VLIMIT_NSEMS ) |
21110 + MASK_ENTRY( VLIMIT_MAPPED ) |
21114 +static int is_valid_vlimit(int id)
21116 + uint32_t mask = vlimit_mask.minimum |
21117 + vlimit_mask.softlimit | vlimit_mask.maximum;
21118 + return mask & (1 << id);
21121 +static int is_accounted_vlimit(int id)
21123 + if (is_valid_vlimit(id))
21125 + return account_mask & (1 << id);
21129 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21131 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21132 + return VX_VLIM(limit);
21135 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21137 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21138 + return VX_VLIM(limit);
21141 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21142 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21144 + if (!is_valid_vlimit(id))
21148 + *minimum = CRLIM_UNSET;
21150 + *softlimit = vc_get_soft(vxi, id);
21152 + *maximum = vc_get_hard(vxi, id);
21156 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21158 + struct vcmd_ctx_rlimit_v0 vc_data;
21161 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21164 + ret = do_get_rlimit(vxi, vc_data.id,
21165 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21169 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21174 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21175 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21177 + if (!is_valid_vlimit(id))
21180 + if (maximum != CRLIM_KEEP)
21181 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21182 + if (softlimit != CRLIM_KEEP)
21183 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21185 + /* clamp soft limit */
21186 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21187 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21192 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21194 + struct vcmd_ctx_rlimit_v0 vc_data;
21196 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21199 + return do_set_rlimit(vxi, vc_data.id,
21200 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21203 +#ifdef CONFIG_IA32_EMULATION
21205 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21207 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21209 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21212 + return do_set_rlimit(vxi, vc_data.id,
21213 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21216 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21218 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21221 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21224 + ret = do_get_rlimit(vxi, vc_data.id,
21225 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21229 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21234 +#endif /* CONFIG_IA32_EMULATION */
21237 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21239 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21245 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21250 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21251 + value = __rlim_get(limit, lim);
21252 + __rlim_rmax(limit, lim) = value;
21253 + __rlim_rmin(limit, lim) = value;
21258 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21260 + vx_reset_minmax(&vxi->limit);
21265 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21267 + struct vcmd_rlimit_stat_v0 vc_data;
21268 + struct _vx_limit *limit = &vxi->limit;
21271 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21275 + if (!is_accounted_vlimit(id))
21278 + vx_limit_fixup(limit, id);
21279 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21280 + vc_data.value = __rlim_get(limit, id);
21281 + vc_data.minimum = __rlim_rmin(limit, id);
21282 + vc_data.maximum = __rlim_rmax(limit, id);
21284 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21290 +void vx_vsi_meminfo(struct sysinfo *val)
21292 + struct vx_info *vxi = current->vx_info;
21293 + unsigned long totalram, freeram;
21296 + /* we blindly accept the max */
21297 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21298 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21300 + /* total minus used equals free */
21301 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21302 + freeram = (v < totalram) ? totalram - v : 0;
21304 + val->totalram = totalram;
21305 + val->freeram = freeram;
21306 + val->bufferram = 0;
21307 + val->totalhigh = 0;
21308 + val->freehigh = 0;
21312 +void vx_vsi_swapinfo(struct sysinfo *val)
21314 + struct vx_info *vxi = current->vx_info;
21315 + unsigned long totalswap, freeswap;
21318 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21319 + if (v == RLIM_INFINITY) {
21320 + val->freeswap = val->totalswap;
21324 + /* we blindly accept the max */
21325 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21326 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
21328 + /* currently 'used' swap */
21329 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21330 + w -= (w > v) ? v : w;
21332 + /* total minus used equals free */
21333 + freeswap = (w < totalswap) ? totalswap - w : 0;
21335 + val->totalswap = totalswap;
21336 + val->freeswap = freeswap;
21341 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21343 + struct vx_info *vxi = mm->mm_vx_info;
21344 + unsigned long points;
21350 + points = vxi->vx_badness_bias;
21352 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21353 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21354 + points += (v > w) ? (v - w) : 0;
21359 diff -NurpP --minimal linux-2.6.29/kernel/vserver/limit_init.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/limit_init.h
21360 --- linux-2.6.29/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
21361 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/limit_init.h 2009-02-22 22:54:26.000000000 +0100
21365 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21369 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21370 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21371 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21372 + __rlim_set(limit, lim, 0);
21373 + atomic_set(&__rlim_lhit(limit, lim), 0);
21374 + __rlim_rmin(limit, lim) = 0;
21375 + __rlim_rmax(limit, lim) = 0;
21379 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21384 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21385 + if ((1 << lim) & VLIM_NOCHECK)
21387 + value = __rlim_get(limit, lim);
21388 + vxwprintk_xid(value,
21389 + "!!! limit: %p[%s,%d] = %ld on exit.",
21390 + limit, vlimit_name[lim], lim, (long)value);
21394 diff -NurpP --minimal linux-2.6.29/kernel/vserver/limit_proc.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/limit_proc.h
21395 --- linux-2.6.29/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
21396 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/limit_proc.h 2009-02-22 22:54:26.000000000 +0100
21398 +#ifndef _VX_LIMIT_PROC_H
21399 +#define _VX_LIMIT_PROC_H
21401 +#include <linux/vserver/limit_int.h>
21404 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21405 +#define VX_LIMIT_TOP \
21406 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21408 +#define VX_LIMIT_ARG(r) \
21409 + (unsigned long)__rlim_get(limit, r), \
21410 + (unsigned long)__rlim_rmin(limit, r), \
21411 + (unsigned long)__rlim_rmax(limit, r), \
21412 + VX_VLIM(__rlim_soft(limit, r)), \
21413 + VX_VLIM(__rlim_hard(limit, r)), \
21414 + atomic_read(&__rlim_lhit(limit, r))
21416 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21418 + vx_limit_fixup(limit, -1);
21419 + return sprintf(buffer, VX_LIMIT_TOP
21420 + "PROC" VX_LIMIT_FMT
21421 + "VM" VX_LIMIT_FMT
21422 + "VML" VX_LIMIT_FMT
21423 + "RSS" VX_LIMIT_FMT
21424 + "ANON" VX_LIMIT_FMT
21425 + "RMAP" VX_LIMIT_FMT
21426 + "FILES" VX_LIMIT_FMT
21427 + "OFD" VX_LIMIT_FMT
21428 + "LOCKS" VX_LIMIT_FMT
21429 + "SOCK" VX_LIMIT_FMT
21430 + "MSGQ" VX_LIMIT_FMT
21431 + "SHM" VX_LIMIT_FMT
21432 + "SEMA" VX_LIMIT_FMT
21433 + "SEMS" VX_LIMIT_FMT
21434 + "DENT" VX_LIMIT_FMT,
21435 + VX_LIMIT_ARG(RLIMIT_NPROC),
21436 + VX_LIMIT_ARG(RLIMIT_AS),
21437 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21438 + VX_LIMIT_ARG(RLIMIT_RSS),
21439 + VX_LIMIT_ARG(VLIMIT_ANON),
21440 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21441 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21442 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21443 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21444 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21445 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21446 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21447 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21448 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21449 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21452 +#endif /* _VX_LIMIT_PROC_H */
21455 diff -NurpP --minimal linux-2.6.29/kernel/vserver/Makefile linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/Makefile
21456 --- linux-2.6.29/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21457 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/Makefile 2009-02-22 22:54:26.000000000 +0100
21460 +# Makefile for the Linux vserver routines.
21464 +obj-y += vserver.o
21466 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21467 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21470 +vserver-$(CONFIG_INET) += inet.o
21471 +vserver-$(CONFIG_PROC_FS) += proc.o
21472 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21473 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21474 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21475 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21477 diff -NurpP --minimal linux-2.6.29/kernel/vserver/monitor.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/monitor.c
21478 --- linux-2.6.29/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21479 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/monitor.c 2009-02-22 22:54:26.000000000 +0100
21482 + * kernel/vserver/monitor.c
21484 + * Virtual Context Scheduler Monitor
21486 + * Copyright (C) 2006-2007 Herbert Pötzl
21488 + * V0.01 basic design
21492 +#include <linux/module.h>
21493 +#include <linux/jiffies.h>
21494 +#include <asm/uaccess.h>
21495 +#include <asm/atomic.h>
21497 +#include <linux/vserver/monitor.h>
21498 +#include <linux/vserver/debug_cmd.h>
21501 +#ifdef CONFIG_VSERVER_MONITOR
21502 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21504 +#define VXM_SIZE 64
21507 +struct _vx_monitor {
21508 + unsigned int counter;
21510 + struct _vx_mon_entry entry[VXM_SIZE+1];
21514 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21516 +unsigned volatile int vxm_active = 1;
21518 +static atomic_t sequence = ATOMIC_INIT(0);
21523 + * requires disabled preemption */
21525 +struct _vx_mon_entry *vxm_advance(int cpu)
21527 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21528 + struct _vx_mon_entry *entry;
21529 + unsigned int index;
21531 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21532 + entry = &mon->entry[index];
21534 + entry->ev.seq = atomic_inc_return(&sequence);
21535 + entry->ev.jif = jiffies;
21539 +EXPORT_SYMBOL_GPL(vxm_advance);
21542 +int do_read_monitor(struct __user _vx_mon_entry *data,
21543 + int cpu, uint32_t *index, uint32_t *count)
21545 + int pos, ret = 0;
21546 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21547 + int end = mon->counter;
21548 + int start = end - VXM_SIZE + 2;
21549 + int idx = *index;
21551 + /* special case: get current pos */
21557 + /* have we lost some data? */
21561 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21562 + struct _vx_mon_entry *entry =
21563 + &mon->entry[idx % VXM_SIZE];
21565 + /* send entry to userspace */
21566 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21570 + /* save new index and count */
21573 + return ret ? ret : (*index < end);
21576 +int vc_read_monitor(uint32_t id, void __user *data)
21578 + struct vcmd_read_monitor_v0 vc_data;
21581 + if (id >= NR_CPUS)
21584 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21587 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21588 + id, &vc_data.index, &vc_data.count);
21590 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21595 +#ifdef CONFIG_COMPAT
21597 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21599 + struct vcmd_read_monitor_v0_x32 vc_data;
21602 + if (id >= NR_CPUS)
21605 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21608 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21609 + compat_ptr(vc_data.data_ptr),
21610 + id, &vc_data.index, &vc_data.count);
21612 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21617 +#endif /* CONFIG_COMPAT */
21619 diff -NurpP --minimal linux-2.6.29/kernel/vserver/network.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/network.c
21620 --- linux-2.6.29/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
21621 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/network.c 2009-02-22 22:54:26.000000000 +0100
21624 + * linux/kernel/vserver/network.c
21626 + * Virtual Server: Network Support
21628 + * Copyright (C) 2003-2007 Herbert Pötzl
21630 + * V0.01 broken out from vcontext V0.05
21631 + * V0.02 cleaned up implementation
21632 + * V0.03 added equiv nx commands
21633 + * V0.04 switch to RCU based hash
21634 + * V0.05 and back to locking again
21635 + * V0.06 changed vcmds to nxi arg
21636 + * V0.07 have __create claim() the nxi
21640 +#include <linux/err.h>
21641 +#include <linux/slab.h>
21642 +#include <linux/rcupdate.h>
21644 +#include <linux/vs_network.h>
21645 +#include <linux/vs_pid.h>
21646 +#include <linux/vserver/network_cmd.h>
21649 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21650 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21652 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
21653 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
21656 +static int __init init_network(void)
21658 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
21659 + sizeof(struct nx_addr_v4), 0,
21660 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21661 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
21662 + sizeof(struct nx_addr_v6), 0,
21663 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21668 +/* __alloc_nx_addr_v4() */
21670 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
21672 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
21673 + nx_addr_v4_cachep, GFP_KERNEL);
21675 + if (!IS_ERR(nxa))
21676 + memset(nxa, 0, sizeof(*nxa));
21680 +/* __dealloc_nx_addr_v4() */
21682 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
21684 + kmem_cache_free(nx_addr_v4_cachep, nxa);
21687 +/* __dealloc_nx_addr_v4_all() */
21689 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21692 + struct nx_addr_v4 *next = nxa->next;
21694 + __dealloc_nx_addr_v4(nxa);
21700 +#ifdef CONFIG_IPV6
21702 +/* __alloc_nx_addr_v6() */
21704 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21706 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21707 + nx_addr_v6_cachep, GFP_KERNEL);
21709 + if (!IS_ERR(nxa))
21710 + memset(nxa, 0, sizeof(*nxa));
21714 +/* __dealloc_nx_addr_v6() */
21716 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21718 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21721 +/* __dealloc_nx_addr_v6_all() */
21723 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21726 + struct nx_addr_v6 *next = nxa->next;
21728 + __dealloc_nx_addr_v6(nxa);
21733 +#endif /* CONFIG_IPV6 */
21735 +/* __alloc_nx_info()
21737 + * allocate an initialized nx_info struct
21738 + * doesn't make it visible (hash) */
21740 +static struct nx_info *__alloc_nx_info(nid_t nid)
21742 + struct nx_info *new = NULL;
21744 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
21746 + /* would this benefit from a slab cache? */
21747 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
21751 + memset(new, 0, sizeof(struct nx_info));
21752 + new->nx_id = nid;
21753 + INIT_HLIST_NODE(&new->nx_hlist);
21754 + atomic_set(&new->nx_usecnt, 0);
21755 + atomic_set(&new->nx_tasks, 0);
21756 + new->nx_state = 0;
21758 + new->nx_flags = NXF_INIT_SET;
21760 + /* rest of init goes here */
21762 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
21763 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
21765 + vxdprintk(VXD_CBIT(nid, 0),
21766 + "alloc_nx_info(%d) = %p", nid, new);
21767 + atomic_inc(&nx_global_ctotal);
21771 +/* __dealloc_nx_info()
21773 + * final disposal of nx_info */
21775 +static void __dealloc_nx_info(struct nx_info *nxi)
21777 + vxdprintk(VXD_CBIT(nid, 0),
21778 + "dealloc_nx_info(%p)", nxi);
21780 + nxi->nx_hlist.next = LIST_POISON1;
21783 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21784 + BUG_ON(atomic_read(&nxi->nx_tasks));
21786 + __dealloc_nx_addr_v4_all(nxi->v4.next);
21788 + nxi->nx_state |= NXS_RELEASED;
21790 + atomic_dec(&nx_global_ctotal);
21793 +static void __shutdown_nx_info(struct nx_info *nxi)
21795 + nxi->nx_state |= NXS_SHUTDOWN;
21796 + vs_net_change(nxi, VSC_NETDOWN);
21799 +/* exported stuff */
21801 +void free_nx_info(struct nx_info *nxi)
21803 + /* context shutdown is mandatory */
21804 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
21806 + /* context must not be hashed */
21807 + BUG_ON(nxi->nx_state & NXS_HASHED);
21809 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21810 + BUG_ON(atomic_read(&nxi->nx_tasks));
21812 + __dealloc_nx_info(nxi);
21816 +void __nx_set_lback(struct nx_info *nxi)
21818 + int nid = nxi->nx_id;
21819 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
21821 + nxi->v4_lback.s_addr = lback;
21824 +extern int __nx_inet_add_lback(__be32 addr);
21825 +extern int __nx_inet_del_lback(__be32 addr);
21828 +/* hash table for nx_info hash */
21830 +#define NX_HASH_SIZE 13
21832 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
21834 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
21837 +static inline unsigned int __hashval(nid_t nid)
21839 + return (nid % NX_HASH_SIZE);
21844 +/* __hash_nx_info()
21846 + * add the nxi to the global hash table
21847 + * requires the hash_lock to be held */
21849 +static inline void __hash_nx_info(struct nx_info *nxi)
21851 + struct hlist_head *head;
21853 + vxd_assert_lock(&nx_info_hash_lock);
21854 + vxdprintk(VXD_CBIT(nid, 4),
21855 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
21857 + /* context must not be hashed */
21858 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
21860 + nxi->nx_state |= NXS_HASHED;
21861 + head = &nx_info_hash[__hashval(nxi->nx_id)];
21862 + hlist_add_head(&nxi->nx_hlist, head);
21863 + atomic_inc(&nx_global_cactive);
21866 +/* __unhash_nx_info()
21868 + * remove the nxi from the global hash table
21869 + * requires the hash_lock to be held */
21871 +static inline void __unhash_nx_info(struct nx_info *nxi)
21873 + vxd_assert_lock(&nx_info_hash_lock);
21874 + vxdprintk(VXD_CBIT(nid, 4),
21875 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
21876 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
21878 + /* context must be hashed */
21879 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
21880 + /* but without tasks */
21881 + BUG_ON(atomic_read(&nxi->nx_tasks));
21883 + nxi->nx_state &= ~NXS_HASHED;
21884 + hlist_del(&nxi->nx_hlist);
21885 + atomic_dec(&nx_global_cactive);
21889 +/* __lookup_nx_info()
21891 + * requires the hash_lock to be held
21892 + * doesn't increment the nx_refcnt */
21894 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
21896 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
21897 + struct hlist_node *pos;
21898 + struct nx_info *nxi;
21900 + vxd_assert_lock(&nx_info_hash_lock);
21901 + hlist_for_each(pos, head) {
21902 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21904 + if (nxi->nx_id == nid)
21909 + vxdprintk(VXD_CBIT(nid, 0),
21910 + "__lookup_nx_info(#%u): %p[#%u]",
21911 + nid, nxi, nxi ? nxi->nx_id : 0);
21916 +/* __create_nx_info()
21918 + * create the requested context
21919 + * get(), claim() and hash it */
21921 +static struct nx_info *__create_nx_info(int id)
21923 + struct nx_info *new, *nxi = NULL;
21925 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21927 + if (!(new = __alloc_nx_info(id)))
21928 + return ERR_PTR(-ENOMEM);
21930 + /* required to make dynamic xids unique */
21931 + spin_lock(&nx_info_hash_lock);
21933 + /* static context requested */
21934 + if ((nxi = __lookup_nx_info(id))) {
21935 + vxdprintk(VXD_CBIT(nid, 0),
21936 + "create_nx_info(%d) = %p (already there)", id, nxi);
21937 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21938 + nxi = ERR_PTR(-EBUSY);
21940 + nxi = ERR_PTR(-EEXIST);
21943 + /* new context */
21944 + vxdprintk(VXD_CBIT(nid, 0),
21945 + "create_nx_info(%d) = %p (new)", id, new);
21946 + claim_nx_info(new, NULL);
21947 + __nx_set_lback(new);
21948 + __hash_nx_info(get_nx_info(new));
21949 + nxi = new, new = NULL;
21952 + spin_unlock(&nx_info_hash_lock);
21954 + __dealloc_nx_info(new);
21960 +/* exported stuff */
21963 +void unhash_nx_info(struct nx_info *nxi)
21965 + __shutdown_nx_info(nxi);
21966 + spin_lock(&nx_info_hash_lock);
21967 + __unhash_nx_info(nxi);
21968 + spin_unlock(&nx_info_hash_lock);
21971 +/* lookup_nx_info()
21973 + * search for a nx_info and get() it
21974 + * negative id means current */
21976 +struct nx_info *lookup_nx_info(int id)
21978 + struct nx_info *nxi = NULL;
21981 + nxi = get_nx_info(current->nx_info);
21982 + } else if (id > 1) {
21983 + spin_lock(&nx_info_hash_lock);
21984 + nxi = get_nx_info(__lookup_nx_info(id));
21985 + spin_unlock(&nx_info_hash_lock);
21990 +/* nid_is_hashed()
21992 + * verify that nid is still hashed */
21994 +int nid_is_hashed(nid_t nid)
21998 + spin_lock(&nx_info_hash_lock);
21999 + hashed = (__lookup_nx_info(nid) != NULL);
22000 + spin_unlock(&nx_info_hash_lock);
22005 +#ifdef CONFIG_PROC_FS
22009 + * get a subset of hashed nids for proc
22010 + * assumes size is at least one */
22012 +int get_nid_list(int index, unsigned int *nids, int size)
22014 + int hindex, nr_nids = 0;
22016 + /* only show current and children */
22017 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22020 + nids[nr_nids] = nx_current_nid();
22024 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22025 + struct hlist_head *head = &nx_info_hash[hindex];
22026 + struct hlist_node *pos;
22028 + spin_lock(&nx_info_hash_lock);
22029 + hlist_for_each(pos, head) {
22030 + struct nx_info *nxi;
22035 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22036 + nids[nr_nids] = nxi->nx_id;
22037 + if (++nr_nids >= size) {
22038 + spin_unlock(&nx_info_hash_lock);
22042 + /* keep the lock time short */
22043 + spin_unlock(&nx_info_hash_lock);
22052 + * migrate task to new network
22053 + * gets nxi, puts old_nxi on change
22056 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22058 + struct nx_info *old_nxi;
22064 + vxdprintk(VXD_CBIT(nid, 5),
22065 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22066 + p, nxi, nxi->nx_id,
22067 + atomic_read(&nxi->nx_usecnt),
22068 + atomic_read(&nxi->nx_tasks));
22070 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22071 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22074 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22077 + /* maybe disallow this completely? */
22078 + old_nxi = task_get_nx_info(p);
22079 + if (old_nxi == nxi)
22084 + clr_nx_info(&p->nx_info);
22085 + claim_nx_info(nxi, p);
22086 + set_nx_info(&p->nx_info, nxi);
22087 + p->nid = nxi->nx_id;
22090 + vxdprintk(VXD_CBIT(nid, 5),
22091 + "moved task %p into nxi:%p[#%d]",
22092 + p, nxi, nxi->nx_id);
22095 + release_nx_info(old_nxi, p);
22098 + put_nx_info(old_nxi);
22103 +void nx_set_persistent(struct nx_info *nxi)
22105 + vxdprintk(VXD_CBIT(nid, 6),
22106 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22108 + get_nx_info(nxi);
22109 + claim_nx_info(nxi, NULL);
22112 +void nx_clear_persistent(struct nx_info *nxi)
22114 + vxdprintk(VXD_CBIT(nid, 6),
22115 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22117 + release_nx_info(nxi, NULL);
22118 + put_nx_info(nxi);
22121 +void nx_update_persistent(struct nx_info *nxi)
22123 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22124 + nx_set_persistent(nxi);
22126 + nx_clear_persistent(nxi);
22129 +/* vserver syscall commands below here */
22131 +/* taks nid and nx_info functions */
22133 +#include <asm/uaccess.h>
22136 +int vc_task_nid(uint32_t id)
22141 + struct task_struct *tsk;
22143 + read_lock(&tasklist_lock);
22144 + tsk = find_task_by_real_pid(id);
22145 + nid = (tsk) ? tsk->nid : -ESRCH;
22146 + read_unlock(&tasklist_lock);
22148 + nid = nx_current_nid();
22153 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22155 + struct vcmd_nx_info_v0 vc_data;
22157 + vc_data.nid = nxi->nx_id;
22159 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22165 +/* network functions */
22167 +int vc_net_create(uint32_t nid, void __user *data)
22169 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22170 + struct nx_info *new_nxi;
22173 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22176 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22179 + new_nxi = __create_nx_info(nid);
22180 + if (IS_ERR(new_nxi))
22181 + return PTR_ERR(new_nxi);
22183 + /* initial flags */
22184 + new_nxi->nx_flags = vc_data.flagword;
22187 + if (vs_net_change(new_nxi, VSC_NETUP))
22190 + ret = nx_migrate_task(current, new_nxi);
22194 + /* return context id on success */
22195 + ret = new_nxi->nx_id;
22197 + /* get a reference for persistent contexts */
22198 + if ((vc_data.flagword & NXF_PERSISTENT))
22199 + nx_set_persistent(new_nxi);
22201 + release_nx_info(new_nxi, NULL);
22202 + put_nx_info(new_nxi);
22207 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22209 + return nx_migrate_task(current, nxi);
22214 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22215 + uint16_t type, uint16_t flags)
22217 + struct nx_addr_v4 *nxa = &nxi->v4;
22219 + if (NX_IPV4(nxi)) {
22220 + /* locate last entry */
22221 + for (; nxa->next; nxa = nxa->next);
22222 + nxa->next = __alloc_nx_addr_v4();
22226 + return PTR_ERR(nxa);
22229 + if (nxi->v4.next)
22230 + /* remove single ip for ip list */
22231 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22233 + nxa->ip[0].s_addr = ip;
22234 + nxa->ip[1].s_addr = ip2;
22235 + nxa->mask.s_addr = mask;
22236 + nxa->type = type;
22237 + nxa->flags = flags;
22242 +int vc_net_add(struct nx_info *nxi, void __user *data)
22244 + struct vcmd_net_addr_v0 vc_data;
22245 + int index, ret = 0;
22247 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22250 + switch (vc_data.type) {
22251 + case NXA_TYPE_IPV4:
22252 + if ((vc_data.count < 1) || (vc_data.count > 4))
22256 + while (index < vc_data.count) {
22257 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22258 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22266 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22267 + nxi->v4_bcast = vc_data.ip[0];
22271 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22272 + nxi->v4_lback = vc_data.ip[0];
22283 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22285 + struct vcmd_net_addr_v0 vc_data;
22287 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22290 + switch (vc_data.type) {
22291 + case NXA_TYPE_ANY:
22292 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22293 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22303 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22305 + struct vcmd_net_addr_ipv4_v1 vc_data;
22307 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22310 + switch (vc_data.type) {
22311 + case NXA_TYPE_ADDR:
22312 + case NXA_TYPE_RANGE:
22313 + case NXA_TYPE_MASK:
22314 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22315 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22317 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22318 + nxi->v4_bcast = vc_data.ip;
22321 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22322 + nxi->v4_lback = vc_data.ip;
22331 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
22333 + struct vcmd_net_addr_ipv4_v1 vc_data;
22335 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22338 + switch (vc_data.type) {
22339 +/* case NXA_TYPE_ADDR:
22342 + case NXA_TYPE_ANY:
22343 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22344 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22354 +#ifdef CONFIG_IPV6
22356 +int do_add_v6_addr(struct nx_info *nxi,
22357 + struct in6_addr *ip, struct in6_addr *mask,
22358 + uint32_t prefix, uint16_t type, uint16_t flags)
22360 + struct nx_addr_v6 *nxa = &nxi->v6;
22362 + if (NX_IPV6(nxi)) {
22363 + /* locate last entry */
22364 + for (; nxa->next; nxa = nxa->next);
22365 + nxa->next = __alloc_nx_addr_v6();
22369 + return PTR_ERR(nxa);
22373 + nxa->mask = *mask;
22374 + nxa->prefix = prefix;
22375 + nxa->type = type;
22376 + nxa->flags = flags;
22381 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
22383 + struct vcmd_net_addr_ipv6_v1 vc_data;
22385 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22388 + switch (vc_data.type) {
22389 + case NXA_TYPE_ADDR:
22390 + case NXA_TYPE_MASK:
22391 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
22392 + vc_data.prefix, vc_data.type, vc_data.flags);
22399 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
22401 + struct vcmd_net_addr_ipv6_v1 vc_data;
22403 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22406 + switch (vc_data.type) {
22407 + case NXA_TYPE_ANY:
22408 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
22409 + memset(&nxi->v6, 0, sizeof(nxi->v6));
22418 +#endif /* CONFIG_IPV6 */
22421 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22423 + struct vcmd_net_flags_v0 vc_data;
22425 + vc_data.flagword = nxi->nx_flags;
22427 + /* special STATE flag handling */
22428 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22430 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22435 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22437 + struct vcmd_net_flags_v0 vc_data;
22438 + uint64_t mask, trigger;
22440 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22443 + /* special STATE flag handling */
22444 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22445 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22447 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22448 + vc_data.flagword, mask);
22449 + if (trigger & NXF_PERSISTENT)
22450 + nx_update_persistent(nxi);
22455 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22457 + struct vcmd_net_caps_v0 vc_data;
22459 + vc_data.ncaps = nxi->nx_ncaps;
22460 + vc_data.cmask = ~0ULL;
22462 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22467 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22469 + struct vcmd_net_caps_v0 vc_data;
22471 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22474 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22475 + vc_data.ncaps, vc_data.cmask);
22480 +#include <linux/module.h>
22482 +module_init(init_network);
22484 +EXPORT_SYMBOL_GPL(free_nx_info);
22485 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22487 diff -NurpP --minimal linux-2.6.29/kernel/vserver/proc.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/proc.c
22488 --- linux-2.6.29/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22489 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/proc.c 2009-02-22 22:54:26.000000000 +0100
22492 + * linux/kernel/vserver/proc.c
22494 + * Virtual Context Support
22496 + * Copyright (C) 2003-2007 Herbert Pötzl
22498 + * V0.01 basic structure
22499 + * V0.02 adaptation vs1.3.0
22500 + * V0.03 proc permissions
22501 + * V0.04 locking/generic
22502 + * V0.05 next generation procfs
22503 + * V0.06 inode validation
22504 + * V0.07 generic rewrite vid
22505 + * V0.08 remove inode type
22509 +#include <linux/proc_fs.h>
22510 +#include <asm/unistd.h>
22512 +#include <linux/vs_context.h>
22513 +#include <linux/vs_network.h>
22514 +#include <linux/vs_cvirt.h>
22516 +#include <linux/in.h>
22517 +#include <linux/inetdevice.h>
22518 +#include <linux/vs_inet.h>
22519 +#include <linux/vs_inet6.h>
22521 +#include <linux/vserver/global.h>
22523 +#include "cvirt_proc.h"
22524 +#include "cacct_proc.h"
22525 +#include "limit_proc.h"
22526 +#include "sched_proc.h"
22527 +#include "vci_config.h"
22530 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22534 + CAP_FOR_EACH_U32(__capi) {
22535 + buffer += sprintf(buffer, "%08x",
22536 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22542 +static struct proc_dir_entry *proc_virtual;
22544 +static struct proc_dir_entry *proc_virtnet;
22547 +/* first the actual feeds */
22550 +static int proc_vci(char *buffer)
22552 + return sprintf(buffer,
22553 + "VCIVersion:\t%04x:%04x\n"
22554 + "VCISyscall:\t%d\n"
22555 + "VCIKernel:\t%08x\n",
22556 + VCI_VERSION >> 16,
22557 + VCI_VERSION & 0xFFFF,
22559 + vci_kernel_config());
22562 +static int proc_virtual_info(char *buffer)
22564 + return proc_vci(buffer);
22567 +static int proc_virtual_status(char *buffer)
22569 + return sprintf(buffer,
22571 + "#CActive:\t%d\n"
22572 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
22573 + atomic_read(&vx_global_ctotal),
22574 + atomic_read(&vx_global_cactive),
22575 + atomic_read(&vs_global_nsproxy),
22576 + atomic_read(&vs_global_fs),
22577 + atomic_read(&vs_global_mnt_ns),
22578 + atomic_read(&vs_global_uts_ns),
22579 + atomic_read(&vs_global_ipc_ns),
22580 + atomic_read(&vs_global_user_ns),
22581 + atomic_read(&vs_global_pid_ns));
22585 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22589 + length = sprintf(buffer,
22597 + vxi->vx_badness_bias);
22601 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22603 + char *orig = buffer;
22605 + buffer += sprintf(buffer,
22608 + "Flags:\t%016llx\n",
22609 + atomic_read(&vxi->vx_usecnt),
22610 + atomic_read(&vxi->vx_tasks),
22611 + (unsigned long long)vxi->vx_flags);
22613 + buffer += sprintf(buffer, "BCaps:\t");
22614 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22615 + buffer += sprintf(buffer, "\n");
22617 + buffer += sprintf(buffer,
22618 + "CCaps:\t%016llx\n"
22619 + "Spaces:\t%08lx %08lx\n",
22620 + (unsigned long long)vxi->vx_ccaps,
22621 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
22622 + return buffer - orig;
22625 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22627 + return vx_info_proc_limit(&vxi->limit, buffer);
22630 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22634 + length = vx_info_proc_sched(&vxi->sched, buffer);
22635 + for_each_online_cpu(cpu) {
22636 + length += vx_info_proc_sched_pc(
22637 + &vx_per_cpu(vxi, sched_pc, cpu),
22638 + buffer + length, cpu);
22643 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
22645 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
22648 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
22650 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
22653 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22657 + vx_update_load(vxi);
22658 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22659 + for_each_online_cpu(cpu) {
22660 + length += vx_info_proc_cvirt_pc(
22661 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22662 + buffer + length, cpu);
22667 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22669 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22673 +static int proc_virtnet_info(char *buffer)
22675 + return proc_vci(buffer);
22678 +static int proc_virtnet_status(char *buffer)
22680 + return sprintf(buffer,
22682 + "#CActive:\t%d\n",
22683 + atomic_read(&nx_global_ctotal),
22684 + atomic_read(&nx_global_cactive));
22687 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22689 + struct nx_addr_v4 *v4a;
22690 +#ifdef CONFIG_IPV6
22691 + struct nx_addr_v6 *v6a;
22695 + length = sprintf(buffer,
22698 + "Bcast:\t" NIPQUAD_FMT "\n"
22699 + "Lback:\t" NIPQUAD_FMT "\n",
22702 + NIPQUAD(nxi->v4_bcast.s_addr),
22703 + NIPQUAD(nxi->v4_lback.s_addr));
22705 + if (!NX_IPV4(nxi))
22707 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22708 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22711 +#ifdef CONFIG_IPV6
22712 + if (!NX_IPV6(nxi))
22714 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22715 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22722 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22726 + length = sprintf(buffer,
22729 + "Flags:\t%016llx\n"
22730 + "NCaps:\t%016llx\n",
22731 + atomic_read(&nxi->nx_usecnt),
22732 + atomic_read(&nxi->nx_tasks),
22733 + (unsigned long long)nxi->nx_flags,
22734 + (unsigned long long)nxi->nx_ncaps);
22740 +/* here the inode helpers */
22746 + struct inode_operations *iop;
22747 + struct file_operations *fop;
22748 + union proc_op op;
22751 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
22753 + struct inode *inode = new_inode(sb);
22758 + inode->i_mode = p->mode;
22760 + inode->i_op = p->iop;
22762 + inode->i_fop = p->fop;
22764 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
22765 + inode->i_flags |= S_IMMUTABLE;
22767 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
22769 + inode->i_uid = 0;
22770 + inode->i_gid = 0;
22771 + inode->i_tag = 0;
22776 +static struct dentry *vs_proc_instantiate(struct inode *dir,
22777 + struct dentry *dentry, int id, void *ptr)
22779 + struct vs_entry *p = ptr;
22780 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
22781 + struct dentry *error = ERR_PTR(-EINVAL);
22786 + PROC_I(inode)->op = p->op;
22787 + PROC_I(inode)->fd = id;
22788 + d_add(dentry, inode);
22796 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
22799 + * Fill a directory entry.
22801 + * If possible create the dcache entry and derive our inode number and
22802 + * file type from dcache entry.
22804 + * Since all of the proc inode numbers are dynamically generated, the inode
22805 + * numbers do not exist until the inode is cache. This means creating the
22806 + * the dcache entry in readdir is necessary to keep the inode numbers
22807 + * reported by readdir in sync with the inode numbers reported
22810 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
22811 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
22813 + struct dentry *child, *dir = filp->f_dentry;
22814 + struct inode *inode;
22815 + struct qstr qname;
22817 + unsigned type = DT_UNKNOWN;
22819 + qname.name = name;
22821 + qname.hash = full_name_hash(name, len);
22823 + child = d_lookup(dir, &qname);
22825 + struct dentry *new;
22826 + new = d_alloc(dir, &qname);
22828 + child = instantiate(dir->d_inode, new, id, ptr);
22835 + if (!child || IS_ERR(child) || !child->d_inode)
22836 + goto end_instantiate;
22837 + inode = child->d_inode;
22839 + ino = inode->i_ino;
22840 + type = inode->i_mode >> 12;
22845 + ino = find_inode_number(dir, &qname);
22848 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22853 +/* get and revalidate vx_info/xid */
22856 +struct vx_info *get_proc_vx_info(struct inode *inode)
22858 + return lookup_vx_info(PROC_I(inode)->fd);
22861 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22863 + struct inode *inode = dentry->d_inode;
22864 + xid_t xid = PROC_I(inode)->fd;
22866 + if (!xid || xid_is_hashed(xid))
22873 +/* get and revalidate nx_info/nid */
22875 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22877 + struct inode *inode = dentry->d_inode;
22878 + nid_t nid = PROC_I(inode)->fd;
22880 + if (!nid || nid_is_hashed(nid))
22888 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22890 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22891 + size_t count, loff_t *ppos)
22893 + struct inode *inode = file->f_dentry->d_inode;
22894 + unsigned long page;
22895 + ssize_t length = 0;
22897 + if (count > PROC_BLOCK_SIZE)
22898 + count = PROC_BLOCK_SIZE;
22900 + /* fade that out as soon as stable */
22901 + WARN_ON(PROC_I(inode)->fd);
22903 + if (!(page = __get_free_page(GFP_KERNEL)))
22906 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22907 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22910 + length = simple_read_from_buffer(buf, count, ppos,
22911 + (char *)page, length);
22917 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22918 + size_t count, loff_t *ppos)
22920 + struct inode *inode = file->f_dentry->d_inode;
22921 + struct vx_info *vxi = NULL;
22922 + xid_t xid = PROC_I(inode)->fd;
22923 + unsigned long page;
22924 + ssize_t length = 0;
22926 + if (count > PROC_BLOCK_SIZE)
22927 + count = PROC_BLOCK_SIZE;
22929 + /* fade that out as soon as stable */
22931 + vxi = lookup_vx_info(xid);
22935 + length = -ENOMEM;
22936 + if (!(page = __get_free_page(GFP_KERNEL)))
22939 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22940 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22943 + length = simple_read_from_buffer(buf, count, ppos,
22944 + (char *)page, length);
22948 + put_vx_info(vxi);
22953 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22954 + size_t count, loff_t *ppos)
22956 + struct inode *inode = file->f_dentry->d_inode;
22957 + struct nx_info *nxi = NULL;
22958 + nid_t nid = PROC_I(inode)->fd;
22959 + unsigned long page;
22960 + ssize_t length = 0;
22962 + if (count > PROC_BLOCK_SIZE)
22963 + count = PROC_BLOCK_SIZE;
22965 + /* fade that out as soon as stable */
22967 + nxi = lookup_nx_info(nid);
22971 + length = -ENOMEM;
22972 + if (!(page = __get_free_page(GFP_KERNEL)))
22975 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22976 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22979 + length = simple_read_from_buffer(buf, count, ppos,
22980 + (char *)page, length);
22984 + put_nx_info(nxi);
22991 +/* here comes the lower level */
22994 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22995 + .len = sizeof(NAME) - 1, \
22996 + .name = (NAME), \
23004 +#define DIR(NAME, MODE, OTYPE) \
23005 + NOD(NAME, (S_IFDIR | (MODE)), \
23006 + &proc_ ## OTYPE ## _inode_operations, \
23007 + &proc_ ## OTYPE ## _file_operations, { } )
23009 +#define INF(NAME, MODE, OTYPE) \
23010 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23011 + &proc_vs_info_file_operations, \
23012 + { .proc_vs_read = &proc_##OTYPE } )
23014 +#define VINF(NAME, MODE, OTYPE) \
23015 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23016 + &proc_vx_info_file_operations, \
23017 + { .proc_vxi_read = &proc_##OTYPE } )
23019 +#define NINF(NAME, MODE, OTYPE) \
23020 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23021 + &proc_nx_info_file_operations, \
23022 + { .proc_nxi_read = &proc_##OTYPE } )
23025 +static struct file_operations proc_vs_info_file_operations = {
23026 + .read = proc_vs_info_read,
23029 +static struct file_operations proc_vx_info_file_operations = {
23030 + .read = proc_vx_info_read,
23033 +static struct dentry_operations proc_xid_dentry_operations = {
23034 + .d_revalidate = proc_xid_revalidate,
23037 +static struct vs_entry vx_base_stuff[] = {
23038 + VINF("info", S_IRUGO, vxi_info),
23039 + VINF("status", S_IRUGO, vxi_status),
23040 + VINF("limit", S_IRUGO, vxi_limit),
23041 + VINF("sched", S_IRUGO, vxi_sched),
23042 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23043 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23044 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23045 + VINF("cacct", S_IRUGO, vxi_cacct),
23052 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23053 + struct dentry *dentry, int id, void *ptr)
23055 + dentry->d_op = &proc_xid_dentry_operations;
23056 + return vs_proc_instantiate(dir, dentry, id, ptr);
23059 +static struct dentry *proc_xid_lookup(struct inode *dir,
23060 + struct dentry *dentry, struct nameidata *nd)
23062 + struct vs_entry *p = vx_base_stuff;
23063 + struct dentry *error = ERR_PTR(-ENOENT);
23065 + for (; p->name; p++) {
23066 + if (p->len != dentry->d_name.len)
23068 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23074 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23079 +static int proc_xid_readdir(struct file *filp,
23080 + void *dirent, filldir_t filldir)
23082 + struct dentry *dentry = filp->f_dentry;
23083 + struct inode *inode = dentry->d_inode;
23084 + struct vs_entry *p = vx_base_stuff;
23085 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23089 + pos = filp->f_pos;
23092 + ino = inode->i_ino;
23093 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23096 + /* fall through */
23098 + ino = parent_ino(dentry);
23099 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23102 + /* fall through */
23105 + if (index >= size)
23107 + for (p += index; p->name; p++) {
23108 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23109 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23115 + filp->f_pos = pos;
23121 +static struct file_operations proc_nx_info_file_operations = {
23122 + .read = proc_nx_info_read,
23125 +static struct dentry_operations proc_nid_dentry_operations = {
23126 + .d_revalidate = proc_nid_revalidate,
23129 +static struct vs_entry nx_base_stuff[] = {
23130 + NINF("info", S_IRUGO, nxi_info),
23131 + NINF("status", S_IRUGO, nxi_status),
23136 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23137 + struct dentry *dentry, int id, void *ptr)
23139 + dentry->d_op = &proc_nid_dentry_operations;
23140 + return vs_proc_instantiate(dir, dentry, id, ptr);
23143 +static struct dentry *proc_nid_lookup(struct inode *dir,
23144 + struct dentry *dentry, struct nameidata *nd)
23146 + struct vs_entry *p = nx_base_stuff;
23147 + struct dentry *error = ERR_PTR(-ENOENT);
23149 + for (; p->name; p++) {
23150 + if (p->len != dentry->d_name.len)
23152 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23158 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23163 +static int proc_nid_readdir(struct file *filp,
23164 + void *dirent, filldir_t filldir)
23166 + struct dentry *dentry = filp->f_dentry;
23167 + struct inode *inode = dentry->d_inode;
23168 + struct vs_entry *p = nx_base_stuff;
23169 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23173 + pos = filp->f_pos;
23176 + ino = inode->i_ino;
23177 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23180 + /* fall through */
23182 + ino = parent_ino(dentry);
23183 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23186 + /* fall through */
23189 + if (index >= size)
23191 + for (p += index; p->name; p++) {
23192 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23193 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23199 + filp->f_pos = pos;
23204 +#define MAX_MULBY10 ((~0U - 9) / 10)
23206 +static inline int atovid(const char *str, int len)
23211 + while (len-- > 0) {
23216 + if (vid >= MAX_MULBY10)
23226 +/* now the upper level (virtual) */
23229 +static struct file_operations proc_xid_file_operations = {
23230 + .read = generic_read_dir,
23231 + .readdir = proc_xid_readdir,
23234 +static struct inode_operations proc_xid_inode_operations = {
23235 + .lookup = proc_xid_lookup,
23238 +static struct vs_entry vx_virtual_stuff[] = {
23239 + INF("info", S_IRUGO, virtual_info),
23240 + INF("status", S_IRUGO, virtual_status),
23241 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23245 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23246 + struct dentry *dentry, struct nameidata *nd)
23248 + struct vs_entry *p = vx_virtual_stuff;
23249 + struct dentry *error = ERR_PTR(-ENOENT);
23252 + for (; p->name; p++) {
23253 + if (p->len != dentry->d_name.len)
23255 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23259 + goto instantiate;
23261 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23262 + if ((id < 0) || !xid_is_hashed(id))
23266 + error = proc_xid_instantiate(dir, dentry, id, p);
23271 +static struct file_operations proc_nid_file_operations = {
23272 + .read = generic_read_dir,
23273 + .readdir = proc_nid_readdir,
23276 +static struct inode_operations proc_nid_inode_operations = {
23277 + .lookup = proc_nid_lookup,
23280 +static struct vs_entry nx_virtnet_stuff[] = {
23281 + INF("info", S_IRUGO, virtnet_info),
23282 + INF("status", S_IRUGO, virtnet_status),
23283 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23287 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23288 + struct dentry *dentry, struct nameidata *nd)
23290 + struct vs_entry *p = nx_virtnet_stuff;
23291 + struct dentry *error = ERR_PTR(-ENOENT);
23294 + for (; p->name; p++) {
23295 + if (p->len != dentry->d_name.len)
23297 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23301 + goto instantiate;
23303 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23304 + if ((id < 0) || !nid_is_hashed(id))
23308 + error = proc_nid_instantiate(dir, dentry, id, p);
23314 +#define PROC_MAXVIDS 32
23316 +int proc_virtual_readdir(struct file *filp,
23317 + void *dirent, filldir_t filldir)
23319 + struct dentry *dentry = filp->f_dentry;
23320 + struct inode *inode = dentry->d_inode;
23321 + struct vs_entry *p = vx_virtual_stuff;
23322 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23324 + unsigned int xid_array[PROC_MAXVIDS];
23325 + char buf[PROC_NUMBUF];
23326 + unsigned int nr_xids, i;
23329 + pos = filp->f_pos;
23332 + ino = inode->i_ino;
23333 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23336 + /* fall through */
23338 + ino = parent_ino(dentry);
23339 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23342 + /* fall through */
23345 + if (index >= size)
23347 + for (p += index; p->name; p++) {
23348 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23349 + vs_proc_instantiate, 0, p))
23354 + index = pos - size;
23355 + p = &vx_virtual_stuff[size - 1];
23356 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23357 + for (i = 0; i < nr_xids; i++) {
23358 + int n, xid = xid_array[i];
23359 + unsigned int j = PROC_NUMBUF;
23363 + buf[--j] = '0' + (n % 10);
23366 + if (proc_fill_cache(filp, dirent, filldir,
23367 + buf + j, PROC_NUMBUF - j,
23368 + vs_proc_instantiate, xid, p))
23374 + filp->f_pos = pos;
23378 +static int proc_virtual_getattr(struct vfsmount *mnt,
23379 + struct dentry *dentry, struct kstat *stat)
23381 + struct inode *inode = dentry->d_inode;
23383 + generic_fillattr(inode, stat);
23384 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23388 +static struct file_operations proc_virtual_dir_operations = {
23389 + .read = generic_read_dir,
23390 + .readdir = proc_virtual_readdir,
23393 +static struct inode_operations proc_virtual_dir_inode_operations = {
23394 + .getattr = proc_virtual_getattr,
23395 + .lookup = proc_virtual_lookup,
23402 +int proc_virtnet_readdir(struct file *filp,
23403 + void *dirent, filldir_t filldir)
23405 + struct dentry *dentry = filp->f_dentry;
23406 + struct inode *inode = dentry->d_inode;
23407 + struct vs_entry *p = nx_virtnet_stuff;
23408 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23410 + unsigned int nid_array[PROC_MAXVIDS];
23411 + char buf[PROC_NUMBUF];
23412 + unsigned int nr_nids, i;
23415 + pos = filp->f_pos;
23418 + ino = inode->i_ino;
23419 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23422 + /* fall through */
23424 + ino = parent_ino(dentry);
23425 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23428 + /* fall through */
23431 + if (index >= size)
23433 + for (p += index; p->name; p++) {
23434 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23435 + vs_proc_instantiate, 0, p))
23440 + index = pos - size;
23441 + p = &nx_virtnet_stuff[size - 1];
23442 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23443 + for (i = 0; i < nr_nids; i++) {
23444 + int n, nid = nid_array[i];
23445 + unsigned int j = PROC_NUMBUF;
23449 + buf[--j] = '0' + (n % 10);
23452 + if (proc_fill_cache(filp, dirent, filldir,
23453 + buf + j, PROC_NUMBUF - j,
23454 + vs_proc_instantiate, nid, p))
23460 + filp->f_pos = pos;
23464 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23465 + struct dentry *dentry, struct kstat *stat)
23467 + struct inode *inode = dentry->d_inode;
23469 + generic_fillattr(inode, stat);
23470 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23474 +static struct file_operations proc_virtnet_dir_operations = {
23475 + .read = generic_read_dir,
23476 + .readdir = proc_virtnet_readdir,
23479 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23480 + .getattr = proc_virtnet_getattr,
23481 + .lookup = proc_virtnet_lookup,
23486 +void proc_vx_init(void)
23488 + struct proc_dir_entry *ent;
23490 + ent = proc_mkdir("virtual", 0);
23492 + ent->proc_fops = &proc_virtual_dir_operations;
23493 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23495 + proc_virtual = ent;
23497 + ent = proc_mkdir("virtnet", 0);
23499 + ent->proc_fops = &proc_virtnet_dir_operations;
23500 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23502 + proc_virtnet = ent;
23508 +/* per pid info */
23511 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23513 + struct vx_info *vxi;
23514 + char *orig = buffer;
23516 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23518 + vxi = task_get_vx_info(p);
23522 + buffer += sprintf(buffer, "BCaps:\t");
23523 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23524 + buffer += sprintf(buffer, "\n");
23525 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23526 + (unsigned long long)vxi->vx_ccaps);
23527 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23528 + (unsigned long long)vxi->vx_flags);
23529 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23531 + put_vx_info(vxi);
23533 + return buffer - orig;
23537 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23539 + struct nx_info *nxi;
23540 + struct nx_addr_v4 *v4a;
23541 +#ifdef CONFIG_IPV6
23542 + struct nx_addr_v6 *v6a;
23544 + char *orig = buffer;
23547 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23549 + nxi = task_get_nx_info(p);
23553 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23554 + (unsigned long long)nxi->nx_ncaps);
23555 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23556 + (unsigned long long)nxi->nx_flags);
23558 + buffer += sprintf(buffer,
23559 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23560 + NIPQUAD(nxi->v4_bcast.s_addr));
23561 + buffer += sprintf (buffer,
23562 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23563 + NIPQUAD(nxi->v4_lback.s_addr));
23564 + if (!NX_IPV4(nxi))
23566 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23567 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23570 +#ifdef CONFIG_IPV6
23571 + if (!NX_IPV6(nxi))
23573 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23574 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
23578 + put_nx_info(nxi);
23580 + return buffer - orig;
23583 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sched.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sched.c
23584 --- linux-2.6.29/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
23585 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sched.c 2009-02-22 22:54:26.000000000 +0100
23588 + * linux/kernel/vserver/sched.c
23590 + * Virtual Server: Scheduler Support
23592 + * Copyright (C) 2004-2007 Herbert Pötzl
23594 + * V0.01 adapted Sam Vilains version to 2.6.3
23595 + * V0.02 removed legacy interface
23596 + * V0.03 changed vcmds to vxi arg
23597 + * V0.04 removed older and legacy interfaces
23601 +#include <linux/vs_context.h>
23602 +#include <linux/vs_sched.h>
23603 +#include <linux/vserver/sched_cmd.h>
23605 +#include <asm/uaccess.h>
23608 +#define vxd_check_range(val, min, max) do { \
23609 + vxlprintk((val < min) || (val > max), \
23610 + "check_range(%ld,%ld,%ld)", \
23611 + (long)val, (long)min, (long)max, \
23612 + __FILE__, __LINE__); \
23616 +void vx_update_sched_param(struct _vx_sched *sched,
23617 + struct _vx_sched_pc *sched_pc)
23619 + unsigned int set_mask = sched->update_mask;
23621 + if (set_mask & VXSM_FILL_RATE)
23622 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23623 + if (set_mask & VXSM_INTERVAL)
23624 + sched_pc->interval[0] = sched->interval[0];
23625 + if (set_mask & VXSM_FILL_RATE2)
23626 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23627 + if (set_mask & VXSM_INTERVAL2)
23628 + sched_pc->interval[1] = sched->interval[1];
23629 + if (set_mask & VXSM_TOKENS)
23630 + sched_pc->tokens = sched->tokens;
23631 + if (set_mask & VXSM_TOKENS_MIN)
23632 + sched_pc->tokens_min = sched->tokens_min;
23633 + if (set_mask & VXSM_TOKENS_MAX)
23634 + sched_pc->tokens_max = sched->tokens_max;
23635 + if (set_mask & VXSM_PRIO_BIAS)
23636 + sched_pc->prio_bias = sched->prio_bias;
23638 + if (set_mask & VXSM_IDLE_TIME)
23639 + sched_pc->flags |= VXSF_IDLE_TIME;
23641 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23644 + sched_pc->norm_time = jiffies;
23649 + * recalculate the context's scheduling tokens
23651 + * ret > 0 : number of tokens available
23652 + * ret < 0 : on hold, check delta_min[]
23653 + * -1 only jiffies
23654 + * -2 also idle time
23657 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23658 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23662 + int flags = sched_pc->flags;
23664 + /* how much time did pass? */
23665 + delta = *norm_time - sched_pc->norm_time;
23666 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
23667 + vxd_check_range(delta, 0, INT_MAX);
23669 + if (delta >= sched_pc->interval[0]) {
23670 + long tokens, integral;
23672 + /* calc integral token part */
23673 + tokens = delta / sched_pc->interval[0];
23674 + integral = tokens * sched_pc->interval[0];
23675 + tokens *= sched_pc->fill_rate[0];
23676 +#ifdef CONFIG_VSERVER_HARDCPU
23677 + delta_min[0] = delta - integral;
23678 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23680 + /* advance time */
23681 + sched_pc->norm_time += delta;
23684 + sched_pc->tokens += tokens;
23685 + sched_pc->token_time += tokens;
23687 + delta_min[0] = delta;
23689 +#ifdef CONFIG_VSERVER_IDLETIME
23690 + if (!(flags & VXSF_IDLE_TIME))
23693 + /* how much was the idle skip? */
23694 + delta = *idle_time - sched_pc->idle_time;
23695 + vxd_check_range(delta, 0, INT_MAX);
23697 + if (delta >= sched_pc->interval[1]) {
23698 + long tokens, integral;
23700 + /* calc fair share token part */
23701 + tokens = delta / sched_pc->interval[1];
23702 + integral = tokens * sched_pc->interval[1];
23703 + tokens *= sched_pc->fill_rate[1];
23704 + delta_min[1] = delta - integral;
23705 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23707 + /* advance idle time */
23708 + sched_pc->idle_time += integral;
23711 + sched_pc->tokens += tokens;
23712 + sched_pc->token_time += tokens;
23714 + delta_min[1] = delta;
23718 + /* clip at maximum */
23719 + if (sched_pc->tokens > sched_pc->tokens_max)
23720 + sched_pc->tokens = sched_pc->tokens_max;
23721 + tokens = sched_pc->tokens;
23723 + if ((flags & VXSF_ONHOLD)) {
23724 + /* can we unhold? */
23725 + if (tokens >= sched_pc->tokens_min) {
23726 + flags &= ~VXSF_ONHOLD;
23727 + sched_pc->hold_ticks +=
23728 + *norm_time - sched_pc->onhold;
23732 + /* put on hold? */
23733 + if (tokens <= 0) {
23734 + flags |= VXSF_ONHOLD;
23735 + sched_pc->onhold = *norm_time;
23739 + sched_pc->flags = flags;
23743 + tokens = sched_pc->tokens_min - tokens;
23744 + sched_pc->flags = flags;
23745 + // BUG_ON(tokens < 0); probably doesn't hold anymore
23747 +#ifdef CONFIG_VSERVER_HARDCPU
23748 + /* next interval? */
23749 + if (!sched_pc->fill_rate[0])
23750 + delta_min[0] = HZ;
23751 + else if (tokens > sched_pc->fill_rate[0])
23752 + delta_min[0] += sched_pc->interval[0] *
23753 + tokens / sched_pc->fill_rate[0];
23755 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
23756 + vxd_check_range(delta_min[0], 0, INT_MAX);
23758 +#ifdef CONFIG_VSERVER_IDLETIME
23759 + if (!(flags & VXSF_IDLE_TIME))
23762 + /* next interval? */
23763 + if (!sched_pc->fill_rate[1])
23764 + delta_min[1] = HZ;
23765 + else if (tokens > sched_pc->fill_rate[1])
23766 + delta_min[1] += sched_pc->interval[1] *
23767 + tokens / sched_pc->fill_rate[1];
23769 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
23770 + vxd_check_range(delta_min[1], 0, INT_MAX);
23775 +#endif /* CONFIG_VSERVER_IDLETIME */
23778 +#endif /* CONFIG_VSERVER_HARDCPU */
23781 +static inline unsigned long msec_to_ticks(unsigned long msec)
23783 + return msecs_to_jiffies(msec);
23786 +static inline unsigned long ticks_to_msec(unsigned long ticks)
23788 + return jiffies_to_msecs(ticks);
23791 +static inline unsigned long ticks_to_usec(unsigned long ticks)
23793 + return jiffies_to_usecs(ticks);
23797 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
23799 + unsigned int set_mask = data->mask;
23800 + unsigned int update_mask;
23803 + /* Sanity check data values */
23804 + if (data->tokens_max <= 0)
23805 + data->tokens_max = HZ;
23806 + if (data->tokens_min < 0)
23807 + data->tokens_min = HZ / 3;
23808 + if (data->tokens_min >= data->tokens_max)
23809 + data->tokens_min = data->tokens_max;
23811 + if (data->prio_bias > MAX_PRIO_BIAS)
23812 + data->prio_bias = MAX_PRIO_BIAS;
23813 + if (data->prio_bias < MIN_PRIO_BIAS)
23814 + data->prio_bias = MIN_PRIO_BIAS;
23816 + spin_lock(&vxi->sched.tokens_lock);
23818 + /* sync up on delayed updates */
23819 + for_each_cpu_mask(cpu, vxi->sched.update)
23820 + vx_update_sched_param(&vxi->sched,
23821 + &vx_per_cpu(vxi, sched_pc, cpu));
23823 + if (set_mask & VXSM_FILL_RATE)
23824 + vxi->sched.fill_rate[0] = data->fill_rate[0];
23825 + if (set_mask & VXSM_FILL_RATE2)
23826 + vxi->sched.fill_rate[1] = data->fill_rate[1];
23827 + if (set_mask & VXSM_INTERVAL)
23828 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
23829 + msec_to_ticks(data->interval[0]) : data->interval[0];
23830 + if (set_mask & VXSM_INTERVAL2)
23831 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
23832 + msec_to_ticks(data->interval[1]) : data->interval[1];
23833 + if (set_mask & VXSM_TOKENS)
23834 + vxi->sched.tokens = data->tokens;
23835 + if (set_mask & VXSM_TOKENS_MIN)
23836 + vxi->sched.tokens_min = data->tokens_min;
23837 + if (set_mask & VXSM_TOKENS_MAX)
23838 + vxi->sched.tokens_max = data->tokens_max;
23839 + if (set_mask & VXSM_PRIO_BIAS)
23840 + vxi->sched.prio_bias = data->prio_bias;
23842 + /* Sanity check rate/interval */
23843 + for (i = 0; i < 2; i++) {
23844 + if (data->fill_rate[i] < 0)
23845 + data->fill_rate[i] = 0;
23846 + if (data->interval[i] <= 0)
23847 + data->interval[i] = HZ;
23850 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
23851 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
23852 + vxi->sched.update_mask = update_mask;
23856 + if (set_mask & VXSM_CPU_ID) {
23857 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
23858 + cpus_and(vxi->sched.update, cpu_online_map,
23859 + vxi->sched.update);
23861 + vxi->sched.update = cpu_online_map;
23863 + /* forced reload? */
23864 + if (set_mask & VXSM_FORCE) {
23865 + for_each_cpu_mask(cpu, vxi->sched.update)
23866 + vx_update_sched_param(&vxi->sched,
23867 + &vx_per_cpu(vxi, sched_pc, cpu));
23868 + vxi->sched.update = CPU_MASK_NONE;
23871 + /* on UP we update immediately */
23872 + vx_update_sched_param(&vxi->sched,
23873 + &vx_per_cpu(vxi, sched_pc, 0));
23876 + spin_unlock(&vxi->sched.tokens_lock);
23881 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
23882 +#define COPY_PRI(C) C(prio_bias)
23883 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23884 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23885 + C(fill_rate[1]); C(interval[1]);
23887 +#define COPY_VALUE(name) vc_data.name = data->name
23889 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
23891 + struct vcmd_sched_v5 vc_data;
23893 + vc_data.mask = data->set_mask;
23894 + COPY_IDS(COPY_VALUE);
23895 + COPY_PRI(COPY_VALUE);
23896 + COPY_TOK(COPY_VALUE);
23897 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
23898 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
23899 + return do_set_sched(vxi, &vc_data);
23902 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
23904 + struct vcmd_set_sched_v4 vc_data;
23906 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23909 + return do_set_sched_v4(vxi, &vc_data);
23912 + /* latest interface is v5 */
23914 +int vc_set_sched(struct vx_info *vxi, void __user *data)
23916 + struct vcmd_sched_v5 vc_data;
23918 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23921 + return do_set_sched(vxi, &vc_data);
23925 +#define COPY_PRI(C) C(prio_bias)
23926 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23927 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23928 + C(fill_rate[1]); C(interval[1]);
23930 +#define COPY_VALUE(name) vc_data.name = data->name
23933 +int vc_get_sched(struct vx_info *vxi, void __user *data)
23935 + struct vcmd_sched_v5 vc_data;
23937 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23940 + if (vc_data.mask & VXSM_CPU_ID) {
23941 + int cpu = vc_data.cpu_id;
23942 + struct _vx_sched_pc *data;
23944 + if (!cpu_possible(cpu))
23947 + data = &vx_per_cpu(vxi, sched_pc, cpu);
23948 + COPY_TOK(COPY_VALUE);
23949 + COPY_PRI(COPY_VALUE);
23950 + COPY_FRI(COPY_VALUE);
23952 + if (data->flags & VXSF_IDLE_TIME)
23953 + vc_data.mask |= VXSM_IDLE_TIME;
23955 + struct _vx_sched *data = &vxi->sched;
23957 + COPY_TOK(COPY_VALUE);
23958 + COPY_PRI(COPY_VALUE);
23959 + COPY_FRI(COPY_VALUE);
23962 + if (vc_data.mask & VXSM_MSEC) {
23963 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
23964 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
23967 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23973 +int vc_sched_info(struct vx_info *vxi, void __user *data)
23975 + struct vcmd_sched_info vc_data;
23978 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23981 + cpu = vc_data.cpu_id;
23982 + if (!cpu_possible(cpu))
23986 + struct _vx_sched_pc *sched_pc =
23987 + &vx_per_cpu(vxi, sched_pc, cpu);
23989 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
23990 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
23991 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
23992 + vc_data.vavavoom = sched_pc->vavavoom;
23994 + vc_data.token_usec = ticks_to_usec(1);
23996 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24001 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sched_init.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sched_init.h
24002 --- linux-2.6.29/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24003 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sched_init.h 2009-02-22 22:54:26.000000000 +0100
24006 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24008 + static struct lock_class_key tokens_lock_key;
24010 + /* scheduling; hard code starting values as constants */
24011 + sched->fill_rate[0] = 1;
24012 + sched->interval[0] = 4;
24013 + sched->fill_rate[1] = 1;
24014 + sched->interval[1] = 8;
24015 + sched->tokens = HZ >> 2;
24016 + sched->tokens_min = HZ >> 4;
24017 + sched->tokens_max = HZ >> 1;
24018 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24019 + sched->prio_bias = 0;
24021 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24025 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24027 + sched_pc->fill_rate[0] = 1;
24028 + sched_pc->interval[0] = 4;
24029 + sched_pc->fill_rate[1] = 1;
24030 + sched_pc->interval[1] = 8;
24031 + sched_pc->tokens = HZ >> 2;
24032 + sched_pc->tokens_min = HZ >> 4;
24033 + sched_pc->tokens_max = HZ >> 1;
24034 + sched_pc->prio_bias = 0;
24035 + sched_pc->vavavoom = 0;
24036 + sched_pc->token_time = 0;
24037 + sched_pc->idle_time = 0;
24038 + sched_pc->norm_time = jiffies;
24040 + sched_pc->user_ticks = 0;
24041 + sched_pc->sys_ticks = 0;
24042 + sched_pc->hold_ticks = 0;
24045 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24051 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24055 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sched_proc.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sched_proc.h
24056 --- linux-2.6.29/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24057 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sched_proc.h 2009-02-22 22:54:26.000000000 +0100
24059 +#ifndef _VX_SCHED_PROC_H
24060 +#define _VX_SCHED_PROC_H
24064 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24068 + length += sprintf(buffer,
24069 + "FillRate:\t%8d,%d\n"
24070 + "Interval:\t%8d,%d\n"
24071 + "TokensMin:\t%8d\n"
24072 + "TokensMax:\t%8d\n"
24073 + "PrioBias:\t%8d\n",
24074 + sched->fill_rate[0],
24075 + sched->fill_rate[1],
24076 + sched->interval[0],
24077 + sched->interval[1],
24078 + sched->tokens_min,
24079 + sched->tokens_max,
24080 + sched->prio_bias);
24085 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24086 + char *buffer, int cpu)
24090 + length += sprintf(buffer + length,
24091 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24092 + (unsigned long long)sched_pc->user_ticks,
24093 + (unsigned long long)sched_pc->sys_ticks,
24094 + (unsigned long long)sched_pc->hold_ticks,
24095 + sched_pc->token_time,
24096 + sched_pc->idle_time);
24097 + length += sprintf(buffer + length,
24098 + " %c%c %d %d %d %d/%d %d/%d",
24099 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24100 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24101 + sched_pc->tokens,
24102 + sched_pc->tokens_min,
24103 + sched_pc->tokens_max,
24104 + sched_pc->fill_rate[0],
24105 + sched_pc->interval[0],
24106 + sched_pc->fill_rate[1],
24107 + sched_pc->interval[1]);
24108 + length += sprintf(buffer + length,
24110 + sched_pc->prio_bias,
24111 + sched_pc->vavavoom);
24115 +#endif /* _VX_SCHED_PROC_H */
24116 diff -NurpP --minimal linux-2.6.29/kernel/vserver/signal.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/signal.c
24117 --- linux-2.6.29/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24118 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/signal.c 2009-02-22 22:54:26.000000000 +0100
24121 + * linux/kernel/vserver/signal.c
24123 + * Virtual Server: Signal Support
24125 + * Copyright (C) 2003-2007 Herbert Pötzl
24127 + * V0.01 broken out from vcontext V0.05
24128 + * V0.02 changed vcmds to vxi arg
24129 + * V0.03 adjusted siginfo for kill
24133 +#include <asm/uaccess.h>
24135 +#include <linux/vs_context.h>
24136 +#include <linux/vs_pid.h>
24137 +#include <linux/vserver/signal_cmd.h>
24140 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24142 + int retval, count = 0;
24143 + struct task_struct *p;
24144 + struct siginfo *sip = SEND_SIG_PRIV;
24147 + vxdprintk(VXD_CBIT(misc, 4),
24148 + "vx_info_kill(%p[#%d],%d,%d)*",
24149 + vxi, vxi->vx_id, pid, sig);
24150 + read_lock(&tasklist_lock);
24154 + for_each_process(p) {
24157 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24158 + (pid && vxi->vx_initpid == p->pid))
24161 + err = group_send_sig_info(sig, sip, p);
24163 + if (err != -EPERM)
24169 + if (vxi->vx_initpid) {
24170 + pid = vxi->vx_initpid;
24171 + /* for now, only SIGINT to private init ... */
24172 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24173 + /* ... as long as there are tasks left */
24174 + (atomic_read(&vxi->vx_tasks) > 1))
24177 + /* fallthrough */
24179 + p = find_task_by_real_pid(pid);
24181 + if (vx_task_xid(p) == vxi->vx_id)
24182 + retval = group_send_sig_info(sig, sip, p);
24186 + read_unlock(&tasklist_lock);
24187 + vxdprintk(VXD_CBIT(misc, 4),
24188 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24189 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24193 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24195 + struct vcmd_ctx_kill_v0 vc_data;
24197 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24200 + /* special check to allow guest shutdown */
24201 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24202 + /* forbid killall pid=0 when init is present */
24203 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24204 + (vc_data.pid > 1)))
24207 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24211 +static int __wait_exit(struct vx_info *vxi)
24213 + DECLARE_WAITQUEUE(wait, current);
24216 + add_wait_queue(&vxi->vx_wait, &wait);
24217 + set_current_state(TASK_INTERRUPTIBLE);
24220 + if (vx_info_state(vxi,
24221 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24223 + if (signal_pending(current)) {
24224 + ret = -ERESTARTSYS;
24231 + set_current_state(TASK_RUNNING);
24232 + remove_wait_queue(&vxi->vx_wait, &wait);
24238 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24240 + struct vcmd_wait_exit_v0 vc_data;
24243 + ret = __wait_exit(vxi);
24244 + vc_data.reboot_cmd = vxi->reboot_cmd;
24245 + vc_data.exit_code = vxi->exit_code;
24247 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24252 diff -NurpP --minimal linux-2.6.29/kernel/vserver/space.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/space.c
24253 --- linux-2.6.29/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24254 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/space.c 2009-03-31 23:05:11.000000000 +0200
24257 + * linux/kernel/vserver/space.c
24259 + * Virtual Server: Context Space Support
24261 + * Copyright (C) 2003-2007 Herbert Pötzl
24263 + * V0.01 broken out from context.c 0.07
24264 + * V0.02 added task locking for namespace
24265 + * V0.03 broken out vx_enter_namespace
24266 + * V0.04 added *space support and commands
24270 +#include <linux/utsname.h>
24271 +#include <linux/nsproxy.h>
24272 +#include <linux/err.h>
24273 +#include <asm/uaccess.h>
24275 +#include <linux/vs_context.h>
24276 +#include <linux/vserver/space.h>
24277 +#include <linux/vserver/space_cmd.h>
24279 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24280 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24281 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24282 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24283 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24284 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24285 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24288 +/* namespace functions */
24290 +#include <linux/mnt_namespace.h>
24291 +#include <linux/user_namespace.h>
24292 +#include <linux/pid_namespace.h>
24293 +#include <linux/ipc_namespace.h>
24294 +#include <net/net_namespace.h>
24297 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24298 + .mask = CLONE_FS |
24302 + /* CLONE_NEWUSER | */
24306 +static const struct vcmd_space_mask_v1 space_mask = {
24307 + .mask = CLONE_FS |
24311 + /* CLONE_NEWUSER | */
24312 +#ifdef CONFIG_PID_NS
24315 +#ifdef CONFIG_NET_NS
24321 +static const struct vcmd_space_mask_v1 default_space_mask = {
24322 + .mask = CLONE_FS |
24326 + /* CLONE_NEWUSER | */
24327 +#ifdef CONFIG_PID_NS
24334 + * build a new nsproxy mix
24335 + * assumes that both proxies are 'const'
24336 + * does not touch nsproxy refcounts
24337 + * will hold a reference on the result.
24340 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24341 + struct nsproxy *new_nsproxy, unsigned long mask)
24343 + struct mnt_namespace *old_ns;
24344 + struct uts_namespace *old_uts;
24345 + struct ipc_namespace *old_ipc;
24346 +#ifdef CONFIG_PID_NS
24347 + struct pid_namespace *old_pid;
24349 +#ifdef CONFIG_NET_NS
24350 + struct net *old_net;
24352 + struct nsproxy *nsproxy;
24354 + nsproxy = copy_nsproxy(old_nsproxy);
24358 + if (mask & CLONE_NEWNS) {
24359 + old_ns = nsproxy->mnt_ns;
24360 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24361 + if (nsproxy->mnt_ns)
24362 + get_mnt_ns(nsproxy->mnt_ns);
24366 + if (mask & CLONE_NEWUTS) {
24367 + old_uts = nsproxy->uts_ns;
24368 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24369 + if (nsproxy->uts_ns)
24370 + get_uts_ns(nsproxy->uts_ns);
24374 + if (mask & CLONE_NEWIPC) {
24375 + old_ipc = nsproxy->ipc_ns;
24376 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24377 + if (nsproxy->ipc_ns)
24378 + get_ipc_ns(nsproxy->ipc_ns);
24382 +#ifdef CONFIG_PID_NS
24383 + if (mask & CLONE_NEWPID) {
24384 + old_pid = nsproxy->pid_ns;
24385 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24386 + if (nsproxy->pid_ns)
24387 + get_pid_ns(nsproxy->pid_ns);
24391 +#ifdef CONFIG_NET_NS
24392 + if (mask & CLONE_NEWNET) {
24393 + old_net = nsproxy->net_ns;
24394 + nsproxy->net_ns = new_nsproxy->net_ns;
24395 + if (nsproxy->net_ns)
24396 + get_net(nsproxy->net_ns);
24401 + put_mnt_ns(old_ns);
24403 + put_uts_ns(old_uts);
24405 + put_ipc_ns(old_ipc);
24406 +#ifdef CONFIG_PID_NS
24408 + put_pid_ns(old_pid);
24410 +#ifdef CONFIG_NET_NS
24412 + put_net(old_net);
24420 + * merge two nsproxy structs into a new one.
24421 + * will hold a reference on the result.
24425 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24426 + struct nsproxy *proxy, unsigned long mask)
24428 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24434 + /* vs_mix_nsproxy returns with reference */
24435 + return vs_mix_nsproxy(old ? old : &null_proxy,
24438 + get_nsproxy(proxy);
24443 + * merge two fs structs into a new one.
24444 + * will take a reference on the result.
24448 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24449 + struct fs_struct *fs, unsigned long mask)
24451 + if (!(mask & CLONE_FS)) {
24453 + atomic_inc(&old->count);
24460 + return copy_fs_struct(fs);
24464 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24466 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24467 + struct fs_struct *fs, *fs_cur, *fs_new;
24470 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24471 + vxi, vxi->vx_id, mask, index);
24473 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24477 + mask = vxi->vx_nsmask[index];
24479 + if ((mask & vxi->vx_nsmask[index]) != mask)
24482 + proxy = vxi->vx_nsproxy[index];
24483 + fs = vxi->vx_fs[index];
24485 + task_lock(current);
24486 + fs_cur = current->fs;
24487 + atomic_inc(&fs_cur->count);
24488 + proxy_cur = current->nsproxy;
24489 + get_nsproxy(proxy_cur);
24490 + task_unlock(current);
24492 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24493 + if (IS_ERR(fs_new)) {
24494 + ret = PTR_ERR(fs_new);
24498 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24499 + if (IS_ERR(proxy_new)) {
24500 + ret = PTR_ERR(proxy_new);
24504 + fs_new = xchg(¤t->fs, fs_new);
24505 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24509 + put_nsproxy(proxy_new);
24512 + put_fs_struct(fs_new);
24515 + put_nsproxy(proxy_cur);
24517 + put_fs_struct(fs_cur);
24522 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24524 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24525 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24528 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24529 + vxi, vxi->vx_id, mask, index);
24532 + mask = default_space_mask.mask;
24534 + if ((mask & space_mask.mask) != mask)
24537 + proxy_vxi = vxi->vx_nsproxy[index];
24538 + fs_vxi = vxi->vx_fs[index];
24540 + task_lock(current);
24541 + fs_cur = current->fs;
24542 + atomic_inc(&fs_cur->count);
24543 + proxy_cur = current->nsproxy;
24544 + get_nsproxy(proxy_cur);
24545 + task_unlock(current);
24547 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24548 + if (IS_ERR(fs_new)) {
24549 + ret = PTR_ERR(fs_new);
24553 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24554 + if (IS_ERR(proxy_new)) {
24555 + ret = PTR_ERR(proxy_new);
24559 + fs_new = xchg(&vxi->vx_fs[index], fs_new);
24560 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
24561 + vxi->vx_nsmask[index] |= mask;
24565 + put_nsproxy(proxy_new);
24568 + put_fs_struct(fs_new);
24571 + put_nsproxy(proxy_cur);
24573 + put_fs_struct(fs_cur);
24578 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24580 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24582 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24585 + return vx_enter_space(vxi, vc_data.mask, 0);
24588 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24590 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24592 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24595 + if (vc_data.index >= VX_SPACES)
24598 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24601 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24603 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24605 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24608 + return vx_set_space(vxi, vc_data.mask, 0);
24611 +int vc_set_space(struct vx_info *vxi, void __user *data)
24613 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24615 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24618 + if (vc_data.index >= VX_SPACES)
24621 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
24624 +int vc_get_space_mask(void __user *data, int type)
24626 + const struct vcmd_space_mask_v1 *mask;
24629 + mask = &space_mask_v0;
24630 + else if (type == 1)
24631 + mask = &space_mask;
24633 + mask = &default_space_mask;
24635 + vxdprintk(VXD_CBIT(space, 10),
24636 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24638 + if (copy_to_user(data, mask, sizeof(*mask)))
24643 diff -NurpP --minimal linux-2.6.29/kernel/vserver/switch.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/switch.c
24644 --- linux-2.6.29/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24645 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/switch.c 2009-03-24 14:59:18.000000000 +0100
24648 + * linux/kernel/vserver/switch.c
24650 + * Virtual Server: Syscall Switch
24652 + * Copyright (C) 2003-2007 Herbert Pötzl
24654 + * V0.01 syscall switch
24655 + * V0.02 added signal to context
24656 + * V0.03 added rlimit functions
24657 + * V0.04 added iattr, task/xid functions
24658 + * V0.05 added debug/history stuff
24659 + * V0.06 added compat32 layer
24660 + * V0.07 vcmd args and perms
24661 + * V0.08 added status commands
24662 + * V0.09 added tag commands
24663 + * V0.10 added oom bias
24664 + * V0.11 added device commands
24668 +#include <linux/vs_context.h>
24669 +#include <linux/vs_network.h>
24670 +#include <linux/vserver/switch.h>
24672 +#include "vci_config.h"
24676 +int vc_get_version(uint32_t id)
24678 + return VCI_VERSION;
24682 +int vc_get_vci(uint32_t id)
24684 + return vci_kernel_config();
24687 +#include <linux/vserver/context_cmd.h>
24688 +#include <linux/vserver/cvirt_cmd.h>
24689 +#include <linux/vserver/cacct_cmd.h>
24690 +#include <linux/vserver/limit_cmd.h>
24691 +#include <linux/vserver/network_cmd.h>
24692 +#include <linux/vserver/sched_cmd.h>
24693 +#include <linux/vserver/debug_cmd.h>
24694 +#include <linux/vserver/inode_cmd.h>
24695 +#include <linux/vserver/dlimit_cmd.h>
24696 +#include <linux/vserver/signal_cmd.h>
24697 +#include <linux/vserver/space_cmd.h>
24698 +#include <linux/vserver/tag_cmd.h>
24699 +#include <linux/vserver/device_cmd.h>
24701 +#include <linux/vserver/inode.h>
24702 +#include <linux/vserver/dlimit.h>
24705 +#ifdef CONFIG_COMPAT
24706 +#define __COMPAT(name, id, data, compat) \
24707 + (compat) ? name ## _x32(id, data) : name(id, data)
24708 +#define __COMPAT_NO_ID(name, data, compat) \
24709 + (compat) ? name ## _x32(data) : name(data)
24711 +#define __COMPAT(name, id, data, compat) \
24713 +#define __COMPAT_NO_ID(name, data, compat) \
24719 +long do_vcmd(uint32_t cmd, uint32_t id,
24720 + struct vx_info *vxi, struct nx_info *nxi,
24721 + void __user *data, int compat)
24725 + case VCMD_get_version:
24726 + return vc_get_version(id);
24727 + case VCMD_get_vci:
24728 + return vc_get_vci(id);
24730 + case VCMD_task_xid:
24731 + return vc_task_xid(id);
24732 + case VCMD_vx_info:
24733 + return vc_vx_info(vxi, data);
24735 + case VCMD_task_nid:
24736 + return vc_task_nid(id);
24737 + case VCMD_nx_info:
24738 + return vc_nx_info(nxi, data);
24740 + case VCMD_task_tag:
24741 + return vc_task_tag(id);
24743 + case VCMD_set_space_v1:
24744 + return vc_set_space_v1(vxi, data);
24745 + /* this is version 2 */
24746 + case VCMD_set_space:
24747 + return vc_set_space(vxi, data);
24749 + case VCMD_get_space_mask_v0:
24750 + return vc_get_space_mask(data, 0);
24751 + /* this is version 1 */
24752 + case VCMD_get_space_mask:
24753 + return vc_get_space_mask(data, 1);
24755 + case VCMD_get_space_default:
24756 + return vc_get_space_mask(data, -1);
24758 +#ifdef CONFIG_IA32_EMULATION
24759 + case VCMD_get_rlimit:
24760 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24761 + case VCMD_set_rlimit:
24762 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24764 + case VCMD_get_rlimit:
24765 + return vc_get_rlimit(vxi, data);
24766 + case VCMD_set_rlimit:
24767 + return vc_set_rlimit(vxi, data);
24769 + case VCMD_get_rlimit_mask:
24770 + return vc_get_rlimit_mask(id, data);
24771 + case VCMD_reset_minmax:
24772 + return vc_reset_minmax(vxi, data);
24774 + case VCMD_get_vhi_name:
24775 + return vc_get_vhi_name(vxi, data);
24776 + case VCMD_set_vhi_name:
24777 + return vc_set_vhi_name(vxi, data);
24779 + case VCMD_ctx_stat:
24780 + return vc_ctx_stat(vxi, data);
24781 + case VCMD_virt_stat:
24782 + return vc_virt_stat(vxi, data);
24783 + case VCMD_sock_stat:
24784 + return vc_sock_stat(vxi, data);
24785 + case VCMD_rlimit_stat:
24786 + return vc_rlimit_stat(vxi, data);
24788 + case VCMD_set_cflags:
24789 + return vc_set_cflags(vxi, data);
24790 + case VCMD_get_cflags:
24791 + return vc_get_cflags(vxi, data);
24793 + /* this is version 1 */
24794 + case VCMD_set_ccaps:
24795 + return vc_set_ccaps(vxi, data);
24796 + /* this is version 1 */
24797 + case VCMD_get_ccaps:
24798 + return vc_get_ccaps(vxi, data);
24799 + case VCMD_set_bcaps:
24800 + return vc_set_bcaps(vxi, data);
24801 + case VCMD_get_bcaps:
24802 + return vc_get_bcaps(vxi, data);
24804 + case VCMD_set_badness:
24805 + return vc_set_badness(vxi, data);
24806 + case VCMD_get_badness:
24807 + return vc_get_badness(vxi, data);
24809 + case VCMD_set_nflags:
24810 + return vc_set_nflags(nxi, data);
24811 + case VCMD_get_nflags:
24812 + return vc_get_nflags(nxi, data);
24814 + case VCMD_set_ncaps:
24815 + return vc_set_ncaps(nxi, data);
24816 + case VCMD_get_ncaps:
24817 + return vc_get_ncaps(nxi, data);
24819 + case VCMD_set_sched_v4:
24820 + return vc_set_sched_v4(vxi, data);
24821 + /* this is version 5 */
24822 + case VCMD_set_sched:
24823 + return vc_set_sched(vxi, data);
24824 + case VCMD_get_sched:
24825 + return vc_get_sched(vxi, data);
24826 + case VCMD_sched_info:
24827 + return vc_sched_info(vxi, data);
24829 + case VCMD_add_dlimit:
24830 + return __COMPAT(vc_add_dlimit, id, data, compat);
24831 + case VCMD_rem_dlimit:
24832 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24833 + case VCMD_set_dlimit:
24834 + return __COMPAT(vc_set_dlimit, id, data, compat);
24835 + case VCMD_get_dlimit:
24836 + return __COMPAT(vc_get_dlimit, id, data, compat);
24838 + case VCMD_ctx_kill:
24839 + return vc_ctx_kill(vxi, data);
24841 + case VCMD_wait_exit:
24842 + return vc_wait_exit(vxi, data);
24844 + case VCMD_get_iattr:
24845 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24846 + case VCMD_set_iattr:
24847 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24849 + case VCMD_fget_iattr:
24850 + return vc_fget_iattr(id, data);
24851 + case VCMD_fset_iattr:
24852 + return vc_fset_iattr(id, data);
24854 + case VCMD_enter_space_v0:
24855 + return vc_enter_space_v1(vxi, NULL);
24856 + case VCMD_enter_space_v1:
24857 + return vc_enter_space_v1(vxi, data);
24858 + /* this is version 2 */
24859 + case VCMD_enter_space:
24860 + return vc_enter_space(vxi, data);
24862 + case VCMD_ctx_create_v0:
24863 + return vc_ctx_create(id, NULL);
24864 + case VCMD_ctx_create:
24865 + return vc_ctx_create(id, data);
24866 + case VCMD_ctx_migrate_v0:
24867 + return vc_ctx_migrate(vxi, NULL);
24868 + case VCMD_ctx_migrate:
24869 + return vc_ctx_migrate(vxi, data);
24871 + case VCMD_net_create_v0:
24872 + return vc_net_create(id, NULL);
24873 + case VCMD_net_create:
24874 + return vc_net_create(id, data);
24875 + case VCMD_net_migrate:
24876 + return vc_net_migrate(nxi, data);
24878 + case VCMD_tag_migrate:
24879 + return vc_tag_migrate(id);
24881 + case VCMD_net_add:
24882 + return vc_net_add(nxi, data);
24883 + case VCMD_net_remove:
24884 + return vc_net_remove(nxi, data);
24886 + case VCMD_net_add_ipv4:
24887 + return vc_net_add_ipv4(nxi, data);
24888 + case VCMD_net_remove_ipv4:
24889 + return vc_net_remove_ipv4(nxi, data);
24890 +#ifdef CONFIG_IPV6
24891 + case VCMD_net_add_ipv6:
24892 + return vc_net_add_ipv6(nxi, data);
24893 + case VCMD_net_remove_ipv6:
24894 + return vc_net_remove_ipv6(nxi, data);
24896 +/* case VCMD_add_match_ipv4:
24897 + return vc_add_match_ipv4(nxi, data);
24898 + case VCMD_get_match_ipv4:
24899 + return vc_get_match_ipv4(nxi, data);
24900 +#ifdef CONFIG_IPV6
24901 + case VCMD_add_match_ipv6:
24902 + return vc_add_match_ipv6(nxi, data);
24903 + case VCMD_get_match_ipv6:
24904 + return vc_get_match_ipv6(nxi, data);
24907 +#ifdef CONFIG_VSERVER_DEVICE
24908 + case VCMD_set_mapping:
24909 + return __COMPAT(vc_set_mapping, vxi, data, compat);
24910 + case VCMD_unset_mapping:
24911 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
24913 +#ifdef CONFIG_VSERVER_HISTORY
24914 + case VCMD_dump_history:
24915 + return vc_dump_history(id);
24916 + case VCMD_read_history:
24917 + return __COMPAT(vc_read_history, id, data, compat);
24919 +#ifdef CONFIG_VSERVER_MONITOR
24920 + case VCMD_read_monitor:
24921 + return __COMPAT(vc_read_monitor, id, data, compat);
24924 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
24925 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
24931 +#define __VCMD(vcmd, _perm, _args, _flags) \
24932 + case VCMD_ ## vcmd: perm = _perm; \
24933 + args = _args; flags = _flags; break
24936 +#define VCA_NONE 0x00
24937 +#define VCA_VXI 0x01
24938 +#define VCA_NXI 0x02
24940 +#define VCF_NONE 0x00
24941 +#define VCF_INFO 0x01
24942 +#define VCF_ADMIN 0x02
24943 +#define VCF_ARES 0x06 /* includes admin */
24944 +#define VCF_SETUP 0x08
24946 +#define VCF_ZIDOK 0x10 /* zero id okay */
24950 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
24953 + int permit = -1, state = 0;
24954 + int perm = -1, args = 0, flags = 0;
24955 + struct vx_info *vxi = NULL;
24956 + struct nx_info *nxi = NULL;
24959 + /* unpriviledged commands */
24960 + __VCMD(get_version, 0, VCA_NONE, 0);
24961 + __VCMD(get_vci, 0, VCA_NONE, 0);
24962 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
24963 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
24964 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
24965 + __VCMD(get_space_default,0, VCA_NONE, 0);
24967 + /* info commands */
24968 + __VCMD(task_xid, 2, VCA_NONE, 0);
24969 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
24970 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
24971 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
24972 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
24973 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
24974 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
24975 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
24976 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
24978 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
24979 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
24980 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
24981 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
24983 + __VCMD(task_nid, 2, VCA_NONE, 0);
24984 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
24985 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
24986 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
24988 + __VCMD(task_tag, 2, VCA_NONE, 0);
24990 + __VCMD(get_iattr, 2, VCA_NONE, 0);
24991 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
24992 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
24993 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
24994 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
24996 + /* lower admin commands */
24997 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
24998 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
24999 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25000 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25001 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25002 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25003 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25004 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25006 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25007 + __VCMD(net_create, 5, VCA_NONE, 0);
25008 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25010 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25012 + /* higher admin commands */
25013 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25014 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25015 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25017 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25018 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25019 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25020 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25022 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25023 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25024 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25025 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25027 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25028 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25029 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25030 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25031 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25032 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25033 +#ifdef CONFIG_IPV6
25034 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25035 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25037 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25038 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25039 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25040 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25041 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25043 +#ifdef CONFIG_VSERVER_DEVICE
25044 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25045 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25047 + /* debug level admin commands */
25048 +#ifdef CONFIG_VSERVER_HISTORY
25049 + __VCMD(dump_history, 9, VCA_NONE, 0);
25050 + __VCMD(read_history, 9, VCA_NONE, 0);
25052 +#ifdef CONFIG_VSERVER_MONITOR
25053 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25060 + vxdprintk(VXD_CBIT(switch, 0),
25061 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25062 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25063 + VC_VERSION(cmd), id, data, compat,
25064 + perm, args, flags);
25071 + if (!capable(CAP_CONTEXT))
25075 + /* moved here from the individual commands */
25077 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25081 + /* vcmd involves resource management */
25083 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25087 + /* various legacy exceptions */
25089 + /* will go away when spectator is a cap */
25090 + case VCMD_ctx_migrate_v0:
25091 + case VCMD_ctx_migrate:
25093 + current->xid = 1;
25099 + /* will go away when spectator is a cap */
25100 + case VCMD_net_migrate:
25102 + current->nid = 1;
25109 + /* vcmds are fine by default */
25112 + /* admin type vcmds require admin ... */
25113 + if (flags & VCF_ADMIN)
25114 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25116 + /* ... but setup type vcmds override that */
25117 + if (!permit && (flags & VCF_SETUP))
25118 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25126 + if (!id && (flags & VCF_ZIDOK))
25130 + if (args & VCA_VXI) {
25131 + vxi = lookup_vx_info(id);
25135 + if ((flags & VCF_ADMIN) &&
25136 + /* special case kill for shutdown */
25137 + (cmd != VCMD_ctx_kill) &&
25138 + /* can context be administrated? */
25139 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25145 + if (args & VCA_NXI) {
25146 + nxi = lookup_nx_info(id);
25150 + if ((flags & VCF_ADMIN) &&
25151 + /* can context be administrated? */
25152 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25159 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25162 + if ((args & VCA_NXI) && nxi)
25163 + put_nx_info(nxi);
25165 + if ((args & VCA_VXI) && vxi)
25166 + put_vx_info(vxi);
25168 + vxdprintk(VXD_CBIT(switch, 1),
25169 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25170 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25171 + VC_VERSION(cmd), ret, ret, state, permit);
25176 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25178 + return do_vserver(cmd, id, data, 0);
25181 +#ifdef CONFIG_COMPAT
25184 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25186 + return do_vserver(cmd, id, data, 1);
25189 +#endif /* CONFIG_COMPAT */
25190 diff -NurpP --minimal linux-2.6.29/kernel/vserver/sysctl.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sysctl.c
25191 --- linux-2.6.29/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25192 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/sysctl.c 2009-02-22 22:54:26.000000000 +0100
25195 + * kernel/vserver/sysctl.c
25197 + * Virtual Context Support
25199 + * Copyright (C) 2004-2007 Herbert Pötzl
25201 + * V0.01 basic structure
25205 +#include <linux/module.h>
25206 +#include <linux/ctype.h>
25207 +#include <linux/sysctl.h>
25208 +#include <linux/parser.h>
25209 +#include <asm/uaccess.h>
25213 + CTL_DEBUG_ERROR = 0,
25214 + CTL_DEBUG_SWITCH = 1,
25229 +unsigned int vx_debug_switch = 0;
25230 +unsigned int vx_debug_xid = 0;
25231 +unsigned int vx_debug_nid = 0;
25232 +unsigned int vx_debug_tag = 0;
25233 +unsigned int vx_debug_net = 0;
25234 +unsigned int vx_debug_limit = 0;
25235 +unsigned int vx_debug_cres = 0;
25236 +unsigned int vx_debug_dlim = 0;
25237 +unsigned int vx_debug_quota = 0;
25238 +unsigned int vx_debug_cvirt = 0;
25239 +unsigned int vx_debug_space = 0;
25240 +unsigned int vx_debug_misc = 0;
25243 +static struct ctl_table_header *vserver_table_header;
25244 +static ctl_table vserver_root_table[];
25247 +void vserver_register_sysctl(void)
25249 + if (!vserver_table_header) {
25250 + vserver_table_header = register_sysctl_table(vserver_root_table);
25255 +void vserver_unregister_sysctl(void)
25257 + if (vserver_table_header) {
25258 + unregister_sysctl_table(vserver_table_header);
25259 + vserver_table_header = NULL;
25264 +static int proc_dodebug(ctl_table *table, int write,
25265 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25267 + char tmpbuf[20], *p, c;
25268 + unsigned int value;
25269 + size_t left, len;
25271 + if ((*ppos && !write) || !*lenp) {
25279 + if (!access_ok(VERIFY_READ, buffer, left))
25281 + p = (char *)buffer;
25282 + while (left && __get_user(c, p) >= 0 && isspace(c))
25287 + if (left > sizeof(tmpbuf) - 1)
25289 + if (copy_from_user(tmpbuf, p, left))
25291 + tmpbuf[left] = '\0';
25293 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25294 + value = 10 * value + (*p - '0');
25295 + if (*p && !isspace(*p))
25297 + while (left && isspace(*p))
25299 + *(unsigned int *)table->data = value;
25301 + if (!access_ok(VERIFY_WRITE, buffer, left))
25303 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25306 + if (__copy_to_user(buffer, tmpbuf, len))
25308 + if ((left -= len) > 0) {
25309 + if (put_user('\n', (char *)buffer + len))
25323 +#define CTL_ENTRY(ctl, name) \
25325 + .ctl_name = ctl, \
25326 + .procname = #name, \
25327 + .data = &vx_ ## name, \
25328 + .maxlen = sizeof(int), \
25330 + .proc_handler = &proc_dodebug, \
25331 + .strategy = &sysctl_intvec, \
25332 + .extra1 = &zero, \
25335 +static ctl_table vserver_debug_table[] = {
25336 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25337 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25338 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25339 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25340 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25341 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25342 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25343 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25344 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25345 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25346 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25347 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25348 + { .ctl_name = 0 }
25351 +static ctl_table vserver_root_table[] = {
25353 + .ctl_name = CTL_VSERVER,
25354 + .procname = "vserver",
25356 + .child = vserver_debug_table
25358 + { .ctl_name = 0 }
25362 +static match_table_t tokens = {
25363 + { CTL_DEBUG_SWITCH, "switch=%x" },
25364 + { CTL_DEBUG_XID, "xid=%x" },
25365 + { CTL_DEBUG_NID, "nid=%x" },
25366 + { CTL_DEBUG_TAG, "tag=%x" },
25367 + { CTL_DEBUG_NET, "net=%x" },
25368 + { CTL_DEBUG_LIMIT, "limit=%x" },
25369 + { CTL_DEBUG_CRES, "cres=%x" },
25370 + { CTL_DEBUG_DLIM, "dlim=%x" },
25371 + { CTL_DEBUG_QUOTA, "quota=%x" },
25372 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25373 + { CTL_DEBUG_SPACE, "space=%x" },
25374 + { CTL_DEBUG_MISC, "misc=%x" },
25375 + { CTL_DEBUG_ERROR, NULL }
25378 +#define HANDLE_CASE(id, name, val) \
25379 + case CTL_DEBUG_ ## id: \
25380 + vx_debug_ ## name = val; \
25381 + printk("vs_debug_" #name "=0x%x\n", val); \
25385 +static int __init vs_debug_setup(char *str)
25390 + printk("vs_debug_setup(%s)\n", str);
25391 + while ((p = strsep(&str, ",")) != NULL) {
25392 + substring_t args[MAX_OPT_ARGS];
25393 + unsigned int value;
25398 + token = match_token(p, tokens, args);
25399 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25402 + HANDLE_CASE(SWITCH, switch, value);
25403 + HANDLE_CASE(XID, xid, value);
25404 + HANDLE_CASE(NID, nid, value);
25405 + HANDLE_CASE(TAG, tag, value);
25406 + HANDLE_CASE(NET, net, value);
25407 + HANDLE_CASE(LIMIT, limit, value);
25408 + HANDLE_CASE(CRES, cres, value);
25409 + HANDLE_CASE(DLIM, dlim, value);
25410 + HANDLE_CASE(QUOTA, quota, value);
25411 + HANDLE_CASE(CVIRT, cvirt, value);
25412 + HANDLE_CASE(SPACE, space, value);
25413 + HANDLE_CASE(MISC, misc, value);
25422 +__setup("vsdebug=", vs_debug_setup);
25426 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25427 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25428 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25429 +EXPORT_SYMBOL_GPL(vx_debug_net);
25430 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25431 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25432 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25433 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25434 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25435 +EXPORT_SYMBOL_GPL(vx_debug_space);
25436 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25438 diff -NurpP --minimal linux-2.6.29/kernel/vserver/tag.c linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/tag.c
25439 --- linux-2.6.29/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25440 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/tag.c 2009-02-22 22:54:26.000000000 +0100
25443 + * linux/kernel/vserver/tag.c
25445 + * Virtual Server: Shallow Tag Space
25447 + * Copyright (C) 2007 Herbert Pötzl
25449 + * V0.01 basic implementation
25453 +#include <linux/sched.h>
25454 +#include <linux/vserver/debug.h>
25455 +#include <linux/vs_pid.h>
25456 +#include <linux/vs_tag.h>
25458 +#include <linux/vserver/tag_cmd.h>
25461 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25466 + vxdprintk(VXD_CBIT(tag, 5),
25467 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25473 + vxdprintk(VXD_CBIT(tag, 5),
25474 + "moved task %p into [#%d]", p, tag);
25478 +/* vserver syscall commands below here */
25480 +/* taks xid and vx_info functions */
25483 +int vc_task_tag(uint32_t id)
25488 + struct task_struct *tsk;
25489 + read_lock(&tasklist_lock);
25490 + tsk = find_task_by_real_pid(id);
25491 + tag = (tsk) ? tsk->tag : -ESRCH;
25492 + read_unlock(&tasklist_lock);
25494 + tag = dx_current_tag();
25499 +int vc_tag_migrate(uint32_t tag)
25501 + return dx_migrate_task(current, tag & 0xFFFF);
25505 diff -NurpP --minimal linux-2.6.29/kernel/vserver/vci_config.h linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/vci_config.h
25506 --- linux-2.6.29/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25507 +++ linux-2.6.29-vs2.3.0.36.9-pre3/kernel/vserver/vci_config.h 2009-02-22 22:54:26.000000000 +0100
25510 +/* interface version */
25512 +#define VCI_VERSION 0x00020304
25516 + VCI_KCBIT_NO_DYNAMIC = 0,
25518 + VCI_KCBIT_PROC_SECURE = 4,
25519 + VCI_KCBIT_HARDCPU = 5,
25520 + VCI_KCBIT_IDLELIMIT = 6,
25521 + VCI_KCBIT_IDLETIME = 7,
25523 + VCI_KCBIT_COWBL = 8,
25524 + VCI_KCBIT_FULLCOWBL = 9,
25525 + VCI_KCBIT_SPACES = 10,
25526 + VCI_KCBIT_NETV2 = 11,
25528 + VCI_KCBIT_DEBUG = 16,
25529 + VCI_KCBIT_HISTORY = 20,
25530 + VCI_KCBIT_TAGGED = 24,
25531 + VCI_KCBIT_PPTAG = 28,
25533 + VCI_KCBIT_MORE = 31,
25537 +static inline uint32_t vci_kernel_config(void)
25540 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25542 + /* configured features */
25543 +#ifdef CONFIG_VSERVER_PROC_SECURE
25544 + (1 << VCI_KCBIT_PROC_SECURE) |
25546 +#ifdef CONFIG_VSERVER_HARDCPU
25547 + (1 << VCI_KCBIT_HARDCPU) |
25549 +#ifdef CONFIG_VSERVER_IDLELIMIT
25550 + (1 << VCI_KCBIT_IDLELIMIT) |
25552 +#ifdef CONFIG_VSERVER_IDLETIME
25553 + (1 << VCI_KCBIT_IDLETIME) |
25555 +#ifdef CONFIG_VSERVER_COWBL
25556 + (1 << VCI_KCBIT_COWBL) |
25557 + (1 << VCI_KCBIT_FULLCOWBL) |
25559 + (1 << VCI_KCBIT_SPACES) |
25560 + (1 << VCI_KCBIT_NETV2) |
25562 + /* debug options */
25563 +#ifdef CONFIG_VSERVER_DEBUG
25564 + (1 << VCI_KCBIT_DEBUG) |
25566 +#ifdef CONFIG_VSERVER_HISTORY
25567 + (1 << VCI_KCBIT_HISTORY) |
25570 + /* inode context tagging */
25571 +#if defined(CONFIG_TAGGING_NONE)
25572 + (0 << VCI_KCBIT_TAGGED) |
25573 +#elif defined(CONFIG_TAGGING_UID16)
25574 + (1 << VCI_KCBIT_TAGGED) |
25575 +#elif defined(CONFIG_TAGGING_GID16)
25576 + (2 << VCI_KCBIT_TAGGED) |
25577 +#elif defined(CONFIG_TAGGING_ID24)
25578 + (3 << VCI_KCBIT_TAGGED) |
25579 +#elif defined(CONFIG_TAGGING_INTERN)
25580 + (4 << VCI_KCBIT_TAGGED) |
25581 +#elif defined(CONFIG_TAGGING_RUNTIME)
25582 + (5 << VCI_KCBIT_TAGGED) |
25584 + (7 << VCI_KCBIT_TAGGED) |
25586 + (1 << VCI_KCBIT_PPTAG) |
25590 diff -NurpP --minimal linux-2.6.29/mm/filemap_xip.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/filemap_xip.c
25591 --- linux-2.6.29/mm/filemap_xip.c 2009-03-24 14:22:45.000000000 +0100
25592 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/filemap_xip.c 2009-03-24 14:48:36.000000000 +0100
25594 #include <linux/sched.h>
25595 #include <linux/seqlock.h>
25596 #include <linux/mutex.h>
25597 +#include <linux/vs_memory.h>
25598 #include <asm/tlbflush.h>
25599 #include <asm/io.h>
25601 diff -NurpP --minimal linux-2.6.29/mm/fremap.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/fremap.c
25602 --- linux-2.6.29/mm/fremap.c 2009-03-24 14:22:45.000000000 +0100
25603 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/fremap.c 2009-03-24 14:48:36.000000000 +0100
25605 #include <linux/module.h>
25606 #include <linux/syscalls.h>
25607 #include <linux/mmu_notifier.h>
25608 +#include <linux/vs_memory.h>
25610 #include <asm/mmu_context.h>
25611 #include <asm/cacheflush.h>
25612 diff -NurpP --minimal linux-2.6.29/mm/hugetlb.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/hugetlb.c
25613 --- linux-2.6.29/mm/hugetlb.c 2009-03-24 14:22:45.000000000 +0100
25614 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/hugetlb.c 2009-03-24 14:48:36.000000000 +0100
25616 #include <asm/io.h>
25618 #include <linux/hugetlb.h>
25619 +#include <linux/vs_memory.h>
25620 #include "internal.h"
25622 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25623 diff -NurpP --minimal linux-2.6.29/mm/memory.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/memory.c
25624 --- linux-2.6.29/mm/memory.c 2009-03-24 14:22:45.000000000 +0100
25625 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/memory.c 2009-03-24 14:48:36.000000000 +0100
25626 @@ -612,6 +612,9 @@ static int copy_pte_range(struct mm_stru
25630 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25634 rss[1] = rss[0] = 0;
25635 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25636 @@ -2433,6 +2436,11 @@ static int do_swap_page(struct mm_struct
25637 count_vm_event(PGMAJFAULT);
25640 + if (!vx_rss_avail(mm, 1)) {
25641 + ret = VM_FAULT_OOM;
25645 mark_page_accessed(page);
25648 @@ -2524,6 +2532,8 @@ static int do_anonymous_page(struct mm_s
25649 /* Allocate our own private page. */
25650 pte_unmap(page_table);
25652 + if (!vx_rss_avail(mm, 1))
25654 if (unlikely(anon_vma_prepare(vma)))
25656 page = alloc_zeroed_user_highpage_movable(vma, address);
25657 @@ -2791,6 +2801,7 @@ static inline int handle_pte_fault(struc
25661 + int ret = 0, type = VXPT_UNKNOWN;
25664 if (!pte_present(entry)) {
25665 @@ -2815,9 +2826,12 @@ static inline int handle_pte_fault(struc
25666 if (unlikely(!pte_same(*pte, entry)))
25668 if (write_access) {
25669 - if (!pte_write(entry))
25670 - return do_wp_page(mm, vma, address,
25671 + if (!pte_write(entry)) {
25672 + ret = do_wp_page(mm, vma, address,
25673 pte, pmd, ptl, entry);
25674 + type = VXPT_WRITE;
25677 entry = pte_mkdirty(entry);
25679 entry = pte_mkyoung(entry);
25680 @@ -2835,7 +2849,10 @@ static inline int handle_pte_fault(struc
25683 pte_unmap_unlock(pte, ptl);
25687 + vx_page_fault(mm, vma, type, ret);
25692 diff -NurpP --minimal linux-2.6.29/mm/mlock.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/mlock.c
25693 --- linux-2.6.29/mm/mlock.c 2009-03-24 14:22:45.000000000 +0100
25694 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/mlock.c 2009-03-28 05:08:26.000000000 +0100
25696 #include <linux/rmap.h>
25697 #include <linux/mmzone.h>
25698 #include <linux/hugetlb.h>
25699 +#include <linux/vs_memory.h>
25701 #include "internal.h"
25703 @@ -415,7 +416,7 @@ success:
25704 nr_pages = (end - start) >> PAGE_SHIFT;
25706 nr_pages = -nr_pages;
25707 - mm->locked_vm += nr_pages;
25708 + vx_vmlocked_add(mm, nr_pages);
25711 * vm_flags is protected by the mmap_sem held in write mode.
25712 @@ -492,7 +493,7 @@ static int do_mlock(unsigned long start,
25714 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
25716 - unsigned long locked;
25717 + unsigned long locked, grow;
25718 unsigned long lock_limit;
25719 int error = -ENOMEM;
25721 @@ -505,8 +506,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25722 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25723 start &= PAGE_MASK;
25725 - locked = len >> PAGE_SHIFT;
25726 - locked += current->mm->locked_vm;
25727 + grow = len >> PAGE_SHIFT;
25728 + if (!vx_vmlocked_avail(current->mm, grow))
25730 + locked = current->mm->locked_vm + grow;
25732 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
25733 lock_limit >>= PAGE_SHIFT;
25734 @@ -514,6 +517,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25735 /* check against resource limits */
25736 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
25737 error = do_mlock(start, len, 1);
25739 up_write(¤t->mm->mmap_sem);
25742 @@ -575,6 +579,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
25743 lock_limit >>= PAGE_SHIFT;
25746 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
25748 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
25749 capable(CAP_IPC_LOCK))
25750 ret = do_mlockall(flags);
25751 @@ -652,8 +658,10 @@ void *alloc_locked_buffer(size_t size)
25755 - current->mm->total_vm += pgsz;
25756 - current->mm->locked_vm += pgsz;
25757 + // current->mm->total_vm += pgsz;
25758 + vx_vmpages_add(current->mm, pgsz);
25759 + // current->mm->locked_vm += pgsz;
25760 + vx_vmlocked_add(current->mm, pgsz);
25763 up_write(¤t->mm->mmap_sem);
25764 @@ -666,8 +674,10 @@ void release_locked_buffer(void *buffer,
25766 down_write(¤t->mm->mmap_sem);
25768 - current->mm->total_vm -= pgsz;
25769 - current->mm->locked_vm -= pgsz;
25770 + // current->mm->total_vm -= pgsz;
25771 + vx_vmpages_sub(current->mm, pgsz);
25772 + // current->mm->locked_vm -= pgsz;
25773 + vx_vmlocked_sub(current->mm, pgsz);
25775 up_write(¤t->mm->mmap_sem);
25777 diff -NurpP --minimal linux-2.6.29/mm/mmap.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/mmap.c
25778 --- linux-2.6.29/mm/mmap.c 2009-03-24 14:22:45.000000000 +0100
25779 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/mmap.c 2009-03-24 14:48:36.000000000 +0100
25780 @@ -1219,7 +1219,8 @@ munmap_back:
25781 if (correct_wcount)
25782 atomic_inc(&inode->i_writecount);
25784 - mm->total_vm += len >> PAGE_SHIFT;
25785 + // mm->total_vm += len >> PAGE_SHIFT;
25786 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25787 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
25788 if (vm_flags & VM_LOCKED) {
25790 @@ -1228,7 +1229,8 @@ out:
25791 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
25793 return nr_pages; /* vma gone! */
25794 - mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
25795 + // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
25796 + vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
25797 } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
25798 make_pages_present(addr, addr + len);
25800 @@ -1575,9 +1577,9 @@ static int acct_stack_growth(struct vm_a
25803 /* Ok, everything looks good - let it rip */
25804 - mm->total_vm += grow;
25805 + vx_vmpages_add(mm, grow);
25806 if (vma->vm_flags & VM_LOCKED)
25807 - mm->locked_vm += grow;
25808 + vx_vmlocked_add(mm, grow);
25809 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
25812 @@ -1752,7 +1754,8 @@ static void remove_vma_list(struct mm_st
25814 long nrpages = vma_pages(vma);
25816 - mm->total_vm -= nrpages;
25817 + // mm->total_vm -= nrpages;
25818 + vx_vmpages_sub(mm, nrpages);
25819 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
25820 vma = remove_vma(vma);
25822 @@ -1924,7 +1927,8 @@ int do_munmap(struct mm_struct *mm, unsi
25823 struct vm_area_struct *tmp = vma;
25824 while (tmp && tmp->vm_start < end) {
25825 if (tmp->vm_flags & VM_LOCKED) {
25826 - mm->locked_vm -= vma_pages(tmp);
25827 + // mm->locked_vm -= vma_pages(tmp);
25828 + vx_vmlocked_sub(mm, vma_pages(tmp));
25829 munlock_vma_pages_all(tmp);
25831 tmp = tmp->vm_next;
25832 @@ -2013,6 +2017,8 @@ unsigned long do_brk(unsigned long addr,
25833 lock_limit >>= PAGE_SHIFT;
25834 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25836 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
25841 @@ -2039,7 +2045,8 @@ unsigned long do_brk(unsigned long addr,
25842 if (mm->map_count > sysctl_max_map_count)
25845 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
25846 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
25847 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
25850 /* Can we just expand an old private anonymous mapping? */
25851 @@ -2065,10 +2072,13 @@ unsigned long do_brk(unsigned long addr,
25852 vma->vm_page_prot = vm_get_page_prot(flags);
25853 vma_link(mm, vma, prev, rb_link, rb_parent);
25855 - mm->total_vm += len >> PAGE_SHIFT;
25856 + // mm->total_vm += len >> PAGE_SHIFT;
25857 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25859 if (flags & VM_LOCKED) {
25860 if (!mlock_vma_pages_range(vma, addr, addr + len))
25861 - mm->locked_vm += (len >> PAGE_SHIFT);
25862 + // mm->locked_vm += (len >> PAGE_SHIFT);
25863 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25867 @@ -2111,6 +2121,11 @@ void exit_mmap(struct mm_struct *mm)
25868 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
25869 tlb_finish_mmu(tlb, 0, end);
25871 + set_mm_counter(mm, file_rss, 0);
25872 + set_mm_counter(mm, anon_rss, 0);
25873 + vx_vmpages_sub(mm, mm->total_vm);
25874 + vx_vmlocked_sub(mm, mm->locked_vm);
25877 * Walk the list again, actually closing and freeing it,
25878 * with preemption enabled, without holding any MM locks.
25879 @@ -2150,7 +2165,8 @@ int insert_vm_struct(struct mm_struct *
25880 if (__vma && __vma->vm_start < vma->vm_end)
25882 if ((vma->vm_flags & VM_ACCOUNT) &&
25883 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
25884 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
25885 + !vx_vmpages_avail(mm, vma_pages(vma))))
25887 vma_link(mm, vma, prev, rb_link, rb_parent);
25889 @@ -2226,6 +2242,8 @@ int may_expand_vm(struct mm_struct *mm,
25891 if (cur + npages > lim)
25893 + if (!vx_vmpages_avail(mm, npages))
25898 @@ -2303,8 +2321,7 @@ int install_special_mapping(struct mm_st
25902 - mm->total_vm += len >> PAGE_SHIFT;
25904 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25908 diff -NurpP --minimal linux-2.6.29/mm/mremap.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/mremap.c
25909 --- linux-2.6.29/mm/mremap.c 2009-03-24 14:22:45.000000000 +0100
25910 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/mremap.c 2009-03-24 14:48:36.000000000 +0100
25912 #include <linux/security.h>
25913 #include <linux/syscalls.h>
25914 #include <linux/mmu_notifier.h>
25915 +#include <linux/vs_memory.h>
25917 #include <asm/uaccess.h>
25918 #include <asm/cacheflush.h>
25919 @@ -220,7 +221,7 @@ static unsigned long move_vma(struct vm_
25920 * If this were a serious issue, we'd add a flag to do_munmap().
25922 hiwater_vm = mm->hiwater_vm;
25923 - mm->total_vm += new_len >> PAGE_SHIFT;
25924 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
25925 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
25927 if (do_munmap(mm, old_addr, old_len) < 0) {
25928 @@ -238,7 +239,7 @@ static unsigned long move_vma(struct vm_
25931 if (vm_flags & VM_LOCKED) {
25932 - mm->locked_vm += new_len >> PAGE_SHIFT;
25933 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
25934 if (new_len > old_len)
25935 mlock_vma_pages_range(new_vma, new_addr + old_len,
25936 new_addr + new_len);
25937 @@ -349,6 +350,9 @@ unsigned long do_mremap(unsigned long ad
25939 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25941 + if (!vx_vmlocked_avail(current->mm,
25942 + (new_len - old_len) >> PAGE_SHIFT))
25945 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
25947 @@ -377,10 +381,12 @@ unsigned long do_mremap(unsigned long ad
25948 vma_adjust(vma, vma->vm_start,
25949 addr + new_len, vma->vm_pgoff, NULL);
25951 - mm->total_vm += pages;
25952 + // mm->total_vm += pages;
25953 + vx_vmpages_add(mm, pages);
25954 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
25955 if (vma->vm_flags & VM_LOCKED) {
25956 - mm->locked_vm += pages;
25957 + // mm->locked_vm += pages;
25958 + vx_vmlocked_add(mm, pages);
25959 mlock_vma_pages_range(vma, addr + old_len,
25962 diff -NurpP --minimal linux-2.6.29/mm/nommu.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/nommu.c
25963 --- linux-2.6.29/mm/nommu.c 2009-03-24 14:22:45.000000000 +0100
25964 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/nommu.c 2009-03-24 18:25:55.000000000 +0100
25965 @@ -1348,7 +1348,7 @@ unsigned long do_mmap_pgoff(struct file
25966 /* okay... we have a mapping; now we have to register it */
25967 result = vma->vm_start;
25969 - current->mm->total_vm += len >> PAGE_SHIFT;
25970 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
25973 add_vma_to_mm(current->mm, vma);
25974 @@ -1614,7 +1614,7 @@ void exit_mmap(struct mm_struct *mm)
25978 - mm->total_vm = 0;
25979 + vx_vmpages_sub(mm, mm->total_vm);
25981 while ((vma = mm->mmap)) {
25982 mm->mmap = vma->vm_next;
25983 diff -NurpP --minimal linux-2.6.29/mm/oom_kill.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/oom_kill.c
25984 --- linux-2.6.29/mm/oom_kill.c 2009-03-24 14:22:45.000000000 +0100
25985 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/oom_kill.c 2009-03-24 14:48:36.000000000 +0100
25987 #include <linux/notifier.h>
25988 #include <linux/memcontrol.h>
25989 #include <linux/security.h>
25990 +#include <linux/vs_memory.h>
25992 int sysctl_panic_on_oom;
25993 int sysctl_oom_kill_allocating_task;
25994 @@ -72,6 +73,12 @@ unsigned long badness(struct task_struct
25995 points = mm->total_vm;
25998 + * add points for context badness
26001 + points += vx_badness(p, mm);
26004 * After this unlock we can no longer dereference local variable `mm'
26007 @@ -162,8 +169,8 @@ unsigned long badness(struct task_struct
26011 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26012 - p->pid, p->comm, points);
26013 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26014 + task_pid_nr(p), p->xid, p->comm, points);
26018 @@ -326,8 +333,8 @@ static void __oom_kill_task(struct task_
26022 - printk(KERN_ERR "Killed process %d (%s)\n",
26023 - task_pid_nr(p), p->comm);
26024 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
26025 + task_pid_nr(p), p->xid, p->comm);
26028 * We give our sacrificial lamb high priority and access to
26029 @@ -410,8 +417,8 @@ static int oom_kill_process(struct task_
26033 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26034 - message, task_pid_nr(p), p->comm, points);
26035 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
26036 + message, task_pid_nr(p), p->xid, p->comm, points);
26038 /* Try to kill a child first */
26039 list_for_each_entry(c, &p->children, sibling) {
26040 diff -NurpP --minimal linux-2.6.29/mm/page_alloc.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/page_alloc.c
26041 --- linux-2.6.29/mm/page_alloc.c 2009-03-24 14:22:45.000000000 +0100
26042 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/page_alloc.c 2009-03-24 14:48:36.000000000 +0100
26044 #include <linux/page-isolation.h>
26045 #include <linux/page_cgroup.h>
26046 #include <linux/debugobjects.h>
26047 +#include <linux/vs_base.h>
26048 +#include <linux/vs_limit.h>
26050 #include <asm/tlbflush.h>
26051 #include <asm/div64.h>
26052 @@ -1839,6 +1841,9 @@ void si_meminfo(struct sysinfo *val)
26053 val->totalhigh = totalhigh_pages;
26054 val->freehigh = nr_free_highpages();
26055 val->mem_unit = PAGE_SIZE;
26057 + if (vx_flags(VXF_VIRT_MEM, 0))
26058 + vx_vsi_meminfo(val);
26061 EXPORT_SYMBOL(si_meminfo);
26062 @@ -1859,6 +1864,9 @@ void si_meminfo_node(struct sysinfo *val
26065 val->mem_unit = PAGE_SIZE;
26067 + if (vx_flags(VXF_VIRT_MEM, 0))
26068 + vx_vsi_meminfo(val);
26072 diff -NurpP --minimal linux-2.6.29/mm/rmap.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/rmap.c
26073 --- linux-2.6.29/mm/rmap.c 2009-03-24 14:22:45.000000000 +0100
26074 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/rmap.c 2009-03-24 18:26:27.000000000 +0100
26076 #include <linux/memcontrol.h>
26077 #include <linux/mmu_notifier.h>
26078 #include <linux/migrate.h>
26079 +#include <linux/vs_memory.h>
26081 #include <asm/tlbflush.h>
26083 diff -NurpP --minimal linux-2.6.29/mm/shmem.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/shmem.c
26084 --- linux-2.6.29/mm/shmem.c 2009-03-24 14:22:45.000000000 +0100
26085 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/shmem.c 2009-03-24 14:48:36.000000000 +0100
26086 @@ -1757,7 +1757,7 @@ static int shmem_statfs(struct dentry *d
26088 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26090 - buf->f_type = TMPFS_MAGIC;
26091 + buf->f_type = TMPFS_SUPER_MAGIC;
26092 buf->f_bsize = PAGE_CACHE_SIZE;
26093 buf->f_namelen = NAME_MAX;
26094 spin_lock(&sbinfo->stat_lock);
26095 @@ -2326,7 +2326,7 @@ static int shmem_fill_super(struct super
26096 sb->s_maxbytes = SHMEM_MAX_BYTES;
26097 sb->s_blocksize = PAGE_CACHE_SIZE;
26098 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26099 - sb->s_magic = TMPFS_MAGIC;
26100 + sb->s_magic = TMPFS_SUPER_MAGIC;
26101 sb->s_op = &shmem_ops;
26102 sb->s_time_gran = 1;
26103 #ifdef CONFIG_TMPFS_POSIX_ACL
26104 diff -NurpP --minimal linux-2.6.29/mm/slab.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/slab.c
26105 --- linux-2.6.29/mm/slab.c 2009-03-24 14:22:45.000000000 +0100
26106 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/slab.c 2009-03-24 14:48:36.000000000 +0100
26107 @@ -509,6 +509,8 @@ struct kmem_cache {
26108 #define STATS_INC_FREEMISS(x) do { } while (0)
26111 +#include "slab_vs.h"
26116 @@ -3275,6 +3277,7 @@ retry:
26118 obj = slab_get_obj(cachep, slabp, nodeid);
26119 check_slabp(cachep, slabp);
26120 + vx_slab_alloc(cachep, flags);
26121 l3->free_objects--;
26122 /* move slabp to correct slabp list: */
26123 list_del(&slabp->list);
26124 @@ -3347,6 +3350,7 @@ __cache_alloc_node(struct kmem_cache *ca
26125 /* ___cache_alloc_node can fall back to other nodes */
26126 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26128 + vx_slab_alloc(cachep, flags);
26129 local_irq_restore(save_flags);
26130 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26132 @@ -3518,6 +3522,7 @@ static inline void __cache_free(struct k
26135 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26136 + vx_slab_free(cachep);
26139 * Skip calling cache_free_alien() when the platform is not numa.
26140 diff -NurpP --minimal linux-2.6.29/mm/slab_vs.h linux-2.6.29-vs2.3.0.36.9-pre3/mm/slab_vs.h
26141 --- linux-2.6.29/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26142 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/slab_vs.h 2009-02-22 22:54:26.000000000 +0100
26145 +#include <linux/vserver/context.h>
26147 +#include <linux/vs_context.h>
26150 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26152 + int what = gfp_zone(cachep->gfpflags);
26154 + if (!current->vx_info)
26157 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26161 +void vx_slab_free(struct kmem_cache *cachep)
26163 + int what = gfp_zone(cachep->gfpflags);
26165 + if (!current->vx_info)
26168 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26171 diff -NurpP --minimal linux-2.6.29/mm/swapfile.c linux-2.6.29-vs2.3.0.36.9-pre3/mm/swapfile.c
26172 --- linux-2.6.29/mm/swapfile.c 2009-03-24 14:22:45.000000000 +0100
26173 +++ linux-2.6.29-vs2.3.0.36.9-pre3/mm/swapfile.c 2009-03-24 18:27:15.000000000 +0100
26175 #include <asm/tlbflush.h>
26176 #include <linux/swapops.h>
26177 #include <linux/page_cgroup.h>
26178 +#include <linux/vs_base.h>
26179 +#include <linux/vs_memory.h>
26181 static DEFINE_SPINLOCK(swap_lock);
26182 static unsigned int nr_swapfiles;
26183 @@ -1935,6 +1937,8 @@ void si_swapinfo(struct sysinfo *val)
26184 val->freeswap = nr_swap_pages + nr_to_be_unused;
26185 val->totalswap = total_swap_pages + nr_to_be_unused;
26186 spin_unlock(&swap_lock);
26187 + if (vx_flags(VXF_VIRT_MEM, 0))
26188 + vx_vsi_swapinfo(val);
26192 diff -NurpP --minimal linux-2.6.29/net/core/dev.c linux-2.6.29-vs2.3.0.36.9-pre3/net/core/dev.c
26193 --- linux-2.6.29/net/core/dev.c 2009-03-24 14:22:46.000000000 +0100
26194 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/core/dev.c 2009-03-24 18:28:15.000000000 +0100
26195 @@ -126,6 +126,7 @@
26196 #include <linux/in.h>
26197 #include <linux/jhash.h>
26198 #include <linux/random.h>
26199 +#include <linux/vs_inet.h>
26201 #include "net-sysfs.h"
26203 @@ -2856,6 +2857,8 @@ static int dev_ifconf(struct net *net, c
26206 for_each_netdev(net, dev) {
26207 + if (!nx_dev_visible(current->nx_info, dev))
26209 for (i = 0; i < NPROTO; i++) {
26210 if (gifconf_list[i]) {
26212 @@ -2924,6 +2927,9 @@ static void dev_seq_printf_stats(struct
26214 const struct net_device_stats *stats = dev_get_stats(dev);
26216 + if (!nx_dev_visible(current->nx_info, dev))
26219 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26220 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26221 dev->name, stats->rx_bytes, stats->rx_packets,
26222 @@ -4865,6 +4871,15 @@ int dev_change_net_namespace(struct net_
26226 +#ifdef CONFIG_SYSFS
26227 + /* Don't allow real devices to be moved when sysfs
26231 + if (dev->dev.parent)
26235 /* Ensure the device has been registrered */
26237 if (dev->reg_state != NETREG_REGISTERED)
26238 @@ -4924,6 +4939,8 @@ int dev_change_net_namespace(struct net_
26240 netdev_unregister_kobject(dev);
26242 + netdev_unregister_kobject(dev);
26244 /* Actually switch the network namespace */
26245 dev_net_set(dev, net);
26247 diff -NurpP --minimal linux-2.6.29/net/core/net-sysfs.c linux-2.6.29-vs2.3.0.36.9-pre3/net/core/net-sysfs.c
26248 --- linux-2.6.29/net/core/net-sysfs.c 2009-03-24 14:22:46.000000000 +0100
26249 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/core/net-sysfs.c 2009-03-24 18:30:01.000000000 +0100
26250 @@ -512,6 +512,9 @@ int netdev_register_kobject(struct net_d
26251 if (dev_net(net) != &init_net)
26254 + if (dev_net(net) != &init_net)
26257 return device_add(dev);
26260 diff -NurpP --minimal linux-2.6.29/net/core/rtnetlink.c linux-2.6.29-vs2.3.0.36.9-pre3/net/core/rtnetlink.c
26261 --- linux-2.6.29/net/core/rtnetlink.c 2009-03-24 14:22:46.000000000 +0100
26262 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/core/rtnetlink.c 2009-03-24 14:48:36.000000000 +0100
26263 @@ -690,6 +690,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26266 for_each_netdev(net, dev) {
26267 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26271 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26272 @@ -1235,6 +1237,9 @@ void rtmsg_ifinfo(int type, struct net_d
26273 struct sk_buff *skb;
26274 int err = -ENOBUFS;
26276 + if (!nx_dev_visible(current->nx_info, dev))
26279 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26282 diff -NurpP --minimal linux-2.6.29/net/core/sock.c linux-2.6.29-vs2.3.0.36.9-pre3/net/core/sock.c
26283 --- linux-2.6.29/net/core/sock.c 2009-03-24 14:22:46.000000000 +0100
26284 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/core/sock.c 2009-03-24 14:48:36.000000000 +0100
26285 @@ -124,6 +124,10 @@
26286 #include <linux/ipsec.h>
26288 #include <linux/filter.h>
26289 +#include <linux/vs_socket.h>
26290 +#include <linux/vs_limit.h>
26291 +#include <linux/vs_context.h>
26292 +#include <linux/vs_network.h>
26295 #include <net/tcp.h>
26296 @@ -900,6 +904,8 @@ static struct sock *sk_prot_alloc(struct
26297 if (!try_module_get(prot->owner))
26300 + sock_vx_init(sk);
26301 + sock_nx_init(sk);
26305 @@ -976,6 +982,11 @@ void sk_free(struct sock *sk)
26306 __func__, atomic_read(&sk->sk_omem_alloc));
26308 put_net(sock_net(sk));
26310 + clr_vx_info(&sk->sk_vx_info);
26312 + clr_nx_info(&sk->sk_nx_info);
26314 sk_prot_free(sk->sk_prot_creator, sk);
26317 @@ -1011,6 +1022,8 @@ struct sock *sk_clone(const struct sock
26320 get_net(sock_net(newsk));
26321 + sock_vx_init(newsk);
26322 + sock_nx_init(newsk);
26323 sk_node_init(&newsk->sk_node);
26324 sock_lock_init(newsk);
26325 bh_lock_sock(newsk);
26326 @@ -1057,6 +1070,12 @@ struct sock *sk_clone(const struct sock
26327 newsk->sk_priority = 0;
26328 atomic_set(&newsk->sk_refcnt, 2);
26330 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26331 + newsk->sk_xid = sk->sk_xid;
26332 + vx_sock_inc(newsk);
26333 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26334 + newsk->sk_nid = sk->sk_nid;
26337 * Increment the counter in the same struct proto as the master
26338 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26339 @@ -1744,6 +1763,11 @@ void sock_init_data(struct socket *sock,
26341 sk->sk_stamp = ktime_set(-1L, 0);
26343 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26344 + sk->sk_xid = vx_current_xid();
26346 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26347 + sk->sk_nid = nx_current_nid();
26348 atomic_set(&sk->sk_refcnt, 1);
26349 atomic_set(&sk->sk_drops, 0);
26351 diff -NurpP --minimal linux-2.6.29/net/ipv4/af_inet.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/af_inet.c
26352 --- linux-2.6.29/net/ipv4/af_inet.c 2009-03-24 14:22:46.000000000 +0100
26353 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/af_inet.c 2009-03-24 14:48:37.000000000 +0100
26354 @@ -115,6 +115,7 @@
26355 #ifdef CONFIG_IP_MROUTE
26356 #include <linux/mroute.h>
26358 +#include <linux/vs_limit.h>
26360 extern void ip_mc_drop_socket(struct sock *sk);
26362 @@ -325,9 +326,12 @@ lookup_protocol:
26366 + if ((protocol == IPPROTO_ICMP) &&
26367 + nx_capable(answer->capability, NXC_RAW_ICMP))
26369 if (answer->capability > 0 && !capable(answer->capability))
26370 goto out_rcu_unlock;
26373 err = -EAFNOSUPPORT;
26374 if (!inet_netns_ok(net, protocol))
26375 goto out_rcu_unlock;
26376 @@ -445,6 +449,7 @@ int inet_bind(struct socket *sock, struc
26377 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26378 struct sock *sk = sock->sk;
26379 struct inet_sock *inet = inet_sk(sk);
26380 + struct nx_v4_sock_addr nsa;
26381 unsigned short snum;
26384 @@ -458,7 +463,11 @@ int inet_bind(struct socket *sock, struc
26385 if (addr_len < sizeof(struct sockaddr_in))
26388 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26389 + err = v4_map_sock_addr(inet, addr, &nsa);
26393 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26395 /* Not specified by any standard per-se, however it breaks too
26396 * many applications when removed. It is unfortunate since
26397 @@ -470,7 +479,7 @@ int inet_bind(struct socket *sock, struc
26398 err = -EADDRNOTAVAIL;
26399 if (!sysctl_ip_nonlocal_bind &&
26400 !(inet->freebind || inet->transparent) &&
26401 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26402 + nsa.saddr != htonl(INADDR_ANY) &&
26403 chk_addr_ret != RTN_LOCAL &&
26404 chk_addr_ret != RTN_MULTICAST &&
26405 chk_addr_ret != RTN_BROADCAST)
26406 @@ -495,7 +504,7 @@ int inet_bind(struct socket *sock, struc
26407 if (sk->sk_state != TCP_CLOSE || inet->num)
26408 goto out_release_sock;
26410 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26411 + v4_set_sock_addr(inet, &nsa);
26412 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26413 inet->saddr = 0; /* Use device */
26415 @@ -688,11 +697,13 @@ int inet_getname(struct socket *sock, st
26418 sin->sin_port = inet->dport;
26419 - sin->sin_addr.s_addr = inet->daddr;
26420 + sin->sin_addr.s_addr =
26421 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26423 __be32 addr = inet->rcv_saddr;
26425 addr = inet->saddr;
26426 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26427 sin->sin_port = inet->sport;
26428 sin->sin_addr.s_addr = addr;
26430 diff -NurpP --minimal linux-2.6.29/net/ipv4/devinet.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/devinet.c
26431 --- linux-2.6.29/net/ipv4/devinet.c 2009-03-24 14:22:46.000000000 +0100
26432 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/devinet.c 2009-03-24 14:48:37.000000000 +0100
26433 @@ -413,6 +413,7 @@ struct in_device *inetdev_by_index(struc
26438 /* Called only from RTNL semaphored context. No locks. */
26440 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26441 @@ -653,6 +654,8 @@ int devinet_ioctl(struct net *net, unsig
26444 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26445 + struct nx_info *nxi = current->nx_info;
26447 if (tryaddrmatch) {
26448 /* Matthias Andree */
26449 /* compare label and address (4.4BSD style) */
26450 @@ -661,6 +664,8 @@ int devinet_ioctl(struct net *net, unsig
26451 This is checked above. */
26452 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26453 ifap = &ifa->ifa_next) {
26454 + if (!nx_v4_ifa_visible(nxi, ifa))
26456 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26457 sin_orig.sin_addr.s_addr ==
26458 ifa->ifa_address) {
26459 @@ -673,9 +678,12 @@ int devinet_ioctl(struct net *net, unsig
26460 comparing just the label */
26462 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26463 - ifap = &ifa->ifa_next)
26464 + ifap = &ifa->ifa_next) {
26465 + if (!nx_v4_ifa_visible(nxi, ifa))
26467 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26473 @@ -826,6 +834,8 @@ static int inet_gifconf(struct net_devic
26476 for (; ifa; ifa = ifa->ifa_next) {
26477 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
26480 done += sizeof(ifr);
26482 @@ -1156,6 +1166,7 @@ static int inet_dump_ifaddr(struct sk_bu
26483 struct net_device *dev;
26484 struct in_device *in_dev;
26485 struct in_ifaddr *ifa;
26486 + struct sock *sk = skb->sk;
26487 int s_ip_idx, s_idx = cb->args[0];
26489 s_ip_idx = ip_idx = cb->args[1];
26490 @@ -1170,6 +1181,8 @@ static int inet_dump_ifaddr(struct sk_bu
26492 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26493 ifa = ifa->ifa_next, ip_idx++) {
26494 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26496 if (ip_idx < s_ip_idx)
26498 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
26499 diff -NurpP --minimal linux-2.6.29/net/ipv4/fib_hash.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/fib_hash.c
26500 --- linux-2.6.29/net/ipv4/fib_hash.c 2009-03-24 14:22:46.000000000 +0100
26501 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/fib_hash.c 2009-03-24 14:48:37.000000000 +0100
26502 @@ -1022,7 +1022,7 @@ static int fib_seq_show(struct seq_file
26503 prefix = f->fn_key;
26504 mask = FZ_MASK(iter->zone);
26505 flags = fib_flag_trans(fa->fa_type, mask, fi);
26507 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
26509 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
26510 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26511 diff -NurpP --minimal linux-2.6.29/net/ipv4/inet_connection_sock.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/inet_connection_sock.c
26512 --- linux-2.6.29/net/ipv4/inet_connection_sock.c 2009-03-24 14:22:46.000000000 +0100
26513 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/inet_connection_sock.c 2009-03-24 14:48:37.000000000 +0100
26514 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
26516 EXPORT_SYMBOL(inet_get_local_port_range);
26518 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26520 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
26521 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26523 + if (inet_v6_ipv6only(sk2))
26526 + if (sk1_rcv_saddr &&
26528 + sk1_rcv_saddr == sk2_rcv_saddr)
26531 + if (sk1_rcv_saddr &&
26532 + !sk2_rcv_saddr &&
26533 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26536 + if (sk2_rcv_saddr &&
26537 + !sk1_rcv_saddr &&
26538 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26541 + if (!sk1_rcv_saddr &&
26542 + !sk2_rcv_saddr &&
26543 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26549 int inet_csk_bind_conflict(const struct sock *sk,
26550 const struct inet_bind_bucket *tb)
26552 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26554 struct hlist_node *node;
26555 int reuse = sk->sk_reuse;
26556 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct
26557 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26558 if (!reuse || !sk2->sk_reuse ||
26559 sk2->sk_state == TCP_LISTEN) {
26560 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26561 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26562 - sk2_rcv_saddr == sk_rcv_saddr)
26563 + if (ipv4_rcv_saddr_equal(sk, sk2))
26567 diff -NurpP --minimal linux-2.6.29/net/ipv4/inet_diag.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/inet_diag.c
26568 --- linux-2.6.29/net/ipv4/inet_diag.c 2009-03-24 14:22:46.000000000 +0100
26569 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/inet_diag.c 2009-03-24 14:48:37.000000000 +0100
26571 #include <linux/stddef.h>
26573 #include <linux/inet_diag.h>
26574 +#include <linux/vs_network.h>
26575 +#include <linux/vs_inet.h>
26577 static const struct inet_diag_handler **inet_diag_table;
26579 @@ -118,8 +120,8 @@ static int inet_csk_diag_fill(struct soc
26581 r->id.idiag_sport = inet->sport;
26582 r->id.idiag_dport = inet->dport;
26583 - r->id.idiag_src[0] = inet->rcv_saddr;
26584 - r->id.idiag_dst[0] = inet->daddr;
26585 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
26586 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26588 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26589 if (r->idiag_family == AF_INET6) {
26590 @@ -206,8 +208,8 @@ static int inet_twsk_diag_fill(struct in
26591 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26592 r->id.idiag_sport = tw->tw_sport;
26593 r->id.idiag_dport = tw->tw_dport;
26594 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26595 - r->id.idiag_dst[0] = tw->tw_daddr;
26596 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26597 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26598 r->idiag_state = tw->tw_substate;
26599 r->idiag_timer = 3;
26600 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26601 @@ -264,6 +266,7 @@ static int inet_diag_get_exact(struct sk
26604 if (req->idiag_family == AF_INET) {
26605 + /* TODO: lback */
26606 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26607 req->id.idiag_dport, req->id.idiag_src[0],
26608 req->id.idiag_sport, req->id.idiag_if);
26609 @@ -506,6 +509,7 @@ static int inet_csk_diag_dump(struct soc
26613 + /* TODO: lback */
26614 entry.saddr = &inet->rcv_saddr;
26615 entry.daddr = &inet->daddr;
26617 @@ -542,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
26621 + /* TODO: lback */
26622 entry.saddr = &tw->tw_rcv_saddr;
26623 entry.daddr = &tw->tw_daddr;
26625 @@ -588,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
26627 r->id.idiag_sport = inet->sport;
26628 r->id.idiag_dport = ireq->rmt_port;
26629 - r->id.idiag_src[0] = ireq->loc_addr;
26630 - r->id.idiag_dst[0] = ireq->rmt_addr;
26631 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26632 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26633 r->idiag_expires = jiffies_to_msecs(tmo);
26634 r->idiag_rqueue = 0;
26635 r->idiag_wqueue = 0;
26636 @@ -659,6 +664,7 @@ static int inet_diag_dump_reqs(struct sk
26640 + /* TODO: lback */
26642 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26643 (entry.family == AF_INET6) ?
26644 @@ -729,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
26645 sk_nulls_for_each(sk, node, &ilb->head) {
26646 struct inet_sock *inet = inet_sk(sk);
26648 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26653 @@ -795,6 +803,8 @@ skip_listen_ht:
26654 sk_nulls_for_each(sk, node, &head->chain) {
26655 struct inet_sock *inet = inet_sk(sk);
26657 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26661 if (!(r->idiag_states & (1 << sk->sk_state)))
26662 @@ -819,6 +829,8 @@ next_normal:
26663 inet_twsk_for_each(tw, node,
26666 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26670 if (r->id.idiag_sport != tw->tw_sport &&
26671 diff -NurpP --minimal linux-2.6.29/net/ipv4/inet_hashtables.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/inet_hashtables.c
26672 --- linux-2.6.29/net/ipv4/inet_hashtables.c 2009-03-24 14:22:46.000000000 +0100
26673 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/inet_hashtables.c 2009-03-24 19:35:10.000000000 +0100
26676 #include <net/inet_connection_sock.h>
26677 #include <net/inet_hashtables.h>
26678 +#include <net/route.h>
26679 #include <net/ip.h>
26682 @@ -142,7 +143,6 @@ static inline int compute_score(struct s
26683 * wildcarded during the search since they can never be otherwise.
26687 struct sock *__inet_lookup_listener(struct net *net,
26688 struct inet_hashinfo *hashinfo,
26689 const __be32 daddr, const unsigned short hnum,
26690 @@ -165,6 +165,7 @@ begin:
26696 * if the nulls value we got at the end of this lookup is
26697 * not the expected one, we must restart lookup.
26698 diff -NurpP --minimal linux-2.6.29/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/netfilter/nf_nat_helper.c
26699 --- linux-2.6.29/net/ipv4/netfilter/nf_nat_helper.c 2008-12-25 00:26:37.000000000 +0100
26700 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/netfilter/nf_nat_helper.c 2009-02-22 22:54:26.000000000 +0100
26702 #include <net/route.h>
26704 #include <linux/netfilter_ipv4.h>
26705 +#include <net/route.h>
26706 #include <net/netfilter/nf_conntrack.h>
26707 #include <net/netfilter/nf_conntrack_helper.h>
26708 #include <net/netfilter/nf_conntrack_ecache.h>
26709 diff -NurpP --minimal linux-2.6.29/net/ipv4/netfilter.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/netfilter.c
26710 --- linux-2.6.29/net/ipv4/netfilter.c 2009-03-24 14:22:46.000000000 +0100
26711 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/netfilter.c 2009-03-24 14:48:37.000000000 +0100
26713 #include <linux/netfilter_ipv4.h>
26714 #include <linux/ip.h>
26715 #include <linux/skbuff.h>
26716 -#include <net/route.h>
26717 +// #include <net/route.h>
26718 #include <net/xfrm.h>
26719 #include <net/ip.h>
26720 #include <net/netfilter/nf_queue.h>
26721 diff -NurpP --minimal linux-2.6.29/net/ipv4/raw.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/raw.c
26722 --- linux-2.6.29/net/ipv4/raw.c 2009-03-24 14:22:46.000000000 +0100
26723 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/raw.c 2009-03-24 14:48:37.000000000 +0100
26724 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
26726 if (net_eq(sock_net(sk), net) && inet->num == num &&
26727 !(inet->daddr && inet->daddr != raddr) &&
26728 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
26729 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
26730 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26731 goto found; /* gotcha */
26733 @@ -372,6 +372,12 @@ static int raw_send_hdrinc(struct sock *
26734 icmp_out_count(net, ((struct icmphdr *)
26735 skb_transport_header(skb))->type);
26738 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
26739 + sk->sk_nx_info &&
26740 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
26743 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
26746 @@ -383,6 +389,7 @@ out:
26753 IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
26754 @@ -550,6 +557,13 @@ static int raw_sendmsg(struct kiocb *ioc
26757 security_sk_classify_flow(sk, &fl);
26758 + if (sk->sk_nx_info) {
26759 + err = ip_v4_find_src(sock_net(sk),
26760 + sk->sk_nx_info, &rt, &fl);
26765 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
26768 @@ -619,17 +633,19 @@ static int raw_bind(struct sock *sk, str
26770 struct inet_sock *inet = inet_sk(sk);
26771 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
26772 + struct nx_v4_sock_addr nsa = { 0 };
26776 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
26778 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26779 + v4_map_sock_addr(inet, addr, &nsa);
26780 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26781 ret = -EADDRNOTAVAIL;
26782 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
26783 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
26784 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
26786 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26787 + v4_set_sock_addr(inet, &nsa);
26788 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26789 inet->saddr = 0; /* Use device */
26791 @@ -681,7 +697,8 @@ static int raw_recvmsg(struct kiocb *ioc
26792 /* Copy the address. */
26794 sin->sin_family = AF_INET;
26795 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26796 + sin->sin_addr.s_addr =
26797 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
26799 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
26801 @@ -858,7 +875,8 @@ static struct sock *raw_get_first(struct
26802 struct hlist_node *node;
26804 sk_for_each(sk, node, &state->h->ht[state->bucket])
26805 - if (sock_net(sk) == seq_file_net(seq))
26806 + if ((sock_net(sk) == seq_file_net(seq)) &&
26807 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26811 @@ -874,7 +892,8 @@ static struct sock *raw_get_next(struct
26815 - } while (sk && sock_net(sk) != seq_file_net(seq));
26816 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
26817 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26819 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
26820 sk = sk_head(&state->h->ht[state->bucket]);
26821 @@ -933,7 +952,10 @@ static void raw_sock_seq_show(struct seq
26823 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
26824 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
26825 - i, src, srcp, dest, destp, sp->sk_state,
26827 + nx_map_sock_lback(current_nx_info(), src), srcp,
26828 + nx_map_sock_lback(current_nx_info(), dest), destp,
26830 atomic_read(&sp->sk_wmem_alloc),
26831 atomic_read(&sp->sk_rmem_alloc),
26832 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
26833 diff -NurpP --minimal linux-2.6.29/net/ipv4/tcp.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/tcp.c
26834 --- linux-2.6.29/net/ipv4/tcp.c 2009-03-24 14:22:46.000000000 +0100
26835 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/tcp.c 2009-03-24 14:48:37.000000000 +0100
26836 @@ -264,6 +264,7 @@
26837 #include <linux/cache.h>
26838 #include <linux/err.h>
26839 #include <linux/crypto.h>
26840 +#include <linux/in.h>
26842 #include <net/icmp.h>
26843 #include <net/tcp.h>
26844 diff -NurpP --minimal linux-2.6.29/net/ipv4/tcp_ipv4.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/tcp_ipv4.c
26845 --- linux-2.6.29/net/ipv4/tcp_ipv4.c 2009-03-24 14:22:46.000000000 +0100
26846 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/tcp_ipv4.c 2009-03-24 19:51:34.000000000 +0100
26847 @@ -1894,6 +1894,12 @@ static void *listening_get_next(struct s
26848 req = req->dl_next;
26851 + vxdprintk(VXD_CBIT(net, 6),
26852 + "sk,req: %p [#%d] (from %d)", req->sk,
26853 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26855 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26857 if (req->rsk_ops->family == st->family) {
26860 @@ -1918,6 +1924,10 @@ get_req:
26863 sk_nulls_for_each_from(sk, node) {
26864 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26865 + sk, sk->sk_nid, nx_current_nid());
26866 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26868 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
26871 @@ -1981,6 +1991,11 @@ static void *established_get_first(struc
26873 spin_lock_bh(lock);
26874 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26875 + vxdprintk(VXD_CBIT(net, 6),
26876 + "sk,egf: %p [#%d] (from %d)",
26877 + sk, sk->sk_nid, nx_current_nid());
26878 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26880 if (sk->sk_family != st->family ||
26881 !net_eq(sock_net(sk), net)) {
26883 @@ -1991,6 +2006,11 @@ static void *established_get_first(struc
26884 st->state = TCP_SEQ_STATE_TIME_WAIT;
26885 inet_twsk_for_each(tw, node,
26886 &tcp_hashinfo.ehash[st->bucket].twchain) {
26887 + vxdprintk(VXD_CBIT(net, 6),
26888 + "tw: %p [#%d] (from %d)",
26889 + tw, tw->tw_nid, nx_current_nid());
26890 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26892 if (tw->tw_family != st->family ||
26893 !net_eq(twsk_net(tw), net)) {
26895 @@ -2019,7 +2039,9 @@ static void *established_get_next(struct
26899 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
26900 + while (tw && (tw->tw_family != st->family ||
26901 + !net_eq(twsk_net(tw), net) ||
26902 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26906 @@ -2042,6 +2064,11 @@ get_tw:
26907 sk = sk_nulls_next(sk);
26909 sk_nulls_for_each_from(sk, node) {
26910 + vxdprintk(VXD_CBIT(net, 6),
26911 + "sk,egn: %p [#%d] (from %d)",
26912 + sk, sk->sk_nid, nx_current_nid());
26913 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26915 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
26918 @@ -2193,9 +2220,9 @@ static void get_openreq4(struct sock *sk
26919 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26920 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
26923 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
26924 ntohs(inet_sk(sk)->sport),
26926 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
26927 ntohs(ireq->rmt_port),
26929 0, 0, /* could print option size, but that is af dependent. */
26930 @@ -2238,7 +2265,10 @@ static void get_tcp4_sock(struct sock *s
26932 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
26933 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
26934 - i, src, srcp, dest, destp, sk->sk_state,
26936 + nx_map_sock_lback(current_nx_info(), src), srcp,
26937 + nx_map_sock_lback(current_nx_info(), dest), destp,
26939 tp->write_seq - tp->snd_una,
26940 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
26941 (tp->rcv_nxt - tp->copied_seq),
26942 @@ -2274,7 +2304,10 @@ static void get_timewait4_sock(struct in
26944 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26945 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
26946 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
26948 + nx_map_sock_lback(current_nx_info(), src), srcp,
26949 + nx_map_sock_lback(current_nx_info(), dest), destp,
26950 + tw->tw_substate, 0, 0,
26951 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
26952 atomic_read(&tw->tw_refcnt), tw, len);
26954 diff -NurpP --minimal linux-2.6.29/net/ipv4/tcp_minisocks.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/tcp_minisocks.c
26955 --- linux-2.6.29/net/ipv4/tcp_minisocks.c 2009-03-24 14:22:46.000000000 +0100
26956 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/tcp_minisocks.c 2009-03-24 14:48:37.000000000 +0100
26958 #include <net/inet_common.h>
26959 #include <net/xfrm.h>
26961 +#include <linux/vs_limit.h>
26962 +#include <linux/vs_socket.h>
26963 +#include <linux/vs_context.h>
26965 #ifdef CONFIG_SYSCTL
26966 #define SYNC_INIT 0 /* let the user enable it */
26968 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
26969 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26970 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26972 + tw->tw_xid = sk->sk_xid;
26973 + tw->tw_vx_info = NULL;
26974 + tw->tw_nid = sk->sk_nid;
26975 + tw->tw_nx_info = NULL;
26977 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26978 if (tw->tw_family == PF_INET6) {
26979 struct ipv6_pinfo *np = inet6_sk(sk);
26980 diff -NurpP --minimal linux-2.6.29/net/ipv4/udp.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/udp.c
26981 --- linux-2.6.29/net/ipv4/udp.c 2009-03-24 14:22:46.000000000 +0100
26982 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv4/udp.c 2009-03-25 10:50:13.000000000 +0100
26983 @@ -222,14 +222,7 @@ fail:
26987 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26989 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
26991 - return ( !ipv6_only_sock(sk2) &&
26992 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
26993 - inet1->rcv_saddr == inet2->rcv_saddr ));
26995 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
26997 int udp_v4_get_port(struct sock *sk, unsigned short snum)
26999 @@ -251,6 +244,11 @@ static inline int compute_score(struct s
27000 if (inet->rcv_saddr != daddr)
27004 + /* block non nx_info ips */
27005 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27006 + daddr, NXA_MASK_BIND))
27010 if (inet->daddr != saddr)
27011 @@ -271,6 +269,7 @@ static inline int compute_score(struct s
27016 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27017 * harder than this. -DaveM
27019 @@ -292,6 +291,11 @@ begin:
27020 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27021 score = compute_score(sk, net, saddr, hnum, sport,
27022 daddr, dport, dif);
27023 + /* FIXME: disabled?
27024 + if (score == 9) {
27028 if (score > badness) {
27031 @@ -305,6 +309,7 @@ begin:
27032 if (get_nulls_value(node) != hash)
27037 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27039 @@ -314,6 +319,7 @@ begin:
27047 @@ -356,7 +362,7 @@ static inline struct sock *udp_v4_mcast_
27048 s->sk_hash != hnum ||
27049 (inet->daddr && inet->daddr != rmt_addr) ||
27050 (inet->dport != rmt_port && inet->dport) ||
27051 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27052 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27053 ipv6_only_sock(s) ||
27054 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27056 @@ -694,8 +700,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27057 { .sport = inet->sport,
27058 .dport = dport } } };
27059 struct net *net = sock_net(sk);
27060 + struct nx_info *nxi = sk->sk_nx_info;
27062 security_sk_classify_flow(sk, &fl);
27063 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27067 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27069 if (err == -ENETUNREACH)
27070 @@ -940,7 +951,8 @@ try_again:
27072 sin->sin_family = AF_INET;
27073 sin->sin_port = udp_hdr(skb)->source;
27074 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27075 + sin->sin_addr.s_addr = nx_map_sock_lback(
27076 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27077 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27079 if (inet->cmsg_flags)
27080 @@ -1594,6 +1606,8 @@ static struct sock *udp_get_first(struct
27081 sk_nulls_for_each(sk, node, &hslot->head) {
27082 if (!net_eq(sock_net(sk), net))
27084 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27086 if (sk->sk_family == state->family)
27089 @@ -1611,7 +1625,9 @@ static struct sock *udp_get_next(struct
27092 sk = sk_nulls_next(sk);
27093 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27094 + } while (sk && (!net_eq(sock_net(sk), net) ||
27095 + sk->sk_family != state->family ||
27096 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27099 spin_unlock_bh(&state->udp_table->hash[state->bucket].lock);
27100 @@ -1712,7 +1728,10 @@ static void udp4_format_sock(struct sock
27102 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27103 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27104 - bucket, src, srcp, dest, destp, sp->sk_state,
27106 + nx_map_sock_lback(current_nx_info(), src), srcp,
27107 + nx_map_sock_lback(current_nx_info(), dest), destp,
27109 atomic_read(&sp->sk_wmem_alloc),
27110 atomic_read(&sp->sk_rmem_alloc),
27111 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27112 diff -NurpP --minimal linux-2.6.29/net/ipv6/addrconf.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/addrconf.c
27113 --- linux-2.6.29/net/ipv6/addrconf.c 2009-03-24 14:22:46.000000000 +0100
27114 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/addrconf.c 2009-03-24 20:39:23.000000000 +0100
27117 #include <linux/proc_fs.h>
27118 #include <linux/seq_file.h>
27119 +#include <linux/vs_network.h>
27120 +#include <linux/vs_inet6.h>
27122 /* Set to 3 to get tracing... */
27123 #define ACONF_DEBUG 2
27124 @@ -1111,7 +1113,7 @@ out:
27126 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27127 const struct in6_addr *daddr, unsigned int prefs,
27128 - struct in6_addr *saddr)
27129 + struct in6_addr *saddr, struct nx_info *nxi)
27131 struct ipv6_saddr_score scores[2],
27132 *score = &scores[0], *hiscore = &scores[1];
27133 @@ -1184,6 +1186,8 @@ int ipv6_dev_get_saddr(struct net *net,
27137 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27141 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27142 @@ -1367,35 +1371,46 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str
27146 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
27148 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27150 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27151 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27152 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
27153 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27154 int sk_ipv6only = ipv6_only_sock(sk);
27155 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27156 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27157 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27159 - if (!sk2_rcv_saddr && !sk_ipv6only)
27160 + /* FIXME: needs handling for v4 ANY */
27161 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
27164 if (addr_type2 == IPV6_ADDR_ANY &&
27165 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27166 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
27167 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
27170 if (addr_type == IPV6_ADDR_ANY &&
27171 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27172 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
27173 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
27176 + if (addr_type == IPV6_ADDR_ANY &&
27177 + addr_type2 == IPV6_ADDR_ANY &&
27178 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
27181 if (sk2_rcv_saddr6 &&
27182 + addr_type != IPV6_ADDR_ANY &&
27183 + addr_type != IPV6_ADDR_ANY &&
27184 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27187 if (addr_type == IPV6_ADDR_MAPPED &&
27189 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
27190 + ipv4_rcv_saddr_equal(sk, sk2))
27194 @@ -2993,7 +3008,10 @@ static void if6_seq_stop(struct seq_file
27195 static int if6_seq_show(struct seq_file *seq, void *v)
27197 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27198 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27200 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27201 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27202 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27204 ifp->idev->dev->ifindex,
27206 @@ -3487,6 +3505,12 @@ static int inet6_dump_addr(struct sk_buf
27207 struct ifmcaddr6 *ifmca;
27208 struct ifacaddr6 *ifaca;
27209 struct net *net = sock_net(skb->sk);
27210 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27212 + /* disable ipv6 on non v6 guests */
27213 + if (nxi && !nx_info_has_v6(nxi))
27217 s_idx = cb->args[0];
27218 s_ip_idx = ip_idx = cb->args[1];
27219 @@ -3508,6 +3532,8 @@ static int inet6_dump_addr(struct sk_buf
27220 ifa = ifa->if_next, ip_idx++) {
27221 if (ip_idx < s_ip_idx)
27223 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27225 err = inet6_fill_ifaddr(skb, ifa,
27226 NETLINK_CB(cb->skb).pid,
27227 cb->nlh->nlmsg_seq,
27228 @@ -3521,6 +3547,8 @@ static int inet6_dump_addr(struct sk_buf
27229 ifmca = ifmca->next, ip_idx++) {
27230 if (ip_idx < s_ip_idx)
27232 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27234 err = inet6_fill_ifmcaddr(skb, ifmca,
27235 NETLINK_CB(cb->skb).pid,
27236 cb->nlh->nlmsg_seq,
27237 @@ -3534,6 +3562,8 @@ static int inet6_dump_addr(struct sk_buf
27238 ifaca = ifaca->aca_next, ip_idx++) {
27239 if (ip_idx < s_ip_idx)
27241 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27243 err = inet6_fill_ifacaddr(skb, ifaca,
27244 NETLINK_CB(cb->skb).pid,
27245 cb->nlh->nlmsg_seq,
27246 @@ -3819,12 +3849,19 @@ static int inet6_dump_ifinfo(struct sk_b
27247 int s_idx = cb->args[0];
27248 struct net_device *dev;
27249 struct inet6_dev *idev;
27250 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27252 + /* FIXME: maybe disable ipv6 on non v6 guests?
27253 + if (skb->sk && skb->sk->sk_vx_info)
27254 + return skb->len; */
27256 read_lock(&dev_base_lock);
27258 for_each_netdev(net, dev) {
27261 + if (!v6_dev_in_nx_info(dev, nxi))
27263 if ((idev = in6_dev_get(dev)) == NULL)
27265 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
27266 diff -NurpP --minimal linux-2.6.29/net/ipv6/af_inet6.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/af_inet6.c
27267 --- linux-2.6.29/net/ipv6/af_inet6.c 2009-03-24 14:22:46.000000000 +0100
27268 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/af_inet6.c 2009-03-24 14:48:37.000000000 +0100
27270 #include <linux/netdevice.h>
27271 #include <linux/icmpv6.h>
27272 #include <linux/netfilter_ipv6.h>
27273 +#include <linux/vs_inet.h>
27274 +#include <linux/vs_inet6.h>
27276 #include <net/ip.h>
27277 #include <net/ipv6.h>
27279 #include <net/tcp.h>
27280 #include <net/ipip.h>
27281 #include <net/protocol.h>
27282 +#include <net/route.h>
27283 #include <net/inet_common.h>
27284 #include <net/route.h>
27285 #include <net/transp_v6.h>
27286 @@ -146,9 +149,12 @@ lookup_protocol:
27290 + if ((protocol == IPPROTO_ICMPV6) &&
27291 + nx_capable(answer->capability, NXC_RAW_ICMP))
27293 if (answer->capability > 0 && !capable(answer->capability))
27294 goto out_rcu_unlock;
27297 sock->ops = answer->ops;
27298 answer_prot = answer->prot;
27299 answer_no_check = answer->no_check;
27300 @@ -247,6 +253,7 @@ int inet6_bind(struct socket *sock, stru
27301 struct inet_sock *inet = inet_sk(sk);
27302 struct ipv6_pinfo *np = inet6_sk(sk);
27303 struct net *net = sock_net(sk);
27304 + struct nx_v6_sock_addr nsa;
27306 unsigned short snum;
27308 @@ -258,6 +265,11 @@ int inet6_bind(struct socket *sock, stru
27310 if (addr_len < SIN6_LEN_RFC2133)
27313 + err = v6_map_sock_addr(inet, addr, &nsa);
27317 addr_type = ipv6_addr_type(&addr->sin6_addr);
27318 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27320 @@ -281,6 +293,10 @@ int inet6_bind(struct socket *sock, stru
27321 err = -EADDRNOTAVAIL;
27324 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27325 + err = -EADDRNOTAVAIL;
27329 if (addr_type != IPV6_ADDR_ANY) {
27330 struct net_device *dev = NULL;
27331 @@ -306,6 +322,11 @@ int inet6_bind(struct socket *sock, stru
27335 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27336 + err = -EADDRNOTAVAIL;
27340 /* ipv4 addr of the socket is invalid. Only the
27341 * unspecified and mapped address have a v4 equivalent.
27343 @@ -324,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
27347 + v6_set_sock_addr(inet, &nsa);
27349 inet->rcv_saddr = v4addr;
27350 inet->saddr = v4addr;
27352 @@ -416,9 +439,11 @@ int inet6_getname(struct socket *sock, s
27354 sin->sin6_port = inet->dport;
27355 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27356 + /* FIXME: remap lback? */
27358 sin->sin6_flowinfo = np->flow_label;
27360 + /* FIXME: remap lback? */
27361 if (ipv6_addr_any(&np->rcv_saddr))
27362 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27364 diff -NurpP --minimal linux-2.6.29/net/ipv6/fib6_rules.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/fib6_rules.c
27365 --- linux-2.6.29/net/ipv6/fib6_rules.c 2008-12-25 00:26:37.000000000 +0100
27366 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/fib6_rules.c 2009-02-22 22:54:26.000000000 +0100
27367 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
27368 if (ipv6_dev_get_saddr(net,
27369 ip6_dst_idev(&rt->u.dst)->dev,
27370 &flp->fl6_dst, srcprefs,
27374 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27376 diff -NurpP --minimal linux-2.6.29/net/ipv6/inet6_hashtables.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/inet6_hashtables.c
27377 --- linux-2.6.29/net/ipv6/inet6_hashtables.c 2009-03-24 14:22:46.000000000 +0100
27378 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/inet6_hashtables.c 2009-03-24 20:50:24.000000000 +0100
27381 #include <linux/module.h>
27382 #include <linux/random.h>
27383 +#include <linux/vs_inet6.h>
27385 #include <net/inet_connection_sock.h>
27386 #include <net/inet_hashtables.h>
27387 @@ -76,7 +77,6 @@ struct sock *__inet6_lookup_established(
27388 unsigned int slot = hash & (hashinfo->ehash_size - 1);
27389 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27394 sk_nulls_for_each_rcu(sk, node, &head->chain) {
27395 @@ -88,7 +88,7 @@ begin:
27403 if (get_nulls_value(node) != slot)
27404 @@ -134,6 +134,9 @@ static int inline compute_score(struct s
27405 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27409 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27412 if (sk->sk_bound_dev_if) {
27413 if (sk->sk_bound_dev_if != dif)
27414 diff -NurpP --minimal linux-2.6.29/net/ipv6/ip6_output.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/ip6_output.c
27415 --- linux-2.6.29/net/ipv6/ip6_output.c 2009-03-24 14:22:47.000000000 +0100
27416 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/ip6_output.c 2009-03-24 14:48:37.000000000 +0100
27417 @@ -951,7 +951,7 @@ static int ip6_dst_lookup_tail(struct so
27418 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27420 sk ? inet6_sk(sk)->srcprefs : 0,
27422 + &fl->fl6_src, sk->sk_nx_info);
27424 goto out_err_release;
27426 diff -NurpP --minimal linux-2.6.29/net/ipv6/Kconfig linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/Kconfig
27427 --- linux-2.6.29/net/ipv6/Kconfig 2008-12-25 00:26:37.000000000 +0100
27428 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/Kconfig 2009-02-22 22:54:26.000000000 +0100
27431 # IPv6 as module will cause a CRASH if you try to unload it
27433 - tristate "The IPv6 protocol"
27435 + bool "The IPv6 protocol"
27438 This is complemental support for the IP version 6.
27439 You will still be able to do traditional IPv4 networking as well.
27440 diff -NurpP --minimal linux-2.6.29/net/ipv6/ndisc.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/ndisc.c
27441 --- linux-2.6.29/net/ipv6/ndisc.c 2009-03-24 14:22:47.000000000 +0100
27442 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/ndisc.c 2009-03-24 14:48:37.000000000 +0100
27443 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
27445 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27446 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27448 + &tmpaddr, NULL /* FIXME: ? */ ))
27450 src_addr = &tmpaddr;
27452 diff -NurpP --minimal linux-2.6.29/net/ipv6/raw.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/raw.c
27453 --- linux-2.6.29/net/ipv6/raw.c 2009-03-24 14:22:47.000000000 +0100
27454 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/raw.c 2009-03-24 14:48:37.000000000 +0100
27456 #include <linux/icmpv6.h>
27457 #include <linux/netfilter.h>
27458 #include <linux/netfilter_ipv6.h>
27459 +#include <linux/vs_inet6.h>
27460 #include <linux/skbuff.h>
27461 #include <asm/uaccess.h>
27462 #include <asm/ioctls.h>
27463 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
27467 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27468 + err = -EADDRNOTAVAIL;
27474 /* ipv4 addr of the socket is invalid. Only the
27475 * unspecified and mapped address have a v4 equivalent.
27477 diff -NurpP --minimal linux-2.6.29/net/ipv6/route.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/route.c
27478 --- linux-2.6.29/net/ipv6/route.c 2009-03-24 14:22:47.000000000 +0100
27479 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/route.c 2009-03-24 14:48:37.000000000 +0100
27480 @@ -2254,7 +2254,8 @@ static int rt6_fill_node(struct net *net
27481 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27482 struct in6_addr saddr_buf;
27483 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27484 - dst, 0, &saddr_buf) == 0)
27485 + dst, 0, &saddr_buf,
27486 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27487 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27490 diff -NurpP --minimal linux-2.6.29/net/ipv6/tcp_ipv6.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/tcp_ipv6.c
27491 --- linux-2.6.29/net/ipv6/tcp_ipv6.c 2009-03-24 14:22:47.000000000 +0100
27492 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/tcp_ipv6.c 2009-03-24 14:48:37.000000000 +0100
27495 #include <linux/crypto.h>
27496 #include <linux/scatterlist.h>
27497 +#include <linux/vs_inet6.h>
27499 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27500 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27501 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
27502 * connect() to INADDR_ANY means loopback (BSD'ism).
27505 - if(ipv6_addr_any(&usin->sin6_addr))
27506 - usin->sin6_addr.s6_addr[15] = 0x1;
27507 + if(ipv6_addr_any(&usin->sin6_addr)) {
27508 + struct nx_info *nxi = sk->sk_nx_info;
27510 + if (nxi && nx_info_has_v6(nxi))
27511 + /* FIXME: remap lback? */
27512 + usin->sin6_addr = nxi->v6.ip;
27514 + usin->sin6_addr.s6_addr[15] = 0x1;
27517 addr_type = ipv6_addr_type(&usin->sin6_addr);
27519 diff -NurpP --minimal linux-2.6.29/net/ipv6/udp.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/udp.c
27520 --- linux-2.6.29/net/ipv6/udp.c 2009-03-24 14:22:47.000000000 +0100
27521 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/udp.c 2009-03-24 20:56:49.000000000 +0100
27524 #include <linux/proc_fs.h>
27525 #include <linux/seq_file.h>
27526 +#include <linux/vs_inet6.h>
27527 #include "udp_impl.h"
27529 int udp_v6_get_port(struct sock *sk, unsigned short snum)
27530 @@ -77,6 +78,10 @@ static inline int compute_score(struct s
27531 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27535 + /* block non nx_info ips */
27536 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27539 if (!ipv6_addr_any(&np->daddr)) {
27540 if (!ipv6_addr_equal(&np->daddr, saddr))
27541 diff -NurpP --minimal linux-2.6.29/net/ipv6/xfrm6_policy.c linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/xfrm6_policy.c
27542 --- linux-2.6.29/net/ipv6/xfrm6_policy.c 2009-03-24 14:22:47.000000000 +0100
27543 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/ipv6/xfrm6_policy.c 2009-03-24 14:48:37.000000000 +0100
27544 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
27545 dev = ip6_dst_idev(dst)->dev;
27546 ipv6_dev_get_saddr(dev_net(dev), dev,
27547 (struct in6_addr *)&daddr->a6, 0,
27548 - (struct in6_addr *)&saddr->a6);
27549 + (struct in6_addr *)&saddr->a6, NULL);
27553 diff -NurpP --minimal linux-2.6.29/net/netlink/af_netlink.c linux-2.6.29-vs2.3.0.36.9-pre3/net/netlink/af_netlink.c
27554 --- linux-2.6.29/net/netlink/af_netlink.c 2009-03-24 14:22:47.000000000 +0100
27555 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/netlink/af_netlink.c 2009-03-24 14:48:37.000000000 +0100
27557 #include <linux/types.h>
27558 #include <linux/audit.h>
27559 #include <linux/mutex.h>
27560 +#include <linux/vs_context.h>
27561 +#include <linux/vs_network.h>
27562 +#include <linux/vs_limit.h>
27564 #include <net/net_namespace.h>
27565 #include <net/sock.h>
27566 @@ -1776,6 +1779,8 @@ static struct sock *netlink_seq_socket_i
27567 sk_for_each(s, node, &hash->table[j]) {
27568 if (sock_net(s) != seq_file_net(seq))
27570 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27574 iter->hash_idx = j;
27575 @@ -1810,7 +1815,8 @@ static void *netlink_seq_next(struct seq
27579 - } while (s && sock_net(s) != seq_file_net(seq));
27580 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27581 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27585 @@ -1822,7 +1828,8 @@ static void *netlink_seq_next(struct seq
27587 for (; j <= hash->mask; j++) {
27588 s = sk_head(&hash->table[j]);
27589 - while (s && sock_net(s) != seq_file_net(seq))
27590 + while (s && (sock_net(s) != seq_file_net(seq) ||
27591 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27595 diff -NurpP --minimal linux-2.6.29/net/sctp/ipv6.c linux-2.6.29-vs2.3.0.36.9-pre3/net/sctp/ipv6.c
27596 --- linux-2.6.29/net/sctp/ipv6.c 2009-03-24 14:22:48.000000000 +0100
27597 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/sctp/ipv6.c 2009-03-24 20:58:14.000000000 +0100
27598 @@ -317,7 +317,8 @@ static void sctp_v6_get_saddr(struct sct
27599 dst ? ip6_dst_idev(dst)->dev : NULL,
27600 &daddr->v6.sin6_addr,
27601 inet6_sk(&sk->inet.sk)->srcprefs,
27602 - &saddr->v6.sin6_addr);
27603 + &saddr->v6.sin6_addr,
27604 + asoc->base.sk->sk_nx_info);
27605 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
27606 &saddr->v6.sin6_addr);
27608 diff -NurpP --minimal linux-2.6.29/net/socket.c linux-2.6.29-vs2.3.0.36.9-pre3/net/socket.c
27609 --- linux-2.6.29/net/socket.c 2009-03-24 14:22:48.000000000 +0100
27610 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/socket.c 2009-03-24 14:48:37.000000000 +0100
27613 #include <net/sock.h>
27614 #include <linux/netfilter.h>
27615 +#include <linux/vs_base.h>
27616 +#include <linux/vs_socket.h>
27617 +#include <linux/vs_inet.h>
27618 +#include <linux/vs_inet6.h>
27620 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
27621 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
27622 @@ -549,7 +553,7 @@ static inline int __sock_sendmsg(struct
27623 struct msghdr *msg, size_t size)
27625 struct sock_iocb *si = kiocb_to_siocb(iocb);
27631 @@ -560,7 +564,22 @@ static inline int __sock_sendmsg(struct
27635 - return sock->ops->sendmsg(iocb, sock, msg, size);
27636 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27639 + vx_sock_send(sock->sk, size);
27641 + vx_sock_fail(sock->sk, size);
27643 + vxdprintk(VXD_CBIT(net, 7),
27644 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27646 + (sock->sk)?sock->sk->sk_nx_info:0,
27647 + (sock->sk)?sock->sk->sk_vx_info:0,
27648 + (sock->sk)?sock->sk->sk_xid:0,
27649 + (sock->sk)?sock->sk->sk_nid:0,
27650 + (unsigned int)size, len);
27654 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27655 @@ -629,7 +648,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
27656 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27657 struct msghdr *msg, size_t size, int flags)
27661 struct sock_iocb *si = kiocb_to_siocb(iocb);
27664 @@ -642,7 +661,18 @@ static inline int __sock_recvmsg(struct
27668 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27669 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27670 + if ((len >= 0) && sock->sk)
27671 + vx_sock_recv(sock->sk, len);
27672 + vxdprintk(VXD_CBIT(net, 7),
27673 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27675 + (sock->sk)?sock->sk->sk_nx_info:0,
27676 + (sock->sk)?sock->sk->sk_vx_info:0,
27677 + (sock->sk)?sock->sk->sk_xid:0,
27678 + (sock->sk)?sock->sk->sk_nid:0,
27679 + (unsigned int)size, len);
27683 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
27684 @@ -1106,6 +1136,13 @@ static int __sock_create(struct net *net
27685 if (type < 0 || type >= SOCK_MAX)
27688 + if (!nx_check(0, VS_ADMIN)) {
27689 + if (family == PF_INET && !current_nx_info_has_v4())
27690 + return -EAFNOSUPPORT;
27691 + if (family == PF_INET6 && !current_nx_info_has_v6())
27692 + return -EAFNOSUPPORT;
27697 This uglymoron is moved from INET layer to here to avoid
27698 @@ -1238,6 +1275,7 @@ SYSCALL_DEFINE3(socket, int, family, int
27702 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27703 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27706 @@ -1279,10 +1317,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
27707 err = sock_create(family, type, protocol, &sock1);
27710 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27712 err = sock_create(family, type, protocol, &sock2);
27714 goto out_release_1;
27715 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27717 err = sock1->ops->socketpair(sock1, sock2);
27719 diff -NurpP --minimal linux-2.6.29/net/sunrpc/auth.c linux-2.6.29-vs2.3.0.36.9-pre3/net/sunrpc/auth.c
27720 --- linux-2.6.29/net/sunrpc/auth.c 2009-03-24 14:22:48.000000000 +0100
27721 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/sunrpc/auth.c 2009-03-24 21:00:49.000000000 +0100
27723 #include <linux/hash.h>
27724 #include <linux/sunrpc/clnt.h>
27725 #include <linux/spinlock.h>
27726 +#include <linux/vs_tag.h>
27729 # define RPCDBG_FACILITY RPCDBG_AUTH
27730 @@ -360,6 +361,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27731 memset(&acred, 0, sizeof(acred));
27732 acred.uid = cred->fsuid;
27733 acred.gid = cred->fsgid;
27734 + acred.tag = dx_current_tag();
27735 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
27737 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
27738 @@ -400,6 +402,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27739 struct auth_cred acred = {
27742 + .tag = dx_current_tag(),
27744 struct rpc_cred *ret;
27746 diff -NurpP --minimal linux-2.6.29/net/sunrpc/auth_unix.c linux-2.6.29-vs2.3.0.36.9-pre3/net/sunrpc/auth_unix.c
27747 --- linux-2.6.29/net/sunrpc/auth_unix.c 2008-12-25 00:26:37.000000000 +0100
27748 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/sunrpc/auth_unix.c 2009-02-22 22:54:26.000000000 +0100
27749 @@ -11,12 +11,14 @@
27750 #include <linux/module.h>
27751 #include <linux/sunrpc/clnt.h>
27752 #include <linux/sunrpc/auth.h>
27753 +#include <linux/vs_tag.h>
27755 #define NFS_NGROUPS 16
27758 struct rpc_cred uc_base;
27761 gid_t uc_gids[NFS_NGROUPS];
27763 #define uc_uid uc_base.cr_uid
27764 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
27765 groups = NFS_NGROUPS;
27767 cred->uc_gid = acred->gid;
27768 + cred->uc_tag = acred->tag;
27769 for (i = 0; i < groups; i++)
27770 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27771 if (i < NFS_NGROUPS)
27772 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
27776 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
27777 + if (cred->uc_uid != acred->uid ||
27778 + cred->uc_gid != acred->gid ||
27779 + cred->uc_tag != acred->tag)
27782 if (acred->group_info != NULL)
27783 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
27784 struct rpc_clnt *clnt = task->tk_client;
27785 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
27786 __be32 *base, *hold;
27790 *p++ = htonl(RPC_AUTH_UNIX);
27792 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
27793 * Copy the UTS nodename captured when the client was created.
27795 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27796 + tag = task->tk_client->cl_tag;
27798 - *p++ = htonl((u32) cred->uc_uid);
27799 - *p++ = htonl((u32) cred->uc_gid);
27800 + *p++ = htonl((u32) TAGINO_UID(tag,
27801 + cred->uc_uid, cred->uc_tag));
27802 + *p++ = htonl((u32) TAGINO_GID(tag,
27803 + cred->uc_gid, cred->uc_tag));
27805 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27806 *p++ = htonl((u32) cred->uc_gids[i]);
27807 diff -NurpP --minimal linux-2.6.29/net/sunrpc/clnt.c linux-2.6.29-vs2.3.0.36.9-pre3/net/sunrpc/clnt.c
27808 --- linux-2.6.29/net/sunrpc/clnt.c 2009-03-24 14:22:48.000000000 +0100
27809 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/sunrpc/clnt.c 2009-03-24 14:48:37.000000000 +0100
27811 #include <linux/utsname.h>
27812 #include <linux/workqueue.h>
27813 #include <linux/in6.h>
27814 +#include <linux/vs_cvirt.h>
27816 #include <linux/sunrpc/clnt.h>
27817 #include <linux/sunrpc/rpc_pipe_fs.h>
27818 @@ -335,6 +336,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27819 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
27820 clnt->cl_chatty = 1;
27822 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27823 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27824 + clnt->cl_tag = 1; */
27827 EXPORT_SYMBOL_GPL(rpc_create);
27828 diff -NurpP --minimal linux-2.6.29/net/unix/af_unix.c linux-2.6.29-vs2.3.0.36.9-pre3/net/unix/af_unix.c
27829 --- linux-2.6.29/net/unix/af_unix.c 2009-03-24 14:22:48.000000000 +0100
27830 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/unix/af_unix.c 2009-03-24 14:48:37.000000000 +0100
27831 @@ -114,6 +114,8 @@
27832 #include <linux/mount.h>
27833 #include <net/checksum.h>
27834 #include <linux/security.h>
27835 +#include <linux/vs_context.h>
27836 +#include <linux/vs_limit.h>
27838 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
27839 static DEFINE_SPINLOCK(unix_table_lock);
27840 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
27841 if (!net_eq(sock_net(s), net))
27844 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27846 if (u->addr->len == len &&
27847 !memcmp(u->addr->name, sunname, len))
27849 @@ -2110,6 +2114,8 @@ static struct sock *unix_seq_idx(struct
27850 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
27851 if (sock_net(s) != seq_file_net(seq))
27853 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27858 @@ -2134,7 +2140,8 @@ static void *unix_seq_next(struct seq_fi
27859 sk = first_unix_socket(&iter->i);
27861 sk = next_unix_socket(&iter->i, sk);
27862 - while (sk && (sock_net(sk) != seq_file_net(seq)))
27863 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
27864 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
27865 sk = next_unix_socket(&iter->i, sk);
27868 diff -NurpP --minimal linux-2.6.29/net/x25/af_x25.c linux-2.6.29-vs2.3.0.36.9-pre3/net/x25/af_x25.c
27869 --- linux-2.6.29/net/x25/af_x25.c 2008-12-25 00:26:37.000000000 +0100
27870 +++ linux-2.6.29-vs2.3.0.36.9-pre3/net/x25/af_x25.c 2009-02-22 22:54:26.000000000 +0100
27871 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
27875 - sock_init_data(sock, sk);
27876 + sk->sk_socket = sock;
27877 + sk->sk_type = sock->type;
27878 + sk->sk_sleep = &sock->wait;
27881 x25_init_timers(sk);
27883 diff -NurpP --minimal linux-2.6.29/scripts/checksyscalls.sh linux-2.6.29-vs2.3.0.36.9-pre3/scripts/checksyscalls.sh
27884 --- linux-2.6.29/scripts/checksyscalls.sh 2008-12-25 00:26:37.000000000 +0100
27885 +++ linux-2.6.29-vs2.3.0.36.9-pre3/scripts/checksyscalls.sh 2009-02-22 22:54:26.000000000 +0100
27886 @@ -108,7 +108,6 @@ cat << EOF
27887 #define __IGNORE_afs_syscall
27888 #define __IGNORE_getpmsg
27889 #define __IGNORE_putpmsg
27890 -#define __IGNORE_vserver
27894 diff -NurpP --minimal linux-2.6.29/security/commoncap.c linux-2.6.29-vs2.3.0.36.9-pre3/security/commoncap.c
27895 --- linux-2.6.29/security/commoncap.c 2009-03-24 14:23:21.000000000 +0100
27896 +++ linux-2.6.29-vs2.3.0.36.9-pre3/security/commoncap.c 2009-03-25 00:34:48.000000000 +0100
27897 @@ -27,10 +27,11 @@
27898 #include <linux/sched.h>
27899 #include <linux/prctl.h>
27900 #include <linux/securebits.h>
27901 +#include <linux/vs_context.h>
27903 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27905 - NETLINK_CB(skb).eff_cap = current_cap();
27906 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
27910 @@ -40,6 +41,7 @@ int cap_netlink_recv(struct sk_buff *skb
27915 EXPORT_SYMBOL(cap_netlink_recv);
27918 @@ -60,7 +62,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
27919 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
27922 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
27923 + struct vx_info *vxi = tsk->vx_info;
27926 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
27927 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
27928 + cap_raised(tsk->cap_effective, cap),
27929 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
27932 + /* special case SETUP */
27933 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
27934 + /* FIXME: maybe use cred instead? */
27935 + cap_raised(tsk->cred->cap_effective, cap))
27938 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
27942 @@ -586,7 +603,7 @@ int cap_inode_setxattr(struct dentry *de
27944 if (!strncmp(name, XATTR_SECURITY_PREFIX,
27945 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
27946 - !capable(CAP_SYS_ADMIN))
27947 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
27951 @@ -931,7 +948,8 @@ error:
27953 int cap_syslog(int type)
27955 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
27956 + if ((type != 3 && type != 10) &&
27957 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27961 @@ -953,3 +971,4 @@ int cap_vm_enough_memory(struct mm_struc
27963 return __vm_enough_memory(mm, pages, cap_sys_admin);
27966 diff -NurpP --minimal linux-2.6.29/security/selinux/hooks.c linux-2.6.29-vs2.3.0.36.9-pre3/security/selinux/hooks.c
27967 --- linux-2.6.29/security/selinux/hooks.c 2009-03-24 14:23:21.000000000 +0100
27968 +++ linux-2.6.29-vs2.3.0.36.9-pre3/security/selinux/hooks.c 2009-03-24 14:48:37.000000000 +0100
27970 #include <linux/dccp.h>
27971 #include <linux/quota.h>
27972 #include <linux/un.h> /* for Unix socket types */
27973 -#include <net/af_unix.h> /* for Unix socket types */
27974 #include <linux/parser.h>
27975 #include <linux/nfs_mount.h>
27976 #include <net/ipv6.h>