diff options
Diffstat (limited to 'fs/ext4/migrate.c')
-rw-r--r-- | fs/ext4/migrate.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 81415814b00b..34dcfc52ef44 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c | |||
@@ -13,6 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/slab.h> | ||
16 | #include "ext4_jbd2.h" | 17 | #include "ext4_jbd2.h" |
17 | #include "ext4_extents.h" | 18 | #include "ext4_extents.h" |
18 | 19 | ||
@@ -365,12 +366,12 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, | |||
365 | * happened after we started the migrate. We need to | 366 | * happened after we started the migrate. We need to |
366 | * fail the migrate | 367 | * fail the migrate |
367 | */ | 368 | */ |
368 | if (!(EXT4_I(inode)->i_state & EXT4_STATE_EXT_MIGRATE)) { | 369 | if (!ext4_test_inode_state(inode, EXT4_STATE_EXT_MIGRATE)) { |
369 | retval = -EAGAIN; | 370 | retval = -EAGAIN; |
370 | up_write(&EXT4_I(inode)->i_data_sem); | 371 | up_write(&EXT4_I(inode)->i_data_sem); |
371 | goto err_out; | 372 | goto err_out; |
372 | } else | 373 | } else |
373 | EXT4_I(inode)->i_state &= ~EXT4_STATE_EXT_MIGRATE; | 374 | ext4_clear_inode_state(inode, EXT4_STATE_EXT_MIGRATE); |
374 | /* | 375 | /* |
375 | * We have the extent map build with the tmp inode. | 376 | * We have the extent map build with the tmp inode. |
376 | * Now copy the i_data across | 377 | * Now copy the i_data across |
@@ -503,14 +504,10 @@ int ext4_ext_migrate(struct inode *inode) | |||
503 | } | 504 | } |
504 | i_size_write(tmp_inode, i_size_read(inode)); | 505 | i_size_write(tmp_inode, i_size_read(inode)); |
505 | /* | 506 | /* |
506 | * We don't want the inode to be reclaimed | 507 | * Set the i_nlink to zero so it will be deleted later |
507 | * if we got interrupted in between. We have | 508 | * 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 | */ | 509 | */ |
513 | tmp_inode->i_nlink = 1; | 510 | tmp_inode->i_nlink = 0; |
514 | 511 | ||
515 | ext4_ext_tree_init(handle, tmp_inode); | 512 | ext4_ext_tree_init(handle, tmp_inode); |
516 | ext4_orphan_add(handle, tmp_inode); | 513 | ext4_orphan_add(handle, tmp_inode); |
@@ -533,10 +530,20 @@ int ext4_ext_migrate(struct inode *inode) | |||
533 | * allocation. | 530 | * allocation. |
534 | */ | 531 | */ |
535 | down_read((&EXT4_I(inode)->i_data_sem)); | 532 | down_read((&EXT4_I(inode)->i_data_sem)); |
536 | EXT4_I(inode)->i_state |= EXT4_STATE_EXT_MIGRATE; | 533 | ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE); |
537 | up_read((&EXT4_I(inode)->i_data_sem)); | 534 | up_read((&EXT4_I(inode)->i_data_sem)); |
538 | 535 | ||
539 | handle = ext4_journal_start(inode, 1); | 536 | handle = ext4_journal_start(inode, 1); |
537 | if (IS_ERR(handle)) { | ||
538 | /* | ||
539 | * It is impossible to update on-disk structures without | ||
540 | * a handle, so just rollback in-core changes and live other | ||
541 | * work to orphan_list_cleanup() | ||
542 | */ | ||
543 | ext4_orphan_del(NULL, tmp_inode); | ||
544 | retval = PTR_ERR(handle); | ||
545 | goto out; | ||
546 | } | ||
540 | 547 | ||
541 | ei = EXT4_I(inode); | 548 | ei = EXT4_I(inode); |
542 | i_data = ei->i_data; | 549 | i_data = ei->i_data; |
@@ -618,15 +625,8 @@ err_out: | |||
618 | 625 | ||
619 | /* Reset the extent details */ | 626 | /* Reset the extent details */ |
620 | ext4_ext_tree_init(handle, tmp_inode); | 627 | 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); | 628 | ext4_journal_stop(handle); |
629 | out: | ||
630 | unlock_new_inode(tmp_inode); | 630 | unlock_new_inode(tmp_inode); |
631 | iput(tmp_inode); | 631 | iput(tmp_inode); |
632 | 632 | ||