fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _I(x) (((long)(&((nsc_io_t *)0)->x))/sizeof (long))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "CopyDirect", (uintptr_t)nsc_ioerr, _I(copy_direct),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "NodeHints", (uintptr_t)nsc_inval, _I(nodehints),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _nsc_alloc_buf_h(blind_t, nsc_off_t, nsc_size_t, int,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _nsc_copy_h(nsc_buf_t *, nsc_buf_t *, nsc_off_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_alloc_handle(nsc_fd_t *fd, void (*d_cb)(), void (*r_cb)(), void (*w_cb)())
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_buf_t *h = (*fd->sf_aio->alloc_h)(d_cb, r_cb, w_cb, fd->sf_cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((*h->sb_fd->sf_aio->free_h)(h, h->sb_fd->sf_cd));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_alloc_abuf(nsc_off_t pos, nsc_size_t len, int flag, nsc_buf_t **ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((h = (*io->alloc_h)(NULL, NULL, NULL, NSC_ANON_CD)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc <= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte h->sb_fd = (nsc_fd_t *)io; /* note overloaded field */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_alloc_buf(nsc_fd_t *fd, nsc_off_t pos, nsc_size_t len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NSC_NODATA access checks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - NSC_READ|NSC_NODATA is illegal since there would
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be no data buffer to immediately read the data into.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - NSC_WRITE|NSC_NODATA is valid since the client can
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * provide the buffer and then call nsc_write() as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * necessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - NSC_NODATA is valid since the client can provide the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buffer and then call nsc_read() or nsc_write() as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * necessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*fn)(fd->sf_cd, pos, len, flag, ptr, fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_nsc_alloc_buf_h(blind_t cd, nsc_off_t pos, nsc_size_t len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(h = nsc_alloc_handle(fd, NULL, NULL, NULL)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = nsc_alloc_buf(fd, pos, len, flag, &h)) <= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_read(nsc_buf_t *h, nsc_off_t pos, nsc_size_t len, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((h->sb_flag & NSC_NODATA) && h->sb_vec == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((*h->sb_fd->sf_aio->read)(h, pos, len, flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_write(nsc_buf_t *h, nsc_off_t pos, nsc_size_t len, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((h->sb_flag & NSC_NODATA) && h->sb_vec == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((*h->sb_fd->sf_aio->write)(h, pos, len, flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_zero(nsc_buf_t *h, nsc_off_t pos, nsc_size_t len, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((h->sb_flag & NSC_NODATA) && h->sb_vec == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((*h->sb_fd->sf_aio->zero)(h, pos, len, flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_copy(nsc_buf_t *h1, nsc_buf_t *h2, nsc_off_t pos1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((h1->sb_flag & NSC_NODATA) && h1->sb_vec == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((h2->sb_flag & NSC_NODATA) && h2->sb_vec == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_nsc_copy_h(nsc_buf_t *h1, nsc_buf_t *h2, nsc_off_t pos1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sz, l1, l2, lenbytes; /* byte sizes within an nsc_vec_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pos1 < h1->sb_pos || pos1 + len > h1->sb_pos + h1->sb_len ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pos2 < h2->sb_pos || pos2 + len > h2->sb_pos + h2->sb_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find starting point in "from" vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find starting point in "to" vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy required data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_copy_direct(nsc_buf_t *h1, nsc_buf_t *h2, nsc_off_t pos1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((h1->sb_flag & NSC_NODATA) && h1->sb_vec == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((h2->sb_flag & NSC_NODATA) && h2->sb_vec == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "nsc_copy_direct: h2 (%p) flags (%x) include NSC_READ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "nsc_copy_direct: h2 (%p) flags (%x) do not "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (h1->sb_fd && h2->sb_fd && h1->sb_fd->sf_aio == h2->sb_fd->sf_aio)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = (*h1->sb_fd->sf_aio->copy_direct)(h1, h2, pos1, pos2, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The slow way ...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_uncommit(nsc_buf_t *h, nsc_off_t pos, nsc_size_t len, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((*h->sb_fd->sf_aio->uncommit)(h, pos, len, flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((h->sb_flag & NSC_NODATA) && (h->sb_vec != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (_nsc_call_io(_I(nodehints), (blind_t)hints,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (_nsc_call_io(_I(nodehints), (blind_t)(unsigned long)hints,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (_nsc_call_io(_I(sizes), (blind_t)asize, (blind_t)wsize, 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*fd->sf_aio->trksize)(fd->sf_cd, trsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_discard_pinned(nsc_fd_t *fd, nsc_off_t pos, nsc_size_t len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*fd->sf_aio->discard)(fd->sf_cd, pos, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_pinned_data(nsc_iodev_t *iodev, nsc_off_t pos, nsc_size_t len)