03 Jun, 2020

1 commit

  • Sparse reports a warning at dlm_empty_lockres()

    warning: context imbalance in dlm_purge_lockres() - unexpected unlock

    The root cause is the missing annotation at dlm_purge_lockres()

    Add the missing __must_hold(&dlm->spinlock)

    Signed-off-by: Jules Irenge
    Signed-off-by: Andrew Morton
    Reviewed-by: Andrew Morton
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Link: http://lkml.kernel.org/r/20200403160505.2832-4-jbi.octave@gmail.com
    Signed-off-by: Linus Torvalds

    Jules Irenge
     

03 Apr, 2020

4 commits

  • Since snprintf() returns the would-be-output size instead of the actual
    output size, the succeeding calls may go beyond the given buffer limit.
    Fix it by replacing with scnprintf().

    Signed-off-by: Takashi Iwai
    Signed-off-by: Andrew Morton
    Acked-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Link: http://lkml.kernel.org/r/20200311093516.25300-1-tiwai@suse.de
    Signed-off-by: Linus Torvalds

    Takashi Iwai
     
  • The current codebase makes use of the zero-length array language extension
    to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning in
    case the flexible array does not occur last in the structure, which will
    help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by this
    change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://urldefense.com/v3/__https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html__;!!GqivPVa7Brio!OVOYL_CouISa5L1Lw-20EEFQntw6cKMx-j8UdY4z78uYgzKBUFcfpn50GaurvbV5v7YiUA$
    [2] https://urldefense.com/v3/__https://github.com/KSPP/linux/issues/21__;!!GqivPVa7Brio!OVOYL_CouISa5L1Lw-20EEFQntw6cKMx-j8UdY4z78uYgzKBUFcfpn50GaurvbXs8Eh8eg$
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Andrew Morton
    Acked-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Link: http://lkml.kernel.org/r/20200309202016.GA8210@embeddedor
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     
  • This macro has been unused since it was introduced.

    Signed-off-by: Alex Shi
    Signed-off-by: Andrew Morton
    Acked-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Link: http://lkml.kernel.org/r/1579578203-254451-1-git-send-email-alex.shi@linux.alibaba.com
    Signed-off-by: Linus Torvalds

    Alex Shi
     
  • O2HB_DEFAULT_BLOCK_BITS/DLM_THREAD_MAX_ASTS/DLM_MIGRATION_RETRY_MS and
    OCFS2_MAX_RESV_WINDOW_BITS/OCFS2_MIN_RESV_WINDOW_BITS have been unused
    since commit 66effd3c6812 ("ocfs2/dlm: Do not migrate resource to a node
    that is leaving the domain").

    Signed-off-by: Alex Shi
    Signed-off-by: Andrew Morton
    Cc: Greg Kroah-Hartman
    Cc: ChenGang
    Cc: Thomas Gleixner
    Cc: Richard Fontana
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Link: http://lkml.kernel.org/r/1579577827-251796-1-git-send-email-alex.shi@linux.alibaba.com
    Signed-off-by: Linus Torvalds

    Alex Shi
     

01 Feb, 2020

4 commits

  • There are users already and will be more of BITS_TO_BYTES() macro. Move
    it to bitops.h for wider use.

    In the case of ocfs2 the replacement is identical.

    As for bnx2x, there are two places where floor version is used. In the
    first case to calculate the amount of structures that can fit one memory
    page. In this case obviously the ceiling variant is correct and
    original code might have a potential bug, if amount of bits % 8 is not
    0. In the second case the macro is used to calculate bytes transmitted
    in one microsecond. This will work for all speeds which is multiply of
    1Gbps without any change, for the rest new code will give ceiling value,
    for instance 100Mbps will give 13 bytes, while old code gives 12 bytes
    and the arithmetically correct one is 12.5 bytes. Further the value is
    used to setup timer threshold which in any case has its own margins due
    to certain resolution. I don't see here an issue with slightly shifting
    thresholds for low speed connections, the card is supposed to utilize
    highest available rate, which is usually 10Gbps.

    Link: http://lkml.kernel.org/r/20200108121316.22411-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Joseph Qi
    Acked-by: Sudarsana Reddy Kalluru
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • The variable ret is being initialized with a value that is never read
    and it is being updated later with a new value. The initialization is
    redundant and can be removed.

    Addresses Coverity ("Unused value")

    Link: http://lkml.kernel.org/r/20191202164833.62865-1-colin.king@canonical.com
    Signed-off-by: Colin Ian King
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Colin Ian King
     
  • Gang He reports the failure of building fs/ocfs2/ as an external module
    of the kernel installed on the system:

    $ cd fs/ocfs2
    $ make -C /lib/modules/`uname -r`/build M=`pwd` modules

    If you want to make it work reliably, I'd recommend to remove ccflags-y
    from the Makefiles, and to make header paths relative to the C files. I
    think this is the correct usage of the #include "..." directive.

    Link: http://lkml.kernel.org/r/20191227022950.14804-1-ghe@suse.com
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Gang He
    Reported-by: Gang He
    Reviewed-by: Gang He
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masahiro Yamada
     
  • In the only caller of dlm_migrate_lockres() - dlm_empty_lockres(),
    target is checked for O2NM_MAX_NODES. Thus, the assertion in
    dlm_migrate_lockres() is unnecessary and can be removed. The patch
    eliminates such a check.

    Link: http://lkml.kernel.org/r/20191218194111.26041-1-pakki001@umn.edu
    Signed-off-by: Aditya Pakki
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aditya Pakki
     

25 Sep, 2019

2 commits

  • There is a scenario causing ocfs2 umount hang when multiple hosts are
    rebooting at the same time.

    NODE1 NODE2 NODE3
    send unlock requset to NODE2
    dies
    become recovery master
    recover NODE2
    find NODE2 dead
    mark resource RECOVERING
    directly remove lock from grant list
    calculate usage but RECOVERING marked
    **miss the window of purging
    clear RECOVERING

    To reproduce this issue, crash a host and then umount ocfs2
    from another node.

    To solve this, just let unlock progress wait for recovery done.

    Link: http://lkml.kernel.org/r/1550124866-20367-1-git-send-email-gechangwei@live.cn
    Signed-off-by: Changwei Ge
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • There is no need to check return value of debugfs_create functions, but
    the last sweep through ocfs missed a number of places where this was
    happening. There is also no need to save the individual dentries for the
    debugfs files, as everything is can just be removed at once when the
    directory is removed.

    By getting rid of the file dentries for the debugfs entries, a bit of
    local memory can be saved as well.

    [colin.king@canonical.com: ensure ret is set to zero before returning]
    Link: http://lkml.kernel.org/r/20190807121929.28918-1-colin.king@canonical.com
    Link: http://lkml.kernel.org/r/20190731132119.GA12603@kroah.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Colin Ian King
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Jia Guo
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Greg Kroah-Hartman
     

13 Jul, 2019

3 commits

  • When calling debugfs functions, there is no need to ever check the
    return value. The function can work or not, but the code logic should
    never do something different based on this.

    Also, because there is no need to save the file dentry, remove all of
    the variables that were being saved, and just recursively delete the
    whole directory when shutting down, saving a lot of logic and local
    variables.

    [gregkh@linuxfoundation.org: v2]
    Link: http://lkml.kernel.org/r/20190613055455.GE19717@kroah.com
    Link: http://lkml.kernel.org/r/20190612152912.GA19151@kroah.com
    Signed-off-by: Greg Kroah-Hartman
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Joseph Qi
    Cc: Jia Guo
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Greg Kroah-Hartman
     
  • One of the more common cases of allocation size calculations is finding
    the size of a structure that has a zero-sized array at the end, along
    with memory for some number of elements for that array. For example:

    struct dlm_migratable_lockres
    {
    ...
    struct dlm_migratable_lock ml[0]; // 16 bytes each, begins at byte 112
    };

    Make use of the struct_size() helper instead of an open-coded version in
    order to avoid any potential type mistakes.

    So, replace the following form:

    sizeof(struct dlm_migratable_lockres) + (mres->num_locks * sizeof(struct dlm_migratable_lock))

    with:

    struct_size(mres, ml, mres->num_locks)

    Notice that, in this case, variable sz is not necessary, hence it is
    removed.

    This code was detected with the help of Coccinelle.

    Link: http://lkml.kernel.org/r/20190605204926.GA24467@embeddedor
    Signed-off-by: Gustavo A. R. Silva
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     
  • There are some spelling mistakes in ocfs, fix it.

    Link: http://lkml.kernel.org/r/1558964623-106628-1-git-send-email-cg.chen@huawei.com
    Signed-off-by: ChenGang
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: Gang He
    Cc: Jun Piao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    ChenGang
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 021110 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 84 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Richard Fontana
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190524100844.756442981@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


18 May, 2019

1 commit

  • Currently, the Kbuild core manipulates header search paths in a crazy
    way [1].

    To fix this mess, I want all Makefiles to add explicit $(srctree)/ to
    the search paths in the srctree. Some Makefiles are already written in
    that way, but not all. The goal of this work is to make the notation
    consistent, and finally get rid of the gross hacks.

    Having whitespaces after -I does not matter since commit 48f6e3cf5bc6
    ("kbuild: do not drop -I without parameter").

    [1]: https://patchwork.kernel.org/patch/9632347/

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

29 Dec, 2018

1 commit

  • Included file path was hard-wired in the ocfs2 makefile, which might
    causes some confusion when compiling ocfs2 as an external module.

    Say if we compile ocfs2 module as following.
    cp -r /kernel/tree/fs/ocfs2 /other/dir/ocfs2
    cd /other/dir/ocfs2
    make -C /path/to/kernel_source M=`pwd` modules

    Acutally, the compiler wil try to find included file in
    /kernel/tree/fs/ocfs2, rather than the directory /other/dir/ocfs2.

    To fix this little bug, we introduce the var $(src) provided by kbuild.
    $(src) means the absolute path of the running kbuild file.

    Link: http://lkml.kernel.org/r/20181108085546.15149-1-lchen@suse.com
    Signed-off-by: Larry Chen
    Reviewed-by: Andrew Morton
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Larry Chen
     

27 Oct, 2018

2 commits

  • The kernel module may sleep with holding a spinlock.

    The function call paths (from bottom to top) in Linux-4.16 are:

    [FUNC] get_zeroed_page(GFP_NOFS)
    fs/ocfs2/dlm/dlmdebug.c, 332: get_zeroed_page in dlm_print_one_mle
    fs/ocfs2/dlm/dlmmaster.c, 240: dlm_print_one_mle in __dlm_put_mle
    fs/ocfs2/dlm/dlmmaster.c, 255: __dlm_put_mle in dlm_put_mle
    fs/ocfs2/dlm/dlmmaster.c, 254: spin_lock in dlm_put_ml

    [FUNC] get_zeroed_page(GFP_NOFS)
    fs/ocfs2/dlm/dlmdebug.c, 332: get_zeroed_page in dlm_print_one_mle
    fs/ocfs2/dlm/dlmmaster.c, 240: dlm_print_one_mle in __dlm_put_mle
    fs/ocfs2/dlm/dlmmaster.c, 222: __dlm_put_mle in dlm_put_mle_inuse
    fs/ocfs2/dlm/dlmmaster.c, 219: spin_lock in dlm_put_mle_inuse

    To fix this bug, GFP_NOFS is replaced with GFP_ATOMIC.

    This bug is found by my static analysis tool DSAC.

    Link: http://lkml.kernel.org/r/20180901112528.27025-1-baijiaju1990@gmail.com
    Signed-off-by: Jia-Ju Bai
    Reviewed-by: Andrew Morton
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jia-Ju Bai
     
  • Clang warns when more than one set of parentheses is used for a
    single conditional statement:

    fs/ocfs2/dlm/dlmthread.c:534:18: warning: equality comparison with extraneous
    parentheses [-Wparentheses-equality]
    if ((res->owner == dlm->node_num)) {
    ~~~~~~~~~~~^~~~~~~~~~~~~~~~
    fs/ocfs2/dlm/dlmthread.c:534:18: note: remove extraneous parentheses around the
    comparison to silence this warning
    if ((res->owner == dlm->node_num)) {
    ~ ^ ~

    Link: http://lkml.kernel.org/r/20180924181929.6853-1-natechancellor@gmail.com
    Signed-off-by: Nathan Chancellor
    Reported-by: Nick Desaulniers
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nathan Chancellor
     

06 Oct, 2018

1 commit

  • In dlm_init_lockres() we access and modify res->tracking and
    dlm->tracking_list without holding dlm->track_lock. This can cause list
    corruptions and can end up in kernel panic.

    Fix this by locking res->tracking and dlm->tracking_list with
    dlm->track_lock instead of dlm->spinlock.

    Link: http://lkml.kernel.org/r/1529951192-4686-1-git-send-email-ashish.samant@oracle.com
    Signed-off-by: Ashish Samant
    Reviewed-by: Changwei Ge
    Acked-by: Joseph Qi
    Acked-by: Jun Piao
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Ashish Samant
     

13 Jun, 2018

1 commit

  • The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

    kmalloc(a * b, gfp)

    with:
    kmalloc_array(a * b, gfp)

    as well as handling cases of:

    kmalloc(a * b * c, gfp)

    with:

    kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kmalloc(sizeof(THING) * C2, ...)
    |
    kmalloc(sizeof(TYPE) * C2, ...)
    |
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

06 Apr, 2018

10 commits

  • Link: http://lkml.kernel.org/r/1522734135-7933-1-git-send-email-ge.changwei@h3c.com
    Signed-off-by: Changwei Ge
    Acked-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • Inspired by the ocfs2 patch to fix the spelling of migrateable to
    migratable, I checked all ocfs2 files and found more spelling mistakes.
    So correct them all.

    Link: http://lkml.kernel.org/r/1521525734-19576-1-git-send-email-ge.changwei@h3c.com
    Signed-off-by: Changwei Ge
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • Trivial fix to spelling mistake in mlog message text

    Link: http://lkml.kernel.org/r/20180319114101.2051-1-colin.king@canonical.com
    Signed-off-by: Colin Ian King
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Colin Ian King
     
  • Wait for dlm recovery done when migrating all lock resources in case that
    new lock resource left after leaving dlm domain. And the left lock
    resource will cause other nodes BUG.

    NodeA NodeB NodeC

    umount:
    dlm_unregister_domain()
    dlm_migrate_all_locks()

    NodeB down

    do recovery for NodeB
    and collect a new lockres
    form other live nodes:

    dlm_do_recovery
    dlm_remaster_locks
    dlm_request_all_locks:

    dlm_mig_lockres_handler
    dlm_new_lockres
    __dlm_insert_lockres

    at last NodeA become the
    master of the new lockres
    and leave domain:
    dlm_leave_domain()

    mount:
    dlm_join_domain()

    touch file and request
    for the owner of the new
    lockres, but all the
    other nodes said 'NO',
    so NodeC decide to be
    the owner, and send do
    assert msg to other
    nodes:
    dlmlock()
    dlm_get_lock_resource()
    dlm_do_assert_master()

    other nodes receive the msg
    and found two masters exist.
    at last cause BUG in
    dlm_assert_master_handler()
    -->BUG();

    Link: http://lkml.kernel.org/r/5AAA6E25.7090303@huawei.com
    Fixes: bc9838c4d44a ("dlm: allow dlm do recovery during shutdown")
    Signed-off-by: Jun Piao
    Reviewed-by: Alex Chen
    Reviewed-by: Yiwen Jiang
    Acked-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    piaojun
     
  • Link: http://lkml.kernel.org/r/1521116681-14602-2-git-send-email-ge.changwei@h3c.com
    Signed-off-by: Changwei Ge
    Cc: Mark Fasheh
    Cc: Joseph Qi
    Cc: Junxiao Bi
    Cc: Joel Becker
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • Link: http://lkml.kernel.org/r/1521116681-14602-1-git-send-email-ge.changwei@h3c.com
    Signed-off-by: Changwei Ge
    Cc: Mark Fasheh
    Cc: Joseph Qi
    Cc: Junxiao Bi
    Cc: Joel Becker
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • Obviously, the comment before dlm_do_local_recovery_cleanup() has nothing
    to do with it. So remove it.

    Link: http://lkml.kernel.org/r/1519371054-4648-1-git-send-email-ge.changwei@h3c.com
    Signed-off-by: Changwei Ge
    Acked-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • As kmem_cache_destroy() already handles null pointers, so we can remove
    the conditional test entirely.

    Link: http://lkml.kernel.org/r/5A9EB21D.3000209@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Reviewed-by: Andrew Morton
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    piaojun
     
  • We should not handle migrate lockres if we are already in
    'DLM_CTXT_IN_SHUTDOWN', as that will cause lockres remains after leaving
    dlm domain. At last other nodes will get stuck into infinite loop when
    requsting lock from us.

    The problem is caused by concurrency umount between nodes. Before
    receiveing N1's DLM_BEGIN_EXIT_DOMAIN_MSG, N2 has picked up N1 as the
    migrate target. So N2 will continue sending lockres to N1 even though
    N1 has left domain.

    N1 N2 (owner)
    touch file

    access the file,
    and get pr lock

    begin leave domain and
    pick up N1 as new owner

    begin leave domain and
    migrate all lockres done

    begin migrate lockres to N1

    end leave domain, but
    the lockres left
    unexpectedly, because
    migrate task has passed

    [piaojun@huawei.com: v3]
    Link: http://lkml.kernel.org/r/5A9CBD19.5020107@huawei.com
    Link: http://lkml.kernel.org/r/5A99F028.2090902@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Reviewed-by: Joseph Qi
    Reviewed-by: Changwei Ge
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jun Piao
     
  • Remove some unused function declarations in dlmcommon.h.

    Link: http://lkml.kernel.org/r/5A7D1034.7050807@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Reviewed-by: Changwei Ge
    Reviewed-by: Alex Chen
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    piaojun
     

01 Feb, 2018

1 commit

  • This code has been commented out for 12 years. Remove it.

    Link: http://lkml.kernel.org/r/63ADC13FD55D6546B7DECE290D39E373CED7EF9E@H3CMLB14-EX.srv.huawei-3com.com
    Signed-off-by: Changwei Ge
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc: Changwei Ge
    Cc: alex chen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     

16 Nov, 2017

3 commits

  • When dlm_add_migration_mle returns -EEXIST, previously input mle will
    not be initialized. So we can't use its associated dlm object. And we
    truly don't need this mle for already launched migration progress, since
    oldmle has taken this role.

    Link: http://lkml.kernel.org/r/63ADC13FD55D6546B7DECE290D39E373CED7AA61@H3CMLB14-EX.srv.huawei-3com.com
    Signed-off-by: Changwei Ge
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • When a node dies, other live nodes have to choose a new master for an
    existed lock resource mastered by the dead node.

    As for ocfs2/dlm implementation, this is done by function -
    dlm_move_lockres_to_recovery_list which marks those lock rsources as
    DLM_LOCK_RES_RECOVERING and manages them via a list from which DLM
    changes lock resource's master later.

    So without invoking dlm_move_lockres_to_recovery_list, no master will be
    choosed after dlm recovery accomplishment since no lock resource can be
    found through ::resource list.

    What's worse is that if DLM_LOCK_RES_RECOVERING is not marked for lock
    resources mastered a dead node, it will break up synchronization among
    nodes.

    So invoke dlm_move_lockres_to_recovery_list again.

    Fixs: 'commit ee8f7fcbe638 ("ocfs2/dlm: continue to purge recovery lockres when recovery master goes down")'
    Link: http://lkml.kernel.org/r/63ADC13FD55D6546B7DECE290D39E373CED6E0F9@H3CMLB14-EX.srv.huawei-3com.com
    Signed-off-by: Changwei Ge
    Reported-by: Vitaly Mayatskih
    Tested-by: Vitaly Mayatskikh
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Changwei Ge
     
  • destroy_workqueue() will do flushing work for us.

    Link: http://lkml.kernel.org/r/59E06476.3090502@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    piaojun
     

02 Mar, 2017

1 commit


28 Feb, 2017

1 commit


14 Jan, 2017

1 commit

  • Since we need to change the implementation, stop exposing internals.

    Provide kref_read() to read the current reference count; typically
    used for debug messages.

    Kills two anti-patterns:

    atomic_read(&kref->refcount)
    kref->refcount.counter

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

13 Dec, 2016

1 commit

  • When 'dispatch_assert' is set, 'response' must be DLM_MASTER_RESP_YES,
    and 'res' won't be null, so execution can't reach these two branch.

    Link: http://lkml.kernel.org/r/58174C91.3040004@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Joseph Qi Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    piaojun