Commit 507388c9 authored by Andrew Morton's avatar Andrew Morton Committed by Dave Jones

[PATCH] speed up ext3_sync_file()

There is never a need to write out b_assoc_buffers() in ext3_sync_file().
parent 864c2acd
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* akpm: A new design for ext3_sync_file(). * akpm: A new design for ext3_sync_file().
* *
* This is only called from sys_fsync(), sys_fdatasync() and sys_msync(). * This is only called from sys_fsync(), sys_fdatasync() and sys_msync().
* There cannot be a transaction open by this task. (AKPM: quotas?) * There cannot be a transaction open by this task.
* Another task could have dirtied this inode. Its data can be in any * Another task could have dirtied this inode. Its data can be in any
* state in the journalling system. * state in the journalling system.
* *
...@@ -50,19 +50,28 @@ ...@@ -50,19 +50,28 @@
int ext3_sync_file(struct file * file, struct dentry *dentry, int datasync) int ext3_sync_file(struct file * file, struct dentry *dentry, int datasync)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int ret;
J_ASSERT(ext3_journal_current_handle() == 0); J_ASSERT(ext3_journal_current_handle() == 0);
/* /*
* fsync_inode_buffers() just walks private_list and waits * data=writeback:
* on them. It's a no-op for full data journalling because * The caller's filemap_fdatawrite()/wait will sync the data.
* private_list will be empty. * ext3_force_commit() will sync the metadata
* Really, we only need to start I/O on the dirty buffers - *
* we'll end up waiting on them in commit. * data=ordered:
* The caller's filemap_fdatawrite() will write the data and
* ext3_force_commit() will wait on the buffers. Then the caller's
* filemap_fdatawait() will wait on the pages (but all IO is complete)
* Not pretty, but it works.
*
* data=journal:
* filemap_fdatawrite won't do anything (the buffers are clean).
* ext3_force_commit will write the file data into the journal and
* will wait on that.
* filemap_fdatawait() will encounter a ton of newly-dirtied pages
* (they were dirtied by commit). But that's OK - the blocks are
* safe in-journal, which is all fsync() needs to ensure.
*/ */
ret = sync_mapping_buffers(inode->i_mapping);
ext3_force_commit(inode->i_sb); ext3_force_commit(inode->i_sb);
return 0;
return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment