1. 26 Jun, 2020 4 commits
    • Junxiao Bi's avatar
      ocfs2: fix value of OCFS2_INVALID_SLOT · 9277f833
      Junxiao Bi authored
      In the ocfs2 disk layout, slot number is 16 bits, but in ocfs2
      implementation, slot number is 32 bits.  Usually this will not cause any
      issue, because slot number is converted from u16 to u32, but
      OCFS2_INVALID_SLOT was defined as -1, when an invalid slot number from
      disk was obtained, its value was (u16)-1, and it was converted to u32.
      Then the following checking in get_local_system_inode will be always
      skipped:
      
       static struct inode **get_local_system_inode(struct ocfs2_super *osb,
                                                     int type,
                                                     u32 slot)
       {
       	BUG_ON(slot == OCFS2_INVALID_SLOT);
      	...
       }
      
      Link: http://lkml.kernel.org/r/20200616183829.87211-5-junxiao.bi@oracle.comSigned-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9277f833
    • Junxiao Bi's avatar
      ocfs2: fix panic on nfs server over ocfs2 · e5a15e17
      Junxiao Bi authored
      The following kernel panic was captured when running nfs server over
      ocfs2, at that time ocfs2_test_inode_bit() was checking whether one
      inode locating at "blkno" 5 was valid, that is ocfs2 root inode, its
      "suballoc_slot" was OCFS2_INVALID_SLOT(65535) and it was allocted from
      //global_inode_alloc, but here it wrongly assumed that it was got from per
      slot inode alloctor which would cause array overflow and trigger kernel
      panic.
      
        BUG: unable to handle kernel paging request at 0000000000001088
        IP: [<ffffffff816f6898>] _raw_spin_lock+0x18/0xf0
        PGD 1e06ba067 PUD 1e9e7d067 PMD 0
        Oops: 0002 [#1] SMP
        CPU: 6 PID: 24873 Comm: nfsd Not tainted 4.1.12-124.36.1.el6uek.x86_64 #2
        Hardware name: Huawei CH121 V3/IT11SGCA1, BIOS 3.87 02/02/2018
        RIP: _raw_spin_lock+0x18/0xf0
        RSP: e02b:ffff88005ae97908  EFLAGS: 00010206
        RAX: ffff88005ae98000 RBX: 0000000000001088 RCX: 0000000000000000
        RDX: 0000000000020000 RSI: 0000000000000009 RDI: 0000000000001088
        RBP: ffff88005ae97928 R08: 0000000000000000 R09: ffff880212878e00
        R10: 0000000000007ff0 R11: 0000000000000000 R12: 0000000000001088
        R13: ffff8800063c0aa8 R14: ffff8800650c27d0 R15: 000000000000ffff
        FS:  0000000000000000(0000) GS:ffff880218180000(0000) knlGS:ffff880218180000
        CS:  e033 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000001088 CR3: 00000002033d0000 CR4: 0000000000042660
        Call Trace:
          igrab+0x1e/0x60
          ocfs2_get_system_file_inode+0x63/0x3a0 [ocfs2]
          ocfs2_test_inode_bit+0x328/0xa00 [ocfs2]
          ocfs2_get_parent+0xba/0x3e0 [ocfs2]
          reconnect_path+0xb5/0x300
          exportfs_decode_fh+0xf6/0x2b0
          fh_verify+0x350/0x660 [nfsd]
          nfsd4_putfh+0x4d/0x60 [nfsd]
          nfsd4_proc_compound+0x3d3/0x6f0 [nfsd]
          nfsd_dispatch+0xe0/0x290 [nfsd]
          svc_process_common+0x412/0x6a0 [sunrpc]
          svc_process+0x123/0x210 [sunrpc]
          nfsd+0xff/0x170 [nfsd]
          kthread+0xcb/0xf0
          ret_from_fork+0x61/0x90
        Code: 83 c2 02 0f b7 f2 e8 18 dc 91 ff 66 90 eb bf 0f 1f 40 00 55 48 89 e5 41 56 41 55 41 54 53 0f 1f 44 00 00 48 89 fb ba 00 00 02 00 <f0> 0f c1 17 89 d0 45 31 e4 45 31 ed c1 e8 10 66 39 d0 41 89 c6
        RIP   _raw_spin_lock+0x18/0xf0
        CR2: 0000000000001088
        ---[ end trace 7264463cd1aac8f9 ]---
        Kernel panic - not syncing: Fatal exception
      
      Link: http://lkml.kernel.org/r/20200616183829.87211-4-junxiao.bi@oracle.comSigned-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e5a15e17
    • Junxiao Bi's avatar
      ocfs2: load global_inode_alloc · 7569d3c7
      Junxiao Bi authored
      Set global_inode_alloc as OCFS2_FIRST_ONLINE_SYSTEM_INODE, that will
      make it load during mount.  It can be used to test whether some
      global/system inodes are valid.  One use case is that nfsd will test
      whether root inode is valid.
      
      Link: http://lkml.kernel.org/r/20200616183829.87211-3-junxiao.bi@oracle.comSigned-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7569d3c7
    • Junxiao Bi's avatar
      ocfs2: avoid inode removal while nfsd is accessing it · 4cd9973f
      Junxiao Bi authored
      Patch series "ocfs2: fix nfsd over ocfs2 issues", v2.
      
      This is a series of patches to fix issues on nfsd over ocfs2.  patch 1
      is to avoid inode removed while nfsd access it patch 2 & 3 is to fix a
      panic issue.
      
      This patch (of 4):
      
      When nfsd is getting file dentry using handle or parent dentry of some
      dentry, one cluster lock is used to avoid inode removed from other node,
      but it still could be removed from local node, so use a rw lock to avoid
      this.
      
      Link: http://lkml.kernel.org/r/20200616183829.87211-1-junxiao.bi@oracle.com
      Link: http://lkml.kernel.org/r/20200616183829.87211-2-junxiao.bi@oracle.comSigned-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4cd9973f
  2. 12 Jun, 2020 1 commit
    • Tom Seewald's avatar
      ocfs2: fix build failure when TCP/IP is disabled · fce1affe
      Tom Seewald authored
      After commit 12abc5ee ("tcp: add tcp_sock_set_nodelay") and commit
      c488aead ("tcp: add tcp_sock_set_user_timeout"), building the kernel
      with OCFS2_FS=y but without INET=y causes it to fail with:
      
        ld: fs/ocfs2/cluster/tcp.o: in function `o2net_accept_many':
        tcp.c:(.text+0x21b1): undefined reference to `tcp_sock_set_nodelay'
        ld: tcp.c:(.text+0x21c1): undefined reference to `tcp_sock_set_user_timeout'
        ld: fs/ocfs2/cluster/tcp.o: in function `o2net_start_connect':
        tcp.c:(.text+0x2633): undefined reference to `tcp_sock_set_nodelay'
        ld: tcp.c:(.text+0x2643): undefined reference to `tcp_sock_set_user_timeout'
      
      This is due to tcp_sock_set_nodelay() and tcp_sock_set_user_timeout()
      being declared in linux/tcp.h and defined in net/ipv4/tcp.c, which
      depend on TCP/IP being enabled.
      
      To fix this, make OCFS2_FS depend on INET=y which already requires
      NET=y.
      
      Fixes: 12abc5ee ("tcp: add tcp_sock_set_nodelay")
      Fixes: c488aead ("tcp: add tcp_sock_set_user_timeout")
      Signed-off-by: default avatarTom Seewald <tseewald@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Sagi Grimberg <sagi@grimberg.me>
      Cc: Jason Gunthorpe <jgg@mellanox.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Link: http://lkml.kernel.org/r/20200606190827.23954-1-tseewald@gmail.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fce1affe
  3. 11 Jun, 2020 1 commit
  4. 04 Jun, 2020 2 commits
  5. 02 Jun, 2020 3 commits
  6. 28 May, 2020 2 commits
  7. 22 May, 2020 1 commit
  8. 09 May, 2020 1 commit
  9. 23 Apr, 2020 2 commits
  10. 20 Apr, 2020 1 commit
  11. 10 Apr, 2020 1 commit
  12. 02 Apr, 2020 15 commits
  13. 04 Feb, 2020 2 commits
    • Masahiro Yamada's avatar
      treewide: remove redundant IS_ERR() before error code check · 45586c70
      Masahiro Yamada authored
      'PTR_ERR(p) == -E*' is a stronger condition than IS_ERR(p).
      Hence, IS_ERR(p) is unneeded.
      
      The semantic patch that generates this commit is as follows:
      
      // <smpl>
      @@
      expression ptr;
      constant error_code;
      @@
      -IS_ERR(ptr) && (PTR_ERR(ptr) == - error_code)
      +PTR_ERR(ptr) == - error_code
      // </smpl>
      
      Link: http://lkml.kernel.org/r/20200106045833.1725-1-masahiroy@kernel.orgSigned-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Cc: Julia Lawall <julia.lawall@lip6.fr>
      Acked-by: Stephen Boyd <sboyd@kernel.org> [drivers/clk/clk.c]
      Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> [GPIO]
      Acked-by: Wolfram Sang <wsa@the-dreams.de> [drivers/i2c]
      Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> [acpi/scan.c]
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Cc: Eric Biggers <ebiggers@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      45586c70
    • Gang He's avatar
      ocfs2: fix oops when writing cloned file · 2d797e9f
      Gang He authored
      Writing a cloned file triggers a kernel oops and the user-space command
      process is also killed by the system.  The bug can be reproduced stably
      via:
      
      1) create a file under ocfs2 file system directory.
      
        journalctl -b > aa.txt
      
      2) create a cloned file for this file.
      
        reflink aa.txt bb.txt
      
      3) write the cloned file with dd command.
      
        dd if=/dev/zero of=bb.txt bs=512 count=1 conv=notrunc
      
      The dd command is killed by the kernel, then you can see the oops message
      via dmesg command.
      
      [  463.875404] BUG: kernel NULL pointer dereference, address: 0000000000000028
      [  463.875413] #PF: supervisor read access in kernel mode
      [  463.875416] #PF: error_code(0x0000) - not-present page
      [  463.875418] PGD 0 P4D 0
      [  463.875425] Oops: 0000 [#1] SMP PTI
      [  463.875431] CPU: 1 PID: 2291 Comm: dd Tainted: G           OE     5.3.16-2-default
      [  463.875433] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
      [  463.875500] RIP: 0010:ocfs2_refcount_cow+0xa4/0x5d0 [ocfs2]
      [  463.875505] Code: 06 89 6c 24 38 89 eb f6 44 24 3c 02 74 be 49 8b 47 28
      [  463.875508] RSP: 0018:ffffa2cb409dfce8 EFLAGS: 00010202
      [  463.875512] RAX: ffff8b1ebdca8000 RBX: 0000000000000001 RCX: ffff8b1eb73a9df0
      [  463.875515] RDX: 0000000000056a01 RSI: 0000000000000000 RDI: 0000000000000000
      [  463.875517] RBP: 0000000000000001 R08: ffff8b1eb73a9de0 R09: 0000000000000000
      [  463.875520] R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
      [  463.875522] R13: ffff8b1eb922f048 R14: 0000000000000000 R15: ffff8b1eb922f048
      [  463.875526] FS:  00007f8f44d15540(0000) GS:ffff8b1ebeb00000(0000) knlGS:0000000000000000
      [  463.875529] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  463.875532] CR2: 0000000000000028 CR3: 000000003c17a000 CR4: 00000000000006e0
      [  463.875546] Call Trace:
      [  463.875596]  ? ocfs2_inode_lock_full_nested+0x18b/0x960 [ocfs2]
      [  463.875648]  ocfs2_file_write_iter+0xaf8/0xc70 [ocfs2]
      [  463.875672]  new_sync_write+0x12d/0x1d0
      [  463.875688]  vfs_write+0xad/0x1a0
      [  463.875697]  ksys_write+0xa1/0xe0
      [  463.875710]  do_syscall_64+0x60/0x1f0
      [  463.875743]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
      [  463.875758] RIP: 0033:0x7f8f4482ed44
      [  463.875762] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 80 00 00 00
      [  463.875765] RSP: 002b:00007fff300a79d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      [  463.875769] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f8f4482ed44
      [  463.875771] RDX: 0000000000000200 RSI: 000055f771b5c000 RDI: 0000000000000001
      [  463.875774] RBP: 0000000000000200 R08: 00007f8f44af9c78 R09: 0000000000000003
      [  463.875776] R10: 000000000000089f R11: 0000000000000246 R12: 000055f771b5c000
      [  463.875779] R13: 0000000000000200 R14: 0000000000000000 R15: 000055f771b5c000
      
      This regression problem was introduced by commit e74540b2 ("ocfs2:
      protect extent tree in ocfs2_prepare_inode_for_write()").
      
      Link: http://lkml.kernel.org/r/20200121050153.13290-1-ghe@suse.com
      Fixes: e74540b2 ("ocfs2: protect extent tree in ocfs2_prepare_inode_for_write()").
      Signed-off-by: default avatarGang He <ghe@suse.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2d797e9f
  14. 31 Jan, 2020 4 commits
    • wangyan's avatar
      ocfs2: use ocfs2_update_inode_fsync_trans() to access t_tid in handle->h_transaction · 25b69918
      wangyan authored
      For the uniform format, we use ocfs2_update_inode_fsync_trans() to
      access t_tid in handle->h_transaction
      
      Link: http://lkml.kernel.org/r/6ff9a312-5f7d-0e27-fb51-bc4e062fcd97@huawei.comSigned-off-by: default avatarYan Wang <wangyan122@huawei.com>
      Reviewed-by: default avatarJun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      25b69918
    • wangyan's avatar
      ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() · 9f16ca48
      wangyan authored
      I found a NULL pointer dereference in ocfs2_update_inode_fsync_trans(),
      handle->h_transaction may be NULL in this situation:
      
      ocfs2_file_write_iter
        ->__generic_file_write_iter
            ->generic_perform_write
              ->ocfs2_write_begin
                ->ocfs2_write_begin_nolock
                  ->ocfs2_write_cluster_by_desc
                    ->ocfs2_write_cluster
                      ->ocfs2_mark_extent_written
                        ->ocfs2_change_extent_flag
                          ->ocfs2_split_extent
                            ->ocfs2_try_to_merge_extent
                              ->ocfs2_extend_rotate_transaction
                                ->ocfs2_extend_trans
                                  ->jbd2_journal_restart
                                    ->jbd2__journal_restart
                                      // handle->h_transaction is NULL here
                                      ->handle->h_transaction = NULL;
                                      ->start_this_handle
                                        /* journal aborted due to storage
                                           network disconnection, return error */
                                        ->return -EROFS;
                               /* line 3806 in ocfs2_try_to_merge_extent (),
                                  it will ignore ret error. */
                              ->ret = 0;
              ->...
              ->ocfs2_write_end
                ->ocfs2_write_end_nolock
                  ->ocfs2_update_inode_fsync_trans
                    // NULL pointer dereference
                    ->oi->i_sync_tid = handle->h_transaction->t_tid;
      
      The information of NULL pointer dereference as follows:
          JBD2: Detected IO errors while flushing file data on dm-11-45
          Aborting journal on device dm-11-45.
          JBD2: Error -5 detected when updating journal superblock for dm-11-45.
          (dd,22081,3):ocfs2_extend_trans:474 ERROR: status = -30
          (dd,22081,3):ocfs2_try_to_merge_extent:3877 ERROR: status = -30
          Unable to handle kernel NULL pointer dereference at
          virtual address 0000000000000008
          Mem abort info:
            ESR = 0x96000004
            Exception class = DABT (current EL), IL = 32 bits
            SET = 0, FnV = 0
            EA = 0, S1PTW = 0
          Data abort info:
            ISV = 0, ISS = 0x00000004
            CM = 0, WnR = 0
          user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000e74e1338
          [0000000000000008] pgd=0000000000000000
          Internal error: Oops: 96000004 [#1] SMP
          Process dd (pid: 22081, stack limit = 0x00000000584f35a9)
          CPU: 3 PID: 22081 Comm: dd Kdump: loaded
          Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
          pstate: 60400009 (nZCv daif +PAN -UAO)
          pc : ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
          lr : ocfs2_write_end_nolock+0x2a0/0x550 [ocfs2]
          sp : ffff0000459fba70
          x29: ffff0000459fba70 x28: 0000000000000000
          x27: ffff807ccf7f1000 x26: 0000000000000001
          x25: ffff807bdff57970 x24: ffff807caf1d4000
          x23: ffff807cc79e9000 x22: 0000000000001000
          x21: 000000006c6cd000 x20: ffff0000091d9000
          x19: ffff807ccb239db0 x18: ffffffffffffffff
          x17: 000000000000000e x16: 0000000000000007
          x15: ffff807c5e15bd78 x14: 0000000000000000
          x13: 0000000000000000 x12: 0000000000000000
          x11: 0000000000000000 x10: 0000000000000001
          x9 : 0000000000000228 x8 : 000000000000000c
          x7 : 0000000000000fff x6 : ffff807a308ed6b0
          x5 : ffff7e01f10967c0 x4 : 0000000000000018
          x3 : d0bc661572445600 x2 : 0000000000000000
          x1 : 000000001b2e0200 x0 : 0000000000000000
          Call trace:
           ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
           ocfs2_write_end+0x4c/0x80 [ocfs2]
           generic_perform_write+0x108/0x1a8
           __generic_file_write_iter+0x158/0x1c8
           ocfs2_file_write_iter+0x668/0x950 [ocfs2]
           __vfs_write+0x11c/0x190
           vfs_write+0xac/0x1c0
           ksys_write+0x6c/0xd8
           __arm64_sys_write+0x24/0x30
           el0_svc_common+0x78/0x130
           el0_svc_handler+0x38/0x78
           el0_svc+0x8/0xc
      
      To prevent NULL pointer dereference in this situation, we use
      is_handle_aborted() before using handle->h_transaction->t_tid.
      
      Link: http://lkml.kernel.org/r/03e750ab-9ade-83aa-b000-b9e81e34e539@huawei.comSigned-off-by: default avatarYan Wang <wangyan122@huawei.com>
      Reviewed-by: default avatarJun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f16ca48
    • Andy Shevchenko's avatar
      ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use · dd3e7cba
      Andy Shevchenko authored
      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.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: default avatarSudarsana Reddy Kalluru <skalluru@marvell.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dd3e7cba
    • Colin Ian King's avatar
      ocfs2/dlm: remove redundant assignment to ret · d8f18750
      Colin Ian King authored
      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.comSigned-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d8f18750