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
641ab736
Commit
641ab736
authored
Dec 06, 2018
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: improve/clarify ptr_disk_sectors()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
57cb2142
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
32 deletions
+37
-32
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+19
-28
fs/bcachefs/buckets.h
fs/bcachefs/buckets.h
+14
-0
fs/bcachefs/extents_types.h
fs/bcachefs/extents_types.h
+4
-4
No files found.
fs/bcachefs/buckets.c
View file @
641ab736
...
@@ -558,36 +558,25 @@ void bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca,
...
@@ -558,36 +558,25 @@ void bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca,
preempt_enable
();
preempt_enable
();
}
}
static
int
__disk_sectors
(
struct
bch_extent_crc_unpacked
crc
,
unsigned
sectors
)
static
s64
ptr_disk_sectors_delta
(
struct
extent_ptr_decoded
p
,
s64
delta
)
{
{
if
(
!
sectors
)
if
(
delta
>
0
)
{
return
0
;
/*
* marking a new extent, which _will have size_ @delta
return
max
(
1U
,
DIV_ROUND_UP
(
sectors
*
crc
.
compressed_size
,
*
crc
.
uncompressed_size
));
* in the bch2_mark_update -> BCH_EXTENT_OVERLAP_MIDDLE
}
* case, we haven't actually created the key we'll be inserting
* yet (for the split) - so we don't want to be using
static
s64
ptr_disk_sectors
(
const
struct
bkey
*
k
,
* k->size/crc.live_size here:
struct
extent_ptr_decoded
p
,
*/
s64
sectors
)
return
__ptr_disk_sectors
(
p
,
delta
);
{
}
else
{
BUG_ON
(
-
delta
>
p
.
crc
.
live_size
);
if
(
p
.
crc
.
compression_type
)
{
unsigned
old_sectors
,
new_sectors
;
if
(
sectors
>
0
)
{
old_sectors
=
0
;
new_sectors
=
sectors
;
}
else
{
old_sectors
=
k
->
size
;
new_sectors
=
k
->
size
+
sectors
;
}
sectors
=
-
__disk_sectors
(
p
.
crc
,
old_sectors
)
return
(
s64
)
__ptr_disk_sectors
(
p
,
p
.
crc
.
live_size
+
delta
)
-
+
__disk_sectors
(
p
.
crc
,
new_sectors
);
(
s64
)
ptr_disk_sectors
(
p
);
}
}
return
sectors
;
}
}
/*
/*
...
@@ -722,7 +711,9 @@ static int bch2_mark_extent(struct bch_fs *c, struct bkey_s_c k,
...
@@ -722,7 +711,9 @@ static int bch2_mark_extent(struct bch_fs *c, struct bkey_s_c k,
BUG_ON
(
!
sectors
);
BUG_ON
(
!
sectors
);
bkey_for_each_ptr_decode
(
k
.
k
,
ptrs
,
p
,
entry
)
{
bkey_for_each_ptr_decode
(
k
.
k
,
ptrs
,
p
,
entry
)
{
s64
disk_sectors
=
ptr_disk_sectors
(
k
.
k
,
p
,
sectors
);
s64
disk_sectors
=
data_type
==
BCH_DATA_BTREE
?
sectors
:
ptr_disk_sectors_delta
(
p
,
sectors
);
s64
adjusted_disk_sectors
=
disk_sectors
;
s64
adjusted_disk_sectors
=
disk_sectors
;
bch2_mark_pointer
(
c
,
p
,
disk_sectors
,
data_type
,
bch2_mark_pointer
(
c
,
p
,
disk_sectors
,
data_type
,
...
...
fs/bcachefs/buckets.h
View file @
641ab736
...
@@ -136,6 +136,20 @@ static inline u8 ptr_stale(struct bch_dev *ca,
...
@@ -136,6 +136,20 @@ static inline u8 ptr_stale(struct bch_dev *ca,
return
gen_after
(
ptr_bucket_mark
(
ca
,
ptr
).
gen
,
ptr
->
gen
);
return
gen_after
(
ptr_bucket_mark
(
ca
,
ptr
).
gen
,
ptr
->
gen
);
}
}
static
inline
unsigned
__ptr_disk_sectors
(
struct
extent_ptr_decoded
p
,
unsigned
live_size
)
{
return
live_size
&&
p
.
crc
.
compression_type
?
max
(
1U
,
DIV_ROUND_UP
(
live_size
*
p
.
crc
.
compressed_size
,
p
.
crc
.
uncompressed_size
))
:
live_size
;
}
static
inline
unsigned
ptr_disk_sectors
(
struct
extent_ptr_decoded
p
)
{
return
__ptr_disk_sectors
(
p
,
p
.
crc
.
live_size
);
}
/* bucket gc marks */
/* bucket gc marks */
static
inline
unsigned
bucket_sectors_used
(
struct
bucket_mark
mark
)
static
inline
unsigned
bucket_sectors_used
(
struct
bucket_mark
mark
)
...
...
fs/bcachefs/extents_types.h
View file @
641ab736
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
#include "bcachefs_format.h"
#include "bcachefs_format.h"
struct
bch_extent_crc_unpacked
{
struct
bch_extent_crc_unpacked
{
u32
compressed_size
;
u32
uncompressed_size
;
u32
live_size
;
u8
csum_type
;
u8
csum_type
;
u8
compression_type
;
u8
compression_type
;
u16
compressed_size
;
u16
uncompressed_size
;
u16
offset
;
u16
offset
;
u16
live_size
;
u16
nonce
;
u16
nonce
;
...
...
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