nsc_disk.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* CDDL HEADER START
*
* 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
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#define __NSC_GEN__
#include "nsc_dev.h"
#include "nsc_disk.h"
#include "../nsctl.h"
nsc_def_t _nsc_disk_def[] = {
0, 0, 0
};
extern nsc_mem_t *_nsc_local_mem;
static int _nsc_free_dhandle(nsc_dbuf_t *);
static int _nsc_free_dbuf(nsc_dbuf_t *);
static void _nsc_wait_dbuf(nsc_dbuf_t *);
static nsc_dbuf_t *_nsc_alloc_dhandle(void (*)(), void (*)(), void (*)());
/*
* void
* _nsc_add_disk (nsc_io_t *io)
* Add disk interface functions.
*
* Updates the I/O module with the appropriate
* interface routines.
*
* Description:
* Add functions to the I/O module to provide a disk
* or cache interface as appropriate.
*/
void
{
return;
}
return;
return;
/*
* Layer the generic nsc_buf_t provider onto a uio_t provider.
*/
}
int
{
}
int
{
return (EIO);
}
int
{
*valp = 0;
}
int
{
*valp = 0;
}
int
{
}
/* ARGSUSED */
static int
{
}
/* ARGSUSED */
static int
{
}
static int
{
size_t n;
int rc;
/* prevent non-FBA bounded I/O - this is a disk driver! */
return (EINVAL);
return (rc);
return (rc);
return (ENXIO);
return (0);
}
while (len > 0) {
return (rc);
for (rc = 0;
}
if (rc) {
rc = 0;
}
}
(void) nsc_free_buf(buf);
}
return (rc);
}
/* ARGSUSED */
static nsc_dbuf_t *
{
nsc_dbuf_t *h;
if ((h = nsc_kmem_zalloc(sizeof (nsc_dbuf_t),
return (NULL);
h->db_flag = NSC_HALLOCATED;
return (h);
}
static int
{
nsc_kmem_free(h, sizeof (*h));
return (0);
}
static int
{
nsc_dbuf_t *h = *hp;
int rc;
if (cd == NSC_ANON_CD) {
} else {
if (h->db_maxfbas == 0) {
if (rc != 0)
return (rc);
else if (h->db_maxfbas == 0)
return (EIO);
}
if (len > h->db_maxfbas)
return (ENOSPC);
}
if (flag & NSC_NODATA) {
} else {
if (h->db_disc)
(*h->db_disc)(h);
return (ENOMEM);
}
h->db_error = 0;
if (flag & NSC_NODATA) {
} else {
}
return (NSC_DONE);
_nsc_wait_dbuf(h);
(void) _nsc_free_dbuf(h);
return (rc);
}
}
return (NSC_DONE);
}
static void
{
nsc_dbuf_t *hp;
/* CONSTCOND */
while (1) {
if (!hp)
break;
if (fn)
}
}
static int
{
int wake = 0;
break;
}
}
if (wake)
}
if ((h->db_flag & NSC_HALLOCATED) == 0)
(void) _nsc_free_dhandle(h);
return (0);
}
static int
{
}
static int
{
}
static int
{
}
static int
{
int destidx;
int (*iofn)();
int rc = 0;
return (EIO);
return (EINVAL);
if (!len)
return (0);
return (0);
if (h->db_disc)
(*h->db_disc)(h);
crp = ddi_get_cred();
/*
* determine where in the vector array we should start.
*/
/*
* Loop performing i/o to the underlying driver.
*/
while (todo) {
destidx = 0;
thisio = 0;
/*
* Copy up to _NSC_DBUF_NVEC vector entries from the
* nsc_vec_t into the iovec_t so that the number of
* i/o operations is minimised.
*/
firstentryfix = 0;
if (!iofn) {
}
destidx++;
vp++;
}
if (!iofn) {
iofn = nsc_uwrite;
}
if (rc != 0) {
break;
}
}
return (rc);
}