Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp309815pxu; Fri, 23 Oct 2020 00:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygVAl4+IER8AAwkMMJsfE7ZAU86xvuPJYtSgZg+BykFoU9MoAz/ojTRlbq14X85xI48dke X-Received: by 2002:a17:906:b055:: with SMTP id bj21mr784998ejb.334.1603439989306; Fri, 23 Oct 2020 00:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603439989; cv=none; d=google.com; s=arc-20160816; b=L4GBoEjB1/DH9lQCjVHGSIZWd525Bx04CjTsPg/VBBS/W5R6ar8aBMCYgrJ8/DUcew ME9/AjxV0gc2EQmTf5XqtnOJYbAwpdyefNM4C21RaDUnLIpBFjZ4fEAja2rjb+bsp7Sg Z4WmIhw3rpB0+H8hSyg3+z8STTAsAJ+zcna06VgSYlmLn+91fosDNskzvLeZgE0iz07L 6gzC7eOFr1npZwq0QCSa1jVe0rvqADQpN+56OiDpb0jzNckNPgVl93NKYib2FOG4GiuP wlk9pNsRvah8HTj+4F+YJLtkq6hGV5gYH74F6dNyx5+1Z8ZY97JHMwvZsvenidprfFNY 0ctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/2CABikAaCtPBaTYm4gbu0i5NqyOFL2kA60JTkx+PYI=; b=ph6YtyzMI9Kfim6DfZIMnPWtCBsvTU+WtJUgNQ7N2IKqC0zuFnLY272C0Ov+vyabc0 OI/aipp1mYog+h4QvYnAWPlsiiDq6ODVC/Wogt/foYNv0T1QOTITqywou24sydM6pwBM exdi04zjlWjRjUbheGR5shEZBkt5vPhw1NCAD0Rmg1c/gRpZygXrbXJCKkv50b6X/FAU R+TW2d3rHpm67UYr8P/HqLbTgIIDg2eCFBGY33Y8Qtcv5iAWUOiR3acaTLxqR8JIVR7p sxOxpCEDVMYCE2/GTFUDZjOXrumhtnQs372Amb2scXtHt0CrAD7R53utDsN2NfUtJi7r cPIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rWrQbXab; 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 i19si384872ejh.153.2020.10.23.00.59.27; Fri, 23 Oct 2020 00:59:49 -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=rWrQbXab; 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 S371662AbgJWFqb (ORCPT + 99 others); Fri, 23 Oct 2020 01:46:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:59156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S371656AbgJWFqb (ORCPT ); Fri, 23 Oct 2020 01:46:31 -0400 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 EC2C321534; Fri, 23 Oct 2020 05:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603431990; bh=oQ6/1NIou2TcFImLpwWF3gr7pTLz587r4JuuStq4BDg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=rWrQbXab/RpNL5qcRM8r2BFSprfg0tDmdcR+KDPvBmSZ5BlU6YUTXyHINt8n+51qn kLjXQWo0zgY2KF3fhzf8jc/p1A1ehzePZcHOKwIpkPeWdX2Ow12ZPBeoADz82fwPYi 3xpwEERpaFTgU11bAw2we/QGoLBBom7rmY6D2phA= Received: by mail-lj1-f169.google.com with SMTP id p15so252611ljj.8; Thu, 22 Oct 2020 22:46:29 -0700 (PDT) X-Gm-Message-State: AOAM533MvHmbZQbCBpADUp6uFseeclKfEUjnZd9YR3BEdt9mA5MDcxfU Y/zrwCCz3IO+N9z8WMPOsPfJ+twIp0DUE1mHSnA= X-Received: by 2002:a2e:808f:: with SMTP id i15mr201106ljg.10.1603431988136; Thu, 22 Oct 2020 22:46:28 -0700 (PDT) MIME-Version: 1.0 References: <20201023033130.11354-1-cunkel@drivescale.com> <20201023033130.11354-2-cunkel@drivescale.com> In-Reply-To: <20201023033130.11354-2-cunkel@drivescale.com> From: Song Liu Date: Thu, 22 Oct 2020 22:46:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/3] md: align superblock writes to physical blocks To: Christopher Unkel Cc: linux-raid , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 8:31 PM Christopher Unkel wrote: > > Writes of the md superblock are aligned to the logical blocks of the > containing device, but no attempt is made to align them to physical > block boundaries. This means that on a "512e" device (4k physical, 512 > logical) every superblock update hits the 512-byte emulation and the > possible associated performance penalty. > > Respect the physical block alignment when possible. > > Signed-off-by: Christopher Unkel > --- > drivers/md/md.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 98bac4f304ae..2b42850acfb3 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -1732,6 +1732,21 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_ > && rdev->new_data_offset < sb_start + (rdev->sb_size/512)) > return -EINVAL; > > + /* Respect physical block size if feasible. */ > + bmask = queue_physical_block_size(rdev->bdev->bd_disk->queue)-1; > + if (!((rdev->sb_start * 512) & bmask) && (rdev->sb_size & bmask)) { > + int candidate_size = (rdev->sb_size | bmask) + 1; > + > + if (minor_version) { > + int sectors = candidate_size / 512; > + > + if (rdev->data_offset >= sb_start + sectors > + && rdev->new_data_offset >= sb_start + sectors) > + rdev->sb_size = candidate_size; > + } else if (bmask <= 4095) > + rdev->sb_size = candidate_size; > + } In super_1_load() and super_1_sync(), we have bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1; I think we should replace it with queue_physical_block_size() so the logic is cleaner. Would this work? Thanks, Song