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( ...@@ -160,189 +160,205 @@ match_kstrtoint(
return ret; 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 static int
xfs_parseargs( xfs_fc_parse_param(
struct xfs_mount *mp, int token,
char *options) 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; 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) { switch (token) {
case Opt_logbufs: case Opt_logbufs:
if (match_int(args, &mp->m_logbufs)) if (match_int(args, &mp->m_logbufs))
return -EINVAL; return -EINVAL;
break; return 0;
case Opt_logbsize: case Opt_logbsize:
if (match_kstrtoint(args, 10, &mp->m_logbsize)) if (match_kstrtoint(args, 10, &mp->m_logbsize))
return -EINVAL; return -EINVAL;
break; return 0;
case Opt_logdev: case Opt_logdev:
kfree(mp->m_logname); kfree(mp->m_logname);
mp->m_logname = match_strdup(args); mp->m_logname = match_strdup(args);
if (!mp->m_logname) if (!mp->m_logname)
return -ENOMEM; return -ENOMEM;
break; return 0;
case Opt_rtdev: case Opt_rtdev:
kfree(mp->m_rtname); kfree(mp->m_rtname);
mp->m_rtname = match_strdup(args); mp->m_rtname = match_strdup(args);
if (!mp->m_rtname) if (!mp->m_rtname)
return -ENOMEM; return -ENOMEM;
break; return 0;
case Opt_allocsize: case Opt_allocsize:
if (match_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;
break; return 0;
case Opt_grpid: case Opt_grpid:
case Opt_bsdgroups: case Opt_bsdgroups:
mp->m_flags |= XFS_MOUNT_GRPID; mp->m_flags |= XFS_MOUNT_GRPID;
break; return 0;
case Opt_nogrpid: case Opt_nogrpid:
case Opt_sysvgroups: case Opt_sysvgroups:
mp->m_flags &= ~XFS_MOUNT_GRPID; mp->m_flags &= ~XFS_MOUNT_GRPID;
break; return 0;
case Opt_wsync: case Opt_wsync:
mp->m_flags |= XFS_MOUNT_WSYNC; mp->m_flags |= XFS_MOUNT_WSYNC;
break; return 0;
case Opt_norecovery: case Opt_norecovery:
mp->m_flags |= XFS_MOUNT_NORECOVERY; mp->m_flags |= XFS_MOUNT_NORECOVERY;
break; return 0;
case Opt_noalign: case Opt_noalign:
mp->m_flags |= XFS_MOUNT_NOALIGN; mp->m_flags |= XFS_MOUNT_NOALIGN;
break; return 0;
case Opt_swalloc: case Opt_swalloc:
mp->m_flags |= XFS_MOUNT_SWALLOC; mp->m_flags |= XFS_MOUNT_SWALLOC;
break; return 0;
case Opt_sunit: case Opt_sunit:
if (match_int(args, &mp->m_dalign)) if (match_int(args, &mp->m_dalign))
return -EINVAL; return -EINVAL;
break; return 0;
case Opt_swidth: case Opt_swidth:
if (match_int(args, &mp->m_swidth)) if (match_int(args, &mp->m_swidth))
return -EINVAL; return -EINVAL;
break; return 0;
case Opt_inode32: case Opt_inode32:
mp->m_flags |= XFS_MOUNT_SMALL_INUMS; mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
break; return 0;
case Opt_inode64: case Opt_inode64:
mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
break; return 0;
case Opt_nouuid: case Opt_nouuid:
mp->m_flags |= XFS_MOUNT_NOUUID; mp->m_flags |= XFS_MOUNT_NOUUID;
break; return 0;
case Opt_ikeep: case Opt_ikeep:
mp->m_flags |= XFS_MOUNT_IKEEP; mp->m_flags |= XFS_MOUNT_IKEEP;
break; return 0;
case Opt_noikeep: case Opt_noikeep:
mp->m_flags &= ~XFS_MOUNT_IKEEP; mp->m_flags &= ~XFS_MOUNT_IKEEP;
break; return 0;
case Opt_largeio: case Opt_largeio:
mp->m_flags |= XFS_MOUNT_LARGEIO; mp->m_flags |= XFS_MOUNT_LARGEIO;
break; return 0;
case Opt_nolargeio: case Opt_nolargeio:
mp->m_flags &= ~XFS_MOUNT_LARGEIO; mp->m_flags &= ~XFS_MOUNT_LARGEIO;
break; return 0;
case Opt_attr2: case Opt_attr2:
mp->m_flags |= XFS_MOUNT_ATTR2; mp->m_flags |= XFS_MOUNT_ATTR2;
break; return 0;
case Opt_noattr2: case Opt_noattr2:
mp->m_flags &= ~XFS_MOUNT_ATTR2; mp->m_flags &= ~XFS_MOUNT_ATTR2;
mp->m_flags |= XFS_MOUNT_NOATTR2; mp->m_flags |= XFS_MOUNT_NOATTR2;
break; return 0;
case Opt_filestreams: case Opt_filestreams:
mp->m_flags |= XFS_MOUNT_FILESTREAMS; mp->m_flags |= XFS_MOUNT_FILESTREAMS;
break; return 0;
case Opt_noquota: case Opt_noquota:
mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD; mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE; mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
break; return 0;
case Opt_quota: case Opt_quota:
case Opt_uquota: case Opt_uquota:
case Opt_usrquota: case Opt_usrquota:
mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE | mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
XFS_UQUOTA_ENFD); XFS_UQUOTA_ENFD);
break; return 0;
case Opt_qnoenforce: case Opt_qnoenforce:
case Opt_uqnoenforce: case Opt_uqnoenforce:
mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE); mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
mp->m_qflags &= ~XFS_UQUOTA_ENFD; mp->m_qflags &= ~XFS_UQUOTA_ENFD;
break; return 0;
case Opt_pquota: case Opt_pquota:
case Opt_prjquota: case Opt_prjquota:
mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
XFS_PQUOTA_ENFD); XFS_PQUOTA_ENFD);
break; return 0;
case Opt_pqnoenforce: case Opt_pqnoenforce:
mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
mp->m_qflags &= ~XFS_PQUOTA_ENFD; mp->m_qflags &= ~XFS_PQUOTA_ENFD;
break; return 0;
case Opt_gquota: case Opt_gquota:
case Opt_grpquota: case Opt_grpquota:
mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
XFS_GQUOTA_ENFD); XFS_GQUOTA_ENFD);
break; return 0;
case Opt_gqnoenforce: case Opt_gqnoenforce:
mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
mp->m_qflags &= ~XFS_GQUOTA_ENFD; mp->m_qflags &= ~XFS_GQUOTA_ENFD;
break; return 0;
case Opt_discard: case Opt_discard:
mp->m_flags |= XFS_MOUNT_DISCARD; mp->m_flags |= XFS_MOUNT_DISCARD;
break; return 0;
case Opt_nodiscard: case Opt_nodiscard:
mp->m_flags &= ~XFS_MOUNT_DISCARD; mp->m_flags &= ~XFS_MOUNT_DISCARD;
break; return 0;
#ifdef CONFIG_FS_DAX #ifdef CONFIG_FS_DAX
case Opt_dax: case Opt_dax:
mp->m_flags |= XFS_MOUNT_DAX; mp->m_flags |= XFS_MOUNT_DAX;
break; return 0;
#endif #endif
default: default:
xfs_warn(mp, "unknown mount option [%s].", p); xfs_warn(mp, "unknown mount option [%s].", p);
return -EINVAL; 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