diff options
author | Theodore Ts'o <tytso@mit.edu> | 2010-01-24 14:34:07 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-01-24 14:34:07 -0500 |
commit | 19f5fb7ad679bb361222c7916086435020c37cce (patch) | |
tree | 9e301163075c4faaf340cf50afd51855c76acd8c /fs/ext4/migrate.c | |
parent | d2eecb03936878ec574ade5532fa83df7d75dde7 (diff) |
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>
Diffstat (limited to 'fs/ext4/migrate.c')
-rw-r--r-- | fs/ext4/migrate.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 81415814b00b..46a4101e0aec 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c | |||
@@ -365,12 +365,12 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, | |||
365 | * happened after we started the migrate. We need to | 365 | * happened after we started the migrate. We need to |
366 | * fail the migrate | 366 | * fail the migrate |
367 | */ | 367 | */ |
368 | if (!(EXT4_I(inode)->i_state & EXT4_STATE_EXT_MIGRATE)) { | 368 | if (!ext4_test_inode_state(inode, EXT4_STATE_EXT_MIGRATE)) { |
369 | retval = -EAGAIN; | 369 | retval = -EAGAIN; |
370 | up_write(&EXT4_I(inode)->i_data_sem); | 370 | up_write(&EXT4_I(inode)->i_data_sem); |
371 | goto err_out; | 371 | goto err_out; |
372 | } else | 372 | } else |
373 | EXT4_I(inode)->i_state &= ~EXT4_STATE_EXT_MIGRATE; | 373 | ext4_clear_inode_state(inode, EXT4_STATE_EXT_MIGRATE); |
374 | /* | 374 | /* |
375 | * We have the extent map build with the tmp inode. | 375 | * We have the extent map build with the tmp inode. |
376 | * Now copy the i_data across | 376 | * Now copy the i_data across |
@@ -533,7 +533,7 @@ int ext4_ext_migrate(struct inode *inode) | |||
533 | * allocation. | 533 | * allocation. |
534 | */ | 534 | */ |
535 | down_read((&EXT4_I(inode)->i_data_sem)); | 535 | down_read((&EXT4_I(inode)->i_data_sem)); |
536 | EXT4_I(inode)->i_state |= EXT4_STATE_EXT_MIGRATE; | 536 | ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE); |
537 | up_read((&EXT4_I(inode)->i_data_sem)); | 537 | up_read((&EXT4_I(inode)->i_data_sem)); |
538 | 538 | ||
539 | handle = ext4_journal_start(inode, 1); | 539 | handle = ext4_journal_start(inode, 1); |