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,26 +248,12 @@ 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 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
......@@ -304,7 +278,7 @@ xfs_start_flags(
mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
/* Default on Linux */
if ( 1 || ap->flags & XFSMNT_32BITINODES)
if (1 || ap->flags & XFSMNT_32BITINODES)
mp->m_flags |= XFS_MOUNT_32BITINODES;
if (ap->flags & XFSMNT_IRIXSGID)
......@@ -328,7 +302,7 @@ xfs_start_flags(
* no recovery flag requires a read-only mount
*/
if (ap->flags & XFSMNT_NORECOVERY) {
if (!(vfsp->vfs_flag & VFS_RDONLY)) {
if (!ronly) {
cmn_err(CE_WARN,
"XFS: tried to mount a FS read-write without recovery!");
return XFS_ERROR(EINVAL);
......@@ -340,7 +314,6 @@ xfs_start_flags(
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;
}
/* 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(vfsp, ddev, logdev, rtdev, ap, mp)))
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! */
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