diff options
| author | Mister Oyster <oysterized@gmail.com> | 2017-05-27 15:16:32 +0200 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-05-27 19:39:50 +0200 |
| commit | 91c9df9892c130fb9570b0a69ffbc7b3e2e28e9b (patch) | |
| tree | 809475c141813daec0f9f535313dc7f0acfba8df /fs/ext4/migrate.c | |
| parent | a804602513a759c2c86cbba4146c5012cd2c7786 (diff) | |
BACKPORT: ext4 from 3.18 to mtk-3.10
Diffstat (limited to 'fs/ext4/migrate.c')
| -rw-r--r-- | fs/ext4/migrate.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index d19efab66..a432634f2 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c @@ -39,8 +39,9 @@ static int finish_range(handle_t *handle, struct inode *inode, newext.ee_block = cpu_to_le32(lb->first_block); newext.ee_len = cpu_to_le16(lb->last_block - lb->first_block + 1); ext4_ext_store_pblock(&newext, lb->first_pblock); - path = ext4_ext_find_extent(inode, lb->first_block, NULL); - + /* Locking only for convinience since we are operating on temp inode */ + down_write(&EXT4_I(inode)->i_data_sem); + path = ext4_find_extent(inode, lb->first_block, NULL, 0); if (IS_ERR(path)) { retval = PTR_ERR(path); path = NULL; @@ -61,7 +62,9 @@ static int finish_range(handle_t *handle, struct inode *inode, */ if (needed && ext4_handle_has_enough_credits(handle, EXT4_RESERVE_TRANS_BLOCKS)) { + up_write((&EXT4_I(inode)->i_data_sem)); retval = ext4_journal_restart(handle, needed); + down_write((&EXT4_I(inode)->i_data_sem)); if (retval) goto err_out; } else if (needed) { @@ -70,17 +73,18 @@ static int finish_range(handle_t *handle, struct inode *inode, /* * IF not able to extend the journal restart the journal */ + up_write((&EXT4_I(inode)->i_data_sem)); retval = ext4_journal_restart(handle, needed); + down_write((&EXT4_I(inode)->i_data_sem)); if (retval) goto err_out; } } - retval = ext4_ext_insert_extent(handle, inode, path, &newext, 0); + retval = ext4_ext_insert_extent(handle, inode, &path, &newext, 0); err_out: - if (path) { - ext4_ext_drop_refs(path); - kfree(path); - } + up_write((&EXT4_I(inode)->i_data_sem)); + ext4_ext_drop_refs(path); + kfree(path); lb->first_pblock = 0; return retval; } @@ -494,7 +498,7 @@ int ext4_ext_migrate(struct inode *inode) * superblock modification. * * For the tmp_inode we already have committed the - * trascation that created the inode. Later as and + * transaction that created the inode. Later as and * when we add extents we extent the journal */ /* @@ -505,7 +509,7 @@ int ext4_ext_migrate(struct inode *inode) * with i_data_sem held to prevent racing with block * allocation. */ - down_read((&EXT4_I(inode)->i_data_sem)); + down_read(&EXT4_I(inode)->i_data_sem); ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE); up_read((&EXT4_I(inode)->i_data_sem)); @@ -616,7 +620,6 @@ int ext4_ind_migrate(struct inode *inode) struct ext4_inode_info *ei = EXT4_I(inode); struct ext4_extent *ex; unsigned int i, len; - ext4_lblk_t start, end; ext4_fsblk_t blk; handle_t *handle; int ret; @@ -630,14 +633,6 @@ int ext4_ind_migrate(struct inode *inode) EXT4_FEATURE_RO_COMPAT_BIGALLOC)) return -EOPNOTSUPP; - /* - * In order to get correct extent info, force all delayed allocation - * blocks to be allocated, otherwise delayed allocation blocks may not - * be reflected and bypass the checks on extent header. - */ - if (test_opt(inode->i_sb, DELALLOC)) - ext4_alloc_da_blocks(inode); - handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1); if (IS_ERR(handle)) return PTR_ERR(handle); @@ -655,13 +650,11 @@ int ext4_ind_migrate(struct inode *inode) goto errout; } if (eh->eh_entries == 0) - blk = len = start = end = 0; + blk = len = 0; else { len = le16_to_cpu(ex->ee_len); blk = ext4_ext_pblock(ex); - start = le32_to_cpu(ex->ee_block); - end = start + len - 1; - if (end >= EXT4_NDIR_BLOCKS) { + if (len > EXT4_NDIR_BLOCKS) { ret = -EOPNOTSUPP; goto errout; } @@ -669,7 +662,7 @@ int ext4_ind_migrate(struct inode *inode) ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS); memset(ei->i_data, 0, sizeof(ei->i_data)); - for (i = start; i <= end; i++) + for (i=0; i < len; i++) ei->i_data[i] = cpu_to_le32(blk++); ext4_mark_inode_dirty(handle, inode); errout: |
