diff options
Diffstat (limited to 'fs/ext4/migrate.c')
| -rw-r--r-- | fs/ext4/migrate.c | 35 | 
1 files changed, 17 insertions, 18 deletions
| diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 81415814b00b..8b87bd0eac95 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 | 
| @@ -503,14 +503,10 @@ int ext4_ext_migrate(struct inode *inode) | |||
| 503 | } | 503 | } | 
| 504 | i_size_write(tmp_inode, i_size_read(inode)); | 504 | i_size_write(tmp_inode, i_size_read(inode)); | 
| 505 | /* | 505 | /* | 
| 506 | * We don't want the inode to be reclaimed | 506 | * Set the i_nlink to zero so it will be deleted later | 
| 507 | * if we got interrupted in between. We have | 507 | * when we drop inode reference. | 
| 508 | * this tmp inode carrying reference to the | ||
| 509 | * data blocks of the original file. We set | ||
| 510 | * the i_nlink to zero at the last stage after | ||
| 511 | * switching the original file to extent format | ||
| 512 | */ | 508 | */ | 
| 513 | tmp_inode->i_nlink = 1; | 509 | tmp_inode->i_nlink = 0; | 
| 514 | 510 | ||
| 515 | ext4_ext_tree_init(handle, tmp_inode); | 511 | ext4_ext_tree_init(handle, tmp_inode); | 
| 516 | ext4_orphan_add(handle, tmp_inode); | 512 | ext4_orphan_add(handle, tmp_inode); | 
| @@ -533,10 +529,20 @@ int ext4_ext_migrate(struct inode *inode) | |||
| 533 | * allocation. | 529 | * allocation. | 
| 534 | */ | 530 | */ | 
| 535 | down_read((&EXT4_I(inode)->i_data_sem)); | 531 | down_read((&EXT4_I(inode)->i_data_sem)); | 
| 536 | EXT4_I(inode)->i_state |= EXT4_STATE_EXT_MIGRATE; | 532 | ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE); | 
| 537 | up_read((&EXT4_I(inode)->i_data_sem)); | 533 | up_read((&EXT4_I(inode)->i_data_sem)); | 
| 538 | 534 | ||
| 539 | handle = ext4_journal_start(inode, 1); | 535 | handle = ext4_journal_start(inode, 1); | 
| 536 | if (IS_ERR(handle)) { | ||
| 537 | /* | ||
| 538 | * It is impossible to update on-disk structures without | ||
| 539 | * a handle, so just rollback in-core changes and live other | ||
| 540 | * work to orphan_list_cleanup() | ||
| 541 | */ | ||
| 542 | ext4_orphan_del(NULL, tmp_inode); | ||
| 543 | retval = PTR_ERR(handle); | ||
| 544 | goto out; | ||
| 545 | } | ||
| 540 | 546 | ||
| 541 | ei = EXT4_I(inode); | 547 | ei = EXT4_I(inode); | 
| 542 | i_data = ei->i_data; | 548 | i_data = ei->i_data; | 
| @@ -618,15 +624,8 @@ err_out: | |||
| 618 | 624 | ||
| 619 | /* Reset the extent details */ | 625 | /* Reset the extent details */ | 
| 620 | ext4_ext_tree_init(handle, tmp_inode); | 626 | ext4_ext_tree_init(handle, tmp_inode); | 
| 621 | |||
| 622 | /* | ||
| 623 | * Set the i_nlink to zero so that | ||
| 624 | * generic_drop_inode really deletes the | ||
| 625 | * inode | ||
| 626 | */ | ||
| 627 | tmp_inode->i_nlink = 0; | ||
| 628 | |||
| 629 | ext4_journal_stop(handle); | 627 | ext4_journal_stop(handle); | 
| 628 | out: | ||
| 630 | unlock_new_inode(tmp_inode); | 629 | unlock_new_inode(tmp_inode); | 
| 631 | iput(tmp_inode); | 630 | iput(tmp_inode); | 
| 632 | 631 | ||
