]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ext3 ordering fix
authorAndrew Morton <akpm@zip.com.au>
Wed, 12 Jun 2002 05:57:02 +0000 (22:57 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 12 Jun 2002 05:57:02 +0000 (22:57 -0700)
Fix the order of inodes being marked dirty in a couple of corner cases.

The only impact of this bug is that the on-disk copies of i_version
might got out of sync for a directory, or that an error inserting an
inode into a directory might leave its i_nlinks incorrect on disk for a
short interval.  Neither problem will cause trouble for ext3 during
normal operation, but the nlink problem might cause e2fsck to emit
unnecessary warnings if we crash while the incorrect version of the
inode is in the journal.

fs/ext3/namei.c

index 693bdd30ccbf5cc15aa716dbb3723af172a879f6..c3a0f0bd68e6c84277c759ac263a831e196a6aad 100644 (file)
@@ -514,8 +514,8 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode)
                        inode->i_mapping->a_ops = &ext3_writeback_aops;
                else
                        inode->i_mapping->a_ops = &ext3_aops;
-               ext3_mark_inode_dirty(handle, inode);
                err = ext3_add_nondir(handle, dentry, inode);
+               ext3_mark_inode_dirty(handle, inode);
        }
        ext3_journal_stop(handle, dir);
        unlock_kernel();
@@ -543,8 +543,8 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry,
        err = PTR_ERR(inode);
        if (!IS_ERR(inode)) {
                init_special_inode(inode, mode, rdev);
-               ext3_mark_inode_dirty(handle, inode);
                err = ext3_add_nondir(handle, dentry, inode);
+               ext3_mark_inode_dirty(handle, inode);
        }
        ext3_journal_stop(handle, dir);
        unlock_kernel();
@@ -1006,8 +1006,8 @@ static int ext3_symlink (struct inode * dir,
                inode->i_size = l-1;
        }
        EXT3_I(inode)->i_disksize = inode->i_size;
-       ext3_mark_inode_dirty(handle, inode);
        err = ext3_add_nondir(handle, dentry, inode);
+       ext3_mark_inode_dirty(handle, inode);
 out_stop:
        ext3_journal_stop(handle, dir);
        unlock_kernel();
@@ -1046,8 +1046,8 @@ static int ext3_link (struct dentry * old_dentry,
        ext3_inc_count(handle, inode);
        atomic_inc(&inode->i_count);
 
-       ext3_mark_inode_dirty(handle, inode);
        err = ext3_add_nondir(handle, dentry, inode);
+       ext3_mark_inode_dirty(handle, inode);
        ext3_journal_stop(handle, dir);
        unlock_kernel();
        return err;