mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 17:41:50 +00:00
Merge branch 'ext3-latency-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'ext3-latency-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext3: Add replace-on-rename hueristics for data=writeback mode ext3: Add replace-on-truncate hueristics for data=writeback mode ext3: Use WRITE_SYNC for commits which are caused by fsync() block_write_full_page: Use synchronous writes for WBC_SYNC_ALL writebacks
This commit is contained in:
commit
20bec8ab14
8 changed files with 38 additions and 11 deletions
|
@ -1595,6 +1595,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
|
||||||
struct buffer_head *bh, *head;
|
struct buffer_head *bh, *head;
|
||||||
const unsigned blocksize = 1 << inode->i_blkbits;
|
const unsigned blocksize = 1 << inode->i_blkbits;
|
||||||
int nr_underway = 0;
|
int nr_underway = 0;
|
||||||
|
int write_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
|
||||||
|
|
||||||
BUG_ON(!PageLocked(page));
|
BUG_ON(!PageLocked(page));
|
||||||
|
|
||||||
|
@ -1686,7 +1687,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
|
||||||
do {
|
do {
|
||||||
struct buffer_head *next = bh->b_this_page;
|
struct buffer_head *next = bh->b_this_page;
|
||||||
if (buffer_async_write(bh)) {
|
if (buffer_async_write(bh)) {
|
||||||
submit_bh(WRITE, bh);
|
submit_bh(write_op, bh);
|
||||||
nr_underway++;
|
nr_underway++;
|
||||||
}
|
}
|
||||||
bh = next;
|
bh = next;
|
||||||
|
@ -1740,7 +1741,7 @@ recover:
|
||||||
struct buffer_head *next = bh->b_this_page;
|
struct buffer_head *next = bh->b_this_page;
|
||||||
if (buffer_async_write(bh)) {
|
if (buffer_async_write(bh)) {
|
||||||
clear_buffer_dirty(bh);
|
clear_buffer_dirty(bh);
|
||||||
submit_bh(WRITE, bh);
|
submit_bh(write_op, bh);
|
||||||
nr_underway++;
|
nr_underway++;
|
||||||
}
|
}
|
||||||
bh = next;
|
bh = next;
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
*/
|
*/
|
||||||
static int ext3_release_file (struct inode * inode, struct file * filp)
|
static int ext3_release_file (struct inode * inode, struct file * filp)
|
||||||
{
|
{
|
||||||
|
if (EXT3_I(inode)->i_state & EXT3_STATE_FLUSH_ON_CLOSE) {
|
||||||
|
filemap_flush(inode->i_mapping);
|
||||||
|
EXT3_I(inode)->i_state &= ~EXT3_STATE_FLUSH_ON_CLOSE;
|
||||||
|
}
|
||||||
/* if we are the last writer on the inode, drop the block reservation */
|
/* if we are the last writer on the inode, drop the block reservation */
|
||||||
if ((filp->f_mode & FMODE_WRITE) &&
|
if ((filp->f_mode & FMODE_WRITE) &&
|
||||||
(atomic_read(&inode->i_writecount) == 1))
|
(atomic_read(&inode->i_writecount) == 1))
|
||||||
|
|
|
@ -2363,6 +2363,9 @@ void ext3_truncate(struct inode *inode)
|
||||||
if (!ext3_can_truncate(inode))
|
if (!ext3_can_truncate(inode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (inode->i_size == 0 && ext3_should_writeback_data(inode))
|
||||||
|
ei->i_state |= EXT3_STATE_FLUSH_ON_CLOSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have to lock the EOF page here, because lock_page() nests
|
* We have to lock the EOF page here, because lock_page() nests
|
||||||
* outside journal_start().
|
* outside journal_start().
|
||||||
|
|
|
@ -2274,7 +2274,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
|
||||||
struct inode * old_inode, * new_inode;
|
struct inode * old_inode, * new_inode;
|
||||||
struct buffer_head * old_bh, * new_bh, * dir_bh;
|
struct buffer_head * old_bh, * new_bh, * dir_bh;
|
||||||
struct ext3_dir_entry_2 * old_de, * new_de;
|
struct ext3_dir_entry_2 * old_de, * new_de;
|
||||||
int retval;
|
int retval, flush_file = 0;
|
||||||
|
|
||||||
old_bh = new_bh = dir_bh = NULL;
|
old_bh = new_bh = dir_bh = NULL;
|
||||||
|
|
||||||
|
@ -2410,6 +2410,8 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
|
||||||
ext3_mark_inode_dirty(handle, new_inode);
|
ext3_mark_inode_dirty(handle, new_inode);
|
||||||
if (!new_inode->i_nlink)
|
if (!new_inode->i_nlink)
|
||||||
ext3_orphan_add(handle, new_inode);
|
ext3_orphan_add(handle, new_inode);
|
||||||
|
if (ext3_should_writeback_data(new_inode))
|
||||||
|
flush_file = 1;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
|
@ -2418,6 +2420,8 @@ end_rename:
|
||||||
brelse (old_bh);
|
brelse (old_bh);
|
||||||
brelse (new_bh);
|
brelse (new_bh);
|
||||||
ext3_journal_stop(handle);
|
ext3_journal_stop(handle);
|
||||||
|
if (retval == 0 && flush_file)
|
||||||
|
filemap_flush(old_inode->i_mapping);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/pagemap.h>
|
#include <linux/pagemap.h>
|
||||||
|
#include <linux/bio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default IO end handler for temporary BJ_IO buffer_heads.
|
* Default IO end handler for temporary BJ_IO buffer_heads.
|
||||||
|
@ -171,14 +172,15 @@ static int journal_write_commit_record(journal_t *journal,
|
||||||
return (ret == -EIO);
|
return (ret == -EIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
|
static void journal_do_submit_data(struct buffer_head **wbuf, int bufs,
|
||||||
|
int write_op)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < bufs; i++) {
|
for (i = 0; i < bufs; i++) {
|
||||||
wbuf[i]->b_end_io = end_buffer_write_sync;
|
wbuf[i]->b_end_io = end_buffer_write_sync;
|
||||||
/* We use-up our safety reference in submit_bh() */
|
/* We use-up our safety reference in submit_bh() */
|
||||||
submit_bh(WRITE, wbuf[i]);
|
submit_bh(write_op, wbuf[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +188,8 @@ static void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
|
||||||
* Submit all the data buffers to disk
|
* Submit all the data buffers to disk
|
||||||
*/
|
*/
|
||||||
static int journal_submit_data_buffers(journal_t *journal,
|
static int journal_submit_data_buffers(journal_t *journal,
|
||||||
transaction_t *commit_transaction)
|
transaction_t *commit_transaction,
|
||||||
|
int write_op)
|
||||||
{
|
{
|
||||||
struct journal_head *jh;
|
struct journal_head *jh;
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
|
@ -225,7 +228,7 @@ write_out_data:
|
||||||
BUFFER_TRACE(bh, "needs blocking lock");
|
BUFFER_TRACE(bh, "needs blocking lock");
|
||||||
spin_unlock(&journal->j_list_lock);
|
spin_unlock(&journal->j_list_lock);
|
||||||
/* Write out all data to prevent deadlocks */
|
/* Write out all data to prevent deadlocks */
|
||||||
journal_do_submit_data(wbuf, bufs);
|
journal_do_submit_data(wbuf, bufs, write_op);
|
||||||
bufs = 0;
|
bufs = 0;
|
||||||
lock_buffer(bh);
|
lock_buffer(bh);
|
||||||
spin_lock(&journal->j_list_lock);
|
spin_lock(&journal->j_list_lock);
|
||||||
|
@ -256,7 +259,7 @@ write_out_data:
|
||||||
jbd_unlock_bh_state(bh);
|
jbd_unlock_bh_state(bh);
|
||||||
if (bufs == journal->j_wbufsize) {
|
if (bufs == journal->j_wbufsize) {
|
||||||
spin_unlock(&journal->j_list_lock);
|
spin_unlock(&journal->j_list_lock);
|
||||||
journal_do_submit_data(wbuf, bufs);
|
journal_do_submit_data(wbuf, bufs, write_op);
|
||||||
bufs = 0;
|
bufs = 0;
|
||||||
goto write_out_data;
|
goto write_out_data;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +289,7 @@ write_out_data:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&journal->j_list_lock);
|
spin_unlock(&journal->j_list_lock);
|
||||||
journal_do_submit_data(wbuf, bufs);
|
journal_do_submit_data(wbuf, bufs, write_op);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -315,6 +318,7 @@ void journal_commit_transaction(journal_t *journal)
|
||||||
int first_tag = 0;
|
int first_tag = 0;
|
||||||
int tag_flag;
|
int tag_flag;
|
||||||
int i;
|
int i;
|
||||||
|
int write_op = WRITE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First job: lock down the current transaction and wait for
|
* First job: lock down the current transaction and wait for
|
||||||
|
@ -347,6 +351,8 @@ void journal_commit_transaction(journal_t *journal)
|
||||||
spin_lock(&journal->j_state_lock);
|
spin_lock(&journal->j_state_lock);
|
||||||
commit_transaction->t_state = T_LOCKED;
|
commit_transaction->t_state = T_LOCKED;
|
||||||
|
|
||||||
|
if (commit_transaction->t_synchronous_commit)
|
||||||
|
write_op = WRITE_SYNC;
|
||||||
spin_lock(&commit_transaction->t_handle_lock);
|
spin_lock(&commit_transaction->t_handle_lock);
|
||||||
while (commit_transaction->t_updates) {
|
while (commit_transaction->t_updates) {
|
||||||
DEFINE_WAIT(wait);
|
DEFINE_WAIT(wait);
|
||||||
|
@ -431,7 +437,8 @@ void journal_commit_transaction(journal_t *journal)
|
||||||
* Now start flushing things to disk, in the order they appear
|
* Now start flushing things to disk, in the order they appear
|
||||||
* on the transaction lists. Data blocks go first.
|
* on the transaction lists. Data blocks go first.
|
||||||
*/
|
*/
|
||||||
err = journal_submit_data_buffers(journal, commit_transaction);
|
err = journal_submit_data_buffers(journal, commit_transaction,
|
||||||
|
write_op);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for all previously submitted IO to complete.
|
* Wait for all previously submitted IO to complete.
|
||||||
|
@ -660,7 +667,7 @@ start_journal_io:
|
||||||
clear_buffer_dirty(bh);
|
clear_buffer_dirty(bh);
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
bh->b_end_io = journal_end_buffer_io_sync;
|
bh->b_end_io = journal_end_buffer_io_sync;
|
||||||
submit_bh(WRITE, bh);
|
submit_bh(write_op, bh);
|
||||||
}
|
}
|
||||||
cond_resched();
|
cond_resched();
|
||||||
|
|
||||||
|
|
|
@ -1440,6 +1440,8 @@ int journal_stop(handle_t *handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (handle->h_sync)
|
||||||
|
transaction->t_synchronous_commit = 1;
|
||||||
current->journal_info = NULL;
|
current->journal_info = NULL;
|
||||||
spin_lock(&journal->j_state_lock);
|
spin_lock(&journal->j_state_lock);
|
||||||
spin_lock(&transaction->t_handle_lock);
|
spin_lock(&transaction->t_handle_lock);
|
||||||
|
|
|
@ -208,6 +208,7 @@ static inline __u32 ext3_mask_flags(umode_t mode, __u32 flags)
|
||||||
#define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */
|
#define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */
|
||||||
#define EXT3_STATE_NEW 0x00000002 /* inode is newly created */
|
#define EXT3_STATE_NEW 0x00000002 /* inode is newly created */
|
||||||
#define EXT3_STATE_XATTR 0x00000004 /* has in-inode xattrs */
|
#define EXT3_STATE_XATTR 0x00000004 /* has in-inode xattrs */
|
||||||
|
#define EXT3_STATE_FLUSH_ON_CLOSE 0x00000008
|
||||||
|
|
||||||
/* Used to pass group descriptor data when online resize is done */
|
/* Used to pass group descriptor data when online resize is done */
|
||||||
struct ext3_new_group_input {
|
struct ext3_new_group_input {
|
||||||
|
|
|
@ -552,6 +552,11 @@ struct transaction_s
|
||||||
*/
|
*/
|
||||||
int t_handle_count;
|
int t_handle_count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This transaction is being forced and some process is
|
||||||
|
* waiting for it to finish.
|
||||||
|
*/
|
||||||
|
int t_synchronous_commit:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue