xref: /titanic_50/usr/src/man/man9e/strategy.9e (revision 0a70879558a701a07771af87e7852a12f3bfd438)
te
Copyright (c) 2003, Sun Microsystems, Inc., All Rights Reserved.
Copyright 1989 AT&T
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
STRATEGY 9E "Nov 6, 2003"
NAME
strategy - perform block I/O
SYNOPSIS

#include <sys/types.h>
#include <sys/buf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>



int prefixstrategy(struct buf *bp);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI). This entry point is required for block devices.

PARAMETERS
bp

Pointer to the buf(9S) structure.

DESCRIPTION

The strategy() routine is called indirectly (through cb_ops(9S)) by the kernel to read and write blocks of data on the block device. strategy() may also be called directly or indirectly to support the raw character interface of a block device (read(9E), write(9E) and ioctl(9E)). The strategy() routine's responsibility is to set up and initiate the transfer.

In general, strategy() should not block. It can, however, perform a kmem_cache_create(9F) with both the KM_PUSHPAGE and KM_SLEEP flags set, which might block, without causing deadlock in low memory situations.

RETURN VALUES

The strategy() function must return 0. On an error condition, it should call bioerror(9F) to set b_flags to the proper error code, and call biodone(9F). Note that a partial transfer is not considered to be an error.

SEE ALSO

ioctl(9E), read(9E), write(9E), biodone(9F), bioerror(9F), buf(9S), cb_ops(9S), kmem_cache_create(9F)

Writing Device Drivers