Commit 1cb2d696 authored by Christoph Hellwig's avatar Christoph Hellwig

XFS: More mount code cleanups

Modid: 2.5.x-xfs:slinx:128159a
parent f6ce5f1a
......@@ -203,14 +203,11 @@ xfs_cleanup(void)
* This function fills in xfs_mount_t fields based on mount args.
* Note: the superblock has _not_ yet been read in.
*/
int
STATIC int
xfs_start_flags(
vfs_t *vfsp,
dev_t ddev,
dev_t logdev,
dev_t rtdev,
struct xfs_mount_args *ap,
struct xfs_mount *mp)
struct xfs_mount *mp,
int ronly)
{
/* Values are in BBs */
if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
......@@ -222,19 +219,10 @@ xfs_start_flags(
*/
mp->m_dalign = ap->sunit;
mp->m_swidth = ap->swidth;
} else {
mp->m_dalign = 0;
mp->m_swidth = 0;
}
if (logdev != 0) {
if (logdev == ddev) {
mp->m_logdev_targp = mp->m_ddev_targp;
} else {
/* Set the log device's block size */
set_blocksize(mp->m_logdev_targp->pbr_bdev, 512);
}
if ((mp->m_logdev_targp != NULL) &&
(mp->m_logdev_targp != mp->m_ddev_targp)) {
if (ap->logbufs != 0 && ap->logbufs != -1 &&
(ap->logbufs < XLOG_NUM_ICLOGS ||
ap->logbufs > XLOG_MAX_ICLOGS)) {
......@@ -260,88 +248,73 @@ xfs_start_flags(
mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP);
strcpy(mp->m_fsname, ap->fsname);
}
if (rtdev != 0) {
if (rtdev == ddev || rtdev == logdev) {
cmn_err(CE_WARN,
"XFS: Cannot mount filesystem with identical rtdev and logdev.");
return XFS_ERROR(EINVAL);
} else {
/* Set the realtime device's block size */
set_blocksize(mp->m_rtdev_targp->pbr_bdev, 512);
}
}
/*
* Pull in the 'wsync' and 'ino64' mount options before we do the real
* work of mounting and recovery. The arg pointer will
* be NULL when we are being called from the root mount code.
*/
if (ap->flags & XFSMNT_WSYNC)
mp->m_flags |= XFS_MOUNT_WSYNC;
#if XFS_BIG_FILESYSTEMS
mp->m_inoadd = 0;
#endif
if (ap != NULL) {
if (ap->flags & XFSMNT_WSYNC)
mp->m_flags |= XFS_MOUNT_WSYNC;
#if XFS_BIG_FILESYSTEMS
if (ap->flags & XFSMNT_INO64) {
mp->m_flags |= XFS_MOUNT_INO64;
mp->m_inoadd = XFS_INO64_OFFSET;
}
if (ap->flags & XFSMNT_INO64) {
mp->m_flags |= XFS_MOUNT_INO64;
mp->m_inoadd = XFS_INO64_OFFSET;
}
#endif
if (ap->flags & XFSMNT_NOATIME)
mp->m_flags |= XFS_MOUNT_NOATIME;
if (ap->flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA))
xfs_qm_mount_quotainit(mp, ap->flags);
if (ap->flags & XFSMNT_NOATIME)
mp->m_flags |= XFS_MOUNT_NOATIME;
if (ap->flags & XFSMNT_RETERR)
mp->m_flags |= XFS_MOUNT_RETERR;
if (ap->flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA))
xfs_qm_mount_quotainit(mp, ap->flags);
if (ap->flags & XFSMNT_NOALIGN)
mp->m_flags |= XFS_MOUNT_NOALIGN;
if (ap->flags & XFSMNT_RETERR)
mp->m_flags |= XFS_MOUNT_RETERR;
if (ap->flags & XFSMNT_OSYNCISOSYNC)
mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
if (ap->flags & XFSMNT_NOALIGN)
mp->m_flags |= XFS_MOUNT_NOALIGN;
/* Default on Linux */
if ( 1 || ap->flags & XFSMNT_32BITINODES)
mp->m_flags |= XFS_MOUNT_32BITINODES;
if (ap->flags & XFSMNT_OSYNCISOSYNC)
mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
if (ap->flags & XFSMNT_IRIXSGID)
mp->m_flags |= XFS_MOUNT_IRIXSGID;
/* Default on Linux */
if (1 || ap->flags & XFSMNT_32BITINODES)
mp->m_flags |= XFS_MOUNT_32BITINODES;
if (ap->flags & XFSMNT_IOSIZE) {
if (ap->iosizelog > XFS_MAX_IO_LOG ||
ap->iosizelog < XFS_MIN_IO_LOG) {
cmn_err(CE_WARN,
"XFS: invalid log iosize: %d [not %d-%d]",
ap->iosizelog, XFS_MIN_IO_LOG,
XFS_MAX_IO_LOG);
return XFS_ERROR(EINVAL);
}
if (ap->flags & XFSMNT_IRIXSGID)
mp->m_flags |= XFS_MOUNT_IRIXSGID;
mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
if (ap->flags & XFSMNT_IOSIZE) {
if (ap->iosizelog > XFS_MAX_IO_LOG ||
ap->iosizelog < XFS_MIN_IO_LOG) {
cmn_err(CE_WARN,
"XFS: invalid log iosize: %d [not %d-%d]",
ap->iosizelog, XFS_MIN_IO_LOG,
XFS_MAX_IO_LOG);
return XFS_ERROR(EINVAL);
}
/*
* no recovery flag requires a read-only mount
*/
if (ap->flags & XFSMNT_NORECOVERY) {
if (!(vfsp->vfs_flag & VFS_RDONLY)) {
cmn_err(CE_WARN,
"XFS: tried to mount a FS read-write without recovery!");
return XFS_ERROR(EINVAL);
}
mp->m_flags |= XFS_MOUNT_NORECOVERY;
}
mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
}
if (ap->flags & XFSMNT_NOUUID)
mp->m_flags |= XFS_MOUNT_NOUUID;
if (ap->flags & XFSMNT_NOLOGFLUSH)
mp->m_flags |= XFS_MOUNT_NOLOGFLUSH;
/*
* no recovery flag requires a read-only mount
*/
if (ap->flags & XFSMNT_NORECOVERY) {
if (!ronly) {
cmn_err(CE_WARN,
"XFS: tried to mount a FS read-write without recovery!");
return XFS_ERROR(EINVAL);
}
mp->m_flags |= XFS_MOUNT_NORECOVERY;
}
if (ap->flags & XFSMNT_NOUUID)
mp->m_flags |= XFS_MOUNT_NOUUID;
if (ap->flags & XFSMNT_NOLOGFLUSH)
mp->m_flags |= XFS_MOUNT_NOLOGFLUSH;
return 0;
}
......@@ -349,14 +322,11 @@ xfs_start_flags(
* This function fills in xfs_mount_t fields based on mount args.
* Note: the superblock _has_ now been read in.
*/
int
STATIC int
xfs_finish_flags(
vfs_t *vfsp,
dev_t ddev,
dev_t logdev,
dev_t rtdev,
struct xfs_mount_args *ap,
struct xfs_mount *mp)
struct xfs_mount *mp,
int ronly)
{
/* Fail a mount where the logbuf is smaller then the log stripe */
if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) {
......@@ -379,8 +349,7 @@ xfs_finish_flags(
/*
* prohibit r/w mounts of read-only filesystems
*/
if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) &&
!(vfsp->vfs_flag & VFS_RDONLY)) {
if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
cmn_err(CE_WARN,
"XFS: cannot mount a read-only filesystem as read-write");
return XFS_ERROR(EROFS);
......@@ -399,7 +368,7 @@ xfs_finish_flags(
/*
* check for shared mount.
*/
if (ap && ap->flags & XFSMNT_SHARED) {
if (ap->flags & XFSMNT_SHARED) {
if (!XFS_SB_VERSION_HASSHARED(&mp->m_sb))
return XFS_ERROR(EINVAL);
......@@ -409,8 +378,7 @@ xfs_finish_flags(
* field set, must be version 0 and can only be mounted
* read-only.
*/
if (!(vfsp->vfs_flag & VFS_RDONLY) ||
!(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
(mp->m_sb.sb_shared_vn != 0))
return XFS_ERROR(EINVAL);
......@@ -441,6 +409,7 @@ xfs_cmountfs(
struct cred *cr)
{
xfs_mount_t *mp;
int ronly = (vfsp->vfs_flag & VFS_RDONLY);
int error = 0;
/*
......@@ -466,6 +435,17 @@ xfs_cmountfs(
pagebuf_lock_disable(mp->m_ddev_targp, 0);
goto error2;
}
if (rtdev == ddev || rtdev == logdev) {
cmn_err(CE_WARN,
"XFS: Cannot mount filesystem with identical rtdev and ddev/logdev.");
error = EINVAL;
pagebuf_lock_disable(mp->m_ddev_targp, 0);
goto error2;
}
/* Set the realtime device's block size */
set_blocksize(mp->m_rtdev_targp->pbr_bdev, 512);
}
if (logdev != ddev) {
......@@ -477,15 +457,20 @@ xfs_cmountfs(
pagebuf_lock_disable(mp->m_rtdev_targp, 1);
goto error2;
}
}
if ((error = xfs_start_flags(vfsp, ddev, logdev, rtdev, ap, mp)))
/* Set the log device's block size */
set_blocksize(mp->m_logdev_targp->pbr_bdev, 512);
} else {
mp->m_logdev_targp = mp->m_ddev_targp;
}
if ((error = xfs_start_flags(ap, mp, ronly)))
goto error3;
if ((error = xfs_readsb(mp)))
goto error3;
if ((error = xfs_finish_flags(vfsp, ddev, logdev, rtdev, ap, mp))) {
if ((error = xfs_finish_flags(ap, mp, ronly))) {
xfs_freesb(mp);
goto error3;
}
......@@ -499,14 +484,11 @@ xfs_cmountfs(
mp->m_sb.sb_blocksize);
mp->m_cxfstype = XFS_CXFS_NOT;
if ((error = xfs_mountfs(vfsp, mp, ddev, 0)) == 0) {
/* Success! */
return 0;
}
error = xfs_mountfs(vfsp, mp, ddev, 0);
if (error)
goto error3;
return 0;
/*
* Be careful not to clobber the value of 'error' here.
*/
error3:
/* It's impossible to get here before buftargs are filled */
xfs_binval(mp->m_ddev_targp);
......
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