Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp305707pxj; Thu, 20 May 2021 09:43:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0xv5E+bX/0jNq9eFz5fJweB4bSm3iuzT7Y7ge8Eqdg4weyR5NEPJRyiHa04H50d7Vmy7f X-Received: by 2002:aa7:cb0a:: with SMTP id s10mr5913293edt.36.1621529027464; Thu, 20 May 2021 09:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529027; cv=none; d=google.com; s=arc-20160816; b=u5jrZWy3Pk6uqUIWQ1sXGCyza/bRN1y0btVIFNaCEdVYNhpeRMlrXLq2uxK3btFAzT AhE0qa14p1mJXfydgsCs9h5blsrdY1l0KKjunBa7F2ozhKmfOt1KheHKLPoGwJl0uJPc cXZnCgtPMII3dyATCOmUuNxP3QaaxRGb+Laux7EvTKoUHm7RsShVU3QEqLdkyxOar4CQ NHuOpqaZwLXZNDZhNP+SwvfbpYXeOL5XPXtt6W0rtqgc2GkDSaWWzM/7fQVnoCoqvW0o dMpKCNg2qHeP/KzrXZoRPqhEOsTf90YegfarACRz4OgKG0YyDHi3bvUpK2z+GUOQbj3c g18Q== 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=K1n6gzPAZ7i6ZBOjtaEXwiT1dSwKIQdoqFajDPjtFDQ=; b=jbnxWgr4c7j29sjCbBtlf4LyoNprQrmR3UOmfwdZi7ODCSZ1NtejjAV8zaarY3WEtR a1RwD7WrwcZ8W5zrjDCuQELSEGwkai5UJntHREROcVFJkMIq9e5FaR+1P6VLuKfG3LNL Yp/NcJFwMAZnXKHayzLllhKUp4i2ZXS+vp1W2g97/nsIWN0ebohTZoBvYfgVZvp0Vpxh pydwDFY8/rfN18aecaijLqNek7qq2yjf3cabF7fsOIRj7oX8l72z0Jz34ufNXPi4Bv7X w/Xgv/5TEKSfkDt9BWFpDflyhe385+Jrmua20sb+4qZ88VUQjOcFr0YG06G7IUjIQcCR KDrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XlsMa0Vw; 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 h14si1652206edr.526.2021.05.20.09.43.21; Thu, 20 May 2021 09:43:47 -0700 (PDT) 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=XlsMa0Vw; 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 S233641AbhETJrt (ORCPT + 99 others); Thu, 20 May 2021 05:47:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:48004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233320AbhETJo5 (ORCPT ); Thu, 20 May 2021 05:44:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 945BD61451; Thu, 20 May 2021 09:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503206; bh=6qMJiWZ3pEETEodCSZjOD1Yryzg/jRm6fKQC5tedRcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlsMa0Vw6l44lfMCOk6U1KGRuLb2iSwDYmCJfouhGydKzv0pRHg+rozOsHKGm8hu2 BpVR/zgW5WSHVfb/QyuCrEOY09o/hqbAy06qj1p+xW2YrdXoObAMbwjCXk3qzG1a0h h5UAYkk0JdpE9xl3HjAg8H/156FllIaABfwFLpK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Thornber , Ming-Hung Tsai , Mike Snitzer Subject: [PATCH 4.19 117/425] dm space map common: fix division bug in sm_ll_find_free_block() Date: Thu, 20 May 2021 11:18:06 +0200 Message-Id: <20210520092135.288867806@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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: Joe Thornber commit 5208692e80a1f3c8ce2063a22b675dd5589d1d80 upstream. This division bug meant the search for free metadata space could skip the final allocation bitmap's worth of entries. Fix affects DM thinp, cache and era targets. Cc: stable@vger.kernel.org Signed-off-by: Joe Thornber Tested-by: Ming-Hung Tsai Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/persistent-data/dm-space-map-common.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/md/persistent-data/dm-space-map-common.c +++ b/drivers/md/persistent-data/dm-space-map-common.c @@ -337,6 +337,8 @@ int sm_ll_find_free_block(struct ll_disk */ begin = do_div(index_begin, ll->entries_per_block); end = do_div(end, ll->entries_per_block); + if (end == 0) + end = ll->entries_per_block; for (i = index_begin; i < index_end; i++, begin = 0) { struct dm_block *blk;