Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
0fdf1804
Commit
0fdf1804
authored
Aug 01, 2018
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: extent unit tests
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
1fe08f31
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
fs/bcachefs/tests.c
fs/bcachefs/tests.c
+62
-0
No files found.
fs/bcachefs/tests.c
View file @
0fdf1804
...
...
@@ -271,6 +271,63 @@ static void test_iterate_slots_extents(struct bch_fs *c, u64 nr)
bch2_btree_iter_unlock
(
&
iter
);
}
/* extent unit tests */
u64
test_version
;
static
void
insert_test_extent
(
struct
bch_fs
*
c
,
u64
start
,
u64
end
)
{
struct
bkey_i_cookie
k
;
int
ret
;
//pr_info("inserting %llu-%llu v %llu", start, end, test_version);
bkey_cookie_init
(
&
k
.
k_i
);
k
.
k_i
.
k
.
p
.
offset
=
end
;
k
.
k_i
.
k
.
size
=
end
-
start
;
k
.
k_i
.
k
.
version
.
lo
=
test_version
++
;
ret
=
bch2_btree_insert
(
c
,
BTREE_ID_EXTENTS
,
&
k
.
k_i
,
NULL
,
NULL
,
NULL
,
0
);
BUG_ON
(
ret
);
}
static
void
__test_extent_overwrite
(
struct
bch_fs
*
c
,
u64
e1_start
,
u64
e1_end
,
u64
e2_start
,
u64
e2_end
)
{
insert_test_extent
(
c
,
e1_start
,
e1_end
);
insert_test_extent
(
c
,
e2_start
,
e2_end
);
delete_test_keys
(
c
);
}
static
void
test_extent_overwrite_front
(
struct
bch_fs
*
c
,
u64
nr
)
{
__test_extent_overwrite
(
c
,
0
,
64
,
0
,
32
);
__test_extent_overwrite
(
c
,
8
,
64
,
0
,
32
);
}
static
void
test_extent_overwrite_back
(
struct
bch_fs
*
c
,
u64
nr
)
{
__test_extent_overwrite
(
c
,
0
,
64
,
32
,
64
);
__test_extent_overwrite
(
c
,
0
,
64
,
32
,
72
);
}
static
void
test_extent_overwrite_middle
(
struct
bch_fs
*
c
,
u64
nr
)
{
__test_extent_overwrite
(
c
,
0
,
64
,
32
,
40
);
}
static
void
test_extent_overwrite_all
(
struct
bch_fs
*
c
,
u64
nr
)
{
__test_extent_overwrite
(
c
,
32
,
64
,
0
,
64
);
__test_extent_overwrite
(
c
,
32
,
64
,
0
,
128
);
__test_extent_overwrite
(
c
,
32
,
64
,
32
,
64
);
__test_extent_overwrite
(
c
,
32
,
64
,
32
,
128
);
}
/* perf tests */
static
u64
test_rand
(
void
)
...
...
@@ -499,6 +556,11 @@ void bch2_btree_perf_test(struct bch_fs *c, const char *testname,
perf_test
(
test_iterate_slots
);
perf_test
(
test_iterate_slots_extents
);
perf_test
(
test_extent_overwrite_front
);
perf_test
(
test_extent_overwrite_back
);
perf_test
(
test_extent_overwrite_middle
);
perf_test
(
test_extent_overwrite_all
);
if
(
!
j
.
fn
)
{
pr_err
(
"unknown test %s"
,
testname
);
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment