From patchwork Wed Aug 24 21:38:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Ledford X-Patchwork-Id: 9298401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 551A160757 for ; Wed, 24 Aug 2016 21:40:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3933029131 for ; Wed, 24 Aug 2016 21:40:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15D0229135; Wed, 24 Aug 2016 21:40:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DDB429131 for ; Wed, 24 Aug 2016 21:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754590AbcHXVku (ORCPT ); Wed, 24 Aug 2016 17:40:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42694 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754444AbcHXVkt (ORCPT ); Wed, 24 Aug 2016 17:40:49 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC6BC1359A; Wed, 24 Aug 2016 21:39:00 +0000 (UTC) Received: from linux-ws.xsintricity.com.com (ovpn-116-61.rdu2.redhat.com [10.10.116.61]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7OLcxhn000637; Wed, 24 Aug 2016 17:39:00 -0400 From: Doug Ledford To: linux-rdma@vger.kernel.org Cc: Doug Ledford , Bart Van Assche , nab@linux-iscsi.org Subject: [PATCH] IB/srpt: Update sport->port_guid with each port refresh Date: Wed, 24 Aug 2016 17:38:45 -0400 Message-Id: <716b076ba4b273f5f85c97448c5110c6d21e73e6.1472072382.git.dledford@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 24 Aug 2016 21:39:01 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If port_guid is set with the default subnet_prefix, then we get a change event and run a port refresh, we don't update the port_guid. As a result, attempts to create a target device that uses the new subnet_prefix in the wwn will fail to find a match and be rejected by the ib_srpt driver. This makes it impossible to configure a port if it was initialized with a default subnet_prefix and later changed to any non-default subnet-prefix. Updating the port refresh task to always update the wwn based upon the current subnext_prefix solves this problem. Cc: Bart Van Assche Cc: nab@linux-iscsi.org Signed-off-by: Doug Ledford --- Bart, Nicholas; This doesn't entirely resolve the problem I'm seeing here. It only fixes one part of it, the ability to set the config once the right subnet_prefix is known. There still is the problem of a race condition between the attempt to configure the target subsystem and the subnet_prefix becoming known. It seems what is needed is the ability to enter srpt configuration even if it doesn't match any known WWNs at the moment, and on a port refresh, if the WWN changes, we should drop the current config and reload any other config that the new WWN matches. But I have no idea how to make this happen in the target core. The other option would be to have a user space dispatcher that reloaded the target config on subnet_prefix changes, but the lio code would need modified to be able to restrict the reload to a specific interface or else if the user had changed the config on another port, then a subnet_prefix change occurred, the lio code might wipe out the user's custom changes. --- drivers/infiniband/ulp/srpt/ib_srpt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index dfa23b075a88..883bbfe08e0e 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -522,6 +522,11 @@ static int srpt_refresh_port(struct srpt_port *sport) if (ret) goto err_query_port; + snprintf(sport->port_guid, sizeof(sport->port_guid), + "0x%016llx%016llx", + be64_to_cpu(sport->gid.global.subnet_prefix), + be64_to_cpu(sport->gid.global.interface_id)); + if (!sport->mad_agent) { memset(®_req, 0, sizeof(reg_req)); reg_req.mgmt_class = IB_MGMT_CLASS_DEVICE_MGMT; @@ -2548,10 +2553,6 @@ static void srpt_add_one(struct ib_device *device) sdev->device->name, i); goto err_ring; } - snprintf(sport->port_guid, sizeof(sport->port_guid), - "0x%016llx%016llx", - be64_to_cpu(sport->gid.global.subnet_prefix), - be64_to_cpu(sport->gid.global.interface_id)); } spin_lock(&srpt_dev_lock);