Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1258920pxx; Tue, 27 Oct 2020 12:03:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA0o+rWPLUiLztfB4mpH17aHJ+EvzHK00plihYfBC+8/HMaECcJ+C0OvFD/Ufed6JhEvRf X-Received: by 2002:aa7:c910:: with SMTP id b16mr3712112edt.286.1603825399808; Tue, 27 Oct 2020 12:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603825399; cv=none; d=google.com; s=arc-20160816; b=gq4LkJBqgZRSDLvhETDC++bYdpd9X7Nc9awN7OjMjfRrcPNE8jdjgi8Y6rLa9eBVCF YhpGhDZW/pzJUYWjAMqZTg35xTT/X2MHmyyeRlD6Xz4roi+Nd6ChGGACpNCO5VXn/Kyb mFAu2Eoqf1wens4La6aRKQ0mRrYXO7vPYPrXY/JoAFC7hstzZ0DDZTsf32LvZwjrznU3 EXPdEhgANdQCc+Y5jTG72ymEamJ3zSsS0vB+qdNfSfcJILsOWO4L+bzJNwOkCu4ugStL yPAeC0VQVanVRLZDtgsbXLQR+Rn7qfZ1u4mU+qx0M2aCdr76pHGYm/ZuW2I44mUeC2Qi LQqg== 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=BE8LMk4TK883mN87vaTisLYx/OfzF8RriObpZem5HCg=; b=u/vcGYKgOkjuc35s9pEeuTq1cJFtE10F8JHz1TI9sG7JyHTcRFQ0tvmITMKRjh2oJT ZiMZi3iAgUYTQhcVHVUEVGf1EnzYr81SJHACt/YD+1jUTa8FvS2MQO0c87lbHif6kJ3B 2RYh/E2lHZjCgcMSrzyAR84Xc/rBYtooIu05adzsEr/f+wFPBlRUUIe09YOPBXzUQi3Y orU2Sicvo8E6RpyT+biEME3XJcYMZ2JiGT6IdGGkJ4H6Bhn620YflwZGRjYm9L0mTJkv YRNYcS4tnjy/LF+FOGqH1EOK9+oayuPnBHuLzz94Ah9wCDtIZwyTFvkWxP70CFl/t5/b cXng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KsrssXK0; 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 s13si379516eds.195.2020.10.27.12.02.57; Tue, 27 Oct 2020 12:03:19 -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=KsrssXK0; 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 S2502010AbgJ0AjK (ORCPT + 99 others); Mon, 26 Oct 2020 20:39:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:50966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409228AbgJZXuz (ORCPT ); Mon, 26 Oct 2020 19:50:55 -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 1A7FD21741; Mon, 26 Oct 2020 23:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756254; bh=YJnQu0a/mHSLYZusbjZ7E7CxSh2AwFB3Vvkd0QXN0nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KsrssXK0386bV7RxGH+hPeeaebZ1y2WqCMDS2HqFQSxoSASKGhRLIN0nrSUtUkjog 2/ZlAYVmOrTKUs++5vgz08uZRT2j6qmWGlHG+ZiaIb7MxEy2d7ISdSzRxD5qBDN+TT +ao3iU1f1i3RLHEIdq6WZiRnWsZ7N5pQ8VaUqOwk= 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.9 089/147] dm: change max_io_len() to use blk_max_size_offset() Date: Mon, 26 Oct 2020 19:48:07 -0400 Message-Id: <20201026234905.1022767-89-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-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 6ed05ca65a0f8..3982012b1309c 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1051,22 +1051,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