summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:17 -0400
commit1dcf58d6e6e6eb7ec10e9abc56887b040205b06f (patch)
treec03e7a25ef13eea62f1547914a76e5c68f3f4c28 /fs
parent80dcc31fbe55932ac9204daee5f2ebc0c49b6da3 (diff)
parente4b0db72be2487bae0e3251c22f82c104f7c1cfd (diff)
Merge branch 'akpm' (patches from Andrew)
Merge first patchbomb from Andrew Morton: - arch/sh updates - ocfs2 updates - kernel/watchdog feature - about half of mm/ * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (122 commits) Documentation: update arch list in the 'memtest' entry Kconfig: memtest: update number of test patterns up to 17 arm: add support for memtest arm64: add support for memtest memtest: use phys_addr_t for physical addresses mm: move memtest under mm mm, hugetlb: abort __get_user_pages if current has been oom killed mm, mempool: do not allow atomic resizing memcg: print cgroup information when system panics due to panic_on_oom mm: numa: remove migrate_ratelimited mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE mm: split ET_DYN ASLR from mmap ASLR s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE mm: expose arch_mmap_rnd when available s390: standardize mmap_rnd() usage powerpc: standardize mmap_rnd() usage mips: extract logic for mmap_rnd() arm64: standardize mmap_rnd() usage x86: standardize mmap_rnd() usage arm: factor out mmap ASLR into mmap_rnd ...
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig.binfmt3
-rw-r--r--fs/binfmt_elf.c31
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/cifs/connect.c6
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/nfs/write.c5
-rw-r--r--fs/ocfs2/alloc.c48
-rw-r--r--fs/ocfs2/aops.c155
-rw-r--r--fs/ocfs2/cluster/heartbeat.c42
-rw-r--r--fs/ocfs2/cluster/masklog.h5
-rw-r--r--fs/ocfs2/dir.c15
-rw-r--r--fs/ocfs2/dlmglue.c7
-rw-r--r--fs/ocfs2/export.c2
-rw-r--r--fs/ocfs2/inode.c4
-rw-r--r--fs/ocfs2/localalloc.c4
-rw-r--r--fs/ocfs2/namei.c6
-rw-r--r--fs/ocfs2/refcounttree.c2
-rw-r--r--fs/ocfs2/slot_map.c4
-rw-r--r--fs/ocfs2/stack_o2cb.c2
-rw-r--r--fs/ocfs2/stack_user.c8
-rw-r--r--fs/ocfs2/suballoc.c2
-rw-r--r--fs/ocfs2/super.c46
-rw-r--r--fs/ocfs2/xattr.c8
-rw-r--r--fs/super.c2
24 files changed, 279 insertions, 134 deletions
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 270c48148f79..2d0cbbd14cfc 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -27,9 +27,6 @@ config COMPAT_BINFMT_ELF
27 bool 27 bool
28 depends on COMPAT && BINFMT_ELF 28 depends on COMPAT && BINFMT_ELF
29 29
30config ARCH_BINFMT_ELF_RANDOMIZE_PIE
31 bool
32
33config ARCH_BINFMT_ELF_STATE 30config ARCH_BINFMT_ELF_STATE
34 bool 31 bool
35 32
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 995986b8e36b..241ef68d2893 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -31,6 +31,7 @@
31#include <linux/security.h> 31#include <linux/security.h>
32#include <linux/random.h> 32#include <linux/random.h>
33#include <linux/elf.h> 33#include <linux/elf.h>
34#include <linux/elf-randomize.h>
34#include <linux/utsname.h> 35#include <linux/utsname.h>
35#include <linux/coredump.h> 36#include <linux/coredump.h>
36#include <linux/sched.h> 37#include <linux/sched.h>
@@ -862,6 +863,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
862 i < loc->elf_ex.e_phnum; i++, elf_ppnt++) { 863 i < loc->elf_ex.e_phnum; i++, elf_ppnt++) {
863 int elf_prot = 0, elf_flags; 864 int elf_prot = 0, elf_flags;
864 unsigned long k, vaddr; 865 unsigned long k, vaddr;
866 unsigned long total_size = 0;
865 867
866 if (elf_ppnt->p_type != PT_LOAD) 868 if (elf_ppnt->p_type != PT_LOAD)
867 continue; 869 continue;
@@ -909,25 +911,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
909 * default mmap base, as well as whatever program they 911 * default mmap base, as well as whatever program they
910 * might try to exec. This is because the brk will 912 * might try to exec. This is because the brk will
911 * follow the loader, and is not movable. */ 913 * follow the loader, and is not movable. */
912#ifdef CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE 914 load_bias = ELF_ET_DYN_BASE - vaddr;
913 /* Memory randomization might have been switched off
914 * in runtime via sysctl or explicit setting of
915 * personality flags.
916 * If that is the case, retain the original non-zero
917 * load_bias value in order to establish proper
918 * non-randomized mappings.
919 */
920 if (current->flags & PF_RANDOMIZE) 915 if (current->flags & PF_RANDOMIZE)
921 load_bias = 0; 916 load_bias += arch_mmap_rnd();
922 else 917 load_bias = ELF_PAGESTART(load_bias);
923 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); 918 total_size = total_mapping_size(elf_phdata,
924#else 919 loc->elf_ex.e_phnum);
925 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); 920 if (!total_size) {
926#endif 921 error = -EINVAL;
922 goto out_free_dentry;
923 }
927 } 924 }
928 925
929 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, 926 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
930 elf_prot, elf_flags, 0); 927 elf_prot, elf_flags, total_size);
931 if (BAD_ADDR(error)) { 928 if (BAD_ADDR(error)) {
932 retval = IS_ERR((void *)error) ? 929 retval = IS_ERR((void *)error) ?
933 PTR_ERR((void*)error) : -EINVAL; 930 PTR_ERR((void*)error) : -EINVAL;
@@ -1053,15 +1050,13 @@ static int load_elf_binary(struct linux_binprm *bprm)
1053 current->mm->end_data = end_data; 1050 current->mm->end_data = end_data;
1054 current->mm->start_stack = bprm->p; 1051 current->mm->start_stack = bprm->p;
1055 1052
1056#ifdef arch_randomize_brk
1057 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) { 1053 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
1058 current->mm->brk = current->mm->start_brk = 1054 current->mm->brk = current->mm->start_brk =
1059 arch_randomize_brk(current->mm); 1055 arch_randomize_brk(current->mm);
1060#ifdef CONFIG_COMPAT_BRK 1056#ifdef compat_brk_randomized
1061 current->brk_randomized = 1; 1057 current->brk_randomized = 1;
1062#endif 1058#endif
1063 } 1059 }
1064#endif
1065 1060
1066 if (current->personality & MMAP_PAGE_ZERO) { 1061 if (current->personality & MMAP_PAGE_ZERO) {
1067 /* Why this, you ask??? Well SVr4 maps page 0 as read-only, 1062 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
diff --git a/fs/buffer.c b/fs/buffer.c
index 20805db2c987..c7a5602d01ee 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3243,8 +3243,8 @@ int try_to_free_buffers(struct page *page)
3243 * to synchronise against __set_page_dirty_buffers and prevent the 3243 * to synchronise against __set_page_dirty_buffers and prevent the
3244 * dirty bit from being lost. 3244 * dirty bit from being lost.
3245 */ 3245 */
3246 if (ret) 3246 if (ret && TestClearPageDirty(page))
3247 cancel_dirty_page(page, PAGE_CACHE_SIZE); 3247 account_page_cleaned(page, mapping);
3248 spin_unlock(&mapping->private_lock); 3248 spin_unlock(&mapping->private_lock);
3249out: 3249out:
3250 if (buffers_to_free) { 3250 if (buffers_to_free) {
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 480cf9c81d50..f3bfe08e177b 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -773,8 +773,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
773 773
774 length = atomic_dec_return(&tcpSesAllocCount); 774 length = atomic_dec_return(&tcpSesAllocCount);
775 if (length > 0) 775 if (length > 0)
776 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 776 mempool_resize(cifs_req_poolp, length + cifs_min_rcv);
777 GFP_KERNEL);
778} 777}
779 778
780static int 779static int
@@ -848,8 +847,7 @@ cifs_demultiplex_thread(void *p)
848 847
849 length = atomic_inc_return(&tcpSesAllocCount); 848 length = atomic_inc_return(&tcpSesAllocCount);
850 if (length > 1) 849 if (length > 1)
851 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 850 mempool_resize(cifs_req_poolp, length + cifs_min_rcv);
852 GFP_KERNEL);
853 851
854 set_freezable(); 852 set_freezable();
855 while (server->tcpStatus != CifsExiting) { 853 while (server->tcpStatus != CifsExiting) {
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c274aca8e8dc..db76cec3ce21 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -319,7 +319,7 @@ static int hugetlbfs_write_end(struct file *file, struct address_space *mapping,
319 319
320static void truncate_huge_page(struct page *page) 320static void truncate_huge_page(struct page *page)
321{ 321{
322 cancel_dirty_page(page, /* No IO accounting for huge pages? */0); 322 ClearPageDirty(page);
323 ClearPageUptodate(page); 323 ClearPageUptodate(page);
324 delete_from_page_cache(page); 324 delete_from_page_cache(page);
325} 325}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 849ed784d6ac..759931088094 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1876,11 +1876,6 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page)
1876 * request from the inode / page_private pointer and 1876 * request from the inode / page_private pointer and
1877 * release it */ 1877 * release it */
1878 nfs_inode_remove_request(req); 1878 nfs_inode_remove_request(req);
1879 /*
1880 * In case nfs_inode_remove_request has marked the
1881 * page as being dirty
1882 */
1883 cancel_dirty_page(page, PAGE_CACHE_SIZE);
1884 nfs_unlock_and_release_request(req); 1879 nfs_unlock_and_release_request(req);
1885 } 1880 }
1886 1881
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 044158bd22be..2d7f76e52c37 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3370,7 +3370,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
3370 ret = ocfs2_get_right_path(et, left_path, &right_path); 3370 ret = ocfs2_get_right_path(et, left_path, &right_path);
3371 if (ret) { 3371 if (ret) {
3372 mlog_errno(ret); 3372 mlog_errno(ret);
3373 goto out; 3373 return ret;
3374 } 3374 }
3375 3375
3376 right_el = path_leaf_el(right_path); 3376 right_el = path_leaf_el(right_path);
@@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
3453 subtree_index); 3453 subtree_index);
3454 } 3454 }
3455out: 3455out:
3456 if (right_path) 3456 ocfs2_free_path(right_path);
3457 ocfs2_free_path(right_path);
3458 return ret; 3457 return ret;
3459} 3458}
3460 3459
@@ -3536,7 +3535,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
3536 ret = ocfs2_get_left_path(et, right_path, &left_path); 3535 ret = ocfs2_get_left_path(et, right_path, &left_path);
3537 if (ret) { 3536 if (ret) {
3538 mlog_errno(ret); 3537 mlog_errno(ret);
3539 goto out; 3538 return ret;
3540 } 3539 }
3541 3540
3542 left_el = path_leaf_el(left_path); 3541 left_el = path_leaf_el(left_path);
@@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
3647 right_path, subtree_index); 3646 right_path, subtree_index);
3648 } 3647 }
3649out: 3648out:
3650 if (left_path) 3649 ocfs2_free_path(left_path);
3651 ocfs2_free_path(left_path);
3652 return ret; 3650 return ret;
3653} 3651}
3654 3652
@@ -4334,17 +4332,17 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
4334 } else if (path->p_tree_depth > 0) { 4332 } else if (path->p_tree_depth > 0) {
4335 status = ocfs2_find_cpos_for_left_leaf(sb, path, &left_cpos); 4333 status = ocfs2_find_cpos_for_left_leaf(sb, path, &left_cpos);
4336 if (status) 4334 if (status)
4337 goto out; 4335 goto exit;
4338 4336
4339 if (left_cpos != 0) { 4337 if (left_cpos != 0) {
4340 left_path = ocfs2_new_path_from_path(path); 4338 left_path = ocfs2_new_path_from_path(path);
4341 if (!left_path) 4339 if (!left_path)
4342 goto out; 4340 goto exit;
4343 4341
4344 status = ocfs2_find_path(et->et_ci, left_path, 4342 status = ocfs2_find_path(et->et_ci, left_path,
4345 left_cpos); 4343 left_cpos);
4346 if (status) 4344 if (status)
4347 goto out; 4345 goto free_left_path;
4348 4346
4349 new_el = path_leaf_el(left_path); 4347 new_el = path_leaf_el(left_path);
4350 4348
@@ -4361,7 +4359,7 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
4361 le16_to_cpu(new_el->l_next_free_rec), 4359 le16_to_cpu(new_el->l_next_free_rec),
4362 le16_to_cpu(new_el->l_count)); 4360 le16_to_cpu(new_el->l_count));
4363 status = -EINVAL; 4361 status = -EINVAL;
4364 goto out; 4362 goto free_left_path;
4365 } 4363 }
4366 rec = &new_el->l_recs[ 4364 rec = &new_el->l_recs[
4367 le16_to_cpu(new_el->l_next_free_rec) - 1]; 4365 le16_to_cpu(new_el->l_next_free_rec) - 1];
@@ -4388,18 +4386,18 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
4388 path->p_tree_depth > 0) { 4386 path->p_tree_depth > 0) {
4389 status = ocfs2_find_cpos_for_right_leaf(sb, path, &right_cpos); 4387 status = ocfs2_find_cpos_for_right_leaf(sb, path, &right_cpos);
4390 if (status) 4388 if (status)
4391 goto out; 4389 goto free_left_path;
4392 4390
4393 if (right_cpos == 0) 4391 if (right_cpos == 0)
4394 goto out; 4392 goto free_left_path;
4395 4393
4396 right_path = ocfs2_new_path_from_path(path); 4394 right_path = ocfs2_new_path_from_path(path);
4397 if (!right_path) 4395 if (!right_path)
4398 goto out; 4396 goto free_left_path;
4399 4397
4400 status = ocfs2_find_path(et->et_ci, right_path, right_cpos); 4398 status = ocfs2_find_path(et->et_ci, right_path, right_cpos);
4401 if (status) 4399 if (status)
4402 goto out; 4400 goto free_right_path;
4403 4401
4404 new_el = path_leaf_el(right_path); 4402 new_el = path_leaf_el(right_path);
4405 rec = &new_el->l_recs[0]; 4403 rec = &new_el->l_recs[0];
@@ -4413,7 +4411,7 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
4413 (unsigned long long)le64_to_cpu(eb->h_blkno), 4411 (unsigned long long)le64_to_cpu(eb->h_blkno),
4414 le16_to_cpu(new_el->l_next_free_rec)); 4412 le16_to_cpu(new_el->l_next_free_rec));
4415 status = -EINVAL; 4413 status = -EINVAL;
4416 goto out; 4414 goto free_right_path;
4417 } 4415 }
4418 rec = &new_el->l_recs[1]; 4416 rec = &new_el->l_recs[1];
4419 } 4417 }
@@ -4430,12 +4428,11 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
4430 ret = contig_type; 4428 ret = contig_type;
4431 } 4429 }
4432 4430
4433out: 4431free_right_path:
4434 if (left_path) 4432 ocfs2_free_path(right_path);
4435 ocfs2_free_path(left_path); 4433free_left_path:
4436 if (right_path) 4434 ocfs2_free_path(left_path);
4437 ocfs2_free_path(right_path); 4435exit:
4438
4439 return ret; 4436 return ret;
4440} 4437}
4441 4438
@@ -6858,13 +6855,13 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
6858 if (pages == NULL) { 6855 if (pages == NULL) {
6859 ret = -ENOMEM; 6856 ret = -ENOMEM;
6860 mlog_errno(ret); 6857 mlog_errno(ret);
6861 goto out; 6858 return ret;
6862 } 6859 }
6863 6860
6864 ret = ocfs2_reserve_clusters(osb, 1, &data_ac); 6861 ret = ocfs2_reserve_clusters(osb, 1, &data_ac);
6865 if (ret) { 6862 if (ret) {
6866 mlog_errno(ret); 6863 mlog_errno(ret);
6867 goto out; 6864 goto free_pages;
6868 } 6865 }
6869 } 6866 }
6870 6867
@@ -6996,9 +6993,8 @@ out_commit:
6996out: 6993out:
6997 if (data_ac) 6994 if (data_ac)
6998 ocfs2_free_alloc_context(data_ac); 6995 ocfs2_free_alloc_context(data_ac);
6999 if (pages) 6996free_pages:
7000 kfree(pages); 6997 kfree(pages);
7001
7002 return ret; 6998 return ret;
7003} 6999}
7004 7000
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index e1bf18c5d25e..8d2bc840c288 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -664,6 +664,117 @@ static int ocfs2_is_overwrite(struct ocfs2_super *osb,
664 return 0; 664 return 0;
665} 665}
666 666
667static int ocfs2_direct_IO_zero_extend(struct ocfs2_super *osb,
668 struct inode *inode, loff_t offset,
669 u64 zero_len, int cluster_align)
670{
671 u32 p_cpos = 0;
672 u32 v_cpos = ocfs2_bytes_to_clusters(osb->sb, i_size_read(inode));
673 unsigned int num_clusters = 0;
674 unsigned int ext_flags = 0;
675 int ret = 0;
676
677 if (offset <= i_size_read(inode) || cluster_align)
678 return 0;
679
680 ret = ocfs2_get_clusters(inode, v_cpos, &p_cpos, &num_clusters,
681 &ext_flags);
682 if (ret < 0) {
683 mlog_errno(ret);
684 return ret;
685 }
686
687 if (p_cpos && !(ext_flags & OCFS2_EXT_UNWRITTEN)) {
688 u64 s = i_size_read(inode);
689 sector_t sector = (p_cpos << (osb->s_clustersize_bits - 9)) +
690 (do_div(s, osb->s_clustersize) >> 9);
691
692 ret = blkdev_issue_zeroout(osb->sb->s_bdev, sector,
693 zero_len >> 9, GFP_NOFS, false);
694 if (ret < 0)
695 mlog_errno(ret);
696 }
697
698 return ret;
699}
700
701static int ocfs2_direct_IO_extend_no_holes(struct ocfs2_super *osb,
702 struct inode *inode, loff_t offset)
703{
704 u64 zero_start, zero_len, total_zero_len;
705 u32 p_cpos = 0, clusters_to_add;
706 u32 v_cpos = ocfs2_bytes_to_clusters(osb->sb, i_size_read(inode));
707 unsigned int num_clusters = 0;
708 unsigned int ext_flags = 0;
709 u32 size_div, offset_div;
710 int ret = 0;
711
712 {
713 u64 o = offset;
714 u64 s = i_size_read(inode);
715
716 offset_div = do_div(o, osb->s_clustersize);
717 size_div = do_div(s, osb->s_clustersize);
718 }
719
720 if (offset <= i_size_read(inode))
721 return 0;
722
723 clusters_to_add = ocfs2_bytes_to_clusters(inode->i_sb, offset) -
724 ocfs2_bytes_to_clusters(inode->i_sb, i_size_read(inode));
725 total_zero_len = offset - i_size_read(inode);
726 if (clusters_to_add)
727 total_zero_len -= offset_div;
728
729 /* Allocate clusters to fill out holes, and this is only needed
730 * when we add more than one clusters. Otherwise the cluster will
731 * be allocated during direct IO */
732 if (clusters_to_add > 1) {
733 ret = ocfs2_extend_allocation(inode,
734 OCFS2_I(inode)->ip_clusters,
735 clusters_to_add - 1, 0);
736 if (ret) {
737 mlog_errno(ret);
738 goto out;
739 }
740 }
741
742 while (total_zero_len) {
743 ret = ocfs2_get_clusters(inode, v_cpos, &p_cpos, &num_clusters,
744 &ext_flags);
745 if (ret < 0) {
746 mlog_errno(ret);
747 goto out;
748 }
749
750 zero_start = ocfs2_clusters_to_bytes(osb->sb, p_cpos) +
751 size_div;
752 zero_len = ocfs2_clusters_to_bytes(osb->sb, num_clusters) -
753 size_div;
754 zero_len = min(total_zero_len, zero_len);
755
756 if (p_cpos && !(ext_flags & OCFS2_EXT_UNWRITTEN)) {
757 ret = blkdev_issue_zeroout(osb->sb->s_bdev,
758 zero_start >> 9, zero_len >> 9,
759 GFP_NOFS, false);
760 if (ret < 0) {
761 mlog_errno(ret);
762 goto out;
763 }
764 }
765
766 total_zero_len -= zero_len;
767 v_cpos += ocfs2_bytes_to_clusters(osb->sb, zero_len + size_div);
768
769 /* Only at first iteration can be cluster not aligned.
770 * So set size_div to 0 for the rest */
771 size_div = 0;
772 }
773
774out:
775 return ret;
776}
777
667static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb, 778static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
668 struct iov_iter *iter, 779 struct iov_iter *iter,
669 loff_t offset) 780 loff_t offset)
@@ -678,8 +789,8 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
678 struct buffer_head *di_bh = NULL; 789 struct buffer_head *di_bh = NULL;
679 size_t count = iter->count; 790 size_t count = iter->count;
680 journal_t *journal = osb->journal->j_journal; 791 journal_t *journal = osb->journal->j_journal;
681 u32 zero_len; 792 u64 zero_len_head, zero_len_tail;
682 int cluster_align; 793 int cluster_align_head, cluster_align_tail;
683 loff_t final_size = offset + count; 794 loff_t final_size = offset + count;
684 int append_write = offset >= i_size_read(inode) ? 1 : 0; 795 int append_write = offset >= i_size_read(inode) ? 1 : 0;
685 unsigned int num_clusters = 0; 796 unsigned int num_clusters = 0;
@@ -687,9 +798,16 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
687 798
688 { 799 {
689 u64 o = offset; 800 u64 o = offset;
801 u64 s = i_size_read(inode);
802
803 zero_len_head = do_div(o, 1 << osb->s_clustersize_bits);
804 cluster_align_head = !zero_len_head;
690 805
691 zero_len = do_div(o, 1 << osb->s_clustersize_bits); 806 zero_len_tail = osb->s_clustersize -
692 cluster_align = !zero_len; 807 do_div(s, osb->s_clustersize);
808 if ((offset - i_size_read(inode)) < zero_len_tail)
809 zero_len_tail = offset - i_size_read(inode);
810 cluster_align_tail = !zero_len_tail;
693 } 811 }
694 812
695 /* 813 /*
@@ -707,21 +825,23 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
707 } 825 }
708 826
709 if (append_write) { 827 if (append_write) {
710 ret = ocfs2_inode_lock(inode, &di_bh, 1); 828 ret = ocfs2_inode_lock(inode, NULL, 1);
711 if (ret < 0) { 829 if (ret < 0) {
712 mlog_errno(ret); 830 mlog_errno(ret);
713 goto clean_orphan; 831 goto clean_orphan;
714 } 832 }
715 833
834 /* zeroing out the previously allocated cluster tail
835 * that but not zeroed */
716 if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) 836 if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)))
717 ret = ocfs2_zero_extend(inode, di_bh, offset); 837 ret = ocfs2_direct_IO_zero_extend(osb, inode, offset,
838 zero_len_tail, cluster_align_tail);
718 else 839 else
719 ret = ocfs2_extend_no_holes(inode, di_bh, offset, 840 ret = ocfs2_direct_IO_extend_no_holes(osb, inode,
720 offset); 841 offset);
721 if (ret < 0) { 842 if (ret < 0) {
722 mlog_errno(ret); 843 mlog_errno(ret);
723 ocfs2_inode_unlock(inode, 1); 844 ocfs2_inode_unlock(inode, 1);
724 brelse(di_bh);
725 goto clean_orphan; 845 goto clean_orphan;
726 } 846 }
727 847
@@ -729,13 +849,10 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
729 if (is_overwrite < 0) { 849 if (is_overwrite < 0) {
730 mlog_errno(is_overwrite); 850 mlog_errno(is_overwrite);
731 ocfs2_inode_unlock(inode, 1); 851 ocfs2_inode_unlock(inode, 1);
732 brelse(di_bh);
733 goto clean_orphan; 852 goto clean_orphan;
734 } 853 }
735 854
736 ocfs2_inode_unlock(inode, 1); 855 ocfs2_inode_unlock(inode, 1);
737 brelse(di_bh);
738 di_bh = NULL;
739 } 856 }
740 857
741 written = __blockdev_direct_IO(WRITE, iocb, inode, inode->i_sb->s_bdev, 858 written = __blockdev_direct_IO(WRITE, iocb, inode, inode->i_sb->s_bdev,
@@ -772,15 +889,23 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
772 if (ret < 0) 889 if (ret < 0)
773 mlog_errno(ret); 890 mlog_errno(ret);
774 } 891 }
775 } else if (written < 0 && append_write && !is_overwrite && 892 } else if (written > 0 && append_write && !is_overwrite &&
776 !cluster_align) { 893 !cluster_align_head) {
894 /* zeroing out the allocated cluster head */
777 u32 p_cpos = 0; 895 u32 p_cpos = 0;
778 u32 v_cpos = ocfs2_bytes_to_clusters(osb->sb, offset); 896 u32 v_cpos = ocfs2_bytes_to_clusters(osb->sb, offset);
779 897
898 ret = ocfs2_inode_lock(inode, NULL, 0);
899 if (ret < 0) {
900 mlog_errno(ret);
901 goto clean_orphan;
902 }
903
780 ret = ocfs2_get_clusters(inode, v_cpos, &p_cpos, 904 ret = ocfs2_get_clusters(inode, v_cpos, &p_cpos,
781 &num_clusters, &ext_flags); 905 &num_clusters, &ext_flags);
782 if (ret < 0) { 906 if (ret < 0) {
783 mlog_errno(ret); 907 mlog_errno(ret);
908 ocfs2_inode_unlock(inode, 0);
784 goto clean_orphan; 909 goto clean_orphan;
785 } 910 }
786 911
@@ -788,9 +913,11 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
788 913
789 ret = blkdev_issue_zeroout(osb->sb->s_bdev, 914 ret = blkdev_issue_zeroout(osb->sb->s_bdev,
790 p_cpos << (osb->s_clustersize_bits - 9), 915 p_cpos << (osb->s_clustersize_bits - 9),
791 zero_len >> 9, GFP_KERNEL, false); 916 zero_len_head >> 9, GFP_NOFS, false);
792 if (ret < 0) 917 if (ret < 0)
793 mlog_errno(ret); 918 mlog_errno(ret);
919
920 ocfs2_inode_unlock(inode, 0);
794 } 921 }
795 922
796clean_orphan: 923clean_orphan:
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 16eff45727ee..8e19b9d7aba8 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1312,7 +1312,9 @@ static int o2hb_debug_init(void)
1312 int ret = -ENOMEM; 1312 int ret = -ENOMEM;
1313 1313
1314 o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL); 1314 o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL);
1315 if (!o2hb_debug_dir) { 1315 if (IS_ERR_OR_NULL(o2hb_debug_dir)) {
1316 ret = o2hb_debug_dir ?
1317 PTR_ERR(o2hb_debug_dir) : -ENOMEM;
1316 mlog_errno(ret); 1318 mlog_errno(ret);
1317 goto bail; 1319 goto bail;
1318 } 1320 }
@@ -1325,7 +1327,9 @@ static int o2hb_debug_init(void)
1325 sizeof(o2hb_live_node_bitmap), 1327 sizeof(o2hb_live_node_bitmap),
1326 O2NM_MAX_NODES, 1328 O2NM_MAX_NODES,
1327 o2hb_live_node_bitmap); 1329 o2hb_live_node_bitmap);
1328 if (!o2hb_debug_livenodes) { 1330 if (IS_ERR_OR_NULL(o2hb_debug_livenodes)) {
1331 ret = o2hb_debug_livenodes ?
1332 PTR_ERR(o2hb_debug_livenodes) : -ENOMEM;
1329 mlog_errno(ret); 1333 mlog_errno(ret);
1330 goto bail; 1334 goto bail;
1331 } 1335 }
@@ -1338,7 +1342,9 @@ static int o2hb_debug_init(void)
1338 sizeof(o2hb_live_region_bitmap), 1342 sizeof(o2hb_live_region_bitmap),
1339 O2NM_MAX_REGIONS, 1343 O2NM_MAX_REGIONS,
1340 o2hb_live_region_bitmap); 1344 o2hb_live_region_bitmap);
1341 if (!o2hb_debug_liveregions) { 1345 if (IS_ERR_OR_NULL(o2hb_debug_liveregions)) {
1346 ret = o2hb_debug_liveregions ?
1347 PTR_ERR(o2hb_debug_liveregions) : -ENOMEM;
1342 mlog_errno(ret); 1348 mlog_errno(ret);
1343 goto bail; 1349 goto bail;
1344 } 1350 }
@@ -1352,7 +1358,9 @@ static int o2hb_debug_init(void)
1352 sizeof(o2hb_quorum_region_bitmap), 1358 sizeof(o2hb_quorum_region_bitmap),
1353 O2NM_MAX_REGIONS, 1359 O2NM_MAX_REGIONS,
1354 o2hb_quorum_region_bitmap); 1360 o2hb_quorum_region_bitmap);
1355 if (!o2hb_debug_quorumregions) { 1361 if (IS_ERR_OR_NULL(o2hb_debug_quorumregions)) {
1362 ret = o2hb_debug_quorumregions ?
1363 PTR_ERR(o2hb_debug_quorumregions) : -ENOMEM;
1356 mlog_errno(ret); 1364 mlog_errno(ret);
1357 goto bail; 1365 goto bail;
1358 } 1366 }
@@ -1366,7 +1374,9 @@ static int o2hb_debug_init(void)
1366 sizeof(o2hb_failed_region_bitmap), 1374 sizeof(o2hb_failed_region_bitmap),
1367 O2NM_MAX_REGIONS, 1375 O2NM_MAX_REGIONS,
1368 o2hb_failed_region_bitmap); 1376 o2hb_failed_region_bitmap);
1369 if (!o2hb_debug_failedregions) { 1377 if (IS_ERR_OR_NULL(o2hb_debug_failedregions)) {
1378 ret = o2hb_debug_failedregions ?
1379 PTR_ERR(o2hb_debug_failedregions) : -ENOMEM;
1370 mlog_errno(ret); 1380 mlog_errno(ret);
1371 goto bail; 1381 goto bail;
1372 } 1382 }
@@ -2000,7 +2010,8 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2000 2010
2001 reg->hr_debug_dir = 2011 reg->hr_debug_dir =
2002 debugfs_create_dir(config_item_name(&reg->hr_item), dir); 2012 debugfs_create_dir(config_item_name(&reg->hr_item), dir);
2003 if (!reg->hr_debug_dir) { 2013 if (IS_ERR_OR_NULL(reg->hr_debug_dir)) {
2014 ret = reg->hr_debug_dir ? PTR_ERR(reg->hr_debug_dir) : -ENOMEM;
2004 mlog_errno(ret); 2015 mlog_errno(ret);
2005 goto bail; 2016 goto bail;
2006 } 2017 }
@@ -2013,7 +2024,9 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2013 O2HB_DB_TYPE_REGION_LIVENODES, 2024 O2HB_DB_TYPE_REGION_LIVENODES,
2014 sizeof(reg->hr_live_node_bitmap), 2025 sizeof(reg->hr_live_node_bitmap),
2015 O2NM_MAX_NODES, reg); 2026 O2NM_MAX_NODES, reg);
2016 if (!reg->hr_debug_livenodes) { 2027 if (IS_ERR_OR_NULL(reg->hr_debug_livenodes)) {
2028 ret = reg->hr_debug_livenodes ?
2029 PTR_ERR(reg->hr_debug_livenodes) : -ENOMEM;
2017 mlog_errno(ret); 2030 mlog_errno(ret);
2018 goto bail; 2031 goto bail;
2019 } 2032 }
@@ -2025,7 +2038,9 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2025 sizeof(*(reg->hr_db_regnum)), 2038 sizeof(*(reg->hr_db_regnum)),
2026 O2HB_DB_TYPE_REGION_NUMBER, 2039 O2HB_DB_TYPE_REGION_NUMBER,
2027 0, O2NM_MAX_NODES, reg); 2040 0, O2NM_MAX_NODES, reg);
2028 if (!reg->hr_debug_regnum) { 2041 if (IS_ERR_OR_NULL(reg->hr_debug_regnum)) {
2042 ret = reg->hr_debug_regnum ?
2043 PTR_ERR(reg->hr_debug_regnum) : -ENOMEM;
2029 mlog_errno(ret); 2044 mlog_errno(ret);
2030 goto bail; 2045 goto bail;
2031 } 2046 }
@@ -2037,7 +2052,9 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2037 sizeof(*(reg->hr_db_elapsed_time)), 2052 sizeof(*(reg->hr_db_elapsed_time)),
2038 O2HB_DB_TYPE_REGION_ELAPSED_TIME, 2053 O2HB_DB_TYPE_REGION_ELAPSED_TIME,
2039 0, 0, reg); 2054 0, 0, reg);
2040 if (!reg->hr_debug_elapsed_time) { 2055 if (IS_ERR_OR_NULL(reg->hr_debug_elapsed_time)) {
2056 ret = reg->hr_debug_elapsed_time ?
2057 PTR_ERR(reg->hr_debug_elapsed_time) : -ENOMEM;
2041 mlog_errno(ret); 2058 mlog_errno(ret);
2042 goto bail; 2059 goto bail;
2043 } 2060 }
@@ -2049,13 +2066,16 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2049 sizeof(*(reg->hr_db_pinned)), 2066 sizeof(*(reg->hr_db_pinned)),
2050 O2HB_DB_TYPE_REGION_PINNED, 2067 O2HB_DB_TYPE_REGION_PINNED,
2051 0, 0, reg); 2068 0, 0, reg);
2052 if (!reg->hr_debug_pinned) { 2069 if (IS_ERR_OR_NULL(reg->hr_debug_pinned)) {
2070 ret = reg->hr_debug_pinned ?
2071 PTR_ERR(reg->hr_debug_pinned) : -ENOMEM;
2053 mlog_errno(ret); 2072 mlog_errno(ret);
2054 goto bail; 2073 goto bail;
2055 } 2074 }
2056 2075
2057 ret = 0; 2076 return 0;
2058bail: 2077bail:
2078 debugfs_remove_recursive(reg->hr_debug_dir);
2059 return ret; 2079 return ret;
2060} 2080}
2061 2081
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h
index 2260fb9e6508..7fdc25a4d8c0 100644
--- a/fs/ocfs2/cluster/masklog.h
+++ b/fs/ocfs2/cluster/masklog.h
@@ -196,13 +196,14 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits;
196 } \ 196 } \
197} while (0) 197} while (0)
198 198
199#define mlog_errno(st) do { \ 199#define mlog_errno(st) ({ \
200 int _st = (st); \ 200 int _st = (st); \
201 if (_st != -ERESTARTSYS && _st != -EINTR && \ 201 if (_st != -ERESTARTSYS && _st != -EINTR && \
202 _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC && \ 202 _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC && \
203 _st != -EDQUOT) \ 203 _st != -EDQUOT) \
204 mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ 204 mlog(ML_ERROR, "status = %lld\n", (long long)_st); \
205} while (0) 205 _st; \
206})
206 207
207#define mlog_bug_on_msg(cond, fmt, args...) do { \ 208#define mlog_bug_on_msg(cond, fmt, args...) do { \
208 if (cond) { \ 209 if (cond) { \
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index b08050bd3f2e..ccd4dcfc3645 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -18,7 +18,7 @@
18 * 18 *
19 * linux/fs/minix/dir.c 19 * linux/fs/minix/dir.c
20 * 20 *
21 * Copyright (C) 1991, 1992 Linux Torvalds 21 * Copyright (C) 1991, 1992 Linus Torvalds
22 * 22 *
23 * This program is free software; you can redistribute it and/or 23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public 24 * modify it under the terms of the GNU General Public
@@ -2047,22 +2047,19 @@ int ocfs2_check_dir_for_entry(struct inode *dir,
2047 const char *name, 2047 const char *name,
2048 int namelen) 2048 int namelen)
2049{ 2049{
2050 int ret; 2050 int ret = 0;
2051 struct ocfs2_dir_lookup_result lookup = { NULL, }; 2051 struct ocfs2_dir_lookup_result lookup = { NULL, };
2052 2052
2053 trace_ocfs2_check_dir_for_entry( 2053 trace_ocfs2_check_dir_for_entry(
2054 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name); 2054 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name);
2055 2055
2056 ret = -EEXIST; 2056 if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) {
2057 if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) 2057 ret = -EEXIST;
2058 goto bail; 2058 mlog_errno(ret);
2059 }
2059 2060
2060 ret = 0;
2061bail:
2062 ocfs2_free_dir_lookup_result(&lookup); 2061 ocfs2_free_dir_lookup_result(&lookup);
2063 2062
2064 if (ret)
2065 mlog_errno(ret);
2066 return ret; 2063 return ret;
2067} 2064}
2068 2065
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 11849a44dc5a..956edf67be20 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -1391,6 +1391,11 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
1391 int noqueue_attempted = 0; 1391 int noqueue_attempted = 0;
1392 int dlm_locked = 0; 1392 int dlm_locked = 0;
1393 1393
1394 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) {
1395 mlog_errno(-EINVAL);
1396 return -EINVAL;
1397 }
1398
1394 ocfs2_init_mask_waiter(&mw); 1399 ocfs2_init_mask_waiter(&mw);
1395 1400
1396 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) 1401 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB)
@@ -2954,7 +2959,7 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
2954 osb->osb_debug_root, 2959 osb->osb_debug_root,
2955 osb, 2960 osb,
2956 &ocfs2_dlm_debug_fops); 2961 &ocfs2_dlm_debug_fops);
2957 if (!dlm_debug->d_locking_state) { 2962 if (IS_ERR_OR_NULL(dlm_debug->d_locking_state)) {
2958 ret = -EINVAL; 2963 ret = -EINVAL;
2959 mlog(ML_ERROR, 2964 mlog(ML_ERROR,
2960 "Unable to create locking state debugfs file.\n"); 2965 "Unable to create locking state debugfs file.\n");
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index 29651167190d..540dc4bdd042 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -82,7 +82,6 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,
82 } 82 }
83 83
84 status = ocfs2_test_inode_bit(osb, blkno, &set); 84 status = ocfs2_test_inode_bit(osb, blkno, &set);
85 trace_ocfs2_get_dentry_test_bit(status, set);
86 if (status < 0) { 85 if (status < 0) {
87 if (status == -EINVAL) { 86 if (status == -EINVAL) {
88 /* 87 /*
@@ -96,6 +95,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,
96 goto unlock_nfs_sync; 95 goto unlock_nfs_sync;
97 } 96 }
98 97
98 trace_ocfs2_get_dentry_test_bit(status, set);
99 /* If the inode allocator bit is clear, this inode must be stale */ 99 /* If the inode allocator bit is clear, this inode must be stale */
100 if (!set) { 100 if (!set) {
101 status = -ESTALE; 101 status = -ESTALE;
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 3025c0da6b8a..be71ca0937f7 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -624,7 +624,7 @@ static int ocfs2_remove_inode(struct inode *inode,
624 ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE, 624 ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE,
625 le16_to_cpu(di->i_suballoc_slot)); 625 le16_to_cpu(di->i_suballoc_slot));
626 if (!inode_alloc_inode) { 626 if (!inode_alloc_inode) {
627 status = -EEXIST; 627 status = -ENOENT;
628 mlog_errno(status); 628 mlog_errno(status);
629 goto bail; 629 goto bail;
630 } 630 }
@@ -742,7 +742,7 @@ static int ocfs2_wipe_inode(struct inode *inode,
742 ORPHAN_DIR_SYSTEM_INODE, 742 ORPHAN_DIR_SYSTEM_INODE,
743 orphaned_slot); 743 orphaned_slot);
744 if (!orphan_dir_inode) { 744 if (!orphan_dir_inode) {
745 status = -EEXIST; 745 status = -ENOENT;
746 mlog_errno(status); 746 mlog_errno(status);
747 goto bail; 747 goto bail;
748 } 748 }
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 044013455621..857bbbcd39f3 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -666,7 +666,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
666 if (le32_to_cpu(alloc->id1.bitmap1.i_used) != 666 if (le32_to_cpu(alloc->id1.bitmap1.i_used) !=
667 ocfs2_local_alloc_count_bits(alloc)) { 667 ocfs2_local_alloc_count_bits(alloc)) {
668 ocfs2_error(osb->sb, "local alloc inode %llu says it has " 668 ocfs2_error(osb->sb, "local alloc inode %llu says it has "
669 "%u free bits, but a count shows %u", 669 "%u used bits, but a count shows %u",
670 (unsigned long long)le64_to_cpu(alloc->i_blkno), 670 (unsigned long long)le64_to_cpu(alloc->i_blkno),
671 le32_to_cpu(alloc->id1.bitmap1.i_used), 671 le32_to_cpu(alloc->id1.bitmap1.i_used),
672 ocfs2_local_alloc_count_bits(alloc)); 672 ocfs2_local_alloc_count_bits(alloc));
@@ -839,7 +839,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
839 u32 *numbits, 839 u32 *numbits,
840 struct ocfs2_alloc_reservation *resv) 840 struct ocfs2_alloc_reservation *resv)
841{ 841{
842 int numfound, bitoff, left, startoff, lastzero; 842 int numfound = 0, bitoff, left, startoff, lastzero;
843 int local_resv = 0; 843 int local_resv = 0;
844 struct ocfs2_alloc_reservation r; 844 struct ocfs2_alloc_reservation r;
845 void *bitmap = NULL; 845 void *bitmap = NULL;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index b5c3a5ea3ee6..09f90cbf0e24 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -2322,10 +2322,10 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
2322 2322
2323 trace_ocfs2_orphan_del( 2323 trace_ocfs2_orphan_del(
2324 (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno, 2324 (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno,
2325 name, namelen); 2325 name, strlen(name));
2326 2326
2327 /* find it's spot in the orphan directory */ 2327 /* find it's spot in the orphan directory */
2328 status = ocfs2_find_entry(name, namelen, orphan_dir_inode, 2328 status = ocfs2_find_entry(name, strlen(name), orphan_dir_inode,
2329 &lookup); 2329 &lookup);
2330 if (status) { 2330 if (status) {
2331 mlog_errno(status); 2331 mlog_errno(status);
@@ -2808,7 +2808,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
2808 ORPHAN_DIR_SYSTEM_INODE, 2808 ORPHAN_DIR_SYSTEM_INODE,
2809 osb->slot_num); 2809 osb->slot_num);
2810 if (!orphan_dir_inode) { 2810 if (!orphan_dir_inode) {
2811 status = -EEXIST; 2811 status = -ENOENT;
2812 mlog_errno(status); 2812 mlog_errno(status);
2813 goto leave; 2813 goto leave;
2814 } 2814 }
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index ee541f92dab4..df3a500789c7 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -4276,7 +4276,7 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
4276 error = posix_acl_create(dir, &mode, &default_acl, &acl); 4276 error = posix_acl_create(dir, &mode, &default_acl, &acl);
4277 if (error) { 4277 if (error) {
4278 mlog_errno(error); 4278 mlog_errno(error);
4279 goto out; 4279 return error;
4280 } 4280 }
4281 4281
4282 error = ocfs2_create_inode_in_orphan(dir, mode, 4282 error = ocfs2_create_inode_in_orphan(dir, mode,
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index d5493e361a38..e78a203d44c8 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -427,7 +427,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
427 if (!si) { 427 if (!si) {
428 status = -ENOMEM; 428 status = -ENOMEM;
429 mlog_errno(status); 429 mlog_errno(status);
430 goto bail; 430 return status;
431 } 431 }
432 432
433 si->si_extended = ocfs2_uses_extended_slot_map(osb); 433 si->si_extended = ocfs2_uses_extended_slot_map(osb);
@@ -452,7 +452,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
452 452
453 osb->slot_info = (struct ocfs2_slot_info *)si; 453 osb->slot_info = (struct ocfs2_slot_info *)si;
454bail: 454bail:
455 if (status < 0 && si) 455 if (status < 0)
456 __ocfs2_free_slot_info(si); 456 __ocfs2_free_slot_info(si);
457 457
458 return status; 458 return status;
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index 1724d43d3da1..220cae7bbdbc 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -295,7 +295,7 @@ static int o2cb_cluster_check(void)
295 set_bit(node_num, netmap); 295 set_bit(node_num, netmap);
296 if (!memcmp(hbmap, netmap, sizeof(hbmap))) 296 if (!memcmp(hbmap, netmap, sizeof(hbmap)))
297 return 0; 297 return 0;
298 if (i < O2CB_MAP_STABILIZE_COUNT) 298 if (i < O2CB_MAP_STABILIZE_COUNT - 1)
299 msleep(1000); 299 msleep(1000);
300 } 300 }
301 301
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index 720aa389e0ea..2768eb1da2b8 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -1004,10 +1004,8 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
1004 BUG_ON(conn == NULL); 1004 BUG_ON(conn == NULL);
1005 1005
1006 lc = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL); 1006 lc = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL);
1007 if (!lc) { 1007 if (!lc)
1008 rc = -ENOMEM; 1008 return -ENOMEM;
1009 goto out;
1010 }
1011 1009
1012 init_waitqueue_head(&lc->oc_wait); 1010 init_waitqueue_head(&lc->oc_wait);
1013 init_completion(&lc->oc_sync_wait); 1011 init_completion(&lc->oc_sync_wait);
@@ -1063,7 +1061,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
1063 } 1061 }
1064 1062
1065out: 1063out:
1066 if (rc && lc) 1064 if (rc)
1067 kfree(lc); 1065 kfree(lc);
1068 return rc; 1066 return rc;
1069} 1067}
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 0cb889a17ae1..4479029630bb 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -2499,6 +2499,8 @@ static int _ocfs2_free_suballoc_bits(handle_t *handle,
2499 alloc_bh, OCFS2_JOURNAL_ACCESS_WRITE); 2499 alloc_bh, OCFS2_JOURNAL_ACCESS_WRITE);
2500 if (status < 0) { 2500 if (status < 0) {
2501 mlog_errno(status); 2501 mlog_errno(status);
2502 ocfs2_block_group_set_bits(handle, alloc_inode, group, group_bh,
2503 start_bit, count);
2502 goto bail; 2504 goto bail;
2503 } 2505 }
2504 2506
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 26675185b886..837ddce4b659 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1112,7 +1112,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
1112 1112
1113 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, 1113 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
1114 ocfs2_debugfs_root); 1114 ocfs2_debugfs_root);
1115 if (!osb->osb_debug_root) { 1115 if (IS_ERR_OR_NULL(osb->osb_debug_root)) {
1116 status = -EINVAL; 1116 status = -EINVAL;
1117 mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n"); 1117 mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n");
1118 goto read_super_error; 1118 goto read_super_error;
@@ -1122,7 +1122,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
1122 osb->osb_debug_root, 1122 osb->osb_debug_root,
1123 osb, 1123 osb,
1124 &ocfs2_osb_debug_fops); 1124 &ocfs2_osb_debug_fops);
1125 if (!osb->osb_ctxt) { 1125 if (IS_ERR_OR_NULL(osb->osb_ctxt)) {
1126 status = -EINVAL; 1126 status = -EINVAL;
1127 mlog_errno(status); 1127 mlog_errno(status);
1128 goto read_super_error; 1128 goto read_super_error;
@@ -1606,8 +1606,9 @@ static int __init ocfs2_init(void)
1606 } 1606 }
1607 1607
1608 ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); 1608 ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
1609 if (!ocfs2_debugfs_root) { 1609 if (IS_ERR_OR_NULL(ocfs2_debugfs_root)) {
1610 status = -ENOMEM; 1610 status = ocfs2_debugfs_root ?
1611 PTR_ERR(ocfs2_debugfs_root) : -ENOMEM;
1611 mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); 1612 mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
1612 goto out4; 1613 goto out4;
1613 } 1614 }
@@ -2069,6 +2070,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
2069 cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits); 2070 cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
2070 bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits); 2071 bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
2071 sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits); 2072 sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
2073 memcpy(sb->s_uuid, di->id2.i_super.s_uuid,
2074 sizeof(di->id2.i_super.s_uuid));
2072 2075
2073 osb->osb_dx_mask = (1 << (cbits - bbits)) - 1; 2076 osb->osb_dx_mask = (1 << (cbits - bbits)) - 1;
2074 2077
@@ -2333,7 +2336,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
2333 mlog_errno(status); 2336 mlog_errno(status);
2334 goto bail; 2337 goto bail;
2335 } 2338 }
2336 cleancache_init_shared_fs((char *)&di->id2.i_super.s_uuid, sb); 2339 cleancache_init_shared_fs(sb);
2337 2340
2338bail: 2341bail:
2339 return status; 2342 return status;
@@ -2563,22 +2566,22 @@ static void ocfs2_handle_error(struct super_block *sb)
2563 ocfs2_set_ro_flag(osb, 0); 2566 ocfs2_set_ro_flag(osb, 0);
2564} 2567}
2565 2568
2566static char error_buf[1024]; 2569void __ocfs2_error(struct super_block *sb, const char *function,
2567 2570 const char *fmt, ...)
2568void __ocfs2_error(struct super_block *sb,
2569 const char *function,
2570 const char *fmt, ...)
2571{ 2571{
2572 struct va_format vaf;
2572 va_list args; 2573 va_list args;
2573 2574
2574 va_start(args, fmt); 2575 va_start(args, fmt);
2575 vsnprintf(error_buf, sizeof(error_buf), fmt, args); 2576 vaf.fmt = fmt;
2576 va_end(args); 2577 vaf.va = &args;
2577 2578
2578 /* Not using mlog here because we want to show the actual 2579 /* Not using mlog here because we want to show the actual
2579 * function the error came from. */ 2580 * function the error came from. */
2580 printk(KERN_CRIT "OCFS2: ERROR (device %s): %s: %s\n", 2581 printk(KERN_CRIT "OCFS2: ERROR (device %s): %s: %pV\n",
2581 sb->s_id, function, error_buf); 2582 sb->s_id, function, &vaf);
2583
2584 va_end(args);
2582 2585
2583 ocfs2_handle_error(sb); 2586 ocfs2_handle_error(sb);
2584} 2587}
@@ -2586,18 +2589,21 @@ void __ocfs2_error(struct super_block *sb,
2586/* Handle critical errors. This is intentionally more drastic than 2589/* Handle critical errors. This is intentionally more drastic than
2587 * ocfs2_handle_error, so we only use for things like journal errors, 2590 * ocfs2_handle_error, so we only use for things like journal errors,
2588 * etc. */ 2591 * etc. */
2589void __ocfs2_abort(struct super_block* sb, 2592void __ocfs2_abort(struct super_block *sb, const char *function,
2590 const char *function,
2591 const char *fmt, ...) 2593 const char *fmt, ...)
2592{ 2594{
2595 struct va_format vaf;
2593 va_list args; 2596 va_list args;
2594 2597
2595 va_start(args, fmt); 2598 va_start(args, fmt);
2596 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
2597 va_end(args);
2598 2599
2599 printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", 2600 vaf.fmt = fmt;
2600 sb->s_id, function, error_buf); 2601 vaf.va = &args;
2602
2603 printk(KERN_CRIT "OCFS2: abort (device %s): %s: %pV\n",
2604 sb->s_id, function, &vaf);
2605
2606 va_end(args);
2601 2607
2602 /* We don't have the cluster support yet to go straight to 2608 /* We don't have the cluster support yet to go straight to
2603 * hard readonly in here. Until then, we want to keep 2609 * hard readonly in here. Until then, we want to keep
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 85b190dc132f..4ca7533be479 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -1238,6 +1238,10 @@ static int ocfs2_xattr_block_get(struct inode *inode,
1238 i, 1238 i,
1239 &block_off, 1239 &block_off,
1240 &name_offset); 1240 &name_offset);
1241 if (ret) {
1242 mlog_errno(ret);
1243 goto cleanup;
1244 }
1241 xs->base = bucket_block(xs->bucket, block_off); 1245 xs->base = bucket_block(xs->bucket, block_off);
1242 } 1246 }
1243 if (ocfs2_xattr_is_local(xs->here)) { 1247 if (ocfs2_xattr_is_local(xs->here)) {
@@ -5665,6 +5669,10 @@ static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
5665 5669
5666 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, 5670 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket,
5667 i, &xv, NULL); 5671 i, &xv, NULL);
5672 if (ret) {
5673 mlog_errno(ret);
5674 break;
5675 }
5668 5676
5669 ret = ocfs2_lock_xattr_remove_allocators(inode, xv, 5677 ret = ocfs2_lock_xattr_remove_allocators(inode, xv,
5670 args->ref_ci, 5678 args->ref_ci,
diff --git a/fs/super.c b/fs/super.c
index 2b7dc90ccdbb..928c20f47af9 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -224,7 +224,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
224 s->s_maxbytes = MAX_NON_LFS; 224 s->s_maxbytes = MAX_NON_LFS;
225 s->s_op = &default_op; 225 s->s_op = &default_op;
226 s->s_time_gran = 1000000000; 226 s->s_time_gran = 1000000000;
227 s->cleancache_poolid = -1; 227 s->cleancache_poolid = CLEANCACHE_NO_POOL;
228 228
229 s->s_shrink.seeks = DEFAULT_SEEKS; 229 s->s_shrink.seeks = DEFAULT_SEEKS;
230 s->s_shrink.scan_objects = super_cache_scan; 230 s->s_shrink.scan_objects = super_cache_scan;