1. 03 Jun, 2021 3 commits
  2. 02 Jun, 2021 26 commits
  3. 31 May, 2021 1 commit
  4. 29 May, 2021 6 commits
  5. 28 May, 2021 4 commits
    • Gioh Kim's avatar
      RDMA/rtrs-clt: Fix memory leak of not-freed sess->stats and stats->pcpu_stats · 7ecd7e29
      Gioh Kim authored
      sess->stats and sess->stats->pcpu_stats objects are freed
      when sysfs entry is removed. If something wrong happens and
      session is closed before sysfs entry is created,
      sess->stats and sess->stats->pcpu_stats objects are not freed.
      
      This patch adds freeing of them at three places:
      1. When client uses wrong address and session creation fails.
      2. When client fails to create a sysfs entry.
      3. When client adds wrong address via sysfs add_path.
      
      Fixes: 215378b8 ("RDMA/rtrs: client: sysfs interface functions")
      Link: https://lore.kernel.org/r/20210528113018.52290-21-jinpu.wang@ionos.comSigned-off-by: default avatarGioh Kim <gi-oh.kim@ionos.com>
      Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      7ecd7e29
    • Md Haris Iqbal's avatar
      RDMA/rtrs-clt: Check if the queue_depth has changed during a reconnection · 5b73b799
      Md Haris Iqbal authored
      The queue_depth is a module parameter for rtrs_server. It is used on the
      client side to determing the queue_depth of the request queue for the RNBD
      virtual block device.
      
      During a reconnection event for an already mapped device, in case the
      rtrs_server module queue_depth has changed, fail the reconnect attempt.
      
      Also stop further auto reconnection attempts. A manual reconnect via
      sysfs has to be triggerred.
      
      Fixes: 6a98d71d ("RDMA/rtrs: client: main functionality")
      Link: https://lore.kernel.org/r/20210528113018.52290-20-jinpu.wang@ionos.comSigned-off-by: default avatarMd Haris Iqbal <haris.iqbal@ionos.com>
      Signed-off-by: default avatarGioh Kim <gi-oh.kim@ionos.com>
      Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      5b73b799
    • Jack Wang's avatar
      RDMA/rtrs-srv: Fix memory leak when having multiple sessions · 6bb97a2c
      Jack Wang authored
      Gioh notice memory leak below
      unreferenced object 0xffff8880acda2000 (size 2048):
        comm "kworker/4:1", pid 77, jiffies 4295062871 (age 1270.730s)
        hex dump (first 32 bytes):
          00 20 da ac 80 88 ff ff 00 20 da ac 80 88 ff ff  . ....... ......
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000e85d85b5>] rtrs_srv_rdma_cm_handler+0x8e5/0xa90 [rtrs_server]
          [<00000000e31a988a>] cma_ib_req_handler+0xdc5/0x2b50 [rdma_cm]
          [<000000000eb02c5b>] cm_process_work+0x2d/0x100 [ib_cm]
          [<00000000e1650ca9>] cm_req_handler+0x11bc/0x1c40 [ib_cm]
          [<000000009c28818b>] cm_work_handler+0xe65/0x3cf2 [ib_cm]
          [<000000002b53eaa1>] process_one_work+0x4bc/0x980
          [<00000000da3499fb>] worker_thread+0x78/0x5c0
          [<00000000167127a4>] kthread+0x191/0x1e0
          [<0000000060802104>] ret_from_fork+0x3a/0x50
      unreferenced object 0xffff88806d595d90 (size 8):
        comm "kworker/4:1H", pid 131, jiffies 4295062972 (age 1269.720s)
        hex dump (first 8 bytes):
          62 6c 61 00 6b 6b 6b a5                          bla.kkk.
        backtrace:
          [<000000004447d253>] kstrdup+0x2e/0x60
          [<0000000047259793>] kobject_set_name_vargs+0x2f/0xb0
          [<00000000c2ee3bc8>] dev_set_name+0xab/0xe0
          [<000000002b6bdfb1>] rtrs_srv_create_sess_files+0x260/0x290 [rtrs_server]
          [<0000000075d87bd7>] rtrs_srv_info_req_done+0x71b/0x960 [rtrs_server]
          [<00000000ccdf1bb5>] __ib_process_cq+0x94/0x100 [ib_core]
          [<00000000cbcb60cb>] ib_cq_poll_work+0x32/0xc0 [ib_core]
          [<000000002b53eaa1>] process_one_work+0x4bc/0x980
          [<00000000da3499fb>] worker_thread+0x78/0x5c0
          [<00000000167127a4>] kthread+0x191/0x1e0
          [<0000000060802104>] ret_from_fork+0x3a/0x50
      unreferenced object 0xffff88806d6bb100 (size 256):
        comm "kworker/4:1H", pid 131, jiffies 4295062972 (age 1269.720s)
        hex dump (first 32 bytes):
          00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .....N..........
          ff ff ff ff ff ff ff ff 00 59 4d 86 ff ff ff ff  .........YM.....
        backtrace:
          [<00000000a18a11e4>] device_add+0x74d/0xa00
          [<00000000a915b95f>] rtrs_srv_create_sess_files.cold+0x49/0x1fe [rtrs_server]
          [<0000000075d87bd7>] rtrs_srv_info_req_done+0x71b/0x960 [rtrs_server]
          [<00000000ccdf1bb5>] __ib_process_cq+0x94/0x100 [ib_core]
          [<00000000cbcb60cb>] ib_cq_poll_work+0x32/0xc0 [ib_core]
          [<000000002b53eaa1>] process_one_work+0x4bc/0x980
          [<00000000da3499fb>] worker_thread+0x78/0x5c0
          [<00000000167127a4>] kthread+0x191/0x1e0
          [<0000000060802104>] ret_from_fork+0x3a/0x50
      
      The problem is we increase device refcount by get_device in process_info_req
      for each path, but only does put_deice for last path, which lead to
      memory leak.
      
      To fix it, it also calls put_device when dev_ref is not 0.
      
      Fixes: e2853c49 ("RDMA/rtrs-srv-sysfs: fix missing put_device")
      Link: https://lore.kernel.org/r/20210528113018.52290-19-jinpu.wang@ionos.comSigned-off-by: default avatarGioh Kim <gi-oh.kim@ionos.com>
      Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      6bb97a2c
    • Gioh Kim's avatar
      RDMA/rtrs-srv: Fix memory leak of unfreed rtrs_srv_stats object · 2371c403
      Gioh Kim authored
      When closing a session, currently the rtrs_srv_stats object in the
      closing session is freed by kobject release. But if it failed
      to create a session by various reasons, it must free the rtrs_srv_stats
      object directly because kobject is not created yet.
      
      This problem is found by kmemleak as below:
      
      1. One client machine maps /dev/nullb0 with session name 'bla':
      root@test1:~# echo "sessname=bla path=ip:192.168.122.190 \
      device_path=/dev/nullb0" > /sys/devices/virtual/rnbd-client/ctl/map_device
      
      2. Another machine failed to create a session with the same name 'bla':
      root@test2:~# echo "sessname=bla path=ip:192.168.122.190 \
      device_path=/dev/nullb1" > /sys/devices/virtual/rnbd-client/ctl/map_device
      -bash: echo: write error: Connection reset by peer
      
      3. The kmemleak on server machine reported an error:
      unreferenced object 0xffff888033cdc800 (size 128):
        comm "kworker/2:1", pid 83, jiffies 4295086585 (age 2508.680s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000a72903b2>] __alloc_sess+0x1d4/0x1250 [rtrs_server]
          [<00000000d1e5321e>] rtrs_srv_rdma_cm_handler+0xc31/0xde0 [rtrs_server]
          [<00000000bb2f6e7e>] cma_ib_req_handler+0xdc5/0x2b50 [rdma_cm]
          [<00000000e896235d>] cm_process_work+0x2d/0x100 [ib_cm]
          [<00000000b6866c5f>] cm_req_handler+0x11bc/0x1c40 [ib_cm]
          [<000000005f5dd9aa>] cm_work_handler+0xe65/0x3cf2 [ib_cm]
          [<00000000610151e7>] process_one_work+0x4bc/0x980
          [<00000000541e0f77>] worker_thread+0x78/0x5c0
          [<00000000423898ca>] kthread+0x191/0x1e0
          [<000000005a24b239>] ret_from_fork+0x3a/0x50
      
      Fixes: 39c2d639 ("RDMA/rtrs-srv: Set .release function for rtrs srv device during device init")
      Link: https://lore.kernel.org/r/20210528113018.52290-18-jinpu.wang@ionos.comSigned-off-by: default avatarGioh Kim <gi-oh.kim@ionos.com>
      Signed-off-by: default avatarMd Haris Iqbal <haris.iqbal@ionos.com>
      Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      2371c403