Revert "Remove TSD zfs_fsyncer_key"

This reverts commit 31f2b5abdf back
to the original code until the fsync(2) performance regression
can be addressed.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2012-12-20 09:55:47 -08:00
parent 23e3c743f6
commit d5446cfc52
4 changed files with 16 additions and 1 deletions

View File

@ -150,6 +150,8 @@ typedef struct zfid_long {
#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t)) #define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t)) #define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
extern uint_t zfs_fsyncer_key;
extern int zfs_suspend_fs(zfs_sb_t *zsb); extern int zfs_suspend_fs(zfs_sb_t *zsb);
extern int zfs_resume_fs(zfs_sb_t *zsb, const char *osname); extern int zfs_resume_fs(zfs_sb_t *zsb, const char *osname);
extern int zfs_userspace_one(zfs_sb_t *zsb, zfs_userquota_prop_t type, extern int zfs_userspace_one(zfs_sb_t *zsb, zfs_userquota_prop_t type,

View File

@ -5187,6 +5187,7 @@ zfs_detach(void)
list_destroy(&zfsdev_state_list); list_destroy(&zfsdev_state_list);
} }
uint_t zfs_fsyncer_key;
extern uint_t rrw_tsd_key; extern uint_t rrw_tsd_key;
#ifdef DEBUG #ifdef DEBUG
@ -5209,6 +5210,7 @@ _init(void)
if ((error = zfs_attach()) != 0) if ((error = zfs_attach()) != 0)
goto out2; goto out2;
tsd_create(&zfs_fsyncer_key, NULL);
tsd_create(&rrw_tsd_key, NULL); tsd_create(&rrw_tsd_key, NULL);
printk(KERN_NOTICE "ZFS: Loaded module v%s-%s%s, " printk(KERN_NOTICE "ZFS: Loaded module v%s-%s%s, "
@ -5238,6 +5240,7 @@ _fini(void)
zfs_fini(); zfs_fini();
spa_fini(); spa_fini();
tsd_destroy(&zfs_fsyncer_key);
tsd_destroy(&rrw_tsd_key); tsd_destroy(&rrw_tsd_key);
printk(KERN_NOTICE "ZFS: Unloaded module v%s-%s%s\n", printk(KERN_NOTICE "ZFS: Unloaded module v%s-%s%s\n",

View File

@ -457,6 +457,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
{ {
itx_wr_state_t write_state; itx_wr_state_t write_state;
boolean_t slogging; boolean_t slogging;
uintptr_t fsync_cnt;
ssize_t immediate_write_sz; ssize_t immediate_write_sz;
if (zil_replaying(zilog, tx) || zp->z_unlinked) if (zil_replaying(zilog, tx) || zp->z_unlinked)
@ -474,6 +475,10 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
else else
write_state = WR_NEED_COPY; 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) { while (resid) {
itx_t *itx; itx_t *itx;
lr_write_t *lr; lr_write_t *lr;
@ -509,7 +514,8 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
itx->itx_private = ZTOZSB(zp); itx->itx_private = ZTOZSB(zp);
if (!(ioflag & (FSYNC | FDSYNC)) && (zp->z_sync_cnt == 0)) if (!(ioflag & (FSYNC | FDSYNC)) && (zp->z_sync_cnt == 0) &&
(fsync_cnt == 0))
itx->itx_sync = B_FALSE; itx->itx_sync = B_FALSE;
zil_itx_assign(zilog, itx, tx); zil_itx_assign(zilog, itx, tx);

View File

@ -2070,12 +2070,16 @@ out:
} }
EXPORT_SYMBOL(zfs_readdir); EXPORT_SYMBOL(zfs_readdir);
ulong_t zfs_fsync_sync_cnt = 4;
int int
zfs_fsync(struct inode *ip, int syncflag, cred_t *cr) zfs_fsync(struct inode *ip, int syncflag, cred_t *cr)
{ {
znode_t *zp = ITOZ(ip); znode_t *zp = ITOZ(ip);
zfs_sb_t *zsb = ITOZSB(ip); zfs_sb_t *zsb = ITOZSB(ip);
(void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt);
if (zsb->z_os->os_sync != ZFS_SYNC_DISABLED) { if (zsb->z_os->os_sync != ZFS_SYNC_DISABLED) {
ZFS_ENTER(zsb); ZFS_ENTER(zsb);
ZFS_VERIFY_ZP(zp); ZFS_VERIFY_ZP(zp);