From: Tom Talpey <tom@talpey.com>
To: Namjae Jeon <linkinjeon@kernel.org>, linux-cifs@vger.kernel.org
Cc: smfrench@gmail.com, senozhatsky@chromium.org,
atteh.mailbox@gmail.com, Kangjing Huang <huangkangjing@gmail.com>
Subject: Re: [PATCH] ksmbd: fix missing RDMA-capable flag for IPoIB device in ksmbd_rdma_capable_netdev()
Date: Tue, 17 Oct 2023 10:06:48 -0400 [thread overview]
Message-ID: <11e5bc36-677d-474d-acae-ab7e6ade9b2b@talpey.com> (raw)
In-Reply-To: <20231015144536.9100-1-linkinjeon@kernel.org>
On 10/15/2023 10:45 AM, Namjae Jeon wrote:
> From: Kangjing Huang <huangkangjing@gmail.com>
>
> Physical ib_device does not have an underlying net_device, thus its
> association with IPoIB net_device cannot be retrieved via
> ops.get_netdev() or ib_device_get_by_netdev(). ksmbd reads physical
> ib_device port GUID from the lower 16 bytes of the hardware addresses on
> IPoIB net_device and match its underlying ib_device using ib_find_gid()
>
> Signed-off-by: Kangjing Huang <huangkangjing@gmail.com>
> Acked-by: Namjae Jeon <linkinjeon@kernel.org>
> ---
> fs/smb/server/transport_rdma.c | 39 +++++++++++++++++++++++++---------
> 1 file changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
> index 3b269e1f523a..a82131f7dd83 100644
> --- a/fs/smb/server/transport_rdma.c
> +++ b/fs/smb/server/transport_rdma.c
> @@ -2140,8 +2140,7 @@ static int smb_direct_ib_client_add(struct ib_device *ib_dev)
> if (ib_dev->node_type != RDMA_NODE_IB_CA)
> smb_direct_port = SMB_DIRECT_PORT_IWARP;
>
> - if (!ib_dev->ops.get_netdev ||
> - !rdma_frwr_is_supported(&ib_dev->attrs))
> + if (!rdma_frwr_is_supported(&ib_dev->attrs))
> return 0;
>
> smb_dev = kzalloc(sizeof(*smb_dev), GFP_KERNEL);
> @@ -2241,17 +2240,37 @@ bool ksmbd_rdma_capable_netdev(struct net_device *netdev)
> for (i = 0; i < smb_dev->ib_dev->phys_port_cnt; i++) {
> struct net_device *ndev;
>
> - ndev = smb_dev->ib_dev->ops.get_netdev(smb_dev->ib_dev,
> - i + 1);
> - if (!ndev)
> - continue;
> + /* RoCE and iWRAP ib_dev is backed by a netdev */
> + if (smb_dev->ib_dev->ops.get_netdev) {
The "IWRAP" is a typo, but IMO the comment is misleading. This is simply
looking up the target netdev, it's not limited to these two rdma types.
I suggest deleting the comment.
> + ndev = smb_dev->ib_dev->ops.get_netdev(
> + smb_dev->ib_dev, i + 1);
> + if (!ndev)
> + continue;
>
> - if (ndev == netdev) {
> + if (ndev == netdev) {
> + dev_put(ndev);
> + rdma_capable = true;
> + goto out;
> + }
> dev_put(ndev);
Why not move this dev_put up above the if (ndev == netdev) test? It's
needed in both cases, so it's confusing to have two copies.
> - rdma_capable = true;
> - goto out;
> + /* match physical ib_dev with IPoIB netdev by GUID */
Add more information to this comment, perhaps:
/* if no exact netdev match, check for matching Infiniband GUID */
> + } else if (netdev->type == ARPHRD_INFINIBAND) {
> + struct netdev_hw_addr *ha;
> + union ib_gid gid;
> + u32 port_num;
> + int ret;
> +
> + netdev_hw_addr_list_for_each(
> + ha, &netdev->dev_addrs) {
> + memcpy(&gid, ha->addr + 4, sizeof(gid));
> + ret = ib_find_gid(smb_dev->ib_dev, &gid,
> + &port_num, NULL);
> + if (!ret) {
> + rdma_capable = true;
> + goto out;
Won't this leak the ndev? It needs a dev_put(ndev) before breaking
the loop, too, right?
> + }
> + }
> }
> - dev_put(ndev);
> }
> }
> out:
next prev parent reply other threads:[~2023-10-17 14:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-15 14:45 [PATCH] ksmbd: fix missing RDMA-capable flag for IPoIB device in ksmbd_rdma_capable_netdev() Namjae Jeon
2023-10-17 14:06 ` Tom Talpey [this message]
2023-10-19 6:01 ` Kangjing (Chaser) Huang
2023-10-19 22:37 ` Namjae Jeon
2023-10-20 1:14 ` Tom Talpey
2023-10-20 11:38 ` Kangjing (Chaser) Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11e5bc36-677d-474d-acae-ab7e6ade9b2b@talpey.com \
--to=tom@talpey.com \
--cc=atteh.mailbox@gmail.com \
--cc=huangkangjing@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox