From patchwork Fri Feb 11 21:40:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0F53C433EF for ; Fri, 11 Feb 2022 21:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349997AbiBKVnD (ORCPT ); Fri, 11 Feb 2022 16:43:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353752AbiBKVlK (ORCPT ); Fri, 11 Feb 2022 16:41:10 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 327EBC73 for ; Fri, 11 Feb 2022 13:41:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=pWHYMVDLAmByoRC12NPUdmnY+6Z0+I5UDqE1eD4oqHM=; b=LtbN58yIWpGy/g5c0vkZJpdZsOJK9gfmsD+7hh0fMNi0oy9FFYG1uWSNeGnsuCKx1lbcSf S1Hhbh8U2LSPl0LaLBMD4GUT/i4NE+fzRlrhPYzhmZYK3An9mS3JEgQTYxQIRTWIjsYXNH cxm4YXIOU/NHOx/yie4ISS1IXziabBs= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-160-1XRDYDeHNjqsv96Ktq7JRw-1; Fri, 11 Feb 2022 16:41:06 -0500 X-MC-Unique: 1XRDYDeHNjqsv96Ktq7JRw-1 Received: by mail-ot1-f71.google.com with SMTP id h5-20020a9d5545000000b0059ecbfae94eso6010525oti.17 for ; Fri, 11 Feb 2022 13:41:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pWHYMVDLAmByoRC12NPUdmnY+6Z0+I5UDqE1eD4oqHM=; b=4CTI1zp9I1IECYlh8qDomzYjyAhW67W9p+G11ezkubqs3AUxfP5j78vdTTDm8FLHHS iJ8lZdBOv0lKr1udti2r9hFiJjN/v6xDYzRdmf05kyMyjreStR2yyJXzLWB+9KOI6PvL iBrmXKdsqRt6lz9QA5sdbostXOCfyv6qzeeVuCMeogK31rXKm4QQ1mSRTo7szt+Gk0L8 ybiKISCvlGEgUzNayMnQfONCkXBM7/sLBFVQwiE7b6gWNH/nmz5g4UGetEqx3Tk0ngdl dyU/6RVitN3Fne1t6EEEVjgLbNeMa8gf51swyJpwV+Sa7dhkwBFQr760RN0o+1jv7TzA 0g+Q== X-Gm-Message-State: AOAM531VodUrqMmt+y0JpSb+C4iW432jkOUvjvXBpPLGAGd3HyNfbxMq WWCDptFjUGX9dgFYnBKjx+nT5D8tdJB9QcpVHoddX6Jhh5BI9KoyqjNTqNtoh66eU3axW6sGNNk PIrWo1hnBK6rStbjvD+Reaw== X-Received: by 2002:a05:6870:1318:: with SMTP id 24mr771263oab.28.1644615664761; Fri, 11 Feb 2022 13:41:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgWYNb7rgOCq30q5kQSDDFSZce9nmYQDDcneTKvKmUg8mfutDHI9Zx5YMSBZTnPEY38/Irbg== X-Received: by 2002:a05:6870:1318:: with SMTP id 24mr771259oab.28.1644615664550; Fri, 11 Feb 2022 13:41:04 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id q4sm9500794otk.39.2022.02.11.13.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:03 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 01/14] dm: rename split functions Date: Fri, 11 Feb 2022 16:40:44 -0500 Message-Id: <20220211214057.40612-2-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Rename __split_and_process_bio to dm_split_and_process_bio. Rename __split_and_process_non_flush to __split_and_process_bio. Also fix a stale comment and whitespace. Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ab9cc91931f9..2cecb8832936 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1359,7 +1359,7 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, /* * Select the correct strategy for processing a non-flush bio. */ -static int __split_and_process_non_flush(struct clone_info *ci) +static int __split_and_process_bio(struct clone_info *ci) { struct dm_target *ti; unsigned len; @@ -1395,8 +1395,8 @@ static void init_clone_info(struct clone_info *ci, struct mapped_device *md, /* * Entry point to split a bio into clones and submit them to the targets. */ -static void __split_and_process_bio(struct mapped_device *md, - struct dm_table *map, struct bio *bio) +static void dm_split_and_process_bio(struct mapped_device *md, + struct dm_table *map, struct bio *bio) { struct clone_info ci; int error = 0; @@ -1409,19 +1409,19 @@ static void __split_and_process_bio(struct mapped_device *md, } else if (op_is_zone_mgmt(bio_op(bio))) { ci.bio = bio; ci.sector_count = 0; - error = __split_and_process_non_flush(&ci); + error = __split_and_process_bio(&ci); } else { ci.bio = bio; ci.sector_count = bio_sectors(bio); - error = __split_and_process_non_flush(&ci); + error = __split_and_process_bio(&ci); if (ci.sector_count && !error) { /* * Remainder must be passed to submit_bio_noacct() * so that it gets handled *after* bios already submitted * have been completely processed. * We take a clone of the original to store in - * ci.io->orig_bio to be used by end_io_acct() and - * for dec_pending to use for completion handling. + * ci.io->orig_bio to be used by end_io_acct() and for + * dm_io_dec_pending() to use for completion handling. */ struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count, GFP_NOIO, &md->queue->bio_split); @@ -1470,7 +1470,7 @@ static void dm_submit_bio(struct bio *bio) if (is_abnormal_io(bio)) blk_queue_split(&bio); - __split_and_process_bio(md, map, bio); + dm_split_and_process_bio(md, map, bio); out: dm_put_live_table(md, srcu_idx); } @@ -2283,11 +2283,11 @@ static int __dm_suspend(struct mapped_device *md, struct dm_table *map, /* * Here we must make sure that no processes are submitting requests * to target drivers i.e. no one may be executing - * __split_and_process_bio from dm_submit_bio. + * dm_split_and_process_bio from dm_submit_bio. * - * To get all processes out of __split_and_process_bio in dm_submit_bio, + * To get all processes out of dm_split_and_process_bio in dm_submit_bio, * we take the write lock. To prevent any process from reentering - * __split_and_process_bio from dm_submit_bio and quiesce the thread + * dm_split_and_process_bio from dm_submit_bio and quiesce the thread * (dm_wq_work), we set DMF_BLOCK_IO_FOR_SUSPEND and call * flush_workqueue(md->wq). */ From patchwork Fri Feb 11 21:40:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06963C433FE for ; Fri, 11 Feb 2022 21:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353715AbiBKVlN (ORCPT ); Fri, 11 Feb 2022 16:41:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241155AbiBKVlM (ORCPT ); Fri, 11 Feb 2022 16:41:12 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CF042C62 for ; Fri, 11 Feb 2022 13:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=pSQq04wy06PXm26IhLE5PNJWpgzIDfqO8yF6qrhvU94=; b=V7Bnws2jM6WeymuQcedNrKWpjINPQ08kLI6UTMIzJaOx+rSJntuYpDdGy7KBDavWe+Ap62 Gwuo621v6z8jVoeMd0CQ2uLPHei82zK5KQZTytEzrx27koQXCu3RVnFeUGgyrIJuTzImml 7MyOzim5mw6pIwe27LNb4ZE4Rht/+bs= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-SZGNJOOsNQC9snaouI3Elw-1; Fri, 11 Feb 2022 16:41:08 -0500 X-MC-Unique: SZGNJOOsNQC9snaouI3Elw-1 Received: by mail-ot1-f71.google.com with SMTP id g6-20020a9d6b06000000b005abea86957eso4827232otp.14 for ; Fri, 11 Feb 2022 13:41:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pSQq04wy06PXm26IhLE5PNJWpgzIDfqO8yF6qrhvU94=; b=iUuznRbSUs/eHVUF7vf0zf66yegVAi1sEfJpSrl+HT1JwORuUCT4CrDsGcQX5ijAEG xQd5MeyGzFin37OT3b2GDcVELC5HBlKOcFEK+Obh8nLXMVDG7eF/q7LoYOK8p0bTiytf OFswt17vD2I0ZgV/31b9PAc8Cq167wVHmJw09MOqiZgGvRvELUMJf6NQfkyHqtsti9gA 5yWvvZvMtbTRV+5euTr8x8a3oPgOJP21mfJWp0f2j+awjW8UYcJXYOarBQd7msG08pTP u2evYUEus1icAJPs+mMnCCWUAw89Fs21Y56fSYbh1TWjr7v1AjSPBYlrg0r9gE/9F8sA c9Gw== X-Gm-Message-State: AOAM531fAKZAmUR3IPqJqBMx1011dORDr197IKO3mhm8TdHB98/PR041 Qu4qRu8QvVBr5N9ZtGGAX72px4TfUogRY6kvScS/Kk7HB0r24GkDMHFclPcmud/uZIO6xPFE3i/ HoJ8cP/LkKZRr/59YziWliA== X-Received: by 2002:a9d:6c8b:: with SMTP id c11mr1270686otr.92.1644615667634; Fri, 11 Feb 2022 13:41:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFoas0EWXUNof1qFC7AgnYYs6iZQl7YqF3JcxmfK7cJthcvMpyzcju8Qara2vobaiK5lDdjA== X-Received: by 2002:a9d:6c8b:: with SMTP id c11mr1270675otr.92.1644615667250; Fri, 11 Feb 2022 13:41:07 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id bl6sm10078090oib.38.2022.02.11.13.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:06 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 02/14] dm: fold __clone_and_map_data_bio into __split_and_process_bio Date: Fri, 11 Feb 2022 16:40:45 -0500 Message-Id: <20220211214057.40612-3-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Fold __clone_and_map_data_bio into its only caller. Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2cecb8832936..2f1942b61d48 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1188,25 +1188,6 @@ static void bio_setup_sector(struct bio *bio, sector_t sector, unsigned len) bio->bi_iter.bi_size = to_bytes(len); } -/* - * Creates a bio that consists of range of complete bvecs. - */ -static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti, - sector_t sector, unsigned *len) -{ - struct bio *bio = ci->bio, *clone; - - clone = alloc_tio(ci, ti, 0, len, GFP_NOIO); - bio_advance(clone, to_bytes(sector - clone->bi_iter.bi_sector)); - clone->bi_iter.bi_size = to_bytes(*len); - - if (bio_integrity(bio)) - bio_integrity_trim(clone); - - __map_bio(clone); - return 0; -} - static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, struct dm_target *ti, unsigned num_bios, unsigned *len) @@ -1361,6 +1342,7 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, */ static int __split_and_process_bio(struct clone_info *ci) { + struct bio *clone; struct dm_target *ti; unsigned len; int r; @@ -1374,9 +1356,13 @@ static int __split_and_process_bio(struct clone_info *ci) len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); - r = __clone_and_map_data_bio(ci, ti, ci->sector, &len); - if (r < 0) - return r; + clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO); + bio_advance(clone, to_bytes(ci->sector - clone->bi_iter.bi_sector)); + clone->bi_iter.bi_size = to_bytes(len); + if (bio_integrity(clone)) + bio_integrity_trim(clone); + + __map_bio(clone); ci->sector += len; ci->sector_count -= len; From patchwork Fri Feb 11 21:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE99FC433F5 for ; Fri, 11 Feb 2022 21:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346319AbiBKVlT (ORCPT ); Fri, 11 Feb 2022 16:41:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbiBKVlR (ORCPT ); Fri, 11 Feb 2022 16:41:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 39460C6C for ; Fri, 11 Feb 2022 13:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=91++qBctEBqt/WcCJjsVysQVehP+OlczjZE5uyGHky0=; b=hcnBSi9xU0zPxHOean9kci1IlQn/44vdaxmXA1+FeiNwWtpPOO1JRpts4yOLSwglJsRpqa S0mit0E8+vntHaPTY7NGE6A+GL+aDcj4UEb9usnRHFB4re1p4Q9yWJQDvAYKgIsbrIa7wN ciCP5i9RVxerLbeuLDYuyG/r9BWkXBQ= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-JK8pW2OTMEKtSns0E-NKsg-1; Fri, 11 Feb 2022 16:41:13 -0500 X-MC-Unique: JK8pW2OTMEKtSns0E-NKsg-1 Received: by mail-oo1-f71.google.com with SMTP id h7-20020a4aa287000000b002eb15de5797so6313847ool.23 for ; Fri, 11 Feb 2022 13:41:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=91++qBctEBqt/WcCJjsVysQVehP+OlczjZE5uyGHky0=; b=jLGQCMvK1IA7P+IseDN49Dybp+9Qr7ZSMx7Wj2CM3RSa9iO5h+IrRROm3WHOCNFpLc CYe0iHm5BS5UzyFTogN09ZDqJZClbEalHA5k+X4158dBUzr1LqXmWQaDFFlFNG1YM7Lw 7efq4nEYIW3XqTnr/gq7cZzHRJYZweUOYp19REtcJhKnSb9LE3CTWrIDHynlCh25BW42 JhekQnuGvh76CBjxz0fqeZLRf0Rxb5GovG+B2fyhfZeOIu40IlYGn9IN/ovFAutKmk/9 dotzLTsFL79jfs1e/vbRxTqIySiijl22SR9Ukm0Rv/OgrkkaJ8er37MShwsVoajGS00n 1rtQ== X-Gm-Message-State: AOAM5324bYgeaF9DQ4pv1Saww51lyCjxnROb3Zx/6ZHF3qOvpqOHl9BO JXCKGjBFSYAgZs0x7e8DbuKm+QWnuIhyAl8UEajrD0atyN0Bb5bAf6pfJ8MZFrtafpyo+9ytsvq dX9NaGq0qrnbMiRYG3cdnDQ== X-Received: by 2002:a05:6808:bcb:: with SMTP id o11mr1188058oik.2.1644615670499; Fri, 11 Feb 2022 13:41:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjJHjKjIojAV77eZvxdta7gUDgvuGSRfVHpC7eifGNL5o3XbrHtskQjvhxdmdPuuAqN+mUCw== X-Received: by 2002:a05:6808:bcb:: with SMTP id o11mr1188019oik.2.1644615669127; Fri, 11 Feb 2022 13:41:09 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id p5sm9852027oou.39.2022.02.11.13.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:08 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 03/14] dm: refactor dm_split_and_process_bio a bit Date: Fri, 11 Feb 2022 16:40:46 -0500 Message-Id: <20220211214057.40612-4-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove needless branching and indentation. Leaves code to catch malformed op_is_zone_mgmt bios (they shouldn't have a payload). Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2f1942b61d48..60a047de620f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1375,7 +1375,13 @@ static void init_clone_info(struct clone_info *ci, struct mapped_device *md, { ci->map = map; ci->io = alloc_io(md, bio); + ci->bio = bio; ci->sector = bio->bi_iter.bi_sector; + ci->sector_count = bio_sectors(bio); + + /* Shouldn't happen but sector_count was being set to 0 so... */ + if (WARN_ON_ONCE(op_is_zone_mgmt(bio_op(bio)) && ci->sector_count)) + ci->sector_count = 0; } /* @@ -1385,6 +1391,7 @@ static void dm_split_and_process_bio(struct mapped_device *md, struct dm_table *map, struct bio *bio) { struct clone_info ci; + struct bio *b; int error = 0; init_clone_info(&ci, md, map, bio); @@ -1392,34 +1399,29 @@ static void dm_split_and_process_bio(struct mapped_device *md, if (bio->bi_opf & REQ_PREFLUSH) { error = __send_empty_flush(&ci); /* dm_io_dec_pending submits any data associated with flush */ - } else if (op_is_zone_mgmt(bio_op(bio))) { - ci.bio = bio; - ci.sector_count = 0; - error = __split_and_process_bio(&ci); - } else { - ci.bio = bio; - ci.sector_count = bio_sectors(bio); - error = __split_and_process_bio(&ci); - if (ci.sector_count && !error) { - /* - * Remainder must be passed to submit_bio_noacct() - * so that it gets handled *after* bios already submitted - * have been completely processed. - * We take a clone of the original to store in - * ci.io->orig_bio to be used by end_io_acct() and for - * dm_io_dec_pending() to use for completion handling. - */ - struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count, - GFP_NOIO, &md->queue->bio_split); - ci.io->orig_bio = b; - - bio_chain(b, bio); - trace_block_split(b, bio->bi_iter.bi_sector); - submit_bio_noacct(bio); - } + goto out; } - start_io_acct(ci.io); + error = __split_and_process_bio(&ci); + if (error || !ci.sector_count) + goto out; + + /* + * Remainder must be passed to submit_bio_noacct() so it gets handled + * *after* bios already submitted have been completely processed. + * We take a clone of the original to store in ci.io->orig_bio to be + * used by end_io_acct() and for dm_io_dec_pending() to use for + * completion handling. + */ + b = bio_split(bio, bio_sectors(bio) - ci.sector_count, + GFP_NOIO, &md->queue->bio_split); + ci.io->orig_bio = b; + + bio_chain(b, bio); + trace_block_split(b, bio->bi_iter.bi_sector); + submit_bio_noacct(bio); +out: + start_io_acct(ci.io); /* drop the extra reference count */ dm_io_dec_pending(ci.io, errno_to_blk_status(error)); } From patchwork Fri Feb 11 21:40:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AEABC433EF for ; Fri, 11 Feb 2022 21:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353776AbiBKVlR (ORCPT ); Fri, 11 Feb 2022 16:41:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345121AbiBKVlP (ORCPT ); Fri, 11 Feb 2022 16:41:15 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08033C65 for ; Fri, 11 Feb 2022 13:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=mv03BNY+xdulNavhI7whyVhl6SEZfhNGRgDBWAdqIBo=; b=AkEdjAMjdtn1NyNqtfI56fUR0ZbC9XPQzXWLSMBvYoHpi2XCxRWkgkxVK7DT1yCLMBtnz9 64khVPOk5o/2NLdEpICQHyXtWs0AN+6mUtkaJtct0w+FHpKdcLLsO77K78LrOhBHgMae27 thOBRiRH5baK/lPQbIryG5+2mpiv9nI= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-HRDWcqn6OX2wvvykJU2SJw-1; Fri, 11 Feb 2022 16:41:11 -0500 X-MC-Unique: HRDWcqn6OX2wvvykJU2SJw-1 Received: by mail-ot1-f72.google.com with SMTP id l1-20020a9d7341000000b0059c2046f9edso6072696otk.3 for ; Fri, 11 Feb 2022 13:41:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mv03BNY+xdulNavhI7whyVhl6SEZfhNGRgDBWAdqIBo=; b=u7qvPY7g2C+7O6HkeUBIkWsi+TbpTDd4vHVo/P1Ze0Br5tGhgNMxRZyCnbJxneshEU mhaT9IbMywZdDTCgpvH/CywFc0ZinMa52yHnUxjz6p7xd/6UQpsVMqg8DXb62YX4EBN2 V72/6x/6rlEnzkDar2s8r0t1RHhgTt2xvJIIqpoMKmsbZRax6LGHbk+aIfMJwY25sAM5 gWUusnFmFGRzRrYj5DqAmVpCSaznZvzKx/FVOWUjRO99XOYnO8PyHOsRpkZUy7xUI7ah UX0fDBI1haQ90cyfU4Ak4kllvyjo8LOXncb1+BKeI7y5t8mb+Zx5RtFrpTA7VJZ4AQpg x49A== X-Gm-Message-State: AOAM530h1971GMCXpJPBcI3KPqr0M98wXa9Js3mSbGmyXdncbeTBdVAB Cts3P07wC8iuINJ0njPCtDbDM6K1vuRAk7jK5A2udIQdfzjkS3qPngSm1H6AYxulckDnJexnb8m 9OTRMl8K6WAEvtg48yovfWQ== X-Received: by 2002:a05:6830:448e:: with SMTP id r14mr1299843otv.102.1644615671076; Fri, 11 Feb 2022 13:41:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6SaEVfuBnc3P3ZkrUt/Pa1m5PKMHPu72Tk0s5Ge6mbotnvK/0AprRlTrDn7upIV5AdGhz6w== X-Received: by 2002:a05:6830:448e:: with SMTP id r14mr1299835otv.102.1644615670766; Fri, 11 Feb 2022 13:41:10 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id 21sm9610956otj.71.2022.02.11.13.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:10 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 04/14] dm: reduce code duplication in __map_bio Date: Fri, 11 Feb 2022 16:40:47 -0500 Message-Id: <20220211214057.40612-5-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Error path code (for handling DM_MAPIO_REQUEUE and DM_MAPIO_KILL) is effectively identical. Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 60a047de620f..8f2288a3b35b 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1161,20 +1161,14 @@ static void __map_bio(struct bio *clone) submit_bio_noacct(clone); break; case DM_MAPIO_KILL: - if (unlikely(swap_bios_limit(ti, clone))) { - struct mapped_device *md = io->md; - up(&md->swap_bios_semaphore); - } - free_tio(clone); - dm_io_dec_pending(io, BLK_STS_IOERR); - break; case DM_MAPIO_REQUEUE: - if (unlikely(swap_bios_limit(ti, clone))) { - struct mapped_device *md = io->md; - up(&md->swap_bios_semaphore); - } + if (unlikely(swap_bios_limit(ti, clone))) + up(&io->md->swap_bios_semaphore); free_tio(clone); - dm_io_dec_pending(io, BLK_STS_DM_REQUEUE); + if (r == DM_MAPIO_KILL) + dm_io_dec_pending(io, BLK_STS_IOERR); + else + dm_io_dec_pending(io, BLK_STS_DM_REQUEUE); break; default: DMWARN("unimplemented target map return value: %d", r); From patchwork Fri Feb 11 21:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32B0DC433FE for ; Fri, 11 Feb 2022 21:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243561AbiBKVlT (ORCPT ); Fri, 11 Feb 2022 16:41:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353774AbiBKVlR (ORCPT ); Fri, 11 Feb 2022 16:41:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2CC9C6E for ; Fri, 11 Feb 2022 13:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=8TzXai5XoIS8MdPbsH2K1r9uRN0R+imGzFYy55uIM5k=; b=h68FHaQDMqRWHOUxLaO/QYnUvOUuoxUDg6ODlYKXxFRKa2iR2VHy3YW7hrsQg8HwpBK9iL fYlPcnDMI+ukOhSYZXBuJg/++7exwNdbo9NgbEh6j3RssLe8Qs+6EjAbjZn8g57cfe4KL5 8WgGfmt/u1WU1hprtjD0ZPNh+eGYzZ8= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-345-Ggw2CMuyMLuP9aXNnodEYg-1; Fri, 11 Feb 2022 16:41:14 -0500 X-MC-Unique: Ggw2CMuyMLuP9aXNnodEYg-1 Received: by mail-oo1-f71.google.com with SMTP id t16-20020a4ae9b0000000b0031877e91c80so2775737ood.13 for ; Fri, 11 Feb 2022 13:41:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8TzXai5XoIS8MdPbsH2K1r9uRN0R+imGzFYy55uIM5k=; b=d5x1krwzfiBDLG1iFJ9GoIPqN8yTwFx/I1NSMVrvj5gaW6gElH4OcZlMMeDIC6+oSN ivYVl9HVklPRZLzQ7fjszEFbhIErgSBv0blEv2sT9oshsDOhyrvheRR8cIMgHycVhbUm h5AieDPMZ9YMaMvcjKxfts6ZuPuwzFlHMs08DxoZMCyKWXxoOCFRNWsfqggSW7/Z+bzL VpcFY+kJEuVOIU2+tlvALOs3AOed12Z7Akfp80BoPaw2IwY9sWBoM97TrFJBPhXVIwRG NsB+RlLfpZmEWoI8fVq8UyU4+Nea6gMwdNt67miDJ3bLLdZjb9l3mrE47QZzNUltvZJ6 jDtQ== X-Gm-Message-State: AOAM531gOobBz83U5i4nJPmToxAVGF2dIZi4k/HrNfm9pbr2htfwgrMk 6cd6FKpwUt6AzJKpSclR/B8wJVnkMEpxR/b9/llyEURrK5hKoHF0fEuReHtnbLsoLbI2CJB0ADv rlTYEY8kh5PbMbNebUoC2og== X-Received: by 2002:a05:6870:2b0b:: with SMTP id ld11mr762367oab.208.1644615672566; Fri, 11 Feb 2022 13:41:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuvVk1tr6R6mjs2QBFnD7weYNLfWqReEpv/lo9zB9fvtwYyowwbNBaoeAkADickixXuBf1Aw== X-Received: by 2002:a05:6870:2b0b:: with SMTP id ld11mr762363oab.208.1644615672407; Fri, 11 Feb 2022 13:41:12 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id 100sm9697215oth.75.2022.02.11.13.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:12 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 05/14] dm: remove impossible BUG_ON in __send_empty_flush Date: Fri, 11 Feb 2022 16:40:48 -0500 Message-Id: <20220211214057.40612-6-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The flush_bio in question was just initialized to be empty, so there is no way bio_has_data() will return true. So remove stale BUG_ON(). Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 8f2288a3b35b..bd07ccadbf01 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1255,7 +1255,6 @@ static int __send_empty_flush(struct clone_info *ci) ci->bio = &flush_bio; ci->sector_count = 0; - BUG_ON(bio_has_data(ci->bio)); while ((ti = dm_table_get_target(ci->map, target_nr++))) __send_duplicate_bios(ci, ti, ti->num_flush_bios, NULL); From patchwork Fri Feb 11 21:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C64CC4332F for ; Fri, 11 Feb 2022 21:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353760AbiBKVlT (ORCPT ); Fri, 11 Feb 2022 16:41:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345121AbiBKVlT (ORCPT ); Fri, 11 Feb 2022 16:41:19 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F457C6A for ; Fri, 11 Feb 2022 13:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=2nmpafQ891zGruDm7dwh6CvU71ZYy/KSzMouVi0m1L4=; b=JRrCrjdHknyc7cJ0D6KBX5R4VWam10bDZGogvd0tOiosXCscklKzP1sNPVojON/THHvJqr 6e8LlPgo10ZpEJOoIV24ZVRQf7yw4Ay4tuF5K8/lp/7QzInFd/3ZSBL05op4+3mloK/2t0 p18iVKeQT1GgIBQcxpIEkyPhAElszAo= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-567-hhEfdB5SPWKubq-NlBqW1A-1; Fri, 11 Feb 2022 16:41:15 -0500 X-MC-Unique: hhEfdB5SPWKubq-NlBqW1A-1 Received: by mail-oo1-f71.google.com with SMTP id y20-20020a4acb94000000b003185ebeeffdso3619221ooq.15 for ; Fri, 11 Feb 2022 13:41:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2nmpafQ891zGruDm7dwh6CvU71ZYy/KSzMouVi0m1L4=; b=nBdomT99tjaBvaiK9TxA3qwWAQcn+p+FiYeUE3xTylz8LkU4Ovh/ulubcmctdcaFO5 Ya0+uPm4tGROQpJod8h1m9/y8yh4KHEPM547rOL/7QdaTTA3JzqTnHttLkonGy1MuVOo JBY4yP5de/qlf4p5RwJ+xzYMQ6wIF7l/dbbiL49sv/kXR/AiscOEs0lOH/3dd2+UWGQQ UUZVt3NUdxhJlxzQgtadCL45R0upq5x2bL6W5yb2A6wrCt4fECR/a95MBZcbHwHgAH8d RF1l3MokDwvirtmKFWCPfoyMNqoYhpwBG3nDkwUhiddkPhbEnISn0cWznzOg3Q8mwiOo AFtg== X-Gm-Message-State: AOAM532duwKcpCQ+IeXKgOivc5ch3/B1IYCxJrcqpBeOo8QEFF9Atv41 t4Qe3SV5nXX/taWZysPVNHc63J2Ae5CAiVEHRpEEIUcg6eY624/jtghzF0/mxRa48Le1S9Qucwj L3iinLm79XtXIbFVjEvlvDg== X-Received: by 2002:a05:6808:21aa:: with SMTP id be42mr1202431oib.181.1644615674264; Fri, 11 Feb 2022 13:41:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPfXPPLsFfj5jCNwhbMCjHAtWwuF5IJFLhrkJvKUleXUnCO1B4gxuNTOXX8lKI2/HhrYfUdA== X-Received: by 2002:a05:6808:21aa:: with SMTP id be42mr1202427oib.181.1644615674109; Fri, 11 Feb 2022 13:41:14 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id b20sm9518934otq.20.2022.02.11.13.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:13 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 06/14] dm: remove unused mapped_device argument from free_tio Date: Fri, 11 Feb 2022 16:40:49 -0500 Message-Id: <20220211214057.40612-7-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index bd07ccadbf01..137e578785f6 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -539,7 +539,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) return io; } -static void free_io(struct mapped_device *md, struct dm_io *io) +static void free_io(struct dm_io *io) { bio_put(&io->tio.clone); } @@ -825,7 +825,7 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) io_error = io->status; start_time = io->start_time; stats_aux = io->stats_aux; - free_io(md, io); + free_io(io); end_io_acct(md, bio, start_time, &stats_aux); if (io_error == BLK_STS_DM_REQUEUE) From patchwork Fri Feb 11 21:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 191C5C433EF for ; Fri, 11 Feb 2022 21:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353767AbiBKVlW (ORCPT ); Fri, 11 Feb 2022 16:41:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbiBKVlV (ORCPT ); Fri, 11 Feb 2022 16:41:21 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2EE4CC65 for ; Fri, 11 Feb 2022 13:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=f2o5ohPI2HuG5wRnh3mt12sAQPRqGLpu4c/5MftkwBY=; b=QJqSpxe+I1lv58tSoM3rVkbHMZ9E3UMwmrD3poozf9CQHUj91OoXymwDYhuEx2andze3JT QF05xC/Tz7wZdLxDMj95sFZouZBPOgNZ3NNKdH7AhB0Glg3a+tsxYKOz/hGow1JbSidZgR K8AcJntS+4vFwiqVYNy+pQqQZ+qH4uk= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-06De6sREM0eGqmTecja5aA-1; Fri, 11 Feb 2022 16:41:17 -0500 X-MC-Unique: 06De6sREM0eGqmTecja5aA-1 Received: by mail-oo1-f71.google.com with SMTP id j18-20020a4ae852000000b003181c031d81so6287204ooj.22 for ; Fri, 11 Feb 2022 13:41:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f2o5ohPI2HuG5wRnh3mt12sAQPRqGLpu4c/5MftkwBY=; b=k7/Qnkj0D5V7BHgioA6VmhoybWRWejOglmVzoQQv/M8jt1cR+lzk2PzoIKmUIgetDl ld7ttNE5FzLNDC8nS3RuqzT1g5kC6BlEm1yRLw80k9WFNVARNKn3+T8QAqvjCOaDOpOt JSPnuSyWAhRDOY1IyGXNnSCHqTL3AR4rUilLl2lJGhr84CDzg8R0img4FDNLCoFrzT3e +t7sm/wlK2T/tEPmJH8eQzg0lDF/M1pA1dNh/Aoxt2ElMN8n1SiUOdwebHx76DbmIkNX 0DQV/GyZzqU+J82yWOuB/69E/Y5ewSourfslC/LYW9XODe9Aze2Btrnp6GpejX7KsROl U5wA== X-Gm-Message-State: AOAM530OXmBSl3Ywbc19PAp0jxqkdhHCSV4tHJsfc0FJ5EWnSFNtZqQC xSBIYLzMp4mGoGK17jJMeHlOlWDnXEV/tL10Mb7+THAziE94hjVXyJeDrslUzAOhuxLBwfo5hWf dvvxhf7zogBjJlXE55DqPAw== X-Received: by 2002:a05:6870:8784:: with SMTP id r4mr784939oam.274.1644615676697; Fri, 11 Feb 2022 13:41:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmRjUtja3RP0gsAIOMggI4AOA1jQTFBsYiSLmauHnRAgEORh5WQj00HCwcy/wmJj5xdWtFcQ== X-Received: by 2002:a05:6870:8784:: with SMTP id r4mr784936oam.274.1644615676503; Fri, 11 Feb 2022 13:41:16 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id y3sm10183932oix.41.2022.02.11.13.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:16 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 07/14] dm: remove code only needed before submit_bio recursion Date: Fri, 11 Feb 2022 16:40:50 -0500 Message-Id: <20220211214057.40612-8-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Commit 8615cb65bd63 ("dm: remove useless loop in __split_and_process_bio") showcased that we no longer loop. Remove the bio_advance() in __split_and_process_bio() that was only needed when looping was possible. Similarly there is no need to advance the bio, using ci->sector cursor, in __send_duplicate_bios(). Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 137e578785f6..164cccf59297 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1176,12 +1176,6 @@ static void __map_bio(struct bio *clone) } } -static void bio_setup_sector(struct bio *bio, sector_t sector, unsigned len) -{ - bio->bi_iter.bi_sector = sector; - bio->bi_iter.bi_size = to_bytes(len); -} - static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, struct dm_target *ti, unsigned num_bios, unsigned *len) @@ -1224,14 +1218,14 @@ static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, case 1: clone = alloc_tio(ci, ti, 0, len, GFP_NOIO); if (len) - bio_setup_sector(clone, ci->sector, *len); + clone->bi_iter.bi_size = to_bytes(*len); __map_bio(clone); break; default: alloc_multiple_bios(&blist, ci, ti, num_bios, len); while ((clone = bio_list_pop(&blist))) { if (len) - bio_setup_sector(clone, ci->sector, *len); + clone->bi_iter.bi_size = to_bytes(*len); __map_bio(clone); } break; @@ -1350,7 +1344,6 @@ static int __split_and_process_bio(struct clone_info *ci) len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO); - bio_advance(clone, to_bytes(ci->sector - clone->bi_iter.bi_sector)); clone->bi_iter.bi_size = to_bytes(len); if (bio_integrity(clone)) bio_integrity_trim(clone); From patchwork Fri Feb 11 21:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 304C1C433EF for ; Fri, 11 Feb 2022 21:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353778AbiBKVlY (ORCPT ); Fri, 11 Feb 2022 16:41:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbiBKVlX (ORCPT ); Fri, 11 Feb 2022 16:41:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9622DC6C for ; Fri, 11 Feb 2022 13:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=faOHtfTWGQl15mu9cVGnYSzZzcsDZXq9izeb7DCgtfk=; b=KTAGOFt3WoO6Z2GCFCDOlDN4Cfl69Fvb2ArNcm3dAUCzIhUsek2k6+Q/w9lu74XPY+V3i3 UpCgH7Cdf/csWEdNDxc1uJyzleJ/zK/Km/2PGenmUdhhTD1Swj+C4NWLup4pY2WCjtAIhk Vlrf+YcSXpU6egJ2iuApPjXkqFrvjQg= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-fL-baxr_PuCUgmNwsTiVIw-1; Fri, 11 Feb 2022 16:41:19 -0500 X-MC-Unique: fL-baxr_PuCUgmNwsTiVIw-1 Received: by mail-oi1-f197.google.com with SMTP id r15-20020a056808210f00b002d0d8b35b4eso2862574oiw.23 for ; Fri, 11 Feb 2022 13:41:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=faOHtfTWGQl15mu9cVGnYSzZzcsDZXq9izeb7DCgtfk=; b=plOLpLr0oXOQBzBMK1GIF7iTpm03GrhZUsqeQypFKpioUKjCRDZu8UXoNbngozF6Cz Hkm4wqxDI2kwEAxKT7iPMo0z59Tu2DF0T9YVduoOErGJdfuZrNZyaObs/Ea++qeHL+xs dh2OPRv2vL4n5HzNjbaNEeR0LOs9ZS0XXzfnynfHxrVu86RgieLnAF2TzQyIh8kA1NNA jDLhew8PXgDehXUvd/wlOXf3aY2kOaBkKxCHpcVzctY866cNJvzoJ5MMVsRpMQ+G2/zl H7tbjT5AzVhDS4Qj7oEW9Skq3rEOzsnF2NQnmwSzfIF2JEEZzDw0fD+/mehyNaQjYlPi rV1w== X-Gm-Message-State: AOAM531MfxlH/Dz5pKCZc1yd+53q9uMW7Uh/KR9dJfxpmgx25Qhwh0jR gboqpOyReq+wMHp3aQza+UpVfdbZRv5ixf6+jax4fy+acFZxDxK3hW3iHVziWfF44DPx9kk2yjh AS2m5LFxbfNMz5mimaMfL4Q== X-Received: by 2002:a05:6870:35c2:: with SMTP id c2mr769399oak.79.1644615678324; Fri, 11 Feb 2022 13:41:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHF2eI3D/fU3NXr6t8JQgauezM5zXIlCfv0BTpbFhkCXv0M5fjNT7muszxcaIOFb2OGolKWg== X-Received: by 2002:a05:6870:35c2:: with SMTP id c2mr769396oak.79.1644615678110; Fri, 11 Feb 2022 13:41:18 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id k6sm9778837oop.28.2022.02.11.13.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:17 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 08/14] dm: record old_sector in dm_target_io before calling map function Date: Fri, 11 Feb 2022 16:40:51 -0500 Message-Id: <20220211214057.40612-9-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Prep for being able to defer trace_block_bio_remap() until when the bio is remapped and submitted by the DM target. Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm-core.h | 1 + drivers/md/dm.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 72d18c3fbf1f..f40be01cca81 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -214,6 +214,7 @@ struct dm_target_io { unsigned int target_bio_nr; unsigned int *len_ptr; bool inside_dm_io; + sector_t old_sector; struct bio clone; }; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 164cccf59297..2f2002348b26 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -567,6 +567,7 @@ static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti, tio->ti = ti; tio->target_bio_nr = target_bio_nr; tio->len_ptr = len; + tio->old_sector = 0; return &tio->clone; } @@ -1120,7 +1121,6 @@ static void __map_bio(struct bio *clone) { struct dm_target_io *tio = clone_to_tio(clone); int r; - sector_t sector; struct dm_io *io = tio->io; struct dm_target *ti = tio->ti; @@ -1132,7 +1132,7 @@ static void __map_bio(struct bio *clone) * this io. */ dm_io_inc_pending(io); - sector = clone->bi_iter.bi_sector; + tio->old_sector = clone->bi_iter.bi_sector; if (unlikely(swap_bios_limit(ti, clone))) { struct mapped_device *md = io->md; @@ -1157,7 +1157,8 @@ static void __map_bio(struct bio *clone) break; case DM_MAPIO_REMAPPED: /* the bio has been remapped so dispatch it */ - trace_block_bio_remap(clone, bio_dev(io->orig_bio), sector); + trace_block_bio_remap(clone, bio_dev(io->orig_bio), + tio->old_sector); submit_bio_noacct(clone); break; case DM_MAPIO_KILL: From patchwork Fri Feb 11 21:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB0D3C433FE for ; Fri, 11 Feb 2022 21:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353781AbiBKVl0 (ORCPT ); Fri, 11 Feb 2022 16:41:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353779AbiBKVlZ (ORCPT ); Fri, 11 Feb 2022 16:41:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25FC7C73 for ; Fri, 11 Feb 2022 13:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=0iX5cBRgHe/bSS7YT5ZJ9ztGvi8JUB0cZ1xYv+ukKb0=; b=KV9OnyIcTjdPfhDUwOejd4VhvmV/gmyAif4byJoGvO8PsouQsxt2wddH+vg3IBEegZvVOq ERBGp+nvXaEUc9mY5jefc/lQf4NccGls3cd+AHE6jaevOU+qJjmrjJqTbgCXdYEKRlyBd8 bbQysFdwj55o8AP3IbpqxJke60JGk6Q= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-265-ZsbPjZ2KO3mpS-czXpJSJQ-1; Fri, 11 Feb 2022 16:41:21 -0500 X-MC-Unique: ZsbPjZ2KO3mpS-czXpJSJQ-1 Received: by mail-ot1-f69.google.com with SMTP id j2-20020a9d7d82000000b005a12a0fb4b0so6043879otn.5 for ; Fri, 11 Feb 2022 13:41:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0iX5cBRgHe/bSS7YT5ZJ9ztGvi8JUB0cZ1xYv+ukKb0=; b=WhwlbfXrefu9QkYns7Abdk16tIX0c7brTnupT9wBHZSmh+ltn8imyOd6Eim06DK2E7 dGK0VrCP0ubclkar0nbwDBnZ6cb0WvSKIBSrsSV1Wb0TYjd/PoJtIMWbcQwyQr1Jaywf 3mFNR19Dv06774oLeO0g0ImDC8sw/deQMZjwooAWM2C2uiaDw8tdQMrV9PirrQlZSK7n dJCyPpmCNheIYcbnHiFYuroMffYl0zcsYsRFQJe8Gt/8fc4pMTxgWtTgsmIW16lNNbr3 TIS0V2g24Ss81TMho8LKFTE1OW+AAQUl54wcOHc95nX0M1BjuBJtMGiaBGvGqO9aikoO 00Zg== X-Gm-Message-State: AOAM530S1IArB7CU2OyXR1cMafvqOWndrq4DFNak1AVMQwjuU/3JQyDJ AYVRQBrVgFdzZsTkWv5GHAt9n04Kq+w4tZF6xgLpAW53gqtr+/kCh5VPMowwX6X4yg36+Ty2cTr Z0jCWXKCJiughLqmnFW5RRA== X-Received: by 2002:a05:6870:3815:: with SMTP id y21mr801773oal.330.1644615680062; Fri, 11 Feb 2022 13:41:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhaY79cQa6rRIF6xGYCLQRnDZ3YcQEltVBHgKRWycktiay6UBHrlSniHAxFVmlgiQyEikfMQ== X-Received: by 2002:a05:6870:3815:: with SMTP id y21mr801770oal.330.1644615679858; Fri, 11 Feb 2022 13:41:19 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id u32sm6180621oiw.28.2022.02.11.13.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:19 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 09/14] dm: move kicking of suspend queue to dm_io_dec_pending Date: Fri, 11 Feb 2022 16:40:52 -0500 Message-Id: <20220211214057.40612-10-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move kicking of the suspend queue to dm_io_dec_pending (the only caller) since end_io_acct will soon only be called if IO accounting was started. Also, some comment tweaks and removal of local variables. No functional change. Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2f2002348b26..72686329f91e 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -487,12 +487,12 @@ EXPORT_SYMBOL_GPL(dm_start_time_ns_from_clone); static void start_io_acct(struct dm_io *io) { - struct mapped_device *md = io->md; struct bio *bio = io->orig_bio; bio_start_io_acct_time(bio, io->start_time); - if (unlikely(dm_stats_used(&md->stats))) - dm_stats_account_io(&md->stats, bio_data_dir(bio), + + if (unlikely(dm_stats_used(&io->md->stats))) + dm_stats_account_io(&io->md->stats, bio_data_dir(bio), bio->bi_iter.bi_sector, bio_sectors(bio), false, 0, &io->stats_aux); } @@ -500,18 +500,12 @@ static void start_io_acct(struct dm_io *io) static void end_io_acct(struct mapped_device *md, struct bio *bio, unsigned long start_time, struct dm_stats_aux *stats_aux) { - unsigned long duration = jiffies - start_time; - bio_end_io_acct(bio, start_time); if (unlikely(dm_stats_used(&md->stats))) dm_stats_account_io(&md->stats, bio_data_dir(bio), bio->bi_iter.bi_sector, bio_sectors(bio), - true, duration, stats_aux); - - /* nudge anyone waiting on suspend queue */ - if (unlikely(wq_has_sleeper(&md->wait))) - wake_up(&md->wait); + true, jiffies - start_time, stats_aux); } static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) @@ -829,6 +823,10 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) free_io(io); end_io_acct(md, bio, start_time, &stats_aux); + /* nudge anyone waiting on suspend queue */ + if (unlikely(wq_has_sleeper(&md->wait))) + wake_up(&md->wait); + if (io_error == BLK_STS_DM_REQUEUE) return; @@ -1127,9 +1125,7 @@ static void __map_bio(struct bio *clone) clone->bi_end_io = clone_endio; /* - * Map the clone. If r == 0 we don't need to do - * anything, the target has assumed ownership of - * this io. + * Map the clone. */ dm_io_inc_pending(io); tio->old_sector = clone->bi_iter.bi_sector; @@ -1154,6 +1150,7 @@ static void __map_bio(struct bio *clone) switch (r) { case DM_MAPIO_SUBMITTED: + /* target has assumed ownership of this io */ break; case DM_MAPIO_REMAPPED: /* the bio has been remapped so dispatch it */ @@ -1301,10 +1298,9 @@ static bool is_abnormal_io(struct bio *bio) static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, int *result) { - struct bio *bio = ci->bio; unsigned num_bios = 0; - switch (bio_op(bio)) { + switch (bio_op(ci->bio)) { case REQ_OP_DISCARD: num_bios = ti->num_discard_bios; break; From patchwork Fri Feb 11 21:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97E84C433EF for ; Fri, 11 Feb 2022 21:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347391AbiBKVla (ORCPT ); Fri, 11 Feb 2022 16:41:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345121AbiBKVl3 (ORCPT ); Fri, 11 Feb 2022 16:41:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D6B61C79 for ; Fri, 11 Feb 2022 13:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=/xjT8ts7rFxVnWvoCjYqEguiAAMtKDyhhIzyuUrbQZc=; b=azR9kBwqCnTBHpTcx7Bqv1ucgliCxbBJdZhyDHw1wvNFKxZ+MoBuOC5EM3c+MC5sUfMJHn mU8EU1hK0LM8ahMJCoRtWH/VCKHbxj6uAmCRzXLlcVBuHRYIegl6QKiLszHBJO9XMt16Xu VycANuhIndYOSDh8L1WQNo4eS0dFgbI= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-Jscgpdy8OvyKw09Z1Uf_ug-1; Fri, 11 Feb 2022 16:41:22 -0500 X-MC-Unique: Jscgpdy8OvyKw09Z1Uf_ug-1 Received: by mail-oo1-f71.google.com with SMTP id r12-20020a4aea8c000000b002fd5bc5d365so6323954ooh.18 for ; Fri, 11 Feb 2022 13:41:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/xjT8ts7rFxVnWvoCjYqEguiAAMtKDyhhIzyuUrbQZc=; b=sckp3frwnX3mTEPhusFPyLAYtBJct8HUu2JlsMkqcS8M3drROi+q44poF5LyVsxF+P Chp69axQI08VQhO1uyBoU0Kz/jXPEYiJKGAyB7+mZy0MX3NuZD3FZ9hWrCoa5kW5wLeu cAY+eWm5uYpj25R2WvGJdsfyPkC8bKfLr9h+mNM6FkD7lA0UrRfJPPDEbvQqj6Pfca8M zxZCWO1jFLJnqlmy8gRHV29QPcbVr1Iz0PlUdVzAxYJnRL4FhIDudgQz1Ljw5CA8TAWP JUTCI79PdoqVJmtBfWNyOkGB/jrkz/kEmojXBC55WePk268zAdRrw7ASuKfUNFK0E3MB +IJw== X-Gm-Message-State: AOAM532AfblI7VNMsPg/UVArKzBci3JjIeQzoZcRBcOufBCD2DZMCMmG Zx7syX8elJqDNw+XNX+bnk89vDDzfE6684XK2+jl6/iRR3HmNxNou28uCiHBpQvgcPt0NaEDG0f OKq2Nlg+YLHKqv9YAoLfvyg== X-Received: by 2002:a05:6808:154:: with SMTP id h20mr1184671oie.103.1644615681662; Fri, 11 Feb 2022 13:41:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHoO/6sjs/LcgGlmXM+T/Mc5GkMP/b9FDb0SWRQu9wbHgj1CE1v/5gDlYkTPnYQty7DeOZug== X-Received: by 2002:a05:6808:154:: with SMTP id h20mr1184665oie.103.1644615681470; Fri, 11 Feb 2022 13:41:21 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id z4sm2876168oad.21.2022.02.11.13.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:21 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 10/14] block: add bio_start_io_acct_remapped for the benefit of DM Date: Fri, 11 Feb 2022 16:40:53 -0500 Message-Id: <20220211214057.40612-11-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org DM needs the ability to account a clone bio's IO to the original block_device. So add @orig_bdev argument to bio_start_io_acct_time. Rename bio_start_io_acct_time to bio_start_io_acct_remapped. Also, follow bio_end_io_acct and bio_end_io_acct_remapped pattern by moving bio_start_io_acct to blkdev.h and have it call bio_start_io_acct_remapped. Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- block/blk-core.c | 24 ++++++++---------------- drivers/md/dm.c | 3 ++- include/linux/blkdev.h | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index be8812f5489d..8f23be96c737 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1077,29 +1077,21 @@ static unsigned long __part_start_io_acct(struct block_device *part, } /** - * bio_start_io_acct_time - start I/O accounting for bio based drivers + * bio_start_io_acct_remapped - start I/O accounting for bio based drivers * @bio: bio to start account for * @start_time: start time that should be passed back to bio_end_io_acct(). - */ -void bio_start_io_acct_time(struct bio *bio, unsigned long start_time) -{ - __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), - bio_op(bio), start_time); -} -EXPORT_SYMBOL_GPL(bio_start_io_acct_time); - -/** - * bio_start_io_acct - start I/O accounting for bio based drivers - * @bio: bio to start account for + * @orig_bdev: block device that I/O must be accounted to. * * Returns the start time that should be passed back to bio_end_io_acct(). */ -unsigned long bio_start_io_acct(struct bio *bio) +unsigned long bio_start_io_acct_remapped(struct bio *bio, + unsigned long start_time, + struct block_device *orig_bdev) { - return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), - bio_op(bio), jiffies); + return __part_start_io_acct(orig_bdev, bio_sectors(bio), + bio_op(bio), start_time); } -EXPORT_SYMBOL_GPL(bio_start_io_acct); +EXPORT_SYMBOL_GPL(bio_start_io_acct_remapped); unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, unsigned int op) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 72686329f91e..c0177552b471 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -489,7 +489,8 @@ static void start_io_acct(struct dm_io *io) { struct bio *bio = io->orig_bio; - bio_start_io_acct_time(bio, io->start_time); + bio_start_io_acct_remapped(bio, io->start_time, + io->orig_bio->bi_bdev); if (unlikely(dm_stats_used(&io->md->stats))) dm_stats_account_io(&io->md->stats, bio_data_dir(bio), diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3bfc75a2a450..31d055d4a17e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1512,11 +1512,23 @@ unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, void disk_end_io_acct(struct gendisk *disk, unsigned int op, unsigned long start_time); -void bio_start_io_acct_time(struct bio *bio, unsigned long start_time); -unsigned long bio_start_io_acct(struct bio *bio); +unsigned long bio_start_io_acct_remapped(struct bio *bio, + unsigned long start_time, + struct block_device *orig_bdev); void bio_end_io_acct_remapped(struct bio *bio, unsigned long start_time, struct block_device *orig_bdev); +/** + * bio_start_io_acct - start I/O accounting for bio based drivers + * @bio: bio to start account for + * + * Returns the start time that should be passed back to bio_end_io_acct(). + */ +static inline unsigned long bio_start_io_acct(struct bio *bio) +{ + return bio_start_io_acct_remapped(bio, jiffies, bio->bi_bdev); +} + /** * bio_end_io_acct - end I/O accounting for bio based drivers * @bio: bio to end account for From patchwork Fri Feb 11 21:40:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE23FC433F5 for ; Fri, 11 Feb 2022 21:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353774AbiBKVla (ORCPT ); Fri, 11 Feb 2022 16:41:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbiBKVl3 (ORCPT ); Fri, 11 Feb 2022 16:41:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFEF0C76 for ; Fri, 11 Feb 2022 13:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=ZTdCeP53ikFV1i4VLG05XOn5JwONyPZ0x07GjSF9VHQ=; b=IGmbk4LooHQHHyYqUhtRKCqYuZkQB7J7T41cn5W2FF9TYwxkKMQI7v9VYOXoD7Zryf2sD4 NYgXz7OZCrsGmX+dRaWi8+b9KEgDOeHhD2g0kLdQwy6iCWj4GegnS65MtS4SxlkwrJ39Ah flIgi0UTietzhX9HMv8D4K0B/OwwTRQ= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-301-2ptUq0BlMCia_NqDUZ-ACA-1; Fri, 11 Feb 2022 16:41:24 -0500 X-MC-Unique: 2ptUq0BlMCia_NqDUZ-ACA-1 Received: by mail-oo1-f72.google.com with SMTP id a10-20020a4a988a000000b00318bdbe9370so16077ooj.2 for ; Fri, 11 Feb 2022 13:41:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZTdCeP53ikFV1i4VLG05XOn5JwONyPZ0x07GjSF9VHQ=; b=r7Ii6OQjg4pWEJtsCD1Psj/dtHjOaInvj/gMDNaS79a/dGA6DJ9j+tXOT/27r2HoEk BhMutqg/H6+26m/8WnpV+vHZcTNEhqaiKZEXtgQKixEhEzU29ShDXG15/8284UeIf9/E qw91FmUPOVpU8fcSsXsZ+r3Fr6EtaJJiKYsVSc5q9s4L5wgNKrYPcC11V2pOAP8wtm2v c0pijHIBL3lCBYWgXmhzryI+x1PWsDbLz+HXSMu4Je0ANp6iyqM4oN0H/9ABj527NT7N Ea7Fpbd3dNg73HwxhsVIELntA4HLMXIaqJV78l7MezcuR++IourjzR8O0qyFilYKUCIv twCw== X-Gm-Message-State: AOAM533rqxsmGRyM1y9IYQBf2bCisfvcg+dLLLo120AobasnjP1j8UcV I5UWepsxEQL5sei8BKDyoanFcbTGNpYURzLk0insezwInE/kD7TjmlHgB65TGU3HX2LlzYzyBn5 zgk2RVH8EctBa8QQ3GcMO/A== X-Received: by 2002:a05:6808:11c1:: with SMTP id p1mr1159596oiv.62.1644615683307; Fri, 11 Feb 2022 13:41:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8ln7pYpddkU+XGN8SlK6Ts0wx4XhZN7aKbGGMg2i3xg9XnfCEYd0cR8QavyaSl2+LXAwvAA== X-Received: by 2002:a05:6808:11c1:: with SMTP id p1mr1159589oiv.62.1644615683084; Fri, 11 Feb 2022 13:41:23 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id x12sm9584980otq.6.2022.02.11.13.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:22 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 11/14] dm: add dm_submit_bio_remap interface Date: Fri, 11 Feb 2022 16:40:54 -0500 Message-Id: <20220211214057.40612-12-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Switch from early bio-based IO accounting (at the time DM clones each incoming bio) to late IO accounting just before each remapped bio is issued to underlying device via submit_bio_noacct(). Allows more precise bio-based IO accounting for DM targets that use their own workqueues to perform additional processing of each bio in conjunction with their DM_MAPIO_SUBMITTED return from their map function. When a target is updated to use dm_submit_bio_remap() they must also set ti->accounts_remapped_io to true. Use xchg() in start_io_acct(), as suggested by Mikulas, to ensure each IO is only started once. Suggested-by: Mikulas Patocka Signed-off-by: Mike Snitzer --- drivers/md/dm-core.h | 1 + drivers/md/dm.c | 59 ++++++++++++++++++++++++++++++++++++------- include/linux/device-mapper.h | 7 +++++ include/uapi/linux/dm-ioctl.h | 4 +-- 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index f40be01cca81..7660ead3f744 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -230,6 +230,7 @@ struct dm_io { atomic_t io_count; struct bio *orig_bio; unsigned long start_time; + int was_accounted; spinlock_t endio_lock; struct dm_stats_aux stats_aux; /* last member of dm_target_io is 'struct bio' */ diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c0177552b471..2461df65e2fe 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -485,9 +485,11 @@ u64 dm_start_time_ns_from_clone(struct bio *bio) } EXPORT_SYMBOL_GPL(dm_start_time_ns_from_clone); -static void start_io_acct(struct dm_io *io) +static void start_io_acct(struct dm_io *io, struct bio *bio) { - struct bio *bio = io->orig_bio; + /* Ensure IO accounting is only ever started once */ + if (xchg(&io->was_accounted, 1) == 1) + return; bio_start_io_acct_remapped(bio, io->start_time, io->orig_bio->bi_bdev); @@ -530,6 +532,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) spin_lock_init(&io->endio_lock); io->start_time = jiffies; + io->was_accounted = 0; return io; } @@ -786,6 +789,7 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) blk_status_t io_error; struct bio *bio; struct mapped_device *md = io->md; + bool was_accounted = false; unsigned long start_time = 0; struct dm_stats_aux stats_aux; @@ -819,10 +823,14 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) } io_error = io->status; - start_time = io->start_time; - stats_aux = io->stats_aux; + if (io->was_accounted) { + was_accounted = true; + start_time = io->start_time; + stats_aux = io->stats_aux; + } free_io(io); - end_io_acct(md, bio, start_time, &stats_aux); + if (was_accounted) + end_io_acct(md, bio, start_time, &stats_aux); /* nudge anyone waiting on suspend queue */ if (unlikely(wq_has_sleeper(&md->wait))) @@ -1100,6 +1108,40 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors) } EXPORT_SYMBOL_GPL(dm_accept_partial_bio); +/* + * @clone: clone bio that DM core passed to target's .map function + * @tgt_clone: bio that target needs to submit (after DM_MAPIO_SUBMITTED) + * + * Targets should use this interface to submit bios they take + * ownership of when returning DM_MAPIO_SUBMITTED. + * + * Target should also enable ti->accounts_remapped_io + */ +void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone) +{ + struct dm_target_io *tio = clone_to_tio(clone); + struct dm_io *io = tio->io; + + /* establish bio that will get submitted */ + if (!tgt_clone) + tgt_clone = clone; + + /* + * account IO to DM device in terms of clone's + * payload to avoid concern about late bio splitting. + * - clone will reflect any dm_accept_partial_bio() + * - any bio splitting is ultimately reflected in + * io->orig_bio so there is no IO imbalance in + * end_io_acct(). + */ + start_io_acct(io, clone); + + trace_block_bio_remap(tgt_clone, bio_dev(io->orig_bio), + tio->old_sector); + submit_bio_noacct(tgt_clone); +} +EXPORT_SYMBOL_GPL(dm_submit_bio_remap); + static noinline void __set_swap_bios_limit(struct mapped_device *md, int latch) { mutex_lock(&md->swap_bios_lock); @@ -1152,12 +1194,12 @@ static void __map_bio(struct bio *clone) switch (r) { case DM_MAPIO_SUBMITTED: /* target has assumed ownership of this io */ + if (!ti->accounts_remapped_io) + start_io_acct(io, clone); break; case DM_MAPIO_REMAPPED: /* the bio has been remapped so dispatch it */ - trace_block_bio_remap(clone, bio_dev(io->orig_bio), - tio->old_sector); - submit_bio_noacct(clone); + dm_submit_bio_remap(clone, NULL); break; case DM_MAPIO_KILL: case DM_MAPIO_REQUEUE: @@ -1405,7 +1447,6 @@ static void dm_split_and_process_bio(struct mapped_device *md, trace_block_split(b, bio->bi_iter.bi_sector); submit_bio_noacct(bio); out: - start_io_acct(ci.io); /* drop the extra reference count */ dm_io_dec_pending(ci.io, errno_to_blk_status(error)); } diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index b26fecf6c8e8..a3e397155bc9 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -362,6 +362,12 @@ struct dm_target { * zone append operations using regular writes. */ bool emulate_zone_append:1; + + /* + * Set if the target will submit IO using dm_submit_bio_remap() + * after returning DM_MAPIO_SUBMITTED from its map function. + */ + bool accounts_remapped_io:1; }; void *dm_per_bio_data(struct bio *bio, size_t data_size); @@ -465,6 +471,7 @@ int dm_suspended(struct dm_target *ti); int dm_post_suspending(struct dm_target *ti); int dm_noflush_suspending(struct dm_target *ti); void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors); +void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone); union map_info *dm_get_rq_mapinfo(struct request *rq); #ifdef CONFIG_BLK_DEV_ZONED diff --git a/include/uapi/linux/dm-ioctl.h b/include/uapi/linux/dm-ioctl.h index c12ce30b52df..b6df4f6707b5 100644 --- a/include/uapi/linux/dm-ioctl.h +++ b/include/uapi/linux/dm-ioctl.h @@ -286,9 +286,9 @@ enum { #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_VERSION_MAJOR 4 -#define DM_VERSION_MINOR 45 +#define DM_VERSION_MINOR 46 #define DM_VERSION_PATCHLEVEL 0 -#define DM_VERSION_EXTRA "-ioctl (2021-03-22)" +#define DM_VERSION_EXTRA "-ioctl (2022-02-11)" /* Status bits */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */ From patchwork Fri Feb 11 21:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1AC0C433FE for ; Fri, 11 Feb 2022 21:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbiBKVlc (ORCPT ); Fri, 11 Feb 2022 16:41:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345121AbiBKVlb (ORCPT ); Fri, 11 Feb 2022 16:41:31 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 775E5CC3 for ; Fri, 11 Feb 2022 13:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=zCLaNAewIh7QkuP3rRG3MbVBEGym23cj6pMb7L3QmRw=; b=a26APAYz2mYmzAz3DwtdyypZwtf+WMEzjKDDE/BQhczBLvQ/3CBjiALIHwSvpj1To/Do9q V02Gjp0tN4JQr2S42nZx9T0q4myRkGl8tVjxlBTuiDsrDh1lXlunab6GRB+sAD0eFcaLk0 lA3MNt+uti5GdKeUOizXhbUvhttsAAY= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-505-Tm37Y0l7PxaJ701yA7IY3A-1; Fri, 11 Feb 2022 16:41:26 -0500 X-MC-Unique: Tm37Y0l7PxaJ701yA7IY3A-1 Received: by mail-oi1-f198.google.com with SMTP id bp18-20020a056808239200b002ced7afbfd2so2865132oib.19 for ; Fri, 11 Feb 2022 13:41:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zCLaNAewIh7QkuP3rRG3MbVBEGym23cj6pMb7L3QmRw=; b=BIKup70U/ROfCups+ibrmUI0YQkT4ShGcwNvHjZw9KoTOB9xhry1ECNGIvuv54XRiT SFnpow6JQXduJjkEa2AQHLM3ExeAdDBn7cK6WPMBM0K9lfTCv3NQMsXJGyVuKy8M3C2N vC4DVrrqd7TQHaKxwjMCb22zJZtv+J6p+WJI0gh8iHjraKInFLnSVEcNRVsdH240Uf2I hRKy7ooug1lz5fD7TuM+58wA2AOdPkTIJrg2J70MhnkJYZqud+TQkWnpfmB3HRq/tp5S xtwcAJ6XTswI156RcetkAxhzs6AlG+U0k+i2pZpgPgGJKIjM2e/nenp2Stxe9eCRjBDW GO1g== X-Gm-Message-State: AOAM530hj6TGWALui9wB5hhxWuqoKRzJpPxyDe8XVPgRqcjPRdoJoHNR pI4+xEPNyBCrYv3InXDeH1nM5ZnQNz0fqNBg+jLrUDX417bJ7J8Vd4kRACoxvIfFeRc+BhsUiHs pmMIQ7ie1V5ij50tgYP7Y5A== X-Received: by 2002:a9d:58c8:: with SMTP id s8mr1306855oth.294.1644615685120; Fri, 11 Feb 2022 13:41:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzn92w1zkt3XkDgBb0WATQwhT0Cg5dpyyOjGhJ9x8FW+WtRk+rD9rUvvy7aLTh3q+qoANrxw== X-Received: by 2002:a9d:58c8:: with SMTP id s8mr1306850oth.294.1644615684909; Fri, 11 Feb 2022 13:41:24 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id n4sm9481217otq.63.2022.02.11.13.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:24 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 12/14] dm crypt: use dm_submit_bio_remap Date: Fri, 11 Feb 2022 16:40:55 -0500 Message-Id: <20220211214057.40612-13-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Signed-off-by: Mike Snitzer --- drivers/md/dm-crypt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index a5006cb6ee8a..337517cb4e90 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1855,7 +1855,7 @@ static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp) return 1; } - submit_bio_noacct(clone); + dm_submit_bio_remap(io->base_bio, clone); return 0; } @@ -1881,7 +1881,7 @@ static void kcryptd_io_write(struct dm_crypt_io *io) { struct bio *clone = io->ctx.bio_out; - submit_bio_noacct(clone); + dm_submit_bio_remap(io->base_bio, clone); } #define crypt_io_from_node(node) rb_entry((node), struct dm_crypt_io, rb_node) @@ -1960,7 +1960,7 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async) if ((likely(!async) && test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags)) || test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags)) { - submit_bio_noacct(clone); + dm_submit_bio_remap(io->base_bio, clone); return; } @@ -3363,6 +3363,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->num_flush_bios = 1; ti->limit_swap_bios = true; + ti->accounts_remapped_io = true; dm_audit_log_ctr(DM_MSG_PREFIX, ti, 1); return 0; @@ -3626,7 +3627,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits) static struct target_type crypt_target = { .name = "crypt", - .version = {1, 23, 0}, + .version = {1, 24, 0}, .module = THIS_MODULE, .ctr = crypt_ctr, .dtr = crypt_dtr, From patchwork Fri Feb 11 21:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8D8AC433EF for ; Fri, 11 Feb 2022 21:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345121AbiBKVle (ORCPT ); Fri, 11 Feb 2022 16:41:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353761AbiBKVld (ORCPT ); Fri, 11 Feb 2022 16:41:33 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C721C6A for ; Fri, 11 Feb 2022 13:41:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=tpMNyPQ6L7rwPA4GSYE86kruce/OO/n8Rw3lkBYRqxc=; b=R/qe0UTSadAPV/fZgcbYVa63+lxlJXUWa9tgjGXpTs0auSAwG067Thn0f1nDIDiITMooFN aUIs3Hi9UwTgE6J5BRXSRAvXPYHCqc3Haryk9gFKnmE1TLjRcCpd5lWJcs9oYmHWQkipVx 1VDCVSCYFq6MGndDrjT2Z5hKQ6ohl0w= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-t65F8qpvPFWJY16wSIMq5w-1; Fri, 11 Feb 2022 16:41:28 -0500 X-MC-Unique: t65F8qpvPFWJY16wSIMq5w-1 Received: by mail-ot1-f71.google.com with SMTP id e110-20020a9d01f7000000b0059ecb99d288so6032775ote.12 for ; Fri, 11 Feb 2022 13:41:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tpMNyPQ6L7rwPA4GSYE86kruce/OO/n8Rw3lkBYRqxc=; b=xwqTH2Sw8mbMo6zqGoaACHwa+NXU960cTK4JoPO247iPY/lG4jTT8ZGu4lSu5GVoso lwVDz99kehvYh6+vQiC4KvaYmQzBUKFLKhCMPbq8BunNiolRUqI0DPPshbiXa09eeEEW ep0ddN0L4yQCdGnxGInsw2pZcwsJnPj2aZSNFgTXX7zl4+u3CbArD32Ux2RNAMUpoetP EbiJq9ZGIl3xkjZwmGCZF6l5+APcw/OuIVe+L10dLsKbxKQD/fK8Pa/5m0BFeuXqeUez BttpHaUKqTAshC8RDUQvsspZX5EukOHeEO1rxEKalnA+zhMydx+uqasFO5lZc7onzK6k AIjA== X-Gm-Message-State: AOAM530vz+knHkp+gZSJPk7WVOU1u+ovWwB9y15mDclEGWy8g0cjftRf s5BDxVWwqkNk6gy35ahJ0sNgEb76qx1JLn/c1RQDaHnKZP4GMrZB5XhRdDiUf9PYP4kfLGqay3+ NAHQw+tNOUTkBiEAJqeFaqg== X-Received: by 2002:a9d:d4c:: with SMTP id 70mr1309172oti.45.1644615687245; Fri, 11 Feb 2022 13:41:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzf5gLazt1jBAQ7XMES2H7/5Hj/cMuqHfTH9oJBaRY1iZVevTkFbiJNV2fzrRS7uVQpcASPzQ== X-Received: by 2002:a9d:d4c:: with SMTP id 70mr1309164oti.45.1644615686831; Fri, 11 Feb 2022 13:41:26 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id p11sm10506598oiv.17.2022.02.11.13.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:26 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 13/14] dm delay: use dm_submit_bio_remap Date: Fri, 11 Feb 2022 16:40:56 -0500 Message-Id: <20220211214057.40612-14-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Signed-off-by: Mike Snitzer --- drivers/md/dm-delay.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c index 59e51d285b0e..9a51bf51a859 100644 --- a/drivers/md/dm-delay.c +++ b/drivers/md/dm-delay.c @@ -72,7 +72,7 @@ static void flush_bios(struct bio *bio) while (bio) { n = bio->bi_next; bio->bi_next = NULL; - submit_bio_noacct(bio); + dm_submit_bio_remap(bio, NULL); bio = n; } } @@ -232,6 +232,7 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->num_flush_bios = 1; ti->num_discard_bios = 1; + ti->accounts_remapped_io = true; ti->per_io_data_size = sizeof(struct dm_delay_info); return 0; @@ -355,7 +356,7 @@ static int delay_iterate_devices(struct dm_target *ti, static struct target_type delay_target = { .name = "delay", - .version = {1, 2, 1}, + .version = {1, 3, 0}, .features = DM_TARGET_PASSES_INTEGRITY, .module = THIS_MODULE, .ctr = delay_ctr, From patchwork Fri Feb 11 21:40:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12743923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E75BC433F5 for ; Fri, 11 Feb 2022 21:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353761AbiBKVlf (ORCPT ); Fri, 11 Feb 2022 16:41:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353777AbiBKVlf (ORCPT ); Fri, 11 Feb 2022 16:41:35 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E564C6D for ; Fri, 11 Feb 2022 13:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644615691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=NzdOPJXGvWlTS8MF/XpfxdYLMQV7NltmT4t/BtAgnos=; b=BSXYUUqZliQy5Gqv0W4SgZin7EXBbMPJmL4SGwAnhU3gzUTwX6JBC9x3aweU6dzIzZY7/E UDdPe3BtDwEKuoQmlObKpDnJvf0PNQXA6SFzbXlZOH20yjlh3/t+0mEGtPYHZc+bmFXAct Hp3wsz1mCAcZ5VWTXTovEs0XzyWBARU= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-Yi0wH8rDO-uGBsObKhH1nw-1; Fri, 11 Feb 2022 16:41:30 -0500 X-MC-Unique: Yi0wH8rDO-uGBsObKhH1nw-1 Received: by mail-oo1-f70.google.com with SMTP id c124-20020a4a4f82000000b002fb4087a29fso6304447oob.20 for ; Fri, 11 Feb 2022 13:41:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NzdOPJXGvWlTS8MF/XpfxdYLMQV7NltmT4t/BtAgnos=; b=bmeW1//KEWZBqyhrrzbul+ABGJHyL/orYd4rbtErWwuLaJr2sQrlWUgAe5qobzynms M0/tda1dgY5vS9lh8PEfMWhxqr60bdZBTnk0xrM9VgI3fa9MmbuTZ4TrDz7iINTbt8rI uiOLZzH/8j/Rvap7GEtUU7vxhSmRZs8eUQYWwQd0DhQ++1rpN9muAf9zvyli0YLARU4Q EqIjv113r5TNurZ7zfN+ufQvMX+x+n+Yy9Aeur3qJw456odlQ4rOTpNm+D5Q3/MgLKoG oLABpQQRNHSQL5eozOUZL5T9i58MiZW5k1nEBnUrupFm9b88t/gRTV9UIOsV9hiqeydS omUg== X-Gm-Message-State: AOAM532nvyNHzg9GH4/qPhxW8U6+qFYby79CCJFLVDpRwi7xD9E2UfYR DE6/fyyD1/lFvrK8PzHGYx8pbV494ZuT+QsHeYAqxoMd+KEXmiJWxRV/DoURqoXkAuobr7e68Y5 C5ttYm+6n3o0yE6uktb/k0w== X-Received: by 2002:a05:6808:13d6:: with SMTP id d22mr1174118oiw.184.1644615689069; Fri, 11 Feb 2022 13:41:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjvjfCjbkgODKupEk2FfXco+AHWfmEFNUHW5C40tZr+sBFx1L6qwEAK968vKCKNbAHr0iUvg== X-Received: by 2002:a05:6808:13d6:: with SMTP id d22mr1174103oiw.184.1644615688566; Fri, 11 Feb 2022 13:41:28 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id o144sm10188855ooo.25.2022.02.11.13.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:41:28 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [PATCH v2 14/14] dm: move duplicate code in callers of alloc_tio into alloc_tio Date: Fri, 11 Feb 2022 16:40:57 -0500 Message-Id: <20220211214057.40612-15-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com> References: <20220211214057.40612-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Suggested-by: Christoph Hellwig Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- drivers/md/dm.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2461df65e2fe..20c7b1b4d1f7 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -546,13 +546,16 @@ static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti, unsigned target_bio_nr, unsigned *len, gfp_t gfp_mask) { struct dm_target_io *tio; + struct bio *clone; if (!ci->io->tio.io) { /* the dm_target_io embedded in ci->io is available */ tio = &ci->io->tio; + /* alloc_io() already initialized embedded clone */ + clone = &tio->clone; } else { - struct bio *clone = bio_alloc_clone(ci->bio->bi_bdev, ci->bio, - gfp_mask, &ci->io->md->bs); + clone = bio_alloc_clone(ci->bio->bi_bdev, ci->bio, + gfp_mask, &ci->io->md->bs); if (!clone) return NULL; @@ -567,7 +570,13 @@ static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti, tio->len_ptr = len; tio->old_sector = 0; - return &tio->clone; + if (len) { + clone->bi_iter.bi_size = to_bytes(*len); + if (bio_integrity(clone)) + bio_integrity_trim(clone); + } + + return clone; } static void free_tio(struct bio *clone) @@ -1258,17 +1267,12 @@ static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, break; case 1: clone = alloc_tio(ci, ti, 0, len, GFP_NOIO); - if (len) - clone->bi_iter.bi_size = to_bytes(*len); __map_bio(clone); break; default: alloc_multiple_bios(&blist, ci, ti, num_bios, len); - while ((clone = bio_list_pop(&blist))) { - if (len) - clone->bi_iter.bi_size = to_bytes(*len); + while ((clone = bio_list_pop(&blist))) __map_bio(clone); - } break; } } @@ -1382,12 +1386,7 @@ static int __split_and_process_bio(struct clone_info *ci) return r; len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); - clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO); - clone->bi_iter.bi_size = to_bytes(len); - if (bio_integrity(clone)) - bio_integrity_trim(clone); - __map_bio(clone); ci->sector += len;