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
eac3ca0f
Commit
eac3ca0f
authored
Jan 24, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: New journal_entry_res mechanism
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
6e1b0718
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
11 deletions
+61
-11
fs/bcachefs/journal.c
fs/bcachefs/journal.c
+46
-11
fs/bcachefs/journal.h
fs/bcachefs/journal.h
+4
-0
fs/bcachefs/journal_types.h
fs/bcachefs/journal_types.h
+11
-0
No files found.
fs/bcachefs/journal.c
View file @
eac3ca0f
...
...
@@ -64,11 +64,6 @@ static void bch2_journal_buf_init(struct journal *j)
buf
->
data
->
u64s
=
0
;
}
static
inline
size_t
journal_entry_u64s_reserve
(
struct
journal_buf
*
buf
)
{
return
BTREE_ID_NR
*
(
JSET_KEYS_U64s
+
BKEY_EXTENT_U64s_MAX
);
}
static
inline
bool
journal_entry_empty
(
struct
jset
*
j
)
{
struct
jset_entry
*
i
;
...
...
@@ -130,7 +125,7 @@ static enum {
j
->
prev_buf_sectors
=
vstruct_blocks_plus
(
buf
->
data
,
c
->
block_bits
,
journal_entry_u64s_reserve
(
buf
)
)
*
buf
->
u64s_reserved
)
*
c
->
opts
.
block_size
;
BUG_ON
(
j
->
prev_buf_sectors
>
j
->
cur_buf_sectors
);
...
...
@@ -225,6 +220,7 @@ static int journal_entry_open(struct journal *j)
return
sectors
;
buf
->
disk_sectors
=
sectors
;
buf
->
u64s_reserved
=
j
->
entry_u64s_reserved
;
sectors
=
min_t
(
unsigned
,
sectors
,
buf
->
size
>>
9
);
j
->
cur_buf_sectors
=
sectors
;
...
...
@@ -233,11 +229,7 @@ static int journal_entry_open(struct journal *j)
/* Subtract the journal header */
u64s
-=
sizeof
(
struct
jset
)
/
sizeof
(
u64
);
/*
* Btree roots, prio pointers don't get added until right before we do
* the write:
*/
u64s
-=
journal_entry_u64s_reserve
(
buf
);
u64s
-=
buf
->
u64s_reserved
;
u64s
=
max_t
(
ssize_t
,
0L
,
u64s
);
BUG_ON
(
u64s
>=
JOURNAL_ENTRY_CLOSED_VAL
);
...
...
@@ -437,6 +429,45 @@ int bch2_journal_res_get_slowpath(struct journal *j, struct journal_res *res,
return
ret
;
}
/* journal_entry_res: */
void
bch2_journal_entry_res_resize
(
struct
journal
*
j
,
struct
journal_entry_res
*
res
,
unsigned
new_u64s
)
{
union
journal_res_state
state
;
int
d
=
new_u64s
-
res
->
u64s
;
spin_lock
(
&
j
->
lock
);
j
->
entry_u64s_reserved
+=
d
;
if
(
d
<=
0
)
goto
out_unlock
;
j
->
cur_entry_u64s
-=
d
;
smp_mb
();
state
=
READ_ONCE
(
j
->
reservations
);
if
(
state
.
cur_entry_offset
<
JOURNAL_ENTRY_CLOSED_VAL
&&
state
.
cur_entry_offset
>
j
->
cur_entry_u64s
)
{
j
->
cur_entry_u64s
+=
d
;
/*
* Not enough room in current journal entry, have to flush it:
*/
__journal_entry_close
(
j
);
goto
out
;
}
journal_cur_buf
(
j
)
->
u64s_reserved
+=
d
;
out_unlock:
spin_unlock
(
&
j
->
lock
);
out:
res
->
u64s
+=
d
;
return
;
}
/* journal flushing: */
u64
bch2_journal_last_unwritten_seq
(
struct
journal
*
j
)
{
u64
seq
;
...
...
@@ -1024,6 +1055,10 @@ int bch2_fs_journal_init(struct journal *j)
j
->
write_delay_ms
=
1000
;
j
->
reclaim_delay_ms
=
100
;
/* Btree roots: */
j
->
entry_u64s_reserved
+=
BTREE_ID_NR
*
(
JSET_KEYS_U64s
+
BKEY_EXTENT_U64s_MAX
);
atomic64_set
(
&
j
->
reservations
.
counter
,
((
union
journal_res_state
)
{
.
cur_entry_offset
=
JOURNAL_ENTRY_CLOSED_VAL
}).
v
);
...
...
fs/bcachefs/journal.h
View file @
eac3ca0f
...
...
@@ -333,6 +333,10 @@ static inline int bch2_journal_res_get(struct journal *j, struct journal_res *re
return
0
;
}
void
bch2_journal_entry_res_resize
(
struct
journal
*
,
struct
journal_entry_res
*
,
unsigned
);
u64
bch2_journal_last_unwritten_seq
(
struct
journal
*
);
int
bch2_journal_open_seq_async
(
struct
journal
*
,
u64
,
struct
closure
*
);
...
...
fs/bcachefs/journal_types.h
View file @
eac3ca0f
...
...
@@ -24,6 +24,7 @@ struct journal_buf {
unsigned
size
;
unsigned
disk_sectors
;
unsigned
u64s_reserved
;
/* bloom filter: */
unsigned
long
has_inode
[
1024
/
sizeof
(
unsigned
long
)];
};
...
...
@@ -155,6 +156,9 @@ struct journal {
u64
seq_ondisk
;
u64
last_seq_ondisk
;
/* Reserved space in journal entry to be used just prior to write */
unsigned
entry_u64s_reserved
;
/*
* FIFO of journal entries whose btree updates have not yet been
* written out.
...
...
@@ -243,4 +247,11 @@ struct journal_device {
struct
closure
read
;
};
/*
* journal_entry_res - reserve space in every journal entry:
*/
struct
journal_entry_res
{
unsigned
u64s
;
};
#endif
/* _BCACHEFS_JOURNAL_TYPES_H */
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