Date: Fri, 5 Jul 2013 03:38:54 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r252755 - stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <201307050338.r653csJ2065123@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Fri Jul 5 03:38:53 2013 New Revision: 252755 URL: http://svnweb.freebsd.org/changeset/base/252755 Log: MFC r251632: illumos #3743 zfs needs a refcount audit Audit zap cursor usage and correct missing calls to zap_cursor_fini(). sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c: Correct early exit handling of several functions that previously failed to close a cursor prior to returning. Submitted by: gibbs Audit holders of dmu_bufs and correct missing calls to dmu_buf_rele(). sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c: Correct early exit handling of several functions that previously failed to release a dmu_buf prior to returning. Submitted by: will Reviewed by: Matthew Ahrens <mahrens@delphix.com>, Eric Schrock <eric.schrock@delphix.com>, George Wilson <george.wilson@delphix.com>, Christopher Siden <christopher.siden@delphix.com> Sponsored by: Spectra Logic Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/cddl/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Jul 5 03:38:06 2013 (r252754) +++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Jul 5 03:38:53 2013 (r252755) @@ -361,8 +361,10 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uin /* 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) { Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c ============================================================================== --- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c Fri Jul 5 03:38:06 2013 (r252754) +++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c Fri Jul 5 03:38:53 2013 (r252755) @@ -183,8 +183,10 @@ process_error_log(spa_t *spa, uint64_t o 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; } Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Jul 5 03:38:06 2013 (r252754) +++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Jul 5 03:38:53 2013 (r252755) @@ -295,7 +295,8 @@ zap_table_load(zap_t *zap, zap_table_phy 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); } @@ -992,18 +993,21 @@ zap_join(objset_t *os, uint64_t fromobj, 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 @@ -1014,18 +1018,21 @@ zap_join_key(objset_t *os, uint64_t from 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 @@ -1036,24 +1043,27 @@ zap_join_increment(objset_t *os, uint64_ 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307050338.r653csJ2065123>