diff options
author | kan <kan@FreeBSD.org> | 2003-11-12 02:54:47 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2003-11-12 02:54:47 +0000 |
commit | 9352a05d4022d31faee0a088a5df3456001e11ae (patch) | |
tree | 963d06f6412e2d375c02189a6cf5029c4daf196f /sys/nfsclient/nfs_vfsops.c | |
parent | d1ef13f16432b757a9c7eaf23feeac0383dc1e92 (diff) | |
download | FreeBSD-src-9352a05d4022d31faee0a088a5df3456001e11ae.zip FreeBSD-src-9352a05d4022d31faee0a088a5df3456001e11ae.tar.gz |
1. Consolidate mount struct allocation/destruction into a common code in
vfs_mount_alloc/vfs_mount_destroy functions and take care to completely
destroy the mount point along with its locks. Mount struct has grown in
coplexity recently and depending on each failure path to destroy it
completely isn't working anymore.
2. Eliminate largely identical vfs_mount and vfs_unmount question by
moving the code to handle both cases into a newly introduced vfs_domount
function.
3. Simplify nfs_mount_diskless to always expect an allocated mount
struct and never attempt an allocation/destruction itself. The
vfs_allocroot allocation was there to support 'magic' swap space
configuration for diskless clients that was already removed by PHK some
time ago.
4. Include a vfs_buildopts cleanups by Peter Edwards to validate the
sanity of nmount parameters passed from userland.
Submitted by: (4) Peter Edwards <peter.edwards@openet-telecom.com>
Reviewed by: rwatson
Diffstat (limited to 'sys/nfsclient/nfs_vfsops.c')
-rw-r--r-- | sys/nfsclient/nfs_vfsops.c | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 81e256d..b53a200 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -145,7 +145,7 @@ SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, void nfsargs_ntoh(struct nfs_args *); static int nfs_mountdiskless(char *, char *, int, struct sockaddr_in *, struct nfs_args *, - struct thread *, struct vnode **, struct mount **); + struct thread *, struct vnode **, struct mount *); static void nfs_convert_diskless(void); static void nfs_convert_oargs(struct nfs_args *args, struct onfs_args *oargs); @@ -458,14 +458,11 @@ nfs_mountroot(struct mount *mp, struct thread *td) (l >> 8) & 0xff, (l >> 0) & 0xff, nd->root_hostnam); printf("NFS ROOT: %s\n", buf); if ((error = nfs_mountdiskless(buf, "/", MNT_RDONLY, - &nd->root_saddr, &nd->root_args, td, &vp, &mp)) != 0) { + &nd->root_saddr, &nd->root_args, td, &vp, mp)) != 0) { return (error); } - mp->mnt_flag |= MNT_ROOTFS; - mp->mnt_vnodecovered = NULLVP; rootvp = vp; - vfs_unbusy(mp, td); /* * This is not really an nfs issue, but it is much easier to @@ -487,22 +484,10 @@ nfs_mountroot(struct mount *mp, struct thread *td) static int nfs_mountdiskless(char *path, char *which, int mountflag, struct sockaddr_in *sin, struct nfs_args *args, struct thread *td, - struct vnode **vpp, struct mount **mpp) + struct vnode **vpp, struct mount *mp) { - struct mount *mp; struct sockaddr *nam; int error; - int didalloc = 0; - - mp = *mpp; - - if (mp == NULL) { - if ((error = vfs_rootmountalloc("nfs", path, &mp)) != 0) { - printf("nfs_mountroot: NFS not configured"); - return (error); - } - didalloc = 1; - } mp->mnt_kern_flag = 0; mp->mnt_flag = mountflag; @@ -510,15 +495,10 @@ nfs_mountdiskless(char *path, char *which, int mountflag, if ((error = mountnfs(args, mp, nam, which, path, vpp, td->td_ucred)) != 0) { printf("nfs_mountroot: mount %s on %s: %d", path, which, error); - mp->mnt_vfc->vfc_refcount--; - vfs_unbusy(mp, td); - if (didalloc) - free(mp, M_MOUNT); FREE(nam, M_SONAME); return (error); } (void) copystr(which, mp->mnt_stat.f_mntonname, MNAMELEN - 1, 0); - *mpp = mp; return (0); } |