TencentOS-kernel/fs/btrfs
Josef Bacik 7ad68f586b btrfs: fix error handling in commit_fs_roots
[ Upstream commit 4f4317c13a40194940acf4a71670179c4faca2b5 ]

While doing error injection I would sometimes get a corrupt file system.
This is because I was injecting errors at btrfs_search_slot, but would
only do it one time per stack.  This uncovered a problem in
commit_fs_roots, where if we get an error we would just break.  However
we're in a nested loop, the first loop being a loop to find all the
dirty fs roots, and then subsequent root updates would succeed clearing
the error value.

This isn't likely to happen in real scenarios, however we could
potentially get a random ENOMEM once and then not again, and we'd end up
with a corrupted file system.  Fix this by moving the error checking
around a bit to the main loop, as this is the only place where something
will fail, and return the error as soon as it occurs.

With this patch my reproducer no longer corrupts the file system.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-04-12 12:52:48 +08:00
..
tests Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Kconfig Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Makefile Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
acl.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
async-thread.c Btrfs: fix crash during unmount due to race with delayed inode workers 2021-03-16 16:26:08 +08:00
async-thread.h Btrfs: fix crash during unmount due to race with delayed inode workers 2021-03-16 16:26:08 +08:00
backref.c btrfs: backref, use correct count to resolve normal data refs 2021-04-12 12:51:49 +08:00
backref.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
block-group.c btrfs: splice remaining dirty_bg's onto the transaction dirty bg list 2021-04-12 12:52:35 +08:00
block-group.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
block-rsv.c btrfs: force chunk allocation if our global rsv is larger than metadata 2021-03-16 16:29:39 +08:00
block-rsv.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
btrfs_inode.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
check-integrity.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
check-integrity.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
compression.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
compression.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ctree.c btrfs: fix extent buffer leak on failure to copy root 2021-04-12 12:52:35 +08:00
ctree.h btrfs: fix backport of 2175bf57dc952 in 5.4.95 2021-04-12 12:52:08 +08:00
delalloc-space.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
delalloc-space.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
delayed-inode.c btrfs: qgroup: fix wrong qgroup metadata reserve for delayed inode 2021-03-16 16:39:59 +08:00
delayed-inode.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
delayed-ref.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
delayed-ref.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
dev-replace.c btrfs: dev-replace: fail mount if we don't have replace item with target device 2021-03-16 16:40:52 +08:00
dev-replace.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
dir-item.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
disk-io.c btrfs: fix overflow when copying corrupt csums for a message 2021-03-16 16:37:39 +08:00
disk-io.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
export.c btrfs: export helpers for subvolume name/id resolution 2021-03-16 16:34:27 +08:00
export.h btrfs: export helpers for subvolume name/id resolution 2021-03-16 16:34:27 +08:00
extent-tree.c btrfs: don't get an EINTR during drop_snapshot for reloc 2021-04-12 12:51:32 +08:00
extent_io.c btrfs: prevent NULL pointer dereference in extent_io_tree_panic 2021-04-12 12:51:21 +08:00
extent_io.h btrfs: trim: fix underflow in trim length to prevent access beyond device boundary 2021-03-16 16:43:32 +08:00
extent_map.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
extent_map.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
file-item.c btrfs: do not ignore error from btrfs_next_leaf() when inserting checksums 2021-03-16 16:29:21 +08:00
file.c btrfs: allow btrfs_truncate_block() to fallback to nocow for data space reservation 2021-03-16 16:37:58 +08:00
free-space-cache.c btrfs: clarify error returns values in __load_free_space_cache 2021-04-12 12:52:21 +08:00
free-space-cache.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
free-space-tree.c btrfs: fix possible free space tree corruption with online conversion 2021-04-12 12:51:44 +08:00
free-space-tree.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
inode-item.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
inode-map.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
inode-map.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
inode.c btrfs: allow btrfs_truncate_block() to fallback to nocow for data space reservation 2021-03-16 16:37:58 +08:00
ioctl.c btrfs: fix race when defragmenting leads to unnecessary IO 2021-03-16 16:43:49 +08:00
locking.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
locking.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
lzo.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
misc.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ordered-data.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ordered-data.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
orphan.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
print-tree.c btrfs: require only sector size alignment for parent eb bytenr 2021-03-16 16:36:03 +08:00
print-tree.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
props.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
props.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
qgroup.c btrfs: fix transaction leak and crash after RO remount caused by qgroup rescan 2021-04-12 12:51:23 +08:00
qgroup.h btrfs: make btrfs_qgroup_check_reserved_leak take btrfs_inode 2021-03-16 16:34:52 +08:00
raid56.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
raid56.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
rcu-string.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
reada.c btrfs: fix readahead hang and use-after-free after removing a device 2021-03-16 16:40:01 +08:00
ref-verify.c btrfs: ref-verify: fix memory leak in btrfs_ref_tree_mod 2021-03-16 16:40:52 +08:00
ref-verify.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
relocation.c btrfs: fix reloc root leak with 0 ref reloc roots on recovery 2021-04-12 12:52:35 +08:00
root-tree.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
scrub.c btrfs: allocate scrub workqueues outside of locks 2021-03-16 16:35:37 +08:00
send.c btrfs: send: fix invalid clone operations when cloning from the same file and root 2021-04-12 12:51:32 +08:00
send.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
space-info.c btrfs: take overcommit into account in inc_block_group_ro 2021-03-16 16:38:08 +08:00
space-info.h btrfs: take overcommit into account in inc_block_group_ro 2021-03-16 16:38:08 +08:00
struct-funcs.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
super.c btrfs: fix transaction leak and crash after RO remount caused by qgroup rescan 2021-04-12 12:51:23 +08:00
sysfs.c btrfs: sysfs: use NOFS for device creation 2021-03-16 16:34:01 +08:00
sysfs.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
transaction.c btrfs: fix error handling in commit_fs_roots 2021-04-12 12:52:48 +08:00
transaction.h btrfs: add wrapper for transaction abort predicate 2021-03-16 16:34:27 +08:00
tree-checker.c btrfs: tree-checker: check if chunk item end overflows 2021-04-12 12:51:22 +08:00
tree-checker.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tree-defrag.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tree-log.c btrfs: reschedule if necessary when logging directory items 2021-03-16 16:39:59 +08:00
tree-log.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ulist.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ulist.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
uuid-tree.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
volumes.c btrfs: fix lockdep splat in btrfs_recover_relocation 2021-04-12 12:51:32 +08:00
volumes.h btrfs: fix readahead hang and use-after-free after removing a device 2021-03-16 16:40:01 +08:00
xattr.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
xattr.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
zlib.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
zstd.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00