Whamcloud - gitweb
LU-9091 sysfs: use string helper like functions for sysfs 58/35658/22
authorJames Simmons <jsimmons@infradead.org>
Fri, 3 Jan 2020 02:47:07 +0000 (21:47 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 10 Jan 2020 07:41:57 +0000 (07:41 +0000)
commitd9e0c9f346d0f0cccfa37737807d6f9d08255ab7
tree9aea002a26d66f76605eb2aa142d6c5ad25587f9
parentc4c17fa4a3f5d9c3df44e19ab3385c8de655cdef
LU-9091 sysfs: use string helper like functions for sysfs

For a very long time the Linux kernel has supported the function
memparse() that allowed the passing in of memory sizes with the
suffix set of K, M, G, T, P, E. Lustre adopted this approach
with its proc / sysfs implmentation. The difference being that
lustre expanded this functionality to allow sizes with a
fractional component, such as 1.5G for example. The code used to
parse for the numerical value is heavily tied into the debugfs
seq_file handling and stomps on the passed in buffer which you
can't do with sysfs files.

Similar functionality to what Lustre does today exist in newer
linux kernels in the form of string helpers. Currently the
string helpers only convert a numerical value to human readable
format. A new function, string_to_size(), was created that takes
a string and turns it into a numerical value. This enables the
use of string helper suffixes i.e MiB, kB etc with the lustre
tunables and we can now support 10 base numbers i.e MB, kB as
well. Already string helper suffixes are used for debugfs files
so I expect this to be adopted over time so it should be
encouraged to use string_to_size() for newer lustre sysfs files.

At the same time we want to perserve the original behavior of
using the suffix set of K, M, G, T, P, E. To do this we create
the function sysfs_memparse() that supports the new string helper
suffixes as well as the older set of suffixes. This new code is
also way simpler than what is currently done with the current code.

Change-Id: Ia437db44f2a987aa11ab4ff3e9df23e9aeba04d7
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/35658
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
13 files changed:
contrib/scripts/spelling.txt
lustre/include/lprocfs_status.h
lustre/ldlm/ldlm_resource.c
lustre/lod/lproc_lod.c
lustre/lov/lproc_lov.c
lustre/mdc/lproc_mdc.c
lustre/obdclass/class_obd.c
lustre/obdclass/lprocfs_status.c
lustre/ofd/lproc_ofd.c
lustre/osc/lproc_osc.c
lustre/osd-ldiskfs/osd_lproc.c
lustre/osd-zfs/osd_lproc.c
lustre/osp/lproc_osp.c