Page MenuHomeFreeBSD

D31405.diff
No OneTemporary

D31405.diff

diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -588,7 +588,7 @@
{
union ctl_io *io = beio->io;
struct mount *mountpoint;
- int error, lock_flags;
+ int error;
DPRINTF("entered\n");
@@ -597,12 +597,8 @@
(void) vn_start_write(be_lun->vn, &mountpoint, V_WAIT);
- if (MNT_SHARED_WRITES(mountpoint) ||
- ((mountpoint == NULL) && MNT_SHARED_WRITES(be_lun->vn->v_mount)))
- lock_flags = LK_SHARED;
- else
- lock_flags = LK_EXCLUSIVE;
- vn_lock(be_lun->vn, lock_flags | LK_RETRY);
+ vn_lock(be_lun->vn, vn_lktype_write(mountpoint, be_lun->vn) |
+ LK_RETRY);
error = VOP_FSYNC(be_lun->vn, beio->io_arg ? MNT_NOWAIT : MNT_WAIT,
curthread);
VOP_UNLOCK(be_lun->vn);
@@ -722,16 +718,10 @@
}
} else {
struct mount *mountpoint;
- int lock_flags;
(void)vn_start_write(be_lun->vn, &mountpoint, V_WAIT);
-
- if (MNT_SHARED_WRITES(mountpoint) || ((mountpoint == NULL)
- && MNT_SHARED_WRITES(be_lun->vn->v_mount)))
- lock_flags = LK_SHARED;
- else
- lock_flags = LK_EXCLUSIVE;
- vn_lock(be_lun->vn, lock_flags | LK_RETRY);
+ vn_lock(be_lun->vn, vn_lktype_write(mountpoint,
+ be_lun->vn) | LK_RETRY);
/*
* UFS pays attention to IO_DIRECT for writes. The write
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -3517,7 +3517,7 @@
struct vnode *vp;
struct mount *mp;
struct file *fp;
- int error, lock_flags;
+ int error;
AUDIT_ARG_FD(fd);
error = getvnode(td, fd, &cap_fsync_rights, &fp);
@@ -3532,13 +3532,7 @@
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0)
goto drop;
- if (MNT_SHARED_WRITES(mp) ||
- ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) {
- lock_flags = LK_SHARED;
- } else {
- lock_flags = LK_EXCLUSIVE;
- }
- vn_lock(vp, lock_flags | LK_RETRY);
+ vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY);
AUDIT_ARG_VNODE1(vp);
if (vp->v_object != NULL) {
VM_OBJECT_WLOCK(vp->v_object);
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -653,11 +653,7 @@
(error = vn_start_write(vp, &mp, V_WAIT | PCATCH))
!= 0)
goto out;
- if (MNT_SHARED_WRITES(mp) ||
- ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount)))
- lock_flags = LK_SHARED;
- else
- lock_flags = LK_EXCLUSIVE;
+ lock_flags = vn_lktype_write(mp, vp);
} else
lock_flags = LK_SHARED;
vn_lock(vp, lock_flags | LK_RETRY);
@@ -1106,7 +1102,7 @@
struct vnode *vp;
struct mount *mp;
off_t orig_offset;
- int error, ioflag, lock_flags;
+ int error, ioflag;
int advice;
bool need_finished_write;
@@ -1147,14 +1143,7 @@
advice = get_advice(fp, uio);
- if (MNT_SHARED_WRITES(mp) ||
- (mp == NULL && MNT_SHARED_WRITES(vp->v_mount))) {
- lock_flags = LK_SHARED;
- } else {
- lock_flags = LK_EXCLUSIVE;
- }
-
- vn_lock(vp, lock_flags | LK_RETRY);
+ vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY);
switch (advice) {
case POSIX_FADV_NORMAL:
case POSIX_FADV_SEQUENTIAL:
@@ -3060,7 +3049,7 @@
{
struct mount *mp;
off_t dataoff, holeoff, xfer2;
- int error, lckf;
+ int error;
/*
* Loop around doing writes of blksize until write has been completed.
@@ -3099,11 +3088,7 @@
VOP_UNLOCK(outvp);
}
} else {
- if (MNT_SHARED_WRITES(mp))
- lckf = LK_SHARED;
- else
- lckf = LK_EXCLUSIVE;
- error = vn_lock(outvp, lckf);
+ error = vn_lock(outvp, vn_lktype_write(mp, outvp));
if (error == 0) {
error = vn_rdwr(UIO_WRITE, outvp, dat, xfer2,
outoff, UIO_SYSSPACE, IO_NODELOCKED,
@@ -3532,3 +3517,12 @@
if (vp2 != NULL)
ASSERT_VOP_ELOCKED(vp2, "vp2 ret");
}
+
+int
+vn_lktype_write(struct mount *mp, struct vnode *vp)
+{
+ if (MNT_SHARED_WRITES(mp) ||
+ (mp == NULL && MNT_SHARED_WRITES(vp->v_mount)))
+ return (LK_SHARED);
+ return (LK_EXCLUSIVE);
+}
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -1089,6 +1089,7 @@
void vn_fsid(struct vnode *vp, struct vattr *va);
int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp);
+int vn_lktype_write(struct mount *mp, struct vnode *vp);
#define VOP_UNLOCK_FLAGS(vp, flags) ({ \
struct vnode *_vp = (vp); \
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -606,7 +606,7 @@
struct mount *mp;
vm_object_t object;
vm_pindex_t pindex;
- int error, lockmode;
+ int error;
object = m->object;
VM_OBJECT_ASSERT_WLOCKED(object);
@@ -640,9 +640,7 @@
vm_object_reference_locked(object);
pindex = m->pindex;
VM_OBJECT_WUNLOCK(object);
- lockmode = MNT_SHARED_WRITES(vp->v_mount) ?
- LK_SHARED : LK_EXCLUSIVE;
- if (vget(vp, lockmode | LK_TIMELOCK)) {
+ if (vget(vp, vn_lktype_write(NULL, vp) | LK_TIMELOCK) != 0) {
vp = NULL;
error = EDEADLK;
goto unlock_mp;

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 3:11 AM (21 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14688944
Default Alt Text
D31405.diff (4 KB)

Event Timeline