Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet/dist/uts/common/fs/zfs Operation zfs_zge...



details:   https://anonhg.NetBSD.org/src/rev/be8538b655bf
branches:  trunk
changeset: 932414:be8538b655bf
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu May 07 09:13:06 2020 +0000

description:
Operation zfs_zget_cleaner() cannot fail, comment and add assertions.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c |  27 +++++++++--------
 1 files changed, 14 insertions(+), 13 deletions(-)

diffs (56 lines):

diff -r 8a1c1941577d -r be8538b655bf external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c    Thu May 07 09:12:31 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c    Thu May 07 09:13:06 2020 +0000
@@ -1288,6 +1288,12 @@
        return error;
 }
 
+/*
+ * Get a known cached znode, to be used from zil_commit()->zfs_get_data()
+ * to resolve log entries.  Doesn't take a reference, will never fail and
+ * depends on zfs_vnops.c::zfs_netbsd_reclaim() running a zil_commit()
+ * before the znode gets freed.
+ */
 int
 zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
 {
@@ -1295,31 +1301,26 @@
        sa_handle_t *hdl;
        dmu_object_info_t doi;
        znode_t *zp;
-       int err;
 
        ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num);
 
-       err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db);
-       if (err) {
-               ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-               return (SET_ERROR(err));
-       }
+       VERIFY(0 == sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db));
 
        dmu_object_info_from_db(db, &doi);
-       if (doi.doi_bonus_type != DMU_OT_SA &&
-           (doi.doi_bonus_type != DMU_OT_ZNODE ||
+       ASSERT(doi.doi_bonus_type == DMU_OT_SA ||
            (doi.doi_bonus_type == DMU_OT_ZNODE &&
-           doi.doi_bonus_size < sizeof (znode_phys_t)))) {
-               sa_buf_rele(db, NULL);
-               ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-               return (SET_ERROR(EINVAL));
-       }
+           doi.doi_bonus_size >= sizeof (znode_phys_t)));
+
        hdl = dmu_buf_get_user(db);
        ASSERT3P(hdl, !=, NULL);
+
        zp = sa_get_userdata(hdl);
        ASSERT3U(zp->z_id, ==, obj_num);
+
        sa_buf_rele(db, NULL);
+
        ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
+
        *zpp = zp;
        return (0);
 }



Home | Main Index | Thread Index | Old Index