xfs: refactor suffix_kstrtoint()
The mount-api doesn't have a "human unit" parse type yet so the options that have values like "10k" etc. still need to be converted by the fs. But the value comes to the fs as a string (not a substring_t type) so there's a need to change the conversion function to take a character string instead. When xfs is switched to use the new mount-api match_kstrtoint() will no longer be used and will be removed. Signed-off-by: Ian Kent <raven@themaw.net> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
Родитель
2c6eba3177
Коммит
c0a6791667
|
@ -108,14 +108,17 @@ static const match_table_t tokens = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
STATIC int
|
static int
|
||||||
suffix_kstrtoint(const substring_t *s, unsigned int base, int *res)
|
suffix_kstrtoint(
|
||||||
|
const char *s,
|
||||||
|
unsigned int base,
|
||||||
|
int *res)
|
||||||
{
|
{
|
||||||
int last, shift_left_factor = 0, _res;
|
int last, shift_left_factor = 0, _res;
|
||||||
char *value;
|
char *value;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
value = match_strdup(s);
|
value = kstrdup(s, GFP_KERNEL);
|
||||||
if (!value)
|
if (!value)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -140,6 +143,23 @@ suffix_kstrtoint(const substring_t *s, unsigned int base, int *res)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
match_kstrtoint(
|
||||||
|
const substring_t *s,
|
||||||
|
unsigned int base,
|
||||||
|
int *res)
|
||||||
|
{
|
||||||
|
const char *value;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
value = match_strdup(s);
|
||||||
|
if (!value)
|
||||||
|
return -ENOMEM;
|
||||||
|
ret = suffix_kstrtoint(value, base, res);
|
||||||
|
kfree(value);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function fills in xfs_mount_t fields based on mount args.
|
* This function fills in xfs_mount_t fields based on mount args.
|
||||||
* Note: the superblock has _not_ yet been read in.
|
* Note: the superblock has _not_ yet been read in.
|
||||||
|
@ -151,7 +171,7 @@ suffix_kstrtoint(const substring_t *s, unsigned int base, int *res)
|
||||||
* path, and we don't want this to have any side effects at remount time.
|
* path, and we don't want this to have any side effects at remount time.
|
||||||
* Today this function does not change *sb, but just to future-proof...
|
* Today this function does not change *sb, but just to future-proof...
|
||||||
*/
|
*/
|
||||||
STATIC int
|
static int
|
||||||
xfs_parseargs(
|
xfs_parseargs(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
char *options)
|
char *options)
|
||||||
|
@ -194,7 +214,7 @@ xfs_parseargs(
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case Opt_logbsize:
|
case Opt_logbsize:
|
||||||
if (suffix_kstrtoint(args, 10, &mp->m_logbsize))
|
if (match_kstrtoint(args, 10, &mp->m_logbsize))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case Opt_logdev:
|
case Opt_logdev:
|
||||||
|
@ -210,7 +230,7 @@ xfs_parseargs(
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
break;
|
break;
|
||||||
case Opt_allocsize:
|
case Opt_allocsize:
|
||||||
if (suffix_kstrtoint(args, 10, &size))
|
if (match_kstrtoint(args, 10, &size))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
mp->m_allocsize_log = ffs(size) - 1;
|
mp->m_allocsize_log = ffs(size) - 1;
|
||||||
mp->m_flags |= XFS_MOUNT_ALLOCSIZE;
|
mp->m_flags |= XFS_MOUNT_ALLOCSIZE;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче