[PATCH] reiserfs: use mark_inode_dirty instead of reiserfs_update_sd
authorChris Mason <mason@suse.com>
Tue, 13 Sep 2005 08:25:17 +0000 (01:25 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 13 Sep 2005 15:22:29 +0000 (08:22 -0700)
reiserfs should use mark_inode_dirty during reiserfs_file_write and
reiserfs_commit_write.  This makes sure the inode is properly flagged as
dirty, which is used during O_SYNC to decide when to trigger log commits.

This patch also removes the O_SYNC check from reiserfs_commit_write, since
that gets dealt with properly at higher layers once we start using
mark_inode_dirty.

Thanks to Hifumi Hisashi <hifumi.hisashi@lab.ntt.co.jp> for catching this.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/reiserfs/file.c
fs/reiserfs/inode.c

index c9f178fb494f511207ca93b982e599f62d7f481d..c20babd6216d970bdb1fbf2c879cab4de7341d2f 100644 (file)
@@ -667,7 +667,7 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
        if (th->t_trans_id) {
                int err;
                // update any changes we made to blk count
-               reiserfs_update_sd(th, inode);
+               mark_inode_dirty(inode);
                err =
                    journal_end(th, inode->i_sb,
                                JOURNAL_PER_BALANCE_CNT * 3 + 1 +
@@ -855,17 +855,18 @@ static int reiserfs_submit_file_region_for_write(struct reiserfs_transaction_han
 
                if (th->t_trans_id) {
                        reiserfs_write_lock(inode->i_sb);
-                       reiserfs_update_sd(th, inode);  // And update on-disk metadata
+                       // this sets the proper flags for O_SYNC to trigger a commit
+                       mark_inode_dirty(inode);
                        reiserfs_write_unlock(inode->i_sb);
                } else
-                       inode->i_sb->s_op->dirty_inode(inode);
+                       mark_inode_dirty(inode);
 
                sd_update = 1;
        }
        if (th->t_trans_id) {
                reiserfs_write_lock(inode->i_sb);
                if (!sd_update)
-                       reiserfs_update_sd(th, inode);
+                       mark_inode_dirty(inode);
                status = journal_end(th, th->t_super, th->t_blocks_allocated);
                if (status)
                        retval = status;
@@ -1320,7 +1321,7 @@ static ssize_t reiserfs_file_write(struct file *file,     /* the file we are going t
                                return err;
                        }
                        reiserfs_update_inode_transaction(inode);
-                       reiserfs_update_sd(&th, inode);
+                       mark_inode_dirty(inode);
                        err = journal_end(&th, inode->i_sb, 1);
                        if (err) {
                                reiserfs_write_unlock(inode->i_sb);
index 1a8a1bf2154d10475a0bacc89b085070587d48d6..d76ee6c4f9b8874f1a26acdaa37a9fe9d693e490 100644 (file)
@@ -2639,6 +2639,12 @@ static int reiserfs_commit_write(struct file *f, struct page *page,
                }
                reiserfs_update_inode_transaction(inode);
                inode->i_size = pos;
+               /*
+                * this will just nest into our transaction.  It's important
+                * to use mark_inode_dirty so the inode gets pushed around on the
+                * dirty lists, and so that O_SYNC works as expected
+                */
+               mark_inode_dirty(inode);
                reiserfs_update_sd(&myth, inode);
                update_sd = 1;
                ret = journal_end(&myth, inode->i_sb, 1);
@@ -2649,21 +2655,13 @@ static int reiserfs_commit_write(struct file *f, struct page *page,
        if (th) {
                reiserfs_write_lock(inode->i_sb);
                if (!update_sd)
-                       reiserfs_update_sd(th, inode);
+                       mark_inode_dirty(inode);
                ret = reiserfs_end_persistent_transaction(th);
                reiserfs_write_unlock(inode->i_sb);
                if (ret)
                        goto out;
        }
 
-       /* we test for O_SYNC here so we can commit the transaction
-        ** for any packed tails the file might have had
-        */
-       if (f && (f->f_flags & O_SYNC)) {
-               reiserfs_write_lock(inode->i_sb);
-               ret = reiserfs_commit_for_inode(inode);
-               reiserfs_write_unlock(inode->i_sb);
-       }
       out:
        return ret;