Whamcloud - gitweb
LU-9859 ptlrpc: simplifying expression parsing in nrs_tbf
The standard approach to parsing in the kernel is to modify strings as
needed, such as to nul-terminate substrings.
Lustre tends to pass around lengths instead, which means that various
kernel functions such as kstrtoNN() or strsep() or even strcmp()
cannot be used.
We can simplify code in nrs_tbf if we kstrdup() strings before parsing
them, and then use standard functions.
cfs_gettok() strips spaces while finding the token. With this patch,
stripping of spaces is left to the final stage where an expression
(a={b}) is being parsed. It might arrive with arbitrary space such as
" a ={ b } ".
A test in sanityn has some spaces added in various places to ensure
that are parsed correctly as an earlier version of this patch got some
of that wrong.
The list parsed in nrs_tbf_id_list_parse() can have multiple separator
(spaces) between elements, which contrasts with expressions which only
have a single '=" or "&" etc.
So strsep() might return an empty token between two consecutive
spaces. This is not necessarily an error - it is only an error if
*all* tokens are empty. So we add a "list_empty()" test at the end.
Test-Parameters: trivial
Test-Parameters: testlist=sanityn
Test-Parameters: testlist=sanity
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Id4fb399773e49e4869ca5ebf93fe63c864d82287
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50835
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>