From patchwork Sat Nov 22 16:54:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 5359641 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 43A809F1E1 for ; Sat, 22 Nov 2014 16:54:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F80920154 for ; Sat, 22 Nov 2014 16:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48914200E0 for ; Sat, 22 Nov 2014 16:54:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751680AbaKVQyi (ORCPT ); Sat, 22 Nov 2014 11:54:38 -0500 Received: from imap.thunk.org ([74.207.234.97]:45344 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbaKVQyg (ORCPT ); Sat, 22 Nov 2014 11:54:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=iCnZzmIQOxNt8mKhMQJtfrFiwO7CqzJs0UG7/7XK/1s=; b=sPi64CzG2n/56VvuRa8wipoRkHSEkhCBzE1pOKTejCoMAerCXtvw7Z1BGn0o5In2cFbpzb8ohjI1taepgdFDpGpxtIOn9uo5rKW0zfCqgYpZEezgj9k96njX4bl6+qA4bM/TQ/DMa0xEZh98QruIFcYVL433NJRGMFMM4uZtGjk=; Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.80) (envelope-from ) id 1XsDxB-0004Da-M2; Sat, 22 Nov 2014 16:54:33 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id D36675804CD; Sat, 22 Nov 2014 11:54:31 -0500 (EST) From: Theodore Ts'o To: linux-fsdevel@vger.kernel.org Cc: Ext4 Developers List , xfs@oss.sgi.com, linux-btrfs@vger.kernel.org, Theodore Ts'o Subject: [PATCH-v2 3/5] vfs: don't let the dirty time inodes get more than a day stale Date: Sat, 22 Nov 2014 11:54:25 -0500 Message-Id: <1416675267-2191-4-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1416675267-2191-1-git-send-email-tytso@mit.edu> References: <1416675267-2191-1-git-send-email-tytso@mit.edu> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Guarantee that the on-disk timestamps will be no more than 24 hours stale. Signed-off-by: Theodore Ts'o --- fs/fs-writeback.c | 1 + fs/inode.c | 16 +++++++++++++++- include/linux/fs.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index ce7de22..eb04277 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1141,6 +1141,7 @@ void __mark_inode_dirty(struct inode *inode, int flags) if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) { trace_writeback_dirty_inode_start(inode, flags); + inode->i_ts_dirty_day = 0; if (sb->s_op->dirty_inode) sb->s_op->dirty_inode(inode, flags); diff --git a/fs/inode.c b/fs/inode.c index 11fe81b..0d939a8 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1511,6 +1511,7 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, */ static int update_time(struct inode *inode, struct timespec *time, int flags) { + unsigned short days_since_boot = jiffies / (HZ * 86400); int ret; if (inode->i_op->update_time) { @@ -1527,14 +1528,27 @@ static int update_time(struct inode *inode, struct timespec *time, int flags) if (flags & S_MTIME) inode->i_mtime = *time; } - if (inode->i_sb->s_flags & MS_LAZYTIME) { + /* + * If i_ts_dirty_day is zero, then either we have not deferred + * timestamp updates, or the system has been up for less than + * a day (so days_since_boot is zero), so we defer timestamp + * updates in that case and set the I_DIRTY_TIME flag. If a + * day or more has passed, then i_ts_dirty_day will be + * different from days_since_boot, and then we should update + * the on-disk inode and then we can clear i_ts_dirty_day. + */ + if ((inode->i_sb->s_flags & MS_LAZYTIME) && + (!inode->i_ts_dirty_day || + inode->i_ts_dirty_day == days_since_boot)) { if (inode->i_state & I_DIRTY_TIME) return 0; spin_lock(&inode->i_lock); inode->i_state |= I_DIRTY_TIME; spin_unlock(&inode->i_lock); + inode->i_ts_dirty_day = days_since_boot; return 0; } + inode->i_ts_dirty_day = 0; if (inode->i_op->write_time) return inode->i_op->write_time(inode); mark_inode_dirty_sync(inode); diff --git a/include/linux/fs.h b/include/linux/fs.h index 489b2f2..e3574cd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -575,6 +575,7 @@ struct inode { struct timespec i_ctime; spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ unsigned short i_bytes; + unsigned short i_ts_dirty_day; unsigned int i_blkbits; blkcnt_t i_blocks;