From patchwork Wed Nov 7 06:31:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 10671947 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 A27E214E2 for ; Wed, 7 Nov 2018 06:32:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 942AD2B64D for ; Wed, 7 Nov 2018 06:32:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88D352B6C8; Wed, 7 Nov 2018 06:32:31 +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=ham 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 397F22B64D for ; Wed, 7 Nov 2018 06:32:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbeKGQB0 (ORCPT ); Wed, 7 Nov 2018 11:01:26 -0500 Received: from ipmail03.adl2.internode.on.net ([150.101.137.141]:63760 "EHLO ipmail03.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbeKGQBU (ORCPT ); Wed, 7 Nov 2018 11:01:20 -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-00086u-6j; Wed, 07 Nov 2018 17:31:32 +1100 Received: from dave by discord.disaster.area with local (Exim 4.91) (envelope-from ) id 1gKHNE-0001jD-5F; 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 13/16] xfs: add zero-around controls to iomap Date: Wed, 7 Nov 2018 17:31:24 +1100 Message-Id: <20181107063127.3902-14-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-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Chinner For buffered writes into block size > page size filesystems, XFS will need to trigger zero-around for delayed allocation mappings and writes over unwritten extents. Unwritten extents will only remain unwritten until the first data gets written back, so we have to ensure that any write mapping triggers zero-around for them. Delayed allocation occurs over holes, which then require the data in the page cache to completely cover them at write-out time. Hence we have to trigger write-around for these mappings, too. Signed-off-by: Dave Chinner --- fs/xfs/xfs_iomap.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 27c93b5f029d..35626855e207 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -575,6 +575,15 @@ xfs_file_iomap_begin_delay( goto out_unlock; } + /* + * If we are about to write to an unwritten extent and the + * the block size is larger than page size, then we need to make sure + * that the caller zeroes blocks partially covered by data. + */ + if (got.br_state == XFS_EXT_UNWRITTEN && + mp->m_sb.sb_blocksize > PAGE_SIZE) + iomap->flags |= IOMAP_F_ZERO_AROUND; + trace_xfs_iomap_found(ip, offset, count, 0, &got); goto done; } @@ -647,6 +656,8 @@ xfs_file_iomap_begin_delay( * them out if the write happens to fail. */ iomap->flags |= IOMAP_F_NEW; + if (mp->m_sb.sb_blocksize > PAGE_SIZE) + iomap->flags |= IOMAP_F_ZERO_AROUND; trace_xfs_iomap_alloc(ip, offset, count, 0, &got); done: if (isnullstartblock(got.br_startblock)) @@ -1107,6 +1118,15 @@ xfs_file_iomap_begin( if (flags & IOMAP_ZERO) goto out_found; + /* + * If we are about to write to an unwritten extent and the + * the block size is larger than page size, then we need to make sure + * that the caller zeroes blocks partially covered by data. + */ + if (imap.br_state == XFS_EXT_UNWRITTEN && + mp->m_sb.sb_blocksize > PAGE_SIZE) + iomap->flags |= IOMAP_F_ZERO_AROUND; + if (!imap_needs_alloc(inode, &imap, nimaps)) goto out_found;