Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp306580pxu; Fri, 23 Oct 2020 00:52:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJvEob8U5+niki7DFuL/u5PFxf6WGJRcv8oeTPkmfeLWw+KQpnslJK6NPLpIOjnsXNplIX X-Received: by 2002:a17:906:6004:: with SMTP id o4mr730310ejj.309.1603439557638; Fri, 23 Oct 2020 00:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603439557; cv=none; d=google.com; s=arc-20160816; b=jHJhpkK5LdWiYuOPJ64lUx6e5Z1x3KdAjag22MQZUFYdhfqKKs32XCEpO1UqAZ0+EU QW+hqjEX8Wi6nHL1l28sGjHT/pD7iWZ9jrqrVrKTwI7V7OuJ+P7n+au1TPRdnaUfTCmi /sIIh7hkI3/2SuHDNfUgRFSzya+ngRyMte1LePuNa+I92RiIY6p8F2k0RART/mr/WpvL h/T+jcLi4ZunBaurZnevDE7uAOpKKUoS+tKWrmnj/La/nwYhwO6vgPAAmHnQqWnXO+Tq B5W9O74umudzytBC+unoNouLqprrGPi3c/skoZBLCGzJw6Wh41Qyo2xt3s2PRA23rLXG 9nlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=kVOU56vMIKPwRdSa1DX4NgPyTaBBOM7ISpZAf+v+NPc=; b=hrhiZw2LCXHYiePOKRSCJcX+E8M2Skne6Kc3AGfaSuSr1tQXHWIkmnE+/7NIqon75y 7zpqzo76g0svURQWMm+An0yimRhnTuJgsr53fVyTWMRjzmQkUtzxZ+nl5a6Hu+XlXh3t +OF8vFekFr3MJonCpmo2jwd8pV2nXipEzEvTPZd5NHXC/Ff6Fds2AJe1RB0+pKB40jpN NBIaiYeEV1Wgrye/PyDEd2PPCKXJ1YTsMsDmoYJHYWo68z0P5Asa7eVh1YyJr8gZFLay oXq8WH+RZLMvUNZ2Tz2EUrbvLguPohy6eKw/7Vv44xgZMRspDTVDIrZaT63jqrf1pCoM n9bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@drivescale-com.20150623.gappssmtp.com header.s=20150623 header.b=FDqHw2Ab; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si395994eju.580.2020.10.23.00.52.15; Fri, 23 Oct 2020 00:52:37 -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=@drivescale-com.20150623.gappssmtp.com header.s=20150623 header.b=FDqHw2Ab; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S374855AbgJWDbq (ORCPT + 99 others); Thu, 22 Oct 2020 23:31:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374872AbgJWDbo (ORCPT ); Thu, 22 Oct 2020 23:31:44 -0400 Received: from mail-vs1-xe63.google.com (mail-vs1-xe63.google.com [IPv6:2607:f8b0:4864:20::e63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4874AC0613D2 for ; Thu, 22 Oct 2020 20:31:44 -0700 (PDT) Received: by mail-vs1-xe63.google.com with SMTP id r1so110609vsi.12 for ; Thu, 22 Oct 2020 20:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=drivescale-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kVOU56vMIKPwRdSa1DX4NgPyTaBBOM7ISpZAf+v+NPc=; b=FDqHw2AbeHw6eX4xu+NIjrtMPLcV35cn+OI5XXsmrMmacbgmO0nReXcxT9fALCsb4J dmRS1nB0hZaY/g4t9LFwCbv8qZzbt2OMSGH8tGHpn4p2zme0ya5sWPWYfOKXJ4QcPu2a HzY6USAQHcs07Ex4HUobYzn6uMa0oyfATmauyOnRYIOPUzQLcE8UcpmDHSBr2C1rXncV i2V/gIdf5ZeJ+Dr8nSEkugfpzi7PVptZWpDjt+iQw/hgaS/31cl0Yy4VppT2vDls6KFQ K4rVQw0d04AqNw/Nc4CGCniUENd2mYMWrANS3Epp+JTm02OBYnOMJHq7Qp+oJvqv/AAc O7DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kVOU56vMIKPwRdSa1DX4NgPyTaBBOM7ISpZAf+v+NPc=; b=olGKGhF6XmSk7Me0sy69h/l84fbeCHARMA4PLB7WShCpvgqEHq2iB144Az1BVkKuwS NCKVbDV9DViJwMuzg6YlEkoSJ0jHUBS5v+EWX5uRxq7h+WZb+iJPeBPoXqxQn+t8xoVK NR0t6UJx6btAWpR4q/md8kLRT1NzB/M+9WSsQWpX/Q78w2xHzVQqtXvyfxCtHCcqI+sH +vieg+1q5INVVT3DJvVGGTqUEu8jxuMfNa7x2yS4sT2vs41qpeEPcAWe8ebhxRCr4TQt XgqoDw1oXLgNTdw06UXBIMtaSQ1WBjbzCNKqW0b+NbWdY1BLDmbOWM08E6SWPEWGIUfM goJA== X-Gm-Message-State: AOAM530nhUUlVoLEo8OK8fB1/t10LrttAy5BOdJMGY6oXTESzWgF1U8A u5xFt+ZevCG+yUFmagwSyH44ip18iejlB7WwOIa+8WMTE1wwvg== X-Received: by 2002:a67:ea4e:: with SMTP id r14mr205149vso.47.1603423903465; Thu, 22 Oct 2020 20:31:43 -0700 (PDT) Received: from dcs.hq.drivescale.com ([68.74.115.3]) by smtp-relay.gmail.com with ESMTP id h12sm41939uar.2.2020.10.22.20.31.43; Thu, 22 Oct 2020 20:31:43 -0700 (PDT) X-Relaying-Domain: drivescale.com Received: from localhost.localdomain (gw1-dc.hq.drivescale.com [192.168.33.175]) by dcs.hq.drivescale.com (Postfix) with ESMTP id 891494211A; Fri, 23 Oct 2020 03:31:42 +0000 (UTC) From: Christopher Unkel To: linux-raid@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Song Liu , cunkel@drivescale.com Subject: [PATCH 1/3] md: align superblock writes to physical blocks Date: Thu, 22 Oct 2020 20:31:28 -0700 Message-Id: <20201023033130.11354-2-cunkel@drivescale.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023033130.11354-1-cunkel@drivescale.com> References: <20201023033130.11354-1-cunkel@drivescale.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + } + if (sb->level == cpu_to_le32(LEVEL_MULTIPATH)) rdev->desc_nr = -1; else -- 2.17.1