From patchwork Wed Oct 5 18:03:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12999546 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E6CC433F5 for ; Wed, 5 Oct 2022 18:03:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 600CD6B0075; Wed, 5 Oct 2022 14:03:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 587656B0078; Wed, 5 Oct 2022 14:03:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B2B66B007B; Wed, 5 Oct 2022 14:03:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 28E396B0075 for ; Wed, 5 Oct 2022 14:03:59 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E09F080FF9 for ; Wed, 5 Oct 2022 18:03:58 +0000 (UTC) X-FDA: 79987669356.17.423237A Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf29.hostedemail.com (Postfix) with ESMTP id 8934B120022 for ; Wed, 5 Oct 2022 18:03:58 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id i7-20020a17090a65c700b0020ad9666a86so2102883pjs.0 for ; Wed, 05 Oct 2022 11:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j+XlP7a4AbJnWW0mvkyBXtZwa/N1Rx2itITpw13S/3I=; b=irYlT/WC2ltGpTTQ+/ZIRFgbI4FjjgprU0/J4MQTS+f+PGfYZscMdNRDCWR1t0WIVx c3AYZNDHPpy416tfUu1G8zyv+V5cHRVfZUkxDgecHomcrjiQOfdqM8UBMQ45cbWzCGWg zazDiDbvm/NDMfZ5l46WEPP5xf3ZJEE02khGUMoA0I+Farvi51O+6Fjs67U3wM2t0sYP UvaWxSVyLhvlrXHXhkJaaiWeJP08MiOSdk9+b0BT/JDvEaH9PkTyGBOtI2scLGj6ZLUw C7BNEi67o0WAh7eP3XlaqlT/lfu1VH6+MEYj+lmbNrPqbklHTYrA4qcuJHuwBRb7NHlR s4RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j+XlP7a4AbJnWW0mvkyBXtZwa/N1Rx2itITpw13S/3I=; b=5R6hiehh06SDNl5eA4rw0jbOP9ibzOCYQXLZ0PHt3gyLr/3ee/v6DwhMzUvN6VyTM7 Aupvr+4rrdjyNo6T4xnMHZgcFtTli7575+qd+GlXqUNRV5ktOb5TwgYQxVbQyoJmJdzZ 94YA7NTTbCUX0EvnRDfwc0UBODGvpdtz7A4dS32ezC5lh5Z1qxnipqx9SnfReONbbnwy cRjA9mfAClLGoQ+u5Alcmh5Wdxs34y9ZCgn9Jx9o4+/f3w4bpeV9n8YZ5cuH8Z8Ap9wK layXRdIHtR6cjVcNsaazm158d9D8tkzpjuDUtRf7bydLnhS2fcK8+Yj2KiR/j0c2f33h K8zQ== X-Gm-Message-State: ACrzQf1/v2PYN+yKfXMHMgbqYpkCUTXdqVYQjX+d06Jzl4pwtI41hIgA bIuB2ggTfaD313Ixsw3iwnI= X-Google-Smtp-Source: AMsMyM7R2vC6Qn5IEDHgIQVREy/czJWxFA0KW9eqPauuVPkuyU3SUmM3xBqqup3gi735DjAFHPyrow== X-Received: by 2002:a17:90b:3e83:b0:20a:f3dd:3e2e with SMTP id rj3-20020a17090b3e8300b0020af3dd3e2emr3106527pjb.191.1664993037711; Wed, 05 Oct 2022 11:03:57 -0700 (PDT) Received: from localhost.localdomain (c-67-174-241-145.hsd1.ca.comcast.net. [67.174.241.145]) by smtp.gmail.com with ESMTPSA id y17-20020a170903011100b001788494b764sm10674639plc.231.2022.10.05.11.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 11:03:56 -0700 (PDT) From: Yang Shi To: mgorman@techsingularity.net, agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] md: dm-crypt: move crypt_free_buffer_pages ahead Date: Wed, 5 Oct 2022 11:03:40 -0700 Message-Id: <20221005180341.1738796-4-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20221005180341.1738796-1-shy828301@gmail.com> References: <20221005180341.1738796-1-shy828301@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664993038; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j+XlP7a4AbJnWW0mvkyBXtZwa/N1Rx2itITpw13S/3I=; b=MUTePWrJqBLgNSCUnraCu2LnSp1shaDsvnq5yATrIzItYZG8sKOyO8C9Appgf3sgN3z7ST TZKWq6lyHtRlanDerqUweB394VQxXuRdqI9duR6HJ2N8zSm5/HtaV58mah/bkZVfeWBa5R myY0vjUcRbm3GlqPlbm7otugPXWFcc4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="irYlT/WC"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=shy828301@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664993038; a=rsa-sha256; cv=none; b=nZKxKL+u/JfY33F4otqagBF07bmMdQG++bo5wiGm2bNDBiLpTdv1hX91JE1ec6l2fLXD/E InCxZXafflMe86q4s4gc6KAVe4DXaz4cHgNUR35xIfeKUiJSPoLT1o8OpNeAqgMM07C5qv VMaRStnVoqgo9QsR7CJb44iu5KpT69k= X-Rspamd-Queue-Id: 8934B120022 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="irYlT/WC"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: q8fe6windze4gy75fq5n5589cu5yb4kx X-HE-Tag: 1664993038-764174 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000024, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With moving crypt_free_buffer_pages() before crypt_alloc_buffer(), we don't need an extra declaration anymore. Signed-off-by: Yang Shi --- drivers/md/dm-crypt.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 159c6806c19b..85ac1f9b37ae 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1639,7 +1639,16 @@ static blk_status_t crypt_convert(struct crypt_config *cc, return 0; } -static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone); +static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) +{ + struct bio_vec *bv; + struct bvec_iter_all iter_all; + + bio_for_each_segment_all(bv, clone, iter_all) { + BUG_ON(!bv->bv_page); + mempool_free(bv->bv_page, &cc->page_pool); + } +} /* * Generate a new unfragmented bio with the given size @@ -1707,17 +1716,6 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) return clone; } -static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) -{ - struct bio_vec *bv; - struct bvec_iter_all iter_all; - - bio_for_each_segment_all(bv, clone, iter_all) { - BUG_ON(!bv->bv_page); - mempool_free(bv->bv_page, &cc->page_pool); - } -} - static void crypt_io_init(struct dm_crypt_io *io, struct crypt_config *cc, struct bio *bio, sector_t sector) {