[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Kernel and Subsystems, 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.

Related Information

Block I/O Buffer Cache Kernel Services: Overview in AIX 5L Version 5.2 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 5L Version 5.2 Kernel Extensions and Device Support Programming Concepts.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]