Skip to content

Commit d5446cf

Browse files
committed
Revert "Remove TSD zfs_fsyncer_key"
This reverts commit 31f2b5a back to the original code until the fsync(2) performance regression can be addressed. Signed-off-by: Brian Behlendorf <[email protected]>
1 parent 23e3c74 commit d5446cf

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

include/sys/zfs_vfsops.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ typedef struct zfid_long {
150150
#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
151151
#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
152152

153+
extern uint_t zfs_fsyncer_key;
154+
153155
extern int zfs_suspend_fs(zfs_sb_t *zsb);
154156
extern int zfs_resume_fs(zfs_sb_t *zsb, const char *osname);
155157
extern int zfs_userspace_one(zfs_sb_t *zsb, zfs_userquota_prop_t type,

module/zfs/zfs_ioctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,6 +5187,7 @@ zfs_detach(void)
51875187
list_destroy(&zfsdev_state_list);
51885188
}
51895189

5190+
uint_t zfs_fsyncer_key;
51905191
extern uint_t rrw_tsd_key;
51915192

51925193
#ifdef DEBUG
@@ -5209,6 +5210,7 @@ _init(void)
52095210
if ((error = zfs_attach()) != 0)
52105211
goto out2;
52115212

5213+
tsd_create(&zfs_fsyncer_key, NULL);
52125214
tsd_create(&rrw_tsd_key, NULL);
52135215

52145216
printk(KERN_NOTICE "ZFS: Loaded module v%s-%s%s, "
@@ -5238,6 +5240,7 @@ _fini(void)
52385240
zfs_fini();
52395241
spa_fini();
52405242

5243+
tsd_destroy(&zfs_fsyncer_key);
52415244
tsd_destroy(&rrw_tsd_key);
52425245

52435246
printk(KERN_NOTICE "ZFS: Unloaded module v%s-%s%s\n",

module/zfs/zfs_log.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
457457
{
458458
itx_wr_state_t write_state;
459459
boolean_t slogging;
460+
uintptr_t fsync_cnt;
460461
ssize_t immediate_write_sz;
461462

462463
if (zil_replaying(zilog, tx) || zp->z_unlinked)
@@ -474,6 +475,10 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
474475
else
475476
write_state = WR_NEED_COPY;
476477

478+
if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) {
479+
(void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1));
480+
}
481+
477482
while (resid) {
478483
itx_t *itx;
479484
lr_write_t *lr;
@@ -509,7 +514,8 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
509514

510515
itx->itx_private = ZTOZSB(zp);
511516

512-
if (!(ioflag & (FSYNC | FDSYNC)) && (zp->z_sync_cnt == 0))
517+
if (!(ioflag & (FSYNC | FDSYNC)) && (zp->z_sync_cnt == 0) &&
518+
(fsync_cnt == 0))
513519
itx->itx_sync = B_FALSE;
514520

515521
zil_itx_assign(zilog, itx, tx);

module/zfs/zfs_vnops.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,12 +2070,16 @@ zfs_readdir(struct inode *ip, void *dirent, filldir_t filldir,
20702070
}
20712071
EXPORT_SYMBOL(zfs_readdir);
20722072

2073+
ulong_t zfs_fsync_sync_cnt = 4;
2074+
20732075
int
20742076
zfs_fsync(struct inode *ip, int syncflag, cred_t *cr)
20752077
{
20762078
znode_t *zp = ITOZ(ip);
20772079
zfs_sb_t *zsb = ITOZSB(ip);
20782080

2081+
(void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt);
2082+
20792083
if (zsb->z_os->os_sync != ZFS_SYNC_DISABLED) {
20802084
ZFS_ENTER(zsb);
20812085
ZFS_VERIFY_ZP(zp);

0 commit comments

Comments
 (0)