Print this page
NEX-3508 CLONE - Port NEX-2946 Add UNMAP/TRIM functionality to ZFS and illumos
Reviewed by: Josef Sipek <josef.sipek@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Conflicts:
    usr/src/uts/common/io/scsi/targets/sd.c
    usr/src/uts/common/sys/scsi/targets/sddef.h
NEX-3023 Panics and hangs when using write_same and compare_and_write
Review by: Bayard Bell <bayard.bell@nexenta.com>
Review by: Rick McNeal <rick.mcneal@nexenta.com>
Review by: Jean McCormack <jean.mccormack@nexenta.com>
Approved by: Jean McCormack <jean.mccormack@nexenta.com>
Related bug: NEX-2723 Kernel panic in xfer_completion code for write_same (0x93) and compare_and_write (0x89)
NEX-1965 Page fault at netbios_first_level_name_decode+0xbb
Support simultaneous compare_and_write operations for VAAI
Bug IDs SUP-505
                SUP-1768
                SUP-1928
Code Reviewers:
        Sarah Jelinek
        Jeffry Molanus
        Albert Lee
        Harold Shaw
OS-69 Open source VAAI
re #7936 rb3706 Support for COMSTAR/OEM
re #8002 rb3706 Allow setting iSCSI vendor ID via stmf_sbd.conf
re #11454 rb3750 Fix inconsistent vid/pid in stmf
8226 nza-kernel needs to be buildable by itself
Re #6790 backspace should perform delete on console
VAAI (XXX ATS support for COMSTAR, YYY Block-copy support for COMSTAR)
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   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  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  23  *
  24  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  25  */
  26 
  27 #ifndef _STMF_SBD_H
  28 #define _STMF_SBD_H
  29 


  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 typedef stmf_status_t   sbd_status_t;

  35 extern char sbd_vendor_id[];
  36 extern char sbd_product_id[];
  37 extern char sbd_revision[];
  38 extern char *sbd_mgmt_url;
  39 extern uint16_t sbd_mgmt_url_alloc_size;
  40 extern krwlock_t sbd_global_prop_lock;
  41 
  42 /*
  43  * Error codes
  44  */
  45 #define SBD_SUCCESS             STMF_SUCCESS
  46 #define SBD_FAILURE             STMF_LU_FAILURE
  47 
  48 #define SBD_ALREADY             (SBD_FAILURE | STMF_FSC(1))
  49 #define SBD_NOT_SUPPORTED       (SBD_FAILURE | STMF_FSC(2))
  50 #define SBD_META_CORRUPTED      (SBD_FAILURE | STMF_FSC(3))
  51 #define SBD_INVALID_ARG         (SBD_FAILURE | STMF_FSC(4))
  52 #define SBD_NOT_FOUND           (SBD_FAILURE | STMF_FSC(5))
  53 #define SBD_ALLOC_FAILURE       (SBD_FAILURE | STMF_FSC(6))
  54 #define SBD_FILEIO_FAILURE      (SBD_FAILURE | STMF_FSC(7))
  55 #define SBD_IO_PAST_EOF         (SBD_FAILURE | STMF_FSC(8))
  56 #define SBD_BUSY                (SBD_FAILURE | STMF_FSC(9))

  57 
  58 #define SHARED_META_DATA_SIZE   65536
  59 #define SBD_META_OFFSET         4096
  60 #define SBD_MIN_LU_SIZE         (1024 * 1024)
  61 
  62 /*
  63  * sms endianess
  64  */
  65 #define SMS_BIG_ENDIAN                  0x00
  66 #define SMS_LITTLE_ENDIAN               0xFF
  67 
  68 #ifdef  _BIG_ENDIAN
  69 #define SMS_DATA_ORDER  SMS_BIG_ENDIAN
  70 #else
  71 #define SMS_DATA_ORDER  SMS_LITTLE_ENDIAN
  72 #endif
  73 
  74 #define SBD_MAGIC       0x53554e5342444c55
  75 
  76 #define SBD_VER_MAJOR           1


 227         void            *sl_zvol_minor_hdl;
 228         void            *sl_zvol_objset_hdl;
 229         void            *sl_zvol_zil_hdl;
 230         void            *sl_zvol_rl_hdl;
 231         void            *sl_zvol_bonus_hdl;
 232 
 233         /* Backing store */
 234         char            *sl_data_filename;
 235         vnode_t         *sl_data_vp;
 236         vtype_t         sl_data_vtype;
 237         uint64_t        sl_total_data_size;
 238         uint64_t        sl_data_readable_size;  /* read() fails after this */
 239         uint64_t        sl_data_offset;         /* After the metadata,if any */
 240         uint64_t        sl_lu_size;             /* READ CAPACITY size */
 241         uint64_t        sl_blksize;             /* used for zvols */
 242         uint64_t        sl_max_xfer_len;        /* used for zvols */
 243 
 244         struct sbd_it_data      *sl_it_list;
 245         struct sbd_pgr          *sl_pgr;
 246         uint64_t        sl_rs_owner_session_id;

 247 } sbd_lu_t;
 248 
 249 /*
 250  * sl_flags
 251  */
 252 #define SL_LINKED                           0x00000001
 253 #define SL_META_OPENED                      0x00000002
 254 #define SL_REGISTERED                       0x00000004
 255 #define SL_META_NEEDS_FLUSH                 0x00000008
 256 #define SL_DATA_NEEDS_FLUSH                 0x00000010
 257 #define SL_VID_VALID                        0x00000020
 258 #define SL_PID_VALID                        0x00000040
 259 #define SL_REV_VALID                        0x00000080
 260 #define SL_WRITE_PROTECTED                  0x00000100
 261 #define SL_MEDIA_LOADED                     0x00000200
 262 #define SL_LU_HAS_SCSI2_RESERVATION         0x00000400
 263 #define SL_WRITEBACK_CACHE_DISABLE          0x00000800
 264 #define SL_SAVED_WRITE_CACHE_DISABLE        0x00001000
 265 #define SL_MEDIUM_REMOVAL_PREVENTED         0x00002000
 266 #define SL_NO_DATA_DKIOFLUSH                0x00004000


 283 #define SL_OP_LU_PROPS                          5
 284 
 285 sbd_status_t sbd_data_read(sbd_lu_t *sl, scsi_task_t *task,
 286     uint64_t offset, uint64_t size, uint8_t *buf);
 287 sbd_status_t sbd_data_write(sbd_lu_t *sl, scsi_task_t *task,
 288     uint64_t offset, uint64_t size, uint8_t *buf);
 289 stmf_status_t sbd_task_alloc(struct scsi_task *task);
 290 void sbd_new_task(struct scsi_task *task, struct stmf_data_buf *initial_dbuf);
 291 void sbd_dbuf_xfer_done(struct scsi_task *task, struct stmf_data_buf *dbuf);
 292 void sbd_send_status_done(struct scsi_task *task);
 293 void sbd_task_free(struct scsi_task *task);
 294 stmf_status_t sbd_abort(struct stmf_lu *lu, int abort_cmd, void *arg,
 295     uint32_t flags);
 296 void sbd_ctl(struct stmf_lu *lu, int cmd, void *arg);
 297 stmf_status_t sbd_info(uint32_t cmd, stmf_lu_t *lu, void *arg, uint8_t *buf,
 298     uint32_t *bufsizep);
 299 sbd_status_t sbd_write_lu_info(sbd_lu_t *sl);
 300 sbd_status_t sbd_flush_data_cache(sbd_lu_t *sl, int fsync_done);
 301 sbd_status_t sbd_wcd_set(int wcd, sbd_lu_t *sl);
 302 void sbd_wcd_get(int *wcd, sbd_lu_t *sl);
 303 int sbd_unmap(sbd_lu_t *, uint64_t, uint64_t);
 304 





 305 #ifdef  __cplusplus
 306 }
 307 #endif
 308 
 309 #endif /* _STMF_SBD_H */
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   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 2015 Nexenta Systems, Inc. All rights reserved.

  25  */
  26 
  27 #ifndef _STMF_SBD_H
  28 #define _STMF_SBD_H
  29 
  30 #include <sys/dkio.h>
  31 
  32 #ifdef  __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 typedef stmf_status_t   sbd_status_t;
  37 #include "ats_copy_mgr.h"
  38 extern char sbd_vendor_id[];
  39 extern char sbd_product_id[];
  40 extern char sbd_revision[];
  41 extern char *sbd_mgmt_url;
  42 extern uint16_t sbd_mgmt_url_alloc_size;
  43 extern krwlock_t sbd_global_prop_lock;
  44 
  45 /*
  46  * Error codes
  47  */
  48 #define SBD_SUCCESS             STMF_SUCCESS
  49 #define SBD_FAILURE             STMF_LU_FAILURE
  50 
  51 #define SBD_ALREADY             (SBD_FAILURE | STMF_FSC(1))
  52 #define SBD_NOT_SUPPORTED       (SBD_FAILURE | STMF_FSC(2))
  53 #define SBD_META_CORRUPTED      (SBD_FAILURE | STMF_FSC(3))
  54 #define SBD_INVALID_ARG         (SBD_FAILURE | STMF_FSC(4))
  55 #define SBD_NOT_FOUND           (SBD_FAILURE | STMF_FSC(5))
  56 #define SBD_ALLOC_FAILURE       (SBD_FAILURE | STMF_FSC(6))
  57 #define SBD_FILEIO_FAILURE      (SBD_FAILURE | STMF_FSC(7))
  58 #define SBD_IO_PAST_EOF         (SBD_FAILURE | STMF_FSC(8))
  59 #define SBD_BUSY                (SBD_FAILURE | STMF_FSC(9))
  60 #define SBD_COMPARE_FAILED      (SBD_FAILURE | STMF_FSC(10))
  61 
  62 #define SHARED_META_DATA_SIZE   65536
  63 #define SBD_META_OFFSET         4096
  64 #define SBD_MIN_LU_SIZE         (1024 * 1024)
  65 
  66 /*
  67  * sms endianess
  68  */
  69 #define SMS_BIG_ENDIAN                  0x00
  70 #define SMS_LITTLE_ENDIAN               0xFF
  71 
  72 #ifdef  _BIG_ENDIAN
  73 #define SMS_DATA_ORDER  SMS_BIG_ENDIAN
  74 #else
  75 #define SMS_DATA_ORDER  SMS_LITTLE_ENDIAN
  76 #endif
  77 
  78 #define SBD_MAGIC       0x53554e5342444c55
  79 
  80 #define SBD_VER_MAJOR           1


 231         void            *sl_zvol_minor_hdl;
 232         void            *sl_zvol_objset_hdl;
 233         void            *sl_zvol_zil_hdl;
 234         void            *sl_zvol_rl_hdl;
 235         void            *sl_zvol_bonus_hdl;
 236 
 237         /* Backing store */
 238         char            *sl_data_filename;
 239         vnode_t         *sl_data_vp;
 240         vtype_t         sl_data_vtype;
 241         uint64_t        sl_total_data_size;
 242         uint64_t        sl_data_readable_size;  /* read() fails after this */
 243         uint64_t        sl_data_offset;         /* After the metadata,if any */
 244         uint64_t        sl_lu_size;             /* READ CAPACITY size */
 245         uint64_t        sl_blksize;             /* used for zvols */
 246         uint64_t        sl_max_xfer_len;        /* used for zvols */
 247 
 248         struct sbd_it_data      *sl_it_list;
 249         struct sbd_pgr          *sl_pgr;
 250         uint64_t        sl_rs_owner_session_id;
 251         list_t          sl_ats_io_list;
 252 } sbd_lu_t;
 253 
 254 /*
 255  * sl_flags
 256  */
 257 #define SL_LINKED                           0x00000001
 258 #define SL_META_OPENED                      0x00000002
 259 #define SL_REGISTERED                       0x00000004
 260 #define SL_META_NEEDS_FLUSH                 0x00000008
 261 #define SL_DATA_NEEDS_FLUSH                 0x00000010
 262 #define SL_VID_VALID                        0x00000020
 263 #define SL_PID_VALID                        0x00000040
 264 #define SL_REV_VALID                        0x00000080
 265 #define SL_WRITE_PROTECTED                  0x00000100
 266 #define SL_MEDIA_LOADED                     0x00000200
 267 #define SL_LU_HAS_SCSI2_RESERVATION         0x00000400
 268 #define SL_WRITEBACK_CACHE_DISABLE          0x00000800
 269 #define SL_SAVED_WRITE_CACHE_DISABLE        0x00001000
 270 #define SL_MEDIUM_REMOVAL_PREVENTED         0x00002000
 271 #define SL_NO_DATA_DKIOFLUSH                0x00004000


 288 #define SL_OP_LU_PROPS                          5
 289 
 290 sbd_status_t sbd_data_read(sbd_lu_t *sl, scsi_task_t *task,
 291     uint64_t offset, uint64_t size, uint8_t *buf);
 292 sbd_status_t sbd_data_write(sbd_lu_t *sl, scsi_task_t *task,
 293     uint64_t offset, uint64_t size, uint8_t *buf);
 294 stmf_status_t sbd_task_alloc(struct scsi_task *task);
 295 void sbd_new_task(struct scsi_task *task, struct stmf_data_buf *initial_dbuf);
 296 void sbd_dbuf_xfer_done(struct scsi_task *task, struct stmf_data_buf *dbuf);
 297 void sbd_send_status_done(struct scsi_task *task);
 298 void sbd_task_free(struct scsi_task *task);
 299 stmf_status_t sbd_abort(struct stmf_lu *lu, int abort_cmd, void *arg,
 300     uint32_t flags);
 301 void sbd_ctl(struct stmf_lu *lu, int cmd, void *arg);
 302 stmf_status_t sbd_info(uint32_t cmd, stmf_lu_t *lu, void *arg, uint8_t *buf,
 303     uint32_t *bufsizep);
 304 sbd_status_t sbd_write_lu_info(sbd_lu_t *sl);
 305 sbd_status_t sbd_flush_data_cache(sbd_lu_t *sl, int fsync_done);
 306 sbd_status_t sbd_wcd_set(int wcd, sbd_lu_t *sl);
 307 void sbd_wcd_get(int *wcd, sbd_lu_t *sl);
 308 int sbd_unmap(sbd_lu_t *sl, dkioc_free_list_t *dfl);
 309 
 310 void sbd_handle_short_write_transfers(scsi_task_t *, stmf_data_buf_t *,
 311     uint32_t);
 312 void sbd_handle_short_read_transfers(scsi_task_t *, stmf_data_buf_t *,
 313     uint8_t *, uint32_t, uint32_t);
 314 
 315 #ifdef  __cplusplus
 316 }
 317 #endif
 318 
 319 #endif /* _STMF_SBD_H */