1 diff -NurpP --minimal linux-2.6.27.14/arch/alpha/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/Kconfig
2 --- linux-2.6.27.14/arch/alpha/Kconfig 2008-10-13 14:51:51.000000000 +0200
3 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/alpha/kernel/entry.S linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/kernel/entry.S
14 --- linux-2.6.27.14/arch/alpha/kernel/entry.S 2009-02-03 17:59:54.000000000 +0100
15 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/alpha/kernel/osf_sys.c linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.27.14/arch/alpha/kernel/osf_sys.c 2008-10-13 14:51:51.000000000 +0200
50 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/alpha/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.27.14/arch/alpha/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
62 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/alpha/kernel/systbls.S linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/kernel/systbls.S
72 --- linux-2.6.27.14/arch/alpha/kernel/systbls.S 2009-02-03 17:59:54.000000000 +0100
73 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/alpha/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/kernel/traps.c
84 --- linux-2.6.27.14/arch/alpha/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
85 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/alpha/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/alpha/mm/fault.c
97 --- linux-2.6.27.14/arch/alpha/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
98 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/arm/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/arm/Kconfig
111 --- linux-2.6.27.14/arch/arm/Kconfig 2008-10-13 14:51:51.000000000 +0200
112 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/arm/kernel/calls.S linux-2.6.27.14-vs2.3.0.36.4/arch/arm/kernel/calls.S
123 --- linux-2.6.27.14/arch/arm/kernel/calls.S 2009-02-03 17:59:54.000000000 +0100
124 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/arm/kernel/process.c linux-2.6.27.14-vs2.3.0.36.4/arch/arm/kernel/process.c
135 --- linux-2.6.27.14/arch/arm/kernel/process.c 2008-10-13 14:51:52.000000000 +0200
136 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/arm/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/arm/kernel/traps.c
148 --- linux-2.6.27.14/arch/arm/kernel/traps.c 2008-10-13 14:51:52.000000000 +0200
149 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/arm/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/arm/mm/fault.c
162 --- linux-2.6.27.14/arch/arm/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
163 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/cris/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/cris/Kconfig
175 --- linux-2.6.27.14/arch/cris/Kconfig 2008-07-13 23:51:29.000000000 +0200
176 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/frv/kernel/kernel_thread.S linux-2.6.27.14-vs2.3.0.36.4/arch/frv/kernel/kernel_thread.S
187 --- linux-2.6.27.14/arch/frv/kernel/kernel_thread.S 2008-07-13 23:51:29.000000000 +0200
188 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/h8300/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/h8300/Kconfig
199 --- linux-2.6.27.14/arch/h8300/Kconfig 2008-10-13 14:51:55.000000000 +0200
200 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/ia32/ia32_entry.S linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/ia32/ia32_entry.S
211 --- linux-2.6.27.14/arch/ia64/ia32/ia32_entry.S 2009-02-03 17:59:54.000000000 +0100
212 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/ia32/sys_ia32.c linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/ia32/sys_ia32.c
223 --- linux-2.6.27.14/arch/ia64/ia32/sys_ia32.c 2008-10-13 14:51:55.000000000 +0200
224 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/Kconfig
235 --- linux-2.6.27.14/arch/ia64/Kconfig 2009-02-03 17:59:54.000000000 +0100
236 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/Kconfig 2009-02-03 17:59:04.000000000 +0100
237 @@ -640,6 +640,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.14/arch/ia64/kernel/entry.S linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/kernel/entry.S
247 --- linux-2.6.27.14/arch/ia64/kernel/entry.S 2009-02-03 17:59:54.000000000 +0100
248 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/kernel/perfmon.c linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/kernel/perfmon.c
259 --- linux-2.6.27.14/arch/ia64/kernel/perfmon.c 2008-10-13 14:51:55.000000000 +0200
260 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/kernel/process.c linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/kernel/process.c
279 --- linux-2.6.27.14/arch/ia64/kernel/process.c 2008-10-13 14:51:55.000000000 +0200
280 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/kernel/ptrace.c
293 --- linux-2.6.27.14/arch/ia64/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
294 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/kernel/traps.c
304 --- linux-2.6.27.14/arch/ia64/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
305 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/ia64/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/ia64/mm/fault.c
331 --- linux-2.6.27.14/arch/ia64/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
332 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/m32r/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/m32r/kernel/traps.c
342 --- linux-2.6.27.14/arch/m32r/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
343 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/m68k/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/m68k/Kconfig
357 --- linux-2.6.27.14/arch/m68k/Kconfig 2008-10-13 14:51:55.000000000 +0200
358 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/m68k/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/m68k/kernel/ptrace.c
369 --- linux-2.6.27.14/arch/m68k/kernel/ptrace.c 2008-07-13 23:51:29.000000000 +0200
370 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/m68k/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/m68k/kernel/traps.c
389 --- linux-2.6.27.14/arch/m68k/kernel/traps.c 2008-07-13 23:51:29.000000000 +0200
390 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/m68knommu/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/m68knommu/Kconfig
403 --- linux-2.6.27.14/arch/m68knommu/Kconfig 2008-10-13 14:51:55.000000000 +0200
404 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/m68knommu/Kconfig 2008-10-13 14:54:20.000000000 +0200
405 @@ -740,6 +740,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.14/arch/m68knommu/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/m68knommu/kernel/traps.c
415 --- linux-2.6.27.14/arch/m68knommu/kernel/traps.c 2008-10-13 14:51:55.000000000 +0200
416 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/mips/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/mips/Kconfig
430 --- linux-2.6.27.14/arch/mips/Kconfig 2008-10-13 14:51:55.000000000 +0200
431 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/mips/Kconfig 2008-10-13 14:54:20.000000000 +0200
432 @@ -2031,6 +2031,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.14/arch/mips/kernel/linux32.c linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/linux32.c
442 --- linux-2.6.27.14/arch/mips/kernel/linux32.c 2008-10-13 14:51:56.000000000 +0200
443 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/linux32.c 2008-10-13 14:54:20.000000000 +0200
444 @@ -191,7 +191,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.14/arch/mips/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/ptrace.c
454 --- linux-2.6.27.14/arch/mips/kernel/ptrace.c 2008-10-13 14:51:56.000000000 +0200
455 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/mips/kernel/scall32-o32.S linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall32-o32.S
475 --- linux-2.6.27.14/arch/mips/kernel/scall32-o32.S 2009-02-03 17:59:54.000000000 +0100
476 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall32-o32.S 2009-02-03 17:59:04.000000000 +0100
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.14/arch/mips/kernel/scall64-64.S linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall64-64.S
487 --- linux-2.6.27.14/arch/mips/kernel/scall64-64.S 2008-10-13 14:51:56.000000000 +0200
488 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall64-64.S 2008-10-13 14:54:20.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.14/arch/mips/kernel/scall64-n32.S linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall64-n32.S
499 --- linux-2.6.27.14/arch/mips/kernel/scall64-n32.S 2008-10-13 14:51:56.000000000 +0200
500 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall64-n32.S 2008-10-13 14:54:20.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.14/arch/mips/kernel/scall64-o32.S linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall64-o32.S
511 --- linux-2.6.27.14/arch/mips/kernel/scall64-o32.S 2008-10-13 14:51:56.000000000 +0200
512 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/scall64-o32.S 2008-10-13 14:54:20.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.14/arch/mips/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/mips/kernel/traps.c
523 --- linux-2.6.27.14/arch/mips/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
524 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/mips/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/mips/mm/fault.c
540 --- linux-2.6.27.14/arch/mips/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
541 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/parisc/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/parisc/Kconfig
553 --- linux-2.6.27.14/arch/parisc/Kconfig 2008-10-13 14:51:56.000000000 +0200
554 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/parisc/kernel/syscall_table.S linux-2.6.27.14-vs2.3.0.36.4/arch/parisc/kernel/syscall_table.S
565 --- linux-2.6.27.14/arch/parisc/kernel/syscall_table.S 2008-07-13 23:51:29.000000000 +0200
566 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/parisc/kernel/sys_parisc32.c linux-2.6.27.14-vs2.3.0.36.4/arch/parisc/kernel/sys_parisc32.c
577 --- linux-2.6.27.14/arch/parisc/kernel/sys_parisc32.c 2008-07-13 23:51:29.000000000 +0200
578 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/parisc/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/parisc/kernel/traps.c
594 --- linux-2.6.27.14/arch/parisc/kernel/traps.c 2009-02-03 17:59:54.000000000 +0100
595 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/parisc/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/parisc/mm/fault.c
620 --- linux-2.6.27.14/arch/parisc/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
621 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/Kconfig
645 --- linux-2.6.27.14/arch/powerpc/Kconfig 2009-02-03 17:59:54.000000000 +0100
646 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/kernel/irq.c linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/kernel/irq.c
657 --- linux-2.6.27.14/arch/powerpc/kernel/irq.c 2008-10-13 14:51:56.000000000 +0200
658 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/kernel/process.c linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/kernel/process.c
668 --- linux-2.6.27.14/arch/powerpc/kernel/process.c 2008-10-13 14:51:56.000000000 +0200
669 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/kernel/sys_ppc32.c linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/kernel/sys_ppc32.c
683 --- linux-2.6.27.14/arch/powerpc/kernel/sys_ppc32.c 2008-10-13 14:51:56.000000000 +0200
684 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/kernel/traps.c
695 --- linux-2.6.27.14/arch/powerpc/kernel/traps.c 2008-10-13 14:51:56.000000000 +0200
696 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/kernel/vdso.c linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/kernel/vdso.c
710 --- linux-2.6.27.14/arch/powerpc/kernel/vdso.c 2008-10-13 14:51:56.000000000 +0200
711 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/powerpc/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/powerpc/mm/fault.c
721 --- linux-2.6.27.14/arch/powerpc/mm/fault.c 2008-10-13 14:51:56.000000000 +0200
722 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/s390/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/s390/Kconfig
734 --- linux-2.6.27.14/arch/s390/Kconfig 2009-02-03 17:59:54.000000000 +0100
735 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/s390/kernel/compat_linux.c linux-2.6.27.14-vs2.3.0.36.4/arch/s390/kernel/compat_linux.c
746 --- linux-2.6.27.14/arch/s390/kernel/compat_linux.c 2008-07-13 23:51:29.000000000 +0200
747 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/s390/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/s390/kernel/ptrace.c
758 --- linux-2.6.27.14/arch/s390/kernel/ptrace.c 2008-10-13 14:51:57.000000000 +0200
759 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/s390/kernel/syscalls.S linux-2.6.27.14-vs2.3.0.36.4/arch/s390/kernel/syscalls.S
769 --- linux-2.6.27.14/arch/s390/kernel/syscalls.S 2009-02-03 17:59:54.000000000 +0100
770 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/s390/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/s390/mm/fault.c
781 --- linux-2.6.27.14/arch/s390/mm/fault.c 2008-07-13 23:51:29.000000000 +0200
782 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sh/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/sh/Kconfig
794 --- linux-2.6.27.14/arch/sh/Kconfig 2008-10-13 14:51:57.000000000 +0200
795 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sh/kernel/irq.c linux-2.6.27.14-vs2.3.0.36.4/arch/sh/kernel/irq.c
806 --- linux-2.6.27.14/arch/sh/kernel/irq.c 2008-10-13 14:51:57.000000000 +0200
807 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.27.14-vs2.3.0.36.4/arch/sh/kernel/vsyscall/vsyscall.c
817 --- linux-2.6.27.14/arch/sh/kernel/vsyscall/vsyscall.c 2008-07-13 23:51:29.000000000 +0200
818 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/sparc/Kconfig
828 --- linux-2.6.27.14/arch/sparc/Kconfig 2008-10-13 14:51:58.000000000 +0200
829 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc/kernel/ptrace.c
840 --- linux-2.6.27.14/arch/sparc/kernel/ptrace.c 2008-10-13 14:51:58.000000000 +0200
841 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc/kernel/systbls.S linux-2.6.27.14-vs2.3.0.36.4/arch/sparc/kernel/systbls.S
851 --- linux-2.6.27.14/arch/sparc/kernel/systbls.S 2009-02-03 17:59:54.000000000 +0100
852 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc/kernel/traps.c
863 --- linux-2.6.27.14/arch/sparc/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
864 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc/mm/fault.c
876 --- linux-2.6.27.14/arch/sparc/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
877 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc64/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/Kconfig
889 --- linux-2.6.27.14/arch/sparc64/Kconfig 2008-10-13 14:51:58.000000000 +0200
890 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/Kconfig 2008-10-13 14:54:20.000000000 +0200
891 @@ -403,6 +403,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.14/arch/sparc64/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/kernel/ptrace.c
901 --- linux-2.6.27.14/arch/sparc64/kernel/ptrace.c 2009-02-03 17:59:54.000000000 +0100
902 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc64/kernel/sys_sparc32.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/kernel/sys_sparc32.c
912 --- linux-2.6.27.14/arch/sparc64/kernel/sys_sparc32.c 2008-10-13 14:51:58.000000000 +0200
913 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/sparc64/kernel/systbls.S linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/kernel/systbls.S
924 --- linux-2.6.27.14/arch/sparc64/kernel/systbls.S 2009-02-03 17:59:54.000000000 +0100
925 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/kernel/systbls.S 2009-02-03 17:59:04.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 sys64_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.14/arch/sparc64/kernel/traps.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/kernel/traps.c
945 --- linux-2.6.27.14/arch/sparc64/kernel/traps.c 2008-10-13 14:51:58.000000000 +0200
946 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/kernel/traps.c 2008-10-13 14:54:20.000000000 +0200
947 @@ -2186,7 +2186,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.14/arch/sparc64/mm/fault.c linux-2.6.27.14-vs2.3.0.36.4/arch/sparc64/mm/fault.c
958 --- linux-2.6.27.14/arch/sparc64/mm/fault.c 2008-10-13 14:51:58.000000000 +0200
959 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/um/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/um/Kconfig
971 --- linux-2.6.27.14/arch/um/Kconfig 2008-07-13 23:51:29.000000000 +0200
972 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/um/kernel/trap.c linux-2.6.27.14-vs2.3.0.36.4/arch/um/kernel/trap.c
983 --- linux-2.6.27.14/arch/um/kernel/trap.c 2008-07-13 23:51:29.000000000 +0200
984 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/arch/x86/ia32/ia32entry.S linux-2.6.27.14-vs2.3.0.36.4/arch/x86/ia32/ia32entry.S
996 --- linux-2.6.27.14/arch/x86/ia32/ia32entry.S 2008-10-13 14:51:58.000000000 +0200
997 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/x86/ia32/ia32entry.S 2008-10-13 14:54:20.000000000 +0200
998 @@ -772,7 +772,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.14/arch/x86/Kconfig linux-2.6.27.14-vs2.3.0.36.4/arch/x86/Kconfig
1008 --- linux-2.6.27.14/arch/x86/Kconfig 2009-02-03 17:59:54.000000000 +0100
1009 +++ linux-2.6.27.14-vs2.3.0.36.4/arch/x86/Kconfig 2009-02-03 17:59:04.000000000 +0100
1010 @@ -1808,6 +1808,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.14/arch/x86/kernel/syscall_table_32.S linux-2.6.27.14-vs2.3.0.36.4/arch/x86/kernel/syscall_table_32.S
1020 --- linux-2.6.27.14/arch/x86/kernel/syscall_table_32.S 2009-02-03 17:59:54.000000000 +0100
1021 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/Documentation/vserver/debug.txt linux-2.6.27.14-vs2.3.0.36.4/Documentation/vserver/debug.txt
1032 --- linux-2.6.27.14/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1033 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/block/Kconfig linux-2.6.27.14-vs2.3.0.36.4/drivers/block/Kconfig
1190 --- linux-2.6.27.14/drivers/block/Kconfig 2008-10-13 14:51:59.000000000 +0200
1191 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/block/loop.c linux-2.6.27.14-vs2.3.0.36.4/drivers/block/loop.c
1207 --- linux-2.6.27.14/drivers/block/loop.c 2008-07-13 23:51:29.000000000 +0200
1208 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/block/Makefile linux-2.6.27.14-vs2.3.0.36.4/drivers/block/Makefile
1263 --- linux-2.6.27.14/drivers/block/Makefile 2008-10-13 14:51:59.000000000 +0200
1264 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/block/vroot.c linux-2.6.27.14-vs2.3.0.36.4/drivers/block/vroot.c
1273 --- linux-2.6.27.14/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1274 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/char/sysrq.c linux-2.6.27.14-vs2.3.0.36.4/drivers/char/sysrq.c
1560 --- linux-2.6.27.14/drivers/char/sysrq.c 2008-10-13 14:51:59.000000000 +0200
1561 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/char/tty_io.c linux-2.6.27.14-vs2.3.0.36.4/drivers/char/tty_io.c
1615 --- linux-2.6.27.14/drivers/char/tty_io.c 2009-02-03 17:59:54.000000000 +0100
1616 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.27.14-vs2.3.0.36.4/drivers/infiniband/hw/ipath/ipath_user_pages.c
1634 --- linux-2.6.27.14/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-07-13 23:51:29.000000000 +0200
1635 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/md/dm.c linux-2.6.27.14-vs2.3.0.36.4/drivers/md/dm.c
1682 --- linux-2.6.27.14/drivers/md/dm.c 2008-10-13 14:52:01.000000000 +0200
1683 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/md/dm.h linux-2.6.27.14-vs2.3.0.36.4/drivers/md/dm.h
1758 --- linux-2.6.27.14/drivers/md/dm.h 2008-10-13 14:52:01.000000000 +0200
1759 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/drivers/md/dm-ioctl.c linux-2.6.27.14-vs2.3.0.36.4/drivers/md/dm-ioctl.c
1770 --- linux-2.6.27.14/drivers/md/dm-ioctl.c 2008-07-13 23:51:29.000000000 +0200
1771 +++ linux-2.6.27.14-vs2.3.0.36.4/drivers/md/dm-ioctl.c 2008-10-13 14:54:20.000000000 +0200
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 @@ -1406,8 +1417,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.14/drivers/net/tun.c linux-2.6.27.14-vs2.3.0.36.4/drivers/net/tun.c
1854 --- linux-2.6.27.14/drivers/net/tun.c 2008-10-13 14:52:02.000000000 +0200
1855 +++ linux-2.6.27.14-vs2.3.0.36.4/drivers/net/tun.c 2008-10-13 14:54:20.000000000 +0200
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 @@ -675,6 +677,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 @@ -707,6 +710,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 @@ -715,7 +721,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 @@ -726,7 +732,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 @@ -966,6 +972,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.14/fs/attr.c linux-2.6.27.14-vs2.3.0.36.4/fs/attr.c
1926 --- linux-2.6.27.14/fs/attr.c 2008-10-13 14:52:05.000000000 +0200
1927 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/binfmt_aout.c linux-2.6.27.14-vs2.3.0.36.4/fs/binfmt_aout.c
1969 --- linux-2.6.27.14/fs/binfmt_aout.c 2008-10-13 14:52:05.000000000 +0200
1970 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/binfmt_elf.c linux-2.6.27.14-vs2.3.0.36.4/fs/binfmt_elf.c
1980 --- linux-2.6.27.14/fs/binfmt_elf.c 2008-10-13 14:52:05.000000000 +0200
1981 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/binfmt_elf.c 2008-10-13 14:54:20.000000000 +0200
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.14/fs/binfmt_flat.c linux-2.6.27.14-vs2.3.0.36.4/fs/binfmt_flat.c
1991 --- linux-2.6.27.14/fs/binfmt_flat.c 2008-10-13 14:52:05.000000000 +0200
1992 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/binfmt_som.c linux-2.6.27.14-vs2.3.0.36.4/fs/binfmt_som.c
2002 --- linux-2.6.27.14/fs/binfmt_som.c 2008-10-13 14:52:05.000000000 +0200
2003 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/block_dev.c linux-2.6.27.14-vs2.3.0.36.4/fs/block_dev.c
2013 --- linux-2.6.27.14/fs/block_dev.c 2008-10-13 14:52:05.000000000 +0200
2014 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/char_dev.c linux-2.6.27.14-vs2.3.0.36.4/fs/char_dev.c
2053 --- linux-2.6.27.14/fs/char_dev.c 2008-10-13 14:52:05.000000000 +0200
2054 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/dcache.c linux-2.6.27.14-vs2.3.0.36.4/fs/dcache.c
2088 --- linux-2.6.27.14/fs/dcache.c 2009-02-03 17:59:55.000000000 +0100
2089 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/devpts/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/devpts/inode.c
2142 --- linux-2.6.27.14/fs/devpts/inode.c 2008-10-13 14:52:05.000000000 +0200
2143 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/exec.c linux-2.6.27.14-vs2.3.0.36.4/fs/exec.c
2225 --- linux-2.6.27.14/fs/exec.c 2009-02-03 17:59:55.000000000 +0100
2226 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/exec.c 2009-02-03 17:59:04.000000000 +0100
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 @@ -1461,7 +1463,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.14/fs/ext2/balloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/balloc.c
2248 --- linux-2.6.27.14/fs/ext2/balloc.c 2009-02-03 17:59:55.000000000 +0100
2249 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/ext2.h linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/ext2.h
2308 --- linux-2.6.27.14/fs/ext2/ext2.h 2008-07-13 23:51:29.000000000 +0200
2309 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/file.c
2319 --- linux-2.6.27.14/fs/ext2/file.c 2008-07-13 23:51:29.000000000 +0200
2320 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/ialloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/ialloc.c
2328 --- linux-2.6.27.14/fs/ext2/ialloc.c 2008-07-13 23:51:29.000000000 +0200
2329 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/inode.c
2386 --- linux-2.6.27.14/fs/ext2/inode.c 2008-10-13 14:52:05.000000000 +0200
2387 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/ioctl.c
2548 --- linux-2.6.27.14/fs/ext2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
2549 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/namei.c
2582 --- linux-2.6.27.14/fs/ext2/namei.c 2008-07-13 23:51:29.000000000 +0200
2583 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/super.c
2615 --- linux-2.6.27.14/fs/ext2/super.c 2008-10-13 14:52:05.000000000 +0200
2616 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/super.c 2008-10-13 14:54:20.000000000 +0200
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.14/fs/ext2/symlink.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/symlink.c
2682 --- linux-2.6.27.14/fs/ext2/symlink.c 2008-07-13 23:51:29.000000000 +0200
2683 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext2/xattr.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext2/xattr.c
2699 --- linux-2.6.27.14/fs/ext2/xattr.c 2008-07-13 23:51:29.000000000 +0200
2700 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/balloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/balloc.c
2739 --- linux-2.6.27.14/fs/ext3/balloc.c 2009-02-03 17:59:55.000000000 +0100
2740 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/file.c
2848 --- linux-2.6.27.14/fs/ext3/file.c 2008-07-13 23:51:29.000000000 +0200
2849 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/ialloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/ialloc.c
2858 --- linux-2.6.27.14/fs/ext3/ialloc.c 2008-10-13 14:52:05.000000000 +0200
2859 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/inode.c
2918 --- linux-2.6.27.14/fs/ext3/inode.c 2009-02-03 17:59:55.000000000 +0100
2919 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/ioctl.c
3128 --- linux-2.6.27.14/fs/ext3/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3129 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/namei.c
3170 --- linux-2.6.27.14/fs/ext3/namei.c 2009-02-03 17:59:55.000000000 +0100
3171 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/super.c
3203 --- linux-2.6.27.14/fs/ext3/super.c 2009-02-03 17:59:55.000000000 +0100
3204 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/symlink.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/symlink.c
3270 --- linux-2.6.27.14/fs/ext3/symlink.c 2008-07-13 23:51:29.000000000 +0200
3271 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext3/xattr.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext3/xattr.c
3287 --- linux-2.6.27.14/fs/ext3/xattr.c 2008-07-13 23:51:29.000000000 +0200
3288 +++ linux-2.6.27.14-vs2.3.0.36.4/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.14/fs/ext4/balloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/balloc.c
3331 --- linux-2.6.27.14/fs/ext4/balloc.c 2008-10-13 14:52:05.000000000 +0200
3332 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/balloc.c 2008-10-13 14:54:20.000000000 +0200
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 @@ -865,8 +867,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 @@ -1726,6 +1730,8 @@ ext4_fsblk_t ext4_old_new_blocks(handle_
3358 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3362 es = EXT4_SB(sb)->s_es;
3363 @@ -1935,12 +1941,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.14/fs/ext4/ext4.h linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/ext4.h
3381 --- linux-2.6.27.14/fs/ext4/ext4.h 2009-02-03 17:59:55.000000000 +0100
3382 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/ext4.h 2009-02-03 17:59:04.000000000 +0100
3383 @@ -242,8 +242,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 @@ -541,6 +545,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 @@ -1055,6 +1060,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.14/fs/ext4/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/file.c
3413 --- linux-2.6.27.14/fs/ext4/file.c 2008-10-13 14:52:05.000000000 +0200
3414 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/file.c 2008-10-13 14:54:20.000000000 +0200
3415 @@ -170,5 +170,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.14/fs/ext4/ialloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/ialloc.c
3423 --- linux-2.6.27.14/fs/ext4/ialloc.c 2009-02-03 17:59:55.000000000 +0100
3424 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/ialloc.c 2009-02-03 17:59:04.000000000 +0100
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 @@ -196,6 +198,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 @@ -602,6 +605,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 @@ -810,7 +819,8 @@ got:
3456 * newly created directory and file only if -o extent mount option is
3459 - ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
3460 + ei->i_flags = EXT4_I(dir)->i_flags &
3461 + ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL|EXT4_IXUNLINK_FL|EXT4_BARRIER_FL);
3463 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
3464 /* dirsync only applies to directories */
3465 @@ -866,6 +876,8 @@ got:
3467 ext4_std_error(sb, err);
3469 + DLIMIT_FREE_INODE(inode);
3474 @@ -877,6 +889,7 @@ fail_free_drop:
3478 + DLIMIT_FREE_INODE(inode);
3479 inode->i_flags |= S_NOQUOTA;
3482 diff -NurpP --minimal linux-2.6.27.14/fs/ext4/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/inode.c
3483 --- linux-2.6.27.14/fs/ext4/inode.c 2009-02-03 17:59:55.000000000 +0100
3484 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/inode.c 2009-02-03 17:59:04.000000000 +0100
3486 #include <linux/mpage.h>
3487 #include <linux/uio.h>
3488 #include <linux/bio.h>
3489 +#include <linux/vs_tag.h>
3490 #include "ext4_jbd2.h"
3493 @@ -3485,7 +3486,7 @@ static void ext4_free_branches(handle_t
3495 int ext4_can_truncate(struct inode *inode)
3497 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3498 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3500 if (S_ISREG(inode->i_mode))
3502 @@ -3844,37 +3845,86 @@ void ext4_set_inode_flags(struct inode *
3504 unsigned int flags = EXT4_I(inode)->i_flags;
3506 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3507 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3508 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3510 + if (flags & EXT4_IMMUTABLE_FL)
3511 + inode->i_flags |= S_IMMUTABLE;
3512 + if (flags & EXT4_IXUNLINK_FL)
3513 + inode->i_flags |= S_IXUNLINK;
3515 if (flags & EXT4_SYNC_FL)
3516 inode->i_flags |= S_SYNC;
3517 if (flags & EXT4_APPEND_FL)
3518 inode->i_flags |= S_APPEND;
3519 - if (flags & EXT4_IMMUTABLE_FL)
3520 - inode->i_flags |= S_IMMUTABLE;
3521 if (flags & EXT4_NOATIME_FL)
3522 inode->i_flags |= S_NOATIME;
3523 if (flags & EXT4_DIRSYNC_FL)
3524 inode->i_flags |= S_DIRSYNC;
3526 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3528 + if (flags & EXT4_BARRIER_FL)
3529 + inode->i_vflags |= V_BARRIER;
3530 + if (flags & EXT4_COW_FL)
3531 + inode->i_vflags |= V_COW;
3534 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3535 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3537 unsigned int flags = ei->vfs_inode.i_flags;
3538 + unsigned int vflags = ei->vfs_inode.i_vflags;
3540 + ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
3541 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
3542 + EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
3543 + EXT4_BARRIER_FL | EXT4_COW_FL);
3545 + if (flags & S_IMMUTABLE)
3546 + ei->i_flags |= EXT4_IMMUTABLE_FL;
3547 + if (flags & S_IXUNLINK)
3548 + ei->i_flags |= EXT4_IXUNLINK_FL;
3550 - ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3551 - EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
3553 ei->i_flags |= EXT4_SYNC_FL;
3554 if (flags & S_APPEND)
3555 ei->i_flags |= EXT4_APPEND_FL;
3556 - if (flags & S_IMMUTABLE)
3557 - ei->i_flags |= EXT4_IMMUTABLE_FL;
3558 if (flags & S_NOATIME)
3559 ei->i_flags |= EXT4_NOATIME_FL;
3560 if (flags & S_DIRSYNC)
3561 ei->i_flags |= EXT4_DIRSYNC_FL;
3563 + if (vflags & V_BARRIER)
3564 + ei->i_flags |= EXT4_BARRIER_FL;
3565 + if (vflags & V_COW)
3566 + ei->i_flags |= EXT4_COW_FL;
3569 +int ext4_sync_flags(struct inode *inode)
3571 + struct ext4_iloc iloc;
3575 + handle = ext4_journal_start(inode, 1);
3576 + if (IS_ERR(handle))
3577 + return PTR_ERR(handle);
3578 + if (IS_SYNC(inode))
3579 + handle->h_sync = 1;
3580 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3584 + ext4_get_inode_flags(EXT4_I(inode));
3585 + inode->i_ctime = CURRENT_TIME;
3587 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3589 + ext4_journal_stop(handle);
3593 static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
3594 struct ext4_inode_info *ei)
3596 @@ -3907,6 +3957,8 @@ struct inode *ext4_iget(struct super_blo
3597 struct inode *inode;
3603 inode = iget_locked(sb, ino);
3605 @@ -3927,12 +3979,17 @@ struct inode *ext4_iget(struct super_blo
3607 raw_inode = ext4_raw_inode(&iloc);
3608 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3609 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3610 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3611 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3612 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3613 if(!(test_opt (inode->i_sb, NO_UID32))) {
3614 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3615 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3616 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3617 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3619 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3620 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3621 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3622 + le16_to_cpu(raw_inode->i_raw_tag));
3624 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3627 @@ -4106,6 +4163,8 @@ static int ext4_do_update_inode(handle_t
3628 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3629 struct ext4_inode_info *ei = EXT4_I(inode);
3630 struct buffer_head *bh = iloc->bh;
3631 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3632 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3633 int err = 0, rc, block;
3635 /* For fields not not tracking in the in-memory inode,
3636 @@ -4116,29 +4175,32 @@ static int ext4_do_update_inode(handle_t
3637 ext4_get_inode_flags(ei);
3638 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3639 if(!(test_opt(inode->i_sb, NO_UID32))) {
3640 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3641 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3642 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3643 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3645 * Fix up interoperability with old kernels. Otherwise, old inodes get
3646 * re-used with the upper 16 bits of the uid/gid intact
3649 raw_inode->i_uid_high =
3650 - cpu_to_le16(high_16_bits(inode->i_uid));
3651 + cpu_to_le16(high_16_bits(uid));
3652 raw_inode->i_gid_high =
3653 - cpu_to_le16(high_16_bits(inode->i_gid));
3654 + cpu_to_le16(high_16_bits(gid));
3656 raw_inode->i_uid_high = 0;
3657 raw_inode->i_gid_high = 0;
3660 raw_inode->i_uid_low =
3661 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3662 + cpu_to_le16(fs_high2lowuid(uid));
3663 raw_inode->i_gid_low =
3664 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3665 + cpu_to_le16(fs_high2lowgid(gid));
3666 raw_inode->i_uid_high = 0;
3667 raw_inode->i_gid_high = 0;
3669 +#ifdef CONFIG_TAGGING_INTERN
3670 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3672 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3674 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3675 @@ -4302,7 +4364,8 @@ int ext4_setattr(struct dentry *dentry,
3678 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3679 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3680 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3681 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3684 /* (user+group)*(old+new) structure, inode write (sb,
3685 @@ -4324,6 +4387,8 @@ int ext4_setattr(struct dentry *dentry,
3686 inode->i_uid = attr->ia_uid;
3687 if (attr->ia_valid & ATTR_GID)
3688 inode->i_gid = attr->ia_gid;
3689 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3690 + inode->i_tag = attr->ia_tag;
3691 error = ext4_mark_inode_dirty(handle, inode);
3692 ext4_journal_stop(handle);
3694 diff -NurpP --minimal linux-2.6.27.14/fs/ext4/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/ioctl.c
3695 --- linux-2.6.27.14/fs/ext4/ioctl.c 2009-02-03 17:59:55.000000000 +0100
3696 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/ioctl.c 2009-02-03 17:59:04.000000000 +0100
3700 #include <linux/fs.h>
3701 +#include <linux/mount.h>
3702 #include <linux/jbd2.h>
3703 #include <linux/capability.h>
3704 #include <linux/time.h>
3705 #include <linux/compat.h>
3706 #include <linux/smp_lock.h>
3707 #include <linux/mount.h>
3708 +#include <linux/vs_tag.h>
3709 #include <asm/uaccess.h>
3710 #include "ext4_jbd2.h"
3712 @@ -52,6 +54,11 @@ long ext4_ioctl(struct file *filp, unsig
3713 if (!S_ISDIR(inode->i_mode))
3714 flags &= ~EXT4_DIRSYNC_FL;
3716 + if (IS_BARRIER(inode)) {
3717 + vxwprintk_task(1, "messing with the barrier.");
3722 mutex_lock(&inode->i_mutex);
3723 /* Is it quota file? Do not allow user to mess with it */
3724 @@ -69,7 +76,9 @@ long ext4_ioctl(struct file *filp, unsig
3726 * This test looks nicer. Thanks to Pauline Middelink
3728 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3729 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3730 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3731 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3732 if (!capable(CAP_LINUX_IMMUTABLE))
3735 diff -NurpP --minimal linux-2.6.27.14/fs/ext4/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/namei.c
3736 --- linux-2.6.27.14/fs/ext4/namei.c 2009-02-03 17:59:55.000000000 +0100
3737 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/namei.c 2009-02-03 17:59:04.000000000 +0100
3739 #include <linux/quotaops.h>
3740 #include <linux/buffer_head.h>
3741 #include <linux/bio.h>
3742 +#include <linux/vs_tag.h>
3744 #include "ext4_jbd2.h"
3746 @@ -914,6 +915,7 @@ restart:
3748 ll_rw_block(READ_META, 1, &bh);
3750 + dx_propagate_tag(nd, inode);
3752 if ((bh = bh_use[ra_ptr++]) == NULL)
3754 @@ -2460,6 +2462,7 @@ const struct inode_operations ext4_dir_i
3755 .removexattr = generic_removexattr,
3757 .permission = ext4_permission,
3758 + .sync_flags = ext4_sync_flags,
3761 const struct inode_operations ext4_special_inode_operations = {
3762 @@ -2471,4 +2474,5 @@ const struct inode_operations ext4_speci
3763 .removexattr = generic_removexattr,
3765 .permission = ext4_permission,
3766 + .sync_flags = ext4_sync_flags,
3768 diff -NurpP --minimal linux-2.6.27.14/fs/ext4/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/super.c
3769 --- linux-2.6.27.14/fs/ext4/super.c 2009-02-03 17:59:55.000000000 +0100
3770 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/super.c 2009-02-03 17:59:04.000000000 +0100
3771 @@ -907,6 +907,7 @@ enum {
3772 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3773 Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
3774 Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_delalloc, Opt_nodelalloc,
3775 + Opt_tag, Opt_notag, Opt_tagid
3778 static match_table_t tokens = {
3779 @@ -967,6 +968,9 @@ static match_table_t tokens = {
3780 {Opt_resize, "resize"},
3781 {Opt_delalloc, "delalloc"},
3782 {Opt_nodelalloc, "nodelalloc"},
3784 + {Opt_notag, "notag"},
3785 + {Opt_tagid, "tagid=%u"},
3789 @@ -1060,6 +1064,20 @@ static int parse_options(char *options,
3791 set_opt(sbi->s_mount_opt, NO_UID32);
3793 +#ifndef CONFIG_TAGGING_NONE
3795 + set_opt (sbi->s_mount_opt, TAGGED);
3798 + clear_opt (sbi->s_mount_opt, TAGGED);
3801 +#ifdef CONFIG_PROPAGATE
3804 + set_opt (sbi->s_mount_opt, TAGGED);
3808 clear_opt(sbi->s_mount_opt, CHECK);
3810 @@ -2033,6 +2051,9 @@ static int ext4_fill_super(struct super_
3814 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3815 + sb->s_flags |= MS_TAGGED;
3817 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3818 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3820 @@ -3015,6 +3036,13 @@ static int ext4_remount(struct super_blo
3821 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
3822 ext4_abort(sb, __func__, "Abort forced by user");
3824 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3825 + !(sb->s_flags & MS_TAGGED)) {
3826 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3831 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3832 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3834 diff -NurpP --minimal linux-2.6.27.14/fs/ext4/symlink.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/symlink.c
3835 --- linux-2.6.27.14/fs/ext4/symlink.c 2008-07-13 23:51:29.000000000 +0200
3836 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/symlink.c 2008-10-13 14:54:20.000000000 +0200
3837 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
3838 .listxattr = ext4_listxattr,
3839 .removexattr = generic_removexattr,
3841 + .sync_flags = ext4_sync_flags,
3844 const struct inode_operations ext4_fast_symlink_inode_operations = {
3845 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
3846 .listxattr = ext4_listxattr,
3847 .removexattr = generic_removexattr,
3849 + .sync_flags = ext4_sync_flags,
3851 diff -NurpP --minimal linux-2.6.27.14/fs/ext4/xattr.c linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/xattr.c
3852 --- linux-2.6.27.14/fs/ext4/xattr.c 2009-02-03 17:59:55.000000000 +0100
3853 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ext4/xattr.c 2009-02-03 17:59:04.000000000 +0100
3855 #include <linux/mbcache.h>
3856 #include <linux/quotaops.h>
3857 #include <linux/rwsem.h>
3858 +#include <linux/vs_dlimit.h>
3859 #include "ext4_jbd2.h"
3862 @@ -490,6 +491,7 @@ ext4_xattr_release_block(handle_t *handl
3863 error = ext4_journal_dirty_metadata(handle, bh);
3866 + DLIMIT_FREE_BLOCK(inode, 1);
3867 DQUOT_FREE_BLOCK(inode, 1);
3868 ea_bdebug(bh, "refcount now=%d; releasing",
3869 le32_to_cpu(BHDR(bh)->h_refcount));
3870 @@ -780,11 +782,14 @@ inserted:
3871 if (new_bh == bs->bh)
3872 ea_bdebug(new_bh, "keeping");
3875 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3877 /* The old block is released after updating
3880 if (DQUOT_ALLOC_BLOCK(inode, 1))
3882 + goto cleanup_dlimit;
3883 error = ext4_journal_get_write_access(handle,
3886 @@ -858,6 +863,8 @@ cleanup:
3889 DQUOT_FREE_BLOCK(inode, 1);
3891 + DLIMIT_FREE_BLOCK(inode, 1);
3895 diff -NurpP --minimal linux-2.6.27.14/fs/fcntl.c linux-2.6.27.14-vs2.3.0.36.4/fs/fcntl.c
3896 --- linux-2.6.27.14/fs/fcntl.c 2009-02-03 17:59:55.000000000 +0100
3897 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/fcntl.c 2009-02-03 17:59:04.000000000 +0100
3899 #include <linux/rcupdate.h>
3900 #include <linux/pid_namespace.h>
3901 #include <linux/smp_lock.h>
3902 +#include <linux/vs_limit.h>
3904 #include <asm/poll.h>
3905 #include <asm/siginfo.h>
3906 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3909 filp_close(tofree, files);
3911 + vx_openfd_inc(newfd); /* fd was unused */
3915 @@ -342,6 +345,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3919 + if (!vx_files_avail(1))
3922 err = security_file_fcntl(filp, cmd, arg);
3924 diff -NurpP --minimal linux-2.6.27.14/fs/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/file.c
3925 --- linux-2.6.27.14/fs/file.c 2008-10-13 14:52:05.000000000 +0200
3926 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/file.c 2008-10-24 04:44:48.000000000 +0200
3928 #include <linux/spinlock.h>
3929 #include <linux/rcupdate.h>
3930 #include <linux/workqueue.h>
3931 +#include <linux/vs_limit.h>
3933 struct fdtable_defer {
3935 @@ -367,6 +368,8 @@ struct files_struct *dup_fd(struct files
3936 struct file *f = *old_fds++;
3939 + /* TODO: sum it first for check and performance */
3940 + vx_openfd_inc(open_files - i);
3943 * The fd may be claimed in the fd bitmap but not yet
3944 @@ -475,6 +478,7 @@ repeat:
3946 FD_CLR(fd, fdt->close_on_exec);
3948 + vx_openfd_inc(fd);
3951 if (rcu_dereference(fdt->fd[fd]) != NULL) {
3952 diff -NurpP --minimal linux-2.6.27.14/fs/file_table.c linux-2.6.27.14-vs2.3.0.36.4/fs/file_table.c
3953 --- linux-2.6.27.14/fs/file_table.c 2008-10-13 14:52:05.000000000 +0200
3954 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/file_table.c 2008-10-13 14:54:20.000000000 +0200
3956 #include <linux/fsnotify.h>
3957 #include <linux/sysctl.h>
3958 #include <linux/percpu_counter.h>
3959 +#include <linux/vs_limit.h>
3960 +#include <linux/vs_context.h>
3962 #include <asm/atomic.h>
3964 @@ -126,6 +128,8 @@ struct file *get_empty_filp(void)
3965 f->f_gid = tsk->fsgid;
3966 eventpoll_init_file(f);
3967 /* f->f_version: 0 */
3968 + f->f_xid = vx_current_xid();
3973 @@ -276,6 +280,8 @@ void __fput(struct file *file)
3974 cdev_put(inode->i_cdev);
3975 fops_put(file->f_op);
3976 put_pid(file->f_owner.pid);
3977 + vx_files_dec(file);
3980 if (file->f_mode & FMODE_WRITE)
3981 drop_file_write_access(file);
3982 @@ -343,6 +349,8 @@ void put_filp(struct file *file)
3984 if (atomic_long_dec_and_test(&file->f_count)) {
3985 security_file_free(file);
3986 + vx_files_dec(file);
3991 diff -NurpP --minimal linux-2.6.27.14/fs/hfsplus/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/hfsplus/ioctl.c
3992 --- linux-2.6.27.14/fs/hfsplus/ioctl.c 2008-07-13 23:51:29.000000000 +0200
3993 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/hfsplus/ioctl.c 2008-10-13 14:54:20.000000000 +0200
3995 #include <linux/mount.h>
3996 #include <linux/sched.h>
3997 #include <linux/xattr.h>
3998 +#include <linux/mount.h>
3999 #include <asm/uaccess.h>
4000 #include "hfsplus_fs.h"
4002 diff -NurpP --minimal linux-2.6.27.14/fs/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/inode.c
4003 --- linux-2.6.27.14/fs/inode.c 2008-10-13 14:52:05.000000000 +0200
4004 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/inode.c 2008-10-13 14:54:20.000000000 +0200
4005 @@ -124,6 +124,9 @@ static struct inode *alloc_inode(struct
4006 struct address_space * const mapping = &inode->i_data;
4010 + /* essential because of inode slab reuse */
4012 inode->i_blkbits = sb->s_blocksize_bits;
4014 atomic_set(&inode->i_count, 1);
4015 @@ -142,6 +145,7 @@ static struct inode *alloc_inode(struct
4016 inode->i_bdev = NULL;
4017 inode->i_cdev = NULL;
4019 + inode->i_mdev = 0;
4020 inode->dirtied_when = 0;
4021 if (security_inode_alloc(inode)) {
4022 if (inode->i_sb->s_op->destroy_inode)
4023 @@ -247,6 +251,8 @@ void __iget(struct inode * inode)
4024 inodes_stat.nr_unused--;
4027 +EXPORT_SYMBOL_GPL(__iget);
4030 * clear_inode - clear an inode
4031 * @inode: inode to clear
4032 @@ -1427,9 +1433,11 @@ void init_special_inode(struct inode *in
4033 if (S_ISCHR(mode)) {
4034 inode->i_fop = &def_chr_fops;
4035 inode->i_rdev = rdev;
4036 + inode->i_mdev = rdev;
4037 } else if (S_ISBLK(mode)) {
4038 inode->i_fop = &def_blk_fops;
4039 inode->i_rdev = rdev;
4040 + inode->i_mdev = rdev;
4041 } else if (S_ISFIFO(mode))
4042 inode->i_fop = &def_fifo_fops;
4043 else if (S_ISSOCK(mode))
4044 diff -NurpP --minimal linux-2.6.27.14/fs/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/ioctl.c
4045 --- linux-2.6.27.14/fs/ioctl.c 2009-02-03 17:59:55.000000000 +0100
4046 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ioctl.c 2009-02-03 17:59:04.000000000 +0100
4048 #include <linux/security.h>
4049 #include <linux/module.h>
4050 #include <linux/uaccess.h>
4051 +#include <linux/proc_fs.h>
4052 +#include <linux/vserver/inode.h>
4053 +#include <linux/vs_tag.h>
4055 #include <asm/ioctls.h>
4057 diff -NurpP --minimal linux-2.6.27.14/fs/ioprio.c linux-2.6.27.14-vs2.3.0.36.4/fs/ioprio.c
4058 --- linux-2.6.27.14/fs/ioprio.c 2009-02-03 17:59:55.000000000 +0100
4059 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ioprio.c 2009-02-03 17:59:04.000000000 +0100
4061 #include <linux/syscalls.h>
4062 #include <linux/security.h>
4063 #include <linux/pid_namespace.h>
4064 +#include <linux/vs_base.h>
4066 static int set_task_ioprio(struct task_struct *task, int ioprio)
4068 @@ -116,6 +117,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4070 pgrp = find_vpid(who);
4071 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4072 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4074 ret = set_task_ioprio(p, ioprio);
4077 @@ -205,6 +208,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4079 pgrp = find_vpid(who);
4080 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4081 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4083 tmpio = get_task_ioprio(p);
4086 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/acl.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/acl.c
4087 --- linux-2.6.27.14/fs/jfs/acl.c 2008-10-13 14:52:05.000000000 +0200
4088 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/acl.c 2008-10-13 14:54:20.000000000 +0200
4089 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
4092 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4093 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4094 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4095 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4096 if (DQUOT_TRANSFER(inode, iattr))
4099 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/file.c
4100 --- linux-2.6.27.14/fs/jfs/file.c 2008-07-13 23:51:29.000000000 +0200
4101 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/file.c 2008-10-13 14:54:20.000000000 +0200
4102 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4103 .setattr = jfs_setattr,
4104 .permission = jfs_permission,
4106 + .sync_flags = jfs_sync_flags,
4109 const struct file_operations jfs_file_operations = {
4110 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/inode.c
4111 --- linux-2.6.27.14/fs/jfs/inode.c 2008-07-13 23:51:29.000000000 +0200
4112 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/inode.c 2008-10-13 14:54:20.000000000 +0200
4114 #include <linux/buffer_head.h>
4115 #include <linux/pagemap.h>
4116 #include <linux/quotaops.h>
4117 +#include <linux/vs_dlimit.h>
4118 #include "jfs_incore.h"
4119 #include "jfs_inode.h"
4120 #include "jfs_filsys.h"
4121 @@ -155,6 +156,7 @@ void jfs_delete_inode(struct inode *inod
4123 DQUOT_FREE_INODE(inode);
4125 + DLIMIT_FREE_INODE(inode);
4129 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/ioctl.c
4130 --- linux-2.6.27.14/fs/jfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
4131 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
4133 #include <linux/mount.h>
4134 #include <linux/time.h>
4135 #include <linux/sched.h>
4136 +#include <linux/mount.h>
4137 #include <asm/current.h>
4138 #include <asm/uaccess.h>
4140 @@ -85,6 +86,11 @@ long jfs_ioctl(struct file *filp, unsign
4141 if (!S_ISDIR(inode->i_mode))
4142 flags &= ~JFS_DIRSYNC_FL;
4144 + if (IS_BARRIER(inode)) {
4145 + vxwprintk_task(1, "messing with the barrier.");
4149 /* Is it quota file? Do not allow user to mess with it */
4150 if (IS_NOQUOTA(inode)) {
4152 @@ -102,8 +108,8 @@ long jfs_ioctl(struct file *filp, unsign
4153 * the relevant capability.
4155 if ((oldflags & JFS_IMMUTABLE_FL) ||
4156 - ((flags ^ oldflags) &
4157 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4158 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4159 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4160 if (!capable(CAP_LINUX_IMMUTABLE)) {
4161 mutex_unlock(&inode->i_mutex);
4163 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_dinode.h linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_dinode.h
4164 --- linux-2.6.27.14/fs/jfs/jfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
4165 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_dinode.h 2008-10-31 18:15:18.000000000 +0100
4166 @@ -161,9 +161,13 @@ struct dinode {
4168 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4169 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4170 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4172 -#define JFS_FL_USER_VISIBLE 0x03F80000
4173 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4174 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4175 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4177 +#define JFS_FL_USER_VISIBLE 0x07F80000
4178 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4179 #define JFS_FL_INHERIT 0x03C80000
4181 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4182 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_dtree.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_dtree.c
4183 --- linux-2.6.27.14/fs/jfs/jfs_dtree.c 2008-07-13 23:51:29.000000000 +0200
4184 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_dtree.c 2008-10-13 14:54:20.000000000 +0200
4187 #include <linux/fs.h>
4188 #include <linux/quotaops.h>
4189 +#include <linux/vs_dlimit.h>
4190 #include "jfs_incore.h"
4191 #include "jfs_superblock.h"
4192 #include "jfs_filsys.h"
4193 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
4195 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
4197 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
4198 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4201 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
4202 + goto clean_up_dquot;
4203 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
4204 + goto clean_up_dlimit;
4207 * Save the table, we're going to overwrite it with the
4208 @@ -480,6 +481,12 @@ static u32 add_index(tid_t tid, struct i
4213 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
4216 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4220 jfs_ip->next_index--;
4221 @@ -951,6 +958,7 @@ static int dtSplitUp(tid_t tid,
4224 int quota_allocation = 0;
4225 + int dlimit_allocation = 0;
4227 /* get split page */
4229 @@ -1033,6 +1041,12 @@ static int dtSplitUp(tid_t tid,
4231 quota_allocation += n;
4233 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
4237 + dlimit_allocation += n;
4239 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
4242 @@ -1306,6 +1320,9 @@ static int dtSplitUp(tid_t tid,
4246 + /* Rollback dlimit allocation */
4247 + if (rc && dlimit_allocation)
4248 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4249 /* Rollback quota allocation */
4250 if (rc && quota_allocation)
4251 DQUOT_FREE_BLOCK(ip, quota_allocation);
4252 @@ -1373,6 +1390,12 @@ static int dtSplitPage(tid_t tid, struct
4253 release_metapage(rmp);
4256 + /* Allocate blocks to dlimit. */
4257 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4258 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4259 + release_metapage(rmp);
4263 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
4265 @@ -1920,6 +1943,12 @@ static int dtSplitRoot(tid_t tid,
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 BT_MARK_DIRTY(rmp, ip);
4278 @@ -2286,6 +2315,8 @@ static int dtDeleteUp(tid_t tid, struct
4280 xlen = lengthPXD(&fp->header.self);
4282 + /* Free dlimit allocation. */
4283 + DLIMIT_FREE_BLOCK(ip, xlen);
4284 /* Free quota allocation. */
4285 DQUOT_FREE_BLOCK(ip, xlen);
4287 @@ -2362,6 +2393,8 @@ static int dtDeleteUp(tid_t tid, struct
4289 xlen = lengthPXD(&p->header.self);
4291 + /* Free dlimit allocation */
4292 + DLIMIT_FREE_BLOCK(ip, xlen);
4293 /* Free quota allocation */
4294 DQUOT_FREE_BLOCK(ip, xlen);
4296 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_extent.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_extent.c
4297 --- linux-2.6.27.14/fs/jfs/jfs_extent.c 2008-07-13 23:51:29.000000000 +0200
4298 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_extent.c 2008-10-13 14:54:20.000000000 +0200
4301 #include <linux/fs.h>
4302 #include <linux/quotaops.h>
4303 +#include <linux/vs_dlimit.h>
4304 #include "jfs_incore.h"
4305 #include "jfs_inode.h"
4306 #include "jfs_superblock.h"
4307 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
4311 + /* Allocate blocks to dlimit. */
4312 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4313 + DQUOT_FREE_BLOCK(ip, nxlen);
4314 + dbFree(ip, nxaddr, (s64) nxlen);
4315 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
4319 /* determine the value of the extent flag */
4320 xflag = abnr ? XAD_NOTRECORDED : 0;
4322 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
4325 dbFree(ip, nxaddr, nxlen);
4326 + DLIMIT_FREE_BLOCK(ip, nxlen);
4327 DQUOT_FREE_BLOCK(ip, nxlen);
4328 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4330 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
4331 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4334 + /* Allocate blocks to dlimit. */
4335 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4336 + DQUOT_FREE_BLOCK(ip, nxlen);
4337 + dbFree(ip, nxaddr, (s64) nxlen);
4338 + up(&JFS_IP(ip)->commit_sem);
4342 delta = nxlen - xlen;
4344 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
4345 /* extend the extent */
4346 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
4347 dbFree(ip, xaddr + xlen, delta);
4348 + DLIMIT_FREE_BLOCK(ip, nxlen);
4349 DQUOT_FREE_BLOCK(ip, nxlen);
4352 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
4354 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
4355 dbFree(ip, nxaddr, nxlen);
4356 + DLIMIT_FREE_BLOCK(ip, nxlen);
4357 DQUOT_FREE_BLOCK(ip, nxlen);
4360 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_filsys.h linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_filsys.h
4361 --- linux-2.6.27.14/fs/jfs/jfs_filsys.h 2008-07-13 23:51:29.000000000 +0200
4362 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_filsys.h 2008-10-13 14:54:20.000000000 +0200
4364 #define JFS_NAME_MAX 255
4365 #define JFS_PATH_MAX BPSIZE
4367 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4370 * file system state (superblock state)
4371 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_imap.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_imap.c
4372 --- linux-2.6.27.14/fs/jfs/jfs_imap.c 2008-10-13 14:52:05.000000000 +0200
4373 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_imap.c 2008-10-13 14:54:20.000000000 +0200
4375 #include <linux/buffer_head.h>
4376 #include <linux/pagemap.h>
4377 #include <linux/quotaops.h>
4378 +#include <linux/vs_tag.h>
4380 #include "jfs_incore.h"
4381 #include "jfs_inode.h"
4382 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
4384 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4385 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4389 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4390 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4391 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
4393 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4395 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4396 + uid = le32_to_cpu(dip->di_uid);
4397 + gid = le32_to_cpu(dip->di_gid);
4398 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4400 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4402 ip->i_uid = jfs_ip->saved_uid;
4404 ip->i_uid = sbi->uid;
4407 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4408 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4410 ip->i_gid = jfs_ip->saved_gid;
4412 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
4413 dip->di_size = cpu_to_le64(ip->i_size);
4414 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4415 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4416 - if (sbi->uid == -1)
4417 - dip->di_uid = cpu_to_le32(ip->i_uid);
4419 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4420 - if (sbi->gid == -1)
4421 - dip->di_gid = cpu_to_le32(ip->i_gid);
4423 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4425 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4426 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4427 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4428 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4430 jfs_get_inode_flags(jfs_ip);
4432 * mode2 is only needed for storing the higher order bits.
4433 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_inode.c
4434 --- linux-2.6.27.14/fs/jfs/jfs_inode.c 2008-07-13 23:51:29.000000000 +0200
4435 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_inode.c 2008-10-13 14:54:20.000000000 +0200
4438 #include <linux/fs.h>
4439 #include <linux/quotaops.h>
4440 +#include <linux/vs_dlimit.h>
4441 +#include <linux/vs_tag.h>
4442 #include "jfs_incore.h"
4443 #include "jfs_inode.h"
4444 #include "jfs_filsys.h"
4445 @@ -30,29 +32,46 @@ void jfs_set_inode_flags(struct inode *i
4447 unsigned int flags = JFS_IP(inode)->mode2;
4449 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4450 - S_NOATIME | S_DIRSYNC | S_SYNC);
4451 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4452 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4454 if (flags & JFS_IMMUTABLE_FL)
4455 inode->i_flags |= S_IMMUTABLE;
4456 + if (flags & JFS_IXUNLINK_FL)
4457 + inode->i_flags |= S_IXUNLINK;
4459 + if (flags & JFS_SYNC_FL)
4460 + inode->i_flags |= S_SYNC;
4461 if (flags & JFS_APPEND_FL)
4462 inode->i_flags |= S_APPEND;
4463 if (flags & JFS_NOATIME_FL)
4464 inode->i_flags |= S_NOATIME;
4465 if (flags & JFS_DIRSYNC_FL)
4466 inode->i_flags |= S_DIRSYNC;
4467 - if (flags & JFS_SYNC_FL)
4468 - inode->i_flags |= S_SYNC;
4470 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4472 + if (flags & JFS_BARRIER_FL)
4473 + inode->i_vflags |= V_BARRIER;
4474 + if (flags & JFS_COW_FL)
4475 + inode->i_vflags |= V_COW;
4478 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4480 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4481 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4483 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4484 + JFS_APPEND_FL | JFS_NOATIME_FL |
4485 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4486 + JFS_BARRIER_FL | JFS_COW_FL);
4488 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4489 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4490 if (flags & S_IMMUTABLE)
4491 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4492 + if (flags & S_IXUNLINK)
4493 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4495 if (flags & S_APPEND)
4496 jfs_ip->mode2 |= JFS_APPEND_FL;
4497 if (flags & S_NOATIME)
4498 @@ -61,6 +80,19 @@ void jfs_get_inode_flags(struct jfs_inod
4499 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4501 jfs_ip->mode2 |= JFS_SYNC_FL;
4503 + if (vflags & V_BARRIER)
4504 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4505 + if (vflags & V_COW)
4506 + jfs_ip->mode2 |= JFS_COW_FL;
4509 +int jfs_sync_flags(struct inode *inode)
4511 + jfs_get_inode_flags(JFS_IP(inode));
4512 + inode->i_ctime = CURRENT_TIME;
4513 + mark_inode_dirty(inode);
4518 @@ -108,10 +140,17 @@ struct inode *ialloc(struct inode *paren
4519 jfs_inode->saved_uid = inode->i_uid;
4520 jfs_inode->saved_gid = inode->i_gid;
4522 + inode->i_tag = dx_current_fstag(sb);
4523 + if (DLIMIT_ALLOC_INODE(inode)) {
4525 + return ERR_PTR(-ENOSPC);
4529 * Allocate inode to quota.
4531 if (DQUOT_ALLOC_INODE(inode)) {
4532 + DLIMIT_FREE_INODE(inode);
4534 inode->i_flags |= S_NOQUOTA;
4536 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_inode.h linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_inode.h
4537 --- linux-2.6.27.14/fs/jfs/jfs_inode.h 2008-07-13 23:51:29.000000000 +0200
4538 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_inode.h 2008-10-13 14:54:20.000000000 +0200
4539 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4540 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4541 int fh_len, int fh_type);
4542 extern void jfs_set_inode_flags(struct inode *);
4543 +extern int jfs_sync_flags(struct inode *);
4544 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4546 extern const struct address_space_operations jfs_aops;
4547 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/jfs_xtree.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_xtree.c
4548 --- linux-2.6.27.14/fs/jfs/jfs_xtree.c 2008-10-13 14:52:05.000000000 +0200
4549 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/jfs_xtree.c 2008-10-13 14:54:20.000000000 +0200
4551 #include <linux/module.h>
4552 #include <linux/quotaops.h>
4553 #include <linux/seq_file.h>
4554 +#include <linux/vs_dlimit.h>
4555 #include "jfs_incore.h"
4556 #include "jfs_filsys.h"
4557 #include "jfs_metapage.h"
4558 @@ -848,7 +849,12 @@ int xtInsert(tid_t tid, /* transaction
4560 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
4562 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
4563 + DQUOT_FREE_BLOCK(ip, xlen);
4566 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
4567 + DLIMIT_FREE_BLOCK(ip, xlen);
4568 DQUOT_FREE_BLOCK(ip, xlen);
4571 @@ -878,6 +884,7 @@ int xtInsert(tid_t tid, /* transaction
4572 /* undo data extent allocation */
4574 dbFree(ip, xaddr, (s64) xlen);
4575 + DLIMIT_FREE_BLOCK(ip, xlen);
4576 DQUOT_FREE_BLOCK(ip, xlen);
4579 @@ -1234,6 +1241,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
4581 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
4582 int quota_allocation = 0;
4583 + int dlimit_allocation = 0;
4586 sp = XT_PAGE(ip, smp);
4587 @@ -1253,6 +1261,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
4589 quota_allocation += lengthPXD(pxd);
4591 + /* Allocate blocks to dlimit. */
4592 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4596 + dlimit_allocation += lengthPXD(pxd);
4599 * allocate the new right page for the split
4601 @@ -1454,6 +1469,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
4605 + /* Rollback dlimit allocation. */
4606 + if (dlimit_allocation)
4607 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4608 /* Rollback quota allocation. */
4609 if (quota_allocation)
4610 DQUOT_FREE_BLOCK(ip, quota_allocation);
4611 @@ -1517,6 +1535,12 @@ xtSplitRoot(tid_t tid,
4612 release_metapage(rmp);
4615 + /* Allocate blocks to dlimit. */
4616 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4617 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4618 + release_metapage(rmp);
4622 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
4624 @@ -3940,6 +3964,8 @@ s64 xtTruncate(tid_t tid, struct inode *
4626 ip->i_size = newsize;
4628 + /* update dlimit allocation to reflect freed blocks */
4629 + DLIMIT_FREE_BLOCK(ip, nfreed);
4630 /* update quota allocation to reflect freed blocks */
4631 DQUOT_FREE_BLOCK(ip, nfreed);
4633 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/namei.c
4634 --- linux-2.6.27.14/fs/jfs/namei.c 2008-10-13 14:52:05.000000000 +0200
4635 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/namei.c 2008-10-13 14:54:20.000000000 +0200
4637 #include <linux/ctype.h>
4638 #include <linux/quotaops.h>
4639 #include <linux/exportfs.h>
4640 +#include <linux/vs_tag.h>
4641 #include "jfs_incore.h"
4642 #include "jfs_superblock.h"
4643 #include "jfs_inode.h"
4644 @@ -1468,6 +1469,7 @@ static struct dentry *jfs_lookup(struct
4645 return ERR_CAST(ip);
4648 + dx_propagate_tag(nd, ip);
4649 dentry = d_splice_alias(ip, dentry);
4651 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4652 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
4653 .setattr = jfs_setattr,
4654 .permission = jfs_permission,
4656 + .sync_flags = jfs_sync_flags,
4659 const struct file_operations jfs_dir_operations = {
4660 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/super.c
4661 --- linux-2.6.27.14/fs/jfs/super.c 2008-10-13 14:52:05.000000000 +0200
4662 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/super.c 2008-10-13 14:54:20.000000000 +0200
4663 @@ -196,7 +196,8 @@ static void jfs_put_super(struct super_b
4665 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4666 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4667 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4668 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4669 + Opt_tag, Opt_notag, Opt_tagid
4672 static match_table_t tokens = {
4673 @@ -206,6 +207,10 @@ static match_table_t tokens = {
4674 {Opt_resize, "resize=%u"},
4675 {Opt_resize_nosize, "resize"},
4676 {Opt_errors, "errors=%s"},
4678 + {Opt_notag, "notag"},
4679 + {Opt_tagid, "tagid=%u"},
4680 + {Opt_tag, "tagxid"},
4681 {Opt_ignore, "noquota"},
4682 {Opt_ignore, "quota"},
4683 {Opt_usrquota, "usrquota"},
4684 @@ -340,6 +345,20 @@ static int parse_options(char *options,
4688 +#ifndef CONFIG_TAGGING_NONE
4690 + *flag |= JFS_TAGGED;
4693 + *flag &= JFS_TAGGED;
4696 +#ifdef CONFIG_PROPAGATE
4699 + *flag |= JFS_TAGGED;
4703 printk("jfs: Unrecognized mount option \"%s\" "
4704 " or missing value\n", p);
4705 @@ -370,6 +389,13 @@ static int jfs_remount(struct super_bloc
4706 if (!parse_options(data, sb, &newLVSize, &flag)) {
4710 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4711 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4717 if (sb->s_flags & MS_RDONLY) {
4719 @@ -441,6 +467,9 @@ static int jfs_fill_super(struct super_b
4720 #ifdef CONFIG_JFS_POSIX_ACL
4721 sb->s_flags |= MS_POSIXACL;
4723 + /* map mount option tagxid */
4724 + if (sbi->flag & JFS_TAGGED)
4725 + sb->s_flags |= MS_TAGGED;
4728 printk(KERN_ERR "resize option for remount only\n");
4729 diff -NurpP --minimal linux-2.6.27.14/fs/jfs/xattr.c linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/xattr.c
4730 --- linux-2.6.27.14/fs/jfs/xattr.c 2008-07-13 23:51:29.000000000 +0200
4731 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/jfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
4733 #include <linux/posix_acl_xattr.h>
4734 #include <linux/quotaops.h>
4735 #include <linux/security.h>
4736 +#include <linux/vs_dlimit.h>
4737 #include "jfs_incore.h"
4738 #include "jfs_superblock.h"
4739 #include "jfs_dmap.h"
4740 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
4741 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
4744 + /* Allocate new blocks to dlimit. */
4745 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
4746 + DQUOT_FREE_BLOCK(ip, nblocks);
4750 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
4752 + /*Rollback dlimit allocation. */
4753 + DLIMIT_FREE_BLOCK(ip, nblocks);
4754 /*Rollback quota allocation. */
4755 DQUOT_FREE_BLOCK(ip, nblocks);
4757 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
4760 /* Rollback quota allocation. */
4761 + DLIMIT_FREE_BLOCK(ip, nblocks);
4762 + /* Rollback quota allocation. */
4763 DQUOT_FREE_BLOCK(ip, nblocks);
4765 dbFree(ip, blkno, nblocks);
4766 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
4769 int quota_allocation = 0;
4770 + int dlimit_allocation = 0;
4772 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
4773 if (ji->ea.flag == 0)
4774 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
4776 quota_allocation = blocks_needed;
4778 + /* Allocate new blocks to dlimit. */
4780 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
4782 + dlimit_allocation = blocks_needed;
4784 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
4787 @@ -600,6 +617,9 @@ static int ea_get(struct inode *inode, s
4791 + /* Rollback dlimit allocation */
4792 + if (dlimit_allocation)
4793 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
4794 /* Rollback quota allocation */
4795 if (quota_allocation)
4796 DQUOT_FREE_BLOCK(inode, quota_allocation);
4797 @@ -676,8 +696,10 @@ static int ea_put(tid_t tid, struct inod
4800 /* If old blocks exist, they must be removed from quota allocation. */
4803 + DLIMIT_FREE_BLOCK(inode, old_blocks);
4804 DQUOT_FREE_BLOCK(inode, old_blocks);
4807 inode->i_ctime = CURRENT_TIME;
4809 diff -NurpP --minimal linux-2.6.27.14/fs/libfs.c linux-2.6.27.14-vs2.3.0.36.4/fs/libfs.c
4810 --- linux-2.6.27.14/fs/libfs.c 2009-02-03 17:59:55.000000000 +0100
4811 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/libfs.c 2009-02-03 17:59:04.000000000 +0100
4812 @@ -125,7 +125,8 @@ static inline unsigned char dt_type(stru
4813 * both impossible due to the lock on directory.
4816 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4817 +static inline int do_dcache_readdir_filter(struct file *filp,
4818 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4820 struct dentry *dentry = filp->f_path.dentry;
4821 struct dentry *cursor = filp->private_data;
4822 @@ -158,6 +159,8 @@ int dcache_readdir(struct file * filp, v
4823 next = list_entry(p, struct dentry, d_u.d_child);
4824 if (d_unhashed(next) || !next->d_inode)
4826 + if (filter && !filter(next))
4829 spin_unlock(&dcache_lock);
4830 if (filldir(dirent, next->d_name.name,
4831 @@ -176,6 +179,18 @@ int dcache_readdir(struct file * filp, v
4835 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4837 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4840 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4841 + int (*filter)(struct dentry *))
4843 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4847 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4850 @@ -823,6 +838,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4851 EXPORT_SYMBOL(dcache_dir_lseek);
4852 EXPORT_SYMBOL(dcache_dir_open);
4853 EXPORT_SYMBOL(dcache_readdir);
4854 +EXPORT_SYMBOL(dcache_readdir_filter);
4855 EXPORT_SYMBOL(generic_read_dir);
4856 EXPORT_SYMBOL(get_sb_pseudo);
4857 EXPORT_SYMBOL(simple_write_begin);
4858 diff -NurpP --minimal linux-2.6.27.14/fs/locks.c linux-2.6.27.14-vs2.3.0.36.4/fs/locks.c
4859 --- linux-2.6.27.14/fs/locks.c 2009-02-03 17:59:55.000000000 +0100
4860 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/locks.c 2009-02-03 17:59:04.000000000 +0100
4862 #include <linux/time.h>
4863 #include <linux/rcupdate.h>
4864 #include <linux/pid_namespace.h>
4865 +#include <linux/vs_base.h>
4866 +#include <linux/vs_limit.h>
4868 #include <asm/uaccess.h>
4870 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
4871 /* Allocate an empty lock structure. */
4872 static struct file_lock *locks_alloc_lock(void)
4874 + if (!vx_locks_avail(1))
4876 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4879 @@ -173,6 +177,7 @@ static void locks_free_lock(struct file_
4880 BUG_ON(!list_empty(&fl->fl_block));
4881 BUG_ON(!list_empty(&fl->fl_link));
4884 locks_release_private(fl);
4885 kmem_cache_free(filelock_cache, fl);
4887 @@ -193,6 +198,7 @@ void locks_init_lock(struct file_lock *f
4888 fl->fl_start = fl->fl_end = 0;
4890 fl->fl_lmops = NULL;
4894 EXPORT_SYMBOL(locks_init_lock);
4895 @@ -247,6 +253,7 @@ void locks_copy_lock(struct file_lock *n
4896 new->fl_file = fl->fl_file;
4897 new->fl_ops = fl->fl_ops;
4898 new->fl_lmops = fl->fl_lmops;
4899 + new->fl_xid = fl->fl_xid;
4901 locks_copy_private(new, fl);
4903 @@ -285,6 +292,11 @@ static int flock_make_lock(struct file *
4904 fl->fl_flags = FL_FLOCK;
4906 fl->fl_end = OFFSET_MAX;
4908 + vxd_assert(filp->f_xid == vx_current_xid(),
4909 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4910 + fl->fl_xid = filp->f_xid;
4915 @@ -450,6 +462,7 @@ static int lease_init(struct file *filp,
4917 fl->fl_owner = current->files;
4918 fl->fl_pid = current->tgid;
4919 + fl->fl_xid = vx_current_xid();
4922 fl->fl_flags = FL_LEASE;
4923 @@ -469,6 +482,11 @@ static struct file_lock *lease_alloc(str
4925 return ERR_PTR(error);
4927 + fl->fl_xid = vx_current_xid();
4929 + vxd_assert(filp->f_xid == fl->fl_xid,
4930 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4932 error = lease_init(filp, type, fl);
4934 locks_free_lock(fl);
4935 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
4939 + new_fl->fl_xid = -1;
4941 for_each_lock(inode, before) {
4942 struct file_lock *fl = *before;
4943 @@ -789,6 +808,7 @@ find_conflict:
4945 locks_copy_lock(new_fl, request);
4946 locks_insert_lock(before, new_fl);
4947 + vx_locks_inc(new_fl);
4951 @@ -799,7 +819,8 @@ out:
4955 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4956 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4957 + struct file_lock *conflock, xid_t xid)
4959 struct file_lock *fl;
4960 struct file_lock *new_fl = NULL;
4961 @@ -809,6 +830,8 @@ static int __posix_lock_file(struct inod
4962 struct file_lock **before;
4963 int error, added = 0;
4965 + vxd_assert(xid == vx_current_xid(),
4966 + "xid(%d) == current(%d)", xid, vx_current_xid());
4968 * We may need two file_lock structures for this operation,
4969 * so we get them in advance to avoid races.
4970 @@ -819,7 +842,11 @@ static int __posix_lock_file(struct inod
4971 (request->fl_type != F_UNLCK ||
4972 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4973 new_fl = locks_alloc_lock();
4974 + new_fl->fl_xid = xid;
4975 + vx_locks_inc(new_fl);
4976 new_fl2 = locks_alloc_lock();
4977 + new_fl2->fl_xid = xid;
4978 + vx_locks_inc(new_fl2);
4982 @@ -1018,7 +1045,8 @@ static int __posix_lock_file(struct inod
4983 int posix_lock_file(struct file *filp, struct file_lock *fl,
4984 struct file_lock *conflock)
4986 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4987 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4988 + fl, conflock, filp->f_xid);
4990 EXPORT_SYMBOL(posix_lock_file);
4992 @@ -1108,7 +1136,7 @@ int locks_mandatory_area(int read_write,
4993 fl.fl_end = offset + count - 1;
4996 - error = __posix_lock_file(inode, &fl, NULL);
4997 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4998 if (error != FILE_LOCK_DEFERRED)
5000 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
5001 @@ -1423,6 +1451,7 @@ int generic_setlease(struct file *filp,
5003 locks_copy_lock(new_fl, lease);
5004 locks_insert_lock(before, new_fl);
5005 + vx_locks_inc(new_fl);
5009 @@ -1777,6 +1806,11 @@ int fcntl_setlk(unsigned int fd, struct
5010 if (file_lock == NULL)
5013 + vxd_assert(filp->f_xid == vx_current_xid(),
5014 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5015 + file_lock->fl_xid = filp->f_xid;
5016 + vx_locks_inc(file_lock);
5019 * This might block, so we do it before checking the inode.
5021 @@ -1895,6 +1929,11 @@ int fcntl_setlk64(unsigned int fd, struc
5022 if (file_lock == NULL)
5025 + vxd_assert(filp->f_xid == vx_current_xid(),
5026 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5027 + file_lock->fl_xid = filp->f_xid;
5028 + vx_locks_inc(file_lock);
5031 * This might block, so we do it before checking the inode.
5033 @@ -2159,8 +2198,11 @@ static int locks_show(struct seq_file *f
5035 lock_get_status(f, fl, (long)f->private, "");
5037 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
5038 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
5039 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
5041 lock_get_status(f, bfl, (long)f->private, " ->");
5046 diff -NurpP --minimal linux-2.6.27.14/fs/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/namei.c
5047 --- linux-2.6.27.14/fs/namei.c 2009-02-03 17:59:55.000000000 +0100
5048 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/namei.c 2009-02-03 17:59:04.000000000 +0100
5050 #include <linux/file.h>
5051 #include <linux/fcntl.h>
5052 #include <linux/device_cgroup.h>
5053 +#include <linux/proc_fs.h>
5054 +#include <linux/vserver/inode.h>
5055 +#include <linux/vs_base.h>
5056 +#include <linux/vs_tag.h>
5057 +#include <linux/vs_cowbl.h>
5058 +#include <linux/vs_device.h>
5059 +#include <linux/vs_context.h>
5060 +#include <linux/pid_namespace.h>
5061 #include <asm/uaccess.h>
5063 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
5064 @@ -167,6 +175,77 @@ void putname(const char *name)
5065 EXPORT_SYMBOL(putname);
5068 +static inline int dx_barrier(struct inode *inode)
5070 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
5071 + vxwprintk_task(1, "did hit the barrier.");
5077 +static int __dx_permission(struct inode *inode, int mask)
5079 + if (dx_barrier(inode))
5082 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
5083 + /* devpts is xid tagged */
5084 + if (S_ISDIR(inode->i_mode) ||
5085 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
5088 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5089 + struct proc_dir_entry *de = PDE(inode);
5091 + if (de && !vx_hide_check(0, de->vx_flags))
5094 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
5096 + struct task_struct *tsk;
5098 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
5099 + vx_flags(VXF_STATE_SETUP, 0))
5102 + pid = PROC_I(inode)->pid;
5106 + tsk = pid_task(pid, PIDTYPE_PID);
5107 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
5108 + tsk, (tsk ? vx_task_xid(tsk) : 0));
5109 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
5113 + /* FIXME: Should we block some entries here? */
5118 + if (dx_notagcheck(inode->i_sb) ||
5119 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
5128 +int dx_permission(struct inode *inode, int mask)
5130 + int ret = __dx_permission(inode, mask);
5131 + if (unlikely(ret)) {
5132 + vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
5133 + mask, inode->i_sb->s_id, inode, inode->i_tag,
5141 * generic_permission - check for access rights on a Posix-like filesystem
5142 @@ -244,10 +323,14 @@ int inode_permission(struct inode *inode
5144 * Nobody gets write access to an immutable file.
5146 - if (IS_IMMUTABLE(inode))
5147 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5151 + retval = dx_permission(inode, mask);
5155 /* Ordinary permission routines do not understand MAY_APPEND. */
5156 if (inode->i_op && inode->i_op->permission) {
5157 retval = inode->i_op->permission(inode, mask);
5158 @@ -451,6 +534,8 @@ static int exec_permission_lite(struct i
5160 umode_t mode = inode->i_mode;
5162 + if (dx_barrier(inode))
5164 if (inode->i_op && inode->i_op->permission)
5167 @@ -773,7 +858,8 @@ static __always_inline void follow_dotdo
5168 if (nd->path.dentry == fs->root.dentry &&
5169 nd->path.mnt == fs->root.mnt) {
5170 read_unlock(&fs->lock);
5172 + /* for sane '/' avoid follow_mount() */
5175 read_unlock(&fs->lock);
5176 spin_lock(&dcache_lock);
5177 @@ -810,16 +896,30 @@ static int do_lookup(struct nameidata *n
5179 struct vfsmount *mnt = nd->path.mnt;
5180 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
5181 + struct inode *inode;
5185 if (dentry->d_op && dentry->d_op->d_revalidate)
5186 goto need_revalidate;
5187 + inode = dentry->d_inode;
5191 + if (__dx_permission(inode, MAY_ACCESS))
5196 path->dentry = dentry;
5197 __follow_mount(path);
5200 + vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] »%s«.",
5201 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5202 + vxd_path(&nd->path));
5207 dentry = real_lookup(nd->path.dentry, name, nd);
5208 @@ -1407,7 +1507,7 @@ static int may_delete(struct inode *dir,
5211 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5212 - IS_IMMUTABLE(victim->d_inode))
5213 + IS_IXORUNLINK(victim->d_inode))
5216 if (!S_ISDIR(victim->d_inode->i_mode))
5217 @@ -1551,6 +1651,14 @@ int may_open(struct nameidata *nd, int a
5221 +#ifdef CONFIG_VSERVER_COWBL
5222 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5223 + if (IS_COW_LINK(inode))
5225 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5226 + mark_inode_dirty(inode);
5229 error = vfs_permission(nd, acc_mode);
5232 @@ -1677,6 +1785,11 @@ struct file *do_filp_open(int dfd, const
5234 int flag = open_to_namei_flags(open_flag);
5236 +#ifdef CONFIG_VSERVER_COWBL
5241 acc_mode = MAY_OPEN | ACC_MODE(flag);
5243 /* O_TRUNC implies we need access checks for write permissions */
5244 @@ -1800,6 +1913,25 @@ ok:
5247 error = may_open(&nd, acc_mode, flag);
5248 +#ifdef CONFIG_VSERVER_COWBL
5249 + if (error == -EMLINK) {
5250 + struct dentry *dentry;
5251 + dentry = cow_break_link(pathname);
5252 + if (IS_ERR(dentry)) {
5253 + error = PTR_ERR(dentry);
5258 + mnt_drop_write(nd.path.mnt);
5259 + release_open_intent(&nd);
5260 + path_put(&nd.path);
5269 mnt_drop_write(nd.path.mnt);
5270 @@ -1952,9 +2084,17 @@ int vfs_mknod(struct inode *dir, struct
5274 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5275 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5278 + if (!capable(CAP_MKNOD))
5281 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5283 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5286 if (!dir->i_op || !dir->i_op->mknod)
5289 @@ -2395,7 +2535,7 @@ int vfs_link(struct dentry *old_dentry,
5291 * A link to an append-only or immutable file cannot be created.
5293 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5294 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5296 if (!dir->i_op || !dir->i_op->link)
5298 @@ -2755,6 +2895,217 @@ int vfs_follow_link(struct nameidata *nd
5299 return __vfs_follow_link(nd, link);
5303 +#ifdef CONFIG_VSERVER_COWBL
5305 +#include <linux/file.h>
5308 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5312 + return do_splice_direct(in, &ppos, out, len, 0);
5315 +struct dentry *cow_break_link(const char *pathname)
5317 + int ret, mode, pathlen, redo = 0;
5318 + struct nameidata old_nd, dir_nd;
5319 + struct path old_path, new_path;
5320 + struct dentry *dir, *res = NULL;
5321 + struct file *old_file;
5322 + struct file *new_file;
5323 + char *to, *path, pad='\251';
5326 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
5327 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5332 + /* old_nd will have refs to dentry and mnt */
5333 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5334 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5336 + goto out_free_path;
5338 + old_path = old_nd.path;
5339 + mode = old_path.dentry->d_inode->i_mode;
5341 + to = d_path(&old_path, path, PATH_MAX-2);
5342 + pathlen = strlen(to);
5343 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
5344 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5345 + old_path.dentry->d_name.len);
5347 + to[pathlen + 1] = 0;
5349 + to[pathlen] = pad--;
5351 + if (pad <= '\240')
5354 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
5355 + /* dir_nd will have refs to dentry and mnt */
5356 + ret = path_lookup(to,
5357 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5358 + vxdprintk(VXD_CBIT(misc, 2),
5359 + "path_lookup(new): %d", ret);
5363 + /* this puppy downs the inode mutex */
5364 + new_path.dentry = lookup_create(&dir_nd, 0);
5365 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5366 + vxdprintk(VXD_CBIT(misc, 2),
5367 + "lookup_create(new): %p", new_path.dentry);
5368 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5369 + path_put(&dir_nd.path);
5372 + vxdprintk(VXD_CBIT(misc, 2),
5373 + "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
5374 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5375 + new_path.dentry->d_name.len);
5376 + dir = dir_nd.path.dentry;
5378 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5379 + vxdprintk(VXD_CBIT(misc, 2),
5380 + "vfs_create(new): %d", ret);
5381 + if (ret == -EEXIST) {
5382 + mutex_unlock(&dir->d_inode->i_mutex);
5383 + dput(new_path.dentry);
5384 + path_put(&dir_nd.path);
5388 + goto out_unlock_new;
5390 + /* drop out early, ret passes ENOENT */
5392 + if ((redo = d_unhashed(old_path.dentry)))
5393 + goto out_unlock_new;
5395 + new_path.mnt = dir_nd.path.mnt;
5396 + dget(old_path.dentry);
5397 + mntget(old_path.mnt);
5398 + /* this one cleans up the dentry/mnt in case of failure */
5399 + old_file = dentry_open(old_path.dentry, old_path.mnt, O_RDONLY);
5400 + vxdprintk(VXD_CBIT(misc, 2),
5401 + "dentry_open(old): %p", old_file);
5402 + if (!old_file || IS_ERR(old_file)) {
5403 + res = IS_ERR(old_file) ? (void *) old_file : res;
5404 + goto out_unlock_new;
5407 + dget(new_path.dentry);
5408 + mntget(new_path.mnt);
5409 + /* this one cleans up the dentry/mnt in case of failure */
5410 + new_file = dentry_open(new_path.dentry, new_path.mnt, O_WRONLY);
5411 + vxdprintk(VXD_CBIT(misc, 2),
5412 + "dentry_open(new): %p", new_file);
5414 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5415 + if (!new_file || IS_ERR(new_file))
5416 + goto out_fput_old;
5418 + size = i_size_read(old_file->f_dentry->d_inode);
5419 + ret = do_cow_splice(old_file, new_file, size);
5420 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5422 + goto out_fput_both;
5423 + } else if (ret < size) {
5425 + goto out_fput_both;
5427 + struct inode *old_inode = old_path.dentry->d_inode;
5428 + struct inode *new_inode = new_path.dentry->d_inode;
5429 + struct iattr attr = {
5430 + .ia_uid = old_inode->i_uid,
5431 + .ia_gid = old_inode->i_gid,
5432 + .ia_valid = ATTR_UID | ATTR_GID
5435 + ret = inode_setattr(new_inode, &attr);
5437 + goto out_fput_both;
5440 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5442 + /* drop out late */
5444 + if ((redo = d_unhashed(old_path.dentry)))
5447 + vxdprintk(VXD_CBIT(misc, 2),
5448 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
5449 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5450 + new_path.dentry->d_name.len,
5451 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5452 + old_path.dentry->d_name.len);
5453 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5454 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5455 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5456 + res = new_path.dentry;
5459 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5462 + vxdprintk(VXD_CBIT(misc, 3),
5463 + "fput(new_file=%p[#%ld])", new_file,
5464 + atomic_read(&new_file->f_count));
5468 + vxdprintk(VXD_CBIT(misc, 3),
5469 + "fput(old_file=%p[#%ld])", old_file,
5470 + atomic_read(&old_file->f_count));
5474 + mutex_unlock(&dir->d_inode->i_mutex);
5478 + /* error path cleanup */
5479 + vfs_unlink(dir->d_inode, new_path.dentry);
5480 + dput(new_path.dentry);
5484 + goto out_rel_both;
5485 + /* lookup dentry once again */
5486 + path_put(&old_nd.path);
5487 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5489 + goto out_rel_both;
5491 + new_path.dentry = old_nd.path.dentry;
5492 + vxdprintk(VXD_CBIT(misc, 2),
5493 + "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
5494 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5495 + new_path.dentry->d_name.len);
5496 + dget(new_path.dentry);
5497 + res = new_path.dentry;
5500 + path_put(&dir_nd.path);
5502 + path_put(&old_nd.path);
5507 + res = ERR_PTR(ret);
5513 /* get the link contents into pagecache */
5514 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5516 diff -NurpP --minimal linux-2.6.27.14/fs/namespace.c linux-2.6.27.14-vs2.3.0.36.4/fs/namespace.c
5517 --- linux-2.6.27.14/fs/namespace.c 2009-02-03 17:59:55.000000000 +0100
5518 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/namespace.c 2009-02-03 17:59:04.000000000 +0100
5520 #include <linux/ramfs.h>
5521 #include <linux/log2.h>
5522 #include <linux/idr.h>
5523 +#include <linux/vs_base.h>
5524 +#include <linux/vs_context.h>
5525 +#include <linux/vs_tag.h>
5526 +#include <linux/vserver/space.h>
5527 +#include <linux/vserver/global.h>
5528 #include <asm/uaccess.h>
5529 #include <asm/unistd.h>
5531 @@ -573,6 +578,7 @@ static struct vfsmount *clone_mnt(struct
5532 mnt->mnt_root = dget(root);
5533 mnt->mnt_mountpoint = mnt->mnt_root;
5534 mnt->mnt_parent = mnt;
5535 + mnt->mnt_tag = old->mnt_tag;
5537 if (flag & CL_SLAVE) {
5538 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5539 @@ -685,6 +691,31 @@ static inline void mangle(struct seq_fil
5540 seq_escape(m, s, " \t\n\\");
5543 +static int mnt_is_reachable(struct vfsmount *mnt)
5546 + struct dentry *point;
5549 + if (mnt == mnt->mnt_ns->root)
5552 + spin_lock(&vfsmount_lock);
5553 + root = current->fs->root;
5554 + point = root.dentry;
5556 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5557 + point = mnt->mnt_mountpoint;
5558 + mnt = mnt->mnt_parent;
5561 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5563 + spin_unlock(&vfsmount_lock);
5569 * Simple .show_options callback for filesystems which don't want to
5570 * implement more complex mount option showing.
5571 @@ -757,6 +788,8 @@ static int show_sb_opts(struct seq_file
5572 { MS_SYNCHRONOUS, ",sync" },
5573 { MS_DIRSYNC, ",dirsync" },
5574 { MS_MANDLOCK, ",mand" },
5575 + { MS_TAGGED, ",tag" },
5576 + { MS_NOTAGCHECK, ",notagcheck" },
5579 const struct proc_fs_info *fs_infop;
5580 @@ -803,10 +836,20 @@ static int show_vfsmnt(struct seq_file *
5582 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5584 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5586 - seq_path(m, &mnt_path, " \t\n\\");
5588 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5590 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5593 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5594 + mnt == current->fs->root.mnt) {
5595 + seq_puts(m, "/dev/root / ");
5597 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5599 + seq_path(m, &mnt_path, " \t\n\\");
5602 show_type(m, mnt->mnt_sb);
5603 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5604 err = show_sb_opts(m, mnt->mnt_sb);
5605 @@ -836,6 +879,11 @@ static int show_mountinfo(struct seq_fil
5606 struct path root = p->root;
5609 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5611 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5614 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5615 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5616 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5617 @@ -894,17 +942,27 @@ static int show_vfsstat(struct seq_file
5618 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5622 - if (mnt->mnt_devname) {
5623 - seq_puts(m, "device ");
5624 - mangle(m, mnt->mnt_devname);
5626 - seq_puts(m, "no device");
5627 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5629 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5633 - seq_puts(m, " mounted on ");
5634 - seq_path(m, &mnt_path, " \t\n\\");
5636 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5637 + mnt == current->fs->root.mnt) {
5638 + seq_puts(m, "device /dev/root mounted on / ");
5641 + if (mnt->mnt_devname) {
5642 + seq_puts(m, "device ");
5643 + mangle(m, mnt->mnt_devname);
5645 + seq_puts(m, "no device");
5648 + seq_puts(m, " mounted on ");
5649 + seq_path(m, &mnt_path, " \t\n\\");
5653 /* file system type */
5654 seq_puts(m, "with fstype ");
5655 @@ -1143,7 +1201,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5659 - if (!capable(CAP_SYS_ADMIN))
5660 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5663 retval = do_umount(path.mnt, flags);
5664 @@ -1169,7 +1227,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5666 static int mount_is_safe(struct nameidata *nd)
5668 - if (capable(CAP_SYS_ADMIN))
5669 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5673 @@ -1462,11 +1520,13 @@ static noinline int do_change_type(struc
5674 * noinline this do_mount helper to save do_mount stack space.
5676 static noinline int do_loopback(struct nameidata *nd, char *old_name,
5678 + tag_t tag, unsigned long flags, int mnt_flags)
5680 struct nameidata old_nd;
5681 struct vfsmount *mnt = NULL;
5682 int err = mount_is_safe(nd);
5683 + int recurse = flags & MS_REC;
5687 if (!old_name || !*old_name)
5688 @@ -1500,6 +1560,7 @@ static noinline int do_loopback(struct n
5689 spin_unlock(&vfsmount_lock);
5690 release_mounts(&umount_list);
5692 + mnt->mnt_flags = mnt_flags;
5695 up_write(&namespace_sem);
5696 @@ -1531,12 +1592,12 @@ static int change_mount_flags(struct vfs
5697 * noinline this do_mount helper to save do_mount stack space.
5699 static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
5701 + void *data, xid_t xid)
5704 struct super_block *sb = nd->path.mnt->mnt_sb;
5706 - if (!capable(CAP_SYS_ADMIN))
5707 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5710 if (!check_mnt(nd->path.mnt))
5711 @@ -1582,7 +1643,7 @@ static noinline int do_move_mount(struct
5712 struct path parent_path;
5715 - if (!capable(CAP_SYS_ADMIN))
5716 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5718 if (!old_name || !*old_name)
5720 @@ -1665,7 +1726,7 @@ static noinline int do_new_mount(struct
5723 /* we need capabilities... */
5724 - if (!capable(CAP_SYS_ADMIN))
5725 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5728 mnt = do_kern_mount(type, flags, name, data);
5729 @@ -1910,6 +1971,7 @@ long do_mount(char *dev_name, char *dir_
5730 struct nameidata nd;
5736 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5737 @@ -1925,6 +1987,12 @@ long do_mount(char *dev_name, char *dir_
5739 ((char *)data_page)[PAGE_SIZE - 1] = 0;
5741 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5742 + /* FIXME: bind and re-mounts get the tag flag? */
5743 + if (flags & (MS_BIND|MS_REMOUNT))
5744 + flags |= MS_TAGID;
5747 /* Separate the per-mountpoint flags */
5748 if (flags & MS_NOSUID)
5749 mnt_flags |= MNT_NOSUID;
5750 @@ -1941,6 +2009,8 @@ long do_mount(char *dev_name, char *dir_
5751 if (flags & MS_RDONLY)
5752 mnt_flags |= MNT_READONLY;
5754 + if (!capable(CAP_SYS_ADMIN))
5755 + mnt_flags |= MNT_NODEV;
5756 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
5757 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
5759 @@ -1956,9 +2026,9 @@ long do_mount(char *dev_name, char *dir_
5761 if (flags & MS_REMOUNT)
5762 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
5765 else if (flags & MS_BIND)
5766 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
5767 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
5768 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5769 retval = do_change_type(&nd, flags);
5770 else if (flags & MS_MOVE)
5771 @@ -2027,6 +2097,7 @@ static struct mnt_namespace *dup_mnt_ns(
5772 q = next_mnt(q, new_ns->root);
5774 up_write(&namespace_sem);
5775 + atomic_inc(&vs_global_mnt_ns);
5779 @@ -2354,5 +2425,6 @@ void __put_mnt_ns(struct mnt_namespace *
5780 spin_unlock(&vfsmount_lock);
5781 up_write(&namespace_sem);
5782 release_mounts(&umount_list);
5783 + atomic_dec(&vs_global_mnt_ns);
5786 diff -NurpP --minimal linux-2.6.27.14/fs/nfs/client.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/client.c
5787 --- linux-2.6.27.14/fs/nfs/client.c 2008-10-13 14:52:05.000000000 +0200
5788 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/client.c 2008-10-13 14:54:20.000000000 +0200
5789 @@ -601,6 +601,9 @@ static int nfs_init_server_rpcclient(str
5790 if (server->flags & NFS_MOUNT_SOFT)
5791 server->client->cl_softrtry = 1;
5793 + server->client->cl_tag = 0;
5794 + if (server->flags & NFS_MOUNT_TAGGED)
5795 + server->client->cl_tag = 1;
5799 @@ -766,6 +769,10 @@ static void nfs_server_set_fsinfo(struct
5800 server->acdirmin = server->acdirmax = 0;
5803 + /* FIXME: needs fsinfo
5804 + if (server->flags & NFS_MOUNT_TAGGED)
5805 + sb->s_flags |= MS_TAGGED; */
5807 server->maxfilesize = fsinfo->maxfilesize;
5809 /* We're airborne Set socket buffersize */
5810 diff -NurpP --minimal linux-2.6.27.14/fs/nfs/dir.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/dir.c
5811 --- linux-2.6.27.14/fs/nfs/dir.c 2008-10-13 14:52:05.000000000 +0200
5812 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/dir.c 2008-10-13 14:54:20.000000000 +0200
5814 #include <linux/namei.h>
5815 #include <linux/mount.h>
5816 #include <linux/sched.h>
5817 +#include <linux/vs_tag.h>
5819 #include "nfs4_fs.h"
5820 #include "delegation.h"
5821 @@ -938,6 +939,7 @@ static struct dentry *nfs_lookup(struct
5823 goto out_unblock_sillyrename;
5825 + dx_propagate_tag(nd, inode);
5827 res = d_materialise_unique(dentry, inode);
5829 diff -NurpP --minimal linux-2.6.27.14/fs/nfs/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/inode.c
5830 --- linux-2.6.27.14/fs/nfs/inode.c 2008-10-13 14:52:05.000000000 +0200
5831 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/inode.c 2008-10-13 14:54:20.000000000 +0200
5833 #include <linux/vfs.h>
5834 #include <linux/inet.h>
5835 #include <linux/nfs_xdr.h>
5836 +#include <linux/vs_tag.h>
5838 #include <asm/system.h>
5839 #include <asm/uaccess.h>
5840 @@ -314,8 +315,10 @@ nfs_fhget(struct super_block *sb, struct
5841 nfsi->change_attr = fattr->change_attr;
5842 inode->i_size = nfs_size_to_loff_t(fattr->size);
5843 inode->i_nlink = fattr->nlink;
5844 - inode->i_uid = fattr->uid;
5845 - inode->i_gid = fattr->gid;
5846 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5847 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5848 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5849 + /* maybe fattr->xid someday */
5850 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5852 * report the blocks in 512byte units
5853 @@ -462,6 +465,8 @@ void nfs_setattr_update_inode(struct ino
5854 inode->i_uid = attr->ia_uid;
5855 if ((attr->ia_valid & ATTR_GID) != 0)
5856 inode->i_gid = attr->ia_gid;
5857 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5858 + inode->i_tag = attr->ia_tag;
5859 spin_lock(&inode->i_lock);
5860 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5861 spin_unlock(&inode->i_lock);
5862 @@ -900,6 +905,9 @@ static int nfs_check_inode_attributes(st
5863 struct nfs_inode *nfsi = NFS_I(inode);
5864 loff_t cur_size, new_isize;
5865 unsigned long invalid = 0;
5871 /* Has the inode gone and changed behind our back? */
5872 @@ -924,10 +932,15 @@ static int nfs_check_inode_attributes(st
5873 if (cur_size != new_isize && nfsi->npages == 0)
5874 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5876 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5877 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5878 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5880 /* Have any file permissions changed? */
5881 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
5882 - || inode->i_uid != fattr->uid
5883 - || inode->i_gid != fattr->gid)
5884 + || inode->i_uid != uid
5885 + || inode->i_gid != gid
5886 + || inode->i_tag != tag)
5887 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5889 /* Has the link count changed? */
5890 @@ -1048,6 +1061,9 @@ static int nfs_update_inode(struct inode
5891 loff_t cur_isize, new_isize;
5892 unsigned long invalid = 0;
5893 unsigned long now = jiffies;
5898 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5899 __func__, inode->i_sb->s_id, inode->i_ino,
5900 @@ -1121,15 +1137,21 @@ static int nfs_update_inode(struct inode
5901 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5902 nfsi->change_attr = fattr->change_attr;
5904 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5905 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5906 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5908 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
5909 - inode->i_uid != fattr->uid ||
5910 - inode->i_gid != fattr->gid)
5911 + inode->i_uid != uid ||
5912 + inode->i_gid != gid ||
5913 + inode->i_tag != tag)
5914 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5916 inode->i_mode = fattr->mode;
5917 inode->i_nlink = fattr->nlink;
5918 - inode->i_uid = fattr->uid;
5919 - inode->i_gid = fattr->gid;
5920 + inode->i_uid = uid;
5921 + inode->i_gid = gid;
5922 + inode->i_tag = tag;
5924 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
5926 diff -NurpP --minimal linux-2.6.27.14/fs/nfs/nfs3xdr.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/nfs3xdr.c
5927 --- linux-2.6.27.14/fs/nfs/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
5928 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
5930 #include <linux/nfs3.h>
5931 #include <linux/nfs_fs.h>
5932 #include <linux/nfsacl.h>
5933 +#include <linux/vs_tag.h>
5934 #include "internal.h"
5936 #define NFSDBG_FACILITY NFSDBG_XDR
5937 @@ -180,7 +181,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5940 static inline __be32 *
5941 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5942 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5944 if (attr->ia_valid & ATTR_MODE) {
5946 @@ -188,15 +189,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5950 - if (attr->ia_valid & ATTR_UID) {
5951 + if (attr->ia_valid & ATTR_UID ||
5952 + (tag && (attr->ia_valid & ATTR_TAG))) {
5954 - *p++ = htonl(attr->ia_uid);
5955 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5959 - if (attr->ia_valid & ATTR_GID) {
5960 + if (attr->ia_valid & ATTR_GID ||
5961 + (tag && (attr->ia_valid & ATTR_TAG))) {
5963 - *p++ = htonl(attr->ia_gid);
5964 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5968 @@ -281,7 +284,8 @@ static int
5969 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5971 p = xdr_encode_fhandle(p, args->fh);
5972 - p = xdr_encode_sattr(p, args->sattr);
5973 + p = xdr_encode_sattr(p, args->sattr,
5974 + req->rq_task->tk_client->cl_tag);
5975 *p++ = htonl(args->guard);
5977 p = xdr_encode_time3(p, &args->guardtime);
5978 @@ -386,7 +390,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5979 *p++ = args->verifier[0];
5980 *p++ = args->verifier[1];
5982 - p = xdr_encode_sattr(p, args->sattr);
5983 + p = xdr_encode_sattr(p, args->sattr,
5984 + req->rq_task->tk_client->cl_tag);
5986 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5988 @@ -400,7 +405,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5990 p = xdr_encode_fhandle(p, args->fh);
5991 p = xdr_encode_array(p, args->name, args->len);
5992 - p = xdr_encode_sattr(p, args->sattr);
5993 + p = xdr_encode_sattr(p, args->sattr,
5994 + req->rq_task->tk_client->cl_tag);
5995 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5998 @@ -413,7 +419,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6000 p = xdr_encode_fhandle(p, args->fromfh);
6001 p = xdr_encode_array(p, args->fromname, args->fromlen);
6002 - p = xdr_encode_sattr(p, args->sattr);
6003 + p = xdr_encode_sattr(p, args->sattr,
6004 + req->rq_task->tk_client->cl_tag);
6005 *p++ = htonl(args->pathlen);
6006 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6008 @@ -431,7 +438,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6009 p = xdr_encode_fhandle(p, args->fh);
6010 p = xdr_encode_array(p, args->name, args->len);
6011 *p++ = htonl(args->type);
6012 - p = xdr_encode_sattr(p, args->sattr);
6013 + p = xdr_encode_sattr(p, args->sattr,
6014 + req->rq_task->tk_client->cl_tag);
6015 if (args->type == NF3CHR || args->type == NF3BLK) {
6016 *p++ = htonl(MAJOR(args->rdev));
6017 *p++ = htonl(MINOR(args->rdev));
6018 diff -NurpP --minimal linux-2.6.27.14/fs/nfs/nfsroot.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/nfsroot.c
6019 --- linux-2.6.27.14/fs/nfs/nfsroot.c 2008-10-13 14:52:05.000000000 +0200
6020 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/nfsroot.c 2008-10-13 14:54:20.000000000 +0200
6021 @@ -117,12 +117,12 @@ static int mount_port __initdata = 0; /
6023 /* Options that take integer arguments */
6024 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6025 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6026 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6027 /* Options that take no arguments */
6028 Opt_soft, Opt_hard, Opt_intr,
6029 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6030 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6031 - Opt_acl, Opt_noacl,
6032 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6036 @@ -159,6 +159,9 @@ static match_table_t __initdata tokens =
6039 {Opt_noacl, "noacl"},
6041 + {Opt_notag, "notag"},
6042 + {Opt_tagid, "tagid=%u"},
6046 @@ -270,6 +273,20 @@ static int __init root_nfs_parse(char *n
6048 nfs_data.flags |= NFS_MOUNT_NOACL;
6050 +#ifndef CONFIG_TAGGING_NONE
6052 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6055 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6058 +#ifdef CONFIG_PROPAGATE
6061 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6065 printk(KERN_WARNING "Root-NFS: unknown "
6067 diff -NurpP --minimal linux-2.6.27.14/fs/nfs/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/super.c
6068 --- linux-2.6.27.14/fs/nfs/super.c 2008-10-13 14:52:05.000000000 +0200
6069 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfs/super.c 2008-10-13 14:54:20.000000000 +0200
6071 #include <linux/nfs_xdr.h>
6072 #include <linux/magic.h>
6073 #include <linux/parser.h>
6074 +#include <linux/vs_tag.h>
6076 #include <asm/system.h>
6077 #include <asm/uaccess.h>
6078 @@ -504,6 +505,7 @@ static void nfs_show_mount_options(struc
6079 { NFS_MOUNT_NOACL, ",noacl", "" },
6080 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6081 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
6082 + { NFS_MOUNT_TAGGED, ",tag", "" },
6085 const struct proc_nfs_info *nfs_infop;
6086 diff -NurpP --minimal linux-2.6.27.14/fs/nfsd/auth.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/auth.c
6087 --- linux-2.6.27.14/fs/nfsd/auth.c 2008-07-13 23:51:29.000000000 +0200
6088 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/auth.c 2008-10-13 14:54:20.000000000 +0200
6090 #include <linux/sunrpc/svcauth.h>
6091 #include <linux/nfsd/nfsd.h>
6092 #include <linux/nfsd/export.h>
6093 +#include <linux/vs_tag.h>
6096 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
6097 @@ -55,19 +56,23 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6098 get_group_info(cred.cr_group_info);
6100 if (cred.cr_uid != (uid_t) -1)
6101 - current->fsuid = cred.cr_uid;
6102 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6104 current->fsuid = exp->ex_anon_uid;
6105 if (cred.cr_gid != (gid_t) -1)
6106 - current->fsgid = cred.cr_gid;
6107 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6109 current->fsgid = exp->ex_anon_gid;
6111 + /* this desperately needs a tag :) */
6112 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6114 if (!cred.cr_group_info)
6116 ret = set_current_groups(cred.cr_group_info);
6117 put_group_info(cred.cr_group_info);
6118 - if ((cred.cr_uid)) {
6120 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
6121 current->cap_effective =
6122 cap_drop_nfsd_set(current->cap_effective);
6124 diff -NurpP --minimal linux-2.6.27.14/fs/nfsd/nfs3xdr.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/nfs3xdr.c
6125 --- linux-2.6.27.14/fs/nfsd/nfs3xdr.c 2008-07-13 23:51:29.000000000 +0200
6126 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/nfs3xdr.c 2008-10-13 14:54:20.000000000 +0200
6128 #include <linux/sunrpc/svc.h>
6129 #include <linux/nfsd/nfsd.h>
6130 #include <linux/nfsd/xdr3.h>
6131 +#include <linux/vs_tag.h>
6134 #define NFSDDBG_FACILITY NFSDDBG_XDR
6135 @@ -108,6 +109,8 @@ static __be32 *
6136 decode_sattr3(__be32 *p, struct iattr *iap)
6144 @@ -117,12 +120,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6147 iap->ia_valid |= ATTR_UID;
6148 - iap->ia_uid = ntohl(*p++);
6149 + uid = ntohl(*p++);
6152 iap->ia_valid |= ATTR_GID;
6153 - iap->ia_gid = ntohl(*p++);
6154 + gid = ntohl(*p++);
6156 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6157 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6158 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6162 @@ -178,8 +184,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6163 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6164 *p++ = htonl((u32) stat->mode);
6165 *p++ = htonl((u32) stat->nlink);
6166 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6167 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6168 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6169 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6170 + stat->uid, stat->tag)));
6171 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6172 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6173 + stat->gid, stat->tag)));
6174 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6175 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6177 diff -NurpP --minimal linux-2.6.27.14/fs/nfsd/nfs4xdr.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/nfs4xdr.c
6178 --- linux-2.6.27.14/fs/nfsd/nfs4xdr.c 2008-10-13 14:52:06.000000000 +0200
6179 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/nfs4xdr.c 2008-10-13 14:54:20.000000000 +0200
6181 #include <linux/nfs4_acl.h>
6182 #include <linux/sunrpc/gss_api.h>
6183 #include <linux/sunrpc/svcauth_gss.h>
6184 +#include <linux/vs_tag.h>
6186 #define NFSDDBG_FACILITY NFSDDBG_XDR
6188 @@ -1704,14 +1705,18 @@ out_acl:
6189 WRITE32(stat.nlink);
6191 if (bmval1 & FATTR4_WORD1_OWNER) {
6192 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6193 + status = nfsd4_encode_user(rqstp,
6194 + TAGINO_UID(DX_TAG(dentry->d_inode),
6195 + stat.uid, stat.tag), &p, &buflen);
6196 if (status == nfserr_resource)
6201 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6202 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6203 + status = nfsd4_encode_group(rqstp,
6204 + TAGINO_GID(DX_TAG(dentry->d_inode),
6205 + stat.gid, stat.tag), &p, &buflen);
6206 if (status == nfserr_resource)
6209 diff -NurpP --minimal linux-2.6.27.14/fs/nfsd/nfsxdr.c linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/nfsxdr.c
6210 --- linux-2.6.27.14/fs/nfsd/nfsxdr.c 2008-07-13 23:51:29.000000000 +0200
6211 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/nfsd/nfsxdr.c 2008-10-13 14:54:20.000000000 +0200
6213 #include <linux/nfsd/nfsd.h>
6214 #include <linux/nfsd/xdr.h>
6215 #include <linux/mm.h>
6216 +#include <linux/vs_tag.h>
6219 #define NFSDDBG_FACILITY NFSDDBG_XDR
6220 @@ -98,6 +99,8 @@ static __be32 *
6221 decode_sattr(__be32 *p, struct iattr *iap)
6229 @@ -111,12 +114,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6231 if ((tmp = ntohl(*p++)) != (u32)-1) {
6232 iap->ia_valid |= ATTR_UID;
6233 - iap->ia_uid = tmp;
6236 if ((tmp = ntohl(*p++)) != (u32)-1) {
6237 iap->ia_valid |= ATTR_GID;
6238 - iap->ia_gid = tmp;
6241 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6242 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6243 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6244 if ((tmp = ntohl(*p++)) != (u32)-1) {
6245 iap->ia_valid |= ATTR_SIZE;
6247 @@ -161,8 +167,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6248 *p++ = htonl(nfs_ftypes[type >> 12]);
6249 *p++ = htonl((u32) stat->mode);
6250 *p++ = htonl((u32) stat->nlink);
6251 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6252 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6253 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6254 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6255 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6256 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6258 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6259 *p++ = htonl(NFS_MAXPATHLEN);
6260 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/dlm/dlmfs.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/dlm/dlmfs.c
6261 --- linux-2.6.27.14/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:52:06.000000000 +0200
6262 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/dlm/dlmfs.c 2008-10-13 14:54:20.000000000 +0200
6264 #include <linux/init.h>
6265 #include <linux/string.h>
6266 #include <linux/backing-dev.h>
6267 +#include <linux/vs_tag.h>
6269 #include <asm/uaccess.h>
6271 @@ -341,6 +342,7 @@ static struct inode *dlmfs_get_root_inod
6272 inode->i_mode = mode;
6273 inode->i_uid = current->fsuid;
6274 inode->i_gid = current->fsgid;
6275 + inode->i_tag = dx_current_fstag(sb);
6276 inode->i_blocks = 0;
6277 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6278 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6279 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
6280 inode->i_mode = mode;
6281 inode->i_uid = current->fsuid;
6282 inode->i_gid = current->fsgid;
6283 + inode->i_tag = dx_current_fstag(sb);
6284 inode->i_blocks = 0;
6285 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
6286 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
6287 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/dlmglue.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/dlmglue.c
6288 --- linux-2.6.27.14/fs/ocfs2/dlmglue.c 2008-10-13 14:52:06.000000000 +0200
6289 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/dlmglue.c 2008-10-13 14:54:20.000000000 +0200
6290 @@ -1846,6 +1846,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6291 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6292 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6293 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6294 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6295 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6296 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6297 lvb->lvb_iatime_packed =
6298 @@ -1900,6 +1901,7 @@ static void ocfs2_refresh_inode_from_lvb
6300 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6301 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6302 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6303 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6304 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6305 ocfs2_unpack_timespec(&inode->i_atime,
6306 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/dlmglue.h linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/dlmglue.h
6307 --- linux-2.6.27.14/fs/ocfs2/dlmglue.h 2008-07-13 23:51:29.000000000 +0200
6308 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/dlmglue.h 2008-10-13 14:54:20.000000000 +0200
6309 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6312 __be32 lvb_igeneration;
6313 - __be32 lvb_reserved2;
6315 + __be16 lvb_reserved2;
6318 /* ocfs2_inode_lock_full() 'arg_flags' flags */
6319 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/file.c
6320 --- linux-2.6.27.14/fs/ocfs2/file.c 2008-10-13 14:52:06.000000000 +0200
6321 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/file.c 2008-10-13 14:54:20.000000000 +0200
6322 @@ -1058,13 +1058,15 @@ int ocfs2_setattr(struct dentry *dentry,
6323 mlog(0, "uid change: %d\n", attr->ia_uid);
6324 if (attr->ia_valid & ATTR_GID)
6325 mlog(0, "gid change: %d\n", attr->ia_gid);
6326 + if (attr->ia_valid & ATTR_TAG)
6327 + mlog(0, "tag change: %d\n", attr->ia_tag);
6328 if (attr->ia_valid & ATTR_SIZE)
6329 mlog(0, "size change...\n");
6330 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6331 mlog(0, "time change...\n");
6333 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6334 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6335 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6336 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6337 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6339 @@ -2227,6 +2229,7 @@ const struct inode_operations ocfs2_file
6340 .setattr = ocfs2_setattr,
6341 .getattr = ocfs2_getattr,
6342 .permission = ocfs2_permission,
6343 + .sync_flags = ocfs2_sync_flags,
6344 .fallocate = ocfs2_fallocate,
6347 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/inode.c
6348 --- linux-2.6.27.14/fs/ocfs2/inode.c 2008-07-13 23:51:29.000000000 +0200
6349 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/inode.c 2008-10-13 14:54:20.000000000 +0200
6351 #include <linux/slab.h>
6352 #include <linux/highmem.h>
6353 #include <linux/pagemap.h>
6354 +#include <linux/vs_tag.h>
6356 #include <asm/byteorder.h>
6360 #include "heartbeat.h"
6363 #include "journal.h"
6365 #include "suballoc.h"
6366 @@ -74,11 +76,13 @@ void ocfs2_set_inode_flags(struct inode
6368 unsigned int flags = OCFS2_I(inode)->ip_attr;
6370 - inode->i_flags &= ~(S_IMMUTABLE |
6371 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6372 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6374 if (flags & OCFS2_IMMUTABLE_FL)
6375 inode->i_flags |= S_IMMUTABLE;
6376 + if (flags & OCFS2_IXUNLINK_FL)
6377 + inode->i_flags |= S_IXUNLINK;
6379 if (flags & OCFS2_SYNC_FL)
6380 inode->i_flags |= S_SYNC;
6381 @@ -88,25 +92,85 @@ void ocfs2_set_inode_flags(struct inode
6382 inode->i_flags |= S_NOATIME;
6383 if (flags & OCFS2_DIRSYNC_FL)
6384 inode->i_flags |= S_DIRSYNC;
6386 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6388 + if (flags & OCFS2_BARRIER_FL)
6389 + inode->i_vflags |= V_BARRIER;
6390 + if (flags & OCFS2_COW_FL)
6391 + inode->i_vflags |= V_COW;
6394 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6395 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6397 unsigned int flags = oi->vfs_inode.i_flags;
6398 + unsigned int vflags = oi->vfs_inode.i_vflags;
6400 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6401 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6402 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6403 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6405 + if (flags & S_IMMUTABLE)
6406 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6407 + if (flags & S_IXUNLINK)
6408 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6410 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6411 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6413 oi->ip_attr |= OCFS2_SYNC_FL;
6414 if (flags & S_APPEND)
6415 oi->ip_attr |= OCFS2_APPEND_FL;
6416 - if (flags & S_IMMUTABLE)
6417 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6418 if (flags & S_NOATIME)
6419 oi->ip_attr |= OCFS2_NOATIME_FL;
6420 if (flags & S_DIRSYNC)
6421 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6423 + if (vflags & V_BARRIER)
6424 + oi->ip_attr |= OCFS2_BARRIER_FL;
6425 + if (vflags & V_COW)
6426 + oi->ip_attr |= OCFS2_COW_FL;
6429 +int ocfs2_sync_flags(struct inode *inode)
6431 + struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6432 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6433 + handle_t *handle = NULL;
6434 + struct buffer_head *bh = NULL;
6437 + status = ocfs2_inode_lock(inode, &bh, 1);
6439 + mlog_errno(status);
6444 + if (IS_RDONLY(inode))
6447 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6448 + if (IS_ERR(handle)) {
6449 + status = PTR_ERR(handle);
6450 + mlog_errno(status);
6454 + ocfs2_get_inode_flags(ocfs2_inode);
6455 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6457 + mlog_errno(status);
6459 + ocfs2_commit_trans(osb, handle);
6461 + ocfs2_inode_unlock(inode, 1);
6466 + mlog_exit(status);
6470 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
6471 @@ -219,6 +283,8 @@ int ocfs2_populate_inode(struct inode *i
6472 struct super_block *sb;
6473 struct ocfs2_super *osb;
6474 int status = -EINVAL;
6478 mlog_entry("(0x%p, size:%llu)\n", inode,
6479 (unsigned long long)le64_to_cpu(fe->i_size));
6480 @@ -254,8 +320,12 @@ int ocfs2_populate_inode(struct inode *i
6481 inode->i_generation = le32_to_cpu(fe->i_generation);
6482 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6483 inode->i_mode = le16_to_cpu(fe->i_mode);
6484 - inode->i_uid = le32_to_cpu(fe->i_uid);
6485 - inode->i_gid = le32_to_cpu(fe->i_gid);
6486 + uid = le32_to_cpu(fe->i_uid);
6487 + gid = le32_to_cpu(fe->i_gid);
6488 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6489 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6490 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6491 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6493 /* Fast symlinks will have i_size but no allocated clusters. */
6494 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6495 @@ -1230,8 +1300,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
6497 fe->i_size = cpu_to_le64(i_size_read(inode));
6498 fe->i_links_count = cpu_to_le16(inode->i_nlink);
6499 - fe->i_uid = cpu_to_le32(inode->i_uid);
6500 - fe->i_gid = cpu_to_le32(inode->i_gid);
6501 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
6502 + inode->i_uid, inode->i_tag));
6503 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
6504 + inode->i_gid, inode->i_tag));
6505 + /* i_tag = = cpu_to_le16(inode->i_tag); */
6506 fe->i_mode = cpu_to_le16(inode->i_mode);
6507 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
6508 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
6509 @@ -1259,16 +1332,25 @@ leave:
6510 void ocfs2_refresh_inode(struct inode *inode,
6511 struct ocfs2_dinode *fe)
6516 spin_lock(&OCFS2_I(inode)->ip_lock);
6518 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
6519 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
6520 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
6521 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
6522 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
6523 ocfs2_set_inode_flags(inode);
6524 i_size_write(inode, le64_to_cpu(fe->i_size));
6525 inode->i_nlink = le16_to_cpu(fe->i_links_count);
6526 - inode->i_uid = le32_to_cpu(fe->i_uid);
6527 - inode->i_gid = le32_to_cpu(fe->i_gid);
6528 + uid = le32_to_cpu(fe->i_uid);
6529 + gid = le32_to_cpu(fe->i_gid);
6530 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6531 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6532 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6533 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6534 inode->i_mode = le16_to_cpu(fe->i_mode);
6535 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
6536 inode->i_blocks = 0;
6537 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/inode.h linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/inode.h
6538 --- linux-2.6.27.14/fs/ocfs2/inode.h 2008-07-13 23:51:29.000000000 +0200
6539 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/inode.h 2008-10-13 14:54:20.000000000 +0200
6540 @@ -143,6 +143,7 @@ int ocfs2_aio_write(struct file *file, s
6542 void ocfs2_set_inode_flags(struct inode *inode);
6543 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6544 +int ocfs2_sync_flags(struct inode *inode);
6546 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6548 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ioctl.c
6549 --- linux-2.6.27.14/fs/ocfs2/ioctl.c 2008-07-13 23:51:29.000000000 +0200
6550 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ioctl.c 2008-10-13 14:54:20.000000000 +0200
6551 @@ -42,7 +42,7 @@ static int ocfs2_get_inode_attr(struct i
6555 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6556 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6559 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6560 @@ -67,6 +67,11 @@ static int ocfs2_set_inode_attr(struct i
6561 if (!S_ISDIR(inode->i_mode))
6562 flags &= ~OCFS2_DIRSYNC_FL;
6564 + if (IS_BARRIER(inode)) {
6565 + vxwprintk_task(1, "messing with the barrier.");
6569 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6570 if (IS_ERR(handle)) {
6571 status = PTR_ERR(handle);
6572 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/ioctl.h linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ioctl.h
6573 --- linux-2.6.27.14/fs/ocfs2/ioctl.h 2008-07-13 23:51:29.000000000 +0200
6574 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ioctl.h 2008-10-13 14:54:20.000000000 +0200
6576 #ifndef OCFS2_IOCTL_H
6577 #define OCFS2_IOCTL_H
6579 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6582 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
6583 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
6585 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/namei.c
6586 --- linux-2.6.27.14/fs/ocfs2/namei.c 2008-07-13 23:51:29.000000000 +0200
6587 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/namei.c 2008-10-13 14:54:20.000000000 +0200
6589 #include <linux/types.h>
6590 #include <linux/slab.h>
6591 #include <linux/highmem.h>
6592 +#include <linux/vs_tag.h>
6594 #define MLOG_MASK_PREFIX ML_NAMEI
6595 #include <cluster/masklog.h>
6596 @@ -366,6 +367,9 @@ static int ocfs2_mknod_locked(struct ocf
6599 struct inode *inode = NULL;
6604 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
6605 (unsigned long)dev, dentry->d_name.len,
6606 @@ -425,13 +429,19 @@ static int ocfs2_mknod_locked(struct ocf
6607 fe->i_blkno = cpu_to_le64(fe_blkno);
6608 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6609 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6610 - fe->i_uid = cpu_to_le32(current->fsuid);
6612 + tag = dx_current_fstag(osb->sb);
6613 + uid = current->fsuid;
6614 if (dir->i_mode & S_ISGID) {
6615 - fe->i_gid = cpu_to_le32(dir->i_gid);
6620 - fe->i_gid = cpu_to_le32(current->fsgid);
6621 + gid = current->fsgid;
6623 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
6624 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
6625 + inode->i_tag = tag;
6626 fe->i_mode = cpu_to_le16(mode);
6627 if (S_ISCHR(mode) || S_ISBLK(mode))
6628 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6629 @@ -1917,5 +1927,6 @@ const struct inode_operations ocfs2_dir_
6630 .rename = ocfs2_rename,
6631 .setattr = ocfs2_setattr,
6632 .getattr = ocfs2_getattr,
6633 + .sync_flags = ocfs2_sync_flags,
6634 .permission = ocfs2_permission,
6636 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/ocfs2_fs.h linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ocfs2_fs.h
6637 --- linux-2.6.27.14/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:52:06.000000000 +0200
6638 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ocfs2_fs.h 2008-10-13 14:54:20.000000000 +0200
6639 @@ -195,18 +195,23 @@
6640 #define OCFS2_INDEXED_DIR_FL (0x0008)
6642 /* Inode attributes, keep in sync with EXT2 */
6643 -#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
6644 -#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
6645 -#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
6646 -#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
6647 -#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
6648 -#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
6649 -#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
6650 -#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
6651 -#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
6652 +#define OCFS2_SECRM_FL FS_SECRM_FL /* Secure deletion */
6653 +#define OCFS2_UNRM_FL FS_UNRM_FL /* Undelete */
6654 +#define OCFS2_COMPR_FL FS_COMPR_FL /* Compress file */
6655 +#define OCFS2_SYNC_FL FS_SYNC_FL /* Synchronous updates */
6656 +#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */
6657 +#define OCFS2_APPEND_FL FS_APPEND_FL /* writes to file may only append */
6658 +#define OCFS2_NODUMP_FL FS_NODUMP_FL /* do not dump file */
6659 +#define OCFS2_NOATIME_FL FS_NOATIME_FL /* do not update atime */
6661 -#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
6662 -#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
6663 +#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
6664 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6666 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6667 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6669 +#define OCFS2_FL_VISIBLE (0x010300FF) /* User visible flags */
6670 +#define OCFS2_FL_MODIFIABLE (0x010300FF) /* User modifiable flags */
6673 * Extent record flags (e_node.leaf.flags)
6674 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/ocfs2.h linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ocfs2.h
6675 --- linux-2.6.27.14/fs/ocfs2/ocfs2.h 2008-10-13 14:52:06.000000000 +0200
6676 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/ocfs2.h 2008-10-13 14:54:20.000000000 +0200
6677 @@ -184,6 +184,7 @@ enum ocfs2_mount_options
6678 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
6679 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
6680 OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
6681 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
6684 #define OCFS2_OSB_SOFT_RO 0x0001
6685 diff -NurpP --minimal linux-2.6.27.14/fs/ocfs2/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/super.c
6686 --- linux-2.6.27.14/fs/ocfs2/super.c 2008-10-13 14:52:06.000000000 +0200
6687 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/ocfs2/super.c 2008-10-13 14:54:20.000000000 +0200
6688 @@ -154,6 +154,7 @@ enum {
6692 + Opt_tag, Opt_notag, Opt_tagid,
6696 @@ -173,6 +174,9 @@ static match_table_t tokens = {
6697 {Opt_localalloc, "localalloc=%d"},
6698 {Opt_localflocks, "localflocks"},
6699 {Opt_stack, "cluster_stack=%s"},
6701 + {Opt_notag, "notag"},
6702 + {Opt_tagid, "tagid=%u"},
6706 @@ -392,6 +396,13 @@ static int ocfs2_remount(struct super_bl
6710 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
6711 + !(sb->s_flags & MS_TAGGED)) {
6713 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6717 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
6718 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
6720 @@ -725,6 +736,9 @@ static int ocfs2_fill_super(struct super
6722 ocfs2_complete_mount_recovery(osb);
6724 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6725 + sb->s_flags |= MS_TAGGED;
6727 if (ocfs2_mount_local(osb))
6728 snprintf(nodestr, sizeof(nodestr), "local");
6730 @@ -918,6 +932,20 @@ static int ocfs2_parse_options(struct su
6731 OCFS2_STACK_LABEL_LEN);
6732 mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
6734 +#ifndef CONFIG_TAGGING_NONE
6736 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6739 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6742 +#ifdef CONFIG_PROPAGATE
6745 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6750 "Unrecognized mount option \"%s\" "
6751 diff -NurpP --minimal linux-2.6.27.14/fs/open.c linux-2.6.27.14-vs2.3.0.36.4/fs/open.c
6752 --- linux-2.6.27.14/fs/open.c 2009-02-03 17:59:55.000000000 +0100
6753 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/open.c 2009-02-03 17:59:04.000000000 +0100
6755 #include <linux/rcupdate.h>
6756 #include <linux/audit.h>
6757 #include <linux/falloc.h>
6758 +#include <linux/vs_base.h>
6759 +#include <linux/vs_limit.h>
6760 +#include <linux/vs_dlimit.h>
6761 +#include <linux/vs_tag.h>
6762 +#include <linux/vs_cowbl.h>
6764 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
6766 int retval = -ENODEV;
6769 + struct super_block *sb = dentry->d_sb;
6772 - if (dentry->d_sb->s_op->statfs) {
6773 + if (sb->s_op->statfs) {
6774 memset(buf, 0, sizeof(*buf));
6775 retval = security_sb_statfs(dentry);
6778 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
6779 + retval = sb->s_op->statfs(dentry, buf);
6780 if (retval == 0 && buf->f_frsize == 0)
6781 buf->f_frsize = buf->f_bsize;
6783 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6784 + vx_vsi_statfs(sb, buf);
6788 @@ -643,6 +652,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6789 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6793 + error = cow_check_and_break(&path);
6795 + goto dput_and_out;
6796 inode = path.dentry->d_inode;
6798 error = mnt_want_write(path.mnt);
6799 @@ -676,11 +689,11 @@ static int chown_common(struct dentry *
6800 newattrs.ia_valid = ATTR_CTIME;
6801 if (user != (uid_t) -1) {
6802 newattrs.ia_valid |= ATTR_UID;
6803 - newattrs.ia_uid = user;
6804 + newattrs.ia_uid = dx_map_uid(user);
6806 if (group != (gid_t) -1) {
6807 newattrs.ia_valid |= ATTR_GID;
6808 - newattrs.ia_gid = group;
6809 + newattrs.ia_gid = dx_map_gid(group);
6811 if (!S_ISDIR(inode->i_mode))
6812 newattrs.ia_valid |=
6813 @@ -703,7 +716,11 @@ SYSCALL_DEFINE3(chown, const char __user
6814 error = mnt_want_write(path.mnt);
6817 - error = chown_common(path.dentry, user, group);
6818 +#ifdef CONFIG_VSERVER_COWBL
6819 + error = cow_check_and_break(&path);
6822 + error = chown_common(path.dentry, user, group);
6823 mnt_drop_write(path.mnt);
6826 @@ -728,7 +745,11 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6827 error = mnt_want_write(path.mnt);
6830 - error = chown_common(path.dentry, user, group);
6831 +#ifdef CONFIG_VSERVER_COWBL
6832 + error = cow_check_and_break(&path);
6835 + error = chown_common(path.dentry, user, group);
6836 mnt_drop_write(path.mnt);
6839 @@ -747,7 +768,11 @@ SYSCALL_DEFINE3(lchown, const char __use
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 @@ -986,6 +1011,7 @@ static void __put_unused_fd(struct files
6853 __FD_CLR(fd, fdt->open_fds);
6854 if (fd < files->next_fd)
6855 files->next_fd = fd;
6856 + vx_openfd_dec(fd);
6859 void put_unused_fd(unsigned int fd)
6860 diff -NurpP --minimal linux-2.6.27.14/fs/proc/array.c linux-2.6.27.14-vs2.3.0.36.4/fs/proc/array.c
6861 --- linux-2.6.27.14/fs/proc/array.c 2008-10-13 14:52:06.000000000 +0200
6862 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/array.c 2008-10-13 14:54:20.000000000 +0200
6864 #include <linux/seq_file.h>
6865 #include <linux/pid_namespace.h>
6866 #include <linux/tracehook.h>
6867 +#include <linux/vs_context.h>
6868 +#include <linux/vs_network.h>
6870 #include <asm/pgtable.h>
6871 #include <asm/processor.h>
6872 @@ -142,8 +144,9 @@ static const char *task_state_array[] =
6873 "D (disk sleep)", /* 2 */
6874 "T (stopped)", /* 4 */
6875 "T (tracing stop)", /* 8 */
6876 - "Z (zombie)", /* 16 */
6877 - "X (dead)" /* 32 */
6878 + "H (on hold)", /* 16 */
6879 + "Z (zombie)", /* 32 */
6880 + "X (dead)", /* 64 */
6883 static inline const char *get_task_state(struct task_struct *tsk)
6884 @@ -164,6 +167,7 @@ static inline void task_state(struct seq
6885 struct group_info *group_info;
6887 struct fdtable *fdt = NULL;
6888 +/* + pid_t pid, ptgid, tppid, tgid; */
6892 @@ -175,6 +179,12 @@ static inline void task_state(struct seq
6894 tpid = task_pid_nr_ns(tracer, ns);
6896 +/* tgid = vx_map_tgid(p->tgid);
6897 + pid = vx_map_pid(p->pid);
6898 + ptgid = vx_map_pid(pid_alive(p) ?
6899 + rcu_dereference(p->real_parent)->tgid : 0);
6900 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
6901 + rcu_dereference(p->parent)->pid : 0); */
6905 @@ -286,7 +296,7 @@ static inline void task_sig(struct seq_f
6908 static void render_cap_t(struct seq_file *m, const char *header,
6910 + struct vx_info *vxi, kernel_cap_t *a)
6914 @@ -300,10 +310,10 @@ static void render_cap_t(struct seq_file
6916 static inline void task_cap(struct seq_file *m, struct task_struct *p)
6918 - render_cap_t(m, "CapInh:\t", &p->cap_inheritable);
6919 - render_cap_t(m, "CapPrm:\t", &p->cap_permitted);
6920 - render_cap_t(m, "CapEff:\t", &p->cap_effective);
6921 - render_cap_t(m, "CapBnd:\t", &p->cap_bset);
6922 + render_cap_t(m, "CapInh:\t", p->vx_info, &p->cap_inheritable);
6923 + render_cap_t(m, "CapPrm:\t", p->vx_info, &p->cap_permitted);
6924 + render_cap_t(m, "CapEff:\t", p->vx_info, &p->cap_effective);
6925 + render_cap_t(m, "CapBnd:\t", p->vx_info, &p->cap_bset);
6928 static inline void task_context_switch_counts(struct seq_file *m,
6929 @@ -315,6 +325,45 @@ static inline void task_context_switch_c
6933 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6934 + struct pid *pid, struct task_struct *task)
6936 + seq_printf(m, "Proxy:\t%p(%c)\n"
6945 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6946 + atomic_read(&task->nsproxy->count),
6947 + task->nsproxy->uts_ns,
6948 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6949 + task->nsproxy->ipc_ns,
6950 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6951 + task->nsproxy->mnt_ns,
6952 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6953 + task->nsproxy->pid_ns,
6954 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6955 + task->nsproxy->user_ns,
6956 + (task->nsproxy->user_ns == init_task.nsproxy->user_ns ? 'I' : '-'),
6957 + task->nsproxy->net_ns,
6958 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6962 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6964 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6967 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6968 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6972 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6973 struct pid *pid, struct task_struct *task)
6975 @@ -330,6 +379,7 @@ int proc_pid_status(struct seq_file *m,
6978 cpuset_task_status_allowed(m, task);
6979 + task_vs_id(m, task);
6980 #if defined(CONFIG_S390)
6981 task_show_regs(m, task);
6983 @@ -442,6 +492,17 @@ static int do_task_stat(struct seq_file
6984 /* convert nsec -> ticks */
6985 start_time = nsec_to_clock_t(start_time);
6987 + /* fixup start time for virt uptime */
6988 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6989 + unsigned long long bias =
6990 + current->vx_info->cvirt.bias_clock;
6992 + if (start_time > bias)
6993 + start_time -= bias;
6998 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6999 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
7000 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
7001 diff -NurpP --minimal linux-2.6.27.14/fs/proc/base.c linux-2.6.27.14-vs2.3.0.36.4/fs/proc/base.c
7002 --- linux-2.6.27.14/fs/proc/base.c 2008-10-13 14:52:06.000000000 +0200
7003 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/base.c 2008-10-13 14:54:20.000000000 +0200
7005 #include <linux/oom.h>
7006 #include <linux/elf.h>
7007 #include <linux/pid_namespace.h>
7008 +#include <linux/vs_context.h>
7009 +#include <linux/vs_network.h>
7010 #include "internal.h"
7013 @@ -1439,6 +1441,8 @@ static struct inode *proc_pid_make_inode
7014 inode->i_uid = task->euid;
7015 inode->i_gid = task->egid;
7017 + /* procfs is xid tagged */
7018 + inode->i_tag = (tag_t)vx_task_xid(task);
7019 security_task_to_inode(task, inode);
7022 @@ -1979,6 +1983,13 @@ static struct dentry *proc_pident_lookup
7026 + /* TODO: maybe we can come up with a generic approach? */
7027 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
7028 + (dentry->d_name.len == 5) &&
7029 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
7030 + !memcmp(dentry->d_name.name, "ninfo", 5)))
7034 * Yes, it does not scale. And it should not. Don't add
7035 * new entries into /proc/<tgid>/ without very good reasons.
7036 @@ -2366,7 +2377,7 @@ out_iput:
7037 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
7039 struct dentry *error;
7040 - struct task_struct *task = get_proc_task(dir);
7041 + struct task_struct *task = get_proc_task_real(dir);
7042 const struct pid_entry *p, *last;
7044 error = ERR_PTR(-ENOENT);
7045 @@ -2449,6 +2460,9 @@ static int proc_tgid_io_accounting(struc
7046 static const struct file_operations proc_task_operations;
7047 static const struct inode_operations proc_task_inode_operations;
7049 +extern int proc_pid_vx_info(struct task_struct *, char *);
7050 +extern int proc_pid_nx_info(struct task_struct *, char *);
7052 static const struct pid_entry tgid_base_stuff[] = {
7053 DIR("task", S_IRUGO|S_IXUGO, task),
7054 DIR("fd", S_IRUSR|S_IXUSR, fd),
7055 @@ -2503,6 +2517,8 @@ static const struct pid_entry tgid_base_
7056 #ifdef CONFIG_CGROUPS
7057 REG("cgroup", S_IRUGO, cgroup),
7059 + INF("vinfo", S_IRUGO, pid_vx_info),
7060 + INF("ninfo", S_IRUGO, pid_nx_info),
7061 INF("oom_score", S_IRUGO, oom_score),
7062 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
7063 #ifdef CONFIG_AUDITSYSCALL
7064 @@ -2518,6 +2534,7 @@ static const struct pid_entry tgid_base_
7065 #ifdef CONFIG_TASK_IO_ACCOUNTING
7066 INF("io", S_IRUGO, tgid_io_accounting),
7068 + ONE("nsproxy", S_IRUGO, pid_nsproxy),
7071 static int proc_tgid_base_readdir(struct file * filp,
7072 @@ -2714,7 +2731,7 @@ retry:
7074 pid = find_ge_pid(iter.tgid, ns);
7076 - iter.tgid = pid_nr_ns(pid, ns);
7077 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
7078 iter.task = pid_task(pid, PIDTYPE_PID);
7079 /* What we to know is if the pid we have find is the
7080 * pid of a thread_group_leader. Testing for task
7081 @@ -2744,7 +2761,7 @@ static int proc_pid_fill_cache(struct fi
7082 struct tgid_iter iter)
7084 char name[PROC_NUMBUF];
7085 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
7086 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
7087 return proc_fill_cache(filp, dirent, filldir, name, len,
7088 proc_pid_instantiate, iter.task, NULL);
7090 @@ -2753,7 +2770,7 @@ static int proc_pid_fill_cache(struct fi
7091 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7093 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7094 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7095 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7096 struct tgid_iter iter;
7097 struct pid_namespace *ns;
7099 @@ -2773,6 +2790,8 @@ int proc_pid_readdir(struct file * filp,
7101 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7102 filp->f_pos = iter.tgid + TGID_OFFSET;
7103 + if (!vx_proc_task_visible(iter.task))
7105 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7106 put_task_struct(iter.task);
7108 @@ -2915,6 +2934,8 @@ static struct dentry *proc_task_lookup(s
7109 tid = name_to_int(dentry);
7112 + if (vx_current_initpid(tid))
7115 ns = dentry->d_sb->s_fs_info;
7117 diff -NurpP --minimal linux-2.6.27.14/fs/proc/generic.c linux-2.6.27.14-vs2.3.0.36.4/fs/proc/generic.c
7118 --- linux-2.6.27.14/fs/proc/generic.c 2008-10-13 14:52:06.000000000 +0200
7119 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/generic.c 2008-10-13 14:54:20.000000000 +0200
7121 #include <linux/bitops.h>
7122 #include <linux/spinlock.h>
7123 #include <linux/completion.h>
7124 +#include <linux/vserver/inode.h>
7125 #include <asm/uaccess.h>
7127 #include "internal.h"
7128 @@ -384,6 +385,8 @@ struct dentry *proc_lookup_de(struct pro
7129 for (de = de->subdir; de ; de = de->next) {
7130 if (de->namelen != dentry->d_name.len)
7132 + if (!vx_hide_check(0, de->vx_flags))
7134 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
7137 @@ -392,6 +395,8 @@ struct dentry *proc_lookup_de(struct pro
7138 spin_unlock(&proc_subdir_lock);
7140 inode = proc_get_inode(dir->i_sb, ino, de);
7141 + /* generic proc entries belong to the host */
7146 @@ -472,6 +477,8 @@ int proc_readdir_de(struct proc_dir_entr
7148 /* filldir passes info to user space */
7150 + if (!vx_hide_check(0, de->vx_flags))
7152 spin_unlock(&proc_subdir_lock);
7153 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
7154 de->low_ino, de->mode >> 12) < 0) {
7155 @@ -479,6 +486,7 @@ int proc_readdir_de(struct proc_dir_entr
7158 spin_lock(&proc_subdir_lock);
7163 @@ -593,6 +601,7 @@ static struct proc_dir_entry *__proc_cre
7165 atomic_set(&ent->count, 1);
7167 + ent->vx_flags = IATTR_PROC_DEFAULT;
7168 spin_lock_init(&ent->pde_unload_lock);
7169 ent->pde_unload_completion = NULL;
7170 INIT_LIST_HEAD(&ent->pde_openers);
7171 @@ -616,7 +625,8 @@ struct proc_dir_entry *proc_symlink(cons
7177 + ent->vx_flags = IATTR_PROC_SYMLINK;
7181 diff -NurpP --minimal linux-2.6.27.14/fs/proc/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/proc/inode.c
7182 --- linux-2.6.27.14/fs/proc/inode.c 2008-10-13 14:52:06.000000000 +0200
7183 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/inode.c 2008-10-13 14:54:20.000000000 +0200
7184 @@ -469,6 +469,8 @@ struct inode *proc_get_inode(struct supe
7185 inode->i_uid = de->uid;
7186 inode->i_gid = de->gid;
7189 + PROC_I(inode)->vx_flags = de->vx_flags;
7191 inode->i_size = de->size;
7193 diff -NurpP --minimal linux-2.6.27.14/fs/proc/internal.h linux-2.6.27.14-vs2.3.0.36.4/fs/proc/internal.h
7194 --- linux-2.6.27.14/fs/proc/internal.h 2008-10-13 14:52:06.000000000 +0200
7195 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/internal.h 2008-10-13 14:54:20.000000000 +0200
7199 #include <linux/proc_fs.h>
7200 +#include <linux/vs_pid.h>
7202 extern struct proc_dir_entry proc_root;
7203 #ifdef CONFIG_PROC_SYSCTL
7204 @@ -55,6 +56,9 @@ extern int proc_pid_status(struct seq_fi
7205 struct pid *pid, struct task_struct *task);
7206 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7207 struct pid *pid, struct task_struct *task);
7208 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7209 + struct pid *pid, struct task_struct *task);
7211 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7213 extern const struct file_operations proc_maps_operations;
7214 @@ -75,11 +79,16 @@ static inline struct pid *proc_pid(struc
7215 return PROC_I(inode)->pid;
7218 -static inline struct task_struct *get_proc_task(struct inode *inode)
7219 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7221 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7224 +static inline struct task_struct *get_proc_task(struct inode *inode)
7226 + return vx_get_proc_task(inode, proc_pid(inode));
7229 static inline int proc_fd(struct inode *inode)
7231 return PROC_I(inode)->fd;
7232 diff -NurpP --minimal linux-2.6.27.14/fs/proc/proc_misc.c linux-2.6.27.14-vs2.3.0.36.4/fs/proc/proc_misc.c
7233 --- linux-2.6.27.14/fs/proc/proc_misc.c 2008-10-13 14:52:06.000000000 +0200
7234 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/proc_misc.c 2008-10-13 14:54:20.000000000 +0200
7236 #include <asm/div64.h>
7237 #include "internal.h"
7239 +#include <linux/vs_cvirt.h>
7241 #define LOAD_INT(x) ((x) >> FSHIFT)
7242 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
7244 @@ -84,22 +86,38 @@ static int proc_calc_metrics(char *page,
7245 static int loadavg_read_proc(char *page, char **start, off_t off,
7246 int count, int *eof, void *data)
7248 + unsigned long running;
7249 + unsigned int threads;
7255 seq = read_seqbegin(&xtime_lock);
7256 - a = avenrun[0] + (FIXED_1/200);
7257 - b = avenrun[1] + (FIXED_1/200);
7258 - c = avenrun[2] + (FIXED_1/200);
7259 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7260 + struct vx_info *vxi = current->vx_info;
7262 + a = vxi->cvirt.load[0] + (FIXED_1/200);
7263 + b = vxi->cvirt.load[1] + (FIXED_1/200);
7264 + c = vxi->cvirt.load[2] + (FIXED_1/200);
7266 + running = atomic_read(&vxi->cvirt.nr_running);
7267 + threads = atomic_read(&vxi->cvirt.nr_threads);
7269 + a = avenrun[0] + (FIXED_1/200);
7270 + b = avenrun[1] + (FIXED_1/200);
7271 + c = avenrun[2] + (FIXED_1/200);
7273 + running = nr_running();
7274 + threads = nr_threads;
7276 } while (read_seqretry(&xtime_lock, seq));
7278 len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
7279 LOAD_INT(a), LOAD_FRAC(a),
7280 LOAD_INT(b), LOAD_FRAC(b),
7281 LOAD_INT(c), LOAD_FRAC(c),
7282 - nr_running(), nr_threads,
7284 task_active_pid_ns(current)->last_pid);
7285 return proc_calc_metrics(page, start, off, count, eof, len);
7287 @@ -115,6 +133,9 @@ static int uptime_read_proc(char *page,
7288 do_posix_clock_monotonic_gettime(&uptime);
7289 monotonic_to_bootbased(&uptime);
7290 cputime_to_timespec(idletime, &idle);
7291 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7292 + vx_vsi_uptime(&uptime, &idle);
7294 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
7295 (unsigned long) uptime.tv_sec,
7296 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7297 @@ -151,7 +172,7 @@ static int meminfo_read_proc(char *page,
7299 cached = global_page_state(NR_FILE_PAGES) -
7300 total_swapcache_pages - i.bufferram;
7302 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
7305 get_vmalloc_info(&vmi);
7306 diff -NurpP --minimal linux-2.6.27.14/fs/proc/root.c linux-2.6.27.14-vs2.3.0.36.4/fs/proc/root.c
7307 --- linux-2.6.27.14/fs/proc/root.c 2008-07-13 23:51:29.000000000 +0200
7308 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/proc/root.c 2008-11-20 00:58:27.000000000 +0100
7310 #include <linux/smp_lock.h>
7311 #include <linux/mount.h>
7312 #include <linux/pid_namespace.h>
7313 +#include <linux/vserver/inode.h>
7315 #include "internal.h"
7317 +struct proc_dir_entry *proc_virtual;
7319 +extern void proc_vx_init(void);
7321 static int proc_test_super(struct super_block *sb, void *data)
7323 return sb->s_fs_info == data;
7324 @@ -137,6 +142,7 @@ void __init proc_root_init(void)
7326 proc_mkdir("bus", NULL);
7331 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7332 @@ -209,6 +215,7 @@ struct proc_dir_entry proc_root = {
7333 .proc_iops = &proc_root_inode_operations,
7334 .proc_fops = &proc_root_operations,
7335 .parent = &proc_root,
7336 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7339 int pid_ns_prepare_proc(struct pid_namespace *ns)
7340 diff -NurpP --minimal linux-2.6.27.14/fs/quota.c linux-2.6.27.14-vs2.3.0.36.4/fs/quota.c
7341 --- linux-2.6.27.14/fs/quota.c 2009-02-03 17:59:55.000000000 +0100
7342 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/quota.c 2009-02-03 17:59:04.000000000 +0100
7344 #include <linux/capability.h>
7345 #include <linux/quotaops.h>
7346 #include <linux/types.h>
7347 +#include <linux/vs_context.h>
7349 /* Check validity of generic quotactl commands */
7350 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
7351 @@ -81,11 +82,11 @@ static int generic_quotactl_valid(struct
7352 if (cmd == Q_GETQUOTA) {
7353 if (((type == USRQUOTA && current->euid != id) ||
7354 (type == GRPQUOTA && !in_egroup_p(id))) &&
7355 - !capable(CAP_SYS_ADMIN))
7356 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7359 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
7360 - if (!capable(CAP_SYS_ADMIN))
7361 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7365 @@ -132,10 +133,10 @@ static int xqm_quotactl_valid(struct sup
7366 if (cmd == Q_XGETQUOTA) {
7367 if (((type == XQM_USRQUOTA && current->euid != id) ||
7368 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
7369 - !capable(CAP_SYS_ADMIN))
7370 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7372 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
7373 - if (!capable(CAP_SYS_ADMIN))
7374 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7378 @@ -334,6 +335,46 @@ static int do_quotactl(struct super_bloc
7382 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7384 +#include <linux/vroot.h>
7385 +#include <linux/major.h>
7386 +#include <linux/module.h>
7387 +#include <linux/kallsyms.h>
7388 +#include <linux/vserver/debug.h>
7390 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7392 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7394 +int register_vroot_grb(vroot_grb_func *func) {
7397 + spin_lock(&vroot_grb_lock);
7398 + if (!vroot_get_real_bdev) {
7399 + vroot_get_real_bdev = func;
7402 + spin_unlock(&vroot_grb_lock);
7405 +EXPORT_SYMBOL(register_vroot_grb);
7407 +int unregister_vroot_grb(vroot_grb_func *func) {
7408 + int ret = -EINVAL;
7410 + spin_lock(&vroot_grb_lock);
7411 + if (vroot_get_real_bdev) {
7412 + vroot_get_real_bdev = NULL;
7415 + spin_unlock(&vroot_grb_lock);
7418 +EXPORT_SYMBOL(unregister_vroot_grb);
7423 * look up a superblock on which quota ops will be performed
7424 * - use the name of a block device to find the superblock thereon
7425 @@ -351,6 +392,22 @@ static inline struct super_block *quotac
7428 return ERR_CAST(bdev);
7429 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7430 + if (bdev && bdev->bd_inode &&
7431 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7432 + struct block_device *bdnew = (void *)-EINVAL;
7434 + if (vroot_get_real_bdev)
7435 + bdnew = vroot_get_real_bdev(bdev);
7437 + vxdprintk(VXD_CBIT(misc, 0),
7438 + "vroot_get_real_bdev not set");
7440 + if (IS_ERR(bdnew))
7441 + return ERR_PTR(PTR_ERR(bdnew));
7445 sb = get_super(bdev);
7448 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/bitmap.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/bitmap.c
7449 --- linux-2.6.27.14/fs/reiserfs/bitmap.c 2008-07-13 23:51:29.000000000 +0200
7450 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/bitmap.c 2008-10-13 14:54:20.000000000 +0200
7452 #include <linux/reiserfs_fs_sb.h>
7453 #include <linux/reiserfs_fs_i.h>
7454 #include <linux/quotaops.h>
7455 +#include <linux/vs_dlimit.h>
7457 #define PREALLOCATION_SIZE 9
7459 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
7460 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
7462 journal_mark_dirty(th, s, sbh);
7463 - if (for_unformatted)
7464 + if (for_unformatted) {
7465 + DLIMIT_FREE_BLOCK(inode, 1);
7466 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
7470 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
7471 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
7472 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
7474 int nr_allocated = 0;
7477 determine_prealloc_size(hint);
7478 if (!hint->formatted_node) {
7479 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
7480 "reiserquota: allocating %d blocks id=%u",
7481 amount_needed, hint->inode->i_uid);
7484 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
7485 - if (quota_ret) /* Quota exceeded? */
7486 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
7489 return QUOTA_EXCEEDED;
7490 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
7491 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7493 + return NO_DISK_SPACE;
7496 if (hint->preallocate && hint->prealloc_size) {
7497 #ifdef REISERQUOTA_DEBUG
7498 reiserfs_debug(s, REISERFS_DEBUG_CODE,
7499 "reiserquota: allocating (prealloc) %d blocks id=%u",
7500 hint->prealloc_size, hint->inode->i_uid);
7503 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7504 - hint->prealloc_size);
7505 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
7506 + hint->prealloc_size);
7508 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
7509 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
7510 + hint->prealloc_size);
7514 hint->preallocate = hint->prealloc_size = 0;
7516 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
7518 hint->inode->i_uid);
7520 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
7521 + /* Free not allocated blocks */
7522 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
7523 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7524 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7526 while (nr_allocated--)
7527 reiserfs_free_block(hint->th, hint->inode,
7528 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
7529 REISERFS_I(hint->inode)->i_prealloc_count,
7530 hint->inode->i_uid);
7532 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
7533 - hint->prealloc_size - nr_allocated -
7534 - REISERFS_I(hint->inode)->
7535 - i_prealloc_count);
7536 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
7537 + REISERFS_I(hint->inode)->i_prealloc_count;
7538 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
7539 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
7543 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/file.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/file.c
7544 --- linux-2.6.27.14/fs/reiserfs/file.c 2008-07-13 23:51:29.000000000 +0200
7545 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/file.c 2008-10-13 14:54:20.000000000 +0200
7546 @@ -306,4 +306,5 @@ const struct inode_operations reiserfs_f
7547 .listxattr = reiserfs_listxattr,
7548 .removexattr = reiserfs_removexattr,
7549 .permission = reiserfs_permission,
7550 + .sync_flags = reiserfs_sync_flags,
7552 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/inode.c
7553 --- linux-2.6.27.14/fs/reiserfs/inode.c 2009-02-03 17:59:55.000000000 +0100
7554 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/inode.c 2009-02-03 17:59:04.000000000 +0100
7556 #include <linux/writeback.h>
7557 #include <linux/quotaops.h>
7558 #include <linux/swap.h>
7559 +#include <linux/vs_dlimit.h>
7560 +#include <linux/vs_tag.h>
7562 int reiserfs_commit_write(struct file *f, struct page *page,
7563 unsigned from, unsigned to);
7564 @@ -54,6 +56,7 @@ void reiserfs_delete_inode(struct inode
7565 * stat data deletion */
7567 DQUOT_FREE_INODE(inode);
7568 + DLIMIT_FREE_INODE(inode);
7570 if (journal_end(&th, inode->i_sb, jbegin_count))
7572 @@ -1116,6 +1119,8 @@ static void init_inode(struct inode *ino
7573 struct buffer_head *bh;
7574 struct item_head *ih;
7578 //int version = ITEM_VERSION_1;
7580 bh = PATH_PLAST_BUFFER(path);
7581 @@ -1139,12 +1144,13 @@ static void init_inode(struct inode *ino
7582 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7583 unsigned long blocks;
7585 + uid = sd_v1_uid(sd);
7586 + gid = sd_v1_gid(sd);
7588 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7589 set_inode_sd_version(inode, STAT_DATA_V1);
7590 inode->i_mode = sd_v1_mode(sd);
7591 inode->i_nlink = sd_v1_nlink(sd);
7592 - inode->i_uid = sd_v1_uid(sd);
7593 - inode->i_gid = sd_v1_gid(sd);
7594 inode->i_size = sd_v1_size(sd);
7595 inode->i_atime.tv_sec = sd_v1_atime(sd);
7596 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7597 @@ -1186,11 +1192,12 @@ static void init_inode(struct inode *ino
7598 // (directories and symlinks)
7599 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7601 + uid = sd_v2_uid(sd);
7602 + gid = sd_v2_gid(sd);
7604 inode->i_mode = sd_v2_mode(sd);
7605 inode->i_nlink = sd_v2_nlink(sd);
7606 - inode->i_uid = sd_v2_uid(sd);
7607 inode->i_size = sd_v2_size(sd);
7608 - inode->i_gid = sd_v2_gid(sd);
7609 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7610 inode->i_atime.tv_sec = sd_v2_atime(sd);
7611 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7612 @@ -1220,6 +1227,10 @@ static void init_inode(struct inode *ino
7613 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7616 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7617 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7618 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7621 if (S_ISREG(inode->i_mode)) {
7622 inode->i_op = &reiserfs_file_inode_operations;
7623 @@ -1242,13 +1253,15 @@ static void init_inode(struct inode *ino
7624 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7626 struct stat_data *sd_v2 = (struct stat_data *)sd;
7627 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7628 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7631 + set_sd_v2_uid(sd_v2, uid);
7632 + set_sd_v2_gid(sd_v2, gid);
7633 set_sd_v2_mode(sd_v2, inode->i_mode);
7634 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7635 - set_sd_v2_uid(sd_v2, inode->i_uid);
7636 set_sd_v2_size(sd_v2, size);
7637 - set_sd_v2_gid(sd_v2, inode->i_gid);
7638 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7639 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7640 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7641 @@ -1771,6 +1784,10 @@ int reiserfs_new_inode(struct reiserfs_t
7643 BUG_ON(!th->t_trans_id);
7645 + if (DLIMIT_ALLOC_INODE(inode)) {
7647 + goto out_bad_dlimit;
7649 if (DQUOT_ALLOC_INODE(inode)) {
7652 @@ -1956,6 +1973,9 @@ int reiserfs_new_inode(struct reiserfs_t
7653 DQUOT_FREE_INODE(inode);
7656 + DLIMIT_FREE_INODE(inode);
7659 journal_end(th, th->t_super, th->t_blocks_allocated);
7660 /* Drop can be outside and it needs more credits so it's better to have it outside */
7662 @@ -2842,14 +2862,19 @@ int reiserfs_commit_write(struct file *f
7663 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7665 if (reiserfs_attrs(inode->i_sb)) {
7666 - if (sd_attrs & REISERFS_SYNC_FL)
7667 - inode->i_flags |= S_SYNC;
7669 - inode->i_flags &= ~S_SYNC;
7670 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7671 inode->i_flags |= S_IMMUTABLE;
7673 inode->i_flags &= ~S_IMMUTABLE;
7674 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7675 + inode->i_flags |= S_IXUNLINK;
7677 + inode->i_flags &= ~S_IXUNLINK;
7679 + if (sd_attrs & REISERFS_SYNC_FL)
7680 + inode->i_flags |= S_SYNC;
7682 + inode->i_flags &= ~S_SYNC;
7683 if (sd_attrs & REISERFS_APPEND_FL)
7684 inode->i_flags |= S_APPEND;
7686 @@ -2862,6 +2887,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7687 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7689 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7691 + if (sd_attrs & REISERFS_BARRIER_FL)
7692 + inode->i_vflags |= V_BARRIER;
7694 + inode->i_vflags &= ~V_BARRIER;
7695 + if (sd_attrs & REISERFS_COW_FL)
7696 + inode->i_vflags |= V_COW;
7698 + inode->i_vflags &= ~V_COW;
7702 @@ -2872,6 +2906,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7703 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7705 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7706 + if (inode->i_flags & S_IXUNLINK)
7707 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7709 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7711 if (inode->i_flags & S_SYNC)
7712 *sd_attrs |= REISERFS_SYNC_FL;
7714 @@ -2884,6 +2923,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7715 *sd_attrs |= REISERFS_NOTAIL_FL;
7717 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7719 + if (inode->i_vflags & V_BARRIER)
7720 + *sd_attrs |= REISERFS_BARRIER_FL;
7722 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7723 + if (inode->i_vflags & V_COW)
7724 + *sd_attrs |= REISERFS_COW_FL;
7726 + *sd_attrs &= ~REISERFS_COW_FL;
7730 @@ -3051,6 +3099,22 @@ static ssize_t reiserfs_direct_IO(int rw
7731 reiserfs_get_blocks_direct_io, NULL);
7734 +int reiserfs_sync_flags(struct inode *inode)
7736 + u16 oldflags, newflags;
7738 + oldflags = REISERFS_I(inode)->i_attrs;
7739 + newflags = oldflags;
7740 + i_attrs_to_sd_attrs(inode, &newflags);
7742 + if (oldflags ^ newflags) {
7743 + REISERFS_I(inode)->i_attrs = newflags;
7744 + inode->i_ctime = CURRENT_TIME_SEC;
7745 + mark_inode_dirty(inode);
7750 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
7752 struct inode *inode = dentry->d_inode;
7753 @@ -3104,9 +3168,11 @@ int reiserfs_setattr(struct dentry *dent
7756 error = inode_change_ok(inode, attr);
7759 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7760 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7761 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7762 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7763 error = reiserfs_chown_xattrs(inode, attr);
7766 @@ -3136,6 +3202,9 @@ int reiserfs_setattr(struct dentry *dent
7767 inode->i_uid = attr->ia_uid;
7768 if (attr->ia_valid & ATTR_GID)
7769 inode->i_gid = attr->ia_gid;
7770 + if ((attr->ia_valid & ATTR_TAG) &&
7772 + inode->i_tag = attr->ia_tag;
7773 mark_inode_dirty(inode);
7775 journal_end(&th, inode->i_sb, jbegin_count);
7776 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/ioctl.c
7777 --- linux-2.6.27.14/fs/reiserfs/ioctl.c 2008-07-13 23:51:29.000000000 +0200
7778 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/ioctl.c 2008-10-13 14:54:20.000000000 +0200
7780 #include <linux/mount.h>
7781 #include <linux/reiserfs_fs.h>
7782 #include <linux/time.h>
7783 +#include <linux/mount.h>
7784 #include <asm/uaccess.h>
7785 #include <linux/pagemap.h>
7786 #include <linux/smp_lock.h>
7788 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
7791 - unsigned int flags;
7792 + unsigned int flags, oldflags;
7796 @@ -43,6 +44,7 @@ int reiserfs_ioctl(struct inode *inode,
7798 flags = REISERFS_I(inode)->i_attrs;
7799 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7800 + flags &= REISERFS_FL_USER_VISIBLE;
7801 return put_user(flags, (int __user *)arg);
7802 case REISERFS_IOC_SETFLAGS:{
7803 if (!reiserfs_attrs(inode->i_sb))
7804 @@ -60,6 +62,10 @@ int reiserfs_ioctl(struct inode *inode,
7808 + if (IS_BARRIER(inode)) {
7809 + vxwprintk_task(1, "messing with the barrier.");
7813 * Is it quota file? Do not allow user to mess with it
7815 @@ -84,6 +90,10 @@ int reiserfs_ioctl(struct inode *inode,
7820 + oldflags = REISERFS_I(inode)->i_attrs;
7821 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
7822 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7823 sd_attrs_to_i_attrs(flags, inode);
7824 REISERFS_I(inode)->i_attrs = flags;
7825 inode->i_ctime = CURRENT_TIME_SEC;
7826 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/namei.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/namei.c
7827 --- linux-2.6.27.14/fs/reiserfs/namei.c 2008-07-13 23:51:29.000000000 +0200
7828 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/namei.c 2008-10-13 14:54:20.000000000 +0200
7830 #include <linux/reiserfs_acl.h>
7831 #include <linux/reiserfs_xattr.h>
7832 #include <linux/quotaops.h>
7833 +#include <linux/vs_tag.h>
7835 #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; }
7836 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7837 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
7838 reiserfs_write_unlock(dir->i_sb);
7839 return ERR_PTR(-EACCES);
7841 + dx_propagate_tag(nd, inode);
7843 /* Propogate the priv_object flag so we know we're in the priv tree */
7844 if (is_reiserfs_priv_object(dir))
7845 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
7847 inode->i_gid = current->fsgid;
7849 + inode->i_tag = dx_current_fstag(inode->i_sb);
7853 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
7854 .listxattr = reiserfs_listxattr,
7855 .removexattr = reiserfs_removexattr,
7856 .permission = reiserfs_permission,
7857 + .sync_flags = reiserfs_sync_flags,
7861 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
7862 .listxattr = reiserfs_listxattr,
7863 .removexattr = reiserfs_removexattr,
7864 .permission = reiserfs_permission,
7865 + .sync_flags = reiserfs_sync_flags,
7869 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
7870 .listxattr = reiserfs_listxattr,
7871 .removexattr = reiserfs_removexattr,
7872 .permission = reiserfs_permission,
7873 + .sync_flags = reiserfs_sync_flags,
7876 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/stree.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/stree.c
7877 --- linux-2.6.27.14/fs/reiserfs/stree.c 2008-07-13 23:51:29.000000000 +0200
7878 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/stree.c 2008-10-13 14:54:20.000000000 +0200
7880 #include <linux/reiserfs_fs.h>
7881 #include <linux/buffer_head.h>
7882 #include <linux/quotaops.h>
7883 +#include <linux/vs_dlimit.h>
7885 /* Does the buffer contain a disk block which is in the tree. */
7886 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
7887 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
7888 "reiserquota delete_item(): freeing %u, id=%u type=%c",
7889 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
7891 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7892 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7894 /* Return deleted body length */
7895 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
7897 DQUOT_FREE_SPACE_NODIRTY(inode,
7899 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
7903 @@ -1734,6 +1737,7 @@ int reiserfs_cut_from_item(struct reiser
7904 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
7905 quota_cut_bytes, p_s_inode->i_uid, '?');
7907 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
7908 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
7911 @@ -1975,6 +1979,11 @@ int reiserfs_paste_into_item(struct reis
7912 pathrelse(p_s_search_path);
7915 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
7916 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7917 + pathrelse(p_s_search_path);
7920 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
7922 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
7923 @@ -2027,6 +2036,7 @@ int reiserfs_paste_into_item(struct reis
7924 n_pasted_size, inode->i_uid,
7925 key2type(&(p_s_key->on_disk_key)));
7927 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
7928 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
7931 @@ -2064,6 +2074,11 @@ int reiserfs_insert_item(struct reiserfs
7932 pathrelse(p_s_path);
7935 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
7936 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7937 + pathrelse(p_s_path);
7941 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
7942 IH_SIZE + ih_item_len(p_s_ih));
7943 @@ -2111,7 +2126,9 @@ int reiserfs_insert_item(struct reiserfs
7944 "reiserquota insert_item(): freeing %u id=%u type=%c",
7945 quota_bytes, inode->i_uid, head2type(p_s_ih));
7949 + DLIMIT_FREE_SPACE(inode, quota_bytes);
7950 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
7954 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/super.c
7955 --- linux-2.6.27.14/fs/reiserfs/super.c 2008-10-13 14:52:06.000000000 +0200
7956 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/super.c 2008-10-13 14:54:20.000000000 +0200
7957 @@ -898,6 +898,14 @@ static int reiserfs_parse_options(struct
7958 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7959 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7961 +#ifndef CONFIG_TAGGING_NONE
7962 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7963 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7964 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7966 +#ifdef CONFIG_PROPAGATE
7967 + {"tag",.arg_required = 'T',.values = NULL},
7969 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7970 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7971 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7972 @@ -1193,6 +1201,12 @@ static int reiserfs_remount(struct super
7973 handle_quota_files(s, qf_names, &qfmt);
7976 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7977 + !(s->s_flags & MS_TAGGED)) {
7978 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
7984 /* Add options that are safe here */
7985 @@ -1657,6 +1671,10 @@ static int reiserfs_fill_super(struct su
7989 + /* map mount option tagxid */
7990 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7991 + s->s_flags |= MS_TAGGED;
7993 rs = SB_DISK_SUPER_BLOCK(s);
7994 /* Let's do basic sanity check to verify that underlying device is not
7995 smaller than the filesystem. If the check fails then abort and scream,
7996 diff -NurpP --minimal linux-2.6.27.14/fs/reiserfs/xattr.c linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/xattr.c
7997 --- linux-2.6.27.14/fs/reiserfs/xattr.c 2008-10-13 14:52:06.000000000 +0200
7998 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/reiserfs/xattr.c 2008-10-13 14:54:20.000000000 +0200
8000 #include <linux/namei.h>
8001 #include <linux/errno.h>
8002 #include <linux/fs.h>
8003 +#include <linux/mount.h>
8004 #include <linux/file.h>
8005 #include <linux/pagemap.h>
8006 #include <linux/xattr.h>
8007 diff -NurpP --minimal linux-2.6.27.14/fs/stat.c linux-2.6.27.14-vs2.3.0.36.4/fs/stat.c
8008 --- linux-2.6.27.14/fs/stat.c 2009-02-03 17:59:55.000000000 +0100
8009 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/stat.c 2009-02-03 17:59:04.000000000 +0100
8010 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
8011 stat->nlink = inode->i_nlink;
8012 stat->uid = inode->i_uid;
8013 stat->gid = inode->i_gid;
8014 + stat->tag = inode->i_tag;
8015 stat->rdev = inode->i_rdev;
8016 stat->atime = inode->i_atime;
8017 stat->mtime = inode->i_mtime;
8018 diff -NurpP --minimal linux-2.6.27.14/fs/super.c linux-2.6.27.14-vs2.3.0.36.4/fs/super.c
8019 --- linux-2.6.27.14/fs/super.c 2009-02-03 17:59:55.000000000 +0100
8020 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/super.c 2009-02-03 17:59:04.000000000 +0100
8022 #include <linux/kobject.h>
8023 #include <linux/mutex.h>
8024 #include <linux/file.h>
8025 +#include <linux/devpts_fs.h>
8026 +#include <linux/proc_fs.h>
8027 +#include <linux/vs_context.h>
8028 #include <asm/uaccess.h>
8029 #include "internal.h"
8031 @@ -887,12 +890,18 @@ struct vfsmount *
8032 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
8034 struct vfsmount *mnt;
8035 + struct super_block *sb;
8036 char *secdata = NULL;
8040 return ERR_PTR(-ENODEV);
8043 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
8044 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
8048 mnt = alloc_vfsmnt(name);
8050 @@ -913,7 +922,14 @@ vfs_kern_mount(struct file_system_type *
8051 goto out_free_secdata;
8052 BUG_ON(!mnt->mnt_sb);
8054 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
8057 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
8058 + (sb->s_magic != PROC_SUPER_MAGIC) &&
8059 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
8062 + error = security_sb_kern_mount(sb, secdata);
8066 diff -NurpP --minimal linux-2.6.27.14/fs/sysfs/mount.c linux-2.6.27.14-vs2.3.0.36.4/fs/sysfs/mount.c
8067 --- linux-2.6.27.14/fs/sysfs/mount.c 2008-07-13 23:51:29.000000000 +0200
8068 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/sysfs/mount.c 2008-10-13 14:54:20.000000000 +0200
8073 -/* Random magic number */
8074 -#define SYSFS_MAGIC 0x62656572
8076 static struct vfsmount *sysfs_mount;
8077 struct super_block * sysfs_sb = NULL;
8078 @@ -46,7 +44,7 @@ static int sysfs_fill_super(struct super
8080 sb->s_blocksize = PAGE_CACHE_SIZE;
8081 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
8082 - sb->s_magic = SYSFS_MAGIC;
8083 + sb->s_magic = SYSFS_SUPER_MAGIC;
8084 sb->s_op = &sysfs_ops;
8085 sb->s_time_gran = 1;
8087 diff -NurpP --minimal linux-2.6.27.14/fs/utimes.c linux-2.6.27.14-vs2.3.0.36.4/fs/utimes.c
8088 --- linux-2.6.27.14/fs/utimes.c 2009-02-03 17:59:55.000000000 +0100
8089 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/utimes.c 2009-02-03 17:59:04.000000000 +0100
8091 #include <linux/stat.h>
8092 #include <linux/utime.h>
8093 #include <linux/syscalls.h>
8094 +#include <linux/mount.h>
8095 +#include <linux/vs_cowbl.h>
8096 #include <asm/uaccess.h>
8097 #include <asm/unistd.h>
8099 diff -NurpP --minimal linux-2.6.27.14/fs/xattr.c linux-2.6.27.14-vs2.3.0.36.4/fs/xattr.c
8100 --- linux-2.6.27.14/fs/xattr.c 2009-02-03 17:59:55.000000000 +0100
8101 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xattr.c 2009-02-03 17:59:04.000000000 +0100
8103 #include <linux/module.h>
8104 #include <linux/fsnotify.h>
8105 #include <linux/audit.h>
8106 +#include <linux/mount.h>
8107 #include <asm/uaccess.h>
8110 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_ioctl.c
8111 --- linux-2.6.27.14/fs/xfs/linux-2.6/xfs_ioctl.c 2008-10-13 14:52:06.000000000 +0200
8112 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_ioctl.c 2008-11-12 18:41:58.000000000 +0100
8113 @@ -806,6 +806,10 @@ xfs_merge_ioc_xflags(
8114 xflags |= XFS_XFLAG_IMMUTABLE;
8116 xflags &= ~XFS_XFLAG_IMMUTABLE;
8117 + if (flags & FS_IXUNLINK_FL)
8118 + xflags |= XFS_XFLAG_IXUNLINK;
8120 + xflags &= ~XFS_XFLAG_IXUNLINK;
8121 if (flags & FS_APPEND_FL)
8122 xflags |= XFS_XFLAG_APPEND;
8124 @@ -834,6 +838,8 @@ xfs_di2lxflags(
8126 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8127 flags |= FS_IMMUTABLE_FL;
8128 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8129 + flags |= FS_IXUNLINK_FL;
8130 if (di_flags & XFS_DIFLAG_APPEND)
8131 flags |= FS_APPEND_FL;
8132 if (di_flags & XFS_DIFLAG_SYNC)
8133 @@ -892,6 +898,8 @@ xfs_set_diflags(
8134 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
8135 if (xflags & XFS_XFLAG_IMMUTABLE)
8136 di_flags |= XFS_DIFLAG_IMMUTABLE;
8137 + if (xflags & XFS_XFLAG_IXUNLINK)
8138 + di_flags |= XFS_DIFLAG_IXUNLINK;
8139 if (xflags & XFS_XFLAG_APPEND)
8140 di_flags |= XFS_DIFLAG_APPEND;
8141 if (xflags & XFS_XFLAG_SYNC)
8142 @@ -934,6 +942,10 @@ xfs_diflags_to_linux(
8143 inode->i_flags |= S_IMMUTABLE;
8145 inode->i_flags &= ~S_IMMUTABLE;
8146 + if (xflags & XFS_XFLAG_IXUNLINK)
8147 + inode->i_flags |= S_IXUNLINK;
8149 + inode->i_flags &= ~S_IXUNLINK;
8150 if (xflags & XFS_XFLAG_APPEND)
8151 inode->i_flags |= S_APPEND;
8153 @@ -1392,10 +1404,18 @@ xfs_ioctl(
8154 case XFS_IOC_FSGETXATTRA:
8155 return xfs_ioc_fsgetxattr(ip, 1, arg);
8156 case XFS_IOC_FSSETXATTR:
8157 + if (IS_BARRIER(inode)) {
8158 + vxwprintk_task(1, "messing with the barrier.");
8159 + return -XFS_ERROR(EACCES);
8161 return xfs_ioc_fssetxattr(ip, filp, arg);
8162 case XFS_IOC_GETXFLAGS:
8163 return xfs_ioc_getxflags(ip, arg);
8164 case XFS_IOC_SETXFLAGS:
8165 + if (IS_BARRIER(inode)) {
8166 + vxwprintk_task(1, "messing with the barrier.");
8167 + return -XFS_ERROR(EACCES);
8169 return xfs_ioc_setxflags(ip, filp, arg);
8171 case XFS_IOC_FSSETDM: {
8172 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_iops.c
8173 --- linux-2.6.27.14/fs/xfs/linux-2.6/xfs_iops.c 2008-10-13 14:52:06.000000000 +0200
8174 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_iops.c 2008-11-12 18:41:58.000000000 +0100
8176 #include <linux/namei.h>
8177 #include <linux/security.h>
8178 #include <linux/falloc.h>
8179 +#include <linux/vs_tag.h>
8182 * Bring the atime in the XFS inode uptodate.
8183 @@ -558,6 +559,7 @@ xfs_vn_getattr(
8184 stat->nlink = ip->i_d.di_nlink;
8185 stat->uid = ip->i_d.di_uid;
8186 stat->gid = ip->i_d.di_gid;
8187 + stat->tag = ip->i_d.di_tag;
8188 stat->ino = ip->i_ino;
8190 stat->ino += mp->m_inoadd;
8191 @@ -597,6 +599,12 @@ xfs_vn_getattr(
8195 +xfs_vn_sync_xflags(struct inode *inode)
8197 + return -xfs_sync_xflags(XFS_I(inode));
8202 struct dentry *dentry,
8203 struct iattr *iattr)
8204 @@ -671,6 +679,7 @@ static const struct inode_operations xfs
8205 .removexattr = generic_removexattr,
8206 .listxattr = xfs_vn_listxattr,
8207 .fallocate = xfs_vn_fallocate,
8208 + .sync_flags = xfs_vn_sync_xflags,
8211 static const struct inode_operations xfs_dir_inode_operations = {
8212 @@ -696,6 +705,7 @@ static const struct inode_operations xfs
8213 .getxattr = generic_getxattr,
8214 .removexattr = generic_removexattr,
8215 .listxattr = xfs_vn_listxattr,
8216 + .sync_flags = xfs_vn_sync_xflags,
8219 static const struct inode_operations xfs_dir_ci_inode_operations = {
8220 @@ -745,6 +755,10 @@ xfs_diflags_to_iflags(
8221 inode->i_flags |= S_IMMUTABLE;
8223 inode->i_flags &= ~S_IMMUTABLE;
8224 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
8225 + inode->i_flags |= S_IXUNLINK;
8227 + inode->i_flags &= ~S_IXUNLINK;
8228 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
8229 inode->i_flags |= S_APPEND;
8231 @@ -757,6 +771,15 @@ xfs_diflags_to_iflags(
8232 inode->i_flags |= S_NOATIME;
8234 inode->i_flags &= ~S_NOATIME;
8236 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
8237 + inode->i_vflags |= V_BARRIER;
8239 + inode->i_vflags &= ~V_BARRIER;
8240 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
8241 + inode->i_vflags |= V_COW;
8243 + inode->i_vflags &= ~V_COW;
8247 @@ -777,6 +800,7 @@ xfs_setup_inode(
8248 inode->i_nlink = ip->i_d.di_nlink;
8249 inode->i_uid = ip->i_d.di_uid;
8250 inode->i_gid = ip->i_d.di_gid;
8251 + inode->i_tag = ip->i_d.di_tag;
8253 switch (inode->i_mode & S_IFMT) {
8255 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_linux.h
8256 --- linux-2.6.27.14/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 14:52:06.000000000 +0200
8257 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_linux.h 2008-10-13 15:35:26.000000000 +0200
8260 #define current_cpu() (raw_smp_processor_id())
8261 #define current_pid() (current->pid)
8262 +#define current_fstag(cred,vp) (dx_current_fstag(vp->i_sb))
8263 #define current_test_flags(f) (current->flags & (f))
8264 #define current_set_flags_nested(sp, f) \
8265 (*(sp) = current->flags, current->flags |= (f))
8266 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/linux-2.6/xfs_super.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_super.c
8267 --- linux-2.6.27.14/fs/xfs/linux-2.6/xfs_super.c 2009-02-03 17:59:55.000000000 +0100
8268 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/linux-2.6/xfs_super.c 2009-02-03 17:59:04.000000000 +0100
8269 @@ -147,6 +147,9 @@ xfs_args_allocate(
8270 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
8271 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
8272 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
8273 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
8274 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
8275 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
8278 * Table driven mount option parser.
8279 @@ -155,10 +158,14 @@ xfs_args_allocate(
8280 * in the future, too.
8283 + Opt_tag, Opt_notag,
8284 Opt_barrier, Opt_nobarrier, Opt_err
8287 static match_table_t tokens = {
8288 + {Opt_tag, "tagxid"},
8290 + {Opt_notag, "notag"},
8291 {Opt_barrier, "barrier"},
8292 {Opt_nobarrier, "nobarrier"},
8294 @@ -383,6 +390,19 @@ xfs_parseargs(
8295 } else if (!strcmp(this_char, "irixsgid")) {
8297 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
8298 +#ifndef CONFIG_TAGGING_NONE
8299 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8300 + args->flags2 |= XFSMNT2_TAGGED;
8301 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
8302 + args->flags2 &= ~XFSMNT2_TAGGED;
8303 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
8304 + args->flags2 |= XFSMNT2_TAGGED;
8306 +#ifdef CONFIG_PROPAGATE
8307 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
8309 + args->flags2 |= XFSMNT2_TAGGED;
8313 "XFS: unknown mount option [%s].", this_char);
8314 @@ -1301,6 +1321,16 @@ xfs_fs_remount(
8316 mp->m_flags &= ~XFS_MOUNT_BARRIER;
8319 + if (!(sb->s_flags & MS_TAGGED)) {
8321 + "XFS: %s: tagging not permitted on remount.\n",
8330 * Logically we would return an error here to prevent
8331 @@ -1555,6 +1585,9 @@ xfs_start_flags(
8333 if (ap->flags & XFSMNT_DMAPI)
8334 mp->m_flags |= XFS_MOUNT_DMAPI;
8336 + if (ap->flags2 & XFSMNT2_TAGGED)
8337 + mp->m_flags |= XFS_MOUNT_TAGGED;
8341 @@ -1749,6 +1782,9 @@ xfs_fs_fill_super(
8343 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname);
8345 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8346 + sb->s_flags |= MS_TAGGED;
8349 sb->s_magic = XFS_SB_MAGIC;
8350 sb->s_blocksize = mp->m_sb.sb_blocksize;
8351 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/quota/xfs_qm_syscalls.c
8352 --- linux-2.6.27.14/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-13 14:52:06.000000000 +0200
8353 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/quota/xfs_qm_syscalls.c 2008-10-24 03:47:08.000000000 +0200
8354 @@ -426,7 +426,7 @@ xfs_qm_scall_quotaon(
8358 - if (!capable(CAP_SYS_ADMIN))
8359 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8360 return XFS_ERROR(EPERM);
8362 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
8363 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_clnt.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_clnt.h
8364 --- linux-2.6.27.14/fs/xfs/xfs_clnt.h 2008-10-13 14:52:06.000000000 +0200
8365 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_clnt.h 2008-10-13 14:54:20.000000000 +0200
8366 @@ -101,5 +101,6 @@ struct xfs_mount_args {
8367 * I/O size in stat(2) */
8368 #define XFSMNT2_FILESTREAMS 0x00000002 /* enable the filestreams
8370 +#define XFSMNT2_TAGGED 0x10000000 /* context tagging */
8372 #endif /* __XFS_CLNT_H__ */
8373 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_dinode.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_dinode.h
8374 --- linux-2.6.27.14/fs/xfs/xfs_dinode.h 2008-07-13 23:51:29.000000000 +0200
8375 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_dinode.h 2008-11-12 18:41:59.000000000 +0100
8376 @@ -53,7 +53,9 @@ typedef struct xfs_dinode_core {
8377 __be32 di_gid; /* owner's group id */
8378 __be32 di_nlink; /* number of links to file */
8379 __be16 di_projid; /* owner's project id */
8380 - __u8 di_pad[8]; /* unused, zeroed space */
8381 + __be16 di_tag; /* context tagging */
8382 + __be16 di_vflags; /* vserver specific flags */
8383 + __u8 di_pad[4]; /* unused, zeroed space */
8384 __be16 di_flushiter; /* incremented on flush */
8385 xfs_timestamp_t di_atime; /* time last accessed */
8386 xfs_timestamp_t di_mtime; /* time last modified */
8387 @@ -136,7 +138,9 @@ typedef struct xfs_dinode
8388 #define XFS_DI_NEXT_UNLINKED 0x1000000
8389 #define XFS_DI_U 0x2000000
8390 #define XFS_DI_A 0x4000000
8391 -#define XFS_DI_NUM_BITS 27
8392 +#define XFS_DI_TAG 0x8000000
8393 +#define XFS_DI_VFLAGS 0x10000000
8394 +#define XFS_DI_NUM_BITS 29
8395 #define XFS_DI_ALL_BITS ((1 << XFS_DI_NUM_BITS) - 1)
8396 #define XFS_DI_CORE_BITS (XFS_DI_ALL_BITS & ~(XFS_DI_U|XFS_DI_A))
8398 @@ -223,6 +227,8 @@ typedef enum xfs_dinode_fmt
8399 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8400 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8401 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8402 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8404 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8405 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8406 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8407 @@ -238,6 +244,7 @@ typedef enum xfs_dinode_fmt
8408 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8409 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8410 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8411 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8413 #ifdef CONFIG_XFS_RT
8414 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8415 @@ -250,6 +257,10 @@ typedef enum xfs_dinode_fmt
8416 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8417 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8418 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8419 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8420 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8421 + XFS_DIFLAG_IXUNLINK)
8423 +#define XFS_DIVFLAG_BARRIER 0x01
8424 +#define XFS_DIVFLAG_COW 0x02
8426 #endif /* __XFS_DINODE_H__ */
8427 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_fs.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_fs.h
8428 --- linux-2.6.27.14/fs/xfs/xfs_fs.h 2008-10-13 14:52:06.000000000 +0200
8429 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_fs.h 2008-10-13 14:54:20.000000000 +0200
8430 @@ -67,6 +67,9 @@ struct fsxattr {
8431 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8432 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8433 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8434 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8435 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8436 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8437 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8440 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8441 __s32 bs_extents; /* number of extents */
8442 __u32 bs_gen; /* generation count */
8443 __u16 bs_projid; /* project id */
8444 - unsigned char bs_pad[14]; /* pad space, unused */
8445 + __u16 bs_tag; /* context tagging */
8446 + unsigned char bs_pad[12]; /* pad space, unused */
8447 __u32 bs_dmevmask; /* DMIG event mask */
8448 __u16 bs_dmstate; /* DMIG state info */
8449 __u16 bs_aextents; /* attribute number of extents */
8450 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_ialloc.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_ialloc.c
8451 --- linux-2.6.27.14/fs/xfs/xfs_ialloc.c 2008-07-13 23:51:29.000000000 +0200
8452 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_ialloc.c 2008-11-12 18:41:59.000000000 +0100
8453 @@ -84,6 +84,8 @@ xfs_ialloc_log_di(
8454 offsetof(xfs_dinode_t, di_next_unlinked),
8455 offsetof(xfs_dinode_t, di_u),
8456 offsetof(xfs_dinode_t, di_a),
8457 + offsetof(xfs_dinode_core_t, di_tag),
8458 + offsetof(xfs_dinode_core_t, di_vflags),
8459 sizeof(xfs_dinode_t)
8462 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_inode.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_inode.c
8463 --- linux-2.6.27.14/fs/xfs/xfs_inode.c 2008-10-13 14:52:06.000000000 +0200
8464 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_inode.c 2008-11-12 18:42:00.000000000 +0100
8465 @@ -249,6 +249,7 @@ xfs_inotobp(
8469 +#include <linux/vs_tag.h>
8472 * This routine is called to map an inode to the buffer containing
8473 @@ -660,15 +661,25 @@ xfs_iformat_btree(
8475 xfs_dinode_from_disk(
8477 - xfs_dinode_core_t *from)
8478 + xfs_dinode_core_t *from,
8481 + uint32_t uid, gid, tag;
8483 to->di_magic = be16_to_cpu(from->di_magic);
8484 to->di_mode = be16_to_cpu(from->di_mode);
8485 to->di_version = from ->di_version;
8486 to->di_format = from->di_format;
8487 to->di_onlink = be16_to_cpu(from->di_onlink);
8488 - to->di_uid = be32_to_cpu(from->di_uid);
8489 - to->di_gid = be32_to_cpu(from->di_gid);
8491 + uid = be32_to_cpu(from->di_uid);
8492 + gid = be32_to_cpu(from->di_gid);
8493 + tag = be16_to_cpu(from->di_tag);
8495 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8496 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8497 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8499 to->di_nlink = be32_to_cpu(from->di_nlink);
8500 to->di_projid = be16_to_cpu(from->di_projid);
8501 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8502 @@ -689,21 +700,26 @@ xfs_dinode_from_disk(
8503 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8504 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8505 to->di_flags = be16_to_cpu(from->di_flags);
8506 + to->di_vflags = be16_to_cpu(from->di_vflags);
8507 to->di_gen = be32_to_cpu(from->di_gen);
8512 xfs_dinode_core_t *to,
8513 - xfs_icdinode_t *from)
8514 + xfs_icdinode_t *from,
8517 to->di_magic = cpu_to_be16(from->di_magic);
8518 to->di_mode = cpu_to_be16(from->di_mode);
8519 to->di_version = from ->di_version;
8520 to->di_format = from->di_format;
8521 to->di_onlink = cpu_to_be16(from->di_onlink);
8522 - to->di_uid = cpu_to_be32(from->di_uid);
8523 - to->di_gid = cpu_to_be32(from->di_gid);
8525 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8526 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8527 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8529 to->di_nlink = cpu_to_be32(from->di_nlink);
8530 to->di_projid = cpu_to_be16(from->di_projid);
8531 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
8532 @@ -724,12 +740,14 @@ xfs_dinode_to_disk(
8533 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8534 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8535 to->di_flags = cpu_to_be16(from->di_flags);
8536 + to->di_vflags = cpu_to_be16(from->di_vflags);
8537 to->di_gen = cpu_to_be32(from->di_gen);
8542 - __uint16_t di_flags)
8543 + __uint16_t di_flags,
8544 + __uint16_t di_vflags)
8548 @@ -740,6 +758,8 @@ _xfs_dic2xflags(
8549 flags |= XFS_XFLAG_PREALLOC;
8550 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8551 flags |= XFS_XFLAG_IMMUTABLE;
8552 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8553 + flags |= XFS_XFLAG_IXUNLINK;
8554 if (di_flags & XFS_DIFLAG_APPEND)
8555 flags |= XFS_XFLAG_APPEND;
8556 if (di_flags & XFS_DIFLAG_SYNC)
8557 @@ -764,6 +784,10 @@ _xfs_dic2xflags(
8558 flags |= XFS_XFLAG_FILESTREAM;
8561 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8562 + flags |= FS_BARRIER_FL;
8563 + if (di_vflags & XFS_DIVFLAG_COW)
8564 + flags |= FS_COW_FL;
8568 @@ -773,7 +797,7 @@ xfs_ip2xflags(
8570 xfs_icdinode_t *dic = &ip->i_d;
8572 - return _xfs_dic2xflags(dic->di_flags) |
8573 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8574 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8577 @@ -783,7 +807,8 @@ xfs_dic2xflags(
8579 xfs_dinode_core_t *dic = &dip->di_core;
8581 - return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
8582 + return _xfs_dic2xflags(be16_to_cpu(dic->di_flags),
8583 + be16_to_cpu(dic->di_vflags)) |
8584 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8587 @@ -878,7 +903,8 @@ xfs_iread(
8588 * Otherwise, just get the truly permanent information.
8590 if (dip->di_core.di_mode) {
8591 - xfs_dinode_from_disk(&ip->i_d, &dip->di_core);
8592 + xfs_dinode_from_disk(&ip->i_d, &dip->di_core,
8593 + mp->m_flags & XFS_MOUNT_TAGGED);
8594 error = xfs_iformat(ip, dip);
8596 kmem_zone_free(xfs_inode_zone, ip);
8597 @@ -1083,6 +1109,7 @@ xfs_ialloc(
8598 ASSERT(ip->i_d.di_nlink == nlink);
8599 ip->i_d.di_uid = current_fsuid();
8600 ip->i_d.di_gid = current_fsgid();
8601 + ip->i_d.di_tag = current_fstag(cr, ip->i_vnode);
8602 ip->i_d.di_projid = prid;
8603 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8605 @@ -1143,6 +1170,7 @@ xfs_ialloc(
8606 ip->i_d.di_dmevmask = 0;
8607 ip->i_d.di_dmstate = 0;
8608 ip->i_d.di_flags = 0;
8609 + ip->i_d.di_vflags = 0;
8610 flags = XFS_ILOG_CORE;
8611 switch (mode & S_IFMT) {
8613 @@ -2249,6 +2277,7 @@ xfs_ifree(
8615 ip->i_d.di_mode = 0; /* mark incore inode as free */
8616 ip->i_d.di_flags = 0;
8617 + ip->i_d.di_vflags = 0;
8618 ip->i_d.di_dmevmask = 0;
8619 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8620 ip->i_df.if_ext_max =
8621 @@ -3342,7 +3371,8 @@ xfs_iflush_int(
8622 * because if the inode is dirty at all the core must
8625 - xfs_dinode_to_disk(&dip->di_core, &ip->i_d);
8626 + xfs_dinode_to_disk(&dip->di_core, &ip->i_d,
8627 + mp->m_flags & XFS_MOUNT_TAGGED);
8629 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8630 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8631 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_inode.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_inode.h
8632 --- linux-2.6.27.14/fs/xfs/xfs_inode.h 2008-10-13 14:52:06.000000000 +0200
8633 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_inode.h 2008-11-12 18:42:03.000000000 +0100
8634 @@ -173,7 +173,9 @@ typedef struct xfs_icdinode {
8635 __uint32_t di_gid; /* owner's group id */
8636 __uint32_t di_nlink; /* number of links to file */
8637 __uint16_t di_projid; /* owner's project id */
8638 - __uint8_t di_pad[8]; /* unused, zeroed space */
8639 + __uint16_t di_tag; /* context tagging */
8640 + __uint16_t di_vflags; /* vserver specific flags */
8641 + __uint8_t di_pad[4]; /* unused, zeroed space */
8642 __uint16_t di_flushiter; /* incremented on flush */
8643 xfs_ictimestamp_t di_atime; /* time last accessed */
8644 xfs_ictimestamp_t di_mtime; /* time last modified */
8645 @@ -500,9 +502,9 @@ int xfs_ialloc(struct xfs_trans *, xfs_
8646 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
8647 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
8648 void xfs_dinode_from_disk(struct xfs_icdinode *,
8649 - struct xfs_dinode_core *);
8650 + struct xfs_dinode_core *, int tagged);
8651 void xfs_dinode_to_disk(struct xfs_dinode_core *,
8652 - struct xfs_icdinode *);
8653 + struct xfs_icdinode *, int tagged);
8655 uint xfs_ip2xflags(struct xfs_inode *);
8656 uint xfs_dic2xflags(struct xfs_dinode *);
8657 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_itable.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_itable.c
8658 --- linux-2.6.27.14/fs/xfs/xfs_itable.c 2008-10-13 14:52:06.000000000 +0200
8659 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_itable.c 2008-11-12 18:42:03.000000000 +0100
8660 @@ -82,6 +82,7 @@ xfs_bulkstat_one_iget(
8661 buf->bs_mode = dic->di_mode;
8662 buf->bs_uid = dic->di_uid;
8663 buf->bs_gid = dic->di_gid;
8664 + buf->bs_tag = dic->di_tag;
8665 buf->bs_size = dic->di_size;
8666 vn_atime_to_bstime(VFS_I(ip), &buf->bs_atime);
8667 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
8668 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_log_recover.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_log_recover.c
8669 --- linux-2.6.27.14/fs/xfs/xfs_log_recover.c 2008-10-13 14:52:06.000000000 +0200
8670 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_log_recover.c 2008-11-12 18:42:03.000000000 +0100
8671 @@ -2417,7 +2417,8 @@ xlog_recover_do_inode_trans(
8673 /* The core is in in-core format */
8674 xfs_dinode_to_disk(&dip->di_core,
8675 - (xfs_icdinode_t *)item->ri_buf[1].i_addr);
8676 + (xfs_icdinode_t *)item->ri_buf[1].i_addr,
8677 + mp->m_flags & XFS_MOUNT_TAGGED);
8679 /* the rest is in on-disk format */
8680 if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) {
8681 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_mount.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_mount.h
8682 --- linux-2.6.27.14/fs/xfs/xfs_mount.h 2008-10-13 14:52:06.000000000 +0200
8683 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_mount.h 2008-10-13 14:54:20.000000000 +0200
8684 @@ -384,6 +384,7 @@ typedef struct xfs_mount {
8686 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8688 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8691 * Default minimum read and write sizes.
8692 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_vnodeops.c linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_vnodeops.c
8693 --- linux-2.6.27.14/fs/xfs/xfs_vnodeops.c 2008-10-13 14:52:06.000000000 +0200
8694 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_vnodeops.c 2008-11-12 18:42:03.000000000 +0100
8695 @@ -75,6 +75,89 @@ xfs_open(
8700 +xfs_get_inode_flags(
8703 + struct inode *inode = VFS_I(ip);
8704 + unsigned int flags = inode->i_flags;
8705 + unsigned int vflags = inode->i_vflags;
8707 + if (flags & S_IMMUTABLE)
8708 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8710 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8711 + if (flags & S_IXUNLINK)
8712 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8714 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8716 + if (vflags & V_BARRIER)
8717 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8719 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8720 + if (vflags & V_COW)
8721 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8723 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8730 + struct xfs_mount *mp = ip->i_mount;
8731 + struct xfs_trans *tp;
8732 + unsigned int lock_flags = 0;
8735 + xfs_itrace_entry(ip);
8737 + if (mp->m_flags & XFS_MOUNT_RDONLY)
8738 + return XFS_ERROR(EROFS);
8741 + * we acquire the inode lock and do an error checking pass.
8743 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8744 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8746 + goto error_return;
8748 + lock_flags = XFS_ILOCK_EXCL;
8749 + xfs_ilock(ip, lock_flags);
8751 + xfs_trans_ijoin(tp, ip, lock_flags);
8752 + xfs_trans_ihold(tp, ip);
8754 + xfs_get_inode_flags(ip);
8755 + // xfs_diflags_to_linux(ip);
8757 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8758 + xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
8760 + XFS_STATS_INC(xs_ig_attrchg);
8763 + * If this is a synchronous mount, make sure that the
8764 + * transaction goes to disk before returning to the user.
8766 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8767 + xfs_trans_set_sync(tp);
8768 + code = xfs_trans_commit(tp, 0);
8769 + xfs_iunlock(ip, lock_flags);
8776 + xfs_trans_cancel(tp, 0);
8778 + xfs_iunlock(ip, lock_flags);
8784 struct xfs_inode *ip,
8785 @@ -91,6 +174,7 @@ xfs_setattr(
8786 uint commit_flags=0;
8787 uid_t uid=0, iuid=0;
8788 gid_t gid=0, igid=0;
8789 + tag_t tag=0, itag=0;
8791 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8793 @@ -238,7 +322,7 @@ xfs_setattr(
8794 * and can change the group id only to a group of which he
8795 * or she is a member.
8797 - if (mask & (ATTR_UID|ATTR_GID)) {
8798 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8800 * These IDs could have changed since we last looked at them.
8801 * But, we're assured that if the ownership did change
8802 @@ -247,8 +331,10 @@ xfs_setattr(
8804 iuid = ip->i_d.di_uid;
8805 igid = ip->i_d.di_gid;
8806 + itag = ip->i_d.di_tag;
8807 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8808 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8809 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8812 * CAP_CHOWN overrides the following restrictions:
8813 @@ -272,7 +358,9 @@ xfs_setattr(
8816 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8817 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
8818 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8819 + (XFS_IS_GQUOTA_ON(mp) && itag != tag)) {
8820 + /* TODO: handle tagging? */
8822 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
8823 capable(CAP_FOWNER) ?
8824 @@ -461,7 +549,7 @@ xfs_setattr(
8825 * and can change the group id only to a group of which he
8826 * or she is a member.
8828 - if (mask & (ATTR_UID|ATTR_GID)) {
8829 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8831 * CAP_FSETID overrides the following restrictions:
8833 @@ -477,6 +565,10 @@ xfs_setattr(
8834 * Change the ownerships and register quota modifications
8835 * in the transaction.
8837 + if (itag != tag) {
8838 + ip->i_d.di_tag = tag;
8839 + inode->i_tag = tag;
8842 if (XFS_IS_UQUOTA_ON(mp)) {
8843 ASSERT(mask & ATTR_UID);
8844 diff -NurpP --minimal linux-2.6.27.14/fs/xfs/xfs_vnodeops.h linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_vnodeops.h
8845 --- linux-2.6.27.14/fs/xfs/xfs_vnodeops.h 2008-10-13 14:52:06.000000000 +0200
8846 +++ linux-2.6.27.14-vs2.3.0.36.4/fs/xfs/xfs_vnodeops.h 2008-11-12 18:42:03.000000000 +0100
8847 @@ -15,6 +15,7 @@ struct xfs_iomap;
8850 int xfs_open(struct xfs_inode *ip);
8851 +int xfs_sync_xflags(struct xfs_inode *ip);
8852 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags,
8853 struct cred *credp);
8854 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8855 diff -NurpP --minimal linux-2.6.27.14/include/asm-generic/tlb.h linux-2.6.27.14-vs2.3.0.36.4/include/asm-generic/tlb.h
8856 --- linux-2.6.27.14/include/asm-generic/tlb.h 2008-07-13 23:51:29.000000000 +0200
8857 +++ linux-2.6.27.14-vs2.3.0.36.4/include/asm-generic/tlb.h 2008-10-13 14:54:20.000000000 +0200
8859 #define _ASM_GENERIC__TLB_H
8861 #include <linux/swap.h>
8862 +#include <linux/vs_memory.h>
8863 #include <asm/pgalloc.h>
8864 #include <asm/tlbflush.h>
8866 diff -NurpP --minimal linux-2.6.27.14/include/asm-x86/unistd_64.h linux-2.6.27.14-vs2.3.0.36.4/include/asm-x86/unistd_64.h
8867 --- linux-2.6.27.14/include/asm-x86/unistd_64.h 2008-10-13 14:52:08.000000000 +0200
8868 +++ linux-2.6.27.14-vs2.3.0.36.4/include/asm-x86/unistd_64.h 2008-10-13 14:54:20.000000000 +0200
8869 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
8870 #define __NR_utimes 235
8871 __SYSCALL(__NR_utimes, sys_utimes)
8872 #define __NR_vserver 236
8873 -__SYSCALL(__NR_vserver, sys_ni_syscall)
8874 +__SYSCALL(__NR_vserver, sys_vserver)
8875 #define __NR_mbind 237
8876 __SYSCALL(__NR_mbind, sys_mbind)
8877 #define __NR_set_mempolicy 238
8878 diff -NurpP --minimal linux-2.6.27.14/include/linux/capability.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/capability.h
8879 --- linux-2.6.27.14/include/linux/capability.h 2008-10-13 14:52:09.000000000 +0200
8880 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/capability.h 2008-10-13 14:54:20.000000000 +0200
8881 @@ -274,6 +274,7 @@ typedef struct kernel_cap_struct {
8882 arbitrary SCSI commands */
8883 /* Allow setting encryption key on loopback filesystem */
8884 /* Allow setting zone reclaim policy */
8885 +/* Allow the selection of a security context */
8887 #define CAP_SYS_ADMIN 21
8889 @@ -346,7 +347,13 @@ typedef struct kernel_cap_struct {
8891 #define CAP_MAC_ADMIN 33
8893 -#define CAP_LAST_CAP CAP_MAC_ADMIN
8894 +/* Allow context manipulations */
8895 +/* Allow changing context info on files */
8897 +#define CAP_CONTEXT 34
8900 +#define CAP_LAST_CAP CAP_CONTEXT
8902 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8904 diff -NurpP --minimal linux-2.6.27.14/include/linux/devpts_fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/devpts_fs.h
8905 --- linux-2.6.27.14/include/linux/devpts_fs.h 2008-07-13 23:51:29.000000000 +0200
8906 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/devpts_fs.h 2008-10-13 14:54:20.000000000 +0200
8907 @@ -34,5 +34,4 @@ static inline void devpts_pty_kill(int n
8912 #endif /* _LINUX_DEVPTS_FS_H */
8913 diff -NurpP --minimal linux-2.6.27.14/include/linux/ext2_fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/ext2_fs.h
8914 --- linux-2.6.27.14/include/linux/ext2_fs.h 2008-10-13 14:52:09.000000000 +0200
8915 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/ext2_fs.h 2008-10-13 14:54:20.000000000 +0200
8916 @@ -189,8 +189,12 @@ struct ext2_group_desc
8917 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8918 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8919 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8920 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8921 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8923 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8924 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8926 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8927 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8929 @@ -247,7 +251,7 @@ struct ext2_inode {
8931 __u8 l_i_frag; /* Fragment number */
8932 __u8 l_i_fsize; /* Fragment size */
8934 + __u16 l_i_tag; /* Context Tag */
8935 __le16 l_i_uid_high; /* these 2 fields */
8936 __le16 l_i_gid_high; /* were reserved2[0] */
8937 __u32 l_i_reserved2;
8938 @@ -279,6 +283,7 @@ struct ext2_inode {
8939 #define i_gid_low i_gid
8940 #define i_uid_high osd2.linux2.l_i_uid_high
8941 #define i_gid_high osd2.linux2.l_i_gid_high
8942 +#define i_raw_tag osd2.linux2.l_i_tag
8943 #define i_reserved2 osd2.linux2.l_i_reserved2
8946 @@ -323,6 +328,7 @@ struct ext2_inode {
8947 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8948 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8949 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8950 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8953 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8954 diff -NurpP --minimal linux-2.6.27.14/include/linux/ext3_fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/ext3_fs.h
8955 --- linux-2.6.27.14/include/linux/ext3_fs.h 2008-10-13 14:52:09.000000000 +0200
8956 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/ext3_fs.h 2008-10-31 18:15:18.000000000 +0100
8957 @@ -173,10 +173,14 @@ struct ext3_group_desc
8958 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8959 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8960 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8961 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8962 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8964 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8965 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8966 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8967 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8969 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8970 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8973 * Inode dynamic state flags
8974 @@ -292,7 +296,7 @@ struct ext3_inode {
8976 __u8 l_i_frag; /* Fragment number */
8977 __u8 l_i_fsize; /* Fragment size */
8979 + __u16 l_i_tag; /* Context Tag */
8980 __le16 l_i_uid_high; /* these 2 fields */
8981 __le16 l_i_gid_high; /* were reserved2[0] */
8982 __u32 l_i_reserved2;
8983 @@ -326,6 +330,7 @@ struct ext3_inode {
8984 #define i_gid_low i_gid
8985 #define i_uid_high osd2.linux2.l_i_uid_high
8986 #define i_gid_high osd2.linux2.l_i_gid_high
8987 +#define i_raw_tag osd2.linux2.l_i_tag
8988 #define i_reserved2 osd2.linux2.l_i_reserved2
8990 #elif defined(__GNU__)
8991 @@ -380,6 +385,7 @@ struct ext3_inode {
8992 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
8993 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
8994 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8995 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8997 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8998 #ifndef _LINUX_EXT2_FS_H
8999 @@ -822,6 +828,7 @@ struct buffer_head * ext3_bread (handle_
9000 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
9001 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
9002 int create, int extend_disksize);
9003 +extern int ext3_sync_flags(struct inode *inode);
9005 extern struct inode *ext3_iget(struct super_block *, unsigned long);
9006 extern int ext3_write_inode (struct inode *, int);
9007 diff -NurpP --minimal linux-2.6.27.14/include/linux/fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/fs.h
9008 --- linux-2.6.27.14/include/linux/fs.h 2009-02-03 17:59:55.000000000 +0100
9009 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/fs.h 2009-02-03 17:59:04.000000000 +0100
9010 @@ -128,6 +128,9 @@ extern int dir_notify_enable;
9011 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
9012 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
9013 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
9014 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
9015 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
9016 +#define MS_NOTAGCHECK (1<<26) /* don't check tags */
9017 #define MS_ACTIVE (1<<30)
9018 #define MS_NOUSER (1<<31)
9020 @@ -154,6 +157,14 @@ extern int dir_notify_enable;
9021 #define S_NOCMTIME 128 /* Do not update file c/mtime */
9022 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
9023 #define S_PRIVATE 512 /* Inode is fs-internal */
9024 +#define S_IXUNLINK 1024 /* Immutable Invert on unlink */
9026 +/* Linux-VServer related Inode flags */
9030 +#define V_BARRIER 4 /* Barrier for chroot() */
9031 +#define V_COW 8 /* Copy on Write */
9034 * Note that nosuid etc flags are inode-specific: setting some file-system
9035 @@ -176,12 +187,15 @@ extern int dir_notify_enable;
9036 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
9037 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
9038 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
9039 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9040 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9041 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9042 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9043 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
9045 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
9046 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
9047 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
9048 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
9049 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
9050 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
9052 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
9053 @@ -189,6 +203,16 @@ extern int dir_notify_enable;
9054 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
9055 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
9057 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
9059 +#ifdef CONFIG_VSERVER_COWBL
9060 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
9061 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
9063 +# define IS_COW(inode) (0)
9064 +# define IS_COW_LINK(inode) (0)
9067 /* the read-only stuff doesn't really belong here, but any other place is
9068 probably as bad and I don't want to create yet another include file. */
9070 @@ -262,11 +286,14 @@ extern int dir_notify_enable;
9071 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
9072 #define FS_EXTENT_FL 0x00080000 /* Extents */
9073 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
9074 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
9075 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
9077 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
9078 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9079 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9080 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
9082 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
9083 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
9085 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
9086 #define SYNC_FILE_RANGE_WRITE 2
9087 @@ -337,6 +364,7 @@ typedef void (dio_iodone_t)(struct kiocb
9088 #define ATTR_KILL_PRIV (1 << 14)
9089 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
9090 #define ATTR_TIMES_SET (1 << 16)
9091 +#define ATTR_TAG (1 << 17)
9094 * This is the Inode Attributes structure, used for notify_change(). It
9095 @@ -352,6 +380,7 @@ struct iattr {
9101 struct timespec ia_atime;
9102 struct timespec ia_mtime;
9103 @@ -365,6 +394,9 @@ struct iattr {
9104 struct file *ia_file;
9107 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
9108 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
9111 * Includes for diskquotas.
9113 @@ -629,7 +661,9 @@ struct inode {
9114 unsigned int i_nlink;
9122 #ifdef __NEED_I_SIZE_ORDERED
9123 @@ -677,7 +711,8 @@ struct inode {
9124 unsigned long i_state;
9125 unsigned long dirtied_when; /* jiffies of first dirtying */
9127 - unsigned int i_flags;
9128 + unsigned short i_flags;
9129 + unsigned short i_vflags;
9131 atomic_t i_writecount;
9132 #ifdef CONFIG_SECURITY
9133 @@ -764,12 +799,12 @@ static inline void i_size_write(struct i
9135 static inline unsigned iminor(const struct inode *inode)
9137 - return MINOR(inode->i_rdev);
9138 + return MINOR(inode->i_mdev);
9141 static inline unsigned imajor(const struct inode *inode)
9143 - return MAJOR(inode->i_rdev);
9144 + return MAJOR(inode->i_mdev);
9147 extern struct block_device *I_BDEV(struct inode *inode);
9148 @@ -827,6 +862,7 @@ struct file {
9150 struct fown_struct f_owner;
9151 unsigned int f_uid, f_gid;
9153 struct file_ra_state f_ra;
9156 @@ -961,6 +997,7 @@ struct file_lock {
9157 struct file *fl_file;
9162 struct fasync_struct * fl_fasync; /* for lease break notifications */
9163 unsigned long fl_break_time; /* for nonblocking lease breaks */
9164 @@ -1289,6 +1326,7 @@ struct inode_operations {
9165 void (*truncate_range)(struct inode *, loff_t, loff_t);
9166 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
9168 + int (*sync_flags) (struct inode *);
9172 @@ -1304,6 +1342,7 @@ extern ssize_t vfs_readv(struct file *,
9173 unsigned long, loff_t *);
9174 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
9175 unsigned long, loff_t *);
9176 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
9178 struct super_operations {
9179 struct inode *(*alloc_inode)(struct super_block *sb);
9180 @@ -1994,6 +2033,7 @@ extern int dcache_dir_open(struct inode
9181 extern int dcache_dir_close(struct inode *, struct file *);
9182 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
9183 extern int dcache_readdir(struct file *, void *, filldir_t);
9184 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
9185 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
9186 extern int simple_statfs(struct dentry *, struct kstatfs *);
9187 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
9188 diff -NurpP --minimal linux-2.6.27.14/include/linux/if_tun.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/if_tun.h
9189 --- linux-2.6.27.14/include/linux/if_tun.h 2008-10-13 14:52:09.000000000 +0200
9190 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/if_tun.h 2008-10-13 14:54:20.000000000 +0200
9192 #define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
9193 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
9194 #define TUNGETIFF _IOR('T', 210, unsigned int)
9195 +#define TUNSETNID _IOW('T', 215, int)
9197 /* TUNSETIFF ifr flags */
9198 #define IFF_TUN 0x0001
9199 diff -NurpP --minimal linux-2.6.27.14/include/linux/init_task.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/init_task.h
9200 --- linux-2.6.27.14/include/linux/init_task.h 2008-10-13 14:52:09.000000000 +0200
9201 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/init_task.h 2008-10-13 14:54:20.000000000 +0200
9202 @@ -179,6 +179,10 @@ extern struct group_info init_groups;
9204 INIT_TRACE_IRQFLAGS \
9207 + .vx_info = NULL, \
9209 + .nx_info = NULL, \
9213 diff -NurpP --minimal linux-2.6.27.14/include/linux/interrupt.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/interrupt.h
9214 --- linux-2.6.27.14/include/linux/interrupt.h 2008-10-13 14:52:09.000000000 +0200
9215 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/interrupt.h 2008-10-13 14:54:20.000000000 +0200
9217 #include <linux/preempt.h>
9218 #include <linux/cpumask.h>
9219 #include <linux/irqreturn.h>
9220 -#include <linux/hardirq.h>
9221 #include <linux/sched.h>
9222 +#include <linux/hardirq.h>
9223 #include <linux/irqflags.h>
9224 #include <asm/atomic.h>
9225 #include <asm/ptrace.h>
9226 diff -NurpP --minimal linux-2.6.27.14/include/linux/ipc.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/ipc.h
9227 --- linux-2.6.27.14/include/linux/ipc.h 2008-07-13 23:51:29.000000000 +0200
9228 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/ipc.h 2008-10-13 14:54:20.000000000 +0200
9229 @@ -93,6 +93,7 @@ struct kern_ipc_perm
9237 diff -NurpP --minimal linux-2.6.27.14/include/linux/Kbuild linux-2.6.27.14-vs2.3.0.36.4/include/linux/Kbuild
9238 --- linux-2.6.27.14/include/linux/Kbuild 2009-02-03 17:59:55.000000000 +0100
9239 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/Kbuild 2009-02-03 18:03:38.000000000 +0100
9240 @@ -370,3 +370,6 @@ unifdef-y += xattr.h
9243 objhdr-y += version.h
9245 +header-y += vserver/
9247 diff -NurpP --minimal linux-2.6.27.14/include/linux/loop.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/loop.h
9248 --- linux-2.6.27.14/include/linux/loop.h 2008-07-13 23:51:29.000000000 +0200
9249 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/loop.h 2008-10-13 14:54:20.000000000 +0200
9250 @@ -45,6 +45,7 @@ struct loop_device {
9251 struct loop_func_table *lo_encryption;
9253 uid_t lo_key_owner; /* Who set the key */
9255 int (*ioctl)(struct loop_device *, int cmd,
9258 diff -NurpP --minimal linux-2.6.27.14/include/linux/magic.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/magic.h
9259 --- linux-2.6.27.14/include/linux/magic.h 2008-07-13 23:51:29.000000000 +0200
9260 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/magic.h 2008-10-13 14:54:20.000000000 +0200
9263 #define ADFS_SUPER_MAGIC 0xadf5
9264 #define AFFS_SUPER_MAGIC 0xadff
9265 -#define AFS_SUPER_MAGIC 0x5346414F
9266 +#define AFS_SUPER_MAGIC 0x5346414F
9267 #define AUTOFS_SUPER_MAGIC 0x0187
9268 #define CODA_SUPER_MAGIC 0x73757245
9269 #define EFS_SUPER_MAGIC 0x414A53
9271 #define NFS_SUPER_MAGIC 0x6969
9272 #define OPENPROM_SUPER_MAGIC 0x9fa1
9273 #define PROC_SUPER_MAGIC 0x9fa0
9274 +#define DEVPTS_SUPER_MAGIC 0x1cd1
9275 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
9277 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
9278 diff -NurpP --minimal linux-2.6.27.14/include/linux/major.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/major.h
9279 --- linux-2.6.27.14/include/linux/major.h 2008-10-13 14:52:09.000000000 +0200
9280 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/major.h 2008-10-13 14:54:20.000000000 +0200
9282 #define HD_MAJOR IDE0_MAJOR
9283 #define PTY_SLAVE_MAJOR 3
9285 +#define VROOT_MAJOR 4
9286 #define TTYAUX_MAJOR 5
9289 diff -NurpP --minimal linux-2.6.27.14/include/linux/mm_types.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/mm_types.h
9290 --- linux-2.6.27.14/include/linux/mm_types.h 2008-10-13 14:52:09.000000000 +0200
9291 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/mm_types.h 2008-10-13 14:54:20.000000000 +0200
9292 @@ -216,6 +216,7 @@ struct mm_struct {
9294 /* Architecture-specific MM context */
9295 mm_context_t context;
9296 + struct vx_info *mm_vx_info;
9298 /* Swap token stuff */
9300 diff -NurpP --minimal linux-2.6.27.14/include/linux/mount.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/mount.h
9301 --- linux-2.6.27.14/include/linux/mount.h 2008-10-13 14:52:09.000000000 +0200
9302 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/mount.h 2008-10-24 03:34:52.000000000 +0200
9303 @@ -37,6 +37,9 @@ struct mnt_namespace;
9304 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
9305 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
9307 +#define MNT_TAGID 0x10000
9308 +#define MNT_NOTAG 0x20000
9311 struct list_head mnt_hash;
9312 struct vfsmount *mnt_parent; /* fs we are mounted on */
9313 @@ -71,6 +74,7 @@ struct vfsmount {
9314 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
9316 atomic_t __mnt_writers;
9317 + tag_t mnt_tag; /* tagging used for vfsmount */
9320 static inline struct vfsmount *mntget(struct vfsmount *mnt)
9321 diff -NurpP --minimal linux-2.6.27.14/include/linux/net.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/net.h
9322 --- linux-2.6.27.14/include/linux/net.h 2008-10-13 14:52:09.000000000 +0200
9323 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/net.h 2008-10-13 14:54:20.000000000 +0200
9324 @@ -68,6 +68,7 @@ struct net;
9325 #define SOCK_NOSPACE 2
9326 #define SOCK_PASSCRED 3
9327 #define SOCK_PASSSEC 4
9328 +#define SOCK_USER_SOCKET 5
9330 #ifndef ARCH_HAS_SOCKET_TYPES
9332 diff -NurpP --minimal linux-2.6.27.14/include/linux/nfs_mount.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/nfs_mount.h
9333 --- linux-2.6.27.14/include/linux/nfs_mount.h 2008-07-13 23:51:29.000000000 +0200
9334 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/nfs_mount.h 2008-10-13 14:54:20.000000000 +0200
9335 @@ -63,6 +63,7 @@ struct nfs_mount_data {
9336 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9337 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9338 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9339 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9340 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9341 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9344 diff -NurpP --minimal linux-2.6.27.14/include/linux/nsproxy.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/nsproxy.h
9345 --- linux-2.6.27.14/include/linux/nsproxy.h 2008-10-13 14:52:09.000000000 +0200
9346 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/nsproxy.h 2008-10-13 14:54:20.000000000 +0200
9349 #include <linux/spinlock.h>
9350 #include <linux/sched.h>
9351 +#include <linux/vserver/debug.h>
9353 struct mnt_namespace;
9354 struct uts_namespace;
9355 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9358 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9359 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9360 void exit_task_namespaces(struct task_struct *tsk);
9361 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9362 void free_nsproxy(struct nsproxy *ns);
9363 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9364 struct fs_struct *);
9366 -static inline void put_nsproxy(struct nsproxy *ns)
9367 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9369 +static inline void __get_nsproxy(struct nsproxy *ns,
9370 + const char *_file, int _line)
9372 - if (atomic_dec_and_test(&ns->count)) {
9375 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9376 + ns, atomic_read(&ns->count), _file, _line);
9377 + atomic_inc(&ns->count);
9380 -static inline void get_nsproxy(struct nsproxy *ns)
9381 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9383 +static inline void __put_nsproxy(struct nsproxy *ns,
9384 + const char *_file, int _line)
9386 - atomic_inc(&ns->count);
9387 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9388 + ns, atomic_read(&ns->count), _file, _line);
9389 + if (atomic_dec_and_test(&ns->count)) {
9394 #ifdef CONFIG_CGROUP_NS
9395 diff -NurpP --minimal linux-2.6.27.14/include/linux/pid.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/pid.h
9396 --- linux-2.6.27.14/include/linux/pid.h 2008-10-13 14:52:09.000000000 +0200
9397 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/pid.h 2008-10-13 14:54:20.000000000 +0200
9398 @@ -8,7 +8,8 @@ enum pid_type
9408 @@ -142,6 +143,7 @@ static inline pid_t pid_nr(struct pid *p
9411 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9412 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9413 pid_t pid_vnr(struct pid *pid);
9415 #define do_each_pid_task(pid, type, task) \
9416 diff -NurpP --minimal linux-2.6.27.14/include/linux/proc_fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/proc_fs.h
9417 --- linux-2.6.27.14/include/linux/proc_fs.h 2008-10-13 14:52:09.000000000 +0200
9418 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/proc_fs.h 2008-10-13 14:54:20.000000000 +0200
9419 @@ -59,6 +59,7 @@ struct proc_dir_entry {
9425 const struct inode_operations *proc_iops;
9427 @@ -274,12 +275,18 @@ static inline void kclist_add(struct kco
9428 extern void kclist_add(struct kcore_list *, void *, size_t);
9435 int (*proc_get_link)(struct inode *, struct path *);
9436 int (*proc_read)(struct task_struct *task, char *page);
9437 int (*proc_show)(struct seq_file *m,
9438 struct pid_namespace *ns, struct pid *pid,
9439 struct task_struct *task);
9440 + int (*proc_vs_read)(char *page);
9441 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9442 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9445 struct ctl_table_header;
9446 @@ -287,6 +294,7 @@ struct ctl_table;
9453 struct proc_dir_entry *pde;
9454 diff -NurpP --minimal linux-2.6.27.14/include/linux/reiserfs_fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/reiserfs_fs.h
9455 --- linux-2.6.27.14/include/linux/reiserfs_fs.h 2008-10-13 14:52:09.000000000 +0200
9456 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/reiserfs_fs.h 2008-10-13 14:54:20.000000000 +0200
9457 @@ -837,6 +837,11 @@ struct stat_data_v1 {
9458 #define REISERFS_COMPR_FL FS_COMPR_FL
9459 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9461 +/* unfortunately reiserfs sdattr is only 16 bit */
9462 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9463 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9464 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9466 /* persistent flags that file inherits from the parent directory */
9467 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9468 REISERFS_SYNC_FL | \
9469 @@ -846,6 +851,9 @@ struct stat_data_v1 {
9470 REISERFS_COMPR_FL | \
9471 REISERFS_NOTAIL_FL )
9473 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9474 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9476 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9479 @@ -1911,6 +1919,7 @@ static inline void reiserfs_update_sd(st
9480 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9481 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9482 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9483 +int reiserfs_sync_flags(struct inode *inode);
9486 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
9487 diff -NurpP --minimal linux-2.6.27.14/include/linux/reiserfs_fs_sb.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/reiserfs_fs_sb.h
9488 --- linux-2.6.27.14/include/linux/reiserfs_fs_sb.h 2008-10-13 14:52:09.000000000 +0200
9489 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/reiserfs_fs_sb.h 2008-10-13 14:54:20.000000000 +0200
9490 @@ -455,6 +455,7 @@ enum reiserfs_mount_options {
9492 REISERFS_BARRIER_NONE,
9493 REISERFS_BARRIER_FLUSH,
9496 /* Actions on error */
9497 REISERFS_ERROR_PANIC,
9498 diff -NurpP --minimal linux-2.6.27.14/include/linux/sched.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/sched.h
9499 --- linux-2.6.27.14/include/linux/sched.h 2009-02-03 17:59:55.000000000 +0100
9500 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/sched.h 2009-02-03 18:03:38.000000000 +0100
9501 @@ -71,7 +71,6 @@ struct sched_param {
9502 #include <linux/fs_struct.h>
9503 #include <linux/compiler.h>
9504 #include <linux/completion.h>
9505 -#include <linux/pid.h>
9506 #include <linux/percpu.h>
9507 #include <linux/topology.h>
9508 #include <linux/proportions.h>
9509 @@ -88,6 +87,7 @@ struct sched_param {
9510 #include <linux/kobject.h>
9511 #include <linux/latencytop.h>
9512 #include <linux/cred.h>
9513 +#include <linux/pid.h>
9515 #include <asm/processor.h>
9517 @@ -357,25 +357,27 @@ extern void arch_unmap_area_topdown(stru
9518 * The mm counters are not protected by its page_table_lock,
9519 * so must be incremented atomically.
9521 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
9522 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
9523 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
9524 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
9525 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
9527 +#define __set_mm_counter(mm, member, value) \
9528 + atomic_long_set(&(mm)->_##member, value)
9529 +#define get_mm_counter(mm, member) \
9530 + ((unsigned long)atomic_long_read(&(mm)->_##member))
9531 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
9533 * The mm counters are protected by its page_table_lock,
9534 * so can be incremented directly.
9536 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
9537 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
9538 #define get_mm_counter(mm, member) ((mm)->_##member)
9539 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
9540 -#define inc_mm_counter(mm, member) (mm)->_##member++
9541 -#define dec_mm_counter(mm, member) (mm)->_##member--
9543 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
9545 +#define set_mm_counter(mm, member, value) \
9546 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
9547 +#define add_mm_counter(mm, member, value) \
9548 + vx_ ## member ## pages_add((mm), (value))
9549 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
9550 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
9552 #define get_mm_rss(mm) \
9553 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
9554 #define update_hiwater_rss(mm) do { \
9555 @@ -1199,6 +1201,14 @@ struct task_struct {
9559 +/* vserver context data */
9560 + struct vx_info *vx_info;
9561 + struct nx_info *nx_info;
9567 /* Thread group tracking */
9570 @@ -1385,6 +1395,11 @@ struct pid_namespace;
9571 * see also pid_nr() etc in include/linux/pid.h
9574 +#include <linux/vserver/base.h>
9575 +#include <linux/vserver/context.h>
9576 +#include <linux/vserver/debug.h>
9577 +#include <linux/vserver/pid.h>
9579 static inline pid_t task_pid_nr(struct task_struct *tsk)
9582 @@ -1394,7 +1409,7 @@ pid_t task_pid_nr_ns(struct task_struct
9584 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9586 - return pid_vnr(task_pid(tsk));
9587 + return vx_map_pid(pid_vnr(task_pid(tsk)));
9591 @@ -1407,7 +1422,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9593 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9595 - return pid_vnr(task_tgid(tsk));
9596 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9600 diff -NurpP --minimal linux-2.6.27.14/include/linux/shmem_fs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/shmem_fs.h
9601 --- linux-2.6.27.14/include/linux/shmem_fs.h 2008-10-13 14:52:09.000000000 +0200
9602 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/shmem_fs.h 2008-10-13 14:54:20.000000000 +0200
9605 #define SHMEM_NR_DIRECT 16
9607 +#define TMPFS_SUPER_MAGIC 0x01021994
9610 struct shmem_inode_info {
9612 unsigned long flags;
9613 diff -NurpP --minimal linux-2.6.27.14/include/linux/stat.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/stat.h
9614 --- linux-2.6.27.14/include/linux/stat.h 2008-07-13 23:51:29.000000000 +0200
9615 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/stat.h 2008-10-13 14:54:20.000000000 +0200
9616 @@ -66,6 +66,7 @@ struct kstat {
9623 struct timespec atime;
9624 diff -NurpP --minimal linux-2.6.27.14/include/linux/sunrpc/auth.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/sunrpc/auth.h
9625 --- linux-2.6.27.14/include/linux/sunrpc/auth.h 2008-07-13 23:51:29.000000000 +0200
9626 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/sunrpc/auth.h 2008-10-13 14:54:20.000000000 +0200
9632 struct group_info *group_info;
9633 unsigned char machine_cred : 1;
9635 diff -NurpP --minimal linux-2.6.27.14/include/linux/sunrpc/clnt.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/sunrpc/clnt.h
9636 --- linux-2.6.27.14/include/linux/sunrpc/clnt.h 2008-10-13 14:52:09.000000000 +0200
9637 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/sunrpc/clnt.h 2008-10-13 14:54:20.000000000 +0200
9638 @@ -43,7 +43,8 @@ struct rpc_clnt {
9639 unsigned int cl_softrtry : 1,/* soft timeouts */
9640 cl_discrtry : 1,/* disconnect before retry */
9641 cl_autobind : 1,/* use getport() */
9642 - cl_chatty : 1;/* be verbose */
9643 + cl_chatty : 1,/* be verbose */
9644 + cl_tag : 1;/* context tagging */
9646 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9647 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9648 diff -NurpP --minimal linux-2.6.27.14/include/linux/syscalls.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/syscalls.h
9649 --- linux-2.6.27.14/include/linux/syscalls.h 2009-02-03 17:59:55.000000000 +0100
9650 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/syscalls.h 2009-02-03 17:59:04.000000000 +0100
9651 @@ -364,6 +364,8 @@ asmlinkage long sys_symlink(const char _
9652 asmlinkage long sys_unlink(const char __user *pathname);
9653 asmlinkage long sys_rename(const char __user *oldname,
9654 const char __user *newname);
9655 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9657 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9658 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9660 diff -NurpP --minimal linux-2.6.27.14/include/linux/sysctl.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/sysctl.h
9661 --- linux-2.6.27.14/include/linux/sysctl.h 2008-10-13 14:52:09.000000000 +0200
9662 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/sysctl.h 2008-10-13 14:54:20.000000000 +0200
9663 @@ -70,6 +70,7 @@ enum
9664 CTL_ABI=9, /* Binary emulation */
9665 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9666 CTL_ARLAN=254, /* arlan wireless driver */
9667 + CTL_VSERVER=4242, /* Linux-VServer debug */
9668 CTL_S390DBF=5677, /* s390 debug */
9669 CTL_SUNRPC=7249, /* sunrpc debug */
9670 CTL_PM=9899, /* frv power management */
9671 @@ -104,6 +105,7 @@ enum
9673 KERN_PANIC=15, /* int: panic timeout */
9674 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9675 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9677 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9678 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9679 diff -NurpP --minimal linux-2.6.27.14/include/linux/sysfs.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/sysfs.h
9680 --- linux-2.6.27.14/include/linux/sysfs.h 2008-10-13 14:52:09.000000000 +0200
9681 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/sysfs.h 2008-10-13 14:54:20.000000000 +0200
9683 #include <linux/list.h>
9684 #include <asm/atomic.h>
9686 +#define SYSFS_SUPER_MAGIC 0x62656572
9691 diff -NurpP --minimal linux-2.6.27.14/include/linux/time.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/time.h
9692 --- linux-2.6.27.14/include/linux/time.h 2009-02-03 17:59:55.000000000 +0100
9693 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/time.h 2009-02-03 17:59:04.000000000 +0100
9694 @@ -180,6 +180,9 @@ static __always_inline void timespec_add
9695 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9699 +#include <linux/vs_time.h>
9701 #endif /* __KERNEL__ */
9703 #define NFDBITS __NFDBITS
9704 diff -NurpP --minimal linux-2.6.27.14/include/linux/types.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/types.h
9705 --- linux-2.6.27.14/include/linux/types.h 2008-07-13 23:51:29.000000000 +0200
9706 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/types.h 2008-10-13 14:54:20.000000000 +0200
9707 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
9708 typedef __kernel_gid32_t gid_t;
9709 typedef __kernel_uid16_t uid16_t;
9710 typedef __kernel_gid16_t gid16_t;
9711 +typedef unsigned int xid_t;
9712 +typedef unsigned int nid_t;
9713 +typedef unsigned int tag_t;
9715 typedef unsigned long uintptr_t;
9717 diff -NurpP --minimal linux-2.6.27.14/include/linux/vroot.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vroot.h
9718 --- linux-2.6.27.14/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9719 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vroot.h 2008-10-13 14:54:20.000000000 +0200
9723 + * include/linux/vroot.h
9725 + * written by Herbert Pötzl, 9/11/2002
9726 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9728 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9729 + * Redistribution of this file is permitted under the
9730 + * GNU General Public License.
9733 +#ifndef _LINUX_VROOT_H
9734 +#define _LINUX_VROOT_H
9739 +/* Possible states of device */
9745 +struct vroot_device {
9749 + struct semaphore vr_ctl_mutex;
9750 + struct block_device *vr_device;
9755 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9757 +extern int register_vroot_grb(vroot_grb_func *);
9758 +extern int unregister_vroot_grb(vroot_grb_func *);
9760 +#endif /* __KERNEL__ */
9762 +#define MAX_VROOT_DEFAULT 8
9765 + * IOCTL commands --- we will commandeer 0x56 ('V')
9768 +#define VROOT_SET_DEV 0x5600
9769 +#define VROOT_CLR_DEV 0x5601
9771 +#endif /* _LINUX_VROOT_H */
9772 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_base.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_base.h
9773 --- linux-2.6.27.14/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9774 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_base.h 2008-10-13 14:54:20.000000000 +0200
9779 +#include "vserver/base.h"
9780 +#include "vserver/check.h"
9781 +#include "vserver/debug.h"
9784 +#warning duplicate inclusion
9786 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_context.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_context.h
9787 --- linux-2.6.27.14/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9788 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_context.h 2008-10-13 14:54:20.000000000 +0200
9790 +#ifndef _VS_CONTEXT_H
9791 +#define _VS_CONTEXT_H
9793 +#include "vserver/base.h"
9794 +#include "vserver/check.h"
9795 +#include "vserver/context.h"
9796 +#include "vserver/history.h"
9797 +#include "vserver/debug.h"
9799 +#include <linux/sched.h>
9802 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9804 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9805 + const char *_file, int _line, void *_here)
9810 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9811 + vxi, vxi ? vxi->vx_id : 0,
9812 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9814 + __vxh_get_vx_info(vxi, _here);
9816 + atomic_inc(&vxi->vx_usecnt);
9821 +extern void free_vx_info(struct vx_info *);
9823 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9825 +static inline void __put_vx_info(struct vx_info *vxi,
9826 + const char *_file, int _line, void *_here)
9831 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9832 + vxi, vxi ? vxi->vx_id : 0,
9833 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9835 + __vxh_put_vx_info(vxi, _here);
9837 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9838 + free_vx_info(vxi);
9842 +#define init_vx_info(p, i) \
9843 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9845 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9846 + const char *_file, int _line, void *_here)
9849 + vxlprintk(VXD_CBIT(xid, 3),
9850 + "init_vx_info(%p[#%d.%d])",
9851 + vxi, vxi ? vxi->vx_id : 0,
9852 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9854 + __vxh_init_vx_info(vxi, vxp, _here);
9856 + atomic_inc(&vxi->vx_usecnt);
9862 +#define set_vx_info(p, i) \
9863 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9865 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9866 + const char *_file, int _line, void *_here)
9868 + struct vx_info *vxo;
9873 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9874 + vxi, vxi ? vxi->vx_id : 0,
9875 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9877 + __vxh_set_vx_info(vxi, vxp, _here);
9879 + atomic_inc(&vxi->vx_usecnt);
9880 + vxo = xchg(vxp, vxi);
9885 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9887 +static inline void __clr_vx_info(struct vx_info **vxp,
9888 + const char *_file, int _line, void *_here)
9890 + struct vx_info *vxo;
9892 + vxo = xchg(vxp, NULL);
9896 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9897 + vxo, vxo ? vxo->vx_id : 0,
9898 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9900 + __vxh_clr_vx_info(vxo, vxp, _here);
9902 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9903 + free_vx_info(vxo);
9907 +#define claim_vx_info(v, p) \
9908 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9910 +static inline void __claim_vx_info(struct vx_info *vxi,
9911 + struct task_struct *task,
9912 + const char *_file, int _line, void *_here)
9914 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9915 + vxi, vxi ? vxi->vx_id : 0,
9916 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9917 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9918 + task, _file, _line);
9919 + __vxh_claim_vx_info(vxi, task, _here);
9921 + atomic_inc(&vxi->vx_tasks);
9925 +extern void unhash_vx_info(struct vx_info *);
9927 +#define release_vx_info(v, p) \
9928 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9930 +static inline void __release_vx_info(struct vx_info *vxi,
9931 + struct task_struct *task,
9932 + const char *_file, int _line, void *_here)
9934 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9935 + vxi, vxi ? vxi->vx_id : 0,
9936 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9937 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9938 + task, _file, _line);
9939 + __vxh_release_vx_info(vxi, task, _here);
9943 + if (atomic_dec_and_test(&vxi->vx_tasks))
9944 + unhash_vx_info(vxi);
9948 +#define task_get_vx_info(p) \
9949 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9951 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9952 + const char *_file, int _line, void *_here)
9954 + struct vx_info *vxi;
9957 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9959 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9965 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9967 + if (waitqueue_active(&vxi->vx_wait))
9968 + wake_up_interruptible(&vxi->vx_wait);
9972 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9974 +static inline void __enter_vx_info(struct vx_info *vxi,
9975 + struct vx_info_save *vxis, const char *_file, int _line)
9977 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9978 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9979 + current->xid, current->vx_info, _file, _line);
9980 + vxis->vxi = xchg(¤t->vx_info, vxi);
9981 + vxis->xid = current->xid;
9982 + current->xid = vxi ? vxi->vx_id : 0;
9985 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9987 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9988 + const char *_file, int _line)
9990 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9991 + vxis, vxis->xid, vxis->vxi, current,
9992 + current->xid, current->vx_info, _file, _line);
9993 + (void)xchg(¤t->vx_info, vxis->vxi);
9994 + current->xid = vxis->xid;
9998 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
10000 + vxis->vxi = xchg(¤t->vx_info, NULL);
10001 + vxis->xid = xchg(¤t->xid, (xid_t)0);
10004 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
10006 + (void)xchg(¤t->xid, vxis->xid);
10007 + (void)xchg(¤t->vx_info, vxis->vxi);
10010 +extern void exit_vx_info(struct task_struct *, int);
10011 +extern void exit_vx_info_early(struct task_struct *, int);
10015 +#warning duplicate inclusion
10017 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_cowbl.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_cowbl.h
10018 --- linux-2.6.27.14/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
10019 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_cowbl.h 2008-10-13 14:54:20.000000000 +0200
10021 +#ifndef _VS_COWBL_H
10022 +#define _VS_COWBL_H
10024 +#include <linux/fs.h>
10025 +#include <linux/dcache.h>
10026 +#include <linux/namei.h>
10028 +extern struct dentry *cow_break_link(const char *pathname);
10030 +static inline int cow_check_and_break(struct path *path)
10032 + struct inode *inode = path->dentry->d_inode;
10035 + /* do we need this check? */
10036 + if (IS_RDONLY(inode))
10039 + if (IS_COW(inode)) {
10040 + if (IS_COW_LINK(inode)) {
10041 + struct dentry *new_dentry, *old_dentry = path->dentry;
10044 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
10048 + pp = d_path(path, buf, PATH_MAX);
10049 + new_dentry = cow_break_link(pp);
10051 + if (!IS_ERR(new_dentry)) {
10052 + path->dentry = new_dentry;
10053 + dput(old_dentry);
10055 + error = PTR_ERR(new_dentry);
10057 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
10058 + inode->i_ctime = CURRENT_TIME;
10059 + mark_inode_dirty(inode);
10066 +#warning duplicate inclusion
10068 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_cvirt.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_cvirt.h
10069 --- linux-2.6.27.14/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
10070 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_cvirt.h 2008-10-13 14:54:20.000000000 +0200
10072 +#ifndef _VS_CVIRT_H
10073 +#define _VS_CVIRT_H
10075 +#include "vserver/cvirt.h"
10076 +#include "vserver/context.h"
10077 +#include "vserver/base.h"
10078 +#include "vserver/check.h"
10079 +#include "vserver/debug.h"
10082 +static inline void vx_activate_task(struct task_struct *p)
10084 + struct vx_info *vxi;
10086 + if ((vxi = p->vx_info)) {
10087 + vx_update_load(vxi);
10088 + atomic_inc(&vxi->cvirt.nr_running);
10092 +static inline void vx_deactivate_task(struct task_struct *p)
10094 + struct vx_info *vxi;
10096 + if ((vxi = p->vx_info)) {
10097 + vx_update_load(vxi);
10098 + atomic_dec(&vxi->cvirt.nr_running);
10102 +static inline void vx_uninterruptible_inc(struct task_struct *p)
10104 + struct vx_info *vxi;
10106 + if ((vxi = p->vx_info))
10107 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
10110 +static inline void vx_uninterruptible_dec(struct task_struct *p)
10112 + struct vx_info *vxi;
10114 + if ((vxi = p->vx_info))
10115 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
10120 +#warning duplicate inclusion
10122 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_device.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_device.h
10123 --- linux-2.6.27.14/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
10124 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_device.h 2008-10-13 14:54:20.000000000 +0200
10126 +#ifndef _VS_DEVICE_H
10127 +#define _VS_DEVICE_H
10129 +#include "vserver/base.h"
10130 +#include "vserver/device.h"
10131 +#include "vserver/debug.h"
10134 +#ifdef CONFIG_VSERVER_DEVICE
10136 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
10138 +#define vs_device_perm(v, d, m, p) \
10139 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
10144 +int vs_map_device(struct vx_info *vxi,
10145 + dev_t device, dev_t *target, umode_t mode)
10148 + *target = device;
10152 +#define vs_device_perm(v, d, m, p) ((p) == (p))
10157 +#define vs_map_chrdev(d, t, p) \
10158 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
10159 +#define vs_map_blkdev(d, t, p) \
10160 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
10162 +#define vs_chrdev_perm(d, p) \
10163 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
10164 +#define vs_blkdev_perm(d, p) \
10165 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
10169 +#warning duplicate inclusion
10171 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_dlimit.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_dlimit.h
10172 --- linux-2.6.27.14/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
10173 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_dlimit.h 2008-10-13 14:54:20.000000000 +0200
10175 +#ifndef _VS_DLIMIT_H
10176 +#define _VS_DLIMIT_H
10178 +#include <linux/fs.h>
10180 +#include "vserver/dlimit.h"
10181 +#include "vserver/base.h"
10182 +#include "vserver/debug.h"
10185 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
10187 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
10188 + const char *_file, int _line)
10192 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
10193 + dli, dli ? dli->dl_tag : 0,
10194 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10196 + atomic_inc(&dli->dl_usecnt);
10201 +#define free_dl_info(i) \
10202 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
10204 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
10206 +static inline void __put_dl_info(struct dl_info *dli,
10207 + const char *_file, int _line)
10211 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
10212 + dli, dli ? dli->dl_tag : 0,
10213 + dli ? atomic_read(&dli->dl_usecnt) : 0,
10215 + if (atomic_dec_and_test(&dli->dl_usecnt))
10216 + free_dl_info(dli);
10220 +#define __dlimit_char(d) ((d) ? '*' : ' ')
10222 +static inline int __dl_alloc_space(struct super_block *sb,
10223 + tag_t tag, dlsize_t nr, const char *file, int line)
10225 + struct dl_info *dli = NULL;
10230 + dli = locate_dl_info(sb, tag);
10234 + spin_lock(&dli->dl_lock);
10235 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
10237 + dli->dl_space_used += nr;
10238 + spin_unlock(&dli->dl_lock);
10239 + put_dl_info(dli);
10241 + vxlprintk(VXD_CBIT(dlim, 1),
10242 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
10243 + sb, tag, __dlimit_char(dli), (long long)nr,
10244 + ret, file, line);
10248 +static inline void __dl_free_space(struct super_block *sb,
10249 + tag_t tag, dlsize_t nr, const char *_file, int _line)
10251 + struct dl_info *dli = NULL;
10255 + dli = locate_dl_info(sb, tag);
10259 + spin_lock(&dli->dl_lock);
10260 + if (dli->dl_space_used > nr)
10261 + dli->dl_space_used -= nr;
10263 + dli->dl_space_used = 0;
10264 + spin_unlock(&dli->dl_lock);
10265 + put_dl_info(dli);
10267 + vxlprintk(VXD_CBIT(dlim, 1),
10268 + "FREE (%p,#%d)%c %lld bytes",
10269 + sb, tag, __dlimit_char(dli), (long long)nr,
10273 +static inline int __dl_alloc_inode(struct super_block *sb,
10274 + tag_t tag, const char *_file, int _line)
10276 + struct dl_info *dli;
10279 + dli = locate_dl_info(sb, tag);
10283 + spin_lock(&dli->dl_lock);
10284 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
10286 + dli->dl_inodes_used++;
10287 + spin_unlock(&dli->dl_lock);
10288 + put_dl_info(dli);
10290 + vxlprintk(VXD_CBIT(dlim, 0),
10291 + "ALLOC (%p,#%d)%c inode (%d)",
10292 + sb, tag, __dlimit_char(dli), ret, _file, _line);
10296 +static inline void __dl_free_inode(struct super_block *sb,
10297 + tag_t tag, const char *_file, int _line)
10299 + struct dl_info *dli;
10301 + dli = locate_dl_info(sb, tag);
10305 + spin_lock(&dli->dl_lock);
10306 + if (dli->dl_inodes_used > 1)
10307 + dli->dl_inodes_used--;
10309 + dli->dl_inodes_used = 0;
10310 + spin_unlock(&dli->dl_lock);
10311 + put_dl_info(dli);
10313 + vxlprintk(VXD_CBIT(dlim, 0),
10314 + "FREE (%p,#%d)%c inode",
10315 + sb, tag, __dlimit_char(dli), _file, _line);
10318 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10319 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10320 + const char *_file, int _line)
10322 + struct dl_info *dli;
10323 + uint64_t broot, bfree;
10325 + dli = locate_dl_info(sb, tag);
10329 + spin_lock(&dli->dl_lock);
10330 + broot = (dli->dl_space_total -
10331 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10332 + >> sb->s_blocksize_bits;
10333 + bfree = (dli->dl_space_total - dli->dl_space_used)
10334 + >> sb->s_blocksize_bits;
10335 + spin_unlock(&dli->dl_lock);
10337 + vxlprintk(VXD_CBIT(dlim, 2),
10338 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10339 + (long long)bfree, (long long)broot,
10340 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10342 + if (free_blocks) {
10343 + if (*free_blocks > bfree)
10344 + *free_blocks = bfree;
10346 + if (root_blocks) {
10347 + if (*root_blocks > broot)
10348 + *root_blocks = broot;
10350 + put_dl_info(dli);
10353 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
10354 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10355 + __FILE__, __LINE__ )
10357 +#define DLIMIT_FREE_SPACE(in, bytes) \
10358 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10359 + __FILE__, __LINE__ )
10361 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
10362 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
10363 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10364 + __FILE__, __LINE__ )
10366 +#define DLIMIT_FREE_BLOCK(in, nr) \
10367 + __dl_free_space((in)->i_sb, (in)->i_tag, \
10368 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
10369 + __FILE__, __LINE__ )
10372 +#define DLIMIT_ALLOC_INODE(in) \
10373 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10375 +#define DLIMIT_FREE_INODE(in) \
10376 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10379 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
10380 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10384 +#warning duplicate inclusion
10386 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/base.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/base.h
10387 --- linux-2.6.27.14/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10388 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/base.h 2008-10-13 14:54:20.000000000 +0200
10390 +#ifndef _VX_BASE_H
10391 +#define _VX_BASE_H
10394 +/* context state changes */
10406 +#define vx_task_xid(t) ((t)->xid)
10408 +#define vx_current_xid() vx_task_xid(current)
10410 +#define current_vx_info() (current->vx_info)
10413 +#define nx_task_nid(t) ((t)->nid)
10415 +#define nx_current_nid() nx_task_nid(current)
10417 +#define current_nx_info() (current->nx_info)
10420 +/* generic flag merging */
10422 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10424 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10426 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10428 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10431 +/* context flags */
10433 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10435 +#define vx_current_flags() __vx_flags(current->vx_info)
10437 +#define vx_info_flags(v, m, f) \
10438 + vs_check_flags(__vx_flags(v), m, f)
10440 +#define task_vx_flags(t, m, f) \
10441 + ((t) && vx_info_flags((t)->vx_info, m, f))
10443 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
10446 +/* context caps */
10448 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10450 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
10452 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10454 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
10458 +/* network flags */
10460 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10462 +#define nx_current_flags() __nx_flags(current->nx_info)
10464 +#define nx_info_flags(n, m, f) \
10465 + vs_check_flags(__nx_flags(n), m, f)
10467 +#define task_nx_flags(t, m, f) \
10468 + ((t) && nx_info_flags((t)->nx_info, m, f))
10470 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
10473 +/* network caps */
10475 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10477 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
10479 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10481 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
10484 +/* context mask capabilities */
10486 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10488 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10490 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
10493 +/* context bcap mask */
10495 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10497 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
10500 +/* mask given bcaps */
10502 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10504 +#define vx_mbcaps(c) vx_info_mbcaps(current->vx_info, c)
10507 +/* masked cap_bset */
10509 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10511 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
10514 +#define vx_info_mbcap(v, b) \
10515 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10516 + vx_info_bcaps(v, b) : (b))
10518 +#define task_vx_mbcap(t, b) \
10519 + vx_info_mbcap((t)->vx_info, (t)->b)
10521 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10524 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10526 +#define vx_capable(b, c) (capable(b) || \
10527 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
10529 +#define nx_capable(b, c) (capable(b) || \
10530 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
10532 +#define vx_current_initpid(n) \
10533 + (current->vx_info && \
10534 + (current->vx_info->vx_initpid == (n)))
10537 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10539 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10542 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10544 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10547 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cacct_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct_cmd.h
10548 --- linux-2.6.27.14/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10549 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct_cmd.h 2008-10-13 14:54:20.000000000 +0200
10551 +#ifndef _VX_CACCT_CMD_H
10552 +#define _VX_CACCT_CMD_H
10555 +/* virtual host info name commands */
10557 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10559 +struct vcmd_sock_stat_v0 {
10561 + uint32_t count[3];
10562 + uint64_t total[3];
10568 +#include <linux/compiler.h>
10570 +extern int vc_sock_stat(struct vx_info *, void __user *);
10572 +#endif /* __KERNEL__ */
10573 +#endif /* _VX_CACCT_CMD_H */
10574 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cacct_def.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct_def.h
10575 --- linux-2.6.27.14/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10576 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct_def.h 2008-10-13 14:54:20.000000000 +0200
10578 +#ifndef _VX_CACCT_DEF_H
10579 +#define _VX_CACCT_DEF_H
10581 +#include <asm/atomic.h>
10582 +#include <linux/vserver/cacct.h>
10585 +struct _vx_sock_acc {
10586 + atomic_long_t count;
10587 + atomic_long_t total;
10590 +/* context sub struct */
10592 +struct _vx_cacct {
10593 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10594 + atomic_t slab[8];
10595 + atomic_t page[6][8];
10598 +#ifdef CONFIG_VSERVER_DEBUG
10600 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10604 + printk("\t_vx_cacct:");
10605 + for (i = 0; i < 6; i++) {
10606 + struct _vx_sock_acc *ptr = cacct->sock[i];
10608 + printk("\t [%d] =", i);
10609 + for (j = 0; j < 3; j++) {
10610 + printk(" [%d] = %8lu, %8lu", j,
10611 + atomic_long_read(&ptr[j].count),
10612 + atomic_long_read(&ptr[j].total));
10620 +#endif /* _VX_CACCT_DEF_H */
10621 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cacct.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct.h
10622 --- linux-2.6.27.14/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10623 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct.h 2008-10-13 14:54:20.000000000 +0200
10625 +#ifndef _VX_CACCT_H
10626 +#define _VX_CACCT_H
10629 +enum sock_acc_field {
10630 + VXA_SOCK_UNSPEC = 0,
10636 + VXA_SOCK_SIZE /* array size */
10639 +#endif /* _VX_CACCT_H */
10640 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cacct_int.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct_int.h
10641 --- linux-2.6.27.14/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10642 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cacct_int.h 2008-10-13 14:54:20.000000000 +0200
10644 +#ifndef _VX_CACCT_INT_H
10645 +#define _VX_CACCT_INT_H
10651 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10653 + return atomic_long_read(&cacct->sock[type][pos].count);
10658 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10660 + return atomic_long_read(&cacct->sock[type][pos].total);
10663 +#endif /* __KERNEL__ */
10664 +#endif /* _VX_CACCT_INT_H */
10665 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/check.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/check.h
10666 --- linux-2.6.27.14/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10667 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/check.h 2008-10-13 14:54:20.000000000 +0200
10669 +#ifndef _VS_CHECK_H
10670 +#define _VS_CHECK_H
10673 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10675 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10676 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10678 +#define MIN_D_CONTEXT 65536
10681 +/* check conditions */
10683 +#define VS_ADMIN 0x0001
10684 +#define VS_WATCH 0x0002
10685 +#define VS_HIDE 0x0004
10686 +#define VS_HOSTID 0x0008
10688 +#define VS_IDENT 0x0010
10689 +#define VS_EQUIV 0x0020
10690 +#define VS_PARENT 0x0040
10691 +#define VS_CHILD 0x0080
10693 +#define VS_ARG_MASK 0x00F0
10695 +#define VS_DYNAMIC 0x0100
10696 +#define VS_STATIC 0x0200
10698 +#define VS_ATR_MASK 0x0F00
10700 +#ifdef CONFIG_VSERVER_PRIVACY
10701 +#define VS_ADMIN_P (0)
10702 +#define VS_WATCH_P (0)
10704 +#define VS_ADMIN_P VS_ADMIN
10705 +#define VS_WATCH_P VS_WATCH
10708 +#define VS_HARDIRQ 0x1000
10709 +#define VS_SOFTIRQ 0x2000
10710 +#define VS_IRQ 0x4000
10712 +#define VS_IRQ_MASK 0xF000
10714 +#include <linux/hardirq.h>
10717 + * check current context for ADMIN/WATCH and
10718 + * optionally against supplied argument
10720 +static inline int __vs_check(int cid, int id, unsigned int mode)
10722 + if (mode & VS_ARG_MASK) {
10723 + if ((mode & VS_IDENT) && (id == cid))
10726 + if (mode & VS_ATR_MASK) {
10727 + if ((mode & VS_DYNAMIC) &&
10728 + (id >= MIN_D_CONTEXT) &&
10729 + (id <= MAX_S_CONTEXT))
10731 + if ((mode & VS_STATIC) &&
10732 + (id > 1) && (id < MIN_D_CONTEXT))
10735 + if (mode & VS_IRQ_MASK) {
10736 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10738 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10740 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10743 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10744 + ((mode & VS_WATCH) && (cid == 1)) ||
10745 + ((mode & VS_HOSTID) && (id == 0)));
10748 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10750 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10753 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10755 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10758 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/context_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/context_cmd.h
10759 --- linux-2.6.27.14/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10760 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/context_cmd.h 2008-10-13 14:54:20.000000000 +0200
10762 +#ifndef _VX_CONTEXT_CMD_H
10763 +#define _VX_CONTEXT_CMD_H
10766 +/* vinfo commands */
10768 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10771 +extern int vc_task_xid(uint32_t);
10773 +#endif /* __KERNEL__ */
10775 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10777 +struct vcmd_vx_info_v0 {
10779 + uint32_t initpid;
10780 + /* more to come */
10784 +extern int vc_vx_info(struct vx_info *, void __user *);
10786 +#endif /* __KERNEL__ */
10788 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10790 +struct vcmd_ctx_stat_v0 {
10793 + /* more to come */
10797 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10799 +#endif /* __KERNEL__ */
10801 +/* context commands */
10803 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10804 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10806 +struct vcmd_ctx_create {
10807 + uint64_t flagword;
10810 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10811 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10813 +struct vcmd_ctx_migrate {
10814 + uint64_t flagword;
10818 +extern int vc_ctx_create(uint32_t, void __user *);
10819 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10821 +#endif /* __KERNEL__ */
10824 +/* flag commands */
10826 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10827 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10829 +struct vcmd_ctx_flags_v0 {
10830 + uint64_t flagword;
10835 +extern int vc_get_cflags(struct vx_info *, void __user *);
10836 +extern int vc_set_cflags(struct vx_info *, void __user *);
10838 +#endif /* __KERNEL__ */
10841 +/* context caps commands */
10843 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10844 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10846 +struct vcmd_ctx_caps_v1 {
10852 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10853 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10855 +#endif /* __KERNEL__ */
10858 +/* bcaps commands */
10860 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10861 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10863 +struct vcmd_bcaps {
10869 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10870 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10872 +#endif /* __KERNEL__ */
10877 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10878 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10880 +struct vcmd_badness_v0 {
10885 +extern int vc_get_badness(struct vx_info *, void __user *);
10886 +extern int vc_set_badness(struct vx_info *, void __user *);
10888 +#endif /* __KERNEL__ */
10889 +#endif /* _VX_CONTEXT_CMD_H */
10890 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/context.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/context.h
10891 --- linux-2.6.27.14/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10892 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/context.h 2008-10-31 18:15:28.000000000 +0100
10894 +#ifndef _VX_CONTEXT_H
10895 +#define _VX_CONTEXT_H
10897 +#include <linux/types.h>
10898 +#include <linux/capability.h>
10901 +/* context flags */
10903 +#define VXF_INFO_SCHED 0x00000002
10904 +#define VXF_INFO_NPROC 0x00000004
10905 +#define VXF_INFO_PRIVATE 0x00000008
10907 +#define VXF_INFO_INIT 0x00000010
10908 +#define VXF_INFO_HIDE 0x00000020
10909 +#define VXF_INFO_ULIMIT 0x00000040
10910 +#define VXF_INFO_NSPACE 0x00000080
10912 +#define VXF_SCHED_HARD 0x00000100
10913 +#define VXF_SCHED_PRIO 0x00000200
10914 +#define VXF_SCHED_PAUSE 0x00000400
10916 +#define VXF_VIRT_MEM 0x00010000
10917 +#define VXF_VIRT_UPTIME 0x00020000
10918 +#define VXF_VIRT_CPU 0x00040000
10919 +#define VXF_VIRT_LOAD 0x00080000
10920 +#define VXF_VIRT_TIME 0x00100000
10922 +#define VXF_HIDE_MOUNT 0x01000000
10923 +/* was VXF_HIDE_NETIF 0x02000000 */
10924 +#define VXF_HIDE_VINFO 0x04000000
10926 +#define VXF_STATE_SETUP (1ULL << 32)
10927 +#define VXF_STATE_INIT (1ULL << 33)
10928 +#define VXF_STATE_ADMIN (1ULL << 34)
10930 +#define VXF_SC_HELPER (1ULL << 36)
10931 +#define VXF_REBOOT_KILL (1ULL << 37)
10932 +#define VXF_PERSISTENT (1ULL << 38)
10934 +#define VXF_FORK_RSS (1ULL << 48)
10935 +#define VXF_PROLIFIC (1ULL << 49)
10937 +#define VXF_IGNEG_NICE (1ULL << 52)
10939 +#define VXF_ONE_TIME (0x0007ULL << 32)
10941 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10944 +/* context migration */
10946 +#define VXM_SET_INIT 0x00000001
10947 +#define VXM_SET_REAPER 0x00000002
10949 +/* context caps */
10951 +#define VXC_CAP_MASK 0x00000000
10953 +#define VXC_SET_UTSNAME 0x00000001
10954 +#define VXC_SET_RLIMIT 0x00000002
10956 +/* was VXC_RAW_ICMP 0x00000100 */
10957 +#define VXC_SYSLOG 0x00001000
10959 +#define VXC_SECURE_MOUNT 0x00010000
10960 +#define VXC_SECURE_REMOUNT 0x00020000
10961 +#define VXC_BINARY_MOUNT 0x00040000
10963 +#define VXC_QUOTA_CTL 0x00100000
10964 +#define VXC_ADMIN_MAPPER 0x00200000
10965 +#define VXC_ADMIN_CLOOP 0x00400000
10967 +#define VXC_KTHREAD 0x01000000
10972 +#include <linux/list.h>
10973 +#include <linux/spinlock.h>
10974 +#include <linux/rcupdate.h>
10976 +#include "limit_def.h"
10977 +#include "sched_def.h"
10978 +#include "cvirt_def.h"
10979 +#include "cacct_def.h"
10980 +#include "device_def.h"
10982 +#define VX_SPACES 2
10984 +struct _vx_info_pc {
10985 + struct _vx_sched_pc sched_pc;
10986 + struct _vx_cvirt_pc cvirt_pc;
10990 + struct hlist_node vx_hlist; /* linked list of contexts */
10991 + xid_t vx_id; /* context id */
10992 + atomic_t vx_usecnt; /* usage count */
10993 + atomic_t vx_tasks; /* tasks count */
10994 + struct vx_info *vx_parent; /* parent context */
10995 + int vx_state; /* context state */
10997 + unsigned long vx_nsmask[VX_SPACES]; /* assignment mask */
10998 + struct nsproxy *vx_nsproxy[VX_SPACES]; /* private namespaces */
10999 + struct fs_struct *vx_fs[VX_SPACES]; /* private namespace fs */
11001 + uint64_t vx_flags; /* context flags */
11002 + uint64_t vx_ccaps; /* context caps (vserver) */
11003 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11004 + // kernel_cap_t vx_cap_bset; /* the guest's bset */
11006 + struct task_struct *vx_reaper; /* guest reaper process */
11007 + pid_t vx_initpid; /* PID of guest init */
11008 + int64_t vx_badness_bias; /* OOM points bias */
11010 + struct _vx_limit limit; /* vserver limits */
11011 + struct _vx_sched sched; /* vserver scheduler */
11012 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11013 + struct _vx_cacct cacct; /* context accounting */
11015 + struct _vx_device dmap; /* default device map targets */
11017 +#ifndef CONFIG_SMP
11018 + struct _vx_info_pc info_pc; /* per cpu data */
11020 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11023 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11024 + int reboot_cmd; /* last sys_reboot() cmd */
11025 + int exit_code; /* last process exit code */
11027 + char vx_name[65]; /* vserver name */
11030 +#ifndef CONFIG_SMP
11031 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11032 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11034 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11035 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11038 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11041 +struct vx_info_save {
11042 + struct vx_info *vxi;
11047 +/* status flags */
11049 +#define VXS_HASHED 0x0001
11050 +#define VXS_PAUSED 0x0010
11051 +#define VXS_SHUTDOWN 0x0100
11052 +#define VXS_HELPER 0x1000
11053 +#define VXS_RELEASED 0x8000
11056 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11057 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11059 +extern struct vx_info *lookup_vx_info(int);
11060 +extern struct vx_info *lookup_or_create_vx_info(int);
11062 +extern int get_xid_list(int, unsigned int *, int);
11063 +extern int xid_is_hashed(xid_t);
11065 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11067 +extern long vs_state_change(struct vx_info *, unsigned int);
11070 +#endif /* __KERNEL__ */
11071 +#endif /* _VX_CONTEXT_H */
11072 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cvirt_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cvirt_cmd.h
11073 --- linux-2.6.27.14/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11074 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cvirt_cmd.h 2008-10-13 14:54:20.000000000 +0200
11076 +#ifndef _VX_CVIRT_CMD_H
11077 +#define _VX_CVIRT_CMD_H
11080 +/* virtual host info name commands */
11082 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11083 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11085 +struct vcmd_vhi_name_v0 {
11091 +enum vhi_name_field {
11092 + VHIN_CONTEXT = 0,
11104 +#include <linux/compiler.h>
11106 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11107 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11109 +#endif /* __KERNEL__ */
11111 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11113 +struct vcmd_virt_stat_v0 {
11116 + uint32_t nr_threads;
11117 + uint32_t nr_running;
11118 + uint32_t nr_uninterruptible;
11119 + uint32_t nr_onhold;
11120 + uint32_t nr_forks;
11121 + uint32_t load[3];
11125 +extern int vc_virt_stat(struct vx_info *, void __user *);
11127 +#endif /* __KERNEL__ */
11128 +#endif /* _VX_CVIRT_CMD_H */
11129 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cvirt_def.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cvirt_def.h
11130 --- linux-2.6.27.14/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11131 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cvirt_def.h 2008-10-13 14:54:20.000000000 +0200
11133 +#ifndef _VX_CVIRT_DEF_H
11134 +#define _VX_CVIRT_DEF_H
11136 +#include <linux/jiffies.h>
11137 +#include <linux/spinlock.h>
11138 +#include <linux/wait.h>
11139 +#include <linux/time.h>
11140 +#include <asm/atomic.h>
11143 +struct _vx_usage_stat {
11147 + uint64_t softirq;
11153 +struct _vx_syslog {
11154 + wait_queue_head_t log_wait;
11155 + spinlock_t logbuf_lock; /* lock for the log buffer */
11157 + unsigned long log_start; /* next char to be read by syslog() */
11158 + unsigned long con_start; /* next char to be sent to consoles */
11159 + unsigned long log_end; /* most-recently-written-char + 1 */
11160 + unsigned long logged_chars; /* #chars since last read+clear operation */
11162 + char log_buf[1024];
11166 +/* context sub struct */
11168 +struct _vx_cvirt {
11169 + atomic_t nr_threads; /* number of current threads */
11170 + atomic_t nr_running; /* number of running threads */
11171 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11173 + atomic_t nr_onhold; /* processes on hold */
11174 + uint32_t onhold_last; /* jiffies when put on hold */
11176 + struct timeval bias_tv; /* time offset to the host */
11177 + struct timespec bias_idle;
11178 + struct timespec bias_uptime; /* context creation point */
11179 + uint64_t bias_clock; /* offset in clock_t */
11181 + spinlock_t load_lock; /* lock for the load averages */
11182 + atomic_t load_updates; /* nr of load updates done so far */
11183 + uint32_t load_last; /* last time load was calculated */
11184 + uint32_t load[3]; /* load averages 1,5,15 */
11186 + atomic_t total_forks; /* number of forks so far */
11188 + struct _vx_syslog syslog;
11191 +struct _vx_cvirt_pc {
11192 + struct _vx_usage_stat cpustat;
11196 +#ifdef CONFIG_VSERVER_DEBUG
11198 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11200 + printk("\t_vx_cvirt:\n");
11201 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11202 + atomic_read(&cvirt->nr_threads),
11203 + atomic_read(&cvirt->nr_running),
11204 + atomic_read(&cvirt->nr_uninterruptible),
11205 + atomic_read(&cvirt->nr_onhold));
11206 + /* add rest here */
11207 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11212 +#endif /* _VX_CVIRT_DEF_H */
11213 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/cvirt.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cvirt.h
11214 --- linux-2.6.27.14/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11215 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/cvirt.h 2008-10-13 14:54:20.000000000 +0200
11217 +#ifndef _VX_CVIRT_H
11218 +#define _VX_CVIRT_H
11225 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11230 +void vx_update_load(struct vx_info *);
11233 +int vx_do_syslog(int, char __user *, int);
11235 +#endif /* __KERNEL__ */
11236 +#endif /* _VX_CVIRT_H */
11237 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/debug_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/debug_cmd.h
11238 --- linux-2.6.27.14/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11239 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/debug_cmd.h 2008-10-13 14:54:20.000000000 +0200
11241 +#ifndef _VX_DEBUG_CMD_H
11242 +#define _VX_DEBUG_CMD_H
11245 +/* debug commands */
11247 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11249 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11250 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11252 +struct vcmd_read_history_v0 {
11255 + char __user *data;
11258 +struct vcmd_read_monitor_v0 {
11261 + char __user *data;
11267 +#ifdef CONFIG_COMPAT
11269 +#include <asm/compat.h>
11271 +struct vcmd_read_history_v0_x32 {
11274 + compat_uptr_t data_ptr;
11277 +struct vcmd_read_monitor_v0_x32 {
11280 + compat_uptr_t data_ptr;
11283 +#endif /* CONFIG_COMPAT */
11285 +extern int vc_dump_history(uint32_t);
11287 +extern int vc_read_history(uint32_t, void __user *);
11288 +extern int vc_read_monitor(uint32_t, void __user *);
11290 +#ifdef CONFIG_COMPAT
11292 +extern int vc_read_history_x32(uint32_t, void __user *);
11293 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11295 +#endif /* CONFIG_COMPAT */
11297 +#endif /* __KERNEL__ */
11298 +#endif /* _VX_DEBUG_CMD_H */
11299 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/debug.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/debug.h
11300 --- linux-2.6.27.14/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11301 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/debug.h 2008-10-13 14:54:20.000000000 +0200
11303 +#ifndef _VX_DEBUG_H
11304 +#define _VX_DEBUG_H
11307 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11308 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11309 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11311 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11312 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11313 +#define VXF_DEV "%p[%lu,%d:%d]"
11316 +#define vxd_path(p) \
11317 + ({ static char _buffer[PATH_MAX]; \
11318 + d_path(p, _buffer, sizeof(_buffer)); })
11320 +#define vxd_cond_path(n) \
11321 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11324 +#ifdef CONFIG_VSERVER_DEBUG
11326 +extern unsigned int vx_debug_switch;
11327 +extern unsigned int vx_debug_xid;
11328 +extern unsigned int vx_debug_nid;
11329 +extern unsigned int vx_debug_tag;
11330 +extern unsigned int vx_debug_net;
11331 +extern unsigned int vx_debug_limit;
11332 +extern unsigned int vx_debug_cres;
11333 +extern unsigned int vx_debug_dlim;
11334 +extern unsigned int vx_debug_quota;
11335 +extern unsigned int vx_debug_cvirt;
11336 +extern unsigned int vx_debug_space;
11337 +extern unsigned int vx_debug_misc;
11340 +#define VX_LOGLEVEL "vxD: "
11341 +#define VX_PROC_FMT "%p: "
11342 +#define VX_PROCESS current
11344 +#define vxdprintk(c, f, x...) \
11347 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11348 + VX_PROCESS , ##x); \
11351 +#define vxlprintk(c, f, x...) \
11354 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11357 +#define vxfprintk(c, f, x...) \
11360 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11366 +void dump_vx_info(struct vx_info *, int);
11367 +void dump_vx_info_inactive(int);
11369 +#else /* CONFIG_VSERVER_DEBUG */
11371 +#define vx_debug_switch 0
11372 +#define vx_debug_xid 0
11373 +#define vx_debug_nid 0
11374 +#define vx_debug_tag 0
11375 +#define vx_debug_net 0
11376 +#define vx_debug_limit 0
11377 +#define vx_debug_cres 0
11378 +#define vx_debug_dlim 0
11379 +#define vx_debug_cvirt 0
11381 +#define vxdprintk(x...) do { } while (0)
11382 +#define vxlprintk(x...) do { } while (0)
11383 +#define vxfprintk(x...) do { } while (0)
11385 +#endif /* CONFIG_VSERVER_DEBUG */
11388 +#ifdef CONFIG_VSERVER_WARN
11390 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11391 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
11392 +#define VX_WARN_XID "[xid #%u] "
11393 +#define VX_WARN_NID "[nid #%u] "
11394 +#define VX_WARN_TAG "[tag #%u] "
11396 +#define vxwprintk(c, f, x...) \
11399 + printk(VX_WARNLEVEL f "\n", ##x); \
11402 +#else /* CONFIG_VSERVER_WARN */
11404 +#define vxwprintk(x...) do { } while (0)
11406 +#endif /* CONFIG_VSERVER_WARN */
11408 +#define vxwprintk_task(c, f, x...) \
11409 + vxwprintk(c, VX_WARN_TASK f, \
11410 + current->comm, current->pid, \
11411 + current->xid, current->nid, current->tag, ##x)
11412 +#define vxwprintk_xid(c, f, x...) \
11413 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11414 +#define vxwprintk_nid(c, f, x...) \
11415 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11416 +#define vxwprintk_tag(c, f, x...) \
11417 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11419 +#ifdef CONFIG_VSERVER_DEBUG
11420 +#define vxd_assert_lock(l) assert_spin_locked(l)
11421 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11422 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11424 +#define vxd_assert_lock(l) do { } while (0)
11425 +#define vxd_assert(c, f, x...) do { } while (0)
11429 +#endif /* _VX_DEBUG_H */
11430 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/device_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/device_cmd.h
11431 --- linux-2.6.27.14/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11432 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/device_cmd.h 2008-10-13 14:54:20.000000000 +0200
11434 +#ifndef _VX_DEVICE_CMD_H
11435 +#define _VX_DEVICE_CMD_H
11438 +/* device vserver commands */
11440 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11441 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11443 +struct vcmd_set_mapping_v0 {
11444 + const char __user *device;
11445 + const char __user *target;
11452 +#ifdef CONFIG_COMPAT
11454 +#include <asm/compat.h>
11456 +struct vcmd_set_mapping_v0_x32 {
11457 + compat_uptr_t device_ptr;
11458 + compat_uptr_t target_ptr;
11462 +#endif /* CONFIG_COMPAT */
11464 +#include <linux/compiler.h>
11466 +extern int vc_set_mapping(struct vx_info *, void __user *);
11467 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11469 +#ifdef CONFIG_COMPAT
11471 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11472 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11474 +#endif /* CONFIG_COMPAT */
11476 +#endif /* __KERNEL__ */
11477 +#endif /* _VX_DEVICE_CMD_H */
11478 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/device_def.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/device_def.h
11479 --- linux-2.6.27.14/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11480 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/device_def.h 2008-10-13 14:54:20.000000000 +0200
11482 +#ifndef _VX_DEVICE_DEF_H
11483 +#define _VX_DEVICE_DEF_H
11485 +#include <linux/types.h>
11487 +struct vx_dmap_target {
11492 +struct _vx_device {
11493 +#ifdef CONFIG_VSERVER_DEVICE
11494 + struct vx_dmap_target targets[2];
11498 +#endif /* _VX_DEVICE_DEF_H */
11499 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/device.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/device.h
11500 --- linux-2.6.27.14/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11501 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/device.h 2008-10-13 14:54:20.000000000 +0200
11503 +#ifndef _VX_DEVICE_H
11504 +#define _VX_DEVICE_H
11507 +#define DATTR_CREATE 0x00000001
11508 +#define DATTR_OPEN 0x00000002
11510 +#define DATTR_REMAP 0x00000010
11512 +#define DATTR_MASK 0x00000013
11515 +#else /* _VX_DEVICE_H */
11516 +#warning duplicate inclusion
11517 +#endif /* _VX_DEVICE_H */
11518 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/dlimit_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/dlimit_cmd.h
11519 --- linux-2.6.27.14/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11520 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/dlimit_cmd.h 2008-10-13 14:54:20.000000000 +0200
11522 +#ifndef _VX_DLIMIT_CMD_H
11523 +#define _VX_DLIMIT_CMD_H
11526 +/* dlimit vserver commands */
11528 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11529 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11531 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11532 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11534 +struct vcmd_ctx_dlimit_base_v0 {
11535 + const char __user *name;
11539 +struct vcmd_ctx_dlimit_v0 {
11540 + const char __user *name;
11541 + uint32_t space_used; /* used space in kbytes */
11542 + uint32_t space_total; /* maximum space in kbytes */
11543 + uint32_t inodes_used; /* used inodes */
11544 + uint32_t inodes_total; /* maximum inodes */
11545 + uint32_t reserved; /* reserved for root in % */
11549 +#define CDLIM_UNSET ((uint32_t)0UL)
11550 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11551 +#define CDLIM_KEEP ((uint32_t)~1UL)
11555 +#ifdef CONFIG_COMPAT
11557 +#include <asm/compat.h>
11559 +struct vcmd_ctx_dlimit_base_v0_x32 {
11560 + compat_uptr_t name_ptr;
11564 +struct vcmd_ctx_dlimit_v0_x32 {
11565 + compat_uptr_t name_ptr;
11566 + uint32_t space_used; /* used space in kbytes */
11567 + uint32_t space_total; /* maximum space in kbytes */
11568 + uint32_t inodes_used; /* used inodes */
11569 + uint32_t inodes_total; /* maximum inodes */
11570 + uint32_t reserved; /* reserved for root in % */
11574 +#endif /* CONFIG_COMPAT */
11576 +#include <linux/compiler.h>
11578 +extern int vc_add_dlimit(uint32_t, void __user *);
11579 +extern int vc_rem_dlimit(uint32_t, void __user *);
11581 +extern int vc_set_dlimit(uint32_t, void __user *);
11582 +extern int vc_get_dlimit(uint32_t, void __user *);
11584 +#ifdef CONFIG_COMPAT
11586 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11587 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11589 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11590 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11592 +#endif /* CONFIG_COMPAT */
11594 +#endif /* __KERNEL__ */
11595 +#endif /* _VX_DLIMIT_CMD_H */
11596 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/dlimit.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/dlimit.h
11597 --- linux-2.6.27.14/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11598 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/dlimit.h 2008-10-13 14:54:20.000000000 +0200
11600 +#ifndef _VX_DLIMIT_H
11601 +#define _VX_DLIMIT_H
11603 +#include "switch.h"
11608 +/* keep in sync with CDLIM_INFINITY */
11610 +#define DLIM_INFINITY (~0ULL)
11612 +#include <linux/spinlock.h>
11613 +#include <linux/rcupdate.h>
11615 +struct super_block;
11618 + struct hlist_node dl_hlist; /* linked list of contexts */
11619 + struct rcu_head dl_rcu; /* the rcu head */
11620 + tag_t dl_tag; /* context tag */
11621 + atomic_t dl_usecnt; /* usage count */
11622 + atomic_t dl_refcnt; /* reference count */
11624 + struct super_block *dl_sb; /* associated superblock */
11626 + spinlock_t dl_lock; /* protect the values */
11628 + unsigned long long dl_space_used; /* used space in bytes */
11629 + unsigned long long dl_space_total; /* maximum space in bytes */
11630 + unsigned long dl_inodes_used; /* used inodes */
11631 + unsigned long dl_inodes_total; /* maximum inodes */
11633 + unsigned int dl_nrlmult; /* non root limit mult */
11638 +extern void rcu_free_dl_info(struct rcu_head *);
11639 +extern void unhash_dl_info(struct dl_info *);
11641 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11646 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11648 +typedef uint64_t dlsize_t;
11650 +#endif /* __KERNEL__ */
11651 +#else /* _VX_DLIMIT_H */
11652 +#warning duplicate inclusion
11653 +#endif /* _VX_DLIMIT_H */
11654 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/global.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/global.h
11655 --- linux-2.6.27.14/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11656 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/global.h 2008-10-13 14:54:20.000000000 +0200
11658 +#ifndef _VX_GLOBAL_H
11659 +#define _VX_GLOBAL_H
11662 +extern atomic_t vx_global_ctotal;
11663 +extern atomic_t vx_global_cactive;
11665 +extern atomic_t nx_global_ctotal;
11666 +extern atomic_t nx_global_cactive;
11668 +extern atomic_t vs_global_nsproxy;
11669 +extern atomic_t vs_global_fs;
11670 +extern atomic_t vs_global_mnt_ns;
11671 +extern atomic_t vs_global_uts_ns;
11672 +extern atomic_t vs_global_ipc_ns;
11673 +extern atomic_t vs_global_user_ns;
11674 +extern atomic_t vs_global_pid_ns;
11677 +#endif /* _VX_GLOBAL_H */
11678 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/history.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/history.h
11679 --- linux-2.6.27.14/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11680 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/history.h 2008-10-13 14:54:20.000000000 +0200
11682 +#ifndef _VX_HISTORY_H
11683 +#define _VX_HISTORY_H
11688 + VXH_THROW_OOPS = 1,
11692 + VXH_INIT_VX_INFO,
11695 + VXH_CLAIM_VX_INFO,
11696 + VXH_RELEASE_VX_INFO,
11697 + VXH_ALLOC_VX_INFO,
11698 + VXH_DEALLOC_VX_INFO,
11699 + VXH_HASH_VX_INFO,
11700 + VXH_UNHASH_VX_INFO,
11702 + VXH_LOOKUP_VX_INFO,
11703 + VXH_CREATE_VX_INFO,
11706 +struct _vxhe_vxi {
11707 + struct vx_info *ptr;
11713 +struct _vxhe_set_clr {
11717 +struct _vxhe_loc_lookup {
11721 +struct _vx_hist_entry {
11723 + unsigned short seq;
11724 + unsigned short type;
11725 + struct _vxhe_vxi vxi;
11727 + struct _vxhe_set_clr sc;
11728 + struct _vxhe_loc_lookup ll;
11732 +#ifdef CONFIG_VSERVER_HISTORY
11734 +extern unsigned volatile int vxh_active;
11736 +struct _vx_hist_entry *vxh_advance(void *loc);
11740 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11742 + entry->vxi.ptr = vxi;
11744 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11745 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11746 + entry->vxi.xid = vxi->vx_id;
11751 +#define __HERE__ current_text_addr()
11753 +#define __VXH_BODY(__type, __data, __here) \
11754 + struct _vx_hist_entry *entry; \
11756 + preempt_disable(); \
11757 + entry = vxh_advance(__here); \
11759 + entry->type = __type; \
11760 + preempt_enable();
11763 + /* pass vxi only */
11765 +#define __VXH_SMPL \
11766 + __vxh_copy_vxi(entry, vxi)
11769 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11771 + __VXH_BODY(__type, __VXH_SMPL, __here)
11774 + /* pass vxi and data (void *) */
11776 +#define __VXH_DATA \
11777 + __vxh_copy_vxi(entry, vxi); \
11778 + entry->sc.data = data
11781 +void __vxh_data(struct vx_info *vxi, void *data,
11782 + int __type, void *__here)
11784 + __VXH_BODY(__type, __VXH_DATA, __here)
11787 + /* pass vxi and arg (long) */
11789 +#define __VXH_LONG \
11790 + __vxh_copy_vxi(entry, vxi); \
11791 + entry->ll.arg = arg
11794 +void __vxh_long(struct vx_info *vxi, long arg,
11795 + int __type, void *__here)
11797 + __VXH_BODY(__type, __VXH_LONG, __here)
11802 +void __vxh_throw_oops(void *__here)
11804 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11805 + /* prevent further acquisition */
11810 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11812 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11813 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11815 +#define __vxh_init_vx_info(v, d, h) \
11816 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11817 +#define __vxh_set_vx_info(v, d, h) \
11818 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11819 +#define __vxh_clr_vx_info(v, d, h) \
11820 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11822 +#define __vxh_claim_vx_info(v, d, h) \
11823 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11824 +#define __vxh_release_vx_info(v, d, h) \
11825 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11827 +#define vxh_alloc_vx_info(v) \
11828 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11829 +#define vxh_dealloc_vx_info(v) \
11830 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11832 +#define vxh_hash_vx_info(v) \
11833 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11834 +#define vxh_unhash_vx_info(v) \
11835 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11837 +#define vxh_loc_vx_info(v, l) \
11838 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11839 +#define vxh_lookup_vx_info(v, l) \
11840 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11841 +#define vxh_create_vx_info(v, l) \
11842 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11844 +extern void vxh_dump_history(void);
11847 +#else /* CONFIG_VSERVER_HISTORY */
11849 +#define __HERE__ 0
11851 +#define vxh_throw_oops() do { } while (0)
11853 +#define __vxh_get_vx_info(v, h) do { } while (0)
11854 +#define __vxh_put_vx_info(v, h) do { } while (0)
11856 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11857 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11858 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11860 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11861 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11863 +#define vxh_alloc_vx_info(v) do { } while (0)
11864 +#define vxh_dealloc_vx_info(v) do { } while (0)
11866 +#define vxh_hash_vx_info(v) do { } while (0)
11867 +#define vxh_unhash_vx_info(v) do { } while (0)
11869 +#define vxh_loc_vx_info(v, l) do { } while (0)
11870 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11871 +#define vxh_create_vx_info(v, l) do { } while (0)
11873 +#define vxh_dump_history() do { } while (0)
11876 +#endif /* CONFIG_VSERVER_HISTORY */
11878 +#endif /* _VX_HISTORY_H */
11879 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/inode_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/inode_cmd.h
11880 --- linux-2.6.27.14/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11881 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/inode_cmd.h 2008-10-13 14:54:20.000000000 +0200
11883 +#ifndef _VX_INODE_CMD_H
11884 +#define _VX_INODE_CMD_H
11887 +/* inode vserver commands */
11889 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11890 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11892 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11893 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11895 +struct vcmd_ctx_iattr_v1 {
11896 + const char __user *name;
11902 +struct vcmd_ctx_fiattr_v0 {
11912 +#ifdef CONFIG_COMPAT
11914 +#include <asm/compat.h>
11916 +struct vcmd_ctx_iattr_v1_x32 {
11917 + compat_uptr_t name_ptr;
11923 +#endif /* CONFIG_COMPAT */
11925 +#include <linux/compiler.h>
11927 +extern int vc_get_iattr(void __user *);
11928 +extern int vc_set_iattr(void __user *);
11930 +extern int vc_fget_iattr(uint32_t, void __user *);
11931 +extern int vc_fset_iattr(uint32_t, void __user *);
11933 +#ifdef CONFIG_COMPAT
11935 +extern int vc_get_iattr_x32(void __user *);
11936 +extern int vc_set_iattr_x32(void __user *);
11938 +#endif /* CONFIG_COMPAT */
11940 +#endif /* __KERNEL__ */
11941 +#endif /* _VX_INODE_CMD_H */
11942 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/inode.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/inode.h
11943 --- linux-2.6.27.14/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11944 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/inode.h 2008-10-13 14:54:20.000000000 +0200
11946 +#ifndef _VX_INODE_H
11947 +#define _VX_INODE_H
11950 +#define IATTR_TAG 0x01000000
11952 +#define IATTR_ADMIN 0x00000001
11953 +#define IATTR_WATCH 0x00000002
11954 +#define IATTR_HIDE 0x00000004
11955 +#define IATTR_FLAGS 0x00000007
11957 +#define IATTR_BARRIER 0x00010000
11958 +#define IATTR_IXUNLINK 0x00020000
11959 +#define IATTR_IMMUTABLE 0x00040000
11964 +#ifdef CONFIG_VSERVER_PROC_SECURE
11965 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11966 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11968 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11969 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11972 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11974 +#endif /* __KERNEL__ */
11976 +/* inode ioctls */
11978 +#define FIOC_GETXFLG _IOR('x', 5, long)
11979 +#define FIOC_SETXFLG _IOW('x', 6, long)
11981 +#else /* _VX_INODE_H */
11982 +#warning duplicate inclusion
11983 +#endif /* _VX_INODE_H */
11984 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/Kbuild linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/Kbuild
11985 --- linux-2.6.27.14/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11986 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/Kbuild 2008-10-13 14:54:20.000000000 +0200
11989 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11990 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11991 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11992 + debug_cmd.h device_cmd.h
11994 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11996 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/limit_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit_cmd.h
11997 --- linux-2.6.27.14/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11998 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit_cmd.h 2009-01-04 02:28:31.000000000 +0100
12000 +#ifndef _VX_LIMIT_CMD_H
12001 +#define _VX_LIMIT_CMD_H
12004 +/* rlimit vserver commands */
12006 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12007 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12008 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12009 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12011 +struct vcmd_ctx_rlimit_v0 {
12013 + uint64_t minimum;
12014 + uint64_t softlimit;
12015 + uint64_t maximum;
12018 +struct vcmd_ctx_rlimit_mask_v0 {
12019 + uint32_t minimum;
12020 + uint32_t softlimit;
12021 + uint32_t maximum;
12024 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12026 +struct vcmd_rlimit_stat_v0 {
12030 + uint64_t minimum;
12031 + uint64_t maximum;
12034 +#define CRLIM_UNSET (0ULL)
12035 +#define CRLIM_INFINITY (~0ULL)
12036 +#define CRLIM_KEEP (~1ULL)
12040 +#ifdef CONFIG_IA32_EMULATION
12042 +struct vcmd_ctx_rlimit_v0_x32 {
12044 + uint64_t minimum;
12045 + uint64_t softlimit;
12046 + uint64_t maximum;
12047 +} __attribute__ ((packed));
12049 +#endif /* CONFIG_IA32_EMULATION */
12051 +#include <linux/compiler.h>
12053 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12054 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12055 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12056 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12058 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12060 +#ifdef CONFIG_IA32_EMULATION
12062 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12063 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12065 +#endif /* CONFIG_IA32_EMULATION */
12067 +#endif /* __KERNEL__ */
12068 +#endif /* _VX_LIMIT_CMD_H */
12069 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/limit_def.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit_def.h
12070 --- linux-2.6.27.14/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12071 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit_def.h 2008-10-13 14:54:20.000000000 +0200
12073 +#ifndef _VX_LIMIT_DEF_H
12074 +#define _VX_LIMIT_DEF_H
12076 +#include <asm/atomic.h>
12077 +#include <asm/resource.h>
12079 +#include "limit.h"
12082 +struct _vx_res_limit {
12083 + rlim_t soft; /* Context soft limit */
12084 + rlim_t hard; /* Context hard limit */
12086 + rlim_atomic_t rcur; /* Current value */
12087 + rlim_t rmin; /* Context minimum */
12088 + rlim_t rmax; /* Context maximum */
12090 + atomic_t lhit; /* Limit hits */
12093 +/* context sub struct */
12095 +struct _vx_limit {
12096 + struct _vx_res_limit res[NUM_LIMITS];
12099 +#ifdef CONFIG_VSERVER_DEBUG
12101 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12105 + printk("\t_vx_limit:");
12106 + for (i = 0; i < NUM_LIMITS; i++) {
12107 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12108 + i, (unsigned long)__rlim_get(limit, i),
12109 + (unsigned long)__rlim_rmin(limit, i),
12110 + (unsigned long)__rlim_rmax(limit, i),
12111 + (long)__rlim_soft(limit, i),
12112 + (long)__rlim_hard(limit, i),
12113 + atomic_read(&__rlim_lhit(limit, i)));
12119 +#endif /* _VX_LIMIT_DEF_H */
12120 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/limit.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit.h
12121 --- linux-2.6.27.14/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12122 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit.h 2008-10-13 14:54:20.000000000 +0200
12124 +#ifndef _VX_LIMIT_H
12125 +#define _VX_LIMIT_H
12127 +#define VLIMIT_NSOCK 16
12128 +#define VLIMIT_OPENFD 17
12129 +#define VLIMIT_ANON 18
12130 +#define VLIMIT_SHMEM 19
12131 +#define VLIMIT_SEMARY 20
12132 +#define VLIMIT_NSEMS 21
12133 +#define VLIMIT_DENTRY 22
12134 +#define VLIMIT_MAPPED 23
12139 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12141 +/* keep in sync with CRLIM_INFINITY */
12143 +#define VLIM_INFINITY (~0ULL)
12145 +#include <asm/atomic.h>
12146 +#include <asm/resource.h>
12148 +#ifndef RLIM_INFINITY
12149 +#warning RLIM_INFINITY is undefined
12152 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12154 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12155 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12157 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12158 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12159 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12161 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12162 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12164 +typedef atomic_long_t rlim_atomic_t;
12165 +typedef unsigned long rlim_t;
12167 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12168 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12169 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12170 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12171 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12172 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12175 +#if (RLIM_INFINITY == VLIM_INFINITY)
12176 +#define VX_VLIM(r) ((long long)(long)(r))
12177 +#define VX_RLIM(v) ((rlim_t)(v))
12179 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12180 + ? VLIM_INFINITY : (long long)(r))
12181 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12182 + ? RLIM_INFINITY : (rlim_t)(v))
12187 +void vx_vsi_meminfo(struct sysinfo *);
12188 +void vx_vsi_swapinfo(struct sysinfo *);
12190 +#define NUM_LIMITS 24
12192 +#endif /* __KERNEL__ */
12193 +#endif /* _VX_LIMIT_H */
12194 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/limit_int.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit_int.h
12195 --- linux-2.6.27.14/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12196 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/limit_int.h 2008-10-13 14:54:20.000000000 +0200
12198 +#ifndef _VX_LIMIT_INT_H
12199 +#define _VX_LIMIT_INT_H
12201 +#include "context.h"
12205 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12206 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12208 +extern const char *vlimit_name[NUM_LIMITS];
12210 +static inline void __vx_acc_cres(struct vx_info *vxi,
12211 + int res, int dir, void *_data, char *_file, int _line)
12213 + if (VXD_RCRES_COND(res))
12214 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12215 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12216 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12217 + (dir > 0) ? "++" : "--", _data, _file, _line);
12222 + __rlim_inc(&vxi->limit, res);
12224 + __rlim_dec(&vxi->limit, res);
12227 +static inline void __vx_add_cres(struct vx_info *vxi,
12228 + int res, int amount, void *_data, char *_file, int _line)
12230 + if (VXD_RCRES_COND(res))
12231 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12232 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12233 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12234 + amount, _data, _file, _line);
12239 + __rlim_add(&vxi->limit, res, amount);
12243 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12245 + int cond = (value > __rlim_rmax(limit, res));
12248 + __rlim_rmax(limit, res) = value;
12253 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12255 + int cond = (value < __rlim_rmin(limit, res));
12258 + __rlim_rmin(limit, res) = value;
12263 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12265 + if (!__vx_cres_adjust_max(limit, res, value))
12266 + __vx_cres_adjust_min(limit, res, value);
12271 + +1 ... no limit hit
12272 + -1 ... over soft limit
12273 + 0 ... over hard limit */
12275 +static inline int __vx_cres_avail(struct vx_info *vxi,
12276 + int res, int num, char *_file, int _line)
12278 + struct _vx_limit *limit;
12281 + if (VXD_RLIMIT_COND(res))
12282 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12283 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12284 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12285 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12286 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12287 + num, _file, _line);
12291 + limit = &vxi->limit;
12292 + value = __rlim_get(limit, res);
12294 + if (!__vx_cres_adjust_max(limit, res, value))
12295 + __vx_cres_adjust_min(limit, res, value);
12300 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12302 + if (value + num <= __rlim_soft(limit, res))
12305 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12307 + if (value + num <= __rlim_hard(limit, res))
12310 + __rlim_hit(limit, res);
12315 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12318 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12320 + rlim_t value, sum = 0;
12323 + while ((res = *array++)) {
12324 + value = __rlim_get(limit, res);
12325 + __vx_cres_fixup(limit, res, value);
12332 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12334 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12335 + int res = *array;
12337 + if (value == __rlim_get(limit, res))
12340 + __rlim_set(limit, res, value);
12341 + /* now adjust min/max */
12342 + if (!__vx_cres_adjust_max(limit, res, value))
12343 + __vx_cres_adjust_min(limit, res, value);
12348 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12349 + const int *array, int num, char *_file, int _line)
12351 + struct _vx_limit *limit;
12352 + rlim_t value = 0;
12360 + limit = &vxi->limit;
12362 + value = __vx_cres_array_sum(limit, array + 1);
12364 + __rlim_set(limit, res, value);
12365 + __vx_cres_fixup(limit, res, value);
12367 + return __vx_cres_avail(vxi, res, num, _file, _line);
12371 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12376 + /* complex resources first */
12377 + if ((id < 0) || (id == RLIMIT_RSS))
12378 + __vx_cres_array_fixup(limit, VLA_RSS);
12380 + for (res = 0; res < NUM_LIMITS; res++) {
12381 + if ((id > 0) && (res != id))
12384 + value = __rlim_get(limit, res);
12385 + __vx_cres_fixup(limit, res, value);
12387 + /* not supposed to happen, maybe warn? */
12388 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12389 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12394 +#endif /* __KERNEL__ */
12395 +#endif /* _VX_LIMIT_INT_H */
12396 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/monitor.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/monitor.h
12397 --- linux-2.6.27.14/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12398 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/monitor.h 2008-10-13 14:54:20.000000000 +0200
12400 +#ifndef _VX_MONITOR_H
12401 +#define _VX_MONITOR_H
12403 +#include <linux/types.h>
12410 + VXM_UPDATE = 0x20,
12414 + VXM_RQINFO_1 = 0x24,
12417 + VXM_ACTIVATE = 0x40,
12424 + VXM_MIGRATE = 0x48,
12427 + /* all other bits are flags */
12428 + VXM_SCHED = 0x80,
12431 +struct _vxm_update_1 {
12432 + uint32_t tokens_max;
12433 + uint32_t fill_rate;
12434 + uint32_t interval;
12437 +struct _vxm_update_2 {
12438 + uint32_t tokens_min;
12439 + uint32_t fill_rate;
12440 + uint32_t interval;
12443 +struct _vxm_rqinfo_1 {
12444 + uint16_t running;
12448 + uint32_t idle_tokens;
12451 +struct _vxm_rqinfo_2 {
12452 + uint32_t norm_time;
12453 + uint32_t idle_time;
12454 + uint32_t idle_skip;
12457 +struct _vxm_sched {
12459 + uint32_t norm_time;
12460 + uint32_t idle_time;
12463 +struct _vxm_task {
12468 +struct _vxm_event {
12477 + struct _vxm_task tsk;
12481 +struct _vx_mon_entry {
12485 + struct _vxm_event ev;
12486 + struct _vxm_sched sd;
12487 + struct _vxm_update_1 u1;
12488 + struct _vxm_update_2 u2;
12489 + struct _vxm_rqinfo_1 q1;
12490 + struct _vxm_rqinfo_2 q2;
12495 +#endif /* _VX_MONITOR_H */
12496 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/network_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/network_cmd.h
12497 --- linux-2.6.27.14/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12498 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/network_cmd.h 2008-10-13 14:54:20.000000000 +0200
12500 +#ifndef _VX_NETWORK_CMD_H
12501 +#define _VX_NETWORK_CMD_H
12504 +/* vinfo commands */
12506 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12509 +extern int vc_task_nid(uint32_t);
12511 +#endif /* __KERNEL__ */
12513 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12515 +struct vcmd_nx_info_v0 {
12517 + /* more to come */
12521 +extern int vc_nx_info(struct nx_info *, void __user *);
12523 +#endif /* __KERNEL__ */
12525 +#include <linux/in.h>
12526 +#include <linux/in6.h>
12528 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12529 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12531 +struct vcmd_net_create {
12532 + uint64_t flagword;
12535 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12537 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12538 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12540 +struct vcmd_net_addr_v0 {
12543 + struct in_addr ip[4];
12544 + struct in_addr mask[4];
12547 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12548 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12550 +struct vcmd_net_addr_ipv4_v1 {
12553 + struct in_addr ip;
12554 + struct in_addr mask;
12557 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12558 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12560 +struct vcmd_net_addr_ipv6_v1 {
12564 + struct in6_addr ip;
12565 + struct in6_addr mask;
12568 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12569 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12571 +struct vcmd_match_ipv4_v0 {
12576 + struct in_addr ip;
12577 + struct in_addr ip2;
12578 + struct in_addr mask;
12581 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12582 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12584 +struct vcmd_match_ipv6_v0 {
12589 + struct in6_addr ip;
12590 + struct in6_addr ip2;
12591 + struct in6_addr mask;
12596 +extern int vc_net_create(uint32_t, void __user *);
12597 +extern int vc_net_migrate(struct nx_info *, void __user *);
12599 +extern int vc_net_add(struct nx_info *, void __user *);
12600 +extern int vc_net_remove(struct nx_info *, void __user *);
12602 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12603 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12605 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12606 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12608 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12609 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12611 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12612 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12614 +#endif /* __KERNEL__ */
12617 +/* flag commands */
12619 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12620 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12622 +struct vcmd_net_flags_v0 {
12623 + uint64_t flagword;
12628 +extern int vc_get_nflags(struct nx_info *, void __user *);
12629 +extern int vc_set_nflags(struct nx_info *, void __user *);
12631 +#endif /* __KERNEL__ */
12634 +/* network caps commands */
12636 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12637 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12639 +struct vcmd_net_caps_v0 {
12645 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12646 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12648 +#endif /* __KERNEL__ */
12649 +#endif /* _VX_CONTEXT_CMD_H */
12650 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/network.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/network.h
12651 --- linux-2.6.27.14/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12652 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/network.h 2008-10-13 14:54:20.000000000 +0200
12654 +#ifndef _VX_NETWORK_H
12655 +#define _VX_NETWORK_H
12657 +#include <linux/types.h>
12660 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12663 +/* network flags */
12665 +#define NXF_INFO_PRIVATE 0x00000008
12667 +#define NXF_SINGLE_IP 0x00000100
12668 +#define NXF_LBACK_REMAP 0x00000200
12669 +#define NXF_LBACK_ALLOW 0x00000400
12671 +#define NXF_HIDE_NETIF 0x02000000
12672 +#define NXF_HIDE_LBACK 0x04000000
12674 +#define NXF_STATE_SETUP (1ULL << 32)
12675 +#define NXF_STATE_ADMIN (1ULL << 34)
12677 +#define NXF_SC_HELPER (1ULL << 36)
12678 +#define NXF_PERSISTENT (1ULL << 38)
12680 +#define NXF_ONE_TIME (0x0005ULL << 32)
12683 +#define NXF_INIT_SET (__nxf_init_set())
12685 +static inline uint64_t __nxf_init_set(void) {
12686 + return NXF_STATE_ADMIN
12687 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12688 + | NXF_LBACK_REMAP
12691 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12694 + | NXF_HIDE_NETIF;
12698 +/* network caps */
12700 +#define NXC_TUN_CREATE 0x00000001
12702 +#define NXC_RAW_ICMP 0x00000100
12705 +/* address types */
12707 +#define NXA_TYPE_IPV4 0x0001
12708 +#define NXA_TYPE_IPV6 0x0002
12710 +#define NXA_TYPE_NONE 0x0000
12711 +#define NXA_TYPE_ANY 0x00FF
12713 +#define NXA_TYPE_ADDR 0x0010
12714 +#define NXA_TYPE_MASK 0x0020
12715 +#define NXA_TYPE_RANGE 0x0040
12717 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12719 +#define NXA_MOD_BCAST 0x0100
12720 +#define NXA_MOD_LBACK 0x0200
12722 +#define NXA_LOOPBACK 0x1000
12724 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12725 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12729 +#include <linux/list.h>
12730 +#include <linux/spinlock.h>
12731 +#include <linux/rcupdate.h>
12732 +#include <linux/in.h>
12733 +#include <linux/in6.h>
12734 +#include <asm/atomic.h>
12736 +struct nx_addr_v4 {
12737 + struct nx_addr_v4 *next;
12738 + struct in_addr ip[2];
12739 + struct in_addr mask;
12744 +struct nx_addr_v6 {
12745 + struct nx_addr_v6 *next;
12746 + struct in6_addr ip;
12747 + struct in6_addr mask;
12754 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12755 + nid_t nx_id; /* vnet id */
12756 + atomic_t nx_usecnt; /* usage count */
12757 + atomic_t nx_tasks; /* tasks count */
12758 + int nx_state; /* context state */
12760 + uint64_t nx_flags; /* network flag word */
12761 + uint64_t nx_ncaps; /* network capabilities */
12763 + struct in_addr v4_lback; /* Loopback address */
12764 + struct in_addr v4_bcast; /* Broadcast address */
12765 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12766 +#ifdef CONFIG_IPV6
12767 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12769 + char nx_name[65]; /* network context name */
12773 +/* status flags */
12775 +#define NXS_HASHED 0x0001
12776 +#define NXS_SHUTDOWN 0x0100
12777 +#define NXS_RELEASED 0x8000
12779 +extern struct nx_info *lookup_nx_info(int);
12781 +extern int get_nid_list(int, unsigned int *, int);
12782 +extern int nid_is_hashed(nid_t);
12784 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12786 +extern long vs_net_change(struct nx_info *, unsigned int);
12791 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12792 +#ifdef CONFIG_IPV6
12793 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12795 +#define NX_IPV6(n) (0)
12798 +#endif /* __KERNEL__ */
12799 +#endif /* _VX_NETWORK_H */
12800 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/percpu.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/percpu.h
12801 --- linux-2.6.27.14/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12802 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/percpu.h 2008-10-13 14:54:20.000000000 +0200
12804 +#ifndef _VX_PERCPU_H
12805 +#define _VX_PERCPU_H
12807 +#include "cvirt_def.h"
12808 +#include "sched_def.h"
12810 +struct _vx_percpu {
12811 + struct _vx_cvirt_pc cvirt;
12812 + struct _vx_sched_pc sched;
12815 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12817 +#endif /* _VX_PERCPU_H */
12818 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/pid.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/pid.h
12819 --- linux-2.6.27.14/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12820 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/pid.h 2008-10-13 14:54:20.000000000 +0200
12822 +#ifndef _VSERVER_PID_H
12823 +#define _VSERVER_PID_H
12825 +/* pid faking stuff */
12827 +#define vx_info_map_pid(v, p) \
12828 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12829 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12830 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
12831 +#define vx_map_tgid(p) vx_map_pid(p)
12833 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12834 + const char *func, const char *file, int line)
12836 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12837 + vxfprintk(VXD_CBIT(cvirt, 2),
12838 + "vx_map_tgid: %p/%llx: %d -> %d",
12839 + vxi, (long long)vxi->vx_flags, pid,
12840 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12841 + func, file, line);
12844 + if (pid == vxi->vx_initpid)
12850 +#define vx_info_rmap_pid(v, p) \
12851 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12852 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
12853 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12855 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12856 + const char *func, const char *file, int line)
12858 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12859 + vxfprintk(VXD_CBIT(cvirt, 2),
12860 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12861 + vxi, (long long)vxi->vx_flags, pid,
12862 + (pid == 1) ? vxi->vx_initpid : pid,
12863 + func, file, line);
12864 + if ((pid == 1) && vxi->vx_initpid)
12865 + return vxi->vx_initpid;
12866 + if (pid == vxi->vx_initpid)
12873 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/sched_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/sched_cmd.h
12874 --- linux-2.6.27.14/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12875 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/sched_cmd.h 2008-10-13 14:54:20.000000000 +0200
12877 +#ifndef _VX_SCHED_CMD_H
12878 +#define _VX_SCHED_CMD_H
12881 +/* sched vserver commands */
12883 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
12884 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
12885 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
12887 +struct vcmd_set_sched_v2 {
12888 + int32_t fill_rate;
12889 + int32_t interval;
12891 + int32_t tokens_min;
12892 + int32_t tokens_max;
12893 + uint64_t cpu_mask;
12896 +struct vcmd_set_sched_v3 {
12897 + uint32_t set_mask;
12898 + int32_t fill_rate;
12899 + int32_t interval;
12901 + int32_t tokens_min;
12902 + int32_t tokens_max;
12903 + int32_t priority_bias;
12906 +struct vcmd_set_sched_v4 {
12907 + uint32_t set_mask;
12908 + int32_t fill_rate;
12909 + int32_t interval;
12911 + int32_t tokens_min;
12912 + int32_t tokens_max;
12913 + int32_t prio_bias;
12915 + int32_t bucket_id;
12918 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
12919 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
12921 +struct vcmd_sched_v5 {
12924 + int32_t bucket_id;
12925 + int32_t fill_rate[2];
12926 + int32_t interval[2];
12928 + int32_t tokens_min;
12929 + int32_t tokens_max;
12930 + int32_t prio_bias;
12933 +#define VXSM_FILL_RATE 0x0001
12934 +#define VXSM_INTERVAL 0x0002
12935 +#define VXSM_FILL_RATE2 0x0004
12936 +#define VXSM_INTERVAL2 0x0008
12937 +#define VXSM_TOKENS 0x0010
12938 +#define VXSM_TOKENS_MIN 0x0020
12939 +#define VXSM_TOKENS_MAX 0x0040
12940 +#define VXSM_PRIO_BIAS 0x0100
12942 +#define VXSM_IDLE_TIME 0x0200
12943 +#define VXSM_FORCE 0x0400
12945 +#define VXSM_V3_MASK 0x0173
12946 +#define VXSM_SET_MASK 0x01FF
12948 +#define VXSM_CPU_ID 0x1000
12949 +#define VXSM_BUCKET_ID 0x2000
12951 +#define VXSM_MSEC 0x4000
12953 +#define SCHED_KEEP (-2) /* only for v2 */
12957 +#include <linux/compiler.h>
12959 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
12960 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
12961 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
12962 +extern int vc_set_sched(struct vx_info *, void __user *);
12963 +extern int vc_get_sched(struct vx_info *, void __user *);
12965 +#endif /* __KERNEL__ */
12967 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
12969 +struct vcmd_sched_info {
12971 + int32_t bucket_id;
12972 + uint64_t user_msec;
12973 + uint64_t sys_msec;
12974 + uint64_t hold_msec;
12975 + uint32_t token_usec;
12976 + int32_t vavavoom;
12981 +extern int vc_sched_info(struct vx_info *, void __user *);
12983 +#endif /* __KERNEL__ */
12984 +#endif /* _VX_SCHED_CMD_H */
12985 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/sched_def.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/sched_def.h
12986 --- linux-2.6.27.14/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12987 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/sched_def.h 2008-10-13 14:54:20.000000000 +0200
12989 +#ifndef _VX_SCHED_DEF_H
12990 +#define _VX_SCHED_DEF_H
12992 +#include <linux/spinlock.h>
12993 +#include <linux/jiffies.h>
12994 +#include <linux/cpumask.h>
12995 +#include <asm/atomic.h>
12996 +#include <asm/param.h>
12999 +/* context sub struct */
13001 +struct _vx_sched {
13002 + spinlock_t tokens_lock; /* lock for token bucket */
13004 + int tokens; /* number of CPU tokens */
13005 + int fill_rate[2]; /* Fill rate: add X tokens... */
13006 + int interval[2]; /* Divisor: per Y jiffies */
13007 + int tokens_min; /* Limit: minimum for unhold */
13008 + int tokens_max; /* Limit: no more than N tokens */
13010 + int prio_bias; /* bias offset for priority */
13012 + unsigned update_mask; /* which features should be updated */
13013 + cpumask_t update; /* CPUs which should update */
13016 +struct _vx_sched_pc {
13017 + int tokens; /* number of CPU tokens */
13018 + int flags; /* bucket flags */
13020 + int fill_rate[2]; /* Fill rate: add X tokens... */
13021 + int interval[2]; /* Divisor: per Y jiffies */
13022 + int tokens_min; /* Limit: minimum for unhold */
13023 + int tokens_max; /* Limit: no more than N tokens */
13025 + int prio_bias; /* bias offset for priority */
13026 + int vavavoom; /* last calculated vavavoom */
13028 + unsigned long norm_time; /* last time accounted */
13029 + unsigned long idle_time; /* non linear time for fair sched */
13030 + unsigned long token_time; /* token time for accounting */
13031 + unsigned long onhold; /* jiffies when put on hold */
13033 + uint64_t user_ticks; /* token tick events */
13034 + uint64_t sys_ticks; /* token tick events */
13035 + uint64_t hold_ticks; /* token ticks paused */
13039 +#define VXSF_ONHOLD 0x0001
13040 +#define VXSF_IDLE_TIME 0x0100
13042 +#ifdef CONFIG_VSERVER_DEBUG
13044 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13046 + printk("\t_vx_sched:\n");
13047 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
13048 + sched->fill_rate[0], sched->interval[0],
13049 + sched->fill_rate[1], sched->interval[1],
13050 + sched->tokens_min, sched->tokens_max);
13051 + printk("\t priority = %4d\n", sched->prio_bias);
13056 +#endif /* _VX_SCHED_DEF_H */
13057 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/sched.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/sched.h
13058 --- linux-2.6.27.14/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13059 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/sched.h 2008-10-13 14:54:20.000000000 +0200
13061 +#ifndef _VX_SCHED_H
13062 +#define _VX_SCHED_H
13069 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13074 +void vx_update_load(struct vx_info *);
13077 +int vx_tokens_recalc(struct _vx_sched_pc *,
13078 + unsigned long *, unsigned long *, int [2]);
13080 +void vx_update_sched_param(struct _vx_sched *sched,
13081 + struct _vx_sched_pc *sched_pc);
13083 +#endif /* __KERNEL__ */
13084 +#else /* _VX_SCHED_H */
13085 +#warning duplicate inclusion
13086 +#endif /* _VX_SCHED_H */
13087 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/signal_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/signal_cmd.h
13088 --- linux-2.6.27.14/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13089 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/signal_cmd.h 2008-10-13 14:54:20.000000000 +0200
13091 +#ifndef _VX_SIGNAL_CMD_H
13092 +#define _VX_SIGNAL_CMD_H
13095 +/* signalling vserver commands */
13097 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13098 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13100 +struct vcmd_ctx_kill_v0 {
13105 +struct vcmd_wait_exit_v0 {
13106 + int32_t reboot_cmd;
13107 + int32_t exit_code;
13112 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13113 +extern int vc_wait_exit(struct vx_info *, void __user *);
13115 +#endif /* __KERNEL__ */
13117 +/* process alteration commands */
13119 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13120 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13122 +struct vcmd_pflags_v0 {
13123 + uint32_t flagword;
13129 +extern int vc_get_pflags(uint32_t pid, void __user *);
13130 +extern int vc_set_pflags(uint32_t pid, void __user *);
13132 +#endif /* __KERNEL__ */
13133 +#endif /* _VX_SIGNAL_CMD_H */
13134 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/signal.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/signal.h
13135 --- linux-2.6.27.14/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13136 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/signal.h 2008-10-13 14:54:20.000000000 +0200
13138 +#ifndef _VX_SIGNAL_H
13139 +#define _VX_SIGNAL_H
13146 +int vx_info_kill(struct vx_info *, int, int);
13148 +#endif /* __KERNEL__ */
13149 +#else /* _VX_SIGNAL_H */
13150 +#warning duplicate inclusion
13151 +#endif /* _VX_SIGNAL_H */
13152 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/space_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/space_cmd.h
13153 --- linux-2.6.27.14/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13154 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/space_cmd.h 2008-10-31 03:49:36.000000000 +0100
13156 +#ifndef _VX_SPACE_CMD_H
13157 +#define _VX_SPACE_CMD_H
13160 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13161 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13162 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13164 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13165 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13166 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13168 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13170 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13171 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13174 +struct vcmd_space_mask_v1 {
13178 +struct vcmd_space_mask_v2 {
13186 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13187 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13188 +extern int vc_enter_space(struct vx_info *, void __user *);
13189 +extern int vc_set_space(struct vx_info *, void __user *);
13190 +extern int vc_get_space_mask(void __user *, int);
13192 +#endif /* __KERNEL__ */
13193 +#endif /* _VX_SPACE_CMD_H */
13194 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/space.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/space.h
13195 --- linux-2.6.27.14/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13196 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/space.h 2008-10-31 04:02:02.000000000 +0100
13198 +#ifndef _VX_SPACE_H
13199 +#define _VX_SPACE_H
13201 +#include <linux/types.h>
13205 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13207 +#else /* _VX_SPACE_H */
13208 +#warning duplicate inclusion
13209 +#endif /* _VX_SPACE_H */
13210 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/switch.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/switch.h
13211 --- linux-2.6.27.14/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13212 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/switch.h 2008-11-22 20:32:00.000000000 +0100
13214 +#ifndef _VX_SWITCH_H
13215 +#define _VX_SWITCH_H
13217 +#include <linux/types.h>
13220 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13221 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13222 +#define VC_VERSION(c) ((c) & 0xFFF)
13224 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13225 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13229 + Syscall Matrix V2.8
13231 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13232 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13233 + |INFO |SETUP | |MOVE | | | | | |
13234 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13235 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13236 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13237 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13238 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13239 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13240 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13241 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13242 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13243 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13244 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13245 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13246 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13247 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13248 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13249 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13250 + OTHER |VSTAT | | | | | | |VINFO | |
13251 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13252 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13253 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13254 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13255 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13256 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13257 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13258 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13262 +#define VC_CAT_VERSION 0
13264 +#define VC_CAT_VSETUP 1
13265 +#define VC_CAT_VHOST 2
13267 +#define VC_CAT_DEVICE 6
13269 +#define VC_CAT_VPROC 9
13270 +#define VC_CAT_PROCALT 10
13271 +#define VC_CAT_PROCMIG 11
13272 +#define VC_CAT_PROCTRL 12
13274 +#define VC_CAT_SCHED 14
13275 +#define VC_CAT_MEMCTRL 20
13277 +#define VC_CAT_VNET 25
13278 +#define VC_CAT_NETALT 26
13279 +#define VC_CAT_NETMIG 27
13280 +#define VC_CAT_NETCTRL 28
13282 +#define VC_CAT_TAGMIG 35
13283 +#define VC_CAT_DLIMIT 36
13284 +#define VC_CAT_INODE 38
13286 +#define VC_CAT_VSTAT 40
13287 +#define VC_CAT_VINFO 46
13288 +#define VC_CAT_EVENT 48
13290 +#define VC_CAT_FLAGS 52
13291 +#define VC_CAT_VSPACE 54
13292 +#define VC_CAT_DEBUG 56
13293 +#define VC_CAT_RLIMIT 60
13295 +#define VC_CAT_SYSTEST 61
13296 +#define VC_CAT_COMPAT 63
13298 +/* query version */
13300 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13301 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13306 +#include <linux/errno.h>
13308 +#endif /* __KERNEL__ */
13310 +#endif /* _VX_SWITCH_H */
13312 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/tag_cmd.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/tag_cmd.h
13313 --- linux-2.6.27.14/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13314 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/tag_cmd.h 2008-10-13 14:54:20.000000000 +0200
13316 +#ifndef _VX_TAG_CMD_H
13317 +#define _VX_TAG_CMD_H
13320 +/* vinfo commands */
13322 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13325 +extern int vc_task_tag(uint32_t);
13327 +#endif /* __KERNEL__ */
13329 +/* context commands */
13331 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13334 +extern int vc_tag_migrate(uint32_t);
13336 +#endif /* __KERNEL__ */
13337 +#endif /* _VX_TAG_CMD_H */
13338 diff -NurpP --minimal linux-2.6.27.14/include/linux/vserver/tag.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/tag.h
13339 --- linux-2.6.27.14/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13340 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vserver/tag.h 2008-10-24 03:34:52.000000000 +0200
13345 +#include <linux/types.h>
13348 +#define DX_TAG(in) (IS_TAGGED(in))
13351 +#ifdef CONFIG_TAG_NFSD
13352 +#define DX_TAG_NFSD 1
13354 +#define DX_TAG_NFSD 0
13358 +#ifdef CONFIG_TAGGING_NONE
13360 +#define MAX_UID 0xFFFFFFFF
13361 +#define MAX_GID 0xFFFFFFFF
13363 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13365 +#define TAGINO_UID(cond, uid, tag) (uid)
13366 +#define TAGINO_GID(cond, gid, tag) (gid)
13371 +#ifdef CONFIG_TAGGING_GID16
13373 +#define MAX_UID 0xFFFFFFFF
13374 +#define MAX_GID 0x0000FFFF
13376 +#define INOTAG_TAG(cond, uid, gid, tag) \
13377 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13379 +#define TAGINO_UID(cond, uid, tag) (uid)
13380 +#define TAGINO_GID(cond, gid, tag) \
13381 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13386 +#ifdef CONFIG_TAGGING_ID24
13388 +#define MAX_UID 0x00FFFFFF
13389 +#define MAX_GID 0x00FFFFFF
13391 +#define INOTAG_TAG(cond, uid, gid, tag) \
13392 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13394 +#define TAGINO_UID(cond, uid, tag) \
13395 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13396 +#define TAGINO_GID(cond, gid, tag) \
13397 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13402 +#ifdef CONFIG_TAGGING_UID16
13404 +#define MAX_UID 0x0000FFFF
13405 +#define MAX_GID 0xFFFFFFFF
13407 +#define INOTAG_TAG(cond, uid, gid, tag) \
13408 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13410 +#define TAGINO_UID(cond, uid, tag) \
13411 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13412 +#define TAGINO_GID(cond, gid, tag) (gid)
13417 +#ifdef CONFIG_TAGGING_INTERN
13419 +#define MAX_UID 0xFFFFFFFF
13420 +#define MAX_GID 0xFFFFFFFF
13422 +#define INOTAG_TAG(cond, uid, gid, tag) \
13423 + ((cond) ? (tag) : 0)
13425 +#define TAGINO_UID(cond, uid, tag) (uid)
13426 +#define TAGINO_GID(cond, gid, tag) (gid)
13431 +#ifndef CONFIG_TAGGING_NONE
13432 +#define dx_current_fstag(sb) \
13433 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13435 +#define dx_current_fstag(sb) (0)
13438 +#ifndef CONFIG_TAGGING_INTERN
13439 +#define TAGINO_TAG(cond, tag) (0)
13441 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13444 +#define INOTAG_UID(cond, uid, gid) \
13445 + ((cond) ? ((uid) & MAX_UID) : (uid))
13446 +#define INOTAG_GID(cond, uid, gid) \
13447 + ((cond) ? ((gid) & MAX_GID) : (gid))
13450 +static inline uid_t dx_map_uid(uid_t uid)
13452 + if ((uid > MAX_UID) && (uid != -1))
13454 + return (uid & MAX_UID);
13457 +static inline gid_t dx_map_gid(gid_t gid)
13459 + if ((gid > MAX_GID) && (gid != -1))
13461 + return (gid & MAX_GID);
13469 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13471 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13472 + unsigned long *flags);
13474 +#ifdef CONFIG_PROPAGATE
13476 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13478 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13481 +#define dx_propagate_tag(n, i) do { } while (0)
13484 +#endif /* _DX_TAG_H */
13485 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_inet6.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_inet6.h
13486 --- linux-2.6.27.14/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13487 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_inet6.h 2008-11-16 17:35:20.000000000 +0100
13489 +#ifndef _VS_INET6_H
13490 +#define _VS_INET6_H
13492 +#include "vserver/base.h"
13493 +#include "vserver/network.h"
13494 +#include "vserver/debug.h"
13496 +#include <net/ipv6.h>
13498 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
13499 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
13502 +#ifdef CONFIG_IPV6
13505 +int v6_addr_match(struct nx_addr_v6 *nxa,
13506 + const struct in6_addr *addr, uint16_t mask)
13510 + switch (nxa->type & mask) {
13511 + case NXA_TYPE_MASK:
13512 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13514 + case NXA_TYPE_ADDR:
13515 + ret = ipv6_addr_equal(&nxa->ip, addr);
13517 + case NXA_TYPE_ANY:
13521 + vxdprintk(VXD_CBIT(net, 0),
13522 + "v6_addr_match(%p" NXAV6_FMT ", " NIP6_FMT ", %04x) = %d",
13523 + nxa, NXAV6(nxa), NIP6(*addr), mask, ret);
13528 +int v6_addr_in_nx_info(struct nx_info *nxi,
13529 + const struct in6_addr *addr, uint16_t mask)
13531 + struct nx_addr_v6 *nxa;
13536 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13537 + if (v6_addr_match(nxa, addr, mask))
13541 + vxdprintk(VXD_CBIT(net, 0),
13542 + "v6_addr_in_nx_info(%p[#%u]," NIP6_FMT ",%04x) = %d",
13543 + nxi, nxi ? nxi->nx_id : 0, NIP6(*addr), mask, ret);
13548 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13550 + /* FIXME: needs full range checks */
13551 + return v6_addr_match(nxa, &addr->ip, mask);
13555 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13557 + struct nx_addr_v6 *ptr;
13559 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13560 + if (v6_nx_addr_match(ptr, nxa, mask))
13567 + * Check if a given address matches for a socket
13569 + * nxi: the socket's nx_info if any
13570 + * addr: to be verified address
13573 +int v6_sock_addr_match (
13574 + struct nx_info *nxi,
13575 + struct inet_sock *inet,
13576 + struct in6_addr *addr)
13578 + struct sock *sk = &inet->sk;
13579 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13581 + if (!ipv6_addr_any(addr) &&
13582 + ipv6_addr_equal(saddr, addr))
13584 + if (ipv6_addr_any(saddr))
13585 + return v6_addr_in_nx_info(nxi, addr, -1);
13590 + * check if address is covered by socket
13592 + * sk: the socket to check against
13593 + * addr: the address in question (must be != 0)
13597 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13599 + struct nx_info *nxi = sk->sk_nx_info;
13600 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13602 + vxdprintk(VXD_CBIT(net, 5),
13603 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
13604 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
13605 + (sk->sk_socket?sk->sk_socket->flags:0));
13607 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13608 + return v6_addr_match(nxa, saddr, -1);
13609 + } else if (nxi) { /* match against nx_info */
13610 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13611 + } else { /* unrestricted any socket */
13617 +/* inet related checks and helpers */
13621 +struct net_device;
13625 +#include <linux/netdevice.h>
13626 +#include <linux/inetdevice.h>
13627 +#include <net/inet_timewait_sock.h>
13630 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13631 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13632 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13637 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13643 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13647 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13649 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13650 + nxi, nxi ? nxi->nx_id : 0, ifa,
13651 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13653 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13655 + if (v6_ifa_in_nx_info(ifa, nxi))
13661 +struct nx_v6_sock_addr {
13662 + struct in6_addr saddr; /* Address used for validation */
13663 + struct in6_addr baddr; /* Address used for socket bind */
13667 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13668 + struct nx_v6_sock_addr *nsa)
13670 + // struct sock *sk = &inet->sk;
13671 + // struct nx_info *nxi = sk->sk_nx_info;
13672 + struct in6_addr saddr = addr->sin6_addr;
13673 + struct in6_addr baddr = saddr;
13675 + nsa->saddr = saddr;
13676 + nsa->baddr = baddr;
13681 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13683 + // struct sock *sk = &inet->sk;
13684 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13686 + // *saddr = nsa->baddr;
13687 + // inet->saddr = nsa->baddr;
13691 +int nx_info_has_v6(struct nx_info *nxi)
13695 + if (NX_IPV6(nxi))
13700 +#else /* CONFIG_IPV6 */
13703 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13710 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13716 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13722 +int nx_info_has_v6(struct nx_info *nxi)
13727 +#endif /* CONFIG_IPV6 */
13729 +#define current_nx_info_has_v6() \
13730 + nx_info_has_v6(current_nx_info())
13733 +#warning duplicate inclusion
13735 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_inet.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_inet.h
13736 --- linux-2.6.27.14/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13737 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_inet.h 2008-10-13 14:54:20.000000000 +0200
13739 +#ifndef _VS_INET_H
13740 +#define _VS_INET_H
13742 +#include "vserver/base.h"
13743 +#include "vserver/network.h"
13744 +#include "vserver/debug.h"
13746 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13748 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13749 + NIPQUAD((a)->mask), (a)->type
13750 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13754 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13756 + __be32 ip = nxa->ip[0].s_addr;
13757 + __be32 mask = nxa->mask.s_addr;
13758 + __be32 bcast = ip | ~mask;
13761 + switch (nxa->type & tmask) {
13762 + case NXA_TYPE_MASK:
13763 + ret = (ip == (addr & mask));
13765 + case NXA_TYPE_ADDR:
13769 + /* fall through to broadcast */
13770 + case NXA_MOD_BCAST:
13771 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13773 + case NXA_TYPE_RANGE:
13774 + ret = ((nxa->ip[0].s_addr <= addr) &&
13775 + (nxa->ip[1].s_addr > addr));
13777 + case NXA_TYPE_ANY:
13782 + vxdprintk(VXD_CBIT(net, 0),
13783 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13784 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13789 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13791 + struct nx_addr_v4 *nxa;
13798 + /* allow 127.0.0.1 when remapping lback */
13799 + if ((tmask & NXA_LOOPBACK) &&
13800 + (addr == IPI_LOOPBACK) &&
13801 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13804 + /* check for lback address */
13805 + if ((tmask & NXA_MOD_LBACK) &&
13806 + (nxi->v4_lback.s_addr == addr))
13809 + /* check for broadcast address */
13810 + if ((tmask & NXA_MOD_BCAST) &&
13811 + (nxi->v4_bcast.s_addr == addr))
13814 + /* check for v4 addresses */
13815 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13816 + if (v4_addr_match(nxa, addr, tmask))
13820 + vxdprintk(VXD_CBIT(net, 0),
13821 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13822 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13827 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13829 + /* FIXME: needs full range checks */
13830 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13834 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13836 + struct nx_addr_v4 *ptr;
13838 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13839 + if (v4_nx_addr_match(ptr, nxa, mask))
13844 +#include <net/inet_sock.h>
13847 + * Check if a given address matches for a socket
13849 + * nxi: the socket's nx_info if any
13850 + * addr: to be verified address
13853 +int v4_sock_addr_match (
13854 + struct nx_info *nxi,
13855 + struct inet_sock *inet,
13858 + __be32 saddr = inet->rcv_saddr;
13859 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13861 + if (addr && (saddr == addr || bcast == addr))
13864 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13869 +/* inet related checks and helpers */
13873 +struct net_device;
13876 +#ifdef CONFIG_INET
13878 +#include <linux/netdevice.h>
13879 +#include <linux/inetdevice.h>
13880 +#include <net/inet_sock.h>
13881 +#include <net/inet_timewait_sock.h>
13884 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13885 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13886 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13890 + * check if address is covered by socket
13892 + * sk: the socket to check against
13893 + * addr: the address in question (must be != 0)
13897 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13899 + struct nx_info *nxi = sk->sk_nx_info;
13900 + __be32 saddr = inet_rcv_saddr(sk);
13902 + vxdprintk(VXD_CBIT(net, 5),
13903 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13904 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13905 + (sk->sk_socket?sk->sk_socket->flags:0));
13907 + if (saddr) { /* direct address match */
13908 + return v4_addr_match(nxa, saddr, -1);
13909 + } else if (nxi) { /* match against nx_info */
13910 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13911 + } else { /* unrestricted any socket */
13919 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13921 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
13922 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13923 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13925 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13927 + if (dev_in_nx_info(dev, nxi))
13934 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13940 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13944 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13946 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13947 + nxi, nxi ? nxi->nx_id : 0, ifa,
13948 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13950 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13952 + if (v4_ifa_in_nx_info(ifa, nxi))
13958 +struct nx_v4_sock_addr {
13959 + __be32 saddr; /* Address used for validation */
13960 + __be32 baddr; /* Address used for socket bind */
13964 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13965 + struct nx_v4_sock_addr *nsa)
13967 + struct sock *sk = &inet->sk;
13968 + struct nx_info *nxi = sk->sk_nx_info;
13969 + __be32 saddr = addr->sin_addr.s_addr;
13970 + __be32 baddr = saddr;
13972 + vxdprintk(VXD_CBIT(net, 3),
13973 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13974 + sk, sk->sk_nx_info, sk->sk_socket,
13975 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13979 + if (saddr == INADDR_ANY) {
13980 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13981 + baddr = nxi->v4.ip[0].s_addr;
13982 + } else if (saddr == IPI_LOOPBACK) {
13983 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13984 + baddr = nxi->v4_lback.s_addr;
13985 + } else { /* normal address bind */
13986 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13987 + return -EADDRNOTAVAIL;
13991 + vxdprintk(VXD_CBIT(net, 3),
13992 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13993 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13995 + nsa->saddr = saddr;
13996 + nsa->baddr = baddr;
14001 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
14003 + inet->saddr = nsa->baddr;
14004 + inet->rcv_saddr = nsa->baddr;
14009 + * helper to simplify inet_lookup_listener
14011 + * nxi: the socket's nx_info if any
14012 + * addr: to be verified address
14013 + * saddr: socket address
14015 +static inline int v4_inet_addr_match (
14016 + struct nx_info *nxi,
14020 + if (addr && (saddr == addr))
14023 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
14027 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
14029 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
14030 + (addr == nxi->v4_lback.s_addr))
14031 + return IPI_LOOPBACK;
14036 +int nx_info_has_v4(struct nx_info *nxi)
14040 + if (NX_IPV4(nxi))
14042 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14047 +#else /* CONFIG_INET */
14050 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
14056 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14062 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14068 +int nx_info_has_v4(struct nx_info *nxi)
14073 +#endif /* CONFIG_INET */
14075 +#define current_nx_info_has_v4() \
14076 + nx_info_has_v4(current_nx_info())
14079 +// #warning duplicate inclusion
14081 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_limit.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_limit.h
14082 --- linux-2.6.27.14/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
14083 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_limit.h 2008-10-13 14:54:20.000000000 +0200
14085 +#ifndef _VS_LIMIT_H
14086 +#define _VS_LIMIT_H
14088 +#include "vserver/limit.h"
14089 +#include "vserver/base.h"
14090 +#include "vserver/context.h"
14091 +#include "vserver/debug.h"
14092 +#include "vserver/context.h"
14093 +#include "vserver/limit_int.h"
14096 +#define vx_acc_cres(v, d, p, r) \
14097 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
14099 +#define vx_acc_cres_cond(x, d, p, r) \
14100 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14101 + r, d, p, __FILE__, __LINE__)
14104 +#define vx_add_cres(v, a, p, r) \
14105 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
14106 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
14108 +#define vx_add_cres_cond(x, a, p, r) \
14109 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14110 + r, a, p, __FILE__, __LINE__)
14111 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
14114 +/* process and file limits */
14116 +#define vx_nproc_inc(p) \
14117 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
14119 +#define vx_nproc_dec(p) \
14120 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
14122 +#define vx_files_inc(f) \
14123 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
14125 +#define vx_files_dec(f) \
14126 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
14128 +#define vx_locks_inc(l) \
14129 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
14131 +#define vx_locks_dec(l) \
14132 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
14134 +#define vx_openfd_inc(f) \
14135 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
14137 +#define vx_openfd_dec(f) \
14138 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
14141 +#define vx_cres_avail(v, n, r) \
14142 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
14145 +#define vx_nproc_avail(n) \
14146 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
14148 +#define vx_files_avail(n) \
14149 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
14151 +#define vx_locks_avail(n) \
14152 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
14154 +#define vx_openfd_avail(n) \
14155 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
14158 +/* dentry limits */
14160 +#define vx_dentry_inc(d) do { \
14161 + if (atomic_read(&d->d_count) == 1) \
14162 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
14165 +#define vx_dentry_dec(d) do { \
14166 + if (atomic_read(&d->d_count) == 0) \
14167 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
14170 +#define vx_dentry_avail(n) \
14171 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
14174 +/* socket limits */
14176 +#define vx_sock_inc(s) \
14177 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
14179 +#define vx_sock_dec(s) \
14180 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
14182 +#define vx_sock_avail(n) \
14183 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
14186 +/* ipc resource limits */
14188 +#define vx_ipcmsg_add(v, u, a) \
14189 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
14191 +#define vx_ipcmsg_sub(v, u, a) \
14192 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
14194 +#define vx_ipcmsg_avail(v, a) \
14195 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
14198 +#define vx_ipcshm_add(v, k, a) \
14199 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14201 +#define vx_ipcshm_sub(v, k, a) \
14202 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
14204 +#define vx_ipcshm_avail(v, a) \
14205 + vx_cres_avail(v, a, VLIMIT_SHMEM)
14208 +#define vx_semary_inc(a) \
14209 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
14211 +#define vx_semary_dec(a) \
14212 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
14215 +#define vx_nsems_add(a,n) \
14216 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
14218 +#define vx_nsems_sub(a,n) \
14219 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
14223 +#warning duplicate inclusion
14225 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_memory.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_memory.h
14226 --- linux-2.6.27.14/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
14227 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_memory.h 2008-10-13 14:54:20.000000000 +0200
14229 +#ifndef _VS_MEMORY_H
14230 +#define _VS_MEMORY_H
14232 +#include "vserver/limit.h"
14233 +#include "vserver/base.h"
14234 +#include "vserver/context.h"
14235 +#include "vserver/debug.h"
14236 +#include "vserver/context.h"
14237 +#include "vserver/limit_int.h"
14240 +#define __acc_add_long(a, v) (*(v) += (a))
14241 +#define __acc_inc_long(v) (++*(v))
14242 +#define __acc_dec_long(v) (--*(v))
14244 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
14245 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
14246 +#define __acc_inc_atomic(v) atomic_long_inc(v)
14247 +#define __acc_dec_atomic(v) atomic_long_dec(v)
14248 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14249 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
14250 +#define __acc_inc_atomic(v) __acc_inc_long(v)
14251 +#define __acc_dec_atomic(v) __acc_dec_long(v)
14252 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
14255 +#define vx_acc_page(m, d, v, r) do { \
14257 + __acc_inc_long(&(m)->v); \
14259 + __acc_dec_long(&(m)->v); \
14260 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14263 +#define vx_acc_page_atomic(m, d, v, r) do { \
14265 + __acc_inc_atomic(&(m)->v); \
14267 + __acc_dec_atomic(&(m)->v); \
14268 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
14272 +#define vx_acc_pages(m, p, v, r) do { \
14273 + unsigned long __p = (p); \
14274 + __acc_add_long(__p, &(m)->v); \
14275 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14278 +#define vx_acc_pages_atomic(m, p, v, r) do { \
14279 + unsigned long __p = (p); \
14280 + __acc_add_atomic(__p, &(m)->v); \
14281 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
14286 +#define vx_acc_vmpage(m, d) \
14287 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
14288 +#define vx_acc_vmlpage(m, d) \
14289 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
14290 +#define vx_acc_file_rsspage(m, d) \
14291 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
14292 +#define vx_acc_anon_rsspage(m, d) \
14293 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
14295 +#define vx_acc_vmpages(m, p) \
14296 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
14297 +#define vx_acc_vmlpages(m, p) \
14298 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
14299 +#define vx_acc_file_rsspages(m, p) \
14300 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
14301 +#define vx_acc_anon_rsspages(m, p) \
14302 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
14304 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
14305 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
14307 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
14308 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
14309 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
14310 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
14312 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
14313 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
14314 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
14315 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
14317 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
14318 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
14319 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
14320 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
14322 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
14323 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
14324 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
14325 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
14328 +#define vx_pages_avail(m, p, r) \
14329 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
14331 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
14332 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
14333 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
14334 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
14336 +#define vx_rss_avail(m, p) \
14337 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
14341 + VXPT_UNKNOWN = 0,
14350 +#define vx_page_fault(mm, vma, type, ret)
14354 +void __vx_page_fault(struct mm_struct *mm,
14355 + struct vm_area_struct *vma, int type, int ret)
14357 + struct vx_info *vxi = mm->mm_vx_info;
14360 + static char *page_type[6] =
14361 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
14362 + static char *page_what[4] =
14363 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
14369 + what = (ret & 0x3);
14371 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
14372 + type, what, ret, page_type[type], page_what[what]);
14374 + if (ret & VM_FAULT_WRITE)
14376 + atomic_inc(&vxi->cacct.page[type][what]);
14379 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
14383 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
14386 +#warning duplicate inclusion
14388 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_network.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_network.h
14389 --- linux-2.6.27.14/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
14390 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_network.h 2008-10-13 14:54:20.000000000 +0200
14392 +#ifndef _NX_VS_NETWORK_H
14393 +#define _NX_VS_NETWORK_H
14395 +#include "vserver/context.h"
14396 +#include "vserver/network.h"
14397 +#include "vserver/base.h"
14398 +#include "vserver/check.h"
14399 +#include "vserver/debug.h"
14401 +#include <linux/sched.h>
14404 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
14406 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
14407 + const char *_file, int _line)
14412 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14413 + nxi, nxi ? nxi->nx_id : 0,
14414 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14417 + atomic_inc(&nxi->nx_usecnt);
14422 +extern void free_nx_info(struct nx_info *);
14424 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14426 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14431 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14432 + nxi, nxi ? nxi->nx_id : 0,
14433 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14436 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14437 + free_nx_info(nxi);
14441 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14443 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14444 + const char *_file, int _line)
14447 + vxlprintk(VXD_CBIT(nid, 3),
14448 + "init_nx_info(%p[#%d.%d])",
14449 + nxi, nxi ? nxi->nx_id : 0,
14450 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14453 + atomic_inc(&nxi->nx_usecnt);
14459 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14461 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14462 + const char *_file, int _line)
14464 + struct nx_info *nxo;
14469 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14470 + nxi, nxi ? nxi->nx_id : 0,
14471 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14474 + atomic_inc(&nxi->nx_usecnt);
14475 + nxo = xchg(nxp, nxi);
14479 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14481 +static inline void __clr_nx_info(struct nx_info **nxp,
14482 + const char *_file, int _line)
14484 + struct nx_info *nxo;
14486 + nxo = xchg(nxp, NULL);
14490 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14491 + nxo, nxo ? nxo->nx_id : 0,
14492 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14495 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14496 + free_nx_info(nxo);
14500 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14502 +static inline void __claim_nx_info(struct nx_info *nxi,
14503 + struct task_struct *task, const char *_file, int _line)
14505 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14506 + nxi, nxi ? nxi->nx_id : 0,
14507 + nxi?atomic_read(&nxi->nx_usecnt):0,
14508 + nxi?atomic_read(&nxi->nx_tasks):0,
14509 + task, _file, _line);
14511 + atomic_inc(&nxi->nx_tasks);
14515 +extern void unhash_nx_info(struct nx_info *);
14517 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14519 +static inline void __release_nx_info(struct nx_info *nxi,
14520 + struct task_struct *task, const char *_file, int _line)
14522 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14523 + nxi, nxi ? nxi->nx_id : 0,
14524 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14525 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14526 + task, _file, _line);
14530 + if (atomic_dec_and_test(&nxi->nx_tasks))
14531 + unhash_nx_info(nxi);
14535 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14537 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14538 + const char *_file, int _line)
14540 + struct nx_info *nxi;
14543 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14544 + p, _file, _line);
14545 + nxi = __get_nx_info(p->nx_info, _file, _line);
14551 +static inline void exit_nx_info(struct task_struct *p)
14554 + release_nx_info(p->nx_info, p);
14559 +#warning duplicate inclusion
14561 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_pid.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_pid.h
14562 --- linux-2.6.27.14/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14563 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_pid.h 2008-10-13 14:54:20.000000000 +0200
14568 +#include "vserver/base.h"
14569 +#include "vserver/check.h"
14570 +#include "vserver/context.h"
14571 +#include "vserver/debug.h"
14572 +#include "vserver/pid.h"
14573 +#include <linux/pid_namespace.h>
14576 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14579 +int vx_proc_task_visible(struct task_struct *task)
14581 + if ((task->pid == 1) &&
14582 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14583 + /* show a blend through init */
14585 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14592 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14597 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14599 + struct task_struct *task = find_task_by_real_pid(pid);
14601 + if (task && !vx_proc_task_visible(task)) {
14602 + vxdprintk(VXD_CBIT(misc, 6),
14603 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14604 + task, task->xid, task->pid,
14605 + current, current->xid, current->pid);
14614 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14616 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14618 + if (task && !vx_proc_task_visible(task)) {
14619 + vxdprintk(VXD_CBIT(misc, 6),
14620 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14621 + task, task->xid, task->pid,
14622 + current, current->xid, current->pid);
14623 + put_task_struct(task);
14632 +struct task_struct *vx_child_reaper(struct task_struct *p)
14634 + struct vx_info *vxi = p->vx_info;
14635 + struct task_struct *reaper = child_reaper(p);
14640 + BUG_ON(!p->vx_info->vx_reaper);
14642 + /* child reaper for the guest reaper */
14643 + if (vxi->vx_reaper == p)
14646 + reaper = vxi->vx_reaper;
14648 + vxdprintk(VXD_CBIT(xid, 7),
14649 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14650 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14658 +#warning duplicate inclusion
14660 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_sched.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_sched.h
14661 --- linux-2.6.27.14/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14662 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_sched.h 2008-10-13 14:54:20.000000000 +0200
14664 +#ifndef _VS_SCHED_H
14665 +#define _VS_SCHED_H
14667 +#include "vserver/base.h"
14668 +#include "vserver/context.h"
14669 +#include "vserver/sched.h"
14672 +#define VAVAVOOM_RATIO 50
14674 +#define MAX_PRIO_BIAS 20
14675 +#define MIN_PRIO_BIAS -20
14678 +#ifdef CONFIG_VSERVER_HARDCPU
14681 + * effective_prio - return the priority that is based on the static
14682 + * priority but is modified by bonuses/penalties.
14684 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14685 + * into a -4 ... 0 ... +4 bonus/penalty range.
14687 + * Additionally, we scale another amount based on the number of
14688 + * CPU tokens currently held by the context, if the process is
14689 + * part of a context (and the appropriate SCHED flag is set).
14690 + * This ranges from -5 ... 0 ... +15, quadratically.
14692 + * So, the total bonus is -9 .. 0 .. +19
14693 + * We use ~50% of the full 0...39 priority range so that:
14695 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14696 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14697 + * unless that context is far exceeding its CPU allocation.
14699 + * Both properties are important to certain workloads.
14702 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
14704 + int vavavoom, max;
14706 + /* lots of tokens = lots of vavavoom
14707 + * no tokens = no vavavoom */
14708 + if ((vavavoom = sched_pc->tokens) >= 0) {
14709 + max = sched_pc->tokens_max;
14710 + vavavoom = max - vavavoom;
14712 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14713 + * (vavavoom*vavavoom - (max >> 2)) / max;
14721 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14723 + struct vx_info *vxi = p->vx_info;
14724 + struct _vx_sched_pc *sched_pc;
14729 + sched_pc = &vx_cpu(vxi, sched_pc);
14730 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
14731 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
14733 + sched_pc->vavavoom = vavavoom;
14734 + prio += vavavoom;
14736 + prio += sched_pc->prio_bias;
14740 +#else /* !CONFIG_VSERVER_HARDCPU */
14743 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14745 + struct vx_info *vxi = p->vx_info;
14748 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14752 +#endif /* CONFIG_VSERVER_HARDCPU */
14755 +static inline void vx_account_user(struct vx_info *vxi,
14756 + cputime_t cputime, int nice)
14760 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14763 +static inline void vx_account_system(struct vx_info *vxi,
14764 + cputime_t cputime, int idle)
14768 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14772 +#warning duplicate inclusion
14774 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_socket.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_socket.h
14775 --- linux-2.6.27.14/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14776 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_socket.h 2008-10-13 14:54:20.000000000 +0200
14778 +#ifndef _VS_SOCKET_H
14779 +#define _VS_SOCKET_H
14781 +#include "vserver/debug.h"
14782 +#include "vserver/base.h"
14783 +#include "vserver/cacct.h"
14784 +#include "vserver/context.h"
14785 +#include "vserver/tag.h"
14788 +/* socket accounting */
14790 +#include <linux/socket.h>
14792 +static inline int vx_sock_type(int family)
14794 + switch (family) {
14796 + return VXA_SOCK_UNSPEC;
14798 + return VXA_SOCK_UNIX;
14800 + return VXA_SOCK_INET;
14802 + return VXA_SOCK_INET6;
14804 + return VXA_SOCK_PACKET;
14806 + return VXA_SOCK_OTHER;
14810 +#define vx_acc_sock(v, f, p, s) \
14811 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14813 +static inline void __vx_acc_sock(struct vx_info *vxi,
14814 + int family, int pos, int size, char *file, int line)
14817 + int type = vx_sock_type(family);
14819 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14820 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14824 +#define vx_sock_recv(sk, s) \
14825 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14826 +#define vx_sock_send(sk, s) \
14827 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14828 +#define vx_sock_fail(sk, s) \
14829 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14832 +#define sock_vx_init(s) do { \
14833 + (s)->sk_xid = 0; \
14834 + (s)->sk_vx_info = NULL; \
14837 +#define sock_nx_init(s) do { \
14838 + (s)->sk_nid = 0; \
14839 + (s)->sk_nx_info = NULL; \
14843 +#warning duplicate inclusion
14845 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_tag.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_tag.h
14846 --- linux-2.6.27.14/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14847 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_tag.h 2008-10-24 03:34:52.000000000 +0200
14852 +#include <linux/vserver/tag.h>
14854 +/* check conditions */
14856 +#define DX_ADMIN 0x0001
14857 +#define DX_WATCH 0x0002
14858 +#define DX_HOSTID 0x0008
14860 +#define DX_IDENT 0x0010
14862 +#define DX_ARG_MASK 0x0010
14865 +#define dx_task_tag(t) ((t)->tag)
14867 +#define dx_current_tag() dx_task_tag(current)
14869 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14871 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14875 + * check current context for ADMIN/WATCH and
14876 + * optionally against supplied argument
14878 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14880 + if (mode & DX_ARG_MASK) {
14881 + if ((mode & DX_IDENT) && (id == cid))
14884 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14885 + ((mode & DX_WATCH) && (cid == 1)) ||
14886 + ((mode & DX_HOSTID) && (id == 0)));
14890 +int dx_permission(struct inode *inode, int mask);
14894 +#warning duplicate inclusion
14896 diff -NurpP --minimal linux-2.6.27.14/include/linux/vs_time.h linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_time.h
14897 --- linux-2.6.27.14/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14898 +++ linux-2.6.27.14-vs2.3.0.36.4/include/linux/vs_time.h 2008-10-13 14:54:20.000000000 +0200
14900 +#ifndef _VS_TIME_H
14901 +#define _VS_TIME_H
14904 +/* time faking stuff */
14906 +#ifdef CONFIG_VSERVER_VTIME
14908 +extern void vx_gettimeofday(struct timeval *tv);
14909 +extern int vx_settimeofday(struct timespec *ts);
14912 +#define vx_gettimeofday(t) do_gettimeofday(t)
14913 +#define vx_settimeofday(t) do_settimeofday(t)
14917 +#warning duplicate inclusion
14919 diff -NurpP --minimal linux-2.6.27.14/include/net/addrconf.h linux-2.6.27.14-vs2.3.0.36.4/include/net/addrconf.h
14920 --- linux-2.6.27.14/include/net/addrconf.h 2008-10-13 14:52:09.000000000 +0200
14921 +++ linux-2.6.27.14-vs2.3.0.36.4/include/net/addrconf.h 2008-10-13 14:54:20.000000000 +0200
14922 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14923 struct net_device *dev,
14924 const struct in6_addr *daddr,
14925 unsigned int srcprefs,
14926 - struct in6_addr *saddr);
14927 + struct in6_addr *saddr,
14928 + struct nx_info *nxi);
14929 extern int ipv6_get_lladdr(struct net_device *dev,
14930 struct in6_addr *addr,
14931 unsigned char banned_flags);
14932 diff -NurpP --minimal linux-2.6.27.14/include/net/af_unix.h linux-2.6.27.14-vs2.3.0.36.4/include/net/af_unix.h
14933 --- linux-2.6.27.14/include/net/af_unix.h 2009-02-03 17:59:55.000000000 +0100
14934 +++ linux-2.6.27.14-vs2.3.0.36.4/include/net/af_unix.h 2009-02-03 17:59:04.000000000 +0100
14936 #include <linux/socket.h>
14937 #include <linux/un.h>
14938 #include <linux/mutex.h>
14939 +#include <linux/vs_base.h>
14940 #include <net/sock.h>
14942 extern void unix_inflight(struct file *fp);
14943 diff -NurpP --minimal linux-2.6.27.14/include/net/inet_sock.h linux-2.6.27.14-vs2.3.0.36.4/include/net/inet_sock.h
14944 --- linux-2.6.27.14/include/net/inet_sock.h 2008-10-13 14:52:09.000000000 +0200
14945 +++ linux-2.6.27.14-vs2.3.0.36.4/include/net/inet_sock.h 2008-10-13 14:54:20.000000000 +0200
14947 #include <net/flow.h>
14948 #include <net/sock.h>
14949 #include <net/request_sock.h>
14950 -#include <net/route.h>
14951 +// #include <net/route.h>
14952 #include <net/netns/hash.h>
14954 /** struct ip_options - IP Options
14955 @@ -195,11 +195,6 @@ static inline int inet_sk_ehashfn(const
14959 -static inline int inet_iif(const struct sk_buff *skb)
14961 - return skb->rtable->rt_iif;
14964 static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops)
14966 struct request_sock *req = reqsk_alloc(ops);
14967 diff -NurpP --minimal linux-2.6.27.14/include/net/inet_timewait_sock.h linux-2.6.27.14-vs2.3.0.36.4/include/net/inet_timewait_sock.h
14968 --- linux-2.6.27.14/include/net/inet_timewait_sock.h 2008-10-13 14:52:09.000000000 +0200
14969 +++ linux-2.6.27.14-vs2.3.0.36.4/include/net/inet_timewait_sock.h 2008-10-13 14:54:20.000000000 +0200
14970 @@ -15,15 +15,14 @@
14971 #ifndef _INET_TIMEWAIT_SOCK_
14972 #define _INET_TIMEWAIT_SOCK_
14974 +// #include <net/inet_sock.h>
14975 +#include <net/sock.h>
14977 #include <linux/list.h>
14978 #include <linux/module.h>
14979 #include <linux/timer.h>
14980 #include <linux/types.h>
14981 #include <linux/workqueue.h>
14983 -#include <net/inet_sock.h>
14984 -#include <net/sock.h>
14985 #include <net/tcp_states.h>
14986 #include <net/timewait_sock.h>
14988 @@ -116,6 +115,10 @@ struct inet_timewait_sock {
14989 #define tw_hash __tw_common.skc_hash
14990 #define tw_prot __tw_common.skc_prot
14991 #define tw_net __tw_common.skc_net
14992 +#define tw_xid __tw_common.skc_xid
14993 +#define tw_vx_info __tw_common.skc_vx_info
14994 +#define tw_nid __tw_common.skc_nid
14995 +#define tw_nx_info __tw_common.skc_nx_info
14997 volatile unsigned char tw_substate;
14998 /* 3 bits hole, try to pack */
14999 diff -NurpP --minimal linux-2.6.27.14/include/net/route.h linux-2.6.27.14-vs2.3.0.36.4/include/net/route.h
15000 --- linux-2.6.27.14/include/net/route.h 2008-10-13 14:52:09.000000000 +0200
15001 +++ linux-2.6.27.14-vs2.3.0.36.4/include/net/route.h 2008-10-13 14:54:20.000000000 +0200
15003 #include <net/inetpeer.h>
15004 #include <net/flow.h>
15005 #include <net/sock.h>
15006 +// #include <linux/in.h>
15007 #include <linux/in_route.h>
15008 #include <linux/rtnetlink.h>
15009 #include <linux/route.h>
15010 @@ -85,6 +86,11 @@ struct ip_rt_acct
15014 +static inline int inet_iif(const struct sk_buff *skb)
15016 + return skb->rtable->rt_iif;
15019 struct rt_cache_stat
15021 unsigned int in_hit;
15022 @@ -135,6 +141,9 @@ static inline void ip_rt_put(struct rtab
15023 dst_release(&rt->u.dst);
15026 +#include <linux/vs_base.h>
15027 +#include <linux/vs_inet.h>
15029 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
15031 extern const __u8 ip_tos2prio[16];
15032 @@ -144,6 +153,9 @@ static inline char rt_tos2priority(u8 to
15033 return ip_tos2prio[IPTOS_TOS(tos)>>1];
15036 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
15037 + struct rtable **, struct flowi *);
15039 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
15040 __be32 src, u32 tos, int oif, u8 protocol,
15041 __be16 sport, __be16 dport, struct sock *sk,
15042 @@ -161,7 +173,21 @@ static inline int ip_route_connect(struc
15045 struct net *net = sock_net(sk);
15046 - if (!dst || !src) {
15047 + struct nx_info *nx_info = current->nx_info;
15050 + nx_info = sk->sk_nx_info;
15052 + vxdprintk(VXD_CBIT(net, 4),
15053 + "ip_route_connect(%p) %p,%p;%lx",
15054 + sk, nx_info, sk->sk_socket,
15055 + (sk->sk_socket?sk->sk_socket->flags:0));
15057 + err = ip_v4_find_src(net, nx_info, rp, &fl);
15061 + if (!fl.fl4_dst || !fl.fl4_src) {
15062 err = __ip_route_output_key(net, rp, &fl);
15065 diff -NurpP --minimal linux-2.6.27.14/include/net/sock.h linux-2.6.27.14-vs2.3.0.36.4/include/net/sock.h
15066 --- linux-2.6.27.14/include/net/sock.h 2008-10-13 14:52:09.000000000 +0200
15067 +++ linux-2.6.27.14-vs2.3.0.36.4/include/net/sock.h 2008-10-13 14:54:20.000000000 +0200
15068 @@ -128,6 +128,10 @@ struct sock_common {
15069 #ifdef CONFIG_NET_NS
15070 struct net *skc_net;
15073 + struct vx_info *skc_vx_info;
15075 + struct nx_info *skc_nx_info;
15079 @@ -211,6 +215,10 @@ struct sock {
15080 #define sk_hash __sk_common.skc_hash
15081 #define sk_prot __sk_common.skc_prot
15082 #define sk_net __sk_common.skc_net
15083 +#define sk_xid __sk_common.skc_xid
15084 +#define sk_vx_info __sk_common.skc_vx_info
15085 +#define sk_nid __sk_common.skc_nid
15086 +#define sk_nx_info __sk_common.skc_nx_info
15087 unsigned char sk_shutdown : 2,
15090 diff -NurpP --minimal linux-2.6.27.14/init/main.c linux-2.6.27.14-vs2.3.0.36.4/init/main.c
15091 --- linux-2.6.27.14/init/main.c 2008-10-13 14:52:09.000000000 +0200
15092 +++ linux-2.6.27.14-vs2.3.0.36.4/init/main.c 2008-10-13 14:54:20.000000000 +0200
15094 #include <linux/sched.h>
15095 #include <linux/signal.h>
15096 #include <linux/idr.h>
15097 +#include <linux/vserver/percpu.h>
15099 #include <asm/io.h>
15100 #include <asm/bugs.h>
15101 @@ -391,12 +392,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
15103 static void __init setup_per_cpu_areas(void)
15105 - unsigned long size, i;
15106 + unsigned long size, vspc, i;
15108 unsigned long nr_possible_cpus = num_possible_cpus();
15110 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
15112 /* Copy section for each CPU (we discard the original) */
15113 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
15114 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
15115 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
15117 for_each_possible_cpu(i) {
15118 diff -NurpP --minimal linux-2.6.27.14/ipc/mqueue.c linux-2.6.27.14-vs2.3.0.36.4/ipc/mqueue.c
15119 --- linux-2.6.27.14/ipc/mqueue.c 2009-02-03 17:59:55.000000000 +0100
15120 +++ linux-2.6.27.14-vs2.3.0.36.4/ipc/mqueue.c 2009-02-03 17:59:04.000000000 +0100
15122 #include <linux/mutex.h>
15123 #include <linux/nsproxy.h>
15124 #include <linux/pid.h>
15125 +#include <linux/vs_context.h>
15126 +#include <linux/vs_limit.h>
15128 #include <net/sock.h>
15130 @@ -71,6 +73,7 @@ struct mqueue_inode_info {
15131 struct sigevent notify;
15132 struct pid* notify_owner;
15133 struct user_struct *user; /* user who created, for accounting */
15134 + struct vx_info *vxi;
15135 struct sock *notify_sock;
15136 struct sk_buff *notify_cookie;
15138 @@ -119,6 +122,7 @@ static struct inode *mqueue_get_inode(st
15139 struct mqueue_inode_info *info;
15140 struct task_struct *p = current;
15141 struct user_struct *u = p->user;
15142 + struct vx_info *vxi = p->vx_info;
15143 unsigned long mq_bytes, mq_msg_tblsz;
15145 inode->i_fop = &mqueue_file_operations;
15146 @@ -133,6 +137,7 @@ static struct inode *mqueue_get_inode(st
15147 info->notify_owner = NULL;
15149 info->user = NULL; /* set when all is ok */
15150 + info->vxi = NULL;
15151 memset(&info->attr, 0, sizeof(info->attr));
15152 info->attr.mq_maxmsg = DFLT_MSGMAX;
15153 info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
15154 @@ -147,22 +152,26 @@ static struct inode *mqueue_get_inode(st
15155 spin_lock(&mq_lock);
15156 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15157 u->mq_bytes + mq_bytes >
15158 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
15159 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
15160 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
15161 spin_unlock(&mq_lock);
15164 u->mq_bytes += mq_bytes;
15165 + vx_ipcmsg_add(vxi, u, mq_bytes);
15166 spin_unlock(&mq_lock);
15168 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
15169 if (!info->messages) {
15170 spin_lock(&mq_lock);
15171 u->mq_bytes -= mq_bytes;
15172 + vx_ipcmsg_sub(vxi, u, mq_bytes);
15173 spin_unlock(&mq_lock);
15177 info->user = get_uid(u);
15178 + info->vxi = get_vx_info(vxi);
15179 } else if (S_ISDIR(mode)) {
15181 /* Some things misbehave if size == 0 on a directory */
15182 @@ -253,10 +262,14 @@ static void mqueue_delete_inode(struct i
15183 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
15186 + struct vx_info *vxi = info->vxi;
15188 spin_lock(&mq_lock);
15189 user->mq_bytes -= mq_bytes;
15190 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15192 spin_unlock(&mq_lock);
15193 + put_vx_info(vxi);
15197 diff -NurpP --minimal linux-2.6.27.14/ipc/msg.c linux-2.6.27.14-vs2.3.0.36.4/ipc/msg.c
15198 --- linux-2.6.27.14/ipc/msg.c 2009-02-03 17:59:55.000000000 +0100
15199 +++ linux-2.6.27.14-vs2.3.0.36.4/ipc/msg.c 2009-02-03 17:59:04.000000000 +0100
15201 #include <linux/rwsem.h>
15202 #include <linux/nsproxy.h>
15203 #include <linux/ipc_namespace.h>
15204 +#include <linux/vs_base.h>
15206 #include <asm/current.h>
15207 #include <asm/uaccess.h>
15208 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
15210 msq->q_perm.mode = msgflg & S_IRWXUGO;
15211 msq->q_perm.key = key;
15212 + msq->q_perm.xid = vx_current_xid();
15214 msq->q_perm.security = NULL;
15215 retval = security_msg_queue_alloc(msq);
15216 diff -NurpP --minimal linux-2.6.27.14/ipc/namespace.c linux-2.6.27.14-vs2.3.0.36.4/ipc/namespace.c
15217 --- linux-2.6.27.14/ipc/namespace.c 2008-07-13 23:51:29.000000000 +0200
15218 +++ linux-2.6.27.14-vs2.3.0.36.4/ipc/namespace.c 2008-10-13 14:54:20.000000000 +0200
15220 #include <linux/rcupdate.h>
15221 #include <linux/nsproxy.h>
15222 #include <linux/slab.h>
15223 +#include <linux/vs_base.h>
15224 +#include <linux/vserver/global.h>
15228 @@ -35,6 +37,7 @@ static struct ipc_namespace *clone_ipc_n
15229 register_ipcns_notifier(ns);
15231 kref_init(&ns->kref);
15232 + atomic_inc(&vs_global_ipc_ns);
15236 @@ -101,6 +104,7 @@ void free_ipc_ns(struct kref *kref)
15240 + atomic_dec(&vs_global_ipc_ns);
15242 atomic_dec(&nr_ipc_ns);
15244 diff -NurpP --minimal linux-2.6.27.14/ipc/sem.c linux-2.6.27.14-vs2.3.0.36.4/ipc/sem.c
15245 --- linux-2.6.27.14/ipc/sem.c 2009-02-03 17:59:55.000000000 +0100
15246 +++ linux-2.6.27.14-vs2.3.0.36.4/ipc/sem.c 2009-02-03 17:59:04.000000000 +0100
15248 #include <linux/rwsem.h>
15249 #include <linux/nsproxy.h>
15250 #include <linux/ipc_namespace.h>
15251 +#include <linux/vs_base.h>
15252 +#include <linux/vs_limit.h>
15254 #include <asm/uaccess.h>
15256 @@ -255,6 +257,7 @@ static int newary(struct ipc_namespace *
15258 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15259 sma->sem_perm.key = key;
15260 + sma->sem_perm.xid = vx_current_xid();
15262 sma->sem_perm.security = NULL;
15263 retval = security_sem_alloc(sma);
15264 @@ -270,6 +273,9 @@ static int newary(struct ipc_namespace *
15267 ns->used_sems += nsems;
15268 + /* FIXME: obsoleted? */
15269 + vx_semary_inc(sma);
15270 + vx_nsems_add(sma, nsems);
15272 sma->sem_base = (struct sem *) &sma[1];
15273 INIT_LIST_HEAD(&sma->sem_pending);
15274 diff -NurpP --minimal linux-2.6.27.14/ipc/shm.c linux-2.6.27.14-vs2.3.0.36.4/ipc/shm.c
15275 --- linux-2.6.27.14/ipc/shm.c 2009-02-03 17:59:55.000000000 +0100
15276 +++ linux-2.6.27.14-vs2.3.0.36.4/ipc/shm.c 2009-02-03 17:59:04.000000000 +0100
15278 #include <linux/nsproxy.h>
15279 #include <linux/mount.h>
15280 #include <linux/ipc_namespace.h>
15281 +#include <linux/vs_context.h>
15282 +#include <linux/vs_limit.h>
15284 #include <asm/uaccess.h>
15286 @@ -168,7 +170,12 @@ static void shm_open(struct vm_area_stru
15288 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15290 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15291 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15292 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15294 + vx_ipcshm_sub(vxi, shp, numpages);
15295 + ns->shm_tot -= numpages;
15299 if (!is_file_hugepages(shp->shm_file))
15300 @@ -178,6 +185,7 @@ static void shm_destroy(struct ipc_names
15302 fput (shp->shm_file);
15303 security_shm_free(shp);
15304 + put_vx_info(vxi);
15305 ipc_rcu_putref(shp);
15308 @@ -347,11 +355,15 @@ static int newseg(struct ipc_namespace *
15309 if (ns->shm_tot + numpages > ns->shm_ctlall)
15312 + if (!vx_ipcshm_avail(current->vx_info, numpages))
15315 shp = ipc_rcu_alloc(sizeof(*shp));
15319 shp->shm_perm.key = key;
15320 + shp->shm_perm.xid = vx_current_xid();
15321 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15322 shp->mlock_user = NULL;
15324 @@ -404,6 +416,7 @@ static int newseg(struct ipc_namespace *
15325 ns->shm_tot += numpages;
15326 error = shp->shm_perm.id;
15328 + vx_ipcshm_add(current->vx_info, key, numpages);
15332 diff -NurpP --minimal linux-2.6.27.14/kernel/capability.c linux-2.6.27.14-vs2.3.0.36.4/kernel/capability.c
15333 --- linux-2.6.27.14/kernel/capability.c 2009-02-03 17:59:55.000000000 +0100
15334 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/capability.c 2009-02-03 17:59:04.000000000 +0100
15336 #include <linux/security.h>
15337 #include <linux/syscalls.h>
15338 #include <linux/pid_namespace.h>
15339 +#include <linux/vs_context.h>
15340 #include <asm/uaccess.h>
15343 @@ -166,6 +167,8 @@ static inline int cap_set_pg(int pgrp_nr
15345 pgrp = find_vpid(pgrp_nr);
15346 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
15347 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
15350 while_each_thread(g, target) {
15351 if (!security_capset_check(target, effective,
15352 @@ -486,6 +489,8 @@ SYSCALL_DEFINE2(capset, cap_user_header_
15356 +#include <linux/vserver/base.h>
15359 * capable - Determine if the current task has a superior capability in effect
15360 * @cap: The capability to be tested for
15361 @@ -498,6 +503,9 @@ SYSCALL_DEFINE2(capset, cap_user_header_
15363 int capable(int cap)
15365 + /* here for now so we don't require task locking */
15366 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15368 if (has_capability(current, cap)) {
15369 current->flags |= PF_SUPERPRIV;
15371 diff -NurpP --minimal linux-2.6.27.14/kernel/compat.c linux-2.6.27.14-vs2.3.0.36.4/kernel/compat.c
15372 --- linux-2.6.27.14/kernel/compat.c 2008-07-13 23:51:29.000000000 +0200
15373 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/compat.c 2008-10-13 14:54:20.000000000 +0200
15374 @@ -845,7 +845,7 @@ asmlinkage long compat_sys_time(compat_t
15378 - do_gettimeofday(&tv);
15379 + vx_gettimeofday(&tv);
15383 @@ -869,7 +869,7 @@ asmlinkage long compat_sys_stime(compat_
15387 - do_settimeofday(&tv);
15388 + vx_settimeofday(&tv);
15392 diff -NurpP --minimal linux-2.6.27.14/kernel/exit.c linux-2.6.27.14-vs2.3.0.36.4/kernel/exit.c
15393 --- linux-2.6.27.14/kernel/exit.c 2009-02-03 17:59:55.000000000 +0100
15394 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/exit.c 2009-02-03 17:59:04.000000000 +0100
15396 #include <linux/blkdev.h>
15397 #include <linux/task_io_accounting_ops.h>
15398 #include <linux/tracehook.h>
15399 +#include <linux/vs_limit.h>
15400 +#include <linux/vs_context.h>
15401 +#include <linux/vs_network.h>
15402 +#include <linux/vs_pid.h>
15403 +#include <linux/vserver/global.h>
15405 #include <asm/uaccess.h>
15406 #include <asm/unistd.h>
15407 @@ -485,9 +490,11 @@ static void close_files(struct files_str
15408 filp_close(file, files);
15411 + vx_openfd_dec(i);
15419 @@ -554,6 +561,7 @@ void put_fs_struct(struct fs_struct *fs)
15420 if (atomic_dec_and_test(&fs->count)) {
15421 path_put(&fs->root);
15422 path_put(&fs->pwd);
15423 + atomic_dec(&vs_global_fs);
15424 kmem_cache_free(fs_cachep, fs);
15427 @@ -1122,6 +1130,10 @@ NORET_TYPE void do_exit(long code)
15428 if (tsk->splice_pipe)
15429 __free_pipe_info(tsk->splice_pipe);
15431 + /* needs to stay after exit_notify() */
15432 + exit_vx_info(tsk, code);
15433 + exit_nx_info(tsk);
15436 /* causes final put_task_struct in finish_task_switch(). */
15437 tsk->state = TASK_DEAD;
15438 diff -NurpP --minimal linux-2.6.27.14/kernel/fork.c linux-2.6.27.14-vs2.3.0.36.4/kernel/fork.c
15439 --- linux-2.6.27.14/kernel/fork.c 2009-02-03 17:59:55.000000000 +0100
15440 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/fork.c 2009-02-03 17:59:04.000000000 +0100
15442 #include <linux/tty.h>
15443 #include <linux/proc_fs.h>
15444 #include <linux/blkdev.h>
15445 +#include <linux/vs_context.h>
15446 +#include <linux/vs_network.h>
15447 +#include <linux/vs_limit.h>
15448 +#include <linux/vs_memory.h>
15449 +#include <linux/vserver/global.h>
15451 #include <asm/pgtable.h>
15452 #include <asm/pgalloc.h>
15453 @@ -135,6 +140,8 @@ void free_task(struct task_struct *tsk)
15454 prop_local_destroy_single(&tsk->dirties);
15455 free_thread_info(tsk->stack);
15456 rt_mutex_debug_task_free(tsk);
15457 + clr_vx_info(&tsk->vx_info);
15458 + clr_nx_info(&tsk->nx_info);
15459 free_task_struct(tsk);
15461 EXPORT_SYMBOL(free_task);
15462 @@ -274,6 +281,8 @@ static int dup_mmap(struct mm_struct *mm
15463 mm->free_area_cache = oldmm->mmap_base;
15464 mm->cached_hole_size = ~0UL;
15466 + __set_mm_counter(mm, file_rss, 0);
15467 + __set_mm_counter(mm, anon_rss, 0);
15468 cpus_clear(mm->cpu_vm_mask);
15469 mm->mm_rb = RB_ROOT;
15470 rb_link = &mm->mm_rb.rb_node;
15471 @@ -285,7 +294,7 @@ static int dup_mmap(struct mm_struct *mm
15473 if (mpnt->vm_flags & VM_DONTCOPY) {
15474 long pages = vma_pages(mpnt);
15475 - mm->total_vm -= pages;
15476 + vx_vmpages_sub(mm, pages);
15477 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15480 @@ -407,8 +416,8 @@ static struct mm_struct * mm_init(struct
15481 : MMF_DUMP_FILTER_DEFAULT;
15482 mm->core_state = NULL;
15484 - set_mm_counter(mm, file_rss, 0);
15485 - set_mm_counter(mm, anon_rss, 0);
15486 + __set_mm_counter(mm, file_rss, 0);
15487 + __set_mm_counter(mm, anon_rss, 0);
15488 spin_lock_init(&mm->page_table_lock);
15489 rwlock_init(&mm->ioctx_list_lock);
15490 mm->ioctx_list = NULL;
15491 @@ -419,6 +428,7 @@ static struct mm_struct * mm_init(struct
15492 if (likely(!mm_alloc_pgd(mm))) {
15494 mmu_notifier_mm_init(mm);
15495 + set_vx_info(&mm->mm_vx_info, p->vx_info);
15499 @@ -452,6 +462,7 @@ void __mmdrop(struct mm_struct *mm)
15501 destroy_context(mm);
15502 mmu_notifier_mm_destroy(mm);
15503 + clr_vx_info(&mm->mm_vx_info);
15506 EXPORT_SYMBOL_GPL(__mmdrop);
15507 @@ -568,6 +579,7 @@ struct mm_struct *dup_mm(struct task_str
15510 memcpy(mm, oldmm, sizeof(*mm));
15511 + mm->mm_vx_info = NULL;
15513 /* Initializing for Swap token stuff */
15514 mm->token_priority = 0;
15515 @@ -601,6 +613,7 @@ fail_nocontext:
15516 * If init_new_context() failed, we cannot use mmput() to free the mm
15517 * because it calls destroy_context()
15519 + clr_vx_info(&mm->mm_vx_info);
15523 @@ -664,6 +677,7 @@ static struct fs_struct *__copy_fs_struc
15524 fs->pwd = old->pwd;
15525 path_get(&old->pwd);
15526 read_unlock(&old->lock);
15527 + atomic_inc(&vs_global_fs);
15531 @@ -907,6 +921,8 @@ static struct task_struct *copy_process(
15533 struct task_struct *p;
15534 int cgroup_callbacks_done = 0;
15535 + struct vx_info *vxi;
15536 + struct nx_info *nxi;
15538 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15539 return ERR_PTR(-EINVAL);
15540 @@ -941,12 +957,28 @@ static struct task_struct *copy_process(
15541 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15542 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15544 + init_vx_info(&p->vx_info, current->vx_info);
15545 + init_nx_info(&p->nx_info, current->nx_info);
15547 + /* check vserver memory */
15548 + if (p->mm && !(clone_flags & CLONE_VM)) {
15549 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15550 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15552 + goto bad_fork_free;
15554 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15555 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15556 + goto bad_fork_cleanup_vm;
15559 + if (!vx_nproc_avail(1))
15560 + goto bad_fork_cleanup_vm;
15561 if (atomic_read(&p->user->processes) >=
15562 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15563 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15564 p->user != current->nsproxy->user_ns->root_user)
15565 - goto bad_fork_free;
15566 + goto bad_fork_cleanup_vm;
15569 atomic_inc(&p->user->__count);
15570 @@ -1244,6 +1276,18 @@ static struct task_struct *copy_process(
15573 spin_unlock(¤t->sighand->siglock);
15575 + /* p is copy of current */
15576 + vxi = p->vx_info;
15578 + claim_vx_info(vxi, p);
15579 + atomic_inc(&vxi->cvirt.nr_threads);
15580 + atomic_inc(&vxi->cvirt.total_forks);
15583 + nxi = p->nx_info;
15585 + claim_nx_info(nxi, p);
15586 write_unlock_irq(&tasklist_lock);
15587 proc_fork_connector(p);
15588 cgroup_post_fork(p);
15589 @@ -1290,6 +1334,9 @@ bad_fork_cleanup_count:
15590 put_group_info(p->group_info);
15591 atomic_dec(&p->user->processes);
15593 +bad_fork_cleanup_vm:
15594 + if (p->mm && !(clone_flags & CLONE_VM))
15595 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15599 diff -NurpP --minimal linux-2.6.27.14/kernel/kthread.c linux-2.6.27.14-vs2.3.0.36.4/kernel/kthread.c
15600 --- linux-2.6.27.14/kernel/kthread.c 2008-10-13 14:52:09.000000000 +0200
15601 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/kthread.c 2008-10-13 14:54:20.000000000 +0200
15603 #include <linux/file.h>
15604 #include <linux/module.h>
15605 #include <linux/mutex.h>
15606 +#include <linux/vs_pid.h>
15608 #define KTHREAD_NICE_LEVEL (-5)
15610 @@ -98,7 +99,7 @@ static void create_kthread(struct kthrea
15611 struct sched_param param = { .sched_priority = 0 };
15612 wait_for_completion(&create->started);
15613 read_lock(&tasklist_lock);
15614 - create->result = find_task_by_pid_ns(pid, &init_pid_ns);
15615 + create->result = find_task_by_real_pid(pid);
15616 read_unlock(&tasklist_lock);
15618 * root may have changed our (kthreadd's) priority or CPU mask.
15619 diff -NurpP --minimal linux-2.6.27.14/kernel/Makefile linux-2.6.27.14-vs2.3.0.36.4/kernel/Makefile
15620 --- linux-2.6.27.14/kernel/Makefile 2009-02-03 17:59:55.000000000 +0100
15621 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/Makefile 2009-02-03 17:59:04.000000000 +0100
15622 @@ -22,6 +22,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
15623 CFLAGS_REMOVE_sched.o = -pg
15627 obj-$(CONFIG_PROFILING) += profile.o
15628 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15629 obj-$(CONFIG_STACKTRACE) += stacktrace.o
15630 diff -NurpP --minimal linux-2.6.27.14/kernel/nsproxy.c linux-2.6.27.14-vs2.3.0.36.4/kernel/nsproxy.c
15631 --- linux-2.6.27.14/kernel/nsproxy.c 2008-10-13 14:52:09.000000000 +0200
15632 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/nsproxy.c 2008-10-13 14:54:20.000000000 +0200
15634 #include <linux/mnt_namespace.h>
15635 #include <linux/utsname.h>
15636 #include <linux/pid_namespace.h>
15637 +#include <linux/vserver/global.h>
15638 +#include <linux/vserver/debug.h>
15639 #include <net/net_namespace.h>
15640 #include <linux/ipc_namespace.h>
15642 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
15644 memcpy(ns, orig, sizeof(struct nsproxy));
15645 atomic_set(&ns->count, 1);
15646 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
15647 + orig, atomic_read(&orig->count), ns);
15648 + atomic_inc(&vs_global_nsproxy);
15652 @@ -46,47 +51,51 @@ static inline struct nsproxy *clone_nspr
15653 * Return the newly created nsproxy. Do not attach this to the task,
15654 * leave it to the caller to do proper locking and attach it to task.
15656 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15657 - struct task_struct *tsk, struct fs_struct *new_fs)
15658 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15659 + struct nsproxy *orig, struct fs_struct *new_fs)
15661 struct nsproxy *new_nsp;
15664 - new_nsp = clone_nsproxy(tsk->nsproxy);
15665 + vxdprintk(VXD_CBIT(space, 4),
15666 + "unshare_namespaces(0x%08lx,%p,%p)",
15667 + flags, orig, new_fs);
15669 + new_nsp = clone_nsproxy(orig);
15671 return ERR_PTR(-ENOMEM);
15673 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15674 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15675 if (IS_ERR(new_nsp->mnt_ns)) {
15676 err = PTR_ERR(new_nsp->mnt_ns);
15680 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15681 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15682 if (IS_ERR(new_nsp->uts_ns)) {
15683 err = PTR_ERR(new_nsp->uts_ns);
15687 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15688 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15689 if (IS_ERR(new_nsp->ipc_ns)) {
15690 err = PTR_ERR(new_nsp->ipc_ns);
15694 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15695 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15696 if (IS_ERR(new_nsp->pid_ns)) {
15697 err = PTR_ERR(new_nsp->pid_ns);
15701 - new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
15702 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15703 if (IS_ERR(new_nsp->user_ns)) {
15704 err = PTR_ERR(new_nsp->user_ns);
15708 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15709 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15710 if (IS_ERR(new_nsp->net_ns)) {
15711 err = PTR_ERR(new_nsp->net_ns);
15713 @@ -114,6 +123,37 @@ out_ns:
15714 return ERR_PTR(err);
15717 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15718 + struct fs_struct *new_fs)
15720 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15724 + * copies the nsproxy, setting refcount to 1, and grabbing a
15725 + * reference to all contained namespaces.
15727 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15729 + struct nsproxy *ns = clone_nsproxy(orig);
15733 + get_mnt_ns(ns->mnt_ns);
15735 + get_uts_ns(ns->uts_ns);
15737 + get_ipc_ns(ns->ipc_ns);
15739 + get_pid_ns(ns->pid_ns);
15741 + get_user_ns(ns->user_ns);
15743 + get_net(ns->net_ns);
15749 * called from clone. This now handles copy for nsproxy and all
15750 * namespaces therein.
15751 @@ -121,9 +161,12 @@ out_ns:
15752 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15754 struct nsproxy *old_ns = tsk->nsproxy;
15755 - struct nsproxy *new_ns;
15756 + struct nsproxy *new_ns = NULL;
15759 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15760 + flags, tsk, old_ns);
15765 @@ -160,6 +203,9 @@ int copy_namespaces(unsigned long flags,
15768 put_nsproxy(old_ns);
15769 + vxdprintk(VXD_CBIT(space, 3),
15770 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15771 + flags, tsk, old_ns, err, new_ns);
15775 @@ -175,7 +221,9 @@ void free_nsproxy(struct nsproxy *ns)
15776 put_pid_ns(ns->pid_ns);
15778 put_user_ns(ns->user_ns);
15779 - put_net(ns->net_ns);
15781 + put_net(ns->net_ns);
15782 + atomic_dec(&vs_global_nsproxy);
15783 kmem_cache_free(nsproxy_cachep, ns);
15786 @@ -188,6 +236,10 @@ int unshare_nsproxy_namespaces(unsigned
15790 + vxdprintk(VXD_CBIT(space, 4),
15791 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15792 + unshare_flags, current->nsproxy);
15794 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15795 CLONE_NEWUSER | CLONE_NEWNET)))
15797 diff -NurpP --minimal linux-2.6.27.14/kernel/pid.c linux-2.6.27.14-vs2.3.0.36.4/kernel/pid.c
15798 --- linux-2.6.27.14/kernel/pid.c 2008-10-13 14:52:09.000000000 +0200
15799 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/pid.c 2008-10-13 14:54:20.000000000 +0200
15801 #include <linux/pid_namespace.h>
15802 #include <linux/init_task.h>
15803 #include <linux/syscalls.h>
15804 +#include <linux/vs_pid.h>
15805 +#include <linux/vserver/global.h>
15807 #define pid_hashfn(nr, ns) \
15808 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15809 @@ -305,7 +307,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15811 struct pid *find_vpid(int nr)
15813 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15814 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15816 EXPORT_SYMBOL_GPL(find_vpid);
15818 @@ -365,6 +367,9 @@ void transfer_pid(struct task_struct *ol
15819 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15821 struct task_struct *result = NULL;
15823 + if (type == PIDTYPE_REALPID)
15824 + type = PIDTYPE_PID;
15826 struct hlist_node *first;
15827 first = rcu_dereference(pid->tasks[type].first);
15828 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid_type_ns);
15830 struct task_struct *find_task_by_vpid(pid_t vnr)
15832 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
15833 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
15834 current->nsproxy->pid_ns);
15836 EXPORT_SYMBOL(find_task_by_vpid);
15838 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15840 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
15841 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
15843 EXPORT_SYMBOL(find_task_by_pid_ns);
15845 @@ -431,7 +436,7 @@ struct pid *find_get_pid(pid_t nr)
15847 EXPORT_SYMBOL_GPL(find_get_pid);
15849 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15850 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15854 @@ -444,6 +449,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15858 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15860 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15863 pid_t pid_vnr(struct pid *pid)
15865 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15866 diff -NurpP --minimal linux-2.6.27.14/kernel/pid_namespace.c linux-2.6.27.14-vs2.3.0.36.4/kernel/pid_namespace.c
15867 --- linux-2.6.27.14/kernel/pid_namespace.c 2008-10-13 14:52:09.000000000 +0200
15868 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/pid_namespace.c 2008-10-13 14:54:20.000000000 +0200
15870 #include <linux/syscalls.h>
15871 #include <linux/err.h>
15872 #include <linux/acct.h>
15873 +#include <linux/vserver/global.h>
15875 #define BITS_PER_PAGE (PAGE_SIZE*8)
15877 @@ -85,6 +86,7 @@ static struct pid_namespace *create_pid_
15880 kref_init(&ns->kref);
15881 + atomic_inc(&vs_global_pid_ns);
15884 set_bit(0, ns->pidmap[0].page);
15885 @@ -109,6 +111,7 @@ static void destroy_pid_namespace(struct
15887 for (i = 0; i < PIDMAP_ENTRIES; i++)
15888 kfree(ns->pidmap[i].page);
15889 + atomic_dec(&vs_global_pid_ns);
15890 kmem_cache_free(pid_ns_cachep, ns);
15893 diff -NurpP --minimal linux-2.6.27.14/kernel/posix-timers.c linux-2.6.27.14-vs2.3.0.36.4/kernel/posix-timers.c
15894 --- linux-2.6.27.14/kernel/posix-timers.c 2009-02-03 17:59:55.000000000 +0100
15895 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/posix-timers.c 2009-02-03 17:59:04.000000000 +0100
15897 #include <linux/wait.h>
15898 #include <linux/workqueue.h>
15899 #include <linux/module.h>
15900 +#include <linux/vs_context.h>
15903 * Management arrays for POSIX timers. Timers are kept in slab memory
15904 @@ -298,6 +299,12 @@ void do_schedule_next_timer(struct sigin
15906 int posix_timer_event(struct k_itimer *timr, int si_private)
15908 + struct vx_info_save vxis;
15909 + struct vx_info *vxi;
15912 + vxi = task_get_vx_info(timr->it_process);
15913 + enter_vx_info(vxi, &vxis);
15915 * FIXME: if ->sigq is queued we can race with
15916 * dequeue_signal()->do_schedule_next_timer().
15917 @@ -318,10 +325,11 @@ int posix_timer_event(struct k_itimer *t
15919 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
15920 struct task_struct *leader;
15921 - int ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15923 + ret = send_sigqueue(timr->sigq, timr->it_process, 0);
15925 if (likely(ret >= 0))
15929 timr->it_sigev_notify = SIGEV_SIGNAL;
15930 leader = timr->it_process->group_leader;
15931 @@ -329,7 +337,11 @@ int posix_timer_event(struct k_itimer *t
15932 timr->it_process = leader;
15935 - return send_sigqueue(timr->sigq, timr->it_process, 1);
15936 + ret = send_sigqueue(timr->sigq, timr->it_process, 1);
15938 + leave_vx_info(&vxis);
15939 + put_vx_info(vxi);
15942 EXPORT_SYMBOL_GPL(posix_timer_event);
15944 diff -NurpP --minimal linux-2.6.27.14/kernel/printk.c linux-2.6.27.14-vs2.3.0.36.4/kernel/printk.c
15945 --- linux-2.6.27.14/kernel/printk.c 2009-02-03 17:59:55.000000000 +0100
15946 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/printk.c 2009-02-03 17:59:04.000000000 +0100
15948 #include <linux/security.h>
15949 #include <linux/bootmem.h>
15950 #include <linux/syscalls.h>
15951 +#include <linux/vs_cvirt.h>
15953 #include <asm/uaccess.h>
15955 @@ -291,18 +292,13 @@ int do_syslog(int type, char __user *buf
15956 unsigned i, j, limit, count;
15962 error = security_syslog(type);
15967 - case 0: /* Close log */
15969 - case 1: /* Open log */
15971 - case 2: /* Read from log */
15972 + if ((type >= 2) && (type <= 4)) {
15974 if (!buf || len < 0)
15976 @@ -313,6 +309,16 @@ int do_syslog(int type, char __user *buf
15981 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15982 + return vx_do_syslog(type, buf, len);
15985 + case 0: /* Close log */
15987 + case 1: /* Open log */
15989 + case 2: /* Read from log */
15990 error = wait_event_interruptible(log_wait,
15991 (log_start - log_end));
15993 @@ -337,16 +343,6 @@ int do_syslog(int type, char __user *buf
15996 case 3: /* Read last kernel messages */
15998 - if (!buf || len < 0)
16003 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16008 if (count > log_buf_len)
16009 count = log_buf_len;
16010 diff -NurpP --minimal linux-2.6.27.14/kernel/ptrace.c linux-2.6.27.14-vs2.3.0.36.4/kernel/ptrace.c
16011 --- linux-2.6.27.14/kernel/ptrace.c 2009-02-03 17:59:55.000000000 +0100
16012 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/ptrace.c 2009-02-03 17:59:04.000000000 +0100
16014 #include <linux/audit.h>
16015 #include <linux/pid_namespace.h>
16016 #include <linux/syscalls.h>
16017 +#include <linux/vs_context.h>
16019 #include <asm/pgtable.h>
16020 #include <asm/uaccess.h>
16021 @@ -139,6 +140,11 @@ int __ptrace_may_access(struct task_stru
16022 dumpable = get_dumpable(task->mm);
16023 if (!dumpable && !capable(CAP_SYS_PTRACE))
16025 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16027 + if (!vx_check(task->xid, VS_IDENT) &&
16028 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16031 return security_ptrace_may_access(task, mode);
16033 @@ -567,6 +573,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
16038 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16039 + goto out_put_task_struct;
16041 if (request == PTRACE_ATTACH) {
16042 ret = ptrace_attach(child);
16044 diff -NurpP --minimal linux-2.6.27.14/kernel/sched.c linux-2.6.27.14-vs2.3.0.36.4/kernel/sched.c
16045 --- linux-2.6.27.14/kernel/sched.c 2009-02-03 17:59:55.000000000 +0100
16046 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sched.c 2009-02-03 17:59:04.000000000 +0100
16048 #include <linux/debugfs.h>
16049 #include <linux/ctype.h>
16050 #include <linux/ftrace.h>
16051 +#include <linux/vs_sched.h>
16052 +#include <linux/vs_cvirt.h>
16054 #include <asm/tlb.h>
16055 #include <asm/irq_regs.h>
16056 @@ -497,6 +499,16 @@ struct root_domain {
16057 static struct root_domain def_root_domain;
16060 + unsigned long norm_time;
16061 + unsigned long idle_time;
16062 +#ifdef CONFIG_VSERVER_IDLETIME
16065 +#ifdef CONFIG_VSERVER_HARDCPU
16066 + struct list_head hold_queue;
16067 + unsigned long nr_onhold;
16072 * This is the main, per-CPU runqueue data structure.
16073 @@ -1640,6 +1652,7 @@ static void update_avg(u64 *avg, u64 sam
16075 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
16077 + // BUG_ON(p->state & TASK_ONHOLD);
16078 sched_info_queued(p);
16079 p->sched_class->enqueue_task(rq, p, wakeup);
16081 @@ -1837,6 +1850,9 @@ struct migration_req {
16082 struct completion done;
16085 +#include "sched_mon.h"
16089 * The task's runqueue lock must be held.
16090 * Returns true if you have to wait for migration thread.
16091 @@ -1846,6 +1862,7 @@ migrate_task(struct task_struct *p, int
16093 struct rq *rq = task_rq(p);
16095 + vxm_migrate_task(p, rq, dest_cpu);
16097 * If the task is not on a runqueue (and not running), then
16098 * it is sufficient to simply update the task's cpu field.
16099 @@ -2242,6 +2259,12 @@ static int try_to_wake_up(struct task_st
16100 /* might preempt at this point */
16101 rq = task_rq_lock(p, &flags);
16102 old_state = p->state;
16104 + /* we need to unhold suspended tasks
16105 + if (old_state & TASK_ONHOLD) {
16106 + vx_unhold_task(p, rq);
16107 + old_state = p->state;
16109 if (!(old_state & state))
16112 @@ -4067,13 +4090,16 @@ unsigned long long task_sched_runtime(st
16113 void account_user_time(struct task_struct *p, cputime_t cputime)
16115 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16116 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16118 + int nice = (TASK_NICE(p) > 0);
16120 p->utime = cputime_add(p->utime, cputime);
16121 + vx_account_user(vxi, cputime, nice);
16123 /* Add user time to cpustat. */
16124 tmp = cputime_to_cputime64(cputime);
16125 - if (TASK_NICE(p) > 0)
16127 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16129 cpustat->user = cputime64_add(cpustat->user, tmp);
16130 @@ -4120,6 +4146,7 @@ void account_system_time(struct task_str
16133 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16134 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16135 struct rq *rq = this_rq();
16138 @@ -4129,6 +4156,7 @@ void account_system_time(struct task_str
16141 p->stime = cputime_add(p->stime, cputime);
16142 + vx_account_system(vxi, cputime, (p == rq->idle));
16144 /* Add system time to cpustat. */
16145 tmp = cputime_to_cputime64(cputime);
16146 @@ -4963,7 +4991,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16149 if (increment < 0 && !can_nice(current, nice))
16151 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16153 retval = security_task_setnice(current, nice);
16155 diff -NurpP --minimal linux-2.6.27.14/kernel/sched_fair.c linux-2.6.27.14-vs2.3.0.36.4/kernel/sched_fair.c
16156 --- linux-2.6.27.14/kernel/sched_fair.c 2008-10-13 14:52:09.000000000 +0200
16157 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sched_fair.c 2008-10-13 14:54:20.000000000 +0200
16158 @@ -724,6 +724,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16159 check_spread(cfs_rq, se);
16160 if (se != cfs_rq->curr)
16161 __enqueue_entity(cfs_rq, se);
16163 + if (entity_is_task(se))
16164 + vx_activate_task(task_of(se));
16168 @@ -750,6 +753,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16170 if (se != cfs_rq->curr)
16171 __dequeue_entity(cfs_rq, se);
16172 + if (entity_is_task(se))
16173 + vx_deactivate_task(task_of(se));
16174 account_entity_dequeue(cfs_rq, se);
16177 diff -NurpP --minimal linux-2.6.27.14/kernel/sched_hard.h linux-2.6.27.14-vs2.3.0.36.4/kernel/sched_hard.h
16178 --- linux-2.6.27.14/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
16179 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sched_hard.h 2008-10-13 14:54:20.000000000 +0200
16182 +#ifdef CONFIG_VSERVER_IDLELIMIT
16185 + * vx_idle_resched - reschedule after maxidle
16188 +void vx_idle_resched(struct rq *rq)
16190 + /* maybe have a better criterion for paused */
16191 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
16192 + set_need_resched();
16195 +#else /* !CONFIG_VSERVER_IDLELIMIT */
16197 +#define vx_idle_resched(rq)
16199 +#endif /* CONFIG_VSERVER_IDLELIMIT */
16203 +#ifdef CONFIG_VSERVER_IDLETIME
16205 +#define vx_set_rq_min_skip(rq, min) \
16206 + (rq)->idle_skip = (min)
16208 +#define vx_save_min_skip(ret, min, val) \
16209 + __vx_save_min_skip(ret, min, val)
16212 +void __vx_save_min_skip(int ret, int *min, int val)
16216 + if ((*min > val) || !*min)
16221 +int vx_try_skip(struct rq *rq, int cpu)
16223 + /* artificially advance time */
16224 + if (rq->idle_skip > 0) {
16225 + vxdprintk(list_empty(&rq->hold_queue),
16226 + "hold queue empty on cpu %d", cpu);
16227 + rq->idle_time += rq->idle_skip;
16228 + vxm_idle_skip(rq, cpu);
16234 +#else /* !CONFIG_VSERVER_IDLETIME */
16236 +#define vx_set_rq_min_skip(rq, min) \
16237 + ({ int dummy = (min); dummy; })
16239 +#define vx_save_min_skip(ret, min, val)
16242 +int vx_try_skip(struct rq *rq, int cpu)
16247 +#endif /* CONFIG_VSERVER_IDLETIME */
16251 +#ifdef CONFIG_VSERVER_HARDCPU
16253 +#define vx_set_rq_max_idle(rq, max) \
16254 + (rq)->idle_tokens = (max)
16256 +#define vx_save_max_idle(ret, min, val) \
16257 + __vx_save_max_idle(ret, min, val)
16260 +void __vx_save_max_idle(int ret, int *min, int val)
16268 + * vx_hold_task - put a task on the hold queue
16271 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16273 + __deactivate_task(p, rq);
16274 + p->state |= TASK_ONHOLD;
16275 + /* a new one on hold */
16277 + vxm_hold_task(p, rq);
16278 + list_add_tail(&p->run_list, &rq->hold_queue);
16282 + * vx_unhold_task - put a task back to the runqueue
16285 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16287 + list_del(&p->run_list);
16288 + /* one less waiting */
16290 + p->state &= ~TASK_ONHOLD;
16291 + enqueue_task(p, rq->expired);
16292 + inc_nr_running(p, rq);
16293 + vxm_unhold_task(p, rq);
16295 + if (p->static_prio < rq->best_expired_prio)
16296 + rq->best_expired_prio = p->static_prio;
16299 +unsigned long nr_onhold(void)
16301 + unsigned long i, sum = 0;
16303 + for_each_online_cpu(i)
16304 + sum += cpu_rq(i)->nr_onhold;
16312 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
16314 + return sched_pc->tokens;
16318 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16320 + sched_pc->tokens--;
16324 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16326 + struct vx_info *vxi = p->vx_info;
16328 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16329 + struct _vx_sched_pc *sched_pc =
16330 + &vx_per_cpu(vxi, sched_pc, cpu);
16333 + /* maybe we can simplify that to decrement
16334 + the token counter unconditional? */
16336 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
16337 + __vx_consume_token(sched_pc);
16339 + /* for tokens > 0, one token was consumed */
16343 + vxm_need_resched(p, slice, cpu);
16344 + return (slice == 0);
16348 +#define vx_set_rq_time(rq, time) do { \
16349 + rq->norm_time = time; \
16354 +void vx_try_unhold(struct rq *rq, int cpu)
16356 + struct vx_info *vxi = NULL;
16357 + struct list_head *l, *n;
16358 + int maxidle = HZ;
16361 + /* nothing to do? what about pause? */
16362 + if (list_empty(&rq->hold_queue))
16365 + list_for_each_safe(l, n, &rq->hold_queue) {
16366 + int ret, delta_min[2];
16367 + struct _vx_sched_pc *sched_pc;
16368 + struct task_struct *p;
16370 + p = list_entry(l, struct task_struct, run_list);
16371 + /* don't bother with same context */
16372 + if (vxi == p->vx_info)
16375 + vxi = p->vx_info;
16376 + /* ignore paused contexts */
16377 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
16380 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16382 + /* recalc tokens */
16383 + vxm_sched_info(sched_pc, vxi, cpu);
16384 + ret = vx_tokens_recalc(sched_pc,
16385 + &rq->norm_time, &rq->idle_time, delta_min);
16386 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16389 + /* we found a runable context */
16390 + vx_unhold_task(p, rq);
16393 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
16394 + vx_save_min_skip(ret, &minskip, delta_min[1]);
16396 + vx_set_rq_max_idle(rq, maxidle);
16397 + vx_set_rq_min_skip(rq, minskip);
16398 + vxm_rq_max_min(rq, cpu);
16403 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16405 + struct vx_info *vxi = next->vx_info;
16406 + struct _vx_sched_pc *sched_pc;
16407 + int delta_min[2];
16413 + flags = vxi->vx_flags;
16415 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
16416 + goto put_on_hold;
16417 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
16420 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16422 + /* update scheduler params */
16423 + if (cpu_isset(cpu, vxi->sched.update)) {
16424 + vx_update_sched_param(&vxi->sched, sched_pc);
16425 + vxm_update_sched(sched_pc, vxi, cpu);
16426 + cpu_clear(cpu, vxi->sched.update);
16429 + vxm_sched_info(sched_pc, vxi, cpu);
16430 + ret = vx_tokens_recalc(sched_pc,
16431 + &rq->norm_time, &rq->idle_time, delta_min);
16432 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16434 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
16437 + if (unlikely(ret < 0)) {
16438 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
16439 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
16440 + vxm_rq_max_min(rq, cpu);
16442 + vx_hold_task(next, rq);
16449 +#else /* CONFIG_VSERVER_HARDCPU */
16452 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16458 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16463 +unsigned long nr_onhold(void)
16470 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16472 + return (slice == 0);
16476 +#define vx_set_rq_time(rq, time)
16479 +void vx_try_unhold(struct rq *rq, int cpu)
16485 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16487 + struct vx_info *vxi = next->vx_info;
16488 + struct _vx_sched_pc *sched_pc;
16489 + int delta_min[2];
16492 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
16495 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16496 + vxm_sched_info(sched_pc, vxi, cpu);
16497 + ret = vx_tokens_recalc(sched_pc,
16498 + &rq->norm_time, &rq->idle_time, delta_min);
16499 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16503 +#endif /* CONFIG_VSERVER_HARDCPU */
16505 diff -NurpP --minimal linux-2.6.27.14/kernel/sched_mon.h linux-2.6.27.14-vs2.3.0.36.4/kernel/sched_mon.h
16506 --- linux-2.6.27.14/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
16507 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sched_mon.h 2008-10-13 14:54:20.000000000 +0200
16510 +#include <linux/vserver/monitor.h>
16512 +#ifdef CONFIG_VSERVER_MONITOR
16514 +#ifdef CONFIG_VSERVER_HARDCPU
16515 +#define HARDCPU(x) (x)
16517 +#define HARDCPU(x) (0)
16520 +#ifdef CONFIG_VSERVER_IDLETIME
16521 +#define IDLETIME(x) (x)
16523 +#define IDLETIME(x) (0)
16526 +struct _vx_mon_entry *vxm_advance(int cpu);
16530 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
16532 + entry->type = type;
16533 + entry->xid = xid;
16537 +void __vxm_sync(int cpu)
16539 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16541 + __vxm_basic(entry, 0, VXM_SYNC);
16542 + entry->ev.sec = xtime.tv_sec;
16543 + entry->ev.nsec = xtime.tv_nsec;
16547 +void __vxm_task(struct task_struct *p, int type)
16549 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
16551 + __vxm_basic(entry, p->xid, type);
16552 + entry->ev.tsk.pid = p->pid;
16553 + entry->ev.tsk.state = p->state;
16557 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16559 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16561 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
16562 + entry->sd.tokens = s->tokens;
16563 + entry->sd.norm_time = s->norm_time;
16564 + entry->sd.idle_time = s->idle_time;
16568 +void __vxm_rqinfo1(struct rq *q, int cpu)
16570 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16572 + entry->type = VXM_RQINFO_1;
16573 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
16574 + entry->q1.running = q->nr_running;
16575 + entry->q1.onhold = HARDCPU(q->nr_onhold);
16576 + entry->q1.iowait = atomic_read(&q->nr_iowait);
16577 + entry->q1.uintr = q->nr_uninterruptible;
16578 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
16582 +void __vxm_rqinfo2(struct rq *q, int cpu)
16584 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16586 + entry->type = VXM_RQINFO_2;
16587 + entry->xid = (unsigned long)q & 0xffff;
16588 + entry->q2.norm_time = q->norm_time;
16589 + entry->q2.idle_time = q->idle_time;
16590 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
16594 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16596 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16598 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
16599 + entry->ev.tokens = s->tokens;
16603 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16605 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16607 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
16608 + entry->u1.tokens_max = s->tokens_max;
16609 + entry->u1.fill_rate = s->fill_rate[0];
16610 + entry->u1.interval = s->interval[0];
16614 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16616 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16618 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
16619 + entry->u2.tokens_min = s->tokens_min;
16620 + entry->u2.fill_rate = s->fill_rate[1];
16621 + entry->u2.interval = s->interval[1];
16625 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
16626 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
16627 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
16628 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
16629 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
16632 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
16634 + __vxm_task(p, VXM_MIGRATE);
16635 + __vxm_rqinfo1(rq, task_cpu(p));
16636 + __vxm_rqinfo2(rq, task_cpu(p));
16640 +void vxm_idle_skip(struct rq *rq, int cpu)
16642 + __vxm_rqinfo1(rq, cpu);
16643 + __vxm_rqinfo2(rq, cpu);
16647 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
16652 + __vxm_task(p, VXM_RESCHED);
16656 +void vxm_sync(unsigned long now, int cpu)
16658 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
16659 + (now % CONFIG_VSERVER_MONITOR_SYNC))
16665 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
16668 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
16669 + struct vx_info *vxi, int cpu)
16671 + __vxm_sched(s, vxi, cpu);
16672 + __vxm_rqinfo2(rq, cpu);
16676 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16678 + __vxm_sched(s, vxi, cpu);
16679 + __vxm_update(s, vxi, cpu);
16680 + __vxm_update1(s, vxi, cpu);
16681 + __vxm_update2(s, vxi, cpu);
16685 +void vxm_rq_max_min(struct rq *rq, int cpu)
16687 + __vxm_rqinfo1(rq, cpu);
16688 + __vxm_rqinfo2(rq, cpu);
16691 +#else /* CONFIG_VSERVER_MONITOR */
16693 +#define vxm_activate_task(t,q) do { } while (0)
16694 +#define vxm_activate_idle(t,q) do { } while (0)
16695 +#define vxm_deactivate_task(t,q) do { } while (0)
16696 +#define vxm_hold_task(t,q) do { } while (0)
16697 +#define vxm_unhold_task(t,q) do { } while (0)
16698 +#define vxm_migrate_task(t,q,d) do { } while (0)
16699 +#define vxm_idle_skip(q,c) do { } while (0)
16700 +#define vxm_need_resched(t,s,c) do { } while (0)
16701 +#define vxm_sync(s,c) do { } while (0)
16702 +#define vxm_sched_info(s,v,c) do { } while (0)
16703 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16704 +#define vxm_update_sched(s,v,c) do { } while (0)
16705 +#define vxm_rq_max_min(q,c) do { } while (0)
16707 +#endif /* CONFIG_VSERVER_MONITOR */
16709 diff -NurpP --minimal linux-2.6.27.14/kernel/signal.c linux-2.6.27.14-vs2.3.0.36.4/kernel/signal.c
16710 --- linux-2.6.27.14/kernel/signal.c 2009-02-03 17:59:55.000000000 +0100
16711 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/signal.c 2009-02-03 17:59:04.000000000 +0100
16713 #include <linux/freezer.h>
16714 #include <linux/pid_namespace.h>
16715 #include <linux/nsproxy.h>
16716 +#include <linux/vs_context.h>
16717 +#include <linux/vs_pid.h>
16719 #include <asm/param.h>
16720 #include <asm/uaccess.h>
16721 @@ -571,6 +573,14 @@ static int check_kill_permission(int sig
16722 if (!valid_signal(sig))
16725 + if ((info != SEND_SIG_NOINFO) &&
16726 + (is_si_special(info) || !SI_FROMUSER(info)))
16729 + vxdprintk(VXD_CBIT(misc, 7),
16730 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16731 + sig, info, t, vx_task_xid(t), t->pid);
16733 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
16736 @@ -595,6 +605,18 @@ static int check_kill_permission(int sig
16741 + if (t->pid == 1 && current->xid)
16745 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16746 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16747 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16748 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16752 return security_task_kill(t, info, sig, 0);
16755 @@ -1051,7 +1073,7 @@ int kill_pid_info(int sig, struct siginf
16758 p = pid_task(pid, PIDTYPE_PID);
16760 + if (p && vx_check(vx_task_xid(p), VS_ADMIN | VS_IDENT)) {
16761 error = group_send_sig_info(sig, info, p);
16762 if (unlikely(error == -ESRCH))
16764 @@ -1089,7 +1111,7 @@ int kill_pid_info_as_uid(int sig, struct
16766 read_lock(&tasklist_lock);
16767 p = pid_task(pid, PIDTYPE_PID);
16769 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16773 @@ -1141,8 +1163,10 @@ static int kill_something_info(int sig,
16774 struct task_struct * p;
16776 for_each_process(p) {
16777 - if (task_pid_vnr(p) > 1 &&
16778 - !same_thread_group(p, current)) {
16779 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16780 + task_pid_vnr(p) > 1 &&
16781 + !same_thread_group(p, current) &&
16782 + !vx_current_initpid(p->pid)) {
16783 int err = group_send_sig_info(sig, info, p);
16786 @@ -1815,6 +1839,11 @@ relock:
16787 !signal_group_exit(signal))
16790 + /* virtual init is protected against user signals */
16791 + if ((info->si_code == SI_USER) &&
16792 + vx_current_initpid(current->pid))
16795 if (sig_kernel_stop(signr)) {
16797 * The default action is to stop all threads in
16798 diff -NurpP --minimal linux-2.6.27.14/kernel/softirq.c linux-2.6.27.14-vs2.3.0.36.4/kernel/softirq.c
16799 --- linux-2.6.27.14/kernel/softirq.c 2008-10-13 14:52:09.000000000 +0200
16800 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/softirq.c 2008-10-13 14:54:20.000000000 +0200
16802 #include <linux/rcupdate.h>
16803 #include <linux/smp.h>
16804 #include <linux/tick.h>
16805 +#include <linux/vs_context.h>
16807 #include <asm/irq.h>
16809 diff -NurpP --minimal linux-2.6.27.14/kernel/sys.c linux-2.6.27.14-vs2.3.0.36.4/kernel/sys.c
16810 --- linux-2.6.27.14/kernel/sys.c 2009-02-03 17:59:55.000000000 +0100
16811 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sys.c 2009-02-03 17:59:04.000000000 +0100
16813 #include <linux/syscalls.h>
16814 #include <linux/kprobes.h>
16815 #include <linux/user_namespace.h>
16816 +#include <linux/vs_pid.h>
16818 #include <asm/uaccess.h>
16819 #include <asm/io.h>
16820 @@ -122,7 +123,10 @@ static int set_one_prio(struct task_stru
16823 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
16825 + if (vx_flags(VXF_IGNEG_NICE, 0))
16831 no_nice = security_task_setnice(p, niceval);
16832 @@ -170,6 +174,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
16834 pgrp = task_pgrp(current);
16835 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16836 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16838 error = set_one_prio(p, niceval, error);
16839 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
16841 @@ -230,6 +236,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
16843 pgrp = task_pgrp(current);
16844 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
16845 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
16847 niceval = 20 - task_nice(p);
16848 if (niceval > retval)
16850 @@ -339,6 +347,9 @@ void kernel_power_off(void)
16851 machine_power_off();
16853 EXPORT_SYMBOL_GPL(kernel_power_off);
16855 +long vs_reboot(unsigned int, void __user *);
16858 * Reboot system call: for obvious reasons only root may call it,
16859 * and even root needs to set up some magic numbers in the registers
16860 @@ -370,6 +381,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
16861 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
16862 cmd = LINUX_REBOOT_CMD_HALT;
16864 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16865 + return vs_reboot(cmd, arg);
16869 case LINUX_REBOOT_CMD_RESTART:
16870 @@ -1345,7 +1359,7 @@ SYSCALL_DEFINE2(sethostname, char __user
16872 char tmp[__NEW_UTS_LEN];
16874 - if (!capable(CAP_SYS_ADMIN))
16875 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16877 if (len < 0 || len > __NEW_UTS_LEN)
16879 @@ -1390,7 +1404,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
16881 char tmp[__NEW_UTS_LEN];
16883 - if (!capable(CAP_SYS_ADMIN))
16884 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
16886 if (len < 0 || len > __NEW_UTS_LEN)
16888 @@ -1458,7 +1472,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
16890 old_rlim = current->signal->rlim + resource;
16891 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
16892 - !capable(CAP_SYS_RESOURCE))
16893 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
16895 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
16897 diff -NurpP --minimal linux-2.6.27.14/kernel/sysctl.c linux-2.6.27.14-vs2.3.0.36.4/kernel/sysctl.c
16898 --- linux-2.6.27.14/kernel/sysctl.c 2009-02-03 17:59:55.000000000 +0100
16899 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sysctl.c 2009-02-03 17:59:04.000000000 +0100
16900 @@ -114,6 +114,7 @@ static int ngroups_max = NGROUPS_MAX;
16901 #ifdef CONFIG_MODULES
16902 extern char modprobe_path[];
16904 +extern char vshelper_path[];
16905 #ifdef CONFIG_CHR_DEV_SG
16906 extern int sg_big_buff;
16908 @@ -503,6 +504,15 @@ static struct ctl_table kern_table[] = {
16909 .strategy = &sysctl_string,
16913 + .ctl_name = KERN_VSHELPER,
16914 + .procname = "vshelper",
16915 + .data = &vshelper_path,
16918 + .proc_handler = &proc_dostring,
16919 + .strategy = &sysctl_string,
16921 #ifdef CONFIG_CHR_DEV_SG
16923 .ctl_name = KERN_SG_BIG_BUFF,
16924 diff -NurpP --minimal linux-2.6.27.14/kernel/sysctl_check.c linux-2.6.27.14-vs2.3.0.36.4/kernel/sysctl_check.c
16925 --- linux-2.6.27.14/kernel/sysctl_check.c 2008-10-13 14:52:09.000000000 +0200
16926 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/sysctl_check.c 2008-10-13 14:54:20.000000000 +0200
16927 @@ -39,6 +39,7 @@ static const struct trans_ctl_table tran
16929 { KERN_PANIC, "panic" },
16930 { KERN_REALROOTDEV, "real-root-dev" },
16931 + { KERN_VSHELPER, "vshelper", },
16933 { KERN_SPARC_REBOOT, "reboot-cmd" },
16934 { KERN_CTLALTDEL, "ctrl-alt-del" },
16935 @@ -1217,6 +1218,22 @@ static const struct trans_ctl_table tran
16939 +static struct trans_ctl_table trans_vserver_table[] = {
16940 + { 1, "debug_switch" },
16941 + { 2, "debug_xid" },
16942 + { 3, "debug_nid" },
16943 + { 4, "debug_tag" },
16944 + { 5, "debug_net" },
16945 + { 6, "debug_limit" },
16946 + { 7, "debug_cres" },
16947 + { 8, "debug_dlim" },
16948 + { 9, "debug_quota" },
16949 + { 10, "debug_cvirt" },
16950 + { 11, "debug_space" },
16951 + { 12, "debug_misc" },
16955 static const struct trans_ctl_table trans_root_table[] = {
16956 { CTL_KERN, "kernel", trans_kern_table },
16957 { CTL_VM, "vm", trans_vm_table },
16958 @@ -1233,6 +1250,7 @@ static const struct trans_ctl_table tran
16959 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
16960 { CTL_PM, "pm", trans_pm_table },
16961 { CTL_FRV, "frv", trans_frv_table },
16962 + { CTL_VSERVER, "vserver", trans_vserver_table },
16966 diff -NurpP --minimal linux-2.6.27.14/kernel/time.c linux-2.6.27.14-vs2.3.0.36.4/kernel/time.c
16967 --- linux-2.6.27.14/kernel/time.c 2009-02-03 17:59:55.000000000 +0100
16968 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/time.c 2009-02-03 17:59:04.000000000 +0100
16969 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
16970 SYSCALL_DEFINE1(time, time_t __user *, tloc)
16972 time_t i = get_seconds();
16973 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
16976 if (put_user(i,tloc))
16977 @@ -91,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
16981 - do_settimeofday(&tv);
16982 + vx_settimeofday(&tv);
16986 @@ -102,7 +103,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
16988 if (likely(tv != NULL)) {
16989 struct timeval ktv;
16990 - do_gettimeofday(&ktv);
16991 + vx_gettimeofday(&ktv);
16992 if (copy_to_user(tv, &ktv, sizeof(ktv)))
16995 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec
16996 /* SMP safe, again the code in arch/foo/time.c should
16997 * globally block out interrupts when it runs.
16999 - return do_settimeofday(tv);
17000 + return vx_settimeofday(tv);
17004 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
17008 - do_gettimeofday(&x);
17009 + vx_gettimeofday(&x);
17010 tv->tv_sec = x.tv_sec;
17011 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17013 diff -NurpP --minimal linux-2.6.27.14/kernel/timer.c linux-2.6.27.14-vs2.3.0.36.4/kernel/timer.c
17014 --- linux-2.6.27.14/kernel/timer.c 2009-02-03 17:59:55.000000000 +0100
17015 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/timer.c 2009-02-03 17:59:04.000000000 +0100
17017 #include <linux/delay.h>
17018 #include <linux/tick.h>
17019 #include <linux/kallsyms.h>
17020 +#include <linux/vs_base.h>
17021 +#include <linux/vs_cvirt.h>
17022 +#include <linux/vs_pid.h>
17023 +#include <linux/vserver/sched.h>
17025 #include <asm/uaccess.h>
17026 #include <asm/unistd.h>
17027 @@ -1081,12 +1085,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17034 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17035 - * should be moved into arch/i386 instead?
17039 * sys_getpid - return the thread group id of the current process
17040 @@ -1115,10 +1113,23 @@ SYSCALL_DEFINE0(getppid)
17042 pid = task_tgid_vnr(current->real_parent);
17044 + return vx_map_pid(pid);
17051 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17054 +asmlinkage long do_getxpid(long *ppid)
17056 + *ppid = sys_getppid();
17057 + return sys_getpid();
17060 +#else /* _alpha_ */
17062 SYSCALL_DEFINE0(getuid)
17064 /* Only we change this so SMP safe */
17065 @@ -1289,6 +1300,8 @@ int do_sysinfo(struct sysinfo *info)
17066 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
17069 + if (vx_flags(VXF_VIRT_UPTIME, 0))
17070 + vx_vsi_uptime(&tp, NULL);
17071 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
17073 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
17074 diff -NurpP --minimal linux-2.6.27.14/kernel/user.c linux-2.6.27.14-vs2.3.0.36.4/kernel/user.c
17075 --- linux-2.6.27.14/kernel/user.c 2008-07-13 23:51:29.000000000 +0200
17076 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/user.c 2008-10-13 14:54:20.000000000 +0200
17077 @@ -243,12 +243,15 @@ static struct kobj_type uids_ktype = {
17080 /* create /sys/kernel/uids/<uid>/cpu_share file for this user */
17081 -static int uids_user_create(struct user_struct *up)
17082 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17084 struct kobject *kobj = &up->kobj;
17088 memset(kobj, 0, sizeof(struct kobject));
17089 + if (ns != &init_user_ns)
17092 kobj->kset = uids_kset;
17093 error = kobject_init_and_add(kobj, &uids_ktype, NULL, "%d", up->uid);
17095 @@ -272,7 +275,7 @@ int __init uids_sysfs_init(void)
17099 - return uids_user_create(&root_user);
17100 + return uids_user_create(NULL, &root_user);
17103 /* work function to remove sysfs directory for a user and free up
17104 @@ -302,9 +305,11 @@ static void remove_user_sysfs_dir(struct
17108 - kobject_uevent(&up->kobj, KOBJ_REMOVE);
17109 - kobject_del(&up->kobj);
17110 - kobject_put(&up->kobj);
17111 + if (up->kobj.name) {
17112 + kobject_uevent(&up->kobj, KOBJ_REMOVE);
17113 + kobject_del(&up->kobj);
17114 + kobject_put(&up->kobj);
17117 sched_destroy_user(up);
17118 key_put(up->uid_keyring);
17119 @@ -332,7 +337,8 @@ static inline void free_user(struct user
17120 #else /* CONFIG_USER_SCHED && CONFIG_SYSFS */
17122 int uids_sysfs_init(void) { return 0; }
17123 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17124 +static inline int uids_user_create(struct user_namespace *ns,
17125 + struct user_struct *up) { return 0; }
17126 static inline void uids_mutex_lock(void) { }
17127 static inline void uids_mutex_unlock(void) { }
17129 @@ -409,7 +415,7 @@ struct user_struct *alloc_uid(struct use
17130 if (sched_create_user(new) < 0)
17131 goto out_free_user;
17133 - if (uids_user_create(new))
17134 + if (uids_user_create(ns, new))
17135 goto out_destoy_sched;
17138 diff -NurpP --minimal linux-2.6.27.14/kernel/user_namespace.c linux-2.6.27.14-vs2.3.0.36.4/kernel/user_namespace.c
17139 --- linux-2.6.27.14/kernel/user_namespace.c 2008-10-13 14:52:09.000000000 +0200
17140 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/user_namespace.c 2008-10-13 14:54:20.000000000 +0200
17142 #include <linux/nsproxy.h>
17143 #include <linux/slab.h>
17144 #include <linux/user_namespace.h>
17145 +#include <linux/vserver/global.h>
17148 * Clone a new ns copying an original user ns, setting refcount to 1
17149 @@ -26,6 +27,7 @@ static struct user_namespace *clone_user
17150 return ERR_PTR(-ENOMEM);
17152 kref_init(&ns->kref);
17153 + atomic_inc(&vs_global_user_ns);
17155 for (n = 0; n < UIDHASH_SZ; ++n)
17156 INIT_HLIST_HEAD(ns->uidhash_table + n);
17157 @@ -71,6 +73,7 @@ void free_user_ns(struct kref *kref)
17159 ns = container_of(kref, struct user_namespace, kref);
17161 + atomic_dec(&vs_global_user_ns);
17164 EXPORT_SYMBOL(free_user_ns);
17165 diff -NurpP --minimal linux-2.6.27.14/kernel/utsname.c linux-2.6.27.14-vs2.3.0.36.4/kernel/utsname.c
17166 --- linux-2.6.27.14/kernel/utsname.c 2008-10-13 14:52:09.000000000 +0200
17167 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/utsname.c 2008-10-13 14:54:20.000000000 +0200
17169 #include <linux/utsname.h>
17170 #include <linux/err.h>
17171 #include <linux/slab.h>
17172 +#include <linux/vserver/global.h>
17175 * Clone a new ns copying an original utsname, setting refcount to 1
17176 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
17177 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17179 kref_init(&ns->kref);
17180 + atomic_inc(&vs_global_uts_ns);
17184 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
17185 struct uts_namespace *ns;
17187 ns = container_of(kref, struct uts_namespace, kref);
17188 + atomic_dec(&vs_global_uts_ns);
17191 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/cacct.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cacct.c
17192 --- linux-2.6.27.14/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17193 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cacct.c 2008-10-13 14:54:20.000000000 +0200
17196 + * linux/kernel/vserver/cacct.c
17198 + * Virtual Server: Context Accounting
17200 + * Copyright (C) 2006-2007 Herbert Pötzl
17202 + * V0.01 added accounting stats
17206 +#include <linux/types.h>
17207 +#include <linux/vs_context.h>
17208 +#include <linux/vserver/cacct_cmd.h>
17209 +#include <linux/vserver/cacct_int.h>
17211 +#include <asm/errno.h>
17212 +#include <asm/uaccess.h>
17215 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17217 + struct vcmd_sock_stat_v0 vc_data;
17220 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17223 + field = vc_data.field;
17224 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17227 + for (j = 0; j < 3; j++) {
17228 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17229 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17232 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17237 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/cacct_init.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cacct_init.h
17238 --- linux-2.6.27.14/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17239 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cacct_init.h 2008-10-13 14:54:20.000000000 +0200
17243 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17248 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17249 + for (j = 0; j < 3; j++) {
17250 + atomic_set(&cacct->sock[i][j].count, 0);
17251 + atomic_set(&cacct->sock[i][j].total, 0);
17254 + for (i = 0; i < 8; i++)
17255 + atomic_set(&cacct->slab[i], 0);
17256 + for (i = 0; i < 5; i++)
17257 + for (j = 0; j < 4; j++)
17258 + atomic_set(&cacct->page[i][j], 0);
17261 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17266 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/cacct_proc.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cacct_proc.h
17267 --- linux-2.6.27.14/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17268 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cacct_proc.h 2008-10-13 14:54:20.000000000 +0200
17270 +#ifndef _VX_CACCT_PROC_H
17271 +#define _VX_CACCT_PROC_H
17273 +#include <linux/vserver/cacct_int.h>
17276 +#define VX_SOCKA_TOP \
17277 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17279 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17281 + int i, j, length = 0;
17282 + static char *type[VXA_SOCK_SIZE] = {
17283 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17286 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17287 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17288 + length += sprintf(buffer + length, "%s:", type[i]);
17289 + for (j = 0; j < 3; j++) {
17290 + length += sprintf(buffer + length,
17291 + "\t%10lu/%-10lu",
17292 + vx_sock_count(cacct, i, j),
17293 + vx_sock_total(cacct, i, j));
17295 + buffer[length++] = '\n';
17298 + length += sprintf(buffer + length, "\n");
17299 + length += sprintf(buffer + length,
17300 + "slab:\t %8u %8u %8u %8u\n",
17301 + atomic_read(&cacct->slab[1]),
17302 + atomic_read(&cacct->slab[4]),
17303 + atomic_read(&cacct->slab[0]),
17304 + atomic_read(&cacct->slab[2]));
17306 + length += sprintf(buffer + length, "\n");
17307 + for (i = 0; i < 5; i++) {
17308 + length += sprintf(buffer + length,
17309 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17310 + atomic_read(&cacct->page[i][0]),
17311 + atomic_read(&cacct->page[i][1]),
17312 + atomic_read(&cacct->page[i][2]),
17313 + atomic_read(&cacct->page[i][3]),
17314 + atomic_read(&cacct->page[i][4]),
17315 + atomic_read(&cacct->page[i][5]),
17316 + atomic_read(&cacct->page[i][6]),
17317 + atomic_read(&cacct->page[i][7]));
17322 +#endif /* _VX_CACCT_PROC_H */
17323 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/context.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/context.c
17324 --- linux-2.6.27.14/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17325 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/context.c 2008-10-31 03:56:55.000000000 +0100
17328 + * linux/kernel/vserver/context.c
17330 + * Virtual Server: Context Support
17332 + * Copyright (C) 2003-2007 Herbert Pötzl
17334 + * V0.01 context helper
17335 + * V0.02 vx_ctx_kill syscall command
17336 + * V0.03 replaced context_info calls
17337 + * V0.04 redesign of struct (de)alloc
17338 + * V0.05 rlimit basic implementation
17339 + * V0.06 task_xid and info commands
17340 + * V0.07 context flags and caps
17341 + * V0.08 switch to RCU based hash
17342 + * V0.09 revert to non RCU for now
17343 + * V0.10 and back to working RCU hash
17344 + * V0.11 and back to locking again
17345 + * V0.12 referenced context store
17346 + * V0.13 separate per cpu data
17347 + * V0.14 changed vcmds to vxi arg
17348 + * V0.15 added context stat
17349 + * V0.16 have __create claim() the vxi
17350 + * V0.17 removed older and legacy stuff
17354 +#include <linux/slab.h>
17355 +#include <linux/types.h>
17356 +#include <linux/security.h>
17357 +#include <linux/pid_namespace.h>
17359 +#include <linux/vserver/context.h>
17360 +#include <linux/vserver/network.h>
17361 +#include <linux/vserver/debug.h>
17362 +#include <linux/vserver/limit.h>
17363 +#include <linux/vserver/limit_int.h>
17364 +#include <linux/vserver/space.h>
17366 +#include <linux/vs_context.h>
17367 +#include <linux/vs_limit.h>
17368 +#include <linux/vs_pid.h>
17369 +#include <linux/vserver/context_cmd.h>
17371 +#include "cvirt_init.h"
17372 +#include "cacct_init.h"
17373 +#include "limit_init.h"
17374 +#include "sched_init.h"
17377 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17378 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17381 +/* now inactive context structures */
17383 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17385 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17388 +/* __alloc_vx_info()
17390 + * allocate an initialized vx_info struct
17391 + * doesn't make it visible (hash) */
17393 +static struct vx_info *__alloc_vx_info(xid_t xid)
17395 + struct vx_info *new = NULL;
17398 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17400 + /* would this benefit from a slab cache? */
17401 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17405 + memset(new, 0, sizeof(struct vx_info));
17407 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17408 + if (!new->ptr_pc)
17411 + new->vx_id = xid;
17412 + INIT_HLIST_NODE(&new->vx_hlist);
17413 + atomic_set(&new->vx_usecnt, 0);
17414 + atomic_set(&new->vx_tasks, 0);
17415 + new->vx_parent = NULL;
17416 + new->vx_state = 0;
17417 + init_waitqueue_head(&new->vx_wait);
17419 + /* prepare reaper */
17420 + get_task_struct(init_pid_ns.child_reaper);
17421 + new->vx_reaper = init_pid_ns.child_reaper;
17422 + new->vx_badness_bias = 0;
17424 + /* rest of init goes here */
17425 + vx_info_init_limit(&new->limit);
17426 + vx_info_init_sched(&new->sched);
17427 + vx_info_init_cvirt(&new->cvirt);
17428 + vx_info_init_cacct(&new->cacct);
17430 + /* per cpu data structures */
17431 + for_each_possible_cpu(cpu) {
17432 + vx_info_init_sched_pc(
17433 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17434 + vx_info_init_cvirt_pc(
17435 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17438 + new->vx_flags = VXF_INIT_SET;
17439 + cap_set_init_eff(new->vx_bcaps);
17440 + new->vx_ccaps = 0;
17441 + // new->vx_cap_bset = current->cap_bset;
17443 + new->reboot_cmd = 0;
17444 + new->exit_code = 0;
17446 + vxdprintk(VXD_CBIT(xid, 0),
17447 + "alloc_vx_info(%d) = %p", xid, new);
17448 + vxh_alloc_vx_info(new);
17449 + atomic_inc(&vx_global_ctotal);
17458 +/* __dealloc_vx_info()
17460 + * final disposal of vx_info */
17462 +static void __dealloc_vx_info(struct vx_info *vxi)
17464 + struct vx_info_save vxis;
17467 + vxdprintk(VXD_CBIT(xid, 0),
17468 + "dealloc_vx_info(%p)", vxi);
17469 + vxh_dealloc_vx_info(vxi);
17471 +#ifdef CONFIG_VSERVER_WARN
17472 + enter_vx_info(vxi, &vxis);
17473 + vx_info_exit_limit(&vxi->limit);
17474 + vx_info_exit_sched(&vxi->sched);
17475 + vx_info_exit_cvirt(&vxi->cvirt);
17476 + vx_info_exit_cacct(&vxi->cacct);
17478 + for_each_possible_cpu(cpu) {
17479 + vx_info_exit_sched_pc(
17480 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17481 + vx_info_exit_cvirt_pc(
17482 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17484 + leave_vx_info(&vxis);
17488 + vxi->vx_state |= VXS_RELEASED;
17491 + free_percpu(vxi->ptr_pc);
17494 + atomic_dec(&vx_global_ctotal);
17497 +static void __shutdown_vx_info(struct vx_info *vxi)
17499 + struct nsproxy *nsproxy;
17500 + struct fs_struct *fs;
17505 + vxi->vx_state |= VXS_SHUTDOWN;
17506 + vs_state_change(vxi, VSC_SHUTDOWN);
17508 + for (index = 0; index < VX_SPACES; index++) {
17509 + nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17511 + put_nsproxy(nsproxy);
17513 + fs = xchg(&vxi->vx_fs[index], NULL);
17515 + put_fs_struct(fs);
17519 +/* exported stuff */
17521 +void free_vx_info(struct vx_info *vxi)
17523 + unsigned long flags;
17526 + /* check for reference counts first */
17527 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17528 + BUG_ON(atomic_read(&vxi->vx_tasks));
17530 + /* context must not be hashed */
17531 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17533 + /* context shutdown is mandatory */
17534 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17536 + /* nsproxy and fs check */
17537 + for (index = 0; index < VX_SPACES; index++) {
17538 + BUG_ON(vxi->vx_nsproxy[index]);
17539 + BUG_ON(vxi->vx_fs[index]);
17542 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17543 + hlist_del(&vxi->vx_hlist);
17544 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17546 + __dealloc_vx_info(vxi);
17550 +/* hash table for vx_info hash */
17552 +#define VX_HASH_SIZE 13
17554 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17555 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17557 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17560 +static inline unsigned int __hashval(xid_t xid)
17562 + return (xid % VX_HASH_SIZE);
17567 +/* __hash_vx_info()
17569 + * add the vxi to the global hash table
17570 + * requires the hash_lock to be held */
17572 +static inline void __hash_vx_info(struct vx_info *vxi)
17574 + struct hlist_head *head;
17576 + vxd_assert_lock(&vx_info_hash_lock);
17577 + vxdprintk(VXD_CBIT(xid, 4),
17578 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17579 + vxh_hash_vx_info(vxi);
17581 + /* context must not be hashed */
17582 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17584 + vxi->vx_state |= VXS_HASHED;
17585 + head = &vx_info_hash[__hashval(vxi->vx_id)];
17586 + hlist_add_head(&vxi->vx_hlist, head);
17587 + atomic_inc(&vx_global_cactive);
17590 +/* __unhash_vx_info()
17592 + * remove the vxi from the global hash table
17593 + * requires the hash_lock to be held */
17595 +static inline void __unhash_vx_info(struct vx_info *vxi)
17597 + unsigned long flags;
17599 + vxd_assert_lock(&vx_info_hash_lock);
17600 + vxdprintk(VXD_CBIT(xid, 4),
17601 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17602 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17603 + vxh_unhash_vx_info(vxi);
17605 + /* context must be hashed */
17606 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17607 + /* but without tasks */
17608 + BUG_ON(atomic_read(&vxi->vx_tasks));
17610 + vxi->vx_state &= ~VXS_HASHED;
17611 + hlist_del_init(&vxi->vx_hlist);
17612 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17613 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17614 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17615 + atomic_dec(&vx_global_cactive);
17619 +/* __lookup_vx_info()
17621 + * requires the hash_lock to be held
17622 + * doesn't increment the vx_refcnt */
17624 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17626 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17627 + struct hlist_node *pos;
17628 + struct vx_info *vxi;
17630 + vxd_assert_lock(&vx_info_hash_lock);
17631 + hlist_for_each(pos, head) {
17632 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17634 + if (vxi->vx_id == xid)
17639 + vxdprintk(VXD_CBIT(xid, 0),
17640 + "__lookup_vx_info(#%u): %p[#%u]",
17641 + xid, vxi, vxi ? vxi->vx_id : 0);
17642 + vxh_lookup_vx_info(vxi, xid);
17647 +/* __create_vx_info()
17649 + * create the requested context
17650 + * get(), claim() and hash it */
17652 +static struct vx_info *__create_vx_info(int id)
17654 + struct vx_info *new, *vxi = NULL;
17656 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17658 + if (!(new = __alloc_vx_info(id)))
17659 + return ERR_PTR(-ENOMEM);
17661 + /* required to make dynamic xids unique */
17662 + spin_lock(&vx_info_hash_lock);
17664 + /* static context requested */
17665 + if ((vxi = __lookup_vx_info(id))) {
17666 + vxdprintk(VXD_CBIT(xid, 0),
17667 + "create_vx_info(%d) = %p (already there)", id, vxi);
17668 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17669 + vxi = ERR_PTR(-EBUSY);
17671 + vxi = ERR_PTR(-EEXIST);
17674 + /* new context */
17675 + vxdprintk(VXD_CBIT(xid, 0),
17676 + "create_vx_info(%d) = %p (new)", id, new);
17677 + claim_vx_info(new, NULL);
17678 + __hash_vx_info(get_vx_info(new));
17679 + vxi = new, new = NULL;
17682 + spin_unlock(&vx_info_hash_lock);
17683 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17685 + __dealloc_vx_info(new);
17690 +/* exported stuff */
17693 +void unhash_vx_info(struct vx_info *vxi)
17695 + __shutdown_vx_info(vxi);
17696 + spin_lock(&vx_info_hash_lock);
17697 + __unhash_vx_info(vxi);
17698 + spin_unlock(&vx_info_hash_lock);
17699 + __wakeup_vx_info(vxi);
17703 +/* lookup_vx_info()
17705 + * search for a vx_info and get() it
17706 + * negative id means current */
17708 +struct vx_info *lookup_vx_info(int id)
17710 + struct vx_info *vxi = NULL;
17713 + vxi = get_vx_info(current->vx_info);
17714 + } else if (id > 1) {
17715 + spin_lock(&vx_info_hash_lock);
17716 + vxi = get_vx_info(__lookup_vx_info(id));
17717 + spin_unlock(&vx_info_hash_lock);
17722 +/* xid_is_hashed()
17724 + * verify that xid is still hashed */
17726 +int xid_is_hashed(xid_t xid)
17730 + spin_lock(&vx_info_hash_lock);
17731 + hashed = (__lookup_vx_info(xid) != NULL);
17732 + spin_unlock(&vx_info_hash_lock);
17736 +#ifdef CONFIG_PROC_FS
17740 + * get a subset of hashed xids for proc
17741 + * assumes size is at least one */
17743 +int get_xid_list(int index, unsigned int *xids, int size)
17745 + int hindex, nr_xids = 0;
17747 + /* only show current and children */
17748 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
17751 + xids[nr_xids] = vx_current_xid();
17755 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
17756 + struct hlist_head *head = &vx_info_hash[hindex];
17757 + struct hlist_node *pos;
17759 + spin_lock(&vx_info_hash_lock);
17760 + hlist_for_each(pos, head) {
17761 + struct vx_info *vxi;
17766 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17767 + xids[nr_xids] = vxi->vx_id;
17768 + if (++nr_xids >= size) {
17769 + spin_unlock(&vx_info_hash_lock);
17773 + /* keep the lock time short */
17774 + spin_unlock(&vx_info_hash_lock);
17781 +#ifdef CONFIG_VSERVER_DEBUG
17783 +void dump_vx_info_inactive(int level)
17785 + struct hlist_node *entry, *next;
17787 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
17788 + struct vx_info *vxi =
17789 + list_entry(entry, struct vx_info, vx_hlist);
17791 + dump_vx_info(vxi, level);
17798 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
17800 + struct user_struct *new_user, *old_user;
17805 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
17808 + new_user = alloc_uid(vxi->vx_id, p->uid);
17812 + old_user = p->user;
17813 + if (new_user != old_user) {
17814 + atomic_inc(&new_user->processes);
17815 + atomic_dec(&old_user->processes);
17816 + p->user = new_user;
17818 + free_uid(old_user);
17824 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
17826 + // p->cap_effective &= vxi->vx_cap_bset;
17827 + p->cap_effective =
17828 + cap_intersect(p->cap_effective, vxi->cap_bset);
17829 + // p->cap_inheritable &= vxi->vx_cap_bset;
17830 + p->cap_inheritable =
17831 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
17832 + // p->cap_permitted &= vxi->vx_cap_bset;
17833 + p->cap_permitted =
17834 + cap_intersect(p->cap_permitted, vxi->cap_bset);
17839 +#include <linux/file.h>
17840 +#include <linux/fdtable.h>
17842 +static int vx_openfd_task(struct task_struct *tsk)
17844 + struct files_struct *files = tsk->files;
17845 + struct fdtable *fdt;
17846 + const unsigned long *bptr;
17847 + int count, total;
17849 + /* no rcu_read_lock() because of spin_lock() */
17850 + spin_lock(&files->file_lock);
17851 + fdt = files_fdtable(files);
17852 + bptr = fdt->open_fds->fds_bits;
17853 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
17854 + for (total = 0; count > 0; count--) {
17856 + total += hweight_long(*bptr);
17859 + spin_unlock(&files->file_lock);
17864 +/* for *space compatibility */
17866 +asmlinkage long sys_unshare(unsigned long);
17869 + * migrate task to new context
17870 + * gets vxi, puts old_vxi on change
17871 + * optionally unshares namespaces (hack)
17874 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
17876 + struct vx_info *old_vxi;
17882 + vxdprintk(VXD_CBIT(xid, 5),
17883 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
17884 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
17886 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
17887 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17890 + if (vx_info_state(vxi, VXS_SHUTDOWN))
17893 + old_vxi = task_get_vx_info(p);
17894 + if (old_vxi == vxi)
17897 +// if (!(ret = vx_migrate_user(p, vxi))) {
17902 + openfd = vx_openfd_task(p);
17905 + atomic_dec(&old_vxi->cvirt.nr_threads);
17906 + atomic_dec(&old_vxi->cvirt.nr_running);
17907 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
17908 + /* FIXME: what about the struct files here? */
17909 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
17910 + /* account for the executable */
17911 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
17913 + atomic_inc(&vxi->cvirt.nr_threads);
17914 + atomic_inc(&vxi->cvirt.nr_running);
17915 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
17916 + /* FIXME: what about the struct files here? */
17917 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
17918 + /* account for the executable */
17919 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
17922 + release_vx_info(old_vxi, p);
17923 + clr_vx_info(&p->vx_info);
17925 + claim_vx_info(vxi, p);
17926 + set_vx_info(&p->vx_info, vxi);
17927 + p->xid = vxi->vx_id;
17929 + vxdprintk(VXD_CBIT(xid, 5),
17930 + "moved task %p into vxi:%p[#%d]",
17931 + p, vxi, vxi->vx_id);
17933 + // vx_mask_cap_bset(vxi, p);
17936 + /* hack for *spaces to provide compatibility */
17938 + struct nsproxy *old_nsp, *new_nsp;
17940 + ret = unshare_nsproxy_namespaces(
17941 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
17946 + old_nsp = xchg(&p->nsproxy, new_nsp);
17947 + vx_set_space(vxi,
17948 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
17949 + put_nsproxy(old_nsp);
17953 + put_vx_info(old_vxi);
17957 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
17959 + struct task_struct *old_reaper;
17964 + vxdprintk(VXD_CBIT(xid, 6),
17965 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
17966 + vxi, vxi->vx_id, p, p->xid, p->pid);
17968 + old_reaper = vxi->vx_reaper;
17969 + if (old_reaper == p)
17972 + /* set new child reaper */
17973 + get_task_struct(p);
17974 + vxi->vx_reaper = p;
17975 + put_task_struct(old_reaper);
17979 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
17984 + vxdprintk(VXD_CBIT(xid, 6),
17985 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
17986 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17988 + vxi->vx_flags &= ~VXF_STATE_INIT;
17989 + vxi->vx_initpid = p->tgid;
17993 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
17995 + vxdprintk(VXD_CBIT(xid, 6),
17996 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
17997 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
17999 + vxi->exit_code = code;
18000 + vxi->vx_initpid = 0;
18004 +void vx_set_persistent(struct vx_info *vxi)
18006 + vxdprintk(VXD_CBIT(xid, 6),
18007 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18009 + get_vx_info(vxi);
18010 + claim_vx_info(vxi, NULL);
18013 +void vx_clear_persistent(struct vx_info *vxi)
18015 + vxdprintk(VXD_CBIT(xid, 6),
18016 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18018 + release_vx_info(vxi, NULL);
18019 + put_vx_info(vxi);
18022 +void vx_update_persistent(struct vx_info *vxi)
18024 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18025 + vx_set_persistent(vxi);
18027 + vx_clear_persistent(vxi);
18031 +/* task must be current or locked */
18033 +void exit_vx_info(struct task_struct *p, int code)
18035 + struct vx_info *vxi = p->vx_info;
18038 + atomic_dec(&vxi->cvirt.nr_threads);
18041 + vxi->exit_code = code;
18042 + release_vx_info(vxi, p);
18046 +void exit_vx_info_early(struct task_struct *p, int code)
18048 + struct vx_info *vxi = p->vx_info;
18051 + if (vxi->vx_initpid == p->tgid)
18052 + vx_exit_init(vxi, p, code);
18053 + if (vxi->vx_reaper == p)
18054 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18059 +/* vserver syscall commands below here */
18061 +/* taks xid and vx_info functions */
18063 +#include <asm/uaccess.h>
18066 +int vc_task_xid(uint32_t id)
18071 + struct task_struct *tsk;
18073 + read_lock(&tasklist_lock);
18074 + tsk = find_task_by_real_pid(id);
18075 + xid = (tsk) ? tsk->xid : -ESRCH;
18076 + read_unlock(&tasklist_lock);
18078 + xid = vx_current_xid();
18083 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18085 + struct vcmd_vx_info_v0 vc_data;
18087 + vc_data.xid = vxi->vx_id;
18088 + vc_data.initpid = vxi->vx_initpid;
18090 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18096 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18098 + struct vcmd_ctx_stat_v0 vc_data;
18100 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18101 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18103 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18109 +/* context functions */
18111 +int vc_ctx_create(uint32_t xid, void __user *data)
18113 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18114 + struct vx_info *new_vxi;
18117 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18120 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18123 + new_vxi = __create_vx_info(xid);
18124 + if (IS_ERR(new_vxi))
18125 + return PTR_ERR(new_vxi);
18127 + /* initial flags */
18128 + new_vxi->vx_flags = vc_data.flagword;
18131 + if (vs_state_change(new_vxi, VSC_STARTUP))
18134 + ret = vx_migrate_task(current, new_vxi, (!data));
18138 + /* return context id on success */
18139 + ret = new_vxi->vx_id;
18141 + /* get a reference for persistent contexts */
18142 + if ((vc_data.flagword & VXF_PERSISTENT))
18143 + vx_set_persistent(new_vxi);
18145 + release_vx_info(new_vxi, NULL);
18146 + put_vx_info(new_vxi);
18151 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18153 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18156 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18159 + ret = vx_migrate_task(current, vxi, 0);
18162 + if (vc_data.flagword & VXM_SET_INIT)
18163 + ret = vx_set_init(vxi, current);
18166 + if (vc_data.flagword & VXM_SET_REAPER)
18167 + ret = vx_set_reaper(vxi, current);
18172 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18174 + struct vcmd_ctx_flags_v0 vc_data;
18176 + vc_data.flagword = vxi->vx_flags;
18178 + /* special STATE flag handling */
18179 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18181 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18186 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18188 + struct vcmd_ctx_flags_v0 vc_data;
18189 + uint64_t mask, trigger;
18191 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18194 + /* special STATE flag handling */
18195 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18196 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18198 + if (vxi == current->vx_info) {
18199 + /* if (trigger & VXF_STATE_SETUP)
18200 + vx_mask_cap_bset(vxi, current); */
18201 + if (trigger & VXF_STATE_INIT) {
18204 + ret = vx_set_init(vxi, current);
18207 + ret = vx_set_reaper(vxi, current);
18213 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18214 + vc_data.flagword, mask);
18215 + if (trigger & VXF_PERSISTENT)
18216 + vx_update_persistent(vxi);
18222 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18224 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18226 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18230 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18232 + kernel_cap_t c = __cap_empty_set;
18234 + c.cap[0] = v & 0xFFFFFFFF;
18235 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18237 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18242 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18245 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18247 + *ccaps = vxi->vx_ccaps;
18252 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18254 + struct vcmd_ctx_caps_v1 vc_data;
18257 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18260 + vc_data.cmask = ~0ULL;
18262 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18267 +static int do_set_caps(struct vx_info *vxi,
18268 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18270 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18273 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18274 + bcaps, bmask, ccaps, cmask);
18276 + vxi->vx_bcaps = cap_t_from_caps(
18277 + vs_mask_flags(bcold, bcaps, bmask));
18278 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18283 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18285 + struct vcmd_ctx_caps_v1 vc_data;
18287 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18290 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18293 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18295 + struct vcmd_bcaps vc_data;
18298 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18301 + vc_data.bmask = ~0ULL;
18303 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18308 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18310 + struct vcmd_bcaps vc_data;
18312 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18315 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18319 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18321 + struct vcmd_badness_v0 vc_data;
18323 + vc_data.bias = vxi->vx_badness_bias;
18325 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18330 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18332 + struct vcmd_badness_v0 vc_data;
18334 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18337 + vxi->vx_badness_bias = vc_data.bias;
18341 +#include <linux/module.h>
18343 +EXPORT_SYMBOL_GPL(free_vx_info);
18345 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/cvirt.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cvirt.c
18346 --- linux-2.6.27.14/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18347 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cvirt.c 2008-10-31 03:49:36.000000000 +0100
18350 + * linux/kernel/vserver/cvirt.c
18352 + * Virtual Server: Context Virtualization
18354 + * Copyright (C) 2004-2007 Herbert Pötzl
18356 + * V0.01 broken out from limit.c
18357 + * V0.02 added utsname stuff
18358 + * V0.03 changed vcmds to vxi arg
18362 +#include <linux/types.h>
18363 +#include <linux/utsname.h>
18364 +#include <linux/vs_cvirt.h>
18365 +#include <linux/vserver/switch.h>
18366 +#include <linux/vserver/cvirt_cmd.h>
18368 +#include <asm/uaccess.h>
18371 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18373 + struct vx_info *vxi = current->vx_info;
18375 + set_normalized_timespec(uptime,
18376 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18377 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18380 + set_normalized_timespec(idle,
18381 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18382 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18386 +uint64_t vx_idle_jiffies(void)
18388 + return init_task.utime + init_task.stime;
18393 +static inline uint32_t __update_loadavg(uint32_t load,
18394 + int wsize, int delta, int n)
18396 + unsigned long long calc, prev;
18398 + /* just set it to n */
18399 + if (unlikely(delta >= wsize))
18400 + return (n << FSHIFT);
18402 + calc = delta * n;
18404 + prev = (wsize - delta);
18407 + do_div(calc, wsize);
18412 +void vx_update_load(struct vx_info *vxi)
18414 + uint32_t now, last, delta;
18415 + unsigned int nr_running, nr_uninterruptible;
18416 + unsigned int total;
18417 + unsigned long flags;
18419 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18422 + last = vxi->cvirt.load_last;
18423 + delta = now - last;
18425 + if (delta < 5*HZ)
18428 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18429 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18430 + total = nr_running + nr_uninterruptible;
18432 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18433 + 60*HZ, delta, total);
18434 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18435 + 5*60*HZ, delta, total);
18436 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18437 + 15*60*HZ, delta, total);
18439 + vxi->cvirt.load_last = now;
18441 + atomic_inc(&vxi->cvirt.load_updates);
18442 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18447 + * Commands to do_syslog:
18449 + * 0 -- Close the log. Currently a NOP.
18450 + * 1 -- Open the log. Currently a NOP.
18451 + * 2 -- Read from the log.
18452 + * 3 -- Read all messages remaining in the ring buffer.
18453 + * 4 -- Read and clear all messages remaining in the ring buffer
18454 + * 5 -- Clear ring buffer.
18455 + * 6 -- Disable printk's to console
18456 + * 7 -- Enable printk's to console
18457 + * 8 -- Set level of messages printed to console
18458 + * 9 -- Return number of unread characters in the log buffer
18459 + * 10 -- Return size of the log buffer
18461 +int vx_do_syslog(int type, char __user *buf, int len)
18464 + int do_clear = 0;
18465 + struct vx_info *vxi = current->vx_info;
18466 + struct _vx_syslog *log;
18470 + log = &vxi->cvirt.syslog;
18473 + case 0: /* Close log */
18474 + case 1: /* Open log */
18476 + case 2: /* Read from log */
18477 + error = wait_event_interruptible(log->log_wait,
18478 + (log->log_start - log->log_end));
18481 + spin_lock_irq(&log->logbuf_lock);
18482 + spin_unlock_irq(&log->logbuf_lock);
18484 + case 4: /* Read/clear last kernel messages */
18486 + /* fall through */
18487 + case 3: /* Read last kernel messages */
18490 + case 5: /* Clear ring buffer */
18493 + case 6: /* Disable logging to console */
18494 + case 7: /* Enable logging to console */
18495 + case 8: /* Set level of messages printed to console */
18498 + case 9: /* Number of chars in the log buffer */
18500 + case 10: /* Size of the log buffer */
18510 +/* virtual host info names */
18512 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18514 + struct nsproxy *nsproxy;
18515 + struct uts_namespace *uts;
18517 + if (id == VHIN_CONTEXT)
18518 + return vxi->vx_name;
18520 + nsproxy = vxi->vx_nsproxy[0];
18524 + uts = nsproxy->uts_ns;
18529 + case VHIN_SYSNAME:
18530 + return uts->name.sysname;
18531 + case VHIN_NODENAME:
18532 + return uts->name.nodename;
18533 + case VHIN_RELEASE:
18534 + return uts->name.release;
18535 + case VHIN_VERSION:
18536 + return uts->name.version;
18537 + case VHIN_MACHINE:
18538 + return uts->name.machine;
18539 + case VHIN_DOMAINNAME:
18540 + return uts->name.domainname;
18547 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18549 + struct vcmd_vhi_name_v0 vc_data;
18552 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18555 + name = vx_vhi_name(vxi, vc_data.field);
18559 + memcpy(name, vc_data.name, 65);
18563 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18565 + struct vcmd_vhi_name_v0 vc_data;
18568 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18571 + name = vx_vhi_name(vxi, vc_data.field);
18575 + memcpy(vc_data.name, name, 65);
18576 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18582 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18584 + struct vcmd_virt_stat_v0 vc_data;
18585 + struct _vx_cvirt *cvirt = &vxi->cvirt;
18586 + struct timespec uptime;
18588 + do_posix_clock_monotonic_gettime(&uptime);
18589 + set_normalized_timespec(&uptime,
18590 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18591 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18593 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18594 + vc_data.uptime = timespec_to_ns(&uptime);
18595 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18596 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
18597 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18598 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18599 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18600 + vc_data.load[0] = cvirt->load[0];
18601 + vc_data.load[1] = cvirt->load[1];
18602 + vc_data.load[2] = cvirt->load[2];
18604 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18610 +#ifdef CONFIG_VSERVER_VTIME
18612 +/* virtualized time base */
18614 +void vx_gettimeofday(struct timeval *tv)
18616 + do_gettimeofday(tv);
18617 + if (!vx_flags(VXF_VIRT_TIME, 0))
18620 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
18621 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
18623 + if (tv->tv_usec >= USEC_PER_SEC) {
18625 + tv->tv_usec -= USEC_PER_SEC;
18626 + } else if (tv->tv_usec < 0) {
18628 + tv->tv_usec += USEC_PER_SEC;
18632 +int vx_settimeofday(struct timespec *ts)
18634 + struct timeval tv;
18636 + if (!vx_flags(VXF_VIRT_TIME, 0))
18637 + return do_settimeofday(ts);
18639 + do_gettimeofday(&tv);
18640 + current->vx_info->cvirt.bias_tv.tv_sec =
18641 + ts->tv_sec - tv.tv_sec;
18642 + current->vx_info->cvirt.bias_tv.tv_usec =
18643 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18649 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/cvirt_init.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cvirt_init.h
18650 --- linux-2.6.27.14/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
18651 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cvirt_init.h 2008-10-13 14:54:20.000000000 +0200
18655 +extern uint64_t vx_idle_jiffies(void);
18657 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18659 + uint64_t idle_jiffies = vx_idle_jiffies();
18660 + uint64_t nsuptime;
18662 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18663 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18664 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18665 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18666 + cvirt->bias_tv.tv_sec = 0;
18667 + cvirt->bias_tv.tv_usec = 0;
18669 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
18670 + atomic_set(&cvirt->nr_threads, 0);
18671 + atomic_set(&cvirt->nr_running, 0);
18672 + atomic_set(&cvirt->nr_uninterruptible, 0);
18673 + atomic_set(&cvirt->nr_onhold, 0);
18675 + spin_lock_init(&cvirt->load_lock);
18676 + cvirt->load_last = jiffies;
18677 + atomic_set(&cvirt->load_updates, 0);
18678 + cvirt->load[0] = 0;
18679 + cvirt->load[1] = 0;
18680 + cvirt->load[2] = 0;
18681 + atomic_set(&cvirt->total_forks, 0);
18683 + spin_lock_init(&cvirt->syslog.logbuf_lock);
18684 + init_waitqueue_head(&cvirt->syslog.log_wait);
18685 + cvirt->syslog.log_start = 0;
18686 + cvirt->syslog.log_end = 0;
18687 + cvirt->syslog.con_start = 0;
18688 + cvirt->syslog.logged_chars = 0;
18692 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18694 + // cvirt_pc->cpustat = { 0 };
18697 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
18701 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
18702 + "!!! cvirt: %p[nr_threads] = %d on exit.",
18704 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
18705 + "!!! cvirt: %p[nr_running] = %d on exit.",
18707 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
18708 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
18710 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
18711 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
18717 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
18722 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/cvirt_proc.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cvirt_proc.h
18723 --- linux-2.6.27.14/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
18724 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/cvirt_proc.h 2008-10-13 14:54:20.000000000 +0200
18726 +#ifndef _VX_CVIRT_PROC_H
18727 +#define _VX_CVIRT_PROC_H
18729 +#include <linux/nsproxy.h>
18730 +#include <linux/mnt_namespace.h>
18731 +#include <linux/ipc_namespace.h>
18732 +#include <linux/utsname.h>
18733 +#include <linux/ipc.h>
18737 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
18739 + struct mnt_namespace *ns;
18740 + struct uts_namespace *uts;
18741 + struct ipc_namespace *ipc;
18742 + struct path path;
18743 + char *pstr, *root;
18749 + length += sprintf(buffer + length,
18750 + "NSProxy:\t%p [%p,%p,%p]\n",
18751 + nsproxy, nsproxy->mnt_ns,
18752 + nsproxy->uts_ns, nsproxy->ipc_ns);
18754 + ns = nsproxy->mnt_ns;
18758 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
18762 + path.mnt = ns->root;
18763 + path.dentry = ns->root->mnt_root;
18764 + root = d_path(&path, pstr, PATH_MAX - 2);
18765 + length += sprintf(buffer + length,
18766 + "Namespace:\t%p [#%u]\n"
18767 + "RootPath:\t%s\n",
18768 + ns, atomic_read(&ns->count),
18773 + uts = nsproxy->uts_ns;
18777 + length += sprintf(buffer + length,
18778 + "SysName:\t%.*s\n"
18779 + "NodeName:\t%.*s\n"
18780 + "Release:\t%.*s\n"
18781 + "Version:\t%.*s\n"
18782 + "Machine:\t%.*s\n"
18783 + "DomainName:\t%.*s\n",
18784 + __NEW_UTS_LEN, uts->name.sysname,
18785 + __NEW_UTS_LEN, uts->name.nodename,
18786 + __NEW_UTS_LEN, uts->name.release,
18787 + __NEW_UTS_LEN, uts->name.version,
18788 + __NEW_UTS_LEN, uts->name.machine,
18789 + __NEW_UTS_LEN, uts->name.domainname);
18792 + ipc = nsproxy->ipc_ns;
18796 + length += sprintf(buffer + length,
18797 + "SEMS:\t\t%d %d %d %d %d\n"
18798 + "MSG:\t\t%d %d %d\n"
18799 + "SHM:\t\t%lu %lu %d %d\n",
18800 + ipc->sem_ctls[0], ipc->sem_ctls[1],
18801 + ipc->sem_ctls[2], ipc->sem_ctls[3],
18803 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
18804 + (unsigned long)ipc->shm_ctlmax,
18805 + (unsigned long)ipc->shm_ctlall,
18806 + ipc->shm_ctlmni, ipc->shm_tot);
18813 +#include <linux/sched.h>
18815 +#define LOAD_INT(x) ((x) >> FSHIFT)
18816 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
18819 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
18824 + length += sprintf(buffer + length,
18825 + "BiasUptime:\t%lu.%02lu\n",
18826 + (unsigned long)cvirt->bias_uptime.tv_sec,
18827 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
18829 + a = cvirt->load[0] + (FIXED_1 / 200);
18830 + b = cvirt->load[1] + (FIXED_1 / 200);
18831 + c = cvirt->load[2] + (FIXED_1 / 200);
18832 + length += sprintf(buffer + length,
18833 + "nr_threads:\t%d\n"
18834 + "nr_running:\t%d\n"
18835 + "nr_unintr:\t%d\n"
18836 + "nr_onhold:\t%d\n"
18837 + "load_updates:\t%d\n"
18838 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
18839 + "total_forks:\t%d\n",
18840 + atomic_read(&cvirt->nr_threads),
18841 + atomic_read(&cvirt->nr_running),
18842 + atomic_read(&cvirt->nr_uninterruptible),
18843 + atomic_read(&cvirt->nr_onhold),
18844 + atomic_read(&cvirt->load_updates),
18845 + LOAD_INT(a), LOAD_FRAC(a),
18846 + LOAD_INT(b), LOAD_FRAC(b),
18847 + LOAD_INT(c), LOAD_FRAC(c),
18848 + atomic_read(&cvirt->total_forks));
18853 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
18854 + char *buffer, int cpu)
18860 +#endif /* _VX_CVIRT_PROC_H */
18861 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/debug.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/debug.c
18862 --- linux-2.6.27.14/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
18863 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/debug.c 2008-10-13 14:54:20.000000000 +0200
18866 + * kernel/vserver/debug.c
18868 + * Copyright (C) 2005-2007 Herbert Pötzl
18870 + * V0.01 vx_info dump support
18874 +#include <linux/module.h>
18876 +#include <linux/vserver/context.h>
18879 +void dump_vx_info(struct vx_info *vxi, int level)
18881 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
18882 + atomic_read(&vxi->vx_usecnt),
18883 + atomic_read(&vxi->vx_tasks),
18886 + __dump_vx_limit(&vxi->limit);
18887 + __dump_vx_sched(&vxi->sched);
18888 + __dump_vx_cvirt(&vxi->cvirt);
18889 + __dump_vx_cacct(&vxi->cacct);
18895 +EXPORT_SYMBOL_GPL(dump_vx_info);
18897 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/device.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/device.c
18898 --- linux-2.6.27.14/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
18899 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/device.c 2008-10-13 14:54:20.000000000 +0200
18902 + * linux/kernel/vserver/device.c
18904 + * Linux-VServer: Device Support
18906 + * Copyright (C) 2006 Herbert Pötzl
18907 + * Copyright (C) 2007 Daniel Hokka Zakrisson
18909 + * V0.01 device mapping basics
18910 + * V0.02 added defaults
18914 +#include <linux/slab.h>
18915 +#include <linux/rcupdate.h>
18916 +#include <linux/fs.h>
18917 +#include <linux/namei.h>
18918 +#include <linux/hash.h>
18920 +#include <asm/errno.h>
18921 +#include <asm/uaccess.h>
18922 +#include <linux/vserver/base.h>
18923 +#include <linux/vserver/debug.h>
18924 +#include <linux/vserver/context.h>
18925 +#include <linux/vserver/device.h>
18926 +#include <linux/vserver/device_cmd.h>
18929 +#define DMAP_HASH_BITS 4
18932 +struct vs_mapping {
18934 + struct hlist_node hlist;
18935 + struct list_head list;
18937 +#define dm_hlist u.hlist
18938 +#define dm_list u.list
18941 + struct vx_dmap_target target;
18945 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
18947 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
18949 +static struct vx_dmap_target dmap_defaults[2] = {
18950 + { .flags = DATTR_OPEN },
18951 + { .flags = DATTR_OPEN },
18955 +struct kmem_cache *dmap_cachep __read_mostly;
18957 +int __init dmap_cache_init(void)
18959 + dmap_cachep = kmem_cache_create("dmap_cache",
18960 + sizeof(struct vs_mapping), 0,
18961 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
18965 +__initcall(dmap_cache_init);
18968 +static inline unsigned int __hashval(dev_t dev, int bits)
18970 + return hash_long((unsigned long)dev, bits);
18974 +/* __hash_mapping()
18975 + * add the mapping to the hash table
18977 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
18979 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18980 + struct hlist_head *head, *hash = dmap_main_hash;
18981 + int device = vdm->device;
18983 + spin_lock(hash_lock);
18984 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
18985 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
18987 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
18988 + hlist_add_head(&vdm->dm_hlist, head);
18989 + spin_unlock(hash_lock);
18993 +static inline int __mode_to_default(umode_t mode)
19006 +/* __set_default()
19009 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19010 + struct vx_dmap_target *vdmt)
19012 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19013 + spin_lock(hash_lock);
19016 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19018 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19021 + spin_unlock(hash_lock);
19023 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19024 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19028 +/* __remove_default()
19029 + * remove a default
19031 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19033 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19034 + spin_lock(hash_lock);
19037 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19038 + else /* remove == reset */
19039 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19041 + spin_unlock(hash_lock);
19046 +/* __find_mapping()
19047 + * find a mapping in the hash table
19049 + * caller must hold hash_lock
19051 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19052 + struct vs_mapping **local, struct vs_mapping **global)
19054 + struct hlist_head *hash = dmap_main_hash;
19055 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19056 + struct hlist_node *pos;
19057 + struct vs_mapping *vdm;
19063 + hlist_for_each(pos, head) {
19064 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19066 + if ((vdm->device == device) &&
19067 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19068 + if (vdm->xid == xid) {
19071 + } else if (global && vdm->xid == 0)
19076 + if (global && *global)
19083 +/* __lookup_mapping()
19084 + * find a mapping and store the result in target and flags
19086 +static inline int __lookup_mapping(struct vx_info *vxi,
19087 + dev_t device, dev_t *target, int *flags, umode_t mode)
19089 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19090 + struct vs_mapping *vdm, *global;
19091 + struct vx_dmap_target *vdmt;
19093 + xid_t xid = vxi->vx_id;
19096 + spin_lock(hash_lock);
19097 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19099 + vdmt = &vdm->target;
19103 + index = __mode_to_default(mode);
19104 + if (vxi && vxi->dmap.targets[index].flags) {
19106 + vdmt = &vxi->dmap.targets[index];
19107 + } else if (global) {
19109 + vdmt = &global->target;
19113 + vdmt = &dmap_defaults[index];
19117 + if (target && (vdmt->flags & DATTR_REMAP))
19118 + *target = vdmt->target;
19120 + *target = device;
19122 + *flags = vdmt->flags;
19124 + spin_unlock(hash_lock);
19130 +/* __remove_mapping()
19131 + * remove a mapping from the hash table
19133 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19136 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19137 + struct vs_mapping *vdm = NULL;
19140 + spin_lock(hash_lock);
19142 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19144 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19145 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19148 + hlist_del(&vdm->dm_hlist);
19151 + spin_unlock(hash_lock);
19153 + kmem_cache_free(dmap_cachep, vdm);
19159 +int vs_map_device(struct vx_info *vxi,
19160 + dev_t device, dev_t *target, umode_t mode)
19162 + int ret, flags = DATTR_MASK;
19166 + *target = device;
19169 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19170 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19171 + device, target ? *target : 0, flags, mode, ret);
19173 + return (flags & DATTR_MASK);
19178 +static int do_set_mapping(struct vx_info *vxi,
19179 + dev_t device, dev_t target, int flags, umode_t mode)
19182 + struct vs_mapping *new;
19184 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19188 + INIT_HLIST_NODE(&new->dm_hlist);
19189 + new->device = device;
19190 + new->target.target = target;
19191 + new->target.flags = flags | mode;
19192 + new->xid = (vxi ? vxi->vx_id : 0);
19194 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19195 + __hash_mapping(vxi, new);
19197 + struct vx_dmap_target new = {
19198 + .target = target,
19199 + .flags = flags | mode,
19201 + __set_default(vxi, mode, &new);
19207 +static int do_unset_mapping(struct vx_info *vxi,
19208 + dev_t device, dev_t target, int flags, umode_t mode)
19210 + int ret = -EINVAL;
19213 + ret = __remove_mapping(vxi, device, mode);
19217 + ret = __remove_default(vxi, mode);
19227 +static inline int __user_device(const char __user *name, dev_t *dev,
19230 + struct nameidata nd;
19237 + ret = user_lpath(name, &nd.path);
19240 + if (nd.path.dentry->d_inode) {
19241 + *dev = nd.path.dentry->d_inode->i_rdev;
19242 + *mode = nd.path.dentry->d_inode->i_mode;
19244 + path_put(&nd.path);
19248 +static inline int __mapping_mode(dev_t device, dev_t target,
19249 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19252 + *mode = device_mode & S_IFMT;
19254 + *mode = target_mode & S_IFMT;
19258 + /* if both given, device and target mode have to match */
19259 + if (device && target &&
19260 + ((device_mode ^ target_mode) & S_IFMT))
19266 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19267 + const char __user *target_path, int flags, int set)
19269 + dev_t device = ~0, target = ~0;
19270 + umode_t device_mode = 0, target_mode = 0, mode;
19273 + ret = __user_device(device_path, &device, &device_mode);
19276 + ret = __user_device(target_path, &target, &target_mode);
19280 + ret = __mapping_mode(device, target,
19281 + device_mode, target_mode, &mode);
19286 + return do_set_mapping(vxi, device, target,
19289 + return do_unset_mapping(vxi, device, target,
19294 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19296 + struct vcmd_set_mapping_v0 vc_data;
19298 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19301 + return do_mapping(vxi, vc_data.device, vc_data.target,
19302 + vc_data.flags, 1);
19305 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19307 + struct vcmd_set_mapping_v0 vc_data;
19309 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19312 + return do_mapping(vxi, vc_data.device, vc_data.target,
19313 + vc_data.flags, 0);
19317 +#ifdef CONFIG_COMPAT
19319 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19321 + struct vcmd_set_mapping_v0_x32 vc_data;
19323 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19326 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19327 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19330 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19332 + struct vcmd_set_mapping_v0_x32 vc_data;
19334 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19337 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19338 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19341 +#endif /* CONFIG_COMPAT */
19344 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/dlimit.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/dlimit.c
19345 --- linux-2.6.27.14/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19346 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/dlimit.c 2008-10-13 14:54:20.000000000 +0200
19349 + * linux/kernel/vserver/dlimit.c
19351 + * Virtual Server: Context Disk Limits
19353 + * Copyright (C) 2004-2007 Herbert Pötzl
19355 + * V0.01 initial version
19356 + * V0.02 compat32 splitup
19360 +#include <linux/statfs.h>
19361 +#include <linux/sched.h>
19362 +#include <linux/namei.h>
19363 +#include <linux/vs_tag.h>
19364 +#include <linux/vs_dlimit.h>
19365 +#include <linux/vserver/dlimit_cmd.h>
19367 +#include <asm/uaccess.h>
19369 +/* __alloc_dl_info()
19371 + * allocate an initialized dl_info struct
19372 + * doesn't make it visible (hash) */
19374 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19376 + struct dl_info *new = NULL;
19378 + vxdprintk(VXD_CBIT(dlim, 5),
19379 + "alloc_dl_info(%p,%d)*", sb, tag);
19381 + /* would this benefit from a slab cache? */
19382 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19386 + memset(new, 0, sizeof(struct dl_info));
19387 + new->dl_tag = tag;
19389 + INIT_RCU_HEAD(&new->dl_rcu);
19390 + INIT_HLIST_NODE(&new->dl_hlist);
19391 + spin_lock_init(&new->dl_lock);
19392 + atomic_set(&new->dl_refcnt, 0);
19393 + atomic_set(&new->dl_usecnt, 0);
19395 + /* rest of init goes here */
19397 + vxdprintk(VXD_CBIT(dlim, 4),
19398 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19402 +/* __dealloc_dl_info()
19404 + * final disposal of dl_info */
19406 +static void __dealloc_dl_info(struct dl_info *dli)
19408 + vxdprintk(VXD_CBIT(dlim, 4),
19409 + "dealloc_dl_info(%p)", dli);
19411 + dli->dl_hlist.next = LIST_POISON1;
19412 + dli->dl_tag = -1;
19415 + BUG_ON(atomic_read(&dli->dl_usecnt));
19416 + BUG_ON(atomic_read(&dli->dl_refcnt));
19422 +/* hash table for dl_info hash */
19424 +#define DL_HASH_SIZE 13
19426 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19428 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19431 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19433 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19438 +/* __hash_dl_info()
19440 + * add the dli to the global hash table
19441 + * requires the hash_lock to be held */
19443 +static inline void __hash_dl_info(struct dl_info *dli)
19445 + struct hlist_head *head;
19447 + vxdprintk(VXD_CBIT(dlim, 6),
19448 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19449 + get_dl_info(dli);
19450 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19451 + hlist_add_head_rcu(&dli->dl_hlist, head);
19454 +/* __unhash_dl_info()
19456 + * remove the dli from the global hash table
19457 + * requires the hash_lock to be held */
19459 +static inline void __unhash_dl_info(struct dl_info *dli)
19461 + vxdprintk(VXD_CBIT(dlim, 6),
19462 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19463 + hlist_del_rcu(&dli->dl_hlist);
19464 + put_dl_info(dli);
19468 +/* __lookup_dl_info()
19470 + * requires the rcu_read_lock()
19471 + * doesn't increment the dl_refcnt */
19473 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19475 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19476 + struct hlist_node *pos;
19477 + struct dl_info *dli;
19479 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19481 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19489 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19491 + struct dl_info *dli;
19494 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19495 + vxdprintk(VXD_CBIT(dlim, 7),
19496 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19497 + rcu_read_unlock();
19501 +void rcu_free_dl_info(struct rcu_head *head)
19503 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19504 + int usecnt, refcnt;
19506 + BUG_ON(!dli || !head);
19508 + usecnt = atomic_read(&dli->dl_usecnt);
19509 + BUG_ON(usecnt < 0);
19511 + refcnt = atomic_read(&dli->dl_refcnt);
19512 + BUG_ON(refcnt < 0);
19514 + vxdprintk(VXD_CBIT(dlim, 3),
19515 + "rcu_free_dl_info(%p)", dli);
19517 + __dealloc_dl_info(dli);
19519 + printk("!!! rcu didn't free\n");
19525 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19526 + uint32_t flags, int add)
19528 + struct path path;
19531 + ret = user_lpath(name, &path);
19533 + struct super_block *sb;
19534 + struct dl_info *dli;
19537 + if (!path.dentry->d_inode)
19538 + goto out_release;
19539 + if (!(sb = path.dentry->d_inode->i_sb))
19540 + goto out_release;
19543 + dli = __alloc_dl_info(sb, id);
19544 + spin_lock(&dl_info_hash_lock);
19547 + if (__lookup_dl_info(sb, id))
19549 + __hash_dl_info(dli);
19552 + spin_lock(&dl_info_hash_lock);
19553 + dli = __lookup_dl_info(sb, id);
19558 + __unhash_dl_info(dli);
19562 + spin_unlock(&dl_info_hash_lock);
19564 + __dealloc_dl_info(dli);
19571 +int vc_add_dlimit(uint32_t id, void __user *data)
19573 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19575 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19578 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19581 +int vc_rem_dlimit(uint32_t id, void __user *data)
19583 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19585 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19588 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19591 +#ifdef CONFIG_COMPAT
19593 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19595 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19597 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19600 + return do_addrem_dlimit(id,
19601 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19604 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19606 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19608 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19611 + return do_addrem_dlimit(id,
19612 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19615 +#endif /* CONFIG_COMPAT */
19619 +int do_set_dlimit(uint32_t id, const char __user *name,
19620 + uint32_t space_used, uint32_t space_total,
19621 + uint32_t inodes_used, uint32_t inodes_total,
19622 + uint32_t reserved, uint32_t flags)
19624 + struct path path;
19627 + ret = user_lpath(name, &path);
19629 + struct super_block *sb;
19630 + struct dl_info *dli;
19633 + if (!path.dentry->d_inode)
19634 + goto out_release;
19635 + if (!(sb = path.dentry->d_inode->i_sb))
19636 + goto out_release;
19637 + if ((reserved != CDLIM_KEEP &&
19638 + reserved > 100) ||
19639 + (inodes_used != CDLIM_KEEP &&
19640 + inodes_used > inodes_total) ||
19641 + (space_used != CDLIM_KEEP &&
19642 + space_used > space_total))
19643 + goto out_release;
19646 + dli = locate_dl_info(sb, id);
19648 + goto out_release;
19650 + spin_lock(&dli->dl_lock);
19652 + if (inodes_used != CDLIM_KEEP)
19653 + dli->dl_inodes_used = inodes_used;
19654 + if (inodes_total != CDLIM_KEEP)
19655 + dli->dl_inodes_total = inodes_total;
19656 + if (space_used != CDLIM_KEEP) {
19657 + dli->dl_space_used = space_used;
19658 + dli->dl_space_used <<= 10;
19660 + if (space_total == CDLIM_INFINITY)
19661 + dli->dl_space_total = DLIM_INFINITY;
19662 + else if (space_total != CDLIM_KEEP) {
19663 + dli->dl_space_total = space_total;
19664 + dli->dl_space_total <<= 10;
19666 + if (reserved != CDLIM_KEEP)
19667 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
19669 + spin_unlock(&dli->dl_lock);
19671 + put_dl_info(dli);
19680 +int vc_set_dlimit(uint32_t id, void __user *data)
19682 + struct vcmd_ctx_dlimit_v0 vc_data;
19684 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19687 + return do_set_dlimit(id, vc_data.name,
19688 + vc_data.space_used, vc_data.space_total,
19689 + vc_data.inodes_used, vc_data.inodes_total,
19690 + vc_data.reserved, vc_data.flags);
19693 +#ifdef CONFIG_COMPAT
19695 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19697 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19699 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19702 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19703 + vc_data.space_used, vc_data.space_total,
19704 + vc_data.inodes_used, vc_data.inodes_total,
19705 + vc_data.reserved, vc_data.flags);
19708 +#endif /* CONFIG_COMPAT */
19712 +int do_get_dlimit(uint32_t id, const char __user *name,
19713 + uint32_t *space_used, uint32_t *space_total,
19714 + uint32_t *inodes_used, uint32_t *inodes_total,
19715 + uint32_t *reserved, uint32_t *flags)
19717 + struct path path;
19720 + ret = user_lpath(name, &path);
19722 + struct super_block *sb;
19723 + struct dl_info *dli;
19726 + if (!path.dentry->d_inode)
19727 + goto out_release;
19728 + if (!(sb = path.dentry->d_inode->i_sb))
19729 + goto out_release;
19732 + dli = locate_dl_info(sb, id);
19734 + goto out_release;
19736 + spin_lock(&dli->dl_lock);
19737 + *inodes_used = dli->dl_inodes_used;
19738 + *inodes_total = dli->dl_inodes_total;
19739 + *space_used = dli->dl_space_used >> 10;
19740 + if (dli->dl_space_total == DLIM_INFINITY)
19741 + *space_total = CDLIM_INFINITY;
19743 + *space_total = dli->dl_space_total >> 10;
19745 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19746 + spin_unlock(&dli->dl_lock);
19748 + put_dl_info(dli);
19759 +int vc_get_dlimit(uint32_t id, void __user *data)
19761 + struct vcmd_ctx_dlimit_v0 vc_data;
19764 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19767 + ret = do_get_dlimit(id, vc_data.name,
19768 + &vc_data.space_used, &vc_data.space_total,
19769 + &vc_data.inodes_used, &vc_data.inodes_total,
19770 + &vc_data.reserved, &vc_data.flags);
19774 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19779 +#ifdef CONFIG_COMPAT
19781 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19783 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19786 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19789 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19790 + &vc_data.space_used, &vc_data.space_total,
19791 + &vc_data.inodes_used, &vc_data.inodes_total,
19792 + &vc_data.reserved, &vc_data.flags);
19796 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19801 +#endif /* CONFIG_COMPAT */
19804 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19806 + struct dl_info *dli;
19807 + __u64 blimit, bfree, bavail;
19810 + dli = locate_dl_info(sb, dx_current_tag());
19814 + spin_lock(&dli->dl_lock);
19815 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19818 + /* reduce max inodes available to limit */
19819 + if (buf->f_files > dli->dl_inodes_total)
19820 + buf->f_files = dli->dl_inodes_total;
19822 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19823 + /* reduce free inodes to min */
19824 + if (ifree < buf->f_ffree)
19825 + buf->f_ffree = ifree;
19828 + if (dli->dl_space_total == DLIM_INFINITY)
19831 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19833 + if (dli->dl_space_total < dli->dl_space_used)
19836 + bfree = (dli->dl_space_total - dli->dl_space_used)
19837 + >> sb->s_blocksize_bits;
19839 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19840 + if (bavail < dli->dl_space_used)
19843 + bavail = (bavail - dli->dl_space_used)
19844 + >> sb->s_blocksize_bits;
19846 + /* reduce max space available to limit */
19847 + if (buf->f_blocks > blimit)
19848 + buf->f_blocks = blimit;
19850 + /* reduce free space to min */
19851 + if (bfree < buf->f_bfree)
19852 + buf->f_bfree = bfree;
19854 + /* reduce avail space to min */
19855 + if (bavail < buf->f_bavail)
19856 + buf->f_bavail = bavail;
19859 + spin_unlock(&dli->dl_lock);
19860 + put_dl_info(dli);
19865 +#include <linux/module.h>
19867 +EXPORT_SYMBOL_GPL(locate_dl_info);
19868 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
19870 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/helper.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/helper.c
19871 --- linux-2.6.27.14/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
19872 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/helper.c 2008-10-13 14:54:20.000000000 +0200
19875 + * linux/kernel/vserver/helper.c
19877 + * Virtual Context Support
19879 + * Copyright (C) 2004-2007 Herbert Pötzl
19881 + * V0.01 basic helper
19885 +#include <linux/kmod.h>
19886 +#include <linux/reboot.h>
19887 +#include <linux/vs_context.h>
19888 +#include <linux/vs_network.h>
19889 +#include <linux/vserver/signal.h>
19892 +char vshelper_path[255] = "/sbin/vshelper";
19895 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
19899 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
19900 + printk( KERN_WARNING
19901 + "%s: (%s %s) returned %s with %d\n",
19902 + name, argv[1], argv[2],
19903 + sync ? "sync" : "async", ret);
19905 + vxdprintk(VXD_CBIT(switch, 4),
19906 + "%s: (%s %s) returned %s with %d",
19907 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
19912 + * vshelper path is set via /proc/sys
19913 + * invoked by vserver sys_reboot(), with
19914 + * the following arguments
19916 + * argv [0] = vshelper_path;
19917 + * argv [1] = action: "restart", "halt", "poweroff", ...
19918 + * argv [2] = context identifier
19920 + * envp [*] = type-specific parameters
19923 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
19925 + char id_buf[8], cmd_buf[16];
19926 + char uid_buf[16], pid_buf[16];
19929 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
19930 + char *envp[] = {"HOME=/", "TERM=linux",
19931 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
19932 + uid_buf, pid_buf, cmd_buf, 0};
19934 + if (vx_info_state(vxi, VXS_HELPER))
19936 + vxi->vx_state |= VXS_HELPER;
19938 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
19940 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
19941 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
19942 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
19945 + case LINUX_REBOOT_CMD_RESTART:
19946 + argv[1] = "restart";
19949 + case LINUX_REBOOT_CMD_HALT:
19950 + argv[1] = "halt";
19953 + case LINUX_REBOOT_CMD_POWER_OFF:
19954 + argv[1] = "poweroff";
19957 + case LINUX_REBOOT_CMD_SW_SUSPEND:
19958 + argv[1] = "swsusp";
19962 + vxi->vx_state &= ~VXS_HELPER;
19966 + ret = do_vshelper(vshelper_path, argv, envp, 0);
19967 + vxi->vx_state &= ~VXS_HELPER;
19968 + __wakeup_vx_info(vxi);
19969 + return (ret) ? -EPERM : 0;
19973 +long vs_reboot(unsigned int cmd, void __user *arg)
19975 + struct vx_info *vxi = current->vx_info;
19978 + vxdprintk(VXD_CBIT(misc, 5),
19979 + "vs_reboot(%p[#%d],%d)",
19980 + vxi, vxi ? vxi->vx_id : 0, cmd);
19982 + ret = vs_reboot_helper(vxi, cmd, arg);
19986 + vxi->reboot_cmd = cmd;
19987 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
19989 + case LINUX_REBOOT_CMD_RESTART:
19990 + case LINUX_REBOOT_CMD_HALT:
19991 + case LINUX_REBOOT_CMD_POWER_OFF:
19992 + vx_info_kill(vxi, 0, SIGKILL);
19993 + vx_info_kill(vxi, 1, SIGKILL);
20003 + * argv [0] = vshelper_path;
20004 + * argv [1] = action: "startup", "shutdown"
20005 + * argv [2] = context identifier
20007 + * envp [*] = type-specific parameters
20010 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20012 + char id_buf[8], cmd_buf[16];
20013 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20014 + char *envp[] = {"HOME=/", "TERM=linux",
20015 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20017 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20020 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20021 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20024 + case VSC_STARTUP:
20025 + argv[1] = "startup";
20027 + case VSC_SHUTDOWN:
20028 + argv[1] = "shutdown";
20034 + return do_vshelper(vshelper_path, argv, envp, 1);
20039 + * argv [0] = vshelper_path;
20040 + * argv [1] = action: "netup", "netdown"
20041 + * argv [2] = context identifier
20043 + * envp [*] = type-specific parameters
20046 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20048 + char id_buf[8], cmd_buf[16];
20049 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20050 + char *envp[] = {"HOME=/", "TERM=linux",
20051 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20053 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20056 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20057 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20061 + argv[1] = "netup";
20063 + case VSC_NETDOWN:
20064 + argv[1] = "netdown";
20070 + return do_vshelper(vshelper_path, argv, envp, 1);
20073 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/history.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/history.c
20074 --- linux-2.6.27.14/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20075 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/history.c 2008-10-13 14:54:20.000000000 +0200
20078 + * kernel/vserver/history.c
20080 + * Virtual Context History Backtrace
20082 + * Copyright (C) 2004-2007 Herbert Pötzl
20084 + * V0.01 basic structure
20085 + * V0.02 hash/unhash and trace
20086 + * V0.03 preemption fixes
20090 +#include <linux/module.h>
20091 +#include <asm/uaccess.h>
20093 +#include <linux/vserver/context.h>
20094 +#include <linux/vserver/debug.h>
20095 +#include <linux/vserver/debug_cmd.h>
20096 +#include <linux/vserver/history.h>
20099 +#ifdef CONFIG_VSERVER_HISTORY
20100 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20102 +#define VXH_SIZE 64
20105 +struct _vx_history {
20106 + unsigned int counter;
20108 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20112 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20114 +unsigned volatile int vxh_active = 1;
20116 +static atomic_t sequence = ATOMIC_INIT(0);
20121 + * requires disabled preemption */
20123 +struct _vx_hist_entry *vxh_advance(void *loc)
20125 + unsigned int cpu = smp_processor_id();
20126 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20127 + struct _vx_hist_entry *entry;
20128 + unsigned int index;
20130 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20131 + entry = &hist->entry[index];
20133 + entry->seq = atomic_inc_return(&sequence);
20134 + entry->loc = loc;
20138 +EXPORT_SYMBOL_GPL(vxh_advance);
20141 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20143 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20146 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20148 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20149 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20150 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20151 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20153 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20155 + switch (e->type) {
20156 + case VXH_THROW_OOPS:
20157 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20160 + case VXH_GET_VX_INFO:
20161 + case VXH_PUT_VX_INFO:
20162 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20164 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20165 + VXH_VXI_ARGS(e));
20168 + case VXH_INIT_VX_INFO:
20169 + case VXH_SET_VX_INFO:
20170 + case VXH_CLR_VX_INFO:
20171 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20173 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20174 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20175 + VXH_VXI_ARGS(e), e->sc.data);
20178 + case VXH_CLAIM_VX_INFO:
20179 + case VXH_RELEASE_VX_INFO:
20180 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20182 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20183 + VXH_VXI_ARGS(e), e->sc.data);
20186 + case VXH_ALLOC_VX_INFO:
20187 + case VXH_DEALLOC_VX_INFO:
20188 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20190 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20191 + VXH_VXI_ARGS(e));
20194 + case VXH_HASH_VX_INFO:
20195 + case VXH_UNHASH_VX_INFO:
20196 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20198 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20199 + VXH_VXI_ARGS(e));
20202 + case VXH_LOC_VX_INFO:
20203 + case VXH_LOOKUP_VX_INFO:
20204 + case VXH_CREATE_VX_INFO:
20205 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20207 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20208 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20209 + e->ll.arg, VXH_VXI_ARGS(e));
20214 +static void __vxh_dump_history(void)
20216 + unsigned int i, cpu;
20218 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20219 + atomic_read(&sequence), NR_CPUS);
20221 + for (i = 0; i < VXH_SIZE; i++) {
20222 + for_each_online_cpu(cpu) {
20223 + struct _vx_history *hist =
20224 + &per_cpu(vx_history_buffer, cpu);
20225 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20226 + struct _vx_hist_entry *entry = &hist->entry[index];
20228 + vxh_dump_entry(entry, cpu);
20233 +void vxh_dump_history(void)
20237 + local_irq_enable();
20239 + local_irq_disable();
20241 + __vxh_dump_history();
20245 +/* vserver syscall commands below here */
20248 +int vc_dump_history(uint32_t id)
20251 + __vxh_dump_history();
20258 +int do_read_history(struct __user _vx_hist_entry *data,
20259 + int cpu, uint32_t *index, uint32_t *count)
20261 + int pos, ret = 0;
20262 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20263 + int end = hist->counter;
20264 + int start = end - VXH_SIZE + 2;
20265 + int idx = *index;
20267 + /* special case: get current pos */
20273 + /* have we lost some data? */
20277 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20278 + struct _vx_hist_entry *entry =
20279 + &hist->entry[idx % VXH_SIZE];
20281 + /* send entry to userspace */
20282 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20286 + /* save new index and count */
20289 + return ret ? ret : (*index < end);
20292 +int vc_read_history(uint32_t id, void __user *data)
20294 + struct vcmd_read_history_v0 vc_data;
20297 + if (id >= NR_CPUS)
20300 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20303 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20304 + id, &vc_data.index, &vc_data.count);
20306 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20311 +#ifdef CONFIG_COMPAT
20313 +int vc_read_history_x32(uint32_t id, void __user *data)
20315 + struct vcmd_read_history_v0_x32 vc_data;
20318 + if (id >= NR_CPUS)
20321 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20324 + ret = do_read_history((struct __user _vx_hist_entry *)
20325 + compat_ptr(vc_data.data_ptr),
20326 + id, &vc_data.index, &vc_data.count);
20328 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20333 +#endif /* CONFIG_COMPAT */
20335 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/inet.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/inet.c
20336 --- linux-2.6.27.14/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20337 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/inet.c 2008-10-13 14:54:20.000000000 +0200
20340 +#include <linux/in.h>
20341 +#include <linux/inetdevice.h>
20342 +#include <linux/vs_inet.h>
20343 +#include <linux/vs_inet6.h>
20344 +#include <linux/vserver/debug.h>
20345 +#include <net/route.h>
20346 +#include <net/addrconf.h>
20349 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20353 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20356 + struct nx_addr_v4 *ptr;
20358 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20359 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20366 + vxdprintk(VXD_CBIT(net, 2),
20367 + "nx_v4_addr_conflict(%p,%p): %d",
20368 + nxi1, nxi2, ret);
20374 +#ifdef CONFIG_IPV6
20376 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20380 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20383 + struct nx_addr_v6 *ptr;
20385 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20386 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20393 + vxdprintk(VXD_CBIT(net, 2),
20394 + "nx_v6_addr_conflict(%p,%p): %d",
20395 + nxi1, nxi2, ret);
20402 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20404 + struct in_device *in_dev;
20405 + struct in_ifaddr **ifap;
20406 + struct in_ifaddr *ifa;
20411 + in_dev = in_dev_get(dev);
20415 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20416 + ifap = &ifa->ifa_next) {
20417 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20422 + in_dev_put(in_dev);
20428 +#ifdef CONFIG_IPV6
20430 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20432 + struct inet6_dev *in_dev;
20433 + struct inet6_ifaddr **ifap;
20434 + struct inet6_ifaddr *ifa;
20439 + in_dev = in6_dev_get(dev);
20443 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20444 + ifap = &ifa->if_next) {
20445 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20450 + in6_dev_put(in_dev);
20457 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20463 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20465 +#ifdef CONFIG_IPV6
20467 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20472 + vxdprintk(VXD_CBIT(net, 3),
20473 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20474 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20478 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20479 + struct rtable **rp, struct flowi *fl)
20484 + /* FIXME: handle lback only case */
20485 + if (!NX_IPV4(nxi))
20488 + vxdprintk(VXD_CBIT(net, 4),
20489 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20490 + nxi, nxi ? nxi->nx_id : 0,
20491 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20493 + /* single IP is unconditional */
20494 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20495 + (fl->fl4_src == INADDR_ANY))
20496 + fl->fl4_src = nxi->v4.ip[0].s_addr;
20498 + if (fl->fl4_src == INADDR_ANY) {
20499 + struct nx_addr_v4 *ptr;
20500 + __be32 found = 0;
20503 + err = __ip_route_output_key(net, rp, fl);
20505 + found = (*rp)->rt_src;
20507 + vxdprintk(VXD_CBIT(net, 4),
20508 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20509 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20510 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20514 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20515 + __be32 primary = ptr->ip[0].s_addr;
20516 + __be32 mask = ptr->mask.s_addr;
20517 + __be32 neta = primary & mask;
20519 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20520 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20521 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20522 + NIPQUAD(mask), NIPQUAD(neta));
20523 + if ((found & mask) != neta)
20526 + fl->fl4_src = primary;
20527 + err = __ip_route_output_key(net, rp, fl);
20528 + vxdprintk(VXD_CBIT(net, 4),
20529 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20530 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20532 + found = (*rp)->rt_src;
20534 + if (found == primary)
20538 + /* still no source ip? */
20539 + found = ipv4_is_loopback(fl->fl4_dst)
20540 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20542 + /* assign src ip to flow */
20543 + fl->fl4_src = found;
20546 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20550 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20551 + if (ipv4_is_loopback(fl->fl4_dst))
20552 + fl->fl4_dst = nxi->v4_lback.s_addr;
20553 + if (ipv4_is_loopback(fl->fl4_src))
20554 + fl->fl4_src = nxi->v4_lback.s_addr;
20555 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
20556 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20562 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20564 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/init.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/init.c
20565 --- linux-2.6.27.14/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
20566 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/init.c 2008-10-13 14:54:20.000000000 +0200
20569 + * linux/kernel/init.c
20571 + * Virtual Server Init
20573 + * Copyright (C) 2004-2007 Herbert Pötzl
20575 + * V0.01 basic structure
20579 +#include <linux/init.h>
20581 +int vserver_register_sysctl(void);
20582 +void vserver_unregister_sysctl(void);
20585 +static int __init init_vserver(void)
20589 +#ifdef CONFIG_VSERVER_DEBUG
20590 + vserver_register_sysctl();
20596 +static void __exit exit_vserver(void)
20599 +#ifdef CONFIG_VSERVER_DEBUG
20600 + vserver_unregister_sysctl();
20605 +/* FIXME: GFP_ZONETYPES gone
20606 +long vx_slab[GFP_ZONETYPES]; */
20610 +module_init(init_vserver);
20611 +module_exit(exit_vserver);
20613 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/inode.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/inode.c
20614 --- linux-2.6.27.14/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20615 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/inode.c 2008-10-24 03:34:52.000000000 +0200
20618 + * linux/kernel/vserver/inode.c
20620 + * Virtual Server: File System Support
20622 + * Copyright (C) 2004-2007 Herbert Pötzl
20624 + * V0.01 separated from vcontext V0.05
20625 + * V0.02 moved to tag (instead of xid)
20629 +#include <linux/tty.h>
20630 +#include <linux/proc_fs.h>
20631 +#include <linux/devpts_fs.h>
20632 +#include <linux/fs.h>
20633 +#include <linux/file.h>
20634 +#include <linux/mount.h>
20635 +#include <linux/parser.h>
20636 +#include <linux/namei.h>
20637 +#include <linux/vserver/inode.h>
20638 +#include <linux/vserver/inode_cmd.h>
20639 +#include <linux/vs_base.h>
20640 +#include <linux/vs_tag.h>
20642 +#include <asm/uaccess.h>
20645 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20647 + struct proc_dir_entry *entry;
20649 + if (!in || !in->i_sb)
20652 + *flags = IATTR_TAG
20653 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
20654 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
20655 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
20656 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE;
20658 + if (S_ISDIR(in->i_mode))
20659 + *mask |= IATTR_BARRIER;
20661 + if (IS_TAGGED(in)) {
20662 + *tag = in->i_tag;
20663 + *mask |= IATTR_TAG;
20666 + switch (in->i_sb->s_magic) {
20667 + case PROC_SUPER_MAGIC:
20668 + entry = PROC_I(in)->pde;
20670 + /* check for specific inodes? */
20672 + *mask |= IATTR_FLAGS;
20674 + *flags |= (entry->vx_flags & IATTR_FLAGS);
20676 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
20679 + case DEVPTS_SUPER_MAGIC:
20680 + *tag = in->i_tag;
20681 + *mask |= IATTR_TAG;
20690 +int vc_get_iattr(void __user *data)
20692 + struct path path;
20693 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
20696 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20699 + ret = user_lpath(vc_data.name, &path);
20701 + ret = __vc_get_iattr(path.dentry->d_inode,
20702 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20708 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20713 +#ifdef CONFIG_COMPAT
20715 +int vc_get_iattr_x32(void __user *data)
20717 + struct path path;
20718 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
20721 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20724 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20726 + ret = __vc_get_iattr(path.dentry->d_inode,
20727 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20733 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20738 +#endif /* CONFIG_COMPAT */
20741 +int vc_fget_iattr(uint32_t fd, void __user *data)
20743 + struct file *filp;
20744 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
20747 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20751 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20754 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20755 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20759 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20765 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20767 + struct inode *in = de->d_inode;
20768 + int error = 0, is_proc = 0, has_tag = 0;
20769 + struct iattr attr = { 0 };
20771 + if (!in || !in->i_sb)
20774 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20775 + if ((*mask & IATTR_FLAGS) && !is_proc)
20778 + has_tag = IS_TAGGED(in) ||
20779 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20780 + if ((*mask & IATTR_TAG) && !has_tag)
20783 + mutex_lock(&in->i_mutex);
20784 + if (*mask & IATTR_TAG) {
20785 + attr.ia_tag = *tag;
20786 + attr.ia_valid |= ATTR_TAG;
20789 + if (*mask & IATTR_FLAGS) {
20790 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20791 + unsigned int iflags = PROC_I(in)->vx_flags;
20793 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20794 + | (*flags & IATTR_FLAGS);
20795 + PROC_I(in)->vx_flags = iflags;
20797 + entry->vx_flags = iflags;
20800 + if (*mask & (IATTR_BARRIER | IATTR_IXUNLINK | IATTR_IMMUTABLE)) {
20801 + if (*mask & IATTR_IMMUTABLE) {
20802 + if (*flags & IATTR_IMMUTABLE)
20803 + in->i_flags |= S_IMMUTABLE;
20805 + in->i_flags &= ~S_IMMUTABLE;
20807 + if (*mask & IATTR_IXUNLINK) {
20808 + if (*flags & IATTR_IXUNLINK)
20809 + in->i_flags |= S_IXUNLINK;
20811 + in->i_flags &= ~S_IXUNLINK;
20813 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20814 + if (*flags & IATTR_BARRIER)
20815 + in->i_vflags |= V_BARRIER;
20817 + in->i_vflags &= ~V_BARRIER;
20819 + if (in->i_op && in->i_op->sync_flags) {
20820 + error = in->i_op->sync_flags(in);
20826 + if (attr.ia_valid) {
20827 + if (in->i_op && in->i_op->setattr)
20828 + error = in->i_op->setattr(de, &attr);
20830 + error = inode_change_ok(in, &attr);
20832 + error = inode_setattr(in, &attr);
20837 + mutex_unlock(&in->i_mutex);
20841 +int vc_set_iattr(void __user *data)
20843 + struct path path;
20844 + struct vcmd_ctx_iattr_v1 vc_data;
20847 + if (!capable(CAP_LINUX_IMMUTABLE))
20849 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20852 + ret = user_lpath(vc_data.name, &path);
20854 + ret = __vc_set_iattr(path.dentry,
20855 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20859 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20864 +#ifdef CONFIG_COMPAT
20866 +int vc_set_iattr_x32(void __user *data)
20868 + struct path path;
20869 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20872 + if (!capable(CAP_LINUX_IMMUTABLE))
20874 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20877 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
20879 + ret = __vc_set_iattr(path.dentry,
20880 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
20884 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20889 +#endif /* CONFIG_COMPAT */
20891 +int vc_fset_iattr(uint32_t fd, void __user *data)
20893 + struct file *filp;
20894 + struct vcmd_ctx_fiattr_v0 vc_data;
20897 + if (!capable(CAP_LINUX_IMMUTABLE))
20899 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20903 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20906 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
20907 + &vc_data.flags, &vc_data.mask);
20911 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20917 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
20919 +static match_table_t tokens = {
20920 + {Opt_notagcheck, "notagcheck"},
20921 +#ifdef CONFIG_PROPAGATE
20922 + {Opt_notag, "notag"},
20923 + {Opt_tag, "tag"},
20924 + {Opt_tagid, "tagid=%u"},
20930 +static void __dx_parse_remove(char *string, char *opt)
20932 + char *p = strstr(string, opt);
20936 + while (*q != '\0' && *q != ',')
20945 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
20946 + unsigned long *flags)
20949 + substring_t args[MAX_OPT_ARGS];
20950 + int token, option = 0;
20951 + char *s, *p, *opts;
20955 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
20960 + while ((p = strsep(&opts, ",")) != NULL) {
20961 + token = match_token(p, tokens, args);
20963 + vxdprintk(VXD_CBIT(tag, 7),
20964 + "dx_parse_tag(»%s«): %d:#%d",
20965 + p, token, option);
20968 +#ifdef CONFIG_PROPAGATE
20973 + __dx_parse_remove(s, "tag");
20974 + *mnt_flags |= MNT_TAGID;
20975 + set |= MNT_TAGID;
20979 + __dx_parse_remove(s, "notag");
20980 + *mnt_flags |= MNT_NOTAG;
20981 + set |= MNT_NOTAG;
20984 + if (tag && !match_int(args, &option))
20987 + __dx_parse_remove(s, "tagid");
20988 + *mnt_flags |= MNT_TAGID;
20989 + set |= MNT_TAGID;
20992 + case Opt_notagcheck:
20994 + __dx_parse_remove(s, "notagcheck");
20995 + *flags |= MS_NOTAGCHECK;
20996 + set |= MS_NOTAGCHECK;
21001 + strcpy(string, s);
21006 +#ifdef CONFIG_PROPAGATE
21008 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21010 + tag_t new_tag = 0;
21011 + struct vfsmount *mnt;
21016 + mnt = nd->path.mnt;
21020 + propagate = (mnt->mnt_flags & MNT_TAGID);
21022 + new_tag = mnt->mnt_tag;
21024 + vxdprintk(VXD_CBIT(tag, 7),
21025 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21026 + inode, inode->i_ino, inode->i_tag,
21027 + new_tag, (propagate) ? 1 : 0);
21030 + inode->i_tag = new_tag;
21033 +#include <linux/module.h>
21035 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21037 +#endif /* CONFIG_PROPAGATE */
21039 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/Kconfig linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/Kconfig
21040 --- linux-2.6.27.14/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21041 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/Kconfig 2008-10-13 14:54:20.000000000 +0200
21044 +# Linux VServer configuration
21047 +menu "Linux VServer"
21049 +config VSERVER_AUTO_LBACK
21050 + bool "Automatically Assign Loopback IP"
21053 + Automatically assign a guest specific loopback
21054 + IP and add it to the kernel network stack on
21057 +config VSERVER_AUTO_SINGLE
21058 + bool "Automatic Single IP Special Casing"
21059 + depends on EXPERIMENTAL
21062 + This allows network contexts with a single IP to
21063 + automatically remap 0.0.0.0 bindings to that IP,
21064 + avoiding further network checks and improving
21067 + (note: such guests do not allow to change the ip
21068 + on the fly and do not show loopback addresses)
21070 +config VSERVER_COWBL
21071 + bool "Enable COW Immutable Link Breaking"
21074 + This enables the COW (Copy-On-Write) link break code.
21075 + It allows you to treat unified files like normal files
21076 + when writing to them (which will implicitely break the
21077 + link and create a copy of the unified file)
21079 +config VSERVER_VTIME
21080 + bool "Enable Virtualized Guest Time"
21081 + depends on EXPERIMENTAL
21084 + This enables per guest time offsets to allow for
21085 + adjusting the system clock individually per guest.
21086 + this adds some overhead to the time functions and
21087 + therefore should not be enabled without good reason.
21089 +config VSERVER_DEVICE
21090 + bool "Enable Guest Device Mapping"
21091 + depends on EXPERIMENTAL
21094 + This enables generic device remapping.
21096 +config VSERVER_PROC_SECURE
21097 + bool "Enable Proc Security"
21098 + depends on PROC_FS
21101 + This configures ProcFS security to initially hide
21102 + non-process entries for all contexts except the main and
21103 + spectator context (i.e. for all guests), which is a secure
21106 + (note: on 1.2x the entries were visible by default)
21108 +config VSERVER_HARDCPU
21109 + bool "Enable Hard CPU Limits"
21112 + Activate the Hard CPU Limits
21114 + This will compile in code that allows the Token Bucket
21115 + Scheduler to put processes on hold when a context's
21116 + tokens are depleted (provided that its per-context
21117 + sched_hard flag is set).
21119 + Processes belonging to that context will not be able
21120 + to consume CPU resources again until a per-context
21121 + configured minimum of tokens has been reached.
21123 +config VSERVER_IDLETIME
21124 + bool "Avoid idle CPUs by skipping Time"
21125 + depends on VSERVER_HARDCPU
21128 + This option allows the scheduler to artificially
21129 + advance time (per cpu) when otherwise the idle
21130 + task would be scheduled, thus keeping the cpu
21131 + busy and sharing the available resources among
21132 + certain contexts.
21134 +config VSERVER_IDLELIMIT
21135 + bool "Limit the IDLE task"
21136 + depends on VSERVER_HARDCPU
21139 + Limit the idle slices, so the the next context
21140 + will be scheduled as soon as possible.
21142 + This might improve interactivity and latency, but
21143 + will also marginally increase scheduling overhead.
21146 + prompt "Persistent Inode Tagging"
21147 + default TAGGING_ID24
21149 + This adds persistent context information to filesystems
21150 + mounted with the tagxid option. Tagging is a requirement
21151 + for per-context disk limits and per-context quota.
21154 +config TAGGING_NONE
21157 + do not store per-context information in inodes.
21159 +config TAGGING_UID16
21160 + bool "UID16/GID32"
21162 + reduces UID to 16 bit, but leaves GID at 32 bit.
21164 +config TAGGING_GID16
21165 + bool "UID32/GID16"
21167 + reduces GID to 16 bit, but leaves UID at 32 bit.
21169 +config TAGGING_ID24
21170 + bool "UID24/GID24"
21172 + uses the upper 8bit from UID and GID for XID tagging
21173 + which leaves 24bit for UID/GID each, which should be
21174 + more than sufficient for normal use.
21176 +config TAGGING_INTERN
21177 + bool "UID32/GID32"
21179 + this uses otherwise reserved inode fields in the on
21180 + disk representation, which limits the use to a few
21181 + filesystems (currently ext2 and ext3)
21186 + bool "Tag NFSD User Auth and Files"
21189 + Enable this if you do want the in-kernel NFS
21190 + Server to use the tagging specified above.
21191 + (will require patched clients too)
21193 +config VSERVER_PRIVACY
21194 + bool "Honor Privacy Aspects of Guests"
21197 + When enabled, most context checks will disallow
21198 + access to structures assigned to a specific context,
21199 + like ptys or loop devices.
21201 +config VSERVER_CONTEXTS
21202 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
21204 + default "768" if 64BIT
21207 + This setting will optimize certain data structures
21208 + and memory allocations according to the expected
21211 + note: this is not a strict upper limit.
21213 +config VSERVER_WARN
21214 + bool "VServer Warnings"
21217 + This enables various runtime warnings, which will
21218 + notify about potential manipulation attempts or
21219 + resource shortage. It is generally considered to
21220 + be a good idea to have that enabled.
21222 +config VSERVER_DEBUG
21223 + bool "VServer Debugging Code"
21226 + Set this to yes if you want to be able to activate
21227 + debugging output at runtime. It adds a very small
21228 + overhead to all vserver related functions and
21229 + increases the kernel size by about 20k.
21231 +config VSERVER_HISTORY
21232 + bool "VServer History Tracing"
21233 + depends on VSERVER_DEBUG
21236 + Set this to yes if you want to record the history of
21237 + linux-vserver activities, so they can be replayed in
21238 + the event of a kernel panic or oops.
21240 +config VSERVER_HISTORY_SIZE
21241 + int "Per-CPU History Size (32-65536)"
21242 + depends on VSERVER_HISTORY
21246 + This allows you to specify the number of entries in
21247 + the per-CPU history buffer.
21249 +config VSERVER_MONITOR
21250 + bool "VServer Scheduling Monitor"
21251 + depends on VSERVER_DISABLED
21254 + Set this to yes if you want to record the scheduling
21255 + decisions, so that they can be relayed to userspace
21256 + for detailed analysis.
21258 +config VSERVER_MONITOR_SIZE
21259 + int "Per-CPU Monitor Queue Size (32-65536)"
21260 + depends on VSERVER_MONITOR
21264 + This allows you to specify the number of entries in
21265 + the per-CPU scheduling monitor buffer.
21267 +config VSERVER_MONITOR_SYNC
21268 + int "Per-CPU Monitor Sync Interval (0-65536)"
21269 + depends on VSERVER_MONITOR
21273 + This allows you to specify the interval in ticks
21274 + when a time sync entry is inserted.
21282 + select NAMESPACES
21288 +config VSERVER_SECURITY
21290 + depends on SECURITY
21292 + select SECURITY_CAPABILITIES
21294 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/limit.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/limit.c
21295 --- linux-2.6.27.14/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21296 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/limit.c 2008-10-13 14:54:20.000000000 +0200
21299 + * linux/kernel/vserver/limit.c
21301 + * Virtual Server: Context Limits
21303 + * Copyright (C) 2004-2007 Herbert Pötzl
21305 + * V0.01 broken out from vcontext V0.05
21306 + * V0.02 changed vcmds to vxi arg
21310 +#include <linux/sched.h>
21311 +#include <linux/module.h>
21312 +#include <linux/vs_limit.h>
21313 +#include <linux/vserver/limit.h>
21314 +#include <linux/vserver/limit_cmd.h>
21316 +#include <asm/uaccess.h>
21319 +const char *vlimit_name[NUM_LIMITS] = {
21320 + [RLIMIT_CPU] = "CPU",
21321 + [RLIMIT_RSS] = "RSS",
21322 + [RLIMIT_NPROC] = "NPROC",
21323 + [RLIMIT_NOFILE] = "NOFILE",
21324 + [RLIMIT_MEMLOCK] = "VML",
21325 + [RLIMIT_AS] = "VM",
21326 + [RLIMIT_LOCKS] = "LOCKS",
21327 + [RLIMIT_SIGPENDING] = "SIGP",
21328 + [RLIMIT_MSGQUEUE] = "MSGQ",
21330 + [VLIMIT_NSOCK] = "NSOCK",
21331 + [VLIMIT_OPENFD] = "OPENFD",
21332 + [VLIMIT_ANON] = "ANON",
21333 + [VLIMIT_SHMEM] = "SHMEM",
21334 + [VLIMIT_DENTRY] = "DENTRY",
21337 +EXPORT_SYMBOL_GPL(vlimit_name);
21339 +#define MASK_ENTRY(x) (1 << (x))
21341 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21344 + , /* softlimit */
21345 + MASK_ENTRY( RLIMIT_RSS ) |
21346 + MASK_ENTRY( VLIMIT_ANON ) |
21349 + MASK_ENTRY( RLIMIT_RSS ) |
21350 + MASK_ENTRY( RLIMIT_NPROC ) |
21351 + MASK_ENTRY( RLIMIT_NOFILE ) |
21352 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21353 + MASK_ENTRY( RLIMIT_AS ) |
21354 + MASK_ENTRY( RLIMIT_LOCKS ) |
21355 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21357 + MASK_ENTRY( VLIMIT_NSOCK ) |
21358 + MASK_ENTRY( VLIMIT_OPENFD ) |
21359 + MASK_ENTRY( VLIMIT_ANON ) |
21360 + MASK_ENTRY( VLIMIT_SHMEM ) |
21361 + MASK_ENTRY( VLIMIT_DENTRY ) |
21364 + /* accounting only */
21365 +uint32_t account_mask =
21366 + MASK_ENTRY( VLIMIT_SEMARY ) |
21367 + MASK_ENTRY( VLIMIT_NSEMS ) |
21368 + MASK_ENTRY( VLIMIT_MAPPED ) |
21372 +static int is_valid_vlimit(int id)
21374 + uint32_t mask = vlimit_mask.minimum |
21375 + vlimit_mask.softlimit | vlimit_mask.maximum;
21376 + return mask & (1 << id);
21379 +static int is_accounted_vlimit(int id)
21381 + if (is_valid_vlimit(id))
21383 + return account_mask & (1 << id);
21387 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21389 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21390 + return VX_VLIM(limit);
21393 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21395 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21396 + return VX_VLIM(limit);
21399 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21400 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21402 + if (!is_valid_vlimit(id))
21406 + *minimum = CRLIM_UNSET;
21408 + *softlimit = vc_get_soft(vxi, id);
21410 + *maximum = vc_get_hard(vxi, id);
21414 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21416 + struct vcmd_ctx_rlimit_v0 vc_data;
21419 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21422 + ret = do_get_rlimit(vxi, vc_data.id,
21423 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21427 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21432 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21433 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21435 + if (!is_valid_vlimit(id))
21438 + if (maximum != CRLIM_KEEP)
21439 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21440 + if (softlimit != CRLIM_KEEP)
21441 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21443 + /* clamp soft limit */
21444 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21445 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21450 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21452 + struct vcmd_ctx_rlimit_v0 vc_data;
21454 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21457 + return do_set_rlimit(vxi, vc_data.id,
21458 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21461 +#ifdef CONFIG_IA32_EMULATION
21463 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21465 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21467 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21470 + return do_set_rlimit(vxi, vc_data.id,
21471 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21474 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21476 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21479 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21482 + ret = do_get_rlimit(vxi, vc_data.id,
21483 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21487 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21492 +#endif /* CONFIG_IA32_EMULATION */
21495 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21497 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21503 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21508 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21509 + value = __rlim_get(limit, lim);
21510 + __rlim_rmax(limit, lim) = value;
21511 + __rlim_rmin(limit, lim) = value;
21516 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21518 + vx_reset_minmax(&vxi->limit);
21523 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21525 + struct vcmd_rlimit_stat_v0 vc_data;
21526 + struct _vx_limit *limit = &vxi->limit;
21529 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21533 + if (!is_accounted_vlimit(id))
21536 + vx_limit_fixup(limit, id);
21537 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21538 + vc_data.value = __rlim_get(limit, id);
21539 + vc_data.minimum = __rlim_rmin(limit, id);
21540 + vc_data.maximum = __rlim_rmax(limit, id);
21542 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21548 +void vx_vsi_meminfo(struct sysinfo *val)
21550 + struct vx_info *vxi = current->vx_info;
21551 + unsigned long totalram, freeram;
21554 + /* we blindly accept the max */
21555 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21556 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21558 + /* total minus used equals free */
21559 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21560 + freeram = (v < totalram) ? totalram - v : 0;
21562 + val->totalram = totalram;
21563 + val->freeram = freeram;
21564 + val->bufferram = 0;
21565 + val->totalhigh = 0;
21566 + val->freehigh = 0;
21570 +void vx_vsi_swapinfo(struct sysinfo *val)
21572 + struct vx_info *vxi = current->vx_info;
21573 + unsigned long totalswap, freeswap;
21576 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21577 + if (v == RLIM_INFINITY) {
21578 + val->freeswap = val->totalswap;
21582 + /* we blindly accept the max */
21583 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21584 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
21586 + /* currently 'used' swap */
21587 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21588 + w -= (w > v) ? v : w;
21590 + /* total minus used equals free */
21591 + freeswap = (w < totalswap) ? totalswap - w : 0;
21593 + val->totalswap = totalswap;
21594 + val->freeswap = freeswap;
21599 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21601 + struct vx_info *vxi = mm->mm_vx_info;
21602 + unsigned long points;
21608 + points = vxi->vx_badness_bias;
21610 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21611 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21612 + points += (v > w) ? (v - w) : 0;
21617 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/limit_init.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/limit_init.h
21618 --- linux-2.6.27.14/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
21619 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/limit_init.h 2008-10-13 14:54:20.000000000 +0200
21623 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21627 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21628 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21629 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21630 + __rlim_set(limit, lim, 0);
21631 + atomic_set(&__rlim_lhit(limit, lim), 0);
21632 + __rlim_rmin(limit, lim) = 0;
21633 + __rlim_rmax(limit, lim) = 0;
21637 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21642 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21643 + if ((1 << lim) & VLIM_NOCHECK)
21645 + value = __rlim_get(limit, lim);
21646 + vxwprintk_xid(value,
21647 + "!!! limit: %p[%s,%d] = %ld on exit.",
21648 + limit, vlimit_name[lim], lim, (long)value);
21652 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/limit_proc.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/limit_proc.h
21653 --- linux-2.6.27.14/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
21654 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/limit_proc.h 2008-10-13 14:54:20.000000000 +0200
21656 +#ifndef _VX_LIMIT_PROC_H
21657 +#define _VX_LIMIT_PROC_H
21659 +#include <linux/vserver/limit_int.h>
21662 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21663 +#define VX_LIMIT_TOP \
21664 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21666 +#define VX_LIMIT_ARG(r) \
21667 + (unsigned long)__rlim_get(limit, r), \
21668 + (unsigned long)__rlim_rmin(limit, r), \
21669 + (unsigned long)__rlim_rmax(limit, r), \
21670 + VX_VLIM(__rlim_soft(limit, r)), \
21671 + VX_VLIM(__rlim_hard(limit, r)), \
21672 + atomic_read(&__rlim_lhit(limit, r))
21674 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21676 + vx_limit_fixup(limit, -1);
21677 + return sprintf(buffer, VX_LIMIT_TOP
21678 + "PROC" VX_LIMIT_FMT
21679 + "VM" VX_LIMIT_FMT
21680 + "VML" VX_LIMIT_FMT
21681 + "RSS" VX_LIMIT_FMT
21682 + "ANON" VX_LIMIT_FMT
21683 + "RMAP" VX_LIMIT_FMT
21684 + "FILES" VX_LIMIT_FMT
21685 + "OFD" VX_LIMIT_FMT
21686 + "LOCKS" VX_LIMIT_FMT
21687 + "SOCK" VX_LIMIT_FMT
21688 + "MSGQ" VX_LIMIT_FMT
21689 + "SHM" VX_LIMIT_FMT
21690 + "SEMA" VX_LIMIT_FMT
21691 + "SEMS" VX_LIMIT_FMT
21692 + "DENT" VX_LIMIT_FMT,
21693 + VX_LIMIT_ARG(RLIMIT_NPROC),
21694 + VX_LIMIT_ARG(RLIMIT_AS),
21695 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21696 + VX_LIMIT_ARG(RLIMIT_RSS),
21697 + VX_LIMIT_ARG(VLIMIT_ANON),
21698 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21699 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21700 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21701 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21702 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21703 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21704 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21705 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21706 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21707 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21710 +#endif /* _VX_LIMIT_PROC_H */
21713 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/Makefile linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/Makefile
21714 --- linux-2.6.27.14/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
21715 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/Makefile 2008-10-13 14:54:20.000000000 +0200
21718 +# Makefile for the Linux vserver routines.
21722 +obj-y += vserver.o
21724 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
21725 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
21728 +vserver-$(CONFIG_INET) += inet.o
21729 +vserver-$(CONFIG_PROC_FS) += proc.o
21730 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
21731 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
21732 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
21733 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
21735 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/monitor.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/monitor.c
21736 --- linux-2.6.27.14/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
21737 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/monitor.c 2008-10-13 14:54:20.000000000 +0200
21740 + * kernel/vserver/monitor.c
21742 + * Virtual Context Scheduler Monitor
21744 + * Copyright (C) 2006-2007 Herbert Pötzl
21746 + * V0.01 basic design
21750 +#include <linux/module.h>
21751 +#include <linux/jiffies.h>
21752 +#include <asm/uaccess.h>
21753 +#include <asm/atomic.h>
21755 +#include <linux/vserver/monitor.h>
21756 +#include <linux/vserver/debug_cmd.h>
21759 +#ifdef CONFIG_VSERVER_MONITOR
21760 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21762 +#define VXM_SIZE 64
21765 +struct _vx_monitor {
21766 + unsigned int counter;
21768 + struct _vx_mon_entry entry[VXM_SIZE+1];
21772 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21774 +unsigned volatile int vxm_active = 1;
21776 +static atomic_t sequence = ATOMIC_INIT(0);
21781 + * requires disabled preemption */
21783 +struct _vx_mon_entry *vxm_advance(int cpu)
21785 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21786 + struct _vx_mon_entry *entry;
21787 + unsigned int index;
21789 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21790 + entry = &mon->entry[index];
21792 + entry->ev.seq = atomic_inc_return(&sequence);
21793 + entry->ev.jif = jiffies;
21797 +EXPORT_SYMBOL_GPL(vxm_advance);
21800 +int do_read_monitor(struct __user _vx_mon_entry *data,
21801 + int cpu, uint32_t *index, uint32_t *count)
21803 + int pos, ret = 0;
21804 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21805 + int end = mon->counter;
21806 + int start = end - VXM_SIZE + 2;
21807 + int idx = *index;
21809 + /* special case: get current pos */
21815 + /* have we lost some data? */
21819 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21820 + struct _vx_mon_entry *entry =
21821 + &mon->entry[idx % VXM_SIZE];
21823 + /* send entry to userspace */
21824 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21828 + /* save new index and count */
21831 + return ret ? ret : (*index < end);
21834 +int vc_read_monitor(uint32_t id, void __user *data)
21836 + struct vcmd_read_monitor_v0 vc_data;
21839 + if (id >= NR_CPUS)
21842 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21845 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21846 + id, &vc_data.index, &vc_data.count);
21848 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21853 +#ifdef CONFIG_COMPAT
21855 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21857 + struct vcmd_read_monitor_v0_x32 vc_data;
21860 + if (id >= NR_CPUS)
21863 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21866 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21867 + compat_ptr(vc_data.data_ptr),
21868 + id, &vc_data.index, &vc_data.count);
21870 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21875 +#endif /* CONFIG_COMPAT */
21877 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/network.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/network.c
21878 --- linux-2.6.27.14/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
21879 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/network.c 2008-10-13 14:54:20.000000000 +0200
21882 + * linux/kernel/vserver/network.c
21884 + * Virtual Server: Network Support
21886 + * Copyright (C) 2003-2007 Herbert Pötzl
21888 + * V0.01 broken out from vcontext V0.05
21889 + * V0.02 cleaned up implementation
21890 + * V0.03 added equiv nx commands
21891 + * V0.04 switch to RCU based hash
21892 + * V0.05 and back to locking again
21893 + * V0.06 changed vcmds to nxi arg
21894 + * V0.07 have __create claim() the nxi
21898 +#include <linux/err.h>
21899 +#include <linux/slab.h>
21900 +#include <linux/rcupdate.h>
21902 +#include <linux/vs_network.h>
21903 +#include <linux/vs_pid.h>
21904 +#include <linux/vserver/network_cmd.h>
21907 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21908 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21910 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
21911 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
21914 +static int __init init_network(void)
21916 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
21917 + sizeof(struct nx_addr_v4), 0,
21918 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21919 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
21920 + sizeof(struct nx_addr_v6), 0,
21921 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
21926 +/* __alloc_nx_addr_v4() */
21928 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
21930 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
21931 + nx_addr_v4_cachep, GFP_KERNEL);
21933 + if (!IS_ERR(nxa))
21934 + memset(nxa, 0, sizeof(*nxa));
21938 +/* __dealloc_nx_addr_v4() */
21940 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
21942 + kmem_cache_free(nx_addr_v4_cachep, nxa);
21945 +/* __dealloc_nx_addr_v4_all() */
21947 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
21950 + struct nx_addr_v4 *next = nxa->next;
21952 + __dealloc_nx_addr_v4(nxa);
21958 +#ifdef CONFIG_IPV6
21960 +/* __alloc_nx_addr_v6() */
21962 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
21964 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
21965 + nx_addr_v6_cachep, GFP_KERNEL);
21967 + if (!IS_ERR(nxa))
21968 + memset(nxa, 0, sizeof(*nxa));
21972 +/* __dealloc_nx_addr_v6() */
21974 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
21976 + kmem_cache_free(nx_addr_v6_cachep, nxa);
21979 +/* __dealloc_nx_addr_v6_all() */
21981 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
21984 + struct nx_addr_v6 *next = nxa->next;
21986 + __dealloc_nx_addr_v6(nxa);
21991 +#endif /* CONFIG_IPV6 */
21993 +/* __alloc_nx_info()
21995 + * allocate an initialized nx_info struct
21996 + * doesn't make it visible (hash) */
21998 +static struct nx_info *__alloc_nx_info(nid_t nid)
22000 + struct nx_info *new = NULL;
22002 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22004 + /* would this benefit from a slab cache? */
22005 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22009 + memset(new, 0, sizeof(struct nx_info));
22010 + new->nx_id = nid;
22011 + INIT_HLIST_NODE(&new->nx_hlist);
22012 + atomic_set(&new->nx_usecnt, 0);
22013 + atomic_set(&new->nx_tasks, 0);
22014 + new->nx_state = 0;
22016 + new->nx_flags = NXF_INIT_SET;
22018 + /* rest of init goes here */
22020 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22021 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22023 + vxdprintk(VXD_CBIT(nid, 0),
22024 + "alloc_nx_info(%d) = %p", nid, new);
22025 + atomic_inc(&nx_global_ctotal);
22029 +/* __dealloc_nx_info()
22031 + * final disposal of nx_info */
22033 +static void __dealloc_nx_info(struct nx_info *nxi)
22035 + vxdprintk(VXD_CBIT(nid, 0),
22036 + "dealloc_nx_info(%p)", nxi);
22038 + nxi->nx_hlist.next = LIST_POISON1;
22041 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22042 + BUG_ON(atomic_read(&nxi->nx_tasks));
22044 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22046 + nxi->nx_state |= NXS_RELEASED;
22048 + atomic_dec(&nx_global_ctotal);
22051 +static void __shutdown_nx_info(struct nx_info *nxi)
22053 + nxi->nx_state |= NXS_SHUTDOWN;
22054 + vs_net_change(nxi, VSC_NETDOWN);
22057 +/* exported stuff */
22059 +void free_nx_info(struct nx_info *nxi)
22061 + /* context shutdown is mandatory */
22062 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22064 + /* context must not be hashed */
22065 + BUG_ON(nxi->nx_state & NXS_HASHED);
22067 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22068 + BUG_ON(atomic_read(&nxi->nx_tasks));
22070 + __dealloc_nx_info(nxi);
22074 +void __nx_set_lback(struct nx_info *nxi)
22076 + int nid = nxi->nx_id;
22077 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22079 + nxi->v4_lback.s_addr = lback;
22082 +extern int __nx_inet_add_lback(__be32 addr);
22083 +extern int __nx_inet_del_lback(__be32 addr);
22086 +/* hash table for nx_info hash */
22088 +#define NX_HASH_SIZE 13
22090 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22092 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22095 +static inline unsigned int __hashval(nid_t nid)
22097 + return (nid % NX_HASH_SIZE);
22102 +/* __hash_nx_info()
22104 + * add the nxi to the global hash table
22105 + * requires the hash_lock to be held */
22107 +static inline void __hash_nx_info(struct nx_info *nxi)
22109 + struct hlist_head *head;
22111 + vxd_assert_lock(&nx_info_hash_lock);
22112 + vxdprintk(VXD_CBIT(nid, 4),
22113 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22115 + /* context must not be hashed */
22116 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22118 + nxi->nx_state |= NXS_HASHED;
22119 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22120 + hlist_add_head(&nxi->nx_hlist, head);
22121 + atomic_inc(&nx_global_cactive);
22124 +/* __unhash_nx_info()
22126 + * remove the nxi from the global hash table
22127 + * requires the hash_lock to be held */
22129 +static inline void __unhash_nx_info(struct nx_info *nxi)
22131 + vxd_assert_lock(&nx_info_hash_lock);
22132 + vxdprintk(VXD_CBIT(nid, 4),
22133 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22134 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22136 + /* context must be hashed */
22137 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22138 + /* but without tasks */
22139 + BUG_ON(atomic_read(&nxi->nx_tasks));
22141 + nxi->nx_state &= ~NXS_HASHED;
22142 + hlist_del(&nxi->nx_hlist);
22143 + atomic_dec(&nx_global_cactive);
22147 +/* __lookup_nx_info()
22149 + * requires the hash_lock to be held
22150 + * doesn't increment the nx_refcnt */
22152 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22154 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22155 + struct hlist_node *pos;
22156 + struct nx_info *nxi;
22158 + vxd_assert_lock(&nx_info_hash_lock);
22159 + hlist_for_each(pos, head) {
22160 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22162 + if (nxi->nx_id == nid)
22167 + vxdprintk(VXD_CBIT(nid, 0),
22168 + "__lookup_nx_info(#%u): %p[#%u]",
22169 + nid, nxi, nxi ? nxi->nx_id : 0);
22174 +/* __create_nx_info()
22176 + * create the requested context
22177 + * get(), claim() and hash it */
22179 +static struct nx_info *__create_nx_info(int id)
22181 + struct nx_info *new, *nxi = NULL;
22183 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22185 + if (!(new = __alloc_nx_info(id)))
22186 + return ERR_PTR(-ENOMEM);
22188 + /* required to make dynamic xids unique */
22189 + spin_lock(&nx_info_hash_lock);
22191 + /* static context requested */
22192 + if ((nxi = __lookup_nx_info(id))) {
22193 + vxdprintk(VXD_CBIT(nid, 0),
22194 + "create_nx_info(%d) = %p (already there)", id, nxi);
22195 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22196 + nxi = ERR_PTR(-EBUSY);
22198 + nxi = ERR_PTR(-EEXIST);
22201 + /* new context */
22202 + vxdprintk(VXD_CBIT(nid, 0),
22203 + "create_nx_info(%d) = %p (new)", id, new);
22204 + claim_nx_info(new, NULL);
22205 + __nx_set_lback(new);
22206 + __hash_nx_info(get_nx_info(new));
22207 + nxi = new, new = NULL;
22210 + spin_unlock(&nx_info_hash_lock);
22212 + __dealloc_nx_info(new);
22218 +/* exported stuff */
22221 +void unhash_nx_info(struct nx_info *nxi)
22223 + __shutdown_nx_info(nxi);
22224 + spin_lock(&nx_info_hash_lock);
22225 + __unhash_nx_info(nxi);
22226 + spin_unlock(&nx_info_hash_lock);
22229 +/* lookup_nx_info()
22231 + * search for a nx_info and get() it
22232 + * negative id means current */
22234 +struct nx_info *lookup_nx_info(int id)
22236 + struct nx_info *nxi = NULL;
22239 + nxi = get_nx_info(current->nx_info);
22240 + } else if (id > 1) {
22241 + spin_lock(&nx_info_hash_lock);
22242 + nxi = get_nx_info(__lookup_nx_info(id));
22243 + spin_unlock(&nx_info_hash_lock);
22248 +/* nid_is_hashed()
22250 + * verify that nid is still hashed */
22252 +int nid_is_hashed(nid_t nid)
22256 + spin_lock(&nx_info_hash_lock);
22257 + hashed = (__lookup_nx_info(nid) != NULL);
22258 + spin_unlock(&nx_info_hash_lock);
22263 +#ifdef CONFIG_PROC_FS
22267 + * get a subset of hashed nids for proc
22268 + * assumes size is at least one */
22270 +int get_nid_list(int index, unsigned int *nids, int size)
22272 + int hindex, nr_nids = 0;
22274 + /* only show current and children */
22275 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22278 + nids[nr_nids] = nx_current_nid();
22282 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22283 + struct hlist_head *head = &nx_info_hash[hindex];
22284 + struct hlist_node *pos;
22286 + spin_lock(&nx_info_hash_lock);
22287 + hlist_for_each(pos, head) {
22288 + struct nx_info *nxi;
22293 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22294 + nids[nr_nids] = nxi->nx_id;
22295 + if (++nr_nids >= size) {
22296 + spin_unlock(&nx_info_hash_lock);
22300 + /* keep the lock time short */
22301 + spin_unlock(&nx_info_hash_lock);
22310 + * migrate task to new network
22311 + * gets nxi, puts old_nxi on change
22314 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22316 + struct nx_info *old_nxi;
22322 + vxdprintk(VXD_CBIT(nid, 5),
22323 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22324 + p, nxi, nxi->nx_id,
22325 + atomic_read(&nxi->nx_usecnt),
22326 + atomic_read(&nxi->nx_tasks));
22328 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22329 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22332 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22335 + /* maybe disallow this completely? */
22336 + old_nxi = task_get_nx_info(p);
22337 + if (old_nxi == nxi)
22342 + clr_nx_info(&p->nx_info);
22343 + claim_nx_info(nxi, p);
22344 + set_nx_info(&p->nx_info, nxi);
22345 + p->nid = nxi->nx_id;
22348 + vxdprintk(VXD_CBIT(nid, 5),
22349 + "moved task %p into nxi:%p[#%d]",
22350 + p, nxi, nxi->nx_id);
22353 + release_nx_info(old_nxi, p);
22356 + put_nx_info(old_nxi);
22361 +void nx_set_persistent(struct nx_info *nxi)
22363 + vxdprintk(VXD_CBIT(nid, 6),
22364 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22366 + get_nx_info(nxi);
22367 + claim_nx_info(nxi, NULL);
22370 +void nx_clear_persistent(struct nx_info *nxi)
22372 + vxdprintk(VXD_CBIT(nid, 6),
22373 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22375 + release_nx_info(nxi, NULL);
22376 + put_nx_info(nxi);
22379 +void nx_update_persistent(struct nx_info *nxi)
22381 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22382 + nx_set_persistent(nxi);
22384 + nx_clear_persistent(nxi);
22387 +/* vserver syscall commands below here */
22389 +/* taks nid and nx_info functions */
22391 +#include <asm/uaccess.h>
22394 +int vc_task_nid(uint32_t id)
22399 + struct task_struct *tsk;
22401 + read_lock(&tasklist_lock);
22402 + tsk = find_task_by_real_pid(id);
22403 + nid = (tsk) ? tsk->nid : -ESRCH;
22404 + read_unlock(&tasklist_lock);
22406 + nid = nx_current_nid();
22411 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22413 + struct vcmd_nx_info_v0 vc_data;
22415 + vc_data.nid = nxi->nx_id;
22417 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22423 +/* network functions */
22425 +int vc_net_create(uint32_t nid, void __user *data)
22427 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22428 + struct nx_info *new_nxi;
22431 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22434 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22437 + new_nxi = __create_nx_info(nid);
22438 + if (IS_ERR(new_nxi))
22439 + return PTR_ERR(new_nxi);
22441 + /* initial flags */
22442 + new_nxi->nx_flags = vc_data.flagword;
22445 + if (vs_net_change(new_nxi, VSC_NETUP))
22448 + ret = nx_migrate_task(current, new_nxi);
22452 + /* return context id on success */
22453 + ret = new_nxi->nx_id;
22455 + /* get a reference for persistent contexts */
22456 + if ((vc_data.flagword & NXF_PERSISTENT))
22457 + nx_set_persistent(new_nxi);
22459 + release_nx_info(new_nxi, NULL);
22460 + put_nx_info(new_nxi);
22465 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22467 + return nx_migrate_task(current, nxi);
22472 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22473 + uint16_t type, uint16_t flags)
22475 + struct nx_addr_v4 *nxa = &nxi->v4;
22477 + if (NX_IPV4(nxi)) {
22478 + /* locate last entry */
22479 + for (; nxa->next; nxa = nxa->next);
22480 + nxa->next = __alloc_nx_addr_v4();
22484 + return PTR_ERR(nxa);
22487 + if (nxi->v4.next)
22488 + /* remove single ip for ip list */
22489 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22491 + nxa->ip[0].s_addr = ip;
22492 + nxa->ip[1].s_addr = ip2;
22493 + nxa->mask.s_addr = mask;
22494 + nxa->type = type;
22495 + nxa->flags = flags;
22500 +int vc_net_add(struct nx_info *nxi, void __user *data)
22502 + struct vcmd_net_addr_v0 vc_data;
22503 + int index, ret = 0;
22505 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22508 + switch (vc_data.type) {
22509 + case NXA_TYPE_IPV4:
22510 + if ((vc_data.count < 1) || (vc_data.count > 4))
22514 + while (index < vc_data.count) {
22515 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22516 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22524 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22525 + nxi->v4_bcast = vc_data.ip[0];
22529 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22530 + nxi->v4_lback = vc_data.ip[0];
22541 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22543 + struct vcmd_net_addr_v0 vc_data;
22545 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22548 + switch (vc_data.type) {
22549 + case NXA_TYPE_ANY:
22550 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22551 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22561 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22563 + struct vcmd_net_addr_ipv4_v1 vc_data;
22565 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22568 + switch (vc_data.type) {
22569 + case NXA_TYPE_ADDR:
22570 + case NXA_TYPE_RANGE:
22571 + case NXA_TYPE_MASK:
22572 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22573 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22575 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22576 + nxi->v4_bcast = vc_data.ip;
22579 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22580 + nxi->v4_lback = vc_data.ip;
22589 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
22591 + struct vcmd_net_addr_ipv4_v1 vc_data;
22593 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22596 + switch (vc_data.type) {
22597 +/* case NXA_TYPE_ADDR:
22600 + case NXA_TYPE_ANY:
22601 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22602 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22612 +#ifdef CONFIG_IPV6
22614 +int do_add_v6_addr(struct nx_info *nxi,
22615 + struct in6_addr *ip, struct in6_addr *mask,
22616 + uint32_t prefix, uint16_t type, uint16_t flags)
22618 + struct nx_addr_v6 *nxa = &nxi->v6;
22620 + if (NX_IPV6(nxi)) {
22621 + /* locate last entry */
22622 + for (; nxa->next; nxa = nxa->next);
22623 + nxa->next = __alloc_nx_addr_v6();
22627 + return PTR_ERR(nxa);
22631 + nxa->mask = *mask;
22632 + nxa->prefix = prefix;
22633 + nxa->type = type;
22634 + nxa->flags = flags;
22639 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
22641 + struct vcmd_net_addr_ipv6_v1 vc_data;
22643 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22646 + switch (vc_data.type) {
22647 + case NXA_TYPE_ADDR:
22648 + case NXA_TYPE_MASK:
22649 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
22650 + vc_data.prefix, vc_data.type, vc_data.flags);
22657 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
22659 + struct vcmd_net_addr_ipv6_v1 vc_data;
22661 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22664 + switch (vc_data.type) {
22665 + case NXA_TYPE_ANY:
22666 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
22667 + memset(&nxi->v6, 0, sizeof(nxi->v6));
22676 +#endif /* CONFIG_IPV6 */
22679 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22681 + struct vcmd_net_flags_v0 vc_data;
22683 + vc_data.flagword = nxi->nx_flags;
22685 + /* special STATE flag handling */
22686 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22688 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22693 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22695 + struct vcmd_net_flags_v0 vc_data;
22696 + uint64_t mask, trigger;
22698 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22701 + /* special STATE flag handling */
22702 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22703 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22705 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22706 + vc_data.flagword, mask);
22707 + if (trigger & NXF_PERSISTENT)
22708 + nx_update_persistent(nxi);
22713 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22715 + struct vcmd_net_caps_v0 vc_data;
22717 + vc_data.ncaps = nxi->nx_ncaps;
22718 + vc_data.cmask = ~0ULL;
22720 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22725 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22727 + struct vcmd_net_caps_v0 vc_data;
22729 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22732 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22733 + vc_data.ncaps, vc_data.cmask);
22738 +#include <linux/module.h>
22740 +module_init(init_network);
22742 +EXPORT_SYMBOL_GPL(free_nx_info);
22743 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22745 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/proc.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/proc.c
22746 --- linux-2.6.27.14/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22747 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/proc.c 2008-10-31 18:15:28.000000000 +0100
22750 + * linux/kernel/vserver/proc.c
22752 + * Virtual Context Support
22754 + * Copyright (C) 2003-2007 Herbert Pötzl
22756 + * V0.01 basic structure
22757 + * V0.02 adaptation vs1.3.0
22758 + * V0.03 proc permissions
22759 + * V0.04 locking/generic
22760 + * V0.05 next generation procfs
22761 + * V0.06 inode validation
22762 + * V0.07 generic rewrite vid
22763 + * V0.08 remove inode type
22767 +#include <linux/proc_fs.h>
22768 +#include <asm/unistd.h>
22770 +#include <linux/vs_context.h>
22771 +#include <linux/vs_network.h>
22772 +#include <linux/vs_cvirt.h>
22774 +#include <linux/in.h>
22775 +#include <linux/inetdevice.h>
22776 +#include <linux/vs_inet.h>
22777 +#include <linux/vs_inet6.h>
22779 +#include <linux/vserver/global.h>
22781 +#include "cvirt_proc.h"
22782 +#include "cacct_proc.h"
22783 +#include "limit_proc.h"
22784 +#include "sched_proc.h"
22785 +#include "vci_config.h"
22788 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22792 + CAP_FOR_EACH_U32(__capi) {
22793 + buffer += sprintf(buffer, "%08x",
22794 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22800 +static struct proc_dir_entry *proc_virtual;
22802 +static struct proc_dir_entry *proc_virtnet;
22805 +/* first the actual feeds */
22808 +static int proc_vci(char *buffer)
22810 + return sprintf(buffer,
22811 + "VCIVersion:\t%04x:%04x\n"
22812 + "VCISyscall:\t%d\n"
22813 + "VCIKernel:\t%08x\n",
22814 + VCI_VERSION >> 16,
22815 + VCI_VERSION & 0xFFFF,
22817 + vci_kernel_config());
22820 +static int proc_virtual_info(char *buffer)
22822 + return proc_vci(buffer);
22825 +static int proc_virtual_status(char *buffer)
22827 + return sprintf(buffer,
22829 + "#CActive:\t%d\n"
22830 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
22831 + atomic_read(&vx_global_ctotal),
22832 + atomic_read(&vx_global_cactive),
22833 + atomic_read(&vs_global_nsproxy),
22834 + atomic_read(&vs_global_fs),
22835 + atomic_read(&vs_global_mnt_ns),
22836 + atomic_read(&vs_global_uts_ns),
22837 + atomic_read(&vs_global_ipc_ns),
22838 + atomic_read(&vs_global_user_ns),
22839 + atomic_read(&vs_global_pid_ns));
22843 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22847 + length = sprintf(buffer,
22855 + vxi->vx_badness_bias);
22859 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22861 + char *orig = buffer;
22863 + buffer += sprintf(buffer,
22866 + "Flags:\t%016llx\n",
22867 + atomic_read(&vxi->vx_usecnt),
22868 + atomic_read(&vxi->vx_tasks),
22869 + (unsigned long long)vxi->vx_flags);
22871 + buffer += sprintf(buffer, "BCaps:\t");
22872 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22873 + buffer += sprintf(buffer, "\n");
22875 + buffer += sprintf(buffer,
22876 + "CCaps:\t%016llx\n"
22877 + "Spaces:\t%08lx %08lx\n",
22878 + (unsigned long long)vxi->vx_ccaps,
22879 + vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
22880 + return buffer - orig;
22883 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22885 + return vx_info_proc_limit(&vxi->limit, buffer);
22888 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22892 + length = vx_info_proc_sched(&vxi->sched, buffer);
22893 + for_each_online_cpu(cpu) {
22894 + length += vx_info_proc_sched_pc(
22895 + &vx_per_cpu(vxi, sched_pc, cpu),
22896 + buffer + length, cpu);
22901 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
22903 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
22906 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
22908 + return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
22911 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22915 + vx_update_load(vxi);
22916 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22917 + for_each_online_cpu(cpu) {
22918 + length += vx_info_proc_cvirt_pc(
22919 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22920 + buffer + length, cpu);
22925 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22927 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22931 +static int proc_virtnet_info(char *buffer)
22933 + return proc_vci(buffer);
22936 +static int proc_virtnet_status(char *buffer)
22938 + return sprintf(buffer,
22940 + "#CActive:\t%d\n",
22941 + atomic_read(&nx_global_ctotal),
22942 + atomic_read(&nx_global_cactive));
22945 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22947 + struct nx_addr_v4 *v4a;
22948 +#ifdef CONFIG_IPV6
22949 + struct nx_addr_v6 *v6a;
22953 + length = sprintf(buffer,
22956 + "Bcast:\t" NIPQUAD_FMT "\n"
22957 + "Lback:\t" NIPQUAD_FMT "\n",
22960 + NIPQUAD(nxi->v4_bcast.s_addr),
22961 + NIPQUAD(nxi->v4_lback.s_addr));
22963 + if (!NX_IPV4(nxi))
22965 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22966 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
22969 +#ifdef CONFIG_IPV6
22970 + if (!NX_IPV6(nxi))
22972 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22973 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
22980 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22984 + length = sprintf(buffer,
22987 + "Flags:\t%016llx\n"
22988 + "NCaps:\t%016llx\n",
22989 + atomic_read(&nxi->nx_usecnt),
22990 + atomic_read(&nxi->nx_tasks),
22991 + (unsigned long long)nxi->nx_flags,
22992 + (unsigned long long)nxi->nx_ncaps);
22998 +/* here the inode helpers */
23004 + struct inode_operations *iop;
23005 + struct file_operations *fop;
23006 + union proc_op op;
23009 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23011 + struct inode *inode = new_inode(sb);
23016 + inode->i_mode = p->mode;
23018 + inode->i_op = p->iop;
23020 + inode->i_fop = p->fop;
23022 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23023 + inode->i_flags |= S_IMMUTABLE;
23025 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23027 + inode->i_uid = 0;
23028 + inode->i_gid = 0;
23029 + inode->i_tag = 0;
23034 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23035 + struct dentry *dentry, int id, void *ptr)
23037 + struct vs_entry *p = ptr;
23038 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23039 + struct dentry *error = ERR_PTR(-EINVAL);
23044 + PROC_I(inode)->op = p->op;
23045 + PROC_I(inode)->fd = id;
23046 + d_add(dentry, inode);
23054 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23057 + * Fill a directory entry.
23059 + * If possible create the dcache entry and derive our inode number and
23060 + * file type from dcache entry.
23062 + * Since all of the proc inode numbers are dynamically generated, the inode
23063 + * numbers do not exist until the inode is cache. This means creating the
23064 + * the dcache entry in readdir is necessary to keep the inode numbers
23065 + * reported by readdir in sync with the inode numbers reported
23068 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23069 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23071 + struct dentry *child, *dir = filp->f_dentry;
23072 + struct inode *inode;
23073 + struct qstr qname;
23075 + unsigned type = DT_UNKNOWN;
23077 + qname.name = name;
23079 + qname.hash = full_name_hash(name, len);
23081 + child = d_lookup(dir, &qname);
23083 + struct dentry *new;
23084 + new = d_alloc(dir, &qname);
23086 + child = instantiate(dir->d_inode, new, id, ptr);
23093 + if (!child || IS_ERR(child) || !child->d_inode)
23094 + goto end_instantiate;
23095 + inode = child->d_inode;
23097 + ino = inode->i_ino;
23098 + type = inode->i_mode >> 12;
23103 + ino = find_inode_number(dir, &qname);
23106 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23111 +/* get and revalidate vx_info/xid */
23114 +struct vx_info *get_proc_vx_info(struct inode *inode)
23116 + return lookup_vx_info(PROC_I(inode)->fd);
23119 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23121 + struct inode *inode = dentry->d_inode;
23122 + xid_t xid = PROC_I(inode)->fd;
23124 + if (!xid || xid_is_hashed(xid))
23131 +/* get and revalidate nx_info/nid */
23133 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23135 + struct inode *inode = dentry->d_inode;
23136 + nid_t nid = PROC_I(inode)->fd;
23138 + if (!nid || nid_is_hashed(nid))
23146 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23148 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23149 + size_t count, loff_t *ppos)
23151 + struct inode *inode = file->f_dentry->d_inode;
23152 + unsigned long page;
23153 + ssize_t length = 0;
23155 + if (count > PROC_BLOCK_SIZE)
23156 + count = PROC_BLOCK_SIZE;
23158 + /* fade that out as soon as stable */
23159 + WARN_ON(PROC_I(inode)->fd);
23161 + if (!(page = __get_free_page(GFP_KERNEL)))
23164 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23165 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23168 + length = simple_read_from_buffer(buf, count, ppos,
23169 + (char *)page, length);
23175 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23176 + size_t count, loff_t *ppos)
23178 + struct inode *inode = file->f_dentry->d_inode;
23179 + struct vx_info *vxi = NULL;
23180 + xid_t xid = PROC_I(inode)->fd;
23181 + unsigned long page;
23182 + ssize_t length = 0;
23184 + if (count > PROC_BLOCK_SIZE)
23185 + count = PROC_BLOCK_SIZE;
23187 + /* fade that out as soon as stable */
23189 + vxi = lookup_vx_info(xid);
23193 + length = -ENOMEM;
23194 + if (!(page = __get_free_page(GFP_KERNEL)))
23197 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23198 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23201 + length = simple_read_from_buffer(buf, count, ppos,
23202 + (char *)page, length);
23206 + put_vx_info(vxi);
23211 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23212 + size_t count, loff_t *ppos)
23214 + struct inode *inode = file->f_dentry->d_inode;
23215 + struct nx_info *nxi = NULL;
23216 + nid_t nid = PROC_I(inode)->fd;
23217 + unsigned long page;
23218 + ssize_t length = 0;
23220 + if (count > PROC_BLOCK_SIZE)
23221 + count = PROC_BLOCK_SIZE;
23223 + /* fade that out as soon as stable */
23225 + nxi = lookup_nx_info(nid);
23229 + length = -ENOMEM;
23230 + if (!(page = __get_free_page(GFP_KERNEL)))
23233 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23234 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23237 + length = simple_read_from_buffer(buf, count, ppos,
23238 + (char *)page, length);
23242 + put_nx_info(nxi);
23249 +/* here comes the lower level */
23252 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23253 + .len = sizeof(NAME) - 1, \
23254 + .name = (NAME), \
23262 +#define DIR(NAME, MODE, OTYPE) \
23263 + NOD(NAME, (S_IFDIR | (MODE)), \
23264 + &proc_ ## OTYPE ## _inode_operations, \
23265 + &proc_ ## OTYPE ## _file_operations, { } )
23267 +#define INF(NAME, MODE, OTYPE) \
23268 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23269 + &proc_vs_info_file_operations, \
23270 + { .proc_vs_read = &proc_##OTYPE } )
23272 +#define VINF(NAME, MODE, OTYPE) \
23273 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23274 + &proc_vx_info_file_operations, \
23275 + { .proc_vxi_read = &proc_##OTYPE } )
23277 +#define NINF(NAME, MODE, OTYPE) \
23278 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23279 + &proc_nx_info_file_operations, \
23280 + { .proc_nxi_read = &proc_##OTYPE } )
23283 +static struct file_operations proc_vs_info_file_operations = {
23284 + .read = proc_vs_info_read,
23287 +static struct file_operations proc_vx_info_file_operations = {
23288 + .read = proc_vx_info_read,
23291 +static struct dentry_operations proc_xid_dentry_operations = {
23292 + .d_revalidate = proc_xid_revalidate,
23295 +static struct vs_entry vx_base_stuff[] = {
23296 + VINF("info", S_IRUGO, vxi_info),
23297 + VINF("status", S_IRUGO, vxi_status),
23298 + VINF("limit", S_IRUGO, vxi_limit),
23299 + VINF("sched", S_IRUGO, vxi_sched),
23300 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23301 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23302 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23303 + VINF("cacct", S_IRUGO, vxi_cacct),
23310 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23311 + struct dentry *dentry, int id, void *ptr)
23313 + dentry->d_op = &proc_xid_dentry_operations;
23314 + return vs_proc_instantiate(dir, dentry, id, ptr);
23317 +static struct dentry *proc_xid_lookup(struct inode *dir,
23318 + struct dentry *dentry, struct nameidata *nd)
23320 + struct vs_entry *p = vx_base_stuff;
23321 + struct dentry *error = ERR_PTR(-ENOENT);
23323 + for (; p->name; p++) {
23324 + if (p->len != dentry->d_name.len)
23326 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23332 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23337 +static int proc_xid_readdir(struct file *filp,
23338 + void *dirent, filldir_t filldir)
23340 + struct dentry *dentry = filp->f_dentry;
23341 + struct inode *inode = dentry->d_inode;
23342 + struct vs_entry *p = vx_base_stuff;
23343 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23347 + pos = filp->f_pos;
23350 + ino = inode->i_ino;
23351 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23354 + /* fall through */
23356 + ino = parent_ino(dentry);
23357 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23360 + /* fall through */
23363 + if (index >= size)
23365 + for (p += index; p->name; p++) {
23366 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23367 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23373 + filp->f_pos = pos;
23379 +static struct file_operations proc_nx_info_file_operations = {
23380 + .read = proc_nx_info_read,
23383 +static struct dentry_operations proc_nid_dentry_operations = {
23384 + .d_revalidate = proc_nid_revalidate,
23387 +static struct vs_entry nx_base_stuff[] = {
23388 + NINF("info", S_IRUGO, nxi_info),
23389 + NINF("status", S_IRUGO, nxi_status),
23394 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23395 + struct dentry *dentry, int id, void *ptr)
23397 + dentry->d_op = &proc_nid_dentry_operations;
23398 + return vs_proc_instantiate(dir, dentry, id, ptr);
23401 +static struct dentry *proc_nid_lookup(struct inode *dir,
23402 + struct dentry *dentry, struct nameidata *nd)
23404 + struct vs_entry *p = nx_base_stuff;
23405 + struct dentry *error = ERR_PTR(-ENOENT);
23407 + for (; p->name; p++) {
23408 + if (p->len != dentry->d_name.len)
23410 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23416 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23421 +static int proc_nid_readdir(struct file *filp,
23422 + void *dirent, filldir_t filldir)
23424 + struct dentry *dentry = filp->f_dentry;
23425 + struct inode *inode = dentry->d_inode;
23426 + struct vs_entry *p = nx_base_stuff;
23427 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23431 + pos = filp->f_pos;
23434 + ino = inode->i_ino;
23435 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23438 + /* fall through */
23440 + ino = parent_ino(dentry);
23441 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23444 + /* fall through */
23447 + if (index >= size)
23449 + for (p += index; p->name; p++) {
23450 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23451 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23457 + filp->f_pos = pos;
23462 +#define MAX_MULBY10 ((~0U - 9) / 10)
23464 +static inline int atovid(const char *str, int len)
23469 + while (len-- > 0) {
23474 + if (vid >= MAX_MULBY10)
23484 +/* now the upper level (virtual) */
23487 +static struct file_operations proc_xid_file_operations = {
23488 + .read = generic_read_dir,
23489 + .readdir = proc_xid_readdir,
23492 +static struct inode_operations proc_xid_inode_operations = {
23493 + .lookup = proc_xid_lookup,
23496 +static struct vs_entry vx_virtual_stuff[] = {
23497 + INF("info", S_IRUGO, virtual_info),
23498 + INF("status", S_IRUGO, virtual_status),
23499 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23503 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23504 + struct dentry *dentry, struct nameidata *nd)
23506 + struct vs_entry *p = vx_virtual_stuff;
23507 + struct dentry *error = ERR_PTR(-ENOENT);
23510 + for (; p->name; p++) {
23511 + if (p->len != dentry->d_name.len)
23513 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23517 + goto instantiate;
23519 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23520 + if ((id < 0) || !xid_is_hashed(id))
23524 + error = proc_xid_instantiate(dir, dentry, id, p);
23529 +static struct file_operations proc_nid_file_operations = {
23530 + .read = generic_read_dir,
23531 + .readdir = proc_nid_readdir,
23534 +static struct inode_operations proc_nid_inode_operations = {
23535 + .lookup = proc_nid_lookup,
23538 +static struct vs_entry nx_virtnet_stuff[] = {
23539 + INF("info", S_IRUGO, virtnet_info),
23540 + INF("status", S_IRUGO, virtnet_status),
23541 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23545 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23546 + struct dentry *dentry, struct nameidata *nd)
23548 + struct vs_entry *p = nx_virtnet_stuff;
23549 + struct dentry *error = ERR_PTR(-ENOENT);
23552 + for (; p->name; p++) {
23553 + if (p->len != dentry->d_name.len)
23555 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23559 + goto instantiate;
23561 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23562 + if ((id < 0) || !nid_is_hashed(id))
23566 + error = proc_nid_instantiate(dir, dentry, id, p);
23572 +#define PROC_MAXVIDS 32
23574 +int proc_virtual_readdir(struct file *filp,
23575 + void *dirent, filldir_t filldir)
23577 + struct dentry *dentry = filp->f_dentry;
23578 + struct inode *inode = dentry->d_inode;
23579 + struct vs_entry *p = vx_virtual_stuff;
23580 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23582 + unsigned int xid_array[PROC_MAXVIDS];
23583 + char buf[PROC_NUMBUF];
23584 + unsigned int nr_xids, i;
23587 + pos = filp->f_pos;
23590 + ino = inode->i_ino;
23591 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23594 + /* fall through */
23596 + ino = parent_ino(dentry);
23597 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23600 + /* fall through */
23603 + if (index >= size)
23605 + for (p += index; p->name; p++) {
23606 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23607 + vs_proc_instantiate, 0, p))
23612 + index = pos - size;
23613 + p = &vx_virtual_stuff[size - 1];
23614 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23615 + for (i = 0; i < nr_xids; i++) {
23616 + int n, xid = xid_array[i];
23617 + unsigned int j = PROC_NUMBUF;
23621 + buf[--j] = '0' + (n % 10);
23624 + if (proc_fill_cache(filp, dirent, filldir,
23625 + buf + j, PROC_NUMBUF - j,
23626 + vs_proc_instantiate, xid, p))
23632 + filp->f_pos = pos;
23636 +static int proc_virtual_getattr(struct vfsmount *mnt,
23637 + struct dentry *dentry, struct kstat *stat)
23639 + struct inode *inode = dentry->d_inode;
23641 + generic_fillattr(inode, stat);
23642 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23646 +static struct file_operations proc_virtual_dir_operations = {
23647 + .read = generic_read_dir,
23648 + .readdir = proc_virtual_readdir,
23651 +static struct inode_operations proc_virtual_dir_inode_operations = {
23652 + .getattr = proc_virtual_getattr,
23653 + .lookup = proc_virtual_lookup,
23660 +int proc_virtnet_readdir(struct file *filp,
23661 + void *dirent, filldir_t filldir)
23663 + struct dentry *dentry = filp->f_dentry;
23664 + struct inode *inode = dentry->d_inode;
23665 + struct vs_entry *p = nx_virtnet_stuff;
23666 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23668 + unsigned int nid_array[PROC_MAXVIDS];
23669 + char buf[PROC_NUMBUF];
23670 + unsigned int nr_nids, i;
23673 + pos = filp->f_pos;
23676 + ino = inode->i_ino;
23677 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23680 + /* fall through */
23682 + ino = parent_ino(dentry);
23683 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23686 + /* fall through */
23689 + if (index >= size)
23691 + for (p += index; p->name; p++) {
23692 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23693 + vs_proc_instantiate, 0, p))
23698 + index = pos - size;
23699 + p = &nx_virtnet_stuff[size - 1];
23700 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23701 + for (i = 0; i < nr_nids; i++) {
23702 + int n, nid = nid_array[i];
23703 + unsigned int j = PROC_NUMBUF;
23707 + buf[--j] = '0' + (n % 10);
23710 + if (proc_fill_cache(filp, dirent, filldir,
23711 + buf + j, PROC_NUMBUF - j,
23712 + vs_proc_instantiate, nid, p))
23718 + filp->f_pos = pos;
23722 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23723 + struct dentry *dentry, struct kstat *stat)
23725 + struct inode *inode = dentry->d_inode;
23727 + generic_fillattr(inode, stat);
23728 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23732 +static struct file_operations proc_virtnet_dir_operations = {
23733 + .read = generic_read_dir,
23734 + .readdir = proc_virtnet_readdir,
23737 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23738 + .getattr = proc_virtnet_getattr,
23739 + .lookup = proc_virtnet_lookup,
23744 +void proc_vx_init(void)
23746 + struct proc_dir_entry *ent;
23748 + ent = proc_mkdir("virtual", 0);
23750 + ent->proc_fops = &proc_virtual_dir_operations;
23751 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23753 + proc_virtual = ent;
23755 + ent = proc_mkdir("virtnet", 0);
23757 + ent->proc_fops = &proc_virtnet_dir_operations;
23758 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23760 + proc_virtnet = ent;
23766 +/* per pid info */
23769 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23771 + struct vx_info *vxi;
23772 + char *orig = buffer;
23774 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23776 + vxi = task_get_vx_info(p);
23780 + buffer += sprintf(buffer, "BCaps:\t");
23781 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23782 + buffer += sprintf(buffer, "\n");
23783 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23784 + (unsigned long long)vxi->vx_ccaps);
23785 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23786 + (unsigned long long)vxi->vx_flags);
23787 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23789 + put_vx_info(vxi);
23791 + return buffer - orig;
23795 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23797 + struct nx_info *nxi;
23798 + struct nx_addr_v4 *v4a;
23799 +#ifdef CONFIG_IPV6
23800 + struct nx_addr_v6 *v6a;
23802 + char *orig = buffer;
23805 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23807 + nxi = task_get_nx_info(p);
23811 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23812 + (unsigned long long)nxi->nx_ncaps);
23813 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23814 + (unsigned long long)nxi->nx_flags);
23816 + buffer += sprintf(buffer,
23817 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23818 + NIPQUAD(nxi->v4_bcast.s_addr));
23819 + buffer += sprintf (buffer,
23820 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
23821 + NIPQUAD(nxi->v4_lback.s_addr));
23822 + if (!NX_IPV4(nxi))
23824 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23825 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
23828 +#ifdef CONFIG_IPV6
23829 + if (!NX_IPV6(nxi))
23831 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23832 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
23836 + put_nx_info(nxi);
23838 + return buffer - orig;
23841 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/sched.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sched.c
23842 --- linux-2.6.27.14/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
23843 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sched.c 2008-10-13 14:54:20.000000000 +0200
23846 + * linux/kernel/vserver/sched.c
23848 + * Virtual Server: Scheduler Support
23850 + * Copyright (C) 2004-2007 Herbert Pötzl
23852 + * V0.01 adapted Sam Vilains version to 2.6.3
23853 + * V0.02 removed legacy interface
23854 + * V0.03 changed vcmds to vxi arg
23855 + * V0.04 removed older and legacy interfaces
23859 +#include <linux/vs_context.h>
23860 +#include <linux/vs_sched.h>
23861 +#include <linux/vserver/sched_cmd.h>
23863 +#include <asm/uaccess.h>
23866 +#define vxd_check_range(val, min, max) do { \
23867 + vxlprintk((val < min) || (val > max), \
23868 + "check_range(%ld,%ld,%ld)", \
23869 + (long)val, (long)min, (long)max, \
23870 + __FILE__, __LINE__); \
23874 +void vx_update_sched_param(struct _vx_sched *sched,
23875 + struct _vx_sched_pc *sched_pc)
23877 + unsigned int set_mask = sched->update_mask;
23879 + if (set_mask & VXSM_FILL_RATE)
23880 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23881 + if (set_mask & VXSM_INTERVAL)
23882 + sched_pc->interval[0] = sched->interval[0];
23883 + if (set_mask & VXSM_FILL_RATE2)
23884 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23885 + if (set_mask & VXSM_INTERVAL2)
23886 + sched_pc->interval[1] = sched->interval[1];
23887 + if (set_mask & VXSM_TOKENS)
23888 + sched_pc->tokens = sched->tokens;
23889 + if (set_mask & VXSM_TOKENS_MIN)
23890 + sched_pc->tokens_min = sched->tokens_min;
23891 + if (set_mask & VXSM_TOKENS_MAX)
23892 + sched_pc->tokens_max = sched->tokens_max;
23893 + if (set_mask & VXSM_PRIO_BIAS)
23894 + sched_pc->prio_bias = sched->prio_bias;
23896 + if (set_mask & VXSM_IDLE_TIME)
23897 + sched_pc->flags |= VXSF_IDLE_TIME;
23899 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23902 + sched_pc->norm_time = jiffies;
23907 + * recalculate the context's scheduling tokens
23909 + * ret > 0 : number of tokens available
23910 + * ret < 0 : on hold, check delta_min[]
23911 + * -1 only jiffies
23912 + * -2 also idle time
23915 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23916 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23920 + int flags = sched_pc->flags;
23922 + /* how much time did pass? */
23923 + delta = *norm_time - sched_pc->norm_time;
23924 + vxd_check_range(delta, 0, INT_MAX);
23926 + if (delta >= sched_pc->interval[0]) {
23927 + long tokens, integral;
23929 + /* calc integral token part */
23930 + tokens = delta / sched_pc->interval[0];
23931 + integral = tokens * sched_pc->interval[0];
23932 + tokens *= sched_pc->fill_rate[0];
23933 +#ifdef CONFIG_VSERVER_HARDCPU
23934 + delta_min[0] = delta - integral;
23935 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23937 + /* advance time */
23938 + sched_pc->norm_time += delta;
23941 + sched_pc->tokens += tokens;
23942 + sched_pc->token_time += tokens;
23944 + delta_min[0] = delta;
23946 +#ifdef CONFIG_VSERVER_IDLETIME
23947 + if (!(flags & VXSF_IDLE_TIME))
23950 + /* how much was the idle skip? */
23951 + delta = *idle_time - sched_pc->idle_time;
23952 + vxd_check_range(delta, 0, INT_MAX);
23954 + if (delta >= sched_pc->interval[1]) {
23955 + long tokens, integral;
23957 + /* calc fair share token part */
23958 + tokens = delta / sched_pc->interval[1];
23959 + integral = tokens * sched_pc->interval[1];
23960 + tokens *= sched_pc->fill_rate[1];
23961 + delta_min[1] = delta - integral;
23962 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23964 + /* advance idle time */
23965 + sched_pc->idle_time += integral;
23968 + sched_pc->tokens += tokens;
23969 + sched_pc->token_time += tokens;
23971 + delta_min[1] = delta;
23975 + /* clip at maximum */
23976 + if (sched_pc->tokens > sched_pc->tokens_max)
23977 + sched_pc->tokens = sched_pc->tokens_max;
23978 + tokens = sched_pc->tokens;
23980 + if ((flags & VXSF_ONHOLD)) {
23981 + /* can we unhold? */
23982 + if (tokens >= sched_pc->tokens_min) {
23983 + flags &= ~VXSF_ONHOLD;
23984 + sched_pc->hold_ticks +=
23985 + *norm_time - sched_pc->onhold;
23989 + /* put on hold? */
23990 + if (tokens <= 0) {
23991 + flags |= VXSF_ONHOLD;
23992 + sched_pc->onhold = *norm_time;
23996 + sched_pc->flags = flags;
24000 + tokens = sched_pc->tokens_min - tokens;
24001 + sched_pc->flags = flags;
24002 + BUG_ON(tokens < 0);
24004 +#ifdef CONFIG_VSERVER_HARDCPU
24005 + /* next interval? */
24006 + if (!sched_pc->fill_rate[0])
24007 + delta_min[0] = HZ;
24008 + else if (tokens > sched_pc->fill_rate[0])
24009 + delta_min[0] += sched_pc->interval[0] *
24010 + tokens / sched_pc->fill_rate[0];
24012 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
24013 + vxd_check_range(delta_min[0], 0, INT_MAX);
24015 +#ifdef CONFIG_VSERVER_IDLETIME
24016 + if (!(flags & VXSF_IDLE_TIME))
24019 + /* next interval? */
24020 + if (!sched_pc->fill_rate[1])
24021 + delta_min[1] = HZ;
24022 + else if (tokens > sched_pc->fill_rate[1])
24023 + delta_min[1] += sched_pc->interval[1] *
24024 + tokens / sched_pc->fill_rate[1];
24026 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
24027 + vxd_check_range(delta_min[1], 0, INT_MAX);
24032 +#endif /* CONFIG_VSERVER_IDLETIME */
24035 +#endif /* CONFIG_VSERVER_HARDCPU */
24038 +static inline unsigned long msec_to_ticks(unsigned long msec)
24040 + return msecs_to_jiffies(msec);
24043 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24045 + return jiffies_to_msecs(ticks);
24048 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24050 + return jiffies_to_usecs(ticks);
24054 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24056 + unsigned int set_mask = data->mask;
24057 + unsigned int update_mask;
24060 + /* Sanity check data values */
24061 + if (data->tokens_max <= 0)
24062 + data->tokens_max = HZ;
24063 + if (data->tokens_min < 0)
24064 + data->tokens_min = HZ / 3;
24065 + if (data->tokens_min >= data->tokens_max)
24066 + data->tokens_min = data->tokens_max;
24068 + if (data->prio_bias > MAX_PRIO_BIAS)
24069 + data->prio_bias = MAX_PRIO_BIAS;
24070 + if (data->prio_bias < MIN_PRIO_BIAS)
24071 + data->prio_bias = MIN_PRIO_BIAS;
24073 + spin_lock(&vxi->sched.tokens_lock);
24075 + /* sync up on delayed updates */
24076 + for_each_cpu_mask(cpu, vxi->sched.update)
24077 + vx_update_sched_param(&vxi->sched,
24078 + &vx_per_cpu(vxi, sched_pc, cpu));
24080 + if (set_mask & VXSM_FILL_RATE)
24081 + vxi->sched.fill_rate[0] = data->fill_rate[0];
24082 + if (set_mask & VXSM_FILL_RATE2)
24083 + vxi->sched.fill_rate[1] = data->fill_rate[1];
24084 + if (set_mask & VXSM_INTERVAL)
24085 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24086 + msec_to_ticks(data->interval[0]) : data->interval[0];
24087 + if (set_mask & VXSM_INTERVAL2)
24088 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24089 + msec_to_ticks(data->interval[1]) : data->interval[1];
24090 + if (set_mask & VXSM_TOKENS)
24091 + vxi->sched.tokens = data->tokens;
24092 + if (set_mask & VXSM_TOKENS_MIN)
24093 + vxi->sched.tokens_min = data->tokens_min;
24094 + if (set_mask & VXSM_TOKENS_MAX)
24095 + vxi->sched.tokens_max = data->tokens_max;
24096 + if (set_mask & VXSM_PRIO_BIAS)
24097 + vxi->sched.prio_bias = data->prio_bias;
24099 + /* Sanity check rate/interval */
24100 + for (i = 0; i < 2; i++) {
24101 + if (data->fill_rate[i] < 0)
24102 + data->fill_rate[i] = 0;
24103 + if (data->interval[i] <= 0)
24104 + data->interval[i] = HZ;
24107 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24108 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24109 + vxi->sched.update_mask = update_mask;
24113 + if (set_mask & VXSM_CPU_ID) {
24114 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24115 + cpus_and(vxi->sched.update, cpu_online_map,
24116 + vxi->sched.update);
24118 + vxi->sched.update = cpu_online_map;
24120 + /* forced reload? */
24121 + if (set_mask & VXSM_FORCE) {
24122 + for_each_cpu_mask(cpu, vxi->sched.update)
24123 + vx_update_sched_param(&vxi->sched,
24124 + &vx_per_cpu(vxi, sched_pc, cpu));
24125 + vxi->sched.update = CPU_MASK_NONE;
24128 + /* on UP we update immediately */
24129 + vx_update_sched_param(&vxi->sched,
24130 + &vx_per_cpu(vxi, sched_pc, 0));
24133 + spin_unlock(&vxi->sched.tokens_lock);
24138 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24139 +#define COPY_PRI(C) C(prio_bias)
24140 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24141 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24142 + C(fill_rate[1]); C(interval[1]);
24144 +#define COPY_VALUE(name) vc_data.name = data->name
24146 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24148 + struct vcmd_sched_v5 vc_data;
24150 + vc_data.mask = data->set_mask;
24151 + COPY_IDS(COPY_VALUE);
24152 + COPY_PRI(COPY_VALUE);
24153 + COPY_TOK(COPY_VALUE);
24154 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24155 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
24156 + return do_set_sched(vxi, &vc_data);
24159 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24161 + struct vcmd_set_sched_v4 vc_data;
24163 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24166 + return do_set_sched_v4(vxi, &vc_data);
24169 + /* latest interface is v5 */
24171 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24173 + struct vcmd_sched_v5 vc_data;
24175 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24178 + return do_set_sched(vxi, &vc_data);
24182 +#define COPY_PRI(C) C(prio_bias)
24183 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24184 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
24185 + C(fill_rate[1]); C(interval[1]);
24187 +#define COPY_VALUE(name) vc_data.name = data->name
24190 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24192 + struct vcmd_sched_v5 vc_data;
24194 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24197 + if (vc_data.mask & VXSM_CPU_ID) {
24198 + int cpu = vc_data.cpu_id;
24199 + struct _vx_sched_pc *data;
24201 + if (!cpu_possible(cpu))
24204 + data = &vx_per_cpu(vxi, sched_pc, cpu);
24205 + COPY_TOK(COPY_VALUE);
24206 + COPY_PRI(COPY_VALUE);
24207 + COPY_FRI(COPY_VALUE);
24209 + if (data->flags & VXSF_IDLE_TIME)
24210 + vc_data.mask |= VXSM_IDLE_TIME;
24212 + struct _vx_sched *data = &vxi->sched;
24214 + COPY_TOK(COPY_VALUE);
24215 + COPY_PRI(COPY_VALUE);
24216 + COPY_FRI(COPY_VALUE);
24219 + if (vc_data.mask & VXSM_MSEC) {
24220 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24221 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24224 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24230 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24232 + struct vcmd_sched_info vc_data;
24235 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24238 + cpu = vc_data.cpu_id;
24239 + if (!cpu_possible(cpu))
24243 + struct _vx_sched_pc *sched_pc =
24244 + &vx_per_cpu(vxi, sched_pc, cpu);
24246 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24247 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24248 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24249 + vc_data.vavavoom = sched_pc->vavavoom;
24251 + vc_data.token_usec = ticks_to_usec(1);
24253 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24258 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/sched_init.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sched_init.h
24259 --- linux-2.6.27.14/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24260 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sched_init.h 2008-10-13 14:54:20.000000000 +0200
24263 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24265 + static struct lock_class_key tokens_lock_key;
24267 + /* scheduling; hard code starting values as constants */
24268 + sched->fill_rate[0] = 1;
24269 + sched->interval[0] = 4;
24270 + sched->fill_rate[1] = 1;
24271 + sched->interval[1] = 8;
24272 + sched->tokens = HZ >> 2;
24273 + sched->tokens_min = HZ >> 4;
24274 + sched->tokens_max = HZ >> 1;
24275 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24276 + sched->prio_bias = 0;
24278 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24282 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24284 + sched_pc->fill_rate[0] = 1;
24285 + sched_pc->interval[0] = 4;
24286 + sched_pc->fill_rate[1] = 1;
24287 + sched_pc->interval[1] = 8;
24288 + sched_pc->tokens = HZ >> 2;
24289 + sched_pc->tokens_min = HZ >> 4;
24290 + sched_pc->tokens_max = HZ >> 1;
24291 + sched_pc->prio_bias = 0;
24292 + sched_pc->vavavoom = 0;
24293 + sched_pc->token_time = 0;
24294 + sched_pc->idle_time = 0;
24295 + sched_pc->norm_time = jiffies;
24297 + sched_pc->user_ticks = 0;
24298 + sched_pc->sys_ticks = 0;
24299 + sched_pc->hold_ticks = 0;
24302 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24308 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24312 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/sched_proc.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sched_proc.h
24313 --- linux-2.6.27.14/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24314 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sched_proc.h 2008-10-13 14:54:20.000000000 +0200
24316 +#ifndef _VX_SCHED_PROC_H
24317 +#define _VX_SCHED_PROC_H
24321 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24325 + length += sprintf(buffer,
24326 + "FillRate:\t%8d,%d\n"
24327 + "Interval:\t%8d,%d\n"
24328 + "TokensMin:\t%8d\n"
24329 + "TokensMax:\t%8d\n"
24330 + "PrioBias:\t%8d\n",
24331 + sched->fill_rate[0],
24332 + sched->fill_rate[1],
24333 + sched->interval[0],
24334 + sched->interval[1],
24335 + sched->tokens_min,
24336 + sched->tokens_max,
24337 + sched->prio_bias);
24342 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24343 + char *buffer, int cpu)
24347 + length += sprintf(buffer + length,
24348 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24349 + (unsigned long long)sched_pc->user_ticks,
24350 + (unsigned long long)sched_pc->sys_ticks,
24351 + (unsigned long long)sched_pc->hold_ticks,
24352 + sched_pc->token_time,
24353 + sched_pc->idle_time);
24354 + length += sprintf(buffer + length,
24355 + " %c%c %d %d %d %d/%d %d/%d",
24356 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24357 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24358 + sched_pc->tokens,
24359 + sched_pc->tokens_min,
24360 + sched_pc->tokens_max,
24361 + sched_pc->fill_rate[0],
24362 + sched_pc->interval[0],
24363 + sched_pc->fill_rate[1],
24364 + sched_pc->interval[1]);
24365 + length += sprintf(buffer + length,
24367 + sched_pc->prio_bias,
24368 + sched_pc->vavavoom);
24372 +#endif /* _VX_SCHED_PROC_H */
24373 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/signal.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/signal.c
24374 --- linux-2.6.27.14/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24375 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/signal.c 2008-10-13 14:54:20.000000000 +0200
24378 + * linux/kernel/vserver/signal.c
24380 + * Virtual Server: Signal Support
24382 + * Copyright (C) 2003-2007 Herbert Pötzl
24384 + * V0.01 broken out from vcontext V0.05
24385 + * V0.02 changed vcmds to vxi arg
24386 + * V0.03 adjusted siginfo for kill
24390 +#include <asm/uaccess.h>
24392 +#include <linux/vs_context.h>
24393 +#include <linux/vs_pid.h>
24394 +#include <linux/vserver/signal_cmd.h>
24397 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24399 + int retval, count = 0;
24400 + struct task_struct *p;
24401 + struct siginfo *sip = SEND_SIG_PRIV;
24404 + vxdprintk(VXD_CBIT(misc, 4),
24405 + "vx_info_kill(%p[#%d],%d,%d)*",
24406 + vxi, vxi->vx_id, pid, sig);
24407 + read_lock(&tasklist_lock);
24411 + for_each_process(p) {
24414 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24415 + (pid && vxi->vx_initpid == p->pid))
24418 + err = group_send_sig_info(sig, sip, p);
24420 + if (err != -EPERM)
24426 + if (vxi->vx_initpid) {
24427 + pid = vxi->vx_initpid;
24428 + /* for now, only SIGINT to private init ... */
24429 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24430 + /* ... as long as there are tasks left */
24431 + (atomic_read(&vxi->vx_tasks) > 1))
24434 + /* fallthrough */
24436 + p = find_task_by_real_pid(pid);
24438 + if (vx_task_xid(p) == vxi->vx_id)
24439 + retval = group_send_sig_info(sig, sip, p);
24443 + read_unlock(&tasklist_lock);
24444 + vxdprintk(VXD_CBIT(misc, 4),
24445 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24446 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24450 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24452 + struct vcmd_ctx_kill_v0 vc_data;
24454 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24457 + /* special check to allow guest shutdown */
24458 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24459 + /* forbid killall pid=0 when init is present */
24460 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24461 + (vc_data.pid > 1)))
24464 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24468 +static int __wait_exit(struct vx_info *vxi)
24470 + DECLARE_WAITQUEUE(wait, current);
24473 + add_wait_queue(&vxi->vx_wait, &wait);
24474 + set_current_state(TASK_INTERRUPTIBLE);
24477 + if (vx_info_state(vxi,
24478 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24480 + if (signal_pending(current)) {
24481 + ret = -ERESTARTSYS;
24488 + set_current_state(TASK_RUNNING);
24489 + remove_wait_queue(&vxi->vx_wait, &wait);
24495 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24497 + struct vcmd_wait_exit_v0 vc_data;
24500 + ret = __wait_exit(vxi);
24501 + vc_data.reboot_cmd = vxi->reboot_cmd;
24502 + vc_data.exit_code = vxi->exit_code;
24504 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24509 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/space.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/space.c
24510 --- linux-2.6.27.14/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24511 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/space.c 2008-10-31 18:15:28.000000000 +0100
24514 + * linux/kernel/vserver/space.c
24516 + * Virtual Server: Context Space Support
24518 + * Copyright (C) 2003-2007 Herbert Pötzl
24520 + * V0.01 broken out from context.c 0.07
24521 + * V0.02 added task locking for namespace
24522 + * V0.03 broken out vx_enter_namespace
24523 + * V0.04 added *space support and commands
24527 +#include <linux/utsname.h>
24528 +#include <linux/nsproxy.h>
24529 +#include <linux/err.h>
24530 +#include <asm/uaccess.h>
24532 +#include <linux/vs_context.h>
24533 +#include <linux/vserver/space.h>
24534 +#include <linux/vserver/space_cmd.h>
24536 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24537 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24538 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24539 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24540 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24541 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24542 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24545 +/* namespace functions */
24547 +#include <linux/mnt_namespace.h>
24548 +#include <linux/user_namespace.h>
24549 +#include <linux/pid_namespace.h>
24550 +#include <linux/ipc_namespace.h>
24551 +#include <net/net_namespace.h>
24554 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24555 + .mask = CLONE_FS |
24563 +static const struct vcmd_space_mask_v1 space_mask = {
24564 + .mask = CLONE_FS |
24569 +#ifdef CONFIG_PID_NS
24572 +#ifdef CONFIG_NET_NS
24578 +static const struct vcmd_space_mask_v1 default_space_mask = {
24579 + .mask = CLONE_FS |
24584 +#ifdef CONFIG_PID_NS
24591 + * build a new nsproxy mix
24592 + * assumes that both proxies are 'const'
24593 + * does not touch nsproxy refcounts
24594 + * will hold a reference on the result.
24597 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24598 + struct nsproxy *new_nsproxy, unsigned long mask)
24600 + struct mnt_namespace *old_ns;
24601 + struct uts_namespace *old_uts;
24602 + struct ipc_namespace *old_ipc;
24603 + struct user_namespace *old_user;
24604 +#ifdef CONFIG_PID_NS
24605 + struct pid_namespace *old_pid;
24607 +#ifdef CONFIG_NET_NS
24608 + struct net *old_net;
24610 + struct nsproxy *nsproxy;
24612 + nsproxy = copy_nsproxy(old_nsproxy);
24616 + if (mask & CLONE_NEWNS) {
24617 + old_ns = nsproxy->mnt_ns;
24618 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24619 + if (nsproxy->mnt_ns)
24620 + get_mnt_ns(nsproxy->mnt_ns);
24624 + if (mask & CLONE_NEWUTS) {
24625 + old_uts = nsproxy->uts_ns;
24626 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24627 + if (nsproxy->uts_ns)
24628 + get_uts_ns(nsproxy->uts_ns);
24632 + if (mask & CLONE_NEWIPC) {
24633 + old_ipc = nsproxy->ipc_ns;
24634 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24635 + if (nsproxy->ipc_ns)
24636 + get_ipc_ns(nsproxy->ipc_ns);
24640 + if (mask & CLONE_NEWUSER) {
24641 + old_user = nsproxy->user_ns;
24642 + nsproxy->user_ns = new_nsproxy->user_ns;
24643 + if (nsproxy->user_ns)
24644 + get_user_ns(nsproxy->user_ns);
24648 +#ifdef CONFIG_PID_NS
24649 + if (mask & CLONE_NEWPID) {
24650 + old_pid = nsproxy->pid_ns;
24651 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24652 + if (nsproxy->pid_ns)
24653 + get_pid_ns(nsproxy->pid_ns);
24657 +#ifdef CONFIG_NET_NS
24658 + if (mask & CLONE_NEWNET) {
24659 + old_net = nsproxy->net_ns;
24660 + nsproxy->net_ns = new_nsproxy->net_ns;
24661 + if (nsproxy->net_ns)
24662 + get_net(nsproxy->net_ns);
24667 + put_mnt_ns(old_ns);
24669 + put_uts_ns(old_uts);
24671 + put_ipc_ns(old_ipc);
24673 + put_user_ns(old_user);
24674 +#ifdef CONFIG_PID_NS
24676 + put_pid_ns(old_pid);
24678 +#ifdef CONFIG_NET_NS
24680 + put_net(old_net);
24688 + * merge two nsproxy structs into a new one.
24689 + * will hold a reference on the result.
24693 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24694 + struct nsproxy *proxy, unsigned long mask)
24696 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24702 + /* vs_mix_nsproxy returns with reference */
24703 + return vs_mix_nsproxy(old ? old : &null_proxy,
24706 + get_nsproxy(proxy);
24711 + * merge two fs structs into a new one.
24712 + * will take a reference on the result.
24716 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24717 + struct fs_struct *fs, unsigned long mask)
24719 + if (!(mask & CLONE_FS)) {
24721 + atomic_inc(&old->count);
24728 + return copy_fs_struct(fs);
24732 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24734 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24735 + struct fs_struct *fs, *fs_cur, *fs_new;
24738 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24739 + vxi, vxi->vx_id, mask, index);
24741 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24745 + mask = vxi->vx_nsmask[index];
24747 + if ((mask & vxi->vx_nsmask[index]) != mask)
24750 + proxy = vxi->vx_nsproxy[index];
24751 + fs = vxi->vx_fs[index];
24753 + task_lock(current);
24754 + fs_cur = current->fs;
24755 + atomic_inc(&fs_cur->count);
24756 + proxy_cur = current->nsproxy;
24757 + get_nsproxy(proxy_cur);
24758 + task_unlock(current);
24760 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24761 + if (IS_ERR(fs_new)) {
24762 + ret = PTR_ERR(fs_new);
24766 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24767 + if (IS_ERR(proxy_new)) {
24768 + ret = PTR_ERR(proxy_new);
24772 + fs_new = xchg(¤t->fs, fs_new);
24773 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24777 + put_nsproxy(proxy_new);
24780 + put_fs_struct(fs_new);
24783 + put_nsproxy(proxy_cur);
24785 + put_fs_struct(fs_cur);
24790 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24792 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24793 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24796 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24797 + vxi, vxi->vx_id, mask, index);
24800 + mask = default_space_mask.mask;
24802 + if ((mask & space_mask.mask) != mask)
24805 + proxy_vxi = vxi->vx_nsproxy[index];
24806 + fs_vxi = vxi->vx_fs[index];
24808 + task_lock(current);
24809 + fs_cur = current->fs;
24810 + atomic_inc(&fs_cur->count);
24811 + proxy_cur = current->nsproxy;
24812 + get_nsproxy(proxy_cur);
24813 + task_unlock(current);
24815 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24816 + if (IS_ERR(fs_new)) {
24817 + ret = PTR_ERR(fs_new);
24821 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24822 + if (IS_ERR(proxy_new)) {
24823 + ret = PTR_ERR(proxy_new);
24827 + fs_new = xchg(&vxi->vx_fs[index], fs_new);
24828 + proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
24829 + vxi->vx_nsmask[index] |= mask;
24833 + put_nsproxy(proxy_new);
24836 + put_fs_struct(fs_new);
24839 + put_nsproxy(proxy_cur);
24841 + put_fs_struct(fs_cur);
24846 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24848 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24850 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24853 + return vx_enter_space(vxi, vc_data.mask, 0);
24856 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24858 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24860 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24863 + if (vc_data.index >= VX_SPACES)
24866 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24869 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24871 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24873 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24876 + return vx_set_space(vxi, vc_data.mask, 0);
24879 +int vc_set_space(struct vx_info *vxi, void __user *data)
24881 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24883 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24886 + if (vc_data.index >= VX_SPACES)
24889 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
24892 +int vc_get_space_mask(void __user *data, int type)
24894 + const struct vcmd_space_mask_v1 *mask;
24897 + mask = &space_mask_v0;
24898 + else if (type == 1)
24899 + mask = &space_mask;
24901 + mask = &default_space_mask;
24903 + vxdprintk(VXD_CBIT(space, 10),
24904 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24906 + if (copy_to_user(data, mask, sizeof(*mask)))
24911 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/switch.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/switch.c
24912 --- linux-2.6.27.14/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24913 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/switch.c 2008-10-31 04:42:36.000000000 +0100
24916 + * linux/kernel/vserver/switch.c
24918 + * Virtual Server: Syscall Switch
24920 + * Copyright (C) 2003-2007 Herbert Pötzl
24922 + * V0.01 syscall switch
24923 + * V0.02 added signal to context
24924 + * V0.03 added rlimit functions
24925 + * V0.04 added iattr, task/xid functions
24926 + * V0.05 added debug/history stuff
24927 + * V0.06 added compat32 layer
24928 + * V0.07 vcmd args and perms
24929 + * V0.08 added status commands
24930 + * V0.09 added tag commands
24931 + * V0.10 added oom bias
24932 + * V0.11 added device commands
24936 +#include <linux/vs_context.h>
24937 +#include <linux/vs_network.h>
24938 +#include <linux/vserver/switch.h>
24940 +#include "vci_config.h"
24944 +int vc_get_version(uint32_t id)
24946 + return VCI_VERSION;
24950 +int vc_get_vci(uint32_t id)
24952 + return vci_kernel_config();
24955 +#include <linux/vserver/context_cmd.h>
24956 +#include <linux/vserver/cvirt_cmd.h>
24957 +#include <linux/vserver/cacct_cmd.h>
24958 +#include <linux/vserver/limit_cmd.h>
24959 +#include <linux/vserver/network_cmd.h>
24960 +#include <linux/vserver/sched_cmd.h>
24961 +#include <linux/vserver/debug_cmd.h>
24962 +#include <linux/vserver/inode_cmd.h>
24963 +#include <linux/vserver/dlimit_cmd.h>
24964 +#include <linux/vserver/signal_cmd.h>
24965 +#include <linux/vserver/space_cmd.h>
24966 +#include <linux/vserver/tag_cmd.h>
24967 +#include <linux/vserver/device_cmd.h>
24969 +#include <linux/vserver/inode.h>
24970 +#include <linux/vserver/dlimit.h>
24973 +#ifdef CONFIG_COMPAT
24974 +#define __COMPAT(name, id, data, compat) \
24975 + (compat) ? name ## _x32(id, data) : name(id, data)
24976 +#define __COMPAT_NO_ID(name, data, compat) \
24977 + (compat) ? name ## _x32(data) : name(data)
24979 +#define __COMPAT(name, id, data, compat) \
24981 +#define __COMPAT_NO_ID(name, data, compat) \
24987 +long do_vcmd(uint32_t cmd, uint32_t id,
24988 + struct vx_info *vxi, struct nx_info *nxi,
24989 + void __user *data, int compat)
24993 + case VCMD_get_version:
24994 + return vc_get_version(id);
24995 + case VCMD_get_vci:
24996 + return vc_get_vci(id);
24998 + case VCMD_task_xid:
24999 + return vc_task_xid(id);
25000 + case VCMD_vx_info:
25001 + return vc_vx_info(vxi, data);
25003 + case VCMD_task_nid:
25004 + return vc_task_nid(id);
25005 + case VCMD_nx_info:
25006 + return vc_nx_info(nxi, data);
25008 + case VCMD_task_tag:
25009 + return vc_task_tag(id);
25011 + case VCMD_set_space_v1:
25012 + return vc_set_space_v1(vxi, data);
25013 + /* this is version 2 */
25014 + case VCMD_set_space:
25015 + return vc_set_space(vxi, data);
25017 + case VCMD_get_space_mask_v0:
25018 + return vc_get_space_mask(data, 0);
25019 + /* this is version 1 */
25020 + case VCMD_get_space_mask:
25021 + return vc_get_space_mask(data, 1);
25023 + case VCMD_get_space_default:
25024 + return vc_get_space_mask(data, -1);
25026 +#ifdef CONFIG_IA32_EMULATION
25027 + case VCMD_get_rlimit:
25028 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25029 + case VCMD_set_rlimit:
25030 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25032 + case VCMD_get_rlimit:
25033 + return vc_get_rlimit(vxi, data);
25034 + case VCMD_set_rlimit:
25035 + return vc_set_rlimit(vxi, data);
25037 + case VCMD_get_rlimit_mask:
25038 + return vc_get_rlimit_mask(id, data);
25039 + case VCMD_reset_minmax:
25040 + return vc_reset_minmax(vxi, data);
25042 + case VCMD_get_vhi_name:
25043 + return vc_get_vhi_name(vxi, data);
25044 + case VCMD_set_vhi_name:
25045 + return vc_set_vhi_name(vxi, data);
25047 + case VCMD_ctx_stat:
25048 + return vc_ctx_stat(vxi, data);
25049 + case VCMD_virt_stat:
25050 + return vc_virt_stat(vxi, data);
25051 + case VCMD_sock_stat:
25052 + return vc_sock_stat(vxi, data);
25053 + case VCMD_rlimit_stat:
25054 + return vc_rlimit_stat(vxi, data);
25056 + case VCMD_set_cflags:
25057 + return vc_set_cflags(vxi, data);
25058 + case VCMD_get_cflags:
25059 + return vc_get_cflags(vxi, data);
25061 + /* this is version 1 */
25062 + case VCMD_set_ccaps:
25063 + return vc_set_ccaps(vxi, data);
25064 + /* this is version 1 */
25065 + case VCMD_get_ccaps:
25066 + return vc_get_ccaps(vxi, data);
25067 + case VCMD_set_bcaps:
25068 + return vc_set_bcaps(vxi, data);
25069 + case VCMD_get_bcaps:
25070 + return vc_get_bcaps(vxi, data);
25072 + case VCMD_set_badness:
25073 + return vc_set_badness(vxi, data);
25074 + case VCMD_get_badness:
25075 + return vc_get_badness(vxi, data);
25077 + case VCMD_set_nflags:
25078 + return vc_set_nflags(nxi, data);
25079 + case VCMD_get_nflags:
25080 + return vc_get_nflags(nxi, data);
25082 + case VCMD_set_ncaps:
25083 + return vc_set_ncaps(nxi, data);
25084 + case VCMD_get_ncaps:
25085 + return vc_get_ncaps(nxi, data);
25087 + case VCMD_set_sched_v4:
25088 + return vc_set_sched_v4(vxi, data);
25089 + /* this is version 5 */
25090 + case VCMD_set_sched:
25091 + return vc_set_sched(vxi, data);
25092 + case VCMD_get_sched:
25093 + return vc_get_sched(vxi, data);
25094 + case VCMD_sched_info:
25095 + return vc_sched_info(vxi, data);
25097 + case VCMD_add_dlimit:
25098 + return __COMPAT(vc_add_dlimit, id, data, compat);
25099 + case VCMD_rem_dlimit:
25100 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25101 + case VCMD_set_dlimit:
25102 + return __COMPAT(vc_set_dlimit, id, data, compat);
25103 + case VCMD_get_dlimit:
25104 + return __COMPAT(vc_get_dlimit, id, data, compat);
25106 + case VCMD_ctx_kill:
25107 + return vc_ctx_kill(vxi, data);
25109 + case VCMD_wait_exit:
25110 + return vc_wait_exit(vxi, data);
25112 + case VCMD_get_iattr:
25113 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25114 + case VCMD_set_iattr:
25115 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25117 + case VCMD_fget_iattr:
25118 + return vc_fget_iattr(id, data);
25119 + case VCMD_fset_iattr:
25120 + return vc_fset_iattr(id, data);
25122 + case VCMD_enter_space_v0:
25123 + return vc_enter_space_v1(vxi, NULL);
25124 + case VCMD_enter_space_v1:
25125 + return vc_enter_space_v1(vxi, data);
25126 + /* this is version 2 */
25127 + case VCMD_enter_space:
25128 + return vc_enter_space(vxi, data);
25130 + case VCMD_ctx_create_v0:
25131 + return vc_ctx_create(id, NULL);
25132 + case VCMD_ctx_create:
25133 + return vc_ctx_create(id, data);
25134 + case VCMD_ctx_migrate_v0:
25135 + return vc_ctx_migrate(vxi, NULL);
25136 + case VCMD_ctx_migrate:
25137 + return vc_ctx_migrate(vxi, data);
25139 + case VCMD_net_create_v0:
25140 + return vc_net_create(id, NULL);
25141 + case VCMD_net_create:
25142 + return vc_net_create(id, data);
25143 + case VCMD_net_migrate:
25144 + return vc_net_migrate(nxi, data);
25146 + case VCMD_tag_migrate:
25147 + return vc_tag_migrate(id);
25149 + case VCMD_net_add:
25150 + return vc_net_add(nxi, data);
25151 + case VCMD_net_remove:
25152 + return vc_net_remove(nxi, data);
25154 + case VCMD_net_add_ipv4:
25155 + return vc_net_add_ipv4(nxi, data);
25156 + case VCMD_net_remove_ipv4:
25157 + return vc_net_remove_ipv4(nxi, data);
25158 +#ifdef CONFIG_IPV6
25159 + case VCMD_net_add_ipv6:
25160 + return vc_net_add_ipv6(nxi, data);
25161 + case VCMD_net_remove_ipv6:
25162 + return vc_net_remove_ipv6(nxi, data);
25164 +/* case VCMD_add_match_ipv4:
25165 + return vc_add_match_ipv4(nxi, data);
25166 + case VCMD_get_match_ipv4:
25167 + return vc_get_match_ipv4(nxi, data);
25168 +#ifdef CONFIG_IPV6
25169 + case VCMD_add_match_ipv6:
25170 + return vc_add_match_ipv6(nxi, data);
25171 + case VCMD_get_match_ipv6:
25172 + return vc_get_match_ipv6(nxi, data);
25175 +#ifdef CONFIG_VSERVER_DEVICE
25176 + case VCMD_set_mapping:
25177 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25178 + case VCMD_unset_mapping:
25179 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25181 +#ifdef CONFIG_VSERVER_HISTORY
25182 + case VCMD_dump_history:
25183 + return vc_dump_history(id);
25184 + case VCMD_read_history:
25185 + return __COMPAT(vc_read_history, id, data, compat);
25187 +#ifdef CONFIG_VSERVER_MONITOR
25188 + case VCMD_read_monitor:
25189 + return __COMPAT(vc_read_monitor, id, data, compat);
25192 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25193 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25199 +#define __VCMD(vcmd, _perm, _args, _flags) \
25200 + case VCMD_ ## vcmd: perm = _perm; \
25201 + args = _args; flags = _flags; break
25204 +#define VCA_NONE 0x00
25205 +#define VCA_VXI 0x01
25206 +#define VCA_NXI 0x02
25208 +#define VCF_NONE 0x00
25209 +#define VCF_INFO 0x01
25210 +#define VCF_ADMIN 0x02
25211 +#define VCF_ARES 0x06 /* includes admin */
25212 +#define VCF_SETUP 0x08
25214 +#define VCF_ZIDOK 0x10 /* zero id okay */
25218 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25221 + int permit = -1, state = 0;
25222 + int perm = -1, args = 0, flags = 0;
25223 + struct vx_info *vxi = NULL;
25224 + struct nx_info *nxi = NULL;
25227 + /* unpriviledged commands */
25228 + __VCMD(get_version, 0, VCA_NONE, 0);
25229 + __VCMD(get_vci, 0, VCA_NONE, 0);
25230 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25231 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25232 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25233 + __VCMD(get_space_default,0, VCA_NONE, 0);
25235 + /* info commands */
25236 + __VCMD(task_xid, 2, VCA_NONE, 0);
25237 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25238 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25239 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25240 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25241 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25242 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25243 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25244 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25246 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25247 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25248 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25249 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25251 + __VCMD(task_nid, 2, VCA_NONE, 0);
25252 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25253 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25254 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25256 + __VCMD(task_tag, 2, VCA_NONE, 0);
25258 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25259 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25260 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25261 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
25262 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
25264 + /* lower admin commands */
25265 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25266 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25267 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25268 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25269 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25270 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25271 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25272 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25274 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25275 + __VCMD(net_create, 5, VCA_NONE, 0);
25276 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25278 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25280 + /* higher admin commands */
25281 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25282 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25283 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25285 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25286 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25287 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25288 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25290 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25291 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25292 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25293 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25295 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25296 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25297 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25298 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25299 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25300 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25301 +#ifdef CONFIG_IPV6
25302 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25303 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25305 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25306 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25307 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25308 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25309 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25311 +#ifdef CONFIG_VSERVER_DEVICE
25312 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25313 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25315 + /* debug level admin commands */
25316 +#ifdef CONFIG_VSERVER_HISTORY
25317 + __VCMD(dump_history, 9, VCA_NONE, 0);
25318 + __VCMD(read_history, 9, VCA_NONE, 0);
25320 +#ifdef CONFIG_VSERVER_MONITOR
25321 + __VCMD(read_monitor, 9, VCA_NONE, 0);
25328 + vxdprintk(VXD_CBIT(switch, 0),
25329 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25330 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25331 + VC_VERSION(cmd), id, data, compat,
25332 + perm, args, flags);
25339 + if (!capable(CAP_CONTEXT))
25343 + /* moved here from the individual commands */
25345 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25349 + /* vcmd involves resource management */
25351 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25355 + /* various legacy exceptions */
25357 + /* will go away when spectator is a cap */
25358 + case VCMD_ctx_migrate_v0:
25359 + case VCMD_ctx_migrate:
25361 + current->xid = 1;
25367 + /* will go away when spectator is a cap */
25368 + case VCMD_net_migrate:
25370 + current->nid = 1;
25377 + /* vcmds are fine by default */
25380 + /* admin type vcmds require admin ... */
25381 + if (flags & VCF_ADMIN)
25382 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25384 + /* ... but setup type vcmds override that */
25385 + if (!permit && (flags & VCF_SETUP))
25386 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25394 + if (!id && (flags & VCF_ZIDOK))
25398 + if (args & VCA_VXI) {
25399 + vxi = lookup_vx_info(id);
25403 + if ((flags & VCF_ADMIN) &&
25404 + /* special case kill for shutdown */
25405 + (cmd != VCMD_ctx_kill) &&
25406 + /* can context be administrated? */
25407 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25413 + if (args & VCA_NXI) {
25414 + nxi = lookup_nx_info(id);
25418 + if ((flags & VCF_ADMIN) &&
25419 + /* can context be administrated? */
25420 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25427 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25430 + if ((args & VCA_NXI) && nxi)
25431 + put_nx_info(nxi);
25433 + if ((args & VCA_VXI) && vxi)
25434 + put_vx_info(vxi);
25436 + vxdprintk(VXD_CBIT(switch, 1),
25437 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25438 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25439 + VC_VERSION(cmd), ret, ret, state, permit);
25444 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25446 + return do_vserver(cmd, id, data, 0);
25449 +#ifdef CONFIG_COMPAT
25452 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25454 + return do_vserver(cmd, id, data, 1);
25457 +#endif /* CONFIG_COMPAT */
25458 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/sysctl.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sysctl.c
25459 --- linux-2.6.27.14/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25460 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/sysctl.c 2008-10-13 14:54:20.000000000 +0200
25463 + * kernel/vserver/sysctl.c
25465 + * Virtual Context Support
25467 + * Copyright (C) 2004-2007 Herbert Pötzl
25469 + * V0.01 basic structure
25473 +#include <linux/module.h>
25474 +#include <linux/ctype.h>
25475 +#include <linux/sysctl.h>
25476 +#include <linux/parser.h>
25477 +#include <asm/uaccess.h>
25481 + CTL_DEBUG_ERROR = 0,
25482 + CTL_DEBUG_SWITCH = 1,
25497 +unsigned int vx_debug_switch = 0;
25498 +unsigned int vx_debug_xid = 0;
25499 +unsigned int vx_debug_nid = 0;
25500 +unsigned int vx_debug_tag = 0;
25501 +unsigned int vx_debug_net = 0;
25502 +unsigned int vx_debug_limit = 0;
25503 +unsigned int vx_debug_cres = 0;
25504 +unsigned int vx_debug_dlim = 0;
25505 +unsigned int vx_debug_quota = 0;
25506 +unsigned int vx_debug_cvirt = 0;
25507 +unsigned int vx_debug_space = 0;
25508 +unsigned int vx_debug_misc = 0;
25511 +static struct ctl_table_header *vserver_table_header;
25512 +static ctl_table vserver_root_table[];
25515 +void vserver_register_sysctl(void)
25517 + if (!vserver_table_header) {
25518 + vserver_table_header = register_sysctl_table(vserver_root_table);
25523 +void vserver_unregister_sysctl(void)
25525 + if (vserver_table_header) {
25526 + unregister_sysctl_table(vserver_table_header);
25527 + vserver_table_header = NULL;
25532 +static int proc_dodebug(ctl_table *table, int write,
25533 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25535 + char tmpbuf[20], *p, c;
25536 + unsigned int value;
25537 + size_t left, len;
25539 + if ((*ppos && !write) || !*lenp) {
25547 + if (!access_ok(VERIFY_READ, buffer, left))
25549 + p = (char *)buffer;
25550 + while (left && __get_user(c, p) >= 0 && isspace(c))
25555 + if (left > sizeof(tmpbuf) - 1)
25557 + if (copy_from_user(tmpbuf, p, left))
25559 + tmpbuf[left] = '\0';
25561 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25562 + value = 10 * value + (*p - '0');
25563 + if (*p && !isspace(*p))
25565 + while (left && isspace(*p))
25567 + *(unsigned int *)table->data = value;
25569 + if (!access_ok(VERIFY_WRITE, buffer, left))
25571 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25574 + if (__copy_to_user(buffer, tmpbuf, len))
25576 + if ((left -= len) > 0) {
25577 + if (put_user('\n', (char *)buffer + len))
25591 +#define CTL_ENTRY(ctl, name) \
25593 + .ctl_name = ctl, \
25594 + .procname = #name, \
25595 + .data = &vx_ ## name, \
25596 + .maxlen = sizeof(int), \
25598 + .proc_handler = &proc_dodebug, \
25599 + .strategy = &sysctl_intvec, \
25600 + .extra1 = &zero, \
25603 +static ctl_table vserver_debug_table[] = {
25604 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25605 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25606 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25607 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25608 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25609 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25610 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25611 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25612 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25613 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25614 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25615 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25616 + { .ctl_name = 0 }
25619 +static ctl_table vserver_root_table[] = {
25621 + .ctl_name = CTL_VSERVER,
25622 + .procname = "vserver",
25624 + .child = vserver_debug_table
25626 + { .ctl_name = 0 }
25630 +static match_table_t tokens = {
25631 + { CTL_DEBUG_SWITCH, "switch=%x" },
25632 + { CTL_DEBUG_XID, "xid=%x" },
25633 + { CTL_DEBUG_NID, "nid=%x" },
25634 + { CTL_DEBUG_TAG, "tag=%x" },
25635 + { CTL_DEBUG_NET, "net=%x" },
25636 + { CTL_DEBUG_LIMIT, "limit=%x" },
25637 + { CTL_DEBUG_CRES, "cres=%x" },
25638 + { CTL_DEBUG_DLIM, "dlim=%x" },
25639 + { CTL_DEBUG_QUOTA, "quota=%x" },
25640 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25641 + { CTL_DEBUG_SPACE, "space=%x" },
25642 + { CTL_DEBUG_MISC, "misc=%x" },
25643 + { CTL_DEBUG_ERROR, NULL }
25646 +#define HANDLE_CASE(id, name, val) \
25647 + case CTL_DEBUG_ ## id: \
25648 + vx_debug_ ## name = val; \
25649 + printk("vs_debug_" #name "=0x%x\n", val); \
25653 +static int __init vs_debug_setup(char *str)
25658 + printk("vs_debug_setup(%s)\n", str);
25659 + while ((p = strsep(&str, ",")) != NULL) {
25660 + substring_t args[MAX_OPT_ARGS];
25661 + unsigned int value;
25666 + token = match_token(p, tokens, args);
25667 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25670 + HANDLE_CASE(SWITCH, switch, value);
25671 + HANDLE_CASE(XID, xid, value);
25672 + HANDLE_CASE(NID, nid, value);
25673 + HANDLE_CASE(TAG, tag, value);
25674 + HANDLE_CASE(NET, net, value);
25675 + HANDLE_CASE(LIMIT, limit, value);
25676 + HANDLE_CASE(CRES, cres, value);
25677 + HANDLE_CASE(DLIM, dlim, value);
25678 + HANDLE_CASE(QUOTA, quota, value);
25679 + HANDLE_CASE(CVIRT, cvirt, value);
25680 + HANDLE_CASE(SPACE, space, value);
25681 + HANDLE_CASE(MISC, misc, value);
25690 +__setup("vsdebug=", vs_debug_setup);
25694 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25695 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25696 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25697 +EXPORT_SYMBOL_GPL(vx_debug_net);
25698 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25699 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25700 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25701 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25702 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25703 +EXPORT_SYMBOL_GPL(vx_debug_space);
25704 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25706 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/tag.c linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/tag.c
25707 --- linux-2.6.27.14/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25708 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/tag.c 2008-10-13 14:54:20.000000000 +0200
25711 + * linux/kernel/vserver/tag.c
25713 + * Virtual Server: Shallow Tag Space
25715 + * Copyright (C) 2007 Herbert Pötzl
25717 + * V0.01 basic implementation
25721 +#include <linux/sched.h>
25722 +#include <linux/vserver/debug.h>
25723 +#include <linux/vs_pid.h>
25724 +#include <linux/vs_tag.h>
25726 +#include <linux/vserver/tag_cmd.h>
25729 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25734 + vxdprintk(VXD_CBIT(tag, 5),
25735 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25741 + vxdprintk(VXD_CBIT(tag, 5),
25742 + "moved task %p into [#%d]", p, tag);
25746 +/* vserver syscall commands below here */
25748 +/* taks xid and vx_info functions */
25751 +int vc_task_tag(uint32_t id)
25756 + struct task_struct *tsk;
25757 + read_lock(&tasklist_lock);
25758 + tsk = find_task_by_real_pid(id);
25759 + tag = (tsk) ? tsk->tag : -ESRCH;
25760 + read_unlock(&tasklist_lock);
25762 + tag = dx_current_tag();
25767 +int vc_tag_migrate(uint32_t tag)
25769 + return dx_migrate_task(current, tag & 0xFFFF);
25773 diff -NurpP --minimal linux-2.6.27.14/kernel/vserver/vci_config.h linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/vci_config.h
25774 --- linux-2.6.27.14/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25775 +++ linux-2.6.27.14-vs2.3.0.36.4/kernel/vserver/vci_config.h 2008-10-31 18:16:04.000000000 +0100
25778 +/* interface version */
25780 +#define VCI_VERSION 0x00020304
25784 + VCI_KCBIT_NO_DYNAMIC = 0,
25786 + VCI_KCBIT_PROC_SECURE = 4,
25787 + VCI_KCBIT_HARDCPU = 5,
25788 + VCI_KCBIT_IDLELIMIT = 6,
25789 + VCI_KCBIT_IDLETIME = 7,
25791 + VCI_KCBIT_COWBL = 8,
25792 + VCI_KCBIT_FULLCOWBL = 9,
25793 + VCI_KCBIT_SPACES = 10,
25794 + VCI_KCBIT_NETV2 = 11,
25796 + VCI_KCBIT_DEBUG = 16,
25797 + VCI_KCBIT_HISTORY = 20,
25798 + VCI_KCBIT_TAGGED = 24,
25799 + VCI_KCBIT_PPTAG = 28,
25801 + VCI_KCBIT_MORE = 31,
25805 +static inline uint32_t vci_kernel_config(void)
25808 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25810 + /* configured features */
25811 +#ifdef CONFIG_VSERVER_PROC_SECURE
25812 + (1 << VCI_KCBIT_PROC_SECURE) |
25814 +#ifdef CONFIG_VSERVER_HARDCPU
25815 + (1 << VCI_KCBIT_HARDCPU) |
25817 +#ifdef CONFIG_VSERVER_IDLELIMIT
25818 + (1 << VCI_KCBIT_IDLELIMIT) |
25820 +#ifdef CONFIG_VSERVER_IDLETIME
25821 + (1 << VCI_KCBIT_IDLETIME) |
25823 +#ifdef CONFIG_VSERVER_COWBL
25824 + (1 << VCI_KCBIT_COWBL) |
25825 + (1 << VCI_KCBIT_FULLCOWBL) |
25827 + (1 << VCI_KCBIT_SPACES) |
25828 + (1 << VCI_KCBIT_NETV2) |
25830 + /* debug options */
25831 +#ifdef CONFIG_VSERVER_DEBUG
25832 + (1 << VCI_KCBIT_DEBUG) |
25834 +#ifdef CONFIG_VSERVER_HISTORY
25835 + (1 << VCI_KCBIT_HISTORY) |
25838 + /* inode context tagging */
25839 +#if defined(CONFIG_TAGGING_NONE)
25840 + (0 << VCI_KCBIT_TAGGED) |
25841 +#elif defined(CONFIG_TAGGING_UID16)
25842 + (1 << VCI_KCBIT_TAGGED) |
25843 +#elif defined(CONFIG_TAGGING_GID16)
25844 + (2 << VCI_KCBIT_TAGGED) |
25845 +#elif defined(CONFIG_TAGGING_ID24)
25846 + (3 << VCI_KCBIT_TAGGED) |
25847 +#elif defined(CONFIG_TAGGING_INTERN)
25848 + (4 << VCI_KCBIT_TAGGED) |
25849 +#elif defined(CONFIG_TAGGING_RUNTIME)
25850 + (5 << VCI_KCBIT_TAGGED) |
25852 + (7 << VCI_KCBIT_TAGGED) |
25854 + (1 << VCI_KCBIT_PPTAG) |
25858 diff -NurpP --minimal linux-2.6.27.14/mm/filemap_xip.c linux-2.6.27.14-vs2.3.0.36.4/mm/filemap_xip.c
25859 --- linux-2.6.27.14/mm/filemap_xip.c 2008-10-13 14:52:09.000000000 +0200
25860 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/filemap_xip.c 2008-10-13 14:54:20.000000000 +0200
25862 #include <linux/sched.h>
25863 #include <linux/seqlock.h>
25864 #include <linux/mutex.h>
25865 +#include <linux/vs_memory.h>
25866 #include <asm/tlbflush.h>
25867 #include <asm/io.h>
25869 diff -NurpP --minimal linux-2.6.27.14/mm/fremap.c linux-2.6.27.14-vs2.3.0.36.4/mm/fremap.c
25870 --- linux-2.6.27.14/mm/fremap.c 2009-02-03 17:59:55.000000000 +0100
25871 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/fremap.c 2009-02-03 17:59:04.000000000 +0100
25873 #include <linux/module.h>
25874 #include <linux/syscalls.h>
25875 #include <linux/mmu_notifier.h>
25876 +#include <linux/vs_memory.h>
25878 #include <asm/mmu_context.h>
25879 #include <asm/cacheflush.h>
25880 diff -NurpP --minimal linux-2.6.27.14/mm/hugetlb.c linux-2.6.27.14-vs2.3.0.36.4/mm/hugetlb.c
25881 --- linux-2.6.27.14/mm/hugetlb.c 2009-02-03 17:59:55.000000000 +0100
25882 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/hugetlb.c 2009-02-03 17:59:04.000000000 +0100
25884 #include <asm/io.h>
25886 #include <linux/hugetlb.h>
25887 +#include <linux/vs_memory.h>
25888 #include "internal.h"
25890 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25891 diff -NurpP --minimal linux-2.6.27.14/mm/memory.c linux-2.6.27.14-vs2.3.0.36.4/mm/memory.c
25892 --- linux-2.6.27.14/mm/memory.c 2008-10-13 14:52:09.000000000 +0200
25893 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/memory.c 2008-10-13 14:54:20.000000000 +0200
25894 @@ -562,6 +562,9 @@ static int copy_pte_range(struct mm_stru
25898 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25902 rss[1] = rss[0] = 0;
25903 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25904 @@ -2294,6 +2297,11 @@ static int do_swap_page(struct mm_struct
25908 + if (!vx_rss_avail(mm, 1)) {
25909 + ret = VM_FAULT_OOM;
25913 mark_page_accessed(page);
25915 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
25916 @@ -2365,6 +2373,8 @@ static int do_anonymous_page(struct mm_s
25917 /* Allocate our own private page. */
25918 pte_unmap(page_table);
25920 + if (!vx_rss_avail(mm, 1))
25922 if (unlikely(anon_vma_prepare(vma)))
25924 page = alloc_zeroed_user_highpage_movable(vma, address);
25925 @@ -2626,6 +2636,7 @@ static inline int handle_pte_fault(struc
25929 + int ret = 0, type = VXPT_UNKNOWN;
25932 if (!pte_present(entry)) {
25933 @@ -2650,9 +2661,12 @@ static inline int handle_pte_fault(struc
25934 if (unlikely(!pte_same(*pte, entry)))
25936 if (write_access) {
25937 - if (!pte_write(entry))
25938 - return do_wp_page(mm, vma, address,
25939 + if (!pte_write(entry)) {
25940 + ret = do_wp_page(mm, vma, address,
25941 pte, pmd, ptl, entry);
25942 + type = VXPT_WRITE;
25945 entry = pte_mkdirty(entry);
25947 entry = pte_mkyoung(entry);
25948 @@ -2670,7 +2684,10 @@ static inline int handle_pte_fault(struc
25951 pte_unmap_unlock(pte, ptl);
25955 + vx_page_fault(mm, vma, type, ret);
25960 diff -NurpP --minimal linux-2.6.27.14/mm/mlock.c linux-2.6.27.14-vs2.3.0.36.4/mm/mlock.c
25961 --- linux-2.6.27.14/mm/mlock.c 2009-02-03 17:59:55.000000000 +0100
25962 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/mlock.c 2009-02-03 17:59:04.000000000 +0100
25964 #include <linux/syscalls.h>
25965 #include <linux/sched.h>
25966 #include <linux/module.h>
25967 +#include <linux/vs_memory.h>
25969 int can_do_mlock(void)
25971 @@ -76,7 +77,7 @@ success:
25972 ret = make_pages_present(start, end);
25975 - mm->locked_vm -= pages;
25976 + vx_vmlocked_sub(mm, pages);
25980 @@ -132,7 +133,7 @@ static int do_mlock(unsigned long start,
25982 SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
25984 - unsigned long locked;
25985 + unsigned long locked, grow;
25986 unsigned long lock_limit;
25987 int error = -ENOMEM;
25989 @@ -143,8 +144,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
25990 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25991 start &= PAGE_MASK;
25993 - locked = len >> PAGE_SHIFT;
25994 - locked += current->mm->locked_vm;
25995 + grow = len >> PAGE_SHIFT;
25996 + if (!vx_vmlocked_avail(current->mm, grow))
25998 + locked = current->mm->locked_vm + grow;
26000 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26001 lock_limit >>= PAGE_SHIFT;
26002 @@ -152,6 +155,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26003 /* check against resource limits */
26004 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26005 error = do_mlock(start, len, 1);
26007 up_write(¤t->mm->mmap_sem);
26010 @@ -211,6 +215,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
26011 lock_limit >>= PAGE_SHIFT;
26014 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
26016 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
26017 capable(CAP_IPC_LOCK))
26018 ret = do_mlockall(flags);
26019 diff -NurpP --minimal linux-2.6.27.14/mm/mmap.c linux-2.6.27.14-vs2.3.0.36.4/mm/mmap.c
26020 --- linux-2.6.27.14/mm/mmap.c 2009-02-03 17:59:55.000000000 +0100
26021 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/mmap.c 2009-02-03 17:59:04.000000000 +0100
26022 @@ -1221,10 +1221,10 @@ munmap_back:
26023 if (correct_wcount)
26024 atomic_inc(&inode->i_writecount);
26026 - mm->total_vm += len >> PAGE_SHIFT;
26027 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26028 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
26029 if (vm_flags & VM_LOCKED) {
26030 - mm->locked_vm += len >> PAGE_SHIFT;
26031 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26032 make_pages_present(addr, addr + len);
26034 if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
26035 @@ -1573,9 +1573,9 @@ static int acct_stack_growth(struct vm_a
26038 /* Ok, everything looks good - let it rip */
26039 - mm->total_vm += grow;
26040 + vx_vmpages_add(mm, grow);
26041 if (vma->vm_flags & VM_LOCKED)
26042 - mm->locked_vm += grow;
26043 + vx_vmlocked_add(mm, grow);
26044 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
26047 @@ -1746,9 +1746,9 @@ static void remove_vma_list(struct mm_st
26049 long nrpages = vma_pages(vma);
26051 - mm->total_vm -= nrpages;
26052 + vx_vmpages_sub(mm, nrpages);
26053 if (vma->vm_flags & VM_LOCKED)
26054 - mm->locked_vm -= nrpages;
26055 + vx_vmlocked_sub(mm, nrpages);
26056 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
26057 vma = remove_vma(vma);
26059 @@ -1995,6 +1995,8 @@ unsigned long do_brk(unsigned long addr,
26060 lock_limit >>= PAGE_SHIFT;
26061 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26063 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
26068 @@ -2021,7 +2023,8 @@ unsigned long do_brk(unsigned long addr,
26069 if (mm->map_count > sysctl_max_map_count)
26072 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
26073 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
26074 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
26077 /* Can we just expand an old private anonymous mapping? */
26078 @@ -2046,9 +2049,9 @@ unsigned long do_brk(unsigned long addr,
26079 vma->vm_page_prot = vm_get_page_prot(flags);
26080 vma_link(mm, vma, prev, rb_link, rb_parent);
26082 - mm->total_vm += len >> PAGE_SHIFT;
26083 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26084 if (flags & VM_LOCKED) {
26085 - mm->locked_vm += len >> PAGE_SHIFT;
26086 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
26087 make_pages_present(addr, addr + len);
26090 @@ -2078,6 +2081,11 @@ void exit_mmap(struct mm_struct *mm)
26091 free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
26092 tlb_finish_mmu(tlb, 0, end);
26094 + set_mm_counter(mm, file_rss, 0);
26095 + set_mm_counter(mm, anon_rss, 0);
26096 + vx_vmpages_sub(mm, mm->total_vm);
26097 + vx_vmlocked_sub(mm, mm->locked_vm);
26100 * Walk the list again, actually closing and freeing it,
26101 * with preemption enabled, without holding any MM locks.
26102 @@ -2117,7 +2125,8 @@ int insert_vm_struct(struct mm_struct *
26103 if (__vma && __vma->vm_start < vma->vm_end)
26105 if ((vma->vm_flags & VM_ACCOUNT) &&
26106 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
26107 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
26108 + !vx_vmpages_avail(mm, vma_pages(vma))))
26110 vma_link(mm, vma, prev, rb_link, rb_parent);
26112 @@ -2193,6 +2202,8 @@ int may_expand_vm(struct mm_struct *mm,
26114 if (cur + npages > lim)
26116 + if (!vx_vmpages_avail(mm, npages))
26121 @@ -2270,8 +2281,7 @@ int install_special_mapping(struct mm_st
26125 - mm->total_vm += len >> PAGE_SHIFT;
26127 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
26131 diff -NurpP --minimal linux-2.6.27.14/mm/mremap.c linux-2.6.27.14-vs2.3.0.36.4/mm/mremap.c
26132 --- linux-2.6.27.14/mm/mremap.c 2009-02-03 17:59:55.000000000 +0100
26133 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/mremap.c 2009-02-03 17:59:04.000000000 +0100
26135 #include <linux/security.h>
26136 #include <linux/syscalls.h>
26137 #include <linux/mmu_notifier.h>
26138 +#include <linux/vs_memory.h>
26140 #include <asm/uaccess.h>
26141 #include <asm/cacheflush.h>
26142 @@ -218,7 +219,7 @@ static unsigned long move_vma(struct vm_
26143 * If this were a serious issue, we'd add a flag to do_munmap().
26145 hiwater_vm = mm->hiwater_vm;
26146 - mm->total_vm += new_len >> PAGE_SHIFT;
26147 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
26148 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
26150 if (do_munmap(mm, old_addr, old_len) < 0) {
26151 @@ -236,7 +237,7 @@ static unsigned long move_vma(struct vm_
26154 if (vm_flags & VM_LOCKED) {
26155 - mm->locked_vm += new_len >> PAGE_SHIFT;
26156 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
26157 if (new_len > old_len)
26158 make_pages_present(new_addr + old_len,
26159 new_addr + new_len);
26160 @@ -347,6 +348,9 @@ unsigned long do_mremap(unsigned long ad
26162 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
26164 + if (!vx_vmlocked_avail(current->mm,
26165 + (new_len - old_len) >> PAGE_SHIFT))
26168 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
26170 @@ -375,10 +379,10 @@ unsigned long do_mremap(unsigned long ad
26171 vma_adjust(vma, vma->vm_start,
26172 addr + new_len, vma->vm_pgoff, NULL);
26174 - mm->total_vm += pages;
26175 + vx_vmpages_add(mm, pages);
26176 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
26177 if (vma->vm_flags & VM_LOCKED) {
26178 - mm->locked_vm += pages;
26179 + vx_vmlocked_add(mm, pages);
26180 make_pages_present(addr + old_len,
26183 diff -NurpP --minimal linux-2.6.27.14/mm/nommu.c linux-2.6.27.14-vs2.3.0.36.4/mm/nommu.c
26184 --- linux-2.6.27.14/mm/nommu.c 2009-02-03 17:59:55.000000000 +0100
26185 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/nommu.c 2009-02-03 17:59:04.000000000 +0100
26186 @@ -1028,7 +1028,7 @@ unsigned long do_mmap_pgoff(struct file
26187 realalloc += kobjsize(vma);
26188 askedalloc += sizeof(*vma);
26190 - current->mm->total_vm += len >> PAGE_SHIFT;
26191 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
26193 add_nommu_vma(vma);
26195 @@ -1160,7 +1160,7 @@ int do_munmap(struct mm_struct *mm, unsi
26198 update_hiwater_vm(mm);
26199 - mm->total_vm -= len >> PAGE_SHIFT;
26200 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
26203 show_process_blocks();
26204 @@ -1193,7 +1193,7 @@ void exit_mmap(struct mm_struct * mm)
26205 printk("Exit_mmap:\n");
26208 - mm->total_vm = 0;
26209 + vx_vmpages_sub(mm, mm->total_vm);
26211 while ((tmp = mm->context.vmlist)) {
26212 mm->context.vmlist = tmp->next;
26213 diff -NurpP --minimal linux-2.6.27.14/mm/oom_kill.c linux-2.6.27.14-vs2.3.0.36.4/mm/oom_kill.c
26214 --- linux-2.6.27.14/mm/oom_kill.c 2008-10-13 14:52:09.000000000 +0200
26215 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/oom_kill.c 2008-10-13 14:54:20.000000000 +0200
26217 #include <linux/notifier.h>
26218 #include <linux/memcontrol.h>
26219 #include <linux/security.h>
26220 +#include <linux/vs_memory.h>
26222 int sysctl_panic_on_oom;
26223 int sysctl_oom_kill_allocating_task;
26224 @@ -73,6 +74,12 @@ unsigned long badness(struct task_struct
26225 points = mm->total_vm;
26228 + * add points for context badness
26231 + points += vx_badness(p, mm);
26234 * After this unlock we can no longer dereference local variable `mm'
26237 @@ -163,8 +170,8 @@ unsigned long badness(struct task_struct
26241 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26242 - p->pid, p->comm, points);
26243 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26244 + task_pid_nr(p), p->xid, p->comm, points);
26248 @@ -325,8 +332,8 @@ static void __oom_kill_task(struct task_
26252 - printk(KERN_ERR "Killed process %d (%s)\n",
26253 - task_pid_nr(p), p->comm);
26254 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
26255 + task_pid_nr(p), p->xid, p->comm);
26258 * We give our sacrificial lamb high priority and access to
26259 @@ -406,8 +413,8 @@ static int oom_kill_process(struct task_
26263 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26264 - message, task_pid_nr(p), p->comm, points);
26265 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
26266 + message, task_pid_nr(p), p->xid, p->comm, points);
26268 /* Try to kill a child first */
26269 list_for_each_entry(c, &p->children, sibling) {
26270 diff -NurpP --minimal linux-2.6.27.14/mm/page_alloc.c linux-2.6.27.14-vs2.3.0.36.4/mm/page_alloc.c
26271 --- linux-2.6.27.14/mm/page_alloc.c 2009-02-03 17:59:55.000000000 +0100
26272 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/page_alloc.c 2009-02-03 17:59:04.000000000 +0100
26274 #include <linux/page-isolation.h>
26275 #include <linux/memcontrol.h>
26276 #include <linux/debugobjects.h>
26277 +#include <linux/vs_base.h>
26278 +#include <linux/vs_limit.h>
26280 #include <asm/tlbflush.h>
26281 #include <asm/div64.h>
26282 @@ -1823,6 +1825,9 @@ void si_meminfo(struct sysinfo *val)
26283 val->totalhigh = totalhigh_pages;
26284 val->freehigh = nr_free_highpages();
26285 val->mem_unit = PAGE_SIZE;
26287 + if (vx_flags(VXF_VIRT_MEM, 0))
26288 + vx_vsi_meminfo(val);
26291 EXPORT_SYMBOL(si_meminfo);
26292 @@ -1843,6 +1848,9 @@ void si_meminfo_node(struct sysinfo *val
26295 val->mem_unit = PAGE_SIZE;
26297 + if (vx_flags(VXF_VIRT_MEM, 0))
26298 + vx_vsi_meminfo(val);
26302 diff -NurpP --minimal linux-2.6.27.14/mm/rmap.c linux-2.6.27.14-vs2.3.0.36.4/mm/rmap.c
26303 --- linux-2.6.27.14/mm/rmap.c 2009-02-03 17:59:55.000000000 +0100
26304 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/rmap.c 2009-02-03 17:59:04.000000000 +0100
26306 #include <linux/kallsyms.h>
26307 #include <linux/memcontrol.h>
26308 #include <linux/mmu_notifier.h>
26309 +#include <linux/vs_memory.h>
26311 #include <asm/tlbflush.h>
26313 diff -NurpP --minimal linux-2.6.27.14/mm/shmem.c linux-2.6.27.14-vs2.3.0.36.4/mm/shmem.c
26314 --- linux-2.6.27.14/mm/shmem.c 2008-10-13 14:52:09.000000000 +0200
26315 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/shmem.c 2008-10-13 14:54:20.000000000 +0200
26317 #include <asm/pgtable.h>
26319 /* This magic number is used in glibc for posix shared memory */
26320 -#define TMPFS_MAGIC 0x01021994
26322 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
26323 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
26324 @@ -1738,7 +1737,7 @@ static int shmem_statfs(struct dentry *d
26326 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26328 - buf->f_type = TMPFS_MAGIC;
26329 + buf->f_type = TMPFS_SUPER_MAGIC;
26330 buf->f_bsize = PAGE_CACHE_SIZE;
26331 buf->f_namelen = NAME_MAX;
26332 spin_lock(&sbinfo->stat_lock);
26333 @@ -2306,7 +2305,7 @@ static int shmem_fill_super(struct super
26334 sb->s_maxbytes = SHMEM_MAX_BYTES;
26335 sb->s_blocksize = PAGE_CACHE_SIZE;
26336 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26337 - sb->s_magic = TMPFS_MAGIC;
26338 + sb->s_magic = TMPFS_SUPER_MAGIC;
26339 sb->s_op = &shmem_ops;
26340 sb->s_time_gran = 1;
26341 #ifdef CONFIG_TMPFS_POSIX_ACL
26342 diff -NurpP --minimal linux-2.6.27.14/mm/slab.c linux-2.6.27.14-vs2.3.0.36.4/mm/slab.c
26343 --- linux-2.6.27.14/mm/slab.c 2008-10-13 14:52:09.000000000 +0200
26344 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/slab.c 2008-10-13 14:54:20.000000000 +0200
26345 @@ -508,6 +508,8 @@ struct kmem_cache {
26346 #define STATS_INC_FREEMISS(x) do { } while (0)
26349 +#include "slab_vs.h"
26354 @@ -3337,6 +3339,7 @@ retry:
26356 obj = slab_get_obj(cachep, slabp, nodeid);
26357 check_slabp(cachep, slabp);
26358 + vx_slab_alloc(cachep, flags);
26359 l3->free_objects--;
26360 /* move slabp to correct slabp list: */
26361 list_del(&slabp->list);
26362 @@ -3409,6 +3412,7 @@ __cache_alloc_node(struct kmem_cache *ca
26363 /* ___cache_alloc_node can fall back to other nodes */
26364 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26366 + vx_slab_alloc(cachep, flags);
26367 local_irq_restore(save_flags);
26368 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26370 @@ -3580,6 +3584,7 @@ static inline void __cache_free(struct k
26373 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26374 + vx_slab_free(cachep);
26377 * Skip calling cache_free_alien() when the platform is not numa.
26378 diff -NurpP --minimal linux-2.6.27.14/mm/slab_vs.h linux-2.6.27.14-vs2.3.0.36.4/mm/slab_vs.h
26379 --- linux-2.6.27.14/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26380 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/slab_vs.h 2008-10-13 14:54:20.000000000 +0200
26383 +#include <linux/vserver/context.h>
26385 +#include <linux/vs_context.h>
26388 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26390 + int what = gfp_zone(cachep->gfpflags);
26392 + if (!current->vx_info)
26395 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26399 +void vx_slab_free(struct kmem_cache *cachep)
26401 + int what = gfp_zone(cachep->gfpflags);
26403 + if (!current->vx_info)
26406 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26409 diff -NurpP --minimal linux-2.6.27.14/mm/swapfile.c linux-2.6.27.14-vs2.3.0.36.4/mm/swapfile.c
26410 --- linux-2.6.27.14/mm/swapfile.c 2009-02-03 17:59:55.000000000 +0100
26411 +++ linux-2.6.27.14-vs2.3.0.36.4/mm/swapfile.c 2009-02-03 17:59:04.000000000 +0100
26413 #include <asm/pgtable.h>
26414 #include <asm/tlbflush.h>
26415 #include <linux/swapops.h>
26416 +#include <linux/vs_base.h>
26417 +#include <linux/vs_memory.h>
26419 static DEFINE_SPINLOCK(swap_lock);
26420 static unsigned int nr_swapfiles;
26421 @@ -1748,6 +1750,8 @@ void si_swapinfo(struct sysinfo *val)
26422 val->freeswap = nr_swap_pages + nr_to_be_unused;
26423 val->totalswap = total_swap_pages + nr_to_be_unused;
26424 spin_unlock(&swap_lock);
26425 + if (vx_flags(VXF_VIRT_MEM, 0))
26426 + vx_vsi_swapinfo(val);
26430 diff -NurpP --minimal linux-2.6.27.14/net/core/dev.c linux-2.6.27.14-vs2.3.0.36.4/net/core/dev.c
26431 --- linux-2.6.27.14/net/core/dev.c 2009-02-03 17:59:55.000000000 +0100
26432 +++ linux-2.6.27.14-vs2.3.0.36.4/net/core/dev.c 2009-02-03 17:59:04.000000000 +0100
26433 @@ -127,6 +127,7 @@
26434 #include <linux/in.h>
26435 #include <linux/jhash.h>
26436 #include <linux/random.h>
26437 +#include <linux/vs_inet.h>
26439 #include "net-sysfs.h"
26441 @@ -925,10 +926,15 @@ int dev_change_name(struct net_device *d
26442 strlcpy(dev->name, newname, IFNAMSIZ);
26445 - err = device_rename(&dev->dev, dev->name);
26447 - memcpy(dev->name, oldname, IFNAMSIZ);
26449 + /* For now only devices in the initial network namespace
26452 + if (net == &init_net) {
26453 + ret = device_rename(&dev->dev, dev->name);
26455 + memcpy(dev->name, oldname, IFNAMSIZ);
26460 write_lock_bh(&dev_base_lock);
26461 @@ -2515,6 +2521,8 @@ static int dev_ifconf(struct net *net, c
26464 for_each_netdev(net, dev) {
26465 + if (!nx_dev_visible(current->nx_info, dev))
26467 for (i = 0; i < NPROTO; i++) {
26468 if (gifconf_list[i]) {
26470 @@ -2583,6 +2591,9 @@ static void dev_seq_printf_stats(struct
26472 struct net_device_stats *stats = dev->get_stats(dev);
26474 + if (!nx_dev_visible(current->nx_info, dev))
26477 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26478 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26479 dev->name, stats->rx_bytes, stats->rx_packets,
26480 @@ -4385,6 +4396,15 @@ int dev_change_net_namespace(struct net_
26481 if (dev->features & NETIF_F_NETNS_LOCAL)
26484 +#ifdef CONFIG_SYSFS
26485 + /* Don't allow real devices to be moved when sysfs
26489 + if (dev->dev.parent)
26493 /* Ensure the device has been registrered */
26495 if (dev->reg_state != NETREG_REGISTERED)
26496 @@ -4442,6 +4462,8 @@ int dev_change_net_namespace(struct net_
26498 dev_addr_discard(dev);
26500 + netdev_unregister_kobject(dev);
26502 /* Actually switch the network namespace */
26503 dev_net_set(dev, net);
26505 @@ -4458,7 +4480,6 @@ int dev_change_net_namespace(struct net_
26508 /* Fixup kobjects */
26509 - netdev_unregister_kobject(dev);
26510 err = netdev_register_kobject(dev);
26513 diff -NurpP --minimal linux-2.6.27.14/net/core/net-sysfs.c linux-2.6.27.14-vs2.3.0.36.4/net/core/net-sysfs.c
26514 --- linux-2.6.27.14/net/core/net-sysfs.c 2008-10-13 14:52:09.000000000 +0200
26515 +++ linux-2.6.27.14-vs2.3.0.36.4/net/core/net-sysfs.c 2008-11-20 15:21:32.000000000 +0100
26516 @@ -440,6 +440,10 @@ void netdev_unregister_kobject(struct ne
26517 struct device *dev = &(net->dev);
26519 kobject_get(&dev->kobj);
26521 + if (dev_net(net) != &init_net)
26527 @@ -465,6 +469,9 @@ int netdev_register_kobject(struct net_d
26529 #endif /* CONFIG_SYSFS */
26531 + if (dev_net(net) != &init_net)
26534 return device_add(dev);
26537 diff -NurpP --minimal linux-2.6.27.14/net/core/rtnetlink.c linux-2.6.27.14-vs2.3.0.36.4/net/core/rtnetlink.c
26538 --- linux-2.6.27.14/net/core/rtnetlink.c 2008-10-13 14:52:09.000000000 +0200
26539 +++ linux-2.6.27.14-vs2.3.0.36.4/net/core/rtnetlink.c 2008-10-13 14:54:20.000000000 +0200
26540 @@ -686,6 +686,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26543 for_each_netdev(net, dev) {
26544 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26548 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26549 @@ -1219,6 +1221,9 @@ void rtmsg_ifinfo(int type, struct net_d
26550 struct sk_buff *skb;
26551 int err = -ENOBUFS;
26553 + if (!nx_dev_visible(current->nx_info, dev))
26556 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26559 diff -NurpP --minimal linux-2.6.27.14/net/core/sock.c linux-2.6.27.14-vs2.3.0.36.4/net/core/sock.c
26560 --- linux-2.6.27.14/net/core/sock.c 2008-10-13 14:52:09.000000000 +0200
26561 +++ linux-2.6.27.14-vs2.3.0.36.4/net/core/sock.c 2008-10-13 14:54:20.000000000 +0200
26562 @@ -124,6 +124,10 @@
26563 #include <linux/ipsec.h>
26565 #include <linux/filter.h>
26566 +#include <linux/vs_socket.h>
26567 +#include <linux/vs_limit.h>
26568 +#include <linux/vs_context.h>
26569 +#include <linux/vs_network.h>
26572 #include <net/tcp.h>
26573 @@ -897,6 +901,8 @@ static struct sock *sk_prot_alloc(struct
26574 if (!try_module_get(prot->owner))
26577 + sock_vx_init(sk);
26578 + sock_nx_init(sk);
26582 @@ -973,6 +979,11 @@ void sk_free(struct sock *sk)
26583 __func__, atomic_read(&sk->sk_omem_alloc));
26585 put_net(sock_net(sk));
26587 + clr_vx_info(&sk->sk_vx_info);
26589 + clr_nx_info(&sk->sk_nx_info);
26591 sk_prot_free(sk->sk_prot_creator, sk);
26594 @@ -1008,6 +1019,8 @@ struct sock *sk_clone(const struct sock
26597 get_net(sock_net(newsk));
26598 + sock_vx_init(newsk);
26599 + sock_nx_init(newsk);
26600 sk_node_init(&newsk->sk_node);
26601 sock_lock_init(newsk);
26602 bh_lock_sock(newsk);
26603 @@ -1054,6 +1067,12 @@ struct sock *sk_clone(const struct sock
26604 newsk->sk_priority = 0;
26605 atomic_set(&newsk->sk_refcnt, 2);
26607 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26608 + newsk->sk_xid = sk->sk_xid;
26609 + vx_sock_inc(newsk);
26610 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26611 + newsk->sk_nid = sk->sk_nid;
26614 * Increment the counter in the same struct proto as the master
26615 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26616 @@ -1738,6 +1757,11 @@ void sock_init_data(struct socket *sock,
26618 sk->sk_stamp = ktime_set(-1L, 0);
26620 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26621 + sk->sk_xid = vx_current_xid();
26623 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26624 + sk->sk_nid = nx_current_nid();
26625 atomic_set(&sk->sk_refcnt, 1);
26626 atomic_set(&sk->sk_drops, 0);
26628 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/af_inet.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/af_inet.c
26629 --- linux-2.6.27.14/net/ipv4/af_inet.c 2008-10-13 14:52:09.000000000 +0200
26630 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/af_inet.c 2008-10-13 14:54:20.000000000 +0200
26631 @@ -114,6 +114,7 @@
26632 #ifdef CONFIG_IP_MROUTE
26633 #include <linux/mroute.h>
26635 +#include <linux/vs_limit.h>
26637 extern void ip_mc_drop_socket(struct sock *sk);
26639 @@ -325,9 +326,12 @@ lookup_protocol:
26643 + if ((protocol == IPPROTO_ICMP) &&
26644 + nx_capable(answer->capability, NXC_RAW_ICMP))
26646 if (answer->capability > 0 && !capable(answer->capability))
26647 goto out_rcu_unlock;
26650 err = -EAFNOSUPPORT;
26651 if (!inet_netns_ok(net, protocol))
26652 goto out_rcu_unlock;
26653 @@ -445,6 +449,7 @@ int inet_bind(struct socket *sock, struc
26654 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26655 struct sock *sk = sock->sk;
26656 struct inet_sock *inet = inet_sk(sk);
26657 + struct nx_v4_sock_addr nsa;
26658 unsigned short snum;
26661 @@ -458,7 +463,11 @@ int inet_bind(struct socket *sock, struc
26662 if (addr_len < sizeof(struct sockaddr_in))
26665 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26666 + err = v4_map_sock_addr(inet, addr, &nsa);
26670 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26672 /* Not specified by any standard per-se, however it breaks too
26673 * many applications when removed. It is unfortunate since
26674 @@ -470,7 +479,7 @@ int inet_bind(struct socket *sock, struc
26675 err = -EADDRNOTAVAIL;
26676 if (!sysctl_ip_nonlocal_bind &&
26678 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26679 + nsa.saddr != htonl(INADDR_ANY) &&
26680 chk_addr_ret != RTN_LOCAL &&
26681 chk_addr_ret != RTN_MULTICAST &&
26682 chk_addr_ret != RTN_BROADCAST)
26683 @@ -495,7 +504,7 @@ int inet_bind(struct socket *sock, struc
26684 if (sk->sk_state != TCP_CLOSE || inet->num)
26685 goto out_release_sock;
26687 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26688 + v4_set_sock_addr(inet, &nsa);
26689 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26690 inet->saddr = 0; /* Use device */
26692 @@ -688,11 +697,13 @@ int inet_getname(struct socket *sock, st
26695 sin->sin_port = inet->dport;
26696 - sin->sin_addr.s_addr = inet->daddr;
26697 + sin->sin_addr.s_addr =
26698 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26700 __be32 addr = inet->rcv_saddr;
26702 addr = inet->saddr;
26703 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26704 sin->sin_port = inet->sport;
26705 sin->sin_addr.s_addr = addr;
26707 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/devinet.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/devinet.c
26708 --- linux-2.6.27.14/net/ipv4/devinet.c 2008-10-13 14:52:09.000000000 +0200
26709 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/devinet.c 2008-10-13 14:54:20.000000000 +0200
26710 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
26715 /* Called only from RTNL semaphored context. No locks. */
26717 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26718 @@ -662,6 +663,8 @@ int devinet_ioctl(struct net *net, unsig
26721 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26722 + struct nx_info *nxi = current->nx_info;
26724 if (tryaddrmatch) {
26725 /* Matthias Andree */
26726 /* compare label and address (4.4BSD style) */
26727 @@ -670,6 +673,8 @@ int devinet_ioctl(struct net *net, unsig
26728 This is checked above. */
26729 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26730 ifap = &ifa->ifa_next) {
26731 + if (!nx_v4_ifa_visible(nxi, ifa))
26733 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26734 sin_orig.sin_addr.s_addr ==
26735 ifa->ifa_address) {
26736 @@ -682,9 +687,12 @@ int devinet_ioctl(struct net *net, unsig
26737 comparing just the label */
26739 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26740 - ifap = &ifa->ifa_next)
26741 + ifap = &ifa->ifa_next) {
26742 + if (!nx_v4_ifa_visible(nxi, ifa))
26744 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26750 @@ -835,6 +843,8 @@ static int inet_gifconf(struct net_devic
26753 for (; ifa; ifa = ifa->ifa_next) {
26754 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
26757 done += sizeof(ifr);
26759 @@ -1165,6 +1175,7 @@ static int inet_dump_ifaddr(struct sk_bu
26760 struct net_device *dev;
26761 struct in_device *in_dev;
26762 struct in_ifaddr *ifa;
26763 + struct sock *sk = skb->sk;
26764 int s_ip_idx, s_idx = cb->args[0];
26766 s_ip_idx = ip_idx = cb->args[1];
26767 @@ -1179,6 +1190,8 @@ static int inet_dump_ifaddr(struct sk_bu
26769 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26770 ifa = ifa->ifa_next, ip_idx++) {
26771 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26773 if (ip_idx < s_ip_idx)
26775 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
26776 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/fib_hash.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/fib_hash.c
26777 --- linux-2.6.27.14/net/ipv4/fib_hash.c 2008-10-13 14:52:09.000000000 +0200
26778 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/fib_hash.c 2008-10-13 14:54:20.000000000 +0200
26779 @@ -1022,7 +1022,7 @@ static int fib_seq_show(struct seq_file
26780 prefix = f->fn_key;
26781 mask = FZ_MASK(iter->zone);
26782 flags = fib_flag_trans(fa->fa_type, mask, fi);
26784 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
26786 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
26787 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26788 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/inet_connection_sock.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/inet_connection_sock.c
26789 --- linux-2.6.27.14/net/ipv4/inet_connection_sock.c 2008-10-13 14:52:09.000000000 +0200
26790 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/inet_connection_sock.c 2008-10-13 14:54:20.000000000 +0200
26791 @@ -47,10 +47,40 @@ void inet_get_local_port_range(int *low,
26793 EXPORT_SYMBOL(inet_get_local_port_range);
26795 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26797 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
26798 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
26800 + if (inet_v6_ipv6only(sk2))
26803 + if (sk1_rcv_saddr &&
26805 + sk1_rcv_saddr == sk2_rcv_saddr)
26808 + if (sk1_rcv_saddr &&
26809 + !sk2_rcv_saddr &&
26810 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26813 + if (sk2_rcv_saddr &&
26814 + !sk1_rcv_saddr &&
26815 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26818 + if (!sk1_rcv_saddr &&
26819 + !sk2_rcv_saddr &&
26820 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26826 int inet_csk_bind_conflict(const struct sock *sk,
26827 const struct inet_bind_bucket *tb)
26829 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26831 struct hlist_node *node;
26832 int reuse = sk->sk_reuse;
26833 @@ -70,9 +100,7 @@ int inet_csk_bind_conflict(const struct
26834 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26835 if (!reuse || !sk2->sk_reuse ||
26836 sk2->sk_state == TCP_LISTEN) {
26837 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26838 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26839 - sk2_rcv_saddr == sk_rcv_saddr)
26840 + if (ipv4_rcv_saddr_equal(sk, sk2))
26844 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/inet_diag.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/inet_diag.c
26845 --- linux-2.6.27.14/net/ipv4/inet_diag.c 2008-10-13 14:52:09.000000000 +0200
26846 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/inet_diag.c 2008-10-13 14:54:20.000000000 +0200
26848 #include <linux/stddef.h>
26850 #include <linux/inet_diag.h>
26851 +#include <linux/vs_network.h>
26852 +#include <linux/vs_inet.h>
26854 static const struct inet_diag_handler **inet_diag_table;
26856 @@ -120,8 +122,8 @@ static int inet_csk_diag_fill(struct soc
26858 r->id.idiag_sport = inet->sport;
26859 r->id.idiag_dport = inet->dport;
26860 - r->id.idiag_src[0] = inet->rcv_saddr;
26861 - r->id.idiag_dst[0] = inet->daddr;
26862 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
26863 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
26865 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26866 if (r->idiag_family == AF_INET6) {
26867 @@ -208,8 +210,8 @@ static int inet_twsk_diag_fill(struct in
26868 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26869 r->id.idiag_sport = tw->tw_sport;
26870 r->id.idiag_dport = tw->tw_dport;
26871 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26872 - r->id.idiag_dst[0] = tw->tw_daddr;
26873 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26874 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26875 r->idiag_state = tw->tw_substate;
26876 r->idiag_timer = 3;
26877 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26878 @@ -266,6 +268,7 @@ static int inet_diag_get_exact(struct sk
26881 if (req->idiag_family == AF_INET) {
26882 + /* TODO: lback */
26883 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26884 req->id.idiag_dport, req->id.idiag_src[0],
26885 req->id.idiag_sport, req->id.idiag_if);
26886 @@ -508,6 +511,7 @@ static int inet_csk_diag_dump(struct soc
26890 + /* TODO: lback */
26891 entry.saddr = &inet->rcv_saddr;
26892 entry.daddr = &inet->daddr;
26894 @@ -544,6 +548,7 @@ static int inet_twsk_diag_dump(struct in
26898 + /* TODO: lback */
26899 entry.saddr = &tw->tw_rcv_saddr;
26900 entry.daddr = &tw->tw_daddr;
26902 @@ -590,8 +595,8 @@ static int inet_diag_fill_req(struct sk_
26904 r->id.idiag_sport = inet->sport;
26905 r->id.idiag_dport = ireq->rmt_port;
26906 - r->id.idiag_src[0] = ireq->loc_addr;
26907 - r->id.idiag_dst[0] = ireq->rmt_addr;
26908 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26909 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26910 r->idiag_expires = jiffies_to_msecs(tmo);
26911 r->idiag_rqueue = 0;
26912 r->idiag_wqueue = 0;
26913 @@ -661,6 +666,7 @@ static int inet_diag_dump_reqs(struct sk
26917 + /* TODO: lback */
26919 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26920 (entry.family == AF_INET6) ?
26921 @@ -729,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
26922 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
26923 struct inet_sock *inet = inet_sk(sk);
26925 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26930 @@ -790,6 +798,8 @@ skip_listen_ht:
26931 sk_for_each(sk, node, &head->chain) {
26932 struct inet_sock *inet = inet_sk(sk);
26934 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26938 if (!(r->idiag_states & (1 << sk->sk_state)))
26939 @@ -814,6 +824,8 @@ next_normal:
26940 inet_twsk_for_each(tw, node,
26943 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26947 if (r->id.idiag_sport != tw->tw_sport &&
26948 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/inet_hashtables.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/inet_hashtables.c
26949 --- linux-2.6.27.14/net/ipv4/inet_hashtables.c 2008-10-13 14:52:09.000000000 +0200
26950 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/inet_hashtables.c 2008-10-13 14:54:20.000000000 +0200
26953 #include <net/inet_connection_sock.h>
26954 #include <net/inet_hashtables.h>
26955 +#include <net/route.h>
26956 #include <net/ip.h>
26959 @@ -163,11 +164,10 @@ static struct sock *inet_lookup_listener
26960 const __be32 rcv_saddr = inet->rcv_saddr;
26961 int score = sk->sk_family == PF_INET ? 1 : 0;
26964 - if (rcv_saddr != daddr)
26966 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
26971 if (sk->sk_bound_dev_if) {
26972 if (sk->sk_bound_dev_if != dif)
26974 @@ -199,7 +199,7 @@ struct sock *__inet_lookup_listener(stru
26975 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
26977 if (inet->num == hnum && !sk->sk_node.next &&
26978 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
26979 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
26980 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
26981 !sk->sk_bound_dev_if && net_eq(sock_net(sk), net))
26983 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/netfilter/nf_nat_helper.c
26984 --- linux-2.6.27.14/net/ipv4/netfilter/nf_nat_helper.c 2008-07-13 23:51:29.000000000 +0200
26985 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/netfilter/nf_nat_helper.c 2008-10-13 14:54:20.000000000 +0200
26987 #include <net/tcp.h>
26989 #include <linux/netfilter_ipv4.h>
26990 +#include <net/route.h>
26991 #include <net/netfilter/nf_conntrack.h>
26992 #include <net/netfilter/nf_conntrack_helper.h>
26993 #include <net/netfilter/nf_conntrack_ecache.h>
26994 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/netfilter.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/netfilter.c
26995 --- linux-2.6.27.14/net/ipv4/netfilter.c 2008-07-13 23:51:29.000000000 +0200
26996 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/netfilter.c 2008-10-13 14:54:20.000000000 +0200
26998 #include <linux/netfilter_ipv4.h>
26999 #include <linux/ip.h>
27000 #include <linux/skbuff.h>
27001 -#include <net/route.h>
27002 +// #include <net/route.h>
27003 #include <net/xfrm.h>
27004 #include <net/ip.h>
27005 #include <net/netfilter/nf_queue.h>
27006 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/raw.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/raw.c
27007 --- linux-2.6.27.14/net/ipv4/raw.c 2008-10-13 14:52:09.000000000 +0200
27008 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/raw.c 2008-10-13 14:54:20.000000000 +0200
27009 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27011 if (net_eq(sock_net(sk), net) && inet->num == num &&
27012 !(inet->daddr && inet->daddr != raddr) &&
27013 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
27014 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
27015 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27016 goto found; /* gotcha */
27018 @@ -372,6 +372,12 @@ static int raw_send_hdrinc(struct sock *
27019 icmp_out_count(net, ((struct icmphdr *)
27020 skb_transport_header(skb))->type);
27023 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27024 + sk->sk_nx_info &&
27025 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27028 err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27031 @@ -383,6 +389,7 @@ out:
27038 IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
27039 @@ -550,6 +557,13 @@ static int raw_sendmsg(struct kiocb *ioc
27042 security_sk_classify_flow(sk, &fl);
27043 + if (sk->sk_nx_info) {
27044 + err = ip_v4_find_src(sock_net(sk),
27045 + sk->sk_nx_info, &rt, &fl);
27050 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27053 @@ -619,17 +633,19 @@ static int raw_bind(struct sock *sk, str
27055 struct inet_sock *inet = inet_sk(sk);
27056 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27057 + struct nx_v4_sock_addr nsa = { 0 };
27061 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27063 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27064 + v4_map_sock_addr(inet, addr, &nsa);
27065 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27066 ret = -EADDRNOTAVAIL;
27067 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27068 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27069 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27071 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
27072 + v4_set_sock_addr(inet, &nsa);
27073 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27074 inet->saddr = 0; /* Use device */
27076 @@ -681,7 +697,8 @@ static int raw_recvmsg(struct kiocb *ioc
27077 /* Copy the address. */
27079 sin->sin_family = AF_INET;
27080 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27081 + sin->sin_addr.s_addr =
27082 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27084 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27086 @@ -858,7 +875,8 @@ static struct sock *raw_get_first(struct
27087 struct hlist_node *node;
27089 sk_for_each(sk, node, &state->h->ht[state->bucket])
27090 - if (sock_net(sk) == seq_file_net(seq))
27091 + if ((sock_net(sk) == seq_file_net(seq)) &&
27092 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27096 @@ -874,7 +892,8 @@ static struct sock *raw_get_next(struct
27100 - } while (sk && sock_net(sk) != seq_file_net(seq));
27101 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27102 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27104 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27105 sk = sk_head(&state->h->ht[state->bucket]);
27106 @@ -933,7 +952,10 @@ static void raw_sock_seq_show(struct seq
27108 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27109 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27110 - i, src, srcp, dest, destp, sp->sk_state,
27112 + nx_map_sock_lback(current_nx_info(), src), srcp,
27113 + nx_map_sock_lback(current_nx_info(), dest), destp,
27115 atomic_read(&sp->sk_wmem_alloc),
27116 atomic_read(&sp->sk_rmem_alloc),
27117 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27118 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/syncookies.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/syncookies.c
27119 --- linux-2.6.27.14/net/ipv4/syncookies.c 2008-10-13 14:52:09.000000000 +0200
27120 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/syncookies.c 2008-10-13 14:54:20.000000000 +0200
27122 #include <linux/cryptohash.h>
27123 #include <linux/kernel.h>
27124 #include <net/tcp.h>
27125 +#include <net/route.h>
27127 /* Timestamps: lowest 9 bits store TCP options */
27129 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/tcp.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/tcp.c
27130 --- linux-2.6.27.14/net/ipv4/tcp.c 2009-02-03 17:59:55.000000000 +0100
27131 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/tcp.c 2009-02-03 17:59:04.000000000 +0100
27132 @@ -264,6 +264,7 @@
27133 #include <linux/cache.h>
27134 #include <linux/err.h>
27135 #include <linux/crypto.h>
27136 +#include <linux/in.h>
27138 #include <net/icmp.h>
27139 #include <net/tcp.h>
27140 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/tcp_ipv4.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/tcp_ipv4.c
27141 --- linux-2.6.27.14/net/ipv4/tcp_ipv4.c 2008-10-13 14:52:09.000000000 +0200
27142 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/tcp_ipv4.c 2008-10-13 14:54:20.000000000 +0200
27143 @@ -1886,6 +1886,12 @@ static void *listening_get_next(struct s
27144 req = req->dl_next;
27147 + vxdprintk(VXD_CBIT(net, 6),
27148 + "sk,req: %p [#%d] (from %d)", req->sk,
27149 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27151 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27153 if (req->rsk_ops->family == st->family) {
27156 @@ -1910,6 +1916,10 @@ get_req:
27159 sk_for_each_from(sk, node) {
27160 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27161 + sk, sk->sk_nid, nx_current_nid());
27162 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27164 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27167 @@ -1960,6 +1970,11 @@ static void *established_get_first(struc
27169 read_lock_bh(lock);
27170 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27171 + vxdprintk(VXD_CBIT(net, 6),
27172 + "sk,egf: %p [#%d] (from %d)",
27173 + sk, sk->sk_nid, nx_current_nid());
27174 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27176 if (sk->sk_family != st->family ||
27177 !net_eq(sock_net(sk), net)) {
27179 @@ -1970,6 +1985,11 @@ static void *established_get_first(struc
27180 st->state = TCP_SEQ_STATE_TIME_WAIT;
27181 inet_twsk_for_each(tw, node,
27182 &tcp_hashinfo.ehash[st->bucket].twchain) {
27183 + vxdprintk(VXD_CBIT(net, 6),
27184 + "tw: %p [#%d] (from %d)",
27185 + tw, tw->tw_nid, nx_current_nid());
27186 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27188 if (tw->tw_family != st->family ||
27189 !net_eq(twsk_net(tw), net)) {
27191 @@ -1998,7 +2018,9 @@ static void *established_get_next(struct
27195 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27196 + while (tw && (tw->tw_family != st->family ||
27197 + !net_eq(twsk_net(tw), net) ||
27198 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27202 @@ -2019,6 +2041,11 @@ get_tw:
27205 sk_for_each_from(sk, node) {
27206 + vxdprintk(VXD_CBIT(net, 6),
27207 + "sk,egn: %p [#%d] (from %d)",
27208 + sk, sk->sk_nid, nx_current_nid());
27209 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27211 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27214 @@ -2173,9 +2200,9 @@ static void get_openreq4(struct sock *sk
27215 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27216 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27219 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27220 ntohs(inet_sk(sk)->sport),
27222 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27223 ntohs(ireq->rmt_port),
27225 0, 0, /* could print option size, but that is af dependent. */
27226 @@ -2218,7 +2245,10 @@ static void get_tcp4_sock(struct sock *s
27228 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27229 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27230 - i, src, srcp, dest, destp, sk->sk_state,
27232 + nx_map_sock_lback(current_nx_info(), src), srcp,
27233 + nx_map_sock_lback(current_nx_info(), dest), destp,
27235 tp->write_seq - tp->snd_una,
27236 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
27237 (tp->rcv_nxt - tp->copied_seq),
27238 @@ -2254,7 +2284,10 @@ static void get_timewait4_sock(struct in
27240 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27241 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27242 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27244 + nx_map_sock_lback(current_nx_info(), src), srcp,
27245 + nx_map_sock_lback(current_nx_info(), dest), destp,
27246 + tw->tw_substate, 0, 0,
27247 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27248 atomic_read(&tw->tw_refcnt), tw, len);
27250 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/tcp_minisocks.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/tcp_minisocks.c
27251 --- linux-2.6.27.14/net/ipv4/tcp_minisocks.c 2008-10-13 14:52:09.000000000 +0200
27252 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/tcp_minisocks.c 2008-10-13 14:54:20.000000000 +0200
27254 #include <net/inet_common.h>
27255 #include <net/xfrm.h>
27257 +#include <linux/vs_limit.h>
27258 +#include <linux/vs_socket.h>
27259 +#include <linux/vs_context.h>
27261 #ifdef CONFIG_SYSCTL
27262 #define SYNC_INIT 0 /* let the user enable it */
27264 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
27265 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27266 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27268 + tw->tw_xid = sk->sk_xid;
27269 + tw->tw_vx_info = NULL;
27270 + tw->tw_nid = sk->sk_nid;
27271 + tw->tw_nx_info = NULL;
27273 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27274 if (tw->tw_family == PF_INET6) {
27275 struct ipv6_pinfo *np = inet6_sk(sk);
27276 diff -NurpP --minimal linux-2.6.27.14/net/ipv4/udp.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/udp.c
27277 --- linux-2.6.27.14/net/ipv4/udp.c 2009-02-03 17:59:55.000000000 +0100
27278 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv4/udp.c 2009-02-03 17:59:04.000000000 +0100
27279 @@ -234,20 +234,14 @@ fail:
27283 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27285 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27287 - return ( !ipv6_only_sock(sk2) &&
27288 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
27289 - inet1->rcv_saddr == inet2->rcv_saddr ));
27291 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27293 int udp_v4_get_port(struct sock *sk, unsigned short snum)
27295 return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal);
27299 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27300 * harder than this. -DaveM
27302 @@ -267,10 +261,16 @@ static struct sock *__udp4_lib_lookup(st
27303 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
27304 !ipv6_only_sock(sk)) {
27305 int score = (sk->sk_family == PF_INET ? 1 : 0);
27307 if (inet->rcv_saddr) {
27308 if (inet->rcv_saddr != daddr)
27312 + /* block non nx_info ips */
27313 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27314 + daddr, NXA_MASK_BIND))
27318 if (inet->daddr != saddr)
27319 @@ -296,6 +296,7 @@ static struct sock *__udp4_lib_lookup(st
27326 read_unlock(&udp_hash_lock);
27327 @@ -318,7 +319,7 @@ static inline struct sock *udp_v4_mcast_
27328 s->sk_hash != hnum ||
27329 (inet->daddr && inet->daddr != rmt_addr) ||
27330 (inet->dport != rmt_port && inet->dport) ||
27331 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
27332 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27333 ipv6_only_sock(s) ||
27334 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27336 @@ -655,8 +656,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27337 { .sport = inet->sport,
27338 .dport = dport } } };
27339 struct net *net = sock_net(sk);
27340 + struct nx_info *nxi = sk->sk_nx_info;
27342 security_sk_classify_flow(sk, &fl);
27343 + err = ip_v4_find_src(net, nxi, &rt, &fl);
27347 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27349 if (err == -ENETUNREACH)
27350 @@ -901,7 +907,8 @@ try_again:
27352 sin->sin_family = AF_INET;
27353 sin->sin_port = udp_hdr(skb)->source;
27354 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27355 + sin->sin_addr.s_addr = nx_map_sock_lback(
27356 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27357 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27359 if (inet->cmsg_flags)
27360 @@ -1530,6 +1537,8 @@ static struct sock *udp_get_first(struct
27361 sk_for_each(sk, node, state->hashtable + state->bucket) {
27362 if (!net_eq(sock_net(sk), net))
27364 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27366 if (sk->sk_family == state->family)
27369 @@ -1548,7 +1557,9 @@ static struct sock *udp_get_next(struct
27373 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27374 + } while (sk && (!net_eq(sock_net(sk), net) ||
27375 + sk->sk_family != state->family ||
27376 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27378 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
27379 sk = sk_head(state->hashtable + state->bucket);
27380 @@ -1649,7 +1660,10 @@ static void udp4_format_sock(struct sock
27382 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27383 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27384 - bucket, src, srcp, dest, destp, sp->sk_state,
27386 + nx_map_sock_lback(current_nx_info(), src), srcp,
27387 + nx_map_sock_lback(current_nx_info(), dest), destp,
27389 atomic_read(&sp->sk_wmem_alloc),
27390 atomic_read(&sp->sk_rmem_alloc),
27391 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27392 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/addrconf.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/addrconf.c
27393 --- linux-2.6.27.14/net/ipv6/addrconf.c 2008-10-13 14:52:09.000000000 +0200
27394 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/addrconf.c 2008-11-21 13:32:00.000000000 +0100
27397 #include <linux/proc_fs.h>
27398 #include <linux/seq_file.h>
27399 +#include <linux/vs_network.h>
27400 +#include <linux/vs_inet6.h>
27402 /* Set to 3 to get tracing... */
27403 #define ACONF_DEBUG 2
27404 @@ -1108,7 +1110,7 @@ out:
27406 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27407 const struct in6_addr *daddr, unsigned int prefs,
27408 - struct in6_addr *saddr)
27409 + struct in6_addr *saddr, struct nx_info *nxi)
27411 struct ipv6_saddr_score scores[2],
27412 *score = &scores[0], *hiscore = &scores[1];
27413 @@ -1181,6 +1183,8 @@ int ipv6_dev_get_saddr(struct net *net,
27417 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27421 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27422 @@ -1364,35 +1368,46 @@ struct inet6_ifaddr *ipv6_get_ifaddr(str
27426 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
27428 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27430 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27431 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27432 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
27433 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27434 int sk_ipv6only = ipv6_only_sock(sk);
27435 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27436 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27437 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27439 - if (!sk2_rcv_saddr && !sk_ipv6only)
27440 + /* FIXME: needs handling for v4 ANY */
27441 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
27444 if (addr_type2 == IPV6_ADDR_ANY &&
27445 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27446 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
27447 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
27450 if (addr_type == IPV6_ADDR_ANY &&
27451 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27452 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
27453 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
27456 + if (addr_type == IPV6_ADDR_ANY &&
27457 + addr_type2 == IPV6_ADDR_ANY &&
27458 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
27461 if (sk2_rcv_saddr6 &&
27462 + addr_type != IPV6_ADDR_ANY &&
27463 + addr_type != IPV6_ADDR_ANY &&
27464 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27467 if (addr_type == IPV6_ADDR_MAPPED &&
27469 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
27470 + ipv4_rcv_saddr_equal(sk, sk2))
27474 @@ -2986,7 +3001,10 @@ static void if6_seq_stop(struct seq_file
27475 static int if6_seq_show(struct seq_file *seq, void *v)
27477 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27480 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27481 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27483 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
27485 ifp->idev->dev->ifindex,
27486 @@ -3481,6 +3499,12 @@ static int inet6_dump_addr(struct sk_buf
27487 struct ifmcaddr6 *ifmca;
27488 struct ifacaddr6 *ifaca;
27489 struct net *net = sock_net(skb->sk);
27490 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27492 + /* disable ipv6 on non v6 guests */
27493 + if (nxi && !nx_info_has_v6(nxi))
27497 s_idx = cb->args[0];
27498 s_ip_idx = ip_idx = cb->args[1];
27499 @@ -3502,6 +3526,8 @@ static int inet6_dump_addr(struct sk_buf
27500 ifa = ifa->if_next, ip_idx++) {
27501 if (ip_idx < s_ip_idx)
27503 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27505 err = inet6_fill_ifaddr(skb, ifa,
27506 NETLINK_CB(cb->skb).pid,
27507 cb->nlh->nlmsg_seq,
27508 @@ -3515,6 +3541,8 @@ static int inet6_dump_addr(struct sk_buf
27509 ifmca = ifmca->next, ip_idx++) {
27510 if (ip_idx < s_ip_idx)
27512 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27514 err = inet6_fill_ifmcaddr(skb, ifmca,
27515 NETLINK_CB(cb->skb).pid,
27516 cb->nlh->nlmsg_seq,
27517 @@ -3528,6 +3556,8 @@ static int inet6_dump_addr(struct sk_buf
27518 ifaca = ifaca->aca_next, ip_idx++) {
27519 if (ip_idx < s_ip_idx)
27521 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27523 err = inet6_fill_ifacaddr(skb, ifaca,
27524 NETLINK_CB(cb->skb).pid,
27525 cb->nlh->nlmsg_seq,
27526 @@ -3813,12 +3843,19 @@ static int inet6_dump_ifinfo(struct sk_b
27527 int s_idx = cb->args[0];
27528 struct net_device *dev;
27529 struct inet6_dev *idev;
27530 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27532 + /* FIXME: maybe disable ipv6 on non v6 guests?
27533 + if (skb->sk && skb->sk->sk_vx_info)
27534 + return skb->len; */
27536 read_lock(&dev_base_lock);
27538 for_each_netdev(net, dev) {
27541 + if (!v6_dev_in_nx_info(dev, nxi))
27543 if ((idev = in6_dev_get(dev)) == NULL)
27545 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
27546 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/af_inet6.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/af_inet6.c
27547 --- linux-2.6.27.14/net/ipv6/af_inet6.c 2008-10-13 14:52:09.000000000 +0200
27548 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/af_inet6.c 2008-10-13 14:54:20.000000000 +0200
27550 #include <linux/netdevice.h>
27551 #include <linux/icmpv6.h>
27552 #include <linux/netfilter_ipv6.h>
27553 +#include <linux/vs_inet.h>
27554 +#include <linux/vs_inet6.h>
27556 #include <net/ip.h>
27557 #include <net/ipv6.h>
27559 #include <net/tcp.h>
27560 #include <net/ipip.h>
27561 #include <net/protocol.h>
27562 +#include <net/route.h>
27563 #include <net/inet_common.h>
27564 #include <net/transp_v6.h>
27565 #include <net/ip6_route.h>
27566 @@ -141,9 +144,12 @@ lookup_protocol:
27570 + if ((protocol == IPPROTO_ICMPV6) &&
27571 + nx_capable(answer->capability, NXC_RAW_ICMP))
27573 if (answer->capability > 0 && !capable(answer->capability))
27574 goto out_rcu_unlock;
27577 sock->ops = answer->ops;
27578 answer_prot = answer->prot;
27579 answer_no_check = answer->no_check;
27580 @@ -242,6 +248,7 @@ int inet6_bind(struct socket *sock, stru
27581 struct inet_sock *inet = inet_sk(sk);
27582 struct ipv6_pinfo *np = inet6_sk(sk);
27583 struct net *net = sock_net(sk);
27584 + struct nx_v6_sock_addr nsa;
27586 unsigned short snum;
27588 @@ -253,6 +260,11 @@ int inet6_bind(struct socket *sock, stru
27590 if (addr_len < SIN6_LEN_RFC2133)
27593 + err = v6_map_sock_addr(inet, addr, &nsa);
27597 addr_type = ipv6_addr_type(&addr->sin6_addr);
27598 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27600 @@ -276,6 +288,10 @@ int inet6_bind(struct socket *sock, stru
27601 err = -EADDRNOTAVAIL;
27604 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27605 + err = -EADDRNOTAVAIL;
27609 if (addr_type != IPV6_ADDR_ANY) {
27610 struct net_device *dev = NULL;
27611 @@ -301,6 +317,11 @@ int inet6_bind(struct socket *sock, stru
27615 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27616 + err = -EADDRNOTAVAIL;
27620 /* ipv4 addr of the socket is invalid. Only the
27621 * unspecified and mapped address have a v4 equivalent.
27623 @@ -319,6 +340,8 @@ int inet6_bind(struct socket *sock, stru
27627 + v6_set_sock_addr(inet, &nsa);
27629 inet->rcv_saddr = v4addr;
27630 inet->saddr = v4addr;
27632 @@ -411,9 +434,11 @@ int inet6_getname(struct socket *sock, s
27634 sin->sin6_port = inet->dport;
27635 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27636 + /* FIXME: remap lback? */
27638 sin->sin6_flowinfo = np->flow_label;
27640 + /* FIXME: remap lback? */
27641 if (ipv6_addr_any(&np->rcv_saddr))
27642 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27644 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/fib6_rules.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/fib6_rules.c
27645 --- linux-2.6.27.14/net/ipv6/fib6_rules.c 2008-10-13 14:52:09.000000000 +0200
27646 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/fib6_rules.c 2008-10-13 14:54:20.000000000 +0200
27647 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
27648 if (ipv6_dev_get_saddr(net,
27649 ip6_dst_idev(&rt->u.dst)->dev,
27650 &flp->fl6_dst, srcprefs,
27654 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27656 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/inet6_hashtables.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/inet6_hashtables.c
27657 --- linux-2.6.27.14/net/ipv6/inet6_hashtables.c 2008-10-13 14:52:09.000000000 +0200
27658 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/inet6_hashtables.c 2008-10-13 14:54:20.000000000 +0200
27661 #include <linux/module.h>
27662 #include <linux/random.h>
27663 +#include <linux/vs_inet6.h>
27665 #include <net/inet_connection_sock.h>
27666 #include <net/inet_hashtables.h>
27667 @@ -115,6 +116,9 @@ struct sock *inet6_lookup_listener(struc
27668 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27672 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27675 if (sk->sk_bound_dev_if) {
27676 if (sk->sk_bound_dev_if != dif)
27677 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/ip6_output.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/ip6_output.c
27678 --- linux-2.6.27.14/net/ipv6/ip6_output.c 2008-10-13 14:52:09.000000000 +0200
27679 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/ip6_output.c 2008-10-13 14:54:20.000000000 +0200
27680 @@ -937,7 +937,7 @@ static int ip6_dst_lookup_tail(struct so
27681 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27683 sk ? inet6_sk(sk)->srcprefs : 0,
27685 + &fl->fl6_src, sk->sk_nx_info);
27687 goto out_err_release;
27689 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/Kconfig linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/Kconfig
27690 --- linux-2.6.27.14/net/ipv6/Kconfig 2008-10-13 14:52:09.000000000 +0200
27691 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/Kconfig 2008-10-13 14:54:20.000000000 +0200
27694 # IPv6 as module will cause a CRASH if you try to unload it
27696 - tristate "The IPv6 protocol"
27698 + bool "The IPv6 protocol"
27701 This is complemental support for the IP version 6.
27702 You will still be able to do traditional IPv4 networking as well.
27703 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/ndisc.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/ndisc.c
27704 --- linux-2.6.27.14/net/ipv6/ndisc.c 2008-10-13 14:52:09.000000000 +0200
27705 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/ndisc.c 2008-10-13 14:54:20.000000000 +0200
27706 @@ -551,7 +551,7 @@ static void ndisc_send_na(struct net_dev
27708 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27709 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27711 + &tmpaddr, NULL /* FIXME: ? */ ))
27713 src_addr = &tmpaddr;
27715 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/raw.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/raw.c
27716 --- linux-2.6.27.14/net/ipv6/raw.c 2008-10-13 14:52:09.000000000 +0200
27717 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/raw.c 2008-11-21 13:32:00.000000000 +0100
27719 #include <linux/icmpv6.h>
27720 #include <linux/netfilter.h>
27721 #include <linux/netfilter_ipv6.h>
27722 +#include <linux/vs_inet6.h>
27723 #include <linux/skbuff.h>
27724 #include <asm/uaccess.h>
27725 #include <asm/ioctls.h>
27726 @@ -281,6 +282,13 @@ static int rawv6_bind(struct sock *sk, s
27730 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27731 + err = -EADDRNOTAVAIL;
27737 /* ipv4 addr of the socket is invalid. Only the
27738 * unspecified and mapped address have a v4 equivalent.
27740 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/route.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/route.c
27741 --- linux-2.6.27.14/net/ipv6/route.c 2008-10-13 14:52:09.000000000 +0200
27742 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/route.c 2008-10-13 14:54:20.000000000 +0200
27743 @@ -2191,7 +2191,8 @@ static int rt6_fill_node(struct net *net
27744 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27745 struct in6_addr saddr_buf;
27746 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27747 - dst, 0, &saddr_buf) == 0)
27748 + dst, 0, &saddr_buf,
27749 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27750 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27753 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/tcp_ipv6.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/tcp_ipv6.c
27754 --- linux-2.6.27.14/net/ipv6/tcp_ipv6.c 2009-02-03 17:59:55.000000000 +0100
27755 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/tcp_ipv6.c 2009-02-03 17:59:04.000000000 +0100
27758 #include <linux/crypto.h>
27759 #include <linux/scatterlist.h>
27760 +#include <linux/vs_inet6.h>
27762 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27763 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27764 @@ -155,8 +156,15 @@ static int tcp_v6_connect(struct sock *s
27765 * connect() to INADDR_ANY means loopback (BSD'ism).
27768 - if(ipv6_addr_any(&usin->sin6_addr))
27769 - usin->sin6_addr.s6_addr[15] = 0x1;
27770 + if(ipv6_addr_any(&usin->sin6_addr)) {
27771 + struct nx_info *nxi = sk->sk_nx_info;
27773 + if (nxi && nx_info_has_v6(nxi))
27774 + /* FIXME: remap lback? */
27775 + usin->sin6_addr = nxi->v6.ip;
27777 + usin->sin6_addr.s6_addr[15] = 0x1;
27780 addr_type = ipv6_addr_type(&usin->sin6_addr);
27782 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/udp.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/udp.c
27783 --- linux-2.6.27.14/net/ipv6/udp.c 2009-02-03 17:59:55.000000000 +0100
27784 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/udp.c 2009-02-03 17:59:04.000000000 +0100
27787 #include <linux/proc_fs.h>
27788 #include <linux/seq_file.h>
27789 +#include <linux/vs_inet6.h>
27790 #include "udp_impl.h"
27792 int udp_v6_get_port(struct sock *sk, unsigned short snum)
27793 @@ -81,6 +82,10 @@ static struct sock *__udp6_lib_lookup(st
27794 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27798 + /* block non nx_info ips */
27799 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27802 if (!ipv6_addr_any(&np->daddr)) {
27803 if (!ipv6_addr_equal(&np->daddr, saddr))
27804 diff -NurpP --minimal linux-2.6.27.14/net/ipv6/xfrm6_policy.c linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/xfrm6_policy.c
27805 --- linux-2.6.27.14/net/ipv6/xfrm6_policy.c 2008-10-13 14:52:09.000000000 +0200
27806 +++ linux-2.6.27.14-vs2.3.0.36.4/net/ipv6/xfrm6_policy.c 2008-10-13 14:54:20.000000000 +0200
27807 @@ -61,7 +61,7 @@ static int xfrm6_get_saddr(xfrm_address_
27808 dev = ip6_dst_idev(dst)->dev;
27809 ipv6_dev_get_saddr(dev_net(dev), dev,
27810 (struct in6_addr *)&daddr->a6, 0,
27811 - (struct in6_addr *)&saddr->a6);
27812 + (struct in6_addr *)&saddr->a6, NULL);
27816 diff -NurpP --minimal linux-2.6.27.14/net/Kconfig linux-2.6.27.14-vs2.3.0.36.4/net/Kconfig
27817 --- linux-2.6.27.14/net/Kconfig 2008-10-13 14:52:09.000000000 +0200
27818 +++ linux-2.6.27.14-vs2.3.0.36.4/net/Kconfig 2008-11-20 15:21:32.000000000 +0100
27819 @@ -27,7 +27,7 @@ menu "Networking options"
27821 bool "Network namespace support"
27823 - depends on EXPERIMENTAL && !SYSFS && NAMESPACES
27824 + depends on EXPERIMENTAL && NAMESPACES
27826 Allow user space to create what appear to be multiple instances
27827 of the network stack.
27828 diff -NurpP --minimal linux-2.6.27.14/net/netlink/af_netlink.c linux-2.6.27.14-vs2.3.0.36.4/net/netlink/af_netlink.c
27829 --- linux-2.6.27.14/net/netlink/af_netlink.c 2008-10-13 14:52:09.000000000 +0200
27830 +++ linux-2.6.27.14-vs2.3.0.36.4/net/netlink/af_netlink.c 2008-10-13 14:54:20.000000000 +0200
27832 #include <linux/types.h>
27833 #include <linux/audit.h>
27834 #include <linux/mutex.h>
27835 +#include <linux/vs_context.h>
27836 +#include <linux/vs_network.h>
27837 +#include <linux/vs_limit.h>
27839 #include <net/net_namespace.h>
27840 #include <net/sock.h>
27841 @@ -1761,6 +1764,8 @@ static struct sock *netlink_seq_socket_i
27842 sk_for_each(s, node, &hash->table[j]) {
27843 if (sock_net(s) != seq_file_net(seq))
27845 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27849 iter->hash_idx = j;
27850 @@ -1795,7 +1800,8 @@ static void *netlink_seq_next(struct seq
27854 - } while (s && sock_net(s) != seq_file_net(seq));
27855 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27856 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27860 @@ -1807,7 +1813,8 @@ static void *netlink_seq_next(struct seq
27862 for (; j <= hash->mask; j++) {
27863 s = sk_head(&hash->table[j]);
27864 - while (s && sock_net(s) != seq_file_net(seq))
27865 + while (s && (sock_net(s) != seq_file_net(seq) ||
27866 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27870 diff -NurpP --minimal linux-2.6.27.14/net/sctp/ipv6.c linux-2.6.27.14-vs2.3.0.36.4/net/sctp/ipv6.c
27871 --- linux-2.6.27.14/net/sctp/ipv6.c 2008-10-13 14:52:09.000000000 +0200
27872 +++ linux-2.6.27.14-vs2.3.0.36.4/net/sctp/ipv6.c 2008-10-13 14:54:20.000000000 +0200
27873 @@ -323,7 +323,8 @@ static void sctp_v6_get_saddr(struct sct
27874 dst ? ip6_dst_idev(dst)->dev : NULL,
27875 &daddr->v6.sin6_addr,
27876 inet6_sk(&sk->inet.sk)->srcprefs,
27877 - &saddr->v6.sin6_addr);
27878 + &saddr->v6.sin6_addr,
27879 + asoc->base.sk->sk_nx_info);
27880 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
27881 NIP6(saddr->v6.sin6_addr));
27883 diff -NurpP --minimal linux-2.6.27.14/net/socket.c linux-2.6.27.14-vs2.3.0.36.4/net/socket.c
27884 --- linux-2.6.27.14/net/socket.c 2009-02-03 17:59:55.000000000 +0100
27885 +++ linux-2.6.27.14-vs2.3.0.36.4/net/socket.c 2009-02-03 17:59:04.000000000 +0100
27888 #include <net/sock.h>
27889 #include <linux/netfilter.h>
27890 +#include <linux/vs_base.h>
27891 +#include <linux/vs_socket.h>
27892 +#include <linux/vs_inet.h>
27893 +#include <linux/vs_inet6.h>
27895 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
27896 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
27897 @@ -550,7 +554,7 @@ static inline int __sock_sendmsg(struct
27898 struct msghdr *msg, size_t size)
27900 struct sock_iocb *si = kiocb_to_siocb(iocb);
27906 @@ -561,7 +565,22 @@ static inline int __sock_sendmsg(struct
27910 - return sock->ops->sendmsg(iocb, sock, msg, size);
27911 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27914 + vx_sock_send(sock->sk, size);
27916 + vx_sock_fail(sock->sk, size);
27918 + vxdprintk(VXD_CBIT(net, 7),
27919 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27921 + (sock->sk)?sock->sk->sk_nx_info:0,
27922 + (sock->sk)?sock->sk->sk_vx_info:0,
27923 + (sock->sk)?sock->sk->sk_xid:0,
27924 + (sock->sk)?sock->sk->sk_nid:0,
27925 + (unsigned int)size, len);
27929 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
27930 @@ -630,7 +649,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
27931 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27932 struct msghdr *msg, size_t size, int flags)
27936 struct sock_iocb *si = kiocb_to_siocb(iocb);
27939 @@ -643,7 +662,18 @@ static inline int __sock_recvmsg(struct
27943 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27944 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27945 + if ((len >= 0) && sock->sk)
27946 + vx_sock_recv(sock->sk, len);
27947 + vxdprintk(VXD_CBIT(net, 7),
27948 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27950 + (sock->sk)?sock->sk->sk_nx_info:0,
27951 + (sock->sk)?sock->sk->sk_vx_info:0,
27952 + (sock->sk)?sock->sk->sk_xid:0,
27953 + (sock->sk)?sock->sk->sk_nid:0,
27954 + (unsigned int)size, len);
27958 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
27959 @@ -1108,6 +1138,13 @@ static int __sock_create(struct net *net
27960 if (type < 0 || type >= SOCK_MAX)
27963 + if (!nx_check(0, VS_ADMIN)) {
27964 + if (family == PF_INET && !current_nx_info_has_v4())
27965 + return -EAFNOSUPPORT;
27966 + if (family == PF_INET6 && !current_nx_info_has_v6())
27967 + return -EAFNOSUPPORT;
27972 This uglymoron is moved from INET layer to here to avoid
27973 @@ -1240,6 +1277,7 @@ SYSCALL_DEFINE3(socket, int, family, int
27977 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27978 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27981 @@ -1281,10 +1319,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
27982 err = sock_create(family, type, protocol, &sock1);
27985 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27987 err = sock_create(family, type, protocol, &sock2);
27989 goto out_release_1;
27990 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27992 err = sock1->ops->socketpair(sock1, sock2);
27994 diff -NurpP --minimal linux-2.6.27.14/net/sunrpc/auth.c linux-2.6.27.14-vs2.3.0.36.4/net/sunrpc/auth.c
27995 --- linux-2.6.27.14/net/sunrpc/auth.c 2008-07-13 23:51:29.000000000 +0200
27996 +++ linux-2.6.27.14-vs2.3.0.36.4/net/sunrpc/auth.c 2008-10-13 14:54:20.000000000 +0200
27998 #include <linux/hash.h>
27999 #include <linux/sunrpc/clnt.h>
28000 #include <linux/spinlock.h>
28001 +#include <linux/vs_tag.h>
28004 # define RPCDBG_FACILITY RPCDBG_AUTH
28005 @@ -353,6 +354,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28006 struct auth_cred acred = {
28007 .uid = current->fsuid,
28008 .gid = current->fsgid,
28009 + .tag = dx_current_tag(),
28010 .group_info = current->group_info,
28012 struct rpc_cred *ret;
28013 @@ -398,6 +400,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28014 struct auth_cred acred = {
28017 + .tag = dx_current_tag(),
28019 struct rpc_cred *ret;
28021 diff -NurpP --minimal linux-2.6.27.14/net/sunrpc/auth_unix.c linux-2.6.27.14-vs2.3.0.36.4/net/sunrpc/auth_unix.c
28022 --- linux-2.6.27.14/net/sunrpc/auth_unix.c 2008-10-13 14:52:09.000000000 +0200
28023 +++ linux-2.6.27.14-vs2.3.0.36.4/net/sunrpc/auth_unix.c 2008-10-13 14:54:20.000000000 +0200
28024 @@ -11,12 +11,14 @@
28025 #include <linux/module.h>
28026 #include <linux/sunrpc/clnt.h>
28027 #include <linux/sunrpc/auth.h>
28028 +#include <linux/vs_tag.h>
28030 #define NFS_NGROUPS 16
28033 struct rpc_cred uc_base;
28036 gid_t uc_gids[NFS_NGROUPS];
28038 #define uc_uid uc_base.cr_uid
28039 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28040 groups = NFS_NGROUPS;
28042 cred->uc_gid = acred->gid;
28043 + cred->uc_tag = acred->tag;
28044 for (i = 0; i < groups; i++)
28045 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28046 if (i < NFS_NGROUPS)
28047 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28051 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28052 + if (cred->uc_uid != acred->uid ||
28053 + cred->uc_gid != acred->gid ||
28054 + cred->uc_tag != acred->tag)
28057 if (acred->group_info != NULL)
28058 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
28059 struct rpc_clnt *clnt = task->tk_client;
28060 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28061 __be32 *base, *hold;
28065 *p++ = htonl(RPC_AUTH_UNIX);
28067 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
28068 * Copy the UTS nodename captured when the client was created.
28070 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28071 + tag = task->tk_client->cl_tag;
28073 - *p++ = htonl((u32) cred->uc_uid);
28074 - *p++ = htonl((u32) cred->uc_gid);
28075 + *p++ = htonl((u32) TAGINO_UID(tag,
28076 + cred->uc_uid, cred->uc_tag));
28077 + *p++ = htonl((u32) TAGINO_GID(tag,
28078 + cred->uc_gid, cred->uc_tag));
28080 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28081 *p++ = htonl((u32) cred->uc_gids[i]);
28082 diff -NurpP --minimal linux-2.6.27.14/net/sunrpc/clnt.c linux-2.6.27.14-vs2.3.0.36.4/net/sunrpc/clnt.c
28083 --- linux-2.6.27.14/net/sunrpc/clnt.c 2008-10-13 14:52:09.000000000 +0200
28084 +++ linux-2.6.27.14-vs2.3.0.36.4/net/sunrpc/clnt.c 2008-10-13 14:54:20.000000000 +0200
28086 #include <linux/utsname.h>
28087 #include <linux/workqueue.h>
28088 #include <linux/in6.h>
28089 +#include <linux/vs_cvirt.h>
28091 #include <linux/sunrpc/clnt.h>
28092 #include <linux/sunrpc/rpc_pipe_fs.h>
28093 @@ -327,6 +328,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28094 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28095 clnt->cl_chatty = 1;
28097 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28098 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28099 + clnt->cl_tag = 1; */
28102 EXPORT_SYMBOL_GPL(rpc_create);
28103 diff -NurpP --minimal linux-2.6.27.14/net/unix/af_unix.c linux-2.6.27.14-vs2.3.0.36.4/net/unix/af_unix.c
28104 --- linux-2.6.27.14/net/unix/af_unix.c 2009-02-03 17:59:55.000000000 +0100
28105 +++ linux-2.6.27.14-vs2.3.0.36.4/net/unix/af_unix.c 2009-02-03 17:59:04.000000000 +0100
28106 @@ -114,6 +114,8 @@
28107 #include <linux/mount.h>
28108 #include <net/checksum.h>
28109 #include <linux/security.h>
28110 +#include <linux/vs_context.h>
28111 +#include <linux/vs_limit.h>
28113 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28114 static DEFINE_SPINLOCK(unix_table_lock);
28115 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28116 if (!net_eq(sock_net(s), net))
28119 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28121 if (u->addr->len == len &&
28122 !memcmp(u->addr->name, sunname, len))
28124 @@ -2103,6 +2107,8 @@ static struct sock *unix_seq_idx(struct
28125 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28126 if (sock_net(s) != seq_file_net(seq))
28128 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28133 @@ -2128,7 +2134,8 @@ static void *unix_seq_next(struct seq_fi
28134 sk = first_unix_socket(&iter->i);
28136 sk = next_unix_socket(&iter->i, sk);
28137 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28138 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28139 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28140 sk = next_unix_socket(&iter->i, sk);
28143 diff -NurpP --minimal linux-2.6.27.14/net/x25/af_x25.c linux-2.6.27.14-vs2.3.0.36.4/net/x25/af_x25.c
28144 --- linux-2.6.27.14/net/x25/af_x25.c 2008-10-13 14:52:10.000000000 +0200
28145 +++ linux-2.6.27.14-vs2.3.0.36.4/net/x25/af_x25.c 2008-10-13 14:54:20.000000000 +0200
28146 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
28150 - sock_init_data(sock, sk);
28151 + sk->sk_socket = sock;
28152 + sk->sk_type = sock->type;
28153 + sk->sk_sleep = &sock->wait;
28156 x25_init_timers(sk);
28158 diff -NurpP --minimal linux-2.6.27.14/scripts/checksyscalls.sh linux-2.6.27.14-vs2.3.0.36.4/scripts/checksyscalls.sh
28159 --- linux-2.6.27.14/scripts/checksyscalls.sh 2008-07-13 23:51:29.000000000 +0200
28160 +++ linux-2.6.27.14-vs2.3.0.36.4/scripts/checksyscalls.sh 2008-10-13 14:54:20.000000000 +0200
28161 @@ -108,7 +108,6 @@ cat << EOF
28162 #define __IGNORE_afs_syscall
28163 #define __IGNORE_getpmsg
28164 #define __IGNORE_putpmsg
28165 -#define __IGNORE_vserver
28169 diff -NurpP --minimal linux-2.6.27.14/security/commoncap.c linux-2.6.27.14-vs2.3.0.36.4/security/commoncap.c
28170 --- linux-2.6.27.14/security/commoncap.c 2009-02-03 17:59:55.000000000 +0100
28171 +++ linux-2.6.27.14-vs2.3.0.36.4/security/commoncap.c 2009-02-03 17:59:04.000000000 +0100
28172 @@ -26,10 +26,11 @@
28173 #include <linux/sched.h>
28174 #include <linux/prctl.h>
28175 #include <linux/securebits.h>
28176 +#include <linux/vs_context.h>
28178 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28180 - NETLINK_CB(skb).eff_cap = current->cap_effective;
28181 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current->cap_effective);
28185 @@ -50,9 +51,24 @@ EXPORT_SYMBOL(cap_netlink_recv);
28187 int cap_capable (struct task_struct *tsk, int cap)
28189 + struct vx_info *vxi = tsk->vx_info;
28192 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28193 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28194 + cap_raised(tsk->cap_effective, cap),
28195 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28198 + /* special case SETUP */
28199 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28200 + cap_raised(tsk->cap_effective, cap))
28203 /* Derived from include/linux/sched.h:capable. */
28204 - if (cap_raised(tsk->cap_effective, cap))
28205 + if (vx_cap_raised(vxi, tsk->cap_effective, cap))
28211 @@ -696,7 +712,8 @@ void cap_task_reparent_to_init (struct t
28213 int cap_syslog (int type)
28215 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
28216 + if ((type != 3 && type != 10) &&
28217 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28221 diff -NurpP --minimal linux-2.6.27.14/security/selinux/hooks.c linux-2.6.27.14-vs2.3.0.36.4/security/selinux/hooks.c
28222 --- linux-2.6.27.14/security/selinux/hooks.c 2008-10-13 14:52:10.000000000 +0200
28223 +++ linux-2.6.27.14-vs2.3.0.36.4/security/selinux/hooks.c 2008-10-13 14:54:20.000000000 +0200
28225 #include <linux/dccp.h>
28226 #include <linux/quota.h>
28227 #include <linux/un.h> /* for Unix socket types */
28228 -#include <net/af_unix.h> /* for Unix socket types */
28229 #include <linux/parser.h>
28230 #include <linux/nfs_mount.h>
28231 #include <net/ipv6.h>