From patchwork Wed Nov 7 06:31:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 10671919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36AAA15E9 for ; Wed, 7 Nov 2018 06:32:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A9732B631 for ; Wed, 7 Nov 2018 06:32:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F8902B63E; Wed, 7 Nov 2018 06:32:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE6652B6B0 for ; Wed, 7 Nov 2018 06:32:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730102AbeKGQBT (ORCPT ); Wed, 7 Nov 2018 11:01:19 -0500 Received: from ipmail03.adl2.internode.on.net ([150.101.137.141]:1838 "EHLO ipmail03.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728299AbeKGQBS (ORCPT ); Wed, 7 Nov 2018 11:01:18 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail03.adl2.internode.on.net with ESMTP; 07 Nov 2018 17:01:34 +1030 Received: from discord.disaster.area ([192.168.1.111]) by dastard with esmtp (Exim 4.80) (envelope-from ) id 1gKHNE-000871-7Q; Wed, 07 Nov 2018 17:31:32 +1100 Received: from dave by discord.disaster.area with local (Exim 4.91) (envelope-from ) id 1gKHNE-0001jG-6H; Wed, 07 Nov 2018 17:31:32 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 14/16] xfs: align writepages to large block sizes Date: Wed, 7 Nov 2018 17:31:25 +1100 Message-Id: <20181107063127.3902-15-david@fromorbit.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181107063127.3902-1-david@fromorbit.com> References: <20181107063127.3902-1-david@fromorbit.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Chinner For data integrity purposes, we need to write back the entire filesystem block when asked to sync a sub-block range of the file. When the filesystem block size is larger than the page size, this means we need to convert single page integrity writes into whole block integrity writes. We do this by extending the writepage range to filesystem block granularity and alignment. Signed-off-by: Dave Chinner --- fs/xfs/xfs_aops.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index f6ef9e0a7312..5334f16be166 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -900,6 +900,7 @@ xfs_vm_writepages( .io_type = XFS_IO_HOLE, }; int ret; + unsigned bsize = i_blocksize(mapping->host); /* * Refuse to write pages out if we are called from reclaim context. @@ -922,6 +923,19 @@ xfs_vm_writepages( if (WARN_ON_ONCE(current->flags & PF_MEMALLOC_NOFS)) return 0; + /* + * If the block size is larger than page size, extent the incoming write + * request to fsb granularity and alignment. This is a requirement for + * data integrity operations and it doesn't hurt for other write + * operations, so do it unconditionally. + */ + if (wbc->range_start) + wbc->range_start = round_down(wbc->range_start, bsize); + if (wbc->range_end != LLONG_MAX) + wbc->range_end = round_up(wbc->range_end, bsize); + if (wbc->nr_to_write < wbc->range_end - wbc->range_start) + wbc->nr_to_write = round_up(wbc->nr_to_write, bsize); + xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); ret = write_cache_pages(mapping, wbc, xfs_do_writepage, &wpc); if (wpc.ioend)