[Top] [All Lists]

Re: [PATCH 3/4] vfs: don't let the dirty time inodes get more than a day

To: Andreas Dilger <adilger@xxxxxxxxx>
Subject: Re: [PATCH 3/4] vfs: don't let the dirty time inodes get more than a day stale
From: Theodore Ts'o <tytso@xxxxxxx>
Date: Fri, 21 Nov 2014 16:36:51 -0500
Cc: linux-fsdevel <linux-fsdevel@xxxxxxxxxxxxxxx>, Ext4 Developers List <linux-ext4@xxxxxxxxxxxxxxx>, xfs@xxxxxxxxxxx, linux-btrfs@xxxxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=jLkg6Y+VM6kb8iJXiNT8ZWGU/1/VDilZj5qKyeLo6PY=; b=P8AaKldkH0ruDhgyi9cl3I2iHh26VQsg1LD640liaLpy9/nmehpvea4OXTSZmWgXk2oxvd3QMW4Gqy099Q4OBow6exO9V3MlbOP+XgD0G4VCXPvfgjuqyEkm+c4HFjBnsbZfHmOXOHpfUnOmR8So/qoOqLwi71gSf0yXIPYY7Qw=;
In-reply-to: <B1759DB3-7D86-499B-BE09-34D9927C75C8@xxxxxxxxx>
References: <1416599964-21892-1-git-send-email-tytso@xxxxxxx> <1416599964-21892-4-git-send-email-tytso@xxxxxxx> <B1759DB3-7D86-499B-BE09-34D9927C75C8@xxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Fri, Nov 21, 2014 at 02:19:07PM -0600, Andreas Dilger wrote:
> > -   if (inode->i_sb->s_flags & MS_LAZYTIME) {
> > +   if ((inode->i_sb->s_flags & MS_LAZYTIME) &&
> > +       (!inode->i_ts_dirty_day ||
> > +        inode->i_ts_dirty_day == days_since_boot)) {
> >             spin_lock(&inode->i_lock);
> >             inode->i_state |= I_DIRTY_TIME;
> >             spin_unlock(&inode->i_lock);
> > +           inode->i_ts_dirty_day = days_since_boot;
> It isn't clear if this is correct.  It looks like the condition will
> only be entered if i_ts_dirty_day == days_since_boot, but that is only
> set inside the condition?

If i_ts_dirty_day is zero, the timestamps don't have to written to
disk.  This is either because the inode has been written to disk, or
the system has been up for less than a day, such that when we last a
lazy mtime update (i.e., we skipped the call to mark_inode_dirty)
since jiffies / (HZ * 86400) was zero.

If it is non-zero, then the timestamps were updated but were not sent
to disk N days since the system was booted.  So long as it remains N
days since the system was booted, we can skip calling
mark_inode_dirty().  But once it becomes N+1 days since the system was
booted, then we will call mark_inode_dirty() and set i_ts_dirty_day to

I'll add a comment so it's a bit more obvious what we're doing here,
but I'm pretty sure we currently have is in fact correct.

> and "days_since_boot" should be declared unsigned short so it wraps
> in the same way as i_ts_dirty_day

Good point, thanks.  This will only be an issue after the system has
been up for almost 90 years, but we might as well get it right,

                                          - Ted

<Prev in Thread] Current Thread [Next in Thread>