From patchwork Thu Feb 10 22:38:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742474 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBB0FC4332F for ; Thu, 10 Feb 2022 22:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532996; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1NNstZck6QaNsyN+snY++Z1Od1f/LlrQ/HE5U2jnNCo=; b=THGzmr/cykU6OCExcFcgC2vU7x/bgNBK3nqLyIdVYvVvAhOh5/P4gZAf/MuzKZ0Hj0DoAP 8czwKDM7NrpmtDNR0DnHyuCEZgAMfqGvQJMEm4Eb3IHChMA5Kt7N5rv67ydamYITsy4wPo 3qOQJUYjKKtbJ+Lz0LE1yd2Gq4QLW+M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-w-j5xipeM5WcI2_LS7Xy0w-1; Thu, 10 Feb 2022 17:43:13 -0500 X-MC-Unique: w-j5xipeM5WcI2_LS7Xy0w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08AB483DD20; Thu, 10 Feb 2022 22:43:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E43CC46983; Thu, 10 Feb 2022 22:43:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BA70A1806D2D; Thu, 10 Feb 2022 22:43:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMccU5014767 for ; Thu, 10 Feb 2022 17:38:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id F2F4CC080AE; Thu, 10 Feb 2022 22:38:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF2EEC07F5D for ; Thu, 10 Feb 2022 22:38:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D58983803916 for ; Thu, 10 Feb 2022 22:38:37 +0000 (UTC) Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-538-3bfscm5xOiyQB-riMzQDsA-1; Thu, 10 Feb 2022 17:38:36 -0500 X-MC-Unique: 3bfscm5xOiyQB-riMzQDsA-1 Received: by mail-qt1-f198.google.com with SMTP id z1-20020ac87ca1000000b002d11bc8d795so5506865qtv.17 for ; Thu, 10 Feb 2022 14:38:36 -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=Aelm5YgrbgtRcjh/7giXHAljK3Fp2NuUOh2H4+pquFs=; b=CzGreNh8pVsS00ghq1rKvm4fnJRtOG7HqeXjSE4SK0wN0UD5QqzB8FK+QwblpxpfTq ZXTIlj83bnB+ED/h3QB2a6/s93gHX+Ylyg/CoK/9GWRM/jWtcbQapFrQ+Aeo66me3s6I DvL0brMd+s2DqF7BwVR7Z7zoJHKY9FypeJYAasFg7swScItvEnmubXAqJtDQkJcNkeKq 2JyqwOuS03UVhSrG7nmt1S3AxNxF6AgKeSeAeQaVGbriHpnpv/xTJ62X00OYjKBkh82g 0n/HhJbegVI0UuFgTyszKhlKddBuHkrLWBfcbqE4ejwS5xA0vm1aT/7/UK7EPkmCv0mp XXTg== X-Gm-Message-State: AOAM533H3s4v26h6X1UY5ucKSD37Qfy/Zs3fueO9F+eXNJlcERVd8xwe yqVUJ1t7VeAKukFG2318e2VMwKwneK5+aEEqsXWYtWxQgEoMR1SFKupIYohLba2JOvlUXNK91DP i1CKJMpKXStLNeqib7BArucx0dA+sKXTwunlph7ZwIMepLYKebM57zc4FLsoBmAWuHA== X-Received: by 2002:a37:aa08:: with SMTP id t8mr5051598qke.773.1644532715689; Thu, 10 Feb 2022 14:38:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQixOwmD12PZY5UkjFPZ06AUK+aTARpLaV0mdw92GohG9RThiH7FoXYWT3NRL1ycsq0RFu0w== X-Received: by 2002:a37:aa08:: with SMTP id t8mr5051585qke.773.1644532715338; Thu, 10 Feb 2022 14:38:35 -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 w5sm10477933qko.34.2022.02.10.14.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:34 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:19 -0500 Message-Id: <20220210223832.99412-2-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 01/14] dm: rename split functions X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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. Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- 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 Thu Feb 10 22:38:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742476 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F156AC433EF for ; Thu, 10 Feb 2022 22:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644533000; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=W2C6x8UJu4uwobx2ZmRUKu4PwpxS0ZnGGdeei6J52I0=; b=H6umjTSpAOYHnLHERJOC/cymIRO+6wvZobk2cp8CN9112ptacBIS3DvfPfGKK5BNVT4B0h KmHnl20En3vBAxJPYTMtJP39rxfoHFIUB8KIhe2aII9uKQ1HyjAkinZi/ySKIULAsga9ki xxz8bZd2c846cq1aLmak8D4Lxh2Nmrw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-d4Vt0zHUPEeTUg-FKetWaQ-1; Thu, 10 Feb 2022 17:43:16 -0500 X-MC-Unique: d4Vt0zHUPEeTUg-FKetWaQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79C5B1018725; Thu, 10 Feb 2022 22:43:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C1E4E73F; Thu, 10 Feb 2022 22:43:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 36F221806D2F; Thu, 10 Feb 2022 22:43:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcicR014812 for ; Thu, 10 Feb 2022 17:38:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id F39C17ACA; Thu, 10 Feb 2022 22:38:43 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE8177AC6 for ; Thu, 10 Feb 2022 22:38:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03AFF80120D for ; Thu, 10 Feb 2022 22:38:39 +0000 (UTC) Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-64-Tx_Rg5SIP9iOkOzeaQajCg-1; Thu, 10 Feb 2022 17:38:37 -0500 X-MC-Unique: Tx_Rg5SIP9iOkOzeaQajCg-1 Received: by mail-qt1-f200.google.com with SMTP id x10-20020ac8700a000000b002c3ef8fc44cso5550406qtm.8 for ; Thu, 10 Feb 2022 14:38:37 -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=gASqrtvOszXul4kd0cd64/f9seYYh7m9E4wnSmr4aF8=; b=ZQL+L5uvYjEol4P8i/jJIDsOqhfSHfLnphOU2pGPkq7bOY3j/YF+86Aq26WCGRZeU9 iCJSklP0bXi630BLicw+yHXjVQbQwGL7xJHDItFfudWHN4yfNyAiIf/cq9wYqWUhiiEB qemOTWyTthrm3ga4hv2ScOFgWIQuYyHZUxuOkK8fJwYb/uGEo342RNTxHcQp5ZBzvg5s yE3easDQGUJN7VTSD9vN8Dpb6IcyUMwtfLFsLwTN7sKyXA95EOb0aK4793IgHOZTqfVB uHIqg5tQOPnA4sY6p3iQDLe+s94p0O0PuPWfRq6B4bPl2jGOzG6sscWsHBefLYT4D8Lh sQpQ== X-Gm-Message-State: AOAM5339waRLUWiZ2KZxj7AapAv/DGiRZEPjMWv7D6GXgPlD6PuUHptA /lVUi+fRN5HqocQ156hIFeotFvwFlua2yw7hfHZxOWjpyHQyK6Pdx1CGkRWvEb5qLfqChsM0o2o 8CymC7wErc9IH6uhoTKTMThn/5ckmZf5T0JYAzVtn58/+zj10DIX2JMPmnGEjHyXErw== X-Received: by 2002:a05:6214:262a:: with SMTP id gv10mr6836045qvb.98.1644532717157; Thu, 10 Feb 2022 14:38:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzshop5rhMcKKQyyYkS5tpUkVizfBc4b1Us/DFjfwBMEjhEWnkmSha5lLdwwyHGYJ/E/eeeTw== X-Received: by 2002:a05:6214:262a:: with SMTP id gv10mr6836035qvb.98.1644532716895; Thu, 10 Feb 2022 14:38:36 -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 y15sm10527083qko.133.2022.02.10.14.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:36 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:20 -0500 Message-Id: <20220210223832.99412-3-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 02/14] dm: fold __clone_and_map_data_bio into __split_and_process_bio X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Fold __clone_and_map_data_bio into its only caller. Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- 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 Thu Feb 10 22:38:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742475 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBAE1C433FE for ; Thu, 10 Feb 2022 22:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532996; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=to49Ck+IW95x8PnNGyiwKPzpyaQrwnMCLRbTMqvVj1Q=; b=HfVYwB6Qmtb1bM4TZ3V+njDibjf/hVb8q8KHMc8p6RA5tVpA89gGVTn6Bz64L/NXSgYwNY TrIww2j7h5HxxaWCs1NJqEpdQLdNho7+RDD1kmCbU5r4FFpfigOK1QILm4X+daAIq+c7zQ ge9XGCsIsG9I+qkFOsdYDNz70Deyo34= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-440-G7dqHsr_PTuMM4ZKpukU9w-1; Thu, 10 Feb 2022 17:43:15 -0500 X-MC-Unique: G7dqHsr_PTuMM4ZKpukU9w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E921D18C8C01; Thu, 10 Feb 2022 22:43:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C70DEE715; Thu, 10 Feb 2022 22:43:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A270B4A700; Thu, 10 Feb 2022 22:43:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcedY014786 for ; Thu, 10 Feb 2022 17:38:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A4C5401E7B; Thu, 10 Feb 2022 22:38:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86976401E9F for ; Thu, 10 Feb 2022 22:38:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BDC61066559 for ; Thu, 10 Feb 2022 22:38:40 +0000 (UTC) Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-n1wKq_K5MEGG9ruqB_jyjQ-1; Thu, 10 Feb 2022 17:38:39 -0500 X-MC-Unique: n1wKq_K5MEGG9ruqB_jyjQ-1 Received: by mail-qt1-f197.google.com with SMTP id w25-20020ac84d19000000b002d2966d66a8so5518307qtv.18 for ; Thu, 10 Feb 2022 14:38:39 -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=Dmbgb58sJS1NVsv2MiEVE8minE/+DuIbbyXB20Z/ekE=; b=4l1SHxZxuCohKZlAdMT79pUGhoOb98H5AoywL8v3hWPIg6k2p0FlD46Nxk95aN6XUI M9ka+XSrUXCKDx7MP77KZkvSnv+/D8sQe1wDapcTlpSeHNj8ps/bwjsx+asil2JXMwaY M/XfddgR0v7wFUdHm6SBunnRKDwb2Eqzlv5PVShCJAAeB8INEo5JZP1Dm2orIxuUpwMz vtPK7BVZNQXze5iXPpIFoj+O4AT89pvu2j7X5DvFqZlOWefLdOtHcJW3Sfo5l5PSulbh fswqQ33niaTXuDKk4jJTieDmfCobVzWDU/CZ6ALX9j1H8vdo0uLa/rbwE+G4FZM7X8Mb 5PhA== X-Gm-Message-State: AOAM531zuYHXpypLnS+I5qCy9DGdssf+IMnM8HibtlkSqdWx98PPN8X4 GF0prXfu0SzxEfZs28Oqnoz4Hvm1F0pFJnS0iIhhxpxEqMz9FS6USjM6JsJU6UAbrL8HyPGDrP3 +ZRVwHqOxFLyj8Cs4+jfuSJ+VdHcnMSyMKipB8t9TBbCBRS2Wg+5Xylb2x3FAV41mjA== X-Received: by 2002:a37:aac9:: with SMTP id t192mr4866680qke.118.1644532718361; Thu, 10 Feb 2022 14:38:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTEaXKZxCVPUG1VrVNIHN3jO/XBixkQ3uTQnAxaqJnd5AV3P7OpyaOaqfg8/NSZ6NUsUbCKA== X-Received: by 2002:a37:aac9:: with SMTP id t192mr4866671qke.118.1644532718037; Thu, 10 Feb 2022 14:38:38 -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 f4sm10753431qko.72.2022.02.10.14.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:37 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:21 -0500 Message-Id: <20220210223832.99412-4-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 03/14] dm: refactor dm_split_and_process_bio a bit X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Remove needless branching. Leaves code to catch malformed op_is_zone_mgmt bios (they shouldn't have a payload). Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- drivers/md/dm.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2f1942b61d48..56734aae718d 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; } /* @@ -1392,34 +1398,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; + goto out; + } - bio_chain(b, bio); - trace_block_split(b, bio->bi_iter.bi_sector); - submit_bio_noacct(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); } +out: start_io_acct(ci.io); - /* drop the extra reference count */ dm_io_dec_pending(ci.io, errno_to_blk_status(error)); } From patchwork Thu Feb 10 22:38:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742465 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38FC8C433F5 for ; Thu, 10 Feb 2022 22:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532842; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IyPpLgMREOqA3BM0HBw5sLyblf7xNDnvGV+U//yHL1g=; b=YnRB792xVBhn9VP8huoK2B/XtsLxZxoolqtK2ylXezevtJzfJIrwzAW4nKKuDz8VgdsTzy jdZexzZbT3Vj+iCAANtUcMuMIOIf8M+qTAIJdc+c6x0jCTmJltrvXjcTQXo5KiAqDO2sVh WqAQOnLZK0h/aWAYJ80bYnWPowwbQDY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-543-GnGrIFCeNV6jTFRsJHIThA-1; Thu, 10 Feb 2022 17:40:38 -0500 X-MC-Unique: GnGrIFCeNV6jTFRsJHIThA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 91CB985EE74; Thu, 10 Feb 2022 22:40:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3218D79588; Thu, 10 Feb 2022 22:40:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EA48C4BB7C; Thu, 10 Feb 2022 22:40:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcf5U014791 for ; Thu, 10 Feb 2022 17:38:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id AEBDD492D51; Thu, 10 Feb 2022 22:38:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AAF66492D47 for ; Thu, 10 Feb 2022 22:38:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 909DC8032EB for ; Thu, 10 Feb 2022 22:38:41 +0000 (UTC) Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-2CkyFYC7P_-VEUvNqi9Zfw-1; Thu, 10 Feb 2022 17:38:40 -0500 X-MC-Unique: 2CkyFYC7P_-VEUvNqi9Zfw-1 Received: by mail-qk1-f200.google.com with SMTP id bl5-20020a05620a1a8500b005088d061be4so4539011qkb.21 for ; Thu, 10 Feb 2022 14:38:40 -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=N1ZtWuQD/2MiqgkrjoL8yazkFH5KXeFDL5OjLo4UsiQ=; b=wq1IXyPvLNTM4hCVBv/OuYI/CYFfgSJ68hAkgwehteJg2ajKjcJMK8hPJou2MEaRLt fqFjLZnNXW8RaKB/tsnN9zzz7+xXcBwWjLFUiqpT9zOIHc8BWhrTgOhNbEihXAi3R20c /SOvYmt4qdcG/oE40eeytZlckaXIypqwCFkncx5cFQshn0IbaO9uzA4iN6MVXwNP+Wjc dF3ioxUGvyPRPu6lP90IPpI0bDgWC6T8BdUd1jAoAplNIroCYoH+J96IoTBcYI8bHgKD +RL4gFIeOWO6lzZh04r6wMzZfKR+hknJWAkSZ6Rg1MHbq7hxLzfBuNgtUThXPHRCHBAJ asTA== X-Gm-Message-State: AOAM5334B5xYbFD+pZN2GwiF4T0Tk1i++kOs4yZzR7FYRsQHrYD18Sq1 tiMIYny1YStRG2caojbLsaRp9S+olLYERM/pS5Lhorpwc/XLJ45GiXCYnuhtZLQQh1Wx0RzyxZZ 2tArJDGQIk/MTXT4Q4S3ejVvE4p+mkzwcWbncweP4WomxvNcP0EfC1wOLDo+j2vOpEw== X-Received: by 2002:ac8:7771:: with SMTP id h17mr6568563qtu.454.1644532719627; Thu, 10 Feb 2022 14:38:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVQD4DjXjI2TI6RHlCNfSHCzJOeMiWv0AytqCY43O5jsmCNUHGzFo0EsTCPdXZui5wk8R+dw== X-Received: by 2002:ac8:7771:: with SMTP id h17mr6568552qtu.454.1644532719407; Thu, 10 Feb 2022 14:38:39 -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 h11sm2556932qkp.89.2022.02.10.14.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:39 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:22 -0500 Message-Id: <20220210223832.99412-5-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 04/14] dm: reduce code duplication in __map_bio X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Error path code (for handling DM_MAPIO_REQUEUE and DM_MAPIO_KILL) is effectively identical. Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- 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 56734aae718d..cc014e56252e 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 Thu Feb 10 22:38:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742466 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AADD4C433F5 for ; Thu, 10 Feb 2022 22:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532845; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TtLjjpvQ/HSRD5TGe+RLYGcRg+d5E6wpkJzHmYVIjks=; b=NKglslHWSsva4rKuqzShWnRielu/nrHYlBwenRS3+NwjzNut3VHyQ8WU80fh3WyRt9nqvA PV0iFyPMUbsdFo2D6006lrqtYv7oiDMYjn8Jpp98t1Vx40iaRtozfbU3V+LQqF25FjaL2Z hkcOBdYLMvUL5u0PHWchLTlcY8nnSRU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-226-kU9gUEHgMHqi8it73sJlkQ-1; Thu, 10 Feb 2022 17:40:42 -0500 X-MC-Unique: kU9gUEHgMHqi8it73sJlkQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4E4464140; Thu, 10 Feb 2022 22:40:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A88024E2DD; Thu, 10 Feb 2022 22:40:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 825F01809CB9; Thu, 10 Feb 2022 22:40:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMchKB014802 for ; Thu, 10 Feb 2022 17:38:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A076492D51; Thu, 10 Feb 2022 22:38:43 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1671A492D47 for ; Thu, 10 Feb 2022 22:38:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F266B1C04B55 for ; Thu, 10 Feb 2022 22:38:42 +0000 (UTC) Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-499-ibUtmLasOMayNuCDnrQJjA-1; Thu, 10 Feb 2022 17:38:41 -0500 X-MC-Unique: ibUtmLasOMayNuCDnrQJjA-1 Received: by mail-qk1-f200.google.com with SMTP id bl5-20020a05620a1a8500b005088d061be4so4539042qkb.21 for ; Thu, 10 Feb 2022 14:38:41 -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=zWCBM8YnYusetp0OPiRYym7xOF2Me0YViFrrQcnA0W4=; b=PfCOpsDFVN+nU7M0at2K5h7I74JnngmQ1fZGHL8Y0PgbitFdEqaKUC+ni4W7CasqEy G9qEDgSknhjzLD4YLoeGzdGSSDYn3xMN/YVi70FgGiwGWPI7uUrzn0Ln6Td4IjKkJoHG 2geFqqAcAC1VD3mjaO1M0Lqoc+gLrRBG7c1P0a1T4kQLfFFsRmoB4FEWaPvMnsOF7wXp HoV2UHF/0p4Fo4z4NIG4PDmLS7OGos7/xwxo7SDJNeZt5JqgjeiTshE9vimFylv5apmm +kVtuAkyrNfGpvNgd2WmYr9R2VstzpkghVmGePLyHKfV4OIrOEWHozny0XdtdZ+Ikz8g kqzg== X-Gm-Message-State: AOAM5305yFH7YgGqRy8gA6bectc1Dtp+BQ7r6nJIwLRs23MJ19gSm3L2 rvd8XKJ/nuX7Hm5Ql+szkQ8jf5aNVhlPQljzVUh06sIrQAMgN/Zq2xgkOk+tAMLqKHEgCovrzhb 8TyiBLDB/qkg6dl+qKnOZacA9fYqKbAUM8h+lvrMNAKQd1Jsud4ETyJwYmYp0Yvuu8g== X-Received: by 2002:a05:620a:8cd:: with SMTP id z13mr4860476qkz.487.1644532721076; Thu, 10 Feb 2022 14:38:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRAUZfBBxSBcOHqSs0cu835y/n502phOPI93DcwbFy1t2ge6HipGrPT3511ZI+QNnRn+BDmg== X-Received: by 2002:a05:620a:8cd:: with SMTP id z13mr4860468qkz.487.1644532720833; Thu, 10 Feb 2022 14:38:40 -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 w3sm11965918qta.13.2022.02.10.14.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:40 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:23 -0500 Message-Id: <20220210223832.99412-6-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 05/14] dm: remove impossible BUG_ON in __send_empty_flush X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The flush_bio in question was just initialized to be empty, so there is no way bio_has_data() will retrun true. So remove stale BUG_ON(). Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- drivers/md/dm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index cc014e56252e..1985fc3f2a95 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 Thu Feb 10 22:38:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742469 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57813C433F5 for ; Thu, 10 Feb 2022 22:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532963; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=T6cBQeF6JP7i/vGvCfcIrm9RT+gIiYF23I97dsvKg9I=; b=HLAEpwgoAMtyDsEOPaibdMqPM4eC0YUJCn/qOnWNhDwr/krQcGDwMx4eyhhHOTn6oVbR7W fQ37bT6+G0vuQeRoT7RYOqlSy0x9babuyZ339JTd6EHpaN2tTeNK+krA+z0jX8et5mJMkR uZCn+vN28GsYbQFL7g9AarZgi+8UOEg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-AplMnRewOe-qdeHH6xuK6Q-1; Thu, 10 Feb 2022 17:42:41 -0500 X-MC-Unique: AplMnRewOe-qdeHH6xuK6Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49CF018C8C02; Thu, 10 Feb 2022 22:42:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2EFE14CEF0; Thu, 10 Feb 2022 22:42:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ED4571809CB9; Thu, 10 Feb 2022 22:42:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMclR2014830 for ; Thu, 10 Feb 2022 17:38:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0F2352166BB1; Thu, 10 Feb 2022 22:38:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B5732166BDB for ; Thu, 10 Feb 2022 22:38:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0683F29AA38B for ; Thu, 10 Feb 2022 22:38:44 +0000 (UTC) Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-muTFlH0ON-eUvdcqwuNz7w-1; Thu, 10 Feb 2022 17:38:42 -0500 X-MC-Unique: muTFlH0ON-eUvdcqwuNz7w-1 Received: by mail-qv1-f69.google.com with SMTP id e9-20020a0cf749000000b0042bf697ff6bso5031756qvo.5 for ; Thu, 10 Feb 2022 14:38:42 -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=TzXjPgdywpvS4JKTWEPuvG6S5tjQ0HqbosRT6X11Ckc=; b=0J1Ngyx3L3FMyqmr81u9/0QzIc80wSz2J0BXcaAXMeY33vpYhdipyRAtCgnFm+FD11 I3X0NLa6ZR1ahwDkSjx6dS5v7ueuqzhAhd09TP1Krta2U7NuSB6hzPHYWkkk35FQgJ6t tZhApjsXxauGua5lB1+3jIWjDS8VBUqqATzHO2rOfcmHBXrTS6vuFJjQNLtC+v6mBVrR q0vDJv0dFjpqOJgcd4cgNmONqP598W7O4AcVD/RYUd3EDFjzPaTUyf4RKAHPYgHPB3xS XEOaTfXCwqujX71bFiHbwoAWe3d3gXt57UgN+H68V+eBl4bv6Y9F+yi3js1/C7wJsrdL rjBg== X-Gm-Message-State: AOAM532ARb9tT5BSa+zEKLHuoLxe3ibdQ6XV8CdQOrw7ItGrGhDZm+/P BkWOxgpwxKsxiP84l/ryEf7+TNutMe9CzaNd8XfjE75o4ulIr5hMs2bm5s3GxE8mAofZQKrFA+t P9qRtXTE+y17l/hCHL5rWJN9b5Q/YO6s4xDnGgUix0fqSQji7BgXBOs842nbGSNRyRQ== X-Received: by 2002:a05:6214:5084:: with SMTP id kk4mr6496959qvb.87.1644532722363; Thu, 10 Feb 2022 14:38:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdUxlHbTKVegt7q96UOVkLZzblVev6PndTCx99qOFkY4DYSKF6tEc5hRZE8V6mEfZmaLcoVA== X-Received: by 2002:a05:6214:5084:: with SMTP id kk4mr6496949qvb.87.1644532722175; Thu, 10 Feb 2022 14:38:42 -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 v14sm10322732qkl.128.2022.02.10.14.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:41 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:24 -0500 Message-Id: <20220210223832.99412-7-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 06/14] dm: remove unused mapped_device argument from free_tio X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- 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 1985fc3f2a95..f091bbf8a8dc 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 Thu Feb 10 22:38:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742478 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0A24C433F5 for ; Thu, 10 Feb 2022 22:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644533003; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GQoQiUCky61fCO5LnsEHp/9Ota0FRD+SNhiu0tcRp9E=; b=IS/i39CjNk2QRbn5dchDdUFaRHVG7wtr6h1sFwQA4NDf2o+YDGQNhMpADS29BQJj6Ju2SB CvQgAtlCvFehaC4Qkj5k64TUlxhBlnpPWQmRBz/QIXwJRUIeVbXTukWk0Dfw8bRizFPBj9 SqEfov4yP/+gA/t+y18oobL5R+HYPts= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-EiLFP2IUNlCZX1XxJAfymg-1; Thu, 10 Feb 2022 17:43:20 -0500 X-MC-Unique: EiLFP2IUNlCZX1XxJAfymg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE386814253; Thu, 10 Feb 2022 22:43:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C42C05C2EF; Thu, 10 Feb 2022 22:43:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9DE464A706; Thu, 10 Feb 2022 22:43:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcu6S014894 for ; Thu, 10 Feb 2022 17:38:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 14FD31454547; Thu, 10 Feb 2022 22:38:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 116BB1454546 for ; Thu, 10 Feb 2022 22:38:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D63093803916 for ; Thu, 10 Feb 2022 22:38:55 +0000 (UTC) Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-ekQ1REnNOMOaIBfJGf4sbw-1; Thu, 10 Feb 2022 17:38:54 -0500 X-MC-Unique: ekQ1REnNOMOaIBfJGf4sbw-1 Received: by mail-qk1-f200.google.com with SMTP id b204-20020a3767d5000000b004b2a0d2e930so4545206qkc.15 for ; Thu, 10 Feb 2022 14:38:45 -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=DEABWOQAG5wChjoRVdmD9+4tJqi002FLqoS+HHDd0E8=; b=Vh6n4n+n2HsNCMZd1lNgl4qrwCxxHrpLdWNcEq1lTmrqfg39bzfugrsdBqejrAjcoK b+7N/FB0ZJYLKVGYm78JZ4P4Fchb33Kx+KdAKnuCgGA1g+RQorXR2/dl4mq6P/wYPvA3 m5BnLbGGtLqURgawRs2cualJ+omv5PGqZ0jL/t7puAnRUhvLyh8fNL5YJdjV2EMYCtCp mdqKvlRbfnjIdh4zqicX8+yopDymnmx73qLB0hf/BdXvSr+uPsWGwH02wnwq/W2fr2z2 TutKLPj2CWIVZcjqxQZr7hoXCc5b7uPXUPuTZ5FzcOzdNuCkCMl9xIy2CU4cjbBy6uBU mQMA== X-Gm-Message-State: AOAM532wA/SoAHPJtwiP2mrL673XRl56KwL2qLKQYM0yXMPztokrIbOP oJeYWOULxY7V8DM+3cpH0tpqaDZBOq6W1Ry4/KR062oRGQWB2PEXuMI05Bb1Iqv5bi6w2nTwhUd uPDrWVA7mrm1rNrNQvW+mdA8JdYESBP3GB3LCvMBj5hxynIMnKPbIfgp4MGM+0jn0iQ== X-Received: by 2002:a05:620a:2954:: with SMTP id n20mr4949258qkp.644.1644532723872; Thu, 10 Feb 2022 14:38:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwB/jwDj6FI1/7jk/S/HO15AQAsoYUPunogWnQegdbM0VkAmgE3KfBpXMwIwDBuvLYdBmPAtw== X-Received: by 2002:a05:620a:2954:: with SMTP id n20mr4949253qkp.644.1644532723624; Thu, 10 Feb 2022 14:38:43 -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 n7sm11816185qta.78.2022.02.10.14.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:43 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:25 -0500 Message-Id: <20220210223832.99412-8-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 07/14] dm: remove code only needed before submit_bio recursion X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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(). Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- 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 f091bbf8a8dc..5950d518e544 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 Thu Feb 10 22:38:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742473 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82804C4332F for ; Thu, 10 Feb 2022 22:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532975; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WErM0niRakstBq3WeILpk4wiX/Dn1VVES8Q295MGsBI=; b=VJubCCmEIAqa3pH/yt52Qgy974tAd6k6HzNu3ZFFtPh2f74QGgOrsD14ja8MgHem7V46oa LAB/9K4rXdksRHtFtmqtJ5Zge7lz79pUv2iJAQLIHOnmTISvBSyAUipNxB0/krz9/GcPqt gFUzLBlvoBQqdD5uo0SnPbN/wCptXhc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-IEgqXqDlOsGwB3iRc2hqCg-1; Thu, 10 Feb 2022 17:42:52 -0500 X-MC-Unique: IEgqXqDlOsGwB3iRc2hqCg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A56DC1091DA8; Thu, 10 Feb 2022 22:42:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A3EB56A81; Thu, 10 Feb 2022 22:42:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 635861802E34; Thu, 10 Feb 2022 22:42:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcwoG014912 for ; Thu, 10 Feb 2022 17:38:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 17B501120AA9; Thu, 10 Feb 2022 22:38:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 138711121335 for ; Thu, 10 Feb 2022 22:38:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E45A811E78 for ; Thu, 10 Feb 2022 22:38:47 +0000 (UTC) Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-sQCUI-eZMbOfplKf1RTc-w-1; Thu, 10 Feb 2022 17:38:46 -0500 X-MC-Unique: sQCUI-eZMbOfplKf1RTc-w-1 Received: by mail-qv1-f69.google.com with SMTP id g2-20020a0562141cc200b004123b0abe18so5059707qvd.2 for ; Thu, 10 Feb 2022 14:38:46 -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=IfXmk5i0i3prdNRYxcELXekeRQ6SpDfxxN4oTGtZnNk=; b=pszJpHUNH3NdiXem168qTaxwaBzTGG58jF6+YSsie9gCA1D6J2Z+O4FbbeeuoemuQq YrtzloNr1+Ueb5h637CSwdha9G4bde4/GxfeefTOJie5RXMQs9uekl/HU0JmN/SXdS0I tR4ZHIk/pWxXx6j6zUcwFdgw8kxh6nOZ98GRXFqFdW7bw9r0p418cyWjCbkheoboG22i 117TB9l4xRO2OW267ot2Bt97/ZpH5cNi3kSHuba7yMTv7/sLd/PWEGlPi84JGuKc5NM+ mdQbuFts0SUNYgiWzmgo5JPBfnSfj8/V8rO4kwPnMx3H8r/5X75wUFuFmxTnfLq1VzIC xsDA== X-Gm-Message-State: AOAM532mU2Wp2D8ygxC8eVbesyYLrEcEOx6e7OoWvPkuaNF2YC90mCJP NmLr2H/syWgiyjjZyV786PjAIA+cdN1AUaEf3lkgwzTQ/7a2YFxf8ScQkO73yOUnatDhlY9/ead G6qO9/RADCjjlbFKFnbOJ0IsvNDtHu2i/IYW2q636RS+f4FLkTdCL2eXqD8X5I9mc8Q== X-Received: by 2002:a05:620a:4012:: with SMTP id h18mr5121618qko.421.1644532725559; Thu, 10 Feb 2022 14:38:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/WuBM1MWf014PQYWdlKPzXr9gGf3iIEk91KFNZ30dmljK3pCiGA6TTM3Dqo0OPQkq2MwW1w== X-Received: by 2002:a05:620a:4012:: with SMTP id h18mr5121607qko.421.1644532725259; Thu, 10 Feb 2022 14:38:45 -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 c3sm6575052qkp.39.2022.02.10.14.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:44 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:26 -0500 Message-Id: <20220210223832.99412-9-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 08/14] dm: record old_sector in dm_target_io before calling map function X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Prep for being able to defer trace_block_bio_remap() until when the bio is remapped and submitted by the DM target. Signed-off-by: Mike Snitzer Reviewed-by: Christoph Hellwig --- 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 5950d518e544..3bd872b0e891 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 Thu Feb 10 22:38:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742467 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97D80C433FE for ; Thu, 10 Feb 2022 22:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532847; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=z39c3PnbQqBq0iaoSuZLL7aE+nQLdWiI/9JLG7NjeqA=; b=ROkWVuoPovWQiat9UOHrZ1/qtvdR9HSp30aBybSCd59PJO8xh+hWuZIIogoj2DbjE8W9fk 8v1Q9xRysS83IQqDYyn9SZTKTpgppCBU8gHf7MGHhmceHSspN2TpBHjsuGiOypEemEJnXL 6napJEaYb9Gj2woxErxjTdsTq5mkBsY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-LY-BAT8yNSG5u8_qupm8tA-1; Thu, 10 Feb 2022 17:40:44 -0500 X-MC-Unique: LY-BAT8yNSG5u8_qupm8tA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9D0718C8C01; Thu, 10 Feb 2022 22:40:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E9F24E2DD; Thu, 10 Feb 2022 22:40:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 79AAD1809CBA; Thu, 10 Feb 2022 22:40:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcs1M014865 for ; Thu, 10 Feb 2022 17:38:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 00D7C2026609; Thu, 10 Feb 2022 22:38:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F030D2026D6B for ; Thu, 10 Feb 2022 22:38:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9FF51066559 for ; Thu, 10 Feb 2022 22:38:48 +0000 (UTC) Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-6MZB7qj1P6Kbletr0WFjBA-1; Thu, 10 Feb 2022 17:38:47 -0500 X-MC-Unique: 6MZB7qj1P6Kbletr0WFjBA-1 Received: by mail-qv1-f70.google.com with SMTP id eo11-20020ad4594b000000b0042151b7180aso5025222qvb.8 for ; Thu, 10 Feb 2022 14:38:47 -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=NJDDntpX1bDz2HHZg4ERdrCl6N9td/COm3CwT3DXHyU=; b=uITbS5S5jdpEk5liH2dgj+xveiAFUXeJWvJhHYlhwFhGjeQmhXuSTpI99VidTqSbWi x+oTjP6s4Z4Hx1XVA67XPzxyE9+aClKBPB2PyhuTg3Lj26hrWmi62fLVzR8rGQ4MLjwH Pui4AXMTwRzYKXnL6WqyEFmyc83JjpV6Pirq5/8+6j0sZdH5lZmz+JEpvad9/BmaIs8e lMfhdQqV2HCMot62uSAa/599BcKigki5FonnUFgxlsU38DF3zms0pfcIqSEA2XDmLi+p F6XELfQa8Nb3u8kliP6Nfxvs6aYqUEy88uRf820P+4ZtLgHXdggJ+hPqzgr5dpLnx7vH saVw== X-Gm-Message-State: AOAM533pZAh8BdPtyQ14d5P96rfKFfn5amRZ0oGZLg+d5e7y0712T/M3 aCdbck+f+0I6VZ56VflINO/YjNa1YmlBvr0aKYRyCte2jR6JIGFqbBP2g55Y7cJrqR+wq1Pbs/x KLfvt60+w/rWV1vTDrqZJtmUYQS8CFxyF4KGJbw5dxNhS1xY4Gc9OKXWBdt8wYAi/Ew== X-Received: by 2002:a05:6214:2308:: with SMTP id gc8mr6697708qvb.108.1644532726960; Thu, 10 Feb 2022 14:38:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/swioXpnZqj/ggEJ7xdDFKsnoeOBasBsyZ13Up+u3iQ8ukuq5/OcxD8Z9zGj3LPPEVFxxxw== X-Received: by 2002:a05:6214:2308:: with SMTP id gc8mr6697693qvb.108.1644532726554; Thu, 10 Feb 2022 14:38:46 -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 z4sm12115514qtw.4.2022.02.10.14.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:46 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:27 -0500 Message-Id: <20220210223832.99412-10-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 09/14] dm: prep for following changes X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Rename dm_io struct's 'endio_lock' member to 'lock' to reuse spinlock to protect new member used to flag if IO accounting has been started. Also move kicking of the suspend queue out to dm_io_dec_pending (the only caller) since end_io_acct will soon only be called if IO accounting was started. Some comment tweaks and removal of local variables. No functional change. Signed-off-by: Mike Snitzer --- drivers/md/dm-core.h | 2 +- drivers/md/dm.c | 32 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index f40be01cca81..8dd196aec130 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -230,7 +230,7 @@ struct dm_io { atomic_t io_count; struct bio *orig_bio; unsigned long start_time; - spinlock_t endio_lock; + spinlock_t lock; struct dm_stats_aux stats_aux; /* last member of dm_target_io is 'struct bio' */ struct dm_target_io tio; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 3bd872b0e891..8c0e96b8e1a5 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) @@ -532,7 +526,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) atomic_set(&io->io_count, 1); io->orig_bio = bio; io->md = md; - spin_lock_init(&io->endio_lock); + spin_lock_init(&io->lock); io->start_time = jiffies; @@ -796,10 +790,10 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) /* Push-back supersedes any I/O errors */ if (unlikely(error)) { - spin_lock_irqsave(&io->endio_lock, flags); + spin_lock_irqsave(&io->lock, flags); if (!(io->status == BLK_STS_DM_REQUEUE && __noflush_suspending(md))) io->status = error; - spin_unlock_irqrestore(&io->endio_lock, flags); + spin_unlock_irqrestore(&io->lock, flags); } if (atomic_dec_and_test(&io->io_count)) { @@ -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 Thu Feb 10 22:38:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742470 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 439C0C433EF for ; Thu, 10 Feb 2022 22:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532968; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/VhCMdTv5Mhg5vcxTHoMYOEWje88pTGIqo+gz5oab80=; b=OTiGMoJ1u9faynV9mwADqMVO8YcRgjPXrnY0FEoD0l9GSNvSlxwcVFYb9yB9WIHNfvCUc9 c26+7YRxpV1yNw2jMCJAAnzBRMHAn1rIfF8RDjxijVshQt3t2qb9GBqhKClPRynfPzLFAD WLLTlezjdfipT3Vy/mb6P7KhsqYmkD8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-145-yIiJEXGkNOiFHTdOuV3oFw-1; Thu, 10 Feb 2022 17:42:44 -0500 X-MC-Unique: yIiJEXGkNOiFHTdOuV3oFw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 730F11018720; Thu, 10 Feb 2022 22:42:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A39B4697C; Thu, 10 Feb 2022 22:42:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 352EF4A7C8; Thu, 10 Feb 2022 22:42:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcoGc014840 for ; Thu, 10 Feb 2022 17:38:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id A309EC07F5D; Thu, 10 Feb 2022 22:38:50 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EDD4C1D38B for ; Thu, 10 Feb 2022 22:38:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86A7485A5A8 for ; Thu, 10 Feb 2022 22:38:50 +0000 (UTC) Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-jzo0LSOeNcy65xVsviOU6Q-1; Thu, 10 Feb 2022 17:38:49 -0500 X-MC-Unique: jzo0LSOeNcy65xVsviOU6Q-1 Received: by mail-qv1-f70.google.com with SMTP id 3-20020ad45b83000000b00423e8603906so5041553qvp.1 for ; Thu, 10 Feb 2022 14:38:49 -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=clg1j9AsWGf13nZ+cL57xlbQXn238yrRMLtUXnWXd9Q=; b=Vu1RBgHBpCLAS2fdZigUOGL8WY8dpdAQ5svNhyjm/GKmUpGC/YLxSQHGKf9/SccoNZ hiUZRRDjj1O1oMmjeBcze2GtfTUjKVKwwzLq6zBoVMJ41JtGU+zT2jHXVkLgdKIdZDst Ll5CR+Rb1I+JaivmPv3yOTUDQoF7MMT8IbjO8tDQaGhELXxmTdZCjyftnFs19ibfPdTq 6elKIQ9HZVqytN/AeC4NDluJmiCvDO5QZuFa2pG+QiXlzdx7sKq1tXde+FDdu+Onu1iR zeoexACfDjLVsMdvMSDg+4ok8qI2hLtJqVVSOjU2605avyTwNAfqfi012cNijXN/bVlX dk6A== X-Gm-Message-State: AOAM531yNQFZGTPE73fFpJo+q1DevR7zJC7Jtdd78EfqwdP9RkH0ekLL 3v6OJdIbsrhOMFAsvlUpkPazJ0Onl9Onwk5KfTYyzk4Ho+reYxvTgjDFh0baXnvzcw9uv+Ux7qD RRmPDP3fFtAm0+/j2fUqQra2z/uEcKR4XBhP5HEabha53swNc21a8gBneXHr+D7j2/Q== X-Received: by 2002:a37:61ca:: with SMTP id v193mr5007963qkb.177.1644532728515; Thu, 10 Feb 2022 14:38:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2IldN0gw3kZyxdPqUqit4+42CSSY2elFZp9qQdt60LjZzqSwEFWIWb3gl3fnkNs62ee8TQw== X-Received: by 2002:a37:61ca:: with SMTP id v193mr5007952qkb.177.1644532728122; Thu, 10 Feb 2022 14:38:48 -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 w14sm12344783qtc.29.2022.02.10.14.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:47 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:28 -0500 Message-Id: <20220210223832.99412-11-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 10/14] dm: add dm_submit_bio_remap interface X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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. Signed-off-by: Mike Snitzer --- drivers/md/dm-core.h | 1 + drivers/md/dm.c | 93 +++++++++++++++++++++++++++++++++++++++---- include/linux/device-mapper.h | 7 ++++ 3 files changed, 93 insertions(+), 8 deletions(-) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 8dd196aec130..3ecd6f294f53 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; + unsigned long io_acct_time; spinlock_t 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 8c0e96b8e1a5..ad512f40716e 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -485,21 +485,54 @@ 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; + unsigned long flags; - bio_start_io_acct_time(bio, io->start_time); + /* Ensure IO accounting is only ever started once */ + spin_lock_irqsave(&io->lock, flags); + if (smp_load_acquire(&io->io_acct_time)) { + spin_unlock_irqrestore(&io->lock, flags); + return; + } + smp_store_release(&io->io_acct_time, jiffies); + spin_unlock_irqrestore(&io->lock, flags); + bio_start_io_acct_time(bio, io->start_time); 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); } +static void start_io_acct(struct dm_io *io, struct bio *bio) +{ + /* Only start_io_acct() once for this IO */ + if (smp_load_acquire(&io->io_acct_time)) + return; + + __start_io_acct(io, bio); +} + +static void clone_and_start_io_acct(struct dm_io *io, struct bio *bio) +{ + struct bio io_acct_clone; + + /* Only clone_and_start_io_acct() once for this IO */ + if (smp_load_acquire(&io->io_acct_time)) + return; + + bio_init_clone(io->orig_bio->bi_bdev, + &io_acct_clone, bio, GFP_NOIO); + __start_io_acct(io, &io_acct_clone); +} + static void end_io_acct(struct mapped_device *md, struct bio *bio, unsigned long start_time, struct dm_stats_aux *stats_aux) { + if (!start_time) + return; + bio_end_io_acct(bio, start_time); if (unlikely(dm_stats_used(&md->stats))) @@ -529,6 +562,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) spin_lock_init(&io->lock); io->start_time = jiffies; + io->io_acct_time = 0; return io; } @@ -818,7 +852,8 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) } io_error = io->status; - start_time = io->start_time; + if (io->io_acct_time) + start_time = io->start_time; stats_aux = io->stats_aux; free_io(io); end_io_acct(md, bio, start_time, &stats_aux); @@ -1099,6 +1134,43 @@ 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; + struct block_device *clone_bdev = clone->bi_bdev; + + /* 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(). + */ + clone->bi_bdev = io->orig_bio->bi_bdev; + start_io_acct(io, clone); + clone->bi_bdev = clone_bdev; + + 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); @@ -1151,12 +1223,18 @@ 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) { + /* + * Any split isn't reflected in io->orig_bio yet. And bio + * cannot be modified because target is submitting it. + * Clone bio and account IO to DM device. + */ + clone_and_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: @@ -1403,7 +1481,6 @@ static void dm_split_and_process_bio(struct mapped_device *md, 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 From patchwork Thu Feb 10 22:38:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742472 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02635C433FE for ; Thu, 10 Feb 2022 22:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532969; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eyDnQBeg85TFQfxTIKFLqxOg5BlkLOx0OEjR8otTYI8=; b=aKyf7KimnkVItmyIV7TeWlVjVajFTD/yJfhVQxLuZoWLC0DMbRvryqzBvfhcwNt5N0XrZ0 nNTxbr7Tcv1CkpbxQEHlGOeaiPoAmIWYpHeNxSB6hOLUQ0MTSXcfLpA01oLgqehDL2f3a7 wAWIieMrelJD7w+IyLcA6WgEJBtUjdY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-oF5MIT9sM3OP1KNYna1o-A-1; Thu, 10 Feb 2022 17:42:46 -0500 X-MC-Unique: oF5MIT9sM3OP1KNYna1o-A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35B2864145; Thu, 10 Feb 2022 22:42:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C2784696D; Thu, 10 Feb 2022 22:42:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EA5014A7CA; Thu, 10 Feb 2022 22:42:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcp3b014845 for ; Thu, 10 Feb 2022 17:38:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 70875492D51; Thu, 10 Feb 2022 22:38:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CEEB492D47 for ; Thu, 10 Feb 2022 22:38:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 593051C05157 for ; Thu, 10 Feb 2022 22:38:51 +0000 (UTC) Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-MaI3DOEKNriyyZI7Wq8RWg-1; Thu, 10 Feb 2022 17:38:50 -0500 X-MC-Unique: MaI3DOEKNriyyZI7Wq8RWg-1 Received: by mail-qk1-f200.google.com with SMTP id d11-20020a37680b000000b0047d87e46f4aso4556697qkc.11 for ; Thu, 10 Feb 2022 14:38:50 -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=QSJblWqLgyZmlZxEVd+22+iLGNHpkwCdE5Y4iGn/nKk=; b=KCKTCWLEXnQMuARY/mKovKvjGafbAJZ1xhzPwReQuChihovGHhM3GCbsO9qUoADGY9 hkCCEH+FzuhZkEjTdICGnjHtXoCT9gNlU/Q/2kYRjxBJ22LdshGxgi14Se6jSMLRJrr3 IpoWRKYPyNkUQEi2CvRd0jF6nmeGxbxlZ5dQW1qt+5aPLIuNhVmjRTJ0VD8qND5sM8ZN 8tFijYKv7Icxi/5BeWDuvSR7x7zpYfF1T9HNEMsuQqHWImEFj7jML/9oa3e9JU6hN1k0 QMm4qgG44DXltuYUqStM/5/jXcgPgdfV2aAZD4gSwzrCBOuawV5I4JQ4S968jCYx70CV qoGw== X-Gm-Message-State: AOAM530JTbShADMwL8wXhzN4wuiy/umzbVtk5TYXzntZnQ1Vwsw6PSDj MY3FiQpDktIZ4wtbRpOEHUzGxUbTxIMF34OcowPGZQMc3HqpsBW/970TioI0R8QlVm24hF4qBAw eJs1wX0WLYnnRuA7Yba0Lr/Cko9YO00FMDjTwDRROn5WZzD82fr4zpu1CJjCWBP96LA== X-Received: by 2002:a05:622a:411:: with SMTP id n17mr6496120qtx.466.1644532729551; Thu, 10 Feb 2022 14:38:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT+PtvXuOy9fF5SaJVeCa3zFUy2819JDuwEm2PCy3GAfUwDOgDHA08+EaJap4V4vdpA0o8KQ== X-Received: by 2002:a05:622a:411:: with SMTP id n17mr6496110qtx.466.1644532729298; Thu, 10 Feb 2022 14:38:49 -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 j11sm11447294qtx.67.2022.02.10.14.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:48 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:29 -0500 Message-Id: <20220210223832.99412-12-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 11/14] dm crypt: use dm_submit_bio_remap X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Signed-off-by: Mike Snitzer --- drivers/md/dm-crypt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index a5006cb6ee8a..9ea197de08c2 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; From patchwork Thu Feb 10 22:38:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742477 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DA26C433F5 for ; Thu, 10 Feb 2022 22:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644533001; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XVZg9rwOSXexfosXsg/Coid8uQC/sI3QOy4g1abHlEk=; b=c+h4RAM92fvvG6MG8g/WsvTYRrsi8Er8P6IU4LooelxfRJ0mUtw5KPmb0UFXU43mQSchrt kf/ysjBmiehI5ffhODT6ZBWoyKjRrcQEdDTQNImALvvsHd+Izb5MqE4oLOBqj0JQ7yFtdF yD3sEuDr4PauKRpItIyI28fDHZSEFJY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-510-7R_jG8oJPIuOWg4KvwrQcQ-1; Thu, 10 Feb 2022 17:43:20 -0500 X-MC-Unique: 7R_jG8oJPIuOWg4KvwrQcQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2523A81424C; Thu, 10 Feb 2022 22:43:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B8C94697F; Thu, 10 Feb 2022 22:43:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DAB5118048A7; Thu, 10 Feb 2022 22:43:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcrLh014860 for ; Thu, 10 Feb 2022 17:38:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4612540885B9; Thu, 10 Feb 2022 22:38:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4244B40885B5 for ; Thu, 10 Feb 2022 22:38:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A209811E7A for ; Thu, 10 Feb 2022 22:38:53 +0000 (UTC) Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-hR394K_RPgW-Qxrsq5MhFw-1; Thu, 10 Feb 2022 17:38:51 -0500 X-MC-Unique: hR394K_RPgW-Qxrsq5MhFw-1 Received: by mail-qk1-f197.google.com with SMTP id q5-20020a05620a0d8500b004738c1b48beso4560080qkl.7 for ; Thu, 10 Feb 2022 14:38:51 -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=CRfDTYNpxGAOLZDzgeFhYGqT+avXL5fj+x7+6gQLvzM=; b=cddtT2P8tT7Z3Ma1408e/e8r1R0Nta7EJ+rDAiTgxuPrB2z0xCfCZUN96Vc5VWxoN/ KhwvriP/8OQokEB1PTOXlejAeWETbuVyjhtm3o6v2JpmDa4omHImwyHBNWr1jakzHJtV xE8reju12jGBgo3Lr90TOGZXaaqGxQrLTc9lTKJFWL+FJT3YEHlu9ZAMWx3MHuL3hoWz X7g1x2H0q5aWRNGA2JxFfHywIU1JhdUGC483UxRvEXCUOp+MRX4MQ/uHqtgRTaOIOWbe AE40KEBZI384mAPxHrbTkuRDKPGFE6jfuWMHH3u48hrFm2D6UiPaF6yDmw8KxWM6ajrp k71Q== X-Gm-Message-State: AOAM532SiSk9fgnb1bHoMt8Ebza076yAc3SkE58xDlJ9Lorn2N9/w252 PpfVrDpAfTOHp+rb+9bqOQG0HGdEvIdmDRWwdvvktTrsvr/9iOqRhJS27DHCJyi/GJ0Jw0NMqEG VpPYfegqmjB4vV0oLGM89INPYhP/VUg2d5ZAGlr8RE2xeUW0LWHc7Ze4hoC7CRn9lVA== X-Received: by 2002:a37:a607:: with SMTP id p7mr5034689qke.763.1644532730860; Thu, 10 Feb 2022 14:38:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxEVIGFiZwGx+fh0BLy5zq1Vh8eVtyQH52OipWCoMyOw9uzoENBF0MFCF33ybEO88rYgtWaw== X-Received: by 2002:a37:a607:: with SMTP id p7mr5034680qke.763.1644532730613; Thu, 10 Feb 2022 14:38:50 -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 bj24sm10469903qkb.115.2022.02.10.14.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:50 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:30 -0500 Message-Id: <20220210223832.99412-13-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 12/14] dm delay: dm_submit_bio_remap X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Signed-off-by: Mike Snitzer --- drivers/md/dm-delay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c index 59e51d285b0e..8235927a3912 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; From patchwork Thu Feb 10 22:38:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742471 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB0EAC433F5 for ; Thu, 10 Feb 2022 22:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532969; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hmZqFXmqlbomLCgs702cXstB+BQ7+uRIYlglQZ72EjM=; b=cyf4LLYeQo9tpFzMYFlHOwqjkar6M9O6yq3t50604yYu5TSVLN/I9L+PfTQfe/YLmzxN/T sCHguG8bPsEkRucfU54fxGs1/x+vjd5GF3TESJFVx5qfFXOE+CKw1AsyS9qgzGtcRzD8oi IOsH7OEkFt9wGO6AHNqrLzRCYRPQQoY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-9YTfVYUbPL2Kl307IdTmIQ-1; Thu, 10 Feb 2022 17:42:48 -0500 X-MC-Unique: 9YTfVYUbPL2Kl307IdTmIQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D511181424B; Thu, 10 Feb 2022 22:42:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B993546971; Thu, 10 Feb 2022 22:42:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 900821809CB9; Thu, 10 Feb 2022 22:42:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMcsP6014866 for ; Thu, 10 Feb 2022 17:38:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1138F40885B9; Thu, 10 Feb 2022 22:38:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D9A440885B5 for ; Thu, 10 Feb 2022 22:38:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAEE21C04B55 for ; Thu, 10 Feb 2022 22:38:53 +0000 (UTC) Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-55-BlEWvNG_MZ-SodVXQITI3g-1; Thu, 10 Feb 2022 17:38:52 -0500 X-MC-Unique: BlEWvNG_MZ-SodVXQITI3g-1 Received: by mail-qt1-f200.google.com with SMTP id a9-20020aed2789000000b002d78436cc47so5539707qtd.12 for ; Thu, 10 Feb 2022 14:38:52 -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=+Mnt9RTq0AtjFUsH7/0mhHCJN7nnx7AZj3Cr8laEsbg=; b=ONJpznVwvl8Ydkn4xqXpyrtCDWT6d4YLSer24fKCc3kIrlOWcgw1CPBfFw/z2hQHNp EnlHuo4SxK7Uuvd0P44AwWb2l8xQSNI7GKZCyGQz0wkxOtC6awMKm6i2JQ/+0uoyaIN6 iYWGpXEutkkhremU+Gn6Me+4pxQ+8leQnUQnQWAIB9h2ko8vhDz0wJRac2ljjSvaVzu9 6XjFgoi7y8xufDyC1JQCVYl2GlxspeaaM3mo3eS+I1uZQdNVqPjSNcKHxWOW/8Trrw3i gZ3vU50zV3wykd8CxNtMwGsnpziUbt/8mzGrVUTF8dDO26UUY5/Tzlg6pJB4d1QwQAzF XN4w== X-Gm-Message-State: AOAM5308d8uYiDz+l+ge9JIVLA4T9jkwwwPU9HwcX0MueW0xZ58cUoSd P0hxDRqWDnyL2eB3TMVFKTUobVP0QifeOUl9mMpxXDsC6R5rfxS49CYguD6TAaimtff5YYJuJpF 24LJ6fdqds8wHajA0zWVxeNBNMRWGCmSVVV3qAqUORrC7WRTIpSuke+3P/dNPVCST/A== X-Received: by 2002:a05:6214:2306:: with SMTP id gc6mr6868148qvb.63.1644532732050; Thu, 10 Feb 2022 14:38:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyamo0E431a2/YSMBqGadwIEB+1DQaLXFNobXLpuclNidyN4EcKw4raCDde0o/OY6oGwrdnag== X-Received: by 2002:a05:6214:2306:: with SMTP id gc6mr6868140qvb.63.1644532731828; Thu, 10 Feb 2022 14:38:51 -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 r3sm10312080qkm.56.2022.02.10.14.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:51 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:31 -0500 Message-Id: <20220210223832.99412-14-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 13/14] dm: improve correctness and efficiency of bio-based IO accounting X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Don't use jiffies as a glorified bool because jiffies can/will rollover to 0. Also use xchg(), instead of spin_lock_irq{save,restore} and smp_load_acquire/smp_store_release, to avoid performance impact of disabling and enabling interrupts. Suggested-by: Mikulas Patocka Signed-off-by: Mike Snitzer --- drivers/md/dm-core.h | 2 +- drivers/md/dm.c | 34 ++++++++++++---------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 3ecd6f294f53..d3c116866fd7 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -230,7 +230,7 @@ struct dm_io { atomic_t io_count; struct bio *orig_bio; unsigned long start_time; - unsigned long io_acct_time; + int was_accounted; spinlock_t 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 ad512f40716e..329f0be64523 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -487,17 +487,6 @@ EXPORT_SYMBOL_GPL(dm_start_time_ns_from_clone); static void __start_io_acct(struct dm_io *io, struct bio *bio) { - unsigned long flags; - - /* Ensure IO accounting is only ever started once */ - spin_lock_irqsave(&io->lock, flags); - if (smp_load_acquire(&io->io_acct_time)) { - spin_unlock_irqrestore(&io->lock, flags); - return; - } - smp_store_release(&io->io_acct_time, jiffies); - spin_unlock_irqrestore(&io->lock, flags); - bio_start_io_acct_time(bio, io->start_time); if (unlikely(dm_stats_used(&io->md->stats))) dm_stats_account_io(&io->md->stats, bio_data_dir(bio), @@ -507,8 +496,8 @@ static void __start_io_acct(struct dm_io *io, struct bio *bio) static void start_io_acct(struct dm_io *io, struct bio *bio) { - /* Only start_io_acct() once for this IO */ - if (smp_load_acquire(&io->io_acct_time)) + /* Ensure IO accounting is only ever started once */ + if (xchg(&io->was_accounted, 1) == 1) return; __start_io_acct(io, bio); @@ -518,8 +507,8 @@ static void clone_and_start_io_acct(struct dm_io *io, struct bio *bio) { struct bio io_acct_clone; - /* Only clone_and_start_io_acct() once for this IO */ - if (smp_load_acquire(&io->io_acct_time)) + /* Ensure IO accounting is only ever started once */ + if (xchg(&io->was_accounted, 1) == 1) return; bio_init_clone(io->orig_bio->bi_bdev, @@ -530,9 +519,6 @@ static void clone_and_start_io_acct(struct dm_io *io, struct bio *bio) static void end_io_acct(struct mapped_device *md, struct bio *bio, unsigned long start_time, struct dm_stats_aux *stats_aux) { - if (!start_time) - return; - bio_end_io_acct(bio, start_time); if (unlikely(dm_stats_used(&md->stats))) @@ -562,7 +548,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) spin_lock_init(&io->lock); io->start_time = jiffies; - io->io_acct_time = 0; + io->was_accounted = 0; return io; } @@ -819,6 +805,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; @@ -852,11 +839,14 @@ void dm_io_dec_pending(struct dm_io *io, blk_status_t error) } io_error = io->status; - if (io->io_acct_time) + if (io->was_accounted) { + was_accounted = true; start_time = io->start_time; - stats_aux = io->stats_aux; + 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))) From patchwork Thu Feb 10 22:38:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 12742468 X-Patchwork-Delegate: snitzer@redhat.com 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 234E7C433F5 for ; Thu, 10 Feb 2022 22:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644532849; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QxvrEVQLkhqyX9M05Vmlq+9LF/Uu5oE2KTWgAvhv3YU=; b=doLXA9FJyF5TITxX+aWu7cBUilIh+fW4FS08SWEE9KbpbSWn4+Sm7MuLYmPteg9fWaSqSC MgRITFRuvCudrJ5iUGBTQd5Pi/zATXeSNsZ3ns1bxsNvhYgaOcE+PEaGrB265N03tP+5uc 7DdtSp4QtoNghpKxshgKCyieoN5LeUI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-4pjTriowN9iDiLMycXJgiQ-1; Thu, 10 Feb 2022 17:40:45 -0500 X-MC-Unique: 4pjTriowN9iDiLMycXJgiQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 612E1100D691; Thu, 10 Feb 2022 22:40:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46D205BC22; Thu, 10 Feb 2022 22:40:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1DAAB4CA93; Thu, 10 Feb 2022 22:40:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21AMctpg014880 for ; Thu, 10 Feb 2022 17:38:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6BC2A492D51; Thu, 10 Feb 2022 22:38:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68036492D47 for ; Thu, 10 Feb 2022 22:38:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5016880120D for ; Thu, 10 Feb 2022 22:38:55 +0000 (UTC) Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-nsckbaLSMmitnfEiNSHWqw-1; Thu, 10 Feb 2022 17:38:54 -0500 X-MC-Unique: nsckbaLSMmitnfEiNSHWqw-1 Received: by mail-qk1-f199.google.com with SMTP id q5-20020ae9dc05000000b00507225deac5so4579436qkf.5 for ; Thu, 10 Feb 2022 14:38:54 -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=64mfGr+BkNDL/qyiDObOyXjA+jYS7+jce6ArkgUIKnM=; b=zHu2PzTGjaj32A06R2BlXEC9CWdH+u/sldvMqcuSL/YSU4DClYQR9anpU5jwraJYnt r9FsQnguiEw1qIQFFVOdrL36u8bvKqD/iLExtqxsWW6/BGfgDoB5VNu73SojKnWBAaq9 Hqf//d21wU+9vtz/P5flRnIcjYYk0ybP867lopbog1A71tJ5zbVh2qbnDaqQytNmjno2 QH/HUeY0rrN++pVVz+lhkuywyaOfX+fe6mxr3JlojcW/OgetgkOq+AbKPpqDpDGLokUa 48AyeyC6UUKUnnpbetoDrCZ50CHbRnniGO6N4nhMhuD/F0O73ueQTNXGNeC69hdu1Sc+ 1GiQ== X-Gm-Message-State: AOAM533RcoMxIJFOxOs8/b1WR6uIgxt3as8oCgBceK9DoDWiCY3tqWVL b+jeAn7d2ILfLcobIYcjcwD1DpA+9LqSjsiXcXtQTigiYdgNPYjzxHIAKBqrdZxr/+5m1uWFNRY kTr455fBGbBEKtgfkSUQndRsM0oBKzxVh33DsTPrbnyBkzRaHE5AyQNXqA1T5go7B9A== X-Received: by 2002:a05:622a:1303:: with SMTP id v3mr6633038qtk.294.1644532733483; Thu, 10 Feb 2022 14:38:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiq9A/dl8/a5+pxZQ8CSXaYG/GlW7bPYTGMKHlZVSuct7m0MfGG+eetHtVr60p3O6UF0//mw== X-Received: by 2002:a05:622a:1303:: with SMTP id v3mr6633025qtk.294.1644532733141; Thu, 10 Feb 2022 14:38:53 -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 q12sm12007982qtx.51.2022.02.10.14.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:38:52 -0800 (PST) From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 10 Feb 2022 17:38:32 -0500 Message-Id: <20220210223832.99412-15-snitzer@redhat.com> In-Reply-To: <20220210223832.99412-1-snitzer@redhat.com> References: <20220210223832.99412-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org Subject: [dm-devel] [PATCH 14/14] block: add bio_start_io_acct_remapped for the benefit of DM X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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. Improve DM to no longer need to play games with swizzling a clone bio's bi_bdev (in dm_submit_bio_remap) and remove DM's clone_and_start_io_acct() interface. Signed-off-by: Mike Snitzer --- block/blk-core.c | 24 ++++++++---------------- drivers/md/dm.c | 41 ++++++++--------------------------------- include/linux/blkdev.h | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 51 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 329f0be64523..e020f505e243 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -485,35 +485,19 @@ 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, struct bio *bio) -{ - bio_start_io_acct_time(bio, io->start_time); - 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); -} - static void start_io_acct(struct dm_io *io, struct bio *bio) { /* Ensure IO accounting is only ever started once */ if (xchg(&io->was_accounted, 1) == 1) return; - __start_io_acct(io, bio); -} + bio_start_io_acct_remapped(bio, io->start_time, + io->orig_bio->bi_bdev); -static void clone_and_start_io_acct(struct dm_io *io, struct bio *bio) -{ - struct bio io_acct_clone; - - /* Ensure IO accounting is only ever started once */ - if (xchg(&io->was_accounted, 1) == 1) - return; - - bio_init_clone(io->orig_bio->bi_bdev, - &io_acct_clone, bio, GFP_NOIO); - __start_io_acct(io, &io_acct_clone); + 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); } static void end_io_acct(struct mapped_device *md, struct bio *bio, @@ -1137,7 +1121,6 @@ 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; - struct block_device *clone_bdev = clone->bi_bdev; /* establish bio that will get submitted */ if (!tgt_clone) @@ -1151,9 +1134,7 @@ void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone) * io->orig_bio so there is no IO imbalance in * end_io_acct(). */ - clone->bi_bdev = io->orig_bio->bi_bdev; start_io_acct(io, clone); - clone->bi_bdev = clone_bdev; trace_block_bio_remap(tgt_clone, bio_dev(io->orig_bio), tio->old_sector); @@ -1213,14 +1194,8 @@ 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) { - /* - * Any split isn't reflected in io->orig_bio yet. And bio - * cannot be modified because target is submitting it. - * Clone bio and account IO to DM device. - */ - clone_and_start_io_acct(io, clone); - } + if (!ti->accounts_remapped_io) + start_io_acct(io, clone); break; case DM_MAPIO_REMAPPED: /* the bio has been remapped so dispatch it */ 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