Skip to content

Commit

Permalink
Misc fixup
Browse files Browse the repository at this point in the history
(cherry picked from commit 391c8ce)
  • Loading branch information
bmeagherix authored and bugclerk committed Dec 12, 2024
1 parent 48a4e45 commit c66e269
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/middlewared/middlewared/plugins/iscsi_/extents.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def do_create(self, data):
await self.clean(data, 'iscsi_extent_create', verrors)
verrors.check()

await self.save(data, 'iscsi_extent_create', verrors)
await self.middleware.call('iscsi.extent.save', data, 'iscsi_extent_create', verrors)

# This change is being made in conjunction with threads_num being specified in scst.conf
if data['type'] == 'DISK' and data['path'].startswith('zvol/'):
Expand Down Expand Up @@ -161,14 +161,15 @@ async def do_update(self, audit_callback, id_, data):
verrors.check()
new.pop(self.locked_field)

if data['path'] is not None and data['path'].startswith('zvol/'):
zvolname = zvol_path_to_name(os.path.join('/dev', data['path']))
zvolpath = new.get('path')
if zvolpath is not None and zvolpath.startswith('zvol/'):
zvolname = zvol_path_to_name(os.path.join('/dev', zvolpath))
await self.middleware.call(
'zfs.dataset.update',
zvolname,
{
'properties': {
'readonly': {'value': 'on' if data['ro'] else 'off'}
'readonly': {'value': 'on' if new['ro'] else 'off'}
}
}
)
Expand All @@ -183,6 +184,9 @@ async def do_update(self, audit_callback, id_, data):

await self._service_change('iscsitarget', 'reload')

# scstadmin can have issues when modifying an existing extent, re-run
await self._service_change('iscsitarget', 'reload')

return await self.get_instance(id_)

@accepts(
Expand Down Expand Up @@ -238,8 +242,8 @@ async def do_delete(self, audit_callback, id_, remove, force):
await self.middleware.call('iscsi.alua.wait_for_alua_settled')

@private
def validate(self, data):
data['serial'] = self.extent_serial(data['serial'])
async def validate(self, data):
data['serial'] = await self.extent_serial(data['serial'])
data['naa'] = self.extent_naa(data.get('naa'))

@private
Expand Down Expand Up @@ -405,10 +409,10 @@ def clean_size(self, data, schema_name, verrors):
return data

@private
def extent_serial(self, serial):
async def extent_serial(self, serial):
if serial in [None, '']:
used_serials = [i['serial'] for i in (
self.middleware.call_sync('iscsi.extent.query', [], {'select': ['serial']})
await self.middleware.call('iscsi.extent.query', [], {'select': ['serial']})
)]
tries = 5
for i in range(tries):
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/pool_/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ async def do_update(self, audit_callback, id_, data):
# as R/O (or R/W), we need to be sure and update the associated extent so
# that we don't get into a scenario where the iscsi extent is R/W but the
# underlying zvol is R/O. Windows clients seem to not handle this very well.
await self.middleware.call('iscsi.global.resync_readonly_property_for_zvol', id_)
await self.middleware.call('iscsi.global.resync_readonly_property_for_zvol', id_, data['readonly'])

updated_ds = await self.get_instance(id_)
self.middleware.send_event('pool.dataset.query', 'CHANGED', id=id_, fields=updated_ds)
Expand Down

0 comments on commit c66e269

Please sign in to comment.