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
2384db8f
Commit
2384db8f
authored
Mar 03, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Separate discards from rest of journal reclaim
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
0ce2dbbe
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
fs/bcachefs/journal.c
fs/bcachefs/journal.c
+12
-1
fs/bcachefs/journal_reclaim.c
fs/bcachefs/journal_reclaim.c
+7
-1
fs/bcachefs/journal_reclaim.h
fs/bcachefs/journal_reclaim.h
+1
-0
fs/bcachefs/journal_types.h
fs/bcachefs/journal_types.h
+2
-0
No files found.
fs/bcachefs/journal.c
View file @
2384db8f
...
@@ -322,6 +322,7 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
...
@@ -322,6 +322,7 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
{
{
struct
bch_fs
*
c
=
container_of
(
j
,
struct
bch_fs
,
journal
);
struct
bch_fs
*
c
=
container_of
(
j
,
struct
bch_fs
,
journal
);
struct
journal_buf
*
buf
;
struct
journal_buf
*
buf
;
bool
can_discard
;
int
ret
;
int
ret
;
retry:
retry:
if
(
journal_res_get_fast
(
j
,
res
,
flags
))
if
(
journal_res_get_fast
(
j
,
res
,
flags
))
...
@@ -370,18 +371,28 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
...
@@ -370,18 +371,28 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
!
j
->
res_get_blocked_start
)
!
j
->
res_get_blocked_start
)
j
->
res_get_blocked_start
=
local_clock
()
?:
1
;
j
->
res_get_blocked_start
=
local_clock
()
?:
1
;
can_discard
=
j
->
can_discard
;
spin_unlock
(
&
j
->
lock
);
spin_unlock
(
&
j
->
lock
);
if
(
!
ret
)
if
(
!
ret
)
goto
retry
;
goto
retry
;
if
(
ret
==
-
ENOSPC
)
{
if
(
ret
==
-
ENOSPC
)
{
/*
/*
* Journal is full - can't rely on reclaim from work item due to
* Journal is full - can't rely on reclaim from work item due to
* freezing:
* freezing:
*/
*/
trace_journal_full
(
c
);
trace_journal_full
(
c
);
if
(
!
(
flags
&
JOURNAL_RES_GET_NONBLOCK
))
if
(
!
(
flags
&
JOURNAL_RES_GET_NONBLOCK
))
{
if
(
can_discard
)
{
bch2_journal_do_discards
(
j
);
goto
retry
;
}
bch2_journal_reclaim_work
(
&
j
->
reclaim_work
.
work
);
bch2_journal_reclaim_work
(
&
j
->
reclaim_work
.
work
);
}
ret
=
-
EAGAIN
;
ret
=
-
EAGAIN
;
}
}
...
...
fs/bcachefs/journal_reclaim.c
View file @
2384db8f
...
@@ -45,6 +45,7 @@ void bch2_journal_space_available(struct journal *j)
...
@@ -45,6 +45,7 @@ void bch2_journal_space_available(struct journal *j)
unsigned
unwritten_sectors
=
j
->
reservations
.
prev_buf_unwritten
unsigned
unwritten_sectors
=
j
->
reservations
.
prev_buf_unwritten
?
journal_prev_buf
(
j
)
->
sectors
?
journal_prev_buf
(
j
)
->
sectors
:
0
;
:
0
;
bool
can_discard
=
false
;
int
ret
=
0
;
int
ret
=
0
;
lockdep_assert_held
(
&
j
->
lock
);
lockdep_assert_held
(
&
j
->
lock
);
...
@@ -65,9 +66,14 @@ void bch2_journal_space_available(struct journal *j)
...
@@ -65,9 +66,14 @@ void bch2_journal_space_available(struct journal *j)
ja
->
bucket_seq
[
ja
->
dirty_idx_ondisk
]
<
j
->
last_seq_ondisk
)
ja
->
bucket_seq
[
ja
->
dirty_idx_ondisk
]
<
j
->
last_seq_ondisk
)
ja
->
dirty_idx_ondisk
=
(
ja
->
dirty_idx_ondisk
+
1
)
%
ja
->
nr
;
ja
->
dirty_idx_ondisk
=
(
ja
->
dirty_idx_ondisk
+
1
)
%
ja
->
nr
;
if
(
ja
->
discard_idx
!=
ja
->
dirty_idx_ondisk
)
can_discard
=
true
;
nr_online
++
;
nr_online
++
;
}
}
j
->
can_discard
=
can_discard
;
if
(
nr_online
<
c
->
opts
.
metadata_replicas_required
)
{
if
(
nr_online
<
c
->
opts
.
metadata_replicas_required
)
{
ret
=
-
EROFS
;
ret
=
-
EROFS
;
sectors_next_entry
=
0
;
sectors_next_entry
=
0
;
...
@@ -156,7 +162,7 @@ static bool should_discard_bucket(struct journal *j, struct journal_device *ja)
...
@@ -156,7 +162,7 @@ static bool should_discard_bucket(struct journal *j, struct journal_device *ja)
* Advance ja->discard_idx as long as it points to buckets that are no longer
* Advance ja->discard_idx as long as it points to buckets that are no longer
* dirty, issuing discards if necessary:
* dirty, issuing discards if necessary:
*/
*/
static
void
bch2_journal_do_discards
(
struct
journal
*
j
)
void
bch2_journal_do_discards
(
struct
journal
*
j
)
{
{
struct
bch_fs
*
c
=
container_of
(
j
,
struct
bch_fs
,
journal
);
struct
bch_fs
*
c
=
container_of
(
j
,
struct
bch_fs
,
journal
);
struct
bch_dev
*
ca
;
struct
bch_dev
*
ca
;
...
...
fs/bcachefs/journal_reclaim.h
View file @
2384db8f
...
@@ -34,6 +34,7 @@ void bch2_journal_pin_add_if_older(struct journal *,
...
@@ -34,6 +34,7 @@ void bch2_journal_pin_add_if_older(struct journal *,
journal_pin_flush_fn
);
journal_pin_flush_fn
);
void
bch2_journal_pin_flush
(
struct
journal
*
,
struct
journal_entry_pin
*
);
void
bch2_journal_pin_flush
(
struct
journal
*
,
struct
journal_entry_pin
*
);
void
bch2_journal_do_discards
(
struct
journal
*
);
void
bch2_journal_reclaim_work
(
struct
work_struct
*
);
void
bch2_journal_reclaim_work
(
struct
work_struct
*
);
void
bch2_journal_flush_pins
(
struct
journal
*
,
u64
);
void
bch2_journal_flush_pins
(
struct
journal
*
,
u64
);
...
...
fs/bcachefs/journal_types.h
View file @
2384db8f
...
@@ -210,6 +210,8 @@ struct journal {
...
@@ -210,6 +210,8 @@ struct journal {
/* protects advancing ja->discard_idx: */
/* protects advancing ja->discard_idx: */
struct
mutex
discard_lock
;
struct
mutex
discard_lock
;
bool
can_discard
;
unsigned
write_delay_ms
;
unsigned
write_delay_ms
;
unsigned
reclaim_delay_ms
;
unsigned
reclaim_delay_ms
;
...
...
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