aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-02-23 23:05:27 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-02-23 23:05:27 -0500
commit8750c6d5fcbd3342b3d908d157f81d345c5325a7 (patch)
tree323e83b9f81379c696acc861555143a06a84eb7b /fs/ext4
parent7d8f9f7d150dded7b68e61ca6403a1f166fb4edf (diff)
ext4: Automatically allocate delay allocated blocks on rename
When renaming a file such that a link to another inode is overwritten, force any delay allocated blocks that to be allocated so that if the filesystem is mounted with data=ordered, the data blocks will be pushed out to disk along with the journal commit. Many application programs expect this, so we do this to avoid zero length files if the system crashes unexpectedly. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/namei.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 6e1ad68cdc7a..eb20246c8965 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2357,7 +2357,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2357 struct inode *old_inode, *new_inode; 2357 struct inode *old_inode, *new_inode;
2358 struct buffer_head *old_bh, *new_bh, *dir_bh; 2358 struct buffer_head *old_bh, *new_bh, *dir_bh;
2359 struct ext4_dir_entry_2 *old_de, *new_de; 2359 struct ext4_dir_entry_2 *old_de, *new_de;
2360 int retval; 2360 int retval, force_da_alloc = 0;
2361 2361
2362 old_bh = new_bh = dir_bh = NULL; 2362 old_bh = new_bh = dir_bh = NULL;
2363 2363
@@ -2497,6 +2497,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2497 ext4_mark_inode_dirty(handle, new_inode); 2497 ext4_mark_inode_dirty(handle, new_inode);
2498 if (!new_inode->i_nlink) 2498 if (!new_inode->i_nlink)
2499 ext4_orphan_add(handle, new_inode); 2499 ext4_orphan_add(handle, new_inode);
2500 force_da_alloc = 1;
2500 } 2501 }
2501 retval = 0; 2502 retval = 0;
2502 2503
@@ -2505,6 +2506,8 @@ end_rename:
2505 brelse(old_bh); 2506 brelse(old_bh);
2506 brelse(new_bh); 2507 brelse(new_bh);
2507 ext4_journal_stop(handle); 2508 ext4_journal_stop(handle);
2509 if (retval == 0 && force_da_alloc)
2510 ext4_alloc_da_blocks(old_inode);
2508 return retval; 2511 return retval;
2509} 2512}
2510 2513