From 9009b9d18fb702f28f3673939f09b9444b81c2cd Mon Sep 17 00:00:00 2001 From: Gil Vitzinger Date: Mon, 7 Oct 2024 11:00:44 +0200 Subject: [PATCH] fix(extend): fs not resizing when mounted *resolves NVMESH-1935 *fixes an issue where fs will fail to extend with 'Nothing To Do!' output because it still see the old size of the block device Change-Id: I9b18ae32820dfc6502c594aef7f1d402a06d3f2f Signed-off-by: Gil --- driver/FileSystemManager.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/driver/FileSystemManager.py b/driver/FileSystemManager.py index 3e8d117..32ba642 100644 --- a/driver/FileSystemManager.py +++ b/driver/FileSystemManager.py @@ -129,8 +129,21 @@ def format_block_device(block_device_path, fs_type, mkfs_options): FileSystemManager.mkfs(fs_type=fs_type, target_path=block_device_path, flags=[mkfs_options]) + + @staticmethod + def update_bdev_cached_size(block_device_path): + ''' + This re-reads the block device partition data which updates the block device size that the fs will see when it wants to resize + ''' + + exit_code, stdout, stderr = Utils.run_command('blockdev --rereadpt {}'.format(block_device_path)) + if exit_code != 0: + raise DriverError(StatusCode.INTERNAL, 'Error re-reading block device partition size on block device {}'.format(block_device_path)) + @staticmethod def expand_file_system(block_device_path, fs_type): + FileSystemManager.update_bdev_cached_size(block_device_path) + fs_type = fs_type.strip() if fs_type == '': @@ -143,7 +156,7 @@ def expand_file_system(block_device_path, fs_type): raise DriverError(StatusCode.INVALID_ARGUMENT, 'unknown fs_type {}'.format(fs_type)) exit_code, stdout, stderr = Utils.run_command(cmd) - logger.debug("resize file-system finished {} {} {}".format(exit_code, stdout, stderr)) + logger.debug("resize file-system finished exit_code: {} stdout: {} stderr: {}".format(exit_code, stdout, stderr)) if exit_code != 0: raise DriverError(StatusCode.INTERNAL, 'Error expanding File System {} on block device {}'.format(fs_type, block_device_path))