From: Jan Kara <jack@suse.cz>
To: linux-ext4@vger.kernel.org
Subject: fsync on ext[34] working only by an accident
Date: Tue, 8 Sep 2009 15:26:01 +0200 [thread overview]
Message-ID: <20090908132601.GA17778@duck.suse.cz> (raw)
Hi,
When looking at how ext3/4 handles fsync, I've realized I don't
understand how writing out inode on fsync can work. The problem is that
ext3/4 mostly calls ext?_mark_inode_dirty() which actually does *not* dirty
the inode. It just copies the in-memory inode content to disk buffer.
So in particular the inode looks clean to VFS and our check in
ext?_sync_file() shouldn't trigger.
The only obvious case when we call mark_inode_dirty() is from write_end
functions when we update i_size but that's clearly not enough. Now I did
some research why things seem to be actually working. The trick is that
when allocating block, we call vfs_dq_alloc_block() which calls
mark_inode_dirty(). But that's all what's keeping our fsync / writeout
logic from breaking!
There are even some cases when the logic actually is broken (I've tested
it and it really does not work) - for example when you create an empty
file, the inode won't get written when you fsync it.
So what we should IMHO do is to convert all ext?_mark_inode_dirty()
calls to simple mark_inode_dirty() (or even maybe introduce and use
mark_inode_dirty_datasync() where appropriate). It will cost us some more
CPU and stack space but if we optimize ext3_dirty_inode() for the case
where handle is already started, it shouldn't be too bad.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next reply other threads:[~2009-09-08 13:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-08 13:26 Jan Kara [this message]
2009-09-10 6:46 ` fsync on ext[34] working only by an accident Aneesh Kumar K.V
2009-09-10 8:50 ` Jan Kara
2009-09-10 9:04 ` Aneesh Kumar K.V
2009-09-10 9:15 ` Jan Kara
2009-09-10 9:15 ` Aneesh Kumar K.V
2009-09-10 10:52 ` Jan Kara
2009-09-10 11:04 ` Aneesh Kumar K.V
2009-09-10 12:32 ` Jan Kara
2009-09-10 13:10 ` Theodore Tso
2009-09-10 14:06 ` Jan Kara
2009-09-10 16:52 ` Theodore Tso
2009-09-14 16:00 ` Jan Kara
2009-09-10 20:14 ` Mingming
2009-09-14 15:25 ` Jan Kara
2009-09-10 16:25 ` Aneesh Kumar K.V
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=20090908132601.GA17778@duck.suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
/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).