11 Dec, 2016

1 commit


10 Dec, 2016

1 commit


08 Dec, 2016

1 commit

  • This function sets req->r_locked_dir which is supposed to indicate to
    ceph_fill_trace that the parent's i_rwsem is locked for write.
    Unfortunately, there is no guarantee that the dir will be locked when
    d_revalidate is called, so we really don't want ceph_fill_trace to do
    any dcache manipulation from this context. Clear req->r_locked_dir since
    it's clearly not safe to do that.

    What we really want to know with d_revalidate is whether the dentry
    still points to the same inode. ceph_fill_trace installs a pointer to
    the inode in req->r_target_inode, so we can just compare that to
    d_inode(dentry) to see if it's the same one after the lookup.

    Also, since we aren't generally interested in the parent here, we can
    switch to using a GETATTR to hint that to the MDS, which also means that
    we only need to reserve one cap.

    Finally, just remove the d_unhashed check. That's really outside the
    purview of a filesystem's d_revalidate. If the thing became unhashed
    while we're checking it, then that's up to the VFS to handle anyway.

    Fixes: 200fd27c8fa2 ("ceph: use lookup request to revalidate dentry")
    Link: http://tracker.ceph.com/issues/18041
    Reported-by: Donatas Abraitis
    Signed-off-by: Jeff Layton
    Reviewed-by: "Yan, Zheng"
    Signed-off-by: Ilya Dryomov

    Jeff Layton
     

06 Dec, 2016

1 commit

  • Basically, the pjdfstests set the ownership of a file to 06555, and then
    chowns it (as root) to a new uid/gid. Prior to commit a09f99eddef4 ("fuse:
    fix killing s[ug]id in setattr"), fuse would send down a setattr with both
    the uid/gid change and a new mode. Now, it just sends down the uid/gid
    change.

    Technically this is NOTABUG, since POSIX doesn't _require_ that we clear
    these bits for a privileged process, but Linux (wisely) has done that and I
    think we don't want to change that behavior here.

    This is caused by the use of should_remove_suid(), which will always return
    0 when the process has CAP_FSETID.

    In fact we really don't need to be calling should_remove_suid() at all,
    since we've already been indicated that we should remove the suid, we just
    don't want to use a (very) stale mode for that.

    This patch should fix the above as well as simplify the logic.

    Reported-by: Jeff Layton
    Signed-off-by: Miklos Szeredi
    Fixes: a09f99eddef4 ("fuse: fix killing s[ug]id in setattr")
    Cc:
    Reviewed-by: Jeff Layton

    Miklos Szeredi
     

04 Dec, 2016

1 commit

  • Couple conflicts resolved here:

    1) In the MACB driver, a bug fix to properly initialize the
    RX tail pointer properly overlapped with some changes
    to support variable sized rings.

    2) In XGBE we had a "CONFIG_PM" --> "CONFIG_PM_SLEEP" fix
    overlapping with a reorganization of the driver to support
    ACPI, OF, as well as PCI variants of the chip.

    3) In 'net' we had several probe error path bug fixes to the
    stmmac driver, meanwhile a lot of this code was cleaned up
    and reorganized in 'net-next'.

    4) The cls_flower classifier obtained a helper function in
    'net-next' called __fl_delete() and this overlapped with
    Daniel Borkamann's bug fix to use RCU for object destruction
    in 'net'. It also overlapped with Jiri's change to guard
    the rhashtable_remove_fast() call with a check against
    tc_skip_sw().

    5) In mlx4, a revert bug fix in 'net' overlapped with some
    unrelated changes in 'net-next'.

    6) In geneve, a stale header pointer after pskb_expand_head()
    bug fix in 'net' overlapped with a large reorganization of
    the same code in 'net-next'. Since the 'net-next' code no
    longer had the bug in question, there was nothing to do
    other than to simply take the 'net-next' hunks.

    Signed-off-by: David S. Miller

    David S. Miller
     

02 Dec, 2016

1 commit


01 Dec, 2016

1 commit

  • The ER records are printed without explicit log level presuming line
    continuation until "\n". After the commit 4bcc595ccd8 (printk:
    reinstate KERN_CONT for printing continuation lines), the ER records are
    printed a character per line.

    Adding KERN_CONT to appropriate printk statements restores the printout
    behavior.

    Signed-off-by: Mike Rapoport
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

29 Nov, 2016

4 commits

  • Handling of recursion in d_real() is completely broken. Recursion is only
    done in the 'inode != NULL' case. But when opening the file we have
    'inode == NULL' hence d_real() will return an overlay dentry. This won't
    work since overlayfs doesn't define its own file operations, so all file
    ops will fail.

    Fix by doing the recursion first and the check against the inode second.

    Bash script to reproduce the issue written by Quentin:

    - 8< - - - - - 8< - - - - - 8< - - - - - 8< - - - -
    tmpdir=$(mktemp -d)
    pushd ${tmpdir}

    mkdir -p {upper,lower,work}
    echo -n 'rocks' > lower/ksplice
    mount -t overlay level_zero upper -o lowerdir=lower,upperdir=upper,workdir=work
    cat upper/ksplice

    tmpdir2=$(mktemp -d)
    pushd ${tmpdir2}

    mkdir -p {upper,work}
    mount -t overlay level_one upper -o lowerdir=${tmpdir}/upper,upperdir=upper,workdir=work
    ls -l upper/ksplice
    cat upper/ksplice
    - 8< - - - - - 8< - - - - - 8< - - - - - 8< - - - -

    Reported-by: Quentin Casasnovas
    Signed-off-by: Miklos Szeredi
    Fixes: 2d902671ce1c ("vfs: merge .d_select_inode() into .d_real()")
    Cc: # v4.8+

    Miklos Szeredi
     
  • Commit 2211d5ba5c6c ("posix_acl: xattr representation cleanups")
    removes the typedefs and the zero-length a_entries array in struct
    posix_acl_xattr_header, and uses bare struct posix_acl_xattr_header
    and struct posix_acl_xattr_entry directly.

    But it failed to iterate over posix acl slots when converting posix
    acls to CIFS format, which results in several test failures in
    xfstests (generic/053 generic/105) when testing against a samba v1
    server, starting from v4.9-rc1 kernel. e.g.

    [root@localhost xfstests]# diff -u tests/generic/105.out /root/xfstests/results//generic/105.out.bad
    --- tests/generic/105.out 2016-09-19 16:33:28.577962575 +0800
    +++ /root/xfstests/results//generic/105.out.bad 2016-10-22 15:41:15.201931110 +0800
    @@ -1,3 +1,4 @@
    QA output created by 105
    -rw-r--r-- root
    +setfacl: subdir: Invalid argument
    -rw-r--r-- root

    Fix it by introducing a new "ace" var, like what
    cifs_copy_posix_acl() does, and iterating posix acl xattr entries
    over it in the for loop.

    Signed-off-by: Eryu Guan
    Signed-off-by: Steve French

    Eryu Guan
     
  • Commit 4fcd1813e640 ("Fix reconnect to not defer smb3 session reconnect
    long after socket reconnect") changes the behaviour of the SMB2 echo
    service and causes it to renegotiate after a socket reconnect. However
    under default settings, the echo service could take up to 120 seconds to
    be scheduled.

    The patch forces the echo service to be called immediately resulting a
    negotiate call being made immediately on reconnect.

    Signed-off-by: Sachin Prabhu
    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Sachin Prabhu
     
  • Andy Lutromirski's new virtually mapped kernel stack allocations moves
    kernel stacks the vmalloc area. This triggers the bug
    kernel BUG at ./include/linux/scatterlist.h:140!
    at calc_seckey()->sg_init()

    Signed-off-by: Sachin Prabhu
    Signed-off-by: Steve French
    Reviewed-by: Jeff Layton

    Sachin Prabhu
     

27 Nov, 2016

2 commits


24 Nov, 2016

1 commit

  • Pull NFS client bugfixes from Anna Schumaker:
    "Most of these fix regressions or races, but there is one patch for
    stable that Arnd sent me

    Stable bugfix:
    - Hide array-bounds warning

    Bugfixes:
    - Keep a reference on lock states while checking
    - Handle NFS4ERR_OLD_STATEID in nfs4_reclaim_open_state
    - Don't call close if the open stateid has already been cleared
    - Fix CLOSE rases with OPEN
    - Fix a regression in DELEGRETURN"

    * tag 'nfs-for-4.9-4' of git://git.linux-nfs.org/projects/anna/linux-nfs:
    NFSv4.x: hide array-bounds warning
    NFSv4.1: Keep a reference on lock states while checking
    NFSv4.1: Handle NFS4ERR_OLD_STATEID in nfs4_reclaim_open_state
    NFSv4: Don't call close if the open stateid has already been cleared
    NFSv4: Fix CLOSE races with OPEN
    NFSv4.1: Fix a regression in DELEGRETURN

    Linus Torvalds
     

23 Nov, 2016

2 commits

  • A correct bugfix introduced a harmless warning that shows up with gcc-7:

    fs/nfs/callback.c: In function 'nfs_callback_up':
    fs/nfs/callback.c:214:14: error: array subscript is outside array bounds [-Werror=array-bounds]

    What happens here is that the 'minorversion == 0' check tells the
    compiler that we assume minorversion can be something other than 0,
    but when CONFIG_NFS_V4_1 is disabled that would be invalid and
    result in an out-of-bounds access.

    The added check for IS_ENABLED(CONFIG_NFS_V4_1) tells gcc that this
    really can't happen, which makes the code slightly smaller and also
    avoids the warning.

    The bugfix that introduced the warning is marked for stable backports,
    we want this one backported to the same releases.

    Fixes: 98b0f80c2396 ("NFSv4.x: Fix a refcount leak in nfs_callback_up_net")
    Cc: stable@vger.kernel.org # v3.7+
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Anna Schumaker

    Arnd Bergmann
     
  • All conflicts were simple overlapping changes except perhaps
    for the Thunder driver.

    That driver has a change_mtu method explicitly for sending
    a message to the hardware. If that fails it returns an
    error.

    Normally a driver doesn't need an ndo_change_mtu method becuase those
    are usually just range changes, which are now handled generically.
    But since this extra operation is needed in the Thunder driver, it has
    to stay.

    However, if the message send fails we have to restore the original
    MTU before the change because the entire call chain expects that if
    an error is thrown by ndo_change_mtu then the MTU did not change.
    Therefore code is added to nicvf_change_mtu to remember the original
    MTU, and to restore it upon nicvf_update_hw_max_frs() failue.

    Signed-off-by: David S. Miller

    David S. Miller
     

22 Nov, 2016

1 commit


20 Nov, 2016

4 commits

  • Pull ext4 fixes from Ted Ts'o:
    "A security fix (so a maliciously corrupted file system image won't
    panic the kernel) and some fixes for CONFIG_VMAP_STACK"

    * tag 'ext4_for_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
    ext4: sanity check the block and cluster size at mount time
    fscrypto: don't use on-stack buffer for key derivation
    fscrypto: don't use on-stack buffer for filename encryption

    Linus Torvalds
     
  • If the block size or cluster size is insane, reject the mount. This
    is important for security reasons (although we shouldn't be just
    depending on this check).

    Ref: http://www.securityfocus.com/archive/1/539661
    Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1332506
    Reported-by: Borislav Petkov
    Reported-by: Nikolay Borisov
    Signed-off-by: Theodore Ts'o
    Cc: stable@vger.kernel.org

    Theodore Ts'o
     
  • With the new (in 4.9) option to use a virtually-mapped stack
    (CONFIG_VMAP_STACK), stack buffers cannot be used as input/output for
    the scatterlist crypto API because they may not be directly mappable to
    struct page. get_crypt_info() was using a stack buffer to hold the
    output from the encryption operation used to derive the per-file key.
    Fix it by using a heap buffer.

    This bug could most easily be observed in a CONFIG_DEBUG_SG kernel
    because this allowed the BUG in sg_set_buf() to be triggered.

    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • With the new (in 4.9) option to use a virtually-mapped stack
    (CONFIG_VMAP_STACK), stack buffers cannot be used as input/output for
    the scatterlist crypto API because they may not be directly mappable to
    struct page. For short filenames, fname_encrypt() was encrypting a
    stack buffer holding the padded filename. Fix it by encrypting the
    filename in-place in the output buffer, thereby making the temporary
    buffer unnecessary.

    This bug could most easily be observed in a CONFIG_DEBUG_SG kernel
    because this allowed the BUG in sg_set_buf() to be triggered.

    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     

19 Nov, 2016

4 commits

  • Now that we're doing TEST_STATEID in nfs4_reclaim_open_state(), we can have
    a NFS4ERR_OLD_STATEID returned from nfs41_open_expired() . Instead of
    marking state recovery as failed, mark the state for recovery again.

    Signed-off-by: Benjamin Coddington
    Signed-off-by: Anna Schumaker

    Benjamin Coddington
     
  • Ensure we test to see if the open stateid is actually set, before we
    send a CLOSE.

    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker

    Trond Myklebust
     
  • If the reply to a successful CLOSE call races with an OPEN to the same
    file, we can end up scribbling over the stateid that represents the
    new open state.
    The race looks like:

    Client Server
    ====== ======

    CLOSE stateid A on file "foo"
    CLOSE stateid A, return stateid C
    OPEN file "foo"
    OPEN "foo", return stateid B
    Receive reply to OPEN
    Reset open state for "foo"
    Associate stateid B to "foo"

    Receive CLOSE for A
    Reset open state for "foo"
    Replace stateid B with C

    The fix is to examine the argument of the CLOSE, and check for a match
    with the current stateid "other" field. If the two do not match, then
    the above race occurred, and we should just ignore the CLOSE.

    Reported-by: Benjamin Coddington
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker

    Trond Myklebust
     
  • We don't want to call nfs4_free_revoked_stateid() in the case where
    the delegreturn was successful.

    Reported-by: Benjamin Coddington
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker

    Trond Myklebust
     

18 Nov, 2016

3 commits

  • Make struct pernet_operations::id unsigned.

    There are 2 reasons to do so:

    1)
    This field is really an index into an zero based array and
    thus is unsigned entity. Using negative value is out-of-bound
    access by definition.

    2)
    On x86_64 unsigned 32-bit data which are mixed with pointers
    via array indexing or offsets added or subtracted to pointers
    are preffered to signed 32-bit data.

    "int" being used as an array index needs to be sign-extended
    to 64-bit before being used.

    void f(long *p, int i)
    {
    g(p[i]);
    }

    roughly translates to

    movsx rsi, esi
    mov rdi, [rsi+...]
    call g

    MOVSX is 3 byte instruction which isn't necessary if the variable is
    unsigned because x86_64 is zero extending by default.

    Now, there is net_generic() function which, you guessed it right, uses
    "int" as an array index:

    static inline void *net_generic(const struct net *net, int id)
    {
    ...
    ptr = ng->ptr[id - 1];
    ...
    }

    And this function is used a lot, so those sign extensions add up.

    Patch snipes ~1730 bytes on allyesconfig kernel (without all junk
    messing with code generation):

    add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)

    Unfortunately some functions actually grow bigger.
    This is a semmingly random artefact of code generation with register
    allocator being used differently. gcc decides that some variable
    needs to live in new r8+ registers and every access now requires REX
    prefix. Or it is shifted into r12, so [r12+0] addressing mode has to be
    used which is longer than [r8]

    However, overall balance is in negative direction:

    add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
    function old new delta
    nfsd4_lock 3886 3959 +73
    tipc_link_build_proto_msg 1096 1140 +44
    mac80211_hwsim_new_radio 2776 2808 +32
    tipc_mon_rcv 1032 1058 +26
    svcauth_gss_legacy_init 1413 1429 +16
    tipc_bcbase_select_primary 379 392 +13
    nfsd4_exchange_id 1247 1260 +13
    nfsd4_setclientid_confirm 782 793 +11
    ...
    put_client_renew_locked 494 480 -14
    ip_set_sockfn_get 730 716 -14
    geneve_sock_add 829 813 -16
    nfsd4_sequence_done 721 703 -18
    nlmclnt_lookup_host 708 686 -22
    nfsd4_lockt 1085 1063 -22
    nfs_get_client 1077 1050 -27
    tcf_bpf_init 1106 1076 -30
    nfsd4_encode_fattr 5997 5930 -67
    Total: Before=154856051, After=154854321, chg -0.00%

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     
  • Pull vfs fixes from Al Viro:
    "A couple of regression fixes"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fix iov_iter_advance() for ITER_PIPE
    xattr: Fix setting security xattrs on sockfs

    Linus Torvalds
     
  • Pull orangefs fix from Mike Marshall:
    "orangefs: add .owner to debugfs file_operations

    Without ".owner = THIS_MODULE" it is possible to crash the kernel by
    unloading the Orangefs module while someone is reading debugfs files"

    * tag 'for-linus-4.9-rc5-ofs-1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
    orangefs: add .owner to debugfs file_operations

    Linus Torvalds
     

17 Nov, 2016

3 commits

  • The IOP_XATTR flag is set on sockfs because sockfs supports getting the
    "system.sockprotoname" xattr. Since commit 6c6ef9f2, this flag is checked for
    setxattr support as well. This is wrong on sockfs because security xattr
    support there is supposed to be provided by security_inode_setsecurity. The
    smack security module relies on socket labels (xattrs).

    Fix this by adding a security xattr handler on sockfs that returns
    -EAGAIN, and by checking for -EAGAIN in setxattr.

    We cannot simply check for -EOPNOTSUPP in setxattr because there are
    filesystems that neither have direct security xattr support nor support
    via security_inode_setsecurity. A more proper fix might be to move the
    call to security_inode_setsecurity into sockfs, but it's not clear to me
    if that is safe: we would end up calling security_inode_post_setxattr after
    that as well.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     
  • Pull fuse fixes from Miklos Szeredi:
    "A regression fix and bug fix bound for stable"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
    fuse: fix fuse_write_end() if zero bytes were copied
    fuse: fix root dentry initialization

    Linus Torvalds
     
  • Without ".owner = THIS_MODULE" it is possible to crash the kernel
    by unloading the Orangefs module while someone is reading debugfs
    files.

    Signed-off-by: Mike Marshall

    Mike Marshall
     

15 Nov, 2016

2 commits


12 Nov, 2016

7 commits

  • Merge misc fixes from Andrew Morton:
    "15 fixes"

    * emailed patches from Andrew Morton :
    lib/stackdepot: export save/fetch stack for drivers
    mm: kmemleak: scan .data.ro_after_init
    memcg: prevent memcg caches to be both OFF_SLAB & OBJFREELIST_SLAB
    coredump: fix unfreezable coredumping task
    mm/filemap: don't allow partially uptodate page for pipes
    mm/hugetlb: fix huge page reservation leak in private mapping error paths
    ocfs2: fix not enough credit panic
    Revert "console: don't prefer first registered if DT specifies stdout-path"
    mm: hwpoison: fix thp split handling in memory_failure()
    swapfile: fix memory corruption via malformed swapfile
    mm/cma.c: check the max limit for cma allocation
    scripts/bloat-o-meter: fix SIGPIPE
    shmem: fix pageflags after swapping DMA32 object
    mm, frontswap: make sure allocated frontswap map is assigned
    mm: remove extra newline from allocation stall warning

    Linus Torvalds
     
  • Pull VFS fixes from Al Viro:
    "Christoph's and Jan's aio fixes, fixup for generic_file_splice_read
    (removal of pointless detritus that actually breaks it when used for
    gfs2 ->splice_read()) and fixup for generic_file_read_iter()
    interaction with ITER_PIPE destinations."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    splice: remove detritus from generic_file_splice_read()
    mm/filemap: don't allow partially uptodate page for pipes
    aio: fix freeze protection of aio writes
    fs: remove aio_run_iocb
    fs: remove the never implemented aio_fsync file operation
    aio: hold an extra file reference over AIO read/write operations

    Linus Torvalds
     
  • Pull Ceph fixes from Ilya Dryomov:
    "Ceph's ->read_iter() implementation is incompatible with the new
    generic_file_splice_read() code that went into -rc1. Switch to the
    less efficient default_file_splice_read() for now; the proper fix is
    being held for 4.10.

    We also have a fix for a 4.8 regression and a trival libceph fixup"

    * tag 'ceph-for-4.9-rc5' of git://github.com/ceph/ceph-client:
    libceph: initialize last_linger_id with a large integer
    libceph: fix legacy layout decode with pool 0
    ceph: use default file splice read callback

    Linus Torvalds
     
  • Pull NFS client bugfixes from Anna Schumaker:
    "Most of these fix regressions in 4.9, and none are going to stable
    this time around.

    Bugfixes:
    - Trim extra slashes in v4 nfs_paths to fix tools that use this
    - Fix a -Wmaybe-uninitialized warnings
    - Fix suspicious RCU usages
    - Fix Oops when mounting multiple servers at once
    - Suppress a false-positive pNFS error
    - Fix a DMAR failure in NFS over RDMA"

    * tag 'nfs-for-4.9-3' of git://git.linux-nfs.org/projects/anna/linux-nfs:
    xprtrdma: Fix DMAR failure in frwr_op_map() after reconnect
    fs/nfs: Fix used uninitialized warn in nfs4_slot_seqid_in_use()
    NFS: Don't print a pNFS error if we aren't using pNFS
    NFS: Ignore connections that have cl_rpcclient uninitialized
    SUNRPC: Fix suspicious RCU usage
    NFSv4.1: work around -Wmaybe-uninitialized warning
    NFS: Trim extra slash in v4 nfs_path

    Linus Torvalds
     
  • …rnel/git/dgc/linux-xfs

    Pull xfs fix from Dave Chinner:
    "This is a fix for an unmount hang (regression) when the filesystem is
    shutdown. It was supposed to go to you for -rc3, but I accidentally
    tagged the commit prior to it in that pullreq.

    Summary:

    - fix for aborting deferred transactions on filesystem shutdown"

    * tag 'xfs-fixes-for-linus-4.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs:
    xfs: defer should abort intent items if the trans roll fails

    Linus Torvalds
     
  • It could be not possible to freeze coredumping task when it waits for
    'core_state->startup' completion, because threads are frozen in
    get_signal() before they got a chance to complete 'core_state->startup'.

    Inability to freeze a task during suspend will cause suspend to fail.
    Also CRIU uses cgroup freezer during dump operation. So with an
    unfreezable task the CRIU dump will fail because it waits for a
    transition from 'FREEZING' to 'FROZEN' state which will never happen.

    Use freezer_do_not_count() to tell freezer to ignore coredumping task
    while it waits for core_state->startup completion.

    Link: http://lkml.kernel.org/r/1475225434-3753-1-git-send-email-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Acked-by: Pavel Machek
    Acked-by: Oleg Nesterov
    Cc: Alexander Viro
    Cc: Tejun Heo
    Cc: "Rafael J. Wysocki"
    Cc: Michal Hocko
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • The following panic was caught when run ocfs2 disconfig single test
    (block size 512 and cluster size 8192). ocfs2_journal_dirty() return
    -ENOSPC, that means credits were used up.

    The total credit should include 3 times of "num_dx_leaves" from
    ocfs2_dx_dir_rebalance(), because 2 times will be consumed in
    ocfs2_dx_dir_transfer_leaf() and 1 time will be consumed in
    ocfs2_dx_dir_new_cluster() -> __ocfs2_dx_dir_new_cluster() ->
    ocfs2_dx_dir_format_cluster(). But only two times is included in
    ocfs2_dx_dir_rebalance_credits(), fix it.

    This can cause read-only fs(v4.1+) or panic for mainline linux depending
    on mount option.

    ------------[ cut here ]------------
    kernel BUG at fs/ocfs2/journal.c:775!
    invalid opcode: 0000 [#1] SMP
    Modules linked in: ocfs2 nfsd lockd grace nfs_acl auth_rpcgss sunrpc autofs4 ocfs2_dlmfs ocfs2_stack_o2cb ocfs2_dlm ocfs2_nodemanager ocfs2_stackglue configfs sd_mod sg ip6t_REJECT nf_reject_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables be2iscsi iscsi_boot_sysfs bnx2i cnic uio cxgb4i cxgb4 cxgb3i libcxgbi cxgb3 mdio ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr ipv6 iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ppdev xen_kbdfront xen_netfront fb_sys_fops sysimgblt sysfillrect syscopyarea parport_pc parport acpi_cpufreq i2c_piix4 i2c_core pcspkr ext4 jbd2 mbcache xen_blkfront floppy pata_acpi ata_generic ata_piix dm_mirror dm_region_hash dm_log dm_mod
    CPU: 2 PID: 10601 Comm: dd Not tainted 4.1.12-71.el6uek.bug24939243.x86_64 #2
    Hardware name: Xen HVM domU, BIOS 4.4.4OVM 02/11/2016
    task: ffff8800b6de6200 ti: ffff8800a7d48000 task.ti: ffff8800a7d48000
    RIP: ocfs2_journal_dirty+0xa7/0xb0 [ocfs2]
    RSP: 0018:ffff8800a7d4b6d8 EFLAGS: 00010286
    RAX: 00000000ffffffe4 RBX: 00000000814d0a9c RCX: 00000000000004f9
    RDX: ffffffffa008e990 RSI: ffffffffa008f1ee RDI: ffff8800622b6460
    RBP: ffff8800a7d4b6f8 R08: ffffffffa008f288 R09: ffff8800622b6460
    R10: 0000000000000000 R11: 0000000000000282 R12: 0000000002c8421e
    R13: ffff88006d0cad00 R14: ffff880092beef60 R15: 0000000000000070
    FS: 00007f9b83e92700(0000) GS:ffff8800be880000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fb2c0d1a000 CR3: 0000000008f80000 CR4: 00000000000406e0
    Call Trace:
    ocfs2_dx_dir_transfer_leaf+0x159/0x1a0 [ocfs2]
    ocfs2_dx_dir_rebalance+0xd9b/0xea0 [ocfs2]
    ocfs2_find_dir_space_dx+0xd3/0x300 [ocfs2]
    ocfs2_prepare_dx_dir_for_insert+0x219/0x450 [ocfs2]
    ocfs2_prepare_dir_for_insert+0x1d6/0x580 [ocfs2]
    ocfs2_mknod+0x5a2/0x1400 [ocfs2]
    ocfs2_create+0x73/0x180 [ocfs2]
    vfs_create+0xd8/0x100
    lookup_open+0x185/0x1c0
    do_last+0x36d/0x780
    path_openat+0x92/0x470
    do_filp_open+0x4a/0xa0
    do_sys_open+0x11a/0x230
    SyS_open+0x1e/0x20
    system_call_fastpath+0x12/0x71
    Code: 1d 3f 29 09 00 48 85 db 74 1f 48 8b 03 0f 1f 80 00 00 00 00 48 8b 7b 08 48 83 c3 10 4c 89 e6 ff d0 48 8b 03 48 85 c0 75 eb eb 90 0b eb fe 0f 1f 44 00 00 55 48 89 e5 41 57 41 56 41 55 41 54
    RIP ocfs2_journal_dirty+0xa7/0xb0 [ocfs2]
    ---[ end trace 91ac5312a6ee1288 ]---
    Kernel panic - not syncing: Fatal exception
    Kernel Offset: disabled

    Link: http://lkml.kernel.org/r/1478248135-31963-1-git-send-email-junxiao.bi@oracle.com
    Signed-off-by: Junxiao Bi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Joseph Qi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Junxiao Bi