diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-13 00:26:01 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-13 22:48:17 -0400 |
commit | 9e203c43dc1cbaefb3888ee0ba885b2d20d47526 (patch) | |
tree | bd0e429e2d3410b54b602edfe8875ed33866c00e /fs/bcachefs/fs-io.c | |
parent | 82cf18f23e1ae17053983e325e550194f947e1f1 (diff) | |
download | linux-stable-9e203c43dc1cbaefb3888ee0ba885b2d20d47526.tar.gz linux-stable-9e203c43dc1cbaefb3888ee0ba885b2d20d47526.tar.bz2 linux-stable-9e203c43dc1cbaefb3888ee0ba885b2d20d47526.zip |
bcachefs: Fix missing write refs in fs fio paths
bch2_journal_flush_seq requires us to have a write ref
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs-io.c')
-rw-r--r-- | fs/bcachefs/fs-io.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 8c70123b6a0c..20b40477425f 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -174,18 +174,18 @@ void __bch2_i_sectors_acct(struct bch_fs *c, struct bch_inode_info *inode, static int bch2_flush_inode(struct bch_fs *c, struct bch_inode_info *inode) { - struct bch_inode_unpacked u; - int ret; - if (c->opts.journal_flush_disabled) return 0; - ret = bch2_inode_find_by_inum(c, inode_inum(inode), &u); - if (ret) - return ret; + if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_fsync)) + return -EROFS; - return bch2_journal_flush_seq(&c->journal, u.bi_journal_seq) ?: - bch2_inode_flush_nocow_writes(c, inode); + struct bch_inode_unpacked u; + int ret = bch2_inode_find_by_inum(c, inode_inum(inode), &u) ?: + bch2_journal_flush_seq(&c->journal, u.bi_journal_seq) ?: + bch2_inode_flush_nocow_writes(c, inode); + bch2_write_ref_put(c, BCH_WRITE_REF_fsync); + return ret; } int bch2_fsync(struct file *file, loff_t start, loff_t end, int datasync) |