From 7a08aa588a5a5c361cba37b0c083f83a055d7b1a Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 11 Jul 2008 19:27:31 -0400 Subject: [PATCH] --- yaml --- r: 101107 b: refs/heads/master c: 9ddfc3dc75b5cc55ff3cfa586e962d252f1db9d3 h: refs/heads/master i: 101105: f168f59fd385b59a39c917c4796cff48a2597c6f 101103: 2f678b51aafdb59250f08eb495440ad4df98da9d v: v3 --- [refs] | 2 +- trunk/fs/ext4/extents.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index d1522c2a220a..05365c827ad5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cf108bca465dde0c015f32dd453b99457d31c7c7 +refs/heads/master: 9ddfc3dc75b5cc55ff3cfa586e962d252f1db9d3 diff --git a/trunk/fs/ext4/extents.c b/trunk/fs/ext4/extents.c index b722bce7d662..7844bbb2bac0 100644 --- a/trunk/fs/ext4/extents.c +++ b/trunk/fs/ext4/extents.c @@ -2768,6 +2768,9 @@ void ext4_ext_truncate(struct inode *inode) if (inode->i_size & (sb->s_blocksize - 1)) ext4_block_truncate_page(handle, mapping, inode->i_size); + if (ext4_orphan_add(handle, inode)) + goto out_stop; + down_write(&EXT4_I(inode)->i_data_sem); ext4_ext_invalidate_cache(inode); @@ -2778,8 +2781,6 @@ void ext4_ext_truncate(struct inode *inode) * Probably we need not scan at all, * because page truncation is enough. */ - if (ext4_orphan_add(handle, inode)) - goto out_stop; /* we have to know where to truncate from in crash case */ EXT4_I(inode)->i_disksize = inode->i_size; @@ -2796,6 +2797,7 @@ void ext4_ext_truncate(struct inode *inode) handle->h_sync = 1; out_stop: + up_write(&EXT4_I(inode)->i_data_sem); /* * If this was a simple ftruncate() and the file will remain alive, * then we need to clear up the orphan record which we created above. @@ -2806,7 +2808,6 @@ void ext4_ext_truncate(struct inode *inode) if (inode->i_nlink) ext4_orphan_del(handle, inode); - up_write(&EXT4_I(inode)->i_data_sem); inode->i_mtime = inode->i_ctime = ext4_current_time(inode); ext4_mark_inode_dirty(handle, inode); ext4_journal_stop(handle);