Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2341001imm; Thu, 11 Oct 2018 08:47:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV60nNAY414n2EOB0FtHMclsS+4vNsQOyUJVPSJvV6VhMakHr2U/rMLuLYD21zua0IPE8SBlR X-Received: by 2002:a62:de05:: with SMTP id h5-v6mr2109188pfg.258.1539272828761; Thu, 11 Oct 2018 08:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539272828; cv=none; d=google.com; s=arc-20160816; b=E3D8wR/5+8PJMYL5SPomnvKgVoQQqq1yMpfPgdY3SbcVxdY5gQqmlfssx+6Qii0ubm wkF77qu3ytfqRhbdZxWWkPzq+enOaPOImpiOsXj8Kq25X39dpEcETZ5UHrbwxGwJ5I3Q o6qWXp1EnH2LcFpD9entrCxeCCbna4ZPXDhzT7qb9fFY16RszhA3dW9DeiXH240ZkPi2 5UPlWpeGW2r5loEAf2LPey3ZeAcRvRGtS3pnJuijo4fmtcWaMOUPNooOjrWSTY0KJd3S F6dk2JVgXaBQ3MiD3J76nKYs2F16BPlKi1nvt3YJ5AXY75DDFcvo8oYo2W4BYsv6m6dm R/5Q== 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=lUAoJW65ZJItgvt7mWZlFOt11KeTnZipEsmjhQAY9JQ=; b=yx0Nex70+kDWc7SOR0N5ms8TJvZL1WuI2Jfl5TSTe+unw5eCa4tqv5qwRUwAcGypN4 BGPHjQobZaswUZCwhn+s+4G5rJv8P3hZmr/GKQj6rLAnSpQTNnSQaT/eDCCujQch3u8/ aj/W80C7b7VgITEoXxQ2hHhR+CdrvVaXwhbdik64YQOcXAqvzZg95i/p0xpTWfUllAQZ OZHI3zzdL3YOPXS2HoQmUTwdD8rLH18ThOq0GoaMcbzqAkqRc5OAFsTeMzpcUsuY7MiZ FoFS60X7LItuhQH8YdO24iGpAuKP8mwnN/qBqpr6Lbk9+S407MHBnEi1Rj7t9hR+otva b2ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ha7U/HSO"; 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 33-v6si25421808pgv.588.2018.10.11.08.46.54; Thu, 11 Oct 2018 08:47:08 -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="ha7U/HSO"; 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 S1731363AbeJKXNV (ORCPT + 99 others); Thu, 11 Oct 2018 19:13:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:45886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbeJKXNU (ORCPT ); Thu, 11 Oct 2018 19:13:20 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 634E220652; Thu, 11 Oct 2018 15:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539272735; bh=1QVX1sAFTQSh1x391XkcBDo1l/w7tmsCuCsZ4ojsQQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ha7U/HSOPfwSbEYrm1w5iKiIGMk+3dY0bFxwWBrFtdhTljLQDZsylnZAzqTFGOFti NNoa7PLem86zBI0oWrxIHiJ4523bQjXkGkpaPwcBwhDGHoihTdnpMB2UTypdeID7Gi T1XmUEyNpfAjIDfdMwcCdiabuMrIYpVQWKIaB+Bc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Snitzer Subject: [PATCH 4.14 20/45] dm cache: fix resize crash if user doesnt reload cache table Date: Thu, 11 Oct 2018 17:39:47 +0200 Message-Id: <20181011152509.739306793@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181011152508.885515042@linuxfoundation.org> References: <20181011152508.885515042@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Snitzer commit 5d07384a666d4b2f781dc056bfeec2c27fbdf383 upstream. A reload of the cache's DM table is needed during resize because otherwise a crash will occur when attempting to access smq policy entries associated with the portion of the cache that was recently extended. The reason is cache-size based data structures in the policy will not be resized, the only way to safely extend the cache is to allow for a proper cache policy initialization that occurs when the cache table is loaded. For example the smq policy's space_init(), init_allocator(), calc_hotspot_params() must be sized based on the extended cache size. The fix for this is to disallow cache resizes of this pattern: 1) suspend "cache" target's device 2) resize the fast device used for the cache 3) resume "cache" target's device Instead, the last step must be a full reload of the cache's DM table. Fixes: 66a636356 ("dm cache: add stochastic-multi-queue (smq) policy") Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-cache-target.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -3097,8 +3097,13 @@ static dm_cblock_t get_cache_dev_size(st static bool can_resize(struct cache *cache, dm_cblock_t new_size) { - if (from_cblock(new_size) > from_cblock(cache->cache_size)) - return true; + if (from_cblock(new_size) > from_cblock(cache->cache_size)) { + if (cache->sized) { + DMERR("%s: unable to extend cache due to missing cache table reload", + cache_device_name(cache)); + return false; + } + } /* * We can't drop a dirty block when shrinking the cache.