From patchwork Tue Mar 30 07:37:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 249D3C433DB for ; Tue, 30 Mar 2021 07:38:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD66261989 for ; Tue, 30 Mar 2021 07:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231295AbhC3HiF (ORCPT ); Tue, 30 Mar 2021 03:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbhC3Hh7 (ORCPT ); Tue, 30 Mar 2021 03:37:59 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2EB7C061762 for ; Tue, 30 Mar 2021 00:37:58 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id o19so17038869edc.3 for ; Tue, 30 Mar 2021 00:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ddO9eelXvjBp3hvrJGg17PhlxijRjIk5UjXMC0YYOFM=; b=jKT6t/yf4qtgltTGURUNEFZsYi+lu48bhBGKiNHly3SYm+Ee6mkIW4X3+dL05VaLOk cKH/4NxlkWldAC9kYw/4D/b5SVUyzYQsfC0Q+VvG2ovmkiwwE0FwXJrRNHCZzBjMPbe8 FXs7/nZi5BeNoWBGrSO83BR7zTh3UBU3Mz9O4xmr7pNW8Sox9w9U8PCMmTUF2QwW38O/ mFSUWYXec4gqsq/ygKm9jbh6pVOjK8sWMBzYENRpuGA+JfiXY6Myu0bgOOqVp7EgsxOj aVDsMVC7Z4NC1kI/h8dv9UpaRXkGc1+cyt2FafBdOceE44qbcmamP092vW8gGHf13PIP A5JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ddO9eelXvjBp3hvrJGg17PhlxijRjIk5UjXMC0YYOFM=; b=FoHFELcgSURN/vQE93tppu8N/XAdj8JOxGJvz2HMonuYlQ4nF1m4BNABu8e+cErG1t mVCHd9tBAfLPxUen3pckhelnOm6BMoIevLkMBfUaMkh6AHJYDAa6uo+37REIWmt6Exz4 1enjD3wdWRwiOamUp0gqwQphV90u00qny4wKxrvZG0TKkjGfNfH5mTS4YxkY+IXq6wxX AKNMnKL9b0Rj46uc3YbvdwAueiKtpH5OHmtZTfiQ0HDVo+gy0WoStUKkCHINxlqShOWO //q7AhGegMu2dqtpTNqJWWuaQojCdn2KvJxovs0ViVDCd8/jm+c/MI5TkgVGwkqWQ01r +bjA== X-Gm-Message-State: AOAM530khOqiPfmR2kW0QzNnOJkIwRwbyzTGUH3KzwLBAnxu40Zycj1/ iSzW8lRUZGfrQWjBk69dQsjP4IUY/CPY+A== X-Google-Smtp-Source: ABdhPJz70EZtMwVkd1lYWF/r0W29te7WR+iv+zHt7RecJQPNBoj/dF2oEbql90MA9dQQ72zkzKQMYg== X-Received: by 2002:a05:6402:30a2:: with SMTP id df2mr31823519edb.29.1617089877284; Tue, 30 Mar 2021 00:37:57 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:37:56 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Danil Kipnis , Md Haris Iqbal , Jack Wang Subject: [PATCHv2 for-next 01/24] MAINTAINERS: Change maintainer for rnbd module Date: Tue, 30 Mar 2021 09:37:29 +0200 Message-Id: <20210330073752.1465613-2-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Danil Kipnis Danil steps down, Haris will take over. Also update email address to ionos.com, the old cloud.ionos.com will still work for some time. Signed-off-by: Danil Kipnis Acked-by: Md Haris Iqbal Signed-off-by: Jack Wang --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index bf947775390c..723ba354dce6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15358,8 +15358,8 @@ N: riscv K: riscv RNBD BLOCK DRIVERS -M: Danil Kipnis -M: Jack Wang +M: Md. Haris Iqbal +M: Jack Wang L: linux-block@vger.kernel.org S: Maintained F: drivers/block/rnbd/ From patchwork Tue Mar 30 07:37:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39B8CC433E3 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1617619A7 for ; Tue, 30 Mar 2021 07:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231225AbhC3Hii (ORCPT ); Tue, 30 Mar 2021 03:38:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbhC3Hh7 (ORCPT ); Tue, 30 Mar 2021 03:37:59 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 643DAC061764 for ; Tue, 30 Mar 2021 00:37:59 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id e14so23264949ejz.11 for ; Tue, 30 Mar 2021 00:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kipd4FaBQ5PXB3dpojcZn5niu7bqNibIYxBeruWL79Q=; b=ajzJ7yr0PWVMqrOoFkFP+QvWcANuCNsyegdCxs6QWbftA4WWYYymWPYkIHyULrW6Iz ny2ZOz/JymE+uQuqKuTGbGSmLhl2Ik5D99otYQws+3KPl6hrwJhmmn3wNNm045sz1Fj8 y5Dy3REoj8jqLLIpWUXObO0EKrPON4lIt7T56sDmBMflkErhd0M5/IZki2uMpV7U2bS0 5B7QXILwmh0AAJIzKO3aVzS3kwzYLnx3rcVgSxGc583S7ZCFFjLC03HkdYk4qooPAtux PSIMB5kGFJ3SH21YCPNEtOBQth1FgHQMFkPD7FxssW6C2JMFS1J8ckkM+hdODQYtIkjC 6Njw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kipd4FaBQ5PXB3dpojcZn5niu7bqNibIYxBeruWL79Q=; b=VsnwMbmbiREyO77Vu2cjcfyejxdXTC8/RXZzfZR9SrrUDt8z/uNnfnBukEVr9jSrsb kelxsIWwiepCi78WxhJPP600D+VLCYQkhAFS517URsUfWE9eHFAEkMfM0/e3JHZ2we3i u/ljY/0vTIyXg9d7KTimcWsBHse4+uXgY7/3PbdbJmvb2P6PhT3JG7IWtXebWH1ikko/ wYgNsbQ8X/QhgKLbaXfYyNJSI2oxz8YE75B4eUf/OqmNsKBTBaoUn6elYL8uuVgqh/+1 Q+lklfu5M28ONxZq0zVbWgmZNFn1r9H6N2EJ16kIHdVQan3m/wVcSg3vR7E41DDVlAyj rGNA== X-Gm-Message-State: AOAM532oY5oSzvKXBWHDkvzH90pdA9vsM+ooPhN2liXjVNNDT2echT/4 S4fm2gYuUjQ/g1ef2qBi7QpRPiPvMytx1g== X-Google-Smtp-Source: ABdhPJwwjhVNUvEIH1Ty+4L5g8NWJTBSyHjm5qQeSTgFClyJ6/Nv+dgN5rwuXzjKuqVab0WZ+nsrIA== X-Received: by 2002:a17:907:50a1:: with SMTP id fv33mr14623496ejc.14.1617089878071; Tue, 30 Mar 2021 00:37:58 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:37:57 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 02/24] Documentation/sysfs-block-rnbd: Add descriptions for remap_device and resize Date: Tue, 30 Mar 2021 09:37:30 +0200 Message-Id: <20210330073752.1465613-3-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim Two sysfs entries, remap_device and resize, are missing. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- Documentation/ABI/testing/sysfs-block-rnbd | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-block-rnbd b/Documentation/ABI/testing/sysfs-block-rnbd index 14a6fe9422b3..ec716e1c31a8 100644 --- a/Documentation/ABI/testing/sysfs-block-rnbd +++ b/Documentation/ABI/testing/sysfs-block-rnbd @@ -44,3 +44,15 @@ Date: Feb 2020 KernelVersion: 5.7 Contact: Jack Wang Danil Kipnis Description: Contains the device access mode: ro, rw or migration. + +What: /sys/block/rnbd/rnbd/resize +Date: Feb 2020 +KernelVersion: 5.7 +Contact: Jack Wang Danil Kipnis +Description: Write the number of sectors to change the size of the disk. + +What: /sys/block/rnbd/rnbd/remap_device +Date: Feb 2020 +KernelVersion: 5.7 +Contact: Jack Wang Danil Kipnis +Description: Remap the disconnected device if the session is not destroyed yet. From patchwork Tue Mar 30 07:37:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F208FC433E0 for ; Tue, 30 Mar 2021 07:39:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEABD6195D for ; Tue, 30 Mar 2021 07:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231310AbhC3Hii (ORCPT ); Tue, 30 Mar 2021 03:38:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbhC3HiC (ORCPT ); Tue, 30 Mar 2021 03:38:02 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28074C061765 for ; Tue, 30 Mar 2021 00:38:00 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id bf3so17029333edb.6 for ; Tue, 30 Mar 2021 00:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f2DinE7fVr8sYCc9qcGvfMu7UAlB1mcRN2WeeCFznEc=; b=MtLeDD0Tssa0QYsp9DKD9lb2qrYeM0+c08gxZ5plMkiDA8TVUo25uC4rspJilEBqQh k6xMQfOW968zHhDQjd+Ftg4o+jEgZdAv7FFTnrb7eJ0Mk4aB/Nfah5kM+yZm7Uyx0P8l fMeqv0Trg+UMrPZtCiPx0xUWdCmVmu8OmTbFU7S+6HRMf1jr4mQfopshVlytGTTNQjR/ x5uB8eK+F0UOxRibg9L3IW3k3lBIp38mHsIq8saiD4tHbxLa25lKcTMgCXrlBwCOZvQ6 RLEkaf1Wlp1S8Zv3NPEg52lxv7xMSSE9f7qjfCrgymqotRgc+iLxrpfrmqLF4PHgAgWG TMgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f2DinE7fVr8sYCc9qcGvfMu7UAlB1mcRN2WeeCFznEc=; b=rsYhtNCE13H5uVP3wvYlpSoD64yoPO6B4TZ1FVsC8l56LTX3Nxt0DnsXS6uFquKpWn TQfqmZOiICewJSc2+k7Om3NyH+hTMz9p2j8DunQRR160Ff2fvswOByO30EV72JdlhBXq jEt4qdnAkervChxqYI2H7k+cJydAxr8B4cAZxV0c0vBkdyv2GOvyZKUiQnN4Vlm8Pp5H IEhjX9vtD2yt/yljOTpKFKydAnbVYFbYUZ5BS6LbOk3GuWxZc6Dy/uRIlAvb69HZZj4h kBqyby/XXKmN0xQxHgRyLZhIUAnZJkWfot1JSzTCE0FXXckm5FHliBaBOfeZErGYFIhL 3FUg== X-Gm-Message-State: AOAM531aaoA30vfX9fmxxaUV3fxHsIHEOf6CCAc672dJaBn09b9jWYkb JFxHApOClgdWetIq5o33GWYNRWJcH6Quag== X-Google-Smtp-Source: ABdhPJzX/qD9grJHmZjMf9AFUigADN0BXrAX4zVYlLHbuIJGfxoCZUnAeQKYjiZgFiEETRFLat/bqg== X-Received: by 2002:aa7:d1cd:: with SMTP id g13mr32281760edp.369.1617089878759; Tue, 30 Mar 2021 00:37:58 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:37:58 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 03/24] block/rnbd: Enable the fault-injection Date: Tue, 30 Mar 2021 09:37:31 +0200 Message-Id: <20210330073752.1465613-4-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim This patch introduces functions to enable the fault-injection for RTRS. * rnbd_fault_inject_init/final: initialize the fault-injection and create a debugfs directory. * rnbd_fault_inject_add: create a debugfs entry to enable the fault-injection point. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-common.c | 44 ++++++++++++++++++++++++++++++++ drivers/block/rnbd/rnbd-proto.h | 14 ++++++++++ 2 files changed, 58 insertions(+) diff --git a/drivers/block/rnbd/rnbd-common.c b/drivers/block/rnbd/rnbd-common.c index 596c3f732403..84bfbf015f6d 100644 --- a/drivers/block/rnbd/rnbd-common.c +++ b/drivers/block/rnbd/rnbd-common.c @@ -21,3 +21,47 @@ const char *rnbd_access_mode_str(enum rnbd_access_mode mode) return "unknown"; } } + +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS +static DECLARE_FAULT_ATTR(fail_default_attr); + +void rnbd_fault_inject_init(struct rnbd_fault_inject *fj, + const char *dir_name, + u32 err_status) +{ + struct dentry *dir, *parent; + struct fault_attr *attr = &fj->attr; + + /* create debugfs directory and attribute */ + parent = debugfs_create_dir(dir_name, NULL); + if (!parent) { + pr_warn("%s: failed to create debugfs directory\n", dir_name); + return; + } + + *attr = fail_default_attr; + dir = fault_create_debugfs_attr("fault_inject", parent, attr); + if (IS_ERR(dir)) { + pr_warn("%s: failed to create debugfs attr\n", dir_name); + debugfs_remove_recursive(parent); + return; + } + fj->parent = parent; + fj->dir = dir; + + /* create debugfs for status code */ + fj->status = err_status; + debugfs_create_u32("status", 0600, dir, &fj->status); +} + +void rnbd_fault_inject_add(struct dentry *dir, const char *fname, bool *value) +{ + debugfs_create_bool(fname, 0600, dir, value); +} + +void rnbd_fault_inject_final(struct rnbd_fault_inject *fj) +{ + /* remove debugfs directories */ + debugfs_remove_recursive(fj->parent); +} +#endif diff --git a/drivers/block/rnbd/rnbd-proto.h b/drivers/block/rnbd/rnbd-proto.h index c1bc5c0fef71..d13dc1d3a00e 100644 --- a/drivers/block/rnbd/rnbd-proto.h +++ b/drivers/block/rnbd/rnbd-proto.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #define RNBD_PROTO_VER_MAJOR 2 @@ -305,6 +306,19 @@ static inline u32 rq_to_rnbd_flags(struct request *rq) return rnbd_opf; } +struct rnbd_fault_inject { +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS + struct fault_attr attr; + struct dentry *parent; + struct dentry *dir; + u32 status; +#endif +}; + const char *rnbd_access_mode_str(enum rnbd_access_mode mode); +void rnbd_fault_inject_init(struct rnbd_fault_inject *fj, + const char *dev_name, u32 err_status); +void rnbd_fault_inject_add(struct dentry *dir, const char *fname, bool *value); +void rnbd_fault_inject_final(struct rnbd_fault_inject *fj); #endif /* RNBD_PROTO_H */ From patchwork Tue Mar 30 07:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D612CC433C1 for ; Tue, 30 Mar 2021 07:39:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BBDE61989 for ; Tue, 30 Mar 2021 07:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbhC3Hij (ORCPT ); Tue, 30 Mar 2021 03:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbhC3HiC (ORCPT ); Tue, 30 Mar 2021 03:38:02 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CA1C061762 for ; Tue, 30 Mar 2021 00:38:00 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id l18so17031519edc.9 for ; Tue, 30 Mar 2021 00:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f9NQ10bkMHujduDKkZT6Q+c0cfGdFOh0Rt1Prtp1wAk=; b=Tre7V6mWBDYQ36iTgRO2T5UKnYqIbEwlL+0KkVDL8+gl5OttmRxO0NhXyJYLVkJJEe dmPkrZFZ4fzH2jY5dTaYgPGcbv3TSp2fgVChHy2KhjXVEZml6oQ0K1JWMI2gRD7BpEV2 PhpJ8YvVDeR6QSfPvj3b7dREKZYUuhU6gxnsGSRgEpbm67iwwiWdIMVIajVX4F6LoQTQ /imLe+q4OvRQ7pgwCrnPHVkqX2MUEXQKDX6a/b8OeTdXn3vqznFj9PpzmbZbUewwlJQ3 1mVSb8dRYwBLGqvcmwSQ/ko+5kKqPinR3zpcokwtZqnt9k9NTcwmGi7R5HgCCpd2ztfc E6Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f9NQ10bkMHujduDKkZT6Q+c0cfGdFOh0Rt1Prtp1wAk=; b=TR4dLxcU2fyyTrsnateAS5tzWFjRGmb77CHhQ4/BqGSVwU2rFV4ignqBqTPjra8qLw Kc27aOVnACPnYRfc0sjXSWVimOm39t9qYHi+fsCBpM0I1bESFhBEEQcBJ25/J3g0KusL 3xgqPbH+6+iWF6TDUa6SjRUsrXOWxBt/bxQ5b1d14Uw7GEkXt9qVD1t9uccwIRRKBjM2 7yMtglSJq3QWonGL8TWOnCHZ2aMbbmpUI1hY2OHpi+fLJq6/cR5v16QOhFisz6mxmXWW 2cwmfFKcBDLGD3ZLRyB453DIGwTmt4NAoA48ARPfobfTpkHVOGzvCUTe01EHQoRCKdkp LFtA== X-Gm-Message-State: AOAM5312w1/CBkwGK/5Y3D0X13RkmcXIn9SC33gxluSI0Ue+TI9xEKjn cFPVB+jCtXUmO1usLpTeFch+VVY0USwPDQ== X-Google-Smtp-Source: ABdhPJyebXeX1Hv0ZUhF+QQeHa7kq31E1Mqjz5ZGzprMKdBlSJaIlkiZaCjODJz4nyFmqsCJMQhRxw== X-Received: by 2002:aa7:c497:: with SMTP id m23mr32027227edq.74.1617089879589; Tue, 30 Mar 2021 00:37:59 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:37:59 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 04/24] block/rnbd-srv: Inject a fault at bio processing Date: Tue, 30 Mar 2021 09:37:32 +0200 Message-Id: <20210330073752.1465613-5-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim If the fault is enabled, it sends an error to the client so that the client thinks the target device on the server has failed. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-srv-sysfs.c | 36 +++++++++++++++++++++++++++++ drivers/block/rnbd/rnbd-srv.c | 7 ++++++ drivers/block/rnbd/rnbd-srv.h | 13 +++++++++++ 3 files changed, 56 insertions(+) diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c b/drivers/block/rnbd/rnbd-srv-sysfs.c index 05ffe488ddc6..278a981302b9 100644 --- a/drivers/block/rnbd/rnbd-srv-sysfs.c +++ b/drivers/block/rnbd/rnbd-srv-sysfs.c @@ -253,3 +253,39 @@ void rnbd_srv_destroy_sysfs_files(void) device_destroy(rnbd_dev_class, MKDEV(0, 0)); class_destroy(rnbd_dev_class); } + +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS +void rnbd_srv_fault_inject_init(struct rnbd_srv_fault_inject *fault_inject, + const char *dev_name) +{ + rnbd_fault_inject_init(&fault_inject->fj, dev_name, -EBUSY); + /* injection points */ + rnbd_fault_inject_add(fault_inject->fj.dir, + "fail-bio", &fault_inject->fail_bio); +} + +void rnbd_srv_fault_inject_fini(struct rnbd_srv_fault_inject *fault_inject) +{ + rnbd_fault_inject_final(&fault_inject->fj); +} + +int rnbd_should_fail_bio(struct rnbd_srv_sess_dev *sess_dev) +{ + struct rnbd_srv_fault_inject *fault_inject = &sess_dev->fault_inject; + if (fault_inject->fail_bio && should_fail(&fault_inject->fj.attr, 1)) + return fault_inject->fj.status; + return 0; +} +#else +void rnbd_srv_fault_inject_init(struct rnbd_srv_fault_inject *fault_inj, + const char *dev_name) +{ +} +void rnbd_srv_fault_inject_fini(struct rnbd_srv_fault_inject *fault_inject) +{ +} +int rnbd_should_fail_bio(struct rnbd_srv_sess_dev *sess_dev) +{ + return 0; +} +#endif diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index a6a68d44f517..447fb0718525 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -88,9 +88,14 @@ void rnbd_endio(void *priv, int error) { struct rnbd_io_private *rnbd_priv = priv; struct rnbd_srv_sess_dev *sess_dev = rnbd_priv->sess_dev; + int fail_err = 0; rnbd_put_sess_dev(sess_dev); + fail_err = rnbd_should_fail_bio(sess_dev); + if (unlikely(fail_err)) /* over-write error which will be sent to client */ + error = fail_err; + rtrs_srv_resp_rdma(rnbd_priv->id, error); kfree(priv); @@ -230,6 +235,7 @@ void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id) rnbd_put_sess_dev(sess_dev); wait_for_completion(&dc); /* wait for inflights to drop to zero */ + rnbd_srv_fault_inject_fini(&sess_dev->fault_inject); rnbd_dev_close(sess_dev->rnbd_dev); list_del(&sess_dev->sess_list); mutex_lock(&sess_dev->dev->lock); @@ -811,6 +817,7 @@ static int process_msg_open(struct rtrs_srv *rtrs, rnbd_srv_info(srv_sess_dev, "Opened device '%s'\n", srv_dev->id); kfree(full_path); + rnbd_srv_fault_inject_init(&srv_sess_dev->fault_inject, kbasename(srv_sess_dev->pathname)); fill_response: rnbd_srv_fill_msg_open_rsp(rsp, srv_sess_dev); diff --git a/drivers/block/rnbd/rnbd-srv.h b/drivers/block/rnbd/rnbd-srv.h index b157371c25ed..120e6d64cb82 100644 --- a/drivers/block/rnbd/rnbd-srv.h +++ b/drivers/block/rnbd/rnbd-srv.h @@ -45,6 +45,13 @@ struct rnbd_srv_dev { int open_write_cnt; }; +struct rnbd_srv_fault_inject { +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS + struct rnbd_fault_inject fj; + bool fail_bio; +#endif +}; + /* Structure which binds N devices and N sessions */ struct rnbd_srv_sess_dev { /* Entry inside rnbd_srv_dev struct */ @@ -62,6 +69,7 @@ struct rnbd_srv_sess_dev { struct completion *destroy_comp; char pathname[NAME_MAX]; enum rnbd_access_mode access_mode; + struct rnbd_srv_fault_inject fault_inject; }; void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev); @@ -77,4 +85,9 @@ int rnbd_srv_create_sysfs_files(void); void rnbd_srv_destroy_sysfs_files(void); void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id); +void rnbd_srv_fault_inject_init(struct rnbd_srv_fault_inject *fault_inj, + const char *dev_name); +void rnbd_srv_fault_inject_fini(struct rnbd_srv_fault_inject *fault_inject); +int rnbd_should_fail_bio(struct rnbd_srv_sess_dev *sess_dev); + #endif /* RNBD_SRV_H */ From patchwork Tue Mar 30 07:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81A88C433E4 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F78E61883 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbhC3Hij (ORCPT ); Tue, 30 Mar 2021 03:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbhC3HiE (ORCPT ); Tue, 30 Mar 2021 03:38:04 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDBAAC0613D8 for ; Tue, 30 Mar 2021 00:38:01 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id o19so17039046edc.3 for ; Tue, 30 Mar 2021 00:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pr6f4CgNg/vO7af8Lnbc0By2HHIYCME5N2QMNGWGV18=; b=dZfLphxgzO0mxIDEGnWi6JgEc3ivjx99R3XeabWd5m5y6KWhs8EHfFrbeqNJ9gl1Li fQsQbDVw5hp8SK2e2/SV0yJAsrWGXY5+YvCbGdaM8LR/fZqt4ywV3zTbEPzGyOKjAHic uBTwbSKniLHehfYKDXaAtOF2CuPFKzr+JxcFKsaWVH7Fxnu6Qc5rIoCq5XRF+w4oRb3E 9T1yv5ml6Z69KDsWyarMDawhAqhYoevKuJg3boJxPSes0dT0YoqHXYluAG7rXwCbJdoD QJOzBATxk6NSQmULEe8l4DQAYe9BT+YSZ7fMEkGV5yv/ZisnHDyiiO+lUq1ttNjYMGAK dcBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pr6f4CgNg/vO7af8Lnbc0By2HHIYCME5N2QMNGWGV18=; b=Ngvw66Nsp/Du9HrqCmeDJ3Ad1FfSvLath/RQTGEEO3gZ7OEM3j0i9pSg+ha/Uk2WOc BS22s6MaiGK7N7EmAGP38B03NGRnAB83hVMo90S5UPviSr0IwvFzyswBuq5OZCIz6qr2 ZU2M/v64d2HUs+s2hpgrx94Heu2q0zDwf4fdH6+4FBtPA6CiBq+tZeYiqhnaa59ogFSM g6LfK8WARv4ziUWTAwR/jnlKnsz5fvnMZXTta9pXsxq/EvQtDi8iGr2lCai9/lJ7sNAl thjqV7q53v/9b1+u5h0gSxGAZGJWq4LeYYW+PhANvfKyUSf2OdaRUIKBAvZ/5/Zvg0ev KmzQ== X-Gm-Message-State: AOAM531Y2P8Ed1f9xh38niyb/jIveZB9xpgUarlwN/0uh42Q1tKECt0d /R8OACZEZyHA+KaoWNJPz0w2eyDJLlMheA== X-Google-Smtp-Source: ABdhPJz0FZIg6dOHdNqoTi/XJybcD/ZEs2QxxlekSXGk1BYqd78dL6SYwRP9UDXJ98xs1tylVjiSYA== X-Received: by 2002:aa7:cdcf:: with SMTP id h15mr31933840edw.28.1617089880308; Tue, 30 Mar 2021 00:38:00 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:00 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 05/24] block/rnbd-clt: Inject some fault points Date: Tue, 30 Mar 2021 09:37:33 +0200 Message-Id: <20210330073752.1465613-6-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim This patch injects two fault points: 1. generate an IO error 2. generate a unmap failure Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-clt-sysfs.c | 53 +++++++++++++++++++++++++++++ drivers/block/rnbd/rnbd-clt.c | 17 +++++++++ drivers/block/rnbd/rnbd-clt.h | 15 ++++++++ 3 files changed, 85 insertions(+) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index d4aa6bfc9555..d83415875960 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -651,3 +651,56 @@ void rnbd_clt_destroy_sysfs_files(void) device_destroy(rnbd_dev_class, MKDEV(0, 0)); class_destroy(rnbd_dev_class); } + +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS +void rnbd_clt_fault_inject_init(struct rnbd_clt_fault_inject *fault_inject, + const char *dev_name) +{ + rnbd_fault_inject_init(&fault_inject->fj, dev_name, -EBUSY); + /* injection points */ + rnbd_fault_inject_add(fault_inject->fj.dir, + "fail-request", &fault_inject->fail_request); + rnbd_fault_inject_add(fault_inject->fj.dir, + "fail-unmap", &fault_inject->fail_unmap); +} + +void rnbd_clt_fault_inject_final(struct rnbd_clt_fault_inject *fault_inject) +{ + rnbd_fault_inject_final(&fault_inject->fj); +} + +int rnbd_clt_should_fail_request(struct request *req) +{ + struct rnbd_clt_dev *dev = req->rq_disk->private_data; + struct rnbd_clt_fault_inject *fault_inject = &dev->fault_inject; + + if (fault_inject->fail_request && should_fail(&fault_inject->fj.attr, 1)) + return fault_inject->fj.status; + return 0; +} + +int rnbd_clt_should_fail_unmap(struct rnbd_clt_dev *dev) +{ + struct rnbd_clt_fault_inject *fault_inject = &dev->fault_inject; + + if (fault_inject->fail_unmap && should_fail(&fault_inject->fj.attr, 1)) + return fault_inject->fj.status; + return 0; +} +#else +void rnbd_clt_fault_inject_init(struct rnbd_clt_fault_inject *fault_inj, + const char *dev_name) +{ +} +void rnbd_clt_fault_inject_final(struct rnbd_clt_fault_inject *fault_inject) +{ +} +int rnbd_clt_should_fail_request(struct request *req) +{ + return 0; +} +int rnbd_clt_should_fail_unmap(struct rnbd_clt_dev *dev) +{ + return 0; +} +#endif diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 45a470076652..8c9a02c8b8bd 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -411,6 +411,11 @@ static void msg_io_conf(void *priv, int errno) struct rnbd_clt_dev *dev = iu->dev; struct request *rq = iu->rq; int rw = rq_data_dir(rq); + int fail_err = 0; + + fail_err = rnbd_clt_should_fail_request(rq); + if (unlikely(fail_err)) /* over-write error */ + errno = fail_err; iu->errno = errno; @@ -1161,6 +1166,7 @@ static blk_status_t rnbd_queue_rq(struct blk_mq_hw_ctx *hctx, } blk_mq_start_request(rq); + err = rnbd_client_xfer_request(dev, rq, iu); if (likely(err == 0)) return BLK_STS_OK; @@ -1545,6 +1551,8 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, goto send_close; } + rnbd_clt_fault_inject_init(&dev->fault_inject, dev->gd->disk_name); + rnbd_clt_info(dev, "map_device: Device mapped as %s (nsectors: %zu, logical_block_size: %d, physical_block_size: %d, max_write_same_sectors: %d, max_discard_sectors: %d, discard_granularity: %d, discard_alignment: %d, secure_discard: %d, max_segments: %d, max_hw_sectors: %d, rotational: %d, wc: %d, fua: %d)\n", dev->gd->disk_name, dev->nsectors, @@ -1599,8 +1607,16 @@ int rnbd_clt_unmap_device(struct rnbd_clt_dev *dev, bool force, struct rnbd_clt_session *sess = dev->sess; int refcount, ret = 0; bool was_mapped; + int fail_err = 0; mutex_lock(&dev->lock); + + fail_err = rnbd_clt_should_fail_unmap(dev); + if (unlikely(fail_err)) { + ret = fail_err; + goto err; + } + if (dev->dev_state == DEV_STATE_UNMAPPED) { rnbd_clt_info(dev, "Device is already being unmapped\n"); ret = -EALREADY; @@ -1618,6 +1634,7 @@ int rnbd_clt_unmap_device(struct rnbd_clt_dev *dev, bool force, dev->dev_state = DEV_STATE_UNMAPPED; mutex_unlock(&dev->lock); + rnbd_clt_fault_inject_final(&dev->fault_inject); delete_dev(dev); destroy_sysfs(dev, sysfs_self); destroy_gen_disk(dev); diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h index 537d499dad3b..5ecbe8dedf24 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -107,6 +107,14 @@ struct rnbd_queue { struct blk_mq_hw_ctx *hctx; }; +struct rnbd_clt_fault_inject { +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS + struct rnbd_fault_inject fj; + bool fail_unmap; + bool fail_request; +#endif +}; + struct rnbd_clt_dev { struct rnbd_clt_session *sess; struct request_queue *queue; @@ -139,6 +147,7 @@ struct rnbd_clt_dev { char *blk_symlink_name; refcount_t refcount; struct work_struct unmap_on_rmmod_work; + struct rnbd_clt_fault_inject fault_inject; }; /* rnbd-clt.c */ @@ -163,4 +172,10 @@ void rnbd_clt_destroy_default_group(void); void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev); +void rnbd_clt_fault_inject_init(struct rnbd_clt_fault_inject *fault_inj, + const char *dev_name); +void rnbd_clt_fault_inject_final(struct rnbd_clt_fault_inject *fault_inject); +int rnbd_clt_should_fail_request(struct request *req); +int rnbd_clt_should_fail_unmap(struct rnbd_clt_dev *dev); +int rnbd_clt_should_fail_request_timeout(struct request *req); #endif /* RNBD_CLT_H */ From patchwork Tue Mar 30 07:37:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A499C433ED for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 063C061959 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbhC3Hil (ORCPT ); Tue, 30 Mar 2021 03:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhC3HiE (ORCPT ); Tue, 30 Mar 2021 03:38:04 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64FA4C061764 for ; Tue, 30 Mar 2021 00:38:02 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id o19so17039149edc.3 for ; Tue, 30 Mar 2021 00:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i3m1ZLIUbsmjdhyhdmher/khBF18PienCGDpXwk+t7E=; b=RDDf9AlTD24XS+F+mTPvLmr1uXGef1hweL3DMhlwDldxxmpxENfQXMpo0wAUpfvLA3 bJuX1kQwd1G/KxJSNJ5cEMCNcYm6i0ewqyEb7yX3JNGtaEhOVCEZdGg6N9jAhrR1fS0C iPd+PnN0dss+2yaoHRWtm5c+3WTczoqjvcDemA7YmK9yxVwwtRyrkqkxCDxQgosOQb6A mkGDwr7H3ihoPN68XnWLo9BMB30FsLzgDHf2HUjACaWEdzrVdfsLjvnTc00kiknkQjES aVfdZLTkS2pQO0lhCdkTkMcU8MuPN0aC51gC34Cw3iSBaXfZFsn/QkUsmtEiVz4SVpLG D0+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i3m1ZLIUbsmjdhyhdmher/khBF18PienCGDpXwk+t7E=; b=TRlPXBf0hBcen6lZZYmrca3AZ0I6dfLR71fN1RaK4dsxfu2k8RtQ0ML38w+4N//LhF wXhVbuik1tMBhWcS1zlW19HT4+wmYgZig7uRyrt9ZjQCoXyBbRTmnyeo1+Stb2ASSIBV ji+968sV+Ijf0vbbmMmjHf1x8zt0HViOCHu3mry9z9BbxO2kQpLvHyEMQPoNWyGgDPzq KDEYFoHGalkTp5BC5WSeL7jjz+eNNJIrWjX1V8pfzvOXeMLjVFdU844Dva6Z0MShn+lE grZi9X7nywbMXffSggjb5kCTWAZLOoC7yoJS0LbZ2CgSJMN0Qjv3OyEBgGIFd2Y4mr1K QJIg== X-Gm-Message-State: AOAM532hPmB14TfskR5Ao4o+v9KVVdCSPiuZZXxc2kMO3Rvsdk+do+qw Xal6HQWuvj2XYH+qqkx38NbH/O8yBu1Fvg== X-Google-Smtp-Source: ABdhPJwiebV/NI055SD5ocJmW/ohEEdwI9lFzXtyRNcr1hc9wQ4M7wHBmOipOutUZtlQxFwxRO2aKQ== X-Received: by 2002:aa7:cf90:: with SMTP id z16mr32215719edx.273.1617089880957; Tue, 30 Mar 2021 00:38:00 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:00 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim Subject: [PATCHv2 for-next 06/24] docs: fault-injection: Add fault-injection manual of RNBD Date: Tue, 30 Mar 2021 09:37:34 +0200 Message-Id: <20210330073752.1465613-7-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim It describes how to use the fault-injection of RNBD. Signed-off-by: Gioh Kim --- .../fault-injection/rnbd-fault-injection.rst | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 Documentation/fault-injection/rnbd-fault-injection.rst diff --git a/Documentation/fault-injection/rnbd-fault-injection.rst b/Documentation/fault-injection/rnbd-fault-injection.rst new file mode 100644 index 000000000000..21594e5e3c91 --- /dev/null +++ b/Documentation/fault-injection/rnbd-fault-injection.rst @@ -0,0 +1,208 @@ +RNBD (RDMA Network Block Device) Fault Injection +================================================ +This document introduces how to enable and use the error injection of RNBD +via debugfs in the /sys/kernel/debug directory. When enabled, users can +enable specific error injection point and change the default status code +via the debugfs. + +Following examples show how to inject an error into the RNBD. + +First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config, +recompile the kernel. After booting up the kernel, map a target device. + +On client, /sys/kernel/debug/rnbdX directory is created after mapping. +And /sys/kernel/debug/ directory is created on server. + +Example 1: Inject an error into request processing of rnbd-client +----------------------------------------------------------------- + +:: + + echo 1 > /sys/kernel/debug/rnbd0/fault_inject/times + echo 100 > /sys/kernel/debug/rnbd0/fault_inject/probability + echo 1 > /sys/kernel/debug/rnbd0/fault_inject/fail-request + dd if=/dev/rnbd0 of=./dd bs=1k count=10 + +Expected Result:: + + dd succeeds but generates an IO error + +Message from dmesg:: + + FAULT_INJECTION: forcing a failure. + name fault_inject, interval 1, probability 100, space 0, times 1 + CPU: 4 PID: 0 Comm: swapper/4 Tainted: G O 5.4.77-pserver+ #167 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 + Call Trace: + + dump_stack+0x97/0xe0 + should_fail.cold+0x5/0x11 + rnbd_clt_should_fail_request+0x5e/0x80 [rnbd_client] + msg_io_conf+0x42/0xb0 [rnbd_client] + complete_rdma_req+0x264/0x600 [rtrs_client] + rtrs_clt_rdma_done+0x4a2/0x690 [rtrs_client] + __ib_process_cq+0x94/0x100 [ib_core] + ib_poll_handler+0x3f/0xa0 [ib_core] + irq_poll_softirq+0xf8/0x280 + __do_softirq+0x122/0x550 + irq_exit+0xfb/0x100 + do_IRQ+0x8a/0x170 + common_interrupt+0xf/0xf + + RIP: 0010:default_idle+0x2b/0x1d0 + Code: 1f 44 00 00 41 55 41 54 65 44 8b 25 7f fe 0a 5a 55 53 0f 1f 44 00 00 e8 53 65 30 ff e9 07 00 00 00 0f 00 2d b7 59 4b 00 fb f4 <65> 44 8b 25 5d fe 0a 5a 0f 1f 44 00 00 5b 5d 41 5c 41 5d c3 65 8b + RSP: 0018:ffff88811963fdc8 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd + RAX: 0000000000000000 RBX: ffff888119633240 RCX: dffffc0000000000 + RDX: 0000000000000007 RSI: 0000000000000006 RDI: ffff888119633ad4 + RBP: 0000000000000004 R08: ffffffffa516d49d R09: 0000000000000000 + R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000004 + R13: 0000000000000000 R14: ffff888119633240 R15: 0000000000000000 + do_idle+0x314/0x370 + cpu_startup_entry+0x19/0x20 + start_secondary+0x212/0x280 + secondary_startup_64+0xa4/0xb0 + rnbd_client L432: read I/O failed with err: -16 + blk_update_request: device resource error, dev rnbd0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 0 + +Example 2: Inject an error into unmapping of rnbd-client +-------------------------------------------------------- + +:: + + echo 100 > /sys/kernel/debug/rnbd0/fault_inject/probability + echo 1 > /sys/kernel/debug/rnbd0/fault_inject/times + echo 1 > /sys/kernel/debug/rnbd0/fault_inject/fail-unmap + echo normal > /sys/block/rnbd0/rnbd/unmap_device + +Expected Result:: + + echo: write error: Device or resource busy + +Message from dmesg:: + + FAULT_INJECTION: forcing a failure. + name fault_inject, interval 1, probability 100, space 0, times 1 + CPU: 2 PID: 648 Comm: bash Tainted: G O 5.4.77-pserver+ #169 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 + Call Trace: + dump_stack+0x97/0xe0 + should_fail.cold+0x5/0x11 + rnbd_clt_should_fail_unmap+0x38/0x60 [rnbd_client] + rnbd_clt_unmap_device+0x3c/0x1c0 [rnbd_client] + rnbd_clt_unmap_dev_store.cold+0xe5/0x13f [rnbd_client] + kernfs_fop_write+0x141/0x240 + vfs_write+0xf2/0x250 + ksys_write+0xc3/0x160 + do_syscall_64+0x68/0x260 + entry_SYSCALL_64_after_hwframe+0x49/0xbe + RIP: 0033:0x7ff883091504 + Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 + RSP: 002b:00007ffe1bc91458 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + RAX: ffffffffffffffda RBX: 0000000000000007 RCX: 00007ff883091504 + RDX: 0000000000000007 RSI: 000056389b73a180 RDI: 0000000000000001 + RBP: 000056389b73a180 R08: 000000000000000a R09: 00007ff883121e80 + R10: 000000000000000a R11: 0000000000000246 R12: 00007ff883163760 + R13: 0000000000000007 R14: 00007ff88315e760 R15: 0000000000000007 + rnbd_client L335: unmap_device: -16 + rnbd_client L321: Unmapping device, option: normal. + +Example 3: Inject an error into bio process of rnbd-server +---------------------------------------------------------- + +After client maps null0b, you can see /sys/kernel/debug/nullb0 directory on server:: + + echo 100 > /sys/kernel/debug/nullb0/fault_inject/probability + echo 1 > /sys/kernel/debug/nullb0/fault_inject/times + echo 1 > /sys/kernel/debug/nullb0/fault_inject/fail-bio + +Then you can generate IO on client:: + + dd if=/dev/rnbd0 of=./dd bs=1k count=10 + +Expected Result on client:: + + dd succeeds but generates an IO error + +Message from dmesg on client:: + + rtrs_client L453: : IO request failed: error=-16 path=ip:192.168.122.142@ip:192.168.122.130 [mlx4_0:1] notify=1 + rnbd_client L432: read I/O failed with err: -16 + blk_update_request: device resource error, dev rnbd0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 0 + +Message from dmesg on server:: + + FAULT_INJECTION: forcing a failure. + name fault_inject, interval 1, probability 100, space 0, times 1 + CPU: 4 PID: 31 Comm: ksoftirqd/4 Tainted: G O 5.4.77-pserver+ #169 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 + Call Trace: + dump_stack+0x97/0xe0 + should_fail.cold+0x5/0x11 + rnbd_should_fail_bio+0x38/0x51 [rnbd_server] + rnbd_endio+0x41/0x70 [rnbd_server] + rnbd_dev_bi_end_io+0x43/0x50 [rnbd_server] + blk_update_request+0x1af/0x520 + blk_mq_end_request+0x2e/0x200 + blk_done_softirq+0x16e/0x1c0 + __do_softirq+0x122/0x550 + run_ksoftirqd+0x24/0x30 + smpboot_thread_fn+0x1a2/0x2d0 + kthread+0x191/0x1e0 + ret_from_fork+0x3a/0x50 + +Example 4: Change the status code +--------------------------------- + +The default status code is -16 (-EBUSY) but you can change it:: + + echo 1 > /sys/kernel/debug/rnbd0/fault_inject/times + echo 100 > /sys/kernel/debug/rnbd0/fault_inject/probability + echo 1 > /sys/kernel/debug/rnbd0/fault_inject/fail-request + echo -10 > /sys/kernel/debug/rnbd0/fault_inject/status + dd if=/dev/rnbd0 of=./dd bs=1k count=10 + +Expected Result:: + + The error value is -10 + +Message from dmesg:: + + FAULT_INJECTION: forcing a failure. + name fault_inject, interval 1, probability 100, space 0, times 1 + CPU: 4 PID: 0 Comm: swapper/4 Tainted: G O 5.4.77-pserver+ #170 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 + Call Trace: + + dump_stack+0x97/0xe0 + should_fail.cold+0x5/0x11 + rnbd_clt_should_fail_request+0x5e/0x80 [rnbd_client] + msg_io_conf+0x42/0xb0 [rnbd_client] + complete_rdma_req+0x264/0x600 [rtrs_client] + rtrs_clt_rdma_done+0x4a2/0x690 [rtrs_client] + __ib_process_cq+0x94/0x100 [ib_core] + ib_poll_handler+0x3f/0xa0 [ib_core] + irq_poll_softirq+0xf8/0x280 + __do_softirq+0x122/0x550 + irq_exit+0xfb/0x100 + do_IRQ+0x8a/0x170 + common_interrupt+0xf/0xf + + RIP: 0010:default_idle+0x2b/0x1d0 + Code: 1f 44 00 00 41 55 41 54 65 44 8b 25 7f fe 0a 7c 55 53 0f 1f 44 00 00 e8 53 65 30 ff e9 07 00 00 00 0f 00 2d b7 59 4b 00 fb f4 <65> 44 8b 25 5d fe 0a 7c 0f 1f 44 00 00 5b 5d 41 5c 41 5d c3 65 8b + RSP: 0018:ffff888114e2fdc8 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd + RAX: 0000000000000000 RBX: ffff888114e26440 RCX: dffffc0000000000 + RDX: 0000000000000007 RSI: 0000000000000006 RDI: ffff888114e26cd4 + RBP: 0000000000000004 R08: ffffffff8316d49d R09: 0000000000000000 + R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000004 + R13: 0000000000000000 R14: ffff888114e26440 R15: 0000000000000000 + ? lockdep_hardirqs_on+0x17d/0x250 + ? default_idle+0x1d/0x1d0 + do_idle+0x314/0x370 + ? arch_cpu_idle_exit+0x40/0x40 + ? schedule_idle+0x46/0x60 + cpu_startup_entry+0x19/0x20 + start_secondary+0x212/0x280 + ? set_cpu_sibling_map+0xcb0/0xcb0 + secondary_startup_64+0xa4/0xb0 + rnbd_client L432: read I/O failed with err: -10 + blk_update_request: I/O error, dev rnbd0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 3 prio class 0 From patchwork Tue Mar 30 07:37:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A60F4C433E8 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 766B561990 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbhC3Hij (ORCPT ); Tue, 30 Mar 2021 03:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbhC3HiE (ORCPT ); Tue, 30 Mar 2021 03:38:04 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C181C0613D9 for ; Tue, 30 Mar 2021 00:38:03 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id bx7so17007634edb.12 for ; Tue, 30 Mar 2021 00:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WQDJlaw0FtQm0N9dNhdmtBw67bwGouq09B/Vh9aj0v4=; b=YtO1yU2QWrgOKeHVQIGxgJMu+QPyA3NIaEFfwToAZIMmmMNuxmQIvnn3qK3YezoQ3b xAMmEFW2flzQW+r5cDMcWlpAi96i4ZXVq/hLQBV8AXt9mWzpkVRfhnHT6YKnz0cxSzoS P1jwu57JsoV8shpDNEQFOdsnnd65A/KdPCS1kRfZOE6odAtkkTJDxZQIEFIZzQn/Yla5 j4cunMW2L85b6WuXtr43VkhVLV2gxmGV8hARWweEcGM817oDnidYDldNJWm5U/7TW1fU wfN4WVbzuV4twq9TavIJUh2D/pjMc0HMpky9cLjGZeccCabOz90fQGmhmOYQ79AzUvhZ xeQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WQDJlaw0FtQm0N9dNhdmtBw67bwGouq09B/Vh9aj0v4=; b=BY4Maui/GKZthf5dkzp/36FCR8ifEb4vmfavtEn5PlnkKt88TcIk1+QjXc8zSGluLm tsqkEWG2bSv5CqppAib69tCUzty6p2TKvrYkQUfU92256kYx536OjIQjwwmuAOCXr6gT C0zytHn4jwaOiW7tLkgCTbz3JlNTCoHihuWdMRR92gH/0Y9FYtuUlGtgwNeSS6Irv9tj oN+yZZms0h/7CeQEdtwaOvE6uhGGlOxIiGokB58nJiMzFL/jIHvVhs16uPSepFx0OtdG 8gn2jO0DoDrWHsc8qV9l34RNwXl9zSd9bGt2TgvL/cej8yosFNGSE6ZrTyEZ5F07R6Ua Ld/g== X-Gm-Message-State: AOAM532KuQbtBmRKKj73Cx69LSElYu2Dq5PitK9NFWgSlhvX/DS1bd6f POqXMVZOafY9OkrvJg8rjnZsUBjAM2lnfA== X-Google-Smtp-Source: ABdhPJzyyQ4e8DODgZmqXTqg5PYpfc7F+L18ziFa1+QtAawYHa4+74NAGE3+F1XFO8kUYCjiRLIjDg== X-Received: by 2002:a05:6402:4386:: with SMTP id o6mr33873943edc.307.1617089881752; Tue, 30 Mar 2021 00:38:01 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:01 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 07/24] docs: Add RTRS/RNBD to the index of fault-injection Date: Tue, 30 Mar 2021 09:37:35 +0200 Message-Id: <20210330073752.1465613-8-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim Add new documents for RTRS and RNBD to the index file. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- Documentation/fault-injection/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/fault-injection/index.rst b/Documentation/fault-injection/index.rst index 8408a8a91b34..669d146af874 100644 --- a/Documentation/fault-injection/index.rst +++ b/Documentation/fault-injection/index.rst @@ -11,6 +11,8 @@ fault-injection notifier-error-inject nvme-fault-injection provoke-crashes + rnbd-fault-injection + rtrs-fault-injection .. only:: subproject and html From patchwork Tue Mar 30 07:37:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C76A0C433EA for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B06D961955 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbhC3Hik (ORCPT ); Tue, 30 Mar 2021 03:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231278AbhC3HiF (ORCPT ); Tue, 30 Mar 2021 03:38:05 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E34F7C0613DA for ; Tue, 30 Mar 2021 00:38:03 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id hq27so23297338ejc.9 for ; Tue, 30 Mar 2021 00:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EdgX4znbSbRT87gcC/hvyjTwqemHSW7vhlSYDeMUDTc=; b=h/w53RSEvs+1BUVdsJ7V2P81Tw3tc+ZGfi1ZZoQ8yeeg4cyndnDqpBj5iOhpVU4Pip JaYKgdU2SVd4k2WqTeIlqOVrR5TGRl7sfe9aRCQ4E1AY0zUcakGAy8opoPxPwFX2QvUW xDlt3ZDzTM5BwRtg0htDrZxQR8tMVi6lKjElcOOMCo7x/bqMPEEUKUVjJGMedZ3lcM2m HMLdxMdaW23HrpaR20DY/4YFHpa+/E2S2EzGLA1mtiPXrsBEX/jHmvIOvfk5BV1jfQAg sCAr2izh15PPTUFb55HOBAuTqJc0bAcppG55JBrzkTbvSSgaU9ZdLThK8MQuTwbaI7+F 6Njg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EdgX4znbSbRT87gcC/hvyjTwqemHSW7vhlSYDeMUDTc=; b=UlFSFlsA5KVCMHJ7Kwagcy1l/S8J51dwwbmodsSuFK819vgnnfi8UJCikTWqvD1aDh Z0kZrBMEm9pYkqP73JgQp1JbSpvqkRLZXB6qrmWwfSPs+rerkBJflaaO53Vd2sAuc/6S 1W89Y6N1upAfnrraYhQw6nB2a2FPb6wQWnTyrDeiO7udAVhwlTn5X32ggBvaA1pGfsEX +Q4loH12YDL8vp3youTTE2uvcefbAoeu9HcyCJNF9yDOol7+rple9B5WzTk2FQB8+OJF o0NYbOYITvQXIFOhKxb19C7mOqLKDhqYdrVsxTihisHrvnnPVbQqzJGYT987Sl6WYPuA jTUw== X-Gm-Message-State: AOAM532a9fmj0WiuOciQSkrvY9U91V2FevietsD0KV2BBRMb1mUSUrZN Wpi9T87Ww7VmJcjmocRjZvHMSDhh3crLtre4 X-Google-Smtp-Source: ABdhPJyRPruDJnC6HaEWj+pxK6CxNFI1tMbGQeV3BRKTZk47KxA7VX5n8fUlTxW5eBNFcXzwBBdSmA== X-Received: by 2002:a17:906:ae88:: with SMTP id md8mr31076641ejb.264.1617089882521; Tue, 30 Mar 2021 00:38:02 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:02 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Danil Kipnis , Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 08/24] block/rnbd-clt: Remove some arguments from insert_dev_if_not_exists_devpath Date: Tue, 30 Mar 2021 09:37:36 +0200 Message-Id: <20210330073752.1465613-9-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Guoqing Jiang Remove 'pathname' and 'sess' since we can dereference it from 'dev'. Signed-off-by: Guoqing Jiang Reviewed-by: Danil Kipnis Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 8c9a02c8b8bd..c8de016553a9 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1477,14 +1477,13 @@ static bool exists_devpath(const char *pathname, const char *sessname) return found; } -static bool insert_dev_if_not_exists_devpath(const char *pathname, - struct rnbd_clt_session *sess, - struct rnbd_clt_dev *dev) +static bool insert_dev_if_not_exists_devpath(struct rnbd_clt_dev *dev) { bool found; + struct rnbd_clt_session *sess = dev->sess; mutex_lock(&sess_lock); - found = __exists_dev(pathname, sess->sessname); + found = __exists_dev(dev->pathname, sess->sessname); if (!found) { mutex_lock(&sess->lock); list_add_tail(&dev->list, &sess->devs_list); @@ -1528,7 +1527,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, ret = PTR_ERR(dev); goto put_sess; } - if (insert_dev_if_not_exists_devpath(pathname, sess, dev)) { + if (insert_dev_if_not_exists_devpath(dev)) { ret = -EEXIST; goto put_dev; } From patchwork Tue Mar 30 07:37:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6C53C433E9 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2FB16199A for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbhC3Hik (ORCPT ); Tue, 30 Mar 2021 03:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbhC3HiF (ORCPT ); Tue, 30 Mar 2021 03:38:05 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF600C061762 for ; Tue, 30 Mar 2021 00:38:04 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id e7so16991937edu.10 for ; Tue, 30 Mar 2021 00:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nb98K5yr7Hr81H1xM1HbveTdnjGZy9hyYyfNIs0ucDU=; b=Hug8apLsGdflPUJT5Gyc9Ti7pTmviziJ2UiK6uSwGxXH4eRS8OGvRPJRYM9lgIJk6B QkQrVzoUENN5X6Ut4L44ZG4EzpdSF8NtfHapOvWmJnTHFxHx1bYim0DgpiSEy+4tHYbN Z/YUx7ZlJD1pDj7e3nDIMgTWMNJazJlqJh27PCaR6FLVNwoqwjl3uTsWGwskY3Ls1129 ve47dNKYN5u0vSN3EklPgSM/HLH18DmQSnvkTa+xrZr6g29NFYA3uU8T17uPUt/oxUtg De68nB7KKP/0v+16Yp3PohKJspT9jyejzXU7zcfaum3l0cpnNlyM4RLMEKLccRauML6d Ud0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nb98K5yr7Hr81H1xM1HbveTdnjGZy9hyYyfNIs0ucDU=; b=FGQ7Jv5Jz5bExDsY9Yb4sIrTepHpDBVw2haPcqimEwhhbKDlwBTekZrZPRDdeGZDzd m+IQbZ3hUqv9aViAkPPq7/6R3+Os20cnOG6Xl/196WgXA0ZuOn90bjQdgWzHP2SvExwk hz7f3TMXgy57eS8FW0PCl8n882SFLjJKfuN/uI+qb+qH9eXa4cZg/6ka5Bl2l1rrQPta V8lOiuWr2ky4lcUU/WjDlNuQEmmHynsRtRcRnNKnAgIbNjMLtLJ1CRf8blLucpWzZgDS ZOHmeyPehF2UwgMQTGiARWkdoz8B3EUdJVCEOQAhjQlI1yrVzv6oMsmTKaG99SJfgssE z2Jg== X-Gm-Message-State: AOAM530mlvK1jK75fvNqsRXwKR3trXa6w05L2RVmPvA+Rxk4lwKjaepy RGwh9qbuui0k8k+jCYYfw8hgGGvPJziB93MA X-Google-Smtp-Source: ABdhPJzeruynk0sLA/xtToJf28maRiWsuPEjqfOZ+6pU0qUruRFH2womp0cMcnWxXYzFDAGmavNraQ== X-Received: by 2002:a05:6402:2076:: with SMTP id bd22mr31761449edb.378.1617089883350; Tue, 30 Mar 2021 00:38:03 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:03 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Danil Kipnis , Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 09/24] block/rnbd-clt: Remove some arguments from rnbd_client_setup_device Date: Tue, 30 Mar 2021 09:37:37 +0200 Message-Id: <20210330073752.1465613-10-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Guoqing Jiang Remove them since both sess and idx can be dereferenced from dev. And sess is not used in the function. Signed-off-by: Guoqing Jiang Reviewed-by: Danil Kipnis Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index c8de016553a9..5d085bc80e24 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1360,10 +1360,9 @@ static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx) blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue); } -static int rnbd_client_setup_device(struct rnbd_clt_session *sess, - struct rnbd_clt_dev *dev, int idx) +static int rnbd_client_setup_device(struct rnbd_clt_dev *dev) { - int err; + int err, idx = dev->clt_device_id; dev->size = dev->nsectors * dev->logical_block_size; @@ -1541,7 +1540,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, mutex_lock(&dev->lock); pr_debug("Opened remote device: session=%s, path='%s'\n", sess->sessname, pathname); - ret = rnbd_client_setup_device(sess, dev, dev->clt_device_id); + ret = rnbd_client_setup_device(dev); if (ret) { rnbd_clt_err(dev, "map_device: Failed to configure device, err: %d\n", From patchwork Tue Mar 30 07:37:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58E65C433E2 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13C0561990 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231259AbhC3Hik (ORCPT ); Tue, 30 Mar 2021 03:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbhC3HiG (ORCPT ); Tue, 30 Mar 2021 03:38:06 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8C5EC061765 for ; Tue, 30 Mar 2021 00:38:05 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a7so23326879ejs.3 for ; Tue, 30 Mar 2021 00:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b2yp/UBdxAZOVqKqqU3/o+Z/JLidVsfOi1IBQ0gDYP8=; b=dpFE5WU4Nxw5eGidDDVsfZ1/SyIA9qWdO6iNgx3ZVKjv9jECj+UTycjrqRHQVWFp9n 3T4nK+XnLECDA5g0Vdg6MxtJMndsF189LvyGN3rA37RQe0yCiIwh7RBmFrZGNxZV4ATp iAKc1fnE9Fcn9nNuS5xWUn71BqJcjz5PmWRDzNxKBSvo4Osts91aBLNE8CcnI/R3FWR9 j4MJ9nHZIV1TD9MKhTB72z8mcNiPZlwNwoqRmwvsoezPLG5HCA0J4vEKMywXOKeYILgQ lV2BPsykQSiaUsk/FcfBc6jPEbPAvyJJM2v3T+A6GIeZ4zoMwv8WI/5+QBnk21jBUspW 7gxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b2yp/UBdxAZOVqKqqU3/o+Z/JLidVsfOi1IBQ0gDYP8=; b=dFhukTfhSEevcdMwz7E7oTk9DdGGbzK5QqesRBqBQN0IQLKNA/pprjDgyio48lIyN2 dMSeUarhiM3orN7ttJ54EZOEw+o0KBT8rSEs2XyMPWnRWh1fJcXAqQViCICMEVs1GkcE cyfyuWZS4AEKa/sv1b+hHUg+d+c0eV2CRE9tzHJWCXReh4tp3igCc/mSUeiJQh6FJe9i wosUr6WCK7PbfSV1TZ+2e6r4k4joWlzaeK/w0FCBm+ttDynAiwG2tEic5MxLTVb54caD YHfQXPLr+gqT+t7zRIR46GBr0DvAe+8jXlFseXjpdySUHRG1sQa/THax3WiOOH68YpSF eMsg== X-Gm-Message-State: AOAM533+rmJf3WNhXdORbMo9LR1YlYegqxeaI//fOLMMT4PYck+1Bm2V 80jwc8To85wavCf2FLwBwSC9C2g4AMrweu/o X-Google-Smtp-Source: ABdhPJw5A0OC4jMYxSKh0Fmw59HSXwdvIrRm8G+ssUd5dXNXB9wsWN10h97n01NWzOxIb3j1mZIUnA== X-Received: by 2002:a17:906:70d:: with SMTP id y13mr31221749ejb.170.1617089884438; Tue, 30 Mar 2021 00:38:04 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:04 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Danil Kipnis , Gioh Kim , Jack Wang Subject: [PATCHv2 for-next 10/24] block/rnbd-clt: Move add_disk(dev->gd) to rnbd_clt_setup_gen_disk Date: Tue, 30 Mar 2021 09:37:38 +0200 Message-Id: <20210330073752.1465613-11-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Guoqing Jiang It makes more sense to add gendisk in rnbd_clt_setup_gen_disk, instead of do it in rnbd_clt_map_device. Signed-off-by: Guoqing Jiang Reviewed-by: Danil Kipnis Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 5d085bc80e24..d8b9c552271c 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1358,6 +1358,7 @@ static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx) if (!dev->rotational) blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue); + add_disk(dev->gd); } static int rnbd_client_setup_device(struct rnbd_clt_dev *dev) @@ -1561,8 +1562,6 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, dev->max_hw_sectors, dev->rotational, dev->wc, dev->fua); mutex_unlock(&dev->lock); - - add_disk(dev->gd); rnbd_clt_put_sess(sess); return dev; From patchwork Tue Mar 30 07:37:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 079EDC433EB for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA597619BB for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbhC3Hil (ORCPT ); Tue, 30 Mar 2021 03:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhC3HiH (ORCPT ); Tue, 30 Mar 2021 03:38:07 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C64C0613DB for ; Tue, 30 Mar 2021 00:38:07 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id o19so17039447edc.3 for ; Tue, 30 Mar 2021 00:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CnARvf2OVorx0aWtIbfM1m/ZXt63MvsBP7Ym4cjRdv4=; b=WZ0QBYBa3XXBbh3tval7m1MJ0is9okRYJzU7+PbRvqDtWn5y5tt2/AelU3yS5e+ibo 9Ec6CNhHwIrgNjKAF8NoifRbEhg47QRz5TBzxHsVe/SqXbOKhmcU2N6fx49p7dMHFJnE +XSfLJchg2Q9qr1peDCw/r4rjDef0u7R/YSCZwyupeFRm8Ak2T+m0QswLDVf1sMBPsDE gvFx5nha8396OD7YkLAJBF/v+7PJ9Mf6A1fNIK8RbB6+/t5N+YOt4ajqK5fQ8D8+UY8F DCaAo1UlS4TTl7F0NReY0pdeGrG0djtkqWx149idVM8rlsHTkEJofrS4+kj5IbI1yyOj XvkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CnARvf2OVorx0aWtIbfM1m/ZXt63MvsBP7Ym4cjRdv4=; b=HLb+9kXPeW5E0R2s4PpkekJKcYUZMiv07g60nB18r2IYoChFW9697rqYofmGGlnlBf tsEbNlQc9B8bflvl959v4M10S83zs4Crq3YU4NesGEF9fYpwD6vYo06J2IAAkczuW5c1 oLD+7dy4Og92yDL2dezBu4l7x6rHyEkIj/AqVhWvw72ibYqBKU3g8SXo6QbAQNEu0ZG3 9fjy730UqQO9L/GNbyhHwOm0dRtgZmZKQkucNMmOx5IhUxmNwno9/EzO0eiz5KyI8oie uVzM2ryDVOZcfERten/QwQMLPJ1/70S1oIMukBwAllogHYGybYHheW6TzWxwfVcrghcQ sWMA== X-Gm-Message-State: AOAM533dBWztN5C+kujBNbfXqlGFy4AD9Odl6PoggUgEH0MseuXfBxR7 1b1vB5gobaaYvwb0PUWjOvdEd/W+RnI7vBFC X-Google-Smtp-Source: ABdhPJyX7Jaa7KtBPyoJdhBEHjb/GGFrHdci5RBF9hjG4JuzCHsIJMuSHKTj3+N641l5l7g7RUWMFA== X-Received: by 2002:a50:fe08:: with SMTP id f8mr31943019edt.217.1617089885700; Tue, 30 Mar 2021 00:38:05 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:05 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Danil Kipnis , Gioh Kim Subject: [PATCHv2 for-next 11/24] block/rnbd: Kill rnbd_clt_destroy_default_group Date: Tue, 30 Mar 2021 09:37:39 +0200 Message-Id: <20210330073752.1465613-12-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Guoqing Jiang No need to have it since we can call sysfs_remove_group in the rnbd_clt_destroy_sysfs_files. Then rnbd_clt_destroy_sysfs_files is paired with it's counterpart rnbd_clt_create_sysfs_files. Signed-off-by: Guoqing Jiang Reviewed-by: Danil Kipnis Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt-sysfs.c | 6 +----- drivers/block/rnbd/rnbd-clt.c | 1 - drivers/block/rnbd/rnbd-clt.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index d83415875960..2452eb67547c 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -639,13 +639,9 @@ int rnbd_clt_create_sysfs_files(void) return err; } -void rnbd_clt_destroy_default_group(void) -{ - sysfs_remove_group(&rnbd_dev->kobj, &default_attr_group); -} - void rnbd_clt_destroy_sysfs_files(void) { + sysfs_remove_group(&rnbd_dev->kobj, &default_attr_group); kobject_del(rnbd_devs_kobj); kobject_put(rnbd_devs_kobj); device_destroy(rnbd_dev_class, MKDEV(0, 0)); diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index d8b9c552271c..fce0f345f796 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1692,7 +1692,6 @@ static void rnbd_destroy_sessions(void) struct rnbd_clt_dev *dev, *tn; /* Firstly forbid access through sysfs interface */ - rnbd_clt_destroy_default_group(); rnbd_clt_destroy_sysfs_files(); /* diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h index 5ecbe8dedf24..d2a709f5d7ed 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -168,7 +168,6 @@ int rnbd_clt_resize_disk(struct rnbd_clt_dev *dev, size_t newsize); int rnbd_clt_create_sysfs_files(void); void rnbd_clt_destroy_sysfs_files(void); -void rnbd_clt_destroy_default_group(void); void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev); From patchwork Tue Mar 30 07:37:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB103C433EC for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D94EC61959 for ; Tue, 30 Mar 2021 07:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbhC3Him (ORCPT ); Tue, 30 Mar 2021 03:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbhC3HiI (ORCPT ); Tue, 30 Mar 2021 03:38:08 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C93CDC0613DC for ; Tue, 30 Mar 2021 00:38:07 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id hq27so23297594ejc.9 for ; Tue, 30 Mar 2021 00:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tFSHDt2a4UMse8UCqMOLtSx70A+SNRfPmGCXQKYuQAY=; b=faceGjifndcv1IRDoE48i5dDQkGM+fMgsgFlgzHevrjPnx6HzRoDhfuNDIJcrAtqdk 3jOqzkRdQmCG5RmfWhD7Yu6oT0b+ZtDiLBx9rzEbgQKuhDEs325jnjoL3923p9JWrR4e zkOLf7yCgt0dvduwcTmBMjXOyWBRZtP1QKWGrSKJhvlUNn3I0UkEyBJsJ3CjUwi6hEx7 KQ7skCTRuBzXBX5ROxKsXjsLYTKc7Lk+3is1jc6kpxgCy8O3Mu4xThTcOa7v0G3X0Wcr 6PcYBIvounywtcX5VOpWTpoF5RsV30+1MjTBqQUVUxJ97JyyO8EnqemetzNP9RLToO7N XASQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tFSHDt2a4UMse8UCqMOLtSx70A+SNRfPmGCXQKYuQAY=; b=XEnbbGFyxlffMyX3C9R1W9AapZA2emrJJq1Fk9AtkJ8nlNBk2+6eiC1RL2wn+/6FlA a2lPXVfXNgKwcxfzhlHU/R0uEk0isNKFMNGQw2sPuS9uxuNXUQ3QrSWDwKM2KqTkZknR DKIm5A1jjTJ8gpklBTPwCDTZjj/vbdZzaIUJHyn1oCUJ6QVkJJ6Ozdhn8zyefI75wmpK r/8zTwZ7D+/BFE1HjX6d0sLvekhlfxC0whATHhsMAhcbbDcJQUMwu7flQs9EHmaCLhfe 9ef/LYZoclKkBD4DswoHWgGRtWMB0S2QUNmAY610y8nZ29so/HlKmZYiXMov5tbUnFcI XyWg== X-Gm-Message-State: AOAM533L4Gfo9nfUANXa0uzMRFzdRJWwf8d3UxtvRwfLL4RCpxVq1kOE hm8FNFJUvlLg0S8+LFRTIdF6Pv4llQ841Liq X-Google-Smtp-Source: ABdhPJwWRICxQjoTNQvgwrEe5cBMwNa8uNHj48wmkcz7RT+1C5//6GEPPJ+w6ewG6KdS/aSvhea6sA== X-Received: by 2002:a17:906:3b48:: with SMTP id h8mr31778644ejf.261.1617089886501; Tue, 30 Mar 2021 00:38:06 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:06 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Danil Kipnis , Gioh Kim Subject: [PATCHv2 for-next 12/24] block/rnbd: Kill destroy_device_cb Date: Tue, 30 Mar 2021 09:37:40 +0200 Message-Id: <20210330073752.1465613-13-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Guoqing Jiang We can use destroy_device directly since destroy_device_cb is just the wrapper of destroy_device. Signed-off-by: Guoqing Jiang Reviewed-by: Danil Kipnis Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-srv.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 447fb0718525..895e9c313ff0 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -183,8 +183,10 @@ static int process_rdma(struct rtrs_srv *sess, return err; } -static void destroy_device(struct rnbd_srv_dev *dev) +static void destroy_device(struct kref *kref) { + struct rnbd_srv_dev *dev = container_of(kref, struct rnbd_srv_dev, kref); + WARN_ONCE(!list_empty(&dev->sess_dev_list), "Device %s is being destroyed but still in use!\n", dev->id); @@ -203,18 +205,9 @@ static void destroy_device(struct rnbd_srv_dev *dev) kfree(dev); } -static void destroy_device_cb(struct kref *kref) -{ - struct rnbd_srv_dev *dev; - - dev = container_of(kref, struct rnbd_srv_dev, kref); - - destroy_device(dev); -} - static void rnbd_put_srv_dev(struct rnbd_srv_dev *dev) { - kref_put(&dev->kref, destroy_device_cb); + kref_put(&dev->kref, destroy_device); } void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id) From patchwork Tue Mar 30 07:37:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C315C433FB for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DB9B61955 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbhC3Hio (ORCPT ); Tue, 30 Mar 2021 03:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231329AbhC3HiJ (ORCPT ); Tue, 30 Mar 2021 03:38:09 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B30C5C0613D8 for ; Tue, 30 Mar 2021 00:38:08 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id bf3so17029899edb.6 for ; Tue, 30 Mar 2021 00:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XRGE6YSZlGMJfheJ34bYryhpSeJn76sa8WGvFZ76Ync=; b=HuKlJmO327uqa1epPSGqfHDDGCQc0R1mSFe295/0D+tgj2E7DYwUYmHsR8ieBJOd1+ Gt/MGsW7oIFMuwHlMNgeq+lxvJcnUP1sjKv6WH2xycTJVXfU4zSFRpBzzq8AFQG3vZxp nrm85EEmOe9UkYkKxTUEEBPN5uf4r0b4zkm620p4WaSjfMBXx6EdrmWG7znm4ZDOJtin 5CRFuRe2EpyWkrygvUmZ/OMKb4phEYveqgn+EZkH0oLcbEsDjS5Jaqd32YJWyk1rbpAl zaND4V5fDZ7OodR1tFGTs9gPPPR6Dkpu8YbcTQFgrbzmTucksmE0I0W88g49tE/b/0EB C8/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XRGE6YSZlGMJfheJ34bYryhpSeJn76sa8WGvFZ76Ync=; b=uOc8Q83TtLVxCQkUF6GbHMlSQO2fYEd4uJ7sGLpU1hm3V/6oTzueJJNddD8ATBUlNw zc+26pjgdRd3olALFJG1qxzXlFWyZ5486TyNEEOOTDbjoqnof4cuYdXapdNOr6xQsLO7 NVRHyOOLYgfGqlDOdkro4hP/ckRqrWW96U1uaRvO0mJu/ZxrSF4avvtNySPU4scvnhko cr1R9dbOGX/nCYk42j4mThhLmEN/JYqOPu6nSqRX60jnwOqVSKHyp4eGWHD0PRUH+q6D CC9AV30ujhN6rqGW01Ail7QIcxgZ1WV/XNxsjCSlUxEfDSccmcViNxuPPOWSg5JEaarg v+yQ== X-Gm-Message-State: AOAM533o9BRxCEZXm2zdOqpP8bNwMkE/LZP9caLRixE8IYHdyWyQhxib MQuH0A/QctOm4E1jP/DW4omWVYmrHDhTZKDU X-Google-Smtp-Source: ABdhPJyLG+ibtypQgqhve52tSur+fWMfNPHf1Xdf4huK5wMYYs9tiFAdKaX7YiXCgnU5bbKG6HYX8Q== X-Received: by 2002:a05:6402:484:: with SMTP id k4mr31989952edv.321.1617089887400; Tue, 30 Mar 2021 00:38:07 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:07 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, Guoqing Jiang , Gioh Kim Subject: [PATCHv2 for-next 13/24] block/rnbd-clt: Replace {NO_WAIT,WAIT} with RTRS_PERMIT_{WAIT,NOWAIT} Date: Tue, 30 Mar 2021 09:37:41 +0200 Message-Id: <20210330073752.1465613-14-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim They are defined with the same value and similar meaning, let's remove one of them, then we can remove {WAIT,NOWAIT}. Also change the type of 'wait' from 'int' to 'enum wait_type' to make it clear. Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.c | 42 +++++++++++--------------- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 +-- drivers/infiniband/ulp/rtrs/rtrs.h | 6 ++-- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index fce0f345f796..6aba7b26f260 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -312,13 +312,11 @@ static void rnbd_rerun_all_if_idle(struct rnbd_clt_session *sess) static struct rtrs_permit *rnbd_get_permit(struct rnbd_clt_session *sess, enum rtrs_clt_con_type con_type, - int wait) + enum wait_type wait) { struct rtrs_permit *permit; - permit = rtrs_clt_get_permit(sess->rtrs, con_type, - wait ? RTRS_PERMIT_WAIT : - RTRS_PERMIT_NOWAIT); + permit = rtrs_clt_get_permit(sess->rtrs, con_type, wait); if (likely(permit)) /* We have a subtle rare case here, when all permits can be * consumed before busy counter increased. This is safe, @@ -344,7 +342,7 @@ static void rnbd_put_permit(struct rnbd_clt_session *sess, static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess, enum rtrs_clt_con_type con_type, - int wait) + enum wait_type wait) { struct rnbd_iu *iu; struct rtrs_permit *permit; @@ -354,9 +352,7 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess, return NULL; } - permit = rnbd_get_permit(sess, con_type, - wait ? RTRS_PERMIT_WAIT : - RTRS_PERMIT_NOWAIT); + permit = rnbd_get_permit(sess, con_type, wait); if (unlikely(!permit)) { kfree(iu); return NULL; @@ -440,16 +436,11 @@ static void msg_conf(void *priv, int errno) schedule_work(&iu->work); } -enum wait_type { - NO_WAIT = 0, - WAIT = 1 -}; - static int send_usr_msg(struct rtrs_clt *rtrs, int dir, struct rnbd_iu *iu, struct kvec *vec, size_t len, struct scatterlist *sg, unsigned int sg_len, void (*conf)(struct work_struct *work), - int *errno, enum wait_type wait) + int *errno, int wait) { int err; struct rtrs_clt_req_ops req_ops; @@ -481,7 +472,8 @@ static void msg_close_conf(struct work_struct *work) rnbd_clt_put_dev(dev); } -static int send_msg_close(struct rnbd_clt_dev *dev, u32 device_id, bool wait) +static int send_msg_close(struct rnbd_clt_dev *dev, u32 device_id, + enum wait_type wait) { struct rnbd_clt_session *sess = dev->sess; struct rnbd_msg_close msg; @@ -535,7 +527,7 @@ static void msg_open_conf(struct work_struct *work) * If server thinks its fine, but we fail to process * then be nice and send a close to server. */ - (void)send_msg_close(dev, device_id, NO_WAIT); + send_msg_close(dev, device_id, RTRS_PERMIT_NOWAIT); } } kfree(rsp); @@ -559,7 +551,7 @@ static void msg_sess_info_conf(struct work_struct *work) rnbd_clt_put_sess(sess); } -static int send_msg_open(struct rnbd_clt_dev *dev, bool wait) +static int send_msg_open(struct rnbd_clt_dev *dev, enum wait_type wait) { struct rnbd_clt_session *sess = dev->sess; struct rnbd_msg_open_rsp *rsp; @@ -606,7 +598,7 @@ static int send_msg_open(struct rnbd_clt_dev *dev, bool wait) return err; } -static int send_msg_sess_info(struct rnbd_clt_session *sess, bool wait) +static int send_msg_sess_info(struct rnbd_clt_session *sess, enum wait_type wait) { struct rnbd_msg_sess_info_rsp *rsp; struct rnbd_msg_sess_info msg; @@ -692,7 +684,7 @@ static void remap_devs(struct rnbd_clt_session *sess) * be asynchronous. */ - err = send_msg_sess_info(sess, NO_WAIT); + err = send_msg_sess_info(sess, RTRS_PERMIT_NOWAIT); if (err) { pr_err("send_msg_sess_info(\"%s\"): %d\n", sess->sessname, err); return; @@ -716,7 +708,7 @@ static void remap_devs(struct rnbd_clt_session *sess) continue; rnbd_clt_info(dev, "session reconnected, remapping device\n"); - err = send_msg_open(dev, NO_WAIT); + err = send_msg_open(dev, RTRS_PERMIT_NOWAIT); if (err) { rnbd_clt_err(dev, "send_msg_open(): %d\n", err); break; @@ -1248,7 +1240,7 @@ find_and_get_or_create_sess(const char *sessname, if (err) goto close_rtrs; - err = send_msg_sess_info(sess, WAIT); + err = send_msg_sess_info(sess, RTRS_PERMIT_WAIT); if (err) goto close_rtrs; @@ -1531,7 +1523,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, ret = -EEXIST; goto put_dev; } - ret = send_msg_open(dev, WAIT); + ret = send_msg_open(dev, RTRS_PERMIT_WAIT); if (ret) { rnbd_clt_err(dev, "map_device: failed, can't open remote device, err: %d\n", @@ -1567,7 +1559,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, return dev; send_close: - send_msg_close(dev, dev->device_id, WAIT); + send_msg_close(dev, dev->device_id, RTRS_PERMIT_WAIT); del_dev: delete_dev(dev); put_dev: @@ -1636,7 +1628,7 @@ int rnbd_clt_unmap_device(struct rnbd_clt_dev *dev, bool force, destroy_sysfs(dev, sysfs_self); destroy_gen_disk(dev); if (was_mapped && sess->rtrs) - send_msg_close(dev, dev->device_id, WAIT); + send_msg_close(dev, dev->device_id, RTRS_PERMIT_WAIT); rnbd_clt_info(dev, "Device is unmapped\n"); @@ -1670,7 +1662,7 @@ int rnbd_clt_remap_device(struct rnbd_clt_dev *dev) mutex_unlock(&dev->lock); if (!err) { rnbd_clt_info(dev, "Remapping device.\n"); - err = send_msg_open(dev, WAIT); + err = send_msg_open(dev, RTRS_PERMIT_WAIT); if (err) rnbd_clt_err(dev, "remap_device: %d\n", err); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 0a08b4b742a3..7efd49bdc78c 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -103,11 +103,11 @@ static inline void __rtrs_put_permit(struct rtrs_clt *clt, * up earlier. * * Context: - * Can sleep if @wait == RTRS_TAG_WAIT + * Can sleep if @wait == RTRS_PERMIT_WAIT */ struct rtrs_permit *rtrs_clt_get_permit(struct rtrs_clt *clt, enum rtrs_clt_con_type con_type, - int can_wait) + enum wait_type can_wait) { struct rtrs_permit *permit; DEFINE_WAIT(wait); diff --git a/drivers/infiniband/ulp/rtrs/rtrs.h b/drivers/infiniband/ulp/rtrs/rtrs.h index 8738e90e715a..2db1b5eb3ab0 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.h +++ b/drivers/infiniband/ulp/rtrs/rtrs.h @@ -63,9 +63,9 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, void rtrs_clt_close(struct rtrs_clt *sess); -enum { +enum wait_type { RTRS_PERMIT_NOWAIT = 0, - RTRS_PERMIT_WAIT = 1, + RTRS_PERMIT_WAIT = 1 }; /** @@ -81,7 +81,7 @@ enum rtrs_clt_con_type { struct rtrs_permit *rtrs_clt_get_permit(struct rtrs_clt *sess, enum rtrs_clt_con_type con_type, - int wait); + enum wait_type wait); void rtrs_clt_put_permit(struct rtrs_clt *sess, struct rtrs_permit *permit); From patchwork Tue Mar 30 07:37:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46627C433F1 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D2B861990 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231337AbhC3Him (ORCPT ); Tue, 30 Mar 2021 03:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbhC3HiL (ORCPT ); Tue, 30 Mar 2021 03:38:11 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9275EC061762 for ; Tue, 30 Mar 2021 00:38:09 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id kt15so23282308ejb.12 for ; Tue, 30 Mar 2021 00:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SoMSIcCp8+AqPcP3Tord2AzO8LTHhNxNANk75Scwquk=; b=ITFd70WEYwdOvjemh4iTNpEczrRqBt1NDOlkhgunqsWoHahUkm8TodeNTi5GypuQhN wrPtqU7l0MbgtK5gsHjRFMvAn9/3/afe73NUYM4XxmlmCnGVGC109612VlaFp4nCR9oJ qaJ7lxpU6p70FySP74iNxuQ3Fdukc49MTk3HGr2g1I2xkgRfWWHZNsvNn1HkhUovbURf YTvp7ynX1wKjzSYhgVvcANvHqNgwUNssbT6lROxmX6MDssNIk0X/EtgBdS1D8W2+U4/R OADz8I5RqWjHRz63voYCniM95aINh/pWZLvrTu3Shf113C54r1RAeUGWGK/nx8CcGmKB 0T3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SoMSIcCp8+AqPcP3Tord2AzO8LTHhNxNANk75Scwquk=; b=apq6RQvyPaAAArtxhOtohcOxM+G8+qn1goFa6DXn4biMuhCEfpYc99qH2647oHey/4 Q/p9NPmy49KpQ32wcuO/Dfc78I5xN/YbgwvZGoyviPgDe+YFH0w5R8HedtWp1Xo6/iKX 7JVX2D64oxBA3Y0Xfr+vY6+D9SBGwKlMPjqTO463Ofi5yvF0//3bPAuXZDCKZAjUB0dN v4+NXdg8qtUBsylAi0YS2Sd0j/xvMwzMO2LX28UG5YU6om+YK0JnC7wYuFkuXgCytNHm c1ShjXYTK7wq2EpX/S/7koHyHpP/vxT1uN3JFxKouge3xMzFpS6+Kj1LNYT5Ys8LuLtR w+Qg== X-Gm-Message-State: AOAM532zVQvfqPgMT4Qe8l2E5tTESiKv430CK89TmaIvlgLGX+JYRU2i nnrqGef721nB7wtmwujzGz8/OBvz0ipYpxiJ X-Google-Smtp-Source: ABdhPJxpN6jUprFr0lhe7Y6m7AVLX6BZuXwf+zjXZUTHGkpXjuPemXdbLpbBHNiqZ5tud1tMHdsT2g== X-Received: by 2002:a17:906:85b:: with SMTP id f27mr32597212ejd.414.1617089888132; Tue, 30 Mar 2021 00:38:08 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:07 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv2 for-next 14/24] block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallel Date: Tue, 30 Mar 2021 09:37:42 +0200 Message-Id: <20210330073752.1465613-15-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim We got a warning message below. When server tries to close one session by force, it locks the sysfs interface and locks the srv_sess lock. The problem is that client can send a request to close at the same time. By close request, server locks the srv_sess lock and locks the sysfs to remove the sysfs interfaces. The simplest way to prevent that situation could be just use mutex_trylock. [ 234.153965] ====================================================== [ 234.154093] WARNING: possible circular locking dependency detected [ 234.154219] 5.4.84-storage #5.4.84-1+feature+linux+5.4.y+dbg+20201216.1319+b6b887b~deb10 Tainted: G O [ 234.154381] ------------------------------------------------------ [ 234.154531] kworker/1:1H/618 is trying to acquire lock: [ 234.154651] ffff8887a09db0a8 (kn->count#132){++++}, at: kernfs_remove_by_name_ns+0x40/0x80 [ 234.154819] but task is already holding lock: [ 234.154965] ffff8887ae5f6518 (&srv_sess->lock){+.+.}, at: rnbd_srv_rdma_ev+0x144/0x1590 [rnbd_server] [ 234.155132] which lock already depends on the new lock. [ 234.155311] the existing dependency chain (in reverse order) is: [ 234.155462] -> #1 (&srv_sess->lock){+.+.}: [ 234.155614] __mutex_lock+0x134/0xcb0 [ 234.155761] rnbd_srv_sess_dev_force_close+0x36/0x50 [rnbd_server] [ 234.155889] rnbd_srv_dev_session_force_close_store+0x69/0xc0 [rnbd_server] [ 234.156042] kernfs_fop_write+0x13f/0x240 [ 234.156162] vfs_write+0xf3/0x280 [ 234.156278] ksys_write+0xba/0x150 [ 234.156395] do_syscall_64+0x62/0x270 [ 234.156513] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 234.156632] -> #0 (kn->count#132){++++}: [ 234.156782] __lock_acquire+0x129e/0x23a0 [ 234.156900] lock_acquire+0xf3/0x210 [ 234.157043] __kernfs_remove+0x42b/0x4c0 [ 234.157161] kernfs_remove_by_name_ns+0x40/0x80 [ 234.157282] remove_files+0x3f/0xa0 [ 234.157399] sysfs_remove_group+0x4a/0xb0 [ 234.157519] rnbd_srv_destroy_dev_session_sysfs+0x19/0x30 [rnbd_server] [ 234.157648] rnbd_srv_rdma_ev+0x14c/0x1590 [rnbd_server] [ 234.157775] process_io_req+0x29a/0x6a0 [rtrs_server] [ 234.157924] __ib_process_cq+0x8c/0x100 [ib_core] [ 234.158709] ib_cq_poll_work+0x31/0xb0 [ib_core] [ 234.158834] process_one_work+0x4e5/0xaa0 [ 234.158958] worker_thread+0x65/0x5c0 [ 234.159078] kthread+0x1e0/0x200 [ 234.159194] ret_from_fork+0x24/0x30 [ 234.159309] other info that might help us debug this: [ 234.159513] Possible unsafe locking scenario: [ 234.159658] CPU0 CPU1 [ 234.159775] ---- ---- [ 234.159891] lock(&srv_sess->lock); [ 234.160005] lock(kn->count#132); [ 234.160128] lock(&srv_sess->lock); [ 234.160250] lock(kn->count#132); [ 234.160364] *** DEADLOCK *** [ 234.160536] 3 locks held by kworker/1:1H/618: [ 234.160677] #0: ffff8883ca1ed528 ((wq_completion)ib-comp-wq){+.+.}, at: process_one_work+0x40a/0xaa0 [ 234.160840] #1: ffff8883d2d5fe10 ((work_completion)(&cq->work)){+.+.}, at: process_one_work+0x40a/0xaa0 [ 234.161003] #2: ffff8887ae5f6518 (&srv_sess->lock){+.+.}, at: rnbd_srv_rdma_ev+0x144/0x1590 [rnbd_server] [ 234.161168] stack backtrace: [ 234.161312] CPU: 1 PID: 618 Comm: kworker/1:1H Tainted: G O 5.4.84-storage #5.4.84-1+feature+linux+5.4.y+dbg+20201216.1319+b6b887b~deb10 [ 234.161490] Hardware name: Supermicro H8QG6/H8QG6, BIOS 3.00 09/04/2012 [ 234.161643] Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] [ 234.161765] Call Trace: [ 234.161910] dump_stack+0x96/0xe0 [ 234.162028] check_noncircular+0x29e/0x2e0 [ 234.162148] ? print_circular_bug+0x100/0x100 [ 234.162267] ? register_lock_class+0x1ad/0x8a0 [ 234.162385] ? __lock_acquire+0x68e/0x23a0 [ 234.162505] ? trace_event_raw_event_lock+0x190/0x190 [ 234.162626] __lock_acquire+0x129e/0x23a0 [ 234.162746] ? register_lock_class+0x8a0/0x8a0 [ 234.162866] lock_acquire+0xf3/0x210 [ 234.162982] ? kernfs_remove_by_name_ns+0x40/0x80 [ 234.163127] __kernfs_remove+0x42b/0x4c0 [ 234.163243] ? kernfs_remove_by_name_ns+0x40/0x80 [ 234.163363] ? kernfs_fop_readdir+0x3b0/0x3b0 [ 234.163482] ? strlen+0x1f/0x40 [ 234.163596] ? strcmp+0x30/0x50 [ 234.163712] kernfs_remove_by_name_ns+0x40/0x80 [ 234.163832] remove_files+0x3f/0xa0 [ 234.163948] sysfs_remove_group+0x4a/0xb0 [ 234.164068] rnbd_srv_destroy_dev_session_sysfs+0x19/0x30 [rnbd_server] [ 234.164196] rnbd_srv_rdma_ev+0x14c/0x1590 [rnbd_server] [ 234.164345] ? _raw_spin_unlock_irqrestore+0x43/0x50 [ 234.164466] ? lockdep_hardirqs_on+0x1a8/0x290 [ 234.164597] ? mlx4_ib_poll_cq+0x927/0x1280 [mlx4_ib] [ 234.164732] ? rnbd_get_sess_dev+0x270/0x270 [rnbd_server] [ 234.164859] process_io_req+0x29a/0x6a0 [rtrs_server] [ 234.164982] ? rnbd_get_sess_dev+0x270/0x270 [rnbd_server] [ 234.165130] __ib_process_cq+0x8c/0x100 [ib_core] [ 234.165279] ib_cq_poll_work+0x31/0xb0 [ib_core] [ 234.165404] process_one_work+0x4e5/0xaa0 [ 234.165550] ? pwq_dec_nr_in_flight+0x160/0x160 [ 234.165675] ? do_raw_spin_lock+0x119/0x1d0 [ 234.165796] worker_thread+0x65/0x5c0 [ 234.165914] ? process_one_work+0xaa0/0xaa0 [ 234.166031] kthread+0x1e0/0x200 [ 234.166147] ? kthread_create_worker_on_cpu+0xc0/0xc0 [ 234.166268] ret_from_fork+0x24/0x30 [ 234.251591] rnbd_server L243: : Device closed [ 234.604221] rnbd_server L264: RTRS Session close_device_session disconnected Signed-off-by: Gioh Kim Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-srv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 895e9c313ff0..f284620ef0d3 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -340,7 +340,9 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev) struct rnbd_srv_session *sess = sess_dev->sess; sess_dev->keep_id = true; - mutex_lock(&sess->lock); + /* It is already started to close by client's close message. */ + if (!mutex_trylock(&sess->lock)) + return; rnbd_srv_destroy_dev_session_sysfs(sess_dev); mutex_unlock(&sess->lock); } From patchwork Tue Mar 30 07:37:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B084EC433F8 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96CDD61883 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbhC3Hio (ORCPT ); Tue, 30 Mar 2021 03:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbhC3HiL (ORCPT ); Tue, 30 Mar 2021 03:38:11 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBDAC061765 for ; Tue, 30 Mar 2021 00:38:10 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id y6so17067927eds.1 for ; Tue, 30 Mar 2021 00:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+fPRExy/th2Wxi81rNTwbnWXQ+KI4WdiMLN79pZ5LSY=; b=QySgObKFhq+YYsvXa7tHvjm8IGZV0mRsvwysN+8OIXE7er/UJ3RVgHjD2nxiTyZMYv hS2jnN9tklMnVYmMxtAcYXJGZw2djHOTrp4DyNRa7SRwwxZkqAPN1YSC2jJkpj7Zx1Pe ++cEJx6P6gwY6NiTzl3zTfIaAo9laVOWA2IlP5ENNiI4K19zfUwOJgsZnYBayL2FKOpu HacYk1OFwA5PzsPP+3B+R1fVxbQMzsgdOU442BH8KQfdOZddqC0A9Vz4a7rRBgXnwnuQ tn1DaVR5PzyCLvnyL+YyG96k9y/vHjL4lOWH8z1iq4OmWRSwmJFLzLR5ilmyN+JC8XMP 8arA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+fPRExy/th2Wxi81rNTwbnWXQ+KI4WdiMLN79pZ5LSY=; b=FU059FkXA2qL17im8Cyx3m/XJc2xBVEsCoJTiB+pTUK+utBnLwKgGJpzqVmK4I4viH l/V9tQ5+0nU3ub8D6AhpHtsUzYsfPjl/JaDhZY49qABAyGt0LMg5wKsJg1FNtZMUvw9f N+v9dcpb+NWCGOibv5z0U0k+kiiFNmuIDF+yLM4NbSI953K5HHl28ff8OGRTkEeaNxJk JVBLTf7fF8X2GD7ZRAEgxNERysjXR6H4kNZrZWFAdBHlV8Q/U/S+pgSDu7BTZ2r5o8KE GGw64Fr57XKBSG2LKlFb9ASNfidhBXkM14OLyZjUJR+XaPZ9gU+ebU/vMkekb9Wc1iNd oq4w== X-Gm-Message-State: AOAM530crMI9X7D1cye8Wnt/Ee3PMF31XMtU/bch9lQTtlunbJx2ln9T 1RUc4aayrgi/uBq3I0dHfoZks75sW2ixECfB X-Google-Smtp-Source: ABdhPJzds/SbUvrD1Wn7gGVlnmL6XVEbS0hEVtaYiBvT/ZE1YeFLq6kzaDDiR67HnLbUmdWJy/ERTg== X-Received: by 2002:a05:6402:19a:: with SMTP id r26mr31833190edv.44.1617089889143; Tue, 30 Mar 2021 00:38:09 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:08 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv2 for-next 15/24] block/rnbd-srv: Remove force_close file after holding a lock Date: Tue, 30 Mar 2021 09:37:43 +0200 Message-Id: <20210330073752.1465613-16-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim We changed the rnbd_srv_sess_dev_force_close to use try-lock because rnbd_srv_sess_dev_force_close and process_msg_close can generate a deadlock. Now rnbd_srv_sess_dev_force_close would do nothing if it fails to get the lock. So removing the force_close file should be moved to after the lock. Or the force_close file is removed but the others are not removed. Signed-off-by: Gioh Kim Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-srv-sysfs.c | 5 +---- drivers/block/rnbd/rnbd-srv.c | 5 ++++- drivers/block/rnbd/rnbd-srv.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c b/drivers/block/rnbd/rnbd-srv-sysfs.c index 278a981302b9..76f9c08f611f 100644 --- a/drivers/block/rnbd/rnbd-srv-sysfs.c +++ b/drivers/block/rnbd/rnbd-srv-sysfs.c @@ -147,10 +147,7 @@ static ssize_t rnbd_srv_dev_session_force_close_store(struct kobject *kobj, } rnbd_srv_info(sess_dev, "force close requested\n"); - - /* first remove sysfs itself to avoid deadlock */ - sysfs_remove_file_self(&sess_dev->kobj, &attr->attr); - rnbd_srv_sess_dev_force_close(sess_dev); + rnbd_srv_sess_dev_force_close(sess_dev, attr); return count; } diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index f284620ef0d3..a71b6f7662f5 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -335,7 +335,8 @@ static int rnbd_srv_link_ev(struct rtrs_srv *rtrs, } } -void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev) +void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, + struct kobj_attribute *attr) { struct rnbd_srv_session *sess = sess_dev->sess; @@ -343,6 +344,8 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev) /* It is already started to close by client's close message. */ if (!mutex_trylock(&sess->lock)) return; + /* first remove sysfs itself to avoid deadlock */ + sysfs_remove_file_self(&sess_dev->kobj, &attr->attr); rnbd_srv_destroy_dev_session_sysfs(sess_dev); mutex_unlock(&sess->lock); } diff --git a/drivers/block/rnbd/rnbd-srv.h b/drivers/block/rnbd/rnbd-srv.h index 120e6d64cb82..b513021efc92 100644 --- a/drivers/block/rnbd/rnbd-srv.h +++ b/drivers/block/rnbd/rnbd-srv.h @@ -72,7 +72,8 @@ struct rnbd_srv_sess_dev { struct rnbd_srv_fault_inject fault_inject; }; -void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev); +void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, + struct kobj_attribute *attr); /* rnbd-srv-sysfs.c */ int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev *dev, From patchwork Tue Mar 30 07:37:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60EF1C433F7 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4467361955 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229468AbhC3Him (ORCPT ); Tue, 30 Mar 2021 03:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231344AbhC3HiM (ORCPT ); Tue, 30 Mar 2021 03:38:12 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C33C0613D9 for ; Tue, 30 Mar 2021 00:38:11 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id u5so23329739ejn.8 for ; Tue, 30 Mar 2021 00:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pl2/fbfuKZ1ockeKTle4rwoFO6U1pHK3irg5VzOx9k8=; b=N/ZeqDaiLjWBR2XvYWW9My+j/Fks7Y+jenFhYx2GZCAtrKf2kT4EVX0LK5tnb1B579 jybyKAADuesHIw4cYtuuXv9LRGom1zK1jQdPRn5uBl4vRPwLv4VuI7ikTks5Q2VDLHEm G/6+DVToeeeqTiQt9dSioFW1YsEm2+th0ebbbZbp8JgddM15/nFrPQTwuxUdNNFkc5dt tiauV8RT/RrjiAki/XSD4ObLwAwtPwuZbbDdls9R1VnhpynNTQc32RHD5h5PJvXlid8I FkmFelmnBSuGdnHQXJnVjd6/op5m96JPmEADnze8uUToRMOonNGTJ01MZA5OQioHg4/G r34Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pl2/fbfuKZ1ockeKTle4rwoFO6U1pHK3irg5VzOx9k8=; b=D0wyIS1448b+zgjmYh6pePoG81ZH13Pxwri/0sULJrWkNV+8jtpWmPC0GXjWf/8a01 UUYeg71cZ9vauFe8vowPvqEzdDFdc6P2CLRSCmxkyvPOasXChBDwGq1DutaDTaeAwjZL 2lbNx1416YBKAe8C9m/fRfcaGzxCULXixpR+plOIbXg2NK6ddYJzzxJmxzP+ZWnEFFVa XODbGwT8UcEQziaQ7QCtSPQUHE1NrM52NedAg7wOVvZnyneED8WjUfCmquabf8mFkOnP eFravOBoA0fRhRGbZonSZ3MNEWa0izhaUrxi9otixtt6fmyuBQXRFnOO+aMn4HliACHJ BzMQ== X-Gm-Message-State: AOAM530kD2sq0LwhOiISYPM/8pnp9/n6KPCd9FBpesIWeO1tq7wI6Eoy FoGLT/RpuCjtu5qRNSqkR7WzB26nZb2+Nhmz X-Google-Smtp-Source: ABdhPJzE0oa9YtUt+WjUaubXky3sNLvKv/eOKcupntCS1R7318NoxAXc/WPcBtUgmif04YUeqx+n3Q== X-Received: by 2002:a17:906:33d9:: with SMTP id w25mr33525389eja.413.1617089889944; Tue, 30 Mar 2021 00:38:09 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:09 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Tom Rix , Gioh Kim Subject: [PATCHv2 for-next 16/24] block/rnbd-clt: Improve find_or_create_sess() return check Date: Tue, 30 Mar 2021 09:37:44 +0200 Message-Id: <20210330073752.1465613-17-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Tom Rix clang static analysis reports this problem rnbd-clt.c:1212:11: warning: Branch condition evaluates to a garbage value else if (!first) ^~~~~~ This is triggered in the find_and_get_or_create_sess() call because the variable first is not initialized and the earlier check is specifically for if (sess == ERR_PTR(-ENOMEM)) This is false positive. But the if-check can be reduced by initializing first to false and then returning if the call to find_or_creat_sess() does not set it to true. When it remains false, either sess will be valid or not. The not case is caught by find_and_get_or_create_sess()'s caller rnbd_clt_map_device() sess = find_and_get_or_create_sess(...); if (IS_ERR(sess)) return ERR_CAST(sess); Since find_and_get_or_create_sess() initializes first to false setting it in find_or_create_sess() is not needed. Signed-off-by: Tom Rix Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/block/rnbd/rnbd-clt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 6aba7b26f260..6f955a937f40 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -915,6 +915,7 @@ static struct rnbd_clt_session *__find_and_get_sess(const char *sessname) return NULL; } +/* caller is responsible for initializing 'first' to false */ static struct rnbd_clt_session *find_or_create_sess(const char *sessname, bool *first) { @@ -930,8 +931,7 @@ rnbd_clt_session *find_or_create_sess(const char *sessname, bool *first) } list_add(&sess->list, &sess_list); *first = true; - } else - *first = false; + } mutex_unlock(&sess_lock); return sess; @@ -1200,13 +1200,11 @@ find_and_get_or_create_sess(const char *sessname, struct rnbd_clt_session *sess; struct rtrs_attrs attrs; int err; - bool first; + bool first = false; struct rtrs_clt_ops rtrs_ops; sess = find_or_create_sess(sessname, &first); - if (sess == ERR_PTR(-ENOMEM)) - return ERR_PTR(-ENOMEM); - else if (!first) + if (!first) return sess; if (!path_cnt) { From patchwork Tue Mar 30 07:37:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E73CC433F2 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 180CD619BB for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbhC3Him (ORCPT ); Tue, 30 Mar 2021 03:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbhC3HiM (ORCPT ); Tue, 30 Mar 2021 03:38:12 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CAE5C0613DA for ; Tue, 30 Mar 2021 00:38:12 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id l4so23295360ejc.10 for ; Tue, 30 Mar 2021 00:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0w1fRI368Vhqwr68IvgBQDB9m3lTg5l6TH+c+9pCq5Y=; b=TzfF9wG+Gt/9vMietHhE+uWl1uTo56lFxouA7vW3f/gT3TEU0lZCxf4MFSpUDJGBmx 1PAT/2XsSDEhGOe1/hfBQrJTyugtfwq/+EMUjou1UHdd5uv9zo4obxLkXO67yWDpRolg cXMwiyjgjD0PTvT5+t8+UqkhutQ4w74+imTedPF2N1JAVpxsUhbOsE8WMbj8N143ojMY NrdToT++S9aeYgP6hiSXSAwZSKVC311Ta4/7E6U6AXkXgTJtRPavOpSIALqTVaZH/I+m dYrnj2WHzvt4+QYhiL9M6NjZmKgU+hvypH5SDZ9bH7g7/YNJn9A+VDCGiW1h5uphd+FL xRcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0w1fRI368Vhqwr68IvgBQDB9m3lTg5l6TH+c+9pCq5Y=; b=Bm3woTQ9/qRwB//6jhdXCMGR90bN+HqNMHh7P3bUZ2NAeKFoNj3IzxiabNtSnBSlEY gnRtnlqtdq53HQYiS8+9W5rnLAkLXsID4Jdou585v6hQWqG1+deSZYacQSfwlqyVx1mJ vyJA12w/gOLFIDDb81Rcn9BSp/TyD3DKqVZPFgxK8VTumjZyaC9YE+nU7/1EjAAM+Wxv s7e7ikXjh3LPSxw1ualY/dmXQ4JrNXNKDKB7Ujn3pKwgQsXe6n/lnS7Tg9+rJzGBNyOj H6fNq+OnmeMP1YSl96YZVvwBUkBvaCQvNsS0ROQe0bV/NceSyyDd/UZlEpuRIhEkvgW0 nzQQ== X-Gm-Message-State: AOAM532vuVJrmeRtwbMpOlts0dEIgUHoVg1e1gkdtHSTQ0N5VbuzCy6R UIjeqvoovuK1+zk+4gSZfUR0TM2OMkX3PFZB X-Google-Smtp-Source: ABdhPJyCMLea2iRENozdOiYsl5e18pR+YACobOvhcrvugszO8g4rRrBp6lfXpG2S6Clf8kPiQ1xv6Q== X-Received: by 2002:a17:907:a06b:: with SMTP id ia11mr31661080ejc.294.1617089890631; Tue, 30 Mar 2021 00:38:10 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:10 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv2 for-next 17/24] block/rnbd-clt: Fix missing a memory free when unloading the module Date: Tue, 30 Mar 2021 09:37:45 +0200 Message-Id: <20210330073752.1465613-18-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim When unloading the rnbd-clt module, it does not free a memory including the filename of the symbolic link to /sys/block/rnbdX. It is found by kmemleak as below. unreferenced object 0xffff9f1a83d3c740 (size 16): comm "bash", pid 736, jiffies 4295179665 (age 9841.310s) hex dump (first 16 bytes): 21 64 65 76 21 6e 75 6c 6c 62 30 40 62 6c 61 00 !dev!nullb0@bla. backtrace: [<0000000039f0c55e>] 0xffffffffc0456c24 [<000000001aab9513>] kernfs_fop_write+0xcf/0x1c0 [<00000000db5aa4b3>] vfs_write+0xdb/0x1d0 [<000000007a2e2207>] ksys_write+0x65/0xe0 [<00000000055e280a>] do_syscall_64+0x50/0x1b0 [<00000000c2b51831>] entry_SYSCALL_64_after_hwframe+0x49/0xbe Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-clt-sysfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index 2452eb67547c..885074f2f734 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -432,10 +432,14 @@ void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev) * i.e. rnbd_clt_unmap_dev_store() leading to a sysfs warning because * of sysfs link already was removed already. */ - if (dev->blk_symlink_name && try_module_get(THIS_MODULE)) { - sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name); + if (dev->blk_symlink_name) { + if (try_module_get(THIS_MODULE)) { + sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name); + module_put(THIS_MODULE); + } + /* It should be freed always. */ kfree(dev->blk_symlink_name); - module_put(THIS_MODULE); + dev->blk_symlink_name = NULL; } } From patchwork Tue Mar 30 07:37:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B131C433DB for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0027261955 for ; Tue, 30 Mar 2021 07:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231338AbhC3Hip (ORCPT ); Tue, 30 Mar 2021 03:38:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231366AbhC3HiN (ORCPT ); Tue, 30 Mar 2021 03:38:13 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9A52C0613DC for ; Tue, 30 Mar 2021 00:38:12 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id y6so17068039eds.1 for ; Tue, 30 Mar 2021 00:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HlhC7loombWUFcEvGFDGgJ7hOzitEbTOI0PS0y/ZFaI=; b=XHaz4Gyv8KbHqFAcglA9AFnEx1Z3EgtdQzpLKybsVZS1Xd5WArR2I38f9egVuDNBLh Ml83jFEpUk17no8TgBpqn4IL1aRC8kfosiYk6pVqUFymT+lgqiCrU+rwCbgSCGikgBYF cbOKJfgFdguJTISFoWbDkf3QDH+Xt+n7zzgt2PQJILDR8ER261T9Y10m5M53Yt6ZPHtL k5Kwj86GwZM4ZG+/ApHhFBMTeWpJt0bbPk2C67xDpJczyiGFoX1QJ9MFHud2zv7MkDU1 0jYl/FetlHcP6FUHlJQZUCmToyCE32JASPoJmOv/5MxCXwShAns4rWeRqOp9FtCnROkM P/OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HlhC7loombWUFcEvGFDGgJ7hOzitEbTOI0PS0y/ZFaI=; b=KGfeR+xSoBjIbsHtoVEhmRw+cKVc4CDyZBYdUjevtjzmFupr7dRAXuBnAuk67srrPQ O365u1VeavFoErLUWvozqctNLJxBPFBsgkTV4Fke6U2S9KwBKDnG2JGPfWv2ldVqwuH2 ul3nijLbwhvUTdIiCJX3IfyTcPDtWvV55Mh/PxlTVGbZpCALRadYDfPf1pUX9+0vtx8j o2e1088Y46LKD6kx1FZ/y5J/Qx7m7GwujvN+UZkXluPIxersAR9fr3yWMXNjVljtQu5u 63M+wfYYD9XwPa4EzFsZQou90tLSOm470iDdwgbXb0yYId6UvVJkTsyQ98takZ0qEjSP 3p9Q== X-Gm-Message-State: AOAM532dLHBqdSDHl2hatwE34eTOp9J/obKOWm3YE0L6R/JV4/I830Jl EwG7Q3hBIc5lkpCdf+CIdp+wVlZ9mRLABlUR X-Google-Smtp-Source: ABdhPJxHf5viVO7L99gU/rJfilt4wroNAMV8CdUQu/TkAVE9VUfroLk5/hxDSgRuQcsMBicEpBB/Bw== X-Received: by 2002:aa7:d687:: with SMTP id d7mr31615910edr.118.1617089891482; Tue, 30 Mar 2021 00:38:11 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:11 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, Gioh Kim Subject: [PATCHv2 for-next 18/24] block/rnbd-clt: Support polling mode for IO latency optimization Date: Tue, 30 Mar 2021 09:37:46 +0200 Message-Id: <20210330073752.1465613-19-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim RNBD can make double-queues for irq-mode and poll-mode. For example, on 4-CPU system 8 request-queues are created, 4 for irq-mode and 4 for poll-mode. If the IO has HIPRI flag, the block-layer will call .poll function of RNBD. Then IO is sent to the poll-mode queue. Add optional nr_poll_queues argument for map_devices interface. To support polling of RNBD, RTRS client creates connections for both of irq-mode and direct-poll-mode. For example, on 4-CPU system it could've create 5 connections: con[0] => user message (softirq cq) con[1:4] => softirq cq After this patch, it can create 9 connections: con[0] => user message (softirq cq) con[1:4] => softirq cq con[5:8] => DIRECT-POLL cq Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-clt-sysfs.c | 56 +++++++++++++---- drivers/block/rnbd/rnbd-clt.c | 85 +++++++++++++++++++++++--- drivers/block/rnbd/rnbd-clt.h | 5 +- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 62 +++++++++++++++---- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 1 + drivers/infiniband/ulp/rtrs/rtrs.h | 3 +- 6 files changed, 178 insertions(+), 34 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index 885074f2f734..9ea4da7f894a 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -34,6 +34,7 @@ enum { RNBD_OPT_DEV_PATH = 1 << 2, RNBD_OPT_ACCESS_MODE = 1 << 3, RNBD_OPT_SESSNAME = 1 << 6, + RNBD_OPT_NR_POLL_QUEUES = 1 << 7, }; static const unsigned int rnbd_opt_mandatory[] = { @@ -42,12 +43,13 @@ static const unsigned int rnbd_opt_mandatory[] = { }; static const match_table_t rnbd_opt_tokens = { - {RNBD_OPT_PATH, "path=%s" }, - {RNBD_OPT_DEV_PATH, "device_path=%s"}, - {RNBD_OPT_DEST_PORT, "dest_port=%d" }, - {RNBD_OPT_ACCESS_MODE, "access_mode=%s"}, - {RNBD_OPT_SESSNAME, "sessname=%s" }, - {RNBD_OPT_ERR, NULL }, + {RNBD_OPT_PATH, "path=%s" }, + {RNBD_OPT_DEV_PATH, "device_path=%s" }, + {RNBD_OPT_DEST_PORT, "dest_port=%d" }, + {RNBD_OPT_ACCESS_MODE, "access_mode=%s" }, + {RNBD_OPT_SESSNAME, "sessname=%s" }, + {RNBD_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, + {RNBD_OPT_ERR, NULL }, }; struct rnbd_map_options { @@ -57,6 +59,7 @@ struct rnbd_map_options { char *pathname; u16 *dest_port; enum rnbd_access_mode *access_mode; + u32 *nr_poll_queues; }; static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, @@ -68,7 +71,7 @@ static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, int opt_mask = 0; int token; int ret = -EINVAL; - int i, dest_port; + int i, dest_port, nr_poll_queues; int p_cnt = 0; options = kstrdup(buf, GFP_KERNEL); @@ -178,6 +181,19 @@ static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, kfree(p); break; + case RNBD_OPT_NR_POLL_QUEUES: + if (match_int(args, &nr_poll_queues) || nr_poll_queues < -1 || + nr_poll_queues > (int)nr_cpu_ids) { + pr_err("bad nr_poll_queues parameter '%d'\n", + nr_poll_queues); + ret = -EINVAL; + goto out; + } + if (nr_poll_queues == -1) + nr_poll_queues = nr_cpu_ids; + *opt->nr_poll_queues = nr_poll_queues; + break; + default: pr_err("map_device: Unknown parameter or missing value '%s'\n", p); @@ -227,6 +243,20 @@ static ssize_t state_show(struct kobject *kobj, static struct kobj_attribute rnbd_clt_state_attr = __ATTR_RO(state); +static ssize_t nr_poll_queues_show(struct kobject *kobj, + struct kobj_attribute *attr, char *page) +{ + struct rnbd_clt_dev *dev; + + dev = container_of(kobj, struct rnbd_clt_dev, kobj); + + return snprintf(page, PAGE_SIZE, "%d\n", + dev->nr_poll_queues); +} + +static struct kobj_attribute rnbd_clt_nr_poll_queues = + __ATTR_RO(nr_poll_queues); + static ssize_t mapping_path_show(struct kobject *kobj, struct kobj_attribute *attr, char *page) { @@ -421,6 +451,7 @@ static struct attribute *rnbd_dev_attrs[] = { &rnbd_clt_state_attr.attr, &rnbd_clt_session_attr.attr, &rnbd_clt_access_mode.attr, + &rnbd_clt_nr_poll_queues.attr, NULL, }; @@ -469,7 +500,7 @@ static ssize_t rnbd_clt_map_device_show(struct kobject *kobj, char *page) { return scnprintf(page, PAGE_SIZE, - "Usage: echo \"[dest_port=server port number] sessname= path=<[srcaddr@]dstaddr> [path=<[srcaddr@]dstaddr>] device_path= [access_mode=]\" > %s\n\naddr ::= [ ip: | ip: | gid: ]\n", + "Usage: echo \"[dest_port=server port number] sessname= path=<[srcaddr@]dstaddr> [path=<[srcaddr@]dstaddr>] device_path= [access_mode=] [nr_poll_queues=]\" > %s\n\naddr ::= [ ip: | ip: | gid: ]\n", attr->attr.name); } @@ -541,6 +572,7 @@ static ssize_t rnbd_clt_map_device_store(struct kobject *kobj, char sessname[NAME_MAX]; enum rnbd_access_mode access_mode = RNBD_ACCESS_RW; u16 port_nr = RTRS_PORT; + u32 nr_poll_queues = 0; struct sockaddr_storage *addrs; struct rtrs_addr paths[6]; @@ -552,6 +584,7 @@ static ssize_t rnbd_clt_map_device_store(struct kobject *kobj, opt.pathname = pathname; opt.dest_port = &port_nr; opt.access_mode = &access_mode; + opt.nr_poll_queues = &nr_poll_queues; addrs = kcalloc(ARRAY_SIZE(paths) * 2, sizeof(*addrs), GFP_KERNEL); if (!addrs) return -ENOMEM; @@ -565,12 +598,13 @@ static ssize_t rnbd_clt_map_device_store(struct kobject *kobj, if (ret) goto out; - pr_info("Mapping device %s on session %s, (access_mode: %s)\n", + pr_info("Mapping device %s on session %s, (access_mode: %s, nr_poll_queues: %d)\n", pathname, sessname, - rnbd_access_mode_str(access_mode)); + rnbd_access_mode_str(access_mode), + nr_poll_queues); dev = rnbd_clt_map_device(sessname, paths, path_cnt, port_nr, pathname, - access_mode); + access_mode, nr_poll_queues); if (IS_ERR(dev)) { ret = PTR_ERR(dev); goto out; diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 6f955a937f40..998cadd73d47 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1171,9 +1171,54 @@ static blk_status_t rnbd_queue_rq(struct blk_mq_hw_ctx *hctx, return ret; } +static int rnbd_rdma_poll(struct blk_mq_hw_ctx *hctx) +{ + struct rnbd_queue *q = hctx->driver_data; + struct rnbd_clt_dev *dev = q->dev; + int cnt; + + cnt = rtrs_clt_rdma_cq_direct(dev->sess->rtrs, hctx->queue_num); + return cnt; +} + +static int rnbd_rdma_map_queues(struct blk_mq_tag_set *set) +{ + struct rnbd_clt_session *sess = set->driver_data; + + /* shared read/write queues */ + set->map[HCTX_TYPE_DEFAULT].nr_queues = num_online_cpus(); + set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; + set->map[HCTX_TYPE_READ].nr_queues = num_online_cpus(); + set->map[HCTX_TYPE_READ].queue_offset = 0; + blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]); + blk_mq_map_queues(&set->map[HCTX_TYPE_READ]); + + if (sess->nr_poll_queues) { + /* dedicated queue for poll */ + set->map[HCTX_TYPE_POLL].nr_queues = sess->nr_poll_queues; + set->map[HCTX_TYPE_POLL].queue_offset = set->map[HCTX_TYPE_READ].queue_offset + + set->map[HCTX_TYPE_READ].nr_queues; + blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); + pr_info("[session=%s] mapped %d/%d/%d default/read/poll queues.\n", + sess->sessname, + set->map[HCTX_TYPE_DEFAULT].nr_queues, + set->map[HCTX_TYPE_READ].nr_queues, + set->map[HCTX_TYPE_POLL].nr_queues); + } else { + pr_info("[session=%s] mapped %d/%d default/read queues.\n", + sess->sessname, + set->map[HCTX_TYPE_DEFAULT].nr_queues, + set->map[HCTX_TYPE_READ].nr_queues); + } + + return 0; +} + static struct blk_mq_ops rnbd_mq_ops = { .queue_rq = rnbd_queue_rq, .complete = rnbd_softirq_done_fn, + .map_queues = rnbd_rdma_map_queues, + .poll = rnbd_rdma_poll, }; static int setup_mq_tags(struct rnbd_clt_session *sess) @@ -1187,7 +1232,15 @@ static int setup_mq_tags(struct rnbd_clt_session *sess) tag_set->flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_TAG_QUEUE_SHARED; tag_set->cmd_size = sizeof(struct rnbd_iu) + RNBD_RDMA_SGL_SIZE; - tag_set->nr_hw_queues = num_online_cpus(); + + /* for HCTX_TYPE_DEFAULT, HCTX_TYPE_READ, HCTX_TYPE_POLL */ + tag_set->nr_maps = sess->nr_poll_queues ? HCTX_MAX_TYPES : 2; + /* + * HCTX_TYPE_DEFAULT and HCTX_TYPE_READ share one set of queues + * others are for HCTX_TYPE_POLL + */ + tag_set->nr_hw_queues = num_online_cpus() + sess->nr_poll_queues; + tag_set->driver_data = sess; return blk_mq_alloc_tag_set(tag_set); } @@ -1195,7 +1248,7 @@ static int setup_mq_tags(struct rnbd_clt_session *sess) static struct rnbd_clt_session * find_and_get_or_create_sess(const char *sessname, const struct rtrs_addr *paths, - size_t path_cnt, u16 port_nr) + size_t path_cnt, u16 port_nr, u32 nr_poll_queues) { struct rnbd_clt_session *sess; struct rtrs_attrs attrs; @@ -1204,6 +1257,17 @@ find_and_get_or_create_sess(const char *sessname, struct rtrs_clt_ops rtrs_ops; sess = find_or_create_sess(sessname, &first); + if (sess == ERR_PTR(-ENOMEM)) + return ERR_PTR(-ENOMEM); + else if ((nr_poll_queues && !first) || (!nr_poll_queues && sess->nr_poll_queues)) { + /* + * A device MUST have its own session to use the polling-mode. + * It must fail to map new device with the same session. + */ + err = -EINVAL; + goto put_sess; + } + if (!first) return sess; @@ -1225,7 +1289,7 @@ find_and_get_or_create_sess(const char *sessname, 0, /* Do not use pdu of rtrs */ RECONNECT_DELAY, BMAX_SEGMENTS, BLK_MAX_SEGMENT_SIZE, - MAX_RECONNECTS); + MAX_RECONNECTS, nr_poll_queues); if (IS_ERR(sess->rtrs)) { err = PTR_ERR(sess->rtrs); goto wake_up_and_put; @@ -1233,6 +1297,7 @@ find_and_get_or_create_sess(const char *sessname, rtrs_clt_query(sess->rtrs, &attrs); sess->max_io_size = attrs.max_io_size; sess->queue_depth = attrs.queue_depth; + sess->nr_poll_queues = nr_poll_queues; err = setup_mq_tags(sess); if (err) @@ -1376,7 +1441,8 @@ static int rnbd_client_setup_device(struct rnbd_clt_dev *dev) static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, enum rnbd_access_mode access_mode, - const char *pathname) + const char *pathname, + u32 nr_poll_queues) { struct rnbd_clt_dev *dev; int ret; @@ -1385,7 +1451,8 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, if (!dev) return ERR_PTR(-ENOMEM); - dev->hw_queues = kcalloc(nr_cpu_ids, sizeof(*dev->hw_queues), + dev->hw_queues = kcalloc(nr_cpu_ids /* softirq */ + nr_poll_queues /* poll */, + sizeof(*dev->hw_queues), GFP_KERNEL); if (!dev->hw_queues) { ret = -ENOMEM; @@ -1411,6 +1478,7 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, dev->clt_device_id = ret; dev->sess = sess; dev->access_mode = access_mode; + dev->nr_poll_queues = nr_poll_queues; mutex_init(&dev->lock); refcount_set(&dev->refcount, 1); dev->dev_state = DEV_STATE_INIT; @@ -1497,7 +1565,8 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, struct rtrs_addr *paths, size_t path_cnt, u16 port_nr, const char *pathname, - enum rnbd_access_mode access_mode) + enum rnbd_access_mode access_mode, + u32 nr_poll_queues) { struct rnbd_clt_session *sess; struct rnbd_clt_dev *dev; @@ -1506,11 +1575,11 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, if (unlikely(exists_devpath(pathname, sessname))) return ERR_PTR(-EEXIST); - sess = find_and_get_or_create_sess(sessname, paths, path_cnt, port_nr); + sess = find_and_get_or_create_sess(sessname, paths, path_cnt, port_nr, nr_poll_queues); if (IS_ERR(sess)) return ERR_CAST(sess); - dev = init_dev(sess, access_mode, pathname); + dev = init_dev(sess, access_mode, pathname, nr_poll_queues); if (IS_ERR(dev)) { pr_err("map_device: failed to map device '%s' from session %s, can't initialize device, err: %ld\n", pathname, sess->sessname, PTR_ERR(dev)); diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h index d2a709f5d7ed..685468ccb178 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -90,6 +90,7 @@ struct rnbd_clt_session { int queue_depth; u32 max_io_size; struct blk_mq_tag_set tag_set; + u32 nr_poll_queues; struct mutex lock; /* protects state and devs_list */ struct list_head devs_list; /* list of struct rnbd_clt_dev */ refcount_t refcount; @@ -126,6 +127,7 @@ struct rnbd_clt_dev { enum rnbd_clt_dev_state dev_state; char *pathname; enum rnbd_access_mode access_mode; + u32 nr_poll_queues; bool read_only; bool rotational; bool wc; @@ -156,7 +158,8 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, struct rtrs_addr *paths, size_t path_cnt, u16 port_nr, const char *pathname, - enum rnbd_access_mode access_mode); + enum rnbd_access_mode access_mode, + u32 nr_poll_queues); int rnbd_clt_unmap_device(struct rnbd_clt_dev *dev, bool force, const struct attribute *sysfs_self); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 7efd49bdc78c..cf9dbcbc11e7 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -174,7 +174,7 @@ struct rtrs_clt_con *rtrs_permit_to_clt_con(struct rtrs_clt_sess *sess, int id = 0; if (likely(permit->con_type == RTRS_IO_CON)) - id = (permit->cpu_id % (sess->s.con_num - 1)) + 1; + id = (permit->cpu_id % (sess->s.irq_con_num - 1)) + 1; return to_clt_con(sess->s.con[id]); } @@ -1400,23 +1400,29 @@ static void rtrs_clt_close_work(struct work_struct *work); static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt, const struct rtrs_addr *path, size_t con_num, u16 max_segments, - size_t max_segment_size) + size_t max_segment_size, u32 nr_poll_queues) { struct rtrs_clt_sess *sess; int err = -ENOMEM; int cpu; + size_t total_con; sess = kzalloc(sizeof(*sess), GFP_KERNEL); if (!sess) goto err; - /* Extra connection for user messages */ - con_num += 1; - - sess->s.con = kcalloc(con_num, sizeof(*sess->s.con), GFP_KERNEL); + /* + * irqmode and poll + * +1: Extra connection for user messages + */ + total_con = con_num + nr_poll_queues + 1; + sess->s.con = kcalloc(total_con, sizeof(*sess->s.con), GFP_KERNEL); if (!sess->s.con) goto err_free_sess; + sess->s.con_num = total_con; + sess->s.irq_con_num = con_num + 1; + sess->stats = kzalloc(sizeof(*sess->stats), GFP_KERNEL); if (!sess->stats) goto err_free_con; @@ -1435,7 +1441,6 @@ static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt, memcpy(&sess->s.src_addr, path->src, rdma_addr_size((struct sockaddr *)path->src)); strlcpy(sess->s.sessname, clt->sessname, sizeof(sess->s.sessname)); - sess->s.con_num = con_num; sess->clt = clt; sess->max_pages_per_mr = max_segments * max_segment_size >> 12; init_waitqueue_head(&sess->state_wq); @@ -1576,9 +1581,14 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) } cq_size = max_send_wr + max_recv_wr; cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; - err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, - cq_vector, cq_size, max_send_wr, - max_recv_wr, IB_POLL_SOFTIRQ); + if (con->c.cid >= sess->s.irq_con_num) + err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, + cq_vector, cq_size, max_send_wr, + max_recv_wr, IB_POLL_DIRECT); + else + err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, + cq_vector, cq_size, max_send_wr, + max_recv_wr, IB_POLL_SOFTIRQ); /* * In case of error we do not bother to clean previous allocations, * since destroy_con_cq_qp() must be called. @@ -2631,6 +2641,7 @@ static void free_clt(struct rtrs_clt *clt) * @max_segment_size: Max. size of one segment * @max_reconnect_attempts: Number of times to reconnect on error before giving * up, 0 for * disabled, -1 for forever + * @nr_poll_queues: number of polling mode connection using IB_POLL_DIRECT flag * * Starts session establishment with the rtrs_server. The function can block * up to ~2000ms before it returns. @@ -2644,7 +2655,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, size_t pdu_sz, u8 reconnect_delay_sec, u16 max_segments, size_t max_segment_size, - s16 max_reconnect_attempts) + s16 max_reconnect_attempts, u32 nr_poll_queues) { struct rtrs_clt_sess *sess, *tmp; struct rtrs_clt *clt; @@ -2662,7 +2673,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, struct rtrs_clt_sess *sess; sess = alloc_sess(clt, &paths[i], nr_cpu_ids, - max_segments, max_segment_size); + max_segments, max_segment_size, nr_poll_queues); if (IS_ERR(sess)) { err = PTR_ERR(sess); goto close_all_sess; @@ -2887,6 +2898,31 @@ int rtrs_clt_request(int dir, struct rtrs_clt_req_ops *ops, } EXPORT_SYMBOL(rtrs_clt_request); +int rtrs_clt_rdma_cq_direct(struct rtrs_clt *clt, unsigned int index) +{ + int cnt; + struct rtrs_con *con; + struct rtrs_clt_sess *sess; + struct path_it it; + + rcu_read_lock(); + for (path_it_init(&it, clt); + (sess = it.next_path(&it)) && it.i < it.clt->paths_num; it.i++) { + if (unlikely(READ_ONCE(sess->state) != RTRS_CLT_CONNECTED)) + continue; + + con = sess->s.con[index + 1]; + cnt = ib_process_cq_direct(con->cq, -1); + if (likely(cnt)) + break; + } + path_it_deinit(&it); + rcu_read_unlock(); + + return cnt; +} +EXPORT_SYMBOL(rtrs_clt_rdma_cq_direct); + /** * rtrs_clt_query() - queries RTRS session attributes *@clt: session pointer @@ -2916,7 +2952,7 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, int err; sess = alloc_sess(clt, addr, nr_cpu_ids, clt->max_segments, - clt->max_segment_size); + clt->max_segment_size, 0); if (IS_ERR(sess)) return PTR_ERR(sess); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index 8caad0a2322b..00eb45053339 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -101,6 +101,7 @@ struct rtrs_sess { uuid_t uuid; struct rtrs_con **con; unsigned int con_num; + unsigned int irq_con_num; unsigned int recon_cnt; struct rtrs_ib_dev *dev; int dev_ref; diff --git a/drivers/infiniband/ulp/rtrs/rtrs.h b/drivers/infiniband/ulp/rtrs/rtrs.h index 2db1b5eb3ab0..eb050738cda1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.h +++ b/drivers/infiniband/ulp/rtrs/rtrs.h @@ -59,7 +59,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, size_t pdu_sz, u8 reconnect_delay_sec, u16 max_segments, size_t max_segment_size, - s16 max_reconnect_attempts); + s16 max_reconnect_attempts, u32 nr_poll_queues); void rtrs_clt_close(struct rtrs_clt *sess); @@ -103,6 +103,7 @@ int rtrs_clt_request(int dir, struct rtrs_clt_req_ops *ops, struct rtrs_clt *sess, struct rtrs_permit *permit, const struct kvec *vec, size_t nr, size_t len, struct scatterlist *sg, unsigned int sg_cnt); +int rtrs_clt_rdma_cq_direct(struct rtrs_clt *clt, unsigned int index); /** * rtrs_attrs - RTRS session attributes From patchwork Tue Mar 30 07:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88509C433F4 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D8E261883 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbhC3Hip (ORCPT ); Tue, 30 Mar 2021 03:38:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbhC3HiO (ORCPT ); Tue, 30 Mar 2021 03:38:14 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91F13C061762 for ; Tue, 30 Mar 2021 00:38:13 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id h10so16998460edt.13 for ; Tue, 30 Mar 2021 00:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tsqeH5MSM4WbTb4VKhs81+DKBsJLqPP/9bH4vGe5fWs=; b=DMc/khhH7OoDWL0/7S4ob7huNbmxVOL9Rn+xY21KkTFiWafuieOmN3bFtc1flNLQxd JjFrU0Fl32RStbdCVKWCIPO3bPj0/v2QrVEB3KRUsXW0wwvrjL95ag222a2OIP6xoV/n q2ZtR9EgjA/6XFhSrUKn1Rl9LTKJqeuqJ79Fd5fve1FZVxlAFJm+Mr7c4GJUROTa76U2 li4Fwqk3yYtxMbjjiRn03P1TEW7R7S5wRCJlE1oOH8TKznmkfky7AlXK/AEMvqJhQACw dj0sbz8J8AmJYFMxeEQdiNRVJPf3LXHNTPFA/kZQRW50xnOKowUUpO6Ao0vh8hqOjQcd vReg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tsqeH5MSM4WbTb4VKhs81+DKBsJLqPP/9bH4vGe5fWs=; b=GSXtk3K6wHjP3LNITYsYJVTaHGB0jGIgDQUsmNclubeclNDMcpvz0pztwOtcVRcju+ I933BZgJwARlYxusRa09wRcQryeJOyVMX18Se/0ohstDeUTVfiOZBJC6g6Y9B0LZw0fE iFq3pqMx1EoWZj8Qu5/nf+4sAou8dd8i2Iww5WRb7M14dMXemiXOLo7TaDPwHbl63Ynh O+cd4SUqfZ5QCUbniAdGkq4+UuPidE38QG5vdqTL+9H7nzUiYlIW/Ed6SUQBGiF2RvO2 2dTBwc9+9kSpI2DdxyYdcPfxEbcKZKp76O0UjA8tdxpGIrkrKA4A9ywz2NtslHlNh/q7 fvuw== X-Gm-Message-State: AOAM533fnBqxn5HFa4OwiP0SvRCNM7RvT78YrKj42w7Kme3gGvd4ogka +j2vP0MFXGygcO/R6eOLRTRSxa3wIWqIzHPT X-Google-Smtp-Source: ABdhPJyGFpcXeQYZsMyqXNZ1BmY1bb/qSdJgaf0tZTVDQucaAD/Iueem1rfRz/Mdrfur8YbBFBmu5w== X-Received: by 2002:a50:d84e:: with SMTP id v14mr21692722edj.357.1617089892172; Tue, 30 Mar 2021 00:38:12 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:11 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim Subject: [PATCHv2 for-next 19/24] Documentation/ABI/rnbd-clt: Add description for nr_poll_queues Date: Tue, 30 Mar 2021 09:37:47 +0200 Message-Id: <20210330073752.1465613-20-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org describe how to set nr_poll_queues and enable the polling Signed-off-by: Gioh Kim --- Documentation/ABI/testing/sysfs-block-rnbd | 6 ++++++ Documentation/ABI/testing/sysfs-class-rnbd-client | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-block-rnbd b/Documentation/ABI/testing/sysfs-block-rnbd index ec716e1c31a8..80b420b5d6b8 100644 --- a/Documentation/ABI/testing/sysfs-block-rnbd +++ b/Documentation/ABI/testing/sysfs-block-rnbd @@ -56,3 +56,9 @@ Date: Feb 2020 KernelVersion: 5.7 Contact: Jack Wang Danil Kipnis Description: Remap the disconnected device if the session is not destroyed yet. + +What: /sys/block/rnbd/rnbd/nr_poll_queues +Date: Feb 2020 +KernelVersion: 5.7 +Contact: Jack Wang Danil Kipnis +Description: Contains the number of poll-mode queues diff --git a/Documentation/ABI/testing/sysfs-class-rnbd-client b/Documentation/ABI/testing/sysfs-class-rnbd-client index 2aa05b3e348e..0b5997ab3365 100644 --- a/Documentation/ABI/testing/sysfs-class-rnbd-client +++ b/Documentation/ABI/testing/sysfs-class-rnbd-client @@ -85,6 +85,19 @@ Description: Expected format is the following:: By default "rw" is used. + nr_poll_queues + specifies the number of poll-mode queues. If the IO has HIPRI flag, + the block-layer will send the IO via the poll-mode queue. + For fast network and device the polling is faster than interrupt-base + IO handling because it saves time for context switching, switching to + another process, handling the interrupt and switching back to the + issuing process. + + Set -1 if you want to set it as the number of CPUs + By default rnbd client creates only irq-mode queues. + + NOTICE: MUST make a unique session for a device using the poll-mode queues. + Exit Codes: If the device is already mapped it will fail with EEXIST. If the input From patchwork Tue Mar 30 07:37:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5864C433FC for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEEAB61955 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231370AbhC3Hiq (ORCPT ); Tue, 30 Mar 2021 03:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbhC3HiO (ORCPT ); Tue, 30 Mar 2021 03:38:14 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 627C3C061764 for ; Tue, 30 Mar 2021 00:38:14 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a7so23327481ejs.3 for ; Tue, 30 Mar 2021 00:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+wNTS4XPUWn/jF7E63ntoE+HOXhLVAf70pg15ObO2xg=; b=brHGtSON3jImzIRE1Wid398RfM1Awe0yDVRTJp4gTLGoDkt2SndXqDNY1r6T+atb1J 7Kfig6nfl+lGQ/pgWtJyjdC1qGCYb9+p+29buiT09r/uULD2aOK92Wyot4us99RrY1sH kDsO0/6kzwMygFUnrD5Goubxbzw8WKhpliXbTv2aVQy4fWlvsQQ9cXkq/pxAmIYLtPET Q/sm8pB6y+5L5+wqaVTc/HnfdRHmpuDBfKvkb7MfGQnFUkbqcjUx5rxnJVT6wKb45G3L KuTG8KJlATh9hZgxkY8Z9Lki7J87dBkXBQ0PvD7JK8OcXsIsI6MhoII1GmLFDFnmJpB5 wSsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+wNTS4XPUWn/jF7E63ntoE+HOXhLVAf70pg15ObO2xg=; b=RJSdw6pdzs7UWyH51AKP+gJJAEVLNE1O5GtRjY9akS2bRco0zOxQGb2ZCiUkPdqMUI BYOcCHxeMMiYOIGWzfM+xDPDcIm0upvmZGuLB1oNnXz0oYTV1Ij0B5/GJYQiNkm5LyHY cQfHdYruC6exsjhXS8DsPmufBoq6jt/qRDHnnMJp23IoVckWrUA19aV0XAjQxCS4IZ0C ZtB2KKei92aZuaXNeutgAGVXrh2IqNvrKwm8h5774F68NzWxqAAk1AJr0gQFRgh8SMCN sy2Gu1pogpp8hnDAw4SDMpCD0udlrw8DSSMMgnm+QzVAUjKzdoLBkeZyBymZOFQIXor+ hCbg== X-Gm-Message-State: AOAM531LbfE3yfS1Jd9E4br90M5k/7fKkIZbfUyMbREbsHZQU2Fp/qL0 kObCYO1P2c/XJ5T7NXZXDhDTLJomG7kSemVG X-Google-Smtp-Source: ABdhPJxIF1hG1RscAxIssw08tn4fhsmYHF3kOBMAxxmXv26Led2ovP3+9M+gcd5MvrQXBOUfrR5bcA== X-Received: by 2002:a17:906:1453:: with SMTP id q19mr32502682ejc.76.1617089893062; Tue, 30 Mar 2021 00:38:13 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:12 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, Aleksei Marov , Gioh Kim Subject: [PATCHv2 for-next 20/24] block/rnbd-srv: Remove unused arguments of rnbd_srv_rdma_ev Date: Tue, 30 Mar 2021 09:37:48 +0200 Message-Id: <20210330073752.1465613-21-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Gioh Kim struct rtrs_srv is not used when handling rnbd_srv_rdma_ev messages, so cleaned up rdma_ev function pointer in rtrs_srv_ops also is changed. Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Signed-off-by: Aleksei Marov Signed-off-by: Jack Wang Signed-off-by: Gioh Kim Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-srv.c | 39 ++++++++++---------------- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 +-- drivers/infiniband/ulp/rtrs/rtrs.h | 3 +- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index a71b6f7662f5..78bd0ce0ebf0 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -119,8 +119,7 @@ rnbd_get_sess_dev(int dev_id, struct rnbd_srv_session *srv_sess) return sess_dev; } -static int process_rdma(struct rtrs_srv *sess, - struct rnbd_srv_session *srv_sess, +static int process_rdma(struct rnbd_srv_session *srv_sess, struct rtrs_srv_op *id, void *data, u32 datalen, const void *usr, size_t usrlen) { @@ -350,8 +349,7 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, mutex_unlock(&sess->lock); } -static int process_msg_close(struct rtrs_srv *rtrs, - struct rnbd_srv_session *srv_sess, +static int process_msg_close(struct rnbd_srv_session *srv_sess, void *data, size_t datalen, const void *usr, size_t usrlen) { @@ -370,20 +368,18 @@ static int process_msg_close(struct rtrs_srv *rtrs, return 0; } -static int process_msg_open(struct rtrs_srv *rtrs, - struct rnbd_srv_session *srv_sess, +static int process_msg_open(struct rnbd_srv_session *srv_sess, const void *msg, size_t len, void *data, size_t datalen); -static int process_msg_sess_info(struct rtrs_srv *rtrs, - struct rnbd_srv_session *srv_sess, +static int process_msg_sess_info(struct rnbd_srv_session *srv_sess, const void *msg, size_t len, void *data, size_t datalen); -static int rnbd_srv_rdma_ev(struct rtrs_srv *rtrs, void *priv, - struct rtrs_srv_op *id, int dir, - void *data, size_t datalen, const void *usr, - size_t usrlen) +static int rnbd_srv_rdma_ev(void *priv, + struct rtrs_srv_op *id, int dir, + void *data, size_t datalen, const void *usr, + size_t usrlen) { struct rnbd_srv_session *srv_sess = priv; const struct rnbd_msg_hdr *hdr = usr; @@ -397,19 +393,16 @@ static int rnbd_srv_rdma_ev(struct rtrs_srv *rtrs, void *priv, switch (type) { case RNBD_MSG_IO: - return process_rdma(rtrs, srv_sess, id, data, datalen, usr, - usrlen); + return process_rdma(srv_sess, id, data, datalen, usr, usrlen); case RNBD_MSG_CLOSE: - ret = process_msg_close(rtrs, srv_sess, data, datalen, - usr, usrlen); + ret = process_msg_close(srv_sess, data, datalen, usr, usrlen); break; case RNBD_MSG_OPEN: - ret = process_msg_open(rtrs, srv_sess, usr, usrlen, - data, datalen); + ret = process_msg_open(srv_sess, usr, usrlen, data, datalen); break; case RNBD_MSG_SESS_INFO: - ret = process_msg_sess_info(rtrs, srv_sess, usr, usrlen, - data, datalen); + ret = process_msg_sess_info(srv_sess, usr, usrlen, data, + datalen); break; default: pr_warn("Received unexpected message type %d with dir %d from session %s\n", @@ -662,8 +655,7 @@ static char *rnbd_srv_get_full_path(struct rnbd_srv_session *srv_sess, return full_path; } -static int process_msg_sess_info(struct rtrs_srv *rtrs, - struct rnbd_srv_session *srv_sess, +static int process_msg_sess_info(struct rnbd_srv_session *srv_sess, const void *msg, size_t len, void *data, size_t datalen) { @@ -704,8 +696,7 @@ find_srv_sess_dev(struct rnbd_srv_session *srv_sess, const char *dev_name) return NULL; } -static int process_msg_open(struct rtrs_srv *rtrs, - struct rnbd_srv_session *srv_sess, +static int process_msg_open(struct rnbd_srv_session *srv_sess, const void *msg, size_t len, void *data, size_t datalen) { diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index d071809e3ed2..f7aa2a7e7442 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -998,7 +998,7 @@ static void process_read(struct rtrs_srv_con *con, usr_len = le16_to_cpu(msg->usr_len); data_len = off - usr_len; data = page_address(srv->chunks[buf_id]); - ret = ctx->ops.rdma_ev(srv, srv->priv, id, READ, data, data_len, + ret = ctx->ops.rdma_ev(srv->priv, id, READ, data, data_len, data + data_len, usr_len); if (unlikely(ret)) { @@ -1051,7 +1051,7 @@ static void process_write(struct rtrs_srv_con *con, usr_len = le16_to_cpu(req->usr_len); data_len = off - usr_len; data = page_address(srv->chunks[buf_id]); - ret = ctx->ops.rdma_ev(srv, srv->priv, id, WRITE, data, data_len, + ret = ctx->ops.rdma_ev(srv->priv, id, WRITE, data, data_len, data + data_len, usr_len); if (unlikely(ret)) { rtrs_err_rl(s, diff --git a/drivers/infiniband/ulp/rtrs/rtrs.h b/drivers/infiniband/ulp/rtrs/rtrs.h index eb050738cda1..c25a0fd8a607 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.h +++ b/drivers/infiniband/ulp/rtrs/rtrs.h @@ -139,7 +139,6 @@ struct rtrs_srv_ops { * message for the data transfer will be sent to * the client. - * @sess: Session * @priv: Private data set by rtrs_srv_set_sess_priv() * @id: internal RTRS operation id * @dir: READ/WRITE @@ -153,7 +152,7 @@ struct rtrs_srv_ops { * @usr: The extra user message sent by the client (%vec) * @usrlen: Size of the user message */ - int (*rdma_ev)(struct rtrs_srv *sess, void *priv, + int (*rdma_ev)(void *priv, struct rtrs_srv_op *id, int dir, void *data, size_t datalen, const void *usr, size_t usrlen); From patchwork Tue Mar 30 07:37:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DF31C433C1 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D02A061883 for ; Tue, 30 Mar 2021 07:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbhC3Hip (ORCPT ); Tue, 30 Mar 2021 03:38:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbhC3HiP (ORCPT ); Tue, 30 Mar 2021 03:38:15 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136DFC061762 for ; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id e7so16992454edu.10 for ; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FzPBTlBw1MjHnrff8Rt1PN/OBBefnhXSEo3ZW0EmbAU=; b=bbArIyYc+Agi+s2EyURgl/1IBAtSupFhrqJeJVFieKqC6DrK0VxEQGrjnjyQli60sN 3TJ+29XTA1n9Y+0eiM2JUR64szIF5FVN1bTWwc5F7PaLQFOAmGjtlxnZp1hRoJ3I3Q+Q Vs3yp2MrK/gfMllKsWQZT27WHACMVwNgUczOFH73R54vn9i1Unsm+I4i0KFr3MBodgY6 aZv0bxw8w9UZeVRlha9YGY9mUaHH9VeXIjbUphVeVAVtMI3L70LvguE/q6ma+2KWmeVU jNGBL6LVg+7/m7T2YTz4583aPm8jSIg+eA04u/ufHoTShUglX4h2plvcUGDLmXxI0/Km 3XFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FzPBTlBw1MjHnrff8Rt1PN/OBBefnhXSEo3ZW0EmbAU=; b=ug8EsmpdKFdxX8yk9eXmXV6La5NJkxlJ4l0dYefrzISv19zhbUksQ6XWhYKTd3VxKl SUURsGHQc0FDPNWDhum/2hPgju+NPxvGgx6htQXINcUmlwEfeK2SJVR+n85hgiba1AMI JO1d9hRIquVhOtGAOyIClVfWDrkQrT45UxQ9mpJOc8i8OFaCtzJ57GjK+Wvh92iVHlpf DeXwRivyT1v+6/iD7zuScuB9Dq3+pv63TEuceobCNv9aQcBxRjNIQFoN3ebfii7OVfHk grpspVvS81u64BdgjypgKNhjO70CioFG721Vjmrw7jrQCvh4osFOvHyrFQ+IpMAG65lJ DMDQ== X-Gm-Message-State: AOAM533ktNpIvUcqwHtWKzCmf6Aii2xqEzXRnM36VNuWXYG90fdSuvMT yjHI4HT1FFNRVeXAz3W6wtRFjWoA8Yv4CWAn X-Google-Smtp-Source: ABdhPJytZKYkL3tcAScufRusigsym4RlmZ6xECFID60oCDH2h9TEwBWONMMWE4BrTcbpThkOgUN5sg== X-Received: by 2002:a05:6402:1157:: with SMTP id g23mr32424798edw.303.1617089893730; Tue, 30 Mar 2021 00:38:13 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:13 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Gioh Kim Subject: [PATCHv2 for-next 21/24] block/rnbd-clt: Generate kobject_uevent when the rnbd device state changes Date: Tue, 30 Mar 2021 09:37:49 +0200 Message-Id: <20210330073752.1465613-22-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Md Haris Iqbal When an RTRS session state changes, the transport layer generates an event to RNBD. Then RNBD will change the state of the RNBD client device accordingly. This commit add kobject_uevent when the RNBD device state changes. With this udev rules can be configured to react accordingly. Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/block/rnbd/rnbd-clt-sysfs.c | 1 + drivers/block/rnbd/rnbd-clt.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index 9ea4da7f894a..630351574d1b 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -491,6 +491,7 @@ static int rnbd_clt_add_dev_kobj(struct rnbd_clt_dev *dev) ret); kobject_put(&dev->kobj); } + kobject_uevent(gd_kobj, KOBJ_ONLINE); return ret; } diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 998cadd73d47..6f3ca2e3bc02 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -110,6 +110,7 @@ static int rnbd_clt_change_capacity(struct rnbd_clt_dev *dev, static int process_msg_open_rsp(struct rnbd_clt_dev *dev, struct rnbd_msg_open_rsp *rsp) { + struct kobject *gd_kobj; int err = 0; mutex_lock(&dev->lock); @@ -128,6 +129,8 @@ static int process_msg_open_rsp(struct rnbd_clt_dev *dev, */ if (dev->nsectors != nsectors) rnbd_clt_change_capacity(dev, nsectors); + gd_kobj = &disk_to_dev(dev->gd)->kobj; + kobject_uevent(gd_kobj, KOBJ_ONLINE); rnbd_clt_info(dev, "Device online, device remapped successfully\n"); } err = rnbd_clt_set_dev_attr(dev, rsp); @@ -654,14 +657,18 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, enum wait_type wait static void set_dev_states_to_disconnected(struct rnbd_clt_session *sess) { struct rnbd_clt_dev *dev; + struct kobject *gd_kobj; mutex_lock(&sess->lock); list_for_each_entry(dev, &sess->devs_list, list) { rnbd_clt_err(dev, "Device disconnected.\n"); mutex_lock(&dev->lock); - if (dev->dev_state == DEV_STATE_MAPPED) + if (dev->dev_state == DEV_STATE_MAPPED) { dev->dev_state = DEV_STATE_MAPPED_DISCONNECTED; + gd_kobj = &disk_to_dev(dev->gd)->kobj; + kobject_uevent(gd_kobj, KOBJ_OFFLINE); + } mutex_unlock(&dev->lock); } mutex_unlock(&sess->lock); From patchwork Tue Mar 30 07:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C850C43445 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A95061883 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbhC3Hiq (ORCPT ); Tue, 30 Mar 2021 03:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbhC3HiQ (ORCPT ); Tue, 30 Mar 2021 03:38:16 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA243C061762 for ; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id u5so23330065ejn.8 for ; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eOrWylNgv4HQ5STa2oRnjcaCVNNyjdluAJ/C+cL7Khg=; b=AZwIYOkoi8zraRAtQeHYJ/gWrZ78BQAe9idZDujwTMEIG+b8HskQpgLDV87C6Rtnqe evUa6eH89/PbN3UhMdTO13q67tx9uCHcGCo35QpWsKGcH5Id6yZ5EE2pno+S+/sAOruA Z0aJMJ9yohJDbbcv1Zfb6+JeBr17pM7d4qHVziQL7RIksug5IUMJz/dIsHE6X+FSm4A2 u6q+kPvsY45Cu+2+1wgATLy7z9is0paR9Y8ZJLX5CkP9kCaHSKlNnrg75DgrR43ua3H7 c3FTPTXU8H+zn8VXPQXXzUskBbFGtT6WVfqXWFGxJtIFHnac9WNJjQaO4QKKJ+AwSFyZ QaKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eOrWylNgv4HQ5STa2oRnjcaCVNNyjdluAJ/C+cL7Khg=; b=ufTRAelTieDFoRzR2OURKxcBMP87P5jiZvi3uenFAkG+cf1LBomYncBoMYTgudWj8T x4IY6lFlpD8sX3wx8xLk9HBuf1ugx8xC2L6WW/fsc5iAls3qB1BD6tbRWh9CZzV0SuBc H3N+qPgNpi2sPVp/wp23wxcijRn8GbJ/S1+WX9NTArY/ZIpKnh7dtEhnFCaW1IEIJkq6 li1Ol6Jdu8bcMtZbyLu2WhBt1KyJap5CSW1sroOoLhl3ia6HqlJpytqxEFRw2ZvR4IG5 5TINNkRej33x3Z5KD8ReoSQWW0YUJsphiRisa0WsA7zL/7ckfQklyEVBLmSXW/wnfWH8 zmdQ== X-Gm-Message-State: AOAM533TSdgelpUOgnS76pZMd7TKwPEnwv5ZiG0SM+tIMnPVIWs0nPGy hBxlpGoIqbQIZx5NFcDDooCoQXIvcKtdW5s0 X-Google-Smtp-Source: ABdhPJy7VyIE/oOQM5xjoduVDlOXvH1LpM0JlkkBm2RZLHRuS1ZfKrrEsALCWXvwmmfmE9eDTKaN/Q== X-Received: by 2002:a17:906:ecaa:: with SMTP id qh10mr32193080ejb.425.1617089894488; Tue, 30 Mar 2021 00:38:14 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:14 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Jack Wang , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, Gioh Kim Subject: [PATCHv2 for-next 22/24] block/rnbd-clt: Remove max_segment_size Date: Tue, 30 Mar 2021 09:37:50 +0200 Message-Id: <20210330073752.1465613-23-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Jack Wang We always map with SZ_4K, so do not need max_segment_size. Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal Signed-off-by: Gioh Kim --- drivers/block/rnbd/rnbd-clt.c | 1 - drivers/infiniband/ulp/rtrs/rtrs-clt.c | 15 +++++---------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 - drivers/infiniband/ulp/rtrs/rtrs.h | 1 - 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 6f3ca2e3bc02..9d1bc49d5595 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1295,7 +1295,6 @@ find_and_get_or_create_sess(const char *sessname, paths, path_cnt, port_nr, 0, /* Do not use pdu of rtrs */ RECONNECT_DELAY, BMAX_SEGMENTS, - BLK_MAX_SEGMENT_SIZE, MAX_RECONNECTS, nr_poll_queues); if (IS_ERR(sess->rtrs)) { err = PTR_ERR(sess->rtrs); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index cf9dbcbc11e7..db15257dc978 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1400,7 +1400,7 @@ static void rtrs_clt_close_work(struct work_struct *work); static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt, const struct rtrs_addr *path, size_t con_num, u16 max_segments, - size_t max_segment_size, u32 nr_poll_queues) + u32 nr_poll_queues) { struct rtrs_clt_sess *sess; int err = -ENOMEM; @@ -1442,7 +1442,7 @@ static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt, rdma_addr_size((struct sockaddr *)path->src)); strlcpy(sess->s.sessname, clt->sessname, sizeof(sess->s.sessname)); sess->clt = clt; - sess->max_pages_per_mr = max_segments * max_segment_size >> 12; + sess->max_pages_per_mr = max_segments; init_waitqueue_head(&sess->state_wq); sess->state = RTRS_CLT_CONNECTING; atomic_set(&sess->connected_cnt, 0); @@ -2538,7 +2538,6 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, void (*link_ev)(void *priv, enum rtrs_clt_link_ev ev), unsigned int max_segments, - size_t max_segment_size, unsigned int reconnect_delay_sec, unsigned int max_reconnect_attempts) { @@ -2568,7 +2567,6 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, clt->port = port; clt->pdu_sz = pdu_sz; clt->max_segments = max_segments; - clt->max_segment_size = max_segment_size; clt->reconnect_delay_sec = reconnect_delay_sec; clt->max_reconnect_attempts = max_reconnect_attempts; clt->priv = priv; @@ -2638,7 +2636,6 @@ static void free_clt(struct rtrs_clt *clt) * @pdu_sz: Size of extra payload which can be accessed after permit allocation. * @reconnect_delay_sec: time between reconnect tries * @max_segments: Max. number of segments per IO request - * @max_segment_size: Max. size of one segment * @max_reconnect_attempts: Number of times to reconnect on error before giving * up, 0 for * disabled, -1 for forever * @nr_poll_queues: number of polling mode connection using IB_POLL_DIRECT flag @@ -2654,7 +2651,6 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, size_t paths_num, u16 port, size_t pdu_sz, u8 reconnect_delay_sec, u16 max_segments, - size_t max_segment_size, s16 max_reconnect_attempts, u32 nr_poll_queues) { struct rtrs_clt_sess *sess, *tmp; @@ -2663,7 +2659,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv, ops->link_ev, - max_segments, max_segment_size, reconnect_delay_sec, + max_segments, reconnect_delay_sec, max_reconnect_attempts); if (IS_ERR(clt)) { err = PTR_ERR(clt); @@ -2673,7 +2669,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, struct rtrs_clt_sess *sess; sess = alloc_sess(clt, &paths[i], nr_cpu_ids, - max_segments, max_segment_size, nr_poll_queues); + max_segments, nr_poll_queues); if (IS_ERR(sess)) { err = PTR_ERR(sess); goto close_all_sess; @@ -2951,8 +2947,7 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, struct rtrs_clt_sess *sess; int err; - sess = alloc_sess(clt, addr, nr_cpu_ids, clt->max_segments, - clt->max_segment_size, 0); + sess = alloc_sess(clt, addr, nr_cpu_ids, clt->max_segments, 0); if (IS_ERR(sess)) return PTR_ERR(sess); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 692bc83e1f09..98ba5d0a48b8 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -166,7 +166,6 @@ struct rtrs_clt { unsigned int max_reconnect_attempts; unsigned int reconnect_delay_sec; unsigned int max_segments; - size_t max_segment_size; void *permits; unsigned long *permits_map; size_t queue_depth; diff --git a/drivers/infiniband/ulp/rtrs/rtrs.h b/drivers/infiniband/ulp/rtrs/rtrs.h index c25a0fd8a607..feb76af95e96 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.h +++ b/drivers/infiniband/ulp/rtrs/rtrs.h @@ -58,7 +58,6 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, size_t path_cnt, u16 port, size_t pdu_sz, u8 reconnect_delay_sec, u16 max_segments, - size_t max_segment_size, s16 max_reconnect_attempts, u32 nr_poll_queues); void rtrs_clt_close(struct rtrs_clt *sess); From patchwork Tue Mar 30 07:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DB8EC43381 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 154E361957 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231380AbhC3Hir (ORCPT ); Tue, 30 Mar 2021 03:38:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231394AbhC3HiR (ORCPT ); Tue, 30 Mar 2021 03:38:17 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 809ACC061762 for ; Tue, 30 Mar 2021 00:38:16 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id b16so17029290eds.7 for ; Tue, 30 Mar 2021 00:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OvJ5MzPF8I45JiDjPGx6l81wa3gYMJbbWHVkqSrx3qs=; b=YxyIRE/C34fU7tL0sALIEfjUbtDC3GfWkjg6AwDt2fo8Tw7U639uq51TdoLpB8mNeb i64yee+hdfDSnZ1wd55Yqtf9/bGRpkSvYFkQVLdTVk0BG3QggKg4QaHcUofrOmzLqRdz 1SyUzCbj71ADYTE5BvYaF2QIRkqpBxxnUSp/Fiiq1RJhMOf4OjuuidUxK4bklA5ffnaU laJ9BAbXjHygkLuPG8IiEhyyYtjCG7nUamkJTHoVtxgudxVlkPgifTPD33U4WEhRZEtl G4qdIoIbbnsf5DQz2t63RV5C00uxgwnm0RjQHZjwDm52BJ3umHy5wn0JHT+xPSoV2Ws9 vRgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OvJ5MzPF8I45JiDjPGx6l81wa3gYMJbbWHVkqSrx3qs=; b=bjUoCdjNlXqKTJQON+Q1kBM6KdbRO8o819mye9ZkT3BYVT6HhrD6e970uykukMGrWM RB2CjKVrqX/m5Lqc4gHC9jlAgtSl5FxZ4ARsrKdYa/sjevnrT5OL+kZhcrBrk3DHf7DK P8fG4D9Au0bnAynUy8Yx8U90iqjyjEJbyihY+AXDDCRiA4sxbR2C345Y1grBUY/S68nb UB1KActeIJYObju5eySK5gNhpqgNKPGcgcOMiBobVIoWk7oIhrezUbEq46unqcAdk2Ei hx5FNlVjEjQo7R6+7nrCcH65/cpVPGSrXhd+xWGZ76Z760+gdSC/Yx/GmUYQEKD61kSc G4PQ== X-Gm-Message-State: AOAM532epOMnQKHutj1RY8w7By9xeXqs4sg+rX7uu7lFPQKG2zfXNHeO LihxUpNgYbYaU73+RBO2g2w+uT26GSwg6n/S X-Google-Smtp-Source: ABdhPJwnjkpMY5xAGTsaUINcuGhIRnuppelmcv+GQ2ACkvWY0guY/A+1OQNUL0A0Zllliv6mZZCUMA== X-Received: by 2002:aa7:d954:: with SMTP id l20mr32226314eds.1.1617089895174; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:14 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Dima Stepanov , Dima Stepanov , Arnd Bergmann Subject: [PATCHv2 for-next 23/24] block/rnbd-clt-sysfs: Remove copy buffer overlap in rnbd_clt_get_path_name Date: Tue, 30 Mar 2021 09:37:51 +0200 Message-Id: <20210330073752.1465613-24-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Dima Stepanov cppcheck report the following error: rnbd/rnbd-clt-sysfs.c:522:36: error: The variable 'buf' is used both as a parameter and as destination in snprintf(). The origin and destination buffers overlap. Quote from glibc (C-library) documentation (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions): "If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined." [sprintfOverlappingData] Fix it by initializing the buf variable in the first snprintf call. Fixes: 91f4acb2801c ("block/rnbd-clt: support mapping two devices") Signed-off-by: Dima Stepanov Cc: Arnd Bergmann Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt-sysfs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index 630351574d1b..b1d04115e049 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -515,11 +515,7 @@ static int rnbd_clt_get_path_name(struct rnbd_clt_dev *dev, char *buf, while ((s = strchr(pathname, '/'))) s[0] = '!'; - ret = snprintf(buf, len, "%s", pathname); - if (ret >= len) - return -ENAMETOOLONG; - - ret = snprintf(buf, len, "%s@%s", buf, dev->sess->sessname); + ret = snprintf(buf, len, "%s@%s", pathname, dev->sess->sessname); if (ret >= len) return -ENAMETOOLONG; From patchwork Tue Mar 30 07:37:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5278FC43446 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2831061959 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbhC3Hiq (ORCPT ); Tue, 30 Mar 2021 03:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231395AbhC3HiR (ORCPT ); Tue, 30 Mar 2021 03:38:17 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B93C061762 for ; Tue, 30 Mar 2021 00:38:17 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id o19so17039938edc.3 for ; Tue, 30 Mar 2021 00:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T5srQ/60JF7ZiUGd4AoDyuQgYPEKKpRTj50Ou9B6W4A=; b=XgeSH8V2m5j94LepZ8Iv8Sjiv90ybPfz5YS/1AEQKcs2iZ+c1H/uqXwrFUaoZboRHk XnjRcVlC1x1AcYQceHUvJ93cB7AtuSI/hlwtHPmFbFtmMr3l/yfnlF8hNYr5qWup3UiT JM946+wzb2tGrzK4IUh/HCmQcTduwlaFuq/7pJO444yZkriBjIsZolNs1M+K+DIpC4sn yIVu1M0w411LcbHlGFPBsnOzumhgb+jL/7rxnpoljYkHWSF8xADdR7q2PWiZOv5x7Pvo c/rNoWiK7q4Xcs/XBrRsu1IGZId/AtQk4mtcQEdFU7bLmGi0mPkZlpHgqqOyrRkDE/ip Ar9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T5srQ/60JF7ZiUGd4AoDyuQgYPEKKpRTj50Ou9B6W4A=; b=CAXvuxcmhNqRAIlqLuXDcm5A8gXZqXT6kv9WkzdhCWaPCodPMN29CZ2pHeiVfvWzcm huIFp0OAeziENQF1cLt9o/HuE+lAikQMNbrcG+xGf9U1laPyJPA1uH1mDeL9iKHPkgKn L4sxdn3/ABRu5FZOFSVGjWdMgoS1azyeD+mkOlhdiApLTGAjV4J6vmo2XPNQojvmcrCr DmXCpIWwCNuPC4InCGjtUiLiOmAWkvHj3XphQYp2+9KQArUn720rlVmCqfI1VO5Ove7o JeTMoBJ1z30WNxcYeZTurWsPqdGFM9bEJn1ZlSU8PCFv/kuuN1Elj2DGrCBhR1+X0b7h GoKw== X-Gm-Message-State: AOAM530IbiDhSU+rdUOyyXlpYhwcqqQSVADl0UDWF5lYSVdkTdT4koj1 6a0KtMmYC/Xkxtfln6ZTU8c5RgWIHKl5Q3MG X-Google-Smtp-Source: ABdhPJzF2Qf76nCOB3pvPx83f4ecxiawHlqx5sBknkXDL72ure1LvmAMPEKLD2jTIzrotL7Wuqm0Dg== X-Received: by 2002:a50:ec96:: with SMTP id e22mr32324389edr.385.1617089895904; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:15 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Dima Stepanov Subject: [PATCHv2 for-next 24/24] block/rnbd: Use strscpy instead of strlcpy Date: Tue, 30 Mar 2021 09:37:52 +0200 Message-Id: <20210330073752.1465613-25-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Dima Stepanov During checkpatch analyzing the following warning message was found: WARNING:STRLCPY: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Fix it by using strscpy calls instead of strlcpy. Signed-off-by: Dima Stepanov Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt-sysfs.c | 6 +++--- drivers/block/rnbd/rnbd-clt.c | 4 ++-- drivers/block/rnbd/rnbd-srv.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index b1d04115e049..3c3172af08da 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -99,7 +99,7 @@ static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, kfree(p); goto out; } - strlcpy(opt->sessname, p, NAME_MAX); + strscpy(opt->sessname, p, NAME_MAX); kfree(p); break; @@ -142,7 +142,7 @@ static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, kfree(p); goto out; } - strlcpy(opt->pathname, p, NAME_MAX); + strscpy(opt->pathname, p, NAME_MAX); kfree(p); break; @@ -511,7 +511,7 @@ static int rnbd_clt_get_path_name(struct rnbd_clt_dev *dev, char *buf, int ret; char pathname[NAME_MAX], *s; - strlcpy(pathname, dev->pathname, sizeof(pathname)); + strscpy(pathname, dev->pathname, sizeof(pathname)); while ((s = strchr(pathname, '/'))) s[0] = '!'; diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 9d1bc49d5595..6e5d4a02a9b7 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -583,7 +583,7 @@ static int send_msg_open(struct rnbd_clt_dev *dev, enum wait_type wait) msg.hdr.type = cpu_to_le16(RNBD_MSG_OPEN); msg.access_mode = dev->access_mode; - strlcpy(msg.dev_name, dev->pathname, sizeof(msg.dev_name)); + strscpy(msg.dev_name, dev->pathname, sizeof(msg.dev_name)); WARN_ON(!rnbd_clt_get_dev(dev)); err = send_usr_msg(sess->rtrs, READ, iu, @@ -805,7 +805,7 @@ static struct rnbd_clt_session *alloc_sess(const char *sessname) sess = kzalloc_node(sizeof(*sess), GFP_KERNEL, NUMA_NO_NODE); if (!sess) return ERR_PTR(-ENOMEM); - strlcpy(sess->sessname, sessname, sizeof(sess->sessname)); + strscpy(sess->sessname, sessname, sizeof(sess->sessname)); atomic_set(&sess->busy, 0); mutex_init(&sess->lock); INIT_LIST_HEAD(&sess->devs_list); diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 78bd0ce0ebf0..d6ec16d7211d 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -304,7 +304,7 @@ static int create_sess(struct rtrs_srv *rtrs) mutex_unlock(&sess_lock); srv_sess->rtrs = rtrs; - strlcpy(srv_sess->sessname, sessname, sizeof(srv_sess->sessname)); + strscpy(srv_sess->sessname, sessname, sizeof(srv_sess->sessname)); rtrs_srv_set_sess_priv(rtrs, srv_sess); @@ -443,7 +443,7 @@ static struct rnbd_srv_dev *rnbd_srv_init_srv_dev(const char *id) if (!dev) return ERR_PTR(-ENOMEM); - strlcpy(dev->id, id, sizeof(dev->id)); + strscpy(dev->id, id, sizeof(dev->id)); kref_init(&dev->kref); INIT_LIST_HEAD(&dev->sess_dev_list); mutex_init(&dev->lock); @@ -595,7 +595,7 @@ rnbd_srv_create_set_sess_dev(struct rnbd_srv_session *srv_sess, kref_init(&sdev->kref); - strlcpy(sdev->pathname, open_msg->dev_name, sizeof(sdev->pathname)); + strscpy(sdev->pathname, open_msg->dev_name, sizeof(sdev->pathname)); sdev->rnbd_dev = rnbd_dev; sdev->sess = srv_sess;