From 83998ccd9bfff881f04ce03f6964f8a83e6c5b54 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Wed, 28 Feb 2018 12:48:53 -0700 Subject: gfs2: Dirty source inode during rename Mark the source inode dirty during a rename instead of just updating the underlying buffer head. Otherwise, fsync may find the inode clean and will then skip flushing the journal. A subsequent power failure will cause the rename to be lost. This happens in command sequences like: xfs_io -f -c 'pwrite 0 4096' -c 'fsync' foo mv foo bar xfs_io -c 'fsync' bar # power failure Fixes xfstests generic/322, generic/376. Signed-off-by: Andreas Gruenbacher Signed-off-by: Bob Peterson --- fs/gfs2/inode.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'fs/gfs2/inode.c') diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 59e0560180ec..8700eb815638 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1326,19 +1326,11 @@ static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) static int update_moved_ino(struct gfs2_inode *ip, struct gfs2_inode *ndip, int dir_rename) { - int error; - struct buffer_head *dibh; - if (dir_rename) return gfs2_dir_mvino(ip, &gfs2_qdotdot, ndip, DT_DIR); - error = gfs2_meta_inode_buffer(ip, &dibh); - if (error) - return error; ip->i_inode.i_ctime = current_time(&ip->i_inode); - gfs2_trans_add_meta(ip->i_gl, dibh); - gfs2_dinode_out(ip, dibh->b_data); - brelse(dibh); + mark_inode_dirty_sync(&ip->i_inode); return 0; } -- cgit v1.2.3