ext4: Use bitops to read/modify EXT4_I(inode)->i_state
At several places we modify EXT4_I(inode)->i_state without holding i_mutex (ext4_release_file, ext4_bmap, ext4_journalled_writepage, ext4_do_update_inode, ...). These modifications are racy and we can lose updates to i_state. So convert handling of i_state to use bitops which are atomic. Cc: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
@@ -365,12 +365,12 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode,
|
||||
* happened after we started the migrate. We need to
|
||||
* fail the migrate
|
||||
*/
|
||||
if (!(EXT4_I(inode)->i_state & EXT4_STATE_EXT_MIGRATE)) {
|
||||
if (!ext4_test_inode_state(inode, EXT4_STATE_EXT_MIGRATE)) {
|
||||
retval = -EAGAIN;
|
||||
up_write(&EXT4_I(inode)->i_data_sem);
|
||||
goto err_out;
|
||||
} else
|
||||
EXT4_I(inode)->i_state &= ~EXT4_STATE_EXT_MIGRATE;
|
||||
ext4_clear_inode_state(inode, EXT4_STATE_EXT_MIGRATE);
|
||||
/*
|
||||
* We have the extent map build with the tmp inode.
|
||||
* Now copy the i_data across
|
||||
@@ -533,7 +533,7 @@ int ext4_ext_migrate(struct inode *inode)
|
||||
* allocation.
|
||||
*/
|
||||
down_read((&EXT4_I(inode)->i_data_sem));
|
||||
EXT4_I(inode)->i_state |= EXT4_STATE_EXT_MIGRATE;
|
||||
ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE);
|
||||
up_read((&EXT4_I(inode)->i_data_sem));
|
||||
|
||||
handle = ext4_journal_start(inode, 1);
|
||||
|
Reference in New Issue
Block a user