Skip to content

Commit 8c40984

Browse files
Damenlyakpm00
authored andcommitted
ocfs2: update inode fsync transaction id in ocfs2_unlink and ocfs2_link
transaction id should be updated in ocfs2_unlink and ocfs2_link. Otherwise, inode link will be wrong after journal replay even fsync was called before power failure: ======================================================================= $ touch testdir/bar $ ln testdir/bar testdir/bar_link $ fsync testdir/bar $ stat -c %h $SCRATCH_MNT/testdir/bar 1 $ stat -c %h $SCRATCH_MNT/testdir/bar 1 ======================================================================= Link: https://lkml.kernel.org/r/[email protected] Fixes: ccd979b ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem") Signed-off-by: Su Yue <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Joel Becker <[email protected]> Cc: Jun Piao <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 952b023 commit 8c40984

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/ocfs2/namei.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ static int ocfs2_link(struct dentry *old_dentry,
797797
ocfs2_set_links_count(fe, inode->i_nlink);
798798
fe->i_ctime = cpu_to_le64(inode_get_ctime_sec(inode));
799799
fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime_nsec(inode));
800+
ocfs2_update_inode_fsync_trans(handle, inode, 0);
800801
ocfs2_journal_dirty(handle, fe_bh);
801802

802803
err = ocfs2_add_entry(handle, dentry, inode,
@@ -993,6 +994,7 @@ static int ocfs2_unlink(struct inode *dir,
993994
drop_nlink(inode);
994995
drop_nlink(inode);
995996
ocfs2_set_links_count(fe, inode->i_nlink);
997+
ocfs2_update_inode_fsync_trans(handle, inode, 0);
996998
ocfs2_journal_dirty(handle, fe_bh);
997999

9981000
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));

0 commit comments

Comments
 (0)