1113 *zpp = NULL;
1114
1115 ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num);
1116
1117 err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db);
1118 if (err) {
1119 ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
1120 return (err);
1121 }
1122
1123 dmu_object_info_from_db(db, &doi);
1124 if (doi.doi_bonus_type != DMU_OT_SA &&
1125 (doi.doi_bonus_type != DMU_OT_ZNODE ||
1126 (doi.doi_bonus_type == DMU_OT_ZNODE &&
1127 doi.doi_bonus_size < sizeof (znode_phys_t)))) {
1128 sa_buf_rele(db, NULL);
1129 ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
1130 return (SET_ERROR(EINVAL));
1131 }
1132
1133 hdl = dmu_buf_get_user(db);
1134 if (hdl != NULL) {
1135 zp = sa_get_userdata(hdl);
1136
1137
1138 /*
1139 * Since "SA" does immediate eviction we
1140 * should never find a sa handle that doesn't
1141 * know about the znode.
1142 */
1143
1144 ASSERT3P(zp, !=, NULL);
1145
1146 mutex_enter(&zp->z_lock);
1147 ASSERT3U(zp->z_id, ==, obj_num);
1148 if (zp->z_unlinked) {
1149 err = SET_ERROR(ENOENT);
1150 } else {
1151 VN_HOLD(ZTOV(zp));
1152 *zpp = zp;
1153 err = 0;
|
1113 *zpp = NULL;
1114
1115 ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num);
1116
1117 err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db);
1118 if (err) {
1119 ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
1120 return (err);
1121 }
1122
1123 dmu_object_info_from_db(db, &doi);
1124 if (doi.doi_bonus_type != DMU_OT_SA &&
1125 (doi.doi_bonus_type != DMU_OT_ZNODE ||
1126 (doi.doi_bonus_type == DMU_OT_ZNODE &&
1127 doi.doi_bonus_size < sizeof (znode_phys_t)))) {
1128 sa_buf_rele(db, NULL);
1129 ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
1130 return (SET_ERROR(EINVAL));
1131 }
1132
1133 hdl = (sa_handle_t *)dmu_buf_get_user(db);
1134 if (hdl != NULL) {
1135 zp = sa_get_userdata(hdl);
1136
1137
1138 /*
1139 * Since "SA" does immediate eviction we
1140 * should never find a sa handle that doesn't
1141 * know about the znode.
1142 */
1143
1144 ASSERT3P(zp, !=, NULL);
1145
1146 mutex_enter(&zp->z_lock);
1147 ASSERT3U(zp->z_id, ==, obj_num);
1148 if (zp->z_unlinked) {
1149 err = SET_ERROR(ENOENT);
1150 } else {
1151 VN_HOLD(ZTOV(zp));
1152 *zpp = zp;
1153 err = 0;
|