aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ialloc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-02-09 16:27:09 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-02-09 16:27:09 -0500
commit1139575a927010390c6b38e4215a6d741b056074 (patch)
tree0fb06dbe63ed7aaa2e14ce4c03587fd9c4f87b63 /fs/ext4/ialloc.c
parent95eaefbdececae5e781d76d03fe7472a857c8c7a (diff)
ext4: start handle at the last possible moment when creating inodes
In ext4_{create,mknod,mkdir,symlink}(), don't start the journal handle until the inode has been succesfully allocated. In order to do this, we need to start the handle in the ext4_new_inode(). So create a new variant of this function, ext4_new_inode_start_handle(), so the handle can be created at the last possible minute, before we need to modify the inode allocation bitmap block. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r--fs/ext4/ialloc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 10bd6fecc9ff..91d8fe3aced3 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -634,8 +634,10 @@ static int find_group_other(struct super_block *sb, struct inode *parent,
634 * For other inodes, search forward from the parent directory's block 634 * For other inodes, search forward from the parent directory's block
635 * group to find a free inode. 635 * group to find a free inode.
636 */ 636 */
637struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode, 637struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
638 const struct qstr *qstr, __u32 goal, uid_t *owner) 638 umode_t mode, const struct qstr *qstr,
639 __u32 goal, uid_t *owner, int handle_type,
640 unsigned int line_no, int nblocks)
639{ 641{
640 struct super_block *sb; 642 struct super_block *sb;
641 struct buffer_head *inode_bitmap_bh = NULL; 643 struct buffer_head *inode_bitmap_bh = NULL;
@@ -725,6 +727,15 @@ repeat_in_this_group:
725 "inode=%lu", ino + 1); 727 "inode=%lu", ino + 1);
726 continue; 728 continue;
727 } 729 }
730 if (!handle) {
731 BUG_ON(nblocks <= 0);
732 handle = __ext4_journal_start_sb(dir->i_sb, line_no,
733 handle_type, nblocks);
734 if (IS_ERR(handle)) {
735 err = PTR_ERR(handle);
736 goto fail;
737 }
738 }
728 BUFFER_TRACE(inode_bitmap_bh, "get_write_access"); 739 BUFFER_TRACE(inode_bitmap_bh, "get_write_access");
729 err = ext4_journal_get_write_access(handle, inode_bitmap_bh); 740 err = ext4_journal_get_write_access(handle, inode_bitmap_bh);
730 if (err) 741 if (err)