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

@@ -20,18 +20,19 @@
  */
 
 /*
  * Copyright (c) 1982, 2010, Oracle and/or its affiliates. All rights reserved.
  *
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  */
 
 #ifndef _SYS_DKIO_H
 #define _SYS_DKIO_H
 
 #include <sys/dklabel.h>        /* Needed for NDKMAP define */
+#include <sys/int_limits.h>     /* Needed for UINT16_MAX */
 
 #ifdef  __cplusplus
 extern "C" {
 #endif
 

@@ -521,22 +522,37 @@
 #define FW_TYPE_TEMP    0x0             /* temporary use */
 #define FW_TYPE_PERM    0x1             /* permanent use */
 
 /*
  * ioctl to free space (e.g. SCSI UNMAP) off a disk.
+ * Pass a dkioc_free_list_t containing a list of extents to be freed.
  */
 #define DKIOCFREE       (DKIOC|50)
 
-typedef struct dkioc_free_s {
-        uint32_t df_flags;
-        uint32_t df_reserved;   /* For easy 64-bit alignment below... */
-        diskaddr_t df_start;
-        diskaddr_t df_length;
-} dkioc_free_t;
-
 #define DF_WAIT_SYNC    0x00000001      /* Wait for full write-out of free. */
+typedef struct dkioc_free_list_ext_s {
+        uint64_t                dfle_start;
+        uint64_t                dfle_length;
+} dkioc_free_list_ext_t;
 
+typedef struct dkioc_free_list_s {
+        uint64_t                dfl_flags;
+        uint64_t                dfl_num_exts;
+        int64_t                 dfl_offset;
+
+        /*
+         * N.B. this is only an internal debugging API! This is only called
+         * from debug builds of sd for pre-release checking. Remove before GA!
+         */
+        void                    (*dfl_ck_func)(uint64_t, uint64_t, void *);
+        void                    *dfl_ck_arg;
+
+        dkioc_free_list_ext_t   dfl_exts[1];
+} dkioc_free_list_t;
+#define DFL_SZ(num_exts) \
+        (sizeof (dkioc_free_list_t) + (num_exts - 1) * 16)
+
 #ifdef  __cplusplus
 }
 #endif
 
 #endif /* _SYS_DKIO_H */