aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/extents.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index b722bce7d662..7844bbb2bac0 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2768,6 +2768,9 @@ void ext4_ext_truncate(struct inode *inode)
2768 if (inode->i_size & (sb->s_blocksize - 1)) 2768 if (inode->i_size & (sb->s_blocksize - 1))
2769 ext4_block_truncate_page(handle, mapping, inode->i_size); 2769 ext4_block_truncate_page(handle, mapping, inode->i_size);
2770 2770
2771 if (ext4_orphan_add(handle, inode))
2772 goto out_stop;
2773
2771 down_write(&EXT4_I(inode)->i_data_sem); 2774 down_write(&EXT4_I(inode)->i_data_sem);
2772 ext4_ext_invalidate_cache(inode); 2775 ext4_ext_invalidate_cache(inode);
2773 2776
@@ -2778,8 +2781,6 @@ void ext4_ext_truncate(struct inode *inode)
2778 * Probably we need not scan at all, 2781 * Probably we need not scan at all,
2779 * because page truncation is enough. 2782 * because page truncation is enough.
2780 */ 2783 */
2781 if (ext4_orphan_add(handle, inode))
2782 goto out_stop;
2783 2784
2784 /* we have to know where to truncate from in crash case */ 2785 /* we have to know where to truncate from in crash case */
2785 EXT4_I(inode)->i_disksize = inode->i_size; 2786 EXT4_I(inode)->i_disksize = inode->i_size;
@@ -2796,6 +2797,7 @@ void ext4_ext_truncate(struct inode *inode)
2796 handle->h_sync = 1; 2797 handle->h_sync = 1;
2797 2798
2798out_stop: 2799out_stop:
2800 up_write(&EXT4_I(inode)->i_data_sem);
2799 /* 2801 /*
2800 * If this was a simple ftruncate() and the file will remain alive, 2802 * If this was a simple ftruncate() and the file will remain alive,
2801 * then we need to clear up the orphan record which we created above. 2803 * then we need to clear up the orphan record which we created above.
@@ -2806,7 +2808,6 @@ out_stop:
2806 if (inode->i_nlink) 2808 if (inode->i_nlink)
2807 ext4_orphan_del(handle, inode); 2809 ext4_orphan_del(handle, inode);
2808 2810
2809 up_write(&EXT4_I(inode)->i_data_sem);
2810 inode->i_mtime = inode->i_ctime = ext4_current_time(inode); 2811 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
2811 ext4_mark_inode_dirty(handle, inode); 2812 ext4_mark_inode_dirty(handle, inode);
2812 ext4_journal_stop(handle); 2813 ext4_journal_stop(handle);