diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/aio.c | 16 | ||||
-rw-r--r-- | fs/binfmt_aout.c | 32 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 23 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 18 | ||||
-rw-r--r-- | fs/binfmt_flat.c | 12 | ||||
-rw-r--r-- | fs/binfmt_som.c | 12 | ||||
-rw-r--r-- | fs/buffer.c | 1 | ||||
-rw-r--r-- | fs/dlm/lock.c | 12 | ||||
-rw-r--r-- | fs/eventpoll.c | 4 | ||||
-rw-r--r-- | fs/ext4/super.c | 2 | ||||
-rw-r--r-- | fs/gfs2/lock_dlm.c | 10 | ||||
-rw-r--r-- | fs/hugetlbfs/inode.c | 1 | ||||
-rw-r--r-- | fs/jbd2/commit.c | 4 | ||||
-rw-r--r-- | fs/nfs/dir.c | 4 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 44 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 31 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 9 | ||||
-rw-r--r-- | fs/nfs/read.c | 2 | ||||
-rw-r--r-- | fs/nfs/super.c | 8 | ||||
-rw-r--r-- | fs/nfs/write.c | 5 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 3 |
22 files changed, 137 insertions, 117 deletions
@@ -93,9 +93,8 @@ static void aio_free_ring(struct kioctx *ctx) | |||
93 | put_page(info->ring_pages[i]); | 93 | put_page(info->ring_pages[i]); |
94 | 94 | ||
95 | if (info->mmap_size) { | 95 | if (info->mmap_size) { |
96 | down_write(&ctx->mm->mmap_sem); | 96 | BUG_ON(ctx->mm != current->mm); |
97 | do_munmap(ctx->mm, info->mmap_base, info->mmap_size); | 97 | vm_munmap(info->mmap_base, info->mmap_size); |
98 | up_write(&ctx->mm->mmap_sem); | ||
99 | } | 98 | } |
100 | 99 | ||
101 | if (info->ring_pages && info->ring_pages != info->internal_pages) | 100 | if (info->ring_pages && info->ring_pages != info->internal_pages) |
@@ -389,6 +388,17 @@ void exit_aio(struct mm_struct *mm) | |||
389 | "exit_aio:ioctx still alive: %d %d %d\n", | 388 | "exit_aio:ioctx still alive: %d %d %d\n", |
390 | atomic_read(&ctx->users), ctx->dead, | 389 | atomic_read(&ctx->users), ctx->dead, |
391 | ctx->reqs_active); | 390 | ctx->reqs_active); |
391 | /* | ||
392 | * We don't need to bother with munmap() here - | ||
393 | * exit_mmap(mm) is coming and it'll unmap everything. | ||
394 | * Since aio_free_ring() uses non-zero ->mmap_size | ||
395 | * as indicator that it needs to unmap the area, | ||
396 | * just set it to 0; aio_free_ring() is the only | ||
397 | * place that uses ->mmap_size, so it's safe. | ||
398 | * That way we get all munmap done to current->mm - | ||
399 | * all other callers have ctx->mm == current->mm. | ||
400 | */ | ||
401 | ctx->ring_info.mmap_size = 0; | ||
392 | put_ioctx(ctx); | 402 | put_ioctx(ctx); |
393 | } | 403 | } |
394 | } | 404 | } |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 2eb12f13593d..d146e181d10d 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -50,9 +50,7 @@ static int set_brk(unsigned long start, unsigned long end) | |||
50 | end = PAGE_ALIGN(end); | 50 | end = PAGE_ALIGN(end); |
51 | if (end > start) { | 51 | if (end > start) { |
52 | unsigned long addr; | 52 | unsigned long addr; |
53 | down_write(¤t->mm->mmap_sem); | 53 | addr = vm_brk(start, end - start); |
54 | addr = do_brk(start, end - start); | ||
55 | up_write(¤t->mm->mmap_sem); | ||
56 | if (BAD_ADDR(addr)) | 54 | if (BAD_ADDR(addr)) |
57 | return addr; | 55 | return addr; |
58 | } | 56 | } |
@@ -280,9 +278,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
280 | pos = 32; | 278 | pos = 32; |
281 | map_size = ex.a_text+ex.a_data; | 279 | map_size = ex.a_text+ex.a_data; |
282 | #endif | 280 | #endif |
283 | down_write(¤t->mm->mmap_sem); | 281 | error = vm_brk(text_addr & PAGE_MASK, map_size); |
284 | error = do_brk(text_addr & PAGE_MASK, map_size); | ||
285 | up_write(¤t->mm->mmap_sem); | ||
286 | if (error != (text_addr & PAGE_MASK)) { | 282 | if (error != (text_addr & PAGE_MASK)) { |
287 | send_sig(SIGKILL, current, 0); | 283 | send_sig(SIGKILL, current, 0); |
288 | return error; | 284 | return error; |
@@ -313,9 +309,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
313 | 309 | ||
314 | if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { | 310 | if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { |
315 | loff_t pos = fd_offset; | 311 | loff_t pos = fd_offset; |
316 | down_write(¤t->mm->mmap_sem); | 312 | vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); |
317 | do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); | ||
318 | up_write(¤t->mm->mmap_sem); | ||
319 | bprm->file->f_op->read(bprm->file, | 313 | bprm->file->f_op->read(bprm->file, |
320 | (char __user *)N_TXTADDR(ex), | 314 | (char __user *)N_TXTADDR(ex), |
321 | ex.a_text+ex.a_data, &pos); | 315 | ex.a_text+ex.a_data, &pos); |
@@ -325,24 +319,20 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
325 | goto beyond_if; | 319 | goto beyond_if; |
326 | } | 320 | } |
327 | 321 | ||
328 | down_write(¤t->mm->mmap_sem); | 322 | error = vm_mmap(bprm->file, N_TXTADDR(ex), ex.a_text, |
329 | error = do_mmap(bprm->file, N_TXTADDR(ex), ex.a_text, | ||
330 | PROT_READ | PROT_EXEC, | 323 | PROT_READ | PROT_EXEC, |
331 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE, | 324 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE, |
332 | fd_offset); | 325 | fd_offset); |
333 | up_write(¤t->mm->mmap_sem); | ||
334 | 326 | ||
335 | if (error != N_TXTADDR(ex)) { | 327 | if (error != N_TXTADDR(ex)) { |
336 | send_sig(SIGKILL, current, 0); | 328 | send_sig(SIGKILL, current, 0); |
337 | return error; | 329 | return error; |
338 | } | 330 | } |
339 | 331 | ||
340 | down_write(¤t->mm->mmap_sem); | 332 | error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data, |
341 | error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data, | ||
342 | PROT_READ | PROT_WRITE | PROT_EXEC, | 333 | PROT_READ | PROT_WRITE | PROT_EXEC, |
343 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE, | 334 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE, |
344 | fd_offset + ex.a_text); | 335 | fd_offset + ex.a_text); |
345 | up_write(¤t->mm->mmap_sem); | ||
346 | if (error != N_DATADDR(ex)) { | 336 | if (error != N_DATADDR(ex)) { |
347 | send_sig(SIGKILL, current, 0); | 337 | send_sig(SIGKILL, current, 0); |
348 | return error; | 338 | return error; |
@@ -412,9 +402,7 @@ static int load_aout_library(struct file *file) | |||
412 | "N_TXTOFF is not page aligned. Please convert library: %s\n", | 402 | "N_TXTOFF is not page aligned. Please convert library: %s\n", |
413 | file->f_path.dentry->d_name.name); | 403 | file->f_path.dentry->d_name.name); |
414 | } | 404 | } |
415 | down_write(¤t->mm->mmap_sem); | 405 | vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); |
416 | do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); | ||
417 | up_write(¤t->mm->mmap_sem); | ||
418 | 406 | ||
419 | file->f_op->read(file, (char __user *)start_addr, | 407 | file->f_op->read(file, (char __user *)start_addr, |
420 | ex.a_text + ex.a_data, &pos); | 408 | ex.a_text + ex.a_data, &pos); |
@@ -425,12 +413,10 @@ static int load_aout_library(struct file *file) | |||
425 | goto out; | 413 | goto out; |
426 | } | 414 | } |
427 | /* Now use mmap to map the library into memory. */ | 415 | /* Now use mmap to map the library into memory. */ |
428 | down_write(¤t->mm->mmap_sem); | 416 | error = vm_mmap(file, start_addr, ex.a_text + ex.a_data, |
429 | error = do_mmap(file, start_addr, ex.a_text + ex.a_data, | ||
430 | PROT_READ | PROT_WRITE | PROT_EXEC, | 417 | PROT_READ | PROT_WRITE | PROT_EXEC, |
431 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, | 418 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, |
432 | N_TXTOFF(ex)); | 419 | N_TXTOFF(ex)); |
433 | up_write(¤t->mm->mmap_sem); | ||
434 | retval = error; | 420 | retval = error; |
435 | if (error != start_addr) | 421 | if (error != start_addr) |
436 | goto out; | 422 | goto out; |
@@ -438,9 +424,7 @@ static int load_aout_library(struct file *file) | |||
438 | len = PAGE_ALIGN(ex.a_text + ex.a_data); | 424 | len = PAGE_ALIGN(ex.a_text + ex.a_data); |
439 | bss = ex.a_text + ex.a_data + ex.a_bss; | 425 | bss = ex.a_text + ex.a_data + ex.a_bss; |
440 | if (bss > len) { | 426 | if (bss > len) { |
441 | down_write(¤t->mm->mmap_sem); | 427 | error = vm_brk(start_addr + len, bss - len); |
442 | error = do_brk(start_addr + len, bss - len); | ||
443 | up_write(¤t->mm->mmap_sem); | ||
444 | retval = error; | 428 | retval = error; |
445 | if (error != start_addr + len) | 429 | if (error != start_addr + len) |
446 | goto out; | 430 | goto out; |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 48ffb3dc610a..16f735417072 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -82,9 +82,7 @@ static int set_brk(unsigned long start, unsigned long end) | |||
82 | end = ELF_PAGEALIGN(end); | 82 | end = ELF_PAGEALIGN(end); |
83 | if (end > start) { | 83 | if (end > start) { |
84 | unsigned long addr; | 84 | unsigned long addr; |
85 | down_write(¤t->mm->mmap_sem); | 85 | addr = vm_brk(start, end - start); |
86 | addr = do_brk(start, end - start); | ||
87 | up_write(¤t->mm->mmap_sem); | ||
88 | if (BAD_ADDR(addr)) | 86 | if (BAD_ADDR(addr)) |
89 | return addr; | 87 | return addr; |
90 | } | 88 | } |
@@ -514,9 +512,7 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex, | |||
514 | elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1); | 512 | elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1); |
515 | 513 | ||
516 | /* Map the last of the bss segment */ | 514 | /* Map the last of the bss segment */ |
517 | down_write(¤t->mm->mmap_sem); | 515 | error = vm_brk(elf_bss, last_bss - elf_bss); |
518 | error = do_brk(elf_bss, last_bss - elf_bss); | ||
519 | up_write(¤t->mm->mmap_sem); | ||
520 | if (BAD_ADDR(error)) | 516 | if (BAD_ADDR(error)) |
521 | goto out_close; | 517 | goto out_close; |
522 | } | 518 | } |
@@ -962,10 +958,8 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
962 | and some applications "depend" upon this behavior. | 958 | and some applications "depend" upon this behavior. |
963 | Since we do not have the power to recompile these, we | 959 | Since we do not have the power to recompile these, we |
964 | emulate the SVr4 behavior. Sigh. */ | 960 | emulate the SVr4 behavior. Sigh. */ |
965 | down_write(¤t->mm->mmap_sem); | 961 | error = vm_mmap(NULL, 0, PAGE_SIZE, PROT_READ | PROT_EXEC, |
966 | error = do_mmap(NULL, 0, PAGE_SIZE, PROT_READ | PROT_EXEC, | ||
967 | MAP_FIXED | MAP_PRIVATE, 0); | 962 | MAP_FIXED | MAP_PRIVATE, 0); |
968 | up_write(¤t->mm->mmap_sem); | ||
969 | } | 963 | } |
970 | 964 | ||
971 | #ifdef ELF_PLAT_INIT | 965 | #ifdef ELF_PLAT_INIT |
@@ -1050,8 +1044,7 @@ static int load_elf_library(struct file *file) | |||
1050 | eppnt++; | 1044 | eppnt++; |
1051 | 1045 | ||
1052 | /* Now use mmap to map the library into memory. */ | 1046 | /* Now use mmap to map the library into memory. */ |
1053 | down_write(¤t->mm->mmap_sem); | 1047 | error = vm_mmap(file, |
1054 | error = do_mmap(file, | ||
1055 | ELF_PAGESTART(eppnt->p_vaddr), | 1048 | ELF_PAGESTART(eppnt->p_vaddr), |
1056 | (eppnt->p_filesz + | 1049 | (eppnt->p_filesz + |
1057 | ELF_PAGEOFFSET(eppnt->p_vaddr)), | 1050 | ELF_PAGEOFFSET(eppnt->p_vaddr)), |
@@ -1059,7 +1052,6 @@ static int load_elf_library(struct file *file) | |||
1059 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, | 1052 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, |
1060 | (eppnt->p_offset - | 1053 | (eppnt->p_offset - |
1061 | ELF_PAGEOFFSET(eppnt->p_vaddr))); | 1054 | ELF_PAGEOFFSET(eppnt->p_vaddr))); |
1062 | up_write(¤t->mm->mmap_sem); | ||
1063 | if (error != ELF_PAGESTART(eppnt->p_vaddr)) | 1055 | if (error != ELF_PAGESTART(eppnt->p_vaddr)) |
1064 | goto out_free_ph; | 1056 | goto out_free_ph; |
1065 | 1057 | ||
@@ -1072,11 +1064,8 @@ static int load_elf_library(struct file *file) | |||
1072 | len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + | 1064 | len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + |
1073 | ELF_MIN_ALIGN - 1); | 1065 | ELF_MIN_ALIGN - 1); |
1074 | bss = eppnt->p_memsz + eppnt->p_vaddr; | 1066 | bss = eppnt->p_memsz + eppnt->p_vaddr; |
1075 | if (bss > len) { | 1067 | if (bss > len) |
1076 | down_write(¤t->mm->mmap_sem); | 1068 | vm_brk(len, bss - len); |
1077 | do_brk(len, bss - len); | ||
1078 | up_write(¤t->mm->mmap_sem); | ||
1079 | } | ||
1080 | error = 0; | 1069 | error = 0; |
1081 | 1070 | ||
1082 | out_free_ph: | 1071 | out_free_ph: |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 9bd5612a8224..d390a0fffc65 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -390,21 +390,17 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, | |||
390 | (executable_stack == EXSTACK_DEFAULT && VM_STACK_FLAGS & VM_EXEC)) | 390 | (executable_stack == EXSTACK_DEFAULT && VM_STACK_FLAGS & VM_EXEC)) |
391 | stack_prot |= PROT_EXEC; | 391 | stack_prot |= PROT_EXEC; |
392 | 392 | ||
393 | down_write(¤t->mm->mmap_sem); | 393 | current->mm->start_brk = vm_mmap(NULL, 0, stack_size, stack_prot, |
394 | current->mm->start_brk = do_mmap(NULL, 0, stack_size, stack_prot, | ||
395 | MAP_PRIVATE | MAP_ANONYMOUS | | 394 | MAP_PRIVATE | MAP_ANONYMOUS | |
396 | MAP_UNINITIALIZED | MAP_GROWSDOWN, | 395 | MAP_UNINITIALIZED | MAP_GROWSDOWN, |
397 | 0); | 396 | 0); |
398 | 397 | ||
399 | if (IS_ERR_VALUE(current->mm->start_brk)) { | 398 | if (IS_ERR_VALUE(current->mm->start_brk)) { |
400 | up_write(¤t->mm->mmap_sem); | ||
401 | retval = current->mm->start_brk; | 399 | retval = current->mm->start_brk; |
402 | current->mm->start_brk = 0; | 400 | current->mm->start_brk = 0; |
403 | goto error_kill; | 401 | goto error_kill; |
404 | } | 402 | } |
405 | 403 | ||
406 | up_write(¤t->mm->mmap_sem); | ||
407 | |||
408 | current->mm->brk = current->mm->start_brk; | 404 | current->mm->brk = current->mm->start_brk; |
409 | current->mm->context.end_brk = current->mm->start_brk; | 405 | current->mm->context.end_brk = current->mm->start_brk; |
410 | current->mm->context.end_brk += | 406 | current->mm->context.end_brk += |
@@ -955,10 +951,8 @@ static int elf_fdpic_map_file_constdisp_on_uclinux( | |||
955 | if (params->flags & ELF_FDPIC_FLAG_EXECUTABLE) | 951 | if (params->flags & ELF_FDPIC_FLAG_EXECUTABLE) |
956 | mflags |= MAP_EXECUTABLE; | 952 | mflags |= MAP_EXECUTABLE; |
957 | 953 | ||
958 | down_write(&mm->mmap_sem); | 954 | maddr = vm_mmap(NULL, load_addr, top - base, |
959 | maddr = do_mmap(NULL, load_addr, top - base, | ||
960 | PROT_READ | PROT_WRITE | PROT_EXEC, mflags, 0); | 955 | PROT_READ | PROT_WRITE | PROT_EXEC, mflags, 0); |
961 | up_write(&mm->mmap_sem); | ||
962 | if (IS_ERR_VALUE(maddr)) | 956 | if (IS_ERR_VALUE(maddr)) |
963 | return (int) maddr; | 957 | return (int) maddr; |
964 | 958 | ||
@@ -1096,10 +1090,8 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, | |||
1096 | 1090 | ||
1097 | /* create the mapping */ | 1091 | /* create the mapping */ |
1098 | disp = phdr->p_vaddr & ~PAGE_MASK; | 1092 | disp = phdr->p_vaddr & ~PAGE_MASK; |
1099 | down_write(&mm->mmap_sem); | 1093 | maddr = vm_mmap(file, maddr, phdr->p_memsz + disp, prot, flags, |
1100 | maddr = do_mmap(file, maddr, phdr->p_memsz + disp, prot, flags, | ||
1101 | phdr->p_offset - disp); | 1094 | phdr->p_offset - disp); |
1102 | up_write(&mm->mmap_sem); | ||
1103 | 1095 | ||
1104 | kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx", | 1096 | kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx", |
1105 | loop, phdr->p_memsz + disp, prot, flags, | 1097 | loop, phdr->p_memsz + disp, prot, flags, |
@@ -1143,10 +1135,8 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, | |||
1143 | unsigned long xmaddr; | 1135 | unsigned long xmaddr; |
1144 | 1136 | ||
1145 | flags |= MAP_FIXED | MAP_ANONYMOUS; | 1137 | flags |= MAP_FIXED | MAP_ANONYMOUS; |
1146 | down_write(&mm->mmap_sem); | 1138 | xmaddr = vm_mmap(NULL, xaddr, excess - excess1, |
1147 | xmaddr = do_mmap(NULL, xaddr, excess - excess1, | ||
1148 | prot, flags, 0); | 1139 | prot, flags, 0); |
1149 | up_write(&mm->mmap_sem); | ||
1150 | 1140 | ||
1151 | kdebug("mmap[%d] <anon>" | 1141 | kdebug("mmap[%d] <anon>" |
1152 | " ad=%lx sz=%lx pr=%x fl=%x of=0 --> %08lx", | 1142 | " ad=%lx sz=%lx pr=%x fl=%x of=0 --> %08lx", |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 024d20ee3ca3..6b2daf99fab8 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -542,10 +542,8 @@ static int load_flat_file(struct linux_binprm * bprm, | |||
542 | */ | 542 | */ |
543 | DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n"); | 543 | DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n"); |
544 | 544 | ||
545 | down_write(¤t->mm->mmap_sem); | 545 | textpos = vm_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, |
546 | textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, | ||
547 | MAP_PRIVATE|MAP_EXECUTABLE, 0); | 546 | MAP_PRIVATE|MAP_EXECUTABLE, 0); |
548 | up_write(¤t->mm->mmap_sem); | ||
549 | if (!textpos || IS_ERR_VALUE(textpos)) { | 547 | if (!textpos || IS_ERR_VALUE(textpos)) { |
550 | if (!textpos) | 548 | if (!textpos) |
551 | textpos = (unsigned long) -ENOMEM; | 549 | textpos = (unsigned long) -ENOMEM; |
@@ -556,10 +554,8 @@ static int load_flat_file(struct linux_binprm * bprm, | |||
556 | 554 | ||
557 | len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long); | 555 | len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long); |
558 | len = PAGE_ALIGN(len); | 556 | len = PAGE_ALIGN(len); |
559 | down_write(¤t->mm->mmap_sem); | 557 | realdatastart = vm_mmap(0, 0, len, |
560 | realdatastart = do_mmap(0, 0, len, | ||
561 | PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); | 558 | PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); |
562 | up_write(¤t->mm->mmap_sem); | ||
563 | 559 | ||
564 | if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) { | 560 | if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) { |
565 | if (!realdatastart) | 561 | if (!realdatastart) |
@@ -603,10 +599,8 @@ static int load_flat_file(struct linux_binprm * bprm, | |||
603 | 599 | ||
604 | len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long); | 600 | len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long); |
605 | len = PAGE_ALIGN(len); | 601 | len = PAGE_ALIGN(len); |
606 | down_write(¤t->mm->mmap_sem); | 602 | textpos = vm_mmap(0, 0, len, |
607 | textpos = do_mmap(0, 0, len, | ||
608 | PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); | 603 | PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); |
609 | up_write(¤t->mm->mmap_sem); | ||
610 | 604 | ||
611 | if (!textpos || IS_ERR_VALUE(textpos)) { | 605 | if (!textpos || IS_ERR_VALUE(textpos)) { |
612 | if (!textpos) | 606 | if (!textpos) |
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c index e4fc746629a7..4517aaff61b4 100644 --- a/fs/binfmt_som.c +++ b/fs/binfmt_som.c | |||
@@ -147,10 +147,8 @@ static int map_som_binary(struct file *file, | |||
147 | code_size = SOM_PAGEALIGN(hpuxhdr->exec_tsize); | 147 | code_size = SOM_PAGEALIGN(hpuxhdr->exec_tsize); |
148 | current->mm->start_code = code_start; | 148 | current->mm->start_code = code_start; |
149 | current->mm->end_code = code_start + code_size; | 149 | current->mm->end_code = code_start + code_size; |
150 | down_write(¤t->mm->mmap_sem); | 150 | retval = vm_mmap(file, code_start, code_size, prot, |
151 | retval = do_mmap(file, code_start, code_size, prot, | ||
152 | flags, SOM_PAGESTART(hpuxhdr->exec_tfile)); | 151 | flags, SOM_PAGESTART(hpuxhdr->exec_tfile)); |
153 | up_write(¤t->mm->mmap_sem); | ||
154 | if (retval < 0 && retval > -1024) | 152 | if (retval < 0 && retval > -1024) |
155 | goto out; | 153 | goto out; |
156 | 154 | ||
@@ -158,20 +156,16 @@ static int map_som_binary(struct file *file, | |||
158 | data_size = SOM_PAGEALIGN(hpuxhdr->exec_dsize); | 156 | data_size = SOM_PAGEALIGN(hpuxhdr->exec_dsize); |
159 | current->mm->start_data = data_start; | 157 | current->mm->start_data = data_start; |
160 | current->mm->end_data = bss_start = data_start + data_size; | 158 | current->mm->end_data = bss_start = data_start + data_size; |
161 | down_write(¤t->mm->mmap_sem); | 159 | retval = vm_mmap(file, data_start, data_size, |
162 | retval = do_mmap(file, data_start, data_size, | ||
163 | prot | PROT_WRITE, flags, | 160 | prot | PROT_WRITE, flags, |
164 | SOM_PAGESTART(hpuxhdr->exec_dfile)); | 161 | SOM_PAGESTART(hpuxhdr->exec_dfile)); |
165 | up_write(¤t->mm->mmap_sem); | ||
166 | if (retval < 0 && retval > -1024) | 162 | if (retval < 0 && retval > -1024) |
167 | goto out; | 163 | goto out; |
168 | 164 | ||
169 | som_brk = bss_start + SOM_PAGEALIGN(hpuxhdr->exec_bsize); | 165 | som_brk = bss_start + SOM_PAGEALIGN(hpuxhdr->exec_bsize); |
170 | current->mm->start_brk = current->mm->brk = som_brk; | 166 | current->mm->start_brk = current->mm->brk = som_brk; |
171 | down_write(¤t->mm->mmap_sem); | 167 | retval = vm_mmap(NULL, bss_start, som_brk - bss_start, |
172 | retval = do_mmap(NULL, bss_start, som_brk - bss_start, | ||
173 | prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, 0); | 168 | prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, 0); |
174 | up_write(¤t->mm->mmap_sem); | ||
175 | if (retval > 0 || retval < -1024) | 169 | if (retval > 0 || retval < -1024) |
176 | retval = 0; | 170 | retval = 0; |
177 | out: | 171 | out: |
diff --git a/fs/buffer.c b/fs/buffer.c index 36d66653b931..351e18ea2e53 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -985,7 +985,6 @@ grow_dev_page(struct block_device *bdev, sector_t block, | |||
985 | return page; | 985 | return page; |
986 | 986 | ||
987 | failed: | 987 | failed: |
988 | BUG(); | ||
989 | unlock_page(page); | 988 | unlock_page(page); |
990 | page_cache_release(page); | 989 | page_cache_release(page); |
991 | return NULL; | 990 | return NULL; |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index fa5c07d51dcc..4c58d4a3adc4 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -1737,6 +1737,18 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now) | |||
1737 | return 1; | 1737 | return 1; |
1738 | 1738 | ||
1739 | /* | 1739 | /* |
1740 | * Even if the convert is compat with all granted locks, | ||
1741 | * QUECVT forces it behind other locks on the convert queue. | ||
1742 | */ | ||
1743 | |||
1744 | if (now && conv && (lkb->lkb_exflags & DLM_LKF_QUECVT)) { | ||
1745 | if (list_empty(&r->res_convertqueue)) | ||
1746 | return 1; | ||
1747 | else | ||
1748 | goto out; | ||
1749 | } | ||
1750 | |||
1751 | /* | ||
1740 | * The NOORDER flag is set to avoid the standard vms rules on grant | 1752 | * The NOORDER flag is set to avoid the standard vms rules on grant |
1741 | * order. | 1753 | * order. |
1742 | */ | 1754 | */ |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 739b0985b398..c0b3c70ee87a 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -1663,8 +1663,10 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, | |||
1663 | if (op == EPOLL_CTL_ADD) { | 1663 | if (op == EPOLL_CTL_ADD) { |
1664 | if (is_file_epoll(tfile)) { | 1664 | if (is_file_epoll(tfile)) { |
1665 | error = -ELOOP; | 1665 | error = -ELOOP; |
1666 | if (ep_loop_check(ep, tfile) != 0) | 1666 | if (ep_loop_check(ep, tfile) != 0) { |
1667 | clear_tfile_check_list(); | ||
1667 | goto error_tgt_fput; | 1668 | goto error_tgt_fput; |
1669 | } | ||
1668 | } else | 1670 | } else |
1669 | list_add(&tfile->f_tfile_llink, &tfile_check_list); | 1671 | list_add(&tfile->f_tfile_llink, &tfile_check_list); |
1670 | } | 1672 | } |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 6da193564e43..e1fb1d5de58e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1597,7 +1597,9 @@ static int parse_options(char *options, struct super_block *sb, | |||
1597 | unsigned int *journal_ioprio, | 1597 | unsigned int *journal_ioprio, |
1598 | int is_remount) | 1598 | int is_remount) |
1599 | { | 1599 | { |
1600 | #ifdef CONFIG_QUOTA | ||
1600 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 1601 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1602 | #endif | ||
1601 | char *p; | 1603 | char *p; |
1602 | substring_t args[MAX_OPT_ARGS]; | 1604 | substring_t args[MAX_OPT_ARGS]; |
1603 | int token; | 1605 | int token; |
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c index f8411bd1b805..5f5e70e047dc 100644 --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c | |||
@@ -200,10 +200,11 @@ static int make_mode(const unsigned int lmstate) | |||
200 | return -1; | 200 | return -1; |
201 | } | 201 | } |
202 | 202 | ||
203 | static u32 make_flags(const u32 lkid, const unsigned int gfs_flags, | 203 | static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags, |
204 | const int req) | 204 | const int req) |
205 | { | 205 | { |
206 | u32 lkf = DLM_LKF_VALBLK; | 206 | u32 lkf = DLM_LKF_VALBLK; |
207 | u32 lkid = gl->gl_lksb.sb_lkid; | ||
207 | 208 | ||
208 | if (gfs_flags & LM_FLAG_TRY) | 209 | if (gfs_flags & LM_FLAG_TRY) |
209 | lkf |= DLM_LKF_NOQUEUE; | 210 | lkf |= DLM_LKF_NOQUEUE; |
@@ -227,8 +228,11 @@ static u32 make_flags(const u32 lkid, const unsigned int gfs_flags, | |||
227 | BUG(); | 228 | BUG(); |
228 | } | 229 | } |
229 | 230 | ||
230 | if (lkid != 0) | 231 | if (lkid != 0) { |
231 | lkf |= DLM_LKF_CONVERT; | 232 | lkf |= DLM_LKF_CONVERT; |
233 | if (test_bit(GLF_BLOCKING, &gl->gl_flags)) | ||
234 | lkf |= DLM_LKF_QUECVT; | ||
235 | } | ||
232 | 236 | ||
233 | return lkf; | 237 | return lkf; |
234 | } | 238 | } |
@@ -250,7 +254,7 @@ static int gdlm_lock(struct gfs2_glock *gl, unsigned int req_state, | |||
250 | char strname[GDLM_STRNAME_BYTES] = ""; | 254 | char strname[GDLM_STRNAME_BYTES] = ""; |
251 | 255 | ||
252 | req = make_mode(req_state); | 256 | req = make_mode(req_state); |
253 | lkf = make_flags(gl->gl_lksb.sb_lkid, flags, req); | 257 | lkf = make_flags(gl, flags, req); |
254 | gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT); | 258 | gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT); |
255 | gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT); | 259 | gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT); |
256 | if (gl->gl_lksb.sb_lkid) { | 260 | if (gl->gl_lksb.sb_lkid) { |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 28cf06e4ec84..001ef01d2fe2 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -485,6 +485,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb, | |||
485 | inode->i_fop = &simple_dir_operations; | 485 | inode->i_fop = &simple_dir_operations; |
486 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 486 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
487 | inc_nlink(inode); | 487 | inc_nlink(inode); |
488 | lockdep_annotate_inode_mutex_key(inode); | ||
488 | } | 489 | } |
489 | return inode; | 490 | return inode; |
490 | } | 491 | } |
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 806525a7269c..840f70f50792 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -723,7 +723,7 @@ start_journal_io: | |||
723 | if (commit_transaction->t_need_data_flush && | 723 | if (commit_transaction->t_need_data_flush && |
724 | (journal->j_fs_dev != journal->j_dev) && | 724 | (journal->j_fs_dev != journal->j_dev) && |
725 | (journal->j_flags & JBD2_BARRIER)) | 725 | (journal->j_flags & JBD2_BARRIER)) |
726 | blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL); | 726 | blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL); |
727 | 727 | ||
728 | /* Done it all: now write the commit record asynchronously. */ | 728 | /* Done it all: now write the commit record asynchronously. */ |
729 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, | 729 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, |
@@ -859,7 +859,7 @@ wait_for_iobuf: | |||
859 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, | 859 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, |
860 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) && | 860 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) && |
861 | journal->j_flags & JBD2_BARRIER) { | 861 | journal->j_flags & JBD2_BARRIER) { |
862 | blkdev_issue_flush(journal->j_dev, GFP_KERNEL, NULL); | 862 | blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL); |
863 | } | 863 | } |
864 | 864 | ||
865 | if (err) | 865 | if (err) |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 4aaf0316d76a..8789210c6905 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1429,7 +1429,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | open_flags = nd->intent.open.flags; | 1431 | open_flags = nd->intent.open.flags; |
1432 | attr.ia_valid = 0; | 1432 | attr.ia_valid = ATTR_OPEN; |
1433 | 1433 | ||
1434 | ctx = create_nfs_open_context(dentry, open_flags); | 1434 | ctx = create_nfs_open_context(dentry, open_flags); |
1435 | res = ERR_CAST(ctx); | 1435 | res = ERR_CAST(ctx); |
@@ -1536,7 +1536,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1536 | if (IS_ERR(ctx)) | 1536 | if (IS_ERR(ctx)) |
1537 | goto out; | 1537 | goto out; |
1538 | 1538 | ||
1539 | attr.ia_valid = 0; | 1539 | attr.ia_valid = ATTR_OPEN; |
1540 | if (openflags & O_TRUNC) { | 1540 | if (openflags & O_TRUNC) { |
1541 | attr.ia_valid |= ATTR_SIZE; | 1541 | attr.ia_valid |= ATTR_SIZE; |
1542 | attr.ia_size = 0; | 1542 | attr.ia_size = 0; |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 97ecc863dd76..b6db9e33fb7b 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -59,6 +59,7 @@ struct nfs_unique_id { | |||
59 | 59 | ||
60 | #define NFS_SEQID_CONFIRMED 1 | 60 | #define NFS_SEQID_CONFIRMED 1 |
61 | struct nfs_seqid_counter { | 61 | struct nfs_seqid_counter { |
62 | ktime_t create_time; | ||
62 | int owner_id; | 63 | int owner_id; |
63 | int flags; | 64 | int flags; |
64 | u32 counter; | 65 | u32 counter; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index f82bde005a82..60d5f4c26dda 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -838,7 +838,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, | |||
838 | p->o_arg.open_flags = flags; | 838 | p->o_arg.open_flags = flags; |
839 | p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); | 839 | p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); |
840 | p->o_arg.clientid = server->nfs_client->cl_clientid; | 840 | p->o_arg.clientid = server->nfs_client->cl_clientid; |
841 | p->o_arg.id = sp->so_seqid.owner_id; | 841 | p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time); |
842 | p->o_arg.id.uniquifier = sp->so_seqid.owner_id; | ||
842 | p->o_arg.name = &dentry->d_name; | 843 | p->o_arg.name = &dentry->d_name; |
843 | p->o_arg.server = server; | 844 | p->o_arg.server = server; |
844 | p->o_arg.bitmask = server->attr_bitmask; | 845 | p->o_arg.bitmask = server->attr_bitmask; |
@@ -1466,8 +1467,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) | |||
1466 | goto unlock_no_action; | 1467 | goto unlock_no_action; |
1467 | rcu_read_unlock(); | 1468 | rcu_read_unlock(); |
1468 | } | 1469 | } |
1469 | /* Update sequence id. */ | 1470 | /* Update client id. */ |
1470 | data->o_arg.id = sp->so_seqid.owner_id; | ||
1471 | data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid; | 1471 | data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid; |
1472 | if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) { | 1472 | if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) { |
1473 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; | 1473 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; |
@@ -1954,10 +1954,19 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, | |||
1954 | }; | 1954 | }; |
1955 | int err; | 1955 | int err; |
1956 | do { | 1956 | do { |
1957 | err = nfs4_handle_exception(server, | 1957 | err = _nfs4_do_setattr(inode, cred, fattr, sattr, state); |
1958 | _nfs4_do_setattr(inode, cred, fattr, sattr, state), | 1958 | switch (err) { |
1959 | &exception); | 1959 | case -NFS4ERR_OPENMODE: |
1960 | if (state && !(state->state & FMODE_WRITE)) { | ||
1961 | err = -EBADF; | ||
1962 | if (sattr->ia_valid & ATTR_OPEN) | ||
1963 | err = -EACCES; | ||
1964 | goto out; | ||
1965 | } | ||
1966 | } | ||
1967 | err = nfs4_handle_exception(server, err, &exception); | ||
1960 | } while (exception.retry); | 1968 | } while (exception.retry); |
1969 | out: | ||
1961 | return err; | 1970 | return err; |
1962 | } | 1971 | } |
1963 | 1972 | ||
@@ -4558,7 +4567,9 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f | |||
4558 | static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) | 4567 | static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) |
4559 | { | 4568 | { |
4560 | struct nfs_server *server = NFS_SERVER(state->inode); | 4569 | struct nfs_server *server = NFS_SERVER(state->inode); |
4561 | struct nfs4_exception exception = { }; | 4570 | struct nfs4_exception exception = { |
4571 | .inode = state->inode, | ||
4572 | }; | ||
4562 | int err; | 4573 | int err; |
4563 | 4574 | ||
4564 | do { | 4575 | do { |
@@ -4576,7 +4587,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request | |||
4576 | static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) | 4587 | static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) |
4577 | { | 4588 | { |
4578 | struct nfs_server *server = NFS_SERVER(state->inode); | 4589 | struct nfs_server *server = NFS_SERVER(state->inode); |
4579 | struct nfs4_exception exception = { }; | 4590 | struct nfs4_exception exception = { |
4591 | .inode = state->inode, | ||
4592 | }; | ||
4580 | int err; | 4593 | int err; |
4581 | 4594 | ||
4582 | err = nfs4_set_lock_state(state, request); | 4595 | err = nfs4_set_lock_state(state, request); |
@@ -4676,6 +4689,7 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock * | |||
4676 | { | 4689 | { |
4677 | struct nfs4_exception exception = { | 4690 | struct nfs4_exception exception = { |
4678 | .state = state, | 4691 | .state = state, |
4692 | .inode = state->inode, | ||
4679 | }; | 4693 | }; |
4680 | int err; | 4694 | int err; |
4681 | 4695 | ||
@@ -4721,6 +4735,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) | |||
4721 | 4735 | ||
4722 | if (state == NULL) | 4736 | if (state == NULL) |
4723 | return -ENOLCK; | 4737 | return -ENOLCK; |
4738 | /* | ||
4739 | * Don't rely on the VFS having checked the file open mode, | ||
4740 | * since it won't do this for flock() locks. | ||
4741 | */ | ||
4742 | switch (request->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) { | ||
4743 | case F_RDLCK: | ||
4744 | if (!(filp->f_mode & FMODE_READ)) | ||
4745 | return -EBADF; | ||
4746 | break; | ||
4747 | case F_WRLCK: | ||
4748 | if (!(filp->f_mode & FMODE_WRITE)) | ||
4749 | return -EBADF; | ||
4750 | } | ||
4751 | |||
4724 | do { | 4752 | do { |
4725 | status = nfs4_proc_setlk(state, cmd, request); | 4753 | status = nfs4_proc_setlk(state, cmd, request); |
4726 | if ((status != -EAGAIN) || IS_SETLK(cmd)) | 4754 | if ((status != -EAGAIN) || IS_SETLK(cmd)) |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 0f43414eb25a..7f0fcfc1fe9d 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -393,6 +393,7 @@ nfs4_remove_state_owner_locked(struct nfs4_state_owner *sp) | |||
393 | static void | 393 | static void |
394 | nfs4_init_seqid_counter(struct nfs_seqid_counter *sc) | 394 | nfs4_init_seqid_counter(struct nfs_seqid_counter *sc) |
395 | { | 395 | { |
396 | sc->create_time = ktime_get(); | ||
396 | sc->flags = 0; | 397 | sc->flags = 0; |
397 | sc->counter = 0; | 398 | sc->counter = 0; |
398 | spin_lock_init(&sc->lock); | 399 | spin_lock_init(&sc->lock); |
@@ -434,13 +435,17 @@ nfs4_alloc_state_owner(struct nfs_server *server, | |||
434 | static void | 435 | static void |
435 | nfs4_drop_state_owner(struct nfs4_state_owner *sp) | 436 | nfs4_drop_state_owner(struct nfs4_state_owner *sp) |
436 | { | 437 | { |
437 | if (!RB_EMPTY_NODE(&sp->so_server_node)) { | 438 | struct rb_node *rb_node = &sp->so_server_node; |
439 | |||
440 | if (!RB_EMPTY_NODE(rb_node)) { | ||
438 | struct nfs_server *server = sp->so_server; | 441 | struct nfs_server *server = sp->so_server; |
439 | struct nfs_client *clp = server->nfs_client; | 442 | struct nfs_client *clp = server->nfs_client; |
440 | 443 | ||
441 | spin_lock(&clp->cl_lock); | 444 | spin_lock(&clp->cl_lock); |
442 | rb_erase(&sp->so_server_node, &server->state_owners); | 445 | if (!RB_EMPTY_NODE(rb_node)) { |
443 | RB_CLEAR_NODE(&sp->so_server_node); | 446 | rb_erase(rb_node, &server->state_owners); |
447 | RB_CLEAR_NODE(rb_node); | ||
448 | } | ||
444 | spin_unlock(&clp->cl_lock); | 449 | spin_unlock(&clp->cl_lock); |
445 | } | 450 | } |
446 | } | 451 | } |
@@ -516,6 +521,14 @@ out: | |||
516 | /** | 521 | /** |
517 | * nfs4_put_state_owner - Release a nfs4_state_owner | 522 | * nfs4_put_state_owner - Release a nfs4_state_owner |
518 | * @sp: state owner data to release | 523 | * @sp: state owner data to release |
524 | * | ||
525 | * Note that we keep released state owners on an LRU | ||
526 | * list. | ||
527 | * This caches valid state owners so that they can be | ||
528 | * reused, to avoid the OPEN_CONFIRM on minor version 0. | ||
529 | * It also pins the uniquifier of dropped state owners for | ||
530 | * a while, to ensure that those state owner names are | ||
531 | * never reused. | ||
519 | */ | 532 | */ |
520 | void nfs4_put_state_owner(struct nfs4_state_owner *sp) | 533 | void nfs4_put_state_owner(struct nfs4_state_owner *sp) |
521 | { | 534 | { |
@@ -525,15 +538,9 @@ void nfs4_put_state_owner(struct nfs4_state_owner *sp) | |||
525 | if (!atomic_dec_and_lock(&sp->so_count, &clp->cl_lock)) | 538 | if (!atomic_dec_and_lock(&sp->so_count, &clp->cl_lock)) |
526 | return; | 539 | return; |
527 | 540 | ||
528 | if (!RB_EMPTY_NODE(&sp->so_server_node)) { | 541 | sp->so_expires = jiffies; |
529 | sp->so_expires = jiffies; | 542 | list_add_tail(&sp->so_lru, &server->state_owners_lru); |
530 | list_add_tail(&sp->so_lru, &server->state_owners_lru); | 543 | spin_unlock(&clp->cl_lock); |
531 | spin_unlock(&clp->cl_lock); | ||
532 | } else { | ||
533 | nfs4_remove_state_owner_locked(sp); | ||
534 | spin_unlock(&clp->cl_lock); | ||
535 | nfs4_free_state_owner(sp); | ||
536 | } | ||
537 | } | 544 | } |
538 | 545 | ||
539 | /** | 546 | /** |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index c74fdb114b48..77fc5f959c4e 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -74,7 +74,7 @@ static int nfs4_stat_to_errno(int); | |||
74 | /* lock,open owner id: | 74 | /* lock,open owner id: |
75 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) | 75 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
76 | */ | 76 | */ |
77 | #define open_owner_id_maxsz (1 + 1 + 4) | 77 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
78 | #define lock_owner_id_maxsz (1 + 1 + 4) | 78 | #define lock_owner_id_maxsz (1 + 1 + 4) |
79 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) | 79 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
80 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) | 80 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
@@ -1340,12 +1340,13 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena | |||
1340 | */ | 1340 | */ |
1341 | encode_nfs4_seqid(xdr, arg->seqid); | 1341 | encode_nfs4_seqid(xdr, arg->seqid); |
1342 | encode_share_access(xdr, arg->fmode); | 1342 | encode_share_access(xdr, arg->fmode); |
1343 | p = reserve_space(xdr, 32); | 1343 | p = reserve_space(xdr, 36); |
1344 | p = xdr_encode_hyper(p, arg->clientid); | 1344 | p = xdr_encode_hyper(p, arg->clientid); |
1345 | *p++ = cpu_to_be32(20); | 1345 | *p++ = cpu_to_be32(24); |
1346 | p = xdr_encode_opaque_fixed(p, "open id:", 8); | 1346 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
1347 | *p++ = cpu_to_be32(arg->server->s_dev); | 1347 | *p++ = cpu_to_be32(arg->server->s_dev); |
1348 | xdr_encode_hyper(p, arg->id); | 1348 | *p++ = cpu_to_be32(arg->id.uniquifier); |
1349 | xdr_encode_hyper(p, arg->id.create_time); | ||
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 1352 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 9a0e8ef4a409..0a4be28c2ea3 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -322,7 +322,7 @@ out_bad: | |||
322 | while (!list_empty(res)) { | 322 | while (!list_empty(res)) { |
323 | data = list_entry(res->next, struct nfs_read_data, list); | 323 | data = list_entry(res->next, struct nfs_read_data, list); |
324 | list_del(&data->list); | 324 | list_del(&data->list); |
325 | nfs_readdata_free(data); | 325 | nfs_readdata_release(data); |
326 | } | 326 | } |
327 | nfs_readpage_release(req); | 327 | nfs_readpage_release(req); |
328 | return -ENOMEM; | 328 | return -ENOMEM; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 37412f706b32..1e6715f0616c 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2767,11 +2767,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type, | |||
2767 | char *root_devname; | 2767 | char *root_devname; |
2768 | size_t len; | 2768 | size_t len; |
2769 | 2769 | ||
2770 | len = strlen(hostname) + 3; | 2770 | len = strlen(hostname) + 5; |
2771 | root_devname = kmalloc(len, GFP_KERNEL); | 2771 | root_devname = kmalloc(len, GFP_KERNEL); |
2772 | if (root_devname == NULL) | 2772 | if (root_devname == NULL) |
2773 | return ERR_PTR(-ENOMEM); | 2773 | return ERR_PTR(-ENOMEM); |
2774 | snprintf(root_devname, len, "%s:/", hostname); | 2774 | /* Does hostname needs to be enclosed in brackets? */ |
2775 | if (strchr(hostname, ':')) | ||
2776 | snprintf(root_devname, len, "[%s]:/", hostname); | ||
2777 | else | ||
2778 | snprintf(root_devname, len, "%s:/", hostname); | ||
2775 | root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); | 2779 | root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); |
2776 | kfree(root_devname); | 2780 | kfree(root_devname); |
2777 | return root_mnt; | 2781 | return root_mnt; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 2c68818f68ac..c07462320f6b 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -682,7 +682,8 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode, | |||
682 | req->wb_bytes = rqend - req->wb_offset; | 682 | req->wb_bytes = rqend - req->wb_offset; |
683 | out_unlock: | 683 | out_unlock: |
684 | spin_unlock(&inode->i_lock); | 684 | spin_unlock(&inode->i_lock); |
685 | nfs_clear_request_commit(req); | 685 | if (req) |
686 | nfs_clear_request_commit(req); | ||
686 | return req; | 687 | return req; |
687 | out_flushme: | 688 | out_flushme: |
688 | spin_unlock(&inode->i_lock); | 689 | spin_unlock(&inode->i_lock); |
@@ -1018,7 +1019,7 @@ out_bad: | |||
1018 | while (!list_empty(res)) { | 1019 | while (!list_empty(res)) { |
1019 | data = list_entry(res->next, struct nfs_write_data, list); | 1020 | data = list_entry(res->next, struct nfs_write_data, list); |
1020 | list_del(&data->list); | 1021 | list_del(&data->list); |
1021 | nfs_writedata_free(data); | 1022 | nfs_writedata_release(data); |
1022 | } | 1023 | } |
1023 | nfs_redirty_request(req); | 1024 | nfs_redirty_request(req); |
1024 | return -ENOMEM; | 1025 | return -ENOMEM; |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2b9a7607cbd5..2d60492d6df8 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -597,9 +597,6 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, | |||
597 | if (!page) | 597 | if (!page) |
598 | continue; | 598 | continue; |
599 | 599 | ||
600 | if (PageReserved(page)) | ||
601 | continue; | ||
602 | |||
603 | /* Clear accessed and referenced bits. */ | 600 | /* Clear accessed and referenced bits. */ |
604 | ptep_test_and_clear_young(vma, addr, pte); | 601 | ptep_test_and_clear_young(vma, addr, pte); |
605 | ClearPageReferenced(page); | 602 | ClearPageReferenced(page); |