android_kernel_samsung_univ.../fs/btrfs
Qu Wenruo 40e082b99a btrfs: qgroup: Finish rescan when hit the last leaf of extent tree
[ Upstream commit ff3d27a048d926b3920ccdb75d98788c567cae0d ]

Under the following case, qgroup rescan can double account cowed tree
blocks:

In this case, extent tree only has one tree block.

-
| transid=5 last committed=4
| btrfs_qgroup_rescan_worker()
| |- btrfs_start_transaction()
| |  transid = 5
| |- qgroup_rescan_leaf()
|    |- btrfs_search_slot_for_read() on extent tree
|       Get the only extent tree block from commit root (transid = 4).
|       Scan it, set qgroup_rescan_progress to the last
|       EXTENT/META_ITEM + 1
|       now qgroup_rescan_progress = A + 1.
|
| fs tree get CoWed, new tree block is at A + 16K
| transid 5 get committed
-
| transid=6 last committed=5
| btrfs_qgroup_rescan_worker()
| btrfs_qgroup_rescan_worker()
| |- btrfs_start_transaction()
| |  transid = 5
| |- qgroup_rescan_leaf()
|    |- btrfs_search_slot_for_read() on extent tree
|       Get the only extent tree block from commit root (transid = 5).
|       scan it using qgroup_rescan_progress (A + 1).
|       found new tree block beyong A, and it's fs tree block,
|       account it to increase qgroup numbers.
-

In above case, tree block A, and tree block A + 16K get accounted twice,
while qgroup rescan should stop when it already reach the last leaf,
other than continue using its qgroup_rescan_progress.

Such case could happen by just looping btrfs/017 and with some
possibility it can hit such double qgroup accounting problem.

Fix it by checking the path to determine if we should finish qgroup
rescan, other than relying on next loop to exit.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-06 16:24:33 +02:00
..
tests btrfs: tests/qgroup: Fix wrong tree backref level 2018-05-30 07:49:09 +02:00
acl.c btrfs: preserve i_mode if __btrfs_set_acl() fails 2018-03-11 16:19:47 +01:00
async-thread.c
async-thread.h
backref.c
backref.h
btrfs_inode.h
check-integrity.c
check-integrity.h
compression.c
compression.h
ctree.c btrfs: Fix out of bounds access in btrfs_search_slot 2018-05-30 07:48:54 +02:00
ctree.h btrfs: store and load values of stripes_min/stripes_max in balance status item 2017-01-06 11:16:06 +01:00
delayed-inode.c
delayed-inode.h
delayed-ref.c
delayed-ref.h
dev-replace.c
dev-replace.h
dir-item.c
disk-io.c x86/cpufeature: Replace the old static_cpu_has() with safe variant 2018-07-17 11:31:44 +02:00
disk-io.h
export.c
export.h
extent_io.c btrfs: fix incorrect error return ret being passed to mapping_set_error 2018-04-13 19:50:06 +02:00
extent_io.h
extent_map.c
extent_map.h
extent-tree.c btrfs: Fix possible softlock on single core machines 2018-05-30 07:49:08 +02:00
extent-tree.h
file-item.c
file.c Btrfs: set plug for fsync 2018-05-30 07:48:54 +02:00
free-space-cache.c btrfs: fix deadlock when writing out space cache 2018-02-03 17:04:27 +01:00
free-space-cache.h
hash.c
hash.h
inode-item.c
inode-map.c
inode-map.h
inode.c Btrfs: fix unexpected cow in run_delalloc_nocow 2018-07-03 11:21:35 +02:00
ioctl.c Btrfs: fix clone vs chattr NODATASUM race 2018-07-03 11:21:30 +02:00
Kconfig
locking.c
locking.h
lzo.c
Makefile
math.h
ordered-data.c
ordered-data.h
orphan.c
print-tree.c
print-tree.h
props.c
props.h
qgroup.c btrfs: qgroup: Finish rescan when hit the last leaf of extent tree 2018-08-06 16:24:33 +02:00
qgroup.h
raid56.c Btrfs: make raid6 rebuild retry more 2018-07-03 11:21:24 +02:00
raid56.h
rcu-string.h
reada.c
relocation.c btrfs: fix NULL pointer dereference from free_reloc_roots() 2017-10-05 09:41:46 +02:00
root-tree.c
scrub.c btrfs: scrub: Don't use inode pages for device replace 2018-07-03 11:21:25 +02:00
send.c Btrfs: send, fix issuing write op when processing hole in no data mode 2018-05-30 07:49:03 +02:00
send.h
struct-funcs.c
super.c btrfs: resume qgroup rescan on rw remount 2017-09-13 14:09:46 -07:00
sysfs.c
sysfs.h
transaction.c
transaction.h
tree-defrag.c
tree-log.c btrfs: add barriers to btrfs_sync_log before log_commit_wait wakeups 2018-08-06 16:24:33 +02:00
tree-log.h
ulist.c
ulist.h
uuid-tree.c btrfs: return the actual error value from from btrfs_uuid_tree_iterate 2017-11-30 08:37:28 +00:00
volumes.c Btrfs: make raid6 rebuild retry more 2018-07-03 11:21:24 +02:00
volumes.h
xattr.c
xattr.h
zlib.c