Message ID | 20240331111744.7224-4-l@damenly.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ocfs2 bugs fixes exposed by fstests | expand |
On 3/31/24 7:17 PM, Su Yue wrote: > From: Su Yue <glass.su@suse.com> > > 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 > ======================================================================= > > Signed-off-by: Su Yue <glass.su@suse.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> > --- > fs/ocfs2/namei.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c > index 9221a33f917b..55c9d90caaaf 100644 > --- a/fs/ocfs2/namei.c > +++ b/fs/ocfs2/namei.c > @@ -797,6 +797,7 @@ static int ocfs2_link(struct dentry *old_dentry, > ocfs2_set_links_count(fe, inode->i_nlink); > fe->i_ctime = cpu_to_le64(inode_get_ctime_sec(inode)); > fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime_nsec(inode)); > + ocfs2_update_inode_fsync_trans(handle, inode, 0); > ocfs2_journal_dirty(handle, fe_bh); > > err = ocfs2_add_entry(handle, dentry, inode, > @@ -993,6 +994,7 @@ static int ocfs2_unlink(struct inode *dir, > drop_nlink(inode); > drop_nlink(inode); > ocfs2_set_links_count(fe, inode->i_nlink); > + ocfs2_update_inode_fsync_trans(handle, inode, 0); > ocfs2_journal_dirty(handle, fe_bh); > > inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 9221a33f917b..55c9d90caaaf 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -797,6 +797,7 @@ static int ocfs2_link(struct dentry *old_dentry, ocfs2_set_links_count(fe, inode->i_nlink); fe->i_ctime = cpu_to_le64(inode_get_ctime_sec(inode)); fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime_nsec(inode)); + ocfs2_update_inode_fsync_trans(handle, inode, 0); ocfs2_journal_dirty(handle, fe_bh); err = ocfs2_add_entry(handle, dentry, inode, @@ -993,6 +994,7 @@ static int ocfs2_unlink(struct inode *dir, drop_nlink(inode); drop_nlink(inode); ocfs2_set_links_count(fe, inode->i_nlink); + ocfs2_update_inode_fsync_trans(handle, inode, 0); ocfs2_journal_dirty(handle, fe_bh); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));