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
fa5bed37
Commit
fa5bed37
authored
Aug 18, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: move check_pos_snapshot_overwritten() to snapshot.c
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
7573041a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
49 deletions
+51
-49
fs/bcachefs/btree_update.c
fs/bcachefs/btree_update.c
+4
-49
fs/bcachefs/snapshot.c
fs/bcachefs/snapshot.c
+34
-0
fs/bcachefs/snapshot.h
fs/bcachefs/snapshot.h
+13
-0
No files found.
fs/bcachefs/btree_update.c
View file @
fa5bed37
...
...
@@ -28,51 +28,6 @@ bch2_trans_update_by_path(struct btree_trans *, struct btree_path *,
struct
bkey_i
*
,
enum
btree_update_flags
,
unsigned
long
ip
);
static
noinline
int
__check_pos_snapshot_overwritten
(
struct
btree_trans
*
trans
,
enum
btree_id
id
,
struct
bpos
pos
)
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
btree_iter
iter
;
struct
bkey_s_c
k
;
int
ret
;
bch2_trans_iter_init
(
trans
,
&
iter
,
id
,
pos
,
BTREE_ITER_NOT_EXTENTS
|
BTREE_ITER_ALL_SNAPSHOTS
);
while
(
1
)
{
k
=
bch2_btree_iter_prev
(
&
iter
);
ret
=
bkey_err
(
k
);
if
(
ret
)
break
;
if
(
!
k
.
k
)
break
;
if
(
!
bkey_eq
(
pos
,
k
.
k
->
p
))
break
;
if
(
bch2_snapshot_is_ancestor
(
c
,
k
.
k
->
p
.
snapshot
,
pos
.
snapshot
))
{
ret
=
1
;
break
;
}
}
bch2_trans_iter_exit
(
trans
,
&
iter
);
return
ret
;
}
static
inline
int
check_pos_snapshot_overwritten
(
struct
btree_trans
*
trans
,
enum
btree_id
id
,
struct
bpos
pos
)
{
if
(
!
btree_type_has_snapshots
(
id
)
||
bch2_snapshot_is_leaf
(
trans
->
c
,
pos
.
snapshot
))
return
0
;
return
__check_pos_snapshot_overwritten
(
trans
,
id
,
pos
);
}
static
noinline
int
extent_front_merge
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
,
struct
bkey_s_c
k
,
...
...
@@ -91,8 +46,8 @@ static noinline int extent_front_merge(struct btree_trans *trans,
if
(
!
bch2_bkey_merge
(
c
,
bkey_i_to_s
(
update
),
bkey_i_to_s_c
(
*
insert
)))
return
0
;
ret
=
check_pos_snapshot_overwritten
(
trans
,
iter
->
btree_id
,
k
.
k
->
p
)
?:
check_pos_snapshot_overwritten
(
trans
,
iter
->
btree_id
,
(
*
insert
)
->
k
.
p
);
ret
=
bch2_key_has_snapshot_overwrites
(
trans
,
iter
->
btree_id
,
k
.
k
->
p
)
?:
bch2_key_has_snapshot_overwrites
(
trans
,
iter
->
btree_id
,
(
*
insert
)
->
k
.
p
);
if
(
ret
<
0
)
return
ret
;
if
(
ret
)
...
...
@@ -114,8 +69,8 @@ static noinline int extent_back_merge(struct btree_trans *trans,
struct
bch_fs
*
c
=
trans
->
c
;
int
ret
;
ret
=
check_pos_snapshot_overwritten
(
trans
,
iter
->
btree_id
,
insert
->
k
.
p
)
?:
check_pos_snapshot_overwritten
(
trans
,
iter
->
btree_id
,
k
.
k
->
p
);
ret
=
bch2_key_has_snapshot_overwrites
(
trans
,
iter
->
btree_id
,
insert
->
k
.
p
)
?:
bch2_key_has_snapshot_overwrites
(
trans
,
iter
->
btree_id
,
k
.
k
->
p
);
if
(
ret
<
0
)
return
ret
;
if
(
ret
)
...
...
fs/bcachefs/snapshot.c
View file @
fa5bed37
...
...
@@ -1336,6 +1336,40 @@ int bch2_delete_dead_snapshots_hook(struct btree_trans *trans,
return
0
;
}
int
__bch2_key_has_snapshot_overwrites
(
struct
btree_trans
*
trans
,
enum
btree_id
id
,
struct
bpos
pos
)
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
btree_iter
iter
;
struct
bkey_s_c
k
;
int
ret
;
bch2_trans_iter_init
(
trans
,
&
iter
,
id
,
pos
,
BTREE_ITER_NOT_EXTENTS
|
BTREE_ITER_ALL_SNAPSHOTS
);
while
(
1
)
{
k
=
bch2_btree_iter_prev
(
&
iter
);
ret
=
bkey_err
(
k
);
if
(
ret
)
break
;
if
(
!
k
.
k
)
break
;
if
(
!
bkey_eq
(
pos
,
k
.
k
->
p
))
break
;
if
(
bch2_snapshot_is_ancestor
(
c
,
k
.
k
->
p
.
snapshot
,
pos
.
snapshot
))
{
ret
=
1
;
break
;
}
}
bch2_trans_iter_exit
(
trans
,
&
iter
);
return
ret
;
}
int
bch2_snapshots_read
(
struct
bch_fs
*
c
)
{
struct
btree_iter
iter
;
...
...
fs/bcachefs/snapshot.h
View file @
fa5bed37
...
...
@@ -250,6 +250,19 @@ int bch2_delete_dead_snapshots_hook(struct btree_trans *,
struct
btree_trans_commit_hook
*
);
void
bch2_delete_dead_snapshots_work
(
struct
work_struct
*
);
int
__bch2_key_has_snapshot_overwrites
(
struct
btree_trans
*
,
enum
btree_id
,
struct
bpos
);
static
inline
int
bch2_key_has_snapshot_overwrites
(
struct
btree_trans
*
trans
,
enum
btree_id
id
,
struct
bpos
pos
)
{
if
(
!
btree_type_has_snapshots
(
id
)
||
bch2_snapshot_is_leaf
(
trans
->
c
,
pos
.
snapshot
))
return
0
;
return
__bch2_key_has_snapshot_overwrites
(
trans
,
id
,
pos
);
}
int
bch2_snapshots_read
(
struct
bch_fs
*
);
void
bch2_fs_snapshots_exit
(
struct
bch_fs
*
);
...
...
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