summaryrefslogtreecommitdiffstats
path: root/sys/gnu
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2002-09-19 13:32:45 +0000
committertruckman <truckman@FreeBSD.org>2002-09-19 13:32:45 +0000
commitf2807820032fe586ea72f9048accb23a9d17c75f (patch)
treefed75b0fd3d3243127e21c52a13f663281ff50f1 /sys/gnu
parent38695c19fde9598c887707063c968842a2395e6c (diff)
downloadFreeBSD-src-f2807820032fe586ea72f9048accb23a9d17c75f.zip
FreeBSD-src-f2807820032fe586ea72f9048accb23a9d17c75f.tar.gz
VOP_FSYNC() requires that it's vnode argument be locked, which nfs_link()
wasn't doing. Rather than just lock and unlock the vnode around the call to VOP_FSYNC(), implement rwatson's suggestion to lock the file vnode in kern_link() before calling VOP_LINK(), since the other filesystems also locked the file vnode right away in their link methods. Remove the locking and and unlocking from the leaf filesystem link methods. Reviewed by: rwatson, bde (except for the unionfs_link() changes)
Diffstat (limited to 'sys/gnu')
-rw-r--r--sys/gnu/ext2fs/ext2_vnops.c15
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vnops.c15
2 files changed, 8 insertions, 22 deletions
diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c
index dd24a9d..c1fba78 100644
--- a/sys/gnu/ext2fs/ext2_vnops.c
+++ b/sys/gnu/ext2fs/ext2_vnops.c
@@ -827,7 +827,6 @@ ext2_link(ap)
struct vnode *vp = ap->a_vp;
struct vnode *tdvp = ap->a_tdvp;
struct componentname *cnp = ap->a_cnp;
- struct thread *td = cnp->cn_thread;
struct inode *ip;
int error;
@@ -837,19 +836,16 @@ ext2_link(ap)
#endif
if (tdvp->v_mount != vp->v_mount) {
error = EXDEV;
- goto out2;
- }
- if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, td))) {
- goto out2;
+ goto out;
}
ip = VTOI(vp);
if ((nlink_t)ip->i_nlink >= LINK_MAX) {
error = EMLINK;
- goto out1;
+ goto out;
}
if (ip->i_flags & (IMMUTABLE | APPEND)) {
error = EPERM;
- goto out1;
+ goto out;
}
ip->i_nlink++;
ip->i_flag |= IN_CHANGE;
@@ -860,10 +856,7 @@ ext2_link(ap)
ip->i_nlink--;
ip->i_flag |= IN_CHANGE;
}
-out1:
- if (tdvp != vp)
- VOP_UNLOCK(vp, 0, td);
-out2:
+out:
return (error);
}
diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c
index dd24a9d..c1fba78 100644
--- a/sys/gnu/fs/ext2fs/ext2_vnops.c
+++ b/sys/gnu/fs/ext2fs/ext2_vnops.c
@@ -827,7 +827,6 @@ ext2_link(ap)
struct vnode *vp = ap->a_vp;
struct vnode *tdvp = ap->a_tdvp;
struct componentname *cnp = ap->a_cnp;
- struct thread *td = cnp->cn_thread;
struct inode *ip;
int error;
@@ -837,19 +836,16 @@ ext2_link(ap)
#endif
if (tdvp->v_mount != vp->v_mount) {
error = EXDEV;
- goto out2;
- }
- if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, td))) {
- goto out2;
+ goto out;
}
ip = VTOI(vp);
if ((nlink_t)ip->i_nlink >= LINK_MAX) {
error = EMLINK;
- goto out1;
+ goto out;
}
if (ip->i_flags & (IMMUTABLE | APPEND)) {
error = EPERM;
- goto out1;
+ goto out;
}
ip->i_nlink++;
ip->i_flag |= IN_CHANGE;
@@ -860,10 +856,7 @@ ext2_link(ap)
ip->i_nlink--;
ip->i_flag |= IN_CHANGE;
}
-out1:
- if (tdvp != vp)
- VOP_UNLOCK(vp, 0, td);
-out2:
+out:
return (error);
}
OpenPOWER on IntegriCloud