Skip to content

Commit

Permalink
Revert "Remove fastwrite mutex"
Browse files Browse the repository at this point in the history
This reverts commit b10695c which
very likely introduce a difficult to reproduce regression in the
vdev_pending_fastwrite accounting.  This was removed solely as
a potential optimization so it's being reverted in order to resolve
this issue.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#4267
  • Loading branch information
behlendorf committed May 2, 2016
1 parent ef1c271 commit dfdc2e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sys/metaslab_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct metaslab_class {
uint64_t mc_space; /* total space (alloc + free) */
uint64_t mc_dspace; /* total deflated space */
uint64_t mc_histogram[RANGE_TREE_HISTOGRAM_SIZE];
kmutex_t mc_fastwrite_lock;
};

/*
Expand Down
9 changes: 9 additions & 0 deletions module/zfs/metaslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ metaslab_class_create(spa_t *spa, metaslab_ops_t *ops)
mc->mc_spa = spa;
mc->mc_rotor = NULL;
mc->mc_ops = ops;
mutex_init(&mc->mc_fastwrite_lock, NULL, MUTEX_DEFAULT, NULL);

return (mc);
}
Expand All @@ -211,6 +212,7 @@ metaslab_class_destroy(metaslab_class_t *mc)
ASSERT(mc->mc_space == 0);
ASSERT(mc->mc_dspace == 0);

mutex_destroy(&mc->mc_fastwrite_lock);
kmem_free(mc, sizeof (metaslab_class_t));
}

Expand Down Expand Up @@ -2212,6 +2214,9 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
if (psize >= metaslab_gang_bang && (ddi_get_lbolt() & 3) == 0)
return (SET_ERROR(ENOSPC));

if (flags & METASLAB_FASTWRITE)
mutex_enter(&mc->mc_fastwrite_lock);

/*
* Start at the rotor and loop through all mgs until we find something.
* Note that there's no locking on mc_rotor or mc_aliquot because
Expand Down Expand Up @@ -2397,6 +2402,7 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
if (flags & METASLAB_FASTWRITE) {
atomic_add_64(&vd->vdev_pending_fastwrite,
psize);
mutex_exit(&mc->mc_fastwrite_lock);
}

return (0);
Expand All @@ -2420,6 +2426,9 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,

bzero(&dva[d], sizeof (dva_t));

if (flags & METASLAB_FASTWRITE)
mutex_exit(&mc->mc_fastwrite_lock);

return (SET_ERROR(ENOSPC));
}

Expand Down

0 comments on commit dfdc2e2

Please sign in to comment.