Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3118106pxx; Sun, 1 Nov 2020 23:45:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCjh95Mla9if1xqvLRlk2mzW7g8lvG+aXrGwxw1DclsidRoppCm2eUjxBv8aYcJS70DF7l X-Received: by 2002:a17:906:3782:: with SMTP id n2mr10003514ejc.493.1604303104297; Sun, 01 Nov 2020 23:45:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604303104; cv=none; d=google.com; s=arc-20160816; b=BYQxtgDraTezUwFuprxiGTQe9TvppicJ4qnn5KDycq+afWtth/1JtQnMymgfoBESPr AXHOG5DkLCYoA2E3Oh6yjh4AuPI0mm/b9vXX6Zg3ghXZnACKg4I7bFvUTgW1ytFbabTY UwJXmnrK1ZPwEWpAWq4Z6vYXkdumFWTjtcVegDqgrAeWdTEbAfyhiTycLlwtXgRPDDst vvyGAA1+OcYT0x0tAjVrfBxhVX7SIN3teTceJMdUQ2nXgj3xvYqwQLf9sTwkY2QeyeTF NsJhkVpNSL5y084YtV3rfkWdp7ie/Sc9c+5IbFDgrHa9ygOIWHA7kQtyOWhnGpBIMNCX J57g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qWIfKd9ZiQU29ZqGSlOhjKSzRATAwUeg5+eE8ZDGiys=; b=sY3PDZYUSVErbHU82g8v5peRr5sPBzMkRzdQUX8uUAdhR2WJQrFD0le+ShZbruGHNV ufv9mx+56/3TYajqUGt5wFO0EVoYHSd3NfmugXE4fLRj/zVLxXCOP/+R+6QkaSMmwM0k k3Y2oo+MwSo/ojnFY52sunuGO3vxlcDfip3Tfn6L79DpXjZf6mb66MvbR46cuP5FwglF VcDQDC4SWi23OjmYxRt3pi/VTnyBIcYJ4jETQdgNxCAnrNELlS6cgyxRiAadaD8bQC+T zN7dYc40zkNSSRq9J6X7+tVNs9BpCKrCwYm7D/aRQCVD5rvtWzEvUl6aPzLeQO7yzJ7E CrWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GqDV48Dt; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si10039646ejm.486.2020.11.01.23.44.42; Sun, 01 Nov 2020 23:45:04 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=GqDV48Dt; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728095AbgKBHnK (ORCPT + 99 others); Mon, 2 Nov 2020 02:43:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48152 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728078AbgKBHnK (ORCPT ); Mon, 2 Nov 2020 02:43:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604302989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qWIfKd9ZiQU29ZqGSlOhjKSzRATAwUeg5+eE8ZDGiys=; b=GqDV48Dtc7Rfq0MVHduzQEoK9Py95xu86UufvOx2om7ult8FFyCIKOElYVWBoi7d+EhxIa WKpuceSdA0SZlu7ThKucsvpOrHyve0coC19d3y1u2YecjoUM7ZpUNLqAX7XC+862cpMu75 656vz5udgZBIfBCuc43cScVmtjACtYA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-83-N2pcUwMWNBSe0q4XT1NJLg-1; Mon, 02 Nov 2020 02:43:05 -0500 X-MC-Unique: N2pcUwMWNBSe0q4XT1NJLg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 034C71018F80; Mon, 2 Nov 2020 07:43:04 +0000 (UTC) Received: from localhost.localdomain (ovpn-8-24.pek2.redhat.com [10.72.8.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AA305B4AF; Mon, 2 Nov 2020 07:43:01 +0000 (UTC) Subject: Re: [PATCH v2 0/3] md superblock write alignment on 512e devices To: Christopher Unkel , linux-raid@vger.kernel.org, Song Liu , Christoph Hellwig Cc: linux-kernel@vger.kernel.org References: <20201029201358.29181-1-cunkel@drivescale.com> From: Xiao Ni Message-ID: <265efd48-b0c6-cba5-c77e-5efb0e6b9e00@redhat.com> Date: Mon, 2 Nov 2020 15:42:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20201029201358.29181-1-cunkel@drivescale.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/30/2020 04:13 AM, Christopher Unkel wrote: > Hello, > > Thanks for the feedback on the previous patch series. > > A updated patch series with the same function as the first patch > (https://lkml.org/lkml/2020/10/22/1058 "md: align superblock writes to > physical blocks") follows. > > As suggested, it introduces a helper function, which can be used to > reduce some code duplication. It handles the case in super_1_sync() > where the superblock is extended by the addition of new component > devices. > > I think it also fixes a bug where the existing code in super_1_load() > ought to be rejecting the array with EINVAL: if the superblock padded > out to the *logical* block length runs into the bitmap. For example, if > the bitmap offset is 2 (bitmap 1K after superblock) and the logical > block size is 4K, the superblock padded out to 4K runs into the bitmap. > This case may be unusual (perhaps only happens if the array is created > on a 512n device and then raw contents are copied onto a 4kn device) but > I think it is possible. Hi Chris For super1.1 and super1.2 bitmap offset is 8. It's a fixed value. So it should not have the risk? But for future maybe it has this problem. If the disk logical or physical block size is larger than 4K in future, it has data corruption risk. > > With respect to the option of simply replacing > queue_logical_block_size() with queue_physical_block_size(), I think > this can result in the code rejecting devices that can be loaded, but In mdadm it defines the max super size of super1 is 4096 #define MAX_SB_SIZE 4096 /* bitmap super size is 256, but we round up to a sector for alignment */ #define BM_SUPER_SIZE 512 #define MAX_DEVS ((int)(MAX_SB_SIZE - sizeof(struct mdp_superblock_1)) / 2) #define SUPER1_SIZE (MAX_SB_SIZE + BM_SUPER_SIZE \ + sizeof(struct misc_dev_info)) It should be ok to replace queue_logical_block_size with queue_physical_block_size? Now it doesn't check physical block size and super block size. For super1, we can add a check that if physical block size is larger than MAX_SB_SIZE, then we reject to create/assmble the raid device. > for which the physical block alignment can't be respected--the longer > padded size would trigger the EINVAL cases testing against > data_offset/new_data_offset. I think it's better to proceed in such > cases, just with unaligned superblock writes as would presently happen. > Also if I'm right about the above bug, then I think this subsitution > would be more likely to trigger it. > > Thanks, > > --Chris > > > Christopher Unkel (3): > md: factor out repeated sb alignment logic > md: align superblock writes to physical blocks > md: reuse sb length-checking logic > > drivers/md/md.c | 69 +++++++++++++++++++++++++++++++++++++------------ > 1 file changed, 52 insertions(+), 17 deletions(-) >