diff options
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r-- | fs/f2fs/file.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c58e33075719..7d8b96275092 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -659,16 +659,19 @@ static int expand_inode_data(struct inode *inode, loff_t offset, | |||
659 | off_start = offset & (PAGE_CACHE_SIZE - 1); | 659 | off_start = offset & (PAGE_CACHE_SIZE - 1); |
660 | off_end = (offset + len) & (PAGE_CACHE_SIZE - 1); | 660 | off_end = (offset + len) & (PAGE_CACHE_SIZE - 1); |
661 | 661 | ||
662 | f2fs_lock_op(sbi); | ||
663 | |||
662 | for (index = pg_start; index <= pg_end; index++) { | 664 | for (index = pg_start; index <= pg_end; index++) { |
663 | struct dnode_of_data dn; | 665 | struct dnode_of_data dn; |
664 | 666 | ||
665 | f2fs_lock_op(sbi); | 667 | if (index == pg_end && !off_end) |
668 | goto noalloc; | ||
669 | |||
666 | set_new_dnode(&dn, inode, NULL, NULL, 0); | 670 | set_new_dnode(&dn, inode, NULL, NULL, 0); |
667 | ret = f2fs_reserve_block(&dn, index); | 671 | ret = f2fs_reserve_block(&dn, index); |
668 | f2fs_unlock_op(sbi); | ||
669 | if (ret) | 672 | if (ret) |
670 | break; | 673 | break; |
671 | 674 | noalloc: | |
672 | if (pg_start == pg_end) | 675 | if (pg_start == pg_end) |
673 | new_size = offset + len; | 676 | new_size = offset + len; |
674 | else if (index == pg_start && off_start) | 677 | else if (index == pg_start && off_start) |
@@ -683,8 +686,9 @@ static int expand_inode_data(struct inode *inode, loff_t offset, | |||
683 | i_size_read(inode) < new_size) { | 686 | i_size_read(inode) < new_size) { |
684 | i_size_write(inode, new_size); | 687 | i_size_write(inode, new_size); |
685 | mark_inode_dirty(inode); | 688 | mark_inode_dirty(inode); |
686 | f2fs_write_inode(inode, NULL); | 689 | update_inode_page(inode); |
687 | } | 690 | } |
691 | f2fs_unlock_op(sbi); | ||
688 | 692 | ||
689 | return ret; | 693 | return ret; |
690 | } | 694 | } |