aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zap_micro.c
diff options
context:
space:
mode:
authorGeorge Melikov <[email protected]>2017-01-23 20:36:24 +0300
committerBrian Behlendorf <[email protected]>2017-01-23 09:36:24 -0800
commitf85c06bedfd2a60f5b5d6a7492ed847c2bffd9fe (patch)
treef9088bd3cfb4c9cacdbeae63012ad7d346f4bce8 /module/zfs/zap_micro.c
parent4ea3f86426f76e59244ec6f66504da688d90193c (diff)
OpenZFS 7054 - dmu_tx_hold_t should use refcount_t to track space
Authored by: Igor Kozhukhov [email protected] Reviewed by: George Wilson <[email protected]> Reviewed by: Paul Dagnelie <[email protected]> Reviewed by: Igor Kozhukhov <[email protected]> Approved by: Dan McDonald <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Ported-by: George Melikov [email protected] OpenZFS-issue: https://www.illumos.org/issues/7054 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/0c779ad Closes #5600
Diffstat (limited to 'module/zfs/zap_micro.c')
-rw-r--r--module/zfs/zap_micro.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c
index 7cf7e927c..97c0fff65 100644
--- a/module/zfs/zap_micro.c
+++ b/module/zfs/zap_micro.c
@@ -1552,7 +1552,7 @@ zap_get_stats(objset_t *os, uint64_t zapobj, zap_stats_t *zs)
int
zap_count_write_by_dnode(dnode_t *dn, const char *name, int add,
- uint64_t *towrite, uint64_t *tooverwrite)
+ refcount_t *towrite, refcount_t *tooverwrite)
{
zap_t *zap;
int err = 0;
@@ -1562,14 +1562,15 @@ zap_count_write_by_dnode(dnode_t *dn, const char *name, int add,
* be affected in this operation. So, account for the worst case :
* - 3 blocks overwritten: target leaf, ptrtbl block, header block
* - 4 new blocks written if adding:
- * - 2 blocks for possibly split leaves,
- * - 2 grown ptrtbl blocks
+ * - 2 blocks for possibly split leaves,
+ * - 2 grown ptrtbl blocks
*
* This also accommodates the case where an add operation to a fairly
* large microzap results in a promotion to fatzap.
*/
if (name == NULL) {
- *towrite += (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE;
+ (void) refcount_add_many(towrite,
+ (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE, FTAG);
return (err);
}
@@ -1594,7 +1595,8 @@ zap_count_write_by_dnode(dnode_t *dn, const char *name, int add,
/*
* We treat this case as similar to (name == NULL)
*/
- *towrite += (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE;
+ (void) refcount_add_many(towrite,
+ (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE, FTAG);
}
} else {
/*
@@ -1612,13 +1614,17 @@ zap_count_write_by_dnode(dnode_t *dn, const char *name, int add,
* 4 new blocks written : 2 new split leaf, 2 grown
* ptrtbl blocks
*/
- if (dmu_buf_freeable(zap->zap_dbuf))
- *tooverwrite += MZAP_MAX_BLKSZ;
- else
- *towrite += MZAP_MAX_BLKSZ;
+ if (dmu_buf_freeable(zap->zap_dbuf)) {
+ (void) refcount_add_many(tooverwrite,
+ MZAP_MAX_BLKSZ, FTAG);
+ } else {
+ (void) refcount_add_many(towrite,
+ MZAP_MAX_BLKSZ, FTAG);
+ }
if (add) {
- *towrite += 4 * MZAP_MAX_BLKSZ;
+ (void) refcount_add_many(towrite,
+ 4 * MZAP_MAX_BLKSZ, FTAG);
}
}