aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ext3/file.c1
-rw-r--r--fs/ext3/inode.c27
2 files changed, 11 insertions, 17 deletions
diff --git a/fs/ext3/file.c b/fs/ext3/file.c
index f55df0e61cbd..86c8ab343f6f 100644
--- a/fs/ext3/file.c
+++ b/fs/ext3/file.c
@@ -71,7 +71,6 @@ const struct file_operations ext3_file_operations = {
71}; 71};
72 72
73const struct inode_operations ext3_file_inode_operations = { 73const struct inode_operations ext3_file_inode_operations = {
74 .truncate = ext3_truncate,
75 .setattr = ext3_setattr, 74 .setattr = ext3_setattr,
76#ifdef CONFIG_EXT3_FS_XATTR 75#ifdef CONFIG_EXT3_FS_XATTR
77 .setxattr = generic_setxattr, 76 .setxattr = generic_setxattr,
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 3aa05eebe0b8..b4051c9ac5f2 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -234,12 +234,10 @@ void ext3_evict_inode (struct inode *inode)
234 if (inode->i_blocks) 234 if (inode->i_blocks)
235 ext3_truncate(inode); 235 ext3_truncate(inode);
236 /* 236 /*
237 * Kill off the orphan record which ext3_truncate created. 237 * Kill off the orphan record created when the inode lost the last
238 * AKPM: I think this can be inside the above `if'. 238 * link. Note that ext3_orphan_del() has to be able to cope with the
239 * Note that ext3_orphan_del() has to be able to cope with the 239 * deletion of a non-existent orphan - ext3_truncate() could
240 * deletion of a non-existent orphan - this is because we don't 240 * have removed the record.
241 * know if ext3_truncate() actually created an orphan record.
242 * (Well, we could do this if we need to, but heck - it works)
243 */ 241 */
244 ext3_orphan_del(handle, inode); 242 ext3_orphan_del(handle, inode);
245 EXT3_I(inode)->i_dtime = get_seconds(); 243 EXT3_I(inode)->i_dtime = get_seconds();
@@ -890,6 +888,9 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
890 if (!create || err == -EIO) 888 if (!create || err == -EIO)
891 goto cleanup; 889 goto cleanup;
892 890
891 /*
892 * Block out ext3_truncate while we alter the tree
893 */
893 mutex_lock(&ei->truncate_mutex); 894 mutex_lock(&ei->truncate_mutex);
894 895
895 /* 896 /*
@@ -938,9 +939,6 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
938 */ 939 */
939 count = ext3_blks_to_allocate(partial, indirect_blks, 940 count = ext3_blks_to_allocate(partial, indirect_blks,
940 maxblocks, blocks_to_boundary); 941 maxblocks, blocks_to_boundary);
941 /*
942 * Block out ext3_truncate while we alter the tree
943 */
944 err = ext3_alloc_branch(handle, inode, indirect_blks, &count, goal, 942 err = ext3_alloc_branch(handle, inode, indirect_blks, &count, goal,
945 offsets + (partial - chain), partial); 943 offsets + (partial - chain), partial);
946 944
@@ -1849,7 +1847,7 @@ retry:
1849 loff_t end = offset + iov_length(iov, nr_segs); 1847 loff_t end = offset + iov_length(iov, nr_segs);
1850 1848
1851 if (end > isize) 1849 if (end > isize)
1852 vmtruncate(inode, isize); 1850 ext3_truncate_failed_write(inode);
1853 } 1851 }
1854 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1852 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1855 goto retry; 1853 goto retry;
@@ -1863,7 +1861,7 @@ retry:
1863 /* This is really bad luck. We've written the data 1861 /* This is really bad luck. We've written the data
1864 * but cannot extend i_size. Truncate allocated blocks 1862 * but cannot extend i_size. Truncate allocated blocks
1865 * and pretend the write failed... */ 1863 * and pretend the write failed... */
1866 ext3_truncate(inode); 1864 ext3_truncate_failed_write(inode);
1867 ret = PTR_ERR(handle); 1865 ret = PTR_ERR(handle);
1868 goto out; 1866 goto out;
1869 } 1867 }
@@ -2414,8 +2412,6 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
2414 2412
2415int ext3_can_truncate(struct inode *inode) 2413int ext3_can_truncate(struct inode *inode)
2416{ 2414{
2417 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2418 return 0;
2419 if (S_ISREG(inode->i_mode)) 2415 if (S_ISREG(inode->i_mode))
2420 return 1; 2416 return 1;
2421 if (S_ISDIR(inode->i_mode)) 2417 if (S_ISDIR(inode->i_mode))
@@ -3264,9 +3260,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
3264 3260
3265 if ((attr->ia_valid & ATTR_SIZE) && 3261 if ((attr->ia_valid & ATTR_SIZE) &&
3266 attr->ia_size != i_size_read(inode)) { 3262 attr->ia_size != i_size_read(inode)) {
3267 rc = vmtruncate(inode, attr->ia_size); 3263 truncate_setsize(inode, attr->ia_size);
3268 if (rc) 3264 ext3_truncate(inode);
3269 goto err_out;
3270 } 3265 }
3271 3266
3272 setattr_copy(inode, attr); 3267 setattr_copy(inode, attr);