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
a9bec520
Commit
a9bec520
authored
Aug 01, 2018
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Better calculation of copygc threshold
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
6eac2c2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
23 deletions
+32
-23
fs/bcachefs/alloc.c
fs/bcachefs/alloc.c
+26
-16
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs.h
+1
-0
fs/bcachefs/movinggc.c
fs/bcachefs/movinggc.c
+1
-7
fs/bcachefs/sysfs.c
fs/bcachefs/sysfs.c
+4
-0
No files found.
fs/bcachefs/alloc.c
View file @
a9bec520
...
...
@@ -1711,7 +1711,7 @@ void bch2_alloc_sectors_done(struct bch_fs *c, struct write_point *wp)
void
bch2_recalc_capacity
(
struct
bch_fs
*
c
)
{
struct
bch_dev
*
ca
;
u64
total_capacity
,
capacity
=
0
,
reserved_sectors
=
0
;
u64
capacity
=
0
,
reserved_sectors
=
0
;
unsigned
long
ra_pages
=
0
;
unsigned
i
,
j
;
...
...
@@ -1726,7 +1726,7 @@ void bch2_recalc_capacity(struct bch_fs *c)
bch2_set_ra_pages
(
c
,
ra_pages
);
for_each_rw_member
(
ca
,
c
,
i
)
{
size_t
reserve
=
0
;
u64
dev_capacity
,
dev_
reserve
=
0
;
/*
* We need to reserve buckets (from the number
...
...
@@ -1745,30 +1745,40 @@ void bch2_recalc_capacity(struct bch_fs *c)
* not -ENOSPC calculations.
*/
for
(
j
=
0
;
j
<
RESERVE_NONE
;
j
++
)
reserve
+=
ca
->
free
[
j
].
size
;
dev_
reserve
+=
ca
->
free
[
j
].
size
;
reserve
+=
ca
->
free_inc
.
size
;
dev_
reserve
+=
ca
->
free_inc
.
size
;
reserve
+=
ARRAY_SIZE
(
c
->
write_points
);
dev_
reserve
+=
ARRAY_SIZE
(
c
->
write_points
);
reserve
+=
1
;
/* btree write point */
dev_reserve
+=
1
;
/* btree write point */
dev_reserve
+=
1
;
/* copygc write point */
dev_reserve
+=
1
;
/* rebalance write point */
dev_reserve
+=
WRITE_POINT_COUNT
;
reserved_sectors
+=
bucket_to_sector
(
ca
,
reserve
)
;
dev_reserve
*=
ca
->
mi
.
bucket_size
;
capacity
+=
bucket_to_sector
(
ca
,
ca
->
mi
.
nbuckets
-
ca
->
mi
.
first_bucket
);
}
dev_reserve
*=
2
;
dev_capacity
=
bucket_to_sector
(
ca
,
ca
->
mi
.
nbuckets
-
ca
->
mi
.
first_bucket
);
total_capacity
=
capacity
;
ca
->
copygc_threshold
=
max
(
div64_u64
(
dev_capacity
*
c
->
opts
.
gc_reserve_percent
,
100
),
dev_reserve
)
/
2
;
capacity
*=
(
100
-
c
->
opts
.
gc_reserve_percent
);
capacity
=
div64_u64
(
capacity
,
100
);
capacity
+=
dev_capacity
;
reserved_sectors
+=
dev_reserve
;
}
BUG_ON
(
reserved_sectors
>
total_capacity
);
reserved_sectors
=
max
(
div64_u64
(
capacity
*
c
->
opts
.
gc_reserve_percent
,
100
),
reserved_sectors
);
capacity
=
min
(
capacity
,
total_capacity
-
reserved_sectors
);
BUG_ON
(
reserved_sectors
>
capacity
);
c
->
capacity
=
capacity
;
c
->
capacity
=
capacity
-
reserved_sectors
;
if
(
c
->
capacity
)
{
bch2_io_timer_add
(
&
c
->
io_clock
[
READ
],
...
...
fs/bcachefs/bcachefs.h
View file @
a9bec520
...
...
@@ -427,6 +427,7 @@ struct bch_dev {
copygc_heap
copygc_heap
;
struct
bch_pd_controller
copygc_pd
;
struct
write_point
copygc_write_point
;
u64
copygc_threshold
;
atomic64_t
rebalance_work
;
...
...
fs/bcachefs/movinggc.c
View file @
a9bec520
...
...
@@ -228,16 +228,10 @@ static int bch2_copygc_thread(void *arg)
last
=
atomic_long_read
(
&
clock
->
now
);
reserve
=
div64_u64
((
ca
->
mi
.
nbuckets
-
ca
->
mi
.
first_bucket
)
*
ca
->
mi
.
bucket_size
*
c
->
opts
.
gc_reserve_percent
,
200
);
reserve
=
ca
->
copygc_threshold
;
usage
=
bch2_dev_usage_read
(
c
,
ca
);
/*
* don't start copygc until less than half the gc reserve is
* available:
*/
available
=
__dev_buckets_available
(
ca
,
usage
)
*
ca
->
mi
.
bucket_size
;
if
(
available
>
reserve
)
{
...
...
fs/bcachefs/sysfs.c
View file @
a9bec520
...
...
@@ -788,6 +788,8 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
" meta: %llu
\n
"
" user: %llu
\n
"
" cached: %llu
\n
"
" fragmented: %llu
\n
"
" copygc threshold: %llu
\n
"
"freelist_wait: %s
\n
"
"open buckets: %u/%u (reserved %u)
\n
"
"open_buckets_wait: %s
\n
"
,
...
...
@@ -808,6 +810,8 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
stats
.
sectors
[
BCH_DATA_BTREE
],
stats
.
sectors
[
BCH_DATA_USER
],
stats
.
sectors
[
BCH_DATA_CACHED
],
stats
.
sectors_fragmented
,
ca
->
copygc_threshold
,
c
->
freelist_wait
.
list
.
first
?
"waiting"
:
"empty"
,
c
->
open_buckets_nr_free
,
OPEN_BUCKETS_COUNT
,
BTREE_NODE_RESERVE
,
c
->
open_buckets_wait
.
list
.
first
?
"waiting"
:
"empty"
);
...
...
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