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
b030f691
Commit
b030f691
authored
Jan 19, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Fix some reserve calculations
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
0519b72d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
7 deletions
+26
-7
fs/bcachefs/alloc_foreground.c
fs/bcachefs/alloc_foreground.c
+4
-2
fs/bcachefs/alloc_foreground.h
fs/bcachefs/alloc_foreground.h
+1
-0
fs/bcachefs/alloc_types.h
fs/bcachefs/alloc_types.h
+3
-2
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs.h
+2
-0
fs/bcachefs/sysfs.c
fs/bcachefs/sysfs.c
+16
-3
No files found.
fs/bcachefs/alloc_foreground.c
View file @
b030f691
...
@@ -107,6 +107,7 @@ void __bch2_open_bucket_put(struct bch_fs *c, struct open_bucket *ob)
...
@@ -107,6 +107,7 @@ void __bch2_open_bucket_put(struct bch_fs *c, struct open_bucket *ob)
bch2_mark_alloc_bucket
(
c
,
ca
,
PTR_BUCKET_NR
(
ca
,
&
ob
->
ptr
),
bch2_mark_alloc_bucket
(
c
,
ca
,
PTR_BUCKET_NR
(
ca
,
&
ob
->
ptr
),
false
,
gc_pos_alloc
(
c
,
ob
),
0
);
false
,
gc_pos_alloc
(
c
,
ob
),
0
);
ob
->
valid
=
false
;
ob
->
valid
=
false
;
ob
->
type
=
0
;
spin_unlock
(
&
ob
->
lock
);
spin_unlock
(
&
ob
->
lock
);
percpu_up_read
(
&
c
->
mark_lock
);
percpu_up_read
(
&
c
->
mark_lock
);
...
@@ -142,6 +143,7 @@ static struct open_bucket *bch2_open_bucket_alloc(struct bch_fs *c)
...
@@ -142,6 +143,7 @@ static struct open_bucket *bch2_open_bucket_alloc(struct bch_fs *c)
ob
=
c
->
open_buckets
+
c
->
open_buckets_freelist
;
ob
=
c
->
open_buckets
+
c
->
open_buckets_freelist
;
c
->
open_buckets_freelist
=
ob
->
freelist
;
c
->
open_buckets_freelist
=
ob
->
freelist
;
atomic_set
(
&
ob
->
pin
,
1
);
atomic_set
(
&
ob
->
pin
,
1
);
ob
->
type
=
0
;
c
->
open_buckets_nr_free
--
;
c
->
open_buckets_nr_free
--
;
return
ob
;
return
ob
;
...
@@ -210,9 +212,9 @@ static inline unsigned open_buckets_reserved(enum alloc_reserve reserve)
...
@@ -210,9 +212,9 @@ static inline unsigned open_buckets_reserved(enum alloc_reserve reserve)
case
RESERVE_ALLOC
:
case
RESERVE_ALLOC
:
return
0
;
return
0
;
case
RESERVE_BTREE
:
case
RESERVE_BTREE
:
return
BTREE_NODE_
RESERVE
/
2
;
return
BTREE_NODE_
OPEN_BUCKET_RESERVE
;
default:
default:
return
BTREE_NODE_
RESERVE
;
return
BTREE_NODE_
OPEN_BUCKET_RESERVE
*
2
;
}
}
}
}
...
...
fs/bcachefs/alloc_foreground.h
View file @
b030f691
...
@@ -86,6 +86,7 @@ static inline void bch2_open_bucket_get(struct bch_fs *c,
...
@@ -86,6 +86,7 @@ static inline void bch2_open_bucket_get(struct bch_fs *c,
unsigned
i
;
unsigned
i
;
open_bucket_for_each
(
c
,
&
wp
->
ptrs
,
ob
,
i
)
{
open_bucket_for_each
(
c
,
&
wp
->
ptrs
,
ob
,
i
)
{
ob
->
type
=
wp
->
type
;
atomic_inc
(
&
ob
->
pin
);
atomic_inc
(
&
ob
->
pin
);
ob_push
(
c
,
ptrs
,
ob
);
ob_push
(
c
,
ptrs
,
ob
);
}
}
...
...
fs/bcachefs/alloc_types.h
View file @
b030f691
...
@@ -56,9 +56,10 @@ struct open_bucket {
...
@@ -56,9 +56,10 @@ struct open_bucket {
spinlock_t
lock
;
spinlock_t
lock
;
atomic_t
pin
;
atomic_t
pin
;
u8
freelist
;
u8
freelist
;
bool
valid
;
bool
on_partial_list
;
u8
ec_idx
;
u8
ec_idx
;
u8
type
;
unsigned
valid
:
1
;
unsigned
on_partial_list
:
1
;
unsigned
sectors_free
;
unsigned
sectors_free
;
struct
bch_extent_ptr
ptr
;
struct
bch_extent_ptr
ptr
;
struct
ec_stripe_new
*
ec
;
struct
ec_stripe_new
*
ec
;
...
...
fs/bcachefs/bcachefs.h
View file @
b030f691
...
@@ -333,6 +333,8 @@ enum bch_time_stats {
...
@@ -333,6 +333,8 @@ enum bch_time_stats {
/* Size of the freelist we allocate btree nodes from: */
/* Size of the freelist we allocate btree nodes from: */
#define BTREE_NODE_RESERVE BTREE_RESERVE_MAX
#define BTREE_NODE_RESERVE BTREE_RESERVE_MAX
#define BTREE_NODE_OPEN_BUCKET_RESERVE (BTREE_RESERVE_MAX * BCH_REPLICAS_MAX)
struct
btree
;
struct
btree
;
enum
gc_phase
{
enum
gc_phase
{
...
...
fs/bcachefs/sysfs.c
View file @
b030f691
...
@@ -797,6 +797,12 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
...
@@ -797,6 +797,12 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
{
{
struct
bch_fs
*
c
=
ca
->
fs
;
struct
bch_fs
*
c
=
ca
->
fs
;
struct
bch_dev_usage
stats
=
bch2_dev_usage_read
(
c
,
ca
);
struct
bch_dev_usage
stats
=
bch2_dev_usage_read
(
c
,
ca
);
unsigned
i
,
nr
[
BCH_DATA_NR
];
memset
(
nr
,
0
,
sizeof
(
nr
));
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
c
->
open_buckets
);
i
++
)
nr
[
c
->
open_buckets
[
i
].
type
]
++
;
return
scnprintf
(
buf
,
PAGE_SIZE
,
return
scnprintf
(
buf
,
PAGE_SIZE
,
"free_inc: %zu/%zu
\n
"
"free_inc: %zu/%zu
\n
"
...
@@ -823,7 +829,10 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
...
@@ -823,7 +829,10 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
" copygc threshold: %llu
\n
"
" copygc threshold: %llu
\n
"
"freelist_wait: %s
\n
"
"freelist_wait: %s
\n
"
"open buckets: %u/%u (reserved %u)
\n
"
"open buckets: %u/%u (reserved %u)
\n
"
"open_buckets_wait: %s
\n
"
,
"open_buckets_wait: %s
\n
"
"open_buckets_btree: %u
\n
"
"open_buckets_user: %u
\n
"
"btree reserve cache: %u
\n
"
,
fifo_used
(
&
ca
->
free_inc
),
ca
->
free_inc
.
size
,
fifo_used
(
&
ca
->
free_inc
),
ca
->
free_inc
.
size
,
fifo_used
(
&
ca
->
free
[
RESERVE_BTREE
]),
ca
->
free
[
RESERVE_BTREE
].
size
,
fifo_used
(
&
ca
->
free
[
RESERVE_BTREE
]),
ca
->
free
[
RESERVE_BTREE
].
size
,
fifo_used
(
&
ca
->
free
[
RESERVE_MOVINGGC
]),
ca
->
free
[
RESERVE_MOVINGGC
].
size
,
fifo_used
(
&
ca
->
free
[
RESERVE_MOVINGGC
]),
ca
->
free
[
RESERVE_MOVINGGC
].
size
,
...
@@ -845,8 +854,12 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
...
@@ -845,8 +854,12 @@ static ssize_t show_dev_alloc_debug(struct bch_dev *ca, char *buf)
stats
.
sectors_fragmented
,
stats
.
sectors_fragmented
,
ca
->
copygc_threshold
,
ca
->
copygc_threshold
,
c
->
freelist_wait
.
list
.
first
?
"waiting"
:
"empty"
,
c
->
freelist_wait
.
list
.
first
?
"waiting"
:
"empty"
,
c
->
open_buckets_nr_free
,
OPEN_BUCKETS_COUNT
,
BTREE_NODE_RESERVE
,
c
->
open_buckets_nr_free
,
OPEN_BUCKETS_COUNT
,
c
->
open_buckets_wait
.
list
.
first
?
"waiting"
:
"empty"
);
BTREE_NODE_OPEN_BUCKET_RESERVE
,
c
->
open_buckets_wait
.
list
.
first
?
"waiting"
:
"empty"
,
nr
[
BCH_DATA_BTREE
],
nr
[
BCH_DATA_USER
],
c
->
btree_reserve_cache_nr
);
}
}
static
const
char
*
const
bch2_rw
[]
=
{
static
const
char
*
const
bch2_rw
[]
=
{
...
...
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