mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 19:57:43 +03:00
OpenZFS 7003 - zap_lockdir() should tag hold
zap_lockdir() / zap_unlockdir() should take a "void *tag" argument which tags the hold on the zap. This will help diagnose programming errors which misuse the hold on the ZAP. Sponsored by: Intel Corp. Signed-off-by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Pavel Zakharov <pavel.zakha@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/7003 OpenZFS-commit: https://github.com/openzfs/openzfs/pull/108 Closes #4972
This commit is contained in:
committed by
Brian Behlendorf
parent
ee6370a7a4
commit
8bea981504
+18
-15
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
||||
*/
|
||||
|
||||
@@ -605,7 +605,8 @@ zap_deref_leaf(zap_t *zap, uint64_t h, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp)
|
||||
}
|
||||
|
||||
static int
|
||||
zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
|
||||
zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l,
|
||||
void *tag, dmu_tx_t *tx, zap_leaf_t **lp)
|
||||
{
|
||||
zap_t *zap = zn->zn_zap;
|
||||
uint64_t hash = zn->zn_hash;
|
||||
@@ -627,9 +628,9 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
|
||||
uint64_t object = zap->zap_object;
|
||||
|
||||
zap_put_leaf(l);
|
||||
zap_unlockdir(zap);
|
||||
zap_unlockdir(zap, tag);
|
||||
err = zap_lockdir(os, object, tx, RW_WRITER,
|
||||
FALSE, FALSE, &zn->zn_zap);
|
||||
FALSE, FALSE, tag, &zn->zn_zap);
|
||||
zap = zn->zn_zap;
|
||||
if (err)
|
||||
return (err);
|
||||
@@ -692,7 +693,8 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
|
||||
}
|
||||
|
||||
static void
|
||||
zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx)
|
||||
zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l,
|
||||
void *tag, dmu_tx_t *tx)
|
||||
{
|
||||
zap_t *zap = zn->zn_zap;
|
||||
int shift = zap_f_phys(zap)->zap_ptrtbl.zt_shift;
|
||||
@@ -712,9 +714,9 @@ zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx)
|
||||
objset_t *os = zap->zap_objset;
|
||||
uint64_t zapobj = zap->zap_object;
|
||||
|
||||
zap_unlockdir(zap);
|
||||
zap_unlockdir(zap, tag);
|
||||
err = zap_lockdir(os, zapobj, tx,
|
||||
RW_WRITER, FALSE, FALSE, &zn->zn_zap);
|
||||
RW_WRITER, FALSE, FALSE, tag, &zn->zn_zap);
|
||||
zap = zn->zn_zap;
|
||||
if (err)
|
||||
return;
|
||||
@@ -804,7 +806,7 @@ fzap_lookup(zap_name_t *zn,
|
||||
int
|
||||
fzap_add_cd(zap_name_t *zn,
|
||||
uint64_t integer_size, uint64_t num_integers,
|
||||
const void *val, uint32_t cd, dmu_tx_t *tx)
|
||||
const void *val, uint32_t cd, void *tag, dmu_tx_t *tx)
|
||||
{
|
||||
zap_leaf_t *l;
|
||||
int err;
|
||||
@@ -833,7 +835,7 @@ retry:
|
||||
if (err == 0) {
|
||||
zap_increment_num_entries(zap, 1, tx);
|
||||
} else if (err == EAGAIN) {
|
||||
err = zap_expand_leaf(zn, l, tx, &l);
|
||||
err = zap_expand_leaf(zn, l, tag, tx, &l);
|
||||
zap = zn->zn_zap; /* zap_expand_leaf() may change zap */
|
||||
if (err == 0)
|
||||
goto retry;
|
||||
@@ -841,26 +843,27 @@ retry:
|
||||
|
||||
out:
|
||||
if (zap != NULL)
|
||||
zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx);
|
||||
zap_put_leaf_maybe_grow_ptrtbl(zn, l, tag, tx);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int
|
||||
fzap_add(zap_name_t *zn,
|
||||
uint64_t integer_size, uint64_t num_integers,
|
||||
const void *val, dmu_tx_t *tx)
|
||||
const void *val, void *tag, dmu_tx_t *tx)
|
||||
{
|
||||
int err = fzap_check(zn, integer_size, num_integers);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
|
||||
return (fzap_add_cd(zn, integer_size, num_integers,
|
||||
val, ZAP_NEED_CD, tx));
|
||||
val, ZAP_NEED_CD, tag, tx));
|
||||
}
|
||||
|
||||
int
|
||||
fzap_update(zap_name_t *zn,
|
||||
int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx)
|
||||
int integer_size, uint64_t num_integers, const void *val,
|
||||
void *tag, dmu_tx_t *tx)
|
||||
{
|
||||
zap_leaf_t *l;
|
||||
int err, create;
|
||||
@@ -890,14 +893,14 @@ retry:
|
||||
}
|
||||
|
||||
if (err == EAGAIN) {
|
||||
err = zap_expand_leaf(zn, l, tx, &l);
|
||||
err = zap_expand_leaf(zn, l, tag, tx, &l);
|
||||
zap = zn->zn_zap; /* zap_expand_leaf() may change zap */
|
||||
if (err == 0)
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if (zap != NULL)
|
||||
zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx);
|
||||
zap_put_leaf_maybe_grow_ptrtbl(zn, l, tag, tx);
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user