diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-27 16:55:27 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-05-12 19:42:32 -0400 |
commit | 2d7d8d4a3be09162cddaa772fc32fb2ecee6e920 (patch) | |
tree | 674623b6996b647e479dfd4982bf0a0d24881453 | |
parent | e2359ad3f5f42497685a3aefef5fd3a4e590124b (diff) |
bcachefs: Check for folios that don't have bch_folio attached
With large folios, it's now incidentally possible to end up with a
clean, uptodate folio in the page cache that doesn't have a bch_folio
attached, if a folio has to be split.
This patch fixes __bch2_truncate_folio() to check for this; other code
paths appear to handle it.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/fs-io.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 46b37b18d687..aaa2e99617bd 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -883,6 +883,8 @@ static void bch2_set_folio_dirty(struct bch_fs *c, WARN_ON((u64) folio_pos(folio) + offset + len > round_up((u64) i_size_read(&inode->v), block_bytes(c))); + BUG_ON(!s->uptodate); + spin_lock(&s->lock); for (i = round_down(offset, block_bytes(c)) >> 9; @@ -2808,7 +2810,11 @@ static int __bch2_truncate_folio(struct bch_inode_info *inode, goto unlock; } - BUG_ON(!s->uptodate); + if (!s->uptodate) { + ret = bch2_folio_set(c, inode_inum(inode), &folio, 1); + if (ret) + goto unlock; + } for (i = round_up(start_offset, block_bytes(c)) >> 9; i < round_down(end_offset, block_bytes(c)) >> 9; |