Commit 48a06e1b authored by Ian Kent's avatar Ian Kent Committed by Darrick J. Wong

xfs: refactor xfs_parseags()

Refactor xfs_parseags(), move the entire token case block to a separate
function in an attempt to highlight the code that actually changes in
converting to use the new mount api.

Also change the break in the switch to a return in the factored out
xfs_fc_parse_param() function.
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 846410cc
......@@ -160,189 +160,205 @@ match_kstrtoint(
return ret;
}
/*
* This function fills in xfs_mount_t fields based on mount args.
* Note: the superblock has _not_ yet been read in.
*
* Note that this function leaks the various device name allocations on
* failure. The caller takes care of them.
*
* *sb is const because this is also used to test options on the remount
* 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...
*/
static int
xfs_parseargs(
struct xfs_mount *mp,
char *options)
xfs_fc_parse_param(
int token,
char *p,
substring_t *args,
struct xfs_mount *mp)
{
const struct super_block *sb = mp->m_super;
char *p;
substring_t args[MAX_OPT_ARGS];
int size = 0;
/*
* Copy binary VFS mount flags we are interested in.
*/
if (sb_rdonly(sb))
mp->m_flags |= XFS_MOUNT_RDONLY;
if (sb->s_flags & SB_DIRSYNC)
mp->m_flags |= XFS_MOUNT_DIRSYNC;
if (sb->s_flags & SB_SYNCHRONOUS)
mp->m_flags |= XFS_MOUNT_WSYNC;
/*
* These can be overridden by the mount option parsing.
*/
mp->m_logbufs = -1;
mp->m_logbsize = -1;
mp->m_allocsize_log = 16; /* 64k */
if (!options)
return 0;
while ((p = strsep(&options, ",")) != NULL) {
int token;
if (!*p)
continue;
token = match_token(p, tokens, args);
switch (token) {
case Opt_logbufs:
if (match_int(args, &mp->m_logbufs))
return -EINVAL;
break;
return 0;
case Opt_logbsize:
if (match_kstrtoint(args, 10, &mp->m_logbsize))
return -EINVAL;
break;
return 0;
case Opt_logdev:
kfree(mp->m_logname);
mp->m_logname = match_strdup(args);
if (!mp->m_logname)
return -ENOMEM;
break;
return 0;
case Opt_rtdev:
kfree(mp->m_rtname);
mp->m_rtname = match_strdup(args);
if (!mp->m_rtname)
return -ENOMEM;
break;
return 0;
case Opt_allocsize:
if (match_kstrtoint(args, 10, &size))
return -EINVAL;
mp->m_allocsize_log = ffs(size) - 1;
mp->m_flags |= XFS_MOUNT_ALLOCSIZE;
break;
return 0;
case Opt_grpid:
case Opt_bsdgroups:
mp->m_flags |= XFS_MOUNT_GRPID;
break;
return 0;
case Opt_nogrpid:
case Opt_sysvgroups:
mp->m_flags &= ~XFS_MOUNT_GRPID;
break;
return 0;
case Opt_wsync:
mp->m_flags |= XFS_MOUNT_WSYNC;
break;
return 0;
case Opt_norecovery:
mp->m_flags |= XFS_MOUNT_NORECOVERY;
break;
return 0;
case Opt_noalign:
mp->m_flags |= XFS_MOUNT_NOALIGN;
break;
return 0;
case Opt_swalloc:
mp->m_flags |= XFS_MOUNT_SWALLOC;
break;
return 0;
case Opt_sunit:
if (match_int(args, &mp->m_dalign))
return -EINVAL;
break;
return 0;
case Opt_swidth:
if (match_int(args, &mp->m_swidth))
return -EINVAL;
break;
return 0;
case Opt_inode32:
mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
break;
return 0;
case Opt_inode64:
mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
break;
return 0;
case Opt_nouuid:
mp->m_flags |= XFS_MOUNT_NOUUID;
break;
return 0;
case Opt_ikeep:
mp->m_flags |= XFS_MOUNT_IKEEP;
break;
return 0;
case Opt_noikeep:
mp->m_flags &= ~XFS_MOUNT_IKEEP;
break;
return 0;
case Opt_largeio:
mp->m_flags |= XFS_MOUNT_LARGEIO;
break;
return 0;
case Opt_nolargeio:
mp->m_flags &= ~XFS_MOUNT_LARGEIO;
break;
return 0;
case Opt_attr2:
mp->m_flags |= XFS_MOUNT_ATTR2;
break;
return 0;
case Opt_noattr2:
mp->m_flags &= ~XFS_MOUNT_ATTR2;
mp->m_flags |= XFS_MOUNT_NOATTR2;
break;
return 0;
case Opt_filestreams:
mp->m_flags |= XFS_MOUNT_FILESTREAMS;
break;
return 0;
case Opt_noquota:
mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
break;
return 0;
case Opt_quota:
case Opt_uquota:
case Opt_usrquota:
mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
XFS_UQUOTA_ENFD);
break;
return 0;
case Opt_qnoenforce:
case Opt_uqnoenforce:
mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
mp->m_qflags &= ~XFS_UQUOTA_ENFD;
break;
return 0;
case Opt_pquota:
case Opt_prjquota:
mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
XFS_PQUOTA_ENFD);
break;
return 0;
case Opt_pqnoenforce:
mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
mp->m_qflags &= ~XFS_PQUOTA_ENFD;
break;
return 0;
case Opt_gquota:
case Opt_grpquota:
mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
XFS_GQUOTA_ENFD);
break;
return 0;
case Opt_gqnoenforce:
mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
mp->m_qflags &= ~XFS_GQUOTA_ENFD;
break;
return 0;
case Opt_discard:
mp->m_flags |= XFS_MOUNT_DISCARD;
break;
return 0;
case Opt_nodiscard:
mp->m_flags &= ~XFS_MOUNT_DISCARD;
break;
return 0;
#ifdef CONFIG_FS_DAX
case Opt_dax:
mp->m_flags |= XFS_MOUNT_DAX;
break;
return 0;
#endif
default:
xfs_warn(mp, "unknown mount option [%s].", p);
return -EINVAL;
}
return 0;
}
/*
* This function fills in xfs_mount_t fields based on mount args.
* Note: the superblock has _not_ yet been read in.
*
* Note that this function leaks the various device name allocations on
* failure. The caller takes care of them.
*
* *sb is const because this is also used to test options on the remount
* 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...
*/
static int
xfs_parseargs(
struct xfs_mount *mp,
char *options)
{
const struct super_block *sb = mp->m_super;
char *p;
substring_t args[MAX_OPT_ARGS];
/*
* Copy binary VFS mount flags we are interested in.
*/
if (sb_rdonly(sb))
mp->m_flags |= XFS_MOUNT_RDONLY;
if (sb->s_flags & SB_DIRSYNC)
mp->m_flags |= XFS_MOUNT_DIRSYNC;
if (sb->s_flags & SB_SYNCHRONOUS)
mp->m_flags |= XFS_MOUNT_WSYNC;
/*
* These can be overridden by the mount option parsing.
*/
mp->m_logbufs = -1;
mp->m_logbsize = -1;
mp->m_allocsize_log = 16; /* 64k */
if (!options)
return 0;
while ((p = strsep(&options, ",")) != NULL) {
int token;
int ret;
if (!*p)
continue;
token = match_token(p, tokens, args);
ret = xfs_fc_parse_param(token, p, args, mp);
if (ret)
return ret;
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment