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
43b0e878
Commit
43b0e878
authored
Feb 21, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Check for redundant ec entries/stripe ptrs
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
c9163bb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
fs/bcachefs/extents.c
fs/bcachefs/extents.c
+27
-1
No files found.
fs/bcachefs/extents.c
View file @
43b0e878
...
...
@@ -1116,7 +1116,7 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
unsigned
size_ondisk
=
k
.
k
->
size
;
unsigned
nonce
=
UINT_MAX
;
unsigned
nr_ptrs
=
0
;
bool
unwritten
=
false
,
have_ec
=
false
;
bool
unwritten
=
false
,
have_ec
=
false
,
crc_since_last_ptr
=
false
;
int
ret
;
if
(
bkey_is_btree_ptr
(
k
.
k
))
...
...
@@ -1159,6 +1159,7 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
unwritten
=
entry
->
ptr
.
unwritten
;
have_ec
=
false
;
crc_since_last_ptr
=
false
;
nr_ptrs
++
;
break
;
case
BCH_EXTENT_ENTRY_crc32
:
...
...
@@ -1192,18 +1193,43 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
return
-
BCH_ERR_invalid_bkey
;
}
}
if
(
crc_since_last_ptr
)
{
prt_printf
(
err
,
"redundant crc entry"
);
return
-
BCH_ERR_invalid_bkey
;
}
crc_since_last_ptr
=
true
;
break
;
case
BCH_EXTENT_ENTRY_stripe_ptr
:
if
(
have_ec
)
{
prt_printf
(
err
,
"redundant stripe entry"
);
return
-
BCH_ERR_invalid_bkey
;
}
have_ec
=
true
;
break
;
}
}
if
(
!
nr_ptrs
)
{
prt_str
(
err
,
"no ptrs"
);
return
-
BCH_ERR_invalid_bkey
;
}
if
(
nr_ptrs
>=
BCH_BKEY_PTRS_MAX
)
{
prt_str
(
err
,
"too many ptrs"
);
return
-
BCH_ERR_invalid_bkey
;
}
if
(
crc_since_last_ptr
)
{
prt_printf
(
err
,
"redundant crc entry"
);
return
-
BCH_ERR_invalid_bkey
;
}
if
(
have_ec
)
{
prt_printf
(
err
,
"redundant stripe entry"
);
return
-
BCH_ERR_invalid_bkey
;
}
return
0
;
}
...
...
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