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
0ec39856
Commit
0ec39856
authored
Aug 05, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Move bch_sb_field_crypt code to checksum.c
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
fb8e5b4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
42 deletions
+44
-42
fs/bcachefs/checksum.c
fs/bcachefs/checksum.c
+42
-0
fs/bcachefs/checksum.h
fs/bcachefs/checksum.h
+2
-0
fs/bcachefs/super-io.c
fs/bcachefs/super-io.c
+0
-42
No files found.
fs/bcachefs/checksum.c
View file @
0ec39856
...
...
@@ -460,6 +460,48 @@ int bch2_rechecksum_bio(struct bch_fs *c, struct bio *bio,
return
0
;
}
/* BCH_SB_FIELD_crypt: */
static
int
bch2_sb_crypt_validate
(
struct
bch_sb
*
sb
,
struct
bch_sb_field
*
f
,
struct
printbuf
*
err
)
{
struct
bch_sb_field_crypt
*
crypt
=
field_to_type
(
f
,
crypt
);
if
(
vstruct_bytes
(
&
crypt
->
field
)
<
sizeof
(
*
crypt
))
{
prt_printf
(
err
,
"wrong size (got %zu should be %zu)"
,
vstruct_bytes
(
&
crypt
->
field
),
sizeof
(
*
crypt
));
return
-
BCH_ERR_invalid_sb_crypt
;
}
if
(
BCH_CRYPT_KDF_TYPE
(
crypt
))
{
prt_printf
(
err
,
"bad kdf type %llu"
,
BCH_CRYPT_KDF_TYPE
(
crypt
));
return
-
BCH_ERR_invalid_sb_crypt
;
}
return
0
;
}
static
void
bch2_sb_crypt_to_text
(
struct
printbuf
*
out
,
struct
bch_sb
*
sb
,
struct
bch_sb_field
*
f
)
{
struct
bch_sb_field_crypt
*
crypt
=
field_to_type
(
f
,
crypt
);
prt_printf
(
out
,
"KFD: %llu"
,
BCH_CRYPT_KDF_TYPE
(
crypt
));
prt_newline
(
out
);
prt_printf
(
out
,
"scrypt n: %llu"
,
BCH_KDF_SCRYPT_N
(
crypt
));
prt_newline
(
out
);
prt_printf
(
out
,
"scrypt r: %llu"
,
BCH_KDF_SCRYPT_R
(
crypt
));
prt_newline
(
out
);
prt_printf
(
out
,
"scrypt p: %llu"
,
BCH_KDF_SCRYPT_P
(
crypt
));
prt_newline
(
out
);
}
const
struct
bch_sb_field_ops
bch_sb_field_ops_crypt
=
{
.
validate
=
bch2_sb_crypt_validate
,
.
to_text
=
bch2_sb_crypt_to_text
,
};
#ifdef __KERNEL__
static
int
__bch2_request_key
(
char
*
key_description
,
struct
bch_key
*
key
)
{
...
...
fs/bcachefs/checksum.h
View file @
0ec39856
...
...
@@ -72,6 +72,8 @@ static inline int bch2_encrypt_bio(struct bch_fs *c, unsigned type,
:
0
;
}
extern
const
struct
bch_sb_field_ops
bch_sb_field_ops_crypt
;
int
bch2_decrypt_sb_key
(
struct
bch_fs
*
,
struct
bch_sb_field_crypt
*
,
struct
bch_key
*
);
...
...
fs/bcachefs/super-io.c
View file @
0ec39856
...
...
@@ -1016,48 +1016,6 @@ void __bch2_check_set_feature(struct bch_fs *c, unsigned feat)
mutex_unlock
(
&
c
->
sb_lock
);
}
/* BCH_SB_FIELD_crypt: */
static
int
bch2_sb_crypt_validate
(
struct
bch_sb
*
sb
,
struct
bch_sb_field
*
f
,
struct
printbuf
*
err
)
{
struct
bch_sb_field_crypt
*
crypt
=
field_to_type
(
f
,
crypt
);
if
(
vstruct_bytes
(
&
crypt
->
field
)
<
sizeof
(
*
crypt
))
{
prt_printf
(
err
,
"wrong size (got %zu should be %zu)"
,
vstruct_bytes
(
&
crypt
->
field
),
sizeof
(
*
crypt
));
return
-
BCH_ERR_invalid_sb_crypt
;
}
if
(
BCH_CRYPT_KDF_TYPE
(
crypt
))
{
prt_printf
(
err
,
"bad kdf type %llu"
,
BCH_CRYPT_KDF_TYPE
(
crypt
));
return
-
BCH_ERR_invalid_sb_crypt
;
}
return
0
;
}
static
void
bch2_sb_crypt_to_text
(
struct
printbuf
*
out
,
struct
bch_sb
*
sb
,
struct
bch_sb_field
*
f
)
{
struct
bch_sb_field_crypt
*
crypt
=
field_to_type
(
f
,
crypt
);
prt_printf
(
out
,
"KFD: %llu"
,
BCH_CRYPT_KDF_TYPE
(
crypt
));
prt_newline
(
out
);
prt_printf
(
out
,
"scrypt n: %llu"
,
BCH_KDF_SCRYPT_N
(
crypt
));
prt_newline
(
out
);
prt_printf
(
out
,
"scrypt r: %llu"
,
BCH_KDF_SCRYPT_R
(
crypt
));
prt_newline
(
out
);
prt_printf
(
out
,
"scrypt p: %llu"
,
BCH_KDF_SCRYPT_P
(
crypt
));
prt_newline
(
out
);
}
static
const
struct
bch_sb_field_ops
bch_sb_field_ops_crypt
=
{
.
validate
=
bch2_sb_crypt_validate
,
.
to_text
=
bch2_sb_crypt_to_text
,
};
/* BCH_SB_FIELD_clean: */
int
bch2_sb_clean_validate_late
(
struct
bch_fs
*
c
,
struct
bch_sb_field_clean
*
clean
,
int
write
)
...
...
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