Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp307780pxu; Fri, 23 Oct 2020 00:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx61N3h4a808No5+PS1QAcIqFlDGW4iOjxAWhBbQq7nTCK3WkiCayfaWtlyNMI2bYzDw78l X-Received: by 2002:a05:6402:b16:: with SMTP id bm22mr948040edb.193.1603439719643; Fri, 23 Oct 2020 00:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603439719; cv=none; d=google.com; s=arc-20160816; b=w/cOGu45B3Ux4dMgLFW0DjLq6+eH8jBuqo3M2ZCx3Tjudd7O3JRCVRntqAM44/n4kA Igvn4AHedcJfwxWpnDzH9dIvzEoXiY6iw4faloxXtqEKG3sjQBFo3v1Qyl/GxgIC3IgK jItCBWkyo0ruOIkQsDXI7QqcTPapHRRtqLKWg/eycGh/5IYmafHd+toyxVCpYmi9D99+ XDcoRg+VzZXRNhD7kSh59WLiObGat/Ur4jJaCkmmni78MwrjICgdPmUNR06jLdU3VAty 9s7uU7FqahcZvYIm1dVbsDayACHmrR4rK6eRcXSH0jOxM6yqi5DEoY7mEHhWcpaemiwz t2nA== 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=RhHK93So0VcKlYFbgYUYXeSYVQkNms0+nxyySSnXb+k=; b=qWHFoQ2boqjfRS0mI1Ob5N4zQjpOcdFfjBdVF/s8x0RrfnwjW4Gy6E4DbeTv0ML6n9 3MRstwV/4kfgTXUG5jtp/wMGtU0e40pAxic2sspuWMUYTJVCUx4JO2QIIcIvfeLYhQJS Va7GUNC0mfscf4NOGRDZR/d9jf+9T3zZBPftiTrQ5rdfMGu8k/CNGUitKKTW/y8eCZc6 HxM5wR3hbPuNJIGId40k1eL2yZRb1wUOIzl8o1dSBFEpfMF8X7QC0qoUEQDFWkOEYYjR 29TwPasfZ6EVyCXyZdihVZ1l9EEmbS61rp1rsuZ7pwv8/pMy07KS9dvtJNaMAtyUTVjR Y8Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@drivescale-com.20150623.gappssmtp.com header.s=20150623 header.b=IPFfdKZ7; 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 h20si325495eja.402.2020.10.23.00.54.56; Fri, 23 Oct 2020 00:55: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=@drivescale-com.20150623.gappssmtp.com header.s=20150623 header.b=IPFfdKZ7; 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 S460405AbgJWDb5 (ORCPT + 99 others); Thu, 22 Oct 2020 23:31:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374886AbgJWDbq (ORCPT ); Thu, 22 Oct 2020 23:31:46 -0400 Received: from mail-oi1-x262.google.com (mail-oi1-x262.google.com [IPv6:2607:f8b0:4864:20::262]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BE25C0613D5 for ; Thu, 22 Oct 2020 20:31:44 -0700 (PDT) Received: by mail-oi1-x262.google.com with SMTP id j7so363319oie.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=RhHK93So0VcKlYFbgYUYXeSYVQkNms0+nxyySSnXb+k=; b=IPFfdKZ7mj4Gn6Yl/tH8/Q+MuI0fe9tTCLLeMhotRbKJyhaUuHrUntFTcPozjRq4jQ 0/zjMXzmcPtSrP3uAwhkudtzUYH0ttPOb9Ba0727AiOdYNvgmaY9tMfNGca9wiVfntjW Wyvx4HSZE3cAieHlJGxR4qlBiEgJi3IkljP78r0IwYLSC5TiNsCI1nrpqxkcPJzxqOLK OD2vUXAJIO3CLAPZqACLpIIdR8kYlcJ/caEiRuCBuR70c+VCNl2ufzTPnhl+C2p7vTUR b0smkrP7YD2kMNbs8wP/wqBgD4xZKQyHJcetRsR6c5BB51PY4W+mPYnQ90F1uD9O0UIc OhWA== 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=RhHK93So0VcKlYFbgYUYXeSYVQkNms0+nxyySSnXb+k=; b=fY3KK2B9YpTtmiK6daMGSKj9ueAHswVCxvOvbCeu9ZQrl1Vvj4HUACpajCr/IkNZ9g 737t6ZFmOT1uvnhy1Crl+s+7Qzd6657KCSt9tdu2F4ulmJqAm++AnYYaGmBO7TbAEfJr vs6B9gGj7Vj6ZrhYTHxbAtb5I7yGqHcrSF9KOEYIw5ujsvjHU8C2qN2Rywh3uZDvjTYE ydCQUEIaQwrXV9p5NOeATd2DfL9H5YxmI4pWitMDmnTDMh/zWG8LZPM4k9SjdM0b0Gkd GbX4EHNBLx07Jtf0SKFjA/yYdnagogOOYNPfIi9Hppw0cJfBd7acESUX/gIteaQxjm1n vSGA== X-Gm-Message-State: AOAM531CVskn7pjYjkPG3118rh1vGbsV5nVKWV+lFpS2cnUl8dulZ/3k 5DpYbrCPMyUnRhTjxiPhU4Nf5VXGxKvhkd6oi/ATU4qCJU2Pcw== X-Received: by 2002:a05:6808:28c:: with SMTP id z12mr246573oic.70.1603423903944; 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 w2sm42526ooc.20.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 51BBA420D3; Fri, 23 Oct 2020 03:31:43 +0000 (UTC) From: Christopher Unkel To: linux-raid@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Song Liu , cunkel@drivescale.com Subject: [PATCH 3/3] md: pad writes to end of bitmap to physical blocks Date: Thu, 22 Oct 2020 20:31:30 -0700 Message-Id: <20201023033130.11354-4-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 last page of the bitmap are padded out to the next logical block boundary. However, they are not padded out to the next physical block boundary, so the writes may be less than a physical block. On a "512e" disk (logical block 512 bytes, physical block 4k) and if the last page of the bitmap is less than 3584 bytes, this means that writes of the last bitmap page hit the 512-byte emulation. Respect the physical block boundary as long as the resulting write doesn't run into other data, and is no longer than a page. (If the physical block size is larger than a page no bitmap write will respect the physical block boundaries.) Signed-off-by: Christopher Unkel --- drivers/md/md-bitmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 600b89d5a3ad..21af5f94d495 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -264,10 +264,18 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) if (page->index == store->file_pages-1) { int last_page_size = store->bytes & (PAGE_SIZE-1); + int pb_aligned_size; if (last_page_size == 0) last_page_size = PAGE_SIZE; size = roundup(last_page_size, bdev_logical_block_size(bdev)); + pb_aligned_size = roundup(last_page_size, + bdev_physical_block_size(bdev)); + if (pb_aligned_size > size + && pb_aligned_size <= PAGE_SIZE + && sb_write_alignment_ok(mddev, rdev, page, offset, + pb_aligned_size)) + size = pb_aligned_size; } /* Just make sure we aren't corrupting data or * metadata -- 2.17.1