1 diff -NurpP --minimal linux-2.6.27.25/arch/alpha/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/Kconfig
2 --- linux-2.6.27.25/arch/alpha/Kconfig 2008-10-13 14:51:51.000000000 +0200
3 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/Kconfig 2008-10-13 14:54:20.000000000 +0200
4 @@ -667,6 +667,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.27.25/arch/alpha/kernel/entry.S linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/entry.S
14 --- linux-2.6.27.25/arch/alpha/kernel/entry.S 2009-06-15 17:18:24.000000000 +0200
15 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/entry.S 2009-02-03 17:59:04.000000000 +0100
16 @@ -872,24 +872,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.27.25/arch/alpha/kernel/osf_sys.c linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.27.25/arch/alpha/kernel/osf_sys.c 2008-10-13 14:51:51.000000000 +0200
50 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/osf_sys.c 2008-10-13 14:54:20.000000000 +0200
51 @@ -888,7 +888,7 @@ osf_gettimeofday(struct timeval32 __user
55 - do_gettimeofday(&ktv);
56 + vx_gettimeofday(&ktv);
57 if (put_tv32(tv, &ktv))
60 diff -NurpP --minimal linux-2.6.27.25/arch/alpha/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.27.25/arch/alpha/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
62 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
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.27.25/arch/alpha/kernel/systbls.S linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/systbls.S
72 --- linux-2.6.27.25/arch/alpha/kernel/systbls.S 2009-06-15 17:18:24.000000000 +0200
73 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/systbls.S 2009-02-03 17:59:04.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.27.25/arch/alpha/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/traps.c
84 --- linux-2.6.27.25/arch/alpha/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
85 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
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.27.25/arch/alpha/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/mm/fault.c
97 --- linux-2.6.27.25/arch/alpha/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
98 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/alpha/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
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.27.25/arch/arm/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/arm/Kconfig
111 --- linux-2.6.27.25/arch/arm/Kconfig 2008-10-13 14:51:51.000000000 +0200
112 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/arm/Kconfig 2008-10-13 14:54:20.000000000 +0200
113 @@ -1240,6 +1240,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.27.25/arch/arm/kernel/calls.S linux-2.6.27.25-vs2.3.0.36.6/arch/arm/kernel/calls.S
123 --- linux-2.6.27.25/arch/arm/kernel/calls.S 2009-06-15 17:18:24.000000000 +0200
124 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/arm/kernel/calls.S 2009-02-03 17:59:04.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.27.25/arch/arm/kernel/process.c linux-2.6.27.25-vs2.3.0.36.6/arch/arm/kernel/process.c
135 --- linux-2.6.27.25/arch/arm/kernel/process.c 2008-10-13 14:51:52.000000000 +0200
136 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/arm/kernel/process.c 2008-10-13 14:54:20.000000000 +0200
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.27.25/arch/arm/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/arm/kernel/traps.c
148 --- linux-2.6.27.25/arch/arm/kernel/traps.c 2008-10-13 14:51:52.000000000 +0200
149 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/arm/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
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.27.25/arch/arm/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/arm/mm/fault.c
162 --- linux-2.6.27.25/arch/arm/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
163 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/arm/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
164 @@ -292,7 +292,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.27.25/arch/cris/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/cris/Kconfig
175 --- linux-2.6.27.25/arch/cris/Kconfig 2008-07-13 23:51:29.000000000 +0200
176 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/cris/Kconfig 2008-10-13 14:54:20.000000000 +0200
177 @@ -679,6 +679,8 @@ source "drivers/usb/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.27.25/arch/frv/kernel/kernel_thread.S linux-2.6.27.25-vs2.3.0.36.6/arch/frv/kernel/kernel_thread.S
187 --- linux-2.6.27.25/arch/frv/kernel/kernel_thread.S 2008-07-13 23:51:29.000000000 +0200
188 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/frv/kernel/kernel_thread.S 2008-10-13 14:54:20.000000000 +0200
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.27.25/arch/h8300/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/h8300/Kconfig
199 --- linux-2.6.27.25/arch/h8300/Kconfig 2008-10-13 14:51:55.000000000 +0200
200 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/h8300/Kconfig 2008-10-13 14:54:20.000000000 +0200
201 @@ -219,6 +219,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.27.25/arch/ia64/ia32/ia32_entry.S linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/ia32/ia32_entry.S
211 --- linux-2.6.27.25/arch/ia64/ia32/ia32_entry.S 2009-06-15 17:18:24.000000000 +0200
212 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/ia32/ia32_entry.S 2009-02-03 17:59:04.000000000 +0100
213 @@ -446,7 +446,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.27.25/arch/ia64/ia32/sys_ia32.c linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/ia32/sys_ia32.c
223 --- linux-2.6.27.25/arch/ia64/ia32/sys_ia32.c 2008-10-13 14:51:55.000000000 +0200
224 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/ia32/sys_ia32.c 2008-10-13 14:54:20.000000000 +0200
225 @@ -1178,7 +1178,7 @@ sys32_gettimeofday (struct compat_timeva
229 - do_gettimeofday(&ktv);
230 + vx_gettimeofday(&ktv);
231 if (put_tv32(tv, &ktv))
234 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/Kconfig
235 --- linux-2.6.27.25/arch/ia64/Kconfig 2009-06-15 17:18:24.000000000 +0200
236 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/Kconfig 2009-03-25 14:32:29.000000000 +0100
237 @@ -639,6 +639,8 @@ source "arch/ia64/hp/sim/Kconfig"
239 source "arch/ia64/Kconfig.debug"
241 +source "kernel/vserver/Kconfig"
243 source "security/Kconfig"
245 source "crypto/Kconfig"
246 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/kernel/entry.S linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/entry.S
247 --- linux-2.6.27.25/arch/ia64/kernel/entry.S 2009-06-15 17:18:24.000000000 +0200
248 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/entry.S 2009-02-03 17:59:04.000000000 +0100
249 @@ -1647,7 +1647,7 @@ sys_call_table:
251 data8 sys_mq_getsetattr
253 - data8 sys_ni_syscall // reserved for vserver
255 data8 sys_waitid // 1270
257 data8 sys_request_key
258 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/kernel/perfmon.c linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/perfmon.c
259 --- linux-2.6.27.25/arch/ia64/kernel/perfmon.c 2008-10-13 14:51:55.000000000 +0200
260 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/perfmon.c 2008-10-13 14:54:20.000000000 +0200
262 #include <linux/capability.h>
263 #include <linux/rcupdate.h>
264 #include <linux/completion.h>
265 +#include <linux/vs_memory.h>
267 #include <asm/errno.h>
268 #include <asm/intrinsics.h>
269 @@ -2376,7 +2377,7 @@ pfm_smpl_buffer_alloc(struct task_struct
271 insert_vm_struct(mm, vma);
273 - mm->total_vm += size >> PAGE_SHIFT;
274 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
275 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
277 up_write(&task->mm->mmap_sem);
278 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/kernel/process.c linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/process.c
279 --- linux-2.6.27.25/arch/ia64/kernel/process.c 2008-10-13 14:51:55.000000000 +0200
280 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/process.c 2008-10-13 14:54:20.000000000 +0200
281 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
282 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
285 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
286 - smp_processor_id(), current->comm);
287 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
288 + current->xid, smp_processor_id(), current->comm);
289 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
290 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
291 init_utsname()->release);
292 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/ptrace.c
293 --- linux-2.6.27.25/arch/ia64/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
294 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
296 #include <linux/signal.h>
297 #include <linux/regset.h>
298 #include <linux/elf.h>
299 +#include <linux/vs_base.h>
301 #include <asm/pgtable.h>
302 #include <asm/processor.h>
303 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/traps.c
304 --- linux-2.6.27.25/arch/ia64/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
305 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
306 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
309 if (++die.lock_owner_depth < 3) {
310 - printk("%s[%d]: %s %ld [%d]\n",
311 - current->comm, task_pid_nr(current), str, err, ++die_counter);
312 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
313 + current->comm, task_pid_nr(current), current->xid,
314 + str, err, ++die_counter);
315 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
318 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
319 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
320 last.time = current_jiffies + 5 * HZ;
322 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
323 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
324 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
325 + current->comm, task_pid_nr(current), current->xid,
326 + regs->cr_iip + ia64_psr(regs)->ri, isr);
330 diff -NurpP --minimal linux-2.6.27.25/arch/ia64/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/mm/fault.c
331 --- linux-2.6.27.25/arch/ia64/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
332 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/ia64/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
334 #include <linux/interrupt.h>
335 #include <linux/kprobes.h>
336 #include <linux/kdebug.h>
337 +#include <linux/vs_memory.h>
339 #include <asm/pgtable.h>
340 #include <asm/processor.h>
341 diff -NurpP --minimal linux-2.6.27.25/arch/m32r/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/m32r/kernel/traps.c
342 --- linux-2.6.27.25/arch/m32r/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
343 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/m32r/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
344 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
346 printk("SPI: %08lx\n", sp);
348 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
349 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
350 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
351 + current->comm, task_pid_nr(current), current->xid,
352 + 0xffff & i, 4096+(unsigned long)current);
355 * When in-kernel, we also print out the stack and code at the
356 diff -NurpP --minimal linux-2.6.27.25/arch/m68k/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/m68k/Kconfig
357 --- linux-2.6.27.25/arch/m68k/Kconfig 2008-10-13 14:51:55.000000000 +0200
358 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/m68k/Kconfig 2008-10-13 14:54:20.000000000 +0200
359 @@ -633,6 +633,8 @@ source "fs/Kconfig"
361 source "arch/m68k/Kconfig.debug"
363 +source "kernel/vserver/Kconfig"
365 source "security/Kconfig"
367 source "crypto/Kconfig"
368 diff -NurpP --minimal linux-2.6.27.25/arch/m68k/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/m68k/kernel/ptrace.c
369 --- linux-2.6.27.25/arch/m68k/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
370 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/m68k/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
372 #include <linux/ptrace.h>
373 #include <linux/user.h>
374 #include <linux/signal.h>
375 +#include <linux/vs_base.h>
377 #include <asm/uaccess.h>
378 #include <asm/page.h>
379 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
380 ret = ptrace_request(child, request, addr, data);
383 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
388 diff -NurpP --minimal linux-2.6.27.25/arch/m68k/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/m68k/kernel/traps.c
389 --- linux-2.6.27.25/arch/m68k/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
390 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/m68k/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
391 @@ -909,8 +909,8 @@ void show_registers(struct pt_regs *regs
392 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
393 regs->d4, regs->d5, regs->a0, regs->a1);
395 - printk("Process %s (pid: %d, task=%p)\n",
396 - current->comm, task_pid_nr(current), current);
397 + printk("Process %s (pid: %d[#%u], task=%p)\n",
398 + current->comm, task_pid_nr(current), current->xid, current);
399 addr = (unsigned long)&fp->un;
400 printk("Frame format=%X ", regs->format);
401 switch (regs->format) {
402 diff -NurpP --minimal linux-2.6.27.25/arch/m68knommu/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/m68knommu/Kconfig
403 --- linux-2.6.27.25/arch/m68knommu/Kconfig 2009-06-15 17:18:24.000000000 +0200
404 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/m68knommu/Kconfig 2009-02-22 22:58:32.000000000 +0100
405 @@ -744,6 +744,8 @@ source "fs/Kconfig"
407 source "arch/m68knommu/Kconfig.debug"
409 +source "kernel/vserver/Kconfig"
411 source "security/Kconfig"
413 source "crypto/Kconfig"
414 diff -NurpP --minimal linux-2.6.27.25/arch/m68knommu/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/m68knommu/kernel/traps.c
415 --- linux-2.6.27.25/arch/m68knommu/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
416 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/m68knommu/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
417 @@ -79,8 +79,9 @@ void die_if_kernel(char *str, struct pt_
418 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
419 fp->d4, fp->d5, fp->a0, fp->a1);
421 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
422 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
423 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
424 + current->comm, task_pid_nr(current), current->xid,
425 + PAGE_SIZE+(unsigned long)current);
426 show_stack(NULL, (unsigned long *)(fp + 1));
427 add_taint(TAINT_DIE);
429 diff -NurpP --minimal linux-2.6.27.25/arch/mips/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/mips/Kconfig
430 --- linux-2.6.27.25/arch/mips/Kconfig 2009-06-15 17:18:24.000000000 +0200
431 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/Kconfig 2009-05-15 22:57:04.000000000 +0200
432 @@ -2032,6 +2032,8 @@ source "fs/Kconfig"
434 source "arch/mips/Kconfig.debug"
436 +source "kernel/vserver/Kconfig"
438 source "security/Kconfig"
440 source "crypto/Kconfig"
441 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/linux32.c linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/linux32.c
442 --- linux-2.6.27.25/arch/mips/kernel/linux32.c 2009-06-15 17:18:24.000000000 +0200
443 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/linux32.c 2009-05-15 22:57:04.000000000 +0200
444 @@ -192,7 +192,7 @@ sys32_gettimeofday(struct compat_timeval
448 - do_gettimeofday(&ktv);
449 + vx_gettimeofday(&ktv);
450 if (put_tv32(tv, &ktv))
453 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/ptrace.c
454 --- linux-2.6.27.25/arch/mips/kernel/ptrace.c 2008-10-13 14:51:56.000000000 +0200
455 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
457 #include <linux/security.h>
458 #include <linux/audit.h>
459 #include <linux/seccomp.h>
460 +#include <linux/vs_base.h>
462 #include <asm/byteorder.h>
464 @@ -171,6 +172,9 @@ long arch_ptrace(struct task_struct *chi
468 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
472 /* when I and D space are separate, these will need to be fixed. */
473 case PTRACE_PEEKTEXT: /* read word at location addr. */
474 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/scall32-o32.S linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall32-o32.S
475 --- linux-2.6.27.25/arch/mips/kernel/scall32-o32.S 2009-06-15 17:18:24.000000000 +0200
476 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall32-o32.S 2009-05-15 22:57:04.000000000 +0200
477 @@ -600,7 +600,7 @@ einval: li v0, -EINVAL
478 sys sys_mq_timedreceive 5
479 sys sys_mq_notify 2 /* 4275 */
480 sys sys_mq_getsetattr 3
481 - sys sys_ni_syscall 0 /* sys_vserver */
484 sys sys_ni_syscall 0 /* available, was setaltroot */
485 sys sys_add_key 5 /* 4280 */
486 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/scall64-64.S linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall64-64.S
487 --- linux-2.6.27.25/arch/mips/kernel/scall64-64.S 2009-06-15 17:18:24.000000000 +0200
488 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall64-64.S 2009-05-15 22:57:04.000000000 +0200
489 @@ -434,7 +434,7 @@ sys_call_table:
490 PTR sys_mq_timedreceive
492 PTR sys_mq_getsetattr /* 5235 */
493 - PTR sys_ni_syscall /* sys_vserver */
496 PTR sys_ni_syscall /* available, was setaltroot */
498 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/scall64-n32.S linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall64-n32.S
499 --- linux-2.6.27.25/arch/mips/kernel/scall64-n32.S 2009-06-15 17:18:24.000000000 +0200
500 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall64-n32.S 2009-05-15 22:57:04.000000000 +0200
501 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
502 PTR compat_sys_mq_timedreceive
503 PTR compat_sys_mq_notify
504 PTR compat_sys_mq_getsetattr
505 - PTR sys_ni_syscall /* 6240, sys_vserver */
506 + PTR sys32_vserver /* 6240 */
507 PTR compat_sys_waitid
508 PTR sys_ni_syscall /* available, was setaltroot */
510 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/scall64-o32.S linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall64-o32.S
511 --- linux-2.6.27.25/arch/mips/kernel/scall64-o32.S 2009-06-15 17:18:24.000000000 +0200
512 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/scall64-o32.S 2009-05-15 22:57:46.000000000 +0200
513 @@ -482,7 +482,7 @@ sys_call_table:
514 PTR compat_sys_mq_timedreceive
515 PTR compat_sys_mq_notify /* 4275 */
516 PTR compat_sys_mq_getsetattr
517 - PTR sys_ni_syscall /* sys_vserver */
520 PTR sys_ni_syscall /* available, was setaltroot */
521 PTR sys_add_key /* 4280 */
522 diff -NurpP --minimal linux-2.6.27.25/arch/mips/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/traps.c
523 --- linux-2.6.27.25/arch/mips/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
524 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
525 @@ -328,9 +328,10 @@ void show_registers(const struct pt_regs
529 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
530 - current->comm, current->pid, current_thread_info(), current,
531 - field, current_thread_info()->tp_value);
532 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
533 + current->comm, task_pid_nr(current), current->xid,
534 + current_thread_info(), current,
535 + field, current_thread_info()->tp_value);
536 if (cpu_has_userlocal) {
539 diff -NurpP --minimal linux-2.6.27.25/arch/mips/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/mips/mm/fault.c
540 --- linux-2.6.27.25/arch/mips/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
541 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/mips/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
542 @@ -178,7 +178,8 @@ out_of_memory:
543 down_read(&mm->mmap_sem);
546 - printk("VM: killing process %s\n", tsk->comm);
547 + printk("VM: killing process %s(%d:#%u)\n",
548 + tsk->comm, tsk->pid, tsk->xid);
550 do_group_exit(SIGKILL);
552 diff -NurpP --minimal linux-2.6.27.25/arch/parisc/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/Kconfig
553 --- linux-2.6.27.25/arch/parisc/Kconfig 2008-10-13 14:51:56.000000000 +0200
554 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/Kconfig 2008-10-13 14:54:20.000000000 +0200
555 @@ -279,6 +279,8 @@ source "fs/Kconfig"
557 source "arch/parisc/Kconfig.debug"
559 +source "kernel/vserver/Kconfig"
561 source "security/Kconfig"
563 source "crypto/Kconfig"
564 diff -NurpP --minimal linux-2.6.27.25/arch/parisc/kernel/syscall_table.S linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/kernel/syscall_table.S
565 --- linux-2.6.27.25/arch/parisc/kernel/syscall_table.S 2008-07-13 23:51:29.000000000 +0200
566 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/kernel/syscall_table.S 2008-10-13 14:54:20.000000000 +0200
568 ENTRY_COMP(mbind) /* 260 */
569 ENTRY_COMP(get_mempolicy)
570 ENTRY_COMP(set_mempolicy)
571 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
572 + ENTRY_DIFF(vserver)
574 ENTRY_SAME(request_key) /* 265 */
576 diff -NurpP --minimal linux-2.6.27.25/arch/parisc/kernel/sys_parisc32.c linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/kernel/sys_parisc32.c
577 --- linux-2.6.27.25/arch/parisc/kernel/sys_parisc32.c 2008-07-13 23:51:29.000000000 +0200
578 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/kernel/sys_parisc32.c 2008-10-13 14:54:20.000000000 +0200
579 @@ -203,11 +203,11 @@ static inline long get_ts32(struct times
581 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
583 - extern void do_gettimeofday(struct timeval *tv);
584 + extern void vx_gettimeofday(struct timeval *tv);
588 - do_gettimeofday(&ktv);
589 + vx_gettimeofday(&ktv);
590 if (put_compat_timeval(tv, &ktv))
593 diff -NurpP --minimal linux-2.6.27.25/arch/parisc/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/kernel/traps.c
594 --- linux-2.6.27.25/arch/parisc/kernel/traps.c 2009-06-15 17:18:24.000000000 +0200
595 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/kernel/traps.c 2009-02-03 17:59:04.000000000 +0100
596 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
600 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
601 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
602 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
603 + current->comm, task_pid_nr(current), current->xid,
604 + str, err, regs->iaoq[0]);
605 #ifdef PRINT_USER_FAULTS
606 /* XXX for debugging only */
608 @@ -269,8 +270,8 @@ KERN_CRIT " || |
609 pdc_console_restart();
612 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
613 - current->comm, task_pid_nr(current), str, err);
614 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
615 + current->comm, task_pid_nr(current), current->xid, str, err);
617 /* Wot's wrong wif bein' racy? */
618 if (current->thread.flags & PARISC_KERNEL_DEATH) {
619 diff -NurpP --minimal linux-2.6.27.25/arch/parisc/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/mm/fault.c
620 --- linux-2.6.27.25/arch/parisc/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
621 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/parisc/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
622 @@ -210,8 +210,9 @@ bad_area:
624 #ifdef PRINT_USER_FAULTS
625 printk(KERN_DEBUG "\n");
626 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
627 - task_pid_nr(tsk), tsk->comm, code, address);
628 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
629 + "command='%s' type=%lu address=0x%08lx\n",
630 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
632 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
633 vma->vm_start, vma->vm_end);
634 @@ -261,7 +262,8 @@ no_context:
637 up_read(&mm->mmap_sem);
638 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
639 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
640 + current->comm, current->pid, current->xid);
642 do_group_exit(SIGKILL);
644 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/Kconfig
645 --- linux-2.6.27.25/arch/powerpc/Kconfig 2009-06-15 17:18:24.000000000 +0200
646 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/Kconfig 2009-02-03 17:59:04.000000000 +0100
647 @@ -836,6 +836,8 @@ source "lib/Kconfig"
649 source "arch/powerpc/Kconfig.debug"
651 +source "kernel/vserver/Kconfig"
653 source "security/Kconfig"
656 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/kernel/irq.c linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/irq.c
657 --- linux-2.6.27.25/arch/powerpc/kernel/irq.c 2008-10-13 14:51:56.000000000 +0200
658 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/irq.c 2008-10-13 14:54:20.000000000 +0200
660 #include <linux/bootmem.h>
661 #include <linux/pci.h>
662 #include <linux/debugfs.h>
663 +#include <linux/vs_context.h>
665 #include <asm/uaccess.h>
666 #include <asm/system.h>
667 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/kernel/process.c linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/process.c
668 --- linux-2.6.27.25/arch/powerpc/kernel/process.c 2008-10-13 14:51:56.000000000 +0200
669 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/process.c 2008-10-13 14:54:20.000000000 +0200
670 @@ -513,8 +513,9 @@ void show_regs(struct pt_regs * regs)
672 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
674 - printk("TASK = %p[%d] '%s' THREAD: %p",
675 - current, task_pid_nr(current), current->comm, task_thread_info(current));
676 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
677 + current, task_pid_nr(current), current->xid,
678 + current->comm, task_thread_info(current));
681 printk(" CPU: %d", raw_smp_processor_id());
682 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/kernel/sys_ppc32.c linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/sys_ppc32.c
683 --- linux-2.6.27.25/arch/powerpc/kernel/sys_ppc32.c 2008-10-13 14:51:56.000000000 +0200
684 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/sys_ppc32.c 2008-10-13 14:54:20.000000000 +0200
685 @@ -147,7 +147,7 @@ asmlinkage long compat_sys_gettimeofday(
689 - do_gettimeofday(&ktv);
690 + vx_gettimeofday(&ktv);
691 if (put_tv32(tv, &ktv))
694 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/traps.c
695 --- linux-2.6.27.25/arch/powerpc/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
696 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
697 @@ -941,8 +941,9 @@ void nonrecoverable_exception(struct pt_
699 void trace_syscall(struct pt_regs *regs)
701 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
702 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
703 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
704 + current, task_pid_nr(current), current->xid,
705 + regs->nip, regs->link, regs->gpr[0],
706 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
709 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/kernel/vdso.c linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/vdso.c
710 --- linux-2.6.27.25/arch/powerpc/kernel/vdso.c 2008-10-13 14:51:56.000000000 +0200
711 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/kernel/vdso.c 2008-10-13 14:54:20.000000000 +0200
713 #include <linux/security.h>
714 #include <linux/bootmem.h>
715 #include <linux/lmb.h>
716 +#include <linux/vs_memory.h>
718 #include <asm/pgtable.h>
719 #include <asm/system.h>
720 diff -NurpP --minimal linux-2.6.27.25/arch/powerpc/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/mm/fault.c
721 --- linux-2.6.27.25/arch/powerpc/mm/fault.c 2008-10-13 14:51:56.000000000 +0200
722 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/powerpc/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
723 @@ -354,7 +354,8 @@ out_of_memory:
724 down_read(&mm->mmap_sem);
727 - printk("VM: killing process %s\n", current->comm);
728 + printk("VM: killing process %s(%d:#%u)\n",
729 + current->comm, current->pid, current->xid);
731 do_group_exit(SIGKILL);
733 diff -NurpP --minimal linux-2.6.27.25/arch/s390/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/s390/Kconfig
734 --- linux-2.6.27.25/arch/s390/Kconfig 2009-06-15 17:18:25.000000000 +0200
735 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/s390/Kconfig 2009-02-03 17:59:04.000000000 +0100
736 @@ -588,6 +588,8 @@ source "fs/Kconfig"
738 source "arch/s390/Kconfig.debug"
740 +source "kernel/vserver/Kconfig"
742 source "security/Kconfig"
744 source "crypto/Kconfig"
745 diff -NurpP --minimal linux-2.6.27.25/arch/s390/kernel/compat_linux.c linux-2.6.27.25-vs2.3.0.36.6/arch/s390/kernel/compat_linux.c
746 --- linux-2.6.27.25/arch/s390/kernel/compat_linux.c 2008-07-13 23:51:29.000000000 +0200
747 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/s390/kernel/compat_linux.c 2008-10-13 14:54:20.000000000 +0200
748 @@ -566,7 +566,7 @@ asmlinkage long sys32_gettimeofday(struc
752 - do_gettimeofday(&ktv);
753 + vx_gettimeofday(&ktv);
754 if (put_tv32(tv, &ktv))
757 diff -NurpP --minimal linux-2.6.27.25/arch/s390/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/s390/kernel/ptrace.c
758 --- linux-2.6.27.25/arch/s390/kernel/ptrace.c 2008-10-13 14:51:57.000000000 +0200
759 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/s390/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
761 #include <linux/signal.h>
762 #include <linux/elf.h>
763 #include <linux/regset.h>
764 +#include <linux/vs_base.h>
766 #include <asm/segment.h>
767 #include <asm/page.h>
768 diff -NurpP --minimal linux-2.6.27.25/arch/s390/kernel/syscalls.S linux-2.6.27.25-vs2.3.0.36.6/arch/s390/kernel/syscalls.S
769 --- linux-2.6.27.25/arch/s390/kernel/syscalls.S 2009-06-15 17:18:25.000000000 +0200
770 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/s390/kernel/syscalls.S 2009-02-03 17:59:04.000000000 +0100
771 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
772 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
773 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
774 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
775 -NI_SYSCALL /* reserved for vserver */
776 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
777 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
778 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
779 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
780 diff -NurpP --minimal linux-2.6.27.25/arch/s390/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/s390/mm/fault.c
781 --- linux-2.6.27.25/arch/s390/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
782 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/s390/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
783 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
784 down_read(&mm->mmap_sem);
787 - printk("VM: killing process %s\n", tsk->comm);
788 + printk("VM: killing process %s(%d:#%u)\n",
789 + tsk->comm, tsk->pid, tsk->xid);
790 if (regs->psw.mask & PSW_MASK_PSTATE)
791 do_group_exit(SIGKILL);
792 do_no_context(regs, error_code, address);
793 diff -NurpP --minimal linux-2.6.27.25/arch/sh/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/sh/Kconfig
794 --- linux-2.6.27.25/arch/sh/Kconfig 2008-10-13 14:51:57.000000000 +0200
795 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sh/Kconfig 2008-10-13 14:54:20.000000000 +0200
796 @@ -747,6 +747,8 @@ source "fs/Kconfig"
798 source "arch/sh/Kconfig.debug"
800 +source "kernel/vserver/Kconfig"
802 source "security/Kconfig"
804 source "crypto/Kconfig"
805 diff -NurpP --minimal linux-2.6.27.25/arch/sh/kernel/irq.c linux-2.6.27.25-vs2.3.0.36.6/arch/sh/kernel/irq.c
806 --- linux-2.6.27.25/arch/sh/kernel/irq.c 2008-10-13 14:51:57.000000000 +0200
807 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sh/kernel/irq.c 2008-10-13 14:54:20.000000000 +0200
809 #include <linux/module.h>
810 #include <linux/kernel_stat.h>
811 #include <linux/seq_file.h>
812 +#include <linux/vs_context.h>
813 #include <asm/processor.h>
814 #include <asm/machvec.h>
815 #include <asm/uaccess.h>
816 diff -NurpP --minimal linux-2.6.27.25/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.27.25-vs2.3.0.36.6/arch/sh/kernel/vsyscall/vsyscall.c
817 --- linux-2.6.27.25/arch/sh/kernel/vsyscall/vsyscall.c 2008-07-13 23:51:29.000000000 +0200
818 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sh/kernel/vsyscall/vsyscall.c 2008-10-13 14:54:20.000000000 +0200
820 #include <linux/elf.h>
821 #include <linux/sched.h>
822 #include <linux/err.h>
823 +#include <linux/vs_memory.h>
826 * Should the kernel map a VDSO page into processes and pass its
827 diff -NurpP --minimal linux-2.6.27.25/arch/sparc/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/Kconfig
828 --- linux-2.6.27.25/arch/sparc/Kconfig 2008-10-13 14:51:58.000000000 +0200
829 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/Kconfig 2008-10-13 14:54:20.000000000 +0200
830 @@ -305,6 +305,8 @@ source "fs/Kconfig"
832 source "arch/sparc/Kconfig.debug"
834 +source "kernel/vserver/Kconfig"
836 source "security/Kconfig"
838 source "crypto/Kconfig"
839 diff -NurpP --minimal linux-2.6.27.25/arch/sparc/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/kernel/ptrace.c
840 --- linux-2.6.27.25/arch/sparc/kernel/ptrace.c 2008-10-13 14:51:58.000000000 +0200
841 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/kernel/ptrace.c 2008-10-13 14:54:20.000000000 +0200
843 #include <linux/regset.h>
844 #include <linux/elf.h>
845 #include <linux/tracehook.h>
846 +#include <linux/vs_base.h>
848 #include <asm/pgtable.h>
849 #include <asm/system.h>
850 diff -NurpP --minimal linux-2.6.27.25/arch/sparc/kernel/systbls.S linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/kernel/systbls.S
851 --- linux-2.6.27.25/arch/sparc/kernel/systbls.S 2009-06-15 17:18:25.000000000 +0200
852 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/kernel/systbls.S 2009-02-03 17:59:04.000000000 +0100
853 @@ -70,7 +70,7 @@ sys_call_table:
854 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
855 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
856 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
857 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
858 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
859 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
860 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
861 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
862 diff -NurpP --minimal linux-2.6.27.25/arch/sparc/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/kernel/traps.c
863 --- linux-2.6.27.25/arch/sparc/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
864 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
865 @@ -95,7 +95,8 @@ void die_if_kernel(char *str, struct pt_
869 - printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
870 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
871 + task_pid_nr(current), current->xid, str, ++die_counter);
873 add_taint(TAINT_DIE);
875 diff -NurpP --minimal linux-2.6.27.25/arch/sparc/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/mm/fault.c
876 --- linux-2.6.27.25/arch/sparc/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
877 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
878 @@ -318,7 +318,8 @@ no_context:
881 up_read(&mm->mmap_sem);
882 - printk("VM: killing process %s\n", tsk->comm);
883 + printk("VM: killing process %s(%d:#%u)\n",
884 + tsk->comm, tsk->pid, tsk->xid);
886 do_group_exit(SIGKILL);
888 diff -NurpP --minimal linux-2.6.27.25/arch/sparc64/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/Kconfig
889 --- linux-2.6.27.25/arch/sparc64/Kconfig 2009-06-15 17:18:25.000000000 +0200
890 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/Kconfig 2009-02-22 22:58:32.000000000 +0100
891 @@ -404,6 +404,8 @@ source "fs/Kconfig"
893 source "arch/sparc64/Kconfig.debug"
895 +source "kernel/vserver/Kconfig"
897 source "security/Kconfig"
899 source "crypto/Kconfig"
900 diff -NurpP --minimal linux-2.6.27.25/arch/sparc64/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/ptrace.c
901 --- linux-2.6.27.25/arch/sparc64/kernel/ptrace.c 2009-06-15 17:18:25.000000000 +0200
902 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/ptrace.c 2009-02-03 17:59:04.000000000 +0100
904 #include <linux/tracehook.h>
905 #include <linux/compat.h>
906 #include <linux/elf.h>
907 +#include <linux/vs_base.h>
910 #include <asm/pgtable.h>
911 diff -NurpP --minimal linux-2.6.27.25/arch/sparc64/kernel/sys_sparc32.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/sys_sparc32.c
912 --- linux-2.6.27.25/arch/sparc64/kernel/sys_sparc32.c 2008-10-13 14:51:58.000000000 +0200
913 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/sys_sparc32.c 2008-10-13 14:54:20.000000000 +0200
914 @@ -532,7 +532,7 @@ asmlinkage long sys32_gettimeofday(struc
918 - do_gettimeofday(&ktv);
919 + vx_gettimeofday(&ktv);
920 if (put_tv32(tv, &ktv))
923 diff -NurpP --minimal linux-2.6.27.25/arch/sparc64/kernel/systbls.S linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/systbls.S
924 --- linux-2.6.27.25/arch/sparc64/kernel/systbls.S 2009-06-15 17:18:25.000000000 +0200
925 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/systbls.S 2009-02-22 22:58:32.000000000 +0100
926 @@ -71,7 +71,7 @@ sys_call_table32:
927 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
928 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
929 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
930 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
931 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
932 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
933 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
934 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
935 @@ -145,7 +145,7 @@ sys_call_table:
936 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
937 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
938 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
939 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
940 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
941 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
942 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
943 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
944 diff -NurpP --minimal linux-2.6.27.25/arch/sparc64/kernel/traps.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/traps.c
945 --- linux-2.6.27.25/arch/sparc64/kernel/traps.c 2009-06-15 17:18:25.000000000 +0200
946 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/kernel/traps.c 2009-03-25 14:32:29.000000000 +0100
947 @@ -2201,7 +2201,8 @@ void die_if_kernel(char *str, struct pt_
951 - printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
952 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
953 + task_pid_nr(current), current->xid, str, ++die_counter);
954 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
955 __asm__ __volatile__("flushw");
957 diff -NurpP --minimal linux-2.6.27.25/arch/sparc64/mm/fault.c linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/mm/fault.c
958 --- linux-2.6.27.25/arch/sparc64/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
959 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/sparc64/mm/fault.c 2008-10-13 14:54:20.000000000 +0200
960 @@ -452,7 +452,8 @@ handle_kernel_fault:
962 insn = get_fault_insn(regs, insn);
963 up_read(&mm->mmap_sem);
964 - printk("VM: killing process %s\n", current->comm);
965 + printk("VM: killing process %s(%d:#%u)\n",
966 + current->comm, current->pid, current->xid);
967 if (!(regs->tstate & TSTATE_PRIV))
968 do_group_exit(SIGKILL);
969 goto handle_kernel_fault;
970 diff -NurpP --minimal linux-2.6.27.25/arch/um/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/um/Kconfig
971 --- linux-2.6.27.25/arch/um/Kconfig 2008-07-13 23:51:29.000000000 +0200
972 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/um/Kconfig 2008-10-13 14:54:20.000000000 +0200
973 @@ -245,6 +245,8 @@ source "drivers/connector/Kconfig"
977 +source "kernel/vserver/Kconfig"
979 source "security/Kconfig"
981 source "crypto/Kconfig"
982 diff -NurpP --minimal linux-2.6.27.25/arch/um/kernel/trap.c linux-2.6.27.25-vs2.3.0.36.6/arch/um/kernel/trap.c
983 --- linux-2.6.27.25/arch/um/kernel/trap.c 2008-07-13 23:51:29.000000000 +0200
984 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/um/kernel/trap.c 2008-10-13 14:54:20.000000000 +0200
985 @@ -215,7 +215,8 @@ unsigned long segv(struct faultinfo fi,
986 current->thread.arch.faultinfo = fi;
987 force_sig_info(SIGBUS, &si, current);
988 } else if (err == -ENOMEM) {
989 - printk(KERN_INFO "VM: killing process %s\n", current->comm);
990 + printk(KERN_INFO "VM: killing process %s(%d:#%u)\n",
991 + current->comm, task_pid_nr(current), current->xid);
994 BUG_ON(err != -EFAULT);
995 diff -NurpP --minimal linux-2.6.27.25/arch/x86/ia32/ia32entry.S linux-2.6.27.25-vs2.3.0.36.6/arch/x86/ia32/ia32entry.S
996 --- linux-2.6.27.25/arch/x86/ia32/ia32entry.S 2009-06-15 17:18:25.000000000 +0200
997 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/x86/ia32/ia32entry.S 2009-03-25 14:32:29.000000000 +0100
998 @@ -774,7 +774,7 @@ ia32_sys_call_table:
999 .quad sys_tgkill /* 270 */
1000 .quad compat_sys_utimes
1001 .quad sys32_fadvise64_64
1002 - .quad quiet_ni_syscall /* sys_vserver */
1003 + .quad sys32_vserver
1005 .quad compat_sys_get_mempolicy /* 275 */
1006 .quad sys_set_mempolicy
1007 diff -NurpP --minimal linux-2.6.27.25/arch/x86/Kconfig linux-2.6.27.25-vs2.3.0.36.6/arch/x86/Kconfig
1008 --- linux-2.6.27.25/arch/x86/Kconfig 2009-06-15 17:18:25.000000000 +0200
1009 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/x86/Kconfig 2009-02-22 22:58:32.000000000 +0100
1010 @@ -1811,6 +1811,8 @@ source "fs/Kconfig"
1012 source "arch/x86/Kconfig.debug"
1014 +source "kernel/vserver/Kconfig"
1016 source "security/Kconfig"
1018 source "crypto/Kconfig"
1019 diff -NurpP --minimal linux-2.6.27.25/arch/x86/kernel/syscall_table_32.S linux-2.6.27.25-vs2.3.0.36.6/arch/x86/kernel/syscall_table_32.S
1020 --- linux-2.6.27.25/arch/x86/kernel/syscall_table_32.S 2009-06-15 17:18:26.000000000 +0200
1021 +++ linux-2.6.27.25-vs2.3.0.36.6/arch/x86/kernel/syscall_table_32.S 2009-02-03 17:59:04.000000000 +0100
1022 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1023 .long sys_tgkill /* 270 */
1025 .long sys_fadvise64_64
1026 - .long sys_ni_syscall /* sys_vserver */
1029 .long sys_get_mempolicy
1030 .long sys_set_mempolicy
1031 diff -NurpP --minimal linux-2.6.27.25/Documentation/vserver/debug.txt linux-2.6.27.25-vs2.3.0.36.6/Documentation/vserver/debug.txt
1032 --- linux-2.6.27.25/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1033 +++ linux-2.6.27.25-vs2.3.0.36.6/Documentation/vserver/debug.txt 2008-10-13 14:54:20.000000000 +0200
1038 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1039 + "vx_rmap_tgid: %p/%llx: %d -> %d"
1043 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
1044 + "FREE (%p,#%d)%c inode"
1045 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1046 + "FREE (%p,#%d)%c %lld bytes"
1047 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1048 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1049 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1050 + "rcu_free_dl_info(%p)"
1051 + 4 10 "alloc_dl_info(%p,%d) = %p"
1052 + "dealloc_dl_info(%p)"
1053 + "get_dl_info(%p[#%d.%d])"
1054 + "put_dl_info(%p[#%d.%d])"
1055 + 5 20 "alloc_dl_info(%p,%d)*"
1056 + 6 40 "__hash_dl_info: %p[#%d]"
1057 + "__unhash_dl_info: %p[#%d]"
1058 + 7 80 "locate_dl_info(%p,#%d) = %p"
1062 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
1063 + "new_dqhash: %p [#0x%08x]"
1064 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1065 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1066 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1067 + "vroot_get_real_bdev not set"
1068 + 1 2 "cow_break_link(»%s«)"
1069 + "temp copy »%s«"
1070 + 2 4 "dentry_open(new): %p"
1071 + "dentry_open(old): %p"
1072 + "lookup_create(new): %p"
1074 + "path_lookup(old): %d"
1075 + "vfs_create(new): %d"
1077 + "vfs_sendfile: %d"
1078 + 3 8 "fput(new_file=%p[#%d])"
1079 + "fput(old_file=%p[#%d])"
1080 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1081 + "vx_info_kill(%p[#%d],%d,%d)*"
1082 + 5 20 "vs_reboot(%p[#%d],%d)"
1083 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1087 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1088 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1089 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
1090 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
1091 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
1092 + 6 40 "sk,egf: %p [#%d] (from %d)"
1093 + "sk,egn: %p [#%d] (from %d)"
1094 + "sk,req: %p [#%d] (from %d)"
1095 + "sk: %p [#%d] (from %d)"
1096 + "tw: %p [#%d] (from %d)"
1097 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
1098 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
1102 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
1103 + "alloc_nx_info(%d) = %p"
1104 + "create_nx_info(%d) (dynamic rejected)"
1105 + "create_nx_info(%d) = %p (already there)"
1106 + "create_nx_info(%d) = %p (new)"
1107 + "dealloc_nx_info(%p)"
1108 + 1 2 "alloc_nx_info(%d)*"
1109 + "create_nx_info(%d)*"
1110 + 2 4 "get_nx_info(%p[#%d.%d])"
1111 + "put_nx_info(%p[#%d.%d])"
1112 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1113 + "clr_nx_info(%p[#%d.%d])"
1114 + "init_nx_info(%p[#%d.%d])"
1115 + "release_nx_info(%p[#%d.%d.%d]) %p"
1116 + "set_nx_info(%p[#%d.%d])"
1117 + 4 10 "__hash_nx_info: %p[#%d]"
1118 + "__nx_dynamic_id: [#%d]"
1119 + "__unhash_nx_info: %p[#%d.%d.%d]"
1120 + 5 20 "moved task %p into nxi:%p[#%d]"
1121 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
1122 + "task_get_nx_info(%p)"
1123 + 6 40 "nx_clear_persistent(%p[#%d])"
1127 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
1128 + 1 2 "quota_sync_dqh(%p,%d)"
1129 + "sync_dquots(%p,%d)"
1130 + "sync_dquots_dqh(%p,%d)"
1131 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1135 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1136 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1137 + 4 10 "%s: (%s %s) returned %s with %d"
1141 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1142 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1146 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1147 + "alloc_vx_info(%d) = %p"
1148 + "alloc_vx_info(%d)*"
1149 + "create_vx_info(%d) (dynamic rejected)"
1150 + "create_vx_info(%d) = %p (already there)"
1151 + "create_vx_info(%d) = %p (new)"
1152 + "dealloc_vx_info(%p)"
1153 + "loc_vx_info(%d) = %p (found)"
1154 + "loc_vx_info(%d) = %p (new)"
1155 + "loc_vx_info(%d) = %p (not available)"
1156 + 1 2 "create_vx_info(%d)*"
1157 + "loc_vx_info(%d)*"
1158 + 2 4 "get_vx_info(%p[#%d.%d])"
1159 + "put_vx_info(%p[#%d.%d])"
1160 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1161 + "clr_vx_info(%p[#%d.%d])"
1162 + "init_vx_info(%p[#%d.%d])"
1163 + "release_vx_info(%p[#%d.%d.%d]) %p"
1164 + "set_vx_info(%p[#%d.%d])"
1165 + 4 10 "__hash_vx_info: %p[#%d]"
1166 + "__unhash_vx_info: %p[#%d.%d.%d]"
1167 + "__vx_dynamic_id: [#%d]"
1168 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1169 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1170 + "moved task %p into vxi:%p[#%d]"
1171 + "task_get_vx_info(%p)"
1172 + "vx_migrate_task(%p,%p[#%d.%d])"
1173 + 6 40 "vx_clear_persistent(%p[#%d])"
1174 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1175 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1176 + "vx_set_persistent(%p[#%d])"
1177 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1178 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1183 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1184 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1186 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1187 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1188 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1189 diff -NurpP --minimal linux-2.6.27.25/drivers/block/Kconfig linux-2.6.27.25-vs2.3.0.36.6/drivers/block/Kconfig
1190 --- linux-2.6.27.25/drivers/block/Kconfig 2008-10-13 14:51:59.000000000 +0200
1191 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/block/Kconfig 2008-10-13 14:54:20.000000000 +0200
1192 @@ -263,6 +263,13 @@ config BLK_DEV_CRYPTOLOOP
1193 instead, which can be configured to be on-disk compatible with the
1196 +config BLK_DEV_VROOT
1197 + tristate "Virtual Root device support"
1198 + depends on QUOTACTL
1200 + Saying Y here will allow you to use quota/fs ioctls on a shared
1201 + partition within a virtual server without compromising security.
1204 tristate "Network block device support"
1206 diff -NurpP --minimal linux-2.6.27.25/drivers/block/loop.c linux-2.6.27.25-vs2.3.0.36.6/drivers/block/loop.c
1207 --- linux-2.6.27.25/drivers/block/loop.c 2008-07-13 23:51:29.000000000 +0200
1208 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/block/loop.c 2008-10-13 14:54:20.000000000 +0200
1210 #include <linux/gfp.h>
1211 #include <linux/kthread.h>
1212 #include <linux/splice.h>
1213 +#include <linux/vs_context.h>
1215 #include <asm/uaccess.h>
1217 @@ -794,6 +795,7 @@ static int loop_set_fd(struct loop_devic
1218 lo->lo_blocksize = lo_blocksize;
1219 lo->lo_device = bdev;
1220 lo->lo_flags = lo_flags;
1221 + lo->lo_xid = vx_current_xid();
1222 lo->lo_backing_file = file;
1223 lo->transfer = transfer_none;
1225 @@ -915,6 +917,7 @@ static int loop_clr_fd(struct loop_devic
1226 lo->lo_encrypt_key_size = 0;
1228 lo->lo_thread = NULL;
1230 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1231 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1232 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1233 @@ -938,7 +941,7 @@ loop_set_status(struct loop_device *lo,
1234 struct loop_func_table *xfer;
1236 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
1237 - !capable(CAP_SYS_ADMIN))
1238 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1240 if (lo->lo_state != Lo_bound)
1242 @@ -1022,7 +1025,8 @@ loop_get_status(struct loop_device *lo,
1243 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1244 info->lo_encrypt_type =
1245 lo->lo_encryption ? lo->lo_encryption->number : 0;
1246 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1247 + if (lo->lo_encrypt_key_size &&
1248 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1249 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1250 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1251 lo->lo_encrypt_key_size);
1252 @@ -1331,6 +1335,9 @@ static int lo_open(struct inode *inode,
1254 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1256 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1259 mutex_lock(&lo->lo_ctl_mutex);
1261 mutex_unlock(&lo->lo_ctl_mutex);
1262 diff -NurpP --minimal linux-2.6.27.25/drivers/block/Makefile linux-2.6.27.25-vs2.3.0.36.6/drivers/block/Makefile
1263 --- linux-2.6.27.25/drivers/block/Makefile 2008-10-13 14:51:59.000000000 +0200
1264 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/block/Makefile 2008-10-13 14:54:20.000000000 +0200
1265 @@ -30,5 +30,6 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1266 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1267 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1268 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1269 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1271 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1272 diff -NurpP --minimal linux-2.6.27.25/drivers/block/vroot.c linux-2.6.27.25-vs2.3.0.36.6/drivers/block/vroot.c
1273 --- linux-2.6.27.25/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1274 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/block/vroot.c 2008-10-13 14:54:20.000000000 +0200
1277 + * linux/drivers/block/vroot.c
1279 + * written by Herbert Pötzl, 9/11/2002
1280 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1282 + * based on the loop.c code by Theodore Ts'o.
1284 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1285 + * Redistribution of this file is permitted under the
1286 + * GNU General Public License.
1290 +#include <linux/module.h>
1291 +#include <linux/moduleparam.h>
1292 +#include <linux/file.h>
1293 +#include <linux/major.h>
1294 +#include <linux/blkdev.h>
1296 +#include <linux/vroot.h>
1297 +#include <linux/vs_context.h>
1300 +static int max_vroot = 8;
1302 +static struct vroot_device *vroot_dev;
1303 +static struct gendisk **disks;
1306 +static int vroot_set_dev(
1307 + struct vroot_device *vr,
1308 + struct file *vr_file,
1309 + struct block_device *bdev,
1312 + struct block_device *real_bdev;
1313 + struct file *file;
1314 + struct inode *inode;
1318 + if (vr->vr_state != Vr_unbound)
1327 + inode = file->f_dentry->d_inode;
1330 + if (S_ISBLK(inode->i_mode)) {
1331 + real_bdev = inode->i_bdev;
1332 + vr->vr_device = real_bdev;
1333 + __iget(real_bdev->bd_inode);
1337 + vxdprintk(VXD_CBIT(misc, 0),
1338 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1339 + vr->vr_number, VXD_DEV(real_bdev));
1341 + vr->vr_state = Vr_bound;
1350 +static int vroot_clr_dev(
1351 + struct vroot_device *vr,
1352 + struct file *vr_file,
1353 + struct block_device *bdev)
1355 + struct block_device *real_bdev;
1357 + if (vr->vr_state != Vr_bound)
1359 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1362 + real_bdev = vr->vr_device;
1364 + vxdprintk(VXD_CBIT(misc, 0),
1365 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1366 + vr->vr_number, VXD_DEV(real_bdev));
1369 + vr->vr_state = Vr_unbound;
1370 + vr->vr_device = NULL;
1375 +static int vr_ioctl(struct inode *inode, struct file *file,
1376 + unsigned int cmd, unsigned long arg)
1378 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1381 + down(&vr->vr_ctl_mutex);
1383 + case VROOT_SET_DEV:
1384 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
1386 + case VROOT_CLR_DEV:
1387 + err = vroot_clr_dev(vr, file, inode->i_bdev);
1393 + up(&vr->vr_ctl_mutex);
1397 +static int vr_open(struct inode *inode, struct file *file)
1399 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1401 + down(&vr->vr_ctl_mutex);
1403 + up(&vr->vr_ctl_mutex);
1407 +static int vr_release(struct inode *inode, struct file *file)
1409 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1411 + down(&vr->vr_ctl_mutex);
1413 + up(&vr->vr_ctl_mutex);
1417 +static struct block_device_operations vr_fops = {
1418 + .owner = THIS_MODULE,
1420 + .release = vr_release,
1421 + .ioctl = vr_ioctl,
1424 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1426 + struct inode *inode = bdev->bd_inode;
1427 + struct vroot_device *vr;
1428 + struct block_device *real_bdev;
1429 + int minor = iminor(inode);
1431 + vr = &vroot_dev[minor];
1432 + real_bdev = vr->vr_device;
1434 + vxdprintk(VXD_CBIT(misc, 0),
1435 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1436 + vr->vr_number, VXD_DEV(real_bdev));
1438 + if (vr->vr_state != Vr_bound)
1439 + return ERR_PTR(-ENXIO);
1441 + __iget(real_bdev->bd_inode);
1446 + * And now the modules code and kernel interface.
1449 +module_param(max_vroot, int, 0);
1451 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1452 +MODULE_LICENSE("GPL");
1453 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1455 +MODULE_AUTHOR ("Herbert Pötzl");
1456 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1459 +int __init vroot_init(void)
1463 + if (max_vroot < 1 || max_vroot > 256) {
1464 + max_vroot = MAX_VROOT_DEFAULT;
1465 + printk(KERN_WARNING "vroot: invalid max_vroot "
1466 + "(must be between 1 and 256), "
1467 + "using default (%d)\n", max_vroot);
1470 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1474 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1477 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1479 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1483 + for (i = 0; i < max_vroot; i++) {
1484 + disks[i] = alloc_disk(1);
1487 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1488 + if (!disks[i]->queue)
1492 + for (i = 0; i < max_vroot; i++) {
1493 + struct vroot_device *vr = &vroot_dev[i];
1494 + struct gendisk *disk = disks[i];
1496 + memset(vr, 0, sizeof(*vr));
1497 + init_MUTEX(&vr->vr_ctl_mutex);
1498 + vr->vr_number = i;
1499 + disk->major = VROOT_MAJOR;
1500 + disk->first_minor = i;
1501 + disk->fops = &vr_fops;
1502 + sprintf(disk->disk_name, "vroot%d", i);
1503 + disk->private_data = vr;
1506 + err = register_vroot_grb(&__vroot_get_real_bdev);
1510 + for (i = 0; i < max_vroot; i++)
1511 + add_disk(disks[i]);
1512 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1517 + put_disk(disks[i]);
1522 + unregister_blkdev(VROOT_MAJOR, "vroot");
1523 + printk(KERN_ERR "vroot: ran out of memory\n");
1527 +void vroot_exit(void)
1531 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1532 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1534 + for (i = 0; i < max_vroot; i++) {
1535 + del_gendisk(disks[i]);
1536 + put_disk(disks[i]);
1538 + unregister_blkdev(VROOT_MAJOR, "vroot");
1544 +module_init(vroot_init);
1545 +module_exit(vroot_exit);
1549 +static int __init max_vroot_setup(char *str)
1551 + max_vroot = simple_strtol(str, NULL, 0);
1555 +__setup("max_vroot=", max_vroot_setup);
1559 diff -NurpP --minimal linux-2.6.27.25/drivers/char/sysrq.c linux-2.6.27.25-vs2.3.0.36.6/drivers/char/sysrq.c
1560 --- linux-2.6.27.25/drivers/char/sysrq.c 2008-10-13 14:51:59.000000000 +0200
1561 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/char/sysrq.c 2008-10-13 14:54:20.000000000 +0200
1563 #include <linux/irq.h>
1564 #include <linux/hrtimer.h>
1565 #include <linux/oom.h>
1566 +#include <linux/vserver/debug.h>
1568 #include <asm/ptrace.h>
1569 #include <asm/irq_regs.h>
1570 @@ -351,6 +352,21 @@ static struct sysrq_key_op sysrq_unrt_op
1571 .enable_mask = SYSRQ_ENABLE_RTNICE,
1575 +#ifdef CONFIG_VSERVER_DEBUG
1576 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
1578 + dump_vx_info_inactive((key == 'x')?0:1);
1581 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1582 + .handler = sysrq_handle_vxinfo,
1583 + .help_msg = "conteXt",
1584 + .action_msg = "Show Context Info",
1585 + .enable_mask = SYSRQ_ENABLE_DUMP,
1589 /* Key Operations table and lock */
1590 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1592 @@ -404,7 +420,11 @@ static struct sysrq_key_op *sysrq_key_ta
1594 /* y: May be registered on sparc64 for global register dump */
1597 +#ifdef CONFIG_VSERVER_DEBUG
1598 + &sysrq_showvxinfo_op, /* z */
1604 /* key2index calculation, -1 on invalid index */
1605 @@ -416,6 +436,8 @@ static int sysrq_key_table_key2index(int
1607 else if ((key >= 'a') && (key <= 'z'))
1608 retval = key + 10 - 'a';
1609 + else if ((key >= 'A') && (key <= 'Z'))
1610 + retval = key + 10 - 'A';
1614 diff -NurpP --minimal linux-2.6.27.25/drivers/char/tty_io.c linux-2.6.27.25-vs2.3.0.36.6/drivers/char/tty_io.c
1615 --- linux-2.6.27.25/drivers/char/tty_io.c 2009-06-15 17:18:27.000000000 +0200
1616 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/char/tty_io.c 2009-02-03 17:59:04.000000000 +0100
1619 #include <linux/kmod.h>
1620 #include <linux/nsproxy.h>
1621 +#include <linux/vs_pid.h>
1623 #undef TTY_DEBUG_HANGUP
1625 @@ -2770,6 +2771,7 @@ static int tiocspgrp(struct tty_struct *
1627 if (get_user(pgrp_nr, p))
1629 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1633 diff -NurpP --minimal linux-2.6.27.25/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.27.25-vs2.3.0.36.6/drivers/infiniband/hw/ipath/ipath_user_pages.c
1634 --- linux-2.6.27.25/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-07-13 23:51:29.000000000 +0200
1635 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-10-13 14:54:20.000000000 +0200
1638 #include <linux/mm.h>
1639 #include <linux/device.h>
1640 +#include <linux/vs_memory.h>
1642 #include "ipath_kernel.h"
1644 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
1645 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
1648 - if (num_pages > lock_limit) {
1649 + if (num_pages > lock_limit ||
1650 + !vx_vmlocked_avail(current->mm, num_pages)) {
1654 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
1658 - current->mm->locked_vm += num_pages;
1659 + vx_vmlocked_add(current->mm, num_pages);
1663 @@ -177,7 +179,7 @@ void ipath_release_user_pages(struct pag
1665 __ipath_release_user_pages(p, num_pages, 1);
1667 - current->mm->locked_vm -= num_pages;
1668 + vx_vmlocked_sub(current->mm, num_pages);
1670 up_write(¤t->mm->mmap_sem);
1672 @@ -194,7 +196,7 @@ static void user_pages_account(struct wo
1673 container_of(_work, struct ipath_user_pages_work, work);
1675 down_write(&work->mm->mmap_sem);
1676 - work->mm->locked_vm -= work->num_pages;
1677 + vx_vmlocked_sub(work->mm, work->num_pages);
1678 up_write(&work->mm->mmap_sem);
1681 diff -NurpP --minimal linux-2.6.27.25/drivers/md/dm.c linux-2.6.27.25-vs2.3.0.36.6/drivers/md/dm.c
1682 --- linux-2.6.27.25/drivers/md/dm.c 2008-10-13 14:52:01.000000000 +0200
1683 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/md/dm.c 2008-10-13 14:54:20.000000000 +0200
1685 #include <linux/hdreg.h>
1686 #include <linux/blktrace_api.h>
1687 #include <linux/smp_lock.h>
1688 +#include <linux/vs_base.h>
1690 #define DM_MSG_PREFIX "core"
1692 @@ -91,6 +92,7 @@ struct mapped_device {
1695 atomic_t open_count;
1698 unsigned long flags;
1700 @@ -252,6 +254,7 @@ static void __exit dm_exit(void)
1701 static int dm_blk_open(struct inode *inode, struct file *file)
1703 struct mapped_device *md;
1706 spin_lock(&_minor_lock);
1708 @@ -260,18 +263,19 @@ static int dm_blk_open(struct inode *ino
1711 if (test_bit(DMF_FREEING, &md->flags) ||
1712 - test_bit(DMF_DELETING, &md->flags)) {
1714 + test_bit(DMF_DELETING, &md->flags))
1718 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1723 atomic_inc(&md->open_count);
1727 spin_unlock(&_minor_lock);
1729 - return md ? 0 : -ENXIO;
1733 static int dm_blk_close(struct inode *inode, struct file *file)
1734 @@ -467,6 +471,14 @@ int dm_set_geometry(struct mapped_device
1739 + * Get the xid associated with a dm device
1741 +xid_t dm_get_xid(struct mapped_device *md)
1746 /*-----------------------------------------------------------------
1748 * A more elegant soln is in the works that uses the queue
1749 @@ -1069,6 +1081,7 @@ static struct mapped_device *alloc_dev(i
1750 INIT_LIST_HEAD(&md->uevent_list);
1751 spin_lock_init(&md->uevent_lock);
1753 + md->xid = vx_current_xid();
1754 md->queue = blk_alloc_queue(GFP_KERNEL);
1757 diff -NurpP --minimal linux-2.6.27.25/drivers/md/dm.h linux-2.6.27.25-vs2.3.0.36.6/drivers/md/dm.h
1758 --- linux-2.6.27.25/drivers/md/dm.h 2008-10-13 14:52:01.000000000 +0200
1759 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/md/dm.h 2008-10-13 14:54:20.000000000 +0200
1760 @@ -66,6 +66,8 @@ void dm_put_target_type(struct target_ty
1761 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
1762 void *param), void *param);
1764 +xid_t dm_get_xid(struct mapped_device *md);
1766 /*-----------------------------------------------------------------
1768 *---------------------------------------------------------------*/
1769 diff -NurpP --minimal linux-2.6.27.25/drivers/md/dm-ioctl.c linux-2.6.27.25-vs2.3.0.36.6/drivers/md/dm-ioctl.c
1770 --- linux-2.6.27.25/drivers/md/dm-ioctl.c 2009-06-15 17:18:28.000000000 +0200
1771 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/md/dm-ioctl.c 2009-03-25 14:32:29.000000000 +0100
1773 #include <linux/dm-ioctl.h>
1774 #include <linux/hdreg.h>
1775 #include <linux/compat.h>
1776 +#include <linux/vs_context.h>
1778 #include <asm/uaccess.h>
1780 @@ -101,7 +102,8 @@ static struct hash_cell *__get_name_cell
1781 unsigned int h = hash_str(str);
1783 list_for_each_entry (hc, _name_buckets + h, name_list)
1784 - if (!strcmp(hc->name, str)) {
1785 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1786 + !strcmp(hc->name, str)) {
1790 @@ -115,7 +117,8 @@ static struct hash_cell *__get_uuid_cell
1791 unsigned int h = hash_str(str);
1793 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1794 - if (!strcmp(hc->uuid, str)) {
1795 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1796 + !strcmp(hc->uuid, str)) {
1800 @@ -352,6 +355,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1802 static int remove_all(struct dm_ioctl *param, size_t param_size)
1804 + if (!vx_check(0, VS_ADMIN))
1807 dm_hash_remove_all(1);
1808 param->data_size = 0;
1810 @@ -399,6 +405,8 @@ static int list_devices(struct dm_ioctl
1812 for (i = 0; i < NUM_BUCKETS; i++) {
1813 list_for_each_entry (hc, _name_buckets + i, name_list) {
1814 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1816 needed += sizeof(struct dm_name_list);
1817 needed += strlen(hc->name) + 1;
1818 needed += ALIGN_MASK;
1819 @@ -422,6 +430,8 @@ static int list_devices(struct dm_ioctl
1821 for (i = 0; i < NUM_BUCKETS; i++) {
1822 list_for_each_entry (hc, _name_buckets + i, name_list) {
1823 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1826 old_nl->next = (uint32_t) ((void *) nl -
1828 @@ -612,10 +622,11 @@ static struct hash_cell *__find_device_h
1832 - mdptr = dm_get_mdptr(md);
1833 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1834 + mdptr = dm_get_mdptr(md);
1842 @@ -1407,8 +1418,8 @@ static int ctl_ioctl(uint command, struc
1846 - /* only root can play with this */
1847 - if (!capable(CAP_SYS_ADMIN))
1848 + /* only root and certain contexts can play with this */
1849 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1852 if (_IOC_TYPE(command) != DM_IOCTL)
1853 diff -NurpP --minimal linux-2.6.27.25/drivers/net/tun.c linux-2.6.27.25-vs2.3.0.36.6/drivers/net/tun.c
1854 --- linux-2.6.27.25/drivers/net/tun.c 2009-06-15 17:18:30.000000000 +0200
1855 +++ linux-2.6.27.25-vs2.3.0.36.6/drivers/net/tun.c 2009-02-22 22:58:32.000000000 +0100
1857 #include <linux/crc32.h>
1858 #include <linux/nsproxy.h>
1859 #include <linux/virtio_net.h>
1860 +#include <linux/vs_network.h>
1861 #include <net/net_namespace.h>
1862 #include <net/netns/generic.h>
1864 @@ -93,6 +94,7 @@ struct tun_struct {
1870 wait_queue_head_t read_wait;
1871 struct sk_buff_head readq;
1872 @@ -681,6 +683,7 @@ static void tun_setup(struct net_device
1876 + tun->nid = current->nid;
1878 dev->open = tun_net_open;
1879 dev->hard_start_xmit = tun_net_xmit;
1880 @@ -713,6 +716,9 @@ static int tun_set_iff(struct net *net,
1881 tn = net_generic(net, tun_net_id);
1882 tun = tun_get_by_name(tn, ifr->ifr_name);
1884 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1890 @@ -721,7 +727,7 @@ static int tun_set_iff(struct net *net,
1891 current->euid != tun->owner) ||
1892 (tun->group != -1 &&
1893 current->egid != tun->group)) &&
1894 - !capable(CAP_NET_ADMIN))
1895 + !cap_raised(current->cap_effective, CAP_NET_ADMIN))
1898 else if (__dev_get_by_name(net, ifr->ifr_name))
1899 @@ -732,7 +738,7 @@ static int tun_set_iff(struct net *net,
1903 - if (!capable(CAP_NET_ADMIN))
1904 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1908 @@ -972,6 +978,16 @@ static int tun_chr_ioctl(struct inode *i
1909 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1913 + if (!capable(CAP_CONTEXT))
1916 + /* Set nid owner of the device */
1917 + tun->nid = (nid_t) arg;
1919 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1923 /* Only allow setting the type when the interface is down */
1925 diff -NurpP --minimal linux-2.6.27.25/fs/attr.c linux-2.6.27.25-vs2.3.0.36.6/fs/attr.c
1926 --- linux-2.6.27.25/fs/attr.c 2008-10-13 14:52:05.000000000 +0200
1927 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/attr.c 2008-10-24 03:34:52.000000000 +0200
1929 #include <linux/fcntl.h>
1930 #include <linux/quotaops.h>
1931 #include <linux/security.h>
1932 +#include <linux/proc_fs.h>
1933 +#include <linux/devpts_fs.h>
1934 +#include <linux/vs_tag.h>
1936 /* Taken over from the old code... */
1938 @@ -55,6 +58,10 @@ int inode_change_ok(struct inode *inode,
1939 if (!is_owner_or_cap(inode))
1943 + if (dx_permission(inode, MAY_WRITE))
1949 @@ -78,6 +85,8 @@ int inode_setattr(struct inode * inode,
1950 inode->i_uid = attr->ia_uid;
1951 if (ia_valid & ATTR_GID)
1952 inode->i_gid = attr->ia_gid;
1953 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1954 + inode->i_tag = attr->ia_tag;
1955 if (ia_valid & ATTR_ATIME)
1956 inode->i_atime = timespec_trunc(attr->ia_atime,
1957 inode->i_sb->s_time_gran);
1958 @@ -172,7 +181,8 @@ int notify_change(struct dentry * dentry
1959 error = security_inode_setattr(dentry, attr);
1961 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
1962 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
1963 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
1964 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
1965 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
1967 error = inode_setattr(inode, attr);
1968 diff -NurpP --minimal linux-2.6.27.25/fs/binfmt_aout.c linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_aout.c
1969 --- linux-2.6.27.25/fs/binfmt_aout.c 2008-10-13 14:52:05.000000000 +0200
1970 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_aout.c 2008-10-13 14:54:20.000000000 +0200
1972 #include <linux/binfmts.h>
1973 #include <linux/personality.h>
1974 #include <linux/init.h>
1975 +#include <linux/vs_memory.h>
1977 #include <asm/system.h>
1978 #include <asm/uaccess.h>
1979 diff -NurpP --minimal linux-2.6.27.25/fs/binfmt_elf.c linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_elf.c
1980 --- linux-2.6.27.25/fs/binfmt_elf.c 2009-06-15 17:18:31.000000000 +0200
1981 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_elf.c 2009-02-22 22:58:32.000000000 +0100
1983 #include <linux/random.h>
1984 #include <linux/elf.h>
1985 #include <linux/utsname.h>
1986 +#include <linux/vs_memory.h>
1987 #include <asm/uaccess.h>
1988 #include <asm/param.h>
1989 #include <asm/page.h>
1990 diff -NurpP --minimal linux-2.6.27.25/fs/binfmt_flat.c linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_flat.c
1991 --- linux-2.6.27.25/fs/binfmt_flat.c 2008-10-13 14:52:05.000000000 +0200
1992 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_flat.c 2008-10-13 14:54:20.000000000 +0200
1994 #include <linux/init.h>
1995 #include <linux/flat.h>
1996 #include <linux/syscalls.h>
1997 +#include <linux/vs_memory.h>
1999 #include <asm/byteorder.h>
2000 #include <asm/system.h>
2001 diff -NurpP --minimal linux-2.6.27.25/fs/binfmt_som.c linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_som.c
2002 --- linux-2.6.27.25/fs/binfmt_som.c 2008-10-13 14:52:05.000000000 +0200
2003 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/binfmt_som.c 2008-10-13 14:54:20.000000000 +0200
2005 #include <linux/shm.h>
2006 #include <linux/personality.h>
2007 #include <linux/init.h>
2008 +#include <linux/vs_memory.h>
2010 #include <asm/uaccess.h>
2011 #include <asm/pgtable.h>
2012 diff -NurpP --minimal linux-2.6.27.25/fs/block_dev.c linux-2.6.27.25-vs2.3.0.36.6/fs/block_dev.c
2013 --- linux-2.6.27.25/fs/block_dev.c 2008-10-13 14:52:05.000000000 +0200
2014 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/block_dev.c 2008-10-13 14:54:20.000000000 +0200
2016 #include <linux/uio.h>
2017 #include <linux/namei.h>
2018 #include <linux/log2.h>
2019 +#include <linux/vs_device.h>
2020 #include <asm/uaccess.h>
2021 #include "internal.h"
2023 @@ -389,6 +390,7 @@ struct block_device *bdget(dev_t dev)
2024 bdev->bd_invalidated = 0;
2025 inode->i_mode = S_IFBLK;
2026 inode->i_rdev = dev;
2027 + inode->i_mdev = dev;
2028 inode->i_bdev = bdev;
2029 inode->i_data.a_ops = &def_blk_aops;
2030 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2031 @@ -425,6 +427,11 @@ EXPORT_SYMBOL(bdput);
2032 static struct block_device *bd_acquire(struct inode *inode)
2034 struct block_device *bdev;
2037 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2039 + inode->i_mdev = mdev;
2041 spin_lock(&bdev_lock);
2042 bdev = inode->i_bdev;
2043 @@ -435,7 +442,7 @@ static struct block_device *bd_acquire(s
2045 spin_unlock(&bdev_lock);
2047 - bdev = bdget(inode->i_rdev);
2048 + bdev = bdget(mdev);
2050 spin_lock(&bdev_lock);
2051 if (!inode->i_bdev) {
2052 diff -NurpP --minimal linux-2.6.27.25/fs/char_dev.c linux-2.6.27.25-vs2.3.0.36.6/fs/char_dev.c
2053 --- linux-2.6.27.25/fs/char_dev.c 2008-10-13 14:52:05.000000000 +0200
2054 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/char_dev.c 2008-10-13 14:54:20.000000000 +0200
2056 #include <linux/cdev.h>
2057 #include <linux/mutex.h>
2058 #include <linux/backing-dev.h>
2059 +#include <linux/vs_context.h>
2060 +#include <linux/vs_device.h>
2063 #include <linux/kmod.h>
2064 @@ -361,14 +363,21 @@ static int chrdev_open(struct inode *ino
2066 struct cdev *new = NULL;
2070 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2072 + inode->i_mdev = mdev;
2074 spin_lock(&cdev_lock);
2077 struct kobject *kobj;
2080 spin_unlock(&cdev_lock);
2081 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2083 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2086 new = container_of(kobj, struct cdev, kobj);
2087 diff -NurpP --minimal linux-2.6.27.25/fs/dcache.c linux-2.6.27.25-vs2.3.0.36.6/fs/dcache.c
2088 --- linux-2.6.27.25/fs/dcache.c 2009-06-15 17:18:31.000000000 +0200
2089 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/dcache.c 2009-02-03 17:59:04.000000000 +0100
2091 #include <linux/seqlock.h>
2092 #include <linux/swap.h>
2093 #include <linux/bootmem.h>
2094 +#include <linux/vs_limit.h>
2095 #include "internal.h"
2098 @@ -226,6 +227,8 @@ repeat:
2102 + vx_dentry_dec(dentry);
2105 * AV: ->d_delete() is _NOT_ allowed to block now.
2107 @@ -317,6 +320,7 @@ static inline struct dentry * __dget_loc
2109 atomic_inc(&dentry->d_count);
2110 dentry_lru_del_init(dentry);
2111 + vx_dentry_inc(dentry);
2115 @@ -914,6 +918,9 @@ struct dentry *d_alloc(struct dentry * p
2116 struct dentry *dentry;
2119 + if (!vx_dentry_avail(1))
2122 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2125 @@ -962,6 +969,7 @@ struct dentry *d_alloc(struct dentry * p
2127 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2128 dentry_stat.nr_dentry++;
2129 + vx_dentry_inc(dentry);
2130 spin_unlock(&dcache_lock);
2133 @@ -1415,6 +1423,7 @@ struct dentry * __d_lookup(struct dentry
2136 atomic_inc(&dentry->d_count);
2137 + vx_dentry_inc(dentry);
2139 spin_unlock(&dentry->d_lock);
2141 diff -NurpP --minimal linux-2.6.27.25/fs/devpts/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/devpts/inode.c
2142 --- linux-2.6.27.25/fs/devpts/inode.c 2008-10-13 14:52:05.000000000 +0200
2143 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/devpts/inode.c 2008-10-13 14:54:20.000000000 +0200
2145 #include <linux/tty.h>
2146 #include <linux/mutex.h>
2147 #include <linux/idr.h>
2148 +#include <linux/magic.h>
2149 #include <linux/devpts_fs.h>
2150 #include <linux/parser.h>
2151 #include <linux/fsnotify.h>
2152 #include <linux/seq_file.h>
2154 -#define DEVPTS_SUPER_MAGIC 0x1cd1
2155 +#include <linux/vs_base.h>
2157 #define DEVPTS_DEFAULT_MODE 0600
2159 +static int devpts_permission(struct inode *inode, int mask)
2161 + int ret = -EACCES;
2163 + /* devpts is xid tagged */
2164 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2165 + ret = generic_permission(inode, mask, NULL);
2169 +static struct inode_operations devpts_file_inode_operations = {
2170 + .permission = devpts_permission,
2173 extern int pty_limit; /* Config limit on Unix98 ptys */
2174 static DEFINE_IDA(allocated_ptys);
2175 static DEFINE_MUTEX(allocated_ptys_lock);
2176 @@ -112,6 +126,25 @@ static int devpts_show_options(struct se
2180 +static int devpts_filter(struct dentry *de)
2182 + /* devpts is xid tagged */
2183 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2186 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2188 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2191 +static struct file_operations devpts_dir_operations = {
2192 + .open = dcache_dir_open,
2193 + .release = dcache_dir_close,
2194 + .llseek = dcache_dir_lseek,
2195 + .read = generic_read_dir,
2196 + .readdir = devpts_readdir,
2199 static const struct super_operations devpts_sops = {
2200 .statfs = simple_statfs,
2201 .remount_fs = devpts_remount,
2202 @@ -138,8 +171,10 @@ devpts_fill_super(struct super_block *s,
2203 inode->i_uid = inode->i_gid = 0;
2204 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2205 inode->i_op = &simple_dir_inode_operations;
2206 - inode->i_fop = &simple_dir_operations;
2207 + inode->i_fop = &devpts_dir_operations;
2209 + /* devpts is xid tagged */
2210 + inode->i_tag = (tag_t)vx_current_xid();
2212 devpts_root = s->s_root = d_alloc_root(inode);
2214 @@ -232,6 +267,9 @@ int devpts_pty_new(struct tty_struct *tt
2215 inode->i_gid = config.setgid ? config.gid : current->fsgid;
2216 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2217 init_special_inode(inode, S_IFCHR|config.mode, device);
2218 + /* devpts is xid tagged */
2219 + inode->i_tag = (tag_t)vx_current_xid();
2220 + inode->i_op = &devpts_file_inode_operations;
2221 inode->i_private = tty;
2223 dentry = get_node(number);
2224 diff -NurpP --minimal linux-2.6.27.25/fs/exec.c linux-2.6.27.25-vs2.3.0.36.6/fs/exec.c
2225 --- linux-2.6.27.25/fs/exec.c 2009-06-15 17:18:31.000000000 +0200
2226 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/exec.c 2009-05-15 22:57:04.000000000 +0200
2227 @@ -263,7 +263,9 @@ static int __bprm_mm_init(struct linux_b
2231 - mm->stack_vm = mm->total_vm = 1;
2233 + vx_vmpages_inc(mm);
2235 up_write(&mm->mmap_sem);
2237 bprm->p = vma->vm_end - sizeof(void *);
2238 @@ -1459,7 +1461,7 @@ static int format_corename(char *corenam
2239 /* UNIX time of coredump */
2242 - do_gettimeofday(&tv);
2243 + vx_gettimeofday(&tv);
2244 rc = snprintf(out_ptr, out_end - out_ptr,
2246 if (rc > out_end - out_ptr)
2247 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/balloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/balloc.c
2248 --- linux-2.6.27.25/fs/ext2/balloc.c 2009-06-15 17:18:31.000000000 +0200
2249 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/balloc.c 2009-02-03 17:59:04.000000000 +0100
2251 #include <linux/sched.h>
2252 #include <linux/buffer_head.h>
2253 #include <linux/capability.h>
2254 +#include <linux/vs_dlimit.h>
2255 +#include <linux/vs_tag.h>
2258 * balloc.c contains the blocks allocation and deallocation routines
2259 @@ -569,6 +571,7 @@ do_more:
2263 + DLIMIT_FREE_BLOCK(inode, freed);
2264 release_blocks(sb, freed);
2265 DQUOT_FREE_BLOCK(inode, freed);
2267 @@ -701,7 +704,6 @@ ext2_try_to_allocate(struct super_block
2269 end = EXT2_BLOCKS_PER_GROUP(sb);
2272 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2275 @@ -1251,6 +1253,11 @@ ext2_fsblk_t ext2_new_blocks(struct inod
2279 + if (DLIMIT_ALLOC_BLOCK(inode, num)) {
2281 + DQUOT_FREE_BLOCK(inode, num);
2286 es = EXT2_SB(sb)->s_es;
2287 @@ -1409,6 +1416,7 @@ allocated:
2291 + DLIMIT_FREE_BLOCK(inode, *count-num);
2292 DQUOT_FREE_BLOCK(inode, *count-num);
2295 @@ -1419,8 +1427,10 @@ out:
2297 * Undo the block allocation
2299 - if (!performed_allocation)
2300 + if (!performed_allocation) {
2301 + DLIMIT_FREE_BLOCK(inode, *count);
2302 DQUOT_FREE_BLOCK(inode, *count);
2307 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/ext2.h linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/ext2.h
2308 --- linux-2.6.27.25/fs/ext2/ext2.h 2008-07-13 23:51:29.000000000 +0200
2309 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/ext2.h 2008-10-13 14:54:20.000000000 +0200
2310 @@ -168,6 +168,7 @@ extern const struct file_operations ext2
2311 extern const struct address_space_operations ext2_aops;
2312 extern const struct address_space_operations ext2_aops_xip;
2313 extern const struct address_space_operations ext2_nobh_aops;
2314 +extern int ext2_sync_flags(struct inode *inode);
2317 extern const struct inode_operations ext2_dir_inode_operations;
2318 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/file.c
2319 --- linux-2.6.27.25/fs/ext2/file.c 2008-07-13 23:51:29.000000000 +0200
2320 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/file.c 2008-10-13 14:54:20.000000000 +0200
2321 @@ -86,4 +86,5 @@ const struct inode_operations ext2_file_
2323 .setattr = ext2_setattr,
2324 .permission = ext2_permission,
2325 + .sync_flags = ext2_sync_flags,
2327 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/ialloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/ialloc.c
2328 --- linux-2.6.27.25/fs/ext2/ialloc.c 2008-07-13 23:51:29.000000000 +0200
2329 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/ialloc.c 2008-10-13 14:54:20.000000000 +0200
2331 #include <linux/backing-dev.h>
2332 #include <linux/buffer_head.h>
2333 #include <linux/random.h>
2334 +#include <linux/vs_dlimit.h>
2335 +#include <linux/vs_tag.h>
2339 @@ -123,6 +125,7 @@ void ext2_free_inode (struct inode * ino
2340 ext2_xattr_delete_inode(inode);
2341 DQUOT_FREE_INODE(inode);
2343 + DLIMIT_FREE_INODE(inode);
2346 es = EXT2_SB(sb)->s_es;
2347 @@ -454,6 +457,11 @@ struct inode *ext2_new_inode(struct inod
2349 return ERR_PTR(-ENOMEM);
2351 + inode->i_tag = dx_current_fstag(sb);
2352 + if (DLIMIT_ALLOC_INODE(inode)) {
2359 @@ -565,7 +573,8 @@ got:
2360 inode->i_blocks = 0;
2361 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
2362 memset(ei->i_data, 0, sizeof(ei->i_data));
2363 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
2364 + ei->i_flags = EXT2_I(dir)->i_flags &
2365 + ~(EXT2_BTREE_FL|EXT2_IXUNLINK_FL|EXT2_BARRIER_FL);
2367 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
2368 /* dirsync is only applied to directories */
2369 @@ -610,12 +619,15 @@ fail_free_drop:
2373 + DLIMIT_FREE_INODE(inode);
2374 inode->i_flags |= S_NOQUOTA;
2377 return ERR_PTR(err);
2380 + DLIMIT_FREE_INODE(inode);
2382 make_bad_inode(inode);
2384 return ERR_PTR(err);
2385 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/inode.c
2386 --- linux-2.6.27.25/fs/ext2/inode.c 2008-10-13 14:52:05.000000000 +0200
2387 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/inode.c 2008-10-13 14:54:20.000000000 +0200
2389 #include <linux/writeback.h>
2390 #include <linux/buffer_head.h>
2391 #include <linux/mpage.h>
2392 +#include <linux/vs_tag.h>
2396 @@ -1011,7 +1012,7 @@ void ext2_truncate(struct inode *inode)
2398 if (ext2_inode_is_fast_symlink(inode))
2400 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2401 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2404 blocksize = inode->i_sb->s_blocksize;
2405 @@ -1149,38 +1150,72 @@ void ext2_set_inode_flags(struct inode *
2407 unsigned int flags = EXT2_I(inode)->i_flags;
2409 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2410 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2411 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2414 + if (flags & EXT2_IMMUTABLE_FL)
2415 + inode->i_flags |= S_IMMUTABLE;
2416 + if (flags & EXT2_IXUNLINK_FL)
2417 + inode->i_flags |= S_IXUNLINK;
2419 if (flags & EXT2_SYNC_FL)
2420 inode->i_flags |= S_SYNC;
2421 if (flags & EXT2_APPEND_FL)
2422 inode->i_flags |= S_APPEND;
2423 - if (flags & EXT2_IMMUTABLE_FL)
2424 - inode->i_flags |= S_IMMUTABLE;
2425 if (flags & EXT2_NOATIME_FL)
2426 inode->i_flags |= S_NOATIME;
2427 if (flags & EXT2_DIRSYNC_FL)
2428 inode->i_flags |= S_DIRSYNC;
2430 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2432 + if (flags & EXT2_BARRIER_FL)
2433 + inode->i_vflags |= V_BARRIER;
2434 + if (flags & EXT2_COW_FL)
2435 + inode->i_vflags |= V_COW;
2438 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2439 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2441 unsigned int flags = ei->vfs_inode.i_flags;
2442 + unsigned int vflags = ei->vfs_inode.i_vflags;
2444 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2445 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2446 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2447 + EXT2_BARRIER_FL | EXT2_COW_FL);
2449 + if (flags & S_IMMUTABLE)
2450 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2451 + if (flags & S_IXUNLINK)
2452 + ei->i_flags |= EXT2_IXUNLINK_FL;
2454 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2455 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2457 ei->i_flags |= EXT2_SYNC_FL;
2458 if (flags & S_APPEND)
2459 ei->i_flags |= EXT2_APPEND_FL;
2460 - if (flags & S_IMMUTABLE)
2461 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2462 if (flags & S_NOATIME)
2463 ei->i_flags |= EXT2_NOATIME_FL;
2464 if (flags & S_DIRSYNC)
2465 ei->i_flags |= EXT2_DIRSYNC_FL;
2467 + if (vflags & V_BARRIER)
2468 + ei->i_flags |= EXT2_BARRIER_FL;
2469 + if (vflags & V_COW)
2470 + ei->i_flags |= EXT2_COW_FL;
2473 +int ext2_sync_flags(struct inode *inode)
2475 + ext2_get_inode_flags(EXT2_I(inode));
2476 + inode->i_ctime = CURRENT_TIME;
2477 + mark_inode_dirty(inode);
2482 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2484 struct ext2_inode_info *ei;
2485 @@ -1188,6 +1223,8 @@ struct inode *ext2_iget (struct super_bl
2486 struct ext2_inode *raw_inode;
2487 struct inode *inode;
2493 inode = iget_locked(sb, ino);
2494 @@ -1210,12 +1247,17 @@ struct inode *ext2_iget (struct super_bl
2497 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2498 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2499 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2500 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2501 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2502 if (!(test_opt (inode->i_sb, NO_UID32))) {
2503 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2504 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2505 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2506 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2508 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2509 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2510 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2511 + le16_to_cpu(raw_inode->i_raw_tag));
2513 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2514 inode->i_size = le32_to_cpu(raw_inode->i_size);
2515 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2516 @@ -1311,8 +1353,8 @@ static int ext2_update_inode(struct inod
2517 struct ext2_inode_info *ei = EXT2_I(inode);
2518 struct super_block *sb = inode->i_sb;
2519 ino_t ino = inode->i_ino;
2520 - uid_t uid = inode->i_uid;
2521 - gid_t gid = inode->i_gid;
2522 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2523 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2524 struct buffer_head * bh;
2525 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2527 @@ -1348,6 +1390,9 @@ static int ext2_update_inode(struct inod
2528 raw_inode->i_uid_high = 0;
2529 raw_inode->i_gid_high = 0;
2531 +#ifdef CONFIG_TAGGING_INTERN
2532 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2534 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2535 raw_inode->i_size = cpu_to_le32(inode->i_size);
2536 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2537 @@ -1434,7 +1479,8 @@ int ext2_setattr(struct dentry *dentry,
2540 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2541 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2542 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2543 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2544 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
2547 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/ioctl.c
2548 --- linux-2.6.27.25/fs/ext2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
2549 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/ioctl.c 2008-10-13 14:54:20.000000000 +0200
2551 #include <linux/compat.h>
2552 #include <linux/mount.h>
2553 #include <linux/smp_lock.h>
2554 +#include <linux/mount.h>
2555 #include <asm/current.h>
2556 #include <asm/uaccess.h>
2558 @@ -53,6 +54,11 @@ long ext2_ioctl(struct file *filp, unsig
2559 if (!S_ISDIR(inode->i_mode))
2560 flags &= ~EXT2_DIRSYNC_FL;
2562 + if (IS_BARRIER(inode)) {
2563 + vxwprintk_task(1, "messing with the barrier.");
2567 mutex_lock(&inode->i_mutex);
2568 /* Is it quota file? Do not allow user to mess with it */
2569 if (IS_NOQUOTA(inode)) {
2570 @@ -68,7 +74,9 @@ long ext2_ioctl(struct file *filp, unsig
2572 * This test looks nicer. Thanks to Pauline Middelink
2574 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2575 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2576 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2577 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2578 if (!capable(CAP_LINUX_IMMUTABLE)) {
2579 mutex_unlock(&inode->i_mutex);
2581 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/namei.c
2582 --- linux-2.6.27.25/fs/ext2/namei.c 2008-07-13 23:51:29.000000000 +0200
2583 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/namei.c 2008-10-13 14:54:20.000000000 +0200
2587 #include <linux/pagemap.h>
2588 +#include <linux/vs_tag.h>
2592 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
2593 inode = ext2_iget(dir->i_sb, ino);
2595 return ERR_CAST(inode);
2596 + dx_propagate_tag(nd, inode);
2598 return d_splice_alias(inode, dentry);
2600 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
2602 .setattr = ext2_setattr,
2603 .permission = ext2_permission,
2604 + .sync_flags = ext2_sync_flags,
2607 const struct inode_operations ext2_special_inode_operations = {
2608 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
2610 .setattr = ext2_setattr,
2611 .permission = ext2_permission,
2612 + .sync_flags = ext2_sync_flags,
2614 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/super.c
2615 --- linux-2.6.27.25/fs/ext2/super.c 2009-06-15 17:18:31.000000000 +0200
2616 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/super.c 2009-02-22 22:58:32.000000000 +0100
2617 @@ -390,7 +390,8 @@ enum {
2618 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2619 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2620 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2621 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2622 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2623 + Opt_tag, Opt_notag, Opt_tagid
2626 static match_table_t tokens = {
2627 @@ -418,6 +419,9 @@ static match_table_t tokens = {
2629 {Opt_noacl, "noacl"},
2632 + {Opt_notag, "notag"},
2633 + {Opt_tagid, "tagid=%u"},
2634 {Opt_grpquota, "grpquota"},
2635 {Opt_ignore, "noquota"},
2636 {Opt_quota, "quota"},
2637 @@ -488,6 +492,20 @@ static int parse_options (char * options
2639 set_opt (sbi->s_mount_opt, NO_UID32);
2641 +#ifndef CONFIG_TAGGING_NONE
2643 + set_opt (sbi->s_mount_opt, TAGGED);
2646 + clear_opt (sbi->s_mount_opt, TAGGED);
2649 +#ifdef CONFIG_PROPAGATE
2652 + set_opt (sbi->s_mount_opt, TAGGED);
2656 clear_opt (sbi->s_mount_opt, CHECK);
2658 @@ -830,6 +848,8 @@ static int ext2_fill_super(struct super_
2659 if (!parse_options ((char *) data, sbi))
2662 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2663 + sb->s_flags |= MS_TAGGED;
2664 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2665 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2667 @@ -1162,6 +1182,13 @@ static int ext2_remount (struct super_bl
2671 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2672 + !(sb->s_flags & MS_TAGGED)) {
2673 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2678 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2679 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2681 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/symlink.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/symlink.c
2682 --- linux-2.6.27.25/fs/ext2/symlink.c 2008-07-13 23:51:29.000000000 +0200
2683 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/symlink.c 2008-10-13 14:54:20.000000000 +0200
2684 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
2685 .listxattr = ext2_listxattr,
2686 .removexattr = generic_removexattr,
2688 + .sync_flags = ext2_sync_flags,
2691 const struct inode_operations ext2_fast_symlink_inode_operations = {
2692 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
2693 .listxattr = ext2_listxattr,
2694 .removexattr = generic_removexattr,
2696 + .sync_flags = ext2_sync_flags,
2698 diff -NurpP --minimal linux-2.6.27.25/fs/ext2/xattr.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/xattr.c
2699 --- linux-2.6.27.25/fs/ext2/xattr.c 2008-07-13 23:51:29.000000000 +0200
2700 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext2/xattr.c 2008-10-13 14:54:20.000000000 +0200
2702 #include <linux/mbcache.h>
2703 #include <linux/quotaops.h>
2704 #include <linux/rwsem.h>
2705 +#include <linux/vs_dlimit.h>
2709 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
2711 ea_bdebug(new_bh, "reusing block");
2714 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
2717 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
2718 + DLIMIT_FREE_BLOCK(inode, 1);
2719 unlock_buffer(new_bh);
2722 @@ -731,6 +736,7 @@ ext2_xattr_set2(struct inode *inode, str
2723 le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
2725 mb_cache_entry_release(ce);
2726 + DLIMIT_FREE_BLOCK(inode, 1);
2727 DQUOT_FREE_BLOCK(inode, 1);
2728 mark_buffer_dirty(old_bh);
2729 ea_bdebug(old_bh, "refcount now=%d",
2730 @@ -794,6 +800,7 @@ ext2_xattr_delete_inode(struct inode *in
2731 mark_buffer_dirty(bh);
2733 sync_dirty_buffer(bh);
2734 + DLIMIT_FREE_BLOCK(inode, 1);
2735 DQUOT_FREE_BLOCK(inode, 1);
2737 EXT2_I(inode)->i_file_acl = 0;
2738 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/balloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/balloc.c
2739 --- linux-2.6.27.25/fs/ext3/balloc.c 2009-06-15 17:18:31.000000000 +0200
2740 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/balloc.c 2009-02-03 17:59:04.000000000 +0100
2742 #include <linux/ext3_jbd.h>
2743 #include <linux/quotaops.h>
2744 #include <linux/buffer_head.h>
2745 +#include <linux/vs_dlimit.h>
2746 +#include <linux/vs_tag.h>
2749 * balloc.c contains the blocks allocation and deallocation routines
2750 @@ -675,8 +677,10 @@ void ext3_free_blocks(handle_t *handle,
2753 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
2754 - if (dquot_freed_blocks)
2755 + if (dquot_freed_blocks) {
2756 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
2757 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
2762 @@ -1415,18 +1419,33 @@ out:
2764 * Check if filesystem has at least 1 free block available for allocation.
2766 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
2767 +static int ext3_has_free_blocks(struct super_block *sb)
2769 - ext3_fsblk_t free_blocks, root_blocks;
2770 + struct ext3_sb_info *sbi = EXT3_SB(sb);
2771 + unsigned long long free_blocks, root_blocks;
2774 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
2775 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
2776 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
2778 + vxdprintk(VXD_CBIT(dlim, 3),
2779 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
2780 + sb, free_blocks, root_blocks);
2782 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
2784 + cond = (free_blocks < root_blocks + 1 &&
2785 + !capable(CAP_SYS_RESOURCE) &&
2786 sbi->s_resuid != current->fsuid &&
2787 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
2791 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
2793 + vxdprintk(VXD_CBIT(dlim, 3),
2794 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
2795 + sb, free_blocks, root_blocks,
2796 + !capable(CAP_SYS_RESOURCE)?'1':'0',
2797 + sbi->s_resuid, current->fsuid, cond?0:1);
2799 + return (cond ? 0 : 1);
2803 @@ -1443,7 +1462,7 @@ static int ext3_has_free_blocks(struct e
2805 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
2807 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
2808 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
2811 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
2812 @@ -1506,6 +1525,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2816 + if (DLIMIT_ALLOC_BLOCK(inode, num))
2820 es = EXT3_SB(sb)->s_es;
2821 @@ -1522,7 +1543,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
2822 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
2823 my_rsv = &block_i->rsv_window_node;
2825 - if (!ext3_has_free_blocks(sbi)) {
2826 + if (!ext3_has_free_blocks(sb)) {
2830 @@ -1715,12 +1736,16 @@ allocated:
2833 DQUOT_FREE_BLOCK(inode, *count-num);
2834 + DLIMIT_FREE_BLOCK(inode, *count-num);
2841 + if (!performed_allocation)
2842 + DLIMIT_FREE_BLOCK(inode, *count);
2846 ext3_std_error(sb, fatal);
2847 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/file.c
2848 --- linux-2.6.27.25/fs/ext3/file.c 2008-07-13 23:51:29.000000000 +0200
2849 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/file.c 2008-10-13 14:54:20.000000000 +0200
2850 @@ -134,5 +134,6 @@ const struct inode_operations ext3_file_
2851 .removexattr = generic_removexattr,
2853 .permission = ext3_permission,
2854 + .sync_flags = ext3_sync_flags,
2857 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/ialloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/ialloc.c
2858 --- linux-2.6.27.25/fs/ext3/ialloc.c 2008-10-13 14:52:05.000000000 +0200
2859 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/ialloc.c 2008-10-13 14:54:20.000000000 +0200
2861 #include <linux/buffer_head.h>
2862 #include <linux/random.h>
2863 #include <linux/bitops.h>
2864 +#include <linux/vs_dlimit.h>
2865 +#include <linux/vs_tag.h>
2867 #include <asm/byteorder.h>
2869 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
2870 ext3_xattr_delete_inode(handle, inode);
2871 DQUOT_FREE_INODE(inode);
2873 + DLIMIT_FREE_INODE(inode);
2875 is_directory = S_ISDIR(inode->i_mode);
2877 @@ -440,6 +443,12 @@ struct inode *ext3_new_inode(handle_t *h
2878 inode = new_inode(sb);
2880 return ERR_PTR(-ENOMEM);
2882 + inode->i_tag = dx_current_fstag(sb);
2883 + if (DLIMIT_ALLOC_INODE(inode)) {
2890 @@ -559,7 +568,8 @@ got:
2891 ei->i_dir_start_lookup = 0;
2894 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
2895 + ei->i_flags = EXT3_I(dir)->i_flags &
2896 + ~(EXT3_INDEX_FL|EXT3_IXUNLINK_FL|EXT3_BARRIER_FL);
2898 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
2899 /* dirsync only applies to directories */
2900 @@ -614,6 +624,8 @@ got:
2902 ext3_std_error(sb, err);
2904 + DLIMIT_FREE_INODE(inode);
2909 @@ -625,6 +637,7 @@ fail_free_drop:
2913 + DLIMIT_FREE_INODE(inode);
2914 inode->i_flags |= S_NOQUOTA;
2917 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/inode.c
2918 --- linux-2.6.27.25/fs/ext3/inode.c 2009-06-15 17:18:31.000000000 +0200
2919 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/inode.c 2009-02-03 17:59:04.000000000 +0100
2921 #include <linux/mpage.h>
2922 #include <linux/uio.h>
2923 #include <linux/bio.h>
2924 +#include <linux/vs_tag.h>
2928 @@ -2272,7 +2273,7 @@ static void ext3_free_branches(handle_t
2930 int ext3_can_truncate(struct inode *inode)
2932 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2933 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2935 if (S_ISREG(inode->i_mode))
2937 @@ -2646,36 +2647,84 @@ void ext3_set_inode_flags(struct inode *
2939 unsigned int flags = EXT3_I(inode)->i_flags;
2941 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2942 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2943 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2945 + if (flags & EXT3_IMMUTABLE_FL)
2946 + inode->i_flags |= S_IMMUTABLE;
2947 + if (flags & EXT3_IXUNLINK_FL)
2948 + inode->i_flags |= S_IXUNLINK;
2950 if (flags & EXT3_SYNC_FL)
2951 inode->i_flags |= S_SYNC;
2952 if (flags & EXT3_APPEND_FL)
2953 inode->i_flags |= S_APPEND;
2954 - if (flags & EXT3_IMMUTABLE_FL)
2955 - inode->i_flags |= S_IMMUTABLE;
2956 if (flags & EXT3_NOATIME_FL)
2957 inode->i_flags |= S_NOATIME;
2958 if (flags & EXT3_DIRSYNC_FL)
2959 inode->i_flags |= S_DIRSYNC;
2961 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2963 + if (flags & EXT3_BARRIER_FL)
2964 + inode->i_vflags |= V_BARRIER;
2965 + if (flags & EXT3_COW_FL)
2966 + inode->i_vflags |= V_COW;
2969 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2970 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2972 unsigned int flags = ei->vfs_inode.i_flags;
2973 + unsigned int vflags = ei->vfs_inode.i_vflags;
2975 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2976 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2977 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2978 + EXT3_BARRIER_FL | EXT3_COW_FL);
2980 + if (flags & S_IMMUTABLE)
2981 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2982 + if (flags & S_IXUNLINK)
2983 + ei->i_flags |= EXT3_IXUNLINK_FL;
2985 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2986 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2988 ei->i_flags |= EXT3_SYNC_FL;
2989 if (flags & S_APPEND)
2990 ei->i_flags |= EXT3_APPEND_FL;
2991 - if (flags & S_IMMUTABLE)
2992 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2993 if (flags & S_NOATIME)
2994 ei->i_flags |= EXT3_NOATIME_FL;
2995 if (flags & S_DIRSYNC)
2996 ei->i_flags |= EXT3_DIRSYNC_FL;
2998 + if (vflags & V_BARRIER)
2999 + ei->i_flags |= EXT3_BARRIER_FL;
3000 + if (vflags & V_COW)
3001 + ei->i_flags |= EXT3_COW_FL;
3004 +int ext3_sync_flags(struct inode *inode)
3006 + struct ext3_iloc iloc;
3010 + handle = ext3_journal_start(inode, 1);
3011 + if (IS_ERR(handle))
3012 + return PTR_ERR(handle);
3013 + if (IS_SYNC(inode))
3014 + handle->h_sync = 1;
3015 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3019 + ext3_get_inode_flags(EXT3_I(inode));
3020 + inode->i_ctime = CURRENT_TIME;
3022 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3024 + ext3_journal_stop(handle);
3028 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3029 @@ -2687,6 +2736,8 @@ struct inode *ext3_iget(struct super_blo
3030 struct inode *inode;
3036 inode = iget_locked(sb, ino);
3038 @@ -2707,12 +2758,17 @@ struct inode *ext3_iget(struct super_blo
3040 raw_inode = ext3_raw_inode(&iloc);
3041 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3042 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3043 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3044 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3045 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3046 if(!(test_opt (inode->i_sb, NO_UID32))) {
3047 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3048 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3049 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3050 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3052 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3053 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3054 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3055 + le16_to_cpu(raw_inode->i_raw_tag));
3057 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3058 inode->i_size = le32_to_cpu(raw_inode->i_size);
3059 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3060 @@ -2841,6 +2897,8 @@ static int ext3_do_update_inode(handle_t
3061 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3062 struct ext3_inode_info *ei = EXT3_I(inode);
3063 struct buffer_head *bh = iloc->bh;
3064 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3065 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3066 int err = 0, rc, block;
3068 /* For fields not not tracking in the in-memory inode,
3069 @@ -2851,29 +2909,32 @@ static int ext3_do_update_inode(handle_t
3070 ext3_get_inode_flags(ei);
3071 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3072 if(!(test_opt(inode->i_sb, NO_UID32))) {
3073 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3074 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3075 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3076 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3078 * Fix up interoperability with old kernels. Otherwise, old inodes get
3079 * re-used with the upper 16 bits of the uid/gid intact
3082 raw_inode->i_uid_high =
3083 - cpu_to_le16(high_16_bits(inode->i_uid));
3084 + cpu_to_le16(high_16_bits(uid));
3085 raw_inode->i_gid_high =
3086 - cpu_to_le16(high_16_bits(inode->i_gid));
3087 + cpu_to_le16(high_16_bits(gid));
3089 raw_inode->i_uid_high = 0;
3090 raw_inode->i_gid_high = 0;
3093 raw_inode->i_uid_low =
3094 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3095 + cpu_to_le16(fs_high2lowuid(uid));
3096 raw_inode->i_gid_low =
3097 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3098 + cpu_to_le16(fs_high2lowgid(gid));
3099 raw_inode->i_uid_high = 0;
3100 raw_inode->i_gid_high = 0;
3102 +#ifdef CONFIG_TAGGING_INTERN
3103 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3105 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3106 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3107 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3108 @@ -3026,7 +3087,8 @@ int ext3_setattr(struct dentry *dentry,
3111 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3112 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3113 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3114 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3117 /* (user+group)*(old+new) structure, inode write (sb,
3118 @@ -3048,6 +3110,8 @@ int ext3_setattr(struct dentry *dentry,
3119 inode->i_uid = attr->ia_uid;
3120 if (attr->ia_valid & ATTR_GID)
3121 inode->i_gid = attr->ia_gid;
3122 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3123 + inode->i_tag = attr->ia_tag;
3124 error = ext3_mark_inode_dirty(handle, inode);
3125 ext3_journal_stop(handle);
3127 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/ioctl.c
3128 --- linux-2.6.27.25/fs/ext3/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3129 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/ioctl.c 2008-10-13 14:54:20.000000000 +0200
3133 #include <linux/fs.h>
3134 +#include <linux/mount.h>
3135 #include <linux/jbd.h>
3136 #include <linux/capability.h>
3137 #include <linux/ext3_fs.h>
3139 #include <linux/time.h>
3140 #include <linux/compat.h>
3141 #include <linux/smp_lock.h>
3142 +#include <linux/vs_tag.h>
3143 #include <asm/uaccess.h>
3145 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
3146 @@ -56,6 +58,11 @@ int ext3_ioctl (struct inode * inode, st
3147 if (!S_ISDIR(inode->i_mode))
3148 flags &= ~EXT3_DIRSYNC_FL;
3150 + if (IS_BARRIER(inode)) {
3151 + vxwprintk_task(1, "messing with the barrier.");
3155 mutex_lock(&inode->i_mutex);
3156 /* Is it quota file? Do not allow user to mess with it */
3157 if (IS_NOQUOTA(inode)) {
3158 @@ -74,7 +81,9 @@ int ext3_ioctl (struct inode * inode, st
3160 * This test looks nicer. Thanks to Pauline Middelink
3162 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3163 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3164 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3165 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3166 if (!capable(CAP_LINUX_IMMUTABLE)) {
3167 mutex_unlock(&inode->i_mutex);
3169 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/namei.c
3170 --- linux-2.6.27.25/fs/ext3/namei.c 2009-06-15 17:18:31.000000000 +0200
3171 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/namei.c 2009-02-03 18:03:38.000000000 +0100
3173 #include <linux/quotaops.h>
3174 #include <linux/buffer_head.h>
3175 #include <linux/bio.h>
3176 +#include <linux/vs_tag.h>
3180 @@ -912,6 +913,7 @@ restart:
3182 ll_rw_block(READ_META, 1, &bh);
3184 + dx_propagate_tag(nd, inode);
3186 if ((bh = bh_use[ra_ptr++]) == NULL)
3188 @@ -2433,6 +2435,7 @@ const struct inode_operations ext3_dir_i
3189 .removexattr = generic_removexattr,
3191 .permission = ext3_permission,
3192 + .sync_flags = ext3_sync_flags,
3195 const struct inode_operations ext3_special_inode_operations = {
3196 @@ -2444,4 +2447,5 @@ const struct inode_operations ext3_speci
3197 .removexattr = generic_removexattr,
3199 .permission = ext3_permission,
3200 + .sync_flags = ext3_sync_flags,
3202 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/super.c
3203 --- linux-2.6.27.25/fs/ext3/super.c 2009-06-15 17:18:31.000000000 +0200
3204 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/super.c 2009-02-03 17:59:04.000000000 +0100
3205 @@ -757,7 +757,7 @@ enum {
3206 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3207 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
3208 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3210 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3213 static match_table_t tokens = {
3214 @@ -808,6 +808,9 @@ static match_table_t tokens = {
3215 {Opt_usrquota, "usrquota"},
3216 {Opt_barrier, "barrier=%u"},
3217 {Opt_resize, "resize"},
3219 + {Opt_notag, "notag"},
3220 + {Opt_tagid, "tagid=%u"},
3224 @@ -900,6 +903,20 @@ static int parse_options (char *options,
3226 set_opt (sbi->s_mount_opt, NO_UID32);
3228 +#ifndef CONFIG_TAGGING_NONE
3230 + set_opt (sbi->s_mount_opt, TAGGED);
3233 + clear_opt (sbi->s_mount_opt, TAGGED);
3236 +#ifdef CONFIG_PROPAGATE
3239 + set_opt (sbi->s_mount_opt, TAGGED);
3243 clear_opt (sbi->s_mount_opt, CHECK);
3245 @@ -1609,6 +1626,9 @@ static int ext3_fill_super (struct super
3249 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3250 + sb->s_flags |= MS_TAGGED;
3252 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3253 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3255 @@ -2446,6 +2466,13 @@ static int ext3_remount (struct super_bl
3256 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3257 ext3_abort(sb, __func__, "Abort forced by user");
3259 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3260 + !(sb->s_flags & MS_TAGGED)) {
3261 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3266 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3267 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3269 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/symlink.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/symlink.c
3270 --- linux-2.6.27.25/fs/ext3/symlink.c 2008-07-13 23:51:29.000000000 +0200
3271 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/symlink.c 2008-10-13 14:54:20.000000000 +0200
3272 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
3273 .listxattr = ext3_listxattr,
3274 .removexattr = generic_removexattr,
3276 + .sync_flags = ext3_sync_flags,
3279 const struct inode_operations ext3_fast_symlink_inode_operations = {
3280 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
3281 .listxattr = ext3_listxattr,
3282 .removexattr = generic_removexattr,
3284 + .sync_flags = ext3_sync_flags,
3286 diff -NurpP --minimal linux-2.6.27.25/fs/ext3/xattr.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/xattr.c
3287 --- linux-2.6.27.25/fs/ext3/xattr.c 2008-07-13 23:51:29.000000000 +0200
3288 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext3/xattr.c 2008-10-13 14:54:20.000000000 +0200
3290 #include <linux/mbcache.h>
3291 #include <linux/quotaops.h>
3292 #include <linux/rwsem.h>
3293 +#include <linux/vs_dlimit.h>
3297 @@ -498,6 +499,7 @@ ext3_xattr_release_block(handle_t *handl
3298 error = ext3_journal_dirty_metadata(handle, bh);
3301 + DLIMIT_FREE_BLOCK(inode, 1);
3302 DQUOT_FREE_BLOCK(inode, 1);
3303 ea_bdebug(bh, "refcount now=%d; releasing",
3304 le32_to_cpu(BHDR(bh)->h_refcount));
3305 @@ -771,11 +773,14 @@ inserted:
3306 if (new_bh == bs->bh)
3307 ea_bdebug(new_bh, "keeping");
3310 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3312 /* The old block is released after updating
3315 if (DQUOT_ALLOC_BLOCK(inode, 1))
3317 + goto cleanup_dlimit;
3318 error = ext3_journal_get_write_access(handle,
3321 @@ -849,6 +854,8 @@ cleanup:
3324 DQUOT_FREE_BLOCK(inode, 1);
3326 + DLIMIT_FREE_BLOCK(inode, 1);
3330 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/balloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/balloc.c
3331 --- linux-2.6.27.25/fs/ext4/balloc.c 2009-06-15 17:18:31.000000000 +0200
3332 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/balloc.c 2009-02-22 22:58:32.000000000 +0100
3334 #include <linux/jbd2.h>
3335 #include <linux/quotaops.h>
3336 #include <linux/buffer_head.h>
3337 +#include <linux/vs_dlimit.h>
3338 +#include <linux/vs_tag.h>
3340 #include "ext4_jbd2.h"
3342 @@ -1019,8 +1021,10 @@ void ext4_free_blocks(handle_t *handle,
3344 ext4_mb_free_blocks(handle, inode, block, count,
3345 metadata, &dquot_freed_blocks);
3346 - if (dquot_freed_blocks)
3347 + if (dquot_freed_blocks) {
3348 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3349 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3354 @@ -1880,6 +1884,8 @@ ext4_fsblk_t ext4_old_new_blocks(handle_
3358 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3362 es = EXT4_SB(sb)->s_es;
3363 @@ -2089,12 +2095,16 @@ allocated:
3366 DQUOT_FREE_BLOCK(inode, *count-num);
3367 + DLIMIT_FREE_BLOCK(inode, *count-num);
3374 + if (!performed_allocation)
3375 + DLIMIT_FREE_BLOCK(inode, *count);
3379 ext4_std_error(sb, fatal);
3380 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/ext4.h linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/ext4.h
3381 --- linux-2.6.27.25/fs/ext4/ext4.h 2009-06-15 17:18:31.000000000 +0200
3382 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/ext4.h 2009-06-15 17:22:10.000000000 +0200
3383 @@ -243,8 +243,12 @@ struct flex_groups {
3384 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
3385 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3386 #define EXT4_EXT_MIGRATE 0x00100000 /* Inode is migrating */
3387 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3388 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3390 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3391 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3393 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
3394 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
3396 @@ -569,6 +573,7 @@ do { \
3397 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
3398 #define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */
3399 #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
3400 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
3401 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
3402 #ifndef _LINUX_EXT2_FS_H
3403 #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
3404 @@ -1089,6 +1094,7 @@ int ext4_get_blocks_handle(handle_t *han
3405 ext4_lblk_t iblock, unsigned long maxblocks,
3406 struct buffer_head *bh_result,
3407 int create, int extend_disksize);
3408 +extern int ext4_sync_flags(struct inode *inode);
3410 extern struct inode *ext4_iget(struct super_block *, unsigned long);
3411 extern int ext4_write_inode (struct inode *, int);
3412 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/file.c
3413 --- linux-2.6.27.25/fs/ext4/file.c 2009-06-15 17:18:31.000000000 +0200
3414 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/file.c 2009-06-15 17:22:10.000000000 +0200
3415 @@ -175,5 +175,6 @@ const struct inode_operations ext4_file_
3417 .permission = ext4_permission,
3418 .fallocate = ext4_fallocate,
3419 + .sync_flags = ext4_sync_flags,
3422 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/ialloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/ialloc.c
3423 --- linux-2.6.27.25/fs/ext4/ialloc.c 2009-06-15 17:18:31.000000000 +0200
3424 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/ialloc.c 2009-06-15 17:22:10.000000000 +0200
3426 #include <linux/random.h>
3427 #include <linux/bitops.h>
3428 #include <linux/blkdev.h>
3429 +#include <linux/vs_dlimit.h>
3430 +#include <linux/vs_tag.h>
3431 #include <asm/byteorder.h>
3433 #include "ext4_jbd2.h"
3434 @@ -218,6 +220,7 @@ void ext4_free_inode (handle_t *handle,
3435 ext4_xattr_delete_inode(handle, inode);
3436 DQUOT_FREE_INODE(inode);
3438 + DLIMIT_FREE_INODE(inode);
3440 is_directory = S_ISDIR(inode->i_mode);
3442 @@ -698,6 +701,12 @@ struct inode *ext4_new_inode(handle_t *h
3443 inode = new_inode(sb);
3445 return ERR_PTR(-ENOMEM);
3447 + inode->i_tag = dx_current_fstag(sb);
3448 + if (DLIMIT_ALLOC_INODE(inode)) {
3455 @@ -866,12 +875,17 @@ got:
3459 - * Don't inherit extent flag from directory, amongst others. We set
3460 - * extent flag on newly created directory and file only if -o extent
3461 - * mount option is specified
3462 + * Don't inherit extent flag from directory. We set extent flag on
3463 + * newly created directory and file only if -o extent mount option is
3467 - ext4_mask_flags(mode, EXT4_I(dir)->i_flags & EXT4_FL_INHERITED);
3468 + ei->i_flags = EXT4_I(dir)->i_flags &
3469 + ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL|EXT4_IXUNLINK_FL|EXT4_BARRIER_FL);
3470 + if (S_ISLNK(mode))
3471 + ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
3472 + /* dirsync only applies to directories */
3473 + if (!S_ISDIR(mode))
3474 + ei->i_flags &= ~EXT4_DIRSYNC_FL;
3477 ei->i_block_alloc_info = NULL;
3478 @@ -922,6 +936,8 @@ got:
3480 ext4_std_error(sb, err);
3482 + DLIMIT_FREE_INODE(inode);
3487 @@ -933,6 +949,7 @@ fail_free_drop:
3491 + DLIMIT_FREE_INODE(inode);
3492 inode->i_flags |= S_NOQUOTA;
3495 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/inode.c
3496 --- linux-2.6.27.25/fs/ext4/inode.c 2009-06-15 17:18:31.000000000 +0200
3497 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/inode.c 2009-06-15 17:22:10.000000000 +0200
3499 #include <linux/mpage.h>
3500 #include <linux/uio.h>
3501 #include <linux/bio.h>
3502 +#include <linux/vs_tag.h>
3503 #include "ext4_jbd2.h"
3506 @@ -3611,7 +3612,7 @@ static void ext4_free_branches(handle_t
3508 int ext4_can_truncate(struct inode *inode)
3510 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3511 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3513 if (S_ISREG(inode->i_mode))
3515 @@ -3973,37 +3974,86 @@ void ext4_set_inode_flags(struct inode *
3517 unsigned int flags = EXT4_I(inode)->i_flags;
3519 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3520 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3521 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3523 + if (flags & EXT4_IMMUTABLE_FL)
3524 + inode->i_flags |= S_IMMUTABLE;
3525 + if (flags & EXT4_IXUNLINK_FL)
3526 + inode->i_flags |= S_IXUNLINK;
3528 if (flags & EXT4_SYNC_FL)
3529 inode->i_flags |= S_SYNC;
3530 if (flags & EXT4_APPEND_FL)
3531 inode->i_flags |= S_APPEND;
3532 - if (flags & EXT4_IMMUTABLE_FL)
3533 - inode->i_flags |= S_IMMUTABLE;
3534 if (flags & EXT4_NOATIME_FL)
3535 inode->i_flags |= S_NOATIME;
3536 if (flags & EXT4_DIRSYNC_FL)
3537 inode->i_flags |= S_DIRSYNC;
3539 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3541 + if (flags & EXT4_BARRIER_FL)
3542 + inode->i_vflags |= V_BARRIER;
3543 + if (flags & EXT4_COW_FL)
3544 + inode->i_vflags |= V_COW;
3547 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3548 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3550 unsigned int flags = ei->vfs_inode.i_flags;
3551 + unsigned int vflags = ei->vfs_inode.i_vflags;
3553 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3554 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3555 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3556 + EXT4_BARRIER_FL | EXT4_COW_FL);
3558 + if (flags & S_IMMUTABLE)
3559 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3560 + if (flags & S_IXUNLINK)
3561 + ei->i_flags |= EXT4_IXUNLINK_FL;
3563 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3564 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3566 ei->i_flags |= EXT4_SYNC_FL;
3567 if (flags & S_APPEND)
3568 ei->i_flags |= EXT4_APPEND_FL;
3569 - if (flags & S_IMMUTABLE)
3570 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3571 if (flags & S_NOATIME)
3572 ei->i_flags |= EXT4_NOATIME_FL;
3573 if (flags & S_DIRSYNC)
3574 ei->i_flags |= EXT4_DIRSYNC_FL;
3576 + if (vflags & V_BARRIER)
3577 + ei->i_flags |= EXT4_BARRIER_FL;
3578 + if (vflags & V_COW)
3579 + ei->i_flags |= EXT4_COW_FL;
3582 +int ext4_sync_flags(struct inode *inode)
3584 + struct ext4_iloc iloc;
3588 + handle = ext4_journal_start(inode, 1);
3589 + if (IS_ERR(handle))
3590 + return PTR_ERR(handle);
3591 + if (IS_SYNC(inode))
3592 + handle->h_sync = 1;
3593 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3597 + ext4_get_inode_flags(EXT4_I(inode));
3598 + inode->i_ctime = CURRENT_TIME;
3600 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3602 + ext4_journal_stop(handle);
3606 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3607 struct ext4_inode_info *ei)
3609 @@ -4036,6 +4086,8 @@ struct inode *ext4_iget(struct super_blo
3610 struct inode *inode;
3616 inode = iget_locked(sb, ino);
3618 @@ -4056,12 +4108,17 @@ struct inode *ext4_iget(struct super_blo
3620 raw_inode = ext4_raw_inode(&iloc);
3621 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3622 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3623 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3624 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3625 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3626 if(!(test_opt (inode->i_sb, NO_UID32))) {
3627 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3628 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3629 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3630 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3632 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3633 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3634 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3635 + le16_to_cpu(raw_inode->i_raw_tag));
3637 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3640 @@ -4253,6 +4310,8 @@ static int ext4_do_update_inode(handle_t
3641 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3642 struct ext4_inode_info *ei = EXT4_I(inode);
3643 struct buffer_head *bh = iloc->bh;
3644 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3645 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3646 int err = 0, rc, block;
3648 /* For fields not not tracking in the in-memory inode,
3649 @@ -4263,29 +4322,32 @@ static int ext4_do_update_inode(handle_t
3650 ext4_get_inode_flags(ei);
3651 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3652 if(!(test_opt(inode->i_sb, NO_UID32))) {
3653 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3654 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3655 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3656 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3658 * Fix up interoperability with old kernels. Otherwise, old inodes get
3659 * re-used with the upper 16 bits of the uid/gid intact
3662 raw_inode->i_uid_high =
3663 - cpu_to_le16(high_16_bits(inode->i_uid));
3664 + cpu_to_le16(high_16_bits(uid));
3665 raw_inode->i_gid_high =
3666 - cpu_to_le16(high_16_bits(inode->i_gid));
3667 + cpu_to_le16(high_16_bits(gid));
3669 raw_inode->i_uid_high = 0;
3670 raw_inode->i_gid_high = 0;
3673 raw_inode->i_uid_low =
3674 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3675 + cpu_to_le16(fs_high2lowuid(uid));
3676 raw_inode->i_gid_low =
3677 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3678 + cpu_to_le16(fs_high2lowgid(gid));
3679 raw_inode->i_uid_high = 0;
3680 raw_inode->i_gid_high = 0;
3682 +#ifdef CONFIG_TAGGING_INTERN
3683 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3685 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3687 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3688 @@ -4449,7 +4511,8 @@ int ext4_setattr(struct dentry *dentry,
3691 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3692 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3693 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3694 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3697 /* (user+group)*(old+new) structure, inode write (sb,
3698 @@ -4471,6 +4534,8 @@ int ext4_setattr(struct dentry *dentry,
3699 inode->i_uid = attr->ia_uid;
3700 if (attr->ia_valid & ATTR_GID)
3701 inode->i_gid = attr->ia_gid;
3702 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3703 + inode->i_tag = attr->ia_tag;
3704 error = ext4_mark_inode_dirty(handle, inode);
3705 ext4_journal_stop(handle);
3707 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/ioctl.c
3708 --- linux-2.6.27.25/fs/ext4/ioctl.c 2009-06-15 17:18:31.000000000 +0200
3709 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/ioctl.c 2009-06-15 17:24:03.000000000 +0200
3713 #include <linux/fs.h>
3714 +#include <linux/mount.h>
3715 #include <linux/jbd2.h>
3716 #include <linux/capability.h>
3717 #include <linux/time.h>
3718 #include <linux/compat.h>
3719 #include <linux/smp_lock.h>
3720 #include <linux/mount.h>
3721 +#include <linux/vs_tag.h>
3722 #include <asm/uaccess.h>
3723 #include "ext4_jbd2.h"
3725 @@ -49,6 +51,11 @@ long ext4_ioctl(struct file *filp, unsig
3729 + if (IS_BARRIER(inode)) {
3730 + vxwprintk_task(1, "messing with the barrier.");
3734 flags = ext4_mask_flags(inode->i_mode, flags);
3737 @@ -68,7 +75,9 @@ long ext4_ioctl(struct file *filp, unsig
3739 * This test looks nicer. Thanks to Pauline Middelink
3741 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3742 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3743 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3744 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3745 if (!capable(CAP_LINUX_IMMUTABLE))
3748 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/namei.c
3749 --- linux-2.6.27.25/fs/ext4/namei.c 2009-06-15 17:18:31.000000000 +0200
3750 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/namei.c 2009-06-15 17:22:10.000000000 +0200
3752 #include <linux/quotaops.h>
3753 #include <linux/buffer_head.h>
3754 #include <linux/bio.h>
3755 +#include <linux/vs_tag.h>
3757 #include "ext4_jbd2.h"
3759 @@ -919,6 +920,7 @@ restart:
3761 ll_rw_block(READ_META, 1, &bh);
3763 + dx_propagate_tag(nd, inode);
3765 if ((bh = bh_use[ra_ptr++]) == NULL)
3767 @@ -2487,6 +2489,7 @@ const struct inode_operations ext4_dir_i
3768 .removexattr = generic_removexattr,
3770 .permission = ext4_permission,
3771 + .sync_flags = ext4_sync_flags,
3774 const struct inode_operations ext4_special_inode_operations = {
3775 @@ -2498,4 +2501,5 @@ const struct inode_operations ext4_speci
3776 .removexattr = generic_removexattr,
3778 .permission = ext4_permission,
3779 + .sync_flags = ext4_sync_flags,
3781 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/super.c
3782 --- linux-2.6.27.25/fs/ext4/super.c 2009-06-15 17:18:31.000000000 +0200
3783 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/super.c 2009-03-25 14:32:29.000000000 +0100
3784 @@ -907,6 +907,7 @@ enum {
3785 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3786 Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
3787 Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_delalloc, Opt_nodelalloc,
3788 + Opt_tag, Opt_notag, Opt_tagid
3791 static match_table_t tokens = {
3792 @@ -967,6 +968,9 @@ static match_table_t tokens = {
3793 {Opt_resize, "resize"},
3794 {Opt_delalloc, "delalloc"},
3795 {Opt_nodelalloc, "nodelalloc"},
3797 + {Opt_notag, "notag"},
3798 + {Opt_tagid, "tagid=%u"},
3802 @@ -1060,6 +1064,20 @@ static int parse_options(char *options,
3804 set_opt(sbi->s_mount_opt, NO_UID32);
3806 +#ifndef CONFIG_TAGGING_NONE
3808 + set_opt (sbi->s_mount_opt, TAGGED);
3811 + clear_opt (sbi->s_mount_opt, TAGGED);
3814 +#ifdef CONFIG_PROPAGATE
3817 + set_opt (sbi->s_mount_opt, TAGGED);
3821 clear_opt(sbi->s_mount_opt, CHECK);
3823 @@ -2029,6 +2047,9 @@ static int ext4_fill_super(struct super_
3827 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3828 + sb->s_flags |= MS_TAGGED;
3830 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3831 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3833 @@ -3033,6 +3054,13 @@ static int ext4_remount(struct super_blo
3834 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
3835 ext4_abort(sb, __func__, "Abort forced by user");
3837 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3838 + !(sb->s_flags & MS_TAGGED)) {
3839 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3844 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3845 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3847 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/symlink.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/symlink.c
3848 --- linux-2.6.27.25/fs/ext4/symlink.c 2008-07-13 23:51:29.000000000 +0200
3849 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/symlink.c 2008-10-13 14:54:20.000000000 +0200
3850 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
3851 .listxattr = ext4_listxattr,
3852 .removexattr = generic_removexattr,
3854 + .sync_flags = ext4_sync_flags,
3857 const struct inode_operations ext4_fast_symlink_inode_operations = {
3858 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
3859 .listxattr = ext4_listxattr,
3860 .removexattr = generic_removexattr,
3862 + .sync_flags = ext4_sync_flags,
3864 diff -NurpP --minimal linux-2.6.27.25/fs/ext4/xattr.c linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/xattr.c
3865 --- linux-2.6.27.25/fs/ext4/xattr.c 2009-06-15 17:18:31.000000000 +0200
3866 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ext4/xattr.c 2009-02-03 17:59:04.000000000 +0100
3868 #include <linux/mbcache.h>
3869 #include <linux/quotaops.h>
3870 #include <linux/rwsem.h>
3871 +#include <linux/vs_dlimit.h>
3872 #include "ext4_jbd2.h"
3875 @@ -490,6 +491,7 @@ ext4_xattr_release_block(handle_t *handl
3876 error = ext4_journal_dirty_metadata(handle, bh);
3879 + DLIMIT_FREE_BLOCK(inode, 1);
3880 DQUOT_FREE_BLOCK(inode, 1);
3881 ea_bdebug(bh, "refcount now=%d; releasing",
3882 le32_to_cpu(BHDR(bh)->h_refcount));
3883 @@ -780,11 +782,14 @@ inserted:
3884 if (new_bh == bs->bh)
3885 ea_bdebug(new_bh, "keeping");
3888 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3890 /* The old block is released after updating
3893 if (DQUOT_ALLOC_BLOCK(inode, 1))
3895 + goto cleanup_dlimit;
3896 error = ext4_journal_get_write_access(handle,
3899 @@ -858,6 +863,8 @@ cleanup:
3902 DQUOT_FREE_BLOCK(inode, 1);
3904 + DLIMIT_FREE_BLOCK(inode, 1);
3908 diff -NurpP --minimal linux-2.6.27.25/fs/fcntl.c linux-2.6.27.25-vs2.3.0.36.6/fs/fcntl.c
3909 --- linux-2.6.27.25/fs/fcntl.c 2009-06-15 17:18:31.000000000 +0200
3910 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/fcntl.c 2009-05-22 00:47:30.000000000 +0200
3912 #include <linux/rcupdate.h>
3913 #include <linux/pid_namespace.h>
3914 #include <linux/smp_lock.h>
3915 +#include <linux/vs_limit.h>
3917 #include <asm/poll.h>
3918 #include <asm/siginfo.h>
3919 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3922 filp_close(tofree, files);
3924 + vx_openfd_inc(newfd); /* fd was unused */
3928 @@ -344,6 +347,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3932 + if (!vx_files_avail(1))
3935 err = security_file_fcntl(filp, cmd, arg);
3937 diff -NurpP --minimal linux-2.6.27.25/fs/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/file.c
3938 --- linux-2.6.27.25/fs/file.c 2008-10-13 14:52:05.000000000 +0200
3939 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/file.c 2008-10-24 04:44:48.000000000 +0200
3941 #include <linux/spinlock.h>
3942 #include <linux/rcupdate.h>
3943 #include <linux/workqueue.h>
3944 +#include <linux/vs_limit.h>
3946 struct fdtable_defer {
3948 @@ -367,6 +368,8 @@ struct files_struct *dup_fd(struct files
3949 struct file *f = *old_fds++;
3952 + /* TODO: sum it first for check and performance */
3953 + vx_openfd_inc(open_files - i);
3956 * The fd may be claimed in the fd bitmap but not yet
3957 @@ -475,6 +478,7 @@ repeat:
3959 FD_CLR(fd, fdt->close_on_exec);
3961 + vx_openfd_inc(fd);
3964 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3965 diff -NurpP --minimal linux-2.6.27.25/fs/file_table.c linux-2.6.27.25-vs2.3.0.36.6/fs/file_table.c
3966 --- linux-2.6.27.25/fs/file_table.c 2008-10-13 14:52:05.000000000 +0200
3967 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/file_table.c 2008-10-13 14:54:20.000000000 +0200
3969 #include <linux/fsnotify.h>
3970 #include <linux/sysctl.h>
3971 #include <linux/percpu_counter.h>
3972 +#include <linux/vs_limit.h>
3973 +#include <linux/vs_context.h>
3975 #include <asm/atomic.h>
3977 @@ -126,6 +128,8 @@ struct file *get_empty_filp(void)
3978 f->f_gid = tsk->fsgid;
3979 eventpoll_init_file(f);
3980 /* f->f_version: 0 */
3981 + f->f_xid = vx_current_xid();
3986 @@ -276,6 +280,8 @@ void __fput(struct file *file)
3987 cdev_put(inode->i_cdev);
3988 fops_put(file->f_op);
3989 put_pid(file->f_owner.pid);
3990 + vx_files_dec(file);
3993 if (file->f_mode & FMODE_WRITE)
3994 drop_file_write_access(file);
3995 @@ -343,6 +349,8 @@ void put_filp(struct file *file)
3997 if (atomic_long_dec_and_test(&file->f_count)) {
3998 security_file_free(file);
3999 + vx_files_dec(file);
4004 diff -NurpP --minimal linux-2.6.27.25/fs/hfsplus/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/hfsplus/ioctl.c
4005 --- linux-2.6.27.25/fs/hfsplus/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4006 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/hfsplus/ioctl.c 2008-10-13 14:54:20.000000000 +0200
4008 #include <linux/mount.h>
4009 #include <linux/sched.h>
4010 #include <linux/xattr.h>
4011 +#include <linux/mount.h>
4012 #include <asm/uaccess.h>
4013 #include "hfsplus_fs.h"
4015 diff -NurpP --minimal linux-2.6.27.25/fs/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/inode.c
4016 --- linux-2.6.27.25/fs/inode.c 2009-06-15 17:18:31.000000000 +0200
4017 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/inode.c 2009-03-25 14:32:29.000000000 +0100
4018 @@ -124,6 +124,9 @@ static struct inode *alloc_inode(struct
4019 struct address_space * const mapping = &inode->i_data;
4023 + /* essential because of inode slab reuse */
4025 inode->i_blkbits = sb->s_blocksize_bits;
4027 atomic_set(&inode->i_count, 1);
4028 @@ -142,6 +145,7 @@ static struct inode *alloc_inode(struct
4029 inode->i_bdev = NULL;
4030 inode->i_cdev = NULL;
4032 + inode->i_mdev = 0;
4033 inode->dirtied_when = 0;
4034 if (security_inode_alloc(inode)) {
4035 if (inode->i_sb->s_op->destroy_inode)
4036 @@ -247,6 +251,8 @@ void __iget(struct inode * inode)
4037 inodes_stat.nr_unused--;
4040 +EXPORT_SYMBOL_GPL(__iget);
4043 * clear_inode - clear an inode
4044 * @inode: inode to clear
4045 @@ -1434,9 +1440,11 @@ void init_special_inode(struct inode *in
4046 if (S_ISCHR(mode)) {
4047 inode->i_fop = &def_chr_fops;
4048 inode->i_rdev = rdev;
4049 + inode->i_mdev = rdev;
4050 } else if (S_ISBLK(mode)) {
4051 inode->i_fop = &def_blk_fops;
4052 inode->i_rdev = rdev;
4053 + inode->i_mdev = rdev;
4054 } else if (S_ISFIFO(mode))
4055 inode->i_fop = &def_fifo_fops;
4056 else if (S_ISSOCK(mode))
4057 diff -NurpP --minimal linux-2.6.27.25/fs/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/ioctl.c
4058 --- linux-2.6.27.25/fs/ioctl.c 2009-06-15 17:18:31.000000000 +0200
4059 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ioctl.c 2009-02-03 17:59:04.000000000 +0100
4061 #include <linux/security.h>
4062 #include <linux/module.h>
4063 #include <linux/uaccess.h>
4064 +#include <linux/proc_fs.h>
4065 +#include <linux/vserver/inode.h>
4066 +#include <linux/vs_tag.h>
4068 #include <asm/ioctls.h>
4070 diff -NurpP --minimal linux-2.6.27.25/fs/ioprio.c linux-2.6.27.25-vs2.3.0.36.6/fs/ioprio.c
4071 --- linux-2.6.27.25/fs/ioprio.c 2009-06-15 17:18:31.000000000 +0200
4072 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ioprio.c 2009-02-03 17:59:04.000000000 +0100
4074 #include <linux/syscalls.h>
4075 #include <linux/security.h>
4076 #include <linux/pid_namespace.h>
4077 +#include <linux/vs_base.h>
4079 static int set_task_ioprio(struct task_struct *task, int ioprio)
4081 @@ -116,6 +117,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4083 pgrp = find_vpid(who);
4084 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4085 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4087 ret = set_task_ioprio(p, ioprio);
4090 @@ -205,6 +208,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4092 pgrp = find_vpid(who);
4093 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4094 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4096 tmpio = get_task_ioprio(p);
4099 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/acl.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/acl.c
4100 --- linux-2.6.27.25/fs/jfs/acl.c 2008-10-13 14:52:05.000000000 +0200
4101 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/acl.c 2008-10-13 14:54:20.000000000 +0200
4102 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
4105 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4106 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4107 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4108 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4109 if (DQUOT_TRANSFER(inode, iattr))
4112 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/file.c
4113 --- linux-2.6.27.25/fs/jfs/file.c 2008-07-13 23:51:29.000000000 +0200
4114 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/file.c 2008-10-13 14:54:20.000000000 +0200
4115 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4116 .setattr = jfs_setattr,
4117 .permission = jfs_permission,
4119 + .sync_flags = jfs_sync_flags,
4122 const struct file_operations jfs_file_operations = {
4123 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/inode.c
4124 --- linux-2.6.27.25/fs/jfs/inode.c 2008-07-13 23:51:29.000000000 +0200
4125 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/inode.c 2008-10-13 14:54:20.000000000 +0200
4127 #include <linux/buffer_head.h>
4128 #include <linux/pagemap.h>
4129 #include <linux/quotaops.h>
4130 +#include <linux/vs_dlimit.h>
4131 #include "jfs_incore.h"
4132 #include "jfs_inode.h"
4133 #include "jfs_filsys.h"
4134 @@ -155,6 +156,7 @@ void jfs_delete_inode(struct inode *inod
4136 DQUOT_FREE_INODE(inode);
4138 + DLIMIT_FREE_INODE(inode);
4142 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/ioctl.c
4143 --- linux-2.6.27.25/fs/jfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4144 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
4146 #include <linux/mount.h>
4147 #include <linux/time.h>
4148 #include <linux/sched.h>
4149 +#include <linux/mount.h>
4150 #include <asm/current.h>
4151 #include <asm/uaccess.h>
4153 @@ -85,6 +86,11 @@ long jfs_ioctl(struct file *filp, unsign
4154 if (!S_ISDIR(inode->i_mode))
4155 flags &= ~JFS_DIRSYNC_FL;
4157 + if (IS_BARRIER(inode)) {
4158 + vxwprintk_task(1, "messing with the barrier.");
4162 /* Is it quota file? Do not allow user to mess with it */
4163 if (IS_NOQUOTA(inode)) {
4165 @@ -102,8 +108,8 @@ long jfs_ioctl(struct file *filp, unsign
4166 * the relevant capability.
4168 if ((oldflags & JFS_IMMUTABLE_FL) ||
4169 - ((flags ^ oldflags) &
4170 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4171 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4172 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4173 if (!capable(CAP_LINUX_IMMUTABLE)) {
4174 mutex_unlock(&inode->i_mutex);
4176 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_dinode.h linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_dinode.h
4177 --- linux-2.6.27.25/fs/jfs/jfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
4178 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_dinode.h 2008-10-31 18:15:18.000000000 +0100
4179 @@ -161,9 +161,13 @@ struct dinode {
4181 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4182 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4183 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4185 -#define JFS_FL_USER_VISIBLE 0x03F80000
4186 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4187 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4188 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4190 +#define JFS_FL_USER_VISIBLE 0x07F80000
4191 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4192 #define JFS_FL_INHERIT 0x03C80000
4194 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4195 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_dtree.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_dtree.c
4196 --- linux-2.6.27.25/fs/jfs/jfs_dtree.c 2008-07-13 23:51:29.000000000 +0200
4197 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_dtree.c 2008-10-13 14:54:20.000000000 +0200
4200 #include <linux/fs.h>
4201 #include <linux/quotaops.h>
4202 +#include <linux/vs_dlimit.h>
4203 #include "jfs_incore.h"
4204 #include "jfs_superblock.h"
4205 #include "jfs_filsys.h"
4206 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
4208 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
4210 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
4211 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4214 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
4215 + goto clean_up_dquot;
4216 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
4217 + goto clean_up_dlimit;
4220 * Save the table, we're going to overwrite it with the
4221 @@ -480,6 +481,12 @@ static u32 add_index(tid_t tid, struct i
4226 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
4229 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4233 jfs_ip->next_index--;
4234 @@ -951,6 +958,7 @@ static int dtSplitUp(tid_t tid,
4237 int quota_allocation = 0;
4238 + int dlimit_allocation = 0;
4240 /* get split page */
4242 @@ -1033,6 +1041,12 @@ static int dtSplitUp(tid_t tid,
4244 quota_allocation += n;
4246 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
4250 + dlimit_allocation += n;
4252 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
4255 @@ -1306,6 +1320,9 @@ static int dtSplitUp(tid_t tid,
4259 + /* Rollback dlimit allocation */
4260 + if (rc && dlimit_allocation)
4261 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4262 /* Rollback quota allocation */
4263 if (rc && quota_allocation)
4264 DQUOT_FREE_BLOCK(ip, quota_allocation);
4265 @@ -1373,6 +1390,12 @@ static int dtSplitPage(tid_t tid, struct
4266 release_metapage(rmp);
4269 + /* Allocate blocks to dlimit. */
4270 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4271 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4272 + release_metapage(rmp);
4276 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
4278 @@ -1920,6 +1943,12 @@ static int dtSplitRoot(tid_t tid,
4279 release_metapage(rmp);
4282 + /* Allocate blocks to dlimit. */
4283 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4284 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4285 + release_metapage(rmp);
4289 BT_MARK_DIRTY(rmp, ip);
4291 @@ -2286,6 +2315,8 @@ static int dtDeleteUp(tid_t tid, struct
4293 xlen = lengthPXD(&fp->header.self);
4295 + /* Free dlimit allocation. */
4296 + DLIMIT_FREE_BLOCK(ip, xlen);
4297 /* Free quota allocation. */
4298 DQUOT_FREE_BLOCK(ip, xlen);
4300 @@ -2362,6 +2393,8 @@ static int dtDeleteUp(tid_t tid, struct
4302 xlen = lengthPXD(&p->header.self);
4304 + /* Free dlimit allocation */
4305 + DLIMIT_FREE_BLOCK(ip, xlen);
4306 /* Free quota allocation */
4307 DQUOT_FREE_BLOCK(ip, xlen);
4309 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_extent.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_extent.c
4310 --- linux-2.6.27.25/fs/jfs/jfs_extent.c 2008-07-13 23:51:29.000000000 +0200
4311 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_extent.c 2008-10-13 14:54:20.000000000 +0200
4314 #include <linux/fs.h>
4315 #include <linux/quotaops.h>
4316 +#include <linux/vs_dlimit.h>
4317 #include "jfs_incore.h"
4318 #include "jfs_inode.h"
4319 #include "jfs_superblock.h"
4320 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
4324 + /* Allocate blocks to dlimit. */
4325 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4326 + DQUOT_FREE_BLOCK(ip, nxlen);
4327 + dbFree(ip, nxaddr, (s64) nxlen);
4328 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
4332 /* determine the value of the extent flag */
4333 xflag = abnr ? XAD_NOTRECORDED : 0;
4335 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
4338 dbFree(ip, nxaddr, nxlen);
4339 + DLIMIT_FREE_BLOCK(ip, nxlen);
4340 DQUOT_FREE_BLOCK(ip, nxlen);
4341 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4343 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
4344 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4347 + /* Allocate blocks to dlimit. */
4348 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4349 + DQUOT_FREE_BLOCK(ip, nxlen);
4350 + dbFree(ip, nxaddr, (s64) nxlen);
4351 + up(&JFS_IP(ip)->commit_sem);
4355 delta = nxlen - xlen;
4357 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
4358 /* extend the extent */
4359 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
4360 dbFree(ip, xaddr + xlen, delta);
4361 + DLIMIT_FREE_BLOCK(ip, nxlen);
4362 DQUOT_FREE_BLOCK(ip, nxlen);
4365 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
4367 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
4368 dbFree(ip, nxaddr, nxlen);
4369 + DLIMIT_FREE_BLOCK(ip, nxlen);
4370 DQUOT_FREE_BLOCK(ip, nxlen);
4373 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_filsys.h linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_filsys.h
4374 --- linux-2.6.27.25/fs/jfs/jfs_filsys.h 2008-07-13 23:51:29.000000000 +0200
4375 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_filsys.h 2008-10-13 14:54:20.000000000 +0200
4377 #define JFS_NAME_MAX 255
4378 #define JFS_PATH_MAX BPSIZE
4380 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4383 * file system state (superblock state)
4384 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_imap.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_imap.c
4385 --- linux-2.6.27.25/fs/jfs/jfs_imap.c 2008-10-13 14:52:05.000000000 +0200
4386 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_imap.c 2008-10-13 14:54:20.000000000 +0200
4388 #include <linux/buffer_head.h>
4389 #include <linux/pagemap.h>
4390 #include <linux/quotaops.h>
4391 +#include <linux/vs_tag.h>
4393 #include "jfs_incore.h"
4394 #include "jfs_inode.h"
4395 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
4397 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4398 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4402 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4403 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4404 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
4406 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4408 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4409 + uid = le32_to_cpu(dip->di_uid);
4410 + gid = le32_to_cpu(dip->di_gid);
4411 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4413 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4415 ip->i_uid = jfs_ip->saved_uid;
4417 ip->i_uid = sbi->uid;
4420 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4421 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4423 ip->i_gid = jfs_ip->saved_gid;
4425 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
4426 dip->di_size = cpu_to_le64(ip->i_size);
4427 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4428 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4429 - if (sbi->uid == -1)
4430 - dip->di_uid = cpu_to_le32(ip->i_uid);
4432 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4433 - if (sbi->gid == -1)
4434 - dip->di_gid = cpu_to_le32(ip->i_gid);
4436 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4438 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4439 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4440 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4441 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4443 jfs_get_inode_flags(jfs_ip);
4445 * mode2 is only needed for storing the higher order bits.
4446 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_inode.c
4447 --- linux-2.6.27.25/fs/jfs/jfs_inode.c 2008-07-13 23:51:29.000000000 +0200
4448 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_inode.c 2008-10-13 14:54:20.000000000 +0200
4451 #include <linux/fs.h>
4452 #include <linux/quotaops.h>
4453 +#include <linux/vs_dlimit.h>
4454 +#include <linux/vs_tag.h>
4455 #include "jfs_incore.h"
4456 #include "jfs_inode.h"
4457 #include "jfs_filsys.h"
4458 @@ -30,29 +32,46 @@ void jfs_set_inode_flags(struct inode *i
4460 unsigned int flags = JFS_IP(inode)->mode2;
4462 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4463 - S_NOATIME | S_DIRSYNC | S_SYNC);
4464 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4465 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4467 if (flags & JFS_IMMUTABLE_FL)
4468 inode->i_flags |= S_IMMUTABLE;
4469 + if (flags & JFS_IXUNLINK_FL)
4470 + inode->i_flags |= S_IXUNLINK;
4472 + if (flags & JFS_SYNC_FL)
4473 + inode->i_flags |= S_SYNC;
4474 if (flags & JFS_APPEND_FL)
4475 inode->i_flags |= S_APPEND;
4476 if (flags & JFS_NOATIME_FL)
4477 inode->i_flags |= S_NOATIME;
4478 if (flags & JFS_DIRSYNC_FL)
4479 inode->i_flags |= S_DIRSYNC;
4480 - if (flags & JFS_SYNC_FL)
4481 - inode->i_flags |= S_SYNC;
4483 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4485 + if (flags & JFS_BARRIER_FL)
4486 + inode->i_vflags |= V_BARRIER;
4487 + if (flags & JFS_COW_FL)
4488 + inode->i_vflags |= V_COW;
4491 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4493 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4494 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4496 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4497 + JFS_APPEND_FL | JFS_NOATIME_FL |
4498 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4499 + JFS_BARRIER_FL | JFS_COW_FL);
4501 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4502 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4503 if (flags & S_IMMUTABLE)
4504 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4505 + if (flags & S_IXUNLINK)
4506 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4508 if (flags & S_APPEND)
4509 jfs_ip->mode2 |= JFS_APPEND_FL;
4510 if (flags & S_NOATIME)
4511 @@ -61,6 +80,19 @@ void jfs_get_inode_flags(struct jfs_inod
4512 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4514 jfs_ip->mode2 |= JFS_SYNC_FL;
4516 + if (vflags & V_BARRIER)
4517 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4518 + if (vflags & V_COW)
4519 + jfs_ip->mode2 |= JFS_COW_FL;
4522 +int jfs_sync_flags(struct inode *inode)
4524 + jfs_get_inode_flags(JFS_IP(inode));
4525 + inode->i_ctime = CURRENT_TIME;
4526 + mark_inode_dirty(inode);
4531 @@ -108,10 +140,17 @@ struct inode *ialloc(struct inode *paren
4532 jfs_inode->saved_uid = inode->i_uid;
4533 jfs_inode->saved_gid = inode->i_gid;
4535 + inode->i_tag = dx_current_fstag(sb);
4536 + if (DLIMIT_ALLOC_INODE(inode)) {
4538 + return ERR_PTR(-ENOSPC);
4542 * Allocate inode to quota.
4544 if (DQUOT_ALLOC_INODE(inode)) {
4545 + DLIMIT_FREE_INODE(inode);
4547 inode->i_flags |= S_NOQUOTA;
4549 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_inode.h linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_inode.h
4550 --- linux-2.6.27.25/fs/jfs/jfs_inode.h 2008-07-13 23:51:29.000000000 +0200
4551 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_inode.h 2008-10-13 14:54:20.000000000 +0200
4552 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4553 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4554 int fh_len, int fh_type);
4555 extern void jfs_set_inode_flags(struct inode *);
4556 +extern int jfs_sync_flags(struct inode *);
4557 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4559 extern const struct address_space_operations jfs_aops;
4560 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/jfs_xtree.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_xtree.c
4561 --- linux-2.6.27.25/fs/jfs/jfs_xtree.c 2008-10-13 14:52:05.000000000 +0200
4562 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/jfs_xtree.c 2008-10-13 14:54:20.000000000 +0200
4564 #include <linux/module.h>
4565 #include <linux/quotaops.h>
4566 #include <linux/seq_file.h>
4567 +#include <linux/vs_dlimit.h>
4568 #include "jfs_incore.h"
4569 #include "jfs_filsys.h"
4570 #include "jfs_metapage.h"
4571 @@ -848,7 +849,12 @@ int xtInsert(tid_t tid, /* transaction
4573 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
4575 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
4576 + DQUOT_FREE_BLOCK(ip, xlen);
4579 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
4580 + DLIMIT_FREE_BLOCK(ip, xlen);
4581 DQUOT_FREE_BLOCK(ip, xlen);
4584 @@ -878,6 +884,7 @@ int xtInsert(tid_t tid, /* transaction
4585 /* undo data extent allocation */
4587 dbFree(ip, xaddr, (s64) xlen);
4588 + DLIMIT_FREE_BLOCK(ip, xlen);
4589 DQUOT_FREE_BLOCK(ip, xlen);
4592 @@ -1234,6 +1241,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
4594 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
4595 int quota_allocation = 0;
4596 + int dlimit_allocation = 0;
4599 sp = XT_PAGE(ip, smp);
4600 @@ -1253,6 +1261,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
4602 quota_allocation += lengthPXD(pxd);
4604 + /* Allocate blocks to dlimit. */
4605 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4609 + dlimit_allocation += lengthPXD(pxd);
4612 * allocate the new right page for the split
4614 @@ -1454,6 +1469,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
4618 + /* Rollback dlimit allocation. */
4619 + if (dlimit_allocation)
4620 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4621 /* Rollback quota allocation. */
4622 if (quota_allocation)
4623 DQUOT_FREE_BLOCK(ip, quota_allocation);
4624 @@ -1517,6 +1535,12 @@ xtSplitRoot(tid_t tid,
4625 release_metapage(rmp);
4628 + /* Allocate blocks to dlimit. */
4629 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4630 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4631 + release_metapage(rmp);
4635 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
4637 @@ -3940,6 +3964,8 @@ s64 xtTruncate(tid_t tid, struct inode *
4639 ip->i_size = newsize;
4641 + /* update dlimit allocation to reflect freed blocks */
4642 + DLIMIT_FREE_BLOCK(ip, nfreed);
4643 /* update quota allocation to reflect freed blocks */
4644 DQUOT_FREE_BLOCK(ip, nfreed);
4646 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/namei.c
4647 --- linux-2.6.27.25/fs/jfs/namei.c 2008-10-13 14:52:05.000000000 +0200
4648 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/namei.c 2008-10-13 14:54:20.000000000 +0200
4650 #include <linux/ctype.h>
4651 #include <linux/quotaops.h>
4652 #include <linux/exportfs.h>
4653 +#include <linux/vs_tag.h>
4654 #include "jfs_incore.h"
4655 #include "jfs_superblock.h"
4656 #include "jfs_inode.h"
4657 @@ -1468,6 +1469,7 @@ static struct dentry *jfs_lookup(struct
4658 return ERR_CAST(ip);
4661 + dx_propagate_tag(nd, ip);
4662 dentry = d_splice_alias(ip, dentry);
4664 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4665 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
4666 .setattr = jfs_setattr,
4667 .permission = jfs_permission,
4669 + .sync_flags = jfs_sync_flags,
4672 const struct file_operations jfs_dir_operations = {
4673 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/super.c
4674 --- linux-2.6.27.25/fs/jfs/super.c 2008-10-13 14:52:05.000000000 +0200
4675 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/super.c 2008-10-13 14:54:20.000000000 +0200
4676 @@ -196,7 +196,8 @@ static void jfs_put_super(struct super_b
4678 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4679 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4680 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4681 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4682 + Opt_tag, Opt_notag, Opt_tagid
4685 static match_table_t tokens = {
4686 @@ -206,6 +207,10 @@ static match_table_t tokens = {
4687 {Opt_resize, "resize=%u"},
4688 {Opt_resize_nosize, "resize"},
4689 {Opt_errors, "errors=%s"},
4691 + {Opt_notag, "notag"},
4692 + {Opt_tagid, "tagid=%u"},
4693 + {Opt_tag, "tagxid"},
4694 {Opt_ignore, "noquota"},
4695 {Opt_ignore, "quota"},
4696 {Opt_usrquota, "usrquota"},
4697 @@ -340,6 +345,20 @@ static int parse_options(char *options,
4701 +#ifndef CONFIG_TAGGING_NONE
4703 + *flag |= JFS_TAGGED;
4706 + *flag &= JFS_TAGGED;
4709 +#ifdef CONFIG_PROPAGATE
4712 + *flag |= JFS_TAGGED;
4716 printk("jfs: Unrecognized mount option \"%s\" "
4717 " or missing value\n", p);
4718 @@ -370,6 +389,13 @@ static int jfs_remount(struct super_bloc
4719 if (!parse_options(data, sb, &newLVSize, &flag)) {
4723 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4724 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4730 if (sb->s_flags & MS_RDONLY) {
4732 @@ -441,6 +467,9 @@ static int jfs_fill_super(struct super_b
4733 #ifdef CONFIG_JFS_POSIX_ACL
4734 sb->s_flags |= MS_POSIXACL;
4736 + /* map mount option tagxid */
4737 + if (sbi->flag & JFS_TAGGED)
4738 + sb->s_flags |= MS_TAGGED;
4741 printk(KERN_ERR "resize option for remount only\n");
4742 diff -NurpP --minimal linux-2.6.27.25/fs/jfs/xattr.c linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/xattr.c
4743 --- linux-2.6.27.25/fs/jfs/xattr.c 2008-07-13 23:51:29.000000000 +0200
4744 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/jfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
4746 #include <linux/posix_acl_xattr.h>
4747 #include <linux/quotaops.h>
4748 #include <linux/security.h>
4749 +#include <linux/vs_dlimit.h>
4750 #include "jfs_incore.h"
4751 #include "jfs_superblock.h"
4752 #include "jfs_dmap.h"
4753 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
4754 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
4757 + /* Allocate new blocks to dlimit. */
4758 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
4759 + DQUOT_FREE_BLOCK(ip, nblocks);
4763 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
4765 + /*Rollback dlimit allocation. */
4766 + DLIMIT_FREE_BLOCK(ip, nblocks);
4767 /*Rollback quota allocation. */
4768 DQUOT_FREE_BLOCK(ip, nblocks);
4770 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
4773 /* Rollback quota allocation. */
4774 + DLIMIT_FREE_BLOCK(ip, nblocks);
4775 + /* Rollback quota allocation. */
4776 DQUOT_FREE_BLOCK(ip, nblocks);
4778 dbFree(ip, blkno, nblocks);
4779 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
4782 int quota_allocation = 0;
4783 + int dlimit_allocation = 0;
4785 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
4786 if (ji->ea.flag == 0)
4787 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
4789 quota_allocation = blocks_needed;
4791 + /* Allocate new blocks to dlimit. */
4793 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
4795 + dlimit_allocation = blocks_needed;
4797 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
4800 @@ -600,6 +617,9 @@ static int ea_get(struct inode *inode, s
4804 + /* Rollback dlimit allocation */
4805 + if (dlimit_allocation)
4806 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
4807 /* Rollback quota allocation */
4808 if (quota_allocation)
4809 DQUOT_FREE_BLOCK(inode, quota_allocation);
4810 @@ -676,8 +696,10 @@ static int ea_put(tid_t tid, struct inod
4813 /* If old blocks exist, they must be removed from quota allocation. */
4816 + DLIMIT_FREE_BLOCK(inode, old_blocks);
4817 DQUOT_FREE_BLOCK(inode, old_blocks);
4820 inode->i_ctime = CURRENT_TIME;
4822 diff -NurpP --minimal linux-2.6.27.25/fs/libfs.c linux-2.6.27.25-vs2.3.0.36.6/fs/libfs.c
4823 --- linux-2.6.27.25/fs/libfs.c 2009-06-15 17:18:31.000000000 +0200
4824 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/libfs.c 2009-02-03 17:59:04.000000000 +0100
4825 @@ -125,7 +125,8 @@ static inline unsigned char dt_type(stru
4826 * both impossible due to the lock on directory.
4829 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4830 +static inline int do_dcache_readdir_filter(struct file *filp,
4831 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4833 struct dentry *dentry = filp->f_path.dentry;
4834 struct dentry *cursor = filp->private_data;
4835 @@ -158,6 +159,8 @@ int dcache_readdir(struct file * filp, v
4836 next = list_entry(p, struct dentry, d_u.d_child);
4837 if (d_unhashed(next) || !next->d_inode)
4839 + if (filter && !filter(next))
4842 spin_unlock(&dcache_lock);
4843 if (filldir(dirent, next->d_name.name,
4844 @@ -176,6 +179,18 @@ int dcache_readdir(struct file * filp, v
4848 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4850 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4853 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4854 + int (*filter)(struct dentry *))
4856 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4860 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4863 @@ -823,6 +838,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4864 EXPORT_SYMBOL(dcache_dir_lseek);
4865 EXPORT_SYMBOL(dcache_dir_open);
4866 EXPORT_SYMBOL(dcache_readdir);
4867 +EXPORT_SYMBOL(dcache_readdir_filter);
4868 EXPORT_SYMBOL(generic_read_dir);
4869 EXPORT_SYMBOL(get_sb_pseudo);
4870 EXPORT_SYMBOL(simple_write_begin);
4871 diff -NurpP --minimal linux-2.6.27.25/fs/locks.c linux-2.6.27.25-vs2.3.0.36.6/fs/locks.c
4872 --- linux-2.6.27.25/fs/locks.c 2009-06-15 17:18:31.000000000 +0200
4873 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/locks.c 2009-02-03 17:59:04.000000000 +0100
4875 #include <linux/time.h>
4876 #include <linux/rcupdate.h>
4877 #include <linux/pid_namespace.h>
4878 +#include <linux/vs_base.h>
4879 +#include <linux/vs_limit.h>
4881 #include <asm/uaccess.h>
4883 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4884 /* Allocate an empty lock structure. */
4885 static struct file_lock *locks_alloc_lock(void)
4887 + if (!vx_locks_avail(1))
4889 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4892 @@ -173,6 +177,7 @@ static void locks_free_lock(struct file_
4893 BUG_ON(!list_empty(&fl->fl_block));
4894 BUG_ON(!list_empty(&fl->fl_link));
4897 locks_release_private(fl);
4898 kmem_cache_free(filelock_cache, fl);
4900 @@ -193,6 +198,7 @@ void locks_init_lock(struct file_lock *f
4901 fl->fl_start = fl->fl_end = 0;
4903 fl->fl_lmops = NULL;
4907 EXPORT_SYMBOL(locks_init_lock);
4908 @@ -247,6 +253,7 @@ void locks_copy_lock(struct file_lock *n
4909 new->fl_file = fl->fl_file;
4910 new->fl_ops = fl->fl_ops;
4911 new->fl_lmops = fl->fl_lmops;
4912 + new->fl_xid = fl->fl_xid;
4914 locks_copy_private(new, fl);
4916 @@ -285,6 +292,11 @@ static int flock_make_lock(struct file *
4917 fl->fl_flags = FL_FLOCK;
4919 fl->fl_end = OFFSET_MAX;
4921 + vxd_assert(filp->f_xid == vx_current_xid(),
4922 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4923 + fl->fl_xid = filp->f_xid;
4928 @@ -450,6 +462,7 @@ static int lease_init(struct file *filp,
4930 fl->fl_owner = current->files;
4931 fl->fl_pid = current->tgid;
4932 + fl->fl_xid = vx_current_xid();
4935 fl->fl_flags = FL_LEASE;
4936 @@ -469,6 +482,11 @@ static struct file_lock *lease_alloc(str
4938 return ERR_PTR(error);
4940 + fl->fl_xid = vx_current_xid();
4942 + vxd_assert(filp->f_xid == fl->fl_xid,
4943 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4945 error = lease_init(filp, type, fl);
4947 locks_free_lock(fl);
4948 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
4952 + new_fl->fl_xid = -1;
4954 for_each_lock(inode, before) {
4955 struct file_lock *fl = *before;
4956 @@ -789,6 +808,7 @@ find_conflict:
4958 locks_copy_lock(new_fl, request);
4959 locks_insert_lock(before, new_fl);
4960 + vx_locks_inc(new_fl);
4964 @@ -799,7 +819,8 @@ out:
4968 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4969 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4970 + struct file_lock *conflock, xid_t xid)
4972 struct file_lock *fl;
4973 struct file_lock *new_fl = NULL;
4974 @@ -809,6 +830,8 @@ static int __posix_lock_file(struct inod
4975 struct file_lock **before;
4976 int error, added = 0;
4978 + vxd_assert(xid == vx_current_xid(),
4979 + "xid(%d) == current(%d)", xid, vx_current_xid());
4981 * We may need two file_lock structures for this operation,
4982 * so we get them in advance to avoid races.
4983 @@ -819,7 +842,11 @@ static int __posix_lock_file(struct inod
4984 (request->fl_type != F_UNLCK ||
4985 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4986 new_fl = locks_alloc_lock();
4987 + new_fl->fl_xid = xid;
4988 + vx_locks_inc(new_fl);
4989 new_fl2 = locks_alloc_lock();
4990 + new_fl2->fl_xid = xid;
4991 + vx_locks_inc(new_fl2);
4995 @@ -1018,7 +1045,8 @@ static int __posix_lock_file(struct inod
4996 int posix_lock_file(struct file *filp, struct file_lock *fl,
4997 struct file_lock *conflock)
4999 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
5000 + return __posix_lock_file(filp->f_path.dentry->d_inode,
5001 + fl, conflock, filp->f_xid);
5003 EXPORT_SYMBOL(posix_lock_file);
5005 @@ -1108,7 +1136,7 @@ int locks_mandatory_area(int read_write,
5006 fl.fl_end = offset + count - 1;
5009 - error = __posix_lock_file(inode, &fl, NULL);
5010 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
5011 if (error != FILE_LOCK_DEFERRED)
5013 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
5014 @@ -1423,6 +1451,7 @@ int generic_setlease(struct file *filp,
5016 locks_copy_lock(new_fl, lease);
5017 locks_insert_lock(before, new_fl);
5018 + vx_locks_inc(new_fl);
5022 @@ -1777,6 +1806,11 @@ int fcntl_setlk(unsigned int fd, struct
5023 if (file_lock == NULL)
5026 + vxd_assert(filp->f_xid == vx_current_xid(),
5027 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5028 + file_lock->fl_xid = filp->f_xid;
5029 + vx_locks_inc(file_lock);
5032 * This might block, so we do it before checking the inode.
5034 @@ -1895,6 +1929,11 @@ int fcntl_setlk64(unsigned int fd, struc
5035 if (file_lock == NULL)
5038 + vxd_assert(filp->f_xid == vx_current_xid(),
5039 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5040 + file_lock->fl_xid = filp->f_xid;
5041 + vx_locks_inc(file_lock);
5044 * This might block, so we do it before checking the inode.
5046 @@ -2159,8 +2198,11 @@ static int locks_show(struct seq_file *f
5048 lock_get_status(f, fl, (long)f->private, "");
5050 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
5051 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
5052 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
5054 lock_get_status(f, bfl, (long)f->private, " ->");
5059 diff -NurpP --minimal linux-2.6.27.25/fs/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/namei.c
5060 --- linux-2.6.27.25/fs/namei.c 2009-06-15 17:18:31.000000000 +0200
5061 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/namei.c 2009-02-03 17:59:04.000000000 +0100
5063 #include <linux/file.h>
5064 #include <linux/fcntl.h>
5065 #include <linux/device_cgroup.h>
5066 +#include <linux/proc_fs.h>
5067 +#include <linux/vserver/inode.h>
5068 +#include <linux/vs_base.h>
5069 +#include <linux/vs_tag.h>
5070 +#include <linux/vs_cowbl.h>
5071 +#include <linux/vs_device.h>
5072 +#include <linux/vs_context.h>
5073 +#include <linux/pid_namespace.h>
5074 #include <asm/uaccess.h>
5076 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
5077 @@ -167,6 +175,77 @@ void putname(const char *name)
5078 EXPORT_SYMBOL(putname);
5081 +static inline int dx_barrier(struct inode *inode)
5083 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
5084 + vxwprintk_task(1, "did hit the barrier.");
5090 +static int __dx_permission(struct inode *inode, int mask)
5092 + if (dx_barrier(inode))
5095 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
5096 + /* devpts is xid tagged */
5097 + if (S_ISDIR(inode->i_mode) ||
5098 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
5101 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5102 + struct proc_dir_entry *de = PDE(inode);
5104 + if (de && !vx_hide_check(0, de->vx_flags))
5107 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
5109 + struct task_struct *tsk;
5111 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
5112 + vx_flags(VXF_STATE_SETUP, 0))
5115 + pid = PROC_I(inode)->pid;
5119 + tsk = pid_task(pid, PIDTYPE_PID);
5120 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
5121 + tsk, (tsk ? vx_task_xid(tsk) : 0));
5122 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
5126 + /* FIXME: Should we block some entries here? */
5131 + if (dx_notagcheck(inode->i_sb) ||
5132 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
5141 +int dx_permission(struct inode *inode, int mask)
5143 + int ret = __dx_permission(inode, mask);
5144 + if (unlikely(ret)) {
5145 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
5146 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5154 * generic_permission - check for access rights on a Posix-like filesystem
5155 @@ -244,10 +323,14 @@ int inode_permission(struct inode *inode
5157 * Nobody gets write access to an immutable file.
5159 - if (IS_IMMUTABLE(inode))
5160 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5164 + retval = dx_permission(inode, mask);
5168 /* Ordinary permission routines do not understand MAY_APPEND. */
5169 if (inode->i_op && inode->i_op->permission) {
5170 retval = inode->i_op->permission(inode, mask);
5171 @@ -451,6 +534,8 @@ static int exec_permission_lite(struct i
5173 umode_t mode = inode->i_mode;
5175 + if (dx_barrier(inode))
5177 if (inode->i_op && inode->i_op->permission)
5180 @@ -773,7 +858,8 @@ static __always_inline void follow_dotdo
5181 if (nd->path.dentry == fs->root.dentry &&
5182 nd->path.mnt == fs->root.mnt) {
5183 read_unlock(&fs->lock);
5185 + /* for sane '/' avoid follow_mount() */
5188 read_unlock(&fs->lock);
5189 spin_lock(&dcache_lock);
5190 @@ -810,16 +896,30 @@ static int do_lookup(struct nameidata *n
5192 struct vfsmount *mnt = nd->path.mnt;
5193 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5194 + struct inode *inode;
5198 if (dentry->d_op && dentry->d_op->d_revalidate)
5199 goto need_revalidate;
5200 + inode = dentry->d_inode;
5204 + if (__dx_permission(inode, MAY_ACCESS))
5209 path->dentry = dentry;
5210 __follow_mount(path);
5213 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s«.",
5214 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5215 + vxd_path(&nd->path));
5220 dentry = real_lookup(nd->path.dentry, name, nd);
5221 @@ -1407,7 +1507,7 @@ static int may_delete(struct inode *dir,
5224 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5225 - IS_IMMUTABLE(victim->d_inode))
5226 + IS_IXORUNLINK(victim->d_inode))
5229 if (!S_ISDIR(victim->d_inode->i_mode))
5230 @@ -1551,6 +1651,14 @@ int may_open(struct nameidata *nd, int a
5234 +#ifdef CONFIG_VSERVER_COWBL
5235 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5236 + if (IS_COW_LINK(inode))
5238 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5239 + mark_inode_dirty(inode);
5242 error = vfs_permission(nd, acc_mode);
5245 @@ -1677,6 +1785,11 @@ struct file *do_filp_open(int dfd, const
5247 int flag = open_to_namei_flags(open_flag);
5249 +#ifdef CONFIG_VSERVER_COWBL
5254 acc_mode = MAY_OPEN | ACC_MODE(flag);
5256 /* O_TRUNC implies we need access checks for write permissions */
5257 @@ -1800,6 +1913,25 @@ ok:
5260 error = may_open(&nd, acc_mode, flag);
5261 +#ifdef CONFIG_VSERVER_COWBL
5262 + if (error == -EMLINK) {
5263 + struct dentry *dentry;
5264 + dentry = cow_break_link(pathname);
5265 + if (IS_ERR(dentry)) {
5266 + error = PTR_ERR(dentry);
5271 + mnt_drop_write(nd.path.mnt);
5272 + release_open_intent(&nd);
5273 + path_put(&nd.path);
5282 mnt_drop_write(nd.path.mnt);
5283 @@ -1952,9 +2084,17 @@ int vfs_mknod(struct inode *dir, struct
5287 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5288 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5291 + if (!capable(CAP_MKNOD))
5294 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5296 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5299 if (!dir->i_op || !dir->i_op->mknod)
5302 @@ -2395,7 +2535,7 @@ int vfs_link(struct dentry *old_dentry,
5304 * A link to an append-only or immutable file cannot be created.
5306 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5307 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5309 if (!dir->i_op || !dir->i_op->link)
5311 @@ -2755,6 +2895,217 @@ int vfs_follow_link(struct nameidata *nd
5312 return __vfs_follow_link(nd, link);
5316 +#ifdef CONFIG_VSERVER_COWBL
5318 +#include <linux/file.h>
5321 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5325 + return do_splice_direct(in, &ppos, out, len, 0);
5328 +struct dentry *cow_break_link(const char *pathname)
5330 + int ret, mode, pathlen, redo = 0;
5331 + struct nameidata old_nd, dir_nd;
5332 + struct path old_path, new_path;
5333 + struct dentry *dir, *res = NULL;
5334 + struct file *old_file;
5335 + struct file *new_file;
5336 + char *to, *path, pad='\251';
5339 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5340 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5345 + /* old_nd will have refs to dentry and mnt */
5346 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5347 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5349 + goto out_free_path;
5351 + old_path = old_nd.path;
5352 + mode = old_path.dentry->d_inode->i_mode;
5354 + to = d_path(&old_path, path, PATH_MAX-2);
5355 + pathlen = strlen(to);
5356 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5357 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5358 + old_path.dentry->d_name.len);
5360 + to[pathlen + 1] = 0;
5362 + to[pathlen] = pad--;
5364 + if (pad <= '\240')
5367 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5368 + /* dir_nd will have refs to dentry and mnt */
5369 + ret = path_lookup(to,
5370 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5371 + vxdprintk(VXD_CBIT(misc, 2),
5372 + "path_lookup(new): %d", ret);
5376 + /* this puppy downs the inode mutex */
5377 + new_path.dentry = lookup_create(&dir_nd, 0);
5378 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5379 + vxdprintk(VXD_CBIT(misc, 2),
5380 + "lookup_create(new): %p", new_path.dentry);
5381 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5382 + path_put(&dir_nd.path);
5385 + vxdprintk(VXD_CBIT(misc, 2),
5386 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5387 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5388 + new_path.dentry->d_name.len);
5389 + dir = dir_nd.path.dentry;
5391 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5392 + vxdprintk(VXD_CBIT(misc, 2),
5393 + "vfs_create(new): %d", ret);
5394 + if (ret == -EEXIST) {
5395 + mutex_unlock(&dir->d_inode->i_mutex);
5396 + dput(new_path.dentry);
5397 + path_put(&dir_nd.path);
5401 + goto out_unlock_new;
5403 + /* drop out early, ret passes ENOENT */
5405 + if ((redo = d_unhashed(old_path.dentry)))
5406 + goto out_unlock_new;
5408 + new_path.mnt = dir_nd.path.mnt;
5409 + dget(old_path.dentry);
5410 + mntget(old_path.mnt);
5411 + /* this one cleans up the dentry/mnt in case of failure */
5412 + old_file = dentry_open(old_path.dentry, old_path.mnt, O_RDONLY);
5413 + vxdprintk(VXD_CBIT(misc, 2),
5414 + "dentry_open(old): %p", old_file);
5415 + if (!old_file || IS_ERR(old_file)) {
5416 + res = IS_ERR(old_file) ? (void *) old_file : res;
5417 + goto out_unlock_new;
5420 + dget(new_path.dentry);
5421 + mntget(new_path.mnt);
5422 + /* this one cleans up the dentry/mnt in case of failure */
5423 + new_file = dentry_open(new_path.dentry, new_path.mnt, O_WRONLY);
5424 + vxdprintk(VXD_CBIT(misc, 2),
5425 + "dentry_open(new): %p", new_file);
5427 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5428 + if (!new_file || IS_ERR(new_file))
5429 + goto out_fput_old;
5431 + size = i_size_read(old_file->f_dentry->d_inode);
5432 + ret = do_cow_splice(old_file, new_file, size);
5433 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5435 + goto out_fput_both;
5436 + } else if (ret < size) {
5438 + goto out_fput_both;
5440 + struct inode *old_inode = old_path.dentry->d_inode;
5441 + struct inode *new_inode = new_path.dentry->d_inode;
5442 + struct iattr attr = {
5443 + .ia_uid = old_inode->i_uid,
5444 + .ia_gid = old_inode->i_gid,
5445 + .ia_valid = ATTR_UID | ATTR_GID
5448 + ret = inode_setattr(new_inode, &attr);
5450 + goto out_fput_both;
5453 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5455 + /* drop out late */
5457 + if ((redo = d_unhashed(old_path.dentry)))
5460 + vxdprintk(VXD_CBIT(misc, 2),
5461 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5462 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5463 + new_path.dentry->d_name.len,
5464 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5465 + old_path.dentry->d_name.len);
5466 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5467 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5468 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5469 + res = new_path.dentry;
5472 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5475 + vxdprintk(VXD_CBIT(misc, 3),
5476 + "fput(new_file=%p[#%ld])", new_file,
5477 + atomic_read(&new_file->f_count));
5481 + vxdprintk(VXD_CBIT(misc, 3),
5482 + "fput(old_file=%p[#%ld])", old_file,
5483 + atomic_read(&old_file->f_count));
5487 + mutex_unlock(&dir->d_inode->i_mutex);
5491 + /* error path cleanup */
5492 + vfs_unlink(dir->d_inode, new_path.dentry);
5493 + dput(new_path.dentry);
5497 + goto out_rel_both;
5498 + /* lookup dentry once again */
5499 + path_put(&old_nd.path);
5500 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5502 + goto out_rel_both;
5504 + new_path.dentry = old_nd.path.dentry;
5505 + vxdprintk(VXD_CBIT(misc, 2),
5506 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5507 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5508 + new_path.dentry->d_name.len);
5509 + dget(new_path.dentry);
5510 + res = new_path.dentry;
5513 + path_put(&dir_nd.path);
5515 + path_put(&old_nd.path);
5520 + res = ERR_PTR(ret);
5526 /* get the link contents into pagecache */
5527 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5529 diff -NurpP --minimal linux-2.6.27.25/fs/namespace.c linux-2.6.27.25-vs2.3.0.36.6/fs/namespace.c
5530 --- linux-2.6.27.25/fs/namespace.c 2009-06-15 17:18:31.000000000 +0200
5531 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/namespace.c 2009-05-15 22:59:20.000000000 +0200
5533 #include <linux/ramfs.h>
5534 #include <linux/log2.h>
5535 #include <linux/idr.h>
5536 +#include <linux/vs_base.h>
5537 +#include <linux/vs_context.h>
5538 +#include <linux/vs_tag.h>
5539 +#include <linux/vserver/space.h>
5540 +#include <linux/vserver/global.h>
5541 #include <asm/uaccess.h>
5542 #include <asm/unistd.h>
5544 @@ -573,6 +578,7 @@ static struct vfsmount *clone_mnt(struct
5545 mnt->mnt_root = dget(root);
5546 mnt->mnt_mountpoint = mnt->mnt_root;
5547 mnt->mnt_parent = mnt;
5548 + mnt->mnt_tag = old->mnt_tag;
5550 if (flag & CL_SLAVE) {
5551 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5552 @@ -685,6 +691,31 @@ static inline void mangle(struct seq_fil
5553 seq_escape(m, s, " \t\n\\");
5556 +static int mnt_is_reachable(struct vfsmount *mnt)
5559 + struct dentry *point;
5562 + if (mnt == mnt->mnt_ns->root)
5565 + spin_lock(&vfsmount_lock);
5566 + root = current->fs->root;
5567 + point = root.dentry;
5569 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5570 + point = mnt->mnt_mountpoint;
5571 + mnt = mnt->mnt_parent;
5574 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5576 + spin_unlock(&vfsmount_lock);
5582 * Simple .show_options callback for filesystems which don't want to
5583 * implement more complex mount option showing.
5584 @@ -757,6 +788,8 @@ static int show_sb_opts(struct seq_file
5585 { MS_SYNCHRONOUS, ",sync" },
5586 { MS_DIRSYNC, ",dirsync" },
5587 { MS_MANDLOCK, ",mand" },
5588 + { MS_TAGGED, ",tag" },
5589 + { MS_NOTAGCHECK, ",notagcheck" },
5592 const struct proc_fs_info *fs_infop;
5593 @@ -803,10 +836,20 @@ static int show_vfsmnt(struct seq_file *
5595 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5597 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5599 - seq_path(m, &mnt_path, " \t\n\\");
5601 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5603 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5606 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5607 + mnt == current->fs->root.mnt) {
5608 + seq_puts(m, "/dev/root / ");
5610 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5612 + seq_path(m, &mnt_path, " \t\n\\");
5615 show_type(m, mnt->mnt_sb);
5616 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5617 err = show_sb_opts(m, mnt->mnt_sb);
5618 @@ -836,6 +879,11 @@ static int show_mountinfo(struct seq_fil
5619 struct path root = p->root;
5622 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5624 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5627 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5628 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5629 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5630 @@ -894,17 +942,27 @@ static int show_vfsstat(struct seq_file
5631 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5635 - if (mnt->mnt_devname) {
5636 - seq_puts(m, "device ");
5637 - mangle(m, mnt->mnt_devname);
5639 - seq_puts(m, "no device");
5640 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5642 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5646 - seq_puts(m, " mounted on ");
5647 - seq_path(m, &mnt_path, " \t\n\\");
5649 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5650 + mnt == current->fs->root.mnt) {
5651 + seq_puts(m, "device /dev/root mounted on / ");
5654 + if (mnt->mnt_devname) {
5655 + seq_puts(m, "device ");
5656 + mangle(m, mnt->mnt_devname);
5658 + seq_puts(m, "no device");
5661 + seq_puts(m, " mounted on ");
5662 + seq_path(m, &mnt_path, " \t\n\\");
5666 /* file system type */
5667 seq_puts(m, "with fstype ");
5668 @@ -1143,7 +1201,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5672 - if (!capable(CAP_SYS_ADMIN))
5673 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5676 retval = do_umount(path.mnt, flags);
5677 @@ -1169,7 +1227,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5679 static int mount_is_safe(struct nameidata *nd)
5681 - if (capable(CAP_SYS_ADMIN))
5682 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5686 @@ -1462,11 +1520,13 @@ static noinline int do_change_type(struc
5687 * noinline this do_mount helper to save do_mount stack space.
5689 static noinline int do_loopback(struct nameidata *nd, char *old_name,
5691 + tag_t tag, unsigned long flags, int mnt_flags)
5693 struct nameidata old_nd;
5694 struct vfsmount *mnt = NULL;
5695 int err = mount_is_safe(nd);
5696 + int recurse = flags & MS_REC;
5700 if (!old_name || !*old_name)
5701 @@ -1500,6 +1560,7 @@ static noinline int do_loopback(struct n
5702 spin_unlock(&vfsmount_lock);
5703 release_mounts(&umount_list);
5705 + mnt->mnt_flags = mnt_flags;
5708 up_write(&namespace_sem);
5709 @@ -1531,12 +1592,12 @@ static int change_mount_flags(struct vfs
5710 * noinline this do_mount helper to save do_mount stack space.
5712 static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
5714 + void *data, xid_t xid)
5717 struct super_block *sb = nd->path.mnt->mnt_sb;
5719 - if (!capable(CAP_SYS_ADMIN))
5720 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5723 if (!check_mnt(nd->path.mnt))
5724 @@ -1582,7 +1643,7 @@ static noinline int do_move_mount(struct
5725 struct path parent_path;
5728 - if (!capable(CAP_SYS_ADMIN))
5729 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5731 if (!old_name || !*old_name)
5733 @@ -1665,7 +1726,7 @@ static noinline int do_new_mount(struct
5736 /* we need capabilities... */
5737 - if (!capable(CAP_SYS_ADMIN))
5738 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5741 mnt = do_kern_mount(type, flags, name, data);
5742 @@ -1910,6 +1971,7 @@ long do_mount(char *dev_name, char *dir_
5743 struct nameidata nd;
5749 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5750 @@ -1925,6 +1987,12 @@ long do_mount(char *dev_name, char *dir_
5752 ((char *)data_page)[PAGE_SIZE - 1] = 0;
5754 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5755 + /* FIXME: bind and re-mounts get the tag flag? */
5756 + if (flags & (MS_BIND|MS_REMOUNT))
5757 + flags |= MS_TAGID;
5760 /* Separate the per-mountpoint flags */
5761 if (flags & MS_NOSUID)
5762 mnt_flags |= MNT_NOSUID;
5763 @@ -1941,6 +2009,8 @@ long do_mount(char *dev_name, char *dir_
5764 if (flags & MS_RDONLY)
5765 mnt_flags |= MNT_READONLY;
5767 + if (!capable(CAP_SYS_ADMIN))
5768 + mnt_flags |= MNT_NODEV;
5769 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5770 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
5772 @@ -1956,9 +2026,9 @@ long do_mount(char *dev_name, char *dir_
5774 if (flags & MS_REMOUNT)
5775 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
5778 else if (flags & MS_BIND)
5779 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
5780 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
5781 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5782 retval = do_change_type(&nd, flags);
5783 else if (flags & MS_MOVE)
5784 @@ -2027,6 +2097,7 @@ static struct mnt_namespace *dup_mnt_ns(
5785 q = next_mnt(q, new_ns->root);
5787 up_write(&namespace_sem);
5788 + atomic_inc(&vs_global_mnt_ns);
5792 @@ -2213,9 +2284,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5793 down_write(&namespace_sem);
5794 mutex_lock(&old.dentry->d_inode->i_mutex);
5796 - if (IS_MNT_SHARED(old.mnt) ||
5797 + if ((IS_MNT_SHARED(old.mnt) ||
5798 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5799 - IS_MNT_SHARED(root.mnt->mnt_parent))
5800 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5801 + !vx_flags(VXF_STATE_SETUP, 0))
5803 if (!check_mnt(root.mnt))
5805 @@ -2354,5 +2426,6 @@ void __put_mnt_ns(struct mnt_namespace *
5806 spin_unlock(&vfsmount_lock);
5807 up_write(&namespace_sem);
5808 release_mounts(&umount_list);
5809 + atomic_dec(&vs_global_mnt_ns);
5812 diff -NurpP --minimal linux-2.6.27.25/fs/nfs/client.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/client.c
5813 --- linux-2.6.27.25/fs/nfs/client.c 2008-10-13 14:52:05.000000000 +0200
5814 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/client.c 2008-10-13 14:54:20.000000000 +0200
5815 @@ -601,6 +601,9 @@ static int nfs_init_server_rpcclient(str
5816 if (server->flags & NFS_MOUNT_SOFT)
5817 server->client->cl_softrtry = 1;
5819 + server->client->cl_tag = 0;
5820 + if (server->flags & NFS_MOUNT_TAGGED)
5821 + server->client->cl_tag = 1;
5825 @@ -766,6 +769,10 @@ static void nfs_server_set_fsinfo(struct
5826 server->acdirmin = server->acdirmax = 0;
5829 + /* FIXME: needs fsinfo
5830 + if (server->flags & NFS_MOUNT_TAGGED)
5831 + sb->s_flags |= MS_TAGGED; */
5833 server->maxfilesize = fsinfo->maxfilesize;
5835 /* We're airborne Set socket buffersize */
5836 diff -NurpP --minimal linux-2.6.27.25/fs/nfs/dir.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/dir.c
5837 --- linux-2.6.27.25/fs/nfs/dir.c 2009-06-15 17:18:31.000000000 +0200
5838 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/dir.c 2009-06-15 17:22:10.000000000 +0200
5840 #include <linux/namei.h>
5841 #include <linux/mount.h>
5842 #include <linux/sched.h>
5843 +#include <linux/vs_tag.h>
5845 #include "nfs4_fs.h"
5846 #include "delegation.h"
5847 @@ -938,6 +939,7 @@ static struct dentry *nfs_lookup(struct
5849 goto out_unblock_sillyrename;
5851 + dx_propagate_tag(nd, inode);
5853 res = d_materialise_unique(dentry, inode);
5855 diff -NurpP --minimal linux-2.6.27.25/fs/nfs/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/inode.c
5856 --- linux-2.6.27.25/fs/nfs/inode.c 2008-10-13 14:52:05.000000000 +0200
5857 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/inode.c 2008-10-13 14:54:20.000000000 +0200
5859 #include <linux/vfs.h>
5860 #include <linux/inet.h>
5861 #include <linux/nfs_xdr.h>
5862 +#include <linux/vs_tag.h>
5864 #include <asm/system.h>
5865 #include <asm/uaccess.h>
5866 @@ -314,8 +315,10 @@ nfs_fhget(struct super_block *sb, struct
5867 nfsi->change_attr = fattr->change_attr;
5868 inode->i_size = nfs_size_to_loff_t(fattr->size);
5869 inode->i_nlink = fattr->nlink;
5870 - inode->i_uid = fattr->uid;
5871 - inode->i_gid = fattr->gid;
5872 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5873 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5874 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5875 + /* maybe fattr->xid someday */
5876 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5878 * report the blocks in 512byte units
5879 @@ -462,6 +465,8 @@ void nfs_setattr_update_inode(struct ino
5880 inode->i_uid = attr->ia_uid;
5881 if ((attr->ia_valid & ATTR_GID) != 0)
5882 inode->i_gid = attr->ia_gid;
5883 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5884 + inode->i_tag = attr->ia_tag;
5885 spin_lock(&inode->i_lock);
5886 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5887 spin_unlock(&inode->i_lock);
5888 @@ -900,6 +905,9 @@ static int nfs_check_inode_attributes(st
5889 struct nfs_inode *nfsi = NFS_I(inode);
5890 loff_t cur_size, new_isize;
5891 unsigned long invalid = 0;
5897 /* Has the inode gone and changed behind our back? */
5898 @@ -924,10 +932,15 @@ static int nfs_check_inode_attributes(st
5899 if (cur_size != new_isize && nfsi->npages == 0)
5900 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5902 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5903 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5904 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5906 /* Have any file permissions changed? */
5907 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
5908 - || inode->i_uid != fattr->uid
5909 - || inode->i_gid != fattr->gid)
5910 + || inode->i_uid != uid
5911 + || inode->i_gid != gid
5912 + || inode->i_tag != tag)
5913 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5915 /* Has the link count changed? */
5916 @@ -1048,6 +1061,9 @@ static int nfs_update_inode(struct inode
5917 loff_t cur_isize, new_isize;
5918 unsigned long invalid = 0;
5919 unsigned long now = jiffies;
5924 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5925 __func__, inode->i_sb->s_id, inode->i_ino,
5926 @@ -1121,15 +1137,21 @@ static int nfs_update_inode(struct inode
5927 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5928 nfsi->change_attr = fattr->change_attr;
5930 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5931 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5932 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5934 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
5935 - inode->i_uid != fattr->uid ||
5936 - inode->i_gid != fattr->gid)
5937 + inode->i_uid != uid ||
5938 + inode->i_gid != gid ||
5939 + inode->i_tag != tag)
5940 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5942 inode->i_mode = fattr->mode;
5943 inode->i_nlink = fattr->nlink;
5944 - inode->i_uid = fattr->uid;
5945 - inode->i_gid = fattr->gid;
5946 + inode->i_uid = uid;
5947 + inode->i_gid = gid;
5948 + inode->i_tag = tag;
5950 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5952 diff -NurpP --minimal linux-2.6.27.25/fs/nfs/nfs3xdr.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/nfs3xdr.c
5953 --- linux-2.6.27.25/fs/nfs/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
5954 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
5956 #include <linux/nfs3.h>
5957 #include <linux/nfs_fs.h>
5958 #include <linux/nfsacl.h>
5959 +#include <linux/vs_tag.h>
5960 #include "internal.h"
5962 #define NFSDBG_FACILITY NFSDBG_XDR
5963 @@ -180,7 +181,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5966 static inline __be32 *
5967 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5968 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5970 if (attr->ia_valid & ATTR_MODE) {
5972 @@ -188,15 +189,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5976 - if (attr->ia_valid & ATTR_UID) {
5977 + if (attr->ia_valid & ATTR_UID ||
5978 + (tag && (attr->ia_valid & ATTR_TAG))) {
5980 - *p++ = htonl(attr->ia_uid);
5981 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5985 - if (attr->ia_valid & ATTR_GID) {
5986 + if (attr->ia_valid & ATTR_GID ||
5987 + (tag && (attr->ia_valid & ATTR_TAG))) {
5989 - *p++ = htonl(attr->ia_gid);
5990 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5994 @@ -281,7 +284,8 @@ static int
5995 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5997 p = xdr_encode_fhandle(p, args->fh);
5998 - p = xdr_encode_sattr(p, args->sattr);
5999 + p = xdr_encode_sattr(p, args->sattr,
6000 + req->rq_task->tk_client->cl_tag);
6001 *p++ = htonl(args->guard);
6003 p = xdr_encode_time3(p, &args->guardtime);
6004 @@ -386,7 +390,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
6005 *p++ = args->verifier[0];
6006 *p++ = args->verifier[1];
6008 - p = xdr_encode_sattr(p, args->sattr);
6009 + p = xdr_encode_sattr(p, args->sattr,
6010 + req->rq_task->tk_client->cl_tag);
6012 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6014 @@ -400,7 +405,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
6016 p = xdr_encode_fhandle(p, args->fh);
6017 p = xdr_encode_array(p, args->name, args->len);
6018 - p = xdr_encode_sattr(p, args->sattr);
6019 + p = xdr_encode_sattr(p, args->sattr,
6020 + req->rq_task->tk_client->cl_tag);
6021 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6024 @@ -413,7 +419,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6026 p = xdr_encode_fhandle(p, args->fromfh);
6027 p = xdr_encode_array(p, args->fromname, args->fromlen);
6028 - p = xdr_encode_sattr(p, args->sattr);
6029 + p = xdr_encode_sattr(p, args->sattr,
6030 + req->rq_task->tk_client->cl_tag);
6031 *p++ = htonl(args->pathlen);
6032 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6034 @@ -431,7 +438,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6035 p = xdr_encode_fhandle(p, args->fh);
6036 p = xdr_encode_array(p, args->name, args->len);
6037 *p++ = htonl(args->type);
6038 - p = xdr_encode_sattr(p, args->sattr);
6039 + p = xdr_encode_sattr(p, args->sattr,
6040 + req->rq_task->tk_client->cl_tag);
6041 if (args->type == NF3CHR || args->type == NF3BLK) {
6042 *p++ = htonl(MAJOR(args->rdev));
6043 *p++ = htonl(MINOR(args->rdev));
6044 diff -NurpP --minimal linux-2.6.27.25/fs/nfs/nfsroot.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/nfsroot.c
6045 --- linux-2.6.27.25/fs/nfs/nfsroot.c 2008-10-13 14:52:05.000000000 +0200
6046 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/nfsroot.c 2008-10-13 14:54:20.000000000 +0200
6047 @@ -117,12 +117,12 @@ static int mount_port __initdata = 0; /
6049 /* Options that take integer arguments */
6050 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6051 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6052 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6053 /* Options that take no arguments */
6054 Opt_soft, Opt_hard, Opt_intr,
6055 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6056 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6057 - Opt_acl, Opt_noacl,
6058 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6062 @@ -159,6 +159,9 @@ static match_table_t __initdata tokens =
6065 {Opt_noacl, "noacl"},
6067 + {Opt_notag, "notag"},
6068 + {Opt_tagid, "tagid=%u"},
6072 @@ -270,6 +273,20 @@ static int __init root_nfs_parse(char *n
6074 nfs_data.flags |= NFS_MOUNT_NOACL;
6076 +#ifndef CONFIG_TAGGING_NONE
6078 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6081 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6084 +#ifdef CONFIG_PROPAGATE
6087 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6091 printk(KERN_WARNING "Root-NFS: unknown "
6093 diff -NurpP --minimal linux-2.6.27.25/fs/nfs/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/super.c
6094 --- linux-2.6.27.25/fs/nfs/super.c 2008-10-13 14:52:05.000000000 +0200
6095 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfs/super.c 2008-10-13 14:54:20.000000000 +0200
6097 #include <linux/nfs_xdr.h>
6098 #include <linux/magic.h>
6099 #include <linux/parser.h>
6100 +#include <linux/vs_tag.h>
6102 #include <asm/system.h>
6103 #include <asm/uaccess.h>
6104 @@ -504,6 +505,7 @@ static void nfs_show_mount_options(struc
6105 { NFS_MOUNT_NOACL, ",noacl", "" },
6106 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6107 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
6108 + { NFS_MOUNT_TAGGED, ",tag", "" },
6111 const struct proc_nfs_info *nfs_infop;
6112 diff -NurpP --minimal linux-2.6.27.25/fs/nfsd/auth.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/auth.c
6113 --- linux-2.6.27.25/fs/nfsd/auth.c 2008-07-13 23:51:29.000000000 +0200
6114 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/auth.c 2008-10-13 14:54:20.000000000 +0200
6116 #include <linux/sunrpc/svcauth.h>
6117 #include <linux/nfsd/nfsd.h>
6118 #include <linux/nfsd/export.h>
6119 +#include <linux/vs_tag.h>
6122 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6123 @@ -55,19 +56,23 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6124 get_group_info(cred.cr_group_info);
6126 if (cred.cr_uid != (uid_t) -1)
6127 - current->fsuid = cred.cr_uid;
6128 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6130 current->fsuid = exp->ex_anon_uid;
6131 if (cred.cr_gid != (gid_t) -1)
6132 - current->fsgid = cred.cr_gid;
6133 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6135 current->fsgid = exp->ex_anon_gid;
6137 + /* this desperately needs a tag :) */
6138 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6140 if (!cred.cr_group_info)
6142 ret = set_current_groups(cred.cr_group_info);
6143 put_group_info(cred.cr_group_info);
6144 - if ((cred.cr_uid)) {
6146 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
6147 current->cap_effective =
6148 cap_drop_nfsd_set(current->cap_effective);
6150 diff -NurpP --minimal linux-2.6.27.25/fs/nfsd/nfs3xdr.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/nfs3xdr.c
6151 --- linux-2.6.27.25/fs/nfsd/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
6152 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
6154 #include <linux/sunrpc/svc.h>
6155 #include <linux/nfsd/nfsd.h>
6156 #include <linux/nfsd/xdr3.h>
6157 +#include <linux/vs_tag.h>
6160 #define NFSDDBG_FACILITY NFSDDBG_XDR
6161 @@ -108,6 +109,8 @@ static __be32 *
6162 decode_sattr3(__be32 *p, struct iattr *iap)
6170 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6173 iap->ia_valid |= ATTR_UID;
6174 - iap->ia_uid = ntohl(*p++);
6175 + uid = ntohl(*p++);
6178 iap->ia_valid |= ATTR_GID;
6179 - iap->ia_gid = ntohl(*p++);
6180 + gid = ntohl(*p++);
6182 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6183 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6184 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6188 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6189 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6190 *p++ = htonl((u32) stat->mode);
6191 *p++ = htonl((u32) stat->nlink);
6192 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6193 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6194 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6195 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6196 + stat->uid, stat->tag)));
6197 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6198 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6199 + stat->gid, stat->tag)));
6200 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6201 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6203 diff -NurpP --minimal linux-2.6.27.25/fs/nfsd/nfs4xdr.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/nfs4xdr.c
6204 --- linux-2.6.27.25/fs/nfsd/nfs4xdr.c 2009-06-15 17:18:32.000000000 +0200
6205 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/nfs4xdr.c 2009-05-22 00:47:30.000000000 +0200
6207 #include <linux/nfs4_acl.h>
6208 #include <linux/sunrpc/gss_api.h>
6209 #include <linux/sunrpc/svcauth_gss.h>
6210 +#include <linux/vs_tag.h>
6212 #define NFSDDBG_FACILITY NFSDDBG_XDR
6214 @@ -1704,14 +1705,18 @@ out_acl:
6215 WRITE32(stat.nlink);
6217 if (bmval1 & FATTR4_WORD1_OWNER) {
6218 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6219 + status = nfsd4_encode_user(rqstp,
6220 + TAGINO_UID(DX_TAG(dentry->d_inode),
6221 + stat.uid, stat.tag), &p, &buflen);
6222 if (status == nfserr_resource)
6227 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6228 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6229 + status = nfsd4_encode_group(rqstp,
6230 + TAGINO_GID(DX_TAG(dentry->d_inode),
6231 + stat.gid, stat.tag), &p, &buflen);
6232 if (status == nfserr_resource)
6235 diff -NurpP --minimal linux-2.6.27.25/fs/nfsd/nfsxdr.c linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/nfsxdr.c
6236 --- linux-2.6.27.25/fs/nfsd/nfsxdr.c 2008-07-13 23:51:29.000000000 +0200
6237 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/nfsd/nfsxdr.c 2008-10-13 14:54:20.000000000 +0200
6239 #include <linux/nfsd/nfsd.h>
6240 #include <linux/nfsd/xdr.h>
6241 #include <linux/mm.h>
6242 +#include <linux/vs_tag.h>
6245 #define NFSDDBG_FACILITY NFSDDBG_XDR
6246 @@ -98,6 +99,8 @@ static __be32 *
6247 decode_sattr(__be32 *p, struct iattr *iap)
6255 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6257 if ((tmp = ntohl(*p++)) != (u32)-1) {
6258 iap->ia_valid |= ATTR_UID;
6259 - iap->ia_uid = tmp;
6262 if ((tmp = ntohl(*p++)) != (u32)-1) {
6263 iap->ia_valid |= ATTR_GID;
6264 - iap->ia_gid = tmp;
6267 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6268 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6269 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6270 if ((tmp = ntohl(*p++)) != (u32)-1) {
6271 iap->ia_valid |= ATTR_SIZE;
6273 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6274 *p++ = htonl(nfs_ftypes[type >> 12]);
6275 *p++ = htonl((u32) stat->mode);
6276 *p++ = htonl((u32) stat->nlink);
6277 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6278 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6279 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6280 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6281 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6282 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6284 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6285 *p++ = htonl(NFS_MAXPATHLEN);
6286 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/dlm/dlmfs.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/dlm/dlmfs.c
6287 --- linux-2.6.27.25/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:52:06.000000000 +0200
6288 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:54:20.000000000 +0200
6290 #include <linux/init.h>
6291 #include <linux/string.h>
6292 #include <linux/backing-dev.h>
6293 +#include <linux/vs_tag.h>
6295 #include <asm/uaccess.h>
6297 @@ -341,6 +342,7 @@ static struct inode *dlmfs_get_root_inod
6298 inode->i_mode = mode;
6299 inode->i_uid = current->fsuid;
6300 inode->i_gid = current->fsgid;
6301 + inode->i_tag = dx_current_fstag(sb);
6302 inode->i_blocks = 0;
6303 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6304 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6305 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6306 inode->i_mode = mode;
6307 inode->i_uid = current->fsuid;
6308 inode->i_gid = current->fsgid;
6309 + inode->i_tag = dx_current_fstag(sb);
6310 inode->i_blocks = 0;
6311 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6312 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6313 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/dlmglue.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/dlmglue.c
6314 --- linux-2.6.27.25/fs/ocfs2/dlmglue.c 2008-10-13 14:52:06.000000000 +0200
6315 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/dlmglue.c 2008-10-13 14:54:20.000000000 +0200
6316 @@ -1846,6 +1846,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6317 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6318 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6319 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6320 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6321 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6322 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6323 lvb->lvb_iatime_packed =
6324 @@ -1900,6 +1901,7 @@ static void ocfs2_refresh_inode_from_lvb
6326 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6327 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6328 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6329 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6330 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6331 ocfs2_unpack_timespec(&inode->i_atime,
6332 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/dlmglue.h linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/dlmglue.h
6333 --- linux-2.6.27.25/fs/ocfs2/dlmglue.h 2008-07-13 23:51:29.000000000 +0200
6334 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/dlmglue.h 2008-10-13 14:54:20.000000000 +0200
6335 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6338 __be32 lvb_igeneration;
6339 - __be32 lvb_reserved2;
6341 + __be16 lvb_reserved2;
6344 /* ocfs2_inode_lock_full() 'arg_flags' flags */
6345 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/file.c
6346 --- linux-2.6.27.25/fs/ocfs2/file.c 2009-06-15 17:18:32.000000000 +0200
6347 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/file.c 2009-05-22 00:47:30.000000000 +0200
6348 @@ -1058,13 +1058,15 @@ int ocfs2_setattr(struct dentry *dentry,
6349 mlog(0, "uid change: %d\n", attr->ia_uid);
6350 if (attr->ia_valid & ATTR_GID)
6351 mlog(0, "gid change: %d\n", attr->ia_gid);
6352 + if (attr->ia_valid & ATTR_TAG)
6353 + mlog(0, "tag change: %d\n", attr->ia_tag);
6354 if (attr->ia_valid & ATTR_SIZE)
6355 mlog(0, "size change...\n");
6356 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6357 mlog(0, "time change...\n");
6359 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6360 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6361 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6362 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6363 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6365 @@ -2285,6 +2287,7 @@ const struct inode_operations ocfs2_file
6366 .setattr = ocfs2_setattr,
6367 .getattr = ocfs2_getattr,
6368 .permission = ocfs2_permission,
6369 + .sync_flags = ocfs2_sync_flags,
6370 .fallocate = ocfs2_fallocate,
6373 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/inode.c
6374 --- linux-2.6.27.25/fs/ocfs2/inode.c 2008-07-13 23:51:29.000000000 +0200
6375 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/inode.c 2008-10-13 14:54:20.000000000 +0200
6377 #include <linux/slab.h>
6378 #include <linux/highmem.h>
6379 #include <linux/pagemap.h>
6380 +#include <linux/vs_tag.h>
6382 #include <asm/byteorder.h>
6386 #include "heartbeat.h"
6389 #include "journal.h"
6391 #include "suballoc.h"
6392 @@ -74,11 +76,13 @@ void ocfs2_set_inode_flags(struct inode
6394 unsigned int flags = OCFS2_I(inode)->ip_attr;
6396 - inode->i_flags &= ~(S_IMMUTABLE |
6397 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6398 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6400 if (flags & OCFS2_IMMUTABLE_FL)
6401 inode->i_flags |= S_IMMUTABLE;
6402 + if (flags & OCFS2_IXUNLINK_FL)
6403 + inode->i_flags |= S_IXUNLINK;
6405 if (flags & OCFS2_SYNC_FL)
6406 inode->i_flags |= S_SYNC;
6407 @@ -88,25 +92,85 @@ void ocfs2_set_inode_flags(struct inode
6408 inode->i_flags |= S_NOATIME;
6409 if (flags & OCFS2_DIRSYNC_FL)
6410 inode->i_flags |= S_DIRSYNC;
6412 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6414 + if (flags & OCFS2_BARRIER_FL)
6415 + inode->i_vflags |= V_BARRIER;
6416 + if (flags & OCFS2_COW_FL)
6417 + inode->i_vflags |= V_COW;
6420 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6421 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6423 unsigned int flags = oi->vfs_inode.i_flags;
6424 + unsigned int vflags = oi->vfs_inode.i_vflags;
6426 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6427 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6428 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6429 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6431 + if (flags & S_IMMUTABLE)
6432 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6433 + if (flags & S_IXUNLINK)
6434 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6436 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6437 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6439 oi->ip_attr |= OCFS2_SYNC_FL;
6440 if (flags & S_APPEND)
6441 oi->ip_attr |= OCFS2_APPEND_FL;
6442 - if (flags & S_IMMUTABLE)
6443 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6444 if (flags & S_NOATIME)
6445 oi->ip_attr |= OCFS2_NOATIME_FL;
6446 if (flags & S_DIRSYNC)
6447 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6449 + if (vflags & V_BARRIER)
6450 + oi->ip_attr |= OCFS2_BARRIER_FL;
6451 + if (vflags & V_COW)
6452 + oi->ip_attr |= OCFS2_COW_FL;
6455 +int ocfs2_sync_flags(struct inode *inode)
6457 + struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6458 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6459 + handle_t *handle = NULL;
6460 + struct buffer_head *bh = NULL;
6463 + status = ocfs2_inode_lock(inode, &bh, 1);
6465 + mlog_errno(status);
6470 + if (IS_RDONLY(inode))
6473 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6474 + if (IS_ERR(handle)) {
6475 + status = PTR_ERR(handle);
6476 + mlog_errno(status);
6480 + ocfs2_get_inode_flags(ocfs2_inode);
6481 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6483 + mlog_errno(status);
6485 + ocfs2_commit_trans(osb, handle);
6487 + ocfs2_inode_unlock(inode, 1);
6492 + mlog_exit(status);
6496 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
6497 @@ -219,6 +283,8 @@ int ocfs2_populate_inode(struct inode *i
6498 struct super_block *sb;
6499 struct ocfs2_super *osb;
6500 int status = -EINVAL;
6504 mlog_entry("(0x%p, size:%llu)\n", inode,
6505 (unsigned long long)le64_to_cpu(fe->i_size));
6506 @@ -254,8 +320,12 @@ int ocfs2_populate_inode(struct inode *i
6507 inode->i_generation = le32_to_cpu(fe->i_generation);
6508 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6509 inode->i_mode = le16_to_cpu(fe->i_mode);
6510 - inode->i_uid = le32_to_cpu(fe->i_uid);
6511 - inode->i_gid = le32_to_cpu(fe->i_gid);
6512 + uid = le32_to_cpu(fe->i_uid);
6513 + gid = le32_to_cpu(fe->i_gid);
6514 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6515 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6516 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6517 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6519 /* Fast symlinks will have i_size but no allocated clusters. */
6520 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6521 @@ -1230,8 +1300,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
6523 fe->i_size = cpu_to_le64(i_size_read(inode));
6524 fe->i_links_count = cpu_to_le16(inode->i_nlink);
6525 - fe->i_uid = cpu_to_le32(inode->i_uid);
6526 - fe->i_gid = cpu_to_le32(inode->i_gid);
6527 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
6528 + inode->i_uid, inode->i_tag));
6529 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
6530 + inode->i_gid, inode->i_tag));
6531 + /* i_tag = = cpu_to_le16(inode->i_tag); */
6532 fe->i_mode = cpu_to_le16(inode->i_mode);
6533 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
6534 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
6535 @@ -1259,16 +1332,25 @@ leave:
6536 void ocfs2_refresh_inode(struct inode *inode,
6537 struct ocfs2_dinode *fe)
6542 spin_lock(&OCFS2_I(inode)->ip_lock);
6544 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
6545 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
6546 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
6547 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
6548 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
6549 ocfs2_set_inode_flags(inode);
6550 i_size_write(inode, le64_to_cpu(fe->i_size));
6551 inode->i_nlink = le16_to_cpu(fe->i_links_count);
6552 - inode->i_uid = le32_to_cpu(fe->i_uid);
6553 - inode->i_gid = le32_to_cpu(fe->i_gid);
6554 + uid = le32_to_cpu(fe->i_uid);
6555 + gid = le32_to_cpu(fe->i_gid);
6556 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6557 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6558 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6559 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6560 inode->i_mode = le16_to_cpu(fe->i_mode);
6561 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
6562 inode->i_blocks = 0;
6563 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/inode.h linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/inode.h
6564 --- linux-2.6.27.25/fs/ocfs2/inode.h 2008-07-13 23:51:29.000000000 +0200
6565 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/inode.h 2008-10-13 14:54:20.000000000 +0200
6566 @@ -143,6 +143,7 @@ int ocfs2_aio_write(struct file *file, s
6568 void ocfs2_set_inode_flags(struct inode *inode);
6569 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6570 +int ocfs2_sync_flags(struct inode *inode);
6572 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6574 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ioctl.c
6575 --- linux-2.6.27.25/fs/ocfs2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
6576 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ioctl.c 2008-10-13 14:54:20.000000000 +0200
6577 @@ -42,7 +42,7 @@ static int ocfs2_get_inode_attr(struct i
6581 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6582 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6585 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6586 @@ -67,6 +67,11 @@ static int ocfs2_set_inode_attr(struct i
6587 if (!S_ISDIR(inode->i_mode))
6588 flags &= ~OCFS2_DIRSYNC_FL;
6590 + if (IS_BARRIER(inode)) {
6591 + vxwprintk_task(1, "messing with the barrier.");
6595 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6596 if (IS_ERR(handle)) {
6597 status = PTR_ERR(handle);
6598 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/ioctl.h linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ioctl.h
6599 --- linux-2.6.27.25/fs/ocfs2/ioctl.h 2008-07-13 23:51:29.000000000 +0200
6600 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ioctl.h 2008-10-13 14:54:20.000000000 +0200
6602 #ifndef OCFS2_IOCTL_H
6603 #define OCFS2_IOCTL_H
6605 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6608 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
6609 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
6611 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/namei.c
6612 --- linux-2.6.27.25/fs/ocfs2/namei.c 2008-07-13 23:51:29.000000000 +0200
6613 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/namei.c 2008-10-13 14:54:20.000000000 +0200
6615 #include <linux/types.h>
6616 #include <linux/slab.h>
6617 #include <linux/highmem.h>
6618 +#include <linux/vs_tag.h>
6620 #define MLOG_MASK_PREFIX ML_NAMEI
6621 #include <cluster/masklog.h>
6622 @@ -366,6 +367,9 @@ static int ocfs2_mknod_locked(struct ocf
6625 struct inode *inode = NULL;
6630 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
6631 (unsigned long)dev, dentry->d_name.len,
6632 @@ -425,13 +429,19 @@ static int ocfs2_mknod_locked(struct ocf
6633 fe->i_blkno = cpu_to_le64(fe_blkno);
6634 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6635 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6636 - fe->i_uid = cpu_to_le32(current->fsuid);
6638 + tag = dx_current_fstag(osb->sb);
6639 + uid = current->fsuid;
6640 if (dir->i_mode & S_ISGID) {
6641 - fe->i_gid = cpu_to_le32(dir->i_gid);
6646 - fe->i_gid = cpu_to_le32(current->fsgid);
6647 + gid = current->fsgid;
6649 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
6650 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
6651 + inode->i_tag = tag;
6652 fe->i_mode = cpu_to_le16(mode);
6653 if (S_ISCHR(mode) || S_ISBLK(mode))
6654 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6655 @@ -1917,5 +1927,6 @@ const struct inode_operations ocfs2_dir_
6656 .rename = ocfs2_rename,
6657 .setattr = ocfs2_setattr,
6658 .getattr = ocfs2_getattr,
6659 + .sync_flags = ocfs2_sync_flags,
6660 .permission = ocfs2_permission,
6662 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/ocfs2_fs.h linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ocfs2_fs.h
6663 --- linux-2.6.27.25/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:52:06.000000000 +0200
6664 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:54:20.000000000 +0200
6665 @@ -195,18 +195,23 @@
6666 #define OCFS2_INDEXED_DIR_FL (0x0008)
6668 /* Inode attributes, keep in sync with EXT2 */
6669 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6670 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6671 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6672 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6673 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6674 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6675 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6676 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6677 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6678 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6679 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6680 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6681 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6682 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6683 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6684 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6685 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6687 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6688 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6689 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6690 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6692 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6693 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6695 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6696 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6699 * Extent record flags (e_node.leaf.flags)
6700 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/ocfs2.h linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ocfs2.h
6701 --- linux-2.6.27.25/fs/ocfs2/ocfs2.h 2008-10-13 14:52:06.000000000 +0200
6702 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/ocfs2.h 2008-10-13 14:54:20.000000000 +0200
6703 @@ -184,6 +184,7 @@ enum ocfs2_mount_options
6704 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
6705 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
6706 OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
6707 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
6710 #define OCFS2_OSB_SOFT_RO 0x0001
6711 diff -NurpP --minimal linux-2.6.27.25/fs/ocfs2/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/super.c
6712 --- linux-2.6.27.25/fs/ocfs2/super.c 2008-10-13 14:52:06.000000000 +0200
6713 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/ocfs2/super.c 2008-10-13 14:54:20.000000000 +0200
6714 @@ -154,6 +154,7 @@ enum {
6718 + Opt_tag, Opt_notag, Opt_tagid,
6722 @@ -173,6 +174,9 @@ static match_table_t tokens = {
6723 {Opt_localalloc, "localalloc=%d"},
6724 {Opt_localflocks, "localflocks"},
6725 {Opt_stack, "cluster_stack=%s"},
6727 + {Opt_notag, "notag"},
6728 + {Opt_tagid, "tagid=%u"},
6732 @@ -392,6 +396,13 @@ static int ocfs2_remount(struct super_bl
6736 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
6737 + !(sb->s_flags & MS_TAGGED)) {
6739 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6743 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6744 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6746 @@ -725,6 +736,9 @@ static int ocfs2_fill_super(struct super
6748 ocfs2_complete_mount_recovery(osb);
6750 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6751 + sb->s_flags |= MS_TAGGED;
6753 if (ocfs2_mount_local(osb))
6754 snprintf(nodestr, sizeof(nodestr), "local");
6756 @@ -918,6 +932,20 @@ static int ocfs2_parse_options(struct su
6757 OCFS2_STACK_LABEL_LEN);
6758 mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
6760 +#ifndef CONFIG_TAGGING_NONE
6762 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6765 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6768 +#ifdef CONFIG_PROPAGATE
6771 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6776 "Unrecognized mount option \"%s\" "
6777 diff -NurpP --minimal linux-2.6.27.25/fs/open.c linux-2.6.27.25-vs2.3.0.36.6/fs/open.c
6778 --- linux-2.6.27.25/fs/open.c 2009-06-15 17:18:32.000000000 +0200
6779 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/open.c 2009-02-03 17:59:04.000000000 +0100
6781 #include <linux/rcupdate.h>
6782 #include <linux/audit.h>
6783 #include <linux/falloc.h>
6784 +#include <linux/vs_base.h>
6785 +#include <linux/vs_limit.h>
6786 +#include <linux/vs_dlimit.h>
6787 +#include <linux/vs_tag.h>
6788 +#include <linux/vs_cowbl.h>
6790 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6792 int retval = -ENODEV;
6795 + struct super_block *sb = dentry->d_sb;
6798 - if (dentry->d_sb->s_op->statfs) {
6799 + if (sb->s_op->statfs) {
6800 memset(buf, 0, sizeof(*buf));
6801 retval = security_sb_statfs(dentry);
6804 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6805 + retval = sb->s_op->statfs(dentry, buf);
6806 if (retval == 0 && buf->f_frsize == 0)
6807 buf->f_frsize = buf->f_bsize;
6809 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6810 + vx_vsi_statfs(sb, buf);
6814 @@ -643,6 +652,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6815 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6819 + error = cow_check_and_break(&path);
6821 + goto dput_and_out;
6822 inode = path.dentry->d_inode;
6824 error = mnt_want_write(path.mnt);
6825 @@ -676,11 +689,11 @@ static int chown_common(struct dentry *
6826 newattrs.ia_valid = ATTR_CTIME;
6827 if (user != (uid_t) -1) {
6828 newattrs.ia_valid |= ATTR_UID;
6829 - newattrs.ia_uid = user;
6830 + newattrs.ia_uid = dx_map_uid(user);
6832 if (group != (gid_t) -1) {
6833 newattrs.ia_valid |= ATTR_GID;
6834 - newattrs.ia_gid = group;
6835 + newattrs.ia_gid = dx_map_gid(group);
6837 if (!S_ISDIR(inode->i_mode))
6838 newattrs.ia_valid |=
6839 @@ -703,7 +716,11 @@ SYSCALL_DEFINE3(chown, const char __user
6840 error = mnt_want_write(path.mnt);
6843 - error = chown_common(path.dentry, user, group);
6844 +#ifdef CONFIG_VSERVER_COWBL
6845 + error = cow_check_and_break(&path);
6848 + error = chown_common(path.dentry, user, group);
6849 mnt_drop_write(path.mnt);
6852 @@ -728,7 +745,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6853 error = mnt_want_write(path.mnt);
6856 - error = chown_common(path.dentry, user, group);
6857 +#ifdef CONFIG_VSERVER_COWBL
6858 + error = cow_check_and_break(&path);
6861 + error = chown_common(path.dentry, user, group);
6862 mnt_drop_write(path.mnt);
6865 @@ -747,7 +768,11 @@ SYSCALL_DEFINE3(lchown, const char __use
6866 error = mnt_want_write(path.mnt);
6869 - error = chown_common(path.dentry, user, group);
6870 +#ifdef CONFIG_VSERVER_COWBL
6871 + error = cow_check_and_break(&path);
6874 + error = chown_common(path.dentry, user, group);
6875 mnt_drop_write(path.mnt);
6878 @@ -986,6 +1011,7 @@ static void __put_unused_fd(struct files
6879 __FD_CLR(fd, fdt->open_fds);
6880 if (fd < files->next_fd)
6881 files->next_fd = fd;
6882 + vx_openfd_dec(fd);
6885 void put_unused_fd(unsigned int fd)
6886 diff -NurpP --minimal linux-2.6.27.25/fs/proc/array.c linux-2.6.27.25-vs2.3.0.36.6/fs/proc/array.c
6887 --- linux-2.6.27.25/fs/proc/array.c 2009-06-15 17:18:32.000000000 +0200
6888 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/array.c 2009-05-20 02:14:39.000000000 +0200
6890 #include <linux/pid_namespace.h>
6891 #include <linux/ptrace.h>
6892 #include <linux/tracehook.h>
6893 +#include <linux/vs_context.h>
6894 +#include <linux/vs_network.h>
6896 #include <asm/pgtable.h>
6897 #include <asm/processor.h>
6898 @@ -143,8 +145,9 @@ static const char *task_state_array[] =
6899 "D (disk sleep)", /* 2 */
6900 "T (stopped)", /* 4 */
6901 "T (tracing stop)", /* 8 */
6902 - "Z (zombie)", /* 16 */
6903 - "X (dead)" /* 32 */
6904 + "H (on hold)", /* 16 */
6905 + "Z (zombie)", /* 32 */
6906 + "X (dead)", /* 64 */
6909 static inline const char *get_task_state(struct task_struct *tsk)
6910 @@ -170,6 +173,9 @@ static inline void task_state(struct seq
6912 ppid = pid_alive(p) ?
6913 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6914 + if (unlikely(vx_current_initpid(p->pid)))
6919 struct task_struct *tracer = tracehook_tracer_task(p);
6920 @@ -287,7 +293,7 @@ static inline void task_sig(struct seq_f
6923 static void render_cap_t(struct seq_file *m, const char *header,
6925 + struct vx_info *vxi, kernel_cap_t *a)
6929 @@ -301,10 +307,10 @@ static void render_cap_t(struct seq_file
6931 static inline void task_cap(struct seq_file *m, struct task_struct *p)
6933 - render_cap_t(m, "CapInh:\t", &p->cap_inheritable);
6934 - render_cap_t(m, "CapPrm:\t", &p->cap_permitted);
6935 - render_cap_t(m, "CapEff:\t", &p->cap_effective);
6936 - render_cap_t(m, "CapBnd:\t", &p->cap_bset);
6937 + render_cap_t(m, "CapInh:\t", p->vx_info, &p->cap_inheritable);
6938 + render_cap_t(m, "CapPrm:\t", p->vx_info, &p->cap_permitted);
6939 + render_cap_t(m, "CapEff:\t", p->vx_info, &p->cap_effective);
6940 + render_cap_t(m, "CapBnd:\t", p->vx_info, &p->cap_bset);
6943 static inline void task_context_switch_counts(struct seq_file *m,
6944 @@ -316,6 +322,45 @@ static inline void task_context_switch_c
6948 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6949 + struct pid *pid, struct task_struct *task)
6951 + seq_printf(m, "Proxy:\t%p(%c)\n"
6960 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6961 + atomic_read(&task->nsproxy->count),
6962 + task->nsproxy->uts_ns,
6963 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6964 + task->nsproxy->ipc_ns,
6965 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6966 + task->nsproxy->mnt_ns,
6967 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6968 + task->nsproxy->pid_ns,
6969 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6970 + task->nsproxy->user_ns,
6971 + (task->nsproxy->user_ns == init_task.nsproxy->user_ns ? 'I' : '-'),
6972 + task->nsproxy->net_ns,
6973 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6977 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6979 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6982 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6983 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6987 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6988 struct pid *pid, struct task_struct *task)
6990 @@ -331,6 +376,7 @@ int proc_pid_status(struct seq_file *m,
6993 cpuset_task_status_allowed(m, task);
6994 + task_vs_id(m, task);
6995 #if defined(CONFIG_S390)
6996 task_show_regs(m, task);
6998 @@ -447,6 +493,17 @@ static int do_task_stat(struct seq_file
6999 /* convert nsec -> ticks */
7000 start_time = nsec_to_clock_t(start_time);
7002 + /* fixup start time for virt uptime */
7003 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
7004 + unsigned long long bias =
7005 + current->vx_info->cvirt.bias_clock;
7007 + if (start_time > bias)
7008 + start_time -= bias;
7013 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
7014 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
7015 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
7016 diff -NurpP --minimal linux-2.6.27.25/fs/proc/base.c linux-2.6.27.25-vs2.3.0.36.6/fs/proc/base.c
7017 --- linux-2.6.27.25/fs/proc/base.c 2009-06-15 17:18:32.000000000 +0200
7018 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/base.c 2009-05-15 22:57:04.000000000 +0200
7020 #include <linux/oom.h>
7021 #include <linux/elf.h>
7022 #include <linux/pid_namespace.h>
7023 +#include <linux/vs_context.h>
7024 +#include <linux/vs_network.h>
7025 #include "internal.h"
7028 @@ -1424,6 +1426,8 @@ static struct inode *proc_pid_make_inode
7029 inode->i_uid = task->euid;
7030 inode->i_gid = task->egid;
7032 + /* procfs is xid tagged */
7033 + inode->i_tag = (tag_t)vx_task_xid(task);
7034 security_task_to_inode(task, inode);
7037 @@ -1964,6 +1968,13 @@ static struct dentry *proc_pident_lookup
7041 + /* TODO: maybe we can come up with a generic approach? */
7042 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
7043 + (dentry->d_name.len == 5) &&
7044 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
7045 + !memcmp(dentry->d_name.name, "ninfo", 5)))
7049 * Yes, it does not scale. And it should not. Don't add
7050 * new entries into /proc/<tgid>/ without very good reasons.
7051 @@ -2351,7 +2362,7 @@ out_iput:
7052 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
7054 struct dentry *error;
7055 - struct task_struct *task = get_proc_task(dir);
7056 + struct task_struct *task = get_proc_task_real(dir);
7057 const struct pid_entry *p, *last;
7059 error = ERR_PTR(-ENOENT);
7060 @@ -2434,6 +2445,9 @@ static int proc_tgid_io_accounting(struc
7061 static const struct file_operations proc_task_operations;
7062 static const struct inode_operations proc_task_inode_operations;
7064 +extern int proc_pid_vx_info(struct task_struct *, char *);
7065 +extern int proc_pid_nx_info(struct task_struct *, char *);
7067 static const struct pid_entry tgid_base_stuff[] = {
7068 DIR("task", S_IRUGO|S_IXUGO, task),
7069 DIR("fd", S_IRUSR|S_IXUSR, fd),
7070 @@ -2488,6 +2502,8 @@ static const struct pid_entry tgid_base_
7071 #ifdef CONFIG_CGROUPS
7072 REG("cgroup", S_IRUGO, cgroup),
7074 + INF("vinfo", S_IRUGO, pid_vx_info),
7075 + INF("ninfo", S_IRUGO, pid_nx_info),
7076 INF("oom_score", S_IRUGO, oom_score),
7077 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
7078 #ifdef CONFIG_AUDITSYSCALL
7079 @@ -2503,6 +2519,7 @@ static const struct pid_entry tgid_base_
7080 #ifdef CONFIG_TASK_IO_ACCOUNTING
7081 INF("io", S_IRUGO, tgid_io_accounting),
7083 + ONE("nsproxy", S_IRUGO, pid_nsproxy),
7086 static int proc_tgid_base_readdir(struct file * filp,
7087 @@ -2699,7 +2716,7 @@ retry:
7089 pid = find_ge_pid(iter.tgid, ns);
7091 - iter.tgid = pid_nr_ns(pid, ns);
7092 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
7093 iter.task = pid_task(pid, PIDTYPE_PID);
7094 /* What we to know is if the pid we have find is the
7095 * pid of a thread_group_leader. Testing for task
7096 @@ -2729,7 +2746,7 @@ static int proc_pid_fill_cache(struct fi
7097 struct tgid_iter iter)
7099 char name[PROC_NUMBUF];
7100 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7101 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7102 return proc_fill_cache(filp, dirent, filldir, name, len,
7103 proc_pid_instantiate, iter.task, NULL);
7105 @@ -2738,7 +2755,7 @@ static int proc_pid_fill_cache(struct fi
7106 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7108 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7109 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7110 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7111 struct tgid_iter iter;
7112 struct pid_namespace *ns;
7114 @@ -2758,6 +2775,8 @@ int proc_pid_readdir(struct file * filp,
7116 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7117 filp->f_pos = iter.tgid + TGID_OFFSET;
7118 + if (!vx_proc_task_visible(iter.task))
7120 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7121 put_task_struct(iter.task);
7123 @@ -2900,6 +2919,8 @@ static struct dentry *proc_task_lookup(s
7124 tid = name_to_int(dentry);
7127 + if (vx_current_initpid(tid))
7130 ns = dentry->d_sb->s_fs_info;
7132 diff -NurpP --minimal linux-2.6.27.25/fs/proc/generic.c linux-2.6.27.25-vs2.3.0.36.6/fs/proc/generic.c
7133 --- linux-2.6.27.25/fs/proc/generic.c 2008-10-13 14:52:06.000000000 +0200
7134 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/generic.c 2008-10-13 14:54:20.000000000 +0200
7136 #include <linux/bitops.h>
7137 #include <linux/spinlock.h>
7138 #include <linux/completion.h>
7139 +#include <linux/vserver/inode.h>
7140 #include <asm/uaccess.h>
7142 #include "internal.h"
7143 @@ -384,6 +385,8 @@ struct dentry *proc_lookup_de(struct pro
7144 for (de = de->subdir; de ; de = de->next) {
7145 if (de->namelen != dentry->d_name.len)
7147 + if (!vx_hide_check(0, de->vx_flags))
7149 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7152 @@ -392,6 +395,8 @@ struct dentry *proc_lookup_de(struct pro
7153 spin_unlock(&proc_subdir_lock);
7155 inode = proc_get_inode(dir->i_sb, ino, de);
7156 + /* generic proc entries belong to the host */
7161 @@ -472,6 +477,8 @@ int proc_readdir_de(struct proc_dir_entr
7163 /* filldir passes info to user space */
7165 + if (!vx_hide_check(0, de->vx_flags))
7167 spin_unlock(&proc_subdir_lock);
7168 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7169 de->low_ino, de->mode >> 12) < 0) {
7170 @@ -479,6 +486,7 @@ int proc_readdir_de(struct proc_dir_entr
7173 spin_lock(&proc_subdir_lock);
7178 @@ -593,6 +601,7 @@ static struct proc_dir_entry *__proc_cre
7180 atomic_set(&ent->count, 1);
7182 + ent->vx_flags = IATTR_PROC_DEFAULT;
7183 spin_lock_init(&ent->pde_unload_lock);
7184 ent->pde_unload_completion = NULL;
7185 INIT_LIST_HEAD(&ent->pde_openers);
7186 @@ -616,7 +625,8 @@ struct proc_dir_entry *proc_symlink(cons
7192 + ent->vx_flags = IATTR_PROC_SYMLINK;
7196 diff -NurpP --minimal linux-2.6.27.25/fs/proc/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/proc/inode.c
7197 --- linux-2.6.27.25/fs/proc/inode.c 2008-10-13 14:52:06.000000000 +0200
7198 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/inode.c 2008-10-13 14:54:20.000000000 +0200
7199 @@ -469,6 +469,8 @@ struct inode *proc_get_inode(struct supe
7200 inode->i_uid = de->uid;
7201 inode->i_gid = de->gid;
7204 + PROC_I(inode)->vx_flags = de->vx_flags;
7206 inode->i_size = de->size;
7208 diff -NurpP --minimal linux-2.6.27.25/fs/proc/internal.h linux-2.6.27.25-vs2.3.0.36.6/fs/proc/internal.h
7209 --- linux-2.6.27.25/fs/proc/internal.h 2008-10-13 14:52:06.000000000 +0200
7210 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/internal.h 2008-10-13 14:54:20.000000000 +0200
7214 #include <linux/proc_fs.h>
7215 +#include <linux/vs_pid.h>
7217 extern struct proc_dir_entry proc_root;
7218 #ifdef CONFIG_PROC_SYSCTL
7219 @@ -55,6 +56,9 @@ extern int proc_pid_status(struct seq_fi
7220 struct pid *pid, struct task_struct *task);
7221 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7222 struct pid *pid, struct task_struct *task);
7223 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7224 + struct pid *pid, struct task_struct *task);
7226 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7228 extern const struct file_operations proc_maps_operations;
7229 @@ -75,11 +79,16 @@ static inline struct pid *proc_pid(struc
7230 return PROC_I(inode)->pid;
7233 -static inline struct task_struct *get_proc_task(struct inode *inode)
7234 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7236 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7239 +static inline struct task_struct *get_proc_task(struct inode *inode)
7241 + return vx_get_proc_task(inode, proc_pid(inode));
7244 static inline int proc_fd(struct inode *inode)
7246 return PROC_I(inode)->fd;
7247 diff -NurpP --minimal linux-2.6.27.25/fs/proc/proc_misc.c linux-2.6.27.25-vs2.3.0.36.6/fs/proc/proc_misc.c
7248 --- linux-2.6.27.25/fs/proc/proc_misc.c 2009-06-15 17:18:32.000000000 +0200
7249 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/proc_misc.c 2009-03-25 14:32:29.000000000 +0100
7251 #include <asm/div64.h>
7252 #include "internal.h"
7254 +#include <linux/vs_cvirt.h>
7256 #define LOAD_INT(x) ((x) >> FSHIFT)
7257 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
7259 @@ -84,22 +86,38 @@ static int proc_calc_metrics(char *page,
7260 static int loadavg_read_proc(char *page, char **start, off_t off,
7261 int count, int *eof, void *data)
7263 + unsigned long running;
7264 + unsigned int threads;
7270 seq = read_seqbegin(&xtime_lock);
7271 - a = avenrun[0] + (FIXED_1/200);
7272 - b = avenrun[1] + (FIXED_1/200);
7273 - c = avenrun[2] + (FIXED_1/200);
7274 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7275 + struct vx_info *vxi = current->vx_info;
7277 + a = vxi->cvirt.load[0] + (FIXED_1/200);
7278 + b = vxi->cvirt.load[1] + (FIXED_1/200);
7279 + c = vxi->cvirt.load[2] + (FIXED_1/200);
7281 + running = atomic_read(&vxi->cvirt.nr_running);
7282 + threads = atomic_read(&vxi->cvirt.nr_threads);
7284 + a = avenrun[0] + (FIXED_1/200);
7285 + b = avenrun[1] + (FIXED_1/200);
7286 + c = avenrun[2] + (FIXED_1/200);
7288 + running = nr_running();
7289 + threads = nr_threads;
7291 } while (read_seqretry(&xtime_lock, seq));
7293 len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
7294 LOAD_INT(a), LOAD_FRAC(a),
7295 LOAD_INT(b), LOAD_FRAC(b),
7296 LOAD_INT(c), LOAD_FRAC(c),
7297 - nr_running(), nr_threads,
7299 task_active_pid_ns(current)->last_pid);
7300 return proc_calc_metrics(page, start, off, count, eof, len);
7302 @@ -115,6 +133,9 @@ static int uptime_read_proc(char *page,
7303 do_posix_clock_monotonic_gettime(&uptime);
7304 monotonic_to_bootbased(&uptime);
7305 cputime_to_timespec(idletime, &idle);
7306 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7307 + vx_vsi_uptime(&uptime, &idle);
7309 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
7310 (unsigned long) uptime.tv_sec,
7311 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7312 @@ -151,7 +172,7 @@ static int meminfo_read_proc(char *page,
7314 cached = global_page_state(NR_FILE_PAGES) -
7315 total_swapcache_pages - i.bufferram;
7317 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
7320 get_vmalloc_info(&vmi);
7321 diff -NurpP --minimal linux-2.6.27.25/fs/proc/root.c linux-2.6.27.25-vs2.3.0.36.6/fs/proc/root.c
7322 --- linux-2.6.27.25/fs/proc/root.c 2008-07-13 23:51:29.000000000 +0200
7323 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/proc/root.c 2008-11-20 00:58:27.000000000 +0100
7325 #include <linux/smp_lock.h>
7326 #include <linux/mount.h>
7327 #include <linux/pid_namespace.h>
7328 +#include <linux/vserver/inode.h>
7330 #include "internal.h"
7332 +struct proc_dir_entry *proc_virtual;
7334 +extern void proc_vx_init(void);
7336 static int proc_test_super(struct super_block *sb, void *data)
7338 return sb->s_fs_info == data;
7339 @@ -137,6 +142,7 @@ void __init proc_root_init(void)
7341 proc_mkdir("bus", NULL);
7346 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7347 @@ -209,6 +215,7 @@ struct proc_dir_entry proc_root = {
7348 .proc_iops = &proc_root_inode_operations,
7349 .proc_fops = &proc_root_operations,
7350 .parent = &proc_root,
7351 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7354 int pid_ns_prepare_proc(struct pid_namespace *ns)
7355 diff -NurpP --minimal linux-2.6.27.25/fs/quota.c linux-2.6.27.25-vs2.3.0.36.6/fs/quota.c
7356 --- linux-2.6.27.25/fs/quota.c 2009-06-15 17:18:32.000000000 +0200
7357 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/quota.c 2009-02-03 17:59:04.000000000 +0100
7359 #include <linux/capability.h>
7360 #include <linux/quotaops.h>
7361 #include <linux/types.h>
7362 +#include <linux/vs_context.h>
7364 /* Check validity of generic quotactl commands */
7365 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
7366 @@ -81,11 +82,11 @@ static int generic_quotactl_valid(struct
7367 if (cmd == Q_GETQUOTA) {
7368 if (((type == USRQUOTA && current->euid != id) ||
7369 (type == GRPQUOTA && !in_egroup_p(id))) &&
7370 - !capable(CAP_SYS_ADMIN))
7371 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7374 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7375 - if (!capable(CAP_SYS_ADMIN))
7376 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7380 @@ -132,10 +133,10 @@ static int xqm_quotactl_valid(struct sup
7381 if (cmd == Q_XGETQUOTA) {
7382 if (((type == XQM_USRQUOTA && current->euid != id) ||
7383 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7384 - !capable(CAP_SYS_ADMIN))
7385 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7387 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7388 - if (!capable(CAP_SYS_ADMIN))
7389 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7393 @@ -334,6 +335,46 @@ static int do_quotactl(struct super_bloc
7397 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7399 +#include <linux/vroot.h>
7400 +#include <linux/major.h>
7401 +#include <linux/module.h>
7402 +#include <linux/kallsyms.h>
7403 +#include <linux/vserver/debug.h>
7405 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7407 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7409 +int register_vroot_grb(vroot_grb_func *func) {
7412 + spin_lock(&vroot_grb_lock);
7413 + if (!vroot_get_real_bdev) {
7414 + vroot_get_real_bdev = func;
7417 + spin_unlock(&vroot_grb_lock);
7420 +EXPORT_SYMBOL(register_vroot_grb);
7422 +int unregister_vroot_grb(vroot_grb_func *func) {
7423 + int ret = -EINVAL;
7425 + spin_lock(&vroot_grb_lock);
7426 + if (vroot_get_real_bdev) {
7427 + vroot_get_real_bdev = NULL;
7430 + spin_unlock(&vroot_grb_lock);
7433 +EXPORT_SYMBOL(unregister_vroot_grb);
7438 * look up a superblock on which quota ops will be performed
7439 * - use the name of a block device to find the superblock thereon
7440 @@ -351,6 +392,22 @@ static inline struct super_block *quotac
7443 return ERR_CAST(bdev);
7444 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7445 + if (bdev && bdev->bd_inode &&
7446 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7447 + struct block_device *bdnew = (void *)-EINVAL;
7449 + if (vroot_get_real_bdev)
7450 + bdnew = vroot_get_real_bdev(bdev);
7452 + vxdprintk(VXD_CBIT(misc, 0),
7453 + "vroot_get_real_bdev not set");
7455 + if (IS_ERR(bdnew))
7456 + return ERR_PTR(PTR_ERR(bdnew));
7460 sb = get_super(bdev);
7463 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/bitmap.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/bitmap.c
7464 --- linux-2.6.27.25/fs/reiserfs/bitmap.c 2008-07-13 23:51:29.000000000 +0200
7465 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/bitmap.c 2008-10-13 14:54:20.000000000 +0200
7467 #include <linux/reiserfs_fs_sb.h>
7468 #include <linux/reiserfs_fs_i.h>
7469 #include <linux/quotaops.h>
7470 +#include <linux/vs_dlimit.h>
7472 #define PREALLOCATION_SIZE 9
7474 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
7475 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
7477 journal_mark_dirty(th, s, sbh);
7478 - if (for_unformatted)
7479 + if (for_unformatted) {
7480 + DLIMIT_FREE_BLOCK(inode, 1);
7481 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
7485 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
7486 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
7487 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
7489 int nr_allocated = 0;
7492 determine_prealloc_size(hint);
7493 if (!hint->formatted_node) {
7494 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
7495 "reiserquota: allocating %d blocks id=%u",
7496 amount_needed, hint->inode->i_uid);
7499 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
7500 - if (quota_ret) /* Quota exceeded? */
7501 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
7504 return QUOTA_EXCEEDED;
7505 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
7506 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7508 + return NO_DISK_SPACE;
7511 if (hint->preallocate && hint->prealloc_size) {
7512 #ifdef REISERQUOTA_DEBUG
7513 reiserfs_debug(s, REISERFS_DEBUG_CODE,
7514 "reiserquota: allocating (prealloc) %d blocks id=%u",
7515 hint->prealloc_size, hint->inode->i_uid);
7518 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7519 - hint->prealloc_size);
7520 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7521 + hint->prealloc_size);
7523 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
7524 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7525 + hint->prealloc_size);
7529 hint->preallocate = hint->prealloc_size = 0;
7531 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
7533 hint->inode->i_uid);
7535 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
7536 + /* Free not allocated blocks */
7537 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
7538 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7539 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7541 while (nr_allocated--)
7542 reiserfs_free_block(hint->th, hint->inode,
7543 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
7544 REISERFS_I(hint->inode)->i_prealloc_count,
7545 hint->inode->i_uid);
7547 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
7548 - hint->prealloc_size - nr_allocated -
7549 - REISERFS_I(hint->inode)->
7550 - i_prealloc_count);
7551 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
7552 + REISERFS_I(hint->inode)->i_prealloc_count;
7553 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7554 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7558 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/file.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/file.c
7559 --- linux-2.6.27.25/fs/reiserfs/file.c 2008-07-13 23:51:29.000000000 +0200
7560 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/file.c 2008-10-13 14:54:20.000000000 +0200
7561 @@ -306,4 +306,5 @@ const struct inode_operations reiserfs_f
7562 .listxattr = reiserfs_listxattr,
7563 .removexattr = reiserfs_removexattr,
7564 .permission = reiserfs_permission,
7565 + .sync_flags = reiserfs_sync_flags,
7567 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/inode.c
7568 --- linux-2.6.27.25/fs/reiserfs/inode.c 2009-06-15 17:18:32.000000000 +0200
7569 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/inode.c 2009-02-03 17:59:04.000000000 +0100
7571 #include <linux/writeback.h>
7572 #include <linux/quotaops.h>
7573 #include <linux/swap.h>
7574 +#include <linux/vs_dlimit.h>
7575 +#include <linux/vs_tag.h>
7577 int reiserfs_commit_write(struct file *f, struct page *page,
7578 unsigned from, unsigned to);
7579 @@ -54,6 +56,7 @@ void reiserfs_delete_inode(struct inode
7580 * stat data deletion */
7582 DQUOT_FREE_INODE(inode);
7583 + DLIMIT_FREE_INODE(inode);
7585 if (journal_end(&th, inode->i_sb, jbegin_count))
7587 @@ -1116,6 +1119,8 @@ static void init_inode(struct inode *ino
7588 struct buffer_head *bh;
7589 struct item_head *ih;
7593 //int version = ITEM_VERSION_1;
7595 bh = PATH_PLAST_BUFFER(path);
7596 @@ -1139,12 +1144,13 @@ static void init_inode(struct inode *ino
7597 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7598 unsigned long blocks;
7600 + uid = sd_v1_uid(sd);
7601 + gid = sd_v1_gid(sd);
7603 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7604 set_inode_sd_version(inode, STAT_DATA_V1);
7605 inode->i_mode = sd_v1_mode(sd);
7606 inode->i_nlink = sd_v1_nlink(sd);
7607 - inode->i_uid = sd_v1_uid(sd);
7608 - inode->i_gid = sd_v1_gid(sd);
7609 inode->i_size = sd_v1_size(sd);
7610 inode->i_atime.tv_sec = sd_v1_atime(sd);
7611 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7612 @@ -1186,11 +1192,12 @@ static void init_inode(struct inode *ino
7613 // (directories and symlinks)
7614 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7616 + uid = sd_v2_uid(sd);
7617 + gid = sd_v2_gid(sd);
7619 inode->i_mode = sd_v2_mode(sd);
7620 inode->i_nlink = sd_v2_nlink(sd);
7621 - inode->i_uid = sd_v2_uid(sd);
7622 inode->i_size = sd_v2_size(sd);
7623 - inode->i_gid = sd_v2_gid(sd);
7624 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7625 inode->i_atime.tv_sec = sd_v2_atime(sd);
7626 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7627 @@ -1220,6 +1227,10 @@ static void init_inode(struct inode *ino
7628 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7631 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7632 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7633 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7636 if (S_ISREG(inode->i_mode)) {
7637 inode->i_op = &reiserfs_file_inode_operations;
7638 @@ -1242,13 +1253,15 @@ static void init_inode(struct inode *ino
7639 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7641 struct stat_data *sd_v2 = (struct stat_data *)sd;
7642 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7643 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7646 + set_sd_v2_uid(sd_v2, uid);
7647 + set_sd_v2_gid(sd_v2, gid);
7648 set_sd_v2_mode(sd_v2, inode->i_mode);
7649 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7650 - set_sd_v2_uid(sd_v2, inode->i_uid);
7651 set_sd_v2_size(sd_v2, size);
7652 - set_sd_v2_gid(sd_v2, inode->i_gid);
7653 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7654 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7655 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7656 @@ -1771,6 +1784,10 @@ int reiserfs_new_inode(struct reiserfs_t
7658 BUG_ON(!th->t_trans_id);
7660 + if (DLIMIT_ALLOC_INODE(inode)) {
7662 + goto out_bad_dlimit;
7664 if (DQUOT_ALLOC_INODE(inode)) {
7667 @@ -1956,6 +1973,9 @@ int reiserfs_new_inode(struct reiserfs_t
7668 DQUOT_FREE_INODE(inode);
7671 + DLIMIT_FREE_INODE(inode);
7674 journal_end(th, th->t_super, th->t_blocks_allocated);
7675 /* Drop can be outside and it needs more credits so it's better to have it outside */
7677 @@ -2842,14 +2862,19 @@ int reiserfs_commit_write(struct file *f
7678 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7680 if (reiserfs_attrs(inode->i_sb)) {
7681 - if (sd_attrs & REISERFS_SYNC_FL)
7682 - inode->i_flags |= S_SYNC;
7684 - inode->i_flags &= ~S_SYNC;
7685 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7686 inode->i_flags |= S_IMMUTABLE;
7688 inode->i_flags &= ~S_IMMUTABLE;
7689 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7690 + inode->i_flags |= S_IXUNLINK;
7692 + inode->i_flags &= ~S_IXUNLINK;
7694 + if (sd_attrs & REISERFS_SYNC_FL)
7695 + inode->i_flags |= S_SYNC;
7697 + inode->i_flags &= ~S_SYNC;
7698 if (sd_attrs & REISERFS_APPEND_FL)
7699 inode->i_flags |= S_APPEND;
7701 @@ -2862,6 +2887,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7702 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7704 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7706 + if (sd_attrs & REISERFS_BARRIER_FL)
7707 + inode->i_vflags |= V_BARRIER;
7709 + inode->i_vflags &= ~V_BARRIER;
7710 + if (sd_attrs & REISERFS_COW_FL)
7711 + inode->i_vflags |= V_COW;
7713 + inode->i_vflags &= ~V_COW;
7717 @@ -2872,6 +2906,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7718 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7720 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7721 + if (inode->i_flags & S_IXUNLINK)
7722 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7724 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7726 if (inode->i_flags & S_SYNC)
7727 *sd_attrs |= REISERFS_SYNC_FL;
7729 @@ -2884,6 +2923,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7730 *sd_attrs |= REISERFS_NOTAIL_FL;
7732 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7734 + if (inode->i_vflags & V_BARRIER)
7735 + *sd_attrs |= REISERFS_BARRIER_FL;
7737 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7738 + if (inode->i_vflags & V_COW)
7739 + *sd_attrs |= REISERFS_COW_FL;
7741 + *sd_attrs &= ~REISERFS_COW_FL;
7745 @@ -3051,6 +3099,22 @@ static ssize_t reiserfs_direct_IO(int rw
7746 reiserfs_get_blocks_direct_io, NULL);
7749 +int reiserfs_sync_flags(struct inode *inode)
7751 + u16 oldflags, newflags;
7753 + oldflags = REISERFS_I(inode)->i_attrs;
7754 + newflags = oldflags;
7755 + i_attrs_to_sd_attrs(inode, &newflags);
7757 + if (oldflags ^ newflags) {
7758 + REISERFS_I(inode)->i_attrs = newflags;
7759 + inode->i_ctime = CURRENT_TIME_SEC;
7760 + mark_inode_dirty(inode);
7765 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
7767 struct inode *inode = dentry->d_inode;
7768 @@ -3104,9 +3168,11 @@ int reiserfs_setattr(struct dentry *dent
7771 error = inode_change_ok(inode, attr);
7774 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7775 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7776 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7777 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7778 error = reiserfs_chown_xattrs(inode, attr);
7781 @@ -3136,6 +3202,9 @@ int reiserfs_setattr(struct dentry *dent
7782 inode->i_uid = attr->ia_uid;
7783 if (attr->ia_valid & ATTR_GID)
7784 inode->i_gid = attr->ia_gid;
7785 + if ((attr->ia_valid & ATTR_TAG) &&
7787 + inode->i_tag = attr->ia_tag;
7788 mark_inode_dirty(inode);
7790 journal_end(&th, inode->i_sb, jbegin_count);
7791 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/ioctl.c
7792 --- linux-2.6.27.25/fs/reiserfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
7793 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
7795 #include <linux/mount.h>
7796 #include <linux/reiserfs_fs.h>
7797 #include <linux/time.h>
7798 +#include <linux/mount.h>
7799 #include <asm/uaccess.h>
7800 #include <linux/pagemap.h>
7801 #include <linux/smp_lock.h>
7803 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7806 - unsigned int flags;
7807 + unsigned int flags, oldflags;
7811 @@ -43,6 +44,7 @@ int reiserfs_ioctl(struct inode *inode,
7813 flags = REISERFS_I(inode)->i_attrs;
7814 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7815 + flags &= REISERFS_FL_USER_VISIBLE;
7816 return put_user(flags, (int __user *)arg);
7817 case REISERFS_IOC_SETFLAGS:{
7818 if (!reiserfs_attrs(inode->i_sb))
7819 @@ -60,6 +62,10 @@ int reiserfs_ioctl(struct inode *inode,
7823 + if (IS_BARRIER(inode)) {
7824 + vxwprintk_task(1, "messing with the barrier.");
7828 * Is it quota file? Do not allow user to mess with it
7830 @@ -84,6 +90,10 @@ int reiserfs_ioctl(struct inode *inode,
7835 + oldflags = REISERFS_I(inode)->i_attrs;
7836 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
7837 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7838 sd_attrs_to_i_attrs(flags, inode);
7839 REISERFS_I(inode)->i_attrs = flags;
7840 inode->i_ctime = CURRENT_TIME_SEC;
7841 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/namei.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/namei.c
7842 --- linux-2.6.27.25/fs/reiserfs/namei.c 2008-07-13 23:51:29.000000000 +0200
7843 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/namei.c 2008-10-13 14:54:20.000000000 +0200
7845 #include <linux/reiserfs_acl.h>
7846 #include <linux/reiserfs_xattr.h>
7847 #include <linux/quotaops.h>
7848 +#include <linux/vs_tag.h>
7850 #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; }
7851 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7852 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
7853 reiserfs_write_unlock(dir->i_sb);
7854 return ERR_PTR(-EACCES);
7856 + dx_propagate_tag(nd, inode);
7858 /* Propogate the priv_object flag so we know we're in the priv tree */
7859 if (is_reiserfs_priv_object(dir))
7860 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
7862 inode->i_gid = current->fsgid;
7864 + inode->i_tag = dx_current_fstag(inode->i_sb);
7868 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
7869 .listxattr = reiserfs_listxattr,
7870 .removexattr = reiserfs_removexattr,
7871 .permission = reiserfs_permission,
7872 + .sync_flags = reiserfs_sync_flags,
7876 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
7877 .listxattr = reiserfs_listxattr,
7878 .removexattr = reiserfs_removexattr,
7879 .permission = reiserfs_permission,
7880 + .sync_flags = reiserfs_sync_flags,
7884 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
7885 .listxattr = reiserfs_listxattr,
7886 .removexattr = reiserfs_removexattr,
7887 .permission = reiserfs_permission,
7888 + .sync_flags = reiserfs_sync_flags,
7891 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/stree.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/stree.c
7892 --- linux-2.6.27.25/fs/reiserfs/stree.c 2008-07-13 23:51:29.000000000 +0200
7893 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/stree.c 2008-10-13 14:54:20.000000000 +0200
7895 #include <linux/reiserfs_fs.h>
7896 #include <linux/buffer_head.h>
7897 #include <linux/quotaops.h>
7898 +#include <linux/vs_dlimit.h>
7900 /* Does the buffer contain a disk block which is in the tree. */
7901 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
7902 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
7903 "reiserquota delete_item(): freeing %u, id=%u type=%c",
7904 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
7906 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7907 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7909 /* Return deleted body length */
7910 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
7912 DQUOT_FREE_SPACE_NODIRTY(inode,
7914 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
7918 @@ -1734,6 +1737,7 @@ int reiserfs_cut_from_item(struct reiser
7919 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
7920 quota_cut_bytes, p_s_inode->i_uid, '?');
7922 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7923 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7926 @@ -1975,6 +1979,11 @@ int reiserfs_paste_into_item(struct reis
7927 pathrelse(p_s_search_path);
7930 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
7931 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7932 + pathrelse(p_s_search_path);
7935 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
7937 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
7938 @@ -2027,6 +2036,7 @@ int reiserfs_paste_into_item(struct reis
7939 n_pasted_size, inode->i_uid,
7940 key2type(&(p_s_key->on_disk_key)));
7942 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
7943 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7946 @@ -2064,6 +2074,11 @@ int reiserfs_insert_item(struct reiserfs
7947 pathrelse(p_s_path);
7950 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
7951 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7952 + pathrelse(p_s_path);
7956 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
7957 IH_SIZE + ih_item_len(p_s_ih));
7958 @@ -2111,7 +2126,9 @@ int reiserfs_insert_item(struct reiserfs
7959 "reiserquota insert_item(): freeing %u id=%u type=%c",
7960 quota_bytes, inode->i_uid, head2type(p_s_ih));
7964 + DLIMIT_FREE_SPACE(inode, quota_bytes);
7965 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7969 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/super.c
7970 --- linux-2.6.27.25/fs/reiserfs/super.c 2008-10-13 14:52:06.000000000 +0200
7971 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/super.c 2008-10-13 14:54:20.000000000 +0200
7972 @@ -898,6 +898,14 @@ static int reiserfs_parse_options(struct
7973 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7974 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7976 +#ifndef CONFIG_TAGGING_NONE
7977 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7978 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7979 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7981 +#ifdef CONFIG_PROPAGATE
7982 + {"tag",.arg_required = 'T',.values = NULL},
7984 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7985 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7986 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7987 @@ -1193,6 +1201,12 @@ static int reiserfs_remount(struct super
7988 handle_quota_files(s, qf_names, &qfmt);
7991 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7992 + !(s->s_flags & MS_TAGGED)) {
7993 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
7999 /* Add options that are safe here */
8000 @@ -1657,6 +1671,10 @@ static int reiserfs_fill_super(struct su
8004 + /* map mount option tagxid */
8005 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
8006 + s->s_flags |= MS_TAGGED;
8008 rs = SB_DISK_SUPER_BLOCK(s);
8009 /* Let's do basic sanity check to verify that underlying device is not
8010 smaller than the filesystem. If the check fails then abort and scream,
8011 diff -NurpP --minimal linux-2.6.27.25/fs/reiserfs/xattr.c linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/xattr.c
8012 --- linux-2.6.27.25/fs/reiserfs/xattr.c 2008-10-13 14:52:06.000000000 +0200
8013 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/reiserfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
8015 #include <linux/namei.h>
8016 #include <linux/errno.h>
8017 #include <linux/fs.h>
8018 +#include <linux/mount.h>
8019 #include <linux/file.h>
8020 #include <linux/pagemap.h>
8021 #include <linux/xattr.h>
8022 diff -NurpP --minimal linux-2.6.27.25/fs/stat.c linux-2.6.27.25-vs2.3.0.36.6/fs/stat.c
8023 --- linux-2.6.27.25/fs/stat.c 2009-06-15 17:18:32.000000000 +0200
8024 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/stat.c 2009-02-03 17:59:04.000000000 +0100
8025 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
8026 stat->nlink = inode->i_nlink;
8027 stat->uid = inode->i_uid;
8028 stat->gid = inode->i_gid;
8029 + stat->tag = inode->i_tag;
8030 stat->rdev = inode->i_rdev;
8031 stat->atime = inode->i_atime;
8032 stat->mtime = inode->i_mtime;
8033 diff -NurpP --minimal linux-2.6.27.25/fs/super.c linux-2.6.27.25-vs2.3.0.36.6/fs/super.c
8034 --- linux-2.6.27.25/fs/super.c 2009-06-15 17:18:32.000000000 +0200
8035 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/super.c 2009-02-03 17:59:04.000000000 +0100
8037 #include <linux/kobject.h>
8038 #include <linux/mutex.h>
8039 #include <linux/file.h>
8040 +#include <linux/devpts_fs.h>
8041 +#include <linux/proc_fs.h>
8042 +#include <linux/vs_context.h>
8043 #include <asm/uaccess.h>
8044 #include "internal.h"
8046 @@ -887,12 +890,18 @@ struct vfsmount *
8047 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
8049 struct vfsmount *mnt;
8050 + struct super_block *sb;
8051 char *secdata = NULL;
8055 return ERR_PTR(-ENODEV);
8058 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
8059 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
8063 mnt = alloc_vfsmnt(name);
8065 @@ -913,7 +922,14 @@ vfs_kern_mount(struct file_system_type *
8066 goto out_free_secdata;
8067 BUG_ON(!mnt->mnt_sb);
8069 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
8072 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
8073 + (sb->s_magic != PROC_SUPER_MAGIC) &&
8074 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
8077 + error = security_sb_kern_mount(sb, secdata);
8081 diff -NurpP --minimal linux-2.6.27.25/fs/sysfs/mount.c linux-2.6.27.25-vs2.3.0.36.6/fs/sysfs/mount.c
8082 --- linux-2.6.27.25/fs/sysfs/mount.c 2008-07-13 23:51:29.000000000 +0200
8083 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/sysfs/mount.c 2008-10-13 14:54:20.000000000 +0200
8088 -/* Random magic number */
8089 -#define SYSFS_MAGIC 0x62656572
8091 static struct vfsmount *sysfs_mount;
8092 struct super_block * sysfs_sb = NULL;
8093 @@ -46,7 +44,7 @@ static int sysfs_fill_super(struct super
8095 sb->s_blocksize = PAGE_CACHE_SIZE;
8096 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
8097 - sb->s_magic = SYSFS_MAGIC;
8098 + sb->s_magic = SYSFS_SUPER_MAGIC;
8099 sb->s_op = &sysfs_ops;
8100 sb->s_time_gran = 1;
8102 diff -NurpP --minimal linux-2.6.27.25/fs/utimes.c linux-2.6.27.25-vs2.3.0.36.6/fs/utimes.c
8103 --- linux-2.6.27.25/fs/utimes.c 2009-06-15 17:18:32.000000000 +0200
8104 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/utimes.c 2009-02-03 17:59:04.000000000 +0100
8106 #include <linux/stat.h>
8107 #include <linux/utime.h>
8108 #include <linux/syscalls.h>
8109 +#include <linux/mount.h>
8110 +#include <linux/vs_cowbl.h>
8111 #include <asm/uaccess.h>
8112 #include <asm/unistd.h>
8114 diff -NurpP --minimal linux-2.6.27.25/fs/xattr.c linux-2.6.27.25-vs2.3.0.36.6/fs/xattr.c
8115 --- linux-2.6.27.25/fs/xattr.c 2009-06-15 17:18:32.000000000 +0200
8116 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xattr.c 2009-02-03 17:59:04.000000000 +0100
8118 #include <linux/module.h>
8119 #include <linux/fsnotify.h>
8120 #include <linux/audit.h>
8121 +#include <linux/mount.h>
8122 #include <asm/uaccess.h>
8125 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_ioctl.c
8126 --- linux-2.6.27.25/fs/xfs/linux-2.6/xfs_ioctl.c 2008-10-13 14:52:06.000000000 +0200
8127 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_ioctl.c 2008-11-12 18:41:58.000000000 +0100
8128 @@ -806,6 +806,10 @@ xfs_merge_ioc_xflags(
8129 xflags |= XFS_XFLAG_IMMUTABLE;
8131 xflags &= ~XFS_XFLAG_IMMUTABLE;
8132 + if (flags & FS_IXUNLINK_FL)
8133 + xflags |= XFS_XFLAG_IXUNLINK;
8135 + xflags &= ~XFS_XFLAG_IXUNLINK;
8136 if (flags & FS_APPEND_FL)
8137 xflags |= XFS_XFLAG_APPEND;
8139 @@ -834,6 +838,8 @@ xfs_di2lxflags(
8141 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8142 flags |= FS_IMMUTABLE_FL;
8143 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8144 + flags |= FS_IXUNLINK_FL;
8145 if (di_flags & XFS_DIFLAG_APPEND)
8146 flags |= FS_APPEND_FL;
8147 if (di_flags & XFS_DIFLAG_SYNC)
8148 @@ -892,6 +898,8 @@ xfs_set_diflags(
8149 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
8150 if (xflags & XFS_XFLAG_IMMUTABLE)
8151 di_flags |= XFS_DIFLAG_IMMUTABLE;
8152 + if (xflags & XFS_XFLAG_IXUNLINK)
8153 + di_flags |= XFS_DIFLAG_IXUNLINK;
8154 if (xflags & XFS_XFLAG_APPEND)
8155 di_flags |= XFS_DIFLAG_APPEND;
8156 if (xflags & XFS_XFLAG_SYNC)
8157 @@ -934,6 +942,10 @@ xfs_diflags_to_linux(
8158 inode->i_flags |= S_IMMUTABLE;
8160 inode->i_flags &= ~S_IMMUTABLE;
8161 + if (xflags & XFS_XFLAG_IXUNLINK)
8162 + inode->i_flags |= S_IXUNLINK;
8164 + inode->i_flags &= ~S_IXUNLINK;
8165 if (xflags & XFS_XFLAG_APPEND)
8166 inode->i_flags |= S_APPEND;
8168 @@ -1392,10 +1404,18 @@ xfs_ioctl(
8169 case XFS_IOC_FSGETXATTRA:
8170 return xfs_ioc_fsgetxattr(ip, 1, arg);
8171 case XFS_IOC_FSSETXATTR:
8172 + if (IS_BARRIER(inode)) {
8173 + vxwprintk_task(1, "messing with the barrier.");
8174 + return -XFS_ERROR(EACCES);
8176 return xfs_ioc_fssetxattr(ip, filp, arg);
8177 case XFS_IOC_GETXFLAGS:
8178 return xfs_ioc_getxflags(ip, arg);
8179 case XFS_IOC_SETXFLAGS:
8180 + if (IS_BARRIER(inode)) {
8181 + vxwprintk_task(1, "messing with the barrier.");
8182 + return -XFS_ERROR(EACCES);
8184 return xfs_ioc_setxflags(ip, filp, arg);
8186 case XFS_IOC_FSSETDM: {
8187 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_iops.c
8188 --- linux-2.6.27.25/fs/xfs/linux-2.6/xfs_iops.c 2008-10-13 14:52:06.000000000 +0200
8189 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_iops.c 2008-11-12 18:41:58.000000000 +0100
8191 #include <linux/namei.h>
8192 #include <linux/security.h>
8193 #include <linux/falloc.h>
8194 +#include <linux/vs_tag.h>
8197 * Bring the atime in the XFS inode uptodate.
8198 @@ -558,6 +559,7 @@ xfs_vn_getattr(
8199 stat->nlink = ip->i_d.di_nlink;
8200 stat->uid = ip->i_d.di_uid;
8201 stat->gid = ip->i_d.di_gid;
8202 + stat->tag = ip->i_d.di_tag;
8203 stat->ino = ip->i_ino;
8205 stat->ino += mp->m_inoadd;
8206 @@ -597,6 +599,12 @@ xfs_vn_getattr(
8210 +xfs_vn_sync_xflags(struct inode *inode)
8212 + return -xfs_sync_xflags(XFS_I(inode));
8217 struct dentry *dentry,
8218 struct iattr *iattr)
8219 @@ -671,6 +679,7 @@ static const struct inode_operations xfs
8220 .removexattr = generic_removexattr,
8221 .listxattr = xfs_vn_listxattr,
8222 .fallocate = xfs_vn_fallocate,
8223 + .sync_flags = xfs_vn_sync_xflags,
8226 static const struct inode_operations xfs_dir_inode_operations = {
8227 @@ -696,6 +705,7 @@ static const struct inode_operations xfs
8228 .getxattr = generic_getxattr,
8229 .removexattr = generic_removexattr,
8230 .listxattr = xfs_vn_listxattr,
8231 + .sync_flags = xfs_vn_sync_xflags,
8234 static const struct inode_operations xfs_dir_ci_inode_operations = {
8235 @@ -745,6 +755,10 @@ xfs_diflags_to_iflags(
8236 inode->i_flags |= S_IMMUTABLE;
8238 inode->i_flags &= ~S_IMMUTABLE;
8239 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
8240 + inode->i_flags |= S_IXUNLINK;
8242 + inode->i_flags &= ~S_IXUNLINK;
8243 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
8244 inode->i_flags |= S_APPEND;
8246 @@ -757,6 +771,15 @@ xfs_diflags_to_iflags(
8247 inode->i_flags |= S_NOATIME;
8249 inode->i_flags &= ~S_NOATIME;
8251 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
8252 + inode->i_vflags |= V_BARRIER;
8254 + inode->i_vflags &= ~V_BARRIER;
8255 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8256 + inode->i_vflags |= V_COW;
8258 + inode->i_vflags &= ~V_COW;
8262 @@ -777,6 +800,7 @@ xfs_setup_inode(
8263 inode->i_nlink = ip->i_d.di_nlink;
8264 inode->i_uid = ip->i_d.di_uid;
8265 inode->i_gid = ip->i_d.di_gid;
8266 + inode->i_tag = ip->i_d.di_tag;
8268 switch (inode->i_mode & S_IFMT) {
8270 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_linux.h
8271 --- linux-2.6.27.25/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 14:52:06.000000000 +0200
8272 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 15:35:26.000000000 +0200
8275 #define current_cpu() (raw_smp_processor_id())
8276 #define current_pid() (current->pid)
8277 +#define current_fstag(cred,vp) (dx_current_fstag(vp->i_sb))
8278 #define current_test_flags(f) (current->flags & (f))
8279 #define current_set_flags_nested(sp, f) \
8280 (*(sp) = current->flags, current->flags |= (f))
8281 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/linux-2.6/xfs_super.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_super.c
8282 --- linux-2.6.27.25/fs/xfs/linux-2.6/xfs_super.c 2009-06-15 17:18:32.000000000 +0200
8283 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/linux-2.6/xfs_super.c 2009-02-03 17:59:04.000000000 +0100
8284 @@ -147,6 +147,9 @@ xfs_args_allocate(
8285 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
8286 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
8287 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
8288 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8289 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8290 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8293 * Table driven mount option parser.
8294 @@ -155,10 +158,14 @@ xfs_args_allocate(
8295 * in the future, too.
8298 + Opt_tag, Opt_notag,
8299 Opt_barrier, Opt_nobarrier, Opt_err
8302 static match_table_t tokens = {
8303 + {Opt_tag, "tagxid"},
8305 + {Opt_notag, "notag"},
8306 {Opt_barrier, "barrier"},
8307 {Opt_nobarrier, "nobarrier"},
8309 @@ -383,6 +390,19 @@ xfs_parseargs(
8310 } else if (!strcmp(this_char, "irixsgid")) {
8312 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8313 +#ifndef CONFIG_TAGGING_NONE
8314 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8315 + args->flags2 |= XFSMNT2_TAGGED;
8316 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8317 + args->flags2 &= ~XFSMNT2_TAGGED;
8318 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8319 + args->flags2 |= XFSMNT2_TAGGED;
8321 +#ifdef CONFIG_PROPAGATE
8322 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8324 + args->flags2 |= XFSMNT2_TAGGED;
8328 "XFS: unknown mount option [%s].", this_char);
8329 @@ -1301,6 +1321,16 @@ xfs_fs_remount(
8331 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8334 + if (!(sb->s_flags & MS_TAGGED)) {
8336 + "XFS: %s: tagging not permitted on remount.\n",
8345 * Logically we would return an error here to prevent
8346 @@ -1555,6 +1585,9 @@ xfs_start_flags(
8348 if (ap->flags & XFSMNT_DMAPI)
8349 mp->m_flags |= XFS_MOUNT_DMAPI;
8351 + if (ap->flags2 & XFSMNT2_TAGGED)
8352 + mp->m_flags |= XFS_MOUNT_TAGGED;
8356 @@ -1749,6 +1782,9 @@ xfs_fs_fill_super(
8358 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname);
8360 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8361 + sb->s_flags |= MS_TAGGED;
8364 sb->s_magic = XFS_SB_MAGIC;
8365 sb->s_blocksize = mp->m_sb.sb_blocksize;
8366 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/quota/xfs_qm_syscalls.c
8367 --- linux-2.6.27.25/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-13 14:52:06.000000000 +0200
8368 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-24 03:47:08.000000000 +0200
8369 @@ -426,7 +426,7 @@ xfs_qm_scall_quotaon(
8373 - if (!capable(CAP_SYS_ADMIN))
8374 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8375 return XFS_ERROR(EPERM);
8377 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
8378 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_clnt.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_clnt.h
8379 --- linux-2.6.27.25/fs/xfs/xfs_clnt.h 2008-10-13 14:52:06.000000000 +0200
8380 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_clnt.h 2008-10-13 14:54:20.000000000 +0200
8381 @@ -101,5 +101,6 @@ struct xfs_mount_args {
8382 * I/O size in stat(2) */
8383 #define XFSMNT2_FILESTREAMS 0x00000002 /* enable the filestreams
8385 +#define XFSMNT2_TAGGED 0x10000000 /* context tagging */
8387 #endif /* __XFS_CLNT_H__ */
8388 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_dinode.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_dinode.h
8389 --- linux-2.6.27.25/fs/xfs/xfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
8390 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_dinode.h 2008-11-12 18:41:59.000000000 +0100
8391 @@ -53,7 +53,9 @@ typedef struct xfs_dinode_core {
8392 __be32 di_gid; /* owner's group id */
8393 __be32 di_nlink; /* number of links to file */
8394 __be16 di_projid; /* owner's project id */
8395 - __u8 di_pad[8]; /* unused, zeroed space */
8396 + __be16 di_tag; /* context tagging */
8397 + __be16 di_vflags; /* vserver specific flags */
8398 + __u8 di_pad[4]; /* unused, zeroed space */
8399 __be16 di_flushiter; /* incremented on flush */
8400 xfs_timestamp_t di_atime; /* time last accessed */
8401 xfs_timestamp_t di_mtime; /* time last modified */
8402 @@ -136,7 +138,9 @@ typedef struct xfs_dinode
8403 #define XFS_DI_NEXT_UNLINKED 0x1000000
8404 #define XFS_DI_U 0x2000000
8405 #define XFS_DI_A 0x4000000
8406 -#define XFS_DI_NUM_BITS 27
8407 +#define XFS_DI_TAG 0x8000000
8408 +#define XFS_DI_VFLAGS 0x10000000
8409 +#define XFS_DI_NUM_BITS 29
8410 #define XFS_DI_ALL_BITS ((1 << XFS_DI_NUM_BITS) - 1)
8411 #define XFS_DI_CORE_BITS (XFS_DI_ALL_BITS & ~(XFS_DI_U|XFS_DI_A))
8413 @@ -223,6 +227,8 @@ typedef enum xfs_dinode_fmt
8414 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8415 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8416 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8417 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8419 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8420 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8421 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8422 @@ -238,6 +244,7 @@ typedef enum xfs_dinode_fmt
8423 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8424 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8425 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8426 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8428 #ifdef CONFIG_XFS_RT
8429 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8430 @@ -250,6 +257,10 @@ typedef enum xfs_dinode_fmt
8431 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8432 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8433 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8434 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8435 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8436 + XFS_DIFLAG_IXUNLINK)
8438 +#define XFS_DIVFLAG_BARRIER 0x01
8439 +#define XFS_DIVFLAG_COW 0x02
8441 #endif /* __XFS_DINODE_H__ */
8442 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_fs.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_fs.h
8443 --- linux-2.6.27.25/fs/xfs/xfs_fs.h 2008-10-13 14:52:06.000000000 +0200
8444 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_fs.h 2008-10-13 14:54:20.000000000 +0200
8445 @@ -67,6 +67,9 @@ struct fsxattr {
8446 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8447 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8448 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8449 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8450 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8451 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8452 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8455 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8456 __s32 bs_extents; /* number of extents */
8457 __u32 bs_gen; /* generation count */
8458 __u16 bs_projid; /* project id */
8459 - unsigned char bs_pad[14]; /* pad space, unused */
8460 + __u16 bs_tag; /* context tagging */
8461 + unsigned char bs_pad[12]; /* pad space, unused */
8462 __u32 bs_dmevmask; /* DMIG event mask */
8463 __u16 bs_dmstate; /* DMIG state info */
8464 __u16 bs_aextents; /* attribute number of extents */
8465 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_ialloc.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_ialloc.c
8466 --- linux-2.6.27.25/fs/xfs/xfs_ialloc.c 2008-07-13 23:51:29.000000000 +0200
8467 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_ialloc.c 2008-11-12 18:41:59.000000000 +0100
8468 @@ -84,6 +84,8 @@ xfs_ialloc_log_di(
8469 offsetof(xfs_dinode_t, di_next_unlinked),
8470 offsetof(xfs_dinode_t, di_u),
8471 offsetof(xfs_dinode_t, di_a),
8472 + offsetof(xfs_dinode_core_t, di_tag),
8473 + offsetof(xfs_dinode_core_t, di_vflags),
8474 sizeof(xfs_dinode_t)
8477 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_inode.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_inode.c
8478 --- linux-2.6.27.25/fs/xfs/xfs_inode.c 2008-10-13 14:52:06.000000000 +0200
8479 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_inode.c 2008-11-12 18:42:00.000000000 +0100
8480 @@ -249,6 +249,7 @@ xfs_inotobp(
8484 +#include <linux/vs_tag.h>
8487 * This routine is called to map an inode to the buffer containing
8488 @@ -660,15 +661,25 @@ xfs_iformat_btree(
8490 xfs_dinode_from_disk(
8492 - xfs_dinode_core_t *from)
8493 + xfs_dinode_core_t *from,
8496 + uint32_t uid, gid, tag;
8498 to->di_magic = be16_to_cpu(from->di_magic);
8499 to->di_mode = be16_to_cpu(from->di_mode);
8500 to->di_version = from ->di_version;
8501 to->di_format = from->di_format;
8502 to->di_onlink = be16_to_cpu(from->di_onlink);
8503 - to->di_uid = be32_to_cpu(from->di_uid);
8504 - to->di_gid = be32_to_cpu(from->di_gid);
8506 + uid = be32_to_cpu(from->di_uid);
8507 + gid = be32_to_cpu(from->di_gid);
8508 + tag = be16_to_cpu(from->di_tag);
8510 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8511 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8512 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8514 to->di_nlink = be32_to_cpu(from->di_nlink);
8515 to->di_projid = be16_to_cpu(from->di_projid);
8516 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8517 @@ -689,21 +700,26 @@ xfs_dinode_from_disk(
8518 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8519 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8520 to->di_flags = be16_to_cpu(from->di_flags);
8521 + to->di_vflags = be16_to_cpu(from->di_vflags);
8522 to->di_gen = be32_to_cpu(from->di_gen);
8527 xfs_dinode_core_t *to,
8528 - xfs_icdinode_t *from)
8529 + xfs_icdinode_t *from,
8532 to->di_magic = cpu_to_be16(from->di_magic);
8533 to->di_mode = cpu_to_be16(from->di_mode);
8534 to->di_version = from ->di_version;
8535 to->di_format = from->di_format;
8536 to->di_onlink = cpu_to_be16(from->di_onlink);
8537 - to->di_uid = cpu_to_be32(from->di_uid);
8538 - to->di_gid = cpu_to_be32(from->di_gid);
8540 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8541 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8542 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8544 to->di_nlink = cpu_to_be32(from->di_nlink);
8545 to->di_projid = cpu_to_be16(from->di_projid);
8546 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8547 @@ -724,12 +740,14 @@ xfs_dinode_to_disk(
8548 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8549 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8550 to->di_flags = cpu_to_be16(from->di_flags);
8551 + to->di_vflags = cpu_to_be16(from->di_vflags);
8552 to->di_gen = cpu_to_be32(from->di_gen);
8557 - __uint16_t di_flags)
8558 + __uint16_t di_flags,
8559 + __uint16_t di_vflags)
8563 @@ -740,6 +758,8 @@ _xfs_dic2xflags(
8564 flags |= XFS_XFLAG_PREALLOC;
8565 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8566 flags |= XFS_XFLAG_IMMUTABLE;
8567 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8568 + flags |= XFS_XFLAG_IXUNLINK;
8569 if (di_flags & XFS_DIFLAG_APPEND)
8570 flags |= XFS_XFLAG_APPEND;
8571 if (di_flags & XFS_DIFLAG_SYNC)
8572 @@ -764,6 +784,10 @@ _xfs_dic2xflags(
8573 flags |= XFS_XFLAG_FILESTREAM;
8576 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8577 + flags |= FS_BARRIER_FL;
8578 + if (di_vflags & XFS_DIVFLAG_COW)
8579 + flags |= FS_COW_FL;
8583 @@ -773,7 +797,7 @@ xfs_ip2xflags(
8585 xfs_icdinode_t *dic = &ip->i_d;
8587 - return _xfs_dic2xflags(dic->di_flags) |
8588 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8589 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8592 @@ -783,7 +807,8 @@ xfs_dic2xflags(
8594 xfs_dinode_core_t *dic = &dip->di_core;
8596 - return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
8597 + return _xfs_dic2xflags(be16_to_cpu(dic->di_flags),
8598 + be16_to_cpu(dic->di_vflags)) |
8599 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8602 @@ -878,7 +903,8 @@ xfs_iread(
8603 * Otherwise, just get the truly permanent information.
8605 if (dip->di_core.di_mode) {
8606 - xfs_dinode_from_disk(&ip->i_d, &dip->di_core);
8607 + xfs_dinode_from_disk(&ip->i_d, &dip->di_core,
8608 + mp->m_flags & XFS_MOUNT_TAGGED);
8609 error = xfs_iformat(ip, dip);
8611 kmem_zone_free(xfs_inode_zone, ip);
8612 @@ -1083,6 +1109,7 @@ xfs_ialloc(
8613 ASSERT(ip->i_d.di_nlink == nlink);
8614 ip->i_d.di_uid = current_fsuid();
8615 ip->i_d.di_gid = current_fsgid();
8616 + ip->i_d.di_tag = current_fstag(cr, ip->i_vnode);
8617 ip->i_d.di_projid = prid;
8618 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8620 @@ -1143,6 +1170,7 @@ xfs_ialloc(
8621 ip->i_d.di_dmevmask = 0;
8622 ip->i_d.di_dmstate = 0;
8623 ip->i_d.di_flags = 0;
8624 + ip->i_d.di_vflags = 0;
8625 flags = XFS_ILOG_CORE;
8626 switch (mode & S_IFMT) {
8628 @@ -2249,6 +2277,7 @@ xfs_ifree(
8630 ip->i_d.di_mode = 0; /* mark incore inode as free */
8631 ip->i_d.di_flags = 0;
8632 + ip->i_d.di_vflags = 0;
8633 ip->i_d.di_dmevmask = 0;
8634 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8635 ip->i_df.if_ext_max =
8636 @@ -3342,7 +3371,8 @@ xfs_iflush_int(
8637 * because if the inode is dirty at all the core must
8640 - xfs_dinode_to_disk(&dip->di_core, &ip->i_d);
8641 + xfs_dinode_to_disk(&dip->di_core, &ip->i_d,
8642 + mp->m_flags & XFS_MOUNT_TAGGED);
8644 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8645 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8646 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_inode.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_inode.h
8647 --- linux-2.6.27.25/fs/xfs/xfs_inode.h 2008-10-13 14:52:06.000000000 +0200
8648 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_inode.h 2008-11-12 18:42:03.000000000 +0100
8649 @@ -173,7 +173,9 @@ typedef struct xfs_icdinode {
8650 __uint32_t di_gid; /* owner's group id */
8651 __uint32_t di_nlink; /* number of links to file */
8652 __uint16_t di_projid; /* owner's project id */
8653 - __uint8_t di_pad[8]; /* unused, zeroed space */
8654 + __uint16_t di_tag; /* context tagging */
8655 + __uint16_t di_vflags; /* vserver specific flags */
8656 + __uint8_t di_pad[4]; /* unused, zeroed space */
8657 __uint16_t di_flushiter; /* incremented on flush */
8658 xfs_ictimestamp_t di_atime; /* time last accessed */
8659 xfs_ictimestamp_t di_mtime; /* time last modified */
8660 @@ -500,9 +502,9 @@ int xfs_ialloc(struct xfs_trans *, xfs_
8661 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
8662 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
8663 void xfs_dinode_from_disk(struct xfs_icdinode *,
8664 - struct xfs_dinode_core *);
8665 + struct xfs_dinode_core *, int tagged);
8666 void xfs_dinode_to_disk(struct xfs_dinode_core *,
8667 - struct xfs_icdinode *);
8668 + struct xfs_icdinode *, int tagged);
8670 uint xfs_ip2xflags(struct xfs_inode *);
8671 uint xfs_dic2xflags(struct xfs_dinode *);
8672 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_itable.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_itable.c
8673 --- linux-2.6.27.25/fs/xfs/xfs_itable.c 2008-10-13 14:52:06.000000000 +0200
8674 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_itable.c 2008-11-12 18:42:03.000000000 +0100
8675 @@ -82,6 +82,7 @@ xfs_bulkstat_one_iget(
8676 buf->bs_mode = dic->di_mode;
8677 buf->bs_uid = dic->di_uid;
8678 buf->bs_gid = dic->di_gid;
8679 + buf->bs_tag = dic->di_tag;
8680 buf->bs_size = dic->di_size;
8681 vn_atime_to_bstime(VFS_I(ip), &buf->bs_atime);
8682 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
8683 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_log_recover.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_log_recover.c
8684 --- linux-2.6.27.25/fs/xfs/xfs_log_recover.c 2008-10-13 14:52:06.000000000 +0200
8685 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_log_recover.c 2008-11-12 18:42:03.000000000 +0100
8686 @@ -2417,7 +2417,8 @@ xlog_recover_do_inode_trans(
8688 /* The core is in in-core format */
8689 xfs_dinode_to_disk(&dip->di_core,
8690 - (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8691 + (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8692 + mp->m_flags & XFS_MOUNT_TAGGED);
8694 /* the rest is in on-disk format */
8695 if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) {
8696 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_mount.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_mount.h
8697 --- linux-2.6.27.25/fs/xfs/xfs_mount.h 2008-10-13 14:52:06.000000000 +0200
8698 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_mount.h 2008-10-13 14:54:20.000000000 +0200
8699 @@ -384,6 +384,7 @@ typedef struct xfs_mount {
8701 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8703 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8706 * Default minimum read and write sizes.
8707 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_vnodeops.c linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_vnodeops.c
8708 --- linux-2.6.27.25/fs/xfs/xfs_vnodeops.c 2008-10-13 14:52:06.000000000 +0200
8709 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_vnodeops.c 2008-11-12 18:42:03.000000000 +0100
8710 @@ -75,6 +75,89 @@ xfs_open(
8715 +xfs_get_inode_flags(
8718 + struct inode *inode = VFS_I(ip);
8719 + unsigned int flags = inode->i_flags;
8720 + unsigned int vflags = inode->i_vflags;
8722 + if (flags & S_IMMUTABLE)
8723 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8725 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8726 + if (flags & S_IXUNLINK)
8727 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8729 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8731 + if (vflags & V_BARRIER)
8732 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8734 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8735 + if (vflags & V_COW)
8736 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8738 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8745 + struct xfs_mount *mp = ip->i_mount;
8746 + struct xfs_trans *tp;
8747 + unsigned int lock_flags = 0;
8750 + xfs_itrace_entry(ip);
8752 + if (mp->m_flags & XFS_MOUNT_RDONLY)
8753 + return XFS_ERROR(EROFS);
8756 + * we acquire the inode lock and do an error checking pass.
8758 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8759 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8761 + goto error_return;
8763 + lock_flags = XFS_ILOCK_EXCL;
8764 + xfs_ilock(ip, lock_flags);
8766 + xfs_trans_ijoin(tp, ip, lock_flags);
8767 + xfs_trans_ihold(tp, ip);
8769 + xfs_get_inode_flags(ip);
8770 + // xfs_diflags_to_linux(ip);
8772 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8773 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8775 + XFS_STATS_INC(xs_ig_attrchg);
8778 + * If this is a synchronous mount, make sure that the
8779 + * transaction goes to disk before returning to the user.
8781 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8782 + xfs_trans_set_sync(tp);
8783 + code = xfs_trans_commit(tp, 0);
8784 + xfs_iunlock(ip, lock_flags);
8791 + xfs_trans_cancel(tp, 0);
8793 + xfs_iunlock(ip, lock_flags);
8799 struct xfs_inode *ip,
8800 @@ -91,6 +174,7 @@ xfs_setattr(
8801 uint commit_flags=0;
8802 uid_t uid=0, iuid=0;
8803 gid_t gid=0, igid=0;
8804 + tag_t tag=0, itag=0;
8806 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8808 @@ -238,7 +322,7 @@ xfs_setattr(
8809 * and can change the group id only to a group of which he
8810 * or she is a member.
8812 - if (mask & (ATTR_UID|ATTR_GID)) {
8813 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8815 * These IDs could have changed since we last looked at them.
8816 * But, we're assured that if the ownership did change
8817 @@ -247,8 +331,10 @@ xfs_setattr(
8819 iuid = ip->i_d.di_uid;
8820 igid = ip->i_d.di_gid;
8821 + itag = ip->i_d.di_tag;
8822 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8823 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8824 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8827 * CAP_CHOWN overrides the following restrictions:
8828 @@ -272,7 +358,9 @@ xfs_setattr(
8831 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8832 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
8833 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8834 + (XFS_IS_GQUOTA_ON(mp) && itag != tag)) {
8835 + /* TODO: handle tagging? */
8837 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
8838 capable(CAP_FOWNER) ?
8839 @@ -461,7 +549,7 @@ xfs_setattr(
8840 * and can change the group id only to a group of which he
8841 * or she is a member.
8843 - if (mask & (ATTR_UID|ATTR_GID)) {
8844 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8846 * CAP_FSETID overrides the following restrictions:
8848 @@ -477,6 +565,10 @@ xfs_setattr(
8849 * Change the ownerships and register quota modifications
8850 * in the transaction.
8852 + if (itag != tag) {
8853 + ip->i_d.di_tag = tag;
8854 + inode->i_tag = tag;
8857 if (XFS_IS_UQUOTA_ON(mp)) {
8858 ASSERT(mask & ATTR_UID);
8859 diff -NurpP --minimal linux-2.6.27.25/fs/xfs/xfs_vnodeops.h linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_vnodeops.h
8860 --- linux-2.6.27.25/fs/xfs/xfs_vnodeops.h 2008-10-13 14:52:06.000000000 +0200
8861 +++ linux-2.6.27.25-vs2.3.0.36.6/fs/xfs/xfs_vnodeops.h 2008-11-12 18:42:03.000000000 +0100
8862 @@ -15,6 +15,7 @@ struct xfs_iomap;
8865 int xfs_open(struct xfs_inode *ip);
8866 +int xfs_sync_xflags(struct xfs_inode *ip);
8867 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags,
8868 struct cred *credp);
8869 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8870 diff -NurpP --minimal linux-2.6.27.25/include/asm-generic/tlb.h linux-2.6.27.25-vs2.3.0.36.6/include/asm-generic/tlb.h
8871 --- linux-2.6.27.25/include/asm-generic/tlb.h 2008-07-13 23:51:29.000000000 +0200
8872 +++ linux-2.6.27.25-vs2.3.0.36.6/include/asm-generic/tlb.h 2008-10-13 14:54:20.000000000 +0200
8874 #define _ASM_GENERIC__TLB_H
8876 #include <linux/swap.h>
8877 +#include <linux/vs_memory.h>
8878 #include <asm/pgalloc.h>
8879 #include <asm/tlbflush.h>
8881 diff -NurpP --minimal linux-2.6.27.25/include/asm-x86/unistd_64.h linux-2.6.27.25-vs2.3.0.36.6/include/asm-x86/unistd_64.h
8882 --- linux-2.6.27.25/include/asm-x86/unistd_64.h 2008-10-13 14:52:08.000000000 +0200
8883 +++ linux-2.6.27.25-vs2.3.0.36.6/include/asm-x86/unistd_64.h 2008-10-13 14:54:20.000000000 +0200
8884 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
8885 #define __NR_utimes 235
8886 __SYSCALL(__NR_utimes, sys_utimes)
8887 #define __NR_vserver 236
8888 -__SYSCALL(__NR_vserver, sys_ni_syscall)
8889 +__SYSCALL(__NR_vserver, sys_vserver)
8890 #define __NR_mbind 237
8891 __SYSCALL(__NR_mbind, sys_mbind)
8892 #define __NR_set_mempolicy 238
8893 diff -NurpP --minimal linux-2.6.27.25/include/linux/capability.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/capability.h
8894 --- linux-2.6.27.25/include/linux/capability.h 2009-06-15 17:18:32.000000000 +0200
8895 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/capability.h 2009-05-15 22:57:04.000000000 +0200
8896 @@ -274,6 +274,7 @@ typedef struct kernel_cap_struct {
8897 arbitrary SCSI commands */
8898 /* Allow setting encryption key on loopback filesystem */
8899 /* Allow setting zone reclaim policy */
8900 +/* Allow the selection of a security context */
8902 #define CAP_SYS_ADMIN 21
8904 @@ -346,7 +347,13 @@ typedef struct kernel_cap_struct {
8906 #define CAP_MAC_ADMIN 33
8908 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8909 +/* Allow context manipulations */
8910 +/* Allow changing context info on files */
8912 +#define CAP_CONTEXT 34
8915 +#define CAP_LAST_CAP CAP_CONTEXT
8917 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8919 diff -NurpP --minimal linux-2.6.27.25/include/linux/devpts_fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/devpts_fs.h
8920 --- linux-2.6.27.25/include/linux/devpts_fs.h 2008-07-13 23:51:29.000000000 +0200
8921 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/devpts_fs.h 2008-10-13 14:54:20.000000000 +0200
8922 @@ -34,5 +34,4 @@ static inline void devpts_pty_kill(int n
8927 #endif /* _LINUX_DEVPTS_FS_H */
8928 diff -NurpP --minimal linux-2.6.27.25/include/linux/ext2_fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/ext2_fs.h
8929 --- linux-2.6.27.25/include/linux/ext2_fs.h 2008-10-13 14:52:09.000000000 +0200
8930 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/ext2_fs.h 2008-10-13 14:54:20.000000000 +0200
8931 @@ -189,8 +189,12 @@ struct ext2_group_desc
8932 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8933 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8934 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8935 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8936 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8938 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8939 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8941 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8942 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8944 @@ -247,7 +251,7 @@ struct ext2_inode {
8946 __u8 l_i_frag; /* Fragment number */
8947 __u8 l_i_fsize; /* Fragment size */
8949 + __u16 l_i_tag; /* Context Tag */
8950 __le16 l_i_uid_high; /* these 2 fields */
8951 __le16 l_i_gid_high; /* were reserved2[0] */
8952 __u32 l_i_reserved2;
8953 @@ -279,6 +283,7 @@ struct ext2_inode {
8954 #define i_gid_low i_gid
8955 #define i_uid_high osd2.linux2.l_i_uid_high
8956 #define i_gid_high osd2.linux2.l_i_gid_high
8957 +#define i_raw_tag osd2.linux2.l_i_tag
8958 #define i_reserved2 osd2.linux2.l_i_reserved2
8961 @@ -323,6 +328,7 @@ struct ext2_inode {
8962 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8963 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8964 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8965 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8968 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8969 diff -NurpP --minimal linux-2.6.27.25/include/linux/ext3_fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/ext3_fs.h
8970 --- linux-2.6.27.25/include/linux/ext3_fs.h 2008-10-13 14:52:09.000000000 +0200
8971 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/ext3_fs.h 2008-10-31 18:15:18.000000000 +0100
8972 @@ -173,10 +173,14 @@ struct ext3_group_desc
8973 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8974 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8975 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8976 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8977 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8979 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8980 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8981 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8982 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8984 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8985 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8988 * Inode dynamic state flags
8989 @@ -292,7 +296,7 @@ struct ext3_inode {
8991 __u8 l_i_frag; /* Fragment number */
8992 __u8 l_i_fsize; /* Fragment size */
8994 + __u16 l_i_tag; /* Context Tag */
8995 __le16 l_i_uid_high; /* these 2 fields */
8996 __le16 l_i_gid_high; /* were reserved2[0] */
8997 __u32 l_i_reserved2;
8998 @@ -326,6 +330,7 @@ struct ext3_inode {
8999 #define i_gid_low i_gid
9000 #define i_uid_high osd2.linux2.l_i_uid_high
9001 #define i_gid_high osd2.linux2.l_i_gid_high
9002 +#define i_raw_tag osd2.linux2.l_i_tag
9003 #define i_reserved2 osd2.linux2.l_i_reserved2
9005 #elif defined(__GNU__)
9006 @@ -380,6 +385,7 @@ struct ext3_inode {
9007 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
9008 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
9009 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
9010 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
9012 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
9013 #ifndef _LINUX_EXT2_FS_H
9014 @@ -822,6 +828,7 @@ struct buffer_head * ext3_bread (handle_
9015 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
9016 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
9017 int create, int extend_disksize);
9018 +extern int ext3_sync_flags(struct inode *inode);
9020 extern struct inode *ext3_iget(struct super_block *, unsigned long);
9021 extern int ext3_write_inode (struct inode *, int);
9022 diff -NurpP --minimal linux-2.6.27.25/include/linux/fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/fs.h
9023 --- linux-2.6.27.25/include/linux/fs.h 2009-06-15 17:18:32.000000000 +0200
9024 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/fs.h 2009-03-25 14:32:29.000000000 +0100
9025 @@ -133,6 +133,9 @@ extern int dir_notify_enable;
9026 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
9027 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
9028 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
9029 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
9030 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
9031 +#define MS_NOTAGCHECK (1<<26) /* don't check tags */
9032 #define MS_ACTIVE (1<<30)
9033 #define MS_NOUSER (1<<31)
9035 @@ -159,6 +162,14 @@ extern int dir_notify_enable;
9036 #define S_NOCMTIME 128 /* Do not update file c/mtime */
9037 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
9038 #define S_PRIVATE 512 /* Inode is fs-internal */
9039 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
9041 +/* Linux-VServer related Inode flags */
9045 +#define V_BARRIER 4 /* Barrier for chroot() */
9046 +#define V_COW 8 /* Copy on Write */
9049 * Note that nosuid etc flags are inode-specific: setting some file-system
9050 @@ -181,12 +192,15 @@ extern int dir_notify_enable;
9051 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
9052 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
9053 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
9054 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9055 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9056 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9057 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9058 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
9060 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
9061 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
9062 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
9063 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
9064 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
9065 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
9067 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
9068 @@ -194,6 +208,16 @@ extern int dir_notify_enable;
9069 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
9070 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
9072 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
9074 +#ifdef CONFIG_VSERVER_COWBL
9075 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
9076 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
9078 +# define IS_COW(inode) (0)
9079 +# define IS_COW_LINK(inode) (0)
9082 /* the read-only stuff doesn't really belong here, but any other place is
9083 probably as bad and I don't want to create yet another include file. */
9085 @@ -267,11 +291,14 @@ extern int dir_notify_enable;
9086 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
9087 #define FS_EXTENT_FL 0x00080000 /* Extents */
9088 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
9089 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
9090 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
9092 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
9093 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9094 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9095 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
9097 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
9098 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
9100 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
9101 #define SYNC_FILE_RANGE_WRITE 2
9102 @@ -342,6 +369,7 @@ typedef void (dio_iodone_t)(struct kiocb
9103 #define ATTR_KILL_PRIV (1 << 14)
9104 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
9105 #define ATTR_TIMES_SET (1 << 16)
9106 +#define ATTR_TAG (1 << 17)
9109 * This is the Inode Attributes structure, used for notify_change(). It
9110 @@ -357,6 +385,7 @@ struct iattr {
9116 struct timespec ia_atime;
9117 struct timespec ia_mtime;
9118 @@ -370,6 +399,9 @@ struct iattr {
9119 struct file *ia_file;
9122 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
9123 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
9126 * Includes for diskquotas.
9128 @@ -634,7 +666,9 @@ struct inode {
9129 unsigned int i_nlink;
9137 #ifdef __NEED_I_SIZE_ORDERED
9138 @@ -682,7 +716,8 @@ struct inode {
9139 unsigned long i_state;
9140 unsigned long dirtied_when; /* jiffies of first dirtying */
9142 - unsigned int i_flags;
9143 + unsigned short i_flags;
9144 + unsigned short i_vflags;
9146 atomic_t i_writecount;
9147 #ifdef CONFIG_SECURITY
9148 @@ -769,12 +804,12 @@ static inline void i_size_write(struct i
9150 static inline unsigned iminor(const struct inode *inode)
9152 - return MINOR(inode->i_rdev);
9153 + return MINOR(inode->i_mdev);
9156 static inline unsigned imajor(const struct inode *inode)
9158 - return MAJOR(inode->i_rdev);
9159 + return MAJOR(inode->i_mdev);
9162 extern struct block_device *I_BDEV(struct inode *inode);
9163 @@ -832,6 +867,7 @@ struct file {
9165 struct fown_struct f_owner;
9166 unsigned int f_uid, f_gid;
9168 struct file_ra_state f_ra;
9171 @@ -966,6 +1002,7 @@ struct file_lock {
9172 struct file *fl_file;
9177 struct fasync_struct * fl_fasync; /* for lease break notifications */
9178 unsigned long fl_break_time; /* for nonblocking lease breaks */
9179 @@ -1294,6 +1331,7 @@ struct inode_operations {
9180 void (*truncate_range)(struct inode *, loff_t, loff_t);
9181 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
9183 + int (*sync_flags) (struct inode *);
9187 @@ -1309,6 +1347,7 @@ extern ssize_t vfs_readv(struct file *,
9188 unsigned long, loff_t *);
9189 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
9190 unsigned long, loff_t *);
9191 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
9193 struct super_operations {
9194 struct inode *(*alloc_inode)(struct super_block *sb);
9195 @@ -1999,6 +2038,7 @@ extern int dcache_dir_open(struct inode
9196 extern int dcache_dir_close(struct inode *, struct file *);
9197 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
9198 extern int dcache_readdir(struct file *, void *, filldir_t);
9199 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
9200 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
9201 extern int simple_statfs(struct dentry *, struct kstatfs *);
9202 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
9203 diff -NurpP --minimal linux-2.6.27.25/include/linux/if_tun.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/if_tun.h
9204 --- linux-2.6.27.25/include/linux/if_tun.h 2008-10-13 14:52:09.000000000 +0200
9205 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/if_tun.h 2008-10-13 14:54:20.000000000 +0200
9207 #define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
9208 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
9209 #define TUNGETIFF _IOR('T', 210, unsigned int)
9210 +#define TUNSETNID _IOW('T', 215, int)
9212 /* TUNSETIFF ifr flags */
9213 #define IFF_TUN 0x0001
9214 diff -NurpP --minimal linux-2.6.27.25/include/linux/init_task.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/init_task.h
9215 --- linux-2.6.27.25/include/linux/init_task.h 2008-10-13 14:52:09.000000000 +0200
9216 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/init_task.h 2008-10-13 14:54:20.000000000 +0200
9217 @@ -179,6 +179,10 @@ extern struct group_info init_groups;
9219 INIT_TRACE_IRQFLAGS \
9222 + .vx_info = NULL, \
9224 + .nx_info = NULL, \
9228 diff -NurpP --minimal linux-2.6.27.25/include/linux/interrupt.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/interrupt.h
9229 --- linux-2.6.27.25/include/linux/interrupt.h 2008-10-13 14:52:09.000000000 +0200
9230 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/interrupt.h 2008-10-13 14:54:20.000000000 +0200
9232 #include <linux/preempt.h>
9233 #include <linux/cpumask.h>
9234 #include <linux/irqreturn.h>
9235 -#include <linux/hardirq.h>
9236 #include <linux/sched.h>
9237 +#include <linux/hardirq.h>
9238 #include <linux/irqflags.h>
9239 #include <asm/atomic.h>
9240 #include <asm/ptrace.h>
9241 diff -NurpP --minimal linux-2.6.27.25/include/linux/ipc.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/ipc.h
9242 --- linux-2.6.27.25/include/linux/ipc.h 2008-07-13 23:51:29.000000000 +0200
9243 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/ipc.h 2008-10-13 14:54:20.000000000 +0200
9244 @@ -93,6 +93,7 @@ struct kern_ipc_perm
9252 diff -NurpP --minimal linux-2.6.27.25/include/linux/Kbuild linux-2.6.27.25-vs2.3.0.36.6/include/linux/Kbuild
9253 --- linux-2.6.27.25/include/linux/Kbuild 2009-06-15 17:18:32.000000000 +0200
9254 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/Kbuild 2009-02-03 18:03:38.000000000 +0100
9255 @@ -370,3 +370,6 @@ unifdef-y += xattr.h
9258 objhdr-y += version.h
9260 +header-y += vserver/
9262 diff -NurpP --minimal linux-2.6.27.25/include/linux/loop.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/loop.h
9263 --- linux-2.6.27.25/include/linux/loop.h 2008-07-13 23:51:29.000000000 +0200
9264 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/loop.h 2008-10-13 14:54:20.000000000 +0200
9265 @@ -45,6 +45,7 @@ struct loop_device {
9266 struct loop_func_table *lo_encryption;
9268 uid_t lo_key_owner; /* Who set the key */
9270 int (*ioctl)(struct loop_device *, int cmd,
9273 diff -NurpP --minimal linux-2.6.27.25/include/linux/magic.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/magic.h
9274 --- linux-2.6.27.25/include/linux/magic.h 2008-07-13 23:51:29.000000000 +0200
9275 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/magic.h 2008-10-13 14:54:20.000000000 +0200
9278 #define ADFS_SUPER_MAGIC 0xadf5
9279 #define AFFS_SUPER_MAGIC 0xadff
9280 -#define AFS_SUPER_MAGIC 0x5346414F
9281 +#define AFS_SUPER_MAGIC 0x5346414F
9282 #define AUTOFS_SUPER_MAGIC 0x0187
9283 #define CODA_SUPER_MAGIC 0x73757245
9284 #define EFS_SUPER_MAGIC 0x414A53
9286 #define NFS_SUPER_MAGIC 0x6969
9287 #define OPENPROM_SUPER_MAGIC 0x9fa1
9288 #define PROC_SUPER_MAGIC 0x9fa0
9289 +#define DEVPTS_SUPER_MAGIC 0x1cd1
9290 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
9292 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
9293 diff -NurpP --minimal linux-2.6.27.25/include/linux/major.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/major.h
9294 --- linux-2.6.27.25/include/linux/major.h 2008-10-13 14:52:09.000000000 +0200
9295 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/major.h 2008-10-13 14:54:20.000000000 +0200
9297 #define HD_MAJOR IDE0_MAJOR
9298 #define PTY_SLAVE_MAJOR 3
9300 +#define VROOT_MAJOR 4
9301 #define TTYAUX_MAJOR 5
9304 diff -NurpP --minimal linux-2.6.27.25/include/linux/mm_types.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/mm_types.h
9305 --- linux-2.6.27.25/include/linux/mm_types.h 2008-10-13 14:52:09.000000000 +0200
9306 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/mm_types.h 2008-10-13 14:54:20.000000000 +0200
9307 @@ -216,6 +216,7 @@ struct mm_struct {
9309 /* Architecture-specific MM context */
9310 mm_context_t context;
9311 + struct vx_info *mm_vx_info;
9313 /* Swap token stuff */
9315 diff -NurpP --minimal linux-2.6.27.25/include/linux/mount.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/mount.h
9316 --- linux-2.6.27.25/include/linux/mount.h 2008-10-13 14:52:09.000000000 +0200
9317 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/mount.h 2008-10-24 03:34:52.000000000 +0200
9318 @@ -37,6 +37,9 @@ struct mnt_namespace;
9319 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
9320 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
9322 +#define MNT_TAGID 0x10000
9323 +#define MNT_NOTAG 0x20000
9326 struct list_head mnt_hash;
9327 struct vfsmount *mnt_parent; /* fs we are mounted on */
9328 @@ -71,6 +74,7 @@ struct vfsmount {
9329 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
9331 atomic_t __mnt_writers;
9332 + tag_t mnt_tag; /* tagging used for vfsmount */
9335 static inline struct vfsmount *mntget(struct vfsmount *mnt)
9336 diff -NurpP --minimal linux-2.6.27.25/include/linux/net.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/net.h
9337 --- linux-2.6.27.25/include/linux/net.h 2008-10-13 14:52:09.000000000 +0200
9338 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/net.h 2008-10-13 14:54:20.000000000 +0200
9339 @@ -68,6 +68,7 @@ struct net;
9340 #define SOCK_NOSPACE 2
9341 #define SOCK_PASSCRED 3
9342 #define SOCK_PASSSEC 4
9343 +#define SOCK_USER_SOCKET 5
9345 #ifndef ARCH_HAS_SOCKET_TYPES
9347 diff -NurpP --minimal linux-2.6.27.25/include/linux/nfs_mount.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/nfs_mount.h
9348 --- linux-2.6.27.25/include/linux/nfs_mount.h 2008-07-13 23:51:29.000000000 +0200
9349 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/nfs_mount.h 2008-10-13 14:54:20.000000000 +0200
9350 @@ -63,6 +63,7 @@ struct nfs_mount_data {
9351 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9352 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9353 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9354 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9355 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9356 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9359 diff -NurpP --minimal linux-2.6.27.25/include/linux/nsproxy.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/nsproxy.h
9360 --- linux-2.6.27.25/include/linux/nsproxy.h 2008-10-13 14:52:09.000000000 +0200
9361 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/nsproxy.h 2008-10-13 14:54:20.000000000 +0200
9364 #include <linux/spinlock.h>
9365 #include <linux/sched.h>
9366 +#include <linux/vserver/debug.h>
9368 struct mnt_namespace;
9369 struct uts_namespace;
9370 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9373 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9374 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9375 void exit_task_namespaces(struct task_struct *tsk);
9376 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9377 void free_nsproxy(struct nsproxy *ns);
9378 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9379 struct fs_struct *);
9381 -static inline void put_nsproxy(struct nsproxy *ns)
9382 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9384 +static inline void __get_nsproxy(struct nsproxy *ns,
9385 + const char *_file, int _line)
9387 - if (atomic_dec_and_test(&ns->count)) {
9390 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9391 + ns, atomic_read(&ns->count), _file, _line);
9392 + atomic_inc(&ns->count);
9395 -static inline void get_nsproxy(struct nsproxy *ns)
9396 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9398 +static inline void __put_nsproxy(struct nsproxy *ns,
9399 + const char *_file, int _line)
9401 - atomic_inc(&ns->count);
9402 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9403 + ns, atomic_read(&ns->count), _file, _line);
9404 + if (atomic_dec_and_test(&ns->count)) {
9409 #ifdef CONFIG_CGROUP_NS
9410 diff -NurpP --minimal linux-2.6.27.25/include/linux/pid.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/pid.h
9411 --- linux-2.6.27.25/include/linux/pid.h 2009-06-15 17:18:32.000000000 +0200
9412 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/pid.h 2009-02-22 22:58:33.000000000 +0100
9413 @@ -8,7 +8,8 @@ enum pid_type
9423 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9426 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9427 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9428 pid_t pid_vnr(struct pid *pid);
9430 #define do_each_pid_task(pid, type, task) \
9431 diff -NurpP --minimal linux-2.6.27.25/include/linux/proc_fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/proc_fs.h
9432 --- linux-2.6.27.25/include/linux/proc_fs.h 2008-10-13 14:52:09.000000000 +0200
9433 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/proc_fs.h 2008-10-13 14:54:20.000000000 +0200
9434 @@ -59,6 +59,7 @@ struct proc_dir_entry {
9440 const struct inode_operations *proc_iops;
9442 @@ -274,12 +275,18 @@ static inline void kclist_add(struct kco
9443 extern void kclist_add(struct kcore_list *, void *, size_t);
9450 int (*proc_get_link)(struct inode *, struct path *);
9451 int (*proc_read)(struct task_struct *task, char *page);
9452 int (*proc_show)(struct seq_file *m,
9453 struct pid_namespace *ns, struct pid *pid,
9454 struct task_struct *task);
9455 + int (*proc_vs_read)(char *page);
9456 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9457 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9460 struct ctl_table_header;
9461 @@ -287,6 +294,7 @@ struct ctl_table;
9468 struct proc_dir_entry *pde;
9469 diff -NurpP --minimal linux-2.6.27.25/include/linux/reiserfs_fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/reiserfs_fs.h
9470 --- linux-2.6.27.25/include/linux/reiserfs_fs.h 2008-10-13 14:52:09.000000000 +0200
9471 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/reiserfs_fs.h 2008-10-13 14:54:20.000000000 +0200
9472 @@ -837,6 +837,11 @@ struct stat_data_v1 {
9473 #define REISERFS_COMPR_FL FS_COMPR_FL
9474 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9476 +/* unfortunately reiserfs sdattr is only 16 bit */
9477 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9478 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9479 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9481 /* persistent flags that file inherits from the parent directory */
9482 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9483 REISERFS_SYNC_FL | \
9484 @@ -846,6 +851,9 @@ struct stat_data_v1 {
9485 REISERFS_COMPR_FL | \
9486 REISERFS_NOTAIL_FL )
9488 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9489 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9491 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9494 @@ -1911,6 +1919,7 @@ static inline void reiserfs_update_sd(st
9495 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9496 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9497 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9498 +int reiserfs_sync_flags(struct inode *inode);
9501 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9502 diff -NurpP --minimal linux-2.6.27.25/include/linux/reiserfs_fs_sb.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/reiserfs_fs_sb.h
9503 --- linux-2.6.27.25/include/linux/reiserfs_fs_sb.h 2008-10-13 14:52:09.000000000 +0200
9504 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/reiserfs_fs_sb.h 2008-10-13 14:54:20.000000000 +0200
9505 @@ -455,6 +455,7 @@ enum reiserfs_mount_options {
9507 REISERFS_BARRIER_NONE,
9508 REISERFS_BARRIER_FLUSH,
9511 /* Actions on error */
9512 REISERFS_ERROR_PANIC,
9513 diff -NurpP --minimal linux-2.6.27.25/include/linux/sched.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/sched.h
9514 --- linux-2.6.27.25/include/linux/sched.h 2009-06-15 17:18:32.000000000 +0200
9515 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/sched.h 2009-05-15 22:57:04.000000000 +0200
9516 @@ -71,7 +71,6 @@ struct sched_param {
9517 #include <linux/fs_struct.h>
9518 #include <linux/compiler.h>
9519 #include <linux/completion.h>
9520 -#include <linux/pid.h>
9521 #include <linux/percpu.h>
9522 #include <linux/topology.h>
9523 #include <linux/proportions.h>
9524 @@ -88,6 +87,7 @@ struct sched_param {
9525 #include <linux/kobject.h>
9526 #include <linux/latencytop.h>
9527 #include <linux/cred.h>
9528 +#include <linux/pid.h>
9530 #include <asm/processor.h>
9532 @@ -175,12 +175,13 @@ extern unsigned long long time_sync_thre
9533 #define TASK_UNINTERRUPTIBLE 2
9534 #define __TASK_STOPPED 4
9535 #define __TASK_TRACED 8
9536 +#define TASK_ONHOLD 16
9537 /* in tsk->exit_state */
9538 -#define EXIT_ZOMBIE 16
9539 -#define EXIT_DEAD 32
9540 +#define EXIT_ZOMBIE 32
9541 +#define EXIT_DEAD 64
9542 /* in tsk->state again */
9543 -#define TASK_DEAD 64
9544 -#define TASK_WAKEKILL 128
9545 +#define TASK_DEAD 128
9546 +#define TASK_WAKEKILL 256
9548 /* Convenience macros for the sake of set_task_state */
9549 #define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
9550 @@ -358,25 +359,27 @@ extern void arch_unmap_area_topdown(stru
9551 * The mm counters are not protected by its page_table_lock,
9552 * so must be incremented atomically.
9554 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9555 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9556 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9557 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9558 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9560 +#define __set_mm_counter(mm, member, value) \
9561 + atomic_long_set(&(mm)->_##member, value)
9562 +#define get_mm_counter(mm, member) \
9563 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9564 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
9566 * The mm counters are protected by its page_table_lock,
9567 * so can be incremented directly.
9569 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9570 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9571 #define get_mm_counter(mm, member) ((mm)->_##member)
9572 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9573 -#define inc_mm_counter(mm, member) (mm)->_##member++
9574 -#define dec_mm_counter(mm, member) (mm)->_##member--
9576 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
9578 +#define set_mm_counter(mm, member, value) \
9579 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9580 +#define add_mm_counter(mm, member, value) \
9581 + vx_ ## member ## pages_add((mm), (value))
9582 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9583 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9585 #define get_mm_rss(mm) \
9586 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9587 #define update_hiwater_rss(mm) do { \
9588 @@ -1048,7 +1051,9 @@ struct task_struct {
9589 const struct sched_class *sched_class;
9590 struct sched_entity se;
9591 struct sched_rt_entity rt;
9593 +#ifdef CONFIG_VSERVER_HARDCPU
9594 + struct list_head hq;
9596 #ifdef CONFIG_PREEMPT_NOTIFIERS
9597 /* list of struct preempt_notifier: */
9598 struct hlist_head preempt_notifiers;
9599 @@ -1200,6 +1205,14 @@ struct task_struct {
9603 +/* vserver context data */
9604 + struct vx_info *vx_info;
9605 + struct nx_info *nx_info;
9611 /* Thread group tracking */
9614 @@ -1386,6 +1399,11 @@ struct pid_namespace;
9615 * see also pid_nr() etc in include/linux/pid.h
9618 +#include <linux/vserver/base.h>
9619 +#include <linux/vserver/context.h>
9620 +#include <linux/vserver/debug.h>
9621 +#include <linux/vserver/pid.h>
9623 static inline pid_t task_pid_nr(struct task_struct *tsk)
9626 @@ -1395,7 +1413,7 @@ pid_t task_pid_nr_ns(struct task_struct
9628 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9630 - return pid_vnr(task_pid(tsk));
9631 + return vx_map_pid(pid_vnr(task_pid(tsk)));
9635 @@ -1408,7 +1426,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9637 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9639 - return pid_vnr(task_tgid(tsk));
9640 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9644 diff -NurpP --minimal linux-2.6.27.25/include/linux/shmem_fs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/shmem_fs.h
9645 --- linux-2.6.27.25/include/linux/shmem_fs.h 2008-10-13 14:52:09.000000000 +0200
9646 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/shmem_fs.h 2008-10-13 14:54:20.000000000 +0200
9649 #define SHMEM_NR_DIRECT 16
9651 +#define TMPFS_SUPER_MAGIC 0x01021994
9654 struct shmem_inode_info {
9656 unsigned long flags;
9657 diff -NurpP --minimal linux-2.6.27.25/include/linux/stat.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/stat.h
9658 --- linux-2.6.27.25/include/linux/stat.h 2008-07-13 23:51:29.000000000 +0200
9659 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/stat.h 2008-10-13 14:54:20.000000000 +0200
9660 @@ -66,6 +66,7 @@ struct kstat {
9667 struct timespec atime;
9668 diff -NurpP --minimal linux-2.6.27.25/include/linux/sunrpc/auth.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/sunrpc/auth.h
9669 --- linux-2.6.27.25/include/linux/sunrpc/auth.h 2008-07-13 23:51:29.000000000 +0200
9670 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/sunrpc/auth.h 2008-10-13 14:54:20.000000000 +0200
9676 struct group_info *group_info;
9677 unsigned char machine_cred : 1;
9679 diff -NurpP --minimal linux-2.6.27.25/include/linux/sunrpc/clnt.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/sunrpc/clnt.h
9680 --- linux-2.6.27.25/include/linux/sunrpc/clnt.h 2008-10-13 14:52:09.000000000 +0200
9681 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/sunrpc/clnt.h 2008-10-13 14:54:20.000000000 +0200
9682 @@ -43,7 +43,8 @@ struct rpc_clnt {
9683 unsigned int cl_softrtry : 1,/* soft timeouts */
9684 cl_discrtry : 1,/* disconnect before retry */
9685 cl_autobind : 1,/* use getport() */
9686 - cl_chatty : 1;/* be verbose */
9687 + cl_chatty : 1,/* be verbose */
9688 + cl_tag : 1;/* context tagging */
9690 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9691 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9692 diff -NurpP --minimal linux-2.6.27.25/include/linux/syscalls.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/syscalls.h
9693 --- linux-2.6.27.25/include/linux/syscalls.h 2009-06-15 17:18:32.000000000 +0200
9694 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/syscalls.h 2009-02-22 22:58:33.000000000 +0100
9695 @@ -364,6 +364,8 @@ asmlinkage long sys_symlink(const char _
9696 asmlinkage long sys_unlink(const char __user *pathname);
9697 asmlinkage long sys_rename(const char __user *oldname,
9698 const char __user *newname);
9699 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9701 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9702 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9704 diff -NurpP --minimal linux-2.6.27.25/include/linux/sysctl.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/sysctl.h
9705 --- linux-2.6.27.25/include/linux/sysctl.h 2008-10-13 14:52:09.000000000 +0200
9706 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/sysctl.h 2008-10-13 14:54:20.000000000 +0200
9707 @@ -70,6 +70,7 @@ enum
9708 CTL_ABI=9, /* Binary emulation */
9709 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9710 CTL_ARLAN=254, /* arlan wireless driver */
9711 + CTL_VSERVER=4242, /* Linux-VServer debug */
9712 CTL_S390DBF=5677, /* s390 debug */
9713 CTL_SUNRPC=7249, /* sunrpc debug */
9714 CTL_PM=9899, /* frv power management */
9715 @@ -104,6 +105,7 @@ enum
9717 KERN_PANIC=15, /* int: panic timeout */
9718 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9719 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9721 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9722 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9723 diff -NurpP --minimal linux-2.6.27.25/include/linux/sysfs.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/sysfs.h
9724 --- linux-2.6.27.25/include/linux/sysfs.h 2008-10-13 14:52:09.000000000 +0200
9725 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/sysfs.h 2008-10-13 14:54:20.000000000 +0200
9727 #include <linux/list.h>
9728 #include <asm/atomic.h>
9730 +#define SYSFS_SUPER_MAGIC 0x62656572
9735 diff -NurpP --minimal linux-2.6.27.25/include/linux/time.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/time.h
9736 --- linux-2.6.27.25/include/linux/time.h 2009-06-15 17:18:32.000000000 +0200
9737 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/time.h 2009-02-03 17:59:04.000000000 +0100
9738 @@ -180,6 +180,9 @@ static __always_inline void timespec_add
9739 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9743 +#include <linux/vs_time.h>
9745 #endif /* __KERNEL__ */
9747 #define NFDBITS __NFDBITS
9748 diff -NurpP --minimal linux-2.6.27.25/include/linux/types.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/types.h
9749 --- linux-2.6.27.25/include/linux/types.h 2008-07-13 23:51:29.000000000 +0200
9750 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/types.h 2008-10-13 14:54:20.000000000 +0200
9751 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
9752 typedef __kernel_gid32_t gid_t;
9753 typedef __kernel_uid16_t uid16_t;
9754 typedef __kernel_gid16_t gid16_t;
9755 +typedef unsigned int xid_t;
9756 +typedef unsigned int nid_t;
9757 +typedef unsigned int tag_t;
9759 typedef unsigned long uintptr_t;
9761 diff -NurpP --minimal linux-2.6.27.25/include/linux/vroot.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vroot.h
9762 --- linux-2.6.27.25/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9763 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vroot.h 2008-10-13 14:54:20.000000000 +0200
9767 + * include/linux/vroot.h
9769 + * written by Herbert Pötzl, 9/11/2002
9770 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9772 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9773 + * Redistribution of this file is permitted under the
9774 + * GNU General Public License.
9777 +#ifndef _LINUX_VROOT_H
9778 +#define _LINUX_VROOT_H
9783 +/* Possible states of device */
9789 +struct vroot_device {
9793 + struct semaphore vr_ctl_mutex;
9794 + struct block_device *vr_device;
9799 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9801 +extern int register_vroot_grb(vroot_grb_func *);
9802 +extern int unregister_vroot_grb(vroot_grb_func *);
9804 +#endif /* __KERNEL__ */
9806 +#define MAX_VROOT_DEFAULT 8
9809 + * IOCTL commands --- we will commandeer 0x56 ('V')
9812 +#define VROOT_SET_DEV 0x5600
9813 +#define VROOT_CLR_DEV 0x5601
9815 +#endif /* _LINUX_VROOT_H */
9816 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_base.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_base.h
9817 --- linux-2.6.27.25/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9818 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_base.h 2008-10-13 14:54:20.000000000 +0200
9823 +#include "vserver/base.h"
9824 +#include "vserver/check.h"
9825 +#include "vserver/debug.h"
9828 +#warning duplicate inclusion
9830 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_context.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_context.h
9831 --- linux-2.6.27.25/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9832 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_context.h 2008-10-13 14:54:20.000000000 +0200
9834 +#ifndef _VS_CONTEXT_H
9835 +#define _VS_CONTEXT_H
9837 +#include "vserver/base.h"
9838 +#include "vserver/check.h"
9839 +#include "vserver/context.h"
9840 +#include "vserver/history.h"
9841 +#include "vserver/debug.h"
9843 +#include <linux/sched.h>
9846 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9848 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9849 + const char *_file, int _line, void *_here)
9854 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9855 + vxi, vxi ? vxi->vx_id : 0,
9856 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9858 + __vxh_get_vx_info(vxi, _here);
9860 + atomic_inc(&vxi->vx_usecnt);
9865 +extern void free_vx_info(struct vx_info *);
9867 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9869 +static inline void __put_vx_info(struct vx_info *vxi,
9870 + const char *_file, int _line, void *_here)
9875 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9876 + vxi, vxi ? vxi->vx_id : 0,
9877 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9879 + __vxh_put_vx_info(vxi, _here);
9881 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9882 + free_vx_info(vxi);
9886 +#define init_vx_info(p, i) \
9887 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9889 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9890 + const char *_file, int _line, void *_here)
9893 + vxlprintk(VXD_CBIT(xid, 3),
9894 + "init_vx_info(%p[#%d.%d])",
9895 + vxi, vxi ? vxi->vx_id : 0,
9896 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9898 + __vxh_init_vx_info(vxi, vxp, _here);
9900 + atomic_inc(&vxi->vx_usecnt);
9906 +#define set_vx_info(p, i) \
9907 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9909 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9910 + const char *_file, int _line, void *_here)
9912 + struct vx_info *vxo;
9917 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9918 + vxi, vxi ? vxi->vx_id : 0,
9919 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9921 + __vxh_set_vx_info(vxi, vxp, _here);
9923 + atomic_inc(&vxi->vx_usecnt);
9924 + vxo = xchg(vxp, vxi);
9929 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9931 +static inline void __clr_vx_info(struct vx_info **vxp,
9932 + const char *_file, int _line, void *_here)
9934 + struct vx_info *vxo;
9936 + vxo = xchg(vxp, NULL);
9940 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9941 + vxo, vxo ? vxo->vx_id : 0,
9942 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9944 + __vxh_clr_vx_info(vxo, vxp, _here);
9946 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9947 + free_vx_info(vxo);
9951 +#define claim_vx_info(v, p) \
9952 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9954 +static inline void __claim_vx_info(struct vx_info *vxi,
9955 + struct task_struct *task,
9956 + const char *_file, int _line, void *_here)
9958 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9959 + vxi, vxi ? vxi->vx_id : 0,
9960 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9961 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9962 + task, _file, _line);
9963 + __vxh_claim_vx_info(vxi, task, _here);
9965 + atomic_inc(&vxi->vx_tasks);
9969 +extern void unhash_vx_info(struct vx_info *);
9971 +#define release_vx_info(v, p) \
9972 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9974 +static inline void __release_vx_info(struct vx_info *vxi,
9975 + struct task_struct *task,
9976 + const char *_file, int _line, void *_here)
9978 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9979 + vxi, vxi ? vxi->vx_id : 0,
9980 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9981 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9982 + task, _file, _line);
9983 + __vxh_release_vx_info(vxi, task, _here);
9987 + if (atomic_dec_and_test(&vxi->vx_tasks))
9988 + unhash_vx_info(vxi);
9992 +#define task_get_vx_info(p) \
9993 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9995 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9996 + const char *_file, int _line, void *_here)
9998 + struct vx_info *vxi;
10001 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
10002 + p, _file, _line);
10003 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
10009 +static inline void __wakeup_vx_info(struct vx_info *vxi)
10011 + if (waitqueue_active(&vxi->vx_wait))
10012 + wake_up_interruptible(&vxi->vx_wait);
10016 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
10018 +static inline void __enter_vx_info(struct vx_info *vxi,
10019 + struct vx_info_save *vxis, const char *_file, int _line)
10021 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
10022 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
10023 + current->xid, current->vx_info, _file, _line);
10024 + vxis->vxi = xchg(¤t->vx_info, vxi);
10025 + vxis->xid = current->xid;
10026 + current->xid = vxi ? vxi->vx_id : 0;
10029 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
10031 +static inline void __leave_vx_info(struct vx_info_save *vxis,
10032 + const char *_file, int _line)
10034 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
10035 + vxis, vxis->xid, vxis->vxi, current,
10036 + current->xid, current->vx_info, _file, _line);
10037 + (void)xchg(¤t->vx_info, vxis->vxi);
10038 + current->xid = vxis->xid;
10042 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
10044 + vxis->vxi = xchg(¤t->vx_info, NULL);
10045 + vxis->xid = xchg(¤t->xid, (xid_t)0);
10048 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
10050 + (void)xchg(¤t->xid, vxis->xid);
10051 + (void)xchg(¤t->vx_info, vxis->vxi);
10054 +extern void exit_vx_info(struct task_struct *, int);
10055 +extern void exit_vx_info_early(struct task_struct *, int);
10059 +#warning duplicate inclusion
10061 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_cowbl.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_cowbl.h
10062 --- linux-2.6.27.25/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
10063 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_cowbl.h 2008-10-13 14:54:20.000000000 +0200
10065 +#ifndef _VS_COWBL_H
10066 +#define _VS_COWBL_H
10068 +#include <linux/fs.h>
10069 +#include <linux/dcache.h>
10070 +#include <linux/namei.h>
10072 +extern struct dentry *cow_break_link(const char *pathname);
10074 +static inline int cow_check_and_break(struct path *path)
10076 + struct inode *inode = path->dentry->d_inode;
10079 + /* do we need this check? */
10080 + if (IS_RDONLY(inode))
10083 + if (IS_COW(inode)) {
10084 + if (IS_COW_LINK(inode)) {
10085 + struct dentry *new_dentry, *old_dentry = path->dentry;
10088 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
10092 + pp = d_path(path, buf, PATH_MAX);
10093 + new_dentry = cow_break_link(pp);
10095 + if (!IS_ERR(new_dentry)) {
10096 + path->dentry = new_dentry;
10097 + dput(old_dentry);
10099 + error = PTR_ERR(new_dentry);
10101 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
10102 + inode->i_ctime = CURRENT_TIME;
10103 + mark_inode_dirty(inode);
10110 +#warning duplicate inclusion
10112 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_cvirt.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_cvirt.h
10113 --- linux-2.6.27.25/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
10114 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_cvirt.h 2008-10-13 14:54:20.000000000 +0200
10116 +#ifndef _VS_CVIRT_H
10117 +#define _VS_CVIRT_H
10119 +#include "vserver/cvirt.h"
10120 +#include "vserver/context.h"
10121 +#include "vserver/base.h"
10122 +#include "vserver/check.h"
10123 +#include "vserver/debug.h"
10126 +static inline void vx_activate_task(struct task_struct *p)
10128 + struct vx_info *vxi;
10130 + if ((vxi = p->vx_info)) {
10131 + vx_update_load(vxi);
10132 + atomic_inc(&vxi->cvirt.nr_running);
10136 +static inline void vx_deactivate_task(struct task_struct *p)
10138 + struct vx_info *vxi;
10140 + if ((vxi = p->vx_info)) {
10141 + vx_update_load(vxi);
10142 + atomic_dec(&vxi->cvirt.nr_running);
10146 +static inline void vx_uninterruptible_inc(struct task_struct *p)
10148 + struct vx_info *vxi;
10150 + if ((vxi = p->vx_info))
10151 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
10154 +static inline void vx_uninterruptible_dec(struct task_struct *p)
10156 + struct vx_info *vxi;
10158 + if ((vxi = p->vx_info))
10159 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
10164 +#warning duplicate inclusion
10166 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_device.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_device.h
10167 --- linux-2.6.27.25/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
10168 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_device.h 2008-10-13 14:54:20.000000000 +0200
10170 +#ifndef _VS_DEVICE_H
10171 +#define _VS_DEVICE_H
10173 +#include "vserver/base.h"
10174 +#include "vserver/device.h"
10175 +#include "vserver/debug.h"
10178 +#ifdef CONFIG_VSERVER_DEVICE
10180 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
10182 +#define vs_device_perm(v, d, m, p) \
10183 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
10188 +int vs_map_device(struct vx_info *vxi,
10189 + dev_t device, dev_t *target, umode_t mode)
10192 + *target = device;
10196 +#define vs_device_perm(v, d, m, p) ((p) == (p))
10201 +#define vs_map_chrdev(d, t, p) \
10202 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
10203 +#define vs_map_blkdev(d, t, p) \
10204 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
10206 +#define vs_chrdev_perm(d, p) \
10207 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
10208 +#define vs_blkdev_perm(d, p) \
10209 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
10213 +#warning duplicate inclusion
10215 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_dlimit.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_dlimit.h
10216 --- linux-2.6.27.25/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
10217 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_dlimit.h 2008-10-13 14:54:20.000000000 +0200
10219 +#ifndef _VS_DLIMIT_H
10220 +#define _VS_DLIMIT_H
10222 +#include <linux/fs.h>
10224 +#include "vserver/dlimit.h"
10225 +#include "vserver/base.h"
10226 +#include "vserver/debug.h"
10229 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
10231 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
10232 + const char *_file, int _line)
10236 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
10237 + dli, dli ? dli->dl_tag : 0,
10238 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10240 + atomic_inc(&dli->dl_usecnt);
10245 +#define free_dl_info(i) \
10246 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
10248 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
10250 +static inline void __put_dl_info(struct dl_info *dli,
10251 + const char *_file, int _line)
10255 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10256 + dli, dli ? dli->dl_tag : 0,
10257 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10259 + if (atomic_dec_and_test(&dli->dl_usecnt))
10260 + free_dl_info(dli);
10264 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10266 +static inline int __dl_alloc_space(struct super_block *sb,
10267 + tag_t tag, dlsize_t nr, const char *file, int line)
10269 + struct dl_info *dli = NULL;
10274 + dli = locate_dl_info(sb, tag);
10278 + spin_lock(&dli->dl_lock);
10279 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10281 + dli->dl_space_used += nr;
10282 + spin_unlock(&dli->dl_lock);
10283 + put_dl_info(dli);
10285 + vxlprintk(VXD_CBIT(dlim, 1),
10286 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10287 + sb, tag, __dlimit_char(dli), (long long)nr,
10288 + ret, file, line);
10292 +static inline void __dl_free_space(struct super_block *sb,
10293 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10295 + struct dl_info *dli = NULL;
10299 + dli = locate_dl_info(sb, tag);
10303 + spin_lock(&dli->dl_lock);
10304 + if (dli->dl_space_used > nr)
10305 + dli->dl_space_used -= nr;
10307 + dli->dl_space_used = 0;
10308 + spin_unlock(&dli->dl_lock);
10309 + put_dl_info(dli);
10311 + vxlprintk(VXD_CBIT(dlim, 1),
10312 + "FREE (%p,#%d)%c %lld bytes",
10313 + sb, tag, __dlimit_char(dli), (long long)nr,
10317 +static inline int __dl_alloc_inode(struct super_block *sb,
10318 + tag_t tag, const char *_file, int _line)
10320 + struct dl_info *dli;
10323 + dli = locate_dl_info(sb, tag);
10327 + spin_lock(&dli->dl_lock);
10328 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
10330 + dli->dl_inodes_used++;
10331 + spin_unlock(&dli->dl_lock);
10332 + put_dl_info(dli);
10334 + vxlprintk(VXD_CBIT(dlim, 0),
10335 + "ALLOC (%p,#%d)%c inode (%d)",
10336 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10340 +static inline void __dl_free_inode(struct super_block *sb,
10341 + tag_t tag, const char *_file, int _line)
10343 + struct dl_info *dli;
10345 + dli = locate_dl_info(sb, tag);
10349 + spin_lock(&dli->dl_lock);
10350 + if (dli->dl_inodes_used > 1)
10351 + dli->dl_inodes_used--;
10353 + dli->dl_inodes_used = 0;
10354 + spin_unlock(&dli->dl_lock);
10355 + put_dl_info(dli);
10357 + vxlprintk(VXD_CBIT(dlim, 0),
10358 + "FREE (%p,#%d)%c inode",
10359 + sb, tag, __dlimit_char(dli), _file, _line);
10362 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10363 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10364 + const char *_file, int _line)
10366 + struct dl_info *dli;
10367 + uint64_t broot, bfree;
10369 + dli = locate_dl_info(sb, tag);
10373 + spin_lock(&dli->dl_lock);
10374 + broot = (dli->dl_space_total -
10375 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10376 + >> sb->s_blocksize_bits;
10377 + bfree = (dli->dl_space_total - dli->dl_space_used)
10378 + >> sb->s_blocksize_bits;
10379 + spin_unlock(&dli->dl_lock);
10381 + vxlprintk(VXD_CBIT(dlim, 2),
10382 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10383 + (long long)bfree, (long long)broot,
10384 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10386 + if (free_blocks) {
10387 + if (*free_blocks > bfree)
10388 + *free_blocks = bfree;
10390 + if (root_blocks) {
10391 + if (*root_blocks > broot)
10392 + *root_blocks = broot;
10394 + put_dl_info(dli);
10397 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
10398 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10399 + __FILE__, __LINE__ )
10401 +#define DLIMIT_FREE_SPACE(in, bytes) \
10402 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10403 + __FILE__, __LINE__ )
10405 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
10406 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
10407 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10408 + __FILE__, __LINE__ )
10410 +#define DLIMIT_FREE_BLOCK(in, nr) \
10411 + __dl_free_space((in)->i_sb, (in)->i_tag, \
10412 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10413 + __FILE__, __LINE__ )
10416 +#define DLIMIT_ALLOC_INODE(in) \
10417 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10419 +#define DLIMIT_FREE_INODE(in) \
10420 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10423 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
10424 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10428 +#warning duplicate inclusion
10430 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/base.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/base.h
10431 --- linux-2.6.27.25/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10432 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/base.h 2008-10-13 14:54:20.000000000 +0200
10434 +#ifndef _VX_BASE_H
10435 +#define _VX_BASE_H
10438 +/* context state changes */
10450 +#define vx_task_xid(t) ((t)->xid)
10452 +#define vx_current_xid() vx_task_xid(current)
10454 +#define current_vx_info() (current->vx_info)
10457 +#define nx_task_nid(t) ((t)->nid)
10459 +#define nx_current_nid() nx_task_nid(current)
10461 +#define current_nx_info() (current->nx_info)
10464 +/* generic flag merging */
10466 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10468 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10470 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10472 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10475 +/* context flags */
10477 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10479 +#define vx_current_flags() __vx_flags(current->vx_info)
10481 +#define vx_info_flags(v, m, f) \
10482 + vs_check_flags(__vx_flags(v), m, f)
10484 +#define task_vx_flags(t, m, f) \
10485 + ((t) && vx_info_flags((t)->vx_info, m, f))
10487 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
10490 +/* context caps */
10492 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10494 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
10496 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10498 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
10502 +/* network flags */
10504 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10506 +#define nx_current_flags() __nx_flags(current->nx_info)
10508 +#define nx_info_flags(n, m, f) \
10509 + vs_check_flags(__nx_flags(n), m, f)
10511 +#define task_nx_flags(t, m, f) \
10512 + ((t) && nx_info_flags((t)->nx_info, m, f))
10514 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
10517 +/* network caps */
10519 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10521 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
10523 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10525 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
10528 +/* context mask capabilities */
10530 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10532 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10534 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
10537 +/* context bcap mask */
10539 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10541 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
10544 +/* mask given bcaps */
10546 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10548 +#define vx_mbcaps(c) vx_info_mbcaps(current->vx_info, c)
10551 +/* masked cap_bset */
10553 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10555 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
10558 +#define vx_info_mbcap(v, b) \
10559 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10560 + vx_info_bcaps(v, b) : (b))
10562 +#define task_vx_mbcap(t, b) \
10563 + vx_info_mbcap((t)->vx_info, (t)->b)
10565 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10568 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10570 +#define vx_capable(b, c) (capable(b) || \
10571 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
10573 +#define nx_capable(b, c) (capable(b) || \
10574 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
10576 +#define vx_current_initpid(n) \
10577 + (current->vx_info && \
10578 + (current->vx_info->vx_initpid == (n)))
10581 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10583 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10586 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10588 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10591 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cacct_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct_cmd.h
10592 --- linux-2.6.27.25/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10593 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct_cmd.h 2008-10-13 14:54:20.000000000 +0200
10595 +#ifndef _VX_CACCT_CMD_H
10596 +#define _VX_CACCT_CMD_H
10599 +/* virtual host info name commands */
10601 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10603 +struct vcmd_sock_stat_v0 {
10605 + uint32_t count[3];
10606 + uint64_t total[3];
10612 +#include <linux/compiler.h>
10614 +extern int vc_sock_stat(struct vx_info *, void __user *);
10616 +#endif /* __KERNEL__ */
10617 +#endif /* _VX_CACCT_CMD_H */
10618 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cacct_def.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct_def.h
10619 --- linux-2.6.27.25/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10620 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct_def.h 2008-10-13 14:54:20.000000000 +0200
10622 +#ifndef _VX_CACCT_DEF_H
10623 +#define _VX_CACCT_DEF_H
10625 +#include <asm/atomic.h>
10626 +#include <linux/vserver/cacct.h>
10629 +struct _vx_sock_acc {
10630 + atomic_long_t count;
10631 + atomic_long_t total;
10634 +/* context sub struct */
10636 +struct _vx_cacct {
10637 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10638 + atomic_t slab[8];
10639 + atomic_t page[6][8];
10642 +#ifdef CONFIG_VSERVER_DEBUG
10644 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10648 + printk("\t_vx_cacct:");
10649 + for (i = 0; i < 6; i++) {
10650 + struct _vx_sock_acc *ptr = cacct->sock[i];
10652 + printk("\t [%d] =", i);
10653 + for (j = 0; j < 3; j++) {
10654 + printk(" [%d] = %8lu, %8lu", j,
10655 + atomic_long_read(&ptr[j].count),
10656 + atomic_long_read(&ptr[j].total));
10664 +#endif /* _VX_CACCT_DEF_H */
10665 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cacct.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct.h
10666 --- linux-2.6.27.25/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10667 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct.h 2008-10-13 14:54:20.000000000 +0200
10669 +#ifndef _VX_CACCT_H
10670 +#define _VX_CACCT_H
10673 +enum sock_acc_field {
10674 + VXA_SOCK_UNSPEC = 0,
10680 + VXA_SOCK_SIZE /* array size */
10683 +#endif /* _VX_CACCT_H */
10684 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cacct_int.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct_int.h
10685 --- linux-2.6.27.25/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10686 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cacct_int.h 2008-10-13 14:54:20.000000000 +0200
10688 +#ifndef _VX_CACCT_INT_H
10689 +#define _VX_CACCT_INT_H
10695 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10697 + return atomic_long_read(&cacct->sock[type][pos].count);
10702 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10704 + return atomic_long_read(&cacct->sock[type][pos].total);
10707 +#endif /* __KERNEL__ */
10708 +#endif /* _VX_CACCT_INT_H */
10709 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/check.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/check.h
10710 --- linux-2.6.27.25/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10711 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/check.h 2008-10-13 14:54:20.000000000 +0200
10713 +#ifndef _VS_CHECK_H
10714 +#define _VS_CHECK_H
10717 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10719 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10720 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10722 +#define MIN_D_CONTEXT 65536
10725 +/* check conditions */
10727 +#define VS_ADMIN 0x0001
10728 +#define VS_WATCH 0x0002
10729 +#define VS_HIDE 0x0004
10730 +#define VS_HOSTID 0x0008
10732 +#define VS_IDENT 0x0010
10733 +#define VS_EQUIV 0x0020
10734 +#define VS_PARENT 0x0040
10735 +#define VS_CHILD 0x0080
10737 +#define VS_ARG_MASK 0x00F0
10739 +#define VS_DYNAMIC 0x0100
10740 +#define VS_STATIC 0x0200
10742 +#define VS_ATR_MASK 0x0F00
10744 +#ifdef CONFIG_VSERVER_PRIVACY
10745 +#define VS_ADMIN_P (0)
10746 +#define VS_WATCH_P (0)
10748 +#define VS_ADMIN_P VS_ADMIN
10749 +#define VS_WATCH_P VS_WATCH
10752 +#define VS_HARDIRQ 0x1000
10753 +#define VS_SOFTIRQ 0x2000
10754 +#define VS_IRQ 0x4000
10756 +#define VS_IRQ_MASK 0xF000
10758 +#include <linux/hardirq.h>
10761 + * check current context for ADMIN/WATCH and
10762 + * optionally against supplied argument
10764 +static inline int __vs_check(int cid, int id, unsigned int mode)
10766 + if (mode & VS_ARG_MASK) {
10767 + if ((mode & VS_IDENT) && (id == cid))
10770 + if (mode & VS_ATR_MASK) {
10771 + if ((mode & VS_DYNAMIC) &&
10772 + (id >= MIN_D_CONTEXT) &&
10773 + (id <= MAX_S_CONTEXT))
10775 + if ((mode & VS_STATIC) &&
10776 + (id > 1) && (id < MIN_D_CONTEXT))
10779 + if (mode & VS_IRQ_MASK) {
10780 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10782 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10784 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10787 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10788 + ((mode & VS_WATCH) && (cid == 1)) ||
10789 + ((mode & VS_HOSTID) && (id == 0)));
10792 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10794 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10797 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10799 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10802 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/context_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/context_cmd.h
10803 --- linux-2.6.27.25/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10804 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/context_cmd.h 2008-10-13 14:54:20.000000000 +0200
10806 +#ifndef _VX_CONTEXT_CMD_H
10807 +#define _VX_CONTEXT_CMD_H
10810 +/* vinfo commands */
10812 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10815 +extern int vc_task_xid(uint32_t);
10817 +#endif /* __KERNEL__ */
10819 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10821 +struct vcmd_vx_info_v0 {
10823 + uint32_t initpid;
10824 + /* more to come */
10828 +extern int vc_vx_info(struct vx_info *, void __user *);
10830 +#endif /* __KERNEL__ */
10832 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10834 +struct vcmd_ctx_stat_v0 {
10837 + /* more to come */
10841 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10843 +#endif /* __KERNEL__ */
10845 +/* context commands */
10847 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10848 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10850 +struct vcmd_ctx_create {
10851 + uint64_t flagword;
10854 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10855 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10857 +struct vcmd_ctx_migrate {
10858 + uint64_t flagword;
10862 +extern int vc_ctx_create(uint32_t, void __user *);
10863 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10865 +#endif /* __KERNEL__ */
10868 +/* flag commands */
10870 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10871 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10873 +struct vcmd_ctx_flags_v0 {
10874 + uint64_t flagword;
10879 +extern int vc_get_cflags(struct vx_info *, void __user *);
10880 +extern int vc_set_cflags(struct vx_info *, void __user *);
10882 +#endif /* __KERNEL__ */
10885 +/* context caps commands */
10887 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10888 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10890 +struct vcmd_ctx_caps_v1 {
10896 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10897 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10899 +#endif /* __KERNEL__ */
10902 +/* bcaps commands */
10904 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10905 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10907 +struct vcmd_bcaps {
10913 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10914 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10916 +#endif /* __KERNEL__ */
10921 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10922 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10924 +struct vcmd_badness_v0 {
10929 +extern int vc_get_badness(struct vx_info *, void __user *);
10930 +extern int vc_set_badness(struct vx_info *, void __user *);
10932 +#endif /* __KERNEL__ */
10933 +#endif /* _VX_CONTEXT_CMD_H */
10934 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/context.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/context.h
10935 --- linux-2.6.27.25/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10936 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/context.h 2009-03-09 15:36:36.000000000 +0100
10938 +#ifndef _VX_CONTEXT_H
10939 +#define _VX_CONTEXT_H
10941 +#include <linux/types.h>
10942 +#include <linux/capability.h>
10945 +/* context flags */
10947 +#define VXF_INFO_SCHED 0x00000002
10948 +#define VXF_INFO_NPROC 0x00000004
10949 +#define VXF_INFO_PRIVATE 0x00000008
10951 +#define VXF_INFO_INIT 0x00000010
10952 +#define VXF_INFO_HIDE 0x00000020
10953 +#define VXF_INFO_ULIMIT 0x00000040
10954 +#define VXF_INFO_NSPACE 0x00000080
10956 +#define VXF_SCHED_HARD 0x00000100
10957 +#define VXF_SCHED_PRIO 0x00000200
10958 +#define VXF_SCHED_PAUSE 0x00000400
10960 +#define VXF_VIRT_MEM 0x00010000
10961 +#define VXF_VIRT_UPTIME 0x00020000
10962 +#define VXF_VIRT_CPU 0x00040000
10963 +#define VXF_VIRT_LOAD 0x00080000
10964 +#define VXF_VIRT_TIME 0x00100000
10966 +#define VXF_HIDE_MOUNT 0x01000000
10967 +/* was VXF_HIDE_NETIF 0x02000000 */
10968 +#define VXF_HIDE_VINFO 0x04000000
10970 +#define VXF_STATE_SETUP (1ULL << 32)
10971 +#define VXF_STATE_INIT (1ULL << 33)
10972 +#define VXF_STATE_ADMIN (1ULL << 34)
10974 +#define VXF_SC_HELPER (1ULL << 36)
10975 +#define VXF_REBOOT_KILL (1ULL << 37)
10976 +#define VXF_PERSISTENT (1ULL << 38)
10978 +#define VXF_FORK_RSS (1ULL << 48)
10979 +#define VXF_PROLIFIC (1ULL << 49)
10981 +#define VXF_IGNEG_NICE (1ULL << 52)
10983 +#define VXF_ONE_TIME (0x0007ULL << 32)
10985 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10988 +/* context migration */
10990 +#define VXM_SET_INIT 0x00000001
10991 +#define VXM_SET_REAPER 0x00000002
10993 +/* context caps */
10995 +#define VXC_CAP_MASK 0x00000000
10997 +#define VXC_SET_UTSNAME 0x00000001
10998 +#define VXC_SET_RLIMIT 0x00000002
10999 +#define VXC_FS_SECURITY 0x00000004
11001 +/* was VXC_RAW_ICMP 0x00000100 */
11002 +#define VXC_SYSLOG 0x00001000
11004 +#define VXC_SECURE_MOUNT 0x00010000
11005 +#define VXC_SECURE_REMOUNT 0x00020000
11006 +#define VXC_BINARY_MOUNT 0x00040000
11008 +#define VXC_QUOTA_CTL 0x00100000
11009 +#define VXC_ADMIN_MAPPER 0x00200000
11010 +#define VXC_ADMIN_CLOOP 0x00400000
11012 +#define VXC_KTHREAD 0x01000000
11017 +#include <linux/list.h>
11018 +#include <linux/spinlock.h>
11019 +#include <linux/rcupdate.h>
11021 +#include "limit_def.h"
11022 +#include "sched_def.h"
11023 +#include "cvirt_def.h"
11024 +#include "cacct_def.h"
11025 +#include "device_def.h"
11027 +#define VX_SPACES 2
11029 +struct _vx_info_pc {
11030 + struct _vx_sched_pc sched_pc;
11031 + struct _vx_cvirt_pc cvirt_pc;
11035 + struct hlist_node vx_hlist; /* linked list of contexts */
11036 + xid_t vx_id; /* context id */
11037 + atomic_t vx_usecnt; /* usage count */
11038 + atomic_t vx_tasks; /* tasks count */
11039 + struct vx_info *vx_parent; /* parent context */
11040 + int vx_state; /* context state */
11042 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
11043 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
11044 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
11046 + uint64_t vx_flags; /* context flags */
11047 + uint64_t vx_ccaps; /* context caps (vserver) */
11048 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11049 + // kernel_cap_t vx_cap_bset; /* the guest's bset */
11051 + struct task_struct *vx_reaper; /* guest reaper process */
11052 + pid_t vx_initpid; /* PID of guest init */
11053 + int64_t vx_badness_bias; /* OOM points bias */
11055 + struct _vx_limit limit; /* vserver limits */
11056 + struct _vx_sched sched; /* vserver scheduler */
11057 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11058 + struct _vx_cacct cacct; /* context accounting */
11060 + struct _vx_device dmap; /* default device map targets */
11062 +#ifndef CONFIG_SMP
11063 + struct _vx_info_pc info_pc; /* per cpu data */
11065 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11068 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11069 + int reboot_cmd; /* last sys_reboot() cmd */
11070 + int exit_code; /* last process exit code */
11072 + char vx_name[65]; /* vserver name */
11075 +#ifndef CONFIG_SMP
11076 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11077 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11079 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11080 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11083 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11086 +struct vx_info_save {
11087 + struct vx_info *vxi;
11092 +/* status flags */
11094 +#define VXS_HASHED 0x0001
11095 +#define VXS_PAUSED 0x0010
11096 +#define VXS_SHUTDOWN 0x0100
11097 +#define VXS_HELPER 0x1000
11098 +#define VXS_RELEASED 0x8000
11101 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11102 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11104 +extern struct vx_info *lookup_vx_info(int);
11105 +extern struct vx_info *lookup_or_create_vx_info(int);
11107 +extern int get_xid_list(int, unsigned int *, int);
11108 +extern int xid_is_hashed(xid_t);
11110 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11112 +extern long vs_state_change(struct vx_info *, unsigned int);
11115 +#endif /* __KERNEL__ */
11116 +#endif /* _VX_CONTEXT_H */
11117 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cvirt_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cvirt_cmd.h
11118 --- linux-2.6.27.25/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11119 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cvirt_cmd.h 2008-10-13 14:54:20.000000000 +0200
11121 +#ifndef _VX_CVIRT_CMD_H
11122 +#define _VX_CVIRT_CMD_H
11125 +/* virtual host info name commands */
11127 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11128 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11130 +struct vcmd_vhi_name_v0 {
11136 +enum vhi_name_field {
11137 + VHIN_CONTEXT = 0,
11149 +#include <linux/compiler.h>
11151 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11152 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11154 +#endif /* __KERNEL__ */
11156 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11158 +struct vcmd_virt_stat_v0 {
11161 + uint32_t nr_threads;
11162 + uint32_t nr_running;
11163 + uint32_t nr_uninterruptible;
11164 + uint32_t nr_onhold;
11165 + uint32_t nr_forks;
11166 + uint32_t load[3];
11170 +extern int vc_virt_stat(struct vx_info *, void __user *);
11172 +#endif /* __KERNEL__ */
11173 +#endif /* _VX_CVIRT_CMD_H */
11174 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cvirt_def.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cvirt_def.h
11175 --- linux-2.6.27.25/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11176 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cvirt_def.h 2008-10-13 14:54:20.000000000 +0200
11178 +#ifndef _VX_CVIRT_DEF_H
11179 +#define _VX_CVIRT_DEF_H
11181 +#include <linux/jiffies.h>
11182 +#include <linux/spinlock.h>
11183 +#include <linux/wait.h>
11184 +#include <linux/time.h>
11185 +#include <asm/atomic.h>
11188 +struct _vx_usage_stat {
11192 + uint64_t softirq;
11198 +struct _vx_syslog {
11199 + wait_queue_head_t log_wait;
11200 + spinlock_t logbuf_lock; /* lock for the log buffer */
11202 + unsigned long log_start; /* next char to be read by syslog() */
11203 + unsigned long con_start; /* next char to be sent to consoles */
11204 + unsigned long log_end; /* most-recently-written-char + 1 */
11205 + unsigned long logged_chars; /* #chars since last read+clear operation */
11207 + char log_buf[1024];
11211 +/* context sub struct */
11213 +struct _vx_cvirt {
11214 + atomic_t nr_threads; /* number of current threads */
11215 + atomic_t nr_running; /* number of running threads */
11216 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11218 + atomic_t nr_onhold; /* processes on hold */
11219 + uint32_t onhold_last; /* jiffies when put on hold */
11221 + struct timeval bias_tv; /* time offset to the host */
11222 + struct timespec bias_idle;
11223 + struct timespec bias_uptime; /* context creation point */
11224 + uint64_t bias_clock; /* offset in clock_t */
11226 + spinlock_t load_lock; /* lock for the load averages */
11227 + atomic_t load_updates; /* nr of load updates done so far */
11228 + uint32_t load_last; /* last time load was calculated */
11229 + uint32_t load[3]; /* load averages 1,5,15 */
11231 + atomic_t total_forks; /* number of forks so far */
11233 + struct _vx_syslog syslog;
11236 +struct _vx_cvirt_pc {
11237 + struct _vx_usage_stat cpustat;
11241 +#ifdef CONFIG_VSERVER_DEBUG
11243 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11245 + printk("\t_vx_cvirt:\n");
11246 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11247 + atomic_read(&cvirt->nr_threads),
11248 + atomic_read(&cvirt->nr_running),
11249 + atomic_read(&cvirt->nr_uninterruptible),
11250 + atomic_read(&cvirt->nr_onhold));
11251 + /* add rest here */
11252 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11257 +#endif /* _VX_CVIRT_DEF_H */
11258 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/cvirt.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cvirt.h
11259 --- linux-2.6.27.25/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11260 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/cvirt.h 2008-10-13 14:54:20.000000000 +0200
11262 +#ifndef _VX_CVIRT_H
11263 +#define _VX_CVIRT_H
11270 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11275 +void vx_update_load(struct vx_info *);
11278 +int vx_do_syslog(int, char __user *, int);
11280 +#endif /* __KERNEL__ */
11281 +#endif /* _VX_CVIRT_H */
11282 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/debug_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/debug_cmd.h
11283 --- linux-2.6.27.25/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11284 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/debug_cmd.h 2008-10-13 14:54:20.000000000 +0200
11286 +#ifndef _VX_DEBUG_CMD_H
11287 +#define _VX_DEBUG_CMD_H
11290 +/* debug commands */
11292 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11294 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11295 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11297 +struct vcmd_read_history_v0 {
11300 + char __user *data;
11303 +struct vcmd_read_monitor_v0 {
11306 + char __user *data;
11312 +#ifdef CONFIG_COMPAT
11314 +#include <asm/compat.h>
11316 +struct vcmd_read_history_v0_x32 {
11319 + compat_uptr_t data_ptr;
11322 +struct vcmd_read_monitor_v0_x32 {
11325 + compat_uptr_t data_ptr;
11328 +#endif /* CONFIG_COMPAT */
11330 +extern int vc_dump_history(uint32_t);
11332 +extern int vc_read_history(uint32_t, void __user *);
11333 +extern int vc_read_monitor(uint32_t, void __user *);
11335 +#ifdef CONFIG_COMPAT
11337 +extern int vc_read_history_x32(uint32_t, void __user *);
11338 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11340 +#endif /* CONFIG_COMPAT */
11342 +#endif /* __KERNEL__ */
11343 +#endif /* _VX_DEBUG_CMD_H */
11344 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/debug.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/debug.h
11345 --- linux-2.6.27.25/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11346 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/debug.h 2008-10-13 14:54:20.000000000 +0200
11348 +#ifndef _VX_DEBUG_H
11349 +#define _VX_DEBUG_H
11352 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11353 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11354 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11356 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11357 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11358 +#define VXF_DEV "%p[%lu,%d:%d]"
11361 +#define vxd_path(p) \
11362 + ({ static char _buffer[PATH_MAX]; \
11363 + d_path(p, _buffer, sizeof(_buffer)); })
11365 +#define vxd_cond_path(n) \
11366 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11369 +#ifdef CONFIG_VSERVER_DEBUG
11371 +extern unsigned int vx_debug_switch;
11372 +extern unsigned int vx_debug_xid;
11373 +extern unsigned int vx_debug_nid;
11374 +extern unsigned int vx_debug_tag;
11375 +extern unsigned int vx_debug_net;
11376 +extern unsigned int vx_debug_limit;
11377 +extern unsigned int vx_debug_cres;
11378 +extern unsigned int vx_debug_dlim;
11379 +extern unsigned int vx_debug_quota;
11380 +extern unsigned int vx_debug_cvirt;
11381 +extern unsigned int vx_debug_space;
11382 +extern unsigned int vx_debug_misc;
11385 +#define VX_LOGLEVEL "vxD: "
11386 +#define VX_PROC_FMT "%p: "
11387 +#define VX_PROCESS current
11389 +#define vxdprintk(c, f, x...) \
11392 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11393 + VX_PROCESS , ##x); \
11396 +#define vxlprintk(c, f, x...) \
11399 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11402 +#define vxfprintk(c, f, x...) \
11405 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11411 +void dump_vx_info(struct vx_info *, int);
11412 +void dump_vx_info_inactive(int);
11414 +#else /* CONFIG_VSERVER_DEBUG */
11416 +#define vx_debug_switch 0
11417 +#define vx_debug_xid 0
11418 +#define vx_debug_nid 0
11419 +#define vx_debug_tag 0
11420 +#define vx_debug_net 0
11421 +#define vx_debug_limit 0
11422 +#define vx_debug_cres 0
11423 +#define vx_debug_dlim 0
11424 +#define vx_debug_cvirt 0
11426 +#define vxdprintk(x...) do { } while (0)
11427 +#define vxlprintk(x...) do { } while (0)
11428 +#define vxfprintk(x...) do { } while (0)
11430 +#endif /* CONFIG_VSERVER_DEBUG */
11433 +#ifdef CONFIG_VSERVER_WARN
11435 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11436 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11437 +#define VX_WARN_XID "[xid #%u] "
11438 +#define VX_WARN_NID "[nid #%u] "
11439 +#define VX_WARN_TAG "[tag #%u] "
11441 +#define vxwprintk(c, f, x...) \
11444 + printk(VX_WARNLEVEL f "\n", ##x); \
11447 +#else /* CONFIG_VSERVER_WARN */
11449 +#define vxwprintk(x...) do { } while (0)
11451 +#endif /* CONFIG_VSERVER_WARN */
11453 +#define vxwprintk_task(c, f, x...) \
11454 + vxwprintk(c, VX_WARN_TASK f, \
11455 + current->comm, current->pid, \
11456 + current->xid, current->nid, current->tag, ##x)
11457 +#define vxwprintk_xid(c, f, x...) \
11458 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11459 +#define vxwprintk_nid(c, f, x...) \
11460 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11461 +#define vxwprintk_tag(c, f, x...) \
11462 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11464 +#ifdef CONFIG_VSERVER_DEBUG
11465 +#define vxd_assert_lock(l) assert_spin_locked(l)
11466 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11467 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11469 +#define vxd_assert_lock(l) do { } while (0)
11470 +#define vxd_assert(c, f, x...) do { } while (0)
11474 +#endif /* _VX_DEBUG_H */
11475 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/device_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/device_cmd.h
11476 --- linux-2.6.27.25/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11477 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/device_cmd.h 2008-10-13 14:54:20.000000000 +0200
11479 +#ifndef _VX_DEVICE_CMD_H
11480 +#define _VX_DEVICE_CMD_H
11483 +/* device vserver commands */
11485 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11486 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11488 +struct vcmd_set_mapping_v0 {
11489 + const char __user *device;
11490 + const char __user *target;
11497 +#ifdef CONFIG_COMPAT
11499 +#include <asm/compat.h>
11501 +struct vcmd_set_mapping_v0_x32 {
11502 + compat_uptr_t device_ptr;
11503 + compat_uptr_t target_ptr;
11507 +#endif /* CONFIG_COMPAT */
11509 +#include <linux/compiler.h>
11511 +extern int vc_set_mapping(struct vx_info *, void __user *);
11512 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11514 +#ifdef CONFIG_COMPAT
11516 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11517 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11519 +#endif /* CONFIG_COMPAT */
11521 +#endif /* __KERNEL__ */
11522 +#endif /* _VX_DEVICE_CMD_H */
11523 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/device_def.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/device_def.h
11524 --- linux-2.6.27.25/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11525 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/device_def.h 2008-10-13 14:54:20.000000000 +0200
11527 +#ifndef _VX_DEVICE_DEF_H
11528 +#define _VX_DEVICE_DEF_H
11530 +#include <linux/types.h>
11532 +struct vx_dmap_target {
11537 +struct _vx_device {
11538 +#ifdef CONFIG_VSERVER_DEVICE
11539 + struct vx_dmap_target targets[2];
11543 +#endif /* _VX_DEVICE_DEF_H */
11544 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/device.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/device.h
11545 --- linux-2.6.27.25/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11546 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/device.h 2008-10-13 14:54:20.000000000 +0200
11548 +#ifndef _VX_DEVICE_H
11549 +#define _VX_DEVICE_H
11552 +#define DATTR_CREATE 0x00000001
11553 +#define DATTR_OPEN 0x00000002
11555 +#define DATTR_REMAP 0x00000010
11557 +#define DATTR_MASK 0x00000013
11560 +#else /* _VX_DEVICE_H */
11561 +#warning duplicate inclusion
11562 +#endif /* _VX_DEVICE_H */
11563 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/dlimit_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/dlimit_cmd.h
11564 --- linux-2.6.27.25/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11565 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/dlimit_cmd.h 2008-10-13 14:54:20.000000000 +0200
11567 +#ifndef _VX_DLIMIT_CMD_H
11568 +#define _VX_DLIMIT_CMD_H
11571 +/* dlimit vserver commands */
11573 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11574 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11576 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11577 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11579 +struct vcmd_ctx_dlimit_base_v0 {
11580 + const char __user *name;
11584 +struct vcmd_ctx_dlimit_v0 {
11585 + const char __user *name;
11586 + uint32_t space_used; /* used space in kbytes */
11587 + uint32_t space_total; /* maximum space in kbytes */
11588 + uint32_t inodes_used; /* used inodes */
11589 + uint32_t inodes_total; /* maximum inodes */
11590 + uint32_t reserved; /* reserved for root in % */
11594 +#define CDLIM_UNSET ((uint32_t)0UL)
11595 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11596 +#define CDLIM_KEEP ((uint32_t)~1UL)
11600 +#ifdef CONFIG_COMPAT
11602 +#include <asm/compat.h>
11604 +struct vcmd_ctx_dlimit_base_v0_x32 {
11605 + compat_uptr_t name_ptr;
11609 +struct vcmd_ctx_dlimit_v0_x32 {
11610 + compat_uptr_t name_ptr;
11611 + uint32_t space_used; /* used space in kbytes */
11612 + uint32_t space_total; /* maximum space in kbytes */
11613 + uint32_t inodes_used; /* used inodes */
11614 + uint32_t inodes_total; /* maximum inodes */
11615 + uint32_t reserved; /* reserved for root in % */
11619 +#endif /* CONFIG_COMPAT */
11621 +#include <linux/compiler.h>
11623 +extern int vc_add_dlimit(uint32_t, void __user *);
11624 +extern int vc_rem_dlimit(uint32_t, void __user *);
11626 +extern int vc_set_dlimit(uint32_t, void __user *);
11627 +extern int vc_get_dlimit(uint32_t, void __user *);
11629 +#ifdef CONFIG_COMPAT
11631 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11632 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11634 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11635 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11637 +#endif /* CONFIG_COMPAT */
11639 +#endif /* __KERNEL__ */
11640 +#endif /* _VX_DLIMIT_CMD_H */
11641 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/dlimit.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/dlimit.h
11642 --- linux-2.6.27.25/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11643 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/dlimit.h 2008-10-13 14:54:20.000000000 +0200
11645 +#ifndef _VX_DLIMIT_H
11646 +#define _VX_DLIMIT_H
11648 +#include "switch.h"
11653 +/* keep in sync with CDLIM_INFINITY */
11655 +#define DLIM_INFINITY (~0ULL)
11657 +#include <linux/spinlock.h>
11658 +#include <linux/rcupdate.h>
11660 +struct super_block;
11663 + struct hlist_node dl_hlist; /* linked list of contexts */
11664 + struct rcu_head dl_rcu; /* the rcu head */
11665 + tag_t dl_tag; /* context tag */
11666 + atomic_t dl_usecnt; /* usage count */
11667 + atomic_t dl_refcnt; /* reference count */
11669 + struct super_block *dl_sb; /* associated superblock */
11671 + spinlock_t dl_lock; /* protect the values */
11673 + unsigned long long dl_space_used; /* used space in bytes */
11674 + unsigned long long dl_space_total; /* maximum space in bytes */
11675 + unsigned long dl_inodes_used; /* used inodes */
11676 + unsigned long dl_inodes_total; /* maximum inodes */
11678 + unsigned int dl_nrlmult; /* non root limit mult */
11683 +extern void rcu_free_dl_info(struct rcu_head *);
11684 +extern void unhash_dl_info(struct dl_info *);
11686 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11691 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11693 +typedef uint64_t dlsize_t;
11695 +#endif /* __KERNEL__ */
11696 +#else /* _VX_DLIMIT_H */
11697 +#warning duplicate inclusion
11698 +#endif /* _VX_DLIMIT_H */
11699 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/global.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/global.h
11700 --- linux-2.6.27.25/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11701 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/global.h 2008-10-13 14:54:20.000000000 +0200
11703 +#ifndef _VX_GLOBAL_H
11704 +#define _VX_GLOBAL_H
11707 +extern atomic_t vx_global_ctotal;
11708 +extern atomic_t vx_global_cactive;
11710 +extern atomic_t nx_global_ctotal;
11711 +extern atomic_t nx_global_cactive;
11713 +extern atomic_t vs_global_nsproxy;
11714 +extern atomic_t vs_global_fs;
11715 +extern atomic_t vs_global_mnt_ns;
11716 +extern atomic_t vs_global_uts_ns;
11717 +extern atomic_t vs_global_ipc_ns;
11718 +extern atomic_t vs_global_user_ns;
11719 +extern atomic_t vs_global_pid_ns;
11722 +#endif /* _VX_GLOBAL_H */
11723 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/history.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/history.h
11724 --- linux-2.6.27.25/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11725 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/history.h 2008-10-13 14:54:20.000000000 +0200
11727 +#ifndef _VX_HISTORY_H
11728 +#define _VX_HISTORY_H
11733 + VXH_THROW_OOPS = 1,
11737 + VXH_INIT_VX_INFO,
11740 + VXH_CLAIM_VX_INFO,
11741 + VXH_RELEASE_VX_INFO,
11742 + VXH_ALLOC_VX_INFO,
11743 + VXH_DEALLOC_VX_INFO,
11744 + VXH_HASH_VX_INFO,
11745 + VXH_UNHASH_VX_INFO,
11747 + VXH_LOOKUP_VX_INFO,
11748 + VXH_CREATE_VX_INFO,
11751 +struct _vxhe_vxi {
11752 + struct vx_info *ptr;
11758 +struct _vxhe_set_clr {
11762 +struct _vxhe_loc_lookup {
11766 +struct _vx_hist_entry {
11768 + unsigned short seq;
11769 + unsigned short type;
11770 + struct _vxhe_vxi vxi;
11772 + struct _vxhe_set_clr sc;
11773 + struct _vxhe_loc_lookup ll;
11777 +#ifdef CONFIG_VSERVER_HISTORY
11779 +extern unsigned volatile int vxh_active;
11781 +struct _vx_hist_entry *vxh_advance(void *loc);
11785 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11787 + entry->vxi.ptr = vxi;
11789 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11790 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11791 + entry->vxi.xid = vxi->vx_id;
11796 +#define __HERE__ current_text_addr()
11798 +#define __VXH_BODY(__type, __data, __here) \
11799 + struct _vx_hist_entry *entry; \
11801 + preempt_disable(); \
11802 + entry = vxh_advance(__here); \
11804 + entry->type = __type; \
11805 + preempt_enable();
11808 + /* pass vxi only */
11810 +#define __VXH_SMPL \
11811 + __vxh_copy_vxi(entry, vxi)
11814 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11816 + __VXH_BODY(__type, __VXH_SMPL, __here)
11819 + /* pass vxi and data (void *) */
11821 +#define __VXH_DATA \
11822 + __vxh_copy_vxi(entry, vxi); \
11823 + entry->sc.data = data
11826 +void __vxh_data(struct vx_info *vxi, void *data,
11827 + int __type, void *__here)
11829 + __VXH_BODY(__type, __VXH_DATA, __here)
11832 + /* pass vxi and arg (long) */
11834 +#define __VXH_LONG \
11835 + __vxh_copy_vxi(entry, vxi); \
11836 + entry->ll.arg = arg
11839 +void __vxh_long(struct vx_info *vxi, long arg,
11840 + int __type, void *__here)
11842 + __VXH_BODY(__type, __VXH_LONG, __here)
11847 +void __vxh_throw_oops(void *__here)
11849 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11850 + /* prevent further acquisition */
11855 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11857 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11858 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11860 +#define __vxh_init_vx_info(v, d, h) \
11861 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11862 +#define __vxh_set_vx_info(v, d, h) \
11863 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11864 +#define __vxh_clr_vx_info(v, d, h) \
11865 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11867 +#define __vxh_claim_vx_info(v, d, h) \
11868 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11869 +#define __vxh_release_vx_info(v, d, h) \
11870 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11872 +#define vxh_alloc_vx_info(v) \
11873 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11874 +#define vxh_dealloc_vx_info(v) \
11875 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11877 +#define vxh_hash_vx_info(v) \
11878 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11879 +#define vxh_unhash_vx_info(v) \
11880 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11882 +#define vxh_loc_vx_info(v, l) \
11883 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11884 +#define vxh_lookup_vx_info(v, l) \
11885 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11886 +#define vxh_create_vx_info(v, l) \
11887 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11889 +extern void vxh_dump_history(void);
11892 +#else /* CONFIG_VSERVER_HISTORY */
11894 +#define __HERE__ 0
11896 +#define vxh_throw_oops() do { } while (0)
11898 +#define __vxh_get_vx_info(v, h) do { } while (0)
11899 +#define __vxh_put_vx_info(v, h) do { } while (0)
11901 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11902 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11903 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11905 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11906 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11908 +#define vxh_alloc_vx_info(v) do { } while (0)
11909 +#define vxh_dealloc_vx_info(v) do { } while (0)
11911 +#define vxh_hash_vx_info(v) do { } while (0)
11912 +#define vxh_unhash_vx_info(v) do { } while (0)
11914 +#define vxh_loc_vx_info(v, l) do { } while (0)
11915 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11916 +#define vxh_create_vx_info(v, l) do { } while (0)
11918 +#define vxh_dump_history() do { } while (0)
11921 +#endif /* CONFIG_VSERVER_HISTORY */
11923 +#endif /* _VX_HISTORY_H */
11924 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/inode_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/inode_cmd.h
11925 --- linux-2.6.27.25/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11926 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/inode_cmd.h 2008-10-13 14:54:20.000000000 +0200
11928 +#ifndef _VX_INODE_CMD_H
11929 +#define _VX_INODE_CMD_H
11932 +/* inode vserver commands */
11934 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11935 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11937 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11938 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11940 +struct vcmd_ctx_iattr_v1 {
11941 + const char __user *name;
11947 +struct vcmd_ctx_fiattr_v0 {
11957 +#ifdef CONFIG_COMPAT
11959 +#include <asm/compat.h>
11961 +struct vcmd_ctx_iattr_v1_x32 {
11962 + compat_uptr_t name_ptr;
11968 +#endif /* CONFIG_COMPAT */
11970 +#include <linux/compiler.h>
11972 +extern int vc_get_iattr(void __user *);
11973 +extern int vc_set_iattr(void __user *);
11975 +extern int vc_fget_iattr(uint32_t, void __user *);
11976 +extern int vc_fset_iattr(uint32_t, void __user *);
11978 +#ifdef CONFIG_COMPAT
11980 +extern int vc_get_iattr_x32(void __user *);
11981 +extern int vc_set_iattr_x32(void __user *);
11983 +#endif /* CONFIG_COMPAT */
11985 +#endif /* __KERNEL__ */
11986 +#endif /* _VX_INODE_CMD_H */
11987 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/inode.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/inode.h
11988 --- linux-2.6.27.25/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11989 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/inode.h 2008-10-13 14:54:20.000000000 +0200
11991 +#ifndef _VX_INODE_H
11992 +#define _VX_INODE_H
11995 +#define IATTR_TAG 0x01000000
11997 +#define IATTR_ADMIN 0x00000001
11998 +#define IATTR_WATCH 0x00000002
11999 +#define IATTR_HIDE 0x00000004
12000 +#define IATTR_FLAGS 0x00000007
12002 +#define IATTR_BARRIER 0x00010000
12003 +#define IATTR_IXUNLINK 0x00020000
12004 +#define IATTR_IMMUTABLE 0x00040000
12009 +#ifdef CONFIG_VSERVER_PROC_SECURE
12010 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12011 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12013 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12014 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12017 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12019 +#endif /* __KERNEL__ */
12021 +/* inode ioctls */
12023 +#define FIOC_GETXFLG _IOR('x', 5, long)
12024 +#define FIOC_SETXFLG _IOW('x', 6, long)
12026 +#else /* _VX_INODE_H */
12027 +#warning duplicate inclusion
12028 +#endif /* _VX_INODE_H */
12029 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/Kbuild linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/Kbuild
12030 --- linux-2.6.27.25/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
12031 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/Kbuild 2008-10-13 14:54:20.000000000 +0200
12034 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
12035 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12036 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12037 + debug_cmd.h device_cmd.h
12039 +unifdef-y += switch.h network.h monitor.h inode.h device.h
12041 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/limit_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit_cmd.h
12042 --- linux-2.6.27.25/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12043 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit_cmd.h 2009-01-04 02:28:31.000000000 +0100
12045 +#ifndef _VX_LIMIT_CMD_H
12046 +#define _VX_LIMIT_CMD_H
12049 +/* rlimit vserver commands */
12051 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12052 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12053 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12054 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12056 +struct vcmd_ctx_rlimit_v0 {
12058 + uint64_t minimum;
12059 + uint64_t softlimit;
12060 + uint64_t maximum;
12063 +struct vcmd_ctx_rlimit_mask_v0 {
12064 + uint32_t minimum;
12065 + uint32_t softlimit;
12066 + uint32_t maximum;
12069 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12071 +struct vcmd_rlimit_stat_v0 {
12075 + uint64_t minimum;
12076 + uint64_t maximum;
12079 +#define CRLIM_UNSET (0ULL)
12080 +#define CRLIM_INFINITY (~0ULL)
12081 +#define CRLIM_KEEP (~1ULL)
12085 +#ifdef CONFIG_IA32_EMULATION
12087 +struct vcmd_ctx_rlimit_v0_x32 {
12089 + uint64_t minimum;
12090 + uint64_t softlimit;
12091 + uint64_t maximum;
12092 +} __attribute__ ((packed));
12094 +#endif /* CONFIG_IA32_EMULATION */
12096 +#include <linux/compiler.h>
12098 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12099 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12100 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12101 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12103 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12105 +#ifdef CONFIG_IA32_EMULATION
12107 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12108 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12110 +#endif /* CONFIG_IA32_EMULATION */
12112 +#endif /* __KERNEL__ */
12113 +#endif /* _VX_LIMIT_CMD_H */
12114 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/limit_def.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit_def.h
12115 --- linux-2.6.27.25/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12116 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit_def.h 2008-10-13 14:54:20.000000000 +0200
12118 +#ifndef _VX_LIMIT_DEF_H
12119 +#define _VX_LIMIT_DEF_H
12121 +#include <asm/atomic.h>
12122 +#include <asm/resource.h>
12124 +#include "limit.h"
12127 +struct _vx_res_limit {
12128 + rlim_t soft; /* Context soft limit */
12129 + rlim_t hard; /* Context hard limit */
12131 + rlim_atomic_t rcur; /* Current value */
12132 + rlim_t rmin; /* Context minimum */
12133 + rlim_t rmax; /* Context maximum */
12135 + atomic_t lhit; /* Limit hits */
12138 +/* context sub struct */
12140 +struct _vx_limit {
12141 + struct _vx_res_limit res[NUM_LIMITS];
12144 +#ifdef CONFIG_VSERVER_DEBUG
12146 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12150 + printk("\t_vx_limit:");
12151 + for (i = 0; i < NUM_LIMITS; i++) {
12152 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12153 + i, (unsigned long)__rlim_get(limit, i),
12154 + (unsigned long)__rlim_rmin(limit, i),
12155 + (unsigned long)__rlim_rmax(limit, i),
12156 + (long)__rlim_soft(limit, i),
12157 + (long)__rlim_hard(limit, i),
12158 + atomic_read(&__rlim_lhit(limit, i)));
12164 +#endif /* _VX_LIMIT_DEF_H */
12165 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/limit.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit.h
12166 --- linux-2.6.27.25/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12167 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit.h 2008-10-13 14:54:20.000000000 +0200
12169 +#ifndef _VX_LIMIT_H
12170 +#define _VX_LIMIT_H
12172 +#define VLIMIT_NSOCK 16
12173 +#define VLIMIT_OPENFD 17
12174 +#define VLIMIT_ANON 18
12175 +#define VLIMIT_SHMEM 19
12176 +#define VLIMIT_SEMARY 20
12177 +#define VLIMIT_NSEMS 21
12178 +#define VLIMIT_DENTRY 22
12179 +#define VLIMIT_MAPPED 23
12184 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12186 +/* keep in sync with CRLIM_INFINITY */
12188 +#define VLIM_INFINITY (~0ULL)
12190 +#include <asm/atomic.h>
12191 +#include <asm/resource.h>
12193 +#ifndef RLIM_INFINITY
12194 +#warning RLIM_INFINITY is undefined
12197 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12199 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12200 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12202 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12203 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12204 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12206 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12207 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12209 +typedef atomic_long_t rlim_atomic_t;
12210 +typedef unsigned long rlim_t;
12212 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12213 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12214 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12215 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12216 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12217 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12220 +#if (RLIM_INFINITY == VLIM_INFINITY)
12221 +#define VX_VLIM(r) ((long long)(long)(r))
12222 +#define VX_RLIM(v) ((rlim_t)(v))
12224 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12225 + ? VLIM_INFINITY : (long long)(r))
12226 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12227 + ? RLIM_INFINITY : (rlim_t)(v))
12232 +void vx_vsi_meminfo(struct sysinfo *);
12233 +void vx_vsi_swapinfo(struct sysinfo *);
12235 +#define NUM_LIMITS 24
12237 +#endif /* __KERNEL__ */
12238 +#endif /* _VX_LIMIT_H */
12239 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/limit_int.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit_int.h
12240 --- linux-2.6.27.25/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12241 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/limit_int.h 2008-10-13 14:54:20.000000000 +0200
12243 +#ifndef _VX_LIMIT_INT_H
12244 +#define _VX_LIMIT_INT_H
12246 +#include "context.h"
12250 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12251 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12253 +extern const char *vlimit_name[NUM_LIMITS];
12255 +static inline void __vx_acc_cres(struct vx_info *vxi,
12256 + int res, int dir, void *_data, char *_file, int _line)
12258 + if (VXD_RCRES_COND(res))
12259 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12260 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12261 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12262 + (dir > 0) ? "++" : "--", _data, _file, _line);
12267 + __rlim_inc(&vxi->limit, res);
12269 + __rlim_dec(&vxi->limit, res);
12272 +static inline void __vx_add_cres(struct vx_info *vxi,
12273 + int res, int amount, void *_data, char *_file, int _line)
12275 + if (VXD_RCRES_COND(res))
12276 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12277 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12278 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12279 + amount, _data, _file, _line);
12284 + __rlim_add(&vxi->limit, res, amount);
12288 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12290 + int cond = (value > __rlim_rmax(limit, res));
12293 + __rlim_rmax(limit, res) = value;
12298 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12300 + int cond = (value < __rlim_rmin(limit, res));
12303 + __rlim_rmin(limit, res) = value;
12308 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12310 + if (!__vx_cres_adjust_max(limit, res, value))
12311 + __vx_cres_adjust_min(limit, res, value);
12316 + +1 ... no limit hit
12317 + -1 ... over soft limit
12318 + 0 ... over hard limit */
12320 +static inline int __vx_cres_avail(struct vx_info *vxi,
12321 + int res, int num, char *_file, int _line)
12323 + struct _vx_limit *limit;
12326 + if (VXD_RLIMIT_COND(res))
12327 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12328 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12329 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12330 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12331 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12332 + num, _file, _line);
12336 + limit = &vxi->limit;
12337 + value = __rlim_get(limit, res);
12339 + if (!__vx_cres_adjust_max(limit, res, value))
12340 + __vx_cres_adjust_min(limit, res, value);
12345 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12347 + if (value + num <= __rlim_soft(limit, res))
12350 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12352 + if (value + num <= __rlim_hard(limit, res))
12355 + __rlim_hit(limit, res);
12360 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12363 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12365 + rlim_t value, sum = 0;
12368 + while ((res = *array++)) {
12369 + value = __rlim_get(limit, res);
12370 + __vx_cres_fixup(limit, res, value);
12377 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12379 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12380 + int res = *array;
12382 + if (value == __rlim_get(limit, res))
12385 + __rlim_set(limit, res, value);
12386 + /* now adjust min/max */
12387 + if (!__vx_cres_adjust_max(limit, res, value))
12388 + __vx_cres_adjust_min(limit, res, value);
12393 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12394 + const int *array, int num, char *_file, int _line)
12396 + struct _vx_limit *limit;
12397 + rlim_t value = 0;
12405 + limit = &vxi->limit;
12407 + value = __vx_cres_array_sum(limit, array + 1);
12409 + __rlim_set(limit, res, value);
12410 + __vx_cres_fixup(limit, res, value);
12412 + return __vx_cres_avail(vxi, res, num, _file, _line);
12416 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12421 + /* complex resources first */
12422 + if ((id < 0) || (id == RLIMIT_RSS))
12423 + __vx_cres_array_fixup(limit, VLA_RSS);
12425 + for (res = 0; res < NUM_LIMITS; res++) {
12426 + if ((id > 0) && (res != id))
12429 + value = __rlim_get(limit, res);
12430 + __vx_cres_fixup(limit, res, value);
12432 + /* not supposed to happen, maybe warn? */
12433 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12434 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12439 +#endif /* __KERNEL__ */
12440 +#endif /* _VX_LIMIT_INT_H */
12441 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/monitor.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/monitor.h
12442 --- linux-2.6.27.25/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12443 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/monitor.h 2008-10-13 14:54:20.000000000 +0200
12445 +#ifndef _VX_MONITOR_H
12446 +#define _VX_MONITOR_H
12448 +#include <linux/types.h>
12455 + VXM_UPDATE = 0x20,
12459 + VXM_RQINFO_1 = 0x24,
12462 + VXM_ACTIVATE = 0x40,
12469 + VXM_MIGRATE = 0x48,
12472 + /* all other bits are flags */
12473 + VXM_SCHED = 0x80,
12476 +struct _vxm_update_1 {
12477 + uint32_t tokens_max;
12478 + uint32_t fill_rate;
12479 + uint32_t interval;
12482 +struct _vxm_update_2 {
12483 + uint32_t tokens_min;
12484 + uint32_t fill_rate;
12485 + uint32_t interval;
12488 +struct _vxm_rqinfo_1 {
12489 + uint16_t running;
12493 + uint32_t idle_tokens;
12496 +struct _vxm_rqinfo_2 {
12497 + uint32_t norm_time;
12498 + uint32_t idle_time;
12499 + uint32_t idle_skip;
12502 +struct _vxm_sched {
12504 + uint32_t norm_time;
12505 + uint32_t idle_time;
12508 +struct _vxm_task {
12513 +struct _vxm_event {
12522 + struct _vxm_task tsk;
12526 +struct _vx_mon_entry {
12530 + struct _vxm_event ev;
12531 + struct _vxm_sched sd;
12532 + struct _vxm_update_1 u1;
12533 + struct _vxm_update_2 u2;
12534 + struct _vxm_rqinfo_1 q1;
12535 + struct _vxm_rqinfo_2 q2;
12540 +#endif /* _VX_MONITOR_H */
12541 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/network_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/network_cmd.h
12542 --- linux-2.6.27.25/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12543 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/network_cmd.h 2008-10-13 14:54:20.000000000 +0200
12545 +#ifndef _VX_NETWORK_CMD_H
12546 +#define _VX_NETWORK_CMD_H
12549 +/* vinfo commands */
12551 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12554 +extern int vc_task_nid(uint32_t);
12556 +#endif /* __KERNEL__ */
12558 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12560 +struct vcmd_nx_info_v0 {
12562 + /* more to come */
12566 +extern int vc_nx_info(struct nx_info *, void __user *);
12568 +#endif /* __KERNEL__ */
12570 +#include <linux/in.h>
12571 +#include <linux/in6.h>
12573 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12574 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12576 +struct vcmd_net_create {
12577 + uint64_t flagword;
12580 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12582 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12583 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12585 +struct vcmd_net_addr_v0 {
12588 + struct in_addr ip[4];
12589 + struct in_addr mask[4];
12592 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12593 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12595 +struct vcmd_net_addr_ipv4_v1 {
12598 + struct in_addr ip;
12599 + struct in_addr mask;
12602 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12603 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12605 +struct vcmd_net_addr_ipv6_v1 {
12609 + struct in6_addr ip;
12610 + struct in6_addr mask;
12613 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12614 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12616 +struct vcmd_match_ipv4_v0 {
12621 + struct in_addr ip;
12622 + struct in_addr ip2;
12623 + struct in_addr mask;
12626 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12627 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12629 +struct vcmd_match_ipv6_v0 {
12634 + struct in6_addr ip;
12635 + struct in6_addr ip2;
12636 + struct in6_addr mask;
12641 +extern int vc_net_create(uint32_t, void __user *);
12642 +extern int vc_net_migrate(struct nx_info *, void __user *);
12644 +extern int vc_net_add(struct nx_info *, void __user *);
12645 +extern int vc_net_remove(struct nx_info *, void __user *);
12647 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12648 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12650 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12651 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12653 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12654 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12656 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12657 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12659 +#endif /* __KERNEL__ */
12662 +/* flag commands */
12664 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12665 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12667 +struct vcmd_net_flags_v0 {
12668 + uint64_t flagword;
12673 +extern int vc_get_nflags(struct nx_info *, void __user *);
12674 +extern int vc_set_nflags(struct nx_info *, void __user *);
12676 +#endif /* __KERNEL__ */
12679 +/* network caps commands */
12681 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12682 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12684 +struct vcmd_net_caps_v0 {
12690 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12691 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12693 +#endif /* __KERNEL__ */
12694 +#endif /* _VX_CONTEXT_CMD_H */
12695 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/network.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/network.h
12696 --- linux-2.6.27.25/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12697 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/network.h 2008-10-13 14:54:20.000000000 +0200
12699 +#ifndef _VX_NETWORK_H
12700 +#define _VX_NETWORK_H
12702 +#include <linux/types.h>
12705 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12708 +/* network flags */
12710 +#define NXF_INFO_PRIVATE 0x00000008
12712 +#define NXF_SINGLE_IP 0x00000100
12713 +#define NXF_LBACK_REMAP 0x00000200
12714 +#define NXF_LBACK_ALLOW 0x00000400
12716 +#define NXF_HIDE_NETIF 0x02000000
12717 +#define NXF_HIDE_LBACK 0x04000000
12719 +#define NXF_STATE_SETUP (1ULL << 32)
12720 +#define NXF_STATE_ADMIN (1ULL << 34)
12722 +#define NXF_SC_HELPER (1ULL << 36)
12723 +#define NXF_PERSISTENT (1ULL << 38)
12725 +#define NXF_ONE_TIME (0x0005ULL << 32)
12728 +#define NXF_INIT_SET (__nxf_init_set())
12730 +static inline uint64_t __nxf_init_set(void) {
12731 + return NXF_STATE_ADMIN
12732 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12733 + | NXF_LBACK_REMAP
12736 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12739 + | NXF_HIDE_NETIF;
12743 +/* network caps */
12745 +#define NXC_TUN_CREATE 0x00000001
12747 +#define NXC_RAW_ICMP 0x00000100
12750 +/* address types */
12752 +#define NXA_TYPE_IPV4 0x0001
12753 +#define NXA_TYPE_IPV6 0x0002
12755 +#define NXA_TYPE_NONE 0x0000
12756 +#define NXA_TYPE_ANY 0x00FF
12758 +#define NXA_TYPE_ADDR 0x0010
12759 +#define NXA_TYPE_MASK 0x0020
12760 +#define NXA_TYPE_RANGE 0x0040
12762 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12764 +#define NXA_MOD_BCAST 0x0100
12765 +#define NXA_MOD_LBACK 0x0200
12767 +#define NXA_LOOPBACK 0x1000
12769 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12770 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12774 +#include <linux/list.h>
12775 +#include <linux/spinlock.h>
12776 +#include <linux/rcupdate.h>
12777 +#include <linux/in.h>
12778 +#include <linux/in6.h>
12779 +#include <asm/atomic.h>
12781 +struct nx_addr_v4 {
12782 + struct nx_addr_v4 *next;
12783 + struct in_addr ip[2];
12784 + struct in_addr mask;
12789 +struct nx_addr_v6 {
12790 + struct nx_addr_v6 *next;
12791 + struct in6_addr ip;
12792 + struct in6_addr mask;
12799 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12800 + nid_t nx_id; /* vnet id */
12801 + atomic_t nx_usecnt; /* usage count */
12802 + atomic_t nx_tasks; /* tasks count */
12803 + int nx_state; /* context state */
12805 + uint64_t nx_flags; /* network flag word */
12806 + uint64_t nx_ncaps; /* network capabilities */
12808 + struct in_addr v4_lback; /* Loopback address */
12809 + struct in_addr v4_bcast; /* Broadcast address */
12810 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12811 +#ifdef CONFIG_IPV6
12812 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12814 + char nx_name[65]; /* network context name */
12818 +/* status flags */
12820 +#define NXS_HASHED 0x0001
12821 +#define NXS_SHUTDOWN 0x0100
12822 +#define NXS_RELEASED 0x8000
12824 +extern struct nx_info *lookup_nx_info(int);
12826 +extern int get_nid_list(int, unsigned int *, int);
12827 +extern int nid_is_hashed(nid_t);
12829 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12831 +extern long vs_net_change(struct nx_info *, unsigned int);
12836 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12837 +#ifdef CONFIG_IPV6
12838 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12840 +#define NX_IPV6(n) (0)
12843 +#endif /* __KERNEL__ */
12844 +#endif /* _VX_NETWORK_H */
12845 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/percpu.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/percpu.h
12846 --- linux-2.6.27.25/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12847 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/percpu.h 2008-10-13 14:54:20.000000000 +0200
12849 +#ifndef _VX_PERCPU_H
12850 +#define _VX_PERCPU_H
12852 +#include "cvirt_def.h"
12853 +#include "sched_def.h"
12855 +struct _vx_percpu {
12856 + struct _vx_cvirt_pc cvirt;
12857 + struct _vx_sched_pc sched;
12860 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12862 +#endif /* _VX_PERCPU_H */
12863 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/pid.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/pid.h
12864 --- linux-2.6.27.25/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12865 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/pid.h 2008-10-13 14:54:20.000000000 +0200
12867 +#ifndef _VSERVER_PID_H
12868 +#define _VSERVER_PID_H
12870 +/* pid faking stuff */
12872 +#define vx_info_map_pid(v, p) \
12873 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12874 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12875 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12876 +#define vx_map_tgid(p) vx_map_pid(p)
12878 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12879 + const char *func, const char *file, int line)
12881 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12882 + vxfprintk(VXD_CBIT(cvirt, 2),
12883 + "vx_map_tgid: %p/%llx: %d -> %d",
12884 + vxi, (long long)vxi->vx_flags, pid,
12885 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12886 + func, file, line);
12889 + if (pid == vxi->vx_initpid)
12895 +#define vx_info_rmap_pid(v, p) \
12896 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12897 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12898 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12900 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12901 + const char *func, const char *file, int line)
12903 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12904 + vxfprintk(VXD_CBIT(cvirt, 2),
12905 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12906 + vxi, (long long)vxi->vx_flags, pid,
12907 + (pid == 1) ? vxi->vx_initpid : pid,
12908 + func, file, line);
12909 + if ((pid == 1) && vxi->vx_initpid)
12910 + return vxi->vx_initpid;
12911 + if (pid == vxi->vx_initpid)
12918 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/sched_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/sched_cmd.h
12919 --- linux-2.6.27.25/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12920 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/sched_cmd.h 2008-10-13 14:54:20.000000000 +0200
12922 +#ifndef _VX_SCHED_CMD_H
12923 +#define _VX_SCHED_CMD_H
12926 +/* sched vserver commands */
12928 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12929 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12930 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12932 +struct vcmd_set_sched_v2 {
12933 + int32_t fill_rate;
12934 + int32_t interval;
12936 + int32_t tokens_min;
12937 + int32_t tokens_max;
12938 + uint64_t cpu_mask;
12941 +struct vcmd_set_sched_v3 {
12942 + uint32_t set_mask;
12943 + int32_t fill_rate;
12944 + int32_t interval;
12946 + int32_t tokens_min;
12947 + int32_t tokens_max;
12948 + int32_t priority_bias;
12951 +struct vcmd_set_sched_v4 {
12952 + uint32_t set_mask;
12953 + int32_t fill_rate;
12954 + int32_t interval;
12956 + int32_t tokens_min;
12957 + int32_t tokens_max;
12958 + int32_t prio_bias;
12960 + int32_t bucket_id;
12963 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12964 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12966 +struct vcmd_sched_v5 {
12969 + int32_t bucket_id;
12970 + int32_t fill_rate[2];
12971 + int32_t interval[2];
12973 + int32_t tokens_min;
12974 + int32_t tokens_max;
12975 + int32_t prio_bias;
12978 +#define VXSM_FILL_RATE 0x0001
12979 +#define VXSM_INTERVAL 0x0002
12980 +#define VXSM_FILL_RATE2 0x0004
12981 +#define VXSM_INTERVAL2 0x0008
12982 +#define VXSM_TOKENS 0x0010
12983 +#define VXSM_TOKENS_MIN 0x0020
12984 +#define VXSM_TOKENS_MAX 0x0040
12985 +#define VXSM_PRIO_BIAS 0x0100
12987 +#define VXSM_IDLE_TIME 0x0200
12988 +#define VXSM_FORCE 0x0400
12990 +#define VXSM_V3_MASK 0x0173
12991 +#define VXSM_SET_MASK 0x01FF
12993 +#define VXSM_CPU_ID 0x1000
12994 +#define VXSM_BUCKET_ID 0x2000
12996 +#define VXSM_MSEC 0x4000
12998 +#define SCHED_KEEP (-2) /* only for v2 */
13002 +#include <linux/compiler.h>
13004 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
13005 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
13006 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
13007 +extern int vc_set_sched(struct vx_info *, void __user *);
13008 +extern int vc_get_sched(struct vx_info *, void __user *);
13010 +#endif /* __KERNEL__ */
13012 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
13014 +struct vcmd_sched_info {
13016 + int32_t bucket_id;
13017 + uint64_t user_msec;
13018 + uint64_t sys_msec;
13019 + uint64_t hold_msec;
13020 + uint32_t token_usec;
13021 + int32_t vavavoom;
13026 +extern int vc_sched_info(struct vx_info *, void __user *);
13028 +#endif /* __KERNEL__ */
13029 +#endif /* _VX_SCHED_CMD_H */
13030 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/sched_def.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/sched_def.h
13031 --- linux-2.6.27.25/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13032 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/sched_def.h 2008-10-13 14:54:20.000000000 +0200
13034 +#ifndef _VX_SCHED_DEF_H
13035 +#define _VX_SCHED_DEF_H
13037 +#include <linux/spinlock.h>
13038 +#include <linux/jiffies.h>
13039 +#include <linux/cpumask.h>
13040 +#include <asm/atomic.h>
13041 +#include <asm/param.h>
13044 +/* context sub struct */
13046 +struct _vx_sched {
13047 + spinlock_t tokens_lock; /* lock for token bucket */
13049 + int tokens; /* number of CPU tokens */
13050 + int fill_rate[2]; /* Fill rate: add X tokens... */
13051 + int interval[2]; /* Divisor: per Y jiffies */
13052 + int tokens_min; /* Limit: minimum for unhold */
13053 + int tokens_max; /* Limit: no more than N tokens */
13055 + int prio_bias; /* bias offset for priority */
13057 + unsigned update_mask; /* which features should be updated */
13058 + cpumask_t update; /* CPUs which should update */
13061 +struct _vx_sched_pc {
13062 + int tokens; /* number of CPU tokens */
13063 + int flags; /* bucket flags */
13065 + int fill_rate[2]; /* Fill rate: add X tokens... */
13066 + int interval[2]; /* Divisor: per Y jiffies */
13067 + int tokens_min; /* Limit: minimum for unhold */
13068 + int tokens_max; /* Limit: no more than N tokens */
13070 + int prio_bias; /* bias offset for priority */
13071 + int vavavoom; /* last calculated vavavoom */
13073 + unsigned long norm_time; /* last time accounted */
13074 + unsigned long idle_time; /* non linear time for fair sched */
13075 + unsigned long token_time; /* token time for accounting */
13076 + unsigned long onhold; /* jiffies when put on hold */
13078 + uint64_t user_ticks; /* token tick events */
13079 + uint64_t sys_ticks; /* token tick events */
13080 + uint64_t hold_ticks; /* token ticks paused */
13084 +#define VXSF_ONHOLD 0x0001
13085 +#define VXSF_IDLE_TIME 0x0100
13087 +#ifdef CONFIG_VSERVER_DEBUG
13089 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13091 + printk("\t_vx_sched:\n");
13092 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
13093 + sched->fill_rate[0], sched->interval[0],
13094 + sched->fill_rate[1], sched->interval[1],
13095 + sched->tokens_min, sched->tokens_max);
13096 + printk("\t priority = %4d\n", sched->prio_bias);
13101 +#endif /* _VX_SCHED_DEF_H */
13102 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/sched.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/sched.h
13103 --- linux-2.6.27.25/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13104 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/sched.h 2008-10-13 14:54:20.000000000 +0200
13106 +#ifndef _VX_SCHED_H
13107 +#define _VX_SCHED_H
13114 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13119 +void vx_update_load(struct vx_info *);
13122 +int vx_tokens_recalc(struct _vx_sched_pc *,
13123 + unsigned long *, unsigned long *, int [2]);
13125 +void vx_update_sched_param(struct _vx_sched *sched,
13126 + struct _vx_sched_pc *sched_pc);
13128 +#endif /* __KERNEL__ */
13129 +#else /* _VX_SCHED_H */
13130 +#warning duplicate inclusion
13131 +#endif /* _VX_SCHED_H */
13132 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/signal_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/signal_cmd.h
13133 --- linux-2.6.27.25/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13134 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/signal_cmd.h 2008-10-13 14:54:20.000000000 +0200
13136 +#ifndef _VX_SIGNAL_CMD_H
13137 +#define _VX_SIGNAL_CMD_H
13140 +/* signalling vserver commands */
13142 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13143 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13145 +struct vcmd_ctx_kill_v0 {
13150 +struct vcmd_wait_exit_v0 {
13151 + int32_t reboot_cmd;
13152 + int32_t exit_code;
13157 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13158 +extern int vc_wait_exit(struct vx_info *, void __user *);
13160 +#endif /* __KERNEL__ */
13162 +/* process alteration commands */
13164 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13165 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13167 +struct vcmd_pflags_v0 {
13168 + uint32_t flagword;
13174 +extern int vc_get_pflags(uint32_t pid, void __user *);
13175 +extern int vc_set_pflags(uint32_t pid, void __user *);
13177 +#endif /* __KERNEL__ */
13178 +#endif /* _VX_SIGNAL_CMD_H */
13179 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/signal.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/signal.h
13180 --- linux-2.6.27.25/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13181 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/signal.h 2008-10-13 14:54:20.000000000 +0200
13183 +#ifndef _VX_SIGNAL_H
13184 +#define _VX_SIGNAL_H
13191 +int vx_info_kill(struct vx_info *, int, int);
13193 +#endif /* __KERNEL__ */
13194 +#else /* _VX_SIGNAL_H */
13195 +#warning duplicate inclusion
13196 +#endif /* _VX_SIGNAL_H */
13197 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/space_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/space_cmd.h
13198 --- linux-2.6.27.25/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13199 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/space_cmd.h 2008-10-31 03:49:36.000000000 +0100
13201 +#ifndef _VX_SPACE_CMD_H
13202 +#define _VX_SPACE_CMD_H
13205 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13206 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13207 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13209 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13210 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13211 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13213 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13215 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13216 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13219 +struct vcmd_space_mask_v1 {
13223 +struct vcmd_space_mask_v2 {
13231 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13232 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13233 +extern int vc_enter_space(struct vx_info *, void __user *);
13234 +extern int vc_set_space(struct vx_info *, void __user *);
13235 +extern int vc_get_space_mask(void __user *, int);
13237 +#endif /* __KERNEL__ */
13238 +#endif /* _VX_SPACE_CMD_H */
13239 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/space.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/space.h
13240 --- linux-2.6.27.25/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13241 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/space.h 2008-10-31 04:02:02.000000000 +0100
13243 +#ifndef _VX_SPACE_H
13244 +#define _VX_SPACE_H
13246 +#include <linux/types.h>
13250 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13252 +#else /* _VX_SPACE_H */
13253 +#warning duplicate inclusion
13254 +#endif /* _VX_SPACE_H */
13255 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/switch.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/switch.h
13256 --- linux-2.6.27.25/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13257 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/switch.h 2008-11-22 20:32:00.000000000 +0100
13259 +#ifndef _VX_SWITCH_H
13260 +#define _VX_SWITCH_H
13262 +#include <linux/types.h>
13265 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13266 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13267 +#define VC_VERSION(c) ((c) & 0xFFF)
13269 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13270 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13274 + Syscall Matrix V2.8
13276 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13277 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13278 + |INFO |SETUP | |MOVE | | | | | |
13279 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13280 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13281 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13282 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13283 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13284 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13285 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13286 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13287 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13288 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13289 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13290 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13291 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13292 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13293 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13294 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13295 + OTHER |VSTAT | | | | | | |VINFO | |
13296 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13297 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13298 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13299 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13300 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13301 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13302 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13303 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13307 +#define VC_CAT_VERSION 0
13309 +#define VC_CAT_VSETUP 1
13310 +#define VC_CAT_VHOST 2
13312 +#define VC_CAT_DEVICE 6
13314 +#define VC_CAT_VPROC 9
13315 +#define VC_CAT_PROCALT 10
13316 +#define VC_CAT_PROCMIG 11
13317 +#define VC_CAT_PROCTRL 12
13319 +#define VC_CAT_SCHED 14
13320 +#define VC_CAT_MEMCTRL 20
13322 +#define VC_CAT_VNET 25
13323 +#define VC_CAT_NETALT 26
13324 +#define VC_CAT_NETMIG 27
13325 +#define VC_CAT_NETCTRL 28
13327 +#define VC_CAT_TAGMIG 35
13328 +#define VC_CAT_DLIMIT 36
13329 +#define VC_CAT_INODE 38
13331 +#define VC_CAT_VSTAT 40
13332 +#define VC_CAT_VINFO 46
13333 +#define VC_CAT_EVENT 48
13335 +#define VC_CAT_FLAGS 52
13336 +#define VC_CAT_VSPACE 54
13337 +#define VC_CAT_DEBUG 56
13338 +#define VC_CAT_RLIMIT 60
13340 +#define VC_CAT_SYSTEST 61
13341 +#define VC_CAT_COMPAT 63
13343 +/* query version */
13345 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13346 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13351 +#include <linux/errno.h>
13353 +#endif /* __KERNEL__ */
13355 +#endif /* _VX_SWITCH_H */
13357 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/tag_cmd.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/tag_cmd.h
13358 --- linux-2.6.27.25/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13359 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/tag_cmd.h 2008-10-13 14:54:20.000000000 +0200
13361 +#ifndef _VX_TAG_CMD_H
13362 +#define _VX_TAG_CMD_H
13365 +/* vinfo commands */
13367 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13370 +extern int vc_task_tag(uint32_t);
13372 +#endif /* __KERNEL__ */
13374 +/* context commands */
13376 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13379 +extern int vc_tag_migrate(uint32_t);
13381 +#endif /* __KERNEL__ */
13382 +#endif /* _VX_TAG_CMD_H */
13383 diff -NurpP --minimal linux-2.6.27.25/include/linux/vserver/tag.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/tag.h
13384 --- linux-2.6.27.25/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13385 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vserver/tag.h 2008-10-24 03:34:52.000000000 +0200
13390 +#include <linux/types.h>
13393 +#define DX_TAG(in) (IS_TAGGED(in))
13396 +#ifdef CONFIG_TAG_NFSD
13397 +#define DX_TAG_NFSD 1
13399 +#define DX_TAG_NFSD 0
13403 +#ifdef CONFIG_TAGGING_NONE
13405 +#define MAX_UID 0xFFFFFFFF
13406 +#define MAX_GID 0xFFFFFFFF
13408 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13410 +#define TAGINO_UID(cond, uid, tag) (uid)
13411 +#define TAGINO_GID(cond, gid, tag) (gid)
13416 +#ifdef CONFIG_TAGGING_GID16
13418 +#define MAX_UID 0xFFFFFFFF
13419 +#define MAX_GID 0x0000FFFF
13421 +#define INOTAG_TAG(cond, uid, gid, tag) \
13422 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13424 +#define TAGINO_UID(cond, uid, tag) (uid)
13425 +#define TAGINO_GID(cond, gid, tag) \
13426 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13431 +#ifdef CONFIG_TAGGING_ID24
13433 +#define MAX_UID 0x00FFFFFF
13434 +#define MAX_GID 0x00FFFFFF
13436 +#define INOTAG_TAG(cond, uid, gid, tag) \
13437 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13439 +#define TAGINO_UID(cond, uid, tag) \
13440 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13441 +#define TAGINO_GID(cond, gid, tag) \
13442 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13447 +#ifdef CONFIG_TAGGING_UID16
13449 +#define MAX_UID 0x0000FFFF
13450 +#define MAX_GID 0xFFFFFFFF
13452 +#define INOTAG_TAG(cond, uid, gid, tag) \
13453 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13455 +#define TAGINO_UID(cond, uid, tag) \
13456 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13457 +#define TAGINO_GID(cond, gid, tag) (gid)
13462 +#ifdef CONFIG_TAGGING_INTERN
13464 +#define MAX_UID 0xFFFFFFFF
13465 +#define MAX_GID 0xFFFFFFFF
13467 +#define INOTAG_TAG(cond, uid, gid, tag) \
13468 + ((cond) ? (tag) : 0)
13470 +#define TAGINO_UID(cond, uid, tag) (uid)
13471 +#define TAGINO_GID(cond, gid, tag) (gid)
13476 +#ifndef CONFIG_TAGGING_NONE
13477 +#define dx_current_fstag(sb) \
13478 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13480 +#define dx_current_fstag(sb) (0)
13483 +#ifndef CONFIG_TAGGING_INTERN
13484 +#define TAGINO_TAG(cond, tag) (0)
13486 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13489 +#define INOTAG_UID(cond, uid, gid) \
13490 + ((cond) ? ((uid) & MAX_UID) : (uid))
13491 +#define INOTAG_GID(cond, uid, gid) \
13492 + ((cond) ? ((gid) & MAX_GID) : (gid))
13495 +static inline uid_t dx_map_uid(uid_t uid)
13497 + if ((uid > MAX_UID) && (uid != -1))
13499 + return (uid & MAX_UID);
13502 +static inline gid_t dx_map_gid(gid_t gid)
13504 + if ((gid > MAX_GID) && (gid != -1))
13506 + return (gid & MAX_GID);
13514 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13516 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13517 + unsigned long *flags);
13519 +#ifdef CONFIG_PROPAGATE
13521 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13523 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13526 +#define dx_propagate_tag(n, i) do { } while (0)
13529 +#endif /* _DX_TAG_H */
13530 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_inet6.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_inet6.h
13531 --- linux-2.6.27.25/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13532 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_inet6.h 2008-11-16 17:35:20.000000000 +0100
13534 +#ifndef _VS_INET6_H
13535 +#define _VS_INET6_H
13537 +#include "vserver/base.h"
13538 +#include "vserver/network.h"
13539 +#include "vserver/debug.h"
13541 +#include <net/ipv6.h>
13543 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
13544 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
13547 +#ifdef CONFIG_IPV6
13550 +int v6_addr_match(struct nx_addr_v6 *nxa,
13551 + const struct in6_addr *addr, uint16_t mask)
13555 + switch (nxa->type & mask) {
13556 + case NXA_TYPE_MASK:
13557 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13559 + case NXA_TYPE_ADDR:
13560 + ret = ipv6_addr_equal(&nxa->ip, addr);
13562 + case NXA_TYPE_ANY:
13566 + vxdprintk(VXD_CBIT(net, 0),
13567 + "v6_addr_match(%p" NXAV6_FMT ", " NIP6_FMT ", %04x) = %d",
13568 + nxa, NXAV6(nxa), NIP6(*addr), mask, ret);
13573 +int v6_addr_in_nx_info(struct nx_info *nxi,
13574 + const struct in6_addr *addr, uint16_t mask)
13576 + struct nx_addr_v6 *nxa;
13581 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13582 + if (v6_addr_match(nxa, addr, mask))
13586 + vxdprintk(VXD_CBIT(net, 0),
13587 + "v6_addr_in_nx_info(%p[#%u]," NIP6_FMT ",%04x) = %d",
13588 + nxi, nxi ? nxi->nx_id : 0, NIP6(*addr), mask, ret);
13593 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13595 + /* FIXME: needs full range checks */
13596 + return v6_addr_match(nxa, &addr->ip, mask);
13600 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13602 + struct nx_addr_v6 *ptr;
13604 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13605 + if (v6_nx_addr_match(ptr, nxa, mask))
13612 + * Check if a given address matches for a socket
13614 + * nxi: the socket's nx_info if any
13615 + * addr: to be verified address
13618 +int v6_sock_addr_match (
13619 + struct nx_info *nxi,
13620 + struct inet_sock *inet,
13621 + struct in6_addr *addr)
13623 + struct sock *sk = &inet->sk;
13624 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13626 + if (!ipv6_addr_any(addr) &&
13627 + ipv6_addr_equal(saddr, addr))
13629 + if (ipv6_addr_any(saddr))
13630 + return v6_addr_in_nx_info(nxi, addr, -1);
13635 + * check if address is covered by socket
13637 + * sk: the socket to check against
13638 + * addr: the address in question (must be != 0)
13642 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13644 + struct nx_info *nxi = sk->sk_nx_info;
13645 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13647 + vxdprintk(VXD_CBIT(net, 5),
13648 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
13649 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
13650 + (sk->sk_socket?sk->sk_socket->flags:0));
13652 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13653 + return v6_addr_match(nxa, saddr, -1);
13654 + } else if (nxi) { /* match against nx_info */
13655 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13656 + } else { /* unrestricted any socket */
13662 +/* inet related checks and helpers */
13666 +struct net_device;
13670 +#include <linux/netdevice.h>
13671 +#include <linux/inetdevice.h>
13672 +#include <net/inet_timewait_sock.h>
13675 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13676 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13677 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13682 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13688 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13692 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13694 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13695 + nxi, nxi ? nxi->nx_id : 0, ifa,
13696 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13698 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13700 + if (v6_ifa_in_nx_info(ifa, nxi))
13706 +struct nx_v6_sock_addr {
13707 + struct in6_addr saddr; /* Address used for validation */
13708 + struct in6_addr baddr; /* Address used for socket bind */
13712 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13713 + struct nx_v6_sock_addr *nsa)
13715 + // struct sock *sk = &inet->sk;
13716 + // struct nx_info *nxi = sk->sk_nx_info;
13717 + struct in6_addr saddr = addr->sin6_addr;
13718 + struct in6_addr baddr = saddr;
13720 + nsa->saddr = saddr;
13721 + nsa->baddr = baddr;
13726 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13728 + // struct sock *sk = &inet->sk;
13729 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13731 + // *saddr = nsa->baddr;
13732 + // inet->saddr = nsa->baddr;
13736 +int nx_info_has_v6(struct nx_info *nxi)
13740 + if (NX_IPV6(nxi))
13745 +#else /* CONFIG_IPV6 */
13748 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13755 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13761 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13767 +int nx_info_has_v6(struct nx_info *nxi)
13772 +#endif /* CONFIG_IPV6 */
13774 +#define current_nx_info_has_v6() \
13775 + nx_info_has_v6(current_nx_info())
13778 +#warning duplicate inclusion
13780 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_inet.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_inet.h
13781 --- linux-2.6.27.25/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13782 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_inet.h 2008-10-13 14:54:20.000000000 +0200
13784 +#ifndef _VS_INET_H
13785 +#define _VS_INET_H
13787 +#include "vserver/base.h"
13788 +#include "vserver/network.h"
13789 +#include "vserver/debug.h"
13791 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13793 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13794 + NIPQUAD((a)->mask), (a)->type
13795 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13799 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13801 + __be32 ip = nxa->ip[0].s_addr;
13802 + __be32 mask = nxa->mask.s_addr;
13803 + __be32 bcast = ip | ~mask;
13806 + switch (nxa->type & tmask) {
13807 + case NXA_TYPE_MASK:
13808 + ret = (ip == (addr & mask));
13810 + case NXA_TYPE_ADDR:
13814 + /* fall through to broadcast */
13815 + case NXA_MOD_BCAST:
13816 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13818 + case NXA_TYPE_RANGE:
13819 + ret = ((nxa->ip[0].s_addr <= addr) &&
13820 + (nxa->ip[1].s_addr > addr));
13822 + case NXA_TYPE_ANY:
13827 + vxdprintk(VXD_CBIT(net, 0),
13828 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13829 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13834 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13836 + struct nx_addr_v4 *nxa;
13843 + /* allow 127.0.0.1 when remapping lback */
13844 + if ((tmask & NXA_LOOPBACK) &&
13845 + (addr == IPI_LOOPBACK) &&
13846 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13849 + /* check for lback address */
13850 + if ((tmask & NXA_MOD_LBACK) &&
13851 + (nxi->v4_lback.s_addr == addr))
13854 + /* check for broadcast address */
13855 + if ((tmask & NXA_MOD_BCAST) &&
13856 + (nxi->v4_bcast.s_addr == addr))
13859 + /* check for v4 addresses */
13860 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13861 + if (v4_addr_match(nxa, addr, tmask))
13865 + vxdprintk(VXD_CBIT(net, 0),
13866 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13867 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13872 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13874 + /* FIXME: needs full range checks */
13875 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13879 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13881 + struct nx_addr_v4 *ptr;
13883 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13884 + if (v4_nx_addr_match(ptr, nxa, mask))
13889 +#include <net/inet_sock.h>
13892 + * Check if a given address matches for a socket
13894 + * nxi: the socket's nx_info if any
13895 + * addr: to be verified address
13898 +int v4_sock_addr_match (
13899 + struct nx_info *nxi,
13900 + struct inet_sock *inet,
13903 + __be32 saddr = inet->rcv_saddr;
13904 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13906 + if (addr && (saddr == addr || bcast == addr))
13909 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13914 +/* inet related checks and helpers */
13918 +struct net_device;
13921 +#ifdef CONFIG_INET
13923 +#include <linux/netdevice.h>
13924 +#include <linux/inetdevice.h>
13925 +#include <net/inet_sock.h>
13926 +#include <net/inet_timewait_sock.h>
13929 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13930 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13931 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13935 + * check if address is covered by socket
13937 + * sk: the socket to check against
13938 + * addr: the address in question (must be != 0)
13942 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13944 + struct nx_info *nxi = sk->sk_nx_info;
13945 + __be32 saddr = inet_rcv_saddr(sk);
13947 + vxdprintk(VXD_CBIT(net, 5),
13948 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13949 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13950 + (sk->sk_socket?sk->sk_socket->flags:0));
13952 + if (saddr) { /* direct address match */
13953 + return v4_addr_match(nxa, saddr, -1);
13954 + } else if (nxi) { /* match against nx_info */
13955 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13956 + } else { /* unrestricted any socket */
13964 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13966 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13967 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13968 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13970 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13972 + if (dev_in_nx_info(dev, nxi))
13979 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13985 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13989 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13991 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13992 + nxi, nxi ? nxi->nx_id : 0, ifa,
13993 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13995 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13997 + if (v4_ifa_in_nx_info(ifa, nxi))
14003 +struct nx_v4_sock_addr {
14004 + __be32 saddr; /* Address used for validation */
14005 + __be32 baddr; /* Address used for socket bind */
14009 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
14010 + struct nx_v4_sock_addr *nsa)
14012 + struct sock *sk = &inet->sk;
14013 + struct nx_info *nxi = sk->sk_nx_info;
14014 + __be32 saddr = addr->sin_addr.s_addr;
14015 + __be32 baddr = saddr;
14017 + vxdprintk(VXD_CBIT(net, 3),
14018 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
14019 + sk, sk->sk_nx_info, sk->sk_socket,
14020 + (sk->sk_socket ? sk->sk_socket->flags : 0),
14024 + if (saddr == INADDR_ANY) {
14025 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
14026 + baddr = nxi->v4.ip[0].s_addr;
14027 + } else if (saddr == IPI_LOOPBACK) {
14028 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14029 + baddr = nxi->v4_lback.s_addr;
14030 + } else { /* normal address bind */
14031 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
14032 + return -EADDRNOTAVAIL;
14036 + vxdprintk(VXD_CBIT(net, 3),
14037 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
14038 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
14040 + nsa->saddr = saddr;
14041 + nsa->baddr = baddr;
14046 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
14048 + inet->saddr = nsa->baddr;
14049 + inet->rcv_saddr = nsa->baddr;
14054 + * helper to simplify inet_lookup_listener
14056 + * nxi: the socket's nx_info if any
14057 + * addr: to be verified address
14058 + * saddr: socket address
14060 +static inline int v4_inet_addr_match (
14061 + struct nx_info *nxi,
14065 + if (addr && (saddr == addr))
14068 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
14072 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
14074 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
14075 + (addr == nxi->v4_lback.s_addr))
14076 + return IPI_LOOPBACK;
14081 +int nx_info_has_v4(struct nx_info *nxi)
14085 + if (NX_IPV4(nxi))
14087 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14092 +#else /* CONFIG_INET */
14095 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
14101 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14107 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14113 +int nx_info_has_v4(struct nx_info *nxi)
14118 +#endif /* CONFIG_INET */
14120 +#define current_nx_info_has_v4() \
14121 + nx_info_has_v4(current_nx_info())
14124 +// #warning duplicate inclusion
14126 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_limit.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_limit.h
14127 --- linux-2.6.27.25/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
14128 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_limit.h 2008-10-13 14:54:20.000000000 +0200
14130 +#ifndef _VS_LIMIT_H
14131 +#define _VS_LIMIT_H
14133 +#include "vserver/limit.h"
14134 +#include "vserver/base.h"
14135 +#include "vserver/context.h"
14136 +#include "vserver/debug.h"
14137 +#include "vserver/context.h"
14138 +#include "vserver/limit_int.h"
14141 +#define vx_acc_cres(v, d, p, r) \
14142 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
14144 +#define vx_acc_cres_cond(x, d, p, r) \
14145 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14146 + r, d, p, __FILE__, __LINE__)
14149 +#define vx_add_cres(v, a, p, r) \
14150 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
14151 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
14153 +#define vx_add_cres_cond(x, a, p, r) \
14154 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14155 + r, a, p, __FILE__, __LINE__)
14156 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
14159 +/* process and file limits */
14161 +#define vx_nproc_inc(p) \
14162 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
14164 +#define vx_nproc_dec(p) \
14165 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
14167 +#define vx_files_inc(f) \
14168 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
14170 +#define vx_files_dec(f) \
14171 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
14173 +#define vx_locks_inc(l) \
14174 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
14176 +#define vx_locks_dec(l) \
14177 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
14179 +#define vx_openfd_inc(f) \
14180 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
14182 +#define vx_openfd_dec(f) \
14183 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
14186 +#define vx_cres_avail(v, n, r) \
14187 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
14190 +#define vx_nproc_avail(n) \
14191 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
14193 +#define vx_files_avail(n) \
14194 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
14196 +#define vx_locks_avail(n) \
14197 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
14199 +#define vx_openfd_avail(n) \
14200 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
14203 +/* dentry limits */
14205 +#define vx_dentry_inc(d) do { \
14206 + if (atomic_read(&d->d_count) == 1) \
14207 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
14210 +#define vx_dentry_dec(d) do { \
14211 + if (atomic_read(&d->d_count) == 0) \
14212 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
14215 +#define vx_dentry_avail(n) \
14216 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
14219 +/* socket limits */
14221 +#define vx_sock_inc(s) \
14222 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14224 +#define vx_sock_dec(s) \
14225 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14227 +#define vx_sock_avail(n) \
14228 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
14231 +/* ipc resource limits */
14233 +#define vx_ipcmsg_add(v, u, a) \
14234 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14236 +#define vx_ipcmsg_sub(v, u, a) \
14237 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14239 +#define vx_ipcmsg_avail(v, a) \
14240 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14243 +#define vx_ipcshm_add(v, k, a) \
14244 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14246 +#define vx_ipcshm_sub(v, k, a) \
14247 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14249 +#define vx_ipcshm_avail(v, a) \
14250 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14253 +#define vx_semary_inc(a) \
14254 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
14256 +#define vx_semary_dec(a) \
14257 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
14260 +#define vx_nsems_add(a,n) \
14261 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
14263 +#define vx_nsems_sub(a,n) \
14264 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
14268 +#warning duplicate inclusion
14270 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_memory.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_memory.h
14271 --- linux-2.6.27.25/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14272 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_memory.h 2008-10-13 14:54:20.000000000 +0200
14274 +#ifndef _VS_MEMORY_H
14275 +#define _VS_MEMORY_H
14277 +#include "vserver/limit.h"
14278 +#include "vserver/base.h"
14279 +#include "vserver/context.h"
14280 +#include "vserver/debug.h"
14281 +#include "vserver/context.h"
14282 +#include "vserver/limit_int.h"
14285 +#define __acc_add_long(a, v) (*(v) += (a))
14286 +#define __acc_inc_long(v) (++*(v))
14287 +#define __acc_dec_long(v) (--*(v))
14289 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14290 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14291 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14292 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14293 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14294 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14295 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14296 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14297 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14300 +#define vx_acc_page(m, d, v, r) do { \
14302 + __acc_inc_long(&(m)->v); \
14304 + __acc_dec_long(&(m)->v); \
14305 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14308 +#define vx_acc_page_atomic(m, d, v, r) do { \
14310 + __acc_inc_atomic(&(m)->v); \
14312 + __acc_dec_atomic(&(m)->v); \
14313 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14317 +#define vx_acc_pages(m, p, v, r) do { \
14318 + unsigned long __p = (p); \
14319 + __acc_add_long(__p, &(m)->v); \
14320 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14323 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14324 + unsigned long __p = (p); \
14325 + __acc_add_atomic(__p, &(m)->v); \
14326 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14331 +#define vx_acc_vmpage(m, d) \
14332 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14333 +#define vx_acc_vmlpage(m, d) \
14334 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14335 +#define vx_acc_file_rsspage(m, d) \
14336 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14337 +#define vx_acc_anon_rsspage(m, d) \
14338 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14340 +#define vx_acc_vmpages(m, p) \
14341 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14342 +#define vx_acc_vmlpages(m, p) \
14343 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14344 +#define vx_acc_file_rsspages(m, p) \
14345 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14346 +#define vx_acc_anon_rsspages(m, p) \
14347 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14349 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14350 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14352 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14353 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14354 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14355 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14357 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14358 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14359 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14360 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14362 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14363 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14364 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14365 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14367 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14368 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14369 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14370 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14373 +#define vx_pages_avail(m, p, r) \
14374 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14376 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14377 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14378 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14379 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14381 +#define vx_rss_avail(m, p) \
14382 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14386 + VXPT_UNKNOWN = 0,
14395 +#define vx_page_fault(mm, vma, type, ret)
14399 +void __vx_page_fault(struct mm_struct *mm,
14400 + struct vm_area_struct *vma, int type, int ret)
14402 + struct vx_info *vxi = mm->mm_vx_info;
14405 + static char *page_type[6] =
14406 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14407 + static char *page_what[4] =
14408 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14414 + what = (ret & 0x3);
14416 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14417 + type, what, ret, page_type[type], page_what[what]);
14419 + if (ret & VM_FAULT_WRITE)
14421 + atomic_inc(&vxi->cacct.page[type][what]);
14424 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14428 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14431 +#warning duplicate inclusion
14433 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_network.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_network.h
14434 --- linux-2.6.27.25/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14435 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_network.h 2008-10-13 14:54:20.000000000 +0200
14437 +#ifndef _NX_VS_NETWORK_H
14438 +#define _NX_VS_NETWORK_H
14440 +#include "vserver/context.h"
14441 +#include "vserver/network.h"
14442 +#include "vserver/base.h"
14443 +#include "vserver/check.h"
14444 +#include "vserver/debug.h"
14446 +#include <linux/sched.h>
14449 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14451 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14452 + const char *_file, int _line)
14457 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14458 + nxi, nxi ? nxi->nx_id : 0,
14459 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14462 + atomic_inc(&nxi->nx_usecnt);
14467 +extern void free_nx_info(struct nx_info *);
14469 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14471 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14476 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14477 + nxi, nxi ? nxi->nx_id : 0,
14478 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14481 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14482 + free_nx_info(nxi);
14486 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14488 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14489 + const char *_file, int _line)
14492 + vxlprintk(VXD_CBIT(nid, 3),
14493 + "init_nx_info(%p[#%d.%d])",
14494 + nxi, nxi ? nxi->nx_id : 0,
14495 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14498 + atomic_inc(&nxi->nx_usecnt);
14504 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14506 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14507 + const char *_file, int _line)
14509 + struct nx_info *nxo;
14514 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14515 + nxi, nxi ? nxi->nx_id : 0,
14516 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14519 + atomic_inc(&nxi->nx_usecnt);
14520 + nxo = xchg(nxp, nxi);
14524 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14526 +static inline void __clr_nx_info(struct nx_info **nxp,
14527 + const char *_file, int _line)
14529 + struct nx_info *nxo;
14531 + nxo = xchg(nxp, NULL);
14535 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14536 + nxo, nxo ? nxo->nx_id : 0,
14537 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14540 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14541 + free_nx_info(nxo);
14545 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14547 +static inline void __claim_nx_info(struct nx_info *nxi,
14548 + struct task_struct *task, const char *_file, int _line)
14550 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14551 + nxi, nxi ? nxi->nx_id : 0,
14552 + nxi?atomic_read(&nxi->nx_usecnt):0,
14553 + nxi?atomic_read(&nxi->nx_tasks):0,
14554 + task, _file, _line);
14556 + atomic_inc(&nxi->nx_tasks);
14560 +extern void unhash_nx_info(struct nx_info *);
14562 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14564 +static inline void __release_nx_info(struct nx_info *nxi,
14565 + struct task_struct *task, const char *_file, int _line)
14567 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14568 + nxi, nxi ? nxi->nx_id : 0,
14569 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14570 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14571 + task, _file, _line);
14575 + if (atomic_dec_and_test(&nxi->nx_tasks))
14576 + unhash_nx_info(nxi);
14580 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14582 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14583 + const char *_file, int _line)
14585 + struct nx_info *nxi;
14588 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14589 + p, _file, _line);
14590 + nxi = __get_nx_info(p->nx_info, _file, _line);
14596 +static inline void exit_nx_info(struct task_struct *p)
14599 + release_nx_info(p->nx_info, p);
14604 +#warning duplicate inclusion
14606 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_pid.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_pid.h
14607 --- linux-2.6.27.25/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14608 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_pid.h 2008-10-13 14:54:20.000000000 +0200
14613 +#include "vserver/base.h"
14614 +#include "vserver/check.h"
14615 +#include "vserver/context.h"
14616 +#include "vserver/debug.h"
14617 +#include "vserver/pid.h"
14618 +#include <linux/pid_namespace.h>
14621 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14624 +int vx_proc_task_visible(struct task_struct *task)
14626 + if ((task->pid == 1) &&
14627 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14628 + /* show a blend through init */
14630 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14637 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14642 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14644 + struct task_struct *task = find_task_by_real_pid(pid);
14646 + if (task && !vx_proc_task_visible(task)) {
14647 + vxdprintk(VXD_CBIT(misc, 6),
14648 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14649 + task, task->xid, task->pid,
14650 + current, current->xid, current->pid);
14659 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14661 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14663 + if (task && !vx_proc_task_visible(task)) {
14664 + vxdprintk(VXD_CBIT(misc, 6),
14665 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14666 + task, task->xid, task->pid,
14667 + current, current->xid, current->pid);
14668 + put_task_struct(task);
14677 +struct task_struct *vx_child_reaper(struct task_struct *p)
14679 + struct vx_info *vxi = p->vx_info;
14680 + struct task_struct *reaper = child_reaper(p);
14685 + BUG_ON(!p->vx_info->vx_reaper);
14687 + /* child reaper for the guest reaper */
14688 + if (vxi->vx_reaper == p)
14691 + reaper = vxi->vx_reaper;
14693 + vxdprintk(VXD_CBIT(xid, 7),
14694 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14695 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14703 +#warning duplicate inclusion
14705 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_sched.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_sched.h
14706 --- linux-2.6.27.25/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14707 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_sched.h 2008-10-13 14:54:20.000000000 +0200
14709 +#ifndef _VS_SCHED_H
14710 +#define _VS_SCHED_H
14712 +#include "vserver/base.h"
14713 +#include "vserver/context.h"
14714 +#include "vserver/sched.h"
14717 +#define VAVAVOOM_RATIO 50
14719 +#define MAX_PRIO_BIAS 20
14720 +#define MIN_PRIO_BIAS -20
14723 +#ifdef CONFIG_VSERVER_HARDCPU
14726 + * effective_prio - return the priority that is based on the static
14727 + * priority but is modified by bonuses/penalties.
14729 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14730 + * into a -4 ... 0 ... +4 bonus/penalty range.
14732 + * Additionally, we scale another amount based on the number of
14733 + * CPU tokens currently held by the context, if the process is
14734 + * part of a context (and the appropriate SCHED flag is set).
14735 + * This ranges from -5 ... 0 ... +15, quadratically.
14737 + * So, the total bonus is -9 .. 0 .. +19
14738 + * We use ~50% of the full 0...39 priority range so that:
14740 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14741 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14742 + * unless that context is far exceeding its CPU allocation.
14744 + * Both properties are important to certain workloads.
14747 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14749 + int vavavoom, max;
14751 + /* lots of tokens = lots of vavavoom
14752 + * no tokens = no vavavoom */
14753 + if ((vavavoom = sched_pc->tokens) >= 0) {
14754 + max = sched_pc->tokens_max;
14755 + vavavoom = max - vavavoom;
14757 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14758 + * (vavavoom*vavavoom - (max >> 2)) / max;
14766 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14768 + struct vx_info *vxi = p->vx_info;
14769 + struct _vx_sched_pc *sched_pc;
14774 + sched_pc = &vx_cpu(vxi, sched_pc);
14775 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14776 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14778 + sched_pc->vavavoom = vavavoom;
14779 + prio += vavavoom;
14781 + prio += sched_pc->prio_bias;
14785 +#else /* !CONFIG_VSERVER_HARDCPU */
14788 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14790 + struct vx_info *vxi = p->vx_info;
14793 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14797 +#endif /* CONFIG_VSERVER_HARDCPU */
14800 +static inline void vx_account_user(struct vx_info *vxi,
14801 + cputime_t cputime, int nice)
14805 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14808 +static inline void vx_account_system(struct vx_info *vxi,
14809 + cputime_t cputime, int idle)
14813 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14817 +#warning duplicate inclusion
14819 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_socket.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_socket.h
14820 --- linux-2.6.27.25/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14821 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_socket.h 2008-10-13 14:54:20.000000000 +0200
14823 +#ifndef _VS_SOCKET_H
14824 +#define _VS_SOCKET_H
14826 +#include "vserver/debug.h"
14827 +#include "vserver/base.h"
14828 +#include "vserver/cacct.h"
14829 +#include "vserver/context.h"
14830 +#include "vserver/tag.h"
14833 +/* socket accounting */
14835 +#include <linux/socket.h>
14837 +static inline int vx_sock_type(int family)
14839 + switch (family) {
14841 + return VXA_SOCK_UNSPEC;
14843 + return VXA_SOCK_UNIX;
14845 + return VXA_SOCK_INET;
14847 + return VXA_SOCK_INET6;
14849 + return VXA_SOCK_PACKET;
14851 + return VXA_SOCK_OTHER;
14855 +#define vx_acc_sock(v, f, p, s) \
14856 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14858 +static inline void __vx_acc_sock(struct vx_info *vxi,
14859 + int family, int pos, int size, char *file, int line)
14862 + int type = vx_sock_type(family);
14864 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14865 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14869 +#define vx_sock_recv(sk, s) \
14870 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14871 +#define vx_sock_send(sk, s) \
14872 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14873 +#define vx_sock_fail(sk, s) \
14874 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14877 +#define sock_vx_init(s) do { \
14878 + (s)->sk_xid = 0; \
14879 + (s)->sk_vx_info = NULL; \
14882 +#define sock_nx_init(s) do { \
14883 + (s)->sk_nid = 0; \
14884 + (s)->sk_nx_info = NULL; \
14888 +#warning duplicate inclusion
14890 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_tag.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_tag.h
14891 --- linux-2.6.27.25/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14892 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_tag.h 2008-10-24 03:34:52.000000000 +0200
14897 +#include <linux/vserver/tag.h>
14899 +/* check conditions */
14901 +#define DX_ADMIN 0x0001
14902 +#define DX_WATCH 0x0002
14903 +#define DX_HOSTID 0x0008
14905 +#define DX_IDENT 0x0010
14907 +#define DX_ARG_MASK 0x0010
14910 +#define dx_task_tag(t) ((t)->tag)
14912 +#define dx_current_tag() dx_task_tag(current)
14914 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14916 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14920 + * check current context for ADMIN/WATCH and
14921 + * optionally against supplied argument
14923 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14925 + if (mode & DX_ARG_MASK) {
14926 + if ((mode & DX_IDENT) && (id == cid))
14929 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14930 + ((mode & DX_WATCH) && (cid == 1)) ||
14931 + ((mode & DX_HOSTID) && (id == 0)));
14935 +int dx_permission(struct inode *inode, int mask);
14939 +#warning duplicate inclusion
14941 diff -NurpP --minimal linux-2.6.27.25/include/linux/vs_time.h linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_time.h
14942 --- linux-2.6.27.25/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14943 +++ linux-2.6.27.25-vs2.3.0.36.6/include/linux/vs_time.h 2008-10-13 14:54:20.000000000 +0200
14945 +#ifndef _VS_TIME_H
14946 +#define _VS_TIME_H
14949 +/* time faking stuff */
14951 +#ifdef CONFIG_VSERVER_VTIME
14953 +extern void vx_gettimeofday(struct timeval *tv);
14954 +extern int vx_settimeofday(struct timespec *ts);
14957 +#define vx_gettimeofday(t) do_gettimeofday(t)
14958 +#define vx_settimeofday(t) do_settimeofday(t)
14962 +#warning duplicate inclusion
14964 diff -NurpP --minimal linux-2.6.27.25/include/net/addrconf.h linux-2.6.27.25-vs2.3.0.36.6/include/net/addrconf.h
14965 --- linux-2.6.27.25/include/net/addrconf.h 2008-10-13 14:52:09.000000000 +0200
14966 +++ linux-2.6.27.25-vs2.3.0.36.6/include/net/addrconf.h 2008-10-13 14:54:20.000000000 +0200
14967 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14968 struct net_device *dev,
14969 const struct in6_addr *daddr,
14970 unsigned int srcprefs,
14971 - struct in6_addr *saddr);
14972 + struct in6_addr *saddr,
14973 + struct nx_info *nxi);
14974 extern int ipv6_get_lladdr(struct net_device *dev,
14975 struct in6_addr *addr,
14976 unsigned char banned_flags);
14977 diff -NurpP --minimal linux-2.6.27.25/include/net/af_unix.h linux-2.6.27.25-vs2.3.0.36.6/include/net/af_unix.h
14978 --- linux-2.6.27.25/include/net/af_unix.h 2009-06-15 17:18:32.000000000 +0200
14979 +++ linux-2.6.27.25-vs2.3.0.36.6/include/net/af_unix.h 2009-02-03 17:59:04.000000000 +0100
14981 #include <linux/socket.h>
14982 #include <linux/un.h>
14983 #include <linux/mutex.h>
14984 +#include <linux/vs_base.h>
14985 #include <net/sock.h>
14987 extern void unix_inflight(struct file *fp);
14988 diff -NurpP --minimal linux-2.6.27.25/include/net/inet_sock.h linux-2.6.27.25-vs2.3.0.36.6/include/net/inet_sock.h
14989 --- linux-2.6.27.25/include/net/inet_sock.h 2008-10-13 14:52:09.000000000 +0200
14990 +++ linux-2.6.27.25-vs2.3.0.36.6/include/net/inet_sock.h 2008-10-13 14:54:20.000000000 +0200
14992 #include <net/flow.h>
14993 #include <net/sock.h>
14994 #include <net/request_sock.h>
14995 -#include <net/route.h>
14996 +// #include <net/route.h>
14997 #include <net/netns/hash.h>
14999 /** struct ip_options - IP Options
15000 @@ -195,11 +195,6 @@ static inline int inet_sk_ehashfn(const
15004 -static inline int inet_iif(const struct sk_buff *skb)
15006 - return skb->rtable->rt_iif;
15009 static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops)
15011 struct request_sock *req = reqsk_alloc(ops);
15012 diff -NurpP --minimal linux-2.6.27.25/include/net/inet_timewait_sock.h linux-2.6.27.25-vs2.3.0.36.6/include/net/inet_timewait_sock.h
15013 --- linux-2.6.27.25/include/net/inet_timewait_sock.h 2008-10-13 14:52:09.000000000 +0200
15014 +++ linux-2.6.27.25-vs2.3.0.36.6/include/net/inet_timewait_sock.h 2008-10-13 14:54:20.000000000 +0200
15015 @@ -15,15 +15,14 @@
15016 #ifndef _INET_TIMEWAIT_SOCK_
15017 #define _INET_TIMEWAIT_SOCK_
15019 +// #include <net/inet_sock.h>
15020 +#include <net/sock.h>
15022 #include <linux/list.h>
15023 #include <linux/module.h>
15024 #include <linux/timer.h>
15025 #include <linux/types.h>
15026 #include <linux/workqueue.h>
15028 -#include <net/inet_sock.h>
15029 -#include <net/sock.h>
15030 #include <net/tcp_states.h>
15031 #include <net/timewait_sock.h>
15033 @@ -116,6 +115,10 @@ struct inet_timewait_sock {
15034 #define tw_hash __tw_common.skc_hash
15035 #define tw_prot __tw_common.skc_prot
15036 #define tw_net __tw_common.skc_net
15037 +#define tw_xid __tw_common.skc_xid
15038 +#define tw_vx_info __tw_common.skc_vx_info
15039 +#define tw_nid __tw_common.skc_nid
15040 +#define tw_nx_info __tw_common.skc_nx_info
15042 volatile unsigned char tw_substate;
15043 /* 3 bits hole, try to pack */
15044 diff -NurpP --minimal linux-2.6.27.25/include/net/route.h linux-2.6.27.25-vs2.3.0.36.6/include/net/route.h
15045 --- linux-2.6.27.25/include/net/route.h 2008-10-13 14:52:09.000000000 +0200
15046 +++ linux-2.6.27.25-vs2.3.0.36.6/include/net/route.h 2008-10-13 14:54:20.000000000 +0200
15048 #include <net/inetpeer.h>
15049 #include <net/flow.h>
15050 #include <net/sock.h>
15051 +// #include <linux/in.h>
15052 #include <linux/in_route.h>
15053 #include <linux/rtnetlink.h>
15054 #include <linux/route.h>
15055 @@ -85,6 +86,11 @@ struct ip_rt_acct
15059 +static inline int inet_iif(const struct sk_buff *skb)
15061 + return skb->rtable->rt_iif;
15064 struct rt_cache_stat
15066 unsigned int in_hit;
15067 @@ -135,6 +141,9 @@ static inline void ip_rt_put(struct rtab
15068 dst_release(&rt->u.dst);
15071 +#include <linux/vs_base.h>
15072 +#include <linux/vs_inet.h>
15074 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
15076 extern const __u8 ip_tos2prio[16];
15077 @@ -144,6 +153,9 @@ static inline char rt_tos2priority(u8 to
15078 return ip_tos2prio[IPTOS_TOS(tos)>>1];
15081 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
15082 + struct rtable **, struct flowi *);
15084 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
15085 __be32 src, u32 tos, int oif, u8 protocol,
15086 __be16 sport, __be16 dport, struct sock *sk,
15087 @@ -161,7 +173,21 @@ static inline int ip_route_connect(struc
15090 struct net *net = sock_net(sk);
15091 - if (!dst || !src) {
15092 + struct nx_info *nx_info = current->nx_info;
15095 + nx_info = sk->sk_nx_info;
15097 + vxdprintk(VXD_CBIT(net, 4),
15098 + "ip_route_connect(%p) %p,%p;%lx",
15099 + sk, nx_info, sk->sk_socket,
15100 + (sk->sk_socket?sk->sk_socket->flags:0));
15102 + err = ip_v4_find_src(net, nx_info, rp, &fl);
15106 + if (!fl.fl4_dst || !fl.fl4_src) {
15107 err = __ip_route_output_key(net, rp, &fl);
15110 diff -NurpP --minimal linux-2.6.27.25/include/net/sock.h linux-2.6.27.25-vs2.3.0.36.6/include/net/sock.h
15111 --- linux-2.6.27.25/include/net/sock.h 2009-06-15 17:18:32.000000000 +0200
15112 +++ linux-2.6.27.25-vs2.3.0.36.6/include/net/sock.h 2009-03-25 14:32:29.000000000 +0100
15113 @@ -128,6 +128,10 @@ struct sock_common {
15114 #ifdef CONFIG_NET_NS
15115 struct net *skc_net;
15118 + struct vx_info *skc_vx_info;
15120 + struct nx_info *skc_nx_info;
15124 @@ -211,6 +215,10 @@ struct sock {
15125 #define sk_hash __sk_common.skc_hash
15126 #define sk_prot __sk_common.skc_prot
15127 #define sk_net __sk_common.skc_net
15128 +#define sk_xid __sk_common.skc_xid
15129 +#define sk_vx_info __sk_common.skc_vx_info
15130 +#define sk_nid __sk_common.skc_nid
15131 +#define sk_nx_info __sk_common.skc_nx_info
15132 unsigned char sk_shutdown : 2,
15135 diff -NurpP --minimal linux-2.6.27.25/init/main.c linux-2.6.27.25-vs2.3.0.36.6/init/main.c
15136 --- linux-2.6.27.25/init/main.c 2008-10-13 14:52:09.000000000 +0200
15137 +++ linux-2.6.27.25-vs2.3.0.36.6/init/main.c 2008-10-13 14:54:20.000000000 +0200
15139 #include <linux/sched.h>
15140 #include <linux/signal.h>
15141 #include <linux/idr.h>
15142 +#include <linux/vserver/percpu.h>
15144 #include <asm/io.h>
15145 #include <asm/bugs.h>
15146 @@ -391,12 +392,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
15148 static void __init setup_per_cpu_areas(void)
15150 - unsigned long size, i;
15151 + unsigned long size, vspc, i;
15153 unsigned long nr_possible_cpus = num_possible_cpus();
15155 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
15157 /* Copy section for each CPU (we discard the original) */
15158 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
15159 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
15160 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
15162 for_each_possible_cpu(i) {
15163 diff -NurpP --minimal linux-2.6.27.25/ipc/mqueue.c linux-2.6.27.25-vs2.3.0.36.6/ipc/mqueue.c
15164 --- linux-2.6.27.25/ipc/mqueue.c 2009-06-15 17:18:32.000000000 +0200
15165 +++ linux-2.6.27.25-vs2.3.0.36.6/ipc/mqueue.c 2009-02-22 22:58:33.000000000 +0100
15167 #include <linux/mutex.h>
15168 #include <linux/nsproxy.h>
15169 #include <linux/pid.h>
15170 +#include <linux/vs_context.h>
15171 +#include <linux/vs_limit.h>
15173 #include <net/sock.h>
15175 @@ -71,6 +73,7 @@ struct mqueue_inode_info {
15176 struct sigevent notify;
15177 struct pid* notify_owner;
15178 struct user_struct *user; /* user who created, for accounting */
15179 + struct vx_info *vxi;
15180 struct sock *notify_sock;
15181 struct sk_buff *notify_cookie;
15183 @@ -119,6 +122,7 @@ static struct inode *mqueue_get_inode(st
15184 struct mqueue_inode_info *info;
15185 struct task_struct *p = current;
15186 struct user_struct *u = p->user;
15187 + struct vx_info *vxi = p->vx_info;
15188 unsigned long mq_bytes, mq_msg_tblsz;
15190 inode->i_fop = &mqueue_file_operations;
15191 @@ -133,6 +137,7 @@ static struct inode *mqueue_get_inode(st
15192 info->notify_owner = NULL;
15194 info->user = NULL; /* set when all is ok */
15195 + info->vxi = NULL;
15196 memset(&info->attr, 0, sizeof(info->attr));
15197 info->attr.mq_maxmsg = DFLT_MSGMAX;
15198 info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
15199 @@ -147,22 +152,26 @@ static struct inode *mqueue_get_inode(st
15200 spin_lock(&mq_lock);
15201 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15202 u->mq_bytes + mq_bytes >
15203 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
15204 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
15205 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
15206 spin_unlock(&mq_lock);
15209 u->mq_bytes += mq_bytes;
15210 + vx_ipcmsg_add(vxi, u, mq_bytes);
15211 spin_unlock(&mq_lock);
15213 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
15214 if (!info->messages) {
15215 spin_lock(&mq_lock);
15216 u->mq_bytes -= mq_bytes;
15217 + vx_ipcmsg_sub(vxi, u, mq_bytes);
15218 spin_unlock(&mq_lock);
15222 info->user = get_uid(u);
15223 + info->vxi = get_vx_info(vxi);
15224 } else if (S_ISDIR(mode)) {
15226 /* Some things misbehave if size == 0 on a directory */
15227 @@ -253,10 +262,14 @@ static void mqueue_delete_inode(struct i
15228 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
15231 + struct vx_info *vxi = info->vxi;
15233 spin_lock(&mq_lock);
15234 user->mq_bytes -= mq_bytes;
15235 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15237 spin_unlock(&mq_lock);
15238 + put_vx_info(vxi);
15242 diff -NurpP --minimal linux-2.6.27.25/ipc/msg.c linux-2.6.27.25-vs2.3.0.36.6/ipc/msg.c
15243 --- linux-2.6.27.25/ipc/msg.c 2009-06-15 17:18:32.000000000 +0200
15244 +++ linux-2.6.27.25-vs2.3.0.36.6/ipc/msg.c 2009-02-03 17:59:04.000000000 +0100
15246 #include <linux/rwsem.h>
15247 #include <linux/nsproxy.h>
15248 #include <linux/ipc_namespace.h>
15249 +#include <linux/vs_base.h>
15251 #include <asm/current.h>
15252 #include <asm/uaccess.h>
15253 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
15255 msq->q_perm.mode = msgflg & S_IRWXUGO;
15256 msq->q_perm.key = key;
15257 + msq->q_perm.xid = vx_current_xid();
15259 msq->q_perm.security = NULL;
15260 retval = security_msg_queue_alloc(msq);
15261 diff -NurpP --minimal linux-2.6.27.25/ipc/namespace.c linux-2.6.27.25-vs2.3.0.36.6/ipc/namespace.c
15262 --- linux-2.6.27.25/ipc/namespace.c 2008-07-13 23:51:29.000000000 +0200
15263 +++ linux-2.6.27.25-vs2.3.0.36.6/ipc/namespace.c 2008-10-13 14:54:20.000000000 +0200
15265 #include <linux/rcupdate.h>
15266 #include <linux/nsproxy.h>
15267 #include <linux/slab.h>
15268 +#include <linux/vs_base.h>
15269 +#include <linux/vserver/global.h>
15273 @@ -35,6 +37,7 @@ static struct ipc_namespace *clone_ipc_n
15274 register_ipcns_notifier(ns);
15276 kref_init(&ns->kref);
15277 + atomic_inc(&vs_global_ipc_ns);
15281 @@ -101,6 +104,7 @@ void free_ipc_ns(struct kref *kref)
15285 + atomic_dec(&vs_global_ipc_ns);
15287 atomic_dec(&nr_ipc_ns);
15289 diff -NurpP --minimal linux-2.6.27.25/ipc/sem.c linux-2.6.27.25-vs2.3.0.36.6/ipc/sem.c
15290 --- linux-2.6.27.25/ipc/sem.c 2009-06-15 17:18:32.000000000 +0200
15291 +++ linux-2.6.27.25-vs2.3.0.36.6/ipc/sem.c 2009-03-31 19:53:55.000000000 +0200
15293 #include <linux/rwsem.h>
15294 #include <linux/nsproxy.h>
15295 #include <linux/ipc_namespace.h>
15296 +#include <linux/vs_base.h>
15297 +#include <linux/vs_limit.h>
15299 #include <asm/uaccess.h>
15301 @@ -255,6 +257,7 @@ static int newary(struct ipc_namespace *
15303 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15304 sma->sem_perm.key = key;
15305 + sma->sem_perm.xid = vx_current_xid();
15307 sma->sem_perm.security = NULL;
15308 retval = security_sem_alloc(sma);
15309 @@ -270,6 +273,9 @@ static int newary(struct ipc_namespace *
15312 ns->used_sems += nsems;
15313 + /* FIXME: obsoleted? */
15314 + vx_semary_inc(sma);
15315 + vx_nsems_add(sma, nsems);
15317 sma->sem_base = (struct sem *) &sma[1];
15318 INIT_LIST_HEAD(&sma->sem_pending);
15319 @@ -546,6 +552,9 @@ static void freeary(struct ipc_namespace
15322 ns->used_sems -= sma->sem_nsems;
15323 + /* FIXME: obsoleted? */
15324 + vx_nsems_sub(sma, sma->sem_nsems);
15325 + vx_semary_dec(sma);
15326 security_sem_free(sma);
15327 ipc_rcu_putref(sma);
15329 diff -NurpP --minimal linux-2.6.27.25/ipc/shm.c linux-2.6.27.25-vs2.3.0.36.6/ipc/shm.c
15330 --- linux-2.6.27.25/ipc/shm.c 2009-06-15 17:18:32.000000000 +0200
15331 +++ linux-2.6.27.25-vs2.3.0.36.6/ipc/shm.c 2009-02-22 22:58:33.000000000 +0100
15333 #include <linux/nsproxy.h>
15334 #include <linux/mount.h>
15335 #include <linux/ipc_namespace.h>
15336 +#include <linux/vs_context.h>
15337 +#include <linux/vs_limit.h>
15339 #include <asm/uaccess.h>
15341 @@ -168,7 +170,12 @@ static void shm_open(struct vm_area_stru
15343 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15345 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15346 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15347 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15349 + vx_ipcshm_sub(vxi, shp, numpages);
15350 + ns->shm_tot -= numpages;
15354 if (!is_file_hugepages(shp->shm_file))
15355 @@ -178,6 +185,7 @@ static void shm_destroy(struct ipc_names
15357 fput (shp->shm_file);
15358 security_shm_free(shp);
15359 + put_vx_info(vxi);
15360 ipc_rcu_putref(shp);
15363 @@ -347,11 +355,15 @@ static int newseg(struct ipc_namespace *
15364 if (ns->shm_tot + numpages > ns->shm_ctlall)
15367 + if (!vx_ipcshm_avail(current->vx_info, numpages))
15370 shp = ipc_rcu_alloc(sizeof(*shp));
15374 shp->shm_perm.key = key;
15375 + shp->shm_perm.xid = vx_current_xid();
15376 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15377 shp->mlock_user = NULL;
15379 @@ -404,6 +416,7 @@ static int newseg(struct ipc_namespace *
15380 ns->shm_tot += numpages;
15381 error = shp->shm_perm.id;
15383 + vx_ipcshm_add(current->vx_info, key, numpages);
15387 diff -NurpP --minimal linux-2.6.27.25/kernel/capability.c linux-2.6.27.25-vs2.3.0.36.6/kernel/capability.c
15388 --- linux-2.6.27.25/kernel/capability.c 2009-06-15 17:18:32.000000000 +0200
15389 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/capability.c 2009-02-03 17:59:04.000000000 +0100
15391 #include <linux/security.h>
15392 #include <linux/syscalls.h>
15393 #include <linux/pid_namespace.h>
15394 +#include <linux/vs_context.h>
15395 #include <asm/uaccess.h>
15398 @@ -166,6 +167,8 @@ static inline int cap_set_pg(int pgrp_nr
15400 pgrp = find_vpid(pgrp_nr);
15401 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
15402 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
15405 while_each_thread(g, target) {
15406 if (!security_capset_check(target, effective,
15407 @@ -486,6 +489,8 @@ SYSCALL_DEFINE2(capset, cap_user_header_
15411 +#include <linux/vserver/base.h>
15414 * capable - Determine if the current task has a superior capability in effect
15415 * @cap: The capability to be tested for
15416 @@ -498,6 +503,9 @@ SYSCALL_DEFINE2(capset, cap_user_header_
15418 int capable(int cap)
15420 + /* here for now so we don't require task locking */
15421 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15423 if (has_capability(current, cap)) {
15424 current->flags |= PF_SUPERPRIV;
15426 diff -NurpP --minimal linux-2.6.27.25/kernel/compat.c linux-2.6.27.25-vs2.3.0.36.6/kernel/compat.c
15427 --- linux-2.6.27.25/kernel/compat.c 2008-07-13 23:51:29.000000000 +0200
15428 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/compat.c 2008-10-13 14:54:20.000000000 +0200
15429 @@ -845,7 +845,7 @@ asmlinkage long compat_sys_time(compat_t
15433 - do_gettimeofday(&tv);
15434 + vx_gettimeofday(&tv);
15438 @@ -869,7 +869,7 @@ asmlinkage long compat_sys_stime(compat_
15442 - do_settimeofday(&tv);
15443 + vx_settimeofday(&tv);
15447 diff -NurpP --minimal linux-2.6.27.25/kernel/exit.c linux-2.6.27.25-vs2.3.0.36.6/kernel/exit.c
15448 --- linux-2.6.27.25/kernel/exit.c 2009-06-15 17:18:32.000000000 +0200
15449 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/exit.c 2009-05-15 22:57:04.000000000 +0200
15451 #include <linux/blkdev.h>
15452 #include <linux/task_io_accounting_ops.h>
15453 #include <linux/tracehook.h>
15454 +#include <linux/vs_limit.h>
15455 +#include <linux/vs_context.h>
15456 +#include <linux/vs_network.h>
15457 +#include <linux/vs_pid.h>
15458 +#include <linux/vserver/global.h>
15460 #include <asm/uaccess.h>
15461 #include <asm/unistd.h>
15462 @@ -485,9 +490,11 @@ static void close_files(struct files_str
15463 filp_close(file, files);
15466 + vx_openfd_dec(i);
15474 @@ -554,6 +561,7 @@ void put_fs_struct(struct fs_struct *fs)
15475 if (atomic_dec_and_test(&fs->count)) {
15476 path_put(&fs->root);
15477 path_put(&fs->pwd);
15478 + atomic_dec(&vs_global_fs);
15479 kmem_cache_free(fs_cachep, fs);
15482 @@ -1121,11 +1129,16 @@ NORET_TYPE void do_exit(long code)
15483 if (tsk->splice_pipe)
15484 __free_pipe_info(tsk->splice_pipe);
15486 + /* needs to stay after exit_notify() */
15487 + exit_vx_info(tsk, code);
15488 + exit_nx_info(tsk);
15491 /* causes final put_task_struct in finish_task_switch(). */
15492 tsk->state = TASK_DEAD;
15495 + printk("bad task: %p [%lx]\n", current, current->state);
15497 /* Avoid "noreturn function does return". */
15499 diff -NurpP --minimal linux-2.6.27.25/kernel/fork.c linux-2.6.27.25-vs2.3.0.36.6/kernel/fork.c
15500 --- linux-2.6.27.25/kernel/fork.c 2009-06-15 17:18:32.000000000 +0200
15501 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/fork.c 2009-03-25 14:32:29.000000000 +0100
15503 #include <linux/tty.h>
15504 #include <linux/proc_fs.h>
15505 #include <linux/blkdev.h>
15506 +#include <linux/vs_context.h>
15507 +#include <linux/vs_network.h>
15508 +#include <linux/vs_limit.h>
15509 +#include <linux/vs_memory.h>
15510 +#include <linux/vserver/global.h>
15512 #include <asm/pgtable.h>
15513 #include <asm/pgalloc.h>
15514 @@ -135,6 +140,8 @@ void free_task(struct task_struct *tsk)
15515 prop_local_destroy_single(&tsk->dirties);
15516 free_thread_info(tsk->stack);
15517 rt_mutex_debug_task_free(tsk);
15518 + clr_vx_info(&tsk->vx_info);
15519 + clr_nx_info(&tsk->nx_info);
15520 free_task_struct(tsk);
15522 EXPORT_SYMBOL(free_task);
15523 @@ -274,6 +281,8 @@ static int dup_mmap(struct mm_struct *mm
15524 mm->free_area_cache = oldmm->mmap_base;
15525 mm->cached_hole_size = ~0UL;
15527 + __set_mm_counter(mm, file_rss, 0);
15528 + __set_mm_counter(mm, anon_rss, 0);
15529 cpus_clear(mm->cpu_vm_mask);
15530 mm->mm_rb = RB_ROOT;
15531 rb_link = &mm->mm_rb.rb_node;
15532 @@ -285,7 +294,7 @@ static int dup_mmap(struct mm_struct *mm
15534 if (mpnt->vm_flags & VM_DONTCOPY) {
15535 long pages = vma_pages(mpnt);
15536 - mm->total_vm -= pages;
15537 + vx_vmpages_sub(mm, pages);
15538 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15541 @@ -407,8 +416,8 @@ static struct mm_struct * mm_init(struct
15542 : MMF_DUMP_FILTER_DEFAULT;
15543 mm->core_state = NULL;
15545 - set_mm_counter(mm, file_rss, 0);
15546 - set_mm_counter(mm, anon_rss, 0);
15547 + __set_mm_counter(mm, file_rss, 0);
15548 + __set_mm_counter(mm, anon_rss, 0);
15549 spin_lock_init(&mm->page_table_lock);
15550 rwlock_init(&mm->ioctx_list_lock);
15551 mm->ioctx_list = NULL;
15552 @@ -419,6 +428,7 @@ static struct mm_struct * mm_init(struct
15553 if (likely(!mm_alloc_pgd(mm))) {
15555 mmu_notifier_mm_init(mm);
15556 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15560 @@ -452,6 +462,7 @@ void __mmdrop(struct mm_struct *mm)
15562 destroy_context(mm);
15563 mmu_notifier_mm_destroy(mm);
15564 + clr_vx_info(&mm->mm_vx_info);
15567 EXPORT_SYMBOL_GPL(__mmdrop);
15568 @@ -568,6 +579,7 @@ struct mm_struct *dup_mm(struct task_str
15571 memcpy(mm, oldmm, sizeof(*mm));
15572 + mm->mm_vx_info = NULL;
15574 /* Initializing for Swap token stuff */
15575 mm->token_priority = 0;
15576 @@ -601,6 +613,7 @@ fail_nocontext:
15577 * If init_new_context() failed, we cannot use mmput() to free the mm
15578 * because it calls destroy_context()
15580 + clr_vx_info(&mm->mm_vx_info);
15584 @@ -664,6 +677,7 @@ static struct fs_struct *__copy_fs_struc
15585 fs->pwd = old->pwd;
15586 path_get(&old->pwd);
15587 read_unlock(&old->lock);
15588 + atomic_inc(&vs_global_fs);
15592 @@ -907,6 +921,8 @@ static struct task_struct *copy_process(
15594 struct task_struct *p;
15595 int cgroup_callbacks_done = 0;
15596 + struct vx_info *vxi;
15597 + struct nx_info *nxi;
15599 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15600 return ERR_PTR(-EINVAL);
15601 @@ -941,12 +957,28 @@ static struct task_struct *copy_process(
15602 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15603 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15605 + init_vx_info(&p->vx_info, current->vx_info);
15606 + init_nx_info(&p->nx_info, current->nx_info);
15608 + /* check vserver memory */
15609 + if (p->mm && !(clone_flags & CLONE_VM)) {
15610 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15611 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15613 + goto bad_fork_free;
15615 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15616 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15617 + goto bad_fork_cleanup_vm;
15620 + if (!vx_nproc_avail(1))
15621 + goto bad_fork_cleanup_vm;
15622 if (atomic_read(&p->user->processes) >=
15623 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15624 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15625 p->user != current->nsproxy->user_ns->root_user)
15626 - goto bad_fork_free;
15627 + goto bad_fork_cleanup_vm;
15630 atomic_inc(&p->user->__count);
15631 @@ -1243,6 +1275,18 @@ static struct task_struct *copy_process(
15634 spin_unlock(¤t->sighand->siglock);
15636 + /* p is copy of current */
15637 + vxi = p->vx_info;
15639 + claim_vx_info(vxi, p);
15640 + atomic_inc(&vxi->cvirt.nr_threads);
15641 + atomic_inc(&vxi->cvirt.total_forks);
15644 + nxi = p->nx_info;
15646 + claim_nx_info(nxi, p);
15647 write_unlock_irq(&tasklist_lock);
15648 proc_fork_connector(p);
15649 cgroup_post_fork(p);
15650 @@ -1289,6 +1333,9 @@ bad_fork_cleanup_count:
15651 put_group_info(p->group_info);
15652 atomic_dec(&p->user->processes);
15654 +bad_fork_cleanup_vm:
15655 + if (p->mm && !(clone_flags & CLONE_VM))
15656 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15660 diff -NurpP --minimal linux-2.6.27.25/kernel/kthread.c linux-2.6.27.25-vs2.3.0.36.6/kernel/kthread.c
15661 --- linux-2.6.27.25/kernel/kthread.c 2008-10-13 14:52:09.000000000 +0200
15662 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/kthread.c 2008-10-13 14:54:20.000000000 +0200
15664 #include <linux/file.h>
15665 #include <linux/module.h>
15666 #include <linux/mutex.h>
15667 +#include <linux/vs_pid.h>
15669 #define KTHREAD_NICE_LEVEL (-5)
15671 @@ -98,7 +99,7 @@ static void create_kthread(struct kthrea
15672 struct sched_param param = { .sched_priority = 0 };
15673 wait_for_completion(&create->started);
15674 read_lock(&tasklist_lock);
15675 - create->result = find_task_by_pid_ns(pid, &init_pid_ns);
15676 + create->result = find_task_by_real_pid(pid);
15677 read_unlock(&tasklist_lock);
15679 * root may have changed our (kthreadd's) priority or CPU mask.
15680 diff -NurpP --minimal linux-2.6.27.25/kernel/Makefile linux-2.6.27.25-vs2.3.0.36.6/kernel/Makefile
15681 --- linux-2.6.27.25/kernel/Makefile 2009-06-15 17:18:32.000000000 +0200
15682 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/Makefile 2009-02-03 17:59:04.000000000 +0100
15683 @@ -22,6 +22,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
15684 CFLAGS_REMOVE_sched.o = -pg
15688 obj-$(CONFIG_PROFILING) += profile.o
15689 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15690 obj-$(CONFIG_STACKTRACE) += stacktrace.o
15691 diff -NurpP --minimal linux-2.6.27.25/kernel/nsproxy.c linux-2.6.27.25-vs2.3.0.36.6/kernel/nsproxy.c
15692 --- linux-2.6.27.25/kernel/nsproxy.c 2008-10-13 14:52:09.000000000 +0200
15693 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/nsproxy.c 2008-10-13 14:54:20.000000000 +0200
15695 #include <linux/mnt_namespace.h>
15696 #include <linux/utsname.h>
15697 #include <linux/pid_namespace.h>
15698 +#include <linux/vserver/global.h>
15699 +#include <linux/vserver/debug.h>
15700 #include <net/net_namespace.h>
15701 #include <linux/ipc_namespace.h>
15703 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
15705 memcpy(ns, orig, sizeof(struct nsproxy));
15706 atomic_set(&ns->count, 1);
15707 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
15708 + orig, atomic_read(&orig->count), ns);
15709 + atomic_inc(&vs_global_nsproxy);
15713 @@ -46,47 +51,51 @@ static inline struct nsproxy *clone_nspr
15714 * Return the newly created nsproxy. Do not attach this to the task,
15715 * leave it to the caller to do proper locking and attach it to task.
15717 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15718 - struct task_struct *tsk, struct fs_struct *new_fs)
15719 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15720 + struct nsproxy *orig, struct fs_struct *new_fs)
15722 struct nsproxy *new_nsp;
15725 - new_nsp = clone_nsproxy(tsk->nsproxy);
15726 + vxdprintk(VXD_CBIT(space, 4),
15727 + "unshare_namespaces(0x%08lx,%p,%p)",
15728 + flags, orig, new_fs);
15730 + new_nsp = clone_nsproxy(orig);
15732 return ERR_PTR(-ENOMEM);
15734 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15735 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15736 if (IS_ERR(new_nsp->mnt_ns)) {
15737 err = PTR_ERR(new_nsp->mnt_ns);
15741 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15742 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15743 if (IS_ERR(new_nsp->uts_ns)) {
15744 err = PTR_ERR(new_nsp->uts_ns);
15748 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15749 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15750 if (IS_ERR(new_nsp->ipc_ns)) {
15751 err = PTR_ERR(new_nsp->ipc_ns);
15755 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15756 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15757 if (IS_ERR(new_nsp->pid_ns)) {
15758 err = PTR_ERR(new_nsp->pid_ns);
15762 - new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
15763 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15764 if (IS_ERR(new_nsp->user_ns)) {
15765 err = PTR_ERR(new_nsp->user_ns);
15769 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15770 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15771 if (IS_ERR(new_nsp->net_ns)) {
15772 err = PTR_ERR(new_nsp->net_ns);
15774 @@ -114,6 +123,37 @@ out_ns:
15775 return ERR_PTR(err);
15778 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15779 + struct fs_struct *new_fs)
15781 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15785 + * copies the nsproxy, setting refcount to 1, and grabbing a
15786 + * reference to all contained namespaces.
15788 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15790 + struct nsproxy *ns = clone_nsproxy(orig);
15794 + get_mnt_ns(ns->mnt_ns);
15796 + get_uts_ns(ns->uts_ns);
15798 + get_ipc_ns(ns->ipc_ns);
15800 + get_pid_ns(ns->pid_ns);
15802 + get_user_ns(ns->user_ns);
15804 + get_net(ns->net_ns);
15810 * called from clone. This now handles copy for nsproxy and all
15811 * namespaces therein.
15812 @@ -121,9 +161,12 @@ out_ns:
15813 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15815 struct nsproxy *old_ns = tsk->nsproxy;
15816 - struct nsproxy *new_ns;
15817 + struct nsproxy *new_ns = NULL;
15820 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15821 + flags, tsk, old_ns);
15826 @@ -160,6 +203,9 @@ int copy_namespaces(unsigned long flags,
15829 put_nsproxy(old_ns);
15830 + vxdprintk(VXD_CBIT(space, 3),
15831 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15832 + flags, tsk, old_ns, err, new_ns);
15836 @@ -175,7 +221,9 @@ void free_nsproxy(struct nsproxy *ns)
15837 put_pid_ns(ns->pid_ns);
15839 put_user_ns(ns->user_ns);
15840 - put_net(ns->net_ns);
15842 + put_net(ns->net_ns);
15843 + atomic_dec(&vs_global_nsproxy);
15844 kmem_cache_free(nsproxy_cachep, ns);
15847 @@ -188,6 +236,10 @@ int unshare_nsproxy_namespaces(unsigned
15851 + vxdprintk(VXD_CBIT(space, 4),
15852 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15853 + unshare_flags, current->nsproxy);
15855 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15856 CLONE_NEWUSER | CLONE_NEWNET)))
15858 diff -NurpP --minimal linux-2.6.27.25/kernel/pid.c linux-2.6.27.25-vs2.3.0.36.6/kernel/pid.c
15859 --- linux-2.6.27.25/kernel/pid.c 2008-10-13 14:52:09.000000000 +0200
15860 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/pid.c 2008-10-13 14:54:20.000000000 +0200
15862 #include <linux/pid_namespace.h>
15863 #include <linux/init_task.h>
15864 #include <linux/syscalls.h>
15865 +#include <linux/vs_pid.h>
15866 +#include <linux/vserver/global.h>
15868 #define pid_hashfn(nr, ns) \
15869 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15870 @@ -305,7 +307,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15872 struct pid *find_vpid(int nr)
15874 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15875 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15877 EXPORT_SYMBOL_GPL(find_vpid);
15879 @@ -365,6 +367,9 @@ void transfer_pid(struct task_struct *ol
15880 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15882 struct task_struct *result = NULL;
15884 + if (type == PIDTYPE_REALPID)
15885 + type = PIDTYPE_PID;
15887 struct hlist_node *first;
15888 first = rcu_dereference(pid->tasks[type].first);
15889 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid_type_ns);
15891 struct task_struct *find_task_by_vpid(pid_t vnr)
15893 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
15894 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
15895 current->nsproxy->pid_ns);
15897 EXPORT_SYMBOL(find_task_by_vpid);
15899 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15901 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
15902 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
15904 EXPORT_SYMBOL(find_task_by_pid_ns);
15906 @@ -431,7 +436,7 @@ struct pid *find_get_pid(pid_t nr)
15908 EXPORT_SYMBOL_GPL(find_get_pid);
15910 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15911 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15915 @@ -444,6 +449,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15919 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15921 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15924 pid_t pid_vnr(struct pid *pid)
15926 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15927 diff -NurpP --minimal linux-2.6.27.25/kernel/pid_namespace.c linux-2.6.27.25-vs2.3.0.36.6/kernel/pid_namespace.c
15928 --- linux-2.6.27.25/kernel/pid_namespace.c 2008-10-13 14:52:09.000000000 +0200
15929 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/pid_namespace.c 2008-10-13 14:54:20.000000000 +0200
15931 #include <linux/syscalls.h>
15932 #include <linux/err.h>
15933 #include <linux/acct.h>
15934 +#include <linux/vserver/global.h>
15936 #define BITS_PER_PAGE (PAGE_SIZE*8)
15938 @@ -85,6 +86,7 @@ static struct pid_namespace *create_pid_
15941 kref_init(&ns->kref);
15942 + atomic_inc(&vs_global_pid_ns);
15945 set_bit(0, ns->pidmap[0].page);
15946 @@ -109,6 +111,7 @@ static void destroy_pid_namespace(struct
15948 for (i = 0; i < PIDMAP_ENTRIES; i++)
15949 kfree(ns->pidmap[i].page);
15950 + atomic_dec(&vs_global_pid_ns);
15951 kmem_cache_free(pid_ns_cachep, ns);
15954 diff -NurpP --minimal linux-2.6.27.25/kernel/posix-timers.c linux-2.6.27.25-vs2.3.0.36.6/kernel/posix-timers.c
15955 --- linux-2.6.27.25/kernel/posix-timers.c 2009-06-15 17:18:32.000000000 +0200
15956 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/posix-timers.c 2009-02-03 17:59:04.000000000 +0100
15958 #include <linux/wait.h>
15959 #include <linux/workqueue.h>
15960 #include <linux/module.h>
15961 +#include <linux/vs_context.h>
15964 * Management arrays for POSIX timers. Timers are kept in slab memory
15965 @@ -298,6 +299,12 @@ void do_schedule_next_timer(struct sigin
15967 int posix_timer_event(struct k_itimer *timr, int si_private)
15969 + struct vx_info_save vxis;
15970 + struct vx_info *vxi;
15973 + vxi = task_get_vx_info(timr->it_process);
15974 + enter_vx_info(vxi, &vxis);
15976 * FIXME: if ->sigq is queued we can race with
15977 * dequeue_signal()->do_schedule_next_timer().
15978 @@ -318,10 +325,11 @@ int posix_timer_event(struct k_itimer *t
15980 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
15981 struct task_struct *leader;
15982 - int ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15984 + ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15986 if (likely(ret >= 0))
15990 timr->it_sigev_notify = SIGEV_SIGNAL;
15991 leader = timr->it_process->group_leader;
15992 @@ -329,7 +337,11 @@ int posix_timer_event(struct k_itimer *t
15993 timr->it_process = leader;
15996 - return send_sigqueue(timr->sigq, timr->it_process, 1);
15997 + ret = send_sigqueue(timr->sigq, timr->it_process, 1);
15999 + leave_vx_info(&vxis);
16000 + put_vx_info(vxi);
16003 EXPORT_SYMBOL_GPL(posix_timer_event);
16005 diff -NurpP --minimal linux-2.6.27.25/kernel/printk.c linux-2.6.27.25-vs2.3.0.36.6/kernel/printk.c
16006 --- linux-2.6.27.25/kernel/printk.c 2009-06-15 17:18:32.000000000 +0200
16007 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/printk.c 2009-02-03 17:59:04.000000000 +0100
16009 #include <linux/security.h>
16010 #include <linux/bootmem.h>
16011 #include <linux/syscalls.h>
16012 +#include <linux/vs_cvirt.h>
16014 #include <asm/uaccess.h>
16016 @@ -291,18 +292,13 @@ int do_syslog(int type, char __user *buf
16017 unsigned i, j, limit, count;
16023 error = security_syslog(type);
16028 - case 0: /* Close log */
16030 - case 1: /* Open log */
16032 - case 2: /* Read from log */
16033 + if ((type >= 2) && (type <= 4)) {
16035 if (!buf || len < 0)
16037 @@ -313,6 +309,16 @@ int do_syslog(int type, char __user *buf
16042 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16043 + return vx_do_syslog(type, buf, len);
16046 + case 0: /* Close log */
16048 + case 1: /* Open log */
16050 + case 2: /* Read from log */
16051 error = wait_event_interruptible(log_wait,
16052 (log_start - log_end));
16054 @@ -337,16 +343,6 @@ int do_syslog(int type, char __user *buf
16057 case 3: /* Read last kernel messages */
16059 - if (!buf || len < 0)
16064 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16069 if (count > log_buf_len)
16070 count = log_buf_len;
16071 diff -NurpP --minimal linux-2.6.27.25/kernel/ptrace.c linux-2.6.27.25-vs2.3.0.36.6/kernel/ptrace.c
16072 --- linux-2.6.27.25/kernel/ptrace.c 2009-06-15 17:18:33.000000000 +0200
16073 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/ptrace.c 2009-02-03 17:59:04.000000000 +0100
16075 #include <linux/audit.h>
16076 #include <linux/pid_namespace.h>
16077 #include <linux/syscalls.h>
16078 +#include <linux/vs_context.h>
16080 #include <asm/pgtable.h>
16081 #include <asm/uaccess.h>
16082 @@ -139,6 +140,11 @@ int __ptrace_may_access(struct task_stru
16083 dumpable = get_dumpable(task->mm);
16084 if (!dumpable && !capable(CAP_SYS_PTRACE))
16086 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16088 + if (!vx_check(task->xid, VS_IDENT) &&
16089 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16092 return security_ptrace_may_access(task, mode);
16094 @@ -567,6 +573,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
16099 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16100 + goto out_put_task_struct;
16102 if (request == PTRACE_ATTACH) {
16103 ret = ptrace_attach(child);
16105 diff -NurpP --minimal linux-2.6.27.25/kernel/sched.c linux-2.6.27.25-vs2.3.0.36.6/kernel/sched.c
16106 --- linux-2.6.27.25/kernel/sched.c 2009-06-15 17:18:33.000000000 +0200
16107 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sched.c 2009-03-09 15:36:36.000000000 +0100
16109 #include <linux/debugfs.h>
16110 #include <linux/ctype.h>
16111 #include <linux/ftrace.h>
16112 +#include <linux/vs_sched.h>
16113 +#include <linux/vs_cvirt.h>
16115 #include <asm/tlb.h>
16116 #include <asm/irq_regs.h>
16117 @@ -577,6 +579,16 @@ struct rq {
16119 struct hrtimer hrtick_timer;
16121 + unsigned long norm_time;
16122 + unsigned long idle_time;
16123 +#ifdef CONFIG_VSERVER_IDLETIME
16126 +#ifdef CONFIG_VSERVER_HARDCPU
16127 + struct list_head hold_queue;
16128 + unsigned long nr_onhold;
16132 #ifdef CONFIG_SCHEDSTATS
16133 /* latency stats */
16134 @@ -1640,6 +1652,7 @@ static void update_avg(u64 *avg, u64 sam
16136 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
16138 + // BUG_ON(p->state & TASK_ONHOLD);
16139 sched_info_queued(p);
16140 p->sched_class->enqueue_task(rq, p, wakeup);
16142 @@ -1763,6 +1776,8 @@ static inline void check_class_changed(s
16143 p->sched_class->prio_changed(rq, p, oldprio, running);
16146 +#include "sched_mon.h"
16150 /* Used instead of source_load when we know the type == 0 */
16151 @@ -1846,6 +1861,7 @@ migrate_task(struct task_struct *p, int
16153 struct rq *rq = task_rq(p);
16155 + vxm_migrate_task(p, rq, dest_cpu);
16157 * If the task is not on a runqueue (and not running), then
16158 * it is sufficient to simply update the task's cpu field.
16159 @@ -2178,6 +2194,8 @@ static int sched_balance_self(int cpu, i
16161 #endif /* CONFIG_SMP */
16163 +#include "sched_hard.h"
16166 * try_to_wake_up - wake up a thread
16167 * @p: the to-be-woken-up thread
16168 @@ -2221,6 +2239,13 @@ static int try_to_wake_up(struct task_st
16170 rq = task_rq_lock(p, &flags);
16171 old_state = p->state;
16173 + /* we need to unhold suspended tasks */
16174 + if (old_state & TASK_ONHOLD) {
16175 + vx_unhold_task(p, rq);
16176 + old_state = p->state;
16179 if (!(old_state & state))
16182 @@ -2242,6 +2267,12 @@ static int try_to_wake_up(struct task_st
16183 /* might preempt at this point */
16184 rq = task_rq_lock(p, &flags);
16185 old_state = p->state;
16187 + /* we need to unhold suspended tasks
16188 + if (old_state & TASK_ONHOLD) {
16189 + vx_unhold_task(p, rq);
16190 + old_state = p->state;
16192 if (!(old_state & state))
16195 @@ -4067,13 +4098,16 @@ unsigned long long task_sched_runtime(st
16196 void account_user_time(struct task_struct *p, cputime_t cputime)
16198 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16199 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16201 + int nice = (TASK_NICE(p) > 0);
16203 p->utime = cputime_add(p->utime, cputime);
16204 + vx_account_user(vxi, cputime, nice);
16206 /* Add user time to cpustat. */
16207 tmp = cputime_to_cputime64(cputime);
16208 - if (TASK_NICE(p) > 0)
16210 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16212 cpustat->user = cputime64_add(cpustat->user, tmp);
16213 @@ -4120,6 +4154,7 @@ void account_system_time(struct task_str
16216 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16217 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16218 struct rq *rq = this_rq();
16221 @@ -4129,6 +4164,7 @@ void account_system_time(struct task_str
16224 p->stime = cputime_add(p->stime, cputime);
16225 + vx_account_system(vxi, cputime, (p == rq->idle));
16227 /* Add system time to cpustat. */
16228 tmp = cputime_to_cputime64(cputime);
16229 @@ -4451,6 +4487,11 @@ need_resched_nonpreemptible:
16230 idle_balance(cpu, rq);
16232 prev->sched_class->put_prev_task(rq, prev);
16234 + vx_set_rq_time(rq, jiffies); /* update time */
16235 + vx_schedule(prev, rq, cpu); /* hold if over limit */
16236 + vx_try_unhold(rq, cpu); /* unhold if refilled */
16238 next = pick_next_task(rq, prev);
16240 if (likely(prev != next)) {
16241 @@ -4963,7 +5004,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16244 if (increment < 0 && !can_nice(current, nice))
16246 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16248 retval = security_task_setnice(current, nice);
16250 @@ -8173,7 +8214,10 @@ void __init sched_init(void)
16253 #endif /* CONFIG_FAIR_GROUP_SCHED */
16255 +#ifdef CONFIG_VSERVER_HARDCPU
16256 + INIT_LIST_HEAD(&rq->hold_queue);
16257 + rq->nr_onhold = 0;
16259 rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime;
16260 #ifdef CONFIG_RT_GROUP_SCHED
16261 INIT_LIST_HEAD(&rq->leaf_rt_rq_list);
16262 diff -NurpP --minimal linux-2.6.27.25/kernel/sched_fair.c linux-2.6.27.25-vs2.3.0.36.6/kernel/sched_fair.c
16263 --- linux-2.6.27.25/kernel/sched_fair.c 2008-10-13 14:52:09.000000000 +0200
16264 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sched_fair.c 2008-10-13 14:54:20.000000000 +0200
16265 @@ -724,6 +724,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16266 check_spread(cfs_rq, se);
16267 if (se != cfs_rq->curr)
16268 __enqueue_entity(cfs_rq, se);
16270 + if (entity_is_task(se))
16271 + vx_activate_task(task_of(se));
16275 @@ -750,6 +753,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16277 if (se != cfs_rq->curr)
16278 __dequeue_entity(cfs_rq, se);
16279 + if (entity_is_task(se))
16280 + vx_deactivate_task(task_of(se));
16281 account_entity_dequeue(cfs_rq, se);
16284 diff -NurpP --minimal linux-2.6.27.25/kernel/sched_hard.h linux-2.6.27.25-vs2.3.0.36.6/kernel/sched_hard.h
16285 --- linux-2.6.27.25/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
16286 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sched_hard.h 2009-03-09 15:36:36.000000000 +0100
16289 +#ifdef CONFIG_VSERVER_IDLELIMIT
16292 + * vx_idle_resched - reschedule after maxidle
16295 +void vx_idle_resched(struct rq *rq)
16297 + /* maybe have a better criterion for paused */
16298 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
16299 + set_need_resched();
16302 +#else /* !CONFIG_VSERVER_IDLELIMIT */
16304 +#define vx_idle_resched(rq)
16306 +#endif /* CONFIG_VSERVER_IDLELIMIT */
16310 +#ifdef CONFIG_VSERVER_IDLETIME
16312 +#define vx_set_rq_min_skip(rq, min) \
16313 + (rq)->idle_skip = (min)
16315 +#define vx_save_min_skip(ret, min, val) \
16316 + __vx_save_min_skip(ret, min, val)
16319 +void __vx_save_min_skip(int ret, int *min, int val)
16323 + if ((*min > val) || !*min)
16328 +int vx_try_skip(struct rq *rq, int cpu)
16330 + /* artificially advance time */
16331 + if (rq->idle_skip > 0) {
16332 + vxdprintk(list_empty(&rq->hold_queue),
16333 + "hold queue empty on cpu %d", cpu);
16334 + rq->idle_time += rq->idle_skip;
16335 + vxm_idle_skip(rq, cpu);
16341 +#else /* !CONFIG_VSERVER_IDLETIME */
16343 +#define vx_set_rq_min_skip(rq, min) \
16344 + ({ int dummy = (min); dummy; })
16346 +#define vx_save_min_skip(ret, min, val)
16349 +int vx_try_skip(struct rq *rq, int cpu)
16354 +#endif /* CONFIG_VSERVER_IDLETIME */
16358 +#ifdef CONFIG_VSERVER_HARDCPU
16360 +#define vx_set_rq_max_idle(rq, max) \
16361 + (rq)->idle_tokens = (max)
16363 +#define vx_save_max_idle(ret, min, val) \
16364 + __vx_save_max_idle(ret, min, val)
16367 +void __vx_save_max_idle(int ret, int *min, int val)
16375 + * vx_hold_task - put a task on the hold queue
16378 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16380 + // printk("@ hold_task(%p[%lx])\n", p, p->state);
16382 + /* ignore dead/killed tasks */
16383 + if (unlikely(p->state & (TASK_DEAD | TASK_WAKEKILL)))
16386 + /* ignore sleeping tasks */
16387 + if (unlikely(p->state & TASK_NORMAL))
16390 + /* remove task from runqueue */
16391 + if (likely(p->se.on_rq))
16392 + dequeue_task(rq, p, 0);
16394 + printk("@ woops, task %p not on runqueue?\n", p);
16396 + p->state |= TASK_ONHOLD;
16397 + /* a new one on hold */
16399 + vxm_hold_task(p, rq);
16400 + list_add_tail(&p->hq, &rq->hold_queue);
16401 + // list_add_tail(&p->run_list, &rq->hold_queue);
16405 + * vx_unhold_task - put a task back to the runqueue
16408 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16410 + // printk("@ unhold_task(%p[%lx])\n", p, p->state);
16411 + list_del_init(&p->hq);
16412 + // list_del(&p->run_list);
16413 + /* one less waiting */
16415 + p->state &= ~TASK_ONHOLD;
16416 + enqueue_task(rq, p, 0);
16417 + // ? inc_nr_running(p, rq);
16418 + vxm_unhold_task(p, rq);
16422 + * vx_remove_hold - remove a task from the hold queue
16425 +void vx_remove_hold(struct task_struct *p, struct rq *rq)
16427 + printk("@ remove_hold(%p[%lx])\n", p, p->state);
16428 + list_del_init(&p->hq);
16429 + // list_del(&p->run_list);
16430 + /* one less waiting */
16432 + p->state &= ~TASK_ONHOLD;
16435 +unsigned long nr_onhold(void)
16437 + unsigned long i, sum = 0;
16439 + for_each_online_cpu(i)
16440 + sum += cpu_rq(i)->nr_onhold;
16448 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
16450 + return sched_pc->tokens;
16454 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16456 + sched_pc->tokens--;
16460 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16462 + struct vx_info *vxi = p->vx_info;
16464 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16465 + struct _vx_sched_pc *sched_pc =
16466 + &vx_per_cpu(vxi, sched_pc, cpu);
16469 + /* maybe we can simplify that to decrement
16470 + the token counter unconditional? */
16472 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
16473 + __vx_consume_token(sched_pc);
16475 + /* for tokens > 0, one token was consumed */
16479 + vxm_need_resched(p, slice, cpu);
16480 + return (slice == 0);
16484 +#define vx_set_rq_time(rq, time) do { \
16485 + rq->norm_time = time; \
16490 +void vx_try_unhold(struct rq *rq, int cpu)
16492 + struct vx_info *vxi = NULL;
16493 + struct list_head *l, *n;
16494 + int maxidle = HZ;
16497 + /* nothing to do? what about pause? */
16498 + if (list_empty(&rq->hold_queue))
16501 + list_for_each_safe(l, n, &rq->hold_queue) {
16502 + int ret, delta_min[2];
16503 + struct _vx_sched_pc *sched_pc;
16504 + struct task_struct *p;
16506 + p = list_entry(l, struct task_struct, hq);
16507 + /* don't bother with same context */
16508 + if (vxi == p->vx_info)
16511 + vxi = p->vx_info;
16512 + /* ignore paused contexts */
16513 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
16516 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16518 + /* recalc tokens */
16519 + vxm_sched_info(sched_pc, vxi, cpu);
16520 + ret = vx_tokens_recalc(sched_pc,
16521 + &rq->norm_time, &rq->idle_time, delta_min);
16522 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16525 + /* we found a runable context */
16526 + vx_unhold_task(p, rq);
16529 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
16530 + vx_save_min_skip(ret, &minskip, delta_min[1]);
16532 + vx_set_rq_max_idle(rq, maxidle);
16533 + vx_set_rq_min_skip(rq, minskip);
16534 + vxm_rq_max_min(rq, cpu);
16539 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16541 + struct vx_info *vxi = next->vx_info;
16542 + struct _vx_sched_pc *sched_pc;
16543 + int delta_min[2];
16549 + flags = vxi->vx_flags;
16551 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
16552 + goto put_on_hold;
16553 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
16556 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16558 + /* update scheduler params */
16559 + if (cpu_isset(cpu, vxi->sched.update)) {
16560 + vx_update_sched_param(&vxi->sched, sched_pc);
16561 + vxm_update_sched(sched_pc, vxi, cpu);
16562 + cpu_clear(cpu, vxi->sched.update);
16565 + vxm_sched_info(sched_pc, vxi, cpu);
16566 + ret = vx_tokens_recalc(sched_pc,
16567 + &rq->norm_time, &rq->idle_time, delta_min);
16568 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16570 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
16573 + if (unlikely(ret < 0)) {
16574 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
16575 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
16576 + vxm_rq_max_min(rq, cpu);
16578 + vx_hold_task(next, rq);
16585 +#else /* CONFIG_VSERVER_HARDCPU */
16588 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16594 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16599 +unsigned long nr_onhold(void)
16606 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16608 + return (slice == 0);
16612 +#define vx_set_rq_time(rq, time)
16615 +void vx_try_unhold(struct rq *rq, int cpu)
16621 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16623 + struct vx_info *vxi = next->vx_info;
16624 + struct _vx_sched_pc *sched_pc;
16625 + int delta_min[2];
16628 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
16631 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16632 + vxm_sched_info(sched_pc, vxi, cpu);
16633 + ret = vx_tokens_recalc(sched_pc,
16634 + &rq->norm_time, &rq->idle_time, delta_min);
16635 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16639 +#endif /* CONFIG_VSERVER_HARDCPU */
16641 diff -NurpP --minimal linux-2.6.27.25/kernel/sched_mon.h linux-2.6.27.25-vs2.3.0.36.6/kernel/sched_mon.h
16642 --- linux-2.6.27.25/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
16643 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sched_mon.h 2008-10-13 14:54:20.000000000 +0200
16646 +#include <linux/vserver/monitor.h>
16648 +#ifdef CONFIG_VSERVER_MONITOR
16650 +#ifdef CONFIG_VSERVER_HARDCPU
16651 +#define HARDCPU(x) (x)
16653 +#define HARDCPU(x) (0)
16656 +#ifdef CONFIG_VSERVER_IDLETIME
16657 +#define IDLETIME(x) (x)
16659 +#define IDLETIME(x) (0)
16662 +struct _vx_mon_entry *vxm_advance(int cpu);
16666 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
16668 + entry->type = type;
16669 + entry->xid = xid;
16673 +void __vxm_sync(int cpu)
16675 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16677 + __vxm_basic(entry, 0, VXM_SYNC);
16678 + entry->ev.sec = xtime.tv_sec;
16679 + entry->ev.nsec = xtime.tv_nsec;
16683 +void __vxm_task(struct task_struct *p, int type)
16685 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
16687 + __vxm_basic(entry, p->xid, type);
16688 + entry->ev.tsk.pid = p->pid;
16689 + entry->ev.tsk.state = p->state;
16693 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16695 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16697 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
16698 + entry->sd.tokens = s->tokens;
16699 + entry->sd.norm_time = s->norm_time;
16700 + entry->sd.idle_time = s->idle_time;
16704 +void __vxm_rqinfo1(struct rq *q, int cpu)
16706 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16708 + entry->type = VXM_RQINFO_1;
16709 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
16710 + entry->q1.running = q->nr_running;
16711 + entry->q1.onhold = HARDCPU(q->nr_onhold);
16712 + entry->q1.iowait = atomic_read(&q->nr_iowait);
16713 + entry->q1.uintr = q->nr_uninterruptible;
16714 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
16718 +void __vxm_rqinfo2(struct rq *q, int cpu)
16720 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16722 + entry->type = VXM_RQINFO_2;
16723 + entry->xid = (unsigned long)q & 0xffff;
16724 + entry->q2.norm_time = q->norm_time;
16725 + entry->q2.idle_time = q->idle_time;
16726 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
16730 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16732 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16734 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
16735 + entry->ev.tokens = s->tokens;
16739 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16741 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16743 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
16744 + entry->u1.tokens_max = s->tokens_max;
16745 + entry->u1.fill_rate = s->fill_rate[0];
16746 + entry->u1.interval = s->interval[0];
16750 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16752 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16754 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
16755 + entry->u2.tokens_min = s->tokens_min;
16756 + entry->u2.fill_rate = s->fill_rate[1];
16757 + entry->u2.interval = s->interval[1];
16761 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
16762 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
16763 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
16764 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
16765 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
16768 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
16770 + __vxm_task(p, VXM_MIGRATE);
16771 + __vxm_rqinfo1(rq, task_cpu(p));
16772 + __vxm_rqinfo2(rq, task_cpu(p));
16776 +void vxm_idle_skip(struct rq *rq, int cpu)
16778 + __vxm_rqinfo1(rq, cpu);
16779 + __vxm_rqinfo2(rq, cpu);
16783 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
16788 + __vxm_task(p, VXM_RESCHED);
16792 +void vxm_sync(unsigned long now, int cpu)
16794 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
16795 + (now % CONFIG_VSERVER_MONITOR_SYNC))
16801 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
16804 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
16805 + struct vx_info *vxi, int cpu)
16807 + __vxm_sched(s, vxi, cpu);
16808 + __vxm_rqinfo2(rq, cpu);
16812 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16814 + __vxm_sched(s, vxi, cpu);
16815 + __vxm_update(s, vxi, cpu);
16816 + __vxm_update1(s, vxi, cpu);
16817 + __vxm_update2(s, vxi, cpu);
16821 +void vxm_rq_max_min(struct rq *rq, int cpu)
16823 + __vxm_rqinfo1(rq, cpu);
16824 + __vxm_rqinfo2(rq, cpu);
16827 +#else /* CONFIG_VSERVER_MONITOR */
16829 +#define vxm_activate_task(t,q) do { } while (0)
16830 +#define vxm_activate_idle(t,q) do { } while (0)
16831 +#define vxm_deactivate_task(t,q) do { } while (0)
16832 +#define vxm_hold_task(t,q) do { } while (0)
16833 +#define vxm_unhold_task(t,q) do { } while (0)
16834 +#define vxm_migrate_task(t,q,d) do { } while (0)
16835 +#define vxm_idle_skip(q,c) do { } while (0)
16836 +#define vxm_need_resched(t,s,c) do { } while (0)
16837 +#define vxm_sync(s,c) do { } while (0)
16838 +#define vxm_sched_info(s,v,c) do { } while (0)
16839 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16840 +#define vxm_update_sched(s,v,c) do { } while (0)
16841 +#define vxm_rq_max_min(q,c) do { } while (0)
16843 +#endif /* CONFIG_VSERVER_MONITOR */
16845 diff -NurpP --minimal linux-2.6.27.25/kernel/signal.c linux-2.6.27.25-vs2.3.0.36.6/kernel/signal.c
16846 --- linux-2.6.27.25/kernel/signal.c 2009-06-15 17:18:33.000000000 +0200
16847 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/signal.c 2009-05-15 22:57:04.000000000 +0200
16849 #include <linux/freezer.h>
16850 #include <linux/pid_namespace.h>
16851 #include <linux/nsproxy.h>
16852 +#include <linux/vs_context.h>
16853 +#include <linux/vs_pid.h>
16855 #include <asm/param.h>
16856 #include <asm/uaccess.h>
16857 @@ -571,6 +573,14 @@ static int check_kill_permission(int sig
16858 if (!valid_signal(sig))
16861 + if ((info != SEND_SIG_NOINFO) &&
16862 + (is_si_special(info) || !SI_FROMUSER(info)))
16865 + vxdprintk(VXD_CBIT(misc, 7),
16866 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16867 + sig, info, t, vx_task_xid(t), t->pid);
16869 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
16872 @@ -595,6 +605,18 @@ static int check_kill_permission(int sig
16877 + if (t->pid == 1 && current->xid)
16881 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16882 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16883 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16884 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16888 return security_task_kill(t, info, sig, 0);
16891 @@ -1051,7 +1073,7 @@ int kill_pid_info(int sig, struct siginf
16894 p = pid_task(pid, PIDTYPE_PID);
16896 + if (p && vx_check(vx_task_xid(p), VS_ADMIN | VS_IDENT)) {
16897 error = group_send_sig_info(sig, info, p);
16898 if (unlikely(error == -ESRCH))
16900 @@ -1089,7 +1111,7 @@ int kill_pid_info_as_uid(int sig, struct
16902 read_lock(&tasklist_lock);
16903 p = pid_task(pid, PIDTYPE_PID);
16905 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16909 @@ -1141,8 +1163,10 @@ static int kill_something_info(int sig,
16910 struct task_struct * p;
16912 for_each_process(p) {
16913 - if (task_pid_vnr(p) > 1 &&
16914 - !same_thread_group(p, current)) {
16915 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16916 + task_pid_vnr(p) > 1 &&
16917 + !same_thread_group(p, current) &&
16918 + !vx_current_initpid(p->pid)) {
16919 int err = group_send_sig_info(sig, info, p);
16922 @@ -1823,6 +1847,11 @@ relock:
16923 !signal_group_exit(signal))
16926 + /* virtual init is protected against user signals */
16927 + if ((info->si_code == SI_USER) &&
16928 + vx_current_initpid(current->pid))
16931 if (sig_kernel_stop(signr)) {
16933 * The default action is to stop all threads in
16934 diff -NurpP --minimal linux-2.6.27.25/kernel/softirq.c linux-2.6.27.25-vs2.3.0.36.6/kernel/softirq.c
16935 --- linux-2.6.27.25/kernel/softirq.c 2008-10-13 14:52:09.000000000 +0200
16936 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/softirq.c 2008-10-13 14:54:20.000000000 +0200
16938 #include <linux/rcupdate.h>
16939 #include <linux/smp.h>
16940 #include <linux/tick.h>
16941 +#include <linux/vs_context.h>
16943 #include <asm/irq.h>
16945 diff -NurpP --minimal linux-2.6.27.25/kernel/sys.c linux-2.6.27.25-vs2.3.0.36.6/kernel/sys.c
16946 --- linux-2.6.27.25/kernel/sys.c 2009-06-15 17:18:33.000000000 +0200
16947 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sys.c 2009-02-03 17:59:04.000000000 +0100
16949 #include <linux/syscalls.h>
16950 #include <linux/kprobes.h>
16951 #include <linux/user_namespace.h>
16952 +#include <linux/vs_pid.h>
16954 #include <asm/uaccess.h>
16955 #include <asm/io.h>
16956 @@ -122,7 +123,10 @@ static int set_one_prio(struct task_stru
16959 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16961 + if (vx_flags(VXF_IGNEG_NICE, 0))
16967 no_nice = security_task_setnice(p, niceval);
16968 @@ -170,6 +174,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
16970 pgrp = task_pgrp(current);
16971 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16972 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16974 error = set_one_prio(p, niceval, error);
16975 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16977 @@ -230,6 +236,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
16979 pgrp = task_pgrp(current);
16980 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16981 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16983 niceval = 20 - task_nice(p);
16984 if (niceval > retval)
16986 @@ -339,6 +347,9 @@ void kernel_power_off(void)
16987 machine_power_off();
16989 EXPORT_SYMBOL_GPL(kernel_power_off);
16991 +long vs_reboot(unsigned int, void __user *);
16994 * Reboot system call: for obvious reasons only root may call it,
16995 * and even root needs to set up some magic numbers in the registers
16996 @@ -370,6 +381,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
16997 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16998 cmd = LINUX_REBOOT_CMD_HALT;
17000 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17001 + return vs_reboot(cmd, arg);
17005 case LINUX_REBOOT_CMD_RESTART:
17006 @@ -1345,7 +1359,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17008 char tmp[__NEW_UTS_LEN];
17010 - if (!capable(CAP_SYS_ADMIN))
17011 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17013 if (len < 0 || len > __NEW_UTS_LEN)
17015 @@ -1390,7 +1404,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17017 char tmp[__NEW_UTS_LEN];
17019 - if (!capable(CAP_SYS_ADMIN))
17020 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17022 if (len < 0 || len > __NEW_UTS_LEN)
17024 @@ -1458,7 +1472,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17026 old_rlim = current->signal->rlim + resource;
17027 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17028 - !capable(CAP_SYS_RESOURCE))
17029 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17031 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17033 diff -NurpP --minimal linux-2.6.27.25/kernel/sysctl.c linux-2.6.27.25-vs2.3.0.36.6/kernel/sysctl.c
17034 --- linux-2.6.27.25/kernel/sysctl.c 2009-06-15 17:18:33.000000000 +0200
17035 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sysctl.c 2009-02-03 17:59:04.000000000 +0100
17036 @@ -114,6 +114,7 @@ static int ngroups_max = NGROUPS_MAX;
17037 #ifdef CONFIG_MODULES
17038 extern char modprobe_path[];
17040 +extern char vshelper_path[];
17041 #ifdef CONFIG_CHR_DEV_SG
17042 extern int sg_big_buff;
17044 @@ -503,6 +504,15 @@ static struct ctl_table kern_table[] = {
17045 .strategy = &sysctl_string,
17049 + .ctl_name = KERN_VSHELPER,
17050 + .procname = "vshelper",
17051 + .data = &vshelper_path,
17054 + .proc_handler = &proc_dostring,
17055 + .strategy = &sysctl_string,
17057 #ifdef CONFIG_CHR_DEV_SG
17059 .ctl_name = KERN_SG_BIG_BUFF,
17060 diff -NurpP --minimal linux-2.6.27.25/kernel/sysctl_check.c linux-2.6.27.25-vs2.3.0.36.6/kernel/sysctl_check.c
17061 --- linux-2.6.27.25/kernel/sysctl_check.c 2008-10-13 14:52:09.000000000 +0200
17062 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/sysctl_check.c 2008-10-13 14:54:20.000000000 +0200
17063 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
17065 { KERN_PANIC, "panic" },
17066 { KERN_REALROOTDEV, "real-root-dev" },
17067 + { KERN_VSHELPER, "vshelper", },
17069 { KERN_SPARC_REBOOT, "reboot-cmd" },
17070 { KERN_CTLALTDEL, "ctrl-alt-del" },
17071 @@ -1217,6 +1218,22 @@ static const struct trans_ctl_table tran
17075 +static struct trans_ctl_table trans_vserver_table[] = {
17076 + { 1, "debug_switch" },
17077 + { 2, "debug_xid" },
17078 + { 3, "debug_nid" },
17079 + { 4, "debug_tag" },
17080 + { 5, "debug_net" },
17081 + { 6, "debug_limit" },
17082 + { 7, "debug_cres" },
17083 + { 8, "debug_dlim" },
17084 + { 9, "debug_quota" },
17085 + { 10, "debug_cvirt" },
17086 + { 11, "debug_space" },
17087 + { 12, "debug_misc" },
17091 static const struct trans_ctl_table trans_root_table[] = {
17092 { CTL_KERN, "kernel", trans_kern_table },
17093 { CTL_VM, "vm", trans_vm_table },
17094 @@ -1233,6 +1250,7 @@ static const struct trans_ctl_table tran
17095 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
17096 { CTL_PM, "pm", trans_pm_table },
17097 { CTL_FRV, "frv", trans_frv_table },
17098 + { CTL_VSERVER, "vserver", trans_vserver_table },
17102 diff -NurpP --minimal linux-2.6.27.25/kernel/time.c linux-2.6.27.25-vs2.3.0.36.6/kernel/time.c
17103 --- linux-2.6.27.25/kernel/time.c 2009-06-15 17:18:33.000000000 +0200
17104 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/time.c 2009-02-03 17:59:04.000000000 +0100
17105 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
17106 SYSCALL_DEFINE1(time, time_t __user *, tloc)
17108 time_t i = get_seconds();
17109 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17112 if (put_user(i,tloc))
17113 @@ -91,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17117 - do_settimeofday(&tv);
17118 + vx_settimeofday(&tv);
17122 @@ -102,7 +103,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17124 if (likely(tv != NULL)) {
17125 struct timeval ktv;
17126 - do_gettimeofday(&ktv);
17127 + vx_gettimeofday(&ktv);
17128 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17131 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec
17132 /* SMP safe, again the code in arch/foo/time.c should
17133 * globally block out interrupts when it runs.
17135 - return do_settimeofday(tv);
17136 + return vx_settimeofday(tv);
17140 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
17144 - do_gettimeofday(&x);
17145 + vx_gettimeofday(&x);
17146 tv->tv_sec = x.tv_sec;
17147 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17149 diff -NurpP --minimal linux-2.6.27.25/kernel/timer.c linux-2.6.27.25-vs2.3.0.36.6/kernel/timer.c
17150 --- linux-2.6.27.25/kernel/timer.c 2009-06-15 17:18:33.000000000 +0200
17151 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/timer.c 2009-03-09 15:36:36.000000000 +0100
17153 #include <linux/delay.h>
17154 #include <linux/tick.h>
17155 #include <linux/kallsyms.h>
17156 +#include <linux/vs_base.h>
17157 +#include <linux/vs_cvirt.h>
17158 +#include <linux/vs_pid.h>
17159 +#include <linux/vserver/sched.h>
17161 #include <asm/uaccess.h>
17162 #include <asm/unistd.h>
17163 @@ -964,6 +968,25 @@ void account_process_tick(struct task_st
17168 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
17170 + sched_pc->tokens--;
17174 +void vx_hard_tick(struct task_struct *p, int cpu)
17176 + struct vx_info *vxi = p->vx_info;
17178 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
17179 + struct _vx_sched_pc *sched_pc =
17180 + &vx_per_cpu(vxi, sched_pc, cpu);
17182 + __vx_consume_token(sched_pc);
17187 * Called from the timer interrupt handler to charge one tick to the current
17188 * process. user_tick is 1 if the tick is user time, 0 for system.
17189 @@ -979,6 +1002,7 @@ void update_process_times(int user_tick)
17190 if (rcu_pending(cpu))
17191 rcu_check_callbacks(cpu, user_tick);
17193 + vx_hard_tick(p, cpu);
17194 run_posix_cpu_timers(p);
17197 @@ -1081,12 +1105,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17204 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17205 - * should be moved into arch/i386 instead?
17209 * sys_getpid - return the thread group id of the current process
17210 @@ -1115,10 +1133,23 @@ SYSCALL_DEFINE0(getppid)
17212 pid = task_tgid_vnr(current->real_parent);
17214 + return vx_map_pid(pid);
17221 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17224 +asmlinkage long do_getxpid(long *ppid)
17226 + *ppid = sys_getppid();
17227 + return sys_getpid();
17230 +#else /* _alpha_ */
17232 SYSCALL_DEFINE0(getuid)
17234 /* Only we change this so SMP safe */
17235 @@ -1289,6 +1320,8 @@ int do_sysinfo(struct sysinfo *info)
17236 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
17239 + if (vx_flags(VXF_VIRT_UPTIME, 0))
17240 + vx_vsi_uptime(&tp, NULL);
17241 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
17243 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
17244 diff -NurpP --minimal linux-2.6.27.25/kernel/user.c linux-2.6.27.25-vs2.3.0.36.6/kernel/user.c
17245 --- linux-2.6.27.25/kernel/user.c 2008-07-13 23:51:29.000000000 +0200
17246 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/user.c 2008-10-13 14:54:20.000000000 +0200
17247 @@ -243,12 +243,15 @@ static struct kobj_type uids_ktype = {
17250 /* create /sys/kernel/uids/<uid>/cpu_share file for this user */
17251 -static int uids_user_create(struct user_struct *up)
17252 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17254 struct kobject *kobj = &up->kobj;
17258 memset(kobj, 0, sizeof(struct kobject));
17259 + if (ns != &init_user_ns)
17262 kobj->kset = uids_kset;
17263 error = kobject_init_and_add(kobj, &uids_ktype, NULL, "%d", up->uid);
17265 @@ -272,7 +275,7 @@ int __init uids_sysfs_init(void)
17269 - return uids_user_create(&root_user);
17270 + return uids_user_create(NULL, &root_user);
17273 /* work function to remove sysfs directory for a user and free up
17274 @@ -302,9 +305,11 @@ static void remove_user_sysfs_dir(struct
17278 - kobject_uevent(&up->kobj, KOBJ_REMOVE);
17279 - kobject_del(&up->kobj);
17280 - kobject_put(&up->kobj);
17281 + if (up->kobj.name) {
17282 + kobject_uevent(&up->kobj, KOBJ_REMOVE);
17283 + kobject_del(&up->kobj);
17284 + kobject_put(&up->kobj);
17287 sched_destroy_user(up);
17288 key_put(up->uid_keyring);
17289 @@ -332,7 +337,8 @@ static inline void free_user(struct user
17290 #else /* CONFIG_USER_SCHED && CONFIG_SYSFS */
17292 int uids_sysfs_init(void) { return 0; }
17293 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17294 +static inline int uids_user_create(struct user_namespace *ns,
17295 + struct user_struct *up) { return 0; }
17296 static inline void uids_mutex_lock(void) { }
17297 static inline void uids_mutex_unlock(void) { }
17299 @@ -409,7 +415,7 @@ struct user_struct *alloc_uid(struct use
17300 if (sched_create_user(new) < 0)
17301 goto out_free_user;
17303 - if (uids_user_create(new))
17304 + if (uids_user_create(ns, new))
17305 goto out_destoy_sched;
17308 diff -NurpP --minimal linux-2.6.27.25/kernel/user_namespace.c linux-2.6.27.25-vs2.3.0.36.6/kernel/user_namespace.c
17309 --- linux-2.6.27.25/kernel/user_namespace.c 2008-10-13 14:52:09.000000000 +0200
17310 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/user_namespace.c 2008-10-13 14:54:20.000000000 +0200
17312 #include <linux/nsproxy.h>
17313 #include <linux/slab.h>
17314 #include <linux/user_namespace.h>
17315 +#include <linux/vserver/global.h>
17318 * Clone a new ns copying an original user ns, setting refcount to 1
17319 @@ -26,6 +27,7 @@ static struct user_namespace *clone_user
17320 return ERR_PTR(-ENOMEM);
17322 kref_init(&ns->kref);
17323 + atomic_inc(&vs_global_user_ns);
17325 for (n = 0; n < UIDHASH_SZ; ++n)
17326 INIT_HLIST_HEAD(ns->uidhash_table + n);
17327 @@ -71,6 +73,7 @@ void free_user_ns(struct kref *kref)
17329 ns = container_of(kref, struct user_namespace, kref);
17331 + atomic_dec(&vs_global_user_ns);
17334 EXPORT_SYMBOL(free_user_ns);
17335 diff -NurpP --minimal linux-2.6.27.25/kernel/utsname.c linux-2.6.27.25-vs2.3.0.36.6/kernel/utsname.c
17336 --- linux-2.6.27.25/kernel/utsname.c 2008-10-13 14:52:09.000000000 +0200
17337 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/utsname.c 2008-10-13 14:54:20.000000000 +0200
17339 #include <linux/utsname.h>
17340 #include <linux/err.h>
17341 #include <linux/slab.h>
17342 +#include <linux/vserver/global.h>
17345 * Clone a new ns copying an original utsname, setting refcount to 1
17346 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
17347 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17349 kref_init(&ns->kref);
17350 + atomic_inc(&vs_global_uts_ns);
17354 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
17355 struct uts_namespace *ns;
17357 ns = container_of(kref, struct uts_namespace, kref);
17358 + atomic_dec(&vs_global_uts_ns);
17361 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/cacct.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cacct.c
17362 --- linux-2.6.27.25/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17363 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cacct.c 2008-10-13 14:54:20.000000000 +0200
17366 + * linux/kernel/vserver/cacct.c
17368 + * Virtual Server: Context Accounting
17370 + * Copyright (C) 2006-2007 Herbert Pötzl
17372 + * V0.01 added accounting stats
17376 +#include <linux/types.h>
17377 +#include <linux/vs_context.h>
17378 +#include <linux/vserver/cacct_cmd.h>
17379 +#include <linux/vserver/cacct_int.h>
17381 +#include <asm/errno.h>
17382 +#include <asm/uaccess.h>
17385 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17387 + struct vcmd_sock_stat_v0 vc_data;
17390 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17393 + field = vc_data.field;
17394 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17397 + for (j = 0; j < 3; j++) {
17398 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17399 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17402 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17407 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/cacct_init.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cacct_init.h
17408 --- linux-2.6.27.25/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17409 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cacct_init.h 2008-10-13 14:54:20.000000000 +0200
17413 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17418 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17419 + for (j = 0; j < 3; j++) {
17420 + atomic_set(&cacct->sock[i][j].count, 0);
17421 + atomic_set(&cacct->sock[i][j].total, 0);
17424 + for (i = 0; i < 8; i++)
17425 + atomic_set(&cacct->slab[i], 0);
17426 + for (i = 0; i < 5; i++)
17427 + for (j = 0; j < 4; j++)
17428 + atomic_set(&cacct->page[i][j], 0);
17431 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17436 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/cacct_proc.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cacct_proc.h
17437 --- linux-2.6.27.25/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17438 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cacct_proc.h 2008-10-13 14:54:20.000000000 +0200
17440 +#ifndef _VX_CACCT_PROC_H
17441 +#define _VX_CACCT_PROC_H
17443 +#include <linux/vserver/cacct_int.h>
17446 +#define VX_SOCKA_TOP \
17447 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17449 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17451 + int i, j, length = 0;
17452 + static char *type[VXA_SOCK_SIZE] = {
17453 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17456 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17457 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17458 + length += sprintf(buffer + length, "%s:", type[i]);
17459 + for (j = 0; j < 3; j++) {
17460 + length += sprintf(buffer + length,
17461 + "\t%10lu/%-10lu",
17462 + vx_sock_count(cacct, i, j),
17463 + vx_sock_total(cacct, i, j));
17465 + buffer[length++] = '\n';
17468 + length += sprintf(buffer + length, "\n");
17469 + length += sprintf(buffer + length,
17470 + "slab:\t %8u %8u %8u %8u\n",
17471 + atomic_read(&cacct->slab[1]),
17472 + atomic_read(&cacct->slab[4]),
17473 + atomic_read(&cacct->slab[0]),
17474 + atomic_read(&cacct->slab[2]));
17476 + length += sprintf(buffer + length, "\n");
17477 + for (i = 0; i < 5; i++) {
17478 + length += sprintf(buffer + length,
17479 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17480 + atomic_read(&cacct->page[i][0]),
17481 + atomic_read(&cacct->page[i][1]),
17482 + atomic_read(&cacct->page[i][2]),
17483 + atomic_read(&cacct->page[i][3]),
17484 + atomic_read(&cacct->page[i][4]),
17485 + atomic_read(&cacct->page[i][5]),
17486 + atomic_read(&cacct->page[i][6]),
17487 + atomic_read(&cacct->page[i][7]));
17492 +#endif /* _VX_CACCT_PROC_H */
17493 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/context.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/context.c
17494 --- linux-2.6.27.25/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17495 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/context.c 2008-10-31 03:56:55.000000000 +0100
17498 + * linux/kernel/vserver/context.c
17500 + * Virtual Server: Context Support
17502 + * Copyright (C) 2003-2007 Herbert Pötzl
17504 + * V0.01 context helper
17505 + * V0.02 vx_ctx_kill syscall command
17506 + * V0.03 replaced context_info calls
17507 + * V0.04 redesign of struct (de)alloc
17508 + * V0.05 rlimit basic implementation
17509 + * V0.06 task_xid and info commands
17510 + * V0.07 context flags and caps
17511 + * V0.08 switch to RCU based hash
17512 + * V0.09 revert to non RCU for now
17513 + * V0.10 and back to working RCU hash
17514 + * V0.11 and back to locking again
17515 + * V0.12 referenced context store
17516 + * V0.13 separate per cpu data
17517 + * V0.14 changed vcmds to vxi arg
17518 + * V0.15 added context stat
17519 + * V0.16 have __create claim() the vxi
17520 + * V0.17 removed older and legacy stuff
17524 +#include <linux/slab.h>
17525 +#include <linux/types.h>
17526 +#include <linux/security.h>
17527 +#include <linux/pid_namespace.h>
17529 +#include <linux/vserver/context.h>
17530 +#include <linux/vserver/network.h>
17531 +#include <linux/vserver/debug.h>
17532 +#include <linux/vserver/limit.h>
17533 +#include <linux/vserver/limit_int.h>
17534 +#include <linux/vserver/space.h>
17536 +#include <linux/vs_context.h>
17537 +#include <linux/vs_limit.h>
17538 +#include <linux/vs_pid.h>
17539 +#include <linux/vserver/context_cmd.h>
17541 +#include "cvirt_init.h"
17542 +#include "cacct_init.h"
17543 +#include "limit_init.h"
17544 +#include "sched_init.h"
17547 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17548 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17551 +/* now inactive context structures */
17553 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17555 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17558 +/* __alloc_vx_info()
17560 + * allocate an initialized vx_info struct
17561 + * doesn't make it visible (hash) */
17563 +static struct vx_info *__alloc_vx_info(xid_t xid)
17565 + struct vx_info *new = NULL;
17568 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17570 + /* would this benefit from a slab cache? */
17571 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17575 + memset(new, 0, sizeof(struct vx_info));
17577 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17578 + if (!new->ptr_pc)
17581 + new->vx_id = xid;
17582 + INIT_HLIST_NODE(&new->vx_hlist);
17583 + atomic_set(&new->vx_usecnt, 0);
17584 + atomic_set(&new->vx_tasks, 0);
17585 + new->vx_parent = NULL;
17586 + new->vx_state = 0;
17587 + init_waitqueue_head(&new->vx_wait);
17589 + /* prepare reaper */
17590 + get_task_struct(init_pid_ns.child_reaper);
17591 + new->vx_reaper = init_pid_ns.child_reaper;
17592 + new->vx_badness_bias = 0;
17594 + /* rest of init goes here */
17595 + vx_info_init_limit(&new->limit);
17596 + vx_info_init_sched(&new->sched);
17597 + vx_info_init_cvirt(&new->cvirt);
17598 + vx_info_init_cacct(&new->cacct);
17600 + /* per cpu data structures */
17601 + for_each_possible_cpu(cpu) {
17602 + vx_info_init_sched_pc(
17603 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17604 + vx_info_init_cvirt_pc(
17605 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17608 + new->vx_flags = VXF_INIT_SET;
17609 + cap_set_init_eff(new->vx_bcaps);
17610 + new->vx_ccaps = 0;
17611 + // new->vx_cap_bset = current->cap_bset;
17613 + new->reboot_cmd = 0;
17614 + new->exit_code = 0;
17616 + vxdprintk(VXD_CBIT(xid, 0),
17617 + "alloc_vx_info(%d) = %p", xid, new);
17618 + vxh_alloc_vx_info(new);
17619 + atomic_inc(&vx_global_ctotal);
17628 +/* __dealloc_vx_info()
17630 + * final disposal of vx_info */
17632 +static void __dealloc_vx_info(struct vx_info *vxi)
17634 + struct vx_info_save vxis;
17637 + vxdprintk(VXD_CBIT(xid, 0),
17638 + "dealloc_vx_info(%p)", vxi);
17639 + vxh_dealloc_vx_info(vxi);
17641 +#ifdef CONFIG_VSERVER_WARN
17642 + enter_vx_info(vxi, &vxis);
17643 + vx_info_exit_limit(&vxi->limit);
17644 + vx_info_exit_sched(&vxi->sched);
17645 + vx_info_exit_cvirt(&vxi->cvirt);
17646 + vx_info_exit_cacct(&vxi->cacct);
17648 + for_each_possible_cpu(cpu) {
17649 + vx_info_exit_sched_pc(
17650 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17651 + vx_info_exit_cvirt_pc(
17652 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17654 + leave_vx_info(&vxis);
17658 + vxi->vx_state |= VXS_RELEASED;
17661 + free_percpu(vxi->ptr_pc);
17664 + atomic_dec(&vx_global_ctotal);
17667 +static void __shutdown_vx_info(struct vx_info *vxi)
17669 + struct nsproxy *nsproxy;
17670 + struct fs_struct *fs;
17675 + vxi->vx_state |= VXS_SHUTDOWN;
17676 + vs_state_change(vxi, VSC_SHUTDOWN);
17678 + for (index = 0; index < VX_SPACES; index++) {
17679 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17681 + put_nsproxy(nsproxy);
17683 + fs = xchg(&vxi->vx_fs[index], NULL);
17685 + put_fs_struct(fs);
17689 +/* exported stuff */
17691 +void free_vx_info(struct vx_info *vxi)
17693 + unsigned long flags;
17696 + /* check for reference counts first */
17697 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17698 + BUG_ON(atomic_read(&vxi->vx_tasks));
17700 + /* context must not be hashed */
17701 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17703 + /* context shutdown is mandatory */
17704 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17706 + /* nsproxy and fs check */
17707 + for (index = 0; index < VX_SPACES; index++) {
17708 + BUG_ON(vxi->vx_nsproxy[index]);
17709 + BUG_ON(vxi->vx_fs[index]);
17712 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17713 + hlist_del(&vxi->vx_hlist);
17714 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17716 + __dealloc_vx_info(vxi);
17720 +/* hash table for vx_info hash */
17722 +#define VX_HASH_SIZE 13
17724 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17725 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17727 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17730 +static inline unsigned int __hashval(xid_t xid)
17732 + return (xid % VX_HASH_SIZE);
17737 +/* __hash_vx_info()
17739 + * add the vxi to the global hash table
17740 + * requires the hash_lock to be held */
17742 +static inline void __hash_vx_info(struct vx_info *vxi)
17744 + struct hlist_head *head;
17746 + vxd_assert_lock(&vx_info_hash_lock);
17747 + vxdprintk(VXD_CBIT(xid, 4),
17748 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17749 + vxh_hash_vx_info(vxi);
17751 + /* context must not be hashed */
17752 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17754 + vxi->vx_state |= VXS_HASHED;
17755 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17756 + hlist_add_head(&vxi->vx_hlist, head);
17757 + atomic_inc(&vx_global_cactive);
17760 +/* __unhash_vx_info()
17762 + * remove the vxi from the global hash table
17763 + * requires the hash_lock to be held */
17765 +static inline void __unhash_vx_info(struct vx_info *vxi)
17767 + unsigned long flags;
17769 + vxd_assert_lock(&vx_info_hash_lock);
17770 + vxdprintk(VXD_CBIT(xid, 4),
17771 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17772 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17773 + vxh_unhash_vx_info(vxi);
17775 + /* context must be hashed */
17776 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17777 + /* but without tasks */
17778 + BUG_ON(atomic_read(&vxi->vx_tasks));
17780 + vxi->vx_state &= ~VXS_HASHED;
17781 + hlist_del_init(&vxi->vx_hlist);
17782 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17783 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17784 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17785 + atomic_dec(&vx_global_cactive);
17789 +/* __lookup_vx_info()
17791 + * requires the hash_lock to be held
17792 + * doesn't increment the vx_refcnt */
17794 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17796 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17797 + struct hlist_node *pos;
17798 + struct vx_info *vxi;
17800 + vxd_assert_lock(&vx_info_hash_lock);
17801 + hlist_for_each(pos, head) {
17802 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17804 + if (vxi->vx_id == xid)
17809 + vxdprintk(VXD_CBIT(xid, 0),
17810 + "__lookup_vx_info(#%u): %p[#%u]",
17811 + xid, vxi, vxi ? vxi->vx_id : 0);
17812 + vxh_lookup_vx_info(vxi, xid);
17817 +/* __create_vx_info()
17819 + * create the requested context
17820 + * get(), claim() and hash it */
17822 +static struct vx_info *__create_vx_info(int id)
17824 + struct vx_info *new, *vxi = NULL;
17826 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17828 + if (!(new = __alloc_vx_info(id)))
17829 + return ERR_PTR(-ENOMEM);
17831 + /* required to make dynamic xids unique */
17832 + spin_lock(&vx_info_hash_lock);
17834 + /* static context requested */
17835 + if ((vxi = __lookup_vx_info(id))) {
17836 + vxdprintk(VXD_CBIT(xid, 0),
17837 + "create_vx_info(%d) = %p (already there)", id, vxi);
17838 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17839 + vxi = ERR_PTR(-EBUSY);
17841 + vxi = ERR_PTR(-EEXIST);
17844 + /* new context */
17845 + vxdprintk(VXD_CBIT(xid, 0),
17846 + "create_vx_info(%d) = %p (new)", id, new);
17847 + claim_vx_info(new, NULL);
17848 + __hash_vx_info(get_vx_info(new));
17849 + vxi = new, new = NULL;
17852 + spin_unlock(&vx_info_hash_lock);
17853 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17855 + __dealloc_vx_info(new);
17860 +/* exported stuff */
17863 +void unhash_vx_info(struct vx_info *vxi)
17865 + __shutdown_vx_info(vxi);
17866 + spin_lock(&vx_info_hash_lock);
17867 + __unhash_vx_info(vxi);
17868 + spin_unlock(&vx_info_hash_lock);
17869 + __wakeup_vx_info(vxi);
17873 +/* lookup_vx_info()
17875 + * search for a vx_info and get() it
17876 + * negative id means current */
17878 +struct vx_info *lookup_vx_info(int id)
17880 + struct vx_info *vxi = NULL;
17883 + vxi = get_vx_info(current->vx_info);
17884 + } else if (id > 1) {
17885 + spin_lock(&vx_info_hash_lock);
17886 + vxi = get_vx_info(__lookup_vx_info(id));
17887 + spin_unlock(&vx_info_hash_lock);
17892 +/* xid_is_hashed()
17894 + * verify that xid is still hashed */
17896 +int xid_is_hashed(xid_t xid)
17900 + spin_lock(&vx_info_hash_lock);
17901 + hashed = (__lookup_vx_info(xid) != NULL);
17902 + spin_unlock(&vx_info_hash_lock);
17906 +#ifdef CONFIG_PROC_FS
17910 + * get a subset of hashed xids for proc
17911 + * assumes size is at least one */
17913 +int get_xid_list(int index, unsigned int *xids, int size)
17915 + int hindex, nr_xids = 0;
17917 + /* only show current and children */
17918 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
17921 + xids[nr_xids] = vx_current_xid();
17925 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
17926 + struct hlist_head *head = &vx_info_hash[hindex];
17927 + struct hlist_node *pos;
17929 + spin_lock(&vx_info_hash_lock);
17930 + hlist_for_each(pos, head) {
17931 + struct vx_info *vxi;
17936 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17937 + xids[nr_xids] = vxi->vx_id;
17938 + if (++nr_xids >= size) {
17939 + spin_unlock(&vx_info_hash_lock);
17943 + /* keep the lock time short */
17944 + spin_unlock(&vx_info_hash_lock);
17951 +#ifdef CONFIG_VSERVER_DEBUG
17953 +void dump_vx_info_inactive(int level)
17955 + struct hlist_node *entry, *next;
17957 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
17958 + struct vx_info *vxi =
17959 + list_entry(entry, struct vx_info, vx_hlist);
17961 + dump_vx_info(vxi, level);
17968 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
17970 + struct user_struct *new_user, *old_user;
17975 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
17978 + new_user = alloc_uid(vxi->vx_id, p->uid);
17982 + old_user = p->user;
17983 + if (new_user != old_user) {
17984 + atomic_inc(&new_user->processes);
17985 + atomic_dec(&old_user->processes);
17986 + p->user = new_user;
17988 + free_uid(old_user);
17994 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
17996 + // p->cap_effective &= vxi->vx_cap_bset;
17997 + p->cap_effective =
17998 + cap_intersect(p->cap_effective, vxi->cap_bset);
17999 + // p->cap_inheritable &= vxi->vx_cap_bset;
18000 + p->cap_inheritable =
18001 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18002 + // p->cap_permitted &= vxi->vx_cap_bset;
18003 + p->cap_permitted =
18004 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18009 +#include <linux/file.h>
18010 +#include <linux/fdtable.h>
18012 +static int vx_openfd_task(struct task_struct *tsk)
18014 + struct files_struct *files = tsk->files;
18015 + struct fdtable *fdt;
18016 + const unsigned long *bptr;
18017 + int count, total;
18019 + /* no rcu_read_lock() because of spin_lock() */
18020 + spin_lock(&files->file_lock);
18021 + fdt = files_fdtable(files);
18022 + bptr = fdt->open_fds->fds_bits;
18023 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18024 + for (total = 0; count > 0; count--) {
18026 + total += hweight_long(*bptr);
18029 + spin_unlock(&files->file_lock);
18034 +/* for *space compatibility */
18036 +asmlinkage long sys_unshare(unsigned long);
18039 + * migrate task to new context
18040 + * gets vxi, puts old_vxi on change
18041 + * optionally unshares namespaces (hack)
18044 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18046 + struct vx_info *old_vxi;
18052 + vxdprintk(VXD_CBIT(xid, 5),
18053 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18054 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18056 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18057 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18060 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18063 + old_vxi = task_get_vx_info(p);
18064 + if (old_vxi == vxi)
18067 +// if (!(ret = vx_migrate_user(p, vxi))) {
18072 + openfd = vx_openfd_task(p);
18075 + atomic_dec(&old_vxi->cvirt.nr_threads);
18076 + atomic_dec(&old_vxi->cvirt.nr_running);
18077 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18078 + /* FIXME: what about the struct files here? */
18079 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18080 + /* account for the executable */
18081 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18083 + atomic_inc(&vxi->cvirt.nr_threads);
18084 + atomic_inc(&vxi->cvirt.nr_running);
18085 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18086 + /* FIXME: what about the struct files here? */
18087 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18088 + /* account for the executable */
18089 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18092 + release_vx_info(old_vxi, p);
18093 + clr_vx_info(&p->vx_info);
18095 + claim_vx_info(vxi, p);
18096 + set_vx_info(&p->vx_info, vxi);
18097 + p->xid = vxi->vx_id;
18099 + vxdprintk(VXD_CBIT(xid, 5),
18100 + "moved task %p into vxi:%p[#%d]",
18101 + p, vxi, vxi->vx_id);
18103 + // vx_mask_cap_bset(vxi, p);
18106 + /* hack for *spaces to provide compatibility */
18108 + struct nsproxy *old_nsp, *new_nsp;
18110 + ret = unshare_nsproxy_namespaces(
18111 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18116 + old_nsp = xchg(&p->nsproxy, new_nsp);
18117 + vx_set_space(vxi,
18118 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18119 + put_nsproxy(old_nsp);
18123 + put_vx_info(old_vxi);
18127 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18129 + struct task_struct *old_reaper;
18134 + vxdprintk(VXD_CBIT(xid, 6),
18135 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18136 + vxi, vxi->vx_id, p, p->xid, p->pid);
18138 + old_reaper = vxi->vx_reaper;
18139 + if (old_reaper == p)
18142 + /* set new child reaper */
18143 + get_task_struct(p);
18144 + vxi->vx_reaper = p;
18145 + put_task_struct(old_reaper);
18149 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18154 + vxdprintk(VXD_CBIT(xid, 6),
18155 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18156 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18158 + vxi->vx_flags &= ~VXF_STATE_INIT;
18159 + vxi->vx_initpid = p->tgid;
18163 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18165 + vxdprintk(VXD_CBIT(xid, 6),
18166 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18167 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18169 + vxi->exit_code = code;
18170 + vxi->vx_initpid = 0;
18174 +void vx_set_persistent(struct vx_info *vxi)
18176 + vxdprintk(VXD_CBIT(xid, 6),
18177 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18179 + get_vx_info(vxi);
18180 + claim_vx_info(vxi, NULL);
18183 +void vx_clear_persistent(struct vx_info *vxi)
18185 + vxdprintk(VXD_CBIT(xid, 6),
18186 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18188 + release_vx_info(vxi, NULL);
18189 + put_vx_info(vxi);
18192 +void vx_update_persistent(struct vx_info *vxi)
18194 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18195 + vx_set_persistent(vxi);
18197 + vx_clear_persistent(vxi);
18201 +/* task must be current or locked */
18203 +void exit_vx_info(struct task_struct *p, int code)
18205 + struct vx_info *vxi = p->vx_info;
18208 + atomic_dec(&vxi->cvirt.nr_threads);
18211 + vxi->exit_code = code;
18212 + release_vx_info(vxi, p);
18216 +void exit_vx_info_early(struct task_struct *p, int code)
18218 + struct vx_info *vxi = p->vx_info;
18221 + if (vxi->vx_initpid == p->tgid)
18222 + vx_exit_init(vxi, p, code);
18223 + if (vxi->vx_reaper == p)
18224 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18229 +/* vserver syscall commands below here */
18231 +/* taks xid and vx_info functions */
18233 +#include <asm/uaccess.h>
18236 +int vc_task_xid(uint32_t id)
18241 + struct task_struct *tsk;
18243 + read_lock(&tasklist_lock);
18244 + tsk = find_task_by_real_pid(id);
18245 + xid = (tsk) ? tsk->xid : -ESRCH;
18246 + read_unlock(&tasklist_lock);
18248 + xid = vx_current_xid();
18253 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18255 + struct vcmd_vx_info_v0 vc_data;
18257 + vc_data.xid = vxi->vx_id;
18258 + vc_data.initpid = vxi->vx_initpid;
18260 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18266 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18268 + struct vcmd_ctx_stat_v0 vc_data;
18270 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18271 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18273 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18279 +/* context functions */
18281 +int vc_ctx_create(uint32_t xid, void __user *data)
18283 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18284 + struct vx_info *new_vxi;
18287 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18290 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18293 + new_vxi = __create_vx_info(xid);
18294 + if (IS_ERR(new_vxi))
18295 + return PTR_ERR(new_vxi);
18297 + /* initial flags */
18298 + new_vxi->vx_flags = vc_data.flagword;
18301 + if (vs_state_change(new_vxi, VSC_STARTUP))
18304 + ret = vx_migrate_task(current, new_vxi, (!data));
18308 + /* return context id on success */
18309 + ret = new_vxi->vx_id;
18311 + /* get a reference for persistent contexts */
18312 + if ((vc_data.flagword & VXF_PERSISTENT))
18313 + vx_set_persistent(new_vxi);
18315 + release_vx_info(new_vxi, NULL);
18316 + put_vx_info(new_vxi);
18321 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18323 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18326 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18329 + ret = vx_migrate_task(current, vxi, 0);
18332 + if (vc_data.flagword & VXM_SET_INIT)
18333 + ret = vx_set_init(vxi, current);
18336 + if (vc_data.flagword & VXM_SET_REAPER)
18337 + ret = vx_set_reaper(vxi, current);
18342 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18344 + struct vcmd_ctx_flags_v0 vc_data;
18346 + vc_data.flagword = vxi->vx_flags;
18348 + /* special STATE flag handling */
18349 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18351 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18356 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18358 + struct vcmd_ctx_flags_v0 vc_data;
18359 + uint64_t mask, trigger;
18361 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18364 + /* special STATE flag handling */
18365 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18366 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18368 + if (vxi == current->vx_info) {
18369 + /* if (trigger & VXF_STATE_SETUP)
18370 + vx_mask_cap_bset(vxi, current); */
18371 + if (trigger & VXF_STATE_INIT) {
18374 + ret = vx_set_init(vxi, current);
18377 + ret = vx_set_reaper(vxi, current);
18383 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18384 + vc_data.flagword, mask);
18385 + if (trigger & VXF_PERSISTENT)
18386 + vx_update_persistent(vxi);
18392 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18394 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18396 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18400 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18402 + kernel_cap_t c = __cap_empty_set;
18404 + c.cap[0] = v & 0xFFFFFFFF;
18405 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18407 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18412 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18415 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18417 + *ccaps = vxi->vx_ccaps;
18422 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18424 + struct vcmd_ctx_caps_v1 vc_data;
18427 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18430 + vc_data.cmask = ~0ULL;
18432 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18437 +static int do_set_caps(struct vx_info *vxi,
18438 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18440 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18443 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18444 + bcaps, bmask, ccaps, cmask);
18446 + vxi->vx_bcaps = cap_t_from_caps(
18447 + vs_mask_flags(bcold, bcaps, bmask));
18448 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18453 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18455 + struct vcmd_ctx_caps_v1 vc_data;
18457 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18460 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18463 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18465 + struct vcmd_bcaps vc_data;
18468 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18471 + vc_data.bmask = ~0ULL;
18473 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18478 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18480 + struct vcmd_bcaps vc_data;
18482 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18485 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18489 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18491 + struct vcmd_badness_v0 vc_data;
18493 + vc_data.bias = vxi->vx_badness_bias;
18495 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18500 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18502 + struct vcmd_badness_v0 vc_data;
18504 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18507 + vxi->vx_badness_bias = vc_data.bias;
18511 +#include <linux/module.h>
18513 +EXPORT_SYMBOL_GPL(free_vx_info);
18515 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/cvirt.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cvirt.c
18516 --- linux-2.6.27.25/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18517 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cvirt.c 2008-10-31 03:49:36.000000000 +0100
18520 + * linux/kernel/vserver/cvirt.c
18522 + * Virtual Server: Context Virtualization
18524 + * Copyright (C) 2004-2007 Herbert Pötzl
18526 + * V0.01 broken out from limit.c
18527 + * V0.02 added utsname stuff
18528 + * V0.03 changed vcmds to vxi arg
18532 +#include <linux/types.h>
18533 +#include <linux/utsname.h>
18534 +#include <linux/vs_cvirt.h>
18535 +#include <linux/vserver/switch.h>
18536 +#include <linux/vserver/cvirt_cmd.h>
18538 +#include <asm/uaccess.h>
18541 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18543 + struct vx_info *vxi = current->vx_info;
18545 + set_normalized_timespec(uptime,
18546 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18547 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18550 + set_normalized_timespec(idle,
18551 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18552 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18556 +uint64_t vx_idle_jiffies(void)
18558 + return init_task.utime + init_task.stime;
18563 +static inline uint32_t __update_loadavg(uint32_t load,
18564 + int wsize, int delta, int n)
18566 + unsigned long long calc, prev;
18568 + /* just set it to n */
18569 + if (unlikely(delta >= wsize))
18570 + return (n << FSHIFT);
18572 + calc = delta * n;
18574 + prev = (wsize - delta);
18577 + do_div(calc, wsize);
18582 +void vx_update_load(struct vx_info *vxi)
18584 + uint32_t now, last, delta;
18585 + unsigned int nr_running, nr_uninterruptible;
18586 + unsigned int total;
18587 + unsigned long flags;
18589 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18592 + last = vxi->cvirt.load_last;
18593 + delta = now - last;
18595 + if (delta < 5*HZ)
18598 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18599 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18600 + total = nr_running + nr_uninterruptible;
18602 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18603 + 60*HZ, delta, total);
18604 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18605 + 5*60*HZ, delta, total);
18606 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18607 + 15*60*HZ, delta, total);
18609 + vxi->cvirt.load_last = now;
18611 + atomic_inc(&vxi->cvirt.load_updates);
18612 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18617 + * Commands to do_syslog:
18619 + * 0 -- Close the log. Currently a NOP.
18620 + * 1 -- Open the log. Currently a NOP.
18621 + * 2 -- Read from the log.
18622 + * 3 -- Read all messages remaining in the ring buffer.
18623 + * 4 -- Read and clear all messages remaining in the ring buffer
18624 + * 5 -- Clear ring buffer.
18625 + * 6 -- Disable printk's to console
18626 + * 7 -- Enable printk's to console
18627 + * 8 -- Set level of messages printed to console
18628 + * 9 -- Return number of unread characters in the log buffer
18629 + * 10 -- Return size of the log buffer
18631 +int vx_do_syslog(int type, char __user *buf, int len)
18634 + int do_clear = 0;
18635 + struct vx_info *vxi = current->vx_info;
18636 + struct _vx_syslog *log;
18640 + log = &vxi->cvirt.syslog;
18643 + case 0: /* Close log */
18644 + case 1: /* Open log */
18646 + case 2: /* Read from log */
18647 + error = wait_event_interruptible(log->log_wait,
18648 + (log->log_start - log->log_end));
18651 + spin_lock_irq(&log->logbuf_lock);
18652 + spin_unlock_irq(&log->logbuf_lock);
18654 + case 4: /* Read/clear last kernel messages */
18656 + /* fall through */
18657 + case 3: /* Read last kernel messages */
18660 + case 5: /* Clear ring buffer */
18663 + case 6: /* Disable logging to console */
18664 + case 7: /* Enable logging to console */
18665 + case 8: /* Set level of messages printed to console */
18668 + case 9: /* Number of chars in the log buffer */
18670 + case 10: /* Size of the log buffer */
18680 +/* virtual host info names */
18682 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18684 + struct nsproxy *nsproxy;
18685 + struct uts_namespace *uts;
18687 + if (id == VHIN_CONTEXT)
18688 + return vxi->vx_name;
18690 + nsproxy = vxi->vx_nsproxy[0];
18694 + uts = nsproxy->uts_ns;
18699 + case VHIN_SYSNAME:
18700 + return uts->name.sysname;
18701 + case VHIN_NODENAME:
18702 + return uts->name.nodename;
18703 + case VHIN_RELEASE:
18704 + return uts->name.release;
18705 + case VHIN_VERSION:
18706 + return uts->name.version;
18707 + case VHIN_MACHINE:
18708 + return uts->name.machine;
18709 + case VHIN_DOMAINNAME:
18710 + return uts->name.domainname;
18717 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18719 + struct vcmd_vhi_name_v0 vc_data;
18722 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18725 + name = vx_vhi_name(vxi, vc_data.field);
18729 + memcpy(name, vc_data.name, 65);
18733 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18735 + struct vcmd_vhi_name_v0 vc_data;
18738 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18741 + name = vx_vhi_name(vxi, vc_data.field);
18745 + memcpy(vc_data.name, name, 65);
18746 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18752 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18754 + struct vcmd_virt_stat_v0 vc_data;
18755 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18756 + struct timespec uptime;
18758 + do_posix_clock_monotonic_gettime(&uptime);
18759 + set_normalized_timespec(&uptime,
18760 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18761 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18763 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18764 + vc_data.uptime = timespec_to_ns(&uptime);
18765 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18766 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18767 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18768 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18769 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18770 + vc_data.load[0] = cvirt->load[0];
18771 + vc_data.load[1] = cvirt->load[1];
18772 + vc_data.load[2] = cvirt->load[2];
18774 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18780 +#ifdef CONFIG_VSERVER_VTIME
18782 +/* virtualized time base */
18784 +void vx_gettimeofday(struct timeval *tv)
18786 + do_gettimeofday(tv);
18787 + if (!vx_flags(VXF_VIRT_TIME, 0))
18790 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
18791 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
18793 + if (tv->tv_usec >= USEC_PER_SEC) {
18795 + tv->tv_usec -= USEC_PER_SEC;
18796 + } else if (tv->tv_usec < 0) {
18798 + tv->tv_usec += USEC_PER_SEC;
18802 +int vx_settimeofday(struct timespec *ts)
18804 + struct timeval tv;
18806 + if (!vx_flags(VXF_VIRT_TIME, 0))
18807 + return do_settimeofday(ts);
18809 + do_gettimeofday(&tv);
18810 + current->vx_info->cvirt.bias_tv.tv_sec =
18811 + ts->tv_sec - tv.tv_sec;
18812 + current->vx_info->cvirt.bias_tv.tv_usec =
18813 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18819 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/cvirt_init.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cvirt_init.h
18820 --- linux-2.6.27.25/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
18821 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cvirt_init.h 2008-10-13 14:54:20.000000000 +0200
18825 +extern uint64_t vx_idle_jiffies(void);
18827 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18829 + uint64_t idle_jiffies = vx_idle_jiffies();
18830 + uint64_t nsuptime;
18832 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18833 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18834 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18835 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18836 + cvirt->bias_tv.tv_sec = 0;
18837 + cvirt->bias_tv.tv_usec = 0;
18839 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
18840 + atomic_set(&cvirt->nr_threads, 0);
18841 + atomic_set(&cvirt->nr_running, 0);
18842 + atomic_set(&cvirt->nr_uninterruptible, 0);
18843 + atomic_set(&cvirt->nr_onhold, 0);
18845 + spin_lock_init(&cvirt->load_lock);
18846 + cvirt->load_last = jiffies;
18847 + atomic_set(&cvirt->load_updates, 0);
18848 + cvirt->load[0] = 0;
18849 + cvirt->load[1] = 0;
18850 + cvirt->load[2] = 0;
18851 + atomic_set(&cvirt->total_forks, 0);
18853 + spin_lock_init(&cvirt->syslog.logbuf_lock);
18854 + init_waitqueue_head(&cvirt->syslog.log_wait);
18855 + cvirt->syslog.log_start = 0;
18856 + cvirt->syslog.log_end = 0;
18857 + cvirt->syslog.con_start = 0;
18858 + cvirt->syslog.logged_chars = 0;
18862 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18864 + // cvirt_pc->cpustat = { 0 };
18867 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
18871 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
18872 + "!!! cvirt: %p[nr_threads] = %d on exit.",
18874 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
18875 + "!!! cvirt: %p[nr_running] = %d on exit.",
18877 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
18878 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
18880 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
18881 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
18887 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18892 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/cvirt_proc.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cvirt_proc.h
18893 --- linux-2.6.27.25/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
18894 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/cvirt_proc.h 2008-10-13 14:54:20.000000000 +0200
18896 +#ifndef _VX_CVIRT_PROC_H
18897 +#define _VX_CVIRT_PROC_H
18899 +#include <linux/nsproxy.h>
18900 +#include <linux/mnt_namespace.h>
18901 +#include <linux/ipc_namespace.h>
18902 +#include <linux/utsname.h>
18903 +#include <linux/ipc.h>
18907 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
18909 + struct mnt_namespace *ns;
18910 + struct uts_namespace *uts;
18911 + struct ipc_namespace *ipc;
18912 + struct path path;
18913 + char *pstr, *root;
18919 + length += sprintf(buffer + length,
18920 + "NSProxy:\t%p [%p,%p,%p]\n",
18921 + nsproxy, nsproxy->mnt_ns,
18922 + nsproxy->uts_ns, nsproxy->ipc_ns);
18924 + ns = nsproxy->mnt_ns;
18928 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
18932 + path.mnt = ns->root;
18933 + path.dentry = ns->root->mnt_root;
18934 + root = d_path(&path, pstr, PATH_MAX - 2);
18935 + length += sprintf(buffer + length,
18936 + "Namespace:\t%p [#%u]\n"
18937 + "RootPath:\t%s\n",
18938 + ns, atomic_read(&ns->count),
18943 + uts = nsproxy->uts_ns;
18947 + length += sprintf(buffer + length,
18948 + "SysName:\t%.*s\n"
18949 + "NodeName:\t%.*s\n"
18950 + "Release:\t%.*s\n"
18951 + "Version:\t%.*s\n"
18952 + "Machine:\t%.*s\n"
18953 + "DomainName:\t%.*s\n",
18954 + __NEW_UTS_LEN, uts->name.sysname,
18955 + __NEW_UTS_LEN, uts->name.nodename,
18956 + __NEW_UTS_LEN, uts->name.release,
18957 + __NEW_UTS_LEN, uts->name.version,
18958 + __NEW_UTS_LEN, uts->name.machine,
18959 + __NEW_UTS_LEN, uts->name.domainname);
18962 + ipc = nsproxy->ipc_ns;
18966 + length += sprintf(buffer + length,
18967 + "SEMS:\t\t%d %d %d %d %d\n"
18968 + "MSG:\t\t%d %d %d\n"
18969 + "SHM:\t\t%lu %lu %d %d\n",
18970 + ipc->sem_ctls[0], ipc->sem_ctls[1],
18971 + ipc->sem_ctls[2], ipc->sem_ctls[3],
18973 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
18974 + (unsigned long)ipc->shm_ctlmax,
18975 + (unsigned long)ipc->shm_ctlall,
18976 + ipc->shm_ctlmni, ipc->shm_tot);
18983 +#include <linux/sched.h>
18985 +#define LOAD_INT(x) ((x) >> FSHIFT)
18986 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18989 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18994 + length += sprintf(buffer + length,
18995 + "BiasUptime:\t%lu.%02lu\n",
18996 + (unsigned long)cvirt->bias_uptime.tv_sec,
18997 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18999 + a = cvirt->load[0] + (FIXED_1 / 200);
19000 + b = cvirt->load[1] + (FIXED_1 / 200);
19001 + c = cvirt->load[2] + (FIXED_1 / 200);
19002 + length += sprintf(buffer + length,
19003 + "nr_threads:\t%d\n"
19004 + "nr_running:\t%d\n"
19005 + "nr_unintr:\t%d\n"
19006 + "nr_onhold:\t%d\n"
19007 + "load_updates:\t%d\n"
19008 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19009 + "total_forks:\t%d\n",
19010 + atomic_read(&cvirt->nr_threads),
19011 + atomic_read(&cvirt->nr_running),
19012 + atomic_read(&cvirt->nr_uninterruptible),
19013 + atomic_read(&cvirt->nr_onhold),
19014 + atomic_read(&cvirt->load_updates),
19015 + LOAD_INT(a), LOAD_FRAC(a),
19016 + LOAD_INT(b), LOAD_FRAC(b),
19017 + LOAD_INT(c), LOAD_FRAC(c),
19018 + atomic_read(&cvirt->total_forks));
19023 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19024 + char *buffer, int cpu)
19030 +#endif /* _VX_CVIRT_PROC_H */
19031 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/debug.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/debug.c
19032 --- linux-2.6.27.25/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19033 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/debug.c 2008-10-13 14:54:20.000000000 +0200
19036 + * kernel/vserver/debug.c
19038 + * Copyright (C) 2005-2007 Herbert Pötzl
19040 + * V0.01 vx_info dump support
19044 +#include <linux/module.h>
19046 +#include <linux/vserver/context.h>
19049 +void dump_vx_info(struct vx_info *vxi, int level)
19051 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19052 + atomic_read(&vxi->vx_usecnt),
19053 + atomic_read(&vxi->vx_tasks),
19056 + __dump_vx_limit(&vxi->limit);
19057 + __dump_vx_sched(&vxi->sched);
19058 + __dump_vx_cvirt(&vxi->cvirt);
19059 + __dump_vx_cacct(&vxi->cacct);
19065 +EXPORT_SYMBOL_GPL(dump_vx_info);
19067 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/device.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/device.c
19068 --- linux-2.6.27.25/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19069 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/device.c 2008-10-13 14:54:20.000000000 +0200
19072 + * linux/kernel/vserver/device.c
19074 + * Linux-VServer: Device Support
19076 + * Copyright (C) 2006 Herbert Pötzl
19077 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19079 + * V0.01 device mapping basics
19080 + * V0.02 added defaults
19084 +#include <linux/slab.h>
19085 +#include <linux/rcupdate.h>
19086 +#include <linux/fs.h>
19087 +#include <linux/namei.h>
19088 +#include <linux/hash.h>
19090 +#include <asm/errno.h>
19091 +#include <asm/uaccess.h>
19092 +#include <linux/vserver/base.h>
19093 +#include <linux/vserver/debug.h>
19094 +#include <linux/vserver/context.h>
19095 +#include <linux/vserver/device.h>
19096 +#include <linux/vserver/device_cmd.h>
19099 +#define DMAP_HASH_BITS 4
19102 +struct vs_mapping {
19104 + struct hlist_node hlist;
19105 + struct list_head list;
19107 +#define dm_hlist u.hlist
19108 +#define dm_list u.list
19111 + struct vx_dmap_target target;
19115 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19117 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19119 +static struct vx_dmap_target dmap_defaults[2] = {
19120 + { .flags = DATTR_OPEN },
19121 + { .flags = DATTR_OPEN },
19125 +struct kmem_cache *dmap_cachep __read_mostly;
19127 +int __init dmap_cache_init(void)
19129 + dmap_cachep = kmem_cache_create("dmap_cache",
19130 + sizeof(struct vs_mapping), 0,
19131 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19135 +__initcall(dmap_cache_init);
19138 +static inline unsigned int __hashval(dev_t dev, int bits)
19140 + return hash_long((unsigned long)dev, bits);
19144 +/* __hash_mapping()
19145 + * add the mapping to the hash table
19147 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19149 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19150 + struct hlist_head *head, *hash = dmap_main_hash;
19151 + int device = vdm->device;
19153 + spin_lock(hash_lock);
19154 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19155 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19157 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19158 + hlist_add_head(&vdm->dm_hlist, head);
19159 + spin_unlock(hash_lock);
19163 +static inline int __mode_to_default(umode_t mode)
19176 +/* __set_default()
19179 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19180 + struct vx_dmap_target *vdmt)
19182 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19183 + spin_lock(hash_lock);
19186 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19188 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19191 + spin_unlock(hash_lock);
19193 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19194 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19198 +/* __remove_default()
19199 + * remove a default
19201 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19203 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19204 + spin_lock(hash_lock);
19207 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19208 + else /* remove == reset */
19209 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19211 + spin_unlock(hash_lock);
19216 +/* __find_mapping()
19217 + * find a mapping in the hash table
19219 + * caller must hold hash_lock
19221 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19222 + struct vs_mapping **local, struct vs_mapping **global)
19224 + struct hlist_head *hash = dmap_main_hash;
19225 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19226 + struct hlist_node *pos;
19227 + struct vs_mapping *vdm;
19233 + hlist_for_each(pos, head) {
19234 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19236 + if ((vdm->device == device) &&
19237 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19238 + if (vdm->xid == xid) {
19241 + } else if (global && vdm->xid == 0)
19246 + if (global && *global)
19253 +/* __lookup_mapping()
19254 + * find a mapping and store the result in target and flags
19256 +static inline int __lookup_mapping(struct vx_info *vxi,
19257 + dev_t device, dev_t *target, int *flags, umode_t mode)
19259 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19260 + struct vs_mapping *vdm, *global;
19261 + struct vx_dmap_target *vdmt;
19263 + xid_t xid = vxi->vx_id;
19266 + spin_lock(hash_lock);
19267 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19269 + vdmt = &vdm->target;
19273 + index = __mode_to_default(mode);
19274 + if (vxi && vxi->dmap.targets[index].flags) {
19276 + vdmt = &vxi->dmap.targets[index];
19277 + } else if (global) {
19279 + vdmt = &global->target;
19283 + vdmt = &dmap_defaults[index];
19287 + if (target && (vdmt->flags & DATTR_REMAP))
19288 + *target = vdmt->target;
19290 + *target = device;
19292 + *flags = vdmt->flags;
19294 + spin_unlock(hash_lock);
19300 +/* __remove_mapping()
19301 + * remove a mapping from the hash table
19303 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19306 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19307 + struct vs_mapping *vdm = NULL;
19310 + spin_lock(hash_lock);
19312 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19314 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19315 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19318 + hlist_del(&vdm->dm_hlist);
19321 + spin_unlock(hash_lock);
19323 + kmem_cache_free(dmap_cachep, vdm);
19329 +int vs_map_device(struct vx_info *vxi,
19330 + dev_t device, dev_t *target, umode_t mode)
19332 + int ret, flags = DATTR_MASK;
19336 + *target = device;
19339 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19340 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19341 + device, target ? *target : 0, flags, mode, ret);
19343 + return (flags & DATTR_MASK);
19348 +static int do_set_mapping(struct vx_info *vxi,
19349 + dev_t device, dev_t target, int flags, umode_t mode)
19352 + struct vs_mapping *new;
19354 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19358 + INIT_HLIST_NODE(&new->dm_hlist);
19359 + new->device = device;
19360 + new->target.target = target;
19361 + new->target.flags = flags | mode;
19362 + new->xid = (vxi ? vxi->vx_id : 0);
19364 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19365 + __hash_mapping(vxi, new);
19367 + struct vx_dmap_target new = {
19368 + .target = target,
19369 + .flags = flags | mode,
19371 + __set_default(vxi, mode, &new);
19377 +static int do_unset_mapping(struct vx_info *vxi,
19378 + dev_t device, dev_t target, int flags, umode_t mode)
19380 + int ret = -EINVAL;
19383 + ret = __remove_mapping(vxi, device, mode);
19387 + ret = __remove_default(vxi, mode);
19397 +static inline int __user_device(const char __user *name, dev_t *dev,
19400 + struct nameidata nd;
19407 + ret = user_lpath(name, &nd.path);
19410 + if (nd.path.dentry->d_inode) {
19411 + *dev = nd.path.dentry->d_inode->i_rdev;
19412 + *mode = nd.path.dentry->d_inode->i_mode;
19414 + path_put(&nd.path);
19418 +static inline int __mapping_mode(dev_t device, dev_t target,
19419 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19422 + *mode = device_mode & S_IFMT;
19424 + *mode = target_mode & S_IFMT;
19428 + /* if both given, device and target mode have to match */
19429 + if (device && target &&
19430 + ((device_mode ^ target_mode) & S_IFMT))
19436 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19437 + const char __user *target_path, int flags, int set)
19439 + dev_t device = ~0, target = ~0;
19440 + umode_t device_mode = 0, target_mode = 0, mode;
19443 + ret = __user_device(device_path, &device, &device_mode);
19446 + ret = __user_device(target_path, &target, &target_mode);
19450 + ret = __mapping_mode(device, target,
19451 + device_mode, target_mode, &mode);
19456 + return do_set_mapping(vxi, device, target,
19459 + return do_unset_mapping(vxi, device, target,
19464 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19466 + struct vcmd_set_mapping_v0 vc_data;
19468 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19471 + return do_mapping(vxi, vc_data.device, vc_data.target,
19472 + vc_data.flags, 1);
19475 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19477 + struct vcmd_set_mapping_v0 vc_data;
19479 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19482 + return do_mapping(vxi, vc_data.device, vc_data.target,
19483 + vc_data.flags, 0);
19487 +#ifdef CONFIG_COMPAT
19489 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19491 + struct vcmd_set_mapping_v0_x32 vc_data;
19493 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19496 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19497 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19500 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19502 + struct vcmd_set_mapping_v0_x32 vc_data;
19504 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19507 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19508 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19511 +#endif /* CONFIG_COMPAT */
19514 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/dlimit.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/dlimit.c
19515 --- linux-2.6.27.25/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19516 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/dlimit.c 2008-10-13 14:54:20.000000000 +0200
19519 + * linux/kernel/vserver/dlimit.c
19521 + * Virtual Server: Context Disk Limits
19523 + * Copyright (C) 2004-2007 Herbert Pötzl
19525 + * V0.01 initial version
19526 + * V0.02 compat32 splitup
19530 +#include <linux/statfs.h>
19531 +#include <linux/sched.h>
19532 +#include <linux/namei.h>
19533 +#include <linux/vs_tag.h>
19534 +#include <linux/vs_dlimit.h>
19535 +#include <linux/vserver/dlimit_cmd.h>
19537 +#include <asm/uaccess.h>
19539 +/* __alloc_dl_info()
19541 + * allocate an initialized dl_info struct
19542 + * doesn't make it visible (hash) */
19544 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19546 + struct dl_info *new = NULL;
19548 + vxdprintk(VXD_CBIT(dlim, 5),
19549 + "alloc_dl_info(%p,%d)*", sb, tag);
19551 + /* would this benefit from a slab cache? */
19552 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19556 + memset(new, 0, sizeof(struct dl_info));
19557 + new->dl_tag = tag;
19559 + INIT_RCU_HEAD(&new->dl_rcu);
19560 + INIT_HLIST_NODE(&new->dl_hlist);
19561 + spin_lock_init(&new->dl_lock);
19562 + atomic_set(&new->dl_refcnt, 0);
19563 + atomic_set(&new->dl_usecnt, 0);
19565 + /* rest of init goes here */
19567 + vxdprintk(VXD_CBIT(dlim, 4),
19568 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19572 +/* __dealloc_dl_info()
19574 + * final disposal of dl_info */
19576 +static void __dealloc_dl_info(struct dl_info *dli)
19578 + vxdprintk(VXD_CBIT(dlim, 4),
19579 + "dealloc_dl_info(%p)", dli);
19581 + dli->dl_hlist.next = LIST_POISON1;
19582 + dli->dl_tag = -1;
19585 + BUG_ON(atomic_read(&dli->dl_usecnt));
19586 + BUG_ON(atomic_read(&dli->dl_refcnt));
19592 +/* hash table for dl_info hash */
19594 +#define DL_HASH_SIZE 13
19596 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19598 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19601 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19603 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19608 +/* __hash_dl_info()
19610 + * add the dli to the global hash table
19611 + * requires the hash_lock to be held */
19613 +static inline void __hash_dl_info(struct dl_info *dli)
19615 + struct hlist_head *head;
19617 + vxdprintk(VXD_CBIT(dlim, 6),
19618 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19619 + get_dl_info(dli);
19620 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19621 + hlist_add_head_rcu(&dli->dl_hlist, head);
19624 +/* __unhash_dl_info()
19626 + * remove the dli from the global hash table
19627 + * requires the hash_lock to be held */
19629 +static inline void __unhash_dl_info(struct dl_info *dli)
19631 + vxdprintk(VXD_CBIT(dlim, 6),
19632 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19633 + hlist_del_rcu(&dli->dl_hlist);
19634 + put_dl_info(dli);
19638 +/* __lookup_dl_info()
19640 + * requires the rcu_read_lock()
19641 + * doesn't increment the dl_refcnt */
19643 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19645 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19646 + struct hlist_node *pos;
19647 + struct dl_info *dli;
19649 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19651 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19659 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19661 + struct dl_info *dli;
19664 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19665 + vxdprintk(VXD_CBIT(dlim, 7),
19666 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19667 + rcu_read_unlock();
19671 +void rcu_free_dl_info(struct rcu_head *head)
19673 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19674 + int usecnt, refcnt;
19676 + BUG_ON(!dli || !head);
19678 + usecnt = atomic_read(&dli->dl_usecnt);
19679 + BUG_ON(usecnt < 0);
19681 + refcnt = atomic_read(&dli->dl_refcnt);
19682 + BUG_ON(refcnt < 0);
19684 + vxdprintk(VXD_CBIT(dlim, 3),
19685 + "rcu_free_dl_info(%p)", dli);
19687 + __dealloc_dl_info(dli);
19689 + printk("!!! rcu didn't free\n");
19695 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19696 + uint32_t flags, int add)
19698 + struct path path;
19701 + ret = user_lpath(name, &path);
19703 + struct super_block *sb;
19704 + struct dl_info *dli;
19707 + if (!path.dentry->d_inode)
19708 + goto out_release;
19709 + if (!(sb = path.dentry->d_inode->i_sb))
19710 + goto out_release;
19713 + dli = __alloc_dl_info(sb, id);
19714 + spin_lock(&dl_info_hash_lock);
19717 + if (__lookup_dl_info(sb, id))
19719 + __hash_dl_info(dli);
19722 + spin_lock(&dl_info_hash_lock);
19723 + dli = __lookup_dl_info(sb, id);
19728 + __unhash_dl_info(dli);
19732 + spin_unlock(&dl_info_hash_lock);
19734 + __dealloc_dl_info(dli);
19741 +int vc_add_dlimit(uint32_t id, void __user *data)
19743 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19745 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19748 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19751 +int vc_rem_dlimit(uint32_t id, void __user *data)
19753 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19755 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19758 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19761 +#ifdef CONFIG_COMPAT
19763 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19765 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19767 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19770 + return do_addrem_dlimit(id,
19771 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19774 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19776 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19778 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19781 + return do_addrem_dlimit(id,
19782 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19785 +#endif /* CONFIG_COMPAT */
19789 +int do_set_dlimit(uint32_t id, const char __user *name,
19790 + uint32_t space_used, uint32_t space_total,
19791 + uint32_t inodes_used, uint32_t inodes_total,
19792 + uint32_t reserved, uint32_t flags)
19794 + struct path path;
19797 + ret = user_lpath(name, &path);
19799 + struct super_block *sb;
19800 + struct dl_info *dli;
19803 + if (!path.dentry->d_inode)
19804 + goto out_release;
19805 + if (!(sb = path.dentry->d_inode->i_sb))
19806 + goto out_release;
19807 + if ((reserved != CDLIM_KEEP &&
19808 + reserved > 100) ||
19809 + (inodes_used != CDLIM_KEEP &&
19810 + inodes_used > inodes_total) ||
19811 + (space_used != CDLIM_KEEP &&
19812 + space_used > space_total))
19813 + goto out_release;
19816 + dli = locate_dl_info(sb, id);
19818 + goto out_release;
19820 + spin_lock(&dli->dl_lock);
19822 + if (inodes_used != CDLIM_KEEP)
19823 + dli->dl_inodes_used = inodes_used;
19824 + if (inodes_total != CDLIM_KEEP)
19825 + dli->dl_inodes_total = inodes_total;
19826 + if (space_used != CDLIM_KEEP) {
19827 + dli->dl_space_used = space_used;
19828 + dli->dl_space_used <<= 10;
19830 + if (space_total == CDLIM_INFINITY)
19831 + dli->dl_space_total = DLIM_INFINITY;
19832 + else if (space_total != CDLIM_KEEP) {
19833 + dli->dl_space_total = space_total;
19834 + dli->dl_space_total <<= 10;
19836 + if (reserved != CDLIM_KEEP)
19837 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
19839 + spin_unlock(&dli->dl_lock);
19841 + put_dl_info(dli);
19850 +int vc_set_dlimit(uint32_t id, void __user *data)
19852 + struct vcmd_ctx_dlimit_v0 vc_data;
19854 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19857 + return do_set_dlimit(id, vc_data.name,
19858 + vc_data.space_used, vc_data.space_total,
19859 + vc_data.inodes_used, vc_data.inodes_total,
19860 + vc_data.reserved, vc_data.flags);
19863 +#ifdef CONFIG_COMPAT
19865 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19867 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19869 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19872 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19873 + vc_data.space_used, vc_data.space_total,
19874 + vc_data.inodes_used, vc_data.inodes_total,
19875 + vc_data.reserved, vc_data.flags);
19878 +#endif /* CONFIG_COMPAT */
19882 +int do_get_dlimit(uint32_t id, const char __user *name,
19883 + uint32_t *space_used, uint32_t *space_total,
19884 + uint32_t *inodes_used, uint32_t *inodes_total,
19885 + uint32_t *reserved, uint32_t *flags)
19887 + struct path path;
19890 + ret = user_lpath(name, &path);
19892 + struct super_block *sb;
19893 + struct dl_info *dli;
19896 + if (!path.dentry->d_inode)
19897 + goto out_release;
19898 + if (!(sb = path.dentry->d_inode->i_sb))
19899 + goto out_release;
19902 + dli = locate_dl_info(sb, id);
19904 + goto out_release;
19906 + spin_lock(&dli->dl_lock);
19907 + *inodes_used = dli->dl_inodes_used;
19908 + *inodes_total = dli->dl_inodes_total;
19909 + *space_used = dli->dl_space_used >> 10;
19910 + if (dli->dl_space_total == DLIM_INFINITY)
19911 + *space_total = CDLIM_INFINITY;
19913 + *space_total = dli->dl_space_total >> 10;
19915 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19916 + spin_unlock(&dli->dl_lock);
19918 + put_dl_info(dli);
19929 +int vc_get_dlimit(uint32_t id, void __user *data)
19931 + struct vcmd_ctx_dlimit_v0 vc_data;
19934 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19937 + ret = do_get_dlimit(id, vc_data.name,
19938 + &vc_data.space_used, &vc_data.space_total,
19939 + &vc_data.inodes_used, &vc_data.inodes_total,
19940 + &vc_data.reserved, &vc_data.flags);
19944 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19949 +#ifdef CONFIG_COMPAT
19951 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19953 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19956 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19959 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19960 + &vc_data.space_used, &vc_data.space_total,
19961 + &vc_data.inodes_used, &vc_data.inodes_total,
19962 + &vc_data.reserved, &vc_data.flags);
19966 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19971 +#endif /* CONFIG_COMPAT */
19974 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19976 + struct dl_info *dli;
19977 + __u64 blimit, bfree, bavail;
19980 + dli = locate_dl_info(sb, dx_current_tag());
19984 + spin_lock(&dli->dl_lock);
19985 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19988 + /* reduce max inodes available to limit */
19989 + if (buf->f_files > dli->dl_inodes_total)
19990 + buf->f_files = dli->dl_inodes_total;
19992 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19993 + /* reduce free inodes to min */
19994 + if (ifree < buf->f_ffree)
19995 + buf->f_ffree = ifree;
19998 + if (dli->dl_space_total == DLIM_INFINITY)
20001 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20003 + if (dli->dl_space_total < dli->dl_space_used)
20006 + bfree = (dli->dl_space_total - dli->dl_space_used)
20007 + >> sb->s_blocksize_bits;
20009 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20010 + if (bavail < dli->dl_space_used)
20013 + bavail = (bavail - dli->dl_space_used)
20014 + >> sb->s_blocksize_bits;
20016 + /* reduce max space available to limit */
20017 + if (buf->f_blocks > blimit)
20018 + buf->f_blocks = blimit;
20020 + /* reduce free space to min */
20021 + if (bfree < buf->f_bfree)
20022 + buf->f_bfree = bfree;
20024 + /* reduce avail space to min */
20025 + if (bavail < buf->f_bavail)
20026 + buf->f_bavail = bavail;
20029 + spin_unlock(&dli->dl_lock);
20030 + put_dl_info(dli);
20035 +#include <linux/module.h>
20037 +EXPORT_SYMBOL_GPL(locate_dl_info);
20038 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20040 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/helper.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/helper.c
20041 --- linux-2.6.27.25/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20042 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/helper.c 2008-10-13 14:54:20.000000000 +0200
20045 + * linux/kernel/vserver/helper.c
20047 + * Virtual Context Support
20049 + * Copyright (C) 2004-2007 Herbert Pötzl
20051 + * V0.01 basic helper
20055 +#include <linux/kmod.h>
20056 +#include <linux/reboot.h>
20057 +#include <linux/vs_context.h>
20058 +#include <linux/vs_network.h>
20059 +#include <linux/vserver/signal.h>
20062 +char vshelper_path[255] = "/sbin/vshelper";
20065 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20069 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20070 + printk( KERN_WARNING
20071 + "%s: (%s %s) returned %s with %d\n",
20072 + name, argv[1], argv[2],
20073 + sync ? "sync" : "async", ret);
20075 + vxdprintk(VXD_CBIT(switch, 4),
20076 + "%s: (%s %s) returned %s with %d",
20077 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20082 + * vshelper path is set via /proc/sys
20083 + * invoked by vserver sys_reboot(), with
20084 + * the following arguments
20086 + * argv [0] = vshelper_path;
20087 + * argv [1] = action: "restart", "halt", "poweroff", ...
20088 + * argv [2] = context identifier
20090 + * envp [*] = type-specific parameters
20093 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20095 + char id_buf[8], cmd_buf[16];
20096 + char uid_buf[16], pid_buf[16];
20099 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20100 + char *envp[] = {"HOME=/", "TERM=linux",
20101 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20102 + uid_buf, pid_buf, cmd_buf, 0};
20104 + if (vx_info_state(vxi, VXS_HELPER))
20106 + vxi->vx_state |= VXS_HELPER;
20108 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20110 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20111 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
20112 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20115 + case LINUX_REBOOT_CMD_RESTART:
20116 + argv[1] = "restart";
20119 + case LINUX_REBOOT_CMD_HALT:
20120 + argv[1] = "halt";
20123 + case LINUX_REBOOT_CMD_POWER_OFF:
20124 + argv[1] = "poweroff";
20127 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20128 + argv[1] = "swsusp";
20132 + vxi->vx_state &= ~VXS_HELPER;
20136 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20137 + vxi->vx_state &= ~VXS_HELPER;
20138 + __wakeup_vx_info(vxi);
20139 + return (ret) ? -EPERM : 0;
20143 +long vs_reboot(unsigned int cmd, void __user *arg)
20145 + struct vx_info *vxi = current->vx_info;
20148 + vxdprintk(VXD_CBIT(misc, 5),
20149 + "vs_reboot(%p[#%d],%d)",
20150 + vxi, vxi ? vxi->vx_id : 0, cmd);
20152 + ret = vs_reboot_helper(vxi, cmd, arg);
20156 + vxi->reboot_cmd = cmd;
20157 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20159 + case LINUX_REBOOT_CMD_RESTART:
20160 + case LINUX_REBOOT_CMD_HALT:
20161 + case LINUX_REBOOT_CMD_POWER_OFF:
20162 + vx_info_kill(vxi, 0, SIGKILL);
20163 + vx_info_kill(vxi, 1, SIGKILL);
20173 + * argv [0] = vshelper_path;
20174 + * argv [1] = action: "startup", "shutdown"
20175 + * argv [2] = context identifier
20177 + * envp [*] = type-specific parameters
20180 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20182 + char id_buf[8], cmd_buf[16];
20183 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20184 + char *envp[] = {"HOME=/", "TERM=linux",
20185 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20187 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20190 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20191 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20194 + case VSC_STARTUP:
20195 + argv[1] = "startup";
20197 + case VSC_SHUTDOWN:
20198 + argv[1] = "shutdown";
20204 + return do_vshelper(vshelper_path, argv, envp, 1);
20209 + * argv [0] = vshelper_path;
20210 + * argv [1] = action: "netup", "netdown"
20211 + * argv [2] = context identifier
20213 + * envp [*] = type-specific parameters
20216 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20218 + char id_buf[8], cmd_buf[16];
20219 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20220 + char *envp[] = {"HOME=/", "TERM=linux",
20221 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20223 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20226 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20227 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20231 + argv[1] = "netup";
20233 + case VSC_NETDOWN:
20234 + argv[1] = "netdown";
20240 + return do_vshelper(vshelper_path, argv, envp, 1);
20243 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/history.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/history.c
20244 --- linux-2.6.27.25/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20245 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/history.c 2008-10-13 14:54:20.000000000 +0200
20248 + * kernel/vserver/history.c
20250 + * Virtual Context History Backtrace
20252 + * Copyright (C) 2004-2007 Herbert Pötzl
20254 + * V0.01 basic structure
20255 + * V0.02 hash/unhash and trace
20256 + * V0.03 preemption fixes
20260 +#include <linux/module.h>
20261 +#include <asm/uaccess.h>
20263 +#include <linux/vserver/context.h>
20264 +#include <linux/vserver/debug.h>
20265 +#include <linux/vserver/debug_cmd.h>
20266 +#include <linux/vserver/history.h>
20269 +#ifdef CONFIG_VSERVER_HISTORY
20270 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20272 +#define VXH_SIZE 64
20275 +struct _vx_history {
20276 + unsigned int counter;
20278 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20282 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20284 +unsigned volatile int vxh_active = 1;
20286 +static atomic_t sequence = ATOMIC_INIT(0);
20291 + * requires disabled preemption */
20293 +struct _vx_hist_entry *vxh_advance(void *loc)
20295 + unsigned int cpu = smp_processor_id();
20296 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20297 + struct _vx_hist_entry *entry;
20298 + unsigned int index;
20300 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20301 + entry = &hist->entry[index];
20303 + entry->seq = atomic_inc_return(&sequence);
20304 + entry->loc = loc;
20308 +EXPORT_SYMBOL_GPL(vxh_advance);
20311 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20313 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20316 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20318 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20319 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20320 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20321 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20323 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20325 + switch (e->type) {
20326 + case VXH_THROW_OOPS:
20327 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20330 + case VXH_GET_VX_INFO:
20331 + case VXH_PUT_VX_INFO:
20332 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20334 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20335 + VXH_VXI_ARGS(e));
20338 + case VXH_INIT_VX_INFO:
20339 + case VXH_SET_VX_INFO:
20340 + case VXH_CLR_VX_INFO:
20341 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20343 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20344 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20345 + VXH_VXI_ARGS(e), e->sc.data);
20348 + case VXH_CLAIM_VX_INFO:
20349 + case VXH_RELEASE_VX_INFO:
20350 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20352 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20353 + VXH_VXI_ARGS(e), e->sc.data);
20356 + case VXH_ALLOC_VX_INFO:
20357 + case VXH_DEALLOC_VX_INFO:
20358 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20360 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20361 + VXH_VXI_ARGS(e));
20364 + case VXH_HASH_VX_INFO:
20365 + case VXH_UNHASH_VX_INFO:
20366 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20368 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20369 + VXH_VXI_ARGS(e));
20372 + case VXH_LOC_VX_INFO:
20373 + case VXH_LOOKUP_VX_INFO:
20374 + case VXH_CREATE_VX_INFO:
20375 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20377 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20378 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20379 + e->ll.arg, VXH_VXI_ARGS(e));
20384 +static void __vxh_dump_history(void)
20386 + unsigned int i, cpu;
20388 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20389 + atomic_read(&sequence), NR_CPUS);
20391 + for (i = 0; i < VXH_SIZE; i++) {
20392 + for_each_online_cpu(cpu) {
20393 + struct _vx_history *hist =
20394 + &per_cpu(vx_history_buffer, cpu);
20395 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20396 + struct _vx_hist_entry *entry = &hist->entry[index];
20398 + vxh_dump_entry(entry, cpu);
20403 +void vxh_dump_history(void)
20407 + local_irq_enable();
20409 + local_irq_disable();
20411 + __vxh_dump_history();
20415 +/* vserver syscall commands below here */
20418 +int vc_dump_history(uint32_t id)
20421 + __vxh_dump_history();
20428 +int do_read_history(struct __user _vx_hist_entry *data,
20429 + int cpu, uint32_t *index, uint32_t *count)
20431 + int pos, ret = 0;
20432 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20433 + int end = hist->counter;
20434 + int start = end - VXH_SIZE + 2;
20435 + int idx = *index;
20437 + /* special case: get current pos */
20443 + /* have we lost some data? */
20447 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20448 + struct _vx_hist_entry *entry =
20449 + &hist->entry[idx % VXH_SIZE];
20451 + /* send entry to userspace */
20452 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20456 + /* save new index and count */
20459 + return ret ? ret : (*index < end);
20462 +int vc_read_history(uint32_t id, void __user *data)
20464 + struct vcmd_read_history_v0 vc_data;
20467 + if (id >= NR_CPUS)
20470 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20473 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20474 + id, &vc_data.index, &vc_data.count);
20476 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20481 +#ifdef CONFIG_COMPAT
20483 +int vc_read_history_x32(uint32_t id, void __user *data)
20485 + struct vcmd_read_history_v0_x32 vc_data;
20488 + if (id >= NR_CPUS)
20491 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20494 + ret = do_read_history((struct __user _vx_hist_entry *)
20495 + compat_ptr(vc_data.data_ptr),
20496 + id, &vc_data.index, &vc_data.count);
20498 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20503 +#endif /* CONFIG_COMPAT */
20505 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/inet.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/inet.c
20506 --- linux-2.6.27.25/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20507 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/inet.c 2008-10-13 14:54:20.000000000 +0200
20510 +#include <linux/in.h>
20511 +#include <linux/inetdevice.h>
20512 +#include <linux/vs_inet.h>
20513 +#include <linux/vs_inet6.h>
20514 +#include <linux/vserver/debug.h>
20515 +#include <net/route.h>
20516 +#include <net/addrconf.h>
20519 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20523 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20526 + struct nx_addr_v4 *ptr;
20528 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20529 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20536 + vxdprintk(VXD_CBIT(net, 2),
20537 + "nx_v4_addr_conflict(%p,%p): %d",
20538 + nxi1, nxi2, ret);
20544 +#ifdef CONFIG_IPV6
20546 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20550 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20553 + struct nx_addr_v6 *ptr;
20555 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20556 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20563 + vxdprintk(VXD_CBIT(net, 2),
20564 + "nx_v6_addr_conflict(%p,%p): %d",
20565 + nxi1, nxi2, ret);
20572 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20574 + struct in_device *in_dev;
20575 + struct in_ifaddr **ifap;
20576 + struct in_ifaddr *ifa;
20581 + in_dev = in_dev_get(dev);
20585 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20586 + ifap = &ifa->ifa_next) {
20587 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20592 + in_dev_put(in_dev);
20598 +#ifdef CONFIG_IPV6
20600 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20602 + struct inet6_dev *in_dev;
20603 + struct inet6_ifaddr **ifap;
20604 + struct inet6_ifaddr *ifa;
20609 + in_dev = in6_dev_get(dev);
20613 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20614 + ifap = &ifa->if_next) {
20615 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20620 + in6_dev_put(in_dev);
20627 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20633 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20635 +#ifdef CONFIG_IPV6
20637 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20642 + vxdprintk(VXD_CBIT(net, 3),
20643 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20644 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20648 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20649 + struct rtable **rp, struct flowi *fl)
20654 + /* FIXME: handle lback only case */
20655 + if (!NX_IPV4(nxi))
20658 + vxdprintk(VXD_CBIT(net, 4),
20659 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20660 + nxi, nxi ? nxi->nx_id : 0,
20661 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20663 + /* single IP is unconditional */
20664 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20665 + (fl->fl4_src == INADDR_ANY))
20666 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20668 + if (fl->fl4_src == INADDR_ANY) {
20669 + struct nx_addr_v4 *ptr;
20670 + __be32 found = 0;
20673 + err = __ip_route_output_key(net, rp, fl);
20675 + found = (*rp)->rt_src;
20677 + vxdprintk(VXD_CBIT(net, 4),
20678 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20679 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20680 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20684 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20685 + __be32 primary = ptr->ip[0].s_addr;
20686 + __be32 mask = ptr->mask.s_addr;
20687 + __be32 neta = primary & mask;
20689 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20690 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20691 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20692 + NIPQUAD(mask), NIPQUAD(neta));
20693 + if ((found & mask) != neta)
20696 + fl->fl4_src = primary;
20697 + err = __ip_route_output_key(net, rp, fl);
20698 + vxdprintk(VXD_CBIT(net, 4),
20699 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20700 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20702 + found = (*rp)->rt_src;
20704 + if (found == primary)
20708 + /* still no source ip? */
20709 + found = ipv4_is_loopback(fl->fl4_dst)
20710 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20712 + /* assign src ip to flow */
20713 + fl->fl4_src = found;
20716 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20720 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20721 + if (ipv4_is_loopback(fl->fl4_dst))
20722 + fl->fl4_dst = nxi->v4_lback.s_addr;
20723 + if (ipv4_is_loopback(fl->fl4_src))
20724 + fl->fl4_src = nxi->v4_lback.s_addr;
20725 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20726 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20732 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20734 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/init.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/init.c
20735 --- linux-2.6.27.25/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20736 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/init.c 2008-10-13 14:54:20.000000000 +0200
20739 + * linux/kernel/init.c
20741 + * Virtual Server Init
20743 + * Copyright (C) 2004-2007 Herbert Pötzl
20745 + * V0.01 basic structure
20749 +#include <linux/init.h>
20751 +int vserver_register_sysctl(void);
20752 +void vserver_unregister_sysctl(void);
20755 +static int __init init_vserver(void)
20759 +#ifdef CONFIG_VSERVER_DEBUG
20760 + vserver_register_sysctl();
20766 +static void __exit exit_vserver(void)
20769 +#ifdef CONFIG_VSERVER_DEBUG
20770 + vserver_unregister_sysctl();
20775 +/* FIXME: GFP_ZONETYPES gone
20776 +long vx_slab[GFP_ZONETYPES]; */
20780 +module_init(init_vserver);
20781 +module_exit(exit_vserver);
20783 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/inode.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/inode.c
20784 --- linux-2.6.27.25/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20785 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/inode.c 2008-10-24 03:34:52.000000000 +0200
20788 + * linux/kernel/vserver/inode.c
20790 + * Virtual Server: File System Support
20792 + * Copyright (C) 2004-2007 Herbert Pötzl
20794 + * V0.01 separated from vcontext V0.05
20795 + * V0.02 moved to tag (instead of xid)
20799 +#include <linux/tty.h>
20800 +#include <linux/proc_fs.h>
20801 +#include <linux/devpts_fs.h>
20802 +#include <linux/fs.h>
20803 +#include <linux/file.h>
20804 +#include <linux/mount.h>
20805 +#include <linux/parser.h>
20806 +#include <linux/namei.h>
20807 +#include <linux/vserver/inode.h>
20808 +#include <linux/vserver/inode_cmd.h>
20809 +#include <linux/vs_base.h>
20810 +#include <linux/vs_tag.h>
20812 +#include <asm/uaccess.h>
20815 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20817 + struct proc_dir_entry *entry;
20819 + if (!in || !in->i_sb)
20822 + *flags = IATTR_TAG
20823 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
20824 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
20825 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
20826 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE;
20828 + if (S_ISDIR(in->i_mode))
20829 + *mask |= IATTR_BARRIER;
20831 + if (IS_TAGGED(in)) {
20832 + *tag = in->i_tag;
20833 + *mask |= IATTR_TAG;
20836 + switch (in->i_sb->s_magic) {
20837 + case PROC_SUPER_MAGIC:
20838 + entry = PROC_I(in)->pde;
20840 + /* check for specific inodes? */
20842 + *mask |= IATTR_FLAGS;
20844 + *flags |= (entry->vx_flags & IATTR_FLAGS);
20846 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
20849 + case DEVPTS_SUPER_MAGIC:
20850 + *tag = in->i_tag;
20851 + *mask |= IATTR_TAG;
20860 +int vc_get_iattr(void __user *data)
20862 + struct path path;
20863 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
20866 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20869 + ret = user_lpath(vc_data.name, &path);
20871 + ret = __vc_get_iattr(path.dentry->d_inode,
20872 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20878 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20883 +#ifdef CONFIG_COMPAT
20885 +int vc_get_iattr_x32(void __user *data)
20887 + struct path path;
20888 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
20891 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20894 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20896 + ret = __vc_get_iattr(path.dentry->d_inode,
20897 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20903 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20908 +#endif /* CONFIG_COMPAT */
20911 +int vc_fget_iattr(uint32_t fd, void __user *data)
20913 + struct file *filp;
20914 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
20917 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20921 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20924 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20925 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20929 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20935 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20937 + struct inode *in = de->d_inode;
20938 + int error = 0, is_proc = 0, has_tag = 0;
20939 + struct iattr attr = { 0 };
20941 + if (!in || !in->i_sb)
20944 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20945 + if ((*mask & IATTR_FLAGS) && !is_proc)
20948 + has_tag = IS_TAGGED(in) ||
20949 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20950 + if ((*mask & IATTR_TAG) && !has_tag)
20953 + mutex_lock(&in->i_mutex);
20954 + if (*mask & IATTR_TAG) {
20955 + attr.ia_tag = *tag;
20956 + attr.ia_valid |= ATTR_TAG;
20959 + if (*mask & IATTR_FLAGS) {
20960 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20961 + unsigned int iflags = PROC_I(in)->vx_flags;
20963 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20964 + | (*flags & IATTR_FLAGS);
20965 + PROC_I(in)->vx_flags = iflags;
20967 + entry->vx_flags = iflags;
20970 + if (*mask & (IATTR_BARRIER | IATTR_IXUNLINK | IATTR_IMMUTABLE)) {
20971 + if (*mask & IATTR_IMMUTABLE) {
20972 + if (*flags & IATTR_IMMUTABLE)
20973 + in->i_flags |= S_IMMUTABLE;
20975 + in->i_flags &= ~S_IMMUTABLE;
20977 + if (*mask & IATTR_IXUNLINK) {
20978 + if (*flags & IATTR_IXUNLINK)
20979 + in->i_flags |= S_IXUNLINK;
20981 + in->i_flags &= ~S_IXUNLINK;
20983 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20984 + if (*flags & IATTR_BARRIER)
20985 + in->i_vflags |= V_BARRIER;
20987 + in->i_vflags &= ~V_BARRIER;
20989 + if (in->i_op && in->i_op->sync_flags) {
20990 + error = in->i_op->sync_flags(in);
20996 + if (attr.ia_valid) {
20997 + if (in->i_op && in->i_op->setattr)
20998 + error = in->i_op->setattr(de, &attr);
21000 + error = inode_change_ok(in, &attr);
21002 + error = inode_setattr(in, &attr);
21007 + mutex_unlock(&in->i_mutex);
21011 +int vc_set_iattr(void __user *data)
21013 + struct path path;
21014 + struct vcmd_ctx_iattr_v1 vc_data;
21017 + if (!capable(CAP_LINUX_IMMUTABLE))
21019 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21022 + ret = user_lpath(vc_data.name, &path);
21024 + ret = __vc_set_iattr(path.dentry,
21025 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21029 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21034 +#ifdef CONFIG_COMPAT
21036 +int vc_set_iattr_x32(void __user *data)
21038 + struct path path;
21039 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21042 + if (!capable(CAP_LINUX_IMMUTABLE))
21044 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21047 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21049 + ret = __vc_set_iattr(path.dentry,
21050 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21054 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21059 +#endif /* CONFIG_COMPAT */
21061 +int vc_fset_iattr(uint32_t fd, void __user *data)
21063 + struct file *filp;
21064 + struct vcmd_ctx_fiattr_v0 vc_data;
21067 + if (!capable(CAP_LINUX_IMMUTABLE))
21069 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21073 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21076 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21077 + &vc_data.flags, &vc_data.mask);
21081 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21087 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21089 +static match_table_t tokens = {
21090 + {Opt_notagcheck, "notagcheck"},
21091 +#ifdef CONFIG_PROPAGATE
21092 + {Opt_notag, "notag"},
21093 + {Opt_tag, "tag"},
21094 + {Opt_tagid, "tagid=%u"},
21100 +static void __dx_parse_remove(char *string, char *opt)
21102 + char *p = strstr(string, opt);
21106 + while (*q != '\0' && *q != ',')
21115 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21116 + unsigned long *flags)
21119 + substring_t args[MAX_OPT_ARGS];
21120 + int token, option = 0;
21121 + char *s, *p, *opts;
21125 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21130 + while ((p = strsep(&opts, ",")) != NULL) {
21131 + token = match_token(p, tokens, args);
21133 + vxdprintk(VXD_CBIT(tag, 7),
21134 + "dx_parse_tag(»%s«): %d:#%d",
21135 + p, token, option);
21138 +#ifdef CONFIG_PROPAGATE
21143 + __dx_parse_remove(s, "tag");
21144 + *mnt_flags |= MNT_TAGID;
21145 + set |= MNT_TAGID;
21149 + __dx_parse_remove(s, "notag");
21150 + *mnt_flags |= MNT_NOTAG;
21151 + set |= MNT_NOTAG;
21154 + if (tag && !match_int(args, &option))
21157 + __dx_parse_remove(s, "tagid");
21158 + *mnt_flags |= MNT_TAGID;
21159 + set |= MNT_TAGID;
21162 + case Opt_notagcheck:
21164 + __dx_parse_remove(s, "notagcheck");
21165 + *flags |= MS_NOTAGCHECK;
21166 + set |= MS_NOTAGCHECK;
21171 + strcpy(string, s);
21176 +#ifdef CONFIG_PROPAGATE
21178 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21180 + tag_t new_tag = 0;
21181 + struct vfsmount *mnt;
21186 + mnt = nd->path.mnt;
21190 + propagate = (mnt->mnt_flags & MNT_TAGID);
21192 + new_tag = mnt->mnt_tag;
21194 + vxdprintk(VXD_CBIT(tag, 7),
21195 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21196 + inode, inode->i_ino, inode->i_tag,
21197 + new_tag, (propagate) ? 1 : 0);
21200 + inode->i_tag = new_tag;
21203 +#include <linux/module.h>
21205 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21207 +#endif /* CONFIG_PROPAGATE */
21209 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/Kconfig linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/Kconfig
21210 --- linux-2.6.27.25/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21211 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/Kconfig 2008-10-13 14:54:20.000000000 +0200
21214 +# Linux VServer configuration
21217 +menu "Linux VServer"
21219 +config VSERVER_AUTO_LBACK
21220 + bool "Automatically Assign Loopback IP"
21223 + Automatically assign a guest specific loopback
21224 + IP and add it to the kernel network stack on
21227 +config VSERVER_AUTO_SINGLE
21228 + bool "Automatic Single IP Special Casing"
21229 + depends on EXPERIMENTAL
21232 + This allows network contexts with a single IP to
21233 + automatically remap 0.0.0.0 bindings to that IP,
21234 + avoiding further network checks and improving
21237 + (note: such guests do not allow to change the ip
21238 + on the fly and do not show loopback addresses)
21240 +config VSERVER_COWBL
21241 + bool "Enable COW Immutable Link Breaking"
21244 + This enables the COW (Copy-On-Write) link break code.
21245 + It allows you to treat unified files like normal files
21246 + when writing to them (which will implicitely break the
21247 + link and create a copy of the unified file)
21249 +config VSERVER_VTIME
21250 + bool "Enable Virtualized Guest Time"
21251 + depends on EXPERIMENTAL
21254 + This enables per guest time offsets to allow for
21255 + adjusting the system clock individually per guest.
21256 + this adds some overhead to the time functions and
21257 + therefore should not be enabled without good reason.
21259 +config VSERVER_DEVICE
21260 + bool "Enable Guest Device Mapping"
21261 + depends on EXPERIMENTAL
21264 + This enables generic device remapping.
21266 +config VSERVER_PROC_SECURE
21267 + bool "Enable Proc Security"
21268 + depends on PROC_FS
21271 + This configures ProcFS security to initially hide
21272 + non-process entries for all contexts except the main and
21273 + spectator context (i.e. for all guests), which is a secure
21276 + (note: on 1.2x the entries were visible by default)
21278 +config VSERVER_HARDCPU
21279 + bool "Enable Hard CPU Limits"
21282 + Activate the Hard CPU Limits
21284 + This will compile in code that allows the Token Bucket
21285 + Scheduler to put processes on hold when a context's
21286 + tokens are depleted (provided that its per-context
21287 + sched_hard flag is set).
21289 + Processes belonging to that context will not be able
21290 + to consume CPU resources again until a per-context
21291 + configured minimum of tokens has been reached.
21293 +config VSERVER_IDLETIME
21294 + bool "Avoid idle CPUs by skipping Time"
21295 + depends on VSERVER_HARDCPU
21298 + This option allows the scheduler to artificially
21299 + advance time (per cpu) when otherwise the idle
21300 + task would be scheduled, thus keeping the cpu
21301 + busy and sharing the available resources among
21302 + certain contexts.
21304 +config VSERVER_IDLELIMIT
21305 + bool "Limit the IDLE task"
21306 + depends on VSERVER_HARDCPU
21309 + Limit the idle slices, so the the next context
21310 + will be scheduled as soon as possible.
21312 + This might improve interactivity and latency, but
21313 + will also marginally increase scheduling overhead.
21316 + prompt "Persistent Inode Tagging"
21317 + default TAGGING_ID24
21319 + This adds persistent context information to filesystems
21320 + mounted with the tagxid option. Tagging is a requirement
21321 + for per-context disk limits and per-context quota.
21324 +config TAGGING_NONE
21327 + do not store per-context information in inodes.
21329 +config TAGGING_UID16
21330 + bool "UID16/GID32"
21332 + reduces UID to 16 bit, but leaves GID at 32 bit.
21334 +config TAGGING_GID16
21335 + bool "UID32/GID16"
21337 + reduces GID to 16 bit, but leaves UID at 32 bit.
21339 +config TAGGING_ID24
21340 + bool "UID24/GID24"
21342 + uses the upper 8bit from UID and GID for XID tagging
21343 + which leaves 24bit for UID/GID each, which should be
21344 + more than sufficient for normal use.
21346 +config TAGGING_INTERN
21347 + bool "UID32/GID32"
21349 + this uses otherwise reserved inode fields in the on
21350 + disk representation, which limits the use to a few
21351 + filesystems (currently ext2 and ext3)
21356 + bool "Tag NFSD User Auth and Files"
21359 + Enable this if you do want the in-kernel NFS
21360 + Server to use the tagging specified above.
21361 + (will require patched clients too)
21363 +config VSERVER_PRIVACY
21364 + bool "Honor Privacy Aspects of Guests"
21367 + When enabled, most context checks will disallow
21368 + access to structures assigned to a specific context,
21369 + like ptys or loop devices.
21371 +config VSERVER_CONTEXTS
21372 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
21374 + default "768" if 64BIT
21377 + This setting will optimize certain data structures
21378 + and memory allocations according to the expected
21381 + note: this is not a strict upper limit.
21383 +config VSERVER_WARN
21384 + bool "VServer Warnings"
21387 + This enables various runtime warnings, which will
21388 + notify about potential manipulation attempts or
21389 + resource shortage. It is generally considered to
21390 + be a good idea to have that enabled.
21392 +config VSERVER_DEBUG
21393 + bool "VServer Debugging Code"
21396 + Set this to yes if you want to be able to activate
21397 + debugging output at runtime. It adds a very small
21398 + overhead to all vserver related functions and
21399 + increases the kernel size by about 20k.
21401 +config VSERVER_HISTORY
21402 + bool "VServer History Tracing"
21403 + depends on VSERVER_DEBUG
21406 + Set this to yes if you want to record the history of
21407 + linux-vserver activities, so they can be replayed in
21408 + the event of a kernel panic or oops.
21410 +config VSERVER_HISTORY_SIZE
21411 + int "Per-CPU History Size (32-65536)"
21412 + depends on VSERVER_HISTORY
21416 + This allows you to specify the number of entries in
21417 + the per-CPU history buffer.
21419 +config VSERVER_MONITOR
21420 + bool "VServer Scheduling Monitor"
21421 + depends on VSERVER_DISABLED
21424 + Set this to yes if you want to record the scheduling
21425 + decisions, so that they can be relayed to userspace
21426 + for detailed analysis.
21428 +config VSERVER_MONITOR_SIZE
21429 + int "Per-CPU Monitor Queue Size (32-65536)"
21430 + depends on VSERVER_MONITOR
21434 + This allows you to specify the number of entries in
21435 + the per-CPU scheduling monitor buffer.
21437 +config VSERVER_MONITOR_SYNC
21438 + int "Per-CPU Monitor Sync Interval (0-65536)"
21439 + depends on VSERVER_MONITOR
21443 + This allows you to specify the interval in ticks
21444 + when a time sync entry is inserted.
21452 + select NAMESPACES
21458 +config VSERVER_SECURITY
21460 + depends on SECURITY
21462 + select SECURITY_CAPABILITIES
21464 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/limit.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/limit.c
21465 --- linux-2.6.27.25/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21466 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/limit.c 2008-10-13 14:54:20.000000000 +0200
21469 + * linux/kernel/vserver/limit.c
21471 + * Virtual Server: Context Limits
21473 + * Copyright (C) 2004-2007 Herbert Pötzl
21475 + * V0.01 broken out from vcontext V0.05
21476 + * V0.02 changed vcmds to vxi arg
21480 +#include <linux/sched.h>
21481 +#include <linux/module.h>
21482 +#include <linux/vs_limit.h>
21483 +#include <linux/vserver/limit.h>
21484 +#include <linux/vserver/limit_cmd.h>
21486 +#include <asm/uaccess.h>
21489 +const char *vlimit_name[NUM_LIMITS] = {
21490 + [RLIMIT_CPU] = "CPU",
21491 + [RLIMIT_RSS] = "RSS",
21492 + [RLIMIT_NPROC] = "NPROC",
21493 + [RLIMIT_NOFILE] = "NOFILE",
21494 + [RLIMIT_MEMLOCK] = "VML",
21495 + [RLIMIT_AS] = "VM",
21496 + [RLIMIT_LOCKS] = "LOCKS",
21497 + [RLIMIT_SIGPENDING] = "SIGP",
21498 + [RLIMIT_MSGQUEUE] = "MSGQ",
21500 + [VLIMIT_NSOCK] = "NSOCK",
21501 + [VLIMIT_OPENFD] = "OPENFD",
21502 + [VLIMIT_ANON] = "ANON",
21503 + [VLIMIT_SHMEM] = "SHMEM",
21504 + [VLIMIT_DENTRY] = "DENTRY",
21507 +EXPORT_SYMBOL_GPL(vlimit_name);
21509 +#define MASK_ENTRY(x) (1 << (x))
21511 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21514 + , /* softlimit */
21515 + MASK_ENTRY( RLIMIT_RSS ) |
21516 + MASK_ENTRY( VLIMIT_ANON ) |
21519 + MASK_ENTRY( RLIMIT_RSS ) |
21520 + MASK_ENTRY( RLIMIT_NPROC ) |
21521 + MASK_ENTRY( RLIMIT_NOFILE ) |
21522 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21523 + MASK_ENTRY( RLIMIT_AS ) |
21524 + MASK_ENTRY( RLIMIT_LOCKS ) |
21525 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21527 + MASK_ENTRY( VLIMIT_NSOCK ) |
21528 + MASK_ENTRY( VLIMIT_OPENFD ) |
21529 + MASK_ENTRY( VLIMIT_ANON ) |
21530 + MASK_ENTRY( VLIMIT_SHMEM ) |
21531 + MASK_ENTRY( VLIMIT_DENTRY ) |
21534 + /* accounting only */
21535 +uint32_t account_mask =
21536 + MASK_ENTRY( VLIMIT_SEMARY ) |
21537 + MASK_ENTRY( VLIMIT_NSEMS ) |
21538 + MASK_ENTRY( VLIMIT_MAPPED ) |
21542 +static int is_valid_vlimit(int id)
21544 + uint32_t mask = vlimit_mask.minimum |
21545 + vlimit_mask.softlimit | vlimit_mask.maximum;
21546 + return mask & (1 << id);
21549 +static int is_accounted_vlimit(int id)
21551 + if (is_valid_vlimit(id))
21553 + return account_mask & (1 << id);
21557 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21559 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21560 + return VX_VLIM(limit);
21563 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21565 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21566 + return VX_VLIM(limit);
21569 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21570 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21572 + if (!is_valid_vlimit(id))
21576 + *minimum = CRLIM_UNSET;
21578 + *softlimit = vc_get_soft(vxi, id);
21580 + *maximum = vc_get_hard(vxi, id);
21584 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21586 + struct vcmd_ctx_rlimit_v0 vc_data;
21589 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21592 + ret = do_get_rlimit(vxi, vc_data.id,
21593 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21597 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21602 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21603 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21605 + if (!is_valid_vlimit(id))
21608 + if (maximum != CRLIM_KEEP)
21609 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21610 + if (softlimit != CRLIM_KEEP)
21611 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21613 + /* clamp soft limit */
21614 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21615 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21620 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21622 + struct vcmd_ctx_rlimit_v0 vc_data;
21624 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21627 + return do_set_rlimit(vxi, vc_data.id,
21628 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21631 +#ifdef CONFIG_IA32_EMULATION
21633 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21635 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21637 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21640 + return do_set_rlimit(vxi, vc_data.id,
21641 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21644 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21646 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21649 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21652 + ret = do_get_rlimit(vxi, vc_data.id,
21653 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21657 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21662 +#endif /* CONFIG_IA32_EMULATION */
21665 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21667 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21673 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21678 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21679 + value = __rlim_get(limit, lim);
21680 + __rlim_rmax(limit, lim) = value;
21681 + __rlim_rmin(limit, lim) = value;
21686 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21688 + vx_reset_minmax(&vxi->limit);
21693 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21695 + struct vcmd_rlimit_stat_v0 vc_data;
21696 + struct _vx_limit *limit = &vxi->limit;
21699 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21703 + if (!is_accounted_vlimit(id))
21706 + vx_limit_fixup(limit, id);
21707 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21708 + vc_data.value = __rlim_get(limit, id);
21709 + vc_data.minimum = __rlim_rmin(limit, id);
21710 + vc_data.maximum = __rlim_rmax(limit, id);
21712 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21718 +void vx_vsi_meminfo(struct sysinfo *val)
21720 + struct vx_info *vxi = current->vx_info;
21721 + unsigned long totalram, freeram;
21724 + /* we blindly accept the max */
21725 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21726 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21728 + /* total minus used equals free */
21729 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21730 + freeram = (v < totalram) ? totalram - v : 0;
21732 + val->totalram = totalram;
21733 + val->freeram = freeram;
21734 + val->bufferram = 0;
21735 + val->totalhigh = 0;
21736 + val->freehigh = 0;
21740 +void vx_vsi_swapinfo(struct sysinfo *val)
21742 + struct vx_info *vxi = current->vx_info;
21743 + unsigned long totalswap, freeswap;
21746 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21747 + if (v == RLIM_INFINITY) {
21748 + val->freeswap = val->totalswap;
21752 + /* we blindly accept the max */
21753 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21754 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
21756 + /* currently 'used' swap */
21757 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21758 + w -= (w > v) ? v : w;
21760 + /* total minus used equals free */
21761 + freeswap = (w < totalswap) ? totalswap - w : 0;
21763 + val->totalswap = totalswap;
21764 + val->freeswap = freeswap;
21769 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21771 + struct vx_info *vxi = mm->mm_vx_info;
21772 + unsigned long points;
21778 + points = vxi->vx_badness_bias;
21780 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21781 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21782 + points += (v > w) ? (v - w) : 0;
21787 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/limit_init.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/limit_init.h
21788 --- linux-2.6.27.25/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
21789 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/limit_init.h 2008-10-13 14:54:20.000000000 +0200
21793 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21797 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21798 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21799 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21800 + __rlim_set(limit, lim, 0);
21801 + atomic_set(&__rlim_lhit(limit, lim), 0);
21802 + __rlim_rmin(limit, lim) = 0;
21803 + __rlim_rmax(limit, lim) = 0;
21807 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21812 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21813 + if ((1 << lim) & VLIM_NOCHECK)
21815 + value = __rlim_get(limit, lim);
21816 + vxwprintk_xid(value,
21817 + "!!! limit: %p[%s,%d] = %ld on exit.",
21818 + limit, vlimit_name[lim], lim, (long)value);
21822 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/limit_proc.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/limit_proc.h
21823 --- linux-2.6.27.25/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
21824 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/limit_proc.h 2008-10-13 14:54:20.000000000 +0200
21826 +#ifndef _VX_LIMIT_PROC_H
21827 +#define _VX_LIMIT_PROC_H
21829 +#include <linux/vserver/limit_int.h>
21832 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21833 +#define VX_LIMIT_TOP \
21834 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21836 +#define VX_LIMIT_ARG(r) \
21837 + (unsigned long)__rlim_get(limit, r), \
21838 + (unsigned long)__rlim_rmin(limit, r), \
21839 + (unsigned long)__rlim_rmax(limit, r), \
21840 + VX_VLIM(__rlim_soft(limit, r)), \
21841 + VX_VLIM(__rlim_hard(limit, r)), \
21842 + atomic_read(&__rlim_lhit(limit, r))
21844 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21846 + vx_limit_fixup(limit, -1);
21847 + return sprintf(buffer, VX_LIMIT_TOP
21848 + "PROC" VX_LIMIT_FMT
21849 + "VM" VX_LIMIT_FMT
21850 + "VML" VX_LIMIT_FMT
21851 + "RSS" VX_LIMIT_FMT
21852 + "ANON" VX_LIMIT_FMT
21853 + "RMAP" VX_LIMIT_FMT
21854 + "FILES" VX_LIMIT_FMT
21855 + "OFD" VX_LIMIT_FMT
21856 + "LOCKS" VX_LIMIT_FMT
21857 + "SOCK" VX_LIMIT_FMT
21858 + "MSGQ" VX_LIMIT_FMT
21859 + "SHM" VX_LIMIT_FMT
21860 + "SEMA" VX_LIMIT_FMT
21861 + "SEMS" VX_LIMIT_FMT
21862 + "DENT" VX_LIMIT_FMT,
21863 + VX_LIMIT_ARG(RLIMIT_NPROC),
21864 + VX_LIMIT_ARG(RLIMIT_AS),
21865 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21866 + VX_LIMIT_ARG(RLIMIT_RSS),
21867 + VX_LIMIT_ARG(VLIMIT_ANON),
21868 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21869 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21870 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21871 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21872 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21873 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21874 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21875 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21876 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21877 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21880 +#endif /* _VX_LIMIT_PROC_H */
21883 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/Makefile linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/Makefile
21884 --- linux-2.6.27.25/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21885 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/Makefile 2008-10-13 14:54:20.000000000 +0200
21888 +# Makefile for the Linux vserver routines.
21892 +obj-y += vserver.o
21894 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21895 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21898 +vserver-$(CONFIG_INET) += inet.o
21899 +vserver-$(CONFIG_PROC_FS) += proc.o
21900 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21901 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21902 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21903 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21905 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/monitor.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/monitor.c
21906 --- linux-2.6.27.25/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21907 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/monitor.c 2008-10-13 14:54:20.000000000 +0200
21910 + * kernel/vserver/monitor.c
21912 + * Virtual Context Scheduler Monitor
21914 + * Copyright (C) 2006-2007 Herbert Pötzl
21916 + * V0.01 basic design
21920 +#include <linux/module.h>
21921 +#include <linux/jiffies.h>
21922 +#include <asm/uaccess.h>
21923 +#include <asm/atomic.h>
21925 +#include <linux/vserver/monitor.h>
21926 +#include <linux/vserver/debug_cmd.h>
21929 +#ifdef CONFIG_VSERVER_MONITOR
21930 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21932 +#define VXM_SIZE 64
21935 +struct _vx_monitor {
21936 + unsigned int counter;
21938 + struct _vx_mon_entry entry[VXM_SIZE+1];
21942 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21944 +unsigned volatile int vxm_active = 1;
21946 +static atomic_t sequence = ATOMIC_INIT(0);
21951 + * requires disabled preemption */
21953 +struct _vx_mon_entry *vxm_advance(int cpu)
21955 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21956 + struct _vx_mon_entry *entry;
21957 + unsigned int index;
21959 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21960 + entry = &mon->entry[index];
21962 + entry->ev.seq = atomic_inc_return(&sequence);
21963 + entry->ev.jif = jiffies;
21967 +EXPORT_SYMBOL_GPL(vxm_advance);
21970 +int do_read_monitor(struct __user _vx_mon_entry *data,
21971 + int cpu, uint32_t *index, uint32_t *count)
21973 + int pos, ret = 0;
21974 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21975 + int end = mon->counter;
21976 + int start = end - VXM_SIZE + 2;
21977 + int idx = *index;
21979 + /* special case: get current pos */
21985 + /* have we lost some data? */
21989 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21990 + struct _vx_mon_entry *entry =
21991 + &mon->entry[idx % VXM_SIZE];
21993 + /* send entry to userspace */
21994 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21998 + /* save new index and count */
22001 + return ret ? ret : (*index < end);
22004 +int vc_read_monitor(uint32_t id, void __user *data)
22006 + struct vcmd_read_monitor_v0 vc_data;
22009 + if (id >= NR_CPUS)
22012 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22015 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22016 + id, &vc_data.index, &vc_data.count);
22018 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22023 +#ifdef CONFIG_COMPAT
22025 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22027 + struct vcmd_read_monitor_v0_x32 vc_data;
22030 + if (id >= NR_CPUS)
22033 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22036 + ret = do_read_monitor((struct __user _vx_mon_entry *)
22037 + compat_ptr(vc_data.data_ptr),
22038 + id, &vc_data.index, &vc_data.count);
22040 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22045 +#endif /* CONFIG_COMPAT */
22047 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/network.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/network.c
22048 --- linux-2.6.27.25/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22049 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/network.c 2008-10-13 14:54:20.000000000 +0200
22052 + * linux/kernel/vserver/network.c
22054 + * Virtual Server: Network Support
22056 + * Copyright (C) 2003-2007 Herbert Pötzl
22058 + * V0.01 broken out from vcontext V0.05
22059 + * V0.02 cleaned up implementation
22060 + * V0.03 added equiv nx commands
22061 + * V0.04 switch to RCU based hash
22062 + * V0.05 and back to locking again
22063 + * V0.06 changed vcmds to nxi arg
22064 + * V0.07 have __create claim() the nxi
22068 +#include <linux/err.h>
22069 +#include <linux/slab.h>
22070 +#include <linux/rcupdate.h>
22072 +#include <linux/vs_network.h>
22073 +#include <linux/vs_pid.h>
22074 +#include <linux/vserver/network_cmd.h>
22077 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22078 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22080 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22081 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22084 +static int __init init_network(void)
22086 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22087 + sizeof(struct nx_addr_v4), 0,
22088 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22089 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22090 + sizeof(struct nx_addr_v6), 0,
22091 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22096 +/* __alloc_nx_addr_v4() */
22098 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22100 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22101 + nx_addr_v4_cachep, GFP_KERNEL);
22103 + if (!IS_ERR(nxa))
22104 + memset(nxa, 0, sizeof(*nxa));
22108 +/* __dealloc_nx_addr_v4() */
22110 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22112 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22115 +/* __dealloc_nx_addr_v4_all() */
22117 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22120 + struct nx_addr_v4 *next = nxa->next;
22122 + __dealloc_nx_addr_v4(nxa);
22128 +#ifdef CONFIG_IPV6
22130 +/* __alloc_nx_addr_v6() */
22132 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22134 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22135 + nx_addr_v6_cachep, GFP_KERNEL);
22137 + if (!IS_ERR(nxa))
22138 + memset(nxa, 0, sizeof(*nxa));
22142 +/* __dealloc_nx_addr_v6() */
22144 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22146 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22149 +/* __dealloc_nx_addr_v6_all() */
22151 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22154 + struct nx_addr_v6 *next = nxa->next;
22156 + __dealloc_nx_addr_v6(nxa);
22161 +#endif /* CONFIG_IPV6 */
22163 +/* __alloc_nx_info()
22165 + * allocate an initialized nx_info struct
22166 + * doesn't make it visible (hash) */
22168 +static struct nx_info *__alloc_nx_info(nid_t nid)
22170 + struct nx_info *new = NULL;
22172 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22174 + /* would this benefit from a slab cache? */
22175 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22179 + memset(new, 0, sizeof(struct nx_info));
22180 + new->nx_id = nid;
22181 + INIT_HLIST_NODE(&new->nx_hlist);
22182 + atomic_set(&new->nx_usecnt, 0);
22183 + atomic_set(&new->nx_tasks, 0);
22184 + new->nx_state = 0;
22186 + new->nx_flags = NXF_INIT_SET;
22188 + /* rest of init goes here */
22190 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22191 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22193 + vxdprintk(VXD_CBIT(nid, 0),
22194 + "alloc_nx_info(%d) = %p", nid, new);
22195 + atomic_inc(&nx_global_ctotal);
22199 +/* __dealloc_nx_info()
22201 + * final disposal of nx_info */
22203 +static void __dealloc_nx_info(struct nx_info *nxi)
22205 + vxdprintk(VXD_CBIT(nid, 0),
22206 + "dealloc_nx_info(%p)", nxi);
22208 + nxi->nx_hlist.next = LIST_POISON1;
22211 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22212 + BUG_ON(atomic_read(&nxi->nx_tasks));
22214 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22216 + nxi->nx_state |= NXS_RELEASED;
22218 + atomic_dec(&nx_global_ctotal);
22221 +static void __shutdown_nx_info(struct nx_info *nxi)
22223 + nxi->nx_state |= NXS_SHUTDOWN;
22224 + vs_net_change(nxi, VSC_NETDOWN);
22227 +/* exported stuff */
22229 +void free_nx_info(struct nx_info *nxi)
22231 + /* context shutdown is mandatory */
22232 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22234 + /* context must not be hashed */
22235 + BUG_ON(nxi->nx_state & NXS_HASHED);
22237 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22238 + BUG_ON(atomic_read(&nxi->nx_tasks));
22240 + __dealloc_nx_info(nxi);
22244 +void __nx_set_lback(struct nx_info *nxi)
22246 + int nid = nxi->nx_id;
22247 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22249 + nxi->v4_lback.s_addr = lback;
22252 +extern int __nx_inet_add_lback(__be32 addr);
22253 +extern int __nx_inet_del_lback(__be32 addr);
22256 +/* hash table for nx_info hash */
22258 +#define NX_HASH_SIZE 13
22260 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22262 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22265 +static inline unsigned int __hashval(nid_t nid)
22267 + return (nid % NX_HASH_SIZE);
22272 +/* __hash_nx_info()
22274 + * add the nxi to the global hash table
22275 + * requires the hash_lock to be held */
22277 +static inline void __hash_nx_info(struct nx_info *nxi)
22279 + struct hlist_head *head;
22281 + vxd_assert_lock(&nx_info_hash_lock);
22282 + vxdprintk(VXD_CBIT(nid, 4),
22283 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22285 + /* context must not be hashed */
22286 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22288 + nxi->nx_state |= NXS_HASHED;
22289 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22290 + hlist_add_head(&nxi->nx_hlist, head);
22291 + atomic_inc(&nx_global_cactive);
22294 +/* __unhash_nx_info()
22296 + * remove the nxi from the global hash table
22297 + * requires the hash_lock to be held */
22299 +static inline void __unhash_nx_info(struct nx_info *nxi)
22301 + vxd_assert_lock(&nx_info_hash_lock);
22302 + vxdprintk(VXD_CBIT(nid, 4),
22303 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22304 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22306 + /* context must be hashed */
22307 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22308 + /* but without tasks */
22309 + BUG_ON(atomic_read(&nxi->nx_tasks));
22311 + nxi->nx_state &= ~NXS_HASHED;
22312 + hlist_del(&nxi->nx_hlist);
22313 + atomic_dec(&nx_global_cactive);
22317 +/* __lookup_nx_info()
22319 + * requires the hash_lock to be held
22320 + * doesn't increment the nx_refcnt */
22322 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22324 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22325 + struct hlist_node *pos;
22326 + struct nx_info *nxi;
22328 + vxd_assert_lock(&nx_info_hash_lock);
22329 + hlist_for_each(pos, head) {
22330 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22332 + if (nxi->nx_id == nid)
22337 + vxdprintk(VXD_CBIT(nid, 0),
22338 + "__lookup_nx_info(#%u): %p[#%u]",
22339 + nid, nxi, nxi ? nxi->nx_id : 0);
22344 +/* __create_nx_info()
22346 + * create the requested context
22347 + * get(), claim() and hash it */
22349 +static struct nx_info *__create_nx_info(int id)
22351 + struct nx_info *new, *nxi = NULL;
22353 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22355 + if (!(new = __alloc_nx_info(id)))
22356 + return ERR_PTR(-ENOMEM);
22358 + /* required to make dynamic xids unique */
22359 + spin_lock(&nx_info_hash_lock);
22361 + /* static context requested */
22362 + if ((nxi = __lookup_nx_info(id))) {
22363 + vxdprintk(VXD_CBIT(nid, 0),
22364 + "create_nx_info(%d) = %p (already there)", id, nxi);
22365 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22366 + nxi = ERR_PTR(-EBUSY);
22368 + nxi = ERR_PTR(-EEXIST);
22371 + /* new context */
22372 + vxdprintk(VXD_CBIT(nid, 0),
22373 + "create_nx_info(%d) = %p (new)", id, new);
22374 + claim_nx_info(new, NULL);
22375 + __nx_set_lback(new);
22376 + __hash_nx_info(get_nx_info(new));
22377 + nxi = new, new = NULL;
22380 + spin_unlock(&nx_info_hash_lock);
22382 + __dealloc_nx_info(new);
22388 +/* exported stuff */
22391 +void unhash_nx_info(struct nx_info *nxi)
22393 + __shutdown_nx_info(nxi);
22394 + spin_lock(&nx_info_hash_lock);
22395 + __unhash_nx_info(nxi);
22396 + spin_unlock(&nx_info_hash_lock);
22399 +/* lookup_nx_info()
22401 + * search for a nx_info and get() it
22402 + * negative id means current */
22404 +struct nx_info *lookup_nx_info(int id)
22406 + struct nx_info *nxi = NULL;
22409 + nxi = get_nx_info(current->nx_info);
22410 + } else if (id > 1) {
22411 + spin_lock(&nx_info_hash_lock);
22412 + nxi = get_nx_info(__lookup_nx_info(id));
22413 + spin_unlock(&nx_info_hash_lock);
22418 +/* nid_is_hashed()
22420 + * verify that nid is still hashed */
22422 +int nid_is_hashed(nid_t nid)
22426 + spin_lock(&nx_info_hash_lock);
22427 + hashed = (__lookup_nx_info(nid) != NULL);
22428 + spin_unlock(&nx_info_hash_lock);
22433 +#ifdef CONFIG_PROC_FS
22437 + * get a subset of hashed nids for proc
22438 + * assumes size is at least one */
22440 +int get_nid_list(int index, unsigned int *nids, int size)
22442 + int hindex, nr_nids = 0;
22444 + /* only show current and children */
22445 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22448 + nids[nr_nids] = nx_current_nid();
22452 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22453 + struct hlist_head *head = &nx_info_hash[hindex];
22454 + struct hlist_node *pos;
22456 + spin_lock(&nx_info_hash_lock);
22457 + hlist_for_each(pos, head) {
22458 + struct nx_info *nxi;
22463 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22464 + nids[nr_nids] = nxi->nx_id;
22465 + if (++nr_nids >= size) {
22466 + spin_unlock(&nx_info_hash_lock);
22470 + /* keep the lock time short */
22471 + spin_unlock(&nx_info_hash_lock);
22480 + * migrate task to new network
22481 + * gets nxi, puts old_nxi on change
22484 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22486 + struct nx_info *old_nxi;
22492 + vxdprintk(VXD_CBIT(nid, 5),
22493 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22494 + p, nxi, nxi->nx_id,
22495 + atomic_read(&nxi->nx_usecnt),
22496 + atomic_read(&nxi->nx_tasks));
22498 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22499 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22502 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22505 + /* maybe disallow this completely? */
22506 + old_nxi = task_get_nx_info(p);
22507 + if (old_nxi == nxi)
22512 + clr_nx_info(&p->nx_info);
22513 + claim_nx_info(nxi, p);
22514 + set_nx_info(&p->nx_info, nxi);
22515 + p->nid = nxi->nx_id;
22518 + vxdprintk(VXD_CBIT(nid, 5),
22519 + "moved task %p into nxi:%p[#%d]",
22520 + p, nxi, nxi->nx_id);
22523 + release_nx_info(old_nxi, p);
22526 + put_nx_info(old_nxi);
22531 +void nx_set_persistent(struct nx_info *nxi)
22533 + vxdprintk(VXD_CBIT(nid, 6),
22534 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22536 + get_nx_info(nxi);
22537 + claim_nx_info(nxi, NULL);
22540 +void nx_clear_persistent(struct nx_info *nxi)
22542 + vxdprintk(VXD_CBIT(nid, 6),
22543 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22545 + release_nx_info(nxi, NULL);
22546 + put_nx_info(nxi);
22549 +void nx_update_persistent(struct nx_info *nxi)
22551 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22552 + nx_set_persistent(nxi);
22554 + nx_clear_persistent(nxi);
22557 +/* vserver syscall commands below here */
22559 +/* taks nid and nx_info functions */
22561 +#include <asm/uaccess.h>
22564 +int vc_task_nid(uint32_t id)
22569 + struct task_struct *tsk;
22571 + read_lock(&tasklist_lock);
22572 + tsk = find_task_by_real_pid(id);
22573 + nid = (tsk) ? tsk->nid : -ESRCH;
22574 + read_unlock(&tasklist_lock);
22576 + nid = nx_current_nid();
22581 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22583 + struct vcmd_nx_info_v0 vc_data;
22585 + vc_data.nid = nxi->nx_id;
22587 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22593 +/* network functions */
22595 +int vc_net_create(uint32_t nid, void __user *data)
22597 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22598 + struct nx_info *new_nxi;
22601 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22604 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22607 + new_nxi = __create_nx_info(nid);
22608 + if (IS_ERR(new_nxi))
22609 + return PTR_ERR(new_nxi);
22611 + /* initial flags */
22612 + new_nxi->nx_flags = vc_data.flagword;
22615 + if (vs_net_change(new_nxi, VSC_NETUP))
22618 + ret = nx_migrate_task(current, new_nxi);
22622 + /* return context id on success */
22623 + ret = new_nxi->nx_id;
22625 + /* get a reference for persistent contexts */
22626 + if ((vc_data.flagword & NXF_PERSISTENT))
22627 + nx_set_persistent(new_nxi);
22629 + release_nx_info(new_nxi, NULL);
22630 + put_nx_info(new_nxi);
22635 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22637 + return nx_migrate_task(current, nxi);
22642 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22643 + uint16_t type, uint16_t flags)
22645 + struct nx_addr_v4 *nxa = &nxi->v4;
22647 + if (NX_IPV4(nxi)) {
22648 + /* locate last entry */
22649 + for (; nxa->next; nxa = nxa->next);
22650 + nxa->next = __alloc_nx_addr_v4();
22654 + return PTR_ERR(nxa);
22657 + if (nxi->v4.next)
22658 + /* remove single ip for ip list */
22659 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22661 + nxa->ip[0].s_addr = ip;
22662 + nxa->ip[1].s_addr = ip2;
22663 + nxa->mask.s_addr = mask;
22664 + nxa->type = type;
22665 + nxa->flags = flags;
22670 +int vc_net_add(struct nx_info *nxi, void __user *data)
22672 + struct vcmd_net_addr_v0 vc_data;
22673 + int index, ret = 0;
22675 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22678 + switch (vc_data.type) {
22679 + case NXA_TYPE_IPV4:
22680 + if ((vc_data.count < 1) || (vc_data.count > 4))
22684 + while (index < vc_data.count) {
22685 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22686 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22694 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22695 + nxi->v4_bcast = vc_data.ip[0];
22699 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22700 + nxi->v4_lback = vc_data.ip[0];
22711 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22713 + struct vcmd_net_addr_v0 vc_data;
22715 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22718 + switch (vc_data.type) {
22719 + case NXA_TYPE_ANY:
22720 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22721 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22731 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22733 + struct vcmd_net_addr_ipv4_v1 vc_data;
22735 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22738 + switch (vc_data.type) {
22739 + case NXA_TYPE_ADDR:
22740 + case NXA_TYPE_RANGE:
22741 + case NXA_TYPE_MASK:
22742 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22743 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22745 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22746 + nxi->v4_bcast = vc_data.ip;
22749 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22750 + nxi->v4_lback = vc_data.ip;
22759 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
22761 + struct vcmd_net_addr_ipv4_v1 vc_data;
22763 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22766 + switch (vc_data.type) {
22767 +/* case NXA_TYPE_ADDR:
22770 + case NXA_TYPE_ANY:
22771 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22772 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22782 +#ifdef CONFIG_IPV6
22784 +int do_add_v6_addr(struct nx_info *nxi,
22785 + struct in6_addr *ip, struct in6_addr *mask,
22786 + uint32_t prefix, uint16_t type, uint16_t flags)
22788 + struct nx_addr_v6 *nxa = &nxi->v6;
22790 + if (NX_IPV6(nxi)) {
22791 + /* locate last entry */
22792 + for (; nxa->next; nxa = nxa->next);
22793 + nxa->next = __alloc_nx_addr_v6();
22797 + return PTR_ERR(nxa);
22801 + nxa->mask = *mask;
22802 + nxa->prefix = prefix;
22803 + nxa->type = type;
22804 + nxa->flags = flags;
22809 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
22811 + struct vcmd_net_addr_ipv6_v1 vc_data;
22813 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22816 + switch (vc_data.type) {
22817 + case NXA_TYPE_ADDR:
22818 + case NXA_TYPE_MASK:
22819 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
22820 + vc_data.prefix, vc_data.type, vc_data.flags);
22827 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
22829 + struct vcmd_net_addr_ipv6_v1 vc_data;
22831 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22834 + switch (vc_data.type) {
22835 + case NXA_TYPE_ANY:
22836 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
22837 + memset(&nxi->v6, 0, sizeof(nxi->v6));
22846 +#endif /* CONFIG_IPV6 */
22849 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22851 + struct vcmd_net_flags_v0 vc_data;
22853 + vc_data.flagword = nxi->nx_flags;
22855 + /* special STATE flag handling */
22856 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22858 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22863 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22865 + struct vcmd_net_flags_v0 vc_data;
22866 + uint64_t mask, trigger;
22868 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22871 + /* special STATE flag handling */
22872 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22873 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22875 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22876 + vc_data.flagword, mask);
22877 + if (trigger & NXF_PERSISTENT)
22878 + nx_update_persistent(nxi);
22883 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22885 + struct vcmd_net_caps_v0 vc_data;
22887 + vc_data.ncaps = nxi->nx_ncaps;
22888 + vc_data.cmask = ~0ULL;
22890 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22895 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22897 + struct vcmd_net_caps_v0 vc_data;
22899 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22902 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22903 + vc_data.ncaps, vc_data.cmask);
22908 +#include <linux/module.h>
22910 +module_init(init_network);
22912 +EXPORT_SYMBOL_GPL(free_nx_info);
22913 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22915 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/proc.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/proc.c
22916 --- linux-2.6.27.25/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22917 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/proc.c 2008-10-31 18:15:28.000000000 +0100
22920 + * linux/kernel/vserver/proc.c
22922 + * Virtual Context Support
22924 + * Copyright (C) 2003-2007 Herbert Pötzl
22926 + * V0.01 basic structure
22927 + * V0.02 adaptation vs1.3.0
22928 + * V0.03 proc permissions
22929 + * V0.04 locking/generic
22930 + * V0.05 next generation procfs
22931 + * V0.06 inode validation
22932 + * V0.07 generic rewrite vid
22933 + * V0.08 remove inode type
22937 +#include <linux/proc_fs.h>
22938 +#include <asm/unistd.h>
22940 +#include <linux/vs_context.h>
22941 +#include <linux/vs_network.h>
22942 +#include <linux/vs_cvirt.h>
22944 +#include <linux/in.h>
22945 +#include <linux/inetdevice.h>
22946 +#include <linux/vs_inet.h>
22947 +#include <linux/vs_inet6.h>
22949 +#include <linux/vserver/global.h>
22951 +#include "cvirt_proc.h"
22952 +#include "cacct_proc.h"
22953 +#include "limit_proc.h"
22954 +#include "sched_proc.h"
22955 +#include "vci_config.h"
22958 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22962 + CAP_FOR_EACH_U32(__capi) {
22963 + buffer += sprintf(buffer, "%08x",
22964 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22970 +static struct proc_dir_entry *proc_virtual;
22972 +static struct proc_dir_entry *proc_virtnet;
22975 +/* first the actual feeds */
22978 +static int proc_vci(char *buffer)
22980 + return sprintf(buffer,
22981 + "VCIVersion:\t%04x:%04x\n"
22982 + "VCISyscall:\t%d\n"
22983 + "VCIKernel:\t%08x\n",
22984 + VCI_VERSION >> 16,
22985 + VCI_VERSION & 0xFFFF,
22987 + vci_kernel_config());
22990 +static int proc_virtual_info(char *buffer)
22992 + return proc_vci(buffer);
22995 +static int proc_virtual_status(char *buffer)
22997 + return sprintf(buffer,
22999 + "#CActive:\t%d\n"
23000 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
23001 + atomic_read(&vx_global_ctotal),
23002 + atomic_read(&vx_global_cactive),
23003 + atomic_read(&vs_global_nsproxy),
23004 + atomic_read(&vs_global_fs),
23005 + atomic_read(&vs_global_mnt_ns),
23006 + atomic_read(&vs_global_uts_ns),
23007 + atomic_read(&vs_global_ipc_ns),
23008 + atomic_read(&vs_global_user_ns),
23009 + atomic_read(&vs_global_pid_ns));
23013 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23017 + length = sprintf(buffer,
23025 + vxi->vx_badness_bias);
23029 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23031 + char *orig = buffer;
23033 + buffer += sprintf(buffer,
23036 + "Flags:\t%016llx\n",
23037 + atomic_read(&vxi->vx_usecnt),
23038 + atomic_read(&vxi->vx_tasks),
23039 + (unsigned long long)vxi->vx_flags);
23041 + buffer += sprintf(buffer, "BCaps:\t");
23042 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23043 + buffer += sprintf(buffer, "\n");
23045 + buffer += sprintf(buffer,
23046 + "CCaps:\t%016llx\n"
23047 + "Spaces:\t%08lx %08lx\n",
23048 + (unsigned long long)vxi->vx_ccaps,
23049 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23050 + return buffer - orig;
23053 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23055 + return vx_info_proc_limit(&vxi->limit, buffer);
23058 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23062 + length = vx_info_proc_sched(&vxi->sched, buffer);
23063 + for_each_online_cpu(cpu) {
23064 + length += vx_info_proc_sched_pc(
23065 + &vx_per_cpu(vxi, sched_pc, cpu),
23066 + buffer + length, cpu);
23071 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23073 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23076 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23078 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23081 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23085 + vx_update_load(vxi);
23086 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23087 + for_each_online_cpu(cpu) {
23088 + length += vx_info_proc_cvirt_pc(
23089 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23090 + buffer + length, cpu);
23095 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23097 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23101 +static int proc_virtnet_info(char *buffer)
23103 + return proc_vci(buffer);
23106 +static int proc_virtnet_status(char *buffer)
23108 + return sprintf(buffer,
23110 + "#CActive:\t%d\n",
23111 + atomic_read(&nx_global_ctotal),
23112 + atomic_read(&nx_global_cactive));
23115 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23117 + struct nx_addr_v4 *v4a;
23118 +#ifdef CONFIG_IPV6
23119 + struct nx_addr_v6 *v6a;
23123 + length = sprintf(buffer,
23126 + "Bcast:\t" NIPQUAD_FMT "\n"
23127 + "Lback:\t" NIPQUAD_FMT "\n",
23130 + NIPQUAD(nxi->v4_bcast.s_addr),
23131 + NIPQUAD(nxi->v4_lback.s_addr));
23133 + if (!NX_IPV4(nxi))
23135 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23136 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23139 +#ifdef CONFIG_IPV6
23140 + if (!NX_IPV6(nxi))
23142 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23143 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23150 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23154 + length = sprintf(buffer,
23157 + "Flags:\t%016llx\n"
23158 + "NCaps:\t%016llx\n",
23159 + atomic_read(&nxi->nx_usecnt),
23160 + atomic_read(&nxi->nx_tasks),
23161 + (unsigned long long)nxi->nx_flags,
23162 + (unsigned long long)nxi->nx_ncaps);
23168 +/* here the inode helpers */
23174 + struct inode_operations *iop;
23175 + struct file_operations *fop;
23176 + union proc_op op;
23179 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23181 + struct inode *inode = new_inode(sb);
23186 + inode->i_mode = p->mode;
23188 + inode->i_op = p->iop;
23190 + inode->i_fop = p->fop;
23192 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23193 + inode->i_flags |= S_IMMUTABLE;
23195 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23197 + inode->i_uid = 0;
23198 + inode->i_gid = 0;
23199 + inode->i_tag = 0;
23204 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23205 + struct dentry *dentry, int id, void *ptr)
23207 + struct vs_entry *p = ptr;
23208 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23209 + struct dentry *error = ERR_PTR(-EINVAL);
23214 + PROC_I(inode)->op = p->op;
23215 + PROC_I(inode)->fd = id;
23216 + d_add(dentry, inode);
23224 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23227 + * Fill a directory entry.
23229 + * If possible create the dcache entry and derive our inode number and
23230 + * file type from dcache entry.
23232 + * Since all of the proc inode numbers are dynamically generated, the inode
23233 + * numbers do not exist until the inode is cache. This means creating the
23234 + * the dcache entry in readdir is necessary to keep the inode numbers
23235 + * reported by readdir in sync with the inode numbers reported
23238 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23239 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23241 + struct dentry *child, *dir = filp->f_dentry;
23242 + struct inode *inode;
23243 + struct qstr qname;
23245 + unsigned type = DT_UNKNOWN;
23247 + qname.name = name;
23249 + qname.hash = full_name_hash(name, len);
23251 + child = d_lookup(dir, &qname);
23253 + struct dentry *new;
23254 + new = d_alloc(dir, &qname);
23256 + child = instantiate(dir->d_inode, new, id, ptr);
23263 + if (!child || IS_ERR(child) || !child->d_inode)
23264 + goto end_instantiate;
23265 + inode = child->d_inode;
23267 + ino = inode->i_ino;
23268 + type = inode->i_mode >> 12;
23273 + ino = find_inode_number(dir, &qname);
23276 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23281 +/* get and revalidate vx_info/xid */
23284 +struct vx_info *get_proc_vx_info(struct inode *inode)
23286 + return lookup_vx_info(PROC_I(inode)->fd);
23289 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23291 + struct inode *inode = dentry->d_inode;
23292 + xid_t xid = PROC_I(inode)->fd;
23294 + if (!xid || xid_is_hashed(xid))
23301 +/* get and revalidate nx_info/nid */
23303 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23305 + struct inode *inode = dentry->d_inode;
23306 + nid_t nid = PROC_I(inode)->fd;
23308 + if (!nid || nid_is_hashed(nid))
23316 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23318 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23319 + size_t count, loff_t *ppos)
23321 + struct inode *inode = file->f_dentry->d_inode;
23322 + unsigned long page;
23323 + ssize_t length = 0;
23325 + if (count > PROC_BLOCK_SIZE)
23326 + count = PROC_BLOCK_SIZE;
23328 + /* fade that out as soon as stable */
23329 + WARN_ON(PROC_I(inode)->fd);
23331 + if (!(page = __get_free_page(GFP_KERNEL)))
23334 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23335 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23338 + length = simple_read_from_buffer(buf, count, ppos,
23339 + (char *)page, length);
23345 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23346 + size_t count, loff_t *ppos)
23348 + struct inode *inode = file->f_dentry->d_inode;
23349 + struct vx_info *vxi = NULL;
23350 + xid_t xid = PROC_I(inode)->fd;
23351 + unsigned long page;
23352 + ssize_t length = 0;
23354 + if (count > PROC_BLOCK_SIZE)
23355 + count = PROC_BLOCK_SIZE;
23357 + /* fade that out as soon as stable */
23359 + vxi = lookup_vx_info(xid);
23363 + length = -ENOMEM;
23364 + if (!(page = __get_free_page(GFP_KERNEL)))
23367 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23368 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23371 + length = simple_read_from_buffer(buf, count, ppos,
23372 + (char *)page, length);
23376 + put_vx_info(vxi);
23381 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23382 + size_t count, loff_t *ppos)
23384 + struct inode *inode = file->f_dentry->d_inode;
23385 + struct nx_info *nxi = NULL;
23386 + nid_t nid = PROC_I(inode)->fd;
23387 + unsigned long page;
23388 + ssize_t length = 0;
23390 + if (count > PROC_BLOCK_SIZE)
23391 + count = PROC_BLOCK_SIZE;
23393 + /* fade that out as soon as stable */
23395 + nxi = lookup_nx_info(nid);
23399 + length = -ENOMEM;
23400 + if (!(page = __get_free_page(GFP_KERNEL)))
23403 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23404 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23407 + length = simple_read_from_buffer(buf, count, ppos,
23408 + (char *)page, length);
23412 + put_nx_info(nxi);
23419 +/* here comes the lower level */
23422 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23423 + .len = sizeof(NAME) - 1, \
23424 + .name = (NAME), \
23432 +#define DIR(NAME, MODE, OTYPE) \
23433 + NOD(NAME, (S_IFDIR | (MODE)), \
23434 + &proc_ ## OTYPE ## _inode_operations, \
23435 + &proc_ ## OTYPE ## _file_operations, { } )
23437 +#define INF(NAME, MODE, OTYPE) \
23438 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23439 + &proc_vs_info_file_operations, \
23440 + { .proc_vs_read = &proc_##OTYPE } )
23442 +#define VINF(NAME, MODE, OTYPE) \
23443 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23444 + &proc_vx_info_file_operations, \
23445 + { .proc_vxi_read = &proc_##OTYPE } )
23447 +#define NINF(NAME, MODE, OTYPE) \
23448 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23449 + &proc_nx_info_file_operations, \
23450 + { .proc_nxi_read = &proc_##OTYPE } )
23453 +static struct file_operations proc_vs_info_file_operations = {
23454 + .read = proc_vs_info_read,
23457 +static struct file_operations proc_vx_info_file_operations = {
23458 + .read = proc_vx_info_read,
23461 +static struct dentry_operations proc_xid_dentry_operations = {
23462 + .d_revalidate = proc_xid_revalidate,
23465 +static struct vs_entry vx_base_stuff[] = {
23466 + VINF("info", S_IRUGO, vxi_info),
23467 + VINF("status", S_IRUGO, vxi_status),
23468 + VINF("limit", S_IRUGO, vxi_limit),
23469 + VINF("sched", S_IRUGO, vxi_sched),
23470 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23471 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23472 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23473 + VINF("cacct", S_IRUGO, vxi_cacct),
23480 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23481 + struct dentry *dentry, int id, void *ptr)
23483 + dentry->d_op = &proc_xid_dentry_operations;
23484 + return vs_proc_instantiate(dir, dentry, id, ptr);
23487 +static struct dentry *proc_xid_lookup(struct inode *dir,
23488 + struct dentry *dentry, struct nameidata *nd)
23490 + struct vs_entry *p = vx_base_stuff;
23491 + struct dentry *error = ERR_PTR(-ENOENT);
23493 + for (; p->name; p++) {
23494 + if (p->len != dentry->d_name.len)
23496 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23502 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23507 +static int proc_xid_readdir(struct file *filp,
23508 + void *dirent, filldir_t filldir)
23510 + struct dentry *dentry = filp->f_dentry;
23511 + struct inode *inode = dentry->d_inode;
23512 + struct vs_entry *p = vx_base_stuff;
23513 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23517 + pos = filp->f_pos;
23520 + ino = inode->i_ino;
23521 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23524 + /* fall through */
23526 + ino = parent_ino(dentry);
23527 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23530 + /* fall through */
23533 + if (index >= size)
23535 + for (p += index; p->name; p++) {
23536 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23537 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23543 + filp->f_pos = pos;
23549 +static struct file_operations proc_nx_info_file_operations = {
23550 + .read = proc_nx_info_read,
23553 +static struct dentry_operations proc_nid_dentry_operations = {
23554 + .d_revalidate = proc_nid_revalidate,
23557 +static struct vs_entry nx_base_stuff[] = {
23558 + NINF("info", S_IRUGO, nxi_info),
23559 + NINF("status", S_IRUGO, nxi_status),
23564 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23565 + struct dentry *dentry, int id, void *ptr)
23567 + dentry->d_op = &proc_nid_dentry_operations;
23568 + return vs_proc_instantiate(dir, dentry, id, ptr);
23571 +static struct dentry *proc_nid_lookup(struct inode *dir,
23572 + struct dentry *dentry, struct nameidata *nd)
23574 + struct vs_entry *p = nx_base_stuff;
23575 + struct dentry *error = ERR_PTR(-ENOENT);
23577 + for (; p->name; p++) {
23578 + if (p->len != dentry->d_name.len)
23580 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23586 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23591 +static int proc_nid_readdir(struct file *filp,
23592 + void *dirent, filldir_t filldir)
23594 + struct dentry *dentry = filp->f_dentry;
23595 + struct inode *inode = dentry->d_inode;
23596 + struct vs_entry *p = nx_base_stuff;
23597 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23601 + pos = filp->f_pos;
23604 + ino = inode->i_ino;
23605 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23608 + /* fall through */
23610 + ino = parent_ino(dentry);
23611 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23614 + /* fall through */
23617 + if (index >= size)
23619 + for (p += index; p->name; p++) {
23620 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23621 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23627 + filp->f_pos = pos;
23632 +#define MAX_MULBY10 ((~0U - 9) / 10)
23634 +static inline int atovid(const char *str, int len)
23639 + while (len-- > 0) {
23644 + if (vid >= MAX_MULBY10)
23654 +/* now the upper level (virtual) */
23657 +static struct file_operations proc_xid_file_operations = {
23658 + .read = generic_read_dir,
23659 + .readdir = proc_xid_readdir,
23662 +static struct inode_operations proc_xid_inode_operations = {
23663 + .lookup = proc_xid_lookup,
23666 +static struct vs_entry vx_virtual_stuff[] = {
23667 + INF("info", S_IRUGO, virtual_info),
23668 + INF("status", S_IRUGO, virtual_status),
23669 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23673 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23674 + struct dentry *dentry, struct nameidata *nd)
23676 + struct vs_entry *p = vx_virtual_stuff;
23677 + struct dentry *error = ERR_PTR(-ENOENT);
23680 + for (; p->name; p++) {
23681 + if (p->len != dentry->d_name.len)
23683 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23687 + goto instantiate;
23689 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23690 + if ((id < 0) || !xid_is_hashed(id))
23694 + error = proc_xid_instantiate(dir, dentry, id, p);
23699 +static struct file_operations proc_nid_file_operations = {
23700 + .read = generic_read_dir,
23701 + .readdir = proc_nid_readdir,
23704 +static struct inode_operations proc_nid_inode_operations = {
23705 + .lookup = proc_nid_lookup,
23708 +static struct vs_entry nx_virtnet_stuff[] = {
23709 + INF("info", S_IRUGO, virtnet_info),
23710 + INF("status", S_IRUGO, virtnet_status),
23711 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23715 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23716 + struct dentry *dentry, struct nameidata *nd)
23718 + struct vs_entry *p = nx_virtnet_stuff;
23719 + struct dentry *error = ERR_PTR(-ENOENT);
23722 + for (; p->name; p++) {
23723 + if (p->len != dentry->d_name.len)
23725 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23729 + goto instantiate;
23731 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23732 + if ((id < 0) || !nid_is_hashed(id))
23736 + error = proc_nid_instantiate(dir, dentry, id, p);
23742 +#define PROC_MAXVIDS 32
23744 +int proc_virtual_readdir(struct file *filp,
23745 + void *dirent, filldir_t filldir)
23747 + struct dentry *dentry = filp->f_dentry;
23748 + struct inode *inode = dentry->d_inode;
23749 + struct vs_entry *p = vx_virtual_stuff;
23750 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23752 + unsigned int xid_array[PROC_MAXVIDS];
23753 + char buf[PROC_NUMBUF];
23754 + unsigned int nr_xids, i;
23757 + pos = filp->f_pos;
23760 + ino = inode->i_ino;
23761 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23764 + /* fall through */
23766 + ino = parent_ino(dentry);
23767 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23770 + /* fall through */
23773 + if (index >= size)
23775 + for (p += index; p->name; p++) {
23776 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23777 + vs_proc_instantiate, 0, p))
23782 + index = pos - size;
23783 + p = &vx_virtual_stuff[size - 1];
23784 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23785 + for (i = 0; i < nr_xids; i++) {
23786 + int n, xid = xid_array[i];
23787 + unsigned int j = PROC_NUMBUF;
23791 + buf[--j] = '0' + (n % 10);
23794 + if (proc_fill_cache(filp, dirent, filldir,
23795 + buf + j, PROC_NUMBUF - j,
23796 + vs_proc_instantiate, xid, p))
23802 + filp->f_pos = pos;
23806 +static int proc_virtual_getattr(struct vfsmount *mnt,
23807 + struct dentry *dentry, struct kstat *stat)
23809 + struct inode *inode = dentry->d_inode;
23811 + generic_fillattr(inode, stat);
23812 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23816 +static struct file_operations proc_virtual_dir_operations = {
23817 + .read = generic_read_dir,
23818 + .readdir = proc_virtual_readdir,
23821 +static struct inode_operations proc_virtual_dir_inode_operations = {
23822 + .getattr = proc_virtual_getattr,
23823 + .lookup = proc_virtual_lookup,
23830 +int proc_virtnet_readdir(struct file *filp,
23831 + void *dirent, filldir_t filldir)
23833 + struct dentry *dentry = filp->f_dentry;
23834 + struct inode *inode = dentry->d_inode;
23835 + struct vs_entry *p = nx_virtnet_stuff;
23836 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23838 + unsigned int nid_array[PROC_MAXVIDS];
23839 + char buf[PROC_NUMBUF];
23840 + unsigned int nr_nids, i;
23843 + pos = filp->f_pos;
23846 + ino = inode->i_ino;
23847 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23850 + /* fall through */
23852 + ino = parent_ino(dentry);
23853 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23856 + /* fall through */
23859 + if (index >= size)
23861 + for (p += index; p->name; p++) {
23862 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23863 + vs_proc_instantiate, 0, p))
23868 + index = pos - size;
23869 + p = &nx_virtnet_stuff[size - 1];
23870 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23871 + for (i = 0; i < nr_nids; i++) {
23872 + int n, nid = nid_array[i];
23873 + unsigned int j = PROC_NUMBUF;
23877 + buf[--j] = '0' + (n % 10);
23880 + if (proc_fill_cache(filp, dirent, filldir,
23881 + buf + j, PROC_NUMBUF - j,
23882 + vs_proc_instantiate, nid, p))
23888 + filp->f_pos = pos;
23892 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23893 + struct dentry *dentry, struct kstat *stat)
23895 + struct inode *inode = dentry->d_inode;
23897 + generic_fillattr(inode, stat);
23898 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23902 +static struct file_operations proc_virtnet_dir_operations = {
23903 + .read = generic_read_dir,
23904 + .readdir = proc_virtnet_readdir,
23907 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23908 + .getattr = proc_virtnet_getattr,
23909 + .lookup = proc_virtnet_lookup,
23914 +void proc_vx_init(void)
23916 + struct proc_dir_entry *ent;
23918 + ent = proc_mkdir("virtual", 0);
23920 + ent->proc_fops = &proc_virtual_dir_operations;
23921 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23923 + proc_virtual = ent;
23925 + ent = proc_mkdir("virtnet", 0);
23927 + ent->proc_fops = &proc_virtnet_dir_operations;
23928 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23930 + proc_virtnet = ent;
23936 +/* per pid info */
23939 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23941 + struct vx_info *vxi;
23942 + char *orig = buffer;
23944 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23946 + vxi = task_get_vx_info(p);
23950 + buffer += sprintf(buffer, "BCaps:\t");
23951 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23952 + buffer += sprintf(buffer, "\n");
23953 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23954 + (unsigned long long)vxi->vx_ccaps);
23955 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23956 + (unsigned long long)vxi->vx_flags);
23957 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23959 + put_vx_info(vxi);
23961 + return buffer - orig;
23965 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23967 + struct nx_info *nxi;
23968 + struct nx_addr_v4 *v4a;
23969 +#ifdef CONFIG_IPV6
23970 + struct nx_addr_v6 *v6a;
23972 + char *orig = buffer;
23975 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23977 + nxi = task_get_nx_info(p);
23981 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23982 + (unsigned long long)nxi->nx_ncaps);
23983 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23984 + (unsigned long long)nxi->nx_flags);
23986 + buffer += sprintf(buffer,
23987 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23988 + NIPQUAD(nxi->v4_bcast.s_addr));
23989 + buffer += sprintf (buffer,
23990 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23991 + NIPQUAD(nxi->v4_lback.s_addr));
23992 + if (!NX_IPV4(nxi))
23994 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23995 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23998 +#ifdef CONFIG_IPV6
23999 + if (!NX_IPV6(nxi))
24001 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24002 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24006 + put_nx_info(nxi);
24008 + return buffer - orig;
24011 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/sched.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sched.c
24012 --- linux-2.6.27.25/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24013 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sched.c 2009-03-09 15:36:36.000000000 +0100
24016 + * linux/kernel/vserver/sched.c
24018 + * Virtual Server: Scheduler Support
24020 + * Copyright (C) 2004-2007 Herbert Pötzl
24022 + * V0.01 adapted Sam Vilains version to 2.6.3
24023 + * V0.02 removed legacy interface
24024 + * V0.03 changed vcmds to vxi arg
24025 + * V0.04 removed older and legacy interfaces
24029 +#include <linux/vs_context.h>
24030 +#include <linux/vs_sched.h>
24031 +#include <linux/vserver/sched_cmd.h>
24033 +#include <asm/uaccess.h>
24036 +#define vxd_check_range(val, min, max) do { \
24037 + vxlprintk((val < min) || (val > max), \
24038 + "check_range(%ld,%ld,%ld)", \
24039 + (long)val, (long)min, (long)max, \
24040 + __FILE__, __LINE__); \
24044 +void vx_update_sched_param(struct _vx_sched *sched,
24045 + struct _vx_sched_pc *sched_pc)
24047 + unsigned int set_mask = sched->update_mask;
24049 + if (set_mask & VXSM_FILL_RATE)
24050 + sched_pc->fill_rate[0] = sched->fill_rate[0];
24051 + if (set_mask & VXSM_INTERVAL)
24052 + sched_pc->interval[0] = sched->interval[0];
24053 + if (set_mask & VXSM_FILL_RATE2)
24054 + sched_pc->fill_rate[1] = sched->fill_rate[1];
24055 + if (set_mask & VXSM_INTERVAL2)
24056 + sched_pc->interval[1] = sched->interval[1];
24057 + if (set_mask & VXSM_TOKENS)
24058 + sched_pc->tokens = sched->tokens;
24059 + if (set_mask & VXSM_TOKENS_MIN)
24060 + sched_pc->tokens_min = sched->tokens_min;
24061 + if (set_mask & VXSM_TOKENS_MAX)
24062 + sched_pc->tokens_max = sched->tokens_max;
24063 + if (set_mask & VXSM_PRIO_BIAS)
24064 + sched_pc->prio_bias = sched->prio_bias;
24066 + if (set_mask & VXSM_IDLE_TIME)
24067 + sched_pc->flags |= VXSF_IDLE_TIME;
24069 + sched_pc->flags &= ~VXSF_IDLE_TIME;
24072 + sched_pc->norm_time = jiffies;
24077 + * recalculate the context's scheduling tokens
24079 + * ret > 0 : number of tokens available
24080 + * ret < 0 : on hold, check delta_min[]
24081 + * -1 only jiffies
24082 + * -2 also idle time
24085 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24086 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24090 + int flags = sched_pc->flags;
24092 + /* how much time did pass? */
24093 + delta = *norm_time - sched_pc->norm_time;
24094 + // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24095 + vxd_check_range(delta, 0, INT_MAX);
24097 + if (delta >= sched_pc->interval[0]) {
24098 + long tokens, integral;
24100 + /* calc integral token part */
24101 + tokens = delta / sched_pc->interval[0];
24102 + integral = tokens * sched_pc->interval[0];
24103 + tokens *= sched_pc->fill_rate[0];
24104 +#ifdef CONFIG_VSERVER_HARDCPU
24105 + delta_min[0] = delta - integral;
24106 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24108 + /* advance time */
24109 + sched_pc->norm_time += delta;
24112 + sched_pc->tokens += tokens;
24113 + sched_pc->token_time += tokens;
24115 + delta_min[0] = delta;
24117 +#ifdef CONFIG_VSERVER_IDLETIME
24118 + if (!(flags & VXSF_IDLE_TIME))
24121 + /* how much was the idle skip? */
24122 + delta = *idle_time - sched_pc->idle_time;
24123 + vxd_check_range(delta, 0, INT_MAX);
24125 + if (delta >= sched_pc->interval[1]) {
24126 + long tokens, integral;
24128 + /* calc fair share token part */
24129 + tokens = delta / sched_pc->interval[1];
24130 + integral = tokens * sched_pc->interval[1];
24131 + tokens *= sched_pc->fill_rate[1];
24132 + delta_min[1] = delta - integral;
24133 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24135 + /* advance idle time */
24136 + sched_pc->idle_time += integral;
24139 + sched_pc->tokens += tokens;
24140 + sched_pc->token_time += tokens;
24142 + delta_min[1] = delta;
24146 + /* clip at maximum */
24147 + if (sched_pc->tokens > sched_pc->tokens_max)
24148 + sched_pc->tokens = sched_pc->tokens_max;
24149 + tokens = sched_pc->tokens;
24151 + if ((flags & VXSF_ONHOLD)) {
24152 + /* can we unhold? */
24153 + if (tokens >= sched_pc->tokens_min) {
24154 + flags &= ~VXSF_ONHOLD;
24155 + sched_pc->hold_ticks +=
24156 + *norm_time - sched_pc->onhold;
24160 + /* put on hold? */
24161 + if (tokens <= 0) {
24162 + flags |= VXSF_ONHOLD;
24163 + sched_pc->onhold = *norm_time;
24167 + sched_pc->flags = flags;
24171 + tokens = sched_pc->tokens_min - tokens;
24172 + sched_pc->flags = flags;
24173 + // BUG_ON(tokens < 0); probably doesn't hold anymore
24175 +#ifdef CONFIG_VSERVER_HARDCPU
24176 + /* next interval? */
24177 + if (!sched_pc->fill_rate[0])
24178 + delta_min[0] = HZ;
24179 + else if (tokens > sched_pc->fill_rate[0])
24180 + delta_min[0] += sched_pc->interval[0] *
24181 + tokens / sched_pc->fill_rate[0];
24183 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24184 + vxd_check_range(delta_min[0], 0, INT_MAX);
24186 +#ifdef CONFIG_VSERVER_IDLETIME
24187 + if (!(flags & VXSF_IDLE_TIME))
24190 + /* next interval? */
24191 + if (!sched_pc->fill_rate[1])
24192 + delta_min[1] = HZ;
24193 + else if (tokens > sched_pc->fill_rate[1])
24194 + delta_min[1] += sched_pc->interval[1] *
24195 + tokens / sched_pc->fill_rate[1];
24197 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24198 + vxd_check_range(delta_min[1], 0, INT_MAX);
24203 +#endif /* CONFIG_VSERVER_IDLETIME */
24206 +#endif /* CONFIG_VSERVER_HARDCPU */
24209 +static inline unsigned long msec_to_ticks(unsigned long msec)
24211 + return msecs_to_jiffies(msec);
24214 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24216 + return jiffies_to_msecs(ticks);
24219 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24221 + return jiffies_to_usecs(ticks);
24225 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24227 + unsigned int set_mask = data->mask;
24228 + unsigned int update_mask;
24231 + /* Sanity check data values */
24232 + if (data->tokens_max <= 0)
24233 + data->tokens_max = HZ;
24234 + if (data->tokens_min < 0)
24235 + data->tokens_min = HZ / 3;
24236 + if (data->tokens_min >= data->tokens_max)
24237 + data->tokens_min = data->tokens_max;
24239 + if (data->prio_bias > MAX_PRIO_BIAS)
24240 + data->prio_bias = MAX_PRIO_BIAS;
24241 + if (data->prio_bias < MIN_PRIO_BIAS)
24242 + data->prio_bias = MIN_PRIO_BIAS;
24244 + spin_lock(&vxi->sched.tokens_lock);
24246 + /* sync up on delayed updates */
24247 + for_each_cpu_mask(cpu, vxi->sched.update)
24248 + vx_update_sched_param(&vxi->sched,
24249 + &vx_per_cpu(vxi, sched_pc, cpu));
24251 + if (set_mask & VXSM_FILL_RATE)
24252 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24253 + if (set_mask & VXSM_FILL_RATE2)
24254 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24255 + if (set_mask & VXSM_INTERVAL)
24256 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24257 + msec_to_ticks(data->interval[0]) : data->interval[0];
24258 + if (set_mask & VXSM_INTERVAL2)
24259 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24260 + msec_to_ticks(data->interval[1]) : data->interval[1];
24261 + if (set_mask & VXSM_TOKENS)
24262 + vxi->sched.tokens = data->tokens;
24263 + if (set_mask & VXSM_TOKENS_MIN)
24264 + vxi->sched.tokens_min = data->tokens_min;
24265 + if (set_mask & VXSM_TOKENS_MAX)
24266 + vxi->sched.tokens_max = data->tokens_max;
24267 + if (set_mask & VXSM_PRIO_BIAS)
24268 + vxi->sched.prio_bias = data->prio_bias;
24270 + /* Sanity check rate/interval */
24271 + for (i = 0; i < 2; i++) {
24272 + if (data->fill_rate[i] < 0)
24273 + data->fill_rate[i] = 0;
24274 + if (data->interval[i] <= 0)
24275 + data->interval[i] = HZ;
24278 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24279 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24280 + vxi->sched.update_mask = update_mask;
24284 + if (set_mask & VXSM_CPU_ID) {
24285 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24286 + cpus_and(vxi->sched.update, cpu_online_map,
24287 + vxi->sched.update);
24289 + vxi->sched.update = cpu_online_map;
24291 + /* forced reload? */
24292 + if (set_mask & VXSM_FORCE) {
24293 + for_each_cpu_mask(cpu, vxi->sched.update)
24294 + vx_update_sched_param(&vxi->sched,
24295 + &vx_per_cpu(vxi, sched_pc, cpu));
24296 + vxi->sched.update = CPU_MASK_NONE;
24299 + /* on UP we update immediately */
24300 + vx_update_sched_param(&vxi->sched,
24301 + &vx_per_cpu(vxi, sched_pc, 0));
24304 + spin_unlock(&vxi->sched.tokens_lock);
24309 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24310 +#define COPY_PRI(C) C(prio_bias)
24311 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24312 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24313 + C(fill_rate[1]); C(interval[1]);
24315 +#define COPY_VALUE(name) vc_data.name = data->name
24317 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24319 + struct vcmd_sched_v5 vc_data;
24321 + vc_data.mask = data->set_mask;
24322 + COPY_IDS(COPY_VALUE);
24323 + COPY_PRI(COPY_VALUE);
24324 + COPY_TOK(COPY_VALUE);
24325 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24326 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24327 + return do_set_sched(vxi, &vc_data);
24330 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24332 + struct vcmd_set_sched_v4 vc_data;
24334 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24337 + return do_set_sched_v4(vxi, &vc_data);
24340 + /* latest interface is v5 */
24342 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24344 + struct vcmd_sched_v5 vc_data;
24346 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24349 + return do_set_sched(vxi, &vc_data);
24353 +#define COPY_PRI(C) C(prio_bias)
24354 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24355 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24356 + C(fill_rate[1]); C(interval[1]);
24358 +#define COPY_VALUE(name) vc_data.name = data->name
24361 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24363 + struct vcmd_sched_v5 vc_data;
24365 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24368 + if (vc_data.mask & VXSM_CPU_ID) {
24369 + int cpu = vc_data.cpu_id;
24370 + struct _vx_sched_pc *data;
24372 + if (!cpu_possible(cpu))
24375 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24376 + COPY_TOK(COPY_VALUE);
24377 + COPY_PRI(COPY_VALUE);
24378 + COPY_FRI(COPY_VALUE);
24380 + if (data->flags & VXSF_IDLE_TIME)
24381 + vc_data.mask |= VXSM_IDLE_TIME;
24383 + struct _vx_sched *data = &vxi->sched;
24385 + COPY_TOK(COPY_VALUE);
24386 + COPY_PRI(COPY_VALUE);
24387 + COPY_FRI(COPY_VALUE);
24390 + if (vc_data.mask & VXSM_MSEC) {
24391 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24392 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24395 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24401 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24403 + struct vcmd_sched_info vc_data;
24406 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24409 + cpu = vc_data.cpu_id;
24410 + if (!cpu_possible(cpu))
24414 + struct _vx_sched_pc *sched_pc =
24415 + &vx_per_cpu(vxi, sched_pc, cpu);
24417 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24418 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24419 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24420 + vc_data.vavavoom = sched_pc->vavavoom;
24422 + vc_data.token_usec = ticks_to_usec(1);
24424 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24429 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/sched_init.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sched_init.h
24430 --- linux-2.6.27.25/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24431 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sched_init.h 2008-10-13 14:54:20.000000000 +0200
24434 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24436 + static struct lock_class_key tokens_lock_key;
24438 + /* scheduling; hard code starting values as constants */
24439 + sched->fill_rate[0] = 1;
24440 + sched->interval[0] = 4;
24441 + sched->fill_rate[1] = 1;
24442 + sched->interval[1] = 8;
24443 + sched->tokens = HZ >> 2;
24444 + sched->tokens_min = HZ >> 4;
24445 + sched->tokens_max = HZ >> 1;
24446 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24447 + sched->prio_bias = 0;
24449 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24453 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24455 + sched_pc->fill_rate[0] = 1;
24456 + sched_pc->interval[0] = 4;
24457 + sched_pc->fill_rate[1] = 1;
24458 + sched_pc->interval[1] = 8;
24459 + sched_pc->tokens = HZ >> 2;
24460 + sched_pc->tokens_min = HZ >> 4;
24461 + sched_pc->tokens_max = HZ >> 1;
24462 + sched_pc->prio_bias = 0;
24463 + sched_pc->vavavoom = 0;
24464 + sched_pc->token_time = 0;
24465 + sched_pc->idle_time = 0;
24466 + sched_pc->norm_time = jiffies;
24468 + sched_pc->user_ticks = 0;
24469 + sched_pc->sys_ticks = 0;
24470 + sched_pc->hold_ticks = 0;
24473 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24479 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24483 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/sched_proc.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sched_proc.h
24484 --- linux-2.6.27.25/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24485 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sched_proc.h 2008-10-13 14:54:20.000000000 +0200
24487 +#ifndef _VX_SCHED_PROC_H
24488 +#define _VX_SCHED_PROC_H
24492 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24496 + length += sprintf(buffer,
24497 + "FillRate:\t%8d,%d\n"
24498 + "Interval:\t%8d,%d\n"
24499 + "TokensMin:\t%8d\n"
24500 + "TokensMax:\t%8d\n"
24501 + "PrioBias:\t%8d\n",
24502 + sched->fill_rate[0],
24503 + sched->fill_rate[1],
24504 + sched->interval[0],
24505 + sched->interval[1],
24506 + sched->tokens_min,
24507 + sched->tokens_max,
24508 + sched->prio_bias);
24513 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24514 + char *buffer, int cpu)
24518 + length += sprintf(buffer + length,
24519 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24520 + (unsigned long long)sched_pc->user_ticks,
24521 + (unsigned long long)sched_pc->sys_ticks,
24522 + (unsigned long long)sched_pc->hold_ticks,
24523 + sched_pc->token_time,
24524 + sched_pc->idle_time);
24525 + length += sprintf(buffer + length,
24526 + " %c%c %d %d %d %d/%d %d/%d",
24527 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24528 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24529 + sched_pc->tokens,
24530 + sched_pc->tokens_min,
24531 + sched_pc->tokens_max,
24532 + sched_pc->fill_rate[0],
24533 + sched_pc->interval[0],
24534 + sched_pc->fill_rate[1],
24535 + sched_pc->interval[1]);
24536 + length += sprintf(buffer + length,
24538 + sched_pc->prio_bias,
24539 + sched_pc->vavavoom);
24543 +#endif /* _VX_SCHED_PROC_H */
24544 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/signal.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/signal.c
24545 --- linux-2.6.27.25/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24546 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/signal.c 2008-10-13 14:54:20.000000000 +0200
24549 + * linux/kernel/vserver/signal.c
24551 + * Virtual Server: Signal Support
24553 + * Copyright (C) 2003-2007 Herbert Pötzl
24555 + * V0.01 broken out from vcontext V0.05
24556 + * V0.02 changed vcmds to vxi arg
24557 + * V0.03 adjusted siginfo for kill
24561 +#include <asm/uaccess.h>
24563 +#include <linux/vs_context.h>
24564 +#include <linux/vs_pid.h>
24565 +#include <linux/vserver/signal_cmd.h>
24568 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24570 + int retval, count = 0;
24571 + struct task_struct *p;
24572 + struct siginfo *sip = SEND_SIG_PRIV;
24575 + vxdprintk(VXD_CBIT(misc, 4),
24576 + "vx_info_kill(%p[#%d],%d,%d)*",
24577 + vxi, vxi->vx_id, pid, sig);
24578 + read_lock(&tasklist_lock);
24582 + for_each_process(p) {
24585 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24586 + (pid && vxi->vx_initpid == p->pid))
24589 + err = group_send_sig_info(sig, sip, p);
24591 + if (err != -EPERM)
24597 + if (vxi->vx_initpid) {
24598 + pid = vxi->vx_initpid;
24599 + /* for now, only SIGINT to private init ... */
24600 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24601 + /* ... as long as there are tasks left */
24602 + (atomic_read(&vxi->vx_tasks) > 1))
24605 + /* fallthrough */
24607 + p = find_task_by_real_pid(pid);
24609 + if (vx_task_xid(p) == vxi->vx_id)
24610 + retval = group_send_sig_info(sig, sip, p);
24614 + read_unlock(&tasklist_lock);
24615 + vxdprintk(VXD_CBIT(misc, 4),
24616 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24617 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24621 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24623 + struct vcmd_ctx_kill_v0 vc_data;
24625 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24628 + /* special check to allow guest shutdown */
24629 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24630 + /* forbid killall pid=0 when init is present */
24631 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24632 + (vc_data.pid > 1)))
24635 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24639 +static int __wait_exit(struct vx_info *vxi)
24641 + DECLARE_WAITQUEUE(wait, current);
24644 + add_wait_queue(&vxi->vx_wait, &wait);
24645 + set_current_state(TASK_INTERRUPTIBLE);
24648 + if (vx_info_state(vxi,
24649 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24651 + if (signal_pending(current)) {
24652 + ret = -ERESTARTSYS;
24659 + set_current_state(TASK_RUNNING);
24660 + remove_wait_queue(&vxi->vx_wait, &wait);
24666 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24668 + struct vcmd_wait_exit_v0 vc_data;
24671 + ret = __wait_exit(vxi);
24672 + vc_data.reboot_cmd = vxi->reboot_cmd;
24673 + vc_data.exit_code = vxi->exit_code;
24675 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24680 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/space.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/space.c
24681 --- linux-2.6.27.25/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24682 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/space.c 2008-10-31 18:15:28.000000000 +0100
24685 + * linux/kernel/vserver/space.c
24687 + * Virtual Server: Context Space Support
24689 + * Copyright (C) 2003-2007 Herbert Pötzl
24691 + * V0.01 broken out from context.c 0.07
24692 + * V0.02 added task locking for namespace
24693 + * V0.03 broken out vx_enter_namespace
24694 + * V0.04 added *space support and commands
24698 +#include <linux/utsname.h>
24699 +#include <linux/nsproxy.h>
24700 +#include <linux/err.h>
24701 +#include <asm/uaccess.h>
24703 +#include <linux/vs_context.h>
24704 +#include <linux/vserver/space.h>
24705 +#include <linux/vserver/space_cmd.h>
24707 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24708 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24709 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24710 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24711 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24712 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24713 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24716 +/* namespace functions */
24718 +#include <linux/mnt_namespace.h>
24719 +#include <linux/user_namespace.h>
24720 +#include <linux/pid_namespace.h>
24721 +#include <linux/ipc_namespace.h>
24722 +#include <net/net_namespace.h>
24725 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24726 + .mask = CLONE_FS |
24734 +static const struct vcmd_space_mask_v1 space_mask = {
24735 + .mask = CLONE_FS |
24740 +#ifdef CONFIG_PID_NS
24743 +#ifdef CONFIG_NET_NS
24749 +static const struct vcmd_space_mask_v1 default_space_mask = {
24750 + .mask = CLONE_FS |
24755 +#ifdef CONFIG_PID_NS
24762 + * build a new nsproxy mix
24763 + * assumes that both proxies are 'const'
24764 + * does not touch nsproxy refcounts
24765 + * will hold a reference on the result.
24768 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24769 + struct nsproxy *new_nsproxy, unsigned long mask)
24771 + struct mnt_namespace *old_ns;
24772 + struct uts_namespace *old_uts;
24773 + struct ipc_namespace *old_ipc;
24774 + struct user_namespace *old_user;
24775 +#ifdef CONFIG_PID_NS
24776 + struct pid_namespace *old_pid;
24778 +#ifdef CONFIG_NET_NS
24779 + struct net *old_net;
24781 + struct nsproxy *nsproxy;
24783 + nsproxy = copy_nsproxy(old_nsproxy);
24787 + if (mask & CLONE_NEWNS) {
24788 + old_ns = nsproxy->mnt_ns;
24789 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24790 + if (nsproxy->mnt_ns)
24791 + get_mnt_ns(nsproxy->mnt_ns);
24795 + if (mask & CLONE_NEWUTS) {
24796 + old_uts = nsproxy->uts_ns;
24797 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24798 + if (nsproxy->uts_ns)
24799 + get_uts_ns(nsproxy->uts_ns);
24803 + if (mask & CLONE_NEWIPC) {
24804 + old_ipc = nsproxy->ipc_ns;
24805 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24806 + if (nsproxy->ipc_ns)
24807 + get_ipc_ns(nsproxy->ipc_ns);
24811 + if (mask & CLONE_NEWUSER) {
24812 + old_user = nsproxy->user_ns;
24813 + nsproxy->user_ns = new_nsproxy->user_ns;
24814 + if (nsproxy->user_ns)
24815 + get_user_ns(nsproxy->user_ns);
24819 +#ifdef CONFIG_PID_NS
24820 + if (mask & CLONE_NEWPID) {
24821 + old_pid = nsproxy->pid_ns;
24822 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24823 + if (nsproxy->pid_ns)
24824 + get_pid_ns(nsproxy->pid_ns);
24828 +#ifdef CONFIG_NET_NS
24829 + if (mask & CLONE_NEWNET) {
24830 + old_net = nsproxy->net_ns;
24831 + nsproxy->net_ns = new_nsproxy->net_ns;
24832 + if (nsproxy->net_ns)
24833 + get_net(nsproxy->net_ns);
24838 + put_mnt_ns(old_ns);
24840 + put_uts_ns(old_uts);
24842 + put_ipc_ns(old_ipc);
24844 + put_user_ns(old_user);
24845 +#ifdef CONFIG_PID_NS
24847 + put_pid_ns(old_pid);
24849 +#ifdef CONFIG_NET_NS
24851 + put_net(old_net);
24859 + * merge two nsproxy structs into a new one.
24860 + * will hold a reference on the result.
24864 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24865 + struct nsproxy *proxy, unsigned long mask)
24867 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24873 + /* vs_mix_nsproxy returns with reference */
24874 + return vs_mix_nsproxy(old ? old : &null_proxy,
24877 + get_nsproxy(proxy);
24882 + * merge two fs structs into a new one.
24883 + * will take a reference on the result.
24887 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24888 + struct fs_struct *fs, unsigned long mask)
24890 + if (!(mask & CLONE_FS)) {
24892 + atomic_inc(&old->count);
24899 + return copy_fs_struct(fs);
24903 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24905 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24906 + struct fs_struct *fs, *fs_cur, *fs_new;
24909 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24910 + vxi, vxi->vx_id, mask, index);
24912 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24916 + mask = vxi->vx_nsmask[index];
24918 + if ((mask & vxi->vx_nsmask[index]) != mask)
24921 + proxy = vxi->vx_nsproxy[index];
24922 + fs = vxi->vx_fs[index];
24924 + task_lock(current);
24925 + fs_cur = current->fs;
24926 + atomic_inc(&fs_cur->count);
24927 + proxy_cur = current->nsproxy;
24928 + get_nsproxy(proxy_cur);
24929 + task_unlock(current);
24931 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24932 + if (IS_ERR(fs_new)) {
24933 + ret = PTR_ERR(fs_new);
24937 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24938 + if (IS_ERR(proxy_new)) {
24939 + ret = PTR_ERR(proxy_new);
24943 + fs_new = xchg(¤t->fs, fs_new);
24944 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24948 + put_nsproxy(proxy_new);
24951 + put_fs_struct(fs_new);
24954 + put_nsproxy(proxy_cur);
24956 + put_fs_struct(fs_cur);
24961 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24963 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24964 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24967 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24968 + vxi, vxi->vx_id, mask, index);
24971 + mask = default_space_mask.mask;
24973 + if ((mask & space_mask.mask) != mask)
24976 + proxy_vxi = vxi->vx_nsproxy[index];
24977 + fs_vxi = vxi->vx_fs[index];
24979 + task_lock(current);
24980 + fs_cur = current->fs;
24981 + atomic_inc(&fs_cur->count);
24982 + proxy_cur = current->nsproxy;
24983 + get_nsproxy(proxy_cur);
24984 + task_unlock(current);
24986 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24987 + if (IS_ERR(fs_new)) {
24988 + ret = PTR_ERR(fs_new);
24992 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24993 + if (IS_ERR(proxy_new)) {
24994 + ret = PTR_ERR(proxy_new);
24998 + fs_new = xchg(&vxi->vx_fs[index], fs_new);
24999 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25000 + vxi->vx_nsmask[index] |= mask;
25004 + put_nsproxy(proxy_new);
25007 + put_fs_struct(fs_new);
25010 + put_nsproxy(proxy_cur);
25012 + put_fs_struct(fs_cur);
25017 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25019 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25021 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25024 + return vx_enter_space(vxi, vc_data.mask, 0);
25027 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25029 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25031 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25034 + if (vc_data.index >= VX_SPACES)
25037 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25040 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25042 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25044 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25047 + return vx_set_space(vxi, vc_data.mask, 0);
25050 +int vc_set_space(struct vx_info *vxi, void __user *data)
25052 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25054 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25057 + if (vc_data.index >= VX_SPACES)
25060 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
25063 +int vc_get_space_mask(void __user *data, int type)
25065 + const struct vcmd_space_mask_v1 *mask;
25068 + mask = &space_mask_v0;
25069 + else if (type == 1)
25070 + mask = &space_mask;
25072 + mask = &default_space_mask;
25074 + vxdprintk(VXD_CBIT(space, 10),
25075 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25077 + if (copy_to_user(data, mask, sizeof(*mask)))
25082 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/switch.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/switch.c
25083 --- linux-2.6.27.25/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25084 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/switch.c 2008-10-31 04:42:36.000000000 +0100
25087 + * linux/kernel/vserver/switch.c
25089 + * Virtual Server: Syscall Switch
25091 + * Copyright (C) 2003-2007 Herbert Pötzl
25093 + * V0.01 syscall switch
25094 + * V0.02 added signal to context
25095 + * V0.03 added rlimit functions
25096 + * V0.04 added iattr, task/xid functions
25097 + * V0.05 added debug/history stuff
25098 + * V0.06 added compat32 layer
25099 + * V0.07 vcmd args and perms
25100 + * V0.08 added status commands
25101 + * V0.09 added tag commands
25102 + * V0.10 added oom bias
25103 + * V0.11 added device commands
25107 +#include <linux/vs_context.h>
25108 +#include <linux/vs_network.h>
25109 +#include <linux/vserver/switch.h>
25111 +#include "vci_config.h"
25115 +int vc_get_version(uint32_t id)
25117 + return VCI_VERSION;
25121 +int vc_get_vci(uint32_t id)
25123 + return vci_kernel_config();
25126 +#include <linux/vserver/context_cmd.h>
25127 +#include <linux/vserver/cvirt_cmd.h>
25128 +#include <linux/vserver/cacct_cmd.h>
25129 +#include <linux/vserver/limit_cmd.h>
25130 +#include <linux/vserver/network_cmd.h>
25131 +#include <linux/vserver/sched_cmd.h>
25132 +#include <linux/vserver/debug_cmd.h>
25133 +#include <linux/vserver/inode_cmd.h>
25134 +#include <linux/vserver/dlimit_cmd.h>
25135 +#include <linux/vserver/signal_cmd.h>
25136 +#include <linux/vserver/space_cmd.h>
25137 +#include <linux/vserver/tag_cmd.h>
25138 +#include <linux/vserver/device_cmd.h>
25140 +#include <linux/vserver/inode.h>
25141 +#include <linux/vserver/dlimit.h>
25144 +#ifdef CONFIG_COMPAT
25145 +#define __COMPAT(name, id, data, compat) \
25146 + (compat) ? name ## _x32(id, data) : name(id, data)
25147 +#define __COMPAT_NO_ID(name, data, compat) \
25148 + (compat) ? name ## _x32(data) : name(data)
25150 +#define __COMPAT(name, id, data, compat) \
25152 +#define __COMPAT_NO_ID(name, data, compat) \
25158 +long do_vcmd(uint32_t cmd, uint32_t id,
25159 + struct vx_info *vxi, struct nx_info *nxi,
25160 + void __user *data, int compat)
25164 + case VCMD_get_version:
25165 + return vc_get_version(id);
25166 + case VCMD_get_vci:
25167 + return vc_get_vci(id);
25169 + case VCMD_task_xid:
25170 + return vc_task_xid(id);
25171 + case VCMD_vx_info:
25172 + return vc_vx_info(vxi, data);
25174 + case VCMD_task_nid:
25175 + return vc_task_nid(id);
25176 + case VCMD_nx_info:
25177 + return vc_nx_info(nxi, data);
25179 + case VCMD_task_tag:
25180 + return vc_task_tag(id);
25182 + case VCMD_set_space_v1:
25183 + return vc_set_space_v1(vxi, data);
25184 + /* this is version 2 */
25185 + case VCMD_set_space:
25186 + return vc_set_space(vxi, data);
25188 + case VCMD_get_space_mask_v0:
25189 + return vc_get_space_mask(data, 0);
25190 + /* this is version 1 */
25191 + case VCMD_get_space_mask:
25192 + return vc_get_space_mask(data, 1);
25194 + case VCMD_get_space_default:
25195 + return vc_get_space_mask(data, -1);
25197 +#ifdef CONFIG_IA32_EMULATION
25198 + case VCMD_get_rlimit:
25199 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25200 + case VCMD_set_rlimit:
25201 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25203 + case VCMD_get_rlimit:
25204 + return vc_get_rlimit(vxi, data);
25205 + case VCMD_set_rlimit:
25206 + return vc_set_rlimit(vxi, data);
25208 + case VCMD_get_rlimit_mask:
25209 + return vc_get_rlimit_mask(id, data);
25210 + case VCMD_reset_minmax:
25211 + return vc_reset_minmax(vxi, data);
25213 + case VCMD_get_vhi_name:
25214 + return vc_get_vhi_name(vxi, data);
25215 + case VCMD_set_vhi_name:
25216 + return vc_set_vhi_name(vxi, data);
25218 + case VCMD_ctx_stat:
25219 + return vc_ctx_stat(vxi, data);
25220 + case VCMD_virt_stat:
25221 + return vc_virt_stat(vxi, data);
25222 + case VCMD_sock_stat:
25223 + return vc_sock_stat(vxi, data);
25224 + case VCMD_rlimit_stat:
25225 + return vc_rlimit_stat(vxi, data);
25227 + case VCMD_set_cflags:
25228 + return vc_set_cflags(vxi, data);
25229 + case VCMD_get_cflags:
25230 + return vc_get_cflags(vxi, data);
25232 + /* this is version 1 */
25233 + case VCMD_set_ccaps:
25234 + return vc_set_ccaps(vxi, data);
25235 + /* this is version 1 */
25236 + case VCMD_get_ccaps:
25237 + return vc_get_ccaps(vxi, data);
25238 + case VCMD_set_bcaps:
25239 + return vc_set_bcaps(vxi, data);
25240 + case VCMD_get_bcaps:
25241 + return vc_get_bcaps(vxi, data);
25243 + case VCMD_set_badness:
25244 + return vc_set_badness(vxi, data);
25245 + case VCMD_get_badness:
25246 + return vc_get_badness(vxi, data);
25248 + case VCMD_set_nflags:
25249 + return vc_set_nflags(nxi, data);
25250 + case VCMD_get_nflags:
25251 + return vc_get_nflags(nxi, data);
25253 + case VCMD_set_ncaps:
25254 + return vc_set_ncaps(nxi, data);
25255 + case VCMD_get_ncaps:
25256 + return vc_get_ncaps(nxi, data);
25258 + case VCMD_set_sched_v4:
25259 + return vc_set_sched_v4(vxi, data);
25260 + /* this is version 5 */
25261 + case VCMD_set_sched:
25262 + return vc_set_sched(vxi, data);
25263 + case VCMD_get_sched:
25264 + return vc_get_sched(vxi, data);
25265 + case VCMD_sched_info:
25266 + return vc_sched_info(vxi, data);
25268 + case VCMD_add_dlimit:
25269 + return __COMPAT(vc_add_dlimit, id, data, compat);
25270 + case VCMD_rem_dlimit:
25271 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25272 + case VCMD_set_dlimit:
25273 + return __COMPAT(vc_set_dlimit, id, data, compat);
25274 + case VCMD_get_dlimit:
25275 + return __COMPAT(vc_get_dlimit, id, data, compat);
25277 + case VCMD_ctx_kill:
25278 + return vc_ctx_kill(vxi, data);
25280 + case VCMD_wait_exit:
25281 + return vc_wait_exit(vxi, data);
25283 + case VCMD_get_iattr:
25284 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25285 + case VCMD_set_iattr:
25286 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25288 + case VCMD_fget_iattr:
25289 + return vc_fget_iattr(id, data);
25290 + case VCMD_fset_iattr:
25291 + return vc_fset_iattr(id, data);
25293 + case VCMD_enter_space_v0:
25294 + return vc_enter_space_v1(vxi, NULL);
25295 + case VCMD_enter_space_v1:
25296 + return vc_enter_space_v1(vxi, data);
25297 + /* this is version 2 */
25298 + case VCMD_enter_space:
25299 + return vc_enter_space(vxi, data);
25301 + case VCMD_ctx_create_v0:
25302 + return vc_ctx_create(id, NULL);
25303 + case VCMD_ctx_create:
25304 + return vc_ctx_create(id, data);
25305 + case VCMD_ctx_migrate_v0:
25306 + return vc_ctx_migrate(vxi, NULL);
25307 + case VCMD_ctx_migrate:
25308 + return vc_ctx_migrate(vxi, data);
25310 + case VCMD_net_create_v0:
25311 + return vc_net_create(id, NULL);
25312 + case VCMD_net_create:
25313 + return vc_net_create(id, data);
25314 + case VCMD_net_migrate:
25315 + return vc_net_migrate(nxi, data);
25317 + case VCMD_tag_migrate:
25318 + return vc_tag_migrate(id);
25320 + case VCMD_net_add:
25321 + return vc_net_add(nxi, data);
25322 + case VCMD_net_remove:
25323 + return vc_net_remove(nxi, data);
25325 + case VCMD_net_add_ipv4:
25326 + return vc_net_add_ipv4(nxi, data);
25327 + case VCMD_net_remove_ipv4:
25328 + return vc_net_remove_ipv4(nxi, data);
25329 +#ifdef CONFIG_IPV6
25330 + case VCMD_net_add_ipv6:
25331 + return vc_net_add_ipv6(nxi, data);
25332 + case VCMD_net_remove_ipv6:
25333 + return vc_net_remove_ipv6(nxi, data);
25335 +/* case VCMD_add_match_ipv4:
25336 + return vc_add_match_ipv4(nxi, data);
25337 + case VCMD_get_match_ipv4:
25338 + return vc_get_match_ipv4(nxi, data);
25339 +#ifdef CONFIG_IPV6
25340 + case VCMD_add_match_ipv6:
25341 + return vc_add_match_ipv6(nxi, data);
25342 + case VCMD_get_match_ipv6:
25343 + return vc_get_match_ipv6(nxi, data);
25346 +#ifdef CONFIG_VSERVER_DEVICE
25347 + case VCMD_set_mapping:
25348 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25349 + case VCMD_unset_mapping:
25350 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25352 +#ifdef CONFIG_VSERVER_HISTORY
25353 + case VCMD_dump_history:
25354 + return vc_dump_history(id);
25355 + case VCMD_read_history:
25356 + return __COMPAT(vc_read_history, id, data, compat);
25358 +#ifdef CONFIG_VSERVER_MONITOR
25359 + case VCMD_read_monitor:
25360 + return __COMPAT(vc_read_monitor, id, data, compat);
25363 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25364 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25370 +#define __VCMD(vcmd, _perm, _args, _flags) \
25371 + case VCMD_ ## vcmd: perm = _perm; \
25372 + args = _args; flags = _flags; break
25375 +#define VCA_NONE 0x00
25376 +#define VCA_VXI 0x01
25377 +#define VCA_NXI 0x02
25379 +#define VCF_NONE 0x00
25380 +#define VCF_INFO 0x01
25381 +#define VCF_ADMIN 0x02
25382 +#define VCF_ARES 0x06 /* includes admin */
25383 +#define VCF_SETUP 0x08
25385 +#define VCF_ZIDOK 0x10 /* zero id okay */
25389 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25392 + int permit = -1, state = 0;
25393 + int perm = -1, args = 0, flags = 0;
25394 + struct vx_info *vxi = NULL;
25395 + struct nx_info *nxi = NULL;
25398 + /* unpriviledged commands */
25399 + __VCMD(get_version, 0, VCA_NONE, 0);
25400 + __VCMD(get_vci, 0, VCA_NONE, 0);
25401 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25402 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25403 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25404 + __VCMD(get_space_default,0, VCA_NONE, 0);
25406 + /* info commands */
25407 + __VCMD(task_xid, 2, VCA_NONE, 0);
25408 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25409 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25410 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25411 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25412 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25413 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25414 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25415 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25417 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25418 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25419 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25420 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25422 + __VCMD(task_nid, 2, VCA_NONE, 0);
25423 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25424 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25425 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25427 + __VCMD(task_tag, 2, VCA_NONE, 0);
25429 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25430 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25431 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25432 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25433 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25435 + /* lower admin commands */
25436 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25437 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25438 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25439 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25440 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25441 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25442 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25443 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25445 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25446 + __VCMD(net_create, 5, VCA_NONE, 0);
25447 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25449 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25451 + /* higher admin commands */
25452 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25453 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25454 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25456 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25457 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25458 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25459 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25461 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25462 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25463 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25464 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25466 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25467 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25468 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25469 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25470 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25471 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25472 +#ifdef CONFIG_IPV6
25473 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25474 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25476 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25477 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25478 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25479 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25480 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25482 +#ifdef CONFIG_VSERVER_DEVICE
25483 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25484 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25486 + /* debug level admin commands */
25487 +#ifdef CONFIG_VSERVER_HISTORY
25488 + __VCMD(dump_history, 9, VCA_NONE, 0);
25489 + __VCMD(read_history, 9, VCA_NONE, 0);
25491 +#ifdef CONFIG_VSERVER_MONITOR
25492 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25499 + vxdprintk(VXD_CBIT(switch, 0),
25500 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25501 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25502 + VC_VERSION(cmd), id, data, compat,
25503 + perm, args, flags);
25510 + if (!capable(CAP_CONTEXT))
25514 + /* moved here from the individual commands */
25516 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25520 + /* vcmd involves resource management */
25522 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25526 + /* various legacy exceptions */
25528 + /* will go away when spectator is a cap */
25529 + case VCMD_ctx_migrate_v0:
25530 + case VCMD_ctx_migrate:
25532 + current->xid = 1;
25538 + /* will go away when spectator is a cap */
25539 + case VCMD_net_migrate:
25541 + current->nid = 1;
25548 + /* vcmds are fine by default */
25551 + /* admin type vcmds require admin ... */
25552 + if (flags & VCF_ADMIN)
25553 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25555 + /* ... but setup type vcmds override that */
25556 + if (!permit && (flags & VCF_SETUP))
25557 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25565 + if (!id && (flags & VCF_ZIDOK))
25569 + if (args & VCA_VXI) {
25570 + vxi = lookup_vx_info(id);
25574 + if ((flags & VCF_ADMIN) &&
25575 + /* special case kill for shutdown */
25576 + (cmd != VCMD_ctx_kill) &&
25577 + /* can context be administrated? */
25578 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25584 + if (args & VCA_NXI) {
25585 + nxi = lookup_nx_info(id);
25589 + if ((flags & VCF_ADMIN) &&
25590 + /* can context be administrated? */
25591 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25598 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25601 + if ((args & VCA_NXI) && nxi)
25602 + put_nx_info(nxi);
25604 + if ((args & VCA_VXI) && vxi)
25605 + put_vx_info(vxi);
25607 + vxdprintk(VXD_CBIT(switch, 1),
25608 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25609 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25610 + VC_VERSION(cmd), ret, ret, state, permit);
25615 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25617 + return do_vserver(cmd, id, data, 0);
25620 +#ifdef CONFIG_COMPAT
25623 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25625 + return do_vserver(cmd, id, data, 1);
25628 +#endif /* CONFIG_COMPAT */
25629 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/sysctl.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sysctl.c
25630 --- linux-2.6.27.25/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25631 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/sysctl.c 2008-10-13 14:54:20.000000000 +0200
25634 + * kernel/vserver/sysctl.c
25636 + * Virtual Context Support
25638 + * Copyright (C) 2004-2007 Herbert Pötzl
25640 + * V0.01 basic structure
25644 +#include <linux/module.h>
25645 +#include <linux/ctype.h>
25646 +#include <linux/sysctl.h>
25647 +#include <linux/parser.h>
25648 +#include <asm/uaccess.h>
25652 + CTL_DEBUG_ERROR = 0,
25653 + CTL_DEBUG_SWITCH = 1,
25668 +unsigned int vx_debug_switch = 0;
25669 +unsigned int vx_debug_xid = 0;
25670 +unsigned int vx_debug_nid = 0;
25671 +unsigned int vx_debug_tag = 0;
25672 +unsigned int vx_debug_net = 0;
25673 +unsigned int vx_debug_limit = 0;
25674 +unsigned int vx_debug_cres = 0;
25675 +unsigned int vx_debug_dlim = 0;
25676 +unsigned int vx_debug_quota = 0;
25677 +unsigned int vx_debug_cvirt = 0;
25678 +unsigned int vx_debug_space = 0;
25679 +unsigned int vx_debug_misc = 0;
25682 +static struct ctl_table_header *vserver_table_header;
25683 +static ctl_table vserver_root_table[];
25686 +void vserver_register_sysctl(void)
25688 + if (!vserver_table_header) {
25689 + vserver_table_header = register_sysctl_table(vserver_root_table);
25694 +void vserver_unregister_sysctl(void)
25696 + if (vserver_table_header) {
25697 + unregister_sysctl_table(vserver_table_header);
25698 + vserver_table_header = NULL;
25703 +static int proc_dodebug(ctl_table *table, int write,
25704 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25706 + char tmpbuf[20], *p, c;
25707 + unsigned int value;
25708 + size_t left, len;
25710 + if ((*ppos && !write) || !*lenp) {
25718 + if (!access_ok(VERIFY_READ, buffer, left))
25720 + p = (char *)buffer;
25721 + while (left && __get_user(c, p) >= 0 && isspace(c))
25726 + if (left > sizeof(tmpbuf) - 1)
25728 + if (copy_from_user(tmpbuf, p, left))
25730 + tmpbuf[left] = '\0';
25732 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25733 + value = 10 * value + (*p - '0');
25734 + if (*p && !isspace(*p))
25736 + while (left && isspace(*p))
25738 + *(unsigned int *)table->data = value;
25740 + if (!access_ok(VERIFY_WRITE, buffer, left))
25742 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25745 + if (__copy_to_user(buffer, tmpbuf, len))
25747 + if ((left -= len) > 0) {
25748 + if (put_user('\n', (char *)buffer + len))
25762 +#define CTL_ENTRY(ctl, name) \
25764 + .ctl_name = ctl, \
25765 + .procname = #name, \
25766 + .data = &vx_ ## name, \
25767 + .maxlen = sizeof(int), \
25769 + .proc_handler = &proc_dodebug, \
25770 + .strategy = &sysctl_intvec, \
25771 + .extra1 = &zero, \
25774 +static ctl_table vserver_debug_table[] = {
25775 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25776 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25777 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25778 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25779 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25780 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25781 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25782 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25783 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25784 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25785 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25786 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25787 + { .ctl_name = 0 }
25790 +static ctl_table vserver_root_table[] = {
25792 + .ctl_name = CTL_VSERVER,
25793 + .procname = "vserver",
25795 + .child = vserver_debug_table
25797 + { .ctl_name = 0 }
25801 +static match_table_t tokens = {
25802 + { CTL_DEBUG_SWITCH, "switch=%x" },
25803 + { CTL_DEBUG_XID, "xid=%x" },
25804 + { CTL_DEBUG_NID, "nid=%x" },
25805 + { CTL_DEBUG_TAG, "tag=%x" },
25806 + { CTL_DEBUG_NET, "net=%x" },
25807 + { CTL_DEBUG_LIMIT, "limit=%x" },
25808 + { CTL_DEBUG_CRES, "cres=%x" },
25809 + { CTL_DEBUG_DLIM, "dlim=%x" },
25810 + { CTL_DEBUG_QUOTA, "quota=%x" },
25811 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25812 + { CTL_DEBUG_SPACE, "space=%x" },
25813 + { CTL_DEBUG_MISC, "misc=%x" },
25814 + { CTL_DEBUG_ERROR, NULL }
25817 +#define HANDLE_CASE(id, name, val) \
25818 + case CTL_DEBUG_ ## id: \
25819 + vx_debug_ ## name = val; \
25820 + printk("vs_debug_" #name "=0x%x\n", val); \
25824 +static int __init vs_debug_setup(char *str)
25829 + printk("vs_debug_setup(%s)\n", str);
25830 + while ((p = strsep(&str, ",")) != NULL) {
25831 + substring_t args[MAX_OPT_ARGS];
25832 + unsigned int value;
25837 + token = match_token(p, tokens, args);
25838 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25841 + HANDLE_CASE(SWITCH, switch, value);
25842 + HANDLE_CASE(XID, xid, value);
25843 + HANDLE_CASE(NID, nid, value);
25844 + HANDLE_CASE(TAG, tag, value);
25845 + HANDLE_CASE(NET, net, value);
25846 + HANDLE_CASE(LIMIT, limit, value);
25847 + HANDLE_CASE(CRES, cres, value);
25848 + HANDLE_CASE(DLIM, dlim, value);
25849 + HANDLE_CASE(QUOTA, quota, value);
25850 + HANDLE_CASE(CVIRT, cvirt, value);
25851 + HANDLE_CASE(SPACE, space, value);
25852 + HANDLE_CASE(MISC, misc, value);
25861 +__setup("vsdebug=", vs_debug_setup);
25865 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25866 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25867 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25868 +EXPORT_SYMBOL_GPL(vx_debug_net);
25869 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25870 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25871 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25872 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25873 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25874 +EXPORT_SYMBOL_GPL(vx_debug_space);
25875 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25877 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/tag.c linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/tag.c
25878 --- linux-2.6.27.25/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25879 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/tag.c 2008-10-13 14:54:20.000000000 +0200
25882 + * linux/kernel/vserver/tag.c
25884 + * Virtual Server: Shallow Tag Space
25886 + * Copyright (C) 2007 Herbert Pötzl
25888 + * V0.01 basic implementation
25892 +#include <linux/sched.h>
25893 +#include <linux/vserver/debug.h>
25894 +#include <linux/vs_pid.h>
25895 +#include <linux/vs_tag.h>
25897 +#include <linux/vserver/tag_cmd.h>
25900 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25905 + vxdprintk(VXD_CBIT(tag, 5),
25906 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25912 + vxdprintk(VXD_CBIT(tag, 5),
25913 + "moved task %p into [#%d]", p, tag);
25917 +/* vserver syscall commands below here */
25919 +/* taks xid and vx_info functions */
25922 +int vc_task_tag(uint32_t id)
25927 + struct task_struct *tsk;
25928 + read_lock(&tasklist_lock);
25929 + tsk = find_task_by_real_pid(id);
25930 + tag = (tsk) ? tsk->tag : -ESRCH;
25931 + read_unlock(&tasklist_lock);
25933 + tag = dx_current_tag();
25938 +int vc_tag_migrate(uint32_t tag)
25940 + return dx_migrate_task(current, tag & 0xFFFF);
25944 diff -NurpP --minimal linux-2.6.27.25/kernel/vserver/vci_config.h linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/vci_config.h
25945 --- linux-2.6.27.25/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25946 +++ linux-2.6.27.25-vs2.3.0.36.6/kernel/vserver/vci_config.h 2008-10-31 18:16:04.000000000 +0100
25949 +/* interface version */
25951 +#define VCI_VERSION 0x00020304
25955 + VCI_KCBIT_NO_DYNAMIC = 0,
25957 + VCI_KCBIT_PROC_SECURE = 4,
25958 + VCI_KCBIT_HARDCPU = 5,
25959 + VCI_KCBIT_IDLELIMIT = 6,
25960 + VCI_KCBIT_IDLETIME = 7,
25962 + VCI_KCBIT_COWBL = 8,
25963 + VCI_KCBIT_FULLCOWBL = 9,
25964 + VCI_KCBIT_SPACES = 10,
25965 + VCI_KCBIT_NETV2 = 11,
25967 + VCI_KCBIT_DEBUG = 16,
25968 + VCI_KCBIT_HISTORY = 20,
25969 + VCI_KCBIT_TAGGED = 24,
25970 + VCI_KCBIT_PPTAG = 28,
25972 + VCI_KCBIT_MORE = 31,
25976 +static inline uint32_t vci_kernel_config(void)
25979 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25981 + /* configured features */
25982 +#ifdef CONFIG_VSERVER_PROC_SECURE
25983 + (1 << VCI_KCBIT_PROC_SECURE) |
25985 +#ifdef CONFIG_VSERVER_HARDCPU
25986 + (1 << VCI_KCBIT_HARDCPU) |
25988 +#ifdef CONFIG_VSERVER_IDLELIMIT
25989 + (1 << VCI_KCBIT_IDLELIMIT) |
25991 +#ifdef CONFIG_VSERVER_IDLETIME
25992 + (1 << VCI_KCBIT_IDLETIME) |
25994 +#ifdef CONFIG_VSERVER_COWBL
25995 + (1 << VCI_KCBIT_COWBL) |
25996 + (1 << VCI_KCBIT_FULLCOWBL) |
25998 + (1 << VCI_KCBIT_SPACES) |
25999 + (1 << VCI_KCBIT_NETV2) |
26001 + /* debug options */
26002 +#ifdef CONFIG_VSERVER_DEBUG
26003 + (1 << VCI_KCBIT_DEBUG) |
26005 +#ifdef CONFIG_VSERVER_HISTORY
26006 + (1 << VCI_KCBIT_HISTORY) |
26009 + /* inode context tagging */
26010 +#if defined(CONFIG_TAGGING_NONE)
26011 + (0 << VCI_KCBIT_TAGGED) |
26012 +#elif defined(CONFIG_TAGGING_UID16)
26013 + (1 << VCI_KCBIT_TAGGED) |
26014 +#elif defined(CONFIG_TAGGING_GID16)
26015 + (2 << VCI_KCBIT_TAGGED) |
26016 +#elif defined(CONFIG_TAGGING_ID24)
26017 + (3 << VCI_KCBIT_TAGGED) |
26018 +#elif defined(CONFIG_TAGGING_INTERN)
26019 + (4 << VCI_KCBIT_TAGGED) |
26020 +#elif defined(CONFIG_TAGGING_RUNTIME)
26021 + (5 << VCI_KCBIT_TAGGED) |
26023 + (7 << VCI_KCBIT_TAGGED) |
26025 + (1 << VCI_KCBIT_PPTAG) |
26029 diff -NurpP --minimal linux-2.6.27.25/mm/filemap_xip.c linux-2.6.27.25-vs2.3.0.36.6/mm/filemap_xip.c
26030 --- linux-2.6.27.25/mm/filemap_xip.c 2009-06-15 17:18:33.000000000 +0200
26031 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/filemap_xip.c 2009-05-15 22:57:04.000000000 +0200
26033 #include <linux/sched.h>
26034 #include <linux/seqlock.h>
26035 #include <linux/mutex.h>
26036 +#include <linux/vs_memory.h>
26037 #include <asm/tlbflush.h>
26038 #include <asm/io.h>
26040 diff -NurpP --minimal linux-2.6.27.25/mm/fremap.c linux-2.6.27.25-vs2.3.0.36.6/mm/fremap.c
26041 --- linux-2.6.27.25/mm/fremap.c 2009-06-15 17:18:33.000000000 +0200
26042 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/fremap.c 2009-02-03 17:59:04.000000000 +0100
26044 #include <linux/module.h>
26045 #include <linux/syscalls.h>
26046 #include <linux/mmu_notifier.h>
26047 +#include <linux/vs_memory.h>
26049 #include <asm/mmu_context.h>
26050 #include <asm/cacheflush.h>
26051 diff -NurpP --minimal linux-2.6.27.25/mm/hugetlb.c linux-2.6.27.25-vs2.3.0.36.6/mm/hugetlb.c
26052 --- linux-2.6.27.25/mm/hugetlb.c 2009-06-15 17:18:33.000000000 +0200
26053 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/hugetlb.c 2009-06-15 17:22:10.000000000 +0200
26055 #include <asm/io.h>
26057 #include <linux/hugetlb.h>
26058 +#include <linux/vs_memory.h>
26059 #include "internal.h"
26061 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26062 diff -NurpP --minimal linux-2.6.27.25/mm/memory.c linux-2.6.27.25-vs2.3.0.36.6/mm/memory.c
26063 --- linux-2.6.27.25/mm/memory.c 2009-06-15 17:18:33.000000000 +0200
26064 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/memory.c 2009-05-22 00:47:40.000000000 +0200
26065 @@ -562,6 +562,9 @@ static int copy_pte_range(struct mm_stru
26069 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26073 rss[1] = rss[0] = 0;
26074 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26075 @@ -2340,6 +2343,11 @@ static int do_swap_page(struct mm_struct
26079 + if (!vx_rss_avail(mm, 1)) {
26080 + ret = VM_FAULT_OOM;
26084 mark_page_accessed(page);
26086 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
26087 @@ -2411,6 +2419,8 @@ static int do_anonymous_page(struct mm_s
26088 /* Allocate our own private page. */
26089 pte_unmap(page_table);
26091 + if (!vx_rss_avail(mm, 1))
26093 if (unlikely(anon_vma_prepare(vma)))
26095 page = alloc_zeroed_user_highpage_movable(vma, address);
26096 @@ -2688,6 +2698,7 @@ static inline int handle_pte_fault(struc
26100 + int ret = 0, type = VXPT_UNKNOWN;
26103 if (!pte_present(entry)) {
26104 @@ -2712,9 +2723,12 @@ static inline int handle_pte_fault(struc
26105 if (unlikely(!pte_same(*pte, entry)))
26107 if (write_access) {
26108 - if (!pte_write(entry))
26109 - return do_wp_page(mm, vma, address,
26110 + if (!pte_write(entry)) {
26111 + ret = do_wp_page(mm, vma, address,
26112 pte, pmd, ptl, entry);
26113 + type = VXPT_WRITE;
26116 entry = pte_mkdirty(entry);
26118 entry = pte_mkyoung(entry);
26119 @@ -2732,7 +2746,10 @@ static inline int handle_pte_fault(struc
26122 pte_unmap_unlock(pte, ptl);
26126 + vx_page_fault(mm, vma, type, ret);
26131 diff -NurpP --minimal linux-2.6.27.25/mm/mlock.c linux-2.6.27.25-vs2.3.0.36.6/mm/mlock.c
26132 --- linux-2.6.27.25/mm/mlock.c 2009-06-15 17:18:33.000000000 +0200
26133 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/mlock.c 2009-02-03 17:59:04.000000000 +0100
26135 #include <linux/syscalls.h>
26136 #include <linux/sched.h>
26137 #include <linux/module.h>
26138 +#include <linux/vs_memory.h>
26140 int can_do_mlock(void)
26142 @@ -76,7 +77,7 @@ success:
26143 ret = make_pages_present(start, end);
26146 - mm->locked_vm -= pages;
26147 + vx_vmlocked_sub(mm, pages);
26151 @@ -132,7 +133,7 @@ static int do_mlock(unsigned long start,
26153 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26155 - unsigned long locked;
26156 + unsigned long locked, grow;
26157 unsigned long lock_limit;
26158 int error = -ENOMEM;
26160 @@ -143,8 +144,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26161 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26162 start &= PAGE_MASK;
26164 - locked = len >> PAGE_SHIFT;
26165 - locked += current->mm->locked_vm;
26166 + grow = len >> PAGE_SHIFT;
26167 + if (!vx_vmlocked_avail(current->mm, grow))
26169 + locked = current->mm->locked_vm + grow;
26171 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26172 lock_limit >>= PAGE_SHIFT;
26173 @@ -152,6 +155,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26174 /* check against resource limits */
26175 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26176 error = do_mlock(start, len, 1);
26178 up_write(¤t->mm->mmap_sem);
26181 @@ -211,6 +215,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
26182 lock_limit >>= PAGE_SHIFT;
26185 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26187 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26188 capable(CAP_IPC_LOCK))
26189 ret = do_mlockall(flags);
26190 diff -NurpP --minimal linux-2.6.27.25/mm/mmap.c linux-2.6.27.25-vs2.3.0.36.6/mm/mmap.c
26191 --- linux-2.6.27.25/mm/mmap.c 2009-06-15 17:18:33.000000000 +0200
26192 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/mmap.c 2009-05-15 22:57:04.000000000 +0200
26193 @@ -1221,10 +1221,10 @@ munmap_back:
26194 if (correct_wcount)
26195 atomic_inc(&inode->i_writecount);
26197 - mm->total_vm += len >> PAGE_SHIFT;
26198 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26199 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26200 if (vm_flags & VM_LOCKED) {
26201 - mm->locked_vm += len >> PAGE_SHIFT;
26202 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26203 make_pages_present(addr, addr + len);
26205 if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
26206 @@ -1573,9 +1573,9 @@ static int acct_stack_growth(struct vm_a
26209 /* Ok, everything looks good - let it rip */
26210 - mm->total_vm += grow;
26211 + vx_vmpages_add(mm, grow);
26212 if (vma->vm_flags & VM_LOCKED)
26213 - mm->locked_vm += grow;
26214 + vx_vmlocked_add(mm, grow);
26215 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26218 @@ -1746,9 +1746,9 @@ static void remove_vma_list(struct mm_st
26220 long nrpages = vma_pages(vma);
26222 - mm->total_vm -= nrpages;
26223 + vx_vmpages_sub(mm, nrpages);
26224 if (vma->vm_flags & VM_LOCKED)
26225 - mm->locked_vm -= nrpages;
26226 + vx_vmlocked_sub(mm, nrpages);
26227 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26228 vma = remove_vma(vma);
26230 @@ -1995,6 +1995,8 @@ unsigned long do_brk(unsigned long addr,
26231 lock_limit >>= PAGE_SHIFT;
26232 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26234 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26239 @@ -2021,7 +2023,8 @@ unsigned long do_brk(unsigned long addr,
26240 if (mm->map_count > sysctl_max_map_count)
26243 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26244 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26245 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26248 /* Can we just expand an old private anonymous mapping? */
26249 @@ -2046,9 +2049,9 @@ unsigned long do_brk(unsigned long addr,
26250 vma->vm_page_prot = vm_get_page_prot(flags);
26251 vma_link(mm, vma, prev, rb_link, rb_parent);
26253 - mm->total_vm += len >> PAGE_SHIFT;
26254 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26255 if (flags & VM_LOCKED) {
26256 - mm->locked_vm += len >> PAGE_SHIFT;
26257 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26258 make_pages_present(addr, addr + len);
26261 @@ -2081,6 +2084,11 @@ void exit_mmap(struct mm_struct *mm)
26262 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
26263 tlb_finish_mmu(tlb, 0, end);
26265 + set_mm_counter(mm, file_rss, 0);
26266 + set_mm_counter(mm, anon_rss, 0);
26267 + vx_vmpages_sub(mm, mm->total_vm);
26268 + vx_vmlocked_sub(mm, mm->locked_vm);
26271 * Walk the list again, actually closing and freeing it,
26272 * with preemption enabled, without holding any MM locks.
26273 @@ -2120,7 +2128,8 @@ int insert_vm_struct(struct mm_struct *
26274 if (__vma && __vma->vm_start < vma->vm_end)
26276 if ((vma->vm_flags & VM_ACCOUNT) &&
26277 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
26278 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
26279 + !vx_vmpages_avail(mm, vma_pages(vma))))
26281 vma_link(mm, vma, prev, rb_link, rb_parent);
26283 @@ -2196,6 +2205,8 @@ int may_expand_vm(struct mm_struct *mm,
26285 if (cur + npages > lim)
26287 + if (!vx_vmpages_avail(mm, npages))
26292 @@ -2273,8 +2284,7 @@ int install_special_mapping(struct mm_st
26296 - mm->total_vm += len >> PAGE_SHIFT;
26298 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26302 diff -NurpP --minimal linux-2.6.27.25/mm/mremap.c linux-2.6.27.25-vs2.3.0.36.6/mm/mremap.c
26303 --- linux-2.6.27.25/mm/mremap.c 2009-06-15 17:18:34.000000000 +0200
26304 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/mremap.c 2009-02-03 17:59:04.000000000 +0100
26306 #include <linux/security.h>
26307 #include <linux/syscalls.h>
26308 #include <linux/mmu_notifier.h>
26309 +#include <linux/vs_memory.h>
26311 #include <asm/uaccess.h>
26312 #include <asm/cacheflush.h>
26313 @@ -218,7 +219,7 @@ static unsigned long move_vma(struct vm_
26314 * If this were a serious issue, we'd add a flag to do_munmap().
26316 hiwater_vm = mm->hiwater_vm;
26317 - mm->total_vm += new_len >> PAGE_SHIFT;
26318 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26319 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26321 if (do_munmap(mm, old_addr, old_len) < 0) {
26322 @@ -236,7 +237,7 @@ static unsigned long move_vma(struct vm_
26325 if (vm_flags & VM_LOCKED) {
26326 - mm->locked_vm += new_len >> PAGE_SHIFT;
26327 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26328 if (new_len > old_len)
26329 make_pages_present(new_addr + old_len,
26330 new_addr + new_len);
26331 @@ -347,6 +348,9 @@ unsigned long do_mremap(unsigned long ad
26333 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26335 + if (!vx_vmlocked_avail(current->mm,
26336 + (new_len - old_len) >> PAGE_SHIFT))
26339 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
26341 @@ -375,10 +379,10 @@ unsigned long do_mremap(unsigned long ad
26342 vma_adjust(vma, vma->vm_start,
26343 addr + new_len, vma->vm_pgoff, NULL);
26345 - mm->total_vm += pages;
26346 + vx_vmpages_add(mm, pages);
26347 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26348 if (vma->vm_flags & VM_LOCKED) {
26349 - mm->locked_vm += pages;
26350 + vx_vmlocked_add(mm, pages);
26351 make_pages_present(addr + old_len,
26354 diff -NurpP --minimal linux-2.6.27.25/mm/nommu.c linux-2.6.27.25-vs2.3.0.36.6/mm/nommu.c
26355 --- linux-2.6.27.25/mm/nommu.c 2009-06-15 17:18:34.000000000 +0200
26356 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/nommu.c 2009-02-03 17:59:04.000000000 +0100
26357 @@ -1028,7 +1028,7 @@ unsigned long do_mmap_pgoff(struct file
26358 realalloc += kobjsize(vma);
26359 askedalloc += sizeof(*vma);
26361 - current->mm->total_vm += len >> PAGE_SHIFT;
26362 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26364 add_nommu_vma(vma);
26366 @@ -1160,7 +1160,7 @@ int do_munmap(struct mm_struct *mm, unsi
26369 update_hiwater_vm(mm);
26370 - mm->total_vm -= len >> PAGE_SHIFT;
26371 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
26374 show_process_blocks();
26375 @@ -1193,7 +1193,7 @@ void exit_mmap(struct mm_struct * mm)
26376 printk("Exit_mmap:\n");
26379 - mm->total_vm = 0;
26380 + vx_vmpages_sub(mm, mm->total_vm);
26382 while ((tmp = mm->context.vmlist)) {
26383 mm->context.vmlist = tmp->next;
26384 diff -NurpP --minimal linux-2.6.27.25/mm/oom_kill.c linux-2.6.27.25-vs2.3.0.36.6/mm/oom_kill.c
26385 --- linux-2.6.27.25/mm/oom_kill.c 2008-10-13 14:52:09.000000000 +0200
26386 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/oom_kill.c 2008-10-13 14:54:20.000000000 +0200
26388 #include <linux/notifier.h>
26389 #include <linux/memcontrol.h>
26390 #include <linux/security.h>
26391 +#include <linux/vs_memory.h>
26393 int sysctl_panic_on_oom;
26394 int sysctl_oom_kill_allocating_task;
26395 @@ -73,6 +74,12 @@ unsigned long badness(struct task_struct
26396 points = mm->total_vm;
26399 + * add points for context badness
26402 + points += vx_badness(p, mm);
26405 * After this unlock we can no longer dereference local variable `mm'
26408 @@ -163,8 +170,8 @@ unsigned long badness(struct task_struct
26412 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26413 - p->pid, p->comm, points);
26414 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26415 + task_pid_nr(p), p->xid, p->comm, points);
26419 @@ -325,8 +332,8 @@ static void __oom_kill_task(struct task_
26423 - printk(KERN_ERR "Killed process %d (%s)\n",
26424 - task_pid_nr(p), p->comm);
26425 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
26426 + task_pid_nr(p), p->xid, p->comm);
26429 * We give our sacrificial lamb high priority and access to
26430 @@ -406,8 +413,8 @@ static int oom_kill_process(struct task_
26434 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26435 - message, task_pid_nr(p), p->comm, points);
26436 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
26437 + message, task_pid_nr(p), p->xid, p->comm, points);
26439 /* Try to kill a child first */
26440 list_for_each_entry(c, &p->children, sibling) {
26441 diff -NurpP --minimal linux-2.6.27.25/mm/page_alloc.c linux-2.6.27.25-vs2.3.0.36.6/mm/page_alloc.c
26442 --- linux-2.6.27.25/mm/page_alloc.c 2009-06-15 17:18:34.000000000 +0200
26443 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/page_alloc.c 2009-03-25 14:32:29.000000000 +0100
26445 #include <linux/page-isolation.h>
26446 #include <linux/memcontrol.h>
26447 #include <linux/debugobjects.h>
26448 +#include <linux/vs_base.h>
26449 +#include <linux/vs_limit.h>
26451 #include <asm/tlbflush.h>
26452 #include <asm/div64.h>
26453 @@ -1823,6 +1825,9 @@ void si_meminfo(struct sysinfo *val)
26454 val->totalhigh = totalhigh_pages;
26455 val->freehigh = nr_free_highpages();
26456 val->mem_unit = PAGE_SIZE;
26458 + if (vx_flags(VXF_VIRT_MEM, 0))
26459 + vx_vsi_meminfo(val);
26462 EXPORT_SYMBOL(si_meminfo);
26463 @@ -1843,6 +1848,9 @@ void si_meminfo_node(struct sysinfo *val
26466 val->mem_unit = PAGE_SIZE;
26468 + if (vx_flags(VXF_VIRT_MEM, 0))
26469 + vx_vsi_meminfo(val);
26473 diff -NurpP --minimal linux-2.6.27.25/mm/rmap.c linux-2.6.27.25-vs2.3.0.36.6/mm/rmap.c
26474 --- linux-2.6.27.25/mm/rmap.c 2009-06-15 17:18:34.000000000 +0200
26475 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/rmap.c 2009-02-03 17:59:04.000000000 +0100
26477 #include <linux/kallsyms.h>
26478 #include <linux/memcontrol.h>
26479 #include <linux/mmu_notifier.h>
26480 +#include <linux/vs_memory.h>
26482 #include <asm/tlbflush.h>
26484 diff -NurpP --minimal linux-2.6.27.25/mm/shmem.c linux-2.6.27.25-vs2.3.0.36.6/mm/shmem.c
26485 --- linux-2.6.27.25/mm/shmem.c 2008-10-13 14:52:09.000000000 +0200
26486 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/shmem.c 2008-10-13 14:54:20.000000000 +0200
26488 #include <asm/pgtable.h>
26490 /* This magic number is used in glibc for posix shared memory */
26491 -#define TMPFS_MAGIC 0x01021994
26493 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
26494 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
26495 @@ -1738,7 +1737,7 @@ static int shmem_statfs(struct dentry *d
26497 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26499 - buf->f_type = TMPFS_MAGIC;
26500 + buf->f_type = TMPFS_SUPER_MAGIC;
26501 buf->f_bsize = PAGE_CACHE_SIZE;
26502 buf->f_namelen = NAME_MAX;
26503 spin_lock(&sbinfo->stat_lock);
26504 @@ -2306,7 +2305,7 @@ static int shmem_fill_super(struct super
26505 sb->s_maxbytes = SHMEM_MAX_BYTES;
26506 sb->s_blocksize = PAGE_CACHE_SIZE;
26507 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26508 - sb->s_magic = TMPFS_MAGIC;
26509 + sb->s_magic = TMPFS_SUPER_MAGIC;
26510 sb->s_op = &shmem_ops;
26511 sb->s_time_gran = 1;
26512 #ifdef CONFIG_TMPFS_POSIX_ACL
26513 diff -NurpP --minimal linux-2.6.27.25/mm/slab.c linux-2.6.27.25-vs2.3.0.36.6/mm/slab.c
26514 --- linux-2.6.27.25/mm/slab.c 2008-10-13 14:52:09.000000000 +0200
26515 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/slab.c 2008-10-13 14:54:20.000000000 +0200
26516 @@ -508,6 +508,8 @@ struct kmem_cache {
26517 #define STATS_INC_FREEMISS(x) do { } while (0)
26520 +#include "slab_vs.h"
26525 @@ -3337,6 +3339,7 @@ retry:
26527 obj = slab_get_obj(cachep, slabp, nodeid);
26528 check_slabp(cachep, slabp);
26529 + vx_slab_alloc(cachep, flags);
26530 l3->free_objects--;
26531 /* move slabp to correct slabp list: */
26532 list_del(&slabp->list);
26533 @@ -3409,6 +3412,7 @@ __cache_alloc_node(struct kmem_cache *ca
26534 /* ___cache_alloc_node can fall back to other nodes */
26535 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26537 + vx_slab_alloc(cachep, flags);
26538 local_irq_restore(save_flags);
26539 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26541 @@ -3580,6 +3584,7 @@ static inline void __cache_free(struct k
26544 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26545 + vx_slab_free(cachep);
26548 * Skip calling cache_free_alien() when the platform is not numa.
26549 diff -NurpP --minimal linux-2.6.27.25/mm/slab_vs.h linux-2.6.27.25-vs2.3.0.36.6/mm/slab_vs.h
26550 --- linux-2.6.27.25/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26551 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/slab_vs.h 2008-10-13 14:54:20.000000000 +0200
26554 +#include <linux/vserver/context.h>
26556 +#include <linux/vs_context.h>
26559 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26561 + int what = gfp_zone(cachep->gfpflags);
26563 + if (!current->vx_info)
26566 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26570 +void vx_slab_free(struct kmem_cache *cachep)
26572 + int what = gfp_zone(cachep->gfpflags);
26574 + if (!current->vx_info)
26577 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26580 diff -NurpP --minimal linux-2.6.27.25/mm/swapfile.c linux-2.6.27.25-vs2.3.0.36.6/mm/swapfile.c
26581 --- linux-2.6.27.25/mm/swapfile.c 2009-06-15 17:18:34.000000000 +0200
26582 +++ linux-2.6.27.25-vs2.3.0.36.6/mm/swapfile.c 2009-02-03 17:59:04.000000000 +0100
26584 #include <asm/pgtable.h>
26585 #include <asm/tlbflush.h>
26586 #include <linux/swapops.h>
26587 +#include <linux/vs_base.h>
26588 +#include <linux/vs_memory.h>
26590 static DEFINE_SPINLOCK(swap_lock);
26591 static unsigned int nr_swapfiles;
26592 @@ -1748,6 +1750,8 @@ void si_swapinfo(struct sysinfo *val)
26593 val->freeswap = nr_swap_pages + nr_to_be_unused;
26594 val->totalswap = total_swap_pages + nr_to_be_unused;
26595 spin_unlock(&swap_lock);
26596 + if (vx_flags(VXF_VIRT_MEM, 0))
26597 + vx_vsi_swapinfo(val);
26601 diff -NurpP --minimal linux-2.6.27.25/net/core/dev.c linux-2.6.27.25-vs2.3.0.36.6/net/core/dev.c
26602 --- linux-2.6.27.25/net/core/dev.c 2009-06-15 17:18:34.000000000 +0200
26603 +++ linux-2.6.27.25-vs2.3.0.36.6/net/core/dev.c 2009-02-22 22:58:33.000000000 +0100
26604 @@ -127,6 +127,7 @@
26605 #include <linux/in.h>
26606 #include <linux/jhash.h>
26607 #include <linux/random.h>
26608 +#include <linux/vs_inet.h>
26610 #include "net-sysfs.h"
26612 @@ -925,10 +926,15 @@ int dev_change_name(struct net_device *d
26613 strlcpy(dev->name, newname, IFNAMSIZ);
26616 - err = device_rename(&dev->dev, dev->name);
26618 - memcpy(dev->name, oldname, IFNAMSIZ);
26620 + /* For now only devices in the initial network namespace
26623 + if (net == &init_net) {
26624 + ret = device_rename(&dev->dev, dev->name);
26626 + memcpy(dev->name, oldname, IFNAMSIZ);
26631 write_lock_bh(&dev_base_lock);
26632 @@ -2518,6 +2524,8 @@ static int dev_ifconf(struct net *net, c
26635 for_each_netdev(net, dev) {
26636 + if (!nx_dev_visible(current->nx_info, dev))
26638 for (i = 0; i < NPROTO; i++) {
26639 if (gifconf_list[i]) {
26641 @@ -2586,6 +2594,9 @@ static void dev_seq_printf_stats(struct
26643 struct net_device_stats *stats = dev->get_stats(dev);
26645 + if (!nx_dev_visible(current->nx_info, dev))
26648 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26649 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26650 dev->name, stats->rx_bytes, stats->rx_packets,
26651 @@ -4388,6 +4399,15 @@ int dev_change_net_namespace(struct net_
26652 if (dev->features & NETIF_F_NETNS_LOCAL)
26655 +#ifdef CONFIG_SYSFS
26656 + /* Don't allow real devices to be moved when sysfs
26660 + if (dev->dev.parent)
26664 /* Ensure the device has been registrered */
26666 if (dev->reg_state != NETREG_REGISTERED)
26667 @@ -4445,6 +4465,8 @@ int dev_change_net_namespace(struct net_
26669 dev_addr_discard(dev);
26671 + netdev_unregister_kobject(dev);
26673 /* Actually switch the network namespace */
26674 dev_net_set(dev, net);
26676 @@ -4461,7 +4483,6 @@ int dev_change_net_namespace(struct net_
26679 /* Fixup kobjects */
26680 - netdev_unregister_kobject(dev);
26681 err = netdev_register_kobject(dev);
26684 diff -NurpP --minimal linux-2.6.27.25/net/core/net-sysfs.c linux-2.6.27.25-vs2.3.0.36.6/net/core/net-sysfs.c
26685 --- linux-2.6.27.25/net/core/net-sysfs.c 2008-10-13 14:52:09.000000000 +0200
26686 +++ linux-2.6.27.25-vs2.3.0.36.6/net/core/net-sysfs.c 2008-11-20 15:21:32.000000000 +0100
26687 @@ -440,6 +440,10 @@ void netdev_unregister_kobject(struct ne
26688 struct device *dev = &(net->dev);
26690 kobject_get(&dev->kobj);
26692 + if (dev_net(net) != &init_net)
26698 @@ -465,6 +469,9 @@ int netdev_register_kobject(struct net_d
26700 #endif /* CONFIG_SYSFS */
26702 + if (dev_net(net) != &init_net)
26705 return device_add(dev);
26708 diff -NurpP --minimal linux-2.6.27.25/net/core/rtnetlink.c linux-2.6.27.25-vs2.3.0.36.6/net/core/rtnetlink.c
26709 --- linux-2.6.27.25/net/core/rtnetlink.c 2008-10-13 14:52:09.000000000 +0200
26710 +++ linux-2.6.27.25-vs2.3.0.36.6/net/core/rtnetlink.c 2008-10-13 14:54:20.000000000 +0200
26711 @@ -686,6 +686,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26714 for_each_netdev(net, dev) {
26715 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26719 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26720 @@ -1219,6 +1221,9 @@ void rtmsg_ifinfo(int type, struct net_d
26721 struct sk_buff *skb;
26722 int err = -ENOBUFS;
26724 + if (!nx_dev_visible(current->nx_info, dev))
26727 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26730 diff -NurpP --minimal linux-2.6.27.25/net/core/sock.c linux-2.6.27.25-vs2.3.0.36.6/net/core/sock.c
26731 --- linux-2.6.27.25/net/core/sock.c 2009-06-15 17:18:34.000000000 +0200
26732 +++ linux-2.6.27.25-vs2.3.0.36.6/net/core/sock.c 2009-03-25 14:32:29.000000000 +0100
26733 @@ -124,6 +124,10 @@
26734 #include <linux/ipsec.h>
26736 #include <linux/filter.h>
26737 +#include <linux/vs_socket.h>
26738 +#include <linux/vs_limit.h>
26739 +#include <linux/vs_context.h>
26740 +#include <linux/vs_network.h>
26743 #include <net/tcp.h>
26744 @@ -899,6 +903,8 @@ static struct sock *sk_prot_alloc(struct
26745 if (!try_module_get(prot->owner))
26748 + sock_vx_init(sk);
26749 + sock_nx_init(sk);
26753 @@ -975,6 +981,11 @@ void sk_free(struct sock *sk)
26754 __func__, atomic_read(&sk->sk_omem_alloc));
26756 put_net(sock_net(sk));
26758 + clr_vx_info(&sk->sk_vx_info);
26760 + clr_nx_info(&sk->sk_nx_info);
26762 sk_prot_free(sk->sk_prot_creator, sk);
26765 @@ -1010,6 +1021,8 @@ struct sock *sk_clone(const struct sock
26768 get_net(sock_net(newsk));
26769 + sock_vx_init(newsk);
26770 + sock_nx_init(newsk);
26771 sk_node_init(&newsk->sk_node);
26772 sock_lock_init(newsk);
26773 bh_lock_sock(newsk);
26774 @@ -1056,6 +1069,12 @@ struct sock *sk_clone(const struct sock
26775 newsk->sk_priority = 0;
26776 atomic_set(&newsk->sk_refcnt, 2);
26778 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26779 + newsk->sk_xid = sk->sk_xid;
26780 + vx_sock_inc(newsk);
26781 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26782 + newsk->sk_nid = sk->sk_nid;
26785 * Increment the counter in the same struct proto as the master
26786 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26787 @@ -1739,6 +1758,11 @@ void sock_init_data(struct socket *sock,
26789 sk->sk_stamp = ktime_set(-1L, 0);
26791 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26792 + sk->sk_xid = vx_current_xid();
26794 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26795 + sk->sk_nid = nx_current_nid();
26796 atomic_set(&sk->sk_refcnt, 1);
26797 atomic_set(&sk->sk_drops, 0);
26799 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/af_inet.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/af_inet.c
26800 --- linux-2.6.27.25/net/ipv4/af_inet.c 2008-10-13 14:52:09.000000000 +0200
26801 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/af_inet.c 2008-10-13 14:54:20.000000000 +0200
26802 @@ -114,6 +114,7 @@
26803 #ifdef CONFIG_IP_MROUTE
26804 #include <linux/mroute.h>
26806 +#include <linux/vs_limit.h>
26808 extern void ip_mc_drop_socket(struct sock *sk);
26810 @@ -325,9 +326,12 @@ lookup_protocol:
26814 + if ((protocol == IPPROTO_ICMP) &&
26815 + nx_capable(answer->capability, NXC_RAW_ICMP))
26817 if (answer->capability > 0 && !capable(answer->capability))
26818 goto out_rcu_unlock;
26821 err = -EAFNOSUPPORT;
26822 if (!inet_netns_ok(net, protocol))
26823 goto out_rcu_unlock;
26824 @@ -445,6 +449,7 @@ int inet_bind(struct socket *sock, struc
26825 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26826 struct sock *sk = sock->sk;
26827 struct inet_sock *inet = inet_sk(sk);
26828 + struct nx_v4_sock_addr nsa;
26829 unsigned short snum;
26832 @@ -458,7 +463,11 @@ int inet_bind(struct socket *sock, struc
26833 if (addr_len < sizeof(struct sockaddr_in))
26836 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26837 + err = v4_map_sock_addr(inet, addr, &nsa);
26841 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26843 /* Not specified by any standard per-se, however it breaks too
26844 * many applications when removed. It is unfortunate since
26845 @@ -470,7 +479,7 @@ int inet_bind(struct socket *sock, struc
26846 err = -EADDRNOTAVAIL;
26847 if (!sysctl_ip_nonlocal_bind &&
26849 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26850 + nsa.saddr != htonl(INADDR_ANY) &&
26851 chk_addr_ret != RTN_LOCAL &&
26852 chk_addr_ret != RTN_MULTICAST &&
26853 chk_addr_ret != RTN_BROADCAST)
26854 @@ -495,7 +504,7 @@ int inet_bind(struct socket *sock, struc
26855 if (sk->sk_state != TCP_CLOSE || inet->num)
26856 goto out_release_sock;
26858 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26859 + v4_set_sock_addr(inet, &nsa);
26860 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26861 inet->saddr = 0; /* Use device */
26863 @@ -688,11 +697,13 @@ int inet_getname(struct socket *sock, st
26866 sin->sin_port = inet->dport;
26867 - sin->sin_addr.s_addr = inet->daddr;
26868 + sin->sin_addr.s_addr =
26869 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26871 __be32 addr = inet->rcv_saddr;
26873 addr = inet->saddr;
26874 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26875 sin->sin_port = inet->sport;
26876 sin->sin_addr.s_addr = addr;
26878 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/devinet.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/devinet.c
26879 --- linux-2.6.27.25/net/ipv4/devinet.c 2008-10-13 14:52:09.000000000 +0200
26880 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/devinet.c 2008-10-13 14:54:20.000000000 +0200
26881 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
26886 /* Called only from RTNL semaphored context. No locks. */
26888 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26889 @@ -662,6 +663,8 @@ int devinet_ioctl(struct net *net, unsig
26892 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26893 + struct nx_info *nxi = current->nx_info;
26895 if (tryaddrmatch) {
26896 /* Matthias Andree */
26897 /* compare label and address (4.4BSD style) */
26898 @@ -670,6 +673,8 @@ int devinet_ioctl(struct net *net, unsig
26899 This is checked above. */
26900 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26901 ifap = &ifa->ifa_next) {
26902 + if (!nx_v4_ifa_visible(nxi, ifa))
26904 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26905 sin_orig.sin_addr.s_addr ==
26906 ifa->ifa_address) {
26907 @@ -682,9 +687,12 @@ int devinet_ioctl(struct net *net, unsig
26908 comparing just the label */
26910 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26911 - ifap = &ifa->ifa_next)
26912 + ifap = &ifa->ifa_next) {
26913 + if (!nx_v4_ifa_visible(nxi, ifa))
26915 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26921 @@ -835,6 +843,8 @@ static int inet_gifconf(struct net_devic
26924 for (; ifa; ifa = ifa->ifa_next) {
26925 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
26928 done += sizeof(ifr);
26930 @@ -1165,6 +1175,7 @@ static int inet_dump_ifaddr(struct sk_bu
26931 struct net_device *dev;
26932 struct in_device *in_dev;
26933 struct in_ifaddr *ifa;
26934 + struct sock *sk = skb->sk;
26935 int s_ip_idx, s_idx = cb->args[0];
26937 s_ip_idx = ip_idx = cb->args[1];
26938 @@ -1179,6 +1190,8 @@ static int inet_dump_ifaddr(struct sk_bu
26940 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26941 ifa = ifa->ifa_next, ip_idx++) {
26942 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26944 if (ip_idx < s_ip_idx)
26946 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
26947 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/fib_hash.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/fib_hash.c
26948 --- linux-2.6.27.25/net/ipv4/fib_hash.c 2008-10-13 14:52:09.000000000 +0200
26949 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/fib_hash.c 2008-10-13 14:54:20.000000000 +0200
26950 @@ -1022,7 +1022,7 @@ static int fib_seq_show(struct seq_file
26951 prefix = f->fn_key;
26952 mask = FZ_MASK(iter->zone);
26953 flags = fib_flag_trans(fa->fa_type, mask, fi);
26955 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
26957 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
26958 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26959 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/inet_connection_sock.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/inet_connection_sock.c
26960 --- linux-2.6.27.25/net/ipv4/inet_connection_sock.c 2008-10-13 14:52:09.000000000 +0200
26961 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/inet_connection_sock.c 2008-10-13 14:54:20.000000000 +0200
26962 @@ -47,10 +47,40 @@ void inet_get_local_port_range(int *low,
26964 EXPORT_SYMBOL(inet_get_local_port_range);
26966 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26968 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
26969 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26971 + if (inet_v6_ipv6only(sk2))
26974 + if (sk1_rcv_saddr &&
26976 + sk1_rcv_saddr == sk2_rcv_saddr)
26979 + if (sk1_rcv_saddr &&
26980 + !sk2_rcv_saddr &&
26981 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26984 + if (sk2_rcv_saddr &&
26985 + !sk1_rcv_saddr &&
26986 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26989 + if (!sk1_rcv_saddr &&
26990 + !sk2_rcv_saddr &&
26991 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26997 int inet_csk_bind_conflict(const struct sock *sk,
26998 const struct inet_bind_bucket *tb)
27000 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27002 struct hlist_node *node;
27003 int reuse = sk->sk_reuse;
27004 @@ -70,9 +100,7 @@ int inet_csk_bind_conflict(const struct
27005 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27006 if (!reuse || !sk2->sk_reuse ||
27007 sk2->sk_state == TCP_LISTEN) {
27008 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27009 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27010 - sk2_rcv_saddr == sk_rcv_saddr)
27011 + if (ipv4_rcv_saddr_equal(sk, sk2))
27015 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/inet_diag.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/inet_diag.c
27016 --- linux-2.6.27.25/net/ipv4/inet_diag.c 2008-10-13 14:52:09.000000000 +0200
27017 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/inet_diag.c 2008-10-13 14:54:20.000000000 +0200
27019 #include <linux/stddef.h>
27021 #include <linux/inet_diag.h>
27022 +#include <linux/vs_network.h>
27023 +#include <linux/vs_inet.h>
27025 static const struct inet_diag_handler **inet_diag_table;
27027 @@ -120,8 +122,8 @@ static int inet_csk_diag_fill(struct soc
27029 r->id.idiag_sport = inet->sport;
27030 r->id.idiag_dport = inet->dport;
27031 - r->id.idiag_src[0] = inet->rcv_saddr;
27032 - r->id.idiag_dst[0] = inet->daddr;
27033 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
27034 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
27036 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27037 if (r->idiag_family == AF_INET6) {
27038 @@ -208,8 +210,8 @@ static int inet_twsk_diag_fill(struct in
27039 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27040 r->id.idiag_sport = tw->tw_sport;
27041 r->id.idiag_dport = tw->tw_dport;
27042 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
27043 - r->id.idiag_dst[0] = tw->tw_daddr;
27044 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27045 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27046 r->idiag_state = tw->tw_substate;
27047 r->idiag_timer = 3;
27048 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
27049 @@ -266,6 +268,7 @@ static int inet_diag_get_exact(struct sk
27052 if (req->idiag_family == AF_INET) {
27053 + /* TODO: lback */
27054 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27055 req->id.idiag_dport, req->id.idiag_src[0],
27056 req->id.idiag_sport, req->id.idiag_if);
27057 @@ -508,6 +511,7 @@ static int inet_csk_diag_dump(struct soc
27061 + /* TODO: lback */
27062 entry.saddr = &inet->rcv_saddr;
27063 entry.daddr = &inet->daddr;
27065 @@ -544,6 +548,7 @@ static int inet_twsk_diag_dump(struct in
27069 + /* TODO: lback */
27070 entry.saddr = &tw->tw_rcv_saddr;
27071 entry.daddr = &tw->tw_daddr;
27073 @@ -590,8 +595,8 @@ static int inet_diag_fill_req(struct sk_
27075 r->id.idiag_sport = inet->sport;
27076 r->id.idiag_dport = ireq->rmt_port;
27077 - r->id.idiag_src[0] = ireq->loc_addr;
27078 - r->id.idiag_dst[0] = ireq->rmt_addr;
27079 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27080 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27081 r->idiag_expires = jiffies_to_msecs(tmo);
27082 r->idiag_rqueue = 0;
27083 r->idiag_wqueue = 0;
27084 @@ -661,6 +666,7 @@ static int inet_diag_dump_reqs(struct sk
27088 + /* TODO: lback */
27090 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27091 (entry.family == AF_INET6) ?
27092 @@ -729,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
27093 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
27094 struct inet_sock *inet = inet_sk(sk);
27096 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27101 @@ -790,6 +798,8 @@ skip_listen_ht:
27102 sk_for_each(sk, node, &head->chain) {
27103 struct inet_sock *inet = inet_sk(sk);
27105 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27109 if (!(r->idiag_states & (1 << sk->sk_state)))
27110 @@ -814,6 +824,8 @@ next_normal:
27111 inet_twsk_for_each(tw, node,
27114 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27118 if (r->id.idiag_sport != tw->tw_sport &&
27119 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/inet_hashtables.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/inet_hashtables.c
27120 --- linux-2.6.27.25/net/ipv4/inet_hashtables.c 2008-10-13 14:52:09.000000000 +0200
27121 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/inet_hashtables.c 2008-10-13 14:54:20.000000000 +0200
27124 #include <net/inet_connection_sock.h>
27125 #include <net/inet_hashtables.h>
27126 +#include <net/route.h>
27127 #include <net/ip.h>
27130 @@ -163,11 +164,10 @@ static struct sock *inet_lookup_listener
27131 const __be32 rcv_saddr = inet->rcv_saddr;
27132 int score = sk->sk_family == PF_INET ? 1 : 0;
27135 - if (rcv_saddr != daddr)
27137 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
27142 if (sk->sk_bound_dev_if) {
27143 if (sk->sk_bound_dev_if != dif)
27145 @@ -199,7 +199,7 @@ struct sock *__inet_lookup_listener(stru
27146 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
27148 if (inet->num == hnum && !sk->sk_node.next &&
27149 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
27150 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
27151 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
27152 !sk->sk_bound_dev_if && net_eq(sock_net(sk), net))
27154 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/netfilter/nf_nat_helper.c
27155 --- linux-2.6.27.25/net/ipv4/netfilter/nf_nat_helper.c 2008-07-13 23:51:29.000000000 +0200
27156 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/netfilter/nf_nat_helper.c 2008-10-13 14:54:20.000000000 +0200
27158 #include <net/tcp.h>
27160 #include <linux/netfilter_ipv4.h>
27161 +#include <net/route.h>
27162 #include <net/netfilter/nf_conntrack.h>
27163 #include <net/netfilter/nf_conntrack_helper.h>
27164 #include <net/netfilter/nf_conntrack_ecache.h>
27165 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/netfilter.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/netfilter.c
27166 --- linux-2.6.27.25/net/ipv4/netfilter.c 2008-07-13 23:51:29.000000000 +0200
27167 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/netfilter.c 2008-10-13 14:54:20.000000000 +0200
27169 #include <linux/netfilter_ipv4.h>
27170 #include <linux/ip.h>
27171 #include <linux/skbuff.h>
27172 -#include <net/route.h>
27173 +// #include <net/route.h>
27174 #include <net/xfrm.h>
27175 #include <net/ip.h>
27176 #include <net/netfilter/nf_queue.h>
27177 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/raw.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/raw.c
27178 --- linux-2.6.27.25/net/ipv4/raw.c 2008-10-13 14:52:09.000000000 +0200
27179 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/raw.c 2008-10-13 14:54:20.000000000 +0200
27180 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27182 if (net_eq(sock_net(sk), net) && inet->num == num &&
27183 !(inet->daddr && inet->daddr != raddr) &&
27184 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27185 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27186 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27187 goto found; /* gotcha */
27189 @@ -372,6 +372,12 @@ static int raw_send_hdrinc(struct sock *
27190 icmp_out_count(net, ((struct icmphdr *)
27191 skb_transport_header(skb))->type);
27194 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27195 + sk->sk_nx_info &&
27196 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27199 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27202 @@ -383,6 +389,7 @@ out:
27209 IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
27210 @@ -550,6 +557,13 @@ static int raw_sendmsg(struct kiocb *ioc
27213 security_sk_classify_flow(sk, &fl);
27214 + if (sk->sk_nx_info) {
27215 + err = ip_v4_find_src(sock_net(sk),
27216 + sk->sk_nx_info, &rt, &fl);
27221 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27224 @@ -619,17 +633,19 @@ static int raw_bind(struct sock *sk, str
27226 struct inet_sock *inet = inet_sk(sk);
27227 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27228 + struct nx_v4_sock_addr nsa = { 0 };
27232 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27234 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27235 + v4_map_sock_addr(inet, addr, &nsa);
27236 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27237 ret = -EADDRNOTAVAIL;
27238 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27239 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27240 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27242 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27243 + v4_set_sock_addr(inet, &nsa);
27244 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27245 inet->saddr = 0; /* Use device */
27247 @@ -681,7 +697,8 @@ static int raw_recvmsg(struct kiocb *ioc
27248 /* Copy the address. */
27250 sin->sin_family = AF_INET;
27251 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27252 + sin->sin_addr.s_addr =
27253 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27255 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27257 @@ -858,7 +875,8 @@ static struct sock *raw_get_first(struct
27258 struct hlist_node *node;
27260 sk_for_each(sk, node, &state->h->ht[state->bucket])
27261 - if (sock_net(sk) == seq_file_net(seq))
27262 + if ((sock_net(sk) == seq_file_net(seq)) &&
27263 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27267 @@ -874,7 +892,8 @@ static struct sock *raw_get_next(struct
27271 - } while (sk && sock_net(sk) != seq_file_net(seq));
27272 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27273 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27275 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27276 sk = sk_head(&state->h->ht[state->bucket]);
27277 @@ -933,7 +952,10 @@ static void raw_sock_seq_show(struct seq
27279 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27280 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27281 - i, src, srcp, dest, destp, sp->sk_state,
27283 + nx_map_sock_lback(current_nx_info(), src), srcp,
27284 + nx_map_sock_lback(current_nx_info(), dest), destp,
27286 atomic_read(&sp->sk_wmem_alloc),
27287 atomic_read(&sp->sk_rmem_alloc),
27288 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27289 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/syncookies.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/syncookies.c
27290 --- linux-2.6.27.25/net/ipv4/syncookies.c 2008-10-13 14:52:09.000000000 +0200
27291 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/syncookies.c 2008-10-13 14:54:20.000000000 +0200
27293 #include <linux/cryptohash.h>
27294 #include <linux/kernel.h>
27295 #include <net/tcp.h>
27296 +#include <net/route.h>
27298 /* Timestamps: lowest 9 bits store TCP options */
27300 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/tcp.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/tcp.c
27301 --- linux-2.6.27.25/net/ipv4/tcp.c 2009-06-15 17:18:35.000000000 +0200
27302 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/tcp.c 2009-02-22 22:58:33.000000000 +0100
27303 @@ -264,6 +264,7 @@
27304 #include <linux/cache.h>
27305 #include <linux/err.h>
27306 #include <linux/crypto.h>
27307 +#include <linux/in.h>
27309 #include <net/icmp.h>
27310 #include <net/tcp.h>
27311 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/tcp_ipv4.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/tcp_ipv4.c
27312 --- linux-2.6.27.25/net/ipv4/tcp_ipv4.c 2008-10-13 14:52:09.000000000 +0200
27313 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/tcp_ipv4.c 2008-10-13 14:54:20.000000000 +0200
27314 @@ -1886,6 +1886,12 @@ static void *listening_get_next(struct s
27315 req = req->dl_next;
27318 + vxdprintk(VXD_CBIT(net, 6),
27319 + "sk,req: %p [#%d] (from %d)", req->sk,
27320 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27322 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27324 if (req->rsk_ops->family == st->family) {
27327 @@ -1910,6 +1916,10 @@ get_req:
27330 sk_for_each_from(sk, node) {
27331 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27332 + sk, sk->sk_nid, nx_current_nid());
27333 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27335 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27338 @@ -1960,6 +1970,11 @@ static void *established_get_first(struc
27340 read_lock_bh(lock);
27341 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27342 + vxdprintk(VXD_CBIT(net, 6),
27343 + "sk,egf: %p [#%d] (from %d)",
27344 + sk, sk->sk_nid, nx_current_nid());
27345 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27347 if (sk->sk_family != st->family ||
27348 !net_eq(sock_net(sk), net)) {
27350 @@ -1970,6 +1985,11 @@ static void *established_get_first(struc
27351 st->state = TCP_SEQ_STATE_TIME_WAIT;
27352 inet_twsk_for_each(tw, node,
27353 &tcp_hashinfo.ehash[st->bucket].twchain) {
27354 + vxdprintk(VXD_CBIT(net, 6),
27355 + "tw: %p [#%d] (from %d)",
27356 + tw, tw->tw_nid, nx_current_nid());
27357 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27359 if (tw->tw_family != st->family ||
27360 !net_eq(twsk_net(tw), net)) {
27362 @@ -1998,7 +2018,9 @@ static void *established_get_next(struct
27366 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27367 + while (tw && (tw->tw_family != st->family ||
27368 + !net_eq(twsk_net(tw), net) ||
27369 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27373 @@ -2019,6 +2041,11 @@ get_tw:
27376 sk_for_each_from(sk, node) {
27377 + vxdprintk(VXD_CBIT(net, 6),
27378 + "sk,egn: %p [#%d] (from %d)",
27379 + sk, sk->sk_nid, nx_current_nid());
27380 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27382 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27385 @@ -2173,9 +2200,9 @@ static void get_openreq4(struct sock *sk
27386 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27387 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27390 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27391 ntohs(inet_sk(sk)->sport),
27393 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27394 ntohs(ireq->rmt_port),
27396 0, 0, /* could print option size, but that is af dependent. */
27397 @@ -2218,7 +2245,10 @@ static void get_tcp4_sock(struct sock *s
27399 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27400 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27401 - i, src, srcp, dest, destp, sk->sk_state,
27403 + nx_map_sock_lback(current_nx_info(), src), srcp,
27404 + nx_map_sock_lback(current_nx_info(), dest), destp,
27406 tp->write_seq - tp->snd_una,
27407 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
27408 (tp->rcv_nxt - tp->copied_seq),
27409 @@ -2254,7 +2284,10 @@ static void get_timewait4_sock(struct in
27411 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27412 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27413 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27415 + nx_map_sock_lback(current_nx_info(), src), srcp,
27416 + nx_map_sock_lback(current_nx_info(), dest), destp,
27417 + tw->tw_substate, 0, 0,
27418 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27419 atomic_read(&tw->tw_refcnt), tw, len);
27421 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/tcp_minisocks.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/tcp_minisocks.c
27422 --- linux-2.6.27.25/net/ipv4/tcp_minisocks.c 2008-10-13 14:52:09.000000000 +0200
27423 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/tcp_minisocks.c 2008-10-13 14:54:20.000000000 +0200
27425 #include <net/inet_common.h>
27426 #include <net/xfrm.h>
27428 +#include <linux/vs_limit.h>
27429 +#include <linux/vs_socket.h>
27430 +#include <linux/vs_context.h>
27432 #ifdef CONFIG_SYSCTL
27433 #define SYNC_INIT 0 /* let the user enable it */
27435 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
27436 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27437 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27439 + tw->tw_xid = sk->sk_xid;
27440 + tw->tw_vx_info = NULL;
27441 + tw->tw_nid = sk->sk_nid;
27442 + tw->tw_nx_info = NULL;
27444 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27445 if (tw->tw_family == PF_INET6) {
27446 struct ipv6_pinfo *np = inet6_sk(sk);
27447 diff -NurpP --minimal linux-2.6.27.25/net/ipv4/udp.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/udp.c
27448 --- linux-2.6.27.25/net/ipv4/udp.c 2009-06-15 17:18:35.000000000 +0200
27449 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv4/udp.c 2009-02-22 22:58:33.000000000 +0100
27450 @@ -234,20 +234,14 @@ fail:
27454 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27456 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27458 - return ( !ipv6_only_sock(sk2) &&
27459 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27460 - inet1->rcv_saddr == inet2->rcv_saddr ));
27462 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27464 int udp_v4_get_port(struct sock *sk, unsigned short snum)
27466 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal);
27470 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27471 * harder than this. -DaveM
27473 @@ -267,10 +261,16 @@ static struct sock *__udp4_lib_lookup(st
27474 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
27475 !ipv6_only_sock(sk)) {
27476 int score = (sk->sk_family == PF_INET ? 1 : 0);
27478 if (inet->rcv_saddr) {
27479 if (inet->rcv_saddr != daddr)
27483 + /* block non nx_info ips */
27484 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27485 + daddr, NXA_MASK_BIND))
27489 if (inet->daddr != saddr)
27490 @@ -296,6 +296,7 @@ static struct sock *__udp4_lib_lookup(st
27497 read_unlock(&udp_hash_lock);
27498 @@ -318,7 +319,7 @@ static inline struct sock *udp_v4_mcast_
27499 s->sk_hash != hnum ||
27500 (inet->daddr && inet->daddr != rmt_addr) ||
27501 (inet->dport != rmt_port && inet->dport) ||
27502 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27503 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27504 ipv6_only_sock(s) ||
27505 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27507 @@ -655,8 +656,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27508 { .sport = inet->sport,
27509 .dport = dport } } };
27510 struct net *net = sock_net(sk);
27511 + struct nx_info *nxi = sk->sk_nx_info;
27513 security_sk_classify_flow(sk, &fl);
27514 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27518 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27520 if (err == -ENETUNREACH)
27521 @@ -901,7 +907,8 @@ try_again:
27523 sin->sin_family = AF_INET;
27524 sin->sin_port = udp_hdr(skb)->source;
27525 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27526 + sin->sin_addr.s_addr = nx_map_sock_lback(
27527 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27528 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27530 if (inet->cmsg_flags)
27531 @@ -1533,6 +1540,8 @@ static struct sock *udp_get_first(struct
27532 sk_for_each(sk, node, state->hashtable + state->bucket) {
27533 if (!net_eq(sock_net(sk), net))
27535 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27537 if (sk->sk_family == state->family)
27540 @@ -1551,7 +1560,9 @@ static struct sock *udp_get_next(struct
27544 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27545 + } while (sk && (!net_eq(sock_net(sk), net) ||
27546 + sk->sk_family != state->family ||
27547 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27549 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
27550 sk = sk_head(state->hashtable + state->bucket);
27551 @@ -1652,7 +1663,10 @@ static void udp4_format_sock(struct sock
27553 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27554 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27555 - bucket, src, srcp, dest, destp, sp->sk_state,
27557 + nx_map_sock_lback(current_nx_info(), src), srcp,
27558 + nx_map_sock_lback(current_nx_info(), dest), destp,
27560 atomic_read(&sp->sk_wmem_alloc),
27561 atomic_read(&sp->sk_rmem_alloc),
27562 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27563 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/addrconf.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/addrconf.c
27564 --- linux-2.6.27.25/net/ipv6/addrconf.c 2008-10-13 14:52:09.000000000 +0200
27565 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/addrconf.c 2008-11-21 13:32:00.000000000 +0100
27568 #include <linux/proc_fs.h>
27569 #include <linux/seq_file.h>
27570 +#include <linux/vs_network.h>
27571 +#include <linux/vs_inet6.h>
27573 /* Set to 3 to get tracing... */
27574 #define ACONF_DEBUG 2
27575 @@ -1108,7 +1110,7 @@ out:
27577 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27578 const struct in6_addr *daddr, unsigned int prefs,
27579 - struct in6_addr *saddr)
27580 + struct in6_addr *saddr, struct nx_info *nxi)
27582 struct ipv6_saddr_score scores[2],
27583 *score = &scores[0], *hiscore = &scores[1];
27584 @@ -1181,6 +1183,8 @@ int ipv6_dev_get_saddr(struct net *net,
27588 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27592 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27593 @@ -1364,35 +1368,46 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str
27597 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
27599 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27601 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27602 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27603 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
27604 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27605 int sk_ipv6only = ipv6_only_sock(sk);
27606 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27607 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27608 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27610 - if (!sk2_rcv_saddr && !sk_ipv6only)
27611 + /* FIXME: needs handling for v4 ANY */
27612 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
27615 if (addr_type2 == IPV6_ADDR_ANY &&
27616 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27617 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
27618 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
27621 if (addr_type == IPV6_ADDR_ANY &&
27622 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27623 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
27624 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
27627 + if (addr_type == IPV6_ADDR_ANY &&
27628 + addr_type2 == IPV6_ADDR_ANY &&
27629 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
27632 if (sk2_rcv_saddr6 &&
27633 + addr_type != IPV6_ADDR_ANY &&
27634 + addr_type != IPV6_ADDR_ANY &&
27635 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27638 if (addr_type == IPV6_ADDR_MAPPED &&
27640 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
27641 + ipv4_rcv_saddr_equal(sk, sk2))
27645 @@ -2986,7 +3001,10 @@ static void if6_seq_stop(struct seq_file
27646 static int if6_seq_show(struct seq_file *seq, void *v)
27648 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27651 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27652 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27654 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
27656 ifp->idev->dev->ifindex,
27657 @@ -3481,6 +3499,12 @@ static int inet6_dump_addr(struct sk_buf
27658 struct ifmcaddr6 *ifmca;
27659 struct ifacaddr6 *ifaca;
27660 struct net *net = sock_net(skb->sk);
27661 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27663 + /* disable ipv6 on non v6 guests */
27664 + if (nxi && !nx_info_has_v6(nxi))
27668 s_idx = cb->args[0];
27669 s_ip_idx = ip_idx = cb->args[1];
27670 @@ -3502,6 +3526,8 @@ static int inet6_dump_addr(struct sk_buf
27671 ifa = ifa->if_next, ip_idx++) {
27672 if (ip_idx < s_ip_idx)
27674 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27676 err = inet6_fill_ifaddr(skb, ifa,
27677 NETLINK_CB(cb->skb).pid,
27678 cb->nlh->nlmsg_seq,
27679 @@ -3515,6 +3541,8 @@ static int inet6_dump_addr(struct sk_buf
27680 ifmca = ifmca->next, ip_idx++) {
27681 if (ip_idx < s_ip_idx)
27683 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27685 err = inet6_fill_ifmcaddr(skb, ifmca,
27686 NETLINK_CB(cb->skb).pid,
27687 cb->nlh->nlmsg_seq,
27688 @@ -3528,6 +3556,8 @@ static int inet6_dump_addr(struct sk_buf
27689 ifaca = ifaca->aca_next, ip_idx++) {
27690 if (ip_idx < s_ip_idx)
27692 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27694 err = inet6_fill_ifacaddr(skb, ifaca,
27695 NETLINK_CB(cb->skb).pid,
27696 cb->nlh->nlmsg_seq,
27697 @@ -3813,12 +3843,19 @@ static int inet6_dump_ifinfo(struct sk_b
27698 int s_idx = cb->args[0];
27699 struct net_device *dev;
27700 struct inet6_dev *idev;
27701 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27703 + /* FIXME: maybe disable ipv6 on non v6 guests?
27704 + if (skb->sk && skb->sk->sk_vx_info)
27705 + return skb->len; */
27707 read_lock(&dev_base_lock);
27709 for_each_netdev(net, dev) {
27712 + if (!v6_dev_in_nx_info(dev, nxi))
27714 if ((idev = in6_dev_get(dev)) == NULL)
27716 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
27717 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/af_inet6.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/af_inet6.c
27718 --- linux-2.6.27.25/net/ipv6/af_inet6.c 2008-10-13 14:52:09.000000000 +0200
27719 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/af_inet6.c 2008-10-13 14:54:20.000000000 +0200
27721 #include <linux/netdevice.h>
27722 #include <linux/icmpv6.h>
27723 #include <linux/netfilter_ipv6.h>
27724 +#include <linux/vs_inet.h>
27725 +#include <linux/vs_inet6.h>
27727 #include <net/ip.h>
27728 #include <net/ipv6.h>
27730 #include <net/tcp.h>
27731 #include <net/ipip.h>
27732 #include <net/protocol.h>
27733 +#include <net/route.h>
27734 #include <net/inet_common.h>
27735 #include <net/transp_v6.h>
27736 #include <net/ip6_route.h>
27737 @@ -141,9 +144,12 @@ lookup_protocol:
27741 + if ((protocol == IPPROTO_ICMPV6) &&
27742 + nx_capable(answer->capability, NXC_RAW_ICMP))
27744 if (answer->capability > 0 && !capable(answer->capability))
27745 goto out_rcu_unlock;
27748 sock->ops = answer->ops;
27749 answer_prot = answer->prot;
27750 answer_no_check = answer->no_check;
27751 @@ -242,6 +248,7 @@ int inet6_bind(struct socket *sock, stru
27752 struct inet_sock *inet = inet_sk(sk);
27753 struct ipv6_pinfo *np = inet6_sk(sk);
27754 struct net *net = sock_net(sk);
27755 + struct nx_v6_sock_addr nsa;
27757 unsigned short snum;
27759 @@ -253,6 +260,11 @@ int inet6_bind(struct socket *sock, stru
27761 if (addr_len < SIN6_LEN_RFC2133)
27764 + err = v6_map_sock_addr(inet, addr, &nsa);
27768 addr_type = ipv6_addr_type(&addr->sin6_addr);
27769 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27771 @@ -276,6 +288,10 @@ int inet6_bind(struct socket *sock, stru
27772 err = -EADDRNOTAVAIL;
27775 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27776 + err = -EADDRNOTAVAIL;
27780 if (addr_type != IPV6_ADDR_ANY) {
27781 struct net_device *dev = NULL;
27782 @@ -301,6 +317,11 @@ int inet6_bind(struct socket *sock, stru
27786 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27787 + err = -EADDRNOTAVAIL;
27791 /* ipv4 addr of the socket is invalid. Only the
27792 * unspecified and mapped address have a v4 equivalent.
27794 @@ -319,6 +340,8 @@ int inet6_bind(struct socket *sock, stru
27798 + v6_set_sock_addr(inet, &nsa);
27800 inet->rcv_saddr = v4addr;
27801 inet->saddr = v4addr;
27803 @@ -411,9 +434,11 @@ int inet6_getname(struct socket *sock, s
27805 sin->sin6_port = inet->dport;
27806 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27807 + /* FIXME: remap lback? */
27809 sin->sin6_flowinfo = np->flow_label;
27811 + /* FIXME: remap lback? */
27812 if (ipv6_addr_any(&np->rcv_saddr))
27813 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27815 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/fib6_rules.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/fib6_rules.c
27816 --- linux-2.6.27.25/net/ipv6/fib6_rules.c 2008-10-13 14:52:09.000000000 +0200
27817 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/fib6_rules.c 2008-10-13 14:54:20.000000000 +0200
27818 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
27819 if (ipv6_dev_get_saddr(net,
27820 ip6_dst_idev(&rt->u.dst)->dev,
27821 &flp->fl6_dst, srcprefs,
27825 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27827 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/inet6_hashtables.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/inet6_hashtables.c
27828 --- linux-2.6.27.25/net/ipv6/inet6_hashtables.c 2009-06-15 17:18:35.000000000 +0200
27829 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/inet6_hashtables.c 2009-05-15 22:57:04.000000000 +0200
27832 #include <linux/module.h>
27833 #include <linux/random.h>
27834 +#include <linux/vs_inet6.h>
27836 #include <net/inet_connection_sock.h>
27837 #include <net/inet_hashtables.h>
27838 @@ -115,6 +116,9 @@ struct sock *inet6_lookup_listener(struc
27839 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27843 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27846 if (sk->sk_bound_dev_if) {
27847 if (sk->sk_bound_dev_if != dif)
27848 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/ip6_output.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/ip6_output.c
27849 --- linux-2.6.27.25/net/ipv6/ip6_output.c 2009-06-15 17:18:35.000000000 +0200
27850 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/ip6_output.c 2009-02-22 22:58:33.000000000 +0100
27851 @@ -937,7 +937,7 @@ static int ip6_dst_lookup_tail(struct so
27852 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27854 sk ? inet6_sk(sk)->srcprefs : 0,
27856 + &fl->fl6_src, sk->sk_nx_info);
27858 goto out_err_release;
27860 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/Kconfig linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/Kconfig
27861 --- linux-2.6.27.25/net/ipv6/Kconfig 2008-10-13 14:52:09.000000000 +0200
27862 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/Kconfig 2008-10-13 14:54:20.000000000 +0200
27865 # IPv6 as module will cause a CRASH if you try to unload it
27867 - tristate "The IPv6 protocol"
27869 + bool "The IPv6 protocol"
27872 This is complemental support for the IP version 6.
27873 You will still be able to do traditional IPv4 networking as well.
27874 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/ndisc.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/ndisc.c
27875 --- linux-2.6.27.25/net/ipv6/ndisc.c 2008-10-13 14:52:09.000000000 +0200
27876 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/ndisc.c 2008-10-13 14:54:20.000000000 +0200
27877 @@ -551,7 +551,7 @@ static void ndisc_send_na(struct net_dev
27879 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27880 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27882 + &tmpaddr, NULL /* FIXME: ? */ ))
27884 src_addr = &tmpaddr;
27886 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/raw.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/raw.c
27887 --- linux-2.6.27.25/net/ipv6/raw.c 2008-10-13 14:52:09.000000000 +0200
27888 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/raw.c 2008-11-21 13:32:00.000000000 +0100
27890 #include <linux/icmpv6.h>
27891 #include <linux/netfilter.h>
27892 #include <linux/netfilter_ipv6.h>
27893 +#include <linux/vs_inet6.h>
27894 #include <linux/skbuff.h>
27895 #include <asm/uaccess.h>
27896 #include <asm/ioctls.h>
27897 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
27901 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27902 + err = -EADDRNOTAVAIL;
27908 /* ipv4 addr of the socket is invalid. Only the
27909 * unspecified and mapped address have a v4 equivalent.
27911 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/route.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/route.c
27912 --- linux-2.6.27.25/net/ipv6/route.c 2008-10-13 14:52:09.000000000 +0200
27913 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/route.c 2008-10-13 14:54:20.000000000 +0200
27914 @@ -2191,7 +2191,8 @@ static int rt6_fill_node(struct net *net
27915 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27916 struct in6_addr saddr_buf;
27917 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27918 - dst, 0, &saddr_buf) == 0)
27919 + dst, 0, &saddr_buf,
27920 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27921 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27924 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/tcp_ipv6.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/tcp_ipv6.c
27925 --- linux-2.6.27.25/net/ipv6/tcp_ipv6.c 2009-06-15 17:18:35.000000000 +0200
27926 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/tcp_ipv6.c 2009-02-03 17:59:04.000000000 +0100
27929 #include <linux/crypto.h>
27930 #include <linux/scatterlist.h>
27931 +#include <linux/vs_inet6.h>
27933 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27934 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27935 @@ -155,8 +156,15 @@ static int tcp_v6_connect(struct sock *s
27936 * connect() to INADDR_ANY means loopback (BSD'ism).
27939 - if(ipv6_addr_any(&usin->sin6_addr))
27940 - usin->sin6_addr.s6_addr[15] = 0x1;
27941 + if(ipv6_addr_any(&usin->sin6_addr)) {
27942 + struct nx_info *nxi = sk->sk_nx_info;
27944 + if (nxi && nx_info_has_v6(nxi))
27945 + /* FIXME: remap lback? */
27946 + usin->sin6_addr = nxi->v6.ip;
27948 + usin->sin6_addr.s6_addr[15] = 0x1;
27951 addr_type = ipv6_addr_type(&usin->sin6_addr);
27953 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/udp.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/udp.c
27954 --- linux-2.6.27.25/net/ipv6/udp.c 2009-06-15 17:18:35.000000000 +0200
27955 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/udp.c 2009-02-03 17:59:04.000000000 +0100
27958 #include <linux/proc_fs.h>
27959 #include <linux/seq_file.h>
27960 +#include <linux/vs_inet6.h>
27961 #include "udp_impl.h"
27963 int udp_v6_get_port(struct sock *sk, unsigned short snum)
27964 @@ -81,6 +82,10 @@ static struct sock *__udp6_lib_lookup(st
27965 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27969 + /* block non nx_info ips */
27970 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27973 if (!ipv6_addr_any(&np->daddr)) {
27974 if (!ipv6_addr_equal(&np->daddr, saddr))
27975 diff -NurpP --minimal linux-2.6.27.25/net/ipv6/xfrm6_policy.c linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/xfrm6_policy.c
27976 --- linux-2.6.27.25/net/ipv6/xfrm6_policy.c 2008-10-13 14:52:09.000000000 +0200
27977 +++ linux-2.6.27.25-vs2.3.0.36.6/net/ipv6/xfrm6_policy.c 2008-10-13 14:54:20.000000000 +0200
27978 @@ -61,7 +61,7 @@ static int xfrm6_get_saddr(xfrm_address_
27979 dev = ip6_dst_idev(dst)->dev;
27980 ipv6_dev_get_saddr(dev_net(dev), dev,
27981 (struct in6_addr *)&daddr->a6, 0,
27982 - (struct in6_addr *)&saddr->a6);
27983 + (struct in6_addr *)&saddr->a6, NULL);
27987 diff -NurpP --minimal linux-2.6.27.25/net/Kconfig linux-2.6.27.25-vs2.3.0.36.6/net/Kconfig
27988 --- linux-2.6.27.25/net/Kconfig 2008-10-13 14:52:09.000000000 +0200
27989 +++ linux-2.6.27.25-vs2.3.0.36.6/net/Kconfig 2008-11-20 15:21:32.000000000 +0100
27990 @@ -27,7 +27,7 @@ menu "Networking options"
27992 bool "Network namespace support"
27994 - depends on EXPERIMENTAL && !SYSFS && NAMESPACES
27995 + depends on EXPERIMENTAL && NAMESPACES
27997 Allow user space to create what appear to be multiple instances
27998 of the network stack.
27999 diff -NurpP --minimal linux-2.6.27.25/net/netlink/af_netlink.c linux-2.6.27.25-vs2.3.0.36.6/net/netlink/af_netlink.c
28000 --- linux-2.6.27.25/net/netlink/af_netlink.c 2008-10-13 14:52:09.000000000 +0200
28001 +++ linux-2.6.27.25-vs2.3.0.36.6/net/netlink/af_netlink.c 2008-10-13 14:54:20.000000000 +0200
28003 #include <linux/types.h>
28004 #include <linux/audit.h>
28005 #include <linux/mutex.h>
28006 +#include <linux/vs_context.h>
28007 +#include <linux/vs_network.h>
28008 +#include <linux/vs_limit.h>
28010 #include <net/net_namespace.h>
28011 #include <net/sock.h>
28012 @@ -1761,6 +1764,8 @@ static struct sock *netlink_seq_socket_i
28013 sk_for_each(s, node, &hash->table[j]) {
28014 if (sock_net(s) != seq_file_net(seq))
28016 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28020 iter->hash_idx = j;
28021 @@ -1795,7 +1800,8 @@ static void *netlink_seq_next(struct seq
28025 - } while (s && sock_net(s) != seq_file_net(seq));
28026 + } while (s && (sock_net(s) != seq_file_net(seq) ||
28027 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28031 @@ -1807,7 +1813,8 @@ static void *netlink_seq_next(struct seq
28033 for (; j <= hash->mask; j++) {
28034 s = sk_head(&hash->table[j]);
28035 - while (s && sock_net(s) != seq_file_net(seq))
28036 + while (s && (sock_net(s) != seq_file_net(seq) ||
28037 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28041 diff -NurpP --minimal linux-2.6.27.25/net/sctp/ipv6.c linux-2.6.27.25-vs2.3.0.36.6/net/sctp/ipv6.c
28042 --- linux-2.6.27.25/net/sctp/ipv6.c 2008-10-13 14:52:09.000000000 +0200
28043 +++ linux-2.6.27.25-vs2.3.0.36.6/net/sctp/ipv6.c 2008-10-13 14:54:20.000000000 +0200
28044 @@ -323,7 +323,8 @@ static void sctp_v6_get_saddr(struct sct
28045 dst ? ip6_dst_idev(dst)->dev : NULL,
28046 &daddr->v6.sin6_addr,
28047 inet6_sk(&sk->inet.sk)->srcprefs,
28048 - &saddr->v6.sin6_addr);
28049 + &saddr->v6.sin6_addr,
28050 + asoc->base.sk->sk_nx_info);
28051 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
28052 NIP6(saddr->v6.sin6_addr));
28054 diff -NurpP --minimal linux-2.6.27.25/net/socket.c linux-2.6.27.25-vs2.3.0.36.6/net/socket.c
28055 --- linux-2.6.27.25/net/socket.c 2009-06-15 17:18:35.000000000 +0200
28056 +++ linux-2.6.27.25-vs2.3.0.36.6/net/socket.c 2009-02-03 17:59:04.000000000 +0100
28059 #include <net/sock.h>
28060 #include <linux/netfilter.h>
28061 +#include <linux/vs_base.h>
28062 +#include <linux/vs_socket.h>
28063 +#include <linux/vs_inet.h>
28064 +#include <linux/vs_inet6.h>
28066 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
28067 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
28068 @@ -550,7 +554,7 @@ static inline int __sock_sendmsg(struct
28069 struct msghdr *msg, size_t size)
28071 struct sock_iocb *si = kiocb_to_siocb(iocb);
28077 @@ -561,7 +565,22 @@ static inline int __sock_sendmsg(struct
28081 - return sock->ops->sendmsg(iocb, sock, msg, size);
28082 + len = sock->ops->sendmsg(iocb, sock, msg, size);
28085 + vx_sock_send(sock->sk, size);
28087 + vx_sock_fail(sock->sk, size);
28089 + vxdprintk(VXD_CBIT(net, 7),
28090 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28092 + (sock->sk)?sock->sk->sk_nx_info:0,
28093 + (sock->sk)?sock->sk->sk_vx_info:0,
28094 + (sock->sk)?sock->sk->sk_xid:0,
28095 + (sock->sk)?sock->sk->sk_nid:0,
28096 + (unsigned int)size, len);
28100 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28101 @@ -630,7 +649,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
28102 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28103 struct msghdr *msg, size_t size, int flags)
28107 struct sock_iocb *si = kiocb_to_siocb(iocb);
28110 @@ -643,7 +662,18 @@ static inline int __sock_recvmsg(struct
28114 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28115 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28116 + if ((len >= 0) && sock->sk)
28117 + vx_sock_recv(sock->sk, len);
28118 + vxdprintk(VXD_CBIT(net, 7),
28119 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28121 + (sock->sk)?sock->sk->sk_nx_info:0,
28122 + (sock->sk)?sock->sk->sk_vx_info:0,
28123 + (sock->sk)?sock->sk->sk_xid:0,
28124 + (sock->sk)?sock->sk->sk_nid:0,
28125 + (unsigned int)size, len);
28129 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
28130 @@ -1108,6 +1138,13 @@ static int __sock_create(struct net *net
28131 if (type < 0 || type >= SOCK_MAX)
28134 + if (!nx_check(0, VS_ADMIN)) {
28135 + if (family == PF_INET && !current_nx_info_has_v4())
28136 + return -EAFNOSUPPORT;
28137 + if (family == PF_INET6 && !current_nx_info_has_v6())
28138 + return -EAFNOSUPPORT;
28143 This uglymoron is moved from INET layer to here to avoid
28144 @@ -1240,6 +1277,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28148 + set_bit(SOCK_USER_SOCKET, &sock->flags);
28149 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28152 @@ -1281,10 +1319,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28153 err = sock_create(family, type, protocol, &sock1);
28156 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
28158 err = sock_create(family, type, protocol, &sock2);
28160 goto out_release_1;
28161 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
28163 err = sock1->ops->socketpair(sock1, sock2);
28165 diff -NurpP --minimal linux-2.6.27.25/net/sunrpc/auth.c linux-2.6.27.25-vs2.3.0.36.6/net/sunrpc/auth.c
28166 --- linux-2.6.27.25/net/sunrpc/auth.c 2008-07-13 23:51:29.000000000 +0200
28167 +++ linux-2.6.27.25-vs2.3.0.36.6/net/sunrpc/auth.c 2008-10-13 14:54:20.000000000 +0200
28169 #include <linux/hash.h>
28170 #include <linux/sunrpc/clnt.h>
28171 #include <linux/spinlock.h>
28172 +#include <linux/vs_tag.h>
28175 # define RPCDBG_FACILITY RPCDBG_AUTH
28176 @@ -353,6 +354,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28177 struct auth_cred acred = {
28178 .uid = current->fsuid,
28179 .gid = current->fsgid,
28180 + .tag = dx_current_tag(),
28181 .group_info = current->group_info,
28183 struct rpc_cred *ret;
28184 @@ -398,6 +400,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28185 struct auth_cred acred = {
28188 + .tag = dx_current_tag(),
28190 struct rpc_cred *ret;
28192 diff -NurpP --minimal linux-2.6.27.25/net/sunrpc/auth_unix.c linux-2.6.27.25-vs2.3.0.36.6/net/sunrpc/auth_unix.c
28193 --- linux-2.6.27.25/net/sunrpc/auth_unix.c 2008-10-13 14:52:09.000000000 +0200
28194 +++ linux-2.6.27.25-vs2.3.0.36.6/net/sunrpc/auth_unix.c 2008-10-13 14:54:20.000000000 +0200
28195 @@ -11,12 +11,14 @@
28196 #include <linux/module.h>
28197 #include <linux/sunrpc/clnt.h>
28198 #include <linux/sunrpc/auth.h>
28199 +#include <linux/vs_tag.h>
28201 #define NFS_NGROUPS 16
28204 struct rpc_cred uc_base;
28207 gid_t uc_gids[NFS_NGROUPS];
28209 #define uc_uid uc_base.cr_uid
28210 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28211 groups = NFS_NGROUPS;
28213 cred->uc_gid = acred->gid;
28214 + cred->uc_tag = acred->tag;
28215 for (i = 0; i < groups; i++)
28216 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28217 if (i < NFS_NGROUPS)
28218 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28222 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28223 + if (cred->uc_uid != acred->uid ||
28224 + cred->uc_gid != acred->gid ||
28225 + cred->uc_tag != acred->tag)
28228 if (acred->group_info != NULL)
28229 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
28230 struct rpc_clnt *clnt = task->tk_client;
28231 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28232 __be32 *base, *hold;
28236 *p++ = htonl(RPC_AUTH_UNIX);
28238 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
28239 * Copy the UTS nodename captured when the client was created.
28241 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28242 + tag = task->tk_client->cl_tag;
28244 - *p++ = htonl((u32) cred->uc_uid);
28245 - *p++ = htonl((u32) cred->uc_gid);
28246 + *p++ = htonl((u32) TAGINO_UID(tag,
28247 + cred->uc_uid, cred->uc_tag));
28248 + *p++ = htonl((u32) TAGINO_GID(tag,
28249 + cred->uc_gid, cred->uc_tag));
28251 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28252 *p++ = htonl((u32) cred->uc_gids[i]);
28253 diff -NurpP --minimal linux-2.6.27.25/net/sunrpc/clnt.c linux-2.6.27.25-vs2.3.0.36.6/net/sunrpc/clnt.c
28254 --- linux-2.6.27.25/net/sunrpc/clnt.c 2008-10-13 14:52:09.000000000 +0200
28255 +++ linux-2.6.27.25-vs2.3.0.36.6/net/sunrpc/clnt.c 2008-10-13 14:54:20.000000000 +0200
28257 #include <linux/utsname.h>
28258 #include <linux/workqueue.h>
28259 #include <linux/in6.h>
28260 +#include <linux/vs_cvirt.h>
28262 #include <linux/sunrpc/clnt.h>
28263 #include <linux/sunrpc/rpc_pipe_fs.h>
28264 @@ -327,6 +328,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28265 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28266 clnt->cl_chatty = 1;
28268 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28269 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28270 + clnt->cl_tag = 1; */
28273 EXPORT_SYMBOL_GPL(rpc_create);
28274 diff -NurpP --minimal linux-2.6.27.25/net/unix/af_unix.c linux-2.6.27.25-vs2.3.0.36.6/net/unix/af_unix.c
28275 --- linux-2.6.27.25/net/unix/af_unix.c 2009-06-15 17:18:35.000000000 +0200
28276 +++ linux-2.6.27.25-vs2.3.0.36.6/net/unix/af_unix.c 2009-02-03 17:59:04.000000000 +0100
28277 @@ -114,6 +114,8 @@
28278 #include <linux/mount.h>
28279 #include <net/checksum.h>
28280 #include <linux/security.h>
28281 +#include <linux/vs_context.h>
28282 +#include <linux/vs_limit.h>
28284 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28285 static DEFINE_SPINLOCK(unix_table_lock);
28286 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28287 if (!net_eq(sock_net(s), net))
28290 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28292 if (u->addr->len == len &&
28293 !memcmp(u->addr->name, sunname, len))
28295 @@ -2103,6 +2107,8 @@ static struct sock *unix_seq_idx(struct
28296 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28297 if (sock_net(s) != seq_file_net(seq))
28299 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28304 @@ -2128,7 +2134,8 @@ static void *unix_seq_next(struct seq_fi
28305 sk = first_unix_socket(&iter->i);
28307 sk = next_unix_socket(&iter->i, sk);
28308 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28309 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28310 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28311 sk = next_unix_socket(&iter->i, sk);
28314 diff -NurpP --minimal linux-2.6.27.25/net/x25/af_x25.c linux-2.6.27.25-vs2.3.0.36.6/net/x25/af_x25.c
28315 --- linux-2.6.27.25/net/x25/af_x25.c 2009-06-15 17:18:35.000000000 +0200
28316 +++ linux-2.6.27.25-vs2.3.0.36.6/net/x25/af_x25.c 2009-05-15 22:57:04.000000000 +0200
28317 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
28321 - sock_init_data(sock, sk);
28322 + sk->sk_socket = sock;
28323 + sk->sk_type = sock->type;
28324 + sk->sk_sleep = &sock->wait;
28327 x25_init_timers(sk);
28329 diff -NurpP --minimal linux-2.6.27.25/scripts/checksyscalls.sh linux-2.6.27.25-vs2.3.0.36.6/scripts/checksyscalls.sh
28330 --- linux-2.6.27.25/scripts/checksyscalls.sh 2008-07-13 23:51:29.000000000 +0200
28331 +++ linux-2.6.27.25-vs2.3.0.36.6/scripts/checksyscalls.sh 2008-10-13 14:54:20.000000000 +0200
28332 @@ -108,7 +108,6 @@ cat << EOF
28333 #define __IGNORE_afs_syscall
28334 #define __IGNORE_getpmsg
28335 #define __IGNORE_putpmsg
28336 -#define __IGNORE_vserver
28340 diff -NurpP --minimal linux-2.6.27.25/security/commoncap.c linux-2.6.27.25-vs2.3.0.36.6/security/commoncap.c
28341 --- linux-2.6.27.25/security/commoncap.c 2009-06-15 17:18:35.000000000 +0200
28342 +++ linux-2.6.27.25-vs2.3.0.36.6/security/commoncap.c 2009-03-09 15:36:36.000000000 +0100
28343 @@ -26,10 +26,11 @@
28344 #include <linux/sched.h>
28345 #include <linux/prctl.h>
28346 #include <linux/securebits.h>
28347 +#include <linux/vs_context.h>
28349 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28351 - NETLINK_CB(skb).eff_cap = current->cap_effective;
28352 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current->cap_effective);
28356 @@ -50,9 +51,24 @@ EXPORT_SYMBOL(cap_netlink_recv);
28358 int cap_capable (struct task_struct *tsk, int cap)
28360 + struct vx_info *vxi = tsk->vx_info;
28363 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28364 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28365 + cap_raised(tsk->cap_effective, cap),
28366 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28369 + /* special case SETUP */
28370 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28371 + cap_raised(tsk->cap_effective, cap))
28374 /* Derived from include/linux/sched.h:capable. */
28375 - if (cap_raised(tsk->cap_effective, cap))
28376 + if (vx_cap_raised(vxi, tsk->cap_effective, cap))
28382 @@ -420,7 +436,7 @@ int cap_inode_setxattr(struct dentry *de
28384 } else if (!strncmp(name, XATTR_SECURITY_PREFIX,
28385 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28386 - !capable(CAP_SYS_ADMIN))
28387 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28391 @@ -696,7 +712,8 @@ void cap_task_reparent_to_init (struct t
28393 int cap_syslog (int type)
28395 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
28396 + if ((type != 3 && type != 10) &&
28397 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28401 diff -NurpP --minimal linux-2.6.27.25/security/selinux/hooks.c linux-2.6.27.25-vs2.3.0.36.6/security/selinux/hooks.c
28402 --- linux-2.6.27.25/security/selinux/hooks.c 2009-06-15 17:18:35.000000000 +0200
28403 +++ linux-2.6.27.25-vs2.3.0.36.6/security/selinux/hooks.c 2009-06-15 17:22:10.000000000 +0200
28405 #include <linux/dccp.h>
28406 #include <linux/quota.h>
28407 #include <linux/un.h> /* for Unix socket types */
28408 -#include <net/af_unix.h> /* for Unix socket types */
28409 #include <linux/parser.h>
28410 #include <linux/nfs_mount.h>
28411 #include <net/ipv6.h>