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
Hide 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,
{
struct
bch_fs
*
c
=
container_of
(
j
,
struct
bch_fs
,
journal
);
struct
journal_buf
*
buf
;
bool
can_discard
;
int
ret
;
retry:
if
(
journal_res_get_fast
(
j
,
res
,
flags
))
...
...
@@ -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
=
local_clock
()
?:
1
;
can_discard
=
j
->
can_discard
;
spin_unlock
(
&
j
->
lock
);
if
(
!
ret
)
goto
retry
;
if
(
ret
==
-
ENOSPC
)
{
/*
* Journal is full - can't rely on reclaim from work item due to
* freezing:
*/
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
);
}
ret
=
-
EAGAIN
;
}
...
...
fs/bcachefs/journal_reclaim.c
View file @
2384db8f
...
...
@@ -45,6 +45,7 @@ void bch2_journal_space_available(struct journal *j)
unsigned
unwritten_sectors
=
j
->
reservations
.
prev_buf_unwritten
?
journal_prev_buf
(
j
)
->
sectors
:
0
;
bool
can_discard
=
false
;
int
ret
=
0
;
lockdep_assert_held
(
&
j
->
lock
);
...
...
@@ -65,9 +66,14 @@ void bch2_journal_space_available(struct journal *j)
ja
->
bucket_seq
[
ja
->
dirty_idx_ondisk
]
<
j
->
last_seq_ondisk
)
ja
->
dirty_idx_ondisk
=
(
ja
->
dirty_idx_ondisk
+
1
)
%
ja
->
nr
;
if
(
ja
->
discard_idx
!=
ja
->
dirty_idx_ondisk
)
can_discard
=
true
;
nr_online
++
;
}
j
->
can_discard
=
can_discard
;
if
(
nr_online
<
c
->
opts
.
metadata_replicas_required
)
{
ret
=
-
EROFS
;
sectors_next_entry
=
0
;
...
...
@@ -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
* 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_dev
*
ca
;
...
...
fs/bcachefs/journal_reclaim.h
View file @
2384db8f
...
...
@@ -34,6 +34,7 @@ void bch2_journal_pin_add_if_older(struct journal *,
journal_pin_flush_fn
);
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_flush_pins
(
struct
journal
*
,
u64
);
...
...
fs/bcachefs/journal_types.h
View file @
2384db8f
...
...
@@ -210,6 +210,8 @@ struct journal {
/* protects advancing ja->discard_idx: */
struct
mutex
discard_lock
;
bool
can_discard
;
unsigned
write_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