From: Theodore Ts'o <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>
Subject: Re: Lazytime feature bugs
Date: Wed, 25 Feb 2015 23:33:04 -0500 [thread overview]
Message-ID: <20150226043304.GC11217@thunk.org> (raw)
In-Reply-To: <20150225162506.GE22736@quack.suse.cz>
On Wed, Feb 25, 2015 at 05:25:06PM +0100, Jan Kara wrote:
> Yeah, that sounds reasonable. I've been thinking how to fix those time
> ordering issues and sadly it isn't trivial. We'll likely need a
> timestamp in the inode (although a coarse one is enough) remembering when
> inode was last written (i_dirtied_when needs to remember when dirty *data*
> were created so we cannot use it as I originally thought). And we'll need
> to sort inodes back into the list of inodes with dirty timestamps. It
> could be done in O(length of list + number of inodes added) if we are
> careful but it will be non-trivial.
Well, the bottom line is that the two major problems you've listed
(ignoring the cosmetic issues) is that some of the inodes with dirty
timestamps might not get rewritten out until the inodes get ejected
from memory or the file system is unmounted. This isn't exactly a
disaster; it's not going to cause data loss, or cause the system to
become unstable, no?
1) Inode that gets periodically dirtied with I_DIRTY_PAGES, cleaned and
dirtied again will have inode with updated timestamps never written due
to age since inode->dirtied_when gets reset on each redirtying with
I_DIRTY_PAGES.
If we maintain an i_dirtied_when and a i_dirtied_time_when field, all
we need to do is to check if i_dirtied_time_when is older than 24
hours while we are processing writeback for inodes on b_io (nor just
when we are processing inodes on b_dirty_time), and update the
timestamps if necessary.
2) The code won't maintain time ordering of b_dirty_time list by
inode->dirtied_when - this happens because requeue_inode() moves inode
at the head of the b_dirty_time list but inodes in b_io list from which
we move are no longer ordered by dirtied_when (due to that list being
combined from several lists and also because we sort the list by
superblock). As a result terminating logic in move_expired_inodes() may
terminate the scan too early for b_dirty_time list.
To solve this problem, we need to make sure that the inode is inserted
into the list sorted by i_dirtied_time_when (and then
move_expired_inodes can just terminate checking on i_dirtied_time_when
instead of i_dirtied_when when we are scanning the b_dirty_time list).
If we don't care for this overhead, we could can do the following, at
the cost of a bit less precision about when we write out timestamps:
a) When checking to see if we need to write back timestamps while
processing inodes on b_io, we check not only i_dirty_time_when, but
we also check to see if mtime is oldered than a day. If so, we force
out the timestamps. This means we could potentially push out
timestamps earlier than we should, but in the steady state, the
timestamps will only be updated once a day.
b) When we move an inode from b_io to b_dirty_time, we set
i_dirty_time_when to "now". Because of (a) we know that mtime will be
at most stale by one day. If we don't dirty the inode's pages for the
next 24 hours, at that point the timestamps will be written out.
Hence, in the worst case the dirty timestamps might be stale on disk
by a maximum of two days.
Yes, we're playing loosey-goosey with exactly when the dirtied inodes
will get written out to disk, but the whole point of lazytime is to
relax when timestamps get updated on disk in exchange for better
performance. This just relaxes the timing a bit more.
But the fact that exactly when the timestamps get written back is not
something I view as a particularly critical, even if we don't fix both
of these two issues in 4.0, I don't think it's the end of the world
even if we don't yank the support for the lazytime mount option in
ext4.
Jan, what do you think?
- Ted
next prev parent reply other threads:[~2015-02-26 4:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-18 13:19 Lazytime feature bugs Jan Kara
2015-02-24 18:31 ` Jan Kara
2015-02-24 18:58 ` Linus Torvalds
2015-02-25 14:52 ` Theodore Ts'o
2015-02-25 16:25 ` Jan Kara
2015-02-26 4:33 ` Theodore Ts'o [this message]
2015-02-26 8:34 ` Jan Kara
2015-02-26 13:45 ` Theodore Ts'o
2015-02-26 14:38 ` Jan Kara
2015-02-26 19:27 ` Theodore Ts'o
2015-03-02 8:29 ` Jan Kara
2015-03-07 5:34 ` [PATCH] fs: make sure the timestamps for lazytime inodes eventually get written Theodore Ts'o
2015-03-08 10:06 ` Jan Kara
2015-03-08 19:06 ` Theodore Ts'o
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=20150226043304.GC11217@thunk.org \
--to=tytso@mit.edu \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.