changeset 4720:8edc0d2e6f3f

6535160 Lock contention on zl_lock from zil_commit
author fr157268
date Tue, 24 Jul 2007 12:49:04 -0700
parents 87b00f87a19c
children 02352f4150be
files usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h usr/src/uts/common/fs/zfs/zfs_ioctl.c usr/src/uts/common/fs/zfs/zfs_log.c usr/src/uts/common/fs/zfs/zfs_vnops.c
diffstat 4 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h	Tue Jul 24 12:17:37 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h	Tue Jul 24 12:49:04 2007 -0700
@@ -96,6 +96,8 @@
 #define	SHORT_FID_LEN	(sizeof (zfid_short_t) - sizeof (uint16_t))
 #define	LONG_FID_LEN	(sizeof (zfid_long_t) - sizeof (uint16_t))
 
+extern uint_t zfs_fsyncer_key;
+
 #ifdef	__cplusplus
 }
 #endif
--- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c	Tue Jul 24 12:17:37 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c	Tue Jul 24 12:49:04 2007 -0700
@@ -2341,6 +2341,9 @@
 	NULL
 };
 
+
+uint_t zfs_fsyncer_key;
+
 int
 _init(void)
 {
@@ -2357,6 +2360,8 @@
 		return (error);
 	}
 
+	tsd_create(&zfs_fsyncer_key, NULL);
+
 	error = ldi_ident_from_mod(&modlinkage, &zfs_li);
 	ASSERT(error == 0);
 	mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
@@ -2383,6 +2388,7 @@
 		(void) ddi_modclose(sharefs_mod);
 	}
 
+	tsd_destroy(&zfs_fsyncer_key);
 	ldi_ident_release(zfs_li);
 	zfs_li = NULL;
 	mutex_destroy(&zfs_share_lock);
--- a/usr/src/uts/common/fs/zfs/zfs_log.c	Tue Jul 24 12:17:37 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/zfs_log.c	Tue Jul 24 12:49:04 2007 -0700
@@ -216,6 +216,7 @@
 {
 	itx_wr_state_t write_state;
 	boolean_t slogging;
+	uintptr_t fsync_cnt;
 
 	if (zilog == NULL || zp->z_unlinked)
 		return;
@@ -245,6 +246,10 @@
 	else
 		write_state = WR_NEED_COPY;
 
+	if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) {
+		(void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1));
+	}
+
 	while (resid) {
 		itx_t *itx;
 		lr_write_t *lr;
@@ -281,7 +286,11 @@
 
 		itx->itx_private = zp->z_zfsvfs;
 
-		itx->itx_sync = (zp->z_sync_cnt != 0);
+		if ((zp->z_sync_cnt != 0) || (fsync_cnt != 0))
+			itx->itx_sync = B_TRUE;
+		else
+			itx->itx_sync = B_FALSE;
+
 		zp->z_last_itx = zil_itx_assign(zilog, itx, tx);
 
 		off += len;
--- a/usr/src/uts/common/fs/zfs/zfs_vnops.c	Tue Jul 24 12:17:37 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/zfs_vnops.c	Tue Jul 24 12:49:04 2007 -0700
@@ -1788,6 +1788,8 @@
 	return (error);
 }
 
+ulong_t zfs_fsync_sync_cnt = 4;
+
 static int
 zfs_fsync(vnode_t *vp, int syncflag, cred_t *cr)
 {
@@ -1804,6 +1806,8 @@
 	    (vp->v_type == VREG) && !(IS_SWAPVP(vp)))
 		(void) VOP_PUTPAGE(vp, (offset_t)0, (size_t)0, B_ASYNC, cr);
 
+	(void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt);
+
 	ZFS_ENTER(zfsvfs);
 	zil_commit(zfsvfs->z_log, zp->z_last_itx, zp->z_id);
 	ZFS_EXIT(zfsvfs);