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
436c656d
Commit
436c656d
authored
Jun 09, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: bkey_merge() now takes bkey_s
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
1ae97334
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
38 deletions
+42
-38
fs/bcachefs/bkey_methods.c
fs/bcachefs/bkey_methods.c
+6
-6
fs/bcachefs/bkey_methods.h
fs/bcachefs/bkey_methods.h
+2
-2
fs/bcachefs/bkey_sort.c
fs/bcachefs/bkey_sort.c
+4
-2
fs/bcachefs/extents.c
fs/bcachefs/extents.c
+28
-26
fs/bcachefs/extents.h
fs/bcachefs/extents.h
+2
-2
No files found.
fs/bcachefs/bkey_methods.c
View file @
436c656d
...
...
@@ -199,22 +199,22 @@ bool bch2_bkey_normalize(struct bch_fs *c, struct bkey_s k)
}
enum
merge_result
bch2_bkey_merge
(
struct
bch_fs
*
c
,
struct
bkey_
i
*
l
,
struct
bkey_i
*
r
)
struct
bkey_
s
l
,
struct
bkey_s
r
)
{
const
struct
bkey_ops
*
ops
=
&
bch2_bkey_ops
[
l
->
k
.
type
];
const
struct
bkey_ops
*
ops
=
&
bch2_bkey_ops
[
l
.
k
->
type
];
enum
merge_result
ret
;
if
(
key_merging_disabled
(
c
)
||
!
ops
->
key_merge
||
l
->
k
.
type
!=
r
->
k
.
type
||
bversion_cmp
(
l
->
k
.
version
,
r
->
k
.
version
)
||
bkey_cmp
(
l
->
k
.
p
,
bkey_start_pos
(
&
r
->
k
)))
l
.
k
->
type
!=
r
.
k
->
type
||
bversion_cmp
(
l
.
k
->
version
,
r
.
k
->
version
)
||
bkey_cmp
(
l
.
k
->
p
,
bkey_start_pos
(
r
.
k
)))
return
BCH_MERGE_NOMERGE
;
ret
=
ops
->
key_merge
(
c
,
l
,
r
);
if
(
ret
!=
BCH_MERGE_NOMERGE
)
l
->
k
.
needs_whiteout
|=
r
->
k
.
needs_whiteout
;
l
.
k
->
needs_whiteout
|=
r
.
k
->
needs_whiteout
;
return
ret
;
}
...
...
fs/bcachefs/bkey_methods.h
View file @
436c656d
...
...
@@ -33,7 +33,7 @@ struct bkey_ops {
void
(
*
swab
)(
const
struct
bkey_format
*
,
struct
bkey_packed
*
);
bool
(
*
key_normalize
)(
struct
bch_fs
*
,
struct
bkey_s
);
enum
merge_result
(
*
key_merge
)(
struct
bch_fs
*
,
struct
bkey_
i
*
,
struct
bkey_i
*
);
struct
bkey_
s
,
struct
bkey_s
);
};
const
char
*
bch2_bkey_val_invalid
(
struct
bch_fs
*
,
struct
bkey_s_c
);
...
...
@@ -57,7 +57,7 @@ void bch2_bkey_swab(const struct bkey_format *, struct bkey_packed *);
bool
bch2_bkey_normalize
(
struct
bch_fs
*
,
struct
bkey_s
);
enum
merge_result
bch2_bkey_merge
(
struct
bch_fs
*
,
struct
bkey_
i
*
,
struct
bkey_i
*
);
struct
bkey_
s
,
struct
bkey_s
);
void
bch2_bkey_renumber
(
enum
btree_node_type
,
struct
bkey_packed
*
,
int
);
...
...
fs/bcachefs/bkey_sort.c
View file @
436c656d
...
...
@@ -257,7 +257,7 @@ static void extent_sort_append(struct bch_fs *c,
bch2_bkey_unpack
(
b
,
&
tmp
.
k
,
k
);
if
(
*
prev
&&
bch2_bkey_merge
(
c
,
(
void
*
)
*
prev
,
&
tmp
.
k
))
bch2_bkey_merge
(
c
,
bkey_i_to_s
((
void
*
)
*
prev
),
bkey_i_to_s
(
&
tmp
.
k
)
))
return
;
if
(
*
prev
)
{
...
...
@@ -436,7 +436,9 @@ bch2_sort_repack_merge(struct bch_fs *c,
/* prev is always unpacked, for key merging: */
if
(
prev
&&
bch2_bkey_merge
(
c
,
(
void
*
)
prev
,
&
tmp
.
k
)
==
bch2_bkey_merge
(
c
,
bkey_i_to_s
((
void
*
)
prev
),
bkey_i_to_s
(
&
tmp
.
k
))
==
BCH_MERGE_MERGE
)
continue
;
...
...
fs/bcachefs/extents.c
View file @
436c656d
...
...
@@ -1521,21 +1521,21 @@ void bch2_extent_mark_replicas_cached(struct bch_fs *c,
}
enum
merge_result
bch2_extent_merge
(
struct
bch_fs
*
c
,
struct
bkey_
i
*
l
,
struct
bkey_i
*
r
)
struct
bkey_
s
_l
,
struct
bkey_s
_
r
)
{
struct
bkey_s_extent
el
=
bkey_i_to_s_extent
(
l
);
struct
bkey_s_extent
er
=
bkey_i_to_s_extent
(
r
);
union
bch_extent_entry
*
en_l
=
e
l
.
v
->
start
;
union
bch_extent_entry
*
en_r
=
e
r
.
v
->
start
;
struct
bkey_s_extent
l
=
bkey_s_to_extent
(
_
l
);
struct
bkey_s_extent
r
=
bkey_s_to_extent
(
_
r
);
union
bch_extent_entry
*
en_l
=
l
.
v
->
start
;
union
bch_extent_entry
*
en_r
=
r
.
v
->
start
;
struct
bch_extent_crc_unpacked
crc_l
,
crc_r
;
if
(
bkey_val_u64s
(
&
l
->
k
)
!=
bkey_val_u64s
(
&
r
->
k
))
if
(
bkey_val_u64s
(
l
.
k
)
!=
bkey_val_u64s
(
r
.
k
))
return
BCH_MERGE_NOMERGE
;
crc_l
=
bch2_extent_crc_unpack
(
e
l
.
k
,
NULL
);
crc_l
=
bch2_extent_crc_unpack
(
l
.
k
,
NULL
);
extent_for_each_entry
(
e
l
,
en_l
)
{
en_r
=
vstruct_idx
(
er
.
v
,
(
u64
*
)
en_l
-
e
l
.
v
->
_data
);
extent_for_each_entry
(
l
,
en_l
)
{
en_r
=
vstruct_idx
(
r
.
v
,
(
u64
*
)
en_l
-
l
.
v
->
_data
);
if
(
extent_entry_type
(
en_l
)
!=
extent_entry_type
(
en_r
))
return
BCH_MERGE_NOMERGE
;
...
...
@@ -1567,8 +1567,8 @@ enum merge_result bch2_extent_merge(struct bch_fs *c,
case
BCH_EXTENT_ENTRY_crc32
:
case
BCH_EXTENT_ENTRY_crc64
:
case
BCH_EXTENT_ENTRY_crc128
:
crc_l
=
bch2_extent_crc_unpack
(
e
l
.
k
,
entry_to_crc
(
en_l
));
crc_r
=
bch2_extent_crc_unpack
(
e
r
.
k
,
entry_to_crc
(
en_r
));
crc_l
=
bch2_extent_crc_unpack
(
l
.
k
,
entry_to_crc
(
en_l
));
crc_r
=
bch2_extent_crc_unpack
(
r
.
k
,
entry_to_crc
(
en_r
));
if
(
crc_l
.
csum_type
!=
crc_r
.
csum_type
||
crc_l
.
compression_type
!=
crc_r
.
compression_type
||
...
...
@@ -1600,16 +1600,16 @@ enum merge_result bch2_extent_merge(struct bch_fs *c,
}
}
extent_for_each_entry
(
e
l
,
en_l
)
{
extent_for_each_entry
(
l
,
en_l
)
{
struct
bch_extent_crc_unpacked
crc_l
,
crc_r
;
en_r
=
vstruct_idx
(
er
.
v
,
(
u64
*
)
en_l
-
e
l
.
v
->
_data
);
en_r
=
vstruct_idx
(
r
.
v
,
(
u64
*
)
en_l
-
l
.
v
->
_data
);
if
(
!
extent_entry_is_crc
(
en_l
))
continue
;
crc_l
=
bch2_extent_crc_unpack
(
e
l
.
k
,
entry_to_crc
(
en_l
));
crc_r
=
bch2_extent_crc_unpack
(
e
r
.
k
,
entry_to_crc
(
en_r
));
crc_l
=
bch2_extent_crc_unpack
(
l
.
k
,
entry_to_crc
(
en_l
));
crc_r
=
bch2_extent_crc_unpack
(
r
.
k
,
entry_to_crc
(
en_r
));
crc_l
.
csum
=
bch2_checksum_merge
(
crc_l
.
csum_type
,
crc_l
.
csum
,
...
...
@@ -1622,7 +1622,7 @@ enum merge_result bch2_extent_merge(struct bch_fs *c,
bch2_extent_crc_pack
(
entry_to_crc
(
en_l
),
crc_l
);
}
bch2_key_resize
(
&
l
->
k
,
l
->
k
.
size
+
r
->
k
.
size
);
bch2_key_resize
(
l
.
k
,
l
.
k
->
size
+
r
.
k
->
size
);
return
BCH_MERGE_MERGE
;
}
...
...
@@ -1662,7 +1662,9 @@ static bool bch2_extent_merge_inline(struct bch_fs *c,
bch2_bkey_unpack
(
b
,
&
li
.
k
,
l
);
bch2_bkey_unpack
(
b
,
&
ri
.
k
,
r
);
ret
=
bch2_bkey_merge
(
c
,
&
li
.
k
,
&
ri
.
k
);
ret
=
bch2_bkey_merge
(
c
,
bkey_i_to_s
(
&
li
.
k
),
bkey_i_to_s
(
&
ri
.
k
));
if
(
ret
==
BCH_MERGE_NOMERGE
)
return
false
;
...
...
@@ -1785,22 +1787,22 @@ void bch2_reservation_to_text(struct printbuf *out, struct bch_fs *c,
}
enum
merge_result
bch2_reservation_merge
(
struct
bch_fs
*
c
,
struct
bkey_
i
*
l
,
struct
bkey_i
*
r
)
struct
bkey_
s
_l
,
struct
bkey_s
_
r
)
{
struct
bkey_
i_reservation
*
li
=
bkey_i_to_reservation
(
l
);
struct
bkey_
i_reservation
*
ri
=
bkey_i_to_reservation
(
r
);
struct
bkey_
s_reservation
l
=
bkey_s_to_reservation
(
_
l
);
struct
bkey_
s_reservation
r
=
bkey_s_to_reservation
(
_
r
);
if
(
l
i
->
v
.
generation
!=
ri
->
v
.
generation
||
l
i
->
v
.
nr_replicas
!=
ri
->
v
.
nr_replicas
)
if
(
l
.
v
->
generation
!=
r
.
v
->
generation
||
l
.
v
->
nr_replicas
!=
r
.
v
->
nr_replicas
)
return
BCH_MERGE_NOMERGE
;
if
((
u64
)
l
->
k
.
size
+
r
->
k
.
size
>
KEY_SIZE_MAX
)
{
bch2_key_resize
(
&
l
->
k
,
KEY_SIZE_MAX
);
bch2_cut_front
(
l
->
k
.
p
,
r
);
if
((
u64
)
l
.
k
->
size
+
r
.
k
->
size
>
KEY_SIZE_MAX
)
{
bch2_key_resize
(
l
.
k
,
KEY_SIZE_MAX
);
__bch2_cut_front
(
l
.
k
->
p
,
r
.
s
);
return
BCH_MERGE_PARTIAL
;
}
bch2_key_resize
(
&
l
->
k
,
l
->
k
.
size
+
r
->
k
.
size
);
bch2_key_resize
(
l
.
k
,
l
.
k
->
size
+
r
.
k
->
size
);
return
BCH_MERGE_MERGE
;
}
fs/bcachefs/extents.h
View file @
436c656d
...
...
@@ -386,7 +386,7 @@ void bch2_extent_debugcheck(struct bch_fs *, struct btree *, struct bkey_s_c);
void
bch2_extent_to_text
(
struct
printbuf
*
,
struct
bch_fs
*
,
struct
bkey_s_c
);
bool
bch2_extent_normalize
(
struct
bch_fs
*
,
struct
bkey_s
);
enum
merge_result
bch2_extent_merge
(
struct
bch_fs
*
,
struct
bkey_
i
*
,
struct
bkey_i
*
);
struct
bkey_
s
,
struct
bkey_s
);
#define bch2_bkey_ops_extent (struct bkey_ops) { \
.key_invalid = bch2_extent_invalid, \
...
...
@@ -402,7 +402,7 @@ enum merge_result bch2_extent_merge(struct bch_fs *,
const
char
*
bch2_reservation_invalid
(
const
struct
bch_fs
*
,
struct
bkey_s_c
);
void
bch2_reservation_to_text
(
struct
printbuf
*
,
struct
bch_fs
*
,
struct
bkey_s_c
);
enum
merge_result
bch2_reservation_merge
(
struct
bch_fs
*
,
struct
bkey_
i
*
,
struct
bkey_i
*
);
struct
bkey_
s
,
struct
bkey_s
);
#define bch2_bkey_ops_reservation (struct bkey_ops) { \
.key_invalid = bch2_reservation_invalid, \
...
...
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