From patchwork Mon Jun 1 12:37:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 11581971 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 70C7F13B6 for ; Mon, 1 Jun 2020 12:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52993207DF for ; Mon, 1 Jun 2020 12:37:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="diASRVyf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgFAMhP (ORCPT ); Mon, 1 Jun 2020 08:37:15 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:34160 "EHLO forwardcorp1o.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgFAMhO (ORCPT ); Mon, 1 Jun 2020 08:37:14 -0400 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 63A412E146A; Mon, 1 Jun 2020 15:37:11 +0300 (MSK) Received: from myt4-18a966dbd9be.qloud-c.yandex.net (myt4-18a966dbd9be.qloud-c.yandex.net [2a02:6b8:c00:12ad:0:640:18a9:66db]) by mxbackcorp2j.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id 2BvFuUgSOx-b9fuaNjU; Mon, 01 Jun 2020 15:37:11 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1591015031; bh=TQETKRhtCiB37qEhqMf6OVjO3wUc34huMloLIRNEzig=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=diASRVyfaLvmacOpxcs2ovMQxQZUkZLgWuhkDOxnAR8SThK5rf4OLsGKSyggA/4Vf nSPGDwHLrZMXlH8HF67BO+B26G2Cs66akUZAEpTRsA7YbQfcneJDl5IAIYdPP2KZ9n iRtrHGY87HhZEtbgBwx7Xzcr8UpADkmvQoPQJFMY= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b080:6420::1:8]) by myt4-18a966dbd9be.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 1wSpJbGMQA-b9Wux0gM; Mon, 01 Jun 2020 15:37:09 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Subject: [PATCH RFC 1/3] block: add flag 'nowait_requests' into queue limits From: Konstantin Khlebnikov To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, Jens Axboe Cc: Christoph Hellwig Date: Mon, 01 Jun 2020 15:37:09 +0300 Message-ID: <159101502963.180989.6228080995222059011.stgit@buzz> In-Reply-To: <159101473169.180989.12175693728191972447.stgit@buzz> References: <159101473169.180989.12175693728191972447.stgit@buzz> User-Agent: StGit/0.22-39-gd257 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add flag for marking bio-based queues which support REQ_NOWAIT. Set for all request based (mq) devices. Stacking device should set it after blk_set_stacking_limits() if method make_request() itself doesn't delay requests or handles REQ_NOWAIT. Signed-off-by: Konstantin Khlebnikov --- block/blk-core.c | 4 ++-- block/blk-mq.c | 3 +++ block/blk-settings.c | 3 +++ include/linux/blkdev.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index c4b015004796..9139a316e6d4 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -892,9 +892,9 @@ generic_make_request_checks(struct bio *bio) /* * For a REQ_NOWAIT based request, return -EOPNOTSUPP - * if queue is not a request based queue. + * if queue does not support this flag. */ - if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q)) + if ((bio->bi_opf & REQ_NOWAIT) && !q->limits.nowait_requests) goto not_supported; if (should_fail_bio(bio)) diff --git a/block/blk-mq.c b/block/blk-mq.c index a7785df2c944..0c3daa0cda87 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2952,6 +2952,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, */ q->poll_nsec = BLK_MQ_POLL_CLASSIC; + /* Request based queue always supports REQ_NOWAIT */ + q->limits.nowait_requests = 1; + blk_mq_init_cpu_queues(q, set->nr_hw_queues); blk_mq_add_queue_tag_set(set, q); blk_mq_map_swqueue(q); diff --git a/block/blk-settings.c b/block/blk-settings.c index 14397b4c4b53..8f96c7324497 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -59,6 +59,7 @@ void blk_set_default_limits(struct queue_limits *lim) lim->io_opt = 0; lim->misaligned = 0; lim->zoned = BLK_ZONED_NONE; + lim->nowait_requests = 0; } EXPORT_SYMBOL(blk_set_default_limits); @@ -486,6 +487,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->max_segment_size = min_not_zero(t->max_segment_size, b->max_segment_size); + t->nowait_requests &= b->nowait_requests; + t->misaligned |= b->misaligned; alignment = queue_limit_alignment_offset(b, start); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 32868fbedc9e..5f612dda34c2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -346,6 +346,7 @@ struct queue_limits { unsigned char misaligned; unsigned char discard_misaligned; unsigned char raid_partial_stripes_expensive; + unsigned char nowait_requests; enum blk_zoned_model zoned; }; From patchwork Mon Jun 1 12:37:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 11581977 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 2DEE6739 for ; Mon, 1 Jun 2020 12:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BC412074B for ; Mon, 1 Jun 2020 12:37:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="K9jD1x/W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgFAMhS (ORCPT ); Mon, 1 Jun 2020 08:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgFAMhS (ORCPT ); Mon, 1 Jun 2020 08:37:18 -0400 Received: from forwardcorp1p.mail.yandex.net (forwardcorp1p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5EC3C061A0E; Mon, 1 Jun 2020 05:37:17 -0700 (PDT) Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 2D98F2E1537; Mon, 1 Jun 2020 15:37:15 +0300 (MSK) Received: from myt5-70c90f7d6d7d.qloud-c.yandex.net (myt5-70c90f7d6d7d.qloud-c.yandex.net [2a02:6b8:c12:3e2c:0:640:70c9:f7d]) by mxbackcorp1o.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id sin8Zu6uxy-bCx0121q; Mon, 01 Jun 2020 15:37:15 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1591015035; bh=5PjvOIhiYKATy5WYX6CV1e4IcQVtVa9D6p3WuT8s0D4=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=K9jD1x/WB9MFGRSpVuHnqjbBhyphhBcCrzbaFsCSmn9JkSKKe0ODm3hEKA71EuJyc C+I3jmbann0MWOxySvQwGsSwS5d9o8a3UxSAGqfJ08XOkx6K1CFBy/WMWf6oYvoXfB //Wi04hvl39aEpn3MdcQYH4aWcNe8WtZMfonbUNg= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b080:6420::1:8]) by myt5-70c90f7d6d7d.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id oflWdp3Iqs-bCW4OxOY; Mon, 01 Jun 2020 15:37:12 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Subject: [PATCH RFC 2/3] md/raid0: enable REQ_NOWAIT From: Konstantin Khlebnikov To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, Jens Axboe Cc: Christoph Hellwig Date: Mon, 01 Jun 2020 15:37:12 +0300 Message-ID: <159101503243.180989.945052901574296650.stgit@buzz> In-Reply-To: <159101473169.180989.12175693728191972447.stgit@buzz> References: <159101473169.180989.12175693728191972447.stgit@buzz> User-Agent: StGit/0.22-39-gd257 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Set limits.nowait_requests = 1 before stacking limits. Raid itself does not delay bio in raid0_make_request(). Signed-off-by: Konstantin Khlebnikov --- drivers/md/raid0.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 322386ff5d22..e34292b05488 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -406,6 +406,9 @@ static int raid0_run(struct mddev *mddev) blk_queue_io_opt(mddev->queue, (mddev->chunk_sectors << 9) * mddev->raid_disks); + /* raid0_make_request() does not delay requests */ + mddev->queue->limits.nowait_requests = 1; + rdev_for_each(rdev, mddev) { disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); From patchwork Mon Jun 1 12:37:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 11581973 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 42C5213B6 for ; Mon, 1 Jun 2020 12:37:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29A772077D for ; Mon, 1 Jun 2020 12:37:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="bud8UMHh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbgFAMhU (ORCPT ); Mon, 1 Jun 2020 08:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727890AbgFAMhT (ORCPT ); Mon, 1 Jun 2020 08:37:19 -0400 Received: from forwardcorp1p.mail.yandex.net (forwardcorp1p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24BD2C061A0E; Mon, 1 Jun 2020 05:37:19 -0700 (PDT) Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id B906A2E150E; Mon, 1 Jun 2020 15:37:17 +0300 (MSK) Received: from myt4-18a966dbd9be.qloud-c.yandex.net (myt4-18a966dbd9be.qloud-c.yandex.net [2a02:6b8:c00:12ad:0:640:18a9:66db]) by mxbackcorp1g.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id ai6aEALE3J-bGICEg7u; Mon, 01 Jun 2020 15:37:17 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1591015037; bh=4hRg9MCRpNZccDrLqlIWiCiQ6475nINTgczAmQWqMOs=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=bud8UMHhYef3bRfb9uNwEFOltll5+Dvg3jOm9Z3wH09FN14zy3bnVUx+H45M1cz5i /oE5ny7AHRo8QeTrKkL19r0gR7ttOSCGxQSGU+6kWQABFZoO/P+CEPDlkdne/3YR5e xz9oJ8oG6fzCU/SjZZE8JAUhtIcTcFY2LJux/gyw= Authentication-Results: mxbackcorp1g.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b080:6420::1:8]) by myt4-18a966dbd9be.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ugeF6tCqFx-bGWetb0e; Mon, 01 Jun 2020 15:37:16 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Subject: [PATCH RFC 3/3] dm: add support for REQ_NOWAIT and enable for target dm-linear From: Konstantin Khlebnikov To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, Jens Axboe Cc: Christoph Hellwig Date: Mon, 01 Jun 2020 15:37:16 +0300 Message-ID: <159101503621.180989.6036577504611218020.stgit@buzz> In-Reply-To: <159101473169.180989.12175693728191972447.stgit@buzz> References: <159101473169.180989.12175693728191972447.stgit@buzz> User-Agent: StGit/0.22-39-gd257 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add dm target feature flag DM_TARGET_NOWAIT which tells that target has no problem with REQ_NOWAIT. Set limits.nowait_requests if all targets and backends handle REQ_NOWAIT. Signed-off-by: Konstantin Khlebnikov --- drivers/md/dm-linear.c | 5 +++-- drivers/md/dm-table.c | 3 +++ drivers/md/dm.c | 4 +++- include/linux/device-mapper.h | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index e1db43446327..00774b5d7668 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -228,10 +228,11 @@ static struct target_type linear_target = { .name = "linear", .version = {1, 4, 0}, #ifdef CONFIG_BLK_DEV_ZONED - .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_ZONED_HM, + .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_NOWAIT | + DM_TARGET_ZONED_HM, .report_zones = linear_report_zones, #else - .features = DM_TARGET_PASSES_INTEGRITY, + .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_NOWAIT, #endif .module = THIS_MODULE, .ctr = linear_ctr, diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 0a2cc197f62b..f4610f79ebd6 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1500,12 +1500,15 @@ int dm_calculate_queue_limits(struct dm_table *table, unsigned int zone_sectors = 0; blk_set_stacking_limits(limits); + limits->nowait_requests = 1; for (i = 0; i < dm_table_get_num_targets(table); i++) { blk_set_stacking_limits(&ti_limits); ti = dm_table_get_target(table, i); + ti_limits.nowait_requests = dm_target_supports_nowait(ti->type); + if (!ti->type->iterate_devices) goto combine_limits; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index db9e46114653..767cd4d70341 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1794,7 +1794,9 @@ static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio) if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) { dm_put_live_table(md, srcu_idx); - if (!(bio->bi_opf & REQ_RAHEAD)) + if (bio->bi_opf & REQ_NOWAIT) + bio_wouldblock_error(bio); + else if (!(bio->bi_opf & REQ_RAHEAD)) queue_io(md, bio); else bio_io_error(bio); diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index af48d9da3916..4d4af1eeeba4 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -252,6 +252,12 @@ struct target_type { #define DM_TARGET_ZONED_HM 0x00000040 #define dm_target_supports_zoned_hm(type) ((type)->features & DM_TARGET_ZONED_HM) +/* + * A target handles REQ_NOWAIT + */ +#define DM_TARGET_NOWAIT 0x00000080 +#define dm_target_supports_nowait(type) (!!((type)->features & DM_TARGET_NOWAIT)) + struct dm_target { struct dm_table *table; struct target_type *type;