From: Jan Kara <jack@suse.cz>
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-v4 2/7] vfs: add support for a lazytime mount option
Date: Thu, 27 Nov 2014 14:14:21 +0100 [thread overview]
Message-ID: <20141127131421.GE30152@quack.suse.cz> (raw)
In-Reply-To: <1416997437-26092-3-git-send-email-tytso@mit.edu>
On Wed 26-11-14 05:23:52, Ted Tso wrote:
> Add a new mount option which enables a new "lazytime" mode. This mode
> causes atime, mtime, and ctime updates to only be made to the
> in-memory version of the inode. The on-disk times will only get
> updated when (a) if the inode needs to be updated for some non-time
> related change, (b) if userspace calls fsync(), syncfs() or sync(), or
> (c) just before an undeleted inode is evicted from memory.
>
> This is OK according to POSIX because there are no guarantees after a
> crash unless userspace explicitly requests via a fsync(2) call.
>
> For workloads which feature a large number of random write to a
> preallocated file, the lazytime mount option significantly reduces
> writes to the inode table. The repeated 4k writes to a single block
> will result in undesirable stress on flash devices and SMR disk
> drives. Even on conventional HDD's, the repeated writes to the inode
> table block will trigger Adjacent Track Interference (ATI) remediation
> latencies, which very negatively impact 99.9 percentile latencies ---
> which is a very big deal for web serving tiers (for example).
So this looks better to me than previous versions but I'm still not 100%
happy :)
Looking into the code & your patch I'd prefer to do something like:
* add support for I_DIRTY_TIME in __mark_inode_dirty() - update_time will
call __mark_inode_dirty() with this flag if any of the times was updated.
That way we can just remove your ->write_time() callback - filesystems
can just handle this in their ->dirty_inode() methods if they wish.
__mark_inode_dirty() will take care of moving inode into proper writeback
list (i_dirty / i_dirty_time), dirtied_when will be set to current time.
* change queue_io() to also call
moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io, time + 24hours)
For this you need to tweak move_expired_inodes() to take pointer to
timestamp instead of pointer to work but that's trivial. Also you want
probably leave time ->older_than_this value (i.e. without +24 hours) if
we are doing WB_SYNC_ALL writeback. With this you can remove
flush_sb_dirty_time() completely.
* Changes for iput() & fsync stay as they are.
And this should be all that's necessary. I'm not 100% sure about your dirty
bits naming changes - let's see how that will look like when the above more
substantial changes are done.
One technical detail below:
> diff --git a/fs/inode.c b/fs/inode.c
> index 8f5c4b5..9e464cc 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -1430,11 +1430,22 @@ static void iput_final(struct inode *inode)
> */
> void iput(struct inode *inode)
> {
> - if (inode) {
> - BUG_ON(inode->i_state & I_CLEAR);
> -
> - if (atomic_dec_and_lock(&inode->i_count, &inode->i_lock))
> - iput_final(inode);
> + if (!inode)
> + return;
> + BUG_ON(inode->i_state & I_CLEAR);
I think we can better handle this without retry at this place like:
if (atomic_read(&inode->i_count) == 1 && inode->i_nlink &&
(inode->i_state & I_DIRTY_TIME)) {
if (inode->i_op->write_time)
inode->i_op->write_time(inode);
else if (inode->i_sb->s_op->write_inode)
mark_inode_dirty_sync(inode);
}
Sure it will be one more read of i_count in the fast path but that's IMO
negligible.
BTW: Is the test for ->write_inode really needed? We don't do it e.g. in
update_time().
> +retry:
> + if (atomic_dec_and_lock(&inode->i_count, &inode->i_lock)) {
> + if (inode->i_nlink && (inode->i_state & I_DIRTY_TIME)) {
> + atomic_inc(&inode->i_count);
> + inode->i_state &= ~I_DIRTY_TIME;
> + spin_unlock(&inode->i_lock);
> + if (inode->i_op->write_time)
> + inode->i_op->write_time(inode);
> + else if (inode->i_sb->s_op->write_inode)
> + mark_inode_dirty_sync(inode);
> + goto retry;
> + }
> + iput_final(inode);
> }
> }
> EXPORT_SYMBOL(iput);
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2014-11-27 13:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 10:23 [PATCH-v4 0/7] add support for a lazytime mount option Theodore Ts'o
2014-11-26 10:23 ` [PATCH-v4 1/7] vfs: split update_time() into update_time() and write_time() Theodore Ts'o
2014-11-26 19:23 ` Christoph Hellwig
2014-11-27 12:34 ` Jan Kara
2014-11-27 15:25 ` Christoph Hellwig
2014-11-27 14:41 ` Theodore Ts'o
2014-11-27 15:28 ` Christoph Hellwig
2014-11-27 15:33 ` Theodore Ts'o
2014-11-27 16:49 ` Christoph Hellwig
2014-11-27 20:27 ` Theodore Ts'o
2014-12-01 9:28 ` Christoph Hellwig
2014-12-01 15:04 ` Theodore Ts'o
2014-12-01 17:18 ` David Sterba
2014-12-02 9:20 ` Christoph Hellwig
2014-12-02 15:09 ` Theodore Ts'o
2014-11-26 10:23 ` [PATCH-v4 2/7] vfs: add support for a lazytime mount option Theodore Ts'o
2014-11-27 13:14 ` Jan Kara [this message]
2014-11-27 20:19 ` Theodore Ts'o
2014-11-28 12:41 ` Jan Kara
2014-11-27 23:00 ` Theodore Ts'o
2014-11-28 5:36 ` Theodore Ts'o
2014-11-28 16:24 ` Jan Kara
2014-11-26 10:23 ` [PATCH-v4 3/7] vfs: don't let the dirty time inodes get more than a day stale Theodore Ts'o
2014-11-26 10:23 ` [PATCH-v4 4/7] vfs: add lazytime tracepoints for better debugging Theodore Ts'o
2014-11-26 10:23 ` [PATCH-v4 5/7] vfs: add find_active_inode_nowait() function Theodore Ts'o
2014-11-26 10:23 ` [PATCH-v4 6/7] ext4: add support for a lazytime mount option Theodore Ts'o
2014-11-26 19:24 ` Christoph Hellwig
2014-11-26 22:48 ` Dave Chinner
2014-11-26 23:10 ` Andreas Dilger
2014-11-26 23:35 ` Dave Chinner
2014-11-27 13:27 ` Jan Kara
2014-11-27 13:32 ` Jan Kara
2014-11-27 15:25 ` Theodore Ts'o
2014-11-27 15:41 ` Jan Kara
2014-11-27 20:13 ` Theodore Ts'o
2014-11-26 10:23 ` [PATCH-v4 7/7] btrfs: add an is_readonly() so btrfs can use common code for update_time() 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=20141127131421.GE30152@quack.suse.cz \
--to=jack@suse.cz \
--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;
as well as URLs for NNTP newsgroup(s).