Print this page
5255 uts shouldn't open-code ISP2


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2013 by Delphix. All rights reserved.
  26  */
  27 

  28 #include <sys/conf.h>
  29 #include <sys/file.h>
  30 #include <sys/ddi.h>
  31 #include <sys/sunddi.h>
  32 #include <sys/modctl.h>
  33 #include <sys/scsi/scsi.h>
  34 #include <sys/scsi/impl/scsi_reset_notify.h>
  35 #include <sys/disp.h>
  36 #include <sys/byteorder.h>
  37 #include <sys/pathname.h>
  38 #include <sys/atomic.h>
  39 #include <sys/nvpair.h>
  40 #include <sys/fs/zfs.h>
  41 #include <sys/sdt.h>
  42 #include <sys/dkio.h>
  43 #include <sys/zfs_ioctl.h>
  44 
  45 #include <sys/stmf.h>
  46 #include <sys/lpif.h>
  47 #include <sys/stmf_ioctl.h>


1819                 sl->sl_serial_no_size = slu->slu_serial_size;
1820                 p += slu->slu_serial_size;
1821         }
1822         kmem_free(namebuf, sz);
1823         if (slu->slu_vid_valid) {
1824                 bcopy(slu->slu_vid, sl->sl_vendor_id, 8);
1825                 sl->sl_flags |= SL_VID_VALID;
1826         }
1827         if (slu->slu_pid_valid) {
1828                 bcopy(slu->slu_pid, sl->sl_product_id, 16);
1829                 sl->sl_flags |= SL_PID_VALID;
1830         }
1831         if (slu->slu_rev_valid) {
1832                 bcopy(slu->slu_rev, sl->sl_revision, 4);
1833                 sl->sl_flags |= SL_REV_VALID;
1834         }
1835         if (slu->slu_write_protected) {
1836                 sl->sl_flags |= SL_WRITE_PROTECTED;
1837         }
1838         if (slu->slu_blksize_valid) {
1839                 if ((slu->slu_blksize & (slu->slu_blksize - 1)) ||
1840                     (slu->slu_blksize > (32 * 1024)) ||
1841                     (slu->slu_blksize == 0)) {
1842                         *err_ret = SBD_RET_INVALID_BLKSIZE;
1843                         ret = EINVAL;
1844                         goto scm_err_out;
1845                 }
1846                 while ((1 << sl->sl_data_blocksize_shift) != slu->slu_blksize) {
1847                         sl->sl_data_blocksize_shift++;
1848                 }
1849         } else {
1850                 sl->sl_data_blocksize_shift = 9;     /* 512 by default */
1851                 slu->slu_blksize = 512;
1852         }
1853 
1854         /* Now lets start creating meta */
1855         sl->sl_trans_op = SL_OP_CREATE_REGISTER_LU;
1856         if (sbd_link_lu(sl) != SBD_SUCCESS) {
1857                 *err_ret = SBD_RET_FILE_ALREADY_REGISTERED;
1858                 ret = EALREADY;
1859                 goto scm_err_out;




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2013 by Delphix. All rights reserved.
  26  */
  27 
  28 #include <sys/sysmacros.h>
  29 #include <sys/conf.h>
  30 #include <sys/file.h>
  31 #include <sys/ddi.h>
  32 #include <sys/sunddi.h>
  33 #include <sys/modctl.h>
  34 #include <sys/scsi/scsi.h>
  35 #include <sys/scsi/impl/scsi_reset_notify.h>
  36 #include <sys/disp.h>
  37 #include <sys/byteorder.h>
  38 #include <sys/pathname.h>
  39 #include <sys/atomic.h>
  40 #include <sys/nvpair.h>
  41 #include <sys/fs/zfs.h>
  42 #include <sys/sdt.h>
  43 #include <sys/dkio.h>
  44 #include <sys/zfs_ioctl.h>
  45 
  46 #include <sys/stmf.h>
  47 #include <sys/lpif.h>
  48 #include <sys/stmf_ioctl.h>


1820                 sl->sl_serial_no_size = slu->slu_serial_size;
1821                 p += slu->slu_serial_size;
1822         }
1823         kmem_free(namebuf, sz);
1824         if (slu->slu_vid_valid) {
1825                 bcopy(slu->slu_vid, sl->sl_vendor_id, 8);
1826                 sl->sl_flags |= SL_VID_VALID;
1827         }
1828         if (slu->slu_pid_valid) {
1829                 bcopy(slu->slu_pid, sl->sl_product_id, 16);
1830                 sl->sl_flags |= SL_PID_VALID;
1831         }
1832         if (slu->slu_rev_valid) {
1833                 bcopy(slu->slu_rev, sl->sl_revision, 4);
1834                 sl->sl_flags |= SL_REV_VALID;
1835         }
1836         if (slu->slu_write_protected) {
1837                 sl->sl_flags |= SL_WRITE_PROTECTED;
1838         }
1839         if (slu->slu_blksize_valid) {
1840                 if (!ISP2(slu->slu_blksize) ||
1841                     (slu->slu_blksize > (32 * 1024)) ||
1842                     (slu->slu_blksize == 0)) {
1843                         *err_ret = SBD_RET_INVALID_BLKSIZE;
1844                         ret = EINVAL;
1845                         goto scm_err_out;
1846                 }
1847                 while ((1 << sl->sl_data_blocksize_shift) != slu->slu_blksize) {
1848                         sl->sl_data_blocksize_shift++;
1849                 }
1850         } else {
1851                 sl->sl_data_blocksize_shift = 9;     /* 512 by default */
1852                 slu->slu_blksize = 512;
1853         }
1854 
1855         /* Now lets start creating meta */
1856         sl->sl_trans_op = SL_OP_CREATE_REGISTER_LU;
1857         if (sbd_link_lu(sl) != SBD_SUCCESS) {
1858                 *err_ret = SBD_RET_FILE_ALREADY_REGISTERED;
1859                 ret = EALREADY;
1860                 goto scm_err_out;