Message ID | 3c4582c2ab0ac2537ab70bce3ac3270f81468139.1738163840.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] btrfs: sysfs: accept size suffixes for read policy values | expand |
On Wed, Jan 29, 2025 at 11:21:46PM +0800, Anand Jain wrote: > We now parse human-friendly size values (e.g. '1G', '2M') when setting > read policies. > > Suggested-by: David Sterba <dsterba@suse.com> > Reviewed-by: David Sterba <dsterba@suse.com> > Signed-off-by: Anand Jain <anand.jain@oracle.com> v2 is ok, for simple updates like adding a comment you don't need to resend it. Please add the patch to for-next, thanks.
On Wed, Feb 05, 2025 at 06:58:10PM +0100, David Sterba wrote: > On Wed, Jan 29, 2025 at 11:21:46PM +0800, Anand Jain wrote: > > We now parse human-friendly size values (e.g. '1G', '2M') when setting > > read policies. > > > > Suggested-by: David Sterba <dsterba@suse.com> > > Reviewed-by: David Sterba <dsterba@suse.com> > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > > v2 is ok, for simple updates like adding a comment you don't need to > resend it. Please add the patch to for-next, thanks. Now added to for-next.
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 53b846d99ece..cb6af316fffd 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1342,17 +1342,18 @@ int btrfs_read_policy_to_enum(const char *str, s64 *value_ret) /* Separate value from input in policy:value format. */ value_str = strchr(param, ':'); if (value_str) { - int ret; + char *retptr; *value_str = 0; value_str++; if (!value_ret) return -EINVAL; - ret = kstrtos64(value_str, 10, value_ret); - if (ret) + + *value_ret = memparse(value_str, &retptr); + /* There could be any trailing typos after the value. */ + retptr = skip_spaces(retptr); + if (*retptr != 0 || *value_ret <= 0) return -EINVAL; - if (*value_ret < 0) - return -ERANGE; } #endif