From 4e8c6efae3bf8c016c560e58771b7a4db7032efe Mon Sep 17 00:00:00 2001 From: Tony Asleson Date: Thu, 23 May 2019 14:43:41 -0500 Subject: [PATCH 2/2] sim_array [volume|fs]_resize: Change re-size behavior The simulator only allows size increments of a block size. The code was returning success if the user specified 1 byte more for the resize, but internally it wasn't updating the size, eg. it was leaving the previous rounded down size. This goes against the documentation for the volume re-size where we may round up for resize. This change rounds up the supplied value. If the rounded up size matches current size we return no state change, else we round up and update the simulator value to match. This also matches the expected behavior that when successful the new size will indeed be different, although it may be larger than specified and if the exact operation is repeated, it will fail with no state change. Signed-off-by: Tony Asleson --- plugin/sim/simarray.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py index bc7817b..8552e3d 100644 --- a/plugin/sim/simarray.py +++ b/plugin/sim/simarray.py @@ -1367,18 +1367,12 @@ def _sim_ag_ids_of_masked_vol(self, sim_vol_id): 'vol_masks', 'vol_id="%s"' % sim_vol_id)) def sim_vol_resize(self, sim_vol_id, new_size_bytes): - org_new_size_bytes = new_size_bytes new_size_bytes = BackStore._block_rounding(new_size_bytes) sim_vol = self.sim_vol_of_id(sim_vol_id) if sim_vol['total_space'] == new_size_bytes: - if org_new_size_bytes != new_size_bytes: - # Even volume size is identical to rounded size, - # but it's not what user requested, hence we silently pass. - return - else: - raise LsmError( - ErrorNumber.NO_STATE_CHANGE, - "Volume size is identical to requested") + raise LsmError( + ErrorNumber.NO_STATE_CHANGE, + "Volume size is identical to requested") sim_pool = self.sim_pool_of_id(sim_vol['pool_id']) @@ -1610,17 +1604,13 @@ def sim_fs_delete(self, sim_fs_id): self._data_delete("fss", 'id="%s"' % sim_fs_id) def sim_fs_resize(self, sim_fs_id, new_size_bytes): - org_new_size_bytes = new_size_bytes new_size_bytes = BackStore._block_rounding(new_size_bytes) sim_fs = self.sim_fs_of_id(sim_fs_id) if sim_fs['total_space'] == new_size_bytes: - if new_size_bytes != org_new_size_bytes: - return - else: - raise LsmError( - ErrorNumber.NO_STATE_CHANGE, - "File System size is identical to requested") + raise LsmError( + ErrorNumber.NO_STATE_CHANGE, + "File System size is identical to requested") # TODO(Gris Ge): If a fs is in a clone/snapshot relationship, resize # should be handled properly. -- 2.37.3.windows.1