示例#1
0
static int
zcp_props_list(lua_State *state)
{
	const char *dsname = lua_tostring(state, 1);
	dsl_pool_t *dp = zcp_run_info(state)->zri_pool;
	objset_t *os;
	nvlist_t **props = lua_newuserdata(state, sizeof (nvlist_t *));

	dsl_dataset_t *ds = zcp_dataset_hold(state, dp, dsname, FTAG);
	if (ds == NULL)
		return (1); /* not reached; zcp_dataset_hold() longjmp'd */
	VERIFY0(dmu_objset_from_ds(ds, &os));
	VERIFY0(dsl_prop_get_all(os, props));
	dsl_dataset_rele(ds, FTAG);

	/*
	 * Set the metatable for the properties list to free it on completion.
	 */
	luaL_getmetatable(state, zcp_props_list_info.name);
	(void) lua_setmetatable(state, -2);

	lua_pushlightuserdata(state, NULL);
	lua_pushcclosure(state, &zcp_props_iter, 2);
	return (1);
}
示例#2
0
static int libzfs_update_stats(zfs_handle_t *p_zfs)
{
        objset_t *p_os;
        nvlist_t *pnv_allprops, *pnv_userprops;
        int i_error;

        if((i_error = dmu_objset_hold(p_zfs->zfs_name, FTAG, &p_os)))
                return i_error;

        dmu_objset_fast_stat(p_os, &p_zfs->zfs_dmustats);

        if((i_error = dsl_prop_get_all(p_os, &pnv_allprops)) == 0)
        {
                dmu_objset_stats(p_os, pnv_allprops);
                if(!p_zfs->zfs_dmustats.dds_inconsistent)
                {
                        if(dmu_objset_type(p_os) == DMU_OST_ZVOL)
                                assert(zvol_get_stats(p_os, pnv_allprops) == 0);
                }
        }

        dmu_objset_rele(p_os, FTAG);

        // Continue processing the stats
        if((pnv_userprops = process_user_props(p_zfs, pnv_allprops)) == NULL)
        {
                nvlist_free(pnv_allprops);
                return 1;
        }

        nvlist_free(p_zfs->zfs_props);
        nvlist_free(p_zfs->zfs_user_props);

        p_zfs->zfs_props = pnv_allprops;
        p_zfs->zfs_user_props = pnv_userprops;

        return 0;
}