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
6474b706
Commit
6474b706
authored
Dec 11, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Clean up btree_trans
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
398c9834
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
39 deletions
+40
-39
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.c
+7
-5
fs/bcachefs/btree_trans_commit.c
fs/bcachefs/btree_trans_commit.c
+2
-2
fs/bcachefs/btree_types.h
fs/bcachefs/btree_types.h
+27
-28
fs/bcachefs/btree_update.c
fs/bcachefs/btree_update.c
+2
-2
fs/bcachefs/btree_update.h
fs/bcachefs/btree_update.h
+1
-1
fs/bcachefs/fsck.c
fs/bcachefs/fsck.c
+1
-1
No files found.
fs/bcachefs/btree_iter.c
View file @
6474b706
...
...
@@ -1493,7 +1493,7 @@ static void bch2_trans_update_max_paths(struct btree_trans *trans)
printbuf_exit
(
&
buf
);
trans
->
nr_
max_paths
=
nr
;
trans
->
nr_
paths_max
=
nr
;
}
noinline
__cold
...
...
@@ -1526,13 +1526,11 @@ static inline btree_path_idx_t btree_path_alloc(struct btree_trans *trans,
if
(
unlikely
(
idx
==
BTREE_ITER_MAX
))
btree_path_overflow
(
trans
);
BUG_ON
(
idx
>
BTREE_ITER_MAX
);
/*
* Do this before marking the new path as allocated, since it won't be
* initialized yet:
*/
if
(
unlikely
(
idx
>
trans
->
nr_
max_paths
))
if
(
unlikely
(
idx
>
trans
->
nr_
paths_max
))
bch2_trans_update_max_paths
(
trans
);
__set_bit
(
idx
,
trans
->
paths_allocated
);
...
...
@@ -2918,6 +2916,10 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)
atomic_inc_not_zero
(
&
c
->
journal_keys
.
ref
);
closure_init_stack
(
&
trans
->
ref
);
trans
->
paths_allocated
=
trans
->
_paths_allocated
;
trans
->
sorted
=
trans
->
_sorted
;
trans
->
paths
=
trans
->
_paths
;
trans
->
paths_allocated
[
0
]
=
1
;
s
=
btree_trans_stats
(
trans
);
...
...
@@ -2935,7 +2937,7 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)
}
if
(
s
)
{
trans
->
nr_
max_paths
=
s
->
nr_max_paths
;
trans
->
nr_
paths_max
=
s
->
nr_max_paths
;
trans
->
journal_entries_size
=
s
->
journal_entries_size
;
}
...
...
fs/bcachefs/btree_trans_commit.c
View file @
6474b706
...
...
@@ -1044,9 +1044,9 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
trans
->
journal_u64s
+=
jset_u64s
(
i
->
old_k
.
u64s
);
}
if
(
trans
->
extra_
journal
_res
)
{
if
(
trans
->
extra_
disk
_res
)
{
ret
=
bch2_disk_reservation_add
(
c
,
trans
->
disk_res
,
trans
->
extra_
journal
_res
,
trans
->
extra_
disk
_res
,
(
flags
&
BCH_TRANS_COMMIT_no_enospc
)
?
BCH_DISK_RESERVATION_NOFAIL
:
0
);
if
(
ret
)
...
...
fs/bcachefs/btree_types.h
View file @
6474b706
...
...
@@ -374,21 +374,22 @@ struct btree_trans_commit_hook {
struct
btree_trans
{
struct
bch_fs
*
c
;
const
char
*
fn
;
struct
closure
ref
;
struct
list_head
list
;
u64
last_begin_time
;
u8
lock_may_not_fail
;
u8
lock_must_abort
;
struct
btree_bkey_cached_common
*
locking
;
struct
six_lock_waiter
locking_wait
;
unsigned
long
*
paths_allocated
;
u8
*
sorted
;
struct
btree_path
*
paths
;
int
srcu_idx
;
void
*
mem
;
unsigned
mem_top
;
unsigned
mem_max
;
unsigned
mem_bytes
;
btree_path_idx_t
nr_sorted
;
btree_path_idx_t
nr_paths_max
;
u8
fn_idx
;
u8
nr_sorted
;
u8
nr_updates
;
u8
lock_must_abort
;
bool
lock_may_not_fail
:
1
;
bool
srcu_held
:
1
;
bool
used_mempool
:
1
;
bool
in_traverse_all
:
1
;
...
...
@@ -400,40 +401,38 @@ struct btree_trans {
bool
write_locked
:
1
;
enum
bch_errcode
restarted
:
16
;
u32
restart_count
;
u64
last_begin_time
;
unsigned
long
last_begin_ip
;
unsigned
long
last_restarted_ip
;
unsigned
long
srcu_lock_time
;
/*
* For when bch2_trans_update notices we'll be splitting a compressed
* extent:
*/
unsigned
extra_journal_res
;
btree_path_idx_t
nr_max_paths
;
const
char
*
fn
;
struct
closure
ref
;
struct
list_head
list
;
struct
btree_bkey_cached_common
*
locking
;
struct
six_lock_waiter
locking_wait
;
int
srcu_idx
;
/* update path: */
u16
journal_entries_u64s
;
u16
journal_entries_size
;
struct
jset_entry
*
journal_entries
;
unsigned
long
paths_allocated
[
BITS_TO_LONGS
(
BTREE_ITER_MAX
)];
unsigned
mem_top
;
unsigned
mem_max
;
unsigned
mem_bytes
;
void
*
mem
;
u8
sorted
[
BTREE_ITER_MAX
+
8
];
struct
btree_path
paths
[
BTREE_ITER_MAX
];
struct
btree_insert_entry
updates
[
BTREE_ITER_MAX
];
/* update path: */
struct
btree_trans_commit_hook
*
hooks
;
struct
jset_entry
*
journal_entries
;
struct
journal_entry_pin
*
journal_pin
;
struct
journal_res
journal_res
;
u64
*
journal_seq
;
struct
disk_reservation
*
disk_res
;
unsigned
journal_u64s
;
unsigned
extra_disk_res
;
/* XXX kill */
struct
replicas_delta_list
*
fs_usage_deltas
;
unsigned
long
_paths_allocated
[
BITS_TO_LONGS
(
BTREE_ITER_MAX
)];
u8
_sorted
[
BTREE_ITER_MAX
+
8
];
struct
btree_path
_paths
[
BTREE_ITER_MAX
];
};
static
inline
struct
btree_path
*
btree_iter_path
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
)
...
...
fs/bcachefs/btree_update.c
View file @
6474b706
...
...
@@ -200,7 +200,7 @@ int bch2_trans_update_extent_overwrite(struct btree_trans *trans,
*/
if
(
nr_splits
>
1
&&
(
compressed_sectors
=
bch2_bkey_sectors_compressed
(
old
)))
trans
->
extra_
journal
_res
+=
compressed_sectors
*
(
nr_splits
-
1
);
trans
->
extra_
disk
_res
+=
compressed_sectors
*
(
nr_splits
-
1
);
if
(
front_split
)
{
update
=
bch2_bkey_make_mut_noupdate
(
trans
,
old
);
...
...
@@ -386,7 +386,7 @@ bch2_trans_update_by_path(struct btree_trans *trans, btree_path_idx_t path_idx,
struct
btree_path
*
path
=
trans
->
paths
+
path_idx
;
EBUG_ON
(
!
path
->
should_be_locked
);
EBUG_ON
(
trans
->
nr_updates
>=
BTREE_ITER_MAX
);
EBUG_ON
(
trans
->
nr_updates
>=
ARRAY_SIZE
(
trans
->
updates
)
);
EBUG_ON
(
!
bpos_eq
(
k
->
k
.
p
,
path
->
pos
));
n
=
(
struct
btree_insert_entry
)
{
...
...
fs/bcachefs/btree_update.h
View file @
6474b706
...
...
@@ -196,10 +196,10 @@ static inline void bch2_trans_reset_updates(struct btree_trans *trans)
trans_for_each_update
(
trans
,
i
)
bch2_path_put
(
trans
,
i
->
path
,
true
);
trans
->
extra_journal_res
=
0
;
trans
->
nr_updates
=
0
;
trans
->
journal_entries_u64s
=
0
;
trans
->
hooks
=
NULL
;
trans
->
extra_disk_res
=
0
;
if
(
trans
->
fs_usage_deltas
)
{
trans
->
fs_usage_deltas
->
used
=
0
;
...
...
fs/bcachefs/fsck.c
View file @
6474b706
...
...
@@ -1186,7 +1186,7 @@ static int overlapping_extents_found(struct btree_trans *trans,
swap
(
k1
,
k2
);
}
trans
->
extra_
journal
_res
+=
bch2_bkey_sectors_compressed
(
k2
);
trans
->
extra_
disk
_res
+=
bch2_bkey_sectors_compressed
(
k2
);
ret
=
bch2_trans_update_extent_overwrite
(
trans
,
old_iter
,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE
,
...
...
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