Support shared vnode locks for write operations when the offset is

provided on filesystems that support it.  This really improves mysql
+ innodb performance on ZFS.

Reviewed by:	jhb, kmacy, jeffr
This commit is contained in:
Paul Saab 2009-06-04 16:18:07 +00:00
parent c70761e6b5
commit a6d545d8ed
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=193440
3 changed files with 21 additions and 4 deletions

View File

@ -573,6 +573,7 @@ zfs_domount(vfs_t *vfsp, char *osname)
vfsp->mnt_flag |= MNT_LOCAL;
vfsp->mnt_kern_flag |= MNTK_MPSAFE;
vfsp->mnt_kern_flag |= MNTK_LOOKUP_SHARED;
vfsp->mnt_kern_flag |= MNTK_SHARED_WRITES;
if (error = dsl_prop_get_integer(osname, "readonly", &readonly, NULL))
goto out;

View File

@ -367,7 +367,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, active_cred, file_cred,
struct iovec aiov;
struct mount *mp;
struct ucred *cred;
int error;
int error, lock_flags;
VFS_ASSERT_GIANT(vp->v_mount);
@ -378,7 +378,13 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, active_cred, file_cred,
(error = vn_start_write(vp, &mp, V_WAIT | PCATCH))
!= 0)
return (error);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (mp != NULL &&
(mp->mnt_kern_flag & MNTK_SHARED_WRITES)) {
lock_flags = LK_SHARED;
} else {
lock_flags = LK_EXCLUSIVE;
}
vn_lock(vp, lock_flags | LK_RETRY);
} else
vn_lock(vp, LK_SHARED | LK_RETRY);
@ -564,7 +570,7 @@ vn_write(fp, uio, active_cred, flags, td)
{
struct vnode *vp;
struct mount *mp;
int error, ioflag;
int error, ioflag, lock_flags;
int vfslocked;
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
@ -587,7 +593,16 @@ vn_write(fp, uio, active_cred, flags, td)
if (vp->v_type != VCHR &&
(error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
goto unlock;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (vp->v_mount != NULL &&
(vp->v_mount->mnt_kern_flag & MNTK_SHARED_WRITES) &&
(flags & FOF_OFFSET) != 0) {
lock_flags = LK_SHARED;
} else {
lock_flags = LK_EXCLUSIVE;
}
vn_lock(vp, lock_flags | LK_RETRY);
if ((flags & FOF_OFFSET) == 0)
uio->uio_offset = fp->f_offset;
ioflag |= sequential_heuristic(uio, fp);

View File

@ -326,6 +326,7 @@ void __mnt_vnode_markerfree(struct vnode **mvp, struct mount *mp);
#define MNTK_DRAINING 0x00000010 /* lock draining is happening */
#define MNTK_REFEXPIRE 0x00000020 /* refcount expiring is happening */
#define MNTK_EXTENDED_SHARED 0x00000040 /* Allow shared locking for more ops */
#define MNTK_SHARED_WRITES 0x00000080 /* Allow shared locking for writes */
#define MNTK_UNMOUNT 0x01000000 /* unmount in progress */
#define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */
#define MNTK_SUSPEND 0x08000000 /* request write suspension */