Skip to content

Commit

Permalink
Illumos openzfs#3743
Browse files Browse the repository at this point in the history
3743 zfs needs a refcount audit
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Christopher Siden <christopher.siden@delphix.com>

References:
  https://www.illumos.org/issues/3743
  illumos/illumos-gate@b287be1

Ported-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#1775
  • Loading branch information
wca authored and unya committed Dec 13, 2013
1 parent 98453d3 commit 3cb58d4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
4 changes: 3 additions & 1 deletion module/zfs/dsl_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,

/* Make sure dsobj has the correct object type. */
dmu_object_info_from_db(dbuf, &doi);
if (doi.doi_type != DMU_OT_DSL_DATASET)
if (doi.doi_type != DMU_OT_DSL_DATASET) {
dmu_buf_rele(dbuf, tag);
return (SET_ERROR(EINVAL));
}

ds = dmu_buf_get_user(dbuf);
if (ds == NULL) {
Expand Down
4 changes: 3 additions & 1 deletion module/zfs/spa_errlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ process_error_log(spa_t *spa, uint64_t obj, void *addr, size_t *count)

if (copyout(&zb, (char *)addr +
(*count - 1) * sizeof (zbookmark_t),
sizeof (zbookmark_t)) != 0)
sizeof (zbookmark_t)) != 0) {
zap_cursor_fini(&zc);
return (SET_ERROR(EFAULT));
}

*count -= 1;
}
Expand Down
38 changes: 24 additions & 14 deletions module/zfs/zap.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ zap_table_load(zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t *valp)
err = dmu_buf_hold(zap->zap_objset, zap->zap_object,
(tbl->zt_nextblk + blk) << bs, FTAG, &db,
DMU_READ_NO_PREFETCH);
dmu_buf_rele(db, FTAG);
if (err == 0)
dmu_buf_rele(db, FTAG);
}
return (err);
}
Expand Down Expand Up @@ -992,18 +993,21 @@ zap_join(objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx)
zap_attribute_t za;
int err;

err = 0;
for (zap_cursor_init(&zc, os, fromobj);
zap_cursor_retrieve(&zc, &za) == 0;
(void) zap_cursor_advance(&zc)) {
if (za.za_integer_length != 8 || za.za_num_integers != 1)
return (SET_ERROR(EINVAL));
if (za.za_integer_length != 8 || za.za_num_integers != 1) {
err = SET_ERROR(EINVAL);
break;
}
err = zap_add(os, intoobj, za.za_name,
8, 1, &za.za_first_integer, tx);
if (err)
return (err);
break;
}
zap_cursor_fini(&zc);
return (0);
return (err);
}

int
Expand All @@ -1014,18 +1018,21 @@ zap_join_key(objset_t *os, uint64_t fromobj, uint64_t intoobj,
zap_attribute_t za;
int err;

err = 0;
for (zap_cursor_init(&zc, os, fromobj);
zap_cursor_retrieve(&zc, &za) == 0;
(void) zap_cursor_advance(&zc)) {
if (za.za_integer_length != 8 || za.za_num_integers != 1)
return (SET_ERROR(EINVAL));
if (za.za_integer_length != 8 || za.za_num_integers != 1) {
err = SET_ERROR(EINVAL);
break;
}
err = zap_add(os, intoobj, za.za_name,
8, 1, &value, tx);
if (err)
return (err);
break;
}
zap_cursor_fini(&zc);
return (0);
return (err);
}

int
Expand All @@ -1036,24 +1043,27 @@ zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj,
zap_attribute_t za;
int err;

err = 0;
for (zap_cursor_init(&zc, os, fromobj);
zap_cursor_retrieve(&zc, &za) == 0;
(void) zap_cursor_advance(&zc)) {
uint64_t delta = 0;

if (za.za_integer_length != 8 || za.za_num_integers != 1)
return (SET_ERROR(EINVAL));
if (za.za_integer_length != 8 || za.za_num_integers != 1) {
err = SET_ERROR(EINVAL);
break;
}

err = zap_lookup(os, intoobj, za.za_name, 8, 1, &delta);
if (err != 0 && err != ENOENT)
return (err);
break;
delta += za.za_first_integer;
err = zap_update(os, intoobj, za.za_name, 8, 1, &delta, tx);
if (err)
return (err);
break;
}
zap_cursor_fini(&zc);
return (0);
return (err);
}

int
Expand Down

0 comments on commit 3cb58d4

Please sign in to comment.