Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp418153pxb; Wed, 3 Mar 2021 06:37:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwotZyofphBUejTBpQ+nT8zCA18KNMnalv/U3r4xZQH1f1hRGij2RCr4/sf4xa9dY84Woi2 X-Received: by 2002:a17:906:18f1:: with SMTP id e17mr25320033ejf.372.1614782246248; Wed, 03 Mar 2021 06:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614782246; cv=none; d=google.com; s=arc-20160816; b=FnLaEkCuOgamXZBrJiUosOCfnCW0YuxEXjJPxed4gS7bExeDmL3ly7QfDYzLg6Be4e AFGiu7N4M0hekrGdQp9Sz3Zqopeyo0DAjhuUPjF78cgT7TMCld6tOefvlg1ID+09AYQ1 o8EzZ9QBuAY3tm3jYfrNYp9LewS8Yz11PmSvmqh4A+5gQ3OtqfoIcptGIorIkUYDFOe/ KaPbmqSKAyWFa6xN1houm4ZIClRw9rTyZUaAvAVxB1CeLmN+kIJALpTf7KRF/bbKvQpp aQVqWmVXPD1ZxCxhU1COZtUZsejVMXPCUHs17fU4TyPyL89APIMYfb8CgC9Kx/ilWJS4 XP+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p9RjBU5Es+lA0NNkLbz49fYFktcDYkIluH4ja2TAr1Q=; b=0Etr772SMnYnuZmF3F0Dm7LxiGmR/jUAx/oExCA8C5smZYRZdz9017gDRRyOkQeDO6 ygKr14fPbHw9u3diniONOZL3lb6n61Bhz3RW8ZRmaWo5FZGyq4Ke3//5UNCh8hrDNjq5 C+y8mD4a5WRx6wjuKFgJeMd6pDOrZ32zzHV7L+CPYYCPY/b538rlz8Hew65iJJMcsj2+ sMHdUfs9UWHg74/x0GPlR/UIzuhFR5Raf+f0hOfZGiXrI+DDRAZXe5FYN7LJIxrKEsNi vADfczBMCfnARvE5ONvFO3qaeAYO+bZe1ZMHuZVyQ8nh73Qe1L9QElYXBE50o/pO6nty wX4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQ5SvqMA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si12380539ejy.571.2021.03.03.06.36.42; Wed, 03 Mar 2021 06:37:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQ5SvqMA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235763AbhCAVcJ (ORCPT + 99 others); Mon, 1 Mar 2021 16:32:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:36388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238018AbhCARSZ (ORCPT ); Mon, 1 Mar 2021 12:18:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D23864E04; Mon, 1 Mar 2021 16:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617200; bh=ipdAUUAgfQqx5yQxqKSJuMqKZ6LgBAWFHNauz6J3FcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQ5SvqMA7oZjENEJEFVN4IuH1uNyDyF7Jio1CslulT10n/9F+XdhonlFVMM2FEvab SCs3W1yDU+gL0b2/DYYRM6JttmDZd2rnocZo15NvZFUyPmSLJi36+PI2kv5JP4DwY2 bY5VyiZEBkqdakbWLLQTidv1vQyW/MxLDDXaIKXE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikos Tsironis , Mike Snitzer Subject: [PATCH 4.19 238/247] dm era: only resize metadata in preresume Date: Mon, 1 Mar 2021 17:14:18 +0100 Message-Id: <20210301161043.356012601@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikos Tsironis commit cca2c6aebe86f68103a8615074b3578e854b5016 upstream. Metadata resize shouldn't happen in the ctr. The ctr loads a temporary (inactive) table that will only become active upon resume. That is why resize should always be done in terms of resume. Otherwise a load (ctr) whose inactive table never becomes active will incorrectly resize the metadata. Also, perform the resize directly in preresume, instead of using the worker to do it. The worker might run other metadata operations, e.g., it could start digestion, before resizing the metadata. These operations will end up using the old size. This could lead to errors, like: device-mapper: era: metadata_digest_transcribe_writeset: dm_array_set_value failed device-mapper: era: process_old_eras: digest step failed, stopping digestion The reason of the above error is that the worker started the digestion of the archived writeset using the old, larger size. As a result, metadata_digest_transcribe_writeset tried to write beyond the end of the era array. Fixes: eec40579d84873 ("dm: add era target") Cc: stable@vger.kernel.org # v3.15+ Signed-off-by: Nikos Tsironis Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-era-target.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) --- a/drivers/md/dm-era-target.c +++ b/drivers/md/dm-era-target.c @@ -1500,15 +1500,6 @@ static int era_ctr(struct dm_target *ti, } era->md = md; - era->nr_blocks = calc_nr_blocks(era); - - r = metadata_resize(era->md, &era->nr_blocks); - if (r) { - ti->error = "couldn't resize metadata"; - era_destroy(era); - return -ENOMEM; - } - era->wq = alloc_ordered_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM); if (!era->wq) { ti->error = "could not create workqueue for metadata object"; @@ -1585,9 +1576,17 @@ static int era_preresume(struct dm_targe dm_block_t new_size = calc_nr_blocks(era); if (era->nr_blocks != new_size) { - r = in_worker1(era, metadata_resize, &new_size); - if (r) + r = metadata_resize(era->md, &new_size); + if (r) { + DMERR("%s: metadata_resize failed", __func__); + return r; + } + + r = metadata_commit(era->md); + if (r) { + DMERR("%s: metadata_commit failed", __func__); return r; + } era->nr_blocks = new_size; }