From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Linux Filesystem Development List <linux-fsdevel@vger.kernel.org>,
Ext4 Developers List <linux-ext4@vger.kernel.org>,
Linux btrfs Developers List <linux-btrfs@vger.kernel.org>,
XFS Developers <xfs@oss.sgi.com>
Subject: Re: [PATCH-v3 3/6] vfs: don't let the dirty time inodes get more than a day stale
Date: Tue, 25 Nov 2014 15:58:01 +0100 [thread overview]
Message-ID: <87ioi3iayu.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <1416893674-419-4-git-send-email-tytso@mit.edu> (Theodore Ts'o's message of "Tue, 25 Nov 2014 00:34:31 -0500")
On Tue, Nov 25 2014, Theodore Ts'o <tytso@mit.edu> wrote:
> static int update_time(struct inode *inode, struct timespec *time, int flags)
> {
> + struct timespec uptime;
> + unsigned short daycode;
> int ret;
>
> if (inode->i_op->update_time) {
> @@ -1525,17 +1527,33 @@ static int update_time(struct inode *inode, struct timespec *time, int flags)
> if (flags & S_CTIME)
> inode->i_ctime = *time;
> if (flags & S_MTIME)
> - inode->i_mtime = *time;
> + inode->i_mtime = *time;
> }
> + /*
> + * 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.
> + */
I think days_since_boot was a lot clearer than daycode. In any case,
please make the comment and the code consistent.
> if ((inode->i_sb->s_flags & MS_LAZYTIME) &&
> !(flags & S_VERSION)) {
> 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);
> - return 0;
> + get_monotonic_boottime(&uptime);
> + daycode = div_u64(uptime.tv_sec, (HZ * 86400));
You should probably divide by the number of seconds in a day, not the
number of jiffies in a day.
Isn't div_u64 mostly for when the divisor is not known at compile time?
Technically, "(u64)uptime.tv_sec / 86400" is of course a u64/u64 division,
but the compiler should see that the divisor is only 32 bits and hence
should be able to generate code which is at least as efficient as
whatever inline asm the arch provides for u64/u32 divisions.
Rasmus
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-11-25 14:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 5:34 [PATCH-v3 0/6] add support for a lazytime mount option Theodore Ts'o
2014-11-25 5:34 ` [PATCH-v3 1/6] fs: split update_time() into update_time() and write_time() Theodore Ts'o
2014-11-25 16:00 ` David Sterba
2014-11-25 5:34 ` [PATCH-v3 2/6] vfs: add support for a lazytime mount option Theodore Ts'o
2014-11-25 5:34 ` [PATCH-v3 3/6] vfs: don't let the dirty time inodes get more than a day stale Theodore Ts'o
2014-11-25 14:58 ` Rasmus Villemoes [this message]
2014-11-25 15:55 ` Theodore Ts'o
2014-11-25 5:34 ` [PATCH-v3 4/6] vfs: add lazytime tracepoints for better debugging Theodore Ts'o
2014-11-25 5:34 ` [PATCH-v3 5/6] ext4: add support for a lazytime mount option Theodore Ts'o
2014-11-25 5:34 ` [PATCH-v3 6/6] btrfs: add an is_readonly() so btrfs can use common code for update_time() Theodore Ts'o
2014-11-25 16:02 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ioi3iayu.fsf@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox