Skip to content

Commit

Permalink
Dataset checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
themylogin committed Jul 15, 2021
1 parent 2498eb5 commit 3651bfe
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/middlewared/middlewared/plugins/pool.py
Expand Up @@ -43,6 +43,9 @@

RE_HISTORY_ZPOOL_SCRUB = re.compile(r'^([0-9\.\:\-]{19})\s+zpool scrub', re.MULTILINE)
RE_HISTORY_ZPOOL_CREATE = re.compile(r'^([0-9\.\:\-]{19})\s+zpool create', re.MULTILINE)
ZFS_CHECKSUM_CHOICES = [
'ON', 'OFF', 'FLETCHER2', 'FLETCHER4', 'SHA256', 'SHA512', 'SKEIN', 'EDONR',
]
ZFS_ENCRYPTION_ALGORITHM_CHOICES = [
'AES-128-CCM', 'AES-192-CCM', 'AES-256-CCM', 'AES-128-GCM', 'AES-192-GCM', 'AES-256-GCM'
]
Expand Down Expand Up @@ -567,6 +570,7 @@ def pool_extend(self, pool):
Str('name', required=True),
Bool('encryption', default=False),
Str('deduplication', enum=[None, 'ON', 'VERIFY', 'OFF'], default=None, null=True),
Str('checksum', enum=[None] + ZFS_CHECKSUM_CHOICES, default=None, null=True),
Dict(
'encryption_options',
Bool('generate_key', default=False),
Expand Down Expand Up @@ -749,6 +753,9 @@ async def do_create(self, job, data):
if dedup:
fsoptions['dedup'] = dedup.lower()

if data['checksum'] is not None:
fsoptions['checksum'] = data['checksum'].lower()

cachefile_dir = os.path.dirname(ZPOOL_CACHE_FILE)
if not os.path.isdir(cachefile_dir):
os.makedirs(cachefile_dir)
Expand Down Expand Up @@ -852,6 +859,7 @@ async def restart_services(self):
('rm', {'name': 'encryption'}),
('rm', {'name': 'encryption_options'}),
('rm', {'name': 'deduplication'}),
('rm', {'name': 'checksum'}),
('edit', {'name': 'topology', 'method': lambda x: setattr(x, 'update', True)}),
))
@job(lock='pool_createupdate')
Expand Down Expand Up @@ -2070,6 +2078,16 @@ class Config:
event_send = False
cli_namespace = 'storage.dataset'

@accepts()
@returns(Dict(
*[Str(k, enum=[k]) for k in ZFS_CHECKSUM_CHOICES if v != 'OFF'],
))
async def checksum_choices(self):
"""
Retrieve checksums supported for ZFS dataset.
"""
return {v: v for v in ZFS_CHECKSUM_CHOICES if v != 'OFF'}

@accepts()
@returns(Dict(
*[Str(k, enum=[k]) for k in ZFS_COMPRESSION_ALGORITHM_CHOICES],
Expand Down Expand Up @@ -2994,7 +3012,48 @@ def __transform(self, datasets, retrieve_children, children_filters):
"""

def transform(dataset):
<<<<<<< HEAD
for orig_name, new_name, method in get_props_of_interest_mapping():
=======
for orig_name, new_name, method in (
('org.freenas:description', 'comments', None),
('org.freenas:quota_warning', 'quota_warning', None),
('org.freenas:quota_critical', 'quota_critical', None),
('org.freenas:refquota_warning', 'refquota_warning', None),
('org.freenas:refquota_critical', 'refquota_critical', None),
('org.truenas:managedby', 'managedby', None),
('dedup', 'deduplication', str.upper),
('mountpoint', None, _null),
('aclmode', None, str.upper),
('acltype', None, str.upper),
('xattr', None, str.upper),
('atime', None, str.upper),
('casesensitivity', None, str.upper),
('checksum', None, str.upper),
('exec', None, str.upper),
('sync', None, str.upper),
('compression', None, str.upper),
('compressratio', None, None),
('origin', None, None),
('quota', None, _null),
('refquota', None, _null),
('reservation', None, _null),
('refreservation', None, _null),
('copies', None, None),
('snapdir', None, str.upper),
('readonly', None, str.upper),
('recordsize', None, None),
('sparse', None, None),
('volsize', None, None),
('volblocksize', None, None),
('keyformat', 'key_format', lambda o: o.upper() if o != 'none' else None),
('encryption', 'encryption_algorithm', lambda o: o.upper() if o != 'off' else None),
('used', None, None),
('available', None, None),
('special_small_blocks', 'special_small_block_size', None),
('pbkdf2iters', None, None),
):
>>>>>>> Dataset checksum
if orig_name not in dataset['properties']:
continue
i = new_name or orig_name
Expand Down Expand Up @@ -3057,6 +3116,7 @@ def transform(dataset):
Inheritable(Int('copies')),
Inheritable(Str('snapdir', enum=['VISIBLE', 'HIDDEN'])),
Inheritable(Str('deduplication', enum=['ON', 'VERIFY', 'OFF'])),
Inheritable(Str('checksum', enum=ZFS_CHECKSUM_CHOICES)),
Inheritable(Str('readonly', enum=['ON', 'OFF'])),
Inheritable(Str('recordsize', enum=[
'512', '1K', '2K', '4K', '8K', '16K', '32K', '64K', '128K', '256K', '512K', '1024K',
Expand Down Expand Up @@ -3220,6 +3280,7 @@ async def do_create(self, app, data):
('acltype', None, str.lower, True),
('atime', None, str.lower, True),
('casesensitivity', None, str.lower, True),
('checksum', None, str.lower, True),
('comments', 'org.freenas:description', None, True),
('compression', None, str.lower, True),
('copies', None, lambda x: str(x), True),
Expand Down Expand Up @@ -3353,6 +3414,7 @@ async def do_update(self, id, data):
('aclmode', None, str.lower, True),
('acltype', None, str.lower, True),
('atime', None, str.lower, True),
('checksum', None, str.lower, True),
('comments', 'org.freenas:description', None, False),
('sync', None, str.lower, True),
('compression', None, str.lower, True),
Expand Down

0 comments on commit 3651bfe

Please sign in to comment.