FreeBSD ZFS
The Zettabyte File System
Data Structures | Defines | Typedefs | Functions

sys/rrwlock.h File Reference

#include <sys/zfs_context.h>
#include <sys/refcount.h>
Include dependency graph for rrwlock.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rrwlock
 A reader-writer lock implementation that allows re-entrant reads, but still gives writers priority on "new" reads. More...

Defines

#define RRW_READ_HELD(x)   rrw_held(x, RW_READER)
#define RRW_WRITE_HELD(x)   rrw_held(x, RW_WRITER)

Typedefs

typedef struct rrwlock rrwlock_t
 A reader-writer lock implementation that allows re-entrant reads, but still gives writers priority on "new" reads.

Functions

void rrw_init (rrwlock_t *rrl)
void rrw_destroy (rrwlock_t *rrl)
void rrw_enter (rrwlock_t *rrl, krw_t rw, void *tag)
void rrw_exit (rrwlock_t *rrl, void *tag)
boolean_t rrw_held (rrwlock_t *rrl, krw_t rw)

Define Documentation

#define RRW_READ_HELD (   x)    rrw_held(x, RW_READER)

Definition at line 72 of file rrwlock.h.

#define RRW_WRITE_HELD (   x)    rrw_held(x, RW_WRITER)

Definition at line 73 of file rrwlock.h.


Typedef Documentation

typedef struct rrwlock rrwlock_t

A reader-writer lock implementation that allows re-entrant reads, but still gives writers priority on "new" reads.

See rrwlock.c for more details about the implementation.

Fields of the rrwlock_t structure:

  • rr_lock: protects modification and reading of rrwlock_t fields
  • rr_cv: cv for waking up readers or waiting writers
  • rr_writer: thread id of the current writer
  • rr_anon_rount: number of active anonymous readers
  • rr_linked_rcount: total number of non-anonymous active readers
  • rr_writer_wanted: a writer wants the lock

Function Documentation

void rrw_destroy ( rrwlock_t rrl)

Definition at line 147 of file rrwlock.c.

void rrw_enter ( rrwlock_t rrl,
krw_t  rw,
void *  tag 
)
Parameters:
[in]tagUsed in reference count tracking. The value used in rrw_enter() must also be used any corresponding rrw_exit()s.

Definition at line 210 of file rrwlock.c.

void rrw_exit ( rrwlock_t rrl,
void *  tag 
)
Parameters:
[in]tagUsed in reference count tracking. The value used in rrw_exit() must match that used by its corresponding rrw_enter().

Definition at line 224 of file rrwlock.c.

boolean_t rrw_held ( rrwlock_t rrl,
krw_t  rw 
)

Definition at line 260 of file rrwlock.c.

void rrw_init ( rrwlock_t rrl)

Definition at line 136 of file rrwlock.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines