Whamcloud - gitweb
LU-18163 obdclass: fix sysfs_memparse()/string_to_size() 35/56135/8
authorEtienne AUJAMES <etienne.aujames@cea.fr>
Thu, 22 Aug 2024 15:46:19 +0000 (17:46 +0200)
committerOleg Drokin <green@whamcloud.com>
Sun, 24 Nov 2024 06:04:30 +0000 (06:04 +0000)
commit10547cbf7ad11423729cc7a15ee1352bb4461814
treebfb64310030472a2a24fe78dfc0c660e56ec48ec
parent78bed6a53e3cd1c10534db0c7a470c6a7a2b6754
LU-18163 obdclass: fix sysfs_memparse()/string_to_size()

The patch reworks string_to_size() to avoid string copies and handle
default unit directly in __string_to_size().
Also, this would handle more gracefully fractional value with huge
unit (like 0.5EiB).

This implementation fixes the parsing of the following invalid
strings:
- "10.badbadMib"
- "10MiBbadbad"
- "10MBAD"
- "10.123badMib"
- "1024.KG"

The patch change the way to handle decimal fractional part: a maximum
of 9 digits are supported.

It fixes test_string_to_size_err() to actually return an error if a
test failed and then prevents the module to load.
It fixes obdclass_init() to avoid a crash if obd_init_checks()
failed.

Add regression tests in obd_init_checks.

Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Change-Id: Ic20d11368fc7608637e8123d7c6c5a2ab2cf4a4b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56135
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/class_obd.c
lustre/obdclass/lprocfs_status.c