[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

getblk Kernel Service

Purpose

Assigns a buffer to the specified block.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/buf.h>
struct buf *getblk 
(dev, blkno) 
dev_t  dev; 
daddr_t  blkno;
  

Parameters

dev Specifies the device containing the block to be allocated.
blkno Specifies the block to be allocated.

Description

The getblk kernel service first checks whether the specified buffer is in the buffer cache. If the buffer resides there, but is in use, the e_sleep service is called to wait until the buffer is no longer in use. Upon waking, the getblk service tries again to access the buffer. If the buffer is in the cache and not in use, it is removed from the free list and marked as busy. Its buffer header is then returned. If the buffer is not in the buffer cache, another buffer is taken from the free list and returned.

Execution Environment

The getblk kernel service can be called from the process environment only.

Return Values

The getblk service returns a pointer to the buffer header. A nonzero value for B_ERROR in the b_flags field of the buffer header (buf structure) indicates an error. If this occurs, the caller should release the block's buffer using the brelse kernel service.

Implementation Specifics

The getblk kernel service is part of Base Operating System (BOS) Runtime.

Related Information

Block I/O Buffer Cache Kernel Services: Overview in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts summarizes how the bread, brelse, and getblk services uniquely manage the block I/O buffer cache.

I/O Kernel Services in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]