From patchwork Thu Feb 22 15:29: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: 10235749 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 C1BFB602DC for ; Thu, 22 Feb 2018 15:30:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4B0D28DFA for ; Thu, 22 Feb 2018 15:30:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A972428E22; Thu, 22 Feb 2018 15:30:16 +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=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 50D4F28DFA for ; Thu, 22 Feb 2018 15:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932965AbeBVPaN (ORCPT ); Thu, 22 Feb 2018 10:30:13 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44794 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932957AbeBVPaJ (ORCPT ); Thu, 22 Feb 2018 10:30:09 -0500 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:Cc:To:From:Sender:Reply-To: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=ogVJ/0ePYVGx0iYV3NQQfxKfqmbOrVFnjgL0xGNx3Xk=; b=Gt9vdYTr1pzMgOdnCxgMbkhRM NqfjiE2zqj/1sihHPLXOL5flJJm5W1WI8u3S9UKHxthIrfMgmZN/Z8zBRQr/3NaPXnG61gWtO5Wek Shrxm7vIOCVm7OMHTFEtrxrXugjp255fzfbfXOU0ZgObwJ0mUGDeap1PUHpVjiGiHAPnHG5WQV2bp /OBX5w+umH4b5BsEM/SIv74oALmt6c0u/Jq3gGpmSep8usVHM8goR4fzi4/lb/xY+FKCy9yFUADEF ZSXHxb5UlEbrpgpvTgjysYrel+/hOCToqv0OSfGAM9M+mi1ULyhFsebK4sUAVJ3dYcRk03p5hJCWl kQWGNi+WQ==; Received: from [107.17.164.176] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eosos-0001lU-5Y; Thu, 22 Feb 2018 15:30:02 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, "Theodore Ts'o" Subject: [PATCH 2/2] xfs: implement the lazytime mount options Date: Thu, 22 Feb 2018 07:29:57 -0800 Message-Id: <20180222152957.19624-3-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180222152957.19624-1-hch@lst.de> References: <20180222152957.19624-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 Use the VFS dirty inode tracking for lazytime inodes only, and just log them in ->dirty_inode. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_iops.c | 5 +++++ fs/xfs/xfs_super.c | 23 +++++++++++++++++++++++ fs/xfs/xfs_trans_inode.c | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 56475fcd76f2..0946a3baae6a 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -46,6 +46,7 @@ #include #include #include +#include /* * Directories have different lock order w.r.t. mmap_sem compared to regular @@ -1057,6 +1058,10 @@ xfs_vn_update_time( trace_xfs_update_time(ip); + if ((inode->i_sb->s_flags & SB_LAZYTIME) && + !((flags & S_VERSION) && inode_maybe_inc_iversion(inode, false))) + return generic_update_time(inode, now, flags); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); if (error) return error; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 7aba628dc527..20d53f125c35 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1007,6 +1007,28 @@ xfs_fs_destroy_inode( xfs_inode_set_reclaim_tag(ip); } +static void +xfs_fs_dirty_inode( + struct inode *inode, + int flag) +{ + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + struct xfs_trans *tp; + + if (!(inode->i_sb->s_flags & SB_LAZYTIME)) + return; + if (flag != I_DIRTY_SYNC || !(inode->i_state & I_DIRTY_TIME)) + return; + + if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp)) + return; + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP); + xfs_trans_commit(tp); +} + /* * Slab object creation initialisation for the XFS inode. * This covers only the idempotent fields in the XFS inode; @@ -1787,6 +1809,7 @@ xfs_fs_free_cached_objects( static const struct super_operations xfs_super_operations = { .alloc_inode = xfs_fs_alloc_inode, .destroy_inode = xfs_fs_destroy_inode, + .dirty_inode = xfs_fs_dirty_inode, .drop_inode = xfs_fs_drop_inode, .put_super = xfs_fs_put_super, .sync_fs = xfs_fs_sync_fs, diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c index fddacf9575df..769943fcc1f2 100644 --- a/fs/xfs/xfs_trans_inode.c +++ b/fs/xfs/xfs_trans_inode.c @@ -98,9 +98,17 @@ xfs_trans_log_inode( xfs_inode_t *ip, uint flags) { + struct inode *inode = VFS_I(ip); + ASSERT(ip->i_itemp != NULL); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + if (inode->i_state & (I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED)) { + spin_lock(&inode->i_lock); + inode->i_state &= ~(I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED); + spin_unlock(&inode->i_lock); + } + /* * First time we log the inode in a transaction, bump the inode change * counter if it is configured for this to occur. While we have the