Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3102975pxx; Sun, 1 Nov 2020 23:07:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyr/HBRkTWFyclhlZhDxFJfSHHiahBkvXfooEoTsxUpiAo5Jnxx5+1AL/w11zuPjtXzbIR X-Received: by 2002:a17:906:26c2:: with SMTP id u2mr13499379ejc.529.1604300860301; Sun, 01 Nov 2020 23:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604300860; cv=none; d=google.com; s=arc-20160816; b=DDTY2sK1DW25o7hYJwc+82LRUwWJSnfLYdNpFanhqOksl/Jwi3u3TI5bsLBHDEW9G3 e/a3oEZ84aBf1IUEN68hi48fCtJNHg6rPGUsZiwPEUXVYcKaiLl5BOaJjviCarcxyVcR 1cZU02wy/ZjBoeTCRump93GX4Tqiabyq0qckbf8mVL8huXefoIBcWqik4GPoJZZlZjoE mbq1Ty8Sn3VfVbzRboCM6Ek1g3bp1DzaAyLRSPbHjNXwbJCxVCAvUbBQsaL2kr8Jn/M/ K6Qz25NiFWZFByUhFAD5NOUkPZKYCCwQKpJW/y+Vl7j6XJ7SiijZTBT3+kvqQbjZNjxU qDzA== 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=BhzMP52bVypIwFDjmwBPMHYXAhlB8gsyXxMfVoaGxIA=; b=RGiN6mh2428Vul7Lxkg6eNxzluBkkrVQio0FUfJwjgLBYfzD9o6rCjbqLq8l8pzwZx IZEDjpEF4CH94V3sGBxXP4z8+2MRUMsANESN3EuQAoct1E3JPMidmbXRbZ2LIvnX3cnw i/X9xvqk9RACDTKOfJoytDai4dspH20Gltg5UKNeBLDsnPx2aSSnHAaux8nv/usbEkQm CJgdxD4d/csHjClX9WYtoFHT7PrQvJIgVw9Of+EdWBd7j1ekDOxgH030MWb6HbUSdCmY qiXNA4/JeTxcJX10DnVgVpdZt4t2LtHCpl0eAnB//OwQNvxr4Npd0dIfz5ffdD2mzQSE oThg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vd7pj725; 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 bx14si2103548edb.13.2020.11.01.23.07.18; Sun, 01 Nov 2020 23:07:40 -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=Vd7pj725; 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 S1728027AbgKBHEv (ORCPT + 99 others); Mon, 2 Nov 2020 02:04:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32774 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728017AbgKBHEv (ORCPT ); Mon, 2 Nov 2020 02:04:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604300689; 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=BhzMP52bVypIwFDjmwBPMHYXAhlB8gsyXxMfVoaGxIA=; b=Vd7pj725Vk6kAptFf2JXKH6FTjVFqqlulaN/mW2LcHjM4Eqor2ImsmuNqVbpRjSc6x4pNH 6LlOmeebPKRSFN1cygFfKcFuXV0s7iAHHPFQWT2gr0MoLW9PRFqfX7MABas4pfcZ12bHf5 kh1RqmJpFfQjPenlrimMwLazC1JfjIU= 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-211-y1M2nnBdMxeca6uFDOmWZQ-1; Mon, 02 Nov 2020 02:04:45 -0500 X-MC-Unique: y1M2nnBdMxeca6uFDOmWZQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B2F41882FA5; Mon, 2 Nov 2020 07:04:44 +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 E691E6EF6F; Mon, 2 Nov 2020 07:04:41 +0000 (UTC) Subject: Re: [PATCH 0/3] mdraid sb and bitmap write alignment on 512e drives To: Christopher Unkel , linux-raid@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Song Liu References: <20201023033130.11354-1-cunkel@drivescale.com> From: Xiao Ni Message-ID: Date: Mon, 2 Nov 2020 15:04:39 +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: <20201023033130.11354-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.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23/2020 11:31 AM, Christopher Unkel wrote: > Hello all, > > While investigating some performance issues on mdraid 10 volumes > formed with "512e" disks (4k native/physical sector size but with 512 > byte sector emulation), I've found two cases where mdraid will > needlessly issue writes that start on 4k byte boundary, but are are > shorter than 4k: > > 1. writes of the raid superblock; and > 2. writes of the last page of the write-intent bitmap. > > The following is an excerpt of a blocktrace of one of the component > members of a mdraid 10 volume during a 4k write near the end of the > array: > > 8,32 11 2 0.000001687 711 D WS 2064 + 8 [kworker/11:1H] > * 8,32 11 5 0.001454119 711 D WS 2056 + 1 [kworker/11:1H] > * 8,32 11 8 0.002847204 711 D WS 2080 + 7 [kworker/11:1H] > 8,32 11 11 0.003700545 3094 D WS 11721043920 + 8 [md127_raid1] > 8,32 11 14 0.308785692 711 D WS 2064 + 8 [kworker/11:1H] > * 8,32 11 17 0.310201697 711 D WS 2056 + 1 [kworker/11:1H] > 8,32 11 20 5.500799245 711 D WS 2064 + 8 [kworker/11:1H] > * 8,32 11 23 15.740923558 711 D WS 2080 + 7 [kworker/11:1H] > > Note the starred transactions, which each start on a 4k boundary, but > are less than 4k in length, and so will use the 512-byte emulation. > Sector 2056 holds the superblock, and is written as a single 512-byte > write. Sector 2086 holds the bitmap bit relevant to the written > sector. When it is written the active bits of the last page of the > bitmap are written, starting at sector 2080, padded out to the end of > the 512-byte logical sector as required. This results in a 3.5kb > write, again using the 512-byte emulation. Hi Christopher Which superblock version do you use? If it's super1.1, superblock starts at 0 sector. If it's super1.2, superblock starts at 8 sector. If it's super1.0, superblock starts at the end of device and bitmap is before superblock. As mentioned above, bitmap is behind the superblock, so it should not be super1.0. So I have a question why does 2056 hold the superblock? Regards Xiao > > Note that in some arrays the last page of the bitmap may be > sufficiently full that they are not affected by the issue with the > bitmap write. > > As there can be a substantial penalty to using the 512-byte sector > emulation (turning writes into read-modify writes if the relevant > sector is not in the drive's cache) I believe it makes sense to pad > these writes out to a 4k boundary. The writes are already padded out > for "4k native" drives, where the short access is illegal. > > The following patch set changes the superblock and bitmap writes to > respect the physical block size (e.g. 4k for today's 512e drives) when > possible. In each case there is already logic for padding out to the > underlying logical sector size. I reuse or repeat the logic for > padding out to the physical sector size, but treat the padding out as > optional rather than mandatory. > > The corresponding block trace with these patches is: > > 8,32 1 2 0.000003410 694 D WS 2064 + 8 [kworker/1:1H] > 8,32 1 5 0.001368788 694 D WS 2056 + 8 [kworker/1:1H] > 8,32 1 8 0.002727981 694 D WS 2080 + 8 [kworker/1:1H] > 8,32 1 11 0.003533831 3063 D WS 11721043920 + 8 [md127_raid1] > 8,32 1 14 0.253952321 694 D WS 2064 + 8 [kworker/1:1H] > 8,32 1 17 0.255354215 694 D WS 2056 + 8 [kworker/1:1H] > 8,32 1 20 5.337938486 694 D WS 2064 + 8 [kworker/1:1H] > 8,32 1 23 15.577963062 694 D WS 2080 + 8 [kworker/1:1H] > > I do notice that the code for bitmap writes has a more sophisticated > and thorough check for overlap than the code for superblock writes. > (Compare write_sb_page in md-bitmap.c vs. super_1_load in md.c.) From > what I know since the various structures starts have always been 4k > aligned anyway, it is always safe to pad the superblock write out to > 4k (as occurs on 4k native drives) but not necessarily futher. > > Feedback appreciated. > > --Chris > > > Christopher Unkel (3): > md: align superblock writes to physical blocks > md: factor sb write alignment check into function > md: pad writes to end of bitmap to physical blocks > > drivers/md/md-bitmap.c | 80 +++++++++++++++++++++++++----------------- > drivers/md/md.c | 15 ++++++++ > 2 files changed, 63 insertions(+), 32 deletions(-) >