Chris Mason
53aaa9f1a6
Btrfs: keep pages dirty when using btrfs_writepage_fixup_worker
...
[ Upstream commit 25f3c5021985e885292980d04a1423fd83c967bb ]
For COW, btrfs expects pages dirty pages to have been through a few setup
steps. This includes reserving space for the new block allocations and marking
the range in the state tree for delayed allocation.
A few places outside btrfs will dirty pages directly, especially when unmapping
mmap'd pages. In order for these to properly go through COW, we run them
through a fixup worker to wait for stable pages, and do the delalloc prep.
87826df0ec added a window where the dirty pages were cleaned, but pending
more action from the fixup worker. We clear_page_dirty_for_io() before
we call into writepage, so the page is no longer dirty. The commit
changed it so now we leave the page clean between unlocking it here and
the fixup worker starting at some point in the future.
During this window, page migration can jump in and relocate the page. Once our
fixup work actually starts, it finds page->mapping is NULL and we end up
freeing the page without ever writing it.
This leads to crc errors and other exciting problems, since it screws up the
whole statemachine for waiting for ordered extents. The fix here is to keep
the page dirty while we're waiting for the fixup worker to get to work.
This is accomplished by returning -EAGAIN from btrfs_writepage_cow_fixup
if we queued the page up for fixup, which will cause the writepage
function to redirty the page.
Because we now expect the page to be dirty once it gets to the fixup
worker we must adjust the error cases to call clear_page_dirty_for_io()
on the page. That is the bulk of the patch, but it is not the fix, the
fix is the -EAGAIN from btrfs_writepage_cow_fixup. We cannot separate
these two changes out because the error conditions change with the new
expectations.
Signed-off-by: Chris Mason <[email protected] >
Signed-off-by: Josef Bacik <[email protected] >
Reviewed-by: David Sterba <[email protected] >
Signed-off-by: David Sterba <[email protected] >
Signed-off-by: Sasha Levin <[email protected] >
2020-02-24 08:36:31 +01:00
..
tests
btrfs: Correctly handle empty trees in find_first_clear_extent_bit
2020-02-11 04:35:34 -08:00
acl.c
async-thread.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
async-thread.h
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
backref.c
Btrfs: fix deadlock between fiemap and transaction commits
2019-07-30 18:25:12 +02:00
backref.h
btrfs: fiemap: preallocate ulists for btrfs_check_shared
2019-07-01 13:34:53 +02:00
block-group.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
block-group.h
btrfs: move struct io_ctl to free-space-cache.h
2019-09-09 14:59:15 +02:00
block-rsv.c
btrfs: use btrfs_try_granting_tickets in update_global_rsv
2019-09-09 14:59:19 +02:00
block-rsv.h
btrfs: migrate the global_block_rsv helpers to block-rsv.c
2019-07-02 12:30:55 +02:00
btrfs_inode.h
btrfs: remove assumption about csum type form btrfs_print_data_csum_error()
2019-07-01 13:35:02 +02:00
check-integrity.c
btrfs: reduce stack usage for btrfsic_process_written_block
2019-09-09 14:58:58 +02:00
check-integrity.h
compression.c
btrfs: move cond_wake_up functions out of ctree
2019-09-09 14:59:15 +02:00
compression.h
btrfs: compression: replace set_level callbacks by a common helper
2019-09-09 14:59:11 +02:00
ctree.c
Btrfs: fix race between adding and putting tree mod seq elements and nodes
2020-02-11 04:35:34 -08:00
ctree.h
Btrfs: fix race between adding and putting tree mod seq elements and nodes
2020-02-11 04:35:34 -08:00
delalloc-space.c
Btrfs: fix qgroup double free after failure to reserve metadata for delalloc
2019-10-17 20:13:44 +02:00
delalloc-space.h
btrfs: migrate the delalloc space stuff to it's own home
2019-07-04 17:26:17 +02:00
delayed-inode.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
delayed-inode.h
delayed-ref.c
Btrfs: fix race between adding and putting tree mod seq elements and nodes
2020-02-11 04:35:34 -08:00
delayed-ref.h
btrfs: migrate the delayed refs rsv code
2019-07-04 17:26:17 +02:00
dev-replace.c
btrfs: move cond_wake_up functions out of ctree
2019-09-09 14:59:15 +02:00
dev-replace.h
dir-item.c
disk-io.c
btrfs: print message when tree-log replay starts
2020-02-19 19:53:00 +01:00
disk-io.h
btrfs: Make reada_tree_block_flagged private
2019-09-09 14:59:11 +02:00
export.c
export.h
extent-tree.c
btrfs: handle error in btrfs_cache_block_group
2020-01-12 12:21:30 +01:00
extent_io.c
btrfs: Correctly handle empty trees in find_first_clear_extent_bit
2020-02-11 04:35:34 -08:00
extent_io.h
btrfs: Remove delalloc_end argument from extent_clear_unlock_delalloc
2019-09-09 14:58:59 +02:00
extent_map.c
Btrfs: fix race between using extent maps and merging them
2020-02-19 19:53:00 +01:00
extent_map.h
file-item.c
Btrfs: fix missing data checksums after replaying a log tree
2019-12-31 16:41:58 +01:00
file.c
btrfs: simplify inode locking for RWF_NOWAIT
2020-01-17 19:48:32 +01:00
free-space-cache.c
btrfs: check page->mapping when loading free space cache
2019-12-17 19:56:02 +01:00
free-space-cache.h
btrfs: move struct io_ctl to free-space-cache.h
2019-09-09 14:59:15 +02:00
free-space-tree.c
btrfs: move basic block_group definitions to their own header
2019-09-09 14:59:03 +02:00
free-space-tree.h
btrfs: move basic block_group definitions to their own header
2019-09-09 14:59:03 +02:00
inode-item.c
btrfs: Make btrfs_find_name_in_ext_backref return struct btrfs_inode_extref
2019-09-09 14:59:16 +02:00
inode-map.c
btrfs: qgroup: Always free PREALLOC META reserve in btrfs_delalloc_release_extents()
2019-10-15 18:50:07 +02:00
inode-map.h
inode.c
Btrfs: keep pages dirty when using btrfs_writepage_fixup_worker
2020-02-24 08:36:31 +01:00
ioctl.c
Btrfs: make deduplication with range including the last block work
2020-02-11 04:35:33 -08:00
Kconfig
btrfs: Fix build error while LIBCRC32C is module
2019-07-17 17:03:30 +02:00
locking.c
btrfs: move cond_wake_up functions out of ctree
2019-09-09 14:59:15 +02:00
locking.h
btrfs: Remove unused locking functions
2019-09-09 14:58:59 +02:00
lzo.c
btrfs: compression: replace set_level callbacks by a common helper
2019-09-09 14:59:11 +02:00
Makefile
btrfs: migrate the block group lookup code
2019-09-09 14:59:04 +02:00
misc.h
btrfs: move math functions to misc.h
2019-09-09 14:59:15 +02:00
ordered-data.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
ordered-data.h
btrfs: don't assume ordered sums to be 4 bytes
2019-07-01 13:35:00 +02:00
orphan.c
print-tree.c
btrfs: switch extent_buffer write_locks from atomic to int
2019-07-02 12:30:47 +02:00
print-tree.h
props.c
btrfs: rename the btrfs_calc_*_metadata_size helpers
2019-09-09 14:59:13 +02:00
props.h
qgroup.c
btrfs: fix memory leak in qgroup accounting
2020-01-23 08:22:41 +01:00
qgroup.h
raid56.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
raid56.h
btrfs: constify map parameter for nr_parity_stripes and nr_data_stripes
2019-07-01 13:34:58 +02:00
rcu-string.h
reada.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
ref-verify.c
btrfs: ref-verify: fix memory leaks
2020-02-19 19:53:00 +01:00
ref-verify.h
relocation.c
btrfs: relocation: fix reloc_root lifespan and access
2020-01-23 08:22:40 +01:00
root-tree.c
btrfs: do not delete mismatched root refs
2020-01-23 08:22:40 +01:00
scrub.c
btrfs: get rid of unique workqueue helper functions
2020-01-09 10:20:06 +01:00
send.c
btrfs: send: remove WARN_ON for readonly mount
2019-12-31 16:41:59 +01:00
send.h
space-info.c
Btrfs: fix race leading to metadata space leak after task received signal
2019-10-25 19:11:34 +02:00
space-info.h
btrfs: rename btrfs_space_info_add_old_bytes
2019-09-09 14:59:18 +02:00
struct-funcs.c
btrfs: tie extent buffer and it's token together
2019-09-09 14:59:16 +02:00
super.c
btrfs: log message when rw remount is attempted with unclean tree-log
2020-02-19 19:53:01 +01:00
sysfs.c
btrfs: sysfs: move helper macros to sysfs.c
2019-09-09 14:59:08 +02:00
sysfs.h
btrfs: sysfs: move helper macros to sysfs.c
2019-09-09 14:59:08 +02:00
transaction.c
btrfs: drop log root for dropped roots
2020-02-11 04:35:33 -08:00
transaction.h
Btrfs: fix deadlock between fiemap and transaction commits
2019-07-30 18:25:12 +02:00
tree-checker.c
Btrfs: make tree checker detect checksum items with overlapping ranges
2019-12-31 16:41:55 +01:00
tree-checker.h
tree-defrag.c
tree-log.c
Btrfs: fix infinite loop during fsync after rename operations
2020-02-11 04:35:33 -08:00
tree-log.h
ulist.c
ulist.h
uuid-tree.c
btrfs: handle ENOENT in btrfs_uuid_tree_iterate
2019-12-31 16:42:05 +01:00
volumes.c
btrfs: Handle another split brain scenario with metadata uuid feature
2020-02-11 04:35:28 -08:00
volumes.h
btrfs: Remove btrfs_bio::flags member
2019-12-17 19:56:06 +01:00
xattr.c
xattr.h
zlib.c
btrfs: compression: replace set_level callbacks by a common helper
2019-09-09 14:59:11 +02:00
zstd.c
btrfs: move cond_wake_up functions out of ctree
2019-09-09 14:59:15 +02:00