bcachefs: Make bch2_remap_range respect O_SYNC
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 20 May 2021 01:21:49 +0000 (21:21 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:04 +0000 (17:09 -0400)
Caught by xfstest generic/628

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/fs-io.c

index 763195ed0b3c5f552bdb535db698f9af406564b2..162f0eeb38df266ce275ca6a9b3b205a5b303c86 100644 (file)
@@ -2941,6 +2941,11 @@ loff_t bch2_remap_file_range(struct file *file_src, loff_t pos_src,
        if (pos_dst + ret > dst->v.i_size)
                i_size_write(&dst->v, pos_dst + ret);
        spin_unlock(&dst->v.i_lock);
+
+       if (((file_dst->f_flags & (__O_SYNC | O_DSYNC)) ||
+            IS_SYNC(file_inode(file_dst))) &&
+           !c->opts.journal_flush_disabled)
+               ret = bch2_journal_flush_seq(&c->journal, dst->ei_journal_seq);
 err:
        bch2_unlock_inodes(INODE_LOCK|INODE_PAGECACHE_BLOCK, src, dst);