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
0fa3b977
Commit
0fa3b977
authored
Dec 17, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: btree_node_u64s_with_format() takes nr keys
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
e8c76927
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
17 deletions
+14
-17
fs/bcachefs/btree_update_interior.c
fs/bcachefs/btree_update_interior.c
+14
-13
fs/bcachefs/btree_update_interior.h
fs/bcachefs/btree_update_interior.h
+0
-4
No files found.
fs/bcachefs/btree_update_interior.c
View file @
0fa3b977
...
@@ -99,7 +99,7 @@ static void btree_node_interior_verify(struct bch_fs *c, struct btree *b)
...
@@ -99,7 +99,7 @@ static void btree_node_interior_verify(struct bch_fs *c, struct btree *b)
/* Calculate ideal packed bkey format for new btree nodes: */
/* Calculate ideal packed bkey format for new btree nodes: */
void
__bch2_btree_calc_format
(
struct
bkey_format_state
*
s
,
struct
btree
*
b
)
static
void
__bch2_btree_calc_format
(
struct
bkey_format_state
*
s
,
struct
btree
*
b
)
{
{
struct
bkey_packed
*
k
;
struct
bkey_packed
*
k
;
struct
bset_tree
*
t
;
struct
bset_tree
*
t
;
...
@@ -125,21 +125,20 @@ static struct bkey_format bch2_btree_calc_format(struct btree *b)
...
@@ -125,21 +125,20 @@ static struct bkey_format bch2_btree_calc_format(struct btree *b)
return
bch2_bkey_format_done
(
&
s
);
return
bch2_bkey_format_done
(
&
s
);
}
}
static
size_t
btree_node_u64s_with_format
(
struct
btree
*
b
,
static
size_t
btree_node_u64s_with_format
(
struct
btree_nr_keys
nr
,
struct
bkey_format
*
old_f
,
struct
bkey_format
*
new_f
)
struct
bkey_format
*
new_f
)
{
{
struct
bkey_format
*
old_f
=
&
b
->
format
;
/* stupid integer promotion rules */
/* stupid integer promotion rules */
ssize_t
delta
=
ssize_t
delta
=
(((
int
)
new_f
->
key_u64s
-
old_f
->
key_u64s
)
*
(((
int
)
new_f
->
key_u64s
-
old_f
->
key_u64s
)
*
(
int
)
b
->
nr
.
packed_keys
)
+
(
int
)
nr
.
packed_keys
)
+
(((
int
)
new_f
->
key_u64s
-
BKEY_U64s
)
*
(((
int
)
new_f
->
key_u64s
-
BKEY_U64s
)
*
(
int
)
b
->
nr
.
unpacked_keys
);
(
int
)
nr
.
unpacked_keys
);
BUG_ON
(
delta
+
b
->
nr
.
live_u64s
<
0
);
BUG_ON
(
delta
+
nr
.
live_u64s
<
0
);
return
b
->
nr
.
live_u64s
+
delta
;
return
nr
.
live_u64s
+
delta
;
}
}
/**
/**
...
@@ -147,16 +146,18 @@ static size_t btree_node_u64s_with_format(struct btree *b,
...
@@ -147,16 +146,18 @@ static size_t btree_node_u64s_with_format(struct btree *b,
*
*
* @c: filesystem handle
* @c: filesystem handle
* @b: btree node to rewrite
* @b: btree node to rewrite
* @nr: number of keys for new node (i.e. b->nr)
* @new_f: bkey format to translate keys to
* @new_f: bkey format to translate keys to
*
*
* Returns: true if all re-packed keys will be able to fit in a new node.
* Returns: true if all re-packed keys will be able to fit in a new node.
*
*
* Assumes all keys will successfully pack with the new format.
* Assumes all keys will successfully pack with the new format.
*/
*/
bool
bch2_btree_node_format_fits
(
struct
bch_fs
*
c
,
struct
btree
*
b
,
static
bool
bch2_btree_node_format_fits
(
struct
bch_fs
*
c
,
struct
btree
*
b
,
struct
btree_nr_keys
nr
,
struct
bkey_format
*
new_f
)
struct
bkey_format
*
new_f
)
{
{
size_t
u64s
=
btree_node_u64s_with_format
(
b
,
new_f
);
size_t
u64s
=
btree_node_u64s_with_format
(
nr
,
&
b
->
format
,
new_f
);
return
__vstruct_bytes
(
struct
btree_node
,
u64s
)
<
btree_bytes
(
c
);
return
__vstruct_bytes
(
struct
btree_node
,
u64s
)
<
btree_bytes
(
c
);
}
}
...
@@ -391,7 +392,7 @@ static struct btree *bch2_btree_node_alloc_replacement(struct btree_update *as,
...
@@ -391,7 +392,7 @@ static struct btree *bch2_btree_node_alloc_replacement(struct btree_update *as,
* The keys might expand with the new format - if they wouldn't fit in
* The keys might expand with the new format - if they wouldn't fit in
* the btree node anymore, use the old format for now:
* the btree node anymore, use the old format for now:
*/
*/
if
(
!
bch2_btree_node_format_fits
(
as
->
c
,
b
,
&
format
))
if
(
!
bch2_btree_node_format_fits
(
as
->
c
,
b
,
b
->
nr
,
&
format
))
format
=
b
->
format
;
format
=
b
->
format
;
SET_BTREE_NODE_SEQ
(
n
->
data
,
BTREE_NODE_SEQ
(
b
->
data
)
+
1
);
SET_BTREE_NODE_SEQ
(
n
->
data
,
BTREE_NODE_SEQ
(
b
->
data
)
+
1
);
...
@@ -1822,8 +1823,8 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
...
@@ -1822,8 +1823,8 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
bch2_bkey_format_add_pos
(
&
new_s
,
next
->
data
->
max_key
);
bch2_bkey_format_add_pos
(
&
new_s
,
next
->
data
->
max_key
);
new_f
=
bch2_bkey_format_done
(
&
new_s
);
new_f
=
bch2_bkey_format_done
(
&
new_s
);
sib_u64s
=
btree_node_u64s_with_format
(
b
,
&
new_f
)
+
sib_u64s
=
btree_node_u64s_with_format
(
b
->
nr
,
&
b
->
format
,
&
new_f
)
+
btree_node_u64s_with_format
(
m
,
&
new_f
);
btree_node_u64s_with_format
(
m
->
nr
,
&
m
->
format
,
&
new_f
);
if
(
sib_u64s
>
BTREE_FOREGROUND_MERGE_HYSTERESIS
(
c
))
{
if
(
sib_u64s
>
BTREE_FOREGROUND_MERGE_HYSTERESIS
(
c
))
{
sib_u64s
-=
BTREE_FOREGROUND_MERGE_HYSTERESIS
(
c
);
sib_u64s
-=
BTREE_FOREGROUND_MERGE_HYSTERESIS
(
c
);
...
...
fs/bcachefs/btree_update_interior.h
View file @
0fa3b977
...
@@ -6,10 +6,6 @@
...
@@ -6,10 +6,6 @@
#include "btree_locking.h"
#include "btree_locking.h"
#include "btree_update.h"
#include "btree_update.h"
void
__bch2_btree_calc_format
(
struct
bkey_format_state
*
,
struct
btree
*
);
bool
bch2_btree_node_format_fits
(
struct
bch_fs
*
c
,
struct
btree
*
,
struct
bkey_format
*
);
#define BTREE_UPDATE_NODES_MAX ((BTREE_MAX_DEPTH - 2) * 2 + GC_MERGE_NODES)
#define BTREE_UPDATE_NODES_MAX ((BTREE_MAX_DEPTH - 2) * 2 + GC_MERGE_NODES)
#define BTREE_UPDATE_JOURNAL_RES (BTREE_UPDATE_NODES_MAX * (BKEY_BTREE_PTR_U64s_MAX + 1))
#define BTREE_UPDATE_JOURNAL_RES (BTREE_UPDATE_NODES_MAX * (BKEY_BTREE_PTR_U64s_MAX + 1))
...
...
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