Commit 88c6b61f authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Theodore Ts'o

ext4: move_extent improve bh vanishing success factor

Xiaoguang Wang has reported sporadic EBUSY failures of ext4/302
Unfortunetly there is nothing we can do if some other task holds BH's
refenrence.  So we must return EBUSY in this case.  But we can try
kicking the journal to see if the other task releases the bh reference
after the commit is complete.  Also decrease false positives by
properly checking for ENOSPC and retrying the allocation after kicking
the journal --- which is done by ext4_should_retry_alloc().

[ Modified by tytso to properly check for ENOSPC. ]
Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 0df1f248
...@@ -273,6 +273,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, ...@@ -273,6 +273,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
int replaced_count = 0; int replaced_count = 0;
int from = data_offset_in_page << orig_inode->i_blkbits; int from = data_offset_in_page << orig_inode->i_blkbits;
int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits; int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits;
struct super_block *sb = orig_inode->i_sb;
/* /*
* It needs twice the amount of ordinary journal buffers because * It needs twice the amount of ordinary journal buffers because
...@@ -405,10 +406,13 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, ...@@ -405,10 +406,13 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
page_cache_release(pagep[1]); page_cache_release(pagep[1]);
stop_journal: stop_journal:
ext4_journal_stop(handle); ext4_journal_stop(handle);
if (*err == -ENOSPC &&
ext4_should_retry_alloc(sb, &retries))
goto again;
/* Buffer was busy because probably is pinned to journal transaction, /* Buffer was busy because probably is pinned to journal transaction,
* force transaction commit may help to free it. */ * force transaction commit may help to free it. */
if (*err == -EBUSY && ext4_should_retry_alloc(orig_inode->i_sb, if (*err == -EBUSY && retries++ < 4 && EXT4_SB(sb)->s_journal &&
&retries)) jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal))
goto again; goto again;
return replaced_count; return replaced_count;
......
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