From patchwork Wed Apr 28 06:13:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12228119 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 79D7DC433B4 for ; Wed, 28 Apr 2021 06:14:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53D986141F for ; Wed, 28 Apr 2021 06:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235991AbhD1GO4 (ORCPT ); Wed, 28 Apr 2021 02:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235977AbhD1GO4 (ORCPT ); Wed, 28 Apr 2021 02:14:56 -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 1B7DCC061574 for ; Tue, 27 Apr 2021 23:14:12 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id c22so9091079edn.7 for ; Tue, 27 Apr 2021 23:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yv21oxwwm3U+ivQCHp5JpB+UCkax9HwL+d8tbFJQJ34=; b=PhOX/AdBxPCJ0gpC5bSI0nX+VDTnNu77221EnQrDMdHNbscvb1jJ2tSChf+19p9GX2 qsAtsL1rw1xVAlFzrfwPKDQxS2oyhzgdxnZ3MgCEJs4NiKPUR3HCGrjLfka8vSgJ2BHg EoxnprYRlNLj6CEKqO3tvZwlpjhVqSKzHP5NoCypTkyIGwKhjSrMfkGhxfK1WCsyO7He UQE0fWEtjoeTkBb4gCBGs9zO7IOMaCiW6nVyDL7m4F86Qioydu2hQANQH9ugGp+O48IH K4/m/IPcTJnqdK/JYR+LbT9dW7xY5CDD6SSMGZCLslqqQ2ZpAgGKgw6GkHGj92SfddH7 pN/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=yv21oxwwm3U+ivQCHp5JpB+UCkax9HwL+d8tbFJQJ34=; b=NWxWMhlTnXmPf6Tf1i638fqeV37yJ0Ky16vtNUrI38TbxUlP4lxPZ52AJTeTtiso2r mNRm01C7MA1cPqd1ZwJjDKhGkStA1D5J0oDvQSkJzDUJLzH/zc5/LBV56ykXbAsfxUn4 zv2ci2RAzlJTyGf8vZeHvhFH+8YKeVf1qxS/5cmyr1RSvuyTWvK8wfxPJq8+ufiDd+ih nqo0gRfAJKD1rDAjf9CNvZW1IMoCwwHdaVLeq/2c//wCkyMQOwlNQw9i+MEImlWRId7F 8/nL8s84Q1XIzI/VLkrlQeZ1ZeMYaIHNpTAvvC7S9u96yX64KukyHG8DiIvQ3viC1Z2P HIgg== X-Gm-Message-State: AOAM532HFSG0gNrCF+v1lNG7J9CwuvPdLgo/dmlPuS33gzOvlVvPinFf g0USpIpdX3zJm80as1jOiCjWMToMJSfc7g== X-Google-Smtp-Source: ABdhPJy82hEuWfb2FcQbu0sV/zk4pdGZx6XrwYgpbcZO5+pdzX96npQUIGFJ/9gbmRqAgw1ed896DQ== X-Received: by 2002:a05:6402:694:: with SMTP id f20mr8937626edy.93.1619590450650; Tue, 27 Apr 2021 23:14:10 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5ae8b9.dynamic.kabel-deutschland.de. [95.90.232.185]) by smtp.googlemail.com with ESMTPSA id t4sm3970322edd.6.2021.04.27.23.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 23:14:10 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Guoqing Jiang , Gioh Kim Subject: [PATCH for-next 1/4] block/rnbd-clt: Change queue_depth type in rnbd_clt_session to size_t Date: Wed, 28 Apr 2021 08:13:56 +0200 Message-Id: <20210428061359.206794-2-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210428061359.206794-1-gi-oh.kim@ionos.com> References: <20210428061359.206794-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 The member queue_depth in the structure rnbd_clt_session is read from the rtrs client side using the function rtrs_clt_query, which in turn is read from the rtrs_clt structure. It should really be of type size_t. Fixes: 90426e89f54db ("block/rnbd: client: private header with client structs and functions") Signed-off-by: Md Haris Iqbal Reviewed-by: Guoqing Jiang Signed-off-by: Gioh Kim Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h index 451e7383738f..b5322c5aaac0 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -87,7 +87,7 @@ struct rnbd_clt_session { DECLARE_BITMAP(cpu_queues_bm, NR_CPUS); int __percpu *cpu_rr; /* per-cpu var for CPU round-robin */ atomic_t busy; - int queue_depth; + size_t queue_depth; u32 max_io_size; struct blk_mq_tag_set tag_set; u32 nr_poll_queues; From patchwork Wed Apr 28 06:13:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12228121 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 20367C433ED for ; Wed, 28 Apr 2021 06:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBC0A61418 for ; Wed, 28 Apr 2021 06:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbhD1GO6 (ORCPT ); Wed, 28 Apr 2021 02:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235977AbhD1GO6 (ORCPT ); Wed, 28 Apr 2021 02:14:58 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F61DC061574 for ; Tue, 27 Apr 2021 23:14:13 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id n2so92827589ejy.7 for ; Tue, 27 Apr 2021 23:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LdCRKoX+xuUkB22a7Io1lxLMTt7m0TByGtjMv3RTyrg=; b=ELksowDicNNOCWG16xfEzZBpBAIYLfJaOrLpCO8okNpTNIi48yqFBN3N1CHhdl+DQi AXg6S89k/3nYK4qaCUqpO8+jvH/ZSWffGGp2Po8YM9DSeR05ripP5fbpk1QuEn4I+BPW 2LgmtLT5qESprami2ilBkzm0svJJVP5mzRD3LaJHDQDnazKujCIQpsmW3awY8wbgOHfn O2ZdXg5m81M3/aqU+vjlokHxes+IAQIftldH2/BlKGba8vDRJmNq96yQZA30ZQvG3gqC y3Tmpq+9DhcI3x3e1lXQsKNRh44YqECGsL1UrTwENWC0ApsNCzkVdHb4GWviKpx7Utf+ 7eEg== 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=LdCRKoX+xuUkB22a7Io1lxLMTt7m0TByGtjMv3RTyrg=; b=gVsQjMogcMlba2G+MWVH2wTm12k64aY8XELYr7M0rd6FD/jG4JLnNEljKQfBFskUjo mux1pGnaTXHT9mp1gDgT7KomP65A63Ydu8iyrAEl4S57/a2QKSvSV70A8xcdcRo6do0S pkVBfGVBqMCjFjgoeepyK/vtFSDeMQViunIWNHjocyV7FzSQJaPrStghLb/El1/an3Ac E4fZn7qU9dqORQFHMo0rzLr4GkSJBFQeEo7ipYrtrEVI+C5fiROIxnhZLPA1uii906wt xqQSuL2ij4nx08NIc3roTKEBtnXNcAGgNJEx81fmajNtKAeiw9BhPDtLrurkPix0SSMK mIiQ== X-Gm-Message-State: AOAM533jAhnfAVHC09soh9RDynaCCp7+sX2Z/D5TtwMCO62bbVzwYHz8 DloCmWsqa9KdctI64L5JC0/pEpPls9sukQ== X-Google-Smtp-Source: ABdhPJxoP8104/RU2hNpkLs0ZKSu1Lx2ot6WPRmbMPADTT2EUd+Syo9x7/4q7b5p0oDAh93yddqvAw== X-Received: by 2002:a17:906:564f:: with SMTP id v15mr16159958ejr.96.1619590452041; Tue, 27 Apr 2021 23:14:12 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5ae8b9.dynamic.kabel-deutschland.de. [95.90.232.185]) by smtp.googlemail.com with ESMTPSA id t4sm3970322edd.6.2021.04.27.23.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 23:14:11 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Dima Stepanov , Dima Stepanov , Gioh Kim Subject: [PATCH for-next 2/4] block/rnbd: Fix style issues Date: Wed, 28 Apr 2021 08:13:57 +0200 Message-Id: <20210428061359.206794-3-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210428061359.206794-1-gi-oh.kim@ionos.com> References: <20210428061359.206794-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 This patch fixes some style issues detected by scripts/checkpatch.pl * Resolve spacing and tab issues * Remove extra braces in rnbd_get_iu * Use num_possible_cpus() instead of NR_CPUS in alloc_sess * Fix the comments styling in rnbd_queue_rq Signed-off-by: Dima Stepanov Signed-off-by: Gioh Kim Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index c01786afe1b1..15f831159c31 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -88,7 +88,7 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev, dev->discard_alignment = le32_to_cpu(rsp->discard_alignment); dev->secure_discard = le16_to_cpu(rsp->secure_discard); dev->rotational = rsp->rotational; - dev->wc = !!(rsp->cache_policy & RNBD_WRITEBACK); + dev->wc = !!(rsp->cache_policy & RNBD_WRITEBACK); dev->fua = !!(rsp->cache_policy & RNBD_FUA); dev->max_hw_sectors = sess->max_io_size / SECTOR_SIZE; @@ -351,9 +351,8 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess, struct rtrs_permit *permit; iu = kzalloc(sizeof(*iu), GFP_KERNEL); - if (!iu) { + if (!iu) return NULL; - } permit = rnbd_get_permit(sess, con_type, wait); if (unlikely(!permit)) { @@ -805,7 +804,7 @@ static struct rnbd_clt_session *alloc_sess(const char *sessname) mutex_init(&sess->lock); INIT_LIST_HEAD(&sess->devs_list); INIT_LIST_HEAD(&sess->list); - bitmap_zero(sess->cpu_queues_bm, NR_CPUS); + bitmap_zero(sess->cpu_queues_bm, num_possible_cpus()); init_waitqueue_head(&sess->rtrs_waitq); refcount_set(&sess->refcount, 1); @@ -1148,7 +1147,8 @@ static blk_status_t rnbd_queue_rq(struct blk_mq_hw_ctx *hctx, iu->sgt.sgl = iu->first_sgl; err = sg_alloc_table_chained(&iu->sgt, /* Even-if the request has no segment, - * sglist must have one entry at least */ + * sglist must have one entry at least. + */ blk_rq_nr_phys_segments(rq) ? : 1, iu->sgt.sgl, RNBD_INLINE_SG_CNT); From patchwork Wed Apr 28 06:13: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: 12228123 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 4B23DC433B4 for ; Wed, 28 Apr 2021 06:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28BD461418 for ; Wed, 28 Apr 2021 06:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235977AbhD1GO6 (ORCPT ); Wed, 28 Apr 2021 02:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235863AbhD1GO6 (ORCPT ); Wed, 28 Apr 2021 02:14:58 -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 0A4ACC061763 for ; Tue, 27 Apr 2021 23:14:14 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id gx5so752773ejb.11 for ; Tue, 27 Apr 2021 23:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HN76YNCopOUfvfBy/lksY+1E2cxekdLf/6fjdkK043U=; b=hERUOW+J5ug2xAvXyJrhYW+M2xFohVRto1G9pYwpoDIG5cZ0nhZv7r3wglOrWZWk+D nYZkHYckQxDLMXFZfeYVZtsSSJF4gd+TxPA1pEnwH8BaE/kFTTjoHP9JNTn1Sbi4KZsI nip+2zf6YYJRqhAYnmy9VKrnNkF7DZ59Kuy1BsfAwWcwHVLBVUC62cnIoUwKmoh2H2Jq lkD/EuPpEcGpATbF9qzAr/ubqhrfqRwqzJEOzPewprY6hZLSLh1F/O6zkkm/JeTX6SdQ BG35K4moBmwTwnLKIHoRscDs0uG0RNgx1gFDaGpE1YAxDokk69IjzAW2ZZ6qb4hZzXiH PfvQ== 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=HN76YNCopOUfvfBy/lksY+1E2cxekdLf/6fjdkK043U=; b=Vh+QQN1Bm5kUItHTiZxbCQCnTIltSiCgN2k2/UIoVXAk4xw3BNEXAWfha2D996s2Ew BrONm7vdZcSJKai5+XFcY7Hn3OmBkBktGuKziq9yPDWEPdxUG3rMGEYDYbhZrhcpbEV6 MoBierIGcny9q7FcbKoYxYLTnVIunT3gaJMMHGptFvhfJROeeRi94D7AdLNY5JB7loCy khRfXQbf5NJQ65Fop3LnJ4KM4Xzn2o2oqZ7kd2xpRh1R3gHkj8RJrikMLyOgNMsfpv+C SRc+7kwMKRgoxISZ2tJXY7aJRsb6Iu05+J0yewA5WvBkRVlH/A9AIjMaEN6XqqBjfCfR aKbA== X-Gm-Message-State: AOAM530btInzvtfOnZbeeD4jwtfxcUdlIiWNPIBYl5MX+Hfe6M3oCW0B Xj6o6WeVH15ymfjLswfaWacWmskZMf0VDg== X-Google-Smtp-Source: ABdhPJw280wLG65bMjbT4bjeZulTXoATrvsKQqD+rUXLUaMcnBuNcoNX36QkShYeMPpbwfDY7gofKQ== X-Received: by 2002:a17:906:4486:: with SMTP id y6mr10435953ejo.466.1619590452644; Tue, 27 Apr 2021 23:14:12 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5ae8b9.dynamic.kabel-deutschland.de. [95.90.232.185]) by smtp.googlemail.com with ESMTPSA id t4sm3970322edd.6.2021.04.27.23.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 23:14:12 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Guoqing Jiang , Gioh Kim Subject: [PATCH for-next 3/4] block/rnbd-clt: Check the return value of the function rtrs_clt_query Date: Wed, 28 Apr 2021 08:13:58 +0200 Message-Id: <20210428061359.206794-4-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210428061359.206794-1-gi-oh.kim@ionos.com> References: <20210428061359.206794-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 In case none of the paths are in connected state, the function rtrs_clt_query returns an error. In such a case, error out since the values in the rtrs_attrs structure would be garbage. Fixes: f7a7a5c228d45 ("block/rnbd: client: main functionality") Signed-off-by: Md Haris Iqbal Reviewed-by: Guoqing Jiang Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/block/rnbd/rnbd-clt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 15f831159c31..f855bf1fa8d5 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -691,7 +691,11 @@ static void remap_devs(struct rnbd_clt_session *sess) return; } - rtrs_clt_query(sess->rtrs, &attrs); + err = rtrs_clt_query(sess->rtrs, &attrs); + if (err) { + pr_err("rtrs_clt_query(\"%s\"): %d\n", sess->sessname, err); + return; + } mutex_lock(&sess->lock); sess->max_io_size = attrs.max_io_size; @@ -1294,7 +1298,11 @@ find_and_get_or_create_sess(const char *sessname, err = PTR_ERR(sess->rtrs); goto wake_up_and_put; } - rtrs_clt_query(sess->rtrs, &attrs); + + err = rtrs_clt_query(sess->rtrs, &attrs); + if (err) + goto close_rtrs; + sess->max_io_size = attrs.max_io_size; sess->queue_depth = attrs.queue_depth; sess->nr_poll_queues = nr_poll_queues; From patchwork Wed Apr 28 06:13: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: 12228125 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 4975FC43461 for ; Wed, 28 Apr 2021 06:14:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DBD461418 for ; Wed, 28 Apr 2021 06:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235914AbhD1GO7 (ORCPT ); Wed, 28 Apr 2021 02:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235863AbhD1GO7 (ORCPT ); Wed, 28 Apr 2021 02:14:59 -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 BE35CC061574 for ; Tue, 27 Apr 2021 23:14:14 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id g10so4788624edb.0 for ; Tue, 27 Apr 2021 23:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RBjJPVpwnGK5cg4roDydc/Hj/MwSuec8jWll2zwOld0=; b=WuwpLWjcjsg6+IVAFmfIg8shQuA0tBg5pO4ceBTFqkE+eFjyZCANFdh0bxpksHjj2n XM71I/BsOULMF5rRSUDUwPUJHYebDN9nW2jv30ZukpK78Naa6L+2+U56XAkQM1JY9Sp2 yNF1lTwm/Y+9soRTxjmppvIKJ5wUu/1ys/RJ9GB1PnWifesAbCVHl61Js1xaO7REylkL mGy5NnmubTBjNRop3L7y5/0p8HDsh0hXAAKu7R2tABqqdZve1ik3y+p8JPqiNNzY9GAA lRY2G50X8xRqt3V6eyYcQ7MFQtROdTBPT7LJJXOfpxdjObg/q8u4M6orGcSPhe245/uX e5og== 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=RBjJPVpwnGK5cg4roDydc/Hj/MwSuec8jWll2zwOld0=; b=GkiUhs+Io84SeqssHxfZc1owpzb55BEa9Pvdq+NctS8HttLhZH2gE+w1qmhSgAdxcX +clB+EZOHOaJ3AjS7LzfXFCdMtCAspZCfobsXDckjgSu8YMnbW8BnbkCAC23nUcyxuCh JGSqQXtJEpWe8bviZPMk7BtEVmGdiZqEdAbNcBBIYoLXTUTwaNnkhXnugg9C+T/R3jxl zvC/CcVls7wgQeBK+zV2qqnWUtgcg+ZsOwMSocTfqxhcpNwodezLFYR6vtM65i1KE9RT EHmmSDWbhJlbVH9QoOti7LhCwdy6PD7frb1AbML1teKrdl9UonqHMva6fzzci4G3vd28 yo1w== X-Gm-Message-State: AOAM531yxJMFOioQ5rxDpImcC7GKfmzUkteecX9D021m5G94u20aojG9 JV76g0B/1P6Y0wRpx7C7BgEE2NsBzwOdfg== X-Google-Smtp-Source: ABdhPJw1qAnZ9A08QGoS7UZRZUSYESjYAdS/CTSn7s7Z6HvczqErb4CjEPUTlP1qlBh25b7n3aKMow== X-Received: by 2002:a05:6402:5189:: with SMTP id q9mr8793912edd.168.1619590453324; Tue, 27 Apr 2021 23:14:13 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5ae8b9.dynamic.kabel-deutschland.de. [95.90.232.185]) by smtp.googlemail.com with ESMTPSA id t4sm3970322edd.6.2021.04.27.23.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 23:14:13 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim Subject: [PATCH for-next 4/4] block/rnbd: Remove all likely and unlikely Date: Wed, 28 Apr 2021 08:13:59 +0200 Message-Id: <20210428061359.206794-5-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210428061359.206794-1-gi-oh.kim@ionos.com> References: <20210428061359.206794-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The IO performance test with fio after removing the likely and unlikely macros in all if-statement shows no performance drop. They do not help for the performance of rnbd. The fio test did random read on 32 rnbd devices and 64 processes. Test environment: - AMD Opteron(tm) Processor 6386 SE - 125G memory - kernel version: 5.4.86 - gcc version: gcc (Debian 8.3.0-6) 8.3.0 - Infiniband controller: InfiniBand: Mellanox Technologies MT26428 [ConnectX VPI PCIe 2.0 5GT/s - IB QDR / 10GigE] (rev b0) before read: IOPS=549k, BW=2146MiB/s read: IOPS=544k, BW=2125MiB/s read: IOPS=553k, BW=2158MiB/s read: IOPS=535k, BW=2089MiB/s read: IOPS=543k, BW=2122MiB/s read: IOPS=552k, BW=2154MiB/s average: IOPS=546k, BW=2132MiB/s after read: IOPS=556k, BW=2172MiB/s read: IOPS=561k, BW=2191MiB/s read: IOPS=552k, BW=2156MiB/s read: IOPS=551k, BW=2154MiB/s read: IOPS=562k, BW=2194MiB/s ----------- average: IOPS=556k, BW=2173MiB/s The IOPS and bandwidth got better slightly after removing likely/unlikely. (IOPS= +1.8% BW= +1.9%) But we cannot make sure that removing the likely/unlikely help the performance because it depends on various situations. We only make sure that removing the likely/unlikely does not drop the performance. Signed-off-by: Gioh Kim Reviewed-by: Md Haris Iqbal --- drivers/block/rnbd/rnbd-clt.c | 24 ++++++++++++------------ drivers/block/rnbd/rnbd-srv.c | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index f855bf1fa8d5..c604a402cd5c 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -241,7 +241,7 @@ static bool rnbd_rerun_if_needed(struct rnbd_clt_session *sess) cpu_q = rnbd_get_cpu_qlist(sess, nxt_cpu(cpu_q->cpu))) { if (!spin_trylock_irqsave(&cpu_q->requeue_lock, flags)) continue; - if (unlikely(!test_bit(cpu_q->cpu, sess->cpu_queues_bm))) + if (!test_bit(cpu_q->cpu, sess->cpu_queues_bm)) goto unlock; q = list_first_entry_or_null(&cpu_q->requeue_list, typeof(*q), requeue_list); @@ -320,7 +320,7 @@ static struct rtrs_permit *rnbd_get_permit(struct rnbd_clt_session *sess, struct rtrs_permit *permit; permit = rtrs_clt_get_permit(sess->rtrs, con_type, wait); - if (likely(permit)) + if (permit) /* We have a subtle rare case here, when all permits can be * consumed before busy counter increased. This is safe, * because loser will get NULL as a permit, observe 0 busy @@ -355,7 +355,7 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess, return NULL; permit = rnbd_get_permit(sess, con_type, wait); - if (unlikely(!permit)) { + if (!permit) { kfree(iu); return NULL; } @@ -1050,7 +1050,7 @@ static int rnbd_client_xfer_request(struct rnbd_clt_dev *dev, }; err = rtrs_clt_request(rq_data_dir(rq), &req_ops, rtrs, permit, &vec, 1, size, iu->sgt.sgl, sg_cnt); - if (unlikely(err)) { + if (err) { rnbd_clt_err_rl(dev, "RTRS failed to transfer IO, err: %d\n", err); return err; @@ -1081,7 +1081,7 @@ static bool rnbd_clt_dev_add_to_requeue(struct rnbd_clt_dev *dev, cpu_q = get_cpu_ptr(sess->cpu_queues); spin_lock_irqsave(&cpu_q->requeue_lock, flags); - if (likely(!test_and_set_bit_lock(0, &q->in_list))) { + if (!test_and_set_bit_lock(0, &q->in_list)) { if (WARN_ON(!list_empty(&q->requeue_list))) goto unlock; @@ -1093,7 +1093,7 @@ static bool rnbd_clt_dev_add_to_requeue(struct rnbd_clt_dev *dev, */ smp_mb__before_atomic(); } - if (likely(atomic_read(&sess->busy))) { + if (atomic_read(&sess->busy)) { list_add_tail(&q->requeue_list, &cpu_q->requeue_list); } else { /* Very unlikely, but possible: busy counter was @@ -1121,7 +1121,7 @@ static void rnbd_clt_dev_kick_mq_queue(struct rnbd_clt_dev *dev, if (delay != RNBD_DELAY_IFBUSY) blk_mq_delay_run_hw_queue(hctx, delay); - else if (unlikely(!rnbd_clt_dev_add_to_requeue(dev, q))) + else if (!rnbd_clt_dev_add_to_requeue(dev, q)) /* * If session is not busy we have to restart * the queue ourselves. @@ -1138,12 +1138,12 @@ static blk_status_t rnbd_queue_rq(struct blk_mq_hw_ctx *hctx, int err; blk_status_t ret = BLK_STS_IOERR; - if (unlikely(dev->dev_state != DEV_STATE_MAPPED)) + if (dev->dev_state != DEV_STATE_MAPPED) return BLK_STS_IOERR; iu->permit = rnbd_get_permit(dev->sess, RTRS_IO_CON, RTRS_PERMIT_NOWAIT); - if (unlikely(!iu->permit)) { + if (!iu->permit) { rnbd_clt_dev_kick_mq_queue(dev, hctx, RNBD_DELAY_IFBUSY); return BLK_STS_RESOURCE; } @@ -1165,9 +1165,9 @@ static blk_status_t rnbd_queue_rq(struct blk_mq_hw_ctx *hctx, blk_mq_start_request(rq); err = rnbd_client_xfer_request(dev, rq, iu); - if (likely(err == 0)) + if (err == 0) return BLK_STS_OK; - if (unlikely(err == -EAGAIN || err == -ENOMEM)) { + if (err == -EAGAIN || err == -ENOMEM) { rnbd_clt_dev_kick_mq_queue(dev, hctx, 10/*ms*/); ret = BLK_STS_RESOURCE; } @@ -1584,7 +1584,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, struct rnbd_clt_dev *dev; int ret; - if (unlikely(exists_devpath(pathname, sessname))) + if (exists_devpath(pathname, sessname)) return ERR_PTR(-EEXIST); sess = find_and_get_or_create_sess(sessname, paths, path_cnt, port_nr, nr_poll_queues); diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 899dd9d7c10b..aafecfe97055 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -104,7 +104,7 @@ rnbd_get_sess_dev(int dev_id, struct rnbd_srv_session *srv_sess) rcu_read_lock(); sess_dev = xa_load(&srv_sess->index_idr, dev_id); - if (likely(sess_dev)) + if (sess_dev) ret = kref_get_unless_zero(&sess_dev->kref); rcu_read_unlock();