From patchwork Mon Sep 30 23:00:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167719 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3222E13B1 for ; Mon, 30 Sep 2019 23:00:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B07E206BB for ; Mon, 30 Sep 2019 23:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfI3XA5 (ORCPT ); Mon, 30 Sep 2019 19:00:57 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:32835 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XA5 (ORCPT ); Mon, 30 Sep 2019 19:00:57 -0400 Received: by mail-pf1-f195.google.com with SMTP id q10so6475487pfl.0 for ; Mon, 30 Sep 2019 16:00:57 -0700 (PDT) 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=mSTVW81MOB0fdiWZYyq6yTKbKqq2M0RuHi0rUPr9vpE=; b=QvVFknOFWPl5llzDqy71hDunKY1UHiUzXvrFSlC2t8xo4lhGoIbFe8wUf2A/m6dJkf nCXzt6L0x8wYFmcuzsgnUG/SrnocEf9IgmYeZq/6qyZurSG5e/yCb3qYo1Zkzix17GgC 5dUUVe9wvCEchsU0HY/jc415m9E2Kiw10oxvUMPmsvYge/B+R0Nfkhk/13R16onGPtzr 9eZLevsIfW7nHmmvisqrc6OOc3DqmUaw5l6oaNtzO1iFpr1u6xE+blEtW46aNngXlF/I MygwdOhKIQ/WeOV5R6x8cwO5fxjGuORRgw9DXD3iYN3ExtTme7GcdjW9uFS3x4Zygj2Q J48w== X-Gm-Message-State: APjAAAWrfEEOIHRut52POHWolUbe452GagqM/Phpz3el0PNXkNdai0yD mED8AqaYiAUubcBfN9vKFAA= X-Google-Smtp-Source: APXvYqyPOtkRj+lCOvscYqjp8Ss55MYqBggR/geriNUbUz8W6uU5syuiCRU8uTd4fvlKXwm3rleURQ== X-Received: by 2002:a62:1a4d:: with SMTP id a74mr268625pfa.179.1569884456706; Mon, 30 Sep 2019 16:00:56 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:00:55 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Max Gurtovoy , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 1/8] block: Fix three kernel-doc warnings Date: Mon, 30 Sep 2019 16:00:40 -0700 Message-Id: <20190930230047.44113-2-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Fix the following kernel-doc warnings: block/t10-pi.c:242: warning: Function parameter or member 'rq' not described in 't10_pi_type3_prepare' block/t10-pi.c:249: warning: Function parameter or member 'rq' not described in 't10_pi_type3_complete' block/t10-pi.c:249: warning: Function parameter or member 'nr_bytes' not described in 't10_pi_type3_complete' Cc: Max Gurtovoy Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Fixes: 54d4e6ab91eb ("block: centralize PI remapping logic to the block layer") Signed-off-by: Bart Van Assche --- block/t10-pi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/block/t10-pi.c b/block/t10-pi.c index 9803c7e0376e..f4907d941f03 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -235,16 +235,12 @@ static blk_status_t t10_pi_type3_verify_ip(struct blk_integrity_iter *iter) return t10_pi_verify(iter, t10_pi_ip_fn, T10_PI_TYPE3_PROTECTION); } -/** - * Type 3 does not have a reference tag so no remapping is required. - */ +/* Type 3 does not have a reference tag so no remapping is required. */ static void t10_pi_type3_prepare(struct request *rq) { } -/** - * Type 3 does not have a reference tag so no remapping is required. - */ +/* Type 3 does not have a reference tag so no remapping is required. */ static void t10_pi_type3_complete(struct request *rq, unsigned int nr_bytes) { } From patchwork Mon Sep 30 23:00:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167721 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14D0013B1 for ; Mon, 30 Sep 2019 23:01:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8C17206BB for ; Mon, 30 Sep 2019 23:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727220AbfI3XA7 (ORCPT ); Mon, 30 Sep 2019 19:00:59 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37526 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XA7 (ORCPT ); Mon, 30 Sep 2019 19:00:59 -0400 Received: by mail-pf1-f196.google.com with SMTP id y5so6466005pfo.4 for ; Mon, 30 Sep 2019 16:00:58 -0700 (PDT) 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=344eJ05CFQcBsgTWyIrRGJ8FcbpIVlOeQYSaWb8S7Fs=; b=bKylK8fghroJWf/YC5OPpbdT1wzKD4Vhr4V4MA5QtvH7wTdOmlZX2juz7ZqTiZZREQ FZotCs0RMvzsy0YDlzpJ6R+XwZjEeBCRvuZsaSoTsi2Q8y0QsEs4vS0WgVt8uRYFQjVu SEcWTJYr0PLSVFCfBOFd5eavIK3A+9+TDnFAEU4GJ84fitGymXs+1PBch6xn8PEyYT9j cYHQ6X1LWRtEfPJV/GywDWSGMN5G0XFHqag7DfZL49Ab7FgFPCULNFh6OLtWULc0rpk8 3OmK9b2lfaX0qaDyT39wc+N0XVlRHlJib7Kozqbk3N7+CRYfUbCBZuUXh5NZLkAW5aYP N/zg== X-Gm-Message-State: APjAAAUungsZxuxHkQ/wTfq27gshNmKzUEsL3Hxp1sxkv5n795F9Fkoj fS7RPC+MQ6SKuuLM5+OC83s= X-Google-Smtp-Source: APXvYqxiLyT2ggXAqcfujMoHjPmqzifRaYLNnCY4UvOXbFr2AooHE1nYPXTTz/lYz280x627E9fGKg== X-Received: by 2002:a17:90a:1b48:: with SMTP id q66mr1825898pjq.79.1569884458055; Mon, 30 Sep 2019 16:00:58 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:00:57 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 2/8] block: Fix writeback throttling W=1 compiler warnings Date: Mon, 30 Sep 2019 16:00:41 -0700 Message-Id: <20190930230047.44113-3-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Fix the following compiler warnings: In file included from ./include/linux/bitmap.h:9, from ./include/linux/cpumask.h:12, from ./arch/x86/include/asm/cpumask.h:5, from ./arch/x86/include/asm/msr.h:11, from ./arch/x86/include/asm/processor.h:21, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:38, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from ./include/linux/mmzone.h:8, from ./include/linux/gfp.h:6, from ./include/linux/mm.h:10, from ./include/linux/bvec.h:13, from ./include/linux/blk_types.h:10, from block/blk-wbt.c:23: In function 'strncpy', inlined from 'perf_trace_wbt_stat' at ./include/trace/events/wbt.h:15:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'perf_trace_wbt_lat' at ./include/trace/events/wbt.h:58:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'perf_trace_wbt_step' at ./include/trace/events/wbt.h:87:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'perf_trace_wbt_timer' at ./include/trace/events/wbt.h:126:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'trace_event_raw_event_wbt_stat' at ./include/trace/events/wbt.h:15:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'trace_event_raw_event_wbt_lat' at ./include/trace/events/wbt.h:58:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'trace_event_raw_event_wbt_timer' at ./include/trace/events/wbt.h:126:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'trace_event_raw_event_wbt_step' at ./include/trace/events/wbt.h:87:1: ./include/linux/string.h:260:9: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Fixes: e34cbd307477 ("blk-wbt: add general throttling mechanism"; v4.10). Signed-off-by: Bart Van Assche --- include/trace/events/wbt.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h index b048694070e2..37342a13c9cb 100644 --- a/include/trace/events/wbt.h +++ b/include/trace/events/wbt.h @@ -33,7 +33,8 @@ TRACE_EVENT(wbt_stat, ), TP_fast_assign( - strncpy(__entry->name, dev_name(bdi->dev), 32); + strlcpy(__entry->name, dev_name(bdi->dev), + ARRAY_SIZE(__entry->name)); __entry->rmean = stat[0].mean; __entry->rmin = stat[0].min; __entry->rmax = stat[0].max; @@ -67,7 +68,8 @@ TRACE_EVENT(wbt_lat, ), TP_fast_assign( - strncpy(__entry->name, dev_name(bdi->dev), 32); + strlcpy(__entry->name, dev_name(bdi->dev), + ARRAY_SIZE(__entry->name)); __entry->lat = div_u64(lat, 1000); ), @@ -103,7 +105,8 @@ TRACE_EVENT(wbt_step, ), TP_fast_assign( - strncpy(__entry->name, dev_name(bdi->dev), 32); + strlcpy(__entry->name, dev_name(bdi->dev), + ARRAY_SIZE(__entry->name)); __entry->msg = msg; __entry->step = step; __entry->window = div_u64(window, 1000); @@ -138,7 +141,8 @@ TRACE_EVENT(wbt_timer, ), TP_fast_assign( - strncpy(__entry->name, dev_name(bdi->dev), 32); + strlcpy(__entry->name, dev_name(bdi->dev), + ARRAY_SIZE(__entry->name)); __entry->status = status; __entry->step = step; __entry->inflight = inflight; From patchwork Mon Sep 30 23:00:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3731816C1 for ; Mon, 30 Sep 2019 23:01:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A9EA2081B for ; Mon, 30 Sep 2019 23:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbfI3XBA (ORCPT ); Mon, 30 Sep 2019 19:01:00 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32839 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XBA (ORCPT ); Mon, 30 Sep 2019 19:01:00 -0400 Received: by mail-pf1-f194.google.com with SMTP id q10so6475564pfl.0 for ; Mon, 30 Sep 2019 16:00:59 -0700 (PDT) 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=gpSLYdxnzPeYthWjSUQJp6CR8C6RA6Ja2olEfHMV4mY=; b=VGdjMsA9GeAeCr/RR0/lScAfvdbebg5haGYujteQajomfQ4ck9mgjGsGTWWU77YeQz VWdxSGni5UlKnTn+KcwCdd12YxuVerzoqbpK6nX6tfTDzuzWBRn4w/z5M8fqxKnhZB3X tSuLQA4zr9gGsS5YxOB3OOVrEFby0hN+1p7YdQslxLfbNrTaaa4SUj5HqUY4cjTmuais SiJPKrebMEXb4lyv88cvwhduVn0506EjlN0dvsUB5gotyvOGZfcRo1bED8KRQTaZSZXB SLWveSCbLvjzwH6iif7xYJUGIhd5FbGsyGD9NbXFZFPTI7oTAXmdpJihzpTT1f9fMbWK YS+A== X-Gm-Message-State: APjAAAWu85f0WG0lViGq/B+iopNrMpMC1VMQMuQVLguXVvxhAIr83Dyq CC7fxfKv0pgw4gL0x3fWqnI= X-Google-Smtp-Source: APXvYqyArtbqWoPb3Edyq3NEy42szDRtVUPcSsiNmLG+Xrog6jLVgkl+SbeST6GiNQr0rzuu2/9bPA== X-Received: by 2002:a17:90a:fe04:: with SMTP id ck4mr1917348pjb.74.1569884459379; Mon, 30 Sep 2019 16:00:59 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:00:58 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 3/8] block: Remove request_queue.nr_queues Date: Mon, 30 Sep 2019 16:00:42 -0700 Message-Id: <20190930230047.44113-4-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Commit 897bb0c7f1ea ("blk-mq: Use proper cpumask iterator"; v4.6) removed the last use of request_queue.nr_queues from outside blk_mq_init_allocate_queue(). Remove this member variable to make struct request_queue smaller. This patch does not change any functionality. Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- block/blk-mq.c | 6 +++--- include/linux/blkdev.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 29275f5a996f..25b8a9b44a31 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2867,9 +2867,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, /* init q->mq_kobj and sw queues' kobjects */ blk_mq_sysfs_init(q); - q->nr_queues = nr_hw_queues(set); - q->queue_hw_ctx = kcalloc_node(q->nr_queues, sizeof(*(q->queue_hw_ctx)), - GFP_KERNEL, set->numa_node); + q->queue_hw_ctx = kcalloc_node(nr_hw_queues(set), + sizeof(*(q->queue_hw_ctx)), GFP_KERNEL, + set->numa_node); if (!q->queue_hw_ctx) goto err_sys_init; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 6032bb740cf4..fe32e07c5e3c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -411,7 +411,6 @@ struct request_queue { /* sw queues */ struct blk_mq_ctx __percpu *queue_ctx; - unsigned int nr_queues; unsigned int queue_depth; From patchwork Mon Sep 30 23:00:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167725 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6836113B1 for ; Mon, 30 Sep 2019 23:01:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 510E32081B for ; Mon, 30 Sep 2019 23:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfI3XBB (ORCPT ); Mon, 30 Sep 2019 19:01:01 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37995 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XBB (ORCPT ); Mon, 30 Sep 2019 19:01:01 -0400 Received: by mail-pg1-f193.google.com with SMTP id x10so8217880pgi.5 for ; Mon, 30 Sep 2019 16:01:01 -0700 (PDT) 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=cpnD1+tX5VRBCS1iyxcyXpZHn9kRH7EGBCyKlQavOT0=; b=W4O8DQkWGTMckilPuSycEsp5lBPMC6KfeAEQAXiCKS+n8gSYAXTc/2JWC5t9WQEqoO iCj2a2qF1DkmBAp4tnfSIr7xxAlTn/PAKToC1CZVLNVd8kVce1IZtL2IFCWKV81gVK19 xWx8GAo5dSk0bce0QzAPdLWcIpOCy68UZ80hRLyRetgWEWg6v9pJIq6f4NpRjpmvU2g1 KMJcncKctjzm7Ja0jszJTwAYXuvRcOU5gkSO4HFUMnb0yB5VUya/HMK3ZdETNAet32gX ohyoCJFpr4UB7dW0L05bZBHl384r0EeJNPI2jfdzYp8RZHIkBs5Pz8f1W0lcDxZx+ma7 8tjA== X-Gm-Message-State: APjAAAXgXHhXKwTxfGIEARB+P83CZqWsGDG3ZyZiieq1jRq+/Rm70Gis oxqWLpI7/SvhwzvzmRGOZtI= X-Google-Smtp-Source: APXvYqyUObdwodPOgTiaOS2wxGb8ISr7TmfEqiJujp1+nqmyZgjf3DPoTAPW7yCc1PfagHDsE3kdrA== X-Received: by 2002:a62:e918:: with SMTP id j24mr23595850pfh.219.1569884460698; Mon, 30 Sep 2019 16:01:00 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:00:59 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 4/8] block: Remove "dying" checks from sysfs callbacks Date: Mon, 30 Sep 2019 16:00:43 -0700 Message-Id: <20190930230047.44113-5-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Block drivers must call del_gendisk() before blk_cleanup_queue(). del_gendisk() calls kobject_del() and kobject_del() waits until any ongoing sysfs callback functions have finished. In other words, the sysfs callback functions won't be called for a queue in the dying state. Hence remove the "dying" checks from the sysfs callback functions. Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- block/blk-core.c | 2 ++ block/blk-mq-sysfs.c | 16 ++++------------ block/blk-sysfs.c | 8 -------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d5e668ec751b..8b51d9ec8ae3 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -336,6 +336,8 @@ EXPORT_SYMBOL_GPL(blk_set_queue_dying); */ void blk_cleanup_queue(struct request_queue *q) { + WARN_ON_ONCE(blk_queue_registered(q)); + /* mark @q DYING, no new request or merges will be allowed afterwards */ mutex_lock(&q->sysfs_lock); blk_set_queue_dying(q); diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c index a0d3ce30fa08..81a273b43329 100644 --- a/block/blk-mq-sysfs.c +++ b/block/blk-mq-sysfs.c @@ -74,10 +74,8 @@ static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr, if (!entry->show) return -EIO; - res = -ENOENT; mutex_lock(&q->sysfs_lock); - if (!blk_queue_dying(q)) - res = entry->show(ctx, page); + res = entry->show(ctx, page); mutex_unlock(&q->sysfs_lock); return res; } @@ -97,10 +95,8 @@ static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr, if (!entry->store) return -EIO; - res = -ENOENT; mutex_lock(&q->sysfs_lock); - if (!blk_queue_dying(q)) - res = entry->store(ctx, page, length); + res = entry->store(ctx, page, length); mutex_unlock(&q->sysfs_lock); return res; } @@ -120,10 +116,8 @@ static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj, if (!entry->show) return -EIO; - res = -ENOENT; mutex_lock(&q->sysfs_lock); - if (!blk_queue_dying(q)) - res = entry->show(hctx, page); + res = entry->show(hctx, page); mutex_unlock(&q->sysfs_lock); return res; } @@ -144,10 +138,8 @@ static ssize_t blk_mq_hw_sysfs_store(struct kobject *kobj, if (!entry->store) return -EIO; - res = -ENOENT; mutex_lock(&q->sysfs_lock); - if (!blk_queue_dying(q)) - res = entry->store(hctx, page, length); + res = entry->store(hctx, page, length); mutex_unlock(&q->sysfs_lock); return res; } diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index b82736c781c5..80df16be9f52 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -802,10 +802,6 @@ queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page) if (!entry->show) return -EIO; mutex_lock(&q->sysfs_lock); - if (blk_queue_dying(q)) { - mutex_unlock(&q->sysfs_lock); - return -ENOENT; - } res = entry->show(q, page); mutex_unlock(&q->sysfs_lock); return res; @@ -824,10 +820,6 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr, q = container_of(kobj, struct request_queue, kobj); mutex_lock(&q->sysfs_lock); - if (blk_queue_dying(q)) { - mutex_unlock(&q->sysfs_lock); - return -ENOENT; - } res = entry->store(q, page, length); mutex_unlock(&q->sysfs_lock); return res; From patchwork Mon Sep 30 23:00:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45A2113B1 for ; Mon, 30 Sep 2019 23:01:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EB932081B for ; Mon, 30 Sep 2019 23:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727757AbfI3XBC (ORCPT ); Mon, 30 Sep 2019 19:01:02 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40432 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XBC (ORCPT ); Mon, 30 Sep 2019 19:01:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id x127so6457913pfb.7 for ; Mon, 30 Sep 2019 16:01:02 -0700 (PDT) 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=gONO+eawvhG9dGAqmnmHeqA2HilJJZze++x5pSgsNdY=; b=KqtS5g6YvPYpLT+1AmvQ/NjA0FBJz05lhO7p2zBUaUXh01AQfwT3vvVxIGY6aqKOIl iP/yaSgDQXgL66CivihY6Tb505gg0Hncjg1VLiEM/kD5myDF0ETAzOtjGLQHD4HR63Gk l/AKyZSMrVTCqaTL0fDSJ/dG5vRD5LWCRfQFnRVZsLvlFCnLmVu0uw3Ht7tR4UgQMIvW clPKJcfc/sNlzzkyYXpR2qH3W8EdBB9ajD8doz3nNSiQo8ICHMxfiMtxO1uhYsPotq9Z 1I+sGlAwwsbpT5DmdCvm8kYvEBhHV9Ko5rJdSRSkhM4Yit/Fn1X+o234gi3j9dnVHsP2 nxxQ== X-Gm-Message-State: APjAAAUKvUSmrV89DdufIFruzhiCn+k/RCKiHB12KWRDuc0tBg9rp2a5 alW1CYXq3BsmXH44S+fUo/M= X-Google-Smtp-Source: APXvYqxfEbgUGwH5EoQjEMJeSHoXQK6rsDVyoD4duNzu6+nwJrfshaTm6eeoTiNZCCZsUHbrfUq4oQ== X-Received: by 2002:a62:8702:: with SMTP id i2mr24197492pfe.187.1569884461856; Mon, 30 Sep 2019 16:01:01 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:01:01 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 5/8] block: Reduce sysfs_lock locking inside blk_cleanup_queue() Date: Mon, 30 Sep 2019 16:00:44 -0700 Message-Id: <20190930230047.44113-6-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Since blk_cleanup_queue() is called after blk_unregister_queue() and since that last function removes all sysfs attributes, serializing any code in blk_cleanup_queue() against sysfs callback methods nor against I/O scheduler changes is necessary. Hence remove the syfs_lock locking calls from the start of blk_cleanup_queue(). Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- block/blk-core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 8b51d9ec8ae3..ae506ac2dd48 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -339,13 +339,11 @@ void blk_cleanup_queue(struct request_queue *q) WARN_ON_ONCE(blk_queue_registered(q)); /* mark @q DYING, no new request or merges will be allowed afterwards */ - mutex_lock(&q->sysfs_lock); blk_set_queue_dying(q); blk_queue_flag_set(QUEUE_FLAG_NOMERGES, q); blk_queue_flag_set(QUEUE_FLAG_NOXMERGES, q); blk_queue_flag_set(QUEUE_FLAG_DYING, q); - mutex_unlock(&q->sysfs_lock); /* * Drain all requests queued before DYING marking. Set DEAD flag to From patchwork Mon Sep 30 23:00:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C438D13B1 for ; Mon, 30 Sep 2019 23:01:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD433206BB for ; Mon, 30 Sep 2019 23:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbfI3XBE (ORCPT ); Mon, 30 Sep 2019 19:01:04 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41084 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XBE (ORCPT ); Mon, 30 Sep 2019 19:01:04 -0400 Received: by mail-pg1-f193.google.com with SMTP id s1so8208032pgv.8 for ; Mon, 30 Sep 2019 16:01:03 -0700 (PDT) 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=gmFkOESs1LB3Zda4bDleeNTmC8QYNSpewjw/YIoHv9Y=; b=cKG2rmC/IdrT3FX7XiK872tyADCutYr4cEh9+XN5NPEDDTYtQKSnKqKCQvKvcJyBm8 w4sA3CJ40cxOQkfAK/dQEkNJmQN3ERHqvwgfM6AAfJNRkMppAgnzN46eFRd2yVwX0wDG jf7NXoe2q4dozAA2LcXq9qWcwhBHhyGduPEBLyYTnOTEMvQB3aiXq88BrOEHYKEvkzIx u6sUon2G+GMUcodq4F07VVz0t5Xgs7yHj7evpGVPOFbbWcSkIes+5OAWIBQupVAvRkwc PXqzCEW9TWuUBsh3jqYegRCg7XWmdBDPLo9/s58ftTG/TeS77XRFG0BVYRW4du6tw1i4 2epg== X-Gm-Message-State: APjAAAXfbJ+XKM+SxOK00o9lP9dIZrsGgz7CGfbaM8Us6nngZCWETOjo s4ngH1UmVfFRyy2TwI06K8g= X-Google-Smtp-Source: APXvYqzeW9yK1lmCI680SbQePVNZVFed55CSJ0hgAY4O152Bmp1wDELG2LE3/QYVOPNGix6PTFRz4w== X-Received: by 2002:a62:1888:: with SMTP id 130mr24423832pfy.72.1569884463254; Mon, 30 Sep 2019 16:01:03 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:01:02 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 6/8] block: Document all members of blk_mq_tag_set and bkl_mq_queue_map Date: Mon, 30 Sep 2019 16:00:45 -0700 Message-Id: <20190930230047.44113-7-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The meaning of several member variables of these two data structures is nontrivial. Hence document all member variables using the kernel-doc syntax. Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- include/linux/blk-mq.h | 54 +++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 0bf056de5cc3..a96b5cc957ab 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -76,6 +76,16 @@ struct blk_mq_hw_ctx { struct srcu_struct srcu[0]; }; +/** + * struct blk_mq_queue_map - ctx -> hctx mapping + * @mq_map: CPU ID to hardware queue index map. This is an array + * with nr_cpu_ids elements. Each element has a value in the range + * [@queue_offset, @queue_offset + @nr_queues). + * @nr_queues: Number of hardware queues to map CPU IDs onto. + * @queue_offset: First hardware queue to map onto. Used by the PCIe NVMe + * driver to map each hardware queue type (enum hctx_type) onto a distinct + * set of hardware queues. + */ struct blk_mq_queue_map { unsigned int *mq_map; unsigned int nr_queues; @@ -90,23 +100,45 @@ enum hctx_type { HCTX_MAX_TYPES, }; +/** + * struct blk_mq_tag_set - tag set that can be shared between request queues + * @map: One or more ctx -> hctx mappings. One map exists for each + * hardware queue type (enum hctx_type) that the driver wishes + * to support. There are no restrictions on maps being of the + * same size, and it's perfectly legal to share maps between + * types. + * @nr_maps: Number of elements in the @map array. A number in the range + * [1, HCTX_MAX_TYPES]. + * @ops: Pointers to functions that implement block driver behavior. + * @nr_hw_queues: Number of hardware queues supported by the block driver that + * owns this data structure. + * @queue_depth: Number of tags per hardware queue, reserved tags included. + * @reserved_tags: Number of tags to set aside for BLK_MQ_REQ_RESERVED tag + * allocations. + * @cmd_size: Number of additional bytes to allocate per request. The block + * driver owns these additional bytes. + * @numa_node: NUMA node the storage adapter has been connected to. + * @timeout: Request processing timeout in jiffies. + * @flags: Zero or more BLK_MQ_F_* flags. + * @driver_data: Pointer to data owned by the block driver that created this + * tag set. + * @tags: Tag sets. One tag set per hardware queue. Has @nr_hw_queues + * elements. + * @tag_list_lock: Serializes tag_list accesses. + * @tag_list: List of the request queues that use this tag set. See also + * request_queue.tag_set_list. + */ struct blk_mq_tag_set { - /* - * map[] holds ctx -> hctx mappings, one map exists for each type - * that the driver wishes to support. There are no restrictions - * on maps being of the same size, and it's perfectly legal to - * share maps between types. - */ struct blk_mq_queue_map map[HCTX_MAX_TYPES]; - unsigned int nr_maps; /* nr entries in map[] */ + unsigned int nr_maps; const struct blk_mq_ops *ops; - unsigned int nr_hw_queues; /* nr hw queues across maps */ - unsigned int queue_depth; /* max hw supported */ + unsigned int nr_hw_queues; + unsigned int queue_depth; unsigned int reserved_tags; - unsigned int cmd_size; /* per-request extra data */ + unsigned int cmd_size; int numa_node; unsigned int timeout; - unsigned int flags; /* BLK_MQ_F_* */ + unsigned int flags; void *driver_data; struct blk_mq_tags **tags; From patchwork Mon Sep 30 23:00:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3186816C1 for ; Mon, 30 Sep 2019 23:01:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 192C12053B for ; Mon, 30 Sep 2019 23:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728073AbfI3XBF (ORCPT ); Mon, 30 Sep 2019 19:01:05 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44771 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XBF (ORCPT ); Mon, 30 Sep 2019 19:01:05 -0400 Received: by mail-pg1-f193.google.com with SMTP id i14so8189098pgt.11 for ; Mon, 30 Sep 2019 16:01:05 -0700 (PDT) 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=zhEbudMbPtcbeSY/tmaL3JYTvyPttnYPu5OVMgOG1L0=; b=JDeO1XLneZ+q7NNtqfHyNwojA3xG6rrhNgy3s8cSCnF30XoHBOd7IthM1QhWFVv6iJ 1zx3nGA+NvMeaZ6QwqgIn/GGlul11nac6ZFBYCOQ5wYY9V56kIsOm6SugLXcGsYg4woE 5VY+k7xQp6Ssijc7TLSnVpgNbzQUGffBM0UlROlSdOHbjVZAjyDrAWm3G8iS8EvEeKot V7uVa0eiuPzIPQ5Hwr6evABtSUKGqNo1dOV7k2ROS91+/E+nFo0nE+kcBjXIYJHnNHOj aQpKbXUarft8O6F+z+1chdcaxUGeGttcH2LvHZXSwuG61rGx6816uX9YPQlmblvSxuHk kO9Q== X-Gm-Message-State: APjAAAVugbHPVSEbkAJyJcFSbl4uP6cI+NxmLTtXnzeO/whTNt3NGCVZ YOu8/6b3tvn1mJpAKKOkCUIIG9UD X-Google-Smtp-Source: APXvYqzoSrniWqooNuHouuGpJ+Nd/F0NWSshGaTK3EMvZLM961cdnRWM3JH4ngSmzZKitE+jL14krg== X-Received: by 2002:aa7:998d:: with SMTP id k13mr24369807pfh.134.1569884464672; Mon, 30 Sep 2019 16:01:04 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:01:03 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 7/8] null_blk: Improve nullb_device_##NAME##_store() readability Date: Mon, 30 Sep 2019 16:00:46 -0700 Message-Id: <20190930230047.44113-8-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce a local variable to make the code easier to read. This patch does not change any functionality but makes the next patch in this series easier to read. Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- drivers/block/null_blk_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 0e7da5015ccd..f5747cfd806f 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -274,10 +274,11 @@ static ssize_t \ nullb_device_##NAME##_store(struct config_item *item, const char *page, \ size_t count) \ { \ - if (test_bit(NULLB_DEV_FL_CONFIGURED, &to_nullb_device(item)->flags)) \ + struct nullb_device *dev = to_nullb_device(item); \ + \ + if (test_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags)) \ return -EBUSY; \ - return nullb_device_##TYPE##_attr_store( \ - &to_nullb_device(item)->NAME, page, count); \ + return nullb_device_##TYPE##_attr_store(&dev->NAME, page, count); \ } \ CONFIGFS_ATTR(nullb_device_, NAME); From patchwork Mon Sep 30 23:00:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 11167733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5A1016C1 for ; Mon, 30 Sep 2019 23:01:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEBBA206BB for ; Mon, 30 Sep 2019 23:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729560AbfI3XBH (ORCPT ); Mon, 30 Sep 2019 19:01:07 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41273 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfI3XBH (ORCPT ); Mon, 30 Sep 2019 19:01:07 -0400 Received: by mail-pl1-f196.google.com with SMTP id t10so4481193plr.8 for ; Mon, 30 Sep 2019 16:01:06 -0700 (PDT) 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=zWtYqS7f+YXot9sryt5o/uWT1RslvHBfHCBGifGO1eM=; b=ZBM5KJmX2h/LkSzWlB3uXZZ1DAoei9qysI4fPyp9LklRHeStD3+6YmwpklAXBfO8IS zl7mo46orDOBmyV0j4nm9D5S4wi70SQXZeOqLpFrWeT36rxNK3op0ayagbEwLvY83Xfm Wbys9E6AxkMAOs4L4TnL5styaay/+Db8imfP0b6D0He7ax0lU4p7E8+oX0v8GN+2oIIt f6XQKssylnmhGXM2ct3cta7VN+embvG3TPIydb4kzynbS+IrS/y68lSxN+qPpN0VKz8h IssECmEg7tgnQxAEjkULSatwjXjmrkJB2YWryUJOd3ix+AlW/OPVsvUT4kyO2WYL1KC3 DK+A== X-Gm-Message-State: APjAAAX5T0BSqBY4E/SNEbW9qLzPVtFdhx7CbpUUEjMHu+dHlm+amZrW Nj2b9Db/V2CQdNV21rDyvpyjSWW4 X-Google-Smtp-Source: APXvYqyqNnRU+mG/wjgtZIucT90sSJRoTznTaPp0ZVumYr4n//u32tzNO/F4e/2q/LW+jujhAx32xQ== X-Received: by 2002:a17:902:904b:: with SMTP id w11mr22655407plz.182.1569884466069; Mon, 30 Sep 2019 16:01:06 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:202:4308:52a3:24b6:2c60]) by smtp.gmail.com with ESMTPSA id 74sm15071747pfy.78.2019.09.30.16.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 16:01:05 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Ming Lei , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 8/8] null_blk: Enable modifying 'submit_queues' after an instance has been configured Date: Mon, 30 Sep 2019 16:00:47 -0700 Message-Id: <20190930230047.44113-9-bvanassche@acm.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190930230047.44113-1-bvanassche@acm.org> References: <20190930230047.44113-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch makes it possible to test blk_mq_update_nr_hw_queues() from inside a VM. Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- drivers/block/null_blk_main.c | 75 +++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index f5747cfd806f..f5e0dffb4624 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -227,7 +227,7 @@ static ssize_t nullb_device_uint_attr_store(unsigned int *val, int result; result = kstrtouint(page, 0, &tmp); - if (result) + if (result < 0) return result; *val = tmp; @@ -241,7 +241,7 @@ static ssize_t nullb_device_ulong_attr_store(unsigned long *val, unsigned long tmp; result = kstrtoul(page, 0, &tmp); - if (result) + if (result < 0) return result; *val = tmp; @@ -255,7 +255,7 @@ static ssize_t nullb_device_bool_attr_store(bool *val, const char *page, int result; result = kstrtobool(page, &tmp); - if (result) + if (result < 0) return result; *val = tmp; @@ -263,7 +263,7 @@ static ssize_t nullb_device_bool_attr_store(bool *val, const char *page, } /* The following macro should only be used with TYPE = {uint, ulong, bool}. */ -#define NULLB_DEVICE_ATTR(NAME, TYPE) \ +#define NULLB_DEVICE_ATTR(NAME, TYPE, APPLY) \ static ssize_t \ nullb_device_##NAME##_show(struct config_item *item, char *page) \ { \ @@ -274,32 +274,57 @@ static ssize_t \ nullb_device_##NAME##_store(struct config_item *item, const char *page, \ size_t count) \ { \ + int (*apply_fn)(struct nullb_device *dev, TYPE new_value) = APPLY; \ struct nullb_device *dev = to_nullb_device(item); \ + TYPE new_value; \ + int ret; \ \ - if (test_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags)) \ - return -EBUSY; \ - return nullb_device_##TYPE##_attr_store(&dev->NAME, page, count); \ + ret = nullb_device_##TYPE##_attr_store(&new_value, page, count); \ + if (ret < 0) \ + return ret; \ + if (apply_fn) \ + ret = apply_fn(dev, new_value); \ + else if (test_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags)) \ + ret = -EBUSY; \ + if (ret < 0) \ + return ret; \ + dev->NAME = new_value; \ + return count; \ } \ CONFIGFS_ATTR(nullb_device_, NAME); -NULLB_DEVICE_ATTR(size, ulong); -NULLB_DEVICE_ATTR(completion_nsec, ulong); -NULLB_DEVICE_ATTR(submit_queues, uint); -NULLB_DEVICE_ATTR(home_node, uint); -NULLB_DEVICE_ATTR(queue_mode, uint); -NULLB_DEVICE_ATTR(blocksize, uint); -NULLB_DEVICE_ATTR(irqmode, uint); -NULLB_DEVICE_ATTR(hw_queue_depth, uint); -NULLB_DEVICE_ATTR(index, uint); -NULLB_DEVICE_ATTR(blocking, bool); -NULLB_DEVICE_ATTR(use_per_node_hctx, bool); -NULLB_DEVICE_ATTR(memory_backed, bool); -NULLB_DEVICE_ATTR(discard, bool); -NULLB_DEVICE_ATTR(mbps, uint); -NULLB_DEVICE_ATTR(cache_size, ulong); -NULLB_DEVICE_ATTR(zoned, bool); -NULLB_DEVICE_ATTR(zone_size, ulong); -NULLB_DEVICE_ATTR(zone_nr_conv, uint); +static int nullb_apply_submit_queues(struct nullb_device *dev, + unsigned int submit_queues) +{ + struct nullb *nullb = dev->nullb; + struct blk_mq_tag_set *set; + + if (!nullb) + return 0; + + set = nullb->tag_set; + blk_mq_update_nr_hw_queues(set, submit_queues); + return set->nr_hw_queues == submit_queues ? 0 : -ENOMEM; +} + +NULLB_DEVICE_ATTR(size, ulong, NULL); +NULLB_DEVICE_ATTR(completion_nsec, ulong, NULL); +NULLB_DEVICE_ATTR(submit_queues, uint, nullb_apply_submit_queues); +NULLB_DEVICE_ATTR(home_node, uint, NULL); +NULLB_DEVICE_ATTR(queue_mode, uint, NULL); +NULLB_DEVICE_ATTR(blocksize, uint, NULL); +NULLB_DEVICE_ATTR(irqmode, uint, NULL); +NULLB_DEVICE_ATTR(hw_queue_depth, uint, NULL); +NULLB_DEVICE_ATTR(index, uint, NULL); +NULLB_DEVICE_ATTR(blocking, bool, NULL); +NULLB_DEVICE_ATTR(use_per_node_hctx, bool, NULL); +NULLB_DEVICE_ATTR(memory_backed, bool, NULL); +NULLB_DEVICE_ATTR(discard, bool, NULL); +NULLB_DEVICE_ATTR(mbps, uint, NULL); +NULLB_DEVICE_ATTR(cache_size, ulong, NULL); +NULLB_DEVICE_ATTR(zoned, bool, NULL); +NULLB_DEVICE_ATTR(zone_size, ulong, NULL); +NULLB_DEVICE_ATTR(zone_nr_conv, uint, NULL); static ssize_t nullb_device_power_show(struct config_item *item, char *page) {