这篇教程C++ zap_update函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zap_update函数的典型用法代码示例。如果您正苦于以下问题:C++ zap_update函数的具体用法?C++ zap_update怎么用?C++ zap_update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zap_update函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: zfs_set_userquotaintzfs_set_userquota(zfs_sb_t *zsb, zfs_userquota_prop_t type, const char *domain, uint64_t rid, uint64_t quota){ char buf[32]; int err; dmu_tx_t *tx; uint64_t *objp; boolean_t fuid_dirtied; if (type != ZFS_PROP_USERQUOTA && type != ZFS_PROP_GROUPQUOTA) return (SET_ERROR(EINVAL)); if (zsb->z_version < ZPL_VERSION_USERSPACE) return (SET_ERROR(ENOTSUP)); objp = (type == ZFS_PROP_USERQUOTA) ? &zsb->z_userquota_obj : &zsb->z_groupquota_obj; err = id_to_fuidstr(zsb, domain, rid, buf, B_TRUE); if (err) return (err); fuid_dirtied = zsb->z_fuid_dirty; tx = dmu_tx_create(zsb->z_os); dmu_tx_hold_zap(tx, *objp ? *objp : DMU_NEW_OBJECT, B_TRUE, NULL); if (*objp == 0) { dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, B_TRUE, zfs_userquota_prop_prefixes[type]); } if (fuid_dirtied) zfs_fuid_txhold(zsb, tx); err = dmu_tx_assign(tx, TXG_WAIT); if (err) { dmu_tx_abort(tx); return (err); } mutex_enter(&zsb->z_lock); if (*objp == 0) { *objp = zap_create(zsb->z_os, DMU_OT_USERGROUP_QUOTA, DMU_OT_NONE, 0, tx); VERIFY(0 == zap_add(zsb->z_os, MASTER_NODE_OBJ, zfs_userquota_prop_prefixes[type], 8, 1, objp, tx)); } mutex_exit(&zsb->z_lock); if (quota == 0) { err = zap_remove(zsb->z_os, *objp, buf, tx); if (err == ENOENT) err = 0; } else { err = zap_update(zsb->z_os, *objp, buf, 8, 1, "a, tx); } ASSERT(err == 0); if (fuid_dirtied) zfs_fuid_sync(zsb, tx); dmu_tx_commit(tx); return (err);}
开发者ID:nwf,项目名称:zfs,代码行数:60,
示例2: zvol_create_cb/* * ZFS_IOC_CREATE callback handles dmu zvol and zap object creation. */voidzvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx){ zfs_creat_t *zct = arg; nvlist_t *nvprops = zct->zct_props; int error; uint64_t volblocksize, volsize; VERIFY(nvlist_lookup_uint64(nvprops, zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) == 0); if (nvlist_lookup_uint64(nvprops, zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &volblocksize) != 0) volblocksize = zfs_prop_default_numeric(ZFS_PROP_VOLBLOCKSIZE); /* * These properties must be removed from the list so the generic * property setting step won't apply to them. */ VERIFY(nvlist_remove_all(nvprops, zfs_prop_to_name(ZFS_PROP_VOLSIZE)) == 0); (void) nvlist_remove_all(nvprops, zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE)); error = dmu_object_claim(os, ZVOL_OBJ, DMU_OT_ZVOL, volblocksize, DMU_OT_NONE, 0, tx); ASSERT(error == 0); error = zap_create_claim(os, ZVOL_ZAP_OBJ, DMU_OT_ZVOL_PROP, DMU_OT_NONE, 0, tx); ASSERT(error == 0); error = zap_update(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize, tx); ASSERT(error == 0);}
开发者ID:alek-p,项目名称:zfs,代码行数:37,
示例3: sa_attr_register_syncstatic voidsa_attr_register_sync(sa_handle_t *hdl, dmu_tx_t *tx){ uint64_t attr_value = 0; sa_os_t *sa = hdl->sa_os->os_sa; sa_attr_table_t *tb = sa->sa_attr_table; int i; mutex_enter(&sa->sa_lock); if (!sa->sa_need_attr_registration || sa->sa_master_obj == NULL) { mutex_exit(&sa->sa_lock); return; } if (sa->sa_reg_attr_obj == NULL) { sa->sa_reg_attr_obj = zap_create(hdl->sa_os, DMU_OT_SA_ATTR_REGISTRATION, DMU_OT_NONE, 0, tx); VERIFY(zap_add(hdl->sa_os, sa->sa_master_obj, SA_REGISTRY, 8, 1, &sa->sa_reg_attr_obj, tx) == 0); } for (i = 0; i != sa->sa_num_attrs; i++) { if (sa->sa_attr_table[i].sa_registered) continue; ATTR_ENCODE(attr_value, tb[i].sa_attr, tb[i].sa_length, tb[i].sa_byteswap); VERIFY(0 == zap_update(hdl->sa_os, sa->sa_reg_attr_obj, tb[i].sa_name, 8, 1, &attr_value, tx)); tb[i].sa_registered = B_TRUE; } sa->sa_need_attr_registration = B_FALSE; mutex_exit(&sa->sa_lock);}
开发者ID:kelsieflynn,项目名称:SamFlynnOS,代码行数:33,
示例4: zvol_update_volsize/* * Ensure the zap is flushed then inform the VFS of the capacity change. */static intzvol_update_volsize(uint64_t volsize, objset_t *os){ dmu_tx_t *tx; int error; uint64_t txg; ASSERT(MUTEX_HELD(&zvol_state_lock)); tx = dmu_tx_create(os); dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); dmu_tx_mark_netfree(tx); error = dmu_tx_assign(tx, TXG_WAIT); if (error) { dmu_tx_abort(tx); return (SET_ERROR(error)); } txg = dmu_tx_get_txg(tx); error = zap_update(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize, tx); dmu_tx_commit(tx); txg_wait_synced(dmu_objset_pool(os), txg); if (error == 0) error = dmu_free_long_range(os, ZVOL_OBJ, volsize, DMU_OBJECT_END); return (error);}
开发者ID:alek-p,项目名称:zfs,代码行数:34,
示例5: feature_sync/* * This function is non-static for zhack; it should otherwise not be used * outside this file. */voidfeature_sync(spa_t *spa, zfeature_info_t *feature, uint64_t refcount, dmu_tx_t *tx){ uint64_t zapobj; ASSERT(VALID_FEATURE_OR_NONE(feature->fi_feature)); zapobj = (feature->fi_flags & ZFEATURE_FLAG_READONLY_COMPAT) ? spa->spa_feat_for_write_obj : spa->spa_feat_for_read_obj; VERIFY0(zap_update(spa->spa_meta_objset, zapobj, feature->fi_guid, sizeof (uint64_t), 1, &refcount, tx)); /* * feature_sync is called directly from zhack, allowing the * creation of arbitrary features whose fi_feature field may * be greater than SPA_FEATURES. When called from zhack, the * zfeature_info_t object's fi_feature field will be set to * SPA_FEATURE_NONE. */ if (feature->fi_feature != SPA_FEATURE_NONE) { uint64_t *refcount_cache = &spa->spa_feat_refcount_cache[feature->fi_feature]; VERIFY3U(*refcount_cache, ==, atomic_swap_64(refcount_cache, refcount)); }
开发者ID:64116278,项目名称:zfs,代码行数:29,
示例6: dsl_scan_sync_statestatic voiddsl_scan_sync_state(dsl_scan_t *scn, dmu_tx_t *tx){ VERIFY0(zap_update(scn->scn_dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCAN, sizeof (uint64_t), SCAN_PHYS_NUMINTS, &scn->scn_phys, tx));}
开发者ID:mcarpenter,项目名称:illumos-gate,代码行数:8,
示例7: sa_add_layout_entrystatic sa_lot_t *sa_add_layout_entry(objset_t *os, sa_attr_type_t *attrs, int attr_count, uint64_t lot_num, uint64_t hash, boolean_t zapadd, dmu_tx_t *tx){ sa_os_t *sa = os->os_sa; sa_lot_t *tb, *findtb; int i; avl_index_t loc; ASSERT(MUTEX_HELD(&sa->sa_lock)); tb = kmem_zalloc(sizeof (sa_lot_t), KM_SLEEP); tb->lot_attr_count = attr_count; tb->lot_attrs = kmem_alloc(sizeof (sa_attr_type_t) * attr_count, KM_SLEEP); bcopy(attrs, tb->lot_attrs, sizeof (sa_attr_type_t) * attr_count); tb->lot_num = lot_num; tb->lot_hash = hash; tb->lot_instance = 0; if (zapadd) { char attr_name[8]; if (sa->sa_layout_attr_obj == 0) { sa->sa_layout_attr_obj = zap_create(os, DMU_OT_SA_ATTR_LAYOUTS, DMU_OT_NONE, 0, tx); VERIFY(zap_add(os, sa->sa_master_obj, SA_LAYOUTS, 8, 1, &sa->sa_layout_attr_obj, tx) == 0); } (void) snprintf(attr_name, sizeof (attr_name), "%d", (int)lot_num); VERIFY(0 == zap_update(os, os->os_sa->sa_layout_attr_obj, attr_name, 2, attr_count, attrs, tx)); } list_create(&tb->lot_idx_tab, sizeof (sa_idx_tab_t), offsetof(sa_idx_tab_t, sa_next)); for (i = 0; i != attr_count; i++) { if (sa->sa_attr_table[tb->lot_attrs[i]].sa_length == 0) tb->lot_var_sizes++; } avl_add(&sa->sa_layout_num_tree, tb); /* verify we don't have a hash collision */ if ((findtb = avl_find(&sa->sa_layout_hash_tree, tb, &loc)) != NULL) { for (; findtb && findtb->lot_hash == hash; findtb = AVL_NEXT(&sa->sa_layout_hash_tree, findtb)) { if (findtb->lot_instance != tb->lot_instance) break; tb->lot_instance++; } } avl_add(&sa->sa_layout_hash_tree, tb); return (tb);}
开发者ID:kelsieflynn,项目名称:SamFlynnOS,代码行数:57,
示例8: vdev_initialize_zap_update_syncstatic voidvdev_initialize_zap_update_sync(void *arg, dmu_tx_t *tx){ /* * We pass in the guid instead of the vdev_t since the vdev may * have been freed prior to the sync task being processed. This * happens when a vdev is detached as we call spa_config_vdev_exit(), * stop the initializing thread, schedule the sync task, and free * the vdev. Later when the scheduled sync task is invoked, it would * find that the vdev has been freed. */ uint64_t guid = *(uint64_t *)arg; uint64_t txg = dmu_tx_get_txg(tx); kmem_free(arg, sizeof (uint64_t)); vdev_t *vd = spa_lookup_by_guid(tx->tx_pool->dp_spa, guid, B_FALSE); if (vd == NULL || vd->vdev_top->vdev_removing || !vdev_is_concrete(vd)) return; uint64_t last_offset = vd->vdev_initialize_offset[txg & TXG_MASK]; vd->vdev_initialize_offset[txg & TXG_MASK] = 0; VERIFY(vd->vdev_leaf_zap != 0); objset_t *mos = vd->vdev_spa->spa_meta_objset; if (last_offset > 0) { vd->vdev_initialize_last_offset = last_offset; VERIFY0(zap_update(mos, vd->vdev_leaf_zap, VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET, sizeof (last_offset), 1, &last_offset, tx)); } if (vd->vdev_initialize_action_time > 0) { uint64_t val = (uint64_t)vd->vdev_initialize_action_time; VERIFY0(zap_update(mos, vd->vdev_leaf_zap, VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME, sizeof (val), 1, &val, tx)); } uint64_t initialize_state = vd->vdev_initialize_state; VERIFY0(zap_update(mos, vd->vdev_leaf_zap, VDEV_LEAF_ZAP_INITIALIZE_STATE, sizeof (initialize_state), 1, &initialize_state, tx));}
开发者ID:Rudd-O,项目名称:zfs,代码行数:44,
示例9: zvol_set_volsizeintzvol_set_volsize(zfs_cmd_t *zc){ zvol_state_t *zv; dev_t dev = zc->zc_dev; dmu_tx_t *tx; int error; dmu_object_info_t doi; mutex_enter(&zvol_state_lock); if ((zv = zvol_minor_lookup(zc->zc_name)) == NULL) { mutex_exit(&zvol_state_lock); return (ENXIO); } if ((error = dmu_object_info(zv->zv_objset, ZVOL_OBJ, &doi)) != 0 || (error = zvol_check_volsize(zc, doi.doi_data_block_size)) != 0) { mutex_exit(&zvol_state_lock); return (error); } if (zv->zv_readonly || (zv->zv_mode & DS_MODE_READONLY)) { mutex_exit(&zvol_state_lock); return (EROFS); } tx = dmu_tx_create(zv->zv_objset); dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); dmu_tx_hold_free(tx, ZVOL_OBJ, zc->zc_volsize, DMU_OBJECT_END); error = dmu_tx_assign(tx, TXG_WAIT); if (error) { dmu_tx_abort(tx); mutex_exit(&zvol_state_lock); return (error); } error = zap_update(zv->zv_objset, ZVOL_ZAP_OBJ, "size", 8, 1, &zc->zc_volsize, tx); if (error == 0) { error = dmu_free_range(zv->zv_objset, ZVOL_OBJ, zc->zc_volsize, DMU_OBJECT_END, tx); } dmu_tx_commit(tx); if (error == 0) { zv->zv_volsize = zc->zc_volsize; zvol_size_changed(zv, dev); } mutex_exit(&zvol_state_lock); return (error);}
开发者ID:andreiw,项目名称:polaris,代码行数:55,
示例10: zfs_set_versionintzfs_set_version(zfs_sb_t *zsb, uint64_t newvers){ int error; objset_t *os = zsb->z_os; dmu_tx_t *tx; if (newvers < ZPL_VERSION_INITIAL || newvers > ZPL_VERSION) return (SET_ERROR(EINVAL)); if (newvers < zsb->z_version) return (SET_ERROR(EINVAL)); if (zfs_spa_version_map(newvers) > spa_version(dmu_objset_spa(zsb->z_os))) return (SET_ERROR(ENOTSUP)); tx = dmu_tx_create(os); dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, B_FALSE, ZPL_VERSION_STR); if (newvers >= ZPL_VERSION_SA && !zsb->z_use_sa) { dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, B_TRUE, ZFS_SA_ATTRS); dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); } error = dmu_tx_assign(tx, TXG_WAIT); if (error) { dmu_tx_abort(tx); return (error); } error = zap_update(os, MASTER_NODE_OBJ, ZPL_VERSION_STR, 8, 1, &newvers, tx); if (error) { dmu_tx_commit(tx); return (error); } if (newvers >= ZPL_VERSION_SA && !zsb->z_use_sa) { uint64_t sa_obj; ASSERT3U(spa_version(dmu_objset_spa(zsb->z_os)), >=, SPA_VERSION_SA); sa_obj = zap_create(os, DMU_OT_SA_MASTER_NODE, DMU_OT_NONE, 0, tx); error = zap_add(os, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj, tx); ASSERT0(error); VERIFY(0 == sa_set_sa_object(os, sa_obj)); sa_register_update_callback(os, zfs_sa_upgrade); }
开发者ID:nwf,项目名称:zfs,代码行数:53,
示例11: zfs_set_versionintzfs_set_version(const char *name, uint64_t newvers){ int error; objset_t *os; dmu_tx_t *tx; uint64_t curvers; /* * XXX for now, require that the filesystem be unmounted. Would * be nice to find the zfsvfs_t and just update that if * possible. */ if (newvers < ZPL_VERSION_INITIAL || newvers > ZPL_VERSION) return (EINVAL); error = dmu_objset_open(name, DMU_OST_ZFS, DS_MODE_PRIMARY, &os); if (error) return (error); error = zap_lookup(os, MASTER_NODE_OBJ, ZPL_VERSION_STR, 8, 1, &curvers); if (error) goto out; if (newvers < curvers) { error = EINVAL; goto out; } tx = dmu_tx_create(os); dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, 0, ZPL_VERSION_STR); error = dmu_tx_assign(tx, TXG_WAIT); if (error) { dmu_tx_abort(tx); goto out; } error = zap_update(os, MASTER_NODE_OBJ, ZPL_VERSION_STR, 8, 1, &newvers, tx); spa_history_internal_log(LOG_DS_UPGRADE, dmu_objset_spa(os), tx, CRED(), "oldver=%llu newver=%llu dataset = %llu", curvers, newvers, dmu_objset_id(os)); dmu_tx_commit(tx);out: dmu_objset_close(os); return (error);}
开发者ID:roddi,项目名称:mac-zfs,代码行数:50,
示例12: zvol_create_cbvoidzvol_create_cb(objset_t *os, void *arg, dmu_tx_t *tx){ zfs_cmd_t *zc = arg; int error; error = dmu_object_claim(os, ZVOL_OBJ, DMU_OT_ZVOL, zc->zc_volblocksize, DMU_OT_NONE, 0, tx); ASSERT(error == 0); error = zap_create_claim(os, ZVOL_ZAP_OBJ, DMU_OT_ZVOL_PROP, DMU_OT_NONE, 0, tx); ASSERT(error == 0); error = zap_update(os, ZVOL_ZAP_OBJ, "size", 8, 1, &zc->zc_volsize, tx); ASSERT(error == 0);}
开发者ID:andreiw,项目名称:polaris,代码行数:17,
示例13: dsl_deleg_set_syncstatic voiddsl_deleg_set_sync(void *arg, dmu_tx_t *tx){ dsl_deleg_arg_t *dda = arg; dsl_dir_t *dd; dsl_pool_t *dp = dmu_tx_pool(tx); objset_t *mos = dp->dp_meta_objset; nvpair_t *whopair = NULL; uint64_t zapobj; VERIFY0(dsl_dir_hold(dp, dda->dda_name, FTAG, &dd, NULL)); zapobj = dd->dd_phys->dd_deleg_zapobj; if (zapobj == 0) { dmu_buf_will_dirty(dd->dd_dbuf, tx); zapobj = dd->dd_phys->dd_deleg_zapobj = zap_create(mos, DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx); } while ((whopair = nvlist_next_nvpair(dda->dda_nvlist, whopair))) { const char *whokey = nvpair_name(whopair); nvlist_t *perms; nvpair_t *permpair = NULL; uint64_t jumpobj; perms = fnvpair_value_nvlist(whopair); if (zap_lookup(mos, zapobj, whokey, 8, 1, &jumpobj) != 0) { jumpobj = zap_create_link(mos, DMU_OT_DSL_PERMS, zapobj, whokey, tx); } while ((permpair = nvlist_next_nvpair(perms, permpair))) { const char *perm = nvpair_name(permpair); uint64_t n = 0; VERIFY(zap_update(mos, jumpobj, perm, 8, 1, &n, tx) == 0); spa_history_log_internal_dd(dd, "permission update", tx, "%s %s", whokey, perm); } } dsl_dir_rele(dd, FTAG);}
开发者ID:GarrisonJ,项目名称:zfs,代码行数:44,
示例14: zfs_create_fsvoidzfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx){ struct super_block *sb; zfs_sb_t *zsb; uint64_t moid, obj, sa_obj, version; uint64_t sense = ZFS_CASE_SENSITIVE; uint64_t norm = 0; nvpair_t *elem; int error; int i; znode_t *rootzp = NULL; vattr_t vattr; znode_t *zp; zfs_acl_ids_t acl_ids; /* * First attempt to create master node. */ /* * In an empty objset, there are no blocks to read and thus * there can be no i/o errors (which we assert below). */ moid = MASTER_NODE_OBJ; error = zap_create_claim(os, moid, DMU_OT_MASTER_NODE, DMU_OT_NONE, 0, tx); ASSERT(error == 0); /* * Set starting attributes. */ version = zfs_zpl_version_map(spa_version(dmu_objset_spa(os))); elem = NULL; while ((elem = nvlist_next_nvpair(zplprops, elem)) != NULL) { /* For the moment we expect all zpl props to be uint64_ts */ uint64_t val; char *name; ASSERT(nvpair_type(elem) == DATA_TYPE_UINT64); VERIFY(nvpair_value_uint64(elem, &val) == 0); name = nvpair_name(elem); if (strcmp(name, zfs_prop_to_name(ZFS_PROP_VERSION)) == 0) { if (val < version) version = val; } else { error = zap_update(os, moid, name, 8, 1, &val, tx); } ASSERT(error == 0); if (strcmp(name, zfs_prop_to_name(ZFS_PROP_NORMALIZE)) == 0) norm = val; else if (strcmp(name, zfs_prop_to_name(ZFS_PROP_CASE)) == 0) sense = val; } ASSERT(version != 0); error = zap_update(os, moid, ZPL_VERSION_STR, 8, 1, &version, tx); /* * Create zap object used for SA attribute registration */ if (version >= ZPL_VERSION_SA) { sa_obj = zap_create(os, DMU_OT_SA_MASTER_NODE, DMU_OT_NONE, 0, tx); error = zap_add(os, moid, ZFS_SA_ATTRS, 8, 1, &sa_obj, tx); ASSERT(error == 0); } else { sa_obj = 0; } /* * Create a delete queue. */ obj = zap_create(os, DMU_OT_UNLINKED_SET, DMU_OT_NONE, 0, tx); error = zap_add(os, moid, ZFS_UNLINKED_SET, 8, 1, &obj, tx); ASSERT(error == 0); /* * Create root znode. Create minimal znode/inode/zsb/sb * to allow zfs_mknode to work. */ vattr.va_mask = ATTR_MODE|ATTR_UID|ATTR_GID; vattr.va_mode = S_IFDIR|0755; vattr.va_uid = crgetuid(cr); vattr.va_gid = crgetgid(cr); rootzp = kmem_cache_alloc(znode_cache, KM_PUSHPAGE); rootzp->z_moved = 0; rootzp->z_unlinked = 0; rootzp->z_atime_dirty = 0; rootzp->z_is_sa = USE_SA(version, os); zsb = kmem_zalloc(sizeof (zfs_sb_t), KM_PUSHPAGE | KM_NODEBUG); zsb->z_os = os; zsb->z_parent = zsb; zsb->z_version = version; zsb->z_use_fuids = USE_FUIDS(version, os); zsb->z_use_sa = USE_SA(version, os); zsb->z_norm = norm; sb = kmem_zalloc(sizeof (struct super_block), KM_PUSHPAGE);//.........这里部分代码省略.........
开发者ID:networkelements,项目名称:zfs,代码行数:101,
示例15: osd_scrub_refresh_mapping/** * update/insert/delete the specified OI mapping (@fid @id) according to the ops * * /retval 1, changed nothing * /retval 0, changed successfully * /retval -ve, on error */static int osd_scrub_refresh_mapping(const struct lu_env *env, struct osd_device *dev, const struct lu_fid *fid, uint64_t oid, int ops, bool force, const char *name){ struct osd_thread_info *info = osd_oti_get(env); struct zpl_direntry *zde = &info->oti_zde.lzd_reg; char *buf = info->oti_str; dmu_tx_t *tx = NULL; dnode_t *dn = NULL; uint64_t zapid; int rc; ENTRY; if (dev->od_scrub.os_file.sf_param & SP_DRYRUN && !force) GOTO(log, rc = 0); tx = dmu_tx_create(dev->od_os); if (!tx) GOTO(log, rc = -ENOMEM); zapid = osd_get_name_n_idx(env, dev, fid, buf, sizeof(info->oti_str), &dn); osd_tx_hold_zap(tx, zapid, dn, ops == DTO_INDEX_INSERT ? TRUE : FALSE, NULL); rc = -dmu_tx_assign(tx, TXG_WAIT); if (rc) { dmu_tx_abort(tx); GOTO(log, rc); } switch (ops) { case DTO_INDEX_UPDATE: zde->zde_pad = 0; zde->zde_dnode = oid; zde->zde_type = 0; /* The type in OI mapping is useless. */ rc = -zap_update(dev->od_os, zapid, buf, 8, sizeof(*zde) / 8, zde, tx); if (unlikely(rc == -ENOENT)) { /* Some unlink thread may removed the OI mapping. */ rc = 1; } break; case DTO_INDEX_INSERT: zde->zde_pad = 0; zde->zde_dnode = oid; zde->zde_type = 0; /* The type in OI mapping is useless. */ rc = osd_zap_add(dev, zapid, dn, buf, 8, sizeof(*zde) / 8, zde, tx); if (unlikely(rc == -EEXIST)) rc = 1; break; case DTO_INDEX_DELETE: rc = osd_zap_remove(dev, zapid, dn, buf, tx); if (rc == -ENOENT) { /* It is normal that the unlink thread has removed the * OI mapping already. */ rc = 1; } break; default: LASSERTF(0, "Unexpected ops %d/n", ops); rc = -EINVAL; break; } dmu_tx_commit(tx); GOTO(log, rc);log: CDEBUG(D_LFSCK, "%s: refresh OI map for scrub, op %d, force %s, " DFID" => %llu (%s): rc = %d/n", osd_name(dev), ops, force ? "yes" : "no", PFID(fid), oid, name ? name : "null", rc); return rc;}
开发者ID:Xyratex,项目名称:lustre-stable,代码行数:84,
示例16: dsl_pool_scrub_setup_sync/* ARGSUSED */static voiddsl_pool_scrub_setup_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx){ dsl_pool_t *dp = arg1; enum scrub_func *funcp = arg2; dmu_object_type_t ot = 0; boolean_t complete = B_FALSE; dsl_pool_scrub_cancel_sync(dp, &complete, cr, tx); ASSERT(dp->dp_scrub_func == SCRUB_FUNC_NONE); ASSERT(*funcp > SCRUB_FUNC_NONE); ASSERT(*funcp < SCRUB_FUNC_NUMFUNCS); dp->dp_scrub_min_txg = 0; dp->dp_scrub_max_txg = tx->tx_txg; dp->dp_scrub_ddt_class_max = zfs_scrub_ddt_class_max; if (*funcp == SCRUB_FUNC_CLEAN) { vdev_t *rvd = dp->dp_spa->spa_root_vdev; /* rewrite all disk labels */ vdev_config_dirty(rvd); if (vdev_resilver_needed(rvd, &dp->dp_scrub_min_txg, &dp->dp_scrub_max_txg)) { spa_event_notify(dp->dp_spa, NULL, ESC_ZFS_RESILVER_START); dp->dp_scrub_max_txg = MIN(dp->dp_scrub_max_txg, tx->tx_txg); } else { spa_event_notify(dp->dp_spa, NULL, ESC_ZFS_SCRUB_START); } /* zero out the scrub stats in all vdev_stat_t's */ vdev_scrub_stat_update(rvd, dp->dp_scrub_min_txg ? POOL_SCRUB_RESILVER : POOL_SCRUB_EVERYTHING, B_FALSE); /* * If this is an incremental scrub, limit the DDT scrub phase * to just the auto-ditto class (for correctness); the rest * of the scrub should go faster using top-down pruning. */ if (dp->dp_scrub_min_txg > TXG_INITIAL) dp->dp_scrub_ddt_class_max = DDT_CLASS_DITTO; dp->dp_spa->spa_scrub_started = B_TRUE; } /* back to the generic stuff */ if (dp->dp_blkstats == NULL) { dp->dp_blkstats = kmem_alloc(sizeof (zfs_all_blkstats_t), KM_SLEEP); } bzero(dp->dp_blkstats, sizeof (zfs_all_blkstats_t)); if (spa_version(dp->dp_spa) < SPA_VERSION_DSL_SCRUB) ot = DMU_OT_ZAP_OTHER; dp->dp_scrub_func = *funcp; dp->dp_scrub_queue_obj = zap_create(dp->dp_meta_objset, ot ? ot : DMU_OT_SCRUB_QUEUE, DMU_OT_NONE, 0, tx); bzero(&dp->dp_scrub_bookmark, sizeof (zbookmark_t)); bzero(&dp->dp_scrub_ddt_bookmark, sizeof (ddt_bookmark_t)); dp->dp_scrub_restart = B_FALSE; dp->dp_spa->spa_scrub_errors = 0; VERIFY(0 == zap_add(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_FUNC, sizeof (uint32_t), 1, &dp->dp_scrub_func, tx)); VERIFY(0 == zap_add(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_QUEUE, sizeof (uint64_t), 1, &dp->dp_scrub_queue_obj, tx)); VERIFY(0 == zap_add(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_MIN_TXG, sizeof (uint64_t), 1, &dp->dp_scrub_min_txg, tx)); VERIFY(0 == zap_add(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_MAX_TXG, sizeof (uint64_t), 1, &dp->dp_scrub_max_txg, tx)); VERIFY(0 == zap_add(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_BOOKMARK, sizeof (uint64_t), sizeof (dp->dp_scrub_bookmark) / sizeof (uint64_t), &dp->dp_scrub_bookmark, tx)); VERIFY(0 == zap_update(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_DDT_BOOKMARK, sizeof (uint64_t), sizeof (dp->dp_scrub_ddt_bookmark) / sizeof (uint64_t), &dp->dp_scrub_ddt_bookmark, tx)); VERIFY(0 == zap_update(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_DDT_CLASS_MAX, sizeof (uint64_t), 1, &dp->dp_scrub_ddt_class_max, tx)); VERIFY(0 == zap_add(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_SCRUB_ERRORS, sizeof (uint64_t), 1, &dp->dp_spa->spa_scrub_errors, tx)); spa_history_internal_log(LOG_POOL_SCRUB, dp->dp_spa, tx, cr, "func=%u mintxg=%llu maxtxg=%llu",//.........这里部分代码省略.........
开发者ID:Anuradha-Talur,项目名称:nfs-ganesha,代码行数:101,
示例17: feature_do_actionstatic intfeature_do_action(objset_t *os, uint64_t read_obj, uint64_t write_obj, uint64_t desc_obj, zfeature_info_t *feature, feature_action_t action, dmu_tx_t *tx){ int error; uint64_t refcount; uint64_t zapobj = feature->fi_can_readonly ? write_obj : read_obj; ASSERT(0 != zapobj); ASSERT(zfeature_is_valid_guid(feature->fi_guid)); error = zap_lookup(os, zapobj, feature->fi_guid, sizeof (uint64_t), 1, &refcount); /* * If we can't ascertain the status of the specified feature, an I/O * error occurred. */ if (error != 0 && error != ENOENT) return (error); switch (action) { case FEATURE_ACTION_ENABLE: /* * If the feature is already enabled, ignore the request. */ if (error == 0) return (0); refcount = 0; break; case FEATURE_ACTION_INCR: if (error == ENOENT) return (ENOTSUP); if (refcount == UINT64_MAX) return (EOVERFLOW); refcount++; break; case FEATURE_ACTION_DECR: if (error == ENOENT) return (ENOTSUP); if (refcount == 0) return (EOVERFLOW); refcount--; break; default: ASSERT(0); break; } if (action == FEATURE_ACTION_ENABLE) { int i; for (i = 0; feature->fi_depends[i] != NULL; i++) { zfeature_info_t *dep = feature->fi_depends[i]; error = feature_do_action(os, read_obj, write_obj, desc_obj, dep, FEATURE_ACTION_ENABLE, tx); if (error != 0) return (error); } } error = zap_update(os, zapobj, feature->fi_guid, sizeof (uint64_t), 1, &refcount, tx); if (error != 0) return (error); if (action == FEATURE_ACTION_ENABLE) { error = zap_update(os, desc_obj, feature->fi_guid, 1, strlen(feature->fi_desc) + 1, feature->fi_desc, tx); if (error != 0) return (error); } if (action == FEATURE_ACTION_INCR && refcount == 1 && feature->fi_mos) { spa_activate_mos_feature(dmu_objset_spa(os), feature->fi_guid); } if (action == FEATURE_ACTION_DECR && refcount == 0) { spa_deactivate_mos_feature(dmu_objset_spa(os), feature->fi_guid); } return (0);}
开发者ID:hisaki,项目名称:osv,代码行数:87,
注:本文中的zap_update函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ zassert函数代码示例 C++ zap_lookup函数代码示例 |