From patchwork Tue Mar 13 14:35:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10279193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 46FC0602C2 for ; Tue, 13 Mar 2018 14:36:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36B7928A4E for ; Tue, 13 Mar 2018 14:36:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29FF729037; Tue, 13 Mar 2018 14:36:21 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 7CF8528A4E for ; Tue, 13 Mar 2018 14:36:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932094AbeCMOgT (ORCPT ); Tue, 13 Mar 2018 10:36:19 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60986 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbeCMOgT (ORCPT ); Tue, 13 Mar 2018 10:36:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TX03rPYqDp56OfF7P739maxh04LRe1P7zz7RXtK7s18=; b=IxEkUXq8mB09Ww76USGeYcvXA XYNTIfAOKb/qt2QGBB5N+7XRoY9Gt+esRMrvcrX2EWPNFErIk83+0+m1MnVYOAFfsyiQqR9yXmj4y 4EvG3c7YkXnDWm6hYr8Yj7cdvAy9CAdJSseXzWz1ZZbFa2F2pejIP0BYlboMzKQo/kbCQjYuopVNg JX7XHB+jsh9Ndmxy6HuZA67gI+8zfmr5usi7nxy1L/gURqSzZvbeuDnn6NCyfHxn3/82KrUblbkgA vKj2nOXGLkpUww+kyUWW26O3/64XfaFN+R3iedeKn2DsH+2iVpD1afIZp6MiUbRV+5ELfipBRddzo 0PvO3vNLQ==; Received: from 77.117.139.172.wireless.dyn.drei.com ([77.117.139.172] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1evl2I-0004bH-Dg for linux-xfs@vger.kernel.org; Tue, 13 Mar 2018 14:36:18 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 4/8] xfs: remove xfs_zero_range Date: Tue, 13 Mar 2018 15:35:57 +0100 Message-Id: <20180313143601.30028-5-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180313143601.30028-1-hch@lst.de> References: <20180313143601.30028-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 This helper doesn't add any real value over just calling iomap_zero_range directly, so remove it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_bmap_util.c | 11 ++++------- fs/xfs/xfs_file.c | 48 +++++++----------------------------------------- fs/xfs/xfs_inode.h | 4 ---- fs/xfs/xfs_iops.c | 4 +++- 4 files changed, 14 insertions(+), 53 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 19ea7d086cf8..05dee8fdd895 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1208,18 +1208,15 @@ xfs_free_file_space( /* * Now that we've unmap all full blocks we'll have to zero out any - * partial block at the beginning and/or end. xfs_zero_range is - * smart enough to skip any holes, including those we just created, - * but we must take care not to zero beyond EOF and enlarge i_size. + * partial block at the beginning and/or end. iomap_zero_range is smart + * enough to skip any holes, including those we just created, but we + * must take care not to zero beyond EOF and enlarge i_size. */ - if (offset >= XFS_ISIZE(ip)) return 0; - if (offset + len > XFS_ISIZE(ip)) len = XFS_ISIZE(ip) - offset; - - return xfs_zero_range(ip, offset, len, NULL); + return iomap_zero_range(VFS_I(ip), offset, len, NULL, &xfs_iomap_ops); } /* diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 9ea08326f876..d2666ddf7381 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -48,20 +48,6 @@ static const struct vm_operations_struct xfs_file_vm_ops; -/* - * Clear the specified ranges to zero through either the pagecache or DAX. - * Holes and unwritten extents will be left as-is as they already are zeroed. - */ -int -xfs_zero_range( - struct xfs_inode *ip, - xfs_off_t pos, - xfs_off_t count, - bool *did_zero) -{ - return iomap_zero_range(VFS_I(ip), pos, count, did_zero, &xfs_iomap_ops); -} - int xfs_update_prealloc_flags( struct xfs_inode *ip, @@ -300,31 +286,6 @@ xfs_file_read_iter( return ret; } -/* - * Zero any on disk space between the current EOF and the new, larger EOF. - * - * This handles the normal case of zeroing the remainder of the last block in - * the file and the unusual case of zeroing blocks out beyond the size of the - * file. This second case only happens with fixed size extents and when the - * system crashes before the inode size was updated but after blocks were - * allocated. - * - * Expects the iolock to be held exclusive, and will take the ilock internally. - */ -int /* error (positive) */ -xfs_zero_eof( - struct xfs_inode *ip, - xfs_off_t offset, /* starting I/O offset */ - xfs_fsize_t isize, /* current inode size */ - bool *did_zeroing) -{ - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); - ASSERT(offset > isize); - - trace_xfs_zero_eof(ip, isize, offset - isize); - return xfs_zero_range(ip, isize, offset - isize, did_zeroing); -} - /* * Common pre-write limit and setup checks. * @@ -344,6 +305,7 @@ xfs_file_aio_write_checks( ssize_t error = 0; size_t count = iov_iter_count(from); bool drained_dio = false; + loff_t isize; restart: error = generic_write_checks(iocb, from); @@ -380,7 +342,8 @@ xfs_file_aio_write_checks( * and hence be able to correctly determine if we need to run zeroing. */ spin_lock(&ip->i_flags_lock); - if (iocb->ki_pos > i_size_read(inode)) { + isize = i_size_read(inode); + if (iocb->ki_pos > isize) { spin_unlock(&ip->i_flags_lock); if (!drained_dio) { if (*iolock == XFS_IOLOCK_SHARED) { @@ -401,7 +364,10 @@ xfs_file_aio_write_checks( drained_dio = true; goto restart; } - error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), NULL); + + trace_xfs_zero_eof(ip, isize, iocb->ki_pos - isize); + error = iomap_zero_range(inode, isize, iocb->ki_pos - isize, + NULL, &xfs_iomap_ops); if (error) return error; } else diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 3e8dc990d41c..132d8aa2afc4 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -443,10 +443,6 @@ enum xfs_prealloc_flags { int xfs_update_prealloc_flags(struct xfs_inode *ip, enum xfs_prealloc_flags flags); -int xfs_zero_eof(struct xfs_inode *ip, xfs_off_t offset, - xfs_fsize_t isize, bool *did_zeroing); -int xfs_zero_range(struct xfs_inode *ip, xfs_off_t pos, xfs_off_t count, - bool *did_zero); /* from xfs_iops.c */ extern void xfs_setup_inode(struct xfs_inode *ip); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 8567951eff10..e0307fbff911 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -875,7 +875,9 @@ xfs_setattr_size( * truncate. */ if (newsize > oldsize) { - error = xfs_zero_eof(ip, newsize, oldsize, &did_zeroing); + trace_xfs_zero_eof(ip, oldsize, newsize - oldsize); + error = iomap_zero_range(inode, oldsize, newsize - oldsize, + &did_zeroing, &xfs_iomap_ops); } else { error = iomap_truncate_page(inode, newsize, &did_zeroing, &xfs_iomap_ops);