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
e1120a4c
Commit
e1120a4c
authored
Mar 27, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Add iter->idx
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
ecc892e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
44 deletions
+28
-44
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.c
+10
-17
fs/bcachefs/btree_iter.h
fs/bcachefs/btree_iter.h
+16
-27
fs/bcachefs/btree_types.h
fs/bcachefs/btree_types.h
+2
-0
No files found.
fs/bcachefs/btree_iter.c
View file @
e1120a4c
...
...
@@ -1606,24 +1606,12 @@ static inline void bch2_btree_iter_init(struct btree_trans *trans,
/* new transactional stuff: */
static
inline
unsigned
btree_trans_iter_idx
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
)
{
ssize_t
idx
=
iter
-
trans
->
iters
;
EBUG_ON
(
idx
<
0
||
idx
>=
trans
->
nr_iters
);
EBUG_ON
(
!
(
trans
->
iters_linked
&
(
1ULL
<<
idx
)));
return
idx
;
}
int
bch2_trans_iter_put
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
)
{
ssize_t
idx
=
btree_trans_iter_idx
(
trans
,
iter
);
int
ret
=
btree_iter_err
(
iter
);
trans
->
iters_live
&=
~
(
1ULL
<<
idx
);
trans
->
iters_live
&=
~
(
1ULL
<<
i
ter
->
i
dx
);
return
ret
;
}
...
...
@@ -1643,7 +1631,7 @@ int bch2_trans_iter_free(struct btree_trans *trans,
{
int
ret
=
btree_iter_err
(
iter
);
__bch2_trans_iter_free
(
trans
,
btree_trans_iter_idx
(
trans
,
iter
)
);
__bch2_trans_iter_free
(
trans
,
iter
->
idx
);
return
ret
;
}
...
...
@@ -1652,8 +1640,7 @@ int bch2_trans_iter_free_on_commit(struct btree_trans *trans,
{
int
ret
=
btree_iter_err
(
iter
);
trans
->
iters_unlink_on_commit
|=
1ULL
<<
btree_trans_iter_idx
(
trans
,
iter
);
trans
->
iters_unlink_on_commit
|=
1ULL
<<
iter
->
idx
;
return
ret
;
}
...
...
@@ -1729,6 +1716,8 @@ static int btree_trans_iter_alloc(struct btree_trans *trans)
idx
=
trans
->
nr_iters
++
;
BUG_ON
(
trans
->
nr_iters
>
trans
->
size
);
trans
->
iters
[
idx
].
idx
=
idx
;
got_slot:
BUG_ON
(
trans
->
iters_linked
&
(
1ULL
<<
idx
));
trans
->
iters_linked
|=
1ULL
<<
idx
;
...
...
@@ -1826,6 +1815,7 @@ struct btree_iter *bch2_trans_copy_iter(struct btree_trans *trans,
struct
btree_iter
*
src
)
{
struct
btree_iter
*
iter
;
unsigned
offset
=
offsetof
(
struct
btree_iter
,
trans
);
int
i
,
idx
;
idx
=
btree_trans_iter_alloc
(
trans
);
...
...
@@ -1837,7 +1827,10 @@ struct btree_iter *bch2_trans_copy_iter(struct btree_trans *trans,
trans
->
iters_unlink_on_restart
|=
1ULL
<<
idx
;
iter
=
&
trans
->
iters
[
idx
];
*
iter
=
*
src
;
memcpy
((
void
*
)
iter
+
offset
,
(
void
*
)
src
+
offset
,
sizeof
(
*
iter
)
-
offset
);
for
(
i
=
0
;
i
<
BTREE_MAX_DEPTH
;
i
++
)
if
(
btree_node_locked
(
iter
,
i
))
...
...
fs/bcachefs/btree_iter.h
View file @
e1120a4c
...
...
@@ -36,15 +36,11 @@ static inline int btree_iter_err(const struct btree_iter *iter)
/* Iterate over iters within a transaction: */
static
inline
struct
btree_iter
*
__trans_next_iter
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
)
__trans_next_iter
(
struct
btree_trans
*
trans
,
unsigned
idx
)
{
unsigned
idx
;
EBUG_ON
(
idx
<
trans
->
nr_iters
&&
trans
->
iters
[
idx
].
idx
!=
idx
)
;
/* XXX expensive pointer subtraction: */
for
(
idx
=
iter
-
trans
->
iters
;
idx
<
trans
->
nr_iters
;
idx
++
)
for
(;
idx
<
trans
->
nr_iters
;
idx
++
)
if
(
trans
->
iters_linked
&
(
1ULL
<<
idx
))
return
&
trans
->
iters
[
idx
];
...
...
@@ -52,9 +48,9 @@ __trans_next_iter(struct btree_trans *trans, struct btree_iter *iter)
}
#define trans_for_each_iter(_trans, _iter) \
for (_iter =
(_trans)->iters;
\
(_iter
= __trans_next_iter((_trans), _iter));
\
_iter
++
)
for (_iter =
__trans_next_iter((_trans), 0);
\
(_iter
);
\
_iter
= __trans_next_iter((_trans), (_iter)->idx + 1)
)
static
inline
bool
__iter_has_node
(
const
struct
btree_iter
*
iter
,
const
struct
btree
*
b
)
...
...
@@ -73,30 +69,23 @@ static inline bool __iter_has_node(const struct btree_iter *iter,
static
inline
struct
btree_iter
*
__trans_next_iter_with_node
(
struct
btree_trans
*
trans
,
struct
btree
*
b
,
struct
btree_iter
*
iter
)
unsigned
idx
)
{
unsigned
idx
;
/* XXX expensive pointer subtraction: */
for
(
idx
=
iter
-
trans
->
iters
;
idx
<
trans
->
nr_iters
;
idx
++
)
{
if
(
!
(
trans
->
iters_linked
&
(
1ULL
<<
idx
)))
continue
;
EBUG_ON
(
idx
<
trans
->
nr_iters
&&
trans
->
iters
[
idx
].
idx
!=
idx
);
iter
=
&
trans
->
iters
[
idx
];
if
(
__iter_has_node
(
iter
,
b
))
return
iter
;
}
for
(;
idx
<
trans
->
nr_iters
;
idx
++
)
if
(
(
trans
->
iters_linked
&
(
1ULL
<<
idx
))
&&
__iter_has_node
(
&
trans
->
iters
[
idx
],
b
))
return
&
trans
->
iters
[
idx
];
return
NULL
;
}
#define trans_for_each_iter_with_node(_trans, _b, _iter) \
for (_iter = (_trans)->iters; \
(_iter = __trans_next_iter_with_node((_trans), (_b), _iter));\
_iter++)
for (_iter = __trans_next_iter_with_node((_trans), (_b), 0); \
(_iter); \
_iter = __trans_next_iter_with_node((_trans), (_b), \
(_iter)->idx + 1))
#ifdef CONFIG_BCACHEFS_DEBUG
void
bch2_btree_iter_verify
(
struct
btree_iter
*
,
struct
btree
*
);
...
...
fs/bcachefs/btree_types.h
View file @
e1120a4c
...
...
@@ -210,6 +210,8 @@ enum btree_iter_uptodate {
* @nodes_intent_locked - bitmask indicating which locks are intent locks
*/
struct
btree_iter
{
u8
idx
;
struct
btree_trans
*
trans
;
struct
bpos
pos
;
...
...
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