da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Common Development and Distribution License (the "License").
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "../nsctl.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _I(x) (((long)(&((nsc_io_t *)0)->x))/sizeof (long))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_uread(dev_t, uio_t *, cred_t *, nsc_fd_t *);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_uwrite(dev_t, uio_t *, cred_t *, nsc_fd_t *);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_alloc_dbuf(blind_t, nsc_off_t, nsc_size_t, int, nsc_dbuf_t **);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_read_dbuf(nsc_dbuf_t *, nsc_off_t, nsc_size_t, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_write_dbuf(nsc_dbuf_t *, nsc_off_t, nsc_size_t, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_zero_dbuf(nsc_dbuf_t *, nsc_off_t, nsc_size_t, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic int _nsc_dbuf_io(int (*)(), nsc_dbuf_t *, nsc_off_t, nsc_size_t, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic nsc_dbuf_t *_nsc_alloc_dhandle(void (*)(), void (*)(), void (*)());
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * _nsc_add_disk (nsc_io_t *io)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Add disk interface functions.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Updates the I/O module with the appropriate
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * interface routines.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Description:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Add functions to the I/O module to provide a disk
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * or cache interface as appropriate.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if ((io->alloc_buf != nsc_ioerr && io->free_buf != nsc_fatal) ||
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin io->free_h != nsc_fatal || io->alloc_buf != nsc_ioerr ||
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Layer the generic nsc_buf_t provider onto a uio_t provider.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return (*fd->sf_aio->uwrite)(fd->sf_cd, uiop, crp, fd);
size_t n;
return (EINVAL);
return (rc);
return (rc);
return (ENXIO);
while (len > 0) {
return (rc);
for (rc = 0;
if (rc) {
rc = 0;
return (rc);
static nsc_dbuf_t *
nsc_dbuf_t *h;
return (NULL);
nsc_kmem_free(h, sizeof (*h));
if (h->db_maxfbas == 0) {
if (rc != 0)
return (rc);
else if (h->db_maxfbas == 0)
return (EIO);
return (ENOSPC);
if (h->db_disc)
(*h->db_disc)(h);
return (ENOMEM);
h->db_error = 0;
return (NSC_DONE);
_nsc_wait_dbuf(h);
(void) _nsc_free_dbuf(h);
return (rc);
return (NSC_DONE);
if (!hp)
if (fn)
if (wake)
(void) _nsc_free_dhandle(h);
int (*iofn)();
return (EIO);
return (EINVAL);
if (!len)
if (h->db_disc)
(*h->db_disc)(h);
while (todo) {
destidx = 0;
thisio = 0;
firstentryfix = 0;
if (!iofn) {
destidx++;
vp++;
if (!iofn) {
if (rc != 0) {
return (rc);