Re: [PATCH] btrfs: validate scrub_speed_max sysfs string

David Sterba
2023-12-13T22:57:10Z

On Mon, Dec 11, 2023 at 01:48:15PM +1030, Qu Wenruo wrote:
>
>
> On 2023/12/8 11:11, David Disseldorp wrote:
> > Fail the sysfs I/O on any trailing non-space characters.
> >
> > Signed-off-by: David Disseldorp <ddiss@suse.de>
>
> Reviewed-by: Qu Wenruo <wqu@suse.com>
>
> Although I have an unrelated idea.
>
> Since memparse() provides the @endptr, can we rewind the @endptr, so
> that we can check if the last valid charactor is suffix 'e'.
> Then reject it from btrfs size.
>
> I really don't think we need exabytes suffix for our scrub speed limit
> usage.

I think nobody will intentionally use the 'e' exabyte suffix in this
case but I don't want to add an exception to parsing the values. We'd
have to document that, explain why it's not accepted, it's additional
work for a case I still dont understand why it's so important.

If the exabyte scale values are not properly parsed by memparse() due to
simple_strtoull() as a workaround we can add our parser based on
kstrtoull() or do such change in memparse() proper.