mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
2ed45c0f18
If we have two (or more) tasks attempting to refill the delayed refs block reserve we can end up with the delayed block reserve being over reserved, that is, with a reserved space greater than its size. If this happens, we are holding to more reserved space than necessary for a while. The race happens like this: 1) The delayed refs block reserve has a size of 8M and a reserved space of 6M for example; 2) Task A calls btrfs_delayed_refs_rsv_refill(); 3) Task B also calls btrfs_delayed_refs_rsv_refill(); 4) Task A sees there's a 2M difference between the size and the reserved space of the delayed refs rsv, so it will reserve 2M of space by calling btrfs_reserve_metadata_bytes(); 5) Task B also sees that 2M difference, and like task A, it reserves another 2M of metadata space; 6) Both task A and task B increase the reserved space of block reserve by 2M, by calling btrfs_block_rsv_add_bytes(), so the block reserve ends up with a size of 8M and a reserved space of 10M; 7) The extra, over reserved space will eventually be freed by some task calling btrfs_delayed_refs_rsv_release() -> btrfs_block_rsv_release() -> block_rsv_release_bytes(), as there we will detect the over reserve and release that space. So fix this by checking if we still need to add space to the delayed refs block reserve after reserving the metadata space, and if we don't, just release that space immediately. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> |
||
---|---|---|
.. | ||
tests | ||
accessors.c | ||
accessors.h | ||
acl.c | ||
acl.h | ||
async-thread.c | ||
async-thread.h | ||
backref.c | ||
backref.h | ||
bio.c | ||
bio.h | ||
block-group.c | ||
block-group.h | ||
block-rsv.c | ||
block-rsv.h | ||
btrfs_inode.h | ||
check-integrity.c | ||
check-integrity.h | ||
compression.c | ||
compression.h | ||
ctree.c | ||
ctree.h | ||
defrag.c | ||
defrag.h | ||
delalloc-space.c | ||
delalloc-space.h | ||
delayed-inode.c | ||
delayed-inode.h | ||
delayed-ref.c | ||
delayed-ref.h | ||
dev-replace.c | ||
dev-replace.h | ||
dir-item.c | ||
dir-item.h | ||
discard.c | ||
discard.h | ||
disk-io.c | ||
disk-io.h | ||
export.c | ||
export.h | ||
extent-io-tree.c | ||
extent-io-tree.h | ||
extent-tree.c | ||
extent-tree.h | ||
extent_io.c | ||
extent_io.h | ||
extent_map.c | ||
extent_map.h | ||
file-item.c | ||
file-item.h | ||
file.c | ||
file.h | ||
free-space-cache.c | ||
free-space-cache.h | ||
free-space-tree.c | ||
free-space-tree.h | ||
fs.c | ||
fs.h | ||
inode-item.c | ||
inode-item.h | ||
inode.c | ||
ioctl.c | ||
ioctl.h | ||
Kconfig | ||
locking.c | ||
locking.h | ||
lru_cache.c | ||
lru_cache.h | ||
lzo.c | ||
Makefile | ||
messages.c | ||
messages.h | ||
misc.h | ||
ordered-data.c | ||
ordered-data.h | ||
orphan.c | ||
orphan.h | ||
print-tree.c | ||
print-tree.h | ||
props.c | ||
props.h | ||
qgroup.c | ||
qgroup.h | ||
raid56.c | ||
raid56.h | ||
rcu-string.h | ||
ref-verify.c | ||
ref-verify.h | ||
reflink.c | ||
reflink.h | ||
relocation.c | ||
relocation.h | ||
root-tree.c | ||
root-tree.h | ||
scrub.c | ||
scrub.h | ||
send.c | ||
send.h | ||
space-info.c | ||
space-info.h | ||
subpage.c | ||
subpage.h | ||
super.c | ||
super.h | ||
sysfs.c | ||
sysfs.h | ||
transaction.c | ||
transaction.h | ||
tree-checker.c | ||
tree-checker.h | ||
tree-log.c | ||
tree-log.h | ||
tree-mod-log.c | ||
tree-mod-log.h | ||
ulist.c | ||
ulist.h | ||
uuid-tree.c | ||
uuid-tree.h | ||
verity.c | ||
verity.h | ||
volumes.c | ||
volumes.h | ||
xattr.c | ||
xattr.h | ||
zlib.c | ||
zoned.c | ||
zoned.h | ||
zstd.c |