aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/tests/extent-map-tests.c
AgeCommit message (Collapse)AuthorFilesLines
2022-03-14btrfs: assert we have a write lock when removing and replacing extent mapsFilipe Manana1-0/+2
Removing or replacing an extent map requires holding a write lock on the extent map's tree. We currently do that everywhere, except in one of the self tests, where it's harmless since there's no concurrency. In order to catch possible races in the future, assert that we are holding a write lock on the extent map tree before removing or replacing an extent map in the tree, and update the self test to obtain a write lock before removing extent maps. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
2021-06-22btrfs: fix typos in commentsDavid Sterba1-1/+1
Fix typos that have snuck in since the last round. Found by codespell. Signed-off-by: David Sterba <[email protected]>
2021-02-09btrfs: extend btrfs_rmap_block for specifying a deviceNaohiro Aota1-1/+1
btrfs_rmap_block currently reverse-maps the physical addresses on all devices to the corresponding logical addresses. Extend the function to match to a specified device. The old functionality of querying all devices is left intact by specifying NULL as target device. A block_device instead of a btrfs_device is passed into btrfs_rmap_block, as this function is intended to reverse-map the result of a bio, which only has a block_device. Also export the function for later use. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
2020-01-23btrfs: Add self-tests for btrfs_rmap_blockNikolay Borisov1-1/+153
Add RAID1 and single testcases to verify that data stripes are excluded from super block locations and that the address mapping is valid. Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> [ update changelog ] Signed-off-by: David Sterba <[email protected]>
2019-07-01btrfs: tests: add locks around add_extent_mappingDavid Sterba1-0/+22
There are no concerns about locking during the selftests so the locks are not necessary, but following patches will add lockdep assertions to add_extent_mapping so this is needed in tests too. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: fix comments about tested extent map rangesDavid Sterba1-2/+2
Comments about ranges did not match the code, the correct calculation is to use start and start+len as the interval boundaries. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: use SZ_ constants everywhereDavid Sterba1-3/+3
There are a few unconverted constants that are not powers of two and haven't been converted. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: use standard error message after extent map allocation failureDavid Sterba1-4/+19
Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: return error from all extent map test casesDavid Sterba1-12/+32
The way the extent map tests handle errors does not conform to the rest of the suite, where the first failure is reported and then it stops. Do the same now that we have the errors returned from all the functions. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: return errors from extent map test case 4David Sterba1-7/+14
Replace asserts with error messages and return errors. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: return errors from extent map test case 3David Sterba1-5/+10
Replace asserts with error messages and return errors. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: return errors from extent map test case 2David Sterba1-6/+14
Replace asserts with error messages and return errors. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: return errors from extent map test case 1David Sterba1-6/+14
Replace asserts with error messages and return errors. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: return errors from extent map testsDavid Sterba1-22/+46
The individual testcases for extent maps do not return an error on allocation failures. This is not a big problem as the allocation don't fail in general but there are functional tests handled with ASSERTS. This makes tests dependent on them and it's not reliable. This patch adds the allocation failure handling and allows for the conversion of the asserts to proper error handling and reporting. Signed-off-by: David Sterba <[email protected]>
2019-04-29btrfs: tests: use standard error message after fs_info allocation failureDavid Sterba1-1/+1
Signed-off-by: David Sterba <[email protected]>
2018-10-15Btrfs: extent_map: use rb_first_cachedLiu Bo1-2/+2
rb_first_cached() trades an extra pointer "leftmost" for doing the same job as rb_first() but in O(1). As evict_inode_truncate_pages() removes all extent mapping by always looking for the first rb entry, it's helpful to use rb_first_cached instead. For more details about the optimization see patch "Btrfs: delayed-refs: use rb_first_cached for href_root". Tested-by: Holger Hoffstätte <[email protected]> Signed-off-by: Liu Bo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-05-29btrfs: tests: drop newline from test_msg stringsDavid Sterba1-2/+2
Now that test_err strings do not need the newline, remove them also from the test_msg. Signed-off-by: David Sterba <[email protected]>
2018-05-29btrfs: tests: add helper for error messages and update themDavid Sterba1-15/+15
The test failures are not clearly visible in the system log as they're printed at INFO level. Add a new helper that is level ERROR. As this touches almost all strings, I took the opportunity to unify them: - decapitalize the first letter as there's a prefix and the text continues after ":" - glue strings split to more lines and un-indent so they fit to 80 columns - use %llu instead of %Lu - drop \n from the modified messages (test_msg is left untouched) Signed-off-by: David Sterba <[email protected]>
2018-05-28btrfs: use fs_info for btrfs_handle_em_exist tracepointDavid Sterba1-4/+4
We really want to know to which filesystem the extent map events belong, but as it cannot be reached from the extent_map pointers, we need to pass it down the callchain. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-05-28btrfs: tests: pass fs_info to extent_map testsDavid Sterba1-16/+36
Preparatory work to pass fs_info to btrfs_add_extent_mapping so we can get a better tracepoint message. Extent maps do not need fs_info for anything so we only add a dummy one without any other initialization. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-04-12btrfs: replace GPL boilerplate by SPDX -- sourcesDavid Sterba1-14/+1
Remove GPL boilerplate text (long, short, one-line) and keep the rest, ie. personal, company or original source copyright statements. Add the SPDX header. Signed-off-by: David Sterba <[email protected]>
2018-03-26Btrfs: extent map selftest: add missing void parameter to btrfs_test_extent_mapColin Ian King1-1/+1
Add a missing void parameter to function btrfs_test_extent_map, fixes sparse warning: warning: non-ANSI function declaration of function 'btrfs_test_extent_map' Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22Btrfs: extent map selftest: dio write vs dio readLiu Bo1-0/+89
This test case simulates the racy situation of dio write vs dio read, and see if btrfs_get_extent() would return -EEXIST. Signed-off-by: Liu Bo <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22Btrfs: extent map selftest: buffered write vs dio readLiu Bo1-0/+74
This test case simulates the racy situation of buffered write vs dio read, and see if btrfs_get_extent() would return -EEXIST. Signed-off-by: Liu Bo <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22Btrfs: add extent map selftestsLiu Bo1-0/+203
We've observed that btrfs_get_extent() and merge_extent_mapping() could return -EEXIST in several cases, and they are caused by some racy condition, e.g dio read vs dio write, which makes the problem very tricky to reproduce. This adds extent map selftests in order to simulate those racy situations. Signed-off-by: Liu Bo <[email protected]> Reviewed-by: Josef Bacik <[email protected]> [ minor string adjustments ] Signed-off-by: David Sterba <[email protected]>