Date: Wed, 23 Sep 1998 01:15:38 -0400 (EDT) From: Luoqi Chen <luoqi@watermarkgroup.com> To: current@FreeBSD.ORG Subject: Official softupdates patch for testers Message-ID: <199809230515.BAA08476@lor.watermarkgroup.com>
next in thread | raw e-mail | index | archive | help
The following is the official patch to fix the 'initiate_write_filepage' panic,
plus two changes requested by Bruce Evans,
1. Do not test for vn_lock() failures if LK_RETRY flag bit is set, vn_lock
can't fail in this case.
2. In fsync() syscall, always call VOP_FSYNC() with MNT_WAIT flag. This would
make it a little safer for async mount and keep us in sync with other BSDs.
Please send any feedback to me <luoqi@freebsd.org>. Thanks.
-lq
Index: sys/sys/buf.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/buf.h,v
retrieving revision 1.56
diff -u -r1.56 buf.h
--- buf.h 1998/09/15 08:55:01 1.56
+++ buf.h 1998/09/23 04:50:50
@@ -48,6 +48,7 @@
struct buf;
struct mount;
+struct vnode;
/*
* To avoid including <ufs/ffs/softdep.h>
@@ -63,6 +64,7 @@
void (*io_start) __P((struct buf *));
void (*io_complete) __P((struct buf *));
void (*io_deallocate) __P((struct buf *));
+ int (*io_fsync) __P((struct vnode *));
int (*io_sync) __P((struct mount *));
} bioops;
Index: sys/kern/vfs_syscalls.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.106
diff -u -r1.106 vfs_syscalls.c
--- vfs_syscalls.c 1998/09/10 02:27:52 1.106
+++ vfs_syscalls.c 1998/09/23 04:53:41
@@ -1818,10 +1818,7 @@
struct vattr vattr;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- if (error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)) {
- return error;
- }
-
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
VATTR_NULL(&vattr);
vattr.va_flags = flags;
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
@@ -1892,12 +1889,9 @@
{
int error;
struct vattr vattr;
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- if (error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)) {
- return error;
- }
-
+ VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
VATTR_NULL(&vattr);
vattr.va_mode = mode & ALLPERMS;
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
@@ -1998,12 +1992,9 @@
{
int error;
struct vattr vattr;
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- if (error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)) {
- return error;
- }
-
+ VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
VATTR_NULL(&vattr);
vattr.va_uid = uid;
vattr.va_gid = gid;
@@ -2115,11 +2106,7 @@
struct vattr vattr;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
-
- if (error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)) {
- return error;
- }
-
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
VATTR_NULL(&vattr);
vattr.va_atime.tv_sec = tv[0].tv_sec;
vattr.va_atime.tv_nsec = tv[0].tv_usec * 1000;
@@ -2421,22 +2408,14 @@
if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
return (error);
vp = (struct vnode *)fp->f_data;
- if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)) == NULL) {
- if (vp->v_object) {
- vm_object_page_clean(vp->v_object, 0, 0, FALSE);
- }
- if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP)) {
- error = VOP_FSYNC(vp, fp->f_cred, MNT_LAZY, p);
- } else {
- error = VOP_FSYNC(vp, fp->f_cred,
- (vp->v_mount && (vp->v_mount->mnt_flag & MNT_ASYNC)) ?
- MNT_NOWAIT : MNT_WAIT, p);
- }
- VOP_UNLOCK(vp, 0, p);
-
- if ((vp->v_mount->mnt_flag & MNT_SOFTDEP) && bioops.io_sync)
- (*bioops.io_sync)(NULL);
- }
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
+ if (vp->v_object)
+ vm_object_page_clean(vp->v_object, 0, 0, FALSE);
+ if ((error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p)) == 0 &&
+ vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) &&
+ bioops.io_fsync)
+ error = (*bioops.io_fsync)(vp);
+ VOP_UNLOCK(vp, 0, p);
return (error);
}
Index: sys/ufs/ffs/ffs_vnops.c
===================================================================
RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_vnops.c,v
retrieving revision 1.51
diff -u -r1.51 ffs_vnops.c
--- ffs_vnops.c 1998/09/07 11:50:19 1.51
+++ ffs_vnops.c 1998/09/22 23:36:57
@@ -249,9 +249,5 @@
}
splx(s);
getmicrotime(&tv);
- if ((error = UFS_UPDATE(vp, &tv, &tv, ap->a_waitfor == MNT_WAIT)) != 0)
- return (error);
- if (DOINGSOFTDEP(vp) && ap->a_waitfor == MNT_WAIT)
- error = softdep_fsync(vp);
- return (error);
+ return (UFS_UPDATE(vp, &tv, &tv, ap->a_waitfor == MNT_WAIT));
}
Index: contrib/sys/softupdates/ffs_softdep.c
===================================================================
RCS file: /home/ncvs/src/contrib/sys/softupdates/ffs_softdep.c,v
retrieving revision 1.13
diff -u -r1.13 ffs_softdep.c
--- ffs_softdep.c 1998/08/12 20:46:47 1.13
+++ ffs_softdep.c 1998/09/23 04:54:32
@@ -209,6 +209,7 @@
softdep_disk_io_initiation, /* io_start */
softdep_disk_write_complete, /* io_complete */
softdep_deallocate_dependencies, /* io_deallocate */
+ softdep_fsync, /* io_fsync */
softdep_process_worklist, /* io_sync */
};
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809230515.BAA08476>
