From patchwork Tue Apr 6 07:06:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184279 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,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 8B7ACC433ED for ; Tue, 6 Apr 2021 07:07:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BFFB613C3 for ; Tue, 6 Apr 2021 07:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244150AbhDFHH3 (ORCPT ); Tue, 6 Apr 2021 03:07:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244152AbhDFHH3 (ORCPT ); Tue, 6 Apr 2021 03:07:29 -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 16131C061756 for ; Tue, 6 Apr 2021 00:07:22 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id k8so7792331edn.6 for ; Tue, 06 Apr 2021 00:07:22 -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=c776AqyHciC961n8389x5uwFIXlpdtuFOep0Blv2rAgADs717wvW60/aJHuhz4gliU mnfHQ0QP5hpV/mglBfeLzJQTkEjHpKnRVPYYw1rG2LacEhqC+AE9fZV5uE6pjzUlTRa0 QUxZDZJPnjW+Dat5ZcYT++brRJYJtwUAg77Q9W9mgy1COVd2s1ekqbuETjTdXW5VGLEv BBDpIHWLMbd0+fLyMLfmN2+VN9R7/fsTmOaT6GmY9g1ARW2rAXDBEOqMNDUgNaC3Tx0u GHUCRcK+2B25TZDw2V556t1IxgMtxgMOmIdud2vkM8+5DOekqaa8T+gPn1uCWuZiKOo1 QDRA== 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=mJnx/O62TiAdsmqeYQR9qARB0j8dl86OCmbetnr1vyFQDN5GorFuYQCz9UgRCPZSeH 0AA6fH12sQ6B3jpqHX44NQtUQnELogBP1O0aGr34yYHAQmdj931cTW/neYQPNPOgoNq+ eSbmlBOvbU6rIoPKk1Z5k0/Zq+kPAJZTIV/FE2ut33pPiGL/l9owN98ew8xAvHJHXMsL 8qifD/twlv+lj0pyxwWoNnyeDPtfJIPE1r+jIPXA+rq4DofdoNO2XpQGG0N0+++4dYYg MCAMDi8FKJeNlMSP8nQyGS6AlpWxlL8YkJuGs5ulRAjTUTdfyMKMJ5ZawR+OklnV5I13 G3rA== X-Gm-Message-State: AOAM531klFeR6uAnwPw1eeMotijwAI9POmLbUhipro632dCvCQG6hIDV +rZlqbco3EGYHzkRAW+wrMSCfaE3wFcMMw== X-Google-Smtp-Source: ABdhPJxewG8ZOSm4rvRtTvTmgNL4ESU4vDF2D/949Ode5vihmM0QEA5S/H9J10ozkFgqb71DfquMmA== X-Received: by 2002:a05:6402:26c9:: with SMTP id x9mr35537139edd.322.1617692840711; Tue, 06 Apr 2021 00:07:20 -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 rh6sm3976566ejb.39.2021.04.06.00.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:20 -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: [PATCHv3 for-next 01/19] MAINTAINERS: Change maintainer for rnbd module Date: Tue, 6 Apr 2021 09:06:58 +0200 Message-Id: <20210406070716.168541-2-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 Apr 6 07:06:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184283 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,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 3D2EEC43461 for ; Tue, 6 Apr 2021 07:07:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03F5D613BC for ; Tue, 6 Apr 2021 07:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244152AbhDFHHa (ORCPT ); Tue, 6 Apr 2021 03:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244153AbhDFHHa (ORCPT ); Tue, 6 Apr 2021 03:07:30 -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 CDCF7C06174A for ; Tue, 6 Apr 2021 00:07:22 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id h10so15176340edt.13 for ; Tue, 06 Apr 2021 00:07:22 -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=ADWipWJZQisqEZZVWrg6KcEkCEK5XnhrPQQYTUVfnuG5I2aOB1W9MYHAKSPpZ6oCRs YrzJXsjF1yL4t9V7b2o+19qMZ0rqnv6xPYKpHl+27OflQIbb9dl5ZdBmVHOhQTOSH5SV ozGV9KsZsZ69SHldylIi4MU12hAAX6wryhS1YNN6Petn252VlNXSRKGliHV5lSBXwcIm hm624emLCn8AtzOKcWEoIrhwnRwnQeIr8Ljwjb/55YYAlg8IwYP/HuSqi4gNjL9TJRm3 AqgeZPoqRFNJ0xsrI5GTaco7VB2A8xOBcG3rwQWUngNa7tKom6vG+jC1pUSjR2oK9rpw aSEw== 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=gYOd8ti/oAfD+Cq/JvZfL5VOXVONlGi21rpsQwxm7K3hUrD/Uio/hGC9kAj3oe+4Mn l4Oy4lPk9jQtUGKlUWhURy8eSEJ4a4wIaQaQzz79NNot6vM46BCwAgwE4eZ390FEXbgI X3nKjjy+Ednj/9wmfMrcCX8dfBcs3dlxV/2fS5k4XfxuKYJtd8qy2mvTBasMnys0YsQq P7p66EqkE0uFUofvLnJZnhK1V3OdiwLAdUJvz0akWgs/J+wGqYeoIUv2OZZ9stdEcfFA mmokJ39Y7dM27fadfrR/obthMinIQwKQNW8HT5iFUaQ54IkfdGt5SZNSZJ6ckP7q0NpC xABA== X-Gm-Message-State: AOAM532eCpHZ6of+fJ2tM7vDnfcpzLPR1ZJjmmJoeaHPqA24ThxhS+U2 MOhlGkc3I6zSdEG4gdEu9LfzSs0NkpqkHg== X-Google-Smtp-Source: ABdhPJz/QBDNCrM0uhn81hWJ3H+PG8z0+hubLapnTJPcFn7NX4PZyyc/EzfXZI/8H3tYupsySBRLkg== X-Received: by 2002:a05:6402:27ce:: with SMTP id c14mr7266551ede.263.1617692841406; Tue, 06 Apr 2021 00:07:21 -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 rh6sm3976566ejb.39.2021.04.06.00.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:21 -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: [PATCHv3 for-next 02/19] Documentation/sysfs-block-rnbd: Add descriptions for remap_device and resize Date: Tue, 6 Apr 2021 09:06:59 +0200 Message-Id: <20210406070716.168541-3-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 Apr 6 07:07:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184285 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,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 3C36BC43462 for ; Tue, 6 Apr 2021 07:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 015A4613B7 for ; Tue, 6 Apr 2021 07:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244154AbhDFHHb (ORCPT ); Tue, 6 Apr 2021 03:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244153AbhDFHHa (ORCPT ); Tue, 6 Apr 2021 03:07:30 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F53CC06174A for ; Tue, 6 Apr 2021 00:07:23 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id k8so7792400edn.6 for ; Tue, 06 Apr 2021 00:07:23 -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=0PDpwO5lWof601MDA4aFO5d06aw+1og0zuKo6oNDR1E=; b=NR50vUPRhiH7XgucRRHk2mO0U6XDutBNEq5+DZaR8wvGog/+gFdzjlYXN+IqTb5/Qo x+uIBA4Yw2h/VIiD9cHXnHByOVG2i2+ogLF+2Tes39Ep6oXMZvcLSexhFfXwmyjml+vM r3/HNLcjkCRkpT3RLgDjbEWXPyq57gcGVRMhsdBEUQMC0RjSFdbXmXUece80iV64QRNI LT9O9/bzAIYfQ3QtKCrbMR5eaY3E5AzsU91Qz0WO2WtX9+CWQrMWr58E3rWHn10bcHJ4 X9BylBuu/0gGxaYhKrUTxpA1FXaFbvpHhx/f3cS/ScvPXarKwbt+XRouR783r1nYU2BG FU1A== 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=0PDpwO5lWof601MDA4aFO5d06aw+1og0zuKo6oNDR1E=; b=FAJTiAMhoaLCw8Uk4kSWxL79PeJfVbjOu/u/G6BMhl3FvCn6i57TsvtHlgdLoPNHlC 2lG0vlXpS5D3i0e4UMYW3dPAl3XRficR1BeOAtGyxTfubDYYFY/4Yzr6l2wXZ9AuG0l1 3Ceqpx/UukKAv7sZEQ146U5ocZWiSeHv1ei1a4pgoIUPyH9faMTe8+66nx/r9yVlJG6I vOQpXOFYZJFWEoXDQNyo0g6uzG6TGy19Ik8SQ62VfyFeoUfjlPsqQOGxWuNw3EcxIul+ wWCidoQhhvMNaHSUE8wa3UXdO5PxqoB55PTI5q7nYtFLi7RU5IHKEktMzyqpSZW5AGJc yZDQ== X-Gm-Message-State: AOAM531qSvb0XhKTq6D9YyEP09LE6iHkxRkJKyN6PjUOGT1wNqfqjr4J EFtMcyUAz8QJxGxafR3Eb9rLdhbVGw1qgQ== X-Google-Smtp-Source: ABdhPJzOI0s0h1Q4q0iKx95xmaqbzUzTBltX2svFwSteFbDuv4es82g5Vcra85HemMUoOHMUcRv/yQ== X-Received: by 2002:a05:6402:274d:: with SMTP id z13mr22880910edd.344.1617692842220; Tue, 06 Apr 2021 00:07:22 -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 rh6sm3976566ejb.39.2021.04.06.00.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:21 -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: [PATCHv3 for-next 03/19] block/rnbd-clt: Remove some arguments from insert_dev_if_not_exists_devpath Date: Tue, 6 Apr 2021 09:07:00 +0200 Message-Id: <20210406070716.168541-4-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 45a470076652..5a5c8dea38dc 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1471,14 +1471,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); @@ -1522,7 +1521,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 Apr 6 07:07:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184287 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,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 09413C433B4 for ; Tue, 6 Apr 2021 07:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D80DD613BC for ; Tue, 6 Apr 2021 07:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244155AbhDFHHc (ORCPT ); Tue, 6 Apr 2021 03:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244153AbhDFHHb (ORCPT ); Tue, 6 Apr 2021 03:07:31 -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 30524C06174A for ; Tue, 6 Apr 2021 00:07:24 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id h10so15176411edt.13 for ; Tue, 06 Apr 2021 00:07:24 -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=W+pSKG5MeazyVQaTM4wjfbORD6labF71XC9KX+IrgJ8=; b=bdZbLthootjqO5AA271H3cqOI/4UBsiIM2Csmkc+Dj6Fuqi0r0SvOEp6myS3tGOke2 YK+o6zCapleg+DPUdPposPN9bP4RFGJhYYj1QArb51S+2nGEWu4vpOIGJpBhLQWONSfE 3W43RSN8C2Gnyh5bbf9Uwt0qSg0ljEZEf0RuSG/2AfzyzK9ymS0uscCtaB0be5DpFc3p 1WXhetnMtIKjwitcqzfif280hlEkSNvbkgVdZhGxWEschcNNBqob6kyR2/CygdhjOaFf Z17d61a0c3F8SgczctJHabIbRykihDn0yzbEWecZyNTQ/XN8BXzI7XRtDsW2knb3HMem Qprg== 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=W+pSKG5MeazyVQaTM4wjfbORD6labF71XC9KX+IrgJ8=; b=E/wuaOpVcwL6i7VxTnsxjJSjMdSi9n9OfZ1PNWV1jB3BS19zIPfZ2I818IqRgdlAF5 54HYSgNZziNekB+aTkhnBMMRbhc4t4wudzjpvOpKReO59gSHr0hXoMkc8pla9Ktnx+ps uGGjpbPSQijvOpu1m7L+MgSCr8v4VhaO7Rg4nIST2l/xbJdsWWA8+zm6CerHbNojYryH gqgEOGliOxMe3zZ8OB5HQLpkm5k2sJhVXyUp9Q+c/JAmm3H2UbR8va68kura01/h0Oq4 ClzuoulhAxmI2juKjYhVxRKkY1wRrCRJRBEZvMmhmlLQE5So7y923ReWNQ8RJzZAnAFS LMhg== X-Gm-Message-State: AOAM53079u5vZJRrICwSIku+5aqpAfva/Q5e3nY071Lem7nrJ0PuTXxW uIeT5XZvqgMCoUoqnyJQZAfxPE5nkN9QIw== X-Google-Smtp-Source: ABdhPJxjVtgMbsmRf2HTqiJTFrJ1NT17FLSd8KkMeGZZ3HVN+31Ulw7m0+0QOHmpwUKsYfUsxPwFOg== X-Received: by 2002:aa7:c3c1:: with SMTP id l1mr36565024edr.208.1617692842911; Tue, 06 Apr 2021 00:07:22 -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 rh6sm3976566ejb.39.2021.04.06.00.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:22 -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: [PATCHv3 for-next 04/19] block/rnbd-clt: Remove some arguments from rnbd_client_setup_device Date: Tue, 6 Apr 2021 09:07:01 +0200 Message-Id: <20210406070716.168541-5-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 5a5c8dea38dc..ecb83c10013d 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1354,10 +1354,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; @@ -1535,7 +1534,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 Apr 6 07:07:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184289 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,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 29A0BC43460 for ; Tue, 6 Apr 2021 07:07:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA738613BD for ; Tue, 6 Apr 2021 07:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244158AbhDFHHd (ORCPT ); Tue, 6 Apr 2021 03:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244153AbhDFHHc (ORCPT ); Tue, 6 Apr 2021 03:07:32 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70BBC06174A for ; Tue, 6 Apr 2021 00:07:24 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id dd20so7994290edb.12 for ; Tue, 06 Apr 2021 00:07:24 -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=h0U5h3qflJkPWgDXKbrDDU843EkMfjhOwR5MGRfmGtA=; b=drV85pQhJ1nViuyXKTgHvxSrloghRcHohutG1hfmFnJGDf7+cBrgoT78KZ6/ScT8LJ v50v0Nac46V3Z+LVAmKw5w4rnMOgyDxEg9+1Lvyc+Y73Nc84m6zh72WB1w8HfwGHa9An p2oV5hPoZnmM0ud1X+mUTOuuZTnT1/tBPkGb21OqNh554wsAW1oUuitrcKGUj3ZKoOeA 80ZD32YQuVH3l6EWvk2uo7m3ROVVKUCc0HGKlRt7N++vld1ni3LbSJBcYAw0hwdE/pxK GSKRiD5NUjob8mFCb0O+KmuzeZUzT/Gg2x7CNKBoKDOMtLCaTrBC/R6eaYR5g+H+xsYn CULQ== 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=h0U5h3qflJkPWgDXKbrDDU843EkMfjhOwR5MGRfmGtA=; b=RWirvX/QLBmgB0iTTgqTzpjkzYh++TmiPVMDcVqp7aQSjXYRJCiOs29Y8t7VvWJofA CIK5lEennlt52sT+BmjFN6VwIHA7dh2IdJvqnNK+MVrpItLrm5gf2HT45yEiif5Bk0gP 3sHnGzQI6h2o6veJJr+H4lF6bIy0IrtJCE+Q3BYLtwRILVPRdfdG/y5kGygxKzdSyc+9 aptHYheb2QlPLrLLT4pCg4lKpBHbr8+k7XQriYyodx+ZZkn6ylTX0WboW74G78/HcNfb QZo7ph4BRVKZswXzbqOs7NIbFxvNl3elDcm1oiqGkiUiJYdWiyclqv+wQtiu51Aj1v+F UvEg== X-Gm-Message-State: AOAM533I39RSVLNE7DnP9FVCjSR7KI9p8jJK2dQkTzymDtJ8wdtbuyo7 QPIZaov2sKTmVMuLe5LAQqUV2+lyh0wTzQ== X-Google-Smtp-Source: ABdhPJx94c8q3wUBk7ZpwHwclSOQ9CmDLDQArcsAOnZHkcrR/hdbZplH8nAz+XuzpKJ8NX+M+whHhA== X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr36472652edd.103.1617692843564; Tue, 06 Apr 2021 00:07:23 -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 rh6sm3976566ejb.39.2021.04.06.00.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:23 -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: [PATCHv3 for-next 05/19] block/rnbd-clt: Move add_disk(dev->gd) to rnbd_clt_setup_gen_disk Date: Tue, 6 Apr 2021 09:07:02 +0200 Message-Id: <20210406070716.168541-6-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 ecb83c10013d..f864f06a49b3 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1352,6 +1352,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) @@ -1553,8 +1554,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 Apr 6 07:07:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184291 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,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 61975C433ED for ; Tue, 6 Apr 2021 07:07:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 400E6613BE for ; Tue, 6 Apr 2021 07:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244153AbhDFHHd (ORCPT ); Tue, 6 Apr 2021 03:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244160AbhDFHHd (ORCPT ); Tue, 6 Apr 2021 03:07:33 -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 BDEA8C06174A for ; Tue, 6 Apr 2021 00:07:25 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id z1so15213959edb.8 for ; Tue, 06 Apr 2021 00:07:25 -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=uK/8rpYP1RXWSF8rmgCpV40i0InJQwlPrCpDoA4JLng=; b=g17+Ca1jSg1gppoa0ftuVFCNbk/JN6e06c2yzfIMdb+Dyfmu/dT3jA1N1hVPr3B/oi cKWjgWvb9fkOYpJTbRFLQisMm3lztRwrNPO0l4XbLvUrWY2K0AqZSifCwES6kKydmamU GkHiRvo6gxKSiX9Glk3n+JjEVnEJLnlX4O4MChjLeyhLbNKOXv8j15TE9jcRLPgzRq27 6barD05cft26DVcKQ4bmvAjNX6335zs6zkN1rXsj6rR7prow8vWhWJBUJdEVP9HNE+89 YerE+l+1vp5cK5F8NAiPQjw/i5Zvs9axh+GDdJtxiu8nNZD242xmBBr5TL2huduRqSJO PKWA== 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=uK/8rpYP1RXWSF8rmgCpV40i0InJQwlPrCpDoA4JLng=; b=LNUR71s6uUXv8GRYsuTY/Z+9lagd4DgdcpIOhTvYZj5QphlSnMuv7GtkkCoqGIqNIg U/wGOR5Pjm/yZXx0PGm5WzIYF/Duf6coiDmbDqwKr98IfHVUw2TITfHAFsE/kXw2GsvZ 9SadU3fDILqYM0uHFTkzZv67RS9/aDe7RoBFbKvUD3HZRI6GWiwMME1fSqqUEPJ2sg4X +eXp/72jiSnpTcLtjurXHn8TIr/z94NID8a4AUXPw3+dZAt54KhQ9cha6HGyzHvu1Qyv cqP5orplnesvOErgV+gb2cn84bnPz2lM5oK290rtC6UPpDpkJfLd0+VCm0ztgglXTr8w HVcA== X-Gm-Message-State: AOAM5336Z+LJ7vLpSUsZFsBPBC42X68BDvvVsEWoZEQw7QRZysLQBgvr JQatVNCycWWgN7oiFxcwEh2sDCaapzOQWhim X-Google-Smtp-Source: ABdhPJzIHMQ3s8KwxYWd64J5ZcS626BQivTCh9ie8+yXE58HQOmTG3G6Kr50SEQFlUGmlgWTzfrd7Q== X-Received: by 2002:a05:6402:1013:: with SMTP id c19mr3688819edu.213.1617692844277; Tue, 06 Apr 2021 00:07:24 -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 rh6sm3976566ejb.39.2021.04.06.00.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:24 -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: [PATCHv3 for-next 06/19] block/rnbd: Kill rnbd_clt_destroy_default_group Date: Tue, 6 Apr 2021 09:07:03 +0200 Message-Id: <20210406070716.168541-7-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 d4aa6bfc9555..58c2cc0725b6 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 f864f06a49b3..4e687ec88721 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1675,7 +1675,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 537d499dad3b..714d426b449b 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -159,7 +159,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 Apr 6 07:07:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184293 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,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 A6254C433B4 for ; Tue, 6 Apr 2021 07:07:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75521613BD for ; Tue, 6 Apr 2021 07:07:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244162AbhDFHHf (ORCPT ); Tue, 6 Apr 2021 03:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244156AbhDFHHd (ORCPT ); Tue, 6 Apr 2021 03:07:33 -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 6C2F0C06174A for ; Tue, 6 Apr 2021 00:07:26 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id n2so13952186ejy.7 for ; Tue, 06 Apr 2021 00:07:26 -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=fXtiFaknX7PqfpQnvD4MDPFOwWT0t3CzA0AxdcLxxxA=; b=Wwx3mB6x5kifMTw6ZzO+x/KxitBV9dZ8rhD8uSfVpnhPNKXAFYh2qDdbdVjEgViMCu bn/W36TDxt8X1XasdG2BHJ+EAIDKK8SmKGmWY8hbWXIywV2Pshiii2lY1tP2mpIzt0Wa TOtc2HvUnxR7SJX1Fsr5flo/HwKul0V6bN4jzgeuHXNKTlsmlLV+W0aNN3dn56bgJHUB XQKnvROc35f2Or+hc6P2wKA4zzfe0k2+0p9LDFFlB/q1WeJV+oiHEDfQqFg4yCMjCGaL MIJuytFes2V6NOuDuKWMws/q+9C6/ZfABd4k4dzWJdM0DnfU+zj9hs+yAZIWy6zFyiMn CC0g== 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=fXtiFaknX7PqfpQnvD4MDPFOwWT0t3CzA0AxdcLxxxA=; b=legt012T2G5lNZVIad/7owWyPJkgH+PU3Gn2WDqNhuf4W8BYDTxIJ2nsj8z3bm0OHW 0mzIt2KJAZxnAOZiqql+9dRdDeGk95+eiorX+9KaEm5RRP6Q/XDqK9FjP9QvX8FkrZT6 JfGI6hSiQuoUjoIGDUaMUua1YQ0+5LwyaR8nOfomic765xYISBtw3Vi9yvuyBwSbna8K so7AF7+CbiilwEL06YLY/h98wQ6jmvbgGlfSatIUFBwVrd/IJv1aC/Pj+FuU0R1I+kHd AyragFhs1dJNFGp8QBUO3xlLZp+LJDhi8kxKtWbZEyCuOGf1MHxDJpTiW+1CZRY4IMdl 7DTQ== X-Gm-Message-State: AOAM533E0WUR9WHXKiuwliCq5ndPpYON0aigfj0DLK4gUxY5UOn6ci1C 4SrfkiZvy1WQNMnJN723q+WvLENzs85C6sYT X-Google-Smtp-Source: ABdhPJwnbBY47yW42pJUzo1yBEqdQzQ2MVwYGvXT6Ywaj0KNFNjXRKR+KyQYcSmba8PxTIDjVOrYFw== X-Received: by 2002:a17:906:f283:: with SMTP id gu3mr31745144ejb.91.1617692845111; Tue, 06 Apr 2021 00:07:25 -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 rh6sm3976566ejb.39.2021.04.06.00.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:24 -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: [PATCHv3 for-next 07/19] block/rnbd: Kill destroy_device_cb Date: Tue, 6 Apr 2021 09:07:04 +0200 Message-Id: <20210406070716.168541-8-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 a6a68d44f517..a4fd9f167c18 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -178,8 +178,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); @@ -198,18 +200,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 Apr 6 07:07:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184295 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,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 70FD6C433ED for ; Tue, 6 Apr 2021 07:07:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 493DD613BC for ; Tue, 6 Apr 2021 07:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244164AbhDFHHf (ORCPT ); Tue, 6 Apr 2021 03:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244157AbhDFHHe (ORCPT ); Tue, 6 Apr 2021 03:07:34 -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 1AEBBC06175F for ; Tue, 6 Apr 2021 00:07:27 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id dd20so7994383edb.12 for ; Tue, 06 Apr 2021 00:07:27 -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=REu5NWTcHpJwOG8Gw3rL/WEBLzjt1gQZ2/okvoq/BNc=; b=UVxVg4GfLLD/DCzyn6TYIf5JzsIML89TTVIBHu3JYn+Xs9bol+rPDPcSHQlDsFPR42 zy4o/oAHAjp2sRO0H2SkUgxPbkTSiqkv66S92KfpGGVJRjmMbv6bMRqszSumtBBrSExi pYLpQ3FeOiKMtyhbcSTV5sVAEqnAtyNlT4BaCANt8uZu9zX4QmppUIRzzz/m2ruz5rNZ Gt0cGofXG3OZfzkfAMiqVxI4jilZVAjpIDuvTZln/8E3S5sXQfEXyOhd/cV9bG811Gka Q5s/HaanzQRW5qBZdCZzKZMrw/3TA+WSJo4fNwRusP4QkY/47573NfIjJo5mx5Tk/uzv s4ww== 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=REu5NWTcHpJwOG8Gw3rL/WEBLzjt1gQZ2/okvoq/BNc=; b=Br5WVMPEgaUp+3HitwAsDx/octO3oBN+Vn8g347rrMAucWQy7xpEIQ1kykmzQ5XH4q rbMxu9RZsWu2OfY4k/kZvgE42z3qwzAmdC0mUHXOsfpUZJg/qQ2VXEFUVvTJUMrp4nW0 +wJjBNGnm8geMShISGGGguwWxQYZDoscrjFHcjOFrG9fx8BHzN2EoHlNXLcxXxkbNotA S7Xz7CW37MmELIJozirDCUXqga+rQcx8yW/jx0M84srhJQ2Ihx0ZKWNdqbUXzcDix5qQ bCQTjEyfMhxRZ6IwjyZPaOvEzT4DXBvASMYFpSS9AW2Rb9pfyJFac3qlEOkfOqw1K8XG 7LrQ== X-Gm-Message-State: AOAM532K6QGNF1zEfTgYyoE57jjNqe0up8B2WDkuNQpV0SZsMaglzb3T C8501sbBMwgaafDhSXfsLxTRWDN8H+jj6HlP X-Google-Smtp-Source: ABdhPJyuvVSppHq+kbWLL9SZ8AsF85Q6gYHNxAG5F2i6tL9D2+E7r20lDAqCGVY7ZjeW1L04I531oQ== X-Received: by 2002:aa7:ca04:: with SMTP id y4mr35947723eds.339.1617692845797; Tue, 06 Apr 2021 00:07:25 -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 rh6sm3976566ejb.39.2021.04.06.00.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:25 -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: [PATCHv3 for-next 08/19] block/rnbd-clt: Replace {NO_WAIT,WAIT} with RTRS_PERMIT_{WAIT,NOWAIT} Date: Tue, 6 Apr 2021 09:07:05 +0200 Message-Id: <20210406070716.168541-9-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 4e687ec88721..652b41cc4492 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; @@ -435,16 +431,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; @@ -476,7 +467,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; @@ -530,7 +522,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); @@ -554,7 +546,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; @@ -601,7 +593,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; @@ -687,7 +679,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; @@ -711,7 +703,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; @@ -1242,7 +1234,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; @@ -1525,7 +1517,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", @@ -1559,7 +1551,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: @@ -1619,7 +1611,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"); @@ -1653,7 +1645,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 Apr 6 07:07:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184299 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,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 CD7F7C43462 for ; Tue, 6 Apr 2021 07:07:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB4B9613B7 for ; Tue, 6 Apr 2021 07:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244157AbhDFHHg (ORCPT ); Tue, 6 Apr 2021 03:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244161AbhDFHHf (ORCPT ); Tue, 6 Apr 2021 03:07:35 -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 BCFB4C06174A for ; Tue, 6 Apr 2021 00:07:27 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id p4so4945221edr.2 for ; Tue, 06 Apr 2021 00:07:27 -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=FGH+Ljl4s6SmZtr/mbRqxMi5iJCFYf0z8DPotTgMP2c=; b=hczZH0CqXAUh4LWKFyZNcWcaOiFK88nParQCciRud6pvWm8Nxir6qEuhCEuTp6jFYX 3NHG+20jY0hdjFgYt2BR7syxk6KbQk9aA5HsOOfbSgd6yqDUhY7CAWR+lMY1LK1RohDp hK1i5/yGtIkGnDju+fe9EXiSdV1Y2qR0PlO/KpPGUzhlWJFeAc0L1MXqP+32cfwPtNuf WG5QWbUvKTwyR6opQzDLz0i0CGaKJ8Pt5LEip/enHkOVrWfDnGx+KQJwg875w86qaGKB j/Xa+ma4Xa1S0Aqk+/Nfqt8sswYPxgYWylq9Gk/7oBQ9oG768+iTEGjHHD+EUu8sY1DG 75fA== 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=FGH+Ljl4s6SmZtr/mbRqxMi5iJCFYf0z8DPotTgMP2c=; b=Cf88r5U8I/KbPsiGSK5PKhUU9bcENXXu2uEq7pvNVQDxYC7oBL2FxKBY/cW4L6Y9pK cmGWASk/eCEbn75mz+lchdXWU6ZlewVFFs15G6Qel28SqjCCd0OKUPNaUDWrpubrK1I/ Th5Rg8RktyJsZf/1M3RtE4kskvdN5yCg1wQmJAHZlzSbMSCZub390WMAzZ8XpcOG0aKG VP0jxc4JUIeyJZ6PbTlgI9gWcRKEzE60LjqvR1PjGoSKnSWEDQdk7GMXGgKC7nmggJQr fxdNvtFFUKTMoAQVo71sCPkiyzB570pEY55xrQ9+BImRMaS1gshoiDbU2ny2UvhQC6cF s9Og== X-Gm-Message-State: AOAM5310SX1QnVTXIvJnG6e5/cnng4wD1dgUHsoG5Lu1z/bdHlQ7bl2D jG9IHJetaUSkElr4SZK7KlGzCmLxms3150Th X-Google-Smtp-Source: ABdhPJzo55eFGexFJ4OQtjswzKl2/hESbYXS4DXd2iLhGXrPlJRZ0VPFUR1UlcO/nwyA51bZo9haxA== X-Received: by 2002:a05:6402:4388:: with SMTP id o8mr22685282edc.262.1617692846361; Tue, 06 Apr 2021 00:07:26 -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 rh6sm3976566ejb.39.2021.04.06.00.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:26 -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: [PATCHv3 for-next 09/19] block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallel Date: Tue, 6 Apr 2021 09:07:06 +0200 Message-Id: <20210406070716.168541-10-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 a4fd9f167c18..1549a6361630 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -334,7 +334,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 Apr 6 07:07:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184297 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,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 95E0AC43461 for ; Tue, 6 Apr 2021 07:07:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75FF3613BD for ; Tue, 6 Apr 2021 07:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244161AbhDFHHh (ORCPT ); Tue, 6 Apr 2021 03:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244156AbhDFHHf (ORCPT ); Tue, 6 Apr 2021 03:07:35 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A080C06175F for ; Tue, 6 Apr 2021 00:07:28 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id r22so2717442edq.9 for ; Tue, 06 Apr 2021 00:07:28 -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=+WusjvsYw5StKARzVGPy5VqECBTOsgPT1toBxn5pBW8=; b=NWVVj+xsbec1zi5irfFY60twDIp2xhY45HkRjOWKXLfDEK7kT5z+tVqfZmbVxA1YQ2 dhb8IXFyzZKGJGu1tGWEHBCC3OjaKfyUGGlKsfSYQT+JphXuN8a45Jbdz1QRoPe8MHWS vec/FaYgDYTXhX7SP08PRKLCIDwdqs6cMdG4TmIRnRadNYwokZ2qHxK7eY6PxWps6UP/ E6f7+Rot4/yVjg10MB+6zHkLxLC641W+lemtXH8X69EEGC1pP7Y5U+nCQkiaMTBIk4EX pa1Ql5r2Ai9PHSYpEok0PnBGW/JjC8VImzSMgFivaaHhPPqZjEsbr+twTQUg9NPm6pxj gGCw== 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=+WusjvsYw5StKARzVGPy5VqECBTOsgPT1toBxn5pBW8=; b=c7b66KVIa6u64ROuiQHSoblt3yGJCufTXSF6xoh0Z3+BfSCs9dfhGJboIAW6xx7t4d Ix4sQK5UdfPhBIk0MVLtdKVZSlR3UxcFeSIEeJIJZS+h8Sbx5uR2sIqf6JKhAi+/AxPX GAij160sOX3mj5ObAiqK6cVW9yRcB5art/P6+R/vJ8wPEypRQq0Hic65PZQy8pZAfGz7 WVWM0XXI/Un6nID5Bo+Ncleg1y0RDFIt7q/Em6EzH27Sye3FLwpuLO8tG5WIaRiqsorj 8rKxd/yYL3kZpBMIQh957BrlxqrpBczJBXtW9faPLfTSea6bQxsOzGs1sPg3jogbn9zL zyWw== X-Gm-Message-State: AOAM533IY/BGwLC6rRB9zG4SFjjStAz9Q9dknha+QRsM86tcDU6Ck67q INmx33ek4aQv4G12Gce0QhoEoTg/eqjZrC3y X-Google-Smtp-Source: ABdhPJzfHZjDCaSxZMZCqSvGZZAnCtXbuJ9dcytYS4TgNxTV0+XodGf9U1kK+TYXhLgYylCQaVYRsQ== X-Received: by 2002:a05:6402:430c:: with SMTP id m12mr37036358edc.138.1617692847015; Tue, 06 Apr 2021 00:07:27 -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 rh6sm3976566ejb.39.2021.04.06.00.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:26 -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: [PATCHv3 for-next 10/19] block/rnbd-srv: Remove force_close file after holding a lock Date: Tue, 6 Apr 2021 09:07:07 +0200 Message-Id: <20210406070716.168541-11-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 05ffe488ddc6..acf5fced11ef 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 1549a6361630..a9bb414f7442 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -329,7 +329,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; @@ -337,6 +338,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 b157371c25ed..98ddc31eb408 100644 --- a/drivers/block/rnbd/rnbd-srv.h +++ b/drivers/block/rnbd/rnbd-srv.h @@ -64,7 +64,8 @@ struct rnbd_srv_sess_dev { enum rnbd_access_mode access_mode; }; -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 Apr 6 07:07:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184301 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,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 16513C43470 for ; Tue, 6 Apr 2021 07:07:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBC93613BD for ; Tue, 6 Apr 2021 07:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244165AbhDFHHh (ORCPT ); Tue, 6 Apr 2021 03:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244160AbhDFHHg (ORCPT ); Tue, 6 Apr 2021 03:07:36 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E465FC06174A for ; Tue, 6 Apr 2021 00:07:28 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id w18so15277701edc.0 for ; Tue, 06 Apr 2021 00:07:28 -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=d7YY4Yx0tOezgEdUSrG57nr2i7WNMjSlXas7hudpooo=; b=Gq+AJzHwygRQecO1DUI06EgwmtIa2x4/T8iosx3EBM8c3yRRgv7bGbKNjbQ0AIhmRe 5DM6KEOIFHqB3syV7L9gJZgazFTYf2KMtOj+5KAsvarLRVq0h/YIzTi1yIrylaGr/M9E nEOAMPYRVSrJc668DKuUQWy0Rvh2PfHhlBVo3/d1oHvo3MCbG3cl8XrtRuNuiKHlTXr2 epgIHAP1rg37dbX2xVhRAyvuUX1EXOVeGxUi+YqNLIEXfTgRN1pffiiy5axpIlxNw466 mc5wemeI9vAsCRVdnb+QJcfSu/BtNlC8gt5IgOLM4rDqHojOKvB69+cogP8YuPDHwi8X kXpw== 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=d7YY4Yx0tOezgEdUSrG57nr2i7WNMjSlXas7hudpooo=; b=SvgX9UP93W3U8o0zIH/HtdqiRm3Z11u6aQk8PP6c/Ro735XExbFp9XtyLe48rMyWFL 02Iy1hWQIWs2GeUdYkfhJej7TFGQdh+3JG55oUech5BH466LAwP5tXSUaA6lReJe4M0e RjnU/PX8JYlxpggNiwPa/2vmfqXKxHWjRmoGYa7QSLj2LOAcTdxyMHuh5vzfZ6DZYdBr EY+5Ryml9mnue3O4z9Rr/kpaqI/ngVObwuZmiaztoV6LUImGqzFGBLnuGnH1USLxpPRa CWrEyFgoUDAbjE4XGVTjyVuIv9kAhkQjBd6uNOmSAoCUqRQsUh/VDd6ft/C+It+ltqUb LFzA== X-Gm-Message-State: AOAM5307v2CrArSCUBP8rhx1ttylcblFYFy6OyOoVRZqdy3c1skiRe9F x1oSPASdXNovhPuIk0rRzcPpINkqAa9PRpFk X-Google-Smtp-Source: ABdhPJwVeqfTK7amZO6bEOReVOaiRcS+6tLwJ2OtzEytlMVd6aVDY1v+p4dcvmhHy99aH1tvzHCCLg== X-Received: by 2002:aa7:cd12:: with SMTP id b18mr17421092edw.340.1617692847611; Tue, 06 Apr 2021 00:07:27 -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 rh6sm3976566ejb.39.2021.04.06.00.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:27 -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: [PATCHv3 for-next 11/19] block/rnbd-clt: Improve find_or_create_sess() return check Date: Tue, 6 Apr 2021 09:07:08 +0200 Message-Id: <20210406070716.168541-12-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 652b41cc4492..9b44aac680d5 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -910,6 +910,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) { @@ -925,8 +926,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; @@ -1194,13 +1194,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 Apr 6 07:07:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184303 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,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 EEE52C433ED for ; Tue, 6 Apr 2021 07:07:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAF69613BE for ; Tue, 6 Apr 2021 07:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244160AbhDFHHi (ORCPT ); Tue, 6 Apr 2021 03:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244170AbhDFHHh (ORCPT ); Tue, 6 Apr 2021 03:07:37 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9098BC06175F for ; Tue, 6 Apr 2021 00:07:29 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id z1so15214116edb.8 for ; Tue, 06 Apr 2021 00:07:29 -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=kudgbHD2vmKiyqxiiVxPOr/XbfnTQZ5BaCjcZ6vN5kA=; b=RFeCc/9/aDukrj2fM0mnC2EFO9TrTjpt0jbKUUOrTu/KNoWgD/OlhkXz8v3J6Ssx9/ HePYOS7059u958LZEViz4vYNfFg/1cS+Hdh/1+enNDwfPKMSRKE4I5aSW6ICrlh6cFlO ew7yfOjldJrqq0/VaoPkClOa0lIoT/2Hnq8iPWXDXXqVNdzjyIFUeJ8QMN1crgPnYWe2 K5Ki3iNuxyFujIGAXeEkPHKE3iFtm/2mal0Iyx6FlXnE0nBmG+JYyIu3ZaRvT7ED4IZC HS9Vh3NrDmbPrG8/HplDXSgqPPwHMTI0zEjzHNN/rhZsL5GiqXJ+nc/85xWUwJAH+4Cy 0G/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=kudgbHD2vmKiyqxiiVxPOr/XbfnTQZ5BaCjcZ6vN5kA=; b=cXbOWFdWzoMOQ0QkI5Jowmdcm5dmeNueUKYyBrV17VKKuxCtcNWmaANJCc9EH2BmuJ t+fosF/TSGOEc63bcm1+TcJUCC8v/ZK8Aktph28auPLXakOiZJBUS7w38F6AEhNH/OPp BBcNzQcsuJ2ozOR8tkFDWgg0tuxuc21TT98aJDxu3qngu3ciX2EnIG2CHnYKMR/upPHH rwhPsTkeQ2pYJw6/XZOh6BiGaRphmNqiTdPcFCs63ALpv1wQCjsplj2ChGNcd8j7eUTX mj320BR81mjrKDRhxG9ma5ZxTU2Sa3IbGoMcqNSHLnXWWaWx5r0NJAlkkkUoYJse2K2A U85w== X-Gm-Message-State: AOAM530tkoUp/wXMWUWC5DUs1oGjes7iliI0aGqHNtt2b5+rzEbD7HAM X8CxpNNeYFAybQu67tDHRSZoNI299BoXQLb4 X-Google-Smtp-Source: ABdhPJyiWdE5tWgmO1d9FtkMzYRkR97x2zW4bcmIuef+YR4nlsvi99kD+PZz6uSQ5cFaZVBurXNRLw== X-Received: by 2002:aa7:cd07:: with SMTP id b7mr7106862edw.293.1617692848246; Tue, 06 Apr 2021 00:07:28 -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 rh6sm3976566ejb.39.2021.04.06.00.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:28 -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: [PATCHv3 for-next 12/19] block/rnbd-clt: Fix missing a memory free when unloading the module Date: Tue, 6 Apr 2021 09:07:09 +0200 Message-Id: <20210406070716.168541-13-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 58c2cc0725b6..49015f428e67 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 Apr 6 07:07:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184305 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,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 3F526C433ED for ; Tue, 6 Apr 2021 07:07:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1915D613BC for ; Tue, 6 Apr 2021 07:07:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244156AbhDFHHj (ORCPT ); Tue, 6 Apr 2021 03:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244168AbhDFHHi (ORCPT ); Tue, 6 Apr 2021 03:07:38 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EE72C06175F for ; Tue, 6 Apr 2021 00:07:30 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id u17so13940183ejk.2 for ; Tue, 06 Apr 2021 00:07:30 -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=hJAnhx1U00bz4Zg1lC7sxd5CfxcDWuWV5OG0mwf0sR8=; b=XmsBIgsonxiztmIjY2IjuFSw1ivv5NCZ2jhvdvvYQrtSPx5k/fIik9Dpk+6kZGNMNt /yGiYLmlk4QuKDRBdMyDv0R7a6hrc6Tqsp0K6vHD69u1FtUQZ5dwScsQ86qx1Afy7kTx 6jEc5OsEjYKOYRxRYePSKR6a9kJT51zfExYLSok/lNLPPdcLnceo9tWGm5bK4PNXNWRZ qiDqFZISwKG4B8QVCDcoiuW24/QbBn6Y5w65+YlYkIc9N0r77cFlQrFoy/MtGC7obqUH ZT0qglqpA79tnDvkhVZJt6DIHtrWDu95TpE+TejCHhmQPU8NQnlMRUiSxHSYP02kkWZ0 kvwQ== 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=hJAnhx1U00bz4Zg1lC7sxd5CfxcDWuWV5OG0mwf0sR8=; b=juMDPW416cYCa8Qy9OD4F3cLqAPRd7DOTD1HKHk4xfN7+Gpk4LmwZ58d1nC75VsgQM Q4/UXn9td0x1BKMcD0KpChfm1bYu0iSwm2PanQkeSOcAEqL2VunrqM/7/wvCc3TrEwCX h0sligBJsWeJVC3JH2scvAH6rVs/IkAMGsedFgnpLmbUms8AAA3HBscVNke30xQ3Ji/q 6wRvMlQpXbDxuTg7vDiI2pBAaB1m4n5kJzUkhuaCKrZMXlOziDYUDN268gIyWbw3JKPm rFjuIkhyAucEcaoeYhcx9bGbrg2EaInWBwBjkYJccNC+I05a01PXHyv2mZrdLAQRNRrv lvFg== X-Gm-Message-State: AOAM5315EHiEOQpoGHgYLS1gGs+H/X0lCsjohfPYluWUicKJfFtfnhsC h04RfozMnAECemzJCdZlyEUX/q/IJOt6tq8J X-Google-Smtp-Source: ABdhPJzTlseXk0Uut6EB+rveitJ/HH+C6s1H9ISkZ7TLEIgznRm/Nl/xCNMRoLIRrwxcCyQheGE1fw== X-Received: by 2002:a17:906:468b:: with SMTP id a11mr8478805ejr.190.1617692848943; Tue, 06 Apr 2021 00:07:28 -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 rh6sm3976566ejb.39.2021.04.06.00.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:28 -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: [PATCHv3 for-next 13/19] block/rnbd-clt: Support polling mode for IO latency optimization Date: Tue, 6 Apr 2021 09:07:10 +0200 Message-Id: <20210406070716.168541-14-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 49015f428e67..bd111ebceb75 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 9b44aac680d5..63719ec04d58 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1165,9 +1165,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) @@ -1181,7 +1226,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); } @@ -1189,7 +1242,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; @@ -1198,6 +1251,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; @@ -1219,7 +1283,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; @@ -1227,6 +1291,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) @@ -1370,7 +1435,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; @@ -1379,7 +1445,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; @@ -1405,6 +1472,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; @@ -1491,7 +1559,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; @@ -1500,11 +1569,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 714d426b449b..451e7383738f 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; @@ -118,6 +119,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; @@ -147,7 +149,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..467d135a82cf 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..f891fbe7abe6 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 Apr 6 07:07:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184307 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,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 A6F50C433B4 for ; Tue, 6 Apr 2021 07:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86EEC613BD for ; Tue, 6 Apr 2021 07:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244175AbhDFHHl (ORCPT ); Tue, 6 Apr 2021 03:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244159AbhDFHHj (ORCPT ); Tue, 6 Apr 2021 03:07:39 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE1A7C06174A for ; Tue, 6 Apr 2021 00:07:31 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id hq27so20160106ejc.9 for ; Tue, 06 Apr 2021 00:07:31 -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=FEfmwQUXBosAQZDv4iPqtBJQ9H+nanJx8NHptNglQNyUYRFXiXUhx0jXHKDcQdJa3a zlpYM1a02NTJa8wYEwc5djYFvY3PrIr1bGxbpKNynHiFGicIBsRcVfkII+8UEGrQCYCV +R9tFrIAnWHAe3pzNO4oGZ+taZNFW/x4Je34Q/TsOW6REc0WLdUZGkK58jHo4bAblw79 A72qwuqPdz/Ge7dLThxgThZ0epp/7dzyZWhh+4cLbHV5zUbDwJP7CagtVvmouRJMqJqQ VKsYi4zW7KUz3waH2ovUvZ+QbxZfR2WbwyReKvQnofYw/ThWx5Prx54Iam8yFUsPftS/ cAyg== 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=EXo6fycdoFOrwmR4zN3W37/GhjLQebwf3PlIU13pRWcn9s66IstHdg9Uaifg29E4vu lf9xMKb65GdlO4QD55tGQq9Fb0tQ65IbfnLKzH99pGL+EAQhtmwnOxq2uwJS9B4exDK3 bnsfqRfvzjcrauJRxEfhrWNaDo0fZKfRiDTrTcv0dak2ETQXF+FkORet9pGBsH3XtgdK uapC12etxQtafaI4WNQNVJUHAqEJPBpTslW5ptKAaPzTkh9ELyI1o1XI7V8nYo56xeZj jRF9E+OHaNjfnEU3IPr8U3iJKlQswBvf2kzWO3TLQ+RQXXxCm7rx1OsfH340vcYeITVu SEQw== X-Gm-Message-State: AOAM5319VvTdUxxjwn8D44M95I34nMvdpZNQZD2UXjvOfHXsBZ8cnrJO Xr63tWuU2gMEVErZkSegnUTcbQl2HT0YUOrw X-Google-Smtp-Source: ABdhPJwskWgEDrPtSjvJKOluxt9Xrw5sCnUjjCo+bXft88vaUchkEVSbKfQcj8aSVJuu08B983zKxg== X-Received: by 2002:a17:906:6d8e:: with SMTP id h14mr32293574ejt.410.1617692850455; Tue, 06 Apr 2021 00:07:30 -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 rh6sm3976566ejb.39.2021.04.06.00.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:30 -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: [PATCHv3 for-next 14/19] Documentation/ABI/rnbd-clt: Add description for nr_poll_queues Date: Tue, 6 Apr 2021 09:07:11 +0200 Message-Id: <20210406070716.168541-15-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 Apr 6 07:07:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184309 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,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 90A10C43460 for ; Tue, 6 Apr 2021 07:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DF5F613BC for ; Tue, 6 Apr 2021 07:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244195AbhDFHHs (ORCPT ); Tue, 6 Apr 2021 03:07:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244173AbhDFHHl (ORCPT ); Tue, 6 Apr 2021 03:07:41 -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 8FB72C061756 for ; Tue, 6 Apr 2021 00:07:33 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id w3so20212540ejc.4 for ; Tue, 06 Apr 2021 00:07:33 -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=F812aa4/3PSgeGPzkDT7ljqwsfhAuXYzi7rqcrHnEvo=; b=ayqRf8x4PuFmmln6yZAQD2HSUIns6GQNKasdG2+asQiW+Jpu11KpfLmTPzpj41g9Qr nCSBcTWEpGQ4Z2b6KRi3/ull5gNwou34iRBAEO4E5B+ZJz+DwCkr94BTZI4Hde8y50IG et+jwIEoJwdoBC1CKS2FpNeX0y2/nbT/odvugKBsKMKRySnukV8riNSa/I1tnlmaLZ+A HIvkZYB+0iJO8BG0jrPtySglg/t3COuaTlVi1lBqjdYaTBEK9RKBV4kjoBclhXyIQzwg nBOvoHKzirVcHXpLgjwy/m+bbxhm/+db+5su1DSTx1zqnFPVUeo9b2o+tjbPyOmkkoHW Bo8Q== 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=F812aa4/3PSgeGPzkDT7ljqwsfhAuXYzi7rqcrHnEvo=; b=ZNSSJXsV5EKMTkR4/KOnhjZEQsCef7I6bIduCVnItvHyIUulVhGhJ6jjAn+CmY295D cs6FIBQP+IAS7dSOlu6Mh6u8rW6q9gm/z9qxpErz4wR5RJBqEdwTqbJ6TzQG6sAa0eWt xDbtGiwHvO6PYMvIkPKGfL1IW28c9iwxat1IyBMj2T3O2BPDoN5WZq13cozHAIVr8cYa aX6sEUNL1856AgUNslIZv94ZKCL18pNQSAjtsz+QHXuTosKy9fMjyKBRbsNwXsi1A1fQ WkLSPGTSH9sA1RetVzPNZAVmVU9ruMTkDriYgxUyx1Bi7TlBFTV9QFsLAS4KaZUfmifq ySrg== X-Gm-Message-State: AOAM530y9hpoHD6L6F+4130r3VFKAe1N3r2XmWkcATIp8j/9sW5pGEjj OxWXqdWMRwPZi1n/OPoYtt6ElwQBZKOUOo9U X-Google-Smtp-Source: ABdhPJwcQeDiUEU6sL1cEBzBsNvd7rwxwaCePn+jx+023/SzzZP3CZr09UZ7VwI16y71Ys7rAqBzdA== X-Received: by 2002:a17:906:f953:: with SMTP id ld19mr31277224ejb.164.1617692852211; Tue, 06 Apr 2021 00:07:32 -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 rh6sm3976566ejb.39.2021.04.06.00.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:32 -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: [PATCHv3 for-next 15/19] block/rnbd-srv: Remove unused arguments of rnbd_srv_rdma_ev Date: Tue, 6 Apr 2021 09:07:12 +0200 Message-Id: <20210406070716.168541-16-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 a9bb414f7442..abacd9ef10d6 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -114,8 +114,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) { @@ -344,8 +343,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) { @@ -364,20 +362,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; @@ -391,19 +387,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", @@ -656,8 +649,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) { @@ -698,8 +690,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 f891fbe7abe6..b0f56ffeff88 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 Apr 6 07:07:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184311 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,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 95BD8C433B4 for ; Tue, 6 Apr 2021 07:07:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75E58613B8 for ; Tue, 6 Apr 2021 07:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244174AbhDFHHu (ORCPT ); Tue, 6 Apr 2021 03:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244180AbhDFHHn (ORCPT ); Tue, 6 Apr 2021 03:07:43 -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 452CEC061762 for ; Tue, 6 Apr 2021 00:07:34 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id o19so15225018edc.3 for ; Tue, 06 Apr 2021 00:07:34 -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=4l0uTtiV7ZxDBIfEDONSIU85jI5qJ0lBYkiqNJSWw1E=; b=eWczOm3r9X3LFsQZu8U8zG959MA0I5PnmHH0TvJQq7h5sNf0u0hTDZKfcCNd/hFUmH mQG/g4K0kPq5+jpogkPqKIDSqO6NHDW+mF/aKlXmWAsRnmgHdsYn1HU6rKtVc6APTu0B tip0V5ArzOaRrakWOfjdKZskKzfeqgy32e7IwFoKBxXF3bXzOfzfoXt6MJSRXoNh/j/L hJfZjIhUOjVuMmdqrqasmwmqPzpsO9jxZxYZ5Ed/33wvG7MeWKXj3OmQN5yFVjLpODRp vCRrb2bUgMe/8o8I1KZPzuwsvxrT8WIc0SUCnt83rFLtxLxwhwaLc8lLqLp0jen9bqZQ 7ltw== 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=4l0uTtiV7ZxDBIfEDONSIU85jI5qJ0lBYkiqNJSWw1E=; b=SyM3RGxJQqWCR3wJeMfR8NWV/MNawgBxnZJ+PJxCr52fVrD1ItNIJBliny6VDPFhY4 lnbIGNpEB1/PYvTdaMAUM6wCjGoEprAfQ0EMTf8rPdqJoMSKfxSAIZs9kzudZgpQQtN5 DGrRe90poszXfekD+v6YR9a7713okewb+TJzclWkvjuPZFM/ui+74t1+51sOeaEAC2kY hW6iKTAKsWs2+T1fepYKJJHNkTm6bYjIFj0a1DPZPmV4oZAs7yalqWVQIh48o5lA4MJJ B5GPoY4OD+n6cpHTfHcprNI8MLD7sGGHubYRy79wXHkCNfeclNJfSbtCd4RIh5kFOp21 71cg== X-Gm-Message-State: AOAM530OmVNP5Xsbaufzo8hBTbV30VjBDYw1B9ipLXgZ2ev9xAsWqlbM WKi91AqXyY4cBCMoz23yGPzwLzfU3hxGfW1I X-Google-Smtp-Source: ABdhPJzrgfGzfIV9MLiSgvXcFtJ66B97KA5Dd4YU/8iciFKEPNmqvLCeqC9O/mKyAFOrrTdC4mLAvg== X-Received: by 2002:a05:6402:40d5:: with SMTP id z21mr36971205edb.20.1617692852838; Tue, 06 Apr 2021 00:07:32 -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 rh6sm3976566ejb.39.2021.04.06.00.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:32 -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: [PATCHv3 for-next 16/19] block/rnbd-clt: Generate kobject_uevent when the rnbd device state changes Date: Tue, 6 Apr 2021 09:07:13 +0200 Message-Id: <20210406070716.168541-17-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 bd111ebceb75..5609b9cdc289 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 63719ec04d58..1fe010ed6f69 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); @@ -649,14 +652,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 Apr 6 07:07:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184313 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,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 1B2BBC43461 for ; Tue, 6 Apr 2021 07:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D348A613AD for ; Tue, 6 Apr 2021 07:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244180AbhDFHHv (ORCPT ); Tue, 6 Apr 2021 03:07:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244183AbhDFHHo (ORCPT ); Tue, 6 Apr 2021 03:07:44 -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 10D39C061765 for ; Tue, 6 Apr 2021 00:07:35 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id hq27so20160320ejc.9 for ; Tue, 06 Apr 2021 00:07:34 -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=u9p6hzGO3n9rwReCcMTUMBgkQ/We1yFtqYVf9rejA0g=; b=fuI/PWpDO9cyIua2uqhsuAoM8XuPdY5+68V7VI94sbJ8hUnAt6iZggIwgILtnLC6ih ZmNacMNouvzDOCNnO7GbyKeBmZB+MxzUKs2P8/WfOlvL0y1Yf1fK06wxs7LZJhLzYNs1 UG0ZDYn8oiE8uoBdJ6XFzV17UvSYEbt4O3RTlyRoHuV/Obb996vBA2BL+W4CsdHyPHq1 /b8a422KHw/xVYLSPePnqTF3eaiSA8ycfFX49NcZvavxX/wI18e2FqeB+lt412NtWW++ HMhqnm+ojlmJ4w7n4lwVl7hCX9gUPg3Y6v1CsaUQ5sUxOa8+MDSiOE3cXJHNSENcs1SU z2gQ== 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=u9p6hzGO3n9rwReCcMTUMBgkQ/We1yFtqYVf9rejA0g=; b=L/giWLjTTFKZKF4qe0OgVd36g5eWwJE4982bPvHxE2pk+T1VQurEiY4Oi1TMSoLv1q Ax87haJDbOGRWRdkgX92wDPnB3jGhodLNpTgSDunLUl3gZsVvNIg1KxZYxnCW14eMy3m E/3HhopqucgdSzz1qtX0zB4EfXpsuuR2oDmejnbeGYlc1O55/uKfcFi/V8YZ2gaj+e6f NsxceIc7e1SBAzqP2ZbeunUZz2s2kPYtsRxG/F7AKnzEF8N1dV95mvzR0m8lcS8I6PWa o150QMu/J+lka9rDixiPmiYfYAWtiMiQqEEnOWPznTKnCi6TLm0uOaiM7IXnAXRXTBZM 0EwQ== X-Gm-Message-State: AOAM532Ja23KNsiSPXvSUIjZEdvL3ibqT23M/2DA7OSxnaXANhiDVMrD EPYTaXT5zjULusCsUF3Nh0L9fNmotpIDKGu4 X-Google-Smtp-Source: ABdhPJxtNtAKqmHM44YRSySPOGPs78CY6I2pLWwN6LXxR3bCunUd7U0AJkYgpL3OP2HTLcg1L00p8A== X-Received: by 2002:a17:906:3c03:: with SMTP id h3mr8813240ejg.329.1617692853649; Tue, 06 Apr 2021 00:07:33 -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 rh6sm3976566ejb.39.2021.04.06.00.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:33 -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: [PATCHv3 for-next 17/19] block/rnbd-clt: Remove max_segment_size Date: Tue, 6 Apr 2021 09:07:14 +0200 Message-Id: <20210406070716.168541-18-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 1fe010ed6f69..7446660eb7f2 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1289,7 +1289,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 467d135a82cf..1603e0c399e8 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 b0f56ffeff88..bebaa94c4728 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 Apr 6 07:07:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184315 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,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 8C722C43460 for ; Tue, 6 Apr 2021 07:07:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 643A7613AD for ; Tue, 6 Apr 2021 07:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244184AbhDFHHx (ORCPT ); Tue, 6 Apr 2021 03:07:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244192AbhDFHHs (ORCPT ); Tue, 6 Apr 2021 03:07:48 -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 11F0BC0613D9 for ; Tue, 6 Apr 2021 00:07:36 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id h10so15176958edt.13 for ; Tue, 06 Apr 2021 00:07:35 -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=2s7RNT3LX8gTuZCICYSmyJWDdR3TrhGuTgZQuuJS2r0=; b=BTEOV8igl7doqN0wAM4fVRQ/JhTPJ87oFsAv4b4mf+Fx9jI6x+2BJrrwxeonZu3Jlb BcDqSJuT8oHXByU3AYxbZXPaEaQxd4OM39nAwjqLexMXsVcWbDbNg4C5GLtAFPejuMHe 7TaDh+poHfNp1jCsO9Tx6mE7iJ7Pm5Wo8POrN8cooJQ0DMWRtXIAnVXiAilR+RdBKa58 5usc74sUl/jX4O3KgGAsVTEWfUIGgZ7LRKaITH8MJzrJkvdQM77qyuUP1ZVd3G0yEduM EERedtLO1SPJ4NtkVIBQuGZgy00ikaKN5C2bT+RM2KH5BPYfgfKQQW40YMxehO0k8K4o w54w== 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=2s7RNT3LX8gTuZCICYSmyJWDdR3TrhGuTgZQuuJS2r0=; b=FKI/CGlFXNrapuGMKxBn9MbV0HNmJAaV/bJnVD2Y4IGz/XWDWrSBYI8d8y4qXi0lnI A/tvrq661VvQqb9nrenEskANjAo7f4kUMmya+nuqZ+7ZULaO9sy7/C6Xi1DPeynYOJCB gtB51XpJ0b1+blWRZhBU/sYSOF5egQGoC1aA/AZ9IrfWSA4ihtAhTBPcXigHge6WXYt+ /pc5+wADHl52G/x6nTntkRKvzkX1zzZLm+DPM5maOcXJx+RjRvppmz6FmafjwQNSY4hX xelZSpk9UBF2hP33hLxN041tHJxt73FPeJt/Xp8VsGJEu5RTP4I4etEdrSWUXQLv0Jzz BP/Q== X-Gm-Message-State: AOAM530eJd63BrIEASIi3Z4ZkmZtNM7avzKR7oZDMgmUJGfCUSWsCU3w QFbIgPrvp7Rhqn+Aghh/z0Lgya7942GTJ1V6 X-Google-Smtp-Source: ABdhPJxKyfUuGoAxriaXXPYyA/GCVBcWMsEswwJPKeXp7axcs/ycBMnM5KrIWRG7MAXR3eapl7GaQQ== X-Received: by 2002:a05:6402:394:: with SMTP id o20mr10963660edv.10.1617692854607; Tue, 06 Apr 2021 00:07:34 -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 rh6sm3976566ejb.39.2021.04.06.00.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:34 -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: [PATCHv3 for-next 18/19] block/rnbd-clt-sysfs: Remove copy buffer overlap in rnbd_clt_get_path_name Date: Tue, 6 Apr 2021 09:07:15 +0200 Message-Id: <20210406070716.168541-19-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 5609b9cdc289..062c52e7a468 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 Apr 6 07:07:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12184317 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,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 D91D6C43470 for ; Tue, 6 Apr 2021 07:07:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9807F613BC for ; Tue, 6 Apr 2021 07:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244187AbhDFHHy (ORCPT ); Tue, 6 Apr 2021 03:07:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244199AbhDFHHt (ORCPT ); Tue, 6 Apr 2021 03:07:49 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92A5C0613DB for ; Tue, 6 Apr 2021 00:07:36 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a7so20231588ejs.3 for ; Tue, 06 Apr 2021 00:07:36 -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=k4zffPMBXmPEyMn7OppiFH20hDYGNNgWoIdjGx2E6VI=; b=WjkwRecP6xDENuPwNolwpA6FwfK5PyTJSzZlVOQwdPsruAG0sRvrzpxPJ/qXllH6Vc pPt7cbt81axBf2X6/DVJxXxRIRJvAgAYetyb54X+RCdsA0Mryw0JD3PjKobnC3zfjhFN HoNLJcghAogUbML3r0Pxdz789nmrsmjXKAXq5ak3H7f1A8rYErVRnf4EH6MzFBnEd/ad oWgufN8PJbGh8tdqBsUyZcJ7UDsPhzi5rR8svcwI4ahjj6299Iey6B5TfeOHG4g9ewBv K7KdJvoytf53Un0mWCQuyxxzbNSfxHXayHXbKrN4uDp/QdTQabAuHJxMYBFGipk5+YEm fedw== 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=k4zffPMBXmPEyMn7OppiFH20hDYGNNgWoIdjGx2E6VI=; b=en69WFTAoOtKkWNTpFeA3jrVIqiFc9zxZHY8ug1mRngHqfhqMAP+4eCnBB4TTnbLIM razZMh4OkD3aZ7AvIjfSRrby5vmV8QN+fzhfd7Lk0jlbYLmqWTiQsCernnxUFBJX1T8O q1aV/6cpPs4DQIvEVCNiRbMSboPn/fmhYLoE60HzT+BSL1V55OKOgMBqW5EKLdz4E3V3 YnYiuIMBJCJMCKYrOrY12xD/OoSjrFubdm0C8yRvBF+FcQDTFbxvuzSQH4aUWGL3aHH+ vSybIAZojZrRknytixidkIvWDcjhnEGzM0IK12Ubni8eI6ht6Hh/JLgYHo5m88Jzy1ik KjpA== X-Gm-Message-State: AOAM532/j7O+iug7+4DuMR1qjYKv6mBcSrXBMkRNFU5BxjBSL5+W2sYc 6DU/IpQTa+FAgMhHmCYMiMzu/Hwxs+s6IHR1 X-Google-Smtp-Source: ABdhPJzLk5ZosPvyg9l3HiuYxX15JbVMv4Yqrlj2oQNbMZsUBeNRWbDZLX/4K5jaYONS0Gf2T7lqsg== X-Received: by 2002:a17:907:e8f:: with SMTP id ho15mr33005932ejc.541.1617692855295; Tue, 06 Apr 2021 00:07:35 -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 rh6sm3976566ejb.39.2021.04.06.00.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:07:35 -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: [PATCHv3 for-next 19/19] block/rnbd: Use strscpy instead of strlcpy Date: Tue, 6 Apr 2021 09:07:16 +0200 Message-Id: <20210406070716.168541-20-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210406070716.168541-1-gi-oh.kim@ionos.com> References: <20210406070716.168541-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 --- 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 062c52e7a468..66316cdc2a92 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 7446660eb7f2..76556fd6f153 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -578,7 +578,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, @@ -800,7 +800,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 abacd9ef10d6..899dd9d7c10b 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -298,7 +298,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); @@ -437,7 +437,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); @@ -589,7 +589,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;