[Review] Fixes to the VFS layer
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
While working on the vfs-quota branch, I found some problems in the existing
kernel VFS code.
The attached patches correspond to local commits I have created to fix them.
I'm not too sure if what I've done is ideal, and I'd like these patches
to be reviewed before pushing them to master (or not).
They have been applied to two of my machines (one desktop, one database
server), and do not seem to cause any problem.
--
Francois Tigeot
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0008-Fix-a-bug-in-nullfs_mount.patch"
From 5a3d3b25c6ae1d51977f560a46e1d07e3d682f76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Tigeot?= <ftigeot@wolfpond.org>
Date: Sun, 14 Aug 2011 15:13:30 +0200
Subject: [PATCH 08/41] Fix a bug in nullfs_mount()
All filesystems populate the name of their mount point at mount
time. nullfs did not.
---
sys/vfs/nullfs/null_vfsops.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/sys/vfs/nullfs/null_vfsops.c b/sys/vfs/nullfs/null_vfsops.c
index 520fd1c..eb6d5e9 100644
--- a/sys/vfs/nullfs/null_vfsops.c
+++ b/sys/vfs/nullfs/null_vfsops.c
@@ -194,6 +194,13 @@ nullfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
NULLFSDEBUG("nullfs_mount: lower %s, alias at %s\n",
mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntfromname);
+ /* nullfs_statfs doesn't populate f_mntonname */
+ bzero(mp->mnt_stat.f_mntonname, MNAMELEN);
+ if (path != NULL) {
+ (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1,
+ &size);
+ }
+
/*
* Set NCALIASED so unmount won't complain about namecache refs
* still existing.
--
1.7.5.4
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0023-Populate-the-statfs-structure-associated-to-mount-po.patch"
From 81490128d88e55bff4145b37bbc05a7b5fb31c7a Mon Sep 17 00:00:00 2001
From: Francois Tigeot <ftigeot@wolfpond.org>
Date: Mon, 15 Aug 2011 14:42:23 +0200
Subject: [PATCH 23/41] Populate the statfs structure associated to mount
points for Hammer mounts
Contrary to most filesystems, Hammer didn't do it. The new code was taken
from ffs_mount()
---
sys/vfs/hammer/hammer_vfsops.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c
index 4dfb470..fa9e04c 100644
--- a/sys/vfs/hammer/hammer_vfsops.c
+++ b/sys/vfs/hammer/hammer_vfsops.c
@@ -809,6 +809,18 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data,
vflush(mp, 0, 0);
done:
+ if ((mp->mnt_flag & MNT_UPDATE) == 0) {
+ /* New mount */
+
+ /* Populate info for mount point (NULL pad)*/
+ bzero(mp->mnt_stat.f_mntonname, MNAMELEN);
+ size_t size;
+ if (mntpt) {
+ copyinstr(mntpt, mp->mnt_stat.f_mntonname,
+ MNAMELEN -1, &size);
+ }
+ }
+ (void)VFS_STATFS(mp, &mp->mnt_stat, cred);
hammer_rel_volume(rootvol, 0);
failed:
/*
--
1.7.5.4
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0032-Run-VFS_START-for-the-root-mount-point.patch"
From 3d14be346a4c852d6c3379a720ce06eeb77ce314 Mon Sep 17 00:00:00 2001
From: Francois Tigeot <ftigeot@wolfpond.org>
Date: Thu, 25 Aug 2011 11:39:18 +0200
Subject: [PATCH 32/41] Run VFS_START() for the root mount point.
The namecache has to be initialized properly for that. Use code
taken from start_init()
---
sys/kern/vfs_conf.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c
index 8897dd4..cf01a41 100644
--- a/sys/kern/vfs_conf.c
+++ b/sys/kern/vfs_conf.c
@@ -376,6 +376,8 @@ vfs_mountroot_try(const char *mountfrom)
char patt[32];
const char *cp, *ep;
char *mf;
+ struct proc *p;
+ struct vnode *vp;
vfsname = NULL;
devname = NULL;
@@ -449,6 +451,25 @@ end:
/* sanity check system clock against root fs timestamp */
inittodr(mp->mnt_time);
+
+ /* Get the vnode for '/'. Set p->p_fd->fd_cdir to reference it. */
+ mp = mountlist_boot_getfirst();
+ if (VFS_ROOT(mp, &vp))
+ panic("cannot find root vnode");
+ if (mp->mnt_ncmountpt.ncp == NULL) {
+ cache_allocroot(&mp->mnt_ncmountpt, mp, vp);
+ cache_unlock(&mp->mnt_ncmountpt); /* leave ref intact */
+ }
+ p = curproc;
+ p->p_fd->fd_cdir = vp;
+ vref(p->p_fd->fd_cdir);
+ p->p_fd->fd_rdir = vp;
+ vref(p->p_fd->fd_rdir);
+ vfs_cache_setroot(vp, cache_hold(&mp->mnt_ncmountpt));
+ vn_unlock(vp); /* leave ref intact */
+ cache_copy(&mp->mnt_ncmountpt, &p->p_fd->fd_ncdir);
+ cache_copy(&mp->mnt_ncmountpt, &p->p_fd->fd_nrdir);
+
vfs_unbusy(mp);
if (mp->mnt_syncer == NULL) {
error = vfs_allocate_syncvnode(mp);
@@ -456,6 +477,7 @@ end:
kprintf("Warning: no syncer vp for root!\n");
error = 0;
}
+ VFS_START( mp, 0 );
} else {
if (mp != NULL) {
vfs_unbusy(mp);
--
1.7.5.4
--tThc/1wpZn/ma/RB--
討論串 (同標題文章)
完整討論串 (本文為第 3 之 5 篇):