summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-05-19 01:28:09 +0000
committeralfred <alfred@FreeBSD.org>2001-05-19 01:28:09 +0000
commita3f0842419d98da211706f921fc626e160cd960b (patch)
treee86922a5639c32e1242d4f3088fc487f3be5b236 /sys/ufs
parent9eda9187f024233436e6a743f13bd938b1a0f19c (diff)
downloadFreeBSD-src-a3f0842419d98da211706f921fc626e160cd960b.zip
FreeBSD-src-a3f0842419d98da211706f921fc626e160cd960b.tar.gz
Introduce a global lock for the vm subsystem (vm_mtx).
vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ufs/ufs_readwrite.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c
index db9e239..672d0a0 100644
--- a/sys/ufs/ufs/ufs_readwrite.c
+++ b/sys/ufs/ufs/ufs_readwrite.c
@@ -114,8 +114,11 @@ READ(ap)
return 0;
}
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_reference(object);
+ mtx_unlock(&vm_mtx);
+ }
#ifdef ENABLE_VFS_IOOPT
/*
@@ -147,8 +150,11 @@ READ(ap)
(vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
ip->i_flag |= IN_ACCESS;
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
return error;
}
}
@@ -192,8 +198,11 @@ READ(ap)
(vp->v_mount->mnt_flag &
MNT_NOATIME) == 0)
ip->i_flag |= IN_ACCESS;
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
return error;
}
/*
@@ -355,8 +364,11 @@ READ(ap)
}
}
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
if ((error == 0 || uio->uio_resid != orig_resid) &&
(vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
ip->i_flag |= IN_ACCESS;
@@ -395,8 +407,11 @@ WRITE(ap)
ip = VTOI(vp);
object = vp->v_object;
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_reference(object);
+ mtx_unlock(&vm_mtx);
+ }
#ifdef DIAGNOSTIC
if (uio->uio_rw != UIO_WRITE)
@@ -408,8 +423,11 @@ WRITE(ap)
if (ioflag & IO_APPEND)
uio->uio_offset = ip->i_size;
if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size) {
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
return (EPERM);
}
/* FALLTHROUGH */
@@ -428,8 +446,11 @@ WRITE(ap)
fs = ip->I_FS;
if (uio->uio_offset < 0 ||
(u_int64_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize) {
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
return (EFBIG);
}
/*
@@ -443,8 +464,11 @@ WRITE(ap)
PROC_LOCK(p);
psignal(p, SIGXFSZ);
PROC_UNLOCK(p);
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
return (EFBIG);
}
@@ -455,9 +479,11 @@ WRITE(ap)
flags = B_SYNC;
if (object && (object->flags & OBJ_OPT)) {
+ mtx_lock(&vm_mtx);
vm_freeze_copyopts(object,
OFF_TO_IDX(uio->uio_offset),
OFF_TO_IDX(uio->uio_offset + uio->uio_resid + PAGE_MASK));
+ mtx_unlock(&vm_mtx);
}
for (error = 0; uio->uio_resid > 0;) {
@@ -546,8 +572,11 @@ WRITE(ap)
} else if (resid > uio->uio_resid && (ioflag & IO_SYNC))
error = UFS_UPDATE(vp, 1);
- if (object)
+ if (object) {
+ mtx_lock(&vm_mtx);
vm_object_vndeallocate(object);
+ mtx_unlock(&vm_mtx);
+ }
return (error);
}
OpenPOWER on IntegriCloud