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