Skip to content

Commit

Permalink
Add options for specifying integrity metadata pre-allocations
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Dec 18, 2024
1 parent 10423d2 commit e769d5b
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/stratis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ GLOBAL OPTIONS

COMMANDS
--------
pool create [--key-desc <key_desc>] [--clevis <(nbde|tang|tpm2)> [--tang-url <tang_url>] [<(--thumbprint <thp> | --trust-url)>] [--no-overprovision] <pool_name> <blockdev> [<blockdev>..]::
pool create [--key-desc <key_desc>] [--clevis <(nbde|tang|tpm2)> [--tang-url <tang_url>] [<(--thumbprint <thp> | --trust-url)>] [--no-overprovision] [--journal-size <journal_size>] [--tag-spec <tag_spec>] <pool_name> <blockdev> [<blockdev>..]::
Create a pool from one or more block devices, with the given pool name.
The --tag-spec and --journal-size options are used to configure the amount
of space to reserve for integrity metadata.
pool stop <(--uuid <uuid> |--name <name>)>::
Stop a pool, specifying the pool by its UUID or by its name. Tear down
the storage stack but leave all metadata intact.
Expand Down
2 changes: 2 additions & 0 deletions src/stratis_cli/_actions/_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<arg name="devices" type="as" direction="in" />
<arg name="key_desc" type="(bs)" direction="in" />
<arg name="clevis_info" type="(b(ss))" direction="in" />
<arg name="journal_size" type="(bt)" direction="in" />
<arg name="tag_spec" type="(bs)" direction="in" />
<arg name="result" type="(b(oao))" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
Expand Down
10 changes: 10 additions & 0 deletions src/stratis_cli/_actions/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ def create_pool(namespace): # pylint: disable=too-many-locals
if clevis_info is None
else (True, (clevis_info.pin, json.dumps(clevis_info.config)))
),
"journal_size": (
(False, 0)
if namespace.journal_size is None
else (True, namespace.journal_size.magnitude.numerator)
),
"tag_spec": (
(False, 0)
if namespace.tag_spec is None
else (True, namespace.tag_spec)
),
},
)

Expand Down
13 changes: 13 additions & 0 deletions src/stratis_cli/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,16 @@ class Clevis(Enum):

def __str__(self):
return self.value


class IntegrityTagSpec(Enum):
"""
Options for specifying integrity tag size.
"""

B0 = "0b"
B32 = "32b"
B512 = "512b"

def __str__(self):
return self.value
51 changes: 48 additions & 3 deletions src/stratis_cli/_parser/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
from uuid import UUID

from .._actions import BindActions, PoolActions
from .._constants import Clevis, EncryptionMethod, UnlockMethod, YesOrNo
from .._constants import (
Clevis,
EncryptionMethod,
IntegrityTagSpec,
UnlockMethod,
YesOrNo,
)
from .._error_codes import PoolErrorCode
from ._bind import BIND_SUBCMDS, REBIND_SUBCMDS
from ._debug import POOL_DEBUG_SUBCMDS
from ._range import RejectAction
from ._range import RejectAction, parse_range


class ClevisEncryptionOptions: # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -163,7 +169,46 @@ def _ensure_nat(arg):
)
],
},
)
),
(
"integrity",
{
"description": (
"Optional parameters for configuring integrity "
"metadata pre-allocation"
),
"args": [
(
"--journal-size",
{
"help": (
"Size of integrity device's journal. "
"Each block is written to this journal "
"before being written to its address. "
"The size of the journal must be a "
"multiple of 4 KiB."
),
"type": parse_range,
},
),
(
"--tag-spec",
{
"help": (
"Integrity tag specification defining "
"the size of the tag used to store a "
"checksum or other value for each "
"block on a device. stratisd chooses "
"a default specification if none is "
"given."
),
"choices": list(IntegrityTagSpec),
"type": IntegrityTagSpec,
},
),
],
},
),
],
"args": [
("pool_name", {"help": "Name of new pool"}),
Expand Down
14 changes: 14 additions & 0 deletions tests/whitebox/integration/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,20 @@ def test_create_with_post_parser_set(self):
for prefix in [[], ["--propagate"]]:
self.check_system_exit(prefix + command_line, _PARSE_ERROR)

def test_create_with_oversize_tag_value(self):
"""
Verify that a tag value of at least 256B will result in a parser error.
"""
command_line = [
"pool",
"create",
"pn",
"/dev/n",
"--tag-size=256B",
]
for prefix in [[], ["--propagate"]]:
self.check_system_exit(prefix + command_line, _PARSE_ERROR)

def test_stratis_list_filesystem_with_name_no_pool(self):
"""
We want to get a parse error if filesystem UUID is specified but no
Expand Down

0 comments on commit e769d5b

Please sign in to comment.