From patchwork Mon Nov 21 08:00:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 23564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1438336wrr; Sun, 20 Nov 2022 23:41:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6vHbjZ20i6bUazzQWoC9ANoxIVq40Q78zg0QRHYXYGvtSWF5LyPasHlFf768z5Rv9UaHoY X-Received: by 2002:a63:1e5b:0:b0:477:3c62:49ba with SMTP id p27-20020a631e5b000000b004773c6249bamr10772362pgm.446.1669016481205; Sun, 20 Nov 2022 23:41:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669016481; cv=none; d=google.com; s=arc-20160816; b=CdBWEVEDMiPL80fg8zrl4f6YaRNxqF9W5DEzjrCr80iB8R6lZrRy6NTUfOgItzb9ws zzAbQ5lhwn5PX18mSrUbn86FhTgxco/BrRg3r9CrPEiYRJcQ1lQrqqOdwvFTSa3AJi2+ fk+OzF+Bj9WtmrTlCInzH8Vet4+LaOEgKoKKw1SU4zuRvY03RfXLFse5s24hFtyHF7h2 qdKs3qK4eK1t3OEb69LFp33q1ZwwXlvzTI/nD73vBLWCImgkyOirq5fpGGGrhwHX2vGB gaogoY/dAExH69VC5tMl1HrOv0QL0B3NNrVcTRQCBCYOO7Z3R6ow6C5XS5+Sczm8Bq1s CRLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=McpiLDtH2jL/ya0Cu7XxKsCyW8kJOl7AY++6cLfmZ+0=; b=FOZaVVCN4vR1taKldLTaP4+8uy27WaQWNTeltgXQe/akKiz8La2J2DgCSciRrLUvzi NSlKNiFPPvRQGw99Yr87we1jjjY2wGtRJRlUYncD2Zml2aDqxbHIfnz6Z3MhEWHxeiWm jgsPBGVli1HUzbo8PKa0CY0a30RlGqRO4takV8ANVWSVD6F50dafUXlDK45ggJWfILav 5c07lUgOBNC71EAEEGe4NdQm4d4MLaQ+kMAp6tNUdhXjpT3QJu5DhS5dHpPEh2W1fkI3 PgxFFNGsLNINM/yg5Dt2JCTxASitq422zRmCD9FmhtFAok9ULauLltvEDQFwAHDEePnX pkJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a170902d2c400b001836e51050esi12174307plc.572.2022.11.20.23.41.07; Sun, 20 Nov 2022 23:41:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbiKUHjp (ORCPT + 99 others); Mon, 21 Nov 2022 02:39:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiKUHji (ORCPT ); Mon, 21 Nov 2022 02:39:38 -0500 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B1D2936F; Sun, 20 Nov 2022 23:39:37 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NFzmg3Sktz4f3mSm; Mon, 21 Nov 2022 15:39:31 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgC329g0K3tj2M2XAw--.53628S5; Mon, 21 Nov 2022 15:39:34 +0800 (CST) From: Ye Bin To: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org, linux_oss@crudebyte.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, yebin10@huawei.com Subject: [PATCH 1/5] 9p: fix miss unmap request in 'rdma_request()' Date: Mon, 21 Nov 2022 16:00:45 +0800 Message-Id: <20221121080049.3850133-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221121080049.3850133-1-yebin@huaweicloud.com> References: <20221121080049.3850133-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgC329g0K3tj2M2XAw--.53628S5 X-Coremail-Antispam: 1UD129KBjvJXoWruw1xtw4DXF1DKr1UAw45trb_yoW8Jr4kpa y8uanIkrZxKr15Ar4xJFZIga4jyF4fCFWUCFW8K3ZxJF4qvryYyF4vk3yYqFyxCFWxAF4r Gryqgas5urWUZFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB0b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU2mL9UUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750090625784746992?= X-GMAIL-MSGID: =?utf-8?q?1750090625784746992?= From: Ye Bin If send request failed or fail to get semaphore will not call 'send_done()', request may miss to unmap. So add unmap handle above error. Signed-off-by: Ye Bin --- net/9p/trans_rdma.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index 6ff706760676..e498208ed72b 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c @@ -500,7 +500,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) if (down_interruptible(&rdma->sq_sem)) { err = -EINTR; - goto send_error; + goto mapping_error; } /* Mark request as `sent' *before* we actually send it, @@ -510,12 +510,15 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) req->status = REQ_STATUS_SENT; err = ib_post_send(rdma->qp, &wr, NULL); if (err) - goto send_error; + goto mapping_error; /* Success */ return 0; /* Handle errors that happened during or while preparing the send: */ + mapping_error: + ib_dma_unmap_single(rdma->cm_id->device, c->busa, + c->req->tc.size, DMA_TO_DEVICE); send_error: req->status = REQ_STATUS_ERROR; kfree(c); From patchwork Mon Nov 21 08:00:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 23563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1438198wrr; Sun, 20 Nov 2022 23:40:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf5nd/zpWeaNiwDUm9Skh9+F1jts3riUO+ttVOR+jER9aqmyO9GfizjdopCYlU+A+Glo8+0F X-Received: by 2002:a62:7b47:0:b0:56c:7b59:5137 with SMTP id w68-20020a627b47000000b0056c7b595137mr4667798pfc.74.1669016454940; Sun, 20 Nov 2022 23:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669016454; cv=none; d=google.com; s=arc-20160816; b=rIYxXvXZu3Vdlx8A2SkQROGxHNpoAAkLLr7LXhp03iAjSA1Z6HcV2cTN9oObr1HJYO DjHOA5szPHi3pV5fD41jXJHfNelCKpfa7D2/K1RNqBVSJCKGR9nkekM+0lasgbMCITUa faaH1RJ6li2OA9z4jnBF1vxZPinVjKZkao2TmNprWRJxPPMZpn3bjc0eMRJDHIqq1Gru mN4Rmd3oOifmDVwA7EeIo+jzGDeYR5acLxGEE9vLcunQQ8cLW6edUFgHINg6vLIRN7jn 04wHnVdPf2tetrsGNeuRojSV9nuYxiK6465redXTGojlJrLqk3Fqq4KyLIK5iw4TwCg1 ME5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1wVFyNh4TdQIJ6vBzCWbE7nqdKPoS4uC8UM8dvKf2QI=; b=bPaoUIaVQ/zDd0o8LF4vBA6PfOpXpoC5plECP6IZ0w9PU+WlEIHeVrbVMb7sj7DlrG 9QmrMd19nFJ0rYY3TN2l9tI2NGi/b4mTKkizhjHJI+MKhWmo62PH04s7qOzp4XcCmL/a bZ2okk7rsqvXU9+r8bF8IXIlIBqUg2JCudnmWqMMi9BLMDnDQ3gVJCI9hVT62enDUi12 7qKRS4GrWEAU3Symd8EBMpNzXbDLkXFEu/K08dkxEi0IFnP0xF7ThTPaPnuRSDlTVMPm Oc+MeBATN6oY8R5ZLMS9Qs8nRsynHV2f3xyhglg7QNw2MvnTtBZ3RcOqUdi/S/bryYAi pZKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a6566d1000000b00476e63cf8a4si11050103pgw.129.2022.11.20.23.40.41; Sun, 20 Nov 2022 23:40:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbiKUHjm (ORCPT + 99 others); Mon, 21 Nov 2022 02:39:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiKUHji (ORCPT ); Mon, 21 Nov 2022 02:39:38 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754582D1DE; Sun, 20 Nov 2022 23:39:37 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NFzmg6YCHz4f3jZb; Mon, 21 Nov 2022 15:39:31 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgC329g0K3tj2M2XAw--.53628S6; Mon, 21 Nov 2022 15:39:34 +0800 (CST) From: Ye Bin To: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org, linux_oss@crudebyte.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, yebin10@huawei.com Subject: [PATCH 2/5] 9p: fix miss release semaphore in 'rdma_request()' Date: Mon, 21 Nov 2022 16:00:46 +0800 Message-Id: <20221121080049.3850133-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221121080049.3850133-1-yebin@huaweicloud.com> References: <20221121080049.3850133-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgC329g0K3tj2M2XAw--.53628S6 X-Coremail-Antispam: 1UD129KBjvdXoW7Gw45Wr4kCw45JF43tF1fWFg_yoW3XwbE9F 4fGan3Xas7Jry7KFWjka1Fvr1kCFWxWr1xurn0ya4jkwn8Xr97Gw1jgr98Ar47CF4DCrW8 Jwn8X3yfWFy3ZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbfxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r15M2 8IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UC9aPUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750090598261724286?= X-GMAIL-MSGID: =?utf-8?q?1750090598261724286?= From: Ye Bin If send request failed will not call 'send_done()', but already get '(&rdma->sq_sem'. So add release '(&rdma->sq_sem' after send request failed. Signed-off-by: Ye Bin --- net/9p/trans_rdma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index e498208ed72b..ae2bac9bf510 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c @@ -509,8 +509,10 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) */ req->status = REQ_STATUS_SENT; err = ib_post_send(rdma->qp, &wr, NULL); - if (err) + if (err) { + up(&rdma->sq_sem); goto mapping_error; + } /* Success */ return 0; From patchwork Mon Nov 21 08:00:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 23565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1438524wrr; Sun, 20 Nov 2022 23:42:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7qzkVZANWWTfmkaLqok4P/CK6o2BAy2WYxOPjk40UT2qzcWyGWOsyJm+vVGYFohwZQ+SyG X-Received: by 2002:a17:902:7688:b0:186:971b:b7e5 with SMTP id m8-20020a170902768800b00186971bb7e5mr11162265pll.54.1669016519882; Sun, 20 Nov 2022 23:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669016519; cv=none; d=google.com; s=arc-20160816; b=Y9VNszdhZ4fi8sagiEYKO2Y1jPqnHhJfvBgkGIS1jqqYVdkjMAxPJKkrCA/0PYwU/A AtEOVzi3kuQUtVDBRKcZsqqQq+0b+s+ndsjK4VPQtNVM+YePwV/igalnguPcaQns7FMl 2eyvCQZ8H8gppbVQfxuo0x1kt/bXafDHxozFql56rzmHMC6Ft8mtKS5Y4npj+sPPRdRb KxXcTX8QWCmBqc4dfRCeTJ5zdnpFc2mIfoovviDzYXreVIyO+9fW6yIygPMx0GlkmXgI y1XmyNLxjrhcoLJwBmfQZoey6wFrfnlsFTYbAJIdhndo2wFi0Ey8MW+Ucb5g8ZHFbIvK KY2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=D9EDMK0V3HmS5IMNjJRqDB76e9Mn+gyUGKKlga21uZk=; b=wKwbb3rYa3OujsJUdzMbMxNjaV3tgwPzNFfPd/wEKSjdAN5Uu+/M9A+sYM8EQV48TH JYuAEP60xQoKUmvOxkCxy4v+DuNFrjBAUBoQkdAGjVoCMun3bJbCqrBhhBUhhTPZC1hx ZAoRt1QJgzLGO8Lj9d2pXf+5ovHXf85iiaS73wXzds/vmZSmcwzenjcFwIL6nNG6NoAy sGF98k4aZRtWrOfjozBmfouOVEdzoujaJoi7XTE+G8bWUG+MZzXHu5MrdZs/Cm36n/GN MLp8qctlxEd2K6FieMHr+E7sUjNJnJnc8wCJvs6XuLpd9i8AsopdbRvu3aZ5y+BUB352 fvLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a631355000000b00476759b8788si10520994pgt.861.2022.11.20.23.41.46; Sun, 20 Nov 2022 23:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiKUHjs (ORCPT + 99 others); Mon, 21 Nov 2022 02:39:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbiKUHji (ORCPT ); Mon, 21 Nov 2022 02:39:38 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F156D2D1E4; Sun, 20 Nov 2022 23:39:37 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NFzmh2tT2z4f3tqC; Mon, 21 Nov 2022 15:39:32 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgC329g0K3tj2M2XAw--.53628S7; Mon, 21 Nov 2022 15:39:35 +0800 (CST) From: Ye Bin To: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org, linux_oss@crudebyte.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, yebin10@huawei.com Subject: [PATCH 3/5] 9p: fix error handle in 'post_recv()' Date: Mon, 21 Nov 2022 16:00:47 +0800 Message-Id: <20221121080049.3850133-4-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221121080049.3850133-1-yebin@huaweicloud.com> References: <20221121080049.3850133-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgC329g0K3tj2M2XAw--.53628S7 X-Coremail-Antispam: 1UD129KBjvJXoW7ur13XF1kWw47ZF45XF1fJFb_yoW8Gw18pF Z3uwsxZr9Igr17Aw4kKayDuFySkrsYkF4fG34jkanxJ3WDtr98KF4Ut3yYqFyxGF4xJF4f Gr1DtayruF1UZrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBYb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7IU1c4S7UUUUU== X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750090666412220123?= X-GMAIL-MSGID: =?utf-8?q?1750090666412220123?= From: Ye Bin There are two issues in 'post_recv()': 1. Miss unmap request if receive request failed; 2. Miss release 'rdma->rq_sem' if post receive failed or mapping failed; So add miss release 'rdma->rq_sem' and unmap request when do error handle. Signed-off-by: Ye Bin --- net/9p/trans_rdma.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index ae2bac9bf510..bcab550c2e2c 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c @@ -386,6 +386,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) struct p9_trans_rdma *rdma = client->trans; struct ib_recv_wr wr; struct ib_sge sge; + int err = -EIO; c->busa = ib_dma_map_single(rdma->cm_id->device, c->rc.sdata, client->msize, @@ -403,11 +404,17 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) wr.wr_cqe = &c->cqe; wr.sg_list = &sge; wr.num_sge = 1; - return ib_post_recv(rdma->qp, &wr, NULL); - + err = ib_post_recv(rdma->qp, &wr, NULL); + if (err) { + ib_dma_unmap_single(rdma->cm_id->device, c->busa, + client->msize, DMA_FROM_DEVICE); + goto error; + } + return 0; error: + up(&rdma->rq_sem); p9_debug(P9_DEBUG_ERROR, "EIO\n"); - return -EIO; + return err; } static int rdma_request(struct p9_client *client, struct p9_req_t *req) From patchwork Mon Nov 21 08:00:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 23566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1438626wrr; Sun, 20 Nov 2022 23:42:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ODpczr1UBRGPpydHmRNiS74nrtIzgTVNGTy+TJkwbq4tWjt04P5N+e5pSdU6q/QhRxbur X-Received: by 2002:aa7:9af5:0:b0:56c:b5fc:9167 with SMTP id y21-20020aa79af5000000b0056cb5fc9167mr18992827pfp.40.1669016538757; Sun, 20 Nov 2022 23:42:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669016538; cv=none; d=google.com; s=arc-20160816; b=kRJdARO2b00NtInYuZbB5fmKvlC7E7/i6PmdVaDVKplaL+CBm5v6kMFqTWpKrUwb7K Mjmgkhlo1z6GoMoRuhM3xWgbNKTHVFNFv1WxYNOYLVQw0MH6h4PLogP/9nLEzDdcgNQ6 /LNL1CId37ha+BqrEE7974NF1+vWsX/mfA15sJifqNml7R13mn3WeE1sXZ/njqeCNEqV nVkjKVrwvxMmdMPwOfe+X5TrpS1FZvJQYR/1zNhnbozaisYzmx82Z1ugsHvRW9b0hLPP PgnReErmn4rG/uq/o+LkhNNf+ZNjdLc8eNMZCCtYpELjKDS9Okf0Koee8NBQJ8XJD3JV CmIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cwxqAXWj63UFC97kH+PoHzV7TZfTp41zB+fNxIQUsr0=; b=vnuVg9g2J4v5LgULL/InBxxtRycgGfY6ykMsMRc04K8kCP+AEhDzJQTrTZbMfXC7xF k6Yd8IsvMG9HBifHqbATfghuLcxxzCAmbYw9U2HwZhmB7GB8U0xdnoQ8tmvN6zvd0+ur SApb29vffG1D81KqCg43TiT8SzoQcUWZIs/14AreIrf9w0g62TnCVGesto4mb+l+9qpk PSrigctodfW46JgMGRLLd7E9WA4bCmZxHl09M6aJkTMbbCsPX1N+vloivUOFUNFPURS0 iWuWkl2jSkBzOk+lFj9yJZfuCLDxkE497omsgsFHZMH8h3oesrNrZ4arg2/O2VABoNbB Ve7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc12-20020a17090b1c0c00b0020169c73d8bsi12046286pjb.2.2022.11.20.23.41.49; Sun, 20 Nov 2022 23:42:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229500AbiKUHju (ORCPT + 99 others); Mon, 21 Nov 2022 02:39:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiKUHjj (ORCPT ); Mon, 21 Nov 2022 02:39:39 -0500 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 764542AE0E; Sun, 20 Nov 2022 23:39:38 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NFzmh6wGQz4f3mTF; Mon, 21 Nov 2022 15:39:32 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgC329g0K3tj2M2XAw--.53628S8; Mon, 21 Nov 2022 15:39:35 +0800 (CST) From: Ye Bin To: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org, linux_oss@crudebyte.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, yebin10@huawei.com Subject: [PATCH 4/5] 9p: factor out 'post_send()' Date: Mon, 21 Nov 2022 16:00:48 +0800 Message-Id: <20221121080049.3850133-5-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221121080049.3850133-1-yebin@huaweicloud.com> References: <20221121080049.3850133-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgC329g0K3tj2M2XAw--.53628S8 X-Coremail-Antispam: 1UD129KBjvJXoWxCrWrXry3CrWrJF17Cr4Uurg_yoWrCr43p3 yrJa9IvrZxKF13Aws5Ka4jgF1Yyr4rCayUtryxCws3AFs0vr90yF4jyayYgFyxAFZ7Ca1r KryDKFZ3CryUZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBab4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aV CY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750090686312921866?= X-GMAIL-MSGID: =?utf-8?q?1750090686312921866?= From: Ye Bin Factor out 'post_send()' to send request. No functional change. Signed-off-by: Ye Bin --- net/9p/trans_rdma.c | 130 +++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 61 deletions(-) diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index bcab550c2e2c..bb917389adc9 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c @@ -417,14 +417,72 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) return err; } -static int rdma_request(struct p9_client *client, struct p9_req_t *req) +static int post_send(struct p9_client *client, struct p9_req_t *req) { struct p9_trans_rdma *rdma = client->trans; + struct p9_rdma_context *c = NULL; struct ib_send_wr wr; struct ib_sge sge; + int err; + + c = kmalloc(sizeof *c, GFP_NOFS); + if (!c) { + err = -ENOMEM; + goto error; + } + c->req = req; + + c->busa = ib_dma_map_single(rdma->cm_id->device, + c->req->tc.sdata, c->req->tc.size, + DMA_TO_DEVICE); + if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) { + err = -EIO; + goto error; + } + + c->cqe.done = send_done; + + sge.addr = c->busa; + sge.length = c->req->tc.size; + sge.lkey = rdma->pd->local_dma_lkey; + + wr.next = NULL; + wr.wr_cqe = &c->cqe; + wr.opcode = IB_WR_SEND; + wr.send_flags = IB_SEND_SIGNALED; + wr.sg_list = &sge; + wr.num_sge = 1; + + if (down_interruptible(&rdma->sq_sem)) { + err = -EINTR; + goto mapping_error; + } + + /* Mark request as `sent' *before* we actually send it, + * because doing if after could erase the REQ_STATUS_RCVD + * status in case of a very fast reply. + */ + req->status = REQ_STATUS_SENT; + err = ib_post_send(rdma->qp, &wr, NULL); + if (err) + goto sem_error; + + return 0; +sem_error: + up(&rdma->sq_sem); +mapping_error: + ib_dma_unmap_single(rdma->cm_id->device, c->busa, + c->req->tc.size, DMA_TO_DEVICE); +error: + kfree(c); + return err; +} + +static int rdma_request(struct p9_client *client, struct p9_req_t *req) +{ + struct p9_trans_rdma *rdma = client->trans; int err = 0; unsigned long flags; - struct p9_rdma_context *c = NULL; struct p9_rdma_context *rpl_context = NULL; /* When an error occurs between posting the recv and the send, @@ -476,67 +534,17 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) req->rc.sdata = NULL; dont_need_post_recv: - /* Post the request */ - c = kmalloc(sizeof *c, GFP_NOFS); - if (!c) { - err = -ENOMEM; - goto send_error; - } - c->req = req; - - c->busa = ib_dma_map_single(rdma->cm_id->device, - c->req->tc.sdata, c->req->tc.size, - DMA_TO_DEVICE); - if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) { - err = -EIO; - goto send_error; - } - - c->cqe.done = send_done; - - sge.addr = c->busa; - sge.length = c->req->tc.size; - sge.lkey = rdma->pd->local_dma_lkey; - - wr.next = NULL; - wr.wr_cqe = &c->cqe; - wr.opcode = IB_WR_SEND; - wr.send_flags = IB_SEND_SIGNALED; - wr.sg_list = &sge; - wr.num_sge = 1; - - if (down_interruptible(&rdma->sq_sem)) { - err = -EINTR; - goto mapping_error; - } - - /* Mark request as `sent' *before* we actually send it, - * because doing if after could erase the REQ_STATUS_RCVD - * status in case of a very fast reply. - */ - req->status = REQ_STATUS_SENT; - err = ib_post_send(rdma->qp, &wr, NULL); + err = post_send(client, req); if (err) { - up(&rdma->sq_sem); - goto mapping_error; + req->status = REQ_STATUS_ERROR; + p9_debug(P9_DEBUG_ERROR, "Error %d in rdma_request()\n", err); + + /* Ach. + * We did recv_post(), but not send. We have one recv_post + * in excess. + */ + atomic_inc(&rdma->excess_rc); } - - /* Success */ - return 0; - - /* Handle errors that happened during or while preparing the send: */ - mapping_error: - ib_dma_unmap_single(rdma->cm_id->device, c->busa, - c->req->tc.size, DMA_TO_DEVICE); - send_error: - req->status = REQ_STATUS_ERROR; - kfree(c); - p9_debug(P9_DEBUG_ERROR, "Error %d in rdma_request()\n", err); - - /* Ach. - * We did recv_post(), but not send. We have one recv_post in excess. - */ - atomic_inc(&rdma->excess_rc); return err; /* Handle errors that happened during or while preparing post_recv(): */ From patchwork Mon Nov 21 08:00:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 23567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1438771wrr; Sun, 20 Nov 2022 23:42:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LUfUWWFS+hBH53ui7HHSSQHJRfQRqq5KtU6AgHLaHkwDUGPfAiTdRW3o/nGov4GKx9Yzv X-Received: by 2002:a17:903:2642:b0:186:8558:ded2 with SMTP id je2-20020a170903264200b001868558ded2mr2394250plb.95.1669016561503; Sun, 20 Nov 2022 23:42:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669016561; cv=none; d=google.com; s=arc-20160816; b=kvi98neY9qO6niMAfaL+VyYbeIjKjVId35Khjz3De2eIGyPcfoSrNH0z1j9BPZlWE2 ZMKsCaDrOX1W6Cq+kDXqa+57LRsHYLySN9slYyNAwnKQBJY/MqludJC5zQkhtj5WDcqM /4c4H/W4YhsaJrMRm0vAtNpojLZgPoEks/o0QgMpTQpQ7V3sb8HGm2iRX7orjeHrt15D nT3oK4C/gsVPZ0KmzAOVMrXWccGyhdTuPMExIqyYiQDN2iw0y4LBOkfHRyZyuUThR7Ax Aitd329sVC0Mo1H85Jg/2xg8e5Tta7OV8934gdP39Pu7LdMDStoVSI+hNuSSjUCf4zVp xmtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HIWtb16icPbt7+Y8MR34INS23jrMHnOpe4+79O2FdIA=; b=YFHaaqRLiNjweO/MZbY/TN3XhfQy8kUxUTJRddEaXNwScBVEii5EIAZoVx2BP6SgEN +mxYzSDjo5Po2dIUjOH/kJ6GHjflL7CuHo/eHgeW8WiCri22NRXPXgmvKvVje/SxaXms aBDn7IpTp58n+Ikgt81QSXIlNAUcCRTzPySPNnbkpYG5o4HMtDFBKaSPGOrbyJ26BTBE equiYJDRyL4DKvPrnV4wRFfKJjEzbIJc00trarjplanGxzmlloVOX7Kwv/B08G0mFJlK sy4pDfIkNE4BQRWw13rxC2YUgzqIeiDdQrxgu42tuh2lByDs3RIhTHkFuqybCcaxNHh+ g8HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020aa78d86000000b00563ad44ddf9si5038621pfr.380.2022.11.20.23.42.27; Sun, 20 Nov 2022 23:42:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbiKUHjx (ORCPT + 99 others); Mon, 21 Nov 2022 02:39:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbiKUHjj (ORCPT ); Mon, 21 Nov 2022 02:39:39 -0500 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDAFC13DC4; Sun, 20 Nov 2022 23:39:38 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NFzmj33PDz4f3v7Z; Mon, 21 Nov 2022 15:39:33 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgC329g0K3tj2M2XAw--.53628S9; Mon, 21 Nov 2022 15:39:36 +0800 (CST) From: Ye Bin To: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org, linux_oss@crudebyte.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, yebin10@huawei.com Subject: [PATCH 5/5] 9p: refactor 'post_recv()' Date: Mon, 21 Nov 2022 16:00:49 +0800 Message-Id: <20221121080049.3850133-6-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221121080049.3850133-1-yebin@huaweicloud.com> References: <20221121080049.3850133-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgC329g0K3tj2M2XAw--.53628S9 X-Coremail-Antispam: 1UD129KBjvJXoWxJF4fGr1rKF1fJFykAFyUAwb_yoWrXr1fpF 4fuwsIyrZ0qF17Cw4kKa4UZF12kr4rCa1rG3y8Kws3JFn8trn5KF4jyryFgFWxuFZ7J3WF yr1DKFWruF1UZrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBab4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aV CY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750090710057284447?= X-GMAIL-MSGID: =?utf-8?q?1750090710057284447?= From: Ye Bin Refactor 'post_recv()', move receive resource request from 'rdma_request()' to 'post_recv()'. Signed-off-by: Ye Bin --- net/9p/trans_rdma.c | 77 +++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index bb917389adc9..78452c289f35 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c @@ -380,19 +380,40 @@ static void rdma_destroy_trans(struct p9_trans_rdma *rdma) kfree(rdma); } -static int -post_recv(struct p9_client *client, struct p9_rdma_context *c) +static int post_recv(struct p9_client *client, struct p9_req_t *req) { struct p9_trans_rdma *rdma = client->trans; + struct p9_rdma_context *c = NULL; struct ib_recv_wr wr; struct ib_sge sge; - int err = -EIO; + int err; + + c = kmalloc(sizeof *c, GFP_NOFS); + if (!c) { + err = -ENOMEM; + goto error; + } + c->rc.sdata = req->rc.sdata; + + /* + * Post a receive buffer for this request. We need to ensure + * there is a reply buffer available for every outstanding + * request. A flushed request can result in no reply for an + * outstanding request, so we must keep a count to avoid + * overflowing the RQ. + */ + if (down_interruptible(&rdma->rq_sem)) { + err = -EINTR; + goto error; + } c->busa = ib_dma_map_single(rdma->cm_id->device, c->rc.sdata, client->msize, DMA_FROM_DEVICE); - if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) - goto error; + if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) { + err = -EIO; + goto sem_error; + } c->cqe.done = recv_done; @@ -405,15 +426,18 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) wr.sg_list = &sge; wr.num_sge = 1; err = ib_post_recv(rdma->qp, &wr, NULL); - if (err) { - ib_dma_unmap_single(rdma->cm_id->device, c->busa, - client->msize, DMA_FROM_DEVICE); - goto error; - } + if (err) + goto mapping_error; + return 0; - error: + +mapping_error: + ib_dma_unmap_single(rdma->cm_id->device, c->busa, + client->msize, DMA_FROM_DEVICE); +sem_error: up(&rdma->rq_sem); - p9_debug(P9_DEBUG_ERROR, "EIO\n"); +error: + kfree(c); return err; } @@ -481,9 +505,8 @@ static int post_send(struct p9_client *client, struct p9_req_t *req) static int rdma_request(struct p9_client *client, struct p9_req_t *req) { struct p9_trans_rdma *rdma = client->trans; - int err = 0; unsigned long flags; - struct p9_rdma_context *rpl_context = NULL; + int err; /* When an error occurs between posting the recv and the send, * there will be a receive context posted without a pending request. @@ -505,27 +528,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) } } - /* Allocate an fcall for the reply */ - rpl_context = kmalloc(sizeof *rpl_context, GFP_NOFS); - if (!rpl_context) { - err = -ENOMEM; - goto recv_error; - } - rpl_context->rc.sdata = req->rc.sdata; - - /* - * Post a receive buffer for this request. We need to ensure - * there is a reply buffer available for every outstanding - * request. A flushed request can result in no reply for an - * outstanding request, so we must keep a count to avoid - * overflowing the RQ. - */ - if (down_interruptible(&rdma->rq_sem)) { - err = -EINTR; - goto recv_error; - } - - err = post_recv(client, rpl_context); + err = post_recv(client, req); if (err) { p9_debug(P9_DEBUG_ERROR, "POST RECV failed: %d\n", err); goto recv_error; @@ -547,9 +550,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) } return err; - /* Handle errors that happened during or while preparing post_recv(): */ - recv_error: - kfree(rpl_context); +recv_error: spin_lock_irqsave(&rdma->req_lock, flags); if (err != -EINTR && rdma->state < P9_RDMA_CLOSING) { rdma->state = P9_RDMA_CLOSING;