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
f4e68c85
Commit
f4e68c85
authored
Feb 07, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: check inode->bi_parent_subvol against dirent
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
ea27001e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
23 deletions
+14
-23
fs/bcachefs/fsck.c
fs/bcachefs/fsck.c
+13
-22
fs/bcachefs/sb-errors_types.h
fs/bcachefs/sb-errors_types.h
+1
-1
No files found.
fs/bcachefs/fsck.c
View file @
f4e68c85
...
...
@@ -1012,7 +1012,7 @@ static int check_inode(struct btree_trans *trans,
if
(
fsck_err_on
(
u
.
bi_parent_subvol
&&
(
u
.
bi_subvol
==
0
||
u
.
bi_subvol
==
BCACHEFS_ROOT_SUBVOL
),
c
,
inode_bi_parent_
subvol_
nonzero
,
c
,
inode_bi_parent_nonzero
,
"inode %llu:%u has subvol %u but nonzero parent subvol %u"
,
u
.
bi_inum
,
k
.
k
->
p
.
snapshot
,
u
.
bi_subvol
,
u
.
bi_parent_subvol
))
{
u
.
bi_parent_subvol
=
0
;
...
...
@@ -1685,27 +1685,6 @@ static int check_dirent_target(struct btree_trans *trans,
d
=
dirent_i_to_s_c
(
n
);
}
if
(
fsck_err_on
(
d
.
v
->
d_type
==
DT_SUBVOL
&&
target
->
bi_parent_subvol
!=
le32_to_cpu
(
d
.
v
->
d_parent_subvol
),
c
,
dirent_d_parent_subvol_wrong
,
"dirent has wrong d_parent_subvol field: got %u, should be %u"
,
le32_to_cpu
(
d
.
v
->
d_parent_subvol
),
target
->
bi_parent_subvol
))
{
n
=
bch2_trans_kmalloc
(
trans
,
bkey_bytes
(
d
.
k
));
ret
=
PTR_ERR_OR_ZERO
(
n
);
if
(
ret
)
goto
err
;
bkey_reassemble
(
&
n
->
k_i
,
d
.
s_c
);
n
->
v
.
d_parent_subvol
=
cpu_to_le32
(
target
->
bi_parent_subvol
);
ret
=
bch2_trans_update
(
trans
,
iter
,
&
n
->
k_i
,
0
);
if
(
ret
)
goto
err
;
d
=
dirent_i_to_s_c
(
n
);
}
err:
fsck_err:
printbuf_exit
(
&
buf
);
...
...
@@ -1718,6 +1697,7 @@ static int check_dirent_to_subvol(struct btree_trans *trans, struct btree_iter *
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_inode_unpacked
subvol_root
;
u32
parent_subvol
=
le32_to_cpu
(
d
.
v
->
d_parent_subvol
);
u32
target_subvol
=
le32_to_cpu
(
d
.
v
->
d_child_subvol
);
u32
target_snapshot
;
u64
target_inum
;
...
...
@@ -1738,6 +1718,17 @@ static int check_dirent_to_subvol(struct btree_trans *trans, struct btree_iter *
if
(
ret
&&
!
bch2_err_matches
(
ret
,
ENOENT
))
return
ret
;
if
(
fsck_err_on
(
parent_subvol
!=
subvol_root
.
bi_parent_subvol
,
c
,
inode_bi_parent_wrong
,
"subvol root %llu has wrong bi_parent_subvol: got %u, should be %u"
,
target_inum
,
subvol_root
.
bi_parent_subvol
,
parent_subvol
))
{
subvol_root
.
bi_parent_subvol
=
parent_subvol
;
ret
=
__bch2_fsck_write_inode
(
trans
,
&
subvol_root
,
target_snapshot
);
if
(
ret
)
return
ret
;
}
ret
=
check_dirent_target
(
trans
,
iter
,
d
,
&
subvol_root
,
target_snapshot
);
if
(
ret
)
...
...
fs/bcachefs/sb-errors_types.h
View file @
f4e68c85
...
...
@@ -231,7 +231,7 @@
x(dirent_name_dot_or_dotdot, 223) \
x(dirent_name_has_slash, 224) \
x(dirent_d_type_wrong, 225) \
x(
dirent_d_parent_subvol
_wrong, 226) \
x(
inode_bi_parent
_wrong, 226) \
x(dirent_in_missing_dir_inode, 227) \
x(dirent_in_non_dir_inode, 228) \
x(dirent_to_missing_inode, 229) \
...
...
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