本文整理汇总了C++中rw_exit函数的典型用法代码示例。如果您正苦于以下问题:C++ rw_exit函数的具体用法?C++ rw_exit怎么用?C++ rw_exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rw_exit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zfs_dirlook
/*
* Look up an entry in a directory.
*
* NOTE: '.' and '..' are handled as special cases because
* no directory entries are actually stored for them. If this is
* the root of a filesystem, then '.zfs' is also treated as a
* special pseudo-directory.
*/
int
zfs_dirlook(znode_t *dzp, char *name, vnode_t **vpp)
{
zfs_dirlock_t *dl;
znode_t *zp;
int error = 0;
if (name[0] == 0 || (name[0] == '.' && name[1] == 0)) {
*vpp = ZTOV(dzp);
VN_HOLD(*vpp);
} else if (name[0] == '.' && name[1] == '.' && name[2] == 0) {
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
/*
* If we are a snapshot mounted under .zfs, return
* the vp for the snapshot directory.
*/
if (dzp->z_phys->zp_parent == dzp->z_id &&
zfsvfs->z_parent != zfsvfs) {
error = zfsctl_root_lookup(zfsvfs->z_parent->z_ctldir,
"snapshot", vpp, NULL, 0, NULL, kcred);
return (error);
}
rw_enter(&dzp->z_parent_lock, RW_READER);
error = zfs_zget(zfsvfs, dzp->z_phys->zp_parent, &zp);
if (error == 0)
*vpp = ZTOV(zp);
rw_exit(&dzp->z_parent_lock);
} else if (zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0) {
*vpp = zfsctl_root(dzp);
} else {
error = zfs_dirent_lock(&dl, dzp, name, &zp, ZEXISTS | ZSHARED);
if (error == 0) {
*vpp = ZTOV(zp);
zfs_dirent_unlock(dl);
dzp->z_zn_prefetch = B_TRUE; /* enable prefetching */
}
}
return (error);
}
示例2: rds_open_transport_driver
int
rds_open_transport_driver()
{
int ret = 0;
rw_enter(&rds_transport_lock, RW_WRITER);
if (rds_transport_handle != NULL) {
/*
* Someone beat us to it.
*/
goto done;
}
if (ibt_hw_is_present() == 0) {
ret = ENODEV;
goto done;
}
if (rds_li == NULL) {
ret = EPROTONOSUPPORT;
goto done;
}
ret = ldi_open_by_name("/devices/ib/[email protected]:rdsib",
FREAD | FWRITE, kcred, &rds_transport_handle, rds_li);
if (ret != 0) {
ret = EPROTONOSUPPORT;
rds_transport_handle = NULL;
goto done;
}
ret = rds_transport_ops->rds_transport_open_ib();
if (ret != 0) {
(void) ldi_close(rds_transport_handle, FNDELAY, kcred);
rds_transport_handle = NULL;
}
done:
rw_exit(&rds_transport_lock);
return (ret);
}
示例3: splat_rwlock_test4_type
static int
splat_rwlock_test4_type(taskq_t *tq, rw_priv_t *rwp, int expected_rc,
krw_t holder_type, krw_t try_type)
{
int id, rc = 0;
/* Schedule a task function which will try and acquire the rwlock
* using type try_type while the rwlock is being held as holder_type.
* The result must match expected_rc for the test to pass */
rwp->rw_rc = -EINVAL;
rwp->rw_type = try_type;
if (holder_type == RW_WRITER || holder_type == RW_READER)
rw_enter(&rwp->rw_rwlock, holder_type);
id = taskq_dispatch(tq, splat_rwlock_test4_func, rwp, TQ_SLEEP);
if (id == 0) {
splat_vprint(rwp->rw_file, SPLAT_RWLOCK_TEST4_NAME, "%s",
"taskq_dispatch() failed\n");
rc = -EINVAL;
goto out;
}
taskq_wait_id(tq, id);
if (rwp->rw_rc != expected_rc)
rc = -EINVAL;
splat_vprint(rwp->rw_file, SPLAT_RWLOCK_TEST4_NAME,
"%srw_tryenter(%s) returned %d (expected %d) when %s\n",
rc ? "Fail " : "", splat_rwlock_test4_name(try_type),
rwp->rw_rc, expected_rc,
splat_rwlock_test4_name(holder_type));
out:
if (holder_type == RW_WRITER || holder_type == RW_READER)
rw_exit(&rwp->rw_rwlock);
return rc;
}
示例4: mod_installexec
/*
* Install an exec module.
*/
static int
mod_installexec(struct modlexec *modl, struct modlinkage *modlp)
{
struct execsw *eswp;
struct modctl *mcp;
char *modname;
char *magic;
size_t magic_size;
/*
* See if execsw entry is already allocated. Can't use findexectype()
* because we may get a recursive call to here.
*/
if ((eswp = findexecsw(modl->exec_execsw->exec_magic)) == NULL) {
mcp = mod_getctl(modlp);
ASSERT(mcp != NULL);
modname = mcp->mod_modname;
magic = modl->exec_execsw->exec_magic;
magic_size = modl->exec_execsw->exec_maglen;
if ((eswp = allocate_execsw(modname, magic, magic_size)) ==
NULL) {
printf("no unused entries in 'execsw'\n");
return (ENOSPC);
}
}
if (eswp->exec_func != NULL) {
printf("exec type %x is already installed\n",
*eswp->exec_magic);
return (EBUSY); /* it's already there! */
}
rw_enter(eswp->exec_lock, RW_WRITER);
eswp->exec_func = modl->exec_execsw->exec_func;
eswp->exec_core = modl->exec_execsw->exec_core;
rw_exit(eswp->exec_lock);
return (0);
}
示例5: zfs_fuid_find_by_idx
/*
* Query domain table by index, returning domain string
*
* Returns a pointer from an avl node of the domain string.
*
*/
const char *
zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx)
{
char *domain;
if (idx == 0 || !zfsvfs->z_use_fuids)
return (NULL);
if (!zfsvfs->z_fuid_loaded)
zfs_fuid_init(zfsvfs);
rw_enter(&zfsvfs->z_fuid_lock, RW_READER);
if (zfsvfs->z_fuid_obj || zfsvfs->z_fuid_dirty)
domain = zfs_fuid_idx_domain(&zfsvfs->z_fuid_idx, idx);
else
domain = nulldomain;
rw_exit(&zfsvfs->z_fuid_lock);
ASSERT(domain);
return (domain);
}
示例6: dsl_dir_stats
void
dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv)
{
mutex_enter(&dd->dd_lock);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
dd->dd_phys->dd_used_bytes);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_QUOTA, dd->dd_phys->dd_quota);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_RESERVATION,
dd->dd_phys->dd_reserved);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO,
dd->dd_phys->dd_compressed_bytes == 0 ? 100 :
(dd->dd_phys->dd_uncompressed_bytes * 100 /
dd->dd_phys->dd_compressed_bytes));
if (dd->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN) {
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDSNAP,
dd->dd_phys->dd_used_breakdown[DD_USED_SNAP]);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDDS,
dd->dd_phys->dd_used_breakdown[DD_USED_HEAD]);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDREFRESERV,
dd->dd_phys->dd_used_breakdown[DD_USED_REFRSRV]);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDCHILD,
dd->dd_phys->dd_used_breakdown[DD_USED_CHILD] +
dd->dd_phys->dd_used_breakdown[DD_USED_CHILD_RSRV]);
}
mutex_exit(&dd->dd_lock);
rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER);
if (dsl_dir_is_clone(dd)) {
dsl_dataset_t *ds;
char buf[MAXNAMELEN];
VERIFY(0 == dsl_dataset_hold_obj(dd->dd_pool,
dd->dd_phys->dd_origin_obj, FTAG, &ds));
dsl_dataset_name(ds, buf);
dsl_dataset_rele(ds, FTAG);
dsl_prop_nvlist_add_string(nv, ZFS_PROP_ORIGIN, buf);
}
rw_exit(&dd->dd_pool->dp_config_rwlock);
}
示例7: vdev_raidz_math_get_ops
/*
* Selects the raidz operation for raidz_map
* If rm_ops is set to NULL original raidz implementation will be used
*/
void
vdev_raidz_math_get_ops(raidz_map_t *rm)
{
rw_enter(&vdev_raidz_impl_lock, RW_READER);
rm->rm_ops = vdev_raidz_used_impl;
#if !defined(_KERNEL)
if (zfs_vdev_raidz_impl == IMPL_CYCLE) {
static size_t cycle_impl_idx = 0;
size_t idx;
/*
* Cycle through all supported new implementations, and
* when idx == raidz_supp_impl_cnt, use the original
*/
idx = (++cycle_impl_idx) % (raidz_supp_impl_cnt + 1);
rm->rm_ops = raidz_supp_impl[idx];
}
#endif
rw_exit(&vdev_raidz_impl_lock);
}
示例8: dmu_spill_hold_by_dnode
/*
* returns ENOENT, EIO, or 0.
*
* This interface will allocate a blank spill dbuf when a spill blk
* doesn't already exist on the dnode.
*
* if you only want to find an already existing spill db, then
* dmu_spill_hold_existing() should be used.
*/
int
dmu_spill_hold_by_dnode(dnode_t *dn, uint32_t flags, void *tag, dmu_buf_t **dbp)
{
dmu_buf_impl_t *db = NULL;
int err;
if ((flags & DB_RF_HAVESTRUCT) == 0)
rw_enter(&dn->dn_struct_rwlock, RW_READER);
db = dbuf_hold(dn, DMU_SPILL_BLKID, tag);
if ((flags & DB_RF_HAVESTRUCT) == 0)
rw_exit(&dn->dn_struct_rwlock);
ASSERT(db != NULL);
err = dbuf_read(db, NULL, flags);
if (err == 0)
*dbp = &db->db;
else
dbuf_rele(db, tag);
return (err);
}
示例9: splat_rwlock_test5
static int
splat_rwlock_test5(struct file *file, void *arg)
{
rw_priv_t *rwp;
int rc = -EINVAL;
rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL);
if (rwp == NULL)
return -ENOMEM;
splat_init_rw_priv(rwp, file);
rw_enter(&rwp->rw_rwlock, RW_WRITER);
if (!RW_WRITE_HELD(&rwp->rw_rwlock)) {
splat_vprint(file, SPLAT_RWLOCK_TEST5_NAME,
"rwlock should be write lock: %d\n",
RW_WRITE_HELD(&rwp->rw_rwlock));
goto out;
}
rw_downgrade(&rwp->rw_rwlock);
if (!RW_READ_HELD(&rwp->rw_rwlock)) {
splat_vprint(file, SPLAT_RWLOCK_TEST5_NAME,
"rwlock should be read lock: %d\n",
RW_READ_HELD(&rwp->rw_rwlock));
goto out;
}
rc = 0;
splat_vprint(file, SPLAT_RWLOCK_TEST5_NAME, "%s",
"rwlock properly downgraded\n");
out:
rw_exit(&rwp->rw_rwlock);
rw_destroy(&rwp->rw_rwlock);
kfree(rwp);
return rc;
}
示例10: pap_putmsg
int64_t pap_putmsg(int fildes, struct strbuf * ctlptr, struct strbuf
* dataptr, int *flagsp)
{
struct strbuf kctlptr;
dl_promiscon_req_t *kpromiscon;
inc_refcnt();
dcmn_err((CE_CONT, "putmsg() syscall.\n"));
rw_enter(&config_rwlock, RW_READER);
if (!config.ppromisc ||
copyin(ctlptr, &kctlptr, sizeof(struct strbuf)) != 0)
goto err;
mutex_enter(&promisc_lock);
kpromiscon = (dl_promiscon_req_t *) kmem_alloc(kctlptr.len, KM_SLEEP);
if (!kpromiscon)
goto err_and_unlock;
if (copyin(kctlptr.buf, kpromiscon, kctlptr.len) != 0)
goto err_and_free;
check_promisc(fildes, kpromiscon);
err_and_free:
kmem_free(kpromiscon, kctlptr.len);
err_and_unlock:
mutex_exit(&promisc_lock);
err:
rw_exit(&config_rwlock);
dec_refcnt();
return syscalls[PUTMSG].sc(fildes, ctlptr, dataptr, flagsp);
}
示例11: cpr_grow_statefile
/*
* increase statefile size
*/
static int
cpr_grow_statefile(vnode_t *vp, u_longlong_t newsize)
{
extern uchar_t cpr_pagecopy[];
struct inode *ip = VTOI(vp);
u_longlong_t offset;
int error, increase;
ssize_t resid;
rw_enter(&ip->i_contents, RW_READER);
increase = (ip->i_size < newsize);
offset = ip->i_size;
rw_exit(&ip->i_contents);
if (increase == 0)
return (0);
/*
* write to each logical block to reserve disk space
*/
error = 0;
cpr_pagecopy[0] = '1';
for (; offset < newsize; offset += ip->i_fs->fs_bsize) {
if (error = vn_rdwr(UIO_WRITE, vp, (caddr_t)cpr_pagecopy,
ip->i_fs->fs_bsize, (offset_t)offset, UIO_SYSSPACE, 0,
(rlim64_t)MAXOFF_T, CRED(), &resid)) {
if (error == ENOSPC) {
cpr_err(CE_WARN, "error %d while reserving "
"disk space for statefile %s\n"
"wanted %lld bytes, file is %lld short",
error, cpr_cprconfig_to_path(),
newsize, newsize - offset);
}
break;
}
}
return (error);
}
示例12: mod_removeexec
/*
* Remove an exec module.
*/
static int
mod_removeexec(struct modlexec *modl, struct modlinkage *modlp)
{
struct execsw *eswp;
struct modctl *mcp;
char *modname;
eswp = findexecsw(modl->exec_execsw->exec_magic);
if (eswp == NULL) {
mcp = mod_getctl(modlp);
ASSERT(mcp != NULL);
modname = mcp->mod_modname;
cmn_err(CE_WARN, uninstall_err, modname);
return (EINVAL);
}
if (moddebug & MODDEBUG_NOAUL_EXEC ||
!rw_tryenter(eswp->exec_lock, RW_WRITER))
return (EBUSY);
eswp->exec_func = NULL;
eswp->exec_core = NULL;
rw_exit(eswp->exec_lock);
return (0);
}
示例13: s1394_cmp_impr_recv_read_request
static void
s1394_cmp_impr_recv_read_request(cmd1394_cmd_t *req)
{
s1394_hal_t *hal = req->cmd_callback_arg;
s1394_cmp_hal_t *cmp = &hal->hal_cmp;
TNF_PROBE_0_DEBUG(s1394_cmp_impr_recv_read_request_enter,
S1394_TNF_SL_CMP_STACK, "");
if (req->cmd_type != CMD1394_ASYNCH_RD_QUAD) {
req->cmd_result = IEEE1394_RESP_TYPE_ERROR;
} else {
rw_enter(&cmp->cmp_impr_rwlock, RW_READER);
req->cmd_u.q.quadlet_data = cmp->cmp_impr_val;
rw_exit(&cmp->cmp_impr_rwlock);
req->cmd_result = IEEE1394_RESP_COMPLETE;
}
(void) s1394_send_response(hal, req);
TNF_PROBE_0_DEBUG(s1394_cmp_impr_recv_read_request_exit,
S1394_TNF_SL_CMP_STACK, "");
}
示例14: nfs4_active_reclaim
static int
nfs4_active_reclaim(void)
{
int freed;
int index;
rnode4_t *rp;
#ifdef DEBUG
clstat4_debug.a_reclaim.value.ui64++;
#endif
freed = 0;
for (index = 0; index < rtable4size; index++) {
rw_enter(&rtable4[index].r_lock, RW_READER);
for (rp = rtable4[index].r_hashf;
rp != (rnode4_t *)(&rtable4[index]);
rp = rp->r_hashf) {
if (nfs4_active_data_reclaim(rp))
freed = 1;
}
rw_exit(&rtable4[index].r_lock);
}
return (freed);
}
示例15: filemon_wrapper_execve
static int
filemon_wrapper_execve(struct lwp * l, struct sys_execve_args * uap,
register_t * retval)
{
char fname[MAXPATHLEN];
int ret;
int error;
size_t done;
struct filemon *filemon;
error = copyinstr(SCARG(uap, path), fname, sizeof(fname), &done);
if ((ret = sys_execve(l, uap, retval)) == EJUSTRETURN && error == 0) {
filemon = filemon_lookup(curproc);
if (filemon) {
filemon_printf(filemon, "E %d %s\n",
curproc->p_pid, fname);
rw_exit(&filemon->fm_mtx);
}
}
return (ret);
}