Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp628015pxx; Mon, 26 Oct 2020 17:23:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC9NjoN52P57T4D1zOXVGLvHa0fpo8j8DEWbC+nnCNGYGqSfxQeaNKQ2sibDcCnWq7J9Wv X-Received: by 2002:a17:906:b0d6:: with SMTP id bk22mr17902883ejb.153.1603758214682; Mon, 26 Oct 2020 17:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603758214; cv=none; d=google.com; s=arc-20160816; b=a6oB5YgF9OcVic052goBtSP6sYLDwN5S55f37fjVtKMElZ/qplO0omlZ9EDQfTlzCZ MNf1VxzylUeqsIcdBGx99R2guPq0dpxfN2HjH6KhUGDx+Bk9GvvJZMLkNSKi2uEydCpu +4ODhRNmGR2/UxeNoi+9wDN6vAOh+zFZSMZGuyR6gJ3Ev+G1kn9fUIdUPyEOD1FNoHmb OEkNRAH8VnfRcvRhs5TRRTEvOIa+8XLkyAc9R3rzv8yu7w0x4Zml7SeCkuzaDynXrvsb ZN29T6kidcS9HbrgQwgJ8IQMjODLeZHvLkkfC19MackQMUWjs7JnDDmYtZSzh1AaxWsI A7aA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fEZ8iUXGDMaSpRREQ+7MxR/VtjBLKZuWI6B+Mbvh49E=; b=OgsaLR4TVMOU+2kTQKcmGHkEPU3qLkomwhf21Qb7hoQUUHSpZhHQTbqdjq8cIhKev/ Z69k/pzHYKgTxDEtLyU0zOWdSooOX6nfcML9EmeNNKzhdALmSX+pf4yOAvCovzorsx7E 0Oonc56UmzjRzq2OEbjFbWcVk2wDbgpoG+2IWohTNtgO1nLfdA4yfPPT3bG7yJAshRpn 48hX6PULqJl8AtPbavBdIxmz7R9VEFeEh/f//7qi6wFSzzW3Q3e4yemh7RupTc0MeBJq tqIIb3IMI8BRDdQtRCphYhKpuVcKVua9GFoJUVJp6pYNML3paYWd+2iLTFpRAdWWEBIw pJRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B+9gQUDp; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si8098338ejx.308.2020.10.26.17.23.12; Mon, 26 Oct 2020 17:23:34 -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=@kernel.org header.s=default header.b=B+9gQUDp; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437464AbgJ0ACp (ORCPT + 99 others); Mon, 26 Oct 2020 20:02:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411068AbgJZX4P (ORCPT ); Mon, 26 Oct 2020 19:56:15 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE53C22202; Mon, 26 Oct 2020 23:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756574; bh=KI16gIgQIavrgntmemVYokKWvsvzyiMx5iY8E7kgEOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B+9gQUDpby8IbkovNMtJ4brpY0tIWqli1a+EspTwEekwsTvtFJs9Rz7qTKFVN1IHQ ZzrVhB2MwDpcJQUXZp2mujNWm8BUhqgoi1mLxesv6ZApShqO6Lwm+IQ9t1Wyn8oNFF jP7QZ6COidWoXgSCqUZ+weKjO0c+fyEnAknVR21Y= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Snitzer , Sasha Levin , dm-devel@redhat.com Subject: [PATCH AUTOSEL 5.4 48/80] dm: change max_io_len() to use blk_max_size_offset() Date: Mon, 26 Oct 2020 19:54:44 -0400 Message-Id: <20201026235516.1025100-48-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Snitzer [ Upstream commit 5091cdec56faeaefa79de4b6cb3c3c55e50d1ac3 ] Using blk_max_size_offset() enables DM core's splitting to impose ti->max_io_len (via q->limits.chunk_sectors) and also fallback to respecting q->limits.max_sectors if chunk_sectors isn't set. Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 667db23f10ee1..eed2337934eba 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1027,22 +1027,18 @@ static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti static sector_t max_io_len(sector_t sector, struct dm_target *ti) { sector_t len = max_io_len_target_boundary(sector, ti); - sector_t offset, max_len; + sector_t max_len; /* * Does the target need to split even further? + * - q->limits.chunk_sectors reflects ti->max_io_len so + * blk_max_size_offset() provides required splitting. + * - blk_max_size_offset() also respects q->limits.max_sectors */ - if (ti->max_io_len) { - offset = dm_target_offset(ti, sector); - if (unlikely(ti->max_io_len & (ti->max_io_len - 1))) - max_len = sector_div(offset, ti->max_io_len); - else - max_len = offset & (ti->max_io_len - 1); - max_len = ti->max_io_len - max_len; - - if (len > max_len) - len = max_len; - } + max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue, + dm_target_offset(ti, sector)); + if (len > max_len) + len = max_len; return len; } -- 2.25.1