Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2188141ybm; Thu, 23 May 2019 12:49:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQODm7oTzAMgvEccOty94rvrCp4V+SY2WSygkybYc0wzoCN0Y+Wo0O36pEYcH5oGaupLvh X-Received: by 2002:a65:610b:: with SMTP id z11mr80687738pgu.204.1558640954245; Thu, 23 May 2019 12:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558640954; cv=none; d=google.com; s=arc-20160816; b=OIe8LXSpbkBFp7SJUtkAaoBv/6JWTstH4gVzW7OJ45gQU+R3ELnXawxBqPRpkyQBTf f7nqfkXAmbj8BQktKDXWYQ8xspHPLlPdDDlwUlzdrKasbOz9l/XpUaLYZqKzno/Lgmq2 lH30ayFVuWZf5/AhCV6sP8mUVKUHzbEyZwIfnkeV/E5+N33WVJl23tx6FXgxD2pIUpZY EXnN1PQ77dXEvBTg3bDCa87SJkeJ+3tXPiOyN5JDFNe2pPyUyhLd8yRXXrdPjib9ZesE odPFcodIGkPIjSI4hc45ibVGmwZmi+npLRqYotSgCrmxvXlFHzpTb2ak7YhcxsBPlPmi WQVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1I9QAr76s0GWDxjAT2yA7JJThSJzdCQaeFGI8LuZ8v8=; b=THxLNk3Eugcisk2lbC+jkCI2XQ61kjeVIIdiv64bsskV2kSw2z7oiHmlOMhDvPzqGw vO3r59+q8Aqomp0RNsfBBXx/p1W5oWtoF0qE+RKjtroZk0lD3/Lj0JZ0azykjis5VvSp /XGhTM9TFp3KP8Veam3cIUMiCuldixoEyYUXcjPGVjw7JtUsPugNQE7AudewimmRYDGU ib0SMhChD5LAnWs23J9ADO1lSSOKZFXC1RVu3x8FTIWbY3iP+IQsDPIYYC8wX4w56Ewl 4KV1YcszuhbU+6vFwSQaefkRgfyT4wvit+OBe9W4OZOL7kxpn978g8dKOX0YwYosBv3r bAHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VkwCnqAt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15si520805pgk.260.2019.05.23.12.48.58; Thu, 23 May 2019 12:49:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VkwCnqAt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389086AbfEWTrx (ORCPT + 99 others); Thu, 23 May 2019 15:47:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731711AbfEWTMg (ORCPT ); Thu, 23 May 2019 15:12:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E95B12184B; Thu, 23 May 2019 19:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638756; bh=kxy0S+/6EGxRZ8fVxywLz6w0frDKayjYtMn20Cnr5vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkwCnqAtw9JXZxK80Y+I/97l2VlZYz0Cfv8/U9om1rGE+fovrFQV/C1X13ViulYGC UK3lRYCMkxrhoZmOBm4DbxlyE0+UnAG/reY2GQT+z2+jgr5cjz6zSGRVWUbMfkLUkX a5Mwt3iyDpSeJ1ujc21QBL9qy94ZZELM5dJv4T18= 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.14 53/77] dm cache metadata: Fix loading discard bitset Date: Thu, 23 May 2019 21:06:11 +0200 Message-Id: <20190523181727.349202000@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikos Tsironis commit e28adc3bf34e434b30e8d063df4823ba0f3e0529 upstream. Add missing dm_bitset_cursor_next() to properly advance the bitset cursor. Otherwise, the discarded state of all blocks is set according to the discarded state of the first block. Fixes: ae4a46a1f6 ("dm cache metadata: use bitset cursor api to load discard bitset") Cc: stable@vger.kernel.org Signed-off-by: Nikos Tsironis Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-cache-metadata.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -1166,11 +1166,18 @@ static int __load_discards(struct dm_cac if (r) return r; - for (b = 0; b < from_dblock(cmd->discard_nr_blocks); b++) { + for (b = 0; ; b++) { r = fn(context, cmd->discard_block_size, to_dblock(b), dm_bitset_cursor_get_value(&c)); if (r) break; + + if (b >= (from_dblock(cmd->discard_nr_blocks) - 1)) + break; + + r = dm_bitset_cursor_next(&c); + if (r) + break; } dm_bitset_cursor_end(&c);