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
63f1a598
Commit
63f1a598
authored
Aug 17, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Improved debug checks
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
2cbe5cfe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
22 deletions
+42
-22
fs/bcachefs/bset.c
fs/bcachefs/bset.c
+30
-13
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.c
+12
-9
No files found.
fs/bcachefs/bset.c
View file @
63f1a598
...
...
@@ -21,6 +21,16 @@
static
inline
void
__bch2_btree_node_iter_advance
(
struct
btree_node_iter
*
,
struct
btree
*
);
static
inline
unsigned
__btree_node_iter_used
(
struct
btree_node_iter
*
iter
)
{
unsigned
n
=
ARRAY_SIZE
(
iter
->
data
);
while
(
n
&&
__btree_node_iter_set_end
(
iter
,
n
-
1
))
--
n
;
return
n
;
}
struct
bset_tree
*
bch2_bkey_to_bset
(
struct
btree
*
b
,
struct
bkey_packed
*
k
)
{
return
bch2_bkey_to_bset_inlined
(
b
,
k
);
...
...
@@ -98,7 +108,8 @@ void bch2_dump_btree_node_iter(struct btree *b,
{
struct
btree_node_iter_set
*
set
;
printk
(
KERN_ERR
"btree node iter with %u sets:
\n
"
,
b
->
nsets
);
printk
(
KERN_ERR
"btree node iter with %u/%u sets:
\n
"
,
__btree_node_iter_used
(
iter
),
b
->
nsets
);
btree_node_iter_for_each
(
iter
,
set
)
{
struct
bkey_packed
*
k
=
__btree_node_offset_to_key
(
b
,
set
->
k
);
...
...
@@ -107,8 +118,8 @@ void bch2_dump_btree_node_iter(struct btree *b,
char
buf
[
100
];
bch2_bkey_to_text
(
&
PBUF
(
buf
),
&
uk
);
printk
(
KERN_ERR
"set %zu key %
zi/%u: %s
\n
"
,
t
-
b
->
set
,
k
->
_data
-
bset
(
b
,
t
)
->
_data
,
bset
(
b
,
t
)
->
u64s
,
buf
);
printk
(
KERN_ERR
"set %zu key %
u: %s
\n
"
,
t
-
b
->
set
,
set
->
k
,
buf
);
}
}
...
...
@@ -170,8 +181,12 @@ void bch2_btree_node_iter_verify(struct btree_node_iter *iter,
struct
btree
*
b
)
{
struct
btree_node_iter_set
*
set
,
*
s2
;
struct
bkey_packed
*
k
,
*
p
;
struct
bset_tree
*
t
;
if
(
bch2_btree_node_iter_end
(
iter
))
return
;
/* Verify no duplicates: */
btree_node_iter_for_each
(
iter
,
set
)
btree_node_iter_for_each
(
iter
,
s2
)
...
...
@@ -192,6 +207,18 @@ void bch2_btree_node_iter_verify(struct btree_node_iter *iter,
btree_node_iter_for_each
(
iter
,
set
)
BUG_ON
(
set
!=
iter
->
data
&&
btree_node_iter_cmp
(
b
,
set
[
-
1
],
set
[
0
])
>
0
);
k
=
bch2_btree_node_iter_peek_all
(
iter
,
b
);
for_each_bset
(
b
,
t
)
{
if
(
iter
->
data
[
0
].
end
==
t
->
end_offset
)
continue
;
p
=
bch2_bkey_prev_all
(
b
,
t
,
bch2_btree_node_iter_bset_pos
(
iter
,
b
,
t
));
BUG_ON
(
p
&&
bkey_iter_cmp
(
b
,
k
,
p
)
<
0
);
}
}
void
bch2_verify_insert_pos
(
struct
btree
*
b
,
struct
bkey_packed
*
where
,
...
...
@@ -1652,16 +1679,6 @@ void bch2_btree_node_iter_advance(struct btree_node_iter *iter,
__bch2_btree_node_iter_advance
(
iter
,
b
);
}
static
inline
unsigned
__btree_node_iter_used
(
struct
btree_node_iter
*
iter
)
{
unsigned
n
=
ARRAY_SIZE
(
iter
->
data
);
while
(
n
&&
__btree_node_iter_set_end
(
iter
,
n
-
1
))
--
n
;
return
n
;
}
/*
* Expensive:
*/
...
...
fs/bcachefs/btree_iter.c
View file @
63f1a598
...
...
@@ -1477,6 +1477,8 @@ __bch2_btree_iter_peek_slot_extents(struct btree_iter *iter)
EBUG_ON
(
bkey_cmp
(
k
.
k
->
p
,
iter
->
pos
)
<
0
);
EBUG_ON
(
bkey_deleted
(
k
.
k
));
iter
->
uptodate
=
BTREE_ITER_UPTODATE
;
__bch2_btree_iter_verify
(
iter
,
l
->
b
);
return
k
;
}
...
...
@@ -1507,6 +1509,8 @@ __bch2_btree_iter_peek_slot_extents(struct btree_iter *iter)
iter
->
k
=
n
;
iter
->
uptodate
=
BTREE_ITER_UPTODATE
;
__bch2_btree_iter_verify
(
iter
,
l
->
b
);
return
(
struct
bkey_s_c
)
{
&
iter
->
k
,
NULL
};
}
...
...
@@ -1539,19 +1543,18 @@ __bch2_btree_iter_peek_slot(struct btree_iter *iter)
goto
recheck
;
}
if
(
k
.
k
&&
!
bkey_deleted
(
k
.
k
)
&&
!
bkey_cmp
(
iter
->
pos
,
k
.
k
->
p
))
{
iter
->
uptodate
=
BTREE_ITER_UPTODATE
;
return
k
;
}
else
{
if
(
!
k
.
k
||
bkey_deleted
(
k
.
k
)
||
bkey_cmp
(
iter
->
pos
,
k
.
k
->
p
))
{
/* hole */
bkey_init
(
&
iter
->
k
);
iter
->
k
.
p
=
iter
->
pos
;
k
=
(
struct
bkey_s_c
)
{
&
iter
->
k
,
NULL
};
}
iter
->
uptodate
=
BTREE_ITER_UPTODATE
;
return
(
struct
bkey_s_c
)
{
&
iter
->
k
,
NULL
}
;
}
__bch2_btree_iter_verify
(
iter
,
l
->
b
)
;
return
k
;
}
struct
bkey_s_c
bch2_btree_iter_peek_slot
(
struct
btree_iter
*
iter
)
...
...
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